igiveup 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/README.md +2 -74
  2. package/dist/404.html +1 -1
  3. package/dist/__next.__PAGE__.txt +4 -4
  4. package/dist/__next._full.txt +21 -19
  5. package/dist/__next._head.txt +5 -5
  6. package/dist/__next._index.txt +7 -6
  7. package/dist/__next._tree.txt +4 -3
  8. package/dist/_next/static/chunks/{b18da497cd71639c.js → 22fc8eaca9ee64bc.js} +1 -1
  9. package/dist/_next/static/chunks/60ed5b2efa700aaa.js +1 -0
  10. package/dist/_next/static/chunks/6410fba97b570c28.js +342 -0
  11. package/dist/_next/static/chunks/66fab0b378efd2a4.js +1 -0
  12. package/dist/_next/static/chunks/{7f3a50588edd3e98.js → 698a880cc295fffe.js} +1 -1
  13. package/dist/_next/static/chunks/6b74c6dc32328023.js +4 -0
  14. package/dist/_next/static/chunks/6eab5ca50b95bebb.js +1 -0
  15. package/dist/_next/static/chunks/6f8487ca24b97dbe.css +1 -0
  16. package/dist/_next/static/chunks/75a7d00aac306ce4.js +13 -0
  17. package/dist/_next/static/chunks/8b1c561b940ebca7.css +1 -0
  18. package/dist/_next/static/chunks/{c218146104a27e59.js → 8c8ada6023ad7145.js} +1 -1
  19. package/dist/_next/static/chunks/929661c509b626ae.js +2 -0
  20. package/dist/_next/static/chunks/e511442ff98acb18.js +1 -0
  21. package/dist/_next/static/chunks/{turbopack-42182df38b37704b.js → turbopack-f65fc62433f994bd.js} +2 -2
  22. package/dist/_next/static/media/00014e848e9c95b7.d3603743.woff2 +0 -0
  23. package/dist/_next/static/media/004f258d0f697418.f344da23.woff2 +0 -0
  24. package/dist/_next/static/media/0262ded5424bad8d.3234df93.woff2 +0 -0
  25. package/dist/_next/static/media/0481755b59c0d400.5359174b.woff2 +0 -0
  26. package/dist/_next/static/media/06be43540ab2bc8e.afd4e7b5.woff2 +0 -0
  27. package/dist/_next/static/media/0924b4f9801903fa.e4ec60ec.woff2 +0 -0
  28. package/dist/_next/static/media/0a907ae9cb0738dc.2ade8a59.woff2 +0 -0
  29. package/dist/_next/static/media/0de0b9b70e0c5c75.9455e08f.woff2 +0 -0
  30. package/dist/_next/static/media/0ebbd9c63ec5d991.81c2963d.woff2 +0 -0
  31. package/dist/_next/static/media/10e5706cd96c5c09.8aca4ca4.woff2 +0 -0
  32. package/dist/_next/static/media/11e4380658480fc7.5ae240d7.woff2 +0 -0
  33. package/dist/_next/static/media/132c9044aec49244.0e791b05.woff2 +0 -0
  34. package/dist/_next/static/media/174346f0d0efda44.35ed1557.woff2 +0 -0
  35. package/dist/_next/static/media/1adbfbcd49a895b3.479c81e3.woff2 +0 -0
  36. package/dist/_next/static/media/1ba5f184a07c212d.ae1f3a4e.woff2 +0 -0
  37. package/dist/_next/static/media/1f2a0338c1b94ec5.24996119.woff2 +0 -0
  38. package/dist/_next/static/media/1f416efc35ef14e1.47c7917f.woff2 +0 -0
  39. package/dist/_next/static/media/1f5e72047766afb5.d7e6fac7.woff2 +0 -0
  40. package/dist/_next/static/media/25aca0f82a861946.9c51b364.woff2 +0 -0
  41. package/dist/_next/static/media/29c1bd25fe068aca.c00bd2bd.woff2 +0 -0
  42. package/dist/_next/static/media/2a95a63198c96fdb.9acda241.woff2 +0 -0
  43. package/dist/_next/static/media/32cc90dfa31e1e6d.a74664c0.woff2 +0 -0
  44. package/dist/_next/static/media/3b352ddd20b99253.5bff2508.woff2 +0 -0
  45. package/dist/_next/static/media/3b46bc029424e5c7.bd4d34bf.woff2 +0 -0
  46. package/dist/_next/static/media/3e89a536a849f456.9e1be6d2.woff2 +0 -0
  47. package/dist/_next/static/media/425302cee2d83426.d1d73ee4.woff2 +0 -0
  48. package/dist/_next/static/media/44713c84af92323f.145e6359.woff2 +0 -0
  49. package/dist/_next/static/media/487daf28e0ea8cee.27080888.woff2 +0 -0
  50. package/dist/_next/static/media/4a30c6d3c6b046b2.ead271e0.woff2 +0 -0
  51. package/dist/_next/static/media/4c4374b4f4fdec9e.218a137f.woff2 +0 -0
  52. package/dist/_next/static/media/4d40391e737054ed.9d94255a.woff2 +0 -0
  53. package/dist/_next/static/media/58a4dbc789192060.31c8ae1a.woff2 +0 -0
  54. package/dist/_next/static/media/597d03b254439578.1323d452.woff2 +0 -0
  55. package/dist/_next/static/media/5dabd6bccbaafa57.5aedae46.woff2 +0 -0
  56. package/dist/_next/static/media/5e2f6f0b802cfbdf.f4440eb7.woff2 +0 -0
  57. package/dist/_next/static/media/63825990b35916a6.c2325c77.woff2 +0 -0
  58. package/dist/_next/static/media/667c2a78cf80937f.7377bb29.woff2 +0 -0
  59. package/dist/_next/static/media/67da0c40a8bdba86.80df1f2f.woff2 +0 -0
  60. package/dist/_next/static/media/68c88a4880acb7f7.4a6bbe64.woff2 +0 -0
  61. package/dist/_next/static/media/6902b7f764f8d0a2.b78a77c2.woff2 +0 -0
  62. package/dist/_next/static/media/6b84c3d46053599f.fc503e19.woff2 +0 -0
  63. package/dist/_next/static/media/6b867f4692cc1c24.ec928ed3.woff2 +0 -0
  64. package/dist/_next/static/media/6bc37c1816c36115.54868a7c.woff2 +0 -0
  65. package/dist/_next/static/media/6c4747324ffb7ff6.a687e43f.woff2 +0 -0
  66. package/dist/_next/static/media/6d925f981f4b97d5.ad8174fa.woff2 +0 -0
  67. package/dist/_next/static/media/6e784326faefd94f.57b35f54.woff2 +0 -0
  68. package/dist/_next/static/media/6f063d2e3f5ed4b2.77058057.woff2 +0 -0
  69. package/dist/_next/static/media/737d13bbaa7a3560.b1f2cb20.woff2 +0 -0
  70. package/dist/_next/static/media/75e1c015194f1074.9a830731.woff2 +0 -0
  71. package/dist/_next/static/media/75e28cd10e93746b.b8c31981.woff2 +0 -0
  72. package/dist/_next/static/media/768d2384cfda099c.32e7e5e6.woff2 +0 -0
  73. package/dist/_next/static/media/77fbd8b27544ded4.ef83a7fe.woff2 +0 -0
  74. package/dist/_next/static/media/7aef9075d757d3c6.33f9c009.woff2 +0 -0
  75. package/dist/_next/static/media/7b6b92333187c5da.7c3d2a56.woff2 +0 -0
  76. package/dist/_next/static/media/7bbd1d6f5b5dbc91.4a8fe726.woff2 +0 -0
  77. package/dist/_next/static/media/7dc2d1927a47186e.85db3769.woff2 +0 -0
  78. package/dist/_next/static/media/801542a26b39d54e.6d23e25a.woff2 +0 -0
  79. package/dist/_next/static/media/835a033bc99a3004.530e1c0e.woff2 +0 -0
  80. package/dist/_next/static/media/87624f4b68a7ae18.8219b4bf.woff2 +0 -0
  81. package/dist/_next/static/media/89ec3f0752821d2a.5b472127.woff2 +0 -0
  82. package/dist/_next/static/media/8a8a45bc2be6e75f.ab5dd8b6.woff2 +0 -0
  83. package/dist/_next/static/media/8bb075a1b5cd2fb6.fae87df3.woff2 +0 -0
  84. package/dist/_next/static/media/8de34c732618a697.2c9fb109.woff2 +0 -0
  85. package/dist/_next/static/media/8dee343dfe44bd61.d7ab8266.woff2 +0 -0
  86. package/dist/_next/static/media/946daa5a3a89cfc5.93af40d3.woff2 +0 -0
  87. package/dist/_next/static/media/97f69eeaf40202c0.08e25883.woff2 +0 -0
  88. package/dist/_next/static/media/99c899fe62b2196e.aa168c88.woff2 +0 -0
  89. package/dist/_next/static/media/9c1659cbf1d78c40.3c005ee7.woff2 +0 -0
  90. package/dist/_next/static/media/a2d7248a844b869a.2fe99030.woff2 +0 -0
  91. package/dist/_next/static/media/a88ca424fba28a50.8f914b75.woff2 +0 -0
  92. package/dist/_next/static/media/a95445f9f9529239.0241ea71.woff2 +0 -0
  93. package/dist/_next/static/media/a99d8aa8d1d5d84a.c4f904fe.woff2 +0 -0
  94. package/dist/_next/static/media/adc4c24d849b7d22.6a6a4da8.woff2 +0 -0
  95. package/dist/_next/static/media/b2925ad35584ba70.518eab91.woff2 +0 -0
  96. package/dist/_next/static/media/b5c5a3aee3d68f14.e9880d5c.woff2 +0 -0
  97. package/dist/_next/static/media/b5dccbeb735a2e0f.14defd14.woff2 +0 -0
  98. package/dist/_next/static/media/b775ae14120f0c97.4abb72ee.woff2 +0 -0
  99. package/dist/_next/static/media/b95174f56d442c5d.4812a252.woff2 +0 -0
  100. package/dist/_next/static/media/c0aacfec2f1573c0.f492f708.woff2 +0 -0
  101. package/dist/_next/static/media/c4b0b4dcf0f22c7a.0cfafb9c.woff2 +0 -0
  102. package/dist/_next/static/media/c4e4a6761a279a26.cde1c1b1.woff2 +0 -0
  103. package/dist/_next/static/media/c8065fd4f164b3a5.bb74a635.woff2 +0 -0
  104. package/dist/_next/static/media/cd0ac912c441b9b4.959b6030.woff2 +0 -0
  105. package/dist/_next/static/media/d03debd6cf4b3362.5c0c5927.woff2 +0 -0
  106. package/dist/_next/static/media/d3f4c737e8dc0be9.12c160ef.woff2 +0 -0
  107. package/dist/_next/static/media/d95fa6e3c5a4cdd3.7ddf94b3.woff2 +0 -0
  108. package/dist/_next/static/media/e3a5d23087736f5c.9ad16c03.woff2 +0 -0
  109. package/dist/_next/static/media/e3ef056ddd3a2ac5.1552ef47.woff2 +0 -0
  110. package/dist/_next/static/media/e7faabac039536c0.8e35a3a3.woff2 +0 -0
  111. package/dist/_next/static/media/e87c8e66644fea0e.df5d4a03.woff2 +0 -0
  112. package/dist/_next/static/media/e9242943403695a8.1b7a452f.woff2 +0 -0
  113. package/dist/_next/static/media/f15b8acd20219e15.8c281e97.woff2 +0 -0
  114. package/dist/_next/static/media/f4214a50e6a13e82.a6a48d6d.woff2 +0 -0
  115. package/dist/_next/static/media/f4321b0b4a0dbceb.6e9655ce.woff2 +0 -0
  116. package/dist/_next/static/media/f65cb101f1fc3fec.5a396dcb.woff2 +0 -0
  117. package/dist/_next/static/media/f7ef87dd76e798bf.79cb5561.woff2 +0 -0
  118. package/dist/_next/static/media/f8536e6dafe9eb48.c050e0ac.woff2 +0 -0
  119. package/dist/_next/static/media/f8a93f6b396da90f.6a44a4b6.woff2 +0 -0
  120. package/dist/_next/static/media/fa1c512a13c0dddb.9f3531ba.woff2 +0 -0
  121. package/dist/_next/static/media/fab1392add46a006.7eb29fd5.woff2 +0 -0
  122. package/dist/_next/static/media/fb4edce8a3cbfef3.p.fe3c897b.woff2 +0 -0
  123. package/dist/_next/static/media/fc82e7e9b0e3e420.8c166144.woff2 +0 -0
  124. package/dist/_next/static/media/fd4c56e2e3df4865.05650364.woff2 +0 -0
  125. package/dist/_next/static/media/ff968943fd53ca5d.d4c93737.woff2 +0 -0
  126. package/dist/_next/static/media/ffec6e4bb7681106.a24cdcb3.woff2 +0 -0
  127. package/dist/_not-found/__next._full.txt +18 -15
  128. package/dist/_not-found/__next._head.txt +5 -5
  129. package/dist/_not-found/__next._index.txt +7 -6
  130. package/dist/_not-found/__next._not-found.__PAGE__.txt +2 -2
  131. package/dist/_not-found/__next._not-found.txt +3 -3
  132. package/dist/_not-found/__next._tree.txt +3 -3
  133. package/dist/_not-found.html +1 -1
  134. package/dist/_not-found.txt +18 -15
  135. package/dist/index.html +1 -1
  136. package/dist/index.txt +21 -19
  137. package/dist/manifest.webmanifest +1 -0
  138. package/dist/opengraph-image +0 -0
  139. package/dist/robots.txt +4 -0
  140. package/dist/sitemap.xml +9 -0
  141. package/package.json +22 -5
  142. package/dist/_next/static/chunks/41307292ab86fe39.js +0 -1
  143. package/dist/_next/static/chunks/7521cd4ba12a4d17.css +0 -1
  144. package/dist/_next/static/chunks/a43937f87dbafba4.js +0 -1
  145. package/dist/_next/static/chunks/b4a799ac963d5996.js +0 -323
  146. package/dist/_next/static/chunks/c24f9dcbcebdbbbc.js +0 -13
  147. package/dist/_next/static/chunks/d8c9b2a63125f582.js +0 -2
  148. package/dist/_next/static/chunks/d9468907c0fe03d2.js +0 -4
  149. /package/dist/_next/static/{vI4Wy-xsqGI2uTL0Ayvry → QFKeVo403ziE8a9q3csjK}/_buildManifest.js +0 -0
  150. /package/dist/_next/static/{vI4Wy-xsqGI2uTL0Ayvry → QFKeVo403ziE8a9q3csjK}/_clientMiddlewareManifest.json +0 -0
  151. /package/dist/_next/static/{vI4Wy-xsqGI2uTL0Ayvry → QFKeVo403ziE8a9q3csjK}/_ssgManifest.js +0 -0
@@ -1,323 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,24333,e=>{"use strict";var t,n,i,l,r,o,a,s,u,p,d,c,h,m,f,g,y,E,_,I,T,v,A,C,S,O,b,N,R,P,D,M,w,U,k,L,q,x,G,H,F,V,j,B,J,Y,K,$,W,z,X,Z,Q,ee,et,en,ei,el,er,eo,ea,es,eu,ep,ed,ec,eh,em,ef,eg,ey,eE,e_,eI,eT,ev,eA,eC,eS,eO,eb,eN,eR,eP,eD,eM,ew,eU,ek,eL,eq,ex,eG,eH,eF,eV,ej,eB,eJ,eY,eK,e$,eW,ez,eX,eZ,eQ,e0,e1,e6,e4,e2;let e3,e9;class e5{}function e8(e,t){return e.replace(/\{([^}]+)\}/g,(e,n)=>{if(Object.prototype.hasOwnProperty.call(t,n)){let e=t[n];return null!=e?String(e):""}throw Error(`Key '${n}' not found in valueMap.`)})}function e7(e,t,n){for(let i=0;i<t.length-1;i++){let l=t[i];if(l.endsWith("[]")){let r=l.slice(0,-2);if(!(r in e))if(Array.isArray(n))e[r]=Array.from({length:n.length},()=>({}));else throw Error(`Value must be a list given an array path ${l}`);if(Array.isArray(e[r])){let l=e[r];if(Array.isArray(n))for(let e=0;e<l.length;e++)e7(l[e],t.slice(i+1),n[e]);else for(let e of l)e7(e,t.slice(i+1),n)}return}if(l.endsWith("[0]")){let r=l.slice(0,-3);r in e||(e[r]=[{}]),e7(e[r][0],t.slice(i+1),n);return}e[l]&&"object"==typeof e[l]||(e[l]={}),e=e[l]}let i=t[t.length-1],l=e[i];if(void 0!==l){if(!n||"object"==typeof n&&0===Object.keys(n).length||n===l)return;if("object"==typeof l&&"object"==typeof n&&null!==l&&null!==n)Object.assign(l,n);else throw Error(`Cannot set value for an existing key. Key: ${i}`)}else"_self"!==i||"object"!=typeof n||null===n||Array.isArray(n)?e[i]=n:Object.assign(e,n)}function te(e,t,n){try{if(1===t.length&&"_self"===t[0])return e;for(let i=0;i<t.length;i++){if("object"!=typeof e||null===e)return n;let l=t[i];if(l.endsWith("[]")){let r=l.slice(0,-2);if(!(r in e))return n;{let l=e[r];if(!Array.isArray(l))return n;return l.map(e=>te(e,t.slice(i+1),n))}}e=e[l]}return e}catch(e){if(e instanceof TypeError)return n;throw e}}function tt(e){if("string"!=typeof e)throw Error("fromImageBytes must be a string");return e}function tn(e){var t;let n,i,l,r,o={},a=te(e,["name"]);null!=a&&e7(o,["name"],a);let s=te(e,["metadata"]);null!=s&&e7(o,["metadata"],s);let u=te(e,["done"]);null!=u&&e7(o,["done"],u);let p=te(e,["error"]);null!=p&&e7(o,["error"],p);let d=te(e,["response"]);return null!=d&&e7(o,["response"],(n={},null!=(i=te(t=d,["sdkHttpResponse"]))&&e7(n,["sdkHttpResponse"],i),null!=(l=te(t,["parent"]))&&e7(n,["parent"],l),null!=(r=te(t,["documentName"]))&&e7(n,["documentName"],r),n)),o}(ei=t||(t={})).OUTCOME_UNSPECIFIED="OUTCOME_UNSPECIFIED",ei.OUTCOME_OK="OUTCOME_OK",ei.OUTCOME_FAILED="OUTCOME_FAILED",ei.OUTCOME_DEADLINE_EXCEEDED="OUTCOME_DEADLINE_EXCEEDED",(el=n||(n={})).LANGUAGE_UNSPECIFIED="LANGUAGE_UNSPECIFIED",el.PYTHON="PYTHON",(er=i||(i={})).SCHEDULING_UNSPECIFIED="SCHEDULING_UNSPECIFIED",er.SILENT="SILENT",er.WHEN_IDLE="WHEN_IDLE",er.INTERRUPT="INTERRUPT",(eo=l||(l={})).TYPE_UNSPECIFIED="TYPE_UNSPECIFIED",eo.STRING="STRING",eo.NUMBER="NUMBER",eo.INTEGER="INTEGER",eo.BOOLEAN="BOOLEAN",eo.ARRAY="ARRAY",eo.OBJECT="OBJECT",eo.NULL="NULL",(ea=r||(r={})).MODE_UNSPECIFIED="MODE_UNSPECIFIED",ea.MODE_DYNAMIC="MODE_DYNAMIC",(es=o||(o={})).API_SPEC_UNSPECIFIED="API_SPEC_UNSPECIFIED",es.SIMPLE_SEARCH="SIMPLE_SEARCH",es.ELASTIC_SEARCH="ELASTIC_SEARCH",(eu=a||(a={})).AUTH_TYPE_UNSPECIFIED="AUTH_TYPE_UNSPECIFIED",eu.NO_AUTH="NO_AUTH",eu.API_KEY_AUTH="API_KEY_AUTH",eu.HTTP_BASIC_AUTH="HTTP_BASIC_AUTH",eu.GOOGLE_SERVICE_ACCOUNT_AUTH="GOOGLE_SERVICE_ACCOUNT_AUTH",eu.OAUTH="OAUTH",eu.OIDC_AUTH="OIDC_AUTH",(ep=s||(s={})).HTTP_IN_UNSPECIFIED="HTTP_IN_UNSPECIFIED",ep.HTTP_IN_QUERY="HTTP_IN_QUERY",ep.HTTP_IN_HEADER="HTTP_IN_HEADER",ep.HTTP_IN_PATH="HTTP_IN_PATH",ep.HTTP_IN_BODY="HTTP_IN_BODY",ep.HTTP_IN_COOKIE="HTTP_IN_COOKIE",(ed=u||(u={})).PHISH_BLOCK_THRESHOLD_UNSPECIFIED="PHISH_BLOCK_THRESHOLD_UNSPECIFIED",ed.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",ed.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",ed.BLOCK_HIGH_AND_ABOVE="BLOCK_HIGH_AND_ABOVE",ed.BLOCK_HIGHER_AND_ABOVE="BLOCK_HIGHER_AND_ABOVE",ed.BLOCK_VERY_HIGH_AND_ABOVE="BLOCK_VERY_HIGH_AND_ABOVE",ed.BLOCK_ONLY_EXTREMELY_HIGH="BLOCK_ONLY_EXTREMELY_HIGH",(ec=p||(p={})).THINKING_LEVEL_UNSPECIFIED="THINKING_LEVEL_UNSPECIFIED",ec.LOW="LOW",ec.HIGH="HIGH",(eh=d||(d={})).HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",eh.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",eh.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",eh.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",eh.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT",eh.HARM_CATEGORY_CIVIC_INTEGRITY="HARM_CATEGORY_CIVIC_INTEGRITY",eh.HARM_CATEGORY_IMAGE_HATE="HARM_CATEGORY_IMAGE_HATE",eh.HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT="HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT",eh.HARM_CATEGORY_IMAGE_HARASSMENT="HARM_CATEGORY_IMAGE_HARASSMENT",eh.HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT="HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT",eh.HARM_CATEGORY_JAILBREAK="HARM_CATEGORY_JAILBREAK",(em=c||(c={})).HARM_BLOCK_METHOD_UNSPECIFIED="HARM_BLOCK_METHOD_UNSPECIFIED",em.SEVERITY="SEVERITY",em.PROBABILITY="PROBABILITY",(ef=h||(h={})).HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",ef.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",ef.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",ef.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",ef.BLOCK_NONE="BLOCK_NONE",ef.OFF="OFF",(eg=m||(m={})).FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",eg.STOP="STOP",eg.MAX_TOKENS="MAX_TOKENS",eg.SAFETY="SAFETY",eg.RECITATION="RECITATION",eg.LANGUAGE="LANGUAGE",eg.OTHER="OTHER",eg.BLOCKLIST="BLOCKLIST",eg.PROHIBITED_CONTENT="PROHIBITED_CONTENT",eg.SPII="SPII",eg.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",eg.IMAGE_SAFETY="IMAGE_SAFETY",eg.UNEXPECTED_TOOL_CALL="UNEXPECTED_TOOL_CALL",eg.IMAGE_PROHIBITED_CONTENT="IMAGE_PROHIBITED_CONTENT",eg.NO_IMAGE="NO_IMAGE",(ey=f||(f={})).HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",ey.NEGLIGIBLE="NEGLIGIBLE",ey.LOW="LOW",ey.MEDIUM="MEDIUM",ey.HIGH="HIGH",(eE=g||(g={})).HARM_SEVERITY_UNSPECIFIED="HARM_SEVERITY_UNSPECIFIED",eE.HARM_SEVERITY_NEGLIGIBLE="HARM_SEVERITY_NEGLIGIBLE",eE.HARM_SEVERITY_LOW="HARM_SEVERITY_LOW",eE.HARM_SEVERITY_MEDIUM="HARM_SEVERITY_MEDIUM",eE.HARM_SEVERITY_HIGH="HARM_SEVERITY_HIGH",(e_=y||(y={})).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",(eI=E||(E={})).BLOCKED_REASON_UNSPECIFIED="BLOCKED_REASON_UNSPECIFIED",eI.SAFETY="SAFETY",eI.OTHER="OTHER",eI.BLOCKLIST="BLOCKLIST",eI.PROHIBITED_CONTENT="PROHIBITED_CONTENT",eI.IMAGE_SAFETY="IMAGE_SAFETY",eI.MODEL_ARMOR="MODEL_ARMOR",eI.JAILBREAK="JAILBREAK",(eT=_||(_={})).TRAFFIC_TYPE_UNSPECIFIED="TRAFFIC_TYPE_UNSPECIFIED",eT.ON_DEMAND="ON_DEMAND",eT.PROVISIONED_THROUGHPUT="PROVISIONED_THROUGHPUT",(ev=I||(I={})).MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",ev.TEXT="TEXT",ev.IMAGE="IMAGE",ev.AUDIO="AUDIO",(eA=T||(T={})).MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",eA.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",eA.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",eA.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH",(eC=v||(v={})).TUNING_MODE_UNSPECIFIED="TUNING_MODE_UNSPECIFIED",eC.TUNING_MODE_FULL="TUNING_MODE_FULL",eC.TUNING_MODE_PEFT_ADAPTER="TUNING_MODE_PEFT_ADAPTER",(eS=A||(A={})).ADAPTER_SIZE_UNSPECIFIED="ADAPTER_SIZE_UNSPECIFIED",eS.ADAPTER_SIZE_ONE="ADAPTER_SIZE_ONE",eS.ADAPTER_SIZE_TWO="ADAPTER_SIZE_TWO",eS.ADAPTER_SIZE_FOUR="ADAPTER_SIZE_FOUR",eS.ADAPTER_SIZE_EIGHT="ADAPTER_SIZE_EIGHT",eS.ADAPTER_SIZE_SIXTEEN="ADAPTER_SIZE_SIXTEEN",eS.ADAPTER_SIZE_THIRTY_TWO="ADAPTER_SIZE_THIRTY_TWO",(eO=C||(C={})).JOB_STATE_UNSPECIFIED="JOB_STATE_UNSPECIFIED",eO.JOB_STATE_QUEUED="JOB_STATE_QUEUED",eO.JOB_STATE_PENDING="JOB_STATE_PENDING",eO.JOB_STATE_RUNNING="JOB_STATE_RUNNING",eO.JOB_STATE_SUCCEEDED="JOB_STATE_SUCCEEDED",eO.JOB_STATE_FAILED="JOB_STATE_FAILED",eO.JOB_STATE_CANCELLING="JOB_STATE_CANCELLING",eO.JOB_STATE_CANCELLED="JOB_STATE_CANCELLED",eO.JOB_STATE_PAUSED="JOB_STATE_PAUSED",eO.JOB_STATE_EXPIRED="JOB_STATE_EXPIRED",eO.JOB_STATE_UPDATING="JOB_STATE_UPDATING",eO.JOB_STATE_PARTIALLY_SUCCEEDED="JOB_STATE_PARTIALLY_SUCCEEDED",(eb=S||(S={})).TUNING_TASK_UNSPECIFIED="TUNING_TASK_UNSPECIFIED",eb.TUNING_TASK_I2V="TUNING_TASK_I2V",eb.TUNING_TASK_T2V="TUNING_TASK_T2V",eb.TUNING_TASK_R2V="TUNING_TASK_R2V",(eN=O||(O={})).MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",eN.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",eN.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",eN.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH",(eR=b||(b={})).FEATURE_SELECTION_PREFERENCE_UNSPECIFIED="FEATURE_SELECTION_PREFERENCE_UNSPECIFIED",eR.PRIORITIZE_QUALITY="PRIORITIZE_QUALITY",eR.BALANCED="BALANCED",eR.PRIORITIZE_COST="PRIORITIZE_COST",(eP=N||(N={})).UNSPECIFIED="UNSPECIFIED",eP.BLOCKING="BLOCKING",eP.NON_BLOCKING="NON_BLOCKING",(eD=R||(R={})).MODE_UNSPECIFIED="MODE_UNSPECIFIED",eD.MODE_DYNAMIC="MODE_DYNAMIC",(eM=P||(P={})).ENVIRONMENT_UNSPECIFIED="ENVIRONMENT_UNSPECIFIED",eM.ENVIRONMENT_BROWSER="ENVIRONMENT_BROWSER",(ew=D||(D={})).MODE_UNSPECIFIED="MODE_UNSPECIFIED",ew.AUTO="AUTO",ew.ANY="ANY",ew.NONE="NONE",ew.VALIDATED="VALIDATED",(eU=M||(M={})).BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",eU.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",eU.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",eU.BLOCK_NONE="BLOCK_NONE",(ek=w||(w={})).DONT_ALLOW="DONT_ALLOW",ek.ALLOW_ADULT="ALLOW_ADULT",ek.ALLOW_ALL="ALLOW_ALL",(eL=U||(U={})).auto="auto",eL.en="en",eL.ja="ja",eL.ko="ko",eL.hi="hi",eL.zh="zh",eL.pt="pt",eL.es="es",(eq=k||(k={})).MASK_MODE_DEFAULT="MASK_MODE_DEFAULT",eq.MASK_MODE_USER_PROVIDED="MASK_MODE_USER_PROVIDED",eq.MASK_MODE_BACKGROUND="MASK_MODE_BACKGROUND",eq.MASK_MODE_FOREGROUND="MASK_MODE_FOREGROUND",eq.MASK_MODE_SEMANTIC="MASK_MODE_SEMANTIC",(ex=L||(L={})).CONTROL_TYPE_DEFAULT="CONTROL_TYPE_DEFAULT",ex.CONTROL_TYPE_CANNY="CONTROL_TYPE_CANNY",ex.CONTROL_TYPE_SCRIBBLE="CONTROL_TYPE_SCRIBBLE",ex.CONTROL_TYPE_FACE_MESH="CONTROL_TYPE_FACE_MESH",(eG=q||(q={})).SUBJECT_TYPE_DEFAULT="SUBJECT_TYPE_DEFAULT",eG.SUBJECT_TYPE_PERSON="SUBJECT_TYPE_PERSON",eG.SUBJECT_TYPE_ANIMAL="SUBJECT_TYPE_ANIMAL",eG.SUBJECT_TYPE_PRODUCT="SUBJECT_TYPE_PRODUCT",(eH=x||(x={})).EDIT_MODE_DEFAULT="EDIT_MODE_DEFAULT",eH.EDIT_MODE_INPAINT_REMOVAL="EDIT_MODE_INPAINT_REMOVAL",eH.EDIT_MODE_INPAINT_INSERTION="EDIT_MODE_INPAINT_INSERTION",eH.EDIT_MODE_OUTPAINT="EDIT_MODE_OUTPAINT",eH.EDIT_MODE_CONTROLLED_EDITING="EDIT_MODE_CONTROLLED_EDITING",eH.EDIT_MODE_STYLE="EDIT_MODE_STYLE",eH.EDIT_MODE_BGSWAP="EDIT_MODE_BGSWAP",eH.EDIT_MODE_PRODUCT_IMAGE="EDIT_MODE_PRODUCT_IMAGE",(eF=G||(G={})).FOREGROUND="FOREGROUND",eF.BACKGROUND="BACKGROUND",eF.PROMPT="PROMPT",eF.SEMANTIC="SEMANTIC",eF.INTERACTIVE="INTERACTIVE",(eV=H||(H={})).ASSET="ASSET",eV.STYLE="STYLE",(ej=F||(F={})).INSERT="INSERT",ej.REMOVE="REMOVE",ej.REMOVE_STATIC="REMOVE_STATIC",ej.OUTPAINT="OUTPAINT",(eB=V||(V={})).OPTIMIZED="OPTIMIZED",eB.LOSSLESS="LOSSLESS",(eJ=j||(j={})).SUPERVISED_FINE_TUNING="SUPERVISED_FINE_TUNING",eJ.PREFERENCE_TUNING="PREFERENCE_TUNING",(eY=B||(B={})).STATE_UNSPECIFIED="STATE_UNSPECIFIED",eY.STATE_PENDING="STATE_PENDING",eY.STATE_ACTIVE="STATE_ACTIVE",eY.STATE_FAILED="STATE_FAILED",(eK=J||(J={})).STATE_UNSPECIFIED="STATE_UNSPECIFIED",eK.PROCESSING="PROCESSING",eK.ACTIVE="ACTIVE",eK.FAILED="FAILED",(e$=Y||(Y={})).SOURCE_UNSPECIFIED="SOURCE_UNSPECIFIED",e$.UPLOADED="UPLOADED",e$.GENERATED="GENERATED",(eW=K||(K={})).TURN_COMPLETE_REASON_UNSPECIFIED="TURN_COMPLETE_REASON_UNSPECIFIED",eW.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",eW.RESPONSE_REJECTED="RESPONSE_REJECTED",eW.NEED_MORE_INPUT="NEED_MORE_INPUT",(ez=$||($={})).MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",ez.TEXT="TEXT",ez.IMAGE="IMAGE",ez.VIDEO="VIDEO",ez.AUDIO="AUDIO",ez.DOCUMENT="DOCUMENT",(eX=W||(W={})).START_SENSITIVITY_UNSPECIFIED="START_SENSITIVITY_UNSPECIFIED",eX.START_SENSITIVITY_HIGH="START_SENSITIVITY_HIGH",eX.START_SENSITIVITY_LOW="START_SENSITIVITY_LOW",(eZ=z||(z={})).END_SENSITIVITY_UNSPECIFIED="END_SENSITIVITY_UNSPECIFIED",eZ.END_SENSITIVITY_HIGH="END_SENSITIVITY_HIGH",eZ.END_SENSITIVITY_LOW="END_SENSITIVITY_LOW",(eQ=X||(X={})).ACTIVITY_HANDLING_UNSPECIFIED="ACTIVITY_HANDLING_UNSPECIFIED",eQ.START_OF_ACTIVITY_INTERRUPTS="START_OF_ACTIVITY_INTERRUPTS",eQ.NO_INTERRUPTION="NO_INTERRUPTION",(e0=Z||(Z={})).TURN_COVERAGE_UNSPECIFIED="TURN_COVERAGE_UNSPECIFIED",e0.TURN_INCLUDES_ONLY_ACTIVITY="TURN_INCLUDES_ONLY_ACTIVITY",e0.TURN_INCLUDES_ALL_INPUT="TURN_INCLUDES_ALL_INPUT",(e1=Q||(Q={})).SCALE_UNSPECIFIED="SCALE_UNSPECIFIED",e1.C_MAJOR_A_MINOR="C_MAJOR_A_MINOR",e1.D_FLAT_MAJOR_B_FLAT_MINOR="D_FLAT_MAJOR_B_FLAT_MINOR",e1.D_MAJOR_B_MINOR="D_MAJOR_B_MINOR",e1.E_FLAT_MAJOR_C_MINOR="E_FLAT_MAJOR_C_MINOR",e1.E_MAJOR_D_FLAT_MINOR="E_MAJOR_D_FLAT_MINOR",e1.F_MAJOR_D_MINOR="F_MAJOR_D_MINOR",e1.G_FLAT_MAJOR_E_FLAT_MINOR="G_FLAT_MAJOR_E_FLAT_MINOR",e1.G_MAJOR_E_MINOR="G_MAJOR_E_MINOR",e1.A_FLAT_MAJOR_F_MINOR="A_FLAT_MAJOR_F_MINOR",e1.A_MAJOR_G_FLAT_MINOR="A_MAJOR_G_FLAT_MINOR",e1.B_FLAT_MAJOR_G_MINOR="B_FLAT_MAJOR_G_MINOR",e1.B_MAJOR_A_FLAT_MINOR="B_MAJOR_A_FLAT_MINOR",(e6=ee||(ee={})).MUSIC_GENERATION_MODE_UNSPECIFIED="MUSIC_GENERATION_MODE_UNSPECIFIED",e6.QUALITY="QUALITY",e6.DIVERSITY="DIVERSITY",e6.VOCALIZATION="VOCALIZATION",(e4=et||(et={})).PLAYBACK_CONTROL_UNSPECIFIED="PLAYBACK_CONTROL_UNSPECIFIED",e4.PLAY="PLAY",e4.PAUSE="PAUSE",e4.STOP="STOP",e4.RESET_CONTEXT="RESET_CONTEXT";class ti{constructor(e){const t={};for(const n of e.headers.entries())t[n[0]]=n[1];this.headers=t,this.responseInternal=e}json(){return this.responseInternal.json()}}class tl{get text(){var e,t,n,i,l,r,o,a;if((null==(i=null==(n=null==(t=null==(e=this.candidates)?void 0:e[0])?void 0:t.content)?void 0:n.parts)?void 0:i.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning text from the first one.");let s="",u=!1,p=[];for(let e of null!=(a=null==(o=null==(r=null==(l=this.candidates)?void 0:l[0])?void 0:r.content)?void 0:o.parts)?a:[]){for(let[t,n]of Object.entries(e))"text"!==t&&"thought"!==t&&"thoughtSignature"!==t&&(null!==n||void 0!==n)&&p.push(t);if("string"==typeof e.text){if("boolean"==typeof e.thought&&e.thought)continue;u=!0,s+=e.text}}return p.length>0&&console.warn(`there are non-text parts ${p} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),u?s:void 0}get data(){var e,t,n,i,l,r,o,a;if((null==(i=null==(n=null==(t=null==(e=this.candidates)?void 0:e[0])?void 0:t.content)?void 0:n.parts)?void 0:i.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning data from the first one.");let s="",u=[];for(let e of null!=(a=null==(o=null==(r=null==(l=this.candidates)?void 0:l[0])?void 0:r.content)?void 0:o.parts)?a:[]){for(let[t,n]of Object.entries(e))"inlineData"!==t&&(null!==n||void 0!==n)&&u.push(t);e.inlineData&&"string"==typeof e.inlineData.data&&(s+=atob(e.inlineData.data))}return u.length>0&&console.warn(`there are non-data parts ${u} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),s.length>0?btoa(s):void 0}get functionCalls(){var e,t,n,i,l,r,o,a;if((null==(i=null==(n=null==(t=null==(e=this.candidates)?void 0:e[0])?void 0:t.content)?void 0:n.parts)?void 0:i.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning function calls from the first one.");let s=null==(a=null==(o=null==(r=null==(l=this.candidates)?void 0:l[0])?void 0:r.content)?void 0:o.parts)?void 0:a.filter(e=>e.functionCall).map(e=>e.functionCall).filter(e=>void 0!==e);if((null==s?void 0:s.length)!==0)return s}get executableCode(){var e,t,n,i,l,r,o,a,s;if((null==(i=null==(n=null==(t=null==(e=this.candidates)?void 0:e[0])?void 0:t.content)?void 0:n.parts)?void 0:i.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning executable code from the first one.");let u=null==(a=null==(o=null==(r=null==(l=this.candidates)?void 0:l[0])?void 0:r.content)?void 0:o.parts)?void 0:a.filter(e=>e.executableCode).map(e=>e.executableCode).filter(e=>void 0!==e);if((null==u?void 0:u.length)!==0)return null==(s=null==u?void 0:u[0])?void 0:s.code}get codeExecutionResult(){var e,t,n,i,l,r,o,a,s;if((null==(i=null==(n=null==(t=null==(e=this.candidates)?void 0:e[0])?void 0:t.content)?void 0:n.parts)?void 0:i.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning code execution result from the first one.");let u=null==(a=null==(o=null==(r=null==(l=this.candidates)?void 0:l[0])?void 0:r.content)?void 0:o.parts)?void 0:a.filter(e=>e.codeExecutionResult).map(e=>e.codeExecutionResult).filter(e=>void 0!==e);if((null==u?void 0:u.length)!==0)return null==(s=null==u?void 0:u[0])?void 0:s.output}}class tr{}class to{}class ta{}class ts{}class tu{}class tp{}class td{}class tc{}class th{}class tm{}class tf{_fromAPIResponse({apiResponse:e,_isVertexAI:t}){let n,i=new tf;if(t){let t,i,l,r,o,a;t={},null!=(i=te(e,["name"]))&&e7(t,["name"],i),null!=(l=te(e,["metadata"]))&&e7(t,["metadata"],l),null!=(r=te(e,["done"]))&&e7(t,["done"],r),null!=(o=te(e,["error"]))&&e7(t,["error"],o),null!=(a=te(e,["response"]))&&e7(t,["response"],function(e){let t={},n=te(e,["videos"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>{var t;let n,i,l,r,o,a;return n={},null!=(i=te(e,["_self"]))&&e7(n,["video"],(l={},null!=(r=te(t=i,["gcsUri"]))&&e7(l,["uri"],r),null!=(o=te(t,["bytesBase64Encoded"]))&&e7(l,["videoBytes"],tt(o)),null!=(a=te(t,["mimeType"]))&&e7(l,["mimeType"],a),l)),n})),e7(t,["generatedVideos"],e)}let i=te(e,["raiMediaFilteredCount"]);null!=i&&e7(t,["raiMediaFilteredCount"],i);let l=te(e,["raiMediaFilteredReasons"]);return null!=l&&e7(t,["raiMediaFilteredReasons"],l),t}(a)),n=t}else{let t,i,l,r,o,a;t={},null!=(i=te(e,["name"]))&&e7(t,["name"],i),null!=(l=te(e,["metadata"]))&&e7(t,["metadata"],l),null!=(r=te(e,["done"]))&&e7(t,["done"],r),null!=(o=te(e,["error"]))&&e7(t,["error"],o),null!=(a=te(e,["response","generateVideoResponse"]))&&e7(t,["response"],function(e){let t={},n=te(e,["generatedSamples"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>{var t;let n,i,l,r,o,a;return n={},null!=(i=te(e,["video"]))&&e7(n,["video"],(l={},null!=(r=te(t=i,["uri"]))&&e7(l,["uri"],r),null!=(o=te(t,["encodedVideo"]))&&e7(l,["videoBytes"],tt(o)),null!=(a=te(t,["encoding"]))&&e7(l,["mimeType"],a),l)),n})),e7(t,["generatedVideos"],e)}let i=te(e,["raiMediaFilteredCount"]);null!=i&&e7(t,["raiMediaFilteredCount"],i);let l=te(e,["raiMediaFilteredReasons"]);return null!=l&&e7(t,["raiMediaFilteredReasons"],l),t}(a)),n=t}return Object.assign(i,n),i}}class tg{}class ty{}class tE{}class t_{}class tI{}class tT{}class tv{_fromAPIResponse({apiResponse:e,_isVertexAI:t}){var n;let i,l,r,o,a,s,u,p,d,c,h=new tv;return Object.assign(h,(a={},null!=(s=te(e,["name"]))&&e7(a,["name"],s),null!=(u=te(e,["metadata"]))&&e7(a,["metadata"],u),null!=(p=te(e,["done"]))&&e7(a,["done"],p),null!=(d=te(e,["error"]))&&e7(a,["error"],d),null!=(c=te(e,["response"]))&&e7(a,["response"],(i={},null!=(l=te(n=c,["sdkHttpResponse"]))&&e7(i,["sdkHttpResponse"],l),null!=(r=te(n,["parent"]))&&e7(i,["parent"],r),null!=(o=te(n,["documentName"]))&&e7(i,["documentName"],o),i)),a)),h}}class tA{}class tC{}class tS{}class tO{}class tb{get text(){var e,t,n;let i="",l=!1,r=[];for(let o of null!=(n=null==(t=null==(e=this.serverContent)?void 0:e.modelTurn)?void 0:t.parts)?n:[]){for(let[e,t]of Object.entries(o))"text"!==e&&"thought"!==e&&null!==t&&r.push(e);if("string"==typeof o.text){if("boolean"==typeof o.thought&&o.thought)continue;l=!0,i+=o.text}}return 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.`),l?i:void 0}get data(){var e,t,n;let i="",l=[];for(let r of null!=(n=null==(t=null==(e=this.serverContent)?void 0:e.modelTurn)?void 0:t.parts)?n:[]){for(let[e,t]of Object.entries(r))"inlineData"!==e&&null!==t&&l.push(e);r.inlineData&&"string"==typeof r.inlineData.data&&(i+=atob(r.inlineData.data))}return l.length>0&&console.warn(`there are non-data parts ${l} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),i.length>0?btoa(i):void 0}}class tN{get audioChunk(){if(this.serverContent&&this.serverContent.audioChunks&&this.serverContent.audioChunks.length>0)return this.serverContent.audioChunks[0]}}class tR{_fromAPIResponse({apiResponse:e,_isVertexAI:t}){let n=new tR;return Object.assign(n,tn(e)),n}}function tP(e,t){if(!t||"string"!=typeof t)throw Error("model is required and must be a string");if(t.includes("..")||t.includes("?")||t.includes("&"))throw Error("invalid model parameter");if(e.isVertexAI())if(t.startsWith("publishers/")||t.startsWith("projects/")||t.startsWith("models/"))return t;else{if(!(t.indexOf("/")>=0))return`publishers/google/models/${t}`;let e=t.split("/",2);return`publishers/${e[0]}/models/${e[1]}`}return t.startsWith("models/")||t.startsWith("tunedModels/")?t:`models/${t}`}function tD(e,t){let n=tP(e,t);return n?n.startsWith("publishers/")&&e.isVertexAI()?`projects/${e.getProject()}/locations/${e.getLocation()}/${n}`:n.startsWith("models/")&&e.isVertexAI()?`projects/${e.getProject()}/locations/${e.getLocation()}/publishers/google/${n}`:n:""}function tM(e){return Array.isArray(e)?e.map(e=>tw(e)):[tw(e)]}function tw(e){if("object"==typeof e&&null!==e)return e;throw Error(`Could not parse input as Blob. Unsupported blob type: ${typeof e}`)}function tU(e){let t=tw(e);if(t.mimeType&&t.mimeType.startsWith("image/"))return t;throw Error(`Unsupported mime type: ${t.mimeType}`)}function tk(e){let t=tw(e);if(t.mimeType&&t.mimeType.startsWith("audio/"))return t;throw Error(`Unsupported mime type: ${t.mimeType}`)}function tL(e){if(null==e)throw Error("PartUnion is required");if("object"==typeof e)return e;if("string"==typeof e)return{text:e};throw Error(`Unsupported part type: ${typeof e}`)}function tq(e){if(null==e||Array.isArray(e)&&0===e.length)throw Error("PartListUnion is required");return Array.isArray(e)?e.map(e=>tL(e)):[tL(e)]}function tx(e){return null!=e&&"object"==typeof e&&"parts"in e&&Array.isArray(e.parts)}function tG(e){return null!=e&&"object"==typeof e&&"functionCall"in e}function tH(e){return null!=e&&"object"==typeof e&&"functionResponse"in e}function tF(e){if(null==e)throw Error("ContentUnion is required");return tx(e)?e:{role:"user",parts:tq(e)}}function tV(e,t){if(!t)return[];if(e.isVertexAI()&&Array.isArray(t))return t.flatMap(e=>{let t=tF(e);return t.parts&&t.parts.length>0&&void 0!==t.parts[0].text?[t.parts[0].text]:[]});if(e.isVertexAI()){let e=tF(t);return e.parts&&e.parts.length>0&&void 0!==e.parts[0].text?[e.parts[0].text]:[]}return Array.isArray(t)?t.map(e=>tF(e)):[tF(t)]}function tj(e){if(null==e||Array.isArray(e)&&0===e.length)throw Error("contents are required");if(!Array.isArray(e)){if(tG(e)||tH(e))throw Error("To specify functionCall or functionResponse parts, please wrap them in a Content object, specifying the role for them");return[tF(e)]}let t=[],n=[],i=tx(e[0]);for(let l of e){let e=tx(l);if(e!=i)throw Error("Mixing Content and Parts is not supported, please group the parts into a the appropriate Content objects and specify the roles for them");if(e)t.push(l);else if(tG(l)||tH(l))throw Error("To specify functionCall or functionResponse parts, please wrap them, and any other parts, in Content objects as appropriate, specifying the role for them");else n.push(l)}return i||t.push({role:"user",parts:tq(n)}),t}function tB(e){let t={},n=["items"],i=["anyOf"],r=["properties"];if(e.type&&e.anyOf)throw Error("type and anyOf cannot be both populated.");let o=e.anyOf;for(let[a,s]of(null!=o&&2==o.length&&("null"===o[0].type?(t.nullable=!0,e=o[1]):"null"===o[1].type&&(t.nullable=!0,e=o[0])),e.type instanceof Array&&function(e,t){e.includes("null")&&(t.nullable=!0);let n=e.filter(e=>"null"!==e);if(1===n.length)t.type=Object.values(l).includes(n[0].toUpperCase())?n[0].toUpperCase():l.TYPE_UNSPECIFIED;else for(let e of(t.anyOf=[],n))t.anyOf.push({type:Object.values(l).includes(e.toUpperCase())?e.toUpperCase():l.TYPE_UNSPECIFIED})}(e.type,t),Object.entries(e)))if(null!=s)if("type"==a){if("null"===s)throw Error("type: null can not be the only possible type for the field.");if(s instanceof Array)continue;t.type=Object.values(l).includes(s.toUpperCase())?s.toUpperCase():l.TYPE_UNSPECIFIED}else if(n.includes(a))t[a]=tB(s);else if(i.includes(a)){let e=[];for(let n of s){if("null"==n.type){t.nullable=!0;continue}e.push(tB(n))}t[a]=e}else if(r.includes(a)){let e={};for(let[t,n]of Object.entries(s))e[t]=tB(n);t[a]=e}else{if("additionalProperties"===a)continue;t[a]=s}return t}function tJ(e){if("object"==typeof e)return e;if("string"==typeof e)return{voiceConfig:{prebuiltVoiceConfig:{voiceName:e}}};throw Error(`Unsupported speechConfig type: ${typeof e}`)}function tY(e){if("multiSpeakerVoiceConfig"in e)throw Error("multiSpeakerVoiceConfig is not supported in the live API.");return e}function tK(e){if(e.functionDeclarations)for(let t of e.functionDeclarations)t.parameters&&(Object.keys(t.parameters).includes("$schema")?t.parametersJsonSchema||(t.parametersJsonSchema=t.parameters,delete t.parameters):t.parameters=tB(t.parameters)),t.response&&(Object.keys(t.response).includes("$schema")?t.responseJsonSchema||(t.responseJsonSchema=t.response,delete t.response):t.response=tB(t.response));return e}function t$(e){if(null==e)throw Error("tools is required");if(!Array.isArray(e))throw Error("tools is required and must be an array of Tools");let t=[];for(let n of e)t.push(n);return t}function tW(e,t){if("string"!=typeof t)throw Error("name must be a string");return function(e,t,n,i=1){let l=!t.startsWith(`${n}/`)&&t.split("/").length===i;if(e.isVertexAI())if(t.startsWith("projects/"))return t;else if(t.startsWith("locations/"))return`projects/${e.getProject()}/${t}`;else if(t.startsWith(`${n}/`))return`projects/${e.getProject()}/locations/${e.getLocation()}/${t}`;else if(l)return`projects/${e.getProject()}/locations/${e.getLocation()}/${n}/${t}`;else return t;return l?`${n}/${t}`:t}(e,t,"cachedContents")}function tz(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 tX(e){var t;let n;if(null!=e&&"object"==typeof e&&"name"in e&&(n=e.name),null==e||"object"!=typeof e||!("uri"in e)||void 0!==(n=e.uri)){if(null==e||"object"!=typeof e||!("video"in e)||void 0!==(n=null==(t=e.video)?void 0:t.uri)){if("string"==typeof e&&(n=e),void 0===n)throw Error("Could not extract file name from the provided input.");if(n.startsWith("https://")){let e=n.split("files/")[1].match(/[a-z0-9]+/);if(null===e)throw Error(`Could not extract file name from URI ${n}`);n=e[0]}else n.startsWith("files/")&&(n=n.split("files/")[1]);return n}}}function tZ(e,t){return e.isVertexAI()?t?"publishers/google/models":"models":t?"models":"tunedModels"}function tQ(e){for(let i of["models","tunedModels","publisherModels"]){var t,n;if(t=e,n=i,null!==t&&"object"==typeof t&&n in t)return e[i]}return[]}function t0(e,t){let n;if("string"==typeof t)if(e.isVertexAI())if(t.startsWith("gs://"))n={format:"jsonl",gcsUri:[t]};else if(t.startsWith("bq://"))n={format:"bigquery",bigqueryUri:t};else throw Error(`Unsupported string source for Vertex AI: ${t}`);else if(t.startsWith("files/"))n={fileName:t};else throw Error(`Unsupported string source for Gemini API: ${t}`);else if(Array.isArray(t)){if(e.isVertexAI())throw Error("InlinedRequest[] is not supported in Vertex AI.");n={inlinedRequests:t}}else n=t;let i=[n.gcsUri,n.bigqueryUri].filter(Boolean).length,l=[n.inlinedRequests,n.fileName].filter(Boolean).length;if(e.isVertexAI()){if(l>0||1!==i)throw Error("Exactly one of `gcsUri` or `bigqueryUri` must be set for Vertex AI.")}else if(i>0||1!==l)throw Error("Exactly one of `inlinedRequests`, `fileName`, must be set for Gemini API.");return n}function t1(e){if("object"!=typeof e||null===e)return{};let t=e.inlinedResponses;if("object"!=typeof t||null===t)return e;let n=t.inlinedResponses;if(!Array.isArray(n)||0===n.length)return e;let i=!1;for(let e of n){if("object"!=typeof e||null===e)continue;let t=e.response;if("object"==typeof t&&null!==t&&void 0!==t.embedding){i=!0;break}}return i&&(e.inlinedEmbedContentResponses=e.inlinedResponses,delete e.inlinedResponses),e}function t6(e,t){if(!e.isVertexAI()){if(/batches\/[^/]+$/.test(t))return t.split("/").pop();throw Error(`Invalid batch job name: ${t}.`)}if(/^projects\/[^/]+\/locations\/[^/]+\/batchPredictionJobs\/[^/]+$/.test(t))return t.split("/").pop();if(/^\d+$/.test(t))return t;throw Error(`Invalid batch job name: ${t}.`)}function t4(e){if("BATCH_STATE_UNSPECIFIED"===e)return"JOB_STATE_UNSPECIFIED";if("BATCH_STATE_PENDING"===e)return"JOB_STATE_PENDING";if("BATCH_STATE_RUNNING"===e)return"JOB_STATE_RUNNING";if("BATCH_STATE_SUCCEEDED"===e)return"JOB_STATE_SUCCEEDED";if("BATCH_STATE_FAILED"===e)return"JOB_STATE_FAILED";else if("BATCH_STATE_CANCELLED"===e)return"JOB_STATE_CANCELLED";else if("BATCH_STATE_EXPIRED"===e)return"JOB_STATE_EXPIRED";else return e}function t2(e){let t={},n=te(e,["name"]);null!=n&&e7(t,["name"],n);let i=te(e,["metadata","displayName"]);null!=i&&e7(t,["displayName"],i);let l=te(e,["metadata","state"]);null!=l&&e7(t,["state"],t4(l));let r=te(e,["metadata","createTime"]);null!=r&&e7(t,["createTime"],r);let o=te(e,["metadata","endTime"]);null!=o&&e7(t,["endTime"],o);let a=te(e,["metadata","updateTime"]);null!=a&&e7(t,["updateTime"],a);let s=te(e,["metadata","model"]);null!=s&&e7(t,["model"],s);let u=te(e,["metadata","output"]);return null!=u&&e7(t,["dest"],function(e){let t={},n=te(e,["responsesFile"]);null!=n&&e7(t,["fileName"],n);let i=te(e,["inlinedResponses","inlinedResponses"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>{var t;let n,i,l;return n={},null!=(i=te(t=e,["response"]))&&e7(n,["response"],function(e){let t={},n=te(e,["sdkHttpResponse"]);null!=n&&e7(t,["sdkHttpResponse"],n);let i=te(e,["candidates"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>(function(e){let t={},n=te(e,["content"]);null!=n&&e7(t,["content"],n);let i=te(e,["citationMetadata"]);null!=i&&e7(t,["citationMetadata"],function(e){let t={},n=te(e,["citationSources"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>e)),e7(t,["citations"],e)}return t}(i));let l=te(e,["tokenCount"]);null!=l&&e7(t,["tokenCount"],l);let r=te(e,["finishReason"]);null!=r&&e7(t,["finishReason"],r);let o=te(e,["avgLogprobs"]);null!=o&&e7(t,["avgLogprobs"],o);let a=te(e,["groundingMetadata"]);null!=a&&e7(t,["groundingMetadata"],a);let s=te(e,["index"]);null!=s&&e7(t,["index"],s);let u=te(e,["logprobsResult"]);null!=u&&e7(t,["logprobsResult"],u);let p=te(e,["safetyRatings"]);if(null!=p){let e=p;Array.isArray(e)&&(e=e.map(e=>e)),e7(t,["safetyRatings"],e)}let d=te(e,["urlContextMetadata"]);return null!=d&&e7(t,["urlContextMetadata"],d),t})(e))),e7(t,["candidates"],e)}let l=te(e,["modelVersion"]);null!=l&&e7(t,["modelVersion"],l);let r=te(e,["promptFeedback"]);null!=r&&e7(t,["promptFeedback"],r);let o=te(e,["responseId"]);null!=o&&e7(t,["responseId"],o);let a=te(e,["usageMetadata"]);return null!=a&&e7(t,["usageMetadata"],a),t}(i)),null!=(l=te(t,["error"]))&&e7(n,["error"],l),n})),e7(t,["inlinedResponses"],e)}let l=te(e,["inlinedEmbedContentResponses","inlinedResponses"]);if(null!=l){let e=l;Array.isArray(e)&&(e=e.map(e=>e)),e7(t,["inlinedEmbedContentResponses"],e)}return t}(t1(u))),t}function t3(e){var t,n;let i,l,r,o,a,s,u,p,d={},c=te(e,["name"]);null!=c&&e7(d,["name"],c);let h=te(e,["displayName"]);null!=h&&e7(d,["displayName"],h);let m=te(e,["state"]);null!=m&&e7(d,["state"],t4(m));let f=te(e,["error"]);null!=f&&e7(d,["error"],f);let g=te(e,["createTime"]);null!=g&&e7(d,["createTime"],g);let y=te(e,["startTime"]);null!=y&&e7(d,["startTime"],y);let E=te(e,["endTime"]);null!=E&&e7(d,["endTime"],E);let _=te(e,["updateTime"]);null!=_&&e7(d,["updateTime"],_);let I=te(e,["model"]);null!=I&&e7(d,["model"],I);let T=te(e,["inputConfig"]);null!=T&&e7(d,["src"],(i={},null!=(l=te(n=T,["instancesFormat"]))&&e7(i,["format"],l),null!=(r=te(n,["gcsSource","uris"]))&&e7(i,["gcsUri"],r),null!=(o=te(n,["bigquerySource","inputUri"]))&&e7(i,["bigqueryUri"],o),i));let v=te(e,["outputConfig"]);null!=v&&e7(d,["dest"],(t=t1(v),a={},null!=(s=te(t,["predictionsFormat"]))&&e7(a,["format"],s),null!=(u=te(t,["gcsDestination","outputUriPrefix"]))&&e7(a,["gcsUri"],u),null!=(p=te(t,["bigqueryDestination","outputUri"]))&&e7(a,["bigqueryUri"],p),a));let A=te(e,["completionStats"]);return null!=A&&e7(d,["completionStats"],A),d}function t9(e){let t={},n=te(e,["parts"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>{var t;let n,i,l,r,o,a,s,u,p,d,c,h;return n={},null!=(i=te(t=e,["mediaResolution"]))&&e7(n,["mediaResolution"],i),null!=(l=te(t,["codeExecutionResult"]))&&e7(n,["codeExecutionResult"],l),null!=(r=te(t,["executableCode"]))&&e7(n,["executableCode"],r),null!=(o=te(t,["fileData"]))&&e7(n,["fileData"],function(e){let t={};if(void 0!==te(e,["displayName"]))throw Error("displayName parameter is not supported in Gemini API.");let n=te(e,["fileUri"]);null!=n&&e7(t,["fileUri"],n);let i=te(e,["mimeType"]);return null!=i&&e7(t,["mimeType"],i),t}(o)),null!=(a=te(t,["functionCall"]))&&e7(n,["functionCall"],function(e){let t={},n=te(e,["id"]);null!=n&&e7(t,["id"],n);let i=te(e,["args"]);null!=i&&e7(t,["args"],i);let l=te(e,["name"]);if(null!=l&&e7(t,["name"],l),void 0!==te(e,["partialArgs"]))throw Error("partialArgs parameter is not supported in Gemini API.");if(void 0!==te(e,["willContinue"]))throw Error("willContinue parameter is not supported in Gemini API.");return t}(a)),null!=(s=te(t,["functionResponse"]))&&e7(n,["functionResponse"],s),null!=(u=te(t,["inlineData"]))&&e7(n,["inlineData"],function(e){let t={},n=te(e,["data"]);if(null!=n&&e7(t,["data"],n),void 0!==te(e,["displayName"]))throw Error("displayName parameter is not supported in Gemini API.");let i=te(e,["mimeType"]);return null!=i&&e7(t,["mimeType"],i),t}(u)),null!=(p=te(t,["text"]))&&e7(n,["text"],p),null!=(d=te(t,["thought"]))&&e7(n,["thought"],d),null!=(c=te(t,["thoughtSignature"]))&&e7(n,["thoughtSignature"],c),null!=(h=te(t,["videoMetadata"]))&&e7(n,["videoMetadata"],h),n})),e7(t,["parts"],e)}let i=te(e,["role"]);return null!=i&&e7(t,["role"],i),t}function t5(e,t){let n={},i=te(t,["model"]);null!=i&&e7(n,["_url","model"],tP(e,i));let l=te(t,["src"]);null!=l&&e7(n,["batch","inputConfig"],function(e,t){let n={};if(void 0!==te(t,["format"]))throw Error("format parameter is not supported in Gemini API.");if(void 0!==te(t,["gcsUri"]))throw Error("gcsUri parameter is not supported in Gemini API.");if(void 0!==te(t,["bigqueryUri"]))throw Error("bigqueryUri parameter is not supported in Gemini API.");let i=te(t,["fileName"]);null!=i&&e7(n,["fileName"],i);let l=te(t,["inlinedRequests"]);if(null!=l){let t=l;Array.isArray(t)&&(t=t.map(t=>(function(e,t){let n={},i=te(t,["model"]);null!=i&&e7(n,["request","model"],tP(e,i));let l=te(t,["contents"]);if(null!=l){let e=tj(l);Array.isArray(e)&&(e=e.map(e=>t9(e))),e7(n,["request","contents"],e)}let r=te(t,["metadata"]);null!=r&&e7(n,["metadata"],r);let o=te(t,["config"]);return null!=o&&e7(n,["request","generationConfig"],function(e,t,n){var i;let l,r,o,a={},s=te(t,["systemInstruction"]);void 0!==n&&null!=s&&e7(n,["systemInstruction"],t9(tF(s)));let u=te(t,["temperature"]);null!=u&&e7(a,["temperature"],u);let p=te(t,["topP"]);null!=p&&e7(a,["topP"],p);let d=te(t,["topK"]);null!=d&&e7(a,["topK"],d);let c=te(t,["candidateCount"]);null!=c&&e7(a,["candidateCount"],c);let h=te(t,["maxOutputTokens"]);null!=h&&e7(a,["maxOutputTokens"],h);let m=te(t,["stopSequences"]);null!=m&&e7(a,["stopSequences"],m);let f=te(t,["responseLogprobs"]);null!=f&&e7(a,["responseLogprobs"],f);let g=te(t,["logprobs"]);null!=g&&e7(a,["logprobs"],g);let y=te(t,["presencePenalty"]);null!=y&&e7(a,["presencePenalty"],y);let E=te(t,["frequencyPenalty"]);null!=E&&e7(a,["frequencyPenalty"],E);let _=te(t,["seed"]);null!=_&&e7(a,["seed"],_);let I=te(t,["responseMimeType"]);null!=I&&e7(a,["responseMimeType"],I);let T=te(t,["responseSchema"]);null!=T&&e7(a,["responseSchema"],tB(T));let v=te(t,["responseJsonSchema"]);if(null!=v&&e7(a,["responseJsonSchema"],v),void 0!==te(t,["routingConfig"]))throw Error("routingConfig parameter is not supported in Gemini API.");if(void 0!==te(t,["modelSelectionConfig"]))throw Error("modelSelectionConfig parameter is not supported in Gemini API.");let A=te(t,["safetySettings"]);if(void 0!==n&&null!=A){let e=A;Array.isArray(e)&&(e=e.map(e=>(function(e){let t={},n=te(e,["category"]);if(null!=n&&e7(t,["category"],n),void 0!==te(e,["method"]))throw Error("method parameter is not supported in Gemini API.");let i=te(e,["threshold"]);return null!=i&&e7(t,["threshold"],i),t})(e))),e7(n,["safetySettings"],e)}let C=te(t,["tools"]);if(void 0!==n&&null!=C){let e=t$(C);Array.isArray(e)&&(e=e.map(e=>(function(e){let t={},n=te(e,["functionDeclarations"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>e)),e7(t,["functionDeclarations"],e)}if(void 0!==te(e,["retrieval"]))throw Error("retrieval parameter is not supported in Gemini API.");let i=te(e,["googleSearchRetrieval"]);null!=i&&e7(t,["googleSearchRetrieval"],i);let l=te(e,["computerUse"]);null!=l&&e7(t,["computerUse"],l);let r=te(e,["fileSearch"]);null!=r&&e7(t,["fileSearch"],r);let o=te(e,["codeExecution"]);if(null!=o&&e7(t,["codeExecution"],o),void 0!==te(e,["enterpriseWebSearch"]))throw Error("enterpriseWebSearch parameter is not supported in Gemini API.");let a=te(e,["googleMaps"]);null!=a&&e7(t,["googleMaps"],function(e){let t={};if(void 0!==te(e,["authConfig"]))throw Error("authConfig parameter is not supported in Gemini API.");let n=te(e,["enableWidget"]);return null!=n&&e7(t,["enableWidget"],n),t}(a));let s=te(e,["googleSearch"]);null!=s&&e7(t,["googleSearch"],function(e){let t={};if(void 0!==te(e,["excludeDomains"]))throw Error("excludeDomains parameter is not supported in Gemini API.");if(void 0!==te(e,["blockingConfidence"]))throw Error("blockingConfidence parameter is not supported in Gemini API.");let n=te(e,["timeRangeFilter"]);return null!=n&&e7(t,["timeRangeFilter"],n),t}(s));let u=te(e,["urlContext"]);return null!=u&&e7(t,["urlContext"],u),t})(tK(e)))),e7(n,["tools"],e)}let S=te(t,["toolConfig"]);if(void 0!==n&&null!=S&&e7(n,["toolConfig"],(l={},null!=(r=te(i=S,["functionCallingConfig"]))&&e7(l,["functionCallingConfig"],function(e){let t={},n=te(e,["mode"]);null!=n&&e7(t,["mode"],n);let i=te(e,["allowedFunctionNames"]);if(null!=i&&e7(t,["allowedFunctionNames"],i),void 0!==te(e,["streamFunctionCallArguments"]))throw Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return t}(r)),null!=(o=te(i,["retrievalConfig"]))&&e7(l,["retrievalConfig"],o),l)),void 0!==te(t,["labels"]))throw Error("labels parameter is not supported in Gemini API.");let O=te(t,["cachedContent"]);void 0!==n&&null!=O&&e7(n,["cachedContent"],tW(e,O));let b=te(t,["responseModalities"]);null!=b&&e7(a,["responseModalities"],b);let N=te(t,["mediaResolution"]);null!=N&&e7(a,["mediaResolution"],N);let R=te(t,["speechConfig"]);if(null!=R&&e7(a,["speechConfig"],tJ(R)),void 0!==te(t,["audioTimestamp"]))throw Error("audioTimestamp parameter is not supported in Gemini API.");let P=te(t,["thinkingConfig"]);null!=P&&e7(a,["thinkingConfig"],P);let D=te(t,["imageConfig"]);return null!=D&&e7(a,["imageConfig"],function(e){let t={},n=te(e,["aspectRatio"]);null!=n&&e7(t,["aspectRatio"],n);let i=te(e,["imageSize"]);if(null!=i&&e7(t,["imageSize"],i),void 0!==te(e,["outputMimeType"]))throw Error("outputMimeType parameter is not supported in Gemini API.");if(void 0!==te(e,["outputCompressionQuality"]))throw Error("outputCompressionQuality parameter is not supported in Gemini API.");return t}(D)),a}(e,o,te(n,["request"],{}))),n})(e,t))),e7(n,["requests","requests"],t)}return n}(e,t0(e,l)));let r=te(t,["config"]);return null!=r&&function(e,t){let n=te(e,["displayName"]);if(void 0!==t&&null!=n&&e7(t,["batch","displayName"],n),void 0!==te(e,["dest"]))throw Error("dest parameter is not supported in Gemini API.")}(r,n),n}(e2=en||(en={})).PAGED_ITEM_BATCH_JOBS="batchJobs",e2.PAGED_ITEM_MODELS="models",e2.PAGED_ITEM_TUNING_JOBS="tuningJobs",e2.PAGED_ITEM_FILES="files",e2.PAGED_ITEM_CACHED_CONTENTS="cachedContents",e2.PAGED_ITEM_FILE_SEARCH_STORES="fileSearchStores",e2.PAGED_ITEM_DOCUMENTS="documents";class t8{constructor(e,t,n,i){this.pageInternal=[],this.paramsInternal={},this.requestInternal=t,this.init(e,n,i)}init(e,t,n){var i,l;this.nameInternal=e,this.pageInternal=t[this.nameInternal]||[],this.sdkHttpResponseInternal=null==t?void 0:t.sdkHttpResponse,this.idxInternal=0;let r={config:{}};(r=n&&0!==Object.keys(n).length?"object"==typeof n?Object.assign({},n):n:{config:{}}).config&&(r.config.pageToken=t.nextPageToken),this.paramsInternal=r,this.pageInternalSize=null!=(l=null==(i=r.config)?void 0:i.pageSize)?l:this.pageInternal.length}initNextPage(e){this.init(this.nameInternal,e,this.paramsInternal)}get page(){return this.pageInternal}get name(){return this.nameInternal}get pageSize(){return this.pageInternalSize}get sdkHttpResponse(){return this.sdkHttpResponseInternal}get params(){return this.paramsInternal}get pageLength(){return this.pageInternal.length}getItem(e){return this.pageInternal[e]}[Symbol.asyncIterator](){return{next:async()=>{if(this.idxInternal>=this.pageLength)if(!this.hasNextPage())return{value:void 0,done:!0};else await this.nextPage();let e=this.getItem(this.idxInternal);return this.idxInternal+=1,{value:e,done:!1}},return:async()=>({value:void 0,done:!0})}}async nextPage(){if(!this.hasNextPage())throw Error("No more pages to fetch.");let e=await this.requestInternal(this.params);return this.initNextPage(e),this.page}hasNextPage(){var e;return(null==(e=this.params.config)?void 0:e.pageToken)!==void 0}}class t7 extends e5{constructor(e){super(),this.apiClient=e,this.create=async e=>(this.apiClient.isVertexAI()&&(e.config=this.formatDestination(e.src,e.config)),this.createInternal(e)),this.createEmbeddings=async e=>{if(console.warn("batches.createEmbeddings() is experimental and may change without notice."),this.apiClient.isVertexAI())throw Error("Vertex AI does not support batches.createEmbeddings.");return this.createEmbeddingsInternal(e)},this.list=async(e={})=>new t8(en.PAGED_ITEM_BATCH_JOBS,e=>this.listInternal(e),await this.listInternal(e),e)}createInlinedGenerateContentRequest(e){let t=t5(this.apiClient,e),n=e8("{model}:batchGenerateContent",t._url),i=t.batch.inputConfig.requests,l=i.requests,r=[];for(let e of l){let t=Object.assign({},e);if(t.systemInstruction){let e=t.systemInstruction;delete t.systemInstruction;let n=t.request;n.systemInstruction=e,t.request=n}r.push(t)}return i.requests=r,delete t.config,delete t._url,delete t._query,{path:n,body:t}}getGcsUri(e){return"string"==typeof e?e.startsWith("gs://")?e:void 0:!Array.isArray(e)&&e.gcsUri&&e.gcsUri.length>0?e.gcsUri[0]:void 0}getBigqueryUri(e){return"string"==typeof e?e.startsWith("bq://")?e:void 0:Array.isArray(e)?void 0:e.bigqueryUri}formatDestination(e,t){let n=t?Object.assign({},t):{},i=Date.now().toString();if(n.displayName||(n.displayName=`genaiBatchJob_${i}`),void 0===n.dest){let t=this.getGcsUri(e),l=this.getBigqueryUri(e);if(t)t.endsWith(".jsonl")?n.dest=`${t.slice(0,-6)}/dest`:n.dest=`${t}_dest_${i}`;else if(l)n.dest=`${l}_dest_${i}`;else throw Error("Unsupported source for Vertex AI: No GCS or BigQuery URI found.")}return n}async createInternal(e){var t,n,i,l,r;let o="",a={};if(this.apiClient.isVertexAI()){let i,l,s,u,p,d,c=(r=this.apiClient,i={},null!=(l=te(e,["model"]))&&e7(i,["model"],tP(r,l)),null!=(s=te(e,["src"]))&&e7(i,["inputConfig"],function(e){let t={},n=te(e,["format"]);null!=n&&e7(t,["instancesFormat"],n);let i=te(e,["gcsUri"]);null!=i&&e7(t,["gcsSource","uris"],i);let l=te(e,["bigqueryUri"]);if(null!=l&&e7(t,["bigquerySource","inputUri"],l),void 0!==te(e,["fileName"]))throw Error("fileName parameter is not supported in Vertex AI.");if(void 0!==te(e,["inlinedRequests"]))throw Error("inlinedRequests parameter is not supported in Vertex AI.");return t}(t0(r,s))),null!=(u=te(e,["config"]))&&(p=te(u,["displayName"]),void 0!==i&&null!=p&&e7(i,["displayName"],p),d=te(u,["dest"]),void 0!==i&&null!=d&&e7(i,["outputConfig"],function(e){let t={},n=te(e,["format"]);null!=n&&e7(t,["predictionsFormat"],n);let i=te(e,["gcsUri"]);null!=i&&e7(t,["gcsDestination","outputUriPrefix"],i);let l=te(e,["bigqueryUri"]);if(null!=l&&e7(t,["bigqueryDestination","outputUri"],l),void 0!==te(e,["fileName"]))throw Error("fileName parameter is not supported in Vertex AI.");if(void 0!==te(e,["inlinedResponses"]))throw Error("inlinedResponses parameter is not supported in Vertex AI.");if(void 0!==te(e,["inlinedEmbedContentResponses"]))throw Error("inlinedEmbedContentResponses parameter is not supported in Vertex AI.");return t}(function(e){if("string"!=typeof e)return e;if(e.startsWith("gs://"))return{format:"jsonl",gcsUri:e};if(e.startsWith("bq://"))return{format:"bigquery",bigqueryUri:e};throw Error(`Unsupported destination: ${e}`)}(d)))),i);return o=e8("batchPredictionJobs",c._url),a=c._query,delete c._url,delete c._query,this.apiClient.request({path:o,queryParams:a,body:JSON.stringify(c),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>t3(e))}{let t=t5(this.apiClient,e);return o=e8("{model}:batchGenerateContent",t._url),a=t._query,delete t._url,delete t._query,this.apiClient.request({path:o,queryParams:a,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(l=e.config)?void 0:l.abortSignal}).then(e=>e.json()).then(e=>t2(e))}}async createEmbeddingsInternal(e){var t,n,i,l,r;let o="",a={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let s,u,p,d,c,h,m,f,g=(i=this.apiClient,d={},null!=(c=te(e,["model"]))&&e7(d,["_url","model"],tP(i,c)),null!=(h=te(e,["src"]))&&e7(d,["batch","inputConfig"],(l=i,s={},null!=(u=te(r=h,["fileName"]))&&e7(s,["file_name"],u),null!=(p=te(r,["inlinedRequests"]))&&e7(s,["requests"],function(e,t){let n={},i=te(t,["contents"]);if(null!=i){let t=tV(e,i);Array.isArray(t)&&(t=t.map(e=>e)),e7(n,["requests[]","request","content"],t)}let l=te(t,["config"]);return null!=l&&(e7(n,["_self"],function(e,t){let n=te(e,["taskType"]);void 0!==t&&null!=n&&e7(t,["requests[]","taskType"],n);let i=te(e,["title"]);void 0!==t&&null!=i&&e7(t,["requests[]","title"],i);let l=te(e,["outputDimensionality"]);if(void 0!==t&&null!=l&&e7(t,["requests[]","outputDimensionality"],l),void 0!==te(e,["mimeType"]))throw Error("mimeType parameter is not supported in Gemini API.");if(void 0!==te(e,["autoTruncate"]))throw Error("autoTruncate parameter is not supported in Gemini API.");return{}}(l,n)),!function(e,t){for(let[n,i]of Object.entries(t)){let t=n.split("."),l=i.split("."),r=new Set,o=-1;for(let e=0;e<t.length;e++)if("*"===t[e]){o=e;break}if(-1!==o&&l.length>o)for(let e=o;e<l.length;e++){let t=l[e];"*"===t||t.endsWith("[]")||t.endsWith("[0]")||r.add(t)}!function e(t,n,i,l,r){if(l>=n.length||"object"!=typeof t||null===t)return;let o=n[l];if(o.endsWith("[]")){let a=o.slice(0,-2);if(a in t&&Array.isArray(t[a]))for(let o of t[a])e(o,n,i,l+1,r)}else if("*"===o){if("object"==typeof t&&null!==t&&!Array.isArray(t)){let e=Object.keys(t).filter(e=>!e.startsWith("_")&&!r.has(e)),n={};for(let i of e)n[i]=t[i];for(let[e,r]of Object.entries(n)){let n=[];for(let t of i.slice(l))"*"===t?n.push(e):n.push(t);e7(t,n,r)}for(let n of e)delete t[n]}}else o in t&&e(t[o],n,i,l+1,r)}(e,t,l,0,r)}}(n,{"requests[].*":"requests[].request.*"})),n}(l,p)),s)),null!=(m=te(e,["config"]))&&(f=te(m,["displayName"]),void 0!==d&&null!=f&&e7(d,["batch","displayName"],f)),d);return o=e8("{model}:asyncBatchEmbedContent",g._url),a=g._query,delete g._url,delete g._query,this.apiClient.request({path:o,queryParams:a,body:JSON.stringify(g),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>t2(e))}}async get(e){var t,n,i,l,r,o;let a="",s={};if(this.apiClient.isVertexAI()){let i,l,o=(r=this.apiClient,i={},null!=(l=te(e,["name"]))&&e7(i,["_url","name"],t6(r,l)),i);return a=e8("batchPredictionJobs/{name}",o._url),s=o._query,delete o._url,delete o._query,this.apiClient.request({path:a,queryParams:s,body:JSON.stringify(o),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>t3(e))}{let t,n,r=(o=this.apiClient,t={},null!=(n=te(e,["name"]))&&e7(t,["_url","name"],t6(o,n)),t);return a=e8("batches/{name}",r._url),s=r._query,delete r._url,delete r._query,this.apiClient.request({path:a,queryParams:s,body:JSON.stringify(r),httpMethod:"GET",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(l=e.config)?void 0:l.abortSignal}).then(e=>e.json()).then(e=>t2(e))}}async cancel(e){var t,n,i,l,r,o;let a="",s={};if(this.apiClient.isVertexAI()){let i,l,o=(r=this.apiClient,i={},null!=(l=te(e,["name"]))&&e7(i,["_url","name"],t6(r,l)),i);a=e8("batchPredictionJobs/{name}:cancel",o._url),s=o._query,delete o._url,delete o._query,await this.apiClient.request({path:a,queryParams:s,body:JSON.stringify(o),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal})}else{let t,n,r=(o=this.apiClient,t={},null!=(n=te(e,["name"]))&&e7(t,["_url","name"],t6(o,n)),t);a=e8("batches/{name}:cancel",r._url),s=r._query,delete r._url,delete r._query,await this.apiClient.request({path:a,queryParams:s,body:JSON.stringify(r),httpMethod:"POST",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(l=e.config)?void 0:l.abortSignal})}}async listInternal(e){var t,n,i,l;let r="",o={};if(this.apiClient.isVertexAI()){let i,l,a,s,u,p=(i={},null!=(l=te(e,["config"]))&&(a=te(l,["pageSize"]),void 0!==i&&null!=a&&e7(i,["_query","pageSize"],a),s=te(l,["pageToken"]),void 0!==i&&null!=s&&e7(i,["_query","pageToken"],s),u=te(l,["filter"]),void 0!==i&&null!=u&&e7(i,["_query","filter"],u)),i);return r=e8("batchPredictionJobs",p._url),o=p._query,delete p._url,delete p._query,this.apiClient.request({path:r,queryParams:o,body:JSON.stringify(p),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=function(e){let t={},n=te(e,["sdkHttpResponse"]);null!=n&&e7(t,["sdkHttpResponse"],n);let i=te(e,["nextPageToken"]);null!=i&&e7(t,["nextPageToken"],i);let l=te(e,["batchPredictionJobs"]);if(null!=l){let e=l;Array.isArray(e)&&(e=e.map(e=>t3(e))),e7(t,["batchJobs"],e)}return t}(e),n=new tO;return Object.assign(n,t),n})}{let t,n,a=(t={},null!=(n=te(e,["config"]))&&function(e,t){let n=te(e,["pageSize"]);void 0!==t&&null!=n&&e7(t,["_query","pageSize"],n);let i=te(e,["pageToken"]);if(void 0!==t&&null!=i&&e7(t,["_query","pageToken"],i),void 0!==te(e,["filter"]))throw Error("filter parameter is not supported in Gemini API.")}(n,t),t);return r=e8("batches",a._url),o=a._query,delete a._url,delete a._query,this.apiClient.request({path:r,queryParams:o,body:JSON.stringify(a),httpMethod:"GET",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(l=e.config)?void 0:l.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=function(e){let t={},n=te(e,["sdkHttpResponse"]);null!=n&&e7(t,["sdkHttpResponse"],n);let i=te(e,["nextPageToken"]);null!=i&&e7(t,["nextPageToken"],i);let l=te(e,["operations"]);if(null!=l){let e=l;Array.isArray(e)&&(e=e.map(e=>t2(e))),e7(t,["batchJobs"],e)}return t}(e),n=new tO;return Object.assign(n,t),n})}}async delete(e){var t,n,i,l,r,o;let a="",s={};if(this.apiClient.isVertexAI()){let i,l,o=(r=this.apiClient,i={},null!=(l=te(e,["name"]))&&e7(i,["_url","name"],t6(r,l)),i);return a=e8("batchPredictionJobs/{name}",o._url),s=o._query,delete o._url,delete o._query,this.apiClient.request({path:a,queryParams:s,body:JSON.stringify(o),httpMethod:"DELETE",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t,n,i,l,r;return t={},null!=(n=te(e,["sdkHttpResponse"]))&&e7(t,["sdkHttpResponse"],n),null!=(i=te(e,["name"]))&&e7(t,["name"],i),null!=(l=te(e,["done"]))&&e7(t,["done"],l),null!=(r=te(e,["error"]))&&e7(t,["error"],r),t})}{let t,n,r=(o=this.apiClient,t={},null!=(n=te(e,["name"]))&&e7(t,["_url","name"],t6(o,n)),t);return a=e8("batches/{name}",r._url),s=r._query,delete r._url,delete r._query,this.apiClient.request({path:a,queryParams:s,body:JSON.stringify(r),httpMethod:"DELETE",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(l=e.config)?void 0:l.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t,n,i,l,r;return t={},null!=(n=te(e,["sdkHttpResponse"]))&&e7(t,["sdkHttpResponse"],n),null!=(i=te(e,["name"]))&&e7(t,["name"],i),null!=(l=te(e,["done"]))&&e7(t,["done"],l),null!=(r=te(e,["error"]))&&e7(t,["error"],r),t})}}}function ne(e){let t={},n=te(e,["parts"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>{var t;let n,i,l,r,o,a,s,u,p,d,c,h;return n={},null!=(i=te(t=e,["mediaResolution"]))&&e7(n,["mediaResolution"],i),null!=(l=te(t,["codeExecutionResult"]))&&e7(n,["codeExecutionResult"],l),null!=(r=te(t,["executableCode"]))&&e7(n,["executableCode"],r),null!=(o=te(t,["fileData"]))&&e7(n,["fileData"],function(e){let t={};if(void 0!==te(e,["displayName"]))throw Error("displayName parameter is not supported in Gemini API.");let n=te(e,["fileUri"]);null!=n&&e7(t,["fileUri"],n);let i=te(e,["mimeType"]);return null!=i&&e7(t,["mimeType"],i),t}(o)),null!=(a=te(t,["functionCall"]))&&e7(n,["functionCall"],function(e){let t={},n=te(e,["id"]);null!=n&&e7(t,["id"],n);let i=te(e,["args"]);null!=i&&e7(t,["args"],i);let l=te(e,["name"]);if(null!=l&&e7(t,["name"],l),void 0!==te(e,["partialArgs"]))throw Error("partialArgs parameter is not supported in Gemini API.");if(void 0!==te(e,["willContinue"]))throw Error("willContinue parameter is not supported in Gemini API.");return t}(a)),null!=(s=te(t,["functionResponse"]))&&e7(n,["functionResponse"],s),null!=(u=te(t,["inlineData"]))&&e7(n,["inlineData"],function(e){let t={},n=te(e,["data"]);if(null!=n&&e7(t,["data"],n),void 0!==te(e,["displayName"]))throw Error("displayName parameter is not supported in Gemini API.");let i=te(e,["mimeType"]);return null!=i&&e7(t,["mimeType"],i),t}(u)),null!=(p=te(t,["text"]))&&e7(n,["text"],p),null!=(d=te(t,["thought"]))&&e7(n,["thought"],d),null!=(c=te(t,["thoughtSignature"]))&&e7(n,["thoughtSignature"],c),null!=(h=te(t,["videoMetadata"]))&&e7(n,["videoMetadata"],h),n})),e7(t,["parts"],e)}let i=te(e,["role"]);return null!=i&&e7(t,["role"],i),t}class nt extends e5{constructor(e){super(),this.apiClient=e,this.list=async(e={})=>new t8(en.PAGED_ITEM_CACHED_CONTENTS,e=>this.listInternal(e),await this.listInternal(e),e)}async create(e){var t,n,i,l,r,o;let a="",s={};if(this.apiClient.isVertexAI()){let i,l,o,u=(r=this.apiClient,i={},null!=(l=te(e,["model"]))&&e7(i,["model"],tD(r,l)),null!=(o=te(e,["config"]))&&function(e,t){let n=te(e,["ttl"]);void 0!==t&&null!=n&&e7(t,["ttl"],n);let i=te(e,["expireTime"]);void 0!==t&&null!=i&&e7(t,["expireTime"],i);let l=te(e,["displayName"]);void 0!==t&&null!=l&&e7(t,["displayName"],l);let r=te(e,["contents"]);if(void 0!==t&&null!=r){let e=tj(r);Array.isArray(e)&&(e=e.map(e=>e)),e7(t,["contents"],e)}let o=te(e,["systemInstruction"]);void 0!==t&&null!=o&&e7(t,["systemInstruction"],tF(o));let a=te(e,["tools"]);if(void 0!==t&&null!=a){let e=a;Array.isArray(e)&&(e=e.map(e=>(function(e){let t={},n=te(e,["functionDeclarations"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>(function(e){let t={};if(void 0!==te(e,["behavior"]))throw Error("behavior parameter is not supported in Vertex AI.");let n=te(e,["description"]);null!=n&&e7(t,["description"],n);let i=te(e,["name"]);null!=i&&e7(t,["name"],i);let l=te(e,["parameters"]);null!=l&&e7(t,["parameters"],l);let r=te(e,["parametersJsonSchema"]);null!=r&&e7(t,["parametersJsonSchema"],r);let o=te(e,["response"]);null!=o&&e7(t,["response"],o);let a=te(e,["responseJsonSchema"]);return null!=a&&e7(t,["responseJsonSchema"],a),t})(e))),e7(t,["functionDeclarations"],e)}let i=te(e,["retrieval"]);null!=i&&e7(t,["retrieval"],i);let l=te(e,["googleSearchRetrieval"]);null!=l&&e7(t,["googleSearchRetrieval"],l);let r=te(e,["computerUse"]);if(null!=r&&e7(t,["computerUse"],r),void 0!==te(e,["fileSearch"]))throw Error("fileSearch parameter is not supported in Vertex AI.");let o=te(e,["codeExecution"]);null!=o&&e7(t,["codeExecution"],o);let a=te(e,["enterpriseWebSearch"]);null!=a&&e7(t,["enterpriseWebSearch"],a);let s=te(e,["googleMaps"]);null!=s&&e7(t,["googleMaps"],s);let u=te(e,["googleSearch"]);null!=u&&e7(t,["googleSearch"],u);let p=te(e,["urlContext"]);return null!=p&&e7(t,["urlContext"],p),t})(e))),e7(t,["tools"],e)}let s=te(e,["toolConfig"]);void 0!==t&&null!=s&&e7(t,["toolConfig"],s);let u=te(e,["kmsKeyName"]);void 0!==t&&null!=u&&e7(t,["encryption_spec","kmsKeyName"],u)}(o,i),i);return a=e8("cachedContents",u._url),s=u._query,delete u._url,delete u._query,this.apiClient.request({path:a,queryParams:s,body:JSON.stringify(u),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>e)}{let t,n,r,u=(o=this.apiClient,t={},null!=(n=te(e,["model"]))&&e7(t,["model"],tD(o,n)),null!=(r=te(e,["config"]))&&function(e,t){var n;let i,l,r,o=te(e,["ttl"]);void 0!==t&&null!=o&&e7(t,["ttl"],o);let a=te(e,["expireTime"]);void 0!==t&&null!=a&&e7(t,["expireTime"],a);let s=te(e,["displayName"]);void 0!==t&&null!=s&&e7(t,["displayName"],s);let u=te(e,["contents"]);if(void 0!==t&&null!=u){let e=tj(u);Array.isArray(e)&&(e=e.map(e=>ne(e))),e7(t,["contents"],e)}let p=te(e,["systemInstruction"]);void 0!==t&&null!=p&&e7(t,["systemInstruction"],ne(tF(p)));let d=te(e,["tools"]);if(void 0!==t&&null!=d){let e=d;Array.isArray(e)&&(e=e.map(e=>(function(e){let t={},n=te(e,["functionDeclarations"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>e)),e7(t,["functionDeclarations"],e)}if(void 0!==te(e,["retrieval"]))throw Error("retrieval parameter is not supported in Gemini API.");let i=te(e,["googleSearchRetrieval"]);null!=i&&e7(t,["googleSearchRetrieval"],i);let l=te(e,["computerUse"]);null!=l&&e7(t,["computerUse"],l);let r=te(e,["fileSearch"]);null!=r&&e7(t,["fileSearch"],r);let o=te(e,["codeExecution"]);if(null!=o&&e7(t,["codeExecution"],o),void 0!==te(e,["enterpriseWebSearch"]))throw Error("enterpriseWebSearch parameter is not supported in Gemini API.");let a=te(e,["googleMaps"]);null!=a&&e7(t,["googleMaps"],function(e){let t={};if(void 0!==te(e,["authConfig"]))throw Error("authConfig parameter is not supported in Gemini API.");let n=te(e,["enableWidget"]);return null!=n&&e7(t,["enableWidget"],n),t}(a));let s=te(e,["googleSearch"]);null!=s&&e7(t,["googleSearch"],function(e){let t={};if(void 0!==te(e,["excludeDomains"]))throw Error("excludeDomains parameter is not supported in Gemini API.");if(void 0!==te(e,["blockingConfidence"]))throw Error("blockingConfidence parameter is not supported in Gemini API.");let n=te(e,["timeRangeFilter"]);return null!=n&&e7(t,["timeRangeFilter"],n),t}(s));let u=te(e,["urlContext"]);return null!=u&&e7(t,["urlContext"],u),t})(e))),e7(t,["tools"],e)}let c=te(e,["toolConfig"]);if(void 0!==t&&null!=c&&e7(t,["toolConfig"],(i={},null!=(l=te(n=c,["functionCallingConfig"]))&&e7(i,["functionCallingConfig"],function(e){let t={},n=te(e,["mode"]);null!=n&&e7(t,["mode"],n);let i=te(e,["allowedFunctionNames"]);if(null!=i&&e7(t,["allowedFunctionNames"],i),void 0!==te(e,["streamFunctionCallArguments"]))throw Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return t}(l)),null!=(r=te(n,["retrievalConfig"]))&&e7(i,["retrievalConfig"],r),i)),void 0!==te(e,["kmsKeyName"]))throw Error("kmsKeyName parameter is not supported in Gemini API.")}(r,t),t);return a=e8("cachedContents",u._url),s=u._query,delete u._url,delete u._query,this.apiClient.request({path:a,queryParams:s,body:JSON.stringify(u),httpMethod:"POST",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(l=e.config)?void 0:l.abortSignal}).then(e=>e.json()).then(e=>e)}}async get(e){var t,n,i,l,r,o;let a="",s={};if(this.apiClient.isVertexAI()){let i,l,o=(r=this.apiClient,i={},null!=(l=te(e,["name"]))&&e7(i,["_url","name"],tW(r,l)),i);return a=e8("{name}",o._url),s=o._query,delete o._url,delete o._query,this.apiClient.request({path:a,queryParams:s,body:JSON.stringify(o),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>e)}{let t,n,r=(o=this.apiClient,t={},null!=(n=te(e,["name"]))&&e7(t,["_url","name"],tW(o,n)),t);return a=e8("{name}",r._url),s=r._query,delete r._url,delete r._query,this.apiClient.request({path:a,queryParams:s,body:JSON.stringify(r),httpMethod:"GET",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(l=e.config)?void 0:l.abortSignal}).then(e=>e.json()).then(e=>e)}}async delete(e){var t,n,i,l,r,o;let a="",s={};if(this.apiClient.isVertexAI()){let i,l,o=(r=this.apiClient,i={},null!=(l=te(e,["name"]))&&e7(i,["_url","name"],tW(r,l)),i);return a=e8("{name}",o._url),s=o._query,delete o._url,delete o._query,this.apiClient.request({path:a,queryParams:s,body:JSON.stringify(o),httpMethod:"DELETE",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t,n,i=(t={},null!=(n=te(e,["sdkHttpResponse"]))&&e7(t,["sdkHttpResponse"],n),t),l=new ty;return Object.assign(l,i),l})}{let t,n,r=(o=this.apiClient,t={},null!=(n=te(e,["name"]))&&e7(t,["_url","name"],tW(o,n)),t);return a=e8("{name}",r._url),s=r._query,delete r._url,delete r._query,this.apiClient.request({path:a,queryParams:s,body:JSON.stringify(r),httpMethod:"DELETE",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(l=e.config)?void 0:l.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t,n,i=(t={},null!=(n=te(e,["sdkHttpResponse"]))&&e7(t,["sdkHttpResponse"],n),t),l=new ty;return Object.assign(l,i),l})}}async update(e){var t,n,i,l,r,o;let a="",s={};if(this.apiClient.isVertexAI()){let i,l,o,u,p,d=(r=this.apiClient,i={},null!=(l=te(e,["name"]))&&e7(i,["_url","name"],tW(r,l)),null!=(o=te(e,["config"]))&&(u=te(o,["ttl"]),void 0!==i&&null!=u&&e7(i,["ttl"],u),p=te(o,["expireTime"]),void 0!==i&&null!=p&&e7(i,["expireTime"],p)),i);return a=e8("{name}",d._url),s=d._query,delete d._url,delete d._query,this.apiClient.request({path:a,queryParams:s,body:JSON.stringify(d),httpMethod:"PATCH",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>e)}{let t,n,r,u,p,d=(o=this.apiClient,t={},null!=(n=te(e,["name"]))&&e7(t,["_url","name"],tW(o,n)),null!=(r=te(e,["config"]))&&(u=te(r,["ttl"]),void 0!==t&&null!=u&&e7(t,["ttl"],u),p=te(r,["expireTime"]),void 0!==t&&null!=p&&e7(t,["expireTime"],p)),t);return a=e8("{name}",d._url),s=d._query,delete d._url,delete d._query,this.apiClient.request({path:a,queryParams:s,body:JSON.stringify(d),httpMethod:"PATCH",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(l=e.config)?void 0:l.abortSignal}).then(e=>e.json()).then(e=>e)}}async listInternal(e){var t,n,i,l;let r="",o={};if(this.apiClient.isVertexAI()){let i,l,a,s,u=(i={},null!=(l=te(e,["config"]))&&(a=te(l,["pageSize"]),void 0!==i&&null!=a&&e7(i,["_query","pageSize"],a),s=te(l,["pageToken"]),void 0!==i&&null!=s&&e7(i,["_query","pageToken"],s)),i);return r=e8("cachedContents",u._url),o=u._query,delete u._url,delete u._query,this.apiClient.request({path:r,queryParams:o,body:JSON.stringify(u),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=function(e){let t={},n=te(e,["sdkHttpResponse"]);null!=n&&e7(t,["sdkHttpResponse"],n);let i=te(e,["nextPageToken"]);null!=i&&e7(t,["nextPageToken"],i);let l=te(e,["cachedContents"]);if(null!=l){let e=l;Array.isArray(e)&&(e=e.map(e=>e)),e7(t,["cachedContents"],e)}return t}(e),n=new tE;return Object.assign(n,t),n})}{let t,n,a,s,u=(t={},null!=(n=te(e,["config"]))&&(a=te(n,["pageSize"]),void 0!==t&&null!=a&&e7(t,["_query","pageSize"],a),s=te(n,["pageToken"]),void 0!==t&&null!=s&&e7(t,["_query","pageToken"],s)),t);return r=e8("cachedContents",u._url),o=u._query,delete u._url,delete u._query,this.apiClient.request({path:r,queryParams:o,body:JSON.stringify(u),httpMethod:"GET",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(l=e.config)?void 0:l.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=function(e){let t={},n=te(e,["sdkHttpResponse"]);null!=n&&e7(t,["sdkHttpResponse"],n);let i=te(e,["nextPageToken"]);null!=i&&e7(t,["nextPageToken"],i);let l=te(e,["cachedContents"]);if(null!=l){let e=l;Array.isArray(e)&&(e=e.map(e=>e)),e7(t,["cachedContents"],e)}return t}(e),n=new tE;return Object.assign(n,t),n})}}}function nn(e){return this instanceof nn?(this.v=e,this):new nn(e)}function ni(e,t,n){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var i,l=n.apply(e,t||[]),r=[];return i=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),o("next"),o("throw"),o("return",function(e){return function(t){return Promise.resolve(t).then(e,u)}}),i[Symbol.asyncIterator]=function(){return this},i;function o(e,t){l[e]&&(i[e]=function(t){return new Promise(function(n,i){r.push([e,t,n,i])>1||a(e,t)})},t&&(i[e]=t(i[e])))}function a(e,t){try{var n;(n=l[e](t)).value instanceof nn?Promise.resolve(n.value.v).then(s,u):p(r[0][2],n)}catch(e){p(r[0][3],e)}}function s(e){a("next",e)}function u(e){a("throw",e)}function p(e,t){e(t),r.shift(),r.length&&a(r[0][0],r[0][1])}}function nl(e){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],i=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(e),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(n){t[n]=e[n]&&function(t){return new Promise(function(i,l){var r,o,a;r=i,o=l,a=(t=e[n](t)).done,Promise.resolve(t.value).then(function(e){r({value:e,done:a})},o)})}}}function nr(e){if(void 0===e.parts||0===e.parts.length)return!1;for(let t of e.parts)if(void 0===t||0===Object.keys(t).length)return!1;return!0}function no(e){if(void 0===e||0===e.length)return[];let t=[],n=e.length,i=0;for(;i<n;)if("user"===e[i].role)t.push(e[i]),i++;else{let l=[],r=!0;for(;i<n&&"model"===e[i].role;)l.push(e[i]),r&&!nr(e[i])&&(r=!1),i++;r?t.push(...l):t.pop()}return t}"function"==typeof SuppressedError&&SuppressedError;class na{constructor(e,t){this.modelsModule=e,this.apiClient=t}create(e){return new ns(this.apiClient,this.modelsModule,e.model,e.config,structuredClone(e.history))}}class ns{constructor(e,t,n,i={},l=[]){this.apiClient=e,this.modelsModule=t,this.model=n,this.config=i,this.history=l,this.sendPromise=Promise.resolve(),function(e){if(0!==e.length){for(let t of e)if("user"!==t.role&&"model"!==t.role)throw Error(`Role must be user or model, but got ${t.role}.`)}}(l)}async sendMessage(e){var t;await this.sendPromise;let n=tF(e.message),i=this.modelsModule.generateContent({model:this.model,contents:this.getHistory(!0).concat(n),config:null!=(t=e.config)?t:this.config});return this.sendPromise=(async()=>{var e,t,l;let r=await i,o=null==(t=null==(e=r.candidates)?void 0:e[0])?void 0:t.content,a=r.automaticFunctionCallingHistory,s=this.getHistory(!0).length,u=[];null!=a&&(u=null!=(l=a.slice(s))?l:[]),this.recordHistory(n,o?[o]:[],u)})(),await this.sendPromise.catch(()=>{this.sendPromise=Promise.resolve()}),i}async sendMessageStream(e){var t;await this.sendPromise;let n=tF(e.message),i=this.modelsModule.generateContentStream({model:this.model,contents:this.getHistory(!0).concat(n),config:null!=(t=e.config)?t:this.config});this.sendPromise=i.then(()=>void 0).catch(()=>void 0);let l=await i;return this.processStreamResponse(l,n)}getHistory(e=!1){return structuredClone(e?no(this.history):this.history)}processStreamResponse(e,t){var n,i;return ni(this,arguments,function*(){var l,r,o,a;let s=[];try{for(var u,p=!0,d=nl(e);!(l=(u=yield nn(d.next())).done);p=!0){if(a=u.value,p=!1,function(e){var t;if(void 0==e.candidates||0===e.candidates.length)return!1;let n=null==(t=e.candidates[0])?void 0:t.content;return void 0!==n&&nr(n)}(a)){let e=null==(i=null==(n=a.candidates)?void 0:n[0])?void 0:i.content;void 0!==e&&s.push(e)}yield yield nn(a)}}catch(e){r={error:e}}finally{try{!p&&!l&&(o=d.return)&&(yield nn(o.call(d)))}finally{if(r)throw r.error}}this.recordHistory(t,s)})}recordHistory(e,t,n){let i=[];t.length>0&&t.every(e=>void 0!==e.role)?i=t:i.push({role:"model",parts:[]}),n&&n.length>0?this.history.push(...no(n)):this.history.push(e),this.history.push(...i)}}class nu extends Error{constructor(e){super(e.message),this.name="ApiError",this.status=e.status,Object.setPrototypeOf(this,nu.prototype)}}class np extends e5{constructor(e){super(),this.apiClient=e,this.list=async(e={})=>new t8(en.PAGED_ITEM_FILES,e=>this.listInternal(e),await this.listInternal(e),e)}async upload(e){if(this.apiClient.isVertexAI())throw 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 listInternal(e){var t,n;let i="",l={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let r,o,a,s,u=(r={},null!=(o=te(e,["config"]))&&(a=te(o,["pageSize"]),void 0!==r&&null!=a&&e7(r,["_query","pageSize"],a),s=te(o,["pageToken"]),void 0!==r&&null!=s&&e7(r,["_query","pageToken"],s)),r);return i=e8("files",u._url),l=u._query,delete u._url,delete u._query,this.apiClient.request({path:i,queryParams:l,body:JSON.stringify(u),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=function(e){let t={},n=te(e,["sdkHttpResponse"]);null!=n&&e7(t,["sdkHttpResponse"],n);let i=te(e,["nextPageToken"]);null!=i&&e7(t,["nextPageToken"],i);let l=te(e,["files"]);if(null!=l){let e=l;Array.isArray(e)&&(e=e.map(e=>e)),e7(t,["files"],e)}return t}(e),n=new tA;return Object.assign(n,t),n})}}async createInternal(e){var t,n;let i="",l={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let r,o,a=(r={},null!=(o=te(e,["file"]))&&e7(r,["file"],o),r);return i=e8("upload/v1beta/files",a._url),l=a._query,delete a._url,delete a._query,this.apiClient.request({path:i,queryParams:l,body:JSON.stringify(a),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>{let t,n,i=(t={},null!=(n=te(e,["sdkHttpResponse"]))&&e7(t,["sdkHttpResponse"],n),t),l=new tC;return Object.assign(l,i),l})}}async get(e){var t,n;let i="",l={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let r,o,a=(r={},null!=(o=te(e,["name"]))&&e7(r,["_url","file"],tX(o)),r);return i=e8("files/{file}",a._url),l=a._query,delete a._url,delete a._query,this.apiClient.request({path:i,queryParams:l,body:JSON.stringify(a),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>e)}}async delete(e){var t,n;let i="",l={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let r,o,a=(r={},null!=(o=te(e,["name"]))&&e7(r,["_url","file"],tX(o)),r);return i=e8("files/{file}",a._url),l=a._query,delete a._url,delete a._query,this.apiClient.request({path:i,queryParams:l,body:JSON.stringify(a),httpMethod:"DELETE",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t,n,i=(t={},null!=(n=te(e,["sdkHttpResponse"]))&&e7(t,["sdkHttpResponse"],n),t),l=new tS;return Object.assign(l,i),l})}}}function nd(e){let t={},n=te(e,["data"]);if(null!=n&&e7(t,["data"],n),void 0!==te(e,["displayName"]))throw Error("displayName parameter is not supported in Gemini API.");let i=te(e,["mimeType"]);return null!=i&&e7(t,["mimeType"],i),t}function nc(e){let t={},n=te(e,["languageCode"]);null!=n&&e7(t,["languageCode"],n);let i=te(e,["voiceConfig"]);if(null!=i&&e7(t,["voiceConfig"],i),void 0!==te(e,["multiSpeakerVoiceConfig"]))throw Error("multiSpeakerVoiceConfig parameter is not supported in Vertex AI.");return t}function nh(e){let t={},n=te(e,["parts"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>{var t;let n,i,l,r,o,a,s,u,p,d,c,h;return n={},null!=(i=te(t=e,["mediaResolution"]))&&e7(n,["mediaResolution"],i),null!=(l=te(t,["codeExecutionResult"]))&&e7(n,["codeExecutionResult"],l),null!=(r=te(t,["executableCode"]))&&e7(n,["executableCode"],r),null!=(o=te(t,["fileData"]))&&e7(n,["fileData"],function(e){let t={};if(void 0!==te(e,["displayName"]))throw Error("displayName parameter is not supported in Gemini API.");let n=te(e,["fileUri"]);null!=n&&e7(t,["fileUri"],n);let i=te(e,["mimeType"]);return null!=i&&e7(t,["mimeType"],i),t}(o)),null!=(a=te(t,["functionCall"]))&&e7(n,["functionCall"],function(e){let t={},n=te(e,["id"]);null!=n&&e7(t,["id"],n);let i=te(e,["args"]);null!=i&&e7(t,["args"],i);let l=te(e,["name"]);if(null!=l&&e7(t,["name"],l),void 0!==te(e,["partialArgs"]))throw Error("partialArgs parameter is not supported in Gemini API.");if(void 0!==te(e,["willContinue"]))throw Error("willContinue parameter is not supported in Gemini API.");return t}(a)),null!=(s=te(t,["functionResponse"]))&&e7(n,["functionResponse"],s),null!=(u=te(t,["inlineData"]))&&e7(n,["inlineData"],function(e){let t={},n=te(e,["data"]);if(null!=n&&e7(t,["data"],n),void 0!==te(e,["displayName"]))throw Error("displayName parameter is not supported in Gemini API.");let i=te(e,["mimeType"]);return null!=i&&e7(t,["mimeType"],i),t}(u)),null!=(p=te(t,["text"]))&&e7(n,["text"],p),null!=(d=te(t,["thought"]))&&e7(n,["thought"],d),null!=(c=te(t,["thoughtSignature"]))&&e7(n,["thoughtSignature"],c),null!=(h=te(t,["videoMetadata"]))&&e7(n,["videoMetadata"],h),n})),e7(t,["parts"],e)}let i=te(e,["role"]);return null!=i&&e7(t,["role"],i),t}function nm(e,t){let n={},i=te(t,["model"]);null!=i&&e7(n,["_url","model"],tP(e,i));let l=te(t,["contents"]);if(null!=l){let e=tj(l);Array.isArray(e)&&(e=e.map(e=>nh(e))),e7(n,["contents"],e)}let r=te(t,["config"]);return null!=r&&e7(n,["generationConfig"],function(e,t,n){var i;let l,r,o,a={},s=te(t,["systemInstruction"]);void 0!==n&&null!=s&&e7(n,["systemInstruction"],nh(tF(s)));let u=te(t,["temperature"]);null!=u&&e7(a,["temperature"],u);let p=te(t,["topP"]);null!=p&&e7(a,["topP"],p);let d=te(t,["topK"]);null!=d&&e7(a,["topK"],d);let c=te(t,["candidateCount"]);null!=c&&e7(a,["candidateCount"],c);let h=te(t,["maxOutputTokens"]);null!=h&&e7(a,["maxOutputTokens"],h);let m=te(t,["stopSequences"]);null!=m&&e7(a,["stopSequences"],m);let f=te(t,["responseLogprobs"]);null!=f&&e7(a,["responseLogprobs"],f);let g=te(t,["logprobs"]);null!=g&&e7(a,["logprobs"],g);let y=te(t,["presencePenalty"]);null!=y&&e7(a,["presencePenalty"],y);let E=te(t,["frequencyPenalty"]);null!=E&&e7(a,["frequencyPenalty"],E);let _=te(t,["seed"]);null!=_&&e7(a,["seed"],_);let I=te(t,["responseMimeType"]);null!=I&&e7(a,["responseMimeType"],I);let T=te(t,["responseSchema"]);null!=T&&e7(a,["responseSchema"],tB(T));let v=te(t,["responseJsonSchema"]);if(null!=v&&e7(a,["responseJsonSchema"],v),void 0!==te(t,["routingConfig"]))throw Error("routingConfig parameter is not supported in Gemini API.");if(void 0!==te(t,["modelSelectionConfig"]))throw Error("modelSelectionConfig parameter is not supported in Gemini API.");let A=te(t,["safetySettings"]);if(void 0!==n&&null!=A){let e=A;Array.isArray(e)&&(e=e.map(e=>(function(e){let t={},n=te(e,["category"]);if(null!=n&&e7(t,["category"],n),void 0!==te(e,["method"]))throw Error("method parameter is not supported in Gemini API.");let i=te(e,["threshold"]);return null!=i&&e7(t,["threshold"],i),t})(e))),e7(n,["safetySettings"],e)}let C=te(t,["tools"]);if(void 0!==n&&null!=C){let e=t$(C);Array.isArray(e)&&(e=e.map(e=>(function(e){let t={},n=te(e,["functionDeclarations"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>e)),e7(t,["functionDeclarations"],e)}if(void 0!==te(e,["retrieval"]))throw Error("retrieval parameter is not supported in Gemini API.");let i=te(e,["googleSearchRetrieval"]);null!=i&&e7(t,["googleSearchRetrieval"],i);let l=te(e,["computerUse"]);null!=l&&e7(t,["computerUse"],l);let r=te(e,["fileSearch"]);null!=r&&e7(t,["fileSearch"],r);let o=te(e,["codeExecution"]);if(null!=o&&e7(t,["codeExecution"],o),void 0!==te(e,["enterpriseWebSearch"]))throw Error("enterpriseWebSearch parameter is not supported in Gemini API.");let a=te(e,["googleMaps"]);null!=a&&e7(t,["googleMaps"],function(e){let t={};if(void 0!==te(e,["authConfig"]))throw Error("authConfig parameter is not supported in Gemini API.");let n=te(e,["enableWidget"]);return null!=n&&e7(t,["enableWidget"],n),t}(a));let s=te(e,["googleSearch"]);null!=s&&e7(t,["googleSearch"],function(e){let t={};if(void 0!==te(e,["excludeDomains"]))throw Error("excludeDomains parameter is not supported in Gemini API.");if(void 0!==te(e,["blockingConfidence"]))throw Error("blockingConfidence parameter is not supported in Gemini API.");let n=te(e,["timeRangeFilter"]);return null!=n&&e7(t,["timeRangeFilter"],n),t}(s));let u=te(e,["urlContext"]);return null!=u&&e7(t,["urlContext"],u),t})(tK(e)))),e7(n,["tools"],e)}let S=te(t,["toolConfig"]);if(void 0!==n&&null!=S&&e7(n,["toolConfig"],(l={},null!=(r=te(i=S,["functionCallingConfig"]))&&e7(l,["functionCallingConfig"],function(e){let t={},n=te(e,["mode"]);null!=n&&e7(t,["mode"],n);let i=te(e,["allowedFunctionNames"]);if(null!=i&&e7(t,["allowedFunctionNames"],i),void 0!==te(e,["streamFunctionCallArguments"]))throw Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return t}(r)),null!=(o=te(i,["retrievalConfig"]))&&e7(l,["retrievalConfig"],o),l)),void 0!==te(t,["labels"]))throw Error("labels parameter is not supported in Gemini API.");let O=te(t,["cachedContent"]);void 0!==n&&null!=O&&e7(n,["cachedContent"],tW(e,O));let b=te(t,["responseModalities"]);null!=b&&e7(a,["responseModalities"],b);let N=te(t,["mediaResolution"]);null!=N&&e7(a,["mediaResolution"],N);let R=te(t,["speechConfig"]);if(null!=R&&e7(a,["speechConfig"],tJ(R)),void 0!==te(t,["audioTimestamp"]))throw Error("audioTimestamp parameter is not supported in Gemini API.");let P=te(t,["thinkingConfig"]);null!=P&&e7(a,["thinkingConfig"],P);let D=te(t,["imageConfig"]);return null!=D&&e7(a,["imageConfig"],function(e){let t={},n=te(e,["aspectRatio"]);null!=n&&e7(t,["aspectRatio"],n);let i=te(e,["imageSize"]);if(null!=i&&e7(t,["imageSize"],i),void 0!==te(e,["outputMimeType"]))throw Error("outputMimeType parameter is not supported in Gemini API.");if(void 0!==te(e,["outputCompressionQuality"]))throw Error("outputCompressionQuality parameter is not supported in Gemini API.");return t}(D)),a}(e,r,n)),n}function nf(e,t){let n={},i=te(t,["model"]);null!=i&&e7(n,["_url","model"],tP(e,i));let l=te(t,["contents"]);if(null!=l){let e=tj(l);Array.isArray(e)&&(e=e.map(e=>e)),e7(n,["contents"],e)}let r=te(t,["config"]);return null!=r&&e7(n,["generationConfig"],function(e,t,n){var i;let l,r,o,a,s,u={},p=te(t,["systemInstruction"]);void 0!==n&&null!=p&&e7(n,["systemInstruction"],tF(p));let d=te(t,["temperature"]);null!=d&&e7(u,["temperature"],d);let c=te(t,["topP"]);null!=c&&e7(u,["topP"],c);let h=te(t,["topK"]);null!=h&&e7(u,["topK"],h);let m=te(t,["candidateCount"]);null!=m&&e7(u,["candidateCount"],m);let f=te(t,["maxOutputTokens"]);null!=f&&e7(u,["maxOutputTokens"],f);let g=te(t,["stopSequences"]);null!=g&&e7(u,["stopSequences"],g);let y=te(t,["responseLogprobs"]);null!=y&&e7(u,["responseLogprobs"],y);let E=te(t,["logprobs"]);null!=E&&e7(u,["logprobs"],E);let _=te(t,["presencePenalty"]);null!=_&&e7(u,["presencePenalty"],_);let I=te(t,["frequencyPenalty"]);null!=I&&e7(u,["frequencyPenalty"],I);let T=te(t,["seed"]);null!=T&&e7(u,["seed"],T);let v=te(t,["responseMimeType"]);null!=v&&e7(u,["responseMimeType"],v);let A=te(t,["responseSchema"]);null!=A&&e7(u,["responseSchema"],tB(A));let C=te(t,["responseJsonSchema"]);null!=C&&e7(u,["responseJsonSchema"],C);let S=te(t,["routingConfig"]);null!=S&&e7(u,["routingConfig"],S);let O=te(t,["modelSelectionConfig"]);null!=O&&e7(u,["modelConfig"],O);let b=te(t,["safetySettings"]);if(void 0!==n&&null!=b){let e=b;Array.isArray(e)&&(e=e.map(e=>e)),e7(n,["safetySettings"],e)}let N=te(t,["tools"]);if(void 0!==n&&null!=N){let e=t$(N);Array.isArray(e)&&(e=e.map(e=>nb(tK(e)))),e7(n,["tools"],e)}let R=te(t,["toolConfig"]);void 0!==n&&null!=R&&e7(n,["toolConfig"],R);let P=te(t,["labels"]);void 0!==n&&null!=P&&e7(n,["labels"],P);let D=te(t,["cachedContent"]);void 0!==n&&null!=D&&e7(n,["cachedContent"],tW(e,D));let M=te(t,["responseModalities"]);null!=M&&e7(u,["responseModalities"],M);let w=te(t,["mediaResolution"]);null!=w&&e7(u,["mediaResolution"],w);let U=te(t,["speechConfig"]);null!=U&&e7(u,["speechConfig"],nO(tJ(U)));let k=te(t,["audioTimestamp"]);null!=k&&e7(u,["audioTimestamp"],k);let L=te(t,["thinkingConfig"]);null!=L&&e7(u,["thinkingConfig"],L);let q=te(t,["imageConfig"]);return null!=q&&e7(u,["imageConfig"],(l={},null!=(r=te(i=q,["aspectRatio"]))&&e7(l,["aspectRatio"],r),null!=(o=te(i,["imageSize"]))&&e7(l,["imageSize"],o),null!=(a=te(i,["outputMimeType"]))&&e7(l,["imageOutputOptions","mimeType"],a),null!=(s=te(i,["outputCompressionQuality"]))&&e7(l,["imageOutputOptions","compressionQuality"],s),l)),u}(e,r,n)),n}function ng(e){let t={},n=te(e,["sdkHttpResponse"]);null!=n&&e7(t,["sdkHttpResponse"],n);let i=te(e,["candidates"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>(function(e){let t={},n=te(e,["content"]);null!=n&&e7(t,["content"],n);let i=te(e,["citationMetadata"]);null!=i&&e7(t,["citationMetadata"],function(e){let t={},n=te(e,["citationSources"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>e)),e7(t,["citations"],e)}return t}(i));let l=te(e,["tokenCount"]);null!=l&&e7(t,["tokenCount"],l);let r=te(e,["finishReason"]);null!=r&&e7(t,["finishReason"],r);let o=te(e,["avgLogprobs"]);null!=o&&e7(t,["avgLogprobs"],o);let a=te(e,["groundingMetadata"]);null!=a&&e7(t,["groundingMetadata"],a);let s=te(e,["index"]);null!=s&&e7(t,["index"],s);let u=te(e,["logprobsResult"]);null!=u&&e7(t,["logprobsResult"],u);let p=te(e,["safetyRatings"]);if(null!=p){let e=p;Array.isArray(e)&&(e=e.map(e=>e)),e7(t,["safetyRatings"],e)}let d=te(e,["urlContextMetadata"]);return null!=d&&e7(t,["urlContextMetadata"],d),t})(e))),e7(t,["candidates"],e)}let l=te(e,["modelVersion"]);null!=l&&e7(t,["modelVersion"],l);let r=te(e,["promptFeedback"]);null!=r&&e7(t,["promptFeedback"],r);let o=te(e,["responseId"]);null!=o&&e7(t,["responseId"],o);let a=te(e,["usageMetadata"]);return null!=a&&e7(t,["usageMetadata"],a),t}function ny(e){let t={},n=te(e,["sdkHttpResponse"]);null!=n&&e7(t,["sdkHttpResponse"],n);let i=te(e,["candidates"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),e7(t,["candidates"],e)}let l=te(e,["createTime"]);null!=l&&e7(t,["createTime"],l);let r=te(e,["modelVersion"]);null!=r&&e7(t,["modelVersion"],r);let o=te(e,["promptFeedback"]);null!=o&&e7(t,["promptFeedback"],o);let a=te(e,["responseId"]);null!=a&&e7(t,["responseId"],a);let s=te(e,["usageMetadata"]);return null!=s&&e7(t,["usageMetadata"],s),t}function nE(e){let t={},n=te(e,["_self"]);null!=n&&e7(t,["image"],n_(n));let i=te(e,["raiFilteredReason"]);null!=i&&e7(t,["raiFilteredReason"],i);let l=te(e,["_self"]);null!=l&&e7(t,["safetyAttributes"],nS(l));let r=te(e,["prompt"]);return null!=r&&e7(t,["enhancedPrompt"],r),t}function n_(e){let t={},n=te(e,["gcsUri"]);null!=n&&e7(t,["gcsUri"],n);let i=te(e,["bytesBase64Encoded"]);null!=i&&e7(t,["imageBytes"],tt(i));let l=te(e,["mimeType"]);return null!=l&&e7(t,["mimeType"],l),t}function nI(e){let t={};if(void 0!==te(e,["gcsUri"]))throw Error("gcsUri parameter is not supported in Gemini API.");let n=te(e,["imageBytes"]);null!=n&&e7(t,["bytesBase64Encoded"],tt(n));let i=te(e,["mimeType"]);return null!=i&&e7(t,["mimeType"],i),t}function nT(e){let t={},n=te(e,["gcsUri"]);null!=n&&e7(t,["gcsUri"],n);let i=te(e,["imageBytes"]);null!=i&&e7(t,["bytesBase64Encoded"],tt(i));let l=te(e,["mimeType"]);return null!=l&&e7(t,["mimeType"],l),t}function nv(e){var t;let n,i,l,r,o={},a=te(e,["name"]);null!=a&&e7(o,["name"],a);let s=te(e,["displayName"]);null!=s&&e7(o,["displayName"],s);let u=te(e,["description"]);null!=u&&e7(o,["description"],u);let p=te(e,["version"]);null!=p&&e7(o,["version"],p);let d=te(e,["_self"]);null!=d&&e7(o,["tunedModelInfo"],(n={},null!=(i=te(t=d,["baseModel"]))&&e7(n,["baseModel"],i),null!=(l=te(t,["createTime"]))&&e7(n,["createTime"],l),null!=(r=te(t,["updateTime"]))&&e7(n,["updateTime"],r),n));let c=te(e,["inputTokenLimit"]);null!=c&&e7(o,["inputTokenLimit"],c);let h=te(e,["outputTokenLimit"]);null!=h&&e7(o,["outputTokenLimit"],h);let m=te(e,["supportedGenerationMethods"]);null!=m&&e7(o,["supportedActions"],m);let f=te(e,["temperature"]);null!=f&&e7(o,["temperature"],f);let g=te(e,["maxTemperature"]);null!=g&&e7(o,["maxTemperature"],g);let y=te(e,["topP"]);null!=y&&e7(o,["topP"],y);let E=te(e,["topK"]);null!=E&&e7(o,["topK"],E);let _=te(e,["thinking"]);return null!=_&&e7(o,["thinking"],_),o}function nA(e){var t;let n,i,l,r,o={},a=te(e,["name"]);null!=a&&e7(o,["name"],a);let s=te(e,["displayName"]);null!=s&&e7(o,["displayName"],s);let u=te(e,["description"]);null!=u&&e7(o,["description"],u);let p=te(e,["versionId"]);null!=p&&e7(o,["version"],p);let d=te(e,["deployedModels"]);if(null!=d){let e=d;Array.isArray(e)&&(e=e.map(e=>{let t,n,i;return t={},null!=(n=te(e,["endpoint"]))&&e7(t,["name"],n),null!=(i=te(e,["deployedModelId"]))&&e7(t,["deployedModelId"],i),t})),e7(o,["endpoints"],e)}let c=te(e,["labels"]);null!=c&&e7(o,["labels"],c);let h=te(e,["_self"]);null!=h&&e7(o,["tunedModelInfo"],(n={},null!=(i=te(t=h,["labels","google-vertex-llm-tuning-base-model-id"]))&&e7(n,["baseModel"],i),null!=(l=te(t,["createTime"]))&&e7(n,["createTime"],l),null!=(r=te(t,["updateTime"]))&&e7(n,["updateTime"],r),n));let m=te(e,["defaultCheckpointId"]);null!=m&&e7(o,["defaultCheckpointId"],m);let f=te(e,["checkpoints"]);if(null!=f){let e=f;Array.isArray(e)&&(e=e.map(e=>e)),e7(o,["checkpoints"],e)}return o}function nC(e){let t={},n=te(e,["safetyAttributes","categories"]);null!=n&&e7(t,["categories"],n);let i=te(e,["safetyAttributes","scores"]);null!=i&&e7(t,["scores"],i);let l=te(e,["contentType"]);return null!=l&&e7(t,["contentType"],l),t}function nS(e){let t={},n=te(e,["safetyAttributes","categories"]);null!=n&&e7(t,["categories"],n);let i=te(e,["safetyAttributes","scores"]);null!=i&&e7(t,["scores"],i);let l=te(e,["contentType"]);return null!=l&&e7(t,["contentType"],l),t}function nO(e){let t={},n=te(e,["languageCode"]);null!=n&&e7(t,["languageCode"],n);let i=te(e,["voiceConfig"]);if(null!=i&&e7(t,["voiceConfig"],i),void 0!==te(e,["multiSpeakerVoiceConfig"]))throw Error("multiSpeakerVoiceConfig parameter is not supported in Vertex AI.");return t}function nb(e){let t={},n=te(e,["functionDeclarations"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>(function(e){let t={};if(void 0!==te(e,["behavior"]))throw Error("behavior parameter is not supported in Vertex AI.");let n=te(e,["description"]);null!=n&&e7(t,["description"],n);let i=te(e,["name"]);null!=i&&e7(t,["name"],i);let l=te(e,["parameters"]);null!=l&&e7(t,["parameters"],l);let r=te(e,["parametersJsonSchema"]);null!=r&&e7(t,["parametersJsonSchema"],r);let o=te(e,["response"]);null!=o&&e7(t,["response"],o);let a=te(e,["responseJsonSchema"]);return null!=a&&e7(t,["responseJsonSchema"],a),t})(e))),e7(t,["functionDeclarations"],e)}let i=te(e,["retrieval"]);null!=i&&e7(t,["retrieval"],i);let l=te(e,["googleSearchRetrieval"]);null!=l&&e7(t,["googleSearchRetrieval"],l);let r=te(e,["computerUse"]);if(null!=r&&e7(t,["computerUse"],r),void 0!==te(e,["fileSearch"]))throw Error("fileSearch parameter is not supported in Vertex AI.");let o=te(e,["codeExecution"]);null!=o&&e7(t,["codeExecution"],o);let a=te(e,["enterpriseWebSearch"]);null!=a&&e7(t,["enterpriseWebSearch"],a);let s=te(e,["googleMaps"]);null!=s&&e7(t,["googleMaps"],s);let u=te(e,["googleSearch"]);null!=u&&e7(t,["googleSearch"],u);let p=te(e,["urlContext"]);return null!=p&&e7(t,["urlContext"],p),t}function nN(e){let t={},n=te(e,["uri"]);null!=n&&e7(t,["uri"],n);let i=te(e,["videoBytes"]);null!=i&&e7(t,["encodedVideo"],tt(i));let l=te(e,["mimeType"]);return null!=l&&e7(t,["encoding"],l),t}function nR(e){let t={},n=te(e,["uri"]);null!=n&&e7(t,["gcsUri"],n);let i=te(e,["videoBytes"]);null!=i&&e7(t,["bytesBase64Encoded"],tt(i));let l=te(e,["mimeType"]);return null!=l&&e7(t,["mimeType"],l),t}let nP="x-goog-api-client",nD=/^\s*data: (.*)(?:\n\n|\r\r|\r\n\r\n)/;class nM{constructor(e){var t,n;this.clientOptions=Object.assign(Object.assign({},e),{project:e.project,location:e.location,apiKey:e.apiKey,vertexai:e.vertexai});const i={};this.clientOptions.vertexai?(i.apiVersion=null!=(t=this.clientOptions.apiVersion)?t:"v1beta1",i.baseUrl=this.baseUrlFromProjectLocation(),this.normalizeAuthParameters()):(i.apiVersion=null!=(n=this.clientOptions.apiVersion)?n:"v1beta",i.baseUrl="https://generativelanguage.googleapis.com/"),i.headers=this.getDefaultHeaders(),this.clientOptions.httpOptions=i,e.httpOptions&&(this.clientOptions.httpOptions=this.patchHttpOptions(i,e.httpOptions))}baseUrlFromProjectLocation(){return this.clientOptions.project&&this.clientOptions.location&&"global"!==this.clientOptions.location?`https://${this.clientOptions.location}-aiplatform.googleapis.com/`:"https://aiplatform.googleapis.com/"}normalizeAuthParameters(){if(this.clientOptions.project&&this.clientOptions.location){this.clientOptions.apiKey=void 0;return}this.clientOptions.project=void 0,this.clientOptions.location=void 0}isVertexAI(){var e;return null!=(e=this.clientOptions.vertexai)&&e}getProject(){return this.clientOptions.project}getLocation(){return this.clientOptions.location}getApiVersion(){if(this.clientOptions.httpOptions&&void 0!==this.clientOptions.httpOptions.apiVersion)return this.clientOptions.httpOptions.apiVersion;throw Error("API version is not set.")}getBaseUrl(){if(this.clientOptions.httpOptions&&void 0!==this.clientOptions.httpOptions.baseUrl)return this.clientOptions.httpOptions.baseUrl;throw Error("Base URL is not set.")}getRequestUrl(){return this.getRequestUrlInternal(this.clientOptions.httpOptions)}getHeaders(){if(this.clientOptions.httpOptions&&void 0!==this.clientOptions.httpOptions.headers)return this.clientOptions.httpOptions.headers;throw Error("Headers are not set.")}getRequestUrlInternal(e){if(!e||void 0===e.baseUrl||void 0===e.apiVersion)throw Error("HTTP options are not correctly set.");let t=[e.baseUrl.endsWith("/")?e.baseUrl.slice(0,-1):e.baseUrl];return e.apiVersion&&""!==e.apiVersion&&t.push(e.apiVersion),t.join("/")}getBaseResourcePath(){return`projects/${this.clientOptions.project}/locations/${this.clientOptions.location}`}getApiKey(){return this.clientOptions.apiKey}getWebsocketBaseUrl(){let e=new URL(this.getBaseUrl());return e.protocol="http:"==e.protocol?"ws":"wss",e.toString()}setBaseUrl(e){if(this.clientOptions.httpOptions)this.clientOptions.httpOptions.baseUrl=e;else throw Error("HTTP options are not correctly set.")}constructUrl(e,t,n){let i=[this.getRequestUrlInternal(t)];return n&&i.push(this.getBaseResourcePath()),""!==e&&i.push(e),new URL(`${i.join("/")}`)}shouldPrependVertexProjectPath(e){return!(this.clientOptions.apiKey||!this.clientOptions.vertexai||e.path.startsWith("projects/")||"GET"===e.httpMethod&&e.path.startsWith("publishers/google/models"))}async request(e){let t=this.clientOptions.httpOptions;e.httpOptions&&(t=this.patchHttpOptions(this.clientOptions.httpOptions,e.httpOptions));let n=this.shouldPrependVertexProjectPath(e),i=this.constructUrl(e.path,t,n);if(e.queryParams)for(let[t,n]of Object.entries(e.queryParams))i.searchParams.append(t,String(n));let l={};if("GET"===e.httpMethod){if(e.body&&"{}"!==e.body)throw Error("Request body should be empty for GET request, but got non empty request body")}else l.body=e.body;return l=await this.includeExtraHttpOptionsToRequestInit(l,t,i.toString(),e.abortSignal),this.unaryApiCall(i,l,e.httpMethod)}patchHttpOptions(e,t){let n=JSON.parse(JSON.stringify(e));for(let[e,i]of Object.entries(t))"object"==typeof i?n[e]=Object.assign(Object.assign({},n[e]),i):void 0!==i&&(n[e]=i);return n}async requestStream(e){let t=this.clientOptions.httpOptions;e.httpOptions&&(t=this.patchHttpOptions(this.clientOptions.httpOptions,e.httpOptions));let n=this.shouldPrependVertexProjectPath(e),i=this.constructUrl(e.path,t,n);i.searchParams.has("alt")&&"sse"===i.searchParams.get("alt")||i.searchParams.set("alt","sse");let l={};return l.body=e.body,l=await this.includeExtraHttpOptionsToRequestInit(l,t,i.toString(),e.abortSignal),this.streamApiCall(i,l,e.httpMethod)}async includeExtraHttpOptionsToRequestInit(e,t,n,i){if(t&&t.timeout||i){let n=new AbortController,l=n.signal;if(t.timeout&&(null==t?void 0:t.timeout)>0){let e=setTimeout(()=>n.abort(),t.timeout);e&&"function"==typeof e.unref&&e.unref()}i&&i.addEventListener("abort",()=>{n.abort()}),e.signal=l}return t&&null!==t.extraBody&&function(e,t){if(!t||0===Object.keys(t).length)return;if(e.body instanceof Blob)return console.warn("includeExtraBodyToRequestInit: extraBody provided but current request body is a Blob. extraBody will be ignored as merging is not supported for Blob bodies.");let n={};if("string"==typeof e.body&&e.body.length>0)try{let t=JSON.parse(e.body);if("object"!=typeof t||null===t||Array.isArray(t))return void console.warn("includeExtraBodyToRequestInit: Original request body is valid JSON but not a non-array object. Skip applying extraBody to the request body.");n=t}catch(e){console.warn("includeExtraBodyToRequestInit: Original request body is not valid JSON. Skip applying extraBody to the request body.");return}e.body=JSON.stringify(function e(t,n){let i=Object.assign({},t);for(let t in n)if(Object.prototype.hasOwnProperty.call(n,t)){let l=n[t],r=i[t];l&&"object"==typeof l&&!Array.isArray(l)&&r&&"object"==typeof r&&!Array.isArray(r)?i[t]=e(r,l):(r&&l&&typeof r!=typeof l&&console.warn(`includeExtraBodyToRequestInit:deepMerge: Type mismatch for key "${t}". Original type: ${typeof r}, New type: ${typeof l}. Overwriting.`),i[t]=l)}return i}(n,t))}(e,t.extraBody),e.headers=await this.getHeadersInternal(t,n),e}async unaryApiCall(e,t,n){return this.apiCall(e.toString(),Object.assign(Object.assign({},t),{method:n})).then(async e=>(await nw(e),new ti(e))).catch(e=>{if(e instanceof Error)throw e;throw Error(JSON.stringify(e))})}async streamApiCall(e,t,n){return this.apiCall(e.toString(),Object.assign(Object.assign({},t),{method:n})).then(async e=>(await nw(e),this.processStreamResponse(e))).catch(e=>{if(e instanceof Error)throw e;throw Error(JSON.stringify(e))})}processStreamResponse(e){var t;return ni(this,arguments,function*(){let n=null==(t=null==e?void 0:e.body)?void 0:t.getReader(),i=new TextDecoder("utf-8");if(!n)throw Error("Response body is empty");try{let t="";for(;;){let{done:l,value:r}=yield nn(n.read());if(l){if(t.trim().length>0)throw Error("Incomplete JSON segment at the end");break}let o=i.decode(r,{stream:!0});try{let e=JSON.parse(o);if("error"in e){let t=JSON.parse(JSON.stringify(e.error)),n=t.status,i=t.code,l=`got status: ${n}. ${JSON.stringify(e)}`;if(i>=400&&i<600)throw new nu({message:l,status:i})}}catch(e){if("ApiError"===e.name)throw e}let a=(t+=o).match(nD);for(;a;){let n=a[1];try{let i=new Response(n,{headers:null==e?void 0:e.headers,status:null==e?void 0:e.status,statusText:null==e?void 0:e.statusText});yield yield nn(new ti(i)),a=(t=t.slice(a[0].length)).match(nD)}catch(e){throw Error(`exception parsing stream chunk ${n}. ${e}`)}}}}finally{n.releaseLock()}})}async apiCall(e,t){return fetch(e,t).catch(e=>{throw Error(`exception ${e} sending request`)})}getDefaultHeaders(){let e={},t="google-genai-sdk/1.30.0 "+this.clientOptions.userAgentExtra;return e["User-Agent"]=t,e[nP]=t,e["Content-Type"]="application/json",e}async getHeadersInternal(e,t){let n=new Headers;if(e&&e.headers){for(let[t,i]of Object.entries(e.headers))n.append(t,i);e.timeout&&e.timeout>0&&n.append("X-Server-Timeout",String(Math.ceil(e.timeout/1e3)))}return await this.clientOptions.auth.addAuthHeaders(n,t),n}getFileName(e){var t;let n="";return"string"==typeof e&&(n=null!=(t=(n=e.replace(/[/\\]+$/,"")).split(/[/\\]/).pop())?t:""),n}async uploadFile(e,t){var n;let i={};null!=t&&(i.mimeType=t.mimeType,i.name=t.name,i.displayName=t.displayName),i.name&&!i.name.startsWith("files/")&&(i.name=`files/${i.name}`);let l=this.clientOptions.uploader,r=await l.stat(e);i.sizeBytes=String(r.size);let o=null!=(n=null==t?void 0:t.mimeType)?n:r.type;if(void 0===o||""===o)throw Error("Can not determine mimeType. Please provide mimeType in the config.");i.mimeType=o;let a={file:i},s=this.getFileName(e),u=e8("upload/v1beta/files",a._url),p=await this.fetchUploadUrl(u,i.sizeBytes,i.mimeType,s,a,null==t?void 0:t.httpOptions);return l.upload(e,p,this)}async uploadFileToFileSearchStore(e,t,n){var i;let l=this.clientOptions.uploader,r=await l.stat(t),o=String(r.size),a=null!=(i=null==n?void 0:n.mimeType)?i:r.type;if(void 0===a||""===a)throw Error("Can not determine mimeType. Please provide mimeType in the config.");let s=`upload/v1beta/${e}:uploadToFileSearchStore`,u=this.getFileName(t),p={};(null==n?void 0:n.customMetadata)&&(p.customMetadata=n.customMetadata),(null==n?void 0:n.chunkingConfig)&&(p.chunkingConfig=n.chunkingConfig);let d=await this.fetchUploadUrl(s,o,a,u,p,null==n?void 0:n.httpOptions);return l.uploadToFileSearchStore(t,d,this)}async downloadFile(e){let t=this.clientOptions.downloader;await t.download(e,this)}async fetchUploadUrl(e,t,n,i,l,r){var o;let a={};a=r||{apiVersion:"",headers:Object.assign({"Content-Type":"application/json","X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":`${t}`,"X-Goog-Upload-Header-Content-Type":`${n}`},i?{"X-Goog-Upload-File-Name":i}:{})};let s=await this.request({path:e,body:JSON.stringify(l),httpMethod:"POST",httpOptions:a});if(!s||!(null==s?void 0:s.headers))throw Error("Server did not return an HttpResponse or the returned HttpResponse did not have headers.");let u=null==(o=null==s?void 0:s.headers)?void 0:o["x-goog-upload-url"];if(void 0===u)throw Error("Failed to get upload url. Server did not return the x-google-upload-url in the headers");return u}}async function nw(e){var t;if(void 0===e)throw Error("response is undefined");if(!e.ok){let n=e.status,i=JSON.stringify((null==(t=e.headers.get("content-type"))?void 0:t.includes("application/json"))?await e.json():{error:{message:await e.text(),code:e.status,status:e.statusText}});if(n>=400&&n<600)throw new nu({message:i,status:n});throw Error(i)}}function nU(e){for(let n of e){var t;if(null!==(t=n)&&"object"==typeof t&&t instanceof nL||"object"==typeof n&&"inputSchema"in n)return!0}return!1}function nk(e){var t;let n=null!=(t=e[nP])?t:"";e[nP]=(n+" mcp_used/unknown").trimStart()}class nL{constructor(e=[],t){this.mcpTools=[],this.functionNameToMcpClient={},this.mcpClients=e,this.config=t}static create(e,t){return new nL(e,t)}async initialize(){var e,t,n,i;if(this.mcpTools.length>0)return;let l={},r=[];for(let u of this.mcpClients)try{for(var o,a=!0,s=(t=void 0,nl(function(e,t=100){return ni(this,arguments,function*(){let n,i=0;for(;i<t;){let t=yield nn(e.listTools({cursor:n}));for(let e of t.tools)yield yield nn(e),i++;if(!t.nextCursor)break;n=t.nextCursor}})}(u)));!(e=(o=await s.next()).done);a=!0){i=o.value,a=!1,r.push(i);let e=i.name;if(l[e])throw Error(`Duplicate function name ${e} found in MCP tools. Please ensure function names are unique.`);l[e]=u}}catch(e){t={error:e}}finally{try{!a&&!e&&(n=s.return)&&await n.call(s)}finally{if(t)throw t.error}}this.mcpTools=r,this.functionNameToMcpClient=l}async tool(){return await this.initialize(),function(e,t={}){let n=[],i=new Set;for(let l of e){let e=l.name;if(i.has(e))throw Error(`Duplicate function name ${e} found in MCP tools. Please ensure function names are unique.`);i.add(e);let r=function(e,t={}){let n={name:e.name,description:e.description,parametersJsonSchema:e.inputSchema};return e.outputSchema&&(n.responseJsonSchema=e.outputSchema),t.behavior&&(n.behavior=t.behavior),{functionDeclarations:[n]}}(l,t);r.functionDeclarations&&n.push(...r.functionDeclarations)}return{functionDeclarations:n}}(this.mcpTools,this.config)}async callTool(e){await this.initialize();let t=[];for(let n of e)if(n.name in this.functionNameToMcpClient){let e,i=this.functionNameToMcpClient[n.name];this.config.timeout&&(e={timeout:this.config.timeout});let l=await i.callTool({name:n.name,arguments:n.args},void 0,e);t.push({functionResponse:{name:n.name,response:l.isError?{error:l}:l}})}return t}}async function nq(e,t,n){let i=new tN;Object.assign(i,n.data instanceof Blob?JSON.parse(await n.data.text()):JSON.parse(n.data)),t(i)}class nx{constructor(e,t,n){this.apiClient=e,this.auth=t,this.webSocketFactory=n}async connect(e){var t,n;let i;if(this.apiClient.isVertexAI())throw Error("Live music is not supported for Vertex AI.");console.warn("Live music generation is experimental and may change in future versions.");let l=this.apiClient.getWebsocketBaseUrl(),r=this.apiClient.getApiVersion(),o=function(e){let t=new Headers;for(let[n,i]of Object.entries(e))t.append(n,i);return t}(this.apiClient.getDefaultHeaders()),a=this.apiClient.getApiKey(),s=`${l}/ws/google.ai.generativelanguage.${r}.GenerativeService.BidiGenerateMusic?key=${a}`,u=()=>{},p=new Promise(e=>{u=e}),d=e.callbacks,c=this.apiClient,h={onopen:function(){u({})},onmessage:e=>{nq(c,d.onmessage,e)},onerror:null!=(t=null==d?void 0:d.onerror)?t:function(e){},onclose:null!=(n=null==d?void 0:d.onclose)?n:function(e){}},m=this.webSocketFactory.create(s,(i={},o.forEach((e,t)=>{i[t]=e}),i),h);m.connect(),await p;let f=tP(this.apiClient,e.model);return m.send(JSON.stringify({setup:{model:f}})),new nG(m,this.apiClient)}}class nG{constructor(e,t){this.conn=e,this.apiClient=t}async setWeightedPrompts(e){if(!e.weightedPrompts||0===Object.keys(e.weightedPrompts).length)throw Error("Weighted prompts must be set and contain at least one entry.");let t=function(e){let t={},n=te(e,["weightedPrompts"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>e)),e7(t,["weightedPrompts"],e)}return t}(e);this.conn.send(JSON.stringify({clientContent:t}))}async setMusicGenerationConfig(e){let t,n;e.musicGenerationConfig||(e.musicGenerationConfig={});let i=(t={},null!=(n=te(e,["musicGenerationConfig"]))&&e7(t,["musicGenerationConfig"],n),t);this.conn.send(JSON.stringify(i))}sendPlaybackControl(e){this.conn.send(JSON.stringify({playbackControl:e}))}play(){this.sendPlaybackControl(et.PLAY)}pause(){this.sendPlaybackControl(et.PAUSE)}stop(){this.sendPlaybackControl(et.STOP)}resetContext(){this.sendPlaybackControl(et.RESET_CONTEXT)}close(){this.conn.close()}}async function nH(e,t,n){let i=new tb,l=JSON.parse(n.data instanceof Blob?await n.data.text():n.data instanceof ArrayBuffer?new TextDecoder().decode(n.data):n.data);if(e.isVertexAI()){let e,t,n,r,o,a,s,u;Object.assign(i,(e={},null!=(t=te(l,["setupComplete"]))&&e7(e,["setupComplete"],t),null!=(n=te(l,["serverContent"]))&&e7(e,["serverContent"],n),null!=(r=te(l,["toolCall"]))&&e7(e,["toolCall"],r),null!=(o=te(l,["toolCallCancellation"]))&&e7(e,["toolCallCancellation"],o),null!=(a=te(l,["usageMetadata"]))&&e7(e,["usageMetadata"],function(e){let t={},n=te(e,["promptTokenCount"]);null!=n&&e7(t,["promptTokenCount"],n);let i=te(e,["cachedContentTokenCount"]);null!=i&&e7(t,["cachedContentTokenCount"],i);let l=te(e,["candidatesTokenCount"]);null!=l&&e7(t,["responseTokenCount"],l);let r=te(e,["toolUsePromptTokenCount"]);null!=r&&e7(t,["toolUsePromptTokenCount"],r);let o=te(e,["thoughtsTokenCount"]);null!=o&&e7(t,["thoughtsTokenCount"],o);let a=te(e,["totalTokenCount"]);null!=a&&e7(t,["totalTokenCount"],a);let s=te(e,["promptTokensDetails"]);if(null!=s){let e=s;Array.isArray(e)&&(e=e.map(e=>e)),e7(t,["promptTokensDetails"],e)}let u=te(e,["cacheTokensDetails"]);if(null!=u){let e=u;Array.isArray(e)&&(e=e.map(e=>e)),e7(t,["cacheTokensDetails"],e)}let p=te(e,["candidatesTokensDetails"]);if(null!=p){let e=p;Array.isArray(e)&&(e=e.map(e=>e)),e7(t,["responseTokensDetails"],e)}let d=te(e,["toolUsePromptTokensDetails"]);if(null!=d){let e=d;Array.isArray(e)&&(e=e.map(e=>e)),e7(t,["toolUsePromptTokensDetails"],e)}let c=te(e,["trafficType"]);return null!=c&&e7(t,["trafficType"],c),t}(a)),null!=(s=te(l,["goAway"]))&&e7(e,["goAway"],s),null!=(u=te(l,["sessionResumptionUpdate"]))&&e7(e,["sessionResumptionUpdate"],u),e))}else Object.assign(i,l);t(i)}class nF{constructor(e,t,n){this.apiClient=e,this.auth=t,this.webSocketFactory=n,this.music=new nx(this.apiClient,this.auth,this.webSocketFactory)}async connect(e){var t,n,i,l,r,o,a,s;let u,p;if(e.config&&e.config.httpOptions)throw Error("The Live module does not support httpOptions at request-level in LiveConnectConfig yet. Please use the client-level httpOptions configuration instead.");let d=this.apiClient.getWebsocketBaseUrl(),c=this.apiClient.getApiVersion(),h=this.apiClient.getHeaders();e.config&&e.config.tools&&nU(e.config.tools)&&nk(h);let m=function(e){let t=new Headers;for(let[n,i]of Object.entries(e))t.append(n,i);return t}(h);if(this.apiClient.isVertexAI())u=`${d}/ws/google.cloud.aiplatform.${c}.LlmBidiService/BidiGenerateContent`,await this.auth.addAuthHeaders(m,u);else{let e=this.apiClient.getApiKey(),t="BidiGenerateContent",n="key";(null==e?void 0:e.startsWith("auth_tokens/"))&&(console.warn("Warning: Ephemeral token support is experimental and may change in future versions."),"v1alpha"!==c&&console.warn("Warning: The SDK's ephemeral token support is in v1alpha only. Please use const ai = new GoogleGenAI({apiKey: token.name, httpOptions: { apiVersion: 'v1alpha' }}); before session connection."),t="BidiGenerateContentConstrained",n="access_token"),u=`${d}/ws/google.ai.generativelanguage.${c}.GenerativeService.${t}?${n}=${e}`}let f=()=>{},g=new Promise(e=>{f=e}),y=e.callbacks,E=this.apiClient,_={onopen:function(){var e;null==(e=null==y?void 0:y.onopen)||e.call(y),f({})},onmessage:e=>{nH(E,y.onmessage,e)},onerror:null!=(t=null==y?void 0:y.onerror)?t:function(e){},onclose:null!=(n=null==y?void 0:y.onclose)?n:function(e){}},T=this.webSocketFactory.create(u,(p={},m.forEach((e,t)=>{p[t]=e}),p),_);T.connect(),await g;let v=tP(this.apiClient,e.model);if(this.apiClient.isVertexAI()&&v.startsWith("publishers/")){let e=this.apiClient.getProject(),t=this.apiClient.getLocation();v=`projects/${e}/locations/${t}/`+v}let A={};this.apiClient.isVertexAI()&&(null==(i=e.config)?void 0:i.responseModalities)===void 0&&(void 0===e.config?e.config={responseModalities:[I.AUDIO]}:e.config.responseModalities=[I.AUDIO]),(null==(l=e.config)?void 0:l.generationConfig)&&console.warn("Setting `LiveConnectConfig.generation_config` is deprecated, please set the fields on `LiveConnectConfig` directly. This will become an error in a future version (not before Q3 2025).");let C=null!=(o=null==(r=e.config)?void 0:r.tools)?o:[],S=[];for(let e of C)this.isCallableTool(e)?S.push(await e.tool()):S.push(e);S.length>0&&(e.config.tools=S);let O={model:v,config:e.config,callbacks:e.callbacks};if(this.apiClient.isVertexAI()){let e,t,n;a=this.apiClient,e={},null!=(t=te(O,["model"]))&&e7(e,["setup","model"],tP(a,t)),null!=(n=te(O,["config"]))&&e7(e,["config"],function(e,t){let n=te(e,["generationConfig"]);void 0!==t&&null!=n&&e7(t,["setup","generationConfig"],function(e){let t={},n=te(e,["modelSelectionConfig"]);null!=n&&e7(t,["modelConfig"],n);let i=te(e,["responseJsonSchema"]);null!=i&&e7(t,["responseJsonSchema"],i);let l=te(e,["audioTimestamp"]);null!=l&&e7(t,["audioTimestamp"],l);let r=te(e,["candidateCount"]);null!=r&&e7(t,["candidateCount"],r);let o=te(e,["enableAffectiveDialog"]);null!=o&&e7(t,["enableAffectiveDialog"],o);let a=te(e,["frequencyPenalty"]);null!=a&&e7(t,["frequencyPenalty"],a);let s=te(e,["logprobs"]);null!=s&&e7(t,["logprobs"],s);let u=te(e,["maxOutputTokens"]);null!=u&&e7(t,["maxOutputTokens"],u);let p=te(e,["mediaResolution"]);null!=p&&e7(t,["mediaResolution"],p);let d=te(e,["presencePenalty"]);null!=d&&e7(t,["presencePenalty"],d);let c=te(e,["responseLogprobs"]);null!=c&&e7(t,["responseLogprobs"],c);let h=te(e,["responseMimeType"]);null!=h&&e7(t,["responseMimeType"],h);let m=te(e,["responseModalities"]);null!=m&&e7(t,["responseModalities"],m);let f=te(e,["responseSchema"]);null!=f&&e7(t,["responseSchema"],f);let g=te(e,["routingConfig"]);null!=g&&e7(t,["routingConfig"],g);let y=te(e,["seed"]);null!=y&&e7(t,["seed"],y);let E=te(e,["speechConfig"]);null!=E&&e7(t,["speechConfig"],nc(E));let _=te(e,["stopSequences"]);null!=_&&e7(t,["stopSequences"],_);let I=te(e,["temperature"]);null!=I&&e7(t,["temperature"],I);let T=te(e,["thinkingConfig"]);null!=T&&e7(t,["thinkingConfig"],T);let v=te(e,["topK"]);null!=v&&e7(t,["topK"],v);let A=te(e,["topP"]);if(null!=A&&e7(t,["topP"],A),void 0!==te(e,["enableEnhancedCivicAnswers"]))throw Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");return t}(n));let i=te(e,["responseModalities"]);void 0!==t&&null!=i&&e7(t,["setup","generationConfig","responseModalities"],i);let l=te(e,["temperature"]);void 0!==t&&null!=l&&e7(t,["setup","generationConfig","temperature"],l);let r=te(e,["topP"]);void 0!==t&&null!=r&&e7(t,["setup","generationConfig","topP"],r);let o=te(e,["topK"]);void 0!==t&&null!=o&&e7(t,["setup","generationConfig","topK"],o);let a=te(e,["maxOutputTokens"]);void 0!==t&&null!=a&&e7(t,["setup","generationConfig","maxOutputTokens"],a);let s=te(e,["mediaResolution"]);void 0!==t&&null!=s&&e7(t,["setup","generationConfig","mediaResolution"],s);let u=te(e,["seed"]);void 0!==t&&null!=u&&e7(t,["setup","generationConfig","seed"],u);let p=te(e,["speechConfig"]);void 0!==t&&null!=p&&e7(t,["setup","generationConfig","speechConfig"],nc(tY(p)));let d=te(e,["thinkingConfig"]);void 0!==t&&null!=d&&e7(t,["setup","generationConfig","thinkingConfig"],d);let c=te(e,["enableAffectiveDialog"]);void 0!==t&&null!=c&&e7(t,["setup","generationConfig","enableAffectiveDialog"],c);let h=te(e,["systemInstruction"]);void 0!==t&&null!=h&&e7(t,["setup","systemInstruction"],tF(h));let m=te(e,["tools"]);if(void 0!==t&&null!=m){let e=t$(m);Array.isArray(e)&&(e=e.map(e=>(function(e){let t={},n=te(e,["functionDeclarations"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>(function(e){let t={};if(void 0!==te(e,["behavior"]))throw Error("behavior parameter is not supported in Vertex AI.");let n=te(e,["description"]);null!=n&&e7(t,["description"],n);let i=te(e,["name"]);null!=i&&e7(t,["name"],i);let l=te(e,["parameters"]);null!=l&&e7(t,["parameters"],l);let r=te(e,["parametersJsonSchema"]);null!=r&&e7(t,["parametersJsonSchema"],r);let o=te(e,["response"]);null!=o&&e7(t,["response"],o);let a=te(e,["responseJsonSchema"]);return null!=a&&e7(t,["responseJsonSchema"],a),t})(e))),e7(t,["functionDeclarations"],e)}let i=te(e,["retrieval"]);null!=i&&e7(t,["retrieval"],i);let l=te(e,["googleSearchRetrieval"]);null!=l&&e7(t,["googleSearchRetrieval"],l);let r=te(e,["computerUse"]);if(null!=r&&e7(t,["computerUse"],r),void 0!==te(e,["fileSearch"]))throw Error("fileSearch parameter is not supported in Vertex AI.");let o=te(e,["codeExecution"]);null!=o&&e7(t,["codeExecution"],o);let a=te(e,["enterpriseWebSearch"]);null!=a&&e7(t,["enterpriseWebSearch"],a);let s=te(e,["googleMaps"]);null!=s&&e7(t,["googleMaps"],s);let u=te(e,["googleSearch"]);null!=u&&e7(t,["googleSearch"],u);let p=te(e,["urlContext"]);return null!=p&&e7(t,["urlContext"],p),t})(tK(e)))),e7(t,["setup","tools"],e)}let f=te(e,["sessionResumption"]);void 0!==t&&null!=f&&e7(t,["setup","sessionResumption"],f);let g=te(e,["inputAudioTranscription"]);void 0!==t&&null!=g&&e7(t,["setup","inputAudioTranscription"],g);let y=te(e,["outputAudioTranscription"]);void 0!==t&&null!=y&&e7(t,["setup","outputAudioTranscription"],y);let E=te(e,["realtimeInputConfig"]);void 0!==t&&null!=E&&e7(t,["setup","realtimeInputConfig"],E);let _=te(e,["contextWindowCompression"]);void 0!==t&&null!=_&&e7(t,["setup","contextWindowCompression"],_);let I=te(e,["proactivity"]);return void 0!==t&&null!=I&&e7(t,["setup","proactivity"],I),{}}(n,e)),A=e}else{let e,t,n;s=this.apiClient,e={},null!=(t=te(O,["model"]))&&e7(e,["setup","model"],tP(s,t)),null!=(n=te(O,["config"]))&&e7(e,["config"],function(e,t){let n=te(e,["generationConfig"]);void 0!==t&&null!=n&&e7(t,["setup","generationConfig"],n);let i=te(e,["responseModalities"]);void 0!==t&&null!=i&&e7(t,["setup","generationConfig","responseModalities"],i);let l=te(e,["temperature"]);void 0!==t&&null!=l&&e7(t,["setup","generationConfig","temperature"],l);let r=te(e,["topP"]);void 0!==t&&null!=r&&e7(t,["setup","generationConfig","topP"],r);let o=te(e,["topK"]);void 0!==t&&null!=o&&e7(t,["setup","generationConfig","topK"],o);let a=te(e,["maxOutputTokens"]);void 0!==t&&null!=a&&e7(t,["setup","generationConfig","maxOutputTokens"],a);let s=te(e,["mediaResolution"]);void 0!==t&&null!=s&&e7(t,["setup","generationConfig","mediaResolution"],s);let u=te(e,["seed"]);void 0!==t&&null!=u&&e7(t,["setup","generationConfig","seed"],u);let p=te(e,["speechConfig"]);void 0!==t&&null!=p&&e7(t,["setup","generationConfig","speechConfig"],tY(p));let d=te(e,["thinkingConfig"]);void 0!==t&&null!=d&&e7(t,["setup","generationConfig","thinkingConfig"],d);let c=te(e,["enableAffectiveDialog"]);void 0!==t&&null!=c&&e7(t,["setup","generationConfig","enableAffectiveDialog"],c);let h=te(e,["systemInstruction"]);void 0!==t&&null!=h&&e7(t,["setup","systemInstruction"],function(e){let t={},n=te(e,["parts"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>{var t;let n,i,l,r,o,a,s,u,p,d,c,h;return n={},null!=(i=te(t=e,["mediaResolution"]))&&e7(n,["mediaResolution"],i),null!=(l=te(t,["codeExecutionResult"]))&&e7(n,["codeExecutionResult"],l),null!=(r=te(t,["executableCode"]))&&e7(n,["executableCode"],r),null!=(o=te(t,["fileData"]))&&e7(n,["fileData"],function(e){let t={};if(void 0!==te(e,["displayName"]))throw Error("displayName parameter is not supported in Gemini API.");let n=te(e,["fileUri"]);null!=n&&e7(t,["fileUri"],n);let i=te(e,["mimeType"]);return null!=i&&e7(t,["mimeType"],i),t}(o)),null!=(a=te(t,["functionCall"]))&&e7(n,["functionCall"],function(e){let t={},n=te(e,["id"]);null!=n&&e7(t,["id"],n);let i=te(e,["args"]);null!=i&&e7(t,["args"],i);let l=te(e,["name"]);if(null!=l&&e7(t,["name"],l),void 0!==te(e,["partialArgs"]))throw Error("partialArgs parameter is not supported in Gemini API.");if(void 0!==te(e,["willContinue"]))throw Error("willContinue parameter is not supported in Gemini API.");return t}(a)),null!=(s=te(t,["functionResponse"]))&&e7(n,["functionResponse"],s),null!=(u=te(t,["inlineData"]))&&e7(n,["inlineData"],nd(u)),null!=(p=te(t,["text"]))&&e7(n,["text"],p),null!=(d=te(t,["thought"]))&&e7(n,["thought"],d),null!=(c=te(t,["thoughtSignature"]))&&e7(n,["thoughtSignature"],c),null!=(h=te(t,["videoMetadata"]))&&e7(n,["videoMetadata"],h),n})),e7(t,["parts"],e)}let i=te(e,["role"]);return null!=i&&e7(t,["role"],i),t}(tF(h)));let m=te(e,["tools"]);if(void 0!==t&&null!=m){let e=t$(m);Array.isArray(e)&&(e=e.map(e=>(function(e){let t={},n=te(e,["functionDeclarations"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>e)),e7(t,["functionDeclarations"],e)}if(void 0!==te(e,["retrieval"]))throw Error("retrieval parameter is not supported in Gemini API.");let i=te(e,["googleSearchRetrieval"]);null!=i&&e7(t,["googleSearchRetrieval"],i);let l=te(e,["computerUse"]);null!=l&&e7(t,["computerUse"],l);let r=te(e,["fileSearch"]);null!=r&&e7(t,["fileSearch"],r);let o=te(e,["codeExecution"]);if(null!=o&&e7(t,["codeExecution"],o),void 0!==te(e,["enterpriseWebSearch"]))throw Error("enterpriseWebSearch parameter is not supported in Gemini API.");let a=te(e,["googleMaps"]);null!=a&&e7(t,["googleMaps"],function(e){let t={};if(void 0!==te(e,["authConfig"]))throw Error("authConfig parameter is not supported in Gemini API.");let n=te(e,["enableWidget"]);return null!=n&&e7(t,["enableWidget"],n),t}(a));let s=te(e,["googleSearch"]);null!=s&&e7(t,["googleSearch"],function(e){let t={};if(void 0!==te(e,["excludeDomains"]))throw Error("excludeDomains parameter is not supported in Gemini API.");if(void 0!==te(e,["blockingConfidence"]))throw Error("blockingConfidence parameter is not supported in Gemini API.");let n=te(e,["timeRangeFilter"]);return null!=n&&e7(t,["timeRangeFilter"],n),t}(s));let u=te(e,["urlContext"]);return null!=u&&e7(t,["urlContext"],u),t})(tK(e)))),e7(t,["setup","tools"],e)}let f=te(e,["sessionResumption"]);void 0!==t&&null!=f&&e7(t,["setup","sessionResumption"],function(e){let t={},n=te(e,["handle"]);if(null!=n&&e7(t,["handle"],n),void 0!==te(e,["transparent"]))throw Error("transparent parameter is not supported in Gemini API.");return t}(f));let g=te(e,["inputAudioTranscription"]);void 0!==t&&null!=g&&e7(t,["setup","inputAudioTranscription"],g);let y=te(e,["outputAudioTranscription"]);void 0!==t&&null!=y&&e7(t,["setup","outputAudioTranscription"],y);let E=te(e,["realtimeInputConfig"]);void 0!==t&&null!=E&&e7(t,["setup","realtimeInputConfig"],E);let _=te(e,["contextWindowCompression"]);void 0!==t&&null!=_&&e7(t,["setup","contextWindowCompression"],_);let I=te(e,["proactivity"]);return void 0!==t&&null!=I&&e7(t,["setup","proactivity"],I),{}}(n,e)),A=e}return delete A.config,T.send(JSON.stringify(A)),new nj(T,this.apiClient)}isCallableTool(e){return"callTool"in e&&"function"==typeof e.callTool}}let nV={turnComplete:!0};class nj{constructor(e,t){this.conn=e,this.apiClient=t}tLiveClientContent(e,t){if(null!==t.turns&&void 0!==t.turns){let n=[];try{n=tj(t.turns),e.isVertexAI()||(n=n.map(e=>nh(e)))}catch(e){throw Error(`Failed to parse client content "turns", type: '${typeof t.turns}'`)}return{clientContent:{turns:n,turnComplete:t.turnComplete}}}return{clientContent:{turnComplete:t.turnComplete}}}tLiveClienttToolResponse(e,t){let n=[];if(null==t.functionResponses||0===(n=Array.isArray(t.functionResponses)?t.functionResponses:[t.functionResponses]).length)throw Error("functionResponses is required.");for(let t of n){if("object"!=typeof t||null===t||!("name"in t)||!("response"in t))throw Error(`Could not parse function response, type '${typeof t}'.`);if(!e.isVertexAI()&&!("id"in t))throw Error("FunctionResponse request must have an `id` field from the response of a ToolCall.FunctionalCalls in Google AI.")}return{toolResponse:{functionResponses:n}}}sendClientContent(e){e=Object.assign(Object.assign({},nV),e);let t=this.tLiveClientContent(this.apiClient,e);this.conn.send(JSON.stringify(t))}sendRealtimeInput(e){let t={};t=this.apiClient.isVertexAI()?{realtimeInput:function(e){let t={},n=te(e,["media"]);if(null!=n){let e=tM(n);Array.isArray(e)&&(e=e.map(e=>e)),e7(t,["mediaChunks"],e)}let i=te(e,["audio"]);null!=i&&e7(t,["audio"],tk(i));let l=te(e,["audioStreamEnd"]);null!=l&&e7(t,["audioStreamEnd"],l);let r=te(e,["video"]);null!=r&&e7(t,["video"],tU(r));let o=te(e,["text"]);null!=o&&e7(t,["text"],o);let a=te(e,["activityStart"]);null!=a&&e7(t,["activityStart"],a);let s=te(e,["activityEnd"]);return null!=s&&e7(t,["activityEnd"],s),t}(e)}:{realtimeInput:function(e){let t={},n=te(e,["media"]);if(null!=n){let e=tM(n);Array.isArray(e)&&(e=e.map(e=>nd(e))),e7(t,["mediaChunks"],e)}let i=te(e,["audio"]);null!=i&&e7(t,["audio"],nd(tk(i)));let l=te(e,["audioStreamEnd"]);null!=l&&e7(t,["audioStreamEnd"],l);let r=te(e,["video"]);null!=r&&e7(t,["video"],nd(tU(r)));let o=te(e,["text"]);null!=o&&e7(t,["text"],o);let a=te(e,["activityStart"]);null!=a&&e7(t,["activityStart"],a);let s=te(e,["activityEnd"]);return null!=s&&e7(t,["activityEnd"],s),t}(e)},this.conn.send(JSON.stringify(t))}sendToolResponse(e){if(null==e.functionResponses)throw Error("Tool response parameters are required.");let t=this.tLiveClienttToolResponse(this.apiClient,e);this.conn.send(JSON.stringify(t))}close(){this.conn.close()}}function nB(e){var t,n,i;if(null==(t=null==e?void 0:e.automaticFunctionCalling)?void 0:t.disable)return!0;let l=!1;for(let t of null!=(n=null==e?void 0:e.tools)?n:[])if(nJ(t)){l=!0;break}if(!l)return!0;let r=null==(i=null==e?void 0:e.automaticFunctionCalling)?void 0:i.maximumRemoteCalls;return(!(!r||!(r<0)&&Number.isInteger(r))||0==r)&&(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),!0)}function nJ(e){return"callTool"in e&&"function"==typeof e.callTool}function nY(e){var t;let n=[];return(null==(t=null==e?void 0:e.config)?void 0:t.tools)&&e.config.tools.forEach((e,t)=>{nJ(e)||e.functionDeclarations&&e.functionDeclarations.length>0&&n.push(t)}),n}function nK(e){var t;return!(null==(t=null==e?void 0:e.automaticFunctionCalling)?void 0:t.ignoreCallHistory)}class n$ extends e5{constructor(e){super(),this.apiClient=e,this.generateContent=async e=>{var t,n,i,l,r,o,a,s;let u,p,d=await this.processParamsMaybeAddMcpUsage(e);if(this.maybeMoveToResponseJsonSchem(e),!(null!=(s=null==(a=null==(o=e.config)?void 0:o.tools)?void 0:a.some(e=>nJ(e)))&&s)||nB(e.config))return await this.generateContentInternal(d);let c=nY(e);if(c.length>0){let e=c.map(e=>`tools[${e}]`).join(", ");throw Error(`Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations is not yet supported. Incompatible tools found at ${e}.`)}let h=tj(d.contents),m=null!=(i=null==(n=null==(t=d.config)?void 0:t.automaticFunctionCalling)?void 0:n.maximumRemoteCalls)?i:10,f=0;for(;f<m&&(u=await this.generateContentInternal(d)).functionCalls&&0!==u.functionCalls.length;){let t=u.candidates[0].content,n=[];for(let t of null!=(r=null==(l=e.config)?void 0:l.tools)?r:[])if(nJ(t)){let e=await t.callTool(u.functionCalls);n.push(...e)}f++,p={role:"user",parts:n},d.contents=tj(d.contents),d.contents.push(t),d.contents.push(p),nK(d.config)&&(h.push(t),h.push(p))}return nK(d.config)&&(u.automaticFunctionCallingHistory=h),u},this.generateContentStream=async e=>{var t,n,i,l,r;if(this.maybeMoveToResponseJsonSchem(e),nB(e.config)){let t=await this.processParamsMaybeAddMcpUsage(e);return await this.generateContentStreamInternal(t)}let o=nY(e);if(o.length>0){let e=o.map(e=>`tools[${e}]`).join(", ");throw Error(`Incompatible tools found at ${e}. Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations" is not yet supported.`)}let a=null==(i=null==(n=null==(t=null==e?void 0:e.config)?void 0:t.toolConfig)?void 0:n.functionCallingConfig)?void 0:i.streamFunctionCallArguments,s=null==(r=null==(l=null==e?void 0:e.config)?void 0:l.automaticFunctionCalling)?void 0:r.disable;if(a&&!s)throw Error("Running in streaming mode with 'streamFunctionCallArguments' enabled, this feature is not compatible with automatic function calling (AFC). Please set 'config.automaticFunctionCalling.disable' to true to disable AFC or leave 'config.toolConfig.functionCallingConfig.streamFunctionCallArguments' to be undefined or set to false to disable streaming function call arguments feature.");return await this.processAfcStream(e)},this.generateImages=async e=>await this.generateImagesInternal(e).then(e=>{var t;let n,i=[];if(null==e?void 0:e.generatedImages)for(let l of e.generatedImages)l&&(null==l?void 0:l.safetyAttributes)&&(null==(t=null==l?void 0:l.safetyAttributes)?void 0:t.contentType)==="Positive Prompt"?n=null==l?void 0:l.safetyAttributes:i.push(l);return n?{generatedImages:i,positivePromptSafetyAttributes:n,sdkHttpResponse:e.sdkHttpResponse}:{generatedImages:i,sdkHttpResponse:e.sdkHttpResponse}}),this.list=async e=>{var t;let n={config:Object.assign(Object.assign({},{queryBase:!0}),null==e?void 0:e.config)};if(this.apiClient.isVertexAI()&&!n.config.queryBase)if(null==(t=n.config)?void 0:t.filter)throw Error("Filtering tuned models list for Vertex AI is not currently supported");else n.config.filter="labels.tune-type:*";return new t8(en.PAGED_ITEM_MODELS,e=>this.listInternal(e),await this.listInternal(n),n)},this.editImage=async e=>{let t={model:e.model,prompt:e.prompt,referenceImages:[],config:e.config};return e.referenceImages&&e.referenceImages&&(t.referenceImages=e.referenceImages.map(e=>e.toReferenceImageAPI())),await this.editImageInternal(t)},this.upscaleImage=async e=>{let t={numberOfImages:1,mode:"upscale"};e.config&&(t=Object.assign(Object.assign({},t),e.config));let n={model:e.model,image:e.image,upscaleFactor:e.upscaleFactor,config:t};return await this.upscaleImageInternal(n)},this.generateVideos=async e=>{var t,n,i,l,r,o;if((e.prompt||e.image||e.video)&&e.source)throw Error("Source and prompt/image/video are mutually exclusive. Please only use source.");return!this.apiClient.isVertexAI()&&((null==(t=e.video)?void 0:t.uri)&&(null==(n=e.video)?void 0:n.videoBytes)?e.video={uri:e.video.uri,mimeType:e.video.mimeType}:(null==(l=null==(i=e.source)?void 0:i.video)?void 0:l.uri)&&(null==(o=null==(r=e.source)?void 0:r.video)?void 0:o.videoBytes)&&(e.source.video={uri:e.source.video.uri,mimeType:e.source.video.mimeType})),await this.generateVideosInternal(e)}}maybeMoveToResponseJsonSchem(e){e.config&&e.config.responseSchema&&!e.config.responseJsonSchema&&Object.keys(e.config.responseSchema).includes("$schema")&&(e.config.responseJsonSchema=e.config.responseSchema,delete e.config.responseSchema)}async processParamsMaybeAddMcpUsage(e){var t,n,i;let l=null==(t=e.config)?void 0:t.tools;if(!l)return e;let r=await Promise.all(l.map(async e=>nJ(e)?await e.tool():e)),o={model:e.model,contents:e.contents,config:Object.assign(Object.assign({},e.config),{tools:r})};if(o.config.tools=r,e.config&&e.config.tools&&nU(e.config.tools)){let t=Object.assign({},null!=(i=null==(n=e.config.httpOptions)?void 0:n.headers)?i:{});0===Object.keys(t).length&&(t=this.apiClient.getDefaultHeaders()),nk(t),o.config.httpOptions=Object.assign(Object.assign({},e.config.httpOptions),{headers:t})}return o}async initAfcToolsMap(e){var t,n,i;let l=new Map;for(let r of null!=(n=null==(t=e.config)?void 0:t.tools)?n:[])if(nJ(r))for(let e of null!=(i=(await r.tool()).functionDeclarations)?i:[]){if(!e.name)throw Error("Function declaration name is required.");if(l.has(e.name))throw Error(`Duplicate tool declaration name: ${e.name}`);l.set(e.name,r)}return l}async processAfcStream(e){var t,n,i;let l=null!=(i=null==(n=null==(t=e.config)?void 0:t.automaticFunctionCalling)?void 0:n.maximumRemoteCalls)?i:10,r=!1,o=0;return function(e,t,n){var i,a;return ni(this,arguments,function*(){for(var s,u,p,d;o<l;){r&&(o++,r=!1);let f=yield nn(e.processParamsMaybeAddMcpUsage(n)),g=yield nn(e.generateContentStreamInternal(f)),y=[],E=[];try{for(var c,h=!0,m=(u=void 0,nl(g));!(s=(c=yield nn(m.next())).done);h=!0)if(d=c.value,h=!1,yield yield nn(d),d.candidates&&(null==(i=d.candidates[0])?void 0:i.content)){for(let e of(E.push(d.candidates[0].content),null!=(a=d.candidates[0].content.parts)?a:[]))if(o<l&&e.functionCall){if(!e.functionCall.name)throw Error("Function call name was not returned by the model.");if(t.has(e.functionCall.name)){let n=yield nn(t.get(e.functionCall.name).callTool([e.functionCall]));y.push(...n)}else throw Error(`Automatic function calling was requested, but not all the tools the model used implement the CallableTool interface. Available tools: ${t.keys()}, mising tool: ${e.functionCall.name}`)}}}catch(e){u={error:e}}finally{try{!h&&!s&&(p=m.return)&&(yield nn(p.call(m)))}finally{if(u)throw u.error}}if(y.length>0){r=!0;let e=new tl;e.candidates=[{content:{role:"user",parts:y}}],yield yield nn(e);let t=[];t.push(...E),t.push({role:"user",parts:y});let i=tj(n.contents).concat(t);n.contents=i}else break}})}(this,await this.initAfcToolsMap(e),e)}async generateContentInternal(e){var t,n,i,l;let r="",o={};if(this.apiClient.isVertexAI()){let i=nf(this.apiClient,e);return r=e8("{model}:generateContent",i._url),o=i._query,delete i._url,delete i._query,this.apiClient.request({path:r,queryParams:o,body:JSON.stringify(i),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=ny(e),n=new tl;return Object.assign(n,t),n})}{let t=nm(this.apiClient,e);return r=e8("{model}:generateContent",t._url),o=t._query,delete t._url,delete t._query,this.apiClient.request({path:r,queryParams:o,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(l=e.config)?void 0:l.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=ng(e),n=new tl;return Object.assign(n,t),n})}}async generateContentStreamInternal(e){var t,n,i,l;let r="",o={};if(this.apiClient.isVertexAI()){let i=nf(this.apiClient,e);return r=e8("{model}:streamGenerateContent?alt=sse",i._url),o=i._query,delete i._url,delete i._query,this.apiClient.requestStream({path:r,queryParams:o,body:JSON.stringify(i),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(function(e){return ni(this,arguments,function*(){var t,n,i,l;try{for(var r,o=!0,a=nl(e);!(t=(r=yield nn(a.next())).done);o=!0){l=r.value,o=!1;let e=ny((yield nn(l.json())));e.sdkHttpResponse={headers:l.headers};let t=new tl;Object.assign(t,e),yield yield nn(t)}}catch(e){n={error:e}}finally{try{!o&&!t&&(i=a.return)&&(yield nn(i.call(a)))}finally{if(n)throw n.error}}})})}{let t=nm(this.apiClient,e);return r=e8("{model}:streamGenerateContent?alt=sse",t._url),o=t._query,delete t._url,delete t._query,this.apiClient.requestStream({path:r,queryParams:o,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(l=e.config)?void 0:l.abortSignal}).then(function(e){return ni(this,arguments,function*(){var t,n,i,l;try{for(var r,o=!0,a=nl(e);!(t=(r=yield nn(a.next())).done);o=!0){l=r.value,o=!1;let e=ng((yield nn(l.json())));e.sdkHttpResponse={headers:l.headers};let t=new tl;Object.assign(t,e),yield yield nn(t)}}catch(e){n={error:e}}finally{try{!o&&!t&&(i=a.return)&&(yield nn(i.call(a)))}finally{if(n)throw n.error}}})})}}async embedContent(e){var t,n,i,l;let r="",o={};if(this.apiClient.isVertexAI()){let i=function(e,t){let n,i,l,r,o,a={},s=te(t,["model"]);null!=s&&e7(a,["_url","model"],tP(e,s));let u=te(t,["contents"]);if(null!=u){let t=tV(e,u);Array.isArray(t)&&(t=t.map(e=>e)),e7(a,["instances[]","content"],t)}let p=te(t,["config"]);return null!=p&&(n=te(p,["taskType"]),void 0!==a&&null!=n&&e7(a,["instances[]","task_type"],n),i=te(p,["title"]),void 0!==a&&null!=i&&e7(a,["instances[]","title"],i),l=te(p,["outputDimensionality"]),void 0!==a&&null!=l&&e7(a,["parameters","outputDimensionality"],l),r=te(p,["mimeType"]),void 0!==a&&null!=r&&e7(a,["instances[]","mimeType"],r),o=te(p,["autoTruncate"]),void 0!==a&&null!=o&&e7(a,["parameters","autoTruncate"],o)),a}(this.apiClient,e);return r=e8("{model}:predict",i._url),o=i._query,delete i._url,delete i._query,this.apiClient.request({path:r,queryParams:o,body:JSON.stringify(i),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=function(e){let t={},n=te(e,["sdkHttpResponse"]);null!=n&&e7(t,["sdkHttpResponse"],n);let i=te(e,["predictions[]","embeddings"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>{var t;let n,i,l,r,o,a;return n={},null!=(i=te(e,["values"]))&&e7(n,["values"],i),null!=(l=te(e,["statistics"]))&&e7(n,["statistics"],(r={},null!=(o=te(t=l,["truncated"]))&&e7(r,["truncated"],o),null!=(a=te(t,["token_count"]))&&e7(r,["tokenCount"],a),r)),n})),e7(t,["embeddings"],e)}let l=te(e,["metadata"]);return null!=l&&e7(t,["metadata"],l),t}(e),n=new tr;return Object.assign(n,t),n})}{let t=function(e,t){let n={},i=te(t,["model"]);null!=i&&e7(n,["_url","model"],tP(e,i));let l=te(t,["contents"]);if(null!=l){let t=tV(e,l);Array.isArray(t)&&(t=t.map(e=>e)),e7(n,["requests[]","content"],t)}let r=te(t,["config"]);null!=r&&function(e,t){let n=te(e,["taskType"]);void 0!==t&&null!=n&&e7(t,["requests[]","taskType"],n);let i=te(e,["title"]);void 0!==t&&null!=i&&e7(t,["requests[]","title"],i);let l=te(e,["outputDimensionality"]);if(void 0!==t&&null!=l&&e7(t,["requests[]","outputDimensionality"],l),void 0!==te(e,["mimeType"]))throw Error("mimeType parameter is not supported in Gemini API.");if(void 0!==te(e,["autoTruncate"]))throw Error("autoTruncate parameter is not supported in Gemini API.")}(r,n);let o=te(t,["model"]);return void 0!==o&&e7(n,["requests[]","model"],tP(e,o)),n}(this.apiClient,e);return r=e8("{model}:batchEmbedContents",t._url),o=t._query,delete t._url,delete t._query,this.apiClient.request({path:r,queryParams:o,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(l=e.config)?void 0:l.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=function(e){let t={},n=te(e,["sdkHttpResponse"]);null!=n&&e7(t,["sdkHttpResponse"],n);let i=te(e,["embeddings"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),e7(t,["embeddings"],e)}let l=te(e,["metadata"]);return null!=l&&e7(t,["metadata"],l),t}(e),n=new tr;return Object.assign(n,t),n})}}async generateImagesInternal(e){var t,n,i,l,r,o;let a="",s={};if(this.apiClient.isVertexAI()){let i,l,o,u,p,d,c,h,m,f,g,y,E,_,I,T,v,A,C,S,O,b=(r=this.apiClient,i={},null!=(l=te(e,["model"]))&&e7(i,["_url","model"],tP(r,l)),null!=(o=te(e,["prompt"]))&&e7(i,["instances[0]","prompt"],o),null!=(u=te(e,["config"]))&&(p=te(u,["outputGcsUri"]),void 0!==i&&null!=p&&e7(i,["parameters","storageUri"],p),d=te(u,["negativePrompt"]),void 0!==i&&null!=d&&e7(i,["parameters","negativePrompt"],d),c=te(u,["numberOfImages"]),void 0!==i&&null!=c&&e7(i,["parameters","sampleCount"],c),h=te(u,["aspectRatio"]),void 0!==i&&null!=h&&e7(i,["parameters","aspectRatio"],h),m=te(u,["guidanceScale"]),void 0!==i&&null!=m&&e7(i,["parameters","guidanceScale"],m),f=te(u,["seed"]),void 0!==i&&null!=f&&e7(i,["parameters","seed"],f),g=te(u,["safetyFilterLevel"]),void 0!==i&&null!=g&&e7(i,["parameters","safetySetting"],g),y=te(u,["personGeneration"]),void 0!==i&&null!=y&&e7(i,["parameters","personGeneration"],y),E=te(u,["includeSafetyAttributes"]),void 0!==i&&null!=E&&e7(i,["parameters","includeSafetyAttributes"],E),_=te(u,["includeRaiReason"]),void 0!==i&&null!=_&&e7(i,["parameters","includeRaiReason"],_),I=te(u,["language"]),void 0!==i&&null!=I&&e7(i,["parameters","language"],I),T=te(u,["outputMimeType"]),void 0!==i&&null!=T&&e7(i,["parameters","outputOptions","mimeType"],T),v=te(u,["outputCompressionQuality"]),void 0!==i&&null!=v&&e7(i,["parameters","outputOptions","compressionQuality"],v),A=te(u,["addWatermark"]),void 0!==i&&null!=A&&e7(i,["parameters","addWatermark"],A),C=te(u,["labels"]),void 0!==i&&null!=C&&e7(i,["labels"],C),S=te(u,["imageSize"]),void 0!==i&&null!=S&&e7(i,["parameters","sampleImageSize"],S),O=te(u,["enhancePrompt"]),void 0!==i&&null!=O&&e7(i,["parameters","enhancePrompt"],O)),i);return a=e8("{model}:predict",b._url),s=b._query,delete b._url,delete b._query,this.apiClient.request({path:a,queryParams:s,body:JSON.stringify(b),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=function(e){let t={},n=te(e,["sdkHttpResponse"]);null!=n&&e7(t,["sdkHttpResponse"],n);let i=te(e,["predictions"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>nE(e))),e7(t,["generatedImages"],e)}let l=te(e,["positivePromptSafetyAttributes"]);return null!=l&&e7(t,["positivePromptSafetyAttributes"],nS(l)),t}(e),n=new to;return Object.assign(n,t),n})}{let t,n,r,u,p=(o=this.apiClient,t={},null!=(n=te(e,["model"]))&&e7(t,["_url","model"],tP(o,n)),null!=(r=te(e,["prompt"]))&&e7(t,["instances[0]","prompt"],r),null!=(u=te(e,["config"]))&&function(e,t){if(void 0!==te(e,["outputGcsUri"]))throw Error("outputGcsUri parameter is not supported in Gemini API.");if(void 0!==te(e,["negativePrompt"]))throw Error("negativePrompt parameter is not supported in Gemini API.");let n=te(e,["numberOfImages"]);void 0!==t&&null!=n&&e7(t,["parameters","sampleCount"],n);let i=te(e,["aspectRatio"]);void 0!==t&&null!=i&&e7(t,["parameters","aspectRatio"],i);let l=te(e,["guidanceScale"]);if(void 0!==t&&null!=l&&e7(t,["parameters","guidanceScale"],l),void 0!==te(e,["seed"]))throw Error("seed parameter is not supported in Gemini API.");let r=te(e,["safetyFilterLevel"]);void 0!==t&&null!=r&&e7(t,["parameters","safetySetting"],r);let o=te(e,["personGeneration"]);void 0!==t&&null!=o&&e7(t,["parameters","personGeneration"],o);let a=te(e,["includeSafetyAttributes"]);void 0!==t&&null!=a&&e7(t,["parameters","includeSafetyAttributes"],a);let s=te(e,["includeRaiReason"]);void 0!==t&&null!=s&&e7(t,["parameters","includeRaiReason"],s);let u=te(e,["language"]);void 0!==t&&null!=u&&e7(t,["parameters","language"],u);let p=te(e,["outputMimeType"]);void 0!==t&&null!=p&&e7(t,["parameters","outputOptions","mimeType"],p);let d=te(e,["outputCompressionQuality"]);if(void 0!==t&&null!=d&&e7(t,["parameters","outputOptions","compressionQuality"],d),void 0!==te(e,["addWatermark"]))throw Error("addWatermark parameter is not supported in Gemini API.");if(void 0!==te(e,["labels"]))throw Error("labels parameter is not supported in Gemini API.");let c=te(e,["imageSize"]);if(void 0!==t&&null!=c&&e7(t,["parameters","sampleImageSize"],c),void 0!==te(e,["enhancePrompt"]))throw Error("enhancePrompt parameter is not supported in Gemini API.")}(u,t),t);return a=e8("{model}:predict",p._url),s=p._query,delete p._url,delete p._query,this.apiClient.request({path:a,queryParams:s,body:JSON.stringify(p),httpMethod:"POST",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(l=e.config)?void 0:l.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=function(e){let t={},n=te(e,["sdkHttpResponse"]);null!=n&&e7(t,["sdkHttpResponse"],n);let i=te(e,["predictions"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>{var t,n;let i,l,r,o,a,s,u;return i={},null!=(l=te(t=e,["_self"]))&&e7(i,["image"],(r={},null!=(o=te(n=l,["bytesBase64Encoded"]))&&e7(r,["imageBytes"],tt(o)),null!=(a=te(n,["mimeType"]))&&e7(r,["mimeType"],a),r)),null!=(s=te(t,["raiFilteredReason"]))&&e7(i,["raiFilteredReason"],s),null!=(u=te(t,["_self"]))&&e7(i,["safetyAttributes"],nC(u)),i})),e7(t,["generatedImages"],e)}let l=te(e,["positivePromptSafetyAttributes"]);return null!=l&&e7(t,["positivePromptSafetyAttributes"],nC(l)),t}(e),n=new to;return Object.assign(n,t),n})}}async editImageInternal(e){var t,n;let i="",l={};if(this.apiClient.isVertexAI()){let r=function(e,t){let n,i,l,r,o,a,s,u,p,d,c,h,m,f,g,y,E,_={},I=te(t,["model"]);null!=I&&e7(_,["_url","model"],tP(e,I));let T=te(t,["prompt"]);null!=T&&e7(_,["instances[0]","prompt"],T);let v=te(t,["referenceImages"]);if(null!=v){let e=v;Array.isArray(e)&&(e=e.map(e=>(function(e){let t,n,i,l,r,o,a,s={},u=te(e,["referenceImage"]);null!=u&&e7(s,["referenceImage"],nT(u));let p=te(e,["referenceId"]);null!=p&&e7(s,["referenceId"],p);let d=te(e,["referenceType"]);null!=d&&e7(s,["referenceType"],d);let c=te(e,["maskImageConfig"]);null!=c&&e7(s,["maskImageConfig"],(t={},null!=(n=te(c,["maskMode"]))&&e7(t,["maskMode"],n),null!=(i=te(c,["segmentationClasses"]))&&e7(t,["maskClasses"],i),null!=(l=te(c,["maskDilation"]))&&e7(t,["dilation"],l),t));let h=te(e,["controlImageConfig"]);null!=h&&e7(s,["controlImageConfig"],(r={},null!=(o=te(h,["controlType"]))&&e7(r,["controlType"],o),null!=(a=te(h,["enableControlImageComputation"]))&&e7(r,["computeControl"],a),r));let m=te(e,["styleImageConfig"]);null!=m&&e7(s,["styleImageConfig"],m);let f=te(e,["subjectImageConfig"]);return null!=f&&e7(s,["subjectImageConfig"],f),s})(e))),e7(_,["instances[0]","referenceImages"],e)}let A=te(t,["config"]);return null!=A&&(n=te(A,["outputGcsUri"]),void 0!==_&&null!=n&&e7(_,["parameters","storageUri"],n),i=te(A,["negativePrompt"]),void 0!==_&&null!=i&&e7(_,["parameters","negativePrompt"],i),l=te(A,["numberOfImages"]),void 0!==_&&null!=l&&e7(_,["parameters","sampleCount"],l),r=te(A,["aspectRatio"]),void 0!==_&&null!=r&&e7(_,["parameters","aspectRatio"],r),o=te(A,["guidanceScale"]),void 0!==_&&null!=o&&e7(_,["parameters","guidanceScale"],o),a=te(A,["seed"]),void 0!==_&&null!=a&&e7(_,["parameters","seed"],a),s=te(A,["safetyFilterLevel"]),void 0!==_&&null!=s&&e7(_,["parameters","safetySetting"],s),u=te(A,["personGeneration"]),void 0!==_&&null!=u&&e7(_,["parameters","personGeneration"],u),p=te(A,["includeSafetyAttributes"]),void 0!==_&&null!=p&&e7(_,["parameters","includeSafetyAttributes"],p),d=te(A,["includeRaiReason"]),void 0!==_&&null!=d&&e7(_,["parameters","includeRaiReason"],d),c=te(A,["language"]),void 0!==_&&null!=c&&e7(_,["parameters","language"],c),h=te(A,["outputMimeType"]),void 0!==_&&null!=h&&e7(_,["parameters","outputOptions","mimeType"],h),m=te(A,["outputCompressionQuality"]),void 0!==_&&null!=m&&e7(_,["parameters","outputOptions","compressionQuality"],m),f=te(A,["addWatermark"]),void 0!==_&&null!=f&&e7(_,["parameters","addWatermark"],f),g=te(A,["labels"]),void 0!==_&&null!=g&&e7(_,["labels"],g),y=te(A,["editMode"]),void 0!==_&&null!=y&&e7(_,["parameters","editMode"],y),E=te(A,["baseSteps"]),void 0!==_&&null!=E&&e7(_,["parameters","editConfig","baseSteps"],E)),_}(this.apiClient,e);return i=e8("{model}:predict",r._url),l=r._query,delete r._url,delete r._query,this.apiClient.request({path:i,queryParams:l,body:JSON.stringify(r),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=function(e){let t={},n=te(e,["sdkHttpResponse"]);null!=n&&e7(t,["sdkHttpResponse"],n);let i=te(e,["predictions"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>nE(e))),e7(t,["generatedImages"],e)}return t}(e),n=new ta;return Object.assign(n,t),n})}throw Error("This method is only supported by the Vertex AI.")}async upscaleImageInternal(e){var t,n,i;let l="",r={};if(this.apiClient.isVertexAI()){let o,a,s,u,p,d,c,h,m,f,g,y,E,_,I,T,v=(i=this.apiClient,o={},null!=(a=te(e,["model"]))&&e7(o,["_url","model"],tP(i,a)),null!=(s=te(e,["image"]))&&e7(o,["instances[0]","image"],nT(s)),null!=(u=te(e,["upscaleFactor"]))&&e7(o,["parameters","upscaleConfig","upscaleFactor"],u),null!=(p=te(e,["config"]))&&(d=te(p,["outputGcsUri"]),void 0!==o&&null!=d&&e7(o,["parameters","storageUri"],d),c=te(p,["safetyFilterLevel"]),void 0!==o&&null!=c&&e7(o,["parameters","safetySetting"],c),h=te(p,["personGeneration"]),void 0!==o&&null!=h&&e7(o,["parameters","personGeneration"],h),m=te(p,["includeRaiReason"]),void 0!==o&&null!=m&&e7(o,["parameters","includeRaiReason"],m),f=te(p,["outputMimeType"]),void 0!==o&&null!=f&&e7(o,["parameters","outputOptions","mimeType"],f),g=te(p,["outputCompressionQuality"]),void 0!==o&&null!=g&&e7(o,["parameters","outputOptions","compressionQuality"],g),y=te(p,["enhanceInputImage"]),void 0!==o&&null!=y&&e7(o,["parameters","upscaleConfig","enhanceInputImage"],y),E=te(p,["imagePreservationFactor"]),void 0!==o&&null!=E&&e7(o,["parameters","upscaleConfig","imagePreservationFactor"],E),_=te(p,["labels"]),void 0!==o&&null!=_&&e7(o,["labels"],_),I=te(p,["numberOfImages"]),void 0!==o&&null!=I&&e7(o,["parameters","sampleCount"],I),T=te(p,["mode"]),void 0!==o&&null!=T&&e7(o,["parameters","mode"],T)),o);return l=e8("{model}:predict",v._url),r=v._query,delete v._url,delete v._query,this.apiClient.request({path:l,queryParams:r,body:JSON.stringify(v),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=function(e){let t={},n=te(e,["sdkHttpResponse"]);null!=n&&e7(t,["sdkHttpResponse"],n);let i=te(e,["predictions"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>nE(e))),e7(t,["generatedImages"],e)}return t}(e),n=new ts;return Object.assign(n,t),n})}throw Error("This method is only supported by the Vertex AI.")}async recontextImage(e){var t,n,i;let l="",r={};if(this.apiClient.isVertexAI()){let o,a,s,u,p,d,c,h,m,f,g,y,E,_,I,T=(i=this.apiClient,o={},null!=(a=te(e,["model"]))&&e7(o,["_url","model"],tP(i,a)),null!=(s=te(e,["source"]))&&function(e,t){let n=te(e,["prompt"]);void 0!==t&&null!=n&&e7(t,["instances[0]","prompt"],n);let i=te(e,["personImage"]);void 0!==t&&null!=i&&e7(t,["instances[0]","personImage","image"],nT(i));let l=te(e,["productImages"]);if(void 0!==t&&null!=l){let e=l;Array.isArray(e)&&(e=e.map(e=>{let t,n;return t={},null!=(n=te(e,["productImage"]))&&e7(t,["image"],nT(n)),t})),e7(t,["instances[0]","productImages"],e)}}(s,o),null!=(u=te(e,["config"]))&&(p=te(u,["numberOfImages"]),void 0!==o&&null!=p&&e7(o,["parameters","sampleCount"],p),d=te(u,["baseSteps"]),void 0!==o&&null!=d&&e7(o,["parameters","baseSteps"],d),c=te(u,["outputGcsUri"]),void 0!==o&&null!=c&&e7(o,["parameters","storageUri"],c),h=te(u,["seed"]),void 0!==o&&null!=h&&e7(o,["parameters","seed"],h),m=te(u,["safetyFilterLevel"]),void 0!==o&&null!=m&&e7(o,["parameters","safetySetting"],m),f=te(u,["personGeneration"]),void 0!==o&&null!=f&&e7(o,["parameters","personGeneration"],f),g=te(u,["addWatermark"]),void 0!==o&&null!=g&&e7(o,["parameters","addWatermark"],g),y=te(u,["outputMimeType"]),void 0!==o&&null!=y&&e7(o,["parameters","outputOptions","mimeType"],y),E=te(u,["outputCompressionQuality"]),void 0!==o&&null!=E&&e7(o,["parameters","outputOptions","compressionQuality"],E),_=te(u,["enhancePrompt"]),void 0!==o&&null!=_&&e7(o,["parameters","enhancePrompt"],_),I=te(u,["labels"]),void 0!==o&&null!=I&&e7(o,["labels"],I)),o);return l=e8("{model}:predict",T._url),r=T._query,delete T._url,delete T._query,this.apiClient.request({path:l,queryParams:r,body:JSON.stringify(T),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>{let t=function(e){let t={},n=te(e,["predictions"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>nE(e))),e7(t,["generatedImages"],e)}return t}(e),n=new tu;return Object.assign(n,t),n})}throw Error("This method is only supported by the Vertex AI.")}async segmentImage(e){var t,n,i,l,r;let o="",a={};if(this.apiClient.isVertexAI()){let s,u,p,d,c,h,m,f,g,y,E,_,I,T,v,A=(i=this.apiClient,h={},null!=(m=te(e,["model"]))&&e7(h,["_url","model"],tP(i,m)),null!=(f=te(e,["source"]))&&(l=f,r=h,p=te(l,["prompt"]),void 0!==r&&null!=p&&e7(r,["instances[0]","prompt"],p),d=te(l,["image"]),void 0!==r&&null!=d&&e7(r,["instances[0]","image"],nT(d)),c=te(l,["scribbleImage"]),void 0!==r&&null!=c&&e7(r,["instances[0]","scribble"],(s={},null!=(u=te(c,["image"]))&&e7(s,["image"],nT(u)),s))),null!=(g=te(e,["config"]))&&(y=te(g,["mode"]),void 0!==h&&null!=y&&e7(h,["parameters","mode"],y),E=te(g,["maxPredictions"]),void 0!==h&&null!=E&&e7(h,["parameters","maxPredictions"],E),_=te(g,["confidenceThreshold"]),void 0!==h&&null!=_&&e7(h,["parameters","confidenceThreshold"],_),I=te(g,["maskDilation"]),void 0!==h&&null!=I&&e7(h,["parameters","maskDilation"],I),T=te(g,["binaryColorThreshold"]),void 0!==h&&null!=T&&e7(h,["parameters","binaryColorThreshold"],T),v=te(g,["labels"]),void 0!==h&&null!=v&&e7(h,["labels"],v)),h);return o=e8("{model}:predict",A._url),a=A._query,delete A._url,delete A._query,this.apiClient.request({path:o,queryParams:a,body:JSON.stringify(A),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>{let t=function(e){let t={},n=te(e,["predictions"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>(function(e){let t={},n=te(e,["_self"]);null!=n&&e7(t,["mask"],n_(n));let i=te(e,["labels"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),e7(t,["labels"],e)}return t})(e))),e7(t,["generatedMasks"],e)}return t}(e),n=new tp;return Object.assign(n,t),n})}throw Error("This method is only supported by the Vertex AI.")}async get(e){var t,n,i,l,r,o;let a="",s={};if(this.apiClient.isVertexAI()){let i,l,o=(r=this.apiClient,i={},null!=(l=te(e,["model"]))&&e7(i,["_url","name"],tP(r,l)),i);return a=e8("{name}",o._url),s=o._query,delete o._url,delete o._query,this.apiClient.request({path:a,queryParams:s,body:JSON.stringify(o),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>nA(e))}{let t,n,r=(o=this.apiClient,t={},null!=(n=te(e,["model"]))&&e7(t,["_url","name"],tP(o,n)),t);return a=e8("{name}",r._url),s=r._query,delete r._url,delete r._query,this.apiClient.request({path:a,queryParams:s,body:JSON.stringify(r),httpMethod:"GET",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(l=e.config)?void 0:l.abortSignal}).then(e=>e.json()).then(e=>nv(e))}}async listInternal(e){var t,n,i,l,r,o;let a="",s={};if(this.apiClient.isVertexAI()){let i,l,o,u,p,d,c=(r=this.apiClient,i={},null!=(l=te(e,["config"]))&&(o=te(l,["pageSize"]),void 0!==i&&null!=o&&e7(i,["_query","pageSize"],o),u=te(l,["pageToken"]),void 0!==i&&null!=u&&e7(i,["_query","pageToken"],u),p=te(l,["filter"]),void 0!==i&&null!=p&&e7(i,["_query","filter"],p),d=te(l,["queryBase"]),void 0!==i&&null!=d&&e7(i,["_url","models_url"],tZ(r,d))),i);return a=e8("{models_url}",c._url),s=c._query,delete c._url,delete c._query,this.apiClient.request({path:a,queryParams:s,body:JSON.stringify(c),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=function(e){let t={},n=te(e,["sdkHttpResponse"]);null!=n&&e7(t,["sdkHttpResponse"],n);let i=te(e,["nextPageToken"]);null!=i&&e7(t,["nextPageToken"],i);let l=te(e,["_self"]);if(null!=l){let e=tQ(l);Array.isArray(e)&&(e=e.map(e=>nA(e))),e7(t,["models"],e)}return t}(e),n=new td;return Object.assign(n,t),n})}{let t,n,r,u,p,d,c=(o=this.apiClient,t={},null!=(n=te(e,["config"]))&&(r=te(n,["pageSize"]),void 0!==t&&null!=r&&e7(t,["_query","pageSize"],r),u=te(n,["pageToken"]),void 0!==t&&null!=u&&e7(t,["_query","pageToken"],u),p=te(n,["filter"]),void 0!==t&&null!=p&&e7(t,["_query","filter"],p),d=te(n,["queryBase"]),void 0!==t&&null!=d&&e7(t,["_url","models_url"],tZ(o,d))),t);return a=e8("{models_url}",c._url),s=c._query,delete c._url,delete c._query,this.apiClient.request({path:a,queryParams:s,body:JSON.stringify(c),httpMethod:"GET",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(l=e.config)?void 0:l.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=function(e){let t={},n=te(e,["sdkHttpResponse"]);null!=n&&e7(t,["sdkHttpResponse"],n);let i=te(e,["nextPageToken"]);null!=i&&e7(t,["nextPageToken"],i);let l=te(e,["_self"]);if(null!=l){let e=tQ(l);Array.isArray(e)&&(e=e.map(e=>nv(e))),e7(t,["models"],e)}return t}(e),n=new td;return Object.assign(n,t),n})}}async update(e){var t,n,i,l,r,o;let a="",s={};if(this.apiClient.isVertexAI()){let i,l,o,u,p,d,c=(r=this.apiClient,i={},null!=(l=te(e,["model"]))&&e7(i,["_url","model"],tP(r,l)),null!=(o=te(e,["config"]))&&(u=te(o,["displayName"]),void 0!==i&&null!=u&&e7(i,["displayName"],u),p=te(o,["description"]),void 0!==i&&null!=p&&e7(i,["description"],p),d=te(o,["defaultCheckpointId"]),void 0!==i&&null!=d&&e7(i,["defaultCheckpointId"],d)),i);return a=e8("{model}",c._url),s=c._query,delete c._url,delete c._query,this.apiClient.request({path:a,queryParams:s,body:JSON.stringify(c),httpMethod:"PATCH",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>nA(e))}{let t,n,r,u,p,d,c=(o=this.apiClient,t={},null!=(n=te(e,["model"]))&&e7(t,["_url","name"],tP(o,n)),null!=(r=te(e,["config"]))&&(u=te(r,["displayName"]),void 0!==t&&null!=u&&e7(t,["displayName"],u),p=te(r,["description"]),void 0!==t&&null!=p&&e7(t,["description"],p),d=te(r,["defaultCheckpointId"]),void 0!==t&&null!=d&&e7(t,["defaultCheckpointId"],d)),t);return a=e8("{name}",c._url),s=c._query,delete c._url,delete c._query,this.apiClient.request({path:a,queryParams:s,body:JSON.stringify(c),httpMethod:"PATCH",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(l=e.config)?void 0:l.abortSignal}).then(e=>e.json()).then(e=>nv(e))}}async delete(e){var t,n,i,l,r,o;let a="",s={};if(this.apiClient.isVertexAI()){let i,l,o=(r=this.apiClient,i={},null!=(l=te(e,["model"]))&&e7(i,["_url","name"],tP(r,l)),i);return a=e8("{name}",o._url),s=o._query,delete o._url,delete o._query,this.apiClient.request({path:a,queryParams:s,body:JSON.stringify(o),httpMethod:"DELETE",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t,n,i=(t={},null!=(n=te(e,["sdkHttpResponse"]))&&e7(t,["sdkHttpResponse"],n),t),l=new tc;return Object.assign(l,i),l})}{let t,n,r=(o=this.apiClient,t={},null!=(n=te(e,["model"]))&&e7(t,["_url","name"],tP(o,n)),t);return a=e8("{name}",r._url),s=r._query,delete r._url,delete r._query,this.apiClient.request({path:a,queryParams:s,body:JSON.stringify(r),httpMethod:"DELETE",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(l=e.config)?void 0:l.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t,n,i=(t={},null!=(n=te(e,["sdkHttpResponse"]))&&e7(t,["sdkHttpResponse"],n),t),l=new tc;return Object.assign(l,i),l})}}async countTokens(e){var t,n,i,l;let r="",o={};if(this.apiClient.isVertexAI()){let i=function(e,t){let n={},i=te(t,["model"]);null!=i&&e7(n,["_url","model"],tP(e,i));let l=te(t,["contents"]);if(null!=l){let e=tj(l);Array.isArray(e)&&(e=e.map(e=>e)),e7(n,["contents"],e)}let r=te(t,["config"]);return null!=r&&function(e,t){let n=te(e,["systemInstruction"]);void 0!==t&&null!=n&&e7(t,["systemInstruction"],tF(n));let i=te(e,["tools"]);if(void 0!==t&&null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>nb(e))),e7(t,["tools"],e)}let l=te(e,["generationConfig"]);void 0!==t&&null!=l&&e7(t,["generationConfig"],function(e){let t={},n=te(e,["modelSelectionConfig"]);null!=n&&e7(t,["modelConfig"],n);let i=te(e,["responseJsonSchema"]);null!=i&&e7(t,["responseJsonSchema"],i);let l=te(e,["audioTimestamp"]);null!=l&&e7(t,["audioTimestamp"],l);let r=te(e,["candidateCount"]);null!=r&&e7(t,["candidateCount"],r);let o=te(e,["enableAffectiveDialog"]);null!=o&&e7(t,["enableAffectiveDialog"],o);let a=te(e,["frequencyPenalty"]);null!=a&&e7(t,["frequencyPenalty"],a);let s=te(e,["logprobs"]);null!=s&&e7(t,["logprobs"],s);let u=te(e,["maxOutputTokens"]);null!=u&&e7(t,["maxOutputTokens"],u);let p=te(e,["mediaResolution"]);null!=p&&e7(t,["mediaResolution"],p);let d=te(e,["presencePenalty"]);null!=d&&e7(t,["presencePenalty"],d);let c=te(e,["responseLogprobs"]);null!=c&&e7(t,["responseLogprobs"],c);let h=te(e,["responseMimeType"]);null!=h&&e7(t,["responseMimeType"],h);let m=te(e,["responseModalities"]);null!=m&&e7(t,["responseModalities"],m);let f=te(e,["responseSchema"]);null!=f&&e7(t,["responseSchema"],f);let g=te(e,["routingConfig"]);null!=g&&e7(t,["routingConfig"],g);let y=te(e,["seed"]);null!=y&&e7(t,["seed"],y);let E=te(e,["speechConfig"]);null!=E&&e7(t,["speechConfig"],nO(E));let _=te(e,["stopSequences"]);null!=_&&e7(t,["stopSequences"],_);let I=te(e,["temperature"]);null!=I&&e7(t,["temperature"],I);let T=te(e,["thinkingConfig"]);null!=T&&e7(t,["thinkingConfig"],T);let v=te(e,["topK"]);null!=v&&e7(t,["topK"],v);let A=te(e,["topP"]);if(null!=A&&e7(t,["topP"],A),void 0!==te(e,["enableEnhancedCivicAnswers"]))throw Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");return t}(l))}(r,n),n}(this.apiClient,e);return r=e8("{model}:countTokens",i._url),o=i._query,delete i._url,delete i._query,this.apiClient.request({path:r,queryParams:o,body:JSON.stringify(i),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t,n,i,l=(t={},null!=(n=te(e,["sdkHttpResponse"]))&&e7(t,["sdkHttpResponse"],n),null!=(i=te(e,["totalTokens"]))&&e7(t,["totalTokens"],i),t),r=new th;return Object.assign(r,l),r})}{let t=function(e,t){let n={},i=te(t,["model"]);null!=i&&e7(n,["_url","model"],tP(e,i));let l=te(t,["contents"]);if(null!=l){let e=tj(l);Array.isArray(e)&&(e=e.map(e=>nh(e))),e7(n,["contents"],e)}let r=te(t,["config"]);return null!=r&&function(e){if(void 0!==te(e,["systemInstruction"]))throw Error("systemInstruction parameter is not supported in Gemini API.");if(void 0!==te(e,["tools"]))throw Error("tools parameter is not supported in Gemini API.");if(void 0!==te(e,["generationConfig"]))throw Error("generationConfig parameter is not supported in Gemini API.")}(r),n}(this.apiClient,e);return r=e8("{model}:countTokens",t._url),o=t._query,delete t._url,delete t._query,this.apiClient.request({path:r,queryParams:o,body:JSON.stringify(t),httpMethod:"POST",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(l=e.config)?void 0:l.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t,n,i,l,r=(t={},null!=(n=te(e,["sdkHttpResponse"]))&&e7(t,["sdkHttpResponse"],n),null!=(i=te(e,["totalTokens"]))&&e7(t,["totalTokens"],i),null!=(l=te(e,["cachedContentTokenCount"]))&&e7(t,["cachedContentTokenCount"],l),t),o=new th;return Object.assign(o,r),o})}}async computeTokens(e){var t,n;let i="",l={};if(this.apiClient.isVertexAI()){let r=function(e,t){let n={},i=te(t,["model"]);null!=i&&e7(n,["_url","model"],tP(e,i));let l=te(t,["contents"]);if(null!=l){let e=tj(l);Array.isArray(e)&&(e=e.map(e=>e)),e7(n,["contents"],e)}return n}(this.apiClient,e);return i=e8("{model}:computeTokens",r._url),l=r._query,delete r._url,delete r._query,this.apiClient.request({path:i,queryParams:l,body:JSON.stringify(r),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=function(e){let t={},n=te(e,["sdkHttpResponse"]);null!=n&&e7(t,["sdkHttpResponse"],n);let i=te(e,["tokensInfo"]);if(null!=i){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),e7(t,["tokensInfo"],e)}return t}(e),n=new tm;return Object.assign(n,t),n})}throw Error("This method is only supported by the Vertex AI.")}async generateVideosInternal(e){var t,n,i,l,r,o,a,s,u,p;let d="",c={};if(this.apiClient.isVertexAI()){let i,l,o,u,p,h,m,f,g,y,E=(r=this.apiClient,u={},null!=(p=te(e,["model"]))&&e7(u,["_url","model"],tP(r,p)),null!=(h=te(e,["prompt"]))&&e7(u,["instances[0]","prompt"],h),null!=(m=te(e,["image"]))&&e7(u,["instances[0]","image"],nT(m)),null!=(f=te(e,["video"]))&&e7(u,["instances[0]","video"],nR(f)),null!=(g=te(e,["source"]))&&(a=g,s=u,i=te(a,["prompt"]),void 0!==s&&null!=i&&e7(s,["instances[0]","prompt"],i),l=te(a,["image"]),void 0!==s&&null!=l&&e7(s,["instances[0]","image"],nT(l)),o=te(a,["video"]),void 0!==s&&null!=o&&e7(s,["instances[0]","video"],nR(o))),null!=(y=te(e,["config"]))&&function(e,t){var n;let i,l,r,o=te(e,["numberOfVideos"]);void 0!==t&&null!=o&&e7(t,["parameters","sampleCount"],o);let a=te(e,["outputGcsUri"]);void 0!==t&&null!=a&&e7(t,["parameters","storageUri"],a);let s=te(e,["fps"]);void 0!==t&&null!=s&&e7(t,["parameters","fps"],s);let u=te(e,["durationSeconds"]);void 0!==t&&null!=u&&e7(t,["parameters","durationSeconds"],u);let p=te(e,["seed"]);void 0!==t&&null!=p&&e7(t,["parameters","seed"],p);let d=te(e,["aspectRatio"]);void 0!==t&&null!=d&&e7(t,["parameters","aspectRatio"],d);let c=te(e,["resolution"]);void 0!==t&&null!=c&&e7(t,["parameters","resolution"],c);let h=te(e,["personGeneration"]);void 0!==t&&null!=h&&e7(t,["parameters","personGeneration"],h);let m=te(e,["pubsubTopic"]);void 0!==t&&null!=m&&e7(t,["parameters","pubsubTopic"],m);let f=te(e,["negativePrompt"]);void 0!==t&&null!=f&&e7(t,["parameters","negativePrompt"],f);let g=te(e,["enhancePrompt"]);void 0!==t&&null!=g&&e7(t,["parameters","enhancePrompt"],g);let y=te(e,["generateAudio"]);void 0!==t&&null!=y&&e7(t,["parameters","generateAudio"],y);let E=te(e,["lastFrame"]);void 0!==t&&null!=E&&e7(t,["instances[0]","lastFrame"],nT(E));let _=te(e,["referenceImages"]);if(void 0!==t&&null!=_){let e=_;Array.isArray(e)&&(e=e.map(e=>{var t;let n,i,l;return n={},null!=(i=te(t=e,["image"]))&&e7(n,["image"],nT(i)),null!=(l=te(t,["referenceType"]))&&e7(n,["referenceType"],l),n})),e7(t,["instances[0]","referenceImages"],e)}let I=te(e,["mask"]);void 0!==t&&null!=I&&e7(t,["instances[0]","mask"],(i={},null!=(l=te(n=I,["image"]))&&e7(i,["_self"],nT(l)),null!=(r=te(n,["maskMode"]))&&e7(i,["maskMode"],r),i));let T=te(e,["compressionQuality"]);void 0!==t&&null!=T&&e7(t,["parameters","compressionQuality"],T)}(y,u),u);return d=e8("{model}:predictLongRunning",E._url),c=E._query,delete E._url,delete E._query,this.apiClient.request({path:d,queryParams:c,body:JSON.stringify(E),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>{let t,n,i,l,r,o,a=(t={},null!=(n=te(e,["name"]))&&e7(t,["name"],n),null!=(i=te(e,["metadata"]))&&e7(t,["metadata"],i),null!=(l=te(e,["done"]))&&e7(t,["done"],l),null!=(r=te(e,["error"]))&&e7(t,["error"],r),null!=(o=te(e,["response"]))&&e7(t,["response"],function(e){let t={},n=te(e,["videos"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>{var t;let n,i,l,r,o,a;return n={},null!=(i=te(e,["_self"]))&&e7(n,["video"],(l={},null!=(r=te(t=i,["gcsUri"]))&&e7(l,["uri"],r),null!=(o=te(t,["bytesBase64Encoded"]))&&e7(l,["videoBytes"],tt(o)),null!=(a=te(t,["mimeType"]))&&e7(l,["mimeType"],a),l)),n})),e7(t,["generatedVideos"],e)}let i=te(e,["raiMediaFilteredCount"]);null!=i&&e7(t,["raiMediaFilteredCount"],i);let l=te(e,["raiMediaFilteredReasons"]);return null!=l&&e7(t,["raiMediaFilteredReasons"],l),t}(o)),t),s=new tf;return Object.assign(s,a),s})}{let t,n,r,a,s,h,m,f,g,y,E=(o=this.apiClient,a={},null!=(s=te(e,["model"]))&&e7(a,["_url","model"],tP(o,s)),null!=(h=te(e,["prompt"]))&&e7(a,["instances[0]","prompt"],h),null!=(m=te(e,["image"]))&&e7(a,["instances[0]","image"],nI(m)),null!=(f=te(e,["video"]))&&e7(a,["instances[0]","video"],nN(f)),null!=(g=te(e,["source"]))&&(u=g,p=a,t=te(u,["prompt"]),void 0!==p&&null!=t&&e7(p,["instances[0]","prompt"],t),n=te(u,["image"]),void 0!==p&&null!=n&&e7(p,["instances[0]","image"],nI(n)),r=te(u,["video"]),void 0!==p&&null!=r&&e7(p,["instances[0]","video"],nN(r))),null!=(y=te(e,["config"]))&&function(e,t){let n=te(e,["numberOfVideos"]);if(void 0!==t&&null!=n&&e7(t,["parameters","sampleCount"],n),void 0!==te(e,["outputGcsUri"]))throw Error("outputGcsUri parameter is not supported in Gemini API.");if(void 0!==te(e,["fps"]))throw Error("fps parameter is not supported in Gemini API.");let i=te(e,["durationSeconds"]);if(void 0!==t&&null!=i&&e7(t,["parameters","durationSeconds"],i),void 0!==te(e,["seed"]))throw Error("seed parameter is not supported in Gemini API.");let l=te(e,["aspectRatio"]);void 0!==t&&null!=l&&e7(t,["parameters","aspectRatio"],l);let r=te(e,["resolution"]);void 0!==t&&null!=r&&e7(t,["parameters","resolution"],r);let o=te(e,["personGeneration"]);if(void 0!==t&&null!=o&&e7(t,["parameters","personGeneration"],o),void 0!==te(e,["pubsubTopic"]))throw Error("pubsubTopic parameter is not supported in Gemini API.");let a=te(e,["negativePrompt"]);void 0!==t&&null!=a&&e7(t,["parameters","negativePrompt"],a);let s=te(e,["enhancePrompt"]);if(void 0!==t&&null!=s&&e7(t,["parameters","enhancePrompt"],s),void 0!==te(e,["generateAudio"]))throw Error("generateAudio parameter is not supported in Gemini API.");let u=te(e,["lastFrame"]);void 0!==t&&null!=u&&e7(t,["instances[0]","lastFrame"],nI(u));let p=te(e,["referenceImages"]);if(void 0!==t&&null!=p){let e=p;Array.isArray(e)&&(e=e.map(e=>{var t;let n,i,l;return n={},null!=(i=te(t=e,["image"]))&&e7(n,["image"],nI(i)),null!=(l=te(t,["referenceType"]))&&e7(n,["referenceType"],l),n})),e7(t,["instances[0]","referenceImages"],e)}if(void 0!==te(e,["mask"]))throw Error("mask parameter is not supported in Gemini API.");if(void 0!==te(e,["compressionQuality"]))throw Error("compressionQuality parameter is not supported in Gemini API.")}(y,a),a);return d=e8("{model}:predictLongRunning",E._url),c=E._query,delete E._url,delete E._query,this.apiClient.request({path:d,queryParams:c,body:JSON.stringify(E),httpMethod:"POST",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(l=e.config)?void 0:l.abortSignal}).then(e=>e.json()).then(e=>{let t,n,i,l,r,o,a=(t={},null!=(n=te(e,["name"]))&&e7(t,["name"],n),null!=(i=te(e,["metadata"]))&&e7(t,["metadata"],i),null!=(l=te(e,["done"]))&&e7(t,["done"],l),null!=(r=te(e,["error"]))&&e7(t,["error"],r),null!=(o=te(e,["response","generateVideoResponse"]))&&e7(t,["response"],function(e){let t={},n=te(e,["generatedSamples"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>{var t;let n,i,l,r,o,a;return n={},null!=(i=te(e,["video"]))&&e7(n,["video"],(l={},null!=(r=te(t=i,["uri"]))&&e7(l,["uri"],r),null!=(o=te(t,["encodedVideo"]))&&e7(l,["videoBytes"],tt(o)),null!=(a=te(t,["encoding"]))&&e7(l,["mimeType"],a),l)),n})),e7(t,["generatedVideos"],e)}let i=te(e,["raiMediaFilteredCount"]);null!=i&&e7(t,["raiMediaFilteredCount"],i);let l=te(e,["raiMediaFilteredReasons"]);return null!=l&&e7(t,["raiMediaFilteredReasons"],l),t}(o)),t),s=new tf;return Object.assign(s,a),s})}}}class nW extends e5{constructor(e){super(),this.apiClient=e}async getVideosOperation(e){let t=e.operation,n=e.config;if(void 0===t.name||""===t.name)throw Error("Operation name is required.");if(this.apiClient.isVertexAI()){let e,i=t.name.split("/operations/")[0];n&&"httpOptions"in n&&(e=n.httpOptions);let l=await this.fetchPredictVideosOperationInternal({operationName:t.name,resourceName:i,config:{httpOptions:e}});return t._fromAPIResponse({apiResponse:l,_isVertexAI:!0})}{let e=await this.getVideosOperationInternal({operationName:t.name,config:n});return t._fromAPIResponse({apiResponse:e,_isVertexAI:!1})}}async get(e){let t=e.operation,n=e.config;if(void 0===t.name||""===t.name)throw Error("Operation name is required.");if(this.apiClient.isVertexAI()){let e,i=t.name.split("/operations/")[0];n&&"httpOptions"in n&&(e=n.httpOptions);let l=await this.fetchPredictVideosOperationInternal({operationName:t.name,resourceName:i,config:{httpOptions:e}});return t._fromAPIResponse({apiResponse:l,_isVertexAI:!0})}{let e=await this.getVideosOperationInternal({operationName:t.name,config:n});return t._fromAPIResponse({apiResponse:e,_isVertexAI:!1})}}async getVideosOperationInternal(e){var t,n,i,l;let r="",o={};if(this.apiClient.isVertexAI()){let i,l,a=(i={},null!=(l=te(e,["operationName"]))&&e7(i,["_url","operationName"],l),i);return r=e8("{operationName}",a._url),o=a._query,delete a._url,delete a._query,this.apiClient.request({path:r,queryParams:o,body:JSON.stringify(a),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json())}{let t,n,a=(t={},null!=(n=te(e,["operationName"]))&&e7(t,["_url","operationName"],n),t);return r=e8("{operationName}",a._url),o=a._query,delete a._url,delete a._query,this.apiClient.request({path:r,queryParams:o,body:JSON.stringify(a),httpMethod:"GET",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(l=e.config)?void 0:l.abortSignal}).then(e=>e.json())}}async fetchPredictVideosOperationInternal(e){var t,n;let i="",l={};if(this.apiClient.isVertexAI()){let r,o,a,s=(r={},null!=(o=te(e,["operationName"]))&&e7(r,["operationName"],o),null!=(a=te(e,["resourceName"]))&&e7(r,["_url","resourceName"],a),r);return i=e8("{resourceName}:fetchPredictOperation",s._url),l=s._query,delete s._url,delete s._query,this.apiClient.request({path:i,queryParams:l,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json())}throw Error("This method is only supported by the Vertex AI.")}}class nz extends e5{constructor(e){super(),this.apiClient=e}async create(e){var t,n,i,l,r;let o="",a={};if(this.apiClient.isVertexAI())throw Error("The client.tokens.create method is only supported by the Gemini Developer API.");{let s,u,p,d,c,h,m,f,g,y,E=(i=this.apiClient,d={},null!=(c=te(e,["config"]))&&e7(d,["config"],(h=te(c,["expireTime"]),void 0!==d&&null!=h&&e7(d,["expireTime"],h),m=te(c,["newSessionExpireTime"]),void 0!==d&&null!=m&&e7(d,["newSessionExpireTime"],m),f=te(c,["uses"]),void 0!==d&&null!=f&&e7(d,["uses"],f),g=te(c,["liveConnectConstraints"]),void 0!==d&&null!=g&&e7(d,["bidiGenerateContentSetup"],(l=i,s={},null!=(u=te(r=g,["model"]))&&e7(s,["setup","model"],tP(l,u)),null!=(p=te(r,["config"]))&&e7(s,["config"],function(e,t){let n=te(e,["generationConfig"]);void 0!==t&&null!=n&&e7(t,["setup","generationConfig"],n);let i=te(e,["responseModalities"]);void 0!==t&&null!=i&&e7(t,["setup","generationConfig","responseModalities"],i);let l=te(e,["temperature"]);void 0!==t&&null!=l&&e7(t,["setup","generationConfig","temperature"],l);let r=te(e,["topP"]);void 0!==t&&null!=r&&e7(t,["setup","generationConfig","topP"],r);let o=te(e,["topK"]);void 0!==t&&null!=o&&e7(t,["setup","generationConfig","topK"],o);let a=te(e,["maxOutputTokens"]);void 0!==t&&null!=a&&e7(t,["setup","generationConfig","maxOutputTokens"],a);let s=te(e,["mediaResolution"]);void 0!==t&&null!=s&&e7(t,["setup","generationConfig","mediaResolution"],s);let u=te(e,["seed"]);void 0!==t&&null!=u&&e7(t,["setup","generationConfig","seed"],u);let p=te(e,["speechConfig"]);void 0!==t&&null!=p&&e7(t,["setup","generationConfig","speechConfig"],tY(p));let d=te(e,["thinkingConfig"]);void 0!==t&&null!=d&&e7(t,["setup","generationConfig","thinkingConfig"],d);let c=te(e,["enableAffectiveDialog"]);void 0!==t&&null!=c&&e7(t,["setup","generationConfig","enableAffectiveDialog"],c);let h=te(e,["systemInstruction"]);void 0!==t&&null!=h&&e7(t,["setup","systemInstruction"],function(e){let t={},n=te(e,["parts"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>{var t;let n,i,l,r,o,a,s,u,p,d,c,h;return n={},null!=(i=te(t=e,["mediaResolution"]))&&e7(n,["mediaResolution"],i),null!=(l=te(t,["codeExecutionResult"]))&&e7(n,["codeExecutionResult"],l),null!=(r=te(t,["executableCode"]))&&e7(n,["executableCode"],r),null!=(o=te(t,["fileData"]))&&e7(n,["fileData"],function(e){let t={};if(void 0!==te(e,["displayName"]))throw Error("displayName parameter is not supported in Gemini API.");let n=te(e,["fileUri"]);null!=n&&e7(t,["fileUri"],n);let i=te(e,["mimeType"]);return null!=i&&e7(t,["mimeType"],i),t}(o)),null!=(a=te(t,["functionCall"]))&&e7(n,["functionCall"],function(e){let t={},n=te(e,["id"]);null!=n&&e7(t,["id"],n);let i=te(e,["args"]);null!=i&&e7(t,["args"],i);let l=te(e,["name"]);if(null!=l&&e7(t,["name"],l),void 0!==te(e,["partialArgs"]))throw Error("partialArgs parameter is not supported in Gemini API.");if(void 0!==te(e,["willContinue"]))throw Error("willContinue parameter is not supported in Gemini API.");return t}(a)),null!=(s=te(t,["functionResponse"]))&&e7(n,["functionResponse"],s),null!=(u=te(t,["inlineData"]))&&e7(n,["inlineData"],function(e){let t={},n=te(e,["data"]);if(null!=n&&e7(t,["data"],n),void 0!==te(e,["displayName"]))throw Error("displayName parameter is not supported in Gemini API.");let i=te(e,["mimeType"]);return null!=i&&e7(t,["mimeType"],i),t}(u)),null!=(p=te(t,["text"]))&&e7(n,["text"],p),null!=(d=te(t,["thought"]))&&e7(n,["thought"],d),null!=(c=te(t,["thoughtSignature"]))&&e7(n,["thoughtSignature"],c),null!=(h=te(t,["videoMetadata"]))&&e7(n,["videoMetadata"],h),n})),e7(t,["parts"],e)}let i=te(e,["role"]);return null!=i&&e7(t,["role"],i),t}(tF(h)));let m=te(e,["tools"]);if(void 0!==t&&null!=m){let e=t$(m);Array.isArray(e)&&(e=e.map(e=>(function(e){let t={},n=te(e,["functionDeclarations"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>e)),e7(t,["functionDeclarations"],e)}if(void 0!==te(e,["retrieval"]))throw Error("retrieval parameter is not supported in Gemini API.");let i=te(e,["googleSearchRetrieval"]);null!=i&&e7(t,["googleSearchRetrieval"],i);let l=te(e,["computerUse"]);null!=l&&e7(t,["computerUse"],l);let r=te(e,["fileSearch"]);null!=r&&e7(t,["fileSearch"],r);let o=te(e,["codeExecution"]);if(null!=o&&e7(t,["codeExecution"],o),void 0!==te(e,["enterpriseWebSearch"]))throw Error("enterpriseWebSearch parameter is not supported in Gemini API.");let a=te(e,["googleMaps"]);null!=a&&e7(t,["googleMaps"],function(e){let t={};if(void 0!==te(e,["authConfig"]))throw Error("authConfig parameter is not supported in Gemini API.");let n=te(e,["enableWidget"]);return null!=n&&e7(t,["enableWidget"],n),t}(a));let s=te(e,["googleSearch"]);null!=s&&e7(t,["googleSearch"],function(e){let t={};if(void 0!==te(e,["excludeDomains"]))throw Error("excludeDomains parameter is not supported in Gemini API.");if(void 0!==te(e,["blockingConfidence"]))throw Error("blockingConfidence parameter is not supported in Gemini API.");let n=te(e,["timeRangeFilter"]);return null!=n&&e7(t,["timeRangeFilter"],n),t}(s));let u=te(e,["urlContext"]);return null!=u&&e7(t,["urlContext"],u),t})(tK(e)))),e7(t,["setup","tools"],e)}let f=te(e,["sessionResumption"]);void 0!==t&&null!=f&&e7(t,["setup","sessionResumption"],function(e){let t={},n=te(e,["handle"]);if(null!=n&&e7(t,["handle"],n),void 0!==te(e,["transparent"]))throw Error("transparent parameter is not supported in Gemini API.");return t}(f));let g=te(e,["inputAudioTranscription"]);void 0!==t&&null!=g&&e7(t,["setup","inputAudioTranscription"],g);let y=te(e,["outputAudioTranscription"]);void 0!==t&&null!=y&&e7(t,["setup","outputAudioTranscription"],y);let E=te(e,["realtimeInputConfig"]);void 0!==t&&null!=E&&e7(t,["setup","realtimeInputConfig"],E);let _=te(e,["contextWindowCompression"]);void 0!==t&&null!=_&&e7(t,["setup","contextWindowCompression"],_);let I=te(e,["proactivity"]);return void 0!==t&&null!=I&&e7(t,["setup","proactivity"],I),{}}(p,s)),s)),y=te(c,["lockAdditionalFields"]),void 0!==d&&null!=y&&e7(d,["fieldMask"],y),{})),d);o=e8("auth_tokens",E._url),a=E._query,delete E.config,delete E._url,delete E._query;let _=function(e,t){let n=null,i=e.bidiGenerateContentSetup;if("object"==typeof i&&null!==i&&"setup"in i){let t=i.setup;"object"==typeof t&&null!==t?(e.bidiGenerateContentSetup=t,n=t):delete e.bidiGenerateContentSetup}else void 0!==i&&delete e.bidiGenerateContentSetup;let l=e.fieldMask;if(n){let i=function(e){let t=[];for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)){let i=e[n];if("object"==typeof i&&null!=i&&Object.keys(i).length>0){let e=Object.keys(i).map(e=>`${n}.${e}`);t.push(...e)}else t.push(n)}return t.join(",")}(n);if(Array.isArray(null==t?void 0:t.lockAdditionalFields)&&(null==t?void 0:t.lockAdditionalFields.length)===0)i?e.fieldMask=i:delete e.fieldMask;else if((null==t?void 0:t.lockAdditionalFields)&&t.lockAdditionalFields.length>0&&null!==l&&Array.isArray(l)&&l.length>0){let t=["temperature","topK","topP","maxOutputTokens","responseModalities","seed","speechConfig"],n=[];l.length>0&&(n=l.map(e=>t.includes(e)?`generationConfig.${e}`:e));let r=[];i&&r.push(i),n.length>0&&r.push(...n),r.length>0?e.fieldMask=r.join(","):delete e.fieldMask}else delete e.fieldMask}else null!==l&&Array.isArray(l)&&l.length>0?e.fieldMask=l.join(","):delete e.fieldMask;return e}(E,e.config);return this.apiClient.request({path:o,queryParams:a,body:JSON.stringify(_),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>e)}}}class nX extends e5{constructor(e){super(),this.apiClient=e,this.list=async e=>new t8(en.PAGED_ITEM_DOCUMENTS,t=>this.listInternal({parent:e.parent,config:t.config}),await this.listInternal(e),e)}async get(e){var t,n;let i="",l={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let r,o,a=(r={},null!=(o=te(e,["name"]))&&e7(r,["_url","name"],o),r);return i=e8("{name}",a._url),l=a._query,delete a._url,delete a._query,this.apiClient.request({path:i,queryParams:l,body:JSON.stringify(a),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>e)}}async delete(e){var t,n;let i="",l={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let r,o,a,s,u=(r={},null!=(o=te(e,["name"]))&&e7(r,["_url","name"],o),null!=(a=te(e,["config"]))&&(s=te(a,["force"]),void 0!==r&&null!=s&&e7(r,["_query","force"],s)),r);i=e8("{name}",u._url),l=u._query,delete u._url,delete u._query,await this.apiClient.request({path:i,queryParams:l,body:JSON.stringify(u),httpMethod:"DELETE",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal})}}async listInternal(e){var t,n;let i="",l={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let r,o,a,s,u,p=(r={},null!=(o=te(e,["parent"]))&&e7(r,["_url","parent"],o),null!=(a=te(e,["config"]))&&(s=te(a,["pageSize"]),void 0!==r&&null!=s&&e7(r,["_query","pageSize"],s),u=te(a,["pageToken"]),void 0!==r&&null!=u&&e7(r,["_query","pageToken"],u)),r);return i=e8("{parent}/documents",p._url),l=p._query,delete p._url,delete p._query,this.apiClient.request({path:i,queryParams:l,body:JSON.stringify(p),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>{let t=function(e){let t={},n=te(e,["sdkHttpResponse"]);null!=n&&e7(t,["sdkHttpResponse"],n);let i=te(e,["nextPageToken"]);null!=i&&e7(t,["nextPageToken"],i);let l=te(e,["documents"]);if(null!=l){let e=l;Array.isArray(e)&&(e=e.map(e=>e)),e7(t,["documents"],e)}return t}(e),n=new t_;return Object.assign(n,t),n})}}}class nZ extends e5{constructor(e,t=new nX(e)){super(),this.apiClient=e,this.documents=t,this.list=async(e={})=>new t8(en.PAGED_ITEM_FILE_SEARCH_STORES,e=>this.listInternal(e),await this.listInternal(e),e)}async uploadToFileSearchStore(e){if(this.apiClient.isVertexAI())throw 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 t,n;let i="",l={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let r,o,a,s=(r={},null!=(o=te(e,["config"]))&&(a=te(o,["displayName"]),void 0!==r&&null!=a&&e7(r,["displayName"],a)),r);return i=e8("fileSearchStores",s._url),l=s._query,delete s._url,delete s._query,this.apiClient.request({path:i,queryParams:l,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>e)}}async get(e){var t,n;let i="",l={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let r,o,a=(r={},null!=(o=te(e,["name"]))&&e7(r,["_url","name"],o),r);return i=e8("{name}",a._url),l=a._query,delete a._url,delete a._query,this.apiClient.request({path:i,queryParams:l,body:JSON.stringify(a),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>e)}}async delete(e){var t,n;let i="",l={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let r,o,a,s,u=(r={},null!=(o=te(e,["name"]))&&e7(r,["_url","name"],o),null!=(a=te(e,["config"]))&&(s=te(a,["force"]),void 0!==r&&null!=s&&e7(r,["_query","force"],s)),r);i=e8("{name}",u._url),l=u._query,delete u._url,delete u._query,await this.apiClient.request({path:i,queryParams:l,body:JSON.stringify(u),httpMethod:"DELETE",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal})}}async listInternal(e){var t,n;let i="",l={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let r,o,a,s,u=(r={},null!=(o=te(e,["config"]))&&(a=te(o,["pageSize"]),void 0!==r&&null!=a&&e7(r,["_query","pageSize"],a),s=te(o,["pageToken"]),void 0!==r&&null!=s&&e7(r,["_query","pageToken"],s)),r);return i=e8("fileSearchStores",u._url),l=u._query,delete u._url,delete u._query,this.apiClient.request({path:i,queryParams:l,body:JSON.stringify(u),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>{let t=function(e){let t={},n=te(e,["sdkHttpResponse"]);null!=n&&e7(t,["sdkHttpResponse"],n);let i=te(e,["nextPageToken"]);null!=i&&e7(t,["nextPageToken"],i);let l=te(e,["fileSearchStores"]);if(null!=l){let e=l;Array.isArray(e)&&(e=e.map(e=>e)),e7(t,["fileSearchStores"],e)}return t}(e),n=new tI;return Object.assign(n,t),n})}}async uploadToFileSearchStoreInternal(e){var t,n;let i="",l={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let r,o,a,s=(r={},null!=(o=te(e,["fileSearchStoreName"]))&&e7(r,["_url","file_search_store_name"],o),null!=(a=te(e,["config"]))&&function(e,t){let n=te(e,["mimeType"]);void 0!==t&&null!=n&&e7(t,["mimeType"],n);let i=te(e,["displayName"]);void 0!==t&&null!=i&&e7(t,["displayName"],i);let l=te(e,["customMetadata"]);if(void 0!==t&&null!=l){let e=l;Array.isArray(e)&&(e=e.map(e=>e)),e7(t,["customMetadata"],e)}let r=te(e,["chunkingConfig"]);void 0!==t&&null!=r&&e7(t,["chunkingConfig"],r)}(a,r),r);return i=e8("upload/v1beta/{file_search_store_name}:uploadToFileSearchStore",s._url),l=s._query,delete s._url,delete s._query,this.apiClient.request({path:i,queryParams:l,body:JSON.stringify(s),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>{let t,n,i=(t={},null!=(n=te(e,["sdkHttpResponse"]))&&e7(t,["sdkHttpResponse"],n),t),l=new tT;return Object.assign(l,i),l})}}async importFile(e){var t,n;let i="",l={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let r,o,a,s,u=(r={},null!=(o=te(e,["fileSearchStoreName"]))&&e7(r,["_url","file_search_store_name"],o),null!=(a=te(e,["fileName"]))&&e7(r,["fileName"],a),null!=(s=te(e,["config"]))&&function(e,t){let n=te(e,["customMetadata"]);if(void 0!==t&&null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>e)),e7(t,["customMetadata"],e)}let i=te(e,["chunkingConfig"]);void 0!==t&&null!=i&&e7(t,["chunkingConfig"],i)}(s,r),r);return i=e8("{file_search_store_name}:importFile",u._url),l=u._query,delete u._url,delete u._query,this.apiClient.request({path:i,queryParams:l,body:JSON.stringify(u),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json()).then(e=>{var t;let n,i,l,r,o,a,s,u,p,d,c=(o={},null!=(a=te(e,["name"]))&&e7(o,["name"],a),null!=(s=te(e,["metadata"]))&&e7(o,["metadata"],s),null!=(u=te(e,["done"]))&&e7(o,["done"],u),null!=(p=te(e,["error"]))&&e7(o,["error"],p),null!=(d=te(e,["response"]))&&e7(o,["response"],(n={},null!=(i=te(t=d,["sdkHttpResponse"]))&&e7(n,["sdkHttpResponse"],i),null!=(l=te(t,["parent"]))&&e7(n,["parent"],l),null!=(r=te(t,["documentName"]))&&e7(n,["documentName"],r),n)),o),h=new tv;return Object.assign(h,c),h})}}}function nQ(e,t){let n,i,l,r={},o=te(e,["sdkHttpResponse"]);null!=o&&e7(r,["sdkHttpResponse"],o);let a=te(e,["name"]);null!=a&&e7(r,["name"],a);let s=te(e,["state"]);null!=s&&e7(r,["state"],tz(s));let u=te(e,["createTime"]);null!=u&&e7(r,["createTime"],u);let p=te(e,["tuningTask","startTime"]);null!=p&&e7(r,["startTime"],p);let d=te(e,["tuningTask","completeTime"]);null!=d&&e7(r,["endTime"],d);let c=te(e,["updateTime"]);null!=c&&e7(r,["updateTime"],c);let h=te(e,["description"]);null!=h&&e7(r,["description"],h);let m=te(e,["baseModel"]);null!=m&&e7(r,["baseModel"],m);let f=te(e,["_self"]);return null!=f&&e7(r,["tunedModel"],(n={},null!=(i=te(f,["name"]))&&e7(n,["model"],i),null!=(l=te(f,["name"]))&&e7(n,["endpoint"],l),n)),r}function n0(e,t){let n={},i=te(e,["sdkHttpResponse"]);null!=i&&e7(n,["sdkHttpResponse"],i);let l=te(e,["name"]);null!=l&&e7(n,["name"],l);let r=te(e,["state"]);null!=r&&e7(n,["state"],tz(r));let o=te(e,["createTime"]);null!=o&&e7(n,["createTime"],o);let a=te(e,["startTime"]);null!=a&&e7(n,["startTime"],a);let s=te(e,["endTime"]);null!=s&&e7(n,["endTime"],s);let u=te(e,["updateTime"]);null!=u&&e7(n,["updateTime"],u);let p=te(e,["error"]);null!=p&&e7(n,["error"],p);let d=te(e,["description"]);null!=d&&e7(n,["description"],d);let c=te(e,["baseModel"]);null!=c&&e7(n,["baseModel"],c);let h=te(e,["tunedModel"]);null!=h&&e7(n,["tunedModel"],h);let m=te(e,["preTunedModel"]);null!=m&&e7(n,["preTunedModel"],m);let f=te(e,["supervisedTuningSpec"]);null!=f&&e7(n,["supervisedTuningSpec"],f);let g=te(e,["preferenceOptimizationSpec"]);null!=g&&e7(n,["preferenceOptimizationSpec"],g);let y=te(e,["tuningDataStats"]);null!=y&&e7(n,["tuningDataStats"],y);let E=te(e,["encryptionSpec"]);null!=E&&e7(n,["encryptionSpec"],E);let _=te(e,["partnerModelTuningSpec"]);null!=_&&e7(n,["partnerModelTuningSpec"],_);let I=te(e,["customBaseModel"]);null!=I&&e7(n,["customBaseModel"],I);let T=te(e,["experiment"]);null!=T&&e7(n,["experiment"],T);let v=te(e,["labels"]);null!=v&&e7(n,["labels"],v);let A=te(e,["outputUri"]);null!=A&&e7(n,["outputUri"],A);let C=te(e,["pipelineJob"]);null!=C&&e7(n,["pipelineJob"],C);let S=te(e,["serviceAccount"]);null!=S&&e7(n,["serviceAccount"],S);let O=te(e,["tunedModelDisplayName"]);null!=O&&e7(n,["tunedModelDisplayName"],O);let b=te(e,["veoTuningSpec"]);return null!=b&&e7(n,["veoTuningSpec"],b),n}function n1(e,t){let n={},i=te(e,["gcsUri"]);null!=i&&e7(n,["validationDatasetUri"],i);let l=te(e,["vertexDatasetResource"]);return null!=l&&e7(n,["validationDatasetUri"],l),n}class n6 extends e5{constructor(e){super(),this.apiClient=e,this.get=async e=>await this.getInternal(e),this.list=async(e={})=>new t8(en.PAGED_ITEM_TUNING_JOBS,e=>this.listInternal(e),await this.listInternal(e),e),this.tune=async e=>{var t;if(this.apiClient.isVertexAI())if(e.baseModel.startsWith("projects/")){let n={tunedModelName:e.baseModel};(null==(t=e.config)?void 0:t.preTunedModelCheckpointId)&&(n.checkpointId=e.config.preTunedModelCheckpointId);let i=Object.assign(Object.assign({},e),{preTunedModel:n});return i.baseModel=void 0,await this.tuneInternal(i)}else{let t=Object.assign({},e);return await this.tuneInternal(t)}{let t=Object.assign({},e),n=await this.tuneMldevInternal(t),i="";return void 0!==n.metadata&&void 0!==n.metadata.tunedModel?i=n.metadata.tunedModel:void 0!==n.name&&n.name.includes("/operations/")&&(i=n.name.split("/operations/")[0]),{name:i,state:C.JOB_STATE_QUEUED}}}}async getInternal(e){var t,n,i,l;let r="",o={};if(this.apiClient.isVertexAI()){let i,l,a=(i={},null!=(l=te(e,["name"]))&&e7(i,["_url","name"],l),i);return r=e8("{name}",a._url),o=a._query,delete a._url,delete a._query,this.apiClient.request({path:r,queryParams:o,body:JSON.stringify(a),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>n0(e))}{let t,n,a=(t={},null!=(n=te(e,["name"]))&&e7(t,["_url","name"],n),t);return r=e8("{name}",a._url),o=a._query,delete a._url,delete a._query,this.apiClient.request({path:r,queryParams:o,body:JSON.stringify(a),httpMethod:"GET",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(l=e.config)?void 0:l.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>nQ(e))}}async listInternal(e){var t,n,i,l;let r="",o={};if(this.apiClient.isVertexAI()){let i,l,a,s,u,p=(i={},null!=(l=te(e,["config"]))&&(a=te(l,["pageSize"]),void 0!==i&&null!=a&&e7(i,["_query","pageSize"],a),s=te(l,["pageToken"]),void 0!==i&&null!=s&&e7(i,["_query","pageToken"],s),u=te(l,["filter"]),void 0!==i&&null!=u&&e7(i,["_query","filter"],u)),i);return r=e8("tuningJobs",p._url),o=p._query,delete p._url,delete p._query,this.apiClient.request({path:r,queryParams:o,body:JSON.stringify(p),httpMethod:"GET",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=function(e,t){let n={},i=te(e,["sdkHttpResponse"]);null!=i&&e7(n,["sdkHttpResponse"],i);let l=te(e,["nextPageToken"]);null!=l&&e7(n,["nextPageToken"],l);let r=te(e,["tuningJobs"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>n0(e))),e7(n,["tuningJobs"],e)}return n}(e),n=new tg;return Object.assign(n,t),n})}{let t,n,a,s,u,p=(t={},null!=(n=te(e,["config"]))&&(a=te(n,["pageSize"]),void 0!==t&&null!=a&&e7(t,["_query","pageSize"],a),s=te(n,["pageToken"]),void 0!==t&&null!=s&&e7(t,["_query","pageToken"],s),u=te(n,["filter"]),void 0!==t&&null!=u&&e7(t,["_query","filter"],u)),t);return r=e8("tunedModels",p._url),o=p._query,delete p._url,delete p._query,this.apiClient.request({path:r,queryParams:o,body:JSON.stringify(p),httpMethod:"GET",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(l=e.config)?void 0:l.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t=function(e,t){let n={},i=te(e,["sdkHttpResponse"]);null!=i&&e7(n,["sdkHttpResponse"],i);let l=te(e,["nextPageToken"]);null!=l&&e7(n,["nextPageToken"],l);let r=te(e,["tunedModels"]);if(null!=r){let e=r;Array.isArray(e)&&(e=e.map(e=>nQ(e))),e7(n,["tuningJobs"],e)}return n}(e),n=new tg;return Object.assign(n,t),n})}}async cancel(e){var t,n,i,l;let r="",o={};if(this.apiClient.isVertexAI()){let i,l,a=(i={},null!=(l=te(e,["name"]))&&e7(i,["_url","name"],l),i);r=e8("{name}:cancel",a._url),o=a._query,delete a._url,delete a._query,await this.apiClient.request({path:r,queryParams:o,body:JSON.stringify(a),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal})}else{let t,n,a=(t={},null!=(n=te(e,["name"]))&&e7(t,["_url","name"],n),t);r=e8("{name}:cancel",a._url),o=a._query,delete a._url,delete a._query,await this.apiClient.request({path:r,queryParams:o,body:JSON.stringify(a),httpMethod:"POST",httpOptions:null==(i=e.config)?void 0:i.httpOptions,abortSignal:null==(l=e.config)?void 0:l.abortSignal})}}async tuneInternal(e){var t,n;let i="",l={};if(this.apiClient.isVertexAI()){let r,o,a,s,u,p=(r={},null!=(o=te(e,["baseModel"]))&&e7(r,["baseModel"],o),null!=(a=te(e,["preTunedModel"]))&&e7(r,["preTunedModel"],a),null!=(s=te(e,["trainingDataset"]))&&function(e,t,n){let i=te(n,["config","method"]);if(void 0===i&&(i="SUPERVISED_FINE_TUNING"),"SUPERVISED_FINE_TUNING"===i){let n=te(e,["gcsUri"]);void 0!==t&&null!=n&&e7(t,["supervisedTuningSpec","trainingDatasetUri"],n)}else if("PREFERENCE_TUNING"===i){let n=te(e,["gcsUri"]);void 0!==t&&null!=n&&e7(t,["preferenceOptimizationSpec","trainingDatasetUri"],n)}let l=te(n,["config","method"]);if(void 0===l&&(l="SUPERVISED_FINE_TUNING"),"SUPERVISED_FINE_TUNING"===l){let n=te(e,["vertexDatasetResource"]);void 0!==t&&null!=n&&e7(t,["supervisedTuningSpec","trainingDatasetUri"],n)}else if("PREFERENCE_TUNING"===l){let n=te(e,["vertexDatasetResource"]);void 0!==t&&null!=n&&e7(t,["preferenceOptimizationSpec","trainingDatasetUri"],n)}if(void 0!==te(e,["examples"]))throw Error("examples parameter is not supported in Vertex AI.")}(s,r,e),null!=(u=te(e,["config"]))&&function(e,t,n){let i=te(n,["config","method"]);if(void 0===i&&(i="SUPERVISED_FINE_TUNING"),"SUPERVISED_FINE_TUNING"===i){let n=te(e,["validationDataset"]);void 0!==t&&null!=n&&e7(t,["supervisedTuningSpec"],n1(n))}else if("PREFERENCE_TUNING"===i){let n=te(e,["validationDataset"]);void 0!==t&&null!=n&&e7(t,["preferenceOptimizationSpec"],n1(n))}let l=te(e,["tunedModelDisplayName"]);void 0!==t&&null!=l&&e7(t,["tunedModelDisplayName"],l);let r=te(e,["description"]);void 0!==t&&null!=r&&e7(t,["description"],r);let o=te(n,["config","method"]);if(void 0===o&&(o="SUPERVISED_FINE_TUNING"),"SUPERVISED_FINE_TUNING"===o){let n=te(e,["epochCount"]);void 0!==t&&null!=n&&e7(t,["supervisedTuningSpec","hyperParameters","epochCount"],n)}else if("PREFERENCE_TUNING"===o){let n=te(e,["epochCount"]);void 0!==t&&null!=n&&e7(t,["preferenceOptimizationSpec","hyperParameters","epochCount"],n)}let a=te(n,["config","method"]);if(void 0===a&&(a="SUPERVISED_FINE_TUNING"),"SUPERVISED_FINE_TUNING"===a){let n=te(e,["learningRateMultiplier"]);void 0!==t&&null!=n&&e7(t,["supervisedTuningSpec","hyperParameters","learningRateMultiplier"],n)}else if("PREFERENCE_TUNING"===a){let n=te(e,["learningRateMultiplier"]);void 0!==t&&null!=n&&e7(t,["preferenceOptimizationSpec","hyperParameters","learningRateMultiplier"],n)}let s=te(n,["config","method"]);if(void 0===s&&(s="SUPERVISED_FINE_TUNING"),"SUPERVISED_FINE_TUNING"===s){let n=te(e,["exportLastCheckpointOnly"]);void 0!==t&&null!=n&&e7(t,["supervisedTuningSpec","exportLastCheckpointOnly"],n)}else if("PREFERENCE_TUNING"===s){let n=te(e,["exportLastCheckpointOnly"]);void 0!==t&&null!=n&&e7(t,["preferenceOptimizationSpec","exportLastCheckpointOnly"],n)}let u=te(n,["config","method"]);if(void 0===u&&(u="SUPERVISED_FINE_TUNING"),"SUPERVISED_FINE_TUNING"===u){let n=te(e,["adapterSize"]);void 0!==t&&null!=n&&e7(t,["supervisedTuningSpec","hyperParameters","adapterSize"],n)}else if("PREFERENCE_TUNING"===u){let n=te(e,["adapterSize"]);void 0!==t&&null!=n&&e7(t,["preferenceOptimizationSpec","hyperParameters","adapterSize"],n)}if(void 0!==te(e,["batchSize"]))throw Error("batchSize parameter is not supported in Vertex AI.");if(void 0!==te(e,["learningRate"]))throw Error("learningRate parameter is not supported in Vertex AI.");let p=te(e,["labels"]);void 0!==t&&null!=p&&e7(t,["labels"],p);let d=te(e,["beta"]);void 0!==t&&null!=d&&e7(t,["preferenceOptimizationSpec","hyperParameters","beta"],d)}(u,r,e),r);return i=e8("tuningJobs",p._url),l=p._query,delete p._url,delete p._query,this.apiClient.request({path:i,queryParams:l,body:JSON.stringify(p),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>n0(e))}throw Error("This method is only supported by the Vertex AI.")}async tuneMldevInternal(e){var t,n;let i="",l={};if(this.apiClient.isVertexAI())throw Error("This method is only supported by the Gemini Developer API.");{let r,o,a,s,u,p=(r={},null!=(o=te(e,["baseModel"]))&&e7(r,["baseModel"],o),null!=(a=te(e,["preTunedModel"]))&&e7(r,["preTunedModel"],a),null!=(s=te(e,["trainingDataset"]))&&function(e,t){if(void 0!==te(e,["gcsUri"]))throw Error("gcsUri parameter is not supported in Gemini API.");if(void 0!==te(e,["vertexDatasetResource"]))throw Error("vertexDatasetResource parameter is not supported in Gemini API.");let n=te(e,["examples"]);if(null!=n){let e=n;Array.isArray(e)&&(e=e.map(e=>e)),e7({},["examples","examples"],e)}}(s),null!=(u=te(e,["config"]))&&function(e,t,n){if(void 0!==te(e,["validationDataset"]))throw Error("validationDataset parameter is not supported in Gemini API.");let i=te(e,["tunedModelDisplayName"]);if(void 0!==t&&null!=i&&e7(t,["displayName"],i),void 0!==te(e,["description"]))throw Error("description parameter is not supported in Gemini API.");let l=te(e,["epochCount"]);void 0!==t&&null!=l&&e7(t,["tuningTask","hyperparameters","epochCount"],l);let r=te(e,["learningRateMultiplier"]);if(null!=r&&e7({},["tuningTask","hyperparameters","learningRateMultiplier"],r),void 0!==te(e,["exportLastCheckpointOnly"]))throw Error("exportLastCheckpointOnly parameter is not supported in Gemini API.");if(void 0!==te(e,["preTunedModelCheckpointId"]))throw Error("preTunedModelCheckpointId parameter is not supported in Gemini API.");if(void 0!==te(e,["adapterSize"]))throw Error("adapterSize parameter is not supported in Gemini API.");let o=te(e,["batchSize"]);void 0!==t&&null!=o&&e7(t,["tuningTask","hyperparameters","batchSize"],o);let a=te(e,["learningRate"]);if(void 0!==t&&null!=a&&e7(t,["tuningTask","hyperparameters","learningRate"],a),void 0!==te(e,["labels"]))throw Error("labels parameter is not supported in Gemini API.");if(void 0!==te(e,["beta"]))throw Error("beta parameter is not supported in Gemini API.")}(u,r),r);return i=e8("tunedModels",p._url),l=p._query,delete p._url,delete p._query,this.apiClient.request({path:i,queryParams:l,body:JSON.stringify(p),httpMethod:"POST",httpOptions:null==(t=e.config)?void 0:t.httpOptions,abortSignal:null==(n=e.config)?void 0:n.abortSignal}).then(e=>e.json().then(t=>(t.sdkHttpResponse={headers:e.headers},t))).then(e=>{let t,n,i,l,r,o;return t={},null!=(n=te(e,["sdkHttpResponse"]))&&e7(t,["sdkHttpResponse"],n),null!=(i=te(e,["name"]))&&e7(t,["name"],i),null!=(l=te(e,["metadata"]))&&e7(t,["metadata"],l),null!=(r=te(e,["done"]))&&e7(t,["done"],r),null!=(o=te(e,["error"]))&&e7(t,["error"],o),t})}}}class n4{async download(e,t){throw Error("Download to file is not supported in the browser, please use a browser compliant download like an <a> tag.")}}let n2="x-goog-upload-status";async function n3(e,t,n){var i;let l=await n5(e,t,n),r=await (null==l?void 0:l.json());if((null==(i=null==l?void 0:l.headers)?void 0:i[n2])!=="final")throw Error("Failed to upload file: Upload status is not finalized.");return r.file}async function n9(e,t,n){var i;let l=await n5(e,t,n),r=await (null==l?void 0:l.json());if((null==(i=null==l?void 0:l.headers)?void 0:i[n2])!=="final")throw Error("Failed to upload file: Upload status is not finalized.");let o=tn(r),a=new tR;return Object.assign(a,o),a}async function n5(e,t,n){var i,l;let r=0,o=0,a=new ti(new Response),s="upload";for(r=e.size;o<r;){let u=Math.min(8388608,r-o),p=e.slice(o,o+u);o+u>=r&&(s+=", finalize");let d=0,c=1e3;for(;d<3&&(null==(i=null==(a=await n.request({path:"",body:p,httpMethod:"POST",httpOptions:{apiVersion:"",baseUrl:t,headers:{"X-Goog-Upload-Command":s,"X-Goog-Upload-Offset":String(o),"Content-Length":String(u)}}}))?void 0:a.headers)||!i[n2]);)d++,await function(e){return new Promise(t=>setTimeout(t,e))}(c),c*=2;if(o+=u,(null==(l=null==a?void 0:a.headers)?void 0:l[n2])!=="active")break;if(r<=o)throw Error("All content has been uploaded, but the upload status is not finalized.")}return a}async function n8(e){return{size:e.size,type:e.type}}class n7{async upload(e,t,n){if("string"==typeof e)throw Error("File path is not supported in browser uploader.");return await n3(e,t,n)}async uploadToFileSearchStore(e,t,n){if("string"==typeof e)throw Error("File path is not supported in browser uploader.");return await n9(e,t,n)}async stat(e){if("string"!=typeof e)return await n8(e);throw Error("File path is not supported in browser uploader.")}}class ie{create(e,t,n){return new it(e,t,n)}}class it{constructor(e,t,n){this.url=e,this.headers=t,this.callbacks=n}connect(){this.ws=new WebSocket(this.url),this.ws.onopen=this.callbacks.onopen,this.ws.onerror=this.callbacks.onerror,this.ws.onclose=this.callbacks.onclose,this.ws.onmessage=this.callbacks.onmessage}send(e){if(void 0===this.ws)throw Error("WebSocket is not connected");this.ws.send(e)}close(){if(void 0===this.ws)throw Error("WebSocket is not connected");this.ws.close()}}let ii="x-goog-api-key";class il{constructor(e){this.apiKey=e}async addAuthHeaders(e,t){if(null===e.get(ii)){if(this.apiKey.startsWith("auth_tokens/"))throw Error("Ephemeral tokens are only supported by the live API.");if(!this.apiKey)throw Error("API key is missing. Please provide a valid API key.");e.append(ii,this.apiKey)}}}class ir{constructor(e){var t;if(null==e.apiKey)throw Error("An API Key must be set when running in a browser");if(e.project||e.location)throw Error("Vertex AI project based authentication is not supported on browser runtimes. Please do not provide a project or location.");this.vertexai=null!=(t=e.vertexai)&&t,this.apiKey=e.apiKey;const n=function(e,t,n,i){return(null==e?void 0:e.baseUrl)?e.baseUrl:t?null!=e9?e9:n:null!=e3?e3:i}(e.httpOptions,e.vertexai,void 0,void 0);n&&(e.httpOptions?e.httpOptions.baseUrl=n:e.httpOptions={baseUrl:n}),this.apiVersion=e.apiVersion;const i=new il(this.apiKey);this.apiClient=new nM({auth:i,apiVersion:this.apiVersion,apiKey:this.apiKey,vertexai:this.vertexai,httpOptions:e.httpOptions,userAgentExtra:"gl-node/web",uploader:new n7,downloader:new n4}),this.models=new n$(this.apiClient),this.live=new nF(this.apiClient,i,new ie),this.batches=new t7(this.apiClient),this.chats=new na(this.models,this.apiClient),this.caches=new nt(this.apiClient),this.files=new np(this.apiClient),this.operations=new nW(this.apiClient),this.authTokens=new nz(this.apiClient),this.tunings=new n6(this.apiClient),this.fileSearchStores=new nZ(this.apiClient)}}let io=`你是一位頂尖的 AI 視覺行銷總監。
2
-
3
- ## 任務
4
- 1. 深度分析使用者上傳的「產品圖片」及提供的「品牌資訊/產品名稱」
5
- 2. 制定三個截然不同的行銷視覺策略路線
6
-
7
- ## 輸入處理規則
8
- - **產品名稱**:在分析中準確使用此名稱
9
- - **品牌資訊/網址**:提取品牌精神、調性或背景故事。若包含網址,忽略促銷雜訊(價格、購物車、導航),專注擷取「品牌價值」、「設計理念」、「目標客群」
10
-
11
- ## 執行流程
12
-
13
- ### 階段一:產品分析
14
- 結合圖片視覺特徵與文字資訊,精確描述:
15
- - 產品外觀、包裝設計、色彩搭配
16
- - 材質質感、視覺風格
17
- - 核心功能與賣點
18
-
19
- ### 階段二:策略規劃
20
- 構思三條截然不同的行銷視覺路線,每條需包含:
21
- - 路線名稱(英文,簡潔有力)
22
- - 主標題(繁體中文,8-15字,吸睛有記憶點)
23
- - 副標題(繁體中文,15-25字,補充說明)
24
- - 視覺風格描述(繁體中文,50-80字,包含色調、氛圍、設計元素)
25
- - 目標受眾(繁體中文,描述人群特徵與需求)
26
-
27
- ## 輸出格式
28
- 僅輸出 JSON,不要其他文字:
29
- {
30
- "product_analysis": {
31
- "name": "產品中文名稱",
32
- "visual_description": "產品視覺描述(詳述包裝、色彩、材質、風格)",
33
- "key_features": "核心功能與賣點"
34
- },
35
- "marketing_routes": [
36
- {
37
- "route_name": "English Route Name",
38
- "headline": "主標題",
39
- "subhead": "副標題",
40
- "style_brief": "視覺風格描述",
41
- "target_audience": "目標受眾描述"
42
- }
43
- ]
44
- }
45
-
46
- ## 注意事項
47
- - 三條路線必須差異明顯(如:功能導向 vs 情感導向 vs 生活風格)
48
- - 避免使用過於誇大的形容詞(最、第一、絕對)
49
- - 文案要具體,不要空泛的行銷術語`,ia=`You are a top-tier AI Visual Marketing Director.
50
-
51
- ## Task
52
- 1. Deep analysis of the uploaded "product image" and provided "brand information/product name"
53
- 2. Develop three distinctly different marketing visual strategy routes
54
-
55
- ## Input Processing Rules
56
- - **Product Name**: Use this name accurately in the analysis
57
- - **Brand Information/URL**: Extract brand spirit, tone, or background story. If URLs are included, ignore promotional noise (prices, cart buttons, navigation), focus only on extracting "brand values", "design philosophy", "target audience"
58
-
59
- ## Execution Flow
60
-
61
- ### Phase 1: Product Analysis
62
- Combine image visual features with text information to precisely describe:
63
- - Product appearance, packaging design, color scheme
64
- - Material texture, visual style
65
- - Core features and selling points
66
-
67
- ### Phase 2: Strategy Planning
68
- Conceive three distinctly different marketing visual routes, each must include:
69
- - Route Name (English, concise and impactful)
70
- - Headline (English, 5-10 words, eye-catching and memorable)
71
- - Subhead (English, 10-20 words, supplementary explanation)
72
- - Visual Style Description (English, 50-80 words, including color tone, atmosphere, design elements)
73
- - Target Audience (English, describing demographic characteristics and needs)
74
-
75
- ## Output Format
76
- Output JSON only, no other text:
77
- {
78
- "product_analysis": {
79
- "name": "Product Name in English",
80
- "visual_description": "Product visual description (detailed packaging, colors, materials, style)",
81
- "key_features": "Core features and selling points in English"
82
- },
83
- "marketing_routes": [
84
- {
85
- "route_name": "English Route Name",
86
- "headline": "Headline in English",
87
- "subhead": "Subhead in English",
88
- "style_brief": "Visual style description in English",
89
- "target_audience": "Target audience description in English"
90
- }
91
- ]
92
- }
93
-
94
- ## Important Notes
95
- - Three routes must be distinctly different (e.g., feature-focused vs emotion-focused vs lifestyle)
96
- - Avoid superlatives like "best", "first", "absolute"
97
- - Copy should be specific, avoid vague marketing jargon`,is=`你是一位資深的社群內容規劃師。
98
-
99
- ## 任務
100
- 根據選定的「行銷策略路線」、「參考文案」、「選定的圖片尺寸」,為每個尺寸規劃 **3 組不同的內容方案**。
101
-
102
- ## 輸入資訊
103
- 1. **選定的行銷策略**:Slogan、風格、產品特點
104
- 2. **參考文案(選填)**:拆解其「說服邏輯」與「敘事結構」。若無提供,依產品屬性決定最佳 AIDA 結構
105
- 3. **選定的圖片尺寸**:
106
- - 1:1(FB 貼文)
107
- - 9:16(限時動態 / Stories / Reels)
108
- - 4:5(IG 貼文)
109
- - 16:9(橫式貼文 - 封面、廣告)
110
- - 1:1-commercial(商業攝影 - 專業商品攝影)
111
-
112
- ## 輸出需求:每個尺寸 3 組內容
113
-
114
- 每組包含:
115
- 1. **title**: 圖片主標題(5-12字,吸睛簡潔)
116
- 2. **copy**: 輔助文案(15-30字,具體有說服力)
117
- 3. **visual_summary**: 畫面構圖摘要(描述視覺呈現方式)
118
- 4. **visual_prompt_en**: 英文繪圖指令(給 AI 繪圖模型)
119
-
120
- ## 3 組內容差異化策略
121
- - **第 1 組**:功能導向 - 強調產品功能、特點、使用方式
122
- - **第 2 組**:情感導向 - 強調生活情境、感受、品牌故事
123
- - **第 3 組**:數據/背書導向 - 強調成效、評價、專業認證
124
-
125
- ## 視覺 Prompt 規範
126
-
127
- **開頭固定句**:
128
- "KEEP THE PRODUCT EXACTLY AS SHOWN IN THE REFERENCE IMAGE, DO NOT MODIFY THE PRODUCT ITSELF. "
129
-
130
- **尺寸規範**:
131
- - 1:1:"Square composition, 1:1 aspect ratio, product placement in center"
132
- - 9:16:"Vertical composition, 9:16 aspect ratio, mobile screen layout, product placement in center"
133
- - 4:5:"Vertical composition, 4:5 aspect ratio, Instagram feed optimized, product placement in center"
134
- - 16:9:"Horizontal composition, 16:9 aspect ratio, widescreen layout, banner format, product placement in center"
135
- - 1:1-commercial:"Professional commercial photography, square composition, 1:1 aspect ratio, CLEAN SOLID COLOR BACKGROUND (light gray #f6f6f6 or pure white #ffffff), NO props NO decorations NO distracting elements, studio lighting setup with soft diffused light, high-end DSLR camera quality, product as the ABSOLUTE focal point centered in frame, sharp focus on product details and texture, minimal harsh shadows, commercial e-commerce product photography aesthetic"
136
-
137
- **寫作原則**:
138
- - 產品必須保持原貌,不可改變包裝、顏色、形狀、文字
139
- - 只描述背景、光線、氛圍、道具等周圍元素
140
- - 使用 "around the product" 或 "in the background" 明確區分
141
-
142
- ## 輸出格式
143
- 僅輸出 JSON:
144
- {
145
- "plan_name": "企劃名稱",
146
- "selected_sizes": ["1:1", "9:16"],
147
- "content_sets": [
148
- {
149
- "id": "1-1_set1",
150
- "ratio": "1:1",
151
- "size_label": "產品圖",
152
- "set_number": 1,
153
- "title": "主標題",
154
- "copy": "輔助文案",
155
- "visual_summary": "構圖摘要",
156
- "visual_prompt_en": "英文繪圖指令"
157
- }
158
- ]
159
- }
160
-
161
- ## 重要提醒
162
- - 每個尺寸必須生成恰好 3 組內容
163
- - 3 組內容必須有明顯的行銷角度差異
164
- - ratio 欄位必須完全匹配輸入尺寸(如 "1:1-commercial" 不是 "1:1")
165
- - id 格式:ratio + "_set" + 編號(如 "1-1-commercial_set1")
166
- - 文案避免使用「最」「第一」「絕對」等誇大詞彙`,iu=`You are a senior Social Media Content Strategist.
167
-
168
- ## Task
169
- Based on the selected "marketing strategy route", "reference copy", and "selected image sizes", plan **3 different content sets** for each size.
170
-
171
- ## Input Information
172
- 1. **Selected Marketing Strategy**: Slogan, style, product features
173
- 2. **Reference Copy (Optional)**: Deconstruct its "persuasion logic" and "narrative structure". If not provided, determine the best AIDA structure based on product attributes
174
- 3. **Selected Image Sizes**:
175
- - 1:1 (FB Post)
176
- - 9:16 (Stories / Reels)
177
- - 4:5 (IG Post)
178
- - 16:9 (Landscape - Cover, Ads)
179
- - 1:1-commercial (Commercial Photography - Professional Product Photography)
180
-
181
- ## Output Requirements: 3 Content Sets per Size
182
-
183
- Each set includes (ALL CONTENT IN ENGLISH):
184
- 1. **title**: Image headline (5-10 words, eye-catching and concise)
185
- 2. **copy**: Supporting copy (15-25 words, specific and persuasive)
186
- 3. **visual_summary**: Visual composition summary (describing visual presentation)
187
- 4. **visual_prompt_en**: English drawing instructions (for AI image generation model)
188
-
189
- ## Differentiation Strategy for 3 Sets
190
- - **Set 1**: Feature-oriented - Emphasize product features, characteristics, usage
191
- - **Set 2**: Emotion-oriented - Emphasize lifestyle scenarios, feelings, brand story
192
- - **Set 3**: Data/Endorsement-oriented - Emphasize effectiveness, reviews, professional certification
193
-
194
- ## Visual Prompt Guidelines
195
-
196
- **Fixed Opening Sentence**:
197
- "KEEP THE PRODUCT EXACTLY AS SHOWN IN THE REFERENCE IMAGE, DO NOT MODIFY THE PRODUCT ITSELF. "
198
-
199
- **Size Specifications**:
200
- - 1:1: "Square composition, 1:1 aspect ratio, product placement in center"
201
- - 9:16: "Vertical composition, 9:16 aspect ratio, mobile screen layout, product placement in center"
202
- - 4:5: "Vertical composition, 4:5 aspect ratio, Instagram feed optimized, product placement in center"
203
- - 16:9: "Horizontal composition, 16:9 aspect ratio, widescreen layout, banner format, product placement in center"
204
- - 1:1-commercial: "Professional commercial photography, square composition, 1:1 aspect ratio, CLEAN SOLID COLOR BACKGROUND (light gray #f6f6f6 or pure white #ffffff), NO props NO decorations NO distracting elements, studio lighting setup with soft diffused light, high-end DSLR camera quality, product as the ABSOLUTE focal point centered in frame, sharp focus on product details and texture, minimal harsh shadows, commercial e-commerce product photography aesthetic"
205
-
206
- **Writing Principles**:
207
- - Product must remain unchanged, do not alter packaging, color, shape, text
208
- - Only describe background, lighting, atmosphere, props and surrounding elements
209
- - Use "around the product" or "in the background" to clearly differentiate
210
-
211
- ## Output Format
212
- Output JSON only:
213
- {
214
- "plan_name": "Project Name",
215
- "selected_sizes": ["1:1", "9:16"],
216
- "content_sets": [
217
- {
218
- "id": "1-1_set1",
219
- "ratio": "1:1",
220
- "size_label": "Product Image",
221
- "set_number": 1,
222
- "title": "Headline",
223
- "copy": "Supporting copy",
224
- "visual_summary": "Composition summary",
225
- "visual_prompt_en": "English drawing instructions"
226
- }
227
- ]
228
- }
229
-
230
- ## Important Reminders
231
- - Each size must generate exactly 3 content sets
232
- - 3 sets must have clear marketing angle differences
233
- - ratio field must exactly match input size (e.g., "1:1-commercial" not "1:1")
234
- - id format: ratio + "_set" + number (e.g., "1-1-commercial_set1")
235
- - Avoid superlatives like "best", "first", "absolute" in copy`,ip={zh:{apiKeyInvalid:"API 金鑰無效或已過期。請檢查您的金鑰設定。",rateLimitExceeded:"請求過於頻繁,已達到 API 限制。請稍後再試。",networkError:"網路連線錯誤。請檢查您的網路連線後再試。",requestTimeout:"請求超時。請稍後再試,或嘗試生成較簡單的內容。",contentBlocked:"內容被安全過濾器阻擋。請嘗試調整您的輸入內容。",serviceUnavailable:"AI 服務暫時無法使用。請稍後再試。",apiKeyMissing:"請提供 API 金鑰",noResponse:"Gemini 沒有回應文字",invalidFormat:"AI 返回了無效的格式,且自動修復失敗。請再試一次。",planningFailed:"Gemini 規劃失敗",missingContentSets:"API 返回格式錯誤:缺少 content_sets 陣列",missingSelectedSizes:"API 返回格式錯誤:缺少 selected_sizes 陣列",noImageGenerated:"未生成圖片。",promptRegenerateFailed:"重新生成視覺提示詞失敗"},en:{apiKeyInvalid:"API key is invalid or expired. Please check your key settings.",rateLimitExceeded:"Too many requests. API limit reached. Please try again later.",networkError:"Network connection error. Please check your connection and try again.",requestTimeout:"Request timed out. Please try again later or try generating simpler content.",contentBlocked:"Content was blocked by safety filters. Please adjust your input.",serviceUnavailable:"AI service is temporarily unavailable. Please try again later.",apiKeyMissing:"Please provide an API key",noResponse:"Gemini returned no response",invalidFormat:"AI returned invalid format and auto-repair failed. Please try again.",planningFailed:"Gemini planning failed",missingContentSets:"API returned invalid format: missing content_sets array",missingSelectedSizes:"API returned invalid format: missing selected_sizes array",noImageGenerated:"No image was generated.",promptRegenerateFailed:"Failed to regenerate visual prompt"}};function id(e,t="en"){return ip[t][e]}let ic="gemini-2.5-flash",ih="gemini-3-pro-image-preview",im=e=>{let t=e.trim();return t.startsWith("```json")?t=t.replace(/^```json/,"").replace(/```$/,""):t.startsWith("```")&&(t=t.replace(/^```/,"").replace(/```$/,"")),t.trim()};async function ig(e,t=3,n=1e3){let i;for(let l=0;l<=t;l++)try{return await e()}catch(o){let e=(i=o instanceof Error?o:Error(String(o))).message.toLowerCase();if(!(e.includes("network")||e.includes("timeout")||e.includes("econnreset")||e.includes("enotfound")||e.includes("503")||e.includes("429")||e.includes("rate limit"))||l===t)throw i;let r=n*Math.pow(2,l);await new Promise(e=>setTimeout(e,r))}throw i}function iy(e,t="en"){let n=e instanceof Error?e.message:String(e),i=n.toLowerCase();return i.includes("api key")||i.includes("unauthorized")||i.includes("401")?Error(id("apiKeyInvalid",t)):i.includes("rate limit")||i.includes("429")||i.includes("quota")?Error(id("rateLimitExceeded",t)):i.includes("network")||i.includes("econnreset")||i.includes("enotfound")?Error(id("networkError",t)):i.includes("timeout")?Error(id("requestTimeout",t)):i.includes("safety")||i.includes("blocked")||i.includes("harmful")?Error(id("contentBlocked",t)):i.includes("500")||i.includes("502")||i.includes("503")?Error(id("serviceUnavailable",t)):e instanceof Error?e:Error(n)}async function iE(e){let t=e.locale||"en";if(!e.apiKey)throw Error(id("apiKeyMissing",t));let n=new ir({apiKey:e.apiKey}),i=[];if(e.productInfo){let n="en"===t?"Manual input info":"手動輸入資訊";i.push(`${n}: ${e.productInfo}`)}if(e.productUrl&&(e=>{try{let t=new URL(e);return["http:","https:"].includes(t.protocol)}catch{return!1}})(e.productUrl)){let n="en"===t?"Product URL":"產品網址",l="en"===t?"(Note: Please infer possible brand positioning and product features based on this URL)":"(注意:請根據此網址推測可能的品牌定位與產品特色)";i.push(`${n}: ${e.productUrl}
236
- ${l}`)}let l="en"===t?"Not provided":"未提供",r=i.length>0?i.join("\n\n"):l,o="en"===t?`
237
- Product Name: ${e.productName||"Not provided"}
238
- Brand/Product Info: ${r}
239
- ${e.productUrl?`Product URL: ${e.productUrl}`:""}
240
-
241
- Please analyze the above information and image, and execute the visual marketing director analysis task.
242
- `:`
243
- 產品名稱: ${e.productName||"未提供"}
244
- 品牌/產品資訊: ${r}
245
- ${e.productUrl?`產品網址: ${e.productUrl}`:""}
246
-
247
- 請根據上述資訊與圖片,執行視覺行銷總監的分析任務。
248
- `;try{let i,l=await ig(()=>n.models.generateContent({model:ic,contents:{parts:[{inlineData:{data:e.imageBase64,mimeType:e.imageMimeType}},{text:o}]},config:{systemInstruction:((e="zh")=>"en"===e?ia:io)(t),responseMimeType:"application/json",temperature:1,topP:.95}}));if(!l.text)throw Error(id("noResponse",t));let r=im(l.text);try{i=JSON.parse(r)}catch{let e=r,n=(e.match(/{/g)||[]).length,l=(e.match(/}/g)||[]).length,o=(e.match(/\[/g)||[]).length,a=(e.match(/]/g)||[]).length;n>l&&(e+="}".repeat(n-l)),o>a&&(e+="]".repeat(o-a));try{i=JSON.parse(e)}catch{throw Error(id("invalidFormat",t))}}return i}catch(e){throw iy(e,t)}}async function i_(e){let t=e.locale||"en";if(!e.apiKey)throw Error(id("apiKeyMissing",t));let n=new ir({apiKey:e.apiKey}),i="en"===t?{"1:1":"FB Post","9:16":"Stories","4:5":"IG Post","16:9":"Landscape","1:1-commercial":"Commercial"}:{"1:1":"FB 貼文","9:16":"限時動態 / Stories","4:5":"IG 貼文","16:9":"橫式貼文","1:1-commercial":"商業攝影"},l=e.selectedSizes.map(e=>`${e} (${i[e]})`).join(", "),r="en"===t?`
249
- Selected Strategy Route: ${e.route.route_name}
250
- Headline: ${e.route.headline}
251
- Subhead: ${e.route.subhead}
252
- Style: ${e.route.style_brief}
253
- Target Audience: ${e.route.target_audience}
254
-
255
- Product Name: ${e.analysis.name}
256
- Product Features: ${e.analysis.key_features}
257
-
258
- Reference Copy/Competitor Info: ${e.referenceCopy||"None (please plan the best structure)"}
259
-
260
- Selected Image Sizes: ${l}
261
-
262
- Please generate 3 different content sets for each selected size (JSON).
263
- `:`
264
- 選定策略路線: ${e.route.route_name}
265
- 主標題: ${e.route.headline}
266
- 副標題: ${e.route.subhead}
267
- 風格: ${e.route.style_brief}
268
- 目標受眾: ${e.route.target_audience}
269
-
270
- 產品名稱: ${e.analysis.name}
271
- 產品特點: ${e.analysis.key_features}
272
-
273
- 參考文案/競品資訊: ${e.referenceCopy||"無 (請自行規劃最佳結構)"}
274
-
275
- 選定的圖片尺寸: ${l}
276
-
277
- 請為每個選定的尺寸生成 3 組不同的內容方案 (JSON)。
278
- `;try{let e=await ig(()=>n.models.generateContent({model:ic,contents:{parts:[{text:r}]},config:{systemInstruction:((e="zh")=>"en"===e?iu:is)(t),responseMimeType:"application/json",temperature:1,topP:.95,thinkingConfig:{thinkingBudget:2048}}}));if(!e.text)throw Error(id("planningFailed",t));let i=im(e.text),l=JSON.parse(i);if(!l.content_sets||!Array.isArray(l.content_sets))throw Error(id("missingContentSets",t));if(!l.selected_sizes||!Array.isArray(l.selected_sizes))throw Error(id("missingSelectedSizes",t));if(l.content_sets.filter(e=>!e.id||!e.ratio||!e.title||!e.copy||!e.visual_prompt_en).length>0)throw Error("en"===t?"Some content sets are missing required fields":"部分內容方案缺少必要欄位");return l}catch(e){throw iy(e,t)}}async function iI(e){let t=e.locale||"en";if(!e.apiKey)throw Error(id("apiKeyMissing",t));let n=new ir({apiKey:e.apiKey}),i=(e.aspectRatio,e.prompt);e.secondaryImageBase64&&(i+=`
279
-
280
- IMPORTANT - MULTI-PRODUCT COMPOSITION: This image features TWO products that must appear together naturally in the same scene.
281
- - PRIMARY PRODUCT (first image): Main focus, placed prominently in center or foreground
282
- - SECONDARY PRODUCT (second image): Supporting element, placed naturally alongside, emerging from, or complementing the primary product
283
- - Create a cohesive lifestyle/gift composition where both products appear together harmoniously
284
- - Both products should maintain their original appearance and details
285
- - The scene should tell a story of how these products relate to each other`);let l=[{text:i}];if(e.referenceImageBase64){let t=e.referenceImageBase64.match(/^data:(image\/[a-zA-Z+]+);base64,(.+)$/);t&&l.push({inlineData:{data:t[2],mimeType:t[1]}})}if(e.secondaryImageBase64){let t=e.secondaryImageBase64.match(/^data:(image\/[a-zA-Z+]+);base64,(.+)$/);t&&l.push({inlineData:{data:t[2],mimeType:t[1]}})}try{let e=(await ig(()=>n.models.generateContent({model:ih,contents:{parts:l},config:{responseModalities:["image","text"]}}))).candidates;if(e&&e.length>0){let t=e[0]?.content;if(t?.parts){for(let e of t.parts)if(e.inlineData&&e.inlineData.data)return`data:${e.inlineData.mimeType||"image/png"};base64,${e.inlineData.data}`}}throw Error(id("noImageGenerated",t))}catch(e){throw iy(e,t)}}async function iT(e){let t=e.locale||"en";if(!e.apiKey)throw Error(id("apiKeyMissing",t));let n=new ir({apiKey:e.apiKey}),i={"1:1":"Square composition, 1:1 aspect ratio","9:16":"Vertical composition, 9:16 aspect ratio, mobile screen layout","4:5":"Vertical composition, 4:5 aspect ratio, Instagram feed optimized","16:9":"Horizontal composition, 16:9 aspect ratio, widescreen layout, banner format","1:1-commercial":"Professional commercial photography, square composition, 1:1 aspect ratio, CLEAN SOLID COLOR BACKGROUND (light gray #f6f6f6 or pure white #ffffff), NO props NO decorations NO distracting elements, studio lighting setup with soft diffused light, high-end DSLR camera quality (Canon EOS R5 or Sony A7R IV style), product as the ABSOLUTE focal point centered in frame, sharp focus on product details and texture, minimal harsh shadows, commercial e-commerce product photography aesthetic, high resolution, professional color grading, simple minimalist composition"},l=e.visualSummaryZh?`
286
- - 構圖摘要 (Visual Summary): ${e.visualSummaryZh}
287
-
288
- **重要:請務必根據「構圖摘要」的描述來生成視覺提示詞,這是使用者指定的視覺方向。**`:"",r=`你是一位專業的視覺設計 Prompt 工程師。
289
-
290
- 你的任務是根據提供的「中文標題」、「中文文案」和「構圖摘要」,生成一個專業的英文視覺提示詞 (Visual Prompt),用於 Gemini 3 Pro Image 生成圖片。
291
-
292
- **輸入資訊:**
293
- - 標題 (Title): ${e.titleZh}
294
- - 文案 (Copy): ${e.copyZh}
295
- - 圖片尺寸: ${e.ratio} (${e.sizeLabel})${l}
296
-
297
- **核心要求:**
298
- 1. **必須保持產品原貌**:使用者會提供產品參考圖,生成的圖片必須「保留產品的完整外觀、包裝設計、顏色、形狀」,不可改變產品本身
299
- 2. **只調整背景和氛圍**:根據標題、文案和構圖摘要調整「背景、光線、道具、氛圍」,但產品本身必須維持原樣
300
- 3. 必須包含尺寸規範:${i[e.ratio]}
301
- 4. ${e.visualSummaryZh?"**最重要:構圖摘要中的指示優先級最高,必須完全遵循**":""}
302
-
303
- **Prompt 寫作指南:**
304
- - 在 Prompt 開頭加上:KEEP THE PRODUCT EXACTLY AS SHOWN IN THE REFERENCE IMAGE, DO NOT MODIFY THE PRODUCT ITSELF
305
- - 使用 "product placement in center" 確保產品位置正確
306
- - 描述背景、光線、氛圍時,明確說明「around the product」或「in the background」
307
- - 使用專業的攝影和設計術語(英文)
308
- - 只輸出英文 Prompt 文字,不要包含任何其他說明
309
-
310
- **範例格式:**
311
- "KEEP THE PRODUCT EXACTLY AS SHOWN IN THE REFERENCE IMAGE, DO NOT MODIFY THE PRODUCT ITSELF. ${i[e.ratio]}, product placement in center, [background description], [lighting description around the product], [mood and atmosphere], [additional props or elements in the background]"`;try{let e=await ig(()=>n.models.generateContent({model:ic,contents:{parts:[{text:"請根據上述資訊生成視覺提示詞。"}]},config:{systemInstruction:r,temperature:.8,topP:.9}}));if(!e.text)throw Error(id("promptRegenerateFailed",t));return e.text.trim()}catch(e){throw iy(e,t)}}async function iv(e){let t,n=e.locale||"en";if(!e.apiKey)throw Error(id("apiKeyMissing",n));let i=new ir({apiKey:e.apiKey}),l=e.aspectRatio||"1:1",r="1:1-commercial"===l?"1:1":"4:5"===l?"4:5":"9:16"===l?"9:16":"16:9"===l?"16:9":"1:1",o={"1:1":"1:1 square format","9:16":"9:16 vertical format for mobile screens","4:5":"4:5 vertical format optimized for Instagram","16:9":"16:9 horizontal widescreen format"};if(t=e.similarity>=70?`Create a professional product photography image very closely following the reference image. Match the composition, object placement, layout, lighting setup, color palette, background style, and overall aesthetic. Place the product from the product image as the main subject, maintaining its original appearance. Professional commercial photography quality, ${o[r]}.`:e.similarity>=40?`Create a professional product photography image moderately following the reference image. Match the lighting style, color palette, and overall mood, but feel free to create a different composition and object arrangement. Place the product from the product image as the main subject, maintaining its original appearance. Professional commercial photography quality, ${o[r]}.`:`Create a professional product photography image loosely inspired by the reference image. ONLY take inspiration from the color tone and atmospheric feeling. DO NOT copy the composition, layout, or object placement. Create a completely new and creative composition with the product as the main subject. The product should maintain its original appearance. Professional commercial photography quality, ${o[r]}.`,e.brandLogoBase64&&(t+="\n\nIMPORTANT: Place the uploaded brand logo in one of the four corners (top-left, top-right, bottom-left, or bottom-right) in a subtle, non-intrusive way. The logo should be clearly visible but not dominate the composition."),e.secondaryProductBase64&&(t+=`
312
-
313
- IMPORTANT - MULTI-PRODUCT COMPOSITION: This image features TWO products that must appear together naturally in the same scene.
314
- - PRIMARY PRODUCT: Main focus, placed prominently in center or foreground
315
- - SECONDARY PRODUCT: Supporting element, placed naturally alongside, emerging from, or complementing the primary product
316
- - Create a cohesive lifestyle/gift composition where both products appear together harmoniously
317
- - Both products should maintain their original appearance and details
318
- - The scene should tell a story of how these products relate to each other`),e.showText&&e.titleText&&e.copyText){let n={regular:"Regular (400)",medium:"Medium (500)",bold:"Bold (700)",black:"Black (900)"},i=e.titleWeight?n[e.titleWeight]:"Bold (700)",l=e.copyWeight?n[e.copyWeight]:"Regular (400)";t+=`
319
-
320
- IMPORTANT: Overlay the following text on the image using Noto Sans TC (Noto Sans Traditional Chinese) font:
321
- Title: "${e.titleText}" (Font: Noto Sans TC ${i})
322
- Copy: "${e.copyText}" (Font: Noto Sans TC ${l})
323
- Use appropriate positioning, size, and styling that complements the visual design. Make sure the font is Noto Sans TC (思源黑體).`}let a=[{text:t}],s=e.referenceImageBase64.match(/^data:(image\/[a-zA-Z+]+);base64,(.+)$/);s&&a.push({inlineData:{data:s[2],mimeType:s[1]}});let u=e.productImageBase64.match(/^data:(image\/[a-zA-Z+]+);base64,(.+)$/);if(u&&a.push({inlineData:{data:u[2],mimeType:u[1]}}),e.brandLogoBase64){let t=e.brandLogoBase64.match(/^data:(image\/[a-zA-Z+]+);base64,(.+)$/);t&&a.push({inlineData:{data:t[2],mimeType:t[1]}})}if(e.secondaryProductBase64){let t=e.secondaryProductBase64.match(/^data:(image\/[a-zA-Z+]+);base64,(.+)$/);t&&a.push({inlineData:{data:t[2],mimeType:t[1]}})}try{let e=(await ig(()=>i.models.generateContent({model:ih,contents:{parts:a},config:{responseModalities:["image","text"]}}))).candidates;if(e&&e.length>0){let t=e[0]?.content;if(t?.parts){for(let e of t.parts)if(e.inlineData&&e.inlineData.data)return`data:${e.inlineData.mimeType||"image/png"};base64,${e.inlineData.data}`}}throw Error(id("noImageGenerated",n))}catch(e){throw iy(e,n)}}async function iA(){return!1}e.s(["analyzeProductImageClient",()=>iE,"generateContentPlanClient",()=>i_,"generateImageFromReferenceClient",()=>iv,"generateMarketingImageClient",()=>iI,"hasServerApiKeyClient",()=>iA,"regenerateVisualPromptClient",()=>iT],24333)}]);