@vasfal/vellum 0.1.0 → 0.1.2
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/.next/BUILD_ID +1 -1
- package/.next/app-path-routes-manifest.json +5 -5
- package/.next/build-manifest.json +13 -14
- package/.next/next-minimal-server.js.nft.json +1 -1
- package/.next/next-server.js.nft.json +1 -1
- package/.next/prerender-manifest.json +3 -3
- package/.next/required-server-files.js +2 -0
- package/.next/required-server-files.json +2 -0
- package/.next/server/app/(app)/page.js +2 -15
- package/.next/server/app/(app)/page.js.nft.json +1 -1
- package/.next/server/app/(app)/page_client-reference-manifest.js +1 -3
- package/.next/server/app/(app)/session/[name]/page.js +2 -15
- package/.next/server/app/(app)/session/[name]/page.js.nft.json +1 -1
- package/.next/server/app/(app)/session/[name]/page_client-reference-manifest.js +1 -3
- package/.next/server/app/(app)/settings/key/page.js +2 -15
- package/.next/server/app/(app)/settings/key/page.js.nft.json +1 -1
- package/.next/server/app/(app)/settings/key/page_client-reference-manifest.js +1 -3
- package/.next/server/app/_global-error/page.js +32 -9
- package/.next/server/app/_global-error/page.js.nft.json +1 -1
- package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -3
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.meta +2 -1
- package/.next/server/app/_global-error.rsc +7 -7
- package/.next/server/app/_global-error.segments/_full.segment.rsc +7 -7
- package/.next/server/app/_global-error.segments/{__PAGE__.segment.rsc → _global-error/__PAGE__.segment.rsc} +2 -2
- package/.next/server/app/_global-error.segments/_global-error.segment.rsc +5 -0
- package/.next/server/app/_global-error.segments/_head.segment.rsc +3 -3
- package/.next/server/app/_global-error.segments/_index.segment.rsc +3 -3
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page.js +2 -13
- package/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -3
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +14 -12
- package/.next/server/app/_not-found.segments/_full.segment.rsc +14 -12
- package/.next/server/app/_not-found.segments/_head.segment.rsc +4 -4
- package/.next/server/app/_not-found.segments/_index.segment.rsc +6 -6
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +3 -3
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +4 -2
- package/.next/server/app/api/analyze/route.js +12 -9
- package/.next/server/app/api/analyze/route.js.nft.json +1 -1
- package/.next/server/app/api/analyze/route_client-reference-manifest.js +1 -3
- package/.next/server/app/api/key/route.js +1 -8
- package/.next/server/app/api/key/route.js.nft.json +1 -1
- package/.next/server/app/api/key/route_client-reference-manifest.js +1 -3
- package/.next/server/app/api/key-status/route.js +1 -7
- package/.next/server/app/api/key-status/route.js.nft.json +1 -1
- package/.next/server/app/api/key-status/route_client-reference-manifest.js +1 -3
- package/.next/server/app/api/models/route.js +1 -7
- package/.next/server/app/api/models/route.js.nft.json +1 -1
- package/.next/server/app/api/models/route_client-reference-manifest.js +1 -3
- package/.next/server/app/api/revise/route.js +1 -8
- package/.next/server/app/api/revise/route.js.nft.json +1 -1
- package/.next/server/app/api/revise/route_client-reference-manifest.js +1 -3
- package/.next/server/app/icon.svg/route.js +1 -7
- package/.next/server/app/icon.svg/route.js.nft.json +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +24 -27
- package/.next/server/app/index.segments/!KGFwcCk/__PAGE__.segment.rsc +6 -6
- package/.next/server/app/index.segments/!KGFwcCk.segment.rsc +9 -9
- package/.next/server/app/index.segments/_full.segment.rsc +24 -27
- package/.next/server/app/index.segments/_head.segment.rsc +4 -4
- package/.next/server/app/index.segments/_index.segment.rsc +6 -6
- package/.next/server/app/index.segments/_tree.segment.rsc +4 -4
- package/.next/server/app/record-test/page.js +8 -14
- package/.next/server/app/record-test/page.js.nft.json +1 -1
- package/.next/server/app/record-test/page_client-reference-manifest.js +1 -3
- package/.next/server/app/record-test.html +2 -2
- package/.next/server/app/record-test.rsc +16 -16
- package/.next/server/app/record-test.segments/_full.segment.rsc +16 -16
- package/.next/server/app/record-test.segments/_head.segment.rsc +4 -4
- package/.next/server/app/record-test.segments/_index.segment.rsc +6 -6
- package/.next/server/app/record-test.segments/_tree.segment.rsc +4 -4
- package/.next/server/app/record-test.segments/record-test/__PAGE__.segment.rsc +4 -4
- package/.next/server/app/record-test.segments/record-test.segment.rsc +3 -3
- package/.next/server/app/settings/key.html +1 -1
- package/.next/server/app/settings/key.rsc +28 -34
- package/.next/server/app/settings/key.segments/!KGFwcCk/settings/key/__PAGE__.segment.rsc +5 -5
- package/.next/server/app/settings/key.segments/!KGFwcCk/settings/key.segment.rsc +3 -3
- package/.next/server/app/settings/key.segments/!KGFwcCk/settings.segment.rsc +3 -3
- package/.next/server/app/settings/key.segments/!KGFwcCk.segment.rsc +9 -9
- package/.next/server/app/settings/key.segments/_full.segment.rsc +28 -34
- package/.next/server/app/settings/key.segments/_head.segment.rsc +4 -4
- package/.next/server/app/settings/key.segments/_index.segment.rsc +6 -6
- package/.next/server/app/settings/key.segments/_tree.segment.rsc +4 -4
- package/.next/server/app/styleguide/page.js +2 -15
- package/.next/server/app/styleguide/page.js.nft.json +1 -1
- package/.next/server/app/styleguide/page_client-reference-manifest.js +1 -3
- package/.next/server/app/styleguide.html +1 -1
- package/.next/server/app/styleguide.rsc +68 -71
- package/.next/server/app/styleguide.segments/_full.segment.rsc +68 -71
- package/.next/server/app/styleguide.segments/_head.segment.rsc +4 -4
- package/.next/server/app/styleguide.segments/_index.segment.rsc +6 -6
- package/.next/server/app/styleguide.segments/_tree.segment.rsc +4 -4
- package/.next/server/app/styleguide.segments/styleguide/__PAGE__.segment.rsc +43 -45
- package/.next/server/app/styleguide.segments/styleguide.segment.rsc +3 -3
- package/.next/server/app-paths-manifest.json +5 -5
- package/.next/server/chunks/15.js +1 -0
- package/.next/server/chunks/319.js +45 -0
- package/.next/server/chunks/367.js +122 -0
- package/.next/server/chunks/393.js +4 -0
- package/.next/server/chunks/491.js +2 -0
- package/.next/server/chunks/497.js +1 -0
- package/.next/server/chunks/546.js +1 -0
- package/.next/server/chunks/592.js +44 -0
- package/.next/server/chunks/607.js +4 -0
- package/.next/server/chunks/724.js +1 -0
- package/.next/server/chunks/741.js +18 -0
- package/.next/server/chunks/813.js +1 -0
- package/.next/server/chunks/837.js +75 -0
- package/.next/server/chunks/852.js +14 -0
- package/.next/server/chunks/907.js +62 -0
- package/.next/server/chunks/915.js +8 -0
- package/.next/server/chunks/994.js +8 -0
- package/.next/server/middleware-build-manifest.js +1 -21
- package/.next/server/middleware-manifest.json +2 -2
- package/.next/server/middleware-react-loadable-manifest.js +1 -0
- package/.next/server/next-font-manifest.js +1 -1
- package/.next/server/next-font-manifest.json +1 -31
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/server-reference-manifest.js +1 -1
- package/.next/server/server-reference-manifest.json +1 -5
- package/.next/server/webpack-runtime.js +1 -0
- package/.next/static/FExJe2q2O67X3zxf-SYQ_/_buildManifest.js +1 -0
- package/.next/static/chunks/185-9c51ded7cd36ca7e.js +1 -0
- package/.next/static/chunks/20-cca33f633fa125b2.js +1 -0
- package/.next/static/chunks/27-02413cc56fbb4570.js +1 -0
- package/.next/static/chunks/376-6f7bc95550542e0b.js +62 -0
- package/.next/static/chunks/479-ea67f878851afbcd.js +1 -0
- package/.next/static/chunks/493-6bd8c75c972d3abd.js +2 -0
- package/.next/static/chunks/4bd1b696-deb4a0a1da1923b0.js +1 -0
- package/.next/static/chunks/603-6235d4d53b37035c.js +1 -0
- package/.next/static/chunks/743-c183133e0fbf1564.js +44 -0
- package/.next/static/chunks/793-5e37343b804eb1d9.js +1 -0
- package/.next/static/chunks/794-dc751ec6c8c611f8.js +32 -0
- package/.next/static/chunks/924-9226750edc5c2c2f.js +1 -0
- package/.next/static/chunks/95247769-a29d70f7fbba27c6.js +1 -0
- package/.next/static/chunks/app/(app)/layout-aad46049bfd54648.js +1 -0
- package/.next/static/chunks/app/(app)/page-d75e1fccccdbe30e.js +1 -0
- package/.next/static/chunks/app/(app)/session/[name]/page-60529ed1fd7a66a1.js +1 -0
- package/.next/static/chunks/app/(app)/settings/key/page-c2aab9f11db98d4e.js +1 -0
- package/.next/static/chunks/app/_global-error/page-b1c3f51315835726.js +1 -0
- package/.next/static/chunks/app/_not-found/page-6830be21b0ed0c95.js +1 -0
- package/.next/static/chunks/app/api/analyze/route-b1c3f51315835726.js +1 -0
- package/.next/static/chunks/app/api/key/route-b1c3f51315835726.js +1 -0
- package/.next/static/chunks/app/api/key-status/route-b1c3f51315835726.js +1 -0
- package/.next/static/chunks/app/api/models/route-b1c3f51315835726.js +1 -0
- package/.next/static/chunks/app/api/revise/route-b1c3f51315835726.js +1 -0
- package/.next/static/chunks/app/layout-aa71ca14e7f13c0c.js +1 -0
- package/.next/static/chunks/app/record-test/page-efb4287dda79ede4.js +7 -0
- package/.next/static/chunks/app/styleguide/page-f39510e82c1f9f31.js +1 -0
- package/.next/static/chunks/framework-b29f9083d3cda3b2.js +1 -0
- package/.next/static/chunks/main-app-39f57c6e6702740e.js +1 -0
- package/.next/static/chunks/main-fac8900b4f9c4833.js +5 -0
- package/.next/static/chunks/next/dist/client/components/builtin/app-error-b1c3f51315835726.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/forbidden-b1c3f51315835726.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/global-error-c1d4bb24e31b66a2.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/not-found-b1c3f51315835726.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-b1c3f51315835726.js +1 -0
- package/.next/static/chunks/webpack-ceb933bd5f77076f.js +1 -0
- package/.next/static/css/e2905f0858acd77d.css +3 -0
- package/.next/types/app/(app)/page.ts +87 -0
- package/.next/types/app/(app)/session/[name]/page.ts +87 -0
- package/.next/types/app/(app)/settings/key/page.ts +87 -0
- package/.next/types/app/api/analyze/route.ts +351 -0
- package/.next/types/app/api/key/route.ts +351 -0
- package/.next/types/app/api/key-status/route.ts +351 -0
- package/.next/types/app/api/models/route.ts +351 -0
- package/.next/types/app/api/revise/route.ts +351 -0
- package/.next/types/app/layout.ts +87 -0
- package/.next/types/app/record-test/page.ts +87 -0
- package/.next/types/app/styleguide/page.ts +87 -0
- package/.next/types/package.json +1 -0
- package/README.md +4 -6
- package/next.config.ts +8 -0
- package/package.json +4 -4
- package/.next/build/56416d4ae4ce586f.js +0 -6
- package/.next/build/56416d4ae4ce586f.js.map +0 -5
- package/.next/build/chunks/[root-of-the-server]__0oj80bi._.js +0 -206
- package/.next/build/chunks/[root-of-the-server]__0oj80bi._.js.map +0 -8
- package/.next/build/chunks/[root-of-the-server]__1f933tp._.js +0 -500
- package/.next/build/chunks/[root-of-the-server]__1f933tp._.js.map +0 -11
- package/.next/build/chunks/[turbopack-node]_transforms_postcss_ts_0b7xl6g._.js +0 -13
- package/.next/build/chunks/[turbopack-node]_transforms_postcss_ts_0b7xl6g._.js.map +0 -5
- package/.next/build/chunks/[turbopack]_runtime.js +0 -890
- package/.next/build/chunks/[turbopack]_runtime.js.map +0 -11
- package/.next/build/chunks/node_modules_20v-8wl._.js +0 -6832
- package/.next/build/chunks/node_modules_20v-8wl._.js.map +0 -47
- package/.next/build/package.json +0 -1
- package/.next/cache/.previewinfo +0 -1
- package/.next/cache/.rscinfo +0 -1
- package/.next/cache/.tsbuildinfo +0 -1
- package/.next/diagnostics/route-bundle-stats.json +0 -111
- package/.next/fallback-build-manifest.json +0 -13
- package/.next/server/app/(app)/page/app-paths-manifest.json +0 -3
- package/.next/server/app/(app)/page/build-manifest.json +0 -17
- package/.next/server/app/(app)/page/next-font-manifest.json +0 -11
- package/.next/server/app/(app)/page/server-reference-manifest.json +0 -4
- package/.next/server/app/(app)/page.js.map +0 -5
- package/.next/server/app/(app)/session/[name]/page/app-paths-manifest.json +0 -3
- package/.next/server/app/(app)/session/[name]/page/build-manifest.json +0 -17
- package/.next/server/app/(app)/session/[name]/page/next-font-manifest.json +0 -11
- package/.next/server/app/(app)/session/[name]/page/react-loadable-manifest.json +0 -1
- package/.next/server/app/(app)/session/[name]/page/server-reference-manifest.json +0 -4
- package/.next/server/app/(app)/session/[name]/page.js.map +0 -5
- package/.next/server/app/(app)/settings/key/page/app-paths-manifest.json +0 -3
- package/.next/server/app/(app)/settings/key/page/build-manifest.json +0 -17
- package/.next/server/app/(app)/settings/key/page/next-font-manifest.json +0 -11
- package/.next/server/app/(app)/settings/key/page/react-loadable-manifest.json +0 -1
- package/.next/server/app/(app)/settings/key/page/server-reference-manifest.json +0 -4
- package/.next/server/app/(app)/settings/key/page.js.map +0 -5
- package/.next/server/app/_global-error/page/app-paths-manifest.json +0 -3
- package/.next/server/app/_global-error/page/build-manifest.json +0 -17
- package/.next/server/app/_global-error/page/next-font-manifest.json +0 -6
- package/.next/server/app/_global-error/page/react-loadable-manifest.json +0 -1
- package/.next/server/app/_global-error/page/server-reference-manifest.json +0 -4
- package/.next/server/app/_global-error/page.js.map +0 -5
- package/.next/server/app/_not-found/page/app-paths-manifest.json +0 -3
- package/.next/server/app/_not-found/page/build-manifest.json +0 -17
- package/.next/server/app/_not-found/page/next-font-manifest.json +0 -11
- package/.next/server/app/_not-found/page/react-loadable-manifest.json +0 -1
- package/.next/server/app/_not-found/page/server-reference-manifest.json +0 -4
- package/.next/server/app/_not-found/page.js.map +0 -5
- package/.next/server/app/api/analyze/route/app-paths-manifest.json +0 -3
- package/.next/server/app/api/analyze/route/build-manifest.json +0 -9
- package/.next/server/app/api/analyze/route/server-reference-manifest.json +0 -4
- package/.next/server/app/api/analyze/route.js.map +0 -5
- package/.next/server/app/api/key/route/app-paths-manifest.json +0 -3
- package/.next/server/app/api/key/route/build-manifest.json +0 -9
- package/.next/server/app/api/key/route/server-reference-manifest.json +0 -4
- package/.next/server/app/api/key/route.js.map +0 -5
- package/.next/server/app/api/key-status/route/app-paths-manifest.json +0 -3
- package/.next/server/app/api/key-status/route/build-manifest.json +0 -9
- package/.next/server/app/api/key-status/route/server-reference-manifest.json +0 -4
- package/.next/server/app/api/key-status/route.js.map +0 -5
- package/.next/server/app/api/models/route/app-paths-manifest.json +0 -3
- package/.next/server/app/api/models/route/build-manifest.json +0 -9
- package/.next/server/app/api/models/route/server-reference-manifest.json +0 -4
- package/.next/server/app/api/models/route.js.map +0 -5
- package/.next/server/app/api/revise/route/app-paths-manifest.json +0 -3
- package/.next/server/app/api/revise/route/build-manifest.json +0 -9
- package/.next/server/app/api/revise/route/server-reference-manifest.json +0 -4
- package/.next/server/app/api/revise/route.js.map +0 -5
- package/.next/server/app/icon.svg/route/app-paths-manifest.json +0 -3
- package/.next/server/app/icon.svg/route/build-manifest.json +0 -9
- package/.next/server/app/icon.svg/route.js.map +0 -5
- package/.next/server/app/record-test/page/app-paths-manifest.json +0 -3
- package/.next/server/app/record-test/page/build-manifest.json +0 -17
- package/.next/server/app/record-test/page/next-font-manifest.json +0 -11
- package/.next/server/app/record-test/page/react-loadable-manifest.json +0 -1
- package/.next/server/app/record-test/page/server-reference-manifest.json +0 -4
- package/.next/server/app/record-test/page.js.map +0 -5
- package/.next/server/app/styleguide/page/app-paths-manifest.json +0 -3
- package/.next/server/app/styleguide/page/build-manifest.json +0 -17
- package/.next/server/app/styleguide/page/next-font-manifest.json +0 -11
- package/.next/server/app/styleguide/page/react-loadable-manifest.json +0 -1
- package/.next/server/app/styleguide/page/server-reference-manifest.json +0 -4
- package/.next/server/app/styleguide/page.js.map +0 -5
- package/.next/server/chunks/[externals]__1l0bqbz._.js +0 -3
- package/.next/server/chunks/[externals]__1l0bqbz._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__00u0a0m._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__00u0a0m._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__02oblj7._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__02oblj7._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__04dzkv1._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__04dzkv1._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__081zp1m._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__081zp1m._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__0dkua3v._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__0dkua3v._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__0ezil_h._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__0ezil_h._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__0ww_12a._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__0ww_12a._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__0x-kpif._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__0x-kpif._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__15bjnu5._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__15bjnu5._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__1kmbnvv._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__1kmbnvv._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__1kp4vwc._.js +0 -14
- package/.next/server/chunks/[root-of-the-server]__1kp4vwc._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__1lbd3kd._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__1lbd3kd._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__1ra6psc._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__1ra6psc._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__1zn977r._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__1zn977r._.js.map +0 -1
- package/.next/server/chunks/[turbopack]_runtime.js +0 -903
- package/.next/server/chunks/[turbopack]_runtime.js.map +0 -11
- package/.next/server/chunks/_04h1cv_._.js +0 -185
- package/.next/server/chunks/_04h1cv_._.js.map +0 -1
- package/.next/server/chunks/_0pqmhjh._.js +0 -185
- package/.next/server/chunks/_0pqmhjh._.js.map +0 -1
- package/.next/server/chunks/_next-internal_server_app_api_analyze_route_actions_0lx-23h.js +0 -3
- package/.next/server/chunks/_next-internal_server_app_api_analyze_route_actions_0lx-23h.js.map +0 -1
- package/.next/server/chunks/_next-internal_server_app_api_key-status_route_actions_1qgztm2.js +0 -3
- package/.next/server/chunks/_next-internal_server_app_api_key-status_route_actions_1qgztm2.js.map +0 -1
- package/.next/server/chunks/_next-internal_server_app_api_key_route_actions_15n2qsb.js +0 -3
- package/.next/server/chunks/_next-internal_server_app_api_key_route_actions_15n2qsb.js.map +0 -1
- package/.next/server/chunks/_next-internal_server_app_api_models_route_actions_1h6mkqp.js +0 -3
- package/.next/server/chunks/_next-internal_server_app_api_models_route_actions_1h6mkqp.js.map +0 -1
- package/.next/server/chunks/_next-internal_server_app_api_revise_route_actions_19kk3m-.js +0 -3
- package/.next/server/chunks/_next-internal_server_app_api_revise_route_actions_19kk3m-.js.map +0 -1
- package/.next/server/chunks/_next-internal_server_app_icon_svg_route_actions_1r2h_ub.js +0 -3
- package/.next/server/chunks/_next-internal_server_app_icon_svg_route_actions_1r2h_ub.js.map +0 -1
- package/.next/server/chunks/node_modules_0x51oh_._.js +0 -10
- package/.next/server/chunks/node_modules_0x51oh_._.js.map +0 -1
- package/.next/server/chunks/node_modules_19bvt3l._.js +0 -6
- package/.next/server/chunks/node_modules_19bvt3l._.js.map +0 -1
- package/.next/server/chunks/node_modules_1_-az43._.js +0 -16
- package/.next/server/chunks/node_modules_1_-az43._.js.map +0 -1
- package/.next/server/chunks/node_modules_1t2pqct._.js +0 -10
- package/.next/server/chunks/node_modules_1t2pqct._.js.map +0 -1
- package/.next/server/chunks/node_modules_next_08s853w._.js +0 -13
- package/.next/server/chunks/node_modules_next_08s853w._.js.map +0 -1
- package/.next/server/chunks/node_modules_node-fetch_src_index_1gf-_pn.js +0 -3
- package/.next/server/chunks/node_modules_node-fetch_src_index_1gf-_pn.js.map +0 -1
- package/.next/server/chunks/ssr/[externals]__1l0bqbz._.js +0 -3
- package/.next/server/chunks/ssr/[externals]__1l0bqbz._.js.map +0 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__06ync7f._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__06ync7f._.js.map +0 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__0hml-pd._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__0hml-pd._.js.map +0 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__0ntia6u._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__0ntia6u._.js.map +0 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__0sdpd0o._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__0sdpd0o._.js.map +0 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__0w2pa_y._.js +0 -33
- package/.next/server/chunks/ssr/[root-of-the-server]__0w2pa_y._.js.map +0 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__10y0-wv._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__10y0-wv._.js.map +0 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__11_7weu._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__11_7weu._.js.map +0 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__1_stkwn._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__1_stkwn._.js.map +0 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__1dky4g0._.js +0 -33
- package/.next/server/chunks/ssr/[root-of-the-server]__1dky4g0._.js.map +0 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__1k6ey-q._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__1k6ey-q._.js.map +0 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__1la73u1._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__1la73u1._.js.map +0 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__1nshnxm._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__1nshnxm._.js.map +0 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__1pssg49._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__1pssg49._.js.map +0 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__1q6zd30._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__1q6zd30._.js.map +0 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__1qlmg27._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__1qlmg27._.js.map +0 -1
- package/.next/server/chunks/ssr/[turbopack]_runtime.js +0 -903
- package/.next/server/chunks/ssr/[turbopack]_runtime.js.map +0 -11
- package/.next/server/chunks/ssr/_01pksvc._.js +0 -78
- package/.next/server/chunks/ssr/_01pksvc._.js.map +0 -1
- package/.next/server/chunks/ssr/_03lgii8._.js +0 -3
- package/.next/server/chunks/ssr/_03lgii8._.js.map +0 -1
- package/.next/server/chunks/ssr/_05tft_r._.js +0 -3
- package/.next/server/chunks/ssr/_05tft_r._.js.map +0 -1
- package/.next/server/chunks/ssr/_06gt995._.js +0 -3
- package/.next/server/chunks/ssr/_06gt995._.js.map +0 -1
- package/.next/server/chunks/ssr/_0jrh37c._.js +0 -46
- package/.next/server/chunks/ssr/_0jrh37c._.js.map +0 -1
- package/.next/server/chunks/ssr/_0kw6yq_._.js +0 -3
- package/.next/server/chunks/ssr/_0kw6yq_._.js.map +0 -1
- package/.next/server/chunks/ssr/_0l3c05z._.js +0 -3
- package/.next/server/chunks/ssr/_0l3c05z._.js.map +0 -1
- package/.next/server/chunks/ssr/_0n-ojw-._.js +0 -3
- package/.next/server/chunks/ssr/_0n-ojw-._.js.map +0 -1
- package/.next/server/chunks/ssr/_0t6a1ln._.js +0 -6
- package/.next/server/chunks/ssr/_0t6a1ln._.js.map +0 -1
- package/.next/server/chunks/ssr/_0td-xk-._.js +0 -3
- package/.next/server/chunks/ssr/_0td-xk-._.js.map +0 -1
- package/.next/server/chunks/ssr/_0y92f-y._.js +0 -46
- package/.next/server/chunks/ssr/_0y92f-y._.js.map +0 -1
- package/.next/server/chunks/ssr/_1b6au28._.js +0 -3
- package/.next/server/chunks/ssr/_1b6au28._.js.map +0 -1
- package/.next/server/chunks/ssr/_next-internal_server_app_(app)_page_actions_1gxdy57.js +0 -3
- package/.next/server/chunks/ssr/_next-internal_server_app_(app)_page_actions_1gxdy57.js.map +0 -1
- package/.next/server/chunks/ssr/_next-internal_server_app_(app)_session_[name]_page_actions_115d_ja.js +0 -3
- package/.next/server/chunks/ssr/_next-internal_server_app_(app)_session_[name]_page_actions_115d_ja.js.map +0 -1
- package/.next/server/chunks/ssr/_next-internal_server_app_(app)_settings_key_page_actions_1jsc3or.js +0 -3
- package/.next/server/chunks/ssr/_next-internal_server_app_(app)_settings_key_page_actions_1jsc3or.js.map +0 -1
- package/.next/server/chunks/ssr/_next-internal_server_app__global-error_page_actions_0zi5s8-.js +0 -3
- package/.next/server/chunks/ssr/_next-internal_server_app__global-error_page_actions_0zi5s8-.js.map +0 -1
- package/.next/server/chunks/ssr/_next-internal_server_app__not-found_page_actions_0pt47yr.js +0 -3
- package/.next/server/chunks/ssr/_next-internal_server_app__not-found_page_actions_0pt47yr.js.map +0 -1
- package/.next/server/chunks/ssr/_next-internal_server_app_record-test_page_actions_0a_yofw.js +0 -3
- package/.next/server/chunks/ssr/_next-internal_server_app_record-test_page_actions_0a_yofw.js.map +0 -1
- package/.next/server/chunks/ssr/_next-internal_server_app_styleguide_page_actions_174h7x7.js +0 -3
- package/.next/server/chunks/ssr/_next-internal_server_app_styleguide_page_actions_174h7x7.js.map +0 -1
- package/.next/server/chunks/ssr/node_modules_0el53_h._.js +0 -10
- package/.next/server/chunks/ssr/node_modules_0el53_h._.js.map +0 -1
- package/.next/server/chunks/ssr/node_modules_0h91jdk._.js +0 -33
- package/.next/server/chunks/ssr/node_modules_0h91jdk._.js.map +0 -1
- package/.next/server/chunks/ssr/node_modules_1fxqp22._.js +0 -10
- package/.next/server/chunks/ssr/node_modules_1fxqp22._.js.map +0 -1
- package/.next/server/chunks/ssr/node_modules_1loo6j7._.js +0 -6
- package/.next/server/chunks/ssr/node_modules_1loo6j7._.js.map +0 -1
- package/.next/server/chunks/ssr/node_modules_1pvqj0r._.js +0 -3
- package/.next/server/chunks/ssr/node_modules_1pvqj0r._.js.map +0 -1
- package/.next/server/chunks/ssr/node_modules_next_dist_0uboya6._.js +0 -6
- package/.next/server/chunks/ssr/node_modules_next_dist_0uboya6._.js.map +0 -1
- package/.next/server/chunks/ssr/node_modules_next_dist_172hvm-._.js +0 -19
- package/.next/server/chunks/ssr/node_modules_next_dist_172hvm-._.js.map +0 -1
- package/.next/server/chunks/ssr/node_modules_next_dist_client_components_0wpq8j3._.js +0 -3
- package/.next/server/chunks/ssr/node_modules_next_dist_client_components_0wpq8j3._.js.map +0 -1
- package/.next/server/chunks/ssr/node_modules_next_dist_client_components_builtin_forbidden_0symwr9.js +0 -3
- package/.next/server/chunks/ssr/node_modules_next_dist_client_components_builtin_forbidden_0symwr9.js.map +0 -1
- package/.next/server/chunks/ssr/node_modules_next_dist_client_components_builtin_global-error_0-o-goa.js +0 -3
- package/.next/server/chunks/ssr/node_modules_next_dist_client_components_builtin_global-error_0-o-goa.js.map +0 -1
- package/.next/server/chunks/ssr/node_modules_next_dist_client_components_builtin_unauthorized_0l_sp0x.js +0 -3
- package/.next/server/chunks/ssr/node_modules_next_dist_client_components_builtin_unauthorized_0l_sp0x.js.map +0 -1
- package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_0_q50sh.js +0 -4
- package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_0_q50sh.js.map +0 -1
- package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_0_xbpm0.js +0 -4
- package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_0_xbpm0.js.map +0 -1
- package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_119i6eu.js +0 -4
- package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_119i6eu.js.map +0 -1
- package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_14nl2rs.js +0 -4
- package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_14nl2rs.js.map +0 -1
- package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_18u8k23.js +0 -4
- package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_18u8k23.js.map +0 -1
- package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_19--w_z.js +0 -4
- package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_19--w_z.js.map +0 -1
- package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_1_iwj0a.js +0 -4
- package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_1_iwj0a.js.map +0 -1
- package/.next/server/chunks/ssr/node_modules_node-fetch_src_index_1e0t9p6.js +0 -3
- package/.next/server/chunks/ssr/node_modules_node-fetch_src_index_1e0t9p6.js.map +0 -1
- package/.next/server/chunks/ssr/src_19oqe9t._.js +0 -3
- package/.next/server/chunks/ssr/src_19oqe9t._.js.map +0 -1
- package/.next/server/chunks/ssr/src_app_record-test_page_tsx_08-2bld._.js +0 -9
- package/.next/server/chunks/ssr/src_app_record-test_page_tsx_08-2bld._.js.map +0 -1
- package/.next/server/chunks/ssr/src_components_app-sidebar_tsx_1xx2k53._.js +0 -3
- package/.next/server/chunks/ssr/src_components_app-sidebar_tsx_1xx2k53._.js.map +0 -1
- package/.next/server/chunks/ssr/src_components_settings_key-setup_tsx_0jxhnpa._.js +0 -3
- package/.next/server/chunks/ssr/src_components_settings_key-setup_tsx_0jxhnpa._.js.map +0 -1
- package/.next/server/chunks/ssr/src_components_ui_0lq7ewx._.js +0 -3
- package/.next/server/chunks/ssr/src_components_ui_0lq7ewx._.js.map +0 -1
- package/.next/static/CIZxngYjzUw1Kb0KrE473/_buildManifest.js +0 -11
- package/.next/static/CIZxngYjzUw1Kb0KrE473/_clientMiddlewareManifest.js +0 -1
- package/.next/static/chunks/05-c3ty_6dwfk.js +0 -1
- package/.next/static/chunks/07-hzktxqjvzd.js +0 -4
- package/.next/static/chunks/09bn0buuu6k2x.js +0 -1
- package/.next/static/chunks/0kkimqpuecvfn.js +0 -1
- package/.next/static/chunks/0mk1g55o6kl1e.js +0 -2
- package/.next/static/chunks/0ul837-9k0zx_.js +0 -63
- package/.next/static/chunks/0wpges32btt_p.js +0 -1
- package/.next/static/chunks/18qo-4_hfuwko.js +0 -1
- package/.next/static/chunks/1_dsevxz78b97.js +0 -1
- package/.next/static/chunks/2-oqhnxovgl_2.js +0 -44
- package/.next/static/chunks/2et_7fxuzt9cq.js +0 -31
- package/.next/static/chunks/2im7c515bo69p.js +0 -1
- package/.next/static/chunks/2merpuxt1zcvf.js +0 -1
- package/.next/static/chunks/2qb8lge1e2sv2.js +0 -1
- package/.next/static/chunks/2sj0gufu0lojq.css +0 -3
- package/.next/static/chunks/2zloaj9ja_vpy.js +0 -1
- package/.next/static/chunks/3rvy2rc9d_hwt.js +0 -1
- package/.next/static/chunks/3uci2qhsbp444.js +0 -50
- package/.next/static/chunks/3yao5u25-bf0g.js +0 -1
- package/.next/static/chunks/41_0qs6kjmoek.js +0 -1
- package/.next/static/chunks/4395sbjm36lbl.js +0 -1
- package/.next/static/chunks/turbopack-2cevjmbuh84ft.js +0 -1
- package/.next/static/media/icon.2_sgat73yt9an.svg +0 -7
- package/.next/trace +0 -1
- package/.next/trace-build +0 -1
- package/.next/turbopack +0 -0
- /package/.next/{server/app/(app)/page/react-loadable-manifest.json → react-loadable-manifest.json} +0 -0
- /package/.next/static/{CIZxngYjzUw1Kb0KrE473 → FExJe2q2O67X3zxf-SYQ_}/_ssgManifest.js +0 -0
- /package/.next/static/chunks/{0cz1d0mv5g_q7.js → polyfills-42372ed130431b0a.js} +0 -0
- /package/.next/static/media/{5ce348bf30bf5439-s.31988l_ccedte.woff2 → 013b72fa676f92e0-s.woff2} +0 -0
- /package/.next/static/media/{5476f68d60460930-s.2uwcyprjm3xu3.woff2 → 19cfc7226ec3afaa-s.woff2} +0 -0
- /package/.next/static/media/{9c72aa0f40e4eef8-s.1y4-pdgsjb-pw.woff2 → 21350d82a1f187e9-s.woff2} +0 -0
- /package/.next/static/media/{bbc41e54d2fcbd21-s.1rgnod-3esatf.woff2 → 2b5b02fc7e511755-s.woff2} +0 -0
- /package/.next/static/media/{6306c77e7c8268e4-s.2dbetqa9o8jxf.woff2 → 65f03d54ccadf4a8-s.woff2} +0 -0
- /package/.next/static/media/{797e433ab948586e-s.p.0r6juujl39pe6.woff2 → 7d4881bb7e1bf84d-s.p.woff2} +0 -0
- /package/.next/static/media/{1bffadaabf893a1e-s.3-6t-g6q0vh0a.woff2 → 8e9860b6e62d6359-s.woff2} +0 -0
- /package/.next/static/media/{4fa387ec64143e14-s.2tuy5pz7dlieh.woff2 → b9408752a0c24fb9-s.woff2} +0 -0
- /package/.next/static/media/{2c55a0e60120577a-s.0-dom-5bn10r2.woff2 → ba9851c3c22cd980-s.woff2} +0 -0
- /package/.next/static/media/{ad66f9afd8947f86-s.3lvt2whj97whp.woff2 → c5fe6dc8356a8c31-s.woff2} +0 -0
- /package/.next/static/media/{2bbe8d2671613f1f-s.0k62hbripvv8p.woff2 → df0a9ae256c0569c-s.woff2} +0 -0
- /package/.next/static/media/{7d817b4c03b0c5f1-s.1uyisp29ctx0d.woff2 → e038a29029a234f2-s.woff2} +0 -0
- /package/.next/static/media/{83afe278b6a6bb3c-s.p.2bn3s6zvc0dyp.woff2 → e4af272ccee01ff0-s.p.woff2} +0 -0
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
module.exports=[38047,(e,t,r)=>{function n(e,t){"boolean"==typeof t&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}t.exports=n,n.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},n.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},n.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.push(e),this._errors.unshift(Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var r=this._timeouts.shift();if(void 0===r)if(!this._cachedTimeouts)return!1;else this._errors.splice(0,this._errors.length-1),r=this._cachedTimeouts.slice(-1);var n=this;return this._timer=setTimeout(function(){n._attempts++,n._operationTimeoutCb&&(n._timeout=setTimeout(function(){n._operationTimeoutCb(n._attempts)},n._operationTimeout),n._options.unref&&n._timeout.unref()),n._fn(n._attempts)},r),this._options.unref&&this._timer.unref(),!0},n.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var r=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){r._operationTimeoutCb()},r._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)},n.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)},n.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)},n.prototype.start=n.prototype.try,n.prototype.errors=function(){return this._errors},n.prototype.attempts=function(){return this._attempts},n.prototype.mainError=function(){if(0===this._errors.length)return null;for(var e={},t=null,r=0,n=0;n<this._errors.length;n++){var i=this._errors[n],o=i.message,s=(e[o]||0)+1;e[o]=s,s>=r&&(t=i,r=s)}return t}},18263,(e,t,r)=>{var n=e.r(38047);r.operation=function(e){return new n(r.timeouts(e),{forever:e&&(e.forever||e.retries===1/0),unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})},r.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1e3,maxTimeout:1/0,randomize:!1};for(var r in e)t[r]=e[r];if(t.minTimeout>t.maxTimeout)throw Error("minTimeout is greater than maxTimeout");for(var n=[],i=0;i<t.retries;i++)n.push(this.createTimeout(i,t));return e&&e.forever&&!n.length&&n.push(this.createTimeout(i,t)),n.sort(function(e,t){return e-t}),n},r.createTimeout=function(e,t){var r=Math.round((t.randomize?Math.random()+1:1)*Math.max(t.minTimeout,1)*Math.pow(t.factor,e));return Math.min(r,t.maxTimeout)},r.wrap=function(e,t,n){if(t instanceof Array&&(n=t,t=null),!n)for(var i in n=[],e)"function"==typeof e[i]&&n.push(i);for(var o=0;o<n.length;o++){var s=n[o],a=e[s];e[s]=(function(n){var i=r.operation(t),o=Array.prototype.slice.call(arguments,1),s=o.pop();o.push(function(e){i.retry(e)||(e&&(arguments[0]=i.mainError()),s.apply(this,arguments))}),i.attempt(function(){n.apply(e,o)})}).bind(e,a),e[s].options=t}}},74167,(e,t,r)=>{t.exports=e.r(18263)},36850,(e,t,r)=>{"use strict";let n=e.r(74167),i=["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"];class o extends Error{constructor(e){super(),e instanceof Error?(this.originalError=e,{message:e}=e):(this.originalError=Error(e),this.originalError.stack=this.stack),this.name="AbortError",this.message=e}}let s=(e,t)=>new Promise((r,s)=>{t={onFailedAttempt:()=>{},retries:10,...t};let a=n.operation(t);a.attempt(async n=>{try{r(await e(n))}catch(e){if(!(e instanceof Error))return void s(TypeError(`Non-error was thrown: "${e}". You should only throw errors.`));if(e instanceof o)a.stop(),s(e.originalError);else{let r;if(e instanceof TypeError&&(r=e.message,!i.includes(r)))a.stop(),s(e);else{let r;r=t.retries-(n-1),e.attemptNumber=n,e.retriesLeft=r;try{await t.onFailedAttempt(e)}catch(e){s(e);return}a.retry(e)||s(a.mainError())}}}})});t.exports=s,t.exports.default=s,t.exports.AbortError=o},25705,(e,t,r)=>{"use strict";var n=Object.prototype.hasOwnProperty,i=Object.prototype.toString,o=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===i.call(e)},l=function(e){if(!e||"[object Object]"!==i.call(e))return!1;var t,r=n.call(e,"constructor"),o=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!r&&!o)return!1;for(t in e);return void 0===t||n.call(e,t)},u=function(e,t){o&&"__proto__"===t.name?o(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},c=function(e,t){if("__proto__"===t){if(!n.call(e,t))return;else if(s)return s(e,t).value}return e[t]};t.exports=function e(){var t,r,n,i,o,s,p=arguments[0],d=1,h=arguments.length,f=!1;for("boolean"==typeof p&&(f=p,p=arguments[1]||{},d=2),(null==p||"object"!=typeof p&&"function"!=typeof p)&&(p={});d<h;++d)if(t=arguments[d],null!=t)for(r in t)n=c(p,r),p!==(i=c(t,r))&&(f&&i&&(l(i)||(o=a(i)))?(o?(o=!1,s=n&&a(n)?n:[]):s=n&&l(n)?n:{},u(p,{name:r,newValue:e(f,s,i)})):void 0!==i&&u(p,{name:r,newValue:i}));return p}},73827,(e,t,r)=>{t.exports={name:"gaxios",version:"7.1.5",description:"A simple common HTTP client specifically for Google APIs and services.",main:"build/cjs/src/index.js",types:"build/cjs/src/index.d.ts",files:["build/"],exports:{".":{import:{types:"./build/esm/src/index.d.ts",default:"./build/esm/src/index.js"},require:{types:"./build/cjs/src/index.d.ts",default:"./build/cjs/src/index.js"}}},scripts:{lint:"gts check --no-inline-config",test:"c8 mocha build/esm/test","presystem-test":"npm run compile","system-test":"mocha build/esm/system-test --timeout 80000",compile:"tsc -b ./tsconfig.json ./tsconfig.cjs.json && node utils/enable-esm.mjs",fix:"gts fix",prepare:"npm run compile",pretest:"npm run compile",webpack:"webpack","prebrowser-test":"npm run compile","browser-test":"node build/browser-test/browser-test-runner.js",docs:"jsdoc -c .jsdoc.js","samples-test":"cd samples/ && npm link ../ && npm test && cd ../",prelint:"cd samples; npm link ../; npm install",clean:"gts clean"},repository:{type:"git",directory:"packages/gaxios",url:"https://github.com/googleapis/google-cloud-node-core.git"},keywords:["google"],engines:{node:">=18"},author:"Google, LLC",license:"Apache-2.0",devDependencies:{"@babel/plugin-proposal-private-methods":"^7.18.6","@types/cors":"^2.8.6","@types/express":"^5.0.0","@types/extend":"^3.0.1","@types/mocha":"^10.0.10","@types/multiparty":"4.2.1","@types/mv":"^2.1.0","@types/ncp":"^2.0.8","@types/node":"^24.0.0","@types/sinon":"^21.0.0","@types/tmp":"^0.2.6",assert:"^2.0.0",browserify:"^17.0.0",c8:"^10.1.3",cors:"^2.8.5",express:"^5.0.0",gts:"^6.0.2","is-docker":"^3.0.0",jsdoc:"^4.0.4","jsdoc-fresh":"^5.0.0","jsdoc-region-tag":"^4.0.0",karma:"^6.0.0","karma-chrome-launcher":"^3.0.0","karma-coverage":"^2.0.0","karma-firefox-launcher":"^2.0.0","karma-mocha":"^2.0.0","karma-remap-coverage":"^0.1.5","karma-sourcemap-loader":"^0.4.0","karma-webpack":"^5.0.1",mocha:"^11.1.0",multiparty:"^4.2.1",mv:"^2.1.1",ncp:"^2.0.0",nock:"14.0.5","null-loader":"^4.0.1","pack-n-play":"^4.0.0",puppeteer:"^24.0.0",sinon:"21.0.3","stream-browserify":"^3.0.0",tmp:"0.2.6","ts-loader":"^9.5.2",typescript:"5.8.3","undici-types":"^7.24.1",webpack:"^5.97.1","webpack-cli":"^6.0.1"},dependencies:{extend:"^3.0.2","https-proxy-agent":"^7.0.1","node-fetch":"^3.3.2"},homepage:"https://github.com/googleapis/google-cloud-node-core/tree/main/packages/gaxios"}},61675,(e,t,r)=>{"use strict";t.exports={pkg:e.r(73827)}},27078,(e,t,r)=>{"use strict";var n=e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.GaxiosError=r.GAXIOS_ERROR_SYMBOL=void 0,r.defaultErrorRedactor=function e(t){let r="<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.";function n(e){e&&e.forEach((t,n)=>{(/^authentication$/i.test(n)||/^authorization$/i.test(n)||/secret/i.test(n))&&e.set(n,r)})}function i(e,t){if("object"==typeof e&&null!==e&&"string"==typeof e[t]){let n=e[t];(/grant_type=/i.test(n)||/assertion=/i.test(n)||/secret/i.test(n))&&(e[t]=r)}}function o(e){!e||"object"!=typeof e||(e instanceof FormData||e instanceof URLSearchParams||"forEach"in e&&"set"in e?e.forEach((t,n)=>{(["grant_type","assertion"].includes(n)||/secret/.test(n))&&e.set(n,r)}):("grant_type"in e&&(e.grant_type=r),"assertion"in e&&(e.assertion=r),"client_secret"in e&&(e.client_secret=r)))}return t.config&&(n(t.config.headers),i(t.config,"data"),o(t.config.data),i(t.config,"body"),o(t.config.body),t.config.url.searchParams.has("token")&&t.config.url.searchParams.set("token",r),t.config.url.searchParams.has("client_secret")&&t.config.url.searchParams.set("client_secret",r)),t.response&&(e({config:t.response.config}),n(t.response.headers),t.response.bodyUsed&&(i(t.response,"data"),o(t.response.data))),t};let i=n(e.r(25705)),o=n(e.r(61675)).default.pkg;r.GAXIOS_ERROR_SYMBOL=Symbol.for(`${o.name}-gaxios-error`);class s extends Error{config;response;code;status;error;[r.GAXIOS_ERROR_SYMBOL]=o.version;static[Symbol.hasInstance](e){return!!e&&"object"==typeof e&&r.GAXIOS_ERROR_SYMBOL in e&&e[r.GAXIOS_ERROR_SYMBOL]===o.version||Function.prototype[Symbol.hasInstance].call(s,e)}constructor(e,t,r,n){if(super(e,{cause:n}),this.config=t,this.response=r,this.error=n instanceof Error?n:void 0,this.config=(0,i.default)(!0,{},t),this.response&&(this.response.config=(0,i.default)(!0,{},this.response.config)),this.response){try{this.response.data=function(e,t){switch(e){case"stream":default:return t;case"json":return JSON.parse(JSON.stringify(t));case"arraybuffer":return JSON.parse(Buffer.from(t).toString("utf8"));case"blob":return JSON.parse(t.text())}}(this.config.responseType,this.response?.bodyUsed?this.response?.data:void 0)}catch{}this.status=this.response.status}n instanceof DOMException?this.code=n.name:n&&"object"==typeof n&&"code"in n&&("string"==typeof n.code||"number"==typeof n.code)&&(this.code=n.code)}static extractAPIErrorFromResponse(e,t="The request failed"){let r=t;if("string"==typeof e.data&&(r=e.data),e.data&&"object"==typeof e.data&&"error"in e.data&&e.data.error&&!e.ok){if("string"==typeof e.data.error)return{message:e.data.error,code:e.status,status:e.statusText};if("object"==typeof e.data.error){r="message"in e.data.error&&"string"==typeof e.data.error.message?e.data.error.message:r;let t="status"in e.data.error&&"string"==typeof e.data.error.status?e.data.error.status:e.statusText,n="code"in e.data.error&&"number"==typeof e.data.error.code?e.data.error.code:e.status;if("errors"in e.data.error&&Array.isArray(e.data.error.errors)){let i=[];for(let t of e.data.error.errors)"object"==typeof t&&"message"in t&&"string"==typeof t.message&&i.push(t.message);return Object.assign({message:i.join("\n")||r,code:n,status:t},e.data.error)}return Object.assign({message:r,code:n,status:t},e.data.error)}}return{message:r,code:e.status,status:e.statusText}}}r.GaxiosError=s},35156,(e,t,r)=>{"use strict";async function n(e){var t;let r=o(e);if(!e||!e.config||!r&&!e.config.retry)return{shouldRetry:!1};(r=r||{}).currentRetryAttempt=r.currentRetryAttempt||0,r.retry=void 0===r.retry||null===r.retry?3:r.retry,r.httpMethodsToRetry=r.httpMethodsToRetry||["GET","HEAD","PUT","OPTIONS","DELETE"],r.noResponseRetries=void 0===r.noResponseRetries||null===r.noResponseRetries?2:r.noResponseRetries,r.retryDelayMultiplier=r.retryDelayMultiplier?r.retryDelayMultiplier:2,r.timeOfFirstRequest=r.timeOfFirstRequest?r.timeOfFirstRequest:Date.now(),r.totalTimeout=r.totalTimeout?r.totalTimeout:Number.MAX_SAFE_INTEGER,r.maxRetryDelay=r.maxRetryDelay?r.maxRetryDelay:Number.MAX_SAFE_INTEGER,r.statusCodesToRetry=r.statusCodesToRetry||[[100,199],[408,408],[429,429],[500,599]],e.config.retryConfig=r;let n=r.shouldRetry||i;if(!await n(e))return{shouldRetry:!1,config:e.config};let s=Math.min(((t=r).currentRetryAttempt?0:t.retryDelay??100)+(Math.pow(t.retryDelayMultiplier,t.currentRetryAttempt)-1)/2*1e3,t.totalTimeout-(Date.now()-t.timeOfFirstRequest),t.maxRetryDelay);e.config.retryConfig.currentRetryAttempt+=1;let a=r.retryBackoff?r.retryBackoff(e,s):new Promise(e=>{setTimeout(e,s)});return r.onRetryAttempt&&await r.onRetryAttempt(e),await a,{shouldRetry:!0,config:e.config}}function i(e){let t=o(e);if(e.config.signal?.aborted&&"TimeoutError"!==e.code||"AbortError"===e.code||!t||0===t.retry||!e.response&&(t.currentRetryAttempt||0)>=t.noResponseRetries||!t.httpMethodsToRetry||!t.httpMethodsToRetry.includes(e.config.method?.toUpperCase()||"GET"))return!1;if(e.response&&e.response.status){let r=!1;for(let[n,i]of t.statusCodesToRetry){let t=e.response.status;if(t>=n&&t<=i){r=!0;break}}if(!r)return!1}return t.currentRetryAttempt=t.currentRetryAttempt||0,!(t.currentRetryAttempt>=t.retry)}function o(e){if(e&&e.config&&e.config.retryConfig)return e.config.retryConfig}Object.defineProperty(r,"__esModule",{value:!0}),r.getRetryConfig=n},3137,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.GaxiosInterceptorManager=void 0;class n extends Set{}r.GaxiosInterceptorManager=n},80038,(e,t,r)=>{"use strict";var n,i=e.e&&e.e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.Gaxios=void 0;let o=i(e.r(25705)),s=e.r(24836),a=e.r(27078),l=e.r(35156),u=e.r(88947),c=e.r(3137),p=async()=>globalThis.crypto?.randomUUID()||(await e.A(85685)).randomUUID();class d{agentCache=new Map;defaults;interceptors;constructor(e){this.defaults=e||{},this.interceptors={request:new c.GaxiosInterceptorManager,response:new c.GaxiosInterceptorManager}}fetch(...e){let t,r=e[0],i=e[1],o=new Headers;return("string"==typeof r?t=new URL(r):r instanceof URL?t=r:r&&r.url&&(t=new URL(r.url)),r&&"object"==typeof r&&"headers"in r&&n.mergeHeaders(o,r.headers),i&&n.mergeHeaders(o,new Headers(i.headers)),"object"!=typeof r||r instanceof URL)?this.request({...i,headers:o,url:t}):this.request({...i,...r,headers:o,url:t})}async request(e={}){let t=await this.#e(e);return t=await this.#t(t),this.#r(this._request(t))}async _defaultAdapter(e){let t=e.fetchImplementation||this.defaults.fetchImplementation||await n.#n(),r={...e};delete r.data;let i=await t(e.url,r),o=await this.getResponseData(e,i);return Object.getOwnPropertyDescriptor(i,"data")?.configurable||Object.defineProperties(i,{data:{configurable:!0,writable:!0,enumerable:!0,value:o}}),Object.assign(i,{config:e,data:o})}async _request(e){try{let t;if(t=e.adapter?await e.adapter(e,this._defaultAdapter.bind(this)):await this._defaultAdapter(e),!e.validateStatus(t.status)){if("stream"===e.responseType){let e=[];for await(let r of t.data)e.push(r);t.data=e.toString()}let r=a.GaxiosError.extractAPIErrorFromResponse(t,`Request failed with status code ${t.status}`);throw new a.GaxiosError(r?.message,e,t,r)}return t}catch(i){let t;t=i instanceof a.GaxiosError?i:i instanceof Error?new a.GaxiosError(i.message,e,void 0,i):new a.GaxiosError("Unexpected Gaxios Error",e,void 0,i);let{shouldRetry:r,config:n}=await (0,l.getRetryConfig)(t);if(r&&n)return t.config.retryConfig.currentRetryAttempt=n.retryConfig.currentRetryAttempt,e.retryConfig=t.config?.retryConfig,this.#i(e),this._request(e);throw e.errorRedactor&&e.errorRedactor(t),t}}async getResponseData(e,t){if(204===t.status)return"";if(e.maxContentLength&&t.headers.has("content-length")&&e.maxContentLength<Number.parseInt(t.headers?.get("content-length")||""))throw new a.GaxiosError("Response's `Content-Length` is over the limit.",e,Object.assign(t,{config:e}));switch(e.responseType){case"stream":return t.body;case"json":{let e=await t.text();try{return JSON.parse(e)}catch{return e}}case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"text":return t.text();default:return this.getResponseDataFromContentType(t)}}#o(e,t=[]){let r=new URL(e),n=[...t];for(let e of(process.env.NO_PROXY??process.env.no_proxy)?.split(",")||[])n.push(e.trim());for(let e of n)if(e instanceof RegExp){if(e.test(r.toString()))return!1}else if(e instanceof URL){if(e.origin===r.origin)return!1}else if(e.startsWith("*.")||e.startsWith(".")){let t=e.replace(/^\*\./,".");if(r.hostname.endsWith(t))return!1}else if(e===r.origin||e===r.hostname||e===r.href)return!1;return!0}async #t(e){let t=Promise.resolve(e);for(let e of this.interceptors.request.values())e&&(t=t.then(e.resolved,e.rejected));return t}async #r(e){let t=Promise.resolve(e);for(let e of this.interceptors.response.values())e&&(t=t.then(e.resolved,e.rejected));return t}async #e(e){let t=new Headers(this.defaults.headers);n.mergeHeaders(t,e.headers);let r=(0,o.default)(!0,{},this.defaults,e);if(!r.url)throw Error("URL is required.");if(r.baseURL&&(r.url=new URL(r.url,r.baseURL)),r.url=new URL(r.url),r.params)if(r.paramsSerializer){let e=r.paramsSerializer(r.params);e.startsWith("?")&&(e=e.slice(1));let t=r.url.toString().includes("?")?"&":"?";r.url=r.url+t+e}else{let e=r.url instanceof URL?r.url:new URL(r.url);for(let[t,n]of new URLSearchParams(r.params))e.searchParams.append(t,n);r.url=e}"number"==typeof e.maxContentLength&&(r.size=e.maxContentLength),"number"==typeof e.maxRedirects&&(r.follow=e.maxRedirects);let i="string"==typeof r.data||r.data instanceof ArrayBuffer||r.data instanceof Blob||globalThis.File&&r.data instanceof File||r.data instanceof FormData||r.data instanceof u.Readable||r.data instanceof ReadableStream||r.data instanceof String||r.data instanceof URLSearchParams||ArrayBuffer.isView(r.data)||["Blob","File","FormData"].includes(r.data?.constructor?.name||"");if(r.multipart?.length){let e=await p();t.set("content-type",`multipart/related; boundary=${e}`),r.body=u.Readable.from(this.getMultipartRequest(r.multipart,e))}else i?r.body=r.data:"object"==typeof r.data?"application/x-www-form-urlencoded"===t.get("Content-Type")?r.body=r.paramsSerializer?r.paramsSerializer(r.data):new URLSearchParams(r.data):(t.has("content-type")||t.set("content-type","application/json"),r.body=JSON.stringify(r.data)):r.data&&(r.body=r.data);r.validateStatus=r.validateStatus||this.validateStatus,r.responseType=r.responseType||"unknown",t.has("accept")||"json"!==r.responseType||t.set("accept","application/json");let l=r.proxy||process?.env?.HTTPS_PROXY||process?.env?.https_proxy||process?.env?.HTTP_PROXY||process?.env?.http_proxy;if(r.agent);else if(l&&this.#o(r.url,r.noProxy)){let e=await n.#s();this.agentCache.has(l)?r.agent=this.agentCache.get(l):(r.agent=new e(l,{cert:r.cert,key:r.key}),this.agentCache.set(l,r.agent))}else r.cert&&r.key&&(this.agentCache.has(r.key)?r.agent=this.agentCache.get(r.key):(r.agent=new s.Agent({cert:r.cert,key:r.key}),this.agentCache.set(r.key,r.agent)));return"function"!=typeof r.errorRedactor&&!1!==r.errorRedactor&&(r.errorRedactor=a.defaultErrorRedactor),!r.body||"duplex"in r||(r.duplex="half"),this.#i(r),Object.assign(r,{headers:t,url:r.url instanceof URL?r.url:new URL(r.url)})}#i(e){if(e.timeout){let t=AbortSignal.timeout(e.timeout);e.signal&&!e.signal.aborted?e.signal=AbortSignal.any([e.signal,t]):e.signal=t}}validateStatus(e){return e>=200&&e<300}async getResponseDataFromContentType(e){let t=e.headers.get("Content-Type");if(null===t)return e.text();if((t=t.toLowerCase()).includes("application/json")){let t=await e.text();try{t=JSON.parse(t)}catch{}return t}return t.match(/^text\//)?e.text():e.blob()}async *getMultipartRequest(e,t){let r=`--${t}--`;for(let r of e){let e=r.headers.get("Content-Type")||"application/octet-stream",n=`--${t}\r
|
|
2
|
-
Content-Type: ${e}\r
|
|
3
|
-
\r
|
|
4
|
-
`;yield n,"string"==typeof r.content?yield r.content:yield*r.content,yield"\r\n"}yield r}static #a;static #l;static async #s(){return this.#a||=(await e.A(91961)).HttpsProxyAgent,this.#a}static async #n(){return this.#l||=(await e.A(72331)).default,this.#l}static mergeHeaders(e,...t){for(let r of(e=e instanceof Headers?e:new Headers(e),t))(r instanceof Headers?r:new Headers(r)).forEach((t,r)=>{"set-cookie"===r?e.append(r,t):e.set(r,t)});return e}}r.Gaxios=d,n=d},57612,(e,t,r)=>{"use strict";var n=e.e&&e.e.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=e.e&&e.e.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(r,"__esModule",{value:!0}),r.instance=r.Gaxios=r.GaxiosError=void 0,r.request=a;let o=e.r(80038);Object.defineProperty(r,"Gaxios",{enumerable:!0,get:function(){return o.Gaxios}});var s=e.r(27078);async function a(e){return r.instance.request(e)}Object.defineProperty(r,"GaxiosError",{enumerable:!0,get:function(){return s.GaxiosError}}),i(e.r(3137),r),r.instance=new o.Gaxios},29077,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.GCE_LINUX_BIOS_PATHS=void 0,r.isGoogleCloudServerless=o,r.isGoogleComputeEngineLinux=s,r.isGoogleComputeEngineMACAddress=a,r.isGoogleComputeEngine=l,r.detectGCPResidency=function(){return o()||l()},e.r(22734);let n=e.r(46786);r.GCE_LINUX_BIOS_PATHS={BIOS_DATE:"/sys/class/dmi/id/bios_date",BIOS_VENDOR:"/sys/class/dmi/id/bios_vendor"};let i=/^42:01/;function o(){return!!(process.env.CLOUD_RUN_JOB||process.env.FUNCTION_NAME||process.env.K_SERVICE)}function s(){if("linux"!==(0,n.platform)())return!1}function a(){for(let e of Object.values((0,n.networkInterfaces)()))if(e){for(let{mac:t}of e)if(i.test(t))return!0}return!1}function l(){return s()||a()}},45905,(e,t,r)=>{!function(r){"use strict";var n,i=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,o=Math.ceil,s=Math.floor,a="[BigNumber Error] ",l=a+"Number primitive has more than 15 significant digits: ",u=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13];function c(e){var t=0|e;return e>0||e===t?t:t-1}function p(e){for(var t,r,n=1,i=e.length,o=e[0]+"";n<i;){for(r=14-(t=e[n++]+"").length;r--;t="0"+t);o+=t}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function d(e,t){var r,n,i=e.c,o=t.c,s=e.s,a=t.s,l=e.e,u=t.e;if(!s||!a)return null;if(r=i&&!i[0],n=o&&!o[0],r||n)return r?n?0:-a:s;if(s!=a)return s;if(r=s<0,n=l==u,!i||!o)return n?0:!i^r?1:-1;if(!n)return l>u^r?1:-1;for(s=0,a=(l=i.length)<(u=o.length)?l:u;s<a;s++)if(i[s]!=o[s])return i[s]>o[s]^r?1:-1;return l==u?0:l>u^r?1:-1}function h(e,t,r,n){if(e<t||e>r||e!==s(e))throw Error(a+(n||"Argument")+("number"==typeof e?e<t||e>r?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function f(e){var t=e.c.length-1;return c(e.e/14)==t&&e.c[t]%2!=0}function m(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function g(e,t,r){var n,i;if(t<0){for(i=r+".";++t;i+=r);e=i+e}else if(n=e.length,++t>n){for(i=r,t-=n;--t;i+=r);e+=i}else t<n&&(e=e.slice(0,t)+"."+e.slice(t));return e}if((n=function e(t){var r,n,y,_,E,v,A,T,C,S=j.prototype={constructor:j,toString:null,valueOf:null},b=new j(1),I=20,O=4,w=-7,P=21,R=-1e7,N=1e7,k=!1,D=1,x=0,U={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},G="0123456789abcdefghijklmnopqrstuvwxyz",M=!0;function j(e,t){var r,n,o,a,u,c,p,d,f=this;if(!(f instanceof j))return new j(e,t);if(null==t){if(e&&!0===e._isBigNumber){f.s=e.s,!e.c||e.e>N?f.c=f.e=null:e.e<R?f.c=[f.e=0]:(f.e=e.e,f.c=e.c.slice());return}if((c="number"==typeof e)&&0*e==0){if(f.s=1/e<0?(e=-e,-1):1,e===~~e){for(a=0,u=e;u>=10;u/=10,a++);a>N?f.c=f.e=null:(f.e=a,f.c=[e]);return}d=String(e)}else{if(!i.test(d=String(e)))return C(f,d,c);f.s=45==d.charCodeAt(0)?(d=d.slice(1),-1):1}(a=d.indexOf("."))>-1&&(d=d.replace(".","")),(u=d.search(/e/i))>0?(a<0&&(a=u),a+=+d.slice(u+1),d=d.substring(0,u)):a<0&&(a=d.length)}else{if(h(t,2,G.length,"Base"),10==t&&M)return H(f=new j(e),I+f.e+1,O);if(d=String(e),c="number"==typeof e){if(0*e!=0)return C(f,d,c,t);if(f.s=1/e<0?(d=d.slice(1),-1):1,j.DEBUG&&d.replace(/^0\.0*|\./,"").length>15)throw Error(l+e)}else f.s=45===d.charCodeAt(0)?(d=d.slice(1),-1):1;for(r=G.slice(0,t),a=u=0,p=d.length;u<p;u++)if(0>r.indexOf(n=d.charAt(u))){if("."==n){if(u>a){a=p;continue}}else if(!o&&(d==d.toUpperCase()&&(d=d.toLowerCase())||d==d.toLowerCase()&&(d=d.toUpperCase()))){o=!0,u=-1,a=0;continue}return C(f,String(e),c,t)}c=!1,(a=(d=T(d,t,10,f.s)).indexOf("."))>-1?d=d.replace(".",""):a=d.length}for(u=0;48===d.charCodeAt(u);u++);for(p=d.length;48===d.charCodeAt(--p););if(d=d.slice(u,++p)){if(p-=u,c&&j.DEBUG&&p>15&&(e>0x1fffffffffffff||e!==s(e)))throw Error(l+f.s*e);if((a=a-u-1)>N)f.c=f.e=null;else if(a<R)f.c=[f.e=0];else{if(f.e=a,f.c=[],u=(a+1)%14,a<0&&(u+=14),u<p){for(u&&f.c.push(+d.slice(0,u)),p-=14;u<p;)f.c.push(+d.slice(u,u+=14));u=14-(d=d.slice(u)).length}else u-=p;for(;u--;d+="0");f.c.push(+d)}}else f.c=[f.e=0]}function L(e,t,r,n){var i,o,s,a,l;if(null==r?r=O:h(r,0,8),!e.c)return e.toString();if(i=e.c[0],s=e.e,null==t)l=p(e.c),l=1==n||2==n&&(s<=w||s>=P)?m(l,s):g(l,s,"0");else if(o=(e=H(new j(e),t,r)).e,a=(l=p(e.c)).length,1==n||2==n&&(t<=o||o<=w)){for(;a<t;l+="0",a++);l=m(l,o)}else if(t-=s+(2===n&&o>s),l=g(l,o,"0"),o+1>a){if(--t>0)for(l+=".";t--;l+="0");}else if((t+=o-a)>0)for(o+1==a&&(l+=".");t--;l+="0");return e.s<0&&i?"-"+l:l}function F(e,t){for(var r,n,i=1,o=new j(e[0]);i<e.length;i++)(n=new j(e[i])).s&&(r=d(o,n))!==t&&(0!==r||o.s!==t)||(o=n);return o}function q(e,t,r){for(var n=1,i=t.length;!t[--i];t.pop());for(i=t[0];i>=10;i/=10,n++);return(r=n+14*r-1)>N?e.c=e.e=null:r<R?e.c=[e.e=0]:(e.e=r,e.c=t),e}function H(e,t,r,n){var i,a,l,c,p,d,h,f=e.c;if(f){e:{for(i=1,c=f[0];c>=10;c/=10,i++);if((a=t-i)<0)a+=14,l=t,h=s((p=f[d=0])/u[i-l-1]%10);else if((d=o((a+1)/14))>=f.length)if(n){for(;f.length<=d;f.push(0));p=h=0,i=1,a%=14,l=a-14+1}else break e;else{for(i=1,p=c=f[d];c>=10;c/=10,i++);a%=14,h=(l=a-14+i)<0?0:s(p/u[i-l-1]%10)}if(n=n||t<0||null!=f[d+1]||(l<0?p:p%u[i-l-1]),n=r<4?(h||n)&&(0==r||r==(e.s<0?3:2)):h>5||5==h&&(4==r||n||6==r&&(a>0?l>0?p/u[i-l]:0:f[d-1])%10&1||r==(e.s<0?8:7)),t<1||!f[0])return f.length=0,n?(t-=e.e+1,f[0]=u[(14-t%14)%14],e.e=-t||0):f[0]=e.e=0,e;if(0==a?(f.length=d,c=1,d--):(f.length=d+1,c=u[14-a],f[d]=l>0?s(p/u[i-l]%u[l])*c:0),n)for(;;)if(0==d){for(a=1,l=f[0];l>=10;l/=10,a++);for(l=f[0]+=c,c=1;l>=10;l/=10,c++);a!=c&&(e.e++,1e14==f[0]&&(f[0]=1));break}else{if(f[d]+=c,1e14!=f[d])break;f[d--]=0,c=1}for(a=f.length;0===f[--a];f.pop());}e.e>N?e.c=e.e=null:e.e<R&&(e.c=[e.e=0])}return e}function B(e){var t,r=e.e;return null===r?e.toString():(t=p(e.c),t=r<=w||r>=P?m(t,r):g(t,r,"0"),e.s<0?"-"+t:t)}return j.clone=e,j.ROUND_UP=0,j.ROUND_DOWN=1,j.ROUND_CEIL=2,j.ROUND_FLOOR=3,j.ROUND_HALF_UP=4,j.ROUND_HALF_DOWN=5,j.ROUND_HALF_EVEN=6,j.ROUND_HALF_CEIL=7,j.ROUND_HALF_FLOOR=8,j.EUCLID=9,j.config=j.set=function(e){var t,r;if(null!=e)if("object"==typeof e){if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(h(r=e[t],0,1e9,t),I=r),e.hasOwnProperty(t="ROUNDING_MODE")&&(h(r=e[t],0,8,t),O=r),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((r=e[t])&&r.pop?(h(r[0],-1e9,0,t),h(r[1],0,1e9,t),w=r[0],P=r[1]):(h(r,-1e9,1e9,t),w=-(P=r<0?-r:r))),e.hasOwnProperty(t="RANGE"))if((r=e[t])&&r.pop)h(r[0],-1e9,-1,t),h(r[1],1,1e9,t),R=r[0],N=r[1];else if(h(r,-1e9,1e9,t),r)R=-(N=r<0?-r:r);else throw Error(a+t+" cannot be zero: "+r);if(e.hasOwnProperty(t="CRYPTO"))if(!!(r=e[t])===r)if(r)if("u">typeof crypto&&crypto&&(crypto.getRandomValues||crypto.randomBytes))k=r;else throw k=!r,Error(a+"crypto unavailable");else k=r;else throw Error(a+t+" not true or false: "+r);if(e.hasOwnProperty(t="MODULO_MODE")&&(h(r=e[t],0,9,t),D=r),e.hasOwnProperty(t="POW_PRECISION")&&(h(r=e[t],0,1e9,t),x=r),e.hasOwnProperty(t="FORMAT"))if("object"==typeof(r=e[t]))U=r;else throw Error(a+t+" not an object: "+r);if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(r=e[t])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(a+t+" invalid: "+r);M="0123456789"==r.slice(0,10),G=r}}else throw Error(a+"Object expected: "+e);return{DECIMAL_PLACES:I,ROUNDING_MODE:O,EXPONENTIAL_AT:[w,P],RANGE:[R,N],CRYPTO:k,MODULO_MODE:D,POW_PRECISION:x,FORMAT:U,ALPHABET:G}},j.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!j.DEBUG)return!0;var t,r,n=e.c,i=e.e,o=e.s;e:if("[object Array]"==({}).toString.call(n)){if((1===o||-1===o)&&i>=-1e9&&i<=1e9&&i===s(i)){if(0===n[0]){if(0===i&&1===n.length)return!0;break e}if((t=(i+1)%14)<1&&(t+=14),String(n[0]).length==t){for(t=0;t<n.length;t++)if((r=n[t])<0||r>=1e14||r!==s(r))break e;if(0!==r)return!0}}}else if(null===n&&null===i&&(null===o||1===o||-1===o))return!0;throw Error(a+"Invalid BigNumber: "+e)},j.maximum=j.max=function(){return F(arguments,-1)},j.minimum=j.min=function(){return F(arguments,1)},r=0x20000000000000*Math.random()&2097151?function(){return s(0x20000000000000*Math.random())}:function(){return(0x40000000*Math.random()|0)*8388608+(8388608*Math.random()|0)},j.random=function(e){var t,n,i,l,c,p=0,d=[],f=new j(b);if(null==e?e=I:h(e,0,1e9),l=o(e/14),k)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(l*=2));p<l;)(c=131072*t[p]+(t[p+1]>>>11))>=9e15?(n=crypto.getRandomValues(new Uint32Array(2)),t[p]=n[0],t[p+1]=n[1]):(d.push(c%1e14),p+=2);p=l/2}else if(crypto.randomBytes){for(t=crypto.randomBytes(l*=7);p<l;)(c=(31&t[p])*0x1000000000000+0x10000000000*t[p+1]+0x100000000*t[p+2]+0x1000000*t[p+3]+(t[p+4]<<16)+(t[p+5]<<8)+t[p+6])>=9e15?crypto.randomBytes(7).copy(t,p):(d.push(c%1e14),p+=7);p=l/7}else throw k=!1,Error(a+"crypto unavailable");if(!k)for(;p<l;)(c=r())<9e15&&(d[p++]=c%1e14);for(l=d[--p],e%=14,l&&e&&(c=u[14-e],d[p]=s(l/c)*c);0===d[p];d.pop(),p--);if(p<0)d=[i=0];else{for(i=-1;0===d[0];d.splice(0,1),i-=14);for(p=1,c=d[0];c>=10;c/=10,p++);p<14&&(i-=14-p)}return f.e=i,f.c=d,f},j.sum=function(){for(var e=1,t=arguments,r=new j(t[0]);e<t.length;)r=r.plus(t[e++]);return r},T=function(){var e="0123456789";function t(e,t,r,n){for(var i,o,s=[0],a=0,l=e.length;a<l;){for(o=s.length;o--;s[o]*=t);for(s[0]+=n.indexOf(e.charAt(a++)),i=0;i<s.length;i++)s[i]>r-1&&(null==s[i+1]&&(s[i+1]=0),s[i+1]+=s[i]/r|0,s[i]%=r)}return s.reverse()}return function(r,n,i,o,s){var a,l,u,c,d,h,f,m,y=r.indexOf("."),_=I,E=O;for(y>=0&&(c=x,x=0,r=r.replace(".",""),h=(m=new j(n)).pow(r.length-y),x=c,m.c=t(g(p(h.c),h.e,"0"),10,i,e),m.e=m.c.length),u=c=(f=t(r,n,i,s?(a=G,e):(a=e,G))).length;0==f[--c];f.pop());if(!f[0])return a.charAt(0);if(y<0?--u:(h.c=f,h.e=u,h.s=o,f=(h=A(h,m,_,E,i)).c,d=h.r,u=h.e),y=f[l=u+_+1],c=i/2,d=d||l<0||null!=f[l+1],d=E<4?(null!=y||d)&&(0==E||E==(h.s<0?3:2)):y>c||y==c&&(4==E||d||6==E&&1&f[l-1]||E==(h.s<0?8:7)),l<1||!f[0])r=d?g(a.charAt(1),-_,a.charAt(0)):a.charAt(0);else{if(f.length=l,d)for(--i;++f[--l]>i;)f[l]=0,l||(++u,f=[1].concat(f));for(c=f.length;!f[--c];);for(y=0,r="";y<=c;r+=a.charAt(f[y++]));r=g(r,u,a.charAt(0))}return r}}(),A=function(){function e(e,t,r){var n,i,o,s,a=0,l=e.length,u=t%1e7,c=t/1e7|0;for(e=e.slice();l--;)n=c*(o=e[l]%1e7)+(s=e[l]/1e7|0)*u,a=((i=u*o+n%1e7*1e7+a)/r|0)+(n/1e7|0)+c*s,e[l]=i%r;return a&&(e=[a].concat(e)),e}function t(e,t,r,n){var i,o;if(r!=n)o=r>n?1:-1;else for(i=o=0;i<r;i++)if(e[i]!=t[i]){o=e[i]>t[i]?1:-1;break}return o}function r(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=+(e[r]<t[r]),e[r]=i*n+e[r]-t[r];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(n,i,o,a,l){var u,p,d,h,f,m,g,y,_,E,v,A,T,C,S,b,I,O=n.s==i.s?1:-1,w=n.c,P=i.c;if(!w||!w[0]||!P||!P[0])return new j(!n.s||!i.s||(w?P&&w[0]==P[0]:!P)?NaN:w&&0==w[0]||!P?0*O:O/0);for(_=(y=new j(O)).c=[],O=o+(p=n.e-i.e)+1,l||(l=1e14,p=c(n.e/14)-c(i.e/14),O=O/14|0),d=0;P[d]==(w[d]||0);d++);if(P[d]>(w[d]||0)&&p--,O<0)_.push(1),h=!0;else{for(C=w.length,b=P.length,d=0,O+=2,(f=s(l/(P[0]+1)))>1&&(P=e(P,f,l),w=e(w,f,l),b=P.length,C=w.length),T=b,v=(E=w.slice(0,b)).length;v<b;E[v++]=0);I=[0].concat(I=P.slice()),S=P[0],P[1]>=l/2&&S++;do{if(f=0,(u=t(P,E,b,v))<0){if(A=E[0],b!=v&&(A=A*l+(E[1]||0)),(f=s(A/S))>1)for(f>=l&&(f=l-1),g=(m=e(P,f,l)).length,v=E.length;1==t(m,E,g,v);)f--,r(m,b<g?I:P,g,l),g=m.length,u=1;else 0==f&&(u=f=1),g=(m=P.slice()).length;if(g<v&&(m=[0].concat(m)),r(E,m,v,l),v=E.length,-1==u)for(;1>t(P,E,b,v);)f++,r(E,b<v?I:P,v,l),v=E.length}else 0===u&&(f++,E=[0]);_[d++]=f,E[0]?E[v++]=w[T]||0:(E=[w[T]],v=1)}while((T++<C||null!=E[0])&&O--)h=null!=E[0],_[0]||_.splice(0,1)}if(1e14==l){for(d=1,O=_[0];O>=10;O/=10,d++);H(y,o+(y.e=d+14*p-1)+1,a,h)}else y.e=p,y.r=+h;return y}}(),n=/^(-?)0([xbo])(?=\w[\w.]*$)/i,y=/^([^.]+)\.$/,_=/^\.([^.]+)$/,E=/^-?(Infinity|NaN)$/,v=/^\s*\+(?=[\w.])|^\s+|\s+$/g,C=function(e,t,r,i){var o,s=r?t:t.replace(v,"");if(E.test(s))e.s=isNaN(s)?null:s<0?-1:1;else{if(!r&&(s=s.replace(n,function(e,t,r){return o="x"==(r=r.toLowerCase())?16:"b"==r?2:8,i&&i!=o?e:t}),i&&(o=i,s=s.replace(y,"$1").replace(_,"0.$1")),t!=s))return new j(s,o);if(j.DEBUG)throw Error(a+"Not a"+(i?" base "+i:"")+" number: "+t);e.s=null}e.c=e.e=null},S.absoluteValue=S.abs=function(){var e=new j(this);return e.s<0&&(e.s=1),e},S.comparedTo=function(e,t){return d(this,new j(e,t))},S.decimalPlaces=S.dp=function(e,t){var r,n,i;if(null!=e)return h(e,0,1e9),null==t?t=O:h(t,0,8),H(new j(this),e+this.e+1,t);if(!(r=this.c))return null;if(n=((i=r.length-1)-c(this.e/14))*14,i=r[i])for(;i%10==0;i/=10,n--);return n<0&&(n=0),n},S.dividedBy=S.div=function(e,t){return A(this,new j(e,t),I,O)},S.dividedToIntegerBy=S.idiv=function(e,t){return A(this,new j(e,t),0,1)},S.exponentiatedBy=S.pow=function(e,t){var r,n,i,l,u,c,p,d,h,m=this;if((e=new j(e)).c&&!e.isInteger())throw Error(a+"Exponent not an integer: "+B(e));if(null!=t&&(t=new j(t)),c=e.e>14,!m.c||!m.c[0]||1==m.c[0]&&!m.e&&1==m.c.length||!e.c||!e.c[0])return h=new j(Math.pow(+B(m),c?e.s*(2-f(e)):+B(e))),t?h.mod(t):h;if(p=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new j(NaN);(n=!p&&m.isInteger()&&t.isInteger())&&(m=m.mod(t))}else{if(e.e>9&&(m.e>0||m.e<-1||(0==m.e?m.c[0]>1||c&&m.c[1]>=24e7:m.c[0]<8e13||c&&m.c[0]<=9999975e7)))return l=m.s<0&&f(e)?-0:0,m.e>-1&&(l=1/l),new j(p?1/l:l);x&&(l=o(x/14+2))}for(c?(r=new j(.5),p&&(e.s=1),d=f(e)):d=(i=Math.abs(+B(e)))%2,h=new j(b);;){if(d){if(!(h=h.times(m)).c)break;l?h.c.length>l&&(h.c.length=l):n&&(h=h.mod(t))}if(i){if(0===(i=s(i/2)))break;d=i%2}else if(H(e=e.times(r),e.e+1,1),e.e>14)d=f(e);else{if(0==(i=+B(e)))break;d=i%2}m=m.times(m),l?m.c&&m.c.length>l&&(m.c.length=l):n&&(m=m.mod(t))}return n?h:(p&&(h=b.div(h)),t?h.mod(t):l?H(h,x,O,u):h)},S.integerValue=function(e){var t=new j(this);return null==e?e=O:h(e,0,8),H(t,t.e+1,e)},S.isEqualTo=S.eq=function(e,t){return 0===d(this,new j(e,t))},S.isFinite=function(){return!!this.c},S.isGreaterThan=S.gt=function(e,t){return d(this,new j(e,t))>0},S.isGreaterThanOrEqualTo=S.gte=function(e,t){return 1===(t=d(this,new j(e,t)))||0===t},S.isInteger=function(){return!!this.c&&c(this.e/14)>this.c.length-2},S.isLessThan=S.lt=function(e,t){return 0>d(this,new j(e,t))},S.isLessThanOrEqualTo=S.lte=function(e,t){return -1===(t=d(this,new j(e,t)))||0===t},S.isNaN=function(){return!this.s},S.isNegative=function(){return this.s<0},S.isPositive=function(){return this.s>0},S.isZero=function(){return!!this.c&&0==this.c[0]},S.minus=function(e,t){var r,n,i,o,s=this.s;if(t=(e=new j(e,t)).s,!s||!t)return new j(NaN);if(s!=t)return e.s=-t,this.plus(e);var a=this.e/14,l=e.e/14,u=this.c,p=e.c;if(!a||!l){if(!u||!p)return u?(e.s=-t,e):new j(p?this:NaN);if(!u[0]||!p[0])return p[0]?(e.s=-t,e):new j(u[0]?this:3==O?-0:0)}if(a=c(a),l=c(l),u=u.slice(),s=a-l){for((o=s<0)?(s=-s,i=u):(l=a,i=p),i.reverse(),t=s;t--;i.push(0));i.reverse()}else for(n=(o=(s=u.length)<(t=p.length))?s:t,s=t=0;t<n;t++)if(u[t]!=p[t]){o=u[t]<p[t];break}if(o&&(i=u,u=p,p=i,e.s=-e.s),(t=(n=p.length)-(r=u.length))>0)for(;t--;u[r++]=0);for(t=1e14-1;n>s;){if(u[--n]<p[n]){for(r=n;r&&!u[--r];u[r]=t);--u[r],u[n]+=1e14}u[n]-=p[n]}for(;0==u[0];u.splice(0,1),--l);return u[0]?q(e,u,l):(e.s=3==O?-1:1,e.c=[e.e=0],e)},S.modulo=S.mod=function(e,t){var r,n;return(e=new j(e,t),this.c&&e.s&&(!e.c||e.c[0]))?e.c&&(!this.c||this.c[0])?(9==D?(n=e.s,e.s=1,r=A(this,e,0,3),e.s=n,r.s*=n):r=A(this,e,0,D),(e=this.minus(r.times(e))).c[0]||1!=D||(e.s=this.s),e):new j(this):new j(NaN)},S.multipliedBy=S.times=function(e,t){var r,n,i,o,s,a,l,u,p,d,h,f,m,g=this.c,y=(e=new j(e,t)).c;if(!g||!y||!g[0]||!y[0])return this.s&&e.s&&(!g||g[0]||y)&&(!y||y[0]||g)?(e.s*=this.s,g&&y?(e.c=[0],e.e=0):e.c=e.e=null):e.c=e.e=e.s=null,e;for(n=c(this.e/14)+c(e.e/14),e.s*=this.s,(l=g.length)<(d=y.length)&&(m=g,g=y,y=m,i=l,l=d,d=i),i=l+d,m=[];i--;m.push(0));for(i=d;--i>=0;){for(r=0,h=y[i]%1e7,f=y[i]/1e7|0,o=i+(s=l);o>i;)a=f*(u=g[--s]%1e7)+(p=g[s]/1e7|0)*h,r=((u=h*u+a%1e7*1e7+m[o]+r)/1e14|0)+(a/1e7|0)+f*p,m[o--]=u%1e14;m[o]=r}return r?++n:m.splice(0,1),q(e,m,n)},S.negated=function(){var e=new j(this);return e.s=-e.s||null,e},S.plus=function(e,t){var r,n=this.s;if(t=(e=new j(e,t)).s,!n||!t)return new j(NaN);if(n!=t)return e.s=-t,this.minus(e);var i=this.e/14,o=e.e/14,s=this.c,a=e.c;if(!i||!o){if(!s||!a)return new j(n/0);if(!s[0]||!a[0])return a[0]?e:new j(s[0]?this:0*n)}if(i=c(i),o=c(o),s=s.slice(),n=i-o){for(n>0?(o=i,r=a):(n=-n,r=s),r.reverse();n--;r.push(0));r.reverse()}for((n=s.length)-(t=a.length)<0&&(r=a,a=s,s=r,t=n),n=0;t;)n=(s[--t]=s[t]+a[t]+n)/1e14|0,s[t]=1e14===s[t]?0:s[t]%1e14;return n&&(s=[n].concat(s),++o),q(e,s,o)},S.precision=S.sd=function(e,t){var r,n,i;if(null!=e&&!!e!==e)return h(e,1,1e9),null==t?t=O:h(t,0,8),H(new j(this),e,t);if(!(r=this.c))return null;if(n=14*(i=r.length-1)+1,i=r[i]){for(;i%10==0;i/=10,n--);for(i=r[0];i>=10;i/=10,n++);}return e&&this.e+1>n&&(n=this.e+1),n},S.shiftedBy=function(e){return h(e,-0x1fffffffffffff,0x1fffffffffffff),this.times("1e"+e)},S.squareRoot=S.sqrt=function(){var e,t,r,n,i,o=this.c,s=this.s,a=this.e,l=I+4,u=new j("0.5");if(1!==s||!o||!o[0])return new j(!s||s<0&&(!o||o[0])?NaN:o?this:1/0);if(0==(s=Math.sqrt(+B(this)))||s==1/0?(((t=p(o)).length+a)%2==0&&(t+="0"),s=Math.sqrt(+t),a=c((a+1)/2)-(a<0||a%2),r=new j(t=s==1/0?"5e"+a:(t=s.toExponential()).slice(0,t.indexOf("e")+1)+a)):r=new j(s+""),r.c[0]){for((s=(a=r.e)+l)<3&&(s=0);;)if(i=r,r=u.times(i.plus(A(this,i,l,1))),p(i.c).slice(0,s)===(t=p(r.c)).slice(0,s)){if(r.e<a&&--s,"9999"!=(t=t.slice(s-3,s+1))&&(n||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(H(r,r.e+I+2,1),e=!r.times(r).eq(this));break}if(!n&&(H(i,i.e+I+2,0),i.times(i).eq(this))){r=i;break}l+=4,s+=4,n=1}}return H(r,r.e+I+1,O,e)},S.toExponential=function(e,t){return null!=e&&(h(e,0,1e9),e++),L(this,e,t,1)},S.toFixed=function(e,t){return null!=e&&(h(e,0,1e9),e=e+this.e+1),L(this,e,t)},S.toFormat=function(e,t,r){var n;if(null==r)null!=e&&t&&"object"==typeof t?(r=t,t=null):e&&"object"==typeof e?(r=e,e=t=null):r=U;else if("object"!=typeof r)throw Error(a+"Argument not an object: "+r);if(n=this.toFixed(e,t),this.c){var i,o=n.split("."),s=+r.groupSize,l=+r.secondaryGroupSize,u=r.groupSeparator||"",c=o[0],p=o[1],d=this.s<0,h=d?c.slice(1):c,f=h.length;if(l&&(i=s,s=l,l=i,f-=i),s>0&&f>0){for(i=f%s||s,c=h.substr(0,i);i<f;i+=s)c+=u+h.substr(i,s);l>0&&(c+=u+h.slice(i)),d&&(c="-"+c)}n=p?c+(r.decimalSeparator||"")+((l=+r.fractionGroupSize)?p.replace(RegExp("\\d{"+l+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):p):c}return(r.prefix||"")+n+(r.suffix||"")},S.toFraction=function(e){var t,r,n,i,o,s,l,c,d,h,f,m,g=this.c;if(null!=e&&(!(l=new j(e)).isInteger()&&(l.c||1!==l.s)||l.lt(b)))throw Error(a+"Argument "+(l.isInteger()?"out of range: ":"not an integer: ")+B(l));if(!g)return new j(this);for(t=new j(b),d=r=new j(b),n=c=new j(b),m=p(g),o=t.e=m.length-this.e-1,t.c[0]=u[(s=o%14)<0?14+s:s],e=!e||l.comparedTo(t)>0?o>0?t:d:l,s=N,N=1/0,l=new j(m),c.c[0]=0;h=A(l,t,0,1),1!=(i=r.plus(h.times(n))).comparedTo(e);)r=n,n=i,d=c.plus(h.times(i=d)),c=i,t=l.minus(h.times(i=t)),l=i;return i=A(e.minus(r),n,0,1),c=c.plus(i.times(d)),r=r.plus(i.times(n)),c.s=d.s=this.s,o*=2,f=1>A(d,n,o,O).minus(this).abs().comparedTo(A(c,r,o,O).minus(this).abs())?[d,n]:[c,r],N=s,f},S.toNumber=function(){return+B(this)},S.toPrecision=function(e,t){return null!=e&&h(e,1,1e9),L(this,e,t,2)},S.toString=function(e){var t,r=this,n=r.s,i=r.e;return null===i?n?(t="Infinity",n<0&&(t="-"+t)):t="NaN":(null==e?t=i<=w||i>=P?m(p(r.c),i):g(p(r.c),i,"0"):10===e&&M?t=g(p((r=H(new j(r),I+i+1,O)).c),r.e,"0"):(h(e,2,G.length,"Base"),t=T(g(p(r.c),i,"0"),10,e,n,!0)),n<0&&r.c[0]&&(t="-"+t)),t},S.valueOf=S.toJSON=function(){return B(this)},S._isBigNumber=!0,null!=t&&j.set(t),j}()).default=n.BigNumber=n,"function"==typeof define&&define.amd)e.r,void 0!==n&&e.v(n);else t.exports?t.exports=n:(r||(r="u">typeof self&&self?self:window),r.BigNumber=n)}(e.e)},64349,(e,t,r)=>{var n=e.r(45905),i=t.exports;!function(){"use strict";var e,t,r,o=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,s={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};function a(e){return o.lastIndex=0,o.test(e)?'"'+e.replace(o,function(e){var t=s[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'}"function"!=typeof i.stringify&&(i.stringify=function(i,o,s){var l;if(e="",t="","number"==typeof s)for(l=0;l<s;l+=1)t+=" ";else"string"==typeof s&&(t=s);if(r=o,o&&"function"!=typeof o&&("object"!=typeof o||"number"!=typeof o.length))throw Error("JSON.stringify");return function i(o,s){var l,u,c,p,d,h=e,f=s[o],m=null!=f&&(f instanceof n||n.isBigNumber(f));switch(f&&"object"==typeof f&&"function"==typeof f.toJSON&&(f=f.toJSON(o)),"function"==typeof r&&(f=r.call(s,o,f)),typeof f){case"string":if(m)return f;return a(f);case"number":return isFinite(f)?String(f):"null";case"boolean":case"null":case"bigint":return String(f);case"object":if(!f)return"null";if(e+=t,d=[],"[object Array]"===Object.prototype.toString.apply(f)){for(l=0,p=f.length;l<p;l+=1)d[l]=i(l,f)||"null";return c=0===d.length?"[]":e?"[\n"+e+d.join(",\n"+e)+"\n"+h+"]":"["+d.join(",")+"]",e=h,c}if(r&&"object"==typeof r)for(l=0,p=r.length;l<p;l+=1)"string"==typeof r[l]&&(c=i(u=r[l],f))&&d.push(a(u)+(e?": ":":")+c);else Object.keys(f).forEach(function(t){var r=i(t,f);r&&d.push(a(t)+(e?": ":":")+r)});return c=0===d.length?"{}":e?"{\n"+e+d.join(",\n"+e)+"\n"+h+"}":"{"+d.join(",")+"}",e=h,c}}("",{"":i})})}()},67104,(e,t,r)=>{var n=null;let i=/(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])/,o=/(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)/;t.exports=function(t){"use strict";var r={strict:!1,storeAsString:!1,alwaysParseAsBig:!1,useNativeBigInt:!1,protoAction:"error",constructorAction:"error"};if(null!=t){if(!0===t.strict&&(r.strict=!0),!0===t.storeAsString&&(r.storeAsString=!0),r.alwaysParseAsBig=!0===t.alwaysParseAsBig&&t.alwaysParseAsBig,r.useNativeBigInt=!0===t.useNativeBigInt&&t.useNativeBigInt,void 0!==t.constructorAction)if("error"===t.constructorAction||"ignore"===t.constructorAction||"preserve"===t.constructorAction)r.constructorAction=t.constructorAction;else throw Error(`Incorrect value for constructorAction option, must be "error", "ignore" or undefined but passed ${t.constructorAction}`);if(void 0!==t.protoAction)if("error"===t.protoAction||"ignore"===t.protoAction||"preserve"===t.protoAction)r.protoAction=t.protoAction;else throw Error(`Incorrect value for protoAction option, must be "error", "ignore" or undefined but passed ${t.protoAction}`)}var s,a,l,u,c={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:" "},p=function(e){throw{name:"SyntaxError",message:e,at:s,text:l}},d=function(e){return e&&e!==a&&p("Expected '"+e+"' instead of '"+a+"'"),a=l.charAt(s),s+=1,a},h=function(){var t,i="";for("-"===a&&(i="-",d("-"));a>="0"&&a<="9";)i+=a,d();if("."===a)for(i+=".";d()&&a>="0"&&a<="9";)i+=a;if("e"===a||"E"===a)for(i+=a,d(),("-"===a||"+"===a)&&(i+=a,d());a>="0"&&a<="9";)i+=a,d();if(isFinite(t=+i))return(null==n&&(n=e.r(45905)),i.length>15)?r.storeAsString?i:r.useNativeBigInt?BigInt(i):new n(i):r.alwaysParseAsBig?r.useNativeBigInt?BigInt(t):new n(t):t;p("Bad number")},f=function(){var e,t,r,n="";if('"'===a)for(var i=s;d();){if('"'===a)return s-1>i&&(n+=l.substring(i,s-1)),d(),n;if("\\"===a){if(s-1>i&&(n+=l.substring(i,s-1)),d(),"u"===a){for(t=0,r=0;t<4&&isFinite(e=parseInt(d(),16));t+=1)r=16*r+e;n+=String.fromCharCode(r)}else if("string"==typeof c[a])n+=c[a];else break;i=s}}p("Bad string")},m=function(){for(;a&&a<=" ";)d()},g=function(){switch(a){case"t":return d("t"),d("r"),d("u"),d("e"),!0;case"f":return d("f"),d("a"),d("l"),d("s"),d("e"),!1;case"n":return d("n"),d("u"),d("l"),d("l"),null}p("Unexpected '"+a+"'")},y=function(){var e=[];if("["===a){if(d("["),m(),"]"===a)return d("]"),e;for(;a;){if(e.push(u()),m(),"]"===a)return d("]"),e;d(","),m()}}p("Bad array")},_=function(){var e,t=Object.create(null);if("{"===a){if(d("{"),m(),"}"===a)return d("}"),t;for(;a;){if(e=f(),m(),d(":"),!0===r.strict&&Object.hasOwnProperty.call(t,e)&&p('Duplicate key "'+e+'"'),!0===i.test(e)?"error"===r.protoAction?p("Object contains forbidden prototype property"):"ignore"===r.protoAction?u():t[e]=u():!0===o.test(e)?"error"===r.constructorAction?p("Object contains forbidden constructor property"):"ignore"===r.constructorAction?u():t[e]=u():t[e]=u(),m(),"}"===a)return d("}"),t;d(","),m()}}p("Bad object")};return u=function(){switch(m(),a){case"{":return _();case"[":return y();case'"':return f();case"-":return h();default:return a>="0"&&a<="9"?h():g()}},function(e,t){var r;return l=e+"",s=0,a=" ",r=u(),m(),a&&p("Syntax error"),"function"==typeof t?function e(r,n){var i,o=r[n];return o&&"object"==typeof o&&Object.keys(o).forEach(function(t){void 0!==(i=e(o,t))?o[t]=i:delete o[t]}),t.call(r,n,o)}({"":r},""):r}}},1158,(e,t,r)=>{var n=e.r(64349).stringify,i=e.r(67104);t.exports=function(e){return{parse:i(e),stringify:n}},t.exports.parse=i(),t.exports.stringify=n},6737,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.Colours=void 0;class n{static isEnabled(e){return e&&e.isTTY&&("function"!=typeof e.getColorDepth||e.getColorDepth()>2)}static refresh(){n.enabled=n.isEnabled(null==process?void 0:process.stderr),this.enabled?(n.reset="\x1b[0m",n.bright="\x1b[1m",n.dim="\x1b[2m",n.red="\x1b[31m",n.green="\x1b[32m",n.yellow="\x1b[33m",n.blue="\x1b[34m",n.magenta="\x1b[35m",n.cyan="\x1b[36m",n.white="\x1b[37m",n.grey="\x1b[90m"):(n.reset="",n.bright="",n.dim="",n.red="",n.green="",n.yellow="",n.blue="",n.magenta="",n.cyan="",n.white="",n.grey="")}}r.Colours=n,n.enabled=!1,n.reset="",n.bright="",n.dim="",n.red="",n.green="",n.yellow="",n.blue="",n.magenta="",n.cyan="",n.white="",n.grey="",n.refresh()},90812,(e,t,r)=>{"use strict";let n;var i,o,s,a=e.e&&e.e.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),l=e.e&&e.e.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),u=e.e&&e.e.__importStar||(i=function(e){return(i=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t})(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=i(e),n=0;n<r.length;n++)"default"!==r[n]&&a(t,e,r[n]);return l(t,e),t});Object.defineProperty(r,"__esModule",{value:!0}),r.env=r.DebugLogBackendBase=r.placeholder=r.AdhocDebugLogger=r.LogSeverity=void 0,r.getNodeBackend=y,r.getDebugBackend=function(e){return new _(e)},r.getStructuredBackend=function(e){return new E(e)},r.setBackend=function(e){n=e,v.clear()},r.log=A;let c=e.r(27699),p=u(e.r(5365)),d=u(e.r(24361)),h=e.r(6737);(o=s||(r.LogSeverity=s={})).DEFAULT="DEFAULT",o.DEBUG="DEBUG",o.INFO="INFO",o.WARNING="WARNING",o.ERROR="ERROR";class f extends c.EventEmitter{constructor(e,t){super(),this.namespace=e,this.upstream=t,this.func=Object.assign(this.invoke.bind(this),{instance:this,on:(e,t)=>this.on(e,t)}),this.func.debug=(...e)=>this.invokeSeverity(s.DEBUG,...e),this.func.info=(...e)=>this.invokeSeverity(s.INFO,...e),this.func.warn=(...e)=>this.invokeSeverity(s.WARNING,...e),this.func.error=(...e)=>this.invokeSeverity(s.ERROR,...e),this.func.sublog=e=>A(e,this.func)}invoke(e,...t){if(this.upstream)try{this.upstream(e,...t)}catch(e){}try{this.emit("log",e,t)}catch(e){}}invokeSeverity(e,...t){this.invoke({severity:e},...t)}}r.AdhocDebugLogger=f,r.placeholder=new f("",()=>{}).func;class m{constructor(){var e;this.cached=new Map,this.filters=[],this.filtersSet=!1;let t=null!=(e=p.env[r.env.nodeEnables])?e:"*";"all"===t&&(t="*"),this.filters=t.split(",")}log(e,t,...r){try{this.filtersSet||(this.setFilters(),this.filtersSet=!0);let n=this.cached.get(e);n||(n=this.makeLogger(e),this.cached.set(e,n)),n(t,...r)}catch(e){console.error(e)}}}r.DebugLogBackendBase=m;class g extends m{constructor(){super(...arguments),this.enabledRegexp=/.*/g}isEnabled(e){return this.enabledRegexp.test(e)}makeLogger(e){return this.enabledRegexp.test(e)?(t,...r)=>{var n;let i,o=`${h.Colours.green}${e}${h.Colours.reset}`,a=`${h.Colours.yellow}${p.pid}${h.Colours.reset}`;switch(t.severity){case s.ERROR:i=`${h.Colours.red}${t.severity}${h.Colours.reset}`;break;case s.INFO:i=`${h.Colours.magenta}${t.severity}${h.Colours.reset}`;break;case s.WARNING:i=`${h.Colours.yellow}${t.severity}${h.Colours.reset}`;break;default:i=null!=(n=t.severity)?n:s.DEFAULT}let l=d.formatWithOptions({colors:h.Colours.enabled},...r),u=Object.assign({},t);delete u.severity;let c=Object.getOwnPropertyNames(u).length?JSON.stringify(u):"",f=c?`${h.Colours.grey}${c}${h.Colours.reset}`:"";console.error("%s [%s|%s] %s%s",a,o,i,l,c?` ${f}`:"")}:()=>{}}setFilters(){let e=this.filters.join(",").replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^");this.enabledRegexp=RegExp(`^${e}$`,"i")}}function y(){return new g}class _ extends m{constructor(e){super(),this.debugPkg=e}makeLogger(e){let t=this.debugPkg(e);return(e,...r)=>{t(r[0],...r.slice(1))}}setFilters(){var e;let t=null!=(e=p.env.NODE_DEBUG)?e:"";p.env.NODE_DEBUG=`${t}${t?",":""}${this.filters.join(",")}`}}class E extends m{constructor(e){super(),this.upstream=null!=e?e:void 0}makeLogger(e){var t;let r=null==(t=this.upstream)?void 0:t.makeLogger(e);return(e,...t)=>{var n;let i=JSON.stringify(Object.assign({severity:null!=(n=e.severity)?n:s.INFO,message:d.format(...t)},e));r?r(e,i):console.log("%s",i)}}setFilters(){var e;null==(e=this.upstream)||e.setFilters()}}r.env={nodeEnables:"GOOGLE_SDK_NODE_LOGGING"};let v=new Map;function A(e,t){let i;if(!n&&!p.env[r.env.nodeEnables]||!e)return r.placeholder;t&&(e=`${t.instance.namespace}:${e}`);let o=v.get(e);if(o)return o.func;if(null===n)return r.placeholder;void 0===n&&(n=y());let s=new f(e,(t,...r)=>{if(i!==n){if(null===n)return;void 0===n&&(n=y()),i=n}null==n||n.log(e,t,...r)});return v.set(e,s),s.func}},47637,(e,t,r)=>{"use strict";var n=e.e&&e.e.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=e.e&&e.e.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(r,"__esModule",{value:!0}),i(e.r(90812),r)},82e3,(e,t,r)=>{"use strict";let n;var i,o=e.e&&e.e.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),s=e.e&&e.e.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=e.e&&e.e.__importStar||(i=function(e){return(i=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t})(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=i(e),n=0;n<r.length;n++)"default"!==r[n]&&o(t,e,r[n]);return s(t,e),t}),l=e.e&&e.e.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||o(t,e,r)};Object.defineProperty(r,"__esModule",{value:!0}),r.gcpResidencyCache=r.METADATA_SERVER_DETECTION=r.HEADERS=r.HEADER_VALUE=r.HEADER_NAME=r.SECONDARY_HOST_ADDRESS=r.HOST_ADDRESS=r.BASE_PATH=void 0,r.instance=function(e){return m("instance",e)},r.project=function(e){return m("project",e)},r.universe=function(e){return m("universe",e)},r.bulk=y,r.isAvailable=_,r.resetIsAvailableCache=function(){n=void 0},r.getGCPResidency=E,r.setGCPResidency=v,r.requestTimeout=A;let u=e.r(57612),c=e.r(1158),p=e.r(29077),d=a(e.r(47637));r.BASE_PATH="/computeMetadata/v1",r.HOST_ADDRESS="http://169.254.169.254",r.SECONDARY_HOST_ADDRESS="http://metadata.google.internal.",r.HEADER_NAME="Metadata-Flavor",r.HEADER_VALUE="Google",r.HEADERS=Object.freeze({[r.HEADER_NAME]:r.HEADER_VALUE});let h=d.log("gcp-metadata");function f(e){return e||(e=process.env.GCE_METADATA_IP||process.env.GCE_METADATA_HOST||r.HOST_ADDRESS),/^https?:\/\//.test(e)||(e=`http://${e}`),new URL(r.BASE_PATH,e).href}async function m(e,t={},n=3,i=!1){let o=new Headers(r.HEADERS),s="",a={};("object"==typeof e?(new Headers(e.headers).forEach((e,t)=>o.set(t,e)),s=e.metadataKey,a=e.params||a,n=e.noResponseRetries||n,i=e.fastFail||i):s=e,"string"==typeof t)?s+=`/${t}`:(Object.keys(t).forEach(e=>{switch(e){case"params":case"property":case"headers":break;case"qs":throw Error("'qs' is not a valid configuration option. Please use 'params' instead.");default:throw Error(`'${e}' is not a valid configuration option.`)}}),t.property&&(s+=`/${t.property}`),new Headers(t.headers).forEach((e,t)=>o.set(t,e)),a=t.params||a);let l=i?g:u.request,p={url:`${f()}/${s}`,headers:o,retryConfig:{noResponseRetries:n},params:a,responseType:"text",timeout:A()};h.info("instance request %j",p);let d=await l(p);h.info("instance metadata is %s",d.data);let y=d.headers.get(r.HEADER_NAME);if(y!==r.HEADER_VALUE)throw RangeError(`Invalid response from metadata service: incorrect ${r.HEADER_NAME} header. Expected '${r.HEADER_VALUE}', got ${y?`'${y}'`:"no header"}`);if("string"==typeof d.data)try{return c.parse(d.data)}catch{}return d.data}async function g(e){let t={...e,url:e.url?.toString().replace(f(),f(r.SECONDARY_HOST_ADDRESS))};return Promise.any([(0,u.request)(e),(0,u.request)(t)])}async function y(e){let t={};return await Promise.all(e.map(e=>(async()=>{let r=await m(e);t[e.metadataKey]=r})())),t}async function _(){if(process.env.METADATA_SERVER_DETECTION){let e=process.env.METADATA_SERVER_DETECTION.trim().toLocaleLowerCase();if(!(e in r.METADATA_SERVER_DETECTION))throw RangeError(`Unknown \`METADATA_SERVER_DETECTION\` env variable. Got \`${e}\`, but it should be \`${Object.keys(r.METADATA_SERVER_DETECTION).join("`, `")}\`, or unset`);switch(e){case"assume-present":return!0;case"none":return!1;case"bios-only":return E()}}try{return void 0===n&&(n=m("instance",void 0,process.env.DETECT_GCP_RETRIES?Number(process.env.DETECT_GCP_RETRIES):0,!(process.env.GCE_METADATA_IP||process.env.GCE_METADATA_HOST))),await n,!0}catch(e){if(process.env.DEBUG_AUTH&&console.info(e),"request-timeout"===e.type||e.response&&404===e.response.status)return!1;if(!(e.response&&404===e.response.status)&&(!e.code||!["EHOSTDOWN","EHOSTUNREACH","ENETUNREACH","ENOENT","ENOTFOUND","ECONNREFUSED"].includes(e.code.toString()))){let t="UNKNOWN";e.code&&(t=e.code.toString()),process.emitWarning(`received unexpected error = ${e.message} code = ${t}`,"MetadataLookupWarning")}return!1}}function E(){return null===r.gcpResidencyCache&&v(),r.gcpResidencyCache}function v(e=null){r.gcpResidencyCache=null!==e?e:(0,p.detectGCPResidency)()}function A(){return 3e3*!E()}r.METADATA_SERVER_DETECTION=Object.freeze({"assume-present":"don't try to ping the metadata server, but assume it's present",none:"don't try to ping the metadata server, but don't try to use it either","bios-only":"treat the result of a BIOS probe as canonical (don't fall back to pinging)","ping-only":"skip the BIOS probe, and go straight to pinging"}),r.gcpResidencyCache=null,l(e.r(29077),r)},6920,(e,t,r)=>{"use strict";r.byteLength=function(e){var t=u(e),r=t[0],n=t[1];return(r+n)*3/4-n},r.toByteArray=function(e){var t,r,n=u(e),s=n[0],a=n[1],l=new o((s+a)*3/4-a),c=0,p=a>0?s-4:s;for(r=0;r<p;r+=4)t=i[e.charCodeAt(r)]<<18|i[e.charCodeAt(r+1)]<<12|i[e.charCodeAt(r+2)]<<6|i[e.charCodeAt(r+3)],l[c++]=t>>16&255,l[c++]=t>>8&255,l[c++]=255&t;return 2===a&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,l[c++]=255&t),1===a&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[e.charCodeAt(r+2)]>>2,l[c++]=t>>8&255,l[c++]=255&t),l},r.fromByteArray=function(e){for(var t,r=e.length,i=r%3,o=[],s=0,a=r-i;s<a;s+=16383)o.push(function(e,t,r){for(var i,o=[],s=t;s<r;s+=3)i=(e[s]<<16&0xff0000)+(e[s+1]<<8&65280)+(255&e[s+2]),o.push(n[i>>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return o.join("")}(e,s,s+16383>a?a:s+16383));return 1===i?o.push(n[(t=e[r-1])>>2]+n[t<<4&63]+"=="):2===i&&o.push(n[(t=(e[r-2]<<8)+e[r-1])>>10]+n[t>>4&63]+n[t<<2&63]+"="),o.join("")};for(var n=[],i=[],o="u">typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,l=s.length;a<l;++a)n[a]=s[a],i[s.charCodeAt(a)]=a;function u(e){var t=e.length;if(t%4>0)throw Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");-1===r&&(r=t);var n=r===t?0:4-r%4;return[r,n]}i[45]=62,i[95]=63},46902,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.fromArrayBufferToHex=function(e){return Array.from(new Uint8Array(e)).map(e=>e.toString(16).padStart(2,"0")).join("")}},69216,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.BrowserCrypto=void 0;let n=e.r(6920),i=e.r(46902);class o{constructor(){throw Error("SubtleCrypto not found. Make sure it's an https:// website.")}async sha256DigestBase64(e){let t=new TextEncoder().encode(e),r=await window.crypto.subtle.digest("SHA-256",t);return n.fromByteArray(new Uint8Array(r))}randomBytesBase64(e){let t=new Uint8Array(e);return window.crypto.getRandomValues(t),n.fromByteArray(t)}static padBase64(e){for(;e.length%4!=0;)e+="=";return e}async verify(e,t,r){let i={name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},s=new TextEncoder().encode(t),a=n.toByteArray(o.padBase64(r)),l=await window.crypto.subtle.importKey("jwk",e,i,!0,["verify"]);return await window.crypto.subtle.verify(i,l,Buffer.from(a),s)}async sign(e,t){let r={name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},i=new TextEncoder().encode(t),o=await window.crypto.subtle.importKey("jwk",e,r,!0,["sign"]),s=await window.crypto.subtle.sign(r,o,i);return n.fromByteArray(new Uint8Array(s))}decodeBase64StringUtf8(e){let t=n.toByteArray(o.padBase64(e));return new TextDecoder().decode(t)}encodeBase64StringUtf8(e){let t=new TextEncoder().encode(e);return n.fromByteArray(t)}async sha256DigestHex(e){let t=new TextEncoder().encode(e),r=await window.crypto.subtle.digest("SHA-256",t);return(0,i.fromArrayBufferToHex)(r)}async signWithHmacSha256(e,t){let r="string"==typeof e?e:String.fromCharCode(...new Uint16Array(e)),n=new TextEncoder,i=await window.crypto.subtle.importKey("raw",n.encode(r),{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);return window.crypto.subtle.sign("HMAC",i,n.encode(t))}}r.BrowserCrypto=o},21962,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.NodeCrypto=void 0;let n=e.r(54799);r.NodeCrypto=class{async sha256DigestBase64(e){return n.createHash("sha256").update(e).digest("base64")}randomBytesBase64(e){return n.randomBytes(e).toString("base64")}async verify(e,t,r){let i=n.createVerify("RSA-SHA256");return i.update(t),i.end(),i.verify(e,r,"base64")}async sign(e,t){let r=n.createSign("RSA-SHA256");return r.update(t),r.end(),r.sign(e,"base64")}decodeBase64StringUtf8(e){return Buffer.from(e,"base64").toString("utf-8")}encodeBase64StringUtf8(e){return Buffer.from(e,"utf-8").toString("base64")}async sha256DigestHex(e){return n.createHash("sha256").update(e).digest("hex")}async signWithHmacSha256(e,t){var r;let i="string"==typeof e?e:(r=e,Buffer.from(r));return function(e){let t=new ArrayBuffer(e.length),r=new Uint8Array(t);for(let t=0;t<e.length;++t)r[t]=e[t];return t}(n.createHmac("sha256",i).update(t).digest())}}},59501,(e,t,r)=>{"use strict";var n=e.e&&e.e.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=e.e&&e.e.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(r,"__esModule",{value:!0}),r.createCrypto=function(){return function(){;}(),new o.NodeCrypto},r.hasBrowserCrypto=s,e.r(69216);let o=e.r(21962);function s(){return!1}i(e.r(46902),r)},23469,(e,t,r)=>{var n=e.r(874),i=n.Buffer;function o(e,t){for(var r in e)t[r]=e[r]}function s(e,t,r){return i(e,t,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(o(n,r),r.Buffer=s),s.prototype=Object.create(i.prototype),o(i,s),s.from=function(e,t,r){if("number"==typeof e)throw TypeError("Argument must not be a number");return i(e,t,r)},s.alloc=function(e,t,r){if("number"!=typeof e)throw TypeError("Argument must be a number");var n=i(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},s.allocUnsafe=function(e){if("number"!=typeof e)throw TypeError("Argument must be a number");return i(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw TypeError("Argument must be a number");return n.SlowBuffer(e)}},65880,(e,t,r)=>{"use strict";function n(e){return(e/8|0)+ +(e%8!=0)}var i={ES256:n(256),ES384:n(384),ES512:n(521)};t.exports=function(e){var t=i[e];if(t)return t;throw Error('Unknown algorithm "'+e+'"')}},32955,(e,t,r)=>{"use strict";var n=e.r(23469).Buffer,i=e.r(65880);function o(e){if(n.isBuffer(e))return e;if("string"==typeof e)return n.from(e,"base64");throw TypeError("ECDSA signature must be a Base64 string or a Buffer")}function s(e,t,r){for(var n=0;t+n<r&&0===e[t+n];)++n;return e[t+n]>=128&&--n,n}t.exports={derToJose:function(e,t){e=o(e);var r=i(t),s=r+1,a=e.length,l=0;if(48!==e[l++])throw Error('Could not find expected "seq"');var u=e[l++];if(129===u&&(u=e[l++]),a-l<u)throw Error('"seq" specified length of "'+u+'", only "'+(a-l)+'" remaining');if(2!==e[l++])throw Error('Could not find expected "int" for "r"');var c=e[l++];if(a-l-2<c)throw Error('"r" specified length of "'+c+'", only "'+(a-l-2)+'" available');if(s<c)throw Error('"r" specified length of "'+c+'", max of "'+s+'" is acceptable');var p=l;if(l+=c,2!==e[l++])throw Error('Could not find expected "int" for "s"');var d=e[l++];if(a-l!==d)throw Error('"s" specified length of "'+d+'", expected "'+(a-l)+'"');if(s<d)throw Error('"s" specified length of "'+d+'", max of "'+s+'" is acceptable');var h=l;if((l+=d)!==a)throw Error('Expected to consume entire buffer, but "'+(a-l)+'" bytes remain');var f=r-c,m=r-d,g=n.allocUnsafe(f+c+m+d);for(l=0;l<f;++l)g[l]=0;e.copy(g,l,p+Math.max(-f,0),p+c),l=r;for(var y=l;l<y+m;++l)g[l]=0;return e.copy(g,l,h+Math.max(-m,0),h+d),g=(g=g.toString("base64")).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")},joseToDer:function(e,t){e=o(e);var r=i(t),a=e.length;if(a!==2*r)throw TypeError('"'+t+'" signatures must be "'+2*r+'" bytes, saw "'+a+'"');var l=s(e,0,r),u=s(e,r,e.length),c=r-l,p=r-u,d=2+c+1+1+p,h=d<128,f=n.allocUnsafe((h?2:3)+d),m=0;return f[m++]=48,h?f[m++]=d:(f[m++]=129,f[m++]=255&d),f[m++]=2,f[m++]=c,l<0?(f[m++]=0,m+=e.copy(f,m,0,r)):m+=e.copy(f,m,l,r),f[m++]=2,f[m++]=p,u<0?(f[m++]=0,e.copy(f,m,r)):e.copy(f,m,r+u),f}}},15733,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.LRUCache=void 0,r.snakeToCamel=a,r.originalOrCamelOptions=function(e){return{get:function(t){let r=e||{};return r[t]??r[a(t)]}}},r.removeUndefinedValuesInObject=function(e){return Object.entries(e).forEach(([t,r])=>{(void 0===r||"undefined"===r)&&delete e[t]}),e},r.isValidFile=u,r.getWellKnownCertificateConfigFileLocation=function(){let e=process.env.CLOUDSDK_CONFIG||(i.platform().startsWith("win")?o.join(process.env.APPDATA||"",s):o.join(process.env.HOME||"",".config",s));return o.join(e,"certificate_config.json")};let n=e.r(22734),i=e.r(46786),o=e.r(14747),s="gcloud";function a(e){return e.replace(/([_][^_])/g,e=>e.slice(1).toUpperCase())}class l{capacity;#u=new Map;maxAge;constructor(e){this.capacity=e.capacity,this.maxAge=e.maxAge}#c(e,t){this.#u.delete(e),this.#u.set(e,{value:t,lastAccessed:Date.now()})}set(e,t){this.#c(e,t),this.#p()}get(e){let t=this.#u.get(e);if(t)return this.#c(e,t.value),this.#p(),t.value}#p(){let e=this.maxAge?Date.now()-this.maxAge:0,t=this.#u.entries().next();for(;!t.done&&(this.#u.size>this.capacity||t.value[1].lastAccessed<e);)this.#u.delete(t.value[0]),t=this.#u.entries().next()}}async function u(e){try{return(await n.promises.lstat(e)).isFile()}catch(e){return!1}}r.LRUCache=l},57660,(e,t,r)=>{t.exports={name:"google-auth-library",version:"10.9.0",author:"Google Inc.",description:"Google APIs Authentication Client Library for Node.js",engines:{node:">=18"},main:"./build/src/index.js",types:"./build/src/index.d.ts",repository:{type:"git",directory:"core/packages/google-auth-library-nodejs",url:"https://github.com/googleapis/google-cloud-node.git"},keywords:["google","api","google apis","client","client library"],dependencies:{"base64-js":"^1.3.0","ecdsa-sig-formatter":"^1.0.11",gaxios:"^7.1.4","gcp-metadata":"8.1.2","google-logging-utils":"1.1.3",jws:"^4.0.0"},devDependencies:{"@types/base64-js":"^1.2.5","@types/jws":"^3.1.0","@types/mocha":"^10.0.10","@types/mv":"^2.1.0","@types/ncp":"^2.0.8","@types/node":"^24.0.0","@types/sinon":"^21.0.0","assert-rejects":"^1.0.0",c8:"^10.1.3",codecov:"^3.8.3",gts:"^6.0.2","is-docker":"^3.0.0",jsdoc:"^4.0.4","jsdoc-fresh":"^5.0.0","jsdoc-region-tag":"^4.0.0",karma:"^6.0.0","karma-chrome-launcher":"^3.0.0","karma-coverage":"^2.0.0","karma-firefox-launcher":"^2.0.0","karma-mocha":"^2.0.0","karma-sourcemap-loader":"^0.4.0","karma-webpack":"^5.0.1",keypair:"^1.0.4",mocha:"^11.1.0",mv:"^2.1.1",ncp:"^2.0.0",nock:"^14.0.5","null-loader":"^4.0.1",puppeteer:"^24.0.0",sinon:"21.0.3","ts-loader":"^9.5.2",typescript:"5.8.3",webpack:"^5.97.1","webpack-cli":"^6.0.1"},files:["build/src","!build/src/**/*.map"],scripts:{test:"c8 mocha build/test",clean:"gts clean",prepare:"npm run compile",lint:"gts check --no-inline-config",compile:"tsc -p .",fix:"gts fix",pretest:"npm run compile -- --sourceMap",docs:"jsdoc -c .jsdoc.js","samples-setup":"cd samples/ && npm link ../ && npm run setup && cd ../","samples-test":"cd samples/ && npm link ../ && npm test && cd ../","system-test":"mocha build/system-test --timeout 60000","presystem-test":"npm run compile -- --sourceMap",webpack:"webpack","browser-test":"karma start",prelint:"cd samples; npm link ../; npm install"},license:"Apache-2.0",homepage:"https://github.com/googleapis/google-cloud-node/tree/main/core/packages/google-auth-library-nodejs"}},93714,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.USER_AGENT=r.PRODUCT_NAME=r.pkg=void 0;let n=e.r(57660);r.pkg=n;let i="google-api-nodejs-client";r.PRODUCT_NAME=i,r.USER_AGENT=`${i}/${n.version}`},11656,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.AuthClient=r.DEFAULT_EAGER_REFRESH_THRESHOLD_MILLIS=r.DEFAULT_UNIVERSE=void 0;let n=e.r(27699),i=e.r(57612),o=e.r(15733),s=e.r(47637),a=e.r(93714);r.DEFAULT_UNIVERSE="googleapis.com",r.DEFAULT_EAGER_REFRESH_THRESHOLD_MILLIS=3e5;class l extends n.EventEmitter{apiKey;projectId;quotaProjectId;transporter;credentials={};eagerRefreshThresholdMillis=r.DEFAULT_EAGER_REFRESH_THRESHOLD_MILLIS;forceRefreshOnFailure=!1;universeDomain=r.DEFAULT_UNIVERSE;static RequestMethodNameSymbol=Symbol("request method name");static RequestLogIdSymbol=Symbol("request log id");constructor(e={}){super();const t=(0,o.originalOrCamelOptions)(e);this.apiKey=e.apiKey,this.projectId=t.get("project_id")??null,this.quotaProjectId=t.get("quota_project_id"),this.credentials=t.get("credentials")??{},this.universeDomain=t.get("universe_domain")??r.DEFAULT_UNIVERSE,this.transporter=e.transporter??new i.Gaxios(e.transporterOptions),!1!==t.get("useAuthRequestParameters")&&(this.transporter.interceptors.request.add(l.DEFAULT_REQUEST_INTERCEPTOR),this.transporter.interceptors.response.add(l.DEFAULT_RESPONSE_INTERCEPTOR)),e.eagerRefreshThresholdMillis&&(this.eagerRefreshThresholdMillis=e.eagerRefreshThresholdMillis),this.forceRefreshOnFailure=e.forceRefreshOnFailure??!1}fetch(...e){let t,r=e[0],n=e[1],o=new Headers;return("string"==typeof r?t=new URL(r):r instanceof URL?t=r:r&&r.url&&(t=new URL(r.url)),r&&"object"==typeof r&&"headers"in r&&i.Gaxios.mergeHeaders(o,r.headers),n&&i.Gaxios.mergeHeaders(o,new Headers(n.headers)),"object"!=typeof r||r instanceof URL)?this.request({...n,headers:o,url:t}):this.request({...n,...r,headers:o,url:t})}setCredentials(e){this.credentials=e}addSharedMetadataHeaders(e){return!e.has("x-goog-user-project")&&this.quotaProjectId&&e.set("x-goog-user-project",this.quotaProjectId),e}addUserProjectAndAuthHeaders(e,t){let r=t.get("x-goog-user-project"),n=t.get("authorization");return r&&e.set("x-goog-user-project",r),n&&e.set("authorization",n),e}static log=(0,s.log)("auth");static DEFAULT_REQUEST_INTERCEPTOR={resolved:async e=>{if(!e.headers.has("x-goog-api-client")){let t=process.version.replace(/^v/,"");e.headers.set("x-goog-api-client",`gl-node/${t}`)}let t=e.headers.get("User-Agent");t?t.includes(`${a.PRODUCT_NAME}/`)||e.headers.set("User-Agent",`${t} ${a.USER_AGENT}`):e.headers.set("User-Agent",a.USER_AGENT);try{let t=e[l.RequestMethodNameSymbol],r=`${Math.floor(1e3*Math.random())}`;e[l.RequestLogIdSymbol]=r;let n={url:e.url,headers:e.headers};t?l.log.info("%s [%s] request %j",t,r,n):l.log.info("[%s] request %j",r,n)}catch(e){}return e}};static DEFAULT_RESPONSE_INTERCEPTOR={resolved:async e=>{try{let t=e.config,r=t[l.RequestMethodNameSymbol],n=t[l.RequestLogIdSymbol];r?l.log.info("%s [%s] response %j",r,n,e.data):l.log.info("[%s] response %j",n,e.data)}catch(e){}return e},rejected:async e=>{try{let t=e.config,r=t[l.RequestMethodNameSymbol],n=t[l.RequestLogIdSymbol];r?l.log.info("%s [%s] error %j",r,n,e.response?.data):l.log.error("[%s] error %j",n,e.response?.data)}catch(e){}throw e}};static setMethodName(e,t){try{e[l.RequestMethodNameSymbol]=t}catch(e){}}static get RETRY_CONFIG(){return{retry:!0,retryConfig:{httpMethodsToRetry:["GET","PUT","POST","HEAD","OPTIONS","DELETE"]}}}}r.AuthClient=l},42602,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.LoginTicket=void 0,r.LoginTicket=class{envelope;payload;constructor(e,t){this.envelope=e,this.payload=t}getEnvelope(){return this.envelope}getPayload(){return this.payload}getUserId(){let e=this.getPayload();return e&&e.sub?e.sub:null}getAttributes(){return{envelope:this.getEnvelope(),payload:this.getPayload()}}}},701,(e,t,r)=>{"use strict";var n,i,o,s,a,l;Object.defineProperty(r,"__esModule",{value:!0}),r.OAuth2Client=r.ClientAuthentication=r.CertificateFormat=r.CodeChallengeMethod=void 0;let u=e.r(57612),c=e.r(45706),p=e.r(88947),d=e.r(32955),h=e.r(15733),f=e.r(59501),m=e.r(11656),g=e.r(42602);(s=n||(r.CodeChallengeMethod=n={})).Plain="plain",s.S256="S256",(a=i||(r.CertificateFormat=i={})).PEM="PEM",a.JWK="JWK",(l=o||(r.ClientAuthentication=o={})).ClientSecretPost="ClientSecretPost",l.ClientSecretBasic="ClientSecretBasic",l.None="None";class y extends m.AuthClient{redirectUri;certificateCache={};certificateExpiry=null;certificateCacheFormat=i.PEM;refreshTokenPromises=new Map;endpoints;issuers;clientAuthentication;_clientId;_clientSecret;refreshHandler;constructor(e={},t,r){super("object"==typeof e?e:{}),"object"!=typeof e&&(e={clientId:e,clientSecret:t,redirectUri:r}),this._clientId=e.clientId||e.client_id,this._clientSecret=e.clientSecret||e.client_secret,this.redirectUri=e.redirectUri||e.redirect_uris?.[0],this.endpoints={tokenInfoUrl:"https://oauth2.googleapis.com/tokeninfo",oauth2AuthBaseUrl:"https://accounts.google.com/o/oauth2/v2/auth",oauth2TokenUrl:"https://oauth2.googleapis.com/token",oauth2RevokeUrl:"https://oauth2.googleapis.com/revoke",oauth2FederatedSignonPemCertsUrl:"https://www.googleapis.com/oauth2/v1/certs",oauth2FederatedSignonJwkCertsUrl:"https://www.googleapis.com/oauth2/v3/certs",oauth2IapPublicKeyUrl:"https://www.gstatic.com/iap/verify/public_key",...e.endpoints},this.clientAuthentication=e.clientAuthentication||o.ClientSecretPost,this.issuers=e.issuers||["accounts.google.com","https://accounts.google.com",this.universeDomain]}static GOOGLE_TOKEN_INFO_URL="https://oauth2.googleapis.com/tokeninfo";static CLOCK_SKEW_SECS_=300;static DEFAULT_MAX_TOKEN_LIFETIME_SECS_=86400;generateAuthUrl(e={}){if(e.code_challenge_method&&!e.code_challenge)throw Error("If a code_challenge_method is provided, code_challenge must be included.");return e.response_type=e.response_type||"code",e.client_id=e.client_id||this._clientId,e.redirect_uri=e.redirect_uri||this.redirectUri,Array.isArray(e.scope)&&(e.scope=e.scope.join(" ")),this.endpoints.oauth2AuthBaseUrl.toString()+"?"+c.stringify(e)}generateCodeVerifier(){throw Error("generateCodeVerifier is removed, please use generateCodeVerifierAsync instead.")}async generateCodeVerifierAsync(){let e=(0,f.createCrypto)(),t=e.randomBytesBase64(96).replace(/\+/g,"~").replace(/=/g,"_").replace(/\//g,"-"),r=(await e.sha256DigestBase64(t)).split("=")[0].replace(/\+/g,"-").replace(/\//g,"_");return{codeVerifier:t,codeChallenge:r}}getToken(e,t){let r="string"==typeof e?{code:e}:e;if(!t)return this.getTokenAsync(r);this.getTokenAsync(r).then(e=>t(null,e.tokens,e.res),e=>t(e,null,e.response))}async getTokenAsync(e){let t=this.endpoints.oauth2TokenUrl.toString(),r=new Headers,n={client_id:e.client_id||this._clientId,code_verifier:e.codeVerifier,code:e.code,grant_type:"authorization_code",redirect_uri:e.redirect_uri||this.redirectUri};if(this.clientAuthentication===o.ClientSecretBasic){let e=Buffer.from(`${this._clientId}:${this._clientSecret}`);r.set("authorization",`Basic ${e.toString("base64")}`)}this.clientAuthentication===o.ClientSecretPost&&(n.client_secret=this._clientSecret);let i={...y.RETRY_CONFIG,method:"POST",url:t,data:new URLSearchParams((0,h.removeUndefinedValuesInObject)(n)),headers:r};m.AuthClient.setMethodName(i,"getTokenAsync");let s=await this.transporter.request(i),a=s.data;return s.data&&s.data.expires_in&&(a.expiry_date=new Date().getTime()+1e3*s.data.expires_in,delete a.expires_in),this.emit("tokens",a),{tokens:a,res:s}}async refreshToken(e){if(!e)return this.refreshTokenNoCache(e);if(this.refreshTokenPromises.has(e))return this.refreshTokenPromises.get(e);let t=this.refreshTokenNoCache(e).then(t=>(this.refreshTokenPromises.delete(e),t),t=>{throw this.refreshTokenPromises.delete(e),t});return this.refreshTokenPromises.set(e,t),t}async refreshTokenNoCache(e){let t;if(!e)throw Error("No refresh token is set.");let r=this.endpoints.oauth2TokenUrl.toString(),n={refresh_token:e,client_id:this._clientId,client_secret:this._clientSecret,grant_type:"refresh_token"};try{let e={...y.RETRY_CONFIG,method:"POST",url:r,data:new URLSearchParams((0,h.removeUndefinedValuesInObject)(n))};m.AuthClient.setMethodName(e,"refreshTokenNoCache"),t=await this.transporter.request(e)}catch(e){throw e instanceof u.GaxiosError&&"invalid_grant"===e.message&&e.response?.data&&/ReAuth/i.test(e.response.data.error_description)&&(e.message=JSON.stringify(e.response.data)),e}let i=t.data;return t.data&&t.data.expires_in&&(i.expiry_date=new Date().getTime()+1e3*t.data.expires_in,delete i.expires_in),this.emit("tokens",i),{tokens:i,res:t}}refreshAccessToken(e){if(!e)return this.refreshAccessTokenAsync();this.refreshAccessTokenAsync().then(t=>e(null,t.credentials,t.res),e)}async refreshAccessTokenAsync(){let e=await this.refreshToken(this.credentials.refresh_token),t=e.tokens;return t.refresh_token=this.credentials.refresh_token,this.credentials=t,{credentials:this.credentials,res:e.res}}getAccessToken(e){if(!e)return this.getAccessTokenAsync();this.getAccessTokenAsync().then(t=>e(null,t.token,t.res),e)}async getAccessTokenAsync(){if(!(!this.credentials.access_token||this.isTokenExpiring()))return{token:this.credentials.access_token};{if(!this.credentials.refresh_token)if(this.refreshHandler){let e=await this.processAndValidateRefreshHandler();if(e?.access_token)return this.setCredentials(e),{token:this.credentials.access_token}}else throw Error("No refresh token or refresh handler callback is set.");let e=await this.refreshAccessTokenAsync();if(!e.credentials||e.credentials&&!e.credentials.access_token)throw Error("Could not refresh access token.");return{token:e.credentials.access_token,res:e.res}}}async getRequestHeaders(e){return(await this.getRequestMetadataAsync(e)).headers}async getRequestMetadataAsync(e){let t=this.credentials;if(!t.access_token&&!t.refresh_token&&!this.apiKey&&!this.refreshHandler)throw Error("No access, refresh token, API key or refresh handler callback is set.");if(t.access_token&&!this.isTokenExpiring()){t.token_type=t.token_type||"Bearer";let e=new Headers({authorization:t.token_type+" "+t.access_token});return{headers:this.addSharedMetadataHeaders(e)}}if(this.refreshHandler){let e=await this.processAndValidateRefreshHandler();if(e?.access_token){this.setCredentials(e);let t=new Headers({authorization:"Bearer "+this.credentials.access_token});return{headers:this.addSharedMetadataHeaders(t)}}}if(this.apiKey)return{headers:new Headers({"X-Goog-Api-Key":this.apiKey})};let r=null,n=null;try{n=(r=await this.refreshToken(t.refresh_token)).tokens}catch(e){throw e.response&&(403===e.response.status||404===e.response.status)&&(e.message=`Could not refresh access token: ${e.message}`),e}let i=this.credentials;i.token_type=i.token_type||"Bearer",n.refresh_token=i.refresh_token,this.credentials=n;let o=new Headers({authorization:i.token_type+" "+n.access_token});return{headers:this.addSharedMetadataHeaders(o),res:r.res}}static getRevokeTokenUrl(e){return new y().getRevokeTokenURL(e).toString()}getRevokeTokenURL(e){let t=new URL(this.endpoints.oauth2RevokeUrl);return t.searchParams.append("token",e),t}revokeToken(e,t){let r={...y.RETRY_CONFIG,url:this.getRevokeTokenURL(e).toString(),method:"POST"};if(m.AuthClient.setMethodName(r,"revokeToken"),!t)return this.transporter.request(r);this.transporter.request(r).then(e=>t(null,e),t)}revokeCredentials(e){if(!e)return this.revokeCredentialsAsync();this.revokeCredentialsAsync().then(t=>e(null,t),e)}async revokeCredentialsAsync(){let e=this.credentials.access_token;if(this.credentials={},e)return this.revokeToken(e);throw Error("No access token to revoke.")}request(e,t){if(!t)return this.requestAsync(e);this.requestAsync(e).then(e=>t(null,e),e=>t(e,e.response))}async requestAsync(e,t=!1){try{let t=await this.getRequestMetadataAsync();return e.headers=u.Gaxios.mergeHeaders(e.headers),this.addUserProjectAndAuthHeaders(e.headers,t.headers),this.apiKey&&e.headers.set("X-Goog-Api-Key",this.apiKey),await this.transporter.request(e)}catch(n){let r=n.response;if(r){let n=r.status,i=this.credentials&&this.credentials.access_token&&this.credentials.refresh_token&&(!this.credentials.expiry_date||this.forceRefreshOnFailure),o=this.credentials&&this.credentials.access_token&&!this.credentials.refresh_token&&(!this.credentials.expiry_date||this.forceRefreshOnFailure)&&this.refreshHandler,s=r.config.data instanceof p.Readable,a=401===n||403===n;if(!t&&a&&!s&&i)return await this.refreshAccessTokenAsync(),this.requestAsync(e,!0);if(!t&&a&&!s&&o){let t=await this.processAndValidateRefreshHandler();return t?.access_token&&this.setCredentials(t),this.requestAsync(e,!0)}}throw n}}verifyIdToken(e,t){if(t&&"function"!=typeof t)throw Error("This method accepts an options object as the first parameter, which includes the idToken, audience, and maxExpiry.");if(!t)return this.verifyIdTokenAsync(e);this.verifyIdTokenAsync(e).then(e=>t(null,e),t)}async verifyIdTokenAsync(e){if(!e.idToken)throw Error("The verifyIdToken method requires an ID Token");let t=await this.getFederatedSignonCertsAsync();return await this.verifySignedJwtWithCertsAsync(e.idToken,t.certs,e.audience,this.issuers,e.maxExpiry)}async getTokenInfo(e){let{data:t}=await this.transporter.request({...y.RETRY_CONFIG,method:"POST",headers:{"content-type":"application/x-www-form-urlencoded;charset=UTF-8",authorization:`Bearer ${e}`},url:this.endpoints.tokenInfoUrl.toString()}),r=Object.assign({expiry_date:new Date().getTime()+1e3*t.expires_in,scopes:t.scope.split(" ")},t);return delete r.expires_in,delete r.scope,r}getFederatedSignonCerts(e){if(!e)return this.getFederatedSignonCertsAsync();this.getFederatedSignonCertsAsync().then(t=>e(null,t.certs,t.res),e)}async getFederatedSignonCertsAsync(){let e,t,r=new Date().getTime(),n=(0,f.hasBrowserCrypto)()?i.JWK:i.PEM;if(this.certificateExpiry&&r<this.certificateExpiry.getTime()&&this.certificateCacheFormat===n)return{certs:this.certificateCache,format:n};switch(n){case i.PEM:t=this.endpoints.oauth2FederatedSignonPemCertsUrl.toString();break;case i.JWK:t=this.endpoints.oauth2FederatedSignonJwkCertsUrl.toString();break;default:throw Error(`Unsupported certificate format ${n}`)}try{let r={...y.RETRY_CONFIG,url:t};m.AuthClient.setMethodName(r,"getFederatedSignonCertsAsync"),e=await this.transporter.request(r)}catch(e){throw e instanceof Error&&(e.message=`Failed to retrieve verification certificates: ${e.message}`),e}let o=e?.headers.get("cache-control"),s=-1;if(o){let e=/max-age=(?<maxAge>[0-9]+)/.exec(o)?.groups?.maxAge;e&&(s=1e3*Number(e))}let a={};switch(n){case i.PEM:a=e.data;break;case i.JWK:for(let t of e.data.keys)a[t.kid]=t;break;default:throw Error(`Unsupported certificate format ${n}`)}let l=new Date;return this.certificateExpiry=-1===s?null:new Date(l.getTime()+s),this.certificateCache=a,this.certificateCacheFormat=n,{certs:a,format:n,res:e}}getIapPublicKeys(e){if(!e)return this.getIapPublicKeysAsync();this.getIapPublicKeysAsync().then(t=>e(null,t.pubkeys,t.res),e)}async getIapPublicKeysAsync(){let e,t=this.endpoints.oauth2IapPublicKeyUrl.toString();try{let r={...y.RETRY_CONFIG,url:t};m.AuthClient.setMethodName(r,"getIapPublicKeysAsync"),e=await this.transporter.request(r)}catch(e){throw e instanceof Error&&(e.message=`Failed to retrieve verification certificates: ${e.message}`),e}return{pubkeys:e.data,res:e}}verifySignedJwtWithCerts(){throw Error("verifySignedJwtWithCerts is removed, please use verifySignedJwtWithCertsAsync instead.")}async verifySignedJwtWithCertsAsync(e,t,r,n,i){let o,s,a=(0,f.createCrypto)();i||(i=y.DEFAULT_MAX_TOKEN_LIFETIME_SECS_);let l=e.split(".");if(3!==l.length)throw Error("Wrong number of segments in token: "+e);let u=l[0]+"."+l[1],c=l[2];try{o=JSON.parse(a.decodeBase64StringUtf8(l[0]))}catch(e){throw e instanceof Error&&(e.message=`Can't parse token envelope: ${l[0]}': ${e.message}`),e}if(!o)throw Error("Can't parse token envelope: "+l[0]);try{s=JSON.parse(a.decodeBase64StringUtf8(l[1]))}catch(e){throw e instanceof Error&&(e.message=`Can't parse token payload '${l[0]}`),e}if(!s)throw Error("Can't parse token payload: "+l[1]);if(!Object.prototype.hasOwnProperty.call(t,o.kid))throw Error("No pem found for envelope: "+JSON.stringify(o));let p=t[o.kid];if("ES256"===o.alg&&(c=d.joseToDer(c,"ES256").toString("base64")),!await a.verify(p,u,c))throw Error("Invalid token signature: "+e);if(!s.iat)throw Error("No issue time in token: "+JSON.stringify(s));if(!s.exp)throw Error("No expiration time in token: "+JSON.stringify(s));let h=Number(s.iat);if(isNaN(h))throw Error("iat field using invalid format");let m=Number(s.exp);if(isNaN(m))throw Error("exp field using invalid format");let _=new Date().getTime()/1e3;if(m>=_+i)throw Error("Expiration time too far in future: "+JSON.stringify(s));let E=h-y.CLOCK_SKEW_SECS_,v=m+y.CLOCK_SKEW_SECS_;if(_<E)throw Error("Token used too early, "+_+" < "+E+": "+JSON.stringify(s));if(_>v)throw Error("Token used too late, "+_+" > "+v+": "+JSON.stringify(s));if(n&&0>n.indexOf(s.iss))throw Error("Invalid issuer, expected one of ["+n+"], but got "+s.iss);if(null!=r){let e=s.aud;if(!(r.constructor===Array?r.indexOf(e)>-1:e===r))throw Error("Wrong recipient, payload audience != requiredAudience")}return new g.LoginTicket(o,s)}async processAndValidateRefreshHandler(){if(this.refreshHandler){let e=await this.refreshHandler();if(!e.access_token)throw Error("No access token is returned by the refreshHandler callback.");return e}}isTokenExpiring(){let e=this.credentials.expiry_date;return!!e&&e<=new Date().getTime()+this.eagerRefreshThresholdMillis}}r.OAuth2Client=y},70814,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.Compute=void 0;let n=e.r(57612),i=e.r(82e3),o=e.r(701);class s extends o.OAuth2Client{serviceAccountEmail;scopes;constructor(e={}){super(e),this.credentials={expiry_date:1,refresh_token:"compute-placeholder"},this.serviceAccountEmail=e.serviceAccountEmail||"default",this.scopes=Array.isArray(e.scopes)?e.scopes:e.scopes?[e.scopes]:[]}async refreshTokenNoCache(){let e,t=`service-accounts/${this.serviceAccountEmail}/token`;try{let r={property:t};this.scopes.length>0&&(r.params={scopes:this.scopes.join(",")}),e=await i.instance(r)}catch(e){throw e instanceof n.GaxiosError&&(e.message=`Could not refresh access token: ${e.message}`,this.wrapError(e)),e}let r=e;return e&&e.expires_in&&(r.expiry_date=new Date().getTime()+1e3*e.expires_in,delete r.expires_in),this.emit("tokens",r),{tokens:r,res:null}}async fetchIdToken(e){let t,r=`service-accounts/${this.serviceAccountEmail}/identity?format=full&audience=${e}`;try{t=await i.instance({property:r})}catch(e){throw e instanceof Error&&(e.message=`Could not fetch ID token: ${e.message}`),e}return t}wrapError(e){let t=e.response;t&&t.status&&(e.status=t.status,403===t.status?e.message="A Forbidden error was returned while attempting to retrieve an access token for the Compute Engine built-in service account. This may be because the Compute Engine instance does not have the correct permission scopes specified: "+e.message:404===t.status&&(e.message="A Not Found error was returned while attempting to retrieve an accesstoken for the Compute Engine built-in service account. This may be because the Compute Engine instance does not have any permission scopes specified: "+e.message))}}r.Compute=s},80732,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.IdTokenClient=void 0;let n=e.r(701);class i extends n.OAuth2Client{targetAudience;idTokenProvider;constructor(e){super(e),this.targetAudience=e.targetAudience,this.idTokenProvider=e.idTokenProvider}async getRequestMetadataAsync(){if(!this.credentials.id_token||!this.credentials.expiry_date||this.isTokenExpiring()){let e=await this.idTokenProvider.fetchIdToken(this.targetAudience);this.credentials={id_token:e,expiry_date:this.getIdTokenExpiryDate(e)}}return{headers:new Headers({authorization:"Bearer "+this.credentials.id_token})}}getIdTokenExpiryDate(e){let t=e.split(".")[1];if(t)return 1e3*JSON.parse(Buffer.from(t,"base64").toString("ascii")).exp}}r.IdTokenClient=i},80243,(e,t,r)=>{"use strict";var n,i;let o;Object.defineProperty(r,"__esModule",{value:!0}),r.GCPEnv=void 0,r.clear=function(){o=void 0},r.getEnv=a;let s=e.r(82e3);async function a(){return o||(o=l())}async function l(){n.NONE;return process.env.GAE_SERVICE||process.env.GAE_MODULE_NAME?n.APP_ENGINE:process.env.FUNCTION_NAME||process.env.FUNCTION_TARGET?n.CLOUD_FUNCTIONS:await c()?await u()?n.KUBERNETES_ENGINE:process.env.K_CONFIGURATION?n.CLOUD_RUN:process.env.CLOUD_RUN_JOB?n.CLOUD_RUN_JOBS:n.COMPUTE_ENGINE:n.NONE}async function u(){try{return await s.instance("attributes/cluster-name"),!0}catch(e){return!1}}async function c(){return s.isAvailable()}(i=n||(r.GCPEnv=n={})).APP_ENGINE="APP_ENGINE",i.KUBERNETES_ENGINE="KUBERNETES_ENGINE",i.CLOUD_FUNCTIONS="CLOUD_FUNCTIONS",i.COMPUTE_ENGINE="COMPUTE_ENGINE",i.CLOUD_RUN="CLOUD_RUN",i.CLOUD_RUN_JOBS="CLOUD_RUN_JOBS",i.NONE="NONE"},41949,(e,t,r)=>{var n=e.r(23469).Buffer,i=e.r(88947);function o(e){if(this.buffer=null,this.writable=!0,this.readable=!0,!e)return this.buffer=n.alloc(0),this;if("function"==typeof e.pipe)return this.buffer=n.alloc(0),e.pipe(this),this;if(e.length||"object"==typeof e)return this.buffer=e,this.writable=!1,process.nextTick((function(){this.emit("end",e),this.readable=!1,this.emit("close")}).bind(this)),this;throw TypeError("Unexpected data type ("+typeof e+")")}e.r(24361).inherits(o,i),o.prototype.write=function(e){this.buffer=n.concat([this.buffer,n.from(e)]),this.emit("data",e)},o.prototype.end=function(e){e&&this.write(e),this.emit("end",e),this.emit("close"),this.writable=!1,this.readable=!1},t.exports=o},22691,(e,t,r)=>{"use strict";var n=e.r(874).Buffer,i=e.r(874).SlowBuffer;function o(e,t){if(!n.isBuffer(e)||!n.isBuffer(t)||e.length!==t.length)return!1;for(var r=0,i=0;i<e.length;i++)r|=e[i]^t[i];return 0===r}t.exports=o,o.install=function(){n.prototype.equal=i.prototype.equal=function(e){return o(this,e)}};var s=n.prototype.equal,a=i.prototype.equal;o.restore=function(){n.prototype.equal=s,i.prototype.equal=a}},57067,(e,t,r)=>{var n,i=e.r(23469).Buffer,o=e.r(54799),s=e.r(32955),a=e.r(24361),l="secret must be a string or buffer",u="key must be a string or a buffer",c="function"==typeof o.createPublicKey;function p(e){if(!i.isBuffer(e)&&"string"!=typeof e&&(!c||"object"!=typeof e||"string"!=typeof e.type||"string"!=typeof e.asymmetricKeyType||"function"!=typeof e.export))throw m(u)}function d(e){if(!i.isBuffer(e)&&"string"!=typeof e&&"object"!=typeof e)throw m("key must be a string, a buffer or an object")}function h(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function f(e){var t=4-(e=e.toString()).length%4;if(4!==t)for(var r=0;r<t;++r)e+="=";return e.replace(/\-/g,"+").replace(/_/g,"/")}function m(e){var t=[].slice.call(arguments,1);return TypeError(a.format.bind(a,e).apply(null,t))}function g(e){var t;return t=e,i.isBuffer(t)||"string"==typeof t||(e=JSON.stringify(e)),e}function y(e){return function(t,r){!function(e){if(!i.isBuffer(e)){if("string"!=typeof e){if(!c||"object"!=typeof e||"secret"!==e.type||"function"!=typeof e.export)throw m(l)}}}(r),t=g(t);var n=o.createHmac("sha"+e,r);return h((n.update(t),n.digest("base64")))}}c&&(u+=" or a KeyObject",l+="or a KeyObject");var _="timingSafeEqual"in o?function(e,t){return e.byteLength===t.byteLength&&o.timingSafeEqual(e,t)}:function(t,r){return n||(n=e.r(22691)),n(t,r)};function E(e){return function(t,r,n){var o=y(e)(t,n);return _(i.from(r),i.from(o))}}function v(e){return function(t,r){d(r),t=g(t);var n=o.createSign("RSA-SHA"+e);return h((n.update(t),n.sign(r,"base64")))}}function A(e){return function(t,r,n){p(n),t=g(t),r=f(r);var i=o.createVerify("RSA-SHA"+e);return i.update(t),i.verify(n,r,"base64")}}function T(e){return function(t,r){d(r),t=g(t);var n=o.createSign("RSA-SHA"+e);return h((n.update(t),n.sign({key:r,padding:o.constants.RSA_PKCS1_PSS_PADDING,saltLength:o.constants.RSA_PSS_SALTLEN_DIGEST},"base64")))}}function C(e){return function(t,r,n){p(n),t=g(t),r=f(r);var i=o.createVerify("RSA-SHA"+e);return i.update(t),i.verify({key:n,padding:o.constants.RSA_PKCS1_PSS_PADDING,saltLength:o.constants.RSA_PSS_SALTLEN_DIGEST},r,"base64")}}function S(e){var t=v(e);return function(){var r=t.apply(null,arguments);return s.derToJose(r,"ES"+e)}}function b(e){var t=A(e);return function(r,n,i){return t(r,n=s.joseToDer(n,"ES"+e).toString("base64"),i)}}function I(){return function(){return""}}function O(){return function(e,t){return""===t}}t.exports=function(e){var t=e.match(/^(RS|PS|ES|HS)(256|384|512)$|^(none)$/);if(!t)throw m('"%s" is not a valid algorithm.\n Supported algorithms are:\n "HS256", "HS384", "HS512", "RS256", "RS384", "RS512", "PS256", "PS384", "PS512", "ES256", "ES384", "ES512" and "none".',e);var r=(t[1]||t[3]).toLowerCase(),n=t[2];return{sign:({hs:y,rs:v,ps:T,es:S,none:I})[r](n),verify:({hs:E,rs:A,ps:C,es:b,none:O})[r](n)}}},76872,(e,t,r)=>{var n=e.r(874).Buffer;t.exports=function(e){return"string"==typeof e?e:"number"==typeof e||n.isBuffer(e)?e.toString():JSON.stringify(e)}},14743,(e,t,r)=>{var n=e.r(23469).Buffer,i=e.r(41949),o=e.r(57067),s=e.r(88947),a=e.r(76872),l=e.r(24361);function u(e,t){return n.from(e,t).toString("base64").replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function c(e){var t,r,n,i=e.header,s=e.payload,c=e.secret||e.privateKey,p=e.encoding,d=o(i.alg),h=(t=(t=p)||"utf8",r=u(a(i),"binary"),n=u(a(s),t),l.format("%s.%s",r,n)),f=d.sign(h,c);return l.format("%s.%s",h,f)}function p(e){var t=e.secret;if(t=null==(t=null==t?e.privateKey:t)?e.key:t,!0===/^hs/i.test(e.header.alg)&&null==t)throw TypeError("secret must be a string or buffer or a KeyObject");var r=new i(t);this.readable=!0,this.header=e.header,this.encoding=e.encoding,this.secret=this.privateKey=this.key=r,this.payload=new i(e.payload),this.secret.once("close",(function(){!this.payload.writable&&this.readable&&this.sign()}).bind(this)),this.payload.once("close",(function(){!this.secret.writable&&this.readable&&this.sign()}).bind(this))}l.inherits(p,s),p.prototype.sign=function(){try{var e=c({header:this.header,payload:this.payload.buffer,secret:this.secret.buffer,encoding:this.encoding});return this.emit("done",e),this.emit("data",e),this.emit("end"),this.readable=!1,e}catch(e){this.readable=!1,this.emit("error",e),this.emit("close")}},p.sign=c,t.exports=p},48233,(e,t,r)=>{var n=e.r(23469).Buffer,i=e.r(41949),o=e.r(57067),s=e.r(88947),a=e.r(76872),l=e.r(24361),u=/^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/;function c(e){var t=e.split(".",1)[0],r=n.from(t,"base64").toString("binary");if("[object Object]"===Object.prototype.toString.call(r))return r;try{return JSON.parse(r)}catch(e){return}}function p(e){return e.split(".")[2]}function d(e){return u.test(e)&&!!c(e)}function h(e,t,r){if(!t){var n=Error("Missing algorithm parameter for jws.verify");throw n.code="MISSING_ALGORITHM",n}var i=p(e=a(e)),s=e.split(".",2).join(".");return o(t).verify(s,i,r)}function f(e,t){if(t=t||{},!d(e=a(e)))return null;var r,i,o=c(e);if(!o)return null;var s=(r=r||"utf8",i=e.split(".")[1],n.from(i,"base64").toString(r));return("JWT"===o.typ||t.json)&&(s=JSON.parse(s,t.encoding)),{header:o,payload:s,signature:p(e)}}function m(e){var t=(e=e||{}).secret;if(t=null==(t=null==t?e.publicKey:t)?e.key:t,!0===/^hs/i.test(e.algorithm)&&null==t)throw TypeError("secret must be a string or buffer or a KeyObject");var r=new i(t);this.readable=!0,this.algorithm=e.algorithm,this.encoding=e.encoding,this.secret=this.publicKey=this.key=r,this.signature=new i(e.signature),this.secret.once("close",(function(){!this.signature.writable&&this.readable&&this.verify()}).bind(this)),this.signature.once("close",(function(){!this.secret.writable&&this.readable&&this.verify()}).bind(this))}l.inherits(m,s),m.prototype.verify=function(){try{var e=h(this.signature.buffer,this.algorithm,this.key.buffer),t=f(this.signature.buffer,this.encoding);return this.emit("done",e,t),this.emit("data",e),this.emit("end"),this.readable=!1,e}catch(e){this.readable=!1,this.emit("error",e),this.emit("close")}},m.decode=f,m.isValid=d,m.verify=h,t.exports=m},58184,(e,t,r)=>{var n=e.r(14743),i=e.r(48233);r.ALGORITHMS=["HS256","HS384","HS512","RS256","RS384","RS512","PS256","PS384","PS512","ES256","ES384","ES512"],r.sign=n.sign,r.verify=i.verify,r.decode=i.decode,r.isValid=i.isValid,r.createSign=function(e){return new n(e)},r.createVerify=function(e){return new i(e)}},41443,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.buildPayloadForJwsSign=i,r.getJwsSign=function(e){let t=i(e);return(0,n.sign)({header:{alg:"RS256"},payload:t,secret:e.key})};let n=e.r(58184);function i(e){let t=Math.floor(new Date().getTime()/1e3);return{iss:e.iss,scope:e.scope,aud:"https://oauth2.googleapis.com/token",exp:t+3600,iat:t,sub:e.sub,...e.additionalClaims}}},79739,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.getToken=i;let n=e.r(41443);async function i(e){if(!e.transporter)throw Error("No transporter set.");try{let t={method:"POST",url:"https://oauth2.googleapis.com/token",data:new URLSearchParams({grant_type:"urn:ietf:params:oauth:grant-type:jwt-bearer",assertion:(0,n.getJwsSign)(e)}),responseType:"json",retryConfig:{httpMethodsToRetry:["POST"]}};return(await e.transporter.request(t)).data}catch(t){let e=t.response?.data;throw e?.error&&(t.message=`${e.error}: ${e.error_description}`),t}}},3600,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.ErrorWithCode=void 0,r.ErrorWithCode=class extends Error{code;constructor(e,t){super(e),this.code=t}}},35568,(e,t,r)=>{"use strict";var n,i;Object.defineProperty(r,"__esModule",{value:!0}),r.getCredentials=f;let o=e.r(14747),s=e.r(22734),a=e.r(24361),l=e.r(3600),u=(0,a.promisify)(s.readFile);(i=n||(n={})).JSON=".json",i.DER=".der",i.CRT=".crt",i.PEM=".pem",i.P12=".p12",i.PFX=".pfx";class c{keyFilePath;constructor(e){this.keyFilePath=e}async getCredentials(){let e,t=await u(this.keyFilePath,"utf8");try{e=JSON.parse(t)}catch(e){throw Error(`Invalid JSON key file: ${e.message}`)}let r=e.private_key,n=e.client_email;if(!r||!n)throw new l.ErrorWithCode("private_key and client_email are required.","MISSING_CREDENTIALS");return{privateKey:r,clientEmail:n}}}class p{keyFilePath;constructor(e){this.keyFilePath=e}async getCredentials(){return{privateKey:await u(this.keyFilePath,"utf8")}}}class d{async getCredentials(){throw new l.ErrorWithCode("*.p12 certificates are not supported after v6.1.2. Consider utilizing *.json format or converting *.p12 to *.pem using the OpenSSL CLI.","UNKNOWN_CERTIFICATE_TYPE")}}class h{static create(e){switch(o.extname(e)){case n.JSON:return new c(e);case n.DER:case n.CRT:case n.PEM:return new p(e);case n.P12:case n.PFX:return new d;default:throw new l.ErrorWithCode("Unknown certificate type. Type is determined based on file extension. Current supported extensions are *.json, and *.pem.","UNKNOWN_CERTIFICATE_TYPE")}}}async function f(e){return h.create(e).getCredentials()}},85708,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.TokenHandler=void 0;let n=e.r(79739),i=e.r(35568);r.TokenHandler=class{token;tokenExpiresAt;inFlightRequest;tokenOptions;constructor(e){this.tokenOptions=e}async processCredentials(){if(!this.tokenOptions.key&&!this.tokenOptions.keyFile)throw Error("No key or keyFile set.");if(!this.tokenOptions.key&&this.tokenOptions.keyFile){let e=await (0,i.getCredentials)(this.tokenOptions.keyFile);this.tokenOptions.key=e.privateKey,this.tokenOptions.email=e.clientEmail}}isTokenExpiring(){if(!this.token||!this.tokenExpiresAt)return!0;let e=new Date().getTime(),t=this.tokenOptions.eagerRefreshThresholdMillis??0;return this.tokenExpiresAt<=e+t}hasExpired(){return new Date().getTime(),!this.token||!this.tokenExpiresAt||new Date().getTime()>=this.tokenExpiresAt}async getToken(e){if(await this.processCredentials(),this.inFlightRequest&&!e)return this.inFlightRequest;if(this.token&&!this.isTokenExpiring()&&!e)return this.token;try{this.inFlightRequest=(0,n.getToken)(this.tokenOptions);let e=await this.inFlightRequest;return this.token=e,this.tokenExpiresAt=new Date().getTime()+(e.expires_in??0)*1e3,e}finally{this.inFlightRequest=void 0}}}},27030,(e,t,r)=>{"use strict";async function n(e,t){return await t.request({url:"https://oauth2.googleapis.com/revoke?token="+e,retry:!0})}Object.defineProperty(r,"__esModule",{value:!0}),r.revokeToken=n},99365,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.GoogleToken=void 0;let n=e.r(57612),i=e.r(85708),o=e.r(27030);r.GoogleToken=class{tokenOptions;tokenHandler;constructor(e){this.tokenOptions=e||{},this.tokenOptions.transporter=this.tokenOptions.transporter||{request:e=>(0,n.request)(e)},this.tokenOptions.iss||(this.tokenOptions.iss=this.tokenOptions.email),"object"==typeof this.tokenOptions.scope&&(this.tokenOptions.scope=this.tokenOptions.scope.join(" ")),this.tokenHandler=new i.TokenHandler(this.tokenOptions)}get expiresAt(){return this.tokenHandler.tokenExpiresAt}get accessToken(){return this.tokenHandler.token?.access_token}get idToken(){return this.tokenHandler.token?.id_token}get tokenType(){return this.tokenHandler.token?.token_type}get refreshToken(){return this.tokenHandler.token?.refresh_token}hasExpired(){return this.tokenHandler.hasExpired()}isTokenExpiring(){return this.tokenHandler.isTokenExpiring()}getToken(e,t={forceRefresh:!1}){let r;"function"==typeof e?r=e:"object"==typeof e&&(t=e);let n=this.tokenHandler.getToken(t.forceRefresh??!1);return r&&n.then(e=>r(null,e),r),n}revokeToken(e){if(!this.accessToken)return Promise.reject(Error("No token to revoke."));let t=(0,o.revokeToken)(this.accessToken,this.tokenOptions.transporter);e&&t.then(()=>e(),e),this.tokenHandler=new i.TokenHandler(this.tokenOptions)}get googleTokenOptions(){return this.tokenOptions}}},10247,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.JWTAccess=void 0;let n=e.r(58184),i=e.r(15733),o={alg:"RS256",typ:"JWT"};class s{email;key;keyId;projectId;eagerRefreshThresholdMillis;cache=new i.LRUCache({capacity:500,maxAge:36e5});constructor(e,t,r,n){this.email=e,this.key=t,this.keyId=r,this.eagerRefreshThresholdMillis=n??3e5}getCachedKey(e,t){let r=e;if(t&&Array.isArray(t)&&t.length?r=e?`${e}_${t.join("_")}`:`${t.join("_")}`:"string"==typeof t&&(r=e?`${e}_${t}`:t),!r)throw Error("Scopes or url must be provided");return r}getRequestHeaders(e,t,r){let i,a=this.getCachedKey(e,r),l=this.cache.get(a),u=Date.now();if(l&&l.expiration-u>this.eagerRefreshThresholdMillis)return new Headers(l.headers);let c=Math.floor(Date.now()/1e3),p=s.getExpirationTime(c);if(Array.isArray(r)&&(r=r.join(" ")),i=r?{iss:this.email,sub:this.email,scope:r,exp:p,iat:c}:{iss:this.email,sub:this.email,aud:e,exp:p,iat:c},t){for(let e in i)if(t[e])throw Error(`The '${e}' property is not allowed when passing additionalClaims. This claim is included in the JWT by default.`)}let d=this.keyId?{...o,kid:this.keyId}:o,h=Object.assign(i,t),f=n.sign({header:d,payload:h,secret:this.key}),m=new Headers({authorization:`Bearer ${f}`});return this.cache.set(a,{expiration:1e3*p,headers:m}),m}static getExpirationTime(e){return e+3600}fromJSON(e){if(!e)throw Error("Must pass in a JSON object containing the service account auth settings.");if(!e.client_email)throw Error("The incoming JSON object does not contain a client_email field");if(!e.private_key)throw Error("The incoming JSON object does not contain a private_key field");this.email=e.client_email,this.key=e.private_key,this.keyId=e.private_key_id,this.projectId=e.project_id}fromStream(e,t){if(!t)return this.fromStreamAsync(e);this.fromStreamAsync(e).then(()=>t(),t)}fromStreamAsync(e){return new Promise((t,r)=>{e||r(Error("Must pass in a stream containing the service account auth settings."));let n="";e.setEncoding("utf8").on("data",e=>n+=e).on("error",r).on("end",()=>{try{let e=JSON.parse(n);this.fromJSON(e),t()}catch(e){r(e)}})})}}r.JWTAccess=s},24553,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.JWT=void 0;let n=e.r(99365),i=e.r(35568),o=e.r(10247),s=e.r(701),a=e.r(11656);class l extends s.OAuth2Client{email;keyFile;key;keyId;defaultScopes;scopes;scope;subject;gtoken;additionalClaims;useJWTAccessWithScope;defaultServicePath;access;constructor(e={}){super(e),this.email=e.email,this.keyFile=e.keyFile,this.key=e.key,this.keyId=e.keyId,this.scopes=e.scopes,this.subject=e.subject,this.additionalClaims=e.additionalClaims,this.credentials={refresh_token:"jwt-placeholder",expiry_date:1}}createScoped(e){let t=new l(this);return t.scopes=e,t}async getRequestMetadataAsync(e){e=this.defaultServicePath?`https://${this.defaultServicePath}/`:e;let t=!this.hasUserScopes()&&e||this.useJWTAccessWithScope&&this.hasAnyScopes()||this.universeDomain!==a.DEFAULT_UNIVERSE;if(this.subject&&this.universeDomain!==a.DEFAULT_UNIVERSE)throw RangeError(`Service Account user is configured for the credential. Domain-wide delegation is not supported in universes other than ${a.DEFAULT_UNIVERSE}`);if(!this.apiKey&&t)if(this.additionalClaims&&this.additionalClaims.target_audience){let{tokens:e}=await this.refreshToken();return{headers:this.addSharedMetadataHeaders(new Headers({authorization:`Bearer ${e.id_token}`}))}}else{let t;this.access||(this.access=new o.JWTAccess(this.email,this.key,this.keyId,this.eagerRefreshThresholdMillis)),this.hasUserScopes()?t=this.scopes:e||(t=this.defaultScopes);let r=this.useJWTAccessWithScope||this.universeDomain!==a.DEFAULT_UNIVERSE,n=await this.access.getRequestHeaders(e??void 0,this.additionalClaims,r?t:void 0);return{headers:this.addSharedMetadataHeaders(n)}}return this.hasAnyScopes()||this.apiKey?super.getRequestMetadataAsync(e):{headers:new Headers}}async fetchIdToken(e){let t=new n.GoogleToken({iss:this.email,sub:this.subject,scope:this.scopes||this.defaultScopes,keyFile:this.keyFile,key:this.key,additionalClaims:{target_audience:e},transporter:this.transporter});if(await t.getToken({forceRefresh:!0}),!t.idToken)throw Error("Unknown error: Failed to fetch ID token");return t.idToken}hasUserScopes(){return!!this.scopes&&this.scopes.length>0}hasAnyScopes(){return!!this.scopes&&!!(this.scopes.length>0)||!!this.defaultScopes&&!!(this.defaultScopes.length>0)}authorize(e){if(!e)return this.authorizeAsync();this.authorizeAsync().then(t=>e(null,t),e)}async authorizeAsync(){let e=await this.refreshToken();if(!e)throw Error("No result returned");return this.credentials=e.tokens,this.credentials.refresh_token="jwt-placeholder",this.key=this.gtoken.googleTokenOptions?.key,this.email=this.gtoken.googleTokenOptions?.iss,e.tokens}async refreshTokenNoCache(){let e=this.createGToken(),t={access_token:(await e.getToken({forceRefresh:this.isTokenExpiring()})).access_token,token_type:"Bearer",expiry_date:e.expiresAt,id_token:e.idToken};return this.emit("tokens",t),{res:null,tokens:t}}createGToken(){return this.gtoken||(this.gtoken=new n.GoogleToken({iss:this.email,sub:this.subject,scope:this.scopes||this.defaultScopes,keyFile:this.keyFile,key:this.key,additionalClaims:this.additionalClaims,transporter:this.transporter})),this.gtoken}fromJSON(e){if(!e)throw Error("Must pass in a JSON object containing the service account auth settings.");if(!e.client_email)throw Error("The incoming JSON object does not contain a client_email field");if(!e.private_key)throw Error("The incoming JSON object does not contain a private_key field");this.email=e.client_email,this.key=e.private_key,this.keyId=e.private_key_id,this.projectId=e.project_id,this.quotaProjectId=e.quota_project_id,this.universeDomain=e.universe_domain||this.universeDomain}fromStream(e,t){if(!t)return this.fromStreamAsync(e);this.fromStreamAsync(e).then(()=>t(),t)}fromStreamAsync(e){return new Promise((t,r)=>{if(!e)throw Error("Must pass in a stream containing the service account auth settings.");let n="";e.setEncoding("utf8").on("error",r).on("data",e=>n+=e).on("end",()=>{try{let e=JSON.parse(n);this.fromJSON(e),t()}catch(e){r(e)}})})}fromAPIKey(e){if("string"!=typeof e)throw Error("Must provide an API Key string.");this.apiKey=e}async getCredentials(){if(this.key)return{private_key:this.key,client_email:this.email};if(this.keyFile){this.createGToken();let e=await (0,i.getCredentials)(this.keyFile);return{private_key:e.privateKey,client_email:e.clientEmail}}throw Error("A key or a keyFile must be provided to getCredentials.")}}r.JWT=l},16260,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.UserRefreshClient=r.USER_REFRESH_ACCOUNT_TYPE=void 0;let n=e.r(701),i=e.r(11656);r.USER_REFRESH_ACCOUNT_TYPE="authorized_user";class o extends n.OAuth2Client{_refreshToken;constructor(e,t,r,n,i){const o=e&&"object"==typeof e?e:{clientId:e,clientSecret:t,refreshToken:r,eagerRefreshThresholdMillis:n,forceRefreshOnFailure:i};super(o),this._refreshToken=o.refreshToken,this.credentials.refresh_token=o.refreshToken}async refreshTokenNoCache(){return super.refreshTokenNoCache(this._refreshToken)}async fetchIdToken(e){let t={...o.RETRY_CONFIG,url:this.endpoints.oauth2TokenUrl,method:"POST",data:new URLSearchParams({client_id:this._clientId,client_secret:this._clientSecret,grant_type:"refresh_token",refresh_token:this._refreshToken,target_audience:e}),responseType:"json"};return i.AuthClient.setMethodName(t,"fetchIdToken"),(await this.transporter.request(t)).data.id_token}fromJSON(e){if(!e)throw Error("Must pass in a JSON object containing the user refresh token");if("authorized_user"!==e.type)throw Error('The incoming JSON object does not have the "authorized_user" type');if(!e.client_id)throw Error("The incoming JSON object does not contain a client_id field");if(!e.client_secret)throw Error("The incoming JSON object does not contain a client_secret field");if(!e.refresh_token)throw Error("The incoming JSON object does not contain a refresh_token field");this._clientId=e.client_id,this._clientSecret=e.client_secret,this._refreshToken=e.refresh_token,this.credentials.refresh_token=e.refresh_token,this.quotaProjectId=e.quota_project_id,this.universeDomain=e.universe_domain||this.universeDomain}fromStream(e,t){if(!t)return this.fromStreamAsync(e);this.fromStreamAsync(e).then(()=>t(),t)}async fromStreamAsync(e){return new Promise((t,r)=>{if(!e)return r(Error("Must pass in a stream containing the user refresh token."));let n="";e.setEncoding("utf8").on("error",r).on("data",e=>n+=e).on("end",()=>{try{let e=JSON.parse(n);return this.fromJSON(e),t()}catch(e){return r(e)}})})}static fromJSON(e){let t=new o;return t.fromJSON(e),t}}r.UserRefreshClient=o},36126,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.Impersonated=r.IMPERSONATED_ACCOUNT_TYPE=void 0;let n=e.r(701),i=e.r(57612),o=e.r(15733);r.IMPERSONATED_ACCOUNT_TYPE="impersonated_service_account";class s extends n.OAuth2Client{sourceClient;targetPrincipal;targetScopes;delegates;lifetime;endpoint;constructor(e={}){if(super(e),this.credentials={expiry_date:1,refresh_token:"impersonated-placeholder"},this.sourceClient=e.sourceClient??new n.OAuth2Client,this.targetPrincipal=e.targetPrincipal??"",this.delegates=e.delegates??[],this.targetScopes=e.targetScopes??[],this.lifetime=e.lifetime??3600,(0,o.originalOrCamelOptions)(e).get("universe_domain")){if(this.sourceClient.universeDomain!==this.universeDomain)throw RangeError(`Universe domain ${this.sourceClient.universeDomain} in source credentials does not match ${this.universeDomain} universe domain set for impersonated credentials.`)}else this.universeDomain=this.sourceClient.universeDomain;this.endpoint=e.endpoint??`https://iamcredentials.${this.universeDomain}`}async sign(e){await this.sourceClient.getAccessToken();let t=`projects/-/serviceAccounts/${this.targetPrincipal}`,r=`${this.endpoint}/v1/${t}:signBlob`,n={delegates:this.delegates,payload:Buffer.from(e).toString("base64")};return(await this.sourceClient.request({...s.RETRY_CONFIG,url:r,data:n,method:"POST"})).data}getTargetPrincipal(){return this.targetPrincipal}async refreshToken(){try{await this.sourceClient.getAccessToken();let e="projects/-/serviceAccounts/"+this.targetPrincipal,t=`${this.endpoint}/v1/${e}:generateAccessToken`,r={delegates:this.delegates,scope:this.targetScopes,lifetime:this.lifetime+"s"},n=await this.sourceClient.request({...s.RETRY_CONFIG,url:t,data:r,method:"POST"}),i=n.data;return this.credentials.access_token=i.accessToken,this.credentials.expiry_date=Date.parse(i.expireTime),{tokens:this.credentials,res:n}}catch(r){if(!(r instanceof Error))throw r;let e=0,t="";if(r instanceof i.GaxiosError&&(e=r?.response?.data?.error?.status,t=r?.response?.data?.error?.message),e&&t)throw r.message=`${e}: unable to impersonate: ${t}`,r;throw r.message=`unable to impersonate: ${r}`,r}}async fetchIdToken(e,t){await this.sourceClient.getAccessToken();let r=`projects/-/serviceAccounts/${this.targetPrincipal}`,n=`${this.endpoint}/v1/${r}:generateIdToken`,i={delegates:this.delegates,audience:e,includeEmail:t?.includeEmail??!0,useEmailAzp:t?.includeEmail??!0};return(await this.sourceClient.request({...s.RETRY_CONFIG,url:n,data:i,method:"POST"})).data.token}}r.Impersonated=s},46944,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.OAuthClientAuthHandler=void 0,r.getErrorFromOAuthErrorResponse=function(e,t){let r=e.error,n=e.error_description,i=e.error_uri,o=`Error code ${r}`;void 0!==n&&(o+=`: ${n}`),void 0!==i&&(o+=` - ${i}`);let s=Error(o);if(t){let e=Object.keys(t);t.stack&&e.push("stack"),e.forEach(e=>{"message"!==e&&Object.defineProperty(s,e,{value:t[e],writable:!1,enumerable:!0})})}return s};let n=e.r(57612),i=e.r(59501),o=["PUT","POST","PATCH"];class s{#d=(0,i.createCrypto)();#h;transporter;constructor(e){e&&"clientId"in e?(this.#h=e,this.transporter=new n.Gaxios):(this.#h=e?.clientAuthentication,this.transporter=e?.transporter||new n.Gaxios)}applyClientAuthenticationOptions(e,t){e.headers=n.Gaxios.mergeHeaders(e.headers),this.injectAuthenticatedHeaders(e,t),t||this.injectAuthenticatedRequestBody(e)}injectAuthenticatedHeaders(e,t){if(t)e.headers=n.Gaxios.mergeHeaders(e.headers,{authorization:`Bearer ${t}`});else if(this.#h?.confidentialClientType==="basic"){e.headers=n.Gaxios.mergeHeaders(e.headers);let t=this.#h.clientId,r=this.#h.clientSecret||"",i=this.#d.encodeBase64StringUtf8(`${t}:${r}`);n.Gaxios.mergeHeaders(e.headers,{authorization:`Basic ${i}`})}}injectAuthenticatedRequestBody(e){if(this.#h?.confidentialClientType==="request-body"){let t=(e.method||"GET").toUpperCase();if(!o.includes(t))throw Error(`${t} HTTP method does not support ${this.#h.confidentialClientType} client authentication`);let r=new Headers(e.headers).get("content-type");if(r?.startsWith("application/x-www-form-urlencoded")||e.data instanceof URLSearchParams){let t=new URLSearchParams(e.data??"");t.append("client_id",this.#h.clientId),t.append("client_secret",this.#h.clientSecret||""),e.data=t}else if(r?.startsWith("application/json"))e.data=e.data||{},Object.assign(e.data,{client_id:this.#h.clientId,client_secret:this.#h.clientSecret||""});else throw Error(`${r} content-types are not supported with ${this.#h.confidentialClientType} client authentication`)}}static get RETRY_CONFIG(){return{retry:!0,retryConfig:{httpMethodsToRetry:["GET","PUT","POST","HEAD","OPTIONS","DELETE"]}}}}r.OAuthClientAuthHandler=s},5332,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.StsCredentials=void 0;let n=e.r(57612),i=e.r(11656),o=e.r(46944),s=e.r(15733);class a extends o.OAuthClientAuthHandler{#f;constructor(e={tokenExchangeEndpoint:""},t){("object"!=typeof e||e instanceof URL)&&(e={tokenExchangeEndpoint:e,clientAuthentication:t}),super(e),this.#f=e.tokenExchangeEndpoint}async exchangeToken(e,t,r){let l={grant_type:e.grantType,resource:e.resource,audience:e.audience,scope:e.scope?.join(" "),requested_token_type:e.requestedTokenType,subject_token:e.subjectToken,subject_token_type:e.subjectTokenType,actor_token:e.actingParty?.actorToken,actor_token_type:e.actingParty?.actorTokenType,options:r&&JSON.stringify(r)},u={...a.RETRY_CONFIG,url:this.#f.toString(),method:"POST",headers:t,data:new URLSearchParams((0,s.removeUndefinedValuesInObject)(l)),responseType:"json"};i.AuthClient.setMethodName(u,"exchangeToken"),this.applyClientAuthenticationOptions(u);try{let e=await this.transporter.request(u),t=e.data;return t.res=e,t}catch(e){if(e instanceof n.GaxiosError&&e.response)throw(0,o.getErrorFromOAuthErrorResponse)(e.response.data,e);throw e}}}r.StsCredentials=a},6560,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.BaseExternalAccountClient=r.CLOUD_RESOURCE_MANAGER=r.EXTERNAL_ACCOUNT_TYPE=r.EXPIRATION_TIME_OFFSET=void 0;let n=e.r(57612),i=e.r(88947),o=e.r(11656),s=e.r(5332),a=e.r(15733),l=e.r(93714),u="https://www.googleapis.com/auth/cloud-platform";r.EXPIRATION_TIME_OFFSET=3e5,r.EXTERNAL_ACCOUNT_TYPE="external_account",r.CLOUD_RESOURCE_MANAGER="https://cloudresourcemanager.googleapis.com/v1/projects/";class c extends o.AuthClient{scopes;projectNumber;audience;subjectTokenType;stsCredential;clientAuth;credentialSourceType;cachedAccessToken;serviceAccountImpersonationUrl;serviceAccountImpersonationLifetime;workforcePoolUserProject;configLifetimeRequested;tokenUrl;cloudResourceManagerURL;supplierContext;#m=null;constructor(e){super(e);const t=(0,a.originalOrCamelOptions)(e),n=t.get("type");if(n&&n!==r.EXTERNAL_ACCOUNT_TYPE)throw Error(`Expected "${r.EXTERNAL_ACCOUNT_TYPE}" type but received "${e.type}"`);const i=t.get("client_id"),o=t.get("client_secret");this.tokenUrl=t.get("token_url")??"https://sts.{universeDomain}/v1/token".replace("{universeDomain}",this.universeDomain);const l=t.get("subject_token_type"),c=t.get("workforce_pool_user_project"),p=t.get("service_account_impersonation_url"),d=t.get("service_account_impersonation"),h=(0,a.originalOrCamelOptions)(d).get("token_lifetime_seconds");this.cloudResourceManagerURL=new URL(t.get("cloud_resource_manager_url")||`https://cloudresourcemanager.${this.universeDomain}/v1/projects/`),i&&(this.clientAuth={confidentialClientType:"basic",clientId:i,clientSecret:o}),this.stsCredential=new s.StsCredentials({tokenExchangeEndpoint:this.tokenUrl,clientAuthentication:this.clientAuth}),this.scopes=t.get("scopes")||[u],this.cachedAccessToken=null,this.audience=t.get("audience"),this.subjectTokenType=l,this.workforcePoolUserProject=c;const f=RegExp("//iam\\.googleapis\\.com/locations/[^/]+/workforcePools/[^/]+/providers/.+");if(this.workforcePoolUserProject&&!this.audience.match(f))throw Error("workforcePoolUserProject should not be set for non-workforce pool credentials.");this.serviceAccountImpersonationUrl=p,this.serviceAccountImpersonationLifetime=h,this.serviceAccountImpersonationLifetime?this.configLifetimeRequested=!0:(this.configLifetimeRequested=!1,this.serviceAccountImpersonationLifetime=3600),this.projectNumber=this.getProjectNumber(this.audience),this.supplierContext={audience:this.audience,subjectTokenType:this.subjectTokenType,transporter:this.transporter}}getServiceAccountEmail(){if(this.serviceAccountImpersonationUrl){if(this.serviceAccountImpersonationUrl.length>256)throw RangeError(`URL is too long: ${this.serviceAccountImpersonationUrl}`);let e=/serviceAccounts\/(?<email>[^:]+):generateAccessToken$/.exec(this.serviceAccountImpersonationUrl);return e?.groups?.email||null}return null}setCredentials(e){super.setCredentials(e),this.cachedAccessToken=e}async getAccessToken(){return(!this.cachedAccessToken||this.isExpired(this.cachedAccessToken))&&await this.refreshAccessTokenAsync(),{token:this.cachedAccessToken.access_token,res:this.cachedAccessToken.res}}async getRequestHeaders(){let e=await this.getAccessToken(),t=new Headers({authorization:`Bearer ${e.token}`});return this.addSharedMetadataHeaders(t)}request(e,t){if(!t)return this.requestAsync(e);this.requestAsync(e).then(e=>t(null,e),e=>t(e,e.response))}async getProjectId(){let e=this.projectNumber||this.workforcePoolUserProject;if(this.projectId)return this.projectId;if(e){let t=await this.getRequestHeaders(),r={...c.RETRY_CONFIG,headers:t,url:`${this.cloudResourceManagerURL.toString()}${e}`,responseType:"json"};o.AuthClient.setMethodName(r,"getProjectId");let n=await this.transporter.request(r);return this.projectId=n.data.projectId,this.projectId}return null}async requestAsync(e,t=!1){let r;try{let t=await this.getRequestHeaders();e.headers=n.Gaxios.mergeHeaders(e.headers),this.addUserProjectAndAuthHeaders(e.headers,t),r=await this.transporter.request(e)}catch(n){let r=n.response;if(r){let n=r.status,o=r.config.data instanceof i.Readable;if(!t&&(401===n||403===n)&&!o&&this.forceRefreshOnFailure)return await this.refreshAccessTokenAsync(),await this.requestAsync(e,!0)}throw n}return r}async refreshAccessTokenAsync(){this.#m=this.#m||this.#g();try{return await this.#m}finally{this.#m=null}}async #g(){let e=await this.retrieveSubjectToken(),t={grantType:"urn:ietf:params:oauth:grant-type:token-exchange",audience:this.audience,requestedTokenType:"urn:ietf:params:oauth:token-type:access_token",subjectToken:e,subjectTokenType:this.subjectTokenType,scope:this.serviceAccountImpersonationUrl?[u]:this.getScopesArray()},r=!this.clientAuth&&this.workforcePoolUserProject?{userProject:this.workforcePoolUserProject}:void 0,n=new Headers({"x-goog-api-client":this.getMetricsHeaderValue()}),i=await this.stsCredential.exchangeToken(t,n,r);return this.serviceAccountImpersonationUrl?this.cachedAccessToken=await this.getImpersonatedAccessToken(i.access_token):i.expires_in?this.cachedAccessToken={access_token:i.access_token,expiry_date:new Date().getTime()+1e3*i.expires_in,res:i.res}:this.cachedAccessToken={access_token:i.access_token,res:i.res},this.credentials={},Object.assign(this.credentials,this.cachedAccessToken),delete this.credentials.res,this.emit("tokens",{refresh_token:null,expiry_date:this.cachedAccessToken.expiry_date,access_token:this.cachedAccessToken.access_token,token_type:"Bearer",id_token:null}),this.cachedAccessToken}getProjectNumber(e){let t=e.match(/\/projects\/([^/]+)/);return t?t[1]:null}async getImpersonatedAccessToken(e){let t={...c.RETRY_CONFIG,url:this.serviceAccountImpersonationUrl,method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e}`},data:{scope:this.getScopesArray(),lifetime:this.serviceAccountImpersonationLifetime+"s"},responseType:"json"};o.AuthClient.setMethodName(t,"getImpersonatedAccessToken");let r=await this.transporter.request(t),n=r.data;return{access_token:n.accessToken,expiry_date:new Date(n.expireTime).getTime(),res:r}}isExpired(e){let t=new Date().getTime();return!!e.expiry_date&&t>=e.expiry_date-this.eagerRefreshThresholdMillis}getScopesArray(){return"string"==typeof this.scopes?[this.scopes]:this.scopes||[u]}getMetricsHeaderValue(){let e=process.version.replace(/^v/,""),t=void 0!==this.serviceAccountImpersonationUrl,r=this.credentialSourceType?this.credentialSourceType:"unknown";return`gl-node/${e} auth/${l.pkg.version} google-byoid-sdk source/${r} sa-impersonation/${t} config-lifetime/${this.configLifetimeRequested}`}getTokenUrl(){return this.tokenUrl}}r.BaseExternalAccountClient=c},37289,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.FileSubjectTokenSupplier=void 0;let n=e.r(24361),i=e.r(22734),o=(0,n.promisify)(i.readFile??(()=>{})),s=(0,n.promisify)(i.realpath??(()=>{})),a=(0,n.promisify)(i.lstat??(()=>{}));r.FileSubjectTokenSupplier=class{filePath;formatType;subjectTokenFieldName;constructor(e){this.filePath=e.filePath,this.formatType=e.formatType,this.subjectTokenFieldName=e.subjectTokenFieldName}async getSubjectToken(){let e,t=this.filePath;try{if(t=await s(t),!(await a(t)).isFile())throw Error()}catch(e){throw e instanceof Error&&(e.message=`The file at ${t} does not exist, or it is not a file. ${e.message}`),e}let r=await o(t,{encoding:"utf8"});if("text"===this.formatType?e=r:"json"===this.formatType&&this.subjectTokenFieldName&&(e=JSON.parse(r)[this.subjectTokenFieldName]),!e)throw Error("Unable to parse the subject_token from the credential_source file");return e}}},63057,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.UrlSubjectTokenSupplier=void 0;let n=e.r(11656);r.UrlSubjectTokenSupplier=class{url;headers;formatType;subjectTokenFieldName;additionalGaxiosOptions;constructor(e){this.url=e.url,this.formatType=e.formatType,this.subjectTokenFieldName=e.subjectTokenFieldName,this.headers=e.headers,this.additionalGaxiosOptions=e.additionalGaxiosOptions}async getSubjectToken(e){let t,r={...this.additionalGaxiosOptions,url:this.url,method:"GET",headers:this.headers,responseType:this.formatType};if(n.AuthClient.setMethodName(r,"getSubjectToken"),"text"===this.formatType?t=(await e.transporter.request(r)).data:"json"===this.formatType&&this.subjectTokenFieldName&&(t=(await e.transporter.request(r)).data[this.subjectTokenFieldName]),!t)throw Error("Unable to parse the subject_token from the credential_source URL");return t}}},58218,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.CertificateSubjectTokenSupplier=r.InvalidConfigurationError=r.CertificateSourceUnavailableError=r.CERTIFICATE_CONFIGURATION_ENV_VARIABLE=void 0;let n=e.r(15733),i=e.r(22734),o=e.r(54799),s=e.r(24836);r.CERTIFICATE_CONFIGURATION_ENV_VARIABLE="GOOGLE_API_CERTIFICATE_CONFIG";class a extends Error{constructor(e){super(e),this.name="CertificateSourceUnavailableError"}}r.CertificateSourceUnavailableError=a;class l extends Error{constructor(e){super(e),this.name="InvalidConfigurationError"}}r.InvalidConfigurationError=l,r.CertificateSubjectTokenSupplier=class{certificateConfigPath;trustChainPath;cert;key;constructor(e){if(!e.useDefaultCertificateConfig&&!e.certificateConfigLocation)throw new l("Either `useDefaultCertificateConfig` must be true or a `certificateConfigLocation` must be provided.");if(e.useDefaultCertificateConfig&&e.certificateConfigLocation)throw new l("Both `useDefaultCertificateConfig` and `certificateConfigLocation` cannot be provided.");this.trustChainPath=e.trustChainPath,this.certificateConfigPath=e.certificateConfigLocation??""}async createMtlsHttpsAgent(){if(!this.key||!this.cert)throw new l("Cannot create mTLS Agent with missing certificate or key");return new s.Agent({key:this.key,cert:this.cert})}async getSubjectToken(){this.certificateConfigPath=await this.#y();let{certPath:e,keyPath:t}=await this.#_();return{cert:this.cert,key:this.key}=await this.#E(e,t),await this.#v(this.cert)}async #y(){let e=this.certificateConfigPath;if(e){if(await (0,n.isValidFile)(e))return e;throw new a(`Provided certificate config path is invalid: ${e}`)}let t=process.env[r.CERTIFICATE_CONFIGURATION_ENV_VARIABLE];if(t){if(await (0,n.isValidFile)(t))return t;throw new a(`Path from environment variable "${r.CERTIFICATE_CONFIGURATION_ENV_VARIABLE}" is invalid: ${t}`)}let i=(0,n.getWellKnownCertificateConfigFileLocation)();if(await (0,n.isValidFile)(i))return i;throw new a(`Could not find certificate configuration file. Searched override path, the "${r.CERTIFICATE_CONFIGURATION_ENV_VARIABLE}" env var, and the gcloud path (${i}).`)}async #_(){let e,t=this.certificateConfigPath;try{e=await i.promises.readFile(t,"utf8")}catch(e){throw new a(`Failed to read certificate config file at: ${t}`)}try{let r=JSON.parse(e),n=r?.cert_configs?.workload?.cert_path,i=r?.cert_configs?.workload?.key_path;if(!n||!i)throw new l(`Certificate config file (${t}) is missing required "cert_path" or "key_path" in the workload config.`);return{certPath:n,keyPath:i}}catch(e){if(e instanceof l)throw e;throw new l(`Failed to parse certificate config from ${t}: ${e.message}`)}}async #E(e,t){let r,n;try{r=await i.promises.readFile(e),new o.X509Certificate(r)}catch(r){let t=r instanceof Error?r.message:String(r);throw new a(`Failed to read certificate file at ${e}: ${t}`)}try{n=await i.promises.readFile(t),(0,o.createPrivateKey)(n)}catch(r){let e=r instanceof Error?r.message:String(r);throw new a(`Failed to read private key file at ${t}: ${e}`)}return{cert:r,key:n}}async #v(e){let t=new o.X509Certificate(e);if(!this.trustChainPath)return JSON.stringify([t.raw.toString("base64")]);try{let e,r=((await i.promises.readFile(this.trustChainPath,"utf8")).match(/-----BEGIN CERTIFICATE-----[^-]+-----END CERTIFICATE-----/g)??[]).map((e,t)=>{try{return new o.X509Certificate(e)}catch(r){let e=r instanceof Error?r.message:String(r);throw new l(`Failed to parse certificate at index ${t} in trust chain file ${this.trustChainPath}: ${e}`)}}),n=r.findIndex(e=>t.raw.equals(e.raw));if(-1===n)e=[t,...r];else if(0===n)e=r;else throw new l(`Leaf certificate exists in the trust chain but is not the first entry (found at index ${n}).`);return JSON.stringify(e.map(e=>e.raw.toString("base64")))}catch(t){if(t instanceof l)throw t;let e=t instanceof Error?t.message:String(t);throw new a(`Failed to process certificate chain from ${this.trustChainPath}: ${e}`)}}}},76868,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.IdentityPoolClient=void 0;let n=e.r(6560),i=e.r(15733),o=e.r(37289),s=e.r(63057),a=e.r(58218),l=e.r(5332),u=e.r(57612);class c extends n.BaseExternalAccountClient{subjectTokenSupplier;constructor(e){super(e);const t=(0,i.originalOrCamelOptions)(e),r=t.get("credential_source"),n=t.get("subject_token_supplier");if(!r&&!n)throw Error("A credential source or subject token supplier must be specified.");if(r&&n)throw Error("Only one of credential source or subject token supplier can be specified.");if(n)this.subjectTokenSupplier=n,this.credentialSourceType="programmatic";else{const e=(0,i.originalOrCamelOptions)(r),t=(0,i.originalOrCamelOptions)(e.get("format")),n=t.get("type")||"text",l=t.get("subject_token_field_name");if("json"!==n&&"text"!==n)throw Error(`Invalid credential_source format "${n}"`);if("json"===n&&!l)throw Error("Missing subject_token_field_name for JSON credential_source format");const u=e.get("file"),p=e.get("url"),d=e.get("certificate"),h=e.get("headers");if(u&&p||p&&d||u&&d)throw Error('No valid Identity Pool "credential_source" provided, must be either file, url, or certificate.');if(u)this.credentialSourceType="file",this.subjectTokenSupplier=new o.FileSubjectTokenSupplier({filePath:u,formatType:n,subjectTokenFieldName:l});else if(p)this.credentialSourceType="url",this.subjectTokenSupplier=new s.UrlSubjectTokenSupplier({url:p,formatType:n,subjectTokenFieldName:l,headers:h,additionalGaxiosOptions:c.RETRY_CONFIG});else if(d){this.credentialSourceType="certificate";const e=new a.CertificateSubjectTokenSupplier({useDefaultCertificateConfig:d.use_default_certificate_config,certificateConfigLocation:d.certificate_config_location,trustChainPath:d.trust_chain_path});this.subjectTokenSupplier=e}else throw Error('No valid Identity Pool "credential_source" provided, must be either file, url, or certificate.')}}async retrieveSubjectToken(){let e=await this.subjectTokenSupplier.getSubjectToken(this.supplierContext);if(this.subjectTokenSupplier instanceof a.CertificateSubjectTokenSupplier){let e=await this.subjectTokenSupplier.createMtlsHttpsAgent();this.stsCredential=new l.StsCredentials({tokenExchangeEndpoint:this.getTokenUrl(),clientAuthentication:this.clientAuth,transporter:new u.Gaxios({agent:e})}),this.transporter=new u.Gaxios({...this.transporter.defaults||{},agent:e})}return e}}r.IdentityPoolClient=c},87573,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.AwsRequestSigner=void 0;let n=e.r(57612),i=e.r(59501),o="AWS4-HMAC-SHA256";async function s(e,t,r){return await e.signWithHmacSha256(t,r)}async function a(e,t,r,n,i){let o=await s(e,`AWS4${t}`,r),a=await s(e,o,n),l=await s(e,a,i);return await s(e,l,"aws4_request")}async function l(e){let t=n.Gaxios.mergeHeaders(e.additionalAmzHeaders),r=e.requestPayload||"",l=e.host.split(".")[0],u=new Date,c=u.toISOString().replace(/[-:]/g,"").replace(/\.[0-9]+/,""),p=u.toISOString().replace(/[-]/g,"").replace(/T.*/,"");e.securityCredentials.token&&t.set("x-amz-security-token",e.securityCredentials.token);let d=n.Gaxios.mergeHeaders({host:e.host},t.has("date")?{}:{"x-amz-date":c},t),h="",f=[...d.keys()].sort();f.forEach(e=>{h+=`${e}:${d.get(e)}
|
|
5
|
-
`});let m=f.join(";"),g=await e.crypto.sha256DigestHex(r),y=`${e.method.toUpperCase()}
|
|
6
|
-
${e.canonicalUri}
|
|
7
|
-
${e.canonicalQuerystring}
|
|
8
|
-
${h}
|
|
9
|
-
${m}
|
|
10
|
-
${g}`,_=`${p}/${e.region}/${l}/aws4_request`,E=`${o}
|
|
11
|
-
${c}
|
|
12
|
-
${_}
|
|
13
|
-
`+await e.crypto.sha256DigestHex(y),v=await a(e.crypto,e.securityCredentials.secretAccessKey,p,e.region,l),A=await s(e.crypto,v,E),T=`${o} Credential=${e.securityCredentials.accessKeyId}/${_}, SignedHeaders=${m}, Signature=${(0,i.fromArrayBufferToHex)(A)}`;return{amzDate:t.has("date")?void 0:c,authorizationHeader:T,canonicalQuerystring:e.canonicalQuerystring}}r.AwsRequestSigner=class{getCredentials;region;crypto;constructor(e,t){this.getCredentials=e,this.region=t,this.crypto=(0,i.createCrypto)()}async getRequestOptions(e){if(!e.url)throw RangeError('"url" is required in "amzOptions"');let t="object"==typeof e.data?JSON.stringify(e.data):e.data,r=e.url,i=e.method||"GET",o=e.body||t,s=e.headers,a=await this.getCredentials(),u=new URL(r);if("string"!=typeof o&&void 0!==o)throw TypeError(`'requestPayload' is expected to be a string if provided. Got: ${o}`);let c=await l({crypto:this.crypto,host:u.host,canonicalUri:u.pathname,canonicalQuerystring:u.search.slice(1),method:i,region:this.region,securityCredentials:a,requestPayload:o,additionalAmzHeaders:s}),p=n.Gaxios.mergeHeaders(c.amzDate?{"x-amz-date":c.amzDate}:{},{authorization:c.authorizationHeader,host:u.host},s||{});a.token&&n.Gaxios.mergeHeaders(p,{"x-amz-security-token":a.token});let d={url:r,method:i,headers:p};return void 0!==o&&(d.body=o),d}}},41033,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.DefaultAwsSecurityCredentialsSupplier=void 0;let n=e.r(11656);r.DefaultAwsSecurityCredentialsSupplier=class{regionUrl;securityCredentialsUrl;imdsV2SessionTokenUrl;additionalGaxiosOptions;constructor(e){this.regionUrl=e.regionUrl,this.securityCredentialsUrl=e.securityCredentialsUrl,this.imdsV2SessionTokenUrl=e.imdsV2SessionTokenUrl,this.additionalGaxiosOptions=e.additionalGaxiosOptions}async getAwsRegion(e){if(this.#A)return this.#A;let t=new Headers;if(!this.#A&&this.imdsV2SessionTokenUrl&&t.set("x-aws-ec2-metadata-token",await this.#T(e.transporter)),!this.regionUrl)throw RangeError('Unable to determine AWS region due to missing "options.credential_source.region_url"');let r={...this.additionalGaxiosOptions,url:this.regionUrl,method:"GET",responseType:"text",headers:t};n.AuthClient.setMethodName(r,"getAwsRegion");let i=await e.transporter.request(r);return i.data.substr(0,i.data.length-1)}async getAwsSecurityCredentials(e){if(this.#C)return this.#C;let t=new Headers;this.imdsV2SessionTokenUrl&&t.set("x-aws-ec2-metadata-token",await this.#T(e.transporter));let r=await this.#S(t,e.transporter),n=await this.#b(r,t,e.transporter);return{accessKeyId:n.AccessKeyId,secretAccessKey:n.SecretAccessKey,token:n.Token}}async #T(e){let t={...this.additionalGaxiosOptions,url:this.imdsV2SessionTokenUrl,method:"PUT",responseType:"text",headers:{"x-aws-ec2-metadata-token-ttl-seconds":"300"}};return n.AuthClient.setMethodName(t,"#getImdsV2SessionToken"),(await e.request(t)).data}async #S(e,t){if(!this.securityCredentialsUrl)throw Error('Unable to determine AWS role name due to missing "options.credential_source.url"');let r={...this.additionalGaxiosOptions,url:this.securityCredentialsUrl,method:"GET",responseType:"text",headers:e};return n.AuthClient.setMethodName(r,"#getAwsRoleName"),(await t.request(r)).data}async #b(e,t,r){let i={...this.additionalGaxiosOptions,url:`${this.securityCredentialsUrl}/${e}`,headers:t,responseType:"json"};return n.AuthClient.setMethodName(i,"#retrieveAwsSecurityCredentials"),(await r.request(i)).data}get #A(){return process.env.AWS_REGION||process.env.AWS_DEFAULT_REGION||null}get #C(){return process.env.AWS_ACCESS_KEY_ID&&process.env.AWS_SECRET_ACCESS_KEY?{accessKeyId:process.env.AWS_ACCESS_KEY_ID,secretAccessKey:process.env.AWS_SECRET_ACCESS_KEY,token:process.env.AWS_SESSION_TOKEN}:null}}},90220,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.AwsClient=void 0;let n=e.r(87573),i=e.r(6560),o=e.r(41033),s=e.r(15733),a=e.r(57612);class l extends i.BaseExternalAccountClient{environmentId;awsSecurityCredentialsSupplier;regionalCredVerificationUrl;awsRequestSigner;region;static #I="https://sts.{region}.amazonaws.com?Action=GetCallerIdentity&Version=2011-06-15";static AWS_EC2_METADATA_IPV4_ADDRESS="169.254.169.254";static AWS_EC2_METADATA_IPV6_ADDRESS="fd00:ec2::254";constructor(e){super(e);const t=(0,s.originalOrCamelOptions)(e),r=t.get("credential_source"),n=t.get("aws_security_credentials_supplier");if(!r&&!n)throw Error("A credential source or AWS security credentials supplier must be specified.");if(r&&n)throw Error("Only one of credential source or AWS security credentials supplier can be specified.");if(n)this.awsSecurityCredentialsSupplier=n,this.regionalCredVerificationUrl=l.#I,this.credentialSourceType="programmatic";else{const e=(0,s.originalOrCamelOptions)(r);this.environmentId=e.get("environment_id");const t=e.get("region_url"),n=e.get("url"),i=e.get("imdsv2_session_token_url");this.awsSecurityCredentialsSupplier=new o.DefaultAwsSecurityCredentialsSupplier({regionUrl:t,securityCredentialsUrl:n,imdsV2SessionTokenUrl:i}),this.regionalCredVerificationUrl=e.get("regional_cred_verification_url"),this.credentialSourceType="aws",this.validateEnvironmentId()}this.awsRequestSigner=null,this.region=""}validateEnvironmentId(){let e=this.environmentId?.match(/^(aws)(\d+)$/);if(e&&this.regionalCredVerificationUrl){if(1!==parseInt(e[2],10))throw Error(`aws version "${e[2]}" is not supported in the current build.`)}else throw Error('No valid AWS "credential_source" provided')}async retrieveSubjectToken(){this.awsRequestSigner||(this.region=await this.awsSecurityCredentialsSupplier.getAwsRegion(this.supplierContext),this.awsRequestSigner=new n.AwsRequestSigner(async()=>this.awsSecurityCredentialsSupplier.getAwsSecurityCredentials(this.supplierContext),this.region));let e=await this.awsRequestSigner.getRequestOptions({...l.RETRY_CONFIG,url:this.regionalCredVerificationUrl.replace("{region}",this.region),method:"POST"}),t=[];return a.Gaxios.mergeHeaders({"x-goog-cloud-target-resource":this.audience},e.headers).forEach((e,r)=>t.push({key:r,value:e})),encodeURIComponent(JSON.stringify({url:e.url,method:e.method,headers:t}))}}r.AwsClient=l},71006,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.InvalidSubjectTokenError=r.InvalidMessageFieldError=r.InvalidCodeFieldError=r.InvalidTokenTypeFieldError=r.InvalidExpirationTimeFieldError=r.InvalidSuccessFieldError=r.InvalidVersionFieldError=r.ExecutableResponseError=r.ExecutableResponse=void 0;let n="urn:ietf:params:oauth:token-type:saml2",i="urn:ietf:params:oauth:token-type:id_token",o="urn:ietf:params:oauth:token-type:jwt";r.ExecutableResponse=class{version;success;expirationTime;tokenType;errorCode;errorMessage;subjectToken;constructor(e){if(!e.version)throw new a("Executable response must contain a 'version' field.");if(void 0===e.success)throw new l("Executable response must contain a 'success' field.");if(this.version=e.version,this.success=e.success,this.success){if(this.expirationTime=e.expiration_time,this.tokenType=e.token_type,this.tokenType!==n&&this.tokenType!==i&&this.tokenType!==o)throw new u(`Executable response must contain a 'token_type' field when successful and it must be one of ${i}, ${o}, or ${n}.`);if(this.tokenType===n){if(!e.saml_response)throw new d(`Executable response must contain a 'saml_response' field when token_type=${n}.`);this.subjectToken=e.saml_response}else{if(!e.id_token)throw new d(`Executable response must contain a 'id_token' field when token_type=${i} or ${o}.`);this.subjectToken=e.id_token}}else{if(!e.code)throw new c("Executable response must contain a 'code' field when unsuccessful.");if(!e.message)throw new p("Executable response must contain a 'message' field when unsuccessful.");this.errorCode=e.code,this.errorMessage=e.message}}isValid(){return!this.isExpired()&&this.success}isExpired(){return void 0!==this.expirationTime&&this.expirationTime<Math.round(Date.now()/1e3)}};class s extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}r.ExecutableResponseError=s;class a extends s{}r.InvalidVersionFieldError=a;class l extends s{}r.InvalidSuccessFieldError=l,r.InvalidExpirationTimeFieldError=class extends s{};class u extends s{}r.InvalidTokenTypeFieldError=u;class c extends s{}r.InvalidCodeFieldError=c;class p extends s{}r.InvalidMessageFieldError=p;class d extends s{}r.InvalidSubjectTokenError=d},20336,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.PluggableAuthHandler=r.ExecutableError=void 0;let n=e.r(71006),i=e.r(33405),o=e.r(22734);class s extends Error{code;constructor(e,t){super(`The executable failed with exit code: ${t} and error message: ${e}.`),this.code=t,Object.setPrototypeOf(this,new.target.prototype)}}r.ExecutableError=s;class a{commandComponents;timeoutMillis;outputFile;constructor(e){if(!e.command)throw Error("No command provided.");if(this.commandComponents=a.parseCommand(e.command),this.timeoutMillis=e.timeoutMillis,!this.timeoutMillis)throw Error("No timeoutMillis provided.");this.outputFile=e.outputFile}retrieveResponseFromExecutable(e){return new Promise((t,r)=>{let o=i.spawn(this.commandComponents[0],this.commandComponents.slice(1),{env:{...process.env,...Object.fromEntries(e)}}),a="";o.stdout.on("data",e=>{a+=e}),o.stderr.on("data",e=>{a+=e});let l=setTimeout(()=>(o.removeAllListeners(),o.kill(),r(Error("The executable failed to finish within the timeout specified."))),this.timeoutMillis);o.on("close",e=>{if(clearTimeout(l),0!==e)return r(new s(a,e.toString()));try{let e=JSON.parse(a),r=new n.ExecutableResponse(e);return t(r)}catch(e){if(e instanceof n.ExecutableResponseError)return r(e);return r(new n.ExecutableResponseError(`The executable returned an invalid response: ${a}`))}})})}async retrieveCachedResponse(){let e;if(!this.outputFile||0===this.outputFile.length)return;try{e=await o.promises.realpath(this.outputFile)}catch{return}if(!(await o.promises.lstat(e)).isFile())return;let t=await o.promises.readFile(e,{encoding:"utf8"});if(""!==t)try{let e=JSON.parse(t);if(new n.ExecutableResponse(e).isValid())return new n.ExecutableResponse(e);return}catch(e){if(e instanceof n.ExecutableResponseError)throw e;throw new n.ExecutableResponseError(`The output file contained an invalid response: ${t}`)}}static parseCommand(e){let t=e.match(/(?:[^\s"]+|"[^"]*")+/g);if(!t)throw Error(`Provided command: "${e}" could not be parsed.`);for(let e=0;e<t.length;e++)'"'===t[e][0]&&'"'===t[e].slice(-1)&&(t[e]=t[e].slice(1,-1));return t}}r.PluggableAuthHandler=a},23238,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.PluggableAuthClient=r.ExecutableError=void 0;let n=e.r(6560),i=e.r(71006),o=e.r(20336);var s=e.r(20336);Object.defineProperty(r,"ExecutableError",{enumerable:!0,get:function(){return s.ExecutableError}});class a extends n.BaseExternalAccountClient{command;timeoutMillis;outputFile;handler;constructor(e){if(super(e),!e.credential_source.executable||(this.command=e.credential_source.executable.command,!this.command))throw Error('No valid Pluggable Auth "credential_source" provided.');if(void 0===e.credential_source.executable.timeout_millis)this.timeoutMillis=3e4;else if(this.timeoutMillis=e.credential_source.executable.timeout_millis,this.timeoutMillis<5e3||this.timeoutMillis>12e4)throw Error("Timeout must be between 5000120000 milliseconds.");this.outputFile=e.credential_source.executable.output_file,this.handler=new o.PluggableAuthHandler({command:this.command,timeoutMillis:this.timeoutMillis,outputFile:this.outputFile}),this.credentialSourceType="executable"}async retrieveSubjectToken(){let e;if("1"!==process.env.GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLES)throw Error("Pluggable Auth executables need to be explicitly allowed to run by setting the GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLES environment Variable to 1.");if(this.outputFile&&(e=await this.handler.retrieveCachedResponse()),!e){let t=new Map;t.set("GOOGLE_EXTERNAL_ACCOUNT_AUDIENCE",this.audience),t.set("GOOGLE_EXTERNAL_ACCOUNT_TOKEN_TYPE",this.subjectTokenType),t.set("GOOGLE_EXTERNAL_ACCOUNT_INTERACTIVE","0"),this.outputFile&&t.set("GOOGLE_EXTERNAL_ACCOUNT_OUTPUT_FILE",this.outputFile);let r=this.getServiceAccountEmail();r&&t.set("GOOGLE_EXTERNAL_ACCOUNT_IMPERSONATED_EMAIL",r),e=await this.handler.retrieveResponseFromExecutable(t)}if(e.version>1)throw Error("Version of executable is not currently supported, maximum supported version is 1.");if(!e.success)throw new o.ExecutableError(e.errorMessage,e.errorCode);if(this.outputFile&&!e.expirationTime)throw new i.InvalidExpirationTimeFieldError("The executable response must contain the `expiration_time` field for successful responses when an output_file has been specified in the configuration.");if(e.isExpired())throw Error("Executable response is expired.");return e.subjectToken}}r.PluggableAuthClient=a},45037,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.ExternalAccountClient=void 0;let n=e.r(6560),i=e.r(76868),o=e.r(90220),s=e.r(23238);r.ExternalAccountClient=class{constructor(){throw Error("ExternalAccountClients should be initialized via: ExternalAccountClient.fromJSON(), directly via explicit constructors, eg. new AwsClient(options), new IdentityPoolClient(options), newPluggableAuthClientOptions, or via new GoogleAuth(options).getClient()")}static fromJSON(e){return e&&e.type===n.EXTERNAL_ACCOUNT_TYPE?e.credential_source?.environment_id?new o.AwsClient(e):e.credential_source?.executable?new s.PluggableAuthClient(e):new i.IdentityPoolClient(e):null}}},74158,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.ExternalAccountAuthorizedUserClient=r.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE=void 0;let n=e.r(11656),i=e.r(46944),o=e.r(57612),s=e.r(88947),a=e.r(6560);r.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE="external_account_authorized_user";class l extends i.OAuthClientAuthHandler{#O;constructor(e){super(e),this.#O=e.tokenRefreshEndpoint}async refreshToken(e,t){let r={...l.RETRY_CONFIG,url:this.#O,method:"POST",headers:t,data:new URLSearchParams({grant_type:"refresh_token",refresh_token:e}),responseType:"json"};n.AuthClient.setMethodName(r,"refreshToken"),this.applyClientAuthenticationOptions(r);try{let e=await this.transporter.request(r),t=e.data;return t.res=e,t}catch(e){if(e instanceof o.GaxiosError&&e.response)throw(0,i.getErrorFromOAuthErrorResponse)(e.response.data,e);throw e}}}class u extends n.AuthClient{cachedAccessToken;externalAccountAuthorizedUserHandler;refreshToken;constructor(e){super(e),e.universe_domain&&(this.universeDomain=e.universe_domain),this.refreshToken=e.refresh_token;const t={confidentialClientType:"basic",clientId:e.client_id,clientSecret:e.client_secret};this.externalAccountAuthorizedUserHandler=new l({tokenRefreshEndpoint:e.token_url??"https://sts.{universeDomain}/v1/oauthtoken".replace("{universeDomain}",this.universeDomain),transporter:this.transporter,clientAuthentication:t}),this.cachedAccessToken=null,this.quotaProjectId=e.quota_project_id,"number"!=typeof e?.eagerRefreshThresholdMillis?this.eagerRefreshThresholdMillis=a.EXPIRATION_TIME_OFFSET:this.eagerRefreshThresholdMillis=e.eagerRefreshThresholdMillis,this.forceRefreshOnFailure=!!e?.forceRefreshOnFailure}async getAccessToken(){return(!this.cachedAccessToken||this.isExpired(this.cachedAccessToken))&&await this.refreshAccessTokenAsync(),{token:this.cachedAccessToken.access_token,res:this.cachedAccessToken.res}}async getRequestHeaders(){let e=await this.getAccessToken(),t=new Headers({authorization:`Bearer ${e.token}`});return this.addSharedMetadataHeaders(t)}request(e,t){if(!t)return this.requestAsync(e);this.requestAsync(e).then(e=>t(null,e),e=>t(e,e.response))}async requestAsync(e,t=!1){let r;try{let t=await this.getRequestHeaders();e.headers=o.Gaxios.mergeHeaders(e.headers),this.addUserProjectAndAuthHeaders(e.headers,t),r=await this.transporter.request(e)}catch(n){let r=n.response;if(r){let n=r.status,i=r.config.data instanceof s.Readable;if(!t&&(401===n||403===n)&&!i&&this.forceRefreshOnFailure)return await this.refreshAccessTokenAsync(),await this.requestAsync(e,!0)}throw n}return r}async refreshAccessTokenAsync(){let e=await this.externalAccountAuthorizedUserHandler.refreshToken(this.refreshToken);return this.cachedAccessToken={access_token:e.access_token,expiry_date:new Date().getTime()+1e3*e.expires_in,res:e.res},void 0!==e.refresh_token&&(this.refreshToken=e.refresh_token),this.cachedAccessToken}isExpired(e){let t=new Date().getTime();return!!e.expiry_date&&t>=e.expiry_date-this.eagerRefreshThresholdMillis}}r.ExternalAccountAuthorizedUserClient=u},87649,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.GdchClient=r.GDCH_SERVICE_ACCOUNT_TYPE=void 0;let n=e.r(54799),i=e.r(22734),o=e.r(24836),s=e.r(701);r.GDCH_SERVICE_ACCOUNT_TYPE="gdch_service_account";class a extends s.OAuth2Client{projectId;privateKeyId;privateKey;serviceIdentityName;tokenServerUri;caCertPath;apiAudience;lifetime;gdchOptions;caAgentPromise;cachedCaCertPath;lastCaCertReadTime=0;CA_CERT_TTL_MS=3e5;constructor(e={}){super(e),this.gdchOptions=e,this.projectId=e.projectId||void 0,this.privateKeyId=e.privateKeyId,this.privateKey=e.privateKey,this.serviceIdentityName=e.serviceIdentityName,this.tokenServerUri=e.tokenServerUri,this.caCertPath=e.caCertPath,this.apiAudience=e.apiAudience,this.lifetime=e.lifetime||3600,this.credentials={refresh_token:"gdch-placeholder",expiry_date:1}}createWithGdchAudience(e){if(!e)throw Error("Audience cannot be null or empty for GDCH service account credentials.");return new a({...this.gdchOptions,projectId:this.projectId,privateKeyId:this.privateKeyId,privateKey:this.privateKey,serviceIdentityName:this.serviceIdentityName,tokenServerUri:this.tokenServerUri,caCertPath:this.caCertPath,lifetime:this.lifetime,apiAudience:e})}fromJSON(e){if(!e)throw Error("Must pass in a JSON object containing the GDCH credentials settings.");if(e.type!==r.GDCH_SERVICE_ACCOUNT_TYPE)throw Error(`The incoming JSON object does not have the "${r.GDCH_SERVICE_ACCOUNT_TYPE}" type`);if("1"!==e.format_version)throw Error("Only format version 1 is supported.");if(!e.project)throw Error("The incoming JSON object does not contain a project field");if(!e.private_key_id)throw Error("The incoming JSON object does not contain a private_key_id field");if(!e.private_key)throw Error("The incoming JSON object does not contain a private_key field");if(!e.name)throw Error("The incoming JSON object does not contain a name field");if(!e.token_uri)throw Error("The incoming JSON object does not contain a token_uri field");this.projectId=e.project,this.privateKeyId=e.private_key_id,this.privateKey=e.private_key,this.serviceIdentityName=e.name,this.tokenServerUri=e.token_uri,this.caCertPath=e.ca_cert_path,this.gdchOptions={...this.gdchOptions,projectId:e.project,privateKeyId:e.private_key_id,privateKey:e.private_key,serviceIdentityName:e.name,tokenServerUri:e.token_uri,caCertPath:e.ca_cert_path}}async refreshTokenNoCache(){if(!this.apiAudience)throw Error("Audience cannot be null or empty for GDCH service account credentials. Specify the audience by calling createWithGdchAudience.");if(!this.privateKey)throw Error("Private key is not configured for GDCH credentials.");if(!this.privateKeyId)throw Error("Private key ID is not configured for GDCH credentials.");if(!this.projectId)throw Error("Project is not configured for GDCH credentials.");if(!this.serviceIdentityName)throw Error("Service identity name is not configured for GDCH credentials.");if(!this.tokenServerUri)throw Error("Token server URI is not configured for GDCH credentials.");let e=this.createAssertion(),t={audience:this.apiAudience,grant_type:"urn:ietf:params:oauth:token-type:token-exchange",requested_token_type:"urn:ietf:params:oauth:token-type:access_token",subject_token:e,subject_token_type:"urn:k8s:params:oauth:token-type:serviceaccount"},r={url:this.tokenServerUri,method:"POST",headers:{"Content-Type":"application/json"},data:t,responseType:"json",timeout:1e4,retry:!0,retryConfig:{httpMethodsToRetry:["POST"],statusCodesToRetry:[[500,599]],noResponseRetries:3}};this.caCertPath&&(r.agent=await this.getCaAgent());try{let e=await this.transporter.request(r),t=e.data;if(!t.access_token)throw Error("Token response did not contain an access_token.");if(!t.expires_in)throw Error("Token response did not contain an expires_in field.");let n={access_token:t.access_token,token_type:"STS-Bearer",expiry_date:Date.now()+1e3*t.expires_in};return this.emit("tokens",n),{res:e,tokens:n}}catch(e){if(e&&e.config&&e.config.data)try{if("string"==typeof e.config.data){let t=JSON.parse(e.config.data);t.subject_token&&(t.subject_token="***REDACTED***",e.config.data=JSON.stringify(t))}else"object"==typeof e.config.data&&e.config.data.subject_token&&(e.config.data.subject_token="***REDACTED***")}catch{}throw e instanceof Error&&(e.message=`Error getting access token for GDCH service account: ${e.message}, iss: ${this.serviceIdentityName}`),e}}createAssertion(){let e={alg:"ES256",typ:"JWT",kid:this.privateKeyId},t=`system:serviceaccount:${this.projectId}:${this.serviceIdentityName}`,r=Math.floor(Date.now()/1e3),i={iss:t,sub:t,iat:r,exp:r+this.lifetime,aud:this.tokenServerUri},o=this.base64UrlEncode(JSON.stringify(e)),s=this.base64UrlEncode(JSON.stringify(i)),a=`${o}.${s}`,l=n.sign("sha256",Buffer.from(a),{key:this.privateKey,dsaEncoding:"ieee-p1363"}),u=this.base64UrlEncode(l);return`${a}.${u}`}async requestAsync(e,t=!1){if(this.caCertPath&&!e.agent){let t=(e.url||"").toString();t.includes("googleapis.com")||t.includes("google.com")||(e.agent=await this.getCaAgent())}return super.requestAsync(e,t)}getCaAgent(){if(!this.caCertPath){this.caAgentPromise=void 0,this.cachedCaCertPath=void 0,this.lastCaCertReadTime=0;return}let e=Date.now(),t=e-this.lastCaCertReadTime>this.CA_CERT_TTL_MS;if(this.caAgentPromise&&this.caCertPath===this.cachedCaCertPath&&!t)return this.caAgentPromise;this.cachedCaCertPath=this.caCertPath,this.lastCaCertReadTime=e;let r=this.caCertPath;return this.caAgentPromise=(async()=>{try{let e=await i.promises.readFile(r);return new o.Agent({ca:e})}catch(e){throw this.cachedCaCertPath===r&&(this.caAgentPromise=void 0,this.cachedCaCertPath=void 0,this.lastCaCertReadTime=0),e instanceof Error&&(e.message=`Error reading certificate file from CA cert path, value '${r}': ${e.message}`),e}})(),this.caAgentPromise}toJSON(){return{...this,privateKey:this.privateKey?"***REDACTED***":void 0,_clientSecret:this._clientSecret?"***REDACTED***":void 0,apiKey:this.apiKey?"***REDACTED***":void 0,gdchOptions:this.gdchOptions?{...this.gdchOptions,privateKey:this.gdchOptions.privateKey?"***REDACTED***":void 0,clientSecret:this.gdchOptions.clientSecret?"***REDACTED***":void 0,client_secret:this.gdchOptions.client_secret?"***REDACTED***":void 0,apiKey:this.gdchOptions.apiKey?"***REDACTED***":void 0,credentials:this.gdchOptions.credentials?{...this.gdchOptions.credentials,access_token:this.gdchOptions.credentials.access_token?"***REDACTED***":void 0,refresh_token:this.gdchOptions.credentials.refresh_token?"***REDACTED***":void 0}:void 0}:void 0,credentials:{...this.credentials,access_token:this.credentials?.access_token?"***REDACTED***":void 0,refresh_token:this.credentials?.refresh_token?"***REDACTED***":void 0}}}[Symbol.for("nodejs.util.inspect.custom")](){return this.toJSON()}base64UrlEncode(e){return("string"==typeof e?Buffer.from(e):e).toString("base64url")}}r.GdchClient=a},64794,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.GoogleAuth=r.GoogleAuthExceptionMessages=void 0;let n=e.r(33405),i=e.r(22734),o=e.r(57612),s=e.r(82e3),a=e.r(46786),l=e.r(14747),u=e.r(59501),c=e.r(70814),p=e.r(80732),d=e.r(80243),h=e.r(24553),f=e.r(16260),m=e.r(36126),g=e.r(45037),y=e.r(6560),_=e.r(11656),E=e.r(74158),v=e.r(87649),A=e.r(15733);r.GoogleAuthExceptionMessages={API_KEY_WITH_CREDENTIALS:"API Keys and Credentials are mutually exclusive authentication methods and cannot be used together.",NO_PROJECT_ID_FOUND:"Unable to detect a Project Id in the current environment. \nTo learn more about authentication and Google APIs, visit: \nhttps://cloud.google.com/docs/authentication/getting-started",NO_CREDENTIALS_FOUND:"Unable to find credentials in current environment. \nTo learn more about authentication and Google APIs, visit: \nhttps://cloud.google.com/docs/authentication/getting-started",NO_ADC_FOUND:"Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.",NO_UNIVERSE_DOMAIN_FOUND:"Unable to detect a Universe Domain in the current environment.\nTo learn more about Universe Domain retrieval, visit: \nhttps://cloud.google.com/compute/docs/metadata/predefined-metadata-keys"},r.GoogleAuth=class{checkIsGCE=void 0;useJWTAccessWithScope;defaultServicePath;get isGCE(){return this.checkIsGCE}_findProjectIdPromise;_cachedProjectId;jsonContent=null;apiKey;cachedCredential=null;#w=null;defaultScopes;keyFilename;scopes;clientOptions={};constructor(e={}){if(this._cachedProjectId=e.projectId||null,this.cachedCredential=e.authClient||null,this.keyFilename=e.keyFilename||e.keyFile,this.scopes=e.scopes,this.clientOptions=e.clientOptions||{},this.jsonContent=e.credentials||null,this.apiKey=e.apiKey||this.clientOptions.apiKey||null,this.apiKey&&(this.jsonContent||this.clientOptions.credentials))throw RangeError(r.GoogleAuthExceptionMessages.API_KEY_WITH_CREDENTIALS);e.universeDomain&&(this.clientOptions.universeDomain=e.universeDomain)}setGapicJWTValues(e){e.defaultServicePath=this.defaultServicePath,e.useJWTAccessWithScope=this.useJWTAccessWithScope,e.defaultScopes=this.defaultScopes}getProjectId(e){if(!e)return this.getProjectIdAsync();this.getProjectIdAsync().then(t=>e(null,t),e)}async getProjectIdOptional(){try{return await this.getProjectId()}catch(e){if(e instanceof Error&&e.message===r.GoogleAuthExceptionMessages.NO_PROJECT_ID_FOUND)return null;throw e}}async findAndCacheProjectId(){let e=null;if(e||=await this.getProductionProjectId(),e||=await this.getFileProjectId(),e||=await this.getDefaultServiceProjectId(),e||=await this.getGCEProjectId(),e||=await this.getExternalAccountClientProjectId())return this._cachedProjectId=e,e;throw Error(r.GoogleAuthExceptionMessages.NO_PROJECT_ID_FOUND)}async getProjectIdAsync(){return this._cachedProjectId?this._cachedProjectId:(this._findProjectIdPromise||(this._findProjectIdPromise=this.findAndCacheProjectId()),this._findProjectIdPromise)}async getUniverseDomainFromMetadataServer(){let e;try{e=await s.universe("universe-domain"),e||=_.DEFAULT_UNIVERSE}catch(t){if(t&&t?.response?.status===404)e=_.DEFAULT_UNIVERSE;else throw t}return e}async getUniverseDomain(){let e=(0,A.originalOrCamelOptions)(this.clientOptions).get("universe_domain");try{e??=(await this.getClient()).universeDomain}catch{e??=_.DEFAULT_UNIVERSE}return e}getAnyScopes(){return this.scopes||this.defaultScopes}getApplicationDefault(e={},t){let r;if("function"==typeof e?t=e:r=e,!t)return this.getApplicationDefaultAsync(r);this.getApplicationDefaultAsync(r).then(e=>t(null,e.credential,e.projectId),t)}async getApplicationDefaultAsync(e={}){let t;if(this.cachedCredential)return await this.#P(this.cachedCredential,null);if((t=await this._tryGetApplicationCredentialsFromEnvironmentVariable(e))||(t=await this._tryGetApplicationCredentialsFromWellKnownFile(e)))return t instanceof h.JWT?t.scopes=this.scopes:t instanceof y.BaseExternalAccountClient&&(t.scopes=this.getAnyScopes()),await this.#P(t);if(await this._checkIsGCE())return e.scopes=this.getAnyScopes(),await this.#P(new c.Compute(e));throw Error(r.GoogleAuthExceptionMessages.NO_ADC_FOUND)}async #P(e,t=process.env.GOOGLE_CLOUD_QUOTA_PROJECT||null){let r=await this.getProjectIdOptional();return t&&(e.quotaProjectId=t),this.cachedCredential=e,{credential:e,projectId:r}}async _checkIsGCE(){return void 0===this.checkIsGCE&&(this.checkIsGCE=s.getGCPResidency()||await s.isAvailable()),this.checkIsGCE}async _tryGetApplicationCredentialsFromEnvironmentVariable(e){let t=process.env.GOOGLE_APPLICATION_CREDENTIALS||process.env.google_application_credentials;if(!t||0===t.length)return null;try{return this._getApplicationCredentialsFromFilePath(t,e)}catch(e){throw e instanceof Error&&(e.message=`Unable to read the credential file specified by the GOOGLE_APPLICATION_CREDENTIALS environment variable: ${e.message}`),e}}async _tryGetApplicationCredentialsFromWellKnownFile(e){let t=null;if(this._isWindows())t=process.env.APPDATA;else{let e=process.env.HOME;e&&(t=l.join(e,".config"))}return(t&&(t=l.join(t,"gcloud","application_default_credentials.json"),i.existsSync(t)||(t=null)),t)?await this._getApplicationCredentialsFromFilePath(t,e):null}async _getApplicationCredentialsFromFilePath(e,t={}){if(!e||0===e.length)throw Error("The file path is invalid.");try{if(e=i.realpathSync(e),!i.lstatSync(e).isFile())throw Error()}catch(t){throw t instanceof Error&&(t.message=`The file at ${e} does not exist, or it is not a file. ${t.message}`),t}let r=i.createReadStream(e);return this.fromStream(r,t)}fromImpersonatedJSON(e){if(!e)throw Error("Must pass in a JSON object containing an impersonated refresh token");if(e.type!==m.IMPERSONATED_ACCOUNT_TYPE)throw Error(`The incoming JSON object does not have the "${m.IMPERSONATED_ACCOUNT_TYPE}" type`);if(!e.source_credentials)throw Error("The incoming JSON object does not contain a source_credentials field");if(!e.service_account_impersonation_url)throw Error("The incoming JSON object does not contain a service_account_impersonation_url field");let t=this.fromJSON(e.source_credentials);if(e.service_account_impersonation_url?.length>256)throw RangeError(`Target principal is too long: ${e.service_account_impersonation_url}`);let r=/(?<target>[^/]+):(generateAccessToken|generateIdToken)$/.exec(e.service_account_impersonation_url)?.groups?.target;if(!r)throw RangeError(`Cannot extract target principal from ${e.service_account_impersonation_url}`);let n=(this.scopes||e.scopes||this.defaultScopes)??[];return new m.Impersonated({...e,sourceClient:t,targetPrincipal:r,targetScopes:Array.isArray(n)?n:[n]})}fromJSON(e,t={}){let r,n=(0,A.originalOrCamelOptions)(t).get("universe_domain");return e.type===f.USER_REFRESH_ACCOUNT_TYPE?(r=new f.UserRefreshClient(t)).fromJSON(e):e.type===m.IMPERSONATED_ACCOUNT_TYPE?r=this.fromImpersonatedJSON(e):e.type===y.EXTERNAL_ACCOUNT_TYPE?(r=g.ExternalAccountClient.fromJSON({...e,...t})).scopes=this.getAnyScopes():e.type===E.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE?r=new E.ExternalAccountAuthorizedUserClient({...e,...t}):e.type===v.GDCH_SERVICE_ACCOUNT_TYPE?(r=new v.GdchClient(t)).fromJSON(e):(t.scopes=this.scopes,r=new h.JWT(t),this.setGapicJWTValues(r),r.fromJSON(e)),n&&(r.universeDomain=n),r}_cacheClientFromJSON(e,t){let r=this.fromJSON(e,t);return this.jsonContent=e,this.cachedCredential=r,r}fromStream(e,t={},r){let n={};if("function"==typeof t?r=t:n=t,!r)return this.fromStreamAsync(e,n);this.fromStreamAsync(e,n).then(e=>r(null,e),r)}fromStreamAsync(e,t){return new Promise((r,n)=>{if(!e)throw Error("Must pass in a stream containing the Google auth settings.");let i=[];e.setEncoding("utf8").on("error",n).on("data",e=>i.push(e)).on("end",()=>{try{try{let e=JSON.parse(i.join("")),n=this._cacheClientFromJSON(e,t);return r(n)}catch(t){if(!this.keyFilename)throw t;let e=new h.JWT({...this.clientOptions,keyFile:this.keyFilename});return this.cachedCredential=e,this.setGapicJWTValues(e),r(e)}}catch(e){return n(e)}})})}fromAPIKey(e,t={}){return new h.JWT({...t,apiKey:e})}_isWindows(){let e=a.platform();return!!e&&!!(e.length>=3)&&"win"===e.substring(0,3).toLowerCase()}async getDefaultServiceProjectId(){return new Promise(e=>{(0,n.exec)("gcloud config config-helper --format json",(t,r)=>{if(!t&&r)try{let t=JSON.parse(r).configuration.properties.core.project;e(t);return}catch(e){}e(null)})})}getProductionProjectId(){return process.env.GCLOUD_PROJECT||process.env.GOOGLE_CLOUD_PROJECT||process.env.gcloud_project||process.env.google_cloud_project}async getFileProjectId(){if(this.cachedCredential)return this.cachedCredential.projectId;if(this.keyFilename){let e=await this.getClient();if(e&&e.projectId)return e.projectId}let e=await this._tryGetApplicationCredentialsFromEnvironmentVariable();return e?e.projectId:null}async getExternalAccountClientProjectId(){if(!this.jsonContent||this.jsonContent.type!==y.EXTERNAL_ACCOUNT_TYPE)return null;let e=await this.getClient();return await e.getProjectId()}async getGCEProjectId(){try{return await s.project("project-id")}catch(e){return null}}getCredentials(e){if(!e)return this.getCredentialsAsync();this.getCredentialsAsync().then(t=>e(null,t),e)}async getCredentialsAsync(){let e=await this.getClient();if(e instanceof m.Impersonated)return{client_email:e.getTargetPrincipal()};if(e instanceof y.BaseExternalAccountClient){let t=e.getServiceAccountEmail();if(t)return{client_email:t,universe_domain:e.universeDomain}}if(this.jsonContent)return{client_email:this.jsonContent.client_email,private_key:this.jsonContent.private_key,universe_domain:this.jsonContent.universe_domain};if(await this._checkIsGCE()){let[e,t]=await Promise.all([s.instance("service-accounts/default/email"),this.getUniverseDomain()]);return{client_email:e,universe_domain:t}}throw Error(r.GoogleAuthExceptionMessages.NO_CREDENTIALS_FOUND)}async getClient(){if(this.cachedCredential)return this.cachedCredential;this.#w=this.#w||this.#R();try{let e=await this.#w;if(e instanceof v.GdchClient&&!e.apiAudience){let t=this.clientOptions,r=t.apiEndpoint||t.servicePath;if(r){let t=r.startsWith("http")?"":"https://",n=`${t}${r}`.replace(/\/+$/,""),i=e.createWithGdchAudience(n);return this.cachedCredential=i,i}}return e}finally{this.#w=null}}async #R(){if(this.jsonContent)return this._cacheClientFromJSON(this.jsonContent,this.clientOptions);if(this.keyFilename){let e=l.resolve(this.keyFilename),t=i.createReadStream(e);return await this.fromStreamAsync(t,this.clientOptions)}if(this.apiKey){let e=await this.fromAPIKey(this.apiKey,this.clientOptions);e.scopes=this.scopes;let{credential:t}=await this.#P(e);return t}{let{credential:e}=await this.getApplicationDefaultAsync(this.clientOptions);return e}}async getIdTokenClient(e){let t=await this.getClient();if(!("fetchIdToken"in t))throw Error("Cannot fetch ID token in this environment, use GCE or set the GOOGLE_APPLICATION_CREDENTIALS environment variable to a service account credentials JSON file.");return new p.IdTokenClient({targetAudience:e,idTokenProvider:t})}async getAccessToken(){let e=await this.getClient();return(await e.getAccessToken()).token}async getRequestHeaders(e){return(await this.getClient()).getRequestHeaders(e)}async authorizeRequest(e={}){let t=e.url,r=await this.getClient(),n=await r.getRequestHeaders(t);return e.headers=o.Gaxios.mergeHeaders(e.headers,n),e}async fetch(...e){return(await this.getClient()).fetch(...e)}async request(e){return(await this.getClient()).request(e)}getEnv(){return(0,d.getEnv)()}async sign(e,t){let r=await this.getClient(),n=await this.getUniverseDomain();if(t=t||`https://iamcredentials.${n}/v1/projects/-/serviceAccounts/`,r instanceof m.Impersonated)return(await r.sign(e)).signedBlob;let i=(0,u.createCrypto)();if(r instanceof h.JWT&&r.key)return await i.sign(r.key,e);let o=await this.getCredentials();if(!o.client_email)throw Error("Cannot sign data without `client_email`.");return this.signBlob(i,o.client_email,e,t)}async signBlob(e,t,r,n){let i=new URL(n+`${t}:signBlob`);return(await this.request({method:"POST",url:i.href,data:{payload:e.encodeBase64StringUtf8(r)},retry:!0,retryConfig:{httpMethodsToRetry:["POST"]}})).data.signedBlob}}},3994,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.IAMAuth=void 0,r.IAMAuth=class{selector;token;constructor(e,t){this.selector=e,this.token=t,this.selector=e,this.token=t}getRequestHeaders(){return{"x-goog-iam-authority-selector":this.selector,"x-goog-iam-authorization-token":this.token}}}},56777,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.DownscopedClient=r.EXPIRATION_TIME_OFFSET=r.MAX_ACCESS_BOUNDARY_RULES_COUNT=void 0;let n=e.r(57612),i=e.r(88947),o=e.r(11656),s=e.r(5332);r.MAX_ACCESS_BOUNDARY_RULES_COUNT=10,r.EXPIRATION_TIME_OFFSET=3e5;class a extends o.AuthClient{authClient;credentialAccessBoundary;cachedDownscopedAccessToken;stsCredential;constructor(e,t={accessBoundary:{accessBoundaryRules:[]}}){if(super(e instanceof o.AuthClient?{}:e),e instanceof o.AuthClient?(this.authClient=e,this.credentialAccessBoundary=t):(this.authClient=e.authClient,this.credentialAccessBoundary=e.credentialAccessBoundary),0===this.credentialAccessBoundary.accessBoundary.accessBoundaryRules.length)throw Error("At least one access boundary rule needs to be defined.");if(this.credentialAccessBoundary.accessBoundary.accessBoundaryRules.length>r.MAX_ACCESS_BOUNDARY_RULES_COUNT)throw Error(`The provided access boundary has more than ${r.MAX_ACCESS_BOUNDARY_RULES_COUNT} access boundary rules.`);for(const e of this.credentialAccessBoundary.accessBoundary.accessBoundaryRules)if(0===e.availablePermissions.length)throw Error("At least one permission should be defined in access boundary rules.");this.stsCredential=new s.StsCredentials({tokenExchangeEndpoint:`https://sts.${this.universeDomain}/v1/token`}),this.cachedDownscopedAccessToken=null}setCredentials(e){if(!e.expiry_date)throw Error("The access token expiry_date field is missing in the provided credentials.");super.setCredentials(e),this.cachedDownscopedAccessToken=e}async getAccessToken(){return(!this.cachedDownscopedAccessToken||this.isExpired(this.cachedDownscopedAccessToken))&&await this.refreshAccessTokenAsync(),{token:this.cachedDownscopedAccessToken.access_token,expirationTime:this.cachedDownscopedAccessToken.expiry_date,res:this.cachedDownscopedAccessToken.res}}async getRequestHeaders(){let e=await this.getAccessToken(),t=new Headers({authorization:`Bearer ${e.token}`});return this.addSharedMetadataHeaders(t)}request(e,t){if(!t)return this.requestAsync(e);this.requestAsync(e).then(e=>t(null,e),e=>t(e,e.response))}async requestAsync(e,t=!1){let r;try{let t=await this.getRequestHeaders();e.headers=n.Gaxios.mergeHeaders(e.headers),this.addUserProjectAndAuthHeaders(e.headers,t),r=await this.transporter.request(e)}catch(n){let r=n.response;if(r){let n=r.status,o=r.config.data instanceof i.Readable;if(!t&&(401===n||403===n)&&!o&&this.forceRefreshOnFailure)return await this.refreshAccessTokenAsync(),await this.requestAsync(e,!0)}throw n}return r}async refreshAccessTokenAsync(){let e=(await this.authClient.getAccessToken()).token,t=await this.stsCredential.exchangeToken({grantType:"urn:ietf:params:oauth:grant-type:token-exchange",requestedTokenType:"urn:ietf:params:oauth:token-type:access_token",subjectToken:e,subjectTokenType:"urn:ietf:params:oauth:token-type:access_token"},void 0,this.credentialAccessBoundary),r=this.authClient.credentials?.expiry_date||null,n=t.expires_in?new Date().getTime()+1e3*t.expires_in:r;return this.cachedDownscopedAccessToken={access_token:t.access_token,expiry_date:n,res:t.res},this.credentials={},Object.assign(this.credentials,this.cachedDownscopedAccessToken),delete this.credentials.res,this.emit("tokens",{refresh_token:null,expiry_date:this.cachedDownscopedAccessToken.expiry_date,access_token:this.cachedDownscopedAccessToken.access_token,token_type:"Bearer",id_token:null}),this.cachedDownscopedAccessToken}isExpired(e){let t=new Date().getTime();return!!e.expiry_date&&t>=e.expiry_date-this.eagerRefreshThresholdMillis}}r.DownscopedClient=a},53534,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.PassThroughClient=void 0;let n=e.r(11656);class i extends n.AuthClient{async request(e){return this.transporter.request(e)}async getAccessToken(){return{}}async getRequestHeaders(){return new Headers}}r.PassThroughClient=i},47334,(e,t,r)=>{"use strict";var n=e.e&&e.e.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=e.e&&e.e.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(r,"__esModule",{value:!0}),r.GoogleAuth=r.auth=r.GDCH_SERVICE_ACCOUNT_TYPE=r.GdchClient=r.PassThroughClient=r.ExternalAccountAuthorizedUserClient=r.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE=r.ExecutableError=r.PluggableAuthClient=r.DownscopedClient=r.BaseExternalAccountClient=r.ExternalAccountClient=r.IdentityPoolClient=r.AwsRequestSigner=r.AwsClient=r.UserRefreshClient=r.LoginTicket=r.ClientAuthentication=r.OAuth2Client=r.CodeChallengeMethod=r.Impersonated=r.JWT=r.JWTAccess=r.IdTokenClient=r.IAMAuth=r.GCPEnv=r.Compute=r.DEFAULT_UNIVERSE=r.AuthClient=r.gaxios=r.gcpMetadata=void 0;let o=e.r(64794);Object.defineProperty(r,"GoogleAuth",{enumerable:!0,get:function(){return o.GoogleAuth}}),r.gcpMetadata=e.r(82e3),r.gaxios=e.r(57612);var s=e.r(11656);Object.defineProperty(r,"AuthClient",{enumerable:!0,get:function(){return s.AuthClient}}),Object.defineProperty(r,"DEFAULT_UNIVERSE",{enumerable:!0,get:function(){return s.DEFAULT_UNIVERSE}});var a=e.r(70814);Object.defineProperty(r,"Compute",{enumerable:!0,get:function(){return a.Compute}});var l=e.r(80243);Object.defineProperty(r,"GCPEnv",{enumerable:!0,get:function(){return l.GCPEnv}});var u=e.r(3994);Object.defineProperty(r,"IAMAuth",{enumerable:!0,get:function(){return u.IAMAuth}});var c=e.r(80732);Object.defineProperty(r,"IdTokenClient",{enumerable:!0,get:function(){return c.IdTokenClient}});var p=e.r(10247);Object.defineProperty(r,"JWTAccess",{enumerable:!0,get:function(){return p.JWTAccess}});var d=e.r(24553);Object.defineProperty(r,"JWT",{enumerable:!0,get:function(){return d.JWT}});var h=e.r(36126);Object.defineProperty(r,"Impersonated",{enumerable:!0,get:function(){return h.Impersonated}});var f=e.r(701);Object.defineProperty(r,"CodeChallengeMethod",{enumerable:!0,get:function(){return f.CodeChallengeMethod}}),Object.defineProperty(r,"OAuth2Client",{enumerable:!0,get:function(){return f.OAuth2Client}}),Object.defineProperty(r,"ClientAuthentication",{enumerable:!0,get:function(){return f.ClientAuthentication}});var m=e.r(42602);Object.defineProperty(r,"LoginTicket",{enumerable:!0,get:function(){return m.LoginTicket}});var g=e.r(16260);Object.defineProperty(r,"UserRefreshClient",{enumerable:!0,get:function(){return g.UserRefreshClient}});var y=e.r(90220);Object.defineProperty(r,"AwsClient",{enumerable:!0,get:function(){return y.AwsClient}});var _=e.r(87573);Object.defineProperty(r,"AwsRequestSigner",{enumerable:!0,get:function(){return _.AwsRequestSigner}});var E=e.r(76868);Object.defineProperty(r,"IdentityPoolClient",{enumerable:!0,get:function(){return E.IdentityPoolClient}});var v=e.r(45037);Object.defineProperty(r,"ExternalAccountClient",{enumerable:!0,get:function(){return v.ExternalAccountClient}});var A=e.r(6560);Object.defineProperty(r,"BaseExternalAccountClient",{enumerable:!0,get:function(){return A.BaseExternalAccountClient}});var T=e.r(56777);Object.defineProperty(r,"DownscopedClient",{enumerable:!0,get:function(){return T.DownscopedClient}});var C=e.r(23238);Object.defineProperty(r,"PluggableAuthClient",{enumerable:!0,get:function(){return C.PluggableAuthClient}}),Object.defineProperty(r,"ExecutableError",{enumerable:!0,get:function(){return C.ExecutableError}});var S=e.r(74158);Object.defineProperty(r,"EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE",{enumerable:!0,get:function(){return S.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE}}),Object.defineProperty(r,"ExternalAccountAuthorizedUserClient",{enumerable:!0,get:function(){return S.ExternalAccountAuthorizedUserClient}});var b=e.r(53534);Object.defineProperty(r,"PassThroughClient",{enumerable:!0,get:function(){return b.PassThroughClient}});var I=e.r(87649);Object.defineProperty(r,"GdchClient",{enumerable:!0,get:function(){return I.GdchClient}}),Object.defineProperty(r,"GDCH_SERVICE_ACCOUNT_TYPE",{enumerable:!0,get:function(){return I.GDCH_SERVICE_ACCOUNT_TYPE}}),i(e.r(99365),r),r.auth=new o.GoogleAuth},74836,(e,t,r)=>{"use strict";let n=["nodebuffer","arraybuffer","fragments"],i="u">typeof Blob;i&&n.push("blob"),t.exports={BINARY_TYPES:n,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:i,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}},97970,(e,t,r)=>{"use strict";let{EMPTY_BUFFER:n}=e.r(74836),i=Buffer[Symbol.species];function o(e,t,r,n,i){for(let o=0;o<i;o++)r[n+o]=e[o]^t[3&o]}function s(e,t){for(let r=0;r<e.length;r++)e[r]^=t[3&r]}function a(e){let t;return(a.readOnly=!0,Buffer.isBuffer(e))?e:(e instanceof ArrayBuffer?t=new i(e):ArrayBuffer.isView(e)?t=new i(e.buffer,e.byteOffset,e.byteLength):(t=Buffer.from(e),a.readOnly=!1),t)}if(t.exports={concat:function(e,t){if(0===e.length)return n;if(1===e.length)return e[0];let r=Buffer.allocUnsafe(t),o=0;for(let t=0;t<e.length;t++){let n=e[t];r.set(n,o),o+=n.length}return o<t?new i(r.buffer,r.byteOffset,o):r},mask:o,toArrayBuffer:function(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)},toBuffer:a,unmask:s},!process.env.WS_NO_BUFFER_UTIL)try{let e=(()=>{let e=Error("Cannot find module 'bufferutil'");throw e.code="MODULE_NOT_FOUND",e})();t.exports.mask=function(t,r,n,i,s){s<48?o(t,r,n,i,s):e.mask(t,r,n,i,s)},t.exports.unmask=function(t,r){t.length<32?s(t,r):e.unmask(t,r)}}catch(e){}},62048,(e,t,r)=>{"use strict";let n=Symbol("kDone"),i=Symbol("kRun");t.exports=class{constructor(e){this[n]=()=>{this.pending--,this[i]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[i]()}[i](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[n])}}}},80295,(e,t,r)=>{"use strict";let n,i=e.r(6461),o=e.r(97970),s=e.r(62048),{kStatusCode:a}=e.r(74836),l=Buffer[Symbol.species],u=Buffer.from([0,0,255,255]),c=Symbol("permessage-deflate"),p=Symbol("total-length"),d=Symbol("callback"),h=Symbol("buffers"),f=Symbol("error");function m(e){this[h].push(e),this[p]+=e.length}function g(e){(this[p]+=e.length,this[c]._maxPayload<1||this[p]<=this[c]._maxPayload)?this[h].push(e):(this[f]=RangeError("Max payload size exceeded"),this[f].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[f][a]=1009,this.removeListener("data",g),this.reset())}function y(e){(this[c]._inflate=null,this[f])?this[d](this[f]):(e[a]=1007,this[d](e))}t.exports=class{constructor(e){this._options=e||{},this._threshold=void 0!==this._options.threshold?this._options.threshold:1024,this._maxPayload=0|this._options.maxPayload,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,n||(n=new s(void 0!==this._options.concurrencyLimit?this._options.concurrencyLimit:10))}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:null==this._options.clientMaxWindowBits&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[d];this._deflate.close(),this._deflate=null,e&&e(Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let t=this._options,r=e.find(e=>(!1!==t.serverNoContextTakeover||!e.server_no_context_takeover)&&(!e.server_max_window_bits||!1!==t.serverMaxWindowBits&&("number"!=typeof t.serverMaxWindowBits||!(t.serverMaxWindowBits>e.server_max_window_bits)))&&("number"!=typeof t.clientMaxWindowBits||!!e.client_max_window_bits));if(!r)throw Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(r.server_no_context_takeover=!0),t.clientNoContextTakeover&&(r.client_no_context_takeover=!0),"number"==typeof t.serverMaxWindowBits&&(r.server_max_window_bits=t.serverMaxWindowBits),"number"==typeof t.clientMaxWindowBits?r.client_max_window_bits=t.clientMaxWindowBits:(!0===r.client_max_window_bits||!1===t.clientMaxWindowBits)&&delete r.client_max_window_bits,r}acceptAsClient(e){let t=e[0];if(!1===this._options.clientNoContextTakeover&&t.client_no_context_takeover)throw Error('Unexpected parameter "client_no_context_takeover"');if(t.client_max_window_bits){if(!1===this._options.clientMaxWindowBits||"number"==typeof this._options.clientMaxWindowBits&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw Error('Unexpected or invalid parameter "client_max_window_bits"')}else"number"==typeof this._options.clientMaxWindowBits&&(t.client_max_window_bits=this._options.clientMaxWindowBits);return t}normalizeParams(e){return e.forEach(e=>{Object.keys(e).forEach(t=>{let r=e[t];if(r.length>1)throw Error(`Parameter "${t}" must have only a single value`);if(r=r[0],"client_max_window_bits"===t){if(!0!==r){let e=+r;if(!Number.isInteger(e)||e<8||e>15)throw TypeError(`Invalid value for parameter "${t}": ${r}`);r=e}else if(!this._isServer)throw TypeError(`Invalid value for parameter "${t}": ${r}`)}else if("server_max_window_bits"===t){let e=+r;if(!Number.isInteger(e)||e<8||e>15)throw TypeError(`Invalid value for parameter "${t}": ${r}`);r=e}else if("client_no_context_takeover"===t||"server_no_context_takeover"===t){if(!0!==r)throw TypeError(`Invalid value for parameter "${t}": ${r}`)}else throw Error(`Unknown parameter "${t}"`);e[t]=r})}),e}decompress(e,t,r){n.add(n=>{this._decompress(e,t,(e,t)=>{n(),r(e,t)})})}compress(e,t,r){n.add(n=>{this._compress(e,t,(e,t)=>{n(),r(e,t)})})}_decompress(e,t,r){let n=this._isServer?"client":"server";if(!this._inflate){let e=`${n}_max_window_bits`,t="number"!=typeof this.params[e]?i.Z_DEFAULT_WINDOWBITS:this.params[e];this._inflate=i.createInflateRaw({...this._options.zlibInflateOptions,windowBits:t}),this._inflate[c]=this,this._inflate[p]=0,this._inflate[h]=[],this._inflate.on("error",y),this._inflate.on("data",g)}this._inflate[d]=r,this._inflate.write(e),t&&this._inflate.write(u),this._inflate.flush(()=>{let e=this._inflate[f];if(e){this._inflate.close(),this._inflate=null,r(e);return}let i=o.concat(this._inflate[h],this._inflate[p]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[p]=0,this._inflate[h]=[],t&&this.params[`${n}_no_context_takeover`]&&this._inflate.reset()),r(null,i)})}_compress(e,t,r){let n=this._isServer?"server":"client";if(!this._deflate){let e=`${n}_max_window_bits`,t="number"!=typeof this.params[e]?i.Z_DEFAULT_WINDOWBITS:this.params[e];this._deflate=i.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:t}),this._deflate[p]=0,this._deflate[h]=[],this._deflate.on("data",m)}this._deflate[d]=r,this._deflate.write(e),this._deflate.flush(i.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let e=o.concat(this._deflate[h],this._deflate[p]);t&&(e=new l(e.buffer,e.byteOffset,e.length-4)),this._deflate[d]=null,this._deflate[p]=0,this._deflate[h]=[],t&&this.params[`${n}_no_context_takeover`]&&this._deflate.reset(),r(null,e)})}}},58739,(e,t,r)=>{"use strict";let{isUtf8:n}=e.r(874),{hasBlob:i}=e.r(74836);function o(e){let t=e.length,r=0;for(;r<t;)if((128&e[r])==0)r++;else if((224&e[r])==192){if(r+1===t||(192&e[r+1])!=128||(254&e[r])==192)return!1;r+=2}else if((240&e[r])==224){if(r+2>=t||(192&e[r+1])!=128||(192&e[r+2])!=128||224===e[r]&&(224&e[r+1])==128||237===e[r]&&(224&e[r+1])==160)return!1;r+=3}else{if((248&e[r])!=240||r+3>=t||(192&e[r+1])!=128||(192&e[r+2])!=128||(192&e[r+3])!=128||240===e[r]&&(240&e[r+1])==128||244===e[r]&&e[r+1]>143||e[r]>244)return!1;r+=4}return!0}if(t.exports={isBlob:function(e){return i&&"object"==typeof e&&"function"==typeof e.arrayBuffer&&"string"==typeof e.type&&"function"==typeof e.stream&&("Blob"===e[Symbol.toStringTag]||"File"===e[Symbol.toStringTag])},isValidStatusCode:function(e){return e>=1e3&&e<=1014&&1004!==e&&1005!==e&&1006!==e||e>=3e3&&e<=4999},isValidUTF8:o,tokenChars:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0]},n)t.exports.isValidUTF8=function(e){return e.length<24?o(e):n(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let e=(()=>{let e=Error("Cannot find module 'utf-8-validate'");throw e.code="MODULE_NOT_FOUND",e})();t.exports.isValidUTF8=function(t){return t.length<32?o(t):e(t)}}catch(e){}},29485,(e,t,r)=>{"use strict";let{Writable:n}=e.r(88947),i=e.r(80295),{BINARY_TYPES:o,EMPTY_BUFFER:s,kStatusCode:a,kWebSocket:l}=e.r(74836),{concat:u,toArrayBuffer:c,unmask:p}=e.r(97970),{isValidStatusCode:d,isValidUTF8:h}=e.r(58739),f=Buffer[Symbol.species];t.exports=class extends n{constructor(e={}){super(),this._allowSynchronousEvents=void 0===e.allowSynchronousEvents||e.allowSynchronousEvents,this._binaryType=e.binaryType||o[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxBufferedChunks=0|e.maxBufferedChunks,this._maxFragments=0|e.maxFragments,this._maxPayload=0|e.maxPayload,this._skipUTF8Validation=!!e.skipUTF8Validation,this[l]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write(e,t,r){return 8===this._opcode&&0==this._state?r():this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks?void r(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS")):void(this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(r))}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let t=this._buffers[0];return this._buffers[0]=new f(t.buffer,t.byteOffset+e,t.length-e),new f(t.buffer,t.byteOffset,e)}let t=Buffer.allocUnsafe(e);do{let r=this._buffers[0],n=t.length-e;e>=r.length?t.set(this._buffers.shift(),n):(t.set(new Uint8Array(r.buffer,r.byteOffset,e),n),this._buffers[0]=new f(r.buffer,r.byteOffset+e,r.length-e)),e-=r.length}while(e>0)return t}startLoop(e){this._loop=!0;do switch(this._state){case 0:this.getInfo(e);break;case 1:this.getPayloadLength16(e);break;case 2:this.getPayloadLength64(e);break;case 3:this.getMask();break;case 4:this.getData(e);break;case 5:case 6:this._loop=!1;return}while(this._loop)this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let t=this.consume(2);if((48&t[0])!=0)return void e(this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3"));let r=(64&t[0])==64;if(r&&!this._extensions[i.extensionName])return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"));if(this._fin=(128&t[0])==128,this._opcode=15&t[0],this._payloadLength=127&t[1],0===this._opcode){if(r)return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"));if(!this._fragmented)return void e(this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE"));this._opcode=this._fragmented}else if(1===this._opcode||2===this._opcode){if(this._fragmented)return void e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE"));this._compressed=r}else{if(!(this._opcode>7)||!(this._opcode<11))return void e(this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE"));if(!this._fin)return void e(this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN"));if(r)return void e(this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1"));if(this._payloadLength>125||8===this._opcode&&1===this._payloadLength)return void e(this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH"))}if(this._fin||this._fragmented||(this._fragmented=this._opcode),this._masked=(128&t[1])==128,this._isServer){if(!this._masked)return void e(this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK"))}else if(this._masked)return void e(this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK"));126===this._payloadLength?this._state=1:127===this._payloadLength?this._state=2:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let t=this.consume(8),r=t.readUInt32BE(0);r>2097151?e(this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH")):(this._payloadLength=0x100000000*r+t.readUInt32BE(4),this.haveLength(e))}haveLength(e){this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)?e(this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH")):this._masked?this._state=3:this._state=4}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=4}getData(e){let t=s;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}t=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!=0&&p(t,this._mask)}if(this._opcode>7)return void this.controlMessage(t,e);if(this._compressed){this._state=5,this.decompress(t,e);return}if(t.length){if(this._maxFragments>0&&this._fragments.length>=this._maxFragments)return void e(this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));this._messageLength=this._totalPayloadLength,this._fragments.push(t)}this.dataMessage(e)}decompress(e,t){this._extensions[i.extensionName].decompress(e,this._fin,(e,r)=>{if(e)return t(e);if(r.length){if(this._messageLength+=r.length,this._messageLength>this._maxPayload&&this._maxPayload>0)return void t(this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"));if(this._maxFragments>0&&this._fragments.length>=this._maxFragments)return void t(this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));this._fragments.push(r)}this.dataMessage(t),0===this._state&&this.startLoop(t)})}dataMessage(e){if(!this._fin){this._state=0;return}let t=this._messageLength,r=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],2===this._opcode){let n;n="nodebuffer"===this._binaryType?u(r,t):"arraybuffer"===this._binaryType?c(u(r,t)):"blob"===this._binaryType?new Blob(r):r,this._allowSynchronousEvents?(this.emit("message",n,!0),this._state=0):(this._state=6,setImmediate(()=>{this.emit("message",n,!0),this._state=0,this.startLoop(e)}))}else{let n=u(r,t);if(!this._skipUTF8Validation&&!h(n))return void e(this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8"));5===this._state||this._allowSynchronousEvents?(this.emit("message",n,!1),this._state=0):(this._state=6,setImmediate(()=>{this.emit("message",n,!1),this._state=0,this.startLoop(e)}))}}controlMessage(e,t){if(8===this._opcode){if(0===e.length)this._loop=!1,this.emit("conclude",1005,s),this.end();else{let r=e.readUInt16BE(0);if(!d(r))return void t(this.createError(RangeError,`invalid status code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE"));let n=new f(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!h(n))return void t(this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8"));this._loop=!1,this.emit("conclude",r,n),this.end()}this._state=0;return}this._allowSynchronousEvents?(this.emit(9===this._opcode?"ping":"pong",e),this._state=0):(this._state=6,setImmediate(()=>{this.emit(9===this._opcode?"ping":"pong",e),this._state=0,this.startLoop(t)}))}createError(e,t,r,n,i){this._loop=!1,this._errored=!0;let o=new e(r?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(o,this.createError),o.code=i,o[a]=n,o}}},16735,(e,t,r)=>{"use strict";let n,{Duplex:i}=e.r(88947),{randomFillSync:o}=e.r(54799),{types:{isUint8Array:s}}=e.r(24361),a=e.r(80295),{EMPTY_BUFFER:l,kWebSocket:u,NOOP:c}=e.r(74836),{isBlob:p,isValidStatusCode:d}=e.r(58739),{mask:h,toBuffer:f}=e.r(97970),m=Symbol("kByteLength"),g=Buffer.alloc(4),y=8192;class _{constructor(e,t,r){this._extensions=t||{},r&&(this._generateMask=r,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=0,this.onerror=c,this[u]=void 0}static frame(e,t){let r,i,s=!1,a=2,l=!1;t.mask&&(r=t.maskBuffer||g,t.generateMask?t.generateMask(r):(8192===y&&(void 0===n&&(n=Buffer.alloc(8192)),o(n,0,8192),y=0),r[0]=n[y++],r[1]=n[y++],r[2]=n[y++],r[3]=n[y++]),l=(r[0]|r[1]|r[2]|r[3])==0,a=6),"string"==typeof e?i=(!t.mask||l)&&void 0!==t[m]?t[m]:(e=Buffer.from(e)).length:(i=e.length,s=t.mask&&t.readOnly&&!l);let u=i;i>=65536?(a+=8,u=127):i>125&&(a+=2,u=126);let c=Buffer.allocUnsafe(s?i+a:a);return(c[0]=t.fin?128|t.opcode:t.opcode,t.rsv1&&(c[0]|=64),c[1]=u,126===u?c.writeUInt16BE(i,2):127===u&&(c[2]=c[3]=0,c.writeUIntBE(i,4,6)),t.mask)?(c[1]|=128,c[a-4]=r[0],c[a-3]=r[1],c[a-2]=r[2],c[a-1]=r[3],l)?[c,e]:s?(h(e,r,c,a,i),[c]):(h(e,r,e,0,i),[c,e]):[c,e]}close(e,t,r,n){let i;if(void 0===e)i=l;else if("number"==typeof e&&d(e))if(void 0!==t&&t.length){let r=Buffer.byteLength(t);if(r>123)throw RangeError("The message must not be greater than 123 bytes");if((i=Buffer.allocUnsafe(2+r)).writeUInt16BE(e,0),"string"==typeof t)i.write(t,2);else if(s(t))i.set(t,2);else throw TypeError("Second argument must be a string or a Uint8Array")}else(i=Buffer.allocUnsafe(2)).writeUInt16BE(e,0);else throw TypeError("First argument must be a valid error code number");let o={[m]:i.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};0!==this._state?this.enqueue([this.dispatch,i,!1,o,n]):this.sendFrame(_.frame(i,o),n)}ping(e,t,r){let n,i;if("string"==typeof e?(n=Buffer.byteLength(e),i=!1):p(e)?(n=e.size,i=!1):(n=(e=f(e)).length,i=f.readOnly),n>125)throw RangeError("The data size must not be greater than 125 bytes");let o={[m]:n,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:i,rsv1:!1};p(e)?0!==this._state?this.enqueue([this.getBlobData,e,!1,o,r]):this.getBlobData(e,!1,o,r):0!==this._state?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(_.frame(e,o),r)}pong(e,t,r){let n,i;if("string"==typeof e?(n=Buffer.byteLength(e),i=!1):p(e)?(n=e.size,i=!1):(n=(e=f(e)).length,i=f.readOnly),n>125)throw RangeError("The data size must not be greater than 125 bytes");let o={[m]:n,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:i,rsv1:!1};p(e)?0!==this._state?this.enqueue([this.getBlobData,e,!1,o,r]):this.getBlobData(e,!1,o,r):0!==this._state?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(_.frame(e,o),r)}send(e,t,r){let n,i,o=this._extensions[a.extensionName],s=t.binary?2:1,l=t.compress;"string"==typeof e?(n=Buffer.byteLength(e),i=!1):p(e)?(n=e.size,i=!1):(n=(e=f(e)).length,i=f.readOnly),this._firstFragment?(this._firstFragment=!1,l&&o&&o.params[o._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(l=n>=o._threshold),this._compress=l):(l=!1,s=0),t.fin&&(this._firstFragment=!0);let u={[m]:n,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:i,rsv1:l};p(e)?0!==this._state?this.enqueue([this.getBlobData,e,this._compress,u,r]):this.getBlobData(e,this._compress,u,r):0!==this._state?this.enqueue([this.dispatch,e,this._compress,u,r]):this.dispatch(e,this._compress,u,r)}getBlobData(e,t,r,n){this._bufferedBytes+=r[m],this._state=2,e.arrayBuffer().then(e=>{if(this._socket.destroyed){let e=Error("The socket was closed while the blob was being read");process.nextTick(E,this,e,n);return}this._bufferedBytes-=r[m];let i=f(e);t?this.dispatch(i,t,r,n):(this._state=0,this.sendFrame(_.frame(i,r),n),this.dequeue())}).catch(e=>{process.nextTick(v,this,e,n)})}dispatch(e,t,r,n){if(!t)return void this.sendFrame(_.frame(e,r),n);let i=this._extensions[a.extensionName];this._bufferedBytes+=r[m],this._state=1,i.compress(e,r.fin,(e,t)=>{this._socket.destroyed?E(this,Error("The socket was closed while data was being compressed"),n):(this._bufferedBytes-=r[m],this._state=0,r.readOnly=!1,this.sendFrame(_.frame(t,r),n),this.dequeue())})}dequeue(){for(;0===this._state&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][m],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][m],this._queue.push(e)}sendFrame(e,t){2===e.length?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}}function E(e,t,r){"function"==typeof r&&r(t);for(let r=0;r<e._queue.length;r++){let n=e._queue[r],i=n[n.length-1];"function"==typeof i&&i(t)}}function v(e,t,r){E(e,t,r),e.onerror(t)}t.exports=_},70494,(e,t,r)=>{"use strict";let{kForOnEventAttribute:n,kListener:i}=e.r(74836),o=Symbol("kCode"),s=Symbol("kData"),a=Symbol("kError"),l=Symbol("kMessage"),u=Symbol("kReason"),c=Symbol("kTarget"),p=Symbol("kType"),d=Symbol("kWasClean");class h{constructor(e){this[c]=null,this[p]=e}get target(){return this[c]}get type(){return this[p]}}Object.defineProperty(h.prototype,"target",{enumerable:!0}),Object.defineProperty(h.prototype,"type",{enumerable:!0});class f extends h{constructor(e,t={}){super(e),this[o]=void 0===t.code?0:t.code,this[u]=void 0===t.reason?"":t.reason,this[d]=void 0!==t.wasClean&&t.wasClean}get code(){return this[o]}get reason(){return this[u]}get wasClean(){return this[d]}}Object.defineProperty(f.prototype,"code",{enumerable:!0}),Object.defineProperty(f.prototype,"reason",{enumerable:!0}),Object.defineProperty(f.prototype,"wasClean",{enumerable:!0});class m extends h{constructor(e,t={}){super(e),this[a]=void 0===t.error?null:t.error,this[l]=void 0===t.message?"":t.message}get error(){return this[a]}get message(){return this[l]}}Object.defineProperty(m.prototype,"error",{enumerable:!0}),Object.defineProperty(m.prototype,"message",{enumerable:!0});class g extends h{constructor(e,t={}){super(e),this[s]=void 0===t.data?null:t.data}get data(){return this[s]}}function y(e,t,r){"object"==typeof e&&e.handleEvent?e.handleEvent.call(e,r):e.call(t,r)}Object.defineProperty(g.prototype,"data",{enumerable:!0}),t.exports={CloseEvent:f,ErrorEvent:m,Event:h,EventTarget:{addEventListener(e,t,r={}){let o;for(let o of this.listeners(e))if(!r[n]&&o[i]===t&&!o[n])return;if("message"===e)o=function(e,r){let n=new g("message",{data:r?e:e.toString()});n[c]=this,y(t,this,n)};else if("close"===e)o=function(e,r){let n=new f("close",{code:e,reason:r.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});n[c]=this,y(t,this,n)};else if("error"===e)o=function(e){let r=new m("error",{error:e,message:e.message});r[c]=this,y(t,this,r)};else{if("open"!==e)return;o=function(){let e=new h("open");e[c]=this,y(t,this,e)}}o[n]=!!r[n],o[i]=t,r.once?this.once(e,o):this.on(e,o)},removeEventListener(e,t){for(let r of this.listeners(e))if(r[i]===t&&!r[n]){this.removeListener(e,r);break}}},MessageEvent:g}},96903,(e,t,r)=>{"use strict";let{tokenChars:n}=e.r(58739);function i(e,t,r){void 0===e[t]?e[t]=[r]:e[t].push(r)}t.exports={format:function(e){return Object.keys(e).map(t=>{let r=e[t];return Array.isArray(r)||(r=[r]),r.map(e=>[t].concat(Object.keys(e).map(t=>{let r=e[t];return Array.isArray(r)||(r=[r]),r.map(e=>!0===e?t:`${t}=${e}`).join("; ")})).join("; ")).join(", ")}).join(", ")},parse:function(e){let t,r,o=Object.create(null),s=Object.create(null),a=!1,l=!1,u=!1,c=-1,p=-1,d=-1,h=0;for(;h<e.length;h++)if(p=e.charCodeAt(h),void 0===t)if(-1===d&&1===n[p])-1===c&&(c=h);else if(0!==h&&(32===p||9===p))-1===d&&-1!==c&&(d=h);else if(59===p||44===p){if(-1===c)throw SyntaxError(`Unexpected character at index ${h}`);-1===d&&(d=h);let r=e.slice(c,d);44===p?(i(o,r,s),s=Object.create(null)):t=r,c=d=-1}else throw SyntaxError(`Unexpected character at index ${h}`);else if(void 0===r)if(-1===d&&1===n[p])-1===c&&(c=h);else if(32===p||9===p)-1===d&&-1!==c&&(d=h);else if(59===p||44===p){if(-1===c)throw SyntaxError(`Unexpected character at index ${h}`);-1===d&&(d=h),i(s,e.slice(c,d),!0),44===p&&(i(o,t,s),s=Object.create(null),t=void 0),c=d=-1}else if(61===p&&-1!==c&&-1===d)r=e.slice(c,h),c=d=-1;else throw SyntaxError(`Unexpected character at index ${h}`);else if(l){if(1!==n[p])throw SyntaxError(`Unexpected character at index ${h}`);-1===c?c=h:a||(a=!0),l=!1}else if(u)if(1===n[p])-1===c&&(c=h);else if(34===p&&-1!==c)u=!1,d=h;else if(92===p)l=!0;else throw SyntaxError(`Unexpected character at index ${h}`);else if(34===p&&61===e.charCodeAt(h-1))u=!0;else if(-1===d&&1===n[p])-1===c&&(c=h);else if(-1!==c&&(32===p||9===p))-1===d&&(d=h);else if(59===p||44===p){if(-1===c)throw SyntaxError(`Unexpected character at index ${h}`);-1===d&&(d=h);let n=e.slice(c,d);a&&(n=n.replace(/\\/g,""),a=!1),i(s,r,n),44===p&&(i(o,t,s),s=Object.create(null),t=void 0),r=void 0,c=d=-1}else throw SyntaxError(`Unexpected character at index ${h}`);if(-1===c||u||32===p||9===p)throw SyntaxError("Unexpected end of input");-1===d&&(d=h);let f=e.slice(c,d);return void 0===t?i(o,f,s):(void 0===r?i(s,f,!0):a?i(s,r,f.replace(/\\/g,"")):i(s,r,f),i(o,t,s)),o}}},35065,(e,t,r)=>{"use strict";let n=e.r(27699),i=e.r(24836),o=e.r(21517),s=e.r(4446),a=e.r(55004),{randomBytes:l,createHash:u}=e.r(54799),{Duplex:c,Readable:p}=e.r(88947),{URL:d}=e.r(92509),h=e.r(80295),f=e.r(29485),m=e.r(16735),{isBlob:g}=e.r(58739),{BINARY_TYPES:y,CLOSE_TIMEOUT:_,EMPTY_BUFFER:E,GUID:v,kForOnEventAttribute:A,kListener:T,kStatusCode:C,kWebSocket:S,NOOP:b}=e.r(74836),{EventTarget:{addEventListener:I,removeEventListener:O}}=e.r(70494),{format:w,parse:P}=e.r(96903),{toBuffer:R}=e.r(97970),N=Symbol("kAborted"),k=[8,13],D=["CONNECTING","OPEN","CLOSING","CLOSED"],x=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class U extends n{constructor(e,t,r){super(),this._binaryType=y[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=E,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=U.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,null!==e?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,void 0===t?t=[]:Array.isArray(t)||("object"==typeof t&&null!==t?(r=t,t=[]):t=[t]),function e(t,r,n,s){let a,c,p,f,m={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:_,protocolVersion:k[1],maxBufferedChunks:1048576,maxFragments:131072,maxPayload:0x6400000,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...s,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=m.autoPong,t._closeTimeout=m.closeTimeout,!k.includes(m.protocolVersion))throw RangeError(`Unsupported protocol version: ${m.protocolVersion} (supported versions: ${k.join(", ")})`);if(r instanceof d)a=r;else try{a=new d(r)}catch{throw SyntaxError(`Invalid URL: ${r}`)}"http:"===a.protocol?a.protocol="ws:":"https:"===a.protocol&&(a.protocol="wss:"),t._url=a.href;let g="wss:"===a.protocol,y="ws+unix:"===a.protocol;if("ws:"===a.protocol||g||y?y&&!a.pathname?c="The URL's pathname is empty":a.hash&&(c="The URL contains a fragment identifier"):c='The URL\'s protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"',c){let e=SyntaxError(c);if(0!==t._redirects)return void G(t,e);throw e}let E=g?443:80,A=l(16).toString("base64"),T=g?i.request:o.request,C=new Set;if(m.createConnection=m.createConnection||(g?j:M),m.defaultPort=m.defaultPort||E,m.port=a.port||E,m.host=a.hostname.startsWith("[")?a.hostname.slice(1,-1):a.hostname,m.headers={...m.headers,"Sec-WebSocket-Version":m.protocolVersion,"Sec-WebSocket-Key":A,Connection:"Upgrade",Upgrade:"websocket"},m.path=a.pathname+a.search,m.timeout=m.handshakeTimeout,m.perMessageDeflate&&(p=new h({...m.perMessageDeflate,isServer:!1,maxPayload:m.maxPayload}),m.headers["Sec-WebSocket-Extensions"]=w({[h.extensionName]:p.offer()})),n.length){for(let e of n){if("string"!=typeof e||!x.test(e)||C.has(e))throw SyntaxError("An invalid or duplicated subprotocol was specified");C.add(e)}m.headers["Sec-WebSocket-Protocol"]=n.join(",")}if(m.origin&&(m.protocolVersion<13?m.headers["Sec-WebSocket-Origin"]=m.origin:m.headers.Origin=m.origin),(a.username||a.password)&&(m.auth=`${a.username}:${a.password}`),y){let e=m.path.split(":");m.socketPath=e[0],m.path=e[1]}if(m.followRedirects){if(0===t._redirects){t._originalIpc=y,t._originalSecure=g,t._originalHostOrSocketPath=y?m.socketPath:a.host;let e=s&&s.headers;if(s={...s,headers:{}},e)for(let[t,r]of Object.entries(e))s.headers[t.toLowerCase()]=r}else if(0===t.listenerCount("redirect")){let e=y?!!t._originalIpc&&m.socketPath===t._originalHostOrSocketPath:!t._originalIpc&&a.host===t._originalHostOrSocketPath;e&&(!t._originalSecure||g)||(delete m.headers.authorization,delete m.headers.cookie,e||delete m.headers.host,m.auth=void 0)}m.auth&&!s.headers.authorization&&(s.headers.authorization="Basic "+Buffer.from(m.auth).toString("base64")),f=t._req=T(m),t._redirects&&t.emit("redirect",t.url,f)}else f=t._req=T(m);m.timeout&&f.on("timeout",()=>{L(t,f,"Opening handshake has timed out")}),f.on("error",e=>{null===f||f[N]||(f=t._req=null,G(t,e))}),f.on("response",i=>{let o=i.headers.location,a=i.statusCode;if(o&&m.followRedirects&&a>=300&&a<400){let i;if(++t._redirects>m.maxRedirects)return void L(t,f,"Maximum redirects exceeded");f.abort();try{i=new d(o,r)}catch(e){G(t,SyntaxError(`Invalid URL: ${o}`));return}e(t,i,n,s)}else t.emit("unexpected-response",f,i)||L(t,f,`Unexpected server response: ${i.statusCode}`)}),f.on("upgrade",(e,r,n)=>{let i;if(t.emit("upgrade",e),t.readyState!==U.CONNECTING)return;f=t._req=null;let o=e.headers.upgrade;if(void 0===o||"websocket"!==o.toLowerCase())return void L(t,r,"Invalid Upgrade header");let s=u("sha1").update(A+v).digest("base64");if(e.headers["sec-websocket-accept"]!==s)return void L(t,r,"Invalid Sec-WebSocket-Accept header");let a=e.headers["sec-websocket-protocol"];if(void 0!==a?C.size?C.has(a)||(i="Server sent an invalid subprotocol"):i="Server sent a subprotocol but none was requested":C.size&&(i="Server sent no subprotocol"),i)return void L(t,r,i);a&&(t._protocol=a);let l=e.headers["sec-websocket-extensions"];if(void 0!==l){let e;if(!p)return void L(t,r,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");try{e=P(l)}catch(e){L(t,r,"Invalid Sec-WebSocket-Extensions header");return}let n=Object.keys(e);if(1!==n.length||n[0]!==h.extensionName)return void L(t,r,"Server indicated an extension that was not requested");try{p.accept(e[h.extensionName])}catch(e){L(t,r,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[h.extensionName]=p}t.setSocket(r,n,{allowSynchronousEvents:m.allowSynchronousEvents,generateMask:m.generateMask,maxBufferedChunks:m.maxBufferedChunks,maxFragments:m.maxFragments,maxPayload:m.maxPayload,skipUTF8Validation:m.skipUTF8Validation})}),m.finishRequest?m.finishRequest(f,t):f.end()}(this,e,t,r)):(this._autoPong=r.autoPong,this._closeTimeout=r.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){y.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,t,r){let n=new f({allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:r.maxBufferedChunks,maxFragments:r.maxFragments,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation}),i=new m(e,this._extensions,r.generateMask);this._receiver=n,this._sender=i,this._socket=e,n[S]=this,i[S]=this,e[S]=this,n.on("conclude",q),n.on("drain",H),n.on("error",B),n.on("message",$),n.on("ping",J),n.on("pong",W),i.onerror=Y,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",z),e.on("data",Q),e.on("end",Z),e.on("error",ee),this._readyState=U.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=U.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[h.extensionName]&&this._extensions[h.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=U.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==U.CLOSED){if(this.readyState===U.CONNECTING)return void L(this,this._req,"WebSocket was closed before the connection was established");if(this.readyState===U.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=U.CLOSING,this._sender.close(e,t,!this._isServer,e=>{!e&&(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),X(this)}}pause(){this.readyState!==U.CONNECTING&&this.readyState!==U.CLOSED&&(this._paused=!0,this._socket.pause())}ping(e,t,r){if(this.readyState===U.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");("function"==typeof e?(r=e,e=t=void 0):"function"==typeof t&&(r=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState!==U.OPEN)?F(this,e,r):(void 0===t&&(t=!this._isServer),this._sender.ping(e||E,t,r))}pong(e,t,r){if(this.readyState===U.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");("function"==typeof e?(r=e,e=t=void 0):"function"==typeof t&&(r=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState!==U.OPEN)?F(this,e,r):(void 0===t&&(t=!this._isServer),this._sender.pong(e||E,t,r))}resume(){this.readyState!==U.CONNECTING&&this.readyState!==U.CLOSED&&(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,t,r){if(this.readyState===U.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if("function"==typeof t&&(r=t,t={}),"number"==typeof e&&(e=e.toString()),this.readyState!==U.OPEN)return void F(this,e,r);let n={binary:"string"!=typeof e,mask:!this._isServer,compress:!0,fin:!0,...t};this._extensions[h.extensionName]||(n.compress=!1),this._sender.send(e||E,n,r)}terminate(){if(this.readyState!==U.CLOSED){if(this.readyState===U.CONNECTING)return void L(this,this._req,"WebSocket was closed before the connection was established");this._socket&&(this._readyState=U.CLOSING,this._socket.destroy())}}}function G(e,t){e._readyState=U.CLOSING,e._errorEmitted=!0,e.emit("error",t),e.emitClose()}function M(e){return e.path=e.socketPath,s.connect(e)}function j(e){return e.path=void 0,e.servername||""===e.servername||(e.servername=s.isIP(e.host)?"":e.host),a.connect(e)}function L(e,t,r){e._readyState=U.CLOSING;let n=Error(r);Error.captureStackTrace(n,L),t.setHeader?(t[N]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(G,e,n)):(t.destroy(n),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}function F(e,t,r){if(t){let r=g(t)?t.size:R(t).length;e._socket?e._sender._bufferedBytes+=r:e._bufferedAmount+=r}if(r){let t=Error(`WebSocket is not open: readyState ${e.readyState} (${D[e.readyState]})`);process.nextTick(r,t)}}function q(e,t){let r=this[S];r._closeFrameReceived=!0,r._closeMessage=t,r._closeCode=e,void 0!==r._socket[S]&&(r._socket.removeListener("data",Q),process.nextTick(K,r._socket),1005===e?r.close():r.close(e,t))}function H(){let e=this[S];e.isPaused||e._socket.resume()}function B(e){let t=this[S];void 0!==t._socket[S]&&(t._socket.removeListener("data",Q),process.nextTick(K,t._socket),t.close(e[C])),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e))}function V(){this[S].emitClose()}function $(e,t){this[S].emit("message",e,t)}function J(e){let t=this[S];t._autoPong&&t.pong(e,!this._isServer,b),t.emit("ping",e)}function W(e){this[S].emit("pong",e)}function K(e){e.resume()}function Y(e){let t=this[S];t.readyState!==U.CLOSED&&(t.readyState===U.OPEN&&(t._readyState=U.CLOSING,X(t)),this._socket.end(),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e)))}function X(e){e._closeTimer=setTimeout(e._socket.destroy.bind(e._socket),e._closeTimeout)}function z(){let e=this[S];if(this.removeListener("close",z),this.removeListener("data",Q),this.removeListener("end",Z),e._readyState=U.CLOSING,!this._readableState.endEmitted&&!e._closeFrameReceived&&!e._receiver._writableState.errorEmitted&&0!==this._readableState.length){let t=this.read(this._readableState.length);e._receiver.write(t)}e._receiver.end(),this[S]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",V),e._receiver.on("finish",V))}function Q(e){this[S]._receiver.write(e)||this.pause()}function Z(){let e=this[S];e._readyState=U.CLOSING,e._receiver.end(),this.end()}function ee(){let e=this[S];this.removeListener("error",ee),this.on("error",b),e&&(e._readyState=U.CLOSING,this.destroy())}Object.defineProperty(U,"CONNECTING",{enumerable:!0,value:D.indexOf("CONNECTING")}),Object.defineProperty(U.prototype,"CONNECTING",{enumerable:!0,value:D.indexOf("CONNECTING")}),Object.defineProperty(U,"OPEN",{enumerable:!0,value:D.indexOf("OPEN")}),Object.defineProperty(U.prototype,"OPEN",{enumerable:!0,value:D.indexOf("OPEN")}),Object.defineProperty(U,"CLOSING",{enumerable:!0,value:D.indexOf("CLOSING")}),Object.defineProperty(U.prototype,"CLOSING",{enumerable:!0,value:D.indexOf("CLOSING")}),Object.defineProperty(U,"CLOSED",{enumerable:!0,value:D.indexOf("CLOSED")}),Object.defineProperty(U.prototype,"CLOSED",{enumerable:!0,value:D.indexOf("CLOSED")}),["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(e=>{Object.defineProperty(U.prototype,e,{enumerable:!0})}),["open","error","close","message"].forEach(e=>{Object.defineProperty(U.prototype,`on${e}`,{enumerable:!0,get(){for(let t of this.listeners(e))if(t[A])return t[T];return null},set(t){for(let t of this.listeners(e))if(t[A]){this.removeListener(e,t);break}"function"==typeof t&&this.addEventListener(e,t,{[A]:!0})}})}),U.prototype.addEventListener=I,U.prototype.removeEventListener=O,t.exports=U},21365,(e,t,r)=>{"use strict";e.r(35065);let{Duplex:n}=e.r(88947);function i(e){e.emit("close")}function o(){!this.destroyed&&this._writableState.finished&&this.destroy()}function s(e){this.removeListener("error",s),this.destroy(),0===this.listenerCount("error")&&this.emit("error",e)}t.exports=function(e,t){let r=!0,a=new n({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",function(t,r){let n=!r&&a._readableState.objectMode?t.toString():t;a.push(n)||e.pause()}),e.once("error",function(e){a.destroyed||(r=!1,a.destroy(e))}),e.once("close",function(){a.destroyed||a.push(null)}),a._destroy=function(t,n){if(e.readyState===e.CLOSED){n(t),process.nextTick(i,a);return}let o=!1;e.once("error",function(e){o=!0,n(e)}),e.once("close",function(){o||n(t),process.nextTick(i,a)}),r&&e.terminate()},a._final=function(t){e.readyState===e.CONNECTING?e.once("open",function(){a._final(t)}):null!==e._socket&&(e._socket._writableState.finished?(t(),a._readableState.endEmitted&&a.destroy()):(e._socket.once("finish",function(){t()}),e.close()))},a._read=function(){e.isPaused&&e.resume()},a._write=function(t,r,n){e.readyState===e.CONNECTING?e.once("open",function(){a._write(t,r,n)}):e.send(t,n)},a.on("end",o),a.on("error",s),a}},42977,(e,t,r)=>{"use strict";let{tokenChars:n}=e.r(58739);t.exports={parse:function(e){let t=new Set,r=-1,i=-1,o=0;for(;o<e.length;o++){let s=e.charCodeAt(o);if(-1===i&&1===n[s])-1===r&&(r=o);else if(0!==o&&(32===s||9===s))-1===i&&-1!==r&&(i=o);else if(44===s){if(-1===r)throw SyntaxError(`Unexpected character at index ${o}`);-1===i&&(i=o);let n=e.slice(r,i);if(t.has(n))throw SyntaxError(`The "${n}" subprotocol is duplicated`);t.add(n),r=i=-1}else throw SyntaxError(`Unexpected character at index ${o}`)}if(-1===r||-1!==i)throw SyntaxError("Unexpected end of input");let s=e.slice(r,o);if(t.has(s))throw SyntaxError(`The "${s}" subprotocol is duplicated`);return t.add(s),t}}},17198,(e,t,r)=>{"use strict";let n=e.r(27699),i=e.r(21517),{Duplex:o}=e.r(88947),{createHash:s}=e.r(54799),a=e.r(96903),l=e.r(80295),u=e.r(42977),c=e.r(35065),{CLOSE_TIMEOUT:p,GUID:d,kWebSocket:h}=e.r(74836),f=/^[+/0-9A-Za-z]{22}==$/;function m(e){e._state=2,e.emit("close")}function g(){this.destroy()}function y(e,t,r,n){r=r||i.STATUS_CODES[t],n={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(r),...n},e.once("finish",e.destroy),e.end(`HTTP/1.1 ${t} ${i.STATUS_CODES[t]}\r
|
|
14
|
-
`+Object.keys(n).map(e=>`${e}: ${n[e]}`).join("\r\n")+"\r\n\r\n"+r)}function _(e,t,r,n,i,o){if(e.listenerCount("wsClientError")){let n=Error(i);Error.captureStackTrace(n,_),e.emit("wsClientError",n,r,t)}else y(r,n,i,o)}t.exports=class extends n{constructor(e,t){if(super(),null==(e={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:1048576,maxFragments:131072,maxPayload:0x6400000,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:p,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:c,...e}).port&&!e.server&&!e.noServer||null!=e.port&&(e.server||e.noServer)||e.server&&e.noServer)throw TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(null!=e.port?(this._server=i.createServer((e,t)=>{let r=i.STATUS_CODES[426];t.writeHead(426,{"Content-Length":r.length,"Content-Type":"text/plain"}),t.end(r)}),this._server.listen(e.port,e.host,e.backlog,t)):e.server&&(this._server=e.server),this._server){const e=this.emit.bind(this,"connection");this._removeListeners=function(e,t){for(let r of Object.keys(t))e.on(r,t[r]);return function(){for(let r of Object.keys(t))e.removeListener(r,t[r])}}(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(t,r,n)=>{this.handleUpgrade(t,r,n,e)}})}!0===e.perMessageDeflate&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=0}address(){if(this.options.noServer)throw Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(2===this._state){e&&this.once("close",()=>{e(Error("The server is not running"))}),process.nextTick(m,this);return}if(e&&this.once("close",e),1!==this._state)if(this._state=1,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients&&this.clients.size?this._shouldEmitClose=!0:process.nextTick(m,this);else{let e=this._server;this._removeListeners(),this._removeListeners=this._server=null,e.close(()=>{m(this)})}}shouldHandle(e){if(this.options.path){let t=e.url.indexOf("?");if((-1!==t?e.url.slice(0,t):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,t,r,n){t.on("error",g);let i=e.headers["sec-websocket-key"],o=e.headers.upgrade,s=+e.headers["sec-websocket-version"];if("GET"!==e.method)return void _(this,e,t,405,"Invalid HTTP method");if(void 0===o||"websocket"!==o.toLowerCase())return void _(this,e,t,400,"Invalid Upgrade header");if(void 0===i||!f.test(i))return void _(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header");if(13!==s&&8!==s)return void _(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});if(!this.shouldHandle(e))return void y(t,400);let c=e.headers["sec-websocket-protocol"],p=new Set;if(void 0!==c)try{p=u.parse(c)}catch(r){_(this,e,t,400,"Invalid Sec-WebSocket-Protocol header");return}let d=e.headers["sec-websocket-extensions"],h={};if(this.options.perMessageDeflate&&void 0!==d){let r=new l({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let e=a.parse(d);e[l.extensionName]&&(r.accept(e[l.extensionName]),h[l.extensionName]=r)}catch(r){_(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let o={origin:e.headers[`${8===s?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(2===this.options.verifyClient.length)return void this.options.verifyClient(o,(o,s,a,l)=>{if(!o)return y(t,s||401,a,l);this.completeUpgrade(h,i,p,e,t,r,n)});if(!this.options.verifyClient(o))return y(t,401)}this.completeUpgrade(h,i,p,e,t,r,n)}completeUpgrade(e,t,r,n,i,o,u){if(!i.readable||!i.writable)return i.destroy();if(i[h])throw Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return y(i,503);let c=s("sha1").update(t+d).digest("base64"),p=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${c}`],f=new this.options.WebSocket(null,void 0,this.options);if(r.size){let e=this.options.handleProtocols?this.options.handleProtocols(r,n):r.values().next().value;e&&(p.push(`Sec-WebSocket-Protocol: ${e}`),f._protocol=e)}if(e[l.extensionName]){let t=e[l.extensionName].params,r=a.format({[l.extensionName]:[t]});p.push(`Sec-WebSocket-Extensions: ${r}`),f._extensions=e}this.emit("headers",p,n),i.write(p.concat("\r\n").join("\r\n")),i.removeListener("error",g),f.setSocket(i,o,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxBufferedChunks:this.options.maxBufferedChunks,maxFragments:this.options.maxFragments,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(f),f.on("close",()=>{this.clients.delete(f),this._shouldEmitClose&&!this.clients.size&&process.nextTick(m,this)})),u(f,n)}}},34731,e=>{"use strict";let t,r,n;var i,o,s,a,l,u,c,p,d,h,f,m,g,y,_,E,v,A,T,C,S,b,I,O,w,P,R,N,k,D,x,U,G,M,j,L,F,q,H,B,V,$,J,W,K,Y,X,z,Q,Z,ee,et,er,en,ei,eo,es,ea,el,eu,ec,ep,ed,eh,ef,em,eg,ey,e_,eE,ev,eA,eT,eC,eS,eb,eI,eO,ew,eP,eR,eN,ek,eD,ex,eU,eG,eM,ej,eL,eF,eq,eH,eB,eV,e$,eJ,eW,eK,eY,eX,ez,eQ,eZ,e0,e1,e2,e4,e3,e5,e6,e8,e7,e9,te,tt,tr,tn,ti,to,ts,ta,tl,tu,tc,tp,td,th,tf,tm,tg,ty,t_,tE,tv,tA,tT,tC,tS,tb,tI,tO,tw,tP,tR,tN,tk,tD,tx=e.i(36850),tU=e.i(47334),tG=e.i(22734),tM=e.i(24868),tj=e.i(81111),tL=e.i(88646);e.i(21365),e.i(96903),e.i(80295),e.i(29485),e.i(16735),e.i(42977);var tF=e.i(35065);e.i(17198),tF.default;var tq=e.i(14747);class tH{}function tB(e,t){return e.replace(/\{([^}]+)\}/g,(e,r)=>{if(Object.prototype.hasOwnProperty.call(t,r)){let e=t[r];return null!=e?String(e):""}throw Error(`Key '${r}' not found in valueMap.`)})}function tV(e,t,r){for(let n=0;n<t.length-1;n++){let i=t[n];if(i.endsWith("[]")){let o=i.slice(0,-2);if(!(o in e))if(Array.isArray(r))e[o]=Array.from({length:r.length},()=>({}));else throw Error(`Value must be a list given an array path ${i}`);if(Array.isArray(e[o])){let i=e[o];if(Array.isArray(r))for(let e=0;e<i.length;e++)tV(i[e],t.slice(n+1),r[e]);else for(let e of i)tV(e,t.slice(n+1),r)}return}if(i.endsWith("[0]")){let o=i.slice(0,-3);o in e||(e[o]=[{}]),tV(e[o][0],t.slice(n+1),r);return}e[i]&&"object"==typeof e[i]||(e[i]={}),e=e[i]}let n=t[t.length-1],i=e[n];if(void 0!==i){if(!r||"object"==typeof r&&0===Object.keys(r).length||r===i)return;if("object"==typeof i&&"object"==typeof r&&null!==i&&null!==r)Object.assign(i,r);else throw Error(`Cannot set value for an existing key. Key: ${n}`)}else"_self"!==n||"object"!=typeof r||null===r||Array.isArray(r)?e[n]=r:Object.assign(e,r)}function t$(e,t,r){try{if(1===t.length&&"_self"===t[0])return e;for(let n=0;n<t.length;n++){if("object"!=typeof e||null===e)return r;let i=t[n];if(i.endsWith("[]")){let o=i.slice(0,-2);if(!(o in e))return r;{let i=e[o];if(!Array.isArray(i))return r;return i.map(e=>t$(e,t.slice(n+1),r))}}e=e[i]}return e}catch(e){if(e instanceof TypeError)return r;throw e}}function tJ(e){if("string"!=typeof e)throw Error("fromImageBytes must be a string");return e}function tW(e){var t;let r,n,i,o,s={},a=t$(e,["name"]);null!=a&&tV(s,["name"],a);let l=t$(e,["metadata"]);null!=l&&tV(s,["metadata"],l);let u=t$(e,["done"]);null!=u&&tV(s,["done"],u);let c=t$(e,["error"]);null!=c&&tV(s,["error"],c);let p=t$(e,["response"]);return null!=p&&tV(s,["response"],(r={},null!=(n=t$(t=p,["sdkHttpResponse"]))&&tV(r,["sdkHttpResponse"],n),null!=(i=t$(t,["parent"]))&&tV(r,["parent"],i),null!=(o=t$(t,["documentName"]))&&tV(r,["documentName"],o),r)),s}(i=eC||(eC={})).OUTCOME_UNSPECIFIED="OUTCOME_UNSPECIFIED",i.OUTCOME_OK="OUTCOME_OK",i.OUTCOME_FAILED="OUTCOME_FAILED",i.OUTCOME_DEADLINE_EXCEEDED="OUTCOME_DEADLINE_EXCEEDED",(o=eS||(eS={})).LANGUAGE_UNSPECIFIED="LANGUAGE_UNSPECIFIED",o.PYTHON="PYTHON",(s=eb||(eb={})).SCHEDULING_UNSPECIFIED="SCHEDULING_UNSPECIFIED",s.SILENT="SILENT",s.WHEN_IDLE="WHEN_IDLE",s.INTERRUPT="INTERRUPT",(a=eI||(eI={})).TYPE_UNSPECIFIED="TYPE_UNSPECIFIED",a.STRING="STRING",a.NUMBER="NUMBER",a.INTEGER="INTEGER",a.BOOLEAN="BOOLEAN",a.ARRAY="ARRAY",a.OBJECT="OBJECT",a.NULL="NULL",(l=eO||(eO={})).AUTH_TYPE_UNSPECIFIED="AUTH_TYPE_UNSPECIFIED",l.NO_AUTH="NO_AUTH",l.API_KEY_AUTH="API_KEY_AUTH",l.HTTP_BASIC_AUTH="HTTP_BASIC_AUTH",l.GOOGLE_SERVICE_ACCOUNT_AUTH="GOOGLE_SERVICE_ACCOUNT_AUTH",l.OAUTH="OAUTH",l.OIDC_AUTH="OIDC_AUTH",(u=ew||(ew={})).HTTP_IN_UNSPECIFIED="HTTP_IN_UNSPECIFIED",u.HTTP_IN_QUERY="HTTP_IN_QUERY",u.HTTP_IN_HEADER="HTTP_IN_HEADER",u.HTTP_IN_PATH="HTTP_IN_PATH",u.HTTP_IN_BODY="HTTP_IN_BODY",u.HTTP_IN_COOKIE="HTTP_IN_COOKIE",(c=eP||(eP={})).API_SPEC_UNSPECIFIED="API_SPEC_UNSPECIFIED",c.SIMPLE_SEARCH="SIMPLE_SEARCH",c.ELASTIC_SEARCH="ELASTIC_SEARCH",(p=eR||(eR={})).ENVIRONMENT_UNSPECIFIED="ENVIRONMENT_UNSPECIFIED",p.ENVIRONMENT_BROWSER="ENVIRONMENT_BROWSER",p.ENVIRONMENT_MOBILE="ENVIRONMENT_MOBILE",p.ENVIRONMENT_DESKTOP="ENVIRONMENT_DESKTOP",(d=eN||(eN={})).SAFETY_POLICY_UNSPECIFIED="SAFETY_POLICY_UNSPECIFIED",d.FINANCIAL_TRANSACTIONS="FINANCIAL_TRANSACTIONS",d.SENSITIVE_DATA_MODIFICATION="SENSITIVE_DATA_MODIFICATION",d.COMMUNICATION_TOOL="COMMUNICATION_TOOL",d.ACCOUNT_CREATION="ACCOUNT_CREATION",d.DATA_MODIFICATION="DATA_MODIFICATION",d.USER_CONSENT_MANAGEMENT="USER_CONSENT_MANAGEMENT",d.LEGAL_TERMS_AND_AGREEMENTS="LEGAL_TERMS_AND_AGREEMENTS",(h=ek||(ek={})).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",(f=eD||(eD={})).UNSPECIFIED="UNSPECIFIED",f.BLOCKING="BLOCKING",f.NON_BLOCKING="NON_BLOCKING",(m=ex||(ex={})).MODE_UNSPECIFIED="MODE_UNSPECIFIED",m.MODE_DYNAMIC="MODE_DYNAMIC",(g=eU||(eU={})).THINKING_LEVEL_UNSPECIFIED="THINKING_LEVEL_UNSPECIFIED",g.MINIMAL="MINIMAL",g.LOW="LOW",g.MEDIUM="MEDIUM",g.HIGH="HIGH",(y=eG||(eG={})).DONT_ALLOW="DONT_ALLOW",y.ALLOW_ADULT="ALLOW_ADULT",y.ALLOW_ALL="ALLOW_ALL",(_=eM||(eM={})).PROMINENT_PEOPLE_UNSPECIFIED="PROMINENT_PEOPLE_UNSPECIFIED",_.ALLOW_PROMINENT_PEOPLE="ALLOW_PROMINENT_PEOPLE",_.BLOCK_PROMINENT_PEOPLE="BLOCK_PROMINENT_PEOPLE",(E=ej||(ej={})).HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",E.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",E.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",E.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",E.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT",E.HARM_CATEGORY_CIVIC_INTEGRITY="HARM_CATEGORY_CIVIC_INTEGRITY",E.HARM_CATEGORY_IMAGE_HATE="HARM_CATEGORY_IMAGE_HATE",E.HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT="HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT",E.HARM_CATEGORY_IMAGE_HARASSMENT="HARM_CATEGORY_IMAGE_HARASSMENT",E.HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT="HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT",E.HARM_CATEGORY_JAILBREAK="HARM_CATEGORY_JAILBREAK",(v=eL||(eL={})).HARM_BLOCK_METHOD_UNSPECIFIED="HARM_BLOCK_METHOD_UNSPECIFIED",v.SEVERITY="SEVERITY",v.PROBABILITY="PROBABILITY",(A=eF||(eF={})).HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",A.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",A.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",A.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",A.BLOCK_NONE="BLOCK_NONE",A.OFF="OFF",(T=eq||(eq={})).MODE_UNSPECIFIED="MODE_UNSPECIFIED",T.AUTO="AUTO",T.ANY="ANY",T.NONE="NONE",T.VALIDATED="VALIDATED",(C=eH||(eH={})).FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",C.STOP="STOP",C.MAX_TOKENS="MAX_TOKENS",C.SAFETY="SAFETY",C.RECITATION="RECITATION",C.LANGUAGE="LANGUAGE",C.OTHER="OTHER",C.BLOCKLIST="BLOCKLIST",C.PROHIBITED_CONTENT="PROHIBITED_CONTENT",C.SPII="SPII",C.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",C.IMAGE_SAFETY="IMAGE_SAFETY",C.UNEXPECTED_TOOL_CALL="UNEXPECTED_TOOL_CALL",C.IMAGE_PROHIBITED_CONTENT="IMAGE_PROHIBITED_CONTENT",C.NO_IMAGE="NO_IMAGE",C.IMAGE_RECITATION="IMAGE_RECITATION",C.IMAGE_OTHER="IMAGE_OTHER",(S=eB||(eB={})).HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",S.NEGLIGIBLE="NEGLIGIBLE",S.LOW="LOW",S.MEDIUM="MEDIUM",S.HIGH="HIGH",(b=eV||(eV={})).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",(I=e$||(e$={})).URL_RETRIEVAL_STATUS_UNSPECIFIED="URL_RETRIEVAL_STATUS_UNSPECIFIED",I.URL_RETRIEVAL_STATUS_SUCCESS="URL_RETRIEVAL_STATUS_SUCCESS",I.URL_RETRIEVAL_STATUS_ERROR="URL_RETRIEVAL_STATUS_ERROR",I.URL_RETRIEVAL_STATUS_PAYWALL="URL_RETRIEVAL_STATUS_PAYWALL",I.URL_RETRIEVAL_STATUS_UNSAFE="URL_RETRIEVAL_STATUS_UNSAFE",(O=eJ||(eJ={})).BLOCKED_REASON_UNSPECIFIED="BLOCKED_REASON_UNSPECIFIED",O.SAFETY="SAFETY",O.OTHER="OTHER",O.BLOCKLIST="BLOCKLIST",O.PROHIBITED_CONTENT="PROHIBITED_CONTENT",O.IMAGE_SAFETY="IMAGE_SAFETY",O.MODEL_ARMOR="MODEL_ARMOR",O.JAILBREAK="JAILBREAK",(w=eW||(eW={})).TRAFFIC_TYPE_UNSPECIFIED="TRAFFIC_TYPE_UNSPECIFIED",w.ON_DEMAND="ON_DEMAND",w.ON_DEMAND_PRIORITY="ON_DEMAND_PRIORITY",w.ON_DEMAND_FLEX="ON_DEMAND_FLEX",w.PROVISIONED_THROUGHPUT="PROVISIONED_THROUGHPUT",(P=eK||(eK={})).MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",P.TEXT="TEXT",P.IMAGE="IMAGE",P.VIDEO="VIDEO",P.AUDIO="AUDIO",P.DOCUMENT="DOCUMENT",(R=eY||(eY={})).MODEL_STAGE_UNSPECIFIED="MODEL_STAGE_UNSPECIFIED",R.UNSTABLE_EXPERIMENTAL="UNSTABLE_EXPERIMENTAL",R.EXPERIMENTAL="EXPERIMENTAL",R.PREVIEW="PREVIEW",R.STABLE="STABLE",R.LEGACY="LEGACY",R.DEPRECATED="DEPRECATED",R.RETIRED="RETIRED",(N=eX||(eX={})).MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",N.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",N.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",N.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH",(k=ez||(ez={})).MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",k.TEXT="TEXT",k.IMAGE="IMAGE",k.AUDIO="AUDIO",k.VIDEO="VIDEO",(D=eQ||(eQ={})).TUNING_MODE_UNSPECIFIED="TUNING_MODE_UNSPECIFIED",D.TUNING_MODE_FULL="TUNING_MODE_FULL",D.TUNING_MODE_PEFT_ADAPTER="TUNING_MODE_PEFT_ADAPTER",(x=eZ||(eZ={})).ADAPTER_SIZE_UNSPECIFIED="ADAPTER_SIZE_UNSPECIFIED",x.ADAPTER_SIZE_ONE="ADAPTER_SIZE_ONE",x.ADAPTER_SIZE_TWO="ADAPTER_SIZE_TWO",x.ADAPTER_SIZE_FOUR="ADAPTER_SIZE_FOUR",x.ADAPTER_SIZE_EIGHT="ADAPTER_SIZE_EIGHT",x.ADAPTER_SIZE_SIXTEEN="ADAPTER_SIZE_SIXTEEN",x.ADAPTER_SIZE_THIRTY_TWO="ADAPTER_SIZE_THIRTY_TWO",(U=e0||(e0={})).JOB_STATE_UNSPECIFIED="JOB_STATE_UNSPECIFIED",U.JOB_STATE_QUEUED="JOB_STATE_QUEUED",U.JOB_STATE_PENDING="JOB_STATE_PENDING",U.JOB_STATE_RUNNING="JOB_STATE_RUNNING",U.JOB_STATE_SUCCEEDED="JOB_STATE_SUCCEEDED",U.JOB_STATE_FAILED="JOB_STATE_FAILED",U.JOB_STATE_CANCELLING="JOB_STATE_CANCELLING",U.JOB_STATE_CANCELLED="JOB_STATE_CANCELLED",U.JOB_STATE_PAUSED="JOB_STATE_PAUSED",U.JOB_STATE_EXPIRED="JOB_STATE_EXPIRED",U.JOB_STATE_UPDATING="JOB_STATE_UPDATING",U.JOB_STATE_PARTIALLY_SUCCEEDED="JOB_STATE_PARTIALLY_SUCCEEDED",(G=e1||(e1={})).TUNING_JOB_STATE_UNSPECIFIED="TUNING_JOB_STATE_UNSPECIFIED",G.TUNING_JOB_STATE_WAITING_FOR_QUOTA="TUNING_JOB_STATE_WAITING_FOR_QUOTA",G.TUNING_JOB_STATE_PROCESSING_DATASET="TUNING_JOB_STATE_PROCESSING_DATASET",G.TUNING_JOB_STATE_WAITING_FOR_CAPACITY="TUNING_JOB_STATE_WAITING_FOR_CAPACITY",G.TUNING_JOB_STATE_TUNING="TUNING_JOB_STATE_TUNING",G.TUNING_JOB_STATE_POST_PROCESSING="TUNING_JOB_STATE_POST_PROCESSING",(M=e2||(e2={})).AGGREGATION_METRIC_UNSPECIFIED="AGGREGATION_METRIC_UNSPECIFIED",M.AVERAGE="AVERAGE",M.MODE="MODE",M.STANDARD_DEVIATION="STANDARD_DEVIATION",M.VARIANCE="VARIANCE",M.MINIMUM="MINIMUM",M.MAXIMUM="MAXIMUM",M.MEDIAN="MEDIAN",M.PERCENTILE_P90="PERCENTILE_P90",M.PERCENTILE_P95="PERCENTILE_P95",M.PERCENTILE_P99="PERCENTILE_P99",(j=e4||(e4={})).PAIRWISE_CHOICE_UNSPECIFIED="PAIRWISE_CHOICE_UNSPECIFIED",j.BASELINE="BASELINE",j.CANDIDATE="CANDIDATE",j.TIE="TIE",(L=e3||(e3={})).TUNING_SPEED_UNSPECIFIED="TUNING_SPEED_UNSPECIFIED",L.REGULAR="REGULAR",L.FAST="FAST",(F=e5||(e5={})).TUNING_TASK_UNSPECIFIED="TUNING_TASK_UNSPECIFIED",F.TUNING_TASK_I2V="TUNING_TASK_I2V",F.TUNING_TASK_T2V="TUNING_TASK_T2V",F.TUNING_TASK_R2V="TUNING_TASK_R2V",(q=e6||(e6={})).VIDEO_ORIENTATION_UNSPECIFIED="VIDEO_ORIENTATION_UNSPECIFIED",q.LANDSCAPE="LANDSCAPE",q.PORTRAIT="PORTRAIT",(H=e8||(e8={})).STATE_UNSPECIFIED="STATE_UNSPECIFIED",H.STATE_PENDING="STATE_PENDING",H.STATE_ACTIVE="STATE_ACTIVE",H.STATE_FAILED="STATE_FAILED",(B=e7||(e7={})).UNSPECIFIED="unspecified",B.FLEX="flex",B.STANDARD="standard",B.PRIORITY="priority",(V=e9||(e9={})).MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",V.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",V.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",V.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH",V.MEDIA_RESOLUTION_ULTRA_HIGH="MEDIA_RESOLUTION_ULTRA_HIGH",($=te||(te={})).TOOL_TYPE_UNSPECIFIED="TOOL_TYPE_UNSPECIFIED",$.GOOGLE_SEARCH_WEB="GOOGLE_SEARCH_WEB",$.GOOGLE_SEARCH_IMAGE="GOOGLE_SEARCH_IMAGE",$.URL_CONTEXT="URL_CONTEXT",$.GOOGLE_MAPS="GOOGLE_MAPS",$.FILE_SEARCH="FILE_SEARCH",(tt||(tt={})).COLLECTION="COLLECTION",(J=tr||(tr={})).FEATURE_SELECTION_PREFERENCE_UNSPECIFIED="FEATURE_SELECTION_PREFERENCE_UNSPECIFIED",J.PRIORITIZE_QUALITY="PRIORITIZE_QUALITY",J.BALANCED="BALANCED",J.PRIORITIZE_COST="PRIORITIZE_COST",(W=tn||(tn={})).PREDICT="PREDICT",W.EMBED_CONTENT="EMBED_CONTENT",(K=ti||(ti={})).BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",K.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",K.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",K.BLOCK_NONE="BLOCK_NONE",(Y=to||(to={})).auto="auto",Y.en="en",Y.ja="ja",Y.ko="ko",Y.hi="hi",Y.zh="zh",Y.pt="pt",Y.es="es",(X=ts||(ts={})).MASK_MODE_DEFAULT="MASK_MODE_DEFAULT",X.MASK_MODE_USER_PROVIDED="MASK_MODE_USER_PROVIDED",X.MASK_MODE_BACKGROUND="MASK_MODE_BACKGROUND",X.MASK_MODE_FOREGROUND="MASK_MODE_FOREGROUND",X.MASK_MODE_SEMANTIC="MASK_MODE_SEMANTIC",(z=ta||(ta={})).CONTROL_TYPE_DEFAULT="CONTROL_TYPE_DEFAULT",z.CONTROL_TYPE_CANNY="CONTROL_TYPE_CANNY",z.CONTROL_TYPE_SCRIBBLE="CONTROL_TYPE_SCRIBBLE",z.CONTROL_TYPE_FACE_MESH="CONTROL_TYPE_FACE_MESH",(Q=tl||(tl={})).SUBJECT_TYPE_DEFAULT="SUBJECT_TYPE_DEFAULT",Q.SUBJECT_TYPE_PERSON="SUBJECT_TYPE_PERSON",Q.SUBJECT_TYPE_ANIMAL="SUBJECT_TYPE_ANIMAL",Q.SUBJECT_TYPE_PRODUCT="SUBJECT_TYPE_PRODUCT",(Z=tu||(tu={})).EDIT_MODE_DEFAULT="EDIT_MODE_DEFAULT",Z.EDIT_MODE_INPAINT_REMOVAL="EDIT_MODE_INPAINT_REMOVAL",Z.EDIT_MODE_INPAINT_INSERTION="EDIT_MODE_INPAINT_INSERTION",Z.EDIT_MODE_OUTPAINT="EDIT_MODE_OUTPAINT",Z.EDIT_MODE_CONTROLLED_EDITING="EDIT_MODE_CONTROLLED_EDITING",Z.EDIT_MODE_STYLE="EDIT_MODE_STYLE",Z.EDIT_MODE_BGSWAP="EDIT_MODE_BGSWAP",Z.EDIT_MODE_PRODUCT_IMAGE="EDIT_MODE_PRODUCT_IMAGE",(ee=tc||(tc={})).FOREGROUND="FOREGROUND",ee.BACKGROUND="BACKGROUND",ee.PROMPT="PROMPT",ee.SEMANTIC="SEMANTIC",ee.INTERACTIVE="INTERACTIVE",(et=tp||(tp={})).ASSET="ASSET",et.STYLE="STYLE",(er=td||(td={})).INSERT="INSERT",er.REMOVE="REMOVE",er.REMOVE_STATIC="REMOVE_STATIC",er.OUTPAINT="OUTPAINT",(en=th||(th={})).OPTIMIZED="OPTIMIZED",en.LOSSLESS="LOSSLESS",(ei=tf||(tf={})).CROP="CROP",ei.PAD="PAD",(eo=tm||(tm={})).RESPONSE_PARSE_TYPE_UNSPECIFIED="RESPONSE_PARSE_TYPE_UNSPECIFIED",eo.IDENTITY="IDENTITY",eo.REGEX_EXTRACT="REGEX_EXTRACT",(es=tg||(tg={})).MATCH_OPERATION_UNSPECIFIED="MATCH_OPERATION_UNSPECIFIED",es.REGEX_CONTAINS="REGEX_CONTAINS",es.PARTIAL_MATCH="PARTIAL_MATCH",es.EXACT_MATCH="EXACT_MATCH",(ea=ty||(ty={})).REINFORCEMENT_TUNING_THINKING_LEVEL_UNSPECIFIED="REINFORCEMENT_TUNING_THINKING_LEVEL_UNSPECIFIED",ea.MINIMAL="MINIMAL",ea.HIGH="HIGH",(el=t_||(t_={})).SUPERVISED_FINE_TUNING="SUPERVISED_FINE_TUNING",el.PREFERENCE_TUNING="PREFERENCE_TUNING",el.DISTILLATION="DISTILLATION",el.REINFORCEMENT_TUNING="REINFORCEMENT_TUNING",(eu=tE||(tE={})).STATE_UNSPECIFIED="STATE_UNSPECIFIED",eu.PROCESSING="PROCESSING",eu.ACTIVE="ACTIVE",eu.FAILED="FAILED",(ec=tv||(tv={})).SOURCE_UNSPECIFIED="SOURCE_UNSPECIFIED",ec.UPLOADED="UPLOADED",ec.GENERATED="GENERATED",ec.REGISTERED="REGISTERED",(ep=tA||(tA={})).TURN_COMPLETE_REASON_UNSPECIFIED="TURN_COMPLETE_REASON_UNSPECIFIED",ep.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",ep.RESPONSE_REJECTED="RESPONSE_REJECTED",ep.NEED_MORE_INPUT="NEED_MORE_INPUT",ep.PROHIBITED_INPUT_CONTENT="PROHIBITED_INPUT_CONTENT",ep.IMAGE_PROHIBITED_INPUT_CONTENT="IMAGE_PROHIBITED_INPUT_CONTENT",ep.INPUT_TEXT_CONTAIN_PROMINENT_PERSON_PROHIBITED="INPUT_TEXT_CONTAIN_PROMINENT_PERSON_PROHIBITED",ep.INPUT_IMAGE_CELEBRITY="INPUT_IMAGE_CELEBRITY",ep.INPUT_IMAGE_PHOTO_REALISTIC_CHILD_PROHIBITED="INPUT_IMAGE_PHOTO_REALISTIC_CHILD_PROHIBITED",ep.INPUT_TEXT_NCII_PROHIBITED="INPUT_TEXT_NCII_PROHIBITED",ep.INPUT_OTHER="INPUT_OTHER",ep.INPUT_IP_PROHIBITED="INPUT_IP_PROHIBITED",ep.BLOCKLIST="BLOCKLIST",ep.UNSAFE_PROMPT_FOR_IMAGE_GENERATION="UNSAFE_PROMPT_FOR_IMAGE_GENERATION",ep.GENERATED_IMAGE_SAFETY="GENERATED_IMAGE_SAFETY",ep.GENERATED_CONTENT_SAFETY="GENERATED_CONTENT_SAFETY",ep.GENERATED_AUDIO_SAFETY="GENERATED_AUDIO_SAFETY",ep.GENERATED_VIDEO_SAFETY="GENERATED_VIDEO_SAFETY",ep.GENERATED_CONTENT_PROHIBITED="GENERATED_CONTENT_PROHIBITED",ep.GENERATED_CONTENT_BLOCKLIST="GENERATED_CONTENT_BLOCKLIST",ep.GENERATED_IMAGE_PROHIBITED="GENERATED_IMAGE_PROHIBITED",ep.GENERATED_IMAGE_CELEBRITY="GENERATED_IMAGE_CELEBRITY",ep.GENERATED_IMAGE_PROMINENT_PEOPLE_DETECTED_BY_REWRITER="GENERATED_IMAGE_PROMINENT_PEOPLE_DETECTED_BY_REWRITER",ep.GENERATED_IMAGE_IDENTIFIABLE_PEOPLE="GENERATED_IMAGE_IDENTIFIABLE_PEOPLE",ep.GENERATED_IMAGE_MINORS="GENERATED_IMAGE_MINORS",ep.OUTPUT_IMAGE_IP_PROHIBITED="OUTPUT_IMAGE_IP_PROHIBITED",ep.GENERATED_OTHER="GENERATED_OTHER",ep.MAX_REGENERATION_REACHED="MAX_REGENERATION_REACHED",(ed=tT||(tT={})).VAD_SIGNAL_TYPE_UNSPECIFIED="VAD_SIGNAL_TYPE_UNSPECIFIED",ed.VAD_SIGNAL_TYPE_SOS="VAD_SIGNAL_TYPE_SOS",ed.VAD_SIGNAL_TYPE_EOS="VAD_SIGNAL_TYPE_EOS",(eh=tC||(tC={})).TYPE_UNSPECIFIED="TYPE_UNSPECIFIED",eh.ACTIVITY_START="ACTIVITY_START",eh.ACTIVITY_END="ACTIVITY_END",(ef=tS||(tS={})).START_SENSITIVITY_UNSPECIFIED="START_SENSITIVITY_UNSPECIFIED",ef.START_SENSITIVITY_HIGH="START_SENSITIVITY_HIGH",ef.START_SENSITIVITY_LOW="START_SENSITIVITY_LOW",(em=tb||(tb={})).END_SENSITIVITY_UNSPECIFIED="END_SENSITIVITY_UNSPECIFIED",em.END_SENSITIVITY_HIGH="END_SENSITIVITY_HIGH",em.END_SENSITIVITY_LOW="END_SENSITIVITY_LOW",(eg=tI||(tI={})).ACTIVITY_HANDLING_UNSPECIFIED="ACTIVITY_HANDLING_UNSPECIFIED",eg.START_OF_ACTIVITY_INTERRUPTS="START_OF_ACTIVITY_INTERRUPTS",eg.NO_INTERRUPTION="NO_INTERRUPTION",(ey=tO||(tO={})).TURN_COVERAGE_UNSPECIFIED="TURN_COVERAGE_UNSPECIFIED",ey.TURN_INCLUDES_ONLY_ACTIVITY="TURN_INCLUDES_ONLY_ACTIVITY",ey.TURN_INCLUDES_ALL_INPUT="TURN_INCLUDES_ALL_INPUT",ey.TURN_INCLUDES_AUDIO_ACTIVITY_AND_ALL_VIDEO="TURN_INCLUDES_AUDIO_ACTIVITY_AND_ALL_VIDEO",(e_=tw||(tw={})).SCALE_UNSPECIFIED="SCALE_UNSPECIFIED",e_.C_MAJOR_A_MINOR="C_MAJOR_A_MINOR",e_.D_FLAT_MAJOR_B_FLAT_MINOR="D_FLAT_MAJOR_B_FLAT_MINOR",e_.D_MAJOR_B_MINOR="D_MAJOR_B_MINOR",e_.E_FLAT_MAJOR_C_MINOR="E_FLAT_MAJOR_C_MINOR",e_.E_MAJOR_D_FLAT_MINOR="E_MAJOR_D_FLAT_MINOR",e_.F_MAJOR_D_MINOR="F_MAJOR_D_MINOR",e_.G_FLAT_MAJOR_E_FLAT_MINOR="G_FLAT_MAJOR_E_FLAT_MINOR",e_.G_MAJOR_E_MINOR="G_MAJOR_E_MINOR",e_.A_FLAT_MAJOR_F_MINOR="A_FLAT_MAJOR_F_MINOR",e_.A_MAJOR_G_FLAT_MINOR="A_MAJOR_G_FLAT_MINOR",e_.B_FLAT_MAJOR_G_MINOR="B_FLAT_MAJOR_G_MINOR",e_.B_MAJOR_A_FLAT_MINOR="B_MAJOR_A_FLAT_MINOR",(eE=tP||(tP={})).MUSIC_GENERATION_MODE_UNSPECIFIED="MUSIC_GENERATION_MODE_UNSPECIFIED",eE.QUALITY="QUALITY",eE.DIVERSITY="DIVERSITY",eE.VOCALIZATION="VOCALIZATION",(ev=tR||(tR={})).PLAYBACK_CONTROL_UNSPECIFIED="PLAYBACK_CONTROL_UNSPECIFIED",ev.PLAY="PLAY",ev.PAUSE="PAUSE",ev.STOP="STOP",ev.RESET_CONTEXT="RESET_CONTEXT";function tK(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)}class tY{constructor(e){const t={};for(const r of e.headers.entries())t[r[0]]=r[1];this.headers=t,this.responseInternal=e}json(){return this.responseInternal.json()}}class tX{get text(){var e,t,r,n,i,o,s,a;if((null==(n=null==(r=null==(t=null==(e=this.candidates)?void 0:e[0])?void 0:t.content)?void 0:r.parts)?void 0:n.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 l="",u=!1,c=[];for(let e of null!=(a=null==(s=null==(o=null==(i=this.candidates)?void 0:i[0])?void 0:o.content)?void 0:s.parts)?a:[]){for(let[t,r]of Object.entries(e))"text"!==t&&"thought"!==t&&"thoughtSignature"!==t&&(null!==r||void 0!==r)&&c.push(t);if("string"==typeof e.text){if("boolean"==typeof e.thought&&e.thought)continue;u=!0,l+=e.text}}return c.length>0&&console.warn(`there are non-text parts ${c} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),u?l:void 0}get data(){var e,t,r,n,i,o,s,a;if((null==(n=null==(r=null==(t=null==(e=this.candidates)?void 0:e[0])?void 0:t.content)?void 0:r.parts)?void 0:n.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 l="",u=[];for(let e of null!=(a=null==(s=null==(o=null==(i=this.candidates)?void 0:i[0])?void 0:o.content)?void 0:s.parts)?a:[]){for(let[t,r]of Object.entries(e))"inlineData"!==t&&(null!==r||void 0!==r)&&u.push(t);e.inlineData&&"string"==typeof e.inlineData.data&&(l+=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.`),l.length>0?btoa(l):void 0}get functionCalls(){var e,t,r,n,i,o,s,a;if((null==(n=null==(r=null==(t=null==(e=this.candidates)?void 0:e[0])?void 0:t.content)?void 0:r.parts)?void 0:n.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 l=null==(a=null==(s=null==(o=null==(i=this.candidates)?void 0:i[0])?void 0:o.content)?void 0:s.parts)?void 0:a.filter(e=>e.functionCall).map(e=>e.functionCall).filter(e=>void 0!==e);if((null==l?void 0:l.length)!==0)return l}get executableCode(){var e,t,r,n,i,o,s,a,l;if((null==(n=null==(r=null==(t=null==(e=this.candidates)?void 0:e[0])?void 0:t.content)?void 0:r.parts)?void 0:n.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==(a=null==(s=null==(o=null==(i=this.candidates)?void 0:i[0])?void 0:o.content)?void 0:s.parts)?void 0:a.filter(e=>e.executableCode).map(e=>e.executableCode).filter(e=>void 0!==e);if((null==u?void 0:u.length)!==0)return null==(l=null==u?void 0:u[0])?void 0:l.code}get codeExecutionResult(){var e,t,r,n,i,o,s,a,l;if((null==(n=null==(r=null==(t=null==(e=this.candidates)?void 0:e[0])?void 0:t.content)?void 0:r.parts)?void 0:n.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==(a=null==(s=null==(o=null==(i=this.candidates)?void 0:i[0])?void 0:o.content)?void 0:s.parts)?void 0:a.filter(e=>e.codeExecutionResult).map(e=>e.codeExecutionResult).filter(e=>void 0!==e);if((null==u?void 0:u.length)!==0)return null==(l=null==u?void 0:u[0])?void 0:l.output}}class tz{}class tQ{}class tZ{}class t0{}class t1{}class t2{}class t4{}class t3{}class t5{}class t6{}class t8{_fromAPIResponse({apiResponse:e,_isVertexAI:t}){let r,n=new t8;if(t){let t,n,i,o,s,a;t={},null!=(n=t$(e,["name"]))&&tV(t,["name"],n),null!=(i=t$(e,["metadata"]))&&tV(t,["metadata"],i),null!=(o=t$(e,["done"]))&&tV(t,["done"],o),null!=(s=t$(e,["error"]))&&tV(t,["error"],s),null!=(a=t$(e,["response"]))&&tV(t,["response"],function(e){let t={},r=t$(e,["videos"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>{var t;let r,n,i,o,s,a;return r={},null!=(n=t$(e,["_self"]))&&tV(r,["video"],(i={},null!=(o=t$(t=n,["gcsUri"]))&&tV(i,["uri"],o),null!=(s=t$(t,["bytesBase64Encoded"]))&&tV(i,["videoBytes"],tJ(s)),null!=(a=t$(t,["mimeType"]))&&tV(i,["mimeType"],a),i)),r})),tV(t,["generatedVideos"],e)}let n=t$(e,["raiMediaFilteredCount"]);null!=n&&tV(t,["raiMediaFilteredCount"],n);let i=t$(e,["raiMediaFilteredReasons"]);return null!=i&&tV(t,["raiMediaFilteredReasons"],i),t}(a)),r=t}else{let t,n,i,o,s,a;t={},null!=(n=t$(e,["name"]))&&tV(t,["name"],n),null!=(i=t$(e,["metadata"]))&&tV(t,["metadata"],i),null!=(o=t$(e,["done"]))&&tV(t,["done"],o),null!=(s=t$(e,["error"]))&&tV(t,["error"],s),null!=(a=t$(e,["response","generateVideoResponse"]))&&tV(t,["response"],function(e){let t={},r=t$(e,["generatedSamples"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>{var t;let r,n,i,o,s,a;return r={},null!=(n=t$(e,["video"]))&&tV(r,["video"],(i={},null!=(o=t$(t=n,["uri"]))&&tV(i,["uri"],o),null!=(s=t$(t,["encodedVideo"]))&&tV(i,["videoBytes"],tJ(s)),null!=(a=t$(t,["encoding"]))&&tV(i,["mimeType"],a),i)),r})),tV(t,["generatedVideos"],e)}let n=t$(e,["raiMediaFilteredCount"]);null!=n&&tV(t,["raiMediaFilteredCount"],n);let i=t$(e,["raiMediaFilteredReasons"]);return null!=i&&tV(t,["raiMediaFilteredReasons"],i),t}(a)),r=t}return Object.assign(n,r),n}}class t7{}class t9{}class re{}class rt{}class rr{}class rn{}class ri{}class ro{}class rs{_fromAPIResponse({apiResponse:e,_isVertexAI:t}){var r;let n,i,o,s,a,l,u,c,p,d,h=new rs;return Object.assign(h,(a={},null!=(l=t$(e,["name"]))&&tV(a,["name"],l),null!=(u=t$(e,["metadata"]))&&tV(a,["metadata"],u),null!=(c=t$(e,["done"]))&&tV(a,["done"],c),null!=(p=t$(e,["error"]))&&tV(a,["error"],p),null!=(d=t$(e,["response"]))&&tV(a,["response"],(n={},null!=(i=t$(r=d,["sdkHttpResponse"]))&&tV(n,["sdkHttpResponse"],i),null!=(o=t$(r,["parent"]))&&tV(n,["parent"],o),null!=(s=t$(r,["documentName"]))&&tV(n,["documentName"],s),n)),a)),h}}class ra{}class rl{}class ru{}class rc{}class rp{}class rd{get text(){var e,t,r;let n="",i=!1,o=[];for(let s of null!=(r=null==(t=null==(e=this.serverContent)?void 0:e.modelTurn)?void 0:t.parts)?r:[]){for(let[e,t]of Object.entries(s))"text"!==e&&"thought"!==e&&null!==t&&o.push(e);if("string"==typeof s.text){if("boolean"==typeof s.thought&&s.thought)continue;i=!0,n+=s.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.`),i?n:void 0}get data(){var e,t,r;let n="",i=[];for(let o of null!=(r=null==(t=null==(e=this.serverContent)?void 0:e.modelTurn)?void 0:t.parts)?r:[]){for(let[e,t]of Object.entries(o))"inlineData"!==e&&null!==t&&i.push(e);o.inlineData&&"string"==typeof o.inlineData.data&&(n+=atob(o.inlineData.data))}return i.length>0&&console.warn(`there are non-data parts ${i} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),n.length>0?btoa(n):void 0}}class rh{get audioChunk(){if(this.serverContent&&this.serverContent.audioChunks&&this.serverContent.audioChunks.length>0)return this.serverContent.audioChunks[0]}}class rf{_fromAPIResponse({apiResponse:e,_isVertexAI:t}){let r=new rf;return Object.assign(r,tW(e)),r}}function rm(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 rg(e,t){let r=rm(e,t);return r?r.startsWith("publishers/")&&e.isVertexAI()?`projects/${e.getProject()}/locations/${e.getLocation()}/${r}`:r.startsWith("models/")&&e.isVertexAI()?`projects/${e.getProject()}/locations/${e.getLocation()}/publishers/google/${r}`:r:""}function ry(e){return Array.isArray(e)?e.map(e=>r_(e)):[r_(e)]}function r_(e){if("object"==typeof e&&null!==e)return e;throw Error(`Could not parse input as Blob. Unsupported blob type: ${typeof e}`)}function rE(e){let t=r_(e);if(t.mimeType&&t.mimeType.startsWith("image/"))return t;throw Error(`Unsupported mime type: ${t.mimeType}`)}function rv(e){let t=r_(e);if(t.mimeType&&t.mimeType.startsWith("audio/"))return t;throw Error(`Unsupported mime type: ${t.mimeType}`)}function rA(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 rT(e){if(null==e||Array.isArray(e)&&0===e.length)throw Error("PartListUnion is required");return Array.isArray(e)?e.map(e=>rA(e)):[rA(e)]}function rC(e){return null!=e&&"object"==typeof e&&"parts"in e&&Array.isArray(e.parts)}function rS(e){return null!=e&&"object"==typeof e&&"functionCall"in e}function rb(e){return null!=e&&"object"==typeof e&&"functionResponse"in e}function rI(e){if(null==e)throw Error("ContentUnion is required");return rC(e)?e:{role:"user",parts:rT(e)}}function rO(e,t){if(!t)return[];if(e.isVertexAI()&&Array.isArray(t))return t.flatMap(e=>{let t=rI(e);return t.parts&&t.parts.length>0&&void 0!==t.parts[0].text?[t.parts[0].text]:[]});if(e.isVertexAI()){let e=rI(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=>rI(e)):[rI(t)]}function rw(e){if(null==e||Array.isArray(e)&&0===e.length)throw Error("contents are required");if(!Array.isArray(e)){if(rS(e)||rb(e))throw Error("To specify functionCall or functionResponse parts, please wrap them in a Content object, specifying the role for them");return[rI(e)]}let t=[],r=[],n=rC(e[0]);for(let i of e){let e=rC(i);if(e!=n)throw Error("Mixing Content and Parts is not supported, please group the parts into a the appropriate Content objects and specify the roles for them");if(e)t.push(i);else if(rS(i)||rb(i))throw Error("To specify functionCall or functionResponse parts, please wrap them, and any other parts, in Content objects as appropriate, specifying the role for them");else r.push(i)}return n||t.push({role:"user",parts:rT(r)}),t}function rP(e){let t={},r=["items"],n=["anyOf"],i=["properties"];if(e.type&&e.anyOf)throw Error("type and anyOf cannot be both populated.");let o=e.anyOf;for(let[s,a]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 r=e.filter(e=>"null"!==e);if(1===r.length)t.type=Object.values(eI).includes(r[0].toUpperCase())?r[0].toUpperCase():eI.TYPE_UNSPECIFIED;else for(let e of(t.anyOf=[],r))t.anyOf.push({type:Object.values(eI).includes(e.toUpperCase())?e.toUpperCase():eI.TYPE_UNSPECIFIED})}(e.type,t),Object.entries(e)))if(null!=a)if("type"==s){if("null"===a)throw Error("type: null can not be the only possible type for the field.");if(a instanceof Array)continue;t.type=Object.values(eI).includes(a.toUpperCase())?a.toUpperCase():eI.TYPE_UNSPECIFIED}else if(r.includes(s))t[s]=rP(a);else if(n.includes(s)){let e=[];for(let r of a){if("null"==r.type){t.nullable=!0;continue}e.push(rP(r))}t[s]=e}else if(i.includes(s)){let e={};for(let[t,r]of Object.entries(a))e[t]=rP(r);t[s]=e}else{if("additionalProperties"===s)continue;t[s]=a}return t}function rR(e){if("object"==typeof e)return e;if("string"==typeof e)return{voiceConfig:{prebuiltVoiceConfig:{voiceName:e}}};throw Error(`Unsupported speechConfig type: ${typeof e}`)}function rN(e){if("multiSpeakerVoiceConfig"in e)throw Error("multiSpeakerVoiceConfig is not supported in the live API.");return e}function rk(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=rP(t.parameters)),t.response&&(Object.keys(t.response).includes("$schema")?t.responseJsonSchema||(t.responseJsonSchema=t.response,delete t.response):t.response=rP(t.response));return e}function rD(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 r of e)t.push(r);return t}function rx(e,t){if("string"!=typeof t)throw Error("name must be a string");return function(e,t,r,n=1){let i=!t.startsWith(`${r}/`)&&t.split("/").length===n;if(e.isVertexAI())if(t.startsWith("projects/"))return t;else if(t.startsWith("locations/"))return`projects/${e.getProject()}/${t}`;else if(t.startsWith(`${r}/`))return`projects/${e.getProject()}/locations/${e.getLocation()}/${t}`;else if(i)return`projects/${e.getProject()}/locations/${e.getLocation()}/${r}/${t}`;else return t;return i?`${r}/${t}`:t}(e,t,"cachedContents")}function rU(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 rG(e){return null!=e&&"object"==typeof e&&"video"in e}function rM(e){return null!=e&&"object"==typeof e&&"uri"in e}function rj(e){var t;let r;if(null!=e&&"object"==typeof e&&"name"in e&&(r=e.name),!rM(e)||void 0!==(r=e.uri)){if(!rG(e)||void 0!==(r=null==(t=e.video)?void 0:t.uri)){if("string"==typeof e&&(r=e),void 0===r)throw Error("Could not extract file name from the provided input.");if(r.startsWith("https://")){let e=r.split("files/")[1].match(/[a-z0-9]+/);if(null===e)throw Error(`Could not extract file name from URI ${r}`);r=e[0]}else r.startsWith("files/")&&(r=r.split("files/")[1]);return r}}}function rL(e,t){return e.isVertexAI()?t?"publishers/google/models":"models":t?"models":"tunedModels"}function rF(e){for(let n of["models","tunedModels","publisherModels"]){var t,r;if(t=e,r=n,null!==t&&"object"==typeof t&&r in t)return e[n]}return[]}function rq(e,t){let r;if("string"==typeof t)if(e.isVertexAI())if(t.startsWith("gs://"))r={format:"jsonl",gcsUri:[t]};else if(t.startsWith("bq://"))r={format:"bigquery",bigqueryUri:t};else if(/^projects\/[^/]+\/locations\/[^/]+\/datasets\/[^/]+$/.test(t))r={format:"vertex-dataset",vertexDatasetName:t};else throw Error(`Unsupported string source for Vertex AI: ${t}`);else if(t.startsWith("files/"))r={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.");r={inlinedRequests:t}}else r=t;let n=[r.gcsUri,r.bigqueryUri,r.vertexDatasetName].filter(Boolean).length,i=[r.inlinedRequests,r.fileName].filter(Boolean).length;if(e.isVertexAI()){if(i>0||1!==n)throw Error("Exactly one of `gcsUri`, `bigqueryUri`, or `vertexDatasetName` must be set for Vertex AI.")}else if(n>0||1!==i)throw Error("Exactly one of `inlinedRequests`, `fileName`, must be set for Gemini API.");return r}function rH(e){if("object"!=typeof e||null===e)return{};let t=e.inlinedResponses;if("object"!=typeof t||null===t)return e;let r=t.inlinedResponses;if(!Array.isArray(r)||0===r.length)return e;let n=!1;for(let e of r){if("object"!=typeof e||null===e)continue;let t=e.response;if("object"==typeof t&&null!==t&&void 0!==t.embedding){n=!0;break}}return n&&(e.inlinedEmbedContentResponses=e.inlinedResponses,delete e.inlinedResponses),e}function rB(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 rV(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 r$(e){let t={},r=t$(e,["name"]);null!=r&&tV(t,["name"],r);let n=t$(e,["metadata","displayName"]);null!=n&&tV(t,["displayName"],n);let i=t$(e,["metadata","state"]);null!=i&&tV(t,["state"],rV(i));let o=t$(e,["metadata","createTime"]);null!=o&&tV(t,["createTime"],o);let s=t$(e,["metadata","endTime"]);null!=s&&tV(t,["endTime"],s);let a=t$(e,["metadata","updateTime"]);null!=a&&tV(t,["updateTime"],a);let l=t$(e,["metadata","model"]);null!=l&&tV(t,["model"],l);let u=t$(e,["metadata","output"]);return null!=u&&tV(t,["dest"],function(e){let t={},r=t$(e,["responsesFile"]);null!=r&&tV(t,["fileName"],r);let n=t$(e,["inlinedResponses","inlinedResponses"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>{var t;let r,n,i,o;return r={},null!=(n=t$(t=e,["response"]))&&tV(r,["response"],function(e){let t={},r=t$(e,["sdkHttpResponse"]);null!=r&&tV(t,["sdkHttpResponse"],r);let n=t$(e,["candidates"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>(function(e){let t={},r=t$(e,["content"]);null!=r&&tV(t,["content"],r);let n=t$(e,["citationMetadata"]);null!=n&&tV(t,["citationMetadata"],function(e){let t={},r=t$(e,["citationSources"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),tV(t,["citations"],e)}return t}(n));let i=t$(e,["tokenCount"]);null!=i&&tV(t,["tokenCount"],i);let o=t$(e,["finishReason"]);null!=o&&tV(t,["finishReason"],o);let s=t$(e,["groundingMetadata"]);null!=s&&tV(t,["groundingMetadata"],s);let a=t$(e,["avgLogprobs"]);null!=a&&tV(t,["avgLogprobs"],a);let l=t$(e,["index"]);null!=l&&tV(t,["index"],l);let u=t$(e,["logprobsResult"]);null!=u&&tV(t,["logprobsResult"],u);let c=t$(e,["safetyRatings"]);if(null!=c){let e=c;Array.isArray(e)&&(e=e.map(e=>e)),tV(t,["safetyRatings"],e)}let p=t$(e,["urlContextMetadata"]);return null!=p&&tV(t,["urlContextMetadata"],p),t})(e))),tV(t,["candidates"],e)}let i=t$(e,["modelVersion"]);null!=i&&tV(t,["modelVersion"],i);let o=t$(e,["promptFeedback"]);null!=o&&tV(t,["promptFeedback"],o);let s=t$(e,["responseId"]);null!=s&&tV(t,["responseId"],s);let a=t$(e,["usageMetadata"]);null!=a&&tV(t,["usageMetadata"],a);let l=t$(e,["modelStatus"]);return null!=l&&tV(t,["modelStatus"],l),t}(n)),null!=(i=t$(t,["metadata"]))&&tV(r,["metadata"],i),null!=(o=t$(t,["error"]))&&tV(r,["error"],o),r})),tV(t,["inlinedResponses"],e)}let i=t$(e,["inlinedEmbedContentResponses","inlinedResponses"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),tV(t,["inlinedEmbedContentResponses"],e)}return t}(rH(u))),t}function rJ(e){var t,r,n;let i,o,s,a,l,u,c,p,d,h,f,m,g,y={},_=t$(e,["name"]);null!=_&&tV(y,["name"],_);let E=t$(e,["displayName"]);null!=E&&tV(y,["displayName"],E);let v=t$(e,["state"]);null!=v&&tV(y,["state"],rV(v));let A=t$(e,["error"]);null!=A&&tV(y,["error"],A);let T=t$(e,["createTime"]);null!=T&&tV(y,["createTime"],T);let C=t$(e,["startTime"]);null!=C&&tV(y,["startTime"],C);let S=t$(e,["endTime"]);null!=S&&tV(y,["endTime"],S);let b=t$(e,["updateTime"]);null!=b&&tV(y,["updateTime"],b);let I=t$(e,["model"]);null!=I&&tV(y,["model"],I);let O=t$(e,["inputConfig"]);null!=O&&tV(y,["src"],(i={},null!=(o=t$(r=O,["instancesFormat"]))&&tV(i,["format"],o),null!=(s=t$(r,["gcsSource","uris"]))&&tV(i,["gcsUri"],s),null!=(a=t$(r,["bigquerySource","inputUri"]))&&tV(i,["bigqueryUri"],a),null!=(l=t$(r,["vertexMultimodalDatasetSource","datasetName"]))&&tV(i,["vertexDatasetName"],l),i));let w=t$(e,["outputConfig"]);null!=w&&tV(y,["dest"],(t=rH(w),d={},null!=(h=t$(t,["predictionsFormat"]))&&tV(d,["format"],h),null!=(f=t$(t,["gcsDestination","outputUriPrefix"]))&&tV(d,["gcsUri"],f),null!=(m=t$(t,["bigqueryDestination","outputUri"]))&&tV(d,["bigqueryUri"],m),null!=(g=t$(t,["vertexMultimodalDatasetDestination"]))&&tV(d,["vertexDataset"],(u={},null!=(c=t$(n=g,["bigqueryDestination","outputUri"]))&&tV(u,["bigqueryDestination"],c),null!=(p=t$(n,["displayName"]))&&tV(u,["displayName"],p),u)),d));let P=t$(e,["completionStats"]);null!=P&&tV(y,["completionStats"],P);let R=t$(e,["outputInfo"]);return null!=R&&tV(y,["outputInfo"],R),y}function rW(e){let t={},r=t$(e,["parts"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>{var t;let r,n,i,o,s,a,l,u,c,p,d,h,f,m,g;return r={},null!=(n=t$(t=e,["mediaResolution"]))&&tV(r,["mediaResolution"],n),null!=(i=t$(t,["codeExecutionResult"]))&&tV(r,["codeExecutionResult"],i),null!=(o=t$(t,["executableCode"]))&&tV(r,["executableCode"],o),null!=(s=t$(t,["fileData"]))&&tV(r,["fileData"],function(e){let t={};if(void 0!==t$(e,["displayName"]))throw Error("displayName parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let r=t$(e,["fileUri"]);null!=r&&tV(t,["fileUri"],r);let n=t$(e,["mimeType"]);return null!=n&&tV(t,["mimeType"],n),t}(s)),null!=(a=t$(t,["functionCall"]))&&tV(r,["functionCall"],function(e){let t={},r=t$(e,["id"]);null!=r&&tV(t,["id"],r);let n=t$(e,["args"]);null!=n&&tV(t,["args"],n);let i=t$(e,["name"]);if(null!=i&&tV(t,["name"],i),void 0!==t$(e,["partialArgs"]))throw Error("partialArgs parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["willContinue"]))throw Error("willContinue parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return t}(a)),null!=(l=t$(t,["functionResponse"]))&&tV(r,["functionResponse"],l),null!=(u=t$(t,["inlineData"]))&&tV(r,["inlineData"],function(e){let t={},r=t$(e,["data"]);if(null!=r&&tV(t,["data"],r),void 0!==t$(e,["displayName"]))throw Error("displayName parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let n=t$(e,["mimeType"]);return null!=n&&tV(t,["mimeType"],n),t}(u)),null!=(c=t$(t,["text"]))&&tV(r,["text"],c),null!=(p=t$(t,["thought"]))&&tV(r,["thought"],p),null!=(d=t$(t,["thoughtSignature"]))&&tV(r,["thoughtSignature"],d),null!=(h=t$(t,["videoMetadata"]))&&tV(r,["videoMetadata"],h),null!=(f=t$(t,["toolCall"]))&&tV(r,["toolCall"],f),null!=(m=t$(t,["toolResponse"]))&&tV(r,["toolResponse"],m),null!=(g=t$(t,["partMetadata"]))&&tV(r,["partMetadata"],g),r})),tV(t,["parts"],e)}let n=t$(e,["role"]);return null!=n&&tV(t,["role"],n),t}function rK(e,t){let r={},n=t$(t,["model"]);null!=n&&tV(r,["_url","model"],rm(e,n));let i=t$(t,["src"]);null!=i&&tV(r,["batch","inputConfig"],function(e,t){let r={};if(void 0!==t$(t,["format"]))throw Error("format parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(t,["gcsUri"]))throw Error("gcsUri parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(t,["bigqueryUri"]))throw Error("bigqueryUri parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let n=t$(t,["fileName"]);null!=n&&tV(r,["fileName"],n);let i=t$(t,["inlinedRequests"]);if(null!=i){let t=i;Array.isArray(t)&&(t=t.map(t=>(function(e,t){let r={},n=t$(t,["model"]);null!=n&&tV(r,["request","model"],rm(e,n));let i=t$(t,["contents"]);if(null!=i){let e=rw(i);Array.isArray(e)&&(e=e.map(e=>rW(e))),tV(r,["request","contents"],e)}let o=t$(t,["metadata"]);null!=o&&tV(r,["metadata"],o);let s=t$(t,["config"]);return null!=s&&tV(r,["request","generationConfig"],function(e,t,r){var n;let i,o,s,a,l={},u=t$(t,["systemInstruction"]);void 0!==r&&null!=u&&tV(r,["systemInstruction"],rW(rI(u)));let c=t$(t,["temperature"]);null!=c&&tV(l,["temperature"],c);let p=t$(t,["topP"]);null!=p&&tV(l,["topP"],p);let d=t$(t,["topK"]);null!=d&&tV(l,["topK"],d);let h=t$(t,["candidateCount"]);null!=h&&tV(l,["candidateCount"],h);let f=t$(t,["maxOutputTokens"]);null!=f&&tV(l,["maxOutputTokens"],f);let m=t$(t,["stopSequences"]);null!=m&&tV(l,["stopSequences"],m);let g=t$(t,["responseLogprobs"]);null!=g&&tV(l,["responseLogprobs"],g);let y=t$(t,["logprobs"]);null!=y&&tV(l,["logprobs"],y);let _=t$(t,["presencePenalty"]);null!=_&&tV(l,["presencePenalty"],_);let E=t$(t,["frequencyPenalty"]);null!=E&&tV(l,["frequencyPenalty"],E);let v=t$(t,["seed"]);null!=v&&tV(l,["seed"],v);let A=t$(t,["responseMimeType"]);null!=A&&tV(l,["responseMimeType"],A);let T=t$(t,["responseSchema"]);null!=T&&tV(l,["responseSchema"],rP(T));let C=t$(t,["responseJsonSchema"]);if(null!=C&&tV(l,["responseJsonSchema"],C),void 0!==t$(t,["routingConfig"]))throw Error("routingConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(t,["modelSelectionConfig"]))throw Error("modelSelectionConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let S=t$(t,["safetySettings"]);if(void 0!==r&&null!=S){let e=S;Array.isArray(e)&&(e=e.map(e=>(function(e){let t={},r=t$(e,["category"]);if(null!=r&&tV(t,["category"],r),void 0!==t$(e,["method"]))throw Error("method parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let n=t$(e,["threshold"]);return null!=n&&tV(t,["threshold"],n),t})(e))),tV(r,["safetySettings"],e)}let b=t$(t,["tools"]);if(void 0!==r&&null!=b){let e=rD(b);Array.isArray(e)&&(e=e.map(e=>(function(e){let t,r,n,i={};if(void 0!==t$(e,["retrieval"]))throw Error("retrieval parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let o=t$(e,["computerUse"]);null!=o&&tV(i,["computerUse"],o);let s=t$(e,["fileSearch"]);null!=s&&tV(i,["fileSearch"],s);let a=t$(e,["googleSearch"]);null!=a&&tV(i,["googleSearch"],function(e){let t={},r=t$(e,["searchTypes"]);if(null!=r&&tV(t,["searchTypes"],r),void 0!==t$(e,["blockingConfidence"]))throw Error("blockingConfidence parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["excludeDomains"]))throw Error("excludeDomains parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let n=t$(e,["timeRangeFilter"]);return null!=n&&tV(t,["timeRangeFilter"],n),t}(a));let l=t$(e,["googleMaps"]);null!=l&&tV(i,["googleMaps"],(t={},null!=(r=t$(l,["authConfig"]))&&tV(t,["authConfig"],function(e){let t={},r=t$(e,["apiKey"]);if(null!=r&&tV(t,["apiKey"],r),void 0!==t$(e,["apiKeyConfig"]))throw Error("apiKeyConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["authType"]))throw Error("authType parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["googleServiceAccountConfig"]))throw Error("googleServiceAccountConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["httpBasicAuthConfig"]))throw Error("httpBasicAuthConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["oauthConfig"]))throw Error("oauthConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["oidcConfig"]))throw Error("oidcConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return t}(r)),null!=(n=t$(l,["enableWidget"]))&&tV(t,["enableWidget"],n),t));let u=t$(e,["codeExecution"]);if(null!=u&&tV(i,["codeExecution"],u),void 0!==t$(e,["enterpriseWebSearch"]))throw Error("enterpriseWebSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let c=t$(e,["functionDeclarations"]);if(null!=c){let e=c;Array.isArray(e)&&(e=e.map(e=>e)),tV(i,["functionDeclarations"],e)}let p=t$(e,["googleSearchRetrieval"]);if(null!=p&&tV(i,["googleSearchRetrieval"],p),void 0!==t$(e,["parallelAiSearch"]))throw Error("parallelAiSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let d=t$(e,["urlContext"]);null!=d&&tV(i,["urlContext"],d);let h=t$(e,["mcpServers"]);if(null!=h){let e=h;Array.isArray(e)&&(e=e.map(e=>e)),tV(i,["mcpServers"],e)}return i})(rk(e)))),tV(r,["tools"],e)}let I=t$(t,["toolConfig"]);if(void 0!==r&&null!=I&&tV(r,["toolConfig"],(i={},null!=(o=t$(n=I,["retrievalConfig"]))&&tV(i,["retrievalConfig"],o),null!=(s=t$(n,["functionCallingConfig"]))&&tV(i,["functionCallingConfig"],function(e){let t={},r=t$(e,["allowedFunctionNames"]);null!=r&&tV(t,["allowedFunctionNames"],r);let n=t$(e,["mode"]);if(null!=n&&tV(t,["mode"],n),void 0!==t$(e,["streamFunctionCallArguments"]))throw Error("streamFunctionCallArguments parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return t}(s)),null!=(a=t$(n,["includeServerSideToolInvocations"]))&&tV(i,["includeServerSideToolInvocations"],a),i)),void 0!==t$(t,["labels"]))throw Error("labels parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let O=t$(t,["cachedContent"]);void 0!==r&&null!=O&&tV(r,["cachedContent"],rx(e,O));let w=t$(t,["responseModalities"]);null!=w&&tV(l,["responseModalities"],w);let P=t$(t,["mediaResolution"]);null!=P&&tV(l,["mediaResolution"],P);let R=t$(t,["speechConfig"]);if(null!=R&&tV(l,["speechConfig"],rR(R)),void 0!==t$(t,["audioTimestamp"]))throw Error("audioTimestamp parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let N=t$(t,["thinkingConfig"]);null!=N&&tV(l,["thinkingConfig"],N);let k=t$(t,["imageConfig"]);null!=k&&tV(l,["imageConfig"],function(e){let t={},r=t$(e,["aspectRatio"]);null!=r&&tV(t,["aspectRatio"],r);let n=t$(e,["imageSize"]);if(null!=n&&tV(t,["imageSize"],n),void 0!==t$(e,["personGeneration"]))throw Error("personGeneration parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["prominentPeople"]))throw Error("prominentPeople parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["outputMimeType"]))throw Error("outputMimeType parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["outputCompressionQuality"]))throw Error("outputCompressionQuality parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["imageOutputOptions"]))throw Error("imageOutputOptions parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return t}(k));let D=t$(t,["enableEnhancedCivicAnswers"]);if(null!=D&&tV(l,["enableEnhancedCivicAnswers"],D),void 0!==t$(t,["modelArmorConfig"]))throw Error("modelArmorConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let x=t$(t,["serviceTier"]);return void 0!==r&&null!=x&&tV(r,["serviceTier"],x),l}(e,s,t$(r,["request"],{}))),r})(e,t))),tV(r,["requests","requests"],t)}if(void 0!==t$(t,["vertexDatasetName"]))throw Error("vertexDatasetName parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return r}(e,rq(e,i)));let o=t$(t,["config"]);return null!=o&&function(e,t){let r=t$(e,["displayName"]);if(void 0!==t&&null!=r&&tV(t,["batch","displayName"],r),void 0!==t$(e,["dest"]))throw Error("dest parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let n=t$(e,["webhookConfig"]);void 0!==t&&null!=n&&tV(t,["batch","webhookConfig"],n)}(o,r),r}(eA=tN||(tN={})).PAGED_ITEM_BATCH_JOBS="batchJobs",eA.PAGED_ITEM_MODELS="models",eA.PAGED_ITEM_TUNING_JOBS="tuningJobs",eA.PAGED_ITEM_FILES="files",eA.PAGED_ITEM_CACHED_CONTENTS="cachedContents",eA.PAGED_ITEM_FILE_SEARCH_STORES="fileSearchStores",eA.PAGED_ITEM_DOCUMENTS="documents",eA.PAGED_ITEM_SKILLS="skills";class rY{constructor(e,t,r,n){this.pageInternal=[],this.paramsInternal={},this.requestInternal=t,this.init(e,r,n)}init(e,t,r){var n,i;this.nameInternal=e,this.pageInternal=t[this.nameInternal]||[],this.sdkHttpResponseInternal=null==t?void 0:t.sdkHttpResponse,this.idxInternal=0;let o={config:{}};(o=r&&0!==Object.keys(r).length?"object"==typeof r?Object.assign({},r):r:{config:{}}).config&&(o.config.pageToken=t.nextPageToken),this.paramsInternal=o,this.pageInternalSize=null!=(i=null==(n=o.config)?void 0:n.pageSize)?i: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 rX extends tH{constructor(e){super(),this.apiClient=e,this.list=async(e={})=>new rY(tN.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=rK(this.apiClient,e),r=tB("{model}:batchGenerateContent",t._url),n=t.batch.inputConfig.requests,i=n.requests,o=[];for(let e of i){let t=Object.assign({},e);if(t.systemInstruction){let e=t.systemInstruction;delete t.systemInstruction;let r=t.request;r.systemInstruction=e,t.request=r}o.push(t)}return n.requests=o,delete t.config,delete t._url,delete t._query,{path:r,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 r=t?Object.assign({},t):{},n=Date.now().toString();if(r.displayName||(r.displayName=`genaiBatchJob_${n}`),void 0===r.dest){let t=this.getGcsUri(e),i=this.getBigqueryUri(e);if(t)t.endsWith(".jsonl")?r.dest=`${t.slice(0,-6)}/dest`:r.dest=`${t}_dest_${n}`;else if(i)r.dest=`${i}_dest_${n}`;else throw Error("Unsupported source for Gemini Enterprise Agent Platform (previously known as Vertex AI): No GCS or BigQuery URI found.")}return r}async createInternal(e){var t,r,n,i,o;let s="",a={};if(this.apiClient.isVertexAI()){let n,i,l,u,c=(o=this.apiClient,n={},null!=(i=t$(e,["model"]))&&tV(n,["model"],rm(o,i)),null!=(l=t$(e,["src"]))&&tV(n,["inputConfig"],function(e){let t={},r=t$(e,["format"]);null!=r&&tV(t,["instancesFormat"],r);let n=t$(e,["gcsUri"]);null!=n&&tV(t,["gcsSource","uris"],n);let i=t$(e,["bigqueryUri"]);if(null!=i&&tV(t,["bigquerySource","inputUri"],i),void 0!==t$(e,["fileName"]))throw Error("fileName parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");if(void 0!==t$(e,["inlinedRequests"]))throw Error("inlinedRequests parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");let o=t$(e,["vertexDatasetName"]);return null!=o&&tV(t,["vertexMultimodalDatasetSource","datasetName"],o),t}(rq(o,l))),null!=(u=t$(e,["config"]))&&function(e,t){let r=t$(e,["displayName"]);void 0!==t&&null!=r&&tV(t,["displayName"],r);let n=t$(e,["dest"]);if(void 0!==t&&null!=n&&tV(t,["outputConfig"],function(e){var t;let r,n,i,o={},s=t$(e,["format"]);null!=s&&tV(o,["predictionsFormat"],s);let a=t$(e,["gcsUri"]);null!=a&&tV(o,["gcsDestination","outputUriPrefix"],a);let l=t$(e,["bigqueryUri"]);if(null!=l&&tV(o,["bigqueryDestination","outputUri"],l),void 0!==t$(e,["fileName"]))throw Error("fileName parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");if(void 0!==t$(e,["inlinedResponses"]))throw Error("inlinedResponses parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");if(void 0!==t$(e,["inlinedEmbedContentResponses"]))throw Error("inlinedEmbedContentResponses parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");let u=t$(e,["vertexDataset"]);return null!=u&&tV(o,["vertexMultimodalDatasetDestination"],(r={},null!=(n=t$(t=u,["bigqueryDestination"]))&&tV(r,["bigqueryDestination","outputUri"],n),null!=(i=t$(t,["displayName"]))&&tV(r,["displayName"],i),r)),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}`)}(n))),void 0!==t$(e,["webhookConfig"]))throw Error("webhookConfig parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.")}(u,n),n);return s=tB("batchPredictionJobs",c._url),a=c._query,delete c._url,delete c._query,this.apiClient.request({path:s,queryParams:a,body:JSON.stringify(c),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json()).then(e=>rJ(e))}{let t=rK(this.apiClient,e);return s=tB("{model}:batchGenerateContent",t._url),a=t._query,delete t._url,delete t._query,this.apiClient.request({path:s,queryParams:a,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null==(n=e.config)?void 0:n.httpOptions,abortSignal:null==(i=e.config)?void 0:i.abortSignal}).then(e=>e.json()).then(e=>r$(e))}}async createEmbeddingsInternal(e){var t,r,n,i,o;let s="",a={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let l,u,c,p,d,h,f,m,g=(n=this.apiClient,p={},null!=(d=t$(e,["model"]))&&tV(p,["_url","model"],rm(n,d)),null!=(h=t$(e,["src"]))&&tV(p,["batch","inputConfig"],(i=n,l={},null!=(u=t$(o=h,["fileName"]))&&tV(l,["file_name"],u),null!=(c=t$(o,["inlinedRequests"]))&&tV(l,["requests"],function(e,t){let r={},n=t$(t,["contents"]);if(null!=n){let t=rO(e,n);Array.isArray(t)&&(t=t.map(e=>e)),tV(r,["requests[]","request","content"],t)}let i=t$(t,["config"]);return null!=i&&(tV(r,["_self"],function(e,t){let r=t$(e,["taskType"]);void 0!==t&&null!=r&&tV(t,["requests[]","taskType"],r);let n=t$(e,["title"]);void 0!==t&&null!=n&&tV(t,["requests[]","title"],n);let i=t$(e,["outputDimensionality"]);if(void 0!==t&&null!=i&&tV(t,["requests[]","outputDimensionality"],i),void 0!==t$(e,["mimeType"]))throw Error("mimeType parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["autoTruncate"]))throw Error("autoTruncate parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["documentOcr"]))throw Error("documentOcr parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["audioTrackExtraction"]))throw Error("audioTrackExtraction parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return{}}(i,r)),!function(e,t){for(let[r,n]of Object.entries(t)){let t=r.split("."),i=n.split("."),o=new Set,s=-1;for(let e=0;e<t.length;e++)if("*"===t[e]){s=e;break}if(-1!==s&&i.length>s)for(let e=s;e<i.length;e++){let t=i[e];"*"===t||t.endsWith("[]")||t.endsWith("[0]")||o.add(t)}!function e(t,r,n,i,o){if(i>=r.length||"object"!=typeof t||null===t)return;let s=r[i];if(s.endsWith("[]")){let a=s.slice(0,-2);if(a in t&&Array.isArray(t[a]))for(let s of t[a])e(s,r,n,i+1,o)}else if("*"===s){if("object"==typeof t&&null!==t&&!Array.isArray(t)){let e=Object.keys(t).filter(e=>!e.startsWith("_")&&!o.has(e)),r={};for(let n of e)r[n]=t[n];for(let[e,o]of Object.entries(r)){let r=[];for(let t of n.slice(i))"*"===t?r.push(e):r.push(t);tV(t,r,o)}for(let r of e)delete t[r]}}else s in t&&e(t[s],r,n,i+1,o)}(e,t,i,0,o)}}(r,{"requests[].*":"requests[].request.*"})),r}(i,c)),l)),null!=(f=t$(e,["config"]))&&(m=t$(f,["displayName"]),void 0!==p&&null!=m&&tV(p,["batch","displayName"],m)),p);return s=tB("{model}:asyncBatchEmbedContent",g._url),a=g._query,delete g._url,delete g._query,this.apiClient.request({path:s,queryParams:a,body:JSON.stringify(g),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json()).then(e=>r$(e))}}async get(e){var t,r,n,i,o,s;let a="",l={};if(this.apiClient.isVertexAI()){let n,i,s=(o=this.apiClient,n={},null!=(i=t$(e,["name"]))&&tV(n,["_url","name"],rB(o,i)),n);return a=tB("batchPredictionJobs/{name}",s._url),l=s._query,delete s._url,delete s._query,this.apiClient.request({path:a,queryParams:l,body:JSON.stringify(s),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json()).then(e=>rJ(e))}{let t,r,o=(s=this.apiClient,t={},null!=(r=t$(e,["name"]))&&tV(t,["_url","name"],rB(s,r)),t);return a=tB("batches/{name}",o._url),l=o._query,delete o._url,delete o._query,this.apiClient.request({path:a,queryParams:l,body:JSON.stringify(o),httpMethod:"GET",httpOptions:null==(n=e.config)?void 0:n.httpOptions,abortSignal:null==(i=e.config)?void 0:i.abortSignal}).then(e=>e.json()).then(e=>r$(e))}}async cancel(e){var t,r,n,i,o,s;let a="",l={};if(this.apiClient.isVertexAI()){let n,i,s=(o=this.apiClient,n={},null!=(i=t$(e,["name"]))&&tV(n,["_url","name"],rB(o,i)),n);a=tB("batchPredictionJobs/{name}:cancel",s._url),l=s._query,delete s._url,delete s._query,await this.apiClient.request({path:a,queryParams:l,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal})}else{let t,r,o=(s=this.apiClient,t={},null!=(r=t$(e,["name"]))&&tV(t,["_url","name"],rB(s,r)),t);a=tB("batches/{name}:cancel",o._url),l=o._query,delete o._url,delete o._query,await this.apiClient.request({path:a,queryParams:l,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null==(n=e.config)?void 0:n.httpOptions,abortSignal:null==(i=e.config)?void 0:i.abortSignal})}}async listInternal(e){var t,r,n,i;let o="",s={};if(this.apiClient.isVertexAI()){let n,i,a,l,u,c=(n={},null!=(i=t$(e,["config"]))&&(a=t$(i,["pageSize"]),void 0!==n&&null!=a&&tV(n,["_query","pageSize"],a),l=t$(i,["pageToken"]),void 0!==n&&null!=l&&tV(n,["_query","pageToken"],l),u=t$(i,["filter"]),void 0!==n&&null!=u&&tV(n,["_query","filter"],u)),n);return o=tB("batchPredictionJobs",c._url),s=c._query,delete c._url,delete c._query,this.apiClient.request({path:o,queryParams:s,body:JSON.stringify(c),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.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={},r=t$(e,["sdkHttpResponse"]);null!=r&&tV(t,["sdkHttpResponse"],r);let n=t$(e,["nextPageToken"]);null!=n&&tV(t,["nextPageToken"],n);let i=t$(e,["batchPredictionJobs"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>rJ(e))),tV(t,["batchJobs"],e)}return t}(e),r=new rp;return Object.assign(r,t),r})}{let t,r,a=(t={},null!=(r=t$(e,["config"]))&&function(e,t){let r=t$(e,["pageSize"]);void 0!==t&&null!=r&&tV(t,["_query","pageSize"],r);let n=t$(e,["pageToken"]);if(void 0!==t&&null!=n&&tV(t,["_query","pageToken"],n),void 0!==t$(e,["filter"]))throw Error("filter parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.")}(r,t),t);return o=tB("batches",a._url),s=a._query,delete a._url,delete a._query,this.apiClient.request({path:o,queryParams:s,body:JSON.stringify(a),httpMethod:"GET",httpOptions:null==(n=e.config)?void 0:n.httpOptions,abortSignal:null==(i=e.config)?void 0:i.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=function(e){let t={},r=t$(e,["sdkHttpResponse"]);null!=r&&tV(t,["sdkHttpResponse"],r);let n=t$(e,["nextPageToken"]);null!=n&&tV(t,["nextPageToken"],n);let i=t$(e,["operations"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>r$(e))),tV(t,["batchJobs"],e)}return t}(e),r=new rp;return Object.assign(r,t),r})}}async delete(e){var t,r,n,i,o,s;let a="",l={};if(this.apiClient.isVertexAI()){let n,i,s=(o=this.apiClient,n={},null!=(i=t$(e,["name"]))&&tV(n,["_url","name"],rB(o,i)),n);return a=tB("batchPredictionJobs/{name}",s._url),l=s._query,delete s._url,delete s._query,this.apiClient.request({path:a,queryParams:l,body:JSON.stringify(s),httpMethod:"DELETE",httpOptions:null==(t=e.config)?void 0:t.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,r,n,i,o;return t={},null!=(r=t$(e,["sdkHttpResponse"]))&&tV(t,["sdkHttpResponse"],r),null!=(n=t$(e,["name"]))&&tV(t,["name"],n),null!=(i=t$(e,["done"]))&&tV(t,["done"],i),null!=(o=t$(e,["error"]))&&tV(t,["error"],o),t})}{let t,r,o=(s=this.apiClient,t={},null!=(r=t$(e,["name"]))&&tV(t,["_url","name"],rB(s,r)),t);return a=tB("batches/{name}",o._url),l=o._query,delete o._url,delete o._query,this.apiClient.request({path:a,queryParams:l,body:JSON.stringify(o),httpMethod:"DELETE",httpOptions:null==(n=e.config)?void 0:n.httpOptions,abortSignal:null==(i=e.config)?void 0:i.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t,r,n,i,o;return t={},null!=(r=t$(e,["sdkHttpResponse"]))&&tV(t,["sdkHttpResponse"],r),null!=(n=t$(e,["name"]))&&tV(t,["name"],n),null!=(i=t$(e,["done"]))&&tV(t,["done"],i),null!=(o=t$(e,["error"]))&&tV(t,["error"],o),t})}}}function rz(e){let t={},r=t$(e,["parts"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>{var t;let r,n,i,o,s,a,l,u,c,p,d,h,f,m,g;return r={},null!=(n=t$(t=e,["mediaResolution"]))&&tV(r,["mediaResolution"],n),null!=(i=t$(t,["codeExecutionResult"]))&&tV(r,["codeExecutionResult"],i),null!=(o=t$(t,["executableCode"]))&&tV(r,["executableCode"],o),null!=(s=t$(t,["fileData"]))&&tV(r,["fileData"],function(e){let t={};if(void 0!==t$(e,["displayName"]))throw Error("displayName parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let r=t$(e,["fileUri"]);null!=r&&tV(t,["fileUri"],r);let n=t$(e,["mimeType"]);return null!=n&&tV(t,["mimeType"],n),t}(s)),null!=(a=t$(t,["functionCall"]))&&tV(r,["functionCall"],function(e){let t={},r=t$(e,["id"]);null!=r&&tV(t,["id"],r);let n=t$(e,["args"]);null!=n&&tV(t,["args"],n);let i=t$(e,["name"]);if(null!=i&&tV(t,["name"],i),void 0!==t$(e,["partialArgs"]))throw Error("partialArgs parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["willContinue"]))throw Error("willContinue parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return t}(a)),null!=(l=t$(t,["functionResponse"]))&&tV(r,["functionResponse"],l),null!=(u=t$(t,["inlineData"]))&&tV(r,["inlineData"],function(e){let t={},r=t$(e,["data"]);if(null!=r&&tV(t,["data"],r),void 0!==t$(e,["displayName"]))throw Error("displayName parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let n=t$(e,["mimeType"]);return null!=n&&tV(t,["mimeType"],n),t}(u)),null!=(c=t$(t,["text"]))&&tV(r,["text"],c),null!=(p=t$(t,["thought"]))&&tV(r,["thought"],p),null!=(d=t$(t,["thoughtSignature"]))&&tV(r,["thoughtSignature"],d),null!=(h=t$(t,["videoMetadata"]))&&tV(r,["videoMetadata"],h),null!=(f=t$(t,["toolCall"]))&&tV(r,["toolCall"],f),null!=(m=t$(t,["toolResponse"]))&&tV(r,["toolResponse"],m),null!=(g=t$(t,["partMetadata"]))&&tV(r,["partMetadata"],g),r})),tV(t,["parts"],e)}let n=t$(e,["role"]);return null!=n&&tV(t,["role"],n),t}function rQ(e){let t={},r=t$(e,["parts"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>(function(e){let t={},r=t$(e,["mediaResolution"]);null!=r&&tV(t,["mediaResolution"],r);let n=t$(e,["codeExecutionResult"]);null!=n&&tV(t,["codeExecutionResult"],function(e){let t={},r=t$(e,["outcome"]);null!=r&&tV(t,["outcome"],r);let n=t$(e,["output"]);if(null!=n&&tV(t,["output"],n),void 0!==t$(e,["id"]))throw Error("id parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return t}(n));let i=t$(e,["executableCode"]);null!=i&&tV(t,["executableCode"],function(e){let t={},r=t$(e,["code"]);null!=r&&tV(t,["code"],r);let n=t$(e,["language"]);if(null!=n&&tV(t,["language"],n),void 0!==t$(e,["id"]))throw Error("id parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return t}(i));let o=t$(e,["fileData"]);null!=o&&tV(t,["fileData"],o);let s=t$(e,["functionCall"]);null!=s&&tV(t,["functionCall"],s);let a=t$(e,["functionResponse"]);null!=a&&tV(t,["functionResponse"],a);let l=t$(e,["inlineData"]);null!=l&&tV(t,["inlineData"],l);let u=t$(e,["text"]);null!=u&&tV(t,["text"],u);let c=t$(e,["thought"]);null!=c&&tV(t,["thought"],c);let p=t$(e,["thoughtSignature"]);null!=p&&tV(t,["thoughtSignature"],p);let d=t$(e,["videoMetadata"]);if(null!=d&&tV(t,["videoMetadata"],d),void 0!==t$(e,["toolCall"]))throw Error("toolCall parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");if(void 0!==t$(e,["toolResponse"]))throw Error("toolResponse parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");if(void 0!==t$(e,["partMetadata"]))throw Error("partMetadata parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return t})(e))),tV(t,["parts"],e)}let n=t$(e,["role"]);return null!=n&&tV(t,["role"],n),t}class rZ extends tH{constructor(e){super(),this.apiClient=e,this.list=async(e={})=>new rY(tN.PAGED_ITEM_CACHED_CONTENTS,e=>this.listInternal(e),await this.listInternal(e),e)}async create(e){var t,r,n,i,o,s;let a="",l={};if(this.apiClient.isVertexAI()){let n,i,s,u=(o=this.apiClient,n={},null!=(i=t$(e,["model"]))&&tV(n,["model"],rg(o,i)),null!=(s=t$(e,["config"]))&&function(e,t){let r=t$(e,["ttl"]);void 0!==t&&null!=r&&tV(t,["ttl"],r);let n=t$(e,["expireTime"]);void 0!==t&&null!=n&&tV(t,["expireTime"],n);let i=t$(e,["displayName"]);void 0!==t&&null!=i&&tV(t,["displayName"],i);let o=t$(e,["contents"]);if(void 0!==t&&null!=o){let e=rw(o);Array.isArray(e)&&(e=e.map(e=>rQ(e))),tV(t,["contents"],e)}let s=t$(e,["systemInstruction"]);void 0!==t&&null!=s&&tV(t,["systemInstruction"],rQ(rI(s)));let a=t$(e,["tools"]);if(void 0!==t&&null!=a){let e=a;Array.isArray(e)&&(e=e.map(e=>(function(e){let t={},r=t$(e,["retrieval"]);null!=r&&tV(t,["retrieval"],r);let n=t$(e,["computerUse"]);if(null!=n&&tV(t,["computerUse"],function(e){let t={},r=t$(e,["environment"]);null!=r&&tV(t,["environment"],r);let n=t$(e,["excludedPredefinedFunctions"]);null!=n&&tV(t,["excludedPredefinedFunctions"],n);let i=t$(e,["enablePromptInjectionDetection"]);if(null!=i&&tV(t,["enablePromptInjectionDetection"],i),void 0!==t$(e,["disabledSafetyPolicies"]))throw Error("disabledSafetyPolicies parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return t}(n)),void 0!==t$(e,["fileSearch"]))throw Error("fileSearch parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");let i=t$(e,["googleSearch"]);null!=i&&tV(t,["googleSearch"],i);let o=t$(e,["googleMaps"]);null!=o&&tV(t,["googleMaps"],o);let s=t$(e,["codeExecution"]);null!=s&&tV(t,["codeExecution"],s);let a=t$(e,["enterpriseWebSearch"]);null!=a&&tV(t,["enterpriseWebSearch"],a);let l=t$(e,["functionDeclarations"]);if(null!=l){let e=l;Array.isArray(e)&&(e=e.map(e=>e)),tV(t,["functionDeclarations"],e)}let u=t$(e,["googleSearchRetrieval"]);null!=u&&tV(t,["googleSearchRetrieval"],u);let c=t$(e,["parallelAiSearch"]);null!=c&&tV(t,["parallelAiSearch"],c);let p=t$(e,["urlContext"]);null!=p&&tV(t,["urlContext"],p);let d=t$(e,["mcpServers"]);if(null!=d){let e=d;Array.isArray(e)&&(e=e.map(e=>(function(e){if(void 0!==t$(e,["name"]))throw Error("name parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");if(void 0!==t$(e,["streamableHttpTransport"]))throw Error("streamableHttpTransport parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return{}})(e))),tV(t,["mcpServers"],e)}return t})(e))),tV(t,["tools"],e)}let l=t$(e,["toolConfig"]);void 0!==t&&null!=l&&tV(t,["toolConfig"],function(e){let t={},r=t$(e,["retrievalConfig"]);null!=r&&tV(t,["retrievalConfig"],r);let n=t$(e,["functionCallingConfig"]);if(null!=n&&tV(t,["functionCallingConfig"],n),void 0!==t$(e,["includeServerSideToolInvocations"]))throw Error("includeServerSideToolInvocations parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return t}(l));let u=t$(e,["kmsKeyName"]);void 0!==t&&null!=u&&tV(t,["encryption_spec","kmsKeyName"],u)}(s,n),n);return a=tB("cachedContents",u._url),l=u._query,delete u._url,delete u._query,this.apiClient.request({path:a,queryParams:l,body:JSON.stringify(u),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json()).then(e=>e)}{let t,r,o,u=(s=this.apiClient,t={},null!=(r=t$(e,["model"]))&&tV(t,["model"],rg(s,r)),null!=(o=t$(e,["config"]))&&function(e,t){var r;let n,i,o,s,a=t$(e,["ttl"]);void 0!==t&&null!=a&&tV(t,["ttl"],a);let l=t$(e,["expireTime"]);void 0!==t&&null!=l&&tV(t,["expireTime"],l);let u=t$(e,["displayName"]);void 0!==t&&null!=u&&tV(t,["displayName"],u);let c=t$(e,["contents"]);if(void 0!==t&&null!=c){let e=rw(c);Array.isArray(e)&&(e=e.map(e=>rz(e))),tV(t,["contents"],e)}let p=t$(e,["systemInstruction"]);void 0!==t&&null!=p&&tV(t,["systemInstruction"],rz(rI(p)));let d=t$(e,["tools"]);if(void 0!==t&&null!=d){let e=d;Array.isArray(e)&&(e=e.map(e=>(function(e){let t,r,n,i={};if(void 0!==t$(e,["retrieval"]))throw Error("retrieval parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let o=t$(e,["computerUse"]);null!=o&&tV(i,["computerUse"],o);let s=t$(e,["fileSearch"]);null!=s&&tV(i,["fileSearch"],s);let a=t$(e,["googleSearch"]);null!=a&&tV(i,["googleSearch"],function(e){let t={},r=t$(e,["searchTypes"]);if(null!=r&&tV(t,["searchTypes"],r),void 0!==t$(e,["blockingConfidence"]))throw Error("blockingConfidence parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["excludeDomains"]))throw Error("excludeDomains parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let n=t$(e,["timeRangeFilter"]);return null!=n&&tV(t,["timeRangeFilter"],n),t}(a));let l=t$(e,["googleMaps"]);null!=l&&tV(i,["googleMaps"],(t={},null!=(r=t$(l,["authConfig"]))&&tV(t,["authConfig"],function(e){let t={},r=t$(e,["apiKey"]);if(null!=r&&tV(t,["apiKey"],r),void 0!==t$(e,["apiKeyConfig"]))throw Error("apiKeyConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["authType"]))throw Error("authType parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["googleServiceAccountConfig"]))throw Error("googleServiceAccountConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["httpBasicAuthConfig"]))throw Error("httpBasicAuthConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["oauthConfig"]))throw Error("oauthConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["oidcConfig"]))throw Error("oidcConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return t}(r)),null!=(n=t$(l,["enableWidget"]))&&tV(t,["enableWidget"],n),t));let u=t$(e,["codeExecution"]);if(null!=u&&tV(i,["codeExecution"],u),void 0!==t$(e,["enterpriseWebSearch"]))throw Error("enterpriseWebSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let c=t$(e,["functionDeclarations"]);if(null!=c){let e=c;Array.isArray(e)&&(e=e.map(e=>e)),tV(i,["functionDeclarations"],e)}let p=t$(e,["googleSearchRetrieval"]);if(null!=p&&tV(i,["googleSearchRetrieval"],p),void 0!==t$(e,["parallelAiSearch"]))throw Error("parallelAiSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let d=t$(e,["urlContext"]);null!=d&&tV(i,["urlContext"],d);let h=t$(e,["mcpServers"]);if(null!=h){let e=h;Array.isArray(e)&&(e=e.map(e=>e)),tV(i,["mcpServers"],e)}return i})(e))),tV(t,["tools"],e)}let h=t$(e,["toolConfig"]);if(void 0!==t&&null!=h&&tV(t,["toolConfig"],(n={},null!=(i=t$(r=h,["retrievalConfig"]))&&tV(n,["retrievalConfig"],i),null!=(o=t$(r,["functionCallingConfig"]))&&tV(n,["functionCallingConfig"],function(e){let t={},r=t$(e,["allowedFunctionNames"]);null!=r&&tV(t,["allowedFunctionNames"],r);let n=t$(e,["mode"]);if(null!=n&&tV(t,["mode"],n),void 0!==t$(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!=(s=t$(r,["includeServerSideToolInvocations"]))&&tV(n,["includeServerSideToolInvocations"],s),n)),void 0!==t$(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 a=tB("cachedContents",u._url),l=u._query,delete u._url,delete u._query,this.apiClient.request({path:a,queryParams:l,body:JSON.stringify(u),httpMethod:"POST",httpOptions:null==(n=e.config)?void 0:n.httpOptions,abortSignal:null==(i=e.config)?void 0:i.abortSignal}).then(e=>e.json()).then(e=>e)}}async get(e){var t,r,n,i,o,s;let a="",l={};if(this.apiClient.isVertexAI()){let n,i,s=(o=this.apiClient,n={},null!=(i=t$(e,["name"]))&&tV(n,["_url","name"],rx(o,i)),n);return a=tB("{name}",s._url),l=s._query,delete s._url,delete s._query,this.apiClient.request({path:a,queryParams:l,body:JSON.stringify(s),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json()).then(e=>e)}{let t,r,o=(s=this.apiClient,t={},null!=(r=t$(e,["name"]))&&tV(t,["_url","name"],rx(s,r)),t);return a=tB("{name}",o._url),l=o._query,delete o._url,delete o._query,this.apiClient.request({path:a,queryParams:l,body:JSON.stringify(o),httpMethod:"GET",httpOptions:null==(n=e.config)?void 0:n.httpOptions,abortSignal:null==(i=e.config)?void 0:i.abortSignal}).then(e=>e.json()).then(e=>e)}}async delete(e){var t,r,n,i,o,s;let a="",l={};if(this.apiClient.isVertexAI()){let n,i,s=(o=this.apiClient,n={},null!=(i=t$(e,["name"]))&&tV(n,["_url","name"],rx(o,i)),n);return a=tB("{name}",s._url),l=s._query,delete s._url,delete s._query,this.apiClient.request({path:a,queryParams:l,body:JSON.stringify(s),httpMethod:"DELETE",httpOptions:null==(t=e.config)?void 0:t.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,r,n=(t={},null!=(r=t$(e,["sdkHttpResponse"]))&&tV(t,["sdkHttpResponse"],r),t),i=new rt;return Object.assign(i,n),i})}{let t,r,o=(s=this.apiClient,t={},null!=(r=t$(e,["name"]))&&tV(t,["_url","name"],rx(s,r)),t);return a=tB("{name}",o._url),l=o._query,delete o._url,delete o._query,this.apiClient.request({path:a,queryParams:l,body:JSON.stringify(o),httpMethod:"DELETE",httpOptions:null==(n=e.config)?void 0:n.httpOptions,abortSignal:null==(i=e.config)?void 0:i.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t,r,n=(t={},null!=(r=t$(e,["sdkHttpResponse"]))&&tV(t,["sdkHttpResponse"],r),t),i=new rt;return Object.assign(i,n),i})}}async update(e){var t,r,n,i,o,s;let a="",l={};if(this.apiClient.isVertexAI()){let n,i,s,u,c,p=(o=this.apiClient,n={},null!=(i=t$(e,["name"]))&&tV(n,["_url","name"],rx(o,i)),null!=(s=t$(e,["config"]))&&(u=t$(s,["ttl"]),void 0!==n&&null!=u&&tV(n,["ttl"],u),c=t$(s,["expireTime"]),void 0!==n&&null!=c&&tV(n,["expireTime"],c)),n);return a=tB("{name}",p._url),l=p._query,delete p._url,delete p._query,this.apiClient.request({path:a,queryParams:l,body:JSON.stringify(p),httpMethod:"PATCH",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json()).then(e=>e)}{let t,r,o,u,c,p=(s=this.apiClient,t={},null!=(r=t$(e,["name"]))&&tV(t,["_url","name"],rx(s,r)),null!=(o=t$(e,["config"]))&&(u=t$(o,["ttl"]),void 0!==t&&null!=u&&tV(t,["ttl"],u),c=t$(o,["expireTime"]),void 0!==t&&null!=c&&tV(t,["expireTime"],c)),t);return a=tB("{name}",p._url),l=p._query,delete p._url,delete p._query,this.apiClient.request({path:a,queryParams:l,body:JSON.stringify(p),httpMethod:"PATCH",httpOptions:null==(n=e.config)?void 0:n.httpOptions,abortSignal:null==(i=e.config)?void 0:i.abortSignal}).then(e=>e.json()).then(e=>e)}}async listInternal(e){var t,r,n,i;let o="",s={};if(this.apiClient.isVertexAI()){let n,i,a,l,u=(n={},null!=(i=t$(e,["config"]))&&(a=t$(i,["pageSize"]),void 0!==n&&null!=a&&tV(n,["_query","pageSize"],a),l=t$(i,["pageToken"]),void 0!==n&&null!=l&&tV(n,["_query","pageToken"],l)),n);return o=tB("cachedContents",u._url),s=u._query,delete u._url,delete u._query,this.apiClient.request({path:o,queryParams:s,body:JSON.stringify(u),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.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={},r=t$(e,["sdkHttpResponse"]);null!=r&&tV(t,["sdkHttpResponse"],r);let n=t$(e,["nextPageToken"]);null!=n&&tV(t,["nextPageToken"],n);let i=t$(e,["cachedContents"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),tV(t,["cachedContents"],e)}return t}(e),r=new rr;return Object.assign(r,t),r})}{let t,r,a,l,u=(t={},null!=(r=t$(e,["config"]))&&(a=t$(r,["pageSize"]),void 0!==t&&null!=a&&tV(t,["_query","pageSize"],a),l=t$(r,["pageToken"]),void 0!==t&&null!=l&&tV(t,["_query","pageToken"],l)),t);return o=tB("cachedContents",u._url),s=u._query,delete u._url,delete u._query,this.apiClient.request({path:o,queryParams:s,body:JSON.stringify(u),httpMethod:"GET",httpOptions:null==(n=e.config)?void 0:n.httpOptions,abortSignal:null==(i=e.config)?void 0:i.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=function(e){let t={},r=t$(e,["sdkHttpResponse"]);null!=r&&tV(t,["sdkHttpResponse"],r);let n=t$(e,["nextPageToken"]);null!=n&&tV(t,["nextPageToken"],n);let i=t$(e,["cachedContents"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),tV(t,["cachedContents"],e)}return t}(e),r=new rr;return Object.assign(r,t),r})}}}function r0(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)0>t.indexOf(n[i])&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r}function r1(e){return this instanceof r1?(this.v=e,this):new r1(e)}function r2(e,t,r){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var n,i=r.apply(e,t||[]),o=[];return n=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),s("next"),s("throw"),s("return",function(e){return function(t){return Promise.resolve(t).then(e,u)}}),n[Symbol.asyncIterator]=function(){return this},n;function s(e,t){i[e]&&(n[e]=function(t){return new Promise(function(r,n){o.push([e,t,r,n])>1||a(e,t)})},t&&(n[e]=t(n[e])))}function a(e,t){try{var r;(r=i[e](t)).value instanceof r1?Promise.resolve(r.value.v).then(l,u):c(o[0][2],r)}catch(e){c(o[0][3],e)}}function l(e){a("next",e)}function u(e){a("throw",e)}function c(e,t){e(t),o.shift(),o.length&&a(o[0][0],o[0][1])}}function r4(e){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise(function(n,i){var o,s,a;o=n,s=i,a=(t=e[r](t)).done,Promise.resolve(t.value).then(function(e){o({value:e,done:a})},s)})}}}function r3(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 r5(e){if(void 0===e||0===e.length)return[];let t=[],r=e.length,n=0;for(;n<r;)if("user"===e[n].role)t.push(e[n]),n++;else{let i=[],o=!0;for(;n<r&&"model"===e[n].role;)i.push(e[n]),o&&!r3(e[n])&&(o=!1),n++;o?t.push(...i):t.pop()}return t}"function"==typeof SuppressedError&&SuppressedError;class r6{constructor(e,t){this.modelsModule=e,this.apiClient=t}create(e){return new r8(this.apiClient,this.modelsModule,e.model,e.config,structuredClone(e.history))}}class r8{constructor(e,t,r,n={},i=[]){this.apiClient=e,this.modelsModule=t,this.model=r,this.config=n,this.history=i,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}.`)}}(i)}async sendMessage(e){var t;await this.sendPromise;let r=rI(e.message),n=this.modelsModule.generateContent({model:this.model,contents:this.getHistory(!0).concat(r),config:null!=(t=e.config)?t:this.config});return this.sendPromise=(async()=>{var e,t,i;let o=await n,s=null==(t=null==(e=o.candidates)?void 0:e[0])?void 0:t.content,a=o.automaticFunctionCallingHistory,l=this.getHistory(!0).length,u=[];null!=a&&(u=null!=(i=a.slice(l))?i:[]),this.recordHistory(r,s?[s]:[],u)})(),await this.sendPromise.catch(()=>{this.sendPromise=Promise.resolve()}),n}async sendMessageStream(e){var t;await this.sendPromise;let r=rI(e.message),n=this.modelsModule.generateContentStream({model:this.model,contents:this.getHistory(!0).concat(r),config:null!=(t=e.config)?t:this.config});this.sendPromise=n.then(()=>void 0).catch(()=>void 0);let i=await n;return this.processStreamResponse(i,r)}getHistory(e=!1){return structuredClone(e?r5(this.history):this.history)}processStreamResponse(e,t){return r2(this,arguments,function*(){let r=[];try{for(var n,i,o,s,a,l,u,c=!0,p=r4(e);!(n=(u=yield r1(p.next())).done);c=!0){if(s=u.value,c=!1,function(e){var t;if(void 0==e.candidates||0===e.candidates.length)return!1;let r=null==(t=e.candidates[0])?void 0:t.content;return void 0!==r&&r3(r)}(s)){let e=null==(l=null==(a=s.candidates)?void 0:a[0])?void 0:l.content;void 0!==e&&r.push(e)}yield yield r1(s)}}catch(e){i={error:e}}finally{try{!c&&!n&&(o=p.return)&&(yield r1(o.call(p)))}finally{if(i)throw i.error}}this.recordHistory(t,r)})}recordHistory(e,t,r){let n=[];t.length>0&&t.every(e=>void 0!==e.role)?n=t:n.push({role:"model",parts:[]}),r&&r.length>0?this.history.push(...r5(r)):this.history.push(e),this.history.push(...n)}}class r7 extends Error{constructor(e){super(e.message),this.name="ApiError",this.status=e.status,Object.setPrototypeOf(this,r7.prototype)}}class r9 extends tH{constructor(e){super(),this.apiClient=e,this.list=async(e={})=>new rY(tN.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,r;let n="",i={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let o,s,a,l,u=(o={},null!=(s=t$(e,["config"]))&&(a=t$(s,["pageSize"]),void 0!==o&&null!=a&&tV(o,["_query","pageSize"],a),l=t$(s,["pageToken"]),void 0!==o&&null!=l&&tV(o,["_query","pageToken"],l)),o);return n=tB("files",u._url),i=u._query,delete u._url,delete u._query,this.apiClient.request({path:n,queryParams:i,body:JSON.stringify(u),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.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={},r=t$(e,["sdkHttpResponse"]);null!=r&&tV(t,["sdkHttpResponse"],r);let n=t$(e,["nextPageToken"]);null!=n&&tV(t,["nextPageToken"],n);let i=t$(e,["files"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),tV(t,["files"],e)}return t}(e),r=new ra;return Object.assign(r,t),r})}}async createInternal(e){var t,r;let n="",i={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let o,s,a=(o={},null!=(s=t$(e,["file"]))&&tV(o,["file"],s),o);return n=tB("upload/v1beta/files",a._url),i=a._query,delete a._url,delete a._query,this.apiClient.request({path:n,queryParams:i,body:JSON.stringify(a),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json()).then(e=>{let t,r,n=(t={},null!=(r=t$(e,["sdkHttpResponse"]))&&tV(t,["sdkHttpResponse"],r),t),i=new rl;return Object.assign(i,n),i})}}async get(e){var t,r;let n="",i={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let o,s,a=(o={},null!=(s=t$(e,["name"]))&&tV(o,["_url","file"],rj(s)),o);return n=tB("files/{file}",a._url),i=a._query,delete a._url,delete a._query,this.apiClient.request({path:n,queryParams:i,body:JSON.stringify(a),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json()).then(e=>e)}}async delete(e){var t,r;let n="",i={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let o,s,a=(o={},null!=(s=t$(e,["name"]))&&tV(o,["_url","file"],rj(s)),o);return n=tB("files/{file}",a._url),i=a._query,delete a._url,delete a._query,this.apiClient.request({path:n,queryParams:i,body:JSON.stringify(a),httpMethod:"DELETE",httpOptions:null==(t=e.config)?void 0:t.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,r,n=(t={},null!=(r=t$(e,["sdkHttpResponse"]))&&tV(t,["sdkHttpResponse"],r),t),i=new ru;return Object.assign(i,n),i})}}async registerFilesInternal(e){var t,r;let n="",i={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let o,s,a=(o={},null!=(s=t$(e,["uris"]))&&tV(o,["uris"],s),o);return n=tB("files:register",a._url),i=a._query,delete a._url,delete a._query,this.apiClient.request({path:n,queryParams:i,body:JSON.stringify(a),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json()).then(e=>{let t=function(e){let t={},r=t$(e,["sdkHttpResponse"]);null!=r&&tV(t,["sdkHttpResponse"],r);let n=t$(e,["files"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>e)),tV(t,["files"],e)}return t}(e),r=new rc;return Object.assign(r,t),r})}}}function ne(e){let t={};if(void 0!==t$(e,["languageCodes"]))throw Error("languageCodes parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let r=t$(e,["languageAuto"]);null!=r&&tV(t,["languageAuto"],r);let n=t$(e,["languageHints"]);null!=n&&tV(t,["languageHints"],n);let i=t$(e,["adaptationPhrases"]);return null!=i&&tV(t,["adaptationPhrases"],i),t}function nt(e){let t={},r=t$(e,["data"]);if(null!=r&&tV(t,["data"],r),void 0!==t$(e,["displayName"]))throw Error("displayName parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let n=t$(e,["mimeType"]);return null!=n&&tV(t,["mimeType"],n),t}function nr(e,t){let r={},n=t$(e,["parts"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>{var t;let r,n,i,o,s,a,l,u,c,p,d,h,f,m,g;return r={},null!=(n=t$(t=e,["mediaResolution"]))&&tV(r,["mediaResolution"],n),null!=(i=t$(t,["codeExecutionResult"]))&&tV(r,["codeExecutionResult"],i),null!=(o=t$(t,["executableCode"]))&&tV(r,["executableCode"],o),null!=(s=t$(t,["fileData"]))&&tV(r,["fileData"],function(e){let t={};if(void 0!==t$(e,["displayName"]))throw Error("displayName parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let r=t$(e,["fileUri"]);null!=r&&tV(t,["fileUri"],r);let n=t$(e,["mimeType"]);return null!=n&&tV(t,["mimeType"],n),t}(s)),null!=(a=t$(t,["functionCall"]))&&tV(r,["functionCall"],function(e){let t={},r=t$(e,["id"]);null!=r&&tV(t,["id"],r);let n=t$(e,["args"]);null!=n&&tV(t,["args"],n);let i=t$(e,["name"]);if(null!=i&&tV(t,["name"],i),void 0!==t$(e,["partialArgs"]))throw Error("partialArgs parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["willContinue"]))throw Error("willContinue parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return t}(a)),null!=(l=t$(t,["functionResponse"]))&&tV(r,["functionResponse"],l),null!=(u=t$(t,["inlineData"]))&&tV(r,["inlineData"],function(e){let t={},r=t$(e,["data"]);if(null!=r&&tV(t,["data"],r),void 0!==t$(e,["displayName"]))throw Error("displayName parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let n=t$(e,["mimeType"]);return null!=n&&tV(t,["mimeType"],n),t}(u)),null!=(c=t$(t,["text"]))&&tV(r,["text"],c),null!=(p=t$(t,["thought"]))&&tV(r,["thought"],p),null!=(d=t$(t,["thoughtSignature"]))&&tV(r,["thoughtSignature"],d),null!=(h=t$(t,["videoMetadata"]))&&tV(r,["videoMetadata"],h),null!=(f=t$(t,["toolCall"]))&&tV(r,["toolCall"],f),null!=(m=t$(t,["toolResponse"]))&&tV(r,["toolResponse"],m),null!=(g=t$(t,["partMetadata"]))&&tV(r,["partMetadata"],g),r})),tV(r,["parts"],e)}let i=t$(e,["role"]);return null!=i&&tV(r,["role"],i),r}function nn(e,t){let r={},n=t$(e,["parts"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>(function(e){let t={},r=t$(e,["mediaResolution"]);null!=r&&tV(t,["mediaResolution"],r);let n=t$(e,["codeExecutionResult"]);null!=n&&tV(t,["codeExecutionResult"],function(e){let t={},r=t$(e,["outcome"]);null!=r&&tV(t,["outcome"],r);let n=t$(e,["output"]);if(null!=n&&tV(t,["output"],n),void 0!==t$(e,["id"]))throw Error("id parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return t}(n));let i=t$(e,["executableCode"]);null!=i&&tV(t,["executableCode"],function(e){let t={},r=t$(e,["code"]);null!=r&&tV(t,["code"],r);let n=t$(e,["language"]);if(null!=n&&tV(t,["language"],n),void 0!==t$(e,["id"]))throw Error("id parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return t}(i));let o=t$(e,["fileData"]);null!=o&&tV(t,["fileData"],o);let s=t$(e,["functionCall"]);null!=s&&tV(t,["functionCall"],s);let a=t$(e,["functionResponse"]);null!=a&&tV(t,["functionResponse"],a);let l=t$(e,["inlineData"]);null!=l&&tV(t,["inlineData"],l);let u=t$(e,["text"]);null!=u&&tV(t,["text"],u);let c=t$(e,["thought"]);null!=c&&tV(t,["thought"],c);let p=t$(e,["thoughtSignature"]);null!=p&&tV(t,["thoughtSignature"],p);let d=t$(e,["videoMetadata"]);if(null!=d&&tV(t,["videoMetadata"],d),void 0!==t$(e,["toolCall"]))throw Error("toolCall parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");if(void 0!==t$(e,["toolResponse"]))throw Error("toolResponse parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");if(void 0!==t$(e,["partMetadata"]))throw Error("partMetadata parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return t})(e))),tV(r,["parts"],e)}let i=t$(e,["role"]);return null!=i&&tV(r,["role"],i),r}function ni(e,t,r){let n={},i=t$(t,["model"]);null!=i&&tV(n,["_url","model"],rm(e,i));let o=t$(t,["contents"]);if(null!=o){let e=rw(o);Array.isArray(e)&&(e=e.map(e=>nr(e))),tV(n,["contents"],e)}let s=t$(t,["config"]);return null!=s&&tV(n,["generationConfig"],function(e,t,r){var n;let i,o,s,a,l={},u=t$(t,["systemInstruction"]);void 0!==r&&null!=u&&tV(r,["systemInstruction"],nr(rI(u)));let c=t$(t,["temperature"]);null!=c&&tV(l,["temperature"],c);let p=t$(t,["topP"]);null!=p&&tV(l,["topP"],p);let d=t$(t,["topK"]);null!=d&&tV(l,["topK"],d);let h=t$(t,["candidateCount"]);null!=h&&tV(l,["candidateCount"],h);let f=t$(t,["maxOutputTokens"]);null!=f&&tV(l,["maxOutputTokens"],f);let m=t$(t,["stopSequences"]);null!=m&&tV(l,["stopSequences"],m);let g=t$(t,["responseLogprobs"]);null!=g&&tV(l,["responseLogprobs"],g);let y=t$(t,["logprobs"]);null!=y&&tV(l,["logprobs"],y);let _=t$(t,["presencePenalty"]);null!=_&&tV(l,["presencePenalty"],_);let E=t$(t,["frequencyPenalty"]);null!=E&&tV(l,["frequencyPenalty"],E);let v=t$(t,["seed"]);null!=v&&tV(l,["seed"],v);let A=t$(t,["responseMimeType"]);null!=A&&tV(l,["responseMimeType"],A);let T=t$(t,["responseSchema"]);null!=T&&tV(l,["responseSchema"],rP(T));let C=t$(t,["responseJsonSchema"]);if(null!=C&&tV(l,["responseJsonSchema"],C),void 0!==t$(t,["routingConfig"]))throw Error("routingConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(t,["modelSelectionConfig"]))throw Error("modelSelectionConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let S=t$(t,["safetySettings"]);if(void 0!==r&&null!=S){let e=S;Array.isArray(e)&&(e=e.map(e=>(function(e){let t={},r=t$(e,["category"]);if(null!=r&&tV(t,["category"],r),void 0!==t$(e,["method"]))throw Error("method parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let n=t$(e,["threshold"]);return null!=n&&tV(t,["threshold"],n),t})(e))),tV(r,["safetySettings"],e)}let b=t$(t,["tools"]);if(void 0!==r&&null!=b){let e=rD(b);Array.isArray(e)&&(e=e.map(e=>(function(e){let t,r,n,i={};if(void 0!==t$(e,["retrieval"]))throw Error("retrieval parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let o=t$(e,["computerUse"]);null!=o&&tV(i,["computerUse"],o);let s=t$(e,["fileSearch"]);null!=s&&tV(i,["fileSearch"],s);let a=t$(e,["googleSearch"]);null!=a&&tV(i,["googleSearch"],function(e){let t={},r=t$(e,["searchTypes"]);if(null!=r&&tV(t,["searchTypes"],r),void 0!==t$(e,["blockingConfidence"]))throw Error("blockingConfidence parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["excludeDomains"]))throw Error("excludeDomains parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let n=t$(e,["timeRangeFilter"]);return null!=n&&tV(t,["timeRangeFilter"],n),t}(a));let l=t$(e,["googleMaps"]);null!=l&&tV(i,["googleMaps"],(t={},null!=(r=t$(l,["authConfig"]))&&tV(t,["authConfig"],function(e){let t={},r=t$(e,["apiKey"]);if(null!=r&&tV(t,["apiKey"],r),void 0!==t$(e,["apiKeyConfig"]))throw Error("apiKeyConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["authType"]))throw Error("authType parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["googleServiceAccountConfig"]))throw Error("googleServiceAccountConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["httpBasicAuthConfig"]))throw Error("httpBasicAuthConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["oauthConfig"]))throw Error("oauthConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["oidcConfig"]))throw Error("oidcConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return t}(r)),null!=(n=t$(l,["enableWidget"]))&&tV(t,["enableWidget"],n),t));let u=t$(e,["codeExecution"]);if(null!=u&&tV(i,["codeExecution"],u),void 0!==t$(e,["enterpriseWebSearch"]))throw Error("enterpriseWebSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let c=t$(e,["functionDeclarations"]);if(null!=c){let e=c;Array.isArray(e)&&(e=e.map(e=>e)),tV(i,["functionDeclarations"],e)}let p=t$(e,["googleSearchRetrieval"]);if(null!=p&&tV(i,["googleSearchRetrieval"],p),void 0!==t$(e,["parallelAiSearch"]))throw Error("parallelAiSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let d=t$(e,["urlContext"]);null!=d&&tV(i,["urlContext"],d);let h=t$(e,["mcpServers"]);if(null!=h){let e=h;Array.isArray(e)&&(e=e.map(e=>e)),tV(i,["mcpServers"],e)}return i})(rk(e)))),tV(r,["tools"],e)}let I=t$(t,["toolConfig"]);if(void 0!==r&&null!=I&&tV(r,["toolConfig"],(i={},null!=(o=t$(n=I,["retrievalConfig"]))&&tV(i,["retrievalConfig"],o),null!=(s=t$(n,["functionCallingConfig"]))&&tV(i,["functionCallingConfig"],function(e){let t={},r=t$(e,["allowedFunctionNames"]);null!=r&&tV(t,["allowedFunctionNames"],r);let n=t$(e,["mode"]);if(null!=n&&tV(t,["mode"],n),void 0!==t$(e,["streamFunctionCallArguments"]))throw Error("streamFunctionCallArguments parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return t}(s)),null!=(a=t$(n,["includeServerSideToolInvocations"]))&&tV(i,["includeServerSideToolInvocations"],a),i)),void 0!==t$(t,["labels"]))throw Error("labels parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let O=t$(t,["cachedContent"]);void 0!==r&&null!=O&&tV(r,["cachedContent"],rx(e,O));let w=t$(t,["responseModalities"]);null!=w&&tV(l,["responseModalities"],w);let P=t$(t,["mediaResolution"]);null!=P&&tV(l,["mediaResolution"],P);let R=t$(t,["speechConfig"]);if(null!=R&&tV(l,["speechConfig"],rR(R)),void 0!==t$(t,["audioTimestamp"]))throw Error("audioTimestamp parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let N=t$(t,["thinkingConfig"]);null!=N&&tV(l,["thinkingConfig"],N);let k=t$(t,["imageConfig"]);null!=k&&tV(l,["imageConfig"],function(e){let t={},r=t$(e,["aspectRatio"]);null!=r&&tV(t,["aspectRatio"],r);let n=t$(e,["imageSize"]);if(null!=n&&tV(t,["imageSize"],n),void 0!==t$(e,["personGeneration"]))throw Error("personGeneration parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["prominentPeople"]))throw Error("prominentPeople parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["outputMimeType"]))throw Error("outputMimeType parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["outputCompressionQuality"]))throw Error("outputCompressionQuality parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["imageOutputOptions"]))throw Error("imageOutputOptions parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return t}(k));let D=t$(t,["enableEnhancedCivicAnswers"]);if(null!=D&&tV(l,["enableEnhancedCivicAnswers"],D),void 0!==t$(t,["modelArmorConfig"]))throw Error("modelArmorConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let x=t$(t,["serviceTier"]);return void 0!==r&&null!=x&&tV(r,["serviceTier"],x),l}(e,s,n)),n}function no(e,t,r){let n={},i=t$(t,["model"]);null!=i&&tV(n,["_url","model"],rm(e,i));let o=t$(t,["contents"]);if(null!=o){let e=rw(o);Array.isArray(e)&&(e=e.map(e=>nn(e))),tV(n,["contents"],e)}let s=t$(t,["config"]);return null!=s&&tV(n,["generationConfig"],function(e,t,r){var n;let i,o,s,a,l,u,c,p,d={},h=t$(t,["systemInstruction"]);void 0!==r&&null!=h&&tV(r,["systemInstruction"],nn(rI(h)));let f=t$(t,["temperature"]);null!=f&&tV(d,["temperature"],f);let m=t$(t,["topP"]);null!=m&&tV(d,["topP"],m);let g=t$(t,["topK"]);null!=g&&tV(d,["topK"],g);let y=t$(t,["candidateCount"]);null!=y&&tV(d,["candidateCount"],y);let _=t$(t,["maxOutputTokens"]);null!=_&&tV(d,["maxOutputTokens"],_);let E=t$(t,["stopSequences"]);null!=E&&tV(d,["stopSequences"],E);let v=t$(t,["responseLogprobs"]);null!=v&&tV(d,["responseLogprobs"],v);let A=t$(t,["logprobs"]);null!=A&&tV(d,["logprobs"],A);let T=t$(t,["presencePenalty"]);null!=T&&tV(d,["presencePenalty"],T);let C=t$(t,["frequencyPenalty"]);null!=C&&tV(d,["frequencyPenalty"],C);let S=t$(t,["seed"]);null!=S&&tV(d,["seed"],S);let b=t$(t,["responseMimeType"]);null!=b&&tV(d,["responseMimeType"],b);let I=t$(t,["responseSchema"]);null!=I&&tV(d,["responseSchema"],rP(I));let O=t$(t,["responseJsonSchema"]);null!=O&&tV(d,["responseJsonSchema"],O);let w=t$(t,["routingConfig"]);null!=w&&tV(d,["routingConfig"],w);let P=t$(t,["modelSelectionConfig"]);null!=P&&tV(d,["modelConfig"],P);let R=t$(t,["safetySettings"]);if(void 0!==r&&null!=R){let e=R;Array.isArray(e)&&(e=e.map(e=>e)),tV(r,["safetySettings"],e)}let N=t$(t,["tools"]);if(void 0!==r&&null!=N){let e=rD(N);Array.isArray(e)&&(e=e.map(e=>ng(rk(e)))),tV(r,["tools"],e)}let k=t$(t,["toolConfig"]);void 0!==r&&null!=k&&tV(r,["toolConfig"],function(e){let t={},r=t$(e,["retrievalConfig"]);null!=r&&tV(t,["retrievalConfig"],r);let n=t$(e,["functionCallingConfig"]);if(null!=n&&tV(t,["functionCallingConfig"],n),void 0!==t$(e,["includeServerSideToolInvocations"]))throw Error("includeServerSideToolInvocations parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return t}(k));let D=t$(t,["labels"]);void 0!==r&&null!=D&&tV(r,["labels"],D);let x=t$(t,["cachedContent"]);void 0!==r&&null!=x&&tV(r,["cachedContent"],rx(e,x));let U=t$(t,["responseModalities"]);null!=U&&tV(d,["responseModalities"],U);let G=t$(t,["mediaResolution"]);null!=G&&tV(d,["mediaResolution"],G);let M=t$(t,["speechConfig"]);null!=M&&tV(d,["speechConfig"],rR(M));let j=t$(t,["audioTimestamp"]);null!=j&&tV(d,["audioTimestamp"],j);let L=t$(t,["thinkingConfig"]);null!=L&&tV(d,["thinkingConfig"],L);let F=t$(t,["imageConfig"]);if(null!=F&&tV(d,["imageConfig"],(i={},null!=(o=t$(n=F,["aspectRatio"]))&&tV(i,["aspectRatio"],o),null!=(s=t$(n,["imageSize"]))&&tV(i,["imageSize"],s),null!=(a=t$(n,["personGeneration"]))&&tV(i,["personGeneration"],a),null!=(l=t$(n,["prominentPeople"]))&&tV(i,["prominentPeople"],l),null!=(u=t$(n,["outputMimeType"]))&&tV(i,["imageOutputOptions","mimeType"],u),null!=(c=t$(n,["outputCompressionQuality"]))&&tV(i,["imageOutputOptions","compressionQuality"],c),null!=(p=t$(n,["imageOutputOptions"]))&&tV(i,["imageOutputOptions"],p),i)),void 0!==t$(t,["enableEnhancedCivicAnswers"]))throw Error("enableEnhancedCivicAnswers parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");let q=t$(t,["modelArmorConfig"]);void 0!==r&&null!=q&&tV(r,["modelArmorConfig"],q);let H=t$(t,["serviceTier"]);return void 0!==r&&null!=H&&tV(r,["serviceTier"],H),d}(e,s,n)),n}function ns(e,t){let r={},n=t$(e,["sdkHttpResponse"]);null!=n&&tV(r,["sdkHttpResponse"],n);let i=t$(e,["candidates"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>(function(e){let t={},r=t$(e,["content"]);null!=r&&tV(t,["content"],r);let n=t$(e,["citationMetadata"]);null!=n&&tV(t,["citationMetadata"],function(e){let t={},r=t$(e,["citationSources"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),tV(t,["citations"],e)}return t}(n));let i=t$(e,["tokenCount"]);null!=i&&tV(t,["tokenCount"],i);let o=t$(e,["finishReason"]);null!=o&&tV(t,["finishReason"],o);let s=t$(e,["groundingMetadata"]);null!=s&&tV(t,["groundingMetadata"],s);let a=t$(e,["avgLogprobs"]);null!=a&&tV(t,["avgLogprobs"],a);let l=t$(e,["index"]);null!=l&&tV(t,["index"],l);let u=t$(e,["logprobsResult"]);null!=u&&tV(t,["logprobsResult"],u);let c=t$(e,["safetyRatings"]);if(null!=c){let e=c;Array.isArray(e)&&(e=e.map(e=>e)),tV(t,["safetyRatings"],e)}let p=t$(e,["urlContextMetadata"]);return null!=p&&tV(t,["urlContextMetadata"],p),t})(e))),tV(r,["candidates"],e)}let o=t$(e,["modelVersion"]);null!=o&&tV(r,["modelVersion"],o);let s=t$(e,["promptFeedback"]);null!=s&&tV(r,["promptFeedback"],s);let a=t$(e,["responseId"]);null!=a&&tV(r,["responseId"],a);let l=t$(e,["usageMetadata"]);null!=l&&tV(r,["usageMetadata"],l);let u=t$(e,["modelStatus"]);return null!=u&&tV(r,["modelStatus"],u),r}function na(e,t){let r={},n=t$(e,["sdkHttpResponse"]);null!=n&&tV(r,["sdkHttpResponse"],n);let i=t$(e,["candidates"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),tV(r,["candidates"],e)}let o=t$(e,["createTime"]);null!=o&&tV(r,["createTime"],o);let s=t$(e,["modelVersion"]);null!=s&&tV(r,["modelVersion"],s);let a=t$(e,["promptFeedback"]);null!=a&&tV(r,["promptFeedback"],a);let l=t$(e,["responseId"]);null!=l&&tV(r,["responseId"],l);let u=t$(e,["usageMetadata"]);return null!=u&&tV(r,["usageMetadata"],u),r}function nl(e,t){let r={},n=t$(e,["_self"]);null!=n&&tV(r,["image"],nu(n));let i=t$(e,["raiFilteredReason"]);null!=i&&tV(r,["raiFilteredReason"],i);let o=t$(e,["_self"]);null!=o&&tV(r,["safetyAttributes"],nm(o));let s=t$(e,["prompt"]);return null!=s&&tV(r,["enhancedPrompt"],s),r}function nu(e,t){let r={},n=t$(e,["gcsUri"]);null!=n&&tV(r,["gcsUri"],n);let i=t$(e,["bytesBase64Encoded"]);null!=i&&tV(r,["imageBytes"],tJ(i));let o=t$(e,["mimeType"]);return null!=o&&tV(r,["mimeType"],o),r}function nc(e,t){let r={};if(void 0!==t$(e,["gcsUri"]))throw Error("gcsUri parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let n=t$(e,["imageBytes"]);null!=n&&tV(r,["bytesBase64Encoded"],tJ(n));let i=t$(e,["mimeType"]);return null!=i&&tV(r,["mimeType"],i),r}function np(e,t){let r={},n=t$(e,["gcsUri"]);null!=n&&tV(r,["gcsUri"],n);let i=t$(e,["imageBytes"]);null!=i&&tV(r,["bytesBase64Encoded"],tJ(i));let o=t$(e,["mimeType"]);return null!=o&&tV(r,["mimeType"],o),r}function nd(e,t){var r;let n,i,o,s,a={},l=t$(e,["name"]);null!=l&&tV(a,["name"],l);let u=t$(e,["displayName"]);null!=u&&tV(a,["displayName"],u);let c=t$(e,["description"]);null!=c&&tV(a,["description"],c);let p=t$(e,["version"]);null!=p&&tV(a,["version"],p);let d=t$(e,["_self"]);null!=d&&tV(a,["tunedModelInfo"],(n={},null!=(i=t$(r=d,["baseModel"]))&&tV(n,["baseModel"],i),null!=(o=t$(r,["createTime"]))&&tV(n,["createTime"],o),null!=(s=t$(r,["updateTime"]))&&tV(n,["updateTime"],s),n));let h=t$(e,["inputTokenLimit"]);null!=h&&tV(a,["inputTokenLimit"],h);let f=t$(e,["outputTokenLimit"]);null!=f&&tV(a,["outputTokenLimit"],f);let m=t$(e,["supportedGenerationMethods"]);null!=m&&tV(a,["supportedActions"],m);let g=t$(e,["temperature"]);null!=g&&tV(a,["temperature"],g);let y=t$(e,["maxTemperature"]);null!=y&&tV(a,["maxTemperature"],y);let _=t$(e,["topP"]);null!=_&&tV(a,["topP"],_);let E=t$(e,["topK"]);null!=E&&tV(a,["topK"],E);let v=t$(e,["thinking"]);return null!=v&&tV(a,["thinking"],v),a}function nh(e,t){var r;let n,i,o,s,a={},l=t$(e,["name"]);null!=l&&tV(a,["name"],l);let u=t$(e,["displayName"]);null!=u&&tV(a,["displayName"],u);let c=t$(e,["description"]);null!=c&&tV(a,["description"],c);let p=t$(e,["versionId"]);null!=p&&tV(a,["version"],p);let d=t$(e,["deployedModels"]);if(null!=d){let e=d;Array.isArray(e)&&(e=e.map(e=>{let t,r,n;return t={},null!=(r=t$(e,["endpoint"]))&&tV(t,["name"],r),null!=(n=t$(e,["deployedModelId"]))&&tV(t,["deployedModelId"],n),t})),tV(a,["endpoints"],e)}let h=t$(e,["labels"]);null!=h&&tV(a,["labels"],h);let f=t$(e,["_self"]);null!=f&&tV(a,["tunedModelInfo"],(n={},null!=(i=t$(r=f,["labels","google-vertex-llm-tuning-base-model-id"]))&&tV(n,["baseModel"],i),null!=(o=t$(r,["createTime"]))&&tV(n,["createTime"],o),null!=(s=t$(r,["updateTime"]))&&tV(n,["updateTime"],s),n));let m=t$(e,["defaultCheckpointId"]);null!=m&&tV(a,["defaultCheckpointId"],m);let g=t$(e,["checkpoints"]);if(null!=g){let e=g;Array.isArray(e)&&(e=e.map(e=>e)),tV(a,["checkpoints"],e)}return a}function nf(e,t){let r={},n=t$(e,["safetyAttributes","categories"]);null!=n&&tV(r,["categories"],n);let i=t$(e,["safetyAttributes","scores"]);null!=i&&tV(r,["scores"],i);let o=t$(e,["contentType"]);return null!=o&&tV(r,["contentType"],o),r}function nm(e,t){let r={},n=t$(e,["safetyAttributes","categories"]);null!=n&&tV(r,["categories"],n);let i=t$(e,["safetyAttributes","scores"]);null!=i&&tV(r,["scores"],i);let o=t$(e,["contentType"]);return null!=o&&tV(r,["contentType"],o),r}function ng(e,t){let r={},n=t$(e,["retrieval"]);null!=n&&tV(r,["retrieval"],n);let i=t$(e,["computerUse"]);if(null!=i&&tV(r,["computerUse"],function(e){let t={},r=t$(e,["environment"]);null!=r&&tV(t,["environment"],r);let n=t$(e,["excludedPredefinedFunctions"]);null!=n&&tV(t,["excludedPredefinedFunctions"],n);let i=t$(e,["enablePromptInjectionDetection"]);if(null!=i&&tV(t,["enablePromptInjectionDetection"],i),void 0!==t$(e,["disabledSafetyPolicies"]))throw Error("disabledSafetyPolicies parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return t}(i)),void 0!==t$(e,["fileSearch"]))throw Error("fileSearch parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");let o=t$(e,["googleSearch"]);null!=o&&tV(r,["googleSearch"],o);let s=t$(e,["googleMaps"]);null!=s&&tV(r,["googleMaps"],s);let a=t$(e,["codeExecution"]);null!=a&&tV(r,["codeExecution"],a);let l=t$(e,["enterpriseWebSearch"]);null!=l&&tV(r,["enterpriseWebSearch"],l);let u=t$(e,["functionDeclarations"]);if(null!=u){let e=u;Array.isArray(e)&&(e=e.map(e=>e)),tV(r,["functionDeclarations"],e)}let c=t$(e,["googleSearchRetrieval"]);null!=c&&tV(r,["googleSearchRetrieval"],c);let p=t$(e,["parallelAiSearch"]);null!=p&&tV(r,["parallelAiSearch"],p);let d=t$(e,["urlContext"]);null!=d&&tV(r,["urlContext"],d);let h=t$(e,["mcpServers"]);if(null!=h){let e=h;Array.isArray(e)&&(e=e.map(e=>(function(e){if(void 0!==t$(e,["name"]))throw Error("name parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");if(void 0!==t$(e,["streamableHttpTransport"]))throw Error("streamableHttpTransport parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return{}})(e))),tV(r,["mcpServers"],e)}return r}function ny(e,t){let r={},n=t$(e,["uri"]);null!=n&&tV(r,["uri"],n);let i=t$(e,["videoBytes"]);null!=i&&tV(r,["encodedVideo"],tJ(i));let o=t$(e,["mimeType"]);return null!=o&&tV(r,["encoding"],o),r}function n_(e,t){let r={},n=t$(e,["uri"]);null!=n&&tV(r,["gcsUri"],n);let i=t$(e,["videoBytes"]);null!=i&&tV(r,["bytesBase64Encoded"],tJ(i));let o=t$(e,["mimeType"]);return null!=o&&tV(r,["mimeType"],o),r}function nE(e,t){let r=t$(e,["mimeType"]);void 0!==t&&null!=r&&tV(t,["mimeType"],r);let n=t$(e,["displayName"]);void 0!==t&&null!=n&&tV(t,["displayName"],n);let i=t$(e,["customMetadata"]);if(void 0!==t&&null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),tV(t,["customMetadata"],e)}let o=t$(e,["chunkingConfig"]);return void 0!==t&&null!=o&&tV(t,["chunkingConfig"],o),{}}let nv="x-goog-api-client",nA=new Set(["us","eu"]),nT=[408,429,500,502,503,504];class nC{constructor(e){var t,r,n;this.clientOptions=Object.assign({},e),this.customBaseUrl=null==(t=e.httpOptions)?void 0:t.baseUrl,this.clientOptions.vertexai&&(this.clientOptions.project&&this.clientOptions.location?this.clientOptions.apiKey=void 0:this.clientOptions.apiKey&&(this.clientOptions.project=void 0,this.clientOptions.location=void 0));const i={};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?(i.baseUrl=this.customBaseUrl,this.clientOptions.project=void 0,this.clientOptions.location=void 0):this.clientOptions.apiKey||"global"===this.clientOptions.location?i.baseUrl="https://aiplatform.googleapis.com/":this.clientOptions.project&&this.clientOptions.location&&nA.has(this.clientOptions.location)?i.baseUrl=`https://aiplatform.${this.clientOptions.location}.rep.googleapis.com/`:this.clientOptions.project&&this.clientOptions.location&&(i.baseUrl=`https://${this.clientOptions.location}-aiplatform.googleapis.com/`),i.apiVersion=null!=(r=this.clientOptions.apiVersion)?r:"v1beta1"}else this.clientOptions.apiKey||console.warn("API key should be set when using the Gemini API."),i.apiVersion=null!=(n=this.clientOptions.apiVersion)?n:"v1beta",i.baseUrl="https://generativelanguage.googleapis.com/";i.headers=this.getDefaultHeaders(),this.clientOptions.httpOptions=i,e.httpOptions&&(this.clientOptions.httpOptions=this.patchHttpOptions(i,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.")}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,r){let n=[this.getRequestUrlInternal(t)];return r&&n.push(this.getBaseResourcePath()),""!==e&&n.push(e),new URL(`${n.join("/")}`)}shouldPrependVertexProjectPath(e,t){return!(t.baseUrl&&t.baseUrlResourceScope===tt.COLLECTION||this.clientOptions.apiKey||!this.clientOptions.vertexai||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 r=this.shouldPrependVertexProjectPath(e,t),n=this.constructUrl(e.path,t,r);if(e.queryParams)for(let[t,r]of Object.entries(e.queryParams))n.searchParams.append(t,String(r));let i={};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 i.body=e.body;return i=await this.includeExtraHttpOptionsToRequestInit(i,t,n.toString(),e.abortSignal),this.unaryApiCall(n,i,e.httpMethod)}patchHttpOptions(e,t){let r=JSON.parse(JSON.stringify(e));for(let[e,n]of Object.entries(t))"object"==typeof n?r[e]=Object.assign(Object.assign({},r[e]),n):void 0!==n&&(r[e]=n);return r}async requestStream(e){let t=this.clientOptions.httpOptions;e.httpOptions&&(t=this.patchHttpOptions(this.clientOptions.httpOptions,e.httpOptions));let r=this.shouldPrependVertexProjectPath(e,t),n=this.constructUrl(e.path,t,r);n.searchParams.has("alt")&&"sse"===n.searchParams.get("alt")||n.searchParams.set("alt","sse");let i={};return i.body=e.body,i=await this.includeExtraHttpOptionsToRequestInit(i,t,n.toString(),e.abortSignal),this.streamApiCall(n,i,e.httpMethod)}async includeExtraHttpOptionsToRequestInit(e,t,r,n){if(t&&t.timeout||n){let r=new AbortController,i=r.signal;if(t.timeout&&(null==t?void 0:t.timeout)>0){let e=Symbol.for("undici.globalDispatcher.1"),n=globalThis[e];if(n)for(let e of Object.getOwnPropertySymbols(n)){let r=e.description;if((null==r?void 0:r.includes("headers timeout"))||(null==r?void 0:r.includes("body timeout"))){let r=n[e];"number"==typeof r&&(n[e]=Math.max(r,t.timeout))}}let i=setTimeout(()=>r.abort(),t.timeout);i&&"function"==typeof i.unref&&i.unref()}n&&n.addEventListener("abort",()=>{r.abort()}),e.signal=i}return 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 r={};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.");r=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,r){let n=Object.assign({},t);for(let t in r)if(Object.prototype.hasOwnProperty.call(r,t)){let i=r[t],o=n[t];i&&"object"==typeof i&&!Array.isArray(i)&&o&&"object"==typeof o&&!Array.isArray(o)?n[t]=e(o,i):(o&&i&&typeof o!=typeof i&&console.warn(`includeExtraBodyToRequestInit:deepMerge: Type mismatch for key "${t}". Original type: ${typeof o}, New type: ${typeof i}. Overwriting.`),n[t]=i)}return n}(r,t))}(e,t.extraBody),e.headers=await this.getHeadersInternal(t,r),e}async unaryApiCall(e,t,r){return this.apiCall(e.toString(),Object.assign(Object.assign({},t),{method:r})).then(async e=>(await nS(e),new tY(e))).catch(e=>{if(e instanceof Error)throw e;throw Error(`exception ${e} sending request`,{cause:e})})}async streamApiCall(e,t,r){return this.apiCall(e.toString(),Object.assign(Object.assign({},t),{method:r})).then(async e=>(await nS(e),this.processStreamResponse(e))).catch(e=>{if(e instanceof Error)throw e;throw Error(`exception ${e} sending request`,{cause:e})})}processStreamResponse(e){return r2(this,arguments,function*(){var t;let r=null==(t=null==e?void 0:e.body)?void 0:t.getReader(),n=new TextDecoder("utf-8");if(!r)throw Error("Response body is empty");try{let t="",i="data:",o=["\n\n","\r\r","\r\n\r\n"];for(;;){let{done:s,value:a}=yield r1(r.read());if(s){if(t.trim().length>0)throw Error("Incomplete JSON segment at the end");break}let l=n.decode(a,{stream:!0});try{let e=JSON.parse(l);if("error"in e){let t=JSON.parse(JSON.stringify(e.error)),r=t.status,n=t.code,i=`got status: ${r}. ${JSON.stringify(e)}`;if(n>=400&&n<600)throw new r7({message:i,status:n})}}catch(e){if("ApiError"===e.name)throw e}t+=l;let u=-1,c=0;for(;;){for(let e of(u=-1,c=0,o)){let r=t.indexOf(e);-1!==r&&(-1===u||r<u)&&(u=r,c=e.length)}if(-1===u)break;let r=t.substring(0,u);t=t.substring(u+c);let n=r.trim();if(n.startsWith(i)){let t=n.substring(i.length).trim();try{let r=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 r1(new tY(r))}catch(e){throw Error(`exception parsing stream chunk ${t}. ${e}`)}}}}}finally{r.releaseLock()}})}async apiCall(e,t){var r;if(!this.clientOptions.httpOptions||!this.clientOptions.httpOptions.retryOptions)return fetch(e,t);let n=this.clientOptions.httpOptions.retryOptions,i=async()=>{let r=await fetch(e,t);if(r.ok)return r;if(nT.includes(r.status))throw Error(`Retryable HTTP Error: ${r.statusText}`);throw new tx.AbortError(`Non-retryable exception ${r.statusText} sending request`)};return(0,tx.default)(i,{retries:(null!=(r=n.attempts)?r:5)-1})}getDefaultHeaders(){let e={},t="google-genai-sdk/2.10.0 "+this.clientOptions.userAgentExtra;return e["User-Agent"]=t,e[nv]=t,e["Content-Type"]="application/json",e}async getHeadersInternal(e,t){let r=new Headers;if(e&&e.headers)for(let[t,n]of Object.entries(e.headers))r.append(t,n);return(null==e?void 0:e.timeout)&&e.timeout>0&&r.append("X-Server-Timeout",String(Math.ceil(e.timeout/1e3))),await this.clientOptions.auth.addAuthHeaders(r,t),r}getFileName(e){var t;let r="";return"string"==typeof e&&(r=null!=(t=(r=e.replace(/[/\\]+$/,"")).split(/[/\\]/).pop())?t:""),r}async uploadFile(e,t){var r;let n={};null!=t&&(n.mimeType=t.mimeType,n.name=t.name,n.displayName=t.displayName),n.name&&!n.name.startsWith("files/")&&(n.name=`files/${n.name}`);let i=this.clientOptions.uploader,o=await i.stat(e);n.sizeBytes=String(o.size);let s=null!=(r=null==t?void 0:t.mimeType)?r:o.type;if(void 0===s||""===s)throw Error("Can not determine mimeType. Please provide mimeType in the config.");n.mimeType=s;let a={file:n},l=this.getFileName(e),u=tB("upload/v1beta/files",a._url),c=await this.fetchUploadUrl(u,n.sizeBytes,n.mimeType,l,a,null==t?void 0:t.httpOptions);return i.upload(e,c,this)}async uploadFileToFileSearchStore(e,t,r){var n;let i=this.clientOptions.uploader,o=await i.stat(t),s=String(o.size),a=null!=(n=null==r?void 0:r.mimeType)?n:o.type;if(void 0===a||""===a)throw Error("Can not determine mimeType. Please provide mimeType in the config.");let l=`upload/v1beta/${e}:uploadToFileSearchStore`,u=this.getFileName(t),c={};null!=r&&nE(r,c);let p=await this.fetchUploadUrl(l,s,a,u,c,null==r?void 0:r.httpOptions);return i.uploadToFileSearchStore(t,p,this)}async downloadFile(e){let t=this.clientOptions.downloader;await t.download(e,this)}async fetchUploadUrl(e,t,r,n,i,o){var s;let a={};a=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":`${r}`},n?{"X-Goog-Upload-File-Name":n}:{})};let l=await this.request({path:e,body:JSON.stringify(i),httpMethod:"POST",httpOptions:a});if(!l||!(null==l?void 0:l.headers))throw Error("Server did not return an HttpResponse or the returned HttpResponse did not have headers.");let u=null==(s=null==l?void 0:l.headers)?void 0:s["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 nS(e){var t;if(void 0===e)throw Error("response is undefined");if(!e.ok){let r=e.status,n=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(r>=400&&r<600)throw new r7({message:n,status:r});throw Error(n)}}function nb(e){for(let r of e){var t;if(null!==(t=r)&&"object"==typeof t&&t instanceof nO||"object"==typeof r&&"inputSchema"in r)return!0}return!1}function nI(e){var t;let r=null!=(t=e[nv])?t:"";e[nv]=(r+" mcp_used/unknown").trimStart()}class nO{constructor(e=[],t){this.mcpTools=[],this.functionNameToMcpClient={},this.mcpClients=e,this.config=t}static create(e,t){return new nO(e,t)}async initialize(){var e,t,r,n;if(this.mcpTools.length>0)return;let i={},o=[];for(let u of this.mcpClients)try{for(var s,a=!0,l=(t=void 0,r4(function(e){return r2(this,arguments,function*(e,t=100){let r,n=0;for(;n<t;){let t=yield r1(e.listTools({cursor:r}));for(let e of t.tools)yield yield r1(e),n++;if(!t.nextCursor)break;r=t.nextCursor}})}(u)));!(e=(s=await l.next()).done);a=!0){n=s.value,a=!1,o.push(n);let e=n.name;if(i[e])throw Error(`Duplicate function name ${e} found in MCP tools. Please ensure function names are unique.`);i[e]=u}}catch(e){t={error:e}}finally{try{!a&&!e&&(r=l.return)&&await r.call(l)}finally{if(t)throw t.error}}this.mcpTools=o,this.functionNameToMcpClient=i}async tool(){return await this.initialize(),function(e,t={}){let r=[],n=new Set;for(let i of e){let e=i.name;if(n.has(e))throw Error(`Duplicate function name ${e} found in MCP tools. Please ensure function names are unique.`);n.add(e);let o=function(e,t={}){let r={name:e.name,description:e.description,parametersJsonSchema:e.inputSchema};return e.outputSchema&&(r.responseJsonSchema=e.outputSchema),t.behavior&&(r.behavior=t.behavior),{functionDeclarations:[r]}}(i,t);o.functionDeclarations&&r.push(...o.functionDeclarations)}return{functionDeclarations:r}}(this.mcpTools,this.config)}async callTool(e){await this.initialize();let t=[];for(let r of e)if(r.name in this.functionNameToMcpClient){let e,n=this.functionNameToMcpClient[r.name];this.config.timeout&&(e={timeout:this.config.timeout});let i=await n.callTool({name:r.name,arguments:r.args},void 0,e);t.push({functionResponse:{name:r.name,response:i.isError?{error:i}:i}})}return t}}async function nw(e,t,r){let n=new rh;Object.assign(n,r.data instanceof Blob?JSON.parse(await r.data.text()):JSON.parse(r.data)),t(n)}class nP{constructor(e,t,r){this.apiClient=e,this.auth=t,this.webSocketFactory=r}async connect(e){var t,r;let n;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 i=this.apiClient.getWebsocketBaseUrl(),o=this.apiClient.getApiVersion(),s=function(e){let t=new Headers;for(let[r,n]of Object.entries(e))t.append(r,n);return t}(this.apiClient.getDefaultHeaders()),a=this.apiClient.getApiKey(),l=`${i}/ws/google.ai.generativelanguage.${o}.GenerativeService.BidiGenerateMusic?key=${a}`,u=()=>{},c=new Promise(e=>{u=e}),p=e.callbacks,d=this.apiClient,h={onopen:function(){u({})},onmessage:e=>{nw(d,p.onmessage,e)},onerror:null!=(t=null==p?void 0:p.onerror)?t:function(e){},onclose:null!=(r=null==p?void 0:p.onclose)?r:function(e){}},f=this.webSocketFactory.create(l,(n={},s.forEach((e,t)=>{n[t]=e}),n),h);f.connect(),await c;let m=rm(this.apiClient,e.model);return f.send(JSON.stringify({setup:{model:m}})),new nR(f,this.apiClient)}}class nR{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={},r=t$(e,["weightedPrompts"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),tV(t,["weightedPrompts"],e)}return t}(e);this.conn.send(JSON.stringify({clientContent:t}))}async setMusicGenerationConfig(e){let t,r;e.musicGenerationConfig||(e.musicGenerationConfig={});let n=(t={},null!=(r=t$(e,["musicGenerationConfig"]))&&tV(t,["musicGenerationConfig"],r),t);this.conn.send(JSON.stringify(n))}sendPlaybackControl(e){this.conn.send(JSON.stringify({playbackControl:e}))}play(){this.sendPlaybackControl(tR.PLAY)}pause(){this.sendPlaybackControl(tR.PAUSE)}stop(){this.sendPlaybackControl(tR.STOP)}resetContext(){this.sendPlaybackControl(tR.RESET_CONTEXT)}close(){this.conn.close()}}async function nN(e,t,r){let n=new rd,i=JSON.parse(r.data instanceof Blob?await r.data.text():r.data instanceof ArrayBuffer?new TextDecoder().decode(r.data):r.data);if(e.isVertexAI()){var o;let e,t,r,s,a,l,u,c,p,d,h,f,m;Object.assign(n,(e={},null!=(t=t$(i,["setupComplete"]))&&tV(e,["setupComplete"],t),null!=(r=t$(i,["serverContent"]))&&tV(e,["serverContent"],r),null!=(s=t$(i,["toolCall"]))&&tV(e,["toolCall"],s),null!=(a=t$(i,["toolCallCancellation"]))&&tV(e,["toolCallCancellation"],a),null!=(l=t$(i,["usageMetadata"]))&&tV(e,["usageMetadata"],function(e){let t={},r=t$(e,["promptTokenCount"]);null!=r&&tV(t,["promptTokenCount"],r);let n=t$(e,["cachedContentTokenCount"]);null!=n&&tV(t,["cachedContentTokenCount"],n);let i=t$(e,["candidatesTokenCount"]);null!=i&&tV(t,["responseTokenCount"],i);let o=t$(e,["toolUsePromptTokenCount"]);null!=o&&tV(t,["toolUsePromptTokenCount"],o);let s=t$(e,["thoughtsTokenCount"]);null!=s&&tV(t,["thoughtsTokenCount"],s);let a=t$(e,["totalTokenCount"]);null!=a&&tV(t,["totalTokenCount"],a);let l=t$(e,["promptTokensDetails"]);if(null!=l){let e=l;Array.isArray(e)&&(e=e.map(e=>e)),tV(t,["promptTokensDetails"],e)}let u=t$(e,["cacheTokensDetails"]);if(null!=u){let e=u;Array.isArray(e)&&(e=e.map(e=>e)),tV(t,["cacheTokensDetails"],e)}let c=t$(e,["candidatesTokensDetails"]);if(null!=c){let e=c;Array.isArray(e)&&(e=e.map(e=>e)),tV(t,["responseTokensDetails"],e)}let p=t$(e,["toolUsePromptTokensDetails"]);if(null!=p){let e=p;Array.isArray(e)&&(e=e.map(e=>e)),tV(t,["toolUsePromptTokensDetails"],e)}let d=t$(e,["trafficType"]);return null!=d&&tV(t,["trafficType"],d),t}(l)),null!=(u=t$(i,["goAway"]))&&tV(e,["goAway"],u),null!=(c=t$(i,["sessionResumptionUpdate"]))&&tV(e,["sessionResumptionUpdate"],c),null!=(p=t$(i,["voiceActivityDetectionSignal"]))&&tV(e,["voiceActivityDetectionSignal"],p),null!=(d=t$(i,["voiceActivity"]))&&tV(e,["voiceActivity"],(h={},null!=(f=t$(o=d,["type"]))&&tV(h,["voiceActivityType"],f),null!=(m=t$(o,["audioOffset"]))&&tV(h,["audioOffset"],m),h)),e))}else Object.assign(n,i);t(n)}class nk{constructor(e,t,r){this.apiClient=e,this.auth=t,this.webSocketFactory=r,this.music=new nP(this.apiClient,this.auth,this.webSocketFactory)}async connect(e){var t,r,n,i,o,s,a,l;let u,c;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 p=this.apiClient.getWebsocketBaseUrl(),d=this.apiClient.getApiVersion(),h=this.apiClient.getHeaders();e.config&&e.config.tools&&nb(e.config.tools)&&nI(h);let f=function(e){let t=new Headers;for(let[r,n]of Object.entries(e))t.append(r,n);return t}(h);if(this.apiClient.isVertexAI()){let e=this.apiClient.getProject(),t=this.apiClient.getLocation(),r=this.apiClient.getApiKey();this.apiClient.getCustomBaseUrl()&&!(e&&t||r)?u=p:(u=`${p}/ws/google.cloud.aiplatform.${d}.LlmBidiService/BidiGenerateContent`,await this.auth.addAuthHeaders(f,u))}else{let e=this.apiClient.getApiKey(),t="BidiGenerateContent",r="key";(null==e?void 0:e.startsWith("auth_tokens/"))&&(console.warn("Warning: Ephemeral token support is experimental and may change in future versions."),"v1alpha"!==d&&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",r="access_token"),u=`${p}/ws/google.ai.generativelanguage.${d}.GenerativeService.${t}?${r}=${e}`}let m=()=>{},g=new Promise(e=>{m=e}),y=e.callbacks,_=this.apiClient,E={onopen:function(){var e;null==(e=null==y?void 0:y.onopen)||e.call(y),m({})},onmessage:e=>{nN(_,y.onmessage,e)},onerror:null!=(t=null==y?void 0:y.onerror)?t:function(e){},onclose:null!=(r=null==y?void 0:y.onclose)?r:function(e){}},v=this.webSocketFactory.create(u,(c={},f.forEach((e,t)=>{c[t]=e}),c),E);v.connect(),await g;let A=rm(this.apiClient,e.model);if(this.apiClient.isVertexAI()&&A.startsWith("publishers/")){let e=this.apiClient.getProject(),t=this.apiClient.getLocation();e&&t&&(A=`projects/${e}/locations/${t}/`+A)}let T={};this.apiClient.isVertexAI()&&(null==(n=e.config)?void 0:n.responseModalities)===void 0&&(void 0===e.config?e.config={responseModalities:[ez.AUDIO]}:e.config.responseModalities=[ez.AUDIO]),(null==(i=e.config)?void 0:i.generationConfig)&&console.warn("Setting `LiveConnectConfig.generation_config` is deprecated, please set the fields on `LiveConnectConfig` directly. This will become an error in a future version (not before Q3 2025).");let C=null!=(s=null==(o=e.config)?void 0:o.tools)?s:[],S=[];for(let e of C)this.isCallableTool(e)?S.push(await e.tool()):S.push(e);S.length>0&&(e.config.tools=S);let b={model:A,config:e.config,callbacks:e.callbacks};if(this.apiClient.isVertexAI()){let e,t,r;a=this.apiClient,e={},null!=(t=t$(b,["model"]))&&tV(e,["setup","model"],rm(a,t)),null!=(r=t$(b,["config"]))&&tV(e,["config"],function(e,t){let r=t$(e,["generationConfig"]);void 0!==t&&null!=r&&tV(t,["setup","generationConfig"],function(e){let t={},r=t$(e,["modelSelectionConfig"]);null!=r&&tV(t,["modelConfig"],r);let n=t$(e,["responseJsonSchema"]);null!=n&&tV(t,["responseJsonSchema"],n);let i=t$(e,["audioTimestamp"]);null!=i&&tV(t,["audioTimestamp"],i);let o=t$(e,["candidateCount"]);null!=o&&tV(t,["candidateCount"],o);let s=t$(e,["enableAffectiveDialog"]);null!=s&&tV(t,["enableAffectiveDialog"],s);let a=t$(e,["frequencyPenalty"]);null!=a&&tV(t,["frequencyPenalty"],a);let l=t$(e,["logprobs"]);null!=l&&tV(t,["logprobs"],l);let u=t$(e,["maxOutputTokens"]);null!=u&&tV(t,["maxOutputTokens"],u);let c=t$(e,["mediaResolution"]);null!=c&&tV(t,["mediaResolution"],c);let p=t$(e,["presencePenalty"]);null!=p&&tV(t,["presencePenalty"],p);let d=t$(e,["responseLogprobs"]);null!=d&&tV(t,["responseLogprobs"],d);let h=t$(e,["responseMimeType"]);null!=h&&tV(t,["responseMimeType"],h);let f=t$(e,["responseModalities"]);null!=f&&tV(t,["responseModalities"],f);let m=t$(e,["responseSchema"]);null!=m&&tV(t,["responseSchema"],m);let g=t$(e,["routingConfig"]);null!=g&&tV(t,["routingConfig"],g);let y=t$(e,["seed"]);null!=y&&tV(t,["seed"],y);let _=t$(e,["speechConfig"]);null!=_&&tV(t,["speechConfig"],_);let E=t$(e,["stopSequences"]);null!=E&&tV(t,["stopSequences"],E);let v=t$(e,["temperature"]);null!=v&&tV(t,["temperature"],v);let A=t$(e,["thinkingConfig"]);null!=A&&tV(t,["thinkingConfig"],A);let T=t$(e,["topK"]);null!=T&&tV(t,["topK"],T);let C=t$(e,["topP"]);if(null!=C&&tV(t,["topP"],C),void 0!==t$(e,["enableEnhancedCivicAnswers"]))throw Error("enableEnhancedCivicAnswers parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return t}(r));let n=t$(e,["responseModalities"]);void 0!==t&&null!=n&&tV(t,["setup","generationConfig","responseModalities"],n);let i=t$(e,["temperature"]);void 0!==t&&null!=i&&tV(t,["setup","generationConfig","temperature"],i);let o=t$(e,["topP"]);void 0!==t&&null!=o&&tV(t,["setup","generationConfig","topP"],o);let s=t$(e,["topK"]);void 0!==t&&null!=s&&tV(t,["setup","generationConfig","topK"],s);let a=t$(e,["maxOutputTokens"]);void 0!==t&&null!=a&&tV(t,["setup","generationConfig","maxOutputTokens"],a);let l=t$(e,["mediaResolution"]);void 0!==t&&null!=l&&tV(t,["setup","generationConfig","mediaResolution"],l);let u=t$(e,["seed"]);void 0!==t&&null!=u&&tV(t,["setup","generationConfig","seed"],u);let c=t$(e,["speechConfig"]);void 0!==t&&null!=c&&tV(t,["setup","generationConfig","speechConfig"],rN(c));let p=t$(e,["thinkingConfig"]);void 0!==t&&null!=p&&tV(t,["setup","generationConfig","thinkingConfig"],p);let d=t$(e,["enableAffectiveDialog"]);void 0!==t&&null!=d&&tV(t,["setup","generationConfig","enableAffectiveDialog"],d);let h=t$(e,["systemInstruction"]);void 0!==t&&null!=h&&tV(t,["setup","systemInstruction"],function(e){let t={},r=t$(e,["parts"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>(function(e){let t={},r=t$(e,["mediaResolution"]);null!=r&&tV(t,["mediaResolution"],r);let n=t$(e,["codeExecutionResult"]);null!=n&&tV(t,["codeExecutionResult"],function(e){let t={},r=t$(e,["outcome"]);null!=r&&tV(t,["outcome"],r);let n=t$(e,["output"]);if(null!=n&&tV(t,["output"],n),void 0!==t$(e,["id"]))throw Error("id parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return t}(n));let i=t$(e,["executableCode"]);null!=i&&tV(t,["executableCode"],function(e){let t={},r=t$(e,["code"]);null!=r&&tV(t,["code"],r);let n=t$(e,["language"]);if(null!=n&&tV(t,["language"],n),void 0!==t$(e,["id"]))throw Error("id parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return t}(i));let o=t$(e,["fileData"]);null!=o&&tV(t,["fileData"],o);let s=t$(e,["functionCall"]);null!=s&&tV(t,["functionCall"],s);let a=t$(e,["functionResponse"]);null!=a&&tV(t,["functionResponse"],a);let l=t$(e,["inlineData"]);null!=l&&tV(t,["inlineData"],l);let u=t$(e,["text"]);null!=u&&tV(t,["text"],u);let c=t$(e,["thought"]);null!=c&&tV(t,["thought"],c);let p=t$(e,["thoughtSignature"]);null!=p&&tV(t,["thoughtSignature"],p);let d=t$(e,["videoMetadata"]);if(null!=d&&tV(t,["videoMetadata"],d),void 0!==t$(e,["toolCall"]))throw Error("toolCall parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");if(void 0!==t$(e,["toolResponse"]))throw Error("toolResponse parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");if(void 0!==t$(e,["partMetadata"]))throw Error("partMetadata parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return t})(e))),tV(t,["parts"],e)}let n=t$(e,["role"]);return null!=n&&tV(t,["role"],n),t}(rI(h)));let f=t$(e,["tools"]);if(void 0!==t&&null!=f){let e=rD(f);Array.isArray(e)&&(e=e.map(e=>(function(e){let t={},r=t$(e,["retrieval"]);null!=r&&tV(t,["retrieval"],r);let n=t$(e,["computerUse"]);if(null!=n&&tV(t,["computerUse"],function(e){let t={},r=t$(e,["environment"]);null!=r&&tV(t,["environment"],r);let n=t$(e,["excludedPredefinedFunctions"]);null!=n&&tV(t,["excludedPredefinedFunctions"],n);let i=t$(e,["enablePromptInjectionDetection"]);if(null!=i&&tV(t,["enablePromptInjectionDetection"],i),void 0!==t$(e,["disabledSafetyPolicies"]))throw Error("disabledSafetyPolicies parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return t}(n)),void 0!==t$(e,["fileSearch"]))throw Error("fileSearch parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");let i=t$(e,["googleSearch"]);null!=i&&tV(t,["googleSearch"],i);let o=t$(e,["googleMaps"]);null!=o&&tV(t,["googleMaps"],o);let s=t$(e,["codeExecution"]);null!=s&&tV(t,["codeExecution"],s);let a=t$(e,["enterpriseWebSearch"]);null!=a&&tV(t,["enterpriseWebSearch"],a);let l=t$(e,["functionDeclarations"]);if(null!=l){let e=l;Array.isArray(e)&&(e=e.map(e=>e)),tV(t,["functionDeclarations"],e)}let u=t$(e,["googleSearchRetrieval"]);null!=u&&tV(t,["googleSearchRetrieval"],u);let c=t$(e,["parallelAiSearch"]);null!=c&&tV(t,["parallelAiSearch"],c);let p=t$(e,["urlContext"]);null!=p&&tV(t,["urlContext"],p);let d=t$(e,["mcpServers"]);if(null!=d){let e=d;Array.isArray(e)&&(e=e.map(e=>(function(e){if(void 0!==t$(e,["name"]))throw Error("name parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");if(void 0!==t$(e,["streamableHttpTransport"]))throw Error("streamableHttpTransport parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return{}})(e))),tV(t,["mcpServers"],e)}return t})(rk(e)))),tV(t,["setup","tools"],e)}let m=t$(e,["sessionResumption"]);void 0!==t&&null!=m&&tV(t,["setup","sessionResumption"],m);let g=t$(e,["inputAudioTranscription"]);void 0!==t&&null!=g&&tV(t,["setup","inputAudioTranscription"],g);let y=t$(e,["outputAudioTranscription"]);void 0!==t&&null!=y&&tV(t,["setup","outputAudioTranscription"],y);let _=t$(e,["realtimeInputConfig"]);void 0!==t&&null!=_&&tV(t,["setup","realtimeInputConfig"],_);let E=t$(e,["contextWindowCompression"]);void 0!==t&&null!=E&&tV(t,["setup","contextWindowCompression"],E);let v=t$(e,["proactivity"]);void 0!==t&&null!=v&&tV(t,["setup","proactivity"],v);let A=t$(e,["explicitVadSignal"]);void 0!==t&&null!=A&&tV(t,["setup","explicitVadSignal"],A);let T=t$(e,["avatarConfig"]);void 0!==t&&null!=T&&tV(t,["setup","avatarConfig"],T);let C=t$(e,["safetySettings"]);if(void 0!==t&&null!=C){let e=C;Array.isArray(e)&&(e=e.map(e=>e)),tV(t,["setup","safetySettings"],e)}if(void 0!==t$(e,["translationConfig"]))throw Error("translationConfig parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return{}}(r,e)),T=e}else{let e,t,r;l=this.apiClient,e={},null!=(t=t$(b,["model"]))&&tV(e,["setup","model"],rm(l,t)),null!=(r=t$(b,["config"]))&&tV(e,["config"],function(e,t){let r=t$(e,["generationConfig"]);void 0!==t&&null!=r&&tV(t,["setup","generationConfig"],r);let n=t$(e,["responseModalities"]);void 0!==t&&null!=n&&tV(t,["setup","generationConfig","responseModalities"],n);let i=t$(e,["temperature"]);void 0!==t&&null!=i&&tV(t,["setup","generationConfig","temperature"],i);let o=t$(e,["topP"]);void 0!==t&&null!=o&&tV(t,["setup","generationConfig","topP"],o);let s=t$(e,["topK"]);void 0!==t&&null!=s&&tV(t,["setup","generationConfig","topK"],s);let a=t$(e,["maxOutputTokens"]);void 0!==t&&null!=a&&tV(t,["setup","generationConfig","maxOutputTokens"],a);let l=t$(e,["mediaResolution"]);void 0!==t&&null!=l&&tV(t,["setup","generationConfig","mediaResolution"],l);let u=t$(e,["seed"]);void 0!==t&&null!=u&&tV(t,["setup","generationConfig","seed"],u);let c=t$(e,["speechConfig"]);void 0!==t&&null!=c&&tV(t,["setup","generationConfig","speechConfig"],rN(c));let p=t$(e,["thinkingConfig"]);void 0!==t&&null!=p&&tV(t,["setup","generationConfig","thinkingConfig"],p);let d=t$(e,["enableAffectiveDialog"]);void 0!==t&&null!=d&&tV(t,["setup","generationConfig","enableAffectiveDialog"],d);let h=t$(e,["systemInstruction"]);void 0!==t&&null!=h&&tV(t,["setup","systemInstruction"],function(e){let t={},r=t$(e,["parts"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>{var t;let r,n,i,o,s,a,l,u,c,p,d,h,f,m,g;return r={},null!=(n=t$(t=e,["mediaResolution"]))&&tV(r,["mediaResolution"],n),null!=(i=t$(t,["codeExecutionResult"]))&&tV(r,["codeExecutionResult"],i),null!=(o=t$(t,["executableCode"]))&&tV(r,["executableCode"],o),null!=(s=t$(t,["fileData"]))&&tV(r,["fileData"],function(e){let t={};if(void 0!==t$(e,["displayName"]))throw Error("displayName parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let r=t$(e,["fileUri"]);null!=r&&tV(t,["fileUri"],r);let n=t$(e,["mimeType"]);return null!=n&&tV(t,["mimeType"],n),t}(s)),null!=(a=t$(t,["functionCall"]))&&tV(r,["functionCall"],function(e){let t={},r=t$(e,["id"]);null!=r&&tV(t,["id"],r);let n=t$(e,["args"]);null!=n&&tV(t,["args"],n);let i=t$(e,["name"]);if(null!=i&&tV(t,["name"],i),void 0!==t$(e,["partialArgs"]))throw Error("partialArgs parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["willContinue"]))throw Error("willContinue parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return t}(a)),null!=(l=t$(t,["functionResponse"]))&&tV(r,["functionResponse"],l),null!=(u=t$(t,["inlineData"]))&&tV(r,["inlineData"],nt(u)),null!=(c=t$(t,["text"]))&&tV(r,["text"],c),null!=(p=t$(t,["thought"]))&&tV(r,["thought"],p),null!=(d=t$(t,["thoughtSignature"]))&&tV(r,["thoughtSignature"],d),null!=(h=t$(t,["videoMetadata"]))&&tV(r,["videoMetadata"],h),null!=(f=t$(t,["toolCall"]))&&tV(r,["toolCall"],f),null!=(m=t$(t,["toolResponse"]))&&tV(r,["toolResponse"],m),null!=(g=t$(t,["partMetadata"]))&&tV(r,["partMetadata"],g),r})),tV(t,["parts"],e)}let n=t$(e,["role"]);return null!=n&&tV(t,["role"],n),t}(rI(h)));let f=t$(e,["tools"]);if(void 0!==t&&null!=f){let e=rD(f);Array.isArray(e)&&(e=e.map(e=>(function(e){let t,r,n,i={};if(void 0!==t$(e,["retrieval"]))throw Error("retrieval parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let o=t$(e,["computerUse"]);null!=o&&tV(i,["computerUse"],o);let s=t$(e,["fileSearch"]);null!=s&&tV(i,["fileSearch"],s);let a=t$(e,["googleSearch"]);null!=a&&tV(i,["googleSearch"],function(e){let t={},r=t$(e,["searchTypes"]);if(null!=r&&tV(t,["searchTypes"],r),void 0!==t$(e,["blockingConfidence"]))throw Error("blockingConfidence parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["excludeDomains"]))throw Error("excludeDomains parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let n=t$(e,["timeRangeFilter"]);return null!=n&&tV(t,["timeRangeFilter"],n),t}(a));let l=t$(e,["googleMaps"]);null!=l&&tV(i,["googleMaps"],(t={},null!=(r=t$(l,["authConfig"]))&&tV(t,["authConfig"],function(e){let t={},r=t$(e,["apiKey"]);if(null!=r&&tV(t,["apiKey"],r),void 0!==t$(e,["apiKeyConfig"]))throw Error("apiKeyConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["authType"]))throw Error("authType parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["googleServiceAccountConfig"]))throw Error("googleServiceAccountConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["httpBasicAuthConfig"]))throw Error("httpBasicAuthConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["oauthConfig"]))throw Error("oauthConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["oidcConfig"]))throw Error("oidcConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return t}(r)),null!=(n=t$(l,["enableWidget"]))&&tV(t,["enableWidget"],n),t));let u=t$(e,["codeExecution"]);if(null!=u&&tV(i,["codeExecution"],u),void 0!==t$(e,["enterpriseWebSearch"]))throw Error("enterpriseWebSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let c=t$(e,["functionDeclarations"]);if(null!=c){let e=c;Array.isArray(e)&&(e=e.map(e=>e)),tV(i,["functionDeclarations"],e)}let p=t$(e,["googleSearchRetrieval"]);if(null!=p&&tV(i,["googleSearchRetrieval"],p),void 0!==t$(e,["parallelAiSearch"]))throw Error("parallelAiSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let d=t$(e,["urlContext"]);null!=d&&tV(i,["urlContext"],d);let h=t$(e,["mcpServers"]);if(null!=h){let e=h;Array.isArray(e)&&(e=e.map(e=>e)),tV(i,["mcpServers"],e)}return i})(rk(e)))),tV(t,["setup","tools"],e)}let m=t$(e,["sessionResumption"]);void 0!==t&&null!=m&&tV(t,["setup","sessionResumption"],function(e){let t={},r=t$(e,["handle"]);if(null!=r&&tV(t,["handle"],r),void 0!==t$(e,["transparent"]))throw Error("transparent parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return t}(m));let g=t$(e,["inputAudioTranscription"]);void 0!==t&&null!=g&&tV(t,["setup","inputAudioTranscription"],ne(g));let y=t$(e,["outputAudioTranscription"]);void 0!==t&&null!=y&&tV(t,["setup","outputAudioTranscription"],ne(y));let _=t$(e,["realtimeInputConfig"]);void 0!==t&&null!=_&&tV(t,["setup","realtimeInputConfig"],_);let E=t$(e,["contextWindowCompression"]);void 0!==t&&null!=E&&tV(t,["setup","contextWindowCompression"],E);let v=t$(e,["proactivity"]);if(void 0!==t&&null!=v&&tV(t,["setup","proactivity"],v),void 0!==t$(e,["explicitVadSignal"]))throw Error("explicitVadSignal parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let A=t$(e,["avatarConfig"]);void 0!==t&&null!=A&&tV(t,["setup","avatarConfig"],A);let T=t$(e,["safetySettings"]);if(void 0!==t&&null!=T){let e=T;Array.isArray(e)&&(e=e.map(e=>(function(e){let t={},r=t$(e,["category"]);if(null!=r&&tV(t,["category"],r),void 0!==t$(e,["method"]))throw Error("method parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let n=t$(e,["threshold"]);return null!=n&&tV(t,["threshold"],n),t})(e))),tV(t,["setup","safetySettings"],e)}let C=t$(e,["translationConfig"]);return void 0!==t&&null!=C&&tV(t,["setup","generationConfig","translationConfig"],C),{}}(r,e)),T=e}return delete T.config,v.send(JSON.stringify(T)),new nx(v,this.apiClient)}isCallableTool(e){return"callTool"in e&&"function"==typeof e.callTool}}let nD={turnComplete:!0};class nx{constructor(e,t){this.conn=e,this.apiClient=t}tLiveClientContent(e,t){if(null!==t.turns&&void 0!==t.turns){let r=[];try{r=rw(t.turns),e.isVertexAI()||(r=r.map(e=>nr(e)))}catch(e){throw Error(`Failed to parse client content "turns", type: '${typeof t.turns}'`)}return{clientContent:{turns:r,turnComplete:t.turnComplete}}}return{clientContent:{turnComplete:t.turnComplete}}}tLiveClienttToolResponse(e,t){let r=[];if(null==t.functionResponses||0===(r=Array.isArray(t.functionResponses)?t.functionResponses:[t.functionResponses]).length)throw Error("functionResponses is required.");for(let t of r){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:r}}}sendClientContent(e){e=Object.assign(Object.assign({},nD),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={},r=t$(e,["media"]);if(null!=r){let e=ry(r);Array.isArray(e)&&(e=e.map(e=>e)),tV(t,["mediaChunks"],e)}let n=t$(e,["audio"]);null!=n&&tV(t,["audio"],rv(n));let i=t$(e,["audioStreamEnd"]);null!=i&&tV(t,["audioStreamEnd"],i);let o=t$(e,["video"]);null!=o&&tV(t,["video"],rE(o));let s=t$(e,["text"]);null!=s&&tV(t,["text"],s);let a=t$(e,["activityStart"]);null!=a&&tV(t,["activityStart"],a);let l=t$(e,["activityEnd"]);return null!=l&&tV(t,["activityEnd"],l),t}(e)}:{realtimeInput:function(e){let t={},r=t$(e,["media"]);if(null!=r){let e=ry(r);Array.isArray(e)&&(e=e.map(e=>nt(e))),tV(t,["mediaChunks"],e)}let n=t$(e,["audio"]);null!=n&&tV(t,["audio"],nt(rv(n)));let i=t$(e,["audioStreamEnd"]);null!=i&&tV(t,["audioStreamEnd"],i);let o=t$(e,["video"]);null!=o&&tV(t,["video"],nt(rE(o)));let s=t$(e,["text"]);null!=s&&tV(t,["text"],s);let a=t$(e,["activityStart"]);null!=a&&tV(t,["activityStart"],a);let l=t$(e,["activityEnd"]);return null!=l&&tV(t,["activityEnd"],l),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 nU(e){var t,r,n;if(null==(t=null==e?void 0:e.automaticFunctionCalling)?void 0:t.disable)return!0;let i=!1;for(let t of null!=(r=null==e?void 0:e.tools)?r:[])if(nG(t)){i=!0;break}if(!i)return!0;let o=null==(n=null==e?void 0:e.automaticFunctionCalling)?void 0:n.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 nG(e){return"callTool"in e&&"function"==typeof e.callTool}function nM(e){var t;let r=[];return(null==(t=null==e?void 0:e.config)?void 0:t.tools)&&e.config.tools.forEach((e,t)=>{nG(e)||e.functionDeclarations&&e.functionDeclarations.length>0&&r.push(t)}),r}function nj(e){var t;return!(null==(t=null==e?void 0:e.automaticFunctionCalling)?void 0:t.ignoreCallHistory)}class nL extends tH{constructor(e){super(),this.apiClient=e,this.embedContent=async e=>{if(!this.apiClient.isVertexAI())return e.model.includes("gemini-embedding-2")&&(e.contents=rw(e.contents)),await this.embedContentInternal(e);if(e.model.includes("gemini")&&"gemini-embedding-001"!==e.model||e.model.includes("maas")){let t=rw(e.contents);if(t.length>1)throw Error("The embedContent API for this model only supports one content at a time.");let r=Object.assign(Object.assign({},e),{content:t[0],embeddingApiType:tn.EMBED_CONTENT});return await this.embedContentInternal(r)}{let t=Object.assign(Object.assign({},e),{embeddingApiType:tn.PREDICT});return await this.embedContentInternal(t)}},this.generateContent=async e=>{var t,r,n,i,o,s,a,l;let u,c,p=await this.processParamsMaybeAddMcpUsage(e);if(this.maybeMoveToResponseJsonSchema(e),!(null!=(l=null==(a=null==(s=e.config)?void 0:s.tools)?void 0:a.some(e=>nG(e)))&&l)||nU(e.config))return await this.generateContentInternal(p);let d=nM(e);if(d.length>0){let e=d.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 h=rw(p.contents),f=null!=(n=null==(r=null==(t=p.config)?void 0:t.automaticFunctionCalling)?void 0:r.maximumRemoteCalls)?n:10,m=0;for(;m<f&&(u=await this.generateContentInternal(p)).functionCalls&&0!==u.functionCalls.length;){let t=u.candidates[0].content,r=[];for(let t of null!=(o=null==(i=e.config)?void 0:i.tools)?o:[])if(nG(t)){let e=await t.callTool(u.functionCalls);r.push(...e)}m++,c={role:"user",parts:r},p.contents=rw(p.contents),p.contents.push(t),p.contents.push(c),nj(p.config)&&(h.push(t),h.push(c))}return nj(p.config)&&(u.automaticFunctionCallingHistory=h),u},this.generateContentStream=async e=>{var t,r,n,i,o;if(this.maybeMoveToResponseJsonSchema(e),nU(e.config)){let t=await this.processParamsMaybeAddMcpUsage(e);return await this.generateContentStreamInternal(t)}let s=nM(e);if(s.length>0){let e=s.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 a=null==(n=null==(r=null==(t=null==e?void 0:e.config)?void 0:t.toolConfig)?void 0:r.functionCallingConfig)?void 0:n.streamFunctionCallArguments,l=null==(o=null==(i=null==e?void 0:e.config)?void 0:i.automaticFunctionCalling)?void 0:o.disable;if(a&&!l)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=>await this.generateImagesInternal(e).then(e=>{var t;let r,n=[];if(null==e?void 0:e.generatedImages)for(let i of e.generatedImages)i&&(null==i?void 0:i.safetyAttributes)&&(null==(t=null==i?void 0:i.safetyAttributes)?void 0:t.contentType)==="Positive Prompt"?r=null==i?void 0:i.safetyAttributes:n.push(i);return r?{generatedImages:n,positivePromptSafetyAttributes:r,sdkHttpResponse:e.sdkHttpResponse}:{generatedImages:n,sdkHttpResponse:e.sdkHttpResponse}}),this.list=async e=>{var t;let r={config:Object.assign(Object.assign({},{queryBase:!0}),null==e?void 0:e.config)};if(this.apiClient.isVertexAI()&&!r.config.queryBase)if(null==(t=r.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 r.config.filter="labels.tune-type:*";return new rY(tN.PAGED_ITEM_MODELS,e=>this.listInternal(e),await this.listInternal(r),r)},this.editImage=async e=>{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 r={model:e.model,image:e.image,upscaleFactor:e.upscaleFactor,config:t};return await this.upscaleImageInternal(r)},this.generateVideos=async e=>{var t,r,n,i,o,s;if((e.prompt||e.image||e.video)&&e.source)throw Error("Source and prompt/image/video are mutually exclusive. Please only use source.");return!this.apiClient.isVertexAI()&&((null==(t=e.video)?void 0:t.uri)&&(null==(r=e.video)?void 0:r.videoBytes)?e.video={uri:e.video.uri,mimeType:e.video.mimeType}:(null==(i=null==(n=e.source)?void 0:n.video)?void 0:i.uri)&&(null==(s=null==(o=e.source)?void 0:o.video)?void 0:s.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,r,n;let i=null==(t=e.config)?void 0:t.tools;if(!i)return e;let o=await Promise.all(i.map(async e=>nG(e)?await e.tool():e)),s={model:e.model,contents:e.contents,config:Object.assign(Object.assign({},e.config),{tools:o})};if(s.config.tools=o,e.config&&e.config.tools&&nb(e.config.tools)){let t=Object.assign({},null!=(n=null==(r=e.config.httpOptions)?void 0:r.headers)?n:{});0===Object.keys(t).length&&(t=this.apiClient.getDefaultHeaders()),nI(t),s.config.httpOptions=Object.assign(Object.assign({},e.config.httpOptions),{headers:t})}return s}async initAfcToolsMap(e){var t,r,n;let i=new Map;for(let o of null!=(r=null==(t=e.config)?void 0:t.tools)?r:[])if(nG(o))for(let e of null!=(n=(await o.tool()).functionDeclarations)?n:[]){if(!e.name)throw Error("Function declaration name is required.");if(i.has(e.name))throw Error(`Duplicate tool declaration name: ${e.name}`);i.set(e.name,o)}return i}async processAfcStream(e){var t,r,n;let i=null!=(n=null==(r=null==(t=e.config)?void 0:t.automaticFunctionCalling)?void 0:r.maximumRemoteCalls)?n:10,o=!1,s=0;return function(e,t,r){return r2(this,arguments,function*(){for(;s<i;){o&&(s++,o=!1);let m=yield r1(e.processParamsMaybeAddMcpUsage(r)),g=yield r1(e.generateContentStreamInternal(m)),y=[],_=[];try{for(var n,a,l,u,c,p,d,h=!0,f=(a=void 0,r4(g));!(n=(d=yield r1(f.next())).done);h=!0)if(u=d.value,h=!1,yield yield r1(u),u.candidates&&(null==(c=u.candidates[0])?void 0:c.content)){for(let e of(_.push(u.candidates[0].content),null!=(p=u.candidates[0].content.parts)?p:[]))if(s<i&&e.functionCall){if(!e.functionCall.name)throw Error("Function call name was not returned by the model.");if(t.has(e.functionCall.name)){let r=yield r1(t.get(e.functionCall.name).callTool([e.functionCall]));y.push(...r)}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){a={error:e}}finally{try{!h&&!n&&(l=f.return)&&(yield r1(l.call(f)))}finally{if(a)throw a.error}}if(y.length>0){o=!0;let e=new tX;e.candidates=[{content:{role:"user",parts:y}}],yield yield r1(e);let t=[];t.push(..._),t.push({role:"user",parts:y});let n=rw(r.contents).concat(t);r.contents=n}else break}})}(this,await this.initAfcToolsMap(e),e)}async generateContentInternal(e){var t,r,n,i;let o="",s={};if(this.apiClient.isVertexAI()){let n=no(this.apiClient,e);return o=tB("{model}:generateContent",n._url),s=n._query,delete n._url,delete n._query,this.apiClient.request({path:o,queryParams:s,body:JSON.stringify(n),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.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=na(e),r=new tX;return Object.assign(r,t),r})}{let t=ni(this.apiClient,e);return o=tB("{model}:generateContent",t._url),s=t._query,delete t._url,delete t._query,this.apiClient.request({path:o,queryParams:s,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null==(n=e.config)?void 0:n.httpOptions,abortSignal:null==(i=e.config)?void 0:i.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=ns(e),r=new tX;return Object.assign(r,t),r})}}async generateContentStreamInternal(e){var t,r,n,i;let o="",s={};if(this.apiClient.isVertexAI()){let n=no(this.apiClient,e);return o=tB("{model}:streamGenerateContent?alt=sse",n._url),s=n._query,delete n._url,delete n._query,this.apiClient.requestStream({path:o,queryParams:s,body:JSON.stringify(n),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(function(t){return r2(this,arguments,function*(){var r,n,i,o;try{for(var s,a=!0,l=r4(t);!(r=(s=yield r1(l.next())).done);a=!0){o=s.value,a=!1;let t=na((yield r1(o.json())),e);t.sdkHttpResponse={headers:o.headers};let r=new tX;Object.assign(r,t),yield yield r1(r)}}catch(e){n={error:e}}finally{try{!a&&!r&&(i=l.return)&&(yield r1(i.call(l)))}finally{if(n)throw n.error}}})})}{let t=ni(this.apiClient,e);return o=tB("{model}:streamGenerateContent?alt=sse",t._url),s=t._query,delete t._url,delete t._query,this.apiClient.requestStream({path:o,queryParams:s,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null==(n=e.config)?void 0:n.httpOptions,abortSignal:null==(i=e.config)?void 0:i.abortSignal}).then(function(t){return r2(this,arguments,function*(){var r,n,i,o;try{for(var s,a=!0,l=r4(t);!(r=(s=yield r1(l.next())).done);a=!0){o=s.value,a=!1;let t=ns((yield r1(o.json())),e);t.sdkHttpResponse={headers:o.headers};let r=new tX;Object.assign(r,t),yield yield r1(r)}}catch(e){n={error:e}}finally{try{!a&&!r&&(i=l.return)&&(yield r1(i.call(l)))}finally{if(n)throw n.error}}})})}}async embedContentInternal(e){var t,r,n,i,o;let s="",a={};if(this.apiClient.isVertexAI()){let n=function(e,t,r){let n={},i=t$(t,["model"]);null!=i&&tV(n,["_url","model"],rm(e,i));let o=t$(r,["embeddingApiType"]);if(void 0===o&&(o="PREDICT"),"PREDICT"===o){let r=t$(t,["contents"]);if(null!=r){let t=rO(e,r);Array.isArray(t)&&(t=t.map(e=>e)),tV(n,["instances[]","content"],t)}}let s=t$(r,["embeddingApiType"]);if(void 0===s&&(s="PREDICT"),"EMBED_CONTENT"===s){let e=t$(t,["content"]);null!=e&&tV(n,["content"],nn(rI(e)))}let a=t$(t,["config"]);return null!=a&&function(e,t,r){let n=t$(r,["embeddingApiType"]);if(void 0===n&&(n="PREDICT"),"PREDICT"===n){let r=t$(e,["taskType"]);void 0!==t&&null!=r&&tV(t,["instances[]","task_type"],r)}else if("EMBED_CONTENT"===n){let r=t$(e,["taskType"]);void 0!==t&&null!=r&&tV(t,["embedContentConfig","taskType"],r)}let i=t$(r,["embeddingApiType"]);if(void 0===i&&(i="PREDICT"),"PREDICT"===i){let r=t$(e,["title"]);void 0!==t&&null!=r&&tV(t,["instances[]","title"],r)}else if("EMBED_CONTENT"===i){let r=t$(e,["title"]);void 0!==t&&null!=r&&tV(t,["embedContentConfig","title"],r)}let o=t$(r,["embeddingApiType"]);if(void 0===o&&(o="PREDICT"),"PREDICT"===o){let r=t$(e,["outputDimensionality"]);void 0!==t&&null!=r&&tV(t,["parameters","outputDimensionality"],r)}else if("EMBED_CONTENT"===o){let r=t$(e,["outputDimensionality"]);void 0!==t&&null!=r&&tV(t,["embedContentConfig","outputDimensionality"],r)}let s=t$(r,["embeddingApiType"]);if(void 0===s&&(s="PREDICT"),"PREDICT"===s){let r=t$(e,["mimeType"]);void 0!==t&&null!=r&&tV(t,["instances[]","mimeType"],r)}let a=t$(r,["embeddingApiType"]);if(void 0===a&&(a="PREDICT"),"PREDICT"===a){let r=t$(e,["autoTruncate"]);void 0!==t&&null!=r&&tV(t,["parameters","autoTruncate"],r)}else if("EMBED_CONTENT"===a){let r=t$(e,["autoTruncate"]);void 0!==t&&null!=r&&tV(t,["embedContentConfig","autoTruncate"],r)}let l=t$(r,["embeddingApiType"]);if(void 0===l&&(l="PREDICT"),"EMBED_CONTENT"===l){let r=t$(e,["documentOcr"]);void 0!==t&&null!=r&&tV(t,["embedContentConfig","documentOcr"],r)}let u=t$(r,["embeddingApiType"]);if(void 0===u&&(u="PREDICT"),"EMBED_CONTENT"===u){let r=t$(e,["audioTrackExtraction"]);void 0!==t&&null!=r&&tV(t,["embedContentConfig","audioTrackExtraction"],r)}}(a,n,r),n}(this.apiClient,e,e);return s=tB((o=e.model).includes("gemini")&&"gemini-embedding-001"!==o||o.includes("maas")?"{model}:embedContent":"{model}:predict",n._url),a=n._query,delete n._url,delete n._query,this.apiClient.request({path:s,queryParams:a,body:JSON.stringify(n),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(t=>{let r=function(e,t){let r={},n=t$(e,["sdkHttpResponse"]);null!=n&&tV(r,["sdkHttpResponse"],n);let i=t$(e,["predictions[]","embeddings"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>{var t;let r,n,i,o,s,a;return r={},null!=(n=t$(e,["values"]))&&tV(r,["values"],n),null!=(i=t$(e,["statistics"]))&&tV(r,["statistics"],(o={},null!=(s=t$(t=i,["truncated"]))&&tV(o,["truncated"],s),null!=(a=t$(t,["token_count"]))&&tV(o,["tokenCount"],a),o)),r})),tV(r,["embeddings"],e)}let o=t$(e,["metadata"]);if(null!=o&&tV(r,["metadata"],o),t&&"EMBED_CONTENT"===t$(t,["embeddingApiType"])){let t=t$(e,["embedding"]),n=t$(e,["usageMetadata"]),i=t$(e,["truncated"]);if(t){let e={};n&&n.promptTokenCount&&(e.tokenCount=n.promptTokenCount),i&&(e.truncated=i),t.statistics=e,tV(r,["embeddings"],[t])}}return r}(t,e),n=new tz;return Object.assign(n,r),n})}{let t=function(e,t){let r={},n=t$(t,["model"]);null!=n&&tV(r,["_url","model"],rm(e,n));let i=t$(t,["contents"]);if(null!=i){let t=rO(e,i);Array.isArray(t)&&(t=t.map(e=>e)),tV(r,["requests[]","content"],t)}let o=t$(t,["content"]);null!=o&&nr(rI(o));let s=t$(t,["config"]);null!=s&&function(e,t){let r=t$(e,["taskType"]);void 0!==t&&null!=r&&tV(t,["requests[]","taskType"],r);let n=t$(e,["title"]);void 0!==t&&null!=n&&tV(t,["requests[]","title"],n);let i=t$(e,["outputDimensionality"]);if(void 0!==t&&null!=i&&tV(t,["requests[]","outputDimensionality"],i),void 0!==t$(e,["mimeType"]))throw Error("mimeType parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["autoTruncate"]))throw Error("autoTruncate parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["documentOcr"]))throw Error("documentOcr parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["audioTrackExtraction"]))throw Error("audioTrackExtraction parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.")}(s,r);let a=t$(t,["model"]);return void 0!==a&&tV(r,["requests[]","model"],rm(e,a)),r}(this.apiClient,e);return s=tB("{model}:batchEmbedContents",t._url),a=t._query,delete t._url,delete t._query,this.apiClient.request({path:s,queryParams:a,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null==(n=e.config)?void 0:n.httpOptions,abortSignal:null==(i=e.config)?void 0:i.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=function(e){let t={},r=t$(e,["sdkHttpResponse"]);null!=r&&tV(t,["sdkHttpResponse"],r);let n=t$(e,["embeddings"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>e)),tV(t,["embeddings"],e)}let i=t$(e,["metadata"]);return null!=i&&tV(t,["metadata"],i),t}(e),r=new tz;return Object.assign(r,t),r})}}async generateImagesInternal(e){var t,r,n,i,o,s;let a="",l={};if(this.apiClient.isVertexAI()){let n,i,s,u,c,p,d,h,f,m,g,y,_,E,v,A,T,C,S,b,I,O=(o=this.apiClient,n={},null!=(i=t$(e,["model"]))&&tV(n,["_url","model"],rm(o,i)),null!=(s=t$(e,["prompt"]))&&tV(n,["instances[0]","prompt"],s),null!=(u=t$(e,["config"]))&&(c=t$(u,["outputGcsUri"]),void 0!==n&&null!=c&&tV(n,["parameters","storageUri"],c),p=t$(u,["negativePrompt"]),void 0!==n&&null!=p&&tV(n,["parameters","negativePrompt"],p),d=t$(u,["numberOfImages"]),void 0!==n&&null!=d&&tV(n,["parameters","sampleCount"],d),h=t$(u,["aspectRatio"]),void 0!==n&&null!=h&&tV(n,["parameters","aspectRatio"],h),f=t$(u,["guidanceScale"]),void 0!==n&&null!=f&&tV(n,["parameters","guidanceScale"],f),m=t$(u,["seed"]),void 0!==n&&null!=m&&tV(n,["parameters","seed"],m),g=t$(u,["safetyFilterLevel"]),void 0!==n&&null!=g&&tV(n,["parameters","safetySetting"],g),y=t$(u,["personGeneration"]),void 0!==n&&null!=y&&tV(n,["parameters","personGeneration"],y),_=t$(u,["includeSafetyAttributes"]),void 0!==n&&null!=_&&tV(n,["parameters","includeSafetyAttributes"],_),E=t$(u,["includeRaiReason"]),void 0!==n&&null!=E&&tV(n,["parameters","includeRaiReason"],E),v=t$(u,["language"]),void 0!==n&&null!=v&&tV(n,["parameters","language"],v),A=t$(u,["outputMimeType"]),void 0!==n&&null!=A&&tV(n,["parameters","outputOptions","mimeType"],A),T=t$(u,["outputCompressionQuality"]),void 0!==n&&null!=T&&tV(n,["parameters","outputOptions","compressionQuality"],T),C=t$(u,["addWatermark"]),void 0!==n&&null!=C&&tV(n,["parameters","addWatermark"],C),S=t$(u,["labels"]),void 0!==n&&null!=S&&tV(n,["labels"],S),b=t$(u,["imageSize"]),void 0!==n&&null!=b&&tV(n,["parameters","sampleImageSize"],b),I=t$(u,["enhancePrompt"]),void 0!==n&&null!=I&&tV(n,["parameters","enhancePrompt"],I)),n);return a=tB("{model}:predict",O._url),l=O._query,delete O._url,delete O._query,this.apiClient.request({path:a,queryParams:l,body:JSON.stringify(O),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.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={},r=t$(e,["sdkHttpResponse"]);null!=r&&tV(t,["sdkHttpResponse"],r);let n=t$(e,["predictions"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>nl(e))),tV(t,["generatedImages"],e)}let i=t$(e,["positivePromptSafetyAttributes"]);return null!=i&&tV(t,["positivePromptSafetyAttributes"],nm(i)),t}(e),r=new tQ;return Object.assign(r,t),r})}{let t,r,o,u,c=(s=this.apiClient,t={},null!=(r=t$(e,["model"]))&&tV(t,["_url","model"],rm(s,r)),null!=(o=t$(e,["prompt"]))&&tV(t,["instances[0]","prompt"],o),null!=(u=t$(e,["config"]))&&function(e,t){if(void 0!==t$(e,["outputGcsUri"]))throw Error("outputGcsUri parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["negativePrompt"]))throw Error("negativePrompt parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let r=t$(e,["numberOfImages"]);void 0!==t&&null!=r&&tV(t,["parameters","sampleCount"],r);let n=t$(e,["aspectRatio"]);void 0!==t&&null!=n&&tV(t,["parameters","aspectRatio"],n);let i=t$(e,["guidanceScale"]);if(void 0!==t&&null!=i&&tV(t,["parameters","guidanceScale"],i),void 0!==t$(e,["seed"]))throw Error("seed parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let o=t$(e,["safetyFilterLevel"]);void 0!==t&&null!=o&&tV(t,["parameters","safetySetting"],o);let s=t$(e,["personGeneration"]);void 0!==t&&null!=s&&tV(t,["parameters","personGeneration"],s);let a=t$(e,["includeSafetyAttributes"]);void 0!==t&&null!=a&&tV(t,["parameters","includeSafetyAttributes"],a);let l=t$(e,["includeRaiReason"]);void 0!==t&&null!=l&&tV(t,["parameters","includeRaiReason"],l);let u=t$(e,["language"]);void 0!==t&&null!=u&&tV(t,["parameters","language"],u);let c=t$(e,["outputMimeType"]);void 0!==t&&null!=c&&tV(t,["parameters","outputOptions","mimeType"],c);let p=t$(e,["outputCompressionQuality"]);if(void 0!==t&&null!=p&&tV(t,["parameters","outputOptions","compressionQuality"],p),void 0!==t$(e,["addWatermark"]))throw Error("addWatermark parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["labels"]))throw Error("labels parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let d=t$(e,["imageSize"]);if(void 0!==t&&null!=d&&tV(t,["parameters","sampleImageSize"],d),void 0!==t$(e,["enhancePrompt"]))throw Error("enhancePrompt parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.")}(u,t),t);return a=tB("{model}:predict",c._url),l=c._query,delete c._url,delete c._query,this.apiClient.request({path:a,queryParams:l,body:JSON.stringify(c),httpMethod:"POST",httpOptions:null==(n=e.config)?void 0:n.httpOptions,abortSignal:null==(i=e.config)?void 0:i.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=function(e){let t={},r=t$(e,["sdkHttpResponse"]);null!=r&&tV(t,["sdkHttpResponse"],r);let n=t$(e,["predictions"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>{var t,r;let n,i,o,s,a,l,u;return n={},null!=(i=t$(t=e,["_self"]))&&tV(n,["image"],(o={},null!=(s=t$(r=i,["bytesBase64Encoded"]))&&tV(o,["imageBytes"],tJ(s)),null!=(a=t$(r,["mimeType"]))&&tV(o,["mimeType"],a),o)),null!=(l=t$(t,["raiFilteredReason"]))&&tV(n,["raiFilteredReason"],l),null!=(u=t$(t,["_self"]))&&tV(n,["safetyAttributes"],nf(u)),n})),tV(t,["generatedImages"],e)}let i=t$(e,["positivePromptSafetyAttributes"]);return null!=i&&tV(t,["positivePromptSafetyAttributes"],nf(i)),t}(e),r=new tQ;return Object.assign(r,t),r})}}async editImageInternal(e){var t,r;let n="",i={};if(this.apiClient.isVertexAI()){let o=function(e,t){let r,n,i,o,s,a,l,u,c,p,d,h,f,m,g,y,_,E={},v=t$(t,["model"]);null!=v&&tV(E,["_url","model"],rm(e,v));let A=t$(t,["prompt"]);null!=A&&tV(E,["instances[0]","prompt"],A);let T=t$(t,["referenceImages"]);if(null!=T){let e=T;Array.isArray(e)&&(e=e.map(e=>(function(e){let t,r,n,i,o,s,a,l={},u=t$(e,["referenceImage"]);null!=u&&tV(l,["referenceImage"],np(u));let c=t$(e,["referenceId"]);null!=c&&tV(l,["referenceId"],c);let p=t$(e,["referenceType"]);null!=p&&tV(l,["referenceType"],p);let d=t$(e,["maskImageConfig"]);null!=d&&tV(l,["maskImageConfig"],(t={},null!=(r=t$(d,["maskMode"]))&&tV(t,["maskMode"],r),null!=(n=t$(d,["segmentationClasses"]))&&tV(t,["maskClasses"],n),null!=(i=t$(d,["maskDilation"]))&&tV(t,["dilation"],i),t));let h=t$(e,["controlImageConfig"]);null!=h&&tV(l,["controlImageConfig"],(o={},null!=(s=t$(h,["controlType"]))&&tV(o,["controlType"],s),null!=(a=t$(h,["enableControlImageComputation"]))&&tV(o,["computeControl"],a),o));let f=t$(e,["styleImageConfig"]);null!=f&&tV(l,["styleImageConfig"],f);let m=t$(e,["subjectImageConfig"]);return null!=m&&tV(l,["subjectImageConfig"],m),l})(e))),tV(E,["instances[0]","referenceImages"],e)}let C=t$(t,["config"]);return null!=C&&(r=t$(C,["outputGcsUri"]),void 0!==E&&null!=r&&tV(E,["parameters","storageUri"],r),n=t$(C,["negativePrompt"]),void 0!==E&&null!=n&&tV(E,["parameters","negativePrompt"],n),i=t$(C,["numberOfImages"]),void 0!==E&&null!=i&&tV(E,["parameters","sampleCount"],i),o=t$(C,["aspectRatio"]),void 0!==E&&null!=o&&tV(E,["parameters","aspectRatio"],o),s=t$(C,["guidanceScale"]),void 0!==E&&null!=s&&tV(E,["parameters","guidanceScale"],s),a=t$(C,["seed"]),void 0!==E&&null!=a&&tV(E,["parameters","seed"],a),l=t$(C,["safetyFilterLevel"]),void 0!==E&&null!=l&&tV(E,["parameters","safetySetting"],l),u=t$(C,["personGeneration"]),void 0!==E&&null!=u&&tV(E,["parameters","personGeneration"],u),c=t$(C,["includeSafetyAttributes"]),void 0!==E&&null!=c&&tV(E,["parameters","includeSafetyAttributes"],c),p=t$(C,["includeRaiReason"]),void 0!==E&&null!=p&&tV(E,["parameters","includeRaiReason"],p),d=t$(C,["language"]),void 0!==E&&null!=d&&tV(E,["parameters","language"],d),h=t$(C,["outputMimeType"]),void 0!==E&&null!=h&&tV(E,["parameters","outputOptions","mimeType"],h),f=t$(C,["outputCompressionQuality"]),void 0!==E&&null!=f&&tV(E,["parameters","outputOptions","compressionQuality"],f),m=t$(C,["addWatermark"]),void 0!==E&&null!=m&&tV(E,["parameters","addWatermark"],m),g=t$(C,["labels"]),void 0!==E&&null!=g&&tV(E,["labels"],g),y=t$(C,["editMode"]),void 0!==E&&null!=y&&tV(E,["parameters","editMode"],y),_=t$(C,["baseSteps"]),void 0!==E&&null!=_&&tV(E,["parameters","editConfig","baseSteps"],_)),E}(this.apiClient,e);return n=tB("{model}:predict",o._url),i=o._query,delete o._url,delete o._query,this.apiClient.request({path:n,queryParams:i,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.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={},r=t$(e,["sdkHttpResponse"]);null!=r&&tV(t,["sdkHttpResponse"],r);let n=t$(e,["predictions"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>nl(e))),tV(t,["generatedImages"],e)}return t}(e),r=new tZ;return Object.assign(r,t),r})}throw Error("This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).")}async upscaleImageInternal(e){var t,r,n;let i="",o={};if(this.apiClient.isVertexAI()){let s,a,l,u,c,p,d,h,f,m,g,y,_,E,v,A,T=(n=this.apiClient,s={},null!=(a=t$(e,["model"]))&&tV(s,["_url","model"],rm(n,a)),null!=(l=t$(e,["image"]))&&tV(s,["instances[0]","image"],np(l)),null!=(u=t$(e,["upscaleFactor"]))&&tV(s,["parameters","upscaleConfig","upscaleFactor"],u),null!=(c=t$(e,["config"]))&&(p=t$(c,["outputGcsUri"]),void 0!==s&&null!=p&&tV(s,["parameters","storageUri"],p),d=t$(c,["safetyFilterLevel"]),void 0!==s&&null!=d&&tV(s,["parameters","safetySetting"],d),h=t$(c,["personGeneration"]),void 0!==s&&null!=h&&tV(s,["parameters","personGeneration"],h),f=t$(c,["includeRaiReason"]),void 0!==s&&null!=f&&tV(s,["parameters","includeRaiReason"],f),m=t$(c,["outputMimeType"]),void 0!==s&&null!=m&&tV(s,["parameters","outputOptions","mimeType"],m),g=t$(c,["outputCompressionQuality"]),void 0!==s&&null!=g&&tV(s,["parameters","outputOptions","compressionQuality"],g),y=t$(c,["enhanceInputImage"]),void 0!==s&&null!=y&&tV(s,["parameters","upscaleConfig","enhanceInputImage"],y),_=t$(c,["imagePreservationFactor"]),void 0!==s&&null!=_&&tV(s,["parameters","upscaleConfig","imagePreservationFactor"],_),E=t$(c,["labels"]),void 0!==s&&null!=E&&tV(s,["labels"],E),v=t$(c,["numberOfImages"]),void 0!==s&&null!=v&&tV(s,["parameters","sampleCount"],v),A=t$(c,["mode"]),void 0!==s&&null!=A&&tV(s,["parameters","mode"],A)),s);return i=tB("{model}:predict",T._url),o=T._query,delete T._url,delete T._query,this.apiClient.request({path:i,queryParams:o,body:JSON.stringify(T),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.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={},r=t$(e,["sdkHttpResponse"]);null!=r&&tV(t,["sdkHttpResponse"],r);let n=t$(e,["predictions"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>nl(e))),tV(t,["generatedImages"],e)}return t}(e),r=new t0;return Object.assign(r,t),r})}throw Error("This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).")}async recontextImage(e){var t,r,n;let i="",o={};if(this.apiClient.isVertexAI()){let s,a,l,u,c,p,d,h,f,m,g,y,_,E,v,A=(n=this.apiClient,s={},null!=(a=t$(e,["model"]))&&tV(s,["_url","model"],rm(n,a)),null!=(l=t$(e,["source"]))&&function(e,t){let r=t$(e,["prompt"]);void 0!==t&&null!=r&&tV(t,["instances[0]","prompt"],r);let n=t$(e,["personImage"]);void 0!==t&&null!=n&&tV(t,["instances[0]","personImage","image"],np(n));let i=t$(e,["productImages"]);if(void 0!==t&&null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>{let t,r;return t={},null!=(r=t$(e,["productImage"]))&&tV(t,["image"],np(r)),t})),tV(t,["instances[0]","productImages"],e)}}(l,s),null!=(u=t$(e,["config"]))&&(c=t$(u,["numberOfImages"]),void 0!==s&&null!=c&&tV(s,["parameters","sampleCount"],c),p=t$(u,["baseSteps"]),void 0!==s&&null!=p&&tV(s,["parameters","baseSteps"],p),d=t$(u,["outputGcsUri"]),void 0!==s&&null!=d&&tV(s,["parameters","storageUri"],d),h=t$(u,["seed"]),void 0!==s&&null!=h&&tV(s,["parameters","seed"],h),f=t$(u,["safetyFilterLevel"]),void 0!==s&&null!=f&&tV(s,["parameters","safetySetting"],f),m=t$(u,["personGeneration"]),void 0!==s&&null!=m&&tV(s,["parameters","personGeneration"],m),g=t$(u,["addWatermark"]),void 0!==s&&null!=g&&tV(s,["parameters","addWatermark"],g),y=t$(u,["outputMimeType"]),void 0!==s&&null!=y&&tV(s,["parameters","outputOptions","mimeType"],y),_=t$(u,["outputCompressionQuality"]),void 0!==s&&null!=_&&tV(s,["parameters","outputOptions","compressionQuality"],_),E=t$(u,["enhancePrompt"]),void 0!==s&&null!=E&&tV(s,["parameters","enhancePrompt"],E),v=t$(u,["labels"]),void 0!==s&&null!=v&&tV(s,["labels"],v)),s);return i=tB("{model}:predict",A._url),o=A._query,delete A._url,delete A._query,this.apiClient.request({path:i,queryParams:o,body:JSON.stringify(A),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json()).then(e=>{let t=function(e){let t={},r=t$(e,["predictions"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>nl(e))),tV(t,["generatedImages"],e)}return t}(e),r=new t1;return Object.assign(r,t),r})}throw Error("This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).")}async segmentImage(e){var t,r,n,i,o;let s="",a={};if(this.apiClient.isVertexAI()){let l,u,c,p,d,h,f,m,g,y,_,E,v,A,T,C=(n=this.apiClient,h={},null!=(f=t$(e,["model"]))&&tV(h,["_url","model"],rm(n,f)),null!=(m=t$(e,["source"]))&&(i=m,o=h,c=t$(i,["prompt"]),void 0!==o&&null!=c&&tV(o,["instances[0]","prompt"],c),p=t$(i,["image"]),void 0!==o&&null!=p&&tV(o,["instances[0]","image"],np(p)),d=t$(i,["scribbleImage"]),void 0!==o&&null!=d&&tV(o,["instances[0]","scribble"],(l={},null!=(u=t$(d,["image"]))&&tV(l,["image"],np(u)),l))),null!=(g=t$(e,["config"]))&&(y=t$(g,["mode"]),void 0!==h&&null!=y&&tV(h,["parameters","mode"],y),_=t$(g,["maxPredictions"]),void 0!==h&&null!=_&&tV(h,["parameters","maxPredictions"],_),E=t$(g,["confidenceThreshold"]),void 0!==h&&null!=E&&tV(h,["parameters","confidenceThreshold"],E),v=t$(g,["maskDilation"]),void 0!==h&&null!=v&&tV(h,["parameters","maskDilation"],v),A=t$(g,["binaryColorThreshold"]),void 0!==h&&null!=A&&tV(h,["parameters","binaryColorThreshold"],A),T=t$(g,["labels"]),void 0!==h&&null!=T&&tV(h,["labels"],T)),h);return s=tB("{model}:predict",C._url),a=C._query,delete C._url,delete C._query,this.apiClient.request({path:s,queryParams:a,body:JSON.stringify(C),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json()).then(e=>{let t=function(e){let t={},r=t$(e,["predictions"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>(function(e){let t={},r=t$(e,["_self"]);null!=r&&tV(t,["mask"],nu(r));let n=t$(e,["labels"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>e)),tV(t,["labels"],e)}return t})(e))),tV(t,["generatedMasks"],e)}return t}(e),r=new t2;return Object.assign(r,t),r})}throw Error("This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).")}async get(e){var t,r,n,i,o,s;let a="",l={};if(this.apiClient.isVertexAI()){let n,i,s=(o=this.apiClient,n={},null!=(i=t$(e,["model"]))&&tV(n,["_url","name"],rm(o,i)),n);return a=tB("{name}",s._url),l=s._query,delete s._url,delete s._query,this.apiClient.request({path:a,queryParams:l,body:JSON.stringify(s),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json()).then(e=>nh(e))}{let t,r,o=(s=this.apiClient,t={},null!=(r=t$(e,["model"]))&&tV(t,["_url","name"],rm(s,r)),t);return a=tB("{name}",o._url),l=o._query,delete o._url,delete o._query,this.apiClient.request({path:a,queryParams:l,body:JSON.stringify(o),httpMethod:"GET",httpOptions:null==(n=e.config)?void 0:n.httpOptions,abortSignal:null==(i=e.config)?void 0:i.abortSignal}).then(e=>e.json()).then(e=>nd(e))}}async listInternal(e){var t,r,n,i,o,s;let a="",l={};if(this.apiClient.isVertexAI()){let n,i,s,u,c,p,d=(o=this.apiClient,n={},null!=(i=t$(e,["config"]))&&(s=t$(i,["pageSize"]),void 0!==n&&null!=s&&tV(n,["_query","pageSize"],s),u=t$(i,["pageToken"]),void 0!==n&&null!=u&&tV(n,["_query","pageToken"],u),c=t$(i,["filter"]),void 0!==n&&null!=c&&tV(n,["_query","filter"],c),p=t$(i,["queryBase"]),void 0!==n&&null!=p&&tV(n,["_url","models_url"],rL(o,p))),n);return a=tB("{models_url}",d._url),l=d._query,delete d._url,delete d._query,this.apiClient.request({path:a,queryParams:l,body:JSON.stringify(d),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.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={},r=t$(e,["sdkHttpResponse"]);null!=r&&tV(t,["sdkHttpResponse"],r);let n=t$(e,["nextPageToken"]);null!=n&&tV(t,["nextPageToken"],n);let i=t$(e,["_self"]);if(null!=i){let e=rF(i);Array.isArray(e)&&(e=e.map(e=>nh(e))),tV(t,["models"],e)}return t}(e),r=new t4;return Object.assign(r,t),r})}{let t,r,o,u,c,p,d=(s=this.apiClient,t={},null!=(r=t$(e,["config"]))&&(o=t$(r,["pageSize"]),void 0!==t&&null!=o&&tV(t,["_query","pageSize"],o),u=t$(r,["pageToken"]),void 0!==t&&null!=u&&tV(t,["_query","pageToken"],u),c=t$(r,["filter"]),void 0!==t&&null!=c&&tV(t,["_query","filter"],c),p=t$(r,["queryBase"]),void 0!==t&&null!=p&&tV(t,["_url","models_url"],rL(s,p))),t);return a=tB("{models_url}",d._url),l=d._query,delete d._url,delete d._query,this.apiClient.request({path:a,queryParams:l,body:JSON.stringify(d),httpMethod:"GET",httpOptions:null==(n=e.config)?void 0:n.httpOptions,abortSignal:null==(i=e.config)?void 0:i.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=function(e){let t={},r=t$(e,["sdkHttpResponse"]);null!=r&&tV(t,["sdkHttpResponse"],r);let n=t$(e,["nextPageToken"]);null!=n&&tV(t,["nextPageToken"],n);let i=t$(e,["_self"]);if(null!=i){let e=rF(i);Array.isArray(e)&&(e=e.map(e=>nd(e))),tV(t,["models"],e)}return t}(e),r=new t4;return Object.assign(r,t),r})}}async update(e){var t,r,n,i,o,s;let a="",l={};if(this.apiClient.isVertexAI()){let n,i,s,u,c,p,d=(o=this.apiClient,n={},null!=(i=t$(e,["model"]))&&tV(n,["_url","model"],rm(o,i)),null!=(s=t$(e,["config"]))&&(u=t$(s,["displayName"]),void 0!==n&&null!=u&&tV(n,["displayName"],u),c=t$(s,["description"]),void 0!==n&&null!=c&&tV(n,["description"],c),p=t$(s,["defaultCheckpointId"]),void 0!==n&&null!=p&&tV(n,["defaultCheckpointId"],p)),n);return a=tB("{model}",d._url),l=d._query,delete d._url,delete d._query,this.apiClient.request({path:a,queryParams:l,body:JSON.stringify(d),httpMethod:"PATCH",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json()).then(e=>nh(e))}{let t,r,o,u,c,p,d=(s=this.apiClient,t={},null!=(r=t$(e,["model"]))&&tV(t,["_url","name"],rm(s,r)),null!=(o=t$(e,["config"]))&&(u=t$(o,["displayName"]),void 0!==t&&null!=u&&tV(t,["displayName"],u),c=t$(o,["description"]),void 0!==t&&null!=c&&tV(t,["description"],c),p=t$(o,["defaultCheckpointId"]),void 0!==t&&null!=p&&tV(t,["defaultCheckpointId"],p)),t);return a=tB("{name}",d._url),l=d._query,delete d._url,delete d._query,this.apiClient.request({path:a,queryParams:l,body:JSON.stringify(d),httpMethod:"PATCH",httpOptions:null==(n=e.config)?void 0:n.httpOptions,abortSignal:null==(i=e.config)?void 0:i.abortSignal}).then(e=>e.json()).then(e=>nd(e))}}async delete(e){var t,r,n,i,o,s;let a="",l={};if(this.apiClient.isVertexAI()){let n,i,s=(o=this.apiClient,n={},null!=(i=t$(e,["model"]))&&tV(n,["_url","name"],rm(o,i)),n);return a=tB("{name}",s._url),l=s._query,delete s._url,delete s._query,this.apiClient.request({path:a,queryParams:l,body:JSON.stringify(s),httpMethod:"DELETE",httpOptions:null==(t=e.config)?void 0:t.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,r,n=(t={},null!=(r=t$(e,["sdkHttpResponse"]))&&tV(t,["sdkHttpResponse"],r),t),i=new t3;return Object.assign(i,n),i})}{let t,r,o=(s=this.apiClient,t={},null!=(r=t$(e,["model"]))&&tV(t,["_url","name"],rm(s,r)),t);return a=tB("{name}",o._url),l=o._query,delete o._url,delete o._query,this.apiClient.request({path:a,queryParams:l,body:JSON.stringify(o),httpMethod:"DELETE",httpOptions:null==(n=e.config)?void 0:n.httpOptions,abortSignal:null==(i=e.config)?void 0:i.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t,r,n=(t={},null!=(r=t$(e,["sdkHttpResponse"]))&&tV(t,["sdkHttpResponse"],r),t),i=new t3;return Object.assign(i,n),i})}}async countTokens(e){var t,r,n,i;let o="",s={};if(this.apiClient.isVertexAI()){let n=function(e,t){let r={},n=t$(t,["model"]);null!=n&&tV(r,["_url","model"],rm(e,n));let i=t$(t,["contents"]);if(null!=i){let e=rw(i);Array.isArray(e)&&(e=e.map(e=>nn(e))),tV(r,["contents"],e)}let o=t$(t,["config"]);return null!=o&&function(e,t){let r=t$(e,["systemInstruction"]);void 0!==t&&null!=r&&tV(t,["systemInstruction"],nn(rI(r)));let n=t$(e,["tools"]);if(void 0!==t&&null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>ng(e))),tV(t,["tools"],e)}let i=t$(e,["generationConfig"]);void 0!==t&&null!=i&&tV(t,["generationConfig"],function(e){let t={},r=t$(e,["modelSelectionConfig"]);null!=r&&tV(t,["modelConfig"],r);let n=t$(e,["responseJsonSchema"]);null!=n&&tV(t,["responseJsonSchema"],n);let i=t$(e,["audioTimestamp"]);null!=i&&tV(t,["audioTimestamp"],i);let o=t$(e,["candidateCount"]);null!=o&&tV(t,["candidateCount"],o);let s=t$(e,["enableAffectiveDialog"]);null!=s&&tV(t,["enableAffectiveDialog"],s);let a=t$(e,["frequencyPenalty"]);null!=a&&tV(t,["frequencyPenalty"],a);let l=t$(e,["logprobs"]);null!=l&&tV(t,["logprobs"],l);let u=t$(e,["maxOutputTokens"]);null!=u&&tV(t,["maxOutputTokens"],u);let c=t$(e,["mediaResolution"]);null!=c&&tV(t,["mediaResolution"],c);let p=t$(e,["presencePenalty"]);null!=p&&tV(t,["presencePenalty"],p);let d=t$(e,["responseLogprobs"]);null!=d&&tV(t,["responseLogprobs"],d);let h=t$(e,["responseMimeType"]);null!=h&&tV(t,["responseMimeType"],h);let f=t$(e,["responseModalities"]);null!=f&&tV(t,["responseModalities"],f);let m=t$(e,["responseSchema"]);null!=m&&tV(t,["responseSchema"],m);let g=t$(e,["routingConfig"]);null!=g&&tV(t,["routingConfig"],g);let y=t$(e,["seed"]);null!=y&&tV(t,["seed"],y);let _=t$(e,["speechConfig"]);null!=_&&tV(t,["speechConfig"],_);let E=t$(e,["stopSequences"]);null!=E&&tV(t,["stopSequences"],E);let v=t$(e,["temperature"]);null!=v&&tV(t,["temperature"],v);let A=t$(e,["thinkingConfig"]);null!=A&&tV(t,["thinkingConfig"],A);let T=t$(e,["topK"]);null!=T&&tV(t,["topK"],T);let C=t$(e,["topP"]);if(null!=C&&tV(t,["topP"],C),void 0!==t$(e,["enableEnhancedCivicAnswers"]))throw Error("enableEnhancedCivicAnswers parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return t}(i))}(o,r),r}(this.apiClient,e);return o=tB("{model}:countTokens",n._url),s=n._query,delete n._url,delete n._query,this.apiClient.request({path:o,queryParams:s,body:JSON.stringify(n),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.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,r,n,i=(t={},null!=(r=t$(e,["sdkHttpResponse"]))&&tV(t,["sdkHttpResponse"],r),null!=(n=t$(e,["totalTokens"]))&&tV(t,["totalTokens"],n),t),o=new t5;return Object.assign(o,i),o})}{let t=function(e,t){let r={},n=t$(t,["model"]);null!=n&&tV(r,["_url","model"],rm(e,n));let i=t$(t,["contents"]);if(null!=i){let e=rw(i);Array.isArray(e)&&(e=e.map(e=>nr(e))),tV(r,["contents"],e)}let o=t$(t,["config"]);return null!=o&&function(e){if(void 0!==t$(e,["systemInstruction"]))throw Error("systemInstruction parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["tools"]))throw Error("tools parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["generationConfig"]))throw Error("generationConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.")}(o),r}(this.apiClient,e);return o=tB("{model}:countTokens",t._url),s=t._query,delete t._url,delete t._query,this.apiClient.request({path:o,queryParams:s,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null==(n=e.config)?void 0:n.httpOptions,abortSignal:null==(i=e.config)?void 0:i.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t,r,n,i,o=(t={},null!=(r=t$(e,["sdkHttpResponse"]))&&tV(t,["sdkHttpResponse"],r),null!=(n=t$(e,["totalTokens"]))&&tV(t,["totalTokens"],n),null!=(i=t$(e,["cachedContentTokenCount"]))&&tV(t,["cachedContentTokenCount"],i),t),s=new t5;return Object.assign(s,o),s})}}async computeTokens(e){var t,r;let n="",i={};if(this.apiClient.isVertexAI()){let o=function(e,t){let r={},n=t$(t,["model"]);null!=n&&tV(r,["_url","model"],rm(e,n));let i=t$(t,["contents"]);if(null!=i){let e=rw(i);Array.isArray(e)&&(e=e.map(e=>nn(e))),tV(r,["contents"],e)}return r}(this.apiClient,e);return n=tB("{model}:computeTokens",o._url),i=o._query,delete o._url,delete o._query,this.apiClient.request({path:n,queryParams:i,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.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={},r=t$(e,["sdkHttpResponse"]);null!=r&&tV(t,["sdkHttpResponse"],r);let n=t$(e,["tokensInfo"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>e)),tV(t,["tokensInfo"],e)}return t}(e),r=new t6;return Object.assign(r,t),r})}throw Error("This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).")}async generateVideosInternal(e){var t,r,n,i,o,s,a,l,u,c;let p="",d={};if(this.apiClient.isVertexAI()){let n,i,s,u,c,h,f,m,g,y,_=(o=this.apiClient,u={},null!=(c=t$(e,["model"]))&&tV(u,["_url","model"],rm(o,c)),null!=(h=t$(e,["prompt"]))&&tV(u,["instances[0]","prompt"],h),null!=(f=t$(e,["image"]))&&tV(u,["instances[0]","image"],np(f)),null!=(m=t$(e,["video"]))&&tV(u,["instances[0]","video"],n_(m)),null!=(g=t$(e,["source"]))&&(a=g,l=u,n=t$(a,["prompt"]),void 0!==l&&null!=n&&tV(l,["instances[0]","prompt"],n),i=t$(a,["image"]),void 0!==l&&null!=i&&tV(l,["instances[0]","image"],np(i)),s=t$(a,["video"]),void 0!==l&&null!=s&&tV(l,["instances[0]","video"],n_(s))),null!=(y=t$(e,["config"]))&&function(e,t){var r;let n,i,o,s=t$(e,["numberOfVideos"]);void 0!==t&&null!=s&&tV(t,["parameters","sampleCount"],s);let a=t$(e,["outputGcsUri"]);void 0!==t&&null!=a&&tV(t,["parameters","storageUri"],a);let l=t$(e,["fps"]);void 0!==t&&null!=l&&tV(t,["parameters","fps"],l);let u=t$(e,["durationSeconds"]);void 0!==t&&null!=u&&tV(t,["parameters","durationSeconds"],u);let c=t$(e,["seed"]);void 0!==t&&null!=c&&tV(t,["parameters","seed"],c);let p=t$(e,["aspectRatio"]);void 0!==t&&null!=p&&tV(t,["parameters","aspectRatio"],p);let d=t$(e,["resolution"]);void 0!==t&&null!=d&&tV(t,["parameters","resolution"],d);let h=t$(e,["personGeneration"]);void 0!==t&&null!=h&&tV(t,["parameters","personGeneration"],h);let f=t$(e,["pubsubTopic"]);void 0!==t&&null!=f&&tV(t,["parameters","pubsubTopic"],f);let m=t$(e,["negativePrompt"]);void 0!==t&&null!=m&&tV(t,["parameters","negativePrompt"],m);let g=t$(e,["enhancePrompt"]);void 0!==t&&null!=g&&tV(t,["parameters","enhancePrompt"],g);let y=t$(e,["generateAudio"]);void 0!==t&&null!=y&&tV(t,["parameters","generateAudio"],y);let _=t$(e,["lastFrame"]);void 0!==t&&null!=_&&tV(t,["instances[0]","lastFrame"],np(_));let E=t$(e,["referenceImages"]);if(void 0!==t&&null!=E){let e=E;Array.isArray(e)&&(e=e.map(e=>{var t;let r,n,i;return r={},null!=(n=t$(t=e,["image"]))&&tV(r,["image"],np(n)),null!=(i=t$(t,["referenceType"]))&&tV(r,["referenceType"],i),r})),tV(t,["instances[0]","referenceImages"],e)}let v=t$(e,["mask"]);void 0!==t&&null!=v&&tV(t,["instances[0]","mask"],(n={},null!=(i=t$(r=v,["image"]))&&tV(n,["_self"],np(i)),null!=(o=t$(r,["maskMode"]))&&tV(n,["maskMode"],o),n));let A=t$(e,["compressionQuality"]);void 0!==t&&null!=A&&tV(t,["parameters","compressionQuality"],A);let T=t$(e,["labels"]);if(void 0!==t&&null!=T&&tV(t,["labels"],T),void 0!==t$(e,["webhookConfig"]))throw Error("webhookConfig parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");let C=t$(e,["resizeMode"]);void 0!==t&&null!=C&&tV(t,["parameters","resizeMode"],C)}(y,u),u);return p=tB("{model}:predictLongRunning",_._url),d=_._query,delete _._url,delete _._query,this.apiClient.request({path:p,queryParams:d,body:JSON.stringify(_),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json()).then(e=>{let t,r,n,i,o,s,a=(t={},null!=(r=t$(e,["name"]))&&tV(t,["name"],r),null!=(n=t$(e,["metadata"]))&&tV(t,["metadata"],n),null!=(i=t$(e,["done"]))&&tV(t,["done"],i),null!=(o=t$(e,["error"]))&&tV(t,["error"],o),null!=(s=t$(e,["response"]))&&tV(t,["response"],function(e){let t={},r=t$(e,["videos"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>{var t;let r,n,i,o,s,a;return r={},null!=(n=t$(e,["_self"]))&&tV(r,["video"],(i={},null!=(o=t$(t=n,["gcsUri"]))&&tV(i,["uri"],o),null!=(s=t$(t,["bytesBase64Encoded"]))&&tV(i,["videoBytes"],tJ(s)),null!=(a=t$(t,["mimeType"]))&&tV(i,["mimeType"],a),i)),r})),tV(t,["generatedVideos"],e)}let n=t$(e,["raiMediaFilteredCount"]);null!=n&&tV(t,["raiMediaFilteredCount"],n);let i=t$(e,["raiMediaFilteredReasons"]);return null!=i&&tV(t,["raiMediaFilteredReasons"],i),t}(s)),t),l=new t8;return Object.assign(l,a),l})}{let t,r,o,a,l,h,f,m,g,y,_=(s=this.apiClient,a={},null!=(l=t$(e,["model"]))&&tV(a,["_url","model"],rm(s,l)),null!=(h=t$(e,["prompt"]))&&tV(a,["instances[0]","prompt"],h),null!=(f=t$(e,["image"]))&&tV(a,["instances[0]","image"],nc(f)),null!=(m=t$(e,["video"]))&&tV(a,["instances[0]","video"],ny(m)),null!=(g=t$(e,["source"]))&&(u=g,c=a,t=t$(u,["prompt"]),void 0!==c&&null!=t&&tV(c,["instances[0]","prompt"],t),r=t$(u,["image"]),void 0!==c&&null!=r&&tV(c,["instances[0]","image"],nc(r)),o=t$(u,["video"]),void 0!==c&&null!=o&&tV(c,["instances[0]","video"],ny(o))),null!=(y=t$(e,["config"]))&&function(e,t){let r=t$(e,["numberOfVideos"]);if(void 0!==t&&null!=r&&tV(t,["parameters","sampleCount"],r),void 0!==t$(e,["outputGcsUri"]))throw Error("outputGcsUri parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["fps"]))throw Error("fps parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let n=t$(e,["durationSeconds"]);if(void 0!==t&&null!=n&&tV(t,["parameters","durationSeconds"],n),void 0!==t$(e,["seed"]))throw Error("seed parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let i=t$(e,["aspectRatio"]);void 0!==t&&null!=i&&tV(t,["parameters","aspectRatio"],i);let o=t$(e,["resolution"]);void 0!==t&&null!=o&&tV(t,["parameters","resolution"],o);let s=t$(e,["personGeneration"]);if(void 0!==t&&null!=s&&tV(t,["parameters","personGeneration"],s),void 0!==t$(e,["pubsubTopic"]))throw Error("pubsubTopic parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let a=t$(e,["negativePrompt"]);void 0!==t&&null!=a&&tV(t,["parameters","negativePrompt"],a);let l=t$(e,["enhancePrompt"]);if(void 0!==t&&null!=l&&tV(t,["parameters","enhancePrompt"],l),void 0!==t$(e,["generateAudio"]))throw Error("generateAudio parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let u=t$(e,["lastFrame"]);void 0!==t&&null!=u&&tV(t,["instances[0]","lastFrame"],nc(u));let c=t$(e,["referenceImages"]);if(void 0!==t&&null!=c){let e=c;Array.isArray(e)&&(e=e.map(e=>{var t;let r,n,i;return r={},null!=(n=t$(t=e,["image"]))&&tV(r,["image"],nc(n)),null!=(i=t$(t,["referenceType"]))&&tV(r,["referenceType"],i),r})),tV(t,["instances[0]","referenceImages"],e)}if(void 0!==t$(e,["mask"]))throw Error("mask parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["compressionQuality"]))throw Error("compressionQuality parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["labels"]))throw Error("labels parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let p=t$(e,["webhookConfig"]);if(void 0!==t&&null!=p&&tV(t,["webhookConfig"],p),void 0!==t$(e,["resizeMode"]))throw Error("resizeMode parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.")}(y,a),a);return p=tB("{model}:predictLongRunning",_._url),d=_._query,delete _._url,delete _._query,this.apiClient.request({path:p,queryParams:d,body:JSON.stringify(_),httpMethod:"POST",httpOptions:null==(n=e.config)?void 0:n.httpOptions,abortSignal:null==(i=e.config)?void 0:i.abortSignal}).then(e=>e.json()).then(e=>{let t,r,n,i,o,s,a=(t={},null!=(r=t$(e,["name"]))&&tV(t,["name"],r),null!=(n=t$(e,["metadata"]))&&tV(t,["metadata"],n),null!=(i=t$(e,["done"]))&&tV(t,["done"],i),null!=(o=t$(e,["error"]))&&tV(t,["error"],o),null!=(s=t$(e,["response","generateVideoResponse"]))&&tV(t,["response"],function(e){let t={},r=t$(e,["generatedSamples"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>{var t;let r,n,i,o,s,a;return r={},null!=(n=t$(e,["video"]))&&tV(r,["video"],(i={},null!=(o=t$(t=n,["uri"]))&&tV(i,["uri"],o),null!=(s=t$(t,["encodedVideo"]))&&tV(i,["videoBytes"],tJ(s)),null!=(a=t$(t,["encoding"]))&&tV(i,["mimeType"],a),i)),r})),tV(t,["generatedVideos"],e)}let n=t$(e,["raiMediaFilteredCount"]);null!=n&&tV(t,["raiMediaFilteredCount"],n);let i=t$(e,["raiMediaFilteredReasons"]);return null!=i&&tV(t,["raiMediaFilteredReasons"],i),t}(s)),t),l=new t8;return Object.assign(l,a),l})}}}class nF extends tH{constructor(e){super(),this.apiClient=e}async getVideosOperation(e){let t=e.operation,r=e.config;if(void 0===t.name||""===t.name)throw Error("Operation name is required.");if(this.apiClient.isVertexAI()){let e,n=t.name.split("/operations/")[0];r&&"httpOptions"in r&&(e=r.httpOptions);let i=await this.fetchPredictVideosOperationInternal({operationName:t.name,resourceName:n,config:{httpOptions:e}});return t._fromAPIResponse({apiResponse:i,_isVertexAI:!0})}{let e=await this.getVideosOperationInternal({operationName:t.name,config:r});return t._fromAPIResponse({apiResponse:e,_isVertexAI:!1})}}async get(e){let t=e.operation,r=e.config;if(void 0===t.name||""===t.name)throw Error("Operation name is required.");if(this.apiClient.isVertexAI()){let e,n=t.name.split("/operations/")[0];r&&"httpOptions"in r&&(e=r.httpOptions);let i=await this.fetchPredictVideosOperationInternal({operationName:t.name,resourceName:n,config:{httpOptions:e}});return t._fromAPIResponse({apiResponse:i,_isVertexAI:!0})}{let e=await this.getVideosOperationInternal({operationName:t.name,config:r});return t._fromAPIResponse({apiResponse:e,_isVertexAI:!1})}}async getVideosOperationInternal(e){var t,r,n,i;let o="",s={};if(this.apiClient.isVertexAI()){let n,i,a=(n={},null!=(i=t$(e,["operationName"]))&&tV(n,["_url","operationName"],i),n);return o=tB("{operationName}",a._url),s=a._query,delete a._url,delete a._query,this.apiClient.request({path:o,queryParams:s,body:JSON.stringify(a),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json())}{let t,r,a=(t={},null!=(r=t$(e,["operationName"]))&&tV(t,["_url","operationName"],r),t);return o=tB("{operationName}",a._url),s=a._query,delete a._url,delete a._query,this.apiClient.request({path:o,queryParams:s,body:JSON.stringify(a),httpMethod:"GET",httpOptions:null==(n=e.config)?void 0:n.httpOptions,abortSignal:null==(i=e.config)?void 0:i.abortSignal}).then(e=>e.json())}}async fetchPredictVideosOperationInternal(e){var t,r;let n="",i={};if(this.apiClient.isVertexAI()){let o,s,a,l=(o={},null!=(s=t$(e,["operationName"]))&&tV(o,["operationName"],s),null!=(a=t$(e,["resourceName"]))&&tV(o,["_url","resourceName"],a),o);return n=tB("{resourceName}:fetchPredictOperation",l._url),i=l._query,delete l._url,delete l._query,this.apiClient.request({path:n,queryParams:i,body:JSON.stringify(l),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json())}throw Error("This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).")}}function nq(e){let t={};if(void 0!==t$(e,["languageCodes"]))throw Error("languageCodes parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let r=t$(e,["languageAuto"]);null!=r&&tV(t,["languageAuto"],r);let n=t$(e,["languageHints"]);null!=n&&tV(t,["languageHints"],n);let i=t$(e,["adaptationPhrases"]);return null!=i&&tV(t,["adaptationPhrases"],i),t}class nH extends tH{constructor(e){super(),this.apiClient=e}async create(e){var t,r,n,i,o;let s="",a={};if(this.apiClient.isVertexAI())throw Error("The client.tokens.create method is only supported by the Gemini Developer API.");{let l,u,c,p,d,h,f,m,g,y,_=(n=this.apiClient,p={},null!=(d=t$(e,["config"]))&&tV(p,["config"],(h=t$(d,["expireTime"]),void 0!==p&&null!=h&&tV(p,["expireTime"],h),f=t$(d,["newSessionExpireTime"]),void 0!==p&&null!=f&&tV(p,["newSessionExpireTime"],f),m=t$(d,["uses"]),void 0!==p&&null!=m&&tV(p,["uses"],m),g=t$(d,["liveConnectConstraints"]),void 0!==p&&null!=g&&tV(p,["bidiGenerateContentSetup"],(i=n,l={},null!=(u=t$(o=g,["model"]))&&tV(l,["setup","model"],rm(i,u)),null!=(c=t$(o,["config"]))&&tV(l,["config"],function(e,t){let r=t$(e,["generationConfig"]);void 0!==t&&null!=r&&tV(t,["setup","generationConfig"],r);let n=t$(e,["responseModalities"]);void 0!==t&&null!=n&&tV(t,["setup","generationConfig","responseModalities"],n);let i=t$(e,["temperature"]);void 0!==t&&null!=i&&tV(t,["setup","generationConfig","temperature"],i);let o=t$(e,["topP"]);void 0!==t&&null!=o&&tV(t,["setup","generationConfig","topP"],o);let s=t$(e,["topK"]);void 0!==t&&null!=s&&tV(t,["setup","generationConfig","topK"],s);let a=t$(e,["maxOutputTokens"]);void 0!==t&&null!=a&&tV(t,["setup","generationConfig","maxOutputTokens"],a);let l=t$(e,["mediaResolution"]);void 0!==t&&null!=l&&tV(t,["setup","generationConfig","mediaResolution"],l);let u=t$(e,["seed"]);void 0!==t&&null!=u&&tV(t,["setup","generationConfig","seed"],u);let c=t$(e,["speechConfig"]);void 0!==t&&null!=c&&tV(t,["setup","generationConfig","speechConfig"],rN(c));let p=t$(e,["thinkingConfig"]);void 0!==t&&null!=p&&tV(t,["setup","generationConfig","thinkingConfig"],p);let d=t$(e,["enableAffectiveDialog"]);void 0!==t&&null!=d&&tV(t,["setup","generationConfig","enableAffectiveDialog"],d);let h=t$(e,["systemInstruction"]);void 0!==t&&null!=h&&tV(t,["setup","systemInstruction"],function(e){let t={},r=t$(e,["parts"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>{var t;let r,n,i,o,s,a,l,u,c,p,d,h,f,m,g;return r={},null!=(n=t$(t=e,["mediaResolution"]))&&tV(r,["mediaResolution"],n),null!=(i=t$(t,["codeExecutionResult"]))&&tV(r,["codeExecutionResult"],i),null!=(o=t$(t,["executableCode"]))&&tV(r,["executableCode"],o),null!=(s=t$(t,["fileData"]))&&tV(r,["fileData"],function(e){let t={};if(void 0!==t$(e,["displayName"]))throw Error("displayName parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let r=t$(e,["fileUri"]);null!=r&&tV(t,["fileUri"],r);let n=t$(e,["mimeType"]);return null!=n&&tV(t,["mimeType"],n),t}(s)),null!=(a=t$(t,["functionCall"]))&&tV(r,["functionCall"],function(e){let t={},r=t$(e,["id"]);null!=r&&tV(t,["id"],r);let n=t$(e,["args"]);null!=n&&tV(t,["args"],n);let i=t$(e,["name"]);if(null!=i&&tV(t,["name"],i),void 0!==t$(e,["partialArgs"]))throw Error("partialArgs parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["willContinue"]))throw Error("willContinue parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return t}(a)),null!=(l=t$(t,["functionResponse"]))&&tV(r,["functionResponse"],l),null!=(u=t$(t,["inlineData"]))&&tV(r,["inlineData"],function(e){let t={},r=t$(e,["data"]);if(null!=r&&tV(t,["data"],r),void 0!==t$(e,["displayName"]))throw Error("displayName parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let n=t$(e,["mimeType"]);return null!=n&&tV(t,["mimeType"],n),t}(u)),null!=(c=t$(t,["text"]))&&tV(r,["text"],c),null!=(p=t$(t,["thought"]))&&tV(r,["thought"],p),null!=(d=t$(t,["thoughtSignature"]))&&tV(r,["thoughtSignature"],d),null!=(h=t$(t,["videoMetadata"]))&&tV(r,["videoMetadata"],h),null!=(f=t$(t,["toolCall"]))&&tV(r,["toolCall"],f),null!=(m=t$(t,["toolResponse"]))&&tV(r,["toolResponse"],m),null!=(g=t$(t,["partMetadata"]))&&tV(r,["partMetadata"],g),r})),tV(t,["parts"],e)}let n=t$(e,["role"]);return null!=n&&tV(t,["role"],n),t}(rI(h)));let f=t$(e,["tools"]);if(void 0!==t&&null!=f){let e=rD(f);Array.isArray(e)&&(e=e.map(e=>(function(e){let t,r,n,i={};if(void 0!==t$(e,["retrieval"]))throw Error("retrieval parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let o=t$(e,["computerUse"]);null!=o&&tV(i,["computerUse"],o);let s=t$(e,["fileSearch"]);null!=s&&tV(i,["fileSearch"],s);let a=t$(e,["googleSearch"]);null!=a&&tV(i,["googleSearch"],function(e){let t={},r=t$(e,["searchTypes"]);if(null!=r&&tV(t,["searchTypes"],r),void 0!==t$(e,["blockingConfidence"]))throw Error("blockingConfidence parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["excludeDomains"]))throw Error("excludeDomains parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let n=t$(e,["timeRangeFilter"]);return null!=n&&tV(t,["timeRangeFilter"],n),t}(a));let l=t$(e,["googleMaps"]);null!=l&&tV(i,["googleMaps"],(t={},null!=(r=t$(l,["authConfig"]))&&tV(t,["authConfig"],function(e){let t={},r=t$(e,["apiKey"]);if(null!=r&&tV(t,["apiKey"],r),void 0!==t$(e,["apiKeyConfig"]))throw Error("apiKeyConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["authType"]))throw Error("authType parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["googleServiceAccountConfig"]))throw Error("googleServiceAccountConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["httpBasicAuthConfig"]))throw Error("httpBasicAuthConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["oauthConfig"]))throw Error("oauthConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["oidcConfig"]))throw Error("oidcConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return t}(r)),null!=(n=t$(l,["enableWidget"]))&&tV(t,["enableWidget"],n),t));let u=t$(e,["codeExecution"]);if(null!=u&&tV(i,["codeExecution"],u),void 0!==t$(e,["enterpriseWebSearch"]))throw Error("enterpriseWebSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let c=t$(e,["functionDeclarations"]);if(null!=c){let e=c;Array.isArray(e)&&(e=e.map(e=>e)),tV(i,["functionDeclarations"],e)}let p=t$(e,["googleSearchRetrieval"]);if(null!=p&&tV(i,["googleSearchRetrieval"],p),void 0!==t$(e,["parallelAiSearch"]))throw Error("parallelAiSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let d=t$(e,["urlContext"]);null!=d&&tV(i,["urlContext"],d);let h=t$(e,["mcpServers"]);if(null!=h){let e=h;Array.isArray(e)&&(e=e.map(e=>e)),tV(i,["mcpServers"],e)}return i})(rk(e)))),tV(t,["setup","tools"],e)}let m=t$(e,["sessionResumption"]);void 0!==t&&null!=m&&tV(t,["setup","sessionResumption"],function(e){let t={},r=t$(e,["handle"]);if(null!=r&&tV(t,["handle"],r),void 0!==t$(e,["transparent"]))throw Error("transparent parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");return t}(m));let g=t$(e,["inputAudioTranscription"]);void 0!==t&&null!=g&&tV(t,["setup","inputAudioTranscription"],nq(g));let y=t$(e,["outputAudioTranscription"]);void 0!==t&&null!=y&&tV(t,["setup","outputAudioTranscription"],nq(y));let _=t$(e,["realtimeInputConfig"]);void 0!==t&&null!=_&&tV(t,["setup","realtimeInputConfig"],_);let E=t$(e,["contextWindowCompression"]);void 0!==t&&null!=E&&tV(t,["setup","contextWindowCompression"],E);let v=t$(e,["proactivity"]);if(void 0!==t&&null!=v&&tV(t,["setup","proactivity"],v),void 0!==t$(e,["explicitVadSignal"]))throw Error("explicitVadSignal parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let A=t$(e,["avatarConfig"]);void 0!==t&&null!=A&&tV(t,["setup","avatarConfig"],A);let T=t$(e,["safetySettings"]);if(void 0!==t&&null!=T){let e=T;Array.isArray(e)&&(e=e.map(e=>(function(e){let t={},r=t$(e,["category"]);if(null!=r&&tV(t,["category"],r),void 0!==t$(e,["method"]))throw Error("method parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let n=t$(e,["threshold"]);return null!=n&&tV(t,["threshold"],n),t})(e))),tV(t,["setup","safetySettings"],e)}let C=t$(e,["translationConfig"]);return void 0!==t&&null!=C&&tV(t,["setup","generationConfig","translationConfig"],C),{}}(c,l)),l)),y=t$(d,["lockAdditionalFields"]),void 0!==p&&null!=y&&tV(p,["fieldMask"],y),{})),p);s=tB("auth_tokens",_._url),a=_._query,delete _.config,delete _._url,delete _._query;let E=function(e,t){let r=null,n=e.bidiGenerateContentSetup;if("object"==typeof n&&null!==n&&"setup"in n){let t=n.setup;"object"==typeof t&&null!==t?(e.bidiGenerateContentSetup=t,r=t):delete e.bidiGenerateContentSetup}else void 0!==n&&delete e.bidiGenerateContentSetup;let i=e.fieldMask;if(r){let n=function(e){let t=[];for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)){let n=e[r];if("object"==typeof n&&null!=n&&Object.keys(n).length>0){let e=Object.keys(n).map(e=>`${r}.${e}`);t.push(...e)}else t.push(r)}return t.join(",")}(r);if(Array.isArray(null==t?void 0:t.lockAdditionalFields)&&(null==t?void 0:t.lockAdditionalFields.length)===0)n?e.fieldMask=n:delete e.fieldMask;else if((null==t?void 0:t.lockAdditionalFields)&&t.lockAdditionalFields.length>0&&null!==i&&Array.isArray(i)&&i.length>0){let t=["temperature","topK","topP","maxOutputTokens","responseModalities","seed","speechConfig"],r=[];i.length>0&&(r=i.map(e=>t.includes(e)?`generationConfig.${e}`:e));let o=[];n&&o.push(n),r.length>0&&o.push(...r),o.length>0?e.fieldMask=o.join(","):delete e.fieldMask}else delete e.fieldMask}else null!==i&&Array.isArray(i)&&i.length>0?e.fieldMask=i.join(","):delete e.fieldMask;return e}(_,e.config);return this.apiClient.request({path:s,queryParams:a,body:JSON.stringify(E),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json()).then(e=>e)}}}class nB extends tH{constructor(e){super(),this.apiClient=e,this.list=async e=>new rY(tN.PAGED_ITEM_DOCUMENTS,t=>this.listInternal({parent:e.parent,config:t.config}),await this.listInternal(e),e)}async get(e){var t,r;let n="",i={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let o,s,a=(o={},null!=(s=t$(e,["name"]))&&tV(o,["_url","name"],s),o);return n=tB("{name}",a._url),i=a._query,delete a._url,delete a._query,this.apiClient.request({path:n,queryParams:i,body:JSON.stringify(a),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json()).then(e=>e)}}async delete(e){var t,r;let n="",i={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let o,s,a,l,u=(o={},null!=(s=t$(e,["name"]))&&tV(o,["_url","name"],s),null!=(a=t$(e,["config"]))&&(l=t$(a,["force"]),void 0!==o&&null!=l&&tV(o,["_query","force"],l)),o);n=tB("{name}",u._url),i=u._query,delete u._url,delete u._query,await this.apiClient.request({path:n,queryParams:i,body:JSON.stringify(u),httpMethod:"DELETE",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal})}}async listInternal(e){var t,r;let n="",i={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let o,s,a,l,u,c=(o={},null!=(s=t$(e,["parent"]))&&tV(o,["_url","parent"],s),null!=(a=t$(e,["config"]))&&(l=t$(a,["pageSize"]),void 0!==o&&null!=l&&tV(o,["_query","pageSize"],l),u=t$(a,["pageToken"]),void 0!==o&&null!=u&&tV(o,["_query","pageToken"],u)),o);return n=tB("{parent}/documents",c._url),i=c._query,delete c._url,delete c._query,this.apiClient.request({path:n,queryParams:i,body:JSON.stringify(c),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json()).then(e=>{let t=function(e){let t={},r=t$(e,["sdkHttpResponse"]);null!=r&&tV(t,["sdkHttpResponse"],r);let n=t$(e,["nextPageToken"]);null!=n&&tV(t,["nextPageToken"],n);let i=t$(e,["documents"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),tV(t,["documents"],e)}return t}(e),r=new rn;return Object.assign(r,t),r})}}}class nV extends tH{constructor(e,t=new nB(e)){super(),this.apiClient=e,this.documents=t,this.list=async(e={})=>new rY(tN.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 r=new URL(e,"http://dummy.com"),n=r.pathname;if(n.startsWith("/")&&(n=n.slice(1)),!n.includes("/media/"))throw Error(`Invalid uri format: ${e}. Expected to contain /media/`);let i={};r.searchParams.forEach((e,t)=>{i[t]=e}),i.alt="media";let o=Object.assign({},null==t?void 0:t.httpOptions),s=await this.apiClient.request({path:n,httpMethod:"GET",queryParams:i,httpOptions:o});if(s instanceof tY)return new Uint8Array(await s.responseInternal.arrayBuffer());throw Error("Unexpected response type from downloadMedia")}async create(e){var t,r,n;let i="",o={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let s,a,l,u,c=(n=this.apiClient,s={},null!=(a=t$(e,["config"]))&&(l=t$(a,["displayName"]),void 0!==s&&null!=l&&tV(s,["displayName"],l),u=t$(a,["embeddingModel"]),void 0!==s&&null!=u&&tV(s,["embeddingModel"],rm(n,u))),s);return i=tB("fileSearchStores",c._url),o=c._query,delete c._url,delete c._query,this.apiClient.request({path:i,queryParams:o,body:JSON.stringify(c),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json()).then(e=>e)}}async get(e){var t,r;let n="",i={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let o,s,a=(o={},null!=(s=t$(e,["name"]))&&tV(o,["_url","name"],s),o);return n=tB("{name}",a._url),i=a._query,delete a._url,delete a._query,this.apiClient.request({path:n,queryParams:i,body:JSON.stringify(a),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json()).then(e=>e)}}async delete(e){var t,r;let n="",i={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let o,s,a,l,u=(o={},null!=(s=t$(e,["name"]))&&tV(o,["_url","name"],s),null!=(a=t$(e,["config"]))&&(l=t$(a,["force"]),void 0!==o&&null!=l&&tV(o,["_query","force"],l)),o);n=tB("{name}",u._url),i=u._query,delete u._url,delete u._query,await this.apiClient.request({path:n,queryParams:i,body:JSON.stringify(u),httpMethod:"DELETE",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal})}}async listInternal(e){var t,r;let n="",i={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let o,s,a,l,u=(o={},null!=(s=t$(e,["config"]))&&(a=t$(s,["pageSize"]),void 0!==o&&null!=a&&tV(o,["_query","pageSize"],a),l=t$(s,["pageToken"]),void 0!==o&&null!=l&&tV(o,["_query","pageToken"],l)),o);return n=tB("fileSearchStores",u._url),i=u._query,delete u._url,delete u._query,this.apiClient.request({path:n,queryParams:i,body:JSON.stringify(u),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json()).then(e=>{let t=function(e){let t={},r=t$(e,["sdkHttpResponse"]);null!=r&&tV(t,["sdkHttpResponse"],r);let n=t$(e,["nextPageToken"]);null!=n&&tV(t,["nextPageToken"],n);let i=t$(e,["fileSearchStores"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),tV(t,["fileSearchStores"],e)}return t}(e),r=new ri;return Object.assign(r,t),r})}}async uploadToFileSearchStoreInternal(e){var t,r;let n="",i={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let o,s,a,l=(o={},null!=(s=t$(e,["fileSearchStoreName"]))&&tV(o,["_url","file_search_store_name"],s),null!=(a=t$(e,["config"]))&&nE(a,o),o);return n=tB("upload/v1beta/{file_search_store_name}:uploadToFileSearchStore",l._url),i=l._query,delete l._url,delete l._query,this.apiClient.request({path:n,queryParams:i,body:JSON.stringify(l),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json()).then(e=>{let t,r,n=(t={},null!=(r=t$(e,["sdkHttpResponse"]))&&tV(t,["sdkHttpResponse"],r),t),i=new ro;return Object.assign(i,n),i})}}async importFile(e){var t,r;let n="",i={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let o,s,a,l,u=(o={},null!=(s=t$(e,["fileSearchStoreName"]))&&tV(o,["_url","file_search_store_name"],s),null!=(a=t$(e,["fileName"]))&&tV(o,["fileName"],a),null!=(l=t$(e,["config"]))&&function(e,t){let r=t$(e,["customMetadata"]);if(void 0!==t&&null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),tV(t,["customMetadata"],e)}let n=t$(e,["chunkingConfig"]);void 0!==t&&null!=n&&tV(t,["chunkingConfig"],n)}(l,o),o);return n=tB("{file_search_store_name}:importFile",u._url),i=u._query,delete u._url,delete u._query,this.apiClient.request({path:n,queryParams:i,body:JSON.stringify(u),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json()).then(e=>{var t;let r,n,i,o,s,a,l,u,c,p,d=(s={},null!=(a=t$(e,["name"]))&&tV(s,["name"],a),null!=(l=t$(e,["metadata"]))&&tV(s,["metadata"],l),null!=(u=t$(e,["done"]))&&tV(s,["done"],u),null!=(c=t$(e,["error"]))&&tV(s,["error"],c),null!=(p=t$(e,["response"]))&&tV(s,["response"],(r={},null!=(n=t$(t=p,["sdkHttpResponse"]))&&tV(r,["sdkHttpResponse"],n),null!=(i=t$(t,["parent"]))&&tV(r,["parent"],i),null!=(o=t$(t,["documentName"]))&&tV(r,["documentName"],o),r)),s),h=new rs;return Object.assign(h,d),h})}}}function n$(){var e,t,r,i,o,s;if(n)return n;let a=globalThis;return n=("Deno"in globalThis?0:1)?null!=(s=null==(o=a.process)?void 0:o.env)?s:{}:null!=(i=null==(r=null==(t=null==(e=a.Deno)?void 0:e.env)?void 0:t.toObject)?void 0:r.call(t))?i:{}}class nJ{constructor(e){this.options=e}getDefaultHeaders(){return this.options.defaultHeaders}async resolveGoogleGenAISecurity(e){return function(e){var t,r;let n={};for(let[t,r]of e){let e=t.toLowerCase();"authorization"!==e&&"x-goog-api-key"!==e&&(n[t]=r)}let i={access_token:null!=(t=e.get("authorization"))?t:void 0,api_key:null!=(r=e.get("x-goog-api-key"))?r:void 0,default_headers:Object.keys(n).length?n:void 0};return nZ(i)?i:void 0}(await this.options.getAuthHeaders(e))}}class nW{beforeCreateRequest(e,t){return Object.assign(Object.assign({},t),{url:function(e){let[,t,...r]=e.pathname.split("/");if(!t)return e;let n=decodeURIComponent(t);if(!n.includes("/"))return e;let i=new URL(e);return i.pathname=`/${n}/${r.join("/")}`,i}(t.url)})}async beforeRequest(e,t){var r,n,i,o,s,a,l,u,c;if(nX(t.headers,nQ(r=e.security_source)?null!=(i=null==(n=r.getDefaultHeaders)?void 0:n.call(r))?i:r.defaultHeaders:nz(r)?r.default_headers:void 0),o=e,null===(s=t.headers).get("api-revision")&&s.set("Api-Revision",null!=(a=o.options.api_revision)?a:"2026-05-20"),l=e,u=t.headers,void 0!==l.options.user_project&&null===u.get("x-goog-user-project")&&u.set("x-goog-user-project",l.options.user_project),null!==(c=t.headers).get("authorization")||null!==c.get("x-goog-api-key"))return t;let p=await nK(e.security_source,t.url);return nX(t.headers,null==p?void 0:p.default_headers),function(e,t){if(t){var r;if(t.api_key)return e.set("x-goog-api-key",t.api_key);t.access_token&&e.set("Authorization","bearer "===(r=t.access_token).slice(0,7).toLowerCase()?r:`Bearer ${r}`)}}(t.headers,p),t}}async function nK(e,t){if(nQ(e))return e.resolveGoogleGenAISecurity(t);let r="function"==typeof e?await e():e;return nz(r)?nY(r):nY(void 0)}function nY(e){var t,r;let n=n$(),i=Object.assign(Object.assign({},e),{api_key:null!=(t=null==e?void 0:e.api_key)?t:n.GOOGLE_GENAI_API_KEY,access_token:null!=(r=null==e?void 0:e.access_token)?r:n.GOOGLE_GENAI_ACCESS_TOKEN});return nZ(i)?i:void 0}function nX(e,t){if(t)for(let[r,n]of new Headers(t))null===e.get(r)&&e.set(r,n)}function nz(e){return"object"==typeof e&&null!==e}function nQ(e){return"object"==typeof e&&null!==e&&"resolveGoogleGenAISecurity"in e&&"function"==typeof e.resolveGoogleGenAISecurity}function nZ(e){return void 0!==e.api_key||void 0!==e.access_token||void 0!==e.default_headers}class n0 extends Error{constructor(e,t){let r=e;(null==t?void 0:t.cause)&&(r+=`: ${t.cause}`),super(r,t),this.name="HTTPClientError",void 0===this.cause&&(this.cause=null==t?void 0:t.cause)}}class n1 extends n0{constructor(){super(...arguments),this.name="UnexpectedClientError"}}class n2 extends n0{constructor(){super(...arguments),this.name="InvalidRequestError"}}class n4 extends n0{constructor(){super(...arguments),this.name="RequestAbortedError"}}class n3 extends n0{constructor(){super(...arguments),this.name="RequestTimeoutError"}}class n5 extends n0{constructor(){super(...arguments),this.name="ConnectionError"}}class n6 extends Error{constructor(e,t){var r,n,i,o;super(e),this.statusCode=null==(r=null==t?void 0:t.response)?void 0:r.status,this.body=null!=(n=null==t?void 0:t.body)?n:"",this.headers=null==(i=null==t?void 0:t.response)?void 0:i.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 n8 extends Error{}class n7 extends n8{constructor(e,t,r,n){super(n7.makeMessage(e,t,r)),this.status=e,this.headers=n,this.error=t,this.statusCode=e,this.body=ih(t),this.contentType=(null==n?void 0:n.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,r){var n,i;let o=t&&null!==(i=t)&&"object"==typeof i&&!Array.isArray(i)&&"string"==typeof t.message?t.message:void 0,s=ih(t),a=null!=(n=null!=o?o:r)?n:s||"An error occurred",l=e?`${e} `:"";return`${l}${a}`}static generate(e,t,r,n){return e&&n?400===e?new ir(e,t,r,n):401===e?new ii(e,t,r,n):403===e?new io(e,t,r,n):404===e?new is(e,t,r,n):409===e?new ia(e,t,r,n):422===e?new il(e,t,r,n):429===e?new iu(e,t,r,n):e>=500?new ic(e,t,r,n):new n7(e,t,r,n):new ie({message:r,cause:t instanceof Error?t:void 0})}}class n9 extends n7{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}}class ie extends n7{constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0),this.cause=t}}class it extends ie{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 ir extends n7{}class ii extends n7{}class io extends n7{}class is extends n7{}class ia extends n7{}class il extends n7{}class iu extends n7{}class ic extends n7{}function ip(e){var t,r,n;let i,o;return"object"==typeof(t=e)&&null!==t&&n7.prototype.isPrototypeOf(t)?e:e instanceof n6?(i=function(e){let t=id(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 r=id(e,"error");return r&&"object"==typeof r?r:void 0}(r=e),im(o=n7.generate(r.statusCode,i,r.message,r.headers),"body",r.body),im(o,"contentType",r.contentType),im(o,"rawResponse",r.rawResponse),im(o,"statusCode",r.statusCode),im(o,"cause",r),o):e instanceof n0?(n=e)instanceof n3?new it({message:n.message}):n instanceof n4?new n9({message:n.message}):(n instanceof n5,new ie({message:n.message,cause:n})):e}function id(e,t){return e&&"object"==typeof e?e[t]:void 0}function ih(e){if(!e)return"";try{return JSON.stringify(e)}catch(t){return String(e)}}function im(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,value:r,writable:!1})}class ig{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 nW;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 r=t;for(let t of this.beforeCreateRequestHooks)r=t.beforeCreateRequest(e,r);return r}async beforeRequest(e,t){let r=t;for(let t of this.beforeRequestHooks)r=await t.beforeRequest(e,r);return r}async afterSuccess(e,t){let r=t;for(let t of this.afterSuccessHooks)r=await t.afterSuccess(e,r);return r}async afterError(e,t,r){let n=t,i=r;for(let t of this.afterErrorHooks){let r=await t.afterError(e,n,i);n=r.response,i=r.error}return{response:n,error:i}}}function iy(e){return{ok:!0,value:e}}function i_(e){return{ok:!1,error:e}}function iE(e){return btoa(String.fromCodePoint(...e))}let iv=Object.prototype.hasOwnProperty;function iA(e,t){let r=/\{([a-zA-Z0-9_][a-zA-Z0-9_-]*?)\}/g;return function(t={}){return e.replace(r,function(e,r){if(!iv.call(t,r))throw Error(`Parameter '${r}' is required`);let n=t[r];if("string"!=typeof n&&"number"!=typeof n)throw Error(`Parameter '${r}' must be a string or number`);return`${n}`}).replace(/^\/+/,"")}}let iT=["https://generativelanguage.googleapis.com"];function iC(e){let t={};for(let[r,n]of Object.entries(e))void 0!==n&&(t[r]=n);return t}function iS(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 ib=(e,t,r)=>{let n="",i=(null==r?void 0:r.explode)?iw(e,t):[[e,t]];if(i.every(([e,t])=>null==t))return;let o=e=>(null==r?void 0:r.charEncoding)==="percent"?encodeURIComponent(e):e,s=o(",");return i.forEach(([e,t])=>{var r,i;let a="",l=null;null!=t&&(null==(l=Array.isArray(t)?null==(r=iN(t,e=>`${o(iP(e))}`))?void 0:r.join(s):iS(t)?null==(i=ik(Object.entries(t),([e,t])=>`${o(e)}${s}${o(iP(t))}`))?void 0:i.join(s):`${o(iP(t))}`)||(a=`${o(e)}=${l}`)&&"="!==a&&(n+=`&${a}`))}),n.slice(1)};function iI(e,t,r){if(void 0===t)return;let n=e=>(null==r?void 0:r.charEncoding)==="percent"?encodeURIComponent(e):e,i=n(JSON.stringify(t,iR));return(null==r?void 0:r.explode)?i:`${n(e)}=${i}`}let iO=(e,t,r)=>{let n="",i=(null==r?void 0:r.explode)?iw(e,t):[[e,t]];if(i.every(([e,t])=>null==t))return;let o=e=>(null==r?void 0:r.charEncoding)==="percent"?encodeURIComponent(e):e;return i.forEach(([e,i])=>{var s;let a="";if(null!=i){if(Array.isArray(i))a=null==(s=iN(i,e=>`${o(iP(e))}`))?void 0:s.join(",");else if(iS(i)){let e=ik(Object.entries(i),([e,t])=>`,${o(e)},${o(iP(t))}`);a=null==e?void 0:e.join("").slice(1)}else{let n=(null==r?void 0:r.explode)&&iS(t)?`${e}=`:"";a=`${n}${o(iP(i))}`}n+=a?`,${a}`:""}}),n.slice(1)};function iw(e,t){return Array.isArray(t)?t.map(t=>[e,t]):iS(t)?Object.entries(null!=t?t:{}).map(([e,t])=>[e,t]):[[e,t]]}function iP(e){return null==e?"":e instanceof Date?e.toISOString():e instanceof Uint8Array?iE(e):"object"==typeof e?JSON.stringify(e,iR):`${e}`}function iR(e,t){return t instanceof Uint8Array?iE(t):t}function iN(e,t){let r=e.reduce((e,r)=>{if(null==r)return e;let n=t(r);return null==n||e.push(n),e},[]);return r.length?r:null}function ik(e,t){let r=[];for(let[n,i]of e){if(null==i)continue;let e=t([n,i]);null!=e&&r.push(e)}return r.length?r:null}let iD=function(e,t){var r,n,i;let o=Object.assign(Object.assign({},t),{explode:null==(r=null==t?void 0:t.explode)||r,charEncoding:null!=(n=null==t?void 0:t.charEncoding)?n:"percent"}),s=new Set(null!=(i=null==t?void 0:t.allowEmptyValue)?i:[]);return function(...e){return e.filter(Boolean).join("&")}(...Object.entries(e).map(([e,t])=>s.has(e)&&(null==t||""===t||Array.isArray(t)&&0===t.length)?`${encodeURIComponent(e)}=`:ib(e,t,o)))},ix=(e,t)=>null==t?fetch(e):fetch(e,t);class iU{constructor(e={}){this.options=e,this.requestHooks=[],this.requestErrorHooks=[],this.responseHooks=[],this.fetcher=e.fetcher||ix}async request(e){let t=e;for(let e of this.requestHooks){let r=await e(t);r&&(t=r)}try{let e=await this.fetcher(t);for(let r of this.responseHooks)await r(e,t);return e}catch(e){for(let r of this.requestErrorHooks)await r(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 r=t.findIndex(t=>t===e[1]);return r>=0&&t.splice(r,1),this}clone(){let e=new iU(this.options);return e.requestHooks=this.requestHooks.slice(),e.requestErrorHooks=this.requestErrorHooks.slice(),e.responseHooks=this.responseHooks.slice(),e}}let iG=/\s*;\s*/g;function iM(e,t){var r;if("*"===t)return!0;let n=(null==(r=e.headers.get("content-type"))?void 0:r.trim())||"application/octet-stream";n=n.toLowerCase();let[i="",...o]=t.toLowerCase().trim().split(iG);if(2!==i.split("/").length)return!1;let[s="",...a]=n.split(iG),[l="",u=""]=s.split("/");if(!l||!u||"*/*"!==i&&s!==i&&`${l}/*`!==i&&`*/${u}`!==i||a.length<o.length)return!1;let c=new Set(a);for(let e of o)if(!c.has(e))return!1;return!0}let ij=RegExp("^[0-9]xx$","i");function iL(e,t){let r=`${e.status}`,n=Array.isArray(t)?t:[t];return!!n.length&&n.some(e=>{let t=`${e}`;if("default"===t)return!0;if(!ij.test(`${t}`))return t===r;let n=t.charAt(0);if(!n)throw Error("Invalid status code range");let i=r.charAt(0);if(!i)throw Error(`Invalid response status code: ${r}`);return i===n})}function iF(e){if("object"!=typeof e||null==e)return!1;let t=e instanceof TypeError&&e.message.toLowerCase().startsWith("failed to fetch"),r=e instanceof TypeError&&e.message.toLowerCase().startsWith("fetch failed"),n="name"in e&&"ConnectionError"===e.name,i="code"in e&&"string"==typeof e.code&&"econnreset"===e.code.toLowerCase();return t||r||i||n}function iq(e){if("object"!=typeof e||null==e)return!1;let t="name"in e&&"TimeoutError"===e.name,r="code"in e&&23===e.code,n="code"in e&&"string"==typeof e.code&&"econnaborted"===e.code.toLowerCase();return t||r||n}let iH={initialInterval:500,maxInterval:6e4,exponent:1.5,maxElapsedTime:36e5};class iB extends Error{constructor(e,t){let r=e;(null==t?void 0:t.cause)&&(r+=`: ${t.cause}`),super(r,t),this.name="PermanentError",void 0===this.cause&&(this.cause=null==t?void 0:t.cause),Object.setPrototypeOf(this,iB.prototype)}}class iV extends Error{constructor(e,t){super(e),this.response=t,this.name="TemporaryError",Object.setPrototypeOf(this,iV.prototype)}}async function i$(e,t){var r;switch(t.config.strategy){case"backoff":return iK(iJ(e,{statusCodes:t.statusCodes,retryConnectionErrors:!!t.config.retryConnectionErrors}),null!=(r=t.config.backoff)?r:iH);case"attempt-count-backoff":return iY(iJ(e,{statusCodes:t.statusCodes,retryConnectionErrors:!!t.config.retryConnectionErrors}),Object.assign(Object.assign({},iH),t.config.backoff),t.config);default:return await e(0)}}function iJ(e,t){return async r=>{try{var n,i;let o,s=await e(r);if(n=s,i=t.statusCodes,o=`${n.status}`,i.some(e=>{if(!iW.test(e))return e===o;let t=e.charAt(0);if(!t)throw Error("Invalid status code range");let r=o.charAt(0);if(!r)throw Error(`Invalid response status code: ${o}`);return r===t}))throw new iV("Response failed with retryable status code",s);return s}catch(e){if(e instanceof iV||t.retryConnectionErrors&&(iq(e)||iF(e)))throw e;throw new iB("Permanent error",{cause:e})}}}let iW=RegExp("^[0-9]xx$","i");async function iK(e,t){let{maxElapsedTime:r,initialInterval:n,exponent:i,maxInterval:o}=t,s=Date.now(),a=0;for(;;)try{return await e(a)}catch(l){if(l instanceof iB)throw l.cause;if(Date.now()-s>r){if(l instanceof iV)return l.response;throw l}let e=0;l instanceof iV&&(e=iX(l.response)),e<=0&&(e=n*Math.pow(a,i)+1e3*Math.random());let t=Math.min(e,o);await iz(t),a++}}async function iY(e,t,r){let n=0;for(;;)try{return await e(n)}catch(o){if(o instanceof iB)throw o.cause;if(n>=r.maxRetries){if(o instanceof iV)return o.response;throw o}let e=0;o instanceof iV&&(e=iX(o.response)),e<=0&&(e=t.initialInterval*Math.pow(t.exponent,n)*(1-.25*Math.random()));let i=Math.min(e,t.maxInterval);await iz(i),n++}}function iX(e){let t=e.headers.get("retry-after-ms");if(t){let e=Number(t);if(Number.isFinite(e)&&e>=0)return e}let r=e.headers.get("retry-after")||"";if(!r)return 0;let n=Number(r);if(Number.isInteger(n))return 1e3*n;let i=Date.parse(r);if(Number.isInteger(i)){let e=i-Date.now();return e>0?Math.ceil(e):0}return 0}async function iz(e){return new Promise(t=>setTimeout(t,e))}let iQ="u"<typeof globalThis?null:globalThis,iZ="object"==typeof iQ&&null!=iQ&&"importScripts"in iQ&&"function"==typeof iQ.importScripts||"u">typeof navigator&&"serviceWorker"in navigator;class i0{constructor(e={}){const t=e;"object"==typeof t&&null!=t&&"hooks"in t&&t.hooks instanceof ig?this._hooks=t.hooks:this._hooks=new ig;const r=new iU;e.http_client=e.http_client||r;const n=function(e){var t;let r=e.server_url;if(!r){let n=null!=(t=e.server_idx)?t:0;if(n<0||n>=iT.length)throw Error(`Invalid server index ${n}`);r=iT[n]||""}return new URL(iA(r)({}))}(e=this._hooks.sdkInit(e));n&&(n.pathname=n.pathname.replace(/\/+$/,"")+"/"),this._baseURL=n,this._httpClient=e.http_client||r,this._options=Object.assign(Object.assign({},function(e){let t=Object.assign({},e),r=n$();return void 0!==r.GOOGLE_GENAI_API_VERSION&&(null!=t.api_version||(t.api_version=r.GOOGLE_GENAI_API_VERSION)),void 0!==r.GOOGLE_GENAI_API_REVISION&&(null!=t.api_revision||(t.api_revision=r.GOOGLE_GENAI_API_REVISION)),void 0!==r.GOOGLE_GENAI_USER_PROJECT&&(null!=t.user_project||(t.user_project=r.GOOGLE_GENAI_USER_PROJECT)),t}(e)),{hooks:this._hooks}),this._logger=this._options.debug_logger,!this._logger&&n$().GOOGLE_GENAI_DEBUG&&(this._logger=console)}_createRequest(e,t,r){var n,i,o,s,a,l;let u,c,{method:p,path:d,query:h,headers:f,security:m}=t,g=null!=(n=t.baseURL)?n:this._baseURL;if(!g)return i_(new n2("No base URL provided for operation"));let y=new URL(g);d?(y.pathname=y.pathname.replace(/\/+$/,"")+"/",!(u=new URL(d,y)).search&&y.search&&(u.search=y.search)):u=y,u.hash="";let _=e=>Object.entries(e).map(([e,t])=>{if(null==t)return;let r=iS(t)?JSON.stringify(t):t;return ib(e,r,{explode:Array.isArray(r),charEncoding:"percent"})}).filter(e=>void 0!==e).join("&"),E=[h||"",_((null==r?void 0:r.extra_query)||{}),_((null==m?void 0:m.queryParams)||{})].reduce((e,t)=>{if(!t)return e;let r=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&&!r.has(null!=(t=e.split("=")[0])?t:"")}),t].join("&")},u.search.slice(1));E&&(u.search=`?${E}`);let v=new Headers(f),A=null==m?void 0:m.basic.username,T=null==m?void 0:m.basic.password;if(null!=A||null!=T){let e=iE((l=[A||"",T||""].join(":"),new TextEncoder().encode(l)));v.set("Authorization",`Basic ${e}`)}for(let[e,t]of new Headers((null==m?void 0:m.headers)||{}))v.set(e,t);let C=v.get("cookie")||"";for(let[e,t]of Object.entries((null==m?void 0:m.cookies)||{}))C+=`; ${e}=${t}`;for(let[e,t]of(C=C.startsWith("; ")?C.slice(2):C,v.set("cookie",C),new Headers(null!=(i=null==r?void 0:r.headers)?i:null==(o=null==r?void 0:r.fetch_options)?void 0:o.headers)))v.set(e,t);iZ||v.set(null!=(s=t.uaHeader)?s:"user-agent",null!=(a=t.userAgent)?a:"speakeasy-sdk/typescript 2.4.1-preview.4 2.911.0 v1beta @google/genai");let S=t.body,b=Object.fromEntries(Object.entries((null==r?void 0:r.extra_body)||{}).filter(([,e])=>void 0!==e));if(Object.keys(b).length>0){let e,t=new Headers(f).get("content-type")||"";if(!/^(application|text)\/([^+]+\+)*json/.test(t)||"string"!=typeof S&&null!=S)return i_(new n2("extra_body can only be merged into JSON object request bodies"));try{e=S?JSON.parse(S):{}}catch(e){return i_(new n2("extra_body can only be merged into JSON object request bodies",{cause:e}))}if(!iS(e))return i_(new n2("extra_body can only be merged into JSON object request bodies"));S=JSON.stringify(Object.assign(Object.assign({},e),b)),v.delete("content-length")}let I=Object.assign(Object.assign({},null==r?void 0:r.fetch_options),r);(null==I?void 0:I.signal)||null==t.timeout_ms||!(t.timeout_ms>0)||(e.timeout_ms=t.timeout_ms),t.body instanceof ReadableStream&&Object.assign(I,{duplex:"half"});try{c=this._hooks.beforeCreateRequest(e,{url:u,options:Object.assign(Object.assign({},I),{body:null!=S?S:null,headers:v,method:p})})}catch(e){return i_(new n1("Create request hook failed to execute",{cause:e}))}return iy(new Request(c.url,c.options))}async _do(e,t){let{context:r,isErrorStatusCode:n}=t,i=r.timeout_ms;return i$(async()=>{var t;let o=e.clone(),s=o;if(null!=i&&i>0){let e=AbortSignal.timeout(i),r=null!=(t=function(...e){let t=[];for(let r of e)r&&t.push(r);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 r=t;let n=new AbortController,i=n.signal;if(!r.length)return n.signal;if(1===r.length)return r[0]||n.signal;for(let e of r)if(e.aborted)return e;function o(){n.abort(this.reason),function(){for(let e of s){let t=e.deref();t&&t.removeEventListener("abort",o)}}()}let s=[];for(let e of r)s.push(new WeakRef(e)),e.addEventListener("abort",o);return i}}(o.signal,e))?t:e;s=new Request(o,{signal:r})}let a=await this._hooks.beforeRequest(r,s);await i4(this._logger,a).catch(e=>{var t;return null==(t=this._logger)?void 0:t.log("Failed to log request:",e)});let l=await this._httpClient.request(a);try{if(n(l.status)){let e=await this._hooks.afterError(r,l,null);if(e.error)throw e.error;l=e.response||l}else l=await this._hooks.afterSuccess(r,l)}finally{await i3(this._logger,l,a).catch(e=>{var t;return null==(t=this._logger)?void 0:t.log("Failed to log response:",e)})}return l},{config:t.retryConfig,statusCodes:t.retryCodes}).then(e=>iy(e),e=>{switch(!0){case function(e){if("object"!=typeof e||null==e)return!1;let t="name"in e&&"AbortError"===e.name,r="code"in e&&20===e.code,n="code"in e&&"string"==typeof e.code&&"econnaborted"===e.code.toLowerCase();return t||r||n}(e):return i_(new n4("Request aborted by client",{cause:e}));case iq(e):return i_(new n3("Request timed out",{cause:e}));case iF(e):return i_(new n5("Unable to make request",{cause:e}));default:return i_(new n1("Unexpected HTTP client error",{cause:e}))}})}}let i1=/^(application|text)\/([^+]+\+)*json.*/,i2=/^(application|text)\/([^+]+\+)*(jsonl|x-ndjson)\b.*/;async function i4(e,t){if(!e)return;let r=t.headers.get("content-type"),n=(null==r?void 0:r.split(";")[0])||"";for(let[r,n]of(e.group(`> Request: ${t.method} ${t.url}`),e.group("Headers:"),t.headers.entries()))e.log(`${r}: ${n}`);switch(e.groupEnd(),e.group("Body:"),!0){case i1.test(n):e.log(await t.clone().json());break;case n.startsWith("text/"):e.log(await t.clone().text());break;case"multipart/form-data"===n:for(let[r,n]of(await t.clone().formData())){let t=n instanceof Blob?"<Blob>":n;e.log(`${r}: ${t}`)}break;default:e.log(`<${r}>`)}e.groupEnd(),e.groupEnd()}async function i3(e,t,r){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(`< Response: ${r.method} ${r.url}`),e.log("Status Code:",t.status,t.statusText),e.group("Headers:"),t.headers.entries()))e.log(`${n}: ${i}`);switch(e.groupEnd(),e.group("Body:"),!0){case iM(t,"application/json")||i1.test(i)&&!i2.test(i):e.log(await t.clone().json());break;case iM(t,"application/jsonl")||i2.test(i):case iM(t,"text/event-stream"):e.log(`<${n}>`);break;case iM(t,"text/*"):e.log(await t.clone().text());break;case iM(t,"multipart/form-data"):for(let[r,n]of(await t.clone().formData())){let t=n instanceof Blob?"<Blob>":n;e.log(`${r}: ${t}`)}break;default:e.log(`<${n}>`)}e.groupEnd(),e.groupEnd()}class i5 extends n6{constructor(e,t){e&&(e+=": "),e+=`Status ${t.response.status}`;const r=t.response.headers.get("content-type")||'""';"application/json"!==r&&(e+=` Content-Type ${r.includes(" ")?`"${r}"`:r}`);const n=t.body||'""';e+=n.length>100?"\n":". ";let i=n;if(n.length>1e4){const e=n.substring(0,1e4),t=n.length-1e4;i=`${e}...and ${t} more chars`}e+=`Body: ${i}`,super(e=e.trim(),t),this.name="GoogleGenAiDefaultError"}}function i6(e){try{return JSON.parse(e)}catch(t){return e}}class i8 extends ReadableStream{constructor(e,t,r){var n;const i=e.getReader();let o=new Uint8Array(4096),s=0,a=0;const l={eventId:void 0},u=null==(n=null==r?void 0:r.dataRequired)||n;super({async pull(e){try{for(;;){let r=function(e,t,r){for(let n=r;n<t;n++)if(13===e[n]||10===e[n])for(let r of i7){if(n+r.length>t)continue;let i=!0;for(let t=0;t<r.length;t++)if(e[n+t]!==r[t]){i=!1;break}if(i)return{index:n,length:r.length}}return null}(o,s,a);if(!r){a=Math.max(0,s-i9+1);let t=await i.read();if(t.done)return e.close();if(s+t.value.length>o.length){let e=new Uint8Array(Math.max(2*o.length,s+t.value.length));e.set(o.subarray(0,s)),o=e}o.set(t.value,s),s+=t.value.length;continue}let n=o.slice(0,r.index);if(o.copyWithin(0,r.index+r.length,s),s-=r.index+r.length,o.length>4096&&s<=o.length>>2){let e=new Uint8Array(Math.max(4096,2*s));e.set(o.subarray(0,s)),o=e}a=0;let c=function(e,t,r,n){let i=new TextDecoder().decode(e).split(/\r\n|\r|\n/),o=[],s={},a=!0;for(let e of i){if(!e||e.startsWith(":"))continue;a=!1;let t=e.indexOf(":"),n=e,i="";t>0&&(n=e.slice(0,t),i=" "===e[t+1]?e.slice(t+2):e.slice(t+1)),"data"===n?o.push(i):"event"===n?s.event=i:"id"!==n||i.includes("\0")?"retry"===n&&/^\d+$/.test(i)&&(s.retry=Number(i)):r.eventId=i}if(!a){if(s.id=r.eventId,o.length)s.data=o.join("\n");else if(n)return;return t(s)}}(n,t,l,u);if(c&&!c.done)return e.enqueue(c.value);if(null==c?void 0:c.done)return await i.cancel("done"),e.close()}}catch(t){e.error(t),await i.cancel(t)}},cancel:e=>i.cancel(e)})}[Symbol.asyncIterator](e){let t=ReadableStream.prototype[Symbol.asyncIterator];if("function"==typeof t)return t.call(this,e);let r=this.getReader(),n={next:async()=>{let e=await r.read();return e.done?(r.releaseLock(),{done:!0,value:void 0}):{done:!1,value:e.value}},throw:async e=>(await r.cancel(e),r.releaseLock(),{done:!0,value:void 0}),return:async()=>(await r.cancel("done"),r.releaseLock(),{done:!0,value:void 0}),[Symbol.asyncIterator](){return this}},i=Symbol.asyncDispose;return i&&(n[i]=async()=>{var e;await (null==(e=n.return)?void 0:e.call(n))}),n}values(e){return this[Symbol.asyncIterator](e)}}let i7=[[13,10,13,10],[13,10,13],[13,10,10],[13,13,10],[10,13,10],[13,13],[10,13],[10,10]],i9=i7.reduce((e,t)=>Math.max(e,t.length),0),oe={jsonl:"application/jsonl",json:"application/json",text:"text/plain",bytes:"application/octet-stream",stream:"application/octet-stream",sse:"text/event-stream",nil:"*",fail:"*"};function ot(e,t,r){return Object.assign(Object.assign({},r),{err:!0,enc:"json",codes:e,errorClass:t})}function or(e,t){return Object.assign(Object.assign({},t),{enc:"json",codes:e})}function on(e,t,r){return Object.assign(Object.assign(Object.assign({},r),{enc:"sse",codes:e}),t?{sse:t}:{})}function oi(e){return{enc:"fail",codes:e}}function oo(...e){return async function(t,r,n){let i,o,s;for(let r of e){let{codes:e}=r,n="ctype"in r?r.ctype:oe[r.enc];if(n&&iL(t,e)&&iM(t,n)||!n&&iL(t,e)){o=r;break}}if(!o)return[{ok:!1,error:new i5("Unexpected Status or Content-Type",{response:t,request:r,body:await t.text().catch(()=>"")})},i];let a=o.enc,l="";switch(a){case"json":l=await t.text();try{i=JSON.parse(l)}catch(e){if(!("err"in o))throw e;i=l}break;case"jsonl":case"stream":i=t.body;break;case"bytes":i=new Uint8Array(await t.arrayBuffer());break;case"text":case"fail":i=l=await t.text();break;case"sse":if(t.body){let e="sse"in o&&o.sse||{};i=function(e,t={}){var r,n;let i=!0===t.flattened,o=null!=(r=t.sentinel)?r:"";return new i8(e,e=>""!==o&&e.data===o?{done:!0,value:void 0}:i?{done:!1,value:null==e.data?void 0:i6(e.data)}:{done:!1,value:Object.assign(Object.assign({},e),{data:null==e.data?e.data:i6(e.data)})},{dataRequired:null==(n=t.dataRequired)||n})}(t.body,e)}else i=null;break;case"nil":l=await t.text(),i=void 0;break;default:throw Error(`Unsupported response type: ${a}`)}if("fail"===o.enc)return[{ok:!1,error:new i5("API error occurred",{request:r,response:t,body:l})},i];let u=o.key||(null==n?void 0:n.resultKey),c=o.hdrs?{headers:function(e){let t={};for(let[r,n]of e.entries())t[r]=n.split(os);return t}(t.headers)}:null;return(s="err"in o?Object.assign(Object.assign(Object.assign({},null==n?void 0:n.extraFields),c),iS(i)?i:null):u?Object.assign(Object.assign(Object.assign({},null==n?void 0:n.extraFields),c),{[u]:i}):o.hdrs?Object.assign(Object.assign(Object.assign({},null==n?void 0:n.extraFields),c),iS(i)?i:null):i,"err"in o)?[{ok:!1,error:o.errorClass?new o.errorClass(s,{request:r,response:t,body:l}):s},i]:[{ok:!0,value:s},i]}}let os=/, */;(eT=tk||(tk={})).Incomplete="incomplete",eT.UnrecognisedSecurityType="unrecognized_security_type";class oa extends Error{constructor(e,t){super(t),this.code=e,this.name="SecurityError"}static incomplete(){return new oa(tk.Incomplete,"Security requirements not met in order to perform the operation")}static unrecognizedType(e){return new oa(tk.UnrecognisedSecurityType,`Unrecognised security type: ${e}`)}}function ol(e,t){var r,n;return function(...e){let t={basic:{},headers:{},queryParams:{},cookies:{},oauth2:{type:"none"}},r=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==r?null:(r.forEach(e=>{if(null==e.value)return;let{type:r}=e;switch(r){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 n,i;n=t,null!=(i=e).value&&(n.basic=i.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 r=t.value;"bearer "!==r.slice(0,7).toLowerCase()&&(r=`Bearer ${r}`),void 0!==t.fieldName&&(e.headers[t.fieldName]=r)}(t,e);break;default:throw oa.unrecognizedType(r)}}),t)}([{fieldName:"apiKey",type:"http:custom",value:null!=(r=null==e?void 0:e.api_key)?r:n$().GOOGLE_GENAI_API_KEY},{fieldName:"accessToken",type:"http:custom",value:null!=(n=null==e?void 0:e.access_token)?n:n$().GOOGLE_GENAI_ACCESS_TOKEN},{fieldName:"defaultHeaders",type:"http:custom",value:null==e?void 0:e.default_headers}])}async function ou(e){if(null!=e)return"function"==typeof e?e():e}class oc{constructor(e,t){this[tD]="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 r=this._promise.then(([t,r])=>[e(t),r]);return r.catch(()=>{}),new oc(r,null!=(t=this._callSource)?t:void 0)}}function op(e){let t=e.$inspect(),r=t.then(([e,t])=>{if(!e.ok)throw e.error;return[e.value,t]}),n=t.then(([e,t])=>{var r;if(!e.ok&&!(null==(r=t.response)?void 0:r.ok))throw e.error;return t});return r.catch(()=>{}),n.catch(()=>{}),new oc(r,n)}async function od(e,t,r,n){var i,o;let s=iI("body",t,{explode:!0}),a={api_version:iO("api_version",null!=r?r:e._options.api_version,{explode:!1,charEncoding:"percent"})},l=iA("/{api_version}/agents")(a),u=new Headers(iC({"Content-Type":"application/json",Accept:"application/json"})),c=ol(await ou(e._options.security)),p={options:e._options,base_url:null!=(o=null!=(i=null==n?void 0:n.server_url)?i:e._baseURL)?o:"",operation_id:"CreateAgent",o_auth2_scopes:null,resolved_security:c,security_source:e._options.security,retry_config:(null==n?void 0:n.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==n?void 0:n.retry_codes)||["408","409","429","5XX"]},d=e._createRequest(p,{security:c,method:"POST",baseURL:null==n?void 0:n.server_url,path:l,headers:u,body:s,userAgent:e._options.user_agent,timeout_ms:(null==n?void 0:n.timeout_ms)||e._options.timeout_ms||-1},n);if(!d.ok)return[d,{status:"invalid"}];let h=d.value,f=await e._do(h,{context:p,isErrorStatusCode:e=>iL({status:e},["4XX","5XX"]),retryConfig:p.retry_config,retryCodes:p.retry_codes});if(!f.ok)return[f,{status:"request-error",request:h}];let m=f.value,[g]=await oo(oi("4XX"),oi("5XX"),or("default"))(m,h);return!g.ok,[g,{status:"complete",request:h,response:m}]}async function oh(e,t,r,n){var i,o;let s={api_version:iO("api_version",null!=r?r:e._options.api_version,{explode:!1,charEncoding:"percent"}),id:iO("id",t,{explode:!1,charEncoding:"percent"})},a=iA("/{api_version}/agents/{id}")(s),l=new Headers(iC({Accept:"application/json"})),u=ol(await ou(e._options.security)),c={options:e._options,base_url:null!=(o=null!=(i=null==n?void 0:n.server_url)?i:e._baseURL)?o:"",operation_id:"DeleteAgent",o_auth2_scopes:null,resolved_security:u,security_source:e._options.security,retry_config:(null==n?void 0:n.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==n?void 0:n.retry_codes)||["408","409","429","5XX"]},p=e._createRequest(c,{security:u,method:"DELETE",baseURL:null==n?void 0:n.server_url,path:a,headers:l,body:null,userAgent:e._options.user_agent,timeout_ms:(null==n?void 0:n.timeout_ms)||e._options.timeout_ms||-1},n);if(!p.ok)return[p,{status:"invalid"}];let d=p.value,h=await e._do(d,{context:c,isErrorStatusCode:e=>iL({status:e},["4XX","5XX"]),retryConfig:c.retry_config,retryCodes:c.retry_codes});if(!h.ok)return[h,{status:"request-error",request:d}];let f=h.value,[m]=await oo(oi("4XX"),oi("5XX"),or("default"))(f,d);return!m.ok,[m,{status:"complete",request:d,response:f}]}async function of(e,t,r,n){var i,o;let s={api_version:iO("api_version",null!=r?r:e._options.api_version,{explode:!1,charEncoding:"percent"}),id:iO("id",t,{explode:!1,charEncoding:"percent"})},a=iA("/{api_version}/agents/{id}")(s),l=new Headers(iC({Accept:"application/json"})),u=ol(await ou(e._options.security)),c={options:e._options,base_url:null!=(o=null!=(i=null==n?void 0:n.server_url)?i:e._baseURL)?o:"",operation_id:"GetAgent",o_auth2_scopes:null,resolved_security:u,security_source:e._options.security,retry_config:(null==n?void 0:n.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==n?void 0:n.retry_codes)||["408","409","429","5XX"]},p=e._createRequest(c,{security:u,method:"GET",baseURL:null==n?void 0:n.server_url,path:a,headers:l,body:null,userAgent:e._options.user_agent,timeout_ms:(null==n?void 0:n.timeout_ms)||e._options.timeout_ms||-1},n);if(!p.ok)return[p,{status:"invalid"}];let d=p.value,h=await e._do(d,{context:c,isErrorStatusCode:e=>iL({status:e},["4XX","5XX"]),retryConfig:c.retry_config,retryCodes:c.retry_codes});if(!h.ok)return[h,{status:"request-error",request:d}];let f=h.value,[m]=await oo(oi("4XX"),oi("5XX"),or("default"))(f,d);return!m.ok,[m,{status:"complete",request:d,response:f}]}async function om(e,t,r,n,i,o){var s,a,l;let u={api_version:t,page_size:r,page_token:n,parent:i},c={api_version:iO("api_version",null!=(s=null==u?void 0:u.api_version)?s:e._options.api_version,{explode:!1,charEncoding:"percent"})},p=iA("/{api_version}/agents")(c),d=iD({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}),h=new Headers(iC({Accept:"application/json"})),f=ol(await ou(e._options.security)),m={options:e._options,base_url:null!=(l=null!=(a=null==o?void 0:o.server_url)?a:e._baseURL)?l:"",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(m,{security:f,method:"GET",baseURL:null==o?void 0:o.server_url,path:p,headers:h,query:d,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 y=g.value,_=await e._do(y,{context:m,isErrorStatusCode:e=>iL({status:e},["4XX","5XX"]),retryConfig:m.retry_config,retryCodes:m.retry_codes});if(!_.ok)return[_,{status:"request-error",request:y}];let E=_.value,[v]=await oo(oi("4XX"),oi("5XX"),or("default"))(E,y);return!v.ok,[v,{status:"complete",request:y,response:E}]}tD=Symbol.toStringTag;class og extends i0{create(e,t){let{api_version:r}=e;return op(new oc(od(this,r0(e,["api_version"]),r,t)))}list(e,t){var r,n,i;return op((r=null==e?void 0:e.api_version,n=null==e?void 0:e.page_size,i=null==e?void 0:e.page_token,new oc(om(this,r,n,i,null==e?void 0:e.parent,t))))}get(e,t,r){return op(new oc(of(this,e,null==t?void 0:t.api_version,r)))}delete(e,t,r){return op(new oc(oh(this,e,null==t?void 0:t.api_version,r)))}}class oy extends n6{constructor(e,t){var r;super((null==(r=e.error)?void 0:r.message)||`API error occurred: ${JSON.stringify(e)}`,t),this.data$=e,this.error=e.error,this.name="CancelInteractionByIdServerError"}}class o_ extends n6{constructor(e,t){var r;super((null==(r=e.error)?void 0:r.message)||`API error occurred: ${JSON.stringify(e)}`,t),this.data$=e,this.error=e.error,this.name="CancelInteractionByIdClientError"}}class oE extends n6{constructor(e,t){var r;super((null==(r=e.error)?void 0:r.message)||`API error occurred: ${JSON.stringify(e)}`,t),this.data$=e,this.error=e.error,this.name="CreateInteractionServerError"}}class ov extends n6{constructor(e,t){var r;super((null==(r=e.error)?void 0:r.message)||`API error occurred: ${JSON.stringify(e)}`,t),this.data$=e,this.error=e.error,this.name="CreateInteractionClientError"}}class oA extends n6{constructor(e,t){var r;super((null==(r=e.error)?void 0:r.message)||`API error occurred: ${JSON.stringify(e)}`,t),this.data$=e,this.error=e.error,this.name="DeleteInteractionServerError"}}class oT extends n6{constructor(e,t){var r;super((null==(r=e.error)?void 0:r.message)||`API error occurred: ${JSON.stringify(e)}`,t),this.data$=e,this.error=e.error,this.name="DeleteInteractionClientError"}}class oC extends n6{constructor(e,t){var r;super((null==(r=e.error)?void 0:r.message)||`API error occurred: ${JSON.stringify(e)}`,t),this.data$=e,this.error=e.error,this.name="GetInteractionByIdServerError"}}class oS extends n6{constructor(e,t){var r;super((null==(r=e.error)?void 0:r.message)||`API error occurred: ${JSON.stringify(e)}`,t),this.data$=e,this.error=e.error,this.name="GetInteractionByIdClientError"}}async function ob(e,t,r,n){var i,o;let s={api_version:iO("api_version",null!=r?r:e._options.api_version,{explode:!1,charEncoding:"percent"}),id:iO("id",t,{explode:!1,charEncoding:"percent"})},a=iA("/{api_version}/interactions/{id}/cancel")(s),l=new Headers(iC({Accept:"application/json"})),u=ol(await ou(e._options.security)),c={options:e._options,base_url:null!=(o=null!=(i=null==n?void 0:n.server_url)?i:e._baseURL)?o:"",operation_id:"cancelInteractionById",o_auth2_scopes:null,resolved_security:u,security_source:e._options.security,retry_config:(null==n?void 0:n.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==n?void 0:n.retry_codes)||["408","409","429","5XX"]},p=e._createRequest(c,{security:u,method:"POST",baseURL:null==n?void 0:n.server_url,path:a,headers:l,body:null,userAgent:e._options.user_agent,timeout_ms:(null==n?void 0:n.timeout_ms)||e._options.timeout_ms||-1},n);if(!p.ok)return[p,{status:"invalid"}];let d=p.value,h=await e._do(d,{context:c,isErrorStatusCode:e=>iL({status:e},["4XX","5XX"]),retryConfig:c.retry_config,retryCodes:c.retry_codes});if(!h.ok)return[h,{status:"request-error",request:d}];let f=h.value,[m]=await oo(or(200),ot("4XX",o_),ot("5XX",oy))(f,d,{extraFields:{httpMeta:{response:f,request:d}}});return!m.ok,[m,{status:"complete",request:d,response:f}]}async function oI(e,t,r,n){var i,o,s,a;let l={body:t,api_version:r},u=iI("body",l.body,{explode:!0}),c={api_version:iO("api_version",null!=(i=l.api_version)?i:e._options.api_version,{explode:!1,charEncoding:"percent"})},p=iA("/{api_version}/interactions")(c),d=new Headers(iC({"Content-Type":"application/json",Accept:(null==(o=null==l?void 0:l.body)?void 0:o.stream)?"text/event-stream":"application/json"})),h=ol(await ou(e._options.security)),f={options:e._options,base_url:null!=(a=null!=(s=null==n?void 0:n.server_url)?s:e._baseURL)?a:"",operation_id:"CreateInteraction",o_auth2_scopes:null,resolved_security:h,security_source:e._options.security,retry_config:(null==n?void 0:n.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==n?void 0:n.retry_codes)||["408","409","429","5XX"]},m=e._createRequest(f,{security:h,method:"POST",baseURL:null==n?void 0:n.server_url,path:p,headers:d,body:u,userAgent:e._options.user_agent,timeout_ms:(null==n?void 0:n.timeout_ms)||e._options.timeout_ms||-1},n);if(!m.ok)return[m,{status:"invalid"}];let g=m.value,y=await e._do(g,{context:f,isErrorStatusCode:e=>iL({status:e},["4XX","5XX"]),retryConfig:f.retry_config,retryCodes:f.retry_codes});if(!y.ok)return[y,{status:"request-error",request:g}];let _=y.value,[E]=await oo(or(200),on(200,{sentinel:"[DONE]",flattened:!0}),ot("4XX",ov),ot("5XX",oE))(_,g,{extraFields:{httpMeta:{response:_,request:g}}});return!E.ok,[E,{status:"complete",request:g,response:_}]}async function oO(e,t,r,n){var i,o;let s={api_version:iO("api_version",null!=r?r:e._options.api_version,{explode:!1,charEncoding:"percent"}),id:iO("id",t,{explode:!1,charEncoding:"percent"})},a=iA("/{api_version}/interactions/{id}")(s),l=new Headers(iC({Accept:"application/json"})),u=ol(await ou(e._options.security)),c={options:e._options,base_url:null!=(o=null!=(i=null==n?void 0:n.server_url)?i:e._baseURL)?o:"",operation_id:"deleteInteraction",o_auth2_scopes:null,resolved_security:u,security_source:e._options.security,retry_config:(null==n?void 0:n.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==n?void 0:n.retry_codes)||["408","409","429","5XX"]},p=e._createRequest(c,{security:u,method:"DELETE",baseURL:null==n?void 0:n.server_url,path:a,headers:l,body:null,userAgent:e._options.user_agent,timeout_ms:(null==n?void 0:n.timeout_ms)||e._options.timeout_ms||-1},n);if(!p.ok)return[p,{status:"invalid"}];let d=p.value,h=await e._do(d,{context:c,isErrorStatusCode:e=>iL({status:e},["4XX","5XX"]),retryConfig:c.retry_config,retryCodes:c.retry_codes});if(!h.ok)return[h,{status:"request-error",request:d}];let f=h.value,[m]=await oo(Object.assign(Object.assign({},void 0),{enc:"nil",codes:200}),ot("4XX",oT),ot("5XX",oA))(f,d,{extraFields:{httpMeta:{response:f,request:d}}});return!m.ok,[m,{status:"complete",request:d,response:f}]}async function ow(e,t,r,n,i,o,s){var a,l,u;let c={id:t,stream:r,last_event_id:n,include_input:i,api_version:o},p={api_version:iO("api_version",null!=(a=c.api_version)?a:e._options.api_version,{explode:!1,charEncoding:"percent"}),id:iO("id",c.id,{explode:!1,charEncoding:"percent"})},d=iA("/{api_version}/interactions/{id}")(p),h=iD({include_input:c.include_input,last_event_id:c.last_event_id,stream:c.stream}),f=new Headers(iC({Accept:(null==c?void 0:c.stream)?"text/event-stream":"application/json"})),m=ol(await ou(e._options.security)),g={options:e._options,base_url:null!=(u=null!=(l=null==s?void 0:s.server_url)?l:e._baseURL)?u:"",operation_id:"getInteractionById",o_auth2_scopes:null,resolved_security:m,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"]},y=e._createRequest(g,{security:m,method:"GET",baseURL:null==s?void 0:s.server_url,path:d,headers:f,query:h,body:null,userAgent:e._options.user_agent,timeout_ms:(null==s?void 0:s.timeout_ms)||e._options.timeout_ms||-1},s);if(!y.ok)return[y,{status:"invalid"}];let _=y.value,E=await e._do(_,{context:g,isErrorStatusCode:e=>iL({status:e},["4XX","5XX"]),retryConfig:g.retry_config,retryCodes:g.retry_codes});if(!E.ok)return[E,{status:"request-error",request:_}];let v=E.value,[A]=await oo(or(200),on(200,{sentinel:"[DONE]",flattened:!0}),ot("4XX",oS),ot("5XX",oC))(v,_,{extraFields:{httpMeta:{response:v,request:_}}});return!A.ok,[A,{status:"complete",request:_,response:v}]}class oP extends i0{create(e,t){let{api_version:r}=e;return op(new oc(oI(this,r0(e,["api_version"]),r,t)))}get(e,t,r){var n,i,o;return op((n=null==t?void 0:t.stream,i=null==t?void 0:t.last_event_id,o=null==t?void 0:t.include_input,new oc(ow(this,e,n,i,o,null==t?void 0:t.api_version,r))))}delete(e,t,r){return op(new oc(oO(this,e,null==t?void 0:t.api_version,r)))}cancel(e,t,r){return op(new oc(ob(this,e,null==t?void 0:t.api_version,r)))}}async function oR(e,t,r,n){var i,o;let s=iI("body",t,{explode:!0}),a={api_version:iO("api_version",null!=r?r:e._options.api_version,{explode:!1,charEncoding:"percent"})},l=iA("/{api_version}/webhooks")(a),u=new Headers(iC({"Content-Type":"application/json",Accept:"application/json"})),c=ol(await ou(e._options.security)),p={options:e._options,base_url:null!=(o=null!=(i=null==n?void 0:n.server_url)?i:e._baseURL)?o:"",operation_id:"CreateWebhook",o_auth2_scopes:null,resolved_security:c,security_source:e._options.security,retry_config:(null==n?void 0:n.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==n?void 0:n.retry_codes)||["408","409","429","5XX"]},d=e._createRequest(p,{security:c,method:"POST",baseURL:null==n?void 0:n.server_url,path:l,headers:u,body:s,userAgent:e._options.user_agent,timeout_ms:(null==n?void 0:n.timeout_ms)||e._options.timeout_ms||-1},n);if(!d.ok)return[d,{status:"invalid"}];let h=d.value,f=await e._do(h,{context:p,isErrorStatusCode:e=>iL({status:e},["4XX","5XX"]),retryConfig:p.retry_config,retryCodes:p.retry_codes});if(!f.ok)return[f,{status:"request-error",request:h}];let m=f.value,[g]=await oo(oi("4XX"),oi("5XX"),or("default"))(m,h);return!g.ok,[g,{status:"complete",request:h,response:m}]}async function oN(e,t,r,n){var i,o;let s={api_version:iO("api_version",null!=r?r:e._options.api_version,{explode:!1,charEncoding:"percent"}),id:iO("id",t,{explode:!1,charEncoding:"percent"})},a=iA("/{api_version}/webhooks/{id}")(s),l=new Headers(iC({Accept:"application/json"})),u=ol(await ou(e._options.security)),c={options:e._options,base_url:null!=(o=null!=(i=null==n?void 0:n.server_url)?i:e._baseURL)?o:"",operation_id:"DeleteWebhook",o_auth2_scopes:null,resolved_security:u,security_source:e._options.security,retry_config:(null==n?void 0:n.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==n?void 0:n.retry_codes)||["408","409","429","5XX"]},p=e._createRequest(c,{security:u,method:"DELETE",baseURL:null==n?void 0:n.server_url,path:a,headers:l,body:null,userAgent:e._options.user_agent,timeout_ms:(null==n?void 0:n.timeout_ms)||e._options.timeout_ms||-1},n);if(!p.ok)return[p,{status:"invalid"}];let d=p.value,h=await e._do(d,{context:c,isErrorStatusCode:e=>iL({status:e},["4XX","5XX"]),retryConfig:c.retry_config,retryCodes:c.retry_codes});if(!h.ok)return[h,{status:"request-error",request:d}];let f=h.value,[m]=await oo(oi("4XX"),oi("5XX"),or("default"))(f,d);return!m.ok,[m,{status:"complete",request:d,response:f}]}async function ok(e,t,r,n){var i,o;let s={api_version:iO("api_version",null!=r?r:e._options.api_version,{explode:!1,charEncoding:"percent"}),id:iO("id",t,{explode:!1,charEncoding:"percent"})},a=iA("/{api_version}/webhooks/{id}")(s),l=new Headers(iC({Accept:"application/json"})),u=ol(await ou(e._options.security)),c={options:e._options,base_url:null!=(o=null!=(i=null==n?void 0:n.server_url)?i:e._baseURL)?o:"",operation_id:"GetWebhook",o_auth2_scopes:null,resolved_security:u,security_source:e._options.security,retry_config:(null==n?void 0:n.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==n?void 0:n.retry_codes)||["408","409","429","5XX"]},p=e._createRequest(c,{security:u,method:"GET",baseURL:null==n?void 0:n.server_url,path:a,headers:l,body:null,userAgent:e._options.user_agent,timeout_ms:(null==n?void 0:n.timeout_ms)||e._options.timeout_ms||-1},n);if(!p.ok)return[p,{status:"invalid"}];let d=p.value,h=await e._do(d,{context:c,isErrorStatusCode:e=>iL({status:e},["4XX","5XX"]),retryConfig:c.retry_config,retryCodes:c.retry_codes});if(!h.ok)return[h,{status:"request-error",request:d}];let f=h.value,[m]=await oo(oi("4XX"),oi("5XX"),or("default"))(f,d);return!m.ok,[m,{status:"complete",request:d,response:f}]}async function oD(e,t,r,n,i){var o,s,a;let l={api_version:t,page_size:r,page_token:n},u={api_version:iO("api_version",null!=(o=null==l?void 0:l.api_version)?o:e._options.api_version,{explode:!1,charEncoding:"percent"})},c=iA("/{api_version}/webhooks")(u),p=iD({page_size:null==l?void 0:l.page_size,page_token:null==l?void 0:l.page_token}),d=new Headers(iC({Accept:"application/json"})),h=ol(await ou(e._options.security)),f={options:e._options,base_url:null!=(a=null!=(s=null==i?void 0:i.server_url)?s:e._baseURL)?a:"",operation_id:"ListWebhooks",o_auth2_scopes:null,resolved_security:h,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"]},m=e._createRequest(f,{security:h,method:"GET",baseURL:null==i?void 0:i.server_url,path:c,headers:d,query:p,body:null,userAgent:e._options.user_agent,timeout_ms:(null==i?void 0:i.timeout_ms)||e._options.timeout_ms||-1},i);if(!m.ok)return[m,{status:"invalid"}];let g=m.value,y=await e._do(g,{context:f,isErrorStatusCode:e=>iL({status:e},["4XX","5XX"]),retryConfig:f.retry_config,retryCodes:f.retry_codes});if(!y.ok)return[y,{status:"request-error",request:g}];let _=y.value,[E]=await oo(oi("4XX"),oi("5XX"),or("default"))(_,g);return!E.ok,[E,{status:"complete",request:g,response:_}]}async function ox(e,t,r,n,i){var o,s;let a=iI("body",n,{explode:!0}),l={api_version:iO("api_version",null!=r?r:e._options.api_version,{explode:!1,charEncoding:"percent"}),id:iO("id",t,{explode:!1,charEncoding:"percent"})},u=iA("/{api_version}/webhooks/{id}:ping")(l),c=new Headers(iC({"Content-Type":"application/json",Accept:"application/json"})),p=ol(await ou(e._options.security)),d={options:e._options,base_url:null!=(s=null!=(o=null==i?void 0:i.server_url)?o:e._baseURL)?s:"",operation_id:"PingWebhook",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"]},h=e._createRequest(d,{security:p,method:"POST",baseURL:null==i?void 0:i.server_url,path:u,headers:c,body:a,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 f=h.value,m=await e._do(f,{context:d,isErrorStatusCode:e=>iL({status:e},["4XX","5XX"]),retryConfig:d.retry_config,retryCodes:d.retry_codes});if(!m.ok)return[m,{status:"request-error",request:f}];let g=m.value,[y]=await oo(oi("4XX"),oi("5XX"),or("default"))(g,f);return!y.ok,[y,{status:"complete",request:f,response:g}]}async function oU(e,t,r,n,i){var o,s;let a=iI("body",n,{explode:!0}),l={api_version:iO("api_version",null!=r?r:e._options.api_version,{explode:!1,charEncoding:"percent"}),id:iO("id",t,{explode:!1,charEncoding:"percent"})},u=iA("/{api_version}/webhooks/{id}:rotateSigningSecret")(l),c=new Headers(iC({"Content-Type":"application/json",Accept:"application/json"})),p=ol(await ou(e._options.security)),d={options:e._options,base_url:null!=(s=null!=(o=null==i?void 0:i.server_url)?o:e._baseURL)?s:"",operation_id:"RotateSigningSecret",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"]},h=e._createRequest(d,{security:p,method:"POST",baseURL:null==i?void 0:i.server_url,path:u,headers:c,body:a,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 f=h.value,m=await e._do(f,{context:d,isErrorStatusCode:e=>iL({status:e},["4XX","5XX"]),retryConfig:d.retry_config,retryCodes:d.retry_codes});if(!m.ok)return[m,{status:"request-error",request:f}];let g=m.value,[y]=await oo(oi("4XX"),oi("5XX"),or("default"))(g,f);return!y.ok,[y,{status:"complete",request:f,response:g}]}async function oG(e,t,r,n,i,o){var s,a;let l=iI("body",i,{explode:!0}),u={api_version:iO("api_version",null!=r?r:e._options.api_version,{explode:!1,charEncoding:"percent"}),id:iO("id",t,{explode:!1,charEncoding:"percent"})},c=iA("/{api_version}/webhooks/{id}")(u),p=iD({update_mask:n}),d=new Headers(iC({"Content-Type":"application/json",Accept:"application/json"})),h=ol(await ou(e._options.security)),f={options:e._options,base_url:null!=(a=null!=(s=null==o?void 0:o.server_url)?s:e._baseURL)?a:"",operation_id:"UpdateWebhook",o_auth2_scopes:null,resolved_security:h,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"]},m=e._createRequest(f,{security:h,method:"PATCH",baseURL:null==o?void 0:o.server_url,path:c,headers:d,query:p,body:l,userAgent:e._options.user_agent,timeout_ms:(null==o?void 0:o.timeout_ms)||e._options.timeout_ms||-1},o);if(!m.ok)return[m,{status:"invalid"}];let g=m.value,y=await e._do(g,{context:f,isErrorStatusCode:e=>iL({status:e},["4XX","5XX"]),retryConfig:f.retry_config,retryCodes:f.retry_codes});if(!y.ok)return[y,{status:"request-error",request:g}];let _=y.value,[E]=await oo(oi("4XX"),oi("5XX"),or("default"))(_,g);return!E.ok,[E,{status:"complete",request:g,response:_}]}class oM extends i0{create(e,t){let{api_version:r}=e;return op(new oc(oR(this,r0(e,["api_version"]),r,t)))}list(e,t){var r,n;return op((r=null==e?void 0:e.api_version,n=null==e?void 0:e.page_size,new oc(oD(this,r,n,null==e?void 0:e.page_token,t))))}get(e,t,r){return op(new oc(ok(this,e,null==t?void 0:t.api_version,r)))}update(e,t,r){let n=null!=t?t:{},{api_version:i,update_mask:o}=n,s=r0(n,["api_version","update_mask"]);return op(new oc(oG(this,e,i,o,void 0===t||0===Object.keys(s).length?void 0:s,r)))}delete(e,t,r){return op(new oc(oN(this,e,null==t?void 0:t.api_version,r)))}rotateSigningSecret(e,t,r,n){return op(new oc(oU(this,e,t,r,n)))}ping(e,t,r,n){return op(new oc(ox(this,e,t,r,n)))}}let oj=class extends i0{get interactions(){var e;return null!=(e=this._interactions)?e:this._interactions=new oP(this._options)}get webhooks(){var e;return null!=(e=this._webhooks)?e:this._webhooks=new oM(this._options)}get agents(){var e;return null!=(e=this._agents)?e:this._agents=new og(this._options)}},oL=new Set(["lyria-3-pro-preview","lyria-3-clip-preview"]);function oF(e,t={}){var r,n,i,o;let s,a,l;return new oj(Object.assign(Object.assign({},t),{api_version:null!=(r=t.api_version)?r:(s=e.getApiVersion().replace(/^\/+|\/+$/g,""),a=e.getProject(),l=e.getLocation(),e.isVertexAI()&&s&&a&&l?`${s}/projects/${encodeURIComponent(a)}/locations/${encodeURIComponent(l)}`:s),security:null!=(n=t.security)?n:new nJ({defaultHeaders:null==(i=e.getDefaultHeaders)?void 0:i.call(e),getAuthHeaders:t=>e.getAuthHeaders(t)}),server_url:null!=(o=t.server_url)?o:function(e){let t=e.getBaseUrl();if(!t)throw Error("Base URL must be set.");return t.replace(/\/+$/,"")}(e)}))}class oq{constructor(e){this.parentClient=e}async create(e,t){let{api_version:r}=e,n=r0(e,["api_version"]);return!0===n.stream?oK(await oW(()=>this.getClient(r).interactions.create(Object.assign(Object.assign({},n),{stream:!0,api_version:r}),oV(t,!0)))):oY(await oJ(new oc(oI(this.getClient(r),n,r,oV(t)))))}async get(e,t={},r){let{api_version:n,stream:i=!1,last_event_id:o,include_input:s}=null!=t?t:{};return!0===i?oK(await oW(()=>this.getClient(n).interactions.get(e,{stream:i,last_event_id:o,include_input:s,api_version:n},oV(r,!0)))):oY(await oJ(new oc(ow(this.getClient(n),e,i,o,s,n,oV(r)))))}async delete(e,t={},r){return oW(()=>this.getClient(null==t?void 0:t.api_version).interactions.delete(e,{api_version:null==t?void 0:t.api_version},oV(r)))}async cancel(e,t={},r){var n;return oY(await oJ((n=this.getClient(null==t?void 0:t.api_version),new oc(ob(n,e,null==t?void 0:t.api_version,oV(r))))))}getClient(e){return e?oF(this.parentClient,{api_version:e}):(null!=this.sdk||(this.sdk=oF(this.parentClient)),this.sdk)}}class oH{constructor(e){this.parentClient=e}async create(e={},t){let r=null!=e?e:{},{api_version:n}=r,i=r0(r,["api_version"]);return oJ(new oc(od(this.getClient(n),i,n,oV(t))))}async list(e={},t){let{api_version:r,pageSize:n,pageToken:i,parent:o}=null!=e?e:{};return oJ(new oc(om(this.getClient(r),r,n,i,o,oV(t))))}async get(e,t={},r){var n;return oJ((n=this.getClient(null==t?void 0:t.api_version),new oc(of(n,e,null==t?void 0:t.api_version,oV(r)))))}async delete(e,t={},r){var n;return oJ((n=this.getClient(null==t?void 0:t.api_version),new oc(oh(n,e,null==t?void 0:t.api_version,oV(r)))))}getClient(e){return e?oF(this.parentClient,{api_version:e}):(null!=this.sdk||(this.sdk=oF(this.parentClient)),this.sdk)}}class oB{constructor(e){this.parentClient=e}async create(e,t){let{api_version:r}=e,n=r0(e,["api_version"]);return oJ(new oc(oR(this.getClient(),n,r,oV(t))))}async list(e={},t){let{api_version:r,page_size:n,page_token:i}=null!=e?e:{};return oJ(new oc(oD(this.getClient(),r,n,i,oV(t))))}async get(e,t={},r){var n;return oJ((n=this.getClient(),new oc(ok(n,e,null==t?void 0:t.api_version,oV(r)))))}async update(e,t={},r){let n=null!=t?t:{},{api_version:i,update_mask:o}=n,s=r0(n,["api_version","update_mask"]);return oJ(new oc(oG(this.getClient(),e,i,o,s,oV(r))))}async delete(e,t={},r){var n;return oJ((n=this.getClient(),new oc(oN(n,e,null==t?void 0:t.api_version,oV(r)))))}async rotateSigningSecret(e,t={},r){let n=null!=t?t:{},{api_version:i}=n,o=r0(n,["api_version"]);return oJ(new oc(oU(this.getClient(),e,i,o,oV(r))))}async ping(e,t,r){let{api_version:n,body:i}=null!=t?t:{};return oJ(new oc(ox(this.getClient(),e,n,i,oV(r))))}getClient(){return null!=this.sdk||(this.sdk=oF(this.parentClient)),this.sdk}}function oV(e,t=!1){var r,n,i,o;if(!e&&!t)return;let s=null!=e?e:{},{timeout:a,maxRetries:l,defaultBaseURL:u,query:c,body:p,fetchOptions:d}=s,h=r0(s,["timeout","maxRetries","defaultBaseURL","query","body","fetchOptions"]),f=Object.assign({},h);oX(c)?f.extra_query=c:o$("query",c),oX(p)?f.extra_body=p:o$("body",p);let m=null!=(r=h.fetch_options)?r:d;m&&(f.fetch_options=m);let g=null!=(n=h.server_url)?n:u;g&&(f.server_url=g);let y=null!=(i=h.timeout_ms)?i:a;if(void 0!==y&&(f.timeout_ms=y),void 0!==l&&(f.retries={strategy:"attempt-count-backoff",retryConnectionErrors:!0,maxRetries:l}),t){let e=new Headers(null!=(o=f.headers)?o:null==m?void 0:m.headers);e.set("Accept","text/event-stream"),f.headers=e}return f}function o$(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 oJ(e){var t,r;let[n,i]=await e.$inspect();if(!n.ok)throw ip(n.error);return t=n.value,r=i,oX(t)&&"complete"===r.status?Object.assign(Object.assign({},t),{sdkHttpResponse:function(e,t){let r={};for(let[t,n]of e.headers.entries())r[t]=n;return{headers:r,responseInternal:e,json:async()=>t}}(r.response,t)}):t}async function oW(e){try{return await e()}catch(e){throw ip(e)}}function oK(e){return new Proxy(e,{get(t,r){if(r!==Symbol.asyncIterator){let e=Reflect.get(t,r,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 ip(e)}},async return(e){if(!t.return)return{done:!0,value:e};try{return await t.return(e)}catch(e){throw ip(e)}},async throw(e){if(!t.throw)throw ip(e);try{return await t.throw(e)}catch(e){throw ip(e)}},[Symbol.asyncIterator](){return this}}}}})}function oY(e){let t=function(e){if(oX(e)){let t;if(Array.isArray(e.steps))return e;if("string"==typeof(t=e.model)&&oL.has(t)){let t=e.outputs;if(Array.isArray(t)){let{outputs:r}=e;return Object.assign(Object.assign({},r0(e,["outputs"])),{steps:[{type:"model_output",content:t}]})}}return Object.assign(Object.assign({},e),{steps:[]})}}(e);return t?function(e){var t,r,n;let i,o,s,a=Object.assign(Object.assign({},n=e),{created:oz(n.created),updated:oz(n.updated)}),l=null!=(t=a.steps)?t:[],u=[],c=!1;t:for(let e=l.length-1;e>=0;e--){let t=l[e];if("user_input"===t.type)break;if("model_output"!==t.type||!t.content){if(c)break;continue}let n=t.content;for(let e=n.length-1;e>=0;e--){let t=n[e];if("text"===t.type)c=!0,u.push(null!=(r=t.text)?r:"");else if(c)break t}}for(let e=l.length-1;e>=0;e--){let t=l[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 r=t.content[e];"image"!==r.type||i||(i=r),"audio"!==r.type||o||(o=r),"video"!==r.type||s||(s=r)}}let p=u.reverse().join("");return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},a),p&&{output_text:p}),i?{output_image:i}:{}),o?{output_audio:o}:{}),s?{output_video:s}:{})}(t):e}function oX(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function oz(e){return e instanceof Date?e.toISOString():e}let oQ="x-goog-api-key",oZ="https://www.googleapis.com/auth/cloud-platform";class o0{constructor(e){if(void 0!==e.apiKey){this.apiKey=e.apiKey;return}const t=function(e){let t;if(!e)return{scopes:[oZ]};if((t=e).scopes){if("string"==typeof t.scopes&&t.scopes!==oZ||Array.isArray(t.scopes)&&0>t.scopes.indexOf(oZ))throw Error(`Invalid auth scopes. Scopes must include: ${oZ}`)}else t.scopes=[oZ];return t}(e.googleAuthOptions);this.googleAuth=new tU.GoogleAuth(t)}async addAuthHeaders(e,t){if(void 0!==this.apiKey){if(this.apiKey.startsWith("auth_tokens/"))throw Error("Ephemeral tokens are only supported by the live API.");this.addKeyHeader(e);return}return this.addGoogleAuthHeaders(e,t)}addKeyHeader(e){if(null===e.get(oQ)){if(void 0===this.apiKey)throw Error("Trying to set API key header but apiKey is not set");e.append(oQ,this.apiKey)}}async addGoogleAuthHeaders(e,t){if(void 0===this.googleAuth)throw Error("Trying to set google-auth headers but googleAuth is unset");for(let[r,n]of(await this.googleAuth.getRequestHeaders(t)))null===e.get(r)&&e.append(r,n)}}class o1{async download(e,t){if(e.downloadPath){let r=await o2(e,t);if(r instanceof tY){let t=(0,tG.createWriteStream)(e.downloadPath);tj.Readable.fromWeb(r.responseInternal.body).pipe(t),await (0,tL.finished)(t)}else try{await (0,tM.writeFile)(e.downloadPath,r,{encoding:"base64"})}catch(t){throw Error(`Failed to write file to ${e.downloadPath}: ${t}`)}}}}async function o2(e,t){var r,n,i;let o=rj(e.file);if(void 0!==o)return await t.request({path:`files/${o}:download`,httpMethod:"GET",queryParams:{alt:"media"},httpOptions:null==(r=e.config)?void 0:r.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal});if(rG(e.file)){let t=null==(i=e.file.video)?void 0:i.videoBytes;if("string"==typeof t)return t;throw Error("Failed to download generated video, Uri or videoBytes not found.")}if(rM(e.file)){let t=e.file.videoBytes;if("string"==typeof t)return t;throw Error("Failed to download video, Uri or videoBytes not found.")}throw Error("Unsupported file type")}class o4{create(e,t,r){return new o3(e,t,r)}}class o3{constructor(e,t,r){this.url=e,this.headers=t,this.callbacks=r}connect(){this.ws=new tF.default(this.url,{headers:this.headers}),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()}}function o5(e,t){let r={},n=t$(e,["parts"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>(function(e){let t={},r=t$(e,["mediaResolution"]);null!=r&&tV(t,["mediaResolution"],r);let n=t$(e,["codeExecutionResult"]);null!=n&&tV(t,["codeExecutionResult"],function(e){let t={},r=t$(e,["outcome"]);null!=r&&tV(t,["outcome"],r);let n=t$(e,["output"]);if(null!=n&&tV(t,["output"],n),void 0!==t$(e,["id"]))throw Error("id parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return t}(n));let i=t$(e,["executableCode"]);null!=i&&tV(t,["executableCode"],function(e){let t={},r=t$(e,["code"]);null!=r&&tV(t,["code"],r);let n=t$(e,["language"]);if(null!=n&&tV(t,["language"],n),void 0!==t$(e,["id"]))throw Error("id parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return t}(i));let o=t$(e,["fileData"]);null!=o&&tV(t,["fileData"],o);let s=t$(e,["functionCall"]);null!=s&&tV(t,["functionCall"],s);let a=t$(e,["functionResponse"]);null!=a&&tV(t,["functionResponse"],a);let l=t$(e,["inlineData"]);null!=l&&tV(t,["inlineData"],l);let u=t$(e,["text"]);null!=u&&tV(t,["text"],u);let c=t$(e,["thought"]);null!=c&&tV(t,["thought"],c);let p=t$(e,["thoughtSignature"]);null!=p&&tV(t,["thoughtSignature"],p);let d=t$(e,["videoMetadata"]);if(null!=d&&tV(t,["videoMetadata"],d),void 0!==t$(e,["toolCall"]))throw Error("toolCall parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");if(void 0!==t$(e,["toolResponse"]))throw Error("toolResponse parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");if(void 0!==t$(e,["partMetadata"]))throw Error("partMetadata parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.");return t})(e))),tV(r,["parts"],e)}let i=t$(e,["role"]);return null!=i&&tV(r,["role"],i),r}function o6(e,t){var r;let n,i,o,s,a,l,u,c,p,d,h,f,m,g,y,_,E,v,A,T,C,S,b,I={},O=t$(e,["adapterSize"]);null!=O&&tV(I,["adapterSize"],O);let w=t$(e,["epochCount"]);null!=w&&tV(I,["epochCount"],w);let P=t$(e,["learningRateMultiplier"]);null!=P&&tV(I,["learningRateMultiplier"],P);let R=t$(e,["generationConfig"]);null!=R&&tV(I,["generationConfig"],(n={},null!=(i=t$(r=R,["modelConfig"]))&&tV(n,["modelSelectionConfig"],i),null!=(o=t$(r,["responseJsonSchema"]))&&tV(n,["responseJsonSchema"],o),null!=(s=t$(r,["audioTimestamp"]))&&tV(n,["audioTimestamp"],s),null!=(a=t$(r,["candidateCount"]))&&tV(n,["candidateCount"],a),null!=(l=t$(r,["enableAffectiveDialog"]))&&tV(n,["enableAffectiveDialog"],l),null!=(u=t$(r,["frequencyPenalty"]))&&tV(n,["frequencyPenalty"],u),null!=(c=t$(r,["logprobs"]))&&tV(n,["logprobs"],c),null!=(p=t$(r,["maxOutputTokens"]))&&tV(n,["maxOutputTokens"],p),null!=(d=t$(r,["mediaResolution"]))&&tV(n,["mediaResolution"],d),null!=(h=t$(r,["presencePenalty"]))&&tV(n,["presencePenalty"],h),null!=(f=t$(r,["responseLogprobs"]))&&tV(n,["responseLogprobs"],f),null!=(m=t$(r,["responseMimeType"]))&&tV(n,["responseMimeType"],m),null!=(g=t$(r,["responseModalities"]))&&tV(n,["responseModalities"],g),null!=(y=t$(r,["responseSchema"]))&&tV(n,["responseSchema"],y),null!=(_=t$(r,["routingConfig"]))&&tV(n,["routingConfig"],_),null!=(E=t$(r,["seed"]))&&tV(n,["seed"],E),null!=(v=t$(r,["speechConfig"]))&&tV(n,["speechConfig"],v),null!=(A=t$(r,["stopSequences"]))&&tV(n,["stopSequences"],A),null!=(T=t$(r,["temperature"]))&&tV(n,["temperature"],T),null!=(C=t$(r,["thinkingConfig"]))&&tV(n,["thinkingConfig"],C),null!=(S=t$(r,["topK"]))&&tV(n,["topK"],S),null!=(b=t$(r,["topP"]))&&tV(n,["topP"],b),n));let N=t$(e,["learningRate"]);null!=N&&tV(I,["learningRate"],N);let k=t$(e,["batchSize"]);return null!=k&&tV(I,["batchSize"],k),I}function o8(e,t){let r,n,i,o,s,a,l,u,c,p,d,h,f,m,g,y,_={},E=t$(e,["sdkHttpResponse"]);null!=E&&tV(_,["sdkHttpResponse"],E);let v=t$(e,["name"]);null!=v&&tV(_,["name"],v);let A=t$(e,["state"]);null!=A&&tV(_,["state"],rU(A));let T=t$(e,["createTime"]);null!=T&&tV(_,["createTime"],T);let C=t$(e,["startTime"]);null!=C&&tV(_,["startTime"],C);let S=t$(e,["endTime"]);null!=S&&tV(_,["endTime"],S);let b=t$(e,["updateTime"]);null!=b&&tV(_,["updateTime"],b);let I=t$(e,["error"]);null!=I&&tV(_,["error"],I);let O=t$(e,["description"]);null!=O&&tV(_,["description"],O);let w=t$(e,["baseModel"]);null!=w&&tV(_,["baseModel"],w);let P=t$(e,["tunedModel"]);null!=P&&tV(_,["tunedModel"],P);let R=t$(e,["preTunedModel"]);null!=R&&tV(_,["preTunedModel"],R);let N=t$(e,["supervisedTuningSpec"]);null!=N&&tV(_,["supervisedTuningSpec"],N);let k=t$(e,["preferenceOptimizationSpec"]);null!=k&&tV(_,["preferenceOptimizationSpec"],k);let D=t$(e,["distillationSpec"]);null!=D&&tV(_,["distillationSpec"],(r={},null!=(n=t$(D,["promptDatasetUri"]))&&tV(r,["promptDatasetUri"],n),null!=(i=t$(D,["baseTeacherModel"]))&&tV(r,["baseTeacherModel"],i),null!=(o=t$(D,["hyperParameters"]))&&tV(r,["hyperParameters"],o6(o)),null!=(s=t$(D,["pipelineRootDirectory"]))&&tV(r,["pipelineRootDirectory"],s),null!=(a=t$(D,["studentModel"]))&&tV(r,["studentModel"],a),null!=(l=t$(D,["trainingDatasetUri"]))&&tV(r,["trainingDatasetUri"],l),null!=(u=t$(D,["tunedTeacherModelSource"]))&&tV(r,["tunedTeacherModelSource"],u),null!=(c=t$(D,["validationDatasetUri"]))&&tV(r,["validationDatasetUri"],c),null!=(p=t$(D,["tuningMode"]))&&tV(r,["tuningMode"],p),r));let x=t$(e,["reinforcementTuningSpec"]);null!=x&&tV(_,["reinforcementTuningSpec"],x);let U=t$(e,["tuningDataStats"]);null!=U&&tV(_,["tuningDataStats"],U);let G=t$(e,["encryptionSpec"]);null!=G&&tV(_,["encryptionSpec"],G);let M=t$(e,["partnerModelTuningSpec"]);null!=M&&tV(_,["partnerModelTuningSpec"],M);let j=t$(e,["customBaseModel"]);null!=j&&tV(_,["customBaseModel"],j);let L=t$(e,["evaluateDatasetRuns"]);if(null!=L){let e=L;Array.isArray(e)&&(e=e.map(e=>e)),tV(_,["evaluateDatasetRuns"],e)}let F=t$(e,["experiment"]);null!=F&&tV(_,["experiment"],F);let q=t$(e,["fullFineTuningSpec"]);null!=q&&tV(_,["fullFineTuningSpec"],q);let H=t$(e,["labels"]);null!=H&&tV(_,["labels"],H);let B=t$(e,["outputUri"]);null!=B&&tV(_,["outputUri"],B);let V=t$(e,["pipelineJob"]);null!=V&&tV(_,["pipelineJob"],V);let $=t$(e,["serviceAccount"]);null!=$&&tV(_,["serviceAccount"],$);let J=t$(e,["tunedModelDisplayName"]);null!=J&&tV(_,["tunedModelDisplayName"],J);let W=t$(e,["tuningJobState"]);null!=W&&tV(_,["tuningJobState"],W);let K=t$(e,["veoTuningSpec"]);null!=K&&tV(_,["veoTuningSpec"],K);let Y=t$(e,["tuningJobMetadata"]);null!=Y&&tV(_,["tuningJobMetadata"],Y);let X=t$(e,["veoLoraTuningSpec"]);null!=X&&tV(_,["veoLoraTuningSpec"],X);let z=t$(e,["distillationSamplingSpec"]);return null!=z&&tV(_,["distillationSamplingSpec"],(d={},null!=(h=t$(z,["baseTeacherModel"]))&&tV(d,["baseTeacherModel"],h),null!=(f=t$(z,["tunedTeacherModelSource"]))&&tV(d,["tunedTeacherModelSource"],f),null!=(m=t$(z,["validationDatasetUri"]))&&tV(d,["validationDatasetUri"],m),null!=(g=t$(z,["promptDatasetUri"]))&&tV(d,["promptDatasetUri"],g),null!=(y=t$(z,["hyperparameters"]))&&tV(d,["hyperparameters"],o6(y)),d)),_}function o7(e,t){let r={},n=t$(e,["gcsUri"]);null!=n&&tV(r,["validationDatasetUri"],n);let i=t$(e,["vertexDatasetResource"]);return null!=i&&tV(r,["validationDatasetUri"],i),r}class o9 extends tH{constructor(e){super(),this.apiClient=e,this.list=async(e={})=>new rY(tN.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 r={tunedModelName:e.baseModel};(null==(t=e.config)?void 0:t.preTunedModelCheckpointId)&&(r.checkpointId=e.config.preTunedModelCheckpointId);let n=Object.assign(Object.assign({},e),{preTunedModel:r});return n.baseModel=void 0,await this.tuneInternal(n)}else{let t=Object.assign({},e);return await this.tuneInternal(t)}{let t=Object.assign({},e),r=await this.tuneMldevInternal(t),n="";return void 0!==r.metadata&&void 0!==r.metadata.tunedModel?n=r.metadata.tunedModel:void 0!==r.name&&r.name.includes("/operations/")&&(n=r.name.split("/operations/")[0]),{name:n,state:e0.JOB_STATE_QUEUED}}}}async getInternal(e){var t,r,n,i;let o="",s={};if(this.apiClient.isVertexAI()){let n,i,a=(n={},null!=(i=t$(e,["name"]))&&tV(n,["_url","name"],i),n);return o=tB("{name}",a._url),s=a._query,delete a._url,delete a._query,this.apiClient.request({path:o,queryParams:s,body:JSON.stringify(a),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>o8(e))}{let t,r,a=(t={},null!=(r=t$(e,["name"]))&&tV(t,["_url","name"],r),t);return o=tB("{name}",a._url),s=a._query,delete a._url,delete a._query,this.apiClient.request({path:o,queryParams:s,body:JSON.stringify(a),httpMethod:"GET",httpOptions:null==(n=e.config)?void 0:n.httpOptions,abortSignal:null==(i=e.config)?void 0:i.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t,r,n,i,o,s,a,l,u,c,p,d,h,f;return t={},null!=(r=t$(e,["sdkHttpResponse"]))&&tV(t,["sdkHttpResponse"],r),null!=(n=t$(e,["name"]))&&tV(t,["name"],n),null!=(i=t$(e,["state"]))&&tV(t,["state"],rU(i)),null!=(o=t$(e,["createTime"]))&&tV(t,["createTime"],o),null!=(s=t$(e,["tuningTask","startTime"]))&&tV(t,["startTime"],s),null!=(a=t$(e,["tuningTask","completeTime"]))&&tV(t,["endTime"],a),null!=(l=t$(e,["updateTime"]))&&tV(t,["updateTime"],l),null!=(u=t$(e,["description"]))&&tV(t,["description"],u),null!=(c=t$(e,["baseModel"]))&&tV(t,["baseModel"],c),null!=(p=t$(e,["_self"]))&&tV(t,["tunedModel"],(d={},null!=(h=t$(p,["name"]))&&tV(d,["model"],h),null!=(f=t$(p,["name"]))&&tV(d,["endpoint"],f),d)),t})}}async listInternal(e){var t,r;let n="",i={};if(this.apiClient.isVertexAI()){let o,s,a,l,u,c=(o={},null!=(s=t$(e,["config"]))&&(a=t$(s,["pageSize"]),void 0!==o&&null!=a&&tV(o,["_query","pageSize"],a),l=t$(s,["pageToken"]),void 0!==o&&null!=l&&tV(o,["_query","pageToken"],l),u=t$(s,["filter"]),void 0!==o&&null!=u&&tV(o,["_query","filter"],u)),o);return n=tB("tuningJobs",c._url),i=c._query,delete c._url,delete c._query,this.apiClient.request({path:n,queryParams:i,body:JSON.stringify(c),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.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={},r=t$(e,["sdkHttpResponse"]);null!=r&&tV(t,["sdkHttpResponse"],r);let n=t$(e,["nextPageToken"]);null!=n&&tV(t,["nextPageToken"],n);let i=t$(e,["tuningJobs"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>o8(e))),tV(t,["tuningJobs"],e)}return t}(e),r=new t7;return Object.assign(r,t),r})}throw Error("This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).")}async cancel(e){var t,r,n,i;let o="",s={};if(this.apiClient.isVertexAI()){let n,i,a=(n={},null!=(i=t$(e,["name"]))&&tV(n,["_url","name"],i),n);return o=tB("{name}:cancel",a._url),s=a._query,delete a._url,delete a._query,this.apiClient.request({path:o,queryParams:s,body:JSON.stringify(a),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.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,r,n=(t={},null!=(r=t$(e,["sdkHttpResponse"]))&&tV(t,["sdkHttpResponse"],r),t),i=new t9;return Object.assign(i,n),i})}{let t,r,a=(t={},null!=(r=t$(e,["name"]))&&tV(t,["_url","name"],r),t);return o=tB("{name}:cancel",a._url),s=a._query,delete a._url,delete a._query,this.apiClient.request({path:o,queryParams:s,body:JSON.stringify(a),httpMethod:"POST",httpOptions:null==(n=e.config)?void 0:n.httpOptions,abortSignal:null==(i=e.config)?void 0:i.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t,r,n=(t={},null!=(r=t$(e,["sdkHttpResponse"]))&&tV(t,["sdkHttpResponse"],r),t),i=new t9;return Object.assign(i,n),i})}}async tuneInternal(e){var t,r;let n="",i={};if(this.apiClient.isVertexAI()){let o,s,a,l,u,c=(o={},null!=(s=t$(e,["baseModel"]))&&tV(o,["baseModel"],s),null!=(a=t$(e,["preTunedModel"]))&&tV(o,["preTunedModel"],a),null!=(l=t$(e,["trainingDataset"]))&&function(e,t,r){let n=t$(r,["config","method"]);if(void 0===n&&(n="SUPERVISED_FINE_TUNING"),"SUPERVISED_FINE_TUNING"===n){let r=t$(e,["gcsUri"]);void 0!==t&&null!=r&&tV(t,["supervisedTuningSpec","trainingDatasetUri"],r)}else if("PREFERENCE_TUNING"===n){let r=t$(e,["gcsUri"]);void 0!==t&&null!=r&&tV(t,["preferenceOptimizationSpec","trainingDatasetUri"],r)}else if("DISTILLATION"===n){let r=t$(e,["gcsUri"]);void 0!==t&&null!=r&&tV(t,["distillationSpec","promptDatasetUri"],r)}else if("REINFORCEMENT_TUNING"===n){let r=t$(e,["gcsUri"]);void 0!==t&&null!=r&&tV(t,["reinforcementTuningSpec","trainingDatasetUri"],r)}let i=t$(r,["config","method"]);if(void 0===i&&(i="SUPERVISED_FINE_TUNING"),"SUPERVISED_FINE_TUNING"===i){let r=t$(e,["vertexDatasetResource"]);void 0!==t&&null!=r&&tV(t,["supervisedTuningSpec","trainingDatasetUri"],r)}else if("PREFERENCE_TUNING"===i){let r=t$(e,["vertexDatasetResource"]);void 0!==t&&null!=r&&tV(t,["preferenceOptimizationSpec","trainingDatasetUri"],r)}else if("DISTILLATION"===i){let r=t$(e,["vertexDatasetResource"]);void 0!==t&&null!=r&&tV(t,["distillationSpec","promptDatasetUri"],r)}else if("REINFORCEMENT_TUNING"===i){let r=t$(e,["vertexDatasetResource"]);void 0!==t&&null!=r&&tV(t,["reinforcementTuningSpec","trainingDatasetUri"],r)}if(void 0!==t$(e,["examples"]))throw Error("examples parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.")}(l,o,e),null!=(u=t$(e,["config"]))&&function(e,t,r){let n=t$(r,["config","method"]);if(void 0===n&&(n="SUPERVISED_FINE_TUNING"),"SUPERVISED_FINE_TUNING"===n){let r=t$(e,["validationDataset"]);void 0!==t&&null!=r&&tV(t,["supervisedTuningSpec"],o7(r))}else if("PREFERENCE_TUNING"===n){let r=t$(e,["validationDataset"]);void 0!==t&&null!=r&&tV(t,["preferenceOptimizationSpec"],o7(r))}else if("DISTILLATION"===n){let r=t$(e,["validationDataset"]);void 0!==t&&null!=r&&tV(t,["distillationSpec"],o7(r))}else if("REINFORCEMENT_TUNING"===n){let r=t$(e,["validationDataset"]);void 0!==t&&null!=r&&tV(t,["reinforcementTuningSpec"],o7(r))}let i=t$(e,["tunedModelDisplayName"]);void 0!==t&&null!=i&&tV(t,["tunedModelDisplayName"],i);let o=t$(e,["description"]);void 0!==t&&null!=o&&tV(t,["description"],o);let s=t$(r,["config","method"]);if(void 0===s&&(s="SUPERVISED_FINE_TUNING"),"SUPERVISED_FINE_TUNING"===s){let r=t$(e,["epochCount"]);void 0!==t&&null!=r&&tV(t,["supervisedTuningSpec","hyperParameters","epochCount"],r)}else if("PREFERENCE_TUNING"===s){let r=t$(e,["epochCount"]);void 0!==t&&null!=r&&tV(t,["preferenceOptimizationSpec","hyperParameters","epochCount"],r)}else if("DISTILLATION"===s){let r=t$(e,["epochCount"]);void 0!==t&&null!=r&&tV(t,["distillationSpec","hyperParameters","epochCount"],r)}else if("REINFORCEMENT_TUNING"===s){let r=t$(e,["epochCount"]);void 0!==t&&null!=r&&tV(t,["reinforcementTuningSpec","hyperParameters","epochCount"],r)}let a=t$(r,["config","method"]);if(void 0===a&&(a="SUPERVISED_FINE_TUNING"),"SUPERVISED_FINE_TUNING"===a){let r=t$(e,["learningRateMultiplier"]);void 0!==t&&null!=r&&tV(t,["supervisedTuningSpec","hyperParameters","learningRateMultiplier"],r)}else if("PREFERENCE_TUNING"===a){let r=t$(e,["learningRateMultiplier"]);void 0!==t&&null!=r&&tV(t,["preferenceOptimizationSpec","hyperParameters","learningRateMultiplier"],r)}else if("DISTILLATION"===a){let r=t$(e,["learningRateMultiplier"]);void 0!==t&&null!=r&&tV(t,["distillationSpec","hyperParameters","learningRateMultiplier"],r)}else if("REINFORCEMENT_TUNING"===a){let r=t$(e,["learningRateMultiplier"]);void 0!==t&&null!=r&&tV(t,["reinforcementTuningSpec","hyperParameters","learningRateMultiplier"],r)}let l=t$(r,["config","method"]);if(void 0===l&&(l="SUPERVISED_FINE_TUNING"),"SUPERVISED_FINE_TUNING"===l){let r=t$(e,["exportLastCheckpointOnly"]);void 0!==t&&null!=r&&tV(t,["supervisedTuningSpec","exportLastCheckpointOnly"],r)}else if("PREFERENCE_TUNING"===l){let r=t$(e,["exportLastCheckpointOnly"]);void 0!==t&&null!=r&&tV(t,["preferenceOptimizationSpec","exportLastCheckpointOnly"],r)}else if("DISTILLATION"===l){let r=t$(e,["exportLastCheckpointOnly"]);void 0!==t&&null!=r&&tV(t,["distillationSpec","exportLastCheckpointOnly"],r)}let u=t$(r,["config","method"]);if(void 0===u&&(u="SUPERVISED_FINE_TUNING"),"SUPERVISED_FINE_TUNING"===u){let r=t$(e,["adapterSize"]);void 0!==t&&null!=r&&tV(t,["supervisedTuningSpec","hyperParameters","adapterSize"],r)}else if("PREFERENCE_TUNING"===u){let r=t$(e,["adapterSize"]);void 0!==t&&null!=r&&tV(t,["preferenceOptimizationSpec","hyperParameters","adapterSize"],r)}else if("DISTILLATION"===u){let r=t$(e,["adapterSize"]);void 0!==t&&null!=r&&tV(t,["distillationSpec","hyperParameters","adapterSize"],r)}else if("REINFORCEMENT_TUNING"===u){let r=t$(e,["adapterSize"]);void 0!==t&&null!=r&&tV(t,["reinforcementTuningSpec","hyperParameters","adapterSize"],r)}let c=t$(r,["config","method"]);if(void 0===c&&(c="SUPERVISED_FINE_TUNING"),"SUPERVISED_FINE_TUNING"===c){let r=t$(e,["tuningMode"]);void 0!==t&&null!=r&&tV(t,["supervisedTuningSpec","tuningMode"],r)}else if("DISTILLATION"===c){let r=t$(e,["tuningMode"]);void 0!==t&&null!=r&&tV(t,["distillationSpec","tuningMode"],r)}let p=t$(e,["customBaseModel"]);void 0!==t&&null!=p&&tV(t,["customBaseModel"],p);let d=t$(r,["config","method"]);if(void 0===d&&(d="SUPERVISED_FINE_TUNING"),"SUPERVISED_FINE_TUNING"===d){let r=t$(e,["batchSize"]);void 0!==t&&null!=r&&tV(t,["supervisedTuningSpec","hyperParameters","batchSize"],r)}else if("DISTILLATION"===d){let r=t$(e,["batchSize"]);void 0!==t&&null!=r&&tV(t,["distillationSpec","hyperParameters","batchSize"],r)}else if("REINFORCEMENT_TUNING"===d){let r=t$(e,["batchSize"]);void 0!==t&&null!=r&&tV(t,["reinforcementTuningSpec","hyperParameters","batchSize"],r)}let h=t$(r,["config","method"]);if(void 0===h&&(h="SUPERVISED_FINE_TUNING"),"SUPERVISED_FINE_TUNING"===h){let r=t$(e,["learningRate"]);void 0!==t&&null!=r&&tV(t,["supervisedTuningSpec","hyperParameters","learningRate"],r)}else if("DISTILLATION"===h){let r=t$(e,["learningRate"]);void 0!==t&&null!=r&&tV(t,["distillationSpec","hyperParameters","learningRate"],r)}let f=t$(e,["labels"]);void 0!==t&&null!=f&&tV(t,["labels"],f);let m=t$(e,["beta"]);void 0!==t&&null!=m&&tV(t,["preferenceOptimizationSpec","hyperParameters","beta"],m);let g=t$(e,["baseTeacherModel"]);void 0!==t&&null!=g&&tV(t,["distillationSpec","baseTeacherModel"],g);let y=t$(e,["tunedTeacherModelSource"]);void 0!==t&&null!=y&&tV(t,["distillationSpec","tunedTeacherModelSource"],y);let _=t$(e,["sftLossWeightMultiplier"]);void 0!==t&&null!=_&&tV(t,["distillationSpec","hyperParameters","sftLossWeightMultiplier"],_);let E=t$(e,["outputUri"]);void 0!==t&&null!=E&&tV(t,["outputUri"],E);let v=t$(e,["encryptionSpec"]);void 0!==t&&null!=v&&tV(t,["encryptionSpec"],v);let A=t$(e,["rewardConfig"]);void 0!==t&&null!=A&&tV(t,["reinforcementTuningSpec","singleRewardConfig"],A);let T=t$(e,["compositeRewardConfig"]);void 0!==t&&null!=T&&tV(t,["reinforcementTuningSpec","compositeRewardConfig"],T);let C=t$(e,["samplesPerPrompt"]);void 0!==t&&null!=C&&tV(t,["reinforcementTuningSpec","hyperParameters","samplesPerPrompt"],C);let S=t$(e,["evaluateInterval"]);void 0!==t&&null!=S&&tV(t,["reinforcementTuningSpec","hyperParameters","evaluateInterval"],S);let b=t$(e,["checkpointInterval"]);void 0!==t&&null!=b&&tV(t,["reinforcementTuningSpec","hyperParameters","checkpointInterval"],b);let I=t$(e,["maxOutputTokens"]);void 0!==t&&null!=I&&tV(t,["reinforcementTuningSpec","hyperParameters","maxOutputTokens"],I);let O=t$(e,["thinkingLevel"]);void 0!==t&&null!=O&&tV(t,["reinforcementTuningSpec","hyperParameters","thinkingLevel"],O);let w=t$(e,["validationDatasetUri"]);void 0!==t&&null!=w&&tV(t,["reinforcementTuningSpec","validationDatasetUri"],w)}(u,o,e),o);return n=tB("tuningJobs",c._url),i=c._query,delete c._url,delete c._query,this.apiClient.request({path:n,queryParams:i,body:JSON.stringify(c),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(r=e.config)?void 0:r.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>o8(e))}throw Error("This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).")}async tuneMldevInternal(e){var t,r;let n="",i={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let o,s,a,l,u,c=(o={},null!=(s=t$(e,["baseModel"]))&&tV(o,["baseModel"],s),null!=(a=t$(e,["preTunedModel"]))&&tV(o,["preTunedModel"],a),null!=(l=t$(e,["trainingDataset"]))&&function(e){if(void 0!==t$(e,["gcsUri"]))throw Error("gcsUri parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["vertexDatasetResource"]))throw Error("vertexDatasetResource parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let t=t$(e,["examples"]);if(null!=t){let e=t;Array.isArray(e)&&(e=e.map(e=>e)),tV({},["examples","examples"],e)}}(l),null!=(u=t$(e,["config"]))&&function(e,t){if(void 0!==t$(e,["validationDataset"]))throw Error("validationDataset parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let r=t$(e,["tunedModelDisplayName"]);if(void 0!==t&&null!=r&&tV(t,["displayName"],r),void 0!==t$(e,["description"]))throw Error("description parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let n=t$(e,["epochCount"]);void 0!==t&&null!=n&&tV(t,["tuningTask","hyperparameters","epochCount"],n);let i=t$(e,["learningRateMultiplier"]);if(null!=i&&tV({},["tuningTask","hyperparameters","learningRateMultiplier"],i),void 0!==t$(e,["exportLastCheckpointOnly"]))throw Error("exportLastCheckpointOnly parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["preTunedModelCheckpointId"]))throw Error("preTunedModelCheckpointId parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["adapterSize"]))throw Error("adapterSize parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["tuningMode"]))throw Error("tuningMode parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["customBaseModel"]))throw Error("customBaseModel parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");let o=t$(e,["batchSize"]);void 0!==t&&null!=o&&tV(t,["tuningTask","hyperparameters","batchSize"],o);let s=t$(e,["learningRate"]);if(void 0!==t&&null!=s&&tV(t,["tuningTask","hyperparameters","learningRate"],s),void 0!==t$(e,["labels"]))throw Error("labels parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["beta"]))throw Error("beta parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["baseTeacherModel"]))throw Error("baseTeacherModel parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["tunedTeacherModelSource"]))throw Error("tunedTeacherModelSource parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["sftLossWeightMultiplier"]))throw Error("sftLossWeightMultiplier parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["outputUri"]))throw Error("outputUri parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["encryptionSpec"]))throw Error("encryptionSpec parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["rewardConfig"]))throw Error("rewardConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["compositeRewardConfig"]))throw Error("compositeRewardConfig parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["samplesPerPrompt"]))throw Error("samplesPerPrompt parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["evaluateInterval"]))throw Error("evaluateInterval parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["checkpointInterval"]))throw Error("checkpointInterval parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["maxOutputTokens"]))throw Error("maxOutputTokens parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["thinkingLevel"]))throw Error("thinkingLevel parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.");if(void 0!==t$(e,["validationDatasetUri"]))throw Error("validationDatasetUri parameter is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode.")}(u,o),o);return n=tB("tunedModels",c._url),i=c._query,delete c._url,delete c._query,this.apiClient.request({path:n,queryParams:i,body:JSON.stringify(c),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.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,r,n,i,o,s;return t={},null!=(r=t$(e,["sdkHttpResponse"]))&&tV(t,["sdkHttpResponse"],r),null!=(n=t$(e,["name"]))&&tV(t,["name"],n),null!=(i=t$(e,["metadata"]))&&tV(t,["metadata"],i),null!=(o=t$(e,["done"]))&&tV(t,["done"],o),null!=(s=t$(e,["error"]))&&tV(t,["error"],s),t})}}async validateReward(e){var t,r;let n="",i={};if(this.apiClient.isVertexAI()){let o,s,a,l,u,c,p=(o={},null!=(s=t$(e,["parent"]))&&tV(o,["_url","parent"],s),null!=(a=t$(e,["sampleResponse"]))&&tV(o,["sampleResponse"],o5(a)),null!=(l=t$(e,["example"]))&&tV(o,["example"],function(e){let t={},r=t$(e,["contents"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>o5(e))),tV(t,["contents"],e)}let n=t$(e,["references"]);null!=n&&tV(t,["references"],n);let i=t$(e,["systemInstruction"]);return null!=i&&tV(t,["systemInstruction"],o5(i)),t}(l)),null!=(u=t$(e,["singleRewardConfig"]))&&tV(o,["singleRewardConfig"],u),null!=(c=t$(e,["compositeRewardConfig"]))&&tV(o,["compositeRewardConfig"],c),o);return n=tB("{parent}/tuningJobs:validateReinforcementTuningReward",p._url),i=p._query,delete p._url,delete p._query,this.apiClient.request({path:n,queryParams:i,body:JSON.stringify(p),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.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,r,n,i,o,s=(t={},null!=(r=t$(e,["sdkHttpResponse"]))&&tV(t,["sdkHttpResponse"],r),null!=(n=t$(e,["overallReward"]))&&tV(t,["overallReward"],n),null!=(i=t$(e,["error"]))&&tV(t,["error"],i),null!=(o=t$(e,["rewardInfoDetails"]))&&tV(t,["rewardInfoDetails"],o),t),a=new re;return Object.assign(a,s),a})}throw Error("This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).")}}let se="x-goog-upload-status";async function st(e,t,r,n){var i;let o=await sn(e,t,r,n),s=await (null==o?void 0:o.json());if((null==(i=null==o?void 0:o.headers)?void 0:i[se])!=="final")throw Error("Failed to upload file: Upload status is not finalized.");return s.file}async function sr(e,t,r,n){var i;let o=await sn(e,t,r,n),s=await (null==o?void 0:o.json());if((null==(i=null==o?void 0:o.headers)?void 0:i[se])!=="final")throw Error("Failed to upload file: Upload status is not finalized.");let a=tW(s),l=new rf;return Object.assign(l,a),l}async function sn(e,t,r,n){var i,o,s;let a=t,l=(null==n?void 0:n.baseUrl)||(null==(i=r.clientOptions.httpOptions)?void 0:i.baseUrl);if(l){let e=new URL(l),r=new URL(t);r.protocol=e.protocol,r.host=e.host,r.port=e.port,a=r.toString()}let u=0,c=0,p=new tY(new Response),d="upload";for(u=e.size;c<u;){let t=Math.min(8388608,u-c),i=e.slice(c,c+t);c+t>=u&&(d+=", finalize");let l=0,h=1e3;for(;l<3;){let e=Object.assign(Object.assign({},(null==n?void 0:n.headers)||{}),{"X-Goog-Upload-Command":d,"X-Goog-Upload-Offset":String(c),"Content-Length":String(t)});if(null==(o=null==(p=await r.request({path:"",body:i,httpMethod:"POST",httpOptions:Object.assign(Object.assign({},n),{apiVersion:"",baseUrl:a,headers:e})}))?void 0:p.headers)?void 0:o[se])break;l++,await so(h),h*=2}if(c+=t,(null==(s=null==p?void 0:p.headers)?void 0:s[se])!=="active")break;if(u<=c)throw Error("All content has been uploaded, but the upload status is not finalized.")}return p}async function si(e){return{size:e.size,type:e.type}}function so(e){return new Promise(t=>setTimeout(t,e))}class ss{async stat(e){let t={size:0,type:void 0};return"string"==typeof e?(t.size=(await tM.stat(e)).size,t.type=this.inferMimeType(e),t):await si(e)}async upload(e,t,r,n){return"string"==typeof e?await this.uploadFileFromPath(e,t,r,n):st(e,t,r,n)}async uploadToFileSearchStore(e,t,r,n){return"string"==typeof e?await this.uploadFileToFileSearchStoreFromPath(e,t,r,n):sr(e,t,r,n)}inferMimeType(e){return({aac:"audio/aac",abw:"application/x-abiword",arc:"application/x-freearc",avi:"video/x-msvideo",azw:"application/vnd.amazon.ebook",bin:"application/octet-stream",bmp:"image/bmp",bz:"application/x-bzip",bz2:"application/x-bzip2",csh:"application/x-csh",css:"text/css",csv:"text/csv",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",eot:"application/vnd.ms-fontobject",epub:"application/epub+zip",gz:"application/gzip",gif:"image/gif",htm:"text/html",html:"text/html",ico:"image/vnd.microsoft.icon",ics:"text/calendar",jar:"application/java-archive",jpeg:"image/jpeg",jpg:"image/jpeg",js:"text/javascript",json:"application/json",jsonld:"application/ld+json",kml:"application/vnd.google-earth.kml+xml",kmz:"application/vnd.google-earth.kmz+xml",mjs:"text/javascript",mp3:"audio/mpeg",mp4:"video/mp4",mpeg:"video/mpeg",mpkg:"application/vnd.apple.installer+xml",odt:"application/vnd.oasis.opendocument.text",oga:"audio/ogg",ogv:"video/ogg",ogx:"application/ogg",opus:"audio/opus",otf:"font/otf",png:"image/png",pdf:"application/pdf",php:"application/x-httpd-php",ppt:"application/vnd.ms-powerpoint",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",rar:"application/vnd.rar",rtf:"application/rtf",sh:"application/x-sh",svg:"image/svg+xml",swf:"application/x-shockwave-flash",tar:"application/x-tar",tif:"image/tiff",tiff:"image/tiff",ts:"video/mp2t",ttf:"font/ttf",txt:"text/plain",vsd:"application/vnd.visio",wav:"audio/wav",weba:"audio/webm",webm:"video/webm",webp:"image/webp",woff:"font/woff",woff2:"font/woff2",xhtml:"application/xhtml+xml",xls:"application/vnd.ms-excel",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",xml:"application/xml",xul:"application/vnd.mozilla.xul+xml",zip:"application/zip","3gp":"video/3gpp","3g2":"video/3gpp2","7z":"application/x-7z-compressed"})[e.slice(e.lastIndexOf(".")+1).toLowerCase()]}async uploadFileFromPath(e,t,r,n){var i;let o=await this.uploadFileFromPathInternal(e,t,r,n),s=await (null==o?void 0:o.json());if((null==(i=null==o?void 0:o.headers)?void 0:i[se])!=="final")throw Error("Failed to upload file: Upload status is not finalized.");return s.file}async uploadFileToFileSearchStoreFromPath(e,t,r,n){var i;let o=await this.uploadFileFromPathInternal(e,t,r,n),s=await (null==o?void 0:o.json());if((null==(i=null==o?void 0:o.headers)?void 0:i[se])!=="final")throw Error("Failed to upload file: Upload status is not finalized.");let a=tW(s),l=new rf;return Object.assign(l,a),l}async uploadFileFromPathInternal(e,t,r,n){var i,o,s;let a,l=t,u=(null==n?void 0:n.baseUrl)||(null==(i=r.clientOptions.httpOptions)?void 0:i.baseUrl);if(u){let e=new URL(u),r=new URL(t);r.protocol=e.protocol,r.host=e.host,r.port=e.port,l=r.toString()}let c=0,p=0,d=new tY(new Response),h="upload",f=tq.basename(e);try{if(!(a=await tM.open(e,"r")))throw Error("Failed to open file");for(c=(await a.stat()).size;p<c;){let e=Math.min(8388608,c-p);p+e>=c&&(h+=", finalize");let t=new Uint8Array(e),{bytesRead:i}=await a.read(t,0,e,p);if(i!==e)throw Error(`Failed to read ${e} bytes from file at offset ${p}. bytes actually read: ${i}`);let u=new Blob([t]),m=0,g=1e3;for(;m<3;){let e=Object.assign(Object.assign({},(null==n?void 0:n.headers)||{}),{"X-Goog-Upload-Command":h,"X-Goog-Upload-Offset":String(p),"Content-Length":String(i),"X-Goog-Upload-File-Name":f});if(null==(o=null==(d=await r.request({path:"",body:u,httpMethod:"POST",httpOptions:Object.assign(Object.assign({},n),{apiVersion:"",baseUrl:l,headers:e})}))?void 0:d.headers)?void 0:o[se])break;m++,await so(g),g*=2}if(p+=i,(null==(s=null==d?void 0:d.headers)?void 0:s[se])!=="active")break;if(c<=p)throw Error("All content has been uploaded, but the upload status is not finalized.")}return d}finally{a&&await a.close()}}}class sa extends r9{async registerFiles(e){if("u"<typeof process||!process.versions||!process.versions.node)throw Error("registerFiles is only supported in Node.js environments.");let t=e.auth,r=await t.getRequestHeaders(),n=e.config||{},i=n.httpOptions||{},o=Object.assign({},i.headers||{});if(r)if("function"==typeof r[Symbol.iterator])for(let[e,t]of r)o[e]=t;else for(let[e,t]of Object.entries(r))o[e]=t;return this._registerFiles({uris:e.uris,config:Object.assign(Object.assign({},n),{httpOptions:Object.assign(Object.assign({},i),{headers:o})})})}}function sl(e){var t,r,n;return null!=(n=null==(r=null==(t=null==process?void 0:process.env)?void 0:t[e])?void 0:r.trim())?n:void 0}function su(e){return void 0!==e&&"true"===e.toLowerCase()}e.s(["ApiError",0,r7,"FileState",0,tE,"GoogleGenAI",0,class{getNextGenClient(){let e=this.httpOptions;return void 0===this._nextGenClient&&(this._nextGenClient=oF(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 oq(this.apiClient)),this._interactions}get webhooks(){return void 0!==this._webhooks||(this._webhooks=new oB(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 oH(this.apiClient)),this._agents}constructor(e){var n,i,o,s;if((e.project||e.location)&&e.apiKey)throw Error("Project/location and API key are mutually exclusive in the client initializer.");this.vertexai=function(e){var t;if(void 0!==e.enterprise||void 0!==e.vertexai){if(void 0!==e.enterprise&&void 0!==e.vertexai&&e.enterprise!==e.vertexai)throw Error("enterprise and vertexAI flags have conflicting values, please set enterprise value only.");return null!=(t=e.enterprise)?t:e.vertexai}let r=sl("GOOGLE_GENAI_USE_ENTERPRISE"),n=sl("GOOGLE_GENAI_USE_VERTEXAI"),i=su(r),o=su(n);return(void 0!==r&&void 0!==n&&i!==o&&console.warn("Warning: Both GOOGLE_GENAI_USE_ENTERPRISE and GOOGLE_GENAI_USE_VERTEXAI are set with conflicting values. The value of GOOGLE_GENAI_USE_ENTERPRISE will be used."),void 0!==r)?i:void 0!==n&&o}(e);const a=function(){let e=sl("GOOGLE_API_KEY"),t=sl("GEMINI_API_KEY");return e&&t&&console.warn("Both GOOGLE_API_KEY and GEMINI_API_KEY are set. Using GOOGLE_API_KEY."),e||t||void 0}(),l=sl("GOOGLE_CLOUD_PROJECT"),u=sl("GOOGLE_CLOUD_LOCATION");this.apiKey=null!=(n=e.apiKey)?n:a,this.project=null!=(i=e.project)?i:l,this.location=null!=(o=e.location)?o:u,this.vertexai||this.apiKey||console.warn("API key should be set when using the Gemini API."),this.vertexai&&((null==(s=e.googleAuthOptions)?void 0:s.credentials)&&(console.debug("The user provided Google Cloud credentials will take precedence over the API key from the environment variable."),this.apiKey=void 0),(l||u)&&e.apiKey?(console.debug("The user provided Vertex AI API key will take precedence over the project/location from the environment variables."),this.project=void 0,this.location=void 0):(e.project||e.location)&&a?(console.debug("The user provided project/location will take precedence over the API key from the environment variables."),this.apiKey=void 0):(l||u)&&a&&(console.debug("The project/location from the environment variables will take precedence over the API key from the environment variables."),this.apiKey=void 0),this.location||this.apiKey||(this.location="global"));const c=function(e,n,i,o){return(null==e?void 0:e.baseUrl)?e.baseUrl:n?null!=r?r:i:null!=t?t:o}(e.httpOptions,this.vertexai,sl("GOOGLE_VERTEX_BASE_URL"),sl("GOOGLE_GEMINI_BASE_URL"));c&&(e.httpOptions?e.httpOptions.baseUrl=c:e.httpOptions={baseUrl:c}),this.apiVersion=e.apiVersion,this.httpOptions=e.httpOptions;const p=new o0({apiKey:this.apiKey,googleAuthOptions:e.googleAuthOptions});this.apiClient=new nC({auth:p,project:this.project,location:this.location,apiVersion:this.apiVersion,apiKey:this.apiKey,vertexai:this.vertexai,httpOptions:this.httpOptions,userAgentExtra:"gl-node/"+process.version,uploader:new ss,downloader:new o1}),this.models=new nL(this.apiClient),this.live=new nk(this.apiClient,p,new o4),this.batches=new rX(this.apiClient),this.chats=new r6(this.models,this.apiClient),this.caches=new rZ(this.apiClient),this.files=new sa(this.apiClient),this.operations=new nF(this.apiClient),this.authTokens=new nH(this.apiClient),this.tunings=new o9(this.apiClient),this.fileSearchStores=new nV(this.apiClient)}},"Type",0,eI,"createPartFromUri",0,function(e,t,r){return Object.assign({fileData:{fileUri:e,mimeType:t}},r&&{mediaResolution:{level:r}})},"createUserContent",0,function(e){return{role:"user",parts:function(e){let t=[];if("string"==typeof e)t.push({text:e});else if(tK(e))t.push(e);else if(Array.isArray(e)){if(0===e.length)throw Error("partOrString cannot be an empty array");for(let r of e)if("string"==typeof r)t.push({text:r});else if(tK(r))t.push(r);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}(e)}}],34731)}];
|
|
15
|
-
|
|
16
|
-
//# sourceMappingURL=node_modules_1_-az43._.js.map
|