(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))a(r);new MutationObserver(r=>{for(const f of r)if(f.type==="childList")for(const m of f.addedNodes)m.tagName==="LINK"&&m.rel==="modulepreload"&&a(m)}).observe(document,{childList:!0,subtree:!0});function l(r){const f={};return r.integrity&&(f.integrity=r.integrity),r.referrerPolicy&&(f.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?f.credentials="include":r.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f}function a(r){if(r.ep)return;r.ep=!0;const f=l(r);fetch(r.href,f)}})();function Lh(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var lu={exports:{}},$o={};/** * @license React * react-jsx-runtime.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var Op;function e0(){if(Op)return $o;Op=1;var i=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function l(a,r,f){var m=null;if(f!==void 0&&(m=""+f),r.key!==void 0&&(m=""+r.key),"key"in r){f={};for(var g in r)g!=="key"&&(f[g]=r[g])}else f=r;return r=f.ref,{$$typeof:i,type:a,key:m,ref:r!==void 0?r:null,props:f}}return $o.Fragment=t,$o.jsx=l,$o.jsxs=l,$o}var Fp;function t0(){return Fp||(Fp=1,lu.exports=e0()),lu.exports}var B=t0(),au={exports:{}},le={};/** * @license React * react.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var Jp;function n0(){if(Jp)return le;Jp=1;var i=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),l=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),f=Symbol.for("react.consumer"),m=Symbol.for("react.context"),g=Symbol.for("react.forward_ref"),y=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),S=Symbol.for("react.activity"),E=Symbol.iterator;function C(M){return M===null||typeof M!="object"?null:(M=E&&M[E]||M["@@iterator"],typeof M=="function"?M:null)}var U={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},H=Object.assign,b={};function P(M,z,J){this.props=M,this.context=z,this.refs=b,this.updater=J||U}P.prototype.isReactComponent={},P.prototype.setState=function(M,z){if(typeof M!="object"&&typeof M!="function"&&M!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,M,z,"setState")},P.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function X(){}X.prototype=P.prototype;function k(M,z,J){this.props=M,this.context=z,this.refs=b,this.updater=J||U}var K=k.prototype=new X;K.constructor=k,H(K,P.prototype),K.isPureReactComponent=!0;var ee=Array.isArray;function te(){}var F={H:null,A:null,T:null,S:null},he=Object.prototype.hasOwnProperty;function W(M,z,J){var Z=J.ref;return{$$typeof:i,type:M,key:z,ref:Z!==void 0?Z:null,props:J}}function de(M,z){return W(M.type,z,M.props)}function Ce(M){return typeof M=="object"&&M!==null&&M.$$typeof===i}function Ge(M){var z={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(J){return z[J]})}var Ee=/\/+/g;function Pe(M,z){return typeof M=="object"&&M!==null&&M.key!=null?Ge(""+M.key):z.toString(36)}function rt(M){switch(M.status){case"fulfilled":return M.value;case"rejected":throw M.reason;default:switch(typeof M.status=="string"?M.then(te,te):(M.status="pending",M.then(function(z){M.status==="pending"&&(M.status="fulfilled",M.value=z)},function(z){M.status==="pending"&&(M.status="rejected",M.reason=z)})),M.status){case"fulfilled":return M.value;case"rejected":throw M.reason}}throw M}function L(M,z,J,Z,ae){var ue=typeof M;(ue==="undefined"||ue==="boolean")&&(M=null);var _e=!1;if(M===null)_e=!0;else switch(ue){case"bigint":case"string":case"number":_e=!0;break;case"object":switch(M.$$typeof){case i:case t:_e=!0;break;case v:return _e=M._init,L(_e(M._payload),z,J,Z,ae)}}if(_e)return ae=ae(M),_e=Z===""?"."+Pe(M,0):Z,ee(ae)?(J="",_e!=null&&(J=_e.replace(Ee,"$&/")+"/"),L(ae,z,J,"",function(io){return io})):ae!=null&&(Ce(ae)&&(ae=de(ae,J+(ae.key==null||M&&M.key===ae.key?"":(""+ae.key).replace(Ee,"$&/")+"/")+_e)),z.push(ae)),1;_e=0;var ot=Z===""?".":Z+":";if(ee(M))for(var Ve=0;Ve>>1,De=L[Me];if(0>>1;Mer(J,ie))Zr(ae,J)?(L[Me]=ae,L[Z]=ie,Me=Z):(L[Me]=J,L[z]=ie,Me=z);else if(Zr(ae,ie))L[Me]=ae,L[Z]=ie,Me=Z;else break e}}return O}function r(L,O){var ie=L.sortIndex-O.sortIndex;return ie!==0?ie:L.id-O.id}if(i.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var f=performance;i.unstable_now=function(){return f.now()}}else{var m=Date,g=m.now();i.unstable_now=function(){return m.now()-g}}var y=[],h=[],v=1,S=null,E=3,C=!1,U=!1,H=!1,b=!1,P=typeof setTimeout=="function"?setTimeout:null,X=typeof clearTimeout=="function"?clearTimeout:null,k=typeof setImmediate<"u"?setImmediate:null;function K(L){for(var O=l(h);O!==null;){if(O.callback===null)a(h);else if(O.startTime<=L)a(h),O.sortIndex=O.expirationTime,t(y,O);else break;O=l(h)}}function ee(L){if(H=!1,K(L),!U)if(l(y)!==null)U=!0,te||(te=!0,Ge());else{var O=l(h);O!==null&&rt(ee,O.startTime-L)}}var te=!1,F=-1,he=5,W=-1;function de(){return b?!0:!(i.unstable_now()-WL&&de());){var Me=S.callback;if(typeof Me=="function"){S.callback=null,E=S.priorityLevel;var De=Me(S.expirationTime<=L);if(L=i.unstable_now(),typeof De=="function"){S.callback=De,K(L),O=!0;break t}S===l(y)&&a(y),K(L)}else a(y);S=l(y)}if(S!==null)O=!0;else{var M=l(h);M!==null&&rt(ee,M.startTime-L),O=!1}}break e}finally{S=null,E=ie,C=!1}O=void 0}}finally{O?Ge():te=!1}}}var Ge;if(typeof k=="function")Ge=function(){k(Ce)};else if(typeof MessageChannel<"u"){var Ee=new MessageChannel,Pe=Ee.port2;Ee.port1.onmessage=Ce,Ge=function(){Pe.postMessage(null)}}else Ge=function(){P(Ce,0)};function rt(L,O){F=P(function(){L(i.unstable_now())},O)}i.unstable_IdlePriority=5,i.unstable_ImmediatePriority=1,i.unstable_LowPriority=4,i.unstable_NormalPriority=3,i.unstable_Profiling=null,i.unstable_UserBlockingPriority=2,i.unstable_cancelCallback=function(L){L.callback=null},i.unstable_forceFrameRate=function(L){0>L||125Me?(L.sortIndex=ie,t(h,L),l(y)===null&&L===l(h)&&(H?(X(F),F=-1):H=!0,rt(ee,ie-Me))):(L.sortIndex=De,t(y,L),U||C||(U=!0,te||(te=!0,Ge()))),L},i.unstable_shouldYield=de,i.unstable_wrapCallback=function(L){var O=E;return function(){var ie=E;E=O;try{return L.apply(this,arguments)}finally{E=ie}}}})(uu)),uu}var Kp;function l0(){return Kp||(Kp=1,ru.exports=o0()),ru.exports}var cu={exports:{}},tt={};/** * @license React * react-dom.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var Qp;function a0(){if(Qp)return tt;Qp=1;var i=Du();function t(y){var h="https://react.dev/errors/"+y;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(t){console.error(t)}}return i(),cu.exports=a0(),cu.exports}/** * @license React * react-dom-client.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var $p;function r0(){if($p)return Wo;$p=1;var i=l0(),t=Du(),l=s0();function a(e){var n="https://react.dev/errors/"+e;if(1De||(e.current=Me[De],Me[De]=null,De--)}function J(e,n){De++,Me[De]=e.current,e.current=n}var Z=M(null),ae=M(null),ue=M(null),_e=M(null);function ot(e,n){switch(J(ue,n),J(ae,e),J(Z,null),n.nodeType){case 9:case 11:e=(e=n.documentElement)&&(e=e.namespaceURI)?dp(e):0;break;default:if(e=n.tagName,n=n.namespaceURI)n=dp(n),e=pp(n,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}z(Z),J(Z,e)}function Ve(){z(Z),z(ae),z(ue)}function io(e){e.memoizedState!==null&&J(_e,e);var n=Z.current,o=pp(n,e.type);n!==o&&(J(ae,e),J(Z,o))}function nl(e){ae.current===e&&(z(Z),z(ae)),_e.current===e&&(z(_e),Xo._currentValue=ie)}var Pa,Pu;function Fn(e){if(Pa===void 0)try{throw Error()}catch(o){var n=o.stack.trim().match(/\n( *(at )?)/);Pa=n&&n[1]||"",Pu=-1)":-1d||A[s]!==x[d]){var G=` `+A[s].replace(" at new "," at ");return e.displayName&&G.includes("")&&(G=G.replace("",e.displayName)),G}while(1<=s&&0<=d);break}}}finally{ka=!1,Error.prepareStackTrace=o}return(o=e?e.displayName||e.name:"")?Fn(o):""}function Ug(e,n){switch(e.tag){case 26:case 27:case 5:return Fn(e.type);case 16:return Fn("Lazy");case 13:return e.child!==n&&n!==null?Fn("Suspense Fallback"):Fn("Suspense");case 19:return Fn("SuspenseList");case 0:case 15:return Oa(e.type,!1);case 11:return Oa(e.type.render,!1);case 1:return Oa(e.type,!0);case 31:return Fn("Activity");default:return""}}function ku(e){try{var n="",o=null;do n+=Ug(e,o),o=e,e=e.return;while(e);return n}catch(s){return` Error generating stack: `+s.message+` `+s.stack}}var Fa=Object.prototype.hasOwnProperty,Ja=i.unstable_scheduleCallback,Ya=i.unstable_cancelCallback,wg=i.unstable_shouldYield,bg=i.unstable_requestPaint,gt=i.unstable_now,Lg=i.unstable_getCurrentPriorityLevel,Ou=i.unstable_ImmediatePriority,Fu=i.unstable_UserBlockingPriority,il=i.unstable_NormalPriority,Gg=i.unstable_LowPriority,Ju=i.unstable_IdlePriority,Hg=i.log,qg=i.unstable_setDisableYieldValue,oo=null,yt=null;function yn(e){if(typeof Hg=="function"&&qg(e),yt&&typeof yt.setStrictMode=="function")try{yt.setStrictMode(oo,e)}catch{}}var vt=Math.clz32?Math.clz32:Bg,Vg=Math.log,zg=Math.LN2;function Bg(e){return e>>>=0,e===0?32:31-(Vg(e)/zg|0)|0}var ol=256,ll=262144,al=4194304;function Jn(e){var n=e&42;if(n!==0)return n;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function sl(e,n,o){var s=e.pendingLanes;if(s===0)return 0;var d=0,p=e.suspendedLanes,T=e.pingedLanes;e=e.warmLanes;var _=s&134217727;return _!==0?(s=_&~p,s!==0?d=Jn(s):(T&=_,T!==0?d=Jn(T):o||(o=_&~e,o!==0&&(d=Jn(o))))):(_=s&~p,_!==0?d=Jn(_):T!==0?d=Jn(T):o||(o=s&~e,o!==0&&(d=Jn(o)))),d===0?0:n!==0&&n!==d&&(n&p)===0&&(p=d&-d,o=n&-n,p>=o||p===32&&(o&4194048)!==0)?n:d}function lo(e,n){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&n)===0}function Pg(e,n){switch(e){case 1:case 2:case 4:case 8:case 64:return n+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Yu(){var e=al;return al<<=1,(al&62914560)===0&&(al=4194304),e}function Xa(e){for(var n=[],o=0;31>o;o++)n.push(e);return n}function ao(e,n){e.pendingLanes|=n,n!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function kg(e,n,o,s,d,p){var T=e.pendingLanes;e.pendingLanes=o,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=o,e.entangledLanes&=o,e.errorRecoveryDisabledLanes&=o,e.shellSuspendCounter=0;var _=e.entanglements,A=e.expirationTimes,x=e.hiddenUpdates;for(o=T&~o;0"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var Kg=/[\n"\\]/g;function Nt(e){return e.replace(Kg,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function ja(e,n,o,s,d,p,T,_){e.name="",T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"?e.type=T:e.removeAttribute("type"),n!=null?T==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+Mt(n)):e.value!==""+Mt(n)&&(e.value=""+Mt(n)):T!=="submit"&&T!=="reset"||e.removeAttribute("value"),n!=null?es(e,T,Mt(n)):o!=null?es(e,T,Mt(o)):s!=null&&e.removeAttribute("value"),d==null&&p!=null&&(e.defaultChecked=!!p),d!=null&&(e.checked=d&&typeof d!="function"&&typeof d!="symbol"),_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"?e.name=""+Mt(_):e.removeAttribute("name")}function lc(e,n,o,s,d,p,T,_){if(p!=null&&typeof p!="function"&&typeof p!="symbol"&&typeof p!="boolean"&&(e.type=p),n!=null||o!=null){if(!(p!=="submit"&&p!=="reset"||n!=null)){Wa(e);return}o=o!=null?""+Mt(o):"",n=n!=null?""+Mt(n):o,_||n===e.value||(e.value=n),e.defaultValue=n}s=s??d,s=typeof s!="function"&&typeof s!="symbol"&&!!s,e.checked=_?e.checked:!!s,e.defaultChecked=!!s,T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"&&(e.name=T),Wa(e)}function es(e,n,o){n==="number"&&cl(e.ownerDocument)===e||e.defaultValue===""+o||(e.defaultValue=""+o)}function gi(e,n,o,s){if(e=e.options,n){n={};for(var d=0;d"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),ls=!1;if($t)try{var co={};Object.defineProperty(co,"passive",{get:function(){ls=!0}}),window.addEventListener("test",co,co),window.removeEventListener("test",co,co)}catch{ls=!1}var Tn=null,as=null,dl=null;function dc(){if(dl)return dl;var e,n=as,o=n.length,s,d="value"in Tn?Tn.value:Tn.textContent,p=d.length;for(e=0;e=mo),vc=" ",Tc=!1;function Sc(e,n){switch(e){case"keyup":return _y.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ec(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Si=!1;function Ay(e,n){switch(e){case"compositionend":return Ec(n);case"keypress":return n.which!==32?null:(Tc=!0,vc);case"textInput":return e=n.data,e===vc&&Tc?null:e;default:return null}}function Ry(e,n){if(Si)return e==="compositionend"||!fs&&Sc(e,n)?(e=dc(),dl=as=Tn=null,Si=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1=n)return{node:o,offset:n-e};e=s}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=xc(o)}}function Uc(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Uc(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function wc(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var n=cl(e.document);n instanceof e.HTMLIFrameElement;){try{var o=typeof n.contentWindow.location.href=="string"}catch{o=!1}if(o)e=n.contentWindow;else break;n=cl(e.document)}return n}function ms(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}var by=$t&&"documentMode"in document&&11>=document.documentMode,Ei=null,hs=null,vo=null,gs=!1;function bc(e,n,o){var s=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;gs||Ei==null||Ei!==cl(s)||(s=Ei,"selectionStart"in s&&ms(s)?s={start:s.selectionStart,end:s.selectionEnd}:(s=(s.ownerDocument&&s.ownerDocument.defaultView||window).getSelection(),s={anchorNode:s.anchorNode,anchorOffset:s.anchorOffset,focusNode:s.focusNode,focusOffset:s.focusOffset}),vo&&yo(vo,s)||(vo=s,s=la(hs,"onSelect"),0>=T,d-=T,Ft=1<<32-vt(n)+d|o<re?(me=$,$=null):me=$.sibling;var ve=D(N,$,I[re],q);if(ve===null){$===null&&($=me);break}e&&$&&ve.alternate===null&&n(N,$),R=p(ve,R,re),ye===null?j=ve:ye.sibling=ve,ye=ve,$=me}if(re===I.length)return o(N,$),ge&&jt(N,re),j;if($===null){for(;rere?(me=$,$=null):me=$.sibling;var Pn=D(N,$,ve.value,q);if(Pn===null){$===null&&($=me);break}e&&$&&Pn.alternate===null&&n(N,$),R=p(Pn,R,re),ye===null?j=Pn:ye.sibling=Pn,ye=Pn,$=me}if(ve.done)return o(N,$),ge&&jt(N,re),j;if($===null){for(;!ve.done;re++,ve=I.next())ve=V(N,ve.value,q),ve!==null&&(R=p(ve,R,re),ye===null?j=ve:ye.sibling=ve,ye=ve);return ge&&jt(N,re),j}for($=s($);!ve.done;re++,ve=I.next())ve=w($,N,re,ve.value,q),ve!==null&&(e&&ve.alternate!==null&&$.delete(ve.key===null?re:ve.key),R=p(ve,R,re),ye===null?j=ve:ye.sibling=ve,ye=ve);return e&&$.forEach(function(jv){return n(N,jv)}),ge&&jt(N,re),j}function xe(N,R,I,q){if(typeof I=="object"&&I!==null&&I.type===H&&I.key===null&&(I=I.props.children),typeof I=="object"&&I!==null){switch(I.$$typeof){case C:e:{for(var j=I.key;R!==null;){if(R.key===j){if(j=I.type,j===H){if(R.tag===7){o(N,R.sibling),q=d(R,I.props.children),q.return=N,N=q;break e}}else if(R.elementType===j||typeof j=="object"&&j!==null&&j.$$typeof===he&&ni(j)===R.type){o(N,R.sibling),q=d(R,I.props),Ao(q,I),q.return=N,N=q;break e}o(N,R);break}else n(N,R);R=R.sibling}I.type===H?(q=$n(I.props.children,N.mode,q,I.key),q.return=N,N=q):(q=_l(I.type,I.key,I.props,null,N.mode,q),Ao(q,I),q.return=N,N=q)}return T(N);case U:e:{for(j=I.key;R!==null;){if(R.key===j)if(R.tag===4&&R.stateNode.containerInfo===I.containerInfo&&R.stateNode.implementation===I.implementation){o(N,R.sibling),q=d(R,I.children||[]),q.return=N,N=q;break e}else{o(N,R);break}else n(N,R);R=R.sibling}q=Cs(I,N.mode,q),q.return=N,N=q}return T(N);case he:return I=ni(I),xe(N,R,I,q)}if(rt(I))return Q(N,R,I,q);if(Ge(I)){if(j=Ge(I),typeof j!="function")throw Error(a(150));return I=j.call(I),ne(N,R,I,q)}if(typeof I.then=="function")return xe(N,R,xl(I),q);if(I.$$typeof===k)return xe(N,R,Rl(N,I),q);Dl(N,I)}return typeof I=="string"&&I!==""||typeof I=="number"||typeof I=="bigint"?(I=""+I,R!==null&&R.tag===6?(o(N,R.sibling),q=d(R,I),q.return=N,N=q):(o(N,R),q=_s(I,N.mode,q),q.return=N,N=q),T(N)):o(N,R)}return function(N,R,I,q){try{Co=0;var j=xe(N,R,I,q);return wi=null,j}catch($){if($===Ui||$===Nl)throw $;var ye=St(29,$,null,N.mode);return ye.lanes=q,ye.return=N,ye}finally{}}}var oi=nf(!0),of=nf(!1),An=!1;function Gs(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Hs(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Rn(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Mn(e,n,o){var s=e.updateQueue;if(s===null)return null;if(s=s.shared,(Se&2)!==0){var d=s.pending;return d===null?n.next=n:(n.next=d.next,d.next=n),s.pending=n,n=El(e),Bc(e,null,o),n}return Sl(e,s,n,o),El(e)}function Ro(e,n,o){if(n=n.updateQueue,n!==null&&(n=n.shared,(o&4194048)!==0)){var s=n.lanes;s&=e.pendingLanes,o|=s,n.lanes=o,Ku(e,o)}}function qs(e,n){var o=e.updateQueue,s=e.alternate;if(s!==null&&(s=s.updateQueue,o===s)){var d=null,p=null;if(o=o.firstBaseUpdate,o!==null){do{var T={lane:o.lane,tag:o.tag,payload:o.payload,callback:null,next:null};p===null?d=p=T:p=p.next=T,o=o.next}while(o!==null);p===null?d=p=n:p=p.next=n}else d=p=n;o={baseState:s.baseState,firstBaseUpdate:d,lastBaseUpdate:p,shared:s.shared,callbacks:s.callbacks},e.updateQueue=o;return}e=o.lastBaseUpdate,e===null?o.firstBaseUpdate=n:e.next=n,o.lastBaseUpdate=n}var Vs=!1;function Mo(){if(Vs){var e=Di;if(e!==null)throw e}}function No(e,n,o,s){Vs=!1;var d=e.updateQueue;An=!1;var p=d.firstBaseUpdate,T=d.lastBaseUpdate,_=d.shared.pending;if(_!==null){d.shared.pending=null;var A=_,x=A.next;A.next=null,T===null?p=x:T.next=x,T=A;var G=e.alternate;G!==null&&(G=G.updateQueue,_=G.lastBaseUpdate,_!==T&&(_===null?G.firstBaseUpdate=x:_.next=x,G.lastBaseUpdate=A))}if(p!==null){var V=d.baseState;T=0,G=x=A=null,_=p;do{var D=_.lane&-536870913,w=D!==_.lane;if(w?(pe&D)===D:(s&D)===D){D!==0&&D===xi&&(Vs=!0),G!==null&&(G=G.next={lane:0,tag:_.tag,payload:_.payload,callback:null,next:null});e:{var Q=e,ne=_;D=n;var xe=o;switch(ne.tag){case 1:if(Q=ne.payload,typeof Q=="function"){V=Q.call(xe,V,D);break e}V=Q;break e;case 3:Q.flags=Q.flags&-65537|128;case 0:if(Q=ne.payload,D=typeof Q=="function"?Q.call(xe,V,D):Q,D==null)break e;V=S({},V,D);break e;case 2:An=!0}}D=_.callback,D!==null&&(e.flags|=64,w&&(e.flags|=8192),w=d.callbacks,w===null?d.callbacks=[D]:w.push(D))}else w={lane:D,tag:_.tag,payload:_.payload,callback:_.callback,next:null},G===null?(x=G=w,A=V):G=G.next=w,T|=D;if(_=_.next,_===null){if(_=d.shared.pending,_===null)break;w=_,_=w.next,w.next=null,d.lastBaseUpdate=w,d.shared.pending=null}}while(!0);G===null&&(A=V),d.baseState=A,d.firstBaseUpdate=x,d.lastBaseUpdate=G,p===null&&(d.shared.lanes=0),Un|=T,e.lanes=T,e.memoizedState=V}}function lf(e,n){if(typeof e!="function")throw Error(a(191,e));e.call(n)}function af(e,n){var o=e.callbacks;if(o!==null)for(e.callbacks=null,e=0;ep?p:8;var T=L.T,_={};L.T=_,ir(e,!1,n,o);try{var A=d(),x=L.S;if(x!==null&&x(_,A),A!==null&&typeof A=="object"&&typeof A.then=="function"){var G=ky(A,s);Do(e,n,G,Rt(e))}else Do(e,n,s,Rt(e))}catch(V){Do(e,n,{then:function(){},status:"rejected",reason:V},Rt())}finally{O.p=p,T!==null&&_.types!==null&&(T.types=_.types),L.T=T}}function Ky(){}function tr(e,n,o,s){if(e.tag!==5)throw Error(a(476));var d=Vf(e).queue;qf(e,d,n,ie,o===null?Ky:function(){return zf(e),o(s)})}function Vf(e){var n=e.memoizedState;if(n!==null)return n;n={memoizedState:ie,baseState:ie,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:on,lastRenderedState:ie},next:null};var o={};return n.next={memoizedState:o,baseState:o,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:on,lastRenderedState:o},next:null},e.memoizedState=n,e=e.alternate,e!==null&&(e.memoizedState=n),n}function zf(e){var n=Vf(e);n.next===null&&(n=e.alternate.memoizedState),Do(e,n.next.queue,{},Rt())}function nr(){return We(Xo)}function Bf(){return Be().memoizedState}function Pf(){return Be().memoizedState}function Qy(e){for(var n=e.return;n!==null;){switch(n.tag){case 24:case 3:var o=Rt();e=Rn(o);var s=Mn(n,e,o);s!==null&&(ht(s,n,o),Ro(s,n,o)),n={cache:Us()},e.payload=n;return}n=n.return}}function Zy(e,n,o){var s=Rt();o={lane:s,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Bl(e)?Of(n,o):(o=Ss(e,n,o,s),o!==null&&(ht(o,e,s),Ff(o,n,s)))}function kf(e,n,o){var s=Rt();Do(e,n,o,s)}function Do(e,n,o,s){var d={lane:s,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null};if(Bl(e))Of(n,d);else{var p=e.alternate;if(e.lanes===0&&(p===null||p.lanes===0)&&(p=n.lastRenderedReducer,p!==null))try{var T=n.lastRenderedState,_=p(T,o);if(d.hasEagerState=!0,d.eagerState=_,Tt(_,T))return Sl(e,n,d,0),Ue===null&&Tl(),!1}catch{}finally{}if(o=Ss(e,n,d,s),o!==null)return ht(o,e,s),Ff(o,n,s),!0}return!1}function ir(e,n,o,s){if(s={lane:2,revertLane:Gr(),gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null},Bl(e)){if(n)throw Error(a(479))}else n=Ss(e,o,s,2),n!==null&&ht(n,e,2)}function Bl(e){var n=e.alternate;return e===se||n!==null&&n===se}function Of(e,n){Li=bl=!0;var o=e.pending;o===null?n.next=n:(n.next=o.next,o.next=n),e.pending=n}function Ff(e,n,o){if((o&4194048)!==0){var s=n.lanes;s&=e.pendingLanes,o|=s,n.lanes=o,Ku(e,o)}}var Uo={readContext:We,use:Hl,useCallback:He,useContext:He,useEffect:He,useImperativeHandle:He,useLayoutEffect:He,useInsertionEffect:He,useMemo:He,useReducer:He,useRef:He,useState:He,useDebugValue:He,useDeferredValue:He,useTransition:He,useSyncExternalStore:He,useId:He,useHostTransitionStatus:He,useFormState:He,useActionState:He,useOptimistic:He,useMemoCache:He,useCacheRefresh:He};Uo.useEffectEvent=He;var Jf={readContext:We,use:Hl,useCallback:function(e,n){return lt().memoizedState=[e,n===void 0?null:n],e},useContext:We,useEffect:If,useImperativeHandle:function(e,n,o){o=o!=null?o.concat([e]):null,Vl(4194308,4,wf.bind(null,n,e),o)},useLayoutEffect:function(e,n){return Vl(4194308,4,e,n)},useInsertionEffect:function(e,n){Vl(4,2,e,n)},useMemo:function(e,n){var o=lt();n=n===void 0?null:n;var s=e();if(li){yn(!0);try{e()}finally{yn(!1)}}return o.memoizedState=[s,n],s},useReducer:function(e,n,o){var s=lt();if(o!==void 0){var d=o(n);if(li){yn(!0);try{o(n)}finally{yn(!1)}}}else d=n;return s.memoizedState=s.baseState=d,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:d},s.queue=e,e=e.dispatch=Zy.bind(null,se,e),[s.memoizedState,e]},useRef:function(e){var n=lt();return e={current:e},n.memoizedState=e},useState:function(e){e=Zs(e);var n=e.queue,o=kf.bind(null,se,n);return n.dispatch=o,[e.memoizedState,o]},useDebugValue:js,useDeferredValue:function(e,n){var o=lt();return er(o,e,n)},useTransition:function(){var e=Zs(!1);return e=qf.bind(null,se,e.queue,!0,!1),lt().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,n,o){var s=se,d=lt();if(ge){if(o===void 0)throw Error(a(407));o=o()}else{if(o=n(),Ue===null)throw Error(a(349));(pe&127)!==0||df(s,n,o)}d.memoizedState=o;var p={value:o,getSnapshot:n};return d.queue=p,If(mf.bind(null,s,p,e),[e]),s.flags|=2048,Hi(9,{destroy:void 0},pf.bind(null,s,p,o,n),null),o},useId:function(){var e=lt(),n=Ue.identifierPrefix;if(ge){var o=Jt,s=Ft;o=(s&~(1<<32-vt(s)-1)).toString(32)+o,n="_"+n+"R_"+o,o=Ll++,0<\/script>",p=p.removeChild(p.firstChild);break;case"select":p=typeof s.is=="string"?T.createElement("select",{is:s.is}):T.createElement("select"),s.multiple?p.multiple=!0:s.size&&(p.size=s.size);break;default:p=typeof s.is=="string"?T.createElement(d,{is:s.is}):T.createElement(d)}}p[Ze]=n,p[ut]=s;e:for(T=n.child;T!==null;){if(T.tag===5||T.tag===6)p.appendChild(T.stateNode);else if(T.tag!==4&&T.tag!==27&&T.child!==null){T.child.return=T,T=T.child;continue}if(T===n)break e;for(;T.sibling===null;){if(T.return===null||T.return===n)break e;T=T.return}T.sibling.return=T.return,T=T.sibling}n.stateNode=p;e:switch(et(p,d,s),d){case"button":case"input":case"select":case"textarea":s=!!s.autoFocus;break e;case"img":s=!0;break e;default:s=!1}s&&an(n)}}return be(n),yr(n,n.type,e===null?null:e.memoizedProps,n.pendingProps,o),null;case 6:if(e&&n.stateNode!=null)e.memoizedProps!==s&&an(n);else{if(typeof s!="string"&&n.stateNode===null)throw Error(a(166));if(e=ue.current,Ni(n)){if(e=n.stateNode,o=n.memoizedProps,s=null,d=$e,d!==null)switch(d.tag){case 27:case 5:s=d.memoizedProps}e[Ze]=n,e=!!(e.nodeValue===o||s!==null&&s.suppressHydrationWarning===!0||cp(e.nodeValue,o)),e||_n(n,!0)}else e=aa(e).createTextNode(s),e[Ze]=n,n.stateNode=e}return be(n),null;case 31:if(o=n.memoizedState,e===null||e.memoizedState!==null){if(s=Ni(n),o!==null){if(e===null){if(!s)throw Error(a(318));if(e=n.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(a(557));e[Ze]=n}else Wn(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;be(n),e=!1}else o=Ns(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=o),e=!0;if(!e)return n.flags&256?(_t(n),n):(_t(n),null);if((n.flags&128)!==0)throw Error(a(558))}return be(n),null;case 13:if(s=n.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(d=Ni(n),s!==null&&s.dehydrated!==null){if(e===null){if(!d)throw Error(a(318));if(d=n.memoizedState,d=d!==null?d.dehydrated:null,!d)throw Error(a(317));d[Ze]=n}else Wn(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;be(n),d=!1}else d=Ns(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=d),d=!0;if(!d)return n.flags&256?(_t(n),n):(_t(n),null)}return _t(n),(n.flags&128)!==0?(n.lanes=o,n):(o=s!==null,e=e!==null&&e.memoizedState!==null,o&&(s=n.child,d=null,s.alternate!==null&&s.alternate.memoizedState!==null&&s.alternate.memoizedState.cachePool!==null&&(d=s.alternate.memoizedState.cachePool.pool),p=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(p=s.memoizedState.cachePool.pool),p!==d&&(s.flags|=2048)),o!==e&&o&&(n.child.flags|=8192),Jl(n,n.updateQueue),be(n),null);case 4:return Ve(),e===null&&zr(n.stateNode.containerInfo),be(n),null;case 10:return tn(n.type),be(n),null;case 19:if(z(ze),s=n.memoizedState,s===null)return be(n),null;if(d=(n.flags&128)!==0,p=s.rendering,p===null)if(d)bo(s,!1);else{if(qe!==0||e!==null&&(e.flags&128)!==0)for(e=n.child;e!==null;){if(p=wl(e),p!==null){for(n.flags|=128,bo(s,!1),e=p.updateQueue,n.updateQueue=e,Jl(n,e),n.subtreeFlags=0,e=o,o=n.child;o!==null;)Pc(o,e),o=o.sibling;return J(ze,ze.current&1|2),ge&&jt(n,s.treeForkCount),n.child}e=e.sibling}s.tail!==null&>()>Zl&&(n.flags|=128,d=!0,bo(s,!1),n.lanes=4194304)}else{if(!d)if(e=wl(p),e!==null){if(n.flags|=128,d=!0,e=e.updateQueue,n.updateQueue=e,Jl(n,e),bo(s,!0),s.tail===null&&s.tailMode==="hidden"&&!p.alternate&&!ge)return be(n),null}else 2*gt()-s.renderingStartTime>Zl&&o!==536870912&&(n.flags|=128,d=!0,bo(s,!1),n.lanes=4194304);s.isBackwards?(p.sibling=n.child,n.child=p):(e=s.last,e!==null?e.sibling=p:n.child=p,s.last=p)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=gt(),e.sibling=null,o=ze.current,J(ze,d?o&1|2:o&1),ge&&jt(n,s.treeForkCount),e):(be(n),null);case 22:case 23:return _t(n),Bs(),s=n.memoizedState!==null,e!==null?e.memoizedState!==null!==s&&(n.flags|=8192):s&&(n.flags|=8192),s?(o&536870912)!==0&&(n.flags&128)===0&&(be(n),n.subtreeFlags&6&&(n.flags|=8192)):be(n),o=n.updateQueue,o!==null&&Jl(n,o.retryQueue),o=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(o=e.memoizedState.cachePool.pool),s=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(s=n.memoizedState.cachePool.pool),s!==o&&(n.flags|=2048),e!==null&&z(ti),null;case 24:return o=null,e!==null&&(o=e.memoizedState.cache),n.memoizedState.cache!==o&&(n.flags|=2048),tn(ke),be(n),null;case 25:return null;case 30:return null}throw Error(a(156,n.tag))}function tv(e,n){switch(Rs(n),n.tag){case 1:return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return tn(ke),Ve(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 26:case 27:case 5:return nl(n),null;case 31:if(n.memoizedState!==null){if(_t(n),n.alternate===null)throw Error(a(340));Wn()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 13:if(_t(n),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(a(340));Wn()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return z(ze),null;case 4:return Ve(),null;case 10:return tn(n.type),null;case 22:case 23:return _t(n),Bs(),e!==null&&z(ti),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 24:return tn(ke),null;case 25:return null;default:return null}}function hd(e,n){switch(Rs(n),n.tag){case 3:tn(ke),Ve();break;case 26:case 27:case 5:nl(n);break;case 4:Ve();break;case 31:n.memoizedState!==null&&_t(n);break;case 13:_t(n);break;case 19:z(ze);break;case 10:tn(n.type);break;case 22:case 23:_t(n),Bs(),e!==null&&z(ti);break;case 24:tn(ke)}}function Lo(e,n){try{var o=n.updateQueue,s=o!==null?o.lastEffect:null;if(s!==null){var d=s.next;o=d;do{if((o.tag&e)===e){s=void 0;var p=o.create,T=o.inst;s=p(),T.destroy=s}o=o.next}while(o!==d)}}catch(_){Re(n,n.return,_)}}function xn(e,n,o){try{var s=n.updateQueue,d=s!==null?s.lastEffect:null;if(d!==null){var p=d.next;s=p;do{if((s.tag&e)===e){var T=s.inst,_=T.destroy;if(_!==void 0){T.destroy=void 0,d=n;var A=o,x=_;try{x()}catch(G){Re(d,A,G)}}}s=s.next}while(s!==p)}}catch(G){Re(n,n.return,G)}}function gd(e){var n=e.updateQueue;if(n!==null){var o=e.stateNode;try{af(n,o)}catch(s){Re(e,e.return,s)}}}function yd(e,n,o){o.props=ai(e.type,e.memoizedProps),o.state=e.memoizedState;try{o.componentWillUnmount()}catch(s){Re(e,n,s)}}function Go(e,n){try{var o=e.ref;if(o!==null){switch(e.tag){case 26:case 27:case 5:var s=e.stateNode;break;case 30:s=e.stateNode;break;default:s=e.stateNode}typeof o=="function"?e.refCleanup=o(s):o.current=s}}catch(d){Re(e,n,d)}}function Yt(e,n){var o=e.ref,s=e.refCleanup;if(o!==null)if(typeof s=="function")try{s()}catch(d){Re(e,n,d)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof o=="function")try{o(null)}catch(d){Re(e,n,d)}else o.current=null}function vd(e){var n=e.type,o=e.memoizedProps,s=e.stateNode;try{e:switch(n){case"button":case"input":case"select":case"textarea":o.autoFocus&&s.focus();break e;case"img":o.src?s.src=o.src:o.srcSet&&(s.srcset=o.srcSet)}}catch(d){Re(e,e.return,d)}}function vr(e,n,o){try{var s=e.stateNode;Cv(s,e.type,o,n),s[ut]=n}catch(d){Re(e,e.return,d)}}function Td(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Hn(e.type)||e.tag===4}function Tr(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Td(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Hn(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Sr(e,n,o){var s=e.tag;if(s===5||s===6)e=e.stateNode,n?(o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o).insertBefore(e,n):(n=o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o,n.appendChild(e),o=o._reactRootContainer,o!=null||n.onclick!==null||(n.onclick=Zt));else if(s!==4&&(s===27&&Hn(e.type)&&(o=e.stateNode,n=null),e=e.child,e!==null))for(Sr(e,n,o),e=e.sibling;e!==null;)Sr(e,n,o),e=e.sibling}function Yl(e,n,o){var s=e.tag;if(s===5||s===6)e=e.stateNode,n?o.insertBefore(e,n):o.appendChild(e);else if(s!==4&&(s===27&&Hn(e.type)&&(o=e.stateNode),e=e.child,e!==null))for(Yl(e,n,o),e=e.sibling;e!==null;)Yl(e,n,o),e=e.sibling}function Sd(e){var n=e.stateNode,o=e.memoizedProps;try{for(var s=e.type,d=n.attributes;d.length;)n.removeAttributeNode(d[0]);et(n,s,o),n[Ze]=e,n[ut]=o}catch(p){Re(e,e.return,p)}}var sn=!1,Je=!1,Er=!1,Ed=typeof WeakSet=="function"?WeakSet:Set,Ke=null;function nv(e,n){if(e=e.containerInfo,kr=pa,e=wc(e),ms(e)){if("selectionStart"in e)var o={start:e.selectionStart,end:e.selectionEnd};else e:{o=(o=e.ownerDocument)&&o.defaultView||window;var s=o.getSelection&&o.getSelection();if(s&&s.rangeCount!==0){o=s.anchorNode;var d=s.anchorOffset,p=s.focusNode;s=s.focusOffset;try{o.nodeType,p.nodeType}catch{o=null;break e}var T=0,_=-1,A=-1,x=0,G=0,V=e,D=null;t:for(;;){for(var w;V!==o||d!==0&&V.nodeType!==3||(_=T+d),V!==p||s!==0&&V.nodeType!==3||(A=T+s),V.nodeType===3&&(T+=V.nodeValue.length),(w=V.firstChild)!==null;)D=V,V=w;for(;;){if(V===e)break t;if(D===o&&++x===d&&(_=T),D===p&&++G===s&&(A=T),(w=V.nextSibling)!==null)break;V=D,D=V.parentNode}V=w}o=_===-1||A===-1?null:{start:_,end:A}}else o=null}o=o||{start:0,end:0}}else o=null;for(Or={focusedElem:e,selectionRange:o},pa=!1,Ke=n;Ke!==null;)if(n=Ke,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,Ke=e;else for(;Ke!==null;){switch(n=Ke,p=n.alternate,e=n.flags,n.tag){case 0:if((e&4)!==0&&(e=n.updateQueue,e=e!==null?e.events:null,e!==null))for(o=0;o title"))),et(p,s,o),p[Ze]=e,Xe(p),s=p;break e;case"link":var T=Np("link","href",d).get(s+(o.href||""));if(T){for(var _=0;_xe&&(T=xe,xe=ne,ne=T);var N=Dc(_,ne),R=Dc(_,xe);if(N&&R&&(w.rangeCount!==1||w.anchorNode!==N.node||w.anchorOffset!==N.offset||w.focusNode!==R.node||w.focusOffset!==R.offset)){var I=V.createRange();I.setStart(N.node,N.offset),w.removeAllRanges(),ne>xe?(w.addRange(I),w.extend(R.node,R.offset)):(I.setEnd(R.node,R.offset),w.addRange(I))}}}}for(V=[],w=_;w=w.parentNode;)w.nodeType===1&&V.push({element:w,left:w.scrollLeft,top:w.scrollTop});for(typeof _.focus=="function"&&_.focus(),_=0;_o?32:o,L.T=null,o=Ir,Ir=null;var p=bn,T=dn;if(Ye=0,Pi=bn=null,dn=0,(Se&6)!==0)throw Error(a(331));var _=Se;if(Se|=4,wd(p.current),xd(p,p.current,T,o),Se=_,Po(0,!1),yt&&typeof yt.onPostCommitFiberRoot=="function")try{yt.onPostCommitFiberRoot(oo,p)}catch{}return!0}finally{O.p=d,L.T=s,Zd(e,n)}}function Wd(e,n,o){n=xt(o,n),n=sr(e.stateNode,n,2),e=Mn(e,n,2),e!==null&&(ao(e,2),Xt(e))}function Re(e,n,o){if(e.tag===3)Wd(e,e,o);else for(;n!==null;){if(n.tag===3){Wd(n,e,o);break}else if(n.tag===1){var s=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof s.componentDidCatch=="function"&&(wn===null||!wn.has(s))){e=xt(o,e),o=jf(2),s=Mn(n,o,2),s!==null&&(ed(o,s,n,e),ao(s,2),Xt(s));break}}n=n.return}}function wr(e,n,o){var s=e.pingCache;if(s===null){s=e.pingCache=new lv;var d=new Set;s.set(n,d)}else d=s.get(n),d===void 0&&(d=new Set,s.set(n,d));d.has(o)||(Ar=!0,d.add(o),e=cv.bind(null,e,n,o),n.then(e,e))}function cv(e,n,o){var s=e.pingCache;s!==null&&s.delete(n),e.pingedLanes|=e.suspendedLanes&o,e.warmLanes&=~o,Ue===e&&(pe&o)===o&&(qe===4||qe===3&&(pe&62914560)===pe&&300>gt()-Ql?(Se&2)===0&&ki(e,0):Rr|=o,Bi===pe&&(Bi=0)),Xt(e)}function jd(e,n){n===0&&(n=Yu()),e=Zn(e,n),e!==null&&(ao(e,n),Xt(e))}function fv(e){var n=e.memoizedState,o=0;n!==null&&(o=n.retryLane),jd(e,o)}function dv(e,n){var o=0;switch(e.tag){case 31:case 13:var s=e.stateNode,d=e.memoizedState;d!==null&&(o=d.retryLane);break;case 19:s=e.stateNode;break;case 22:s=e.stateNode._retryCache;break;default:throw Error(a(314))}s!==null&&s.delete(n),jd(e,o)}function pv(e,n){return Ja(e,n)}var na=null,Fi=null,br=!1,ia=!1,Lr=!1,Gn=0;function Xt(e){e!==Fi&&e.next===null&&(Fi===null?na=Fi=e:Fi=Fi.next=e),ia=!0,br||(br=!0,hv())}function Po(e,n){if(!Lr&&ia){Lr=!0;do for(var o=!1,s=na;s!==null;){if(e!==0){var d=s.pendingLanes;if(d===0)var p=0;else{var T=s.suspendedLanes,_=s.pingedLanes;p=(1<<31-vt(42|e)+1)-1,p&=d&~(T&~_),p=p&201326741?p&201326741|1:p?p|2:0}p!==0&&(o=!0,ip(s,p))}else p=pe,p=sl(s,s===Ue?p:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),(p&3)===0||lo(s,p)||(o=!0,ip(s,p));s=s.next}while(o);Lr=!1}}function mv(){ep()}function ep(){ia=br=!1;var e=0;Gn!==0&&Rv()&&(e=Gn);for(var n=gt(),o=null,s=na;s!==null;){var d=s.next,p=tp(s,n);p===0?(s.next=null,o===null?na=d:o.next=d,d===null&&(Fi=o)):(o=s,(e!==0||(p&3)!==0)&&(ia=!0)),s=d}Ye!==0&&Ye!==5||Po(e),Gn!==0&&(Gn=0)}function tp(e,n){for(var o=e.suspendedLanes,s=e.pingedLanes,d=e.expirationTimes,p=e.pendingLanes&-62914561;0_)break;var G=A.transferSize,V=A.initiatorType;G&&fp(V)&&(A=A.responseEnd,T+=G*(A<_?1:(_-x)/(A-x)))}if(--s,n+=8*(p+T)/(d.duration/1e3),e++,10"u"?null:document;function Cp(e,n,o){var s=Ji;if(s&&typeof n=="string"&&n){var d=Nt(n);d='link[rel="'+e+'"][href="'+d+'"]',typeof o=="string"&&(d+='[crossorigin="'+o+'"]'),_p.has(d)||(_p.add(d),e={rel:e,crossOrigin:o,href:n},s.querySelector(d)===null&&(n=s.createElement("link"),et(n,"link",e),Xe(n),s.head.appendChild(n)))}}function Lv(e){pn.D(e),Cp("dns-prefetch",e,null)}function Gv(e,n){pn.C(e,n),Cp("preconnect",e,n)}function Hv(e,n,o){pn.L(e,n,o);var s=Ji;if(s&&e&&n){var d='link[rel="preload"][as="'+Nt(n)+'"]';n==="image"&&o&&o.imageSrcSet?(d+='[imagesrcset="'+Nt(o.imageSrcSet)+'"]',typeof o.imageSizes=="string"&&(d+='[imagesizes="'+Nt(o.imageSizes)+'"]')):d+='[href="'+Nt(e)+'"]';var p=d;switch(n){case"style":p=Yi(e);break;case"script":p=Xi(e)}Gt.has(p)||(e=S({rel:"preload",href:n==="image"&&o&&o.imageSrcSet?void 0:e,as:n},o),Gt.set(p,e),s.querySelector(d)!==null||n==="style"&&s.querySelector(Jo(p))||n==="script"&&s.querySelector(Yo(p))||(n=s.createElement("link"),et(n,"link",e),Xe(n),s.head.appendChild(n)))}}function qv(e,n){pn.m(e,n);var o=Ji;if(o&&e){var s=n&&typeof n.as=="string"?n.as:"script",d='link[rel="modulepreload"][as="'+Nt(s)+'"][href="'+Nt(e)+'"]',p=d;switch(s){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":p=Xi(e)}if(!Gt.has(p)&&(e=S({rel:"modulepreload",href:e},n),Gt.set(p,e),o.querySelector(d)===null)){switch(s){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(o.querySelector(Yo(p)))return}s=o.createElement("link"),et(s,"link",e),Xe(s),o.head.appendChild(s)}}}function Vv(e,n,o){pn.S(e,n,o);var s=Ji;if(s&&e){var d=mi(s).hoistableStyles,p=Yi(e);n=n||"default";var T=d.get(p);if(!T){var _={loading:0,preload:null};if(T=s.querySelector(Jo(p)))_.loading=5;else{e=S({rel:"stylesheet",href:e,"data-precedence":n},o),(o=Gt.get(p))&&Zr(e,o);var A=T=s.createElement("link");Xe(A),et(A,"link",e),A._p=new Promise(function(x,G){A.onload=x,A.onerror=G}),A.addEventListener("load",function(){_.loading|=1}),A.addEventListener("error",function(){_.loading|=2}),_.loading|=4,ra(T,n,s)}T={type:"stylesheet",instance:T,count:1,state:_},d.set(p,T)}}}function zv(e,n){pn.X(e,n);var o=Ji;if(o&&e){var s=mi(o).hoistableScripts,d=Xi(e),p=s.get(d);p||(p=o.querySelector(Yo(d)),p||(e=S({src:e,async:!0},n),(n=Gt.get(d))&&$r(e,n),p=o.createElement("script"),Xe(p),et(p,"link",e),o.head.appendChild(p)),p={type:"script",instance:p,count:1,state:null},s.set(d,p))}}function Bv(e,n){pn.M(e,n);var o=Ji;if(o&&e){var s=mi(o).hoistableScripts,d=Xi(e),p=s.get(d);p||(p=o.querySelector(Yo(d)),p||(e=S({src:e,async:!0,type:"module"},n),(n=Gt.get(d))&&$r(e,n),p=o.createElement("script"),Xe(p),et(p,"link",e),o.head.appendChild(p)),p={type:"script",instance:p,count:1,state:null},s.set(d,p))}}function Ap(e,n,o,s){var d=(d=ue.current)?sa(d):null;if(!d)throw Error(a(446));switch(e){case"meta":case"title":return null;case"style":return typeof o.precedence=="string"&&typeof o.href=="string"?(n=Yi(o.href),o=mi(d).hoistableStyles,s=o.get(n),s||(s={type:"style",instance:null,count:0,state:null},o.set(n,s)),s):{type:"void",instance:null,count:0,state:null};case"link":if(o.rel==="stylesheet"&&typeof o.href=="string"&&typeof o.precedence=="string"){e=Yi(o.href);var p=mi(d).hoistableStyles,T=p.get(e);if(T||(d=d.ownerDocument||d,T={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},p.set(e,T),(p=d.querySelector(Jo(e)))&&!p._p&&(T.instance=p,T.state.loading=5),Gt.has(e)||(o={rel:"preload",as:"style",href:o.href,crossOrigin:o.crossOrigin,integrity:o.integrity,media:o.media,hrefLang:o.hrefLang,referrerPolicy:o.referrerPolicy},Gt.set(e,o),p||Pv(d,e,o,T.state))),n&&s===null)throw Error(a(528,""));return T}if(n&&s!==null)throw Error(a(529,""));return null;case"script":return n=o.async,o=o.src,typeof o=="string"&&n&&typeof n!="function"&&typeof n!="symbol"?(n=Xi(o),o=mi(d).hoistableScripts,s=o.get(n),s||(s={type:"script",instance:null,count:0,state:null},o.set(n,s)),s):{type:"void",instance:null,count:0,state:null};default:throw Error(a(444,e))}}function Yi(e){return'href="'+Nt(e)+'"'}function Jo(e){return'link[rel="stylesheet"]['+e+"]"}function Rp(e){return S({},e,{"data-precedence":e.precedence,precedence:null})}function Pv(e,n,o,s){e.querySelector('link[rel="preload"][as="style"]['+n+"]")?s.loading=1:(n=e.createElement("link"),s.preload=n,n.addEventListener("load",function(){return s.loading|=1}),n.addEventListener("error",function(){return s.loading|=2}),et(n,"link",o),Xe(n),e.head.appendChild(n))}function Xi(e){return'[src="'+Nt(e)+'"]'}function Yo(e){return"script[async]"+e}function Mp(e,n,o){if(n.count++,n.instance===null)switch(n.type){case"style":var s=e.querySelector('style[data-href~="'+Nt(o.href)+'"]');if(s)return n.instance=s,Xe(s),s;var d=S({},o,{"data-href":o.href,"data-precedence":o.precedence,href:null,precedence:null});return s=(e.ownerDocument||e).createElement("style"),Xe(s),et(s,"style",d),ra(s,o.precedence,e),n.instance=s;case"stylesheet":d=Yi(o.href);var p=e.querySelector(Jo(d));if(p)return n.state.loading|=4,n.instance=p,Xe(p),p;s=Rp(o),(d=Gt.get(d))&&Zr(s,d),p=(e.ownerDocument||e).createElement("link"),Xe(p);var T=p;return T._p=new Promise(function(_,A){T.onload=_,T.onerror=A}),et(p,"link",s),n.state.loading|=4,ra(p,o.precedence,e),n.instance=p;case"script":return p=Xi(o.src),(d=e.querySelector(Yo(p)))?(n.instance=d,Xe(d),d):(s=o,(d=Gt.get(p))&&(s=S({},o),$r(s,d)),e=e.ownerDocument||e,d=e.createElement("script"),Xe(d),et(d,"link",s),e.head.appendChild(d),n.instance=d);case"void":return null;default:throw Error(a(443,n.type))}else n.type==="stylesheet"&&(n.state.loading&4)===0&&(s=n.instance,n.state.loading|=4,ra(s,o.precedence,e));return n.instance}function ra(e,n,o){for(var s=o.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),d=s.length?s[s.length-1]:null,p=d,T=0;T title"):null)}function kv(e,n,o){if(o===1||n.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof n.precedence!="string"||typeof n.href!="string"||n.href==="")break;return!0;case"link":if(typeof n.rel!="string"||typeof n.href!="string"||n.href===""||n.onLoad||n.onError)break;switch(n.rel){case"stylesheet":return e=n.disabled,typeof n.precedence=="string"&&e==null;default:return!0}case"script":if(n.async&&typeof n.async!="function"&&typeof n.async!="symbol"&&!n.onLoad&&!n.onError&&n.src&&typeof n.src=="string")return!0}return!1}function xp(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function Ov(e,n,o,s){if(o.type==="stylesheet"&&(typeof s.media!="string"||matchMedia(s.media).matches!==!1)&&(o.state.loading&4)===0){if(o.instance===null){var d=Yi(s.href),p=n.querySelector(Jo(d));if(p){n=p._p,n!==null&&typeof n=="object"&&typeof n.then=="function"&&(e.count++,e=ca.bind(e),n.then(e,e)),o.state.loading|=4,o.instance=p,Xe(p);return}p=n.ownerDocument||n,s=Rp(s),(d=Gt.get(d))&&Zr(s,d),p=p.createElement("link"),Xe(p);var T=p;T._p=new Promise(function(_,A){T.onload=_,T.onerror=A}),et(p,"link",s),o.instance=p}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(o,n),(n=o.state.preload)&&(o.state.loading&3)===0&&(e.count++,o=ca.bind(e),n.addEventListener("load",o),n.addEventListener("error",o))}}var Wr=0;function Fv(e,n){return e.stylesheets&&e.count===0&&da(e,e.stylesheets),0Wr?50:800)+n);return e.unsuspend=o,function(){e.unsuspend=null,clearTimeout(s),clearTimeout(d)}}:null}function ca(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)da(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var fa=null;function da(e,n){e.stylesheets=null,e.unsuspend!==null&&(e.count++,fa=new Map,n.forEach(Jv,e),fa=null,ca.call(e))}function Jv(e,n){if(!(n.state.loading&4)){var o=fa.get(e);if(o)var s=o.get(null);else{o=new Map,fa.set(e,o);for(var d=e.querySelectorAll("link[data-precedence],style[data-precedence]"),p=0;p"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(t){console.error(t)}}return i(),su.exports=r0(),su.exports}var c0=u0();const f0=Lh(c0),jp=({children:i})=>B.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-start pt-8 pb-8 px-4 sm:px-6 max-w-md mx-auto w-full relative",children:[B.jsxs("div",{className:"fixed top-0 left-0 w-full h-full overflow-hidden pointer-events-none -z-10",children:[B.jsx("div",{className:"absolute top-10 right-10 w-20 h-20 border-4 border-white/20 rounded-full animate-float"}),B.jsx("div",{className:"absolute bottom-20 left-10 w-16 h-16 bg-brand-yellow/20 rounded-full blur-xl animate-pulse"})]}),B.jsxs("header",{className:"w-full flex flex-col items-center mb-6 text-center relative z-20",children:[B.jsx("div",{className:"inline-block bg-white text-brand-red px-3 py-1 rounded-full text-xs font-bold mb-3 shadow-lg transform -rotate-2",children:"🎵 歌词灵感 · 现场征集"}),B.jsxs("h1",{className:"text-4xl font-black italic tracking-tighter text-white drop-shadow-lg mb-2 transform -skew-x-3",children:["一起做首",B.jsx("br",{}),B.jsx("span",{className:"text-5xl",children:"我们的歌"})]}),B.jsxs("div",{className:"mt-6 space-y-1",children:[B.jsx("p",{className:"text-lg font-bold text-white border-b-2 border-white/30 inline-block pb-1",children:"门槛不高,不需要懂音乐"}),B.jsx("p",{className:"text-sm opacity-90",children:"聊聊咱们的故事,将灵感汇聚成歌"})]})]}),B.jsx("main",{className:"w-full bg-white rounded-3xl p-6 shadow-xl relative overflow-hidden text-gray-800",children:i}),B.jsxs("footer",{className:"mt-8 text-[10px] text-white/60 text-center uppercase tracking-wider",children:[B.jsx("p",{className:"mb-1",children:"朴见潮音"}),B.jsx("p",{children:"© 2025 COMMUNE Music Co-creation"})]})]});/** * @license lucide-react v0.561.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const d0=i=>i.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),p0=i=>i.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,l,a)=>a?a.toUpperCase():l.toLowerCase()),em=i=>{const t=p0(i);return t.charAt(0).toUpperCase()+t.slice(1)},Gh=(...i)=>i.filter((t,l,a)=>!!t&&t.trim()!==""&&a.indexOf(t)===l).join(" ").trim(),m0=i=>{for(const t in i)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};/** * @license lucide-react v0.561.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */var h0={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** * @license lucide-react v0.561.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const g0=nt.forwardRef(({color:i="currentColor",size:t=24,strokeWidth:l=2,absoluteStrokeWidth:a,className:r="",children:f,iconNode:m,...g},y)=>nt.createElement("svg",{ref:y,...h0,width:t,height:t,stroke:i,strokeWidth:a?Number(l)*24/Number(t):l,className:Gh("lucide",r),...!f&&!m0(g)&&{"aria-hidden":"true"},...g},[...m.map(([h,v])=>nt.createElement(h,v)),...Array.isArray(f)?f:[f]]));/** * @license lucide-react v0.561.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kt=(i,t)=>{const l=nt.forwardRef(({className:a,...r},f)=>nt.createElement(g0,{ref:f,iconNode:t,className:Gh(`lucide-${d0(em(i))}`,`lucide-${i}`,a),...r}));return l.displayName=em(i),l};/** * @license lucide-react v0.561.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const y0=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],v0=Kt("arrow-right",y0);/** * @license lucide-react v0.561.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const T0=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],S0=Kt("circle-check",T0);/** * @license lucide-react v0.561.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const E0=[["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M14 2v2",key:"6buw04"}],["path",{d:"M16 8a1 1 0 0 1 1 1v8a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1h14a4 4 0 1 1 0 8h-1",key:"pwadti"}],["path",{d:"M6 2v2",key:"colzsn"}]],_0=Kt("coffee",E0);/** * @license lucide-react v0.561.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const C0=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Hh=Kt("loader-circle",C0);/** * @license lucide-react v0.561.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const A0=[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]],R0=Kt("quote",A0);/** * @license lucide-react v0.561.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const M0=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],N0=Kt("refresh-cw",M0);/** * @license lucide-react v0.561.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const I0=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],x0=Kt("send",I0);/** * @license lucide-react v0.561.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const D0=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],U0=Kt("smartphone",D0);/** * @license lucide-react v0.561.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const w0=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],qh=Kt("sparkles",w0);/** * @license lucide-react v0.561.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const b0=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],L0=Kt("user",b0),fu="ai_song_fest_user",du="ai_song_fest_songs",G0=/^1[3-9]\d{9}$/,hu={login:async i=>{if(await new Promise(a=>setTimeout(a,800)),!G0.test(i))return{success:!1,error:"手机号格式不正确"};if(i.endsWith("0000"))return{success:!1,error:"该手机号未报名参与本次活动"};const t=`tk_${i}_${Date.now().toString(36)}`,l={phone:i,token:t};return localStorage.setItem(fu,JSON.stringify(l)),{success:!0,token:t}},getCurrentUser:()=>{const i=localStorage.getItem(fu);return i?JSON.parse(i):null},logout:()=>{localStorage.removeItem(fu)}},Sa={getSongByPhone:async i=>(await new Promise(l=>setTimeout(l,300)),JSON.parse(localStorage.getItem(du)||"{}")[i]||null),submitSong:async(i,t)=>{await new Promise(f=>setTimeout(f,1500));const l=`TKT-${Math.floor(Math.random()*1e4).toString().padStart(4,"0")}-${Date.now().toString().slice(-4)}`,a={id:Date.now().toString(36),phone:i,title:t.title,lyrics:t.lyrics,style:t.style,nickname:t.nickname,status:"submitted",ticketNumber:l,createdAt:Date.now()},r=JSON.parse(localStorage.getItem(du)||"{}");return r[i]=a,localStorage.setItem(du,JSON.stringify(r)),a}},H0=({onLoginSuccess:i})=>{const[t,l]=nt.useState(""),[a,r]=nt.useState(!1),[f,m]=nt.useState(""),g=async y=>{y.preventDefault(),r(!0),m("");try{const h=await hu.login(t);h.success?i():m(h.error||"验证失败")}catch{m("发生未知错误")}finally{r(!1)}};return B.jsxs("div",{className:"space-y-8 py-2",children:[B.jsxs("div",{className:"text-center space-y-2",children:[B.jsx("h2",{className:"text-2xl font-black text-brand-dark tracking-wide",children:"欢迎加入共创"}),B.jsx("p",{className:"text-gray-500 text-sm",children:"输入手机号,开始分享你的故事"})]}),B.jsxs("form",{onSubmit:g,className:"space-y-6",children:[B.jsxs("div",{className:"group",children:[B.jsx("label",{className:"block text-xs font-bold text-gray-500 mb-2 uppercase tracking-wider ml-1",children:"手机号码"}),B.jsxs("div",{className:"relative transition-transform duration-300 focus-within:scale-[1.02]",children:[B.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-12 flex items-center justify-center text-gray-400 group-focus-within:text-brand-orange transition-colors",children:B.jsx(U0,{className:"w-5 h-5"})}),B.jsx("input",{type:"tel",value:t,onChange:y=>l(y.target.value),placeholder:"138 0000 0000",className:"w-full bg-gray-50 border border-gray-200 rounded-xl py-4 pl-12 pr-4 text-gray-800 placeholder-gray-400 focus:outline-none focus:border-brand-orange focus:ring-1 focus:ring-brand-orange transition-all font-mono text-lg",required:!0})]})]}),f&&B.jsxs("div",{className:"p-3 rounded-lg bg-red-50 border border-red-100 text-red-500 text-sm flex items-center gap-2 animate-pulse",children:[B.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-red-500"}),f]}),B.jsx("button",{type:"submit",disabled:a,className:"w-full bg-gradient-to-r from-brand-orange to-brand-red hover:shadow-lg hover:shadow-brand-orange/30 disabled:opacity-50 text-white font-bold py-4 rounded-xl transition-all transform active:scale-95 flex items-center justify-center gap-2",children:a?B.jsx(Hh,{className:"w-5 h-5 animate-spin"}):B.jsxs(B.Fragment,{children:["验证并开始 ",B.jsx(v0,{className:"w-5 h-5"})]})})]}),B.jsx("div",{className:"text-[10px] text-center text-gray-400 pt-4",children:B.jsx("span",{className:"inline-block px-2 py-1 bg-gray-100 rounded",children:"测试提示: 尾号 0000 将会被拒绝"})})]})};var q0={};/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */let V0,z0;function B0(){return{geminiUrl:V0,vertexUrl:z0}}function P0(i,t,l,a){var r,f;if(!(i!=null&&i.baseUrl)){const m=B0();return t?(r=m.vertexUrl)!==null&&r!==void 0?r:l:(f=m.geminiUrl)!==null&&f!==void 0?f:a}return i.baseUrl}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class hn{}function Y(i,t){const l=/\{([^}]+)\}/g;return i.replace(l,(a,r)=>{if(Object.prototype.hasOwnProperty.call(t,r)){const f=t[r];return f!=null?String(f):""}else throw new Error(`Key '${r}' not found in valueMap.`)})}function c(i,t,l){for(let f=0;f({}));else throw new Error(`Value must be a list given an array path ${m}`);if(Array.isArray(i[g])){const y=i[g];if(Array.isArray(l))for(let h=0;hu(g,t.slice(a+1),l)):l}else return l}else i=i[r]}return i}catch(a){if(a instanceof TypeError)return l;throw a}}function k0(i,t){for(const[l,a]of Object.entries(t)){const r=l.split("."),f=a.split("."),m=new Set;let g=-1;for(let y=0;yg)for(let y=g;y=t.length||typeof i!="object"||i===null)return;const f=t[a];if(f.endsWith("[]")){const m=f.slice(0,-2),g=i;if(m in g&&Array.isArray(g[m]))for(const y of g[m])gu(y,t,l,a+1,r)}else if(f==="*"){if(typeof i=="object"&&i!==null&&!Array.isArray(i)){const m=i,g=Object.keys(m).filter(h=>!h.startsWith("_")&&!r.has(h)),y={};for(const h of g)y[h]=m[h];for(const[h,v]of Object.entries(y)){const S=[];for(const E of l.slice(a))E==="*"?S.push(h):S.push(E);c(m,S,v)}for(const h of g)delete m[h]}}else{const m=i;f in m&&gu(m[f],t,l,a+1,r)}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function Uu(i){if(typeof i!="string")throw new Error("fromImageBytes must be a string");return i}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function O0(i){const t={},l=u(i,["operationName"]);l!=null&&c(t,["operationName"],l);const a=u(i,["resourceName"]);return a!=null&&c(t,["_url","resourceName"],a),t}function F0(i){const t={},l=u(i,["name"]);l!=null&&c(t,["name"],l);const a=u(i,["metadata"]);a!=null&&c(t,["metadata"],a);const r=u(i,["done"]);r!=null&&c(t,["done"],r);const f=u(i,["error"]);f!=null&&c(t,["error"],f);const m=u(i,["response","generateVideoResponse"]);return m!=null&&c(t,["response"],Y0(m)),t}function J0(i){const t={},l=u(i,["name"]);l!=null&&c(t,["name"],l);const a=u(i,["metadata"]);a!=null&&c(t,["metadata"],a);const r=u(i,["done"]);r!=null&&c(t,["done"],r);const f=u(i,["error"]);f!=null&&c(t,["error"],f);const m=u(i,["response"]);return m!=null&&c(t,["response"],X0(m)),t}function Y0(i){const t={},l=u(i,["generatedSamples"]);if(l!=null){let f=l;Array.isArray(f)&&(f=f.map(m=>K0(m))),c(t,["generatedVideos"],f)}const a=u(i,["raiMediaFilteredCount"]);a!=null&&c(t,["raiMediaFilteredCount"],a);const r=u(i,["raiMediaFilteredReasons"]);return r!=null&&c(t,["raiMediaFilteredReasons"],r),t}function X0(i){const t={},l=u(i,["videos"]);if(l!=null){let f=l;Array.isArray(f)&&(f=f.map(m=>Q0(m))),c(t,["generatedVideos"],f)}const a=u(i,["raiMediaFilteredCount"]);a!=null&&c(t,["raiMediaFilteredCount"],a);const r=u(i,["raiMediaFilteredReasons"]);return r!=null&&c(t,["raiMediaFilteredReasons"],r),t}function K0(i){const t={},l=u(i,["video"]);return l!=null&&c(t,["video"],tT(l)),t}function Q0(i){const t={},l=u(i,["_self"]);return l!=null&&c(t,["video"],nT(l)),t}function Z0(i){const t={},l=u(i,["operationName"]);return l!=null&&c(t,["_url","operationName"],l),t}function $0(i){const t={},l=u(i,["operationName"]);return l!=null&&c(t,["_url","operationName"],l),t}function W0(i){const t={},l=u(i,["name"]);l!=null&&c(t,["name"],l);const a=u(i,["metadata"]);a!=null&&c(t,["metadata"],a);const r=u(i,["done"]);r!=null&&c(t,["done"],r);const f=u(i,["error"]);f!=null&&c(t,["error"],f);const m=u(i,["response"]);return m!=null&&c(t,["response"],j0(m)),t}function j0(i){const t={},l=u(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=u(i,["parent"]);a!=null&&c(t,["parent"],a);const r=u(i,["documentName"]);return r!=null&&c(t,["documentName"],r),t}function Vh(i){const t={},l=u(i,["name"]);l!=null&&c(t,["name"],l);const a=u(i,["metadata"]);a!=null&&c(t,["metadata"],a);const r=u(i,["done"]);r!=null&&c(t,["done"],r);const f=u(i,["error"]);f!=null&&c(t,["error"],f);const m=u(i,["response"]);return m!=null&&c(t,["response"],eT(m)),t}function eT(i){const t={},l=u(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=u(i,["parent"]);a!=null&&c(t,["parent"],a);const r=u(i,["documentName"]);return r!=null&&c(t,["documentName"],r),t}function tT(i){const t={},l=u(i,["uri"]);l!=null&&c(t,["uri"],l);const a=u(i,["encodedVideo"]);a!=null&&c(t,["videoBytes"],Uu(a));const r=u(i,["encoding"]);return r!=null&&c(t,["mimeType"],r),t}function nT(i){const t={},l=u(i,["gcsUri"]);l!=null&&c(t,["uri"],l);const a=u(i,["bytesBase64Encoded"]);a!=null&&c(t,["videoBytes"],Uu(a));const r=u(i,["mimeType"]);return r!=null&&c(t,["mimeType"],r),t}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */var tm;(function(i){i.OUTCOME_UNSPECIFIED="OUTCOME_UNSPECIFIED",i.OUTCOME_OK="OUTCOME_OK",i.OUTCOME_FAILED="OUTCOME_FAILED",i.OUTCOME_DEADLINE_EXCEEDED="OUTCOME_DEADLINE_EXCEEDED"})(tm||(tm={}));var nm;(function(i){i.LANGUAGE_UNSPECIFIED="LANGUAGE_UNSPECIFIED",i.PYTHON="PYTHON"})(nm||(nm={}));var im;(function(i){i.SCHEDULING_UNSPECIFIED="SCHEDULING_UNSPECIFIED",i.SILENT="SILENT",i.WHEN_IDLE="WHEN_IDLE",i.INTERRUPT="INTERRUPT"})(im||(im={}));var kn;(function(i){i.TYPE_UNSPECIFIED="TYPE_UNSPECIFIED",i.STRING="STRING",i.NUMBER="NUMBER",i.INTEGER="INTEGER",i.BOOLEAN="BOOLEAN",i.ARRAY="ARRAY",i.OBJECT="OBJECT",i.NULL="NULL"})(kn||(kn={}));var om;(function(i){i.MODE_UNSPECIFIED="MODE_UNSPECIFIED",i.MODE_DYNAMIC="MODE_DYNAMIC"})(om||(om={}));var lm;(function(i){i.API_SPEC_UNSPECIFIED="API_SPEC_UNSPECIFIED",i.SIMPLE_SEARCH="SIMPLE_SEARCH",i.ELASTIC_SEARCH="ELASTIC_SEARCH"})(lm||(lm={}));var am;(function(i){i.AUTH_TYPE_UNSPECIFIED="AUTH_TYPE_UNSPECIFIED",i.NO_AUTH="NO_AUTH",i.API_KEY_AUTH="API_KEY_AUTH",i.HTTP_BASIC_AUTH="HTTP_BASIC_AUTH",i.GOOGLE_SERVICE_ACCOUNT_AUTH="GOOGLE_SERVICE_ACCOUNT_AUTH",i.OAUTH="OAUTH",i.OIDC_AUTH="OIDC_AUTH"})(am||(am={}));var sm;(function(i){i.HTTP_IN_UNSPECIFIED="HTTP_IN_UNSPECIFIED",i.HTTP_IN_QUERY="HTTP_IN_QUERY",i.HTTP_IN_HEADER="HTTP_IN_HEADER",i.HTTP_IN_PATH="HTTP_IN_PATH",i.HTTP_IN_BODY="HTTP_IN_BODY",i.HTTP_IN_COOKIE="HTTP_IN_COOKIE"})(sm||(sm={}));var rm;(function(i){i.PHISH_BLOCK_THRESHOLD_UNSPECIFIED="PHISH_BLOCK_THRESHOLD_UNSPECIFIED",i.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",i.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",i.BLOCK_HIGH_AND_ABOVE="BLOCK_HIGH_AND_ABOVE",i.BLOCK_HIGHER_AND_ABOVE="BLOCK_HIGHER_AND_ABOVE",i.BLOCK_VERY_HIGH_AND_ABOVE="BLOCK_VERY_HIGH_AND_ABOVE",i.BLOCK_ONLY_EXTREMELY_HIGH="BLOCK_ONLY_EXTREMELY_HIGH"})(rm||(rm={}));var um;(function(i){i.THINKING_LEVEL_UNSPECIFIED="THINKING_LEVEL_UNSPECIFIED",i.LOW="LOW",i.MEDIUM="MEDIUM",i.HIGH="HIGH",i.MINIMAL="MINIMAL"})(um||(um={}));var cm;(function(i){i.HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",i.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",i.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",i.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",i.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT",i.HARM_CATEGORY_CIVIC_INTEGRITY="HARM_CATEGORY_CIVIC_INTEGRITY",i.HARM_CATEGORY_IMAGE_HATE="HARM_CATEGORY_IMAGE_HATE",i.HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT="HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT",i.HARM_CATEGORY_IMAGE_HARASSMENT="HARM_CATEGORY_IMAGE_HARASSMENT",i.HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT="HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT",i.HARM_CATEGORY_JAILBREAK="HARM_CATEGORY_JAILBREAK"})(cm||(cm={}));var fm;(function(i){i.HARM_BLOCK_METHOD_UNSPECIFIED="HARM_BLOCK_METHOD_UNSPECIFIED",i.SEVERITY="SEVERITY",i.PROBABILITY="PROBABILITY"})(fm||(fm={}));var dm;(function(i){i.HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",i.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",i.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",i.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",i.BLOCK_NONE="BLOCK_NONE",i.OFF="OFF"})(dm||(dm={}));var pm;(function(i){i.FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",i.STOP="STOP",i.MAX_TOKENS="MAX_TOKENS",i.SAFETY="SAFETY",i.RECITATION="RECITATION",i.LANGUAGE="LANGUAGE",i.OTHER="OTHER",i.BLOCKLIST="BLOCKLIST",i.PROHIBITED_CONTENT="PROHIBITED_CONTENT",i.SPII="SPII",i.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",i.IMAGE_SAFETY="IMAGE_SAFETY",i.UNEXPECTED_TOOL_CALL="UNEXPECTED_TOOL_CALL",i.IMAGE_PROHIBITED_CONTENT="IMAGE_PROHIBITED_CONTENT",i.NO_IMAGE="NO_IMAGE",i.IMAGE_RECITATION="IMAGE_RECITATION",i.IMAGE_OTHER="IMAGE_OTHER"})(pm||(pm={}));var mm;(function(i){i.HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",i.NEGLIGIBLE="NEGLIGIBLE",i.LOW="LOW",i.MEDIUM="MEDIUM",i.HIGH="HIGH"})(mm||(mm={}));var hm;(function(i){i.HARM_SEVERITY_UNSPECIFIED="HARM_SEVERITY_UNSPECIFIED",i.HARM_SEVERITY_NEGLIGIBLE="HARM_SEVERITY_NEGLIGIBLE",i.HARM_SEVERITY_LOW="HARM_SEVERITY_LOW",i.HARM_SEVERITY_MEDIUM="HARM_SEVERITY_MEDIUM",i.HARM_SEVERITY_HIGH="HARM_SEVERITY_HIGH"})(hm||(hm={}));var gm;(function(i){i.URL_RETRIEVAL_STATUS_UNSPECIFIED="URL_RETRIEVAL_STATUS_UNSPECIFIED",i.URL_RETRIEVAL_STATUS_SUCCESS="URL_RETRIEVAL_STATUS_SUCCESS",i.URL_RETRIEVAL_STATUS_ERROR="URL_RETRIEVAL_STATUS_ERROR",i.URL_RETRIEVAL_STATUS_PAYWALL="URL_RETRIEVAL_STATUS_PAYWALL",i.URL_RETRIEVAL_STATUS_UNSAFE="URL_RETRIEVAL_STATUS_UNSAFE"})(gm||(gm={}));var ym;(function(i){i.BLOCKED_REASON_UNSPECIFIED="BLOCKED_REASON_UNSPECIFIED",i.SAFETY="SAFETY",i.OTHER="OTHER",i.BLOCKLIST="BLOCKLIST",i.PROHIBITED_CONTENT="PROHIBITED_CONTENT",i.IMAGE_SAFETY="IMAGE_SAFETY",i.MODEL_ARMOR="MODEL_ARMOR",i.JAILBREAK="JAILBREAK"})(ym||(ym={}));var vm;(function(i){i.TRAFFIC_TYPE_UNSPECIFIED="TRAFFIC_TYPE_UNSPECIFIED",i.ON_DEMAND="ON_DEMAND",i.PROVISIONED_THROUGHPUT="PROVISIONED_THROUGHPUT"})(vm||(vm={}));var Ia;(function(i){i.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",i.TEXT="TEXT",i.IMAGE="IMAGE",i.AUDIO="AUDIO"})(Ia||(Ia={}));var Tm;(function(i){i.MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",i.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",i.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",i.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH"})(Tm||(Tm={}));var Sm;(function(i){i.TUNING_MODE_UNSPECIFIED="TUNING_MODE_UNSPECIFIED",i.TUNING_MODE_FULL="TUNING_MODE_FULL",i.TUNING_MODE_PEFT_ADAPTER="TUNING_MODE_PEFT_ADAPTER"})(Sm||(Sm={}));var Em;(function(i){i.ADAPTER_SIZE_UNSPECIFIED="ADAPTER_SIZE_UNSPECIFIED",i.ADAPTER_SIZE_ONE="ADAPTER_SIZE_ONE",i.ADAPTER_SIZE_TWO="ADAPTER_SIZE_TWO",i.ADAPTER_SIZE_FOUR="ADAPTER_SIZE_FOUR",i.ADAPTER_SIZE_EIGHT="ADAPTER_SIZE_EIGHT",i.ADAPTER_SIZE_SIXTEEN="ADAPTER_SIZE_SIXTEEN",i.ADAPTER_SIZE_THIRTY_TWO="ADAPTER_SIZE_THIRTY_TWO"})(Em||(Em={}));var yu;(function(i){i.JOB_STATE_UNSPECIFIED="JOB_STATE_UNSPECIFIED",i.JOB_STATE_QUEUED="JOB_STATE_QUEUED",i.JOB_STATE_PENDING="JOB_STATE_PENDING",i.JOB_STATE_RUNNING="JOB_STATE_RUNNING",i.JOB_STATE_SUCCEEDED="JOB_STATE_SUCCEEDED",i.JOB_STATE_FAILED="JOB_STATE_FAILED",i.JOB_STATE_CANCELLING="JOB_STATE_CANCELLING",i.JOB_STATE_CANCELLED="JOB_STATE_CANCELLED",i.JOB_STATE_PAUSED="JOB_STATE_PAUSED",i.JOB_STATE_EXPIRED="JOB_STATE_EXPIRED",i.JOB_STATE_UPDATING="JOB_STATE_UPDATING",i.JOB_STATE_PARTIALLY_SUCCEEDED="JOB_STATE_PARTIALLY_SUCCEEDED"})(yu||(yu={}));var _m;(function(i){i.TUNING_TASK_UNSPECIFIED="TUNING_TASK_UNSPECIFIED",i.TUNING_TASK_I2V="TUNING_TASK_I2V",i.TUNING_TASK_T2V="TUNING_TASK_T2V",i.TUNING_TASK_R2V="TUNING_TASK_R2V"})(_m||(_m={}));var Cm;(function(i){i.MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",i.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",i.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",i.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH",i.MEDIA_RESOLUTION_ULTRA_HIGH="MEDIA_RESOLUTION_ULTRA_HIGH"})(Cm||(Cm={}));var Am;(function(i){i.FEATURE_SELECTION_PREFERENCE_UNSPECIFIED="FEATURE_SELECTION_PREFERENCE_UNSPECIFIED",i.PRIORITIZE_QUALITY="PRIORITIZE_QUALITY",i.BALANCED="BALANCED",i.PRIORITIZE_COST="PRIORITIZE_COST"})(Am||(Am={}));var Rm;(function(i){i.UNSPECIFIED="UNSPECIFIED",i.BLOCKING="BLOCKING",i.NON_BLOCKING="NON_BLOCKING"})(Rm||(Rm={}));var Mm;(function(i){i.MODE_UNSPECIFIED="MODE_UNSPECIFIED",i.MODE_DYNAMIC="MODE_DYNAMIC"})(Mm||(Mm={}));var Nm;(function(i){i.ENVIRONMENT_UNSPECIFIED="ENVIRONMENT_UNSPECIFIED",i.ENVIRONMENT_BROWSER="ENVIRONMENT_BROWSER"})(Nm||(Nm={}));var Im;(function(i){i.MODE_UNSPECIFIED="MODE_UNSPECIFIED",i.AUTO="AUTO",i.ANY="ANY",i.NONE="NONE",i.VALIDATED="VALIDATED"})(Im||(Im={}));var xm;(function(i){i.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",i.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",i.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",i.BLOCK_NONE="BLOCK_NONE"})(xm||(xm={}));var Dm;(function(i){i.DONT_ALLOW="DONT_ALLOW",i.ALLOW_ADULT="ALLOW_ADULT",i.ALLOW_ALL="ALLOW_ALL"})(Dm||(Dm={}));var Um;(function(i){i.auto="auto",i.en="en",i.ja="ja",i.ko="ko",i.hi="hi",i.zh="zh",i.pt="pt",i.es="es"})(Um||(Um={}));var wm;(function(i){i.MASK_MODE_DEFAULT="MASK_MODE_DEFAULT",i.MASK_MODE_USER_PROVIDED="MASK_MODE_USER_PROVIDED",i.MASK_MODE_BACKGROUND="MASK_MODE_BACKGROUND",i.MASK_MODE_FOREGROUND="MASK_MODE_FOREGROUND",i.MASK_MODE_SEMANTIC="MASK_MODE_SEMANTIC"})(wm||(wm={}));var bm;(function(i){i.CONTROL_TYPE_DEFAULT="CONTROL_TYPE_DEFAULT",i.CONTROL_TYPE_CANNY="CONTROL_TYPE_CANNY",i.CONTROL_TYPE_SCRIBBLE="CONTROL_TYPE_SCRIBBLE",i.CONTROL_TYPE_FACE_MESH="CONTROL_TYPE_FACE_MESH"})(bm||(bm={}));var Lm;(function(i){i.SUBJECT_TYPE_DEFAULT="SUBJECT_TYPE_DEFAULT",i.SUBJECT_TYPE_PERSON="SUBJECT_TYPE_PERSON",i.SUBJECT_TYPE_ANIMAL="SUBJECT_TYPE_ANIMAL",i.SUBJECT_TYPE_PRODUCT="SUBJECT_TYPE_PRODUCT"})(Lm||(Lm={}));var Gm;(function(i){i.EDIT_MODE_DEFAULT="EDIT_MODE_DEFAULT",i.EDIT_MODE_INPAINT_REMOVAL="EDIT_MODE_INPAINT_REMOVAL",i.EDIT_MODE_INPAINT_INSERTION="EDIT_MODE_INPAINT_INSERTION",i.EDIT_MODE_OUTPAINT="EDIT_MODE_OUTPAINT",i.EDIT_MODE_CONTROLLED_EDITING="EDIT_MODE_CONTROLLED_EDITING",i.EDIT_MODE_STYLE="EDIT_MODE_STYLE",i.EDIT_MODE_BGSWAP="EDIT_MODE_BGSWAP",i.EDIT_MODE_PRODUCT_IMAGE="EDIT_MODE_PRODUCT_IMAGE"})(Gm||(Gm={}));var Hm;(function(i){i.FOREGROUND="FOREGROUND",i.BACKGROUND="BACKGROUND",i.PROMPT="PROMPT",i.SEMANTIC="SEMANTIC",i.INTERACTIVE="INTERACTIVE"})(Hm||(Hm={}));var qm;(function(i){i.ASSET="ASSET",i.STYLE="STYLE"})(qm||(qm={}));var Vm;(function(i){i.INSERT="INSERT",i.REMOVE="REMOVE",i.REMOVE_STATIC="REMOVE_STATIC",i.OUTPAINT="OUTPAINT"})(Vm||(Vm={}));var zm;(function(i){i.OPTIMIZED="OPTIMIZED",i.LOSSLESS="LOSSLESS"})(zm||(zm={}));var Bm;(function(i){i.SUPERVISED_FINE_TUNING="SUPERVISED_FINE_TUNING",i.PREFERENCE_TUNING="PREFERENCE_TUNING"})(Bm||(Bm={}));var Pm;(function(i){i.STATE_UNSPECIFIED="STATE_UNSPECIFIED",i.STATE_PENDING="STATE_PENDING",i.STATE_ACTIVE="STATE_ACTIVE",i.STATE_FAILED="STATE_FAILED"})(Pm||(Pm={}));var km;(function(i){i.STATE_UNSPECIFIED="STATE_UNSPECIFIED",i.PROCESSING="PROCESSING",i.ACTIVE="ACTIVE",i.FAILED="FAILED"})(km||(km={}));var Om;(function(i){i.SOURCE_UNSPECIFIED="SOURCE_UNSPECIFIED",i.UPLOADED="UPLOADED",i.GENERATED="GENERATED"})(Om||(Om={}));var Fm;(function(i){i.TURN_COMPLETE_REASON_UNSPECIFIED="TURN_COMPLETE_REASON_UNSPECIFIED",i.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",i.RESPONSE_REJECTED="RESPONSE_REJECTED",i.NEED_MORE_INPUT="NEED_MORE_INPUT"})(Fm||(Fm={}));var Jm;(function(i){i.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",i.TEXT="TEXT",i.IMAGE="IMAGE",i.VIDEO="VIDEO",i.AUDIO="AUDIO",i.DOCUMENT="DOCUMENT"})(Jm||(Jm={}));var Ym;(function(i){i.VAD_SIGNAL_TYPE_UNSPECIFIED="VAD_SIGNAL_TYPE_UNSPECIFIED",i.VAD_SIGNAL_TYPE_SOS="VAD_SIGNAL_TYPE_SOS",i.VAD_SIGNAL_TYPE_EOS="VAD_SIGNAL_TYPE_EOS"})(Ym||(Ym={}));var Xm;(function(i){i.START_SENSITIVITY_UNSPECIFIED="START_SENSITIVITY_UNSPECIFIED",i.START_SENSITIVITY_HIGH="START_SENSITIVITY_HIGH",i.START_SENSITIVITY_LOW="START_SENSITIVITY_LOW"})(Xm||(Xm={}));var Km;(function(i){i.END_SENSITIVITY_UNSPECIFIED="END_SENSITIVITY_UNSPECIFIED",i.END_SENSITIVITY_HIGH="END_SENSITIVITY_HIGH",i.END_SENSITIVITY_LOW="END_SENSITIVITY_LOW"})(Km||(Km={}));var Qm;(function(i){i.ACTIVITY_HANDLING_UNSPECIFIED="ACTIVITY_HANDLING_UNSPECIFIED",i.START_OF_ACTIVITY_INTERRUPTS="START_OF_ACTIVITY_INTERRUPTS",i.NO_INTERRUPTION="NO_INTERRUPTION"})(Qm||(Qm={}));var Zm;(function(i){i.TURN_COVERAGE_UNSPECIFIED="TURN_COVERAGE_UNSPECIFIED",i.TURN_INCLUDES_ONLY_ACTIVITY="TURN_INCLUDES_ONLY_ACTIVITY",i.TURN_INCLUDES_ALL_INPUT="TURN_INCLUDES_ALL_INPUT"})(Zm||(Zm={}));var $m;(function(i){i.SCALE_UNSPECIFIED="SCALE_UNSPECIFIED",i.C_MAJOR_A_MINOR="C_MAJOR_A_MINOR",i.D_FLAT_MAJOR_B_FLAT_MINOR="D_FLAT_MAJOR_B_FLAT_MINOR",i.D_MAJOR_B_MINOR="D_MAJOR_B_MINOR",i.E_FLAT_MAJOR_C_MINOR="E_FLAT_MAJOR_C_MINOR",i.E_MAJOR_D_FLAT_MINOR="E_MAJOR_D_FLAT_MINOR",i.F_MAJOR_D_MINOR="F_MAJOR_D_MINOR",i.G_FLAT_MAJOR_E_FLAT_MINOR="G_FLAT_MAJOR_E_FLAT_MINOR",i.G_MAJOR_E_MINOR="G_MAJOR_E_MINOR",i.A_FLAT_MAJOR_F_MINOR="A_FLAT_MAJOR_F_MINOR",i.A_MAJOR_G_FLAT_MINOR="A_MAJOR_G_FLAT_MINOR",i.B_FLAT_MAJOR_G_MINOR="B_FLAT_MAJOR_G_MINOR",i.B_MAJOR_A_FLAT_MINOR="B_MAJOR_A_FLAT_MINOR"})($m||($m={}));var Wm;(function(i){i.MUSIC_GENERATION_MODE_UNSPECIFIED="MUSIC_GENERATION_MODE_UNSPECIFIED",i.QUALITY="QUALITY",i.DIVERSITY="DIVERSITY",i.VOCALIZATION="VOCALIZATION"})(Wm||(Wm={}));var Zi;(function(i){i.PLAYBACK_CONTROL_UNSPECIFIED="PLAYBACK_CONTROL_UNSPECIFIED",i.PLAY="PLAY",i.PAUSE="PAUSE",i.STOP="STOP",i.RESET_CONTEXT="RESET_CONTEXT"})(Zi||(Zi={}));class vu{constructor(t){const l={};for(const a of t.headers.entries())l[a[0]]=a[1];this.headers=l,this.responseInternal=t}json(){return this.responseInternal.json()}}class jo{get text(){var t,l,a,r,f,m,g,y;if(((r=(a=(l=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||l===void 0?void 0:l.content)===null||a===void 0?void 0:a.parts)===null||r===void 0?void 0:r.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 h="",v=!1;const S=[];for(const E of(y=(g=(m=(f=this.candidates)===null||f===void 0?void 0:f[0])===null||m===void 0?void 0:m.content)===null||g===void 0?void 0:g.parts)!==null&&y!==void 0?y:[]){for(const[C,U]of Object.entries(E))C!=="text"&&C!=="thought"&&C!=="thoughtSignature"&&(U!==null||U!==void 0)&&S.push(C);if(typeof E.text=="string"){if(typeof E.thought=="boolean"&&E.thought)continue;v=!0,h+=E.text}}return S.length>0&&console.warn(`there are non-text parts ${S} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),v?h:void 0}get data(){var t,l,a,r,f,m,g,y;if(((r=(a=(l=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||l===void 0?void 0:l.content)===null||a===void 0?void 0:a.parts)===null||r===void 0?void 0:r.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 h="";const v=[];for(const S of(y=(g=(m=(f=this.candidates)===null||f===void 0?void 0:f[0])===null||m===void 0?void 0:m.content)===null||g===void 0?void 0:g.parts)!==null&&y!==void 0?y:[]){for(const[E,C]of Object.entries(S))E!=="inlineData"&&(C!==null||C!==void 0)&&v.push(E);S.inlineData&&typeof S.inlineData.data=="string"&&(h+=atob(S.inlineData.data))}return v.length>0&&console.warn(`there are non-data parts ${v} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),h.length>0?btoa(h):void 0}get functionCalls(){var t,l,a,r,f,m,g,y;if(((r=(a=(l=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||l===void 0?void 0:l.content)===null||a===void 0?void 0:a.parts)===null||r===void 0?void 0:r.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.");const h=(y=(g=(m=(f=this.candidates)===null||f===void 0?void 0:f[0])===null||m===void 0?void 0:m.content)===null||g===void 0?void 0:g.parts)===null||y===void 0?void 0:y.filter(v=>v.functionCall).map(v=>v.functionCall).filter(v=>v!==void 0);if((h==null?void 0:h.length)!==0)return h}get executableCode(){var t,l,a,r,f,m,g,y,h;if(((r=(a=(l=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||l===void 0?void 0:l.content)===null||a===void 0?void 0:a.parts)===null||r===void 0?void 0:r.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.");const v=(y=(g=(m=(f=this.candidates)===null||f===void 0?void 0:f[0])===null||m===void 0?void 0:m.content)===null||g===void 0?void 0:g.parts)===null||y===void 0?void 0:y.filter(S=>S.executableCode).map(S=>S.executableCode).filter(S=>S!==void 0);if((v==null?void 0:v.length)!==0)return(h=v==null?void 0:v[0])===null||h===void 0?void 0:h.code}get codeExecutionResult(){var t,l,a,r,f,m,g,y,h;if(((r=(a=(l=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||l===void 0?void 0:l.content)===null||a===void 0?void 0:a.parts)===null||r===void 0?void 0:r.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.");const v=(y=(g=(m=(f=this.candidates)===null||f===void 0?void 0:f[0])===null||m===void 0?void 0:m.content)===null||g===void 0?void 0:g.parts)===null||y===void 0?void 0:y.filter(S=>S.codeExecutionResult).map(S=>S.codeExecutionResult).filter(S=>S!==void 0);if((v==null?void 0:v.length)!==0)return(h=v==null?void 0:v[0])===null||h===void 0?void 0:h.output}}class jm{}class eh{}class iT{}class oT{}class lT{}class aT{}class th{}class nh{}class ih{}class sT{}class xa{_fromAPIResponse({apiResponse:t,_isVertexAI:l}){const a=new xa;let r;const f=t;return l?r=J0(f):r=F0(f),Object.assign(a,r),a}}class oh{}class lh{}class ah{}class sh{}class rT{}class uT{}class cT{}class wu{_fromAPIResponse({apiResponse:t,_isVertexAI:l}){const a=new wu,f=W0(t);return Object.assign(a,f),a}}class fT{}class dT{}class pT{}class rh{}class mT{get text(){var t,l,a;let r="",f=!1;const m=[];for(const g of(a=(l=(t=this.serverContent)===null||t===void 0?void 0:t.modelTurn)===null||l===void 0?void 0:l.parts)!==null&&a!==void 0?a:[]){for(const[y,h]of Object.entries(g))y!=="text"&&y!=="thought"&&h!==null&&m.push(y);if(typeof g.text=="string"){if(typeof g.thought=="boolean"&&g.thought)continue;f=!0,r+=g.text}}return m.length>0&&console.warn(`there are non-text parts ${m} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),f?r:void 0}get data(){var t,l,a;let r="";const f=[];for(const m of(a=(l=(t=this.serverContent)===null||t===void 0?void 0:t.modelTurn)===null||l===void 0?void 0:l.parts)!==null&&a!==void 0?a:[]){for(const[g,y]of Object.entries(m))g!=="inlineData"&&y!==null&&f.push(g);m.inlineData&&typeof m.inlineData.data=="string"&&(r+=atob(m.inlineData.data))}return f.length>0&&console.warn(`there are non-data parts ${f} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),r.length>0?btoa(r):void 0}}class hT{get audioChunk(){if(this.serverContent&&this.serverContent.audioChunks&&this.serverContent.audioChunks.length>0)return this.serverContent.audioChunks[0]}}class bu{_fromAPIResponse({apiResponse:t,_isVertexAI:l}){const a=new bu,f=Vh(t);return Object.assign(a,f),a}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function Te(i,t){if(!t||typeof t!="string")throw new Error("model is required and must be a string");if(t.includes("..")||t.includes("?")||t.includes("&"))throw new Error("invalid model parameter");if(i.isVertexAI()){if(t.startsWith("publishers/")||t.startsWith("projects/")||t.startsWith("models/"))return t;if(t.indexOf("/")>=0){const l=t.split("/",2);return`publishers/${l[0]}/models/${l[1]}`}else return`publishers/google/models/${t}`}else return t.startsWith("models/")||t.startsWith("tunedModels/")?t:`models/${t}`}function zh(i,t){const l=Te(i,t);return l?l.startsWith("publishers/")&&i.isVertexAI()?`projects/${i.getProject()}/locations/${i.getLocation()}/${l}`:l.startsWith("models/")&&i.isVertexAI()?`projects/${i.getProject()}/locations/${i.getLocation()}/publishers/google/${l}`:l:""}function Bh(i){return Array.isArray(i)?i.map(t=>Da(t)):[Da(i)]}function Da(i){if(typeof i=="object"&&i!==null)return i;throw new Error(`Could not parse input as Blob. Unsupported blob type: ${typeof i}`)}function Ph(i){const t=Da(i);if(t.mimeType&&t.mimeType.startsWith("image/"))return t;throw new Error(`Unsupported mime type: ${t.mimeType}`)}function kh(i){const t=Da(i);if(t.mimeType&&t.mimeType.startsWith("audio/"))return t;throw new Error(`Unsupported mime type: ${t.mimeType}`)}function uh(i){if(i==null)throw new Error("PartUnion is required");if(typeof i=="object")return i;if(typeof i=="string")return{text:i};throw new Error(`Unsupported part type: ${typeof i}`)}function Oh(i){if(i==null||Array.isArray(i)&&i.length===0)throw new Error("PartListUnion is required");return Array.isArray(i)?i.map(t=>uh(t)):[uh(i)]}function Tu(i){return i!=null&&typeof i=="object"&&"parts"in i&&Array.isArray(i.parts)}function ch(i){return i!=null&&typeof i=="object"&&"functionCall"in i}function fh(i){return i!=null&&typeof i=="object"&&"functionResponse"in i}function it(i){if(i==null)throw new Error("ContentUnion is required");return Tu(i)?i:{role:"user",parts:Oh(i)}}function Lu(i,t){if(!t)return[];if(i.isVertexAI()&&Array.isArray(t))return t.flatMap(l=>{const a=it(l);return a.parts&&a.parts.length>0&&a.parts[0].text!==void 0?[a.parts[0].text]:[]});if(i.isVertexAI()){const l=it(t);return l.parts&&l.parts.length>0&&l.parts[0].text!==void 0?[l.parts[0].text]:[]}return Array.isArray(t)?t.map(l=>it(l)):[it(t)]}function Ht(i){if(i==null||Array.isArray(i)&&i.length===0)throw new Error("contents are required");if(!Array.isArray(i)){if(ch(i)||fh(i))throw new Error("To specify functionCall or functionResponse parts, please wrap them in a Content object, specifying the role for them");return[it(i)]}const t=[],l=[],a=Tu(i[0]);for(const r of i){const f=Tu(r);if(f!=a)throw new Error("Mixing Content and Parts is not supported, please group the parts into a the appropriate Content objects and specify the roles for them");if(f)t.push(r);else{if(ch(r)||fh(r))throw new Error("To specify functionCall or functionResponse parts, please wrap them, and any other parts, in Content objects as appropriate, specifying the role for them");l.push(r)}}return a||t.push({role:"user",parts:Oh(l)}),t}function gT(i,t){i.includes("null")&&(t.nullable=!0);const l=i.filter(a=>a!=="null");if(l.length===1)t.type=Object.values(kn).includes(l[0].toUpperCase())?l[0].toUpperCase():kn.TYPE_UNSPECIFIED;else{t.anyOf=[];for(const a of l)t.anyOf.push({type:Object.values(kn).includes(a.toUpperCase())?a.toUpperCase():kn.TYPE_UNSPECIFIED})}}function Wi(i){const t={},l=["items"],a=["anyOf"],r=["properties"];if(i.type&&i.anyOf)throw new Error("type and anyOf cannot be both populated.");const f=i.anyOf;f!=null&&f.length==2&&(f[0].type==="null"?(t.nullable=!0,i=f[1]):f[1].type==="null"&&(t.nullable=!0,i=f[0])),i.type instanceof Array&&gT(i.type,t);for(const[m,g]of Object.entries(i))if(g!=null)if(m=="type"){if(g==="null")throw new Error("type: null can not be the only possible type for the field.");if(g instanceof Array)continue;t.type=Object.values(kn).includes(g.toUpperCase())?g.toUpperCase():kn.TYPE_UNSPECIFIED}else if(l.includes(m))t[m]=Wi(g);else if(a.includes(m)){const y=[];for(const h of g){if(h.type=="null"){t.nullable=!0;continue}y.push(Wi(h))}t[m]=y}else if(r.includes(m)){const y={};for(const[h,v]of Object.entries(g))y[h]=Wi(v);t[m]=y}else{if(m==="additionalProperties")continue;t[m]=g}return t}function Gu(i){return Wi(i)}function Hu(i){if(typeof i=="object")return i;if(typeof i=="string")return{voiceConfig:{prebuiltVoiceConfig:{voiceName:i}}};throw new Error(`Unsupported speechConfig type: ${typeof i}`)}function qu(i){if("multiSpeakerVoiceConfig"in i)throw new Error("multiSpeakerVoiceConfig is not supported in the live API.");return i}function eo(i){if(i.functionDeclarations)for(const t of i.functionDeclarations)t.parameters&&(Object.keys(t.parameters).includes("$schema")?t.parametersJsonSchema||(t.parametersJsonSchema=t.parameters,delete t.parameters):t.parameters=Wi(t.parameters)),t.response&&(Object.keys(t.response).includes("$schema")?t.responseJsonSchema||(t.responseJsonSchema=t.response,delete t.response):t.response=Wi(t.response));return i}function to(i){if(i==null)throw new Error("tools is required");if(!Array.isArray(i))throw new Error("tools is required and must be an array of Tools");const t=[];for(const l of i)t.push(l);return t}function yT(i,t,l,a=1){const r=!t.startsWith(`${l}/`)&&t.split("/").length===a;return i.isVertexAI()?t.startsWith("projects/")?t:t.startsWith("locations/")?`projects/${i.getProject()}/${t}`:t.startsWith(`${l}/`)?`projects/${i.getProject()}/locations/${i.getLocation()}/${t}`:r?`projects/${i.getProject()}/locations/${i.getLocation()}/${l}/${t}`:t:r?`${l}/${t}`:t}function gn(i,t){if(typeof t!="string")throw new Error("name must be a string");return yT(i,t,"cachedContents")}function Fh(i){switch(i){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 i}}function On(i){return Uu(i)}function vT(i){return i!=null&&typeof i=="object"&&"name"in i}function TT(i){return i!=null&&typeof i=="object"&&"video"in i}function ST(i){return i!=null&&typeof i=="object"&&"uri"in i}function Jh(i){var t;let l;if(vT(i)&&(l=i.name),!(ST(i)&&(l=i.uri,l===void 0))&&!(TT(i)&&(l=(t=i.video)===null||t===void 0?void 0:t.uri,l===void 0))){if(typeof i=="string"&&(l=i),l===void 0)throw new Error("Could not extract file name from the provided input.");if(l.startsWith("https://")){const r=l.split("files/")[1].match(/[a-z0-9]+/);if(r===null)throw new Error(`Could not extract file name from URI ${l}`);l=r[0]}else l.startsWith("files/")&&(l=l.split("files/")[1]);return l}}function Yh(i,t){let l;return i.isVertexAI()?l=t?"publishers/google/models":"models":l=t?"models":"tunedModels",l}function Xh(i){for(const t of["models","tunedModels","publisherModels"])if(ET(i,t))return i[t];return[]}function ET(i,t){return i!==null&&typeof i=="object"&&t in i}function _T(i,t={}){const l=i,a={name:l.name,description:l.description,parametersJsonSchema:l.inputSchema};return l.outputSchema&&(a.responseJsonSchema=l.outputSchema),t.behavior&&(a.behavior=t.behavior),{functionDeclarations:[a]}}function CT(i,t={}){const l=[],a=new Set;for(const r of i){const f=r.name;if(a.has(f))throw new Error(`Duplicate function name ${f} found in MCP tools. Please ensure function names are unique.`);a.add(f);const m=_T(r,t);m.functionDeclarations&&l.push(...m.functionDeclarations)}return{functionDeclarations:l}}function Kh(i,t){let l;if(typeof t=="string")if(i.isVertexAI())if(t.startsWith("gs://"))l={format:"jsonl",gcsUri:[t]};else if(t.startsWith("bq://"))l={format:"bigquery",bigqueryUri:t};else throw new Error(`Unsupported string source for Vertex AI: ${t}`);else if(t.startsWith("files/"))l={fileName:t};else throw new Error(`Unsupported string source for Gemini API: ${t}`);else if(Array.isArray(t)){if(i.isVertexAI())throw new Error("InlinedRequest[] is not supported in Vertex AI.");l={inlinedRequests:t}}else l=t;const a=[l.gcsUri,l.bigqueryUri].filter(Boolean).length,r=[l.inlinedRequests,l.fileName].filter(Boolean).length;if(i.isVertexAI()){if(r>0||a!==1)throw new Error("Exactly one of `gcsUri` or `bigqueryUri` must be set for Vertex AI.")}else if(a>0||r!==1)throw new Error("Exactly one of `inlinedRequests`, `fileName`, must be set for Gemini API.");return l}function AT(i){if(typeof i!="string")return i;const t=i;if(t.startsWith("gs://"))return{format:"jsonl",gcsUri:t};if(t.startsWith("bq://"))return{format:"bigquery",bigqueryUri:t};throw new Error(`Unsupported destination: ${t}`)}function Qh(i){if(typeof i!="object"||i===null)return{};const t=i,l=t.inlinedResponses;if(typeof l!="object"||l===null)return i;const r=l.inlinedResponses;if(!Array.isArray(r)||r.length===0)return i;let f=!1;for(const m of r){if(typeof m!="object"||m===null)continue;const y=m.response;if(typeof y!="object"||y===null)continue;if(y.embedding!==void 0){f=!0;break}}return f&&(t.inlinedEmbedContentResponses=t.inlinedResponses,delete t.inlinedResponses),i}function no(i,t){const l=t;if(!i.isVertexAI()){if(/batches\/[^/]+$/.test(l))return l.split("/").pop();throw new Error(`Invalid batch job name: ${l}.`)}if(/^projects\/[^/]+\/locations\/[^/]+\/batchPredictionJobs\/[^/]+$/.test(l))return l.split("/").pop();if(/^\d+$/.test(l))return l;throw new Error(`Invalid batch job name: ${l}.`)}function Zh(i){const t=i;return t==="BATCH_STATE_UNSPECIFIED"?"JOB_STATE_UNSPECIFIED":t==="BATCH_STATE_PENDING"?"JOB_STATE_PENDING":t==="BATCH_STATE_RUNNING"?"JOB_STATE_RUNNING":t==="BATCH_STATE_SUCCEEDED"?"JOB_STATE_SUCCEEDED":t==="BATCH_STATE_FAILED"?"JOB_STATE_FAILED":t==="BATCH_STATE_CANCELLED"?"JOB_STATE_CANCELLED":t==="BATCH_STATE_EXPIRED"?"JOB_STATE_EXPIRED":t}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function RT(i){const t={},l=u(i,["responsesFile"]);l!=null&&c(t,["fileName"],l);const a=u(i,["inlinedResponses","inlinedResponses"]);if(a!=null){let f=a;Array.isArray(f)&&(f=f.map(m=>lS(m))),c(t,["inlinedResponses"],f)}const r=u(i,["inlinedEmbedContentResponses","inlinedResponses"]);if(r!=null){let f=r;Array.isArray(f)&&(f=f.map(m=>m)),c(t,["inlinedEmbedContentResponses"],f)}return t}function MT(i){const t={},l=u(i,["predictionsFormat"]);l!=null&&c(t,["format"],l);const a=u(i,["gcsDestination","outputUriPrefix"]);a!=null&&c(t,["gcsUri"],a);const r=u(i,["bigqueryDestination","outputUri"]);return r!=null&&c(t,["bigqueryUri"],r),t}function NT(i){const t={},l=u(i,["format"]);l!=null&&c(t,["predictionsFormat"],l);const a=u(i,["gcsUri"]);a!=null&&c(t,["gcsDestination","outputUriPrefix"],a);const r=u(i,["bigqueryUri"]);if(r!=null&&c(t,["bigqueryDestination","outputUri"],r),u(i,["fileName"])!==void 0)throw new Error("fileName parameter is not supported in Vertex AI.");if(u(i,["inlinedResponses"])!==void 0)throw new Error("inlinedResponses parameter is not supported in Vertex AI.");if(u(i,["inlinedEmbedContentResponses"])!==void 0)throw new Error("inlinedEmbedContentResponses parameter is not supported in Vertex AI.");return t}function Ma(i){const t={},l=u(i,["name"]);l!=null&&c(t,["name"],l);const a=u(i,["metadata","displayName"]);a!=null&&c(t,["displayName"],a);const r=u(i,["metadata","state"]);r!=null&&c(t,["state"],Zh(r));const f=u(i,["metadata","createTime"]);f!=null&&c(t,["createTime"],f);const m=u(i,["metadata","endTime"]);m!=null&&c(t,["endTime"],m);const g=u(i,["metadata","updateTime"]);g!=null&&c(t,["updateTime"],g);const y=u(i,["metadata","model"]);y!=null&&c(t,["model"],y);const h=u(i,["metadata","output"]);return h!=null&&c(t,["dest"],RT(Qh(h))),t}function Su(i){const t={},l=u(i,["name"]);l!=null&&c(t,["name"],l);const a=u(i,["displayName"]);a!=null&&c(t,["displayName"],a);const r=u(i,["state"]);r!=null&&c(t,["state"],Zh(r));const f=u(i,["error"]);f!=null&&c(t,["error"],f);const m=u(i,["createTime"]);m!=null&&c(t,["createTime"],m);const g=u(i,["startTime"]);g!=null&&c(t,["startTime"],g);const y=u(i,["endTime"]);y!=null&&c(t,["endTime"],y);const h=u(i,["updateTime"]);h!=null&&c(t,["updateTime"],h);const v=u(i,["model"]);v!=null&&c(t,["model"],v);const S=u(i,["inputConfig"]);S!=null&&c(t,["src"],IT(S));const E=u(i,["outputConfig"]);E!=null&&c(t,["dest"],MT(Qh(E)));const C=u(i,["completionStats"]);return C!=null&&c(t,["completionStats"],C),t}function IT(i){const t={},l=u(i,["instancesFormat"]);l!=null&&c(t,["format"],l);const a=u(i,["gcsSource","uris"]);a!=null&&c(t,["gcsUri"],a);const r=u(i,["bigquerySource","inputUri"]);return r!=null&&c(t,["bigqueryUri"],r),t}function xT(i,t){const l={};if(u(t,["format"])!==void 0)throw new Error("format parameter is not supported in Gemini API.");if(u(t,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");if(u(t,["bigqueryUri"])!==void 0)throw new Error("bigqueryUri parameter is not supported in Gemini API.");const a=u(t,["fileName"]);a!=null&&c(l,["fileName"],a);const r=u(t,["inlinedRequests"]);if(r!=null){let f=r;Array.isArray(f)&&(f=f.map(m=>oS(i,m))),c(l,["requests","requests"],f)}return l}function DT(i){const t={},l=u(i,["format"]);l!=null&&c(t,["instancesFormat"],l);const a=u(i,["gcsUri"]);a!=null&&c(t,["gcsSource","uris"],a);const r=u(i,["bigqueryUri"]);if(r!=null&&c(t,["bigquerySource","inputUri"],r),u(i,["fileName"])!==void 0)throw new Error("fileName parameter is not supported in Vertex AI.");if(u(i,["inlinedRequests"])!==void 0)throw new Error("inlinedRequests parameter is not supported in Vertex AI.");return t}function UT(i){const t={},l=u(i,["data"]);if(l!=null&&c(t,["data"],l),u(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const a=u(i,["mimeType"]);return a!=null&&c(t,["mimeType"],a),t}function wT(i,t){const l={},a=u(t,["name"]);return a!=null&&c(l,["_url","name"],no(i,a)),l}function bT(i,t){const l={},a=u(t,["name"]);return a!=null&&c(l,["_url","name"],no(i,a)),l}function LT(i){const t={},l=u(i,["content"]);l!=null&&c(t,["content"],l);const a=u(i,["citationMetadata"]);a!=null&&c(t,["citationMetadata"],GT(a));const r=u(i,["tokenCount"]);r!=null&&c(t,["tokenCount"],r);const f=u(i,["finishReason"]);f!=null&&c(t,["finishReason"],f);const m=u(i,["avgLogprobs"]);m!=null&&c(t,["avgLogprobs"],m);const g=u(i,["groundingMetadata"]);g!=null&&c(t,["groundingMetadata"],g);const y=u(i,["index"]);y!=null&&c(t,["index"],y);const h=u(i,["logprobsResult"]);h!=null&&c(t,["logprobsResult"],h);const v=u(i,["safetyRatings"]);if(v!=null){let E=v;Array.isArray(E)&&(E=E.map(C=>C)),c(t,["safetyRatings"],E)}const S=u(i,["urlContextMetadata"]);return S!=null&&c(t,["urlContextMetadata"],S),t}function GT(i){const t={},l=u(i,["citationSources"]);if(l!=null){let a=l;Array.isArray(a)&&(a=a.map(r=>r)),c(t,["citations"],a)}return t}function $h(i){const t={},l=u(i,["parts"]);if(l!=null){let r=l;Array.isArray(r)&&(r=r.map(f=>dS(f))),c(t,["parts"],r)}const a=u(i,["role"]);return a!=null&&c(t,["role"],a),t}function HT(i,t){const l={},a=u(i,["displayName"]);if(t!==void 0&&a!=null&&c(t,["batch","displayName"],a),u(i,["dest"])!==void 0)throw new Error("dest parameter is not supported in Gemini API.");return l}function qT(i,t){const l={},a=u(i,["displayName"]);t!==void 0&&a!=null&&c(t,["displayName"],a);const r=u(i,["dest"]);return t!==void 0&&r!=null&&c(t,["outputConfig"],NT(AT(r))),l}function dh(i,t){const l={},a=u(t,["model"]);a!=null&&c(l,["_url","model"],Te(i,a));const r=u(t,["src"]);r!=null&&c(l,["batch","inputConfig"],xT(i,Kh(i,r)));const f=u(t,["config"]);return f!=null&&HT(f,l),l}function VT(i,t){const l={},a=u(t,["model"]);a!=null&&c(l,["model"],Te(i,a));const r=u(t,["src"]);r!=null&&c(l,["inputConfig"],DT(Kh(i,r)));const f=u(t,["config"]);return f!=null&&qT(f,l),l}function zT(i,t){const l={},a=u(i,["displayName"]);return t!==void 0&&a!=null&&c(t,["batch","displayName"],a),l}function BT(i,t){const l={},a=u(t,["model"]);a!=null&&c(l,["_url","model"],Te(i,a));const r=u(t,["src"]);r!=null&&c(l,["batch","inputConfig"],XT(i,r));const f=u(t,["config"]);return f!=null&&zT(f,l),l}function PT(i,t){const l={},a=u(t,["name"]);return a!=null&&c(l,["_url","name"],no(i,a)),l}function kT(i,t){const l={},a=u(t,["name"]);return a!=null&&c(l,["_url","name"],no(i,a)),l}function OT(i){const t={},l=u(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=u(i,["name"]);a!=null&&c(t,["name"],a);const r=u(i,["done"]);r!=null&&c(t,["done"],r);const f=u(i,["error"]);return f!=null&&c(t,["error"],f),t}function FT(i){const t={},l=u(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=u(i,["name"]);a!=null&&c(t,["name"],a);const r=u(i,["done"]);r!=null&&c(t,["done"],r);const f=u(i,["error"]);return f!=null&&c(t,["error"],f),t}function JT(i,t){const l={},a=u(t,["contents"]);if(a!=null){let f=Lu(i,a);Array.isArray(f)&&(f=f.map(m=>m)),c(l,["requests[]","request","content"],f)}const r=u(t,["config"]);return r!=null&&(c(l,["_self"],YT(r,l)),k0(l,{"requests[].*":"requests[].request.*"})),l}function YT(i,t){const l={},a=u(i,["taskType"]);t!==void 0&&a!=null&&c(t,["requests[]","taskType"],a);const r=u(i,["title"]);t!==void 0&&r!=null&&c(t,["requests[]","title"],r);const f=u(i,["outputDimensionality"]);if(t!==void 0&&f!=null&&c(t,["requests[]","outputDimensionality"],f),u(i,["mimeType"])!==void 0)throw new Error("mimeType parameter is not supported in Gemini API.");if(u(i,["autoTruncate"])!==void 0)throw new Error("autoTruncate parameter is not supported in Gemini API.");return l}function XT(i,t){const l={},a=u(t,["fileName"]);a!=null&&c(l,["file_name"],a);const r=u(t,["inlinedRequests"]);return r!=null&&c(l,["requests"],JT(i,r)),l}function KT(i){const t={};if(u(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const l=u(i,["fileUri"]);l!=null&&c(t,["fileUri"],l);const a=u(i,["mimeType"]);return a!=null&&c(t,["mimeType"],a),t}function QT(i){const t={},l=u(i,["id"]);l!=null&&c(t,["id"],l);const a=u(i,["args"]);a!=null&&c(t,["args"],a);const r=u(i,["name"]);if(r!=null&&c(t,["name"],r),u(i,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(u(i,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return t}function ZT(i){const t={},l=u(i,["mode"]);l!=null&&c(t,["mode"],l);const a=u(i,["allowedFunctionNames"]);if(a!=null&&c(t,["allowedFunctionNames"],a),u(i,["streamFunctionCallArguments"])!==void 0)throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return t}function $T(i,t,l){const a={},r=u(t,["systemInstruction"]);l!==void 0&&r!=null&&c(l,["systemInstruction"],$h(it(r)));const f=u(t,["temperature"]);f!=null&&c(a,["temperature"],f);const m=u(t,["topP"]);m!=null&&c(a,["topP"],m);const g=u(t,["topK"]);g!=null&&c(a,["topK"],g);const y=u(t,["candidateCount"]);y!=null&&c(a,["candidateCount"],y);const h=u(t,["maxOutputTokens"]);h!=null&&c(a,["maxOutputTokens"],h);const v=u(t,["stopSequences"]);v!=null&&c(a,["stopSequences"],v);const S=u(t,["responseLogprobs"]);S!=null&&c(a,["responseLogprobs"],S);const E=u(t,["logprobs"]);E!=null&&c(a,["logprobs"],E);const C=u(t,["presencePenalty"]);C!=null&&c(a,["presencePenalty"],C);const U=u(t,["frequencyPenalty"]);U!=null&&c(a,["frequencyPenalty"],U);const H=u(t,["seed"]);H!=null&&c(a,["seed"],H);const b=u(t,["responseMimeType"]);b!=null&&c(a,["responseMimeType"],b);const P=u(t,["responseSchema"]);P!=null&&c(a,["responseSchema"],Gu(P));const X=u(t,["responseJsonSchema"]);if(X!=null&&c(a,["responseJsonSchema"],X),u(t,["routingConfig"])!==void 0)throw new Error("routingConfig parameter is not supported in Gemini API.");if(u(t,["modelSelectionConfig"])!==void 0)throw new Error("modelSelectionConfig parameter is not supported in Gemini API.");const k=u(t,["safetySettings"]);if(l!==void 0&&k!=null){let Ee=k;Array.isArray(Ee)&&(Ee=Ee.map(Pe=>pS(Pe))),c(l,["safetySettings"],Ee)}const K=u(t,["tools"]);if(l!==void 0&&K!=null){let Ee=to(K);Array.isArray(Ee)&&(Ee=Ee.map(Pe=>hS(eo(Pe)))),c(l,["tools"],Ee)}const ee=u(t,["toolConfig"]);if(l!==void 0&&ee!=null&&c(l,["toolConfig"],mS(ee)),u(t,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const te=u(t,["cachedContent"]);l!==void 0&&te!=null&&c(l,["cachedContent"],gn(i,te));const F=u(t,["responseModalities"]);F!=null&&c(a,["responseModalities"],F);const he=u(t,["mediaResolution"]);he!=null&&c(a,["mediaResolution"],he);const W=u(t,["speechConfig"]);if(W!=null&&c(a,["speechConfig"],Hu(W)),u(t,["audioTimestamp"])!==void 0)throw new Error("audioTimestamp parameter is not supported in Gemini API.");const de=u(t,["thinkingConfig"]);de!=null&&c(a,["thinkingConfig"],de);const Ce=u(t,["imageConfig"]);Ce!=null&&c(a,["imageConfig"],iS(Ce));const Ge=u(t,["enableEnhancedCivicAnswers"]);return Ge!=null&&c(a,["enableEnhancedCivicAnswers"],Ge),a}function WT(i){const t={},l=u(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=u(i,["candidates"]);if(a!=null){let y=a;Array.isArray(y)&&(y=y.map(h=>LT(h))),c(t,["candidates"],y)}const r=u(i,["modelVersion"]);r!=null&&c(t,["modelVersion"],r);const f=u(i,["promptFeedback"]);f!=null&&c(t,["promptFeedback"],f);const m=u(i,["responseId"]);m!=null&&c(t,["responseId"],m);const g=u(i,["usageMetadata"]);return g!=null&&c(t,["usageMetadata"],g),t}function jT(i,t){const l={},a=u(t,["name"]);return a!=null&&c(l,["_url","name"],no(i,a)),l}function eS(i,t){const l={},a=u(t,["name"]);return a!=null&&c(l,["_url","name"],no(i,a)),l}function tS(i){const t={};if(u(i,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const l=u(i,["enableWidget"]);return l!=null&&c(t,["enableWidget"],l),t}function nS(i){const t={};if(u(i,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(u(i,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const l=u(i,["timeRangeFilter"]);return l!=null&&c(t,["timeRangeFilter"],l),t}function iS(i){const t={},l=u(i,["aspectRatio"]);l!=null&&c(t,["aspectRatio"],l);const a=u(i,["imageSize"]);if(a!=null&&c(t,["imageSize"],a),u(i,["outputMimeType"])!==void 0)throw new Error("outputMimeType parameter is not supported in Gemini API.");if(u(i,["outputCompressionQuality"])!==void 0)throw new Error("outputCompressionQuality parameter is not supported in Gemini API.");return t}function oS(i,t){const l={},a=u(t,["model"]);a!=null&&c(l,["request","model"],Te(i,a));const r=u(t,["contents"]);if(r!=null){let g=Ht(r);Array.isArray(g)&&(g=g.map(y=>$h(y))),c(l,["request","contents"],g)}const f=u(t,["metadata"]);f!=null&&c(l,["metadata"],f);const m=u(t,["config"]);return m!=null&&c(l,["request","generationConfig"],$T(i,m,u(l,["request"],{}))),l}function lS(i){const t={},l=u(i,["response"]);l!=null&&c(t,["response"],WT(l));const a=u(i,["error"]);return a!=null&&c(t,["error"],a),t}function aS(i,t){const l={},a=u(i,["pageSize"]);t!==void 0&&a!=null&&c(t,["_query","pageSize"],a);const r=u(i,["pageToken"]);if(t!==void 0&&r!=null&&c(t,["_query","pageToken"],r),u(i,["filter"])!==void 0)throw new Error("filter parameter is not supported in Gemini API.");return l}function sS(i,t){const l={},a=u(i,["pageSize"]);t!==void 0&&a!=null&&c(t,["_query","pageSize"],a);const r=u(i,["pageToken"]);t!==void 0&&r!=null&&c(t,["_query","pageToken"],r);const f=u(i,["filter"]);return t!==void 0&&f!=null&&c(t,["_query","filter"],f),l}function rS(i){const t={},l=u(i,["config"]);return l!=null&&aS(l,t),t}function uS(i){const t={},l=u(i,["config"]);return l!=null&&sS(l,t),t}function cS(i){const t={},l=u(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=u(i,["nextPageToken"]);a!=null&&c(t,["nextPageToken"],a);const r=u(i,["operations"]);if(r!=null){let f=r;Array.isArray(f)&&(f=f.map(m=>Ma(m))),c(t,["batchJobs"],f)}return t}function fS(i){const t={},l=u(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=u(i,["nextPageToken"]);a!=null&&c(t,["nextPageToken"],a);const r=u(i,["batchPredictionJobs"]);if(r!=null){let f=r;Array.isArray(f)&&(f=f.map(m=>Su(m))),c(t,["batchJobs"],f)}return t}function dS(i){const t={},l=u(i,["mediaResolution"]);l!=null&&c(t,["mediaResolution"],l);const a=u(i,["codeExecutionResult"]);a!=null&&c(t,["codeExecutionResult"],a);const r=u(i,["executableCode"]);r!=null&&c(t,["executableCode"],r);const f=u(i,["fileData"]);f!=null&&c(t,["fileData"],KT(f));const m=u(i,["functionCall"]);m!=null&&c(t,["functionCall"],QT(m));const g=u(i,["functionResponse"]);g!=null&&c(t,["functionResponse"],g);const y=u(i,["inlineData"]);y!=null&&c(t,["inlineData"],UT(y));const h=u(i,["text"]);h!=null&&c(t,["text"],h);const v=u(i,["thought"]);v!=null&&c(t,["thought"],v);const S=u(i,["thoughtSignature"]);S!=null&&c(t,["thoughtSignature"],S);const E=u(i,["videoMetadata"]);return E!=null&&c(t,["videoMetadata"],E),t}function pS(i){const t={},l=u(i,["category"]);if(l!=null&&c(t,["category"],l),u(i,["method"])!==void 0)throw new Error("method parameter is not supported in Gemini API.");const a=u(i,["threshold"]);return a!=null&&c(t,["threshold"],a),t}function mS(i){const t={},l=u(i,["functionCallingConfig"]);l!=null&&c(t,["functionCallingConfig"],ZT(l));const a=u(i,["retrievalConfig"]);return a!=null&&c(t,["retrievalConfig"],a),t}function hS(i){const t={},l=u(i,["functionDeclarations"]);if(l!=null){let v=l;Array.isArray(v)&&(v=v.map(S=>S)),c(t,["functionDeclarations"],v)}if(u(i,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const a=u(i,["googleSearchRetrieval"]);a!=null&&c(t,["googleSearchRetrieval"],a);const r=u(i,["computerUse"]);r!=null&&c(t,["computerUse"],r);const f=u(i,["fileSearch"]);f!=null&&c(t,["fileSearch"],f);const m=u(i,["codeExecution"]);if(m!=null&&c(t,["codeExecution"],m),u(i,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const g=u(i,["googleMaps"]);g!=null&&c(t,["googleMaps"],tS(g));const y=u(i,["googleSearch"]);y!=null&&c(t,["googleSearch"],nS(y));const h=u(i,["urlContext"]);return h!=null&&c(t,["urlContext"],h),t}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */var mn;(function(i){i.PAGED_ITEM_BATCH_JOBS="batchJobs",i.PAGED_ITEM_MODELS="models",i.PAGED_ITEM_TUNING_JOBS="tuningJobs",i.PAGED_ITEM_FILES="files",i.PAGED_ITEM_CACHED_CONTENTS="cachedContents",i.PAGED_ITEM_FILE_SEARCH_STORES="fileSearchStores",i.PAGED_ITEM_DOCUMENTS="documents"})(mn||(mn={}));class ci{constructor(t,l,a,r){this.pageInternal=[],this.paramsInternal={},this.requestInternal=l,this.init(t,a,r)}init(t,l,a){var r,f;this.nameInternal=t,this.pageInternal=l[this.nameInternal]||[],this.sdkHttpResponseInternal=l==null?void 0:l.sdkHttpResponse,this.idxInternal=0;let m={config:{}};!a||Object.keys(a).length===0?m={config:{}}:typeof a=="object"?m=Object.assign({},a):m=a,m.config&&(m.config.pageToken=l.nextPageToken),this.paramsInternal=m,this.pageInternalSize=(f=(r=m.config)===null||r===void 0?void 0:r.pageSize)!==null&&f!==void 0?f:this.pageInternal.length}initNextPage(t){this.init(this.nameInternal,t,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(t){return this.pageInternal[t]}[Symbol.asyncIterator](){return{next:async()=>{if(this.idxInternal>=this.pageLength)if(this.hasNextPage())await this.nextPage();else return{value:void 0,done:!0};const t=this.getItem(this.idxInternal);return this.idxInternal+=1,{value:t,done:!1}},return:async()=>({value:void 0,done:!0})}}async nextPage(){if(!this.hasNextPage())throw new Error("No more pages to fetch.");const t=await this.requestInternal(this.params);return this.initNextPage(t),this.page}hasNextPage(){var t;return((t=this.params.config)===null||t===void 0?void 0:t.pageToken)!==void 0}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class gS extends hn{constructor(t){super(),this.apiClient=t,this.list=async(l={})=>new ci(mn.PAGED_ITEM_BATCH_JOBS,a=>this.listInternal(a),await this.listInternal(l),l),this.create=async l=>(this.apiClient.isVertexAI()&&(l.config=this.formatDestination(l.src,l.config)),this.createInternal(l)),this.createEmbeddings=async l=>{if(console.warn("batches.createEmbeddings() is experimental and may change without notice."),this.apiClient.isVertexAI())throw new Error("Vertex AI does not support batches.createEmbeddings.");return this.createEmbeddingsInternal(l)}}createInlinedGenerateContentRequest(t){const l=dh(this.apiClient,t),a=l._url,r=Y("{model}:batchGenerateContent",a),g=l.batch.inputConfig.requests,y=g.requests,h=[];for(const v of y){const S=Object.assign({},v);if(S.systemInstruction){const E=S.systemInstruction;delete S.systemInstruction;const C=S.request;C.systemInstruction=E,S.request=C}h.push(S)}return g.requests=h,delete l.config,delete l._url,delete l._query,{path:r,body:l}}getGcsUri(t){if(typeof t=="string")return t.startsWith("gs://")?t:void 0;if(!Array.isArray(t)&&t.gcsUri&&t.gcsUri.length>0)return t.gcsUri[0]}getBigqueryUri(t){if(typeof t=="string")return t.startsWith("bq://")?t:void 0;if(!Array.isArray(t))return t.bigqueryUri}formatDestination(t,l){const a=l?Object.assign({},l):{},r=Date.now().toString();if(a.displayName||(a.displayName=`genaiBatchJob_${r}`),a.dest===void 0){const f=this.getGcsUri(t),m=this.getBigqueryUri(t);if(f)f.endsWith(".jsonl")?a.dest=`${f.slice(0,-6)}/dest`:a.dest=`${f}_dest_${r}`;else if(m)a.dest=`${m}_dest_${r}`;else throw new Error("Unsupported source for Vertex AI: No GCS or BigQuery URI found.")}return a}async createInternal(t){var l,a,r,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=VT(this.apiClient,t);return g=Y("batchPredictionJobs",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json()),m.then(v=>Su(v))}else{const h=dh(this.apiClient,t);return g=Y("{model}:batchGenerateContent",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json()),m.then(v=>Ma(v))}}async createEmbeddingsInternal(t){var l,a;let r,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=BT(this.apiClient,t);return f=Y("{model}:asyncBatchEmbedContent",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json()),r.then(y=>Ma(y))}}async get(t){var l,a,r,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=eS(this.apiClient,t);return g=Y("batchPredictionJobs/{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json()),m.then(v=>Su(v))}else{const h=jT(this.apiClient,t);return g=Y("batches/{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json()),m.then(v=>Ma(v))}}async cancel(t){var l,a,r,f;let m="",g={};if(this.apiClient.isVertexAI()){const y=bT(this.apiClient,t);m=Y("batchPredictionJobs/{name}:cancel",y._url),g=y._query,delete y._url,delete y._query,await this.apiClient.request({path:m,queryParams:g,body:JSON.stringify(y),httpMethod:"POST",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal})}else{const y=wT(this.apiClient,t);m=Y("batches/{name}:cancel",y._url),g=y._query,delete y._url,delete y._query,await this.apiClient.request({path:m,queryParams:g,body:JSON.stringify(y),httpMethod:"POST",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal})}}async listInternal(t){var l,a,r,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=uS(t);return g=Y("batchPredictionJobs",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json().then(S=>{const E=S;return E.sdkHttpResponse={headers:v.headers},E})),m.then(v=>{const S=fS(v),E=new rh;return Object.assign(E,S),E})}else{const h=rS(t);return g=Y("batches",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json().then(S=>{const E=S;return E.sdkHttpResponse={headers:v.headers},E})),m.then(v=>{const S=cS(v),E=new rh;return Object.assign(E,S),E})}}async delete(t){var l,a,r,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=kT(this.apiClient,t);return g=Y("batchPredictionJobs/{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"DELETE",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json().then(S=>{const E=S;return E.sdkHttpResponse={headers:v.headers},E})),m.then(v=>FT(v))}else{const h=PT(this.apiClient,t);return g=Y("batches/{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"DELETE",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json().then(S=>{const E=S;return E.sdkHttpResponse={headers:v.headers},E})),m.then(v=>OT(v))}}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function yS(i){const t={},l=u(i,["data"]);if(l!=null&&c(t,["data"],l),u(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const a=u(i,["mimeType"]);return a!=null&&c(t,["mimeType"],a),t}function ph(i){const t={},l=u(i,["parts"]);if(l!=null){let r=l;Array.isArray(r)&&(r=r.map(f=>BS(f))),c(t,["parts"],r)}const a=u(i,["role"]);return a!=null&&c(t,["role"],a),t}function vS(i,t){const l={},a=u(i,["ttl"]);t!==void 0&&a!=null&&c(t,["ttl"],a);const r=u(i,["expireTime"]);t!==void 0&&r!=null&&c(t,["expireTime"],r);const f=u(i,["displayName"]);t!==void 0&&f!=null&&c(t,["displayName"],f);const m=u(i,["contents"]);if(t!==void 0&&m!=null){let v=Ht(m);Array.isArray(v)&&(v=v.map(S=>ph(S))),c(t,["contents"],v)}const g=u(i,["systemInstruction"]);t!==void 0&&g!=null&&c(t,["systemInstruction"],ph(it(g)));const y=u(i,["tools"]);if(t!==void 0&&y!=null){let v=y;Array.isArray(v)&&(v=v.map(S=>kS(S))),c(t,["tools"],v)}const h=u(i,["toolConfig"]);if(t!==void 0&&h!=null&&c(t,["toolConfig"],PS(h)),u(i,["kmsKeyName"])!==void 0)throw new Error("kmsKeyName parameter is not supported in Gemini API.");return l}function TS(i,t){const l={},a=u(i,["ttl"]);t!==void 0&&a!=null&&c(t,["ttl"],a);const r=u(i,["expireTime"]);t!==void 0&&r!=null&&c(t,["expireTime"],r);const f=u(i,["displayName"]);t!==void 0&&f!=null&&c(t,["displayName"],f);const m=u(i,["contents"]);if(t!==void 0&&m!=null){let S=Ht(m);Array.isArray(S)&&(S=S.map(E=>E)),c(t,["contents"],S)}const g=u(i,["systemInstruction"]);t!==void 0&&g!=null&&c(t,["systemInstruction"],it(g));const y=u(i,["tools"]);if(t!==void 0&&y!=null){let S=y;Array.isArray(S)&&(S=S.map(E=>OS(E))),c(t,["tools"],S)}const h=u(i,["toolConfig"]);t!==void 0&&h!=null&&c(t,["toolConfig"],h);const v=u(i,["kmsKeyName"]);return t!==void 0&&v!=null&&c(t,["encryption_spec","kmsKeyName"],v),l}function SS(i,t){const l={},a=u(t,["model"]);a!=null&&c(l,["model"],zh(i,a));const r=u(t,["config"]);return r!=null&&vS(r,l),l}function ES(i,t){const l={},a=u(t,["model"]);a!=null&&c(l,["model"],zh(i,a));const r=u(t,["config"]);return r!=null&&TS(r,l),l}function _S(i,t){const l={},a=u(t,["name"]);return a!=null&&c(l,["_url","name"],gn(i,a)),l}function CS(i,t){const l={},a=u(t,["name"]);return a!=null&&c(l,["_url","name"],gn(i,a)),l}function AS(i){const t={},l=u(i,["sdkHttpResponse"]);return l!=null&&c(t,["sdkHttpResponse"],l),t}function RS(i){const t={},l=u(i,["sdkHttpResponse"]);return l!=null&&c(t,["sdkHttpResponse"],l),t}function MS(i){const t={};if(u(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const l=u(i,["fileUri"]);l!=null&&c(t,["fileUri"],l);const a=u(i,["mimeType"]);return a!=null&&c(t,["mimeType"],a),t}function NS(i){const t={},l=u(i,["id"]);l!=null&&c(t,["id"],l);const a=u(i,["args"]);a!=null&&c(t,["args"],a);const r=u(i,["name"]);if(r!=null&&c(t,["name"],r),u(i,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(u(i,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return t}function IS(i){const t={},l=u(i,["mode"]);l!=null&&c(t,["mode"],l);const a=u(i,["allowedFunctionNames"]);if(a!=null&&c(t,["allowedFunctionNames"],a),u(i,["streamFunctionCallArguments"])!==void 0)throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return t}function xS(i){const t={};if(u(i,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");const l=u(i,["description"]);l!=null&&c(t,["description"],l);const a=u(i,["name"]);a!=null&&c(t,["name"],a);const r=u(i,["parameters"]);r!=null&&c(t,["parameters"],r);const f=u(i,["parametersJsonSchema"]);f!=null&&c(t,["parametersJsonSchema"],f);const m=u(i,["response"]);m!=null&&c(t,["response"],m);const g=u(i,["responseJsonSchema"]);return g!=null&&c(t,["responseJsonSchema"],g),t}function DS(i,t){const l={},a=u(t,["name"]);return a!=null&&c(l,["_url","name"],gn(i,a)),l}function US(i,t){const l={},a=u(t,["name"]);return a!=null&&c(l,["_url","name"],gn(i,a)),l}function wS(i){const t={};if(u(i,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const l=u(i,["enableWidget"]);return l!=null&&c(t,["enableWidget"],l),t}function bS(i){const t={};if(u(i,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(u(i,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const l=u(i,["timeRangeFilter"]);return l!=null&&c(t,["timeRangeFilter"],l),t}function LS(i,t){const l={},a=u(i,["pageSize"]);t!==void 0&&a!=null&&c(t,["_query","pageSize"],a);const r=u(i,["pageToken"]);return t!==void 0&&r!=null&&c(t,["_query","pageToken"],r),l}function GS(i,t){const l={},a=u(i,["pageSize"]);t!==void 0&&a!=null&&c(t,["_query","pageSize"],a);const r=u(i,["pageToken"]);return t!==void 0&&r!=null&&c(t,["_query","pageToken"],r),l}function HS(i){const t={},l=u(i,["config"]);return l!=null&&LS(l,t),t}function qS(i){const t={},l=u(i,["config"]);return l!=null&&GS(l,t),t}function VS(i){const t={},l=u(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=u(i,["nextPageToken"]);a!=null&&c(t,["nextPageToken"],a);const r=u(i,["cachedContents"]);if(r!=null){let f=r;Array.isArray(f)&&(f=f.map(m=>m)),c(t,["cachedContents"],f)}return t}function zS(i){const t={},l=u(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=u(i,["nextPageToken"]);a!=null&&c(t,["nextPageToken"],a);const r=u(i,["cachedContents"]);if(r!=null){let f=r;Array.isArray(f)&&(f=f.map(m=>m)),c(t,["cachedContents"],f)}return t}function BS(i){const t={},l=u(i,["mediaResolution"]);l!=null&&c(t,["mediaResolution"],l);const a=u(i,["codeExecutionResult"]);a!=null&&c(t,["codeExecutionResult"],a);const r=u(i,["executableCode"]);r!=null&&c(t,["executableCode"],r);const f=u(i,["fileData"]);f!=null&&c(t,["fileData"],MS(f));const m=u(i,["functionCall"]);m!=null&&c(t,["functionCall"],NS(m));const g=u(i,["functionResponse"]);g!=null&&c(t,["functionResponse"],g);const y=u(i,["inlineData"]);y!=null&&c(t,["inlineData"],yS(y));const h=u(i,["text"]);h!=null&&c(t,["text"],h);const v=u(i,["thought"]);v!=null&&c(t,["thought"],v);const S=u(i,["thoughtSignature"]);S!=null&&c(t,["thoughtSignature"],S);const E=u(i,["videoMetadata"]);return E!=null&&c(t,["videoMetadata"],E),t}function PS(i){const t={},l=u(i,["functionCallingConfig"]);l!=null&&c(t,["functionCallingConfig"],IS(l));const a=u(i,["retrievalConfig"]);return a!=null&&c(t,["retrievalConfig"],a),t}function kS(i){const t={},l=u(i,["functionDeclarations"]);if(l!=null){let v=l;Array.isArray(v)&&(v=v.map(S=>S)),c(t,["functionDeclarations"],v)}if(u(i,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const a=u(i,["googleSearchRetrieval"]);a!=null&&c(t,["googleSearchRetrieval"],a);const r=u(i,["computerUse"]);r!=null&&c(t,["computerUse"],r);const f=u(i,["fileSearch"]);f!=null&&c(t,["fileSearch"],f);const m=u(i,["codeExecution"]);if(m!=null&&c(t,["codeExecution"],m),u(i,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const g=u(i,["googleMaps"]);g!=null&&c(t,["googleMaps"],wS(g));const y=u(i,["googleSearch"]);y!=null&&c(t,["googleSearch"],bS(y));const h=u(i,["urlContext"]);return h!=null&&c(t,["urlContext"],h),t}function OS(i){const t={},l=u(i,["functionDeclarations"]);if(l!=null){let S=l;Array.isArray(S)&&(S=S.map(E=>xS(E))),c(t,["functionDeclarations"],S)}const a=u(i,["retrieval"]);a!=null&&c(t,["retrieval"],a);const r=u(i,["googleSearchRetrieval"]);r!=null&&c(t,["googleSearchRetrieval"],r);const f=u(i,["computerUse"]);if(f!=null&&c(t,["computerUse"],f),u(i,["fileSearch"])!==void 0)throw new Error("fileSearch parameter is not supported in Vertex AI.");const m=u(i,["codeExecution"]);m!=null&&c(t,["codeExecution"],m);const g=u(i,["enterpriseWebSearch"]);g!=null&&c(t,["enterpriseWebSearch"],g);const y=u(i,["googleMaps"]);y!=null&&c(t,["googleMaps"],y);const h=u(i,["googleSearch"]);h!=null&&c(t,["googleSearch"],h);const v=u(i,["urlContext"]);return v!=null&&c(t,["urlContext"],v),t}function FS(i,t){const l={},a=u(i,["ttl"]);t!==void 0&&a!=null&&c(t,["ttl"],a);const r=u(i,["expireTime"]);return t!==void 0&&r!=null&&c(t,["expireTime"],r),l}function JS(i,t){const l={},a=u(i,["ttl"]);t!==void 0&&a!=null&&c(t,["ttl"],a);const r=u(i,["expireTime"]);return t!==void 0&&r!=null&&c(t,["expireTime"],r),l}function YS(i,t){const l={},a=u(t,["name"]);a!=null&&c(l,["_url","name"],gn(i,a));const r=u(t,["config"]);return r!=null&&FS(r,l),l}function XS(i,t){const l={},a=u(t,["name"]);a!=null&&c(l,["_url","name"],gn(i,a));const r=u(t,["config"]);return r!=null&&JS(r,l),l}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class KS extends hn{constructor(t){super(),this.apiClient=t,this.list=async(l={})=>new ci(mn.PAGED_ITEM_CACHED_CONTENTS,a=>this.listInternal(a),await this.listInternal(l),l)}async create(t){var l,a,r,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=ES(this.apiClient,t);return g=Y("cachedContents",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json()),m.then(v=>v)}else{const h=SS(this.apiClient,t);return g=Y("cachedContents",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json()),m.then(v=>v)}}async get(t){var l,a,r,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=US(this.apiClient,t);return g=Y("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json()),m.then(v=>v)}else{const h=DS(this.apiClient,t);return g=Y("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json()),m.then(v=>v)}}async delete(t){var l,a,r,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=CS(this.apiClient,t);return g=Y("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"DELETE",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json().then(S=>{const E=S;return E.sdkHttpResponse={headers:v.headers},E})),m.then(v=>{const S=RS(v),E=new ah;return Object.assign(E,S),E})}else{const h=_S(this.apiClient,t);return g=Y("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"DELETE",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json().then(S=>{const E=S;return E.sdkHttpResponse={headers:v.headers},E})),m.then(v=>{const S=AS(v),E=new ah;return Object.assign(E,S),E})}}async update(t){var l,a,r,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=XS(this.apiClient,t);return g=Y("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"PATCH",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json()),m.then(v=>v)}else{const h=YS(this.apiClient,t);return g=Y("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"PATCH",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json()),m.then(v=>v)}}async listInternal(t){var l,a,r,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=qS(t);return g=Y("cachedContents",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json().then(S=>{const E=S;return E.sdkHttpResponse={headers:v.headers},E})),m.then(v=>{const S=zS(v),E=new sh;return Object.assign(E,S),E})}else{const h=HS(t);return g=Y("cachedContents",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json().then(S=>{const E=S;return E.sdkHttpResponse={headers:v.headers},E})),m.then(v=>{const S=VS(v),E=new sh;return Object.assign(E,S),E})}}}function Ua(i,t){var l={};for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&t.indexOf(a)<0&&(l[a]=i[a]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,a=Object.getOwnPropertySymbols(i);r=i.length&&(i=void 0),{value:i&&i[a++],done:!i}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function oe(i){return this instanceof oe?(this.v=i,this):new oe(i)}function Pt(i,t,l){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var a=l.apply(i,t||[]),r,f=[];return r=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),g("next"),g("throw"),g("return",m),r[Symbol.asyncIterator]=function(){return this},r;function m(C){return function(U){return Promise.resolve(U).then(C,S)}}function g(C,U){a[C]&&(r[C]=function(H){return new Promise(function(b,P){f.push([C,H,b,P])>1||y(C,H)})},U&&(r[C]=U(r[C])))}function y(C,U){try{h(a[C](U))}catch(H){E(f[0][3],H)}}function h(C){C.value instanceof oe?Promise.resolve(C.value.v).then(v,S):E(f[0][2],C)}function v(C){y("next",C)}function S(C){y("throw",C)}function E(C,U){C(U),f.shift(),f.length&&y(f[0][0],f[0][1])}}function kt(i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=i[Symbol.asyncIterator],l;return t?t.call(i):(i=typeof mh=="function"?mh(i):i[Symbol.iterator](),l={},a("next"),a("throw"),a("return"),l[Symbol.asyncIterator]=function(){return this},l);function a(f){l[f]=i[f]&&function(m){return new Promise(function(g,y){m=i[f](m),r(g,y,m.done,m.value)})}}function r(f,m,g,y){Promise.resolve(y).then(function(h){f({value:h,done:g})},m)}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function QS(i){var t;if(i.candidates==null||i.candidates.length===0)return!1;const l=(t=i.candidates[0])===null||t===void 0?void 0:t.content;return l===void 0?!1:Wh(l)}function Wh(i){if(i.parts===void 0||i.parts.length===0)return!1;for(const t of i.parts)if(t===void 0||Object.keys(t).length===0)return!1;return!0}function ZS(i){if(i.length!==0){for(const t of i)if(t.role!=="user"&&t.role!=="model")throw new Error(`Role must be user or model, but got ${t.role}.`)}}function hh(i){if(i===void 0||i.length===0)return[];const t=[],l=i.length;let a=0;for(;a{var f,m,g;const y=await r,h=(m=(f=y.candidates)===null||f===void 0?void 0:f[0])===null||m===void 0?void 0:m.content,v=y.automaticFunctionCallingHistory,S=this.getHistory(!0).length;let E=[];v!=null&&(E=(g=v.slice(S))!==null&&g!==void 0?g:[]);const C=h?[h]:[];this.recordHistory(a,C,E)})(),await this.sendPromise.catch(()=>{this.sendPromise=Promise.resolve()}),r}async sendMessageStream(t){var l;await this.sendPromise;const a=it(t.message),r=this.modelsModule.generateContentStream({model:this.model,contents:this.getHistory(!0).concat(a),config:(l=t.config)!==null&&l!==void 0?l:this.config});this.sendPromise=r.then(()=>{}).catch(()=>{});const f=await r;return this.processStreamResponse(f,a)}getHistory(t=!1){const l=t?hh(this.history):this.history;return structuredClone(l)}processStreamResponse(t,l){return Pt(this,arguments,function*(){var r,f,m,g,y,h;const v=[];try{for(var S=!0,E=kt(t),C;C=yield oe(E.next()),r=C.done,!r;S=!0){g=C.value,S=!1;const U=g;if(QS(U)){const H=(h=(y=U.candidates)===null||y===void 0?void 0:y[0])===null||h===void 0?void 0:h.content;H!==void 0&&v.push(H)}yield yield oe(U)}}catch(U){f={error:U}}finally{try{!S&&!r&&(m=E.return)&&(yield oe(m.call(E)))}finally{if(f)throw f.error}}this.recordHistory(l,v)})}recordHistory(t,l,a){let r=[];l.length>0&&l.every(f=>f.role!==void 0)?r=l:r.push({role:"model",parts:[]}),a&&a.length>0?this.history.push(...hh(a)):this.history.push(t),this.history.push(...r)}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class La extends Error{constructor(t){super(t.message),this.name="ApiError",this.status=t.status,Object.setPrototypeOf(this,La.prototype)}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function jS(i){const t={},l=u(i,["file"]);return l!=null&&c(t,["file"],l),t}function eE(i){const t={},l=u(i,["sdkHttpResponse"]);return l!=null&&c(t,["sdkHttpResponse"],l),t}function tE(i){const t={},l=u(i,["name"]);return l!=null&&c(t,["_url","file"],Jh(l)),t}function nE(i){const t={},l=u(i,["sdkHttpResponse"]);return l!=null&&c(t,["sdkHttpResponse"],l),t}function iE(i){const t={},l=u(i,["name"]);return l!=null&&c(t,["_url","file"],Jh(l)),t}function oE(i,t){const l={},a=u(i,["pageSize"]);t!==void 0&&a!=null&&c(t,["_query","pageSize"],a);const r=u(i,["pageToken"]);return t!==void 0&&r!=null&&c(t,["_query","pageToken"],r),l}function lE(i){const t={},l=u(i,["config"]);return l!=null&&oE(l,t),t}function aE(i){const t={},l=u(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=u(i,["nextPageToken"]);a!=null&&c(t,["nextPageToken"],a);const r=u(i,["files"]);if(r!=null){let f=r;Array.isArray(f)&&(f=f.map(m=>m)),c(t,["files"],f)}return t}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class sE extends hn{constructor(t){super(),this.apiClient=t,this.list=async(l={})=>new ci(mn.PAGED_ITEM_FILES,a=>this.listInternal(a),await this.listInternal(l),l)}async upload(t){if(this.apiClient.isVertexAI())throw new Error("Vertex AI does not support uploading files. You can share files through a GCS bucket.");return this.apiClient.uploadFile(t.file,t.config).then(l=>l)}async download(t){await this.apiClient.downloadFile(t)}async listInternal(t){var l,a;let r,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=lE(t);return f=Y("files",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"GET",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json().then(h=>{const v=h;return v.sdkHttpResponse={headers:y.headers},v})),r.then(y=>{const h=aE(y),v=new fT;return Object.assign(v,h),v})}}async createInternal(t){var l,a;let r,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=jS(t);return f=Y("upload/v1beta/files",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json()),r.then(y=>{const h=eE(y),v=new dT;return Object.assign(v,h),v})}}async get(t){var l,a;let r,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=iE(t);return f=Y("files/{file}",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"GET",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json()),r.then(y=>y)}}async delete(t){var l,a;let r,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=tE(t);return f=Y("files/{file}",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"DELETE",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json().then(h=>{const v=h;return v.sdkHttpResponse={headers:y.headers},v})),r.then(y=>{const h=nE(y),v=new pT;return Object.assign(v,h),v})}}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function Na(i){const t={},l=u(i,["data"]);if(l!=null&&c(t,["data"],l),u(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const a=u(i,["mimeType"]);return a!=null&&c(t,["mimeType"],a),t}function rE(i){const t={},l=u(i,["parts"]);if(l!=null){let r=l;Array.isArray(r)&&(r=r.map(f=>AE(f))),c(t,["parts"],r)}const a=u(i,["role"]);return a!=null&&c(t,["role"],a),t}function uE(i){const t={};if(u(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const l=u(i,["fileUri"]);l!=null&&c(t,["fileUri"],l);const a=u(i,["mimeType"]);return a!=null&&c(t,["mimeType"],a),t}function cE(i){const t={},l=u(i,["id"]);l!=null&&c(t,["id"],l);const a=u(i,["args"]);a!=null&&c(t,["args"],a);const r=u(i,["name"]);if(r!=null&&c(t,["name"],r),u(i,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(u(i,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return t}function fE(i){const t={};if(u(i,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");const l=u(i,["description"]);l!=null&&c(t,["description"],l);const a=u(i,["name"]);a!=null&&c(t,["name"],a);const r=u(i,["parameters"]);r!=null&&c(t,["parameters"],r);const f=u(i,["parametersJsonSchema"]);f!=null&&c(t,["parametersJsonSchema"],f);const m=u(i,["response"]);m!=null&&c(t,["response"],m);const g=u(i,["responseJsonSchema"]);return g!=null&&c(t,["responseJsonSchema"],g),t}function dE(i){const t={},l=u(i,["modelSelectionConfig"]);l!=null&&c(t,["modelConfig"],l);const a=u(i,["responseJsonSchema"]);a!=null&&c(t,["responseJsonSchema"],a);const r=u(i,["audioTimestamp"]);r!=null&&c(t,["audioTimestamp"],r);const f=u(i,["candidateCount"]);f!=null&&c(t,["candidateCount"],f);const m=u(i,["enableAffectiveDialog"]);m!=null&&c(t,["enableAffectiveDialog"],m);const g=u(i,["frequencyPenalty"]);g!=null&&c(t,["frequencyPenalty"],g);const y=u(i,["logprobs"]);y!=null&&c(t,["logprobs"],y);const h=u(i,["maxOutputTokens"]);h!=null&&c(t,["maxOutputTokens"],h);const v=u(i,["mediaResolution"]);v!=null&&c(t,["mediaResolution"],v);const S=u(i,["presencePenalty"]);S!=null&&c(t,["presencePenalty"],S);const E=u(i,["responseLogprobs"]);E!=null&&c(t,["responseLogprobs"],E);const C=u(i,["responseMimeType"]);C!=null&&c(t,["responseMimeType"],C);const U=u(i,["responseModalities"]);U!=null&&c(t,["responseModalities"],U);const H=u(i,["responseSchema"]);H!=null&&c(t,["responseSchema"],H);const b=u(i,["routingConfig"]);b!=null&&c(t,["routingConfig"],b);const P=u(i,["seed"]);P!=null&&c(t,["seed"],P);const X=u(i,["speechConfig"]);X!=null&&c(t,["speechConfig"],X);const k=u(i,["stopSequences"]);k!=null&&c(t,["stopSequences"],k);const K=u(i,["temperature"]);K!=null&&c(t,["temperature"],K);const ee=u(i,["thinkingConfig"]);ee!=null&&c(t,["thinkingConfig"],ee);const te=u(i,["topK"]);te!=null&&c(t,["topK"],te);const F=u(i,["topP"]);if(F!=null&&c(t,["topP"],F),u(i,["enableEnhancedCivicAnswers"])!==void 0)throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");return t}function pE(i){const t={};if(u(i,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const l=u(i,["enableWidget"]);return l!=null&&c(t,["enableWidget"],l),t}function mE(i){const t={};if(u(i,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(u(i,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const l=u(i,["timeRangeFilter"]);return l!=null&&c(t,["timeRangeFilter"],l),t}function hE(i,t){const l={},a=u(i,["generationConfig"]);t!==void 0&&a!=null&&c(t,["setup","generationConfig"],a);const r=u(i,["responseModalities"]);t!==void 0&&r!=null&&c(t,["setup","generationConfig","responseModalities"],r);const f=u(i,["temperature"]);t!==void 0&&f!=null&&c(t,["setup","generationConfig","temperature"],f);const m=u(i,["topP"]);t!==void 0&&m!=null&&c(t,["setup","generationConfig","topP"],m);const g=u(i,["topK"]);t!==void 0&&g!=null&&c(t,["setup","generationConfig","topK"],g);const y=u(i,["maxOutputTokens"]);t!==void 0&&y!=null&&c(t,["setup","generationConfig","maxOutputTokens"],y);const h=u(i,["mediaResolution"]);t!==void 0&&h!=null&&c(t,["setup","generationConfig","mediaResolution"],h);const v=u(i,["seed"]);t!==void 0&&v!=null&&c(t,["setup","generationConfig","seed"],v);const S=u(i,["speechConfig"]);t!==void 0&&S!=null&&c(t,["setup","generationConfig","speechConfig"],qu(S));const E=u(i,["thinkingConfig"]);t!==void 0&&E!=null&&c(t,["setup","generationConfig","thinkingConfig"],E);const C=u(i,["enableAffectiveDialog"]);t!==void 0&&C!=null&&c(t,["setup","generationConfig","enableAffectiveDialog"],C);const U=u(i,["systemInstruction"]);t!==void 0&&U!=null&&c(t,["setup","systemInstruction"],rE(it(U)));const H=u(i,["tools"]);if(t!==void 0&&H!=null){let te=to(H);Array.isArray(te)&&(te=te.map(F=>ME(eo(F)))),c(t,["setup","tools"],te)}const b=u(i,["sessionResumption"]);t!==void 0&&b!=null&&c(t,["setup","sessionResumption"],RE(b));const P=u(i,["inputAudioTranscription"]);t!==void 0&&P!=null&&c(t,["setup","inputAudioTranscription"],P);const X=u(i,["outputAudioTranscription"]);t!==void 0&&X!=null&&c(t,["setup","outputAudioTranscription"],X);const k=u(i,["realtimeInputConfig"]);t!==void 0&&k!=null&&c(t,["setup","realtimeInputConfig"],k);const K=u(i,["contextWindowCompression"]);t!==void 0&&K!=null&&c(t,["setup","contextWindowCompression"],K);const ee=u(i,["proactivity"]);if(t!==void 0&&ee!=null&&c(t,["setup","proactivity"],ee),u(i,["explicitVadSignal"])!==void 0)throw new Error("explicitVadSignal parameter is not supported in Gemini API.");return l}function gE(i,t){const l={},a=u(i,["generationConfig"]);t!==void 0&&a!=null&&c(t,["setup","generationConfig"],dE(a));const r=u(i,["responseModalities"]);t!==void 0&&r!=null&&c(t,["setup","generationConfig","responseModalities"],r);const f=u(i,["temperature"]);t!==void 0&&f!=null&&c(t,["setup","generationConfig","temperature"],f);const m=u(i,["topP"]);t!==void 0&&m!=null&&c(t,["setup","generationConfig","topP"],m);const g=u(i,["topK"]);t!==void 0&&g!=null&&c(t,["setup","generationConfig","topK"],g);const y=u(i,["maxOutputTokens"]);t!==void 0&&y!=null&&c(t,["setup","generationConfig","maxOutputTokens"],y);const h=u(i,["mediaResolution"]);t!==void 0&&h!=null&&c(t,["setup","generationConfig","mediaResolution"],h);const v=u(i,["seed"]);t!==void 0&&v!=null&&c(t,["setup","generationConfig","seed"],v);const S=u(i,["speechConfig"]);t!==void 0&&S!=null&&c(t,["setup","generationConfig","speechConfig"],qu(S));const E=u(i,["thinkingConfig"]);t!==void 0&&E!=null&&c(t,["setup","generationConfig","thinkingConfig"],E);const C=u(i,["enableAffectiveDialog"]);t!==void 0&&C!=null&&c(t,["setup","generationConfig","enableAffectiveDialog"],C);const U=u(i,["systemInstruction"]);t!==void 0&&U!=null&&c(t,["setup","systemInstruction"],it(U));const H=u(i,["tools"]);if(t!==void 0&&H!=null){let F=to(H);Array.isArray(F)&&(F=F.map(he=>NE(eo(he)))),c(t,["setup","tools"],F)}const b=u(i,["sessionResumption"]);t!==void 0&&b!=null&&c(t,["setup","sessionResumption"],b);const P=u(i,["inputAudioTranscription"]);t!==void 0&&P!=null&&c(t,["setup","inputAudioTranscription"],P);const X=u(i,["outputAudioTranscription"]);t!==void 0&&X!=null&&c(t,["setup","outputAudioTranscription"],X);const k=u(i,["realtimeInputConfig"]);t!==void 0&&k!=null&&c(t,["setup","realtimeInputConfig"],k);const K=u(i,["contextWindowCompression"]);t!==void 0&&K!=null&&c(t,["setup","contextWindowCompression"],K);const ee=u(i,["proactivity"]);t!==void 0&&ee!=null&&c(t,["setup","proactivity"],ee);const te=u(i,["explicitVadSignal"]);return t!==void 0&&te!=null&&c(t,["setup","explicitVadSignal"],te),l}function yE(i,t){const l={},a=u(t,["model"]);a!=null&&c(l,["setup","model"],Te(i,a));const r=u(t,["config"]);return r!=null&&c(l,["config"],hE(r,l)),l}function vE(i,t){const l={},a=u(t,["model"]);a!=null&&c(l,["setup","model"],Te(i,a));const r=u(t,["config"]);return r!=null&&c(l,["config"],gE(r,l)),l}function TE(i){const t={},l=u(i,["musicGenerationConfig"]);return l!=null&&c(t,["musicGenerationConfig"],l),t}function SE(i){const t={},l=u(i,["weightedPrompts"]);if(l!=null){let a=l;Array.isArray(a)&&(a=a.map(r=>r)),c(t,["weightedPrompts"],a)}return t}function EE(i){const t={},l=u(i,["media"]);if(l!=null){let h=Bh(l);Array.isArray(h)&&(h=h.map(v=>Na(v))),c(t,["mediaChunks"],h)}const a=u(i,["audio"]);a!=null&&c(t,["audio"],Na(kh(a)));const r=u(i,["audioStreamEnd"]);r!=null&&c(t,["audioStreamEnd"],r);const f=u(i,["video"]);f!=null&&c(t,["video"],Na(Ph(f)));const m=u(i,["text"]);m!=null&&c(t,["text"],m);const g=u(i,["activityStart"]);g!=null&&c(t,["activityStart"],g);const y=u(i,["activityEnd"]);return y!=null&&c(t,["activityEnd"],y),t}function _E(i){const t={},l=u(i,["media"]);if(l!=null){let h=Bh(l);Array.isArray(h)&&(h=h.map(v=>v)),c(t,["mediaChunks"],h)}const a=u(i,["audio"]);a!=null&&c(t,["audio"],kh(a));const r=u(i,["audioStreamEnd"]);r!=null&&c(t,["audioStreamEnd"],r);const f=u(i,["video"]);f!=null&&c(t,["video"],Ph(f));const m=u(i,["text"]);m!=null&&c(t,["text"],m);const g=u(i,["activityStart"]);g!=null&&c(t,["activityStart"],g);const y=u(i,["activityEnd"]);return y!=null&&c(t,["activityEnd"],y),t}function CE(i){const t={},l=u(i,["setupComplete"]);l!=null&&c(t,["setupComplete"],l);const a=u(i,["serverContent"]);a!=null&&c(t,["serverContent"],a);const r=u(i,["toolCall"]);r!=null&&c(t,["toolCall"],r);const f=u(i,["toolCallCancellation"]);f!=null&&c(t,["toolCallCancellation"],f);const m=u(i,["usageMetadata"]);m!=null&&c(t,["usageMetadata"],IE(m));const g=u(i,["goAway"]);g!=null&&c(t,["goAway"],g);const y=u(i,["sessionResumptionUpdate"]);y!=null&&c(t,["sessionResumptionUpdate"],y);const h=u(i,["voiceActivityDetectionSignal"]);return h!=null&&c(t,["voiceActivityDetectionSignal"],h),t}function AE(i){const t={},l=u(i,["mediaResolution"]);l!=null&&c(t,["mediaResolution"],l);const a=u(i,["codeExecutionResult"]);a!=null&&c(t,["codeExecutionResult"],a);const r=u(i,["executableCode"]);r!=null&&c(t,["executableCode"],r);const f=u(i,["fileData"]);f!=null&&c(t,["fileData"],uE(f));const m=u(i,["functionCall"]);m!=null&&c(t,["functionCall"],cE(m));const g=u(i,["functionResponse"]);g!=null&&c(t,["functionResponse"],g);const y=u(i,["inlineData"]);y!=null&&c(t,["inlineData"],Na(y));const h=u(i,["text"]);h!=null&&c(t,["text"],h);const v=u(i,["thought"]);v!=null&&c(t,["thought"],v);const S=u(i,["thoughtSignature"]);S!=null&&c(t,["thoughtSignature"],S);const E=u(i,["videoMetadata"]);return E!=null&&c(t,["videoMetadata"],E),t}function RE(i){const t={},l=u(i,["handle"]);if(l!=null&&c(t,["handle"],l),u(i,["transparent"])!==void 0)throw new Error("transparent parameter is not supported in Gemini API.");return t}function ME(i){const t={},l=u(i,["functionDeclarations"]);if(l!=null){let v=l;Array.isArray(v)&&(v=v.map(S=>S)),c(t,["functionDeclarations"],v)}if(u(i,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const a=u(i,["googleSearchRetrieval"]);a!=null&&c(t,["googleSearchRetrieval"],a);const r=u(i,["computerUse"]);r!=null&&c(t,["computerUse"],r);const f=u(i,["fileSearch"]);f!=null&&c(t,["fileSearch"],f);const m=u(i,["codeExecution"]);if(m!=null&&c(t,["codeExecution"],m),u(i,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const g=u(i,["googleMaps"]);g!=null&&c(t,["googleMaps"],pE(g));const y=u(i,["googleSearch"]);y!=null&&c(t,["googleSearch"],mE(y));const h=u(i,["urlContext"]);return h!=null&&c(t,["urlContext"],h),t}function NE(i){const t={},l=u(i,["functionDeclarations"]);if(l!=null){let S=l;Array.isArray(S)&&(S=S.map(E=>fE(E))),c(t,["functionDeclarations"],S)}const a=u(i,["retrieval"]);a!=null&&c(t,["retrieval"],a);const r=u(i,["googleSearchRetrieval"]);r!=null&&c(t,["googleSearchRetrieval"],r);const f=u(i,["computerUse"]);if(f!=null&&c(t,["computerUse"],f),u(i,["fileSearch"])!==void 0)throw new Error("fileSearch parameter is not supported in Vertex AI.");const m=u(i,["codeExecution"]);m!=null&&c(t,["codeExecution"],m);const g=u(i,["enterpriseWebSearch"]);g!=null&&c(t,["enterpriseWebSearch"],g);const y=u(i,["googleMaps"]);y!=null&&c(t,["googleMaps"],y);const h=u(i,["googleSearch"]);h!=null&&c(t,["googleSearch"],h);const v=u(i,["urlContext"]);return v!=null&&c(t,["urlContext"],v),t}function IE(i){const t={},l=u(i,["promptTokenCount"]);l!=null&&c(t,["promptTokenCount"],l);const a=u(i,["cachedContentTokenCount"]);a!=null&&c(t,["cachedContentTokenCount"],a);const r=u(i,["candidatesTokenCount"]);r!=null&&c(t,["responseTokenCount"],r);const f=u(i,["toolUsePromptTokenCount"]);f!=null&&c(t,["toolUsePromptTokenCount"],f);const m=u(i,["thoughtsTokenCount"]);m!=null&&c(t,["thoughtsTokenCount"],m);const g=u(i,["totalTokenCount"]);g!=null&&c(t,["totalTokenCount"],g);const y=u(i,["promptTokensDetails"]);if(y!=null){let C=y;Array.isArray(C)&&(C=C.map(U=>U)),c(t,["promptTokensDetails"],C)}const h=u(i,["cacheTokensDetails"]);if(h!=null){let C=h;Array.isArray(C)&&(C=C.map(U=>U)),c(t,["cacheTokensDetails"],C)}const v=u(i,["candidatesTokensDetails"]);if(v!=null){let C=v;Array.isArray(C)&&(C=C.map(U=>U)),c(t,["responseTokensDetails"],C)}const S=u(i,["toolUsePromptTokensDetails"]);if(S!=null){let C=S;Array.isArray(C)&&(C=C.map(U=>U)),c(t,["toolUsePromptTokensDetails"],C)}const E=u(i,["trafficType"]);return E!=null&&c(t,["trafficType"],E),t}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function xE(i){const t={},l=u(i,["data"]);if(l!=null&&c(t,["data"],l),u(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const a=u(i,["mimeType"]);return a!=null&&c(t,["mimeType"],a),t}function DE(i){const t={},l=u(i,["content"]);l!=null&&c(t,["content"],l);const a=u(i,["citationMetadata"]);a!=null&&c(t,["citationMetadata"],UE(a));const r=u(i,["tokenCount"]);r!=null&&c(t,["tokenCount"],r);const f=u(i,["finishReason"]);f!=null&&c(t,["finishReason"],f);const m=u(i,["avgLogprobs"]);m!=null&&c(t,["avgLogprobs"],m);const g=u(i,["groundingMetadata"]);g!=null&&c(t,["groundingMetadata"],g);const y=u(i,["index"]);y!=null&&c(t,["index"],y);const h=u(i,["logprobsResult"]);h!=null&&c(t,["logprobsResult"],h);const v=u(i,["safetyRatings"]);if(v!=null){let E=v;Array.isArray(E)&&(E=E.map(C=>C)),c(t,["safetyRatings"],E)}const S=u(i,["urlContextMetadata"]);return S!=null&&c(t,["urlContextMetadata"],S),t}function UE(i){const t={},l=u(i,["citationSources"]);if(l!=null){let a=l;Array.isArray(a)&&(a=a.map(r=>r)),c(t,["citations"],a)}return t}function wE(i,t){const l={},a=u(t,["model"]);a!=null&&c(l,["_url","model"],Te(i,a));const r=u(t,["contents"]);if(r!=null){let f=Ht(r);Array.isArray(f)&&(f=f.map(m=>m)),c(l,["contents"],f)}return l}function bE(i){const t={},l=u(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=u(i,["tokensInfo"]);if(a!=null){let r=a;Array.isArray(r)&&(r=r.map(f=>f)),c(t,["tokensInfo"],r)}return t}function LE(i){const t={},l=u(i,["values"]);l!=null&&c(t,["values"],l);const a=u(i,["statistics"]);return a!=null&&c(t,["statistics"],GE(a)),t}function GE(i){const t={},l=u(i,["truncated"]);l!=null&&c(t,["truncated"],l);const a=u(i,["token_count"]);return a!=null&&c(t,["tokenCount"],a),t}function Ga(i){const t={},l=u(i,["parts"]);if(l!=null){let r=l;Array.isArray(r)&&(r=r.map(f=>F_(f))),c(t,["parts"],r)}const a=u(i,["role"]);return a!=null&&c(t,["role"],a),t}function HE(i){const t={},l=u(i,["controlType"]);l!=null&&c(t,["controlType"],l);const a=u(i,["enableControlImageComputation"]);return a!=null&&c(t,["computeControl"],a),t}function qE(i){const t={};if(u(i,["systemInstruction"])!==void 0)throw new Error("systemInstruction parameter is not supported in Gemini API.");if(u(i,["tools"])!==void 0)throw new Error("tools parameter is not supported in Gemini API.");if(u(i,["generationConfig"])!==void 0)throw new Error("generationConfig parameter is not supported in Gemini API.");return t}function VE(i,t){const l={},a=u(i,["systemInstruction"]);t!==void 0&&a!=null&&c(t,["systemInstruction"],it(a));const r=u(i,["tools"]);if(t!==void 0&&r!=null){let m=r;Array.isArray(m)&&(m=m.map(g=>ng(g))),c(t,["tools"],m)}const f=u(i,["generationConfig"]);return t!==void 0&&f!=null&&c(t,["generationConfig"],x_(f)),l}function zE(i,t){const l={},a=u(t,["model"]);a!=null&&c(l,["_url","model"],Te(i,a));const r=u(t,["contents"]);if(r!=null){let m=Ht(r);Array.isArray(m)&&(m=m.map(g=>Ga(g))),c(l,["contents"],m)}const f=u(t,["config"]);return f!=null&&qE(f),l}function BE(i,t){const l={},a=u(t,["model"]);a!=null&&c(l,["_url","model"],Te(i,a));const r=u(t,["contents"]);if(r!=null){let m=Ht(r);Array.isArray(m)&&(m=m.map(g=>g)),c(l,["contents"],m)}const f=u(t,["config"]);return f!=null&&VE(f,l),l}function PE(i){const t={},l=u(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=u(i,["totalTokens"]);a!=null&&c(t,["totalTokens"],a);const r=u(i,["cachedContentTokenCount"]);return r!=null&&c(t,["cachedContentTokenCount"],r),t}function kE(i){const t={},l=u(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=u(i,["totalTokens"]);return a!=null&&c(t,["totalTokens"],a),t}function OE(i,t){const l={},a=u(t,["model"]);return a!=null&&c(l,["_url","name"],Te(i,a)),l}function FE(i,t){const l={},a=u(t,["model"]);return a!=null&&c(l,["_url","name"],Te(i,a)),l}function JE(i){const t={},l=u(i,["sdkHttpResponse"]);return l!=null&&c(t,["sdkHttpResponse"],l),t}function YE(i){const t={},l=u(i,["sdkHttpResponse"]);return l!=null&&c(t,["sdkHttpResponse"],l),t}function XE(i,t){const l={},a=u(i,["outputGcsUri"]);t!==void 0&&a!=null&&c(t,["parameters","storageUri"],a);const r=u(i,["negativePrompt"]);t!==void 0&&r!=null&&c(t,["parameters","negativePrompt"],r);const f=u(i,["numberOfImages"]);t!==void 0&&f!=null&&c(t,["parameters","sampleCount"],f);const m=u(i,["aspectRatio"]);t!==void 0&&m!=null&&c(t,["parameters","aspectRatio"],m);const g=u(i,["guidanceScale"]);t!==void 0&&g!=null&&c(t,["parameters","guidanceScale"],g);const y=u(i,["seed"]);t!==void 0&&y!=null&&c(t,["parameters","seed"],y);const h=u(i,["safetyFilterLevel"]);t!==void 0&&h!=null&&c(t,["parameters","safetySetting"],h);const v=u(i,["personGeneration"]);t!==void 0&&v!=null&&c(t,["parameters","personGeneration"],v);const S=u(i,["includeSafetyAttributes"]);t!==void 0&&S!=null&&c(t,["parameters","includeSafetyAttributes"],S);const E=u(i,["includeRaiReason"]);t!==void 0&&E!=null&&c(t,["parameters","includeRaiReason"],E);const C=u(i,["language"]);t!==void 0&&C!=null&&c(t,["parameters","language"],C);const U=u(i,["outputMimeType"]);t!==void 0&&U!=null&&c(t,["parameters","outputOptions","mimeType"],U);const H=u(i,["outputCompressionQuality"]);t!==void 0&&H!=null&&c(t,["parameters","outputOptions","compressionQuality"],H);const b=u(i,["addWatermark"]);t!==void 0&&b!=null&&c(t,["parameters","addWatermark"],b);const P=u(i,["labels"]);t!==void 0&&P!=null&&c(t,["labels"],P);const X=u(i,["editMode"]);t!==void 0&&X!=null&&c(t,["parameters","editMode"],X);const k=u(i,["baseSteps"]);return t!==void 0&&k!=null&&c(t,["parameters","editConfig","baseSteps"],k),l}function KE(i,t){const l={},a=u(t,["model"]);a!=null&&c(l,["_url","model"],Te(i,a));const r=u(t,["prompt"]);r!=null&&c(l,["instances[0]","prompt"],r);const f=u(t,["referenceImages"]);if(f!=null){let g=f;Array.isArray(g)&&(g=g.map(y=>Z_(y))),c(l,["instances[0]","referenceImages"],g)}const m=u(t,["config"]);return m!=null&&XE(m,l),l}function QE(i){const t={},l=u(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=u(i,["predictions"]);if(a!=null){let r=a;Array.isArray(r)&&(r=r.map(f=>Ha(f))),c(t,["generatedImages"],r)}return t}function ZE(i,t){const l={},a=u(i,["taskType"]);t!==void 0&&a!=null&&c(t,["requests[]","taskType"],a);const r=u(i,["title"]);t!==void 0&&r!=null&&c(t,["requests[]","title"],r);const f=u(i,["outputDimensionality"]);if(t!==void 0&&f!=null&&c(t,["requests[]","outputDimensionality"],f),u(i,["mimeType"])!==void 0)throw new Error("mimeType parameter is not supported in Gemini API.");if(u(i,["autoTruncate"])!==void 0)throw new Error("autoTruncate parameter is not supported in Gemini API.");return l}function $E(i,t){const l={},a=u(i,["taskType"]);t!==void 0&&a!=null&&c(t,["instances[]","task_type"],a);const r=u(i,["title"]);t!==void 0&&r!=null&&c(t,["instances[]","title"],r);const f=u(i,["outputDimensionality"]);t!==void 0&&f!=null&&c(t,["parameters","outputDimensionality"],f);const m=u(i,["mimeType"]);t!==void 0&&m!=null&&c(t,["instances[]","mimeType"],m);const g=u(i,["autoTruncate"]);return t!==void 0&&g!=null&&c(t,["parameters","autoTruncate"],g),l}function WE(i,t){const l={},a=u(t,["model"]);a!=null&&c(l,["_url","model"],Te(i,a));const r=u(t,["contents"]);if(r!=null){let g=Lu(i,r);Array.isArray(g)&&(g=g.map(y=>y)),c(l,["requests[]","content"],g)}const f=u(t,["config"]);f!=null&&ZE(f,l);const m=u(t,["model"]);return m!==void 0&&c(l,["requests[]","model"],Te(i,m)),l}function jE(i,t){const l={},a=u(t,["model"]);a!=null&&c(l,["_url","model"],Te(i,a));const r=u(t,["contents"]);if(r!=null){let m=Lu(i,r);Array.isArray(m)&&(m=m.map(g=>g)),c(l,["instances[]","content"],m)}const f=u(t,["config"]);return f!=null&&$E(f,l),l}function e_(i){const t={},l=u(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=u(i,["embeddings"]);if(a!=null){let f=a;Array.isArray(f)&&(f=f.map(m=>m)),c(t,["embeddings"],f)}const r=u(i,["metadata"]);return r!=null&&c(t,["metadata"],r),t}function t_(i){const t={},l=u(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=u(i,["predictions[]","embeddings"]);if(a!=null){let f=a;Array.isArray(f)&&(f=f.map(m=>LE(m))),c(t,["embeddings"],f)}const r=u(i,["metadata"]);return r!=null&&c(t,["metadata"],r),t}function n_(i){const t={},l=u(i,["endpoint"]);l!=null&&c(t,["name"],l);const a=u(i,["deployedModelId"]);return a!=null&&c(t,["deployedModelId"],a),t}function i_(i){const t={};if(u(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const l=u(i,["fileUri"]);l!=null&&c(t,["fileUri"],l);const a=u(i,["mimeType"]);return a!=null&&c(t,["mimeType"],a),t}function o_(i){const t={},l=u(i,["id"]);l!=null&&c(t,["id"],l);const a=u(i,["args"]);a!=null&&c(t,["args"],a);const r=u(i,["name"]);if(r!=null&&c(t,["name"],r),u(i,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(u(i,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return t}function l_(i){const t={},l=u(i,["mode"]);l!=null&&c(t,["mode"],l);const a=u(i,["allowedFunctionNames"]);if(a!=null&&c(t,["allowedFunctionNames"],a),u(i,["streamFunctionCallArguments"])!==void 0)throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return t}function a_(i){const t={};if(u(i,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");const l=u(i,["description"]);l!=null&&c(t,["description"],l);const a=u(i,["name"]);a!=null&&c(t,["name"],a);const r=u(i,["parameters"]);r!=null&&c(t,["parameters"],r);const f=u(i,["parametersJsonSchema"]);f!=null&&c(t,["parametersJsonSchema"],f);const m=u(i,["response"]);m!=null&&c(t,["response"],m);const g=u(i,["responseJsonSchema"]);return g!=null&&c(t,["responseJsonSchema"],g),t}function s_(i,t,l){const a={},r=u(t,["systemInstruction"]);l!==void 0&&r!=null&&c(l,["systemInstruction"],Ga(it(r)));const f=u(t,["temperature"]);f!=null&&c(a,["temperature"],f);const m=u(t,["topP"]);m!=null&&c(a,["topP"],m);const g=u(t,["topK"]);g!=null&&c(a,["topK"],g);const y=u(t,["candidateCount"]);y!=null&&c(a,["candidateCount"],y);const h=u(t,["maxOutputTokens"]);h!=null&&c(a,["maxOutputTokens"],h);const v=u(t,["stopSequences"]);v!=null&&c(a,["stopSequences"],v);const S=u(t,["responseLogprobs"]);S!=null&&c(a,["responseLogprobs"],S);const E=u(t,["logprobs"]);E!=null&&c(a,["logprobs"],E);const C=u(t,["presencePenalty"]);C!=null&&c(a,["presencePenalty"],C);const U=u(t,["frequencyPenalty"]);U!=null&&c(a,["frequencyPenalty"],U);const H=u(t,["seed"]);H!=null&&c(a,["seed"],H);const b=u(t,["responseMimeType"]);b!=null&&c(a,["responseMimeType"],b);const P=u(t,["responseSchema"]);P!=null&&c(a,["responseSchema"],Gu(P));const X=u(t,["responseJsonSchema"]);if(X!=null&&c(a,["responseJsonSchema"],X),u(t,["routingConfig"])!==void 0)throw new Error("routingConfig parameter is not supported in Gemini API.");if(u(t,["modelSelectionConfig"])!==void 0)throw new Error("modelSelectionConfig parameter is not supported in Gemini API.");const k=u(t,["safetySettings"]);if(l!==void 0&&k!=null){let Ee=k;Array.isArray(Ee)&&(Ee=Ee.map(Pe=>$_(Pe))),c(l,["safetySettings"],Ee)}const K=u(t,["tools"]);if(l!==void 0&&K!=null){let Ee=to(K);Array.isArray(Ee)&&(Ee=Ee.map(Pe=>oC(eo(Pe)))),c(l,["tools"],Ee)}const ee=u(t,["toolConfig"]);if(l!==void 0&&ee!=null&&c(l,["toolConfig"],iC(ee)),u(t,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const te=u(t,["cachedContent"]);l!==void 0&&te!=null&&c(l,["cachedContent"],gn(i,te));const F=u(t,["responseModalities"]);F!=null&&c(a,["responseModalities"],F);const he=u(t,["mediaResolution"]);he!=null&&c(a,["mediaResolution"],he);const W=u(t,["speechConfig"]);if(W!=null&&c(a,["speechConfig"],Hu(W)),u(t,["audioTimestamp"])!==void 0)throw new Error("audioTimestamp parameter is not supported in Gemini API.");const de=u(t,["thinkingConfig"]);de!=null&&c(a,["thinkingConfig"],de);const Ce=u(t,["imageConfig"]);Ce!=null&&c(a,["imageConfig"],L_(Ce));const Ge=u(t,["enableEnhancedCivicAnswers"]);return Ge!=null&&c(a,["enableEnhancedCivicAnswers"],Ge),a}function r_(i,t,l){const a={},r=u(t,["systemInstruction"]);l!==void 0&&r!=null&&c(l,["systemInstruction"],it(r));const f=u(t,["temperature"]);f!=null&&c(a,["temperature"],f);const m=u(t,["topP"]);m!=null&&c(a,["topP"],m);const g=u(t,["topK"]);g!=null&&c(a,["topK"],g);const y=u(t,["candidateCount"]);y!=null&&c(a,["candidateCount"],y);const h=u(t,["maxOutputTokens"]);h!=null&&c(a,["maxOutputTokens"],h);const v=u(t,["stopSequences"]);v!=null&&c(a,["stopSequences"],v);const S=u(t,["responseLogprobs"]);S!=null&&c(a,["responseLogprobs"],S);const E=u(t,["logprobs"]);E!=null&&c(a,["logprobs"],E);const C=u(t,["presencePenalty"]);C!=null&&c(a,["presencePenalty"],C);const U=u(t,["frequencyPenalty"]);U!=null&&c(a,["frequencyPenalty"],U);const H=u(t,["seed"]);H!=null&&c(a,["seed"],H);const b=u(t,["responseMimeType"]);b!=null&&c(a,["responseMimeType"],b);const P=u(t,["responseSchema"]);P!=null&&c(a,["responseSchema"],Gu(P));const X=u(t,["responseJsonSchema"]);X!=null&&c(a,["responseJsonSchema"],X);const k=u(t,["routingConfig"]);k!=null&&c(a,["routingConfig"],k);const K=u(t,["modelSelectionConfig"]);K!=null&&c(a,["modelConfig"],K);const ee=u(t,["safetySettings"]);if(l!==void 0&&ee!=null){let L=ee;Array.isArray(L)&&(L=L.map(O=>O)),c(l,["safetySettings"],L)}const te=u(t,["tools"]);if(l!==void 0&&te!=null){let L=to(te);Array.isArray(L)&&(L=L.map(O=>ng(eo(O)))),c(l,["tools"],L)}const F=u(t,["toolConfig"]);l!==void 0&&F!=null&&c(l,["toolConfig"],F);const he=u(t,["labels"]);l!==void 0&&he!=null&&c(l,["labels"],he);const W=u(t,["cachedContent"]);l!==void 0&&W!=null&&c(l,["cachedContent"],gn(i,W));const de=u(t,["responseModalities"]);de!=null&&c(a,["responseModalities"],de);const Ce=u(t,["mediaResolution"]);Ce!=null&&c(a,["mediaResolution"],Ce);const Ge=u(t,["speechConfig"]);Ge!=null&&c(a,["speechConfig"],Hu(Ge));const Ee=u(t,["audioTimestamp"]);Ee!=null&&c(a,["audioTimestamp"],Ee);const Pe=u(t,["thinkingConfig"]);Pe!=null&&c(a,["thinkingConfig"],Pe);const rt=u(t,["imageConfig"]);if(rt!=null&&c(a,["imageConfig"],G_(rt)),u(t,["enableEnhancedCivicAnswers"])!==void 0)throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");return a}function gh(i,t){const l={},a=u(t,["model"]);a!=null&&c(l,["_url","model"],Te(i,a));const r=u(t,["contents"]);if(r!=null){let m=Ht(r);Array.isArray(m)&&(m=m.map(g=>Ga(g))),c(l,["contents"],m)}const f=u(t,["config"]);return f!=null&&c(l,["generationConfig"],s_(i,f,l)),l}function yh(i,t){const l={},a=u(t,["model"]);a!=null&&c(l,["_url","model"],Te(i,a));const r=u(t,["contents"]);if(r!=null){let m=Ht(r);Array.isArray(m)&&(m=m.map(g=>g)),c(l,["contents"],m)}const f=u(t,["config"]);return f!=null&&c(l,["generationConfig"],r_(i,f,l)),l}function vh(i){const t={},l=u(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=u(i,["candidates"]);if(a!=null){let y=a;Array.isArray(y)&&(y=y.map(h=>DE(h))),c(t,["candidates"],y)}const r=u(i,["modelVersion"]);r!=null&&c(t,["modelVersion"],r);const f=u(i,["promptFeedback"]);f!=null&&c(t,["promptFeedback"],f);const m=u(i,["responseId"]);m!=null&&c(t,["responseId"],m);const g=u(i,["usageMetadata"]);return g!=null&&c(t,["usageMetadata"],g),t}function Th(i){const t={},l=u(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=u(i,["candidates"]);if(a!=null){let h=a;Array.isArray(h)&&(h=h.map(v=>v)),c(t,["candidates"],h)}const r=u(i,["createTime"]);r!=null&&c(t,["createTime"],r);const f=u(i,["modelVersion"]);f!=null&&c(t,["modelVersion"],f);const m=u(i,["promptFeedback"]);m!=null&&c(t,["promptFeedback"],m);const g=u(i,["responseId"]);g!=null&&c(t,["responseId"],g);const y=u(i,["usageMetadata"]);return y!=null&&c(t,["usageMetadata"],y),t}function u_(i,t){const l={};if(u(i,["outputGcsUri"])!==void 0)throw new Error("outputGcsUri parameter is not supported in Gemini API.");if(u(i,["negativePrompt"])!==void 0)throw new Error("negativePrompt parameter is not supported in Gemini API.");const a=u(i,["numberOfImages"]);t!==void 0&&a!=null&&c(t,["parameters","sampleCount"],a);const r=u(i,["aspectRatio"]);t!==void 0&&r!=null&&c(t,["parameters","aspectRatio"],r);const f=u(i,["guidanceScale"]);if(t!==void 0&&f!=null&&c(t,["parameters","guidanceScale"],f),u(i,["seed"])!==void 0)throw new Error("seed parameter is not supported in Gemini API.");const m=u(i,["safetyFilterLevel"]);t!==void 0&&m!=null&&c(t,["parameters","safetySetting"],m);const g=u(i,["personGeneration"]);t!==void 0&&g!=null&&c(t,["parameters","personGeneration"],g);const y=u(i,["includeSafetyAttributes"]);t!==void 0&&y!=null&&c(t,["parameters","includeSafetyAttributes"],y);const h=u(i,["includeRaiReason"]);t!==void 0&&h!=null&&c(t,["parameters","includeRaiReason"],h);const v=u(i,["language"]);t!==void 0&&v!=null&&c(t,["parameters","language"],v);const S=u(i,["outputMimeType"]);t!==void 0&&S!=null&&c(t,["parameters","outputOptions","mimeType"],S);const E=u(i,["outputCompressionQuality"]);if(t!==void 0&&E!=null&&c(t,["parameters","outputOptions","compressionQuality"],E),u(i,["addWatermark"])!==void 0)throw new Error("addWatermark parameter is not supported in Gemini API.");if(u(i,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const C=u(i,["imageSize"]);if(t!==void 0&&C!=null&&c(t,["parameters","sampleImageSize"],C),u(i,["enhancePrompt"])!==void 0)throw new Error("enhancePrompt parameter is not supported in Gemini API.");return l}function c_(i,t){const l={},a=u(i,["outputGcsUri"]);t!==void 0&&a!=null&&c(t,["parameters","storageUri"],a);const r=u(i,["negativePrompt"]);t!==void 0&&r!=null&&c(t,["parameters","negativePrompt"],r);const f=u(i,["numberOfImages"]);t!==void 0&&f!=null&&c(t,["parameters","sampleCount"],f);const m=u(i,["aspectRatio"]);t!==void 0&&m!=null&&c(t,["parameters","aspectRatio"],m);const g=u(i,["guidanceScale"]);t!==void 0&&g!=null&&c(t,["parameters","guidanceScale"],g);const y=u(i,["seed"]);t!==void 0&&y!=null&&c(t,["parameters","seed"],y);const h=u(i,["safetyFilterLevel"]);t!==void 0&&h!=null&&c(t,["parameters","safetySetting"],h);const v=u(i,["personGeneration"]);t!==void 0&&v!=null&&c(t,["parameters","personGeneration"],v);const S=u(i,["includeSafetyAttributes"]);t!==void 0&&S!=null&&c(t,["parameters","includeSafetyAttributes"],S);const E=u(i,["includeRaiReason"]);t!==void 0&&E!=null&&c(t,["parameters","includeRaiReason"],E);const C=u(i,["language"]);t!==void 0&&C!=null&&c(t,["parameters","language"],C);const U=u(i,["outputMimeType"]);t!==void 0&&U!=null&&c(t,["parameters","outputOptions","mimeType"],U);const H=u(i,["outputCompressionQuality"]);t!==void 0&&H!=null&&c(t,["parameters","outputOptions","compressionQuality"],H);const b=u(i,["addWatermark"]);t!==void 0&&b!=null&&c(t,["parameters","addWatermark"],b);const P=u(i,["labels"]);t!==void 0&&P!=null&&c(t,["labels"],P);const X=u(i,["imageSize"]);t!==void 0&&X!=null&&c(t,["parameters","sampleImageSize"],X);const k=u(i,["enhancePrompt"]);return t!==void 0&&k!=null&&c(t,["parameters","enhancePrompt"],k),l}function f_(i,t){const l={},a=u(t,["model"]);a!=null&&c(l,["_url","model"],Te(i,a));const r=u(t,["prompt"]);r!=null&&c(l,["instances[0]","prompt"],r);const f=u(t,["config"]);return f!=null&&u_(f,l),l}function d_(i,t){const l={},a=u(t,["model"]);a!=null&&c(l,["_url","model"],Te(i,a));const r=u(t,["prompt"]);r!=null&&c(l,["instances[0]","prompt"],r);const f=u(t,["config"]);return f!=null&&c_(f,l),l}function p_(i){const t={},l=u(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=u(i,["predictions"]);if(a!=null){let f=a;Array.isArray(f)&&(f=f.map(m=>R_(m))),c(t,["generatedImages"],f)}const r=u(i,["positivePromptSafetyAttributes"]);return r!=null&&c(t,["positivePromptSafetyAttributes"],eg(r)),t}function m_(i){const t={},l=u(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=u(i,["predictions"]);if(a!=null){let f=a;Array.isArray(f)&&(f=f.map(m=>Ha(m))),c(t,["generatedImages"],f)}const r=u(i,["positivePromptSafetyAttributes"]);return r!=null&&c(t,["positivePromptSafetyAttributes"],tg(r)),t}function h_(i,t){const l={},a=u(i,["numberOfVideos"]);if(t!==void 0&&a!=null&&c(t,["parameters","sampleCount"],a),u(i,["outputGcsUri"])!==void 0)throw new Error("outputGcsUri parameter is not supported in Gemini API.");if(u(i,["fps"])!==void 0)throw new Error("fps parameter is not supported in Gemini API.");const r=u(i,["durationSeconds"]);if(t!==void 0&&r!=null&&c(t,["parameters","durationSeconds"],r),u(i,["seed"])!==void 0)throw new Error("seed parameter is not supported in Gemini API.");const f=u(i,["aspectRatio"]);t!==void 0&&f!=null&&c(t,["parameters","aspectRatio"],f);const m=u(i,["resolution"]);t!==void 0&&m!=null&&c(t,["parameters","resolution"],m);const g=u(i,["personGeneration"]);if(t!==void 0&&g!=null&&c(t,["parameters","personGeneration"],g),u(i,["pubsubTopic"])!==void 0)throw new Error("pubsubTopic parameter is not supported in Gemini API.");const y=u(i,["negativePrompt"]);t!==void 0&&y!=null&&c(t,["parameters","negativePrompt"],y);const h=u(i,["enhancePrompt"]);if(t!==void 0&&h!=null&&c(t,["parameters","enhancePrompt"],h),u(i,["generateAudio"])!==void 0)throw new Error("generateAudio parameter is not supported in Gemini API.");const v=u(i,["lastFrame"]);t!==void 0&&v!=null&&c(t,["instances[0]","lastFrame"],qa(v));const S=u(i,["referenceImages"]);if(t!==void 0&&S!=null){let E=S;Array.isArray(E)&&(E=E.map(C=>yC(C))),c(t,["instances[0]","referenceImages"],E)}if(u(i,["mask"])!==void 0)throw new Error("mask parameter is not supported in Gemini API.");if(u(i,["compressionQuality"])!==void 0)throw new Error("compressionQuality parameter is not supported in Gemini API.");return l}function g_(i,t){const l={},a=u(i,["numberOfVideos"]);t!==void 0&&a!=null&&c(t,["parameters","sampleCount"],a);const r=u(i,["outputGcsUri"]);t!==void 0&&r!=null&&c(t,["parameters","storageUri"],r);const f=u(i,["fps"]);t!==void 0&&f!=null&&c(t,["parameters","fps"],f);const m=u(i,["durationSeconds"]);t!==void 0&&m!=null&&c(t,["parameters","durationSeconds"],m);const g=u(i,["seed"]);t!==void 0&&g!=null&&c(t,["parameters","seed"],g);const y=u(i,["aspectRatio"]);t!==void 0&&y!=null&&c(t,["parameters","aspectRatio"],y);const h=u(i,["resolution"]);t!==void 0&&h!=null&&c(t,["parameters","resolution"],h);const v=u(i,["personGeneration"]);t!==void 0&&v!=null&&c(t,["parameters","personGeneration"],v);const S=u(i,["pubsubTopic"]);t!==void 0&&S!=null&&c(t,["parameters","pubsubTopic"],S);const E=u(i,["negativePrompt"]);t!==void 0&&E!=null&&c(t,["parameters","negativePrompt"],E);const C=u(i,["enhancePrompt"]);t!==void 0&&C!=null&&c(t,["parameters","enhancePrompt"],C);const U=u(i,["generateAudio"]);t!==void 0&&U!=null&&c(t,["parameters","generateAudio"],U);const H=u(i,["lastFrame"]);t!==void 0&&H!=null&&c(t,["instances[0]","lastFrame"],Ot(H));const b=u(i,["referenceImages"]);if(t!==void 0&&b!=null){let k=b;Array.isArray(k)&&(k=k.map(K=>vC(K))),c(t,["instances[0]","referenceImages"],k)}const P=u(i,["mask"]);t!==void 0&&P!=null&&c(t,["instances[0]","mask"],gC(P));const X=u(i,["compressionQuality"]);return t!==void 0&&X!=null&&c(t,["parameters","compressionQuality"],X),l}function y_(i){const t={},l=u(i,["name"]);l!=null&&c(t,["name"],l);const a=u(i,["metadata"]);a!=null&&c(t,["metadata"],a);const r=u(i,["done"]);r!=null&&c(t,["done"],r);const f=u(i,["error"]);f!=null&&c(t,["error"],f);const m=u(i,["response","generateVideoResponse"]);return m!=null&&c(t,["response"],E_(m)),t}function v_(i){const t={},l=u(i,["name"]);l!=null&&c(t,["name"],l);const a=u(i,["metadata"]);a!=null&&c(t,["metadata"],a);const r=u(i,["done"]);r!=null&&c(t,["done"],r);const f=u(i,["error"]);f!=null&&c(t,["error"],f);const m=u(i,["response"]);return m!=null&&c(t,["response"],__(m)),t}function T_(i,t){const l={},a=u(t,["model"]);a!=null&&c(l,["_url","model"],Te(i,a));const r=u(t,["prompt"]);r!=null&&c(l,["instances[0]","prompt"],r);const f=u(t,["image"]);f!=null&&c(l,["instances[0]","image"],qa(f));const m=u(t,["video"]);m!=null&&c(l,["instances[0]","video"],ig(m));const g=u(t,["source"]);g!=null&&C_(g,l);const y=u(t,["config"]);return y!=null&&h_(y,l),l}function S_(i,t){const l={},a=u(t,["model"]);a!=null&&c(l,["_url","model"],Te(i,a));const r=u(t,["prompt"]);r!=null&&c(l,["instances[0]","prompt"],r);const f=u(t,["image"]);f!=null&&c(l,["instances[0]","image"],Ot(f));const m=u(t,["video"]);m!=null&&c(l,["instances[0]","video"],og(m));const g=u(t,["source"]);g!=null&&A_(g,l);const y=u(t,["config"]);return y!=null&&g_(y,l),l}function E_(i){const t={},l=u(i,["generatedSamples"]);if(l!=null){let f=l;Array.isArray(f)&&(f=f.map(m=>N_(m))),c(t,["generatedVideos"],f)}const a=u(i,["raiMediaFilteredCount"]);a!=null&&c(t,["raiMediaFilteredCount"],a);const r=u(i,["raiMediaFilteredReasons"]);return r!=null&&c(t,["raiMediaFilteredReasons"],r),t}function __(i){const t={},l=u(i,["videos"]);if(l!=null){let f=l;Array.isArray(f)&&(f=f.map(m=>I_(m))),c(t,["generatedVideos"],f)}const a=u(i,["raiMediaFilteredCount"]);a!=null&&c(t,["raiMediaFilteredCount"],a);const r=u(i,["raiMediaFilteredReasons"]);return r!=null&&c(t,["raiMediaFilteredReasons"],r),t}function C_(i,t){const l={},a=u(i,["prompt"]);t!==void 0&&a!=null&&c(t,["instances[0]","prompt"],a);const r=u(i,["image"]);t!==void 0&&r!=null&&c(t,["instances[0]","image"],qa(r));const f=u(i,["video"]);return t!==void 0&&f!=null&&c(t,["instances[0]","video"],ig(f)),l}function A_(i,t){const l={},a=u(i,["prompt"]);t!==void 0&&a!=null&&c(t,["instances[0]","prompt"],a);const r=u(i,["image"]);t!==void 0&&r!=null&&c(t,["instances[0]","image"],Ot(r));const f=u(i,["video"]);return t!==void 0&&f!=null&&c(t,["instances[0]","video"],og(f)),l}function R_(i){const t={},l=u(i,["_self"]);l!=null&&c(t,["image"],H_(l));const a=u(i,["raiFilteredReason"]);a!=null&&c(t,["raiFilteredReason"],a);const r=u(i,["_self"]);return r!=null&&c(t,["safetyAttributes"],eg(r)),t}function Ha(i){const t={},l=u(i,["_self"]);l!=null&&c(t,["image"],jh(l));const a=u(i,["raiFilteredReason"]);a!=null&&c(t,["raiFilteredReason"],a);const r=u(i,["_self"]);r!=null&&c(t,["safetyAttributes"],tg(r));const f=u(i,["prompt"]);return f!=null&&c(t,["enhancedPrompt"],f),t}function M_(i){const t={},l=u(i,["_self"]);l!=null&&c(t,["mask"],jh(l));const a=u(i,["labels"]);if(a!=null){let r=a;Array.isArray(r)&&(r=r.map(f=>f)),c(t,["labels"],r)}return t}function N_(i){const t={},l=u(i,["video"]);return l!=null&&c(t,["video"],mC(l)),t}function I_(i){const t={},l=u(i,["_self"]);return l!=null&&c(t,["video"],hC(l)),t}function x_(i){const t={},l=u(i,["modelSelectionConfig"]);l!=null&&c(t,["modelConfig"],l);const a=u(i,["responseJsonSchema"]);a!=null&&c(t,["responseJsonSchema"],a);const r=u(i,["audioTimestamp"]);r!=null&&c(t,["audioTimestamp"],r);const f=u(i,["candidateCount"]);f!=null&&c(t,["candidateCount"],f);const m=u(i,["enableAffectiveDialog"]);m!=null&&c(t,["enableAffectiveDialog"],m);const g=u(i,["frequencyPenalty"]);g!=null&&c(t,["frequencyPenalty"],g);const y=u(i,["logprobs"]);y!=null&&c(t,["logprobs"],y);const h=u(i,["maxOutputTokens"]);h!=null&&c(t,["maxOutputTokens"],h);const v=u(i,["mediaResolution"]);v!=null&&c(t,["mediaResolution"],v);const S=u(i,["presencePenalty"]);S!=null&&c(t,["presencePenalty"],S);const E=u(i,["responseLogprobs"]);E!=null&&c(t,["responseLogprobs"],E);const C=u(i,["responseMimeType"]);C!=null&&c(t,["responseMimeType"],C);const U=u(i,["responseModalities"]);U!=null&&c(t,["responseModalities"],U);const H=u(i,["responseSchema"]);H!=null&&c(t,["responseSchema"],H);const b=u(i,["routingConfig"]);b!=null&&c(t,["routingConfig"],b);const P=u(i,["seed"]);P!=null&&c(t,["seed"],P);const X=u(i,["speechConfig"]);X!=null&&c(t,["speechConfig"],X);const k=u(i,["stopSequences"]);k!=null&&c(t,["stopSequences"],k);const K=u(i,["temperature"]);K!=null&&c(t,["temperature"],K);const ee=u(i,["thinkingConfig"]);ee!=null&&c(t,["thinkingConfig"],ee);const te=u(i,["topK"]);te!=null&&c(t,["topK"],te);const F=u(i,["topP"]);if(F!=null&&c(t,["topP"],F),u(i,["enableEnhancedCivicAnswers"])!==void 0)throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");return t}function D_(i,t){const l={},a=u(t,["model"]);return a!=null&&c(l,["_url","name"],Te(i,a)),l}function U_(i,t){const l={},a=u(t,["model"]);return a!=null&&c(l,["_url","name"],Te(i,a)),l}function w_(i){const t={};if(u(i,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const l=u(i,["enableWidget"]);return l!=null&&c(t,["enableWidget"],l),t}function b_(i){const t={};if(u(i,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(u(i,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const l=u(i,["timeRangeFilter"]);return l!=null&&c(t,["timeRangeFilter"],l),t}function L_(i){const t={},l=u(i,["aspectRatio"]);l!=null&&c(t,["aspectRatio"],l);const a=u(i,["imageSize"]);if(a!=null&&c(t,["imageSize"],a),u(i,["outputMimeType"])!==void 0)throw new Error("outputMimeType parameter is not supported in Gemini API.");if(u(i,["outputCompressionQuality"])!==void 0)throw new Error("outputCompressionQuality parameter is not supported in Gemini API.");return t}function G_(i){const t={},l=u(i,["aspectRatio"]);l!=null&&c(t,["aspectRatio"],l);const a=u(i,["imageSize"]);a!=null&&c(t,["imageSize"],a);const r=u(i,["outputMimeType"]);r!=null&&c(t,["imageOutputOptions","mimeType"],r);const f=u(i,["outputCompressionQuality"]);return f!=null&&c(t,["imageOutputOptions","compressionQuality"],f),t}function H_(i){const t={},l=u(i,["bytesBase64Encoded"]);l!=null&&c(t,["imageBytes"],On(l));const a=u(i,["mimeType"]);return a!=null&&c(t,["mimeType"],a),t}function jh(i){const t={},l=u(i,["gcsUri"]);l!=null&&c(t,["gcsUri"],l);const a=u(i,["bytesBase64Encoded"]);a!=null&&c(t,["imageBytes"],On(a));const r=u(i,["mimeType"]);return r!=null&&c(t,["mimeType"],r),t}function qa(i){const t={};if(u(i,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");const l=u(i,["imageBytes"]);l!=null&&c(t,["bytesBase64Encoded"],On(l));const a=u(i,["mimeType"]);return a!=null&&c(t,["mimeType"],a),t}function Ot(i){const t={},l=u(i,["gcsUri"]);l!=null&&c(t,["gcsUri"],l);const a=u(i,["imageBytes"]);a!=null&&c(t,["bytesBase64Encoded"],On(a));const r=u(i,["mimeType"]);return r!=null&&c(t,["mimeType"],r),t}function q_(i,t,l){const a={},r=u(t,["pageSize"]);l!==void 0&&r!=null&&c(l,["_query","pageSize"],r);const f=u(t,["pageToken"]);l!==void 0&&f!=null&&c(l,["_query","pageToken"],f);const m=u(t,["filter"]);l!==void 0&&m!=null&&c(l,["_query","filter"],m);const g=u(t,["queryBase"]);return l!==void 0&&g!=null&&c(l,["_url","models_url"],Yh(i,g)),a}function V_(i,t,l){const a={},r=u(t,["pageSize"]);l!==void 0&&r!=null&&c(l,["_query","pageSize"],r);const f=u(t,["pageToken"]);l!==void 0&&f!=null&&c(l,["_query","pageToken"],f);const m=u(t,["filter"]);l!==void 0&&m!=null&&c(l,["_query","filter"],m);const g=u(t,["queryBase"]);return l!==void 0&&g!=null&&c(l,["_url","models_url"],Yh(i,g)),a}function z_(i,t){const l={},a=u(t,["config"]);return a!=null&&q_(i,a,l),l}function B_(i,t){const l={},a=u(t,["config"]);return a!=null&&V_(i,a,l),l}function P_(i){const t={},l=u(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=u(i,["nextPageToken"]);a!=null&&c(t,["nextPageToken"],a);const r=u(i,["_self"]);if(r!=null){let f=Xh(r);Array.isArray(f)&&(f=f.map(m=>Eu(m))),c(t,["models"],f)}return t}function k_(i){const t={},l=u(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=u(i,["nextPageToken"]);a!=null&&c(t,["nextPageToken"],a);const r=u(i,["_self"]);if(r!=null){let f=Xh(r);Array.isArray(f)&&(f=f.map(m=>_u(m))),c(t,["models"],f)}return t}function O_(i){const t={},l=u(i,["maskMode"]);l!=null&&c(t,["maskMode"],l);const a=u(i,["segmentationClasses"]);a!=null&&c(t,["maskClasses"],a);const r=u(i,["maskDilation"]);return r!=null&&c(t,["dilation"],r),t}function Eu(i){const t={},l=u(i,["name"]);l!=null&&c(t,["name"],l);const a=u(i,["displayName"]);a!=null&&c(t,["displayName"],a);const r=u(i,["description"]);r!=null&&c(t,["description"],r);const f=u(i,["version"]);f!=null&&c(t,["version"],f);const m=u(i,["_self"]);m!=null&&c(t,["tunedModelInfo"],lC(m));const g=u(i,["inputTokenLimit"]);g!=null&&c(t,["inputTokenLimit"],g);const y=u(i,["outputTokenLimit"]);y!=null&&c(t,["outputTokenLimit"],y);const h=u(i,["supportedGenerationMethods"]);h!=null&&c(t,["supportedActions"],h);const v=u(i,["temperature"]);v!=null&&c(t,["temperature"],v);const S=u(i,["maxTemperature"]);S!=null&&c(t,["maxTemperature"],S);const E=u(i,["topP"]);E!=null&&c(t,["topP"],E);const C=u(i,["topK"]);C!=null&&c(t,["topK"],C);const U=u(i,["thinking"]);return U!=null&&c(t,["thinking"],U),t}function _u(i){const t={},l=u(i,["name"]);l!=null&&c(t,["name"],l);const a=u(i,["displayName"]);a!=null&&c(t,["displayName"],a);const r=u(i,["description"]);r!=null&&c(t,["description"],r);const f=u(i,["versionId"]);f!=null&&c(t,["version"],f);const m=u(i,["deployedModels"]);if(m!=null){let S=m;Array.isArray(S)&&(S=S.map(E=>n_(E))),c(t,["endpoints"],S)}const g=u(i,["labels"]);g!=null&&c(t,["labels"],g);const y=u(i,["_self"]);y!=null&&c(t,["tunedModelInfo"],aC(y));const h=u(i,["defaultCheckpointId"]);h!=null&&c(t,["defaultCheckpointId"],h);const v=u(i,["checkpoints"]);if(v!=null){let S=v;Array.isArray(S)&&(S=S.map(E=>E)),c(t,["checkpoints"],S)}return t}function F_(i){const t={},l=u(i,["mediaResolution"]);l!=null&&c(t,["mediaResolution"],l);const a=u(i,["codeExecutionResult"]);a!=null&&c(t,["codeExecutionResult"],a);const r=u(i,["executableCode"]);r!=null&&c(t,["executableCode"],r);const f=u(i,["fileData"]);f!=null&&c(t,["fileData"],i_(f));const m=u(i,["functionCall"]);m!=null&&c(t,["functionCall"],o_(m));const g=u(i,["functionResponse"]);g!=null&&c(t,["functionResponse"],g);const y=u(i,["inlineData"]);y!=null&&c(t,["inlineData"],xE(y));const h=u(i,["text"]);h!=null&&c(t,["text"],h);const v=u(i,["thought"]);v!=null&&c(t,["thought"],v);const S=u(i,["thoughtSignature"]);S!=null&&c(t,["thoughtSignature"],S);const E=u(i,["videoMetadata"]);return E!=null&&c(t,["videoMetadata"],E),t}function J_(i){const t={},l=u(i,["productImage"]);return l!=null&&c(t,["image"],Ot(l)),t}function Y_(i,t){const l={},a=u(i,["numberOfImages"]);t!==void 0&&a!=null&&c(t,["parameters","sampleCount"],a);const r=u(i,["baseSteps"]);t!==void 0&&r!=null&&c(t,["parameters","baseSteps"],r);const f=u(i,["outputGcsUri"]);t!==void 0&&f!=null&&c(t,["parameters","storageUri"],f);const m=u(i,["seed"]);t!==void 0&&m!=null&&c(t,["parameters","seed"],m);const g=u(i,["safetyFilterLevel"]);t!==void 0&&g!=null&&c(t,["parameters","safetySetting"],g);const y=u(i,["personGeneration"]);t!==void 0&&y!=null&&c(t,["parameters","personGeneration"],y);const h=u(i,["addWatermark"]);t!==void 0&&h!=null&&c(t,["parameters","addWatermark"],h);const v=u(i,["outputMimeType"]);t!==void 0&&v!=null&&c(t,["parameters","outputOptions","mimeType"],v);const S=u(i,["outputCompressionQuality"]);t!==void 0&&S!=null&&c(t,["parameters","outputOptions","compressionQuality"],S);const E=u(i,["enhancePrompt"]);t!==void 0&&E!=null&&c(t,["parameters","enhancePrompt"],E);const C=u(i,["labels"]);return t!==void 0&&C!=null&&c(t,["labels"],C),l}function X_(i,t){const l={},a=u(t,["model"]);a!=null&&c(l,["_url","model"],Te(i,a));const r=u(t,["source"]);r!=null&&Q_(r,l);const f=u(t,["config"]);return f!=null&&Y_(f,l),l}function K_(i){const t={},l=u(i,["predictions"]);if(l!=null){let a=l;Array.isArray(a)&&(a=a.map(r=>Ha(r))),c(t,["generatedImages"],a)}return t}function Q_(i,t){const l={},a=u(i,["prompt"]);t!==void 0&&a!=null&&c(t,["instances[0]","prompt"],a);const r=u(i,["personImage"]);t!==void 0&&r!=null&&c(t,["instances[0]","personImage","image"],Ot(r));const f=u(i,["productImages"]);if(t!==void 0&&f!=null){let m=f;Array.isArray(m)&&(m=m.map(g=>J_(g))),c(t,["instances[0]","productImages"],m)}return l}function Z_(i){const t={},l=u(i,["referenceImage"]);l!=null&&c(t,["referenceImage"],Ot(l));const a=u(i,["referenceId"]);a!=null&&c(t,["referenceId"],a);const r=u(i,["referenceType"]);r!=null&&c(t,["referenceType"],r);const f=u(i,["maskImageConfig"]);f!=null&&c(t,["maskImageConfig"],O_(f));const m=u(i,["controlImageConfig"]);m!=null&&c(t,["controlImageConfig"],HE(m));const g=u(i,["styleImageConfig"]);g!=null&&c(t,["styleImageConfig"],g);const y=u(i,["subjectImageConfig"]);return y!=null&&c(t,["subjectImageConfig"],y),t}function eg(i){const t={},l=u(i,["safetyAttributes","categories"]);l!=null&&c(t,["categories"],l);const a=u(i,["safetyAttributes","scores"]);a!=null&&c(t,["scores"],a);const r=u(i,["contentType"]);return r!=null&&c(t,["contentType"],r),t}function tg(i){const t={},l=u(i,["safetyAttributes","categories"]);l!=null&&c(t,["categories"],l);const a=u(i,["safetyAttributes","scores"]);a!=null&&c(t,["scores"],a);const r=u(i,["contentType"]);return r!=null&&c(t,["contentType"],r),t}function $_(i){const t={},l=u(i,["category"]);if(l!=null&&c(t,["category"],l),u(i,["method"])!==void 0)throw new Error("method parameter is not supported in Gemini API.");const a=u(i,["threshold"]);return a!=null&&c(t,["threshold"],a),t}function W_(i){const t={},l=u(i,["image"]);return l!=null&&c(t,["image"],Ot(l)),t}function j_(i,t){const l={},a=u(i,["mode"]);t!==void 0&&a!=null&&c(t,["parameters","mode"],a);const r=u(i,["maxPredictions"]);t!==void 0&&r!=null&&c(t,["parameters","maxPredictions"],r);const f=u(i,["confidenceThreshold"]);t!==void 0&&f!=null&&c(t,["parameters","confidenceThreshold"],f);const m=u(i,["maskDilation"]);t!==void 0&&m!=null&&c(t,["parameters","maskDilation"],m);const g=u(i,["binaryColorThreshold"]);t!==void 0&&g!=null&&c(t,["parameters","binaryColorThreshold"],g);const y=u(i,["labels"]);return t!==void 0&&y!=null&&c(t,["labels"],y),l}function eC(i,t){const l={},a=u(t,["model"]);a!=null&&c(l,["_url","model"],Te(i,a));const r=u(t,["source"]);r!=null&&nC(r,l);const f=u(t,["config"]);return f!=null&&j_(f,l),l}function tC(i){const t={},l=u(i,["predictions"]);if(l!=null){let a=l;Array.isArray(a)&&(a=a.map(r=>M_(r))),c(t,["generatedMasks"],a)}return t}function nC(i,t){const l={},a=u(i,["prompt"]);t!==void 0&&a!=null&&c(t,["instances[0]","prompt"],a);const r=u(i,["image"]);t!==void 0&&r!=null&&c(t,["instances[0]","image"],Ot(r));const f=u(i,["scribbleImage"]);return t!==void 0&&f!=null&&c(t,["instances[0]","scribble"],W_(f)),l}function iC(i){const t={},l=u(i,["functionCallingConfig"]);l!=null&&c(t,["functionCallingConfig"],l_(l));const a=u(i,["retrievalConfig"]);return a!=null&&c(t,["retrievalConfig"],a),t}function oC(i){const t={},l=u(i,["functionDeclarations"]);if(l!=null){let v=l;Array.isArray(v)&&(v=v.map(S=>S)),c(t,["functionDeclarations"],v)}if(u(i,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const a=u(i,["googleSearchRetrieval"]);a!=null&&c(t,["googleSearchRetrieval"],a);const r=u(i,["computerUse"]);r!=null&&c(t,["computerUse"],r);const f=u(i,["fileSearch"]);f!=null&&c(t,["fileSearch"],f);const m=u(i,["codeExecution"]);if(m!=null&&c(t,["codeExecution"],m),u(i,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const g=u(i,["googleMaps"]);g!=null&&c(t,["googleMaps"],w_(g));const y=u(i,["googleSearch"]);y!=null&&c(t,["googleSearch"],b_(y));const h=u(i,["urlContext"]);return h!=null&&c(t,["urlContext"],h),t}function ng(i){const t={},l=u(i,["functionDeclarations"]);if(l!=null){let S=l;Array.isArray(S)&&(S=S.map(E=>a_(E))),c(t,["functionDeclarations"],S)}const a=u(i,["retrieval"]);a!=null&&c(t,["retrieval"],a);const r=u(i,["googleSearchRetrieval"]);r!=null&&c(t,["googleSearchRetrieval"],r);const f=u(i,["computerUse"]);if(f!=null&&c(t,["computerUse"],f),u(i,["fileSearch"])!==void 0)throw new Error("fileSearch parameter is not supported in Vertex AI.");const m=u(i,["codeExecution"]);m!=null&&c(t,["codeExecution"],m);const g=u(i,["enterpriseWebSearch"]);g!=null&&c(t,["enterpriseWebSearch"],g);const y=u(i,["googleMaps"]);y!=null&&c(t,["googleMaps"],y);const h=u(i,["googleSearch"]);h!=null&&c(t,["googleSearch"],h);const v=u(i,["urlContext"]);return v!=null&&c(t,["urlContext"],v),t}function lC(i){const t={},l=u(i,["baseModel"]);l!=null&&c(t,["baseModel"],l);const a=u(i,["createTime"]);a!=null&&c(t,["createTime"],a);const r=u(i,["updateTime"]);return r!=null&&c(t,["updateTime"],r),t}function aC(i){const t={},l=u(i,["labels","google-vertex-llm-tuning-base-model-id"]);l!=null&&c(t,["baseModel"],l);const a=u(i,["createTime"]);a!=null&&c(t,["createTime"],a);const r=u(i,["updateTime"]);return r!=null&&c(t,["updateTime"],r),t}function sC(i,t){const l={},a=u(i,["displayName"]);t!==void 0&&a!=null&&c(t,["displayName"],a);const r=u(i,["description"]);t!==void 0&&r!=null&&c(t,["description"],r);const f=u(i,["defaultCheckpointId"]);return t!==void 0&&f!=null&&c(t,["defaultCheckpointId"],f),l}function rC(i,t){const l={},a=u(i,["displayName"]);t!==void 0&&a!=null&&c(t,["displayName"],a);const r=u(i,["description"]);t!==void 0&&r!=null&&c(t,["description"],r);const f=u(i,["defaultCheckpointId"]);return t!==void 0&&f!=null&&c(t,["defaultCheckpointId"],f),l}function uC(i,t){const l={},a=u(t,["model"]);a!=null&&c(l,["_url","name"],Te(i,a));const r=u(t,["config"]);return r!=null&&sC(r,l),l}function cC(i,t){const l={},a=u(t,["model"]);a!=null&&c(l,["_url","model"],Te(i,a));const r=u(t,["config"]);return r!=null&&rC(r,l),l}function fC(i,t){const l={},a=u(i,["outputGcsUri"]);t!==void 0&&a!=null&&c(t,["parameters","storageUri"],a);const r=u(i,["safetyFilterLevel"]);t!==void 0&&r!=null&&c(t,["parameters","safetySetting"],r);const f=u(i,["personGeneration"]);t!==void 0&&f!=null&&c(t,["parameters","personGeneration"],f);const m=u(i,["includeRaiReason"]);t!==void 0&&m!=null&&c(t,["parameters","includeRaiReason"],m);const g=u(i,["outputMimeType"]);t!==void 0&&g!=null&&c(t,["parameters","outputOptions","mimeType"],g);const y=u(i,["outputCompressionQuality"]);t!==void 0&&y!=null&&c(t,["parameters","outputOptions","compressionQuality"],y);const h=u(i,["enhanceInputImage"]);t!==void 0&&h!=null&&c(t,["parameters","upscaleConfig","enhanceInputImage"],h);const v=u(i,["imagePreservationFactor"]);t!==void 0&&v!=null&&c(t,["parameters","upscaleConfig","imagePreservationFactor"],v);const S=u(i,["labels"]);t!==void 0&&S!=null&&c(t,["labels"],S);const E=u(i,["numberOfImages"]);t!==void 0&&E!=null&&c(t,["parameters","sampleCount"],E);const C=u(i,["mode"]);return t!==void 0&&C!=null&&c(t,["parameters","mode"],C),l}function dC(i,t){const l={},a=u(t,["model"]);a!=null&&c(l,["_url","model"],Te(i,a));const r=u(t,["image"]);r!=null&&c(l,["instances[0]","image"],Ot(r));const f=u(t,["upscaleFactor"]);f!=null&&c(l,["parameters","upscaleConfig","upscaleFactor"],f);const m=u(t,["config"]);return m!=null&&fC(m,l),l}function pC(i){const t={},l=u(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=u(i,["predictions"]);if(a!=null){let r=a;Array.isArray(r)&&(r=r.map(f=>Ha(f))),c(t,["generatedImages"],r)}return t}function mC(i){const t={},l=u(i,["uri"]);l!=null&&c(t,["uri"],l);const a=u(i,["encodedVideo"]);a!=null&&c(t,["videoBytes"],On(a));const r=u(i,["encoding"]);return r!=null&&c(t,["mimeType"],r),t}function hC(i){const t={},l=u(i,["gcsUri"]);l!=null&&c(t,["uri"],l);const a=u(i,["bytesBase64Encoded"]);a!=null&&c(t,["videoBytes"],On(a));const r=u(i,["mimeType"]);return r!=null&&c(t,["mimeType"],r),t}function gC(i){const t={},l=u(i,["image"]);l!=null&&c(t,["_self"],Ot(l));const a=u(i,["maskMode"]);return a!=null&&c(t,["maskMode"],a),t}function yC(i){const t={},l=u(i,["image"]);l!=null&&c(t,["image"],qa(l));const a=u(i,["referenceType"]);return a!=null&&c(t,["referenceType"],a),t}function vC(i){const t={},l=u(i,["image"]);l!=null&&c(t,["image"],Ot(l));const a=u(i,["referenceType"]);return a!=null&&c(t,["referenceType"],a),t}function ig(i){const t={},l=u(i,["uri"]);l!=null&&c(t,["uri"],l);const a=u(i,["videoBytes"]);a!=null&&c(t,["encodedVideo"],On(a));const r=u(i,["mimeType"]);return r!=null&&c(t,["encoding"],r),t}function og(i){const t={},l=u(i,["uri"]);l!=null&&c(t,["gcsUri"],l);const a=u(i,["videoBytes"]);a!=null&&c(t,["bytesBase64Encoded"],On(a));const r=u(i,["mimeType"]);return r!=null&&c(t,["mimeType"],r),t}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function TC(i,t){const l={},a=u(i,["displayName"]);return t!==void 0&&a!=null&&c(t,["displayName"],a),l}function SC(i){const t={},l=u(i,["config"]);return l!=null&&TC(l,t),t}function EC(i,t){const l={},a=u(i,["force"]);return t!==void 0&&a!=null&&c(t,["_query","force"],a),l}function _C(i){const t={},l=u(i,["name"]);l!=null&&c(t,["_url","name"],l);const a=u(i,["config"]);return a!=null&&EC(a,t),t}function CC(i){const t={},l=u(i,["name"]);return l!=null&&c(t,["_url","name"],l),t}function AC(i,t){const l={},a=u(i,["customMetadata"]);if(t!==void 0&&a!=null){let f=a;Array.isArray(f)&&(f=f.map(m=>m)),c(t,["customMetadata"],f)}const r=u(i,["chunkingConfig"]);return t!==void 0&&r!=null&&c(t,["chunkingConfig"],r),l}function RC(i){const t={},l=u(i,["name"]);l!=null&&c(t,["name"],l);const a=u(i,["metadata"]);a!=null&&c(t,["metadata"],a);const r=u(i,["done"]);r!=null&&c(t,["done"],r);const f=u(i,["error"]);f!=null&&c(t,["error"],f);const m=u(i,["response"]);return m!=null&&c(t,["response"],NC(m)),t}function MC(i){const t={},l=u(i,["fileSearchStoreName"]);l!=null&&c(t,["_url","file_search_store_name"],l);const a=u(i,["fileName"]);a!=null&&c(t,["fileName"],a);const r=u(i,["config"]);return r!=null&&AC(r,t),t}function NC(i){const t={},l=u(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=u(i,["parent"]);a!=null&&c(t,["parent"],a);const r=u(i,["documentName"]);return r!=null&&c(t,["documentName"],r),t}function IC(i,t){const l={},a=u(i,["pageSize"]);t!==void 0&&a!=null&&c(t,["_query","pageSize"],a);const r=u(i,["pageToken"]);return t!==void 0&&r!=null&&c(t,["_query","pageToken"],r),l}function xC(i){const t={},l=u(i,["config"]);return l!=null&&IC(l,t),t}function DC(i){const t={},l=u(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=u(i,["nextPageToken"]);a!=null&&c(t,["nextPageToken"],a);const r=u(i,["fileSearchStores"]);if(r!=null){let f=r;Array.isArray(f)&&(f=f.map(m=>m)),c(t,["fileSearchStores"],f)}return t}function lg(i,t){const l={},a=u(i,["mimeType"]);t!==void 0&&a!=null&&c(t,["mimeType"],a);const r=u(i,["displayName"]);t!==void 0&&r!=null&&c(t,["displayName"],r);const f=u(i,["customMetadata"]);if(t!==void 0&&f!=null){let g=f;Array.isArray(g)&&(g=g.map(y=>y)),c(t,["customMetadata"],g)}const m=u(i,["chunkingConfig"]);return t!==void 0&&m!=null&&c(t,["chunkingConfig"],m),l}function UC(i){const t={},l=u(i,["fileSearchStoreName"]);l!=null&&c(t,["_url","file_search_store_name"],l);const a=u(i,["config"]);return a!=null&&lg(a,t),t}function wC(i){const t={},l=u(i,["sdkHttpResponse"]);return l!=null&&c(t,["sdkHttpResponse"],l),t}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const bC="Content-Type",LC="X-Server-Timeout",GC="User-Agent",Cu="x-goog-api-client",HC="1.34.0",qC=`google-genai-sdk/${HC}`,VC="v1beta1",zC="v1beta";class BC{constructor(t){var l,a;this.clientOptions=Object.assign(Object.assign({},t),{project:t.project,location:t.location,apiKey:t.apiKey,vertexai:t.vertexai});const r={};this.clientOptions.vertexai?(r.apiVersion=(l=this.clientOptions.apiVersion)!==null&&l!==void 0?l:VC,r.baseUrl=this.baseUrlFromProjectLocation(),this.normalizeAuthParameters()):(r.apiVersion=(a=this.clientOptions.apiVersion)!==null&&a!==void 0?a:zC,r.baseUrl="https://generativelanguage.googleapis.com/"),r.headers=this.getDefaultHeaders(),this.clientOptions.httpOptions=r,t.httpOptions&&(this.clientOptions.httpOptions=this.patchHttpOptions(r,t.httpOptions))}baseUrlFromProjectLocation(){return this.clientOptions.project&&this.clientOptions.location&&this.clientOptions.location!=="global"?`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 t;return(t=this.clientOptions.vertexai)!==null&&t!==void 0?t:!1}getProject(){return this.clientOptions.project}getLocation(){return this.clientOptions.location}async getAuthHeaders(){const t=new Headers;return await this.clientOptions.auth.addAuthHeaders(t),t}getApiVersion(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.apiVersion!==void 0)return this.clientOptions.httpOptions.apiVersion;throw new Error("API version is not set.")}getBaseUrl(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.baseUrl!==void 0)return this.clientOptions.httpOptions.baseUrl;throw new Error("Base URL is not set.")}getRequestUrl(){return this.getRequestUrlInternal(this.clientOptions.httpOptions)}getHeaders(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.headers!==void 0)return this.clientOptions.httpOptions.headers;throw new Error("Headers are not set.")}getRequestUrlInternal(t){if(!t||t.baseUrl===void 0||t.apiVersion===void 0)throw new Error("HTTP options are not correctly set.");const a=[t.baseUrl.endsWith("/")?t.baseUrl.slice(0,-1):t.baseUrl];return t.apiVersion&&t.apiVersion!==""&&a.push(t.apiVersion),a.join("/")}getBaseResourcePath(){return`projects/${this.clientOptions.project}/locations/${this.clientOptions.location}`}getApiKey(){return this.clientOptions.apiKey}getWebsocketBaseUrl(){const t=this.getBaseUrl(),l=new URL(t);return l.protocol=l.protocol=="http:"?"ws":"wss",l.toString()}setBaseUrl(t){if(this.clientOptions.httpOptions)this.clientOptions.httpOptions.baseUrl=t;else throw new Error("HTTP options are not correctly set.")}constructUrl(t,l,a){const r=[this.getRequestUrlInternal(l)];return a&&r.push(this.getBaseResourcePath()),t!==""&&r.push(t),new URL(`${r.join("/")}`)}shouldPrependVertexProjectPath(t){return!(this.clientOptions.apiKey||!this.clientOptions.vertexai||t.path.startsWith("projects/")||t.httpMethod==="GET"&&t.path.startsWith("publishers/google/models"))}async request(t){let l=this.clientOptions.httpOptions;t.httpOptions&&(l=this.patchHttpOptions(this.clientOptions.httpOptions,t.httpOptions));const a=this.shouldPrependVertexProjectPath(t),r=this.constructUrl(t.path,l,a);if(t.queryParams)for(const[m,g]of Object.entries(t.queryParams))r.searchParams.append(m,String(g));let f={};if(t.httpMethod==="GET"){if(t.body&&t.body!=="{}")throw new Error("Request body should be empty for GET request, but got non empty request body")}else f.body=t.body;return f=await this.includeExtraHttpOptionsToRequestInit(f,l,r.toString(),t.abortSignal),this.unaryApiCall(r,f,t.httpMethod)}patchHttpOptions(t,l){const a=JSON.parse(JSON.stringify(t));for(const[r,f]of Object.entries(l))typeof f=="object"?a[r]=Object.assign(Object.assign({},a[r]),f):f!==void 0&&(a[r]=f);return a}async requestStream(t){let l=this.clientOptions.httpOptions;t.httpOptions&&(l=this.patchHttpOptions(this.clientOptions.httpOptions,t.httpOptions));const a=this.shouldPrependVertexProjectPath(t),r=this.constructUrl(t.path,l,a);(!r.searchParams.has("alt")||r.searchParams.get("alt")!=="sse")&&r.searchParams.set("alt","sse");let f={};return f.body=t.body,f=await this.includeExtraHttpOptionsToRequestInit(f,l,r.toString(),t.abortSignal),this.streamApiCall(r,f,t.httpMethod)}async includeExtraHttpOptionsToRequestInit(t,l,a,r){if(l&&l.timeout||r){const f=new AbortController,m=f.signal;if(l.timeout&&(l==null?void 0:l.timeout)>0){const g=setTimeout(()=>f.abort(),l.timeout);g&&typeof g.unref=="function"&&g.unref()}r&&r.addEventListener("abort",()=>{f.abort()}),t.signal=m}return l&&l.extraBody!==null&&PC(t,l.extraBody),t.headers=await this.getHeadersInternal(l,a),t}async unaryApiCall(t,l,a){return this.apiCall(t.toString(),Object.assign(Object.assign({},l),{method:a})).then(async r=>(await Sh(r),new vu(r))).catch(r=>{throw r instanceof Error?r:new Error(JSON.stringify(r))})}async streamApiCall(t,l,a){return this.apiCall(t.toString(),Object.assign(Object.assign({},l),{method:a})).then(async r=>(await Sh(r),this.processStreamResponse(r))).catch(r=>{throw r instanceof Error?r:new Error(JSON.stringify(r))})}processStreamResponse(t){return Pt(this,arguments,function*(){var a;const r=(a=t==null?void 0:t.body)===null||a===void 0?void 0:a.getReader(),f=new TextDecoder("utf-8");if(!r)throw new Error("Response body is empty");try{let m="";const g="data:",y=[` `,"\r\r",`\r \r `];for(;;){const{done:h,value:v}=yield oe(r.read());if(h){if(m.trim().length>0)throw new Error("Incomplete JSON segment at the end");break}const S=f.decode(v,{stream:!0});try{const U=JSON.parse(S);if("error"in U){const H=JSON.parse(JSON.stringify(U.error)),b=H.status,P=H.code,X=`got status: ${b}. ${JSON.stringify(U)}`;if(P>=400&&P<600)throw new La({message:X,status:P})}}catch(U){if(U.name==="ApiError")throw U}m+=S;let E=-1,C=0;for(;;){E=-1,C=0;for(const b of y){const P=m.indexOf(b);P!==-1&&(E===-1||P{throw new Error(`exception ${a} sending request`)})}getDefaultHeaders(){const t={},l=qC+" "+this.clientOptions.userAgentExtra;return t[GC]=l,t[Cu]=l,t[bC]="application/json",t}async getHeadersInternal(t,l){const a=new Headers;if(t&&t.headers){for(const[r,f]of Object.entries(t.headers))a.append(r,f);t.timeout&&t.timeout>0&&a.append(LC,String(Math.ceil(t.timeout/1e3)))}return await this.clientOptions.auth.addAuthHeaders(a,l),a}getFileName(t){var l;let a="";return typeof t=="string"&&(a=t.replace(/[/\\]+$/,""),a=(l=a.split(/[/\\]/).pop())!==null&&l!==void 0?l:""),a}async uploadFile(t,l){var a;const r={};l!=null&&(r.mimeType=l.mimeType,r.name=l.name,r.displayName=l.displayName),r.name&&!r.name.startsWith("files/")&&(r.name=`files/${r.name}`);const f=this.clientOptions.uploader,m=await f.stat(t);r.sizeBytes=String(m.size);const g=(a=l==null?void 0:l.mimeType)!==null&&a!==void 0?a:m.type;if(g===void 0||g==="")throw new Error("Can not determine mimeType. Please provide mimeType in the config.");r.mimeType=g;const y={file:r},h=this.getFileName(t),v=Y("upload/v1beta/files",y._url),S=await this.fetchUploadUrl(v,r.sizeBytes,r.mimeType,h,y,l==null?void 0:l.httpOptions);return f.upload(t,S,this)}async uploadFileToFileSearchStore(t,l,a){var r;const f=this.clientOptions.uploader,m=await f.stat(l),g=String(m.size),y=(r=a==null?void 0:a.mimeType)!==null&&r!==void 0?r:m.type;if(y===void 0||y==="")throw new Error("Can not determine mimeType. Please provide mimeType in the config.");const h=`upload/v1beta/${t}:uploadToFileSearchStore`,v=this.getFileName(l),S={};a!=null&&lg(a,S);const E=await this.fetchUploadUrl(h,g,y,v,S,a==null?void 0:a.httpOptions);return f.uploadToFileSearchStore(l,E,this)}async downloadFile(t){await this.clientOptions.downloader.download(t,this)}async fetchUploadUrl(t,l,a,r,f,m){var g;let y={};m?y=m:y={apiVersion:"",headers:Object.assign({"Content-Type":"application/json","X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":`${l}`,"X-Goog-Upload-Header-Content-Type":`${a}`},r?{"X-Goog-Upload-File-Name":r}:{})};const h=await this.request({path:t,body:JSON.stringify(f),httpMethod:"POST",httpOptions:y});if(!h||!(h!=null&&h.headers))throw new Error("Server did not return an HttpResponse or the returned HttpResponse did not have headers.");const v=(g=h==null?void 0:h.headers)===null||g===void 0?void 0:g["x-goog-upload-url"];if(v===void 0)throw new Error("Failed to get upload url. Server did not return the x-google-upload-url in the headers");return v}}async function Sh(i){var t;if(i===void 0)throw new Error("response is undefined");if(!i.ok){const l=i.status;let a;!((t=i.headers.get("content-type"))===null||t===void 0)&&t.includes("application/json")?a=await i.json():a={error:{message:await i.text(),code:i.status,status:i.statusText}};const r=JSON.stringify(a);throw l>=400&&l<600?new La({message:r,status:l}):new Error(r)}}function PC(i,t){if(!t||Object.keys(t).length===0)return;if(i.body instanceof Blob){console.warn("includeExtraBodyToRequestInit: extraBody provided but current request body is a Blob. extraBody will be ignored as merging is not supported for Blob bodies.");return}let l={};if(typeof i.body=="string"&&i.body.length>0)try{const f=JSON.parse(i.body);if(typeof f=="object"&&f!==null&&!Array.isArray(f))l=f;else{console.warn("includeExtraBodyToRequestInit: Original request body is valid JSON but not a non-array object. Skip applying extraBody to the request body.");return}}catch{console.warn("includeExtraBodyToRequestInit: Original request body is not valid JSON. Skip applying extraBody to the request body.");return}function a(f,m){const g=Object.assign({},f);for(const y in m)if(Object.prototype.hasOwnProperty.call(m,y)){const h=m[y],v=g[y];h&&typeof h=="object"&&!Array.isArray(h)&&v&&typeof v=="object"&&!Array.isArray(v)?g[y]=a(v,h):(v&&h&&typeof v!=typeof h&&console.warn(`includeExtraBodyToRequestInit:deepMerge: Type mismatch for key "${y}". Original type: ${typeof v}, New type: ${typeof h}. Overwriting.`),g[y]=h)}return g}const r=a(l,t);i.body=JSON.stringify(r)}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const kC="mcp_used/unknown";let OC=!1;function ag(i){for(const t of i)if(FC(t)||typeof t=="object"&&"inputSchema"in t)return!0;return OC}function sg(i){var t;const l=(t=i[Cu])!==null&&t!==void 0?t:"";i[Cu]=(l+` ${kC}`).trimStart()}function FC(i){return i!==null&&typeof i=="object"&&i instanceof Vu}function JC(i){return Pt(this,arguments,function*(l,a=100){let r,f=0;for(;f0)return;const f={},m=[];for(const v of this.mcpClients)try{for(var g=!0,y=(l=void 0,kt(JC(v))),h;h=await y.next(),t=h.done,!t;g=!0){r=h.value,g=!1;const S=r;m.push(S);const E=S.name;if(f[E])throw new Error(`Duplicate function name ${E} found in MCP tools. Please ensure function names are unique.`);f[E]=v}}catch(S){l={error:S}}finally{try{!g&&!t&&(a=y.return)&&await a.call(y)}finally{if(l)throw l.error}}this.mcpTools=m,this.functionNameToMcpClient=f}async tool(){return await this.initialize(),CT(this.mcpTools,this.config)}async callTool(t){await this.initialize();const l=[];for(const a of t)if(a.name in this.functionNameToMcpClient){const r=this.functionNameToMcpClient[a.name];let f;this.config.timeout&&(f={timeout:this.config.timeout});const m=await r.callTool({name:a.name,arguments:a.args},void 0,f);l.push({functionResponse:{name:a.name,response:m.isError?{error:m}:m}})}return l}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */async function YC(i,t,l){const a=new hT;let r;l.data instanceof Blob?r=JSON.parse(await l.data.text()):r=JSON.parse(l.data),Object.assign(a,r),t(a)}class XC{constructor(t,l,a){this.apiClient=t,this.auth=l,this.webSocketFactory=a}async connect(t){var l,a;if(this.apiClient.isVertexAI())throw new Error("Live music is not supported for Vertex AI.");console.warn("Live music generation is experimental and may change in future versions.");const r=this.apiClient.getWebsocketBaseUrl(),f=this.apiClient.getApiVersion(),m=ZC(this.apiClient.getDefaultHeaders()),g=this.apiClient.getApiKey(),y=`${r}/ws/google.ai.generativelanguage.${f}.GenerativeService.BidiGenerateMusic?key=${g}`;let h=()=>{};const v=new Promise(k=>{h=k}),S=t.callbacks,E=function(){h({})},C=this.apiClient,U={onopen:E,onmessage:k=>{YC(C,S.onmessage,k)},onerror:(l=S==null?void 0:S.onerror)!==null&&l!==void 0?l:function(k){},onclose:(a=S==null?void 0:S.onclose)!==null&&a!==void 0?a:function(k){}},H=this.webSocketFactory.create(y,QC(m),U);H.connect(),await v;const X={setup:{model:Te(this.apiClient,t.model)}};return H.send(JSON.stringify(X)),new KC(H,this.apiClient)}}class KC{constructor(t,l){this.conn=t,this.apiClient=l}async setWeightedPrompts(t){if(!t.weightedPrompts||Object.keys(t.weightedPrompts).length===0)throw new Error("Weighted prompts must be set and contain at least one entry.");const l=SE(t);this.conn.send(JSON.stringify({clientContent:l}))}async setMusicGenerationConfig(t){t.musicGenerationConfig||(t.musicGenerationConfig={});const l=TE(t);this.conn.send(JSON.stringify(l))}sendPlaybackControl(t){const l={playbackControl:t};this.conn.send(JSON.stringify(l))}play(){this.sendPlaybackControl(Zi.PLAY)}pause(){this.sendPlaybackControl(Zi.PAUSE)}stop(){this.sendPlaybackControl(Zi.STOP)}resetContext(){this.sendPlaybackControl(Zi.RESET_CONTEXT)}close(){this.conn.close()}}function QC(i){const t={};return i.forEach((l,a)=>{t[a]=l}),t}function ZC(i){const t=new Headers;for(const[l,a]of Object.entries(i))t.append(l,a);return t}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const $C="FunctionResponse request must have an `id` field from the response of a ToolCall.FunctionalCalls in Google AI.";async function WC(i,t,l){const a=new mT;let r;l.data instanceof Blob?r=await l.data.text():l.data instanceof ArrayBuffer?r=new TextDecoder().decode(l.data):r=l.data;const f=JSON.parse(r);if(i.isVertexAI()){const m=CE(f);Object.assign(a,m)}else Object.assign(a,f);t(a)}class jC{constructor(t,l,a){this.apiClient=t,this.auth=l,this.webSocketFactory=a,this.music=new XC(this.apiClient,this.auth,this.webSocketFactory)}async connect(t){var l,a,r,f,m,g;if(t.config&&t.config.httpOptions)throw new Error("The Live module does not support httpOptions at request-level in LiveConnectConfig yet. Please use the client-level httpOptions configuration instead.");const y=this.apiClient.getWebsocketBaseUrl(),h=this.apiClient.getApiVersion();let v;const S=this.apiClient.getHeaders();t.config&&t.config.tools&&ag(t.config.tools)&&sg(S);const E=iA(S);if(this.apiClient.isVertexAI())v=`${y}/ws/google.cloud.aiplatform.${h}.LlmBidiService/BidiGenerateContent`,await this.auth.addAuthHeaders(E,v);else{const W=this.apiClient.getApiKey();let de="BidiGenerateContent",Ce="key";W!=null&&W.startsWith("auth_tokens/")&&(console.warn("Warning: Ephemeral token support is experimental and may change in future versions."),h!=="v1alpha"&&console.warn("Warning: The SDK's ephemeral token support is in v1alpha only. Please use const ai = new GoogleGenAI({apiKey: token.name, httpOptions: { apiVersion: 'v1alpha' }}); before session connection."),de="BidiGenerateContentConstrained",Ce="access_token"),v=`${y}/ws/google.ai.generativelanguage.${h}.GenerativeService.${de}?${Ce}=${W}`}let C=()=>{};const U=new Promise(W=>{C=W}),H=t.callbacks,b=function(){var W;(W=H==null?void 0:H.onopen)===null||W===void 0||W.call(H),C({})},P=this.apiClient,X={onopen:b,onmessage:W=>{WC(P,H.onmessage,W)},onerror:(l=H==null?void 0:H.onerror)!==null&&l!==void 0?l:function(W){},onclose:(a=H==null?void 0:H.onclose)!==null&&a!==void 0?a:function(W){}},k=this.webSocketFactory.create(v,nA(E),X);k.connect(),await U;let K=Te(this.apiClient,t.model);if(this.apiClient.isVertexAI()&&K.startsWith("publishers/")){const W=this.apiClient.getProject(),de=this.apiClient.getLocation();K=`projects/${W}/locations/${de}/`+K}let ee={};this.apiClient.isVertexAI()&&((r=t.config)===null||r===void 0?void 0:r.responseModalities)===void 0&&(t.config===void 0?t.config={responseModalities:[Ia.AUDIO]}:t.config.responseModalities=[Ia.AUDIO]),!((f=t.config)===null||f===void 0)&&f.generationConfig&&console.warn("Setting `LiveConnectConfig.generation_config` is deprecated, please set the fields on `LiveConnectConfig` directly. This will become an error in a future version (not before Q3 2025).");const te=(g=(m=t.config)===null||m===void 0?void 0:m.tools)!==null&&g!==void 0?g:[],F=[];for(const W of te)if(this.isCallableTool(W)){const de=W;F.push(await de.tool())}else F.push(W);F.length>0&&(t.config.tools=F);const he={model:K,config:t.config,callbacks:t.callbacks};return this.apiClient.isVertexAI()?ee=vE(this.apiClient,he):ee=yE(this.apiClient,he),delete ee.config,k.send(JSON.stringify(ee)),new tA(k,this.apiClient)}isCallableTool(t){return"callTool"in t&&typeof t.callTool=="function"}}const eA={turnComplete:!0};class tA{constructor(t,l){this.conn=t,this.apiClient=l}tLiveClientContent(t,l){if(l.turns!==null&&l.turns!==void 0){let a=[];try{a=Ht(l.turns),t.isVertexAI()||(a=a.map(r=>Ga(r)))}catch{throw new Error(`Failed to parse client content "turns", type: '${typeof l.turns}'`)}return{clientContent:{turns:a,turnComplete:l.turnComplete}}}return{clientContent:{turnComplete:l.turnComplete}}}tLiveClienttToolResponse(t,l){let a=[];if(l.functionResponses==null)throw new Error("functionResponses is required.");if(Array.isArray(l.functionResponses)?a=l.functionResponses:a=[l.functionResponses],a.length===0)throw new Error("functionResponses is required.");for(const f of a){if(typeof f!="object"||f===null||!("name"in f)||!("response"in f))throw new Error(`Could not parse function response, type '${typeof f}'.`);if(!t.isVertexAI()&&!("id"in f))throw new Error($C)}return{toolResponse:{functionResponses:a}}}sendClientContent(t){t=Object.assign(Object.assign({},eA),t);const l=this.tLiveClientContent(this.apiClient,t);this.conn.send(JSON.stringify(l))}sendRealtimeInput(t){let l={};this.apiClient.isVertexAI()?l={realtimeInput:_E(t)}:l={realtimeInput:EE(t)},this.conn.send(JSON.stringify(l))}sendToolResponse(t){if(t.functionResponses==null)throw new Error("Tool response parameters are required.");const l=this.tLiveClienttToolResponse(this.apiClient,t);this.conn.send(JSON.stringify(l))}close(){this.conn.close()}}function nA(i){const t={};return i.forEach((l,a)=>{t[a]=l}),t}function iA(i){const t=new Headers;for(const[l,a]of Object.entries(i))t.append(l,a);return t}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const Eh=10;function _h(i){var t,l,a;if(!((t=i==null?void 0:i.automaticFunctionCalling)===null||t===void 0)&&t.disable)return!0;let r=!1;for(const m of(l=i==null?void 0:i.tools)!==null&&l!==void 0?l:[])if(ji(m)){r=!0;break}if(!r)return!0;const f=(a=i==null?void 0:i.automaticFunctionCalling)===null||a===void 0?void 0:a.maximumRemoteCalls;return f&&(f<0||!Number.isInteger(f))||f==0?(console.warn("Invalid maximumRemoteCalls value provided for automatic function calling. Disabled automatic function calling. Please provide a valid integer value greater than 0. maximumRemoteCalls provided:",f),!0):!1}function ji(i){return"callTool"in i&&typeof i.callTool=="function"}function oA(i){var t,l,a;return(a=(l=(t=i.config)===null||t===void 0?void 0:t.tools)===null||l===void 0?void 0:l.some(r=>ji(r)))!==null&&a!==void 0?a:!1}function Ch(i){var t;const l=[];return!((t=i==null?void 0:i.config)===null||t===void 0)&&t.tools&&i.config.tools.forEach((a,r)=>{if(ji(a))return;const f=a;f.functionDeclarations&&f.functionDeclarations.length>0&&l.push(r)}),l}function Ah(i){var t;return!(!((t=i==null?void 0:i.automaticFunctionCalling)===null||t===void 0)&&t.ignoreCallHistory)}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class lA extends hn{constructor(t){super(),this.apiClient=t,this.generateContent=async l=>{var a,r,f,m,g;const y=await this.processParamsMaybeAddMcpUsage(l);if(this.maybeMoveToResponseJsonSchem(l),!oA(l)||_h(l.config))return await this.generateContentInternal(y);const h=Ch(l);if(h.length>0){const H=h.map(b=>`tools[${b}]`).join(", ");throw new Error(`Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations is not yet supported. Incompatible tools found at ${H}.`)}let v,S;const E=Ht(y.contents),C=(f=(r=(a=y.config)===null||a===void 0?void 0:a.automaticFunctionCalling)===null||r===void 0?void 0:r.maximumRemoteCalls)!==null&&f!==void 0?f:Eh;let U=0;for(;U{var a,r,f,m,g;if(this.maybeMoveToResponseJsonSchem(l),_h(l.config)){const S=await this.processParamsMaybeAddMcpUsage(l);return await this.generateContentStreamInternal(S)}const y=Ch(l);if(y.length>0){const S=y.map(E=>`tools[${E}]`).join(", ");throw new Error(`Incompatible tools found at ${S}. Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations" is not yet supported.`)}const h=(f=(r=(a=l==null?void 0:l.config)===null||a===void 0?void 0:a.toolConfig)===null||r===void 0?void 0:r.functionCallingConfig)===null||f===void 0?void 0:f.streamFunctionCallArguments,v=(g=(m=l==null?void 0:l.config)===null||m===void 0?void 0:m.automaticFunctionCalling)===null||g===void 0?void 0:g.disable;if(h&&!v)throw new Error("Running in streaming mode with 'streamFunctionCallArguments' enabled, this feature is not compatible with automatic function calling (AFC). Please set 'config.automaticFunctionCalling.disable' to true to disable AFC or leave 'config.toolConfig.functionCallingConfig.streamFunctionCallArguments' to be undefined or set to false to disable streaming function call arguments feature.");return await this.processAfcStream(l)},this.generateImages=async l=>await this.generateImagesInternal(l).then(a=>{var r;let f;const m=[];if(a!=null&&a.generatedImages)for(const y of a.generatedImages)y&&(y!=null&&y.safetyAttributes)&&((r=y==null?void 0:y.safetyAttributes)===null||r===void 0?void 0:r.contentType)==="Positive Prompt"?f=y==null?void 0:y.safetyAttributes:m.push(y);let g;return f?g={generatedImages:m,positivePromptSafetyAttributes:f,sdkHttpResponse:a.sdkHttpResponse}:g={generatedImages:m,sdkHttpResponse:a.sdkHttpResponse},g}),this.list=async l=>{var a;const m={config:Object.assign(Object.assign({},{queryBase:!0}),l==null?void 0:l.config)};if(this.apiClient.isVertexAI()&&!m.config.queryBase){if(!((a=m.config)===null||a===void 0)&&a.filter)throw new Error("Filtering tuned models list for Vertex AI is not currently supported");m.config.filter="labels.tune-type:*"}return new ci(mn.PAGED_ITEM_MODELS,g=>this.listInternal(g),await this.listInternal(m),m)},this.editImage=async l=>{const a={model:l.model,prompt:l.prompt,referenceImages:[],config:l.config};return l.referenceImages&&l.referenceImages&&(a.referenceImages=l.referenceImages.map(r=>r.toReferenceImageAPI())),await this.editImageInternal(a)},this.upscaleImage=async l=>{let a={numberOfImages:1,mode:"upscale"};l.config&&(a=Object.assign(Object.assign({},a),l.config));const r={model:l.model,image:l.image,upscaleFactor:l.upscaleFactor,config:a};return await this.upscaleImageInternal(r)},this.generateVideos=async l=>{var a,r,f,m,g,y;if((l.prompt||l.image||l.video)&&l.source)throw new Error("Source and prompt/image/video are mutually exclusive. Please only use source.");return this.apiClient.isVertexAI()||(!((a=l.video)===null||a===void 0)&&a.uri&&(!((r=l.video)===null||r===void 0)&&r.videoBytes)?l.video={uri:l.video.uri,mimeType:l.video.mimeType}:!((m=(f=l.source)===null||f===void 0?void 0:f.video)===null||m===void 0)&&m.uri&&(!((y=(g=l.source)===null||g===void 0?void 0:g.video)===null||y===void 0)&&y.videoBytes)&&(l.source.video={uri:l.source.video.uri,mimeType:l.source.video.mimeType})),await this.generateVideosInternal(l)}}maybeMoveToResponseJsonSchem(t){t.config&&t.config.responseSchema&&(t.config.responseJsonSchema||Object.keys(t.config.responseSchema).includes("$schema")&&(t.config.responseJsonSchema=t.config.responseSchema,delete t.config.responseSchema))}async processParamsMaybeAddMcpUsage(t){var l,a,r;const f=(l=t.config)===null||l===void 0?void 0:l.tools;if(!f)return t;const m=await Promise.all(f.map(async y=>ji(y)?await y.tool():y)),g={model:t.model,contents:t.contents,config:Object.assign(Object.assign({},t.config),{tools:m})};if(g.config.tools=m,t.config&&t.config.tools&&ag(t.config.tools)){const y=(r=(a=t.config.httpOptions)===null||a===void 0?void 0:a.headers)!==null&&r!==void 0?r:{};let h=Object.assign({},y);Object.keys(h).length===0&&(h=this.apiClient.getDefaultHeaders()),sg(h),g.config.httpOptions=Object.assign(Object.assign({},t.config.httpOptions),{headers:h})}return g}async initAfcToolsMap(t){var l,a,r;const f=new Map;for(const m of(a=(l=t.config)===null||l===void 0?void 0:l.tools)!==null&&a!==void 0?a:[])if(ji(m)){const g=m,y=await g.tool();for(const h of(r=y.functionDeclarations)!==null&&r!==void 0?r:[]){if(!h.name)throw new Error("Function declaration name is required.");if(f.has(h.name))throw new Error(`Duplicate tool declaration name: ${h.name}`);f.set(h.name,g)}}return f}async processAfcStream(t){var l,a,r;const f=(r=(a=(l=t.config)===null||l===void 0?void 0:l.automaticFunctionCalling)===null||a===void 0?void 0:a.maximumRemoteCalls)!==null&&r!==void 0?r:Eh;let m=!1,g=0;const y=await this.initAfcToolsMap(t);return(function(h,v,S){return Pt(this,arguments,function*(){for(var E,C,U,H,b,P;g0){m=!0;const W=new jo;W.candidates=[{content:{role:"user",parts:F}}],yield yield oe(W);const de=[];de.push(...he),de.push({role:"user",parts:F});const Ce=Ht(S.contents).concat(de);S.contents=Ce}else break}})})(this,y,t)}async generateContentInternal(t){var l,a,r,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=yh(this.apiClient,t);return g=Y("{model}:generateContent",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json().then(S=>{const E=S;return E.sdkHttpResponse={headers:v.headers},E})),m.then(v=>{const S=Th(v),E=new jo;return Object.assign(E,S),E})}else{const h=gh(this.apiClient,t);return g=Y("{model}:generateContent",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json().then(S=>{const E=S;return E.sdkHttpResponse={headers:v.headers},E})),m.then(v=>{const S=vh(v),E=new jo;return Object.assign(E,S),E})}}async generateContentStreamInternal(t){var l,a,r,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=yh(this.apiClient,t);return g=Y("{model}:streamGenerateContent?alt=sse",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.requestStream({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}),m.then(function(S){return Pt(this,arguments,function*(){var E,C,U,H;try{for(var b=!0,P=kt(S),X;X=yield oe(P.next()),E=X.done,!E;b=!0){H=X.value,b=!1;const k=H,K=Th(yield oe(k.json()));K.sdkHttpResponse={headers:k.headers};const ee=new jo;Object.assign(ee,K),yield yield oe(ee)}}catch(k){C={error:k}}finally{try{!b&&!E&&(U=P.return)&&(yield oe(U.call(P)))}finally{if(C)throw C.error}}})})}else{const h=gh(this.apiClient,t);return g=Y("{model}:streamGenerateContent?alt=sse",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.requestStream({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}),m.then(function(S){return Pt(this,arguments,function*(){var E,C,U,H;try{for(var b=!0,P=kt(S),X;X=yield oe(P.next()),E=X.done,!E;b=!0){H=X.value,b=!1;const k=H,K=vh(yield oe(k.json()));K.sdkHttpResponse={headers:k.headers};const ee=new jo;Object.assign(ee,K),yield yield oe(ee)}}catch(k){C={error:k}}finally{try{!b&&!E&&(U=P.return)&&(yield oe(U.call(P)))}finally{if(C)throw C.error}}})})}}async embedContent(t){var l,a,r,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=jE(this.apiClient,t);return g=Y("{model}:predict",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json().then(S=>{const E=S;return E.sdkHttpResponse={headers:v.headers},E})),m.then(v=>{const S=t_(v),E=new jm;return Object.assign(E,S),E})}else{const h=WE(this.apiClient,t);return g=Y("{model}:batchEmbedContents",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json().then(S=>{const E=S;return E.sdkHttpResponse={headers:v.headers},E})),m.then(v=>{const S=e_(v),E=new jm;return Object.assign(E,S),E})}}async generateImagesInternal(t){var l,a,r,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=d_(this.apiClient,t);return g=Y("{model}:predict",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json().then(S=>{const E=S;return E.sdkHttpResponse={headers:v.headers},E})),m.then(v=>{const S=m_(v),E=new eh;return Object.assign(E,S),E})}else{const h=f_(this.apiClient,t);return g=Y("{model}:predict",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json().then(S=>{const E=S;return E.sdkHttpResponse={headers:v.headers},E})),m.then(v=>{const S=p_(v),E=new eh;return Object.assign(E,S),E})}}async editImageInternal(t){var l,a;let r,f="",m={};if(this.apiClient.isVertexAI()){const g=KE(this.apiClient,t);return f=Y("{model}:predict",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json().then(h=>{const v=h;return v.sdkHttpResponse={headers:y.headers},v})),r.then(y=>{const h=QE(y),v=new iT;return Object.assign(v,h),v})}else throw new Error("This method is only supported by the Vertex AI.")}async upscaleImageInternal(t){var l,a;let r,f="",m={};if(this.apiClient.isVertexAI()){const g=dC(this.apiClient,t);return f=Y("{model}:predict",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json().then(h=>{const v=h;return v.sdkHttpResponse={headers:y.headers},v})),r.then(y=>{const h=pC(y),v=new oT;return Object.assign(v,h),v})}else throw new Error("This method is only supported by the Vertex AI.")}async recontextImage(t){var l,a;let r,f="",m={};if(this.apiClient.isVertexAI()){const g=X_(this.apiClient,t);return f=Y("{model}:predict",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json()),r.then(y=>{const h=K_(y),v=new lT;return Object.assign(v,h),v})}else throw new Error("This method is only supported by the Vertex AI.")}async segmentImage(t){var l,a;let r,f="",m={};if(this.apiClient.isVertexAI()){const g=eC(this.apiClient,t);return f=Y("{model}:predict",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json()),r.then(y=>{const h=tC(y),v=new aT;return Object.assign(v,h),v})}else throw new Error("This method is only supported by the Vertex AI.")}async get(t){var l,a,r,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=U_(this.apiClient,t);return g=Y("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json()),m.then(v=>_u(v))}else{const h=D_(this.apiClient,t);return g=Y("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json()),m.then(v=>Eu(v))}}async listInternal(t){var l,a,r,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=B_(this.apiClient,t);return g=Y("{models_url}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json().then(S=>{const E=S;return E.sdkHttpResponse={headers:v.headers},E})),m.then(v=>{const S=k_(v),E=new th;return Object.assign(E,S),E})}else{const h=z_(this.apiClient,t);return g=Y("{models_url}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json().then(S=>{const E=S;return E.sdkHttpResponse={headers:v.headers},E})),m.then(v=>{const S=P_(v),E=new th;return Object.assign(E,S),E})}}async update(t){var l,a,r,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=cC(this.apiClient,t);return g=Y("{model}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"PATCH",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json()),m.then(v=>_u(v))}else{const h=uC(this.apiClient,t);return g=Y("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"PATCH",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json()),m.then(v=>Eu(v))}}async delete(t){var l,a,r,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=FE(this.apiClient,t);return g=Y("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"DELETE",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json().then(S=>{const E=S;return E.sdkHttpResponse={headers:v.headers},E})),m.then(v=>{const S=YE(v),E=new nh;return Object.assign(E,S),E})}else{const h=OE(this.apiClient,t);return g=Y("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"DELETE",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json().then(S=>{const E=S;return E.sdkHttpResponse={headers:v.headers},E})),m.then(v=>{const S=JE(v),E=new nh;return Object.assign(E,S),E})}}async countTokens(t){var l,a,r,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=BE(this.apiClient,t);return g=Y("{model}:countTokens",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json().then(S=>{const E=S;return E.sdkHttpResponse={headers:v.headers},E})),m.then(v=>{const S=kE(v),E=new ih;return Object.assign(E,S),E})}else{const h=zE(this.apiClient,t);return g=Y("{model}:countTokens",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json().then(S=>{const E=S;return E.sdkHttpResponse={headers:v.headers},E})),m.then(v=>{const S=PE(v),E=new ih;return Object.assign(E,S),E})}}async computeTokens(t){var l,a;let r,f="",m={};if(this.apiClient.isVertexAI()){const g=wE(this.apiClient,t);return f=Y("{model}:computeTokens",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json().then(h=>{const v=h;return v.sdkHttpResponse={headers:y.headers},v})),r.then(y=>{const h=bE(y),v=new sT;return Object.assign(v,h),v})}else throw new Error("This method is only supported by the Vertex AI.")}async generateVideosInternal(t){var l,a,r,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=S_(this.apiClient,t);return g=Y("{model}:predictLongRunning",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json()),m.then(v=>{const S=v_(v),E=new xa;return Object.assign(E,S),E})}else{const h=T_(this.apiClient,t);return g=Y("{model}:predictLongRunning",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json()),m.then(v=>{const S=y_(v),E=new xa;return Object.assign(E,S),E})}}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class aA extends hn{constructor(t){super(),this.apiClient=t}async getVideosOperation(t){const l=t.operation,a=t.config;if(l.name===void 0||l.name==="")throw new Error("Operation name is required.");if(this.apiClient.isVertexAI()){const r=l.name.split("/operations/")[0];let f;a&&"httpOptions"in a&&(f=a.httpOptions);const m=await this.fetchPredictVideosOperationInternal({operationName:l.name,resourceName:r,config:{httpOptions:f}});return l._fromAPIResponse({apiResponse:m,_isVertexAI:!0})}else{const r=await this.getVideosOperationInternal({operationName:l.name,config:a});return l._fromAPIResponse({apiResponse:r,_isVertexAI:!1})}}async get(t){const l=t.operation,a=t.config;if(l.name===void 0||l.name==="")throw new Error("Operation name is required.");if(this.apiClient.isVertexAI()){const r=l.name.split("/operations/")[0];let f;a&&"httpOptions"in a&&(f=a.httpOptions);const m=await this.fetchPredictVideosOperationInternal({operationName:l.name,resourceName:r,config:{httpOptions:f}});return l._fromAPIResponse({apiResponse:m,_isVertexAI:!0})}else{const r=await this.getVideosOperationInternal({operationName:l.name,config:a});return l._fromAPIResponse({apiResponse:r,_isVertexAI:!1})}}async getVideosOperationInternal(t){var l,a,r,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=$0(t);return g=Y("{operationName}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json()),m}else{const h=Z0(t);return g=Y("{operationName}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json()),m}}async fetchPredictVideosOperationInternal(t){var l,a;let r,f="",m={};if(this.apiClient.isVertexAI()){const g=O0(t);return f=Y("{resourceName}:fetchPredictOperation",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json()),r}else throw new Error("This method is only supported by the Vertex AI.")}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function sA(i){const t={},l=u(i,["data"]);if(l!=null&&c(t,["data"],l),u(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const a=u(i,["mimeType"]);return a!=null&&c(t,["mimeType"],a),t}function rA(i){const t={},l=u(i,["parts"]);if(l!=null){let r=l;Array.isArray(r)&&(r=r.map(f=>yA(f))),c(t,["parts"],r)}const a=u(i,["role"]);return a!=null&&c(t,["role"],a),t}function uA(i,t,l){const a={},r=u(t,["expireTime"]);l!==void 0&&r!=null&&c(l,["expireTime"],r);const f=u(t,["newSessionExpireTime"]);l!==void 0&&f!=null&&c(l,["newSessionExpireTime"],f);const m=u(t,["uses"]);l!==void 0&&m!=null&&c(l,["uses"],m);const g=u(t,["liveConnectConstraints"]);l!==void 0&&g!=null&&c(l,["bidiGenerateContentSetup"],gA(i,g));const y=u(t,["lockAdditionalFields"]);return l!==void 0&&y!=null&&c(l,["fieldMask"],y),a}function cA(i,t){const l={},a=u(t,["config"]);return a!=null&&c(l,["config"],uA(i,a,l)),l}function fA(i){const t={};if(u(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const l=u(i,["fileUri"]);l!=null&&c(t,["fileUri"],l);const a=u(i,["mimeType"]);return a!=null&&c(t,["mimeType"],a),t}function dA(i){const t={},l=u(i,["id"]);l!=null&&c(t,["id"],l);const a=u(i,["args"]);a!=null&&c(t,["args"],a);const r=u(i,["name"]);if(r!=null&&c(t,["name"],r),u(i,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(u(i,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return t}function pA(i){const t={};if(u(i,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const l=u(i,["enableWidget"]);return l!=null&&c(t,["enableWidget"],l),t}function mA(i){const t={};if(u(i,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(u(i,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const l=u(i,["timeRangeFilter"]);return l!=null&&c(t,["timeRangeFilter"],l),t}function hA(i,t){const l={},a=u(i,["generationConfig"]);t!==void 0&&a!=null&&c(t,["setup","generationConfig"],a);const r=u(i,["responseModalities"]);t!==void 0&&r!=null&&c(t,["setup","generationConfig","responseModalities"],r);const f=u(i,["temperature"]);t!==void 0&&f!=null&&c(t,["setup","generationConfig","temperature"],f);const m=u(i,["topP"]);t!==void 0&&m!=null&&c(t,["setup","generationConfig","topP"],m);const g=u(i,["topK"]);t!==void 0&&g!=null&&c(t,["setup","generationConfig","topK"],g);const y=u(i,["maxOutputTokens"]);t!==void 0&&y!=null&&c(t,["setup","generationConfig","maxOutputTokens"],y);const h=u(i,["mediaResolution"]);t!==void 0&&h!=null&&c(t,["setup","generationConfig","mediaResolution"],h);const v=u(i,["seed"]);t!==void 0&&v!=null&&c(t,["setup","generationConfig","seed"],v);const S=u(i,["speechConfig"]);t!==void 0&&S!=null&&c(t,["setup","generationConfig","speechConfig"],qu(S));const E=u(i,["thinkingConfig"]);t!==void 0&&E!=null&&c(t,["setup","generationConfig","thinkingConfig"],E);const C=u(i,["enableAffectiveDialog"]);t!==void 0&&C!=null&&c(t,["setup","generationConfig","enableAffectiveDialog"],C);const U=u(i,["systemInstruction"]);t!==void 0&&U!=null&&c(t,["setup","systemInstruction"],rA(it(U)));const H=u(i,["tools"]);if(t!==void 0&&H!=null){let te=to(H);Array.isArray(te)&&(te=te.map(F=>TA(eo(F)))),c(t,["setup","tools"],te)}const b=u(i,["sessionResumption"]);t!==void 0&&b!=null&&c(t,["setup","sessionResumption"],vA(b));const P=u(i,["inputAudioTranscription"]);t!==void 0&&P!=null&&c(t,["setup","inputAudioTranscription"],P);const X=u(i,["outputAudioTranscription"]);t!==void 0&&X!=null&&c(t,["setup","outputAudioTranscription"],X);const k=u(i,["realtimeInputConfig"]);t!==void 0&&k!=null&&c(t,["setup","realtimeInputConfig"],k);const K=u(i,["contextWindowCompression"]);t!==void 0&&K!=null&&c(t,["setup","contextWindowCompression"],K);const ee=u(i,["proactivity"]);if(t!==void 0&&ee!=null&&c(t,["setup","proactivity"],ee),u(i,["explicitVadSignal"])!==void 0)throw new Error("explicitVadSignal parameter is not supported in Gemini API.");return l}function gA(i,t){const l={},a=u(t,["model"]);a!=null&&c(l,["setup","model"],Te(i,a));const r=u(t,["config"]);return r!=null&&c(l,["config"],hA(r,l)),l}function yA(i){const t={},l=u(i,["mediaResolution"]);l!=null&&c(t,["mediaResolution"],l);const a=u(i,["codeExecutionResult"]);a!=null&&c(t,["codeExecutionResult"],a);const r=u(i,["executableCode"]);r!=null&&c(t,["executableCode"],r);const f=u(i,["fileData"]);f!=null&&c(t,["fileData"],fA(f));const m=u(i,["functionCall"]);m!=null&&c(t,["functionCall"],dA(m));const g=u(i,["functionResponse"]);g!=null&&c(t,["functionResponse"],g);const y=u(i,["inlineData"]);y!=null&&c(t,["inlineData"],sA(y));const h=u(i,["text"]);h!=null&&c(t,["text"],h);const v=u(i,["thought"]);v!=null&&c(t,["thought"],v);const S=u(i,["thoughtSignature"]);S!=null&&c(t,["thoughtSignature"],S);const E=u(i,["videoMetadata"]);return E!=null&&c(t,["videoMetadata"],E),t}function vA(i){const t={},l=u(i,["handle"]);if(l!=null&&c(t,["handle"],l),u(i,["transparent"])!==void 0)throw new Error("transparent parameter is not supported in Gemini API.");return t}function TA(i){const t={},l=u(i,["functionDeclarations"]);if(l!=null){let v=l;Array.isArray(v)&&(v=v.map(S=>S)),c(t,["functionDeclarations"],v)}if(u(i,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const a=u(i,["googleSearchRetrieval"]);a!=null&&c(t,["googleSearchRetrieval"],a);const r=u(i,["computerUse"]);r!=null&&c(t,["computerUse"],r);const f=u(i,["fileSearch"]);f!=null&&c(t,["fileSearch"],f);const m=u(i,["codeExecution"]);if(m!=null&&c(t,["codeExecution"],m),u(i,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const g=u(i,["googleMaps"]);g!=null&&c(t,["googleMaps"],pA(g));const y=u(i,["googleSearch"]);y!=null&&c(t,["googleSearch"],mA(y));const h=u(i,["urlContext"]);return h!=null&&c(t,["urlContext"],h),t}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function SA(i){const t=[];for(const l in i)if(Object.prototype.hasOwnProperty.call(i,l)){const a=i[l];if(typeof a=="object"&&a!=null&&Object.keys(a).length>0){const r=Object.keys(a).map(f=>`${l}.${f}`);t.push(...r)}else t.push(l)}return t.join(",")}function EA(i,t){let l=null;const a=i.bidiGenerateContentSetup;if(typeof a=="object"&&a!==null&&"setup"in a){const f=a.setup;typeof f=="object"&&f!==null?(i.bidiGenerateContentSetup=f,l=f):delete i.bidiGenerateContentSetup}else a!==void 0&&delete i.bidiGenerateContentSetup;const r=i.fieldMask;if(l){const f=SA(l);if(Array.isArray(t==null?void 0:t.lockAdditionalFields)&&(t==null?void 0:t.lockAdditionalFields.length)===0)f?i.fieldMask=f:delete i.fieldMask;else if(t!=null&&t.lockAdditionalFields&&t.lockAdditionalFields.length>0&&r!==null&&Array.isArray(r)&&r.length>0){const m=["temperature","topK","topP","maxOutputTokens","responseModalities","seed","speechConfig"];let g=[];r.length>0&&(g=r.map(h=>m.includes(h)?`generationConfig.${h}`:h));const y=[];f&&y.push(f),g.length>0&&y.push(...g),y.length>0?i.fieldMask=y.join(","):delete i.fieldMask}else delete i.fieldMask}else r!==null&&Array.isArray(r)&&r.length>0?i.fieldMask=r.join(","):delete i.fieldMask;return i}class _A extends hn{constructor(t){super(),this.apiClient=t}async create(t){var l,a;let r,f="",m={};if(this.apiClient.isVertexAI())throw new Error("The client.tokens.create method is only supported by the Gemini Developer API.");{const g=cA(this.apiClient,t);f=Y("auth_tokens",g._url),m=g._query,delete g.config,delete g._url,delete g._query;const y=EA(g,t.config);return r=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(y),httpMethod:"POST",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(h=>h.json()),r.then(h=>h)}}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function CA(i,t){const l={},a=u(i,["force"]);return t!==void 0&&a!=null&&c(t,["_query","force"],a),l}function AA(i){const t={},l=u(i,["name"]);l!=null&&c(t,["_url","name"],l);const a=u(i,["config"]);return a!=null&&CA(a,t),t}function RA(i){const t={},l=u(i,["name"]);return l!=null&&c(t,["_url","name"],l),t}function MA(i,t){const l={},a=u(i,["pageSize"]);t!==void 0&&a!=null&&c(t,["_query","pageSize"],a);const r=u(i,["pageToken"]);return t!==void 0&&r!=null&&c(t,["_query","pageToken"],r),l}function NA(i){const t={},l=u(i,["parent"]);l!=null&&c(t,["_url","parent"],l);const a=u(i,["config"]);return a!=null&&MA(a,t),t}function IA(i){const t={},l=u(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=u(i,["nextPageToken"]);a!=null&&c(t,["nextPageToken"],a);const r=u(i,["documents"]);if(r!=null){let f=r;Array.isArray(f)&&(f=f.map(m=>m)),c(t,["documents"],f)}return t}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class xA extends hn{constructor(t){super(),this.apiClient=t,this.list=async l=>new ci(mn.PAGED_ITEM_DOCUMENTS,a=>this.listInternal({parent:l.parent,config:a.config}),await this.listInternal(l),l)}async get(t){var l,a;let r,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=RA(t);return f=Y("{name}",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"GET",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json()),r.then(y=>y)}}async delete(t){var l,a;let r="",f={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const m=AA(t);r=Y("{name}",m._url),f=m._query,delete m._url,delete m._query,await this.apiClient.request({path:r,queryParams:f,body:JSON.stringify(m),httpMethod:"DELETE",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal})}}async listInternal(t){var l,a;let r,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=NA(t);return f=Y("{parent}/documents",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"GET",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json()),r.then(y=>{const h=IA(y),v=new rT;return Object.assign(v,h),v})}}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class DA extends hn{constructor(t,l=new xA(t)){super(),this.apiClient=t,this.documents=l,this.list=async(a={})=>new ci(mn.PAGED_ITEM_FILE_SEARCH_STORES,r=>this.listInternal(r),await this.listInternal(a),a)}async uploadToFileSearchStore(t){if(this.apiClient.isVertexAI())throw new Error("Vertex AI does not support uploading files to a file search store.");return this.apiClient.uploadFileToFileSearchStore(t.fileSearchStoreName,t.file,t.config)}async create(t){var l,a;let r,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=SC(t);return f=Y("fileSearchStores",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json()),r.then(y=>y)}}async get(t){var l,a;let r,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=CC(t);return f=Y("{name}",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"GET",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json()),r.then(y=>y)}}async delete(t){var l,a;let r="",f={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const m=_C(t);r=Y("{name}",m._url),f=m._query,delete m._url,delete m._query,await this.apiClient.request({path:r,queryParams:f,body:JSON.stringify(m),httpMethod:"DELETE",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal})}}async listInternal(t){var l,a;let r,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=xC(t);return f=Y("fileSearchStores",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"GET",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json()),r.then(y=>{const h=DC(y),v=new uT;return Object.assign(v,h),v})}}async uploadToFileSearchStoreInternal(t){var l,a;let r,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=UC(t);return f=Y("upload/v1beta/{file_search_store_name}:uploadToFileSearchStore",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json()),r.then(y=>{const h=wC(y),v=new cT;return Object.assign(v,h),v})}}async importFile(t){var l,a;let r,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=MC(t);return f=Y("{file_search_store_name}:importFile",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json()),r.then(y=>{const h=RC(y),v=new wu;return Object.assign(v,h),v})}}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */let rg=function(){const{crypto:i}=globalThis;if(i!=null&&i.randomUUID)return rg=i.randomUUID.bind(i),i.randomUUID();const t=new Uint8Array(1),l=i?()=>i.getRandomValues(t)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,a=>(+a^l()&15>>+a/4).toString(16))};const UA=()=>rg();/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function Au(i){return typeof i=="object"&&i!==null&&("name"in i&&i.name==="AbortError"||"message"in i&&String(i.message).includes("FetchRequestCanceledException"))}const Ru=i=>{if(i instanceof Error)return i;if(typeof i=="object"&&i!==null){try{if(Object.prototype.toString.call(i)==="[object Error]"){const t=new Error(i.message,i.cause?{cause:i.cause}:{});return i.stack&&(t.stack=i.stack),i.cause&&!t.cause&&(t.cause=i.cause),i.name&&(t.name=i.name),t}}catch{}try{return new Error(JSON.stringify(i))}catch{}}return new Error(i)};/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class qt extends Error{}class st extends qt{constructor(t,l,a,r){super(`${st.makeMessage(t,l,a)}`),this.status=t,this.headers=r,this.error=l}static makeMessage(t,l,a){const r=l!=null&&l.message?typeof l.message=="string"?l.message:JSON.stringify(l.message):l?JSON.stringify(l):a;return t&&r?`${t} ${r}`:t?`${t} status code (no body)`:r||"(no status code or body)"}static generate(t,l,a,r){if(!t||!r)return new Va({message:a,cause:Ru(l)});const f=l;return t===400?new cg(t,f,a,r):t===401?new fg(t,f,a,r):t===403?new dg(t,f,a,r):t===404?new pg(t,f,a,r):t===409?new mg(t,f,a,r):t===422?new hg(t,f,a,r):t===429?new gg(t,f,a,r):t>=500?new yg(t,f,a,r):new st(t,f,a,r)}}class Mu extends st{constructor({message:t}={}){super(void 0,void 0,t||"Request was aborted.",void 0)}}class Va extends st{constructor({message:t,cause:l}){super(void 0,void 0,t||"Connection error.",void 0),l&&(this.cause=l)}}class ug extends Va{constructor({message:t}={}){super({message:t??"Request timed out."})}}class cg extends st{}class fg extends st{}class dg extends st{}class pg extends st{}class mg extends st{}class hg extends st{}class gg extends st{}class yg extends st{}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const wA=/^[a-z][a-z0-9+.-]*:/i,bA=i=>wA.test(i);let Nu=i=>(Nu=Array.isArray,Nu(i));const LA=Nu;let GA=LA;const Rh=GA;function HA(i){if(!i)return!0;for(const t in i)return!1;return!0}function qA(i,t){return Object.prototype.hasOwnProperty.call(i,t)}const VA=(i,t)=>{if(typeof t!="number"||!Number.isInteger(t))throw new qt(`${i} must be an integer`);if(t<0)throw new qt(`${i} must be a positive integer`);return t},zA=i=>{try{return JSON.parse(i)}catch{return}};/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const BA=i=>new Promise(t=>setTimeout(t,i));/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const Qi="0.0.1";/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function PA(){return typeof Deno<"u"&&Deno.build!=null?"deno":typeof EdgeRuntime<"u"?"edge":Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]"?"node":"unknown"}const kA=()=>{var i,t,l,a,r;const f=PA();if(f==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Qi,"X-Stainless-OS":Nh(Deno.build.os),"X-Stainless-Arch":Mh(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version=="string"?Deno.version:(t=(i=Deno.version)===null||i===void 0?void 0:i.deno)!==null&&t!==void 0?t:"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Qi,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(f==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Qi,"X-Stainless-OS":Nh((l=globalThis.process.platform)!==null&&l!==void 0?l:"unknown"),"X-Stainless-Arch":Mh((a=globalThis.process.arch)!==null&&a!==void 0?a:"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":(r=globalThis.process.version)!==null&&r!==void 0?r:"unknown"};const m=OA();return m?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Qi,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${m.browser}`,"X-Stainless-Runtime-Version":m.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Qi,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function OA(){if(typeof navigator>"u"||!navigator)return null;const i=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(const{key:t,pattern:l}of i){const a=l.exec(navigator.userAgent);if(a){const r=a[1]||0,f=a[2]||0,m=a[3]||0;return{browser:t,version:`${r}.${f}.${m}`}}}return null}const Mh=i=>i==="x32"?"x32":i==="x86_64"||i==="x64"?"x64":i==="arm"?"arm":i==="aarch64"||i==="arm64"?"arm64":i?`other:${i}`:"unknown",Nh=i=>(i=i.toLowerCase(),i.includes("ios")?"iOS":i==="android"?"Android":i==="darwin"?"MacOS":i==="win32"?"Windows":i==="freebsd"?"FreeBSD":i==="openbsd"?"OpenBSD":i==="linux"?"Linux":i?`Other:${i}`:"Unknown");let Ea;const FA=()=>Ea??(Ea=kA());/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function JA(){if(typeof fetch<"u")return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new GeminiNextGenAPIClient({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function vg(...i){const t=globalThis.ReadableStream;if(typeof t>"u")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...i)}function YA(i){let t=Symbol.asyncIterator in i?i[Symbol.asyncIterator]():i[Symbol.iterator]();return vg({start(){},async pull(l){const{done:a,value:r}=await t.next();a?l.close():l.enqueue(r)},async cancel(){var l;await((l=t.return)===null||l===void 0?void 0:l.call(t))}})}function Tg(i){if(i[Symbol.asyncIterator])return i;const t=i.getReader();return{async next(){try{const l=await t.read();return l!=null&&l.done&&t.releaseLock(),l}catch(l){throw t.releaseLock(),l}},async return(){const l=t.cancel();return t.releaseLock(),await l,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function XA(i){var t,l;if(i===null||typeof i!="object")return;if(i[Symbol.asyncIterator]){await((l=(t=i[Symbol.asyncIterator]()).return)===null||l===void 0?void 0:l.call(t));return}const a=i.getReader(),r=a.cancel();a.releaseLock(),await r}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const KA=({headers:i,body:t})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(t)});/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const Sg=()=>{var i;if(typeof File>"u"){const{process:t}=globalThis,l=typeof((i=t==null?void 0:t.versions)===null||i===void 0?void 0:i.node)=="string"&&parseInt(t.versions.node.split("."))<20;throw new Error("`File` is not defined as a global, which is required for file uploads."+(l?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function pu(i,t,l){return Sg(),new File(i,t??"unknown_file",l)}function QA(i){return(typeof i=="object"&&i!==null&&("name"in i&&i.name&&String(i.name)||"url"in i&&i.url&&String(i.url)||"filename"in i&&i.filename&&String(i.filename)||"path"in i&&i.path&&String(i.path))||"").split(/[\\/]/).pop()||void 0}const ZA=i=>i!=null&&typeof i=="object"&&typeof i[Symbol.asyncIterator]=="function";/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const Eg=i=>i!=null&&typeof i=="object"&&typeof i.size=="number"&&typeof i.type=="string"&&typeof i.text=="function"&&typeof i.slice=="function"&&typeof i.arrayBuffer=="function",$A=i=>i!=null&&typeof i=="object"&&typeof i.name=="string"&&typeof i.lastModified=="number"&&Eg(i),WA=i=>i!=null&&typeof i=="object"&&typeof i.url=="string"&&typeof i.blob=="function";async function jA(i,t,l){if(Sg(),i=await i,$A(i))return i instanceof File?i:pu([await i.arrayBuffer()],i.name);if(WA(i)){const r=await i.blob();return t||(t=new URL(i.url).pathname.split(/[\\/]/).pop()),pu(await Iu(r),t,l)}const a=await Iu(i);if(t||(t=QA(i)),!(l!=null&&l.type)){const r=a.find(f=>typeof f=="object"&&"type"in f&&f.type);typeof r=="string"&&(l=Object.assign(Object.assign({},l),{type:r}))}return pu(a,t,l)}async function Iu(i){var t,l,a,r,f;let m=[];if(typeof i=="string"||ArrayBuffer.isView(i)||i instanceof ArrayBuffer)m.push(i);else if(Eg(i))m.push(i instanceof Blob?i:await i.arrayBuffer());else if(ZA(i))try{for(var g=!0,y=kt(i),h;h=await y.next(),t=h.done,!t;g=!0){r=h.value,g=!1;const v=r;m.push(...await Iu(v))}}catch(v){l={error:v}}finally{try{!g&&!t&&(a=y.return)&&await a.call(y)}finally{if(l)throw l.error}}else{const v=(f=i==null?void 0:i.constructor)===null||f===void 0?void 0:f.name;throw new Error(`Unexpected data type: ${typeof i}${v?`; constructor: ${v}`:""}${eR(i)}`)}return m}function eR(i){return typeof i!="object"||i===null?"":`; props: [${Object.getOwnPropertyNames(i).map(l=>`"${l}"`).join(", ")}]`}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class _g{constructor(t){this._client=t}}_g._key=[];/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function Cg(i){return i.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}const Ih=Object.freeze(Object.create(null)),tR=(i=Cg)=>(function(l,...a){if(l.length===1)return l[0];let r=!1;const f=[],m=l.reduce((v,S,E)=>{var C,U,H;/[?#]/.test(S)&&(r=!0);const b=a[E];let P=(r?encodeURIComponent:i)(""+b);return E!==a.length&&(b==null||typeof b=="object"&&b.toString===((H=Object.getPrototypeOf((U=Object.getPrototypeOf((C=b.hasOwnProperty)!==null&&C!==void 0?C:Ih))!==null&&U!==void 0?U:Ih))===null||H===void 0?void 0:H.toString))&&(P=b+"",f.push({start:v.length+S.length,length:P.length,error:`Value of type ${Object.prototype.toString.call(b).slice(8,-1)} is not a valid path parameter`})),v+S+(E===a.length?"":P)},""),g=m.split(/[?#]/,1)[0],y=new RegExp("(?<=^|\\/)(?:\\.|%2e){1,2}(?=\\/|$)","gi");let h;for(;(h=y.exec(g))!==null;)f.push({start:h.index,length:h[0].length,error:`Value "${h[0]}" can't be safely passed as a path parameter`});if(f.sort((v,S)=>v.start-S.start),f.length>0){let v=0;const S=f.reduce((E,C)=>{const U=" ".repeat(C.start-v),H="^".repeat(C.length);return v=C.start+C.length,E+U+H},"");throw new qt(`Path parameters result in path with invalid segments: ${f.map(E=>E.error).join(` `)} ${m} ${S}`)}return m}),_a=tR(Cg);/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class Ag extends _g{create(t,l){var a;const{api_version:r=this._client.apiVersion}=t,f=Ua(t,["api_version"]);if("model"in f&&"agent_config"in f)throw new qt("Invalid request: specified `model` and `agent_config`. If specifying `model`, use `generation_config`.");if("agent"in f&&"generation_config"in f)throw new qt("Invalid request: specified `agent` and `generation_config`. If specifying `agent`, use `agent_config`.");return this._client.post(_a`/${r}/interactions`,Object.assign(Object.assign({body:f},l),{stream:(a=t.stream)!==null&&a!==void 0?a:!1}))}delete(t,l={},a){const{api_version:r=this._client.apiVersion}=l??{};return this._client.delete(_a`/${r}/interactions/${t}`,a)}cancel(t,l={},a){const{api_version:r=this._client.apiVersion}=l??{};return this._client.post(_a`/${r}/interactions/${t}/cancel`,a)}get(t,l={},a){var r;const f=l??{},{api_version:m=this._client.apiVersion}=f,g=Ua(f,["api_version"]);return this._client.get(_a`/${m}/interactions/${t}`,Object.assign(Object.assign({query:g},a),{stream:(r=l==null?void 0:l.stream)!==null&&r!==void 0?r:!1}))}}Ag._key=Object.freeze(["interactions"]);class Rg extends Ag{}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function nR(i){let t=0;for(const r of i)t+=r.length;const l=new Uint8Array(t);let a=0;for(const r of i)l.set(r,a),a+=r.length;return l}let Ca;function zu(i){let t;return(Ca??(t=new globalThis.TextEncoder,Ca=t.encode.bind(t)))(i)}let Aa;function xh(i){let t;return(Aa??(t=new globalThis.TextDecoder,Aa=t.decode.bind(t)))(i)}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class za{constructor(){this.buffer=new Uint8Array,this.carriageReturnIndex=null}decode(t){if(t==null)return[];const l=t instanceof ArrayBuffer?new Uint8Array(t):typeof t=="string"?zu(t):t;this.buffer=nR([this.buffer,l]);const a=[];let r;for(;(r=iR(this.buffer,this.carriageReturnIndex))!=null;){if(r.carriage&&this.carriageReturnIndex==null){this.carriageReturnIndex=r.index;continue}if(this.carriageReturnIndex!=null&&(r.index!==this.carriageReturnIndex+1||r.carriage)){a.push(xh(this.buffer.subarray(0,this.carriageReturnIndex-1))),this.buffer=this.buffer.subarray(this.carriageReturnIndex),this.carriageReturnIndex=null;continue}const f=this.carriageReturnIndex!==null?r.preceding-1:r.preceding,m=xh(this.buffer.subarray(0,f));a.push(m),this.buffer=this.buffer.subarray(r.index),this.carriageReturnIndex=null}return a}flush(){return this.buffer.length?this.decode(` `):[]}}za.NEWLINE_CHARS=new Set([` `,"\r"]);za.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function iR(i,t){for(let r=t??0;r{if(i){if(qA(wa,i))return i;at(l).warn(`${t} was set to ${JSON.stringify(i)}, expected one of ${JSON.stringify(Object.keys(wa))}`)}};function tl(){}function Ra(i,t,l){return!t||wa[i]>wa[l]?tl:t[i].bind(t)}const lR={error:tl,warn:tl,info:tl,debug:tl};let Uh=new WeakMap;function at(i){var t;const l=i.logger,a=(t=i.logLevel)!==null&&t!==void 0?t:"off";if(!l)return lR;const r=Uh.get(l);if(r&&r[0]===a)return r[1];const f={error:Ra("error",l,a),warn:Ra("warn",l,a),info:Ra("info",l,a),debug:Ra("debug",l,a)};return Uh.set(l,[a,f]),f}const ui=i=>(i.options&&(i.options=Object.assign({},i.options),delete i.options.headers),i.headers&&(i.headers=Object.fromEntries((i.headers instanceof Headers?[...i.headers]:Object.entries(i.headers)).map(([t,l])=>[t,t.toLowerCase()==="x-goog-api-key"||t.toLowerCase()==="authorization"||t.toLowerCase()==="cookie"||t.toLowerCase()==="set-cookie"?"***":l]))),"retryOfRequestLogID"in i&&(i.retryOfRequestLogID&&(i.retryOf=i.retryOfRequestLogID),delete i.retryOfRequestLogID),i);/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class $i{constructor(t,l,a){this.iterator=t,this.controller=l,this.client=a}static fromSSEResponse(t,l,a){let r=!1;const f=a?at(a):console;function m(){return Pt(this,arguments,function*(){var y,h,v,S;if(r)throw new qt("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");r=!0;let E=!1;try{try{for(var C=!0,U=kt(aR(t,l)),H;H=yield oe(U.next()),y=H.done,!y;C=!0){S=H.value,C=!1;const b=S;if(!E)if(b.data.startsWith("[DONE]")){E=!0;continue}else try{yield yield oe(JSON.parse(b.data))}catch(P){throw f.error("Could not parse message into JSON:",b.data),f.error("From chunk:",b.raw),P}}}catch(b){h={error:b}}finally{try{!C&&!y&&(v=U.return)&&(yield oe(v.call(U)))}finally{if(h)throw h.error}}E=!0}catch(b){if(Au(b))return yield oe(void 0);throw b}finally{E||l.abort()}})}return new $i(m,l,a)}static fromReadableStream(t,l,a){let r=!1;function f(){return Pt(this,arguments,function*(){var y,h,v,S;const E=new za,C=Tg(t);try{for(var U=!0,H=kt(C),b;b=yield oe(H.next()),y=b.done,!y;U=!0){S=b.value,U=!1;const P=S;for(const X of E.decode(P))yield yield oe(X)}}catch(P){h={error:P}}finally{try{!U&&!y&&(v=H.return)&&(yield oe(v.call(H)))}finally{if(h)throw h.error}}for(const P of E.flush())yield yield oe(P)})}function m(){return Pt(this,arguments,function*(){var y,h,v,S;if(r)throw new qt("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");r=!0;let E=!1;try{try{for(var C=!0,U=kt(f()),H;H=yield oe(U.next()),y=H.done,!y;C=!0){S=H.value,C=!1;const b=S;E||b&&(yield yield oe(JSON.parse(b)))}}catch(b){h={error:b}}finally{try{!C&&!y&&(v=U.return)&&(yield oe(v.call(U)))}finally{if(h)throw h.error}}E=!0}catch(b){if(Au(b))return yield oe(void 0);throw b}finally{E||l.abort()}})}return new $i(m,l,a)}[Symbol.asyncIterator](){return this.iterator()}tee(){const t=[],l=[],a=this.iterator(),r=f=>({next:()=>{if(f.length===0){const m=a.next();t.push(m),l.push(m)}return f.shift()}});return[new $i(()=>r(t),this.controller,this.client),new $i(()=>r(l),this.controller,this.client)]}toReadableStream(){const t=this;let l;return vg({async start(){l=t[Symbol.asyncIterator]()},async pull(a){try{const{value:r,done:f}=await l.next();if(f)return a.close();const m=zu(JSON.stringify(r)+` `);a.enqueue(m)}catch(r){a.error(r)}},async cancel(){var a;await((a=l.return)===null||a===void 0?void 0:a.call(l))}})}}function aR(i,t){return Pt(this,arguments,function*(){var a,r,f,m;if(!i.body)throw t.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new qt("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api"):new qt("Attempted to iterate over a response with no body");const g=new rR,y=new za,h=Tg(i.body);try{for(var v=!0,S=kt(sR(h)),E;E=yield oe(S.next()),a=E.done,!a;v=!0){m=E.value,v=!1;const C=m;for(const U of y.decode(C)){const H=g.decode(U);H&&(yield yield oe(H))}}}catch(C){r={error:C}}finally{try{!v&&!a&&(f=S.return)&&(yield oe(f.call(S)))}finally{if(r)throw r.error}}for(const C of y.flush()){const U=g.decode(C);U&&(yield yield oe(U))}})}function sR(i){return Pt(this,arguments,function*(){var l,a,r,f;let m=new Uint8Array;try{for(var g=!0,y=kt(i),h;h=yield oe(y.next()),l=h.done,!l;g=!0){f=h.value,g=!1;const v=f;if(v==null)continue;const S=v instanceof ArrayBuffer?new Uint8Array(v):typeof v=="string"?zu(v):v;let E=new Uint8Array(m.length+S.length);E.set(m),E.set(S,m.length),m=E;let C;for(;(C=oR(m))!==-1;)yield yield oe(m.slice(0,C)),m=m.slice(C)}}catch(v){a={error:v}}finally{try{!g&&!l&&(r=y.return)&&(yield oe(r.call(y)))}finally{if(a)throw a.error}}m.length>0&&(yield yield oe(m))})}class rR{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(t){if(t.endsWith("\r")&&(t=t.substring(0,t.length-1)),!t){if(!this.event&&!this.data.length)return null;const f={event:this.event,data:this.data.join(` `),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],f}if(this.chunks.push(t),t.startsWith(":"))return null;let[l,a,r]=uR(t,":");return r.startsWith(" ")&&(r=r.substring(1)),l==="event"?this.event=r:l==="data"&&this.data.push(r),null}}function uR(i,t){const l=i.indexOf(t);return l!==-1?[i.substring(0,l),t,i.substring(l+t.length)]:[i,"",""]}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */async function cR(i,t){const{response:l,requestLogID:a,retryOfRequestLogID:r,startTime:f}=t,m=await(async()=>{var g;if(t.options.stream)return at(i).debug("response",l.status,l.url,l.headers,l.body),t.options.__streamClass?t.options.__streamClass.fromSSEResponse(l,t.controller,i):$i.fromSSEResponse(l,t.controller,i);if(l.status===204)return null;if(t.options.__binaryResponse)return l;const y=l.headers.get("content-type"),h=(g=y==null?void 0:y.split(";")[0])===null||g===void 0?void 0:g.trim();return(h==null?void 0:h.includes("application/json"))||(h==null?void 0:h.endsWith("+json"))?await l.json():await l.text()})();return at(i).debug(`[${a}] response parsed`,ui({retryOfRequestLogID:r,url:l.url,status:l.status,body:m,durationMs:Date.now()-f})),m}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class Bu extends Promise{constructor(t,l,a=cR){super(r=>{r(null)}),this.responsePromise=l,this.parseResponse=a,this.client=t}_thenUnwrap(t){return new Bu(this.client,this.responsePromise,async(l,a)=>t(await this.parseResponse(l,a),a))}asResponse(){return this.responsePromise.then(t=>t.response)}async withResponse(){const[t,l]=await Promise.all([this.parse(),this.asResponse()]);return{data:t,response:l}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(t=>this.parseResponse(this.client,t))),this.parsedPromise}then(t,l){return this.parse().then(t,l)}catch(t){return this.parse().catch(t)}finally(t){return this.parse().finally(t)}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const Mg=Symbol("brand.privateNullableHeaders");function*fR(i){if(!i)return;if(Mg in i){const{values:a,nulls:r}=i;yield*a.entries();for(const f of r)yield[f,null];return}let t=!1,l;i instanceof Headers?l=i.entries():Rh(i)?l=i:(t=!0,l=Object.entries(i??{}));for(let a of l){const r=a[0];if(typeof r!="string")throw new TypeError("expected header name to be a string");const f=Rh(a[1])?a[1]:[a[1]];let m=!1;for(const g of f)g!==void 0&&(t&&!m&&(m=!0,yield[r,null]),yield[r,g])}}const el=i=>{const t=new Headers,l=new Set;for(const a of i){const r=new Set;for(const[f,m]of fR(a)){const g=f.toLowerCase();r.has(g)||(t.delete(f),r.add(g)),m===null?(t.delete(f),l.add(g)):(t.append(f,m),l.delete(g))}}return{[Mg]:!0,values:t,nulls:l}};/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const mu=i=>{var t,l,a,r,f,m;if(typeof globalThis.process<"u")return(a=(l=(t=q0)===null||t===void 0?void 0:t[i])===null||l===void 0?void 0:l.trim())!==null&&a!==void 0?a:void 0;if(typeof globalThis.Deno<"u")return(m=(f=(r=globalThis.Deno.env)===null||r===void 0?void 0:r.get)===null||f===void 0?void 0:f.call(r,i))===null||m===void 0?void 0:m.trim()};/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */var Ng;class Ba{constructor(t){var l,a,r,f,m,g,y,{baseURL:h=mu("GEMINI_NEXT_GEN_API_BASE_URL"),apiKey:v=(l=mu("GEMINI_API_KEY"))!==null&&l!==void 0?l:null,apiVersion:S="v1beta"}=t,E=Ua(t,["baseURL","apiKey","apiVersion"]);const C=Object.assign(Object.assign({apiKey:v,apiVersion:S},E),{baseURL:h||"https://generativelanguage.googleapis.com"});this.baseURL=C.baseURL,this.timeout=(a=C.timeout)!==null&&a!==void 0?a:Ba.DEFAULT_TIMEOUT,this.logger=(r=C.logger)!==null&&r!==void 0?r:console;const U="warn";this.logLevel=U,this.logLevel=(m=(f=Dh(C.logLevel,"ClientOptions.logLevel",this))!==null&&f!==void 0?f:Dh(mu("GEMINI_NEXT_GEN_API_LOG"),"process.env['GEMINI_NEXT_GEN_API_LOG']",this))!==null&&m!==void 0?m:U,this.fetchOptions=C.fetchOptions,this.maxRetries=(g=C.maxRetries)!==null&&g!==void 0?g:2,this.fetch=(y=C.fetch)!==null&&y!==void 0?y:JA(),this.encoder=KA,this._options=C,this.apiKey=v,this.apiVersion=S,this.clientAdapter=C.clientAdapter}withOptions(t){return new this.constructor(Object.assign(Object.assign(Object.assign({},this._options),{baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,apiVersion:this.apiVersion}),t))}baseURLOverridden(){return this.baseURL!=="https://generativelanguage.googleapis.com"}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:t,nulls:l}){if(!(t.has("authorization")||t.has("x-goog-api-key"))&&!(this.apiKey&&t.get("x-goog-api-key"))&&!l.has("x-goog-api-key"))throw new Error('Could not resolve authentication method. Expected the apiKey to be set. Or for the "x-goog-api-key" headers to be explicitly omitted')}async authHeaders(t){const l=el([t.headers]);if(!(l.values.has("authorization")||l.values.has("x-goog-api-key"))){if(this.apiKey)return el([{"x-goog-api-key":this.apiKey}]);if(this.clientAdapter.isVertexAI())return el([await this.clientAdapter.getAuthHeaders()])}}stringifyQuery(t){return Object.entries(t).filter(([l,a])=>typeof a<"u").map(([l,a])=>{if(typeof a=="string"||typeof a=="number"||typeof a=="boolean")return`${encodeURIComponent(l)}=${encodeURIComponent(a)}`;if(a===null)return`${encodeURIComponent(l)}=`;throw new qt(`Cannot stringify type ${typeof a}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}getUserAgent(){return`${this.constructor.name}/JS ${Qi}`}defaultIdempotencyKey(){return`stainless-node-retry-${UA()}`}makeStatusError(t,l,a,r){return st.generate(t,l,a,r)}buildURL(t,l,a){const r=!this.baseURLOverridden()&&a||this.baseURL,f=bA(t)?new URL(t):new URL(r+(r.endsWith("/")&&t.startsWith("/")?t.slice(1):t)),m=this.defaultQuery();return HA(m)||(l=Object.assign(Object.assign({},m),l)),typeof l=="object"&&l&&!Array.isArray(l)&&(f.search=this.stringifyQuery(l)),f.toString()}async prepareOptions(t){if(this.clientAdapter&&this.clientAdapter.isVertexAI()&&!t.path.startsWith(`/${this.apiVersion}/projects/`)){const l=t.path.slice(this.apiVersion.length+1);t.path=`/${this.apiVersion}/projects/${this.clientAdapter.getProject()}/locations/${this.clientAdapter.getLocation()}${l}`}}async prepareRequest(t,{url:l,options:a}){}get(t,l){return this.methodRequest("get",t,l)}post(t,l){return this.methodRequest("post",t,l)}patch(t,l){return this.methodRequest("patch",t,l)}put(t,l){return this.methodRequest("put",t,l)}delete(t,l){return this.methodRequest("delete",t,l)}methodRequest(t,l,a){return this.request(Promise.resolve(a).then(r=>Object.assign({method:t,path:l},r)))}request(t,l=null){return new Bu(this,this.makeRequest(t,l,void 0))}async makeRequest(t,l,a){var r,f,m;const g=await t,y=(r=g.maxRetries)!==null&&r!==void 0?r:this.maxRetries;l==null&&(l=y),await this.prepareOptions(g);const{req:h,url:v,timeout:S}=await this.buildRequest(g,{retryCount:y-l});await this.prepareRequest(h,{url:v,options:g});const E="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),C=a===void 0?"":`, retryOf: ${a}`,U=Date.now();if(at(this).debug(`[${E}] sending request`,ui({retryOfRequestLogID:a,method:g.method,url:v,options:g,headers:h.headers})),!((f=g.signal)===null||f===void 0)&&f.aborted)throw new Mu;const H=new AbortController,b=await this.fetchWithTimeout(v,h,S,H).catch(Ru),P=Date.now();if(b instanceof globalThis.Error){const k=`retrying, ${l} attempts remaining`;if(!((m=g.signal)===null||m===void 0)&&m.aborted)throw new Mu;const K=Au(b)||/timed? ?out/i.test(String(b)+("cause"in b?String(b.cause):""));if(l)return at(this).info(`[${E}] connection ${K?"timed out":"failed"} - ${k}`),at(this).debug(`[${E}] connection ${K?"timed out":"failed"} (${k})`,ui({retryOfRequestLogID:a,url:v,durationMs:P-U,message:b.message})),this.retryRequest(g,l,a??E);throw at(this).info(`[${E}] connection ${K?"timed out":"failed"} - error; no more retries left`),at(this).debug(`[${E}] connection ${K?"timed out":"failed"} (error; no more retries left)`,ui({retryOfRequestLogID:a,url:v,durationMs:P-U,message:b.message})),K?new ug:new Va({cause:b})}const X=`[${E}${C}] ${h.method} ${v} ${b.ok?"succeeded":"failed"} with status ${b.status} in ${P-U}ms`;if(!b.ok){const k=await this.shouldRetry(b);if(l&&k){const W=`retrying, ${l} attempts remaining`;return await XA(b.body),at(this).info(`${X} - ${W}`),at(this).debug(`[${E}] response error (${W})`,ui({retryOfRequestLogID:a,url:b.url,status:b.status,headers:b.headers,durationMs:P-U})),this.retryRequest(g,l,a??E,b.headers)}const K=k?"error; no more retries left":"error; not retryable";at(this).info(`${X} - ${K}`);const ee=await b.text().catch(W=>Ru(W).message),te=zA(ee),F=te?void 0:ee;throw at(this).debug(`[${E}] response error (${K})`,ui({retryOfRequestLogID:a,url:b.url,status:b.status,headers:b.headers,message:F,durationMs:Date.now()-U})),this.makeStatusError(b.status,te,F,b.headers)}return at(this).info(X),at(this).debug(`[${E}] response start`,ui({retryOfRequestLogID:a,url:b.url,status:b.status,headers:b.headers,durationMs:P-U})),{response:b,options:g,controller:H,requestLogID:E,retryOfRequestLogID:a,startTime:U}}async fetchWithTimeout(t,l,a,r){const f=l||{},{signal:m,method:g}=f,y=Ua(f,["signal","method"]);m&&m.addEventListener("abort",()=>r.abort());const h=setTimeout(()=>r.abort(),a),v=globalThis.ReadableStream&&y.body instanceof globalThis.ReadableStream||typeof y.body=="object"&&y.body!==null&&Symbol.asyncIterator in y.body,S=Object.assign(Object.assign(Object.assign({signal:r.signal},v?{duplex:"half"}:{}),{method:"GET"}),y);g&&(S.method=g.toUpperCase());try{return await this.fetch.call(void 0,t,S)}finally{clearTimeout(h)}}async shouldRetry(t){const l=t.headers.get("x-should-retry");return l==="true"?!0:l==="false"?!1:t.status===408||t.status===409||t.status===429||t.status>=500}async retryRequest(t,l,a,r){var f;let m;const g=r==null?void 0:r.get("retry-after-ms");if(g){const h=parseFloat(g);Number.isNaN(h)||(m=h)}const y=r==null?void 0:r.get("retry-after");if(y&&!m){const h=parseFloat(y);Number.isNaN(h)?m=Date.parse(y)-Date.now():m=h*1e3}if(!(m&&0<=m&&m<60*1e3)){const h=(f=t.maxRetries)!==null&&f!==void 0?f:this.maxRetries;m=this.calculateDefaultRetryTimeoutMillis(l,h)}return await BA(m),this.makeRequest(t,l-1,a)}calculateDefaultRetryTimeoutMillis(t,l){const f=l-t,m=Math.min(.5*Math.pow(2,f),8),g=1-Math.random()*.25;return m*g*1e3}async buildRequest(t,{retryCount:l=0}={}){var a,r,f;const m=Object.assign({},t),{method:g,path:y,query:h,defaultBaseURL:v}=m,S=this.buildURL(y,h,v);"timeout"in m&&VA("timeout",m.timeout),m.timeout=(a=m.timeout)!==null&&a!==void 0?a:this.timeout;const{bodyHeaders:E,body:C}=this.buildBody({options:m}),U=await this.buildHeaders({options:t,method:g,bodyHeaders:E,retryCount:l});return{req:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({method:g,headers:U},m.signal&&{signal:m.signal}),globalThis.ReadableStream&&C instanceof globalThis.ReadableStream&&{duplex:"half"}),C&&{body:C}),(r=this.fetchOptions)!==null&&r!==void 0?r:{}),(f=m.fetchOptions)!==null&&f!==void 0?f:{}),url:S,timeout:m.timeout}}async buildHeaders({options:t,method:l,bodyHeaders:a,retryCount:r}){let f={};this.idempotencyHeader&&l!=="get"&&(t.idempotencyKey||(t.idempotencyKey=this.defaultIdempotencyKey()),f[this.idempotencyHeader]=t.idempotencyKey);const m=await this.authHeaders(t);let g=el([f,Object.assign(Object.assign({Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(r)},t.timeout?{"X-Stainless-Timeout":String(Math.trunc(t.timeout/1e3))}:{}),FA()),this._options.defaultHeaders,a,t.headers,m]);return this.validateHeaders(g),g.values}buildBody({options:{body:t,headers:l}}){if(!t)return{bodyHeaders:void 0,body:void 0};const a=el([l]);return ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof DataView||typeof t=="string"&&a.values.has("content-type")||globalThis.Blob&&t instanceof globalThis.Blob||t instanceof FormData||t instanceof URLSearchParams||globalThis.ReadableStream&&t instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:t}:typeof t=="object"&&(Symbol.asyncIterator in t||Symbol.iterator in t&&"next"in t&&typeof t.next=="function")?{bodyHeaders:void 0,body:YA(t)}:this.encoder({body:t,headers:a})}}Ba.DEFAULT_TIMEOUT=6e4;class Qe extends Ba{constructor(){super(...arguments),this.interactions=new Rg(this)}}Ng=Qe;Qe.GeminiNextGenAPIClient=Ng;Qe.GeminiNextGenAPIClientError=qt;Qe.APIError=st;Qe.APIConnectionError=Va;Qe.APIConnectionTimeoutError=ug;Qe.APIUserAbortError=Mu;Qe.NotFoundError=pg;Qe.ConflictError=mg;Qe.RateLimitError=gg;Qe.BadRequestError=cg;Qe.AuthenticationError=fg;Qe.InternalServerError=yg;Qe.PermissionDeniedError=dg;Qe.UnprocessableEntityError=hg;Qe.toFile=jA;Qe.Interactions=Rg;/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function dR(i,t){const l={},a=u(i,["name"]);return a!=null&&c(l,["_url","name"],a),l}function pR(i,t){const l={},a=u(i,["name"]);return a!=null&&c(l,["_url","name"],a),l}function mR(i,t){const l={},a=u(i,["sdkHttpResponse"]);return a!=null&&c(l,["sdkHttpResponse"],a),l}function hR(i,t){const l={},a=u(i,["sdkHttpResponse"]);return a!=null&&c(l,["sdkHttpResponse"],a),l}function gR(i,t,l){const a={};if(u(i,["validationDataset"])!==void 0)throw new Error("validationDataset parameter is not supported in Gemini API.");const r=u(i,["tunedModelDisplayName"]);if(t!==void 0&&r!=null&&c(t,["displayName"],r),u(i,["description"])!==void 0)throw new Error("description parameter is not supported in Gemini API.");const f=u(i,["epochCount"]);t!==void 0&&f!=null&&c(t,["tuningTask","hyperparameters","epochCount"],f);const m=u(i,["learningRateMultiplier"]);if(m!=null&&c(a,["tuningTask","hyperparameters","learningRateMultiplier"],m),u(i,["exportLastCheckpointOnly"])!==void 0)throw new Error("exportLastCheckpointOnly parameter is not supported in Gemini API.");if(u(i,["preTunedModelCheckpointId"])!==void 0)throw new Error("preTunedModelCheckpointId parameter is not supported in Gemini API.");if(u(i,["adapterSize"])!==void 0)throw new Error("adapterSize parameter is not supported in Gemini API.");const g=u(i,["batchSize"]);t!==void 0&&g!=null&&c(t,["tuningTask","hyperparameters","batchSize"],g);const y=u(i,["learningRate"]);if(t!==void 0&&y!=null&&c(t,["tuningTask","hyperparameters","learningRate"],y),u(i,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");if(u(i,["beta"])!==void 0)throw new Error("beta parameter is not supported in Gemini API.");return a}function yR(i,t,l){const a={};let r=u(l,["config","method"]);if(r===void 0&&(r="SUPERVISED_FINE_TUNING"),r==="SUPERVISED_FINE_TUNING"){const C=u(i,["validationDataset"]);t!==void 0&&C!=null&&c(t,["supervisedTuningSpec"],wh(C))}else if(r==="PREFERENCE_TUNING"){const C=u(i,["validationDataset"]);t!==void 0&&C!=null&&c(t,["preferenceOptimizationSpec"],wh(C))}const f=u(i,["tunedModelDisplayName"]);t!==void 0&&f!=null&&c(t,["tunedModelDisplayName"],f);const m=u(i,["description"]);t!==void 0&&m!=null&&c(t,["description"],m);let g=u(l,["config","method"]);if(g===void 0&&(g="SUPERVISED_FINE_TUNING"),g==="SUPERVISED_FINE_TUNING"){const C=u(i,["epochCount"]);t!==void 0&&C!=null&&c(t,["supervisedTuningSpec","hyperParameters","epochCount"],C)}else if(g==="PREFERENCE_TUNING"){const C=u(i,["epochCount"]);t!==void 0&&C!=null&&c(t,["preferenceOptimizationSpec","hyperParameters","epochCount"],C)}let y=u(l,["config","method"]);if(y===void 0&&(y="SUPERVISED_FINE_TUNING"),y==="SUPERVISED_FINE_TUNING"){const C=u(i,["learningRateMultiplier"]);t!==void 0&&C!=null&&c(t,["supervisedTuningSpec","hyperParameters","learningRateMultiplier"],C)}else if(y==="PREFERENCE_TUNING"){const C=u(i,["learningRateMultiplier"]);t!==void 0&&C!=null&&c(t,["preferenceOptimizationSpec","hyperParameters","learningRateMultiplier"],C)}let h=u(l,["config","method"]);if(h===void 0&&(h="SUPERVISED_FINE_TUNING"),h==="SUPERVISED_FINE_TUNING"){const C=u(i,["exportLastCheckpointOnly"]);t!==void 0&&C!=null&&c(t,["supervisedTuningSpec","exportLastCheckpointOnly"],C)}else if(h==="PREFERENCE_TUNING"){const C=u(i,["exportLastCheckpointOnly"]);t!==void 0&&C!=null&&c(t,["preferenceOptimizationSpec","exportLastCheckpointOnly"],C)}let v=u(l,["config","method"]);if(v===void 0&&(v="SUPERVISED_FINE_TUNING"),v==="SUPERVISED_FINE_TUNING"){const C=u(i,["adapterSize"]);t!==void 0&&C!=null&&c(t,["supervisedTuningSpec","hyperParameters","adapterSize"],C)}else if(v==="PREFERENCE_TUNING"){const C=u(i,["adapterSize"]);t!==void 0&&C!=null&&c(t,["preferenceOptimizationSpec","hyperParameters","adapterSize"],C)}if(u(i,["batchSize"])!==void 0)throw new Error("batchSize parameter is not supported in Vertex AI.");if(u(i,["learningRate"])!==void 0)throw new Error("learningRate parameter is not supported in Vertex AI.");const S=u(i,["labels"]);t!==void 0&&S!=null&&c(t,["labels"],S);const E=u(i,["beta"]);return t!==void 0&&E!=null&&c(t,["preferenceOptimizationSpec","hyperParameters","beta"],E),a}function vR(i,t){const l={},a=u(i,["baseModel"]);a!=null&&c(l,["baseModel"],a);const r=u(i,["preTunedModel"]);r!=null&&c(l,["preTunedModel"],r);const f=u(i,["trainingDataset"]);f!=null&&xR(f);const m=u(i,["config"]);return m!=null&&gR(m,l),l}function TR(i,t){const l={},a=u(i,["baseModel"]);a!=null&&c(l,["baseModel"],a);const r=u(i,["preTunedModel"]);r!=null&&c(l,["preTunedModel"],r);const f=u(i,["trainingDataset"]);f!=null&&DR(f,l,t);const m=u(i,["config"]);return m!=null&&yR(m,l,t),l}function SR(i,t){const l={},a=u(i,["name"]);return a!=null&&c(l,["_url","name"],a),l}function ER(i,t){const l={},a=u(i,["name"]);return a!=null&&c(l,["_url","name"],a),l}function _R(i,t,l){const a={},r=u(i,["pageSize"]);t!==void 0&&r!=null&&c(t,["_query","pageSize"],r);const f=u(i,["pageToken"]);t!==void 0&&f!=null&&c(t,["_query","pageToken"],f);const m=u(i,["filter"]);return t!==void 0&&m!=null&&c(t,["_query","filter"],m),a}function CR(i,t,l){const a={},r=u(i,["pageSize"]);t!==void 0&&r!=null&&c(t,["_query","pageSize"],r);const f=u(i,["pageToken"]);t!==void 0&&f!=null&&c(t,["_query","pageToken"],f);const m=u(i,["filter"]);return t!==void 0&&m!=null&&c(t,["_query","filter"],m),a}function AR(i,t){const l={},a=u(i,["config"]);return a!=null&&_R(a,l),l}function RR(i,t){const l={},a=u(i,["config"]);return a!=null&&CR(a,l),l}function MR(i,t){const l={},a=u(i,["sdkHttpResponse"]);a!=null&&c(l,["sdkHttpResponse"],a);const r=u(i,["nextPageToken"]);r!=null&&c(l,["nextPageToken"],r);const f=u(i,["tunedModels"]);if(f!=null){let m=f;Array.isArray(m)&&(m=m.map(g=>Ig(g))),c(l,["tuningJobs"],m)}return l}function NR(i,t){const l={},a=u(i,["sdkHttpResponse"]);a!=null&&c(l,["sdkHttpResponse"],a);const r=u(i,["nextPageToken"]);r!=null&&c(l,["nextPageToken"],r);const f=u(i,["tuningJobs"]);if(f!=null){let m=f;Array.isArray(m)&&(m=m.map(g=>xu(g))),c(l,["tuningJobs"],m)}return l}function IR(i,t){const l={},a=u(i,["name"]);a!=null&&c(l,["model"],a);const r=u(i,["name"]);return r!=null&&c(l,["endpoint"],r),l}function xR(i,t){const l={};if(u(i,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");if(u(i,["vertexDatasetResource"])!==void 0)throw new Error("vertexDatasetResource parameter is not supported in Gemini API.");const a=u(i,["examples"]);if(a!=null){let r=a;Array.isArray(r)&&(r=r.map(f=>f)),c(l,["examples","examples"],r)}return l}function DR(i,t,l){const a={};let r=u(l,["config","method"]);if(r===void 0&&(r="SUPERVISED_FINE_TUNING"),r==="SUPERVISED_FINE_TUNING"){const m=u(i,["gcsUri"]);t!==void 0&&m!=null&&c(t,["supervisedTuningSpec","trainingDatasetUri"],m)}else if(r==="PREFERENCE_TUNING"){const m=u(i,["gcsUri"]);t!==void 0&&m!=null&&c(t,["preferenceOptimizationSpec","trainingDatasetUri"],m)}let f=u(l,["config","method"]);if(f===void 0&&(f="SUPERVISED_FINE_TUNING"),f==="SUPERVISED_FINE_TUNING"){const m=u(i,["vertexDatasetResource"]);t!==void 0&&m!=null&&c(t,["supervisedTuningSpec","trainingDatasetUri"],m)}else if(f==="PREFERENCE_TUNING"){const m=u(i,["vertexDatasetResource"]);t!==void 0&&m!=null&&c(t,["preferenceOptimizationSpec","trainingDatasetUri"],m)}if(u(i,["examples"])!==void 0)throw new Error("examples parameter is not supported in Vertex AI.");return a}function Ig(i,t){const l={},a=u(i,["sdkHttpResponse"]);a!=null&&c(l,["sdkHttpResponse"],a);const r=u(i,["name"]);r!=null&&c(l,["name"],r);const f=u(i,["state"]);f!=null&&c(l,["state"],Fh(f));const m=u(i,["createTime"]);m!=null&&c(l,["createTime"],m);const g=u(i,["tuningTask","startTime"]);g!=null&&c(l,["startTime"],g);const y=u(i,["tuningTask","completeTime"]);y!=null&&c(l,["endTime"],y);const h=u(i,["updateTime"]);h!=null&&c(l,["updateTime"],h);const v=u(i,["description"]);v!=null&&c(l,["description"],v);const S=u(i,["baseModel"]);S!=null&&c(l,["baseModel"],S);const E=u(i,["_self"]);return E!=null&&c(l,["tunedModel"],IR(E)),l}function xu(i,t){const l={},a=u(i,["sdkHttpResponse"]);a!=null&&c(l,["sdkHttpResponse"],a);const r=u(i,["name"]);r!=null&&c(l,["name"],r);const f=u(i,["state"]);f!=null&&c(l,["state"],Fh(f));const m=u(i,["createTime"]);m!=null&&c(l,["createTime"],m);const g=u(i,["startTime"]);g!=null&&c(l,["startTime"],g);const y=u(i,["endTime"]);y!=null&&c(l,["endTime"],y);const h=u(i,["updateTime"]);h!=null&&c(l,["updateTime"],h);const v=u(i,["error"]);v!=null&&c(l,["error"],v);const S=u(i,["description"]);S!=null&&c(l,["description"],S);const E=u(i,["baseModel"]);E!=null&&c(l,["baseModel"],E);const C=u(i,["tunedModel"]);C!=null&&c(l,["tunedModel"],C);const U=u(i,["preTunedModel"]);U!=null&&c(l,["preTunedModel"],U);const H=u(i,["supervisedTuningSpec"]);H!=null&&c(l,["supervisedTuningSpec"],H);const b=u(i,["preferenceOptimizationSpec"]);b!=null&&c(l,["preferenceOptimizationSpec"],b);const P=u(i,["tuningDataStats"]);P!=null&&c(l,["tuningDataStats"],P);const X=u(i,["encryptionSpec"]);X!=null&&c(l,["encryptionSpec"],X);const k=u(i,["partnerModelTuningSpec"]);k!=null&&c(l,["partnerModelTuningSpec"],k);const K=u(i,["customBaseModel"]);K!=null&&c(l,["customBaseModel"],K);const ee=u(i,["experiment"]);ee!=null&&c(l,["experiment"],ee);const te=u(i,["labels"]);te!=null&&c(l,["labels"],te);const F=u(i,["outputUri"]);F!=null&&c(l,["outputUri"],F);const he=u(i,["pipelineJob"]);he!=null&&c(l,["pipelineJob"],he);const W=u(i,["serviceAccount"]);W!=null&&c(l,["serviceAccount"],W);const de=u(i,["tunedModelDisplayName"]);de!=null&&c(l,["tunedModelDisplayName"],de);const Ce=u(i,["veoTuningSpec"]);return Ce!=null&&c(l,["veoTuningSpec"],Ce),l}function UR(i,t){const l={},a=u(i,["sdkHttpResponse"]);a!=null&&c(l,["sdkHttpResponse"],a);const r=u(i,["name"]);r!=null&&c(l,["name"],r);const f=u(i,["metadata"]);f!=null&&c(l,["metadata"],f);const m=u(i,["done"]);m!=null&&c(l,["done"],m);const g=u(i,["error"]);return g!=null&&c(l,["error"],g),l}function wh(i,t){const l={},a=u(i,["gcsUri"]);a!=null&&c(l,["validationDatasetUri"],a);const r=u(i,["vertexDatasetResource"]);return r!=null&&c(l,["validationDatasetUri"],r),l}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class wR extends hn{constructor(t){super(),this.apiClient=t,this.list=async(l={})=>new ci(mn.PAGED_ITEM_TUNING_JOBS,a=>this.listInternal(a),await this.listInternal(l),l),this.get=async l=>await this.getInternal(l),this.tune=async l=>{var a;if(this.apiClient.isVertexAI())if(l.baseModel.startsWith("projects/")){const r={tunedModelName:l.baseModel};!((a=l.config)===null||a===void 0)&&a.preTunedModelCheckpointId&&(r.checkpointId=l.config.preTunedModelCheckpointId);const f=Object.assign(Object.assign({},l),{preTunedModel:r});return f.baseModel=void 0,await this.tuneInternal(f)}else{const r=Object.assign({},l);return await this.tuneInternal(r)}else{const r=Object.assign({},l),f=await this.tuneMldevInternal(r);let m="";return f.metadata!==void 0&&f.metadata.tunedModel!==void 0?m=f.metadata.tunedModel:f.name!==void 0&&f.name.includes("/operations/")&&(m=f.name.split("/operations/")[0]),{name:m,state:yu.JOB_STATE_QUEUED}}}}async getInternal(t){var l,a,r,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=ER(t);return g=Y("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json().then(S=>{const E=S;return E.sdkHttpResponse={headers:v.headers},E})),m.then(v=>xu(v))}else{const h=SR(t);return g=Y("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json().then(S=>{const E=S;return E.sdkHttpResponse={headers:v.headers},E})),m.then(v=>Ig(v))}}async listInternal(t){var l,a,r,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=RR(t);return g=Y("tuningJobs",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json().then(S=>{const E=S;return E.sdkHttpResponse={headers:v.headers},E})),m.then(v=>{const S=NR(v),E=new oh;return Object.assign(E,S),E})}else{const h=AR(t);return g=Y("tunedModels",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json().then(S=>{const E=S;return E.sdkHttpResponse={headers:v.headers},E})),m.then(v=>{const S=MR(v),E=new oh;return Object.assign(E,S),E})}}async cancel(t){var l,a,r,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=pR(t);return g=Y("{name}:cancel",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json().then(S=>{const E=S;return E.sdkHttpResponse={headers:v.headers},E})),m.then(v=>{const S=hR(v),E=new lh;return Object.assign(E,S),E})}else{const h=dR(t);return g=Y("{name}:cancel",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(r=t.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json().then(S=>{const E=S;return E.sdkHttpResponse={headers:v.headers},E})),m.then(v=>{const S=mR(v),E=new lh;return Object.assign(E,S),E})}}async tuneInternal(t){var l,a;let r,f="",m={};if(this.apiClient.isVertexAI()){const g=TR(t,t);return f=Y("tuningJobs",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json().then(h=>{const v=h;return v.sdkHttpResponse={headers:y.headers},v})),r.then(y=>xu(y))}else throw new Error("This method is only supported by the Vertex AI.")}async tuneMldevInternal(t){var l,a;let r,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=vR(t);return f=Y("tunedModels",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(l=t.config)===null||l===void 0?void 0:l.httpOptions,abortSignal:(a=t.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json().then(h=>{const v=h;return v.sdkHttpResponse={headers:y.headers},v})),r.then(y=>UR(y))}}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class bR{async download(t,l){throw new Error("Download to file is not supported in the browser, please use a browser compliant download like an tag.")}}const LR=1024*1024*8,GR=3,HR=1e3,qR=2,ba="x-goog-upload-status";async function VR(i,t,l){var a;const r=await xg(i,t,l),f=await(r==null?void 0:r.json());if(((a=r==null?void 0:r.headers)===null||a===void 0?void 0:a[ba])!=="final")throw new Error("Failed to upload file: Upload status is not finalized.");return f.file}async function zR(i,t,l){var a;const r=await xg(i,t,l),f=await(r==null?void 0:r.json());if(((a=r==null?void 0:r.headers)===null||a===void 0?void 0:a[ba])!=="final")throw new Error("Failed to upload file: Upload status is not finalized.");const m=Vh(f),g=new bu;return Object.assign(g,m),g}async function xg(i,t,l){var a,r;let f=0,m=0,g=new vu(new Response),y="upload";for(f=i.size;m=f&&(y+=", finalize");let S=0,E=HR;for(;SsetTimeout(t,i))}class kR{async upload(t,l,a){if(typeof t=="string")throw new Error("File path is not supported in browser uploader.");return await VR(t,l,a)}async uploadToFileSearchStore(t,l,a){if(typeof t=="string")throw new Error("File path is not supported in browser uploader.");return await zR(t,l,a)}async stat(t){if(typeof t=="string")throw new Error("File path is not supported in browser uploader.");return await BR(t)}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class OR{create(t,l,a){return new FR(t,l,a)}}class FR{constructor(t,l,a){this.url=t,this.headers=l,this.callbacks=a}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(t){if(this.ws===void 0)throw new Error("WebSocket is not connected");this.ws.send(t)}close(){if(this.ws===void 0)throw new Error("WebSocket is not connected");this.ws.close()}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const bh="x-goog-api-key";class JR{constructor(t){this.apiKey=t}async addAuthHeaders(t,l){if(t.get(bh)===null){if(this.apiKey.startsWith("auth_tokens/"))throw new Error("Ephemeral tokens are only supported by the live API.");if(!this.apiKey)throw new Error("API key is missing. Please provide a valid API key.");t.append(bh,this.apiKey)}}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const YR="gl-node/";class XR{get interactions(){if(this._interactions!==void 0)return this._interactions;console.warn("GoogleGenAI.interactions: Interactions usage is experimental and may change in future versions.");const t=this.httpOptions;t!=null&&t.extraBody&&console.warn("GoogleGenAI.interactions: Client level httpOptions.extraBody is not supported by the interactions client and will be ignored.");const l=new Qe({baseURL:this.apiClient.getBaseUrl(),apiKey:this.apiKey,apiVersion:this.apiClient.getApiVersion(),clientAdapter:this.apiClient,defaultHeaders:this.apiClient.getDefaultHeaders(),timeout:t==null?void 0:t.timeout});return this._interactions=l.interactions,this._interactions}constructor(t){var l;if(t.apiKey==null)throw new Error("An API Key must be set when running in a browser");if(t.project||t.location)throw new Error("Vertex AI project based authentication is not supported on browser runtimes. Please do not provide a project or location.");this.vertexai=(l=t.vertexai)!==null&&l!==void 0?l:!1,this.apiKey=t.apiKey;const a=P0(t.httpOptions,t.vertexai,void 0,void 0);a&&(t.httpOptions?t.httpOptions.baseUrl=a:t.httpOptions={baseUrl:a}),this.apiVersion=t.apiVersion,this.httpOptions=t.httpOptions;const r=new JR(this.apiKey);this.apiClient=new BC({auth:r,apiVersion:this.apiVersion,apiKey:this.apiKey,vertexai:this.vertexai,httpOptions:this.httpOptions,userAgentExtra:YR+"web",uploader:new kR,downloader:new bR}),this.models=new lA(this.apiClient),this.live=new jC(this.apiClient,r,new OR),this.batches=new gS(this.apiClient),this.chats=new $S(this.models,this.apiClient),this.caches=new KS(this.apiClient),this.files=new sE(this.apiClient),this.operations=new aA(this.apiClient),this.authTokens=new _A(this.apiClient),this.tunings=new wR(this.apiClient),this.fileSearchStores=new DA(this.apiClient)}}const KR=()=>{const i="PLACEHOLDER_API_KEY";return new XR({apiKey:i})},QR=async(i,t)=>{const l=KR();if(!l)return"错误: 未配置 API Key";try{const a=`Act as a creative songwriter assistant. User is submitting lyrics for a song. Song Style: ${t} User Input (Title or Draft Lyrics): ${i} Task: Write or polish short song lyrics (about 4-8 lines) in Chinese based on the input. Make it poetic and fitting for the style. Return ONLY the lyrics text.`;return(await l.models.generateContent({model:"gemini-2.5-flash",contents:a})).text||"暂时无法生成歌词,请稍后重试。"}catch(a){return console.error("Gemini API Error:",a),"抱歉,AI 灵感枯竭了,请重试。"}},ZR=({onSubmit:i,initialValues:t})=>{const[l,a]=nt.useState({title:(t==null?void 0:t.title)||"",lyrics:(t==null?void 0:t.lyrics)||"",style:(t==null?void 0:t.style)||"",nickname:(t==null?void 0:t.nickname)||""}),[r,f]=nt.useState(!1),[m,g]=nt.useState(!1),y=async()=>{if(!l.title&&!l.lyrics){alert("请至少输入歌名或一点歌词内容!");return}f(!0);const v=await QR(l.title+(l.lyrics?` Content: ${l.lyrics}`:""),l.style||"流行");a(S=>({...S,lyrics:v})),f(!1)},h=v=>{v.preventDefault(),g(!0);const S={...l,nickname:l.nickname.trim()===""?"音乐共创人":l.nickname};i(S)};return B.jsxs("div",{className:"space-y-6",children:[B.jsxs("div",{className:"text-center mb-4",children:[B.jsx("h2",{className:"text-xl font-black text-brand-dark flex items-center justify-center gap-2",children:"填写创作信息"}),B.jsx("p",{className:"text-gray-500 text-xs mt-1",children:"创作一首属于你自已的歌"})]}),B.jsxs("form",{onSubmit:h,className:"space-y-5",children:[B.jsxs("div",{children:[B.jsxs("label",{className:"block text-xs font-bold text-gray-500 mb-1 ml-1",children:["你的昵称 ",B.jsx("span",{className:"text-[10px] font-normal text-gray-400 bg-gray-100 px-1.5 py-0.5 rounded ml-1",children:"选填"})]}),B.jsx("input",{type:"text",value:l.nickname,onChange:v=>a({...l,nickname:v.target.value}),className:"w-full bg-gray-50 border border-gray-200 rounded-lg py-3 px-4 text-gray-800 focus:outline-none focus:border-brand-orange focus:bg-white transition-all placeholder-gray-400",placeholder:"例如: 阳光天地的朋友"})]}),B.jsxs("div",{children:[B.jsxs("label",{className:"block text-xs font-bold text-gray-500 mb-1 ml-1",children:["歌曲风格 ",B.jsx("span",{className:"text-brand-red",children:"*"})]}),B.jsx("input",{type:"text",required:!0,value:l.style,onChange:v=>a({...l,style:v.target.value}),className:"w-full bg-gray-50 border border-gray-200 rounded-lg py-3 px-4 text-gray-800 focus:outline-none focus:border-brand-orange focus:bg-white transition-all placeholder-gray-400",placeholder:"例如: 温暖感动、R&B、摇滚..."})]}),B.jsxs("div",{children:[B.jsxs("label",{className:"block text-xs font-bold text-gray-500 mb-1 ml-1",children:["歌曲名称 ",B.jsx("span",{className:"text-brand-red",children:"*"})]}),B.jsx("input",{type:"text",required:!0,value:l.title,onChange:v=>a({...l,title:v.target.value}),className:"w-full bg-gray-50 border border-gray-200 rounded-lg py-3 px-4 text-gray-800 focus:outline-none focus:border-brand-orange focus:bg-white transition-all placeholder-gray-400",placeholder:"为你的歌起个名字吧..."})]}),B.jsxs("div",{className:"relative",children:[B.jsxs("div",{className:"flex justify-between items-center mb-1 ml-1",children:[B.jsx("label",{className:"block text-xs font-bold text-gray-500",children:"歌词内容"}),B.jsxs("button",{type:"button",onClick:y,disabled:r,className:"flex items-center gap-1.5 text-[10px] font-bold text-brand-orange hover:text-brand-red transition-colors disabled:opacity-50",children:[B.jsx(qh,{className:"w-3 h-3"}),r?"AI 生成中...":"AI 帮我写词"]})]}),B.jsx("textarea",{required:!0,rows:5,value:l.lyrics,onChange:v=>a({...l,lyrics:v.target.value}),className:"w-full bg-gray-50 border border-gray-200 rounded-lg py-3 px-4 text-gray-800 focus:outline-none focus:border-brand-orange focus:bg-white transition-all text-sm leading-relaxed placeholder-gray-400 resize-none",placeholder:"写下你想说的话,或者具体的歌词..."})]}),B.jsx("button",{type:"submit",disabled:m||r,className:"w-full mt-6 bg-gradient-to-r from-brand-orange to-brand-red text-white font-bold py-4 rounded-xl shadow-lg shadow-brand-orange/30 flex items-center justify-center gap-2 hover:scale-[1.02] transition-all active:scale-95",children:m?B.jsx(Hh,{className:"animate-spin"}):B.jsxs(B.Fragment,{children:[B.jsx(x0,{className:"w-4 h-4"})," 确认提交创作"]})})]})]})},$R=({song:i})=>B.jsxs("div",{className:"space-y-6",children:[B.jsxs("div",{className:"text-center mb-4",children:[B.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-green-100 border border-green-200 text-green-600 text-xs font-bold mb-4 animate-bounce",children:[B.jsx(S0,{className:"w-4 h-4"})," 提交成功"]}),B.jsx("h2",{className:"text-1xl font-black text-brand-dark",children:"请截图保存下方凭证,等待工作人员联系"}),B.jsx("p",{className:"text-gray-500 text-xs mt-2",children:"您的创作已收录,快来现场一起畅聊吧"})]}),B.jsxs("div",{className:"relative bg-orange-50 rounded-2xl border-2 border-brand-orange/20 overflow-hidden shadow-sm group",children:[B.jsx("div",{className:"absolute top-0 right-0 p-8 opacity-5",children:B.jsx(R0,{className:"w-24 h-24 text-brand-orange"})}),B.jsxs("div",{className:"p-6 relative z-10",children:[B.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[B.jsx("div",{className:"w-10 h-10 rounded-full bg-white border border-brand-orange/20 flex items-center justify-center shadow-sm",children:B.jsx(L0,{className:"w-5 h-5 text-brand-orange"})}),B.jsxs("div",{children:[B.jsx("div",{className:"text-xs text-gray-400",children:"来自共创人"}),B.jsx("div",{className:"font-bold text-gray-800",children:i.nickname})]}),B.jsx("div",{className:"ml-auto bg-brand-orange/10 text-brand-orange px-2 py-1 rounded text-[10px] font-bold",children:i.style})]}),B.jsxs("div",{className:"bg-white rounded-xl p-4 shadow-sm border border-brand-orange/10 mb-4",children:[B.jsxs("h3",{className:"text-sm font-bold text-brand-dark mb-2 flex items-center gap-2 min-w-0",children:[B.jsx(qh,{className:"w-3.5 h-3.5 text-brand-yellow"}),B.jsx("span",{className:"flex-1 truncate",children:i.title})]}),B.jsxs("p",{className:"text-sm text-gray-600 italic leading-relaxed whitespace-pre-wrap",children:['"',i.lyrics,'"']})]}),B.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-400 border-t border-brand-orange/10 pt-4",children:[B.jsxs("div",{className:"flex items-center gap-1",children:[B.jsx("span",{children:"凭证编号:"}),B.jsx("span",{className:"font-mono text-brand-orange",children:i.ticketNumber||"PENDING"})]}),B.jsx("div",{className:"flex items-center gap-1",children:B.jsx(_0,{className:"w-3.5 h-3.5"})})]})]})]}),B.jsxs("button",{onClick:()=>{localStorage.removeItem("ai_song_fest_songs"),window.location.reload()},className:"w-full py-4 text-xs text-gray-400 hover:text-brand-orange transition-colors flex items-center justify-center gap-2 group",children:[B.jsx(N0,{className:"w-3 h-3 group-hover:rotate-180 transition-transform duration-500"}),"提交新的创作"]})]});function WR(){const[i,t]=nt.useState("loading"),[l,a]=nt.useState(null),[r,f]=nt.useState(null);nt.useEffect(()=>{(async()=>{const v=hu.getCurrentUser();if(!v){t("login");return}a(v);const S=await Sa.getSongByPhone(v.phone);S?(f(S),t("result")):t("form")})()},[]);const m=async()=>{const h=hu.getCurrentUser();if(a(h),h){const v=await Sa.getSongByPhone(h.phone);v?(f(v),t("result")):t("form")}},g=async h=>{if(!l)return;const v=await Sa.submitSong(l.phone,h);f(v),t("result")},y=async()=>{if(l){const h=await Sa.getSongByPhone(l.phone);h&&f(h)}};return i==="loading"?B.jsx(jp,{children:B.jsxs("div",{className:"flex flex-col items-center justify-center h-64 text-white",children:[B.jsx("div",{className:"w-10 h-10 border-4 border-white border-t-transparent rounded-full animate-spin"}),B.jsx("p",{className:"mt-6 text-sm font-bold tracking-widest animate-pulse",children:"正在进入..."})]})}):B.jsxs(jp,{children:[i==="login"&&B.jsx(H0,{onLoginSuccess:m}),i==="form"&&B.jsx(ZR,{onSubmit:g}),i==="result"&&r&&B.jsx($R,{song:r,onRefresh:y})]})}const Dg=document.getElementById("root");if(!Dg)throw new Error("Could not find root element to mount to");const jR=f0.createRoot(Dg);jR.render(B.jsx(i0.StrictMode,{children:B.jsx(WR,{})}));