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.
- package/README.md +101 -100
- package/dist/cjs/app-chips_5.cjs.entry.js +158 -0
- package/dist/cjs/app-chips_5.cjs.entry.js.map +1 -0
- package/dist/cjs/app-globals-Chb-oJtg.js +34 -0
- package/dist/cjs/app-globals-Chb-oJtg.js.map +1 -0
- package/dist/cjs/index-By1scwl6.js +25542 -0
- package/dist/cjs/index-By1scwl6.js.map +1 -0
- package/dist/cjs/index-CgmLNwZO.js +21460 -0
- package/dist/cjs/index-CgmLNwZO.js.map +1 -0
- package/dist/cjs/index.cjs.js +5 -483
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/llm-testrunner.cjs.js +6 -4
- package/dist/cjs/llm-testrunner.cjs.js.map +1 -1
- package/dist/cjs/loader.cjs.js +5 -3
- package/dist/collection/collection-manifest.json +8 -3
- package/dist/collection/components/error-message/error-message.css +34 -0
- package/dist/collection/components/error-message/error-message.js +2 -2
- package/dist/collection/components/error-message/error-message.js.map +1 -1
- package/dist/collection/components/llm-test-runner/header/llm-test-runner-header.css +60 -0
- package/dist/collection/components/llm-test-runner/header/llm-test-runner-header.js +18 -0
- package/dist/collection/components/llm-test-runner/header/llm-test-runner-header.js.map +1 -0
- package/dist/collection/components/llm-test-runner/llm-test-runner.css +17 -657
- package/dist/collection/components/llm-test-runner/llm-test-runner.import-export.test.js +253 -0
- package/dist/collection/components/llm-test-runner/llm-test-runner.import-export.test.js.map +1 -0
- package/dist/collection/components/llm-test-runner/llm-test-runner.js +191 -200
- package/dist/collection/components/llm-test-runner/llm-test-runner.js.map +1 -1
- package/dist/collection/components/llm-test-runner/test-cases/actions/row-actions.css +28 -0
- package/dist/collection/components/llm-test-runner/test-cases/actions/row-actions.js +6 -0
- package/dist/collection/components/llm-test-runner/test-cases/actions/row-actions.js.map +1 -0
- package/dist/collection/components/llm-test-runner/test-cases/evaluation/evaluation-summary.css +67 -0
- package/dist/collection/components/llm-test-runner/test-cases/evaluation/evaluation-summary.js +5 -0
- package/dist/collection/components/llm-test-runner/test-cases/evaluation/evaluation-summary.js.map +1 -0
- package/dist/collection/components/llm-test-runner/test-cases/llm-test-case-row.css +42 -0
- package/dist/collection/components/llm-test-runner/test-cases/llm-test-case-row.js +39 -0
- package/dist/collection/components/llm-test-runner/test-cases/llm-test-case-row.js.map +1 -0
- package/dist/collection/components/llm-test-runner/test-cases/llm-test-cases.css +39 -0
- package/dist/collection/components/llm-test-runner/test-cases/llm-test-cases.js +7 -0
- package/dist/collection/components/llm-test-runner/test-cases/llm-test-cases.js.map +1 -0
- package/dist/collection/components/llm-test-runner/test-cases/output/response-output.css +51 -0
- package/dist/collection/components/llm-test-runner/test-cases/output/response-output.js +5 -0
- package/dist/collection/components/llm-test-runner/test-cases/output/response-output.js.map +1 -0
- package/dist/collection/global/env.js +3 -1
- package/dist/collection/global/env.js.map +1 -1
- package/dist/collection/index.js.map +1 -1
- package/dist/collection/lib/evaluation/constants.js +14 -0
- package/dist/collection/lib/evaluation/constants.js.map +1 -0
- package/dist/collection/lib/evaluation/evaluation-engine.js +45 -45
- package/dist/collection/lib/evaluation/evaluation-engine.js.map +1 -1
- package/dist/collection/lib/evaluation/evaluation-service.js +33 -0
- package/dist/collection/lib/evaluation/evaluation-service.js.map +1 -0
- package/dist/collection/lib/evaluation/evaluators/bleu/bleu-evaluator.js +116 -0
- package/dist/collection/lib/evaluation/evaluators/bleu/bleu-evaluator.js.map +1 -0
- package/dist/collection/lib/evaluation/evaluators/bleu/tests/bleu.test.js +352 -0
- package/dist/collection/lib/evaluation/evaluators/bleu/tests/bleu.test.js.map +1 -0
- package/dist/collection/lib/evaluation/evaluators/exact/exact.js +44 -0
- package/dist/collection/lib/evaluation/evaluators/exact/exact.js.map +1 -0
- package/dist/collection/lib/evaluation/evaluators/rouge1-evaluator.js +88 -0
- package/dist/collection/lib/evaluation/evaluators/rouge1-evaluator.js.map +1 -0
- package/dist/collection/lib/evaluation/evaluators/rougeL-evaluator.js +82 -0
- package/dist/collection/lib/evaluation/evaluators/rougeL-evaluator.js.map +1 -0
- package/dist/collection/lib/evaluation/evaluators/rougeL-evaluator.test.js +326 -0
- package/dist/collection/lib/evaluation/evaluators/rougeL-evaluator.test.js.map +1 -0
- package/dist/collection/lib/evaluation/evaluators/semantic/SemanticEvaluator.js +69 -0
- package/dist/collection/lib/evaluation/evaluators/semantic/SemanticEvaluator.js.map +1 -0
- package/dist/collection/lib/evaluation/evaluators/semantic/evaluate-keywords.js +56 -0
- package/dist/collection/lib/evaluation/evaluators/semantic/evaluate-keywords.js.map +1 -0
- package/dist/collection/lib/evaluation/evaluators/semantic/index.js +7 -0
- package/dist/collection/lib/evaluation/evaluators/semantic/index.js.map +1 -0
- package/dist/collection/lib/evaluation/evaluators/semantic/model-loader.js +19 -0
- package/dist/collection/lib/evaluation/evaluators/semantic/model-loader.js.map +1 -0
- package/dist/collection/lib/evaluation/evaluators/semantic/similarity-utils.js +16 -0
- package/dist/collection/lib/evaluation/evaluators/semantic/similarity-utils.js.map +1 -0
- package/dist/collection/lib/evaluation/evaluators/semantic/tests/evaluate-keywords.test.js +65 -0
- package/dist/collection/lib/evaluation/evaluators/semantic/tests/evaluate-keywords.test.js.map +1 -0
- package/dist/collection/lib/evaluation/evaluators/semantic/text-utils.js +5 -0
- package/dist/collection/lib/evaluation/evaluators/semantic/text-utils.js.map +1 -0
- package/dist/collection/lib/evaluation/index.js.map +1 -1
- package/dist/collection/lib/evaluation/rouge1-evaluator.test.js +117 -0
- package/dist/collection/lib/evaluation/rouge1-evaluator.test.js.map +1 -0
- package/dist/collection/lib/evaluation/types.js.map +1 -1
- package/dist/collection/lib/file/file-download.js +18 -0
- package/dist/collection/lib/file/file-download.js.map +1 -0
- package/dist/collection/lib/file/file-reader.js +14 -0
- package/dist/collection/lib/file/file-reader.js.map +1 -0
- package/dist/collection/lib/form/components/app-chips.css +97 -0
- package/dist/collection/lib/form/components/app-chips.js +155 -0
- package/dist/collection/lib/form/components/app-chips.js.map +1 -0
- package/dist/collection/lib/form/components/app-select.css +28 -0
- package/dist/collection/lib/form/components/app-select.js +101 -0
- package/dist/collection/lib/form/components/app-select.js.map +1 -0
- package/dist/collection/lib/form/components/app-textarea.css +38 -0
- package/dist/collection/lib/form/components/app-textarea.js +126 -0
- package/dist/collection/lib/form/components/app-textarea.js.map +1 -0
- package/dist/collection/lib/form/form-builder.js +171 -0
- package/dist/collection/lib/form/form-builder.js.map +1 -0
- package/dist/collection/lib/form/schema/base-input-field-config.js +2 -0
- package/dist/collection/lib/form/schema/base-input-field-config.js.map +1 -0
- package/dist/collection/lib/form/schema/form-control-config.js +2 -0
- package/dist/collection/lib/form/schema/form-control-config.js.map +1 -0
- package/dist/collection/lib/form/schema/index.js +8 -0
- package/dist/collection/lib/form/schema/index.js.map +1 -0
- package/dist/collection/lib/import-export/test-results-csv.js +65 -0
- package/dist/collection/lib/import-export/test-results-csv.js.map +1 -0
- package/dist/collection/lib/import-export/test-suite-exporter.js +15 -0
- package/dist/collection/lib/import-export/test-suite-exporter.js.map +1 -0
- package/dist/collection/lib/import-export/test-suite-importer.js +44 -0
- package/dist/collection/lib/import-export/test-suite-importer.js.map +1 -0
- package/dist/collection/lib/rate-limited-fetcher/rate-limited-fetcher.js +6 -6
- package/dist/collection/lib/rate-limited-fetcher/rate-limited-fetcher.js.map +1 -1
- package/dist/collection/lib/test-cases/test-case-factory.js +56 -0
- package/dist/collection/lib/test-cases/test-case-factory.js.map +1 -0
- package/dist/collection/lib/test-cases/test-case-mutations.js +16 -0
- package/dist/collection/lib/test-cases/test-case-mutations.js.map +1 -0
- package/dist/collection/lib/ui/button/button.css +113 -0
- package/dist/collection/lib/ui/button/button.js +21 -0
- package/dist/collection/lib/ui/button/button.js.map +1 -0
- package/dist/collection/lib/ui/button/index.js +2 -0
- package/dist/collection/lib/ui/button/index.js.map +1 -0
- package/dist/collection/lib/ui/icon-button/icon-button.css +77 -0
- package/dist/collection/lib/ui/icon-button/icon-button.js +19 -0
- package/dist/collection/lib/ui/icon-button/icon-button.js.map +1 -0
- package/dist/collection/lib/ui/icon-button/index.js +2 -0
- package/dist/collection/lib/ui/icon-button/index.js.map +1 -0
- package/dist/collection/services/adapters.js +2 -0
- package/dist/collection/services/adapters.js.map +1 -0
- package/dist/collection/services/models/gemini.js +17 -0
- package/dist/collection/services/models/gemini.js.map +1 -0
- package/dist/collection/styles/tokens.css +180 -0
- package/dist/collection/types/evaluation.js +2 -0
- package/dist/collection/types/evaluation.js.map +1 -0
- package/dist/collection/types/llm-test-runner.js +2 -0
- package/dist/collection/types/llm-test-runner.js.map +1 -0
- package/dist/components/app-chips.d.ts +11 -0
- package/dist/components/app-chips.js +2 -0
- package/dist/components/app-chips.js.map +1 -0
- package/dist/components/app-select.d.ts +11 -0
- package/dist/components/app-select.js +2 -0
- package/dist/components/app-select.js.map +1 -0
- package/dist/components/app-textarea.d.ts +11 -0
- package/dist/components/app-textarea.js +2 -0
- package/dist/components/app-textarea.js.map +1 -0
- package/dist/components/form-builder.d.ts +11 -0
- package/dist/components/form-builder.js +2 -0
- package/dist/components/form-builder.js.map +1 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +1 -13
- package/dist/components/index.js.map +1 -1
- package/dist/components/llm-test-runner.js +1 -8
- package/dist/components/llm-test-runner.js.map +1 -1
- package/dist/components/p--2rdv_J9.js +2 -0
- package/dist/components/p--2rdv_J9.js.map +1 -0
- package/dist/components/p-B7J48VNq.js +2 -0
- package/dist/components/p-B7J48VNq.js.map +1 -0
- package/dist/components/p-BCB1rjPS.js +7 -0
- package/dist/components/p-BCB1rjPS.js.map +1 -0
- package/dist/components/p-BQhb2H_a.js +2 -0
- package/dist/components/p-BQhb2H_a.js.map +1 -0
- package/dist/components/p-D9BrlHdP.js +297 -0
- package/dist/components/p-D9BrlHdP.js.map +1 -0
- package/dist/components/p-DtCkZ1g2.js +2 -0
- package/dist/components/p-DtCkZ1g2.js.map +1 -0
- package/dist/esm/app-chips_5.entry.js +153 -0
- package/dist/esm/app-chips_5.entry.js.map +1 -0
- package/dist/esm/app-globals-DbR5vV7d.js +32 -0
- package/dist/esm/app-globals-DbR5vV7d.js.map +1 -0
- package/dist/esm/index-Bvg6mh1M.js +25539 -0
- package/dist/esm/index-Bvg6mh1M.js.map +1 -0
- package/dist/esm/index-DxzhGhec.js +21450 -0
- package/dist/esm/index-DxzhGhec.js.map +1 -0
- package/dist/esm/index.js +4 -486
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/llm-testrunner.js +7 -5
- package/dist/esm/llm-testrunner.js.map +1 -1
- package/dist/esm/loader.js +6 -4
- package/dist/llm-testrunner/index.esm.js +1 -1
- package/dist/llm-testrunner/index.esm.js.map +1 -1
- package/dist/llm-testrunner/llm-testrunner.esm.js +1 -1
- package/dist/llm-testrunner/llm-testrunner.esm.js.map +1 -1
- package/dist/llm-testrunner/p-3f04b0fb.entry.js +2 -0
- package/dist/llm-testrunner/p-3f04b0fb.entry.js.map +1 -0
- package/dist/llm-testrunner/p-DFds8y01.js +7 -0
- package/dist/llm-testrunner/p-DFds8y01.js.map +1 -0
- package/dist/llm-testrunner/p-DxzhGhec.js +298 -0
- package/dist/llm-testrunner/p-DxzhGhec.js.map +1 -0
- package/dist/llm-testrunner/p-GQwFOmwJ.js +2 -0
- package/dist/llm-testrunner/p-GQwFOmwJ.js.map +1 -0
- package/dist/react/components.d.ts +32 -2
- package/dist/react/components.d.ts.map +1 -1
- package/dist/react/components.js +44 -2
- package/dist/types/components/llm-test-runner/header/llm-test-runner-header.d.ts +14 -0
- package/dist/types/components/llm-test-runner/llm-test-runner.d.ts +13 -29
- package/dist/types/components/llm-test-runner/llm-test-runner.import-export.test.d.ts +1 -0
- package/dist/types/components/llm-test-runner/test-cases/actions/row-actions.d.ts +8 -0
- package/dist/types/components/llm-test-runner/test-cases/evaluation/evaluation-summary.d.ts +7 -0
- package/dist/types/components/llm-test-runner/test-cases/llm-test-case-row.d.ts +25 -0
- package/dist/types/components/llm-test-runner/test-cases/llm-test-cases.d.ts +26 -0
- package/dist/types/components/llm-test-runner/test-cases/output/response-output.d.ts +6 -0
- package/dist/types/components.d.ts +199 -4
- package/dist/types/global/env.d.ts +2 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/lib/evaluation/constants.d.ts +11 -0
- package/dist/types/lib/evaluation/evaluation-engine.d.ts +0 -4
- package/dist/types/lib/evaluation/evaluation-service.d.ts +15 -0
- package/dist/types/lib/evaluation/evaluators/bleu/bleu-evaluator.d.ts +18 -0
- package/dist/types/lib/evaluation/evaluators/bleu/tests/bleu.test.d.ts +1 -0
- package/dist/types/lib/evaluation/evaluators/exact/exact.d.ts +2 -0
- package/dist/types/lib/evaluation/evaluators/rouge1-evaluator.d.ts +17 -0
- package/dist/types/lib/evaluation/evaluators/rougeL-evaluator.d.ts +2 -0
- package/dist/types/lib/evaluation/evaluators/rougeL-evaluator.test.d.ts +1 -0
- package/dist/types/lib/evaluation/evaluators/semantic/SemanticEvaluator.d.ts +6 -0
- package/dist/types/lib/evaluation/evaluators/semantic/evaluate-keywords.d.ts +7 -0
- package/dist/types/lib/evaluation/evaluators/semantic/index.d.ts +2 -0
- package/dist/types/lib/evaluation/evaluators/semantic/model-loader.d.ts +1 -0
- package/dist/types/lib/evaluation/evaluators/semantic/similarity-utils.d.ts +1 -0
- package/dist/types/lib/evaluation/evaluators/semantic/tests/evaluate-keywords.test.d.ts +1 -0
- package/dist/types/lib/evaluation/evaluators/semantic/text-utils.d.ts +1 -0
- package/dist/types/lib/evaluation/index.d.ts +2 -2
- package/dist/types/lib/evaluation/rouge1-evaluator.test.d.ts +1 -0
- package/dist/types/lib/evaluation/types.d.ts +19 -7
- package/dist/types/lib/file/file-download.d.ts +7 -0
- package/dist/types/lib/file/file-reader.d.ts +6 -0
- package/dist/types/lib/form/components/app-chips.d.ts +20 -0
- package/dist/types/lib/form/components/app-select.d.ts +7 -0
- package/dist/types/lib/form/components/app-textarea.d.ts +14 -0
- package/dist/types/lib/form/form-builder.d.ts +24 -0
- package/dist/types/lib/form/schema/base-input-field-config.d.ts +37 -0
- package/dist/types/lib/form/schema/form-control-config.d.ts +13 -0
- package/dist/types/lib/form/schema/index.d.ts +9 -0
- package/dist/types/lib/import-export/test-results-csv.d.ts +13 -0
- package/dist/types/lib/import-export/test-suite-exporter.d.ts +16 -0
- package/dist/types/lib/import-export/test-suite-importer.d.ts +12 -0
- package/dist/types/lib/rate-limited-fetcher/rate-limited-fetcher.d.ts +1 -1
- package/dist/types/lib/test-cases/test-case-factory.d.ts +12 -0
- package/dist/types/lib/test-cases/test-case-mutations.d.ts +9 -0
- package/dist/types/lib/ui/button/button.d.ts +13 -0
- package/dist/types/lib/ui/button/index.d.ts +2 -0
- package/dist/types/lib/ui/icon-button/icon-button.d.ts +11 -0
- package/dist/types/lib/ui/icon-button/index.d.ts +2 -0
- package/dist/types/services/adapters.d.ts +3 -0
- package/dist/types/services/models/gemini.d.ts +11 -0
- package/dist/types/stencil-public-runtime.d.ts +110 -6
- package/dist/types/types/evaluation.d.ts +9 -0
- package/dist/types/types/llm-test-runner.d.ts +22 -0
- package/package.json +30 -6
- package/dist/cjs/app-globals-CbbEbofA.js +0 -14
- package/dist/cjs/app-globals-CbbEbofA.js.map +0 -1
- package/dist/cjs/index-D-FySkoV.js +0 -1470
- package/dist/cjs/index-D-FySkoV.js.map +0 -1
- package/dist/cjs/llm-test-runner.cjs.entry.js +0 -9
- package/dist/cjs/llm-test-runner.entry.cjs.js.map +0 -1
- package/dist/components/p-CYUbsbxt.js +0 -1770
- package/dist/components/p-CYUbsbxt.js.map +0 -1
- package/dist/esm/app-globals-BOQOUavG.js +0 -12
- package/dist/esm/app-globals-BOQOUavG.js.map +0 -1
- package/dist/esm/index-cncubhtM.js +0 -1463
- package/dist/esm/index-cncubhtM.js.map +0 -1
- package/dist/esm/llm-test-runner.entry.js +0 -3
- package/dist/esm/llm-test-runner.entry.js.map +0 -1
- package/dist/llm-testrunner/llm-test-runner.entry.esm.js.map +0 -1
- package/dist/llm-testrunner/loader.esm.js.map +0 -1
- package/dist/llm-testrunner/p-BOQOUavG.js +0 -2
- package/dist/llm-testrunner/p-BOQOUavG.js.map +0 -1
- package/dist/llm-testrunner/p-cncubhtM.js +0 -3
- package/dist/llm-testrunner/p-cncubhtM.js.map +0 -1
- package/dist/llm-testrunner/p-f68fd660.entry.js +0 -2
- package/dist/llm-testrunner/p-f68fd660.entry.js.map +0 -1
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
const e="llm-testrunner";const n={hotModuleReplacement:false,hydratedSelectorName:"hydrated",lazyLoad:true,propChangeCallback:false,state:true,updatable:true};function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e["default"]:e}function i(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 o={exports:{}};var r={};var s;var l;function u(){if(l)return s;l=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)}}s=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 s}var a;function c(){if(a)return r;a=1;(function(e){var n=u();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}}})(r);return r}var f;var d;function p(){if(d)return f;d=1;f=c();return f}var h;function m(){if(h)return o.exports;h=1;const e=p();const n=["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"];class t 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 i=(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,o)=>new Promise(((s,l)=>{o={onFailedAttempt:()=>{},retries:10,...o};const u=e.operation(o);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 t){u.stop();l(n.originalError)}else if(n instanceof TypeError&&!r(n.message)){u.stop();l(n)}else{i(n,e,o);try{await o.onFailedAttempt(n)}catch(e){l(e);return}if(!u.retry(n)){l(u.mainError())}}}}))}));o.exports=s;o.exports.default=s;o.exports.AbortError=t;return o.exports}var g=m();var y=t(g);
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2025 Google LLC
|
|
5
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
*/let v=undefined;let E=undefined;function w(){return{geminiUrl:v,vertexUrl:E}}function b(e,n,t,i){var o,r;if(!(e===null||e===void 0?void 0:e.baseUrl)){const e=w();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 T{}function S(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 I(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];I(r,n.slice(i+1),t[e])}}else{for(const e of o){I(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];I(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 A(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=>A(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 O(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)}}}C(e,n,o,0,r)}}function C(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]){C(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)}}I(n,r,o)}for(const e of r){delete n[e]}}}else{const s=e;if(r in s){C(s[r],n,t,i+1,o)}}}
|
|
12
|
+
/**
|
|
13
|
+
* @license
|
|
14
|
+
* Copyright 2025 Google LLC
|
|
15
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
16
|
+
*/function _(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 P(e){const n={};const t=A(e,["operationName"]);if(t!=null){I(n,["operationName"],t)}const i=A(e,["resourceName"]);if(i!=null){I(n,["_url","resourceName"],i)}return n}function R(e){const n={};const t=A(e,["name"]);if(t!=null){I(n,["name"],t)}const i=A(e,["metadata"]);if(i!=null){I(n,["metadata"],i)}const o=A(e,["done"]);if(o!=null){I(n,["done"],o)}const r=A(e,["error"]);if(r!=null){I(n,["error"],r)}const s=A(e,["response","generateVideoResponse"]);if(s!=null){I(n,["response"],M(s))}return n}function N(e){const n={};const t=A(e,["name"]);if(t!=null){I(n,["name"],t)}const i=A(e,["metadata"]);if(i!=null){I(n,["metadata"],i)}const o=A(e,["done"]);if(o!=null){I(n,["done"],o)}const r=A(e,["error"]);if(r!=null){I(n,["error"],r)}const s=A(e,["response"]);if(s!=null){I(n,["response"],D(s))}return n}function M(e){const n={};const t=A(e,["generatedSamples"]);if(t!=null){let e=t;if(Array.isArray(e)){e=e.map((e=>U(e)))}I(n,["generatedVideos"],e)}const i=A(e,["raiMediaFilteredCount"]);if(i!=null){I(n,["raiMediaFilteredCount"],i)}const o=A(e,["raiMediaFilteredReasons"]);if(o!=null){I(n,["raiMediaFilteredReasons"],o)}return n}function D(e){const n={};const t=A(e,["videos"]);if(t!=null){let e=t;if(Array.isArray(e)){e=e.map((e=>k(e)))}I(n,["generatedVideos"],e)}const i=A(e,["raiMediaFilteredCount"]);if(i!=null){I(n,["raiMediaFilteredCount"],i)}const o=A(e,["raiMediaFilteredReasons"]);if(o!=null){I(n,["raiMediaFilteredReasons"],o)}return n}function U(e){const n={};const t=A(e,["video"]);if(t!=null){I(n,["video"],H(t))}return n}function k(e){const n={};const t=A(e,["_self"]);if(t!=null){I(n,["video"],$(t))}return n}function G(e){const n={};const t=A(e,["operationName"]);if(t!=null){I(n,["_url","operationName"],t)}return n}function x(e){const n={};const t=A(e,["operationName"]);if(t!=null){I(n,["_url","operationName"],t)}return n}function L(e){const n={};const t=A(e,["name"]);if(t!=null){I(n,["name"],t)}const i=A(e,["metadata"]);if(i!=null){I(n,["metadata"],i)}const o=A(e,["done"]);if(o!=null){I(n,["done"],o)}const r=A(e,["error"]);if(r!=null){I(n,["error"],r)}const s=A(e,["response"]);if(s!=null){I(n,["response"],j(s))}return n}function j(e){const n={};const t=A(e,["sdkHttpResponse"]);if(t!=null){I(n,["sdkHttpResponse"],t)}const i=A(e,["parent"]);if(i!=null){I(n,["parent"],i)}const o=A(e,["documentName"]);if(o!=null){I(n,["documentName"],o)}return n}function F(e){const n={};const t=A(e,["name"]);if(t!=null){I(n,["name"],t)}const i=A(e,["metadata"]);if(i!=null){I(n,["metadata"],i)}const o=A(e,["done"]);if(o!=null){I(n,["done"],o)}const r=A(e,["error"]);if(r!=null){I(n,["error"],r)}const s=A(e,["response"]);if(s!=null){I(n,["response"],q(s))}return n}function q(e){const n={};const t=A(e,["sdkHttpResponse"]);if(t!=null){I(n,["sdkHttpResponse"],t)}const i=A(e,["parent"]);if(i!=null){I(n,["parent"],i)}const o=A(e,["documentName"]);if(o!=null){I(n,["documentName"],o)}return n}function H(e){const n={};const t=A(e,["uri"]);if(t!=null){I(n,["uri"],t)}const i=A(e,["encodedVideo"]);if(i!=null){I(n,["videoBytes"],_(i))}const o=A(e,["encoding"]);if(o!=null){I(n,["mimeType"],o)}return n}function $(e){const n={};const t=A(e,["gcsUri"]);if(t!=null){I(n,["uri"],t)}const i=A(e,["bytesBase64Encoded"]);if(i!=null){I(n,["videoBytes"],_(i))}const o=A(e,["mimeType"]);if(o!=null){I(n,["mimeType"],o)}return n}
|
|
22
|
+
/**
|
|
23
|
+
* @license
|
|
24
|
+
* Copyright 2025 Google LLC
|
|
25
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
26
|
+
*/var J;(function(e){e["OUTCOME_UNSPECIFIED"]="OUTCOME_UNSPECIFIED";e["OUTCOME_OK"]="OUTCOME_OK";e["OUTCOME_FAILED"]="OUTCOME_FAILED";e["OUTCOME_DEADLINE_EXCEEDED"]="OUTCOME_DEADLINE_EXCEEDED"})(J||(J={}));var V;(function(e){e["LANGUAGE_UNSPECIFIED"]="LANGUAGE_UNSPECIFIED";e["PYTHON"]="PYTHON"})(V||(V={}));var B;(function(e){e["SCHEDULING_UNSPECIFIED"]="SCHEDULING_UNSPECIFIED";e["SILENT"]="SILENT";e["WHEN_IDLE"]="WHEN_IDLE";e["INTERRUPT"]="INTERRUPT"})(B||(B={}));var W;(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"})(W||(W={}));var Y;(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"})(Y||(Y={}));var K;(function(e){e["API_SPEC_UNSPECIFIED"]="API_SPEC_UNSPECIFIED";e["SIMPLE_SEARCH"]="SIMPLE_SEARCH";e["ELASTIC_SEARCH"]="ELASTIC_SEARCH"})(K||(K={}));var z;(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"})(z||(z={}));var X;(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"})(X||(X={}));var Q;(function(e){e["UNSPECIFIED"]="UNSPECIFIED";e["BLOCKING"]="BLOCKING";e["NON_BLOCKING"]="NON_BLOCKING"})(Q||(Q={}));var Z;(function(e){e["MODE_UNSPECIFIED"]="MODE_UNSPECIFIED";e["MODE_DYNAMIC"]="MODE_DYNAMIC"})(Z||(Z={}));var ee;(function(e){e["MODE_UNSPECIFIED"]="MODE_UNSPECIFIED";e["AUTO"]="AUTO";e["ANY"]="ANY";e["NONE"]="NONE";e["VALIDATED"]="VALIDATED"})(ee||(ee={}));var ne;(function(e){e["THINKING_LEVEL_UNSPECIFIED"]="THINKING_LEVEL_UNSPECIFIED";e["LOW"]="LOW";e["MEDIUM"]="MEDIUM";e["HIGH"]="HIGH";e["MINIMAL"]="MINIMAL"})(ne||(ne={}));var te;(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"})(te||(te={}));var ie;(function(e){e["HARM_BLOCK_METHOD_UNSPECIFIED"]="HARM_BLOCK_METHOD_UNSPECIFIED";e["SEVERITY"]="SEVERITY";e["PROBABILITY"]="PROBABILITY"})(ie||(ie={}));var oe;(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"})(oe||(oe={}));var re;(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"})(re||(re={}));var se;(function(e){e["HARM_PROBABILITY_UNSPECIFIED"]="HARM_PROBABILITY_UNSPECIFIED";e["NEGLIGIBLE"]="NEGLIGIBLE";e["LOW"]="LOW";e["MEDIUM"]="MEDIUM";e["HIGH"]="HIGH"})(se||(se={}));var le;(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"})(le||(le={}));var ue;(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"})(ue||(ue={}));var ae;(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"})(ae||(ae={}));var ce;(function(e){e["TRAFFIC_TYPE_UNSPECIFIED"]="TRAFFIC_TYPE_UNSPECIFIED";e["ON_DEMAND"]="ON_DEMAND";e["PROVISIONED_THROUGHPUT"]="PROVISIONED_THROUGHPUT"})(ce||(ce={}));var fe;(function(e){e["MODALITY_UNSPECIFIED"]="MODALITY_UNSPECIFIED";e["TEXT"]="TEXT";e["IMAGE"]="IMAGE";e["AUDIO"]="AUDIO"})(fe||(fe={}));var de;(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"})(de||(de={}));var pe;(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"})(pe||(pe={}));var he;(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"})(he||(he={}));var me;(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"})(me||(me={}));var ge;(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"})(ge||(ge={}));var ye;(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"})(ye||(ye={}));var ve;(function(e){e["COLLECTION"]="COLLECTION"})(ve||(ve={}));var Ee;(function(e){e["FEATURE_SELECTION_PREFERENCE_UNSPECIFIED"]="FEATURE_SELECTION_PREFERENCE_UNSPECIFIED";e["PRIORITIZE_QUALITY"]="PRIORITIZE_QUALITY";e["BALANCED"]="BALANCED";e["PRIORITIZE_COST"]="PRIORITIZE_COST"})(Ee||(Ee={}));var we;(function(e){e["ENVIRONMENT_UNSPECIFIED"]="ENVIRONMENT_UNSPECIFIED";e["ENVIRONMENT_BROWSER"]="ENVIRONMENT_BROWSER"})(we||(we={}));var be;(function(e){e["PROMINENT_PEOPLE_UNSPECIFIED"]="PROMINENT_PEOPLE_UNSPECIFIED";e["ALLOW_PROMINENT_PEOPLE"]="ALLOW_PROMINENT_PEOPLE";e["BLOCK_PROMINENT_PEOPLE"]="BLOCK_PROMINENT_PEOPLE"})(be||(be={}));var Te;(function(e){e["PREDICT"]="PREDICT";e["EMBED_CONTENT"]="EMBED_CONTENT"})(Te||(Te={}));var Se;(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"})(Se||(Se={}));var Ie;(function(e){e["DONT_ALLOW"]="DONT_ALLOW";e["ALLOW_ADULT"]="ALLOW_ADULT";e["ALLOW_ALL"]="ALLOW_ALL"})(Ie||(Ie={}));var Ae;(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"})(Ae||(Ae={}));var Oe;(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"})(Oe||(Oe={}));var Ce;(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"})(Ce||(Ce={}));var _e;(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"})(_e||(_e={}));var Pe;(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"})(Pe||(Pe={}));var Re;(function(e){e["FOREGROUND"]="FOREGROUND";e["BACKGROUND"]="BACKGROUND";e["PROMPT"]="PROMPT";e["SEMANTIC"]="SEMANTIC";e["INTERACTIVE"]="INTERACTIVE"})(Re||(Re={}));var Ne;(function(e){e["ASSET"]="ASSET";e["STYLE"]="STYLE"})(Ne||(Ne={}));var Me;(function(e){e["INSERT"]="INSERT";e["REMOVE"]="REMOVE";e["REMOVE_STATIC"]="REMOVE_STATIC";e["OUTPAINT"]="OUTPAINT"})(Me||(Me={}));var De;(function(e){e["OPTIMIZED"]="OPTIMIZED";e["LOSSLESS"]="LOSSLESS"})(De||(De={}));var Ue;(function(e){e["SUPERVISED_FINE_TUNING"]="SUPERVISED_FINE_TUNING";e["PREFERENCE_TUNING"]="PREFERENCE_TUNING";e["DISTILLATION"]="DISTILLATION"})(Ue||(Ue={}));var ke;(function(e){e["STATE_UNSPECIFIED"]="STATE_UNSPECIFIED";e["STATE_PENDING"]="STATE_PENDING";e["STATE_ACTIVE"]="STATE_ACTIVE";e["STATE_FAILED"]="STATE_FAILED"})(ke||(ke={}));var Ge;(function(e){e["STATE_UNSPECIFIED"]="STATE_UNSPECIFIED";e["PROCESSING"]="PROCESSING";e["ACTIVE"]="ACTIVE";e["FAILED"]="FAILED"})(Ge||(Ge={}));var xe;(function(e){e["SOURCE_UNSPECIFIED"]="SOURCE_UNSPECIFIED";e["UPLOADED"]="UPLOADED";e["GENERATED"]="GENERATED";e["REGISTERED"]="REGISTERED"})(xe||(xe={}));var Le;(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"})(Le||(Le={}));var je;(function(e){e["MODALITY_UNSPECIFIED"]="MODALITY_UNSPECIFIED";e["TEXT"]="TEXT";e["IMAGE"]="IMAGE";e["VIDEO"]="VIDEO";e["AUDIO"]="AUDIO";e["DOCUMENT"]="DOCUMENT"})(je||(je={}));var Fe;(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"})(Fe||(Fe={}));var qe;(function(e){e["TYPE_UNSPECIFIED"]="TYPE_UNSPECIFIED";e["ACTIVITY_START"]="ACTIVITY_START";e["ACTIVITY_END"]="ACTIVITY_END"})(qe||(qe={}));var He;(function(e){e["START_SENSITIVITY_UNSPECIFIED"]="START_SENSITIVITY_UNSPECIFIED";e["START_SENSITIVITY_HIGH"]="START_SENSITIVITY_HIGH";e["START_SENSITIVITY_LOW"]="START_SENSITIVITY_LOW"})(He||(He={}));var $e;(function(e){e["END_SENSITIVITY_UNSPECIFIED"]="END_SENSITIVITY_UNSPECIFIED";e["END_SENSITIVITY_HIGH"]="END_SENSITIVITY_HIGH";e["END_SENSITIVITY_LOW"]="END_SENSITIVITY_LOW"})($e||($e={}));var Je;(function(e){e["ACTIVITY_HANDLING_UNSPECIFIED"]="ACTIVITY_HANDLING_UNSPECIFIED";e["START_OF_ACTIVITY_INTERRUPTS"]="START_OF_ACTIVITY_INTERRUPTS";e["NO_INTERRUPTION"]="NO_INTERRUPTION"})(Je||(Je={}));var Ve;(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"})(Ve||(Ve={}));var Be;(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"})(Be||(Be={}));var We;(function(e){e["MUSIC_GENERATION_MODE_UNSPECIFIED"]="MUSIC_GENERATION_MODE_UNSPECIFIED";e["QUALITY"]="QUALITY";e["DIVERSITY"]="DIVERSITY";e["VOCALIZATION"]="VOCALIZATION"})(We||(We={}));var Ye;(function(e){e["PLAYBACK_CONTROL_UNSPECIFIED"]="PLAYBACK_CONTROL_UNSPECIFIED";e["PLAY"]="PLAY";e["PAUSE"]="PAUSE";e["STOP"]="STOP";e["RESET_CONTEXT"]="RESET_CONTEXT"})(Ye||(Ye={}));class Ke{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 ze{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 Xe{}class Qe{}class Ze{}class en{}class nn{}class tn{}class on{}class rn{}class sn{}class ln{}class un{_fromAPIResponse({apiResponse:e,_isVertexAI:n}){const t=new un;let i;const o=e;if(n){i=N(o)}else{i=R(o)}Object.assign(t,i);return t}}class an{}class cn{}class fn{}class dn{}class pn{}class hn{}class mn{}class gn{_fromAPIResponse({apiResponse:e,_isVertexAI:n}){const t=new gn;const i=e;const o=L(i);Object.assign(t,o);return t}}class yn{}class vn{}class En{}class wn{}class bn{}class Tn{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 Sn{get audioChunk(){if(this.serverContent&&this.serverContent.audioChunks&&this.serverContent.audioChunks.length>0){return this.serverContent.audioChunks[0]}return undefined}}class In{_fromAPIResponse({apiResponse:e,_isVertexAI:n}){const t=new In;const i=e;const o=F(i);Object.assign(t,o);return t}}
|
|
27
|
+
/**
|
|
28
|
+
* @license
|
|
29
|
+
* Copyright 2025 Google LLC
|
|
30
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
31
|
+
*/function An(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 On(e,n){const t=An(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 Cn(e){if(Array.isArray(e)){return e.map((e=>_n(e)))}else{return[_n(e)]}}function _n(e){if(typeof e==="object"&&e!==null){return e}throw new Error(`Could not parse input as Blob. Unsupported blob type: ${typeof e}`)}function Pn(e){const n=_n(e);if(n.mimeType&&n.mimeType.startsWith("image/")){return n}throw new Error(`Unsupported mime type: ${n.mimeType}`)}function Rn(e){const n=_n(e);if(n.mimeType&&n.mimeType.startsWith("audio/")){return n}throw new Error(`Unsupported mime type: ${n.mimeType}`)}function Nn(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 Mn(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=>Nn(e)))}return[Nn(e)]}function Dn(e){return e!==null&&e!==undefined&&typeof e==="object"&&"parts"in e&&Array.isArray(e.parts)}function Un(e){return e!==null&&e!==undefined&&typeof e==="object"&&"functionCall"in e}function kn(e){return e!==null&&e!==undefined&&typeof e==="object"&&"functionResponse"in e}function Gn(e){if(e===null||e===undefined){throw new Error("ContentUnion is required")}if(Dn(e)){return e}return{role:"user",parts:Mn(e)}}function xn(e,n){if(!n){return[]}if(e.isVertexAI()&&Array.isArray(n)){return n.flatMap((e=>{const n=Gn(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=Gn(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=>Gn(e)))}return[Gn(n)]}function Ln(e){if(e===null||e===undefined||Array.isArray(e)&&e.length===0){throw new Error("contents are required")}if(!Array.isArray(e)){if(Un(e)||kn(e)){throw new Error("To specify functionCall or functionResponse parts, please wrap them in a Content object, specifying the role for them")}return[Gn(e)]}const n=[];const t=[];const i=Dn(e[0]);for(const o of e){const e=Dn(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(Un(o)||kn(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:Mn(t)})}return n}function jn(e,n){if(e.includes("null")){n["nullable"]=true}const t=e.filter((e=>e!=="null"));if(t.length===1){n["type"]=Object.values(W).includes(t[0].toUpperCase())?t[0].toUpperCase():W.TYPE_UNSPECIFIED}else{n["anyOf"]=[];for(const e of t){n["anyOf"].push({type:Object.values(W).includes(e.toUpperCase())?e.toUpperCase():W.TYPE_UNSPECIFIED})}}}function Fn(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){jn(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(W).includes(s.toUpperCase())?s.toUpperCase():W.TYPE_UNSPECIFIED}else if(t.includes(r)){n[r]=Fn(s)}else if(i.includes(r)){const e=[];for(const t of s){if(t["type"]=="null"){n["nullable"]=true;continue}e.push(Fn(t))}n[r]=e}else if(o.includes(r)){const e={};for(const[n,t]of Object.entries(s)){e[n]=Fn(t)}n[r]=e}else{if(r==="additionalProperties"){continue}n[r]=s}}return n}function qn(e){return Fn(e)}function Hn(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 $n(e){if("multiSpeakerVoiceConfig"in e){throw new Error("multiSpeakerVoiceConfig is not supported in the live API.")}return e}function Jn(e){if(e.functionDeclarations){for(const n of e.functionDeclarations){if(n.parameters){if(!Object.keys(n.parameters).includes("$schema")){n.parameters=Fn(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=Fn(n.response)}else{if(!n.responseJsonSchema){n.responseJsonSchema=n.response;delete n.response}}}}}return e}function Vn(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 Bn(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 Wn(e,n){if(typeof n!=="string"){throw new Error("name must be a string")}return Bn(e,n,"cachedContents")}function Yn(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 Kn(e){return _(e)}function zn(e){return e!==null&&e!==undefined&&typeof e==="object"&&"name"in e}function Xn(e){return e!==null&&e!==undefined&&typeof e==="object"&&"video"in e}function Qn(e){return e!==null&&e!==undefined&&typeof e==="object"&&"uri"in e}function Zn(e){var n;let t;if(zn(e)){t=e.name}if(Qn(e)){t=e.uri;if(t===undefined){return undefined}}if(Xn(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 et(e,n){let t;if(e.isVertexAI()){t=n?"publishers/google/models":"models"}else{t=n?"models":"tunedModels"}return t}function nt(e){for(const n of["models","tunedModels","publisherModels"]){if(tt(e,n)){return e[n]}}return[]}function tt(e,n){return e!==null&&typeof e==="object"&&n in e}function it(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 ot(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=it(o,n);if(r.functionDeclarations){t.push(...r.functionDeclarations)}}return{functionDeclarations:t}}function rt(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 st(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 lt(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 ut(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 at(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 ct(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 ft(e){const n={};const t=A(e,["responsesFile"]);if(t!=null){I(n,["fileName"],t)}const i=A(e,["inlinedResponses","inlinedResponses"]);if(i!=null){let e=i;if(Array.isArray(e)){e=e.map((e=>Kt(e)))}I(n,["inlinedResponses"],e)}const o=A(e,["inlinedEmbedContentResponses","inlinedResponses"]);if(o!=null){let e=o;if(Array.isArray(e)){e=e.map((e=>e))}I(n,["inlinedEmbedContentResponses"],e)}return n}function dt(e){const n={};const t=A(e,["predictionsFormat"]);if(t!=null){I(n,["format"],t)}const i=A(e,["gcsDestination","outputUriPrefix"]);if(i!=null){I(n,["gcsUri"],i)}const o=A(e,["bigqueryDestination","outputUri"]);if(o!=null){I(n,["bigqueryUri"],o)}return n}function pt(e){const n={};const t=A(e,["format"]);if(t!=null){I(n,["predictionsFormat"],t)}const i=A(e,["gcsUri"]);if(i!=null){I(n,["gcsDestination","outputUriPrefix"],i)}const o=A(e,["bigqueryUri"]);if(o!=null){I(n,["bigqueryDestination","outputUri"],o)}if(A(e,["fileName"])!==undefined){throw new Error("fileName parameter is not supported in Vertex AI.")}if(A(e,["inlinedResponses"])!==undefined){throw new Error("inlinedResponses parameter is not supported in Vertex AI.")}if(A(e,["inlinedEmbedContentResponses"])!==undefined){throw new Error("inlinedEmbedContentResponses parameter is not supported in Vertex AI.")}return n}function ht(e){const n={};const t=A(e,["name"]);if(t!=null){I(n,["name"],t)}const i=A(e,["metadata","displayName"]);if(i!=null){I(n,["displayName"],i)}const o=A(e,["metadata","state"]);if(o!=null){I(n,["state"],at(o))}const r=A(e,["metadata","createTime"]);if(r!=null){I(n,["createTime"],r)}const s=A(e,["metadata","endTime"]);if(s!=null){I(n,["endTime"],s)}const l=A(e,["metadata","updateTime"]);if(l!=null){I(n,["updateTime"],l)}const u=A(e,["metadata","model"]);if(u!=null){I(n,["model"],u)}const a=A(e,["metadata","output"]);if(a!=null){I(n,["dest"],ft(lt(a)))}return n}function mt(e){const n={};const t=A(e,["name"]);if(t!=null){I(n,["name"],t)}const i=A(e,["displayName"]);if(i!=null){I(n,["displayName"],i)}const o=A(e,["state"]);if(o!=null){I(n,["state"],at(o))}const r=A(e,["error"]);if(r!=null){I(n,["error"],r)}const s=A(e,["createTime"]);if(s!=null){I(n,["createTime"],s)}const l=A(e,["startTime"]);if(l!=null){I(n,["startTime"],l)}const u=A(e,["endTime"]);if(u!=null){I(n,["endTime"],u)}const a=A(e,["updateTime"]);if(a!=null){I(n,["updateTime"],a)}const c=A(e,["model"]);if(c!=null){I(n,["model"],c)}const f=A(e,["inputConfig"]);if(f!=null){I(n,["src"],gt(f))}const d=A(e,["outputConfig"]);if(d!=null){I(n,["dest"],dt(lt(d)))}const p=A(e,["completionStats"]);if(p!=null){I(n,["completionStats"],p)}return n}function gt(e){const n={};const t=A(e,["instancesFormat"]);if(t!=null){I(n,["format"],t)}const i=A(e,["gcsSource","uris"]);if(i!=null){I(n,["gcsUri"],i)}const o=A(e,["bigquerySource","inputUri"]);if(o!=null){I(n,["bigqueryUri"],o)}return n}function yt(e,n){const t={};if(A(n,["format"])!==undefined){throw new Error("format parameter is not supported in Gemini API.")}if(A(n,["gcsUri"])!==undefined){throw new Error("gcsUri parameter is not supported in Gemini API.")}if(A(n,["bigqueryUri"])!==undefined){throw new Error("bigqueryUri parameter is not supported in Gemini API.")}const i=A(n,["fileName"]);if(i!=null){I(t,["fileName"],i)}const o=A(n,["inlinedRequests"]);if(o!=null){let n=o;if(Array.isArray(n)){n=n.map((n=>Yt(e,n)))}I(t,["requests","requests"],n)}return t}function vt(e){const n={};const t=A(e,["format"]);if(t!=null){I(n,["instancesFormat"],t)}const i=A(e,["gcsUri"]);if(i!=null){I(n,["gcsSource","uris"],i)}const o=A(e,["bigqueryUri"]);if(o!=null){I(n,["bigquerySource","inputUri"],o)}if(A(e,["fileName"])!==undefined){throw new Error("fileName parameter is not supported in Vertex AI.")}if(A(e,["inlinedRequests"])!==undefined){throw new Error("inlinedRequests parameter is not supported in Vertex AI.")}return n}function Et(e){const n={};const t=A(e,["data"]);if(t!=null){I(n,["data"],t)}if(A(e,["displayName"])!==undefined){throw new Error("displayName parameter is not supported in Gemini API.")}const i=A(e,["mimeType"]);if(i!=null){I(n,["mimeType"],i)}return n}function wt(e,n){const t={};const i=A(n,["name"]);if(i!=null){I(t,["_url","name"],ut(e,i))}return t}function bt(e,n){const t={};const i=A(n,["name"]);if(i!=null){I(t,["_url","name"],ut(e,i))}return t}function Tt(e){const n={};const t=A(e,["content"]);if(t!=null){I(n,["content"],t)}const i=A(e,["citationMetadata"]);if(i!=null){I(n,["citationMetadata"],St(i))}const o=A(e,["tokenCount"]);if(o!=null){I(n,["tokenCount"],o)}const r=A(e,["finishReason"]);if(r!=null){I(n,["finishReason"],r)}const s=A(e,["groundingMetadata"]);if(s!=null){I(n,["groundingMetadata"],s)}const l=A(e,["avgLogprobs"]);if(l!=null){I(n,["avgLogprobs"],l)}const u=A(e,["index"]);if(u!=null){I(n,["index"],u)}const a=A(e,["logprobsResult"]);if(a!=null){I(n,["logprobsResult"],a)}const c=A(e,["safetyRatings"]);if(c!=null){let e=c;if(Array.isArray(e)){e=e.map((e=>e))}I(n,["safetyRatings"],e)}const f=A(e,["urlContextMetadata"]);if(f!=null){I(n,["urlContextMetadata"],f)}return n}function St(e){const n={};const t=A(e,["citationSources"]);if(t!=null){let e=t;if(Array.isArray(e)){e=e.map((e=>e))}I(n,["citations"],e)}return n}function It(e){const n={};const t=A(e,["parts"]);if(t!=null){let e=t;if(Array.isArray(e)){e=e.map((e=>ti(e)))}I(n,["parts"],e)}const i=A(e,["role"]);if(i!=null){I(n,["role"],i)}return n}function At(e,n){const t={};const i=A(e,["displayName"]);if(n!==undefined&&i!=null){I(n,["batch","displayName"],i)}if(A(e,["dest"])!==undefined){throw new Error("dest parameter is not supported in Gemini API.")}return t}function Ot(e,n){const t={};const i=A(e,["displayName"]);if(n!==undefined&&i!=null){I(n,["displayName"],i)}const o=A(e,["dest"]);if(n!==undefined&&o!=null){I(n,["outputConfig"],pt(st(o)))}return t}function Ct(e,n){const t={};const i=A(n,["model"]);if(i!=null){I(t,["_url","model"],An(e,i))}const o=A(n,["src"]);if(o!=null){I(t,["batch","inputConfig"],yt(e,rt(e,o)))}const r=A(n,["config"]);if(r!=null){At(r,t)}return t}function _t(e,n){const t={};const i=A(n,["model"]);if(i!=null){I(t,["model"],An(e,i))}const o=A(n,["src"]);if(o!=null){I(t,["inputConfig"],vt(rt(e,o)))}const r=A(n,["config"]);if(r!=null){Ot(r,t)}return t}function Pt(e,n){const t={};const i=A(e,["displayName"]);if(n!==undefined&&i!=null){I(n,["batch","displayName"],i)}return t}function Rt(e,n){const t={};const i=A(n,["model"]);if(i!=null){I(t,["_url","model"],An(e,i))}const o=A(n,["src"]);if(o!=null){I(t,["batch","inputConfig"],xt(e,o))}const r=A(n,["config"]);if(r!=null){Pt(r,t)}return t}function Nt(e,n){const t={};const i=A(n,["name"]);if(i!=null){I(t,["_url","name"],ut(e,i))}return t}function Mt(e,n){const t={};const i=A(n,["name"]);if(i!=null){I(t,["_url","name"],ut(e,i))}return t}function Dt(e){const n={};const t=A(e,["sdkHttpResponse"]);if(t!=null){I(n,["sdkHttpResponse"],t)}const i=A(e,["name"]);if(i!=null){I(n,["name"],i)}const o=A(e,["done"]);if(o!=null){I(n,["done"],o)}const r=A(e,["error"]);if(r!=null){I(n,["error"],r)}return n}function Ut(e){const n={};const t=A(e,["sdkHttpResponse"]);if(t!=null){I(n,["sdkHttpResponse"],t)}const i=A(e,["name"]);if(i!=null){I(n,["name"],i)}const o=A(e,["done"]);if(o!=null){I(n,["done"],o)}const r=A(e,["error"]);if(r!=null){I(n,["error"],r)}return n}function kt(e,n){const t={};const i=A(n,["contents"]);if(i!=null){let n=xn(e,i);if(Array.isArray(n)){n=n.map((e=>e))}I(t,["requests[]","request","content"],n)}const o=A(n,["config"]);if(o!=null){I(t,["_self"],Gt(o,t));O(t,{"requests[].*":"requests[].request.*"})}return t}function Gt(e,n){const t={};const i=A(e,["taskType"]);if(n!==undefined&&i!=null){I(n,["requests[]","taskType"],i)}const o=A(e,["title"]);if(n!==undefined&&o!=null){I(n,["requests[]","title"],o)}const r=A(e,["outputDimensionality"]);if(n!==undefined&&r!=null){I(n,["requests[]","outputDimensionality"],r)}if(A(e,["mimeType"])!==undefined){throw new Error("mimeType parameter is not supported in Gemini API.")}if(A(e,["autoTruncate"])!==undefined){throw new Error("autoTruncate parameter is not supported in Gemini API.")}return t}function xt(e,n){const t={};const i=A(n,["fileName"]);if(i!=null){I(t,["file_name"],i)}const o=A(n,["inlinedRequests"]);if(o!=null){I(t,["requests"],kt(e,o))}return t}function Lt(e){const n={};if(A(e,["displayName"])!==undefined){throw new Error("displayName parameter is not supported in Gemini API.")}const t=A(e,["fileUri"]);if(t!=null){I(n,["fileUri"],t)}const i=A(e,["mimeType"]);if(i!=null){I(n,["mimeType"],i)}return n}function jt(e){const n={};const t=A(e,["id"]);if(t!=null){I(n,["id"],t)}const i=A(e,["args"]);if(i!=null){I(n,["args"],i)}const o=A(e,["name"]);if(o!=null){I(n,["name"],o)}if(A(e,["partialArgs"])!==undefined){throw new Error("partialArgs parameter is not supported in Gemini API.")}if(A(e,["willContinue"])!==undefined){throw new Error("willContinue parameter is not supported in Gemini API.")}return n}function Ft(e){const n={};const t=A(e,["allowedFunctionNames"]);if(t!=null){I(n,["allowedFunctionNames"],t)}const i=A(e,["mode"]);if(i!=null){I(n,["mode"],i)}if(A(e,["streamFunctionCallArguments"])!==undefined){throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.")}return n}function qt(e,n,t){const i={};const o=A(n,["systemInstruction"]);if(t!==undefined&&o!=null){I(t,["systemInstruction"],It(Gn(o)))}const r=A(n,["temperature"]);if(r!=null){I(i,["temperature"],r)}const s=A(n,["topP"]);if(s!=null){I(i,["topP"],s)}const l=A(n,["topK"]);if(l!=null){I(i,["topK"],l)}const u=A(n,["candidateCount"]);if(u!=null){I(i,["candidateCount"],u)}const a=A(n,["maxOutputTokens"]);if(a!=null){I(i,["maxOutputTokens"],a)}const c=A(n,["stopSequences"]);if(c!=null){I(i,["stopSequences"],c)}const f=A(n,["responseLogprobs"]);if(f!=null){I(i,["responseLogprobs"],f)}const d=A(n,["logprobs"]);if(d!=null){I(i,["logprobs"],d)}const p=A(n,["presencePenalty"]);if(p!=null){I(i,["presencePenalty"],p)}const h=A(n,["frequencyPenalty"]);if(h!=null){I(i,["frequencyPenalty"],h)}const m=A(n,["seed"]);if(m!=null){I(i,["seed"],m)}const g=A(n,["responseMimeType"]);if(g!=null){I(i,["responseMimeType"],g)}const y=A(n,["responseSchema"]);if(y!=null){I(i,["responseSchema"],qn(y))}const v=A(n,["responseJsonSchema"]);if(v!=null){I(i,["responseJsonSchema"],v)}if(A(n,["routingConfig"])!==undefined){throw new Error("routingConfig parameter is not supported in Gemini API.")}if(A(n,["modelSelectionConfig"])!==undefined){throw new Error("modelSelectionConfig parameter is not supported in Gemini API.")}const E=A(n,["safetySettings"]);if(t!==undefined&&E!=null){let e=E;if(Array.isArray(e)){e=e.map((e=>ii(e)))}I(t,["safetySettings"],e)}const w=A(n,["tools"]);if(t!==undefined&&w!=null){let e=Vn(w);if(Array.isArray(e)){e=e.map((e=>ri(Jn(e))))}I(t,["tools"],e)}const b=A(n,["toolConfig"]);if(t!==undefined&&b!=null){I(t,["toolConfig"],oi(b))}if(A(n,["labels"])!==undefined){throw new Error("labels parameter is not supported in Gemini API.")}const T=A(n,["cachedContent"]);if(t!==undefined&&T!=null){I(t,["cachedContent"],Wn(e,T))}const S=A(n,["responseModalities"]);if(S!=null){I(i,["responseModalities"],S)}const O=A(n,["mediaResolution"]);if(O!=null){I(i,["mediaResolution"],O)}const C=A(n,["speechConfig"]);if(C!=null){I(i,["speechConfig"],Hn(C))}if(A(n,["audioTimestamp"])!==undefined){throw new Error("audioTimestamp parameter is not supported in Gemini API.")}const _=A(n,["thinkingConfig"]);if(_!=null){I(i,["thinkingConfig"],_)}const P=A(n,["imageConfig"]);if(P!=null){I(i,["imageConfig"],Wt(P))}const R=A(n,["enableEnhancedCivicAnswers"]);if(R!=null){I(i,["enableEnhancedCivicAnswers"],R)}if(A(n,["modelArmorConfig"])!==undefined){throw new Error("modelArmorConfig parameter is not supported in Gemini API.")}return i}function Ht(e){const n={};const t=A(e,["sdkHttpResponse"]);if(t!=null){I(n,["sdkHttpResponse"],t)}const i=A(e,["candidates"]);if(i!=null){let e=i;if(Array.isArray(e)){e=e.map((e=>Tt(e)))}I(n,["candidates"],e)}const o=A(e,["modelVersion"]);if(o!=null){I(n,["modelVersion"],o)}const r=A(e,["promptFeedback"]);if(r!=null){I(n,["promptFeedback"],r)}const s=A(e,["responseId"]);if(s!=null){I(n,["responseId"],s)}const l=A(e,["usageMetadata"]);if(l!=null){I(n,["usageMetadata"],l)}return n}function $t(e,n){const t={};const i=A(n,["name"]);if(i!=null){I(t,["_url","name"],ut(e,i))}return t}function Jt(e,n){const t={};const i=A(n,["name"]);if(i!=null){I(t,["_url","name"],ut(e,i))}return t}function Vt(e){const n={};if(A(e,["authConfig"])!==undefined){throw new Error("authConfig parameter is not supported in Gemini API.")}const t=A(e,["enableWidget"]);if(t!=null){I(n,["enableWidget"],t)}return n}function Bt(e){const n={};const t=A(e,["searchTypes"]);if(t!=null){I(n,["searchTypes"],t)}if(A(e,["excludeDomains"])!==undefined){throw new Error("excludeDomains parameter is not supported in Gemini API.")}if(A(e,["blockingConfidence"])!==undefined){throw new Error("blockingConfidence parameter is not supported in Gemini API.")}const i=A(e,["timeRangeFilter"]);if(i!=null){I(n,["timeRangeFilter"],i)}return n}function Wt(e){const n={};const t=A(e,["aspectRatio"]);if(t!=null){I(n,["aspectRatio"],t)}const i=A(e,["imageSize"]);if(i!=null){I(n,["imageSize"],i)}if(A(e,["personGeneration"])!==undefined){throw new Error("personGeneration parameter is not supported in Gemini API.")}if(A(e,["prominentPeople"])!==undefined){throw new Error("prominentPeople parameter is not supported in Gemini API.")}if(A(e,["outputMimeType"])!==undefined){throw new Error("outputMimeType parameter is not supported in Gemini API.")}if(A(e,["outputCompressionQuality"])!==undefined){throw new Error("outputCompressionQuality parameter is not supported in Gemini API.")}return n}function Yt(e,n){const t={};const i=A(n,["model"]);if(i!=null){I(t,["request","model"],An(e,i))}const o=A(n,["contents"]);if(o!=null){let e=Ln(o);if(Array.isArray(e)){e=e.map((e=>It(e)))}I(t,["request","contents"],e)}const r=A(n,["metadata"]);if(r!=null){I(t,["metadata"],r)}const s=A(n,["config"]);if(s!=null){I(t,["request","generationConfig"],qt(e,s,A(t,["request"],{})))}return t}function Kt(e){const n={};const t=A(e,["response"]);if(t!=null){I(n,["response"],Ht(t))}const i=A(e,["metadata"]);if(i!=null){I(n,["metadata"],i)}const o=A(e,["error"]);if(o!=null){I(n,["error"],o)}return n}function zt(e,n){const t={};const i=A(e,["pageSize"]);if(n!==undefined&&i!=null){I(n,["_query","pageSize"],i)}const o=A(e,["pageToken"]);if(n!==undefined&&o!=null){I(n,["_query","pageToken"],o)}if(A(e,["filter"])!==undefined){throw new Error("filter parameter is not supported in Gemini API.")}return t}function Xt(e,n){const t={};const i=A(e,["pageSize"]);if(n!==undefined&&i!=null){I(n,["_query","pageSize"],i)}const o=A(e,["pageToken"]);if(n!==undefined&&o!=null){I(n,["_query","pageToken"],o)}const r=A(e,["filter"]);if(n!==undefined&&r!=null){I(n,["_query","filter"],r)}return t}function Qt(e){const n={};const t=A(e,["config"]);if(t!=null){zt(t,n)}return n}function Zt(e){const n={};const t=A(e,["config"]);if(t!=null){Xt(t,n)}return n}function ei(e){const n={};const t=A(e,["sdkHttpResponse"]);if(t!=null){I(n,["sdkHttpResponse"],t)}const i=A(e,["nextPageToken"]);if(i!=null){I(n,["nextPageToken"],i)}const o=A(e,["operations"]);if(o!=null){let e=o;if(Array.isArray(e)){e=e.map((e=>ht(e)))}I(n,["batchJobs"],e)}return n}function ni(e){const n={};const t=A(e,["sdkHttpResponse"]);if(t!=null){I(n,["sdkHttpResponse"],t)}const i=A(e,["nextPageToken"]);if(i!=null){I(n,["nextPageToken"],i)}const o=A(e,["batchPredictionJobs"]);if(o!=null){let e=o;if(Array.isArray(e)){e=e.map((e=>mt(e)))}I(n,["batchJobs"],e)}return n}function ti(e){const n={};const t=A(e,["mediaResolution"]);if(t!=null){I(n,["mediaResolution"],t)}const i=A(e,["codeExecutionResult"]);if(i!=null){I(n,["codeExecutionResult"],i)}const o=A(e,["executableCode"]);if(o!=null){I(n,["executableCode"],o)}const r=A(e,["fileData"]);if(r!=null){I(n,["fileData"],Lt(r))}const s=A(e,["functionCall"]);if(s!=null){I(n,["functionCall"],jt(s))}const l=A(e,["functionResponse"]);if(l!=null){I(n,["functionResponse"],l)}const u=A(e,["inlineData"]);if(u!=null){I(n,["inlineData"],Et(u))}const a=A(e,["text"]);if(a!=null){I(n,["text"],a)}const c=A(e,["thought"]);if(c!=null){I(n,["thought"],c)}const f=A(e,["thoughtSignature"]);if(f!=null){I(n,["thoughtSignature"],f)}const d=A(e,["videoMetadata"]);if(d!=null){I(n,["videoMetadata"],d)}return n}function ii(e){const n={};const t=A(e,["category"]);if(t!=null){I(n,["category"],t)}if(A(e,["method"])!==undefined){throw new Error("method parameter is not supported in Gemini API.")}const i=A(e,["threshold"]);if(i!=null){I(n,["threshold"],i)}return n}function oi(e){const n={};const t=A(e,["retrievalConfig"]);if(t!=null){I(n,["retrievalConfig"],t)}const i=A(e,["functionCallingConfig"]);if(i!=null){I(n,["functionCallingConfig"],Ft(i))}return n}function ri(e){const n={};if(A(e,["retrieval"])!==undefined){throw new Error("retrieval parameter is not supported in Gemini API.")}const t=A(e,["computerUse"]);if(t!=null){I(n,["computerUse"],t)}const i=A(e,["fileSearch"]);if(i!=null){I(n,["fileSearch"],i)}const o=A(e,["googleSearch"]);if(o!=null){I(n,["googleSearch"],Bt(o))}const r=A(e,["codeExecution"]);if(r!=null){I(n,["codeExecution"],r)}if(A(e,["enterpriseWebSearch"])!==undefined){throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.")}const s=A(e,["functionDeclarations"]);if(s!=null){let e=s;if(Array.isArray(e)){e=e.map((e=>e))}I(n,["functionDeclarations"],e)}const l=A(e,["googleMaps"]);if(l!=null){I(n,["googleMaps"],Vt(l))}const u=A(e,["googleSearchRetrieval"]);if(u!=null){I(n,["googleSearchRetrieval"],u)}const a=A(e,["urlContext"]);if(a!=null){I(n,["urlContext"],a)}const c=A(e,["mcpServers"]);if(c!=null){let e=c;if(Array.isArray(e)){e=e.map((e=>e))}I(n,["mcpServers"],e)}return n}
|
|
37
|
+
/**
|
|
38
|
+
* @license
|
|
39
|
+
* Copyright 2025 Google LLC
|
|
40
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
41
|
+
*/var si;(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"})(si||(si={}));class li{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 ui extends T{constructor(e){super();this.apiClient=e;this.list=async(e={})=>new li(si.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=Ct(this.apiClient,e);const t=n["_url"];const i=S("{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=_t(this.apiClient,e);s=S("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=mt(e);return n}))}else{const n=Ct(this.apiClient,e);s=S("{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=ht(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=Rt(this.apiClient,e);o=S("{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=ht(e);return n}))}}async get(e){var n,t,i,o;let r;let s="";let l={};if(this.apiClient.isVertexAI()){const i=Jt(this.apiClient,e);s=S("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=mt(e);return n}))}else{const n=$t(this.apiClient,e);s=S("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=ht(e);return n}))}}async cancel(e){var n,t,i,o;let r="";let s={};if(this.apiClient.isVertexAI()){const i=bt(this.apiClient,e);r=S("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=wt(this.apiClient,e);r=S("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=Zt(e);s=S("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=ni(e);const t=new bn;Object.assign(t,n);return t}))}else{const n=Qt(e);s=S("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=ei(e);const t=new bn;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=Mt(this.apiClient,e);s=S("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=Ut(e);return n}))}else{const n=Nt(this.apiClient,e);s=S("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=Dt(e);return n}))}}}
|
|
47
|
+
/**
|
|
48
|
+
* @license
|
|
49
|
+
* Copyright 2025 Google LLC
|
|
50
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
51
|
+
*/function ai(e){const n={};const t=A(e,["data"]);if(t!=null){I(n,["data"],t)}if(A(e,["displayName"])!==undefined){throw new Error("displayName parameter is not supported in Gemini API.")}const i=A(e,["mimeType"]);if(i!=null){I(n,["mimeType"],i)}return n}function ci(e){const n={};const t=A(e,["parts"]);if(t!=null){let e=t;if(Array.isArray(e)){e=e.map((e=>Di(e)))}I(n,["parts"],e)}const i=A(e,["role"]);if(i!=null){I(n,["role"],i)}return n}function fi(e,n){const t={};const i=A(e,["ttl"]);if(n!==undefined&&i!=null){I(n,["ttl"],i)}const o=A(e,["expireTime"]);if(n!==undefined&&o!=null){I(n,["expireTime"],o)}const r=A(e,["displayName"]);if(n!==undefined&&r!=null){I(n,["displayName"],r)}const s=A(e,["contents"]);if(n!==undefined&&s!=null){let e=Ln(s);if(Array.isArray(e)){e=e.map((e=>ci(e)))}I(n,["contents"],e)}const l=A(e,["systemInstruction"]);if(n!==undefined&&l!=null){I(n,["systemInstruction"],ci(Gn(l)))}const u=A(e,["tools"]);if(n!==undefined&&u!=null){let e=u;if(Array.isArray(e)){e=e.map((e=>ki(e)))}I(n,["tools"],e)}const a=A(e,["toolConfig"]);if(n!==undefined&&a!=null){I(n,["toolConfig"],Ui(a))}if(A(e,["kmsKeyName"])!==undefined){throw new Error("kmsKeyName parameter is not supported in Gemini API.")}return t}function di(e,n){const t={};const i=A(e,["ttl"]);if(n!==undefined&&i!=null){I(n,["ttl"],i)}const o=A(e,["expireTime"]);if(n!==undefined&&o!=null){I(n,["expireTime"],o)}const r=A(e,["displayName"]);if(n!==undefined&&r!=null){I(n,["displayName"],r)}const s=A(e,["contents"]);if(n!==undefined&&s!=null){let e=Ln(s);if(Array.isArray(e)){e=e.map((e=>e))}I(n,["contents"],e)}const l=A(e,["systemInstruction"]);if(n!==undefined&&l!=null){I(n,["systemInstruction"],Gn(l))}const u=A(e,["tools"]);if(n!==undefined&&u!=null){let e=u;if(Array.isArray(e)){e=e.map((e=>Gi(e)))}I(n,["tools"],e)}const a=A(e,["toolConfig"]);if(n!==undefined&&a!=null){I(n,["toolConfig"],a)}const c=A(e,["kmsKeyName"]);if(n!==undefined&&c!=null){I(n,["encryption_spec","kmsKeyName"],c)}return t}function pi(e,n){const t={};const i=A(n,["model"]);if(i!=null){I(t,["model"],On(e,i))}const o=A(n,["config"]);if(o!=null){fi(o,t)}return t}function hi(e,n){const t={};const i=A(n,["model"]);if(i!=null){I(t,["model"],On(e,i))}const o=A(n,["config"]);if(o!=null){di(o,t)}return t}function mi(e,n){const t={};const i=A(n,["name"]);if(i!=null){I(t,["_url","name"],Wn(e,i))}return t}function gi(e,n){const t={};const i=A(n,["name"]);if(i!=null){I(t,["_url","name"],Wn(e,i))}return t}function yi(e){const n={};const t=A(e,["sdkHttpResponse"]);if(t!=null){I(n,["sdkHttpResponse"],t)}return n}function vi(e){const n={};const t=A(e,["sdkHttpResponse"]);if(t!=null){I(n,["sdkHttpResponse"],t)}return n}function Ei(e){const n={};if(A(e,["displayName"])!==undefined){throw new Error("displayName parameter is not supported in Gemini API.")}const t=A(e,["fileUri"]);if(t!=null){I(n,["fileUri"],t)}const i=A(e,["mimeType"]);if(i!=null){I(n,["mimeType"],i)}return n}function wi(e){const n={};const t=A(e,["id"]);if(t!=null){I(n,["id"],t)}const i=A(e,["args"]);if(i!=null){I(n,["args"],i)}const o=A(e,["name"]);if(o!=null){I(n,["name"],o)}if(A(e,["partialArgs"])!==undefined){throw new Error("partialArgs parameter is not supported in Gemini API.")}if(A(e,["willContinue"])!==undefined){throw new Error("willContinue parameter is not supported in Gemini API.")}return n}function bi(e){const n={};const t=A(e,["allowedFunctionNames"]);if(t!=null){I(n,["allowedFunctionNames"],t)}const i=A(e,["mode"]);if(i!=null){I(n,["mode"],i)}if(A(e,["streamFunctionCallArguments"])!==undefined){throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.")}return n}function Ti(e){const n={};const t=A(e,["description"]);if(t!=null){I(n,["description"],t)}const i=A(e,["name"]);if(i!=null){I(n,["name"],i)}const o=A(e,["parameters"]);if(o!=null){I(n,["parameters"],o)}const r=A(e,["parametersJsonSchema"]);if(r!=null){I(n,["parametersJsonSchema"],r)}const s=A(e,["response"]);if(s!=null){I(n,["response"],s)}const l=A(e,["responseJsonSchema"]);if(l!=null){I(n,["responseJsonSchema"],l)}if(A(e,["behavior"])!==undefined){throw new Error("behavior parameter is not supported in Vertex AI.")}return n}function Si(e,n){const t={};const i=A(n,["name"]);if(i!=null){I(t,["_url","name"],Wn(e,i))}return t}function Ii(e,n){const t={};const i=A(n,["name"]);if(i!=null){I(t,["_url","name"],Wn(e,i))}return t}function Ai(e){const n={};if(A(e,["authConfig"])!==undefined){throw new Error("authConfig parameter is not supported in Gemini API.")}const t=A(e,["enableWidget"]);if(t!=null){I(n,["enableWidget"],t)}return n}function Oi(e){const n={};const t=A(e,["searchTypes"]);if(t!=null){I(n,["searchTypes"],t)}if(A(e,["excludeDomains"])!==undefined){throw new Error("excludeDomains parameter is not supported in Gemini API.")}if(A(e,["blockingConfidence"])!==undefined){throw new Error("blockingConfidence parameter is not supported in Gemini API.")}const i=A(e,["timeRangeFilter"]);if(i!=null){I(n,["timeRangeFilter"],i)}return n}function Ci(e,n){const t={};const i=A(e,["pageSize"]);if(n!==undefined&&i!=null){I(n,["_query","pageSize"],i)}const o=A(e,["pageToken"]);if(n!==undefined&&o!=null){I(n,["_query","pageToken"],o)}return t}function _i(e,n){const t={};const i=A(e,["pageSize"]);if(n!==undefined&&i!=null){I(n,["_query","pageSize"],i)}const o=A(e,["pageToken"]);if(n!==undefined&&o!=null){I(n,["_query","pageToken"],o)}return t}function Pi(e){const n={};const t=A(e,["config"]);if(t!=null){Ci(t,n)}return n}function Ri(e){const n={};const t=A(e,["config"]);if(t!=null){_i(t,n)}return n}function Ni(e){const n={};const t=A(e,["sdkHttpResponse"]);if(t!=null){I(n,["sdkHttpResponse"],t)}const i=A(e,["nextPageToken"]);if(i!=null){I(n,["nextPageToken"],i)}const o=A(e,["cachedContents"]);if(o!=null){let e=o;if(Array.isArray(e)){e=e.map((e=>e))}I(n,["cachedContents"],e)}return n}function Mi(e){const n={};const t=A(e,["sdkHttpResponse"]);if(t!=null){I(n,["sdkHttpResponse"],t)}const i=A(e,["nextPageToken"]);if(i!=null){I(n,["nextPageToken"],i)}const o=A(e,["cachedContents"]);if(o!=null){let e=o;if(Array.isArray(e)){e=e.map((e=>e))}I(n,["cachedContents"],e)}return n}function Di(e){const n={};const t=A(e,["mediaResolution"]);if(t!=null){I(n,["mediaResolution"],t)}const i=A(e,["codeExecutionResult"]);if(i!=null){I(n,["codeExecutionResult"],i)}const o=A(e,["executableCode"]);if(o!=null){I(n,["executableCode"],o)}const r=A(e,["fileData"]);if(r!=null){I(n,["fileData"],Ei(r))}const s=A(e,["functionCall"]);if(s!=null){I(n,["functionCall"],wi(s))}const l=A(e,["functionResponse"]);if(l!=null){I(n,["functionResponse"],l)}const u=A(e,["inlineData"]);if(u!=null){I(n,["inlineData"],ai(u))}const a=A(e,["text"]);if(a!=null){I(n,["text"],a)}const c=A(e,["thought"]);if(c!=null){I(n,["thought"],c)}const f=A(e,["thoughtSignature"]);if(f!=null){I(n,["thoughtSignature"],f)}const d=A(e,["videoMetadata"]);if(d!=null){I(n,["videoMetadata"],d)}return n}function Ui(e){const n={};const t=A(e,["retrievalConfig"]);if(t!=null){I(n,["retrievalConfig"],t)}const i=A(e,["functionCallingConfig"]);if(i!=null){I(n,["functionCallingConfig"],bi(i))}return n}function ki(e){const n={};if(A(e,["retrieval"])!==undefined){throw new Error("retrieval parameter is not supported in Gemini API.")}const t=A(e,["computerUse"]);if(t!=null){I(n,["computerUse"],t)}const i=A(e,["fileSearch"]);if(i!=null){I(n,["fileSearch"],i)}const o=A(e,["googleSearch"]);if(o!=null){I(n,["googleSearch"],Oi(o))}const r=A(e,["codeExecution"]);if(r!=null){I(n,["codeExecution"],r)}if(A(e,["enterpriseWebSearch"])!==undefined){throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.")}const s=A(e,["functionDeclarations"]);if(s!=null){let e=s;if(Array.isArray(e)){e=e.map((e=>e))}I(n,["functionDeclarations"],e)}const l=A(e,["googleMaps"]);if(l!=null){I(n,["googleMaps"],Ai(l))}const u=A(e,["googleSearchRetrieval"]);if(u!=null){I(n,["googleSearchRetrieval"],u)}const a=A(e,["urlContext"]);if(a!=null){I(n,["urlContext"],a)}const c=A(e,["mcpServers"]);if(c!=null){let e=c;if(Array.isArray(e)){e=e.map((e=>e))}I(n,["mcpServers"],e)}return n}function Gi(e){const n={};const t=A(e,["retrieval"]);if(t!=null){I(n,["retrieval"],t)}const i=A(e,["computerUse"]);if(i!=null){I(n,["computerUse"],i)}if(A(e,["fileSearch"])!==undefined){throw new Error("fileSearch parameter is not supported in Vertex AI.")}const o=A(e,["googleSearch"]);if(o!=null){I(n,["googleSearch"],o)}const r=A(e,["codeExecution"]);if(r!=null){I(n,["codeExecution"],r)}const s=A(e,["enterpriseWebSearch"]);if(s!=null){I(n,["enterpriseWebSearch"],s)}const l=A(e,["functionDeclarations"]);if(l!=null){let e=l;if(Array.isArray(e)){e=e.map((e=>Ti(e)))}I(n,["functionDeclarations"],e)}const u=A(e,["googleMaps"]);if(u!=null){I(n,["googleMaps"],u)}const a=A(e,["googleSearchRetrieval"]);if(a!=null){I(n,["googleSearchRetrieval"],a)}const c=A(e,["urlContext"]);if(c!=null){I(n,["urlContext"],c)}if(A(e,["mcpServers"])!==undefined){throw new Error("mcpServers parameter is not supported in Vertex AI.")}return n}function xi(e,n){const t={};const i=A(e,["ttl"]);if(n!==undefined&&i!=null){I(n,["ttl"],i)}const o=A(e,["expireTime"]);if(n!==undefined&&o!=null){I(n,["expireTime"],o)}return t}function Li(e,n){const t={};const i=A(e,["ttl"]);if(n!==undefined&&i!=null){I(n,["ttl"],i)}const o=A(e,["expireTime"]);if(n!==undefined&&o!=null){I(n,["expireTime"],o)}return t}function ji(e,n){const t={};const i=A(n,["name"]);if(i!=null){I(t,["_url","name"],Wn(e,i))}const o=A(n,["config"]);if(o!=null){xi(o,t)}return t}function Fi(e,n){const t={};const i=A(n,["name"]);if(i!=null){I(t,["_url","name"],Wn(e,i))}const o=A(n,["config"]);if(o!=null){Li(o,t)}return t}
|
|
52
|
+
/**
|
|
53
|
+
* @license
|
|
54
|
+
* Copyright 2025 Google LLC
|
|
55
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
56
|
+
*/class qi extends T{constructor(e){super();this.apiClient=e;this.list=async(e={})=>new li(si.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=hi(this.apiClient,e);s=S("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=pi(this.apiClient,e);s=S("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=Ii(this.apiClient,e);s=S("{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=Si(this.apiClient,e);s=S("{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=gi(this.apiClient,e);s=S("{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=vi(e);const t=new fn;Object.assign(t,n);return t}))}else{const n=mi(this.apiClient,e);s=S("{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=yi(e);const t=new fn;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=Fi(this.apiClient,e);s=S("{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=ji(this.apiClient,e);s=S("{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=Ri(e);s=S("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=Mi(e);const t=new dn;Object.assign(t,n);return t}))}else{const n=Pi(e);s=S("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=Ni(e);const t=new dn;Object.assign(t,n);return t}))}}}function Hi(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 $i(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 Ji(e){return this instanceof Ji?(this.v=e,this):new Ji(e)}function Vi(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 Ji?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 Bi(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 $i==="function"?$i(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 Wi(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 Yi(t)}function Yi(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 Ki(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 zi(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&&!Yi(e[i])){r=false}i++}if(r){n.push(...o)}else{n.pop()}}}return n}class Xi{constructor(e,n){this.modelsModule=e;this.apiClient=n}create(e){return new Qi(this.apiClient,this.modelsModule,e.model,e.config,structuredClone(e.history))}}class Qi{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();Ki(o)}async sendMessage(e){var n;await this.sendPromise;const t=Gn(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=Gn(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?zi(this.history):this.history;return structuredClone(n)}processStreamResponse(e,n){return Vi(this,arguments,(function*t(){var i,o,r,s;var l,u;const a=[];try{for(var c=true,f=Bi(e),d;d=yield Ji(f.next()),i=d.done,!i;c=true){s=d.value;c=false;const e=s;if(Wi(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 Ji(e)}}catch(e){o={error:e}}finally{try{if(!c&&!i&&(r=f.return))yield Ji(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(...zi(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 Zi extends Error{constructor(e){super(e.message);this.name="ApiError";this.status=e.status;Object.setPrototypeOf(this,Zi.prototype)}}
|
|
67
|
+
/**
|
|
68
|
+
* @license
|
|
69
|
+
* Copyright 2025 Google LLC
|
|
70
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
71
|
+
*/function eo(e){const n={};const t=A(e,["file"]);if(t!=null){I(n,["file"],t)}return n}function no(e){const n={};const t=A(e,["sdkHttpResponse"]);if(t!=null){I(n,["sdkHttpResponse"],t)}return n}function to(e){const n={};const t=A(e,["name"]);if(t!=null){I(n,["_url","file"],Zn(t))}return n}function io(e){const n={};const t=A(e,["sdkHttpResponse"]);if(t!=null){I(n,["sdkHttpResponse"],t)}return n}function oo(e){const n={};const t=A(e,["name"]);if(t!=null){I(n,["_url","file"],Zn(t))}return n}function ro(e){const n={};const t=A(e,["uris"]);if(t!=null){I(n,["uris"],t)}return n}function so(e,n){const t={};const i=A(e,["pageSize"]);if(n!==undefined&&i!=null){I(n,["_query","pageSize"],i)}const o=A(e,["pageToken"]);if(n!==undefined&&o!=null){I(n,["_query","pageToken"],o)}return t}function lo(e){const n={};const t=A(e,["config"]);if(t!=null){so(t,n)}return n}function uo(e){const n={};const t=A(e,["sdkHttpResponse"]);if(t!=null){I(n,["sdkHttpResponse"],t)}const i=A(e,["nextPageToken"]);if(i!=null){I(n,["nextPageToken"],i)}const o=A(e,["files"]);if(o!=null){let e=o;if(Array.isArray(e)){e=e.map((e=>e))}I(n,["files"],e)}return n}function ao(e){const n={};const t=A(e,["sdkHttpResponse"]);if(t!=null){I(n,["sdkHttpResponse"],t)}const i=A(e,["files"]);if(i!=null){let e=i;if(Array.isArray(e)){e=e.map((e=>e))}I(n,["files"],e)}return n}
|
|
72
|
+
/**
|
|
73
|
+
* @license
|
|
74
|
+
* Copyright 2025 Google LLC
|
|
75
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
76
|
+
*/class co extends T{constructor(e){super();this.apiClient=e;this.list=async(e={})=>new li(si.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=lo(e);o=S("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=uo(e);const t=new yn;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=eo(e);o=S("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=no(e);const t=new vn;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=oo(e);o=S("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=to(e);o=S("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=io(e);const t=new En;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=ro(e);o=S("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=ao(e);const t=new wn;Object.assign(t,n);return t}))}}}
|
|
77
|
+
/**
|
|
78
|
+
* @license
|
|
79
|
+
* Copyright 2025 Google LLC
|
|
80
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
81
|
+
*/function fo(e){const n={};const t=A(e,["data"]);if(t!=null){I(n,["data"],t)}if(A(e,["displayName"])!==undefined){throw new Error("displayName parameter is not supported in Gemini API.")}const i=A(e,["mimeType"]);if(i!=null){I(n,["mimeType"],i)}return n}function po(e){const n={};const t=A(e,["parts"]);if(t!=null){let e=t;if(Array.isArray(e)){e=e.map((e=>Po(e)))}I(n,["parts"],e)}const i=A(e,["role"]);if(i!=null){I(n,["role"],i)}return n}function ho(e){const n={};if(A(e,["displayName"])!==undefined){throw new Error("displayName parameter is not supported in Gemini API.")}const t=A(e,["fileUri"]);if(t!=null){I(n,["fileUri"],t)}const i=A(e,["mimeType"]);if(i!=null){I(n,["mimeType"],i)}return n}function mo(e){const n={};const t=A(e,["id"]);if(t!=null){I(n,["id"],t)}const i=A(e,["args"]);if(i!=null){I(n,["args"],i)}const o=A(e,["name"]);if(o!=null){I(n,["name"],o)}if(A(e,["partialArgs"])!==undefined){throw new Error("partialArgs parameter is not supported in Gemini API.")}if(A(e,["willContinue"])!==undefined){throw new Error("willContinue parameter is not supported in Gemini API.")}return n}function go(e){const n={};const t=A(e,["description"]);if(t!=null){I(n,["description"],t)}const i=A(e,["name"]);if(i!=null){I(n,["name"],i)}const o=A(e,["parameters"]);if(o!=null){I(n,["parameters"],o)}const r=A(e,["parametersJsonSchema"]);if(r!=null){I(n,["parametersJsonSchema"],r)}const s=A(e,["response"]);if(s!=null){I(n,["response"],s)}const l=A(e,["responseJsonSchema"]);if(l!=null){I(n,["responseJsonSchema"],l)}if(A(e,["behavior"])!==undefined){throw new Error("behavior parameter is not supported in Vertex AI.")}return n}function yo(e){const n={};const t=A(e,["modelSelectionConfig"]);if(t!=null){I(n,["modelConfig"],t)}const i=A(e,["responseJsonSchema"]);if(i!=null){I(n,["responseJsonSchema"],i)}const o=A(e,["audioTimestamp"]);if(o!=null){I(n,["audioTimestamp"],o)}const r=A(e,["candidateCount"]);if(r!=null){I(n,["candidateCount"],r)}const s=A(e,["enableAffectiveDialog"]);if(s!=null){I(n,["enableAffectiveDialog"],s)}const l=A(e,["frequencyPenalty"]);if(l!=null){I(n,["frequencyPenalty"],l)}const u=A(e,["logprobs"]);if(u!=null){I(n,["logprobs"],u)}const a=A(e,["maxOutputTokens"]);if(a!=null){I(n,["maxOutputTokens"],a)}const c=A(e,["mediaResolution"]);if(c!=null){I(n,["mediaResolution"],c)}const f=A(e,["presencePenalty"]);if(f!=null){I(n,["presencePenalty"],f)}const d=A(e,["responseLogprobs"]);if(d!=null){I(n,["responseLogprobs"],d)}const p=A(e,["responseMimeType"]);if(p!=null){I(n,["responseMimeType"],p)}const h=A(e,["responseModalities"]);if(h!=null){I(n,["responseModalities"],h)}const m=A(e,["responseSchema"]);if(m!=null){I(n,["responseSchema"],m)}const g=A(e,["routingConfig"]);if(g!=null){I(n,["routingConfig"],g)}const y=A(e,["seed"]);if(y!=null){I(n,["seed"],y)}const v=A(e,["speechConfig"]);if(v!=null){I(n,["speechConfig"],v)}const E=A(e,["stopSequences"]);if(E!=null){I(n,["stopSequences"],E)}const w=A(e,["temperature"]);if(w!=null){I(n,["temperature"],w)}const b=A(e,["thinkingConfig"]);if(b!=null){I(n,["thinkingConfig"],b)}const T=A(e,["topK"]);if(T!=null){I(n,["topK"],T)}const S=A(e,["topP"]);if(S!=null){I(n,["topP"],S)}if(A(e,["enableEnhancedCivicAnswers"])!==undefined){throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.")}return n}function vo(e){const n={};if(A(e,["authConfig"])!==undefined){throw new Error("authConfig parameter is not supported in Gemini API.")}const t=A(e,["enableWidget"]);if(t!=null){I(n,["enableWidget"],t)}return n}function Eo(e){const n={};const t=A(e,["searchTypes"]);if(t!=null){I(n,["searchTypes"],t)}if(A(e,["excludeDomains"])!==undefined){throw new Error("excludeDomains parameter is not supported in Gemini API.")}if(A(e,["blockingConfidence"])!==undefined){throw new Error("blockingConfidence parameter is not supported in Gemini API.")}const i=A(e,["timeRangeFilter"]);if(i!=null){I(n,["timeRangeFilter"],i)}return n}function wo(e,n){const t={};const i=A(e,["generationConfig"]);if(n!==undefined&&i!=null){I(n,["setup","generationConfig"],i)}const o=A(e,["responseModalities"]);if(n!==undefined&&o!=null){I(n,["setup","generationConfig","responseModalities"],o)}const r=A(e,["temperature"]);if(n!==undefined&&r!=null){I(n,["setup","generationConfig","temperature"],r)}const s=A(e,["topP"]);if(n!==undefined&&s!=null){I(n,["setup","generationConfig","topP"],s)}const l=A(e,["topK"]);if(n!==undefined&&l!=null){I(n,["setup","generationConfig","topK"],l)}const u=A(e,["maxOutputTokens"]);if(n!==undefined&&u!=null){I(n,["setup","generationConfig","maxOutputTokens"],u)}const a=A(e,["mediaResolution"]);if(n!==undefined&&a!=null){I(n,["setup","generationConfig","mediaResolution"],a)}const c=A(e,["seed"]);if(n!==undefined&&c!=null){I(n,["setup","generationConfig","seed"],c)}const f=A(e,["speechConfig"]);if(n!==undefined&&f!=null){I(n,["setup","generationConfig","speechConfig"],$n(f))}const d=A(e,["thinkingConfig"]);if(n!==undefined&&d!=null){I(n,["setup","generationConfig","thinkingConfig"],d)}const p=A(e,["enableAffectiveDialog"]);if(n!==undefined&&p!=null){I(n,["setup","generationConfig","enableAffectiveDialog"],p)}const h=A(e,["systemInstruction"]);if(n!==undefined&&h!=null){I(n,["setup","systemInstruction"],po(Gn(h)))}const m=A(e,["tools"]);if(n!==undefined&&m!=null){let e=Vn(m);if(Array.isArray(e)){e=e.map((e=>No(Jn(e))))}I(n,["setup","tools"],e)}const g=A(e,["sessionResumption"]);if(n!==undefined&&g!=null){I(n,["setup","sessionResumption"],Ro(g))}const y=A(e,["inputAudioTranscription"]);if(n!==undefined&&y!=null){I(n,["setup","inputAudioTranscription"],y)}const v=A(e,["outputAudioTranscription"]);if(n!==undefined&&v!=null){I(n,["setup","outputAudioTranscription"],v)}const E=A(e,["realtimeInputConfig"]);if(n!==undefined&&E!=null){I(n,["setup","realtimeInputConfig"],E)}const w=A(e,["contextWindowCompression"]);if(n!==undefined&&w!=null){I(n,["setup","contextWindowCompression"],w)}const b=A(e,["proactivity"]);if(n!==undefined&&b!=null){I(n,["setup","proactivity"],b)}if(A(e,["explicitVadSignal"])!==undefined){throw new Error("explicitVadSignal parameter is not supported in Gemini API.")}return t}function bo(e,n){const t={};const i=A(e,["generationConfig"]);if(n!==undefined&&i!=null){I(n,["setup","generationConfig"],yo(i))}const o=A(e,["responseModalities"]);if(n!==undefined&&o!=null){I(n,["setup","generationConfig","responseModalities"],o)}const r=A(e,["temperature"]);if(n!==undefined&&r!=null){I(n,["setup","generationConfig","temperature"],r)}const s=A(e,["topP"]);if(n!==undefined&&s!=null){I(n,["setup","generationConfig","topP"],s)}const l=A(e,["topK"]);if(n!==undefined&&l!=null){I(n,["setup","generationConfig","topK"],l)}const u=A(e,["maxOutputTokens"]);if(n!==undefined&&u!=null){I(n,["setup","generationConfig","maxOutputTokens"],u)}const a=A(e,["mediaResolution"]);if(n!==undefined&&a!=null){I(n,["setup","generationConfig","mediaResolution"],a)}const c=A(e,["seed"]);if(n!==undefined&&c!=null){I(n,["setup","generationConfig","seed"],c)}const f=A(e,["speechConfig"]);if(n!==undefined&&f!=null){I(n,["setup","generationConfig","speechConfig"],$n(f))}const d=A(e,["thinkingConfig"]);if(n!==undefined&&d!=null){I(n,["setup","generationConfig","thinkingConfig"],d)}const p=A(e,["enableAffectiveDialog"]);if(n!==undefined&&p!=null){I(n,["setup","generationConfig","enableAffectiveDialog"],p)}const h=A(e,["systemInstruction"]);if(n!==undefined&&h!=null){I(n,["setup","systemInstruction"],Gn(h))}const m=A(e,["tools"]);if(n!==undefined&&m!=null){let e=Vn(m);if(Array.isArray(e)){e=e.map((e=>Mo(Jn(e))))}I(n,["setup","tools"],e)}const g=A(e,["sessionResumption"]);if(n!==undefined&&g!=null){I(n,["setup","sessionResumption"],g)}const y=A(e,["inputAudioTranscription"]);if(n!==undefined&&y!=null){I(n,["setup","inputAudioTranscription"],y)}const v=A(e,["outputAudioTranscription"]);if(n!==undefined&&v!=null){I(n,["setup","outputAudioTranscription"],v)}const E=A(e,["realtimeInputConfig"]);if(n!==undefined&&E!=null){I(n,["setup","realtimeInputConfig"],E)}const w=A(e,["contextWindowCompression"]);if(n!==undefined&&w!=null){I(n,["setup","contextWindowCompression"],w)}const b=A(e,["proactivity"]);if(n!==undefined&&b!=null){I(n,["setup","proactivity"],b)}const T=A(e,["explicitVadSignal"]);if(n!==undefined&&T!=null){I(n,["setup","explicitVadSignal"],T)}return t}function To(e,n){const t={};const i=A(n,["model"]);if(i!=null){I(t,["setup","model"],An(e,i))}const o=A(n,["config"]);if(o!=null){I(t,["config"],wo(o,t))}return t}function So(e,n){const t={};const i=A(n,["model"]);if(i!=null){I(t,["setup","model"],An(e,i))}const o=A(n,["config"]);if(o!=null){I(t,["config"],bo(o,t))}return t}function Io(e){const n={};const t=A(e,["musicGenerationConfig"]);if(t!=null){I(n,["musicGenerationConfig"],t)}return n}function Ao(e){const n={};const t=A(e,["weightedPrompts"]);if(t!=null){let e=t;if(Array.isArray(e)){e=e.map((e=>e))}I(n,["weightedPrompts"],e)}return n}function Oo(e){const n={};const t=A(e,["media"]);if(t!=null){let e=Cn(t);if(Array.isArray(e)){e=e.map((e=>fo(e)))}I(n,["mediaChunks"],e)}const i=A(e,["audio"]);if(i!=null){I(n,["audio"],fo(Rn(i)))}const o=A(e,["audioStreamEnd"]);if(o!=null){I(n,["audioStreamEnd"],o)}const r=A(e,["video"]);if(r!=null){I(n,["video"],fo(Pn(r)))}const s=A(e,["text"]);if(s!=null){I(n,["text"],s)}const l=A(e,["activityStart"]);if(l!=null){I(n,["activityStart"],l)}const u=A(e,["activityEnd"]);if(u!=null){I(n,["activityEnd"],u)}return n}function Co(e){const n={};const t=A(e,["media"]);if(t!=null){let e=Cn(t);if(Array.isArray(e)){e=e.map((e=>e))}I(n,["mediaChunks"],e)}const i=A(e,["audio"]);if(i!=null){I(n,["audio"],Rn(i))}const o=A(e,["audioStreamEnd"]);if(o!=null){I(n,["audioStreamEnd"],o)}const r=A(e,["video"]);if(r!=null){I(n,["video"],Pn(r))}const s=A(e,["text"]);if(s!=null){I(n,["text"],s)}const l=A(e,["activityStart"]);if(l!=null){I(n,["activityStart"],l)}const u=A(e,["activityEnd"]);if(u!=null){I(n,["activityEnd"],u)}return n}function _o(e){const n={};const t=A(e,["setupComplete"]);if(t!=null){I(n,["setupComplete"],t)}const i=A(e,["serverContent"]);if(i!=null){I(n,["serverContent"],i)}const o=A(e,["toolCall"]);if(o!=null){I(n,["toolCall"],o)}const r=A(e,["toolCallCancellation"]);if(r!=null){I(n,["toolCallCancellation"],r)}const s=A(e,["usageMetadata"]);if(s!=null){I(n,["usageMetadata"],Do(s))}const l=A(e,["goAway"]);if(l!=null){I(n,["goAway"],l)}const u=A(e,["sessionResumptionUpdate"]);if(u!=null){I(n,["sessionResumptionUpdate"],u)}const a=A(e,["voiceActivityDetectionSignal"]);if(a!=null){I(n,["voiceActivityDetectionSignal"],a)}const c=A(e,["voiceActivity"]);if(c!=null){I(n,["voiceActivity"],Uo(c))}return n}function Po(e){const n={};const t=A(e,["mediaResolution"]);if(t!=null){I(n,["mediaResolution"],t)}const i=A(e,["codeExecutionResult"]);if(i!=null){I(n,["codeExecutionResult"],i)}const o=A(e,["executableCode"]);if(o!=null){I(n,["executableCode"],o)}const r=A(e,["fileData"]);if(r!=null){I(n,["fileData"],ho(r))}const s=A(e,["functionCall"]);if(s!=null){I(n,["functionCall"],mo(s))}const l=A(e,["functionResponse"]);if(l!=null){I(n,["functionResponse"],l)}const u=A(e,["inlineData"]);if(u!=null){I(n,["inlineData"],fo(u))}const a=A(e,["text"]);if(a!=null){I(n,["text"],a)}const c=A(e,["thought"]);if(c!=null){I(n,["thought"],c)}const f=A(e,["thoughtSignature"]);if(f!=null){I(n,["thoughtSignature"],f)}const d=A(e,["videoMetadata"]);if(d!=null){I(n,["videoMetadata"],d)}return n}function Ro(e){const n={};const t=A(e,["handle"]);if(t!=null){I(n,["handle"],t)}if(A(e,["transparent"])!==undefined){throw new Error("transparent parameter is not supported in Gemini API.")}return n}function No(e){const n={};if(A(e,["retrieval"])!==undefined){throw new Error("retrieval parameter is not supported in Gemini API.")}const t=A(e,["computerUse"]);if(t!=null){I(n,["computerUse"],t)}const i=A(e,["fileSearch"]);if(i!=null){I(n,["fileSearch"],i)}const o=A(e,["googleSearch"]);if(o!=null){I(n,["googleSearch"],Eo(o))}const r=A(e,["codeExecution"]);if(r!=null){I(n,["codeExecution"],r)}if(A(e,["enterpriseWebSearch"])!==undefined){throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.")}const s=A(e,["functionDeclarations"]);if(s!=null){let e=s;if(Array.isArray(e)){e=e.map((e=>e))}I(n,["functionDeclarations"],e)}const l=A(e,["googleMaps"]);if(l!=null){I(n,["googleMaps"],vo(l))}const u=A(e,["googleSearchRetrieval"]);if(u!=null){I(n,["googleSearchRetrieval"],u)}const a=A(e,["urlContext"]);if(a!=null){I(n,["urlContext"],a)}const c=A(e,["mcpServers"]);if(c!=null){let e=c;if(Array.isArray(e)){e=e.map((e=>e))}I(n,["mcpServers"],e)}return n}function Mo(e){const n={};const t=A(e,["retrieval"]);if(t!=null){I(n,["retrieval"],t)}const i=A(e,["computerUse"]);if(i!=null){I(n,["computerUse"],i)}if(A(e,["fileSearch"])!==undefined){throw new Error("fileSearch parameter is not supported in Vertex AI.")}const o=A(e,["googleSearch"]);if(o!=null){I(n,["googleSearch"],o)}const r=A(e,["codeExecution"]);if(r!=null){I(n,["codeExecution"],r)}const s=A(e,["enterpriseWebSearch"]);if(s!=null){I(n,["enterpriseWebSearch"],s)}const l=A(e,["functionDeclarations"]);if(l!=null){let e=l;if(Array.isArray(e)){e=e.map((e=>go(e)))}I(n,["functionDeclarations"],e)}const u=A(e,["googleMaps"]);if(u!=null){I(n,["googleMaps"],u)}const a=A(e,["googleSearchRetrieval"]);if(a!=null){I(n,["googleSearchRetrieval"],a)}const c=A(e,["urlContext"]);if(c!=null){I(n,["urlContext"],c)}if(A(e,["mcpServers"])!==undefined){throw new Error("mcpServers parameter is not supported in Vertex AI.")}return n}function Do(e){const n={};const t=A(e,["promptTokenCount"]);if(t!=null){I(n,["promptTokenCount"],t)}const i=A(e,["cachedContentTokenCount"]);if(i!=null){I(n,["cachedContentTokenCount"],i)}const o=A(e,["candidatesTokenCount"]);if(o!=null){I(n,["responseTokenCount"],o)}const r=A(e,["toolUsePromptTokenCount"]);if(r!=null){I(n,["toolUsePromptTokenCount"],r)}const s=A(e,["thoughtsTokenCount"]);if(s!=null){I(n,["thoughtsTokenCount"],s)}const l=A(e,["totalTokenCount"]);if(l!=null){I(n,["totalTokenCount"],l)}const u=A(e,["promptTokensDetails"]);if(u!=null){let e=u;if(Array.isArray(e)){e=e.map((e=>e))}I(n,["promptTokensDetails"],e)}const a=A(e,["cacheTokensDetails"]);if(a!=null){let e=a;if(Array.isArray(e)){e=e.map((e=>e))}I(n,["cacheTokensDetails"],e)}const c=A(e,["candidatesTokensDetails"]);if(c!=null){let e=c;if(Array.isArray(e)){e=e.map((e=>e))}I(n,["responseTokensDetails"],e)}const f=A(e,["toolUsePromptTokensDetails"]);if(f!=null){let e=f;if(Array.isArray(e)){e=e.map((e=>e))}I(n,["toolUsePromptTokensDetails"],e)}const d=A(e,["trafficType"]);if(d!=null){I(n,["trafficType"],d)}return n}function Uo(e){const n={};const t=A(e,["type"]);if(t!=null){I(n,["voiceActivityType"],t)}return n}
|
|
82
|
+
/**
|
|
83
|
+
* @license
|
|
84
|
+
* Copyright 2025 Google LLC
|
|
85
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
86
|
+
*/function ko(e,n){const t={};const i=A(e,["data"]);if(i!=null){I(t,["data"],i)}if(A(e,["displayName"])!==undefined){throw new Error("displayName parameter is not supported in Gemini API.")}const o=A(e,["mimeType"]);if(o!=null){I(t,["mimeType"],o)}return t}function Go(e,n){const t={};const i=A(e,["content"]);if(i!=null){I(t,["content"],i)}const o=A(e,["citationMetadata"]);if(o!=null){I(t,["citationMetadata"],xo(o))}const r=A(e,["tokenCount"]);if(r!=null){I(t,["tokenCount"],r)}const s=A(e,["finishReason"]);if(s!=null){I(t,["finishReason"],s)}const l=A(e,["groundingMetadata"]);if(l!=null){I(t,["groundingMetadata"],l)}const u=A(e,["avgLogprobs"]);if(u!=null){I(t,["avgLogprobs"],u)}const a=A(e,["index"]);if(a!=null){I(t,["index"],a)}const c=A(e,["logprobsResult"]);if(c!=null){I(t,["logprobsResult"],c)}const f=A(e,["safetyRatings"]);if(f!=null){let e=f;if(Array.isArray(e)){e=e.map((e=>e))}I(t,["safetyRatings"],e)}const d=A(e,["urlContextMetadata"]);if(d!=null){I(t,["urlContextMetadata"],d)}return t}function xo(e,n){const t={};const i=A(e,["citationSources"]);if(i!=null){let e=i;if(Array.isArray(e)){e=e.map((e=>e))}I(t,["citations"],e)}return t}function Lo(e,n,t){const i={};const o=A(n,["model"]);if(o!=null){I(i,["_url","model"],An(e,o))}const r=A(n,["contents"]);if(r!=null){let e=Ln(r);if(Array.isArray(e)){e=e.map((e=>e))}I(i,["contents"],e)}return i}function jo(e,n){const t={};const i=A(e,["sdkHttpResponse"]);if(i!=null){I(t,["sdkHttpResponse"],i)}const o=A(e,["tokensInfo"]);if(o!=null){let e=o;if(Array.isArray(e)){e=e.map((e=>e))}I(t,["tokensInfo"],e)}return t}function Fo(e,n){const t={};const i=A(e,["values"]);if(i!=null){I(t,["values"],i)}const o=A(e,["statistics"]);if(o!=null){I(t,["statistics"],qo(o))}return t}function qo(e,n){const t={};const i=A(e,["truncated"]);if(i!=null){I(t,["truncated"],i)}const o=A(e,["token_count"]);if(o!=null){I(t,["tokenCount"],o)}return t}function Ho(e,n){const t={};const i=A(e,["parts"]);if(i!=null){let e=i;if(Array.isArray(e)){e=e.map((e=>ls(e)))}I(t,["parts"],e)}const o=A(e,["role"]);if(o!=null){I(t,["role"],o)}return t}function $o(e,n){const t={};const i=A(e,["controlType"]);if(i!=null){I(t,["controlType"],i)}const o=A(e,["enableControlImageComputation"]);if(o!=null){I(t,["computeControl"],o)}return t}function Jo(e,n){const t={};if(A(e,["systemInstruction"])!==undefined){throw new Error("systemInstruction parameter is not supported in Gemini API.")}if(A(e,["tools"])!==undefined){throw new Error("tools parameter is not supported in Gemini API.")}if(A(e,["generationConfig"])!==undefined){throw new Error("generationConfig parameter is not supported in Gemini API.")}return t}function Vo(e,n,t){const i={};const o=A(e,["systemInstruction"]);if(n!==undefined&&o!=null){I(n,["systemInstruction"],Gn(o))}const r=A(e,["tools"]);if(n!==undefined&&r!=null){let e=r;if(Array.isArray(e)){e=e.map((e=>Is(e)))}I(n,["tools"],e)}const s=A(e,["generationConfig"]);if(n!==undefined&&s!=null){I(n,["generationConfig"],qr(s))}return i}function Bo(e,n,t){const i={};const o=A(n,["model"]);if(o!=null){I(i,["_url","model"],An(e,o))}const r=A(n,["contents"]);if(r!=null){let e=Ln(r);if(Array.isArray(e)){e=e.map((e=>Ho(e)))}I(i,["contents"],e)}const s=A(n,["config"]);if(s!=null){Jo(s)}return i}function Wo(e,n,t){const i={};const o=A(n,["model"]);if(o!=null){I(i,["_url","model"],An(e,o))}const r=A(n,["contents"]);if(r!=null){let e=Ln(r);if(Array.isArray(e)){e=e.map((e=>e))}I(i,["contents"],e)}const s=A(n,["config"]);if(s!=null){Vo(s,i)}return i}function Yo(e,n){const t={};const i=A(e,["sdkHttpResponse"]);if(i!=null){I(t,["sdkHttpResponse"],i)}const o=A(e,["totalTokens"]);if(o!=null){I(t,["totalTokens"],o)}const r=A(e,["cachedContentTokenCount"]);if(r!=null){I(t,["cachedContentTokenCount"],r)}return t}function Ko(e,n){const t={};const i=A(e,["sdkHttpResponse"]);if(i!=null){I(t,["sdkHttpResponse"],i)}const o=A(e,["totalTokens"]);if(o!=null){I(t,["totalTokens"],o)}return t}function zo(e,n,t){const i={};const o=A(n,["model"]);if(o!=null){I(i,["_url","name"],An(e,o))}return i}function Xo(e,n,t){const i={};const o=A(n,["model"]);if(o!=null){I(i,["_url","name"],An(e,o))}return i}function Qo(e,n){const t={};const i=A(e,["sdkHttpResponse"]);if(i!=null){I(t,["sdkHttpResponse"],i)}return t}function Zo(e,n){const t={};const i=A(e,["sdkHttpResponse"]);if(i!=null){I(t,["sdkHttpResponse"],i)}return t}function er(e,n,t){const i={};const o=A(e,["outputGcsUri"]);if(n!==undefined&&o!=null){I(n,["parameters","storageUri"],o)}const r=A(e,["negativePrompt"]);if(n!==undefined&&r!=null){I(n,["parameters","negativePrompt"],r)}const s=A(e,["numberOfImages"]);if(n!==undefined&&s!=null){I(n,["parameters","sampleCount"],s)}const l=A(e,["aspectRatio"]);if(n!==undefined&&l!=null){I(n,["parameters","aspectRatio"],l)}const u=A(e,["guidanceScale"]);if(n!==undefined&&u!=null){I(n,["parameters","guidanceScale"],u)}const a=A(e,["seed"]);if(n!==undefined&&a!=null){I(n,["parameters","seed"],a)}const c=A(e,["safetyFilterLevel"]);if(n!==undefined&&c!=null){I(n,["parameters","safetySetting"],c)}const f=A(e,["personGeneration"]);if(n!==undefined&&f!=null){I(n,["parameters","personGeneration"],f)}const d=A(e,["includeSafetyAttributes"]);if(n!==undefined&&d!=null){I(n,["parameters","includeSafetyAttributes"],d)}const p=A(e,["includeRaiReason"]);if(n!==undefined&&p!=null){I(n,["parameters","includeRaiReason"],p)}const h=A(e,["language"]);if(n!==undefined&&h!=null){I(n,["parameters","language"],h)}const m=A(e,["outputMimeType"]);if(n!==undefined&&m!=null){I(n,["parameters","outputOptions","mimeType"],m)}const g=A(e,["outputCompressionQuality"]);if(n!==undefined&&g!=null){I(n,["parameters","outputOptions","compressionQuality"],g)}const y=A(e,["addWatermark"]);if(n!==undefined&&y!=null){I(n,["parameters","addWatermark"],y)}const v=A(e,["labels"]);if(n!==undefined&&v!=null){I(n,["labels"],v)}const E=A(e,["editMode"]);if(n!==undefined&&E!=null){I(n,["parameters","editMode"],E)}const w=A(e,["baseSteps"]);if(n!==undefined&&w!=null){I(n,["parameters","editConfig","baseSteps"],w)}return i}function nr(e,n,t){const i={};const o=A(n,["model"]);if(o!=null){I(i,["_url","model"],An(e,o))}const r=A(n,["prompt"]);if(r!=null){I(i,["instances[0]","prompt"],r)}const s=A(n,["referenceImages"]);if(s!=null){let e=s;if(Array.isArray(e)){e=e.map((e=>ps(e)))}I(i,["instances[0]","referenceImages"],e)}const l=A(n,["config"]);if(l!=null){er(l,i)}return i}function tr(e,n){const t={};const i=A(e,["sdkHttpResponse"]);if(i!=null){I(t,["sdkHttpResponse"],i)}const o=A(e,["predictions"]);if(o!=null){let e=o;if(Array.isArray(e)){e=e.map((e=>xr(e)))}I(t,["generatedImages"],e)}return t}function ir(e,n,t){const i={};const o=A(e,["taskType"]);if(n!==undefined&&o!=null){I(n,["requests[]","taskType"],o)}const r=A(e,["title"]);if(n!==undefined&&r!=null){I(n,["requests[]","title"],r)}const s=A(e,["outputDimensionality"]);if(n!==undefined&&s!=null){I(n,["requests[]","outputDimensionality"],s)}if(A(e,["mimeType"])!==undefined){throw new Error("mimeType parameter is not supported in Gemini API.")}if(A(e,["autoTruncate"])!==undefined){throw new Error("autoTruncate parameter is not supported in Gemini API.")}return i}function or(e,n,t){const i={};let o=A(t,["embeddingApiType"]);if(o===undefined){o="PREDICT"}if(o==="PREDICT"){const t=A(e,["taskType"]);if(n!==undefined&&t!=null){I(n,["instances[]","task_type"],t)}}else if(o==="EMBED_CONTENT"){const t=A(e,["taskType"]);if(n!==undefined&&t!=null){I(n,["taskType"],t)}}let r=A(t,["embeddingApiType"]);if(r===undefined){r="PREDICT"}if(r==="PREDICT"){const t=A(e,["title"]);if(n!==undefined&&t!=null){I(n,["instances[]","title"],t)}}else if(r==="EMBED_CONTENT"){const t=A(e,["title"]);if(n!==undefined&&t!=null){I(n,["title"],t)}}let s=A(t,["embeddingApiType"]);if(s===undefined){s="PREDICT"}if(s==="PREDICT"){const t=A(e,["outputDimensionality"]);if(n!==undefined&&t!=null){I(n,["parameters","outputDimensionality"],t)}}else if(s==="EMBED_CONTENT"){const t=A(e,["outputDimensionality"]);if(n!==undefined&&t!=null){I(n,["outputDimensionality"],t)}}let l=A(t,["embeddingApiType"]);if(l===undefined){l="PREDICT"}if(l==="PREDICT"){const t=A(e,["mimeType"]);if(n!==undefined&&t!=null){I(n,["instances[]","mimeType"],t)}}let u=A(t,["embeddingApiType"]);if(u===undefined){u="PREDICT"}if(u==="PREDICT"){const t=A(e,["autoTruncate"]);if(n!==undefined&&t!=null){I(n,["parameters","autoTruncate"],t)}}else if(u==="EMBED_CONTENT"){const t=A(e,["autoTruncate"]);if(n!==undefined&&t!=null){I(n,["autoTruncate"],t)}}return i}function rr(e,n,t){const i={};const o=A(n,["model"]);if(o!=null){I(i,["_url","model"],An(e,o))}const r=A(n,["contents"]);if(r!=null){let n=xn(e,r);if(Array.isArray(n)){n=n.map((e=>e))}I(i,["requests[]","content"],n)}const s=A(n,["content"]);if(s!=null){Ho(Gn(s))}const l=A(n,["config"]);if(l!=null){ir(l,i)}const u=A(n,["model"]);if(u!==undefined){I(i,["requests[]","model"],An(e,u))}return i}function sr(e,n,t){const i={};const o=A(n,["model"]);if(o!=null){I(i,["_url","model"],An(e,o))}let r=A(t,["embeddingApiType"]);if(r===undefined){r="PREDICT"}if(r==="PREDICT"){const t=A(n,["contents"]);if(t!=null){let n=xn(e,t);if(Array.isArray(n)){n=n.map((e=>e))}I(i,["instances[]","content"],n)}}let s=A(t,["embeddingApiType"]);if(s===undefined){s="PREDICT"}if(s==="EMBED_CONTENT"){const e=A(n,["content"]);if(e!=null){I(i,["content"],Gn(e))}}const l=A(n,["config"]);if(l!=null){or(l,i,t)}return i}function lr(e,n){const t={};const i=A(e,["sdkHttpResponse"]);if(i!=null){I(t,["sdkHttpResponse"],i)}const o=A(e,["embeddings"]);if(o!=null){let e=o;if(Array.isArray(e)){e=e.map((e=>e))}I(t,["embeddings"],e)}const r=A(e,["metadata"]);if(r!=null){I(t,["metadata"],r)}return t}function ur(e,n){const t={};const i=A(e,["sdkHttpResponse"]);if(i!=null){I(t,["sdkHttpResponse"],i)}const o=A(e,["predictions[]","embeddings"]);if(o!=null){let e=o;if(Array.isArray(e)){e=e.map((e=>Fo(e)))}I(t,["embeddings"],e)}const r=A(e,["metadata"]);if(r!=null){I(t,["metadata"],r)}if(n&&A(n,["embeddingApiType"])==="EMBED_CONTENT"){const n=A(e,["embedding"]);const i=A(e,["usageMetadata"]);const o=A(e,["truncated"]);if(n){const e={};if(i&&i["promptTokenCount"]){e.tokenCount=i["promptTokenCount"]}if(o){e.truncated=o}n.statistics=e;I(t,["embeddings"],[n])}}return t}function ar(e,n){const t={};const i=A(e,["endpoint"]);if(i!=null){I(t,["name"],i)}const o=A(e,["deployedModelId"]);if(o!=null){I(t,["deployedModelId"],o)}return t}function cr(e,n){const t={};if(A(e,["displayName"])!==undefined){throw new Error("displayName parameter is not supported in Gemini API.")}const i=A(e,["fileUri"]);if(i!=null){I(t,["fileUri"],i)}const o=A(e,["mimeType"]);if(o!=null){I(t,["mimeType"],o)}return t}function fr(e,n){const t={};const i=A(e,["id"]);if(i!=null){I(t,["id"],i)}const o=A(e,["args"]);if(o!=null){I(t,["args"],o)}const r=A(e,["name"]);if(r!=null){I(t,["name"],r)}if(A(e,["partialArgs"])!==undefined){throw new Error("partialArgs parameter is not supported in Gemini API.")}if(A(e,["willContinue"])!==undefined){throw new Error("willContinue parameter is not supported in Gemini API.")}return t}function dr(e,n){const t={};const i=A(e,["allowedFunctionNames"]);if(i!=null){I(t,["allowedFunctionNames"],i)}const o=A(e,["mode"]);if(o!=null){I(t,["mode"],o)}if(A(e,["streamFunctionCallArguments"])!==undefined){throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.")}return t}function pr(e,n){const t={};const i=A(e,["description"]);if(i!=null){I(t,["description"],i)}const o=A(e,["name"]);if(o!=null){I(t,["name"],o)}const r=A(e,["parameters"]);if(r!=null){I(t,["parameters"],r)}const s=A(e,["parametersJsonSchema"]);if(s!=null){I(t,["parametersJsonSchema"],s)}const l=A(e,["response"]);if(l!=null){I(t,["response"],l)}const u=A(e,["responseJsonSchema"]);if(u!=null){I(t,["responseJsonSchema"],u)}if(A(e,["behavior"])!==undefined){throw new Error("behavior parameter is not supported in Vertex AI.")}return t}function hr(e,n,t,i){const o={};const r=A(n,["systemInstruction"]);if(t!==undefined&&r!=null){I(t,["systemInstruction"],Ho(Gn(r)))}const s=A(n,["temperature"]);if(s!=null){I(o,["temperature"],s)}const l=A(n,["topP"]);if(l!=null){I(o,["topP"],l)}const u=A(n,["topK"]);if(u!=null){I(o,["topK"],u)}const a=A(n,["candidateCount"]);if(a!=null){I(o,["candidateCount"],a)}const c=A(n,["maxOutputTokens"]);if(c!=null){I(o,["maxOutputTokens"],c)}const f=A(n,["stopSequences"]);if(f!=null){I(o,["stopSequences"],f)}const d=A(n,["responseLogprobs"]);if(d!=null){I(o,["responseLogprobs"],d)}const p=A(n,["logprobs"]);if(p!=null){I(o,["logprobs"],p)}const h=A(n,["presencePenalty"]);if(h!=null){I(o,["presencePenalty"],h)}const m=A(n,["frequencyPenalty"]);if(m!=null){I(o,["frequencyPenalty"],m)}const g=A(n,["seed"]);if(g!=null){I(o,["seed"],g)}const y=A(n,["responseMimeType"]);if(y!=null){I(o,["responseMimeType"],y)}const v=A(n,["responseSchema"]);if(v!=null){I(o,["responseSchema"],qn(v))}const E=A(n,["responseJsonSchema"]);if(E!=null){I(o,["responseJsonSchema"],E)}if(A(n,["routingConfig"])!==undefined){throw new Error("routingConfig parameter is not supported in Gemini API.")}if(A(n,["modelSelectionConfig"])!==undefined){throw new Error("modelSelectionConfig parameter is not supported in Gemini API.")}const w=A(n,["safetySettings"]);if(t!==undefined&&w!=null){let e=w;if(Array.isArray(e)){e=e.map((e=>gs(e)))}I(t,["safetySettings"],e)}const b=A(n,["tools"]);if(t!==undefined&&b!=null){let e=Vn(b);if(Array.isArray(e)){e=e.map((e=>Ss(Jn(e))))}I(t,["tools"],e)}const T=A(n,["toolConfig"]);if(t!==undefined&&T!=null){I(t,["toolConfig"],Ts(T))}if(A(n,["labels"])!==undefined){throw new Error("labels parameter is not supported in Gemini API.")}const S=A(n,["cachedContent"]);if(t!==undefined&&S!=null){I(t,["cachedContent"],Wn(e,S))}const O=A(n,["responseModalities"]);if(O!=null){I(o,["responseModalities"],O)}const C=A(n,["mediaResolution"]);if(C!=null){I(o,["mediaResolution"],C)}const _=A(n,["speechConfig"]);if(_!=null){I(o,["speechConfig"],Hn(_))}if(A(n,["audioTimestamp"])!==undefined){throw new Error("audioTimestamp parameter is not supported in Gemini API.")}const P=A(n,["thinkingConfig"]);if(P!=null){I(o,["thinkingConfig"],P)}const R=A(n,["imageConfig"]);if(R!=null){I(o,["imageConfig"],Br(R))}const N=A(n,["enableEnhancedCivicAnswers"]);if(N!=null){I(o,["enableEnhancedCivicAnswers"],N)}if(A(n,["modelArmorConfig"])!==undefined){throw new Error("modelArmorConfig parameter is not supported in Gemini API.")}return o}function mr(e,n,t,i){const o={};const r=A(n,["systemInstruction"]);if(t!==undefined&&r!=null){I(t,["systemInstruction"],Gn(r))}const s=A(n,["temperature"]);if(s!=null){I(o,["temperature"],s)}const l=A(n,["topP"]);if(l!=null){I(o,["topP"],l)}const u=A(n,["topK"]);if(u!=null){I(o,["topK"],u)}const a=A(n,["candidateCount"]);if(a!=null){I(o,["candidateCount"],a)}const c=A(n,["maxOutputTokens"]);if(c!=null){I(o,["maxOutputTokens"],c)}const f=A(n,["stopSequences"]);if(f!=null){I(o,["stopSequences"],f)}const d=A(n,["responseLogprobs"]);if(d!=null){I(o,["responseLogprobs"],d)}const p=A(n,["logprobs"]);if(p!=null){I(o,["logprobs"],p)}const h=A(n,["presencePenalty"]);if(h!=null){I(o,["presencePenalty"],h)}const m=A(n,["frequencyPenalty"]);if(m!=null){I(o,["frequencyPenalty"],m)}const g=A(n,["seed"]);if(g!=null){I(o,["seed"],g)}const y=A(n,["responseMimeType"]);if(y!=null){I(o,["responseMimeType"],y)}const v=A(n,["responseSchema"]);if(v!=null){I(o,["responseSchema"],qn(v))}const E=A(n,["responseJsonSchema"]);if(E!=null){I(o,["responseJsonSchema"],E)}const w=A(n,["routingConfig"]);if(w!=null){I(o,["routingConfig"],w)}const b=A(n,["modelSelectionConfig"]);if(b!=null){I(o,["modelConfig"],b)}const T=A(n,["safetySettings"]);if(t!==undefined&&T!=null){let e=T;if(Array.isArray(e)){e=e.map((e=>e))}I(t,["safetySettings"],e)}const S=A(n,["tools"]);if(t!==undefined&&S!=null){let e=Vn(S);if(Array.isArray(e)){e=e.map((e=>Is(Jn(e))))}I(t,["tools"],e)}const O=A(n,["toolConfig"]);if(t!==undefined&&O!=null){I(t,["toolConfig"],O)}const C=A(n,["labels"]);if(t!==undefined&&C!=null){I(t,["labels"],C)}const _=A(n,["cachedContent"]);if(t!==undefined&&_!=null){I(t,["cachedContent"],Wn(e,_))}const P=A(n,["responseModalities"]);if(P!=null){I(o,["responseModalities"],P)}const R=A(n,["mediaResolution"]);if(R!=null){I(o,["mediaResolution"],R)}const N=A(n,["speechConfig"]);if(N!=null){I(o,["speechConfig"],Hn(N))}const M=A(n,["audioTimestamp"]);if(M!=null){I(o,["audioTimestamp"],M)}const D=A(n,["thinkingConfig"]);if(D!=null){I(o,["thinkingConfig"],D)}const U=A(n,["imageConfig"]);if(U!=null){I(o,["imageConfig"],Wr(U))}if(A(n,["enableEnhancedCivicAnswers"])!==undefined){throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.")}const k=A(n,["modelArmorConfig"]);if(t!==undefined&&k!=null){I(t,["modelArmorConfig"],k)}return o}function gr(e,n,t){const i={};const o=A(n,["model"]);if(o!=null){I(i,["_url","model"],An(e,o))}const r=A(n,["contents"]);if(r!=null){let e=Ln(r);if(Array.isArray(e)){e=e.map((e=>Ho(e)))}I(i,["contents"],e)}const s=A(n,["config"]);if(s!=null){I(i,["generationConfig"],hr(e,s,i))}return i}function yr(e,n,t){const i={};const o=A(n,["model"]);if(o!=null){I(i,["_url","model"],An(e,o))}const r=A(n,["contents"]);if(r!=null){let e=Ln(r);if(Array.isArray(e)){e=e.map((e=>e))}I(i,["contents"],e)}const s=A(n,["config"]);if(s!=null){I(i,["generationConfig"],mr(e,s,i))}return i}function vr(e,n){const t={};const i=A(e,["sdkHttpResponse"]);if(i!=null){I(t,["sdkHttpResponse"],i)}const o=A(e,["candidates"]);if(o!=null){let e=o;if(Array.isArray(e)){e=e.map((e=>Go(e)))}I(t,["candidates"],e)}const r=A(e,["modelVersion"]);if(r!=null){I(t,["modelVersion"],r)}const s=A(e,["promptFeedback"]);if(s!=null){I(t,["promptFeedback"],s)}const l=A(e,["responseId"]);if(l!=null){I(t,["responseId"],l)}const u=A(e,["usageMetadata"]);if(u!=null){I(t,["usageMetadata"],u)}return t}function Er(e,n){const t={};const i=A(e,["sdkHttpResponse"]);if(i!=null){I(t,["sdkHttpResponse"],i)}const o=A(e,["candidates"]);if(o!=null){let e=o;if(Array.isArray(e)){e=e.map((e=>e))}I(t,["candidates"],e)}const r=A(e,["createTime"]);if(r!=null){I(t,["createTime"],r)}const s=A(e,["modelVersion"]);if(s!=null){I(t,["modelVersion"],s)}const l=A(e,["promptFeedback"]);if(l!=null){I(t,["promptFeedback"],l)}const u=A(e,["responseId"]);if(u!=null){I(t,["responseId"],u)}const a=A(e,["usageMetadata"]);if(a!=null){I(t,["usageMetadata"],a)}return t}function wr(e,n,t){const i={};if(A(e,["outputGcsUri"])!==undefined){throw new Error("outputGcsUri parameter is not supported in Gemini API.")}if(A(e,["negativePrompt"])!==undefined){throw new Error("negativePrompt parameter is not supported in Gemini API.")}const o=A(e,["numberOfImages"]);if(n!==undefined&&o!=null){I(n,["parameters","sampleCount"],o)}const r=A(e,["aspectRatio"]);if(n!==undefined&&r!=null){I(n,["parameters","aspectRatio"],r)}const s=A(e,["guidanceScale"]);if(n!==undefined&&s!=null){I(n,["parameters","guidanceScale"],s)}if(A(e,["seed"])!==undefined){throw new Error("seed parameter is not supported in Gemini API.")}const l=A(e,["safetyFilterLevel"]);if(n!==undefined&&l!=null){I(n,["parameters","safetySetting"],l)}const u=A(e,["personGeneration"]);if(n!==undefined&&u!=null){I(n,["parameters","personGeneration"],u)}const a=A(e,["includeSafetyAttributes"]);if(n!==undefined&&a!=null){I(n,["parameters","includeSafetyAttributes"],a)}const c=A(e,["includeRaiReason"]);if(n!==undefined&&c!=null){I(n,["parameters","includeRaiReason"],c)}const f=A(e,["language"]);if(n!==undefined&&f!=null){I(n,["parameters","language"],f)}const d=A(e,["outputMimeType"]);if(n!==undefined&&d!=null){I(n,["parameters","outputOptions","mimeType"],d)}const p=A(e,["outputCompressionQuality"]);if(n!==undefined&&p!=null){I(n,["parameters","outputOptions","compressionQuality"],p)}if(A(e,["addWatermark"])!==undefined){throw new Error("addWatermark parameter is not supported in Gemini API.")}if(A(e,["labels"])!==undefined){throw new Error("labels parameter is not supported in Gemini API.")}const h=A(e,["imageSize"]);if(n!==undefined&&h!=null){I(n,["parameters","sampleImageSize"],h)}if(A(e,["enhancePrompt"])!==undefined){throw new Error("enhancePrompt parameter is not supported in Gemini API.")}return i}function br(e,n,t){const i={};const o=A(e,["outputGcsUri"]);if(n!==undefined&&o!=null){I(n,["parameters","storageUri"],o)}const r=A(e,["negativePrompt"]);if(n!==undefined&&r!=null){I(n,["parameters","negativePrompt"],r)}const s=A(e,["numberOfImages"]);if(n!==undefined&&s!=null){I(n,["parameters","sampleCount"],s)}const l=A(e,["aspectRatio"]);if(n!==undefined&&l!=null){I(n,["parameters","aspectRatio"],l)}const u=A(e,["guidanceScale"]);if(n!==undefined&&u!=null){I(n,["parameters","guidanceScale"],u)}const a=A(e,["seed"]);if(n!==undefined&&a!=null){I(n,["parameters","seed"],a)}const c=A(e,["safetyFilterLevel"]);if(n!==undefined&&c!=null){I(n,["parameters","safetySetting"],c)}const f=A(e,["personGeneration"]);if(n!==undefined&&f!=null){I(n,["parameters","personGeneration"],f)}const d=A(e,["includeSafetyAttributes"]);if(n!==undefined&&d!=null){I(n,["parameters","includeSafetyAttributes"],d)}const p=A(e,["includeRaiReason"]);if(n!==undefined&&p!=null){I(n,["parameters","includeRaiReason"],p)}const h=A(e,["language"]);if(n!==undefined&&h!=null){I(n,["parameters","language"],h)}const m=A(e,["outputMimeType"]);if(n!==undefined&&m!=null){I(n,["parameters","outputOptions","mimeType"],m)}const g=A(e,["outputCompressionQuality"]);if(n!==undefined&&g!=null){I(n,["parameters","outputOptions","compressionQuality"],g)}const y=A(e,["addWatermark"]);if(n!==undefined&&y!=null){I(n,["parameters","addWatermark"],y)}const v=A(e,["labels"]);if(n!==undefined&&v!=null){I(n,["labels"],v)}const E=A(e,["imageSize"]);if(n!==undefined&&E!=null){I(n,["parameters","sampleImageSize"],E)}const w=A(e,["enhancePrompt"]);if(n!==undefined&&w!=null){I(n,["parameters","enhancePrompt"],w)}return i}function Tr(e,n,t){const i={};const o=A(n,["model"]);if(o!=null){I(i,["_url","model"],An(e,o))}const r=A(n,["prompt"]);if(r!=null){I(i,["instances[0]","prompt"],r)}const s=A(n,["config"]);if(s!=null){wr(s,i)}return i}function Sr(e,n,t){const i={};const o=A(n,["model"]);if(o!=null){I(i,["_url","model"],An(e,o))}const r=A(n,["prompt"]);if(r!=null){I(i,["instances[0]","prompt"],r)}const s=A(n,["config"]);if(s!=null){br(s,i)}return i}function Ir(e,n){const t={};const i=A(e,["sdkHttpResponse"]);if(i!=null){I(t,["sdkHttpResponse"],i)}const o=A(e,["predictions"]);if(o!=null){let e=o;if(Array.isArray(e)){e=e.map((e=>Gr(e)))}I(t,["generatedImages"],e)}const r=A(e,["positivePromptSafetyAttributes"]);if(r!=null){I(t,["positivePromptSafetyAttributes"],hs(r))}return t}function Ar(e,n){const t={};const i=A(e,["sdkHttpResponse"]);if(i!=null){I(t,["sdkHttpResponse"],i)}const o=A(e,["predictions"]);if(o!=null){let e=o;if(Array.isArray(e)){e=e.map((e=>xr(e)))}I(t,["generatedImages"],e)}const r=A(e,["positivePromptSafetyAttributes"]);if(r!=null){I(t,["positivePromptSafetyAttributes"],ms(r))}return t}function Or(e,n,t){const i={};const o=A(e,["numberOfVideos"]);if(n!==undefined&&o!=null){I(n,["parameters","sampleCount"],o)}if(A(e,["outputGcsUri"])!==undefined){throw new Error("outputGcsUri parameter is not supported in Gemini API.")}if(A(e,["fps"])!==undefined){throw new Error("fps parameter is not supported in Gemini API.")}const r=A(e,["durationSeconds"]);if(n!==undefined&&r!=null){I(n,["parameters","durationSeconds"],r)}if(A(e,["seed"])!==undefined){throw new Error("seed parameter is not supported in Gemini API.")}const s=A(e,["aspectRatio"]);if(n!==undefined&&s!=null){I(n,["parameters","aspectRatio"],s)}const l=A(e,["resolution"]);if(n!==undefined&&l!=null){I(n,["parameters","resolution"],l)}const u=A(e,["personGeneration"]);if(n!==undefined&&u!=null){I(n,["parameters","personGeneration"],u)}if(A(e,["pubsubTopic"])!==undefined){throw new Error("pubsubTopic parameter is not supported in Gemini API.")}const a=A(e,["negativePrompt"]);if(n!==undefined&&a!=null){I(n,["parameters","negativePrompt"],a)}const c=A(e,["enhancePrompt"]);if(n!==undefined&&c!=null){I(n,["parameters","enhancePrompt"],c)}if(A(e,["generateAudio"])!==undefined){throw new Error("generateAudio parameter is not supported in Gemini API.")}const f=A(e,["lastFrame"]);if(n!==undefined&&f!=null){I(n,["instances[0]","lastFrame"],zr(f))}const d=A(e,["referenceImages"]);if(n!==undefined&&d!=null){let e=d;if(Array.isArray(e)){e=e.map((e=>xs(e)))}I(n,["instances[0]","referenceImages"],e)}if(A(e,["mask"])!==undefined){throw new Error("mask parameter is not supported in Gemini API.")}if(A(e,["compressionQuality"])!==undefined){throw new Error("compressionQuality parameter is not supported in Gemini API.")}return i}function Cr(e,n,t){const i={};const o=A(e,["numberOfVideos"]);if(n!==undefined&&o!=null){I(n,["parameters","sampleCount"],o)}const r=A(e,["outputGcsUri"]);if(n!==undefined&&r!=null){I(n,["parameters","storageUri"],r)}const s=A(e,["fps"]);if(n!==undefined&&s!=null){I(n,["parameters","fps"],s)}const l=A(e,["durationSeconds"]);if(n!==undefined&&l!=null){I(n,["parameters","durationSeconds"],l)}const u=A(e,["seed"]);if(n!==undefined&&u!=null){I(n,["parameters","seed"],u)}const a=A(e,["aspectRatio"]);if(n!==undefined&&a!=null){I(n,["parameters","aspectRatio"],a)}const c=A(e,["resolution"]);if(n!==undefined&&c!=null){I(n,["parameters","resolution"],c)}const f=A(e,["personGeneration"]);if(n!==undefined&&f!=null){I(n,["parameters","personGeneration"],f)}const d=A(e,["pubsubTopic"]);if(n!==undefined&&d!=null){I(n,["parameters","pubsubTopic"],d)}const p=A(e,["negativePrompt"]);if(n!==undefined&&p!=null){I(n,["parameters","negativePrompt"],p)}const h=A(e,["enhancePrompt"]);if(n!==undefined&&h!=null){I(n,["parameters","enhancePrompt"],h)}const m=A(e,["generateAudio"]);if(n!==undefined&&m!=null){I(n,["parameters","generateAudio"],m)}const g=A(e,["lastFrame"]);if(n!==undefined&&g!=null){I(n,["instances[0]","lastFrame"],Xr(g))}const y=A(e,["referenceImages"]);if(n!==undefined&&y!=null){let e=y;if(Array.isArray(e)){e=e.map((e=>Ls(e)))}I(n,["instances[0]","referenceImages"],e)}const v=A(e,["mask"]);if(n!==undefined&&v!=null){I(n,["instances[0]","mask"],Gs(v))}const E=A(e,["compressionQuality"]);if(n!==undefined&&E!=null){I(n,["parameters","compressionQuality"],E)}return i}function _r(e,n){const t={};const i=A(e,["name"]);if(i!=null){I(t,["name"],i)}const o=A(e,["metadata"]);if(o!=null){I(t,["metadata"],o)}const r=A(e,["done"]);if(r!=null){I(t,["done"],r)}const s=A(e,["error"]);if(s!=null){I(t,["error"],s)}const l=A(e,["response","generateVideoResponse"]);if(l!=null){I(t,["response"],Mr(l))}return t}function Pr(e,n){const t={};const i=A(e,["name"]);if(i!=null){I(t,["name"],i)}const o=A(e,["metadata"]);if(o!=null){I(t,["metadata"],o)}const r=A(e,["done"]);if(r!=null){I(t,["done"],r)}const s=A(e,["error"]);if(s!=null){I(t,["error"],s)}const l=A(e,["response"]);if(l!=null){I(t,["response"],Dr(l))}return t}function Rr(e,n,t){const i={};const o=A(n,["model"]);if(o!=null){I(i,["_url","model"],An(e,o))}const r=A(n,["prompt"]);if(r!=null){I(i,["instances[0]","prompt"],r)}const s=A(n,["image"]);if(s!=null){I(i,["instances[0]","image"],zr(s))}const l=A(n,["video"]);if(l!=null){I(i,["instances[0]","video"],js(l))}const u=A(n,["source"]);if(u!=null){Ur(u,i)}const a=A(n,["config"]);if(a!=null){Or(a,i)}return i}function Nr(e,n,t){const i={};const o=A(n,["model"]);if(o!=null){I(i,["_url","model"],An(e,o))}const r=A(n,["prompt"]);if(r!=null){I(i,["instances[0]","prompt"],r)}const s=A(n,["image"]);if(s!=null){I(i,["instances[0]","image"],Xr(s))}const l=A(n,["video"]);if(l!=null){I(i,["instances[0]","video"],Fs(l))}const u=A(n,["source"]);if(u!=null){kr(u,i)}const a=A(n,["config"]);if(a!=null){Cr(a,i)}return i}function Mr(e,n){const t={};const i=A(e,["generatedSamples"]);if(i!=null){let e=i;if(Array.isArray(e)){e=e.map((e=>jr(e)))}I(t,["generatedVideos"],e)}const o=A(e,["raiMediaFilteredCount"]);if(o!=null){I(t,["raiMediaFilteredCount"],o)}const r=A(e,["raiMediaFilteredReasons"]);if(r!=null){I(t,["raiMediaFilteredReasons"],r)}return t}function Dr(e,n){const t={};const i=A(e,["videos"]);if(i!=null){let e=i;if(Array.isArray(e)){e=e.map((e=>Fr(e)))}I(t,["generatedVideos"],e)}const o=A(e,["raiMediaFilteredCount"]);if(o!=null){I(t,["raiMediaFilteredCount"],o)}const r=A(e,["raiMediaFilteredReasons"]);if(r!=null){I(t,["raiMediaFilteredReasons"],r)}return t}function Ur(e,n,t){const i={};const o=A(e,["prompt"]);if(n!==undefined&&o!=null){I(n,["instances[0]","prompt"],o)}const r=A(e,["image"]);if(n!==undefined&&r!=null){I(n,["instances[0]","image"],zr(r))}const s=A(e,["video"]);if(n!==undefined&&s!=null){I(n,["instances[0]","video"],js(s))}return i}function kr(e,n,t){const i={};const o=A(e,["prompt"]);if(n!==undefined&&o!=null){I(n,["instances[0]","prompt"],o)}const r=A(e,["image"]);if(n!==undefined&&r!=null){I(n,["instances[0]","image"],Xr(r))}const s=A(e,["video"]);if(n!==undefined&&s!=null){I(n,["instances[0]","video"],Fs(s))}return i}function Gr(e,n){const t={};const i=A(e,["_self"]);if(i!=null){I(t,["image"],Yr(i))}const o=A(e,["raiFilteredReason"]);if(o!=null){I(t,["raiFilteredReason"],o)}const r=A(e,["_self"]);if(r!=null){I(t,["safetyAttributes"],hs(r))}return t}function xr(e,n){const t={};const i=A(e,["_self"]);if(i!=null){I(t,["image"],Kr(i))}const o=A(e,["raiFilteredReason"]);if(o!=null){I(t,["raiFilteredReason"],o)}const r=A(e,["_self"]);if(r!=null){I(t,["safetyAttributes"],ms(r))}const s=A(e,["prompt"]);if(s!=null){I(t,["enhancedPrompt"],s)}return t}function Lr(e,n){const t={};const i=A(e,["_self"]);if(i!=null){I(t,["mask"],Kr(i))}const o=A(e,["labels"]);if(o!=null){let e=o;if(Array.isArray(e)){e=e.map((e=>e))}I(t,["labels"],e)}return t}function jr(e,n){const t={};const i=A(e,["video"]);if(i!=null){I(t,["video"],Us(i))}return t}function Fr(e,n){const t={};const i=A(e,["_self"]);if(i!=null){I(t,["video"],ks(i))}return t}function qr(e,n){const t={};const i=A(e,["modelSelectionConfig"]);if(i!=null){I(t,["modelConfig"],i)}const o=A(e,["responseJsonSchema"]);if(o!=null){I(t,["responseJsonSchema"],o)}const r=A(e,["audioTimestamp"]);if(r!=null){I(t,["audioTimestamp"],r)}const s=A(e,["candidateCount"]);if(s!=null){I(t,["candidateCount"],s)}const l=A(e,["enableAffectiveDialog"]);if(l!=null){I(t,["enableAffectiveDialog"],l)}const u=A(e,["frequencyPenalty"]);if(u!=null){I(t,["frequencyPenalty"],u)}const a=A(e,["logprobs"]);if(a!=null){I(t,["logprobs"],a)}const c=A(e,["maxOutputTokens"]);if(c!=null){I(t,["maxOutputTokens"],c)}const f=A(e,["mediaResolution"]);if(f!=null){I(t,["mediaResolution"],f)}const d=A(e,["presencePenalty"]);if(d!=null){I(t,["presencePenalty"],d)}const p=A(e,["responseLogprobs"]);if(p!=null){I(t,["responseLogprobs"],p)}const h=A(e,["responseMimeType"]);if(h!=null){I(t,["responseMimeType"],h)}const m=A(e,["responseModalities"]);if(m!=null){I(t,["responseModalities"],m)}const g=A(e,["responseSchema"]);if(g!=null){I(t,["responseSchema"],g)}const y=A(e,["routingConfig"]);if(y!=null){I(t,["routingConfig"],y)}const v=A(e,["seed"]);if(v!=null){I(t,["seed"],v)}const E=A(e,["speechConfig"]);if(E!=null){I(t,["speechConfig"],E)}const w=A(e,["stopSequences"]);if(w!=null){I(t,["stopSequences"],w)}const b=A(e,["temperature"]);if(b!=null){I(t,["temperature"],b)}const T=A(e,["thinkingConfig"]);if(T!=null){I(t,["thinkingConfig"],T)}const S=A(e,["topK"]);if(S!=null){I(t,["topK"],S)}const O=A(e,["topP"]);if(O!=null){I(t,["topP"],O)}if(A(e,["enableEnhancedCivicAnswers"])!==undefined){throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.")}return t}function Hr(e,n,t){const i={};const o=A(n,["model"]);if(o!=null){I(i,["_url","name"],An(e,o))}return i}function $r(e,n,t){const i={};const o=A(n,["model"]);if(o!=null){I(i,["_url","name"],An(e,o))}return i}function Jr(e,n){const t={};if(A(e,["authConfig"])!==undefined){throw new Error("authConfig parameter is not supported in Gemini API.")}const i=A(e,["enableWidget"]);if(i!=null){I(t,["enableWidget"],i)}return t}function Vr(e,n){const t={};const i=A(e,["searchTypes"]);if(i!=null){I(t,["searchTypes"],i)}if(A(e,["excludeDomains"])!==undefined){throw new Error("excludeDomains parameter is not supported in Gemini API.")}if(A(e,["blockingConfidence"])!==undefined){throw new Error("blockingConfidence parameter is not supported in Gemini API.")}const o=A(e,["timeRangeFilter"]);if(o!=null){I(t,["timeRangeFilter"],o)}return t}function Br(e,n){const t={};const i=A(e,["aspectRatio"]);if(i!=null){I(t,["aspectRatio"],i)}const o=A(e,["imageSize"]);if(o!=null){I(t,["imageSize"],o)}if(A(e,["personGeneration"])!==undefined){throw new Error("personGeneration parameter is not supported in Gemini API.")}if(A(e,["prominentPeople"])!==undefined){throw new Error("prominentPeople parameter is not supported in Gemini API.")}if(A(e,["outputMimeType"])!==undefined){throw new Error("outputMimeType parameter is not supported in Gemini API.")}if(A(e,["outputCompressionQuality"])!==undefined){throw new Error("outputCompressionQuality parameter is not supported in Gemini API.")}return t}function Wr(e,n){const t={};const i=A(e,["aspectRatio"]);if(i!=null){I(t,["aspectRatio"],i)}const o=A(e,["imageSize"]);if(o!=null){I(t,["imageSize"],o)}const r=A(e,["personGeneration"]);if(r!=null){I(t,["personGeneration"],r)}const s=A(e,["prominentPeople"]);if(s!=null){I(t,["prominentPeople"],s)}const l=A(e,["outputMimeType"]);if(l!=null){I(t,["imageOutputOptions","mimeType"],l)}const u=A(e,["outputCompressionQuality"]);if(u!=null){I(t,["imageOutputOptions","compressionQuality"],u)}return t}function Yr(e,n){const t={};const i=A(e,["bytesBase64Encoded"]);if(i!=null){I(t,["imageBytes"],Kn(i))}const o=A(e,["mimeType"]);if(o!=null){I(t,["mimeType"],o)}return t}function Kr(e,n){const t={};const i=A(e,["gcsUri"]);if(i!=null){I(t,["gcsUri"],i)}const o=A(e,["bytesBase64Encoded"]);if(o!=null){I(t,["imageBytes"],Kn(o))}const r=A(e,["mimeType"]);if(r!=null){I(t,["mimeType"],r)}return t}function zr(e,n){const t={};if(A(e,["gcsUri"])!==undefined){throw new Error("gcsUri parameter is not supported in Gemini API.")}const i=A(e,["imageBytes"]);if(i!=null){I(t,["bytesBase64Encoded"],Kn(i))}const o=A(e,["mimeType"]);if(o!=null){I(t,["mimeType"],o)}return t}function Xr(e,n){const t={};const i=A(e,["gcsUri"]);if(i!=null){I(t,["gcsUri"],i)}const o=A(e,["imageBytes"]);if(o!=null){I(t,["bytesBase64Encoded"],Kn(o))}const r=A(e,["mimeType"]);if(r!=null){I(t,["mimeType"],r)}return t}function Qr(e,n,t,i){const o={};const r=A(n,["pageSize"]);if(t!==undefined&&r!=null){I(t,["_query","pageSize"],r)}const s=A(n,["pageToken"]);if(t!==undefined&&s!=null){I(t,["_query","pageToken"],s)}const l=A(n,["filter"]);if(t!==undefined&&l!=null){I(t,["_query","filter"],l)}const u=A(n,["queryBase"]);if(t!==undefined&&u!=null){I(t,["_url","models_url"],et(e,u))}return o}function Zr(e,n,t,i){const o={};const r=A(n,["pageSize"]);if(t!==undefined&&r!=null){I(t,["_query","pageSize"],r)}const s=A(n,["pageToken"]);if(t!==undefined&&s!=null){I(t,["_query","pageToken"],s)}const l=A(n,["filter"]);if(t!==undefined&&l!=null){I(t,["_query","filter"],l)}const u=A(n,["queryBase"]);if(t!==undefined&&u!=null){I(t,["_url","models_url"],et(e,u))}return o}function es(e,n,t){const i={};const o=A(n,["config"]);if(o!=null){Qr(e,o,i)}return i}function ns(e,n,t){const i={};const o=A(n,["config"]);if(o!=null){Zr(e,o,i)}return i}function ts(e,n){const t={};const i=A(e,["sdkHttpResponse"]);if(i!=null){I(t,["sdkHttpResponse"],i)}const o=A(e,["nextPageToken"]);if(o!=null){I(t,["nextPageToken"],o)}const r=A(e,["_self"]);if(r!=null){let e=nt(r);if(Array.isArray(e)){e=e.map((e=>rs(e)))}I(t,["models"],e)}return t}function is(e,n){const t={};const i=A(e,["sdkHttpResponse"]);if(i!=null){I(t,["sdkHttpResponse"],i)}const o=A(e,["nextPageToken"]);if(o!=null){I(t,["nextPageToken"],o)}const r=A(e,["_self"]);if(r!=null){let e=nt(r);if(Array.isArray(e)){e=e.map((e=>ss(e)))}I(t,["models"],e)}return t}function os(e,n){const t={};const i=A(e,["maskMode"]);if(i!=null){I(t,["maskMode"],i)}const o=A(e,["segmentationClasses"]);if(o!=null){I(t,["maskClasses"],o)}const r=A(e,["maskDilation"]);if(r!=null){I(t,["dilation"],r)}return t}function rs(e,n){const t={};const i=A(e,["name"]);if(i!=null){I(t,["name"],i)}const o=A(e,["displayName"]);if(o!=null){I(t,["displayName"],o)}const r=A(e,["description"]);if(r!=null){I(t,["description"],r)}const s=A(e,["version"]);if(s!=null){I(t,["version"],s)}const l=A(e,["_self"]);if(l!=null){I(t,["tunedModelInfo"],As(l))}const u=A(e,["inputTokenLimit"]);if(u!=null){I(t,["inputTokenLimit"],u)}const a=A(e,["outputTokenLimit"]);if(a!=null){I(t,["outputTokenLimit"],a)}const c=A(e,["supportedGenerationMethods"]);if(c!=null){I(t,["supportedActions"],c)}const f=A(e,["temperature"]);if(f!=null){I(t,["temperature"],f)}const d=A(e,["maxTemperature"]);if(d!=null){I(t,["maxTemperature"],d)}const p=A(e,["topP"]);if(p!=null){I(t,["topP"],p)}const h=A(e,["topK"]);if(h!=null){I(t,["topK"],h)}const m=A(e,["thinking"]);if(m!=null){I(t,["thinking"],m)}return t}function ss(e,n){const t={};const i=A(e,["name"]);if(i!=null){I(t,["name"],i)}const o=A(e,["displayName"]);if(o!=null){I(t,["displayName"],o)}const r=A(e,["description"]);if(r!=null){I(t,["description"],r)}const s=A(e,["versionId"]);if(s!=null){I(t,["version"],s)}const l=A(e,["deployedModels"]);if(l!=null){let e=l;if(Array.isArray(e)){e=e.map((e=>ar(e)))}I(t,["endpoints"],e)}const u=A(e,["labels"]);if(u!=null){I(t,["labels"],u)}const a=A(e,["_self"]);if(a!=null){I(t,["tunedModelInfo"],Os(a))}const c=A(e,["defaultCheckpointId"]);if(c!=null){I(t,["defaultCheckpointId"],c)}const f=A(e,["checkpoints"]);if(f!=null){let e=f;if(Array.isArray(e)){e=e.map((e=>e))}I(t,["checkpoints"],e)}return t}function ls(e,n){const t={};const i=A(e,["mediaResolution"]);if(i!=null){I(t,["mediaResolution"],i)}const o=A(e,["codeExecutionResult"]);if(o!=null){I(t,["codeExecutionResult"],o)}const r=A(e,["executableCode"]);if(r!=null){I(t,["executableCode"],r)}const s=A(e,["fileData"]);if(s!=null){I(t,["fileData"],cr(s))}const l=A(e,["functionCall"]);if(l!=null){I(t,["functionCall"],fr(l))}const u=A(e,["functionResponse"]);if(u!=null){I(t,["functionResponse"],u)}const a=A(e,["inlineData"]);if(a!=null){I(t,["inlineData"],ko(a))}const c=A(e,["text"]);if(c!=null){I(t,["text"],c)}const f=A(e,["thought"]);if(f!=null){I(t,["thought"],f)}const d=A(e,["thoughtSignature"]);if(d!=null){I(t,["thoughtSignature"],d)}const p=A(e,["videoMetadata"]);if(p!=null){I(t,["videoMetadata"],p)}return t}function us(e,n){const t={};const i=A(e,["productImage"]);if(i!=null){I(t,["image"],Xr(i))}return t}function as(e,n,t){const i={};const o=A(e,["numberOfImages"]);if(n!==undefined&&o!=null){I(n,["parameters","sampleCount"],o)}const r=A(e,["baseSteps"]);if(n!==undefined&&r!=null){I(n,["parameters","baseSteps"],r)}const s=A(e,["outputGcsUri"]);if(n!==undefined&&s!=null){I(n,["parameters","storageUri"],s)}const l=A(e,["seed"]);if(n!==undefined&&l!=null){I(n,["parameters","seed"],l)}const u=A(e,["safetyFilterLevel"]);if(n!==undefined&&u!=null){I(n,["parameters","safetySetting"],u)}const a=A(e,["personGeneration"]);if(n!==undefined&&a!=null){I(n,["parameters","personGeneration"],a)}const c=A(e,["addWatermark"]);if(n!==undefined&&c!=null){I(n,["parameters","addWatermark"],c)}const f=A(e,["outputMimeType"]);if(n!==undefined&&f!=null){I(n,["parameters","outputOptions","mimeType"],f)}const d=A(e,["outputCompressionQuality"]);if(n!==undefined&&d!=null){I(n,["parameters","outputOptions","compressionQuality"],d)}const p=A(e,["enhancePrompt"]);if(n!==undefined&&p!=null){I(n,["parameters","enhancePrompt"],p)}const h=A(e,["labels"]);if(n!==undefined&&h!=null){I(n,["labels"],h)}return i}function cs(e,n,t){const i={};const o=A(n,["model"]);if(o!=null){I(i,["_url","model"],An(e,o))}const r=A(n,["source"]);if(r!=null){ds(r,i)}const s=A(n,["config"]);if(s!=null){as(s,i)}return i}function fs(e,n){const t={};const i=A(e,["predictions"]);if(i!=null){let e=i;if(Array.isArray(e)){e=e.map((e=>xr(e)))}I(t,["generatedImages"],e)}return t}function ds(e,n,t){const i={};const o=A(e,["prompt"]);if(n!==undefined&&o!=null){I(n,["instances[0]","prompt"],o)}const r=A(e,["personImage"]);if(n!==undefined&&r!=null){I(n,["instances[0]","personImage","image"],Xr(r))}const s=A(e,["productImages"]);if(n!==undefined&&s!=null){let e=s;if(Array.isArray(e)){e=e.map((e=>us(e)))}I(n,["instances[0]","productImages"],e)}return i}function ps(e,n){const t={};const i=A(e,["referenceImage"]);if(i!=null){I(t,["referenceImage"],Xr(i))}const o=A(e,["referenceId"]);if(o!=null){I(t,["referenceId"],o)}const r=A(e,["referenceType"]);if(r!=null){I(t,["referenceType"],r)}const s=A(e,["maskImageConfig"]);if(s!=null){I(t,["maskImageConfig"],os(s))}const l=A(e,["controlImageConfig"]);if(l!=null){I(t,["controlImageConfig"],$o(l))}const u=A(e,["styleImageConfig"]);if(u!=null){I(t,["styleImageConfig"],u)}const a=A(e,["subjectImageConfig"]);if(a!=null){I(t,["subjectImageConfig"],a)}return t}function hs(e,n){const t={};const i=A(e,["safetyAttributes","categories"]);if(i!=null){I(t,["categories"],i)}const o=A(e,["safetyAttributes","scores"]);if(o!=null){I(t,["scores"],o)}const r=A(e,["contentType"]);if(r!=null){I(t,["contentType"],r)}return t}function ms(e,n){const t={};const i=A(e,["safetyAttributes","categories"]);if(i!=null){I(t,["categories"],i)}const o=A(e,["safetyAttributes","scores"]);if(o!=null){I(t,["scores"],o)}const r=A(e,["contentType"]);if(r!=null){I(t,["contentType"],r)}return t}function gs(e,n){const t={};const i=A(e,["category"]);if(i!=null){I(t,["category"],i)}if(A(e,["method"])!==undefined){throw new Error("method parameter is not supported in Gemini API.")}const o=A(e,["threshold"]);if(o!=null){I(t,["threshold"],o)}return t}function ys(e,n){const t={};const i=A(e,["image"]);if(i!=null){I(t,["image"],Xr(i))}return t}function vs(e,n,t){const i={};const o=A(e,["mode"]);if(n!==undefined&&o!=null){I(n,["parameters","mode"],o)}const r=A(e,["maxPredictions"]);if(n!==undefined&&r!=null){I(n,["parameters","maxPredictions"],r)}const s=A(e,["confidenceThreshold"]);if(n!==undefined&&s!=null){I(n,["parameters","confidenceThreshold"],s)}const l=A(e,["maskDilation"]);if(n!==undefined&&l!=null){I(n,["parameters","maskDilation"],l)}const u=A(e,["binaryColorThreshold"]);if(n!==undefined&&u!=null){I(n,["parameters","binaryColorThreshold"],u)}const a=A(e,["labels"]);if(n!==undefined&&a!=null){I(n,["labels"],a)}return i}function Es(e,n,t){const i={};const o=A(n,["model"]);if(o!=null){I(i,["_url","model"],An(e,o))}const r=A(n,["source"]);if(r!=null){bs(r,i)}const s=A(n,["config"]);if(s!=null){vs(s,i)}return i}function ws(e,n){const t={};const i=A(e,["predictions"]);if(i!=null){let e=i;if(Array.isArray(e)){e=e.map((e=>Lr(e)))}I(t,["generatedMasks"],e)}return t}function bs(e,n,t){const i={};const o=A(e,["prompt"]);if(n!==undefined&&o!=null){I(n,["instances[0]","prompt"],o)}const r=A(e,["image"]);if(n!==undefined&&r!=null){I(n,["instances[0]","image"],Xr(r))}const s=A(e,["scribbleImage"]);if(n!==undefined&&s!=null){I(n,["instances[0]","scribble"],ys(s))}return i}function Ts(e,n){const t={};const i=A(e,["retrievalConfig"]);if(i!=null){I(t,["retrievalConfig"],i)}const o=A(e,["functionCallingConfig"]);if(o!=null){I(t,["functionCallingConfig"],dr(o))}return t}function Ss(e,n){const t={};if(A(e,["retrieval"])!==undefined){throw new Error("retrieval parameter is not supported in Gemini API.")}const i=A(e,["computerUse"]);if(i!=null){I(t,["computerUse"],i)}const o=A(e,["fileSearch"]);if(o!=null){I(t,["fileSearch"],o)}const r=A(e,["googleSearch"]);if(r!=null){I(t,["googleSearch"],Vr(r))}const s=A(e,["codeExecution"]);if(s!=null){I(t,["codeExecution"],s)}if(A(e,["enterpriseWebSearch"])!==undefined){throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.")}const l=A(e,["functionDeclarations"]);if(l!=null){let e=l;if(Array.isArray(e)){e=e.map((e=>e))}I(t,["functionDeclarations"],e)}const u=A(e,["googleMaps"]);if(u!=null){I(t,["googleMaps"],Jr(u))}const a=A(e,["googleSearchRetrieval"]);if(a!=null){I(t,["googleSearchRetrieval"],a)}const c=A(e,["urlContext"]);if(c!=null){I(t,["urlContext"],c)}const f=A(e,["mcpServers"]);if(f!=null){let e=f;if(Array.isArray(e)){e=e.map((e=>e))}I(t,["mcpServers"],e)}return t}function Is(e,n){const t={};const i=A(e,["retrieval"]);if(i!=null){I(t,["retrieval"],i)}const o=A(e,["computerUse"]);if(o!=null){I(t,["computerUse"],o)}if(A(e,["fileSearch"])!==undefined){throw new Error("fileSearch parameter is not supported in Vertex AI.")}const r=A(e,["googleSearch"]);if(r!=null){I(t,["googleSearch"],r)}const s=A(e,["codeExecution"]);if(s!=null){I(t,["codeExecution"],s)}const l=A(e,["enterpriseWebSearch"]);if(l!=null){I(t,["enterpriseWebSearch"],l)}const u=A(e,["functionDeclarations"]);if(u!=null){let e=u;if(Array.isArray(e)){e=e.map((e=>pr(e)))}I(t,["functionDeclarations"],e)}const a=A(e,["googleMaps"]);if(a!=null){I(t,["googleMaps"],a)}const c=A(e,["googleSearchRetrieval"]);if(c!=null){I(t,["googleSearchRetrieval"],c)}const f=A(e,["urlContext"]);if(f!=null){I(t,["urlContext"],f)}if(A(e,["mcpServers"])!==undefined){throw new Error("mcpServers parameter is not supported in Vertex AI.")}return t}function As(e,n){const t={};const i=A(e,["baseModel"]);if(i!=null){I(t,["baseModel"],i)}const o=A(e,["createTime"]);if(o!=null){I(t,["createTime"],o)}const r=A(e,["updateTime"]);if(r!=null){I(t,["updateTime"],r)}return t}function Os(e,n){const t={};const i=A(e,["labels","google-vertex-llm-tuning-base-model-id"]);if(i!=null){I(t,["baseModel"],i)}const o=A(e,["createTime"]);if(o!=null){I(t,["createTime"],o)}const r=A(e,["updateTime"]);if(r!=null){I(t,["updateTime"],r)}return t}function Cs(e,n,t){const i={};const o=A(e,["displayName"]);if(n!==undefined&&o!=null){I(n,["displayName"],o)}const r=A(e,["description"]);if(n!==undefined&&r!=null){I(n,["description"],r)}const s=A(e,["defaultCheckpointId"]);if(n!==undefined&&s!=null){I(n,["defaultCheckpointId"],s)}return i}function _s(e,n,t){const i={};const o=A(e,["displayName"]);if(n!==undefined&&o!=null){I(n,["displayName"],o)}const r=A(e,["description"]);if(n!==undefined&&r!=null){I(n,["description"],r)}const s=A(e,["defaultCheckpointId"]);if(n!==undefined&&s!=null){I(n,["defaultCheckpointId"],s)}return i}function Ps(e,n,t){const i={};const o=A(n,["model"]);if(o!=null){I(i,["_url","name"],An(e,o))}const r=A(n,["config"]);if(r!=null){Cs(r,i)}return i}function Rs(e,n,t){const i={};const o=A(n,["model"]);if(o!=null){I(i,["_url","model"],An(e,o))}const r=A(n,["config"]);if(r!=null){_s(r,i)}return i}function Ns(e,n,t){const i={};const o=A(e,["outputGcsUri"]);if(n!==undefined&&o!=null){I(n,["parameters","storageUri"],o)}const r=A(e,["safetyFilterLevel"]);if(n!==undefined&&r!=null){I(n,["parameters","safetySetting"],r)}const s=A(e,["personGeneration"]);if(n!==undefined&&s!=null){I(n,["parameters","personGeneration"],s)}const l=A(e,["includeRaiReason"]);if(n!==undefined&&l!=null){I(n,["parameters","includeRaiReason"],l)}const u=A(e,["outputMimeType"]);if(n!==undefined&&u!=null){I(n,["parameters","outputOptions","mimeType"],u)}const a=A(e,["outputCompressionQuality"]);if(n!==undefined&&a!=null){I(n,["parameters","outputOptions","compressionQuality"],a)}const c=A(e,["enhanceInputImage"]);if(n!==undefined&&c!=null){I(n,["parameters","upscaleConfig","enhanceInputImage"],c)}const f=A(e,["imagePreservationFactor"]);if(n!==undefined&&f!=null){I(n,["parameters","upscaleConfig","imagePreservationFactor"],f)}const d=A(e,["labels"]);if(n!==undefined&&d!=null){I(n,["labels"],d)}const p=A(e,["numberOfImages"]);if(n!==undefined&&p!=null){I(n,["parameters","sampleCount"],p)}const h=A(e,["mode"]);if(n!==undefined&&h!=null){I(n,["parameters","mode"],h)}return i}function Ms(e,n,t){const i={};const o=A(n,["model"]);if(o!=null){I(i,["_url","model"],An(e,o))}const r=A(n,["image"]);if(r!=null){I(i,["instances[0]","image"],Xr(r))}const s=A(n,["upscaleFactor"]);if(s!=null){I(i,["parameters","upscaleConfig","upscaleFactor"],s)}const l=A(n,["config"]);if(l!=null){Ns(l,i)}return i}function Ds(e,n){const t={};const i=A(e,["sdkHttpResponse"]);if(i!=null){I(t,["sdkHttpResponse"],i)}const o=A(e,["predictions"]);if(o!=null){let e=o;if(Array.isArray(e)){e=e.map((e=>xr(e)))}I(t,["generatedImages"],e)}return t}function Us(e,n){const t={};const i=A(e,["uri"]);if(i!=null){I(t,["uri"],i)}const o=A(e,["encodedVideo"]);if(o!=null){I(t,["videoBytes"],Kn(o))}const r=A(e,["encoding"]);if(r!=null){I(t,["mimeType"],r)}return t}function ks(e,n){const t={};const i=A(e,["gcsUri"]);if(i!=null){I(t,["uri"],i)}const o=A(e,["bytesBase64Encoded"]);if(o!=null){I(t,["videoBytes"],Kn(o))}const r=A(e,["mimeType"]);if(r!=null){I(t,["mimeType"],r)}return t}function Gs(e,n){const t={};const i=A(e,["image"]);if(i!=null){I(t,["_self"],Xr(i))}const o=A(e,["maskMode"]);if(o!=null){I(t,["maskMode"],o)}return t}function xs(e,n){const t={};const i=A(e,["image"]);if(i!=null){I(t,["image"],zr(i))}const o=A(e,["referenceType"]);if(o!=null){I(t,["referenceType"],o)}return t}function Ls(e,n){const t={};const i=A(e,["image"]);if(i!=null){I(t,["image"],Xr(i))}const o=A(e,["referenceType"]);if(o!=null){I(t,["referenceType"],o)}return t}function js(e,n){const t={};const i=A(e,["uri"]);if(i!=null){I(t,["uri"],i)}const o=A(e,["videoBytes"]);if(o!=null){I(t,["encodedVideo"],Kn(o))}const r=A(e,["mimeType"]);if(r!=null){I(t,["encoding"],r)}return t}function Fs(e,n){const t={};const i=A(e,["uri"]);if(i!=null){I(t,["gcsUri"],i)}const o=A(e,["videoBytes"]);if(o!=null){I(t,["bytesBase64Encoded"],Kn(o))}const r=A(e,["mimeType"]);if(r!=null){I(t,["mimeType"],r)}return t}
|
|
87
|
+
/**
|
|
88
|
+
* @license
|
|
89
|
+
* Copyright 2025 Google LLC
|
|
90
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
91
|
+
*/function qs(e,n){const t={};const i=A(e,["displayName"]);if(n!==undefined&&i!=null){I(n,["displayName"],i)}return t}function Hs(e){const n={};const t=A(e,["config"]);if(t!=null){qs(t,n)}return n}function $s(e,n){const t={};const i=A(e,["force"]);if(n!==undefined&&i!=null){I(n,["_query","force"],i)}return t}function Js(e){const n={};const t=A(e,["name"]);if(t!=null){I(n,["_url","name"],t)}const i=A(e,["config"]);if(i!=null){$s(i,n)}return n}function Vs(e){const n={};const t=A(e,["name"]);if(t!=null){I(n,["_url","name"],t)}return n}function Bs(e,n){const t={};const i=A(e,["customMetadata"]);if(n!==undefined&&i!=null){let e=i;if(Array.isArray(e)){e=e.map((e=>e))}I(n,["customMetadata"],e)}const o=A(e,["chunkingConfig"]);if(n!==undefined&&o!=null){I(n,["chunkingConfig"],o)}return t}function Ws(e){const n={};const t=A(e,["name"]);if(t!=null){I(n,["name"],t)}const i=A(e,["metadata"]);if(i!=null){I(n,["metadata"],i)}const o=A(e,["done"]);if(o!=null){I(n,["done"],o)}const r=A(e,["error"]);if(r!=null){I(n,["error"],r)}const s=A(e,["response"]);if(s!=null){I(n,["response"],Ks(s))}return n}function Ys(e){const n={};const t=A(e,["fileSearchStoreName"]);if(t!=null){I(n,["_url","file_search_store_name"],t)}const i=A(e,["fileName"]);if(i!=null){I(n,["fileName"],i)}const o=A(e,["config"]);if(o!=null){Bs(o,n)}return n}function Ks(e){const n={};const t=A(e,["sdkHttpResponse"]);if(t!=null){I(n,["sdkHttpResponse"],t)}const i=A(e,["parent"]);if(i!=null){I(n,["parent"],i)}const o=A(e,["documentName"]);if(o!=null){I(n,["documentName"],o)}return n}function zs(e,n){const t={};const i=A(e,["pageSize"]);if(n!==undefined&&i!=null){I(n,["_query","pageSize"],i)}const o=A(e,["pageToken"]);if(n!==undefined&&o!=null){I(n,["_query","pageToken"],o)}return t}function Xs(e){const n={};const t=A(e,["config"]);if(t!=null){zs(t,n)}return n}function Qs(e){const n={};const t=A(e,["sdkHttpResponse"]);if(t!=null){I(n,["sdkHttpResponse"],t)}const i=A(e,["nextPageToken"]);if(i!=null){I(n,["nextPageToken"],i)}const o=A(e,["fileSearchStores"]);if(o!=null){let e=o;if(Array.isArray(e)){e=e.map((e=>e))}I(n,["fileSearchStores"],e)}return n}function Zs(e,n){const t={};const i=A(e,["mimeType"]);if(n!==undefined&&i!=null){I(n,["mimeType"],i)}const o=A(e,["displayName"]);if(n!==undefined&&o!=null){I(n,["displayName"],o)}const r=A(e,["customMetadata"]);if(n!==undefined&&r!=null){let e=r;if(Array.isArray(e)){e=e.map((e=>e))}I(n,["customMetadata"],e)}const s=A(e,["chunkingConfig"]);if(n!==undefined&&s!=null){I(n,["chunkingConfig"],s)}return t}function el(e){const n={};const t=A(e,["fileSearchStoreName"]);if(t!=null){I(n,["_url","file_search_store_name"],t)}const i=A(e,["config"]);if(i!=null){Zs(i,n)}return n}function nl(e){const n={};const t=A(e,["sdkHttpResponse"]);if(t!=null){I(n,["sdkHttpResponse"],t)}return n}
|
|
92
|
+
/**
|
|
93
|
+
* @license
|
|
94
|
+
* Copyright 2025 Google LLC
|
|
95
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
96
|
+
*/const tl="Content-Type";const il="X-Server-Timeout";const ol="User-Agent";const rl="x-goog-api-client";const sl="1.43.0";const ll=`google-genai-sdk/${sl}`;const ul="v1beta1";const al="v1beta";const cl=5;const fl=[408,429,500,502,503,504];class dl{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:ul}else{if(!this.clientOptions.apiKey){throw new Zi({message:"API key must be set when using the Gemini API.",status:403})}o.apiVersion=(i=this.clientOptions.apiVersion)!==null&&i!==void 0?i:al;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===ve.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){hl(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 pl(e);return new Ke(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 pl(e);return this.processStreamResponse(e)})).catch((e=>{if(e instanceof Error){throw e}else{throw new Error(JSON.stringify(e))}}))}processStreamResponse(e){return Vi(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 Ji(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 Zi({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 Ji(new Ke(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(fl.includes(t.status)){throw new Error(`Retryable HTTP Error: ${t.statusText}`)}throw new g.AbortError(`Non-retryable exception ${t.statusText} sending request`)};return y(o,{retries:((t=i.attempts)!==null&&t!==void 0?t:cl)-1})}getDefaultHeaders(){const e={};const n=ll+" "+this.clientOptions.userAgentExtra;e[ol]=n;e[rl]=n;e[tl]="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(il,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=S("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){Zs(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 pl(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 Zi({message:o,status:t});throw e}throw new Error(o)}}function hl(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 ml="mcp_used/unknown";let gl=false;function yl(e){for(const n of e){if(El(n)){return true}if(typeof n==="object"&&"inputSchema"in n){return true}}return gl}function vl(e){var n;const t=(n=e[rl])!==null&&n!==void 0?n:"";e[rl]=(t+` ${ml}`).trimStart()}function El(e){return e!==null&&typeof e==="object"&&e instanceof bl}function wl(e){return Vi(this,arguments,(function*e(n,t=100){let i=undefined;let o=0;while(o<t){const e=yield Ji(n.listTools({cursor:i}));for(const n of e.tools){yield yield Ji(n);o++}if(!e.nextCursor){break}i=e.nextCursor}}))}class bl{constructor(e=[],n){this.mcpTools=[];this.functionNameToMcpClient={};this.mcpClients=e;this.config=n}static create(e,n){return new bl(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,Bi(wl(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 ot(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 Tl(e,n,t){const i=new Sn;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 Sl{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=Ol(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 Tl(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,Al(r),p);h.connect();await a;const m=An(this.apiClient,e.model);const g={model:m};const y={setup:g};h.send(JSON.stringify(y));return new Il(h,this.apiClient)}}class Il{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=Ao(e);this.conn.send(JSON.stringify({clientContent:n}))}async setMusicGenerationConfig(e){if(!e.musicGenerationConfig){e.musicGenerationConfig={}}const n=Io(e);this.conn.send(JSON.stringify(n))}sendPlaybackControl(e){const n={playbackControl:e};this.conn.send(JSON.stringify(n))}play(){this.sendPlaybackControl(Ye.PLAY)}pause(){this.sendPlaybackControl(Ye.PAUSE)}stop(){this.sendPlaybackControl(Ye.STOP)}resetContext(){this.sendPlaybackControl(Ye.RESET_CONTEXT)}close(){this.conn.close()}}function Al(e){const n={};e.forEach(((e,t)=>{n[t]=e}));return n}function Ol(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 Cl="FunctionResponse request must have an `id` field from the response of a ToolCall.FunctionalCalls in Google AI.";async function _l(e,n,t){const i=new Tn;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=_o(r);Object.assign(i,e)}else{const e=r;Object.assign(i,e)}n(i)}class Pl{constructor(e,n,t){this.apiClient=e;this.auth=n;this.webSocketFactory=t;this.music=new Sl(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&&yl(e.config.tools)){vl(c)}const f=Dl(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 _l(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,Ml(f),y);v.connect();await p;let E=An(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:[fe.AUDIO]}}else{e.config.responseModalities=[fe.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=So(this.apiClient,S)}else{w=To(this.apiClient,S)}delete w["config"];v.send(JSON.stringify(w));return new Nl(v,this.apiClient)}isCallableTool(e){return"callTool"in e&&typeof e.callTool==="function"}}const Rl={turnComplete:true};class Nl{constructor(e,n){this.conn=e;this.apiClient=n}tLiveClientContent(e,n){if(n.turns!==null&&n.turns!==undefined){let t=[];try{t=Ln(n.turns);if(!e.isVertexAI()){t=t.map((e=>Ho(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(Cl)}}const i={toolResponse:{functionResponses:t}};return i}sendClientContent(e){e=Object.assign(Object.assign({},Rl),e);const n=this.tLiveClientContent(this.apiClient,e);this.conn.send(JSON.stringify(n))}sendRealtimeInput(e){let n={};if(this.apiClient.isVertexAI()){n={realtimeInput:Co(e)}}else{n={realtimeInput:Oo(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 Ml(e){const n={};e.forEach(((e,t)=>{n[t]=e}));return n}function Dl(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 Ul=10;function kl(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(Gl(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 Gl(e){return"callTool"in e&&typeof e.callTool==="function"}function xl(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=>Gl(e))))!==null&&i!==void 0?i:false}function Ll(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(Gl(e)){return}const i=e;if(i.functionDeclarations&&i.functionDeclarations.length>0){t.push(n)}}));return t}function jl(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 Fl extends T{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=Ln(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:Te.EMBED_CONTENT});return await this.embedContentInternal(t)}else{const n=Object.assign(Object.assign({},e),{embeddingApiType:Te.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(!xl(e)||kl(e.config)){return await this.generateContentInternal(s)}const l=Ll(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=Ln(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:Ul;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(Gl(n)){const e=n;const i=await e.callTool(u.functionCalls);t.push(...i)}}d++;a={role:"user",parts:t};s.contents=Ln(s.contents);s.contents.push(n);s.contents.push(a);if(jl(s.config)){c.push(n);c.push(a)}}if(jl(s.config)){u.automaticFunctionCallingHistory=c}return u};this.generateContentStream=async e=>{var n,t,i,o,r;this.maybeMoveToResponseJsonSchem(e);if(kl(e.config)){const n=await this.processParamsMaybeAddMcpUsage(e);return await this.generateContentStreamInternal(n)}const s=Ll(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 li(si.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(Gl(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&&yl(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()}vl(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(Gl(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:Ul;let r=false;let s=0;const l=await this.initAfcToolsMap(e);return function(e,n,t){return Vi(this,arguments,(function*(){var i,l,u,a;var c,f;while(s<o){if(r){s++;r=false}const m=yield Ji(e.processParamsMaybeAddMcpUsage(t));const g=yield Ji(e.generateContentStreamInternal(m));const y=[];const v=[];try{for(var d=true,p=(l=void 0,Bi(g)),h;h=yield Ji(p.next()),i=h.done,!i;d=true){a=h.value;d=false;const e=a;yield yield Ji(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 Ji(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 Ji(u.call(p))}finally{if(l)throw l.error}}if(y.length>0){r=true;const e=new ze;e.candidates=[{content:{role:"user",parts:y}}];yield yield Ji(e);const n=[];n.push(...v);n.push({role:"user",parts:y});const i=Ln(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=yr(this.apiClient,e);s=S("{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=Er(e);const t=new ze;Object.assign(t,n);return t}))}else{const n=gr(this.apiClient,e);s=S("{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=vr(e);const t=new ze;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=yr(this.apiClient,e);s=S("{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 Vi(this,arguments,(function*(){var n,t,i,o;try{for(var r=true,s=Bi(e),l;l=yield Ji(s.next()),n=l.done,!n;r=true){o=l.value;r=false;const e=o;const n=Er(yield Ji(e.json()));n["sdkHttpResponse"]={headers:e.headers};const t=new ze;Object.assign(t,n);yield yield Ji(t)}}catch(e){t={error:e}}finally{try{if(!r&&!n&&(i=s.return))yield Ji(i.call(s))}finally{if(t)throw t.error}}}))}))}else{const n=gr(this.apiClient,e);s=S("{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 Vi(this,arguments,(function*(){var n,t,i,o;try{for(var r=true,s=Bi(e),l;l=yield Ji(s.next()),n=l.done,!n;r=true){o=l.value;r=false;const e=o;const n=vr(yield Ji(e.json()));n["sdkHttpResponse"]={headers:e.headers};const t=new ze;Object.assign(t,n);yield yield Ji(t)}}catch(e){t={error:e}}finally{try{if(!r&&!n&&(i=s.return))yield Ji(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=sr(this.apiClient,e,e);const o=ct(e.model)?"{model}:embedContent":"{model}:predict";s=S(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=ur(n,e);const i=new Xe;Object.assign(i,t);return i}))}else{const n=rr(this.apiClient,e);s=S("{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=lr(e);const t=new Xe;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=Sr(this.apiClient,e);s=S("{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=Ar(e);const t=new Qe;Object.assign(t,n);return t}))}else{const n=Tr(this.apiClient,e);s=S("{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=Ir(e);const t=new Qe;Object.assign(t,n);return t}))}}async editImageInternal(e){var n,t;let i;let o="";let r={};if(this.apiClient.isVertexAI()){const s=nr(this.apiClient,e);o=S("{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=tr(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 upscaleImageInternal(e){var n,t;let i;let o="";let r={};if(this.apiClient.isVertexAI()){const s=Ms(this.apiClient,e);o=S("{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=Ds(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 recontextImage(e){var n,t;let i;let o="";let r={};if(this.apiClient.isVertexAI()){const s=cs(this.apiClient,e);o=S("{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=fs(e);const t=new nn;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=Es(this.apiClient,e);o=S("{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=ws(e);const t=new tn;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=$r(this.apiClient,e);s=S("{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=ss(e);return n}))}else{const n=Hr(this.apiClient,e);s=S("{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=rs(e);return n}))}}async listInternal(e){var n,t,i,o;let r;let s="";let l={};if(this.apiClient.isVertexAI()){const i=ns(this.apiClient,e);s=S("{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=is(e);const t=new on;Object.assign(t,n);return t}))}else{const n=es(this.apiClient,e);s=S("{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=ts(e);const t=new on;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=Rs(this.apiClient,e);s=S("{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=ss(e);return n}))}else{const n=Ps(this.apiClient,e);s=S("{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=rs(e);return n}))}}async delete(e){var n,t,i,o;let r;let s="";let l={};if(this.apiClient.isVertexAI()){const i=Xo(this.apiClient,e);s=S("{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=Zo(e);const t=new rn;Object.assign(t,n);return t}))}else{const n=zo(this.apiClient,e);s=S("{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=Qo(e);const t=new rn;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=Wo(this.apiClient,e);s=S("{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=Ko(e);const t=new sn;Object.assign(t,n);return t}))}else{const n=Bo(this.apiClient,e);s=S("{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=Yo(e);const t=new sn;Object.assign(t,n);return t}))}}async computeTokens(e){var n,t;let i;let o="";let r={};if(this.apiClient.isVertexAI()){const s=Lo(this.apiClient,e);o=S("{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=jo(e);const t=new ln;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=Nr(this.apiClient,e);s=S("{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=Pr(e);const t=new un;Object.assign(t,n);return t}))}else{const n=Rr(this.apiClient,e);s=S("{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=_r(e);const t=new un;Object.assign(t,n);return t}))}}}
|
|
122
|
+
/**
|
|
123
|
+
* @license
|
|
124
|
+
* Copyright 2025 Google LLC
|
|
125
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
126
|
+
*/class ql extends T{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=x(e);s=S("{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=G(e);s=S("{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=P(e);o=S("{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 Hl(e){const n={};const t=A(e,["data"]);if(t!=null){I(n,["data"],t)}if(A(e,["displayName"])!==undefined){throw new Error("displayName parameter is not supported in Gemini API.")}const i=A(e,["mimeType"]);if(i!=null){I(n,["mimeType"],i)}return n}function $l(e){const n={};const t=A(e,["parts"]);if(t!=null){let e=t;if(Array.isArray(e)){e=e.map((e=>Ql(e)))}I(n,["parts"],e)}const i=A(e,["role"]);if(i!=null){I(n,["role"],i)}return n}function Jl(e,n,t){const i={};const o=A(n,["expireTime"]);if(t!==undefined&&o!=null){I(t,["expireTime"],o)}const r=A(n,["newSessionExpireTime"]);if(t!==undefined&&r!=null){I(t,["newSessionExpireTime"],r)}const s=A(n,["uses"]);if(t!==undefined&&s!=null){I(t,["uses"],s)}const l=A(n,["liveConnectConstraints"]);if(t!==undefined&&l!=null){I(t,["bidiGenerateContentSetup"],Xl(e,l))}const u=A(n,["lockAdditionalFields"]);if(t!==undefined&&u!=null){I(t,["fieldMask"],u)}return i}function Vl(e,n){const t={};const i=A(n,["config"]);if(i!=null){I(t,["config"],Jl(e,i,t))}return t}function Bl(e){const n={};if(A(e,["displayName"])!==undefined){throw new Error("displayName parameter is not supported in Gemini API.")}const t=A(e,["fileUri"]);if(t!=null){I(n,["fileUri"],t)}const i=A(e,["mimeType"]);if(i!=null){I(n,["mimeType"],i)}return n}function Wl(e){const n={};const t=A(e,["id"]);if(t!=null){I(n,["id"],t)}const i=A(e,["args"]);if(i!=null){I(n,["args"],i)}const o=A(e,["name"]);if(o!=null){I(n,["name"],o)}if(A(e,["partialArgs"])!==undefined){throw new Error("partialArgs parameter is not supported in Gemini API.")}if(A(e,["willContinue"])!==undefined){throw new Error("willContinue parameter is not supported in Gemini API.")}return n}function Yl(e){const n={};if(A(e,["authConfig"])!==undefined){throw new Error("authConfig parameter is not supported in Gemini API.")}const t=A(e,["enableWidget"]);if(t!=null){I(n,["enableWidget"],t)}return n}function Kl(e){const n={};const t=A(e,["searchTypes"]);if(t!=null){I(n,["searchTypes"],t)}if(A(e,["excludeDomains"])!==undefined){throw new Error("excludeDomains parameter is not supported in Gemini API.")}if(A(e,["blockingConfidence"])!==undefined){throw new Error("blockingConfidence parameter is not supported in Gemini API.")}const i=A(e,["timeRangeFilter"]);if(i!=null){I(n,["timeRangeFilter"],i)}return n}function zl(e,n){const t={};const i=A(e,["generationConfig"]);if(n!==undefined&&i!=null){I(n,["setup","generationConfig"],i)}const o=A(e,["responseModalities"]);if(n!==undefined&&o!=null){I(n,["setup","generationConfig","responseModalities"],o)}const r=A(e,["temperature"]);if(n!==undefined&&r!=null){I(n,["setup","generationConfig","temperature"],r)}const s=A(e,["topP"]);if(n!==undefined&&s!=null){I(n,["setup","generationConfig","topP"],s)}const l=A(e,["topK"]);if(n!==undefined&&l!=null){I(n,["setup","generationConfig","topK"],l)}const u=A(e,["maxOutputTokens"]);if(n!==undefined&&u!=null){I(n,["setup","generationConfig","maxOutputTokens"],u)}const a=A(e,["mediaResolution"]);if(n!==undefined&&a!=null){I(n,["setup","generationConfig","mediaResolution"],a)}const c=A(e,["seed"]);if(n!==undefined&&c!=null){I(n,["setup","generationConfig","seed"],c)}const f=A(e,["speechConfig"]);if(n!==undefined&&f!=null){I(n,["setup","generationConfig","speechConfig"],$n(f))}const d=A(e,["thinkingConfig"]);if(n!==undefined&&d!=null){I(n,["setup","generationConfig","thinkingConfig"],d)}const p=A(e,["enableAffectiveDialog"]);if(n!==undefined&&p!=null){I(n,["setup","generationConfig","enableAffectiveDialog"],p)}const h=A(e,["systemInstruction"]);if(n!==undefined&&h!=null){I(n,["setup","systemInstruction"],$l(Gn(h)))}const m=A(e,["tools"]);if(n!==undefined&&m!=null){let e=Vn(m);if(Array.isArray(e)){e=e.map((e=>eu(Jn(e))))}I(n,["setup","tools"],e)}const g=A(e,["sessionResumption"]);if(n!==undefined&&g!=null){I(n,["setup","sessionResumption"],Zl(g))}const y=A(e,["inputAudioTranscription"]);if(n!==undefined&&y!=null){I(n,["setup","inputAudioTranscription"],y)}const v=A(e,["outputAudioTranscription"]);if(n!==undefined&&v!=null){I(n,["setup","outputAudioTranscription"],v)}const E=A(e,["realtimeInputConfig"]);if(n!==undefined&&E!=null){I(n,["setup","realtimeInputConfig"],E)}const w=A(e,["contextWindowCompression"]);if(n!==undefined&&w!=null){I(n,["setup","contextWindowCompression"],w)}const b=A(e,["proactivity"]);if(n!==undefined&&b!=null){I(n,["setup","proactivity"],b)}if(A(e,["explicitVadSignal"])!==undefined){throw new Error("explicitVadSignal parameter is not supported in Gemini API.")}return t}function Xl(e,n){const t={};const i=A(n,["model"]);if(i!=null){I(t,["setup","model"],An(e,i))}const o=A(n,["config"]);if(o!=null){I(t,["config"],zl(o,t))}return t}function Ql(e){const n={};const t=A(e,["mediaResolution"]);if(t!=null){I(n,["mediaResolution"],t)}const i=A(e,["codeExecutionResult"]);if(i!=null){I(n,["codeExecutionResult"],i)}const o=A(e,["executableCode"]);if(o!=null){I(n,["executableCode"],o)}const r=A(e,["fileData"]);if(r!=null){I(n,["fileData"],Bl(r))}const s=A(e,["functionCall"]);if(s!=null){I(n,["functionCall"],Wl(s))}const l=A(e,["functionResponse"]);if(l!=null){I(n,["functionResponse"],l)}const u=A(e,["inlineData"]);if(u!=null){I(n,["inlineData"],Hl(u))}const a=A(e,["text"]);if(a!=null){I(n,["text"],a)}const c=A(e,["thought"]);if(c!=null){I(n,["thought"],c)}const f=A(e,["thoughtSignature"]);if(f!=null){I(n,["thoughtSignature"],f)}const d=A(e,["videoMetadata"]);if(d!=null){I(n,["videoMetadata"],d)}return n}function Zl(e){const n={};const t=A(e,["handle"]);if(t!=null){I(n,["handle"],t)}if(A(e,["transparent"])!==undefined){throw new Error("transparent parameter is not supported in Gemini API.")}return n}function eu(e){const n={};if(A(e,["retrieval"])!==undefined){throw new Error("retrieval parameter is not supported in Gemini API.")}const t=A(e,["computerUse"]);if(t!=null){I(n,["computerUse"],t)}const i=A(e,["fileSearch"]);if(i!=null){I(n,["fileSearch"],i)}const o=A(e,["googleSearch"]);if(o!=null){I(n,["googleSearch"],Kl(o))}const r=A(e,["codeExecution"]);if(r!=null){I(n,["codeExecution"],r)}if(A(e,["enterpriseWebSearch"])!==undefined){throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.")}const s=A(e,["functionDeclarations"]);if(s!=null){let e=s;if(Array.isArray(e)){e=e.map((e=>e))}I(n,["functionDeclarations"],e)}const l=A(e,["googleMaps"]);if(l!=null){I(n,["googleMaps"],Yl(l))}const u=A(e,["googleSearchRetrieval"]);if(u!=null){I(n,["googleSearchRetrieval"],u)}const a=A(e,["urlContext"]);if(a!=null){I(n,["urlContext"],a)}const c=A(e,["mcpServers"]);if(c!=null){let e=c;if(Array.isArray(e)){e=e.map((e=>e))}I(n,["mcpServers"],e)}return n}
|
|
132
|
+
/**
|
|
133
|
+
* @license
|
|
134
|
+
* Copyright 2025 Google LLC
|
|
135
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
136
|
+
*/function nu(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 tu(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=nu(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 iu extends T{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=Vl(this.apiClient,e);o=S("auth_tokens",s["_url"]);r=s["_query"];delete s["config"];delete s["_url"];delete s["_query"];const l=tu(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 ou(e,n){const t={};const i=A(e,["force"]);if(n!==undefined&&i!=null){I(n,["_query","force"],i)}return t}function ru(e){const n={};const t=A(e,["name"]);if(t!=null){I(n,["_url","name"],t)}const i=A(e,["config"]);if(i!=null){ou(i,n)}return n}function su(e){const n={};const t=A(e,["name"]);if(t!=null){I(n,["_url","name"],t)}return n}function lu(e,n){const t={};const i=A(e,["pageSize"]);if(n!==undefined&&i!=null){I(n,["_query","pageSize"],i)}const o=A(e,["pageToken"]);if(n!==undefined&&o!=null){I(n,["_query","pageToken"],o)}return t}function uu(e){const n={};const t=A(e,["parent"]);if(t!=null){I(n,["_url","parent"],t)}const i=A(e,["config"]);if(i!=null){lu(i,n)}return n}function au(e){const n={};const t=A(e,["sdkHttpResponse"]);if(t!=null){I(n,["sdkHttpResponse"],t)}const i=A(e,["nextPageToken"]);if(i!=null){I(n,["nextPageToken"],i)}const o=A(e,["documents"]);if(o!=null){let e=o;if(Array.isArray(e)){e=e.map((e=>e))}I(n,["documents"],e)}return n}
|
|
142
|
+
/**
|
|
143
|
+
* @license
|
|
144
|
+
* Copyright 2025 Google LLC
|
|
145
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
146
|
+
*/class cu extends T{constructor(e){super();this.apiClient=e;this.list=async e=>new li(si.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=su(e);o=S("{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=ru(e);i=S("{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=uu(e);o=S("{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=au(e);const t=new pn;Object.assign(t,n);return t}))}}}
|
|
147
|
+
/**
|
|
148
|
+
* @license
|
|
149
|
+
* Copyright 2025 Google LLC
|
|
150
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
151
|
+
*/class fu extends T{constructor(e,n=new cu(e)){super();this.apiClient=e;this.documents=n;this.list=async(e={})=>new li(si.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=Hs(e);o=S("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=Vs(e);o=S("{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=Js(e);i=S("{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=Xs(e);o=S("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=Qs(e);const t=new hn;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=el(e);o=S("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=nl(e);const t=new mn;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=Ys(e);o=S("{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=Ws(e);const t=new gn;Object.assign(t,n);return t}))}}}
|
|
152
|
+
/**
|
|
153
|
+
* @license
|
|
154
|
+
* Copyright 2025 Google LLC
|
|
155
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
156
|
+
*/let du=function(){const{crypto:e}=globalThis;if(e===null||e===void 0?void 0:e.randomUUID){du=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 pu=()=>du()
|
|
157
|
+
/**
|
|
158
|
+
* @license
|
|
159
|
+
* Copyright 2025 Google LLC
|
|
160
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
161
|
+
*/;function hu(e){return typeof e==="object"&&e!==null&&("name"in e&&e.name==="AbortError"||"message"in e&&String(e.message).includes("FetchRequestCanceledException"))}const mu=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 gu extends Error{}class yu extends gu{constructor(e,n,t,i){super(`${yu.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 Eu({message:t,cause:mu(n)})}const o=n;if(e===400){return new bu(e,o,t,i)}if(e===401){return new Tu(e,o,t,i)}if(e===403){return new Su(e,o,t,i)}if(e===404){return new Iu(e,o,t,i)}if(e===409){return new Au(e,o,t,i)}if(e===422){return new Ou(e,o,t,i)}if(e===429){return new Cu(e,o,t,i)}if(e>=500){return new _u(e,o,t,i)}return new yu(e,o,t,i)}}class vu extends yu{constructor({message:e}={}){super(undefined,undefined,e||"Request was aborted.",undefined)}}class Eu extends yu{constructor({message:e,cause:n}){super(undefined,undefined,e||"Connection error.",undefined);if(n)this.cause=n}}class wu extends Eu{constructor({message:e}={}){super({message:e!==null&&e!==void 0?e:"Request timed out."})}}class bu extends yu{}class Tu extends yu{}class Su extends yu{}class Iu extends yu{}class Au extends yu{}class Ou extends yu{}class Cu extends yu{}class _u extends yu{}
|
|
167
|
+
/**
|
|
168
|
+
* @license
|
|
169
|
+
* Copyright 2025 Google LLC
|
|
170
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
171
|
+
*/const Pu=/^[a-z][a-z0-9+.-]*:/i;const Ru=e=>Pu.test(e);let Nu=e=>(Nu=Array.isArray,Nu(e));const Mu=Nu;let Du=Mu;const Uu=Du;function ku(e){if(!e)return true;for(const n in e)return false;return true}function Gu(e,n){return Object.prototype.hasOwnProperty.call(e,n)}const xu=(e,n)=>{if(typeof n!=="number"||!Number.isInteger(n)){throw new gu(`${e} must be an integer`)}if(n<0){throw new gu(`${e} must be a positive integer`)}return n};const Lu=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 ju=e=>new Promise((n=>setTimeout(n,e)))
|
|
177
|
+
/**
|
|
178
|
+
* @license
|
|
179
|
+
* Copyright 2025 Google LLC
|
|
180
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
181
|
+
*/;const Fu="0.0.1";
|
|
182
|
+
/**
|
|
183
|
+
* @license
|
|
184
|
+
* Copyright 2025 Google LLC
|
|
185
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
186
|
+
*/function qu(){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 Hu=()=>{var e,n,t,i,o;const r=qu();if(r==="deno"){return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Fu,"X-Stainless-OS":Vu(Deno.build.os),"X-Stainless-Arch":Ju(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":Fu,"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":Fu,"X-Stainless-OS":Vu((t=globalThis.process.platform)!==null&&t!==void 0?t:"unknown"),"X-Stainless-Arch":Ju((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=$u();if(s){return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Fu,"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":Fu,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function $u(){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 Ju=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 Vu=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 Bu;const Wu=()=>Bu!==null&&Bu!==void 0?Bu:Bu=Hu();
|
|
187
|
+
/**
|
|
188
|
+
* @license
|
|
189
|
+
* Copyright 2025 Google LLC
|
|
190
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
191
|
+
*/function Yu(){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 Ku(...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 zu(e){let n=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return Ku({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 Xu(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 Qu(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 Zu=({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 ea=()=>{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 na(e,n,t){ea();return new File(e,n!==null&&n!==void 0?n:"unknown_file",t)}function ta(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 ia=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 oa=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 ra=e=>e!=null&&typeof e==="object"&&typeof e.name==="string"&&typeof e.lastModified==="number"&&oa(e);const sa=e=>e!=null&&typeof e==="object"&&typeof e.url==="string"&&typeof e.blob==="function";async function la(e,n,t){ea();e=await e;if(ra(e)){if(e instanceof File){return e}return na([await e.arrayBuffer()],e.name)}if(sa(e)){const i=await e.blob();n||(n=new URL(e.url).pathname.split(/[\\/]/).pop());return na(await ua(i),n,t)}const i=await ua(e);n||(n=ta(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 na(i,n,t)}async function ua(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(oa(e)){s.push(e instanceof Blob?e:await e.arrayBuffer())}else if(ia(e)){try{for(var l=true,u=Bi(e),a;a=await u.next(),n=a.done,!n;l=true){o=a.value;l=false;const e=o;s.push(...await ua(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}`:""}${aa(e)}`)}return s}function aa(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 ca{constructor(e){this._client=e}}ca._key=[];
|
|
212
|
+
/**
|
|
213
|
+
* @license
|
|
214
|
+
* Copyright 2025 Google LLC
|
|
215
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
216
|
+
*/function fa(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}const da=Object.freeze(Object.create(null));const pa=(e=fa)=>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:da))!==null&&u!==void 0?u:da))===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 gu(`Path parameters result in path with invalid segments:\n${r.map((e=>e.error)).join("\n")}\n${n}\n${t}`)}return n};const ha=pa(fa);
|
|
217
|
+
/**
|
|
218
|
+
* @license
|
|
219
|
+
* Copyright 2025 Google LLC
|
|
220
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
221
|
+
*/class ma extends ca{create(e,n){var t;const{api_version:i=this._client.apiVersion}=e,o=Hi(e,["api_version"]);if("model"in o&&"agent_config"in o){throw new gu(`Invalid request: specified \`model\` and \`agent_config\`. If specifying \`model\`, use \`generation_config\`.`)}if("agent"in o&&"generation_config"in o){throw new gu(`Invalid request: specified \`agent\` and \`generation_config\`. If specifying \`agent\`, use \`agent_config\`.`)}return this._client.post(ha`/${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(ha`/${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(ha`/${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=Hi(o,["api_version"]);return this._client.get(ha`/${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}))}}ma._key=Object.freeze(["interactions"]);class ga extends ma{}
|
|
222
|
+
/**
|
|
223
|
+
* @license
|
|
224
|
+
* Copyright 2025 Google LLC
|
|
225
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
226
|
+
*/function ya(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 va;function Ea(e){let n;return(va!==null&&va!==void 0?va:(n=new globalThis.TextEncoder,va=n.encode.bind(n)))(e)}let wa;function ba(e){let n;return(wa!==null&&wa!==void 0?wa:(n=new globalThis.TextDecoder,wa=n.decode.bind(n)))(e)}
|
|
227
|
+
/**
|
|
228
|
+
* @license
|
|
229
|
+
* Copyright 2025 Google LLC
|
|
230
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
231
|
+
*/class Ta{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"?Ea(e):e;this.buffer=ya([this.buffer,n]);const t=[];let i;while((i=Sa(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(ba(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=ba(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")}}Ta.NEWLINE_CHARS=new Set(["\n","\r"]);Ta.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function Sa(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 Ia(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 Aa={off:0,error:200,warn:300,info:400,debug:500};const Oa=(e,n,t)=>{if(!e){return undefined}if(Gu(Aa,e)){return e}Na(t).warn(`${n} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(Aa))}`);return undefined};function Ca(){}function _a(e,n,t){if(!n||Aa[e]>Aa[t]){return Ca}else{return n[e].bind(n)}}const Pa={error:Ca,warn:Ca,info:Ca,debug:Ca};let Ra=new WeakMap;function Na(e){var n;const t=e.logger;const i=(n=e.logLevel)!==null&&n!==void 0?n:"off";if(!t){return Pa}const o=Ra.get(t);if(o&&o[0]===i){return o[1]}const r={error:_a("error",t,i),warn:_a("warn",t,i),info:_a("info",t,i),debug:_a("debug",t,i)};Ra.set(t,[i,r]);return r}const Ma=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 Da{constructor(e,n,t){this.iterator=e;this.controller=n;this.client=t}static fromSSEResponse(e,n,t){let i=false;const o=t?Na(t):console;function r(){return Vi(this,arguments,(function*t(){var r,s,l,u;if(i){throw new gu("Cannot iterate over a consumed stream, use `.tee()` to split the stream.")}i=true;let a=false;try{try{for(var c=true,f=Bi(Ua(e,n)),d;d=yield Ji(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 Ji(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 Ji(l.call(f))}finally{if(s)throw s.error}}a=true}catch(e){if(hu(e))return yield Ji(void 0);throw e}finally{if(!a)n.abort()}}))}return new Da(r,n,t)}static fromReadableStream(e,n,t){let i=false;function o(){return Vi(this,arguments,(function*n(){var t,i,o,r;const s=new Ta;const l=Xu(e);try{for(var u=true,a=Bi(l),c;c=yield Ji(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 Ji(n)}}}catch(e){i={error:e}}finally{try{if(!u&&!t&&(o=a.return))yield Ji(o.call(a))}finally{if(i)throw i.error}}for(const e of s.flush()){yield yield Ji(e)}}))}function r(){return Vi(this,arguments,(function*e(){var t,r,s,l;if(i){throw new gu("Cannot iterate over a consumed stream, use `.tee()` to split the stream.")}i=true;let u=false;try{try{for(var a=true,c=Bi(o()),f;f=yield Ji(c.next()),t=f.done,!t;a=true){l=f.value;a=false;const e=l;if(u)continue;if(e)yield yield Ji(JSON.parse(e))}}catch(e){r={error:e}}finally{try{if(!a&&!t&&(s=c.return))yield Ji(s.call(c))}finally{if(r)throw r.error}}u=true}catch(e){if(hu(e))return yield Ji(void 0);throw e}finally{if(!u)n.abort()}}))}return new Da(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 Da((()=>i(e)),this.controller,this.client),new Da((()=>i(n)),this.controller,this.client)]}toReadableStream(){const e=this;let n;return Ku({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=Ea(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 Ua(e,n){return Vi(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 gu(`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 gu(`Attempted to iterate over a response with no body`)}const l=new Ga;const u=new Ta;const a=Xu(e.body);try{for(var c=true,f=Bi(ka(a)),d;d=yield Ji(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 Ji(e)}}}catch(e){o={error:e}}finally{try{if(!c&&!i&&(r=f.return))yield Ji(r.call(f))}finally{if(o)throw o.error}}for(const e of u.flush()){const n=l.decode(e);if(n)yield yield Ji(n)}}))}function ka(e){return Vi(this,arguments,(function*n(){var t,i,o,r;let s=new Uint8Array;try{for(var l=true,u=Bi(e),a;a=yield Ji(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"?Ea(e):e;let t=new Uint8Array(s.length+n.length);t.set(s);t.set(n,s.length);s=t;let i;while((i=Ia(s))!==-1){yield yield Ji(s.slice(0,i));s=s.slice(i)}}}catch(e){i={error:e}}finally{try{if(!l&&!t&&(o=u.return))yield Ji(o.call(u))}finally{if(i)throw i.error}}if(s.length>0){yield yield Ji(s)}}))}class Ga{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]=xa(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 xa(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 La(e,n){const{response:t,requestLogID:i,retryOfRequestLogID:o,startTime:r}=n;const s=await(async()=>{var i;if(n.options.stream){Na(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 Da.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})();Na(e).debug(`[${i}] response parsed`,Ma({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 ja extends Promise{constructor(e,n,t=La){super((e=>{e(null)}));this.responsePromise=n;this.parseResponse=t;this.client=e}_thenUnwrap(e){return new ja(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 Fa=Symbol("brand.privateNullableHeaders");function*qa(e){if(!e)return;if(Fa 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(Uu(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=Uu(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 Ha=e=>{const n=new Headers;const t=new Set;for(const i of e){const e=new Set;for(const[o,r]of qa(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{[Fa]:true,values:n,nulls:t}};
|
|
257
|
+
/**
|
|
258
|
+
* @license
|
|
259
|
+
* Copyright 2025 Google LLC
|
|
260
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
261
|
+
*/const $a=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 Ja;class Va{constructor(e){var n,t,i,o,r,s,l;var{baseURL:u=$a("GEMINI_NEXT_GEN_API_BASE_URL"),apiKey:a=((n=$a("GEMINI_API_KEY"))!==null&&n!==void 0?n:null),apiVersion:c="v1beta"}=e,f=Hi(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:Va.DEFAULT_TIMEOUT;this.logger=(i=d.logger)!==null&&i!==void 0?i:console;const p="warn";this.logLevel=p;this.logLevel=(r=(o=Oa(d.logLevel,"ClientOptions.logLevel",this))!==null&&o!==void 0?o:Oa($a("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:Yu();this.encoder=Zu;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=Ha([e.headers]);if(n.values.has("authorization")||n.values.has("x-goog-api-key")){return undefined}if(this.apiKey){return Ha([{"x-goog-api-key":this.apiKey}])}if(this.clientAdapter.isVertexAI()){return Ha([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 gu(`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 ${Fu}`}defaultIdempotencyKey(){return`stainless-node-retry-${pu()}`}makeStatusError(e,n,t,i){return yu.generate(e,n,t,i)}buildURL(e,n,t){const i=!this.baseURLOverridden()&&t||this.baseURL;const o=Ru(e)?new URL(e):new URL(i+(i.endsWith("/")&&e.startsWith("/")?e.slice(1):e));const r=this.defaultQuery();if(!ku(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 ja(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();Na(this).debug(`[${f}] sending request`,Ma({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 vu}const h=new AbortController;const m=await this.fetchWithTimeout(a,u,c,h).catch(mu);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 vu}const i=hu(m)||/timed? ?out/i.test(String(m)+("cause"in m?String(m.cause):""));if(n){Na(this).info(`[${f}] connection ${i?"timed out":"failed"} - ${e}`);Na(this).debug(`[${f}] connection ${i?"timed out":"failed"} (${e})`,Ma({retryOfRequestLogID:t,url:a,durationMs:g-p,message:m.message}));return this.retryRequest(s,n,t!==null&&t!==void 0?t:f)}Na(this).info(`[${f}] connection ${i?"timed out":"failed"} - error; no more retries left`);Na(this).debug(`[${f}] connection ${i?"timed out":"failed"} (error; no more retries left)`,Ma({retryOfRequestLogID:t,url:a,durationMs:g-p,message:m.message}));if(i){throw new wu}throw new Eu({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 Qu(m.body);Na(this).info(`${y} - ${e}`);Na(this).debug(`[${f}] response error (${e})`,Ma({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`;Na(this).info(`${y} - ${i}`);const o=await m.text().catch((e=>mu(e).message));const r=Lu(o);const l=r?undefined:o;Na(this).debug(`[${f}] response error (${i})`,Ma({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}Na(this).info(y);Na(this).debug(`[${f}] response start`,Ma({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=Hi(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 ju(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)xu("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=Ha([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))}:{}),Wu()),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=Ha([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:zu(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})}}}Va.DEFAULT_TIMEOUT=6e4;class Ba extends Va{constructor(){super(...arguments);this.interactions=new ga(this)}}Ja=Ba;Ba.GeminiNextGenAPIClient=Ja;Ba.GeminiNextGenAPIClientError=gu;Ba.APIError=yu;Ba.APIConnectionError=Eu;Ba.APIConnectionTimeoutError=wu;Ba.APIUserAbortError=vu;Ba.NotFoundError=Iu;Ba.ConflictError=Au;Ba.RateLimitError=Cu;Ba.BadRequestError=bu;Ba.AuthenticationError=Tu;Ba.InternalServerError=_u;Ba.PermissionDeniedError=Su;Ba.UnprocessableEntityError=Ou;Ba.toFile=la;Ba.Interactions=ga;
|
|
267
|
+
/**
|
|
268
|
+
* @license
|
|
269
|
+
* Copyright 2025 Google LLC
|
|
270
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
271
|
+
*/function Wa(e,n){const t={};const i=A(e,["name"]);if(i!=null){I(t,["_url","name"],i)}return t}function Ya(e,n){const t={};const i=A(e,["name"]);if(i!=null){I(t,["_url","name"],i)}return t}function Ka(e,n){const t={};const i=A(e,["sdkHttpResponse"]);if(i!=null){I(t,["sdkHttpResponse"],i)}return t}function za(e,n){const t={};const i=A(e,["sdkHttpResponse"]);if(i!=null){I(t,["sdkHttpResponse"],i)}return t}function Xa(e,n,t){const i={};if(A(e,["validationDataset"])!==undefined){throw new Error("validationDataset parameter is not supported in Gemini API.")}const o=A(e,["tunedModelDisplayName"]);if(n!==undefined&&o!=null){I(n,["displayName"],o)}if(A(e,["description"])!==undefined){throw new Error("description parameter is not supported in Gemini API.")}const r=A(e,["epochCount"]);if(n!==undefined&&r!=null){I(n,["tuningTask","hyperparameters","epochCount"],r)}const s=A(e,["learningRateMultiplier"]);if(s!=null){I(i,["tuningTask","hyperparameters","learningRateMultiplier"],s)}if(A(e,["exportLastCheckpointOnly"])!==undefined){throw new Error("exportLastCheckpointOnly parameter is not supported in Gemini API.")}if(A(e,["preTunedModelCheckpointId"])!==undefined){throw new Error("preTunedModelCheckpointId parameter is not supported in Gemini API.")}if(A(e,["adapterSize"])!==undefined){throw new Error("adapterSize parameter is not supported in Gemini API.")}if(A(e,["tuningMode"])!==undefined){throw new Error("tuningMode parameter is not supported in Gemini API.")}if(A(e,["customBaseModel"])!==undefined){throw new Error("customBaseModel parameter is not supported in Gemini API.")}const l=A(e,["batchSize"]);if(n!==undefined&&l!=null){I(n,["tuningTask","hyperparameters","batchSize"],l)}const u=A(e,["learningRate"]);if(n!==undefined&&u!=null){I(n,["tuningTask","hyperparameters","learningRate"],u)}if(A(e,["labels"])!==undefined){throw new Error("labels parameter is not supported in Gemini API.")}if(A(e,["beta"])!==undefined){throw new Error("beta parameter is not supported in Gemini API.")}if(A(e,["baseTeacherModel"])!==undefined){throw new Error("baseTeacherModel parameter is not supported in Gemini API.")}if(A(e,["tunedTeacherModelSource"])!==undefined){throw new Error("tunedTeacherModelSource parameter is not supported in Gemini API.")}if(A(e,["sftLossWeightMultiplier"])!==undefined){throw new Error("sftLossWeightMultiplier parameter is not supported in Gemini API.")}if(A(e,["outputUri"])!==undefined){throw new Error("outputUri parameter is not supported in Gemini API.")}if(A(e,["encryptionSpec"])!==undefined){throw new Error("encryptionSpec parameter is not supported in Gemini API.")}return i}function Qa(e,n,t){const i={};let o=A(t,["config","method"]);if(o===undefined){o="SUPERVISED_FINE_TUNING"}if(o==="SUPERVISED_FINE_TUNING"){const t=A(e,["validationDataset"]);if(n!==undefined&&t!=null){I(n,["supervisedTuningSpec"],mc(t))}}else if(o==="PREFERENCE_TUNING"){const t=A(e,["validationDataset"]);if(n!==undefined&&t!=null){I(n,["preferenceOptimizationSpec"],mc(t))}}else if(o==="DISTILLATION"){const t=A(e,["validationDataset"]);if(n!==undefined&&t!=null){I(n,["distillationSpec"],mc(t))}}const r=A(e,["tunedModelDisplayName"]);if(n!==undefined&&r!=null){I(n,["tunedModelDisplayName"],r)}const s=A(e,["description"]);if(n!==undefined&&s!=null){I(n,["description"],s)}let l=A(t,["config","method"]);if(l===undefined){l="SUPERVISED_FINE_TUNING"}if(l==="SUPERVISED_FINE_TUNING"){const t=A(e,["epochCount"]);if(n!==undefined&&t!=null){I(n,["supervisedTuningSpec","hyperParameters","epochCount"],t)}}else if(l==="PREFERENCE_TUNING"){const t=A(e,["epochCount"]);if(n!==undefined&&t!=null){I(n,["preferenceOptimizationSpec","hyperParameters","epochCount"],t)}}else if(l==="DISTILLATION"){const t=A(e,["epochCount"]);if(n!==undefined&&t!=null){I(n,["distillationSpec","hyperParameters","epochCount"],t)}}let u=A(t,["config","method"]);if(u===undefined){u="SUPERVISED_FINE_TUNING"}if(u==="SUPERVISED_FINE_TUNING"){const t=A(e,["learningRateMultiplier"]);if(n!==undefined&&t!=null){I(n,["supervisedTuningSpec","hyperParameters","learningRateMultiplier"],t)}}else if(u==="PREFERENCE_TUNING"){const t=A(e,["learningRateMultiplier"]);if(n!==undefined&&t!=null){I(n,["preferenceOptimizationSpec","hyperParameters","learningRateMultiplier"],t)}}else if(u==="DISTILLATION"){const t=A(e,["learningRateMultiplier"]);if(n!==undefined&&t!=null){I(n,["distillationSpec","hyperParameters","learningRateMultiplier"],t)}}let a=A(t,["config","method"]);if(a===undefined){a="SUPERVISED_FINE_TUNING"}if(a==="SUPERVISED_FINE_TUNING"){const t=A(e,["exportLastCheckpointOnly"]);if(n!==undefined&&t!=null){I(n,["supervisedTuningSpec","exportLastCheckpointOnly"],t)}}else if(a==="PREFERENCE_TUNING"){const t=A(e,["exportLastCheckpointOnly"]);if(n!==undefined&&t!=null){I(n,["preferenceOptimizationSpec","exportLastCheckpointOnly"],t)}}else if(a==="DISTILLATION"){const t=A(e,["exportLastCheckpointOnly"]);if(n!==undefined&&t!=null){I(n,["distillationSpec","exportLastCheckpointOnly"],t)}}let c=A(t,["config","method"]);if(c===undefined){c="SUPERVISED_FINE_TUNING"}if(c==="SUPERVISED_FINE_TUNING"){const t=A(e,["adapterSize"]);if(n!==undefined&&t!=null){I(n,["supervisedTuningSpec","hyperParameters","adapterSize"],t)}}else if(c==="PREFERENCE_TUNING"){const t=A(e,["adapterSize"]);if(n!==undefined&&t!=null){I(n,["preferenceOptimizationSpec","hyperParameters","adapterSize"],t)}}else if(c==="DISTILLATION"){const t=A(e,["adapterSize"]);if(n!==undefined&&t!=null){I(n,["distillationSpec","hyperParameters","adapterSize"],t)}}let f=A(t,["config","method"]);if(f===undefined){f="SUPERVISED_FINE_TUNING"}if(f==="SUPERVISED_FINE_TUNING"){const t=A(e,["tuningMode"]);if(n!==undefined&&t!=null){I(n,["supervisedTuningSpec","tuningMode"],t)}}const d=A(e,["customBaseModel"]);if(n!==undefined&&d!=null){I(n,["customBaseModel"],d)}let p=A(t,["config","method"]);if(p===undefined){p="SUPERVISED_FINE_TUNING"}if(p==="SUPERVISED_FINE_TUNING"){const t=A(e,["batchSize"]);if(n!==undefined&&t!=null){I(n,["supervisedTuningSpec","hyperParameters","batchSize"],t)}}let h=A(t,["config","method"]);if(h===undefined){h="SUPERVISED_FINE_TUNING"}if(h==="SUPERVISED_FINE_TUNING"){const t=A(e,["learningRate"]);if(n!==undefined&&t!=null){I(n,["supervisedTuningSpec","hyperParameters","learningRate"],t)}}const m=A(e,["labels"]);if(n!==undefined&&m!=null){I(n,["labels"],m)}const g=A(e,["beta"]);if(n!==undefined&&g!=null){I(n,["preferenceOptimizationSpec","hyperParameters","beta"],g)}const y=A(e,["baseTeacherModel"]);if(n!==undefined&&y!=null){I(n,["distillationSpec","baseTeacherModel"],y)}const v=A(e,["tunedTeacherModelSource"]);if(n!==undefined&&v!=null){I(n,["distillationSpec","tunedTeacherModelSource"],v)}const E=A(e,["sftLossWeightMultiplier"]);if(n!==undefined&&E!=null){I(n,["distillationSpec","hyperParameters","sftLossWeightMultiplier"],E)}const w=A(e,["outputUri"]);if(n!==undefined&&w!=null){I(n,["outputUri"],w)}const b=A(e,["encryptionSpec"]);if(n!==undefined&&b!=null){I(n,["encryptionSpec"],b)}return i}function Za(e,n){const t={};const i=A(e,["baseModel"]);if(i!=null){I(t,["baseModel"],i)}const o=A(e,["preTunedModel"]);if(o!=null){I(t,["preTunedModel"],o)}const r=A(e,["trainingDataset"]);if(r!=null){cc(r)}const s=A(e,["config"]);if(s!=null){Xa(s,t)}return t}function ec(e,n){const t={};const i=A(e,["baseModel"]);if(i!=null){I(t,["baseModel"],i)}const o=A(e,["preTunedModel"]);if(o!=null){I(t,["preTunedModel"],o)}const r=A(e,["trainingDataset"]);if(r!=null){fc(r,t,n)}const s=A(e,["config"]);if(s!=null){Qa(s,t,n)}return t}function nc(e,n){const t={};const i=A(e,["name"]);if(i!=null){I(t,["_url","name"],i)}return t}function tc(e,n){const t={};const i=A(e,["name"]);if(i!=null){I(t,["_url","name"],i)}return t}function ic(e,n,t){const i={};const o=A(e,["pageSize"]);if(n!==undefined&&o!=null){I(n,["_query","pageSize"],o)}const r=A(e,["pageToken"]);if(n!==undefined&&r!=null){I(n,["_query","pageToken"],r)}const s=A(e,["filter"]);if(n!==undefined&&s!=null){I(n,["_query","filter"],s)}return i}function oc(e,n,t){const i={};const o=A(e,["pageSize"]);if(n!==undefined&&o!=null){I(n,["_query","pageSize"],o)}const r=A(e,["pageToken"]);if(n!==undefined&&r!=null){I(n,["_query","pageToken"],r)}const s=A(e,["filter"]);if(n!==undefined&&s!=null){I(n,["_query","filter"],s)}return i}function rc(e,n){const t={};const i=A(e,["config"]);if(i!=null){ic(i,t)}return t}function sc(e,n){const t={};const i=A(e,["config"]);if(i!=null){oc(i,t)}return t}function lc(e,n){const t={};const i=A(e,["sdkHttpResponse"]);if(i!=null){I(t,["sdkHttpResponse"],i)}const o=A(e,["nextPageToken"]);if(o!=null){I(t,["nextPageToken"],o)}const r=A(e,["tunedModels"]);if(r!=null){let e=r;if(Array.isArray(e)){e=e.map((e=>dc(e)))}I(t,["tuningJobs"],e)}return t}function uc(e,n){const t={};const i=A(e,["sdkHttpResponse"]);if(i!=null){I(t,["sdkHttpResponse"],i)}const o=A(e,["nextPageToken"]);if(o!=null){I(t,["nextPageToken"],o)}const r=A(e,["tuningJobs"]);if(r!=null){let e=r;if(Array.isArray(e)){e=e.map((e=>pc(e)))}I(t,["tuningJobs"],e)}return t}function ac(e,n){const t={};const i=A(e,["name"]);if(i!=null){I(t,["model"],i)}const o=A(e,["name"]);if(o!=null){I(t,["endpoint"],o)}return t}function cc(e,n){const t={};if(A(e,["gcsUri"])!==undefined){throw new Error("gcsUri parameter is not supported in Gemini API.")}if(A(e,["vertexDatasetResource"])!==undefined){throw new Error("vertexDatasetResource parameter is not supported in Gemini API.")}const i=A(e,["examples"]);if(i!=null){let e=i;if(Array.isArray(e)){e=e.map((e=>e))}I(t,["examples","examples"],e)}return t}function fc(e,n,t){const i={};let o=A(t,["config","method"]);if(o===undefined){o="SUPERVISED_FINE_TUNING"}if(o==="SUPERVISED_FINE_TUNING"){const t=A(e,["gcsUri"]);if(n!==undefined&&t!=null){I(n,["supervisedTuningSpec","trainingDatasetUri"],t)}}else if(o==="PREFERENCE_TUNING"){const t=A(e,["gcsUri"]);if(n!==undefined&&t!=null){I(n,["preferenceOptimizationSpec","trainingDatasetUri"],t)}}else if(o==="DISTILLATION"){const t=A(e,["gcsUri"]);if(n!==undefined&&t!=null){I(n,["distillationSpec","promptDatasetUri"],t)}}let r=A(t,["config","method"]);if(r===undefined){r="SUPERVISED_FINE_TUNING"}if(r==="SUPERVISED_FINE_TUNING"){const t=A(e,["vertexDatasetResource"]);if(n!==undefined&&t!=null){I(n,["supervisedTuningSpec","trainingDatasetUri"],t)}}else if(r==="PREFERENCE_TUNING"){const t=A(e,["vertexDatasetResource"]);if(n!==undefined&&t!=null){I(n,["preferenceOptimizationSpec","trainingDatasetUri"],t)}}else if(r==="DISTILLATION"){const t=A(e,["vertexDatasetResource"]);if(n!==undefined&&t!=null){I(n,["distillationSpec","promptDatasetUri"],t)}}if(A(e,["examples"])!==undefined){throw new Error("examples parameter is not supported in Vertex AI.")}return i}function dc(e,n){const t={};const i=A(e,["sdkHttpResponse"]);if(i!=null){I(t,["sdkHttpResponse"],i)}const o=A(e,["name"]);if(o!=null){I(t,["name"],o)}const r=A(e,["state"]);if(r!=null){I(t,["state"],Yn(r))}const s=A(e,["createTime"]);if(s!=null){I(t,["createTime"],s)}const l=A(e,["tuningTask","startTime"]);if(l!=null){I(t,["startTime"],l)}const u=A(e,["tuningTask","completeTime"]);if(u!=null){I(t,["endTime"],u)}const a=A(e,["updateTime"]);if(a!=null){I(t,["updateTime"],a)}const c=A(e,["description"]);if(c!=null){I(t,["description"],c)}const f=A(e,["baseModel"]);if(f!=null){I(t,["baseModel"],f)}const d=A(e,["_self"]);if(d!=null){I(t,["tunedModel"],ac(d))}return t}function pc(e,n){const t={};const i=A(e,["sdkHttpResponse"]);if(i!=null){I(t,["sdkHttpResponse"],i)}const o=A(e,["name"]);if(o!=null){I(t,["name"],o)}const r=A(e,["state"]);if(r!=null){I(t,["state"],Yn(r))}const s=A(e,["createTime"]);if(s!=null){I(t,["createTime"],s)}const l=A(e,["startTime"]);if(l!=null){I(t,["startTime"],l)}const u=A(e,["endTime"]);if(u!=null){I(t,["endTime"],u)}const a=A(e,["updateTime"]);if(a!=null){I(t,["updateTime"],a)}const c=A(e,["error"]);if(c!=null){I(t,["error"],c)}const f=A(e,["description"]);if(f!=null){I(t,["description"],f)}const d=A(e,["baseModel"]);if(d!=null){I(t,["baseModel"],d)}const p=A(e,["tunedModel"]);if(p!=null){I(t,["tunedModel"],p)}const h=A(e,["preTunedModel"]);if(h!=null){I(t,["preTunedModel"],h)}const m=A(e,["supervisedTuningSpec"]);if(m!=null){I(t,["supervisedTuningSpec"],m)}const g=A(e,["preferenceOptimizationSpec"]);if(g!=null){I(t,["preferenceOptimizationSpec"],g)}const y=A(e,["distillationSpec"]);if(y!=null){I(t,["distillationSpec"],y)}const v=A(e,["tuningDataStats"]);if(v!=null){I(t,["tuningDataStats"],v)}const E=A(e,["encryptionSpec"]);if(E!=null){I(t,["encryptionSpec"],E)}const w=A(e,["partnerModelTuningSpec"]);if(w!=null){I(t,["partnerModelTuningSpec"],w)}const b=A(e,["customBaseModel"]);if(b!=null){I(t,["customBaseModel"],b)}const T=A(e,["experiment"]);if(T!=null){I(t,["experiment"],T)}const S=A(e,["labels"]);if(S!=null){I(t,["labels"],S)}const O=A(e,["outputUri"]);if(O!=null){I(t,["outputUri"],O)}const C=A(e,["pipelineJob"]);if(C!=null){I(t,["pipelineJob"],C)}const _=A(e,["serviceAccount"]);if(_!=null){I(t,["serviceAccount"],_)}const P=A(e,["tunedModelDisplayName"]);if(P!=null){I(t,["tunedModelDisplayName"],P)}const R=A(e,["veoTuningSpec"]);if(R!=null){I(t,["veoTuningSpec"],R)}return t}function hc(e,n){const t={};const i=A(e,["sdkHttpResponse"]);if(i!=null){I(t,["sdkHttpResponse"],i)}const o=A(e,["name"]);if(o!=null){I(t,["name"],o)}const r=A(e,["metadata"]);if(r!=null){I(t,["metadata"],r)}const s=A(e,["done"]);if(s!=null){I(t,["done"],s)}const l=A(e,["error"]);if(l!=null){I(t,["error"],l)}return t}function mc(e,n){const t={};const i=A(e,["gcsUri"]);if(i!=null){I(t,["validationDatasetUri"],i)}const o=A(e,["vertexDatasetResource"]);if(o!=null){I(t,["validationDatasetUri"],o)}return t}
|
|
272
|
+
/**
|
|
273
|
+
* @license
|
|
274
|
+
* Copyright 2025 Google LLC
|
|
275
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
276
|
+
*/class gc extends T{constructor(e){super();this.apiClient=e;this.list=async(e={})=>new li(si.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:me.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=tc(e);s=S("{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=pc(e);return n}))}else{const n=nc(e);s=S("{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=dc(e);return n}))}}async listInternal(e){var n,t,i,o;let r;let s="";let l={};if(this.apiClient.isVertexAI()){const i=sc(e);s=S("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=uc(e);const t=new an;Object.assign(t,n);return t}))}else{const n=rc(e);s=S("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=lc(e);const t=new an;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=Ya(e);s=S("{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=za(e);const t=new cn;Object.assign(t,n);return t}))}else{const n=Wa(e);s=S("{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=Ka(e);const t=new cn;Object.assign(t,n);return t}))}}async tuneInternal(e){var n,t;let i;let o="";let r={};if(this.apiClient.isVertexAI()){const s=ec(e,e);o=S("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=pc(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=Za(e);o=S("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=hc(e);return n}))}}}
|
|
277
|
+
/**
|
|
278
|
+
* @license
|
|
279
|
+
* Copyright 2025 Google LLC
|
|
280
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
281
|
+
*/class yc{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 vc=1024*1024*8;const Ec=3;const wc=1e3;const bc=2;const Tc="x-goog-upload-status";async function Sc(e,n,t){var i;const o=await Ac(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[Tc])!=="final"){throw new Error("Failed to upload file: Upload status is not finalized.")}return r["file"]}async function Ic(e,n,t){var i;const o=await Ac(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[Tc])!=="final"){throw new Error("Failed to upload file: Upload status is not finalized.")}const s=F(r);const l=new In;Object.assign(l,s);return l}async function Ac(e,n,t){var i,o;let r=0;let s=0;let l=new Ke(new Response);let u="upload";r=e.size;while(s<r){const a=Math.min(vc,r-s);const c=e.slice(s,s+a);if(s+a>=r){u+=", finalize"}let f=0;let d=wc;while(f<Ec){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[Tc]){break}f++;await Cc(d);d=d*bc}s+=a;if(((o=l===null||l===void 0?void 0:l.headers)===null||o===void 0?void 0:o[Tc])!=="active"){break}if(r<=s){throw new Error("All content has been uploaded, but the upload status is not finalized.")}}return l}async function Oc(e){const n={size:e.size,type:e.type};return n}function Cc(e){return new Promise((n=>setTimeout(n,e)))}class _c{async upload(e,n,t){if(typeof e==="string"){throw new Error("File path is not supported in browser uploader.")}return await Sc(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 Ic(e,n,t)}async stat(e){if(typeof e==="string"){throw new Error("File path is not supported in browser uploader.")}else{return await Oc(e)}}}
|
|
282
|
+
/**
|
|
283
|
+
* @license
|
|
284
|
+
* Copyright 2025 Google LLC
|
|
285
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
286
|
+
*/class Pc{create(e,n,t){return new Rc(e,n,t)}}class Rc{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 Nc="x-goog-api-key";class Mc{constructor(e){this.apiKey=e}async addAuthHeaders(e,n){if(e.get(Nc)!==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(Nc,this.apiKey)}}
|
|
292
|
+
/**
|
|
293
|
+
* @license
|
|
294
|
+
* Copyright 2025 Google LLC
|
|
295
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
296
|
+
*/const Dc="gl-node/";class Uc{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 Ba({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=b(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 Mc(this.apiKey);this.apiClient=new dl({auth:i,apiVersion:this.apiVersion,apiKey:this.apiKey,vertexai:this.vertexai,httpOptions:this.httpOptions,userAgentExtra:Dc+"web",uploader:new _c,downloader:new yc});this.models=new Fl(this.apiClient);this.live=new Pl(this.apiClient,i,new Pc);this.batches=new ui(this.apiClient);this.chats=new Xi(this.models,this.apiClient);this.caches=new qi(this.apiClient);this.files=new co(this.apiClient);this.operations=new ql(this.apiClient);this.authTokens=new iu(this.apiClient);this.tunings=new gc(this.apiClient);this.fileSearchStores=new fu(this.apiClient)}}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,t)=>{if(!t)return;e.__stencil__getHostRef=()=>t;t.l=e;if(t.t.u&512&&n.state){Gc(e,t)}};var jc=(e,n)=>{const t={u:0,$hostElement$:e,t:n,o:new Map,p:new Map};{t.h=new Promise((e=>t.m=e))}{t.T=new Promise((e=>t.S=e));e["s-p"]=[];e["s-rc"]=[]}{t.I=[]}const i=t;e.__stencil__getHostRef=()=>i;return i};var Fc=(e,n)=>n in e;var qc=(e,n)=>(0,console.error)(e,n);var Hc=new Map;var $c=(e,n,t)=>{const i=e.A.replace(/-/g,"_");const o=e.O;if(!o){return void 0}const r=Hc.get(o);if(r){return r[i]}
|
|
297
|
+
/*!__STENCIL_STATIC_IMPORT_SWITCH__*/return import(`./${o}.entry.js${""}`).then((e=>{{Hc.set(o,e)}return e[i]}),(e=>{qc(e,n.$hostElement$)}))};var Jc=new Map;var Vc="{visibility:hidden}.hydrated{visibility:inherit}";var Bc="slot-fb{display:contents}slot-fb[hidden]{display:none}";var Wc="http://www.w3.org/1999/xlink";var Yc=typeof window!=="undefined"?window:{};var Kc={u:0,C:"",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 zc=e=>Promise.resolve(e);var Xc=(()=>{try{if(!Yc.document.adoptedStyleSheets){return false}new CSSStyleSheet;return typeof(new CSSStyleSheet).replaceSync==="function"}catch(e){}return false})();var Qc=Xc?(()=>!!Yc.document&&Object.getOwnPropertyDescriptor(Yc.document.adoptedStyleSheets,"length").writable)():false;var Zc=false;var ef=[];var nf=[];var tf=(e,n)=>t=>{e.push(t);if(!Zc){Zc=true;if(n&&Kc.u&4){sf(rf)}else{Kc.raf(rf)}}};var of=e=>{for(let n=0;n<e.length;n++){try{e[n](performance.now())}catch(e){qc(e)}}e.length=0};var rf=()=>{of(ef);{of(nf);if(Zc=ef.length>0){Kc.raf(rf)}}};var sf=e=>zc().then(e);var lf=tf(nf,true);function uf(e){return void 0}var af;function cf(e){var n;const t={mode:"open"};const i=this.attachShadow(t);if(af===void 0)af=(n=uf())!=null?n:null;if(af){if(Qc){i.adoptedStyleSheets.push(af)}else{i.adoptedStyleSheets=[...i.adoptedStyleSheets,af]}}}var ff=(e,n="")=>{{return()=>{}}};var df=(e,n)=>{{return()=>{}}};function pf(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 hf=new WeakMap;var mf=(e,n,t)=>{let i=Jc.get(e);if(Xc&&t){i=i||new CSSStyleSheet;if(typeof i==="string"){i=n}else{i.replaceSync(n)}}else{i=n}Jc.set(e,i)};var gf=(e,n,t)=>{var i,o,r;const s=vf(n);const l=Jc.get(s);if(!Yc.document){return s}e=e.nodeType===11?e:Yc.document;if(l){if(typeof l==="string"){e=e.head||e;let t=hf.get(e);let r;if(!t){hf.set(e,t=new Set)}if(!t.has(s)){r=Yc.document.createElement("style");r.textContent=l;const u=(i=Kc._)!=null?i:pf(Yc.document);if(u!=null){r.setAttribute("nonce",u)}if(!(n.u&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(Xc){const n=(o=e.defaultView)!=null?o:e.ownerDocument.defaultView;const t=new n.CSSStyleSheet;t.replaceSync(l);if(Qc){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.u&1){e.insertBefore(r,null)}if(n.u&4){r.textContent+=Bc}if(t){t.add(s)}}}else{let n=hf.get(e);if(!n){hf.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(Qc){e.adoptedStyleSheets.push(i)}else{e.adoptedStyleSheets=[...e.adoptedStyleSheets,i]}n.add(s)}}}return s};var yf=e=>{const n=e.t;const t=e.$hostElement$;const i=n.u;const o=ff("attachStyles",n.A);const r=gf(t.shadowRoot?t.shadowRoot:t.getRootNode(),n);if(i&10){t["s-sc"]=r;t.classList.add(r+"-h")}o()};var vf=(e,n)=>"sc-"+e.A;var Ef=e=>{e=typeof e;return e==="object"||e==="function"};var wf=(e,n,...t)=>{if(typeof e==="string"){e=wd(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"&&!Ef(i)){i=String(i)}if(r&&s){l[l.length-1].P+=i}else{l.push(r?bf(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,If)}const a=bf(e,null);a.R=n;if(l.length>0){a.N=l}{a.M=o}return a};var bf=(e,n)=>{const t={u:0,D:e,P:n!=null?n:null,U:null,N:null};{t.R=null}{t.M=null}return t};var Tf={};var Sf=e=>e&&e.D===Tf;var If={forEach:(e,n)=>e.map(Af).forEach(n),map:(e,n)=>e.map(Af).map(n).map(Of)};var Af=e=>({vattrs:e.R,vchildren:e.N,vkey:e.M,vname:e.k,vtag:e.D,vtext:e.P});var Of=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 wf(e.vtag,n,...e.vchildren||[])}const n=bf(e.vtag,e.vtext);n.R=e.vattrs;n.N=e.vchildren;n.M=e.vkey;n.k=e.vname;return n};var Cf=(e,n,t)=>{if(e!=null&&!Ef(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 _f=e=>{var n;return(n=xc(e))==null?void 0:n.$hostElement$};var Pf=(e,n,t)=>{const i=_f(e);return{emit:e=>Rf(i,n,{bubbles:true,composed:true,cancelable:true,detail:e})}};var Rf=(e,n,t)=>{const i=Kc.ce(n,t);e.dispatchEvent(i);return i};var Nf=(e,n,t,i,o,r,s)=>{if(t===i){return}let l=Fc(e,n);let u=n.toLowerCase();if(n==="class"){const n=e.classList;const o=Df(t);let r=Df(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){Kf(i,e)}}else if(!l&&n[0]==="o"&&n[1]==="n"){if(n[2]==="-"){n=n.slice(3)}else if(Fc(Yc,u)){n=u.slice(2)}else{n=u[2]+n.slice(3)}if(t||i){const o=n.endsWith(Uf);n=n.replace(kf,"");if(t){Kc.rel(e,n,t,o)}if(i){Kc.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=Ef(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(Wc,n)}else{e.removeAttribute(n)}}}else if((!l||r&4||o)&&!s&&e.nodeType===1){i=i===true?"":i;if(a){e.setAttributeNS(Wc,n,i)}else{e.setAttribute(n,i)}}}};var Mf=/\s/;var Df=e=>{if(typeof e==="object"&&e&&"baseVal"in e){e=e.baseVal}if(!e||typeof e!=="string"){return[]}return e.split(Mf)};var Uf="Capture";var kf=new RegExp(Uf+"$");var Gf=(e,n,t,i)=>{const o=n.U.nodeType===11&&n.U.host?n.U.host:n.U;const r=e&&e.R||{};const s=n.R||{};{for(const e of xf(Object.keys(r))){if(!(e in s)){Nf(o,e,r[e],void 0,t,n.u)}}}for(const e of xf(Object.keys(s))){Nf(o,e,r[e],s[e],t,n.u)}};function xf(e){return e.includes("ref")?[...e.filter((e=>e!=="ref")),"ref"]:e}var Lf;var jf=false;var Ff=[];var qf=[];var Hf=(e,n,t)=>{const i=n.N[t];let o=0;let r;let s;if(i.P!=null){r=i.U=Yc.document.createTextNode(i.P)}else{if(!Yc.document){throw new Error("You are trying to render a Stencil component in an environment that doesn't support the DOM.")}r=i.U=Yc.document.createElement(i.D);{Gf(null,i,jf)}if(i.N){const n=i.D==="template"?r.content:r;for(o=0;o<i.N.length;++o){s=Hf(e,i,o);if(s){n.appendChild(s)}}}}r["s-hn"]=Lf;return r};var $f=(e,n,t,i,o,r)=>{let s=e;let l;if(s.shadowRoot&&s.tagName===Lf){s=s.shadowRoot}if(t.D==="template"){s=s.content}for(;o<=r;++o){if(i[o]){l=Hf(null,t,o);if(l){i[o].U=l;Xf(s,l,n)}}}};var Jf=(e,n,t)=>{for(let i=n;i<=t;++i){const n=e[i];if(n){const e=n.U;Yf(n);if(e){e.remove()}}}};var Vf=(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.D==="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(Bf(c,p,o)){Wf(c,p,o);c=n[++r];p=i[++s]}else if(Bf(f,h,o)){Wf(f,h,o);f=n[--a];h=i[--d]}else if(Bf(c,h,o)){Wf(c,h,o);Xf(y,c.U,f.U.nextSibling);c=n[++r];h=i[--d]}else if(Bf(f,p,o)){Wf(f,p,o);Xf(y,f.U,c.U);f=n[--a];p=i[++s]}else{l=-1;{for(u=r;u<=a;++u){if(n[u]&&n[u].M!==null&&n[u].M===p.M){l=u;break}}}if(l>=0){g=n[l];if(g.D!==p.D){m=Hf(n&&n[s],t,l)}else{Wf(g,p,o);n[l]=void 0;m=g.U}p=i[++s]}else{m=Hf(n&&n[s],t,s);p=i[++s]}if(m){{Xf(c.U.parentNode,m,c.U)}}}}if(r>a){$f(e,i[d+1]==null?null:i[d+1].U,t,i,s,d)}else if(s>d){Jf(n,r,a)}};var Bf=(e,n,t=false)=>{if(e.D===n.D){if(!t){return e.M===n.M}if(t&&!e.M&&n.M){e.M=n.M}return true}return false};var Wf=(e,t,i=false)=>{const o=t.U=e.U;const r=e.N;const s=t.N;const l=t.P;if(l==null){{Gf(e,t,jf)}if(r!==null&&s!==null){Vf(o,r,t,s,i)}else if(s!==null){if(e.P!==null){o.textContent=""}$f(o,null,t,s,0,s.length-1)}else if(!i&&n.updatable&&r!==null){Jf(r,0,r.length-1)}else;}else if(e.P!==l){o.data=l}};var Yf=e=>{{if(e.R&&e.R.ref){Ff.push((()=>e.R.ref(null)))}e.N&&e.N.map(Yf)}};var Kf=(e,n)=>{{qf.push((()=>e(n)))}};var zf=()=>{{Ff.forEach((e=>e()));Ff.length=0;qf.forEach((e=>e()));qf.length=0}};var Xf=(e,n,t,i)=>{if(e.__insertBefore){return e.__insertBefore(n,t)}else{return e==null?void 0:e.insertBefore(n,t)}};var Qf=(e,n,t=false)=>{const i=e.$hostElement$;const o=e.G||bf(null,null);const r=Sf(n);const s=r?n:wf(null,null,n);Lf=i.tagName;if(t&&s.R){for(const e of Object.keys(s.R)){if(i.hasAttribute(e)&&!["key","ref","style","class"].includes(e)){s.R[e]=i[e]}}}s.D=null;s.u|=4;e.G=s;s.U=o.U=i.shadowRoot||i;Wf(o,s,t);zf()};var Zf=(e,n)=>{if(n&&!e.L&&n["s-p"]){const t=n["s-p"].push(new Promise((i=>e.L=()=>{n["s-p"].splice(t-1,1);i()})))}};var ed=(e,n)=>{{e.u|=16}if(e.u&4){e.u|=512;return}Zf(e,e.j);const t=()=>nd(e,n);if(n){queueMicrotask((()=>{t()}));return}return lf(t)};var nd=(e,n)=>{const t=e.$hostElement$;const i=ff("scheduleUpdate",e.t.A);const o=e.l;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){{if(e.I.length){e.I.forEach((e=>e(t)))}}r=ud(o,"componentWillLoad",void 0,t)}else{r=ud(o,"componentWillUpdate",void 0,t)}r=td(r,(()=>ud(o,"componentWillRender",void 0,t)));i();return td(r,(()=>od(e,o,n)))};var td=(e,n)=>id(e)?e.then(n).catch((e=>{console.error(e);n()})):n();var id=e=>e instanceof Promise||e&&e.then&&typeof e.then==="function";var od=async(e,n,t)=>{var i;const o=e.$hostElement$;const r=ff("update",e.t.A);const s=o["s-rc"];if(t){yf(e)}const l=ff("render",e.t.A);{rd(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=()=>sd(e);if(n.length===0){t()}else{Promise.all(n).then(t).catch(t);e.u|=4;n.length=0}}};var rd=(e,n,t,i)=>{try{n=n.render();{e.u&=-17}{e.u|=2}{{{Qf(e,n,i)}}}}catch(n){qc(n,e.$hostElement$)}return null};var sd=e=>{const n=e.t.A;const t=e.$hostElement$;const i=ff("postUpdate",n);const o=e.l;const r=e.j;ud(o,"componentDidRender",void 0,t);if(!(e.u&64)){e.u|=64;{ad(t)}ud(o,"componentDidLoad",void 0,t);i();{e.S(t);if(!r){ld()}}}else{ud(o,"componentDidUpdate",void 0,t);i()}{e.m(t)}{if(e.L){e.L();e.L=void 0}if(e.u&512){sf((()=>ed(e,false)))}e.u&=-517}};var ld=n=>{sf((()=>Rf(Yc,"appload",{detail:{namespace:e}})))};var ud=(e,n,t,i)=>{if(e&&e[n]){try{return e[n](t)}catch(e){qc(e,i)}}return void 0};var ad=e=>{var t;return e.classList.add((t=n.hydratedSelectorName)!=null?t:"hydrated")};var cd=(e,n)=>xc(e).o.get(n);var fd=(e,n,t,i)=>{const o=xc(e);if(!o){return}if(!o){throw new Error(`Couldn't find host element for "${i.A}" as it is unknown to this Stencil runtime. This usually happens when integrating a 3rd party Stencil component with another Stencil component or application. Please reach out to the maintainers of the 3rd party Stencil component or report this on the Stencil Discord server (https://chat.stenciljs.com) or comment on this similar [GitHub issue](https://github.com/stenciljs/core/issues/5457).`)}const r=o.o.get(n);const s=o.u;const l=o.l;t=Cf(t,i.i[n][0]);const u=Number.isNaN(r)&&Number.isNaN(t);const a=t!==r&&!u;if((!(s&8)||r===void 0)&&a){o.o.set(n,t);if(s&2){if(l.componentShouldUpdate){const e=l.componentShouldUpdate(t,r,n);if(e===false&&!(s&16)){return}}if(!(s&16)){ed(o,false)}}}};var dd=(e,t,i)=>{var o,r;const s=e.prototype;if(t.i||n.propChangeCallback){const l=Object.entries((o=t.i)!=null?o:{});l.map((([e,[n]])=>{if(n&31||i&2&&n&32){const{get:o,set:r}=kc(s,e)||{};if(o)t.i[e][0]|=2048;if(r)t.i[e][0]|=4096;if(i&1||!o){Object.defineProperty(s,e,{get(){{if((t.i[e][0]&2048)===0){return cd(this,e)}const n=xc(this);const i=n?n.l:s;if(!i)return;return i[e]}},configurable:true,enumerable:true})}Object.defineProperty(s,e,{set(o){const s=xc(this);if(!s){return}if(r){const i=n&32?this[e]:s.$hostElement$[e];if(typeof i==="undefined"&&s.o.get(e)){o=s.o.get(e)}r.apply(this,[Cf(o,n)]);o=n&32?this[e]:s.$hostElement$[e];fd(this,e,o,t);return}{if((i&1)===0||(t.i[e][0]&4096)===0){fd(this,e,o,t);if(i&1&&!s.l){s.I.push((()=>{if(t.i[e][0]&4096&&s.l[e]!==s.o.get(e)){s.l[e]=o}}))}return}const r=()=>{const i=s.l[e];if(!s.o.get(e)&&i){s.o.set(e,i)}s.l[e]=Cf(o,n);fd(this,e,s.l[e],t)};if(s.l){r()}else{s.I.push((()=>{r()}))}}}})}else if(i&1&&n&64){Object.defineProperty(s,e,{value(...n){var t;const i=xc(this);return(t=i==null?void 0:i.h)==null?void 0:t.then((()=>{var t;return(t=i.l)==null?void 0:t[e](...n)}))}})}}));if(i&1){const i=new Map;s.attributeChangedCallback=function(e,o,r){Kc.jmp((()=>{var u;const a=i.get(e);const c=xc(this);if(this.hasOwnProperty(a)&&n.lazyLoad){r=this[a];delete this[a]}if(s.hasOwnProperty(a)&&typeof this[a]==="number"&&this[a]==r){return}else if(a==null){const n=c==null?void 0:c.u;if(c&&n&&!(n&8)&&r!==o){const i=c.l;const s=(u=t.F)==null?void 0:u[e];s==null?void 0:s.forEach((t=>{const[[s,l]]=Object.entries(t);if(i[s]!=null&&(n&128||l&1)){i[s].call(i,r,o,e)}}))}return}const f=l.find((([e])=>e===a));if(f&&f[1][0]&4){r=r===null||r==="false"?false:true}const d=Object.getOwnPropertyDescriptor(s,a);if(r!=this[a]&&(!d.get||!!d.set)){this[a]=r}}))};e.observedAttributes=Array.from(new Set([...Object.keys((r=t.F)!=null?r:{}),...l.filter((([e,n])=>n[0]&31)).map((([e,n])=>{const t=n[1]||e;i.set(t,e);return t}))]))}}return e};var pd=async(e,t,i,o)=>{let r;try{if((t.u&32)===0){t.u|=32;const o=i.O;if(o){const n=$c(i,t);if(n&&"then"in n){const e=df();r=await n;e()}else{r=n}if(!r){throw new Error(`Constructor for "${i.A}#${t.q}" was not found`)}if(!r.isProxied){dd(r,i,2);r.isProxied=true}const o=ff("createInstance",i.A);{t.u|=8}try{new r(t)}catch(n){qc(n,e)}{t.u&=-9}o();{hd(t.l,e)}}else{r=e.constructor;const n=e.localName;customElements.whenDefined(n).then((()=>t.u|=128))}if(r&&r.style){let e;if(typeof r.style==="string"){e=r.style}const t=vf(i);if(!Jc.has(t)||n.hotModuleReplacement){const n=ff("registerStyles",i.A);mf(t,e,!!(i.u&1));n()}}}const o=t.j;const s=()=>ed(t,true);if(o&&o["s-rc"]){o["s-rc"].push(s)}else{s()}}catch(n){qc(n,e);if(t.L){t.L();t.L=void 0}if(t.S){t.S(e)}}};var hd=(e,n)=>{{ud(e,"connectedCallback",void 0,n)}};var md=e=>{if((Kc.u&1)===0){const n=xc(e);if(!n){return}const t=n.t;const i=ff("connectedCallback",t.A);if(!(n.u&1)){n.u|=1;{let t=e;while(t=t.parentNode||t.host){if(t["s-p"]){Zf(n,n.j=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}}))}{pd(e,n,t)}}else{if(n==null?void 0:n.l){hd(n.l,e)}else if(n==null?void 0:n.T){n.T.then((()=>hd(n.l,e)))}}i()}};var gd=(e,n)=>{{ud(e,"disconnectedCallback",void 0,n||e)}};var yd=async e=>{if((Kc.u&1)===0){const n=xc(e);if(n==null?void 0:n.l){gd(n.l,e)}else if(n==null?void 0:n.T){n.T.then((()=>gd(n.l,e)))}}if(hf.has(e)){hf.delete(e)}if(e.shadowRoot&&hf.has(e.shadowRoot)){hf.delete(e.shadowRoot)}};var vd=(e,n={})=>{var t;if(!Yc.document){console.warn("Stencil: No document found. Skipping bootstrapping lazy components.");return}const i=ff();const o=[];const r=n.exclude||[];const s=Yc.customElements;const l=Yc.document.head;const u=l.querySelector("meta[charset]");const a=Yc.document.createElement("style");const c=[];let f;let d=true;Object.assign(Kc,n);Kc.C=new URL(n.resourcesUrl||"./",Yc.document.baseURI).href;e.map((e=>{e[1].map((n=>{const t={u:n[0],A:n[1],i:n[2],H:n[3]};{t.i=n[2]}const i=wd(t.A);const l=class extends HTMLElement{["s-p"];["s-rc"];hasRegisteredEventListeners=false;constructor(e){super(e);e=this;jc(e,t);if(t.u&1){{if(!e.shadowRoot){cf.call(e,t)}else{if(e.shadowRoot.mode!=="open"){throw new Error(`Unable to re-use existing shadow root for ${t.A}! Mode is set to ${e.shadowRoot.mode} but Stencil only supports open shadow roots.`)}}}}}connectedCallback(){const e=xc(this);if(!e){return}if(!this.hasRegisteredEventListeners){this.hasRegisteredEventListeners=true}if(f){clearTimeout(f);f=null}if(d){c.push(this)}else{Kc.jmp((()=>md(this)))}}disconnectedCallback(){Kc.jmp((()=>yd(this)));Kc.raf((()=>{var e;const n=xc(this);if(!n){return}const t=c.findIndex((e=>e===this));if(t>-1){c.splice(t,1)}if(((e=n==null?void 0:n.G)==null?void 0:e.U)instanceof Node&&!n.G.U.isConnected){delete n.G.U}}))}componentOnReady(){var e;return(e=xc(this))==null?void 0:e.T}};t.O=e[0];if(!r.includes(i)&&!s.get(i)){o.push(i);s.define(i,dd(l,t,1))}}))}));if(o.length>0){{a.textContent+=o.sort()+Vc}if(a.innerHTML.length){a.setAttribute("data-styles","");const e=(t=Kc._)!=null?t:pf(Yc.document);if(e!=null){a.setAttribute("nonce",e)}l.insertBefore(a,u?u.nextSibling:l.firstChild)}}d=false;if(c.length){c.map((e=>e.connectedCallback()))}else{{Kc.jmp((()=>f=setTimeout(ld,30)))}}i()};var Ed=e=>Kc._=e;function wd(e){return e}export{Uc as G,t as a,vd as b,Pf as c,i as g,wf as h,zc as p,Lc as r,Ed as s};
|
|
298
|
+
//# sourceMappingURL=p-DxzhGhec.js.map
|