llm-testrunner-components 1.0.6 → 1.0.9

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.
Files changed (266) hide show
  1. package/README.md +101 -100
  2. package/dist/cjs/app-chips_5.cjs.entry.js +158 -0
  3. package/dist/cjs/app-chips_5.cjs.entry.js.map +1 -0
  4. package/dist/cjs/app-globals-Chb-oJtg.js +34 -0
  5. package/dist/cjs/app-globals-Chb-oJtg.js.map +1 -0
  6. package/dist/cjs/index-By1scwl6.js +25542 -0
  7. package/dist/cjs/index-By1scwl6.js.map +1 -0
  8. package/dist/cjs/index-CgmLNwZO.js +21460 -0
  9. package/dist/cjs/index-CgmLNwZO.js.map +1 -0
  10. package/dist/cjs/index.cjs.js +5 -483
  11. package/dist/cjs/index.cjs.js.map +1 -1
  12. package/dist/cjs/llm-testrunner.cjs.js +6 -4
  13. package/dist/cjs/llm-testrunner.cjs.js.map +1 -1
  14. package/dist/cjs/loader.cjs.js +5 -3
  15. package/dist/collection/collection-manifest.json +8 -3
  16. package/dist/collection/components/error-message/error-message.css +34 -0
  17. package/dist/collection/components/error-message/error-message.js +2 -2
  18. package/dist/collection/components/error-message/error-message.js.map +1 -1
  19. package/dist/collection/components/llm-test-runner/header/llm-test-runner-header.css +60 -0
  20. package/dist/collection/components/llm-test-runner/header/llm-test-runner-header.js +18 -0
  21. package/dist/collection/components/llm-test-runner/header/llm-test-runner-header.js.map +1 -0
  22. package/dist/collection/components/llm-test-runner/llm-test-runner.css +17 -657
  23. package/dist/collection/components/llm-test-runner/llm-test-runner.import-export.test.js +253 -0
  24. package/dist/collection/components/llm-test-runner/llm-test-runner.import-export.test.js.map +1 -0
  25. package/dist/collection/components/llm-test-runner/llm-test-runner.js +191 -200
  26. package/dist/collection/components/llm-test-runner/llm-test-runner.js.map +1 -1
  27. package/dist/collection/components/llm-test-runner/test-cases/actions/row-actions.css +28 -0
  28. package/dist/collection/components/llm-test-runner/test-cases/actions/row-actions.js +6 -0
  29. package/dist/collection/components/llm-test-runner/test-cases/actions/row-actions.js.map +1 -0
  30. package/dist/collection/components/llm-test-runner/test-cases/evaluation/evaluation-summary.css +67 -0
  31. package/dist/collection/components/llm-test-runner/test-cases/evaluation/evaluation-summary.js +5 -0
  32. package/dist/collection/components/llm-test-runner/test-cases/evaluation/evaluation-summary.js.map +1 -0
  33. package/dist/collection/components/llm-test-runner/test-cases/llm-test-case-row.css +42 -0
  34. package/dist/collection/components/llm-test-runner/test-cases/llm-test-case-row.js +39 -0
  35. package/dist/collection/components/llm-test-runner/test-cases/llm-test-case-row.js.map +1 -0
  36. package/dist/collection/components/llm-test-runner/test-cases/llm-test-cases.css +39 -0
  37. package/dist/collection/components/llm-test-runner/test-cases/llm-test-cases.js +7 -0
  38. package/dist/collection/components/llm-test-runner/test-cases/llm-test-cases.js.map +1 -0
  39. package/dist/collection/components/llm-test-runner/test-cases/output/response-output.css +51 -0
  40. package/dist/collection/components/llm-test-runner/test-cases/output/response-output.js +5 -0
  41. package/dist/collection/components/llm-test-runner/test-cases/output/response-output.js.map +1 -0
  42. package/dist/collection/global/env.js +3 -1
  43. package/dist/collection/global/env.js.map +1 -1
  44. package/dist/collection/index.js.map +1 -1
  45. package/dist/collection/lib/evaluation/constants.js +14 -0
  46. package/dist/collection/lib/evaluation/constants.js.map +1 -0
  47. package/dist/collection/lib/evaluation/evaluation-engine.js +45 -45
  48. package/dist/collection/lib/evaluation/evaluation-engine.js.map +1 -1
  49. package/dist/collection/lib/evaluation/evaluation-service.js +33 -0
  50. package/dist/collection/lib/evaluation/evaluation-service.js.map +1 -0
  51. package/dist/collection/lib/evaluation/evaluators/bleu/bleu-evaluator.js +116 -0
  52. package/dist/collection/lib/evaluation/evaluators/bleu/bleu-evaluator.js.map +1 -0
  53. package/dist/collection/lib/evaluation/evaluators/bleu/tests/bleu.test.js +352 -0
  54. package/dist/collection/lib/evaluation/evaluators/bleu/tests/bleu.test.js.map +1 -0
  55. package/dist/collection/lib/evaluation/evaluators/exact/exact.js +44 -0
  56. package/dist/collection/lib/evaluation/evaluators/exact/exact.js.map +1 -0
  57. package/dist/collection/lib/evaluation/evaluators/rouge1-evaluator.js +88 -0
  58. package/dist/collection/lib/evaluation/evaluators/rouge1-evaluator.js.map +1 -0
  59. package/dist/collection/lib/evaluation/evaluators/rougeL-evaluator.js +82 -0
  60. package/dist/collection/lib/evaluation/evaluators/rougeL-evaluator.js.map +1 -0
  61. package/dist/collection/lib/evaluation/evaluators/rougeL-evaluator.test.js +326 -0
  62. package/dist/collection/lib/evaluation/evaluators/rougeL-evaluator.test.js.map +1 -0
  63. package/dist/collection/lib/evaluation/evaluators/semantic/SemanticEvaluator.js +69 -0
  64. package/dist/collection/lib/evaluation/evaluators/semantic/SemanticEvaluator.js.map +1 -0
  65. package/dist/collection/lib/evaluation/evaluators/semantic/evaluate-keywords.js +56 -0
  66. package/dist/collection/lib/evaluation/evaluators/semantic/evaluate-keywords.js.map +1 -0
  67. package/dist/collection/lib/evaluation/evaluators/semantic/index.js +7 -0
  68. package/dist/collection/lib/evaluation/evaluators/semantic/index.js.map +1 -0
  69. package/dist/collection/lib/evaluation/evaluators/semantic/model-loader.js +19 -0
  70. package/dist/collection/lib/evaluation/evaluators/semantic/model-loader.js.map +1 -0
  71. package/dist/collection/lib/evaluation/evaluators/semantic/similarity-utils.js +16 -0
  72. package/dist/collection/lib/evaluation/evaluators/semantic/similarity-utils.js.map +1 -0
  73. package/dist/collection/lib/evaluation/evaluators/semantic/tests/evaluate-keywords.test.js +65 -0
  74. package/dist/collection/lib/evaluation/evaluators/semantic/tests/evaluate-keywords.test.js.map +1 -0
  75. package/dist/collection/lib/evaluation/evaluators/semantic/text-utils.js +5 -0
  76. package/dist/collection/lib/evaluation/evaluators/semantic/text-utils.js.map +1 -0
  77. package/dist/collection/lib/evaluation/index.js.map +1 -1
  78. package/dist/collection/lib/evaluation/rouge1-evaluator.test.js +117 -0
  79. package/dist/collection/lib/evaluation/rouge1-evaluator.test.js.map +1 -0
  80. package/dist/collection/lib/evaluation/types.js.map +1 -1
  81. package/dist/collection/lib/file/file-download.js +18 -0
  82. package/dist/collection/lib/file/file-download.js.map +1 -0
  83. package/dist/collection/lib/file/file-reader.js +14 -0
  84. package/dist/collection/lib/file/file-reader.js.map +1 -0
  85. package/dist/collection/lib/form/components/app-chips.css +97 -0
  86. package/dist/collection/lib/form/components/app-chips.js +155 -0
  87. package/dist/collection/lib/form/components/app-chips.js.map +1 -0
  88. package/dist/collection/lib/form/components/app-select.css +28 -0
  89. package/dist/collection/lib/form/components/app-select.js +101 -0
  90. package/dist/collection/lib/form/components/app-select.js.map +1 -0
  91. package/dist/collection/lib/form/components/app-textarea.css +38 -0
  92. package/dist/collection/lib/form/components/app-textarea.js +126 -0
  93. package/dist/collection/lib/form/components/app-textarea.js.map +1 -0
  94. package/dist/collection/lib/form/form-builder.js +171 -0
  95. package/dist/collection/lib/form/form-builder.js.map +1 -0
  96. package/dist/collection/lib/form/schema/base-input-field-config.js +2 -0
  97. package/dist/collection/lib/form/schema/base-input-field-config.js.map +1 -0
  98. package/dist/collection/lib/form/schema/form-control-config.js +2 -0
  99. package/dist/collection/lib/form/schema/form-control-config.js.map +1 -0
  100. package/dist/collection/lib/form/schema/index.js +8 -0
  101. package/dist/collection/lib/form/schema/index.js.map +1 -0
  102. package/dist/collection/lib/import-export/test-results-csv.js +65 -0
  103. package/dist/collection/lib/import-export/test-results-csv.js.map +1 -0
  104. package/dist/collection/lib/import-export/test-suite-exporter.js +15 -0
  105. package/dist/collection/lib/import-export/test-suite-exporter.js.map +1 -0
  106. package/dist/collection/lib/import-export/test-suite-importer.js +44 -0
  107. package/dist/collection/lib/import-export/test-suite-importer.js.map +1 -0
  108. package/dist/collection/lib/rate-limited-fetcher/rate-limited-fetcher.js +6 -6
  109. package/dist/collection/lib/rate-limited-fetcher/rate-limited-fetcher.js.map +1 -1
  110. package/dist/collection/lib/test-cases/test-case-factory.js +56 -0
  111. package/dist/collection/lib/test-cases/test-case-factory.js.map +1 -0
  112. package/dist/collection/lib/test-cases/test-case-mutations.js +16 -0
  113. package/dist/collection/lib/test-cases/test-case-mutations.js.map +1 -0
  114. package/dist/collection/lib/ui/button/button.css +113 -0
  115. package/dist/collection/lib/ui/button/button.js +21 -0
  116. package/dist/collection/lib/ui/button/button.js.map +1 -0
  117. package/dist/collection/lib/ui/button/index.js +2 -0
  118. package/dist/collection/lib/ui/button/index.js.map +1 -0
  119. package/dist/collection/lib/ui/icon-button/icon-button.css +77 -0
  120. package/dist/collection/lib/ui/icon-button/icon-button.js +19 -0
  121. package/dist/collection/lib/ui/icon-button/icon-button.js.map +1 -0
  122. package/dist/collection/lib/ui/icon-button/index.js +2 -0
  123. package/dist/collection/lib/ui/icon-button/index.js.map +1 -0
  124. package/dist/collection/services/adapters.js +2 -0
  125. package/dist/collection/services/adapters.js.map +1 -0
  126. package/dist/collection/services/models/gemini.js +17 -0
  127. package/dist/collection/services/models/gemini.js.map +1 -0
  128. package/dist/collection/styles/tokens.css +180 -0
  129. package/dist/collection/types/evaluation.js +2 -0
  130. package/dist/collection/types/evaluation.js.map +1 -0
  131. package/dist/collection/types/llm-test-runner.js +2 -0
  132. package/dist/collection/types/llm-test-runner.js.map +1 -0
  133. package/dist/components/app-chips.d.ts +11 -0
  134. package/dist/components/app-chips.js +2 -0
  135. package/dist/components/app-chips.js.map +1 -0
  136. package/dist/components/app-select.d.ts +11 -0
  137. package/dist/components/app-select.js +2 -0
  138. package/dist/components/app-select.js.map +1 -0
  139. package/dist/components/app-textarea.d.ts +11 -0
  140. package/dist/components/app-textarea.js +2 -0
  141. package/dist/components/app-textarea.js.map +1 -0
  142. package/dist/components/form-builder.d.ts +11 -0
  143. package/dist/components/form-builder.js +2 -0
  144. package/dist/components/form-builder.js.map +1 -0
  145. package/dist/components/index.d.ts +2 -0
  146. package/dist/components/index.js +1 -13
  147. package/dist/components/index.js.map +1 -1
  148. package/dist/components/llm-test-runner.js +1 -8
  149. package/dist/components/llm-test-runner.js.map +1 -1
  150. package/dist/components/p--2rdv_J9.js +2 -0
  151. package/dist/components/p--2rdv_J9.js.map +1 -0
  152. package/dist/components/p-B7J48VNq.js +2 -0
  153. package/dist/components/p-B7J48VNq.js.map +1 -0
  154. package/dist/components/p-BCB1rjPS.js +7 -0
  155. package/dist/components/p-BCB1rjPS.js.map +1 -0
  156. package/dist/components/p-BQhb2H_a.js +2 -0
  157. package/dist/components/p-BQhb2H_a.js.map +1 -0
  158. package/dist/components/p-D9BrlHdP.js +297 -0
  159. package/dist/components/p-D9BrlHdP.js.map +1 -0
  160. package/dist/components/p-DtCkZ1g2.js +2 -0
  161. package/dist/components/p-DtCkZ1g2.js.map +1 -0
  162. package/dist/esm/app-chips_5.entry.js +153 -0
  163. package/dist/esm/app-chips_5.entry.js.map +1 -0
  164. package/dist/esm/app-globals-DbR5vV7d.js +32 -0
  165. package/dist/esm/app-globals-DbR5vV7d.js.map +1 -0
  166. package/dist/esm/index-Bvg6mh1M.js +25539 -0
  167. package/dist/esm/index-Bvg6mh1M.js.map +1 -0
  168. package/dist/esm/index-DxzhGhec.js +21450 -0
  169. package/dist/esm/index-DxzhGhec.js.map +1 -0
  170. package/dist/esm/index.js +4 -486
  171. package/dist/esm/index.js.map +1 -1
  172. package/dist/esm/llm-testrunner.js +7 -5
  173. package/dist/esm/llm-testrunner.js.map +1 -1
  174. package/dist/esm/loader.js +6 -4
  175. package/dist/llm-testrunner/index.esm.js +1 -1
  176. package/dist/llm-testrunner/index.esm.js.map +1 -1
  177. package/dist/llm-testrunner/llm-testrunner.esm.js +1 -1
  178. package/dist/llm-testrunner/llm-testrunner.esm.js.map +1 -1
  179. package/dist/llm-testrunner/p-3f04b0fb.entry.js +2 -0
  180. package/dist/llm-testrunner/p-3f04b0fb.entry.js.map +1 -0
  181. package/dist/llm-testrunner/p-DFds8y01.js +7 -0
  182. package/dist/llm-testrunner/p-DFds8y01.js.map +1 -0
  183. package/dist/llm-testrunner/p-DxzhGhec.js +298 -0
  184. package/dist/llm-testrunner/p-DxzhGhec.js.map +1 -0
  185. package/dist/llm-testrunner/p-GQwFOmwJ.js +2 -0
  186. package/dist/llm-testrunner/p-GQwFOmwJ.js.map +1 -0
  187. package/dist/react/components.d.ts +32 -2
  188. package/dist/react/components.d.ts.map +1 -1
  189. package/dist/react/components.js +44 -2
  190. package/dist/types/components/llm-test-runner/header/llm-test-runner-header.d.ts +14 -0
  191. package/dist/types/components/llm-test-runner/llm-test-runner.d.ts +13 -29
  192. package/dist/types/components/llm-test-runner/llm-test-runner.import-export.test.d.ts +1 -0
  193. package/dist/types/components/llm-test-runner/test-cases/actions/row-actions.d.ts +8 -0
  194. package/dist/types/components/llm-test-runner/test-cases/evaluation/evaluation-summary.d.ts +7 -0
  195. package/dist/types/components/llm-test-runner/test-cases/llm-test-case-row.d.ts +25 -0
  196. package/dist/types/components/llm-test-runner/test-cases/llm-test-cases.d.ts +26 -0
  197. package/dist/types/components/llm-test-runner/test-cases/output/response-output.d.ts +6 -0
  198. package/dist/types/components.d.ts +199 -4
  199. package/dist/types/global/env.d.ts +2 -0
  200. package/dist/types/index.d.ts +1 -1
  201. package/dist/types/lib/evaluation/constants.d.ts +11 -0
  202. package/dist/types/lib/evaluation/evaluation-engine.d.ts +0 -4
  203. package/dist/types/lib/evaluation/evaluation-service.d.ts +15 -0
  204. package/dist/types/lib/evaluation/evaluators/bleu/bleu-evaluator.d.ts +18 -0
  205. package/dist/types/lib/evaluation/evaluators/bleu/tests/bleu.test.d.ts +1 -0
  206. package/dist/types/lib/evaluation/evaluators/exact/exact.d.ts +2 -0
  207. package/dist/types/lib/evaluation/evaluators/rouge1-evaluator.d.ts +17 -0
  208. package/dist/types/lib/evaluation/evaluators/rougeL-evaluator.d.ts +2 -0
  209. package/dist/types/lib/evaluation/evaluators/rougeL-evaluator.test.d.ts +1 -0
  210. package/dist/types/lib/evaluation/evaluators/semantic/SemanticEvaluator.d.ts +6 -0
  211. package/dist/types/lib/evaluation/evaluators/semantic/evaluate-keywords.d.ts +7 -0
  212. package/dist/types/lib/evaluation/evaluators/semantic/index.d.ts +2 -0
  213. package/dist/types/lib/evaluation/evaluators/semantic/model-loader.d.ts +1 -0
  214. package/dist/types/lib/evaluation/evaluators/semantic/similarity-utils.d.ts +1 -0
  215. package/dist/types/lib/evaluation/evaluators/semantic/tests/evaluate-keywords.test.d.ts +1 -0
  216. package/dist/types/lib/evaluation/evaluators/semantic/text-utils.d.ts +1 -0
  217. package/dist/types/lib/evaluation/index.d.ts +2 -2
  218. package/dist/types/lib/evaluation/rouge1-evaluator.test.d.ts +1 -0
  219. package/dist/types/lib/evaluation/types.d.ts +19 -7
  220. package/dist/types/lib/file/file-download.d.ts +7 -0
  221. package/dist/types/lib/file/file-reader.d.ts +6 -0
  222. package/dist/types/lib/form/components/app-chips.d.ts +20 -0
  223. package/dist/types/lib/form/components/app-select.d.ts +7 -0
  224. package/dist/types/lib/form/components/app-textarea.d.ts +14 -0
  225. package/dist/types/lib/form/form-builder.d.ts +24 -0
  226. package/dist/types/lib/form/schema/base-input-field-config.d.ts +37 -0
  227. package/dist/types/lib/form/schema/form-control-config.d.ts +13 -0
  228. package/dist/types/lib/form/schema/index.d.ts +9 -0
  229. package/dist/types/lib/import-export/test-results-csv.d.ts +13 -0
  230. package/dist/types/lib/import-export/test-suite-exporter.d.ts +16 -0
  231. package/dist/types/lib/import-export/test-suite-importer.d.ts +12 -0
  232. package/dist/types/lib/rate-limited-fetcher/rate-limited-fetcher.d.ts +1 -1
  233. package/dist/types/lib/test-cases/test-case-factory.d.ts +12 -0
  234. package/dist/types/lib/test-cases/test-case-mutations.d.ts +9 -0
  235. package/dist/types/lib/ui/button/button.d.ts +13 -0
  236. package/dist/types/lib/ui/button/index.d.ts +2 -0
  237. package/dist/types/lib/ui/icon-button/icon-button.d.ts +11 -0
  238. package/dist/types/lib/ui/icon-button/index.d.ts +2 -0
  239. package/dist/types/services/adapters.d.ts +3 -0
  240. package/dist/types/services/models/gemini.d.ts +11 -0
  241. package/dist/types/stencil-public-runtime.d.ts +110 -6
  242. package/dist/types/types/evaluation.d.ts +9 -0
  243. package/dist/types/types/llm-test-runner.d.ts +22 -0
  244. package/package.json +30 -6
  245. package/dist/cjs/app-globals-CbbEbofA.js +0 -14
  246. package/dist/cjs/app-globals-CbbEbofA.js.map +0 -1
  247. package/dist/cjs/index-D-FySkoV.js +0 -1470
  248. package/dist/cjs/index-D-FySkoV.js.map +0 -1
  249. package/dist/cjs/llm-test-runner.cjs.entry.js +0 -9
  250. package/dist/cjs/llm-test-runner.entry.cjs.js.map +0 -1
  251. package/dist/components/p-CYUbsbxt.js +0 -1770
  252. package/dist/components/p-CYUbsbxt.js.map +0 -1
  253. package/dist/esm/app-globals-BOQOUavG.js +0 -12
  254. package/dist/esm/app-globals-BOQOUavG.js.map +0 -1
  255. package/dist/esm/index-cncubhtM.js +0 -1463
  256. package/dist/esm/index-cncubhtM.js.map +0 -1
  257. package/dist/esm/llm-test-runner.entry.js +0 -3
  258. package/dist/esm/llm-test-runner.entry.js.map +0 -1
  259. package/dist/llm-testrunner/llm-test-runner.entry.esm.js.map +0 -1
  260. package/dist/llm-testrunner/loader.esm.js.map +0 -1
  261. package/dist/llm-testrunner/p-BOQOUavG.js +0 -2
  262. package/dist/llm-testrunner/p-BOQOUavG.js.map +0 -1
  263. package/dist/llm-testrunner/p-cncubhtM.js +0 -3
  264. package/dist/llm-testrunner/p-cncubhtM.js.map +0 -1
  265. package/dist/llm-testrunner/p-f68fd660.entry.js +0 -2
  266. package/dist/llm-testrunner/p-f68fd660.entry.js.map +0 -1
@@ -0,0 +1,297 @@
1
+ function e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e["default"]:e}function n(e){if(e.__esModule)return e;var n=e.default;if(typeof n=="function"){var t=function e(){if(this instanceof e){return Reflect.construct(n,arguments,this.constructor)}return n.apply(this,arguments)};t.prototype=n.prototype}else t={};Object.defineProperty(t,"__esModule",{value:true});Object.keys(e).forEach((function(n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:true,get:function(){return e[n]}})}));return t}var t={exports:{}};var i={};var o;var r;function s(){if(r)return o;r=1;function e(e,n){if(typeof n==="boolean"){n={forever:n}}this._originalTimeouts=JSON.parse(JSON.stringify(e));this._timeouts=e;this._options=n||{};this._maxRetryTime=n&&n.maxRetryTime||Infinity;this._fn=null;this._errors=[];this._attempts=1;this._operationTimeout=null;this._operationTimeoutCb=null;this._timeout=null;this._operationStart=null;this._timer=null;if(this._options.forever){this._cachedTimeouts=this._timeouts.slice(0)}}o=e;e.prototype.reset=function(){this._attempts=1;this._timeouts=this._originalTimeouts.slice(0)};e.prototype.stop=function(){if(this._timeout){clearTimeout(this._timeout)}if(this._timer){clearTimeout(this._timer)}this._timeouts=[];this._cachedTimeouts=null};e.prototype.retry=function(e){if(this._timeout){clearTimeout(this._timeout)}if(!e){return false}var n=(new Date).getTime();if(e&&n-this._operationStart>=this._maxRetryTime){this._errors.push(e);this._errors.unshift(new Error("RetryOperation timeout occurred"));return false}this._errors.push(e);var t=this._timeouts.shift();if(t===undefined){if(this._cachedTimeouts){this._errors.splice(0,this._errors.length-1);t=this._cachedTimeouts.slice(-1)}else{return false}}var i=this;this._timer=setTimeout((function(){i._attempts++;if(i._operationTimeoutCb){i._timeout=setTimeout((function(){i._operationTimeoutCb(i._attempts)}),i._operationTimeout);if(i._options.unref){i._timeout.unref()}}i._fn(i._attempts)}),t);if(this._options.unref){this._timer.unref()}return true};e.prototype.attempt=function(e,n){this._fn=e;if(n){if(n.timeout){this._operationTimeout=n.timeout}if(n.cb){this._operationTimeoutCb=n.cb}}var t=this;if(this._operationTimeoutCb){this._timeout=setTimeout((function(){t._operationTimeoutCb()}),t._operationTimeout)}this._operationStart=(new Date).getTime();this._fn(this._attempts)};e.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated");this.attempt(e)};e.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated");this.attempt(e)};e.prototype.start=e.prototype.try;e.prototype.errors=function(){return this._errors};e.prototype.attempts=function(){return this._attempts};e.prototype.mainError=function(){if(this._errors.length===0){return null}var e={};var n=null;var t=0;for(var i=0;i<this._errors.length;i++){var o=this._errors[i];var r=o.message;var s=(e[r]||0)+1;e[r]=s;if(s>=t){n=o;t=s}}return n};return o}var l;function u(){if(l)return i;l=1;(function(e){var n=s();e.operation=function(t){var i=e.timeouts(t);return new n(i,{forever:t&&(t.forever||t.retries===Infinity),unref:t&&t.unref,maxRetryTime:t&&t.maxRetryTime})};e.timeouts=function(e){if(e instanceof Array){return[].concat(e)}var n={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:Infinity,randomize:false};for(var t in e){n[t]=e[t]}if(n.minTimeout>n.maxTimeout){throw new Error("minTimeout is greater than maxTimeout")}var i=[];for(var o=0;o<n.retries;o++){i.push(this.createTimeout(o,n))}if(e&&e.forever&&!i.length){i.push(this.createTimeout(o,n))}i.sort((function(e,n){return e-n}));return i};e.createTimeout=function(e,n){var t=n.randomize?Math.random()+1:1;var i=Math.round(t*Math.max(n.minTimeout,1)*Math.pow(n.factor,e));i=Math.min(i,n.maxTimeout);return i};e.wrap=function(n,t,i){if(t instanceof Array){i=t;t=null}if(!i){i=[];for(var o in n){if(typeof n[o]==="function"){i.push(o)}}}for(var r=0;r<i.length;r++){var s=i[r];var l=n[s];n[s]=function i(o){var r=e.operation(t);var s=Array.prototype.slice.call(arguments,1);var l=s.pop();s.push((function(e){if(r.retry(e)){return}if(e){arguments[0]=r.mainError()}l.apply(this,arguments)}));r.attempt((function(){o.apply(n,s)}))}.bind(n,l);n[s].options=t}}})(i);return i}var a;var c;function f(){if(c)return a;c=1;a=u();return a}var d;function p(){if(d)return t.exports;d=1;const e=f();const n=["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"];class i extends Error{constructor(e){super();if(e instanceof Error){this.originalError=e;({message:e}=e)}else{this.originalError=new Error(e);this.originalError.stack=this.stack}this.name="AbortError";this.message=e}}const o=(e,n,t)=>{const i=t.retries-(n-1);e.attemptNumber=n;e.retriesLeft=i;return e};const r=e=>n.includes(e);const s=(n,t)=>new Promise(((s,l)=>{t={onFailedAttempt:()=>{},retries:10,...t};const u=e.operation(t);u.attempt((async e=>{try{s(await n(e))}catch(n){if(!(n instanceof Error)){l(new TypeError(`Non-error was thrown: "${n}". You should only throw errors.`));return}if(n instanceof i){u.stop();l(n.originalError)}else if(n instanceof TypeError&&!r(n.message)){u.stop();l(n)}else{o(n,e,t);try{await t.onFailedAttempt(n)}catch(e){l(e);return}if(!u.retry(n)){l(u.mainError())}}}}))}));t.exports=s;t.exports.default=s;t.exports.AbortError=i;return t.exports}var h=p();var m=e(h);
2
+ /**
3
+ * @license
4
+ * Copyright 2025 Google LLC
5
+ * SPDX-License-Identifier: Apache-2.0
6
+ */let g=undefined;let y=undefined;function v(){return{geminiUrl:g,vertexUrl:y}}function E(e,n,t,i){var o,r;if(!(e===null||e===void 0?void 0:e.baseUrl)){const e=v();if(n){return(o=e.vertexUrl)!==null&&o!==void 0?o:t}else{return(r=e.geminiUrl)!==null&&r!==void 0?r:i}}return e.baseUrl}
7
+ /**
8
+ * @license
9
+ * Copyright 2025 Google LLC
10
+ * SPDX-License-Identifier: Apache-2.0
11
+ */class w{}function b(e,n){const t=/\{([^}]+)\}/g;return e.replace(t,((e,t)=>{if(Object.prototype.hasOwnProperty.call(n,t)){const e=n[t];return e!==undefined&&e!==null?String(e):""}else{throw new Error(`Key '${t}' not found in valueMap.`)}}))}function T(e,n,t){for(let i=0;i<n.length-1;i++){const o=n[i];if(o.endsWith("[]")){const r=o.slice(0,-2);if(!(r in e)){if(Array.isArray(t)){e[r]=Array.from({length:t.length},(()=>({})))}else{throw new Error(`Value must be a list given an array path ${o}`)}}if(Array.isArray(e[r])){const o=e[r];if(Array.isArray(t)){for(let e=0;e<o.length;e++){const r=o[e];T(r,n.slice(i+1),t[e])}}else{for(const e of o){T(e,n.slice(i+1),t)}}}return}else if(o.endsWith("[0]")){const r=o.slice(0,-3);if(!(r in e)){e[r]=[{}]}const s=e[r];T(s[0],n.slice(i+1),t);return}if(!e[o]||typeof e[o]!=="object"){e[o]={}}e=e[o]}const i=n[n.length-1];const o=e[i];if(o!==undefined){if(!t||typeof t==="object"&&Object.keys(t).length===0){return}if(t===o){return}if(typeof o==="object"&&typeof t==="object"&&o!==null&&t!==null){Object.assign(o,t)}else{throw new Error(`Cannot set value for an existing key. Key: ${i}`)}}else{if(i==="_self"&&typeof t==="object"&&t!==null&&!Array.isArray(t)){const n=t;Object.assign(e,n)}else{e[i]=t}}}function S(e,n,t=undefined){try{if(n.length===1&&n[0]==="_self"){return e}for(let i=0;i<n.length;i++){if(typeof e!=="object"||e===null){return t}const o=n[i];if(o.endsWith("[]")){const r=o.slice(0,-2);if(r in e){const o=e[r];if(!Array.isArray(o)){return t}return o.map((e=>S(e,n.slice(i+1),t)))}else{return t}}else{e=e[o]}}return e}catch(e){if(e instanceof TypeError){return t}throw e}}function I(e,n){for(const[t,i]of Object.entries(n)){const n=t.split(".");const o=i.split(".");const r=new Set;let s=-1;for(let e=0;e<n.length;e++){if(n[e]==="*"){s=e;break}}if(s!==-1&&o.length>s){for(let e=s;e<o.length;e++){const n=o[e];if(n!=="*"&&!n.endsWith("[]")&&!n.endsWith("[0]")){r.add(n)}}}A(e,n,o,0,r)}}function A(e,n,t,i,o){if(i>=n.length){return}if(typeof e!=="object"||e===null){return}const r=n[i];if(r.endsWith("[]")){const s=r.slice(0,-2);const l=e;if(s in l&&Array.isArray(l[s])){for(const e of l[s]){A(e,n,t,i+1,o)}}}else if(r==="*"){if(typeof e==="object"&&e!==null&&!Array.isArray(e)){const n=e;const r=Object.keys(n).filter((e=>!e.startsWith("_")&&!o.has(e)));const s={};for(const e of r){s[e]=n[e]}for(const[e,o]of Object.entries(s)){const r=[];for(const n of t.slice(i)){if(n==="*"){r.push(e)}else{r.push(n)}}T(n,r,o)}for(const e of r){delete n[e]}}}else{const s=e;if(r in s){A(s[r],n,t,i+1,o)}}}
12
+ /**
13
+ * @license
14
+ * Copyright 2025 Google LLC
15
+ * SPDX-License-Identifier: Apache-2.0
16
+ */function O(e){if(typeof e!=="string"){throw new Error("fromImageBytes must be a string")}return e}
17
+ /**
18
+ * @license
19
+ * Copyright 2025 Google LLC
20
+ * SPDX-License-Identifier: Apache-2.0
21
+ */function C(e){const n={};const t=S(e,["operationName"]);if(t!=null){T(n,["operationName"],t)}const i=S(e,["resourceName"]);if(i!=null){T(n,["_url","resourceName"],i)}return n}function _(e){const n={};const t=S(e,["name"]);if(t!=null){T(n,["name"],t)}const i=S(e,["metadata"]);if(i!=null){T(n,["metadata"],i)}const o=S(e,["done"]);if(o!=null){T(n,["done"],o)}const r=S(e,["error"]);if(r!=null){T(n,["error"],r)}const s=S(e,["response","generateVideoResponse"]);if(s!=null){T(n,["response"],R(s))}return n}function P(e){const n={};const t=S(e,["name"]);if(t!=null){T(n,["name"],t)}const i=S(e,["metadata"]);if(i!=null){T(n,["metadata"],i)}const o=S(e,["done"]);if(o!=null){T(n,["done"],o)}const r=S(e,["error"]);if(r!=null){T(n,["error"],r)}const s=S(e,["response"]);if(s!=null){T(n,["response"],N(s))}return n}function R(e){const n={};const t=S(e,["generatedSamples"]);if(t!=null){let e=t;if(Array.isArray(e)){e=e.map((e=>M(e)))}T(n,["generatedVideos"],e)}const i=S(e,["raiMediaFilteredCount"]);if(i!=null){T(n,["raiMediaFilteredCount"],i)}const o=S(e,["raiMediaFilteredReasons"]);if(o!=null){T(n,["raiMediaFilteredReasons"],o)}return n}function N(e){const n={};const t=S(e,["videos"]);if(t!=null){let e=t;if(Array.isArray(e)){e=e.map((e=>D(e)))}T(n,["generatedVideos"],e)}const i=S(e,["raiMediaFilteredCount"]);if(i!=null){T(n,["raiMediaFilteredCount"],i)}const o=S(e,["raiMediaFilteredReasons"]);if(o!=null){T(n,["raiMediaFilteredReasons"],o)}return n}function M(e){const n={};const t=S(e,["video"]);if(t!=null){T(n,["video"],F(t))}return n}function D(e){const n={};const t=S(e,["_self"]);if(t!=null){T(n,["video"],q(t))}return n}function U(e){const n={};const t=S(e,["operationName"]);if(t!=null){T(n,["_url","operationName"],t)}return n}function k(e){const n={};const t=S(e,["operationName"]);if(t!=null){T(n,["_url","operationName"],t)}return n}function G(e){const n={};const t=S(e,["name"]);if(t!=null){T(n,["name"],t)}const i=S(e,["metadata"]);if(i!=null){T(n,["metadata"],i)}const o=S(e,["done"]);if(o!=null){T(n,["done"],o)}const r=S(e,["error"]);if(r!=null){T(n,["error"],r)}const s=S(e,["response"]);if(s!=null){T(n,["response"],x(s))}return n}function x(e){const n={};const t=S(e,["sdkHttpResponse"]);if(t!=null){T(n,["sdkHttpResponse"],t)}const i=S(e,["parent"]);if(i!=null){T(n,["parent"],i)}const o=S(e,["documentName"]);if(o!=null){T(n,["documentName"],o)}return n}function L(e){const n={};const t=S(e,["name"]);if(t!=null){T(n,["name"],t)}const i=S(e,["metadata"]);if(i!=null){T(n,["metadata"],i)}const o=S(e,["done"]);if(o!=null){T(n,["done"],o)}const r=S(e,["error"]);if(r!=null){T(n,["error"],r)}const s=S(e,["response"]);if(s!=null){T(n,["response"],j(s))}return n}function j(e){const n={};const t=S(e,["sdkHttpResponse"]);if(t!=null){T(n,["sdkHttpResponse"],t)}const i=S(e,["parent"]);if(i!=null){T(n,["parent"],i)}const o=S(e,["documentName"]);if(o!=null){T(n,["documentName"],o)}return n}function F(e){const n={};const t=S(e,["uri"]);if(t!=null){T(n,["uri"],t)}const i=S(e,["encodedVideo"]);if(i!=null){T(n,["videoBytes"],O(i))}const o=S(e,["encoding"]);if(o!=null){T(n,["mimeType"],o)}return n}function q(e){const n={};const t=S(e,["gcsUri"]);if(t!=null){T(n,["uri"],t)}const i=S(e,["bytesBase64Encoded"]);if(i!=null){T(n,["videoBytes"],O(i))}const o=S(e,["mimeType"]);if(o!=null){T(n,["mimeType"],o)}return n}
22
+ /**
23
+ * @license
24
+ * Copyright 2025 Google LLC
25
+ * SPDX-License-Identifier: Apache-2.0
26
+ */var H;(function(e){e["OUTCOME_UNSPECIFIED"]="OUTCOME_UNSPECIFIED";e["OUTCOME_OK"]="OUTCOME_OK";e["OUTCOME_FAILED"]="OUTCOME_FAILED";e["OUTCOME_DEADLINE_EXCEEDED"]="OUTCOME_DEADLINE_EXCEEDED"})(H||(H={}));var $;(function(e){e["LANGUAGE_UNSPECIFIED"]="LANGUAGE_UNSPECIFIED";e["PYTHON"]="PYTHON"})($||($={}));var J;(function(e){e["SCHEDULING_UNSPECIFIED"]="SCHEDULING_UNSPECIFIED";e["SILENT"]="SILENT";e["WHEN_IDLE"]="WHEN_IDLE";e["INTERRUPT"]="INTERRUPT"})(J||(J={}));var V;(function(e){e["TYPE_UNSPECIFIED"]="TYPE_UNSPECIFIED";e["STRING"]="STRING";e["NUMBER"]="NUMBER";e["INTEGER"]="INTEGER";e["BOOLEAN"]="BOOLEAN";e["ARRAY"]="ARRAY";e["OBJECT"]="OBJECT";e["NULL"]="NULL"})(V||(V={}));var B;(function(e){e["PHISH_BLOCK_THRESHOLD_UNSPECIFIED"]="PHISH_BLOCK_THRESHOLD_UNSPECIFIED";e["BLOCK_LOW_AND_ABOVE"]="BLOCK_LOW_AND_ABOVE";e["BLOCK_MEDIUM_AND_ABOVE"]="BLOCK_MEDIUM_AND_ABOVE";e["BLOCK_HIGH_AND_ABOVE"]="BLOCK_HIGH_AND_ABOVE";e["BLOCK_HIGHER_AND_ABOVE"]="BLOCK_HIGHER_AND_ABOVE";e["BLOCK_VERY_HIGH_AND_ABOVE"]="BLOCK_VERY_HIGH_AND_ABOVE";e["BLOCK_ONLY_EXTREMELY_HIGH"]="BLOCK_ONLY_EXTREMELY_HIGH"})(B||(B={}));var W;(function(e){e["API_SPEC_UNSPECIFIED"]="API_SPEC_UNSPECIFIED";e["SIMPLE_SEARCH"]="SIMPLE_SEARCH";e["ELASTIC_SEARCH"]="ELASTIC_SEARCH"})(W||(W={}));var Y;(function(e){e["AUTH_TYPE_UNSPECIFIED"]="AUTH_TYPE_UNSPECIFIED";e["NO_AUTH"]="NO_AUTH";e["API_KEY_AUTH"]="API_KEY_AUTH";e["HTTP_BASIC_AUTH"]="HTTP_BASIC_AUTH";e["GOOGLE_SERVICE_ACCOUNT_AUTH"]="GOOGLE_SERVICE_ACCOUNT_AUTH";e["OAUTH"]="OAUTH";e["OIDC_AUTH"]="OIDC_AUTH"})(Y||(Y={}));var K;(function(e){e["HTTP_IN_UNSPECIFIED"]="HTTP_IN_UNSPECIFIED";e["HTTP_IN_QUERY"]="HTTP_IN_QUERY";e["HTTP_IN_HEADER"]="HTTP_IN_HEADER";e["HTTP_IN_PATH"]="HTTP_IN_PATH";e["HTTP_IN_BODY"]="HTTP_IN_BODY";e["HTTP_IN_COOKIE"]="HTTP_IN_COOKIE"})(K||(K={}));var z;(function(e){e["UNSPECIFIED"]="UNSPECIFIED";e["BLOCKING"]="BLOCKING";e["NON_BLOCKING"]="NON_BLOCKING"})(z||(z={}));var X;(function(e){e["MODE_UNSPECIFIED"]="MODE_UNSPECIFIED";e["MODE_DYNAMIC"]="MODE_DYNAMIC"})(X||(X={}));var Q;(function(e){e["MODE_UNSPECIFIED"]="MODE_UNSPECIFIED";e["AUTO"]="AUTO";e["ANY"]="ANY";e["NONE"]="NONE";e["VALIDATED"]="VALIDATED"})(Q||(Q={}));var Z;(function(e){e["THINKING_LEVEL_UNSPECIFIED"]="THINKING_LEVEL_UNSPECIFIED";e["LOW"]="LOW";e["MEDIUM"]="MEDIUM";e["HIGH"]="HIGH";e["MINIMAL"]="MINIMAL"})(Z||(Z={}));var ee;(function(e){e["HARM_CATEGORY_UNSPECIFIED"]="HARM_CATEGORY_UNSPECIFIED";e["HARM_CATEGORY_HARASSMENT"]="HARM_CATEGORY_HARASSMENT";e["HARM_CATEGORY_HATE_SPEECH"]="HARM_CATEGORY_HATE_SPEECH";e["HARM_CATEGORY_SEXUALLY_EXPLICIT"]="HARM_CATEGORY_SEXUALLY_EXPLICIT";e["HARM_CATEGORY_DANGEROUS_CONTENT"]="HARM_CATEGORY_DANGEROUS_CONTENT";e["HARM_CATEGORY_CIVIC_INTEGRITY"]="HARM_CATEGORY_CIVIC_INTEGRITY";e["HARM_CATEGORY_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"})(ee||(ee={}));var ne;(function(e){e["HARM_BLOCK_METHOD_UNSPECIFIED"]="HARM_BLOCK_METHOD_UNSPECIFIED";e["SEVERITY"]="SEVERITY";e["PROBABILITY"]="PROBABILITY"})(ne||(ne={}));var te;(function(e){e["HARM_BLOCK_THRESHOLD_UNSPECIFIED"]="HARM_BLOCK_THRESHOLD_UNSPECIFIED";e["BLOCK_LOW_AND_ABOVE"]="BLOCK_LOW_AND_ABOVE";e["BLOCK_MEDIUM_AND_ABOVE"]="BLOCK_MEDIUM_AND_ABOVE";e["BLOCK_ONLY_HIGH"]="BLOCK_ONLY_HIGH";e["BLOCK_NONE"]="BLOCK_NONE";e["OFF"]="OFF"})(te||(te={}));var ie;(function(e){e["FINISH_REASON_UNSPECIFIED"]="FINISH_REASON_UNSPECIFIED";e["STOP"]="STOP";e["MAX_TOKENS"]="MAX_TOKENS";e["SAFETY"]="SAFETY";e["RECITATION"]="RECITATION";e["LANGUAGE"]="LANGUAGE";e["OTHER"]="OTHER";e["BLOCKLIST"]="BLOCKLIST";e["PROHIBITED_CONTENT"]="PROHIBITED_CONTENT";e["SPII"]="SPII";e["MALFORMED_FUNCTION_CALL"]="MALFORMED_FUNCTION_CALL";e["IMAGE_SAFETY"]="IMAGE_SAFETY";e["UNEXPECTED_TOOL_CALL"]="UNEXPECTED_TOOL_CALL";e["IMAGE_PROHIBITED_CONTENT"]="IMAGE_PROHIBITED_CONTENT";e["NO_IMAGE"]="NO_IMAGE";e["IMAGE_RECITATION"]="IMAGE_RECITATION";e["IMAGE_OTHER"]="IMAGE_OTHER"})(ie||(ie={}));var oe;(function(e){e["HARM_PROBABILITY_UNSPECIFIED"]="HARM_PROBABILITY_UNSPECIFIED";e["NEGLIGIBLE"]="NEGLIGIBLE";e["LOW"]="LOW";e["MEDIUM"]="MEDIUM";e["HIGH"]="HIGH"})(oe||(oe={}));var re;(function(e){e["HARM_SEVERITY_UNSPECIFIED"]="HARM_SEVERITY_UNSPECIFIED";e["HARM_SEVERITY_NEGLIGIBLE"]="HARM_SEVERITY_NEGLIGIBLE";e["HARM_SEVERITY_LOW"]="HARM_SEVERITY_LOW";e["HARM_SEVERITY_MEDIUM"]="HARM_SEVERITY_MEDIUM";e["HARM_SEVERITY_HIGH"]="HARM_SEVERITY_HIGH"})(re||(re={}));var se;(function(e){e["URL_RETRIEVAL_STATUS_UNSPECIFIED"]="URL_RETRIEVAL_STATUS_UNSPECIFIED";e["URL_RETRIEVAL_STATUS_SUCCESS"]="URL_RETRIEVAL_STATUS_SUCCESS";e["URL_RETRIEVAL_STATUS_ERROR"]="URL_RETRIEVAL_STATUS_ERROR";e["URL_RETRIEVAL_STATUS_PAYWALL"]="URL_RETRIEVAL_STATUS_PAYWALL";e["URL_RETRIEVAL_STATUS_UNSAFE"]="URL_RETRIEVAL_STATUS_UNSAFE"})(se||(se={}));var le;(function(e){e["BLOCKED_REASON_UNSPECIFIED"]="BLOCKED_REASON_UNSPECIFIED";e["SAFETY"]="SAFETY";e["OTHER"]="OTHER";e["BLOCKLIST"]="BLOCKLIST";e["PROHIBITED_CONTENT"]="PROHIBITED_CONTENT";e["IMAGE_SAFETY"]="IMAGE_SAFETY";e["MODEL_ARMOR"]="MODEL_ARMOR";e["JAILBREAK"]="JAILBREAK"})(le||(le={}));var ue;(function(e){e["TRAFFIC_TYPE_UNSPECIFIED"]="TRAFFIC_TYPE_UNSPECIFIED";e["ON_DEMAND"]="ON_DEMAND";e["PROVISIONED_THROUGHPUT"]="PROVISIONED_THROUGHPUT"})(ue||(ue={}));var ae;(function(e){e["MODALITY_UNSPECIFIED"]="MODALITY_UNSPECIFIED";e["TEXT"]="TEXT";e["IMAGE"]="IMAGE";e["AUDIO"]="AUDIO"})(ae||(ae={}));var ce;(function(e){e["MEDIA_RESOLUTION_UNSPECIFIED"]="MEDIA_RESOLUTION_UNSPECIFIED";e["MEDIA_RESOLUTION_LOW"]="MEDIA_RESOLUTION_LOW";e["MEDIA_RESOLUTION_MEDIUM"]="MEDIA_RESOLUTION_MEDIUM";e["MEDIA_RESOLUTION_HIGH"]="MEDIA_RESOLUTION_HIGH"})(ce||(ce={}));var fe;(function(e){e["TUNING_MODE_UNSPECIFIED"]="TUNING_MODE_UNSPECIFIED";e["TUNING_MODE_FULL"]="TUNING_MODE_FULL";e["TUNING_MODE_PEFT_ADAPTER"]="TUNING_MODE_PEFT_ADAPTER"})(fe||(fe={}));var de;(function(e){e["ADAPTER_SIZE_UNSPECIFIED"]="ADAPTER_SIZE_UNSPECIFIED";e["ADAPTER_SIZE_ONE"]="ADAPTER_SIZE_ONE";e["ADAPTER_SIZE_TWO"]="ADAPTER_SIZE_TWO";e["ADAPTER_SIZE_FOUR"]="ADAPTER_SIZE_FOUR";e["ADAPTER_SIZE_EIGHT"]="ADAPTER_SIZE_EIGHT";e["ADAPTER_SIZE_SIXTEEN"]="ADAPTER_SIZE_SIXTEEN";e["ADAPTER_SIZE_THIRTY_TWO"]="ADAPTER_SIZE_THIRTY_TWO"})(de||(de={}));var pe;(function(e){e["JOB_STATE_UNSPECIFIED"]="JOB_STATE_UNSPECIFIED";e["JOB_STATE_QUEUED"]="JOB_STATE_QUEUED";e["JOB_STATE_PENDING"]="JOB_STATE_PENDING";e["JOB_STATE_RUNNING"]="JOB_STATE_RUNNING";e["JOB_STATE_SUCCEEDED"]="JOB_STATE_SUCCEEDED";e["JOB_STATE_FAILED"]="JOB_STATE_FAILED";e["JOB_STATE_CANCELLING"]="JOB_STATE_CANCELLING";e["JOB_STATE_CANCELLED"]="JOB_STATE_CANCELLED";e["JOB_STATE_PAUSED"]="JOB_STATE_PAUSED";e["JOB_STATE_EXPIRED"]="JOB_STATE_EXPIRED";e["JOB_STATE_UPDATING"]="JOB_STATE_UPDATING";e["JOB_STATE_PARTIALLY_SUCCEEDED"]="JOB_STATE_PARTIALLY_SUCCEEDED"})(pe||(pe={}));var he;(function(e){e["TUNING_TASK_UNSPECIFIED"]="TUNING_TASK_UNSPECIFIED";e["TUNING_TASK_I2V"]="TUNING_TASK_I2V";e["TUNING_TASK_T2V"]="TUNING_TASK_T2V";e["TUNING_TASK_R2V"]="TUNING_TASK_R2V"})(he||(he={}));var me;(function(e){e["MEDIA_RESOLUTION_UNSPECIFIED"]="MEDIA_RESOLUTION_UNSPECIFIED";e["MEDIA_RESOLUTION_LOW"]="MEDIA_RESOLUTION_LOW";e["MEDIA_RESOLUTION_MEDIUM"]="MEDIA_RESOLUTION_MEDIUM";e["MEDIA_RESOLUTION_HIGH"]="MEDIA_RESOLUTION_HIGH";e["MEDIA_RESOLUTION_ULTRA_HIGH"]="MEDIA_RESOLUTION_ULTRA_HIGH"})(me||(me={}));var ge;(function(e){e["COLLECTION"]="COLLECTION"})(ge||(ge={}));var ye;(function(e){e["FEATURE_SELECTION_PREFERENCE_UNSPECIFIED"]="FEATURE_SELECTION_PREFERENCE_UNSPECIFIED";e["PRIORITIZE_QUALITY"]="PRIORITIZE_QUALITY";e["BALANCED"]="BALANCED";e["PRIORITIZE_COST"]="PRIORITIZE_COST"})(ye||(ye={}));var ve;(function(e){e["ENVIRONMENT_UNSPECIFIED"]="ENVIRONMENT_UNSPECIFIED";e["ENVIRONMENT_BROWSER"]="ENVIRONMENT_BROWSER"})(ve||(ve={}));var Ee;(function(e){e["PROMINENT_PEOPLE_UNSPECIFIED"]="PROMINENT_PEOPLE_UNSPECIFIED";e["ALLOW_PROMINENT_PEOPLE"]="ALLOW_PROMINENT_PEOPLE";e["BLOCK_PROMINENT_PEOPLE"]="BLOCK_PROMINENT_PEOPLE"})(Ee||(Ee={}));var we;(function(e){e["PREDICT"]="PREDICT";e["EMBED_CONTENT"]="EMBED_CONTENT"})(we||(we={}));var be;(function(e){e["BLOCK_LOW_AND_ABOVE"]="BLOCK_LOW_AND_ABOVE";e["BLOCK_MEDIUM_AND_ABOVE"]="BLOCK_MEDIUM_AND_ABOVE";e["BLOCK_ONLY_HIGH"]="BLOCK_ONLY_HIGH";e["BLOCK_NONE"]="BLOCK_NONE"})(be||(be={}));var Te;(function(e){e["DONT_ALLOW"]="DONT_ALLOW";e["ALLOW_ADULT"]="ALLOW_ADULT";e["ALLOW_ALL"]="ALLOW_ALL"})(Te||(Te={}));var Se;(function(e){e["auto"]="auto";e["en"]="en";e["ja"]="ja";e["ko"]="ko";e["hi"]="hi";e["zh"]="zh";e["pt"]="pt";e["es"]="es"})(Se||(Se={}));var Ie;(function(e){e["MASK_MODE_DEFAULT"]="MASK_MODE_DEFAULT";e["MASK_MODE_USER_PROVIDED"]="MASK_MODE_USER_PROVIDED";e["MASK_MODE_BACKGROUND"]="MASK_MODE_BACKGROUND";e["MASK_MODE_FOREGROUND"]="MASK_MODE_FOREGROUND";e["MASK_MODE_SEMANTIC"]="MASK_MODE_SEMANTIC"})(Ie||(Ie={}));var Ae;(function(e){e["CONTROL_TYPE_DEFAULT"]="CONTROL_TYPE_DEFAULT";e["CONTROL_TYPE_CANNY"]="CONTROL_TYPE_CANNY";e["CONTROL_TYPE_SCRIBBLE"]="CONTROL_TYPE_SCRIBBLE";e["CONTROL_TYPE_FACE_MESH"]="CONTROL_TYPE_FACE_MESH"})(Ae||(Ae={}));var Oe;(function(e){e["SUBJECT_TYPE_DEFAULT"]="SUBJECT_TYPE_DEFAULT";e["SUBJECT_TYPE_PERSON"]="SUBJECT_TYPE_PERSON";e["SUBJECT_TYPE_ANIMAL"]="SUBJECT_TYPE_ANIMAL";e["SUBJECT_TYPE_PRODUCT"]="SUBJECT_TYPE_PRODUCT"})(Oe||(Oe={}));var Ce;(function(e){e["EDIT_MODE_DEFAULT"]="EDIT_MODE_DEFAULT";e["EDIT_MODE_INPAINT_REMOVAL"]="EDIT_MODE_INPAINT_REMOVAL";e["EDIT_MODE_INPAINT_INSERTION"]="EDIT_MODE_INPAINT_INSERTION";e["EDIT_MODE_OUTPAINT"]="EDIT_MODE_OUTPAINT";e["EDIT_MODE_CONTROLLED_EDITING"]="EDIT_MODE_CONTROLLED_EDITING";e["EDIT_MODE_STYLE"]="EDIT_MODE_STYLE";e["EDIT_MODE_BGSWAP"]="EDIT_MODE_BGSWAP";e["EDIT_MODE_PRODUCT_IMAGE"]="EDIT_MODE_PRODUCT_IMAGE"})(Ce||(Ce={}));var _e;(function(e){e["FOREGROUND"]="FOREGROUND";e["BACKGROUND"]="BACKGROUND";e["PROMPT"]="PROMPT";e["SEMANTIC"]="SEMANTIC";e["INTERACTIVE"]="INTERACTIVE"})(_e||(_e={}));var Pe;(function(e){e["ASSET"]="ASSET";e["STYLE"]="STYLE"})(Pe||(Pe={}));var Re;(function(e){e["INSERT"]="INSERT";e["REMOVE"]="REMOVE";e["REMOVE_STATIC"]="REMOVE_STATIC";e["OUTPAINT"]="OUTPAINT"})(Re||(Re={}));var Ne;(function(e){e["OPTIMIZED"]="OPTIMIZED";e["LOSSLESS"]="LOSSLESS"})(Ne||(Ne={}));var Me;(function(e){e["SUPERVISED_FINE_TUNING"]="SUPERVISED_FINE_TUNING";e["PREFERENCE_TUNING"]="PREFERENCE_TUNING";e["DISTILLATION"]="DISTILLATION"})(Me||(Me={}));var De;(function(e){e["STATE_UNSPECIFIED"]="STATE_UNSPECIFIED";e["STATE_PENDING"]="STATE_PENDING";e["STATE_ACTIVE"]="STATE_ACTIVE";e["STATE_FAILED"]="STATE_FAILED"})(De||(De={}));var Ue;(function(e){e["STATE_UNSPECIFIED"]="STATE_UNSPECIFIED";e["PROCESSING"]="PROCESSING";e["ACTIVE"]="ACTIVE";e["FAILED"]="FAILED"})(Ue||(Ue={}));var ke;(function(e){e["SOURCE_UNSPECIFIED"]="SOURCE_UNSPECIFIED";e["UPLOADED"]="UPLOADED";e["GENERATED"]="GENERATED";e["REGISTERED"]="REGISTERED"})(ke||(ke={}));var Ge;(function(e){e["TURN_COMPLETE_REASON_UNSPECIFIED"]="TURN_COMPLETE_REASON_UNSPECIFIED";e["MALFORMED_FUNCTION_CALL"]="MALFORMED_FUNCTION_CALL";e["RESPONSE_REJECTED"]="RESPONSE_REJECTED";e["NEED_MORE_INPUT"]="NEED_MORE_INPUT"})(Ge||(Ge={}));var xe;(function(e){e["MODALITY_UNSPECIFIED"]="MODALITY_UNSPECIFIED";e["TEXT"]="TEXT";e["IMAGE"]="IMAGE";e["VIDEO"]="VIDEO";e["AUDIO"]="AUDIO";e["DOCUMENT"]="DOCUMENT"})(xe||(xe={}));var Le;(function(e){e["VAD_SIGNAL_TYPE_UNSPECIFIED"]="VAD_SIGNAL_TYPE_UNSPECIFIED";e["VAD_SIGNAL_TYPE_SOS"]="VAD_SIGNAL_TYPE_SOS";e["VAD_SIGNAL_TYPE_EOS"]="VAD_SIGNAL_TYPE_EOS"})(Le||(Le={}));var je;(function(e){e["TYPE_UNSPECIFIED"]="TYPE_UNSPECIFIED";e["ACTIVITY_START"]="ACTIVITY_START";e["ACTIVITY_END"]="ACTIVITY_END"})(je||(je={}));var Fe;(function(e){e["START_SENSITIVITY_UNSPECIFIED"]="START_SENSITIVITY_UNSPECIFIED";e["START_SENSITIVITY_HIGH"]="START_SENSITIVITY_HIGH";e["START_SENSITIVITY_LOW"]="START_SENSITIVITY_LOW"})(Fe||(Fe={}));var qe;(function(e){e["END_SENSITIVITY_UNSPECIFIED"]="END_SENSITIVITY_UNSPECIFIED";e["END_SENSITIVITY_HIGH"]="END_SENSITIVITY_HIGH";e["END_SENSITIVITY_LOW"]="END_SENSITIVITY_LOW"})(qe||(qe={}));var He;(function(e){e["ACTIVITY_HANDLING_UNSPECIFIED"]="ACTIVITY_HANDLING_UNSPECIFIED";e["START_OF_ACTIVITY_INTERRUPTS"]="START_OF_ACTIVITY_INTERRUPTS";e["NO_INTERRUPTION"]="NO_INTERRUPTION"})(He||(He={}));var $e;(function(e){e["TURN_COVERAGE_UNSPECIFIED"]="TURN_COVERAGE_UNSPECIFIED";e["TURN_INCLUDES_ONLY_ACTIVITY"]="TURN_INCLUDES_ONLY_ACTIVITY";e["TURN_INCLUDES_ALL_INPUT"]="TURN_INCLUDES_ALL_INPUT"})($e||($e={}));var Je;(function(e){e["SCALE_UNSPECIFIED"]="SCALE_UNSPECIFIED";e["C_MAJOR_A_MINOR"]="C_MAJOR_A_MINOR";e["D_FLAT_MAJOR_B_FLAT_MINOR"]="D_FLAT_MAJOR_B_FLAT_MINOR";e["D_MAJOR_B_MINOR"]="D_MAJOR_B_MINOR";e["E_FLAT_MAJOR_C_MINOR"]="E_FLAT_MAJOR_C_MINOR";e["E_MAJOR_D_FLAT_MINOR"]="E_MAJOR_D_FLAT_MINOR";e["F_MAJOR_D_MINOR"]="F_MAJOR_D_MINOR";e["G_FLAT_MAJOR_E_FLAT_MINOR"]="G_FLAT_MAJOR_E_FLAT_MINOR";e["G_MAJOR_E_MINOR"]="G_MAJOR_E_MINOR";e["A_FLAT_MAJOR_F_MINOR"]="A_FLAT_MAJOR_F_MINOR";e["A_MAJOR_G_FLAT_MINOR"]="A_MAJOR_G_FLAT_MINOR";e["B_FLAT_MAJOR_G_MINOR"]="B_FLAT_MAJOR_G_MINOR";e["B_MAJOR_A_FLAT_MINOR"]="B_MAJOR_A_FLAT_MINOR"})(Je||(Je={}));var Ve;(function(e){e["MUSIC_GENERATION_MODE_UNSPECIFIED"]="MUSIC_GENERATION_MODE_UNSPECIFIED";e["QUALITY"]="QUALITY";e["DIVERSITY"]="DIVERSITY";e["VOCALIZATION"]="VOCALIZATION"})(Ve||(Ve={}));var Be;(function(e){e["PLAYBACK_CONTROL_UNSPECIFIED"]="PLAYBACK_CONTROL_UNSPECIFIED";e["PLAY"]="PLAY";e["PAUSE"]="PAUSE";e["STOP"]="STOP";e["RESET_CONTEXT"]="RESET_CONTEXT"})(Be||(Be={}));class We{constructor(e){const n={};for(const t of e.headers.entries()){n[t[0]]=t[1]}this.headers=n;this.responseInternal=e}json(){return this.responseInternal.json()}}class Ye{get text(){var e,n,t,i,o,r,s,l;if(((i=(t=(n=(e=this.candidates)===null||e===void 0?void 0:e[0])===null||n===void 0?void 0:n.content)===null||t===void 0?void 0:t.parts)===null||i===void 0?void 0:i.length)===0){return undefined}if(this.candidates&&this.candidates.length>1){console.warn("there are multiple candidates in the response, returning text from the first one.")}let u="";let a=false;const c=[];for(const e of(l=(s=(r=(o=this.candidates)===null||o===void 0?void 0:o[0])===null||r===void 0?void 0:r.content)===null||s===void 0?void 0:s.parts)!==null&&l!==void 0?l:[]){for(const[n,t]of Object.entries(e)){if(n!=="text"&&n!=="thought"&&n!=="thoughtSignature"&&(t!==null||t!==undefined)){c.push(n)}}if(typeof e.text==="string"){if(typeof e.thought==="boolean"&&e.thought){continue}a=true;u+=e.text}}if(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.`)}return a?u:undefined}get data(){var e,n,t,i,o,r,s,l;if(((i=(t=(n=(e=this.candidates)===null||e===void 0?void 0:e[0])===null||n===void 0?void 0:n.content)===null||t===void 0?void 0:t.parts)===null||i===void 0?void 0:i.length)===0){return undefined}if(this.candidates&&this.candidates.length>1){console.warn("there are multiple candidates in the response, returning data from the first one.")}let u="";const a=[];for(const e of(l=(s=(r=(o=this.candidates)===null||o===void 0?void 0:o[0])===null||r===void 0?void 0:r.content)===null||s===void 0?void 0:s.parts)!==null&&l!==void 0?l:[]){for(const[n,t]of Object.entries(e)){if(n!=="inlineData"&&(t!==null||t!==undefined)){a.push(n)}}if(e.inlineData&&typeof e.inlineData.data==="string"){u+=atob(e.inlineData.data)}}if(a.length>0){console.warn(`there are non-data parts ${a} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`)}return u.length>0?btoa(u):undefined}get functionCalls(){var e,n,t,i,o,r,s,l;if(((i=(t=(n=(e=this.candidates)===null||e===void 0?void 0:e[0])===null||n===void 0?void 0:n.content)===null||t===void 0?void 0:t.parts)===null||i===void 0?void 0:i.length)===0){return undefined}if(this.candidates&&this.candidates.length>1){console.warn("there are multiple candidates in the response, returning function calls from the first one.")}const u=(l=(s=(r=(o=this.candidates)===null||o===void 0?void 0:o[0])===null||r===void 0?void 0:r.content)===null||s===void 0?void 0:s.parts)===null||l===void 0?void 0:l.filter((e=>e.functionCall)).map((e=>e.functionCall)).filter((e=>e!==undefined));if((u===null||u===void 0?void 0:u.length)===0){return undefined}return u}get executableCode(){var e,n,t,i,o,r,s,l,u;if(((i=(t=(n=(e=this.candidates)===null||e===void 0?void 0:e[0])===null||n===void 0?void 0:n.content)===null||t===void 0?void 0:t.parts)===null||i===void 0?void 0:i.length)===0){return undefined}if(this.candidates&&this.candidates.length>1){console.warn("there are multiple candidates in the response, returning executable code from the first one.")}const a=(l=(s=(r=(o=this.candidates)===null||o===void 0?void 0:o[0])===null||r===void 0?void 0:r.content)===null||s===void 0?void 0:s.parts)===null||l===void 0?void 0:l.filter((e=>e.executableCode)).map((e=>e.executableCode)).filter((e=>e!==undefined));if((a===null||a===void 0?void 0:a.length)===0){return undefined}return(u=a===null||a===void 0?void 0:a[0])===null||u===void 0?void 0:u.code}get codeExecutionResult(){var e,n,t,i,o,r,s,l,u;if(((i=(t=(n=(e=this.candidates)===null||e===void 0?void 0:e[0])===null||n===void 0?void 0:n.content)===null||t===void 0?void 0:t.parts)===null||i===void 0?void 0:i.length)===0){return undefined}if(this.candidates&&this.candidates.length>1){console.warn("there are multiple candidates in the response, returning code execution result from the first one.")}const a=(l=(s=(r=(o=this.candidates)===null||o===void 0?void 0:o[0])===null||r===void 0?void 0:r.content)===null||s===void 0?void 0:s.parts)===null||l===void 0?void 0:l.filter((e=>e.codeExecutionResult)).map((e=>e.codeExecutionResult)).filter((e=>e!==undefined));if((a===null||a===void 0?void 0:a.length)===0){return undefined}return(u=a===null||a===void 0?void 0:a[0])===null||u===void 0?void 0:u.output}}class Ke{}class ze{}class Xe{}class Qe{}class Ze{}class en{}class nn{}class tn{}class on{}class rn{}class sn{_fromAPIResponse({apiResponse:e,_isVertexAI:n}){const t=new sn;let i;const o=e;if(n){i=P(o)}else{i=_(o)}Object.assign(t,i);return t}}class ln{}class un{}class an{}class cn{}class fn{}class dn{}class pn{}class hn{_fromAPIResponse({apiResponse:e,_isVertexAI:n}){const t=new hn;const i=e;const o=G(i);Object.assign(t,o);return t}}class mn{}class gn{}class yn{}class vn{}class En{}class wn{get text(){var e,n,t;let i="";let o=false;const r=[];for(const s of(t=(n=(e=this.serverContent)===null||e===void 0?void 0:e.modelTurn)===null||n===void 0?void 0:n.parts)!==null&&t!==void 0?t:[]){for(const[e,n]of Object.entries(s)){if(e!=="text"&&e!=="thought"&&n!==null){r.push(e)}}if(typeof s.text==="string"){if(typeof s.thought==="boolean"&&s.thought){continue}o=true;i+=s.text}}if(r.length>0){console.warn(`there are non-text parts ${r} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`)}return o?i:undefined}get data(){var e,n,t;let i="";const o=[];for(const r of(t=(n=(e=this.serverContent)===null||e===void 0?void 0:e.modelTurn)===null||n===void 0?void 0:n.parts)!==null&&t!==void 0?t:[]){for(const[e,n]of Object.entries(r)){if(e!=="inlineData"&&n!==null){o.push(e)}}if(r.inlineData&&typeof r.inlineData.data==="string"){i+=atob(r.inlineData.data)}}if(o.length>0){console.warn(`there are non-data parts ${o} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`)}return i.length>0?btoa(i):undefined}}class bn{get audioChunk(){if(this.serverContent&&this.serverContent.audioChunks&&this.serverContent.audioChunks.length>0){return this.serverContent.audioChunks[0]}return undefined}}class Tn{_fromAPIResponse({apiResponse:e,_isVertexAI:n}){const t=new Tn;const i=e;const o=L(i);Object.assign(t,o);return t}}
27
+ /**
28
+ * @license
29
+ * Copyright 2025 Google LLC
30
+ * SPDX-License-Identifier: Apache-2.0
31
+ */function Sn(e,n){if(!n||typeof n!=="string"){throw new Error("model is required and must be a string")}if(n.includes("..")||n.includes("?")||n.includes("&")){throw new Error("invalid model parameter")}if(e.isVertexAI()){if(n.startsWith("publishers/")||n.startsWith("projects/")||n.startsWith("models/")){return n}else if(n.indexOf("/")>=0){const e=n.split("/",2);return`publishers/${e[0]}/models/${e[1]}`}else{return`publishers/google/models/${n}`}}else{if(n.startsWith("models/")||n.startsWith("tunedModels/")){return n}else{return`models/${n}`}}}function In(e,n){const t=Sn(e,n);if(!t){return""}if(t.startsWith("publishers/")&&e.isVertexAI()){return`projects/${e.getProject()}/locations/${e.getLocation()}/${t}`}else if(t.startsWith("models/")&&e.isVertexAI()){return`projects/${e.getProject()}/locations/${e.getLocation()}/publishers/google/${t}`}else{return t}}function An(e){if(Array.isArray(e)){return e.map((e=>On(e)))}else{return[On(e)]}}function On(e){if(typeof e==="object"&&e!==null){return e}throw new Error(`Could not parse input as Blob. Unsupported blob type: ${typeof e}`)}function Cn(e){const n=On(e);if(n.mimeType&&n.mimeType.startsWith("image/")){return n}throw new Error(`Unsupported mime type: ${n.mimeType}`)}function _n(e){const n=On(e);if(n.mimeType&&n.mimeType.startsWith("audio/")){return n}throw new Error(`Unsupported mime type: ${n.mimeType}`)}function Pn(e){if(e===null||e===undefined){throw new Error("PartUnion is required")}if(typeof e==="object"){return e}if(typeof e==="string"){return{text:e}}throw new Error(`Unsupported part type: ${typeof e}`)}function Rn(e){if(e===null||e===undefined||Array.isArray(e)&&e.length===0){throw new Error("PartListUnion is required")}if(Array.isArray(e)){return e.map((e=>Pn(e)))}return[Pn(e)]}function Nn(e){return e!==null&&e!==undefined&&typeof e==="object"&&"parts"in e&&Array.isArray(e.parts)}function Mn(e){return e!==null&&e!==undefined&&typeof e==="object"&&"functionCall"in e}function Dn(e){return e!==null&&e!==undefined&&typeof e==="object"&&"functionResponse"in e}function Un(e){if(e===null||e===undefined){throw new Error("ContentUnion is required")}if(Nn(e)){return e}return{role:"user",parts:Rn(e)}}function kn(e,n){if(!n){return[]}if(e.isVertexAI()&&Array.isArray(n)){return n.flatMap((e=>{const n=Un(e);if(n.parts&&n.parts.length>0&&n.parts[0].text!==undefined){return[n.parts[0].text]}return[]}))}else if(e.isVertexAI()){const e=Un(n);if(e.parts&&e.parts.length>0&&e.parts[0].text!==undefined){return[e.parts[0].text]}return[]}if(Array.isArray(n)){return n.map((e=>Un(e)))}return[Un(n)]}function Gn(e){if(e===null||e===undefined||Array.isArray(e)&&e.length===0){throw new Error("contents are required")}if(!Array.isArray(e)){if(Mn(e)||Dn(e)){throw new Error("To specify functionCall or functionResponse parts, please wrap them in a Content object, specifying the role for them")}return[Un(e)]}const n=[];const t=[];const i=Nn(e[0]);for(const o of e){const e=Nn(o);if(e!=i){throw new Error("Mixing Content and Parts is not supported, please group the parts into a the appropriate Content objects and specify the roles for them")}if(e){n.push(o)}else if(Mn(o)||Dn(o)){throw new Error("To specify functionCall or functionResponse parts, please wrap them, and any other parts, in Content objects as appropriate, specifying the role for them")}else{t.push(o)}}if(!i){n.push({role:"user",parts:Rn(t)})}return n}function xn(e,n){if(e.includes("null")){n["nullable"]=true}const t=e.filter((e=>e!=="null"));if(t.length===1){n["type"]=Object.values(V).includes(t[0].toUpperCase())?t[0].toUpperCase():V.TYPE_UNSPECIFIED}else{n["anyOf"]=[];for(const e of t){n["anyOf"].push({type:Object.values(V).includes(e.toUpperCase())?e.toUpperCase():V.TYPE_UNSPECIFIED})}}}function Ln(e){const n={};const t=["items"];const i=["anyOf"];const o=["properties"];if(e["type"]&&e["anyOf"]){throw new Error("type and anyOf cannot be both populated.")}const r=e["anyOf"];if(r!=null&&r.length==2){if(r[0]["type"]==="null"){n["nullable"]=true;e=r[1]}else if(r[1]["type"]==="null"){n["nullable"]=true;e=r[0]}}if(e["type"]instanceof Array){xn(e["type"],n)}for(const[r,s]of Object.entries(e)){if(s==null){continue}if(r=="type"){if(s==="null"){throw new Error("type: null can not be the only possible type for the field.")}if(s instanceof Array){continue}n["type"]=Object.values(V).includes(s.toUpperCase())?s.toUpperCase():V.TYPE_UNSPECIFIED}else if(t.includes(r)){n[r]=Ln(s)}else if(i.includes(r)){const e=[];for(const t of s){if(t["type"]=="null"){n["nullable"]=true;continue}e.push(Ln(t))}n[r]=e}else if(o.includes(r)){const e={};for(const[n,t]of Object.entries(s)){e[n]=Ln(t)}n[r]=e}else{if(r==="additionalProperties"){continue}n[r]=s}}return n}function jn(e){return Ln(e)}function Fn(e){if(typeof e==="object"){return e}else if(typeof e==="string"){return{voiceConfig:{prebuiltVoiceConfig:{voiceName:e}}}}else{throw new Error(`Unsupported speechConfig type: ${typeof e}`)}}function qn(e){if("multiSpeakerVoiceConfig"in e){throw new Error("multiSpeakerVoiceConfig is not supported in the live API.")}return e}function Hn(e){if(e.functionDeclarations){for(const n of e.functionDeclarations){if(n.parameters){if(!Object.keys(n.parameters).includes("$schema")){n.parameters=Ln(n.parameters)}else{if(!n.parametersJsonSchema){n.parametersJsonSchema=n.parameters;delete n.parameters}}}if(n.response){if(!Object.keys(n.response).includes("$schema")){n.response=Ln(n.response)}else{if(!n.responseJsonSchema){n.responseJsonSchema=n.response;delete n.response}}}}}return e}function $n(e){if(e===undefined||e===null){throw new Error("tools is required")}if(!Array.isArray(e)){throw new Error("tools is required and must be an array of Tools")}const n=[];for(const t of e){n.push(t)}return n}function Jn(e,n,t,i=1){const o=!n.startsWith(`${t}/`)&&n.split("/").length===i;if(e.isVertexAI()){if(n.startsWith("projects/")){return n}else if(n.startsWith("locations/")){return`projects/${e.getProject()}/${n}`}else if(n.startsWith(`${t}/`)){return`projects/${e.getProject()}/locations/${e.getLocation()}/${n}`}else if(o){return`projects/${e.getProject()}/locations/${e.getLocation()}/${t}/${n}`}else{return n}}if(o){return`${t}/${n}`}return n}function Vn(e,n){if(typeof n!=="string"){throw new Error("name must be a string")}return Jn(e,n,"cachedContents")}function Bn(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 Wn(e){return O(e)}function Yn(e){return e!==null&&e!==undefined&&typeof e==="object"&&"name"in e}function Kn(e){return e!==null&&e!==undefined&&typeof e==="object"&&"video"in e}function zn(e){return e!==null&&e!==undefined&&typeof e==="object"&&"uri"in e}function Xn(e){var n;let t;if(Yn(e)){t=e.name}if(zn(e)){t=e.uri;if(t===undefined){return undefined}}if(Kn(e)){t=(n=e.video)===null||n===void 0?void 0:n.uri;if(t===undefined){return undefined}}if(typeof e==="string"){t=e}if(t===undefined){throw new Error("Could not extract file name from the provided input.")}if(t.startsWith("https://")){const e=t.split("files/")[1];const n=e.match(/[a-z0-9]+/);if(n===null){throw new Error(`Could not extract file name from URI ${t}`)}t=n[0]}else if(t.startsWith("files/")){t=t.split("files/")[1]}return t}function Qn(e,n){let t;if(e.isVertexAI()){t=n?"publishers/google/models":"models"}else{t=n?"models":"tunedModels"}return t}function Zn(e){for(const n of["models","tunedModels","publisherModels"]){if(et(e,n)){return e[n]}}return[]}function et(e,n){return e!==null&&typeof e==="object"&&n in e}function nt(e,n={}){const t=e;const i={name:t["name"],description:t["description"],parametersJsonSchema:t["inputSchema"]};if(t["outputSchema"]){i["responseJsonSchema"]=t["outputSchema"]}if(n.behavior){i["behavior"]=n.behavior}const o={functionDeclarations:[i]};return o}function tt(e,n={}){const t=[];const i=new Set;for(const o of e){const e=o.name;if(i.has(e)){throw new Error(`Duplicate function name ${e} found in MCP tools. Please ensure function names are unique.`)}i.add(e);const r=nt(o,n);if(r.functionDeclarations){t.push(...r.functionDeclarations)}}return{functionDeclarations:t}}function it(e,n){let t;if(typeof n==="string"){if(e.isVertexAI()){if(n.startsWith("gs://")){t={format:"jsonl",gcsUri:[n]}}else if(n.startsWith("bq://")){t={format:"bigquery",bigqueryUri:n}}else{throw new Error(`Unsupported string source for Vertex AI: ${n}`)}}else{if(n.startsWith("files/")){t={fileName:n}}else{throw new Error(`Unsupported string source for Gemini API: ${n}`)}}}else if(Array.isArray(n)){if(e.isVertexAI()){throw new Error("InlinedRequest[] is not supported in Vertex AI.")}t={inlinedRequests:n}}else{t=n}const i=[t.gcsUri,t.bigqueryUri].filter(Boolean).length;const o=[t.inlinedRequests,t.fileName].filter(Boolean).length;if(e.isVertexAI()){if(o>0||i!==1){throw new Error("Exactly one of `gcsUri` or `bigqueryUri` must be set for Vertex AI.")}}else{if(i>0||o!==1){throw new Error("Exactly one of `inlinedRequests`, `fileName`, "+"must be set for Gemini API.")}}return t}function ot(e){if(typeof e!=="string"){return e}const n=e;if(n.startsWith("gs://")){return{format:"jsonl",gcsUri:n}}else if(n.startsWith("bq://")){return{format:"bigquery",bigqueryUri:n}}else{throw new Error(`Unsupported destination: ${n}`)}}function rt(e){if(typeof e!=="object"||e===null){return{}}const n=e;const t=n["inlinedResponses"];if(typeof t!=="object"||t===null){return e}const i=t;const o=i["inlinedResponses"];if(!Array.isArray(o)||o.length===0){return e}let r=false;for(const e of o){if(typeof e!=="object"||e===null){continue}const n=e;const t=n["response"];if(typeof t!=="object"||t===null){continue}const i=t;if(i["embedding"]!==undefined){r=true;break}}if(r){n["inlinedEmbedContentResponses"]=n["inlinedResponses"];delete n["inlinedResponses"]}return e}function st(e,n){const t=n;if(!e.isVertexAI()){const e=/batches\/[^/]+$/;if(e.test(t)){return t.split("/").pop()}else{throw new Error(`Invalid batch job name: ${t}.`)}}const i=/^projects\/[^/]+\/locations\/[^/]+\/batchPredictionJobs\/[^/]+$/;if(i.test(t)){return t.split("/").pop()}else if(/^\d+$/.test(t)){return t}else{throw new Error(`Invalid batch job name: ${t}.`)}}function lt(e){const n=e;if(n==="BATCH_STATE_UNSPECIFIED"){return"JOB_STATE_UNSPECIFIED"}else if(n==="BATCH_STATE_PENDING"){return"JOB_STATE_PENDING"}else if(n==="BATCH_STATE_RUNNING"){return"JOB_STATE_RUNNING"}else if(n==="BATCH_STATE_SUCCEEDED"){return"JOB_STATE_SUCCEEDED"}else if(n==="BATCH_STATE_FAILED"){return"JOB_STATE_FAILED"}else if(n==="BATCH_STATE_CANCELLED"){return"JOB_STATE_CANCELLED"}else if(n==="BATCH_STATE_EXPIRED"){return"JOB_STATE_EXPIRED"}else{return n}}function ut(e){return e.includes("gemini")&&e!=="gemini-embedding-001"||e.includes("maas")}
32
+ /**
33
+ * @license
34
+ * Copyright 2025 Google LLC
35
+ * SPDX-License-Identifier: Apache-2.0
36
+ */function at(e){const n={};const t=S(e,["responsesFile"]);if(t!=null){T(n,["fileName"],t)}const i=S(e,["inlinedResponses","inlinedResponses"]);if(i!=null){let e=i;if(Array.isArray(e)){e=e.map((e=>Wt(e)))}T(n,["inlinedResponses"],e)}const o=S(e,["inlinedEmbedContentResponses","inlinedResponses"]);if(o!=null){let e=o;if(Array.isArray(e)){e=e.map((e=>e))}T(n,["inlinedEmbedContentResponses"],e)}return n}function ct(e){const n={};const t=S(e,["predictionsFormat"]);if(t!=null){T(n,["format"],t)}const i=S(e,["gcsDestination","outputUriPrefix"]);if(i!=null){T(n,["gcsUri"],i)}const o=S(e,["bigqueryDestination","outputUri"]);if(o!=null){T(n,["bigqueryUri"],o)}return n}function ft(e){const n={};const t=S(e,["format"]);if(t!=null){T(n,["predictionsFormat"],t)}const i=S(e,["gcsUri"]);if(i!=null){T(n,["gcsDestination","outputUriPrefix"],i)}const o=S(e,["bigqueryUri"]);if(o!=null){T(n,["bigqueryDestination","outputUri"],o)}if(S(e,["fileName"])!==undefined){throw new Error("fileName parameter is not supported in Vertex AI.")}if(S(e,["inlinedResponses"])!==undefined){throw new Error("inlinedResponses parameter is not supported in Vertex AI.")}if(S(e,["inlinedEmbedContentResponses"])!==undefined){throw new Error("inlinedEmbedContentResponses parameter is not supported in Vertex AI.")}return n}function dt(e){const n={};const t=S(e,["name"]);if(t!=null){T(n,["name"],t)}const i=S(e,["metadata","displayName"]);if(i!=null){T(n,["displayName"],i)}const o=S(e,["metadata","state"]);if(o!=null){T(n,["state"],lt(o))}const r=S(e,["metadata","createTime"]);if(r!=null){T(n,["createTime"],r)}const s=S(e,["metadata","endTime"]);if(s!=null){T(n,["endTime"],s)}const l=S(e,["metadata","updateTime"]);if(l!=null){T(n,["updateTime"],l)}const u=S(e,["metadata","model"]);if(u!=null){T(n,["model"],u)}const a=S(e,["metadata","output"]);if(a!=null){T(n,["dest"],at(rt(a)))}return n}function pt(e){const n={};const t=S(e,["name"]);if(t!=null){T(n,["name"],t)}const i=S(e,["displayName"]);if(i!=null){T(n,["displayName"],i)}const o=S(e,["state"]);if(o!=null){T(n,["state"],lt(o))}const r=S(e,["error"]);if(r!=null){T(n,["error"],r)}const s=S(e,["createTime"]);if(s!=null){T(n,["createTime"],s)}const l=S(e,["startTime"]);if(l!=null){T(n,["startTime"],l)}const u=S(e,["endTime"]);if(u!=null){T(n,["endTime"],u)}const a=S(e,["updateTime"]);if(a!=null){T(n,["updateTime"],a)}const c=S(e,["model"]);if(c!=null){T(n,["model"],c)}const f=S(e,["inputConfig"]);if(f!=null){T(n,["src"],ht(f))}const d=S(e,["outputConfig"]);if(d!=null){T(n,["dest"],ct(rt(d)))}const p=S(e,["completionStats"]);if(p!=null){T(n,["completionStats"],p)}return n}function ht(e){const n={};const t=S(e,["instancesFormat"]);if(t!=null){T(n,["format"],t)}const i=S(e,["gcsSource","uris"]);if(i!=null){T(n,["gcsUri"],i)}const o=S(e,["bigquerySource","inputUri"]);if(o!=null){T(n,["bigqueryUri"],o)}return n}function mt(e,n){const t={};if(S(n,["format"])!==undefined){throw new Error("format parameter is not supported in Gemini API.")}if(S(n,["gcsUri"])!==undefined){throw new Error("gcsUri parameter is not supported in Gemini API.")}if(S(n,["bigqueryUri"])!==undefined){throw new Error("bigqueryUri parameter is not supported in Gemini API.")}const i=S(n,["fileName"]);if(i!=null){T(t,["fileName"],i)}const o=S(n,["inlinedRequests"]);if(o!=null){let n=o;if(Array.isArray(n)){n=n.map((n=>Bt(e,n)))}T(t,["requests","requests"],n)}return t}function gt(e){const n={};const t=S(e,["format"]);if(t!=null){T(n,["instancesFormat"],t)}const i=S(e,["gcsUri"]);if(i!=null){T(n,["gcsSource","uris"],i)}const o=S(e,["bigqueryUri"]);if(o!=null){T(n,["bigquerySource","inputUri"],o)}if(S(e,["fileName"])!==undefined){throw new Error("fileName parameter is not supported in Vertex AI.")}if(S(e,["inlinedRequests"])!==undefined){throw new Error("inlinedRequests parameter is not supported in Vertex AI.")}return n}function yt(e){const n={};const t=S(e,["data"]);if(t!=null){T(n,["data"],t)}if(S(e,["displayName"])!==undefined){throw new Error("displayName parameter is not supported in Gemini API.")}const i=S(e,["mimeType"]);if(i!=null){T(n,["mimeType"],i)}return n}function vt(e,n){const t={};const i=S(n,["name"]);if(i!=null){T(t,["_url","name"],st(e,i))}return t}function Et(e,n){const t={};const i=S(n,["name"]);if(i!=null){T(t,["_url","name"],st(e,i))}return t}function wt(e){const n={};const t=S(e,["content"]);if(t!=null){T(n,["content"],t)}const i=S(e,["citationMetadata"]);if(i!=null){T(n,["citationMetadata"],bt(i))}const o=S(e,["tokenCount"]);if(o!=null){T(n,["tokenCount"],o)}const r=S(e,["finishReason"]);if(r!=null){T(n,["finishReason"],r)}const s=S(e,["groundingMetadata"]);if(s!=null){T(n,["groundingMetadata"],s)}const l=S(e,["avgLogprobs"]);if(l!=null){T(n,["avgLogprobs"],l)}const u=S(e,["index"]);if(u!=null){T(n,["index"],u)}const a=S(e,["logprobsResult"]);if(a!=null){T(n,["logprobsResult"],a)}const c=S(e,["safetyRatings"]);if(c!=null){let e=c;if(Array.isArray(e)){e=e.map((e=>e))}T(n,["safetyRatings"],e)}const f=S(e,["urlContextMetadata"]);if(f!=null){T(n,["urlContextMetadata"],f)}return n}function bt(e){const n={};const t=S(e,["citationSources"]);if(t!=null){let e=t;if(Array.isArray(e)){e=e.map((e=>e))}T(n,["citations"],e)}return n}function Tt(e){const n={};const t=S(e,["parts"]);if(t!=null){let e=t;if(Array.isArray(e)){e=e.map((e=>ei(e)))}T(n,["parts"],e)}const i=S(e,["role"]);if(i!=null){T(n,["role"],i)}return n}function St(e,n){const t={};const i=S(e,["displayName"]);if(n!==undefined&&i!=null){T(n,["batch","displayName"],i)}if(S(e,["dest"])!==undefined){throw new Error("dest parameter is not supported in Gemini API.")}return t}function It(e,n){const t={};const i=S(e,["displayName"]);if(n!==undefined&&i!=null){T(n,["displayName"],i)}const o=S(e,["dest"]);if(n!==undefined&&o!=null){T(n,["outputConfig"],ft(ot(o)))}return t}function At(e,n){const t={};const i=S(n,["model"]);if(i!=null){T(t,["_url","model"],Sn(e,i))}const o=S(n,["src"]);if(o!=null){T(t,["batch","inputConfig"],mt(e,it(e,o)))}const r=S(n,["config"]);if(r!=null){St(r,t)}return t}function Ot(e,n){const t={};const i=S(n,["model"]);if(i!=null){T(t,["model"],Sn(e,i))}const o=S(n,["src"]);if(o!=null){T(t,["inputConfig"],gt(it(e,o)))}const r=S(n,["config"]);if(r!=null){It(r,t)}return t}function Ct(e,n){const t={};const i=S(e,["displayName"]);if(n!==undefined&&i!=null){T(n,["batch","displayName"],i)}return t}function _t(e,n){const t={};const i=S(n,["model"]);if(i!=null){T(t,["_url","model"],Sn(e,i))}const o=S(n,["src"]);if(o!=null){T(t,["batch","inputConfig"],kt(e,o))}const r=S(n,["config"]);if(r!=null){Ct(r,t)}return t}function Pt(e,n){const t={};const i=S(n,["name"]);if(i!=null){T(t,["_url","name"],st(e,i))}return t}function Rt(e,n){const t={};const i=S(n,["name"]);if(i!=null){T(t,["_url","name"],st(e,i))}return t}function Nt(e){const n={};const t=S(e,["sdkHttpResponse"]);if(t!=null){T(n,["sdkHttpResponse"],t)}const i=S(e,["name"]);if(i!=null){T(n,["name"],i)}const o=S(e,["done"]);if(o!=null){T(n,["done"],o)}const r=S(e,["error"]);if(r!=null){T(n,["error"],r)}return n}function Mt(e){const n={};const t=S(e,["sdkHttpResponse"]);if(t!=null){T(n,["sdkHttpResponse"],t)}const i=S(e,["name"]);if(i!=null){T(n,["name"],i)}const o=S(e,["done"]);if(o!=null){T(n,["done"],o)}const r=S(e,["error"]);if(r!=null){T(n,["error"],r)}return n}function Dt(e,n){const t={};const i=S(n,["contents"]);if(i!=null){let n=kn(e,i);if(Array.isArray(n)){n=n.map((e=>e))}T(t,["requests[]","request","content"],n)}const o=S(n,["config"]);if(o!=null){T(t,["_self"],Ut(o,t));I(t,{"requests[].*":"requests[].request.*"})}return t}function Ut(e,n){const t={};const i=S(e,["taskType"]);if(n!==undefined&&i!=null){T(n,["requests[]","taskType"],i)}const o=S(e,["title"]);if(n!==undefined&&o!=null){T(n,["requests[]","title"],o)}const r=S(e,["outputDimensionality"]);if(n!==undefined&&r!=null){T(n,["requests[]","outputDimensionality"],r)}if(S(e,["mimeType"])!==undefined){throw new Error("mimeType parameter is not supported in Gemini API.")}if(S(e,["autoTruncate"])!==undefined){throw new Error("autoTruncate parameter is not supported in Gemini API.")}return t}function kt(e,n){const t={};const i=S(n,["fileName"]);if(i!=null){T(t,["file_name"],i)}const o=S(n,["inlinedRequests"]);if(o!=null){T(t,["requests"],Dt(e,o))}return t}function Gt(e){const n={};if(S(e,["displayName"])!==undefined){throw new Error("displayName parameter is not supported in Gemini API.")}const t=S(e,["fileUri"]);if(t!=null){T(n,["fileUri"],t)}const i=S(e,["mimeType"]);if(i!=null){T(n,["mimeType"],i)}return n}function xt(e){const n={};const t=S(e,["id"]);if(t!=null){T(n,["id"],t)}const i=S(e,["args"]);if(i!=null){T(n,["args"],i)}const o=S(e,["name"]);if(o!=null){T(n,["name"],o)}if(S(e,["partialArgs"])!==undefined){throw new Error("partialArgs parameter is not supported in Gemini API.")}if(S(e,["willContinue"])!==undefined){throw new Error("willContinue parameter is not supported in Gemini API.")}return n}function Lt(e){const n={};const t=S(e,["allowedFunctionNames"]);if(t!=null){T(n,["allowedFunctionNames"],t)}const i=S(e,["mode"]);if(i!=null){T(n,["mode"],i)}if(S(e,["streamFunctionCallArguments"])!==undefined){throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.")}return n}function jt(e,n,t){const i={};const o=S(n,["systemInstruction"]);if(t!==undefined&&o!=null){T(t,["systemInstruction"],Tt(Un(o)))}const r=S(n,["temperature"]);if(r!=null){T(i,["temperature"],r)}const s=S(n,["topP"]);if(s!=null){T(i,["topP"],s)}const l=S(n,["topK"]);if(l!=null){T(i,["topK"],l)}const u=S(n,["candidateCount"]);if(u!=null){T(i,["candidateCount"],u)}const a=S(n,["maxOutputTokens"]);if(a!=null){T(i,["maxOutputTokens"],a)}const c=S(n,["stopSequences"]);if(c!=null){T(i,["stopSequences"],c)}const f=S(n,["responseLogprobs"]);if(f!=null){T(i,["responseLogprobs"],f)}const d=S(n,["logprobs"]);if(d!=null){T(i,["logprobs"],d)}const p=S(n,["presencePenalty"]);if(p!=null){T(i,["presencePenalty"],p)}const h=S(n,["frequencyPenalty"]);if(h!=null){T(i,["frequencyPenalty"],h)}const m=S(n,["seed"]);if(m!=null){T(i,["seed"],m)}const g=S(n,["responseMimeType"]);if(g!=null){T(i,["responseMimeType"],g)}const y=S(n,["responseSchema"]);if(y!=null){T(i,["responseSchema"],jn(y))}const v=S(n,["responseJsonSchema"]);if(v!=null){T(i,["responseJsonSchema"],v)}if(S(n,["routingConfig"])!==undefined){throw new Error("routingConfig parameter is not supported in Gemini API.")}if(S(n,["modelSelectionConfig"])!==undefined){throw new Error("modelSelectionConfig parameter is not supported in Gemini API.")}const E=S(n,["safetySettings"]);if(t!==undefined&&E!=null){let e=E;if(Array.isArray(e)){e=e.map((e=>ni(e)))}T(t,["safetySettings"],e)}const w=S(n,["tools"]);if(t!==undefined&&w!=null){let e=$n(w);if(Array.isArray(e)){e=e.map((e=>ii(Hn(e))))}T(t,["tools"],e)}const b=S(n,["toolConfig"]);if(t!==undefined&&b!=null){T(t,["toolConfig"],ti(b))}if(S(n,["labels"])!==undefined){throw new Error("labels parameter is not supported in Gemini API.")}const I=S(n,["cachedContent"]);if(t!==undefined&&I!=null){T(t,["cachedContent"],Vn(e,I))}const A=S(n,["responseModalities"]);if(A!=null){T(i,["responseModalities"],A)}const O=S(n,["mediaResolution"]);if(O!=null){T(i,["mediaResolution"],O)}const C=S(n,["speechConfig"]);if(C!=null){T(i,["speechConfig"],Fn(C))}if(S(n,["audioTimestamp"])!==undefined){throw new Error("audioTimestamp parameter is not supported in Gemini API.")}const _=S(n,["thinkingConfig"]);if(_!=null){T(i,["thinkingConfig"],_)}const P=S(n,["imageConfig"]);if(P!=null){T(i,["imageConfig"],Vt(P))}const R=S(n,["enableEnhancedCivicAnswers"]);if(R!=null){T(i,["enableEnhancedCivicAnswers"],R)}if(S(n,["modelArmorConfig"])!==undefined){throw new Error("modelArmorConfig parameter is not supported in Gemini API.")}return i}function Ft(e){const n={};const t=S(e,["sdkHttpResponse"]);if(t!=null){T(n,["sdkHttpResponse"],t)}const i=S(e,["candidates"]);if(i!=null){let e=i;if(Array.isArray(e)){e=e.map((e=>wt(e)))}T(n,["candidates"],e)}const o=S(e,["modelVersion"]);if(o!=null){T(n,["modelVersion"],o)}const r=S(e,["promptFeedback"]);if(r!=null){T(n,["promptFeedback"],r)}const s=S(e,["responseId"]);if(s!=null){T(n,["responseId"],s)}const l=S(e,["usageMetadata"]);if(l!=null){T(n,["usageMetadata"],l)}return n}function qt(e,n){const t={};const i=S(n,["name"]);if(i!=null){T(t,["_url","name"],st(e,i))}return t}function Ht(e,n){const t={};const i=S(n,["name"]);if(i!=null){T(t,["_url","name"],st(e,i))}return t}function $t(e){const n={};if(S(e,["authConfig"])!==undefined){throw new Error("authConfig parameter is not supported in Gemini API.")}const t=S(e,["enableWidget"]);if(t!=null){T(n,["enableWidget"],t)}return n}function Jt(e){const n={};const t=S(e,["searchTypes"]);if(t!=null){T(n,["searchTypes"],t)}if(S(e,["excludeDomains"])!==undefined){throw new Error("excludeDomains parameter is not supported in Gemini API.")}if(S(e,["blockingConfidence"])!==undefined){throw new Error("blockingConfidence parameter is not supported in Gemini API.")}const i=S(e,["timeRangeFilter"]);if(i!=null){T(n,["timeRangeFilter"],i)}return n}function Vt(e){const n={};const t=S(e,["aspectRatio"]);if(t!=null){T(n,["aspectRatio"],t)}const i=S(e,["imageSize"]);if(i!=null){T(n,["imageSize"],i)}if(S(e,["personGeneration"])!==undefined){throw new Error("personGeneration parameter is not supported in Gemini API.")}if(S(e,["prominentPeople"])!==undefined){throw new Error("prominentPeople parameter is not supported in Gemini API.")}if(S(e,["outputMimeType"])!==undefined){throw new Error("outputMimeType parameter is not supported in Gemini API.")}if(S(e,["outputCompressionQuality"])!==undefined){throw new Error("outputCompressionQuality parameter is not supported in Gemini API.")}return n}function Bt(e,n){const t={};const i=S(n,["model"]);if(i!=null){T(t,["request","model"],Sn(e,i))}const o=S(n,["contents"]);if(o!=null){let e=Gn(o);if(Array.isArray(e)){e=e.map((e=>Tt(e)))}T(t,["request","contents"],e)}const r=S(n,["metadata"]);if(r!=null){T(t,["metadata"],r)}const s=S(n,["config"]);if(s!=null){T(t,["request","generationConfig"],jt(e,s,S(t,["request"],{})))}return t}function Wt(e){const n={};const t=S(e,["response"]);if(t!=null){T(n,["response"],Ft(t))}const i=S(e,["metadata"]);if(i!=null){T(n,["metadata"],i)}const o=S(e,["error"]);if(o!=null){T(n,["error"],o)}return n}function Yt(e,n){const t={};const i=S(e,["pageSize"]);if(n!==undefined&&i!=null){T(n,["_query","pageSize"],i)}const o=S(e,["pageToken"]);if(n!==undefined&&o!=null){T(n,["_query","pageToken"],o)}if(S(e,["filter"])!==undefined){throw new Error("filter parameter is not supported in Gemini API.")}return t}function Kt(e,n){const t={};const i=S(e,["pageSize"]);if(n!==undefined&&i!=null){T(n,["_query","pageSize"],i)}const o=S(e,["pageToken"]);if(n!==undefined&&o!=null){T(n,["_query","pageToken"],o)}const r=S(e,["filter"]);if(n!==undefined&&r!=null){T(n,["_query","filter"],r)}return t}function zt(e){const n={};const t=S(e,["config"]);if(t!=null){Yt(t,n)}return n}function Xt(e){const n={};const t=S(e,["config"]);if(t!=null){Kt(t,n)}return n}function Qt(e){const n={};const t=S(e,["sdkHttpResponse"]);if(t!=null){T(n,["sdkHttpResponse"],t)}const i=S(e,["nextPageToken"]);if(i!=null){T(n,["nextPageToken"],i)}const o=S(e,["operations"]);if(o!=null){let e=o;if(Array.isArray(e)){e=e.map((e=>dt(e)))}T(n,["batchJobs"],e)}return n}function Zt(e){const n={};const t=S(e,["sdkHttpResponse"]);if(t!=null){T(n,["sdkHttpResponse"],t)}const i=S(e,["nextPageToken"]);if(i!=null){T(n,["nextPageToken"],i)}const o=S(e,["batchPredictionJobs"]);if(o!=null){let e=o;if(Array.isArray(e)){e=e.map((e=>pt(e)))}T(n,["batchJobs"],e)}return n}function ei(e){const n={};const t=S(e,["mediaResolution"]);if(t!=null){T(n,["mediaResolution"],t)}const i=S(e,["codeExecutionResult"]);if(i!=null){T(n,["codeExecutionResult"],i)}const o=S(e,["executableCode"]);if(o!=null){T(n,["executableCode"],o)}const r=S(e,["fileData"]);if(r!=null){T(n,["fileData"],Gt(r))}const s=S(e,["functionCall"]);if(s!=null){T(n,["functionCall"],xt(s))}const l=S(e,["functionResponse"]);if(l!=null){T(n,["functionResponse"],l)}const u=S(e,["inlineData"]);if(u!=null){T(n,["inlineData"],yt(u))}const a=S(e,["text"]);if(a!=null){T(n,["text"],a)}const c=S(e,["thought"]);if(c!=null){T(n,["thought"],c)}const f=S(e,["thoughtSignature"]);if(f!=null){T(n,["thoughtSignature"],f)}const d=S(e,["videoMetadata"]);if(d!=null){T(n,["videoMetadata"],d)}return n}function ni(e){const n={};const t=S(e,["category"]);if(t!=null){T(n,["category"],t)}if(S(e,["method"])!==undefined){throw new Error("method parameter is not supported in Gemini API.")}const i=S(e,["threshold"]);if(i!=null){T(n,["threshold"],i)}return n}function ti(e){const n={};const t=S(e,["retrievalConfig"]);if(t!=null){T(n,["retrievalConfig"],t)}const i=S(e,["functionCallingConfig"]);if(i!=null){T(n,["functionCallingConfig"],Lt(i))}return n}function ii(e){const n={};if(S(e,["retrieval"])!==undefined){throw new Error("retrieval parameter is not supported in Gemini API.")}const t=S(e,["computerUse"]);if(t!=null){T(n,["computerUse"],t)}const i=S(e,["fileSearch"]);if(i!=null){T(n,["fileSearch"],i)}const o=S(e,["googleSearch"]);if(o!=null){T(n,["googleSearch"],Jt(o))}const r=S(e,["codeExecution"]);if(r!=null){T(n,["codeExecution"],r)}if(S(e,["enterpriseWebSearch"])!==undefined){throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.")}const s=S(e,["functionDeclarations"]);if(s!=null){let e=s;if(Array.isArray(e)){e=e.map((e=>e))}T(n,["functionDeclarations"],e)}const l=S(e,["googleMaps"]);if(l!=null){T(n,["googleMaps"],$t(l))}const u=S(e,["googleSearchRetrieval"]);if(u!=null){T(n,["googleSearchRetrieval"],u)}const a=S(e,["urlContext"]);if(a!=null){T(n,["urlContext"],a)}const c=S(e,["mcpServers"]);if(c!=null){let e=c;if(Array.isArray(e)){e=e.map((e=>e))}T(n,["mcpServers"],e)}return n}
37
+ /**
38
+ * @license
39
+ * Copyright 2025 Google LLC
40
+ * SPDX-License-Identifier: Apache-2.0
41
+ */var oi;(function(e){e["PAGED_ITEM_BATCH_JOBS"]="batchJobs";e["PAGED_ITEM_MODELS"]="models";e["PAGED_ITEM_TUNING_JOBS"]="tuningJobs";e["PAGED_ITEM_FILES"]="files";e["PAGED_ITEM_CACHED_CONTENTS"]="cachedContents";e["PAGED_ITEM_FILE_SEARCH_STORES"]="fileSearchStores";e["PAGED_ITEM_DOCUMENTS"]="documents"})(oi||(oi={}));class ri{constructor(e,n,t,i){this.pageInternal=[];this.paramsInternal={};this.requestInternal=n;this.init(e,t,i)}init(e,n,t){var i,o;this.nameInternal=e;this.pageInternal=n[this.nameInternal]||[];this.sdkHttpResponseInternal=n===null||n===void 0?void 0:n.sdkHttpResponse;this.idxInternal=0;let r={config:{}};if(!t||Object.keys(t).length===0){r={config:{}}}else if(typeof t==="object"){r=Object.assign({},t)}else{r=t}if(r["config"]){r["config"]["pageToken"]=n["nextPageToken"]}this.paramsInternal=r;this.pageInternalSize=(o=(i=r["config"])===null||i===void 0?void 0:i["pageSize"])!==null&&o!==void 0?o:this.pageInternal.length}initNextPage(e){this.init(this.nameInternal,e,this.paramsInternal)}get page(){return this.pageInternal}get name(){return this.nameInternal}get pageSize(){return this.pageInternalSize}get sdkHttpResponse(){return this.sdkHttpResponseInternal}get params(){return this.paramsInternal}get pageLength(){return this.pageInternal.length}getItem(e){return this.pageInternal[e]}[Symbol.asyncIterator](){return{next:async()=>{if(this.idxInternal>=this.pageLength){if(this.hasNextPage()){await this.nextPage()}else{return{value:undefined,done:true}}}const e=this.getItem(this.idxInternal);this.idxInternal+=1;return{value:e,done:false}},return:async()=>({value:undefined,done:true})}}async nextPage(){if(!this.hasNextPage()){throw new Error("No more pages to fetch.")}const e=await this.requestInternal(this.params);this.initNextPage(e);return this.page}hasNextPage(){var e;if(((e=this.params["config"])===null||e===void 0?void 0:e["pageToken"])!==undefined){return true}return false}}
42
+ /**
43
+ * @license
44
+ * Copyright 2025 Google LLC
45
+ * SPDX-License-Identifier: Apache-2.0
46
+ */class si extends w{constructor(e){super();this.apiClient=e;this.list=async(e={})=>new ri(oi.PAGED_ITEM_BATCH_JOBS,(e=>this.listInternal(e)),await this.listInternal(e),e);this.create=async e=>{if(this.apiClient.isVertexAI()){e.config=this.formatDestination(e.src,e.config)}return this.createInternal(e)};this.createEmbeddings=async e=>{console.warn("batches.createEmbeddings() is experimental and may change without notice.");if(this.apiClient.isVertexAI()){throw new Error("Vertex AI does not support batches.createEmbeddings.")}return this.createEmbeddingsInternal(e)}}createInlinedGenerateContentRequest(e){const n=At(this.apiClient,e);const t=n["_url"];const i=b("{model}:batchGenerateContent",t);const o=n["batch"];const r=o["inputConfig"];const s=r["requests"];const l=s["requests"];const u=[];for(const e of l){const n=Object.assign({},e);if(n["systemInstruction"]){const e=n["systemInstruction"];delete n["systemInstruction"];const t=n["request"];t["systemInstruction"]=e;n["request"]=t}u.push(n)}s["requests"]=u;delete n["config"];delete n["_url"];delete n["_query"];return{path:i,body:n}}getGcsUri(e){if(typeof e==="string"){return e.startsWith("gs://")?e:undefined}if(!Array.isArray(e)&&e.gcsUri&&e.gcsUri.length>0){return e.gcsUri[0]}return undefined}getBigqueryUri(e){if(typeof e==="string"){return e.startsWith("bq://")?e:undefined}if(!Array.isArray(e)){return e.bigqueryUri}return undefined}formatDestination(e,n){const t=n?Object.assign({},n):{};const i=Date.now().toString();if(!t.displayName){t.displayName=`genaiBatchJob_${i}`}if(t.dest===undefined){const n=this.getGcsUri(e);const o=this.getBigqueryUri(e);if(n){if(n.endsWith(".jsonl")){t.dest=`${n.slice(0,-6)}/dest`}else{t.dest=`${n}_dest_${i}`}}else if(o){t.dest=`${o}_dest_${i}`}else{throw new Error("Unsupported source for Vertex AI: No GCS or BigQuery URI found.")}}return t}async createInternal(e){var n,t,i,o;let r;let s="";let l={};if(this.apiClient.isVertexAI()){const i=Ot(this.apiClient,e);s=b("batchPredictionJobs",i["_url"]);l=i["_query"];delete i["_url"];delete i["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(i),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json()));return r.then((e=>{const n=pt(e);return n}))}else{const n=At(this.apiClient,e);s=b("{model}:batchGenerateContent",n["_url"]);l=n["_query"];delete n["_url"];delete n["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(n),httpMethod:"POST",httpOptions:(i=e.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then((e=>e.json()));return r.then((e=>{const n=dt(e);return n}))}}async createEmbeddingsInternal(e){var n,t;let i;let o="";let r={};if(this.apiClient.isVertexAI()){throw new Error("This method is only supported by the Gemini Developer API.")}else{const s=_t(this.apiClient,e);o=b("{model}:asyncBatchEmbedContent",s["_url"]);r=s["_query"];delete s["_url"];delete s["_query"];i=this.apiClient.request({path:o,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json()));return i.then((e=>{const n=dt(e);return n}))}}async get(e){var n,t,i,o;let r;let s="";let l={};if(this.apiClient.isVertexAI()){const i=Ht(this.apiClient,e);s=b("batchPredictionJobs/{name}",i["_url"]);l=i["_query"];delete i["_url"];delete i["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(i),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json()));return r.then((e=>{const n=pt(e);return n}))}else{const n=qt(this.apiClient,e);s=b("batches/{name}",n["_url"]);l=n["_query"];delete n["_url"];delete n["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(n),httpMethod:"GET",httpOptions:(i=e.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then((e=>e.json()));return r.then((e=>{const n=dt(e);return n}))}}async cancel(e){var n,t,i,o;let r="";let s={};if(this.apiClient.isVertexAI()){const i=Et(this.apiClient,e);r=b("batchPredictionJobs/{name}:cancel",i["_url"]);s=i["_query"];delete i["_url"];delete i["_query"];await this.apiClient.request({path:r,queryParams:s,body:JSON.stringify(i),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal})}else{const n=vt(this.apiClient,e);r=b("batches/{name}:cancel",n["_url"]);s=n["_query"];delete n["_url"];delete n["_query"];await this.apiClient.request({path:r,queryParams:s,body:JSON.stringify(n),httpMethod:"POST",httpOptions:(i=e.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal})}}async listInternal(e){var n,t,i,o;let r;let s="";let l={};if(this.apiClient.isVertexAI()){const i=Xt(e);s=b("batchPredictionJobs",i["_url"]);l=i["_query"];delete i["_url"];delete i["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(i),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json().then((n=>{const t=n;t.sdkHttpResponse={headers:e.headers};return t}))));return r.then((e=>{const n=Zt(e);const t=new En;Object.assign(t,n);return t}))}else{const n=zt(e);s=b("batches",n["_url"]);l=n["_query"];delete n["_url"];delete n["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(n),httpMethod:"GET",httpOptions:(i=e.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then((e=>e.json().then((n=>{const t=n;t.sdkHttpResponse={headers:e.headers};return t}))));return r.then((e=>{const n=Qt(e);const t=new En;Object.assign(t,n);return t}))}}async delete(e){var n,t,i,o;let r;let s="";let l={};if(this.apiClient.isVertexAI()){const i=Rt(this.apiClient,e);s=b("batchPredictionJobs/{name}",i["_url"]);l=i["_query"];delete i["_url"];delete i["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(i),httpMethod:"DELETE",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json().then((n=>{const t=n;t.sdkHttpResponse={headers:e.headers};return t}))));return r.then((e=>{const n=Mt(e);return n}))}else{const n=Pt(this.apiClient,e);s=b("batches/{name}",n["_url"]);l=n["_query"];delete n["_url"];delete n["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(n),httpMethod:"DELETE",httpOptions:(i=e.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then((e=>e.json().then((n=>{const t=n;t.sdkHttpResponse={headers:e.headers};return t}))));return r.then((e=>{const n=Nt(e);return n}))}}}
47
+ /**
48
+ * @license
49
+ * Copyright 2025 Google LLC
50
+ * SPDX-License-Identifier: Apache-2.0
51
+ */function li(e){const n={};const t=S(e,["data"]);if(t!=null){T(n,["data"],t)}if(S(e,["displayName"])!==undefined){throw new Error("displayName parameter is not supported in Gemini API.")}const i=S(e,["mimeType"]);if(i!=null){T(n,["mimeType"],i)}return n}function ui(e){const n={};const t=S(e,["parts"]);if(t!=null){let e=t;if(Array.isArray(e)){e=e.map((e=>Ni(e)))}T(n,["parts"],e)}const i=S(e,["role"]);if(i!=null){T(n,["role"],i)}return n}function ai(e,n){const t={};const i=S(e,["ttl"]);if(n!==undefined&&i!=null){T(n,["ttl"],i)}const o=S(e,["expireTime"]);if(n!==undefined&&o!=null){T(n,["expireTime"],o)}const r=S(e,["displayName"]);if(n!==undefined&&r!=null){T(n,["displayName"],r)}const s=S(e,["contents"]);if(n!==undefined&&s!=null){let e=Gn(s);if(Array.isArray(e)){e=e.map((e=>ui(e)))}T(n,["contents"],e)}const l=S(e,["systemInstruction"]);if(n!==undefined&&l!=null){T(n,["systemInstruction"],ui(Un(l)))}const u=S(e,["tools"]);if(n!==undefined&&u!=null){let e=u;if(Array.isArray(e)){e=e.map((e=>Di(e)))}T(n,["tools"],e)}const a=S(e,["toolConfig"]);if(n!==undefined&&a!=null){T(n,["toolConfig"],Mi(a))}if(S(e,["kmsKeyName"])!==undefined){throw new Error("kmsKeyName parameter is not supported in Gemini API.")}return t}function ci(e,n){const t={};const i=S(e,["ttl"]);if(n!==undefined&&i!=null){T(n,["ttl"],i)}const o=S(e,["expireTime"]);if(n!==undefined&&o!=null){T(n,["expireTime"],o)}const r=S(e,["displayName"]);if(n!==undefined&&r!=null){T(n,["displayName"],r)}const s=S(e,["contents"]);if(n!==undefined&&s!=null){let e=Gn(s);if(Array.isArray(e)){e=e.map((e=>e))}T(n,["contents"],e)}const l=S(e,["systemInstruction"]);if(n!==undefined&&l!=null){T(n,["systemInstruction"],Un(l))}const u=S(e,["tools"]);if(n!==undefined&&u!=null){let e=u;if(Array.isArray(e)){e=e.map((e=>Ui(e)))}T(n,["tools"],e)}const a=S(e,["toolConfig"]);if(n!==undefined&&a!=null){T(n,["toolConfig"],a)}const c=S(e,["kmsKeyName"]);if(n!==undefined&&c!=null){T(n,["encryption_spec","kmsKeyName"],c)}return t}function fi(e,n){const t={};const i=S(n,["model"]);if(i!=null){T(t,["model"],In(e,i))}const o=S(n,["config"]);if(o!=null){ai(o,t)}return t}function di(e,n){const t={};const i=S(n,["model"]);if(i!=null){T(t,["model"],In(e,i))}const o=S(n,["config"]);if(o!=null){ci(o,t)}return t}function pi(e,n){const t={};const i=S(n,["name"]);if(i!=null){T(t,["_url","name"],Vn(e,i))}return t}function hi(e,n){const t={};const i=S(n,["name"]);if(i!=null){T(t,["_url","name"],Vn(e,i))}return t}function mi(e){const n={};const t=S(e,["sdkHttpResponse"]);if(t!=null){T(n,["sdkHttpResponse"],t)}return n}function gi(e){const n={};const t=S(e,["sdkHttpResponse"]);if(t!=null){T(n,["sdkHttpResponse"],t)}return n}function yi(e){const n={};if(S(e,["displayName"])!==undefined){throw new Error("displayName parameter is not supported in Gemini API.")}const t=S(e,["fileUri"]);if(t!=null){T(n,["fileUri"],t)}const i=S(e,["mimeType"]);if(i!=null){T(n,["mimeType"],i)}return n}function vi(e){const n={};const t=S(e,["id"]);if(t!=null){T(n,["id"],t)}const i=S(e,["args"]);if(i!=null){T(n,["args"],i)}const o=S(e,["name"]);if(o!=null){T(n,["name"],o)}if(S(e,["partialArgs"])!==undefined){throw new Error("partialArgs parameter is not supported in Gemini API.")}if(S(e,["willContinue"])!==undefined){throw new Error("willContinue parameter is not supported in Gemini API.")}return n}function Ei(e){const n={};const t=S(e,["allowedFunctionNames"]);if(t!=null){T(n,["allowedFunctionNames"],t)}const i=S(e,["mode"]);if(i!=null){T(n,["mode"],i)}if(S(e,["streamFunctionCallArguments"])!==undefined){throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.")}return n}function wi(e){const n={};const t=S(e,["description"]);if(t!=null){T(n,["description"],t)}const i=S(e,["name"]);if(i!=null){T(n,["name"],i)}const o=S(e,["parameters"]);if(o!=null){T(n,["parameters"],o)}const r=S(e,["parametersJsonSchema"]);if(r!=null){T(n,["parametersJsonSchema"],r)}const s=S(e,["response"]);if(s!=null){T(n,["response"],s)}const l=S(e,["responseJsonSchema"]);if(l!=null){T(n,["responseJsonSchema"],l)}if(S(e,["behavior"])!==undefined){throw new Error("behavior parameter is not supported in Vertex AI.")}return n}function bi(e,n){const t={};const i=S(n,["name"]);if(i!=null){T(t,["_url","name"],Vn(e,i))}return t}function Ti(e,n){const t={};const i=S(n,["name"]);if(i!=null){T(t,["_url","name"],Vn(e,i))}return t}function Si(e){const n={};if(S(e,["authConfig"])!==undefined){throw new Error("authConfig parameter is not supported in Gemini API.")}const t=S(e,["enableWidget"]);if(t!=null){T(n,["enableWidget"],t)}return n}function Ii(e){const n={};const t=S(e,["searchTypes"]);if(t!=null){T(n,["searchTypes"],t)}if(S(e,["excludeDomains"])!==undefined){throw new Error("excludeDomains parameter is not supported in Gemini API.")}if(S(e,["blockingConfidence"])!==undefined){throw new Error("blockingConfidence parameter is not supported in Gemini API.")}const i=S(e,["timeRangeFilter"]);if(i!=null){T(n,["timeRangeFilter"],i)}return n}function Ai(e,n){const t={};const i=S(e,["pageSize"]);if(n!==undefined&&i!=null){T(n,["_query","pageSize"],i)}const o=S(e,["pageToken"]);if(n!==undefined&&o!=null){T(n,["_query","pageToken"],o)}return t}function Oi(e,n){const t={};const i=S(e,["pageSize"]);if(n!==undefined&&i!=null){T(n,["_query","pageSize"],i)}const o=S(e,["pageToken"]);if(n!==undefined&&o!=null){T(n,["_query","pageToken"],o)}return t}function Ci(e){const n={};const t=S(e,["config"]);if(t!=null){Ai(t,n)}return n}function _i(e){const n={};const t=S(e,["config"]);if(t!=null){Oi(t,n)}return n}function Pi(e){const n={};const t=S(e,["sdkHttpResponse"]);if(t!=null){T(n,["sdkHttpResponse"],t)}const i=S(e,["nextPageToken"]);if(i!=null){T(n,["nextPageToken"],i)}const o=S(e,["cachedContents"]);if(o!=null){let e=o;if(Array.isArray(e)){e=e.map((e=>e))}T(n,["cachedContents"],e)}return n}function Ri(e){const n={};const t=S(e,["sdkHttpResponse"]);if(t!=null){T(n,["sdkHttpResponse"],t)}const i=S(e,["nextPageToken"]);if(i!=null){T(n,["nextPageToken"],i)}const o=S(e,["cachedContents"]);if(o!=null){let e=o;if(Array.isArray(e)){e=e.map((e=>e))}T(n,["cachedContents"],e)}return n}function Ni(e){const n={};const t=S(e,["mediaResolution"]);if(t!=null){T(n,["mediaResolution"],t)}const i=S(e,["codeExecutionResult"]);if(i!=null){T(n,["codeExecutionResult"],i)}const o=S(e,["executableCode"]);if(o!=null){T(n,["executableCode"],o)}const r=S(e,["fileData"]);if(r!=null){T(n,["fileData"],yi(r))}const s=S(e,["functionCall"]);if(s!=null){T(n,["functionCall"],vi(s))}const l=S(e,["functionResponse"]);if(l!=null){T(n,["functionResponse"],l)}const u=S(e,["inlineData"]);if(u!=null){T(n,["inlineData"],li(u))}const a=S(e,["text"]);if(a!=null){T(n,["text"],a)}const c=S(e,["thought"]);if(c!=null){T(n,["thought"],c)}const f=S(e,["thoughtSignature"]);if(f!=null){T(n,["thoughtSignature"],f)}const d=S(e,["videoMetadata"]);if(d!=null){T(n,["videoMetadata"],d)}return n}function Mi(e){const n={};const t=S(e,["retrievalConfig"]);if(t!=null){T(n,["retrievalConfig"],t)}const i=S(e,["functionCallingConfig"]);if(i!=null){T(n,["functionCallingConfig"],Ei(i))}return n}function Di(e){const n={};if(S(e,["retrieval"])!==undefined){throw new Error("retrieval parameter is not supported in Gemini API.")}const t=S(e,["computerUse"]);if(t!=null){T(n,["computerUse"],t)}const i=S(e,["fileSearch"]);if(i!=null){T(n,["fileSearch"],i)}const o=S(e,["googleSearch"]);if(o!=null){T(n,["googleSearch"],Ii(o))}const r=S(e,["codeExecution"]);if(r!=null){T(n,["codeExecution"],r)}if(S(e,["enterpriseWebSearch"])!==undefined){throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.")}const s=S(e,["functionDeclarations"]);if(s!=null){let e=s;if(Array.isArray(e)){e=e.map((e=>e))}T(n,["functionDeclarations"],e)}const l=S(e,["googleMaps"]);if(l!=null){T(n,["googleMaps"],Si(l))}const u=S(e,["googleSearchRetrieval"]);if(u!=null){T(n,["googleSearchRetrieval"],u)}const a=S(e,["urlContext"]);if(a!=null){T(n,["urlContext"],a)}const c=S(e,["mcpServers"]);if(c!=null){let e=c;if(Array.isArray(e)){e=e.map((e=>e))}T(n,["mcpServers"],e)}return n}function Ui(e){const n={};const t=S(e,["retrieval"]);if(t!=null){T(n,["retrieval"],t)}const i=S(e,["computerUse"]);if(i!=null){T(n,["computerUse"],i)}if(S(e,["fileSearch"])!==undefined){throw new Error("fileSearch parameter is not supported in Vertex AI.")}const o=S(e,["googleSearch"]);if(o!=null){T(n,["googleSearch"],o)}const r=S(e,["codeExecution"]);if(r!=null){T(n,["codeExecution"],r)}const s=S(e,["enterpriseWebSearch"]);if(s!=null){T(n,["enterpriseWebSearch"],s)}const l=S(e,["functionDeclarations"]);if(l!=null){let e=l;if(Array.isArray(e)){e=e.map((e=>wi(e)))}T(n,["functionDeclarations"],e)}const u=S(e,["googleMaps"]);if(u!=null){T(n,["googleMaps"],u)}const a=S(e,["googleSearchRetrieval"]);if(a!=null){T(n,["googleSearchRetrieval"],a)}const c=S(e,["urlContext"]);if(c!=null){T(n,["urlContext"],c)}if(S(e,["mcpServers"])!==undefined){throw new Error("mcpServers parameter is not supported in Vertex AI.")}return n}function ki(e,n){const t={};const i=S(e,["ttl"]);if(n!==undefined&&i!=null){T(n,["ttl"],i)}const o=S(e,["expireTime"]);if(n!==undefined&&o!=null){T(n,["expireTime"],o)}return t}function Gi(e,n){const t={};const i=S(e,["ttl"]);if(n!==undefined&&i!=null){T(n,["ttl"],i)}const o=S(e,["expireTime"]);if(n!==undefined&&o!=null){T(n,["expireTime"],o)}return t}function xi(e,n){const t={};const i=S(n,["name"]);if(i!=null){T(t,["_url","name"],Vn(e,i))}const o=S(n,["config"]);if(o!=null){ki(o,t)}return t}function Li(e,n){const t={};const i=S(n,["name"]);if(i!=null){T(t,["_url","name"],Vn(e,i))}const o=S(n,["config"]);if(o!=null){Gi(o,t)}return t}
52
+ /**
53
+ * @license
54
+ * Copyright 2025 Google LLC
55
+ * SPDX-License-Identifier: Apache-2.0
56
+ */class ji extends w{constructor(e){super();this.apiClient=e;this.list=async(e={})=>new ri(oi.PAGED_ITEM_CACHED_CONTENTS,(e=>this.listInternal(e)),await this.listInternal(e),e)}async create(e){var n,t,i,o;let r;let s="";let l={};if(this.apiClient.isVertexAI()){const i=di(this.apiClient,e);s=b("cachedContents",i["_url"]);l=i["_query"];delete i["_url"];delete i["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(i),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json()));return r.then((e=>e))}else{const n=fi(this.apiClient,e);s=b("cachedContents",n["_url"]);l=n["_query"];delete n["_url"];delete n["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(n),httpMethod:"POST",httpOptions:(i=e.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then((e=>e.json()));return r.then((e=>e))}}async get(e){var n,t,i,o;let r;let s="";let l={};if(this.apiClient.isVertexAI()){const i=Ti(this.apiClient,e);s=b("{name}",i["_url"]);l=i["_query"];delete i["_url"];delete i["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(i),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json()));return r.then((e=>e))}else{const n=bi(this.apiClient,e);s=b("{name}",n["_url"]);l=n["_query"];delete n["_url"];delete n["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(n),httpMethod:"GET",httpOptions:(i=e.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then((e=>e.json()));return r.then((e=>e))}}async delete(e){var n,t,i,o;let r;let s="";let l={};if(this.apiClient.isVertexAI()){const i=hi(this.apiClient,e);s=b("{name}",i["_url"]);l=i["_query"];delete i["_url"];delete i["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(i),httpMethod:"DELETE",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json().then((n=>{const t=n;t.sdkHttpResponse={headers:e.headers};return t}))));return r.then((e=>{const n=gi(e);const t=new an;Object.assign(t,n);return t}))}else{const n=pi(this.apiClient,e);s=b("{name}",n["_url"]);l=n["_query"];delete n["_url"];delete n["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(n),httpMethod:"DELETE",httpOptions:(i=e.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then((e=>e.json().then((n=>{const t=n;t.sdkHttpResponse={headers:e.headers};return t}))));return r.then((e=>{const n=mi(e);const t=new an;Object.assign(t,n);return t}))}}async update(e){var n,t,i,o;let r;let s="";let l={};if(this.apiClient.isVertexAI()){const i=Li(this.apiClient,e);s=b("{name}",i["_url"]);l=i["_query"];delete i["_url"];delete i["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(i),httpMethod:"PATCH",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json()));return r.then((e=>e))}else{const n=xi(this.apiClient,e);s=b("{name}",n["_url"]);l=n["_query"];delete n["_url"];delete n["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(n),httpMethod:"PATCH",httpOptions:(i=e.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then((e=>e.json()));return r.then((e=>e))}}async listInternal(e){var n,t,i,o;let r;let s="";let l={};if(this.apiClient.isVertexAI()){const i=_i(e);s=b("cachedContents",i["_url"]);l=i["_query"];delete i["_url"];delete i["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(i),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json().then((n=>{const t=n;t.sdkHttpResponse={headers:e.headers};return t}))));return r.then((e=>{const n=Ri(e);const t=new cn;Object.assign(t,n);return t}))}else{const n=Ci(e);s=b("cachedContents",n["_url"]);l=n["_query"];delete n["_url"];delete n["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(n),httpMethod:"GET",httpOptions:(i=e.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then((e=>e.json().then((n=>{const t=n;t.sdkHttpResponse={headers:e.headers};return t}))));return r.then((e=>{const n=Pi(e);const t=new cn;Object.assign(t,n);return t}))}}}function Fi(e,n){var t={};for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)&&n.indexOf(i)<0)t[i]=e[i];if(e!=null&&typeof Object.getOwnPropertySymbols==="function")for(var o=0,i=Object.getOwnPropertySymbols(e);o<i.length;o++){if(n.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o]))t[i[o]]=e[i[o]]}return t}function qi(e){var n=typeof Symbol==="function"&&Symbol.iterator,t=n&&e[n],i=0;if(t)return t.call(e);if(e&&typeof e.length==="number")return{next:function(){if(e&&i>=e.length)e=void 0;return{value:e&&e[i++],done:!e}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function Hi(e){return this instanceof Hi?(this.v=e,this):new Hi(e)}function $i(e,n,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=t.apply(e,n||[]),o,r=[];return o=Object.create((typeof AsyncIterator==="function"?AsyncIterator:Object).prototype),l("next"),l("throw"),l("return",s),o[Symbol.asyncIterator]=function(){return this},o;function s(e){return function(n){return Promise.resolve(n).then(e,f)}}function l(e,n){if(i[e]){o[e]=function(n){return new Promise((function(t,i){r.push([e,n,t,i])>1||u(e,n)}))};if(n)o[e]=n(o[e])}}function u(e,n){try{a(i[e](n))}catch(e){d(r[0][3],e)}}function a(e){e.value instanceof Hi?Promise.resolve(e.value.v).then(c,f):d(r[0][2],e)}function c(e){u("next",e)}function f(e){u("throw",e)}function d(e,n){if(e(n),r.shift(),r.length)u(r[0][0],r[0][1])}}function Ji(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=e[Symbol.asyncIterator],t;return n?n.call(e):(e=typeof qi==="function"?qi(e):e[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(n){t[n]=e[n]&&function(t){return new Promise((function(i,r){t=e[n](t),o(i,r,t.done,t.value)}))}}function o(e,n,t,i){Promise.resolve(i).then((function(n){e({value:n,done:t})}),n)}}typeof SuppressedError==="function"?SuppressedError:function(e,n,t){var i=new Error(t);return i.name="SuppressedError",i.error=e,i.suppressed=n,i};
57
+ /**
58
+ * @license
59
+ * Copyright 2025 Google LLC
60
+ * SPDX-License-Identifier: Apache-2.0
61
+ */function Vi(e){var n;if(e.candidates==undefined||e.candidates.length===0){return false}const t=(n=e.candidates[0])===null||n===void 0?void 0:n.content;if(t===undefined){return false}return Bi(t)}function Bi(e){if(e.parts===undefined||e.parts.length===0){return false}for(const n of e.parts){if(n===undefined||Object.keys(n).length===0){return false}}return true}function Wi(e){if(e.length===0){return}for(const n of e){if(n.role!=="user"&&n.role!=="model"){throw new Error(`Role must be user or model, but got ${n.role}.`)}}}function Yi(e){if(e===undefined||e.length===0){return[]}const n=[];const t=e.length;let i=0;while(i<t){if(e[i].role==="user"){n.push(e[i]);i++}else{const o=[];let r=true;while(i<t&&e[i].role==="model"){o.push(e[i]);if(r&&!Bi(e[i])){r=false}i++}if(r){n.push(...o)}else{n.pop()}}}return n}class Ki{constructor(e,n){this.modelsModule=e;this.apiClient=n}create(e){return new zi(this.apiClient,this.modelsModule,e.model,e.config,structuredClone(e.history))}}class zi{constructor(e,n,t,i={},o=[]){this.apiClient=e;this.modelsModule=n;this.model=t;this.config=i;this.history=o;this.sendPromise=Promise.resolve();Wi(o)}async sendMessage(e){var n;await this.sendPromise;const t=Un(e.message);const i=this.modelsModule.generateContent({model:this.model,contents:this.getHistory(true).concat(t),config:(n=e.config)!==null&&n!==void 0?n:this.config});this.sendPromise=(async()=>{var e,n,o;const r=await i;const s=(n=(e=r.candidates)===null||e===void 0?void 0:e[0])===null||n===void 0?void 0:n.content;const l=r.automaticFunctionCallingHistory;const u=this.getHistory(true).length;let a=[];if(l!=null){a=(o=l.slice(u))!==null&&o!==void 0?o:[]}const c=s?[s]:[];this.recordHistory(t,c,a);return})();await this.sendPromise.catch((()=>{this.sendPromise=Promise.resolve()}));return i}async sendMessageStream(e){var n;await this.sendPromise;const t=Un(e.message);const i=this.modelsModule.generateContentStream({model:this.model,contents:this.getHistory(true).concat(t),config:(n=e.config)!==null&&n!==void 0?n:this.config});this.sendPromise=i.then((()=>undefined)).catch((()=>undefined));const o=await i;const r=this.processStreamResponse(o,t);return r}getHistory(e=false){const n=e?Yi(this.history):this.history;return structuredClone(n)}processStreamResponse(e,n){return $i(this,arguments,(function*t(){var i,o,r,s;var l,u;const a=[];try{for(var c=true,f=Ji(e),d;d=yield Hi(f.next()),i=d.done,!i;c=true){s=d.value;c=false;const e=s;if(Vi(e)){const n=(u=(l=e.candidates)===null||l===void 0?void 0:l[0])===null||u===void 0?void 0:u.content;if(n!==undefined){a.push(n)}}yield yield Hi(e)}}catch(e){o={error:e}}finally{try{if(!c&&!i&&(r=f.return))yield Hi(r.call(f))}finally{if(o)throw o.error}}this.recordHistory(n,a)}))}recordHistory(e,n,t){let i=[];if(n.length>0&&n.every((e=>e.role!==undefined))){i=n}else{i.push({role:"model",parts:[]})}if(t&&t.length>0){this.history.push(...Yi(t))}else{this.history.push(e)}this.history.push(...i)}}
62
+ /**
63
+ * @license
64
+ * Copyright 2025 Google LLC
65
+ * SPDX-License-Identifier: Apache-2.0
66
+ */class Xi extends Error{constructor(e){super(e.message);this.name="ApiError";this.status=e.status;Object.setPrototypeOf(this,Xi.prototype)}}
67
+ /**
68
+ * @license
69
+ * Copyright 2025 Google LLC
70
+ * SPDX-License-Identifier: Apache-2.0
71
+ */function Qi(e){const n={};const t=S(e,["file"]);if(t!=null){T(n,["file"],t)}return n}function Zi(e){const n={};const t=S(e,["sdkHttpResponse"]);if(t!=null){T(n,["sdkHttpResponse"],t)}return n}function eo(e){const n={};const t=S(e,["name"]);if(t!=null){T(n,["_url","file"],Xn(t))}return n}function no(e){const n={};const t=S(e,["sdkHttpResponse"]);if(t!=null){T(n,["sdkHttpResponse"],t)}return n}function to(e){const n={};const t=S(e,["name"]);if(t!=null){T(n,["_url","file"],Xn(t))}return n}function io(e){const n={};const t=S(e,["uris"]);if(t!=null){T(n,["uris"],t)}return n}function oo(e,n){const t={};const i=S(e,["pageSize"]);if(n!==undefined&&i!=null){T(n,["_query","pageSize"],i)}const o=S(e,["pageToken"]);if(n!==undefined&&o!=null){T(n,["_query","pageToken"],o)}return t}function ro(e){const n={};const t=S(e,["config"]);if(t!=null){oo(t,n)}return n}function so(e){const n={};const t=S(e,["sdkHttpResponse"]);if(t!=null){T(n,["sdkHttpResponse"],t)}const i=S(e,["nextPageToken"]);if(i!=null){T(n,["nextPageToken"],i)}const o=S(e,["files"]);if(o!=null){let e=o;if(Array.isArray(e)){e=e.map((e=>e))}T(n,["files"],e)}return n}function lo(e){const n={};const t=S(e,["sdkHttpResponse"]);if(t!=null){T(n,["sdkHttpResponse"],t)}const i=S(e,["files"]);if(i!=null){let e=i;if(Array.isArray(e)){e=e.map((e=>e))}T(n,["files"],e)}return n}
72
+ /**
73
+ * @license
74
+ * Copyright 2025 Google LLC
75
+ * SPDX-License-Identifier: Apache-2.0
76
+ */class uo extends w{constructor(e){super();this.apiClient=e;this.list=async(e={})=>new ri(oi.PAGED_ITEM_FILES,(e=>this.listInternal(e)),await this.listInternal(e),e)}async upload(e){if(this.apiClient.isVertexAI()){throw new Error("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 new Error("registerFiles is only supported in Node.js environments.")}async _registerFiles(e){return this.registerFilesInternal(e)}async listInternal(e){var n,t;let i;let o="";let r={};if(this.apiClient.isVertexAI()){throw new Error("This method is only supported by the Gemini Developer API.")}else{const s=ro(e);o=b("files",s["_url"]);r=s["_query"];delete s["_url"];delete s["_query"];i=this.apiClient.request({path:o,queryParams:r,body:JSON.stringify(s),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json().then((n=>{const t=n;t.sdkHttpResponse={headers:e.headers};return t}))));return i.then((e=>{const n=so(e);const t=new mn;Object.assign(t,n);return t}))}}async createInternal(e){var n,t;let i;let o="";let r={};if(this.apiClient.isVertexAI()){throw new Error("This method is only supported by the Gemini Developer API.")}else{const s=Qi(e);o=b("upload/v1beta/files",s["_url"]);r=s["_query"];delete s["_url"];delete s["_query"];i=this.apiClient.request({path:o,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json()));return i.then((e=>{const n=Zi(e);const t=new gn;Object.assign(t,n);return t}))}}async get(e){var n,t;let i;let o="";let r={};if(this.apiClient.isVertexAI()){throw new Error("This method is only supported by the Gemini Developer API.")}else{const s=to(e);o=b("files/{file}",s["_url"]);r=s["_query"];delete s["_url"];delete s["_query"];i=this.apiClient.request({path:o,queryParams:r,body:JSON.stringify(s),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json()));return i.then((e=>e))}}async delete(e){var n,t;let i;let o="";let r={};if(this.apiClient.isVertexAI()){throw new Error("This method is only supported by the Gemini Developer API.")}else{const s=eo(e);o=b("files/{file}",s["_url"]);r=s["_query"];delete s["_url"];delete s["_query"];i=this.apiClient.request({path:o,queryParams:r,body:JSON.stringify(s),httpMethod:"DELETE",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json().then((n=>{const t=n;t.sdkHttpResponse={headers:e.headers};return t}))));return i.then((e=>{const n=no(e);const t=new yn;Object.assign(t,n);return t}))}}async registerFilesInternal(e){var n,t;let i;let o="";let r={};if(this.apiClient.isVertexAI()){throw new Error("This method is only supported by the Gemini Developer API.")}else{const s=io(e);o=b("files:register",s["_url"]);r=s["_query"];delete s["_url"];delete s["_query"];i=this.apiClient.request({path:o,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json()));return i.then((e=>{const n=lo(e);const t=new vn;Object.assign(t,n);return t}))}}}
77
+ /**
78
+ * @license
79
+ * Copyright 2025 Google LLC
80
+ * SPDX-License-Identifier: Apache-2.0
81
+ */function ao(e){const n={};const t=S(e,["data"]);if(t!=null){T(n,["data"],t)}if(S(e,["displayName"])!==undefined){throw new Error("displayName parameter is not supported in Gemini API.")}const i=S(e,["mimeType"]);if(i!=null){T(n,["mimeType"],i)}return n}function co(e){const n={};const t=S(e,["parts"]);if(t!=null){let e=t;if(Array.isArray(e)){e=e.map((e=>Co(e)))}T(n,["parts"],e)}const i=S(e,["role"]);if(i!=null){T(n,["role"],i)}return n}function fo(e){const n={};if(S(e,["displayName"])!==undefined){throw new Error("displayName parameter is not supported in Gemini API.")}const t=S(e,["fileUri"]);if(t!=null){T(n,["fileUri"],t)}const i=S(e,["mimeType"]);if(i!=null){T(n,["mimeType"],i)}return n}function po(e){const n={};const t=S(e,["id"]);if(t!=null){T(n,["id"],t)}const i=S(e,["args"]);if(i!=null){T(n,["args"],i)}const o=S(e,["name"]);if(o!=null){T(n,["name"],o)}if(S(e,["partialArgs"])!==undefined){throw new Error("partialArgs parameter is not supported in Gemini API.")}if(S(e,["willContinue"])!==undefined){throw new Error("willContinue parameter is not supported in Gemini API.")}return n}function ho(e){const n={};const t=S(e,["description"]);if(t!=null){T(n,["description"],t)}const i=S(e,["name"]);if(i!=null){T(n,["name"],i)}const o=S(e,["parameters"]);if(o!=null){T(n,["parameters"],o)}const r=S(e,["parametersJsonSchema"]);if(r!=null){T(n,["parametersJsonSchema"],r)}const s=S(e,["response"]);if(s!=null){T(n,["response"],s)}const l=S(e,["responseJsonSchema"]);if(l!=null){T(n,["responseJsonSchema"],l)}if(S(e,["behavior"])!==undefined){throw new Error("behavior parameter is not supported in Vertex AI.")}return n}function mo(e){const n={};const t=S(e,["modelSelectionConfig"]);if(t!=null){T(n,["modelConfig"],t)}const i=S(e,["responseJsonSchema"]);if(i!=null){T(n,["responseJsonSchema"],i)}const o=S(e,["audioTimestamp"]);if(o!=null){T(n,["audioTimestamp"],o)}const r=S(e,["candidateCount"]);if(r!=null){T(n,["candidateCount"],r)}const s=S(e,["enableAffectiveDialog"]);if(s!=null){T(n,["enableAffectiveDialog"],s)}const l=S(e,["frequencyPenalty"]);if(l!=null){T(n,["frequencyPenalty"],l)}const u=S(e,["logprobs"]);if(u!=null){T(n,["logprobs"],u)}const a=S(e,["maxOutputTokens"]);if(a!=null){T(n,["maxOutputTokens"],a)}const c=S(e,["mediaResolution"]);if(c!=null){T(n,["mediaResolution"],c)}const f=S(e,["presencePenalty"]);if(f!=null){T(n,["presencePenalty"],f)}const d=S(e,["responseLogprobs"]);if(d!=null){T(n,["responseLogprobs"],d)}const p=S(e,["responseMimeType"]);if(p!=null){T(n,["responseMimeType"],p)}const h=S(e,["responseModalities"]);if(h!=null){T(n,["responseModalities"],h)}const m=S(e,["responseSchema"]);if(m!=null){T(n,["responseSchema"],m)}const g=S(e,["routingConfig"]);if(g!=null){T(n,["routingConfig"],g)}const y=S(e,["seed"]);if(y!=null){T(n,["seed"],y)}const v=S(e,["speechConfig"]);if(v!=null){T(n,["speechConfig"],v)}const E=S(e,["stopSequences"]);if(E!=null){T(n,["stopSequences"],E)}const w=S(e,["temperature"]);if(w!=null){T(n,["temperature"],w)}const b=S(e,["thinkingConfig"]);if(b!=null){T(n,["thinkingConfig"],b)}const I=S(e,["topK"]);if(I!=null){T(n,["topK"],I)}const A=S(e,["topP"]);if(A!=null){T(n,["topP"],A)}if(S(e,["enableEnhancedCivicAnswers"])!==undefined){throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.")}return n}function go(e){const n={};if(S(e,["authConfig"])!==undefined){throw new Error("authConfig parameter is not supported in Gemini API.")}const t=S(e,["enableWidget"]);if(t!=null){T(n,["enableWidget"],t)}return n}function yo(e){const n={};const t=S(e,["searchTypes"]);if(t!=null){T(n,["searchTypes"],t)}if(S(e,["excludeDomains"])!==undefined){throw new Error("excludeDomains parameter is not supported in Gemini API.")}if(S(e,["blockingConfidence"])!==undefined){throw new Error("blockingConfidence parameter is not supported in Gemini API.")}const i=S(e,["timeRangeFilter"]);if(i!=null){T(n,["timeRangeFilter"],i)}return n}function vo(e,n){const t={};const i=S(e,["generationConfig"]);if(n!==undefined&&i!=null){T(n,["setup","generationConfig"],i)}const o=S(e,["responseModalities"]);if(n!==undefined&&o!=null){T(n,["setup","generationConfig","responseModalities"],o)}const r=S(e,["temperature"]);if(n!==undefined&&r!=null){T(n,["setup","generationConfig","temperature"],r)}const s=S(e,["topP"]);if(n!==undefined&&s!=null){T(n,["setup","generationConfig","topP"],s)}const l=S(e,["topK"]);if(n!==undefined&&l!=null){T(n,["setup","generationConfig","topK"],l)}const u=S(e,["maxOutputTokens"]);if(n!==undefined&&u!=null){T(n,["setup","generationConfig","maxOutputTokens"],u)}const a=S(e,["mediaResolution"]);if(n!==undefined&&a!=null){T(n,["setup","generationConfig","mediaResolution"],a)}const c=S(e,["seed"]);if(n!==undefined&&c!=null){T(n,["setup","generationConfig","seed"],c)}const f=S(e,["speechConfig"]);if(n!==undefined&&f!=null){T(n,["setup","generationConfig","speechConfig"],qn(f))}const d=S(e,["thinkingConfig"]);if(n!==undefined&&d!=null){T(n,["setup","generationConfig","thinkingConfig"],d)}const p=S(e,["enableAffectiveDialog"]);if(n!==undefined&&p!=null){T(n,["setup","generationConfig","enableAffectiveDialog"],p)}const h=S(e,["systemInstruction"]);if(n!==undefined&&h!=null){T(n,["setup","systemInstruction"],co(Un(h)))}const m=S(e,["tools"]);if(n!==undefined&&m!=null){let e=$n(m);if(Array.isArray(e)){e=e.map((e=>Po(Hn(e))))}T(n,["setup","tools"],e)}const g=S(e,["sessionResumption"]);if(n!==undefined&&g!=null){T(n,["setup","sessionResumption"],_o(g))}const y=S(e,["inputAudioTranscription"]);if(n!==undefined&&y!=null){T(n,["setup","inputAudioTranscription"],y)}const v=S(e,["outputAudioTranscription"]);if(n!==undefined&&v!=null){T(n,["setup","outputAudioTranscription"],v)}const E=S(e,["realtimeInputConfig"]);if(n!==undefined&&E!=null){T(n,["setup","realtimeInputConfig"],E)}const w=S(e,["contextWindowCompression"]);if(n!==undefined&&w!=null){T(n,["setup","contextWindowCompression"],w)}const b=S(e,["proactivity"]);if(n!==undefined&&b!=null){T(n,["setup","proactivity"],b)}if(S(e,["explicitVadSignal"])!==undefined){throw new Error("explicitVadSignal parameter is not supported in Gemini API.")}return t}function Eo(e,n){const t={};const i=S(e,["generationConfig"]);if(n!==undefined&&i!=null){T(n,["setup","generationConfig"],mo(i))}const o=S(e,["responseModalities"]);if(n!==undefined&&o!=null){T(n,["setup","generationConfig","responseModalities"],o)}const r=S(e,["temperature"]);if(n!==undefined&&r!=null){T(n,["setup","generationConfig","temperature"],r)}const s=S(e,["topP"]);if(n!==undefined&&s!=null){T(n,["setup","generationConfig","topP"],s)}const l=S(e,["topK"]);if(n!==undefined&&l!=null){T(n,["setup","generationConfig","topK"],l)}const u=S(e,["maxOutputTokens"]);if(n!==undefined&&u!=null){T(n,["setup","generationConfig","maxOutputTokens"],u)}const a=S(e,["mediaResolution"]);if(n!==undefined&&a!=null){T(n,["setup","generationConfig","mediaResolution"],a)}const c=S(e,["seed"]);if(n!==undefined&&c!=null){T(n,["setup","generationConfig","seed"],c)}const f=S(e,["speechConfig"]);if(n!==undefined&&f!=null){T(n,["setup","generationConfig","speechConfig"],qn(f))}const d=S(e,["thinkingConfig"]);if(n!==undefined&&d!=null){T(n,["setup","generationConfig","thinkingConfig"],d)}const p=S(e,["enableAffectiveDialog"]);if(n!==undefined&&p!=null){T(n,["setup","generationConfig","enableAffectiveDialog"],p)}const h=S(e,["systemInstruction"]);if(n!==undefined&&h!=null){T(n,["setup","systemInstruction"],Un(h))}const m=S(e,["tools"]);if(n!==undefined&&m!=null){let e=$n(m);if(Array.isArray(e)){e=e.map((e=>Ro(Hn(e))))}T(n,["setup","tools"],e)}const g=S(e,["sessionResumption"]);if(n!==undefined&&g!=null){T(n,["setup","sessionResumption"],g)}const y=S(e,["inputAudioTranscription"]);if(n!==undefined&&y!=null){T(n,["setup","inputAudioTranscription"],y)}const v=S(e,["outputAudioTranscription"]);if(n!==undefined&&v!=null){T(n,["setup","outputAudioTranscription"],v)}const E=S(e,["realtimeInputConfig"]);if(n!==undefined&&E!=null){T(n,["setup","realtimeInputConfig"],E)}const w=S(e,["contextWindowCompression"]);if(n!==undefined&&w!=null){T(n,["setup","contextWindowCompression"],w)}const b=S(e,["proactivity"]);if(n!==undefined&&b!=null){T(n,["setup","proactivity"],b)}const I=S(e,["explicitVadSignal"]);if(n!==undefined&&I!=null){T(n,["setup","explicitVadSignal"],I)}return t}function wo(e,n){const t={};const i=S(n,["model"]);if(i!=null){T(t,["setup","model"],Sn(e,i))}const o=S(n,["config"]);if(o!=null){T(t,["config"],vo(o,t))}return t}function bo(e,n){const t={};const i=S(n,["model"]);if(i!=null){T(t,["setup","model"],Sn(e,i))}const o=S(n,["config"]);if(o!=null){T(t,["config"],Eo(o,t))}return t}function To(e){const n={};const t=S(e,["musicGenerationConfig"]);if(t!=null){T(n,["musicGenerationConfig"],t)}return n}function So(e){const n={};const t=S(e,["weightedPrompts"]);if(t!=null){let e=t;if(Array.isArray(e)){e=e.map((e=>e))}T(n,["weightedPrompts"],e)}return n}function Io(e){const n={};const t=S(e,["media"]);if(t!=null){let e=An(t);if(Array.isArray(e)){e=e.map((e=>ao(e)))}T(n,["mediaChunks"],e)}const i=S(e,["audio"]);if(i!=null){T(n,["audio"],ao(_n(i)))}const o=S(e,["audioStreamEnd"]);if(o!=null){T(n,["audioStreamEnd"],o)}const r=S(e,["video"]);if(r!=null){T(n,["video"],ao(Cn(r)))}const s=S(e,["text"]);if(s!=null){T(n,["text"],s)}const l=S(e,["activityStart"]);if(l!=null){T(n,["activityStart"],l)}const u=S(e,["activityEnd"]);if(u!=null){T(n,["activityEnd"],u)}return n}function Ao(e){const n={};const t=S(e,["media"]);if(t!=null){let e=An(t);if(Array.isArray(e)){e=e.map((e=>e))}T(n,["mediaChunks"],e)}const i=S(e,["audio"]);if(i!=null){T(n,["audio"],_n(i))}const o=S(e,["audioStreamEnd"]);if(o!=null){T(n,["audioStreamEnd"],o)}const r=S(e,["video"]);if(r!=null){T(n,["video"],Cn(r))}const s=S(e,["text"]);if(s!=null){T(n,["text"],s)}const l=S(e,["activityStart"]);if(l!=null){T(n,["activityStart"],l)}const u=S(e,["activityEnd"]);if(u!=null){T(n,["activityEnd"],u)}return n}function Oo(e){const n={};const t=S(e,["setupComplete"]);if(t!=null){T(n,["setupComplete"],t)}const i=S(e,["serverContent"]);if(i!=null){T(n,["serverContent"],i)}const o=S(e,["toolCall"]);if(o!=null){T(n,["toolCall"],o)}const r=S(e,["toolCallCancellation"]);if(r!=null){T(n,["toolCallCancellation"],r)}const s=S(e,["usageMetadata"]);if(s!=null){T(n,["usageMetadata"],No(s))}const l=S(e,["goAway"]);if(l!=null){T(n,["goAway"],l)}const u=S(e,["sessionResumptionUpdate"]);if(u!=null){T(n,["sessionResumptionUpdate"],u)}const a=S(e,["voiceActivityDetectionSignal"]);if(a!=null){T(n,["voiceActivityDetectionSignal"],a)}const c=S(e,["voiceActivity"]);if(c!=null){T(n,["voiceActivity"],Mo(c))}return n}function Co(e){const n={};const t=S(e,["mediaResolution"]);if(t!=null){T(n,["mediaResolution"],t)}const i=S(e,["codeExecutionResult"]);if(i!=null){T(n,["codeExecutionResult"],i)}const o=S(e,["executableCode"]);if(o!=null){T(n,["executableCode"],o)}const r=S(e,["fileData"]);if(r!=null){T(n,["fileData"],fo(r))}const s=S(e,["functionCall"]);if(s!=null){T(n,["functionCall"],po(s))}const l=S(e,["functionResponse"]);if(l!=null){T(n,["functionResponse"],l)}const u=S(e,["inlineData"]);if(u!=null){T(n,["inlineData"],ao(u))}const a=S(e,["text"]);if(a!=null){T(n,["text"],a)}const c=S(e,["thought"]);if(c!=null){T(n,["thought"],c)}const f=S(e,["thoughtSignature"]);if(f!=null){T(n,["thoughtSignature"],f)}const d=S(e,["videoMetadata"]);if(d!=null){T(n,["videoMetadata"],d)}return n}function _o(e){const n={};const t=S(e,["handle"]);if(t!=null){T(n,["handle"],t)}if(S(e,["transparent"])!==undefined){throw new Error("transparent parameter is not supported in Gemini API.")}return n}function Po(e){const n={};if(S(e,["retrieval"])!==undefined){throw new Error("retrieval parameter is not supported in Gemini API.")}const t=S(e,["computerUse"]);if(t!=null){T(n,["computerUse"],t)}const i=S(e,["fileSearch"]);if(i!=null){T(n,["fileSearch"],i)}const o=S(e,["googleSearch"]);if(o!=null){T(n,["googleSearch"],yo(o))}const r=S(e,["codeExecution"]);if(r!=null){T(n,["codeExecution"],r)}if(S(e,["enterpriseWebSearch"])!==undefined){throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.")}const s=S(e,["functionDeclarations"]);if(s!=null){let e=s;if(Array.isArray(e)){e=e.map((e=>e))}T(n,["functionDeclarations"],e)}const l=S(e,["googleMaps"]);if(l!=null){T(n,["googleMaps"],go(l))}const u=S(e,["googleSearchRetrieval"]);if(u!=null){T(n,["googleSearchRetrieval"],u)}const a=S(e,["urlContext"]);if(a!=null){T(n,["urlContext"],a)}const c=S(e,["mcpServers"]);if(c!=null){let e=c;if(Array.isArray(e)){e=e.map((e=>e))}T(n,["mcpServers"],e)}return n}function Ro(e){const n={};const t=S(e,["retrieval"]);if(t!=null){T(n,["retrieval"],t)}const i=S(e,["computerUse"]);if(i!=null){T(n,["computerUse"],i)}if(S(e,["fileSearch"])!==undefined){throw new Error("fileSearch parameter is not supported in Vertex AI.")}const o=S(e,["googleSearch"]);if(o!=null){T(n,["googleSearch"],o)}const r=S(e,["codeExecution"]);if(r!=null){T(n,["codeExecution"],r)}const s=S(e,["enterpriseWebSearch"]);if(s!=null){T(n,["enterpriseWebSearch"],s)}const l=S(e,["functionDeclarations"]);if(l!=null){let e=l;if(Array.isArray(e)){e=e.map((e=>ho(e)))}T(n,["functionDeclarations"],e)}const u=S(e,["googleMaps"]);if(u!=null){T(n,["googleMaps"],u)}const a=S(e,["googleSearchRetrieval"]);if(a!=null){T(n,["googleSearchRetrieval"],a)}const c=S(e,["urlContext"]);if(c!=null){T(n,["urlContext"],c)}if(S(e,["mcpServers"])!==undefined){throw new Error("mcpServers parameter is not supported in Vertex AI.")}return n}function No(e){const n={};const t=S(e,["promptTokenCount"]);if(t!=null){T(n,["promptTokenCount"],t)}const i=S(e,["cachedContentTokenCount"]);if(i!=null){T(n,["cachedContentTokenCount"],i)}const o=S(e,["candidatesTokenCount"]);if(o!=null){T(n,["responseTokenCount"],o)}const r=S(e,["toolUsePromptTokenCount"]);if(r!=null){T(n,["toolUsePromptTokenCount"],r)}const s=S(e,["thoughtsTokenCount"]);if(s!=null){T(n,["thoughtsTokenCount"],s)}const l=S(e,["totalTokenCount"]);if(l!=null){T(n,["totalTokenCount"],l)}const u=S(e,["promptTokensDetails"]);if(u!=null){let e=u;if(Array.isArray(e)){e=e.map((e=>e))}T(n,["promptTokensDetails"],e)}const a=S(e,["cacheTokensDetails"]);if(a!=null){let e=a;if(Array.isArray(e)){e=e.map((e=>e))}T(n,["cacheTokensDetails"],e)}const c=S(e,["candidatesTokensDetails"]);if(c!=null){let e=c;if(Array.isArray(e)){e=e.map((e=>e))}T(n,["responseTokensDetails"],e)}const f=S(e,["toolUsePromptTokensDetails"]);if(f!=null){let e=f;if(Array.isArray(e)){e=e.map((e=>e))}T(n,["toolUsePromptTokensDetails"],e)}const d=S(e,["trafficType"]);if(d!=null){T(n,["trafficType"],d)}return n}function Mo(e){const n={};const t=S(e,["type"]);if(t!=null){T(n,["voiceActivityType"],t)}return n}
82
+ /**
83
+ * @license
84
+ * Copyright 2025 Google LLC
85
+ * SPDX-License-Identifier: Apache-2.0
86
+ */function Do(e,n){const t={};const i=S(e,["data"]);if(i!=null){T(t,["data"],i)}if(S(e,["displayName"])!==undefined){throw new Error("displayName parameter is not supported in Gemini API.")}const o=S(e,["mimeType"]);if(o!=null){T(t,["mimeType"],o)}return t}function Uo(e,n){const t={};const i=S(e,["content"]);if(i!=null){T(t,["content"],i)}const o=S(e,["citationMetadata"]);if(o!=null){T(t,["citationMetadata"],ko(o))}const r=S(e,["tokenCount"]);if(r!=null){T(t,["tokenCount"],r)}const s=S(e,["finishReason"]);if(s!=null){T(t,["finishReason"],s)}const l=S(e,["groundingMetadata"]);if(l!=null){T(t,["groundingMetadata"],l)}const u=S(e,["avgLogprobs"]);if(u!=null){T(t,["avgLogprobs"],u)}const a=S(e,["index"]);if(a!=null){T(t,["index"],a)}const c=S(e,["logprobsResult"]);if(c!=null){T(t,["logprobsResult"],c)}const f=S(e,["safetyRatings"]);if(f!=null){let e=f;if(Array.isArray(e)){e=e.map((e=>e))}T(t,["safetyRatings"],e)}const d=S(e,["urlContextMetadata"]);if(d!=null){T(t,["urlContextMetadata"],d)}return t}function ko(e,n){const t={};const i=S(e,["citationSources"]);if(i!=null){let e=i;if(Array.isArray(e)){e=e.map((e=>e))}T(t,["citations"],e)}return t}function Go(e,n,t){const i={};const o=S(n,["model"]);if(o!=null){T(i,["_url","model"],Sn(e,o))}const r=S(n,["contents"]);if(r!=null){let e=Gn(r);if(Array.isArray(e)){e=e.map((e=>e))}T(i,["contents"],e)}return i}function xo(e,n){const t={};const i=S(e,["sdkHttpResponse"]);if(i!=null){T(t,["sdkHttpResponse"],i)}const o=S(e,["tokensInfo"]);if(o!=null){let e=o;if(Array.isArray(e)){e=e.map((e=>e))}T(t,["tokensInfo"],e)}return t}function Lo(e,n){const t={};const i=S(e,["values"]);if(i!=null){T(t,["values"],i)}const o=S(e,["statistics"]);if(o!=null){T(t,["statistics"],jo(o))}return t}function jo(e,n){const t={};const i=S(e,["truncated"]);if(i!=null){T(t,["truncated"],i)}const o=S(e,["token_count"]);if(o!=null){T(t,["tokenCount"],o)}return t}function Fo(e,n){const t={};const i=S(e,["parts"]);if(i!=null){let e=i;if(Array.isArray(e)){e=e.map((e=>rs(e)))}T(t,["parts"],e)}const o=S(e,["role"]);if(o!=null){T(t,["role"],o)}return t}function qo(e,n){const t={};const i=S(e,["controlType"]);if(i!=null){T(t,["controlType"],i)}const o=S(e,["enableControlImageComputation"]);if(o!=null){T(t,["computeControl"],o)}return t}function Ho(e,n){const t={};if(S(e,["systemInstruction"])!==undefined){throw new Error("systemInstruction parameter is not supported in Gemini API.")}if(S(e,["tools"])!==undefined){throw new Error("tools parameter is not supported in Gemini API.")}if(S(e,["generationConfig"])!==undefined){throw new Error("generationConfig parameter is not supported in Gemini API.")}return t}function $o(e,n,t){const i={};const o=S(e,["systemInstruction"]);if(n!==undefined&&o!=null){T(n,["systemInstruction"],Un(o))}const r=S(e,["tools"]);if(n!==undefined&&r!=null){let e=r;if(Array.isArray(e)){e=e.map((e=>Ts(e)))}T(n,["tools"],e)}const s=S(e,["generationConfig"]);if(n!==undefined&&s!=null){T(n,["generationConfig"],jr(s))}return i}function Jo(e,n,t){const i={};const o=S(n,["model"]);if(o!=null){T(i,["_url","model"],Sn(e,o))}const r=S(n,["contents"]);if(r!=null){let e=Gn(r);if(Array.isArray(e)){e=e.map((e=>Fo(e)))}T(i,["contents"],e)}const s=S(n,["config"]);if(s!=null){Ho(s)}return i}function Vo(e,n,t){const i={};const o=S(n,["model"]);if(o!=null){T(i,["_url","model"],Sn(e,o))}const r=S(n,["contents"]);if(r!=null){let e=Gn(r);if(Array.isArray(e)){e=e.map((e=>e))}T(i,["contents"],e)}const s=S(n,["config"]);if(s!=null){$o(s,i)}return i}function Bo(e,n){const t={};const i=S(e,["sdkHttpResponse"]);if(i!=null){T(t,["sdkHttpResponse"],i)}const o=S(e,["totalTokens"]);if(o!=null){T(t,["totalTokens"],o)}const r=S(e,["cachedContentTokenCount"]);if(r!=null){T(t,["cachedContentTokenCount"],r)}return t}function Wo(e,n){const t={};const i=S(e,["sdkHttpResponse"]);if(i!=null){T(t,["sdkHttpResponse"],i)}const o=S(e,["totalTokens"]);if(o!=null){T(t,["totalTokens"],o)}return t}function Yo(e,n,t){const i={};const o=S(n,["model"]);if(o!=null){T(i,["_url","name"],Sn(e,o))}return i}function Ko(e,n,t){const i={};const o=S(n,["model"]);if(o!=null){T(i,["_url","name"],Sn(e,o))}return i}function zo(e,n){const t={};const i=S(e,["sdkHttpResponse"]);if(i!=null){T(t,["sdkHttpResponse"],i)}return t}function Xo(e,n){const t={};const i=S(e,["sdkHttpResponse"]);if(i!=null){T(t,["sdkHttpResponse"],i)}return t}function Qo(e,n,t){const i={};const o=S(e,["outputGcsUri"]);if(n!==undefined&&o!=null){T(n,["parameters","storageUri"],o)}const r=S(e,["negativePrompt"]);if(n!==undefined&&r!=null){T(n,["parameters","negativePrompt"],r)}const s=S(e,["numberOfImages"]);if(n!==undefined&&s!=null){T(n,["parameters","sampleCount"],s)}const l=S(e,["aspectRatio"]);if(n!==undefined&&l!=null){T(n,["parameters","aspectRatio"],l)}const u=S(e,["guidanceScale"]);if(n!==undefined&&u!=null){T(n,["parameters","guidanceScale"],u)}const a=S(e,["seed"]);if(n!==undefined&&a!=null){T(n,["parameters","seed"],a)}const c=S(e,["safetyFilterLevel"]);if(n!==undefined&&c!=null){T(n,["parameters","safetySetting"],c)}const f=S(e,["personGeneration"]);if(n!==undefined&&f!=null){T(n,["parameters","personGeneration"],f)}const d=S(e,["includeSafetyAttributes"]);if(n!==undefined&&d!=null){T(n,["parameters","includeSafetyAttributes"],d)}const p=S(e,["includeRaiReason"]);if(n!==undefined&&p!=null){T(n,["parameters","includeRaiReason"],p)}const h=S(e,["language"]);if(n!==undefined&&h!=null){T(n,["parameters","language"],h)}const m=S(e,["outputMimeType"]);if(n!==undefined&&m!=null){T(n,["parameters","outputOptions","mimeType"],m)}const g=S(e,["outputCompressionQuality"]);if(n!==undefined&&g!=null){T(n,["parameters","outputOptions","compressionQuality"],g)}const y=S(e,["addWatermark"]);if(n!==undefined&&y!=null){T(n,["parameters","addWatermark"],y)}const v=S(e,["labels"]);if(n!==undefined&&v!=null){T(n,["labels"],v)}const E=S(e,["editMode"]);if(n!==undefined&&E!=null){T(n,["parameters","editMode"],E)}const w=S(e,["baseSteps"]);if(n!==undefined&&w!=null){T(n,["parameters","editConfig","baseSteps"],w)}return i}function Zo(e,n,t){const i={};const o=S(n,["model"]);if(o!=null){T(i,["_url","model"],Sn(e,o))}const r=S(n,["prompt"]);if(r!=null){T(i,["instances[0]","prompt"],r)}const s=S(n,["referenceImages"]);if(s!=null){let e=s;if(Array.isArray(e)){e=e.map((e=>fs(e)))}T(i,["instances[0]","referenceImages"],e)}const l=S(n,["config"]);if(l!=null){Qo(l,i)}return i}function er(e,n){const t={};const i=S(e,["sdkHttpResponse"]);if(i!=null){T(t,["sdkHttpResponse"],i)}const o=S(e,["predictions"]);if(o!=null){let e=o;if(Array.isArray(e)){e=e.map((e=>kr(e)))}T(t,["generatedImages"],e)}return t}function nr(e,n,t){const i={};const o=S(e,["taskType"]);if(n!==undefined&&o!=null){T(n,["requests[]","taskType"],o)}const r=S(e,["title"]);if(n!==undefined&&r!=null){T(n,["requests[]","title"],r)}const s=S(e,["outputDimensionality"]);if(n!==undefined&&s!=null){T(n,["requests[]","outputDimensionality"],s)}if(S(e,["mimeType"])!==undefined){throw new Error("mimeType parameter is not supported in Gemini API.")}if(S(e,["autoTruncate"])!==undefined){throw new Error("autoTruncate parameter is not supported in Gemini API.")}return i}function tr(e,n,t){const i={};let o=S(t,["embeddingApiType"]);if(o===undefined){o="PREDICT"}if(o==="PREDICT"){const t=S(e,["taskType"]);if(n!==undefined&&t!=null){T(n,["instances[]","task_type"],t)}}else if(o==="EMBED_CONTENT"){const t=S(e,["taskType"]);if(n!==undefined&&t!=null){T(n,["taskType"],t)}}let r=S(t,["embeddingApiType"]);if(r===undefined){r="PREDICT"}if(r==="PREDICT"){const t=S(e,["title"]);if(n!==undefined&&t!=null){T(n,["instances[]","title"],t)}}else if(r==="EMBED_CONTENT"){const t=S(e,["title"]);if(n!==undefined&&t!=null){T(n,["title"],t)}}let s=S(t,["embeddingApiType"]);if(s===undefined){s="PREDICT"}if(s==="PREDICT"){const t=S(e,["outputDimensionality"]);if(n!==undefined&&t!=null){T(n,["parameters","outputDimensionality"],t)}}else if(s==="EMBED_CONTENT"){const t=S(e,["outputDimensionality"]);if(n!==undefined&&t!=null){T(n,["outputDimensionality"],t)}}let l=S(t,["embeddingApiType"]);if(l===undefined){l="PREDICT"}if(l==="PREDICT"){const t=S(e,["mimeType"]);if(n!==undefined&&t!=null){T(n,["instances[]","mimeType"],t)}}let u=S(t,["embeddingApiType"]);if(u===undefined){u="PREDICT"}if(u==="PREDICT"){const t=S(e,["autoTruncate"]);if(n!==undefined&&t!=null){T(n,["parameters","autoTruncate"],t)}}else if(u==="EMBED_CONTENT"){const t=S(e,["autoTruncate"]);if(n!==undefined&&t!=null){T(n,["autoTruncate"],t)}}return i}function ir(e,n,t){const i={};const o=S(n,["model"]);if(o!=null){T(i,["_url","model"],Sn(e,o))}const r=S(n,["contents"]);if(r!=null){let n=kn(e,r);if(Array.isArray(n)){n=n.map((e=>e))}T(i,["requests[]","content"],n)}const s=S(n,["content"]);if(s!=null){Fo(Un(s))}const l=S(n,["config"]);if(l!=null){nr(l,i)}const u=S(n,["model"]);if(u!==undefined){T(i,["requests[]","model"],Sn(e,u))}return i}function or(e,n,t){const i={};const o=S(n,["model"]);if(o!=null){T(i,["_url","model"],Sn(e,o))}let r=S(t,["embeddingApiType"]);if(r===undefined){r="PREDICT"}if(r==="PREDICT"){const t=S(n,["contents"]);if(t!=null){let n=kn(e,t);if(Array.isArray(n)){n=n.map((e=>e))}T(i,["instances[]","content"],n)}}let s=S(t,["embeddingApiType"]);if(s===undefined){s="PREDICT"}if(s==="EMBED_CONTENT"){const e=S(n,["content"]);if(e!=null){T(i,["content"],Un(e))}}const l=S(n,["config"]);if(l!=null){tr(l,i,t)}return i}function rr(e,n){const t={};const i=S(e,["sdkHttpResponse"]);if(i!=null){T(t,["sdkHttpResponse"],i)}const o=S(e,["embeddings"]);if(o!=null){let e=o;if(Array.isArray(e)){e=e.map((e=>e))}T(t,["embeddings"],e)}const r=S(e,["metadata"]);if(r!=null){T(t,["metadata"],r)}return t}function sr(e,n){const t={};const i=S(e,["sdkHttpResponse"]);if(i!=null){T(t,["sdkHttpResponse"],i)}const o=S(e,["predictions[]","embeddings"]);if(o!=null){let e=o;if(Array.isArray(e)){e=e.map((e=>Lo(e)))}T(t,["embeddings"],e)}const r=S(e,["metadata"]);if(r!=null){T(t,["metadata"],r)}if(n&&S(n,["embeddingApiType"])==="EMBED_CONTENT"){const n=S(e,["embedding"]);const i=S(e,["usageMetadata"]);const o=S(e,["truncated"]);if(n){const e={};if(i&&i["promptTokenCount"]){e.tokenCount=i["promptTokenCount"]}if(o){e.truncated=o}n.statistics=e;T(t,["embeddings"],[n])}}return t}function lr(e,n){const t={};const i=S(e,["endpoint"]);if(i!=null){T(t,["name"],i)}const o=S(e,["deployedModelId"]);if(o!=null){T(t,["deployedModelId"],o)}return t}function ur(e,n){const t={};if(S(e,["displayName"])!==undefined){throw new Error("displayName parameter is not supported in Gemini API.")}const i=S(e,["fileUri"]);if(i!=null){T(t,["fileUri"],i)}const o=S(e,["mimeType"]);if(o!=null){T(t,["mimeType"],o)}return t}function ar(e,n){const t={};const i=S(e,["id"]);if(i!=null){T(t,["id"],i)}const o=S(e,["args"]);if(o!=null){T(t,["args"],o)}const r=S(e,["name"]);if(r!=null){T(t,["name"],r)}if(S(e,["partialArgs"])!==undefined){throw new Error("partialArgs parameter is not supported in Gemini API.")}if(S(e,["willContinue"])!==undefined){throw new Error("willContinue parameter is not supported in Gemini API.")}return t}function cr(e,n){const t={};const i=S(e,["allowedFunctionNames"]);if(i!=null){T(t,["allowedFunctionNames"],i)}const o=S(e,["mode"]);if(o!=null){T(t,["mode"],o)}if(S(e,["streamFunctionCallArguments"])!==undefined){throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.")}return t}function fr(e,n){const t={};const i=S(e,["description"]);if(i!=null){T(t,["description"],i)}const o=S(e,["name"]);if(o!=null){T(t,["name"],o)}const r=S(e,["parameters"]);if(r!=null){T(t,["parameters"],r)}const s=S(e,["parametersJsonSchema"]);if(s!=null){T(t,["parametersJsonSchema"],s)}const l=S(e,["response"]);if(l!=null){T(t,["response"],l)}const u=S(e,["responseJsonSchema"]);if(u!=null){T(t,["responseJsonSchema"],u)}if(S(e,["behavior"])!==undefined){throw new Error("behavior parameter is not supported in Vertex AI.")}return t}function dr(e,n,t,i){const o={};const r=S(n,["systemInstruction"]);if(t!==undefined&&r!=null){T(t,["systemInstruction"],Fo(Un(r)))}const s=S(n,["temperature"]);if(s!=null){T(o,["temperature"],s)}const l=S(n,["topP"]);if(l!=null){T(o,["topP"],l)}const u=S(n,["topK"]);if(u!=null){T(o,["topK"],u)}const a=S(n,["candidateCount"]);if(a!=null){T(o,["candidateCount"],a)}const c=S(n,["maxOutputTokens"]);if(c!=null){T(o,["maxOutputTokens"],c)}const f=S(n,["stopSequences"]);if(f!=null){T(o,["stopSequences"],f)}const d=S(n,["responseLogprobs"]);if(d!=null){T(o,["responseLogprobs"],d)}const p=S(n,["logprobs"]);if(p!=null){T(o,["logprobs"],p)}const h=S(n,["presencePenalty"]);if(h!=null){T(o,["presencePenalty"],h)}const m=S(n,["frequencyPenalty"]);if(m!=null){T(o,["frequencyPenalty"],m)}const g=S(n,["seed"]);if(g!=null){T(o,["seed"],g)}const y=S(n,["responseMimeType"]);if(y!=null){T(o,["responseMimeType"],y)}const v=S(n,["responseSchema"]);if(v!=null){T(o,["responseSchema"],jn(v))}const E=S(n,["responseJsonSchema"]);if(E!=null){T(o,["responseJsonSchema"],E)}if(S(n,["routingConfig"])!==undefined){throw new Error("routingConfig parameter is not supported in Gemini API.")}if(S(n,["modelSelectionConfig"])!==undefined){throw new Error("modelSelectionConfig parameter is not supported in Gemini API.")}const w=S(n,["safetySettings"]);if(t!==undefined&&w!=null){let e=w;if(Array.isArray(e)){e=e.map((e=>hs(e)))}T(t,["safetySettings"],e)}const b=S(n,["tools"]);if(t!==undefined&&b!=null){let e=$n(b);if(Array.isArray(e)){e=e.map((e=>bs(Hn(e))))}T(t,["tools"],e)}const I=S(n,["toolConfig"]);if(t!==undefined&&I!=null){T(t,["toolConfig"],ws(I))}if(S(n,["labels"])!==undefined){throw new Error("labels parameter is not supported in Gemini API.")}const A=S(n,["cachedContent"]);if(t!==undefined&&A!=null){T(t,["cachedContent"],Vn(e,A))}const O=S(n,["responseModalities"]);if(O!=null){T(o,["responseModalities"],O)}const C=S(n,["mediaResolution"]);if(C!=null){T(o,["mediaResolution"],C)}const _=S(n,["speechConfig"]);if(_!=null){T(o,["speechConfig"],Fn(_))}if(S(n,["audioTimestamp"])!==undefined){throw new Error("audioTimestamp parameter is not supported in Gemini API.")}const P=S(n,["thinkingConfig"]);if(P!=null){T(o,["thinkingConfig"],P)}const R=S(n,["imageConfig"]);if(R!=null){T(o,["imageConfig"],Jr(R))}const N=S(n,["enableEnhancedCivicAnswers"]);if(N!=null){T(o,["enableEnhancedCivicAnswers"],N)}if(S(n,["modelArmorConfig"])!==undefined){throw new Error("modelArmorConfig parameter is not supported in Gemini API.")}return o}function pr(e,n,t,i){const o={};const r=S(n,["systemInstruction"]);if(t!==undefined&&r!=null){T(t,["systemInstruction"],Un(r))}const s=S(n,["temperature"]);if(s!=null){T(o,["temperature"],s)}const l=S(n,["topP"]);if(l!=null){T(o,["topP"],l)}const u=S(n,["topK"]);if(u!=null){T(o,["topK"],u)}const a=S(n,["candidateCount"]);if(a!=null){T(o,["candidateCount"],a)}const c=S(n,["maxOutputTokens"]);if(c!=null){T(o,["maxOutputTokens"],c)}const f=S(n,["stopSequences"]);if(f!=null){T(o,["stopSequences"],f)}const d=S(n,["responseLogprobs"]);if(d!=null){T(o,["responseLogprobs"],d)}const p=S(n,["logprobs"]);if(p!=null){T(o,["logprobs"],p)}const h=S(n,["presencePenalty"]);if(h!=null){T(o,["presencePenalty"],h)}const m=S(n,["frequencyPenalty"]);if(m!=null){T(o,["frequencyPenalty"],m)}const g=S(n,["seed"]);if(g!=null){T(o,["seed"],g)}const y=S(n,["responseMimeType"]);if(y!=null){T(o,["responseMimeType"],y)}const v=S(n,["responseSchema"]);if(v!=null){T(o,["responseSchema"],jn(v))}const E=S(n,["responseJsonSchema"]);if(E!=null){T(o,["responseJsonSchema"],E)}const w=S(n,["routingConfig"]);if(w!=null){T(o,["routingConfig"],w)}const b=S(n,["modelSelectionConfig"]);if(b!=null){T(o,["modelConfig"],b)}const I=S(n,["safetySettings"]);if(t!==undefined&&I!=null){let e=I;if(Array.isArray(e)){e=e.map((e=>e))}T(t,["safetySettings"],e)}const A=S(n,["tools"]);if(t!==undefined&&A!=null){let e=$n(A);if(Array.isArray(e)){e=e.map((e=>Ts(Hn(e))))}T(t,["tools"],e)}const O=S(n,["toolConfig"]);if(t!==undefined&&O!=null){T(t,["toolConfig"],O)}const C=S(n,["labels"]);if(t!==undefined&&C!=null){T(t,["labels"],C)}const _=S(n,["cachedContent"]);if(t!==undefined&&_!=null){T(t,["cachedContent"],Vn(e,_))}const P=S(n,["responseModalities"]);if(P!=null){T(o,["responseModalities"],P)}const R=S(n,["mediaResolution"]);if(R!=null){T(o,["mediaResolution"],R)}const N=S(n,["speechConfig"]);if(N!=null){T(o,["speechConfig"],Fn(N))}const M=S(n,["audioTimestamp"]);if(M!=null){T(o,["audioTimestamp"],M)}const D=S(n,["thinkingConfig"]);if(D!=null){T(o,["thinkingConfig"],D)}const U=S(n,["imageConfig"]);if(U!=null){T(o,["imageConfig"],Vr(U))}if(S(n,["enableEnhancedCivicAnswers"])!==undefined){throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.")}const k=S(n,["modelArmorConfig"]);if(t!==undefined&&k!=null){T(t,["modelArmorConfig"],k)}return o}function hr(e,n,t){const i={};const o=S(n,["model"]);if(o!=null){T(i,["_url","model"],Sn(e,o))}const r=S(n,["contents"]);if(r!=null){let e=Gn(r);if(Array.isArray(e)){e=e.map((e=>Fo(e)))}T(i,["contents"],e)}const s=S(n,["config"]);if(s!=null){T(i,["generationConfig"],dr(e,s,i))}return i}function mr(e,n,t){const i={};const o=S(n,["model"]);if(o!=null){T(i,["_url","model"],Sn(e,o))}const r=S(n,["contents"]);if(r!=null){let e=Gn(r);if(Array.isArray(e)){e=e.map((e=>e))}T(i,["contents"],e)}const s=S(n,["config"]);if(s!=null){T(i,["generationConfig"],pr(e,s,i))}return i}function gr(e,n){const t={};const i=S(e,["sdkHttpResponse"]);if(i!=null){T(t,["sdkHttpResponse"],i)}const o=S(e,["candidates"]);if(o!=null){let e=o;if(Array.isArray(e)){e=e.map((e=>Uo(e)))}T(t,["candidates"],e)}const r=S(e,["modelVersion"]);if(r!=null){T(t,["modelVersion"],r)}const s=S(e,["promptFeedback"]);if(s!=null){T(t,["promptFeedback"],s)}const l=S(e,["responseId"]);if(l!=null){T(t,["responseId"],l)}const u=S(e,["usageMetadata"]);if(u!=null){T(t,["usageMetadata"],u)}return t}function yr(e,n){const t={};const i=S(e,["sdkHttpResponse"]);if(i!=null){T(t,["sdkHttpResponse"],i)}const o=S(e,["candidates"]);if(o!=null){let e=o;if(Array.isArray(e)){e=e.map((e=>e))}T(t,["candidates"],e)}const r=S(e,["createTime"]);if(r!=null){T(t,["createTime"],r)}const s=S(e,["modelVersion"]);if(s!=null){T(t,["modelVersion"],s)}const l=S(e,["promptFeedback"]);if(l!=null){T(t,["promptFeedback"],l)}const u=S(e,["responseId"]);if(u!=null){T(t,["responseId"],u)}const a=S(e,["usageMetadata"]);if(a!=null){T(t,["usageMetadata"],a)}return t}function vr(e,n,t){const i={};if(S(e,["outputGcsUri"])!==undefined){throw new Error("outputGcsUri parameter is not supported in Gemini API.")}if(S(e,["negativePrompt"])!==undefined){throw new Error("negativePrompt parameter is not supported in Gemini API.")}const o=S(e,["numberOfImages"]);if(n!==undefined&&o!=null){T(n,["parameters","sampleCount"],o)}const r=S(e,["aspectRatio"]);if(n!==undefined&&r!=null){T(n,["parameters","aspectRatio"],r)}const s=S(e,["guidanceScale"]);if(n!==undefined&&s!=null){T(n,["parameters","guidanceScale"],s)}if(S(e,["seed"])!==undefined){throw new Error("seed parameter is not supported in Gemini API.")}const l=S(e,["safetyFilterLevel"]);if(n!==undefined&&l!=null){T(n,["parameters","safetySetting"],l)}const u=S(e,["personGeneration"]);if(n!==undefined&&u!=null){T(n,["parameters","personGeneration"],u)}const a=S(e,["includeSafetyAttributes"]);if(n!==undefined&&a!=null){T(n,["parameters","includeSafetyAttributes"],a)}const c=S(e,["includeRaiReason"]);if(n!==undefined&&c!=null){T(n,["parameters","includeRaiReason"],c)}const f=S(e,["language"]);if(n!==undefined&&f!=null){T(n,["parameters","language"],f)}const d=S(e,["outputMimeType"]);if(n!==undefined&&d!=null){T(n,["parameters","outputOptions","mimeType"],d)}const p=S(e,["outputCompressionQuality"]);if(n!==undefined&&p!=null){T(n,["parameters","outputOptions","compressionQuality"],p)}if(S(e,["addWatermark"])!==undefined){throw new Error("addWatermark parameter is not supported in Gemini API.")}if(S(e,["labels"])!==undefined){throw new Error("labels parameter is not supported in Gemini API.")}const h=S(e,["imageSize"]);if(n!==undefined&&h!=null){T(n,["parameters","sampleImageSize"],h)}if(S(e,["enhancePrompt"])!==undefined){throw new Error("enhancePrompt parameter is not supported in Gemini API.")}return i}function Er(e,n,t){const i={};const o=S(e,["outputGcsUri"]);if(n!==undefined&&o!=null){T(n,["parameters","storageUri"],o)}const r=S(e,["negativePrompt"]);if(n!==undefined&&r!=null){T(n,["parameters","negativePrompt"],r)}const s=S(e,["numberOfImages"]);if(n!==undefined&&s!=null){T(n,["parameters","sampleCount"],s)}const l=S(e,["aspectRatio"]);if(n!==undefined&&l!=null){T(n,["parameters","aspectRatio"],l)}const u=S(e,["guidanceScale"]);if(n!==undefined&&u!=null){T(n,["parameters","guidanceScale"],u)}const a=S(e,["seed"]);if(n!==undefined&&a!=null){T(n,["parameters","seed"],a)}const c=S(e,["safetyFilterLevel"]);if(n!==undefined&&c!=null){T(n,["parameters","safetySetting"],c)}const f=S(e,["personGeneration"]);if(n!==undefined&&f!=null){T(n,["parameters","personGeneration"],f)}const d=S(e,["includeSafetyAttributes"]);if(n!==undefined&&d!=null){T(n,["parameters","includeSafetyAttributes"],d)}const p=S(e,["includeRaiReason"]);if(n!==undefined&&p!=null){T(n,["parameters","includeRaiReason"],p)}const h=S(e,["language"]);if(n!==undefined&&h!=null){T(n,["parameters","language"],h)}const m=S(e,["outputMimeType"]);if(n!==undefined&&m!=null){T(n,["parameters","outputOptions","mimeType"],m)}const g=S(e,["outputCompressionQuality"]);if(n!==undefined&&g!=null){T(n,["parameters","outputOptions","compressionQuality"],g)}const y=S(e,["addWatermark"]);if(n!==undefined&&y!=null){T(n,["parameters","addWatermark"],y)}const v=S(e,["labels"]);if(n!==undefined&&v!=null){T(n,["labels"],v)}const E=S(e,["imageSize"]);if(n!==undefined&&E!=null){T(n,["parameters","sampleImageSize"],E)}const w=S(e,["enhancePrompt"]);if(n!==undefined&&w!=null){T(n,["parameters","enhancePrompt"],w)}return i}function wr(e,n,t){const i={};const o=S(n,["model"]);if(o!=null){T(i,["_url","model"],Sn(e,o))}const r=S(n,["prompt"]);if(r!=null){T(i,["instances[0]","prompt"],r)}const s=S(n,["config"]);if(s!=null){vr(s,i)}return i}function br(e,n,t){const i={};const o=S(n,["model"]);if(o!=null){T(i,["_url","model"],Sn(e,o))}const r=S(n,["prompt"]);if(r!=null){T(i,["instances[0]","prompt"],r)}const s=S(n,["config"]);if(s!=null){Er(s,i)}return i}function Tr(e,n){const t={};const i=S(e,["sdkHttpResponse"]);if(i!=null){T(t,["sdkHttpResponse"],i)}const o=S(e,["predictions"]);if(o!=null){let e=o;if(Array.isArray(e)){e=e.map((e=>Ur(e)))}T(t,["generatedImages"],e)}const r=S(e,["positivePromptSafetyAttributes"]);if(r!=null){T(t,["positivePromptSafetyAttributes"],ds(r))}return t}function Sr(e,n){const t={};const i=S(e,["sdkHttpResponse"]);if(i!=null){T(t,["sdkHttpResponse"],i)}const o=S(e,["predictions"]);if(o!=null){let e=o;if(Array.isArray(e)){e=e.map((e=>kr(e)))}T(t,["generatedImages"],e)}const r=S(e,["positivePromptSafetyAttributes"]);if(r!=null){T(t,["positivePromptSafetyAttributes"],ps(r))}return t}function Ir(e,n,t){const i={};const o=S(e,["numberOfVideos"]);if(n!==undefined&&o!=null){T(n,["parameters","sampleCount"],o)}if(S(e,["outputGcsUri"])!==undefined){throw new Error("outputGcsUri parameter is not supported in Gemini API.")}if(S(e,["fps"])!==undefined){throw new Error("fps parameter is not supported in Gemini API.")}const r=S(e,["durationSeconds"]);if(n!==undefined&&r!=null){T(n,["parameters","durationSeconds"],r)}if(S(e,["seed"])!==undefined){throw new Error("seed parameter is not supported in Gemini API.")}const s=S(e,["aspectRatio"]);if(n!==undefined&&s!=null){T(n,["parameters","aspectRatio"],s)}const l=S(e,["resolution"]);if(n!==undefined&&l!=null){T(n,["parameters","resolution"],l)}const u=S(e,["personGeneration"]);if(n!==undefined&&u!=null){T(n,["parameters","personGeneration"],u)}if(S(e,["pubsubTopic"])!==undefined){throw new Error("pubsubTopic parameter is not supported in Gemini API.")}const a=S(e,["negativePrompt"]);if(n!==undefined&&a!=null){T(n,["parameters","negativePrompt"],a)}const c=S(e,["enhancePrompt"]);if(n!==undefined&&c!=null){T(n,["parameters","enhancePrompt"],c)}if(S(e,["generateAudio"])!==undefined){throw new Error("generateAudio parameter is not supported in Gemini API.")}const f=S(e,["lastFrame"]);if(n!==undefined&&f!=null){T(n,["instances[0]","lastFrame"],Yr(f))}const d=S(e,["referenceImages"]);if(n!==undefined&&d!=null){let e=d;if(Array.isArray(e)){e=e.map((e=>ks(e)))}T(n,["instances[0]","referenceImages"],e)}if(S(e,["mask"])!==undefined){throw new Error("mask parameter is not supported in Gemini API.")}if(S(e,["compressionQuality"])!==undefined){throw new Error("compressionQuality parameter is not supported in Gemini API.")}return i}function Ar(e,n,t){const i={};const o=S(e,["numberOfVideos"]);if(n!==undefined&&o!=null){T(n,["parameters","sampleCount"],o)}const r=S(e,["outputGcsUri"]);if(n!==undefined&&r!=null){T(n,["parameters","storageUri"],r)}const s=S(e,["fps"]);if(n!==undefined&&s!=null){T(n,["parameters","fps"],s)}const l=S(e,["durationSeconds"]);if(n!==undefined&&l!=null){T(n,["parameters","durationSeconds"],l)}const u=S(e,["seed"]);if(n!==undefined&&u!=null){T(n,["parameters","seed"],u)}const a=S(e,["aspectRatio"]);if(n!==undefined&&a!=null){T(n,["parameters","aspectRatio"],a)}const c=S(e,["resolution"]);if(n!==undefined&&c!=null){T(n,["parameters","resolution"],c)}const f=S(e,["personGeneration"]);if(n!==undefined&&f!=null){T(n,["parameters","personGeneration"],f)}const d=S(e,["pubsubTopic"]);if(n!==undefined&&d!=null){T(n,["parameters","pubsubTopic"],d)}const p=S(e,["negativePrompt"]);if(n!==undefined&&p!=null){T(n,["parameters","negativePrompt"],p)}const h=S(e,["enhancePrompt"]);if(n!==undefined&&h!=null){T(n,["parameters","enhancePrompt"],h)}const m=S(e,["generateAudio"]);if(n!==undefined&&m!=null){T(n,["parameters","generateAudio"],m)}const g=S(e,["lastFrame"]);if(n!==undefined&&g!=null){T(n,["instances[0]","lastFrame"],Kr(g))}const y=S(e,["referenceImages"]);if(n!==undefined&&y!=null){let e=y;if(Array.isArray(e)){e=e.map((e=>Gs(e)))}T(n,["instances[0]","referenceImages"],e)}const v=S(e,["mask"]);if(n!==undefined&&v!=null){T(n,["instances[0]","mask"],Us(v))}const E=S(e,["compressionQuality"]);if(n!==undefined&&E!=null){T(n,["parameters","compressionQuality"],E)}return i}function Or(e,n){const t={};const i=S(e,["name"]);if(i!=null){T(t,["name"],i)}const o=S(e,["metadata"]);if(o!=null){T(t,["metadata"],o)}const r=S(e,["done"]);if(r!=null){T(t,["done"],r)}const s=S(e,["error"]);if(s!=null){T(t,["error"],s)}const l=S(e,["response","generateVideoResponse"]);if(l!=null){T(t,["response"],Rr(l))}return t}function Cr(e,n){const t={};const i=S(e,["name"]);if(i!=null){T(t,["name"],i)}const o=S(e,["metadata"]);if(o!=null){T(t,["metadata"],o)}const r=S(e,["done"]);if(r!=null){T(t,["done"],r)}const s=S(e,["error"]);if(s!=null){T(t,["error"],s)}const l=S(e,["response"]);if(l!=null){T(t,["response"],Nr(l))}return t}function _r(e,n,t){const i={};const o=S(n,["model"]);if(o!=null){T(i,["_url","model"],Sn(e,o))}const r=S(n,["prompt"]);if(r!=null){T(i,["instances[0]","prompt"],r)}const s=S(n,["image"]);if(s!=null){T(i,["instances[0]","image"],Yr(s))}const l=S(n,["video"]);if(l!=null){T(i,["instances[0]","video"],xs(l))}const u=S(n,["source"]);if(u!=null){Mr(u,i)}const a=S(n,["config"]);if(a!=null){Ir(a,i)}return i}function Pr(e,n,t){const i={};const o=S(n,["model"]);if(o!=null){T(i,["_url","model"],Sn(e,o))}const r=S(n,["prompt"]);if(r!=null){T(i,["instances[0]","prompt"],r)}const s=S(n,["image"]);if(s!=null){T(i,["instances[0]","image"],Kr(s))}const l=S(n,["video"]);if(l!=null){T(i,["instances[0]","video"],Ls(l))}const u=S(n,["source"]);if(u!=null){Dr(u,i)}const a=S(n,["config"]);if(a!=null){Ar(a,i)}return i}function Rr(e,n){const t={};const i=S(e,["generatedSamples"]);if(i!=null){let e=i;if(Array.isArray(e)){e=e.map((e=>xr(e)))}T(t,["generatedVideos"],e)}const o=S(e,["raiMediaFilteredCount"]);if(o!=null){T(t,["raiMediaFilteredCount"],o)}const r=S(e,["raiMediaFilteredReasons"]);if(r!=null){T(t,["raiMediaFilteredReasons"],r)}return t}function Nr(e,n){const t={};const i=S(e,["videos"]);if(i!=null){let e=i;if(Array.isArray(e)){e=e.map((e=>Lr(e)))}T(t,["generatedVideos"],e)}const o=S(e,["raiMediaFilteredCount"]);if(o!=null){T(t,["raiMediaFilteredCount"],o)}const r=S(e,["raiMediaFilteredReasons"]);if(r!=null){T(t,["raiMediaFilteredReasons"],r)}return t}function Mr(e,n,t){const i={};const o=S(e,["prompt"]);if(n!==undefined&&o!=null){T(n,["instances[0]","prompt"],o)}const r=S(e,["image"]);if(n!==undefined&&r!=null){T(n,["instances[0]","image"],Yr(r))}const s=S(e,["video"]);if(n!==undefined&&s!=null){T(n,["instances[0]","video"],xs(s))}return i}function Dr(e,n,t){const i={};const o=S(e,["prompt"]);if(n!==undefined&&o!=null){T(n,["instances[0]","prompt"],o)}const r=S(e,["image"]);if(n!==undefined&&r!=null){T(n,["instances[0]","image"],Kr(r))}const s=S(e,["video"]);if(n!==undefined&&s!=null){T(n,["instances[0]","video"],Ls(s))}return i}function Ur(e,n){const t={};const i=S(e,["_self"]);if(i!=null){T(t,["image"],Br(i))}const o=S(e,["raiFilteredReason"]);if(o!=null){T(t,["raiFilteredReason"],o)}const r=S(e,["_self"]);if(r!=null){T(t,["safetyAttributes"],ds(r))}return t}function kr(e,n){const t={};const i=S(e,["_self"]);if(i!=null){T(t,["image"],Wr(i))}const o=S(e,["raiFilteredReason"]);if(o!=null){T(t,["raiFilteredReason"],o)}const r=S(e,["_self"]);if(r!=null){T(t,["safetyAttributes"],ps(r))}const s=S(e,["prompt"]);if(s!=null){T(t,["enhancedPrompt"],s)}return t}function Gr(e,n){const t={};const i=S(e,["_self"]);if(i!=null){T(t,["mask"],Wr(i))}const o=S(e,["labels"]);if(o!=null){let e=o;if(Array.isArray(e)){e=e.map((e=>e))}T(t,["labels"],e)}return t}function xr(e,n){const t={};const i=S(e,["video"]);if(i!=null){T(t,["video"],Ms(i))}return t}function Lr(e,n){const t={};const i=S(e,["_self"]);if(i!=null){T(t,["video"],Ds(i))}return t}function jr(e,n){const t={};const i=S(e,["modelSelectionConfig"]);if(i!=null){T(t,["modelConfig"],i)}const o=S(e,["responseJsonSchema"]);if(o!=null){T(t,["responseJsonSchema"],o)}const r=S(e,["audioTimestamp"]);if(r!=null){T(t,["audioTimestamp"],r)}const s=S(e,["candidateCount"]);if(s!=null){T(t,["candidateCount"],s)}const l=S(e,["enableAffectiveDialog"]);if(l!=null){T(t,["enableAffectiveDialog"],l)}const u=S(e,["frequencyPenalty"]);if(u!=null){T(t,["frequencyPenalty"],u)}const a=S(e,["logprobs"]);if(a!=null){T(t,["logprobs"],a)}const c=S(e,["maxOutputTokens"]);if(c!=null){T(t,["maxOutputTokens"],c)}const f=S(e,["mediaResolution"]);if(f!=null){T(t,["mediaResolution"],f)}const d=S(e,["presencePenalty"]);if(d!=null){T(t,["presencePenalty"],d)}const p=S(e,["responseLogprobs"]);if(p!=null){T(t,["responseLogprobs"],p)}const h=S(e,["responseMimeType"]);if(h!=null){T(t,["responseMimeType"],h)}const m=S(e,["responseModalities"]);if(m!=null){T(t,["responseModalities"],m)}const g=S(e,["responseSchema"]);if(g!=null){T(t,["responseSchema"],g)}const y=S(e,["routingConfig"]);if(y!=null){T(t,["routingConfig"],y)}const v=S(e,["seed"]);if(v!=null){T(t,["seed"],v)}const E=S(e,["speechConfig"]);if(E!=null){T(t,["speechConfig"],E)}const w=S(e,["stopSequences"]);if(w!=null){T(t,["stopSequences"],w)}const b=S(e,["temperature"]);if(b!=null){T(t,["temperature"],b)}const I=S(e,["thinkingConfig"]);if(I!=null){T(t,["thinkingConfig"],I)}const A=S(e,["topK"]);if(A!=null){T(t,["topK"],A)}const O=S(e,["topP"]);if(O!=null){T(t,["topP"],O)}if(S(e,["enableEnhancedCivicAnswers"])!==undefined){throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.")}return t}function Fr(e,n,t){const i={};const o=S(n,["model"]);if(o!=null){T(i,["_url","name"],Sn(e,o))}return i}function qr(e,n,t){const i={};const o=S(n,["model"]);if(o!=null){T(i,["_url","name"],Sn(e,o))}return i}function Hr(e,n){const t={};if(S(e,["authConfig"])!==undefined){throw new Error("authConfig parameter is not supported in Gemini API.")}const i=S(e,["enableWidget"]);if(i!=null){T(t,["enableWidget"],i)}return t}function $r(e,n){const t={};const i=S(e,["searchTypes"]);if(i!=null){T(t,["searchTypes"],i)}if(S(e,["excludeDomains"])!==undefined){throw new Error("excludeDomains parameter is not supported in Gemini API.")}if(S(e,["blockingConfidence"])!==undefined){throw new Error("blockingConfidence parameter is not supported in Gemini API.")}const o=S(e,["timeRangeFilter"]);if(o!=null){T(t,["timeRangeFilter"],o)}return t}function Jr(e,n){const t={};const i=S(e,["aspectRatio"]);if(i!=null){T(t,["aspectRatio"],i)}const o=S(e,["imageSize"]);if(o!=null){T(t,["imageSize"],o)}if(S(e,["personGeneration"])!==undefined){throw new Error("personGeneration parameter is not supported in Gemini API.")}if(S(e,["prominentPeople"])!==undefined){throw new Error("prominentPeople parameter is not supported in Gemini API.")}if(S(e,["outputMimeType"])!==undefined){throw new Error("outputMimeType parameter is not supported in Gemini API.")}if(S(e,["outputCompressionQuality"])!==undefined){throw new Error("outputCompressionQuality parameter is not supported in Gemini API.")}return t}function Vr(e,n){const t={};const i=S(e,["aspectRatio"]);if(i!=null){T(t,["aspectRatio"],i)}const o=S(e,["imageSize"]);if(o!=null){T(t,["imageSize"],o)}const r=S(e,["personGeneration"]);if(r!=null){T(t,["personGeneration"],r)}const s=S(e,["prominentPeople"]);if(s!=null){T(t,["prominentPeople"],s)}const l=S(e,["outputMimeType"]);if(l!=null){T(t,["imageOutputOptions","mimeType"],l)}const u=S(e,["outputCompressionQuality"]);if(u!=null){T(t,["imageOutputOptions","compressionQuality"],u)}return t}function Br(e,n){const t={};const i=S(e,["bytesBase64Encoded"]);if(i!=null){T(t,["imageBytes"],Wn(i))}const o=S(e,["mimeType"]);if(o!=null){T(t,["mimeType"],o)}return t}function Wr(e,n){const t={};const i=S(e,["gcsUri"]);if(i!=null){T(t,["gcsUri"],i)}const o=S(e,["bytesBase64Encoded"]);if(o!=null){T(t,["imageBytes"],Wn(o))}const r=S(e,["mimeType"]);if(r!=null){T(t,["mimeType"],r)}return t}function Yr(e,n){const t={};if(S(e,["gcsUri"])!==undefined){throw new Error("gcsUri parameter is not supported in Gemini API.")}const i=S(e,["imageBytes"]);if(i!=null){T(t,["bytesBase64Encoded"],Wn(i))}const o=S(e,["mimeType"]);if(o!=null){T(t,["mimeType"],o)}return t}function Kr(e,n){const t={};const i=S(e,["gcsUri"]);if(i!=null){T(t,["gcsUri"],i)}const o=S(e,["imageBytes"]);if(o!=null){T(t,["bytesBase64Encoded"],Wn(o))}const r=S(e,["mimeType"]);if(r!=null){T(t,["mimeType"],r)}return t}function zr(e,n,t,i){const o={};const r=S(n,["pageSize"]);if(t!==undefined&&r!=null){T(t,["_query","pageSize"],r)}const s=S(n,["pageToken"]);if(t!==undefined&&s!=null){T(t,["_query","pageToken"],s)}const l=S(n,["filter"]);if(t!==undefined&&l!=null){T(t,["_query","filter"],l)}const u=S(n,["queryBase"]);if(t!==undefined&&u!=null){T(t,["_url","models_url"],Qn(e,u))}return o}function Xr(e,n,t,i){const o={};const r=S(n,["pageSize"]);if(t!==undefined&&r!=null){T(t,["_query","pageSize"],r)}const s=S(n,["pageToken"]);if(t!==undefined&&s!=null){T(t,["_query","pageToken"],s)}const l=S(n,["filter"]);if(t!==undefined&&l!=null){T(t,["_query","filter"],l)}const u=S(n,["queryBase"]);if(t!==undefined&&u!=null){T(t,["_url","models_url"],Qn(e,u))}return o}function Qr(e,n,t){const i={};const o=S(n,["config"]);if(o!=null){zr(e,o,i)}return i}function Zr(e,n,t){const i={};const o=S(n,["config"]);if(o!=null){Xr(e,o,i)}return i}function es(e,n){const t={};const i=S(e,["sdkHttpResponse"]);if(i!=null){T(t,["sdkHttpResponse"],i)}const o=S(e,["nextPageToken"]);if(o!=null){T(t,["nextPageToken"],o)}const r=S(e,["_self"]);if(r!=null){let e=Zn(r);if(Array.isArray(e)){e=e.map((e=>is(e)))}T(t,["models"],e)}return t}function ns(e,n){const t={};const i=S(e,["sdkHttpResponse"]);if(i!=null){T(t,["sdkHttpResponse"],i)}const o=S(e,["nextPageToken"]);if(o!=null){T(t,["nextPageToken"],o)}const r=S(e,["_self"]);if(r!=null){let e=Zn(r);if(Array.isArray(e)){e=e.map((e=>os(e)))}T(t,["models"],e)}return t}function ts(e,n){const t={};const i=S(e,["maskMode"]);if(i!=null){T(t,["maskMode"],i)}const o=S(e,["segmentationClasses"]);if(o!=null){T(t,["maskClasses"],o)}const r=S(e,["maskDilation"]);if(r!=null){T(t,["dilation"],r)}return t}function is(e,n){const t={};const i=S(e,["name"]);if(i!=null){T(t,["name"],i)}const o=S(e,["displayName"]);if(o!=null){T(t,["displayName"],o)}const r=S(e,["description"]);if(r!=null){T(t,["description"],r)}const s=S(e,["version"]);if(s!=null){T(t,["version"],s)}const l=S(e,["_self"]);if(l!=null){T(t,["tunedModelInfo"],Ss(l))}const u=S(e,["inputTokenLimit"]);if(u!=null){T(t,["inputTokenLimit"],u)}const a=S(e,["outputTokenLimit"]);if(a!=null){T(t,["outputTokenLimit"],a)}const c=S(e,["supportedGenerationMethods"]);if(c!=null){T(t,["supportedActions"],c)}const f=S(e,["temperature"]);if(f!=null){T(t,["temperature"],f)}const d=S(e,["maxTemperature"]);if(d!=null){T(t,["maxTemperature"],d)}const p=S(e,["topP"]);if(p!=null){T(t,["topP"],p)}const h=S(e,["topK"]);if(h!=null){T(t,["topK"],h)}const m=S(e,["thinking"]);if(m!=null){T(t,["thinking"],m)}return t}function os(e,n){const t={};const i=S(e,["name"]);if(i!=null){T(t,["name"],i)}const o=S(e,["displayName"]);if(o!=null){T(t,["displayName"],o)}const r=S(e,["description"]);if(r!=null){T(t,["description"],r)}const s=S(e,["versionId"]);if(s!=null){T(t,["version"],s)}const l=S(e,["deployedModels"]);if(l!=null){let e=l;if(Array.isArray(e)){e=e.map((e=>lr(e)))}T(t,["endpoints"],e)}const u=S(e,["labels"]);if(u!=null){T(t,["labels"],u)}const a=S(e,["_self"]);if(a!=null){T(t,["tunedModelInfo"],Is(a))}const c=S(e,["defaultCheckpointId"]);if(c!=null){T(t,["defaultCheckpointId"],c)}const f=S(e,["checkpoints"]);if(f!=null){let e=f;if(Array.isArray(e)){e=e.map((e=>e))}T(t,["checkpoints"],e)}return t}function rs(e,n){const t={};const i=S(e,["mediaResolution"]);if(i!=null){T(t,["mediaResolution"],i)}const o=S(e,["codeExecutionResult"]);if(o!=null){T(t,["codeExecutionResult"],o)}const r=S(e,["executableCode"]);if(r!=null){T(t,["executableCode"],r)}const s=S(e,["fileData"]);if(s!=null){T(t,["fileData"],ur(s))}const l=S(e,["functionCall"]);if(l!=null){T(t,["functionCall"],ar(l))}const u=S(e,["functionResponse"]);if(u!=null){T(t,["functionResponse"],u)}const a=S(e,["inlineData"]);if(a!=null){T(t,["inlineData"],Do(a))}const c=S(e,["text"]);if(c!=null){T(t,["text"],c)}const f=S(e,["thought"]);if(f!=null){T(t,["thought"],f)}const d=S(e,["thoughtSignature"]);if(d!=null){T(t,["thoughtSignature"],d)}const p=S(e,["videoMetadata"]);if(p!=null){T(t,["videoMetadata"],p)}return t}function ss(e,n){const t={};const i=S(e,["productImage"]);if(i!=null){T(t,["image"],Kr(i))}return t}function ls(e,n,t){const i={};const o=S(e,["numberOfImages"]);if(n!==undefined&&o!=null){T(n,["parameters","sampleCount"],o)}const r=S(e,["baseSteps"]);if(n!==undefined&&r!=null){T(n,["parameters","baseSteps"],r)}const s=S(e,["outputGcsUri"]);if(n!==undefined&&s!=null){T(n,["parameters","storageUri"],s)}const l=S(e,["seed"]);if(n!==undefined&&l!=null){T(n,["parameters","seed"],l)}const u=S(e,["safetyFilterLevel"]);if(n!==undefined&&u!=null){T(n,["parameters","safetySetting"],u)}const a=S(e,["personGeneration"]);if(n!==undefined&&a!=null){T(n,["parameters","personGeneration"],a)}const c=S(e,["addWatermark"]);if(n!==undefined&&c!=null){T(n,["parameters","addWatermark"],c)}const f=S(e,["outputMimeType"]);if(n!==undefined&&f!=null){T(n,["parameters","outputOptions","mimeType"],f)}const d=S(e,["outputCompressionQuality"]);if(n!==undefined&&d!=null){T(n,["parameters","outputOptions","compressionQuality"],d)}const p=S(e,["enhancePrompt"]);if(n!==undefined&&p!=null){T(n,["parameters","enhancePrompt"],p)}const h=S(e,["labels"]);if(n!==undefined&&h!=null){T(n,["labels"],h)}return i}function us(e,n,t){const i={};const o=S(n,["model"]);if(o!=null){T(i,["_url","model"],Sn(e,o))}const r=S(n,["source"]);if(r!=null){cs(r,i)}const s=S(n,["config"]);if(s!=null){ls(s,i)}return i}function as(e,n){const t={};const i=S(e,["predictions"]);if(i!=null){let e=i;if(Array.isArray(e)){e=e.map((e=>kr(e)))}T(t,["generatedImages"],e)}return t}function cs(e,n,t){const i={};const o=S(e,["prompt"]);if(n!==undefined&&o!=null){T(n,["instances[0]","prompt"],o)}const r=S(e,["personImage"]);if(n!==undefined&&r!=null){T(n,["instances[0]","personImage","image"],Kr(r))}const s=S(e,["productImages"]);if(n!==undefined&&s!=null){let e=s;if(Array.isArray(e)){e=e.map((e=>ss(e)))}T(n,["instances[0]","productImages"],e)}return i}function fs(e,n){const t={};const i=S(e,["referenceImage"]);if(i!=null){T(t,["referenceImage"],Kr(i))}const o=S(e,["referenceId"]);if(o!=null){T(t,["referenceId"],o)}const r=S(e,["referenceType"]);if(r!=null){T(t,["referenceType"],r)}const s=S(e,["maskImageConfig"]);if(s!=null){T(t,["maskImageConfig"],ts(s))}const l=S(e,["controlImageConfig"]);if(l!=null){T(t,["controlImageConfig"],qo(l))}const u=S(e,["styleImageConfig"]);if(u!=null){T(t,["styleImageConfig"],u)}const a=S(e,["subjectImageConfig"]);if(a!=null){T(t,["subjectImageConfig"],a)}return t}function ds(e,n){const t={};const i=S(e,["safetyAttributes","categories"]);if(i!=null){T(t,["categories"],i)}const o=S(e,["safetyAttributes","scores"]);if(o!=null){T(t,["scores"],o)}const r=S(e,["contentType"]);if(r!=null){T(t,["contentType"],r)}return t}function ps(e,n){const t={};const i=S(e,["safetyAttributes","categories"]);if(i!=null){T(t,["categories"],i)}const o=S(e,["safetyAttributes","scores"]);if(o!=null){T(t,["scores"],o)}const r=S(e,["contentType"]);if(r!=null){T(t,["contentType"],r)}return t}function hs(e,n){const t={};const i=S(e,["category"]);if(i!=null){T(t,["category"],i)}if(S(e,["method"])!==undefined){throw new Error("method parameter is not supported in Gemini API.")}const o=S(e,["threshold"]);if(o!=null){T(t,["threshold"],o)}return t}function ms(e,n){const t={};const i=S(e,["image"]);if(i!=null){T(t,["image"],Kr(i))}return t}function gs(e,n,t){const i={};const o=S(e,["mode"]);if(n!==undefined&&o!=null){T(n,["parameters","mode"],o)}const r=S(e,["maxPredictions"]);if(n!==undefined&&r!=null){T(n,["parameters","maxPredictions"],r)}const s=S(e,["confidenceThreshold"]);if(n!==undefined&&s!=null){T(n,["parameters","confidenceThreshold"],s)}const l=S(e,["maskDilation"]);if(n!==undefined&&l!=null){T(n,["parameters","maskDilation"],l)}const u=S(e,["binaryColorThreshold"]);if(n!==undefined&&u!=null){T(n,["parameters","binaryColorThreshold"],u)}const a=S(e,["labels"]);if(n!==undefined&&a!=null){T(n,["labels"],a)}return i}function ys(e,n,t){const i={};const o=S(n,["model"]);if(o!=null){T(i,["_url","model"],Sn(e,o))}const r=S(n,["source"]);if(r!=null){Es(r,i)}const s=S(n,["config"]);if(s!=null){gs(s,i)}return i}function vs(e,n){const t={};const i=S(e,["predictions"]);if(i!=null){let e=i;if(Array.isArray(e)){e=e.map((e=>Gr(e)))}T(t,["generatedMasks"],e)}return t}function Es(e,n,t){const i={};const o=S(e,["prompt"]);if(n!==undefined&&o!=null){T(n,["instances[0]","prompt"],o)}const r=S(e,["image"]);if(n!==undefined&&r!=null){T(n,["instances[0]","image"],Kr(r))}const s=S(e,["scribbleImage"]);if(n!==undefined&&s!=null){T(n,["instances[0]","scribble"],ms(s))}return i}function ws(e,n){const t={};const i=S(e,["retrievalConfig"]);if(i!=null){T(t,["retrievalConfig"],i)}const o=S(e,["functionCallingConfig"]);if(o!=null){T(t,["functionCallingConfig"],cr(o))}return t}function bs(e,n){const t={};if(S(e,["retrieval"])!==undefined){throw new Error("retrieval parameter is not supported in Gemini API.")}const i=S(e,["computerUse"]);if(i!=null){T(t,["computerUse"],i)}const o=S(e,["fileSearch"]);if(o!=null){T(t,["fileSearch"],o)}const r=S(e,["googleSearch"]);if(r!=null){T(t,["googleSearch"],$r(r))}const s=S(e,["codeExecution"]);if(s!=null){T(t,["codeExecution"],s)}if(S(e,["enterpriseWebSearch"])!==undefined){throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.")}const l=S(e,["functionDeclarations"]);if(l!=null){let e=l;if(Array.isArray(e)){e=e.map((e=>e))}T(t,["functionDeclarations"],e)}const u=S(e,["googleMaps"]);if(u!=null){T(t,["googleMaps"],Hr(u))}const a=S(e,["googleSearchRetrieval"]);if(a!=null){T(t,["googleSearchRetrieval"],a)}const c=S(e,["urlContext"]);if(c!=null){T(t,["urlContext"],c)}const f=S(e,["mcpServers"]);if(f!=null){let e=f;if(Array.isArray(e)){e=e.map((e=>e))}T(t,["mcpServers"],e)}return t}function Ts(e,n){const t={};const i=S(e,["retrieval"]);if(i!=null){T(t,["retrieval"],i)}const o=S(e,["computerUse"]);if(o!=null){T(t,["computerUse"],o)}if(S(e,["fileSearch"])!==undefined){throw new Error("fileSearch parameter is not supported in Vertex AI.")}const r=S(e,["googleSearch"]);if(r!=null){T(t,["googleSearch"],r)}const s=S(e,["codeExecution"]);if(s!=null){T(t,["codeExecution"],s)}const l=S(e,["enterpriseWebSearch"]);if(l!=null){T(t,["enterpriseWebSearch"],l)}const u=S(e,["functionDeclarations"]);if(u!=null){let e=u;if(Array.isArray(e)){e=e.map((e=>fr(e)))}T(t,["functionDeclarations"],e)}const a=S(e,["googleMaps"]);if(a!=null){T(t,["googleMaps"],a)}const c=S(e,["googleSearchRetrieval"]);if(c!=null){T(t,["googleSearchRetrieval"],c)}const f=S(e,["urlContext"]);if(f!=null){T(t,["urlContext"],f)}if(S(e,["mcpServers"])!==undefined){throw new Error("mcpServers parameter is not supported in Vertex AI.")}return t}function Ss(e,n){const t={};const i=S(e,["baseModel"]);if(i!=null){T(t,["baseModel"],i)}const o=S(e,["createTime"]);if(o!=null){T(t,["createTime"],o)}const r=S(e,["updateTime"]);if(r!=null){T(t,["updateTime"],r)}return t}function Is(e,n){const t={};const i=S(e,["labels","google-vertex-llm-tuning-base-model-id"]);if(i!=null){T(t,["baseModel"],i)}const o=S(e,["createTime"]);if(o!=null){T(t,["createTime"],o)}const r=S(e,["updateTime"]);if(r!=null){T(t,["updateTime"],r)}return t}function As(e,n,t){const i={};const o=S(e,["displayName"]);if(n!==undefined&&o!=null){T(n,["displayName"],o)}const r=S(e,["description"]);if(n!==undefined&&r!=null){T(n,["description"],r)}const s=S(e,["defaultCheckpointId"]);if(n!==undefined&&s!=null){T(n,["defaultCheckpointId"],s)}return i}function Os(e,n,t){const i={};const o=S(e,["displayName"]);if(n!==undefined&&o!=null){T(n,["displayName"],o)}const r=S(e,["description"]);if(n!==undefined&&r!=null){T(n,["description"],r)}const s=S(e,["defaultCheckpointId"]);if(n!==undefined&&s!=null){T(n,["defaultCheckpointId"],s)}return i}function Cs(e,n,t){const i={};const o=S(n,["model"]);if(o!=null){T(i,["_url","name"],Sn(e,o))}const r=S(n,["config"]);if(r!=null){As(r,i)}return i}function _s(e,n,t){const i={};const o=S(n,["model"]);if(o!=null){T(i,["_url","model"],Sn(e,o))}const r=S(n,["config"]);if(r!=null){Os(r,i)}return i}function Ps(e,n,t){const i={};const o=S(e,["outputGcsUri"]);if(n!==undefined&&o!=null){T(n,["parameters","storageUri"],o)}const r=S(e,["safetyFilterLevel"]);if(n!==undefined&&r!=null){T(n,["parameters","safetySetting"],r)}const s=S(e,["personGeneration"]);if(n!==undefined&&s!=null){T(n,["parameters","personGeneration"],s)}const l=S(e,["includeRaiReason"]);if(n!==undefined&&l!=null){T(n,["parameters","includeRaiReason"],l)}const u=S(e,["outputMimeType"]);if(n!==undefined&&u!=null){T(n,["parameters","outputOptions","mimeType"],u)}const a=S(e,["outputCompressionQuality"]);if(n!==undefined&&a!=null){T(n,["parameters","outputOptions","compressionQuality"],a)}const c=S(e,["enhanceInputImage"]);if(n!==undefined&&c!=null){T(n,["parameters","upscaleConfig","enhanceInputImage"],c)}const f=S(e,["imagePreservationFactor"]);if(n!==undefined&&f!=null){T(n,["parameters","upscaleConfig","imagePreservationFactor"],f)}const d=S(e,["labels"]);if(n!==undefined&&d!=null){T(n,["labels"],d)}const p=S(e,["numberOfImages"]);if(n!==undefined&&p!=null){T(n,["parameters","sampleCount"],p)}const h=S(e,["mode"]);if(n!==undefined&&h!=null){T(n,["parameters","mode"],h)}return i}function Rs(e,n,t){const i={};const o=S(n,["model"]);if(o!=null){T(i,["_url","model"],Sn(e,o))}const r=S(n,["image"]);if(r!=null){T(i,["instances[0]","image"],Kr(r))}const s=S(n,["upscaleFactor"]);if(s!=null){T(i,["parameters","upscaleConfig","upscaleFactor"],s)}const l=S(n,["config"]);if(l!=null){Ps(l,i)}return i}function Ns(e,n){const t={};const i=S(e,["sdkHttpResponse"]);if(i!=null){T(t,["sdkHttpResponse"],i)}const o=S(e,["predictions"]);if(o!=null){let e=o;if(Array.isArray(e)){e=e.map((e=>kr(e)))}T(t,["generatedImages"],e)}return t}function Ms(e,n){const t={};const i=S(e,["uri"]);if(i!=null){T(t,["uri"],i)}const o=S(e,["encodedVideo"]);if(o!=null){T(t,["videoBytes"],Wn(o))}const r=S(e,["encoding"]);if(r!=null){T(t,["mimeType"],r)}return t}function Ds(e,n){const t={};const i=S(e,["gcsUri"]);if(i!=null){T(t,["uri"],i)}const o=S(e,["bytesBase64Encoded"]);if(o!=null){T(t,["videoBytes"],Wn(o))}const r=S(e,["mimeType"]);if(r!=null){T(t,["mimeType"],r)}return t}function Us(e,n){const t={};const i=S(e,["image"]);if(i!=null){T(t,["_self"],Kr(i))}const o=S(e,["maskMode"]);if(o!=null){T(t,["maskMode"],o)}return t}function ks(e,n){const t={};const i=S(e,["image"]);if(i!=null){T(t,["image"],Yr(i))}const o=S(e,["referenceType"]);if(o!=null){T(t,["referenceType"],o)}return t}function Gs(e,n){const t={};const i=S(e,["image"]);if(i!=null){T(t,["image"],Kr(i))}const o=S(e,["referenceType"]);if(o!=null){T(t,["referenceType"],o)}return t}function xs(e,n){const t={};const i=S(e,["uri"]);if(i!=null){T(t,["uri"],i)}const o=S(e,["videoBytes"]);if(o!=null){T(t,["encodedVideo"],Wn(o))}const r=S(e,["mimeType"]);if(r!=null){T(t,["encoding"],r)}return t}function Ls(e,n){const t={};const i=S(e,["uri"]);if(i!=null){T(t,["gcsUri"],i)}const o=S(e,["videoBytes"]);if(o!=null){T(t,["bytesBase64Encoded"],Wn(o))}const r=S(e,["mimeType"]);if(r!=null){T(t,["mimeType"],r)}return t}
87
+ /**
88
+ * @license
89
+ * Copyright 2025 Google LLC
90
+ * SPDX-License-Identifier: Apache-2.0
91
+ */function js(e,n){const t={};const i=S(e,["displayName"]);if(n!==undefined&&i!=null){T(n,["displayName"],i)}return t}function Fs(e){const n={};const t=S(e,["config"]);if(t!=null){js(t,n)}return n}function qs(e,n){const t={};const i=S(e,["force"]);if(n!==undefined&&i!=null){T(n,["_query","force"],i)}return t}function Hs(e){const n={};const t=S(e,["name"]);if(t!=null){T(n,["_url","name"],t)}const i=S(e,["config"]);if(i!=null){qs(i,n)}return n}function $s(e){const n={};const t=S(e,["name"]);if(t!=null){T(n,["_url","name"],t)}return n}function Js(e,n){const t={};const i=S(e,["customMetadata"]);if(n!==undefined&&i!=null){let e=i;if(Array.isArray(e)){e=e.map((e=>e))}T(n,["customMetadata"],e)}const o=S(e,["chunkingConfig"]);if(n!==undefined&&o!=null){T(n,["chunkingConfig"],o)}return t}function Vs(e){const n={};const t=S(e,["name"]);if(t!=null){T(n,["name"],t)}const i=S(e,["metadata"]);if(i!=null){T(n,["metadata"],i)}const o=S(e,["done"]);if(o!=null){T(n,["done"],o)}const r=S(e,["error"]);if(r!=null){T(n,["error"],r)}const s=S(e,["response"]);if(s!=null){T(n,["response"],Ws(s))}return n}function Bs(e){const n={};const t=S(e,["fileSearchStoreName"]);if(t!=null){T(n,["_url","file_search_store_name"],t)}const i=S(e,["fileName"]);if(i!=null){T(n,["fileName"],i)}const o=S(e,["config"]);if(o!=null){Js(o,n)}return n}function Ws(e){const n={};const t=S(e,["sdkHttpResponse"]);if(t!=null){T(n,["sdkHttpResponse"],t)}const i=S(e,["parent"]);if(i!=null){T(n,["parent"],i)}const o=S(e,["documentName"]);if(o!=null){T(n,["documentName"],o)}return n}function Ys(e,n){const t={};const i=S(e,["pageSize"]);if(n!==undefined&&i!=null){T(n,["_query","pageSize"],i)}const o=S(e,["pageToken"]);if(n!==undefined&&o!=null){T(n,["_query","pageToken"],o)}return t}function Ks(e){const n={};const t=S(e,["config"]);if(t!=null){Ys(t,n)}return n}function zs(e){const n={};const t=S(e,["sdkHttpResponse"]);if(t!=null){T(n,["sdkHttpResponse"],t)}const i=S(e,["nextPageToken"]);if(i!=null){T(n,["nextPageToken"],i)}const o=S(e,["fileSearchStores"]);if(o!=null){let e=o;if(Array.isArray(e)){e=e.map((e=>e))}T(n,["fileSearchStores"],e)}return n}function Xs(e,n){const t={};const i=S(e,["mimeType"]);if(n!==undefined&&i!=null){T(n,["mimeType"],i)}const o=S(e,["displayName"]);if(n!==undefined&&o!=null){T(n,["displayName"],o)}const r=S(e,["customMetadata"]);if(n!==undefined&&r!=null){let e=r;if(Array.isArray(e)){e=e.map((e=>e))}T(n,["customMetadata"],e)}const s=S(e,["chunkingConfig"]);if(n!==undefined&&s!=null){T(n,["chunkingConfig"],s)}return t}function Qs(e){const n={};const t=S(e,["fileSearchStoreName"]);if(t!=null){T(n,["_url","file_search_store_name"],t)}const i=S(e,["config"]);if(i!=null){Xs(i,n)}return n}function Zs(e){const n={};const t=S(e,["sdkHttpResponse"]);if(t!=null){T(n,["sdkHttpResponse"],t)}return n}
92
+ /**
93
+ * @license
94
+ * Copyright 2025 Google LLC
95
+ * SPDX-License-Identifier: Apache-2.0
96
+ */const el="Content-Type";const nl="X-Server-Timeout";const tl="User-Agent";const il="x-goog-api-client";const ol="1.43.0";const rl=`google-genai-sdk/${ol}`;const sl="v1beta1";const ll="v1beta";const ul=5;const al=[408,429,500,502,503,504];class cl{constructor(e){var n,t,i;this.clientOptions=Object.assign({},e);this.customBaseUrl=(n=e.httpOptions)===null||n===void 0?void 0:n.baseUrl;if(this.clientOptions.vertexai){if(this.clientOptions.project&&this.clientOptions.location){this.clientOptions.apiKey=undefined}else if(this.clientOptions.apiKey){this.clientOptions.project=undefined;this.clientOptions.location=undefined}}const o={};if(this.clientOptions.vertexai){if(!this.clientOptions.location&&!this.clientOptions.apiKey&&!this.customBaseUrl){this.clientOptions.location="global"}const n=this.clientOptions.project&&this.clientOptions.location||this.clientOptions.apiKey;if(!n&&!this.customBaseUrl){throw new Error("Authentication is not set up. Please provide either a project and location, or an API key, or a custom base URL.")}const i=e.project&&e.location||!!e.apiKey;if(this.customBaseUrl&&!i){o.baseUrl=this.customBaseUrl;this.clientOptions.project=undefined;this.clientOptions.location=undefined}else if(this.clientOptions.apiKey||this.clientOptions.location==="global"){o.baseUrl="https://aiplatform.googleapis.com/"}else if(this.clientOptions.project&&this.clientOptions.location){o.baseUrl=`https://${this.clientOptions.location}-aiplatform.googleapis.com/`}o.apiVersion=(t=this.clientOptions.apiVersion)!==null&&t!==void 0?t:sl}else{if(!this.clientOptions.apiKey){throw new Xi({message:"API key must be set when using the Gemini API.",status:403})}o.apiVersion=(i=this.clientOptions.apiVersion)!==null&&i!==void 0?i:ll;o.baseUrl=`https://generativelanguage.googleapis.com/`}o.headers=this.getDefaultHeaders();this.clientOptions.httpOptions=o;if(e.httpOptions){this.clientOptions.httpOptions=this.patchHttpOptions(o,e.httpOptions)}}isVertexAI(){var e;return(e=this.clientOptions.vertexai)!==null&&e!==void 0?e:false}getProject(){return this.clientOptions.project}getLocation(){return this.clientOptions.location}getCustomBaseUrl(){return this.customBaseUrl}async getAuthHeaders(){const e=new Headers;await this.clientOptions.auth.addAuthHeaders(e);return e}getApiVersion(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.apiVersion!==undefined){return this.clientOptions.httpOptions.apiVersion}throw new Error("API version is not set.")}getBaseUrl(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.baseUrl!==undefined){return this.clientOptions.httpOptions.baseUrl}throw new Error("Base URL is not set.")}getRequestUrl(){return this.getRequestUrlInternal(this.clientOptions.httpOptions)}getHeaders(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.headers!==undefined){return this.clientOptions.httpOptions.headers}else{throw new Error("Headers are not set.")}}getRequestUrlInternal(e){if(!e||e.baseUrl===undefined||e.apiVersion===undefined){throw new Error("HTTP options are not correctly set.")}const n=e.baseUrl.endsWith("/")?e.baseUrl.slice(0,-1):e.baseUrl;const t=[n];if(e.apiVersion&&e.apiVersion!==""){t.push(e.apiVersion)}return t.join("/")}getBaseResourcePath(){return`projects/${this.clientOptions.project}/locations/${this.clientOptions.location}`}getApiKey(){return this.clientOptions.apiKey}getWebsocketBaseUrl(){const e=this.getBaseUrl();const n=new URL(e);n.protocol=n.protocol=="http:"?"ws":"wss";return n.toString()}setBaseUrl(e){if(this.clientOptions.httpOptions){this.clientOptions.httpOptions.baseUrl=e}else{throw new Error("HTTP options are not correctly set.")}}constructUrl(e,n,t){const i=[this.getRequestUrlInternal(n)];if(t){i.push(this.getBaseResourcePath())}if(e!==""){i.push(e)}const o=new URL(`${i.join("/")}`);return o}shouldPrependVertexProjectPath(e,n){if(n.baseUrl&&n.baseUrlResourceScope===ge.COLLECTION){return false}if(this.clientOptions.apiKey){return false}if(!this.clientOptions.vertexai){return false}if(e.path.startsWith("projects/")){return false}if(e.httpMethod==="GET"&&e.path.startsWith("publishers/google/models")){return false}return true}async request(e){let n=this.clientOptions.httpOptions;if(e.httpOptions){n=this.patchHttpOptions(this.clientOptions.httpOptions,e.httpOptions)}const t=this.shouldPrependVertexProjectPath(e,n);const i=this.constructUrl(e.path,n,t);if(e.queryParams){for(const[n,t]of Object.entries(e.queryParams)){i.searchParams.append(n,String(t))}}let o={};if(e.httpMethod==="GET"){if(e.body&&e.body!=="{}"){throw new Error("Request body should be empty for GET request, but got non empty request body")}}else{o.body=e.body}o=await this.includeExtraHttpOptionsToRequestInit(o,n,i.toString(),e.abortSignal);return this.unaryApiCall(i,o,e.httpMethod)}patchHttpOptions(e,n){const t=JSON.parse(JSON.stringify(e));for(const[e,i]of Object.entries(n)){if(typeof i==="object"){t[e]=Object.assign(Object.assign({},t[e]),i)}else if(i!==undefined){t[e]=i}}return t}async requestStream(e){let n=this.clientOptions.httpOptions;if(e.httpOptions){n=this.patchHttpOptions(this.clientOptions.httpOptions,e.httpOptions)}const t=this.shouldPrependVertexProjectPath(e,n);const i=this.constructUrl(e.path,n,t);if(!i.searchParams.has("alt")||i.searchParams.get("alt")!=="sse"){i.searchParams.set("alt","sse")}let o={};o.body=e.body;o=await this.includeExtraHttpOptionsToRequestInit(o,n,i.toString(),e.abortSignal);return this.streamApiCall(i,o,e.httpMethod)}async includeExtraHttpOptionsToRequestInit(e,n,t,i){if(n&&n.timeout||i){const t=new AbortController;const o=t.signal;if(n.timeout&&(n===null||n===void 0?void 0:n.timeout)>0){const e=setTimeout((()=>t.abort()),n.timeout);if(e&&typeof e.unref==="function"){e.unref()}}if(i){i.addEventListener("abort",(()=>{t.abort()}))}e.signal=o}if(n&&n.extraBody!==null){dl(e,n.extraBody)}e.headers=await this.getHeadersInternal(n,t);return e}async unaryApiCall(e,n,t){return this.apiCall(e.toString(),Object.assign(Object.assign({},n),{method:t})).then((async e=>{await fl(e);return new We(e)})).catch((e=>{if(e instanceof Error){throw e}else{throw new Error(JSON.stringify(e))}}))}async streamApiCall(e,n,t){return this.apiCall(e.toString(),Object.assign(Object.assign({},n),{method:t})).then((async e=>{await fl(e);return this.processStreamResponse(e)})).catch((e=>{if(e instanceof Error){throw e}else{throw new Error(JSON.stringify(e))}}))}processStreamResponse(e){return $i(this,arguments,(function*n(){var t;const i=(t=e===null||e===void 0?void 0:e.body)===null||t===void 0?void 0:t.getReader();const o=new TextDecoder("utf-8");if(!i){throw new Error("Response body is empty")}try{let n="";const t="data:";const r=["\n\n","\r\r","\r\n\r\n"];while(true){const{done:s,value:l}=yield Hi(i.read());if(s){if(n.trim().length>0){throw new Error("Incomplete JSON segment at the end")}break}const u=o.decode(l,{stream:true});try{const e=JSON.parse(u);if("error"in e){const n=JSON.parse(JSON.stringify(e["error"]));const t=n["status"];const i=n["code"];const o=`got status: ${t}. ${JSON.stringify(e)}`;if(i>=400&&i<600){const e=new Xi({message:o,status:i});throw e}}}catch(e){const n=e;if(n.name==="ApiError"){throw e}}n+=u;let a=-1;let c=0;while(true){a=-1;c=0;for(const e of r){const t=n.indexOf(e);if(t!==-1&&(a===-1||t<a)){a=t;c=e.length}}if(a===-1){break}const i=n.substring(0,a);n=n.substring(a+c);const o=i.trim();if(o.startsWith(t)){const n=o.substring(t.length).trim();try{const t=new Response(n,{headers:e===null||e===void 0?void 0:e.headers,status:e===null||e===void 0?void 0:e.status,statusText:e===null||e===void 0?void 0:e.statusText});yield yield Hi(new We(t))}catch(e){throw new Error(`exception parsing stream chunk ${n}. ${e}`)}}}}}finally{i.releaseLock()}}))}async apiCall(e,n){var t;if(!this.clientOptions.httpOptions||!this.clientOptions.httpOptions.retryOptions){return fetch(e,n)}const i=this.clientOptions.httpOptions.retryOptions;const o=async()=>{const t=await fetch(e,n);if(t.ok){return t}if(al.includes(t.status)){throw new Error(`Retryable HTTP Error: ${t.statusText}`)}throw new h.AbortError(`Non-retryable exception ${t.statusText} sending request`)};return m(o,{retries:((t=i.attempts)!==null&&t!==void 0?t:ul)-1})}getDefaultHeaders(){const e={};const n=rl+" "+this.clientOptions.userAgentExtra;e[tl]=n;e[il]=n;e[el]="application/json";return e}async getHeadersInternal(e,n){const t=new Headers;if(e&&e.headers){for(const[n,i]of Object.entries(e.headers)){t.append(n,i)}if(e.timeout&&e.timeout>0){t.append(nl,String(Math.ceil(e.timeout/1e3)))}}await this.clientOptions.auth.addAuthHeaders(t,n);return t}getFileName(e){var n;let t="";if(typeof e==="string"){t=e.replace(/[/\\]+$/,"");t=(n=t.split(/[/\\]/).pop())!==null&&n!==void 0?n:""}return t}async uploadFile(e,n){var t;const i={};if(n!=null){i.mimeType=n.mimeType;i.name=n.name;i.displayName=n.displayName}if(i.name&&!i.name.startsWith("files/")){i.name=`files/${i.name}`}const o=this.clientOptions.uploader;const r=await o.stat(e);i.sizeBytes=String(r.size);const s=(t=n===null||n===void 0?void 0:n.mimeType)!==null&&t!==void 0?t:r.type;if(s===undefined||s===""){throw new Error("Can not determine mimeType. Please provide mimeType in the config.")}i.mimeType=s;const l={file:i};const u=this.getFileName(e);const a=b("upload/v1beta/files",l["_url"]);const c=await this.fetchUploadUrl(a,i.sizeBytes,i.mimeType,u,l,n===null||n===void 0?void 0:n.httpOptions);return o.upload(e,c,this)}async uploadFileToFileSearchStore(e,n,t){var i;const o=this.clientOptions.uploader;const r=await o.stat(n);const s=String(r.size);const l=(i=t===null||t===void 0?void 0:t.mimeType)!==null&&i!==void 0?i:r.type;if(l===undefined||l===""){throw new Error("Can not determine mimeType. Please provide mimeType in the config.")}const u=`upload/v1beta/${e}:uploadToFileSearchStore`;const a=this.getFileName(n);const c={};if(t!=null){Xs(t,c)}const f=await this.fetchUploadUrl(u,s,l,a,c,t===null||t===void 0?void 0:t.httpOptions);return o.uploadToFileSearchStore(n,f,this)}async downloadFile(e){const n=this.clientOptions.downloader;await n.download(e,this)}async fetchUploadUrl(e,n,t,i,o,r){var s;let l={};if(r){l=r}else{l={apiVersion:"",headers:Object.assign({"Content-Type":"application/json","X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":`${n}`,"X-Goog-Upload-Header-Content-Type":`${t}`},i?{"X-Goog-Upload-File-Name":i}:{})}}const u=await this.request({path:e,body:JSON.stringify(o),httpMethod:"POST",httpOptions:l});if(!u||!(u===null||u===void 0?void 0:u.headers)){throw new Error("Server did not return an HttpResponse or the returned HttpResponse did not have headers.")}const a=(s=u===null||u===void 0?void 0:u.headers)===null||s===void 0?void 0:s["x-goog-upload-url"];if(a===undefined){throw new Error("Failed to get upload url. Server did not return the x-google-upload-url in the headers")}return a}}async function fl(e){var n;if(e===undefined){throw new Error("response is undefined")}if(!e.ok){const t=e.status;let i;if((n=e.headers.get("content-type"))===null||n===void 0?void 0:n.includes("application/json")){i=await e.json()}else{i={error:{message:await e.text(),code:e.status,status:e.statusText}}}const o=JSON.stringify(i);if(t>=400&&t<600){const e=new Xi({message:o,status:t});throw e}throw new Error(o)}}function dl(e,n){if(!n||Object.keys(n).length===0){return}if(e.body instanceof Blob){console.warn("includeExtraBodyToRequestInit: extraBody provided but current request body is a Blob. extraBody will be ignored as merging is not supported for Blob bodies.");return}let t={};if(typeof e.body==="string"&&e.body.length>0){try{const n=JSON.parse(e.body);if(typeof n==="object"&&n!==null&&!Array.isArray(n)){t=n}else{console.warn("includeExtraBodyToRequestInit: Original request body is valid JSON but not a non-array object. Skip applying extraBody to the request body.");return}}catch(e){console.warn("includeExtraBodyToRequestInit: Original request body is not valid JSON. Skip applying extraBody to the request body.");return}}function i(e,n){const t=Object.assign({},e);for(const e in n){if(Object.prototype.hasOwnProperty.call(n,e)){const o=n[e];const r=t[e];if(o&&typeof o==="object"&&!Array.isArray(o)&&r&&typeof r==="object"&&!Array.isArray(r)){t[e]=i(r,o)}else{if(r&&o&&typeof r!==typeof o){console.warn(`includeExtraBodyToRequestInit:deepMerge: Type mismatch for key "${e}". Original type: ${typeof r}, New type: ${typeof o}. Overwriting.`)}t[e]=o}}}return t}const o=i(t,n);e.body=JSON.stringify(o)}
97
+ /**
98
+ * @license
99
+ * Copyright 2025 Google LLC
100
+ * SPDX-License-Identifier: Apache-2.0
101
+ */const pl="mcp_used/unknown";let hl=false;function ml(e){for(const n of e){if(yl(n)){return true}if(typeof n==="object"&&"inputSchema"in n){return true}}return hl}function gl(e){var n;const t=(n=e[il])!==null&&n!==void 0?n:"";e[il]=(t+` ${pl}`).trimStart()}function yl(e){return e!==null&&typeof e==="object"&&e instanceof El}function vl(e){return $i(this,arguments,(function*e(n,t=100){let i=undefined;let o=0;while(o<t){const e=yield Hi(n.listTools({cursor:i}));for(const n of e.tools){yield yield Hi(n);o++}if(!e.nextCursor){break}i=e.nextCursor}}))}class El{constructor(e=[],n){this.mcpTools=[];this.functionNameToMcpClient={};this.mcpClients=e;this.config=n}static create(e,n){return new El(e,n)}async initialize(){var e,n,t,i;if(this.mcpTools.length>0){return}const o={};const r=[];for(const a of this.mcpClients){try{for(var s=true,l=(n=void 0,Ji(vl(a))),u;u=await l.next(),e=u.done,!e;s=true){i=u.value;s=false;const e=i;r.push(e);const n=e.name;if(o[n]){throw new Error(`Duplicate function name ${n} found in MCP tools. Please ensure function names are unique.`)}o[n]=a}}catch(e){n={error:e}}finally{try{if(!s&&!e&&(t=l.return))await t.call(l)}finally{if(n)throw n.error}}}this.mcpTools=r;this.functionNameToMcpClient=o}async tool(){await this.initialize();return tt(this.mcpTools,this.config)}async callTool(e){await this.initialize();const n=[];for(const t of e){if(t.name in this.functionNameToMcpClient){const e=this.functionNameToMcpClient[t.name];let i=undefined;if(this.config.timeout){i={timeout:this.config.timeout}}const o=await e.callTool({name:t.name,arguments:t.args},undefined,i);n.push({functionResponse:{name:t.name,response:o.isError?{error:o}:o}})}}return n}}
102
+ /**
103
+ * @license
104
+ * Copyright 2025 Google LLC
105
+ * SPDX-License-Identifier: Apache-2.0
106
+ */async function wl(e,n,t){const i=new bn;let o;if(t.data instanceof Blob){o=JSON.parse(await t.data.text())}else{o=JSON.parse(t.data)}Object.assign(i,o);n(i)}class bl{constructor(e,n,t){this.apiClient=e;this.auth=n;this.webSocketFactory=t}async connect(e){var n,t;if(this.apiClient.isVertexAI()){throw new Error("Live music is not supported for Vertex AI.")}console.warn("Live music generation is experimental and may change in future versions.");const i=this.apiClient.getWebsocketBaseUrl();const o=this.apiClient.getApiVersion();const r=Il(this.apiClient.getDefaultHeaders());const s=this.apiClient.getApiKey();const l=`${i}/ws/google.ai.generativelanguage.${o}.GenerativeService.BidiGenerateMusic?key=${s}`;let u=()=>{};const a=new Promise((e=>{u=e}));const c=e.callbacks;const f=function(){u({})};const d=this.apiClient;const p={onopen:f,onmessage:e=>{void wl(d,c.onmessage,e)},onerror:(n=c===null||c===void 0?void 0:c.onerror)!==null&&n!==void 0?n:function(e){},onclose:(t=c===null||c===void 0?void 0:c.onclose)!==null&&t!==void 0?t:function(e){}};const h=this.webSocketFactory.create(l,Sl(r),p);h.connect();await a;const m=Sn(this.apiClient,e.model);const g={model:m};const y={setup:g};h.send(JSON.stringify(y));return new Tl(h,this.apiClient)}}class Tl{constructor(e,n){this.conn=e;this.apiClient=n}async setWeightedPrompts(e){if(!e.weightedPrompts||Object.keys(e.weightedPrompts).length===0){throw new Error("Weighted prompts must be set and contain at least one entry.")}const n=So(e);this.conn.send(JSON.stringify({clientContent:n}))}async setMusicGenerationConfig(e){if(!e.musicGenerationConfig){e.musicGenerationConfig={}}const n=To(e);this.conn.send(JSON.stringify(n))}sendPlaybackControl(e){const n={playbackControl:e};this.conn.send(JSON.stringify(n))}play(){this.sendPlaybackControl(Be.PLAY)}pause(){this.sendPlaybackControl(Be.PAUSE)}stop(){this.sendPlaybackControl(Be.STOP)}resetContext(){this.sendPlaybackControl(Be.RESET_CONTEXT)}close(){this.conn.close()}}function Sl(e){const n={};e.forEach(((e,t)=>{n[t]=e}));return n}function Il(e){const n=new Headers;for(const[t,i]of Object.entries(e)){n.append(t,i)}return n}
107
+ /**
108
+ * @license
109
+ * Copyright 2025 Google LLC
110
+ * SPDX-License-Identifier: Apache-2.0
111
+ */const Al="FunctionResponse request must have an `id` field from the response of a ToolCall.FunctionalCalls in Google AI.";async function Ol(e,n,t){const i=new wn;let o;if(t.data instanceof Blob){o=await t.data.text()}else if(t.data instanceof ArrayBuffer){o=(new TextDecoder).decode(t.data)}else{o=t.data}const r=JSON.parse(o);if(e.isVertexAI()){const e=Oo(r);Object.assign(i,e)}else{const e=r;Object.assign(i,e)}n(i)}class Cl{constructor(e,n,t){this.apiClient=e;this.auth=n;this.webSocketFactory=t;this.music=new bl(this.apiClient,this.auth,this.webSocketFactory)}async connect(e){var n,t,i,o,r,s;if(e.config&&e.config.httpOptions){throw new Error("The Live module does not support httpOptions at request-level in"+" LiveConnectConfig yet. Please use the client-level httpOptions"+" configuration instead.")}const l=this.apiClient.getWebsocketBaseUrl();const u=this.apiClient.getApiVersion();let a;const c=this.apiClient.getHeaders();if(e.config&&e.config.tools&&ml(e.config.tools)){gl(c)}const f=Nl(c);if(this.apiClient.isVertexAI()){const e=this.apiClient.getProject();const n=this.apiClient.getLocation();const t=this.apiClient.getApiKey();const i=!!e&&!!n||!!t;if(this.apiClient.getCustomBaseUrl()&&!i){a=l}else{a=`${l}/ws/google.cloud.aiplatform.${u}.LlmBidiService/BidiGenerateContent`;await this.auth.addAuthHeaders(f,a)}}else{const e=this.apiClient.getApiKey();let n="BidiGenerateContent";let t="key";if(e===null||e===void 0?void 0:e.startsWith("auth_tokens/")){console.warn("Warning: Ephemeral token support is experimental and may change in future versions.");if(u!=="v1alpha"){console.warn("Warning: The SDK's ephemeral token support is in v1alpha only. Please use const ai = new GoogleGenAI({apiKey: token.name, httpOptions: { apiVersion: 'v1alpha' }}); before session connection.")}n="BidiGenerateContentConstrained";t="access_token"}a=`${l}/ws/google.ai.generativelanguage.${u}.GenerativeService.${n}?${t}=${e}`}let d=()=>{};const p=new Promise((e=>{d=e}));const h=e.callbacks;const m=function(){var e;(e=h===null||h===void 0?void 0:h.onopen)===null||e===void 0?void 0:e.call(h);d({})};const g=this.apiClient;const y={onopen:m,onmessage:e=>{void Ol(g,h.onmessage,e)},onerror:(n=h===null||h===void 0?void 0:h.onerror)!==null&&n!==void 0?n:function(e){},onclose:(t=h===null||h===void 0?void 0:h.onclose)!==null&&t!==void 0?t:function(e){}};const v=this.webSocketFactory.create(a,Rl(f),y);v.connect();await p;let E=Sn(this.apiClient,e.model);if(this.apiClient.isVertexAI()&&E.startsWith("publishers/")){const e=this.apiClient.getProject();const n=this.apiClient.getLocation();if(e&&n){E=`projects/${e}/locations/${n}/`+E}}let w={};if(this.apiClient.isVertexAI()&&((i=e.config)===null||i===void 0?void 0:i.responseModalities)===undefined){if(e.config===undefined){e.config={responseModalities:[ae.AUDIO]}}else{e.config.responseModalities=[ae.AUDIO]}}if((o=e.config)===null||o===void 0?void 0:o.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).")}const b=(s=(r=e.config)===null||r===void 0?void 0:r.tools)!==null&&s!==void 0?s:[];const T=[];for(const e of b){if(this.isCallableTool(e)){const n=e;T.push(await n.tool())}else{T.push(e)}}if(T.length>0){e.config.tools=T}const S={model:E,config:e.config,callbacks:e.callbacks};if(this.apiClient.isVertexAI()){w=bo(this.apiClient,S)}else{w=wo(this.apiClient,S)}delete w["config"];v.send(JSON.stringify(w));return new Pl(v,this.apiClient)}isCallableTool(e){return"callTool"in e&&typeof e.callTool==="function"}}const _l={turnComplete:true};class Pl{constructor(e,n){this.conn=e;this.apiClient=n}tLiveClientContent(e,n){if(n.turns!==null&&n.turns!==undefined){let t=[];try{t=Gn(n.turns);if(!e.isVertexAI()){t=t.map((e=>Fo(e)))}}catch(e){throw new Error(`Failed to parse client content "turns", type: '${typeof n.turns}'`)}return{clientContent:{turns:t,turnComplete:n.turnComplete}}}return{clientContent:{turnComplete:n.turnComplete}}}tLiveClienttToolResponse(e,n){let t=[];if(n.functionResponses==null){throw new Error("functionResponses is required.")}if(!Array.isArray(n.functionResponses)){t=[n.functionResponses]}else{t=n.functionResponses}if(t.length===0){throw new Error("functionResponses is required.")}for(const n of t){if(typeof n!=="object"||n===null||!("name"in n)||!("response"in n)){throw new Error(`Could not parse function response, type '${typeof n}'.`)}if(!e.isVertexAI()&&!("id"in n)){throw new Error(Al)}}const i={toolResponse:{functionResponses:t}};return i}sendClientContent(e){e=Object.assign(Object.assign({},_l),e);const n=this.tLiveClientContent(this.apiClient,e);this.conn.send(JSON.stringify(n))}sendRealtimeInput(e){let n={};if(this.apiClient.isVertexAI()){n={realtimeInput:Ao(e)}}else{n={realtimeInput:Io(e)}}this.conn.send(JSON.stringify(n))}sendToolResponse(e){if(e.functionResponses==null){throw new Error("Tool response parameters are required.")}const n=this.tLiveClienttToolResponse(this.apiClient,e);this.conn.send(JSON.stringify(n))}close(){this.conn.close()}}function Rl(e){const n={};e.forEach(((e,t)=>{n[t]=e}));return n}function Nl(e){const n=new Headers;for(const[t,i]of Object.entries(e)){n.append(t,i)}return n}
112
+ /**
113
+ * @license
114
+ * Copyright 2025 Google LLC
115
+ * SPDX-License-Identifier: Apache-2.0
116
+ */const Ml=10;function Dl(e){var n,t,i;if((n=e===null||e===void 0?void 0:e.automaticFunctionCalling)===null||n===void 0?void 0:n.disable){return true}let o=false;for(const n of(t=e===null||e===void 0?void 0:e.tools)!==null&&t!==void 0?t:[]){if(Ul(n)){o=true;break}}if(!o){return true}const r=(i=e===null||e===void 0?void 0:e.automaticFunctionCalling)===null||i===void 0?void 0:i.maximumRemoteCalls;if(r&&(r<0||!Number.isInteger(r))||r==0){console.warn("Invalid maximumRemoteCalls value provided for automatic function calling. Disabled automatic function calling. Please provide a valid integer value greater than 0. maximumRemoteCalls provided:",r);return true}return false}function Ul(e){return"callTool"in e&&typeof e.callTool==="function"}function kl(e){var n,t,i;return(i=(t=(n=e.config)===null||n===void 0?void 0:n.tools)===null||t===void 0?void 0:t.some((e=>Ul(e))))!==null&&i!==void 0?i:false}function Gl(e){var n;const t=[];if(!((n=e===null||e===void 0?void 0:e.config)===null||n===void 0?void 0:n.tools)){return t}e.config.tools.forEach(((e,n)=>{if(Ul(e)){return}const i=e;if(i.functionDeclarations&&i.functionDeclarations.length>0){t.push(n)}}));return t}function xl(e){var n;return!((n=e===null||e===void 0?void 0:e.automaticFunctionCalling)===null||n===void 0?void 0:n.ignoreCallHistory)}
117
+ /**
118
+ * @license
119
+ * Copyright 2025 Google LLC
120
+ * SPDX-License-Identifier: Apache-2.0
121
+ */class Ll extends w{constructor(e){super();this.apiClient=e;this.embedContent=async e=>{if(!this.apiClient.isVertexAI()){return await this.embedContentInternal(e)}const n=e.model.includes("gemini")&&e.model!=="gemini-embedding-001"||e.model.includes("maas");if(n){const n=Gn(e.contents);if(n.length>1){throw new Error("The embedContent API for this model only supports one content at a time.")}const t=Object.assign(Object.assign({},e),{content:n[0],embeddingApiType:we.EMBED_CONTENT});return await this.embedContentInternal(t)}else{const n=Object.assign(Object.assign({},e),{embeddingApiType:we.PREDICT});return await this.embedContentInternal(n)}};this.generateContent=async e=>{var n,t,i,o,r;const s=await this.processParamsMaybeAddMcpUsage(e);this.maybeMoveToResponseJsonSchem(e);if(!kl(e)||Dl(e.config)){return await this.generateContentInternal(s)}const l=Gl(e);if(l.length>0){const e=l.map((e=>`tools[${e}]`)).join(", ");throw new Error(`Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations is not yet supported. Incompatible tools found at ${e}.`)}let u;let a;const c=Gn(s.contents);const f=(i=(t=(n=s.config)===null||n===void 0?void 0:n.automaticFunctionCalling)===null||t===void 0?void 0:t.maximumRemoteCalls)!==null&&i!==void 0?i:Ml;let d=0;while(d<f){u=await this.generateContentInternal(s);if(!u.functionCalls||u.functionCalls.length===0){break}const n=u.candidates[0].content;const t=[];for(const n of(r=(o=e.config)===null||o===void 0?void 0:o.tools)!==null&&r!==void 0?r:[]){if(Ul(n)){const e=n;const i=await e.callTool(u.functionCalls);t.push(...i)}}d++;a={role:"user",parts:t};s.contents=Gn(s.contents);s.contents.push(n);s.contents.push(a);if(xl(s.config)){c.push(n);c.push(a)}}if(xl(s.config)){u.automaticFunctionCallingHistory=c}return u};this.generateContentStream=async e=>{var n,t,i,o,r;this.maybeMoveToResponseJsonSchem(e);if(Dl(e.config)){const n=await this.processParamsMaybeAddMcpUsage(e);return await this.generateContentStreamInternal(n)}const s=Gl(e);if(s.length>0){const e=s.map((e=>`tools[${e}]`)).join(", ");throw new Error(`Incompatible tools found at ${e}. Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations" is not yet supported.`)}const l=(i=(t=(n=e===null||e===void 0?void 0:e.config)===null||n===void 0?void 0:n.toolConfig)===null||t===void 0?void 0:t.functionCallingConfig)===null||i===void 0?void 0:i.streamFunctionCallArguments;const u=(r=(o=e===null||e===void 0?void 0:e.config)===null||o===void 0?void 0:o.automaticFunctionCalling)===null||r===void 0?void 0:r.disable;if(l&&!u){throw new 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 n;let t;const i=[];if(e===null||e===void 0?void 0:e.generatedImages){for(const o of e.generatedImages){if(o&&(o===null||o===void 0?void 0:o.safetyAttributes)&&((n=o===null||o===void 0?void 0:o.safetyAttributes)===null||n===void 0?void 0:n.contentType)==="Positive Prompt"){t=o===null||o===void 0?void 0:o.safetyAttributes}else{i.push(o)}}}let o;if(t){o={generatedImages:i,positivePromptSafetyAttributes:t,sdkHttpResponse:e.sdkHttpResponse}}else{o={generatedImages:i,sdkHttpResponse:e.sdkHttpResponse}}return o}));this.list=async e=>{var n;const t={queryBase:true};const i=Object.assign(Object.assign({},t),e===null||e===void 0?void 0:e.config);const o={config:i};if(this.apiClient.isVertexAI()){if(!o.config.queryBase){if((n=o.config)===null||n===void 0?void 0:n.filter){throw new Error("Filtering tuned models list for Vertex AI is not currently supported")}else{o.config.filter="labels.tune-type:*"}}}return new ri(oi.PAGED_ITEM_MODELS,(e=>this.listInternal(e)),await this.listInternal(o),o)};this.editImage=async e=>{const n={model:e.model,prompt:e.prompt,referenceImages:[],config:e.config};if(e.referenceImages){if(e.referenceImages){n.referenceImages=e.referenceImages.map((e=>e.toReferenceImageAPI()))}}return await this.editImageInternal(n)};this.upscaleImage=async e=>{let n={numberOfImages:1,mode:"upscale"};if(e.config){n=Object.assign(Object.assign({},n),e.config)}const t={model:e.model,image:e.image,upscaleFactor:e.upscaleFactor,config:n};return await this.upscaleImageInternal(t)};this.generateVideos=async e=>{var n,t,i,o,r,s;if((e.prompt||e.image||e.video)&&e.source){throw new Error("Source and prompt/image/video are mutually exclusive. Please only use source.")}if(!this.apiClient.isVertexAI()){if(((n=e.video)===null||n===void 0?void 0:n.uri)&&((t=e.video)===null||t===void 0?void 0:t.videoBytes)){e.video={uri:e.video.uri,mimeType:e.video.mimeType}}else if(((o=(i=e.source)===null||i===void 0?void 0:i.video)===null||o===void 0?void 0:o.uri)&&((s=(r=e.source)===null||r===void 0?void 0:r.video)===null||s===void 0?void 0:s.videoBytes)){e.source.video={uri:e.source.video.uri,mimeType:e.source.video.mimeType}}}return await this.generateVideosInternal(e)}}maybeMoveToResponseJsonSchem(e){if(e.config&&e.config.responseSchema){if(!e.config.responseJsonSchema){if(Object.keys(e.config.responseSchema).includes("$schema")){e.config.responseJsonSchema=e.config.responseSchema;delete e.config.responseSchema}}}return}async processParamsMaybeAddMcpUsage(e){var n,t,i;const o=(n=e.config)===null||n===void 0?void 0:n.tools;if(!o){return e}const r=await Promise.all(o.map((async e=>{if(Ul(e)){const n=e;return await n.tool()}return e})));const s={model:e.model,contents:e.contents,config:Object.assign(Object.assign({},e.config),{tools:r})};s.config.tools=r;if(e.config&&e.config.tools&&ml(e.config.tools)){const n=(i=(t=e.config.httpOptions)===null||t===void 0?void 0:t.headers)!==null&&i!==void 0?i:{};let o=Object.assign({},n);if(Object.keys(o).length===0){o=this.apiClient.getDefaultHeaders()}gl(o);s.config.httpOptions=Object.assign(Object.assign({},e.config.httpOptions),{headers:o})}return s}async initAfcToolsMap(e){var n,t,i;const o=new Map;for(const r of(t=(n=e.config)===null||n===void 0?void 0:n.tools)!==null&&t!==void 0?t:[]){if(Ul(r)){const e=r;const n=await e.tool();for(const t of(i=n.functionDeclarations)!==null&&i!==void 0?i:[]){if(!t.name){throw new Error("Function declaration name is required.")}if(o.has(t.name)){throw new Error(`Duplicate tool declaration name: ${t.name}`)}o.set(t.name,e)}}}return o}async processAfcStream(e){var n,t,i;const o=(i=(t=(n=e.config)===null||n===void 0?void 0:n.automaticFunctionCalling)===null||t===void 0?void 0:t.maximumRemoteCalls)!==null&&i!==void 0?i:Ml;let r=false;let s=0;const l=await this.initAfcToolsMap(e);return function(e,n,t){return $i(this,arguments,(function*(){var i,l,u,a;var c,f;while(s<o){if(r){s++;r=false}const m=yield Hi(e.processParamsMaybeAddMcpUsage(t));const g=yield Hi(e.generateContentStreamInternal(m));const y=[];const v=[];try{for(var d=true,p=(l=void 0,Ji(g)),h;h=yield Hi(p.next()),i=h.done,!i;d=true){a=h.value;d=false;const e=a;yield yield Hi(e);if(e.candidates&&((c=e.candidates[0])===null||c===void 0?void 0:c.content)){v.push(e.candidates[0].content);for(const t of(f=e.candidates[0].content.parts)!==null&&f!==void 0?f:[]){if(s<o&&t.functionCall){if(!t.functionCall.name){throw new Error("Function call name was not returned by the model.")}if(!n.has(t.functionCall.name)){throw new Error(`Automatic function calling was requested, but not all the tools the model used implement the CallableTool interface. Available tools: ${n.keys()}, mising tool: ${t.functionCall.name}`)}else{const e=yield Hi(n.get(t.functionCall.name).callTool([t.functionCall]));y.push(...e)}}}}}}catch(e){l={error:e}}finally{try{if(!d&&!i&&(u=p.return))yield Hi(u.call(p))}finally{if(l)throw l.error}}if(y.length>0){r=true;const e=new Ye;e.candidates=[{content:{role:"user",parts:y}}];yield yield Hi(e);const n=[];n.push(...v);n.push({role:"user",parts:y});const i=Gn(t.contents).concat(n);t.contents=i}else{break}}}))}(this,l,e)}async generateContentInternal(e){var n,t,i,o;let r;let s="";let l={};if(this.apiClient.isVertexAI()){const i=mr(this.apiClient,e);s=b("{model}:generateContent",i["_url"]);l=i["_query"];delete i["_url"];delete i["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(i),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json().then((n=>{const t=n;t.sdkHttpResponse={headers:e.headers};return t}))));return r.then((e=>{const n=yr(e);const t=new Ye;Object.assign(t,n);return t}))}else{const n=hr(this.apiClient,e);s=b("{model}:generateContent",n["_url"]);l=n["_query"];delete n["_url"];delete n["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(n),httpMethod:"POST",httpOptions:(i=e.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then((e=>e.json().then((n=>{const t=n;t.sdkHttpResponse={headers:e.headers};return t}))));return r.then((e=>{const n=gr(e);const t=new Ye;Object.assign(t,n);return t}))}}async generateContentStreamInternal(e){var n,t,i,o;let r;let s="";let l={};if(this.apiClient.isVertexAI()){const i=mr(this.apiClient,e);s=b("{model}:streamGenerateContent?alt=sse",i["_url"]);l=i["_query"];delete i["_url"];delete i["_query"];const o=this.apiClient;r=o.requestStream({path:s,queryParams:l,body:JSON.stringify(i),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal});return r.then((function(e){return $i(this,arguments,(function*(){var n,t,i,o;try{for(var r=true,s=Ji(e),l;l=yield Hi(s.next()),n=l.done,!n;r=true){o=l.value;r=false;const e=o;const n=yr(yield Hi(e.json()));n["sdkHttpResponse"]={headers:e.headers};const t=new Ye;Object.assign(t,n);yield yield Hi(t)}}catch(e){t={error:e}}finally{try{if(!r&&!n&&(i=s.return))yield Hi(i.call(s))}finally{if(t)throw t.error}}}))}))}else{const n=hr(this.apiClient,e);s=b("{model}:streamGenerateContent?alt=sse",n["_url"]);l=n["_query"];delete n["_url"];delete n["_query"];const t=this.apiClient;r=t.requestStream({path:s,queryParams:l,body:JSON.stringify(n),httpMethod:"POST",httpOptions:(i=e.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal});return r.then((function(e){return $i(this,arguments,(function*(){var n,t,i,o;try{for(var r=true,s=Ji(e),l;l=yield Hi(s.next()),n=l.done,!n;r=true){o=l.value;r=false;const e=o;const n=gr(yield Hi(e.json()));n["sdkHttpResponse"]={headers:e.headers};const t=new Ye;Object.assign(t,n);yield yield Hi(t)}}catch(e){t={error:e}}finally{try{if(!r&&!n&&(i=s.return))yield Hi(i.call(s))}finally{if(t)throw t.error}}}))}))}}async embedContentInternal(e){var n,t,i,o;let r;let s="";let l={};if(this.apiClient.isVertexAI()){const i=or(this.apiClient,e,e);const o=ut(e.model)?"{model}:embedContent":"{model}:predict";s=b(o,i["_url"]);l=i["_query"];delete i["_url"];delete i["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(i),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json().then((n=>{const t=n;t.sdkHttpResponse={headers:e.headers};return t}))));return r.then((n=>{const t=sr(n,e);const i=new Ke;Object.assign(i,t);return i}))}else{const n=ir(this.apiClient,e);s=b("{model}:batchEmbedContents",n["_url"]);l=n["_query"];delete n["_url"];delete n["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(n),httpMethod:"POST",httpOptions:(i=e.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then((e=>e.json().then((n=>{const t=n;t.sdkHttpResponse={headers:e.headers};return t}))));return r.then((e=>{const n=rr(e);const t=new Ke;Object.assign(t,n);return t}))}}async generateImagesInternal(e){var n,t,i,o;let r;let s="";let l={};if(this.apiClient.isVertexAI()){const i=br(this.apiClient,e);s=b("{model}:predict",i["_url"]);l=i["_query"];delete i["_url"];delete i["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(i),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json().then((n=>{const t=n;t.sdkHttpResponse={headers:e.headers};return t}))));return r.then((e=>{const n=Sr(e);const t=new ze;Object.assign(t,n);return t}))}else{const n=wr(this.apiClient,e);s=b("{model}:predict",n["_url"]);l=n["_query"];delete n["_url"];delete n["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(n),httpMethod:"POST",httpOptions:(i=e.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then((e=>e.json().then((n=>{const t=n;t.sdkHttpResponse={headers:e.headers};return t}))));return r.then((e=>{const n=Tr(e);const t=new ze;Object.assign(t,n);return t}))}}async editImageInternal(e){var n,t;let i;let o="";let r={};if(this.apiClient.isVertexAI()){const s=Zo(this.apiClient,e);o=b("{model}:predict",s["_url"]);r=s["_query"];delete s["_url"];delete s["_query"];i=this.apiClient.request({path:o,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json().then((n=>{const t=n;t.sdkHttpResponse={headers:e.headers};return t}))));return i.then((e=>{const n=er(e);const t=new Xe;Object.assign(t,n);return t}))}else{throw new Error("This method is only supported by the Vertex AI.")}}async upscaleImageInternal(e){var n,t;let i;let o="";let r={};if(this.apiClient.isVertexAI()){const s=Rs(this.apiClient,e);o=b("{model}:predict",s["_url"]);r=s["_query"];delete s["_url"];delete s["_query"];i=this.apiClient.request({path:o,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json().then((n=>{const t=n;t.sdkHttpResponse={headers:e.headers};return t}))));return i.then((e=>{const n=Ns(e);const t=new Qe;Object.assign(t,n);return t}))}else{throw new Error("This method is only supported by the Vertex AI.")}}async recontextImage(e){var n,t;let i;let o="";let r={};if(this.apiClient.isVertexAI()){const s=us(this.apiClient,e);o=b("{model}:predict",s["_url"]);r=s["_query"];delete s["_url"];delete s["_query"];i=this.apiClient.request({path:o,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json()));return i.then((e=>{const n=as(e);const t=new Ze;Object.assign(t,n);return t}))}else{throw new Error("This method is only supported by the Vertex AI.")}}async segmentImage(e){var n,t;let i;let o="";let r={};if(this.apiClient.isVertexAI()){const s=ys(this.apiClient,e);o=b("{model}:predict",s["_url"]);r=s["_query"];delete s["_url"];delete s["_query"];i=this.apiClient.request({path:o,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json()));return i.then((e=>{const n=vs(e);const t=new en;Object.assign(t,n);return t}))}else{throw new Error("This method is only supported by the Vertex AI.")}}async get(e){var n,t,i,o;let r;let s="";let l={};if(this.apiClient.isVertexAI()){const i=qr(this.apiClient,e);s=b("{name}",i["_url"]);l=i["_query"];delete i["_url"];delete i["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(i),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json()));return r.then((e=>{const n=os(e);return n}))}else{const n=Fr(this.apiClient,e);s=b("{name}",n["_url"]);l=n["_query"];delete n["_url"];delete n["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(n),httpMethod:"GET",httpOptions:(i=e.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then((e=>e.json()));return r.then((e=>{const n=is(e);return n}))}}async listInternal(e){var n,t,i,o;let r;let s="";let l={};if(this.apiClient.isVertexAI()){const i=Zr(this.apiClient,e);s=b("{models_url}",i["_url"]);l=i["_query"];delete i["_url"];delete i["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(i),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json().then((n=>{const t=n;t.sdkHttpResponse={headers:e.headers};return t}))));return r.then((e=>{const n=ns(e);const t=new nn;Object.assign(t,n);return t}))}else{const n=Qr(this.apiClient,e);s=b("{models_url}",n["_url"]);l=n["_query"];delete n["_url"];delete n["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(n),httpMethod:"GET",httpOptions:(i=e.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then((e=>e.json().then((n=>{const t=n;t.sdkHttpResponse={headers:e.headers};return t}))));return r.then((e=>{const n=es(e);const t=new nn;Object.assign(t,n);return t}))}}async update(e){var n,t,i,o;let r;let s="";let l={};if(this.apiClient.isVertexAI()){const i=_s(this.apiClient,e);s=b("{model}",i["_url"]);l=i["_query"];delete i["_url"];delete i["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(i),httpMethod:"PATCH",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json()));return r.then((e=>{const n=os(e);return n}))}else{const n=Cs(this.apiClient,e);s=b("{name}",n["_url"]);l=n["_query"];delete n["_url"];delete n["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(n),httpMethod:"PATCH",httpOptions:(i=e.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then((e=>e.json()));return r.then((e=>{const n=is(e);return n}))}}async delete(e){var n,t,i,o;let r;let s="";let l={};if(this.apiClient.isVertexAI()){const i=Ko(this.apiClient,e);s=b("{name}",i["_url"]);l=i["_query"];delete i["_url"];delete i["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(i),httpMethod:"DELETE",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json().then((n=>{const t=n;t.sdkHttpResponse={headers:e.headers};return t}))));return r.then((e=>{const n=Xo(e);const t=new tn;Object.assign(t,n);return t}))}else{const n=Yo(this.apiClient,e);s=b("{name}",n["_url"]);l=n["_query"];delete n["_url"];delete n["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(n),httpMethod:"DELETE",httpOptions:(i=e.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then((e=>e.json().then((n=>{const t=n;t.sdkHttpResponse={headers:e.headers};return t}))));return r.then((e=>{const n=zo(e);const t=new tn;Object.assign(t,n);return t}))}}async countTokens(e){var n,t,i,o;let r;let s="";let l={};if(this.apiClient.isVertexAI()){const i=Vo(this.apiClient,e);s=b("{model}:countTokens",i["_url"]);l=i["_query"];delete i["_url"];delete i["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(i),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json().then((n=>{const t=n;t.sdkHttpResponse={headers:e.headers};return t}))));return r.then((e=>{const n=Wo(e);const t=new on;Object.assign(t,n);return t}))}else{const n=Jo(this.apiClient,e);s=b("{model}:countTokens",n["_url"]);l=n["_query"];delete n["_url"];delete n["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(n),httpMethod:"POST",httpOptions:(i=e.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then((e=>e.json().then((n=>{const t=n;t.sdkHttpResponse={headers:e.headers};return t}))));return r.then((e=>{const n=Bo(e);const t=new on;Object.assign(t,n);return t}))}}async computeTokens(e){var n,t;let i;let o="";let r={};if(this.apiClient.isVertexAI()){const s=Go(this.apiClient,e);o=b("{model}:computeTokens",s["_url"]);r=s["_query"];delete s["_url"];delete s["_query"];i=this.apiClient.request({path:o,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json().then((n=>{const t=n;t.sdkHttpResponse={headers:e.headers};return t}))));return i.then((e=>{const n=xo(e);const t=new rn;Object.assign(t,n);return t}))}else{throw new Error("This method is only supported by the Vertex AI.")}}async generateVideosInternal(e){var n,t,i,o;let r;let s="";let l={};if(this.apiClient.isVertexAI()){const i=Pr(this.apiClient,e);s=b("{model}:predictLongRunning",i["_url"]);l=i["_query"];delete i["_url"];delete i["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(i),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json()));return r.then((e=>{const n=Cr(e);const t=new sn;Object.assign(t,n);return t}))}else{const n=_r(this.apiClient,e);s=b("{model}:predictLongRunning",n["_url"]);l=n["_query"];delete n["_url"];delete n["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(n),httpMethod:"POST",httpOptions:(i=e.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then((e=>e.json()));return r.then((e=>{const n=Or(e);const t=new sn;Object.assign(t,n);return t}))}}}
122
+ /**
123
+ * @license
124
+ * Copyright 2025 Google LLC
125
+ * SPDX-License-Identifier: Apache-2.0
126
+ */class jl extends w{constructor(e){super();this.apiClient=e}async getVideosOperation(e){const n=e.operation;const t=e.config;if(n.name===undefined||n.name===""){throw new Error("Operation name is required.")}if(this.apiClient.isVertexAI()){const e=n.name.split("/operations/")[0];let i=undefined;if(t&&"httpOptions"in t){i=t.httpOptions}const o=await this.fetchPredictVideosOperationInternal({operationName:n.name,resourceName:e,config:{httpOptions:i}});return n._fromAPIResponse({apiResponse:o,_isVertexAI:true})}else{const e=await this.getVideosOperationInternal({operationName:n.name,config:t});return n._fromAPIResponse({apiResponse:e,_isVertexAI:false})}}async get(e){const n=e.operation;const t=e.config;if(n.name===undefined||n.name===""){throw new Error("Operation name is required.")}if(this.apiClient.isVertexAI()){const e=n.name.split("/operations/")[0];let i=undefined;if(t&&"httpOptions"in t){i=t.httpOptions}const o=await this.fetchPredictVideosOperationInternal({operationName:n.name,resourceName:e,config:{httpOptions:i}});return n._fromAPIResponse({apiResponse:o,_isVertexAI:true})}else{const e=await this.getVideosOperationInternal({operationName:n.name,config:t});return n._fromAPIResponse({apiResponse:e,_isVertexAI:false})}}async getVideosOperationInternal(e){var n,t,i,o;let r;let s="";let l={};if(this.apiClient.isVertexAI()){const i=k(e);s=b("{operationName}",i["_url"]);l=i["_query"];delete i["_url"];delete i["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(i),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json()));return r}else{const n=U(e);s=b("{operationName}",n["_url"]);l=n["_query"];delete n["_url"];delete n["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(n),httpMethod:"GET",httpOptions:(i=e.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then((e=>e.json()));return r}}async fetchPredictVideosOperationInternal(e){var n,t;let i;let o="";let r={};if(this.apiClient.isVertexAI()){const s=C(e);o=b("{resourceName}:fetchPredictOperation",s["_url"]);r=s["_query"];delete s["_url"];delete s["_query"];i=this.apiClient.request({path:o,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json()));return i}else{throw new Error("This method is only supported by the Vertex AI.")}}}
127
+ /**
128
+ * @license
129
+ * Copyright 2025 Google LLC
130
+ * SPDX-License-Identifier: Apache-2.0
131
+ */function Fl(e){const n={};const t=S(e,["data"]);if(t!=null){T(n,["data"],t)}if(S(e,["displayName"])!==undefined){throw new Error("displayName parameter is not supported in Gemini API.")}const i=S(e,["mimeType"]);if(i!=null){T(n,["mimeType"],i)}return n}function ql(e){const n={};const t=S(e,["parts"]);if(t!=null){let e=t;if(Array.isArray(e)){e=e.map((e=>zl(e)))}T(n,["parts"],e)}const i=S(e,["role"]);if(i!=null){T(n,["role"],i)}return n}function Hl(e,n,t){const i={};const o=S(n,["expireTime"]);if(t!==undefined&&o!=null){T(t,["expireTime"],o)}const r=S(n,["newSessionExpireTime"]);if(t!==undefined&&r!=null){T(t,["newSessionExpireTime"],r)}const s=S(n,["uses"]);if(t!==undefined&&s!=null){T(t,["uses"],s)}const l=S(n,["liveConnectConstraints"]);if(t!==undefined&&l!=null){T(t,["bidiGenerateContentSetup"],Kl(e,l))}const u=S(n,["lockAdditionalFields"]);if(t!==undefined&&u!=null){T(t,["fieldMask"],u)}return i}function $l(e,n){const t={};const i=S(n,["config"]);if(i!=null){T(t,["config"],Hl(e,i,t))}return t}function Jl(e){const n={};if(S(e,["displayName"])!==undefined){throw new Error("displayName parameter is not supported in Gemini API.")}const t=S(e,["fileUri"]);if(t!=null){T(n,["fileUri"],t)}const i=S(e,["mimeType"]);if(i!=null){T(n,["mimeType"],i)}return n}function Vl(e){const n={};const t=S(e,["id"]);if(t!=null){T(n,["id"],t)}const i=S(e,["args"]);if(i!=null){T(n,["args"],i)}const o=S(e,["name"]);if(o!=null){T(n,["name"],o)}if(S(e,["partialArgs"])!==undefined){throw new Error("partialArgs parameter is not supported in Gemini API.")}if(S(e,["willContinue"])!==undefined){throw new Error("willContinue parameter is not supported in Gemini API.")}return n}function Bl(e){const n={};if(S(e,["authConfig"])!==undefined){throw new Error("authConfig parameter is not supported in Gemini API.")}const t=S(e,["enableWidget"]);if(t!=null){T(n,["enableWidget"],t)}return n}function Wl(e){const n={};const t=S(e,["searchTypes"]);if(t!=null){T(n,["searchTypes"],t)}if(S(e,["excludeDomains"])!==undefined){throw new Error("excludeDomains parameter is not supported in Gemini API.")}if(S(e,["blockingConfidence"])!==undefined){throw new Error("blockingConfidence parameter is not supported in Gemini API.")}const i=S(e,["timeRangeFilter"]);if(i!=null){T(n,["timeRangeFilter"],i)}return n}function Yl(e,n){const t={};const i=S(e,["generationConfig"]);if(n!==undefined&&i!=null){T(n,["setup","generationConfig"],i)}const o=S(e,["responseModalities"]);if(n!==undefined&&o!=null){T(n,["setup","generationConfig","responseModalities"],o)}const r=S(e,["temperature"]);if(n!==undefined&&r!=null){T(n,["setup","generationConfig","temperature"],r)}const s=S(e,["topP"]);if(n!==undefined&&s!=null){T(n,["setup","generationConfig","topP"],s)}const l=S(e,["topK"]);if(n!==undefined&&l!=null){T(n,["setup","generationConfig","topK"],l)}const u=S(e,["maxOutputTokens"]);if(n!==undefined&&u!=null){T(n,["setup","generationConfig","maxOutputTokens"],u)}const a=S(e,["mediaResolution"]);if(n!==undefined&&a!=null){T(n,["setup","generationConfig","mediaResolution"],a)}const c=S(e,["seed"]);if(n!==undefined&&c!=null){T(n,["setup","generationConfig","seed"],c)}const f=S(e,["speechConfig"]);if(n!==undefined&&f!=null){T(n,["setup","generationConfig","speechConfig"],qn(f))}const d=S(e,["thinkingConfig"]);if(n!==undefined&&d!=null){T(n,["setup","generationConfig","thinkingConfig"],d)}const p=S(e,["enableAffectiveDialog"]);if(n!==undefined&&p!=null){T(n,["setup","generationConfig","enableAffectiveDialog"],p)}const h=S(e,["systemInstruction"]);if(n!==undefined&&h!=null){T(n,["setup","systemInstruction"],ql(Un(h)))}const m=S(e,["tools"]);if(n!==undefined&&m!=null){let e=$n(m);if(Array.isArray(e)){e=e.map((e=>Ql(Hn(e))))}T(n,["setup","tools"],e)}const g=S(e,["sessionResumption"]);if(n!==undefined&&g!=null){T(n,["setup","sessionResumption"],Xl(g))}const y=S(e,["inputAudioTranscription"]);if(n!==undefined&&y!=null){T(n,["setup","inputAudioTranscription"],y)}const v=S(e,["outputAudioTranscription"]);if(n!==undefined&&v!=null){T(n,["setup","outputAudioTranscription"],v)}const E=S(e,["realtimeInputConfig"]);if(n!==undefined&&E!=null){T(n,["setup","realtimeInputConfig"],E)}const w=S(e,["contextWindowCompression"]);if(n!==undefined&&w!=null){T(n,["setup","contextWindowCompression"],w)}const b=S(e,["proactivity"]);if(n!==undefined&&b!=null){T(n,["setup","proactivity"],b)}if(S(e,["explicitVadSignal"])!==undefined){throw new Error("explicitVadSignal parameter is not supported in Gemini API.")}return t}function Kl(e,n){const t={};const i=S(n,["model"]);if(i!=null){T(t,["setup","model"],Sn(e,i))}const o=S(n,["config"]);if(o!=null){T(t,["config"],Yl(o,t))}return t}function zl(e){const n={};const t=S(e,["mediaResolution"]);if(t!=null){T(n,["mediaResolution"],t)}const i=S(e,["codeExecutionResult"]);if(i!=null){T(n,["codeExecutionResult"],i)}const o=S(e,["executableCode"]);if(o!=null){T(n,["executableCode"],o)}const r=S(e,["fileData"]);if(r!=null){T(n,["fileData"],Jl(r))}const s=S(e,["functionCall"]);if(s!=null){T(n,["functionCall"],Vl(s))}const l=S(e,["functionResponse"]);if(l!=null){T(n,["functionResponse"],l)}const u=S(e,["inlineData"]);if(u!=null){T(n,["inlineData"],Fl(u))}const a=S(e,["text"]);if(a!=null){T(n,["text"],a)}const c=S(e,["thought"]);if(c!=null){T(n,["thought"],c)}const f=S(e,["thoughtSignature"]);if(f!=null){T(n,["thoughtSignature"],f)}const d=S(e,["videoMetadata"]);if(d!=null){T(n,["videoMetadata"],d)}return n}function Xl(e){const n={};const t=S(e,["handle"]);if(t!=null){T(n,["handle"],t)}if(S(e,["transparent"])!==undefined){throw new Error("transparent parameter is not supported in Gemini API.")}return n}function Ql(e){const n={};if(S(e,["retrieval"])!==undefined){throw new Error("retrieval parameter is not supported in Gemini API.")}const t=S(e,["computerUse"]);if(t!=null){T(n,["computerUse"],t)}const i=S(e,["fileSearch"]);if(i!=null){T(n,["fileSearch"],i)}const o=S(e,["googleSearch"]);if(o!=null){T(n,["googleSearch"],Wl(o))}const r=S(e,["codeExecution"]);if(r!=null){T(n,["codeExecution"],r)}if(S(e,["enterpriseWebSearch"])!==undefined){throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.")}const s=S(e,["functionDeclarations"]);if(s!=null){let e=s;if(Array.isArray(e)){e=e.map((e=>e))}T(n,["functionDeclarations"],e)}const l=S(e,["googleMaps"]);if(l!=null){T(n,["googleMaps"],Bl(l))}const u=S(e,["googleSearchRetrieval"]);if(u!=null){T(n,["googleSearchRetrieval"],u)}const a=S(e,["urlContext"]);if(a!=null){T(n,["urlContext"],a)}const c=S(e,["mcpServers"]);if(c!=null){let e=c;if(Array.isArray(e)){e=e.map((e=>e))}T(n,["mcpServers"],e)}return n}
132
+ /**
133
+ * @license
134
+ * Copyright 2025 Google LLC
135
+ * SPDX-License-Identifier: Apache-2.0
136
+ */function Zl(e){const n=[];for(const t in e){if(Object.prototype.hasOwnProperty.call(e,t)){const i=e[t];if(typeof i==="object"&&i!=null&&Object.keys(i).length>0){const e=Object.keys(i).map((e=>`${t}.${e}`));n.push(...e)}else{n.push(t)}}}return n.join(",")}function eu(e,n){let t=null;const i=e["bidiGenerateContentSetup"];if(typeof i==="object"&&i!==null&&"setup"in i){const n=i.setup;if(typeof n==="object"&&n!==null){e["bidiGenerateContentSetup"]=n;t=n}else{delete e["bidiGenerateContentSetup"]}}else if(i!==undefined){delete e["bidiGenerateContentSetup"]}const o=e["fieldMask"];if(t){const i=Zl(t);if(Array.isArray(n===null||n===void 0?void 0:n.lockAdditionalFields)&&(n===null||n===void 0?void 0:n.lockAdditionalFields.length)===0){if(i){e["fieldMask"]=i}else{delete e["fieldMask"]}}else if((n===null||n===void 0?void 0:n.lockAdditionalFields)&&n.lockAdditionalFields.length>0&&o!==null&&Array.isArray(o)&&o.length>0){const n=["temperature","topK","topP","maxOutputTokens","responseModalities","seed","speechConfig"];let t=[];if(o.length>0){t=o.map((e=>{if(n.includes(e)){return`generationConfig.${e}`}return e}))}const r=[];if(i){r.push(i)}if(t.length>0){r.push(...t)}if(r.length>0){e["fieldMask"]=r.join(",")}else{delete e["fieldMask"]}}else{delete e["fieldMask"]}}else{if(o!==null&&Array.isArray(o)&&o.length>0){e["fieldMask"]=o.join(",")}else{delete e["fieldMask"]}}return e}class nu extends w{constructor(e){super();this.apiClient=e}async create(e){var n,t;let i;let o="";let r={};if(this.apiClient.isVertexAI()){throw new Error("The client.tokens.create method is only supported by the Gemini Developer API.")}else{const s=$l(this.apiClient,e);o=b("auth_tokens",s["_url"]);r=s["_query"];delete s["config"];delete s["_url"];delete s["_query"];const l=eu(s,e.config);i=this.apiClient.request({path:o,queryParams:r,body:JSON.stringify(l),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json()));return i.then((e=>e))}}}
137
+ /**
138
+ * @license
139
+ * Copyright 2025 Google LLC
140
+ * SPDX-License-Identifier: Apache-2.0
141
+ */function tu(e,n){const t={};const i=S(e,["force"]);if(n!==undefined&&i!=null){T(n,["_query","force"],i)}return t}function iu(e){const n={};const t=S(e,["name"]);if(t!=null){T(n,["_url","name"],t)}const i=S(e,["config"]);if(i!=null){tu(i,n)}return n}function ou(e){const n={};const t=S(e,["name"]);if(t!=null){T(n,["_url","name"],t)}return n}function ru(e,n){const t={};const i=S(e,["pageSize"]);if(n!==undefined&&i!=null){T(n,["_query","pageSize"],i)}const o=S(e,["pageToken"]);if(n!==undefined&&o!=null){T(n,["_query","pageToken"],o)}return t}function su(e){const n={};const t=S(e,["parent"]);if(t!=null){T(n,["_url","parent"],t)}const i=S(e,["config"]);if(i!=null){ru(i,n)}return n}function lu(e){const n={};const t=S(e,["sdkHttpResponse"]);if(t!=null){T(n,["sdkHttpResponse"],t)}const i=S(e,["nextPageToken"]);if(i!=null){T(n,["nextPageToken"],i)}const o=S(e,["documents"]);if(o!=null){let e=o;if(Array.isArray(e)){e=e.map((e=>e))}T(n,["documents"],e)}return n}
142
+ /**
143
+ * @license
144
+ * Copyright 2025 Google LLC
145
+ * SPDX-License-Identifier: Apache-2.0
146
+ */class uu extends w{constructor(e){super();this.apiClient=e;this.list=async e=>new ri(oi.PAGED_ITEM_DOCUMENTS,(n=>this.listInternal({parent:e.parent,config:n.config})),await this.listInternal(e),e)}async get(e){var n,t;let i;let o="";let r={};if(this.apiClient.isVertexAI()){throw new Error("This method is only supported by the Gemini Developer API.")}else{const s=ou(e);o=b("{name}",s["_url"]);r=s["_query"];delete s["_url"];delete s["_query"];i=this.apiClient.request({path:o,queryParams:r,body:JSON.stringify(s),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json()));return i.then((e=>e))}}async delete(e){var n,t;let i="";let o={};if(this.apiClient.isVertexAI()){throw new Error("This method is only supported by the Gemini Developer API.")}else{const r=iu(e);i=b("{name}",r["_url"]);o=r["_query"];delete r["_url"];delete r["_query"];await this.apiClient.request({path:i,queryParams:o,body:JSON.stringify(r),httpMethod:"DELETE",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal})}}async listInternal(e){var n,t;let i;let o="";let r={};if(this.apiClient.isVertexAI()){throw new Error("This method is only supported by the Gemini Developer API.")}else{const s=su(e);o=b("{parent}/documents",s["_url"]);r=s["_query"];delete s["_url"];delete s["_query"];i=this.apiClient.request({path:o,queryParams:r,body:JSON.stringify(s),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json()));return i.then((e=>{const n=lu(e);const t=new fn;Object.assign(t,n);return t}))}}}
147
+ /**
148
+ * @license
149
+ * Copyright 2025 Google LLC
150
+ * SPDX-License-Identifier: Apache-2.0
151
+ */class au extends w{constructor(e,n=new uu(e)){super();this.apiClient=e;this.documents=n;this.list=async(e={})=>new ri(oi.PAGED_ITEM_FILE_SEARCH_STORES,(e=>this.listInternal(e)),await this.listInternal(e),e)}async uploadToFileSearchStore(e){if(this.apiClient.isVertexAI()){throw new Error("Vertex AI does not support uploading files to a file search store.")}return this.apiClient.uploadFileToFileSearchStore(e.fileSearchStoreName,e.file,e.config)}async create(e){var n,t;let i;let o="";let r={};if(this.apiClient.isVertexAI()){throw new Error("This method is only supported by the Gemini Developer API.")}else{const s=Fs(e);o=b("fileSearchStores",s["_url"]);r=s["_query"];delete s["_url"];delete s["_query"];i=this.apiClient.request({path:o,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json()));return i.then((e=>e))}}async get(e){var n,t;let i;let o="";let r={};if(this.apiClient.isVertexAI()){throw new Error("This method is only supported by the Gemini Developer API.")}else{const s=$s(e);o=b("{name}",s["_url"]);r=s["_query"];delete s["_url"];delete s["_query"];i=this.apiClient.request({path:o,queryParams:r,body:JSON.stringify(s),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json()));return i.then((e=>e))}}async delete(e){var n,t;let i="";let o={};if(this.apiClient.isVertexAI()){throw new Error("This method is only supported by the Gemini Developer API.")}else{const r=Hs(e);i=b("{name}",r["_url"]);o=r["_query"];delete r["_url"];delete r["_query"];await this.apiClient.request({path:i,queryParams:o,body:JSON.stringify(r),httpMethod:"DELETE",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal})}}async listInternal(e){var n,t;let i;let o="";let r={};if(this.apiClient.isVertexAI()){throw new Error("This method is only supported by the Gemini Developer API.")}else{const s=Ks(e);o=b("fileSearchStores",s["_url"]);r=s["_query"];delete s["_url"];delete s["_query"];i=this.apiClient.request({path:o,queryParams:r,body:JSON.stringify(s),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json()));return i.then((e=>{const n=zs(e);const t=new dn;Object.assign(t,n);return t}))}}async uploadToFileSearchStoreInternal(e){var n,t;let i;let o="";let r={};if(this.apiClient.isVertexAI()){throw new Error("This method is only supported by the Gemini Developer API.")}else{const s=Qs(e);o=b("upload/v1beta/{file_search_store_name}:uploadToFileSearchStore",s["_url"]);r=s["_query"];delete s["_url"];delete s["_query"];i=this.apiClient.request({path:o,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json()));return i.then((e=>{const n=Zs(e);const t=new pn;Object.assign(t,n);return t}))}}async importFile(e){var n,t;let i;let o="";let r={};if(this.apiClient.isVertexAI()){throw new Error("This method is only supported by the Gemini Developer API.")}else{const s=Bs(e);o=b("{file_search_store_name}:importFile",s["_url"]);r=s["_query"];delete s["_url"];delete s["_query"];i=this.apiClient.request({path:o,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json()));return i.then((e=>{const n=Vs(e);const t=new hn;Object.assign(t,n);return t}))}}}
152
+ /**
153
+ * @license
154
+ * Copyright 2025 Google LLC
155
+ * SPDX-License-Identifier: Apache-2.0
156
+ */let cu=function(){const{crypto:e}=globalThis;if(e===null||e===void 0?void 0:e.randomUUID){cu=e.randomUUID.bind(e);return e.randomUUID()}const n=new Uint8Array(1);const t=e?()=>e.getRandomValues(n)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(e=>(+e^t()&15>>+e/4).toString(16)))};const fu=()=>cu()
157
+ /**
158
+ * @license
159
+ * Copyright 2025 Google LLC
160
+ * SPDX-License-Identifier: Apache-2.0
161
+ */;function du(e){return typeof e==="object"&&e!==null&&("name"in e&&e.name==="AbortError"||"message"in e&&String(e.message).includes("FetchRequestCanceledException"))}const pu=e=>{if(e instanceof Error)return e;if(typeof e==="object"&&e!==null){try{if(Object.prototype.toString.call(e)==="[object Error]"){const n=new Error(e.message,e.cause?{cause:e.cause}:{});if(e.stack)n.stack=e.stack;if(e.cause&&!n.cause)n.cause=e.cause;if(e.name)n.name=e.name;return n}}catch(e){}try{return new Error(JSON.stringify(e))}catch(e){}}return new Error(e)};
162
+ /**
163
+ * @license
164
+ * Copyright 2025 Google LLC
165
+ * SPDX-License-Identifier: Apache-2.0
166
+ */class hu extends Error{}class mu extends hu{constructor(e,n,t,i){super(`${mu.makeMessage(e,n,t)}`);this.status=e;this.headers=i;this.error=n}static makeMessage(e,n,t){const i=(n===null||n===void 0?void 0:n.message)?typeof n.message==="string"?n.message:JSON.stringify(n.message):n?JSON.stringify(n):t;if(e&&i){return`${e} ${i}`}if(e){return`${e} status code (no body)`}if(i){return i}return"(no status code or body)"}static generate(e,n,t,i){if(!e||!i){return new yu({message:t,cause:pu(n)})}const o=n;if(e===400){return new Eu(e,o,t,i)}if(e===401){return new wu(e,o,t,i)}if(e===403){return new bu(e,o,t,i)}if(e===404){return new Tu(e,o,t,i)}if(e===409){return new Su(e,o,t,i)}if(e===422){return new Iu(e,o,t,i)}if(e===429){return new Au(e,o,t,i)}if(e>=500){return new Ou(e,o,t,i)}return new mu(e,o,t,i)}}class gu extends mu{constructor({message:e}={}){super(undefined,undefined,e||"Request was aborted.",undefined)}}class yu extends mu{constructor({message:e,cause:n}){super(undefined,undefined,e||"Connection error.",undefined);if(n)this.cause=n}}class vu extends yu{constructor({message:e}={}){super({message:e!==null&&e!==void 0?e:"Request timed out."})}}class Eu extends mu{}class wu extends mu{}class bu extends mu{}class Tu extends mu{}class Su extends mu{}class Iu extends mu{}class Au extends mu{}class Ou extends mu{}
167
+ /**
168
+ * @license
169
+ * Copyright 2025 Google LLC
170
+ * SPDX-License-Identifier: Apache-2.0
171
+ */const Cu=/^[a-z][a-z0-9+.-]*:/i;const _u=e=>Cu.test(e);let Pu=e=>(Pu=Array.isArray,Pu(e));const Ru=Pu;let Nu=Ru;const Mu=Nu;function Du(e){if(!e)return true;for(const n in e)return false;return true}function Uu(e,n){return Object.prototype.hasOwnProperty.call(e,n)}const ku=(e,n)=>{if(typeof n!=="number"||!Number.isInteger(n)){throw new hu(`${e} must be an integer`)}if(n<0){throw new hu(`${e} must be a positive integer`)}return n};const Gu=e=>{try{return JSON.parse(e)}catch(e){return undefined}};
172
+ /**
173
+ * @license
174
+ * Copyright 2025 Google LLC
175
+ * SPDX-License-Identifier: Apache-2.0
176
+ */const xu=e=>new Promise((n=>setTimeout(n,e)))
177
+ /**
178
+ * @license
179
+ * Copyright 2025 Google LLC
180
+ * SPDX-License-Identifier: Apache-2.0
181
+ */;const Lu="0.0.1";
182
+ /**
183
+ * @license
184
+ * Copyright 2025 Google LLC
185
+ * SPDX-License-Identifier: Apache-2.0
186
+ */function ju(){if(typeof Deno!=="undefined"&&Deno.build!=null){return"deno"}if(typeof EdgeRuntime!=="undefined"){return"edge"}if(Object.prototype.toString.call(typeof globalThis.process!=="undefined"?globalThis.process:0)==="[object process]"){return"node"}return"unknown"}const Fu=()=>{var e,n,t,i,o;const r=ju();if(r==="deno"){return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Lu,"X-Stainless-OS":$u(Deno.build.os),"X-Stainless-Arch":Hu(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version==="string"?Deno.version:(n=(e=Deno.version)===null||e===void 0?void 0:e.deno)!==null&&n!==void 0?n:"unknown"}}if(typeof EdgeRuntime!=="undefined"){return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Lu,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version}}if(r==="node"){return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Lu,"X-Stainless-OS":$u((t=globalThis.process.platform)!==null&&t!==void 0?t:"unknown"),"X-Stainless-Arch":Hu((i=globalThis.process.arch)!==null&&i!==void 0?i:"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":(o=globalThis.process.version)!==null&&o!==void 0?o:"unknown"}}const s=qu();if(s){return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Lu,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${s.browser}`,"X-Stainless-Runtime-Version":s.version}}return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Lu,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function qu(){if(typeof navigator==="undefined"||!navigator){return null}const e=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(const{key:n,pattern:t}of e){const e=t.exec(navigator.userAgent);if(e){const t=e[1]||0;const i=e[2]||0;const o=e[3]||0;return{browser:n,version:`${t}.${i}.${o}`}}}return null}const Hu=e=>{if(e==="x32")return"x32";if(e==="x86_64"||e==="x64")return"x64";if(e==="arm")return"arm";if(e==="aarch64"||e==="arm64")return"arm64";if(e)return`other:${e}`;return"unknown"};const $u=e=>{e=e.toLowerCase();if(e.includes("ios"))return"iOS";if(e==="android")return"Android";if(e==="darwin")return"MacOS";if(e==="win32")return"Windows";if(e==="freebsd")return"FreeBSD";if(e==="openbsd")return"OpenBSD";if(e==="linux")return"Linux";if(e)return`Other:${e}`;return"Unknown"};let Ju;const Vu=()=>Ju!==null&&Ju!==void 0?Ju:Ju=Fu();
187
+ /**
188
+ * @license
189
+ * Copyright 2025 Google LLC
190
+ * SPDX-License-Identifier: Apache-2.0
191
+ */function Bu(){if(typeof fetch!=="undefined"){return fetch}throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new GeminiNextGenAPIClient({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function Wu(...e){const n=globalThis.ReadableStream;if(typeof n==="undefined"){throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`")}return new n(...e)}function Yu(e){let n=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return Wu({start(){},async pull(e){const{done:t,value:i}=await n.next();if(t){e.close()}else{e.enqueue(i)}},async cancel(){var e;await((e=n.return)===null||e===void 0?void 0:e.call(n))}})}function Ku(e){if(e[Symbol.asyncIterator])return e;const n=e.getReader();return{async next(){try{const e=await n.read();if(e===null||e===void 0?void 0:e.done)n.releaseLock();return e}catch(e){n.releaseLock();throw e}},async return(){const e=n.cancel();n.releaseLock();await e;return{done:true,value:undefined}},[Symbol.asyncIterator](){return this}}}async function zu(e){var n,t;if(e===null||typeof e!=="object")return;if(e[Symbol.asyncIterator]){await((t=(n=e[Symbol.asyncIterator]()).return)===null||t===void 0?void 0:t.call(n));return}const i=e.getReader();const o=i.cancel();i.releaseLock();await o}
192
+ /**
193
+ * @license
194
+ * Copyright 2025 Google LLC
195
+ * SPDX-License-Identifier: Apache-2.0
196
+ */const Xu=({headers:e,body:n})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(n)});
197
+ /**
198
+ * @license
199
+ * Copyright 2025 Google LLC
200
+ * SPDX-License-Identifier: Apache-2.0
201
+ */const Qu=()=>{var e;if(typeof File==="undefined"){const{process:n}=globalThis;const t=typeof((e=n===null||n===void 0?void 0:n.versions)===null||e===void 0?void 0:e.node)==="string"&&parseInt(n.versions.node.split("."))<20;throw new Error("`File` is not defined as a global, which is required for file uploads."+(t?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function Zu(e,n,t){Qu();return new File(e,n!==null&&n!==void 0?n:"unknown_file",t)}function ea(e){return(typeof e==="object"&&e!==null&&("name"in e&&e.name&&String(e.name)||"url"in e&&e.url&&String(e.url)||"filename"in e&&e.filename&&String(e.filename)||"path"in e&&e.path&&String(e.path))||"").split(/[\\/]/).pop()||undefined}const na=e=>e!=null&&typeof e==="object"&&typeof e[Symbol.asyncIterator]==="function"
202
+ /**
203
+ * @license
204
+ * Copyright 2025 Google LLC
205
+ * SPDX-License-Identifier: Apache-2.0
206
+ */;const ta=e=>e!=null&&typeof e==="object"&&typeof e.size==="number"&&typeof e.type==="string"&&typeof e.text==="function"&&typeof e.slice==="function"&&typeof e.arrayBuffer==="function";const ia=e=>e!=null&&typeof e==="object"&&typeof e.name==="string"&&typeof e.lastModified==="number"&&ta(e);const oa=e=>e!=null&&typeof e==="object"&&typeof e.url==="string"&&typeof e.blob==="function";async function ra(e,n,t){Qu();e=await e;if(ia(e)){if(e instanceof File){return e}return Zu([await e.arrayBuffer()],e.name)}if(oa(e)){const i=await e.blob();n||(n=new URL(e.url).pathname.split(/[\\/]/).pop());return Zu(await sa(i),n,t)}const i=await sa(e);n||(n=ea(e));if(!(t===null||t===void 0?void 0:t.type)){const e=i.find((e=>typeof e==="object"&&"type"in e&&e.type));if(typeof e==="string"){t=Object.assign(Object.assign({},t),{type:e})}}return Zu(i,n,t)}async function sa(e){var n,t,i,o;var r;let s=[];if(typeof e==="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer){s.push(e)}else if(ta(e)){s.push(e instanceof Blob?e:await e.arrayBuffer())}else if(na(e)){try{for(var l=true,u=Ji(e),a;a=await u.next(),n=a.done,!n;l=true){o=a.value;l=false;const e=o;s.push(...await sa(e))}}catch(e){t={error:e}}finally{try{if(!l&&!n&&(i=u.return))await i.call(u)}finally{if(t)throw t.error}}}else{const n=(r=e===null||e===void 0?void 0:e.constructor)===null||r===void 0?void 0:r.name;throw new Error(`Unexpected data type: ${typeof e}${n?`; constructor: ${n}`:""}${la(e)}`)}return s}function la(e){if(typeof e!=="object"||e===null)return"";const n=Object.getOwnPropertyNames(e);return`; props: [${n.map((e=>`"${e}"`)).join(", ")}]`}
207
+ /**
208
+ * @license
209
+ * Copyright 2025 Google LLC
210
+ * SPDX-License-Identifier: Apache-2.0
211
+ */class ua{constructor(e){this._client=e}}ua._key=[];
212
+ /**
213
+ * @license
214
+ * Copyright 2025 Google LLC
215
+ * SPDX-License-Identifier: Apache-2.0
216
+ */function aa(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}const ca=Object.freeze(Object.create(null));const fa=(e=aa)=>function n(t,...i){if(t.length===1)return t[0];let o=false;const r=[];const n=t.reduce(((n,t,s)=>{var l,u,a;if(/[?#]/.test(t)){o=true}const c=i[s];let f=(o?encodeURIComponent:e)(""+c);if(s!==i.length&&(c==null||typeof c==="object"&&c.toString===((a=Object.getPrototypeOf((u=Object.getPrototypeOf((l=c.hasOwnProperty)!==null&&l!==void 0?l:ca))!==null&&u!==void 0?u:ca))===null||a===void 0?void 0:a.toString))){f=c+"";r.push({start:n.length+t.length,length:f.length,error:`Value of type ${Object.prototype.toString.call(c).slice(8,-1)} is not a valid path parameter`})}return n+t+(s===i.length?"":f)}),"");const s=n.split(/[?#]/,1)[0];const l=/(^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;let u;while((u=l.exec(s))!==null){const e=u[0].startsWith("/");const n=e?1:0;const t=e?u[0].slice(1):u[0];r.push({start:u.index+n,length:t.length,error:`Value "${t}" can't be safely passed as a path parameter`})}r.sort(((e,n)=>e.start-n.start));if(r.length>0){let e=0;const t=r.reduce(((n,t)=>{const i=" ".repeat(t.start-e);const o="^".repeat(t.length);e=t.start+t.length;return n+i+o}),"");throw new hu(`Path parameters result in path with invalid segments:\n${r.map((e=>e.error)).join("\n")}\n${n}\n${t}`)}return n};const da=fa(aa);
217
+ /**
218
+ * @license
219
+ * Copyright 2025 Google LLC
220
+ * SPDX-License-Identifier: Apache-2.0
221
+ */class pa extends ua{create(e,n){var t;const{api_version:i=this._client.apiVersion}=e,o=Fi(e,["api_version"]);if("model"in o&&"agent_config"in o){throw new hu(`Invalid request: specified \`model\` and \`agent_config\`. If specifying \`model\`, use \`generation_config\`.`)}if("agent"in o&&"generation_config"in o){throw new hu(`Invalid request: specified \`agent\` and \`generation_config\`. If specifying \`agent\`, use \`agent_config\`.`)}return this._client.post(da`/${i}/interactions`,Object.assign(Object.assign({body:o},n),{stream:(t=e.stream)!==null&&t!==void 0?t:false}))}delete(e,n={},t){const{api_version:i=this._client.apiVersion}=n!==null&&n!==void 0?n:{};return this._client.delete(da`/${i}/interactions/${e}`,t)}cancel(e,n={},t){const{api_version:i=this._client.apiVersion}=n!==null&&n!==void 0?n:{};return this._client.post(da`/${i}/interactions/${e}/cancel`,t)}get(e,n={},t){var i;const o=n!==null&&n!==void 0?n:{},{api_version:r=this._client.apiVersion}=o,s=Fi(o,["api_version"]);return this._client.get(da`/${r}/interactions/${e}`,Object.assign(Object.assign({query:s},t),{stream:(i=n===null||n===void 0?void 0:n.stream)!==null&&i!==void 0?i:false}))}}pa._key=Object.freeze(["interactions"]);class ha extends pa{}
222
+ /**
223
+ * @license
224
+ * Copyright 2025 Google LLC
225
+ * SPDX-License-Identifier: Apache-2.0
226
+ */function ma(e){let n=0;for(const t of e){n+=t.length}const t=new Uint8Array(n);let i=0;for(const n of e){t.set(n,i);i+=n.length}return t}let ga;function ya(e){let n;return(ga!==null&&ga!==void 0?ga:(n=new globalThis.TextEncoder,ga=n.encode.bind(n)))(e)}let va;function Ea(e){let n;return(va!==null&&va!==void 0?va:(n=new globalThis.TextDecoder,va=n.decode.bind(n)))(e)}
227
+ /**
228
+ * @license
229
+ * Copyright 2025 Google LLC
230
+ * SPDX-License-Identifier: Apache-2.0
231
+ */class wa{constructor(){this.buffer=new Uint8Array;this.carriageReturnIndex=null}decode(e){if(e==null){return[]}const n=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==="string"?ya(e):e;this.buffer=ma([this.buffer,n]);const t=[];let i;while((i=ba(this.buffer,this.carriageReturnIndex))!=null){if(i.carriage&&this.carriageReturnIndex==null){this.carriageReturnIndex=i.index;continue}if(this.carriageReturnIndex!=null&&(i.index!==this.carriageReturnIndex+1||i.carriage)){t.push(Ea(this.buffer.subarray(0,this.carriageReturnIndex-1)));this.buffer=this.buffer.subarray(this.carriageReturnIndex);this.carriageReturnIndex=null;continue}const e=this.carriageReturnIndex!==null?i.preceding-1:i.preceding;const n=Ea(this.buffer.subarray(0,e));t.push(n);this.buffer=this.buffer.subarray(i.index);this.carriageReturnIndex=null}return t}flush(){if(!this.buffer.length){return[]}return this.decode("\n")}}wa.NEWLINE_CHARS=new Set(["\n","\r"]);wa.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function ba(e,n){const t=10;const i=13;for(let o=n!==null&&n!==void 0?n:0;o<e.length;o++){if(e[o]===t){return{preceding:o,index:o+1,carriage:false}}if(e[o]===i){return{preceding:o,index:o+1,carriage:true}}}return null}function Ta(e){const n=10;const t=13;for(let i=0;i<e.length-1;i++){if(e[i]===n&&e[i+1]===n){return i+2}if(e[i]===t&&e[i+1]===t){return i+2}if(e[i]===t&&e[i+1]===n&&i+3<e.length&&e[i+2]===t&&e[i+3]===n){return i+4}}return-1}
232
+ /**
233
+ * @license
234
+ * Copyright 2025 Google LLC
235
+ * SPDX-License-Identifier: Apache-2.0
236
+ */const Sa={off:0,error:200,warn:300,info:400,debug:500};const Ia=(e,n,t)=>{if(!e){return undefined}if(Uu(Sa,e)){return e}Pa(t).warn(`${n} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(Sa))}`);return undefined};function Aa(){}function Oa(e,n,t){if(!n||Sa[e]>Sa[t]){return Aa}else{return n[e].bind(n)}}const Ca={error:Aa,warn:Aa,info:Aa,debug:Aa};let _a=new WeakMap;function Pa(e){var n;const t=e.logger;const i=(n=e.logLevel)!==null&&n!==void 0?n:"off";if(!t){return Ca}const o=_a.get(t);if(o&&o[0]===i){return o[1]}const r={error:Oa("error",t,i),warn:Oa("warn",t,i),info:Oa("info",t,i),debug:Oa("debug",t,i)};_a.set(t,[i,r]);return r}const Ra=e=>{if(e.options){e.options=Object.assign({},e.options);delete e.options["headers"]}if(e.headers){e.headers=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map((([e,n])=>[e,e.toLowerCase()==="x-goog-api-key"||e.toLowerCase()==="authorization"||e.toLowerCase()==="cookie"||e.toLowerCase()==="set-cookie"?"***":n])))}if("retryOfRequestLogID"in e){if(e.retryOfRequestLogID){e.retryOf=e.retryOfRequestLogID}delete e.retryOfRequestLogID}return e};
237
+ /**
238
+ * @license
239
+ * Copyright 2025 Google LLC
240
+ * SPDX-License-Identifier: Apache-2.0
241
+ */class Na{constructor(e,n,t){this.iterator=e;this.controller=n;this.client=t}static fromSSEResponse(e,n,t){let i=false;const o=t?Pa(t):console;function r(){return $i(this,arguments,(function*t(){var r,s,l,u;if(i){throw new hu("Cannot iterate over a consumed stream, use `.tee()` to split the stream.")}i=true;let a=false;try{try{for(var c=true,f=Ji(Ma(e,n)),d;d=yield Hi(f.next()),r=d.done,!r;c=true){u=d.value;c=false;const e=u;if(a)continue;if(e.data.startsWith("[DONE]")){a=true;continue}else{try{yield yield Hi(JSON.parse(e.data))}catch(n){o.error(`Could not parse message into JSON:`,e.data);o.error(`From chunk:`,e.raw);throw n}}}}catch(e){s={error:e}}finally{try{if(!c&&!r&&(l=f.return))yield Hi(l.call(f))}finally{if(s)throw s.error}}a=true}catch(e){if(du(e))return yield Hi(void 0);throw e}finally{if(!a)n.abort()}}))}return new Na(r,n,t)}static fromReadableStream(e,n,t){let i=false;function o(){return $i(this,arguments,(function*n(){var t,i,o,r;const s=new wa;const l=Ku(e);try{for(var u=true,a=Ji(l),c;c=yield Hi(a.next()),t=c.done,!t;u=true){r=c.value;u=false;const e=r;for(const n of s.decode(e)){yield yield Hi(n)}}}catch(e){i={error:e}}finally{try{if(!u&&!t&&(o=a.return))yield Hi(o.call(a))}finally{if(i)throw i.error}}for(const e of s.flush()){yield yield Hi(e)}}))}function r(){return $i(this,arguments,(function*e(){var t,r,s,l;if(i){throw new hu("Cannot iterate over a consumed stream, use `.tee()` to split the stream.")}i=true;let u=false;try{try{for(var a=true,c=Ji(o()),f;f=yield Hi(c.next()),t=f.done,!t;a=true){l=f.value;a=false;const e=l;if(u)continue;if(e)yield yield Hi(JSON.parse(e))}}catch(e){r={error:e}}finally{try{if(!a&&!t&&(s=c.return))yield Hi(s.call(c))}finally{if(r)throw r.error}}u=true}catch(e){if(du(e))return yield Hi(void 0);throw e}finally{if(!u)n.abort()}}))}return new Na(r,n,t)}[Symbol.asyncIterator](){return this.iterator()}tee(){const e=[];const n=[];const t=this.iterator();const i=i=>({next:()=>{if(i.length===0){const i=t.next();e.push(i);n.push(i)}return i.shift()}});return[new Na((()=>i(e)),this.controller,this.client),new Na((()=>i(n)),this.controller,this.client)]}toReadableStream(){const e=this;let n;return Wu({async start(){n=e[Symbol.asyncIterator]()},async pull(e){try{const{value:t,done:i}=await n.next();if(i)return e.close();const o=ya(JSON.stringify(t)+"\n");e.enqueue(o)}catch(n){e.error(n)}},async cancel(){var e;await((e=n.return)===null||e===void 0?void 0:e.call(n))}})}}function Ma(e,n){return $i(this,arguments,(function*t(){var i,o,r,s;if(!e.body){n.abort();if(typeof globalThis.navigator!=="undefined"&&globalThis.navigator.product==="ReactNative"){throw new hu(`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`)}throw new hu(`Attempted to iterate over a response with no body`)}const l=new Ua;const u=new wa;const a=Ku(e.body);try{for(var c=true,f=Ji(Da(a)),d;d=yield Hi(f.next()),i=d.done,!i;c=true){s=d.value;c=false;const e=s;for(const n of u.decode(e)){const e=l.decode(n);if(e)yield yield Hi(e)}}}catch(e){o={error:e}}finally{try{if(!c&&!i&&(r=f.return))yield Hi(r.call(f))}finally{if(o)throw o.error}}for(const e of u.flush()){const n=l.decode(e);if(n)yield yield Hi(n)}}))}function Da(e){return $i(this,arguments,(function*n(){var t,i,o,r;let s=new Uint8Array;try{for(var l=true,u=Ji(e),a;a=yield Hi(u.next()),t=a.done,!t;l=true){r=a.value;l=false;const e=r;if(e==null){continue}const n=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==="string"?ya(e):e;let t=new Uint8Array(s.length+n.length);t.set(s);t.set(n,s.length);s=t;let i;while((i=Ta(s))!==-1){yield yield Hi(s.slice(0,i));s=s.slice(i)}}}catch(e){i={error:e}}finally{try{if(!l&&!t&&(o=u.return))yield Hi(o.call(u))}finally{if(i)throw i.error}}if(s.length>0){yield yield Hi(s)}}))}class Ua{constructor(){this.event=null;this.data=[];this.chunks=[]}decode(e){if(e.endsWith("\r")){e=e.substring(0,e.length-1)}if(!e){if(!this.event&&!this.data.length)return null;const e={event:this.event,data:this.data.join("\n"),raw:this.chunks};this.event=null;this.data=[];this.chunks=[];return e}this.chunks.push(e);if(e.startsWith(":")){return null}let[n,t,i]=ka(e,":");if(i.startsWith(" ")){i=i.substring(1)}if(n==="event"){this.event=i}else if(n==="data"){this.data.push(i)}return null}}function ka(e,n){const t=e.indexOf(n);if(t!==-1){return[e.substring(0,t),n,e.substring(t+n.length)]}return[e,"",""]}
242
+ /**
243
+ * @license
244
+ * Copyright 2025 Google LLC
245
+ * SPDX-License-Identifier: Apache-2.0
246
+ */async function Ga(e,n){const{response:t,requestLogID:i,retryOfRequestLogID:o,startTime:r}=n;const s=await(async()=>{var i;if(n.options.stream){Pa(e).debug("response",t.status,t.url,t.headers,t.body);if(n.options.__streamClass){return n.options.__streamClass.fromSSEResponse(t,n.controller,e)}return Na.fromSSEResponse(t,n.controller,e)}if(t.status===204){return null}if(n.options.__binaryResponse){return t}const o=t.headers.get("content-type");const r=(i=o===null||o===void 0?void 0:o.split(";")[0])===null||i===void 0?void 0:i.trim();const s=(r===null||r===void 0?void 0:r.includes("application/json"))||(r===null||r===void 0?void 0:r.endsWith("+json"));if(s){const e=t.headers.get("content-length");if(e==="0"){return undefined}const n=await t.json();return n}const l=await t.text();return l})();Pa(e).debug(`[${i}] response parsed`,Ra({retryOfRequestLogID:o,url:t.url,status:t.status,body:s,durationMs:Date.now()-r}));return s}
247
+ /**
248
+ * @license
249
+ * Copyright 2025 Google LLC
250
+ * SPDX-License-Identifier: Apache-2.0
251
+ */class xa extends Promise{constructor(e,n,t=Ga){super((e=>{e(null)}));this.responsePromise=n;this.parseResponse=t;this.client=e}_thenUnwrap(e){return new xa(this.client,this.responsePromise,(async(n,t)=>e(await this.parseResponse(n,t),t)))}asResponse(){return this.responsePromise.then((e=>e.response))}async withResponse(){const[e,n]=await Promise.all([this.parse(),this.asResponse()]);return{data:e,response:n}}parse(){if(!this.parsedPromise){this.parsedPromise=this.responsePromise.then((e=>this.parseResponse(this.client,e)))}return this.parsedPromise}then(e,n){return this.parse().then(e,n)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}}
252
+ /**
253
+ * @license
254
+ * Copyright 2025 Google LLC
255
+ * SPDX-License-Identifier: Apache-2.0
256
+ */const La=Symbol("brand.privateNullableHeaders");function*ja(e){if(!e)return;if(La in e){const{values:n,nulls:t}=e;yield*n.entries();for(const e of t){yield[e,null]}return}let n=false;let t;if(e instanceof Headers){t=e.entries()}else if(Mu(e)){t=e}else{n=true;t=Object.entries(e!==null&&e!==void 0?e:{})}for(let e of t){const t=e[0];if(typeof t!=="string")throw new TypeError("expected header name to be a string");const i=Mu(e[1])?e[1]:[e[1]];let o=false;for(const e of i){if(e===undefined)continue;if(n&&!o){o=true;yield[t,null]}yield[t,e]}}}const Fa=e=>{const n=new Headers;const t=new Set;for(const i of e){const e=new Set;for(const[o,r]of ja(i)){const i=o.toLowerCase();if(!e.has(i)){n.delete(o);e.add(i)}if(r===null){n.delete(o);t.add(i)}else{n.append(o,r);t.delete(i)}}}return{[La]:true,values:n,nulls:t}};
257
+ /**
258
+ * @license
259
+ * Copyright 2025 Google LLC
260
+ * SPDX-License-Identifier: Apache-2.0
261
+ */const qa=e=>{var n,t,i,o,r,s;if(typeof globalThis.process!=="undefined"){return(i=(t=(n=globalThis.process.env)===null||n===void 0?void 0:n[e])===null||t===void 0?void 0:t.trim())!==null&&i!==void 0?i:undefined}if(typeof globalThis.Deno!=="undefined"){return(s=(r=(o=globalThis.Deno.env)===null||o===void 0?void 0:o.get)===null||r===void 0?void 0:r.call(o,e))===null||s===void 0?void 0:s.trim()}return undefined};
262
+ /**
263
+ * @license
264
+ * Copyright 2025 Google LLC
265
+ * SPDX-License-Identifier: Apache-2.0
266
+ */var Ha;class $a{constructor(e){var n,t,i,o,r,s,l;var{baseURL:u=qa("GEMINI_NEXT_GEN_API_BASE_URL"),apiKey:a=((n=qa("GEMINI_API_KEY"))!==null&&n!==void 0?n:null),apiVersion:c="v1beta"}=e,f=Fi(e,["baseURL","apiKey","apiVersion"]);const d=Object.assign(Object.assign({apiKey:a,apiVersion:c},f),{baseURL:u||`https://generativelanguage.googleapis.com`});this.baseURL=d.baseURL;this.timeout=(t=d.timeout)!==null&&t!==void 0?t:$a.DEFAULT_TIMEOUT;this.logger=(i=d.logger)!==null&&i!==void 0?i:console;const p="warn";this.logLevel=p;this.logLevel=(r=(o=Ia(d.logLevel,"ClientOptions.logLevel",this))!==null&&o!==void 0?o:Ia(qa("GEMINI_NEXT_GEN_API_LOG"),"process.env['GEMINI_NEXT_GEN_API_LOG']",this))!==null&&r!==void 0?r:p;this.fetchOptions=d.fetchOptions;this.maxRetries=(s=d.maxRetries)!==null&&s!==void 0?s:2;this.fetch=(l=d.fetch)!==null&&l!==void 0?l:Bu();this.encoder=Xu;this._options=d;this.apiKey=a;this.apiVersion=c;this.clientAdapter=d.clientAdapter}withOptions(e){const n=new this.constructor(Object.assign(Object.assign(Object.assign({},this._options),{baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,apiVersion:this.apiVersion}),e));return n}baseURLOverridden(){return this.baseURL!=="https://generativelanguage.googleapis.com"}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:n}){if(e.has("authorization")||e.has("x-goog-api-key")){return}if(this.apiKey&&e.get("x-goog-api-key")){return}if(n.has("x-goog-api-key")){return}throw new Error('Could not resolve authentication method. Expected the apiKey to be set. Or for the "x-goog-api-key" headers to be explicitly omitted')}async authHeaders(e){const n=Fa([e.headers]);if(n.values.has("authorization")||n.values.has("x-goog-api-key")){return undefined}if(this.apiKey){return Fa([{"x-goog-api-key":this.apiKey}])}if(this.clientAdapter.isVertexAI()){return Fa([await this.clientAdapter.getAuthHeaders()])}return undefined}stringifyQuery(e){return Object.entries(e).filter((([e,n])=>typeof n!=="undefined")).map((([e,n])=>{if(typeof n==="string"||typeof n==="number"||typeof n==="boolean"){return`${encodeURIComponent(e)}=${encodeURIComponent(n)}`}if(n===null){return`${encodeURIComponent(e)}=`}throw new hu(`Cannot stringify type ${typeof n}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)})).join("&")}getUserAgent(){return`${this.constructor.name}/JS ${Lu}`}defaultIdempotencyKey(){return`stainless-node-retry-${fu()}`}makeStatusError(e,n,t,i){return mu.generate(e,n,t,i)}buildURL(e,n,t){const i=!this.baseURLOverridden()&&t||this.baseURL;const o=_u(e)?new URL(e):new URL(i+(i.endsWith("/")&&e.startsWith("/")?e.slice(1):e));const r=this.defaultQuery();if(!Du(r)){n=Object.assign(Object.assign({},r),n)}if(typeof n==="object"&&n&&!Array.isArray(n)){o.search=this.stringifyQuery(n)}return o.toString()}async prepareOptions(e){if(this.clientAdapter&&this.clientAdapter.isVertexAI()&&!e.path.startsWith(`/${this.apiVersion}/projects/`)){const n=e.path.slice(this.apiVersion.length+1);e.path=`/${this.apiVersion}/projects/${this.clientAdapter.getProject()}/locations/${this.clientAdapter.getLocation()}${n}`}}async prepareRequest(e,{url:n,options:t}){}get(e,n){return this.methodRequest("get",e,n)}post(e,n){return this.methodRequest("post",e,n)}patch(e,n){return this.methodRequest("patch",e,n)}put(e,n){return this.methodRequest("put",e,n)}delete(e,n){return this.methodRequest("delete",e,n)}methodRequest(e,n,t){return this.request(Promise.resolve(t).then((t=>Object.assign({method:e,path:n},t))))}request(e,n=null){return new xa(this,this.makeRequest(e,n,undefined))}async makeRequest(e,n,t){var i,o,r;const s=await e;const l=(i=s.maxRetries)!==null&&i!==void 0?i:this.maxRetries;if(n==null){n=l}await this.prepareOptions(s);const{req:u,url:a,timeout:c}=await this.buildRequest(s,{retryCount:l-n});await this.prepareRequest(u,{url:a,options:s});const f="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0");const d=t===undefined?"":`, retryOf: ${t}`;const p=Date.now();Pa(this).debug(`[${f}] sending request`,Ra({retryOfRequestLogID:t,method:s.method,url:a,options:s,headers:u.headers}));if((o=s.signal)===null||o===void 0?void 0:o.aborted){throw new gu}const h=new AbortController;const m=await this.fetchWithTimeout(a,u,c,h).catch(pu);const g=Date.now();if(m instanceof globalThis.Error){const e=`retrying, ${n} attempts remaining`;if((r=s.signal)===null||r===void 0?void 0:r.aborted){throw new gu}const i=du(m)||/timed? ?out/i.test(String(m)+("cause"in m?String(m.cause):""));if(n){Pa(this).info(`[${f}] connection ${i?"timed out":"failed"} - ${e}`);Pa(this).debug(`[${f}] connection ${i?"timed out":"failed"} (${e})`,Ra({retryOfRequestLogID:t,url:a,durationMs:g-p,message:m.message}));return this.retryRequest(s,n,t!==null&&t!==void 0?t:f)}Pa(this).info(`[${f}] connection ${i?"timed out":"failed"} - error; no more retries left`);Pa(this).debug(`[${f}] connection ${i?"timed out":"failed"} (error; no more retries left)`,Ra({retryOfRequestLogID:t,url:a,durationMs:g-p,message:m.message}));if(i){throw new vu}throw new yu({cause:m})}const y=`[${f}${d}] ${u.method} ${a} ${m.ok?"succeeded":"failed"} with status ${m.status} in ${g-p}ms`;if(!m.ok){const e=await this.shouldRetry(m);if(n&&e){const e=`retrying, ${n} attempts remaining`;await zu(m.body);Pa(this).info(`${y} - ${e}`);Pa(this).debug(`[${f}] response error (${e})`,Ra({retryOfRequestLogID:t,url:m.url,status:m.status,headers:m.headers,durationMs:g-p}));return this.retryRequest(s,n,t!==null&&t!==void 0?t:f,m.headers)}const i=e?`error; no more retries left`:`error; not retryable`;Pa(this).info(`${y} - ${i}`);const o=await m.text().catch((e=>pu(e).message));const r=Gu(o);const l=r?undefined:o;Pa(this).debug(`[${f}] response error (${i})`,Ra({retryOfRequestLogID:t,url:m.url,status:m.status,headers:m.headers,message:l,durationMs:Date.now()-p}));const u=this.makeStatusError(m.status,r,l,m.headers);throw u}Pa(this).info(y);Pa(this).debug(`[${f}] response start`,Ra({retryOfRequestLogID:t,url:m.url,status:m.status,headers:m.headers,durationMs:g-p}));return{response:m,options:s,controller:h,requestLogID:f,retryOfRequestLogID:t,startTime:p}}async fetchWithTimeout(e,n,t,i){const o=n||{},{signal:r,method:s}=o,l=Fi(o,["signal","method"]);const u=this._makeAbort(i);if(r)r.addEventListener("abort",u,{once:true});const a=setTimeout(u,t);const c=globalThis.ReadableStream&&l.body instanceof globalThis.ReadableStream||typeof l.body==="object"&&l.body!==null&&Symbol.asyncIterator in l.body;const f=Object.assign(Object.assign(Object.assign({signal:i.signal},c?{duplex:"half"}:{}),{method:"GET"}),l);if(s){f.method=s.toUpperCase()}try{return await this.fetch.call(undefined,e,f)}finally{clearTimeout(a)}}async shouldRetry(e){const n=e.headers.get("x-should-retry");if(n==="true")return true;if(n==="false")return false;if(e.status===408)return true;if(e.status===409)return true;if(e.status===429)return true;if(e.status>=500)return true;return false}async retryRequest(e,n,t,i){var o;let r;const s=i===null||i===void 0?void 0:i.get("retry-after-ms");if(s){const e=parseFloat(s);if(!Number.isNaN(e)){r=e}}const l=i===null||i===void 0?void 0:i.get("retry-after");if(l&&!r){const e=parseFloat(l);if(!Number.isNaN(e)){r=e*1e3}else{r=Date.parse(l)-Date.now()}}if(!(r&&0<=r&&r<60*1e3)){const t=(o=e.maxRetries)!==null&&o!==void 0?o:this.maxRetries;r=this.calculateDefaultRetryTimeoutMillis(n,t)}await xu(r);return this.makeRequest(e,n-1,t)}calculateDefaultRetryTimeoutMillis(e,n){const t=.5;const i=8;const o=n-e;const r=Math.min(t*Math.pow(2,o),i);const s=1-Math.random()*.25;return r*s*1e3}async buildRequest(e,{retryCount:n=0}={}){var t,i,o;const r=Object.assign({},e);const{method:s,path:l,query:u,defaultBaseURL:a}=r;const c=this.buildURL(l,u,a);if("timeout"in r)ku("timeout",r.timeout);r.timeout=(t=r.timeout)!==null&&t!==void 0?t:this.timeout;const{bodyHeaders:f,body:d}=this.buildBody({options:r});const p=await this.buildHeaders({options:e,method:s,bodyHeaders:f,retryCount:n});const h=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({method:s,headers:p},r.signal&&{signal:r.signal}),globalThis.ReadableStream&&d instanceof globalThis.ReadableStream&&{duplex:"half"}),d&&{body:d}),(i=this.fetchOptions)!==null&&i!==void 0?i:{}),(o=r.fetchOptions)!==null&&o!==void 0?o:{});return{req:h,url:c,timeout:r.timeout}}async buildHeaders({options:e,method:n,bodyHeaders:t,retryCount:i}){let o={};if(this.idempotencyHeader&&n!=="get"){if(!e.idempotencyKey)e.idempotencyKey=this.defaultIdempotencyKey();o[this.idempotencyHeader]=e.idempotencyKey}const r=await this.authHeaders(e);let s=Fa([o,Object.assign(Object.assign({Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(i)},e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{}),Vu()),this._options.defaultHeaders,t,e.headers,r]);this.validateHeaders(s);return s.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:n}}){if(!e){return{bodyHeaders:undefined,body:undefined}}const t=Fa([n]);if(ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e==="string"&&t.values.has("content-type")||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||globalThis.ReadableStream&&e instanceof globalThis.ReadableStream){return{bodyHeaders:undefined,body:e}}else if(typeof e==="object"&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&typeof e.next==="function")){return{bodyHeaders:undefined,body:Yu(e)}}else if(typeof e==="object"&&t.values.get("content-type")==="application/x-www-form-urlencoded"){return{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(e)}}else{return this.encoder({body:e,headers:t})}}}$a.DEFAULT_TIMEOUT=6e4;class Ja extends $a{constructor(){super(...arguments);this.interactions=new ha(this)}}Ha=Ja;Ja.GeminiNextGenAPIClient=Ha;Ja.GeminiNextGenAPIClientError=hu;Ja.APIError=mu;Ja.APIConnectionError=yu;Ja.APIConnectionTimeoutError=vu;Ja.APIUserAbortError=gu;Ja.NotFoundError=Tu;Ja.ConflictError=Su;Ja.RateLimitError=Au;Ja.BadRequestError=Eu;Ja.AuthenticationError=wu;Ja.InternalServerError=Ou;Ja.PermissionDeniedError=bu;Ja.UnprocessableEntityError=Iu;Ja.toFile=ra;Ja.Interactions=ha;
267
+ /**
268
+ * @license
269
+ * Copyright 2025 Google LLC
270
+ * SPDX-License-Identifier: Apache-2.0
271
+ */function Va(e,n){const t={};const i=S(e,["name"]);if(i!=null){T(t,["_url","name"],i)}return t}function Ba(e,n){const t={};const i=S(e,["name"]);if(i!=null){T(t,["_url","name"],i)}return t}function Wa(e,n){const t={};const i=S(e,["sdkHttpResponse"]);if(i!=null){T(t,["sdkHttpResponse"],i)}return t}function Ya(e,n){const t={};const i=S(e,["sdkHttpResponse"]);if(i!=null){T(t,["sdkHttpResponse"],i)}return t}function Ka(e,n,t){const i={};if(S(e,["validationDataset"])!==undefined){throw new Error("validationDataset parameter is not supported in Gemini API.")}const o=S(e,["tunedModelDisplayName"]);if(n!==undefined&&o!=null){T(n,["displayName"],o)}if(S(e,["description"])!==undefined){throw new Error("description parameter is not supported in Gemini API.")}const r=S(e,["epochCount"]);if(n!==undefined&&r!=null){T(n,["tuningTask","hyperparameters","epochCount"],r)}const s=S(e,["learningRateMultiplier"]);if(s!=null){T(i,["tuningTask","hyperparameters","learningRateMultiplier"],s)}if(S(e,["exportLastCheckpointOnly"])!==undefined){throw new Error("exportLastCheckpointOnly parameter is not supported in Gemini API.")}if(S(e,["preTunedModelCheckpointId"])!==undefined){throw new Error("preTunedModelCheckpointId parameter is not supported in Gemini API.")}if(S(e,["adapterSize"])!==undefined){throw new Error("adapterSize parameter is not supported in Gemini API.")}if(S(e,["tuningMode"])!==undefined){throw new Error("tuningMode parameter is not supported in Gemini API.")}if(S(e,["customBaseModel"])!==undefined){throw new Error("customBaseModel parameter is not supported in Gemini API.")}const l=S(e,["batchSize"]);if(n!==undefined&&l!=null){T(n,["tuningTask","hyperparameters","batchSize"],l)}const u=S(e,["learningRate"]);if(n!==undefined&&u!=null){T(n,["tuningTask","hyperparameters","learningRate"],u)}if(S(e,["labels"])!==undefined){throw new Error("labels parameter is not supported in Gemini API.")}if(S(e,["beta"])!==undefined){throw new Error("beta parameter is not supported in Gemini API.")}if(S(e,["baseTeacherModel"])!==undefined){throw new Error("baseTeacherModel parameter is not supported in Gemini API.")}if(S(e,["tunedTeacherModelSource"])!==undefined){throw new Error("tunedTeacherModelSource parameter is not supported in Gemini API.")}if(S(e,["sftLossWeightMultiplier"])!==undefined){throw new Error("sftLossWeightMultiplier parameter is not supported in Gemini API.")}if(S(e,["outputUri"])!==undefined){throw new Error("outputUri parameter is not supported in Gemini API.")}if(S(e,["encryptionSpec"])!==undefined){throw new Error("encryptionSpec parameter is not supported in Gemini API.")}return i}function za(e,n,t){const i={};let o=S(t,["config","method"]);if(o===undefined){o="SUPERVISED_FINE_TUNING"}if(o==="SUPERVISED_FINE_TUNING"){const t=S(e,["validationDataset"]);if(n!==undefined&&t!=null){T(n,["supervisedTuningSpec"],pc(t))}}else if(o==="PREFERENCE_TUNING"){const t=S(e,["validationDataset"]);if(n!==undefined&&t!=null){T(n,["preferenceOptimizationSpec"],pc(t))}}else if(o==="DISTILLATION"){const t=S(e,["validationDataset"]);if(n!==undefined&&t!=null){T(n,["distillationSpec"],pc(t))}}const r=S(e,["tunedModelDisplayName"]);if(n!==undefined&&r!=null){T(n,["tunedModelDisplayName"],r)}const s=S(e,["description"]);if(n!==undefined&&s!=null){T(n,["description"],s)}let l=S(t,["config","method"]);if(l===undefined){l="SUPERVISED_FINE_TUNING"}if(l==="SUPERVISED_FINE_TUNING"){const t=S(e,["epochCount"]);if(n!==undefined&&t!=null){T(n,["supervisedTuningSpec","hyperParameters","epochCount"],t)}}else if(l==="PREFERENCE_TUNING"){const t=S(e,["epochCount"]);if(n!==undefined&&t!=null){T(n,["preferenceOptimizationSpec","hyperParameters","epochCount"],t)}}else if(l==="DISTILLATION"){const t=S(e,["epochCount"]);if(n!==undefined&&t!=null){T(n,["distillationSpec","hyperParameters","epochCount"],t)}}let u=S(t,["config","method"]);if(u===undefined){u="SUPERVISED_FINE_TUNING"}if(u==="SUPERVISED_FINE_TUNING"){const t=S(e,["learningRateMultiplier"]);if(n!==undefined&&t!=null){T(n,["supervisedTuningSpec","hyperParameters","learningRateMultiplier"],t)}}else if(u==="PREFERENCE_TUNING"){const t=S(e,["learningRateMultiplier"]);if(n!==undefined&&t!=null){T(n,["preferenceOptimizationSpec","hyperParameters","learningRateMultiplier"],t)}}else if(u==="DISTILLATION"){const t=S(e,["learningRateMultiplier"]);if(n!==undefined&&t!=null){T(n,["distillationSpec","hyperParameters","learningRateMultiplier"],t)}}let a=S(t,["config","method"]);if(a===undefined){a="SUPERVISED_FINE_TUNING"}if(a==="SUPERVISED_FINE_TUNING"){const t=S(e,["exportLastCheckpointOnly"]);if(n!==undefined&&t!=null){T(n,["supervisedTuningSpec","exportLastCheckpointOnly"],t)}}else if(a==="PREFERENCE_TUNING"){const t=S(e,["exportLastCheckpointOnly"]);if(n!==undefined&&t!=null){T(n,["preferenceOptimizationSpec","exportLastCheckpointOnly"],t)}}else if(a==="DISTILLATION"){const t=S(e,["exportLastCheckpointOnly"]);if(n!==undefined&&t!=null){T(n,["distillationSpec","exportLastCheckpointOnly"],t)}}let c=S(t,["config","method"]);if(c===undefined){c="SUPERVISED_FINE_TUNING"}if(c==="SUPERVISED_FINE_TUNING"){const t=S(e,["adapterSize"]);if(n!==undefined&&t!=null){T(n,["supervisedTuningSpec","hyperParameters","adapterSize"],t)}}else if(c==="PREFERENCE_TUNING"){const t=S(e,["adapterSize"]);if(n!==undefined&&t!=null){T(n,["preferenceOptimizationSpec","hyperParameters","adapterSize"],t)}}else if(c==="DISTILLATION"){const t=S(e,["adapterSize"]);if(n!==undefined&&t!=null){T(n,["distillationSpec","hyperParameters","adapterSize"],t)}}let f=S(t,["config","method"]);if(f===undefined){f="SUPERVISED_FINE_TUNING"}if(f==="SUPERVISED_FINE_TUNING"){const t=S(e,["tuningMode"]);if(n!==undefined&&t!=null){T(n,["supervisedTuningSpec","tuningMode"],t)}}const d=S(e,["customBaseModel"]);if(n!==undefined&&d!=null){T(n,["customBaseModel"],d)}let p=S(t,["config","method"]);if(p===undefined){p="SUPERVISED_FINE_TUNING"}if(p==="SUPERVISED_FINE_TUNING"){const t=S(e,["batchSize"]);if(n!==undefined&&t!=null){T(n,["supervisedTuningSpec","hyperParameters","batchSize"],t)}}let h=S(t,["config","method"]);if(h===undefined){h="SUPERVISED_FINE_TUNING"}if(h==="SUPERVISED_FINE_TUNING"){const t=S(e,["learningRate"]);if(n!==undefined&&t!=null){T(n,["supervisedTuningSpec","hyperParameters","learningRate"],t)}}const m=S(e,["labels"]);if(n!==undefined&&m!=null){T(n,["labels"],m)}const g=S(e,["beta"]);if(n!==undefined&&g!=null){T(n,["preferenceOptimizationSpec","hyperParameters","beta"],g)}const y=S(e,["baseTeacherModel"]);if(n!==undefined&&y!=null){T(n,["distillationSpec","baseTeacherModel"],y)}const v=S(e,["tunedTeacherModelSource"]);if(n!==undefined&&v!=null){T(n,["distillationSpec","tunedTeacherModelSource"],v)}const E=S(e,["sftLossWeightMultiplier"]);if(n!==undefined&&E!=null){T(n,["distillationSpec","hyperParameters","sftLossWeightMultiplier"],E)}const w=S(e,["outputUri"]);if(n!==undefined&&w!=null){T(n,["outputUri"],w)}const b=S(e,["encryptionSpec"]);if(n!==undefined&&b!=null){T(n,["encryptionSpec"],b)}return i}function Xa(e,n){const t={};const i=S(e,["baseModel"]);if(i!=null){T(t,["baseModel"],i)}const o=S(e,["preTunedModel"]);if(o!=null){T(t,["preTunedModel"],o)}const r=S(e,["trainingDataset"]);if(r!=null){uc(r)}const s=S(e,["config"]);if(s!=null){Ka(s,t)}return t}function Qa(e,n){const t={};const i=S(e,["baseModel"]);if(i!=null){T(t,["baseModel"],i)}const o=S(e,["preTunedModel"]);if(o!=null){T(t,["preTunedModel"],o)}const r=S(e,["trainingDataset"]);if(r!=null){ac(r,t,n)}const s=S(e,["config"]);if(s!=null){za(s,t,n)}return t}function Za(e,n){const t={};const i=S(e,["name"]);if(i!=null){T(t,["_url","name"],i)}return t}function ec(e,n){const t={};const i=S(e,["name"]);if(i!=null){T(t,["_url","name"],i)}return t}function nc(e,n,t){const i={};const o=S(e,["pageSize"]);if(n!==undefined&&o!=null){T(n,["_query","pageSize"],o)}const r=S(e,["pageToken"]);if(n!==undefined&&r!=null){T(n,["_query","pageToken"],r)}const s=S(e,["filter"]);if(n!==undefined&&s!=null){T(n,["_query","filter"],s)}return i}function tc(e,n,t){const i={};const o=S(e,["pageSize"]);if(n!==undefined&&o!=null){T(n,["_query","pageSize"],o)}const r=S(e,["pageToken"]);if(n!==undefined&&r!=null){T(n,["_query","pageToken"],r)}const s=S(e,["filter"]);if(n!==undefined&&s!=null){T(n,["_query","filter"],s)}return i}function ic(e,n){const t={};const i=S(e,["config"]);if(i!=null){nc(i,t)}return t}function oc(e,n){const t={};const i=S(e,["config"]);if(i!=null){tc(i,t)}return t}function rc(e,n){const t={};const i=S(e,["sdkHttpResponse"]);if(i!=null){T(t,["sdkHttpResponse"],i)}const o=S(e,["nextPageToken"]);if(o!=null){T(t,["nextPageToken"],o)}const r=S(e,["tunedModels"]);if(r!=null){let e=r;if(Array.isArray(e)){e=e.map((e=>cc(e)))}T(t,["tuningJobs"],e)}return t}function sc(e,n){const t={};const i=S(e,["sdkHttpResponse"]);if(i!=null){T(t,["sdkHttpResponse"],i)}const o=S(e,["nextPageToken"]);if(o!=null){T(t,["nextPageToken"],o)}const r=S(e,["tuningJobs"]);if(r!=null){let e=r;if(Array.isArray(e)){e=e.map((e=>fc(e)))}T(t,["tuningJobs"],e)}return t}function lc(e,n){const t={};const i=S(e,["name"]);if(i!=null){T(t,["model"],i)}const o=S(e,["name"]);if(o!=null){T(t,["endpoint"],o)}return t}function uc(e,n){const t={};if(S(e,["gcsUri"])!==undefined){throw new Error("gcsUri parameter is not supported in Gemini API.")}if(S(e,["vertexDatasetResource"])!==undefined){throw new Error("vertexDatasetResource parameter is not supported in Gemini API.")}const i=S(e,["examples"]);if(i!=null){let e=i;if(Array.isArray(e)){e=e.map((e=>e))}T(t,["examples","examples"],e)}return t}function ac(e,n,t){const i={};let o=S(t,["config","method"]);if(o===undefined){o="SUPERVISED_FINE_TUNING"}if(o==="SUPERVISED_FINE_TUNING"){const t=S(e,["gcsUri"]);if(n!==undefined&&t!=null){T(n,["supervisedTuningSpec","trainingDatasetUri"],t)}}else if(o==="PREFERENCE_TUNING"){const t=S(e,["gcsUri"]);if(n!==undefined&&t!=null){T(n,["preferenceOptimizationSpec","trainingDatasetUri"],t)}}else if(o==="DISTILLATION"){const t=S(e,["gcsUri"]);if(n!==undefined&&t!=null){T(n,["distillationSpec","promptDatasetUri"],t)}}let r=S(t,["config","method"]);if(r===undefined){r="SUPERVISED_FINE_TUNING"}if(r==="SUPERVISED_FINE_TUNING"){const t=S(e,["vertexDatasetResource"]);if(n!==undefined&&t!=null){T(n,["supervisedTuningSpec","trainingDatasetUri"],t)}}else if(r==="PREFERENCE_TUNING"){const t=S(e,["vertexDatasetResource"]);if(n!==undefined&&t!=null){T(n,["preferenceOptimizationSpec","trainingDatasetUri"],t)}}else if(r==="DISTILLATION"){const t=S(e,["vertexDatasetResource"]);if(n!==undefined&&t!=null){T(n,["distillationSpec","promptDatasetUri"],t)}}if(S(e,["examples"])!==undefined){throw new Error("examples parameter is not supported in Vertex AI.")}return i}function cc(e,n){const t={};const i=S(e,["sdkHttpResponse"]);if(i!=null){T(t,["sdkHttpResponse"],i)}const o=S(e,["name"]);if(o!=null){T(t,["name"],o)}const r=S(e,["state"]);if(r!=null){T(t,["state"],Bn(r))}const s=S(e,["createTime"]);if(s!=null){T(t,["createTime"],s)}const l=S(e,["tuningTask","startTime"]);if(l!=null){T(t,["startTime"],l)}const u=S(e,["tuningTask","completeTime"]);if(u!=null){T(t,["endTime"],u)}const a=S(e,["updateTime"]);if(a!=null){T(t,["updateTime"],a)}const c=S(e,["description"]);if(c!=null){T(t,["description"],c)}const f=S(e,["baseModel"]);if(f!=null){T(t,["baseModel"],f)}const d=S(e,["_self"]);if(d!=null){T(t,["tunedModel"],lc(d))}return t}function fc(e,n){const t={};const i=S(e,["sdkHttpResponse"]);if(i!=null){T(t,["sdkHttpResponse"],i)}const o=S(e,["name"]);if(o!=null){T(t,["name"],o)}const r=S(e,["state"]);if(r!=null){T(t,["state"],Bn(r))}const s=S(e,["createTime"]);if(s!=null){T(t,["createTime"],s)}const l=S(e,["startTime"]);if(l!=null){T(t,["startTime"],l)}const u=S(e,["endTime"]);if(u!=null){T(t,["endTime"],u)}const a=S(e,["updateTime"]);if(a!=null){T(t,["updateTime"],a)}const c=S(e,["error"]);if(c!=null){T(t,["error"],c)}const f=S(e,["description"]);if(f!=null){T(t,["description"],f)}const d=S(e,["baseModel"]);if(d!=null){T(t,["baseModel"],d)}const p=S(e,["tunedModel"]);if(p!=null){T(t,["tunedModel"],p)}const h=S(e,["preTunedModel"]);if(h!=null){T(t,["preTunedModel"],h)}const m=S(e,["supervisedTuningSpec"]);if(m!=null){T(t,["supervisedTuningSpec"],m)}const g=S(e,["preferenceOptimizationSpec"]);if(g!=null){T(t,["preferenceOptimizationSpec"],g)}const y=S(e,["distillationSpec"]);if(y!=null){T(t,["distillationSpec"],y)}const v=S(e,["tuningDataStats"]);if(v!=null){T(t,["tuningDataStats"],v)}const E=S(e,["encryptionSpec"]);if(E!=null){T(t,["encryptionSpec"],E)}const w=S(e,["partnerModelTuningSpec"]);if(w!=null){T(t,["partnerModelTuningSpec"],w)}const b=S(e,["customBaseModel"]);if(b!=null){T(t,["customBaseModel"],b)}const I=S(e,["experiment"]);if(I!=null){T(t,["experiment"],I)}const A=S(e,["labels"]);if(A!=null){T(t,["labels"],A)}const O=S(e,["outputUri"]);if(O!=null){T(t,["outputUri"],O)}const C=S(e,["pipelineJob"]);if(C!=null){T(t,["pipelineJob"],C)}const _=S(e,["serviceAccount"]);if(_!=null){T(t,["serviceAccount"],_)}const P=S(e,["tunedModelDisplayName"]);if(P!=null){T(t,["tunedModelDisplayName"],P)}const R=S(e,["veoTuningSpec"]);if(R!=null){T(t,["veoTuningSpec"],R)}return t}function dc(e,n){const t={};const i=S(e,["sdkHttpResponse"]);if(i!=null){T(t,["sdkHttpResponse"],i)}const o=S(e,["name"]);if(o!=null){T(t,["name"],o)}const r=S(e,["metadata"]);if(r!=null){T(t,["metadata"],r)}const s=S(e,["done"]);if(s!=null){T(t,["done"],s)}const l=S(e,["error"]);if(l!=null){T(t,["error"],l)}return t}function pc(e,n){const t={};const i=S(e,["gcsUri"]);if(i!=null){T(t,["validationDatasetUri"],i)}const o=S(e,["vertexDatasetResource"]);if(o!=null){T(t,["validationDatasetUri"],o)}return t}
272
+ /**
273
+ * @license
274
+ * Copyright 2025 Google LLC
275
+ * SPDX-License-Identifier: Apache-2.0
276
+ */class hc extends w{constructor(e){super();this.apiClient=e;this.list=async(e={})=>new ri(oi.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 n;if(this.apiClient.isVertexAI()){if(e.baseModel.startsWith("projects/")){const t={tunedModelName:e.baseModel};if((n=e.config)===null||n===void 0?void 0:n.preTunedModelCheckpointId){t.checkpointId=e.config.preTunedModelCheckpointId}const i=Object.assign(Object.assign({},e),{preTunedModel:t});i.baseModel=undefined;return await this.tuneInternal(i)}else{const n=Object.assign({},e);return await this.tuneInternal(n)}}else{const n=Object.assign({},e);const t=await this.tuneMldevInternal(n);let i="";if(t["metadata"]!==undefined&&t["metadata"]["tunedModel"]!==undefined){i=t["metadata"]["tunedModel"]}else if(t["name"]!==undefined&&t["name"].includes("/operations/")){i=t["name"].split("/operations/")[0]}const o={name:i,state:pe.JOB_STATE_QUEUED};return o}}}async getInternal(e){var n,t,i,o;let r;let s="";let l={};if(this.apiClient.isVertexAI()){const i=ec(e);s=b("{name}",i["_url"]);l=i["_query"];delete i["_url"];delete i["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(i),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json().then((n=>{const t=n;t.sdkHttpResponse={headers:e.headers};return t}))));return r.then((e=>{const n=fc(e);return n}))}else{const n=Za(e);s=b("{name}",n["_url"]);l=n["_query"];delete n["_url"];delete n["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(n),httpMethod:"GET",httpOptions:(i=e.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then((e=>e.json().then((n=>{const t=n;t.sdkHttpResponse={headers:e.headers};return t}))));return r.then((e=>{const n=cc(e);return n}))}}async listInternal(e){var n,t,i,o;let r;let s="";let l={};if(this.apiClient.isVertexAI()){const i=oc(e);s=b("tuningJobs",i["_url"]);l=i["_query"];delete i["_url"];delete i["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(i),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json().then((n=>{const t=n;t.sdkHttpResponse={headers:e.headers};return t}))));return r.then((e=>{const n=sc(e);const t=new ln;Object.assign(t,n);return t}))}else{const n=ic(e);s=b("tunedModels",n["_url"]);l=n["_query"];delete n["_url"];delete n["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(n),httpMethod:"GET",httpOptions:(i=e.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then((e=>e.json().then((n=>{const t=n;t.sdkHttpResponse={headers:e.headers};return t}))));return r.then((e=>{const n=rc(e);const t=new ln;Object.assign(t,n);return t}))}}async cancel(e){var n,t,i,o;let r;let s="";let l={};if(this.apiClient.isVertexAI()){const i=Ba(e);s=b("{name}:cancel",i["_url"]);l=i["_query"];delete i["_url"];delete i["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(i),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json().then((n=>{const t=n;t.sdkHttpResponse={headers:e.headers};return t}))));return r.then((e=>{const n=Ya(e);const t=new un;Object.assign(t,n);return t}))}else{const n=Va(e);s=b("{name}:cancel",n["_url"]);l=n["_query"];delete n["_url"];delete n["_query"];r=this.apiClient.request({path:s,queryParams:l,body:JSON.stringify(n),httpMethod:"POST",httpOptions:(i=e.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=e.config)===null||o===void 0?void 0:o.abortSignal}).then((e=>e.json().then((n=>{const t=n;t.sdkHttpResponse={headers:e.headers};return t}))));return r.then((e=>{const n=Wa(e);const t=new un;Object.assign(t,n);return t}))}}async tuneInternal(e){var n,t;let i;let o="";let r={};if(this.apiClient.isVertexAI()){const s=Qa(e,e);o=b("tuningJobs",s["_url"]);r=s["_query"];delete s["_url"];delete s["_query"];i=this.apiClient.request({path:o,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json().then((n=>{const t=n;t.sdkHttpResponse={headers:e.headers};return t}))));return i.then((e=>{const n=fc(e);return n}))}else{throw new Error("This method is only supported by the Vertex AI.")}}async tuneMldevInternal(e){var n,t;let i;let o="";let r={};if(this.apiClient.isVertexAI()){throw new Error("This method is only supported by the Gemini Developer API.")}else{const s=Xa(e);o=b("tunedModels",s["_url"]);r=s["_query"];delete s["_url"];delete s["_query"];i=this.apiClient.request({path:o,queryParams:r,body:JSON.stringify(s),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(t=e.config)===null||t===void 0?void 0:t.abortSignal}).then((e=>e.json().then((n=>{const t=n;t.sdkHttpResponse={headers:e.headers};return t}))));return i.then((e=>{const n=dc(e);return n}))}}}
277
+ /**
278
+ * @license
279
+ * Copyright 2025 Google LLC
280
+ * SPDX-License-Identifier: Apache-2.0
281
+ */class mc{async download(e,n){throw new Error("Download to file is not supported in the browser, please use a browser compliant download like an <a> tag.")}}const gc=1024*1024*8;const yc=3;const vc=1e3;const Ec=2;const wc="x-goog-upload-status";async function bc(e,n,t){var i;const o=await Sc(e,n,t);const r=await(o===null||o===void 0?void 0:o.json());if(((i=o===null||o===void 0?void 0:o.headers)===null||i===void 0?void 0:i[wc])!=="final"){throw new Error("Failed to upload file: Upload status is not finalized.")}return r["file"]}async function Tc(e,n,t){var i;const o=await Sc(e,n,t);const r=await(o===null||o===void 0?void 0:o.json());if(((i=o===null||o===void 0?void 0:o.headers)===null||i===void 0?void 0:i[wc])!=="final"){throw new Error("Failed to upload file: Upload status is not finalized.")}const s=L(r);const l=new Tn;Object.assign(l,s);return l}async function Sc(e,n,t){var i,o;let r=0;let s=0;let l=new We(new Response);let u="upload";r=e.size;while(s<r){const a=Math.min(gc,r-s);const c=e.slice(s,s+a);if(s+a>=r){u+=", finalize"}let f=0;let d=vc;while(f<yc){l=await t.request({path:"",body:c,httpMethod:"POST",httpOptions:{apiVersion:"",baseUrl:n,headers:{"X-Goog-Upload-Command":u,"X-Goog-Upload-Offset":String(s),"Content-Length":String(a)}}});if((i=l===null||l===void 0?void 0:l.headers)===null||i===void 0?void 0:i[wc]){break}f++;await Ac(d);d=d*Ec}s+=a;if(((o=l===null||l===void 0?void 0:l.headers)===null||o===void 0?void 0:o[wc])!=="active"){break}if(r<=s){throw new Error("All content has been uploaded, but the upload status is not finalized.")}}return l}async function Ic(e){const n={size:e.size,type:e.type};return n}function Ac(e){return new Promise((n=>setTimeout(n,e)))}class Oc{async upload(e,n,t){if(typeof e==="string"){throw new Error("File path is not supported in browser uploader.")}return await bc(e,n,t)}async uploadToFileSearchStore(e,n,t){if(typeof e==="string"){throw new Error("File path is not supported in browser uploader.")}return await Tc(e,n,t)}async stat(e){if(typeof e==="string"){throw new Error("File path is not supported in browser uploader.")}else{return await Ic(e)}}}
282
+ /**
283
+ * @license
284
+ * Copyright 2025 Google LLC
285
+ * SPDX-License-Identifier: Apache-2.0
286
+ */class Cc{create(e,n,t){return new _c(e,n,t)}}class _c{constructor(e,n,t){this.url=e;this.headers=n;this.callbacks=t}connect(){this.ws=new WebSocket(this.url);this.ws.onopen=this.callbacks.onopen;this.ws.onerror=this.callbacks.onerror;this.ws.onclose=this.callbacks.onclose;this.ws.onmessage=this.callbacks.onmessage}send(e){if(this.ws===undefined){throw new Error("WebSocket is not connected")}this.ws.send(e)}close(){if(this.ws===undefined){throw new Error("WebSocket is not connected")}this.ws.close()}}
287
+ /**
288
+ * @license
289
+ * Copyright 2025 Google LLC
290
+ * SPDX-License-Identifier: Apache-2.0
291
+ */const Pc="x-goog-api-key";class Rc{constructor(e){this.apiKey=e}async addAuthHeaders(e,n){if(e.get(Pc)!==null){return}if(this.apiKey.startsWith("auth_tokens/")){throw new Error("Ephemeral tokens are only supported by the live API.")}if(!this.apiKey){throw new Error("API key is missing. Please provide a valid API key.")}e.append(Pc,this.apiKey)}}
292
+ /**
293
+ * @license
294
+ * Copyright 2025 Google LLC
295
+ * SPDX-License-Identifier: Apache-2.0
296
+ */const Nc="gl-node/";class Mc{get interactions(){var e;if(this._interactions!==undefined){return this._interactions}console.warn("GoogleGenAI.interactions: Interactions usage is experimental and may change in future versions.");const n=this.httpOptions;if(n===null||n===void 0?void 0:n.extraBody){console.warn("GoogleGenAI.interactions: Client level httpOptions.extraBody is not supported by the interactions client and will be ignored.")}const t=new Ja({baseURL:this.apiClient.getBaseUrl(),apiKey:this.apiKey,apiVersion:this.apiClient.getApiVersion(),clientAdapter:this.apiClient,defaultHeaders:this.apiClient.getDefaultHeaders(),timeout:n===null||n===void 0?void 0:n.timeout,maxRetries:(e=n===null||n===void 0?void 0:n.retryOptions)===null||e===void 0?void 0:e.attempts});this._interactions=t.interactions;return this._interactions}constructor(e){var n;if(e.apiKey==null){throw new Error("An API Key must be set when running in a browser")}if(e.project||e.location){throw new Error("Vertex AI project based authentication is not supported on browser runtimes. Please do not provide a project or location.")}this.vertexai=(n=e.vertexai)!==null&&n!==void 0?n:false;this.apiKey=e.apiKey;const t=E(e.httpOptions,e.vertexai,undefined,undefined);if(t){if(e.httpOptions){e.httpOptions.baseUrl=t}else{e.httpOptions={baseUrl:t}}}this.apiVersion=e.apiVersion;this.httpOptions=e.httpOptions;const i=new Rc(this.apiKey);this.apiClient=new cl({auth:i,apiVersion:this.apiVersion,apiKey:this.apiKey,vertexai:this.vertexai,httpOptions:this.httpOptions,userAgentExtra:Nc+"web",uploader:new Oc,downloader:new mc});this.models=new Ll(this.apiClient);this.live=new Cl(this.apiClient,i,new Cc);this.batches=new si(this.apiClient);this.chats=new Ki(this.models,this.apiClient);this.caches=new ji(this.apiClient);this.files=new uo(this.apiClient);this.operations=new jl(this.apiClient);this.authTokens=new nu(this.apiClient);this.tunings=new hc(this.apiClient);this.fileSearchStores=new au(this.apiClient)}}const Dc="llm-testrunner";const Uc={hotModuleReplacement:false,hydratedSelectorName:"hydrated",lazyLoad:false,propChangeCallback:false,state:true,updatable:true};function kc(e,n,t){const i=typeof HTMLElement!=="undefined"?HTMLElement.prototype:null;while(e&&e!==i){const i=Object.getOwnPropertyDescriptor(e,n);if(i&&(!t||i.get))return i;e=Object.getPrototypeOf(e)}return void 0}var Gc=(e,n)=>{var t;const i=n.t;const o=Object.entries((t=i.i)!=null?t:{});o.map((([t,[i]])=>{if(i&31||i&32){const i=e[t];const o=kc(Object.getPrototypeOf(e),t,true)||Object.getOwnPropertyDescriptor(e,t);if(o){Object.defineProperty(e,t,{get(){return o.get.call(this)},set(e){o.set.call(this,e)},configurable:true,enumerable:true})}if(n.o.has(t)){e[t]=n.o.get(t)}else if(i!==void 0){e[t]=i}}}))};var xc=e=>{if(e.__stencil__getHostRef){return e.__stencil__getHostRef()}return void 0};var Lc=(e,n)=>{const t={l:0,$hostElement$:e,t:n,o:new Map,u:new Map};{t.p=new Promise((e=>t.h=e));e["s-p"]=[];e["s-rc"]=[]}const i=t;e.__stencil__getHostRef=()=>i;if(n.l&512&&Uc.state){Gc(e,t)}return i};var jc=(e,n)=>n in e;var Fc=(e,n)=>(0,console.error)(e,n);var qc=new Map;var Hc="slot-fb{display:contents}slot-fb[hidden]{display:none}";var $c="http://www.w3.org/1999/xlink";var Jc=typeof window!=="undefined"?window:{};var Vc=Jc.HTMLElement||class{};var Bc={l:0,m:"",jmp:e=>e(),raf:e=>requestAnimationFrame(e),ael:(e,n,t,i)=>e.addEventListener(n,t,i),rel:(e,n,t,i)=>e.removeEventListener(n,t,i),ce:(e,n)=>new CustomEvent(e,n)};var Wc=e=>Promise.resolve(e);var Yc=(()=>{try{if(!Jc.document.adoptedStyleSheets){return false}new CSSStyleSheet;return typeof(new CSSStyleSheet).replaceSync==="function"}catch(e){}return false})();var Kc=Yc?(()=>!!Jc.document&&Object.getOwnPropertyDescriptor(Jc.document.adoptedStyleSheets,"length").writable)():false;var zc=false;var Xc=[];var Qc=[];var Zc=(e,n)=>t=>{e.push(t);if(!zc){zc=true;if(n&&Bc.l&4){tf(nf)}else{Bc.raf(nf)}}};var ef=e=>{for(let n=0;n<e.length;n++){try{e[n](performance.now())}catch(e){Fc(e)}}e.length=0};var nf=()=>{ef(Xc);{ef(Qc);if(zc=Xc.length>0){Bc.raf(nf)}}};var tf=e=>Wc().then(e);var of=Zc(Qc,true);var rf=e=>{const n=new URL(e,Bc.m);return n.origin!==Jc.location.origin?n.href:n.pathname};var sf=e=>Bc.m=e;function lf(e){return void 0}var uf;function af(e){var n;const t={mode:"open"};const i=this.attachShadow(t);if(uf===void 0)uf=(n=lf())!=null?n:null;if(uf){if(Kc){i.adoptedStyleSheets.push(uf)}else{i.adoptedStyleSheets=[...i.adoptedStyleSheets,uf]}}}var cf=(e,n="")=>{{return()=>{}}};function ff(e){var n,t,i;return(i=(t=(n=e.head)==null?void 0:n.querySelector('meta[name="csp-nonce"]'))==null?void 0:t.getAttribute("content"))!=null?i:void 0}var df=new WeakMap;var pf=(e,n,t)=>{let i=qc.get(e);if(Yc&&t){i=i||new CSSStyleSheet;if(typeof i==="string"){i=n}else{i.replaceSync(n)}}else{i=n}qc.set(e,i)};var hf=(e,n,t)=>{var i,o,r;const s=gf(n);const l=qc.get(s);if(!Jc.document){return s}e=e.nodeType===11?e:Jc.document;if(l){if(typeof l==="string"){e=e.head||e;let t=df.get(e);let r;if(!t){df.set(e,t=new Set)}if(!t.has(s)){r=Jc.document.createElement("style");r.textContent=l;const u=(i=Bc.T)!=null?i:ff(Jc.document);if(u!=null){r.setAttribute("nonce",u)}if(!(n.l&1)){if(e.nodeName==="HEAD"){const n=e.querySelectorAll("link[rel=preconnect]");const t=n.length>0?n[n.length-1].nextSibling:e.querySelector("style");e.insertBefore(r,(t==null?void 0:t.parentNode)===e?t:null)}else if("host"in e){if(Yc){const n=(o=e.defaultView)!=null?o:e.ownerDocument.defaultView;const t=new n.CSSStyleSheet;t.replaceSync(l);if(Kc){e.adoptedStyleSheets.unshift(t)}else{e.adoptedStyleSheets=[t,...e.adoptedStyleSheets]}}else{const n=e.querySelector("style");if(n&&true){n.textContent=l+n.textContent}else{e.prepend(r)}}}else{e.append(r)}}if(n.l&1){e.insertBefore(r,null)}if(n.l&4){r.textContent+=Hc}if(t){t.add(s)}}}else{let n=df.get(e);if(!n){df.set(e,n=new Set)}if(!n.has(s)){const t=(r=e.defaultView)!=null?r:e.ownerDocument.defaultView;let i;if(l.constructor===t.CSSStyleSheet){i=l}else{i=new t.CSSStyleSheet;for(let e=0;e<l.cssRules.length;e++){i.insertRule(l.cssRules[e].cssText,e)}}if(Kc){e.adoptedStyleSheets.push(i)}else{e.adoptedStyleSheets=[...e.adoptedStyleSheets,i]}n.add(s)}}}return s};var mf=e=>{const n=e.t;const t=e.$hostElement$;const i=n.l;const o=cf("attachStyles",n.S);const r=hf(t.shadowRoot?t.shadowRoot:t.getRootNode(),n);if(i&10){t["s-sc"]=r;t.classList.add(r+"-h")}o()};var gf=(e,n)=>"sc-"+e.S;var yf=e=>{e=typeof e;return e==="object"||e==="function"};var vf=(e,n,...t)=>{if(typeof e==="string"){e=Ed(e)}let i=null;let o=null;let r=false;let s=false;const l=[];const u=n=>{for(let t=0;t<n.length;t++){i=n[t];if(Array.isArray(i)){u(i)}else if(i!=null&&typeof i!=="boolean"){if(r=typeof e!=="function"&&!yf(i)){i=String(i)}if(r&&s){l[l.length-1].I+=i}else{l.push(r?Ef(null,i):i)}s=r}}};u(t);if(n){if(n.key){o=n.key}{const e=n.className||n.class;if(e){n.class=typeof e!=="object"?e:Object.keys(e).filter((n=>e[n])).join(" ")}}}if(typeof e==="function"){return e(n===null?{}:n,l,Tf)}const a=Ef(e,null);a.A=n;if(l.length>0){a.O=l}{a.C=o}return a};var Ef=(e,n)=>{const t={l:0,_:e,I:n!=null?n:null,P:null,O:null};{t.A=null}{t.C=null}return t};var wf={};var bf=e=>e&&e._===wf;var Tf={forEach:(e,n)=>e.map(Sf).forEach(n),map:(e,n)=>e.map(Sf).map(n).map(If)};var Sf=e=>({vattrs:e.A,vchildren:e.O,vkey:e.C,vname:e.R,vtag:e._,vtext:e.I});var If=e=>{if(typeof e.vtag==="function"){const n={...e.vattrs};if(e.vkey){n.key=e.vkey}if(e.vname){n.name=e.vname}return vf(e.vtag,n,...e.vchildren||[])}const n=Ef(e.vtag,e.vtext);n.A=e.vattrs;n.O=e.vchildren;n.C=e.vkey;n.R=e.vname;return n};var Af=(e,n,t)=>{if(e!=null&&!yf(e)){if(n&4){{return e==="false"?false:e===""||!!e}}if(n&2){return typeof e==="string"?parseFloat(e):typeof e==="number"?e:NaN}if(n&1){return String(e)}return e}return e};var Of=e=>e;var Cf=(e,n,t)=>{const i=Of(e);return{emit:e=>_f(i,n,{bubbles:true,composed:true,cancelable:true,detail:e})}};var _f=(e,n,t)=>{const i=Bc.ce(n,t);e.dispatchEvent(i);return i};var Pf=(e,n,t,i,o,r,s)=>{if(t===i){return}let l=jc(e,n);let u=n.toLowerCase();if(n==="class"){const n=e.classList;const o=Nf(t);let r=Nf(i);{n.remove(...o.filter((e=>e&&!r.includes(e))));n.add(...r.filter((e=>e&&!o.includes(e))))}}else if(n==="style"){{for(const n in t){if(!i||i[n]==null){if(n.includes("-")){e.style.removeProperty(n)}else{e.style[n]=""}}}}for(const n in i){if(!t||i[n]!==t[n]){if(n.includes("-")){e.style.setProperty(n,i[n])}else{e.style[n]=i[n]}}}}else if(n==="key");else if(n==="ref"){if(i){Wf(i,e)}}else if(!e.__lookupSetter__(n)&&n[0]==="o"&&n[1]==="n"){if(n[2]==="-"){n=n.slice(3)}else if(jc(Jc,u)){n=u.slice(2)}else{n=u[2]+n.slice(3)}if(t||i){const o=n.endsWith(Mf);n=n.replace(Df,"");if(t){Bc.rel(e,n,t,o)}if(i){Bc.ael(e,n,i,o)}}}else if(n[0]==="a"&&n.startsWith("attr:")){const t=n.slice(5);let o;{const n=xc(e);if(n&&n.t&&n.t.i){const e=n.t.i[t];if(e&&e[1]){o=e[1]}}}if(!o){o=t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}if(i==null||i===false){if(i!==false||e.getAttribute(o)===""){e.removeAttribute(o)}}else{e.setAttribute(o,i===true?"":i)}return}else if(n[0]==="p"&&n.startsWith("prop:")){const t=n.slice(5);try{e[t]=i}catch(e){}return}else{const s=yf(i);if((l||s&&i!==null)&&!o){try{if(!e.tagName.includes("-")){const o=i==null?"":i;if(n==="list"){l=false}else if(t==null||e[n]!==o){if(typeof e.__lookupSetter__(n)==="function"){e[n]=o}else{e.setAttribute(n,o)}}}else if(e[n]!==i){e[n]=i}}catch(e){}}let a=false;{if(u!==(u=u.replace(/^xlink\:?/,""))){n=u;a=true}}if(i==null||i===false){if(i!==false||e.getAttribute(n)===""){if(a){e.removeAttributeNS($c,n)}else{e.removeAttribute(n)}}}else if((!l||r&4||o)&&!s&&e.nodeType===1){i=i===true?"":i;if(a){e.setAttributeNS($c,n,i)}else{e.setAttribute(n,i)}}}};var Rf=/\s/;var Nf=e=>{if(typeof e==="object"&&e&&"baseVal"in e){e=e.baseVal}if(!e||typeof e!=="string"){return[]}return e.split(Rf)};var Mf="Capture";var Df=new RegExp(Mf+"$");var Uf=(e,n,t,i)=>{const o=n.P.nodeType===11&&n.P.host?n.P.host:n.P;const r=e&&e.A||{};const s=n.A||{};{for(const e of kf(Object.keys(r))){if(!(e in s)){Pf(o,e,r[e],void 0,t,n.l)}}}for(const e of kf(Object.keys(s))){Pf(o,e,r[e],s[e],t,n.l)}};function kf(e){return e.includes("ref")?[...e.filter((e=>e!=="ref")),"ref"]:e}var Gf;var xf=false;var Lf=[];var jf=[];var Ff=(e,n,t)=>{const i=n.O[t];let o=0;let r;let s;if(i.I!=null){r=i.P=Jc.document.createTextNode(i.I)}else{if(!Jc.document){throw new Error("You are trying to render a Stencil component in an environment that doesn't support the DOM.")}r=i.P=Jc.document.createElement(i._);{Uf(null,i,xf)}if(i.O){const n=i._==="template"?r.content:r;for(o=0;o<i.O.length;++o){s=Ff(e,i,o);if(s){n.appendChild(s)}}}}r["s-hn"]=Gf;return r};var qf=(e,n,t,i,o,r)=>{let s=e;let l;if(s.shadowRoot&&s.tagName===Gf){s=s.shadowRoot}if(t._==="template"){s=s.content}for(;o<=r;++o){if(i[o]){l=Ff(null,t,o);if(l){i[o].P=l;Kf(s,l,n)}}}};var Hf=(e,n,t)=>{for(let i=n;i<=t;++i){const n=e[i];if(n){const e=n.P;Bf(n);if(e){e.remove()}}}};var $f=(e,n,t,i,o=false)=>{let r=0;let s=0;let l=0;let u=0;let a=n.length-1;let c=n[0];let f=n[a];let d=i.length-1;let p=i[0];let h=i[d];let m;let g;const y=t._==="template"?e.content:e;while(r<=a&&s<=d){if(c==null){c=n[++r]}else if(f==null){f=n[--a]}else if(p==null){p=i[++s]}else if(h==null){h=i[--d]}else if(Jf(c,p,o)){Vf(c,p,o);c=n[++r];p=i[++s]}else if(Jf(f,h,o)){Vf(f,h,o);f=n[--a];h=i[--d]}else if(Jf(c,h,o)){Vf(c,h,o);Kf(y,c.P,f.P.nextSibling);c=n[++r];h=i[--d]}else if(Jf(f,p,o)){Vf(f,p,o);Kf(y,f.P,c.P);f=n[--a];p=i[++s]}else{l=-1;{for(u=r;u<=a;++u){if(n[u]&&n[u].C!==null&&n[u].C===p.C){l=u;break}}}if(l>=0){g=n[l];if(g._!==p._){m=Ff(n&&n[s],t,l)}else{Vf(g,p,o);n[l]=void 0;m=g.P}p=i[++s]}else{m=Ff(n&&n[s],t,s);p=i[++s]}if(m){{Kf(c.P.parentNode,m,c.P)}}}}if(r>a){qf(e,i[d+1]==null?null:i[d+1].P,t,i,s,d)}else if(s>d){Hf(n,r,a)}};var Jf=(e,n,t=false)=>{if(e._===n._){if(!t){return e.C===n.C}if(t&&!e.C&&n.C){e.C=n.C}return true}return false};var Vf=(e,n,t=false)=>{const i=n.P=e.P;const o=e.O;const r=n.O;const s=n.I;if(s==null){{Uf(e,n,xf)}if(o!==null&&r!==null){$f(i,o,n,r,t)}else if(r!==null){if(e.I!==null){i.textContent=""}qf(i,null,n,r,0,r.length-1)}else if(!t&&Uc.updatable&&o!==null){Hf(o,0,o.length-1)}else;}else if(e.I!==s){i.data=s}};var Bf=e=>{{if(e.A&&e.A.ref){Lf.push((()=>e.A.ref(null)))}e.O&&e.O.map(Bf)}};var Wf=(e,n)=>{{jf.push((()=>e(n)))}};var Yf=()=>{{Lf.forEach((e=>e()));Lf.length=0;jf.forEach((e=>e()));jf.length=0}};var Kf=(e,n,t,i)=>{if(e.__insertBefore){return e.__insertBefore(n,t)}else{return e==null?void 0:e.insertBefore(n,t)}};var zf=(e,n,t=false)=>{const i=e.$hostElement$;const o=e.N||Ef(null,null);const r=bf(n);const s=r?n:vf(null,null,n);Gf=i.tagName;if(t&&s.A){for(const e of Object.keys(s.A)){if(i.hasAttribute(e)&&!["key","ref","style","class"].includes(e)){s.A[e]=i[e]}}}s._=null;s.l|=4;e.N=s;s.P=o.P=i.shadowRoot||i;Vf(o,s,t);Yf()};var Xf=(e,n)=>{if(n&&!e.M&&n["s-p"]){const t=n["s-p"].push(new Promise((i=>e.M=()=>{n["s-p"].splice(t-1,1);i()})))}};var Qf=(e,n)=>{{e.l|=16}if(e.l&4){e.l|=512;return}Xf(e,e.D);const t=()=>Zf(e,n);if(n){queueMicrotask((()=>{t()}));return}return of(t)};var Zf=(e,n)=>{const t=e.$hostElement$;const i=cf("scheduleUpdate",e.t.S);const o=t;if(!o){throw new Error(`Can't render component <${t.tagName.toLowerCase()} /> with invalid Stencil runtime! Make sure this imported component is compiled with a \`externalRuntime: true\` flag. For more information, please refer to https://stenciljs.com/docs/custom-elements#externalruntime`)}let r;if(n){r=sd(o,"componentWillLoad",void 0,t)}else{r=sd(o,"componentWillUpdate",void 0,t)}r=ed(r,(()=>sd(o,"componentWillRender",void 0,t)));i();return ed(r,(()=>td(e,o,n)))};var ed=(e,n)=>nd(e)?e.then(n).catch((e=>{console.error(e);n()})):n();var nd=e=>e instanceof Promise||e&&e.then&&typeof e.then==="function";var td=async(e,n,t)=>{var i;const o=e.$hostElement$;const r=cf("update",e.t.S);const s=o["s-rc"];if(t){mf(e)}const l=cf("render",e.t.S);{id(e,n,o,t)}if(s){s.map((e=>e()));o["s-rc"]=void 0}l();r();{const n=(i=o["s-p"])!=null?i:[];const t=()=>od(e);if(n.length===0){t()}else{Promise.all(n).then(t).catch(t);e.l|=4;n.length=0}}};var id=(e,n,t,i)=>{try{n=n.render();{e.l&=-17}{e.l|=2}{{{zf(e,n,i)}}}}catch(n){Fc(n,e.$hostElement$)}return null};var od=e=>{const n=e.t.S;const t=e.$hostElement$;const i=cf("postUpdate",n);const o=t;const r=e.D;sd(o,"componentDidRender",void 0,t);if(!(e.l&64)){e.l|=64;{ld(t)}sd(o,"componentDidLoad",void 0,t);i();{e.h(t);if(!r){rd()}}}else{sd(o,"componentDidUpdate",void 0,t);i()}{if(e.M){e.M();e.M=void 0}if(e.l&512){tf((()=>Qf(e,false)))}e.l&=-517}};var rd=e=>{tf((()=>_f(Jc,"appload",{detail:{namespace:Dc}})))};var sd=(e,n,t,i)=>{if(e&&e[n]){try{return e[n](t)}catch(e){Fc(e,i)}}return void 0};var ld=e=>{var n;return e.classList.add((n=Uc.hydratedSelectorName)!=null?n:"hydrated")};var ud=(e,n)=>xc(e).o.get(n);var ad=(e,n,t,i)=>{const o=xc(e);if(!o){return}const r=e;const s=o.o.get(n);const l=o.l;const u=r;t=Af(t,i.i[n][0]);const a=Number.isNaN(s)&&Number.isNaN(t);const c=t!==s&&!a;if(c){o.o.set(n,t);if(l&2){if(u.componentShouldUpdate){const e=u.componentShouldUpdate(t,s,n);if(e===false&&!(l&16)){return}}if(!(l&16)){Qf(o,false)}}}};var cd=(e,n,t)=>{var i,o;const r=e.prototype;if(n.i||Uc.propChangeCallback){const t=Object.entries((i=n.i)!=null?i:{});t.map((([e,[t]])=>{if(t&31||t&32){const{get:i,set:o}=kc(r,e)||{};if(i)n.i[e][0]|=2048;if(o)n.i[e][0]|=4096;{Object.defineProperty(r,e,{get(){{return i?i.apply(this):ud(this,e)}},configurable:true,enumerable:true})}Object.defineProperty(r,e,{set(i){const r=xc(this);if(!r){return}if(o){const s=t&32?this[e]:r.$hostElement$[e];if(typeof s==="undefined"&&r.o.get(e)){i=r.o.get(e)}o.apply(this,[Af(i,t)]);i=t&32?this[e]:r.$hostElement$[e];ad(this,e,i,n);return}{ad(this,e,i,n);return}}})}}));{const i=new Map;r.attributeChangedCallback=function(e,o,s){Bc.jmp((()=>{var l;const u=i.get(e);const a=xc(this);if(this.hasOwnProperty(u)&&Uc.lazyLoad);if(r.hasOwnProperty(u)&&typeof this[u]==="number"&&this[u]==s){return}else if(u==null){const t=a==null?void 0:a.l;if(a&&t&&!(t&8)&&s!==o){const i=this;const r=i;const u=(l=n.U)==null?void 0:l[e];u==null?void 0:u.forEach((n=>{const[[i,l]]=Object.entries(n);if(r[i]!=null&&(t&128||l&1)){r[i].call(r,s,o,e)}}))}return}const c=t.find((([e])=>e===u));if(c&&c[1][0]&4){s=s===null||s==="false"?false:true}const f=Object.getOwnPropertyDescriptor(r,u);if(s!=this[u]&&(!f.get||!!f.set)){this[u]=s}}))};e.observedAttributes=Array.from(new Set([...Object.keys((o=n.U)!=null?o:{}),...t.filter((([e,n])=>n[0]&31)).map((([e,n])=>{const t=n[1]||e;i.set(t,e);return t}))]))}}return e};var fd=async(e,n,t,i)=>{let o;try{if((n.l&32)===0){n.l|=32;{o=e.constructor;const t=e.localName;customElements.whenDefined(t).then((()=>n.l|=128))}if(o&&o.style){let e;if(typeof o.style==="string"){e=o.style}const n=gf(t);if(!qc.has(n)||Uc.hotModuleReplacement){const i=cf("registerStyles",t.S);pf(n,e,!!(t.l&1));i()}}}const i=n.D;const r=()=>Qf(n,true);if(i&&i["s-rc"]){i["s-rc"].push(r)}else{r()}}catch(t){Fc(t,e);if(n.M){n.M();n.M=void 0}if(n.h){n.h(e)}}};var dd=(e,n)=>{};var pd=e=>{if((Bc.l&1)===0){const n=xc(e);if(!n){return}const t=n.t;const i=cf("connectedCallback",t.S);if(!(n.l&1)){n.l|=1;{let t=e;while(t=t.parentNode||t.host){if(t["s-p"]){Xf(n,n.D=t);break}}}if(t.i){Object.entries(t.i).map((([n,[t]])=>{if(t&31&&Object.prototype.hasOwnProperty.call(e,n)){const t=e[n];delete e[n];e[n]=t}}))}{fd(e,n,t)}}else{if(n==null?void 0:n.k);else if(n==null?void 0:n.p){n.p.then((()=>dd()))}}i()}};var hd=async e=>{if((Bc.l&1)===0){xc(e)}if(df.has(e)){df.delete(e)}if(e.shadowRoot&&df.has(e.shadowRoot)){df.delete(e.shadowRoot)}};var md=(e,n)=>{const t={l:n[0],S:n[1]};try{{t.i=n[2]}const i=e.prototype.connectedCallback;const o=e.prototype.disconnectedCallback;Object.assign(e.prototype,{__hasHostListenerAttached:false,__registerHost(){Lc(this,t)},connectedCallback(){if(!this.__hasHostListenerAttached){const e=xc(this);if(!e){return}this.__hasHostListenerAttached=true}pd(this);if(i){i.call(this)}},disconnectedCallback(){hd(this);if(o){o.call(this)}},__attachShadow(){{if(!this.shadowRoot){af.call(this,t)}else{if(this.shadowRoot.mode!=="open"){throw new Error(`Unable to re-use existing shadow root for ${t.S}! Mode is set to ${this.shadowRoot.mode} but Stencil only supports open shadow roots.`)}}}}});Object.defineProperty(e,"is",{value:t.S,configurable:true});return cd(e,t)}catch(n){Fc(n);return e}};var gd=e=>Bc.T=e;var yd=e=>Object.assign(Bc,e);function vd(e,n){const t={$hostElement$:n};zf(t,e)}function Ed(e){return e}export{Mc as G,Vc as H,gd as a,yd as b,n as c,e as d,Cf as e,rf as g,vf as h,md as p,vd as r,sf as s,Ed as t};
297
+ //# sourceMappingURL=p-D9BrlHdP.js.map