(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const u of document.querySelectorAll('link[rel="modulepreload"]'))a(u);new MutationObserver(u=>{for(const f of u)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(u){const f={};return u.integrity&&(f.integrity=u.integrity),u.referrerPolicy&&(f.referrerPolicy=u.referrerPolicy),u.crossOrigin==="use-credentials"?f.credentials="include":u.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f}function a(u){if(u.ep)return;u.ep=!0;const f=l(u);fetch(u.href,f)}})();function Ih(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var iu={exports:{}},Zo={};/** * @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 zp;function Jv(){if(zp)return Zo;zp=1;var i=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function l(a,u,f){var m=null;if(f!==void 0&&(m=""+f),u.key!==void 0&&(m=""+u.key),"key"in u){f={};for(var g in u)g!=="key"&&(f[g]=u[g])}else f=u;return u=f.ref,{$$typeof:i,type:a,key:m,ref:u!==void 0?u:null,props:f}}return Zo.Fragment=t,Zo.jsx=l,Zo.jsxs=l,Zo}var Bp;function Yv(){return Bp||(Bp=1,iu.exports=Jv()),iu.exports}var qe=Yv(),ou={exports:{}},ae={};/** * @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 Pp;function Xv(){if(Pp)return ae;Pp=1;var i=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),l=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),u=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 w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},G=Object.assign,x={};function B(M,V,k){this.props=M,this.context=V,this.refs=x,this.updater=k||w}B.prototype.isReactComponent={},B.prototype.setState=function(M,V){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,V,"setState")},B.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function Y(){}Y.prototype=B.prototype;function P(M,V,k){this.props=M,this.context=V,this.refs=x,this.updater=k||w}var Q=P.prototype=new Y;Q.constructor=P,G(Q,B.prototype),Q.isPureReactComponent=!0;var j=Array.isArray;function W(){}var F={H:null,A:null,T:null,S:null},ee=Object.prototype.hasOwnProperty;function X(M,V,k){var K=k.ref;return{$$typeof:i,type:M,key:V,ref:K!==void 0?K:null,props:k}}function re(M,V){return X(M.type,V,M.props)}function ye(M){return typeof M=="object"&&M!==null&&M.$$typeof===i}function Ae(M){var V={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(k){return V[k]})}var ue=/\/+/g;function ve(M,V){return typeof M=="object"&&M!==null&&M.key!=null?Ae(""+M.key):V.toString(36)}function be(M){switch(M.status){case"fulfilled":return M.value;case"rejected":throw M.reason;default:switch(typeof M.status=="string"?M.then(W,W):(M.status="pending",M.then(function(V){M.status==="pending"&&(M.status="fulfilled",M.value=V)},function(V){M.status==="pending"&&(M.status="rejected",M.reason=V)})),M.status){case"fulfilled":return M.value;case"rejected":throw M.reason}}throw M}function b(M,V,k,K,oe){var de=typeof M;(de==="undefined"||de==="boolean")&&(M=null);var Me=!1;if(M===null)Me=!0;else switch(de){case"bigint":case"string":case"number":Me=!0;break;case"object":switch(M.$$typeof){case i:case t:Me=!0;break;case v:return Me=M._init,b(Me(M._payload),V,k,K,oe)}}if(Me)return oe=oe(M),Me=K===""?"."+ve(M,0):K,j(oe)?(k="",Me!=null&&(k=Me.replace(ue,"$&/")+"/"),b(oe,V,k,"",function(no){return no})):oe!=null&&(ye(oe)&&(oe=re(oe,k+(oe.key==null||M&&M.key===oe.key?"":(""+oe.key).replace(ue,"$&/")+"/")+Me)),V.push(oe)),1;Me=0;var ot=K===""?".":K+":";if(j(M))for(var Be=0;Be>>1,fe=b[Se];if(0>>1;Seu(k,ne))Ku(oe,k)?(b[Se]=oe,b[K]=ne,Se=K):(b[Se]=k,b[V]=ne,Se=V);else if(Ku(oe,ne))b[Se]=oe,b[K]=ne,Se=K;else break e}}return O}function u(b,O){var ne=b.sortIndex-O.sortIndex;return ne!==0?ne:b.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,w=!1,G=!1,x=!1,B=typeof setTimeout=="function"?setTimeout:null,Y=typeof clearTimeout=="function"?clearTimeout:null,P=typeof setImmediate<"u"?setImmediate:null;function Q(b){for(var O=l(h);O!==null;){if(O.callback===null)a(h);else if(O.startTime<=b)a(h),O.sortIndex=O.expirationTime,t(y,O);else break;O=l(h)}}function j(b){if(G=!1,Q(b),!w)if(l(y)!==null)w=!0,W||(W=!0,Ae());else{var O=l(h);O!==null&&be(j,O.startTime-b)}}var W=!1,F=-1,ee=5,X=-1;function re(){return x?!0:!(i.unstable_now()-Xb&&re());){var Se=S.callback;if(typeof Se=="function"){S.callback=null,E=S.priorityLevel;var fe=Se(S.expirationTime<=b);if(b=i.unstable_now(),typeof fe=="function"){S.callback=fe,Q(b),O=!0;break t}S===l(y)&&a(y),Q(b)}else a(y);S=l(y)}if(S!==null)O=!0;else{var M=l(h);M!==null&&be(j,M.startTime-b),O=!1}}break e}finally{S=null,E=ne,C=!1}O=void 0}}finally{O?Ae():W=!1}}}var Ae;if(typeof P=="function")Ae=function(){P(ye)};else if(typeof MessageChannel<"u"){var ue=new MessageChannel,ve=ue.port2;ue.port1.onmessage=ye,Ae=function(){ve.postMessage(null)}}else Ae=function(){B(ye,0)};function be(b,O){F=B(function(){b(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(b){b.callback=null},i.unstable_forceFrameRate=function(b){0>b||125Se?(b.sortIndex=ne,t(h,b),l(y)===null&&b===l(h)&&(G?(Y(F),F=-1):G=!0,be(j,ne-Se))):(b.sortIndex=fe,t(y,b),w||C||(w=!0,W||(W=!0,Ae()))),b},i.unstable_shouldYield=re,i.unstable_wrapCallback=function(b){var O=E;return function(){var ne=E;E=O;try{return b.apply(this,arguments)}finally{E=ne}}}})(su)),su}var Fp;function Zv(){return Fp||(Fp=1,au.exports=Qv()),au.exports}var ru={exports:{}},nt={};/** * @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 Jp;function $v(){if(Jp)return nt;Jp=1;var i=Mu();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(),ru.exports=$v(),ru.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 Xp;function jv(){if(Xp)return $o;Xp=1;var i=Zv(),t=Mu(),l=Wv();function a(e){var n="https://react.dev/errors/"+e;if(1fe||(e.current=Se[fe],Se[fe]=null,fe--)}function k(e,n){fe++,Se[fe]=e.current,e.current=n}var K=M(null),oe=M(null),de=M(null),Me=M(null);function ot(e,n){switch(k(de,n),k(oe,e),k(K,null),n.nodeType){case 9:case 11:e=(e=n.documentElement)&&(e=e.namespaceURI)?rp(e):0;break;default:if(e=n.tagName,n=n.namespaceURI)n=rp(n),e=up(n,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}V(K),k(K,e)}function Be(){V(K),V(oe),V(de)}function no(e){e.memoizedState!==null&&k(Me,e);var n=K.current,o=up(n,e.type);n!==o&&(k(oe,e),k(K,o))}function nl(e){oe.current===e&&(V(K),V(oe)),Me.current===e&&(V(Me),Yo._currentValue=ne)}var za,qu;function kn(e){if(za===void 0)try{throw Error()}catch(o){var n=o.stack.trim().match(/\n( *(at )?)/);za=n&&n[1]||"",qu=-1)":-1d||A[s]!==D[d]){var H=` `+A[s].replace(" at new "," at ");return e.displayName&&H.includes("")&&(H=H.replace("",e.displayName)),H}while(1<=s&&0<=d);break}}}finally{Ba=!1,Error.prepareStackTrace=o}return(o=e?e.displayName||e.name:"")?kn(o):""}function _g(e,n){switch(e.tag){case 26:case 27:case 5:return kn(e.type);case 16:return kn("Lazy");case 13:return e.child!==n&&n!==null?kn("Suspense Fallback"):kn("Suspense");case 19:return kn("SuspenseList");case 0:case 15:return Pa(e.type,!1);case 11:return Pa(e.type.render,!1);case 1:return Pa(e.type,!0);case 31:return kn("Activity");default:return""}}function Vu(e){try{var n="",o=null;do n+=_g(e,o),o=e,e=e.return;while(e);return n}catch(s){return` Error generating stack: `+s.message+` `+s.stack}}var Oa=Object.prototype.hasOwnProperty,ka=i.unstable_scheduleCallback,Fa=i.unstable_cancelCallback,Cg=i.unstable_shouldYield,Ag=i.unstable_requestPaint,gt=i.unstable_now,Rg=i.unstable_getCurrentPriorityLevel,zu=i.unstable_ImmediatePriority,Bu=i.unstable_UserBlockingPriority,il=i.unstable_NormalPriority,Mg=i.unstable_LowPriority,Pu=i.unstable_IdlePriority,Ng=i.log,Ig=i.unstable_setDisableYieldValue,io=null,yt=null;function gn(e){if(typeof Ng=="function"&&Ig(e),yt&&typeof yt.setStrictMode=="function")try{yt.setStrictMode(io,e)}catch{}}var vt=Math.clz32?Math.clz32:wg,Dg=Math.log,Ug=Math.LN2;function wg(e){return e>>>=0,e===0?32:31-(Dg(e)/Ug|0)|0}var ol=256,ll=262144,al=4194304;function Fn(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=Fn(s):(T&=_,T!==0?d=Fn(T):o||(o=_&~e,o!==0&&(d=Fn(o))))):(_=s&~p,_!==0?d=Fn(_):T!==0?d=Fn(T):o||(o=s&~e,o!==0&&(d=Fn(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 oo(e,n){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&n)===0}function xg(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 Ou(){var e=al;return al<<=1,(al&62914560)===0&&(al=4194304),e}function Ja(e){for(var n=[],o=0;31>o;o++)n.push(e);return n}function lo(e,n){e.pendingLanes|=n,n!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function bg(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,D=e.hiddenUpdates;for(o=T&~o;0"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var zg=/[\n"\\]/g;function Nt(e){return e.replace(zg,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function $a(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?Wa(e,T,Mt(n)):o!=null?Wa(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 tc(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)){Za(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),Za(e)}function Wa(e,n,o){n==="number"&&cl(e.ownerDocument)===e||e.defaultValue===""+o||(e.defaultValue=""+o)}function hi(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"),is=!1;if(Zt)try{var uo={};Object.defineProperty(uo,"passive",{get:function(){is=!0}}),window.addEventListener("test",uo,uo),window.removeEventListener("test",uo,uo)}catch{is=!1}var vn=null,os=null,dl=null;function rc(){if(dl)return dl;var e,n=os,o=n.length,s,d="value"in vn?vn.value:vn.textContent,p=d.length;for(e=0;e=po),mc=" ",hc=!1;function gc(e,n){switch(e){case"keyup":return py.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function yc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Ti=!1;function hy(e,n){switch(e){case"compositionend":return yc(n);case"keypress":return n.which!==32?null:(hc=!0,mc);case"textInput":return e=n.data,e===mc&&hc?null:e;default:return null}}function gy(e,n){if(Ti)return e==="compositionend"||!us&&gc(e,n)?(e=rc(),dl=os=vn=null,Ti=!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=Rc(o)}}function Nc(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Nc(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function Ic(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 ds(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 Ay=Zt&&"documentMode"in document&&11>=document.documentMode,Si=null,ps=null,yo=null,ms=!1;function Dc(e,n,o){var s=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;ms||Si==null||Si!==cl(s)||(s=Si,"selectionStart"in s&&ds(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}),yo&&go(yo,s)||(yo=s,s=la(ps,"onSelect"),0>=T,d-=T,Ft=1<<32-vt(n)+d|o<ce?(ge=$,$=null):ge=$.sibling;var _e=U(N,$,I[ce],q);if(_e===null){$===null&&($=ge);break}e&&$&&_e.alternate===null&&n(N,$),R=p(_e,R,ce),Ee===null?te=_e:Ee.sibling=_e,Ee=_e,$=ge}if(ce===I.length)return o(N,$),Te&&Wt(N,ce),te;if($===null){for(;cece?(ge=$,$=null):ge=$.sibling;var Bn=U(N,$,_e.value,q);if(Bn===null){$===null&&($=ge);break}e&&$&&Bn.alternate===null&&n(N,$),R=p(Bn,R,ce),Ee===null?te=Bn:Ee.sibling=Bn,Ee=Bn,$=ge}if(_e.done)return o(N,$),Te&&Wt(N,ce),te;if($===null){for(;!_e.done;ce++,_e=I.next())_e=z(N,_e.value,q),_e!==null&&(R=p(_e,R,ce),Ee===null?te=_e:Ee.sibling=_e,Ee=_e);return Te&&Wt(N,ce),te}for($=s($);!_e.done;ce++,_e=I.next())_e=L($,N,ce,_e.value,q),_e!==null&&(e&&_e.alternate!==null&&$.delete(_e.key===null?ce:_e.key),R=p(_e,R,ce),Ee===null?te=_e:Ee.sibling=_e,Ee=_e);return e&&$.forEach(function(Fv){return n(N,Fv)}),Te&&Wt(N,ce),te}function we(N,R,I,q){if(typeof I=="object"&&I!==null&&I.type===G&&I.key===null&&(I=I.props.children),typeof I=="object"&&I!==null){switch(I.$$typeof){case C:e:{for(var te=I.key;R!==null;){if(R.key===te){if(te=I.type,te===G){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===te||typeof te=="object"&&te!==null&&te.$$typeof===ee&&ti(te)===R.type){o(N,R.sibling),q=d(R,I.props),Co(q,I),q.return=N,N=q;break e}o(N,R);break}else n(N,R);R=R.sibling}I.type===G?(q=Zn(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),Co(q,I),q.return=N,N=q)}return T(N);case w:e:{for(te=I.key;R!==null;){if(R.key===te)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=Es(I,N.mode,q),q.return=N,N=q}return T(N);case ee:return I=ti(I),we(N,R,I,q)}if(be(I))return Z(N,R,I,q);if(Ae(I)){if(te=Ae(I),typeof te!="function")throw Error(a(150));return I=te.call(I),ie(N,R,I,q)}if(typeof I.then=="function")return we(N,R,Dl(I),q);if(I.$$typeof===P)return we(N,R,Rl(N,I),q);Ul(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=Ss(I,N.mode,q),q.return=N,N=q),T(N)):o(N,R)}return function(N,R,I,q){try{_o=0;var te=we(N,R,I,q);return wi=null,te}catch($){if($===Ui||$===Nl)throw $;var Ee=St(29,$,null,N.mode);return Ee.lanes=q,Ee.return=N,Ee}finally{}}}var ii=Wc(!0),jc=Wc(!1),Cn=!1;function bs(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ls(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 An(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Rn(e,n,o){var s=e.updateQueue;if(s===null)return null;if(s=s.shared,(Re&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),Hc(e,null,o),n}return Sl(e,s,n,o),El(e)}function Ao(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,Fu(e,o)}}function Gs(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 Hs=!1;function Ro(){if(Hs){var e=Di;if(e!==null)throw e}}function Mo(e,n,o,s){Hs=!1;var d=e.updateQueue;Cn=!1;var p=d.firstBaseUpdate,T=d.lastBaseUpdate,_=d.shared.pending;if(_!==null){d.shared.pending=null;var A=_,D=A.next;A.next=null,T===null?p=D:T.next=D,T=A;var H=e.alternate;H!==null&&(H=H.updateQueue,_=H.lastBaseUpdate,_!==T&&(_===null?H.firstBaseUpdate=D:_.next=D,H.lastBaseUpdate=A))}if(p!==null){var z=d.baseState;T=0,H=D=A=null,_=p;do{var U=_.lane&-536870913,L=U!==_.lane;if(L?(he&U)===U:(s&U)===U){U!==0&&U===Ii&&(Hs=!0),H!==null&&(H=H.next={lane:0,tag:_.tag,payload:_.payload,callback:null,next:null});e:{var Z=e,ie=_;U=n;var we=o;switch(ie.tag){case 1:if(Z=ie.payload,typeof Z=="function"){z=Z.call(we,z,U);break e}z=Z;break e;case 3:Z.flags=Z.flags&-65537|128;case 0:if(Z=ie.payload,U=typeof Z=="function"?Z.call(we,z,U):Z,U==null)break e;z=S({},z,U);break e;case 2:Cn=!0}}U=_.callback,U!==null&&(e.flags|=64,L&&(e.flags|=8192),L=d.callbacks,L===null?d.callbacks=[U]:L.push(U))}else L={lane:U,tag:_.tag,payload:_.payload,callback:_.callback,next:null},H===null?(D=H=L,A=z):H=H.next=L,T|=U;if(_=_.next,_===null){if(_=d.shared.pending,_===null)break;L=_,_=L.next,L.next=null,d.lastBaseUpdate=L,d.shared.pending=null}}while(!0);H===null&&(A=z),d.baseState=A,d.firstBaseUpdate=D,d.lastBaseUpdate=H,p===null&&(d.shared.lanes=0),Un|=T,e.lanes=T,e.memoizedState=z}}function ef(e,n){if(typeof e!="function")throw Error(a(191,e));e.call(n)}function tf(e,n){var o=e.callbacks;if(o!==null)for(e.callbacks=null,e=0;ep?p:8;var T=b.T,_={};b.T=_,tr(e,!1,n,o);try{var A=d(),D=b.S;if(D!==null&&D(_,A),A!==null&&typeof A=="object"&&typeof A.then=="function"){var H=by(A,s);Do(e,n,H,Rt(e))}else Do(e,n,s,Rt(e))}catch(z){Do(e,n,{then:function(){},status:"rejected",reason:z},Rt())}finally{O.p=p,T!==null&&_.types!==null&&(T.types=_.types),b.T=T}}function zy(){}function js(e,n,o,s){if(e.tag!==5)throw Error(a(476));var d=Lf(e).queue;bf(e,d,n,ne,o===null?zy:function(){return Gf(e),o(s)})}function Lf(e){var n=e.memoizedState;if(n!==null)return n;n={memoizedState:ne,baseState:ne,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:nn,lastRenderedState:ne},next:null};var o={};return n.next={memoizedState:o,baseState:o,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:nn,lastRenderedState:o},next:null},e.memoizedState=n,e=e.alternate,e!==null&&(e.memoizedState=n),n}function Gf(e){var n=Lf(e);n.next===null&&(n=e.alternate.memoizedState),Do(e,n.next.queue,{},Rt())}function er(){return je(Yo)}function Hf(){return Oe().memoizedState}function qf(){return Oe().memoizedState}function By(e){for(var n=e.return;n!==null;){switch(n.tag){case 24:case 3:var o=Rt();e=An(o);var s=Rn(n,e,o);s!==null&&(ht(s,n,o),Ao(s,n,o)),n={cache:Ds()},e.payload=n;return}n=n.return}}function Py(e,n,o){var s=Rt();o={lane:s,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Bl(e)?zf(n,o):(o=vs(e,n,o,s),o!==null&&(ht(o,e,s),Bf(o,n,s)))}function Vf(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))zf(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),xe===null&&Tl(),!1}catch{}finally{}if(o=vs(e,n,d,s),o!==null)return ht(o,e,s),Bf(o,n,s),!0}return!1}function tr(e,n,o,s){if(s={lane:2,revertLane:br(),gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null},Bl(e)){if(n)throw Error(a(479))}else n=vs(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 zf(e,n){bi=bl=!0;var o=e.pending;o===null?n.next=n:(n.next=o.next,o.next=n),e.pending=n}function Bf(e,n,o){if((o&4194048)!==0){var s=n.lanes;s&=e.pendingLanes,o|=s,n.lanes=o,Fu(e,o)}}var Uo={readContext:je,use:Hl,useCallback:Ve,useContext:Ve,useEffect:Ve,useImperativeHandle:Ve,useLayoutEffect:Ve,useInsertionEffect:Ve,useMemo:Ve,useReducer:Ve,useRef:Ve,useState:Ve,useDebugValue:Ve,useDeferredValue:Ve,useTransition:Ve,useSyncExternalStore:Ve,useId:Ve,useHostTransitionStatus:Ve,useFormState:Ve,useActionState:Ve,useOptimistic:Ve,useMemoCache:Ve,useCacheRefresh:Ve};Uo.useEffectEvent=Ve;var Pf={readContext:je,use:Hl,useCallback:function(e,n){return lt().memoizedState=[e,n===void 0?null:n],e},useContext:je,useEffect:Af,useImperativeHandle:function(e,n,o){o=o!=null?o.concat([e]):null,Vl(4194308,4,If.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(oi){gn(!0);try{e()}finally{gn(!1)}}return o.memoizedState=[s,n],s},useReducer:function(e,n,o){var s=lt();if(o!==void 0){var d=o(n);if(oi){gn(!0);try{o(n)}finally{gn(!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=Py.bind(null,se,e),[s.memoizedState,e]},useRef:function(e){var n=lt();return e={current:e},n.memoizedState=e},useState:function(e){e=Ks(e);var n=e.queue,o=Vf.bind(null,se,n);return n.dispatch=o,[e.memoizedState,o]},useDebugValue:$s,useDeferredValue:function(e,n){var o=lt();return Ws(o,e,n)},useTransition:function(){var e=Ks(!1);return e=bf.bind(null,se,e.queue,!0,!1),lt().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,n,o){var s=se,d=lt();if(Te){if(o===void 0)throw Error(a(407));o=o()}else{if(o=n(),xe===null)throw Error(a(349));(he&127)!==0||rf(s,n,o)}d.memoizedState=o;var p={value:o,getSnapshot:n};return d.queue=p,Af(cf.bind(null,s,p,e),[e]),s.flags|=2048,Gi(9,{destroy:void 0},uf.bind(null,s,p,o,n),null),o},useId:function(){var e=lt(),n=xe.identifierPrefix;if(Te){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[$e]=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(tt(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&&ln(n)}}return Ge(n),hr(n,n.type,e===null?null:e.memoizedProps,n.pendingProps,o),null;case 6:if(e&&n.stateNode!=null)e.memoizedProps!==s&&ln(n);else{if(typeof s!="string"&&n.stateNode===null)throw Error(a(166));if(e=de.current,Mi(n)){if(e=n.stateNode,o=n.memoizedProps,s=null,d=We,d!==null)switch(d.tag){case 27:case 5:s=d.memoizedProps}e[$e]=n,e=!!(e.nodeValue===o||s!==null&&s.suppressHydrationWarning===!0||ap(e.nodeValue,o)),e||En(n,!0)}else e=aa(e).createTextNode(s),e[$e]=n,n.stateNode=e}return Ge(n),null;case 31:if(o=n.memoizedState,e===null||e.memoizedState!==null){if(s=Mi(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[$e]=n}else $n(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;Ge(n),e=!1}else o=Rs(),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 Ge(n),null;case 13:if(s=n.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(d=Mi(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[$e]=n}else $n(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;Ge(n),d=!1}else d=Rs(),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),Ge(n),null);case 4:return Be(),e===null&&qr(n.stateNode.containerInfo),Ge(n),null;case 10:return en(n.type),Ge(n),null;case 19:if(V(Pe),s=n.memoizedState,s===null)return Ge(n),null;if(d=(n.flags&128)!==0,p=s.rendering,p===null)if(d)xo(s,!1);else{if(ze!==0||e!==null&&(e.flags&128)!==0)for(e=n.child;e!==null;){if(p=xl(e),p!==null){for(n.flags|=128,xo(s,!1),e=p.updateQueue,n.updateQueue=e,Jl(n,e),n.subtreeFlags=0,e=o,o=n.child;o!==null;)qc(o,e),o=o.sibling;return k(Pe,Pe.current&1|2),Te&&Wt(n,s.treeForkCount),n.child}e=e.sibling}s.tail!==null&>()>Zl&&(n.flags|=128,d=!0,xo(s,!1),n.lanes=4194304)}else{if(!d)if(e=xl(p),e!==null){if(n.flags|=128,d=!0,e=e.updateQueue,n.updateQueue=e,Jl(n,e),xo(s,!0),s.tail===null&&s.tailMode==="hidden"&&!p.alternate&&!Te)return Ge(n),null}else 2*gt()-s.renderingStartTime>Zl&&o!==536870912&&(n.flags|=128,d=!0,xo(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=Pe.current,k(Pe,d?o&1|2:o&1),Te&&Wt(n,s.treeForkCount),e):(Ge(n),null);case 22:case 23:return _t(n),Vs(),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&&(Ge(n),n.subtreeFlags&6&&(n.flags|=8192)):Ge(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&&V(ei),null;case 24:return o=null,e!==null&&(o=e.memoizedState.cache),n.memoizedState.cache!==o&&(n.flags|=2048),en(ke),Ge(n),null;case 25:return null;case 30:return null}throw Error(a(156,n.tag))}function Yy(e,n){switch(Cs(n),n.tag){case 1:return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return en(ke),Be(),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));$n()}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));$n()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return V(Pe),null;case 4:return Be(),null;case 10:return en(n.type),null;case 22:case 23:return _t(n),Vs(),e!==null&&V(ei),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 24:return en(ke),null;case 25:return null;default:return null}}function fd(e,n){switch(Cs(n),n.tag){case 3:en(ke),Be();break;case 26:case 27:case 5:nl(n);break;case 4:Be();break;case 31:n.memoizedState!==null&&_t(n);break;case 13:_t(n);break;case 19:V(Pe);break;case 10:en(n.type);break;case 22:case 23:_t(n),Vs(),e!==null&&V(ei);break;case 24:en(ke)}}function bo(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(_){Ie(n,n.return,_)}}function In(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,D=_;try{D()}catch(H){Ie(d,A,H)}}}s=s.next}while(s!==p)}}catch(H){Ie(n,n.return,H)}}function dd(e){var n=e.updateQueue;if(n!==null){var o=e.stateNode;try{tf(n,o)}catch(s){Ie(e,e.return,s)}}}function pd(e,n,o){o.props=li(e.type,e.memoizedProps),o.state=e.memoizedState;try{o.componentWillUnmount()}catch(s){Ie(e,n,s)}}function Lo(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){Ie(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){Ie(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){Ie(e,n,d)}else o.current=null}function md(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){Ie(e,e.return,d)}}function gr(e,n,o){try{var s=e.stateNode;mv(s,e.type,o,n),s[ut]=n}catch(d){Ie(e,e.return,d)}}function hd(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Gn(e.type)||e.tag===4}function yr(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||hd(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&&Gn(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 vr(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=Qt));else if(s!==4&&(s===27&&Gn(e.type)&&(o=e.stateNode,n=null),e=e.child,e!==null))for(vr(e,n,o),e=e.sibling;e!==null;)vr(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&&Gn(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 gd(e){var n=e.stateNode,o=e.memoizedProps;try{for(var s=e.type,d=n.attributes;d.length;)n.removeAttributeNode(d[0]);tt(n,s,o),n[$e]=e,n[ut]=o}catch(p){Ie(e,e.return,p)}}var an=!1,Ye=!1,Tr=!1,yd=typeof WeakSet=="function"?WeakSet:Set,Qe=null;function Xy(e,n){if(e=e.containerInfo,Br=pa,e=Ic(e),ds(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,D=0,H=0,z=e,U=null;t:for(;;){for(var L;z!==o||d!==0&&z.nodeType!==3||(_=T+d),z!==p||s!==0&&z.nodeType!==3||(A=T+s),z.nodeType===3&&(T+=z.nodeValue.length),(L=z.firstChild)!==null;)U=z,z=L;for(;;){if(z===e)break t;if(U===o&&++D===d&&(_=T),U===p&&++H===s&&(A=T),(L=z.nextSibling)!==null)break;z=U,U=z.parentNode}z=L}o=_===-1||A===-1?null:{start:_,end:A}}else o=null}o=o||{start:0,end:0}}else o=null;for(Pr={focusedElem:e,selectionRange:o},pa=!1,Qe=n;Qe!==null;)if(n=Qe,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,Qe=e;else for(;Qe!==null;){switch(n=Qe,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"))),tt(p,s,o),p[$e]=e,Ke(p),s=p;break e;case"link":var T=Cp("link","href",d).get(s+(o.href||""));if(T){for(var _=0;_we&&(T=we,we=ie,ie=T);var N=Mc(_,ie),R=Mc(_,we);if(N&&R&&(L.rangeCount!==1||L.anchorNode!==N.node||L.anchorOffset!==N.offset||L.focusNode!==R.node||L.focusOffset!==R.offset)){var I=z.createRange();I.setStart(N.node,N.offset),L.removeAllRanges(),ie>we?(L.addRange(I),L.extend(R.node,R.offset)):(I.setEnd(R.node,R.offset),L.addRange(I))}}}}for(z=[],L=_;L=L.parentNode;)L.nodeType===1&&z.push({element:L,left:L.scrollLeft,top:L.scrollTop});for(typeof _.focus=="function"&&_.focus(),_=0;_o?32:o,b.T=null,o=Mr,Mr=null;var p=xn,T=fn;if(Xe=0,Bi=xn=null,fn=0,(Re&6)!==0)throw Error(a(331));var _=Re;if(Re|=4,Id(p.current),Rd(p,p.current,T,o),Re=_,Bo(0,!1),yt&&typeof yt.onPostCommitFiberRoot=="function")try{yt.onPostCommitFiberRoot(io,p)}catch{}return!0}finally{O.p=d,b.T=s,Yd(e,n)}}function Kd(e,n,o){n=Dt(o,n),n=lr(e.stateNode,n,2),e=Rn(e,n,2),e!==null&&(lo(e,2),Xt(e))}function Ie(e,n,o){if(e.tag===3)Kd(e,e,o);else for(;n!==null;){if(n.tag===3){Kd(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=Dt(o,e),o=Qf(2),s=Rn(n,o,2),s!==null&&(Zf(o,s,n,e),lo(s,2),Xt(s));break}}n=n.return}}function Ur(e,n,o){var s=e.pingCache;if(s===null){s=e.pingCache=new Zy;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)||(_r=!0,d.add(o),e=tv.bind(null,e,n,o),n.then(e,e))}function tv(e,n,o){var s=e.pingCache;s!==null&&s.delete(n),e.pingedLanes|=e.suspendedLanes&o,e.warmLanes&=~o,xe===e&&(he&o)===o&&(ze===4||ze===3&&(he&62914560)===he&&300>gt()-Ql?(Re&2)===0&&Pi(e,0):Cr|=o,zi===he&&(zi=0)),Xt(e)}function Qd(e,n){n===0&&(n=Ou()),e=Qn(e,n),e!==null&&(lo(e,n),Xt(e))}function nv(e){var n=e.memoizedState,o=0;n!==null&&(o=n.retryLane),Qd(e,o)}function iv(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),Qd(e,o)}function ov(e,n){return ka(e,n)}var na=null,ki=null,wr=!1,ia=!1,xr=!1,Ln=0;function Xt(e){e!==ki&&e.next===null&&(ki===null?na=ki=e:ki=ki.next=e),ia=!0,wr||(wr=!0,av())}function Bo(e,n){if(!xr&&ia){xr=!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,jd(s,p))}else p=he,p=sl(s,s===xe?p:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),(p&3)===0||oo(s,p)||(o=!0,jd(s,p));s=s.next}while(o);xr=!1}}function lv(){Zd()}function Zd(){ia=wr=!1;var e=0;Ln!==0&&gv()&&(e=Ln);for(var n=gt(),o=null,s=na;s!==null;){var d=s.next,p=$d(s,n);p===0?(s.next=null,o===null?na=d:o.next=d,d===null&&(ki=o)):(o=s,(e!==0||(p&3)!==0)&&(ia=!0)),s=d}Xe!==0&&Xe!==5||Bo(e),Ln!==0&&(Ln=0)}function $d(e,n){for(var o=e.suspendedLanes,s=e.pingedLanes,d=e.expirationTimes,p=e.pendingLanes&-62914561;0_)break;var H=A.transferSize,z=A.initiatorType;H&&sp(z)&&(A=A.responseEnd,T+=H*(A<_?1:(_-D)/(A-D)))}if(--s,n+=8*(p+T)/(d.duration/1e3),e++,10"u"?null:document;function Tp(e,n,o){var s=Fi;if(s&&typeof n=="string"&&n){var d=Nt(n);d='link[rel="'+e+'"][href="'+d+'"]',typeof o=="string"&&(d+='[crossorigin="'+o+'"]'),vp.has(d)||(vp.add(d),e={rel:e,crossOrigin:o,href:n},s.querySelector(d)===null&&(n=s.createElement("link"),tt(n,"link",e),Ke(n),s.head.appendChild(n)))}}function Rv(e){dn.D(e),Tp("dns-prefetch",e,null)}function Mv(e,n){dn.C(e,n),Tp("preconnect",e,n)}function Nv(e,n,o){dn.L(e,n,o);var s=Fi;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=Ji(e);break;case"script":p=Yi(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(Fo(p))||n==="script"&&s.querySelector(Jo(p))||(n=s.createElement("link"),tt(n,"link",e),Ke(n),s.head.appendChild(n)))}}function Iv(e,n){dn.m(e,n);var o=Fi;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=Yi(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(Jo(p)))return}s=o.createElement("link"),tt(s,"link",e),Ke(s),o.head.appendChild(s)}}}function Dv(e,n,o){dn.S(e,n,o);var s=Fi;if(s&&e){var d=pi(s).hoistableStyles,p=Ji(e);n=n||"default";var T=d.get(p);if(!T){var _={loading:0,preload:null};if(T=s.querySelector(Fo(p)))_.loading=5;else{e=S({rel:"stylesheet",href:e,"data-precedence":n},o),(o=Gt.get(p))&&Kr(e,o);var A=T=s.createElement("link");Ke(A),tt(A,"link",e),A._p=new Promise(function(D,H){A.onload=D,A.onerror=H}),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 Uv(e,n){dn.X(e,n);var o=Fi;if(o&&e){var s=pi(o).hoistableScripts,d=Yi(e),p=s.get(d);p||(p=o.querySelector(Jo(d)),p||(e=S({src:e,async:!0},n),(n=Gt.get(d))&&Qr(e,n),p=o.createElement("script"),Ke(p),tt(p,"link",e),o.head.appendChild(p)),p={type:"script",instance:p,count:1,state:null},s.set(d,p))}}function wv(e,n){dn.M(e,n);var o=Fi;if(o&&e){var s=pi(o).hoistableScripts,d=Yi(e),p=s.get(d);p||(p=o.querySelector(Jo(d)),p||(e=S({src:e,async:!0,type:"module"},n),(n=Gt.get(d))&&Qr(e,n),p=o.createElement("script"),Ke(p),tt(p,"link",e),o.head.appendChild(p)),p={type:"script",instance:p,count:1,state:null},s.set(d,p))}}function Sp(e,n,o,s){var d=(d=de.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=Ji(o.href),o=pi(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=Ji(o.href);var p=pi(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(Fo(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||xv(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=Yi(o),o=pi(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 Ji(e){return'href="'+Nt(e)+'"'}function Fo(e){return'link[rel="stylesheet"]['+e+"]"}function Ep(e){return S({},e,{"data-precedence":e.precedence,precedence:null})}function xv(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}),tt(n,"link",o),Ke(n),e.head.appendChild(n))}function Yi(e){return'[src="'+Nt(e)+'"]'}function Jo(e){return"script[async]"+e}function _p(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,Ke(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"),Ke(s),tt(s,"style",d),ra(s,o.precedence,e),n.instance=s;case"stylesheet":d=Ji(o.href);var p=e.querySelector(Fo(d));if(p)return n.state.loading|=4,n.instance=p,Ke(p),p;s=Ep(o),(d=Gt.get(d))&&Kr(s,d),p=(e.ownerDocument||e).createElement("link"),Ke(p);var T=p;return T._p=new Promise(function(_,A){T.onload=_,T.onerror=A}),tt(p,"link",s),n.state.loading|=4,ra(p,o.precedence,e),n.instance=p;case"script":return p=Yi(o.src),(d=e.querySelector(Jo(p)))?(n.instance=d,Ke(d),d):(s=o,(d=Gt.get(p))&&(s=S({},o),Qr(s,d)),e=e.ownerDocument||e,d=e.createElement("script"),Ke(d),tt(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 bv(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 Rp(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function Lv(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=Ji(s.href),p=n.querySelector(Fo(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,Ke(p);return}p=n.ownerDocument||n,s=Ep(s),(d=Gt.get(d))&&Kr(s,d),p=p.createElement("link"),Ke(p);var T=p;T._p=new Promise(function(_,A){T.onload=_,T.onerror=A}),tt(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 Zr=0;function Gv(e,n){return e.stylesheets&&e.count===0&&da(e,e.stylesheets),0Zr?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(Hv,e),fa=null,ca.call(e))}function Hv(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(),lu.exports=jv(),lu.exports}var t0=e0();const n0=Ih(t0),i0=`את מִיָּה (Miya) - העוזרת הקולית של MyStory. השם שלך נהגה "מִיָּה" עם י דגושה. 🎯 התפקיד שלך: את נציגת השירות, המדריכה והמלווה הרגשית של האתר. את מדברת עברית חמה, רגועה ובטוחה - לא טכנולוגית מדי, לא ילדותית מדי. את לא גימיק - את מוח האתר. 📘 מבנה האתר שאת מכירה: - דף בית - הכירות עם MyStory - איך זה עובד - 6 שלבים ליצירת ספר - יצירת ספר (Wizard) - התהליך עצמו - חבילות: דיגיטלית (₪49) / דיגיטלי + מודפס (₪129) - כרטיס מתנה - דוגמאות וסיפורים - דפי צביעה - שאלות נפוצות ותמיכה 📦 מוצרים: - ספר דיגיטלי (PDF) - נוצר מיידית - הקראה קולית (MP3) - ספר מודפס בכריכה איכותית - דפי צביעה (4-6 דפים בדיגיטלי, 8-10 במורחב) - כרטיס מתנה 🧠 חוקים חשובים: - אין תשלום לפני סוף התהליך - רק 2 חבילות: ₪49 (דיגיטלי) ו-₪129 (דיגיטלי + מודפס) - כל ספר נוצר אישית לפי שם הילד והתמונה - התצוגה המקדימה היא הצצה בלבד - לא המוצר הסופי 🧭 מה את עושה: 1. ניווט חכם - את יכולה להציע "רוצה שאעביר אותך למחירים?" או "להראות לך דוגמה?" 2. הסבר בכל שלב ב-Wizard: - שלב 1: "פה בוחרים את פרטי הילד. השם יופיע לאורך כל הסיפור" - שלב 4 (Preview): "זו הצצה קטנה. הספר המלא נוצר רק אחרי הרכישה" - שלב 5 (חבילות): "רוב ההורים בוחרים בחבילה המשולבת כדי לקבל גם ספר פיזי" 3. המלצות עדינות (לא מכירה אגרסיבית): - אחרי Preview: "רוצה גם דפי צביעה של הסיפור?" - בכרטיס מתנה: "זה מושלם ליום הולדת. רוצה שאסביר?" 💬 סגנון התקשורת שלך: - חמה ואמפתית: "אתם עושים משהו מיוחד. זה לא עוד ספר - זה סיפור עם משמעות" - קצרה וענינית - משפט או שניים בכל פעם - את מלווה, לא מקריינת - את יכולה לשיר שיר קצר בעברית אם מבקשים ⚠️ מה לא לעשות: - לא להציק או לדבר יותר מדי - לא למכור בכוח - לא לדבר באמצע הקלדה או תשלום חשוב: את נמצאת באזור הזמן של ישראל (Asia/Jerusalem).`;var o0={};/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */let l0,a0;function s0(){return{geminiUrl:l0,vertexUrl:a0}}function r0(i,t,l,a){var u,f;if(!(i!=null&&i.baseUrl)){const m=s0();return t?(u=m.vertexUrl)!==null&&u!==void 0?u: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 mn{}function J(i,t){const l=/\{([^}]+)\}/g;return i.replace(l,(a,u)=>{if(Object.prototype.hasOwnProperty.call(t,u)){const f=t[u];return f!=null?String(f):""}else throw new Error(`Key '${u}' 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;hr(g,t.slice(a+1),l)):l}else return l}else i=i[u]}return i}catch(a){if(a instanceof TypeError)return l;throw a}}function u0(i,t){for(const[l,a]of Object.entries(t)){const u=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])du(y,t,l,a+1,u)}else if(f==="*"){if(typeof i=="object"&&i!==null&&!Array.isArray(i)){const m=i,g=Object.keys(m).filter(h=>!h.startsWith("_")&&!u.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&&du(m[f],t,l,a+1,u)}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function Nu(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 c0(i){const t={},l=r(i,["operationName"]);l!=null&&c(t,["operationName"],l);const a=r(i,["resourceName"]);return a!=null&&c(t,["_url","resourceName"],a),t}function f0(i){const t={},l=r(i,["name"]);l!=null&&c(t,["name"],l);const a=r(i,["metadata"]);a!=null&&c(t,["metadata"],a);const u=r(i,["done"]);u!=null&&c(t,["done"],u);const f=r(i,["error"]);f!=null&&c(t,["error"],f);const m=r(i,["response","generateVideoResponse"]);return m!=null&&c(t,["response"],p0(m)),t}function d0(i){const t={},l=r(i,["name"]);l!=null&&c(t,["name"],l);const a=r(i,["metadata"]);a!=null&&c(t,["metadata"],a);const u=r(i,["done"]);u!=null&&c(t,["done"],u);const f=r(i,["error"]);f!=null&&c(t,["error"],f);const m=r(i,["response"]);return m!=null&&c(t,["response"],m0(m)),t}function p0(i){const t={},l=r(i,["generatedSamples"]);if(l!=null){let f=l;Array.isArray(f)&&(f=f.map(m=>h0(m))),c(t,["generatedVideos"],f)}const a=r(i,["raiMediaFilteredCount"]);a!=null&&c(t,["raiMediaFilteredCount"],a);const u=r(i,["raiMediaFilteredReasons"]);return u!=null&&c(t,["raiMediaFilteredReasons"],u),t}function m0(i){const t={},l=r(i,["videos"]);if(l!=null){let f=l;Array.isArray(f)&&(f=f.map(m=>g0(m))),c(t,["generatedVideos"],f)}const a=r(i,["raiMediaFilteredCount"]);a!=null&&c(t,["raiMediaFilteredCount"],a);const u=r(i,["raiMediaFilteredReasons"]);return u!=null&&c(t,["raiMediaFilteredReasons"],u),t}function h0(i){const t={},l=r(i,["video"]);return l!=null&&c(t,["video"],_0(l)),t}function g0(i){const t={},l=r(i,["_self"]);return l!=null&&c(t,["video"],C0(l)),t}function y0(i){const t={},l=r(i,["operationName"]);return l!=null&&c(t,["_url","operationName"],l),t}function v0(i){const t={},l=r(i,["operationName"]);return l!=null&&c(t,["_url","operationName"],l),t}function T0(i){const t={},l=r(i,["name"]);l!=null&&c(t,["name"],l);const a=r(i,["metadata"]);a!=null&&c(t,["metadata"],a);const u=r(i,["done"]);u!=null&&c(t,["done"],u);const f=r(i,["error"]);f!=null&&c(t,["error"],f);const m=r(i,["response"]);return m!=null&&c(t,["response"],S0(m)),t}function S0(i){const t={},l=r(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=r(i,["parent"]);a!=null&&c(t,["parent"],a);const u=r(i,["documentName"]);return u!=null&&c(t,["documentName"],u),t}function Dh(i){const t={},l=r(i,["name"]);l!=null&&c(t,["name"],l);const a=r(i,["metadata"]);a!=null&&c(t,["metadata"],a);const u=r(i,["done"]);u!=null&&c(t,["done"],u);const f=r(i,["error"]);f!=null&&c(t,["error"],f);const m=r(i,["response"]);return m!=null&&c(t,["response"],E0(m)),t}function E0(i){const t={},l=r(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=r(i,["parent"]);a!=null&&c(t,["parent"],a);const u=r(i,["documentName"]);return u!=null&&c(t,["documentName"],u),t}function _0(i){const t={},l=r(i,["uri"]);l!=null&&c(t,["uri"],l);const a=r(i,["encodedVideo"]);a!=null&&c(t,["videoBytes"],Nu(a));const u=r(i,["encoding"]);return u!=null&&c(t,["mimeType"],u),t}function C0(i){const t={},l=r(i,["gcsUri"]);l!=null&&c(t,["uri"],l);const a=r(i,["bytesBase64Encoded"]);a!=null&&c(t,["videoBytes"],Nu(a));const u=r(i,["mimeType"]);return u!=null&&c(t,["mimeType"],u),t}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */var Qp;(function(i){i.OUTCOME_UNSPECIFIED="OUTCOME_UNSPECIFIED",i.OUTCOME_OK="OUTCOME_OK",i.OUTCOME_FAILED="OUTCOME_FAILED",i.OUTCOME_DEADLINE_EXCEEDED="OUTCOME_DEADLINE_EXCEEDED"})(Qp||(Qp={}));var Zp;(function(i){i.LANGUAGE_UNSPECIFIED="LANGUAGE_UNSPECIFIED",i.PYTHON="PYTHON"})(Zp||(Zp={}));var $p;(function(i){i.SCHEDULING_UNSPECIFIED="SCHEDULING_UNSPECIFIED",i.SILENT="SILENT",i.WHEN_IDLE="WHEN_IDLE",i.INTERRUPT="INTERRUPT"})($p||($p={}));var Pn;(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"})(Pn||(Pn={}));var Wp;(function(i){i.API_SPEC_UNSPECIFIED="API_SPEC_UNSPECIFIED",i.SIMPLE_SEARCH="SIMPLE_SEARCH",i.ELASTIC_SEARCH="ELASTIC_SEARCH"})(Wp||(Wp={}));var jp;(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"})(jp||(jp={}));var em;(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"})(em||(em={}));var tm;(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"})(tm||(tm={}));var nm;(function(i){i.UNSPECIFIED="UNSPECIFIED",i.BLOCKING="BLOCKING",i.NON_BLOCKING="NON_BLOCKING"})(nm||(nm={}));var im;(function(i){i.MODE_UNSPECIFIED="MODE_UNSPECIFIED",i.MODE_DYNAMIC="MODE_DYNAMIC"})(im||(im={}));var om;(function(i){i.MODE_UNSPECIFIED="MODE_UNSPECIFIED",i.AUTO="AUTO",i.ANY="ANY",i.NONE="NONE",i.VALIDATED="VALIDATED"})(om||(om={}));var lm;(function(i){i.THINKING_LEVEL_UNSPECIFIED="THINKING_LEVEL_UNSPECIFIED",i.LOW="LOW",i.MEDIUM="MEDIUM",i.HIGH="HIGH",i.MINIMAL="MINIMAL"})(lm||(lm={}));var am;(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"})(am||(am={}));var sm;(function(i){i.HARM_BLOCK_METHOD_UNSPECIFIED="HARM_BLOCK_METHOD_UNSPECIFIED",i.SEVERITY="SEVERITY",i.PROBABILITY="PROBABILITY"})(sm||(sm={}));var rm;(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"})(rm||(rm={}));var um;(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"})(um||(um={}));var cm;(function(i){i.HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",i.NEGLIGIBLE="NEGLIGIBLE",i.LOW="LOW",i.MEDIUM="MEDIUM",i.HIGH="HIGH"})(cm||(cm={}));var fm;(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"})(fm||(fm={}));var dm;(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"})(dm||(dm={}));var pm;(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"})(pm||(pm={}));var mm;(function(i){i.TRAFFIC_TYPE_UNSPECIFIED="TRAFFIC_TYPE_UNSPECIFIED",i.ON_DEMAND="ON_DEMAND",i.PROVISIONED_THROUGHPUT="PROVISIONED_THROUGHPUT"})(mm||(mm={}));var tl;(function(i){i.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",i.TEXT="TEXT",i.IMAGE="IMAGE",i.AUDIO="AUDIO"})(tl||(tl={}));var hm;(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"})(hm||(hm={}));var gm;(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"})(gm||(gm={}));var ym;(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"})(ym||(ym={}));var pu;(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"})(pu||(pu={}));var vm;(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"})(vm||(vm={}));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",i.MEDIA_RESOLUTION_ULTRA_HIGH="MEDIA_RESOLUTION_ULTRA_HIGH"})(Tm||(Tm={}));var Sm;(function(i){i.FEATURE_SELECTION_PREFERENCE_UNSPECIFIED="FEATURE_SELECTION_PREFERENCE_UNSPECIFIED",i.PRIORITIZE_QUALITY="PRIORITIZE_QUALITY",i.BALANCED="BALANCED",i.PRIORITIZE_COST="PRIORITIZE_COST"})(Sm||(Sm={}));var Em;(function(i){i.ENVIRONMENT_UNSPECIFIED="ENVIRONMENT_UNSPECIFIED",i.ENVIRONMENT_BROWSER="ENVIRONMENT_BROWSER"})(Em||(Em={}));var _m;(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"})(_m||(_m={}));var Cm;(function(i){i.DONT_ALLOW="DONT_ALLOW",i.ALLOW_ADULT="ALLOW_ADULT",i.ALLOW_ALL="ALLOW_ALL"})(Cm||(Cm={}));var Am;(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"})(Am||(Am={}));var Rm;(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"})(Rm||(Rm={}));var Mm;(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"})(Mm||(Mm={}));var Nm;(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"})(Nm||(Nm={}));var Im;(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"})(Im||(Im={}));var Dm;(function(i){i.FOREGROUND="FOREGROUND",i.BACKGROUND="BACKGROUND",i.PROMPT="PROMPT",i.SEMANTIC="SEMANTIC",i.INTERACTIVE="INTERACTIVE"})(Dm||(Dm={}));var Um;(function(i){i.ASSET="ASSET",i.STYLE="STYLE"})(Um||(Um={}));var wm;(function(i){i.INSERT="INSERT",i.REMOVE="REMOVE",i.REMOVE_STATIC="REMOVE_STATIC",i.OUTPAINT="OUTPAINT"})(wm||(wm={}));var xm;(function(i){i.OPTIMIZED="OPTIMIZED",i.LOSSLESS="LOSSLESS"})(xm||(xm={}));var bm;(function(i){i.SUPERVISED_FINE_TUNING="SUPERVISED_FINE_TUNING",i.PREFERENCE_TUNING="PREFERENCE_TUNING"})(bm||(bm={}));var Lm;(function(i){i.STATE_UNSPECIFIED="STATE_UNSPECIFIED",i.STATE_PENDING="STATE_PENDING",i.STATE_ACTIVE="STATE_ACTIVE",i.STATE_FAILED="STATE_FAILED"})(Lm||(Lm={}));var Gm;(function(i){i.STATE_UNSPECIFIED="STATE_UNSPECIFIED",i.PROCESSING="PROCESSING",i.ACTIVE="ACTIVE",i.FAILED="FAILED"})(Gm||(Gm={}));var Hm;(function(i){i.SOURCE_UNSPECIFIED="SOURCE_UNSPECIFIED",i.UPLOADED="UPLOADED",i.GENERATED="GENERATED",i.REGISTERED="REGISTERED"})(Hm||(Hm={}));var qm;(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"})(qm||(qm={}));var Vm;(function(i){i.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",i.TEXT="TEXT",i.IMAGE="IMAGE",i.VIDEO="VIDEO",i.AUDIO="AUDIO",i.DOCUMENT="DOCUMENT"})(Vm||(Vm={}));var zm;(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"})(zm||(zm={}));var Bm;(function(i){i.START_SENSITIVITY_UNSPECIFIED="START_SENSITIVITY_UNSPECIFIED",i.START_SENSITIVITY_HIGH="START_SENSITIVITY_HIGH",i.START_SENSITIVITY_LOW="START_SENSITIVITY_LOW"})(Bm||(Bm={}));var Pm;(function(i){i.END_SENSITIVITY_UNSPECIFIED="END_SENSITIVITY_UNSPECIFIED",i.END_SENSITIVITY_HIGH="END_SENSITIVITY_HIGH",i.END_SENSITIVITY_LOW="END_SENSITIVITY_LOW"})(Pm||(Pm={}));var Om;(function(i){i.ACTIVITY_HANDLING_UNSPECIFIED="ACTIVITY_HANDLING_UNSPECIFIED",i.START_OF_ACTIVITY_INTERRUPTS="START_OF_ACTIVITY_INTERRUPTS",i.NO_INTERRUPTION="NO_INTERRUPTION"})(Om||(Om={}));var km;(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"})(km||(km={}));var Fm;(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"})(Fm||(Fm={}));var Jm;(function(i){i.MUSIC_GENERATION_MODE_UNSPECIFIED="MUSIC_GENERATION_MODE_UNSPECIFIED",i.QUALITY="QUALITY",i.DIVERSITY="DIVERSITY",i.VOCALIZATION="VOCALIZATION"})(Jm||(Jm={}));var Qi;(function(i){i.PLAYBACK_CONTROL_UNSPECIFIED="PLAYBACK_CONTROL_UNSPECIFIED",i.PLAY="PLAY",i.PAUSE="PAUSE",i.STOP="STOP",i.RESET_CONTEXT="RESET_CONTEXT"})(Qi||(Qi={}));class mu{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 Wo{get text(){var t,l,a,u,f,m,g,y;if(((u=(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||u===void 0?void 0:u.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,w]of Object.entries(E))C!=="text"&&C!=="thought"&&C!=="thoughtSignature"&&(w!==null||w!==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,u,f,m,g,y;if(((u=(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||u===void 0?void 0:u.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,u,f,m,g,y;if(((u=(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||u===void 0?void 0:u.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,u,f,m,g,y,h;if(((u=(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||u===void 0?void 0:u.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,u,f,m,g,y,h;if(((u=(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||u===void 0?void 0:u.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 Ym{}class Xm{}class A0{}class R0{}class M0{}class N0{}class Km{}class Qm{}class Zm{}class I0{}class Na{_fromAPIResponse({apiResponse:t,_isVertexAI:l}){const a=new Na;let u;const f=t;return l?u=d0(f):u=f0(f),Object.assign(a,u),a}}class $m{}class Wm{}class jm{}class eh{}class D0{}class U0{}class w0{}class Iu{_fromAPIResponse({apiResponse:t,_isVertexAI:l}){const a=new Iu,f=T0(t);return Object.assign(a,f),a}}class x0{}class b0{}class L0{}class th{}class G0{get text(){var t,l,a;let u="",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,u+=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?u:void 0}get data(){var t,l,a;let u="";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"&&(u+=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.`),u.length>0?btoa(u):void 0}}class H0{get audioChunk(){if(this.serverContent&&this.serverContent.audioChunks&&this.serverContent.audioChunks.length>0)return this.serverContent.audioChunks[0]}}class Du{_fromAPIResponse({apiResponse:t,_isVertexAI:l}){const a=new Du,f=Dh(t);return Object.assign(a,f),a}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function Ce(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 Uh(i,t){const l=Ce(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 wh(i){return Array.isArray(i)?i.map(t=>Ia(t)):[Ia(i)]}function Ia(i){if(typeof i=="object"&&i!==null)return i;throw new Error(`Could not parse input as Blob. Unsupported blob type: ${typeof i}`)}function xh(i){const t=Ia(i);if(t.mimeType&&t.mimeType.startsWith("image/"))return t;throw new Error(`Unsupported mime type: ${t.mimeType}`)}function bh(i){const t=Ia(i);if(t.mimeType&&t.mimeType.startsWith("audio/"))return t;throw new Error(`Unsupported mime type: ${t.mimeType}`)}function nh(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 Lh(i){if(i==null||Array.isArray(i)&&i.length===0)throw new Error("PartListUnion is required");return Array.isArray(i)?i.map(t=>nh(t)):[nh(i)]}function hu(i){return i!=null&&typeof i=="object"&&"parts"in i&&Array.isArray(i.parts)}function ih(i){return i!=null&&typeof i=="object"&&"functionCall"in i}function oh(i){return i!=null&&typeof i=="object"&&"functionResponse"in i}function it(i){if(i==null)throw new Error("ContentUnion is required");return hu(i)?i:{role:"user",parts:Lh(i)}}function Uu(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(ih(i)||oh(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=hu(i[0]);for(const u of i){const f=hu(u);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(u);else{if(ih(u)||oh(u))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(u)}}return a||t.push({role:"user",parts:Lh(l)}),t}function q0(i,t){i.includes("null")&&(t.nullable=!0);const l=i.filter(a=>a!=="null");if(l.length===1)t.type=Object.values(Pn).includes(l[0].toUpperCase())?l[0].toUpperCase():Pn.TYPE_UNSPECIFIED;else{t.anyOf=[];for(const a of l)t.anyOf.push({type:Object.values(Pn).includes(a.toUpperCase())?a.toUpperCase():Pn.TYPE_UNSPECIFIED})}}function $i(i){const t={},l=["items"],a=["anyOf"],u=["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&&q0(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(Pn).includes(g.toUpperCase())?g.toUpperCase():Pn.TYPE_UNSPECIFIED}else if(l.includes(m))t[m]=$i(g);else if(a.includes(m)){const y=[];for(const h of g){if(h.type=="null"){t.nullable=!0;continue}y.push($i(h))}t[m]=y}else if(u.includes(m)){const y={};for(const[h,v]of Object.entries(g))y[h]=$i(v);t[m]=y}else{if(m==="additionalProperties")continue;t[m]=g}return t}function wu(i){return $i(i)}function xu(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 bu(i){if("multiSpeakerVoiceConfig"in i)throw new Error("multiSpeakerVoiceConfig is not supported in the live API.");return i}function ji(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=$i(t.parameters)),t.response&&(Object.keys(t.response).includes("$schema")?t.responseJsonSchema||(t.responseJsonSchema=t.response,delete t.response):t.response=$i(t.response));return i}function eo(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 V0(i,t,l,a=1){const u=!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}`:u?`projects/${i.getProject()}/locations/${i.getLocation()}/${l}/${t}`:t:u?`${l}/${t}`:t}function hn(i,t){if(typeof t!="string")throw new Error("name must be a string");return V0(i,t,"cachedContents")}function Gh(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 Nu(i)}function z0(i){return i!=null&&typeof i=="object"&&"name"in i}function B0(i){return i!=null&&typeof i=="object"&&"video"in i}function P0(i){return i!=null&&typeof i=="object"&&"uri"in i}function Hh(i){var t;let l;if(z0(i)&&(l=i.name),!(P0(i)&&(l=i.uri,l===void 0))&&!(B0(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 u=l.split("files/")[1].match(/[a-z0-9]+/);if(u===null)throw new Error(`Could not extract file name from URI ${l}`);l=u[0]}else l.startsWith("files/")&&(l=l.split("files/")[1]);return l}}function qh(i,t){let l;return i.isVertexAI()?l=t?"publishers/google/models":"models":l=t?"models":"tunedModels",l}function Vh(i){for(const t of["models","tunedModels","publisherModels"])if(O0(i,t))return i[t];return[]}function O0(i,t){return i!==null&&typeof i=="object"&&t in i}function k0(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 F0(i,t={}){const l=[],a=new Set;for(const u of i){const f=u.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=k0(u,t);m.functionDeclarations&&l.push(...m.functionDeclarations)}return{functionDeclarations:l}}function zh(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,u=[l.inlinedRequests,l.fileName].filter(Boolean).length;if(i.isVertexAI()){if(u>0||a!==1)throw new Error("Exactly one of `gcsUri` or `bigqueryUri` must be set for Vertex AI.")}else if(a>0||u!==1)throw new Error("Exactly one of `inlinedRequests`, `fileName`, must be set for Gemini API.");return l}function J0(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 Bh(i){if(typeof i!="object"||i===null)return{};const t=i,l=t.inlinedResponses;if(typeof l!="object"||l===null)return i;const u=l.inlinedResponses;if(!Array.isArray(u)||u.length===0)return i;let f=!1;for(const m of u){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 to(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 Ph(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 Y0(i){const t={},l=r(i,["responsesFile"]);l!=null&&c(t,["fileName"],l);const a=r(i,["inlinedResponses","inlinedResponses"]);if(a!=null){let f=a;Array.isArray(f)&&(f=f.map(m=>MT(m))),c(t,["inlinedResponses"],f)}const u=r(i,["inlinedEmbedContentResponses","inlinedResponses"]);if(u!=null){let f=u;Array.isArray(f)&&(f=f.map(m=>m)),c(t,["inlinedEmbedContentResponses"],f)}return t}function X0(i){const t={},l=r(i,["predictionsFormat"]);l!=null&&c(t,["format"],l);const a=r(i,["gcsDestination","outputUriPrefix"]);a!=null&&c(t,["gcsUri"],a);const u=r(i,["bigqueryDestination","outputUri"]);return u!=null&&c(t,["bigqueryUri"],u),t}function K0(i){const t={},l=r(i,["format"]);l!=null&&c(t,["predictionsFormat"],l);const a=r(i,["gcsUri"]);a!=null&&c(t,["gcsDestination","outputUriPrefix"],a);const u=r(i,["bigqueryUri"]);if(u!=null&&c(t,["bigqueryDestination","outputUri"],u),r(i,["fileName"])!==void 0)throw new Error("fileName parameter is not supported in Vertex AI.");if(r(i,["inlinedResponses"])!==void 0)throw new Error("inlinedResponses parameter is not supported in Vertex AI.");if(r(i,["inlinedEmbedContentResponses"])!==void 0)throw new Error("inlinedEmbedContentResponses parameter is not supported in Vertex AI.");return t}function Ra(i){const t={},l=r(i,["name"]);l!=null&&c(t,["name"],l);const a=r(i,["metadata","displayName"]);a!=null&&c(t,["displayName"],a);const u=r(i,["metadata","state"]);u!=null&&c(t,["state"],Ph(u));const f=r(i,["metadata","createTime"]);f!=null&&c(t,["createTime"],f);const m=r(i,["metadata","endTime"]);m!=null&&c(t,["endTime"],m);const g=r(i,["metadata","updateTime"]);g!=null&&c(t,["updateTime"],g);const y=r(i,["metadata","model"]);y!=null&&c(t,["model"],y);const h=r(i,["metadata","output"]);return h!=null&&c(t,["dest"],Y0(Bh(h))),t}function gu(i){const t={},l=r(i,["name"]);l!=null&&c(t,["name"],l);const a=r(i,["displayName"]);a!=null&&c(t,["displayName"],a);const u=r(i,["state"]);u!=null&&c(t,["state"],Ph(u));const f=r(i,["error"]);f!=null&&c(t,["error"],f);const m=r(i,["createTime"]);m!=null&&c(t,["createTime"],m);const g=r(i,["startTime"]);g!=null&&c(t,["startTime"],g);const y=r(i,["endTime"]);y!=null&&c(t,["endTime"],y);const h=r(i,["updateTime"]);h!=null&&c(t,["updateTime"],h);const v=r(i,["model"]);v!=null&&c(t,["model"],v);const S=r(i,["inputConfig"]);S!=null&&c(t,["src"],Q0(S));const E=r(i,["outputConfig"]);E!=null&&c(t,["dest"],X0(Bh(E)));const C=r(i,["completionStats"]);return C!=null&&c(t,["completionStats"],C),t}function Q0(i){const t={},l=r(i,["instancesFormat"]);l!=null&&c(t,["format"],l);const a=r(i,["gcsSource","uris"]);a!=null&&c(t,["gcsUri"],a);const u=r(i,["bigquerySource","inputUri"]);return u!=null&&c(t,["bigqueryUri"],u),t}function Z0(i,t){const l={};if(r(t,["format"])!==void 0)throw new Error("format parameter is not supported in Gemini API.");if(r(t,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");if(r(t,["bigqueryUri"])!==void 0)throw new Error("bigqueryUri parameter is not supported in Gemini API.");const a=r(t,["fileName"]);a!=null&&c(l,["fileName"],a);const u=r(t,["inlinedRequests"]);if(u!=null){let f=u;Array.isArray(f)&&(f=f.map(m=>RT(i,m))),c(l,["requests","requests"],f)}return l}function $0(i){const t={},l=r(i,["format"]);l!=null&&c(t,["instancesFormat"],l);const a=r(i,["gcsUri"]);a!=null&&c(t,["gcsSource","uris"],a);const u=r(i,["bigqueryUri"]);if(u!=null&&c(t,["bigquerySource","inputUri"],u),r(i,["fileName"])!==void 0)throw new Error("fileName parameter is not supported in Vertex AI.");if(r(i,["inlinedRequests"])!==void 0)throw new Error("inlinedRequests parameter is not supported in Vertex AI.");return t}function W0(i){const t={},l=r(i,["data"]);if(l!=null&&c(t,["data"],l),r(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const a=r(i,["mimeType"]);return a!=null&&c(t,["mimeType"],a),t}function j0(i,t){const l={},a=r(t,["name"]);return a!=null&&c(l,["_url","name"],to(i,a)),l}function eT(i,t){const l={},a=r(t,["name"]);return a!=null&&c(l,["_url","name"],to(i,a)),l}function tT(i){const t={},l=r(i,["content"]);l!=null&&c(t,["content"],l);const a=r(i,["citationMetadata"]);a!=null&&c(t,["citationMetadata"],nT(a));const u=r(i,["tokenCount"]);u!=null&&c(t,["tokenCount"],u);const f=r(i,["finishReason"]);f!=null&&c(t,["finishReason"],f);const m=r(i,["avgLogprobs"]);m!=null&&c(t,["avgLogprobs"],m);const g=r(i,["groundingMetadata"]);g!=null&&c(t,["groundingMetadata"],g);const y=r(i,["index"]);y!=null&&c(t,["index"],y);const h=r(i,["logprobsResult"]);h!=null&&c(t,["logprobsResult"],h);const v=r(i,["safetyRatings"]);if(v!=null){let E=v;Array.isArray(E)&&(E=E.map(C=>C)),c(t,["safetyRatings"],E)}const S=r(i,["urlContextMetadata"]);return S!=null&&c(t,["urlContextMetadata"],S),t}function nT(i){const t={},l=r(i,["citationSources"]);if(l!=null){let a=l;Array.isArray(a)&&(a=a.map(u=>u)),c(t,["citations"],a)}return t}function Oh(i){const t={},l=r(i,["parts"]);if(l!=null){let u=l;Array.isArray(u)&&(u=u.map(f=>bT(f))),c(t,["parts"],u)}const a=r(i,["role"]);return a!=null&&c(t,["role"],a),t}function iT(i,t){const l={},a=r(i,["displayName"]);if(t!==void 0&&a!=null&&c(t,["batch","displayName"],a),r(i,["dest"])!==void 0)throw new Error("dest parameter is not supported in Gemini API.");return l}function oT(i,t){const l={},a=r(i,["displayName"]);t!==void 0&&a!=null&&c(t,["displayName"],a);const u=r(i,["dest"]);return t!==void 0&&u!=null&&c(t,["outputConfig"],K0(J0(u))),l}function lh(i,t){const l={},a=r(t,["model"]);a!=null&&c(l,["_url","model"],Ce(i,a));const u=r(t,["src"]);u!=null&&c(l,["batch","inputConfig"],Z0(i,zh(i,u)));const f=r(t,["config"]);return f!=null&&iT(f,l),l}function lT(i,t){const l={},a=r(t,["model"]);a!=null&&c(l,["model"],Ce(i,a));const u=r(t,["src"]);u!=null&&c(l,["inputConfig"],$0(zh(i,u)));const f=r(t,["config"]);return f!=null&&oT(f,l),l}function aT(i,t){const l={},a=r(i,["displayName"]);return t!==void 0&&a!=null&&c(t,["batch","displayName"],a),l}function sT(i,t){const l={},a=r(t,["model"]);a!=null&&c(l,["_url","model"],Ce(i,a));const u=r(t,["src"]);u!=null&&c(l,["batch","inputConfig"],mT(i,u));const f=r(t,["config"]);return f!=null&&aT(f,l),l}function rT(i,t){const l={},a=r(t,["name"]);return a!=null&&c(l,["_url","name"],to(i,a)),l}function uT(i,t){const l={},a=r(t,["name"]);return a!=null&&c(l,["_url","name"],to(i,a)),l}function cT(i){const t={},l=r(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=r(i,["name"]);a!=null&&c(t,["name"],a);const u=r(i,["done"]);u!=null&&c(t,["done"],u);const f=r(i,["error"]);return f!=null&&c(t,["error"],f),t}function fT(i){const t={},l=r(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=r(i,["name"]);a!=null&&c(t,["name"],a);const u=r(i,["done"]);u!=null&&c(t,["done"],u);const f=r(i,["error"]);return f!=null&&c(t,["error"],f),t}function dT(i,t){const l={},a=r(t,["contents"]);if(a!=null){let f=Uu(i,a);Array.isArray(f)&&(f=f.map(m=>m)),c(l,["requests[]","request","content"],f)}const u=r(t,["config"]);return u!=null&&(c(l,["_self"],pT(u,l)),u0(l,{"requests[].*":"requests[].request.*"})),l}function pT(i,t){const l={},a=r(i,["taskType"]);t!==void 0&&a!=null&&c(t,["requests[]","taskType"],a);const u=r(i,["title"]);t!==void 0&&u!=null&&c(t,["requests[]","title"],u);const f=r(i,["outputDimensionality"]);if(t!==void 0&&f!=null&&c(t,["requests[]","outputDimensionality"],f),r(i,["mimeType"])!==void 0)throw new Error("mimeType parameter is not supported in Gemini API.");if(r(i,["autoTruncate"])!==void 0)throw new Error("autoTruncate parameter is not supported in Gemini API.");return l}function mT(i,t){const l={},a=r(t,["fileName"]);a!=null&&c(l,["file_name"],a);const u=r(t,["inlinedRequests"]);return u!=null&&c(l,["requests"],dT(i,u)),l}function hT(i){const t={};if(r(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const l=r(i,["fileUri"]);l!=null&&c(t,["fileUri"],l);const a=r(i,["mimeType"]);return a!=null&&c(t,["mimeType"],a),t}function gT(i){const t={},l=r(i,["id"]);l!=null&&c(t,["id"],l);const a=r(i,["args"]);a!=null&&c(t,["args"],a);const u=r(i,["name"]);if(u!=null&&c(t,["name"],u),r(i,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(r(i,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return t}function yT(i){const t={},l=r(i,["allowedFunctionNames"]);l!=null&&c(t,["allowedFunctionNames"],l);const a=r(i,["mode"]);if(a!=null&&c(t,["mode"],a),r(i,["streamFunctionCallArguments"])!==void 0)throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return t}function vT(i,t,l){const a={},u=r(t,["systemInstruction"]);l!==void 0&&u!=null&&c(l,["systemInstruction"],Oh(it(u)));const f=r(t,["temperature"]);f!=null&&c(a,["temperature"],f);const m=r(t,["topP"]);m!=null&&c(a,["topP"],m);const g=r(t,["topK"]);g!=null&&c(a,["topK"],g);const y=r(t,["candidateCount"]);y!=null&&c(a,["candidateCount"],y);const h=r(t,["maxOutputTokens"]);h!=null&&c(a,["maxOutputTokens"],h);const v=r(t,["stopSequences"]);v!=null&&c(a,["stopSequences"],v);const S=r(t,["responseLogprobs"]);S!=null&&c(a,["responseLogprobs"],S);const E=r(t,["logprobs"]);E!=null&&c(a,["logprobs"],E);const C=r(t,["presencePenalty"]);C!=null&&c(a,["presencePenalty"],C);const w=r(t,["frequencyPenalty"]);w!=null&&c(a,["frequencyPenalty"],w);const G=r(t,["seed"]);G!=null&&c(a,["seed"],G);const x=r(t,["responseMimeType"]);x!=null&&c(a,["responseMimeType"],x);const B=r(t,["responseSchema"]);B!=null&&c(a,["responseSchema"],wu(B));const Y=r(t,["responseJsonSchema"]);if(Y!=null&&c(a,["responseJsonSchema"],Y),r(t,["routingConfig"])!==void 0)throw new Error("routingConfig parameter is not supported in Gemini API.");if(r(t,["modelSelectionConfig"])!==void 0)throw new Error("modelSelectionConfig parameter is not supported in Gemini API.");const P=r(t,["safetySettings"]);if(l!==void 0&&P!=null){let ue=P;Array.isArray(ue)&&(ue=ue.map(ve=>LT(ve))),c(l,["safetySettings"],ue)}const Q=r(t,["tools"]);if(l!==void 0&&Q!=null){let ue=eo(Q);Array.isArray(ue)&&(ue=ue.map(ve=>HT(ji(ve)))),c(l,["tools"],ue)}const j=r(t,["toolConfig"]);if(l!==void 0&&j!=null&&c(l,["toolConfig"],GT(j)),r(t,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const W=r(t,["cachedContent"]);l!==void 0&&W!=null&&c(l,["cachedContent"],hn(i,W));const F=r(t,["responseModalities"]);F!=null&&c(a,["responseModalities"],F);const ee=r(t,["mediaResolution"]);ee!=null&&c(a,["mediaResolution"],ee);const X=r(t,["speechConfig"]);if(X!=null&&c(a,["speechConfig"],xu(X)),r(t,["audioTimestamp"])!==void 0)throw new Error("audioTimestamp parameter is not supported in Gemini API.");const re=r(t,["thinkingConfig"]);re!=null&&c(a,["thinkingConfig"],re);const ye=r(t,["imageConfig"]);ye!=null&&c(a,["imageConfig"],AT(ye));const Ae=r(t,["enableEnhancedCivicAnswers"]);return Ae!=null&&c(a,["enableEnhancedCivicAnswers"],Ae),a}function TT(i){const t={},l=r(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=r(i,["candidates"]);if(a!=null){let y=a;Array.isArray(y)&&(y=y.map(h=>tT(h))),c(t,["candidates"],y)}const u=r(i,["modelVersion"]);u!=null&&c(t,["modelVersion"],u);const f=r(i,["promptFeedback"]);f!=null&&c(t,["promptFeedback"],f);const m=r(i,["responseId"]);m!=null&&c(t,["responseId"],m);const g=r(i,["usageMetadata"]);return g!=null&&c(t,["usageMetadata"],g),t}function ST(i,t){const l={},a=r(t,["name"]);return a!=null&&c(l,["_url","name"],to(i,a)),l}function ET(i,t){const l={},a=r(t,["name"]);return a!=null&&c(l,["_url","name"],to(i,a)),l}function _T(i){const t={};if(r(i,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const l=r(i,["enableWidget"]);return l!=null&&c(t,["enableWidget"],l),t}function CT(i){const t={};if(r(i,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(r(i,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const l=r(i,["timeRangeFilter"]);return l!=null&&c(t,["timeRangeFilter"],l),t}function AT(i){const t={},l=r(i,["aspectRatio"]);l!=null&&c(t,["aspectRatio"],l);const a=r(i,["imageSize"]);if(a!=null&&c(t,["imageSize"],a),r(i,["personGeneration"])!==void 0)throw new Error("personGeneration parameter is not supported in Gemini API.");if(r(i,["outputMimeType"])!==void 0)throw new Error("outputMimeType parameter is not supported in Gemini API.");if(r(i,["outputCompressionQuality"])!==void 0)throw new Error("outputCompressionQuality parameter is not supported in Gemini API.");return t}function RT(i,t){const l={},a=r(t,["model"]);a!=null&&c(l,["request","model"],Ce(i,a));const u=r(t,["contents"]);if(u!=null){let g=Ht(u);Array.isArray(g)&&(g=g.map(y=>Oh(y))),c(l,["request","contents"],g)}const f=r(t,["metadata"]);f!=null&&c(l,["metadata"],f);const m=r(t,["config"]);return m!=null&&c(l,["request","generationConfig"],vT(i,m,r(l,["request"],{}))),l}function MT(i){const t={},l=r(i,["response"]);l!=null&&c(t,["response"],TT(l));const a=r(i,["error"]);return a!=null&&c(t,["error"],a),t}function NT(i,t){const l={},a=r(i,["pageSize"]);t!==void 0&&a!=null&&c(t,["_query","pageSize"],a);const u=r(i,["pageToken"]);if(t!==void 0&&u!=null&&c(t,["_query","pageToken"],u),r(i,["filter"])!==void 0)throw new Error("filter parameter is not supported in Gemini API.");return l}function IT(i,t){const l={},a=r(i,["pageSize"]);t!==void 0&&a!=null&&c(t,["_query","pageSize"],a);const u=r(i,["pageToken"]);t!==void 0&&u!=null&&c(t,["_query","pageToken"],u);const f=r(i,["filter"]);return t!==void 0&&f!=null&&c(t,["_query","filter"],f),l}function DT(i){const t={},l=r(i,["config"]);return l!=null&&NT(l,t),t}function UT(i){const t={},l=r(i,["config"]);return l!=null&&IT(l,t),t}function wT(i){const t={},l=r(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=r(i,["nextPageToken"]);a!=null&&c(t,["nextPageToken"],a);const u=r(i,["operations"]);if(u!=null){let f=u;Array.isArray(f)&&(f=f.map(m=>Ra(m))),c(t,["batchJobs"],f)}return t}function xT(i){const t={},l=r(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=r(i,["nextPageToken"]);a!=null&&c(t,["nextPageToken"],a);const u=r(i,["batchPredictionJobs"]);if(u!=null){let f=u;Array.isArray(f)&&(f=f.map(m=>gu(m))),c(t,["batchJobs"],f)}return t}function bT(i){const t={},l=r(i,["mediaResolution"]);l!=null&&c(t,["mediaResolution"],l);const a=r(i,["codeExecutionResult"]);a!=null&&c(t,["codeExecutionResult"],a);const u=r(i,["executableCode"]);u!=null&&c(t,["executableCode"],u);const f=r(i,["fileData"]);f!=null&&c(t,["fileData"],hT(f));const m=r(i,["functionCall"]);m!=null&&c(t,["functionCall"],gT(m));const g=r(i,["functionResponse"]);g!=null&&c(t,["functionResponse"],g);const y=r(i,["inlineData"]);y!=null&&c(t,["inlineData"],W0(y));const h=r(i,["text"]);h!=null&&c(t,["text"],h);const v=r(i,["thought"]);v!=null&&c(t,["thought"],v);const S=r(i,["thoughtSignature"]);S!=null&&c(t,["thoughtSignature"],S);const E=r(i,["videoMetadata"]);return E!=null&&c(t,["videoMetadata"],E),t}function LT(i){const t={},l=r(i,["category"]);if(l!=null&&c(t,["category"],l),r(i,["method"])!==void 0)throw new Error("method parameter is not supported in Gemini API.");const a=r(i,["threshold"]);return a!=null&&c(t,["threshold"],a),t}function GT(i){const t={},l=r(i,["retrievalConfig"]);l!=null&&c(t,["retrievalConfig"],l);const a=r(i,["functionCallingConfig"]);return a!=null&&c(t,["functionCallingConfig"],yT(a)),t}function HT(i){const t={};if(r(i,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const l=r(i,["computerUse"]);l!=null&&c(t,["computerUse"],l);const a=r(i,["fileSearch"]);a!=null&&c(t,["fileSearch"],a);const u=r(i,["codeExecution"]);if(u!=null&&c(t,["codeExecution"],u),r(i,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const f=r(i,["functionDeclarations"]);if(f!=null){let v=f;Array.isArray(v)&&(v=v.map(S=>S)),c(t,["functionDeclarations"],v)}const m=r(i,["googleMaps"]);m!=null&&c(t,["googleMaps"],_T(m));const g=r(i,["googleSearch"]);g!=null&&c(t,["googleSearch"],CT(g));const y=r(i,["googleSearchRetrieval"]);y!=null&&c(t,["googleSearchRetrieval"],y);const h=r(i,["urlContext"]);return h!=null&&c(t,["urlContext"],h),t}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */var pn;(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"})(pn||(pn={}));class ui{constructor(t,l,a,u){this.pageInternal=[],this.paramsInternal={},this.requestInternal=l,this.init(t,a,u)}init(t,l,a){var u,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=(u=m.config)===null||u===void 0?void 0:u.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 qT extends mn{constructor(t){super(),this.apiClient=t,this.list=async(l={})=>new ui(pn.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=lh(this.apiClient,t),a=l._url,u=J("{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:u,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):{},u=Date.now().toString();if(a.displayName||(a.displayName=`genaiBatchJob_${u}`),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_${u}`;else if(m)a.dest=`${m}_dest_${u}`;else throw new Error("Unsupported source for Vertex AI: No GCS or BigQuery URI found.")}return a}async createInternal(t){var l,a,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=lT(this.apiClient,t);return g=J("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=>gu(v))}else{const h=lh(this.apiClient,t);return g=J("{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:(u=t.config)===null||u===void 0?void 0:u.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json()),m.then(v=>Ra(v))}}async createEmbeddingsInternal(t){var l,a;let u,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=sT(this.apiClient,t);return f=J("{model}:asyncBatchEmbedContent",g._url),m=g._query,delete g._url,delete g._query,u=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()),u.then(y=>Ra(y))}}async get(t){var l,a,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=ET(this.apiClient,t);return g=J("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=>gu(v))}else{const h=ST(this.apiClient,t);return g=J("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:(u=t.config)===null||u===void 0?void 0:u.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json()),m.then(v=>Ra(v))}}async cancel(t){var l,a,u,f;let m="",g={};if(this.apiClient.isVertexAI()){const y=eT(this.apiClient,t);m=J("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=j0(this.apiClient,t);m=J("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:(u=t.config)===null||u===void 0?void 0:u.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal})}}async listInternal(t){var l,a,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=UT(t);return g=J("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=xT(v),E=new th;return Object.assign(E,S),E})}else{const h=DT(t);return g=J("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:(u=t.config)===null||u===void 0?void 0:u.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=wT(v),E=new th;return Object.assign(E,S),E})}}async delete(t){var l,a,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=uT(this.apiClient,t);return g=J("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=rT(this.apiClient,t);return g=J("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:(u=t.config)===null||u===void 0?void 0:u.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=>cT(v))}}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function VT(i){const t={},l=r(i,["data"]);if(l!=null&&c(t,["data"],l),r(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const a=r(i,["mimeType"]);return a!=null&&c(t,["mimeType"],a),t}function ah(i){const t={},l=r(i,["parts"]);if(l!=null){let u=l;Array.isArray(u)&&(u=u.map(f=>sS(f))),c(t,["parts"],u)}const a=r(i,["role"]);return a!=null&&c(t,["role"],a),t}function zT(i,t){const l={},a=r(i,["ttl"]);t!==void 0&&a!=null&&c(t,["ttl"],a);const u=r(i,["expireTime"]);t!==void 0&&u!=null&&c(t,["expireTime"],u);const f=r(i,["displayName"]);t!==void 0&&f!=null&&c(t,["displayName"],f);const m=r(i,["contents"]);if(t!==void 0&&m!=null){let v=Ht(m);Array.isArray(v)&&(v=v.map(S=>ah(S))),c(t,["contents"],v)}const g=r(i,["systemInstruction"]);t!==void 0&&g!=null&&c(t,["systemInstruction"],ah(it(g)));const y=r(i,["tools"]);if(t!==void 0&&y!=null){let v=y;Array.isArray(v)&&(v=v.map(S=>uS(S))),c(t,["tools"],v)}const h=r(i,["toolConfig"]);if(t!==void 0&&h!=null&&c(t,["toolConfig"],rS(h)),r(i,["kmsKeyName"])!==void 0)throw new Error("kmsKeyName parameter is not supported in Gemini API.");return l}function BT(i,t){const l={},a=r(i,["ttl"]);t!==void 0&&a!=null&&c(t,["ttl"],a);const u=r(i,["expireTime"]);t!==void 0&&u!=null&&c(t,["expireTime"],u);const f=r(i,["displayName"]);t!==void 0&&f!=null&&c(t,["displayName"],f);const m=r(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=r(i,["systemInstruction"]);t!==void 0&&g!=null&&c(t,["systemInstruction"],it(g));const y=r(i,["tools"]);if(t!==void 0&&y!=null){let S=y;Array.isArray(S)&&(S=S.map(E=>cS(E))),c(t,["tools"],S)}const h=r(i,["toolConfig"]);t!==void 0&&h!=null&&c(t,["toolConfig"],h);const v=r(i,["kmsKeyName"]);return t!==void 0&&v!=null&&c(t,["encryption_spec","kmsKeyName"],v),l}function PT(i,t){const l={},a=r(t,["model"]);a!=null&&c(l,["model"],Uh(i,a));const u=r(t,["config"]);return u!=null&&zT(u,l),l}function OT(i,t){const l={},a=r(t,["model"]);a!=null&&c(l,["model"],Uh(i,a));const u=r(t,["config"]);return u!=null&&BT(u,l),l}function kT(i,t){const l={},a=r(t,["name"]);return a!=null&&c(l,["_url","name"],hn(i,a)),l}function FT(i,t){const l={},a=r(t,["name"]);return a!=null&&c(l,["_url","name"],hn(i,a)),l}function JT(i){const t={},l=r(i,["sdkHttpResponse"]);return l!=null&&c(t,["sdkHttpResponse"],l),t}function YT(i){const t={},l=r(i,["sdkHttpResponse"]);return l!=null&&c(t,["sdkHttpResponse"],l),t}function XT(i){const t={};if(r(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const l=r(i,["fileUri"]);l!=null&&c(t,["fileUri"],l);const a=r(i,["mimeType"]);return a!=null&&c(t,["mimeType"],a),t}function KT(i){const t={},l=r(i,["id"]);l!=null&&c(t,["id"],l);const a=r(i,["args"]);a!=null&&c(t,["args"],a);const u=r(i,["name"]);if(u!=null&&c(t,["name"],u),r(i,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(r(i,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return t}function QT(i){const t={},l=r(i,["allowedFunctionNames"]);l!=null&&c(t,["allowedFunctionNames"],l);const a=r(i,["mode"]);if(a!=null&&c(t,["mode"],a),r(i,["streamFunctionCallArguments"])!==void 0)throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return t}function ZT(i){const t={},l=r(i,["description"]);l!=null&&c(t,["description"],l);const a=r(i,["name"]);a!=null&&c(t,["name"],a);const u=r(i,["parameters"]);u!=null&&c(t,["parameters"],u);const f=r(i,["parametersJsonSchema"]);f!=null&&c(t,["parametersJsonSchema"],f);const m=r(i,["response"]);m!=null&&c(t,["response"],m);const g=r(i,["responseJsonSchema"]);if(g!=null&&c(t,["responseJsonSchema"],g),r(i,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");return t}function $T(i,t){const l={},a=r(t,["name"]);return a!=null&&c(l,["_url","name"],hn(i,a)),l}function WT(i,t){const l={},a=r(t,["name"]);return a!=null&&c(l,["_url","name"],hn(i,a)),l}function jT(i){const t={};if(r(i,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const l=r(i,["enableWidget"]);return l!=null&&c(t,["enableWidget"],l),t}function eS(i){const t={};if(r(i,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(r(i,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const l=r(i,["timeRangeFilter"]);return l!=null&&c(t,["timeRangeFilter"],l),t}function tS(i,t){const l={},a=r(i,["pageSize"]);t!==void 0&&a!=null&&c(t,["_query","pageSize"],a);const u=r(i,["pageToken"]);return t!==void 0&&u!=null&&c(t,["_query","pageToken"],u),l}function nS(i,t){const l={},a=r(i,["pageSize"]);t!==void 0&&a!=null&&c(t,["_query","pageSize"],a);const u=r(i,["pageToken"]);return t!==void 0&&u!=null&&c(t,["_query","pageToken"],u),l}function iS(i){const t={},l=r(i,["config"]);return l!=null&&tS(l,t),t}function oS(i){const t={},l=r(i,["config"]);return l!=null&&nS(l,t),t}function lS(i){const t={},l=r(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=r(i,["nextPageToken"]);a!=null&&c(t,["nextPageToken"],a);const u=r(i,["cachedContents"]);if(u!=null){let f=u;Array.isArray(f)&&(f=f.map(m=>m)),c(t,["cachedContents"],f)}return t}function aS(i){const t={},l=r(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=r(i,["nextPageToken"]);a!=null&&c(t,["nextPageToken"],a);const u=r(i,["cachedContents"]);if(u!=null){let f=u;Array.isArray(f)&&(f=f.map(m=>m)),c(t,["cachedContents"],f)}return t}function sS(i){const t={},l=r(i,["mediaResolution"]);l!=null&&c(t,["mediaResolution"],l);const a=r(i,["codeExecutionResult"]);a!=null&&c(t,["codeExecutionResult"],a);const u=r(i,["executableCode"]);u!=null&&c(t,["executableCode"],u);const f=r(i,["fileData"]);f!=null&&c(t,["fileData"],XT(f));const m=r(i,["functionCall"]);m!=null&&c(t,["functionCall"],KT(m));const g=r(i,["functionResponse"]);g!=null&&c(t,["functionResponse"],g);const y=r(i,["inlineData"]);y!=null&&c(t,["inlineData"],VT(y));const h=r(i,["text"]);h!=null&&c(t,["text"],h);const v=r(i,["thought"]);v!=null&&c(t,["thought"],v);const S=r(i,["thoughtSignature"]);S!=null&&c(t,["thoughtSignature"],S);const E=r(i,["videoMetadata"]);return E!=null&&c(t,["videoMetadata"],E),t}function rS(i){const t={},l=r(i,["retrievalConfig"]);l!=null&&c(t,["retrievalConfig"],l);const a=r(i,["functionCallingConfig"]);return a!=null&&c(t,["functionCallingConfig"],QT(a)),t}function uS(i){const t={};if(r(i,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const l=r(i,["computerUse"]);l!=null&&c(t,["computerUse"],l);const a=r(i,["fileSearch"]);a!=null&&c(t,["fileSearch"],a);const u=r(i,["codeExecution"]);if(u!=null&&c(t,["codeExecution"],u),r(i,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const f=r(i,["functionDeclarations"]);if(f!=null){let v=f;Array.isArray(v)&&(v=v.map(S=>S)),c(t,["functionDeclarations"],v)}const m=r(i,["googleMaps"]);m!=null&&c(t,["googleMaps"],jT(m));const g=r(i,["googleSearch"]);g!=null&&c(t,["googleSearch"],eS(g));const y=r(i,["googleSearchRetrieval"]);y!=null&&c(t,["googleSearchRetrieval"],y);const h=r(i,["urlContext"]);return h!=null&&c(t,["urlContext"],h),t}function cS(i){const t={},l=r(i,["retrieval"]);l!=null&&c(t,["retrieval"],l);const a=r(i,["computerUse"]);if(a!=null&&c(t,["computerUse"],a),r(i,["fileSearch"])!==void 0)throw new Error("fileSearch parameter is not supported in Vertex AI.");const u=r(i,["codeExecution"]);u!=null&&c(t,["codeExecution"],u);const f=r(i,["enterpriseWebSearch"]);f!=null&&c(t,["enterpriseWebSearch"],f);const m=r(i,["functionDeclarations"]);if(m!=null){let S=m;Array.isArray(S)&&(S=S.map(E=>ZT(E))),c(t,["functionDeclarations"],S)}const g=r(i,["googleMaps"]);g!=null&&c(t,["googleMaps"],g);const y=r(i,["googleSearch"]);y!=null&&c(t,["googleSearch"],y);const h=r(i,["googleSearchRetrieval"]);h!=null&&c(t,["googleSearchRetrieval"],h);const v=r(i,["urlContext"]);return v!=null&&c(t,["urlContext"],v),t}function fS(i,t){const l={},a=r(i,["ttl"]);t!==void 0&&a!=null&&c(t,["ttl"],a);const u=r(i,["expireTime"]);return t!==void 0&&u!=null&&c(t,["expireTime"],u),l}function dS(i,t){const l={},a=r(i,["ttl"]);t!==void 0&&a!=null&&c(t,["ttl"],a);const u=r(i,["expireTime"]);return t!==void 0&&u!=null&&c(t,["expireTime"],u),l}function pS(i,t){const l={},a=r(t,["name"]);a!=null&&c(l,["_url","name"],hn(i,a));const u=r(t,["config"]);return u!=null&&fS(u,l),l}function mS(i,t){const l={},a=r(t,["name"]);a!=null&&c(l,["_url","name"],hn(i,a));const u=r(t,["config"]);return u!=null&&dS(u,l),l}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class hS extends mn{constructor(t){super(),this.apiClient=t,this.list=async(l={})=>new ui(pn.PAGED_ITEM_CACHED_CONTENTS,a=>this.listInternal(a),await this.listInternal(l),l)}async create(t){var l,a,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=OT(this.apiClient,t);return g=J("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=PT(this.apiClient,t);return g=J("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:(u=t.config)===null||u===void 0?void 0:u.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,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=WT(this.apiClient,t);return g=J("{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=$T(this.apiClient,t);return g=J("{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:(u=t.config)===null||u===void 0?void 0:u.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,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=FT(this.apiClient,t);return g=J("{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=YT(v),E=new jm;return Object.assign(E,S),E})}else{const h=kT(this.apiClient,t);return g=J("{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:(u=t.config)===null||u===void 0?void 0:u.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=JT(v),E=new jm;return Object.assign(E,S),E})}}async update(t){var l,a,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=mS(this.apiClient,t);return g=J("{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=pS(this.apiClient,t);return g=J("{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:(u=t.config)===null||u===void 0?void 0:u.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,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=oS(t);return g=J("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=aS(v),E=new eh;return Object.assign(E,S),E})}else{const h=iS(t);return g=J("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:(u=t.config)===null||u===void 0?void 0:u.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=lS(v),E=new eh;return Object.assign(E,S),E})}}}function Da(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 u=0,a=Object.getOwnPropertySymbols(i);u=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 le(i){return this instanceof le?(this.v=i,this):new le(i)}function Pt(i,t,l){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var a=l.apply(i,t||[]),u,f=[];return u=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),g("next"),g("throw"),g("return",m),u[Symbol.asyncIterator]=function(){return this},u;function m(C){return function(w){return Promise.resolve(w).then(C,S)}}function g(C,w){a[C]&&(u[C]=function(G){return new Promise(function(x,B){f.push([C,G,x,B])>1||y(C,G)})},w&&(u[C]=w(u[C])))}function y(C,w){try{h(a[C](w))}catch(G){E(f[0][3],G)}}function h(C){C.value instanceof le?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,w){C(w),f.shift(),f.length&&y(f[0][0],f[0][1])}}function Ot(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 sh=="function"?sh(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),u(g,y,m.done,m.value)})}}function u(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 gS(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:kh(l)}function kh(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 yS(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 rh(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 u,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()}),u}async sendMessageStream(t){var l;await this.sendPromise;const a=it(t.message),u=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=u.then(()=>{}).catch(()=>{});const f=await u;return this.processStreamResponse(f,a)}getHistory(t=!1){const l=t?rh(this.history):this.history;return structuredClone(l)}processStreamResponse(t,l){return Pt(this,arguments,function*(){var u,f,m,g,y,h;const v=[];try{for(var S=!0,E=Ot(t),C;C=yield le(E.next()),u=C.done,!u;S=!0){g=C.value,S=!1;const w=g;if(gS(w)){const G=(h=(y=w.candidates)===null||y===void 0?void 0:y[0])===null||h===void 0?void 0:h.content;G!==void 0&&v.push(G)}yield yield le(w)}}catch(w){f={error:w}}finally{try{!S&&!u&&(m=E.return)&&(yield le(m.call(E)))}finally{if(f)throw f.error}}this.recordHistory(l,v)})}recordHistory(t,l,a){let u=[];l.length>0&&l.every(f=>f.role!==void 0)?u=l:u.push({role:"model",parts:[]}),a&&a.length>0?this.history.push(...rh(a)):this.history.push(t),this.history.push(...u)}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class xa extends Error{constructor(t){super(t.message),this.name="ApiError",this.status=t.status,Object.setPrototypeOf(this,xa.prototype)}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function SS(i){const t={},l=r(i,["file"]);return l!=null&&c(t,["file"],l),t}function ES(i){const t={},l=r(i,["sdkHttpResponse"]);return l!=null&&c(t,["sdkHttpResponse"],l),t}function _S(i){const t={},l=r(i,["name"]);return l!=null&&c(t,["_url","file"],Hh(l)),t}function CS(i){const t={},l=r(i,["sdkHttpResponse"]);return l!=null&&c(t,["sdkHttpResponse"],l),t}function AS(i){const t={},l=r(i,["name"]);return l!=null&&c(t,["_url","file"],Hh(l)),t}function RS(i,t){const l={},a=r(i,["pageSize"]);t!==void 0&&a!=null&&c(t,["_query","pageSize"],a);const u=r(i,["pageToken"]);return t!==void 0&&u!=null&&c(t,["_query","pageToken"],u),l}function MS(i){const t={},l=r(i,["config"]);return l!=null&&RS(l,t),t}function NS(i){const t={},l=r(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=r(i,["nextPageToken"]);a!=null&&c(t,["nextPageToken"],a);const u=r(i,["files"]);if(u!=null){let f=u;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 IS extends mn{constructor(t){super(),this.apiClient=t,this.list=async(l={})=>new ui(pn.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 u,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=MS(t);return f=J("files",g._url),m=g._query,delete g._url,delete g._query,u=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})),u.then(y=>{const h=NS(y),v=new x0;return Object.assign(v,h),v})}}async createInternal(t){var l,a;let u,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=SS(t);return f=J("upload/v1beta/files",g._url),m=g._query,delete g._url,delete g._query,u=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()),u.then(y=>{const h=ES(y),v=new b0;return Object.assign(v,h),v})}}async get(t){var l,a;let u,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=AS(t);return f=J("files/{file}",g._url),m=g._query,delete g._url,delete g._query,u=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()),u.then(y=>y)}}async delete(t){var l,a;let u,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=_S(t);return f=J("files/{file}",g._url),m=g._query,delete g._url,delete g._query,u=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})),u.then(y=>{const h=CS(y),v=new L0;return Object.assign(v,h),v})}}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function Ma(i){const t={},l=r(i,["data"]);if(l!=null&&c(t,["data"],l),r(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const a=r(i,["mimeType"]);return a!=null&&c(t,["mimeType"],a),t}function DS(i){const t={},l=r(i,["parts"]);if(l!=null){let u=l;Array.isArray(u)&&(u=u.map(f=>JS(f))),c(t,["parts"],u)}const a=r(i,["role"]);return a!=null&&c(t,["role"],a),t}function US(i){const t={};if(r(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const l=r(i,["fileUri"]);l!=null&&c(t,["fileUri"],l);const a=r(i,["mimeType"]);return a!=null&&c(t,["mimeType"],a),t}function wS(i){const t={},l=r(i,["id"]);l!=null&&c(t,["id"],l);const a=r(i,["args"]);a!=null&&c(t,["args"],a);const u=r(i,["name"]);if(u!=null&&c(t,["name"],u),r(i,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(r(i,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return t}function xS(i){const t={},l=r(i,["description"]);l!=null&&c(t,["description"],l);const a=r(i,["name"]);a!=null&&c(t,["name"],a);const u=r(i,["parameters"]);u!=null&&c(t,["parameters"],u);const f=r(i,["parametersJsonSchema"]);f!=null&&c(t,["parametersJsonSchema"],f);const m=r(i,["response"]);m!=null&&c(t,["response"],m);const g=r(i,["responseJsonSchema"]);if(g!=null&&c(t,["responseJsonSchema"],g),r(i,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");return t}function bS(i){const t={},l=r(i,["modelSelectionConfig"]);l!=null&&c(t,["modelConfig"],l);const a=r(i,["responseJsonSchema"]);a!=null&&c(t,["responseJsonSchema"],a);const u=r(i,["audioTimestamp"]);u!=null&&c(t,["audioTimestamp"],u);const f=r(i,["candidateCount"]);f!=null&&c(t,["candidateCount"],f);const m=r(i,["enableAffectiveDialog"]);m!=null&&c(t,["enableAffectiveDialog"],m);const g=r(i,["frequencyPenalty"]);g!=null&&c(t,["frequencyPenalty"],g);const y=r(i,["logprobs"]);y!=null&&c(t,["logprobs"],y);const h=r(i,["maxOutputTokens"]);h!=null&&c(t,["maxOutputTokens"],h);const v=r(i,["mediaResolution"]);v!=null&&c(t,["mediaResolution"],v);const S=r(i,["presencePenalty"]);S!=null&&c(t,["presencePenalty"],S);const E=r(i,["responseLogprobs"]);E!=null&&c(t,["responseLogprobs"],E);const C=r(i,["responseMimeType"]);C!=null&&c(t,["responseMimeType"],C);const w=r(i,["responseModalities"]);w!=null&&c(t,["responseModalities"],w);const G=r(i,["responseSchema"]);G!=null&&c(t,["responseSchema"],G);const x=r(i,["routingConfig"]);x!=null&&c(t,["routingConfig"],x);const B=r(i,["seed"]);B!=null&&c(t,["seed"],B);const Y=r(i,["speechConfig"]);Y!=null&&c(t,["speechConfig"],Y);const P=r(i,["stopSequences"]);P!=null&&c(t,["stopSequences"],P);const Q=r(i,["temperature"]);Q!=null&&c(t,["temperature"],Q);const j=r(i,["thinkingConfig"]);j!=null&&c(t,["thinkingConfig"],j);const W=r(i,["topK"]);W!=null&&c(t,["topK"],W);const F=r(i,["topP"]);if(F!=null&&c(t,["topP"],F),r(i,["enableEnhancedCivicAnswers"])!==void 0)throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");return t}function LS(i){const t={};if(r(i,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const l=r(i,["enableWidget"]);return l!=null&&c(t,["enableWidget"],l),t}function GS(i){const t={};if(r(i,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(r(i,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const l=r(i,["timeRangeFilter"]);return l!=null&&c(t,["timeRangeFilter"],l),t}function HS(i,t){const l={},a=r(i,["generationConfig"]);t!==void 0&&a!=null&&c(t,["setup","generationConfig"],a);const u=r(i,["responseModalities"]);t!==void 0&&u!=null&&c(t,["setup","generationConfig","responseModalities"],u);const f=r(i,["temperature"]);t!==void 0&&f!=null&&c(t,["setup","generationConfig","temperature"],f);const m=r(i,["topP"]);t!==void 0&&m!=null&&c(t,["setup","generationConfig","topP"],m);const g=r(i,["topK"]);t!==void 0&&g!=null&&c(t,["setup","generationConfig","topK"],g);const y=r(i,["maxOutputTokens"]);t!==void 0&&y!=null&&c(t,["setup","generationConfig","maxOutputTokens"],y);const h=r(i,["mediaResolution"]);t!==void 0&&h!=null&&c(t,["setup","generationConfig","mediaResolution"],h);const v=r(i,["seed"]);t!==void 0&&v!=null&&c(t,["setup","generationConfig","seed"],v);const S=r(i,["speechConfig"]);t!==void 0&&S!=null&&c(t,["setup","generationConfig","speechConfig"],bu(S));const E=r(i,["thinkingConfig"]);t!==void 0&&E!=null&&c(t,["setup","generationConfig","thinkingConfig"],E);const C=r(i,["enableAffectiveDialog"]);t!==void 0&&C!=null&&c(t,["setup","generationConfig","enableAffectiveDialog"],C);const w=r(i,["systemInstruction"]);t!==void 0&&w!=null&&c(t,["setup","systemInstruction"],DS(it(w)));const G=r(i,["tools"]);if(t!==void 0&&G!=null){let W=eo(G);Array.isArray(W)&&(W=W.map(F=>XS(ji(F)))),c(t,["setup","tools"],W)}const x=r(i,["sessionResumption"]);t!==void 0&&x!=null&&c(t,["setup","sessionResumption"],YS(x));const B=r(i,["inputAudioTranscription"]);t!==void 0&&B!=null&&c(t,["setup","inputAudioTranscription"],B);const Y=r(i,["outputAudioTranscription"]);t!==void 0&&Y!=null&&c(t,["setup","outputAudioTranscription"],Y);const P=r(i,["realtimeInputConfig"]);t!==void 0&&P!=null&&c(t,["setup","realtimeInputConfig"],P);const Q=r(i,["contextWindowCompression"]);t!==void 0&&Q!=null&&c(t,["setup","contextWindowCompression"],Q);const j=r(i,["proactivity"]);if(t!==void 0&&j!=null&&c(t,["setup","proactivity"],j),r(i,["explicitVadSignal"])!==void 0)throw new Error("explicitVadSignal parameter is not supported in Gemini API.");return l}function qS(i,t){const l={},a=r(i,["generationConfig"]);t!==void 0&&a!=null&&c(t,["setup","generationConfig"],bS(a));const u=r(i,["responseModalities"]);t!==void 0&&u!=null&&c(t,["setup","generationConfig","responseModalities"],u);const f=r(i,["temperature"]);t!==void 0&&f!=null&&c(t,["setup","generationConfig","temperature"],f);const m=r(i,["topP"]);t!==void 0&&m!=null&&c(t,["setup","generationConfig","topP"],m);const g=r(i,["topK"]);t!==void 0&&g!=null&&c(t,["setup","generationConfig","topK"],g);const y=r(i,["maxOutputTokens"]);t!==void 0&&y!=null&&c(t,["setup","generationConfig","maxOutputTokens"],y);const h=r(i,["mediaResolution"]);t!==void 0&&h!=null&&c(t,["setup","generationConfig","mediaResolution"],h);const v=r(i,["seed"]);t!==void 0&&v!=null&&c(t,["setup","generationConfig","seed"],v);const S=r(i,["speechConfig"]);t!==void 0&&S!=null&&c(t,["setup","generationConfig","speechConfig"],bu(S));const E=r(i,["thinkingConfig"]);t!==void 0&&E!=null&&c(t,["setup","generationConfig","thinkingConfig"],E);const C=r(i,["enableAffectiveDialog"]);t!==void 0&&C!=null&&c(t,["setup","generationConfig","enableAffectiveDialog"],C);const w=r(i,["systemInstruction"]);t!==void 0&&w!=null&&c(t,["setup","systemInstruction"],it(w));const G=r(i,["tools"]);if(t!==void 0&&G!=null){let F=eo(G);Array.isArray(F)&&(F=F.map(ee=>KS(ji(ee)))),c(t,["setup","tools"],F)}const x=r(i,["sessionResumption"]);t!==void 0&&x!=null&&c(t,["setup","sessionResumption"],x);const B=r(i,["inputAudioTranscription"]);t!==void 0&&B!=null&&c(t,["setup","inputAudioTranscription"],B);const Y=r(i,["outputAudioTranscription"]);t!==void 0&&Y!=null&&c(t,["setup","outputAudioTranscription"],Y);const P=r(i,["realtimeInputConfig"]);t!==void 0&&P!=null&&c(t,["setup","realtimeInputConfig"],P);const Q=r(i,["contextWindowCompression"]);t!==void 0&&Q!=null&&c(t,["setup","contextWindowCompression"],Q);const j=r(i,["proactivity"]);t!==void 0&&j!=null&&c(t,["setup","proactivity"],j);const W=r(i,["explicitVadSignal"]);return t!==void 0&&W!=null&&c(t,["setup","explicitVadSignal"],W),l}function VS(i,t){const l={},a=r(t,["model"]);a!=null&&c(l,["setup","model"],Ce(i,a));const u=r(t,["config"]);return u!=null&&c(l,["config"],HS(u,l)),l}function zS(i,t){const l={},a=r(t,["model"]);a!=null&&c(l,["setup","model"],Ce(i,a));const u=r(t,["config"]);return u!=null&&c(l,["config"],qS(u,l)),l}function BS(i){const t={},l=r(i,["musicGenerationConfig"]);return l!=null&&c(t,["musicGenerationConfig"],l),t}function PS(i){const t={},l=r(i,["weightedPrompts"]);if(l!=null){let a=l;Array.isArray(a)&&(a=a.map(u=>u)),c(t,["weightedPrompts"],a)}return t}function OS(i){const t={},l=r(i,["media"]);if(l!=null){let h=wh(l);Array.isArray(h)&&(h=h.map(v=>Ma(v))),c(t,["mediaChunks"],h)}const a=r(i,["audio"]);a!=null&&c(t,["audio"],Ma(bh(a)));const u=r(i,["audioStreamEnd"]);u!=null&&c(t,["audioStreamEnd"],u);const f=r(i,["video"]);f!=null&&c(t,["video"],Ma(xh(f)));const m=r(i,["text"]);m!=null&&c(t,["text"],m);const g=r(i,["activityStart"]);g!=null&&c(t,["activityStart"],g);const y=r(i,["activityEnd"]);return y!=null&&c(t,["activityEnd"],y),t}function kS(i){const t={},l=r(i,["media"]);if(l!=null){let h=wh(l);Array.isArray(h)&&(h=h.map(v=>v)),c(t,["mediaChunks"],h)}const a=r(i,["audio"]);a!=null&&c(t,["audio"],bh(a));const u=r(i,["audioStreamEnd"]);u!=null&&c(t,["audioStreamEnd"],u);const f=r(i,["video"]);f!=null&&c(t,["video"],xh(f));const m=r(i,["text"]);m!=null&&c(t,["text"],m);const g=r(i,["activityStart"]);g!=null&&c(t,["activityStart"],g);const y=r(i,["activityEnd"]);return y!=null&&c(t,["activityEnd"],y),t}function FS(i){const t={},l=r(i,["setupComplete"]);l!=null&&c(t,["setupComplete"],l);const a=r(i,["serverContent"]);a!=null&&c(t,["serverContent"],a);const u=r(i,["toolCall"]);u!=null&&c(t,["toolCall"],u);const f=r(i,["toolCallCancellation"]);f!=null&&c(t,["toolCallCancellation"],f);const m=r(i,["usageMetadata"]);m!=null&&c(t,["usageMetadata"],QS(m));const g=r(i,["goAway"]);g!=null&&c(t,["goAway"],g);const y=r(i,["sessionResumptionUpdate"]);y!=null&&c(t,["sessionResumptionUpdate"],y);const h=r(i,["voiceActivityDetectionSignal"]);return h!=null&&c(t,["voiceActivityDetectionSignal"],h),t}function JS(i){const t={},l=r(i,["mediaResolution"]);l!=null&&c(t,["mediaResolution"],l);const a=r(i,["codeExecutionResult"]);a!=null&&c(t,["codeExecutionResult"],a);const u=r(i,["executableCode"]);u!=null&&c(t,["executableCode"],u);const f=r(i,["fileData"]);f!=null&&c(t,["fileData"],US(f));const m=r(i,["functionCall"]);m!=null&&c(t,["functionCall"],wS(m));const g=r(i,["functionResponse"]);g!=null&&c(t,["functionResponse"],g);const y=r(i,["inlineData"]);y!=null&&c(t,["inlineData"],Ma(y));const h=r(i,["text"]);h!=null&&c(t,["text"],h);const v=r(i,["thought"]);v!=null&&c(t,["thought"],v);const S=r(i,["thoughtSignature"]);S!=null&&c(t,["thoughtSignature"],S);const E=r(i,["videoMetadata"]);return E!=null&&c(t,["videoMetadata"],E),t}function YS(i){const t={},l=r(i,["handle"]);if(l!=null&&c(t,["handle"],l),r(i,["transparent"])!==void 0)throw new Error("transparent parameter is not supported in Gemini API.");return t}function XS(i){const t={};if(r(i,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const l=r(i,["computerUse"]);l!=null&&c(t,["computerUse"],l);const a=r(i,["fileSearch"]);a!=null&&c(t,["fileSearch"],a);const u=r(i,["codeExecution"]);if(u!=null&&c(t,["codeExecution"],u),r(i,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const f=r(i,["functionDeclarations"]);if(f!=null){let v=f;Array.isArray(v)&&(v=v.map(S=>S)),c(t,["functionDeclarations"],v)}const m=r(i,["googleMaps"]);m!=null&&c(t,["googleMaps"],LS(m));const g=r(i,["googleSearch"]);g!=null&&c(t,["googleSearch"],GS(g));const y=r(i,["googleSearchRetrieval"]);y!=null&&c(t,["googleSearchRetrieval"],y);const h=r(i,["urlContext"]);return h!=null&&c(t,["urlContext"],h),t}function KS(i){const t={},l=r(i,["retrieval"]);l!=null&&c(t,["retrieval"],l);const a=r(i,["computerUse"]);if(a!=null&&c(t,["computerUse"],a),r(i,["fileSearch"])!==void 0)throw new Error("fileSearch parameter is not supported in Vertex AI.");const u=r(i,["codeExecution"]);u!=null&&c(t,["codeExecution"],u);const f=r(i,["enterpriseWebSearch"]);f!=null&&c(t,["enterpriseWebSearch"],f);const m=r(i,["functionDeclarations"]);if(m!=null){let S=m;Array.isArray(S)&&(S=S.map(E=>xS(E))),c(t,["functionDeclarations"],S)}const g=r(i,["googleMaps"]);g!=null&&c(t,["googleMaps"],g);const y=r(i,["googleSearch"]);y!=null&&c(t,["googleSearch"],y);const h=r(i,["googleSearchRetrieval"]);h!=null&&c(t,["googleSearchRetrieval"],h);const v=r(i,["urlContext"]);return v!=null&&c(t,["urlContext"],v),t}function QS(i){const t={},l=r(i,["promptTokenCount"]);l!=null&&c(t,["promptTokenCount"],l);const a=r(i,["cachedContentTokenCount"]);a!=null&&c(t,["cachedContentTokenCount"],a);const u=r(i,["candidatesTokenCount"]);u!=null&&c(t,["responseTokenCount"],u);const f=r(i,["toolUsePromptTokenCount"]);f!=null&&c(t,["toolUsePromptTokenCount"],f);const m=r(i,["thoughtsTokenCount"]);m!=null&&c(t,["thoughtsTokenCount"],m);const g=r(i,["totalTokenCount"]);g!=null&&c(t,["totalTokenCount"],g);const y=r(i,["promptTokensDetails"]);if(y!=null){let C=y;Array.isArray(C)&&(C=C.map(w=>w)),c(t,["promptTokensDetails"],C)}const h=r(i,["cacheTokensDetails"]);if(h!=null){let C=h;Array.isArray(C)&&(C=C.map(w=>w)),c(t,["cacheTokensDetails"],C)}const v=r(i,["candidatesTokensDetails"]);if(v!=null){let C=v;Array.isArray(C)&&(C=C.map(w=>w)),c(t,["responseTokensDetails"],C)}const S=r(i,["toolUsePromptTokensDetails"]);if(S!=null){let C=S;Array.isArray(C)&&(C=C.map(w=>w)),c(t,["toolUsePromptTokensDetails"],C)}const E=r(i,["trafficType"]);return E!=null&&c(t,["trafficType"],E),t}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function ZS(i){const t={},l=r(i,["data"]);if(l!=null&&c(t,["data"],l),r(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const a=r(i,["mimeType"]);return a!=null&&c(t,["mimeType"],a),t}function $S(i){const t={},l=r(i,["content"]);l!=null&&c(t,["content"],l);const a=r(i,["citationMetadata"]);a!=null&&c(t,["citationMetadata"],WS(a));const u=r(i,["tokenCount"]);u!=null&&c(t,["tokenCount"],u);const f=r(i,["finishReason"]);f!=null&&c(t,["finishReason"],f);const m=r(i,["avgLogprobs"]);m!=null&&c(t,["avgLogprobs"],m);const g=r(i,["groundingMetadata"]);g!=null&&c(t,["groundingMetadata"],g);const y=r(i,["index"]);y!=null&&c(t,["index"],y);const h=r(i,["logprobsResult"]);h!=null&&c(t,["logprobsResult"],h);const v=r(i,["safetyRatings"]);if(v!=null){let E=v;Array.isArray(E)&&(E=E.map(C=>C)),c(t,["safetyRatings"],E)}const S=r(i,["urlContextMetadata"]);return S!=null&&c(t,["urlContextMetadata"],S),t}function WS(i){const t={},l=r(i,["citationSources"]);if(l!=null){let a=l;Array.isArray(a)&&(a=a.map(u=>u)),c(t,["citations"],a)}return t}function jS(i,t){const l={},a=r(t,["model"]);a!=null&&c(l,["_url","model"],Ce(i,a));const u=r(t,["contents"]);if(u!=null){let f=Ht(u);Array.isArray(f)&&(f=f.map(m=>m)),c(l,["contents"],f)}return l}function eE(i){const t={},l=r(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=r(i,["tokensInfo"]);if(a!=null){let u=a;Array.isArray(u)&&(u=u.map(f=>f)),c(t,["tokensInfo"],u)}return t}function tE(i){const t={},l=r(i,["values"]);l!=null&&c(t,["values"],l);const a=r(i,["statistics"]);return a!=null&&c(t,["statistics"],nE(a)),t}function nE(i){const t={},l=r(i,["truncated"]);l!=null&&c(t,["truncated"],l);const a=r(i,["token_count"]);return a!=null&&c(t,["tokenCount"],a),t}function ba(i){const t={},l=r(i,["parts"]);if(l!=null){let u=l;Array.isArray(u)&&(u=u.map(f=>f_(f))),c(t,["parts"],u)}const a=r(i,["role"]);return a!=null&&c(t,["role"],a),t}function iE(i){const t={},l=r(i,["controlType"]);l!=null&&c(t,["controlType"],l);const a=r(i,["enableControlImageComputation"]);return a!=null&&c(t,["computeControl"],a),t}function oE(i){const t={};if(r(i,["systemInstruction"])!==void 0)throw new Error("systemInstruction parameter is not supported in Gemini API.");if(r(i,["tools"])!==void 0)throw new Error("tools parameter is not supported in Gemini API.");if(r(i,["generationConfig"])!==void 0)throw new Error("generationConfig parameter is not supported in Gemini API.");return t}function lE(i,t){const l={},a=r(i,["systemInstruction"]);t!==void 0&&a!=null&&c(t,["systemInstruction"],it(a));const u=r(i,["tools"]);if(t!==void 0&&u!=null){let m=u;Array.isArray(m)&&(m=m.map(g=>Xh(g))),c(t,["tools"],m)}const f=r(i,["generationConfig"]);return t!==void 0&&f!=null&&c(t,["generationConfig"],ZE(f)),l}function aE(i,t){const l={},a=r(t,["model"]);a!=null&&c(l,["_url","model"],Ce(i,a));const u=r(t,["contents"]);if(u!=null){let m=Ht(u);Array.isArray(m)&&(m=m.map(g=>ba(g))),c(l,["contents"],m)}const f=r(t,["config"]);return f!=null&&oE(f),l}function sE(i,t){const l={},a=r(t,["model"]);a!=null&&c(l,["_url","model"],Ce(i,a));const u=r(t,["contents"]);if(u!=null){let m=Ht(u);Array.isArray(m)&&(m=m.map(g=>g)),c(l,["contents"],m)}const f=r(t,["config"]);return f!=null&&lE(f,l),l}function rE(i){const t={},l=r(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=r(i,["totalTokens"]);a!=null&&c(t,["totalTokens"],a);const u=r(i,["cachedContentTokenCount"]);return u!=null&&c(t,["cachedContentTokenCount"],u),t}function uE(i){const t={},l=r(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=r(i,["totalTokens"]);return a!=null&&c(t,["totalTokens"],a),t}function cE(i,t){const l={},a=r(t,["model"]);return a!=null&&c(l,["_url","name"],Ce(i,a)),l}function fE(i,t){const l={},a=r(t,["model"]);return a!=null&&c(l,["_url","name"],Ce(i,a)),l}function dE(i){const t={},l=r(i,["sdkHttpResponse"]);return l!=null&&c(t,["sdkHttpResponse"],l),t}function pE(i){const t={},l=r(i,["sdkHttpResponse"]);return l!=null&&c(t,["sdkHttpResponse"],l),t}function mE(i,t){const l={},a=r(i,["outputGcsUri"]);t!==void 0&&a!=null&&c(t,["parameters","storageUri"],a);const u=r(i,["negativePrompt"]);t!==void 0&&u!=null&&c(t,["parameters","negativePrompt"],u);const f=r(i,["numberOfImages"]);t!==void 0&&f!=null&&c(t,["parameters","sampleCount"],f);const m=r(i,["aspectRatio"]);t!==void 0&&m!=null&&c(t,["parameters","aspectRatio"],m);const g=r(i,["guidanceScale"]);t!==void 0&&g!=null&&c(t,["parameters","guidanceScale"],g);const y=r(i,["seed"]);t!==void 0&&y!=null&&c(t,["parameters","seed"],y);const h=r(i,["safetyFilterLevel"]);t!==void 0&&h!=null&&c(t,["parameters","safetySetting"],h);const v=r(i,["personGeneration"]);t!==void 0&&v!=null&&c(t,["parameters","personGeneration"],v);const S=r(i,["includeSafetyAttributes"]);t!==void 0&&S!=null&&c(t,["parameters","includeSafetyAttributes"],S);const E=r(i,["includeRaiReason"]);t!==void 0&&E!=null&&c(t,["parameters","includeRaiReason"],E);const C=r(i,["language"]);t!==void 0&&C!=null&&c(t,["parameters","language"],C);const w=r(i,["outputMimeType"]);t!==void 0&&w!=null&&c(t,["parameters","outputOptions","mimeType"],w);const G=r(i,["outputCompressionQuality"]);t!==void 0&&G!=null&&c(t,["parameters","outputOptions","compressionQuality"],G);const x=r(i,["addWatermark"]);t!==void 0&&x!=null&&c(t,["parameters","addWatermark"],x);const B=r(i,["labels"]);t!==void 0&&B!=null&&c(t,["labels"],B);const Y=r(i,["editMode"]);t!==void 0&&Y!=null&&c(t,["parameters","editMode"],Y);const P=r(i,["baseSteps"]);return t!==void 0&&P!=null&&c(t,["parameters","editConfig","baseSteps"],P),l}function hE(i,t){const l={},a=r(t,["model"]);a!=null&&c(l,["_url","model"],Ce(i,a));const u=r(t,["prompt"]);u!=null&&c(l,["instances[0]","prompt"],u);const f=r(t,["referenceImages"]);if(f!=null){let g=f;Array.isArray(g)&&(g=g.map(y=>y_(y))),c(l,["instances[0]","referenceImages"],g)}const m=r(t,["config"]);return m!=null&&mE(m,l),l}function gE(i){const t={},l=r(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=r(i,["predictions"]);if(a!=null){let u=a;Array.isArray(u)&&(u=u.map(f=>La(f))),c(t,["generatedImages"],u)}return t}function yE(i,t){const l={},a=r(i,["taskType"]);t!==void 0&&a!=null&&c(t,["requests[]","taskType"],a);const u=r(i,["title"]);t!==void 0&&u!=null&&c(t,["requests[]","title"],u);const f=r(i,["outputDimensionality"]);if(t!==void 0&&f!=null&&c(t,["requests[]","outputDimensionality"],f),r(i,["mimeType"])!==void 0)throw new Error("mimeType parameter is not supported in Gemini API.");if(r(i,["autoTruncate"])!==void 0)throw new Error("autoTruncate parameter is not supported in Gemini API.");return l}function vE(i,t){const l={},a=r(i,["taskType"]);t!==void 0&&a!=null&&c(t,["instances[]","task_type"],a);const u=r(i,["title"]);t!==void 0&&u!=null&&c(t,["instances[]","title"],u);const f=r(i,["outputDimensionality"]);t!==void 0&&f!=null&&c(t,["parameters","outputDimensionality"],f);const m=r(i,["mimeType"]);t!==void 0&&m!=null&&c(t,["instances[]","mimeType"],m);const g=r(i,["autoTruncate"]);return t!==void 0&&g!=null&&c(t,["parameters","autoTruncate"],g),l}function TE(i,t){const l={},a=r(t,["model"]);a!=null&&c(l,["_url","model"],Ce(i,a));const u=r(t,["contents"]);if(u!=null){let g=Uu(i,u);Array.isArray(g)&&(g=g.map(y=>y)),c(l,["requests[]","content"],g)}const f=r(t,["config"]);f!=null&&yE(f,l);const m=r(t,["model"]);return m!==void 0&&c(l,["requests[]","model"],Ce(i,m)),l}function SE(i,t){const l={},a=r(t,["model"]);a!=null&&c(l,["_url","model"],Ce(i,a));const u=r(t,["contents"]);if(u!=null){let m=Uu(i,u);Array.isArray(m)&&(m=m.map(g=>g)),c(l,["instances[]","content"],m)}const f=r(t,["config"]);return f!=null&&vE(f,l),l}function EE(i){const t={},l=r(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=r(i,["embeddings"]);if(a!=null){let f=a;Array.isArray(f)&&(f=f.map(m=>m)),c(t,["embeddings"],f)}const u=r(i,["metadata"]);return u!=null&&c(t,["metadata"],u),t}function _E(i){const t={},l=r(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=r(i,["predictions[]","embeddings"]);if(a!=null){let f=a;Array.isArray(f)&&(f=f.map(m=>tE(m))),c(t,["embeddings"],f)}const u=r(i,["metadata"]);return u!=null&&c(t,["metadata"],u),t}function CE(i){const t={},l=r(i,["endpoint"]);l!=null&&c(t,["name"],l);const a=r(i,["deployedModelId"]);return a!=null&&c(t,["deployedModelId"],a),t}function AE(i){const t={};if(r(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const l=r(i,["fileUri"]);l!=null&&c(t,["fileUri"],l);const a=r(i,["mimeType"]);return a!=null&&c(t,["mimeType"],a),t}function RE(i){const t={},l=r(i,["id"]);l!=null&&c(t,["id"],l);const a=r(i,["args"]);a!=null&&c(t,["args"],a);const u=r(i,["name"]);if(u!=null&&c(t,["name"],u),r(i,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(r(i,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return t}function ME(i){const t={},l=r(i,["allowedFunctionNames"]);l!=null&&c(t,["allowedFunctionNames"],l);const a=r(i,["mode"]);if(a!=null&&c(t,["mode"],a),r(i,["streamFunctionCallArguments"])!==void 0)throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return t}function NE(i){const t={},l=r(i,["description"]);l!=null&&c(t,["description"],l);const a=r(i,["name"]);a!=null&&c(t,["name"],a);const u=r(i,["parameters"]);u!=null&&c(t,["parameters"],u);const f=r(i,["parametersJsonSchema"]);f!=null&&c(t,["parametersJsonSchema"],f);const m=r(i,["response"]);m!=null&&c(t,["response"],m);const g=r(i,["responseJsonSchema"]);if(g!=null&&c(t,["responseJsonSchema"],g),r(i,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");return t}function IE(i,t,l){const a={},u=r(t,["systemInstruction"]);l!==void 0&&u!=null&&c(l,["systemInstruction"],ba(it(u)));const f=r(t,["temperature"]);f!=null&&c(a,["temperature"],f);const m=r(t,["topP"]);m!=null&&c(a,["topP"],m);const g=r(t,["topK"]);g!=null&&c(a,["topK"],g);const y=r(t,["candidateCount"]);y!=null&&c(a,["candidateCount"],y);const h=r(t,["maxOutputTokens"]);h!=null&&c(a,["maxOutputTokens"],h);const v=r(t,["stopSequences"]);v!=null&&c(a,["stopSequences"],v);const S=r(t,["responseLogprobs"]);S!=null&&c(a,["responseLogprobs"],S);const E=r(t,["logprobs"]);E!=null&&c(a,["logprobs"],E);const C=r(t,["presencePenalty"]);C!=null&&c(a,["presencePenalty"],C);const w=r(t,["frequencyPenalty"]);w!=null&&c(a,["frequencyPenalty"],w);const G=r(t,["seed"]);G!=null&&c(a,["seed"],G);const x=r(t,["responseMimeType"]);x!=null&&c(a,["responseMimeType"],x);const B=r(t,["responseSchema"]);B!=null&&c(a,["responseSchema"],wu(B));const Y=r(t,["responseJsonSchema"]);if(Y!=null&&c(a,["responseJsonSchema"],Y),r(t,["routingConfig"])!==void 0)throw new Error("routingConfig parameter is not supported in Gemini API.");if(r(t,["modelSelectionConfig"])!==void 0)throw new Error("modelSelectionConfig parameter is not supported in Gemini API.");const P=r(t,["safetySettings"]);if(l!==void 0&&P!=null){let ue=P;Array.isArray(ue)&&(ue=ue.map(ve=>v_(ve))),c(l,["safetySettings"],ue)}const Q=r(t,["tools"]);if(l!==void 0&&Q!=null){let ue=eo(Q);Array.isArray(ue)&&(ue=ue.map(ve=>R_(ji(ve)))),c(l,["tools"],ue)}const j=r(t,["toolConfig"]);if(l!==void 0&&j!=null&&c(l,["toolConfig"],A_(j)),r(t,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const W=r(t,["cachedContent"]);l!==void 0&&W!=null&&c(l,["cachedContent"],hn(i,W));const F=r(t,["responseModalities"]);F!=null&&c(a,["responseModalities"],F);const ee=r(t,["mediaResolution"]);ee!=null&&c(a,["mediaResolution"],ee);const X=r(t,["speechConfig"]);if(X!=null&&c(a,["speechConfig"],xu(X)),r(t,["audioTimestamp"])!==void 0)throw new Error("audioTimestamp parameter is not supported in Gemini API.");const re=r(t,["thinkingConfig"]);re!=null&&c(a,["thinkingConfig"],re);const ye=r(t,["imageConfig"]);ye!=null&&c(a,["imageConfig"],t_(ye));const Ae=r(t,["enableEnhancedCivicAnswers"]);return Ae!=null&&c(a,["enableEnhancedCivicAnswers"],Ae),a}function DE(i,t,l){const a={},u=r(t,["systemInstruction"]);l!==void 0&&u!=null&&c(l,["systemInstruction"],it(u));const f=r(t,["temperature"]);f!=null&&c(a,["temperature"],f);const m=r(t,["topP"]);m!=null&&c(a,["topP"],m);const g=r(t,["topK"]);g!=null&&c(a,["topK"],g);const y=r(t,["candidateCount"]);y!=null&&c(a,["candidateCount"],y);const h=r(t,["maxOutputTokens"]);h!=null&&c(a,["maxOutputTokens"],h);const v=r(t,["stopSequences"]);v!=null&&c(a,["stopSequences"],v);const S=r(t,["responseLogprobs"]);S!=null&&c(a,["responseLogprobs"],S);const E=r(t,["logprobs"]);E!=null&&c(a,["logprobs"],E);const C=r(t,["presencePenalty"]);C!=null&&c(a,["presencePenalty"],C);const w=r(t,["frequencyPenalty"]);w!=null&&c(a,["frequencyPenalty"],w);const G=r(t,["seed"]);G!=null&&c(a,["seed"],G);const x=r(t,["responseMimeType"]);x!=null&&c(a,["responseMimeType"],x);const B=r(t,["responseSchema"]);B!=null&&c(a,["responseSchema"],wu(B));const Y=r(t,["responseJsonSchema"]);Y!=null&&c(a,["responseJsonSchema"],Y);const P=r(t,["routingConfig"]);P!=null&&c(a,["routingConfig"],P);const Q=r(t,["modelSelectionConfig"]);Q!=null&&c(a,["modelConfig"],Q);const j=r(t,["safetySettings"]);if(l!==void 0&&j!=null){let b=j;Array.isArray(b)&&(b=b.map(O=>O)),c(l,["safetySettings"],b)}const W=r(t,["tools"]);if(l!==void 0&&W!=null){let b=eo(W);Array.isArray(b)&&(b=b.map(O=>Xh(ji(O)))),c(l,["tools"],b)}const F=r(t,["toolConfig"]);l!==void 0&&F!=null&&c(l,["toolConfig"],F);const ee=r(t,["labels"]);l!==void 0&&ee!=null&&c(l,["labels"],ee);const X=r(t,["cachedContent"]);l!==void 0&&X!=null&&c(l,["cachedContent"],hn(i,X));const re=r(t,["responseModalities"]);re!=null&&c(a,["responseModalities"],re);const ye=r(t,["mediaResolution"]);ye!=null&&c(a,["mediaResolution"],ye);const Ae=r(t,["speechConfig"]);Ae!=null&&c(a,["speechConfig"],xu(Ae));const ue=r(t,["audioTimestamp"]);ue!=null&&c(a,["audioTimestamp"],ue);const ve=r(t,["thinkingConfig"]);ve!=null&&c(a,["thinkingConfig"],ve);const be=r(t,["imageConfig"]);if(be!=null&&c(a,["imageConfig"],n_(be)),r(t,["enableEnhancedCivicAnswers"])!==void 0)throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");return a}function uh(i,t){const l={},a=r(t,["model"]);a!=null&&c(l,["_url","model"],Ce(i,a));const u=r(t,["contents"]);if(u!=null){let m=Ht(u);Array.isArray(m)&&(m=m.map(g=>ba(g))),c(l,["contents"],m)}const f=r(t,["config"]);return f!=null&&c(l,["generationConfig"],IE(i,f,l)),l}function ch(i,t){const l={},a=r(t,["model"]);a!=null&&c(l,["_url","model"],Ce(i,a));const u=r(t,["contents"]);if(u!=null){let m=Ht(u);Array.isArray(m)&&(m=m.map(g=>g)),c(l,["contents"],m)}const f=r(t,["config"]);return f!=null&&c(l,["generationConfig"],DE(i,f,l)),l}function fh(i){const t={},l=r(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=r(i,["candidates"]);if(a!=null){let y=a;Array.isArray(y)&&(y=y.map(h=>$S(h))),c(t,["candidates"],y)}const u=r(i,["modelVersion"]);u!=null&&c(t,["modelVersion"],u);const f=r(i,["promptFeedback"]);f!=null&&c(t,["promptFeedback"],f);const m=r(i,["responseId"]);m!=null&&c(t,["responseId"],m);const g=r(i,["usageMetadata"]);return g!=null&&c(t,["usageMetadata"],g),t}function dh(i){const t={},l=r(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=r(i,["candidates"]);if(a!=null){let h=a;Array.isArray(h)&&(h=h.map(v=>v)),c(t,["candidates"],h)}const u=r(i,["createTime"]);u!=null&&c(t,["createTime"],u);const f=r(i,["modelVersion"]);f!=null&&c(t,["modelVersion"],f);const m=r(i,["promptFeedback"]);m!=null&&c(t,["promptFeedback"],m);const g=r(i,["responseId"]);g!=null&&c(t,["responseId"],g);const y=r(i,["usageMetadata"]);return y!=null&&c(t,["usageMetadata"],y),t}function UE(i,t){const l={};if(r(i,["outputGcsUri"])!==void 0)throw new Error("outputGcsUri parameter is not supported in Gemini API.");if(r(i,["negativePrompt"])!==void 0)throw new Error("negativePrompt parameter is not supported in Gemini API.");const a=r(i,["numberOfImages"]);t!==void 0&&a!=null&&c(t,["parameters","sampleCount"],a);const u=r(i,["aspectRatio"]);t!==void 0&&u!=null&&c(t,["parameters","aspectRatio"],u);const f=r(i,["guidanceScale"]);if(t!==void 0&&f!=null&&c(t,["parameters","guidanceScale"],f),r(i,["seed"])!==void 0)throw new Error("seed parameter is not supported in Gemini API.");const m=r(i,["safetyFilterLevel"]);t!==void 0&&m!=null&&c(t,["parameters","safetySetting"],m);const g=r(i,["personGeneration"]);t!==void 0&&g!=null&&c(t,["parameters","personGeneration"],g);const y=r(i,["includeSafetyAttributes"]);t!==void 0&&y!=null&&c(t,["parameters","includeSafetyAttributes"],y);const h=r(i,["includeRaiReason"]);t!==void 0&&h!=null&&c(t,["parameters","includeRaiReason"],h);const v=r(i,["language"]);t!==void 0&&v!=null&&c(t,["parameters","language"],v);const S=r(i,["outputMimeType"]);t!==void 0&&S!=null&&c(t,["parameters","outputOptions","mimeType"],S);const E=r(i,["outputCompressionQuality"]);if(t!==void 0&&E!=null&&c(t,["parameters","outputOptions","compressionQuality"],E),r(i,["addWatermark"])!==void 0)throw new Error("addWatermark parameter is not supported in Gemini API.");if(r(i,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const C=r(i,["imageSize"]);if(t!==void 0&&C!=null&&c(t,["parameters","sampleImageSize"],C),r(i,["enhancePrompt"])!==void 0)throw new Error("enhancePrompt parameter is not supported in Gemini API.");return l}function wE(i,t){const l={},a=r(i,["outputGcsUri"]);t!==void 0&&a!=null&&c(t,["parameters","storageUri"],a);const u=r(i,["negativePrompt"]);t!==void 0&&u!=null&&c(t,["parameters","negativePrompt"],u);const f=r(i,["numberOfImages"]);t!==void 0&&f!=null&&c(t,["parameters","sampleCount"],f);const m=r(i,["aspectRatio"]);t!==void 0&&m!=null&&c(t,["parameters","aspectRatio"],m);const g=r(i,["guidanceScale"]);t!==void 0&&g!=null&&c(t,["parameters","guidanceScale"],g);const y=r(i,["seed"]);t!==void 0&&y!=null&&c(t,["parameters","seed"],y);const h=r(i,["safetyFilterLevel"]);t!==void 0&&h!=null&&c(t,["parameters","safetySetting"],h);const v=r(i,["personGeneration"]);t!==void 0&&v!=null&&c(t,["parameters","personGeneration"],v);const S=r(i,["includeSafetyAttributes"]);t!==void 0&&S!=null&&c(t,["parameters","includeSafetyAttributes"],S);const E=r(i,["includeRaiReason"]);t!==void 0&&E!=null&&c(t,["parameters","includeRaiReason"],E);const C=r(i,["language"]);t!==void 0&&C!=null&&c(t,["parameters","language"],C);const w=r(i,["outputMimeType"]);t!==void 0&&w!=null&&c(t,["parameters","outputOptions","mimeType"],w);const G=r(i,["outputCompressionQuality"]);t!==void 0&&G!=null&&c(t,["parameters","outputOptions","compressionQuality"],G);const x=r(i,["addWatermark"]);t!==void 0&&x!=null&&c(t,["parameters","addWatermark"],x);const B=r(i,["labels"]);t!==void 0&&B!=null&&c(t,["labels"],B);const Y=r(i,["imageSize"]);t!==void 0&&Y!=null&&c(t,["parameters","sampleImageSize"],Y);const P=r(i,["enhancePrompt"]);return t!==void 0&&P!=null&&c(t,["parameters","enhancePrompt"],P),l}function xE(i,t){const l={},a=r(t,["model"]);a!=null&&c(l,["_url","model"],Ce(i,a));const u=r(t,["prompt"]);u!=null&&c(l,["instances[0]","prompt"],u);const f=r(t,["config"]);return f!=null&&UE(f,l),l}function bE(i,t){const l={},a=r(t,["model"]);a!=null&&c(l,["_url","model"],Ce(i,a));const u=r(t,["prompt"]);u!=null&&c(l,["instances[0]","prompt"],u);const f=r(t,["config"]);return f!=null&&wE(f,l),l}function LE(i){const t={},l=r(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=r(i,["predictions"]);if(a!=null){let f=a;Array.isArray(f)&&(f=f.map(m=>YE(m))),c(t,["generatedImages"],f)}const u=r(i,["positivePromptSafetyAttributes"]);return u!=null&&c(t,["positivePromptSafetyAttributes"],Jh(u)),t}function GE(i){const t={},l=r(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=r(i,["predictions"]);if(a!=null){let f=a;Array.isArray(f)&&(f=f.map(m=>La(m))),c(t,["generatedImages"],f)}const u=r(i,["positivePromptSafetyAttributes"]);return u!=null&&c(t,["positivePromptSafetyAttributes"],Yh(u)),t}function HE(i,t){const l={},a=r(i,["numberOfVideos"]);if(t!==void 0&&a!=null&&c(t,["parameters","sampleCount"],a),r(i,["outputGcsUri"])!==void 0)throw new Error("outputGcsUri parameter is not supported in Gemini API.");if(r(i,["fps"])!==void 0)throw new Error("fps parameter is not supported in Gemini API.");const u=r(i,["durationSeconds"]);if(t!==void 0&&u!=null&&c(t,["parameters","durationSeconds"],u),r(i,["seed"])!==void 0)throw new Error("seed parameter is not supported in Gemini API.");const f=r(i,["aspectRatio"]);t!==void 0&&f!=null&&c(t,["parameters","aspectRatio"],f);const m=r(i,["resolution"]);t!==void 0&&m!=null&&c(t,["parameters","resolution"],m);const g=r(i,["personGeneration"]);if(t!==void 0&&g!=null&&c(t,["parameters","personGeneration"],g),r(i,["pubsubTopic"])!==void 0)throw new Error("pubsubTopic parameter is not supported in Gemini API.");const y=r(i,["negativePrompt"]);t!==void 0&&y!=null&&c(t,["parameters","negativePrompt"],y);const h=r(i,["enhancePrompt"]);if(t!==void 0&&h!=null&&c(t,["parameters","enhancePrompt"],h),r(i,["generateAudio"])!==void 0)throw new Error("generateAudio parameter is not supported in Gemini API.");const v=r(i,["lastFrame"]);t!==void 0&&v!=null&&c(t,["instances[0]","lastFrame"],Ga(v));const S=r(i,["referenceImages"]);if(t!==void 0&&S!=null){let E=S;Array.isArray(E)&&(E=E.map(C=>V_(C))),c(t,["instances[0]","referenceImages"],E)}if(r(i,["mask"])!==void 0)throw new Error("mask parameter is not supported in Gemini API.");if(r(i,["compressionQuality"])!==void 0)throw new Error("compressionQuality parameter is not supported in Gemini API.");return l}function qE(i,t){const l={},a=r(i,["numberOfVideos"]);t!==void 0&&a!=null&&c(t,["parameters","sampleCount"],a);const u=r(i,["outputGcsUri"]);t!==void 0&&u!=null&&c(t,["parameters","storageUri"],u);const f=r(i,["fps"]);t!==void 0&&f!=null&&c(t,["parameters","fps"],f);const m=r(i,["durationSeconds"]);t!==void 0&&m!=null&&c(t,["parameters","durationSeconds"],m);const g=r(i,["seed"]);t!==void 0&&g!=null&&c(t,["parameters","seed"],g);const y=r(i,["aspectRatio"]);t!==void 0&&y!=null&&c(t,["parameters","aspectRatio"],y);const h=r(i,["resolution"]);t!==void 0&&h!=null&&c(t,["parameters","resolution"],h);const v=r(i,["personGeneration"]);t!==void 0&&v!=null&&c(t,["parameters","personGeneration"],v);const S=r(i,["pubsubTopic"]);t!==void 0&&S!=null&&c(t,["parameters","pubsubTopic"],S);const E=r(i,["negativePrompt"]);t!==void 0&&E!=null&&c(t,["parameters","negativePrompt"],E);const C=r(i,["enhancePrompt"]);t!==void 0&&C!=null&&c(t,["parameters","enhancePrompt"],C);const w=r(i,["generateAudio"]);t!==void 0&&w!=null&&c(t,["parameters","generateAudio"],w);const G=r(i,["lastFrame"]);t!==void 0&&G!=null&&c(t,["instances[0]","lastFrame"],kt(G));const x=r(i,["referenceImages"]);if(t!==void 0&&x!=null){let P=x;Array.isArray(P)&&(P=P.map(Q=>z_(Q))),c(t,["instances[0]","referenceImages"],P)}const B=r(i,["mask"]);t!==void 0&&B!=null&&c(t,["instances[0]","mask"],q_(B));const Y=r(i,["compressionQuality"]);return t!==void 0&&Y!=null&&c(t,["parameters","compressionQuality"],Y),l}function VE(i){const t={},l=r(i,["name"]);l!=null&&c(t,["name"],l);const a=r(i,["metadata"]);a!=null&&c(t,["metadata"],a);const u=r(i,["done"]);u!=null&&c(t,["done"],u);const f=r(i,["error"]);f!=null&&c(t,["error"],f);const m=r(i,["response","generateVideoResponse"]);return m!=null&&c(t,["response"],OE(m)),t}function zE(i){const t={},l=r(i,["name"]);l!=null&&c(t,["name"],l);const a=r(i,["metadata"]);a!=null&&c(t,["metadata"],a);const u=r(i,["done"]);u!=null&&c(t,["done"],u);const f=r(i,["error"]);f!=null&&c(t,["error"],f);const m=r(i,["response"]);return m!=null&&c(t,["response"],kE(m)),t}function BE(i,t){const l={},a=r(t,["model"]);a!=null&&c(l,["_url","model"],Ce(i,a));const u=r(t,["prompt"]);u!=null&&c(l,["instances[0]","prompt"],u);const f=r(t,["image"]);f!=null&&c(l,["instances[0]","image"],Ga(f));const m=r(t,["video"]);m!=null&&c(l,["instances[0]","video"],Kh(m));const g=r(t,["source"]);g!=null&&FE(g,l);const y=r(t,["config"]);return y!=null&&HE(y,l),l}function PE(i,t){const l={},a=r(t,["model"]);a!=null&&c(l,["_url","model"],Ce(i,a));const u=r(t,["prompt"]);u!=null&&c(l,["instances[0]","prompt"],u);const f=r(t,["image"]);f!=null&&c(l,["instances[0]","image"],kt(f));const m=r(t,["video"]);m!=null&&c(l,["instances[0]","video"],Qh(m));const g=r(t,["source"]);g!=null&&JE(g,l);const y=r(t,["config"]);return y!=null&&qE(y,l),l}function OE(i){const t={},l=r(i,["generatedSamples"]);if(l!=null){let f=l;Array.isArray(f)&&(f=f.map(m=>KE(m))),c(t,["generatedVideos"],f)}const a=r(i,["raiMediaFilteredCount"]);a!=null&&c(t,["raiMediaFilteredCount"],a);const u=r(i,["raiMediaFilteredReasons"]);return u!=null&&c(t,["raiMediaFilteredReasons"],u),t}function kE(i){const t={},l=r(i,["videos"]);if(l!=null){let f=l;Array.isArray(f)&&(f=f.map(m=>QE(m))),c(t,["generatedVideos"],f)}const a=r(i,["raiMediaFilteredCount"]);a!=null&&c(t,["raiMediaFilteredCount"],a);const u=r(i,["raiMediaFilteredReasons"]);return u!=null&&c(t,["raiMediaFilteredReasons"],u),t}function FE(i,t){const l={},a=r(i,["prompt"]);t!==void 0&&a!=null&&c(t,["instances[0]","prompt"],a);const u=r(i,["image"]);t!==void 0&&u!=null&&c(t,["instances[0]","image"],Ga(u));const f=r(i,["video"]);return t!==void 0&&f!=null&&c(t,["instances[0]","video"],Kh(f)),l}function JE(i,t){const l={},a=r(i,["prompt"]);t!==void 0&&a!=null&&c(t,["instances[0]","prompt"],a);const u=r(i,["image"]);t!==void 0&&u!=null&&c(t,["instances[0]","image"],kt(u));const f=r(i,["video"]);return t!==void 0&&f!=null&&c(t,["instances[0]","video"],Qh(f)),l}function YE(i){const t={},l=r(i,["_self"]);l!=null&&c(t,["image"],i_(l));const a=r(i,["raiFilteredReason"]);a!=null&&c(t,["raiFilteredReason"],a);const u=r(i,["_self"]);return u!=null&&c(t,["safetyAttributes"],Jh(u)),t}function La(i){const t={},l=r(i,["_self"]);l!=null&&c(t,["image"],Fh(l));const a=r(i,["raiFilteredReason"]);a!=null&&c(t,["raiFilteredReason"],a);const u=r(i,["_self"]);u!=null&&c(t,["safetyAttributes"],Yh(u));const f=r(i,["prompt"]);return f!=null&&c(t,["enhancedPrompt"],f),t}function XE(i){const t={},l=r(i,["_self"]);l!=null&&c(t,["mask"],Fh(l));const a=r(i,["labels"]);if(a!=null){let u=a;Array.isArray(u)&&(u=u.map(f=>f)),c(t,["labels"],u)}return t}function KE(i){const t={},l=r(i,["video"]);return l!=null&&c(t,["video"],G_(l)),t}function QE(i){const t={},l=r(i,["_self"]);return l!=null&&c(t,["video"],H_(l)),t}function ZE(i){const t={},l=r(i,["modelSelectionConfig"]);l!=null&&c(t,["modelConfig"],l);const a=r(i,["responseJsonSchema"]);a!=null&&c(t,["responseJsonSchema"],a);const u=r(i,["audioTimestamp"]);u!=null&&c(t,["audioTimestamp"],u);const f=r(i,["candidateCount"]);f!=null&&c(t,["candidateCount"],f);const m=r(i,["enableAffectiveDialog"]);m!=null&&c(t,["enableAffectiveDialog"],m);const g=r(i,["frequencyPenalty"]);g!=null&&c(t,["frequencyPenalty"],g);const y=r(i,["logprobs"]);y!=null&&c(t,["logprobs"],y);const h=r(i,["maxOutputTokens"]);h!=null&&c(t,["maxOutputTokens"],h);const v=r(i,["mediaResolution"]);v!=null&&c(t,["mediaResolution"],v);const S=r(i,["presencePenalty"]);S!=null&&c(t,["presencePenalty"],S);const E=r(i,["responseLogprobs"]);E!=null&&c(t,["responseLogprobs"],E);const C=r(i,["responseMimeType"]);C!=null&&c(t,["responseMimeType"],C);const w=r(i,["responseModalities"]);w!=null&&c(t,["responseModalities"],w);const G=r(i,["responseSchema"]);G!=null&&c(t,["responseSchema"],G);const x=r(i,["routingConfig"]);x!=null&&c(t,["routingConfig"],x);const B=r(i,["seed"]);B!=null&&c(t,["seed"],B);const Y=r(i,["speechConfig"]);Y!=null&&c(t,["speechConfig"],Y);const P=r(i,["stopSequences"]);P!=null&&c(t,["stopSequences"],P);const Q=r(i,["temperature"]);Q!=null&&c(t,["temperature"],Q);const j=r(i,["thinkingConfig"]);j!=null&&c(t,["thinkingConfig"],j);const W=r(i,["topK"]);W!=null&&c(t,["topK"],W);const F=r(i,["topP"]);if(F!=null&&c(t,["topP"],F),r(i,["enableEnhancedCivicAnswers"])!==void 0)throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");return t}function $E(i,t){const l={},a=r(t,["model"]);return a!=null&&c(l,["_url","name"],Ce(i,a)),l}function WE(i,t){const l={},a=r(t,["model"]);return a!=null&&c(l,["_url","name"],Ce(i,a)),l}function jE(i){const t={};if(r(i,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const l=r(i,["enableWidget"]);return l!=null&&c(t,["enableWidget"],l),t}function e_(i){const t={};if(r(i,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(r(i,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const l=r(i,["timeRangeFilter"]);return l!=null&&c(t,["timeRangeFilter"],l),t}function t_(i){const t={},l=r(i,["aspectRatio"]);l!=null&&c(t,["aspectRatio"],l);const a=r(i,["imageSize"]);if(a!=null&&c(t,["imageSize"],a),r(i,["personGeneration"])!==void 0)throw new Error("personGeneration parameter is not supported in Gemini API.");if(r(i,["outputMimeType"])!==void 0)throw new Error("outputMimeType parameter is not supported in Gemini API.");if(r(i,["outputCompressionQuality"])!==void 0)throw new Error("outputCompressionQuality parameter is not supported in Gemini API.");return t}function n_(i){const t={},l=r(i,["aspectRatio"]);l!=null&&c(t,["aspectRatio"],l);const a=r(i,["imageSize"]);a!=null&&c(t,["imageSize"],a);const u=r(i,["personGeneration"]);u!=null&&c(t,["personGeneration"],u);const f=r(i,["outputMimeType"]);f!=null&&c(t,["imageOutputOptions","mimeType"],f);const m=r(i,["outputCompressionQuality"]);return m!=null&&c(t,["imageOutputOptions","compressionQuality"],m),t}function i_(i){const t={},l=r(i,["bytesBase64Encoded"]);l!=null&&c(t,["imageBytes"],On(l));const a=r(i,["mimeType"]);return a!=null&&c(t,["mimeType"],a),t}function Fh(i){const t={},l=r(i,["gcsUri"]);l!=null&&c(t,["gcsUri"],l);const a=r(i,["bytesBase64Encoded"]);a!=null&&c(t,["imageBytes"],On(a));const u=r(i,["mimeType"]);return u!=null&&c(t,["mimeType"],u),t}function Ga(i){const t={};if(r(i,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");const l=r(i,["imageBytes"]);l!=null&&c(t,["bytesBase64Encoded"],On(l));const a=r(i,["mimeType"]);return a!=null&&c(t,["mimeType"],a),t}function kt(i){const t={},l=r(i,["gcsUri"]);l!=null&&c(t,["gcsUri"],l);const a=r(i,["imageBytes"]);a!=null&&c(t,["bytesBase64Encoded"],On(a));const u=r(i,["mimeType"]);return u!=null&&c(t,["mimeType"],u),t}function o_(i,t,l){const a={},u=r(t,["pageSize"]);l!==void 0&&u!=null&&c(l,["_query","pageSize"],u);const f=r(t,["pageToken"]);l!==void 0&&f!=null&&c(l,["_query","pageToken"],f);const m=r(t,["filter"]);l!==void 0&&m!=null&&c(l,["_query","filter"],m);const g=r(t,["queryBase"]);return l!==void 0&&g!=null&&c(l,["_url","models_url"],qh(i,g)),a}function l_(i,t,l){const a={},u=r(t,["pageSize"]);l!==void 0&&u!=null&&c(l,["_query","pageSize"],u);const f=r(t,["pageToken"]);l!==void 0&&f!=null&&c(l,["_query","pageToken"],f);const m=r(t,["filter"]);l!==void 0&&m!=null&&c(l,["_query","filter"],m);const g=r(t,["queryBase"]);return l!==void 0&&g!=null&&c(l,["_url","models_url"],qh(i,g)),a}function a_(i,t){const l={},a=r(t,["config"]);return a!=null&&o_(i,a,l),l}function s_(i,t){const l={},a=r(t,["config"]);return a!=null&&l_(i,a,l),l}function r_(i){const t={},l=r(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=r(i,["nextPageToken"]);a!=null&&c(t,["nextPageToken"],a);const u=r(i,["_self"]);if(u!=null){let f=Vh(u);Array.isArray(f)&&(f=f.map(m=>yu(m))),c(t,["models"],f)}return t}function u_(i){const t={},l=r(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=r(i,["nextPageToken"]);a!=null&&c(t,["nextPageToken"],a);const u=r(i,["_self"]);if(u!=null){let f=Vh(u);Array.isArray(f)&&(f=f.map(m=>vu(m))),c(t,["models"],f)}return t}function c_(i){const t={},l=r(i,["maskMode"]);l!=null&&c(t,["maskMode"],l);const a=r(i,["segmentationClasses"]);a!=null&&c(t,["maskClasses"],a);const u=r(i,["maskDilation"]);return u!=null&&c(t,["dilation"],u),t}function yu(i){const t={},l=r(i,["name"]);l!=null&&c(t,["name"],l);const a=r(i,["displayName"]);a!=null&&c(t,["displayName"],a);const u=r(i,["description"]);u!=null&&c(t,["description"],u);const f=r(i,["version"]);f!=null&&c(t,["version"],f);const m=r(i,["_self"]);m!=null&&c(t,["tunedModelInfo"],M_(m));const g=r(i,["inputTokenLimit"]);g!=null&&c(t,["inputTokenLimit"],g);const y=r(i,["outputTokenLimit"]);y!=null&&c(t,["outputTokenLimit"],y);const h=r(i,["supportedGenerationMethods"]);h!=null&&c(t,["supportedActions"],h);const v=r(i,["temperature"]);v!=null&&c(t,["temperature"],v);const S=r(i,["maxTemperature"]);S!=null&&c(t,["maxTemperature"],S);const E=r(i,["topP"]);E!=null&&c(t,["topP"],E);const C=r(i,["topK"]);C!=null&&c(t,["topK"],C);const w=r(i,["thinking"]);return w!=null&&c(t,["thinking"],w),t}function vu(i){const t={},l=r(i,["name"]);l!=null&&c(t,["name"],l);const a=r(i,["displayName"]);a!=null&&c(t,["displayName"],a);const u=r(i,["description"]);u!=null&&c(t,["description"],u);const f=r(i,["versionId"]);f!=null&&c(t,["version"],f);const m=r(i,["deployedModels"]);if(m!=null){let S=m;Array.isArray(S)&&(S=S.map(E=>CE(E))),c(t,["endpoints"],S)}const g=r(i,["labels"]);g!=null&&c(t,["labels"],g);const y=r(i,["_self"]);y!=null&&c(t,["tunedModelInfo"],N_(y));const h=r(i,["defaultCheckpointId"]);h!=null&&c(t,["defaultCheckpointId"],h);const v=r(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=r(i,["mediaResolution"]);l!=null&&c(t,["mediaResolution"],l);const a=r(i,["codeExecutionResult"]);a!=null&&c(t,["codeExecutionResult"],a);const u=r(i,["executableCode"]);u!=null&&c(t,["executableCode"],u);const f=r(i,["fileData"]);f!=null&&c(t,["fileData"],AE(f));const m=r(i,["functionCall"]);m!=null&&c(t,["functionCall"],RE(m));const g=r(i,["functionResponse"]);g!=null&&c(t,["functionResponse"],g);const y=r(i,["inlineData"]);y!=null&&c(t,["inlineData"],ZS(y));const h=r(i,["text"]);h!=null&&c(t,["text"],h);const v=r(i,["thought"]);v!=null&&c(t,["thought"],v);const S=r(i,["thoughtSignature"]);S!=null&&c(t,["thoughtSignature"],S);const E=r(i,["videoMetadata"]);return E!=null&&c(t,["videoMetadata"],E),t}function d_(i){const t={},l=r(i,["productImage"]);return l!=null&&c(t,["image"],kt(l)),t}function p_(i,t){const l={},a=r(i,["numberOfImages"]);t!==void 0&&a!=null&&c(t,["parameters","sampleCount"],a);const u=r(i,["baseSteps"]);t!==void 0&&u!=null&&c(t,["parameters","baseSteps"],u);const f=r(i,["outputGcsUri"]);t!==void 0&&f!=null&&c(t,["parameters","storageUri"],f);const m=r(i,["seed"]);t!==void 0&&m!=null&&c(t,["parameters","seed"],m);const g=r(i,["safetyFilterLevel"]);t!==void 0&&g!=null&&c(t,["parameters","safetySetting"],g);const y=r(i,["personGeneration"]);t!==void 0&&y!=null&&c(t,["parameters","personGeneration"],y);const h=r(i,["addWatermark"]);t!==void 0&&h!=null&&c(t,["parameters","addWatermark"],h);const v=r(i,["outputMimeType"]);t!==void 0&&v!=null&&c(t,["parameters","outputOptions","mimeType"],v);const S=r(i,["outputCompressionQuality"]);t!==void 0&&S!=null&&c(t,["parameters","outputOptions","compressionQuality"],S);const E=r(i,["enhancePrompt"]);t!==void 0&&E!=null&&c(t,["parameters","enhancePrompt"],E);const C=r(i,["labels"]);return t!==void 0&&C!=null&&c(t,["labels"],C),l}function m_(i,t){const l={},a=r(t,["model"]);a!=null&&c(l,["_url","model"],Ce(i,a));const u=r(t,["source"]);u!=null&&g_(u,l);const f=r(t,["config"]);return f!=null&&p_(f,l),l}function h_(i){const t={},l=r(i,["predictions"]);if(l!=null){let a=l;Array.isArray(a)&&(a=a.map(u=>La(u))),c(t,["generatedImages"],a)}return t}function g_(i,t){const l={},a=r(i,["prompt"]);t!==void 0&&a!=null&&c(t,["instances[0]","prompt"],a);const u=r(i,["personImage"]);t!==void 0&&u!=null&&c(t,["instances[0]","personImage","image"],kt(u));const f=r(i,["productImages"]);if(t!==void 0&&f!=null){let m=f;Array.isArray(m)&&(m=m.map(g=>d_(g))),c(t,["instances[0]","productImages"],m)}return l}function y_(i){const t={},l=r(i,["referenceImage"]);l!=null&&c(t,["referenceImage"],kt(l));const a=r(i,["referenceId"]);a!=null&&c(t,["referenceId"],a);const u=r(i,["referenceType"]);u!=null&&c(t,["referenceType"],u);const f=r(i,["maskImageConfig"]);f!=null&&c(t,["maskImageConfig"],c_(f));const m=r(i,["controlImageConfig"]);m!=null&&c(t,["controlImageConfig"],iE(m));const g=r(i,["styleImageConfig"]);g!=null&&c(t,["styleImageConfig"],g);const y=r(i,["subjectImageConfig"]);return y!=null&&c(t,["subjectImageConfig"],y),t}function Jh(i){const t={},l=r(i,["safetyAttributes","categories"]);l!=null&&c(t,["categories"],l);const a=r(i,["safetyAttributes","scores"]);a!=null&&c(t,["scores"],a);const u=r(i,["contentType"]);return u!=null&&c(t,["contentType"],u),t}function Yh(i){const t={},l=r(i,["safetyAttributes","categories"]);l!=null&&c(t,["categories"],l);const a=r(i,["safetyAttributes","scores"]);a!=null&&c(t,["scores"],a);const u=r(i,["contentType"]);return u!=null&&c(t,["contentType"],u),t}function v_(i){const t={},l=r(i,["category"]);if(l!=null&&c(t,["category"],l),r(i,["method"])!==void 0)throw new Error("method parameter is not supported in Gemini API.");const a=r(i,["threshold"]);return a!=null&&c(t,["threshold"],a),t}function T_(i){const t={},l=r(i,["image"]);return l!=null&&c(t,["image"],kt(l)),t}function S_(i,t){const l={},a=r(i,["mode"]);t!==void 0&&a!=null&&c(t,["parameters","mode"],a);const u=r(i,["maxPredictions"]);t!==void 0&&u!=null&&c(t,["parameters","maxPredictions"],u);const f=r(i,["confidenceThreshold"]);t!==void 0&&f!=null&&c(t,["parameters","confidenceThreshold"],f);const m=r(i,["maskDilation"]);t!==void 0&&m!=null&&c(t,["parameters","maskDilation"],m);const g=r(i,["binaryColorThreshold"]);t!==void 0&&g!=null&&c(t,["parameters","binaryColorThreshold"],g);const y=r(i,["labels"]);return t!==void 0&&y!=null&&c(t,["labels"],y),l}function E_(i,t){const l={},a=r(t,["model"]);a!=null&&c(l,["_url","model"],Ce(i,a));const u=r(t,["source"]);u!=null&&C_(u,l);const f=r(t,["config"]);return f!=null&&S_(f,l),l}function __(i){const t={},l=r(i,["predictions"]);if(l!=null){let a=l;Array.isArray(a)&&(a=a.map(u=>XE(u))),c(t,["generatedMasks"],a)}return t}function C_(i,t){const l={},a=r(i,["prompt"]);t!==void 0&&a!=null&&c(t,["instances[0]","prompt"],a);const u=r(i,["image"]);t!==void 0&&u!=null&&c(t,["instances[0]","image"],kt(u));const f=r(i,["scribbleImage"]);return t!==void 0&&f!=null&&c(t,["instances[0]","scribble"],T_(f)),l}function A_(i){const t={},l=r(i,["retrievalConfig"]);l!=null&&c(t,["retrievalConfig"],l);const a=r(i,["functionCallingConfig"]);return a!=null&&c(t,["functionCallingConfig"],ME(a)),t}function R_(i){const t={};if(r(i,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const l=r(i,["computerUse"]);l!=null&&c(t,["computerUse"],l);const a=r(i,["fileSearch"]);a!=null&&c(t,["fileSearch"],a);const u=r(i,["codeExecution"]);if(u!=null&&c(t,["codeExecution"],u),r(i,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const f=r(i,["functionDeclarations"]);if(f!=null){let v=f;Array.isArray(v)&&(v=v.map(S=>S)),c(t,["functionDeclarations"],v)}const m=r(i,["googleMaps"]);m!=null&&c(t,["googleMaps"],jE(m));const g=r(i,["googleSearch"]);g!=null&&c(t,["googleSearch"],e_(g));const y=r(i,["googleSearchRetrieval"]);y!=null&&c(t,["googleSearchRetrieval"],y);const h=r(i,["urlContext"]);return h!=null&&c(t,["urlContext"],h),t}function Xh(i){const t={},l=r(i,["retrieval"]);l!=null&&c(t,["retrieval"],l);const a=r(i,["computerUse"]);if(a!=null&&c(t,["computerUse"],a),r(i,["fileSearch"])!==void 0)throw new Error("fileSearch parameter is not supported in Vertex AI.");const u=r(i,["codeExecution"]);u!=null&&c(t,["codeExecution"],u);const f=r(i,["enterpriseWebSearch"]);f!=null&&c(t,["enterpriseWebSearch"],f);const m=r(i,["functionDeclarations"]);if(m!=null){let S=m;Array.isArray(S)&&(S=S.map(E=>NE(E))),c(t,["functionDeclarations"],S)}const g=r(i,["googleMaps"]);g!=null&&c(t,["googleMaps"],g);const y=r(i,["googleSearch"]);y!=null&&c(t,["googleSearch"],y);const h=r(i,["googleSearchRetrieval"]);h!=null&&c(t,["googleSearchRetrieval"],h);const v=r(i,["urlContext"]);return v!=null&&c(t,["urlContext"],v),t}function M_(i){const t={},l=r(i,["baseModel"]);l!=null&&c(t,["baseModel"],l);const a=r(i,["createTime"]);a!=null&&c(t,["createTime"],a);const u=r(i,["updateTime"]);return u!=null&&c(t,["updateTime"],u),t}function N_(i){const t={},l=r(i,["labels","google-vertex-llm-tuning-base-model-id"]);l!=null&&c(t,["baseModel"],l);const a=r(i,["createTime"]);a!=null&&c(t,["createTime"],a);const u=r(i,["updateTime"]);return u!=null&&c(t,["updateTime"],u),t}function I_(i,t){const l={},a=r(i,["displayName"]);t!==void 0&&a!=null&&c(t,["displayName"],a);const u=r(i,["description"]);t!==void 0&&u!=null&&c(t,["description"],u);const f=r(i,["defaultCheckpointId"]);return t!==void 0&&f!=null&&c(t,["defaultCheckpointId"],f),l}function D_(i,t){const l={},a=r(i,["displayName"]);t!==void 0&&a!=null&&c(t,["displayName"],a);const u=r(i,["description"]);t!==void 0&&u!=null&&c(t,["description"],u);const f=r(i,["defaultCheckpointId"]);return t!==void 0&&f!=null&&c(t,["defaultCheckpointId"],f),l}function U_(i,t){const l={},a=r(t,["model"]);a!=null&&c(l,["_url","name"],Ce(i,a));const u=r(t,["config"]);return u!=null&&I_(u,l),l}function w_(i,t){const l={},a=r(t,["model"]);a!=null&&c(l,["_url","model"],Ce(i,a));const u=r(t,["config"]);return u!=null&&D_(u,l),l}function x_(i,t){const l={},a=r(i,["outputGcsUri"]);t!==void 0&&a!=null&&c(t,["parameters","storageUri"],a);const u=r(i,["safetyFilterLevel"]);t!==void 0&&u!=null&&c(t,["parameters","safetySetting"],u);const f=r(i,["personGeneration"]);t!==void 0&&f!=null&&c(t,["parameters","personGeneration"],f);const m=r(i,["includeRaiReason"]);t!==void 0&&m!=null&&c(t,["parameters","includeRaiReason"],m);const g=r(i,["outputMimeType"]);t!==void 0&&g!=null&&c(t,["parameters","outputOptions","mimeType"],g);const y=r(i,["outputCompressionQuality"]);t!==void 0&&y!=null&&c(t,["parameters","outputOptions","compressionQuality"],y);const h=r(i,["enhanceInputImage"]);t!==void 0&&h!=null&&c(t,["parameters","upscaleConfig","enhanceInputImage"],h);const v=r(i,["imagePreservationFactor"]);t!==void 0&&v!=null&&c(t,["parameters","upscaleConfig","imagePreservationFactor"],v);const S=r(i,["labels"]);t!==void 0&&S!=null&&c(t,["labels"],S);const E=r(i,["numberOfImages"]);t!==void 0&&E!=null&&c(t,["parameters","sampleCount"],E);const C=r(i,["mode"]);return t!==void 0&&C!=null&&c(t,["parameters","mode"],C),l}function b_(i,t){const l={},a=r(t,["model"]);a!=null&&c(l,["_url","model"],Ce(i,a));const u=r(t,["image"]);u!=null&&c(l,["instances[0]","image"],kt(u));const f=r(t,["upscaleFactor"]);f!=null&&c(l,["parameters","upscaleConfig","upscaleFactor"],f);const m=r(t,["config"]);return m!=null&&x_(m,l),l}function L_(i){const t={},l=r(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=r(i,["predictions"]);if(a!=null){let u=a;Array.isArray(u)&&(u=u.map(f=>La(f))),c(t,["generatedImages"],u)}return t}function G_(i){const t={},l=r(i,["uri"]);l!=null&&c(t,["uri"],l);const a=r(i,["encodedVideo"]);a!=null&&c(t,["videoBytes"],On(a));const u=r(i,["encoding"]);return u!=null&&c(t,["mimeType"],u),t}function H_(i){const t={},l=r(i,["gcsUri"]);l!=null&&c(t,["uri"],l);const a=r(i,["bytesBase64Encoded"]);a!=null&&c(t,["videoBytes"],On(a));const u=r(i,["mimeType"]);return u!=null&&c(t,["mimeType"],u),t}function q_(i){const t={},l=r(i,["image"]);l!=null&&c(t,["_self"],kt(l));const a=r(i,["maskMode"]);return a!=null&&c(t,["maskMode"],a),t}function V_(i){const t={},l=r(i,["image"]);l!=null&&c(t,["image"],Ga(l));const a=r(i,["referenceType"]);return a!=null&&c(t,["referenceType"],a),t}function z_(i){const t={},l=r(i,["image"]);l!=null&&c(t,["image"],kt(l));const a=r(i,["referenceType"]);return a!=null&&c(t,["referenceType"],a),t}function Kh(i){const t={},l=r(i,["uri"]);l!=null&&c(t,["uri"],l);const a=r(i,["videoBytes"]);a!=null&&c(t,["encodedVideo"],On(a));const u=r(i,["mimeType"]);return u!=null&&c(t,["encoding"],u),t}function Qh(i){const t={},l=r(i,["uri"]);l!=null&&c(t,["gcsUri"],l);const a=r(i,["videoBytes"]);a!=null&&c(t,["bytesBase64Encoded"],On(a));const u=r(i,["mimeType"]);return u!=null&&c(t,["mimeType"],u),t}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function B_(i,t){const l={},a=r(i,["displayName"]);return t!==void 0&&a!=null&&c(t,["displayName"],a),l}function P_(i){const t={},l=r(i,["config"]);return l!=null&&B_(l,t),t}function O_(i,t){const l={},a=r(i,["force"]);return t!==void 0&&a!=null&&c(t,["_query","force"],a),l}function k_(i){const t={},l=r(i,["name"]);l!=null&&c(t,["_url","name"],l);const a=r(i,["config"]);return a!=null&&O_(a,t),t}function F_(i){const t={},l=r(i,["name"]);return l!=null&&c(t,["_url","name"],l),t}function J_(i,t){const l={},a=r(i,["customMetadata"]);if(t!==void 0&&a!=null){let f=a;Array.isArray(f)&&(f=f.map(m=>m)),c(t,["customMetadata"],f)}const u=r(i,["chunkingConfig"]);return t!==void 0&&u!=null&&c(t,["chunkingConfig"],u),l}function Y_(i){const t={},l=r(i,["name"]);l!=null&&c(t,["name"],l);const a=r(i,["metadata"]);a!=null&&c(t,["metadata"],a);const u=r(i,["done"]);u!=null&&c(t,["done"],u);const f=r(i,["error"]);f!=null&&c(t,["error"],f);const m=r(i,["response"]);return m!=null&&c(t,["response"],K_(m)),t}function X_(i){const t={},l=r(i,["fileSearchStoreName"]);l!=null&&c(t,["_url","file_search_store_name"],l);const a=r(i,["fileName"]);a!=null&&c(t,["fileName"],a);const u=r(i,["config"]);return u!=null&&J_(u,t),t}function K_(i){const t={},l=r(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=r(i,["parent"]);a!=null&&c(t,["parent"],a);const u=r(i,["documentName"]);return u!=null&&c(t,["documentName"],u),t}function Q_(i,t){const l={},a=r(i,["pageSize"]);t!==void 0&&a!=null&&c(t,["_query","pageSize"],a);const u=r(i,["pageToken"]);return t!==void 0&&u!=null&&c(t,["_query","pageToken"],u),l}function Z_(i){const t={},l=r(i,["config"]);return l!=null&&Q_(l,t),t}function $_(i){const t={},l=r(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=r(i,["nextPageToken"]);a!=null&&c(t,["nextPageToken"],a);const u=r(i,["fileSearchStores"]);if(u!=null){let f=u;Array.isArray(f)&&(f=f.map(m=>m)),c(t,["fileSearchStores"],f)}return t}function Zh(i,t){const l={},a=r(i,["mimeType"]);t!==void 0&&a!=null&&c(t,["mimeType"],a);const u=r(i,["displayName"]);t!==void 0&&u!=null&&c(t,["displayName"],u);const f=r(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=r(i,["chunkingConfig"]);return t!==void 0&&m!=null&&c(t,["chunkingConfig"],m),l}function W_(i){const t={},l=r(i,["fileSearchStoreName"]);l!=null&&c(t,["_url","file_search_store_name"],l);const a=r(i,["config"]);return a!=null&&Zh(a,t),t}function j_(i){const t={},l=r(i,["sdkHttpResponse"]);return l!=null&&c(t,["sdkHttpResponse"],l),t}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const eC="Content-Type",tC="X-Server-Timeout",nC="User-Agent",Tu="x-goog-api-client",iC="1.35.0",oC=`google-genai-sdk/${iC}`,lC="v1beta1",aC="v1beta";class sC{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 u={};this.clientOptions.vertexai?(u.apiVersion=(l=this.clientOptions.apiVersion)!==null&&l!==void 0?l:lC,u.baseUrl=this.baseUrlFromProjectLocation(),this.normalizeAuthParameters()):(u.apiVersion=(a=this.clientOptions.apiVersion)!==null&&a!==void 0?a:aC,u.baseUrl="https://generativelanguage.googleapis.com/"),u.headers=this.getDefaultHeaders(),this.clientOptions.httpOptions=u,t.httpOptions&&(this.clientOptions.httpOptions=this.patchHttpOptions(u,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 u=[this.getRequestUrlInternal(l)];return a&&u.push(this.getBaseResourcePath()),t!==""&&u.push(t),new URL(`${u.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),u=this.constructUrl(t.path,l,a);if(t.queryParams)for(const[m,g]of Object.entries(t.queryParams))u.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,u.toString(),t.abortSignal),this.unaryApiCall(u,f,t.httpMethod)}patchHttpOptions(t,l){const a=JSON.parse(JSON.stringify(t));for(const[u,f]of Object.entries(l))typeof f=="object"?a[u]=Object.assign(Object.assign({},a[u]),f):f!==void 0&&(a[u]=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),u=this.constructUrl(t.path,l,a);(!u.searchParams.has("alt")||u.searchParams.get("alt")!=="sse")&&u.searchParams.set("alt","sse");let f={};return f.body=t.body,f=await this.includeExtraHttpOptionsToRequestInit(f,l,u.toString(),t.abortSignal),this.streamApiCall(u,f,t.httpMethod)}async includeExtraHttpOptionsToRequestInit(t,l,a,u){if(l&&l.timeout||u){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()}u&&u.addEventListener("abort",()=>{f.abort()}),t.signal=m}return l&&l.extraBody!==null&&rC(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 u=>(await ph(u),new mu(u))).catch(u=>{throw u instanceof Error?u:new Error(JSON.stringify(u))})}async streamApiCall(t,l,a){return this.apiCall(t.toString(),Object.assign(Object.assign({},l),{method:a})).then(async u=>(await ph(u),this.processStreamResponse(u))).catch(u=>{throw u instanceof Error?u:new Error(JSON.stringify(u))})}processStreamResponse(t){return Pt(this,arguments,function*(){var a;const u=(a=t==null?void 0:t.body)===null||a===void 0?void 0:a.getReader(),f=new TextDecoder("utf-8");if(!u)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 le(u.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 w=JSON.parse(S);if("error"in w){const G=JSON.parse(JSON.stringify(w.error)),x=G.status,B=G.code,Y=`got status: ${x}. ${JSON.stringify(w)}`;if(B>=400&&B<600)throw new xa({message:Y,status:B})}}catch(w){if(w.name==="ApiError")throw w}m+=S;let E=-1,C=0;for(;;){E=-1,C=0;for(const x of y){const B=m.indexOf(x);B!==-1&&(E===-1||B{throw new Error(`exception ${a} sending request`)})}getDefaultHeaders(){const t={},l=oC+" "+this.clientOptions.userAgentExtra;return t[nC]=l,t[Tu]=l,t[eC]="application/json",t}async getHeadersInternal(t,l){const a=new Headers;if(t&&t.headers){for(const[u,f]of Object.entries(t.headers))a.append(u,f);t.timeout&&t.timeout>0&&a.append(tC,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 u={};l!=null&&(u.mimeType=l.mimeType,u.name=l.name,u.displayName=l.displayName),u.name&&!u.name.startsWith("files/")&&(u.name=`files/${u.name}`);const f=this.clientOptions.uploader,m=await f.stat(t);u.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.");u.mimeType=g;const y={file:u},h=this.getFileName(t),v=J("upload/v1beta/files",y._url),S=await this.fetchUploadUrl(v,u.sizeBytes,u.mimeType,h,y,l==null?void 0:l.httpOptions);return f.upload(t,S,this)}async uploadFileToFileSearchStore(t,l,a){var u;const f=this.clientOptions.uploader,m=await f.stat(l),g=String(m.size),y=(u=a==null?void 0:a.mimeType)!==null&&u!==void 0?u: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&&Zh(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,u,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}`},u?{"X-Goog-Upload-File-Name":u}:{})};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 ph(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 u=JSON.stringify(a);throw l>=400&&l<600?new xa({message:u,status:l}):new Error(u)}}function rC(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 u=a(l,t);i.body=JSON.stringify(u)}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const uC="mcp_used/unknown";let cC=!1;function $h(i){for(const t of i)if(fC(t)||typeof t=="object"&&"inputSchema"in t)return!0;return cC}function Wh(i){var t;const l=(t=i[Tu])!==null&&t!==void 0?t:"";i[Tu]=(l+` ${uC}`).trimStart()}function fC(i){return i!==null&&typeof i=="object"&&i instanceof Lu}function dC(i){return Pt(this,arguments,function*(l,a=100){let u,f=0;for(;f0)return;const f={},m=[];for(const v of this.mcpClients)try{for(var g=!0,y=(l=void 0,Ot(dC(v))),h;h=await y.next(),t=h.done,!t;g=!0){u=h.value,g=!1;const S=u;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(),F0(this.mcpTools,this.config)}async callTool(t){await this.initialize();const l=[];for(const a of t)if(a.name in this.functionNameToMcpClient){const u=this.functionNameToMcpClient[a.name];let f;this.config.timeout&&(f={timeout:this.config.timeout});const m=await u.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 pC(i,t,l){const a=new H0;let u;l.data instanceof Blob?u=JSON.parse(await l.data.text()):u=JSON.parse(l.data),Object.assign(a,u),t(a)}class mC{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 u=this.apiClient.getWebsocketBaseUrl(),f=this.apiClient.getApiVersion(),m=yC(this.apiClient.getDefaultHeaders()),g=this.apiClient.getApiKey(),y=`${u}/ws/google.ai.generativelanguage.${f}.GenerativeService.BidiGenerateMusic?key=${g}`;let h=()=>{};const v=new Promise(P=>{h=P}),S=t.callbacks,E=function(){h({})},C=this.apiClient,w={onopen:E,onmessage:P=>{pC(C,S.onmessage,P)},onerror:(l=S==null?void 0:S.onerror)!==null&&l!==void 0?l:function(P){},onclose:(a=S==null?void 0:S.onclose)!==null&&a!==void 0?a:function(P){}},G=this.webSocketFactory.create(y,gC(m),w);G.connect(),await v;const Y={setup:{model:Ce(this.apiClient,t.model)}};return G.send(JSON.stringify(Y)),new hC(G,this.apiClient)}}class hC{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=PS(t);this.conn.send(JSON.stringify({clientContent:l}))}async setMusicGenerationConfig(t){t.musicGenerationConfig||(t.musicGenerationConfig={});const l=BS(t);this.conn.send(JSON.stringify(l))}sendPlaybackControl(t){const l={playbackControl:t};this.conn.send(JSON.stringify(l))}play(){this.sendPlaybackControl(Qi.PLAY)}pause(){this.sendPlaybackControl(Qi.PAUSE)}stop(){this.sendPlaybackControl(Qi.STOP)}resetContext(){this.sendPlaybackControl(Qi.RESET_CONTEXT)}close(){this.conn.close()}}function gC(i){const t={};return i.forEach((l,a)=>{t[a]=l}),t}function yC(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 vC="FunctionResponse request must have an `id` field from the response of a ToolCall.FunctionalCalls in Google AI.";async function TC(i,t,l){const a=new G0;let u;l.data instanceof Blob?u=await l.data.text():l.data instanceof ArrayBuffer?u=new TextDecoder().decode(l.data):u=l.data;const f=JSON.parse(u);if(i.isVertexAI()){const m=FS(f);Object.assign(a,m)}else Object.assign(a,f);t(a)}class SC{constructor(t,l,a){this.apiClient=t,this.auth=l,this.webSocketFactory=a,this.music=new mC(this.apiClient,this.auth,this.webSocketFactory)}async connect(t){var l,a,u,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&&$h(t.config.tools)&&Wh(S);const E=AC(S);if(this.apiClient.isVertexAI())v=`${y}/ws/google.cloud.aiplatform.${h}.LlmBidiService/BidiGenerateContent`,await this.auth.addAuthHeaders(E,v);else{const X=this.apiClient.getApiKey();let re="BidiGenerateContent",ye="key";X!=null&&X.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."),re="BidiGenerateContentConstrained",ye="access_token"),v=`${y}/ws/google.ai.generativelanguage.${h}.GenerativeService.${re}?${ye}=${X}`}let C=()=>{};const w=new Promise(X=>{C=X}),G=t.callbacks,x=function(){var X;(X=G==null?void 0:G.onopen)===null||X===void 0||X.call(G),C({})},B=this.apiClient,Y={onopen:x,onmessage:X=>{TC(B,G.onmessage,X)},onerror:(l=G==null?void 0:G.onerror)!==null&&l!==void 0?l:function(X){},onclose:(a=G==null?void 0:G.onclose)!==null&&a!==void 0?a:function(X){}},P=this.webSocketFactory.create(v,CC(E),Y);P.connect(),await w;let Q=Ce(this.apiClient,t.model);if(this.apiClient.isVertexAI()&&Q.startsWith("publishers/")){const X=this.apiClient.getProject(),re=this.apiClient.getLocation();Q=`projects/${X}/locations/${re}/`+Q}let j={};this.apiClient.isVertexAI()&&((u=t.config)===null||u===void 0?void 0:u.responseModalities)===void 0&&(t.config===void 0?t.config={responseModalities:[tl.AUDIO]}:t.config.responseModalities=[tl.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 W=(g=(m=t.config)===null||m===void 0?void 0:m.tools)!==null&&g!==void 0?g:[],F=[];for(const X of W)if(this.isCallableTool(X)){const re=X;F.push(await re.tool())}else F.push(X);F.length>0&&(t.config.tools=F);const ee={model:Q,config:t.config,callbacks:t.callbacks};return this.apiClient.isVertexAI()?j=zS(this.apiClient,ee):j=VS(this.apiClient,ee),delete j.config,P.send(JSON.stringify(j)),new _C(P,this.apiClient)}isCallableTool(t){return"callTool"in t&&typeof t.callTool=="function"}}const EC={turnComplete:!0};class _C{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(u=>ba(u)))}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(vC)}return{toolResponse:{functionResponses:a}}}sendClientContent(t){t=Object.assign(Object.assign({},EC),t);const l=this.tLiveClientContent(this.apiClient,t);this.conn.send(JSON.stringify(l))}sendRealtimeInput(t){let l={};this.apiClient.isVertexAI()?l={realtimeInput:kS(t)}:l={realtimeInput:OS(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 CC(i){const t={};return i.forEach((l,a)=>{t[a]=l}),t}function AC(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 mh=10;function hh(i){var t,l,a;if(!((t=i==null?void 0:i.automaticFunctionCalling)===null||t===void 0)&&t.disable)return!0;let u=!1;for(const m of(l=i==null?void 0:i.tools)!==null&&l!==void 0?l:[])if(Wi(m)){u=!0;break}if(!u)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 Wi(i){return"callTool"in i&&typeof i.callTool=="function"}function RC(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(u=>Wi(u)))!==null&&a!==void 0?a:!1}function gh(i){var t;const l=[];return!((t=i==null?void 0:i.config)===null||t===void 0)&&t.tools&&i.config.tools.forEach((a,u)=>{if(Wi(a))return;const f=a;f.functionDeclarations&&f.functionDeclarations.length>0&&l.push(u)}),l}function yh(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 MC extends mn{constructor(t){super(),this.apiClient=t,this.generateContent=async l=>{var a,u,f,m,g;const y=await this.processParamsMaybeAddMcpUsage(l);if(this.maybeMoveToResponseJsonSchem(l),!RC(l)||hh(l.config))return await this.generateContentInternal(y);const h=gh(l);if(h.length>0){const G=h.map(x=>`tools[${x}]`).join(", ");throw new Error(`Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations is not yet supported. Incompatible tools found at ${G}.`)}let v,S;const E=Ht(y.contents),C=(f=(u=(a=y.config)===null||a===void 0?void 0:a.automaticFunctionCalling)===null||u===void 0?void 0:u.maximumRemoteCalls)!==null&&f!==void 0?f:mh;let w=0;for(;w{var a,u,f,m,g;if(this.maybeMoveToResponseJsonSchem(l),hh(l.config)){const S=await this.processParamsMaybeAddMcpUsage(l);return await this.generateContentStreamInternal(S)}const y=gh(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=(u=(a=l==null?void 0:l.config)===null||a===void 0?void 0:a.toolConfig)===null||u===void 0?void 0:u.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 u;let f;const m=[];if(a!=null&&a.generatedImages)for(const y of a.generatedImages)y&&(y!=null&&y.safetyAttributes)&&((u=y==null?void 0:y.safetyAttributes)===null||u===void 0?void 0:u.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 ui(pn.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(u=>u.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 u={model:l.model,image:l.image,upscaleFactor:l.upscaleFactor,config:a};return await this.upscaleImageInternal(u)},this.generateVideos=async l=>{var a,u,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&&(!((u=l.video)===null||u===void 0)&&u.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,u;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=>Wi(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&&$h(t.config.tools)){const y=(u=(a=t.config.httpOptions)===null||a===void 0?void 0:a.headers)!==null&&u!==void 0?u:{};let h=Object.assign({},y);Object.keys(h).length===0&&(h=this.apiClient.getDefaultHeaders()),Wh(h),g.config.httpOptions=Object.assign(Object.assign({},t.config.httpOptions),{headers:h})}return g}async initAfcToolsMap(t){var l,a,u;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(Wi(m)){const g=m,y=await g.tool();for(const h of(u=y.functionDeclarations)!==null&&u!==void 0?u:[]){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,u;const f=(u=(a=(l=t.config)===null||l===void 0?void 0:l.automaticFunctionCalling)===null||a===void 0?void 0:a.maximumRemoteCalls)!==null&&u!==void 0?u:mh;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,w,G,x,B;g0){m=!0;const X=new Wo;X.candidates=[{content:{role:"user",parts:F}}],yield yield le(X);const re=[];re.push(...ee),re.push({role:"user",parts:F});const ye=Ht(S.contents).concat(re);S.contents=ye}else break}})})(this,y,t)}async generateContentInternal(t){var l,a,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=ch(this.apiClient,t);return g=J("{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=dh(v),E=new Wo;return Object.assign(E,S),E})}else{const h=uh(this.apiClient,t);return g=J("{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:(u=t.config)===null||u===void 0?void 0:u.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=fh(v),E=new Wo;return Object.assign(E,S),E})}}async generateContentStreamInternal(t){var l,a,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=ch(this.apiClient,t);return g=J("{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,w,G;try{for(var x=!0,B=Ot(S),Y;Y=yield le(B.next()),E=Y.done,!E;x=!0){G=Y.value,x=!1;const P=G,Q=dh(yield le(P.json()));Q.sdkHttpResponse={headers:P.headers};const j=new Wo;Object.assign(j,Q),yield yield le(j)}}catch(P){C={error:P}}finally{try{!x&&!E&&(w=B.return)&&(yield le(w.call(B)))}finally{if(C)throw C.error}}})})}else{const h=uh(this.apiClient,t);return g=J("{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:(u=t.config)===null||u===void 0?void 0:u.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,w,G;try{for(var x=!0,B=Ot(S),Y;Y=yield le(B.next()),E=Y.done,!E;x=!0){G=Y.value,x=!1;const P=G,Q=fh(yield le(P.json()));Q.sdkHttpResponse={headers:P.headers};const j=new Wo;Object.assign(j,Q),yield yield le(j)}}catch(P){C={error:P}}finally{try{!x&&!E&&(w=B.return)&&(yield le(w.call(B)))}finally{if(C)throw C.error}}})})}}async embedContent(t){var l,a,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=SE(this.apiClient,t);return g=J("{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=_E(v),E=new Ym;return Object.assign(E,S),E})}else{const h=TE(this.apiClient,t);return g=J("{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:(u=t.config)===null||u===void 0?void 0:u.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=EE(v),E=new Ym;return Object.assign(E,S),E})}}async generateImagesInternal(t){var l,a,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=bE(this.apiClient,t);return g=J("{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=GE(v),E=new Xm;return Object.assign(E,S),E})}else{const h=xE(this.apiClient,t);return g=J("{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:(u=t.config)===null||u===void 0?void 0:u.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=LE(v),E=new Xm;return Object.assign(E,S),E})}}async editImageInternal(t){var l,a;let u,f="",m={};if(this.apiClient.isVertexAI()){const g=hE(this.apiClient,t);return f=J("{model}:predict",g._url),m=g._query,delete g._url,delete g._query,u=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})),u.then(y=>{const h=gE(y),v=new A0;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 u,f="",m={};if(this.apiClient.isVertexAI()){const g=b_(this.apiClient,t);return f=J("{model}:predict",g._url),m=g._query,delete g._url,delete g._query,u=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})),u.then(y=>{const h=L_(y),v=new R0;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 u,f="",m={};if(this.apiClient.isVertexAI()){const g=m_(this.apiClient,t);return f=J("{model}:predict",g._url),m=g._query,delete g._url,delete g._query,u=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()),u.then(y=>{const h=h_(y),v=new M0;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 u,f="",m={};if(this.apiClient.isVertexAI()){const g=E_(this.apiClient,t);return f=J("{model}:predict",g._url),m=g._query,delete g._url,delete g._query,u=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()),u.then(y=>{const h=__(y),v=new N0;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,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=WE(this.apiClient,t);return g=J("{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=>vu(v))}else{const h=$E(this.apiClient,t);return g=J("{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:(u=t.config)===null||u===void 0?void 0:u.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json()),m.then(v=>yu(v))}}async listInternal(t){var l,a,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=s_(this.apiClient,t);return g=J("{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=u_(v),E=new Km;return Object.assign(E,S),E})}else{const h=a_(this.apiClient,t);return g=J("{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:(u=t.config)===null||u===void 0?void 0:u.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=r_(v),E=new Km;return Object.assign(E,S),E})}}async update(t){var l,a,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=w_(this.apiClient,t);return g=J("{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=>vu(v))}else{const h=U_(this.apiClient,t);return g=J("{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:(u=t.config)===null||u===void 0?void 0:u.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json()),m.then(v=>yu(v))}}async delete(t){var l,a,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=fE(this.apiClient,t);return g=J("{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=pE(v),E=new Qm;return Object.assign(E,S),E})}else{const h=cE(this.apiClient,t);return g=J("{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:(u=t.config)===null||u===void 0?void 0:u.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=dE(v),E=new Qm;return Object.assign(E,S),E})}}async countTokens(t){var l,a,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=sE(this.apiClient,t);return g=J("{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=uE(v),E=new Zm;return Object.assign(E,S),E})}else{const h=aE(this.apiClient,t);return g=J("{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:(u=t.config)===null||u===void 0?void 0:u.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=rE(v),E=new Zm;return Object.assign(E,S),E})}}async computeTokens(t){var l,a;let u,f="",m={};if(this.apiClient.isVertexAI()){const g=jS(this.apiClient,t);return f=J("{model}:computeTokens",g._url),m=g._query,delete g._url,delete g._query,u=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})),u.then(y=>{const h=eE(y),v=new I0;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,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=PE(this.apiClient,t);return g=J("{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=zE(v),E=new Na;return Object.assign(E,S),E})}else{const h=BE(this.apiClient,t);return g=J("{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:(u=t.config)===null||u===void 0?void 0:u.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json()),m.then(v=>{const S=VE(v),E=new Na;return Object.assign(E,S),E})}}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class NC extends mn{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 u=l.name.split("/operations/")[0];let f;a&&"httpOptions"in a&&(f=a.httpOptions);const m=await this.fetchPredictVideosOperationInternal({operationName:l.name,resourceName:u,config:{httpOptions:f}});return l._fromAPIResponse({apiResponse:m,_isVertexAI:!0})}else{const u=await this.getVideosOperationInternal({operationName:l.name,config:a});return l._fromAPIResponse({apiResponse:u,_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 u=l.name.split("/operations/")[0];let f;a&&"httpOptions"in a&&(f=a.httpOptions);const m=await this.fetchPredictVideosOperationInternal({operationName:l.name,resourceName:u,config:{httpOptions:f}});return l._fromAPIResponse({apiResponse:m,_isVertexAI:!0})}else{const u=await this.getVideosOperationInternal({operationName:l.name,config:a});return l._fromAPIResponse({apiResponse:u,_isVertexAI:!1})}}async getVideosOperationInternal(t){var l,a,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=v0(t);return g=J("{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=y0(t);return g=J("{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:(u=t.config)===null||u===void 0?void 0:u.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 u,f="",m={};if(this.apiClient.isVertexAI()){const g=c0(t);return f=J("{resourceName}:fetchPredictOperation",g._url),m=g._query,delete g._url,delete g._query,u=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()),u}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 IC(i){const t={},l=r(i,["data"]);if(l!=null&&c(t,["data"],l),r(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const a=r(i,["mimeType"]);return a!=null&&c(t,["mimeType"],a),t}function DC(i){const t={},l=r(i,["parts"]);if(l!=null){let u=l;Array.isArray(u)&&(u=u.map(f=>VC(f))),c(t,["parts"],u)}const a=r(i,["role"]);return a!=null&&c(t,["role"],a),t}function UC(i,t,l){const a={},u=r(t,["expireTime"]);l!==void 0&&u!=null&&c(l,["expireTime"],u);const f=r(t,["newSessionExpireTime"]);l!==void 0&&f!=null&&c(l,["newSessionExpireTime"],f);const m=r(t,["uses"]);l!==void 0&&m!=null&&c(l,["uses"],m);const g=r(t,["liveConnectConstraints"]);l!==void 0&&g!=null&&c(l,["bidiGenerateContentSetup"],qC(i,g));const y=r(t,["lockAdditionalFields"]);return l!==void 0&&y!=null&&c(l,["fieldMask"],y),a}function wC(i,t){const l={},a=r(t,["config"]);return a!=null&&c(l,["config"],UC(i,a,l)),l}function xC(i){const t={};if(r(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const l=r(i,["fileUri"]);l!=null&&c(t,["fileUri"],l);const a=r(i,["mimeType"]);return a!=null&&c(t,["mimeType"],a),t}function bC(i){const t={},l=r(i,["id"]);l!=null&&c(t,["id"],l);const a=r(i,["args"]);a!=null&&c(t,["args"],a);const u=r(i,["name"]);if(u!=null&&c(t,["name"],u),r(i,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(r(i,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return t}function LC(i){const t={};if(r(i,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const l=r(i,["enableWidget"]);return l!=null&&c(t,["enableWidget"],l),t}function GC(i){const t={};if(r(i,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(r(i,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const l=r(i,["timeRangeFilter"]);return l!=null&&c(t,["timeRangeFilter"],l),t}function HC(i,t){const l={},a=r(i,["generationConfig"]);t!==void 0&&a!=null&&c(t,["setup","generationConfig"],a);const u=r(i,["responseModalities"]);t!==void 0&&u!=null&&c(t,["setup","generationConfig","responseModalities"],u);const f=r(i,["temperature"]);t!==void 0&&f!=null&&c(t,["setup","generationConfig","temperature"],f);const m=r(i,["topP"]);t!==void 0&&m!=null&&c(t,["setup","generationConfig","topP"],m);const g=r(i,["topK"]);t!==void 0&&g!=null&&c(t,["setup","generationConfig","topK"],g);const y=r(i,["maxOutputTokens"]);t!==void 0&&y!=null&&c(t,["setup","generationConfig","maxOutputTokens"],y);const h=r(i,["mediaResolution"]);t!==void 0&&h!=null&&c(t,["setup","generationConfig","mediaResolution"],h);const v=r(i,["seed"]);t!==void 0&&v!=null&&c(t,["setup","generationConfig","seed"],v);const S=r(i,["speechConfig"]);t!==void 0&&S!=null&&c(t,["setup","generationConfig","speechConfig"],bu(S));const E=r(i,["thinkingConfig"]);t!==void 0&&E!=null&&c(t,["setup","generationConfig","thinkingConfig"],E);const C=r(i,["enableAffectiveDialog"]);t!==void 0&&C!=null&&c(t,["setup","generationConfig","enableAffectiveDialog"],C);const w=r(i,["systemInstruction"]);t!==void 0&&w!=null&&c(t,["setup","systemInstruction"],DC(it(w)));const G=r(i,["tools"]);if(t!==void 0&&G!=null){let W=eo(G);Array.isArray(W)&&(W=W.map(F=>BC(ji(F)))),c(t,["setup","tools"],W)}const x=r(i,["sessionResumption"]);t!==void 0&&x!=null&&c(t,["setup","sessionResumption"],zC(x));const B=r(i,["inputAudioTranscription"]);t!==void 0&&B!=null&&c(t,["setup","inputAudioTranscription"],B);const Y=r(i,["outputAudioTranscription"]);t!==void 0&&Y!=null&&c(t,["setup","outputAudioTranscription"],Y);const P=r(i,["realtimeInputConfig"]);t!==void 0&&P!=null&&c(t,["setup","realtimeInputConfig"],P);const Q=r(i,["contextWindowCompression"]);t!==void 0&&Q!=null&&c(t,["setup","contextWindowCompression"],Q);const j=r(i,["proactivity"]);if(t!==void 0&&j!=null&&c(t,["setup","proactivity"],j),r(i,["explicitVadSignal"])!==void 0)throw new Error("explicitVadSignal parameter is not supported in Gemini API.");return l}function qC(i,t){const l={},a=r(t,["model"]);a!=null&&c(l,["setup","model"],Ce(i,a));const u=r(t,["config"]);return u!=null&&c(l,["config"],HC(u,l)),l}function VC(i){const t={},l=r(i,["mediaResolution"]);l!=null&&c(t,["mediaResolution"],l);const a=r(i,["codeExecutionResult"]);a!=null&&c(t,["codeExecutionResult"],a);const u=r(i,["executableCode"]);u!=null&&c(t,["executableCode"],u);const f=r(i,["fileData"]);f!=null&&c(t,["fileData"],xC(f));const m=r(i,["functionCall"]);m!=null&&c(t,["functionCall"],bC(m));const g=r(i,["functionResponse"]);g!=null&&c(t,["functionResponse"],g);const y=r(i,["inlineData"]);y!=null&&c(t,["inlineData"],IC(y));const h=r(i,["text"]);h!=null&&c(t,["text"],h);const v=r(i,["thought"]);v!=null&&c(t,["thought"],v);const S=r(i,["thoughtSignature"]);S!=null&&c(t,["thoughtSignature"],S);const E=r(i,["videoMetadata"]);return E!=null&&c(t,["videoMetadata"],E),t}function zC(i){const t={},l=r(i,["handle"]);if(l!=null&&c(t,["handle"],l),r(i,["transparent"])!==void 0)throw new Error("transparent parameter is not supported in Gemini API.");return t}function BC(i){const t={};if(r(i,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const l=r(i,["computerUse"]);l!=null&&c(t,["computerUse"],l);const a=r(i,["fileSearch"]);a!=null&&c(t,["fileSearch"],a);const u=r(i,["codeExecution"]);if(u!=null&&c(t,["codeExecution"],u),r(i,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const f=r(i,["functionDeclarations"]);if(f!=null){let v=f;Array.isArray(v)&&(v=v.map(S=>S)),c(t,["functionDeclarations"],v)}const m=r(i,["googleMaps"]);m!=null&&c(t,["googleMaps"],LC(m));const g=r(i,["googleSearch"]);g!=null&&c(t,["googleSearch"],GC(g));const y=r(i,["googleSearchRetrieval"]);y!=null&&c(t,["googleSearchRetrieval"],y);const h=r(i,["urlContext"]);return h!=null&&c(t,["urlContext"],h),t}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function PC(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 u=Object.keys(a).map(f=>`${l}.${f}`);t.push(...u)}else t.push(l)}return t.join(",")}function OC(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 u=i.fieldMask;if(l){const f=PC(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&&u!==null&&Array.isArray(u)&&u.length>0){const m=["temperature","topK","topP","maxOutputTokens","responseModalities","seed","speechConfig"];let g=[];u.length>0&&(g=u.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 u!==null&&Array.isArray(u)&&u.length>0?i.fieldMask=u.join(","):delete i.fieldMask;return i}class kC extends mn{constructor(t){super(),this.apiClient=t}async create(t){var l,a;let u,f="",m={};if(this.apiClient.isVertexAI())throw new Error("The client.tokens.create method is only supported by the Gemini Developer API.");{const g=wC(this.apiClient,t);f=J("auth_tokens",g._url),m=g._query,delete g.config,delete g._url,delete g._query;const y=OC(g,t.config);return u=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()),u.then(h=>h)}}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function FC(i,t){const l={},a=r(i,["force"]);return t!==void 0&&a!=null&&c(t,["_query","force"],a),l}function JC(i){const t={},l=r(i,["name"]);l!=null&&c(t,["_url","name"],l);const a=r(i,["config"]);return a!=null&&FC(a,t),t}function YC(i){const t={},l=r(i,["name"]);return l!=null&&c(t,["_url","name"],l),t}function XC(i,t){const l={},a=r(i,["pageSize"]);t!==void 0&&a!=null&&c(t,["_query","pageSize"],a);const u=r(i,["pageToken"]);return t!==void 0&&u!=null&&c(t,["_query","pageToken"],u),l}function KC(i){const t={},l=r(i,["parent"]);l!=null&&c(t,["_url","parent"],l);const a=r(i,["config"]);return a!=null&&XC(a,t),t}function QC(i){const t={},l=r(i,["sdkHttpResponse"]);l!=null&&c(t,["sdkHttpResponse"],l);const a=r(i,["nextPageToken"]);a!=null&&c(t,["nextPageToken"],a);const u=r(i,["documents"]);if(u!=null){let f=u;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 ZC extends mn{constructor(t){super(),this.apiClient=t,this.list=async l=>new ui(pn.PAGED_ITEM_DOCUMENTS,a=>this.listInternal({parent:l.parent,config:a.config}),await this.listInternal(l),l)}async get(t){var l,a;let u,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=YC(t);return f=J("{name}",g._url),m=g._query,delete g._url,delete g._query,u=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()),u.then(y=>y)}}async delete(t){var l,a;let u="",f={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const m=JC(t);u=J("{name}",m._url),f=m._query,delete m._url,delete m._query,await this.apiClient.request({path:u,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 u,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=KC(t);return f=J("{parent}/documents",g._url),m=g._query,delete g._url,delete g._query,u=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()),u.then(y=>{const h=QC(y),v=new D0;return Object.assign(v,h),v})}}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class $C extends mn{constructor(t,l=new ZC(t)){super(),this.apiClient=t,this.documents=l,this.list=async(a={})=>new ui(pn.PAGED_ITEM_FILE_SEARCH_STORES,u=>this.listInternal(u),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 u,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=P_(t);return f=J("fileSearchStores",g._url),m=g._query,delete g._url,delete g._query,u=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()),u.then(y=>y)}}async get(t){var l,a;let u,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=F_(t);return f=J("{name}",g._url),m=g._query,delete g._url,delete g._query,u=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()),u.then(y=>y)}}async delete(t){var l,a;let u="",f={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const m=k_(t);u=J("{name}",m._url),f=m._query,delete m._url,delete m._query,await this.apiClient.request({path:u,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 u,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=Z_(t);return f=J("fileSearchStores",g._url),m=g._query,delete g._url,delete g._query,u=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()),u.then(y=>{const h=$_(y),v=new U0;return Object.assign(v,h),v})}}async uploadToFileSearchStoreInternal(t){var l,a;let u,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=W_(t);return f=J("upload/v1beta/{file_search_store_name}:uploadToFileSearchStore",g._url),m=g._query,delete g._url,delete g._query,u=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()),u.then(y=>{const h=j_(y),v=new w0;return Object.assign(v,h),v})}}async importFile(t){var l,a;let u,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=X_(t);return f=J("{file_search_store_name}:importFile",g._url),m=g._query,delete g._url,delete g._query,u=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()),u.then(y=>{const h=Y_(y),v=new Iu;return Object.assign(v,h),v})}}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */let jh=function(){const{crypto:i}=globalThis;if(i!=null&&i.randomUUID)return jh=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 WC=()=>jh();/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function Su(i){return typeof i=="object"&&i!==null&&("name"in i&&i.name==="AbortError"||"message"in i&&String(i.message).includes("FetchRequestCanceledException"))}const Eu=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 rt extends qt{constructor(t,l,a,u){super(`${rt.makeMessage(t,l,a)}`),this.status=t,this.headers=u,this.error=l}static makeMessage(t,l,a){const u=l!=null&&l.message?typeof l.message=="string"?l.message:JSON.stringify(l.message):l?JSON.stringify(l):a;return t&&u?`${t} ${u}`:t?`${t} status code (no body)`:u||"(no status code or body)"}static generate(t,l,a,u){if(!t||!u)return new Ha({message:a,cause:Eu(l)});const f=l;return t===400?new tg(t,f,a,u):t===401?new ng(t,f,a,u):t===403?new ig(t,f,a,u):t===404?new og(t,f,a,u):t===409?new lg(t,f,a,u):t===422?new ag(t,f,a,u):t===429?new sg(t,f,a,u):t>=500?new rg(t,f,a,u):new rt(t,f,a,u)}}class _u extends rt{constructor({message:t}={}){super(void 0,void 0,t||"Request was aborted.",void 0)}}class Ha extends rt{constructor({message:t,cause:l}){super(void 0,void 0,t||"Connection error.",void 0),l&&(this.cause=l)}}class eg extends Ha{constructor({message:t}={}){super({message:t??"Request timed out."})}}class tg extends rt{}class ng extends rt{}class ig extends rt{}class og extends rt{}class lg extends rt{}class ag extends rt{}class sg extends rt{}class rg extends rt{}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const jC=/^[a-z][a-z0-9+.-]*:/i,eA=i=>jC.test(i);let Cu=i=>(Cu=Array.isArray,Cu(i));const tA=Cu;let nA=tA;const vh=nA;function iA(i){if(!i)return!0;for(const t in i)return!1;return!0}function oA(i,t){return Object.prototype.hasOwnProperty.call(i,t)}const lA=(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},aA=i=>{try{return JSON.parse(i)}catch{return}};/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const sA=i=>new Promise(t=>setTimeout(t,i));/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const Ki="0.0.1";/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function rA(){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 uA=()=>{var i,t,l,a,u;const f=rA();if(f==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Ki,"X-Stainless-OS":Sh(Deno.build.os),"X-Stainless-Arch":Th(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":Ki,"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":Ki,"X-Stainless-OS":Sh((l=globalThis.process.platform)!==null&&l!==void 0?l:"unknown"),"X-Stainless-Arch":Th((a=globalThis.process.arch)!==null&&a!==void 0?a:"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":(u=globalThis.process.version)!==null&&u!==void 0?u:"unknown"};const m=cA();return m?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Ki,"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":Ki,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function cA(){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 u=a[1]||0,f=a[2]||0,m=a[3]||0;return{browser:t,version:`${u}.${f}.${m}`}}}return null}const Th=i=>i==="x32"?"x32":i==="x86_64"||i==="x64"?"x64":i==="arm"?"arm":i==="aarch64"||i==="arm64"?"arm64":i?`other:${i}`:"unknown",Sh=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 Sa;const fA=()=>Sa??(Sa=uA());/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function dA(){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 ug(...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 pA(i){let t=Symbol.asyncIterator in i?i[Symbol.asyncIterator]():i[Symbol.iterator]();return ug({start(){},async pull(l){const{done:a,value:u}=await t.next();a?l.close():l.enqueue(u)},async cancel(){var l;await((l=t.return)===null||l===void 0?void 0:l.call(t))}})}function cg(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 mA(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(),u=a.cancel();a.releaseLock(),await u}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const hA=({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 fg=()=>{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 uu(i,t,l){return fg(),new File(i,t??"unknown_file",l)}function gA(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 yA=i=>i!=null&&typeof i=="object"&&typeof i[Symbol.asyncIterator]=="function";/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const dg=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",vA=i=>i!=null&&typeof i=="object"&&typeof i.name=="string"&&typeof i.lastModified=="number"&&dg(i),TA=i=>i!=null&&typeof i=="object"&&typeof i.url=="string"&&typeof i.blob=="function";async function SA(i,t,l){if(fg(),i=await i,vA(i))return i instanceof File?i:uu([await i.arrayBuffer()],i.name);if(TA(i)){const u=await i.blob();return t||(t=new URL(i.url).pathname.split(/[\\/]/).pop()),uu(await Au(u),t,l)}const a=await Au(i);if(t||(t=gA(i)),!(l!=null&&l.type)){const u=a.find(f=>typeof f=="object"&&"type"in f&&f.type);typeof u=="string"&&(l=Object.assign(Object.assign({},l),{type:u}))}return uu(a,t,l)}async function Au(i){var t,l,a,u,f;let m=[];if(typeof i=="string"||ArrayBuffer.isView(i)||i instanceof ArrayBuffer)m.push(i);else if(dg(i))m.push(i instanceof Blob?i:await i.arrayBuffer());else if(yA(i))try{for(var g=!0,y=Ot(i),h;h=await y.next(),t=h.done,!t;g=!0){u=h.value,g=!1;const v=u;m.push(...await Au(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}`:""}${EA(i)}`)}return m}function EA(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 pg{constructor(t){this._client=t}}pg._key=[];/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function mg(i){return i.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}const Eh=Object.freeze(Object.create(null)),_A=(i=mg)=>(function(l,...a){if(l.length===1)return l[0];let u=!1;const f=[],m=l.reduce((v,S,E)=>{var C,w,G;/[?#]/.test(S)&&(u=!0);const x=a[E];let B=(u?encodeURIComponent:i)(""+x);return E!==a.length&&(x==null||typeof x=="object"&&x.toString===((G=Object.getPrototypeOf((w=Object.getPrototypeOf((C=x.hasOwnProperty)!==null&&C!==void 0?C:Eh))!==null&&w!==void 0?w:Eh))===null||G===void 0?void 0:G.toString))&&(B=x+"",f.push({start:v.length+S.length,length:B.length,error:`Value of type ${Object.prototype.toString.call(x).slice(8,-1)} is not a valid path parameter`})),v+S+(E===a.length?"":B)},""),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 w=" ".repeat(C.start-v),G="^".repeat(C.length);return v=C.start+C.length,E+w+G},"");throw new qt(`Path parameters result in path with invalid segments: ${f.map(E=>E.error).join(` `)} ${m} ${S}`)}return m}),Ea=_A(mg);/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class hg extends pg{create(t,l){var a;const{api_version:u=this._client.apiVersion}=t,f=Da(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(Ea`/${u}/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:u=this._client.apiVersion}=l??{};return this._client.delete(Ea`/${u}/interactions/${t}`,a)}cancel(t,l={},a){const{api_version:u=this._client.apiVersion}=l??{};return this._client.post(Ea`/${u}/interactions/${t}/cancel`,a)}get(t,l={},a){var u;const f=l??{},{api_version:m=this._client.apiVersion}=f,g=Da(f,["api_version"]);return this._client.get(Ea`/${m}/interactions/${t}`,Object.assign(Object.assign({query:g},a),{stream:(u=l==null?void 0:l.stream)!==null&&u!==void 0?u:!1}))}}hg._key=Object.freeze(["interactions"]);class gg extends hg{}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function CA(i){let t=0;for(const u of i)t+=u.length;const l=new Uint8Array(t);let a=0;for(const u of i)l.set(u,a),a+=u.length;return l}let _a;function Gu(i){let t;return(_a??(t=new globalThis.TextEncoder,_a=t.encode.bind(t)))(i)}let Ca;function _h(i){let t;return(Ca??(t=new globalThis.TextDecoder,Ca=t.decode.bind(t)))(i)}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class qa{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"?Gu(t):t;this.buffer=CA([this.buffer,l]);const a=[];let u;for(;(u=AA(this.buffer,this.carriageReturnIndex))!=null;){if(u.carriage&&this.carriageReturnIndex==null){this.carriageReturnIndex=u.index;continue}if(this.carriageReturnIndex!=null&&(u.index!==this.carriageReturnIndex+1||u.carriage)){a.push(_h(this.buffer.subarray(0,this.carriageReturnIndex-1))),this.buffer=this.buffer.subarray(this.carriageReturnIndex),this.carriageReturnIndex=null;continue}const f=this.carriageReturnIndex!==null?u.preceding-1:u.preceding,m=_h(this.buffer.subarray(0,f));a.push(m),this.buffer=this.buffer.subarray(u.index),this.carriageReturnIndex=null}return a}flush(){return this.buffer.length?this.decode(` `):[]}}qa.NEWLINE_CHARS=new Set([` `,"\r"]);qa.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function AA(i,t){for(let u=t??0;u{if(i){if(oA(Ua,i))return i;st(l).warn(`${t} was set to ${JSON.stringify(i)}, expected one of ${JSON.stringify(Object.keys(Ua))}`)}};function el(){}function Aa(i,t,l){return!t||Ua[i]>Ua[l]?el:t[i].bind(t)}const MA={error:el,warn:el,info:el,debug:el};let Ah=new WeakMap;function st(i){var t;const l=i.logger,a=(t=i.logLevel)!==null&&t!==void 0?t:"off";if(!l)return MA;const u=Ah.get(l);if(u&&u[0]===a)return u[1];const f={error:Aa("error",l,a),warn:Aa("warn",l,a),info:Aa("info",l,a),debug:Aa("debug",l,a)};return Ah.set(l,[a,f]),f}const ri=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 Zi{constructor(t,l,a){this.iterator=t,this.controller=l,this.client=a}static fromSSEResponse(t,l,a){let u=!1;const f=a?st(a):console;function m(){return Pt(this,arguments,function*(){var y,h,v,S;if(u)throw new qt("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");u=!0;let E=!1;try{try{for(var C=!0,w=Ot(NA(t,l)),G;G=yield le(w.next()),y=G.done,!y;C=!0){S=G.value,C=!1;const x=S;if(!E)if(x.data.startsWith("[DONE]")){E=!0;continue}else try{yield yield le(JSON.parse(x.data))}catch(B){throw f.error("Could not parse message into JSON:",x.data),f.error("From chunk:",x.raw),B}}}catch(x){h={error:x}}finally{try{!C&&!y&&(v=w.return)&&(yield le(v.call(w)))}finally{if(h)throw h.error}}E=!0}catch(x){if(Su(x))return yield le(void 0);throw x}finally{E||l.abort()}})}return new Zi(m,l,a)}static fromReadableStream(t,l,a){let u=!1;function f(){return Pt(this,arguments,function*(){var y,h,v,S;const E=new qa,C=cg(t);try{for(var w=!0,G=Ot(C),x;x=yield le(G.next()),y=x.done,!y;w=!0){S=x.value,w=!1;const B=S;for(const Y of E.decode(B))yield yield le(Y)}}catch(B){h={error:B}}finally{try{!w&&!y&&(v=G.return)&&(yield le(v.call(G)))}finally{if(h)throw h.error}}for(const B of E.flush())yield yield le(B)})}function m(){return Pt(this,arguments,function*(){var y,h,v,S;if(u)throw new qt("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");u=!0;let E=!1;try{try{for(var C=!0,w=Ot(f()),G;G=yield le(w.next()),y=G.done,!y;C=!0){S=G.value,C=!1;const x=S;E||x&&(yield yield le(JSON.parse(x)))}}catch(x){h={error:x}}finally{try{!C&&!y&&(v=w.return)&&(yield le(v.call(w)))}finally{if(h)throw h.error}}E=!0}catch(x){if(Su(x))return yield le(void 0);throw x}finally{E||l.abort()}})}return new Zi(m,l,a)}[Symbol.asyncIterator](){return this.iterator()}tee(){const t=[],l=[],a=this.iterator(),u=f=>({next:()=>{if(f.length===0){const m=a.next();t.push(m),l.push(m)}return f.shift()}});return[new Zi(()=>u(t),this.controller,this.client),new Zi(()=>u(l),this.controller,this.client)]}toReadableStream(){const t=this;let l;return ug({async start(){l=t[Symbol.asyncIterator]()},async pull(a){try{const{value:u,done:f}=await l.next();if(f)return a.close();const m=Gu(JSON.stringify(u)+` `);a.enqueue(m)}catch(u){a.error(u)}},async cancel(){var a;await((a=l.return)===null||a===void 0?void 0:a.call(l))}})}}function NA(i,t){return Pt(this,arguments,function*(){var a,u,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 DA,y=new qa,h=cg(i.body);try{for(var v=!0,S=Ot(IA(h)),E;E=yield le(S.next()),a=E.done,!a;v=!0){m=E.value,v=!1;const C=m;for(const w of y.decode(C)){const G=g.decode(w);G&&(yield yield le(G))}}}catch(C){u={error:C}}finally{try{!v&&!a&&(f=S.return)&&(yield le(f.call(S)))}finally{if(u)throw u.error}}for(const C of y.flush()){const w=g.decode(C);w&&(yield yield le(w))}})}function IA(i){return Pt(this,arguments,function*(){var l,a,u,f;let m=new Uint8Array;try{for(var g=!0,y=Ot(i),h;h=yield le(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"?Gu(v):v;let E=new Uint8Array(m.length+S.length);E.set(m),E.set(S,m.length),m=E;let C;for(;(C=RA(m))!==-1;)yield yield le(m.slice(0,C)),m=m.slice(C)}}catch(v){a={error:v}}finally{try{!g&&!l&&(u=y.return)&&(yield le(u.call(y)))}finally{if(a)throw a.error}}m.length>0&&(yield yield le(m))})}class DA{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,u]=UA(t,":");return u.startsWith(" ")&&(u=u.substring(1)),l==="event"?this.event=u:l==="data"&&this.data.push(u),null}}function UA(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 wA(i,t){const{response:l,requestLogID:a,retryOfRequestLogID:u,startTime:f}=t,m=await(async()=>{var g;if(t.options.stream)return st(i).debug("response",l.status,l.url,l.headers,l.body),t.options.__streamClass?t.options.__streamClass.fromSSEResponse(l,t.controller,i):Zi.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 st(i).debug(`[${a}] response parsed`,ri({retryOfRequestLogID:u,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 Hu extends Promise{constructor(t,l,a=wA){super(u=>{u(null)}),this.responsePromise=l,this.parseResponse=a,this.client=t}_thenUnwrap(t){return new Hu(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 yg=Symbol("brand.privateNullableHeaders");function*xA(i){if(!i)return;if(yg in i){const{values:a,nulls:u}=i;yield*a.entries();for(const f of u)yield[f,null];return}let t=!1,l;i instanceof Headers?l=i.entries():vh(i)?l=i:(t=!0,l=Object.entries(i??{}));for(let a of l){const u=a[0];if(typeof u!="string")throw new TypeError("expected header name to be a string");const f=vh(a[1])?a[1]:[a[1]];let m=!1;for(const g of f)g!==void 0&&(t&&!m&&(m=!0,yield[u,null]),yield[u,g])}}const jo=i=>{const t=new Headers,l=new Set;for(const a of i){const u=new Set;for(const[f,m]of xA(a)){const g=f.toLowerCase();u.has(g)||(t.delete(f),u.add(g)),m===null?(t.delete(f),l.add(g)):(t.append(f,m),l.delete(g))}}return{[yg]:!0,values:t,nulls:l}};/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const cu=i=>{var t,l,a,u,f,m;if(typeof globalThis.process<"u")return(a=(l=(t=o0)===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=(u=globalThis.Deno.env)===null||u===void 0?void 0:u.get)===null||f===void 0?void 0:f.call(u,i))===null||m===void 0?void 0:m.trim()};/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */var vg;class Va{constructor(t){var l,a,u,f,m,g,y,{baseURL:h=cu("GEMINI_NEXT_GEN_API_BASE_URL"),apiKey:v=(l=cu("GEMINI_API_KEY"))!==null&&l!==void 0?l:null,apiVersion:S="v1beta"}=t,E=Da(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:Va.DEFAULT_TIMEOUT,this.logger=(u=C.logger)!==null&&u!==void 0?u:console;const w="warn";this.logLevel=w,this.logLevel=(m=(f=Ch(C.logLevel,"ClientOptions.logLevel",this))!==null&&f!==void 0?f:Ch(cu("GEMINI_NEXT_GEN_API_LOG"),"process.env['GEMINI_NEXT_GEN_API_LOG']",this))!==null&&m!==void 0?m:w,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:dA(),this.encoder=hA,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=jo([t.headers]);if(!(l.values.has("authorization")||l.values.has("x-goog-api-key"))){if(this.apiKey)return jo([{"x-goog-api-key":this.apiKey}]);if(this.clientAdapter.isVertexAI())return jo([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 ${Ki}`}defaultIdempotencyKey(){return`stainless-node-retry-${WC()}`}makeStatusError(t,l,a,u){return rt.generate(t,l,a,u)}buildURL(t,l,a){const u=!this.baseURLOverridden()&&a||this.baseURL,f=eA(t)?new URL(t):new URL(u+(u.endsWith("/")&&t.startsWith("/")?t.slice(1):t)),m=this.defaultQuery();return iA(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(u=>Object.assign({method:t,path:l},u)))}request(t,l=null){return new Hu(this,this.makeRequest(t,l,void 0))}async makeRequest(t,l,a){var u,f,m;const g=await t,y=(u=g.maxRetries)!==null&&u!==void 0?u: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}`,w=Date.now();if(st(this).debug(`[${E}] sending request`,ri({retryOfRequestLogID:a,method:g.method,url:v,options:g,headers:h.headers})),!((f=g.signal)===null||f===void 0)&&f.aborted)throw new _u;const G=new AbortController,x=await this.fetchWithTimeout(v,h,S,G).catch(Eu),B=Date.now();if(x instanceof globalThis.Error){const P=`retrying, ${l} attempts remaining`;if(!((m=g.signal)===null||m===void 0)&&m.aborted)throw new _u;const Q=Su(x)||/timed? ?out/i.test(String(x)+("cause"in x?String(x.cause):""));if(l)return st(this).info(`[${E}] connection ${Q?"timed out":"failed"} - ${P}`),st(this).debug(`[${E}] connection ${Q?"timed out":"failed"} (${P})`,ri({retryOfRequestLogID:a,url:v,durationMs:B-w,message:x.message})),this.retryRequest(g,l,a??E);throw st(this).info(`[${E}] connection ${Q?"timed out":"failed"} - error; no more retries left`),st(this).debug(`[${E}] connection ${Q?"timed out":"failed"} (error; no more retries left)`,ri({retryOfRequestLogID:a,url:v,durationMs:B-w,message:x.message})),Q?new eg:new Ha({cause:x})}const Y=`[${E}${C}] ${h.method} ${v} ${x.ok?"succeeded":"failed"} with status ${x.status} in ${B-w}ms`;if(!x.ok){const P=await this.shouldRetry(x);if(l&&P){const X=`retrying, ${l} attempts remaining`;return await mA(x.body),st(this).info(`${Y} - ${X}`),st(this).debug(`[${E}] response error (${X})`,ri({retryOfRequestLogID:a,url:x.url,status:x.status,headers:x.headers,durationMs:B-w})),this.retryRequest(g,l,a??E,x.headers)}const Q=P?"error; no more retries left":"error; not retryable";st(this).info(`${Y} - ${Q}`);const j=await x.text().catch(X=>Eu(X).message),W=aA(j),F=W?void 0:j;throw st(this).debug(`[${E}] response error (${Q})`,ri({retryOfRequestLogID:a,url:x.url,status:x.status,headers:x.headers,message:F,durationMs:Date.now()-w})),this.makeStatusError(x.status,W,F,x.headers)}return st(this).info(Y),st(this).debug(`[${E}] response start`,ri({retryOfRequestLogID:a,url:x.url,status:x.status,headers:x.headers,durationMs:B-w})),{response:x,options:g,controller:G,requestLogID:E,retryOfRequestLogID:a,startTime:w}}async fetchWithTimeout(t,l,a,u){const f=l||{},{signal:m,method:g}=f,y=Da(f,["signal","method"]);m&&m.addEventListener("abort",()=>u.abort());const h=setTimeout(()=>u.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:u.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,u){var f;let m;const g=u==null?void 0:u.get("retry-after-ms");if(g){const h=parseFloat(g);Number.isNaN(h)||(m=h)}const y=u==null?void 0:u.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 sA(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,u,f;const m=Object.assign({},t),{method:g,path:y,query:h,defaultBaseURL:v}=m,S=this.buildURL(y,h,v);"timeout"in m&&lA("timeout",m.timeout),m.timeout=(a=m.timeout)!==null&&a!==void 0?a:this.timeout;const{bodyHeaders:E,body:C}=this.buildBody({options:m}),w=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:w},m.signal&&{signal:m.signal}),globalThis.ReadableStream&&C instanceof globalThis.ReadableStream&&{duplex:"half"}),C&&{body:C}),(u=this.fetchOptions)!==null&&u!==void 0?u:{}),(f=m.fetchOptions)!==null&&f!==void 0?f:{}),url:S,timeout:m.timeout}}async buildHeaders({options:t,method:l,bodyHeaders:a,retryCount:u}){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=jo([f,Object.assign(Object.assign({Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(u)},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=jo([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:pA(t)}:this.encoder({body:t,headers:a})}}Va.DEFAULT_TIMEOUT=6e4;class Ze extends Va{constructor(){super(...arguments),this.interactions=new gg(this)}}vg=Ze;Ze.GeminiNextGenAPIClient=vg;Ze.GeminiNextGenAPIClientError=qt;Ze.APIError=rt;Ze.APIConnectionError=Ha;Ze.APIConnectionTimeoutError=eg;Ze.APIUserAbortError=_u;Ze.NotFoundError=og;Ze.ConflictError=lg;Ze.RateLimitError=sg;Ze.BadRequestError=tg;Ze.AuthenticationError=ng;Ze.InternalServerError=rg;Ze.PermissionDeniedError=ig;Ze.UnprocessableEntityError=ag;Ze.toFile=SA;Ze.Interactions=gg;/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */function bA(i,t){const l={},a=r(i,["name"]);return a!=null&&c(l,["_url","name"],a),l}function LA(i,t){const l={},a=r(i,["name"]);return a!=null&&c(l,["_url","name"],a),l}function GA(i,t){const l={},a=r(i,["sdkHttpResponse"]);return a!=null&&c(l,["sdkHttpResponse"],a),l}function HA(i,t){const l={},a=r(i,["sdkHttpResponse"]);return a!=null&&c(l,["sdkHttpResponse"],a),l}function qA(i,t,l){const a={};if(r(i,["validationDataset"])!==void 0)throw new Error("validationDataset parameter is not supported in Gemini API.");const u=r(i,["tunedModelDisplayName"]);if(t!==void 0&&u!=null&&c(t,["displayName"],u),r(i,["description"])!==void 0)throw new Error("description parameter is not supported in Gemini API.");const f=r(i,["epochCount"]);t!==void 0&&f!=null&&c(t,["tuningTask","hyperparameters","epochCount"],f);const m=r(i,["learningRateMultiplier"]);if(m!=null&&c(a,["tuningTask","hyperparameters","learningRateMultiplier"],m),r(i,["exportLastCheckpointOnly"])!==void 0)throw new Error("exportLastCheckpointOnly parameter is not supported in Gemini API.");if(r(i,["preTunedModelCheckpointId"])!==void 0)throw new Error("preTunedModelCheckpointId parameter is not supported in Gemini API.");if(r(i,["adapterSize"])!==void 0)throw new Error("adapterSize parameter is not supported in Gemini API.");const g=r(i,["batchSize"]);t!==void 0&&g!=null&&c(t,["tuningTask","hyperparameters","batchSize"],g);const y=r(i,["learningRate"]);if(t!==void 0&&y!=null&&c(t,["tuningTask","hyperparameters","learningRate"],y),r(i,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");if(r(i,["beta"])!==void 0)throw new Error("beta parameter is not supported in Gemini API.");return a}function VA(i,t,l){const a={};let u=r(l,["config","method"]);if(u===void 0&&(u="SUPERVISED_FINE_TUNING"),u==="SUPERVISED_FINE_TUNING"){const C=r(i,["validationDataset"]);t!==void 0&&C!=null&&c(t,["supervisedTuningSpec"],Rh(C))}else if(u==="PREFERENCE_TUNING"){const C=r(i,["validationDataset"]);t!==void 0&&C!=null&&c(t,["preferenceOptimizationSpec"],Rh(C))}const f=r(i,["tunedModelDisplayName"]);t!==void 0&&f!=null&&c(t,["tunedModelDisplayName"],f);const m=r(i,["description"]);t!==void 0&&m!=null&&c(t,["description"],m);let g=r(l,["config","method"]);if(g===void 0&&(g="SUPERVISED_FINE_TUNING"),g==="SUPERVISED_FINE_TUNING"){const C=r(i,["epochCount"]);t!==void 0&&C!=null&&c(t,["supervisedTuningSpec","hyperParameters","epochCount"],C)}else if(g==="PREFERENCE_TUNING"){const C=r(i,["epochCount"]);t!==void 0&&C!=null&&c(t,["preferenceOptimizationSpec","hyperParameters","epochCount"],C)}let y=r(l,["config","method"]);if(y===void 0&&(y="SUPERVISED_FINE_TUNING"),y==="SUPERVISED_FINE_TUNING"){const C=r(i,["learningRateMultiplier"]);t!==void 0&&C!=null&&c(t,["supervisedTuningSpec","hyperParameters","learningRateMultiplier"],C)}else if(y==="PREFERENCE_TUNING"){const C=r(i,["learningRateMultiplier"]);t!==void 0&&C!=null&&c(t,["preferenceOptimizationSpec","hyperParameters","learningRateMultiplier"],C)}let h=r(l,["config","method"]);if(h===void 0&&(h="SUPERVISED_FINE_TUNING"),h==="SUPERVISED_FINE_TUNING"){const C=r(i,["exportLastCheckpointOnly"]);t!==void 0&&C!=null&&c(t,["supervisedTuningSpec","exportLastCheckpointOnly"],C)}else if(h==="PREFERENCE_TUNING"){const C=r(i,["exportLastCheckpointOnly"]);t!==void 0&&C!=null&&c(t,["preferenceOptimizationSpec","exportLastCheckpointOnly"],C)}let v=r(l,["config","method"]);if(v===void 0&&(v="SUPERVISED_FINE_TUNING"),v==="SUPERVISED_FINE_TUNING"){const C=r(i,["adapterSize"]);t!==void 0&&C!=null&&c(t,["supervisedTuningSpec","hyperParameters","adapterSize"],C)}else if(v==="PREFERENCE_TUNING"){const C=r(i,["adapterSize"]);t!==void 0&&C!=null&&c(t,["preferenceOptimizationSpec","hyperParameters","adapterSize"],C)}if(r(i,["batchSize"])!==void 0)throw new Error("batchSize parameter is not supported in Vertex AI.");if(r(i,["learningRate"])!==void 0)throw new Error("learningRate parameter is not supported in Vertex AI.");const S=r(i,["labels"]);t!==void 0&&S!=null&&c(t,["labels"],S);const E=r(i,["beta"]);return t!==void 0&&E!=null&&c(t,["preferenceOptimizationSpec","hyperParameters","beta"],E),a}function zA(i,t){const l={},a=r(i,["baseModel"]);a!=null&&c(l,["baseModel"],a);const u=r(i,["preTunedModel"]);u!=null&&c(l,["preTunedModel"],u);const f=r(i,["trainingDataset"]);f!=null&&ZA(f);const m=r(i,["config"]);return m!=null&&qA(m,l),l}function BA(i,t){const l={},a=r(i,["baseModel"]);a!=null&&c(l,["baseModel"],a);const u=r(i,["preTunedModel"]);u!=null&&c(l,["preTunedModel"],u);const f=r(i,["trainingDataset"]);f!=null&&$A(f,l,t);const m=r(i,["config"]);return m!=null&&VA(m,l,t),l}function PA(i,t){const l={},a=r(i,["name"]);return a!=null&&c(l,["_url","name"],a),l}function OA(i,t){const l={},a=r(i,["name"]);return a!=null&&c(l,["_url","name"],a),l}function kA(i,t,l){const a={},u=r(i,["pageSize"]);t!==void 0&&u!=null&&c(t,["_query","pageSize"],u);const f=r(i,["pageToken"]);t!==void 0&&f!=null&&c(t,["_query","pageToken"],f);const m=r(i,["filter"]);return t!==void 0&&m!=null&&c(t,["_query","filter"],m),a}function FA(i,t,l){const a={},u=r(i,["pageSize"]);t!==void 0&&u!=null&&c(t,["_query","pageSize"],u);const f=r(i,["pageToken"]);t!==void 0&&f!=null&&c(t,["_query","pageToken"],f);const m=r(i,["filter"]);return t!==void 0&&m!=null&&c(t,["_query","filter"],m),a}function JA(i,t){const l={},a=r(i,["config"]);return a!=null&&kA(a,l),l}function YA(i,t){const l={},a=r(i,["config"]);return a!=null&&FA(a,l),l}function XA(i,t){const l={},a=r(i,["sdkHttpResponse"]);a!=null&&c(l,["sdkHttpResponse"],a);const u=r(i,["nextPageToken"]);u!=null&&c(l,["nextPageToken"],u);const f=r(i,["tunedModels"]);if(f!=null){let m=f;Array.isArray(m)&&(m=m.map(g=>Tg(g))),c(l,["tuningJobs"],m)}return l}function KA(i,t){const l={},a=r(i,["sdkHttpResponse"]);a!=null&&c(l,["sdkHttpResponse"],a);const u=r(i,["nextPageToken"]);u!=null&&c(l,["nextPageToken"],u);const f=r(i,["tuningJobs"]);if(f!=null){let m=f;Array.isArray(m)&&(m=m.map(g=>Ru(g))),c(l,["tuningJobs"],m)}return l}function QA(i,t){const l={},a=r(i,["name"]);a!=null&&c(l,["model"],a);const u=r(i,["name"]);return u!=null&&c(l,["endpoint"],u),l}function ZA(i,t){const l={};if(r(i,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");if(r(i,["vertexDatasetResource"])!==void 0)throw new Error("vertexDatasetResource parameter is not supported in Gemini API.");const a=r(i,["examples"]);if(a!=null){let u=a;Array.isArray(u)&&(u=u.map(f=>f)),c(l,["examples","examples"],u)}return l}function $A(i,t,l){const a={};let u=r(l,["config","method"]);if(u===void 0&&(u="SUPERVISED_FINE_TUNING"),u==="SUPERVISED_FINE_TUNING"){const m=r(i,["gcsUri"]);t!==void 0&&m!=null&&c(t,["supervisedTuningSpec","trainingDatasetUri"],m)}else if(u==="PREFERENCE_TUNING"){const m=r(i,["gcsUri"]);t!==void 0&&m!=null&&c(t,["preferenceOptimizationSpec","trainingDatasetUri"],m)}let f=r(l,["config","method"]);if(f===void 0&&(f="SUPERVISED_FINE_TUNING"),f==="SUPERVISED_FINE_TUNING"){const m=r(i,["vertexDatasetResource"]);t!==void 0&&m!=null&&c(t,["supervisedTuningSpec","trainingDatasetUri"],m)}else if(f==="PREFERENCE_TUNING"){const m=r(i,["vertexDatasetResource"]);t!==void 0&&m!=null&&c(t,["preferenceOptimizationSpec","trainingDatasetUri"],m)}if(r(i,["examples"])!==void 0)throw new Error("examples parameter is not supported in Vertex AI.");return a}function Tg(i,t){const l={},a=r(i,["sdkHttpResponse"]);a!=null&&c(l,["sdkHttpResponse"],a);const u=r(i,["name"]);u!=null&&c(l,["name"],u);const f=r(i,["state"]);f!=null&&c(l,["state"],Gh(f));const m=r(i,["createTime"]);m!=null&&c(l,["createTime"],m);const g=r(i,["tuningTask","startTime"]);g!=null&&c(l,["startTime"],g);const y=r(i,["tuningTask","completeTime"]);y!=null&&c(l,["endTime"],y);const h=r(i,["updateTime"]);h!=null&&c(l,["updateTime"],h);const v=r(i,["description"]);v!=null&&c(l,["description"],v);const S=r(i,["baseModel"]);S!=null&&c(l,["baseModel"],S);const E=r(i,["_self"]);return E!=null&&c(l,["tunedModel"],QA(E)),l}function Ru(i,t){const l={},a=r(i,["sdkHttpResponse"]);a!=null&&c(l,["sdkHttpResponse"],a);const u=r(i,["name"]);u!=null&&c(l,["name"],u);const f=r(i,["state"]);f!=null&&c(l,["state"],Gh(f));const m=r(i,["createTime"]);m!=null&&c(l,["createTime"],m);const g=r(i,["startTime"]);g!=null&&c(l,["startTime"],g);const y=r(i,["endTime"]);y!=null&&c(l,["endTime"],y);const h=r(i,["updateTime"]);h!=null&&c(l,["updateTime"],h);const v=r(i,["error"]);v!=null&&c(l,["error"],v);const S=r(i,["description"]);S!=null&&c(l,["description"],S);const E=r(i,["baseModel"]);E!=null&&c(l,["baseModel"],E);const C=r(i,["tunedModel"]);C!=null&&c(l,["tunedModel"],C);const w=r(i,["preTunedModel"]);w!=null&&c(l,["preTunedModel"],w);const G=r(i,["supervisedTuningSpec"]);G!=null&&c(l,["supervisedTuningSpec"],G);const x=r(i,["preferenceOptimizationSpec"]);x!=null&&c(l,["preferenceOptimizationSpec"],x);const B=r(i,["tuningDataStats"]);B!=null&&c(l,["tuningDataStats"],B);const Y=r(i,["encryptionSpec"]);Y!=null&&c(l,["encryptionSpec"],Y);const P=r(i,["partnerModelTuningSpec"]);P!=null&&c(l,["partnerModelTuningSpec"],P);const Q=r(i,["customBaseModel"]);Q!=null&&c(l,["customBaseModel"],Q);const j=r(i,["experiment"]);j!=null&&c(l,["experiment"],j);const W=r(i,["labels"]);W!=null&&c(l,["labels"],W);const F=r(i,["outputUri"]);F!=null&&c(l,["outputUri"],F);const ee=r(i,["pipelineJob"]);ee!=null&&c(l,["pipelineJob"],ee);const X=r(i,["serviceAccount"]);X!=null&&c(l,["serviceAccount"],X);const re=r(i,["tunedModelDisplayName"]);re!=null&&c(l,["tunedModelDisplayName"],re);const ye=r(i,["veoTuningSpec"]);return ye!=null&&c(l,["veoTuningSpec"],ye),l}function WA(i,t){const l={},a=r(i,["sdkHttpResponse"]);a!=null&&c(l,["sdkHttpResponse"],a);const u=r(i,["name"]);u!=null&&c(l,["name"],u);const f=r(i,["metadata"]);f!=null&&c(l,["metadata"],f);const m=r(i,["done"]);m!=null&&c(l,["done"],m);const g=r(i,["error"]);return g!=null&&c(l,["error"],g),l}function Rh(i,t){const l={},a=r(i,["gcsUri"]);a!=null&&c(l,["validationDatasetUri"],a);const u=r(i,["vertexDatasetResource"]);return u!=null&&c(l,["validationDatasetUri"],u),l}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class jA extends mn{constructor(t){super(),this.apiClient=t,this.list=async(l={})=>new ui(pn.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 u={tunedModelName:l.baseModel};!((a=l.config)===null||a===void 0)&&a.preTunedModelCheckpointId&&(u.checkpointId=l.config.preTunedModelCheckpointId);const f=Object.assign(Object.assign({},l),{preTunedModel:u});return f.baseModel=void 0,await this.tuneInternal(f)}else{const u=Object.assign({},l);return await this.tuneInternal(u)}else{const u=Object.assign({},l),f=await this.tuneMldevInternal(u);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:pu.JOB_STATE_QUEUED}}}}async getInternal(t){var l,a,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=OA(t);return g=J("{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=>Ru(v))}else{const h=PA(t);return g=J("{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:(u=t.config)===null||u===void 0?void 0:u.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=>Tg(v))}}async listInternal(t){var l,a,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=YA(t);return g=J("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=KA(v),E=new $m;return Object.assign(E,S),E})}else{const h=JA(t);return g=J("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:(u=t.config)===null||u===void 0?void 0:u.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=XA(v),E=new $m;return Object.assign(E,S),E})}}async cancel(t){var l,a,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=LA(t);return g=J("{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=HA(v),E=new Wm;return Object.assign(E,S),E})}else{const h=bA(t);return g=J("{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:(u=t.config)===null||u===void 0?void 0:u.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=GA(v),E=new Wm;return Object.assign(E,S),E})}}async tuneInternal(t){var l,a;let u,f="",m={};if(this.apiClient.isVertexAI()){const g=BA(t,t);return f=J("tuningJobs",g._url),m=g._query,delete g._url,delete g._query,u=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})),u.then(y=>Ru(y))}else throw new Error("This method is only supported by the Vertex AI.")}async tuneMldevInternal(t){var l,a;let u,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=zA(t);return f=J("tunedModels",g._url),m=g._query,delete g._url,delete g._query,u=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})),u.then(y=>WA(y))}}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class eR{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 tR=1024*1024*8,nR=3,iR=1e3,oR=2,wa="x-goog-upload-status";async function lR(i,t,l){var a;const u=await Sg(i,t,l),f=await(u==null?void 0:u.json());if(((a=u==null?void 0:u.headers)===null||a===void 0?void 0:a[wa])!=="final")throw new Error("Failed to upload file: Upload status is not finalized.");return f.file}async function aR(i,t,l){var a;const u=await Sg(i,t,l),f=await(u==null?void 0:u.json());if(((a=u==null?void 0:u.headers)===null||a===void 0?void 0:a[wa])!=="final")throw new Error("Failed to upload file: Upload status is not finalized.");const m=Dh(f),g=new Du;return Object.assign(g,m),g}async function Sg(i,t,l){var a,u;let f=0,m=0,g=new mu(new Response),y="upload";for(f=i.size;m=f&&(y+=", finalize");let S=0,E=iR;for(;SsetTimeout(t,i))}class uR{async upload(t,l,a){if(typeof t=="string")throw new Error("File path is not supported in browser uploader.");return await lR(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 aR(t,l,a)}async stat(t){if(typeof t=="string")throw new Error("File path is not supported in browser uploader.");return await sR(t)}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */class cR{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 Mh="x-goog-api-key";class dR{constructor(t){this.apiKey=t}async addAuthHeaders(t,l){if(t.get(Mh)===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(Mh,this.apiKey)}}}/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */const pR="gl-node/";class mR{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 Ze({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=r0(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 u=new dR(this.apiKey);this.apiClient=new sC({auth:u,apiVersion:this.apiVersion,apiKey:this.apiKey,vertexai:this.vertexai,httpOptions:this.httpOptions,userAgentExtra:pR+"web",uploader:new uR,downloader:new eR}),this.models=new MC(this.apiClient),this.live=new SC(this.apiClient,u,new cR),this.batches=new qT(this.apiClient),this.chats=new vS(this.models,this.apiClient),this.caches=new hS(this.apiClient),this.files=new IS(this.apiClient),this.operations=new NC(this.apiClient),this.authTokens=new kC(this.apiClient),this.tunings=new jA(this.apiClient),this.fileSearchStores=new $C(this.apiClient)}}const hR=i=>{let t="";const l=i.byteLength;for(let a=0;a{const t=atob(i),l=t.length,a=new Uint8Array(l);for(let u=0;u{try{const i=window.parent.location.pathname;return{path:i,info:fu[i]||fu["/"]}}catch{return{path:"/",info:fu["/"]}}},yR=i=>{try{window.parent.location.href=i}catch(t){console.error("Navigation failed:",t)}},vR=({systemInstruction:i})=>{const[t,l]=at.useState(!1),[a,u]=at.useState(!1),[f,m]=at.useState(!1),[g,y]=at.useState(Nh()),h=at.useRef(null),v=at.useRef(null),S=at.useRef(null),E=at.useRef(0),C=at.useRef(new Set),w=at.useRef(null);at.useEffect(()=>{const ee=()=>y(Nh());return ee(),window.addEventListener("focus",ee),()=>window.removeEventListener("focus",ee)},[]);const G=at.useRef([]),x=at.useRef(!1),B=at.useRef(null),Y=3,P=async()=>{const ee=v.current;if(!ee||G.current.length===0){x.current=!1;return}ee.state==="suspended"&&await ee.resume();const X=G.current;G.current=[];const re=X.reduce((be,b)=>be+b.length,0),ye=new Float32Array(re);let Ae=0;for(const be of X)ye.set(be,Ae),Ae+=be.length;const ue=ee.createBuffer(1,re,24e3);ue.getChannelData(0).set(ye);const ve=ee.createBufferSource();ve.buffer=ue,ve.connect(ee.destination),C.current.add(ve),ve.onended=()=>{C.current.delete(ve),G.current.length>0?P():(x.current=!1,m(!1))},ve.start(0)},Q=()=>{B.current&&clearTimeout(B.current),!x.current&&(G.current.length>=Y?(x.current=!0,P()):B.current=setTimeout(()=>{G.current.length>0&&!x.current&&(x.current=!0,P())},300))},j=()=>{G.current=[],x.current=!1,B.current&&(clearTimeout(B.current),B.current=null),C.current.forEach(ee=>{try{ee.stop()}catch{}}),C.current.clear(),E.current=0,m(!1)},W=()=>{S.current&&(S.current.close(),S.current=null),w.current&&(w.current.getTracks().forEach(ee=>ee.stop()),w.current=null),h.current&&(h.current.close(),h.current=null),v.current&&(v.current.close(),v.current=null),j(),l(!1),u(!1)},F=async()=>{if(!(a||t)){u(!0);try{const ee=new mR({apiKey:"AIzaSyAjk6QbBjF2M5PwqH2g7UrfDHFCiDJHPAI"}),X=new(window.AudioContext||window.webkitAudioContext)({sampleRate:16e3}),re=new(window.AudioContext||window.webkitAudioContext)({sampleRate:24e3});h.current=X,v.current=re;const ye=await navigator.mediaDevices.getUserMedia({audio:!0});w.current=ye;const Ae=ee.live.connect({model:"gemini-2.5-flash-native-audio-preview-12-2025",callbacks:{onopen:()=>{l(!0),u(!1),Ae.then(be=>{be.sendClientContent({turns:[{role:"user",parts:[{text:"שלום! ברכי אותי בקצרה והצעי עזרה."}]}],turnComplete:!0})});const ue=X.createMediaStreamSource(ye),ve=X.createScriptProcessor(4096,1,1);ve.onaudioprocess=be=>{if(x.current||C.current.size>0)return;const b=be.inputBuffer.getChannelData(0),O=b.length,ne=new Int16Array(O);for(let fe=0;fe{fe.sendRealtimeInput({media:Se})})},ue.connect(ve),ve.connect(X.destination)},onmessage:async ue=>{var b,O,ne,Se,fe,M;const ve=ue.toolCall;if(ve){console.log("Tool call received:",ve);const V=ve.functionCalls;if(V){for(const k of V)if(k.name==="navigate_to_page"){const K=(b=k.args)==null?void 0:b.path;if(K){console.log("Navigation requested to:",K);try{await(await Ae).sendToolResponse({functionResponses:[{id:k.id,name:k.name,response:{success:!0,message:`מנווט ל-${K}`}}]}),console.log("Tool response sent successfully")}catch(oe){console.error("Error sending tool response:",oe)}setTimeout(()=>{console.log("Executing navigation to:",K),yR(K)},2500)}}}}const be=(fe=(Se=(ne=(O=ue.serverContent)==null?void 0:O.modelTurn)==null?void 0:ne.parts[0])==null?void 0:Se.inlineData)==null?void 0:fe.data;if(be){m(!0);const V=gR(be),k=new Int16Array(V.buffer),K=new Float32Array(k.length);for(let oe=0;oe{console.error("Assistant Error:",ue),W()},onclose:()=>{W()}},config:{responseModalities:[tl.AUDIO],speechConfig:{voiceConfig:{prebuiltVoiceConfig:{voiceName:"Kore"}}},tools:[{functionDeclarations:[{name:"navigate_to_page",description:"Navigate the user to a different page on the MyStory website. Use this when the user asks to go to a specific page or section.",parameters:{type:"object",properties:{path:{type:"string",description:"The path to navigate to. Must be one of: /, /shop.html, /pricing.html, /how-it-works.html, /about.html, /contact.html, /faq.html, /create.html, /book-demo.html, /reviews.html, /gift-card.html, /kindergartens.html"}},required:["path"]}}]}],systemInstruction:i+` דברי רק בעברית תקנית, רהוטה ונעימה מאוד. את זמרת קולית מיומנת. הקפידי על הגייה נכונה של כל מילה. אם מבקשים ממך לשיר, שירי בלחן וקצב נעימים המותאמים לילדים. מיקום נוכחי: את נמצאת כרגע בדף "${g.info.name}" (${g.path}). יש לך כלי ניווט! כשמשתמש מבקש לעבור לדף אחר, השתמשי בכלי navigate_to_page. אמרי "מעבירה אותך לדף X" והשתמשי בכלי. מפת האתר - הדפים שאת יכולה לנווט אליהם: - דף הבית (path: /) - העמוד הראשי - חנות הספרים (path: /shop.html) - כל הספרים שלנו - מחירים (path: /pricing.html) - מחירי הספרים - איך זה עובד (path: /how-it-works.html) - הסבר על התהליך - מי אנחנו (path: /about.html) - על החברה - צור קשר (path: /contact.html) - פרטי התקשרות - שאלות נפוצות (path: /faq.html) - תשובות לשאלות - יצירת ספר (path: /create.html) - התחלת יצירת ספר חדש - ספר לדוגמא (path: /book-demo.html) - צפייה בספר לדוגמא - ביקורות (path: /reviews.html) - מה אומרים הלקוחות - כרטיס מתנה (path: /gift-card.html) - רכישת כרטיס מתנה - גני ילדים (path: /kindergartens.html) - מבצעים לגנים הספרים שלנו בחנות: 1. "הגיבור שבי" - ספר גיבורי על 2. "המסע לכוכב הרחוק" - הרפתקה בחלל 3. "בג'ונגל עם החיות" - הרפתקה בטבע 4. "אגדת חד הקרן" - הרפתקת פנטזיה מחירים: - ספר דיגיטלי: 49 ש"ח - כריכה רכה: 99 ש"ח - כריכה קשה: 149 ש"ח - משלוח חינם! דוגמאות לניווט: - "אני רוצה לראות את המחירים" -> השתמשי בכלי עם path: /pricing.html - "קחי אותי לחנות" -> השתמשי בכלי עם path: /shop.html - "אני רוצה ליצור ספר" -> השתמשי בכלי עם path: /create.html`}});S.current=await Ae}catch(ee){console.error("Failed to initialize assistant:",ee),W()}}};return qe.jsxs("div",{className:"fixed bottom-10 right-10 z-[1000] group",children:[t&&qe.jsxs("div",{className:"absolute bottom-full right-0 mb-4 bg-white/95 backdrop-blur-md p-5 rounded-3xl shadow-2xl border border-purple-100 min-w-[280px] animate-fade-up",children:[qe.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[qe.jsx("div",{className:`w-3 h-3 rounded-full ${f?"bg-green-500 animate-pulse":"bg-purple-400"}`}),qe.jsx("span",{className:"font-bold text-purple-900 text-lg",children:"MyStory 🎤"})]}),qe.jsx("p",{className:"text-purple-700/80 text-sm leading-relaxed",children:f?"מִיָּה מדברת איתך עכשיו...":"מִיָּה מקשיבה לך! דברו איתי בעברית."}),qe.jsx("div",{className:"flex gap-1.5 mt-4 items-end h-8",children:[...Array(8)].map((ee,X)=>qe.jsx("div",{className:"flex-1 bg-gradient-to-t from-purple-600 to-pink-400 rounded-full transition-all duration-300",style:{height:f?`${20+Math.random()*80}%`:"15%",animationDelay:`${X*.1}s`}},X))})]}),qe.jsxs("button",{onClick:t?W:F,disabled:a,"aria-label":t?"עצור סוכן קולי":"הפעל סוכן קולי",className:`relative w-20 h-20 rounded-full flex items-center justify-center shadow-[0_10px_40px_rgba(94,53,177,0.3)] transition-all duration-500 hover:scale-110 active:scale-95 overflow-hidden ${t?"bg-gradient-to-br from-red-500 to-pink-600":"bg-gradient-to-br from-[#5E35B1] to-[#8e24aa] animate-pulse-glow"} ${a?"opacity-70 grayscale cursor-not-allowed":""}`,children:[!t&&!a&&qe.jsxs(qe.Fragment,{children:[qe.jsx("div",{className:"absolute inset-0 rounded-full bg-purple-500 animate-ping-slow opacity-30"}),qe.jsx("div",{className:"absolute inset-[-4px] rounded-full border-2 border-purple-400 animate-pulse-ring opacity-50"})]}),qe.jsx("div",{className:"absolute inset-0 bg-white/10 opacity-0 group-hover:opacity-100 transition-opacity"}),a?qe.jsx("div",{className:"w-8 h-8 border-4 border-white/30 border-t-white rounded-full animate-spin"}):t?qe.jsx("svg",{className:"w-8 h-8 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:qe.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.5,d:"M6 18L18 6M6 6l12 12"})}):qe.jsxs("div",{className:"relative",children:[qe.jsx("span",{className:"text-4xl",children:"🎙️"}),qe.jsx("div",{className:"absolute -top-1 -right-1 w-3 h-3 bg-pink-400 rounded-full animate-ping"})]})]}),qe.jsx("style",{children:` @keyframes fade-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } } .animate-fade-up { animation: fade-up 0.4s ease-out forwards; } @keyframes pulse-glow { 0%, 100% { box-shadow: 0 0 20px rgba(139, 92, 246, 0.4), 0 10px 40px rgba(94, 53, 177, 0.3); } 50% { box-shadow: 0 0 40px rgba(139, 92, 246, 0.6), 0 10px 50px rgba(94, 53, 177, 0.5); } } .animate-pulse-glow { animation: pulse-glow 2s ease-in-out infinite; } @keyframes ping-slow { 0% { transform: scale(1); opacity: 0.3; } 75%, 100% { transform: scale(1.5); opacity: 0; } } .animate-ping-slow { animation: ping-slow 2s cubic-bezier(0, 0, 0.2, 1) infinite; } @keyframes pulse-ring { 0%, 100% { transform: scale(1); opacity: 0.5; } 50% { transform: scale(1.1); opacity: 0.3; } } .animate-pulse-ring { animation: pulse-ring 2s ease-in-out infinite; } `})]})},TR=()=>qe.jsx(vR,{systemInstruction:i0}),Eg=document.getElementById("root");if(!Eg)throw new Error("Could not find root element to mount to");const SR=n0.createRoot(Eg);SR.render(qe.jsx(Kv.StrictMode,{children:qe.jsx(TR,{})}));