diff --git "a/assets/index-B27E2HQm.js" "b/assets/index-B27E2HQm.js" new file mode 100644--- /dev/null +++ "b/assets/index-B27E2HQm.js" @@ -0,0 +1,301 @@ +(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))a(r);new MutationObserver(r=>{for(const d of r)if(d.type==="childList")for(const m of d.addedNodes)m.tagName==="LINK"&&m.rel==="modulepreload"&&a(m)}).observe(document,{childList:!0,subtree:!0});function o(r){const d={};return r.integrity&&(d.integrity=r.integrity),r.referrerPolicy&&(d.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?d.credentials="include":r.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function a(r){if(r.ep)return;r.ep=!0;const d=o(r);fetch(r.href,d)}})();function $m(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Ou={exports:{}},kl={};/** + * @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 yp;function jy(){if(yp)return kl;yp=1;var i=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function o(a,r,d){var m=null;if(d!==void 0&&(m=""+d),r.key!==void 0&&(m=""+r.key),"key"in r){d={};for(var g in r)g!=="key"&&(d[g]=r[g])}else d=r;return r=d.ref,{$$typeof:i,type:a,key:m,ref:r!==void 0?r:null,props:d}}return kl.Fragment=n,kl.jsx=o,kl.jsxs=o,kl}var vp;function e0(){return vp||(vp=1,Ou.exports=jy()),Ou.exports}var N=e0(),Fu={exports:{}},se={};/** + * @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 Tp;function t0(){if(Tp)return se;Tp=1;var i=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),d=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"),_=Symbol.iterator;function M(A){return A===null||typeof A!="object"?null:(A=_&&A[_]||A["@@iterator"],typeof A=="function"?A:null)}var z={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},P=Object.assign,O={};function k(A,L,K){this.props=A,this.context=L,this.refs=O,this.updater=K||z}k.prototype.isReactComponent={},k.prototype.setState=function(A,L){if(typeof A!="object"&&typeof A!="function"&&A!=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,A,L,"setState")},k.prototype.forceUpdate=function(A){this.updater.enqueueForceUpdate(this,A,"forceUpdate")};function F(){}F.prototype=k.prototype;function B(A,L,K){this.props=A,this.context=L,this.refs=O,this.updater=K||z}var Q=B.prototype=new F;Q.constructor=B,P(Q,k.prototype),Q.isPureReactComponent=!0;var ne=Array.isArray;function W(){}var J={H:null,A:null,T:null,S:null},he=Object.prototype.hasOwnProperty;function ee(A,L,K){var Z=K.ref;return{$$typeof:i,type:A,key:L,ref:Z!==void 0?Z:null,props:K}}function re(A,L){return ee(A.type,L,A.props)}function de(A){return typeof A=="object"&&A!==null&&A.$$typeof===i}function ce(A){var L={"=":"=0",":":"=2"};return"$"+A.replace(/[=:]/g,function(K){return L[K]})}var He=/\/+/g;function We(A,L){return typeof A=="object"&&A!==null&&A.key!=null?ce(""+A.key):L.toString(36)}function Ve(A){switch(A.status){case"fulfilled":return A.value;case"rejected":throw A.reason;default:switch(typeof A.status=="string"?A.then(W,W):(A.status="pending",A.then(function(L){A.status==="pending"&&(A.status="fulfilled",A.value=L)},function(L){A.status==="pending"&&(A.status="rejected",A.reason=L)})),A.status){case"fulfilled":return A.value;case"rejected":throw A.reason}}throw A}function U(A,L,K,Z,ae){var ue=typeof A;(ue==="undefined"||ue==="boolean")&&(A=null);var pe=!1;if(A===null)pe=!0;else switch(ue){case"bigint":case"string":case"number":pe=!0;break;case"object":switch(A.$$typeof){case i:case n:pe=!0;break;case v:return pe=A._init,U(pe(A._payload),L,K,Z,ae)}}if(pe)return ae=ae(A),pe=Z===""?"."+We(A,0):Z,ne(ae)?(K="",pe!=null&&(K=pe.replace(He,"$&/")+"/"),U(ae,L,K,"",function(Qi){return Qi})):ae!=null&&(de(ae)&&(ae=re(ae,K+(ae.key==null||A&&A.key===ae.key?"":(""+ae.key).replace(He,"$&/")+"/")+pe)),L.push(ae)),1;pe=0;var Xe=Z===""?".":Z+":";if(ne(A))for(var Be=0;Be>>1,le=U[te];if(0>>1;ter(K,Y))Zr(ae,K)?(U[te]=ae,U[Z]=Y,te=Z):(U[te]=K,U[L]=Y,te=L);else if(Zr(ae,Y))U[te]=ae,U[Z]=Y,te=Z;else break e}}return b}function r(U,b){var Y=U.sortIndex-b.sortIndex;return Y!==0?Y:U.id-b.id}if(i.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var d=performance;i.unstable_now=function(){return d.now()}}else{var m=Date,g=m.now();i.unstable_now=function(){return m.now()-g}}var y=[],h=[],v=1,S=null,_=3,M=!1,z=!1,P=!1,O=!1,k=typeof setTimeout=="function"?setTimeout:null,F=typeof clearTimeout=="function"?clearTimeout:null,B=typeof setImmediate<"u"?setImmediate:null;function Q(U){for(var b=o(h);b!==null;){if(b.callback===null)a(h);else if(b.startTime<=U)a(h),b.sortIndex=b.expirationTime,n(y,b);else break;b=o(h)}}function ne(U){if(P=!1,Q(U),!z)if(o(y)!==null)z=!0,W||(W=!0,ce());else{var b=o(h);b!==null&&Ve(ne,b.startTime-U)}}var W=!1,J=-1,he=5,ee=-1;function re(){return O?!0:!(i.unstable_now()-eeU&&re());){var te=S.callback;if(typeof te=="function"){S.callback=null,_=S.priorityLevel;var le=te(S.expirationTime<=U);if(U=i.unstable_now(),typeof le=="function"){S.callback=le,Q(U),b=!0;break t}S===o(y)&&a(y),Q(U)}else a(y);S=o(y)}if(S!==null)b=!0;else{var A=o(h);A!==null&&Ve(ne,A.startTime-U),b=!1}}break e}finally{S=null,_=Y,M=!1}b=void 0}}finally{b?ce():W=!1}}}var ce;if(typeof B=="function")ce=function(){B(de)};else if(typeof MessageChannel<"u"){var He=new MessageChannel,We=He.port2;He.port1.onmessage=de,ce=function(){We.postMessage(null)}}else ce=function(){k(de,0)};function Ve(U,b){J=k(function(){U(i.unstable_now())},b)}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(U){U.callback=null},i.unstable_forceFrameRate=function(U){0>U||125te?(U.sortIndex=Y,n(h,U),o(y)===null&&U===o(h)&&(P?(F(J),J=-1):P=!0,Ve(ne,Y-te))):(U.sortIndex=le,n(y,U),z||M||(z=!0,W||(W=!0,ce()))),U},i.unstable_shouldYield=re,i.unstable_wrapCallback=function(U){var b=_;return function(){var Y=_;_=b;try{return U.apply(this,arguments)}finally{_=Y}}}})(Ku)),Ku}var _p;function l0(){return _p||(_p=1,Ju.exports=i0()),Ju.exports}var Xu={exports:{}},lt={};/** + * @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 Cp;function o0(){if(Cp)return lt;Cp=1;var i=or();function n(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(n){console.error(n)}}return i(),Xu.exports=o0(),Xu.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 Rp;function s0(){if(Rp)return Ol;Rp=1;var i=l0(),n=or(),o=a0();function a(e){var t="https://react.dev/errors/"+e;if(1le||(e.current=te[le],te[le]=null,le--)}function K(e,t){le++,te[le]=e.current,e.current=t}var Z=A(null),ae=A(null),ue=A(null),pe=A(null);function Xe(e,t){switch(K(ue,t),K(ae,e),K(Z,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Pd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Pd(t),e=Bd(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}L(Z),K(Z,e)}function Be(){L(Z),L(ae),L(ue)}function Qi(e){e.memoizedState!==null&&K(pe,e);var t=Z.current,l=Bd(t,e.type);t!==l&&(K(ae,e),K(Z,l))}function Jl(e){ae.current===e&&(L(Z),L(ae)),pe.current===e&&(L(pe),Vl._currentValue=Y)}var Ra,hr;function Vn(e){if(Ra===void 0)try{throw Error()}catch(l){var t=l.stack.trim().match(/\n( *(at )?)/);Ra=t&&t[1]||"",hr=-1)":-1f||C[s]!==I[f]){var G=` +`+C[s].replace(" at new "," at ");return e.displayName&&G.includes("")&&(G=G.replace("",e.displayName)),G}while(1<=s&&0<=f);break}}}finally{Ma=!1,Error.prepareStackTrace=l}return(l=e?e.displayName||e.name:"")?Vn(l):""}function Ih(e,t){switch(e.tag){case 26:case 27:case 5:return Vn(e.type);case 16:return Vn("Lazy");case 13:return e.child!==t&&t!==null?Vn("Suspense Fallback"):Vn("Suspense");case 19:return Vn("SuspenseList");case 0:case 15:return Na(e.type,!1);case 11:return Na(e.type.render,!1);case 1:return Na(e.type,!0);case 31:return Vn("Activity");default:return""}}function gr(e){try{var t="",l=null;do t+=Ih(e,l),l=e,e=e.return;while(e);return t}catch(s){return` +Error generating stack: `+s.message+` +`+s.stack}}var xa=Object.prototype.hasOwnProperty,Da=i.unstable_scheduleCallback,Ia=i.unstable_cancelCallback,Uh=i.unstable_shouldYield,wh=i.unstable_requestPaint,mt=i.unstable_now,bh=i.unstable_getCurrentPriorityLevel,yr=i.unstable_ImmediatePriority,vr=i.unstable_UserBlockingPriority,Kl=i.unstable_NormalPriority,qh=i.unstable_LowPriority,Tr=i.unstable_IdlePriority,Lh=i.log,Gh=i.unstable_setDisableYieldValue,Zi=null,ht=null;function dn(e){if(typeof Lh=="function"&&Gh(e),ht&&typeof ht.setStrictMode=="function")try{ht.setStrictMode(Zi,e)}catch{}}var gt=Math.clz32?Math.clz32:zh,Hh=Math.log,Vh=Math.LN2;function zh(e){return e>>>=0,e===0?32:31-(Hh(e)/Vh|0)|0}var Xl=256,Ql=262144,Zl=4194304;function zn(e){var t=e&42;if(t!==0)return t;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 $l(e,t,l){var s=e.pendingLanes;if(s===0)return 0;var f=0,p=e.suspendedLanes,T=e.pingedLanes;e=e.warmLanes;var E=s&134217727;return E!==0?(s=E&~p,s!==0?f=zn(s):(T&=E,T!==0?f=zn(T):l||(l=E&~e,l!==0&&(f=zn(l))))):(E=s&~p,E!==0?f=zn(E):T!==0?f=zn(T):l||(l=s&~e,l!==0&&(f=zn(l)))),f===0?0:t!==0&&t!==f&&(t&p)===0&&(p=f&-f,l=t&-t,p>=l||p===32&&(l&4194048)!==0)?t:f}function $i(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Ph(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+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 t+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 Sr(){var e=Zl;return Zl<<=1,(Zl&62914560)===0&&(Zl=4194304),e}function Ua(e){for(var t=[],l=0;31>l;l++)t.push(e);return t}function Wi(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Bh(e,t,l,s,f,p){var T=e.pendingLanes;e.pendingLanes=l,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=l,e.entangledLanes&=l,e.errorRecoveryDisabledLanes&=l,e.shellSuspendCounter=0;var E=e.entanglements,C=e.expirationTimes,I=e.hiddenUpdates;for(l=T&~l;0"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var Kh=/[\n"\\]/g;function Rt(e){return e.replace(Kh,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function Ha(e,t,l,s,f,p,T,E){e.name="",T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"?e.type=T:e.removeAttribute("type"),t!=null?T==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+At(t)):e.value!==""+At(t)&&(e.value=""+At(t)):T!=="submit"&&T!=="reset"||e.removeAttribute("value"),t!=null?Va(e,T,At(t)):l!=null?Va(e,T,At(l)):s!=null&&e.removeAttribute("value"),f==null&&p!=null&&(e.defaultChecked=!!p),f!=null&&(e.checked=f&&typeof f!="function"&&typeof f!="symbol"),E!=null&&typeof E!="function"&&typeof E!="symbol"&&typeof E!="boolean"?e.name=""+At(E):e.removeAttribute("name")}function br(e,t,l,s,f,p,T,E){if(p!=null&&typeof p!="function"&&typeof p!="symbol"&&typeof p!="boolean"&&(e.type=p),t!=null||l!=null){if(!(p!=="submit"&&p!=="reset"||t!=null)){Ga(e);return}l=l!=null?""+At(l):"",t=t!=null?""+At(t):l,E||t===e.value||(e.value=t),e.defaultValue=t}s=s??f,s=typeof s!="function"&&typeof s!="symbol"&&!!s,e.checked=E?e.checked:!!s,e.defaultChecked=!!s,T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"&&(e.name=T),Ga(e)}function Va(e,t,l){t==="number"&&eo(e.ownerDocument)===e||e.defaultValue===""+l||(e.defaultValue=""+l)}function ri(e,t,l,s){if(e=e.options,t){t={};for(var f=0;f"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Oa=!1;if(Jt)try{var nl={};Object.defineProperty(nl,"passive",{get:function(){Oa=!0}}),window.addEventListener("test",nl,nl),window.removeEventListener("test",nl,nl)}catch{Oa=!1}var mn=null,Fa=null,no=null;function Pr(){if(no)return no;var e,t=Fa,l=t.length,s,f="value"in mn?mn.value:mn.textContent,p=f.length;for(e=0;e=ol),Jr=" ",Kr=!1;function Xr(e,t){switch(e){case"keyup":return Eg.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Qr(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var pi=!1;function Cg(e,t){switch(e){case"compositionend":return Qr(t);case"keypress":return t.which!==32?null:(Kr=!0,Jr);case"textInput":return e=t.data,e===Jr&&Kr?null:e;default:return null}}function Ag(e,t){if(pi)return e==="compositionend"||!Qa&&Xr(e,t)?(e=Pr(),no=Fa=mn=null,pi=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:l,offset:t-e};e=s}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=ic(l)}}function oc(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?oc(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function ac(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=eo(e.document);t instanceof e.HTMLIFrameElement;){try{var l=typeof t.contentWindow.location.href=="string"}catch{l=!1}if(l)e=t.contentWindow;else break;t=eo(e.document)}return t}function Wa(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}var wg=Jt&&"documentMode"in document&&11>=document.documentMode,mi=null,ja=null,rl=null,es=!1;function sc(e,t,l){var s=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;es||mi==null||mi!==eo(s)||(s=mi,"selectionStart"in s&&Wa(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}),rl&&ul(rl,s)||(rl=s,s=Zo(ja,"onSelect"),0>=T,f-=T,zt=1<<32-gt(t)+f|l<me?(Te=j,j=null):Te=j.sibling;var Ce=w(x,j,D[me],H);if(Ce===null){j===null&&(j=Te);break}e&&j&&Ce.alternate===null&&t(x,j),R=p(Ce,R,me),_e===null?ie=Ce:_e.sibling=Ce,_e=Ce,j=Te}if(me===D.length)return l(x,j),Se&&Xt(x,me),ie;if(j===null){for(;meme?(Te=j,j=null):Te=j.sibling;var Gn=w(x,j,Ce.value,H);if(Gn===null){j===null&&(j=Te);break}e&&j&&Gn.alternate===null&&t(x,j),R=p(Gn,R,me),_e===null?ie=Gn:_e.sibling=Gn,_e=Gn,j=Te}if(Ce.done)return l(x,j),Se&&Xt(x,me),ie;if(j===null){for(;!Ce.done;me++,Ce=D.next())Ce=V(x,Ce.value,H),Ce!==null&&(R=p(Ce,R,me),_e===null?ie=Ce:_e.sibling=Ce,_e=Ce);return Se&&Xt(x,me),ie}for(j=s(j);!Ce.done;me++,Ce=D.next())Ce=q(j,x,me,Ce.value,H),Ce!==null&&(e&&Ce.alternate!==null&&j.delete(Ce.key===null?me:Ce.key),R=p(Ce,R,me),_e===null?ie=Ce:_e.sibling=Ce,_e=Ce);return e&&j.forEach(function(Wy){return t(x,Wy)}),Se&&Xt(x,me),ie}function Ie(x,R,D,H){if(typeof D=="object"&&D!==null&&D.type===P&&D.key===null&&(D=D.props.children),typeof D=="object"&&D!==null){switch(D.$$typeof){case M:e:{for(var ie=D.key;R!==null;){if(R.key===ie){if(ie=D.type,ie===P){if(R.tag===7){l(x,R.sibling),H=f(R,D.props.children),H.return=x,x=H;break e}}else if(R.elementType===ie||typeof ie=="object"&&ie!==null&&ie.$$typeof===he&&Zn(ie)===R.type){l(x,R.sibling),H=f(R,D.props),hl(H,D),H.return=x,x=H;break e}l(x,R);break}else t(x,R);R=R.sibling}D.type===P?(H=Yn(D.props.children,x.mode,H,D.key),H.return=x,x=H):(H=po(D.type,D.key,D.props,null,x.mode,H),hl(H,D),H.return=x,x=H)}return T(x);case z:e:{for(ie=D.key;R!==null;){if(R.key===ie)if(R.tag===4&&R.stateNode.containerInfo===D.containerInfo&&R.stateNode.implementation===D.implementation){l(x,R.sibling),H=f(R,D.children||[]),H.return=x,x=H;break e}else{l(x,R);break}else t(x,R);R=R.sibling}H=ss(D,x.mode,H),H.return=x,x=H}return T(x);case he:return D=Zn(D),Ie(x,R,D,H)}if(Ve(D))return $(x,R,D,H);if(ce(D)){if(ie=ce(D),typeof ie!="function")throw Error(a(150));return D=ie.call(D),oe(x,R,D,H)}if(typeof D.then=="function")return Ie(x,R,So(D),H);if(D.$$typeof===B)return Ie(x,R,go(x,D),H);Eo(x,D)}return typeof D=="string"&&D!==""||typeof D=="number"||typeof D=="bigint"?(D=""+D,R!==null&&R.tag===6?(l(x,R.sibling),H=f(R,D),H.return=x,x=H):(l(x,R),H=as(D,x.mode,H),H.return=x,x=H),T(x)):l(x,R)}return function(x,R,D,H){try{ml=0;var ie=Ie(x,R,D,H);return Ri=null,ie}catch(j){if(j===Ai||j===vo)throw j;var _e=vt(29,j,null,x.mode);return _e.lanes=H,_e.return=x,_e}finally{}}}var Wn=Ic(!0),Uc=Ic(!1),Tn=!1;function Ts(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ss(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Sn(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function En(e,t,l){var s=e.updateQueue;if(s===null)return null;if(s=s.shared,(Re&2)!==0){var f=s.pending;return f===null?t.next=t:(t.next=f.next,f.next=t),s.pending=t,t=fo(e),mc(e,null,l),t}return co(e,s,t,l),fo(e)}function gl(e,t,l){if(t=t.updateQueue,t!==null&&(t=t.shared,(l&4194048)!==0)){var s=t.lanes;s&=e.pendingLanes,l|=s,t.lanes=l,_r(e,l)}}function Es(e,t){var l=e.updateQueue,s=e.alternate;if(s!==null&&(s=s.updateQueue,l===s)){var f=null,p=null;if(l=l.firstBaseUpdate,l!==null){do{var T={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};p===null?f=p=T:p=p.next=T,l=l.next}while(l!==null);p===null?f=p=t:p=p.next=t}else f=p=t;l={baseState:s.baseState,firstBaseUpdate:f,lastBaseUpdate:p,shared:s.shared,callbacks:s.callbacks},e.updateQueue=l;return}e=l.lastBaseUpdate,e===null?l.firstBaseUpdate=t:e.next=t,l.lastBaseUpdate=t}var _s=!1;function yl(){if(_s){var e=Ci;if(e!==null)throw e}}function vl(e,t,l,s){_s=!1;var f=e.updateQueue;Tn=!1;var p=f.firstBaseUpdate,T=f.lastBaseUpdate,E=f.shared.pending;if(E!==null){f.shared.pending=null;var C=E,I=C.next;C.next=null,T===null?p=I:T.next=I,T=C;var G=e.alternate;G!==null&&(G=G.updateQueue,E=G.lastBaseUpdate,E!==T&&(E===null?G.firstBaseUpdate=I:E.next=I,G.lastBaseUpdate=C))}if(p!==null){var V=f.baseState;T=0,G=I=C=null,E=p;do{var w=E.lane&-536870913,q=w!==E.lane;if(q?(ve&w)===w:(s&w)===w){w!==0&&w===_i&&(_s=!0),G!==null&&(G=G.next={lane:0,tag:E.tag,payload:E.payload,callback:null,next:null});e:{var $=e,oe=E;w=t;var Ie=l;switch(oe.tag){case 1:if($=oe.payload,typeof $=="function"){V=$.call(Ie,V,w);break e}V=$;break e;case 3:$.flags=$.flags&-65537|128;case 0:if($=oe.payload,w=typeof $=="function"?$.call(Ie,V,w):$,w==null)break e;V=S({},V,w);break e;case 2:Tn=!0}}w=E.callback,w!==null&&(e.flags|=64,q&&(e.flags|=8192),q=f.callbacks,q===null?f.callbacks=[w]:q.push(w))}else q={lane:w,tag:E.tag,payload:E.payload,callback:E.callback,next:null},G===null?(I=G=q,C=V):G=G.next=q,T|=w;if(E=E.next,E===null){if(E=f.shared.pending,E===null)break;q=E,E=q.next,q.next=null,f.lastBaseUpdate=q,f.shared.pending=null}}while(!0);G===null&&(C=V),f.baseState=C,f.firstBaseUpdate=I,f.lastBaseUpdate=G,p===null&&(f.shared.lanes=0),Mn|=T,e.lanes=T,e.memoizedState=V}}function wc(e,t){if(typeof e!="function")throw Error(a(191,e));e.call(t)}function bc(e,t){var l=e.callbacks;if(l!==null)for(e.callbacks=null,e=0;ep?p:8;var T=U.T,E={};U.T=E,Bs(e,!1,t,l);try{var C=f(),I=U.S;if(I!==null&&I(E,C),C!==null&&typeof C=="object"&&typeof C.then=="function"){var G=Bg(C,s);El(e,t,G,Ct(e))}else El(e,t,s,Ct(e))}catch(V){El(e,t,{then:function(){},status:"rejected",reason:V},Ct())}finally{b.p=p,T!==null&&E.types!==null&&(T.types=E.types),U.T=T}}function Kg(){}function zs(e,t,l,s){if(e.tag!==5)throw Error(a(476));var f=df(e).queue;ff(e,f,t,Y,l===null?Kg:function(){return pf(e),l(s)})}function df(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:Y,baseState:Y,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Wt,lastRenderedState:Y},next:null};var l={};return t.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Wt,lastRenderedState:l},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function pf(e){var t=df(e);t.next===null&&(t=e.alternate.memoizedState),El(e,t.next.queue,{},Ct())}function Ps(){return tt(Vl)}function mf(){return Oe().memoizedState}function hf(){return Oe().memoizedState}function Xg(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var l=Ct();e=Sn(l);var s=En(t,e,l);s!==null&&(pt(s,t,l),gl(s,t,l)),t={cache:hs()},e.payload=t;return}t=t.return}}function Qg(e,t,l){var s=Ct();l={lane:s,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Uo(e)?yf(t,l):(l=ls(e,t,l,s),l!==null&&(pt(l,e,s),vf(l,t,s)))}function gf(e,t,l){var s=Ct();El(e,t,l,s)}function El(e,t,l,s){var f={lane:s,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(Uo(e))yf(t,f);else{var p=e.alternate;if(e.lanes===0&&(p===null||p.lanes===0)&&(p=t.lastRenderedReducer,p!==null))try{var T=t.lastRenderedState,E=p(T,l);if(f.hasEagerState=!0,f.eagerState=E,yt(E,T))return co(e,t,f,0),we===null&&ro(),!1}catch{}finally{}if(l=ls(e,t,f,s),l!==null)return pt(l,e,s),vf(l,t,s),!0}return!1}function Bs(e,t,l,s){if(s={lane:2,revertLane:Tu(),gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null},Uo(e)){if(t)throw Error(a(479))}else t=ls(e,l,s,2),t!==null&&pt(t,e,2)}function Uo(e){var t=e.alternate;return e===fe||t!==null&&t===fe}function yf(e,t){Ni=Ao=!0;var l=e.pending;l===null?t.next=t:(t.next=l.next,l.next=t),e.pending=t}function vf(e,t,l){if((l&4194048)!==0){var s=t.lanes;s&=e.pendingLanes,l|=s,t.lanes=l,_r(e,l)}}var _l={readContext:tt,use:No,useCallback:ze,useContext:ze,useEffect:ze,useImperativeHandle:ze,useLayoutEffect:ze,useInsertionEffect:ze,useMemo:ze,useReducer:ze,useRef:ze,useState:ze,useDebugValue:ze,useDeferredValue:ze,useTransition:ze,useSyncExternalStore:ze,useId:ze,useHostTransitionStatus:ze,useFormState:ze,useActionState:ze,useOptimistic:ze,useMemoCache:ze,useCacheRefresh:ze};_l.useEffectEvent=ze;var Tf={readContext:tt,use:No,useCallback:function(e,t){return at().memoizedState=[e,t===void 0?null:t],e},useContext:tt,useEffect:tf,useImperativeHandle:function(e,t,l){l=l!=null?l.concat([e]):null,Do(4194308,4,af.bind(null,t,e),l)},useLayoutEffect:function(e,t){return Do(4194308,4,e,t)},useInsertionEffect:function(e,t){Do(4,2,e,t)},useMemo:function(e,t){var l=at();t=t===void 0?null:t;var s=e();if(jn){dn(!0);try{e()}finally{dn(!1)}}return l.memoizedState=[s,t],s},useReducer:function(e,t,l){var s=at();if(l!==void 0){var f=l(t);if(jn){dn(!0);try{l(t)}finally{dn(!1)}}}else f=t;return s.memoizedState=s.baseState=f,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:f},s.queue=e,e=e.dispatch=Qg.bind(null,fe,e),[s.memoizedState,e]},useRef:function(e){var t=at();return e={current:e},t.memoizedState=e},useState:function(e){e=qs(e);var t=e.queue,l=gf.bind(null,fe,t);return t.dispatch=l,[e.memoizedState,l]},useDebugValue:Hs,useDeferredValue:function(e,t){var l=at();return Vs(l,e,t)},useTransition:function(){var e=qs(!1);return e=ff.bind(null,fe,e.queue,!0,!1),at().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,l){var s=fe,f=at();if(Se){if(l===void 0)throw Error(a(407));l=l()}else{if(l=t(),we===null)throw Error(a(349));(ve&127)!==0||zc(s,t,l)}f.memoizedState=l;var p={value:l,getSnapshot:t};return f.queue=p,tf(Bc.bind(null,s,p,e),[e]),s.flags|=2048,Di(9,{destroy:void 0},Pc.bind(null,s,p,l,t),null),l},useId:function(){var e=at(),t=we.identifierPrefix;if(Se){var l=Pt,s=zt;l=(s&~(1<<32-gt(s)-1)).toString(32)+l,t="_"+t+"R_"+l,l=Ro++,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(f,{is:s.is}):T.createElement(f)}}p[je]=t,p[st]=s;e:for(T=t.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===t)break e;for(;T.sibling===null;){if(T.return===null||T.return===t)break e;T=T.return}T.sibling.return=T.return,T=T.sibling}t.stateNode=p;e:switch(it(p,f,s),f){case"button":case"input":case"select":case"textarea":s=!!s.autoFocus;break e;case"img":s=!0;break e;default:s=!1}s&&en(t)}}return qe(t),tu(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,l),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==s&&en(t);else{if(typeof s!="string"&&t.stateNode===null)throw Error(a(166));if(e=ue.current,Si(t)){if(e=t.stateNode,l=t.memoizedProps,s=null,f=et,f!==null)switch(f.tag){case 27:case 5:s=f.memoizedProps}e[je]=t,e=!!(e.nodeValue===l||s!==null&&s.suppressHydrationWarning===!0||Vd(e.nodeValue,l)),e||yn(t,!0)}else e=$o(e).createTextNode(s),e[je]=t,t.stateNode=e}return qe(t),null;case 31:if(l=t.memoizedState,e===null||e.memoizedState!==null){if(s=Si(t),l!==null){if(e===null){if(!s)throw Error(a(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(a(557));e[je]=t}else Jn(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;qe(t),e=!1}else l=fs(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=l),e=!0;if(!e)return t.flags&256?(St(t),t):(St(t),null);if((t.flags&128)!==0)throw Error(a(558))}return qe(t),null;case 13:if(s=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(f=Si(t),s!==null&&s.dehydrated!==null){if(e===null){if(!f)throw Error(a(318));if(f=t.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(a(317));f[je]=t}else Jn(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;qe(t),f=!1}else f=fs(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=f),f=!0;if(!f)return t.flags&256?(St(t),t):(St(t),null)}return St(t),(t.flags&128)!==0?(t.lanes=l,t):(l=s!==null,e=e!==null&&e.memoizedState!==null,l&&(s=t.child,f=null,s.alternate!==null&&s.alternate.memoizedState!==null&&s.alternate.memoizedState.cachePool!==null&&(f=s.alternate.memoizedState.cachePool.pool),p=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(p=s.memoizedState.cachePool.pool),p!==f&&(s.flags|=2048)),l!==e&&l&&(t.child.flags|=8192),Go(t,t.updateQueue),qe(t),null);case 4:return Be(),e===null&&Cu(t.stateNode.containerInfo),qe(t),null;case 10:return Zt(t.type),qe(t),null;case 19:if(L(ke),s=t.memoizedState,s===null)return qe(t),null;if(f=(t.flags&128)!==0,p=s.rendering,p===null)if(f)Al(s,!1);else{if(Pe!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(p=Co(e),p!==null){for(t.flags|=128,Al(s,!1),e=p.updateQueue,t.updateQueue=e,Go(t,e),t.subtreeFlags=0,e=l,l=t.child;l!==null;)hc(l,e),l=l.sibling;return K(ke,ke.current&1|2),Se&&Xt(t,s.treeForkCount),t.child}e=e.sibling}s.tail!==null&&mt()>Bo&&(t.flags|=128,f=!0,Al(s,!1),t.lanes=4194304)}else{if(!f)if(e=Co(p),e!==null){if(t.flags|=128,f=!0,e=e.updateQueue,t.updateQueue=e,Go(t,e),Al(s,!0),s.tail===null&&s.tailMode==="hidden"&&!p.alternate&&!Se)return qe(t),null}else 2*mt()-s.renderingStartTime>Bo&&l!==536870912&&(t.flags|=128,f=!0,Al(s,!1),t.lanes=4194304);s.isBackwards?(p.sibling=t.child,t.child=p):(e=s.last,e!==null?e.sibling=p:t.child=p,s.last=p)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=mt(),e.sibling=null,l=ke.current,K(ke,f?l&1|2:l&1),Se&&Xt(t,s.treeForkCount),e):(qe(t),null);case 22:case 23:return St(t),As(),s=t.memoizedState!==null,e!==null?e.memoizedState!==null!==s&&(t.flags|=8192):s&&(t.flags|=8192),s?(l&536870912)!==0&&(t.flags&128)===0&&(qe(t),t.subtreeFlags&6&&(t.flags|=8192)):qe(t),l=t.updateQueue,l!==null&&Go(t,l.retryQueue),l=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(l=e.memoizedState.cachePool.pool),s=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(s=t.memoizedState.cachePool.pool),s!==l&&(t.flags|=2048),e!==null&&L(Qn),null;case 24:return l=null,e!==null&&(l=e.memoizedState.cache),t.memoizedState.cache!==l&&(t.flags|=2048),Zt(Fe),qe(t),null;case 25:return null;case 30:return null}throw Error(a(156,t.tag))}function ey(e,t){switch(rs(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Zt(Fe),Be(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Jl(t),null;case 31:if(t.memoizedState!==null){if(St(t),t.alternate===null)throw Error(a(340));Jn()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(St(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(a(340));Jn()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return L(ke),null;case 4:return Be(),null;case 10:return Zt(t.type),null;case 22:case 23:return St(t),As(),e!==null&&L(Qn),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Zt(Fe),null;case 25:return null;default:return null}}function Of(e,t){switch(rs(t),t.tag){case 3:Zt(Fe),Be();break;case 26:case 27:case 5:Jl(t);break;case 4:Be();break;case 31:t.memoizedState!==null&&St(t);break;case 13:St(t);break;case 19:L(ke);break;case 10:Zt(t.type);break;case 22:case 23:St(t),As(),e!==null&&L(Qn);break;case 24:Zt(Fe)}}function Rl(e,t){try{var l=t.updateQueue,s=l!==null?l.lastEffect:null;if(s!==null){var f=s.next;l=f;do{if((l.tag&e)===e){s=void 0;var p=l.create,T=l.inst;s=p(),T.destroy=s}l=l.next}while(l!==f)}}catch(E){Ne(t,t.return,E)}}function An(e,t,l){try{var s=t.updateQueue,f=s!==null?s.lastEffect:null;if(f!==null){var p=f.next;s=p;do{if((s.tag&e)===e){var T=s.inst,E=T.destroy;if(E!==void 0){T.destroy=void 0,f=t;var C=l,I=E;try{I()}catch(G){Ne(f,C,G)}}}s=s.next}while(s!==p)}}catch(G){Ne(t,t.return,G)}}function Ff(e){var t=e.updateQueue;if(t!==null){var l=e.stateNode;try{bc(t,l)}catch(s){Ne(e,e.return,s)}}}function Yf(e,t,l){l.props=ei(e.type,e.memoizedProps),l.state=e.memoizedState;try{l.componentWillUnmount()}catch(s){Ne(e,t,s)}}function Ml(e,t){try{var l=e.ref;if(l!==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 l=="function"?e.refCleanup=l(s):l.current=s}}catch(f){Ne(e,t,f)}}function Bt(e,t){var l=e.ref,s=e.refCleanup;if(l!==null)if(typeof s=="function")try{s()}catch(f){Ne(e,t,f)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(f){Ne(e,t,f)}else l.current=null}function Jf(e){var t=e.type,l=e.memoizedProps,s=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":l.autoFocus&&s.focus();break e;case"img":l.src?s.src=l.src:l.srcSet&&(s.srcset=l.srcSet)}}catch(f){Ne(e,e.return,f)}}function nu(e,t,l){try{var s=e.stateNode;_y(s,e.type,l,t),s[st]=t}catch(f){Ne(e,e.return,f)}}function Kf(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Un(e.type)||e.tag===4}function iu(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Kf(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&&Un(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 lu(e,t,l){var s=e.tag;if(s===5||s===6)e=e.stateNode,t?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(e,t):(t=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,t.appendChild(e),l=l._reactRootContainer,l!=null||t.onclick!==null||(t.onclick=Yt));else if(s!==4&&(s===27&&Un(e.type)&&(l=e.stateNode,t=null),e=e.child,e!==null))for(lu(e,t,l),e=e.sibling;e!==null;)lu(e,t,l),e=e.sibling}function Ho(e,t,l){var s=e.tag;if(s===5||s===6)e=e.stateNode,t?l.insertBefore(e,t):l.appendChild(e);else if(s!==4&&(s===27&&Un(e.type)&&(l=e.stateNode),e=e.child,e!==null))for(Ho(e,t,l),e=e.sibling;e!==null;)Ho(e,t,l),e=e.sibling}function Xf(e){var t=e.stateNode,l=e.memoizedProps;try{for(var s=e.type,f=t.attributes;f.length;)t.removeAttributeNode(f[0]);it(t,s,l),t[je]=e,t[st]=l}catch(p){Ne(e,e.return,p)}}var tn=!1,Ke=!1,ou=!1,Qf=typeof WeakSet=="function"?WeakSet:Set,$e=null;function ty(e,t){if(e=e.containerInfo,Mu=la,e=ac(e),Wa(e)){if("selectionStart"in e)var l={start:e.selectionStart,end:e.selectionEnd};else e:{l=(l=e.ownerDocument)&&l.defaultView||window;var s=l.getSelection&&l.getSelection();if(s&&s.rangeCount!==0){l=s.anchorNode;var f=s.anchorOffset,p=s.focusNode;s=s.focusOffset;try{l.nodeType,p.nodeType}catch{l=null;break e}var T=0,E=-1,C=-1,I=0,G=0,V=e,w=null;t:for(;;){for(var q;V!==l||f!==0&&V.nodeType!==3||(E=T+f),V!==p||s!==0&&V.nodeType!==3||(C=T+s),V.nodeType===3&&(T+=V.nodeValue.length),(q=V.firstChild)!==null;)w=V,V=q;for(;;){if(V===e)break t;if(w===l&&++I===f&&(E=T),w===p&&++G===s&&(C=T),(q=V.nextSibling)!==null)break;V=w,w=V.parentNode}V=q}l=E===-1||C===-1?null:{start:E,end:C}}else l=null}l=l||{start:0,end:0}}else l=null;for(Nu={focusedElem:e,selectionRange:l},la=!1,$e=t;$e!==null;)if(t=$e,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,$e=e;else for(;$e!==null;){switch(t=$e,p=t.alternate,e=t.flags,t.tag){case 0:if((e&4)!==0&&(e=t.updateQueue,e=e!==null?e.events:null,e!==null))for(l=0;l title"))),it(p,s,l),p[je]=e,Ze(p),s=p;break e;case"link":var T=tp("link","href",f).get(s+(l.href||""));if(T){for(var E=0;EIe&&(T=Ie,Ie=oe,oe=T);var x=lc(E,oe),R=lc(E,Ie);if(x&&R&&(q.rangeCount!==1||q.anchorNode!==x.node||q.anchorOffset!==x.offset||q.focusNode!==R.node||q.focusOffset!==R.offset)){var D=V.createRange();D.setStart(x.node,x.offset),q.removeAllRanges(),oe>Ie?(q.addRange(D),q.extend(R.node,R.offset)):(D.setEnd(R.node,R.offset),q.addRange(D))}}}}for(V=[],q=E;q=q.parentNode;)q.nodeType===1&&V.push({element:q,left:q.scrollLeft,top:q.scrollTop});for(typeof E.focus=="function"&&E.focus(),E=0;El?32:l,U.T=null,l=du,du=null;var p=xn,T=sn;if(Qe=0,qi=xn=null,sn=0,(Re&6)!==0)throw Error(a(331));var E=Re;if(Re|=4,ad(p.current),id(p,p.current,T,l),Re=E,wl(0,!1),ht&&typeof ht.onPostCommitFiberRoot=="function")try{ht.onPostCommitFiberRoot(Zi,p)}catch{}return!0}finally{b.p=f,U.T=s,Ad(e,t)}}function Md(e,t,l){t=Nt(l,t),t=Ys(e.stateNode,t,2),e=En(e,t,2),e!==null&&(Wi(e,2),kt(e))}function Ne(e,t,l){if(e.tag===3)Md(e,e,l);else for(;t!==null;){if(t.tag===3){Md(t,e,l);break}else if(t.tag===1){var s=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof s.componentDidCatch=="function"&&(Nn===null||!Nn.has(s))){e=Nt(l,e),l=Nf(2),s=En(t,l,2),s!==null&&(xf(l,s,t,e),Wi(s,2),kt(s));break}}t=t.return}}function gu(e,t,l){var s=e.pingCache;if(s===null){s=e.pingCache=new ly;var f=new Set;s.set(t,f)}else f=s.get(t),f===void 0&&(f=new Set,s.set(t,f));f.has(l)||(uu=!0,f.add(l),e=ry.bind(null,e,t,l),t.then(e,e))}function ry(e,t,l){var s=e.pingCache;s!==null&&s.delete(t),e.pingedLanes|=e.suspendedLanes&l,e.warmLanes&=~l,we===e&&(ve&l)===l&&(Pe===4||Pe===3&&(ve&62914560)===ve&&300>mt()-Po?(Re&2)===0&&Li(e,0):ru|=l,bi===ve&&(bi=0)),kt(e)}function Nd(e,t){t===0&&(t=Sr()),e=Fn(e,t),e!==null&&(Wi(e,t),kt(e))}function cy(e){var t=e.memoizedState,l=0;t!==null&&(l=t.retryLane),Nd(e,l)}function fy(e,t){var l=0;switch(e.tag){case 31:case 13:var s=e.stateNode,f=e.memoizedState;f!==null&&(l=f.retryLane);break;case 19:s=e.stateNode;break;case 22:s=e.stateNode._retryCache;break;default:throw Error(a(314))}s!==null&&s.delete(t),Nd(e,l)}function dy(e,t){return Da(e,t)}var Ko=null,Hi=null,yu=!1,Xo=!1,vu=!1,In=0;function kt(e){e!==Hi&&e.next===null&&(Hi===null?Ko=Hi=e:Hi=Hi.next=e),Xo=!0,yu||(yu=!0,my())}function wl(e,t){if(!vu&&Xo){vu=!0;do for(var l=!1,s=Ko;s!==null;){if(e!==0){var f=s.pendingLanes;if(f===0)var p=0;else{var T=s.suspendedLanes,E=s.pingedLanes;p=(1<<31-gt(42|e)+1)-1,p&=f&~(T&~E),p=p&201326741?p&201326741|1:p?p|2:0}p!==0&&(l=!0,Ud(s,p))}else p=ve,p=$l(s,s===we?p:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),(p&3)===0||$i(s,p)||(l=!0,Ud(s,p));s=s.next}while(l);vu=!1}}function py(){xd()}function xd(){Xo=yu=!1;var e=0;In!==0&&Ay()&&(e=In);for(var t=mt(),l=null,s=Ko;s!==null;){var f=s.next,p=Dd(s,t);p===0?(s.next=null,l===null?Ko=f:l.next=f,f===null&&(Hi=l)):(l=s,(e!==0||(p&3)!==0)&&(Xo=!0)),s=f}Qe!==0&&Qe!==5||wl(e),In!==0&&(In=0)}function Dd(e,t){for(var l=e.suspendedLanes,s=e.pingedLanes,f=e.expirationTimes,p=e.pendingLanes&-62914561;0E)break;var G=C.transferSize,V=C.initiatorType;G&&zd(V)&&(C=C.responseEnd,T+=G*(C"u"?null:document;function $d(e,t,l){var s=Vi;if(s&&typeof t=="string"&&t){var f=Rt(t);f='link[rel="'+e+'"][href="'+f+'"]',typeof l=="string"&&(f+='[crossorigin="'+l+'"]'),Zd.has(f)||(Zd.add(f),e={rel:e,crossOrigin:l,href:t},s.querySelector(f)===null&&(t=s.createElement("link"),it(t,"link",e),Ze(t),s.head.appendChild(t)))}}function by(e){un.D(e),$d("dns-prefetch",e,null)}function qy(e,t){un.C(e,t),$d("preconnect",e,t)}function Ly(e,t,l){un.L(e,t,l);var s=Vi;if(s&&e&&t){var f='link[rel="preload"][as="'+Rt(t)+'"]';t==="image"&&l&&l.imageSrcSet?(f+='[imagesrcset="'+Rt(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(f+='[imagesizes="'+Rt(l.imageSizes)+'"]')):f+='[href="'+Rt(e)+'"]';var p=f;switch(t){case"style":p=zi(e);break;case"script":p=Pi(e)}bt.has(p)||(e=S({rel:"preload",href:t==="image"&&l&&l.imageSrcSet?void 0:e,as:t},l),bt.set(p,e),s.querySelector(f)!==null||t==="style"&&s.querySelector(Gl(p))||t==="script"&&s.querySelector(Hl(p))||(t=s.createElement("link"),it(t,"link",e),Ze(t),s.head.appendChild(t)))}}function Gy(e,t){un.m(e,t);var l=Vi;if(l&&e){var s=t&&typeof t.as=="string"?t.as:"script",f='link[rel="modulepreload"][as="'+Rt(s)+'"][href="'+Rt(e)+'"]',p=f;switch(s){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":p=Pi(e)}if(!bt.has(p)&&(e=S({rel:"modulepreload",href:e},t),bt.set(p,e),l.querySelector(f)===null)){switch(s){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(Hl(p)))return}s=l.createElement("link"),it(s,"link",e),Ze(s),l.head.appendChild(s)}}}function Hy(e,t,l){un.S(e,t,l);var s=Vi;if(s&&e){var f=si(s).hoistableStyles,p=zi(e);t=t||"default";var T=f.get(p);if(!T){var E={loading:0,preload:null};if(T=s.querySelector(Gl(p)))E.loading=5;else{e=S({rel:"stylesheet",href:e,"data-precedence":t},l),(l=bt.get(p))&&qu(e,l);var C=T=s.createElement("link");Ze(C),it(C,"link",e),C._p=new Promise(function(I,G){C.onload=I,C.onerror=G}),C.addEventListener("load",function(){E.loading|=1}),C.addEventListener("error",function(){E.loading|=2}),E.loading|=4,jo(T,t,s)}T={type:"stylesheet",instance:T,count:1,state:E},f.set(p,T)}}}function Vy(e,t){un.X(e,t);var l=Vi;if(l&&e){var s=si(l).hoistableScripts,f=Pi(e),p=s.get(f);p||(p=l.querySelector(Hl(f)),p||(e=S({src:e,async:!0},t),(t=bt.get(f))&&Lu(e,t),p=l.createElement("script"),Ze(p),it(p,"link",e),l.head.appendChild(p)),p={type:"script",instance:p,count:1,state:null},s.set(f,p))}}function zy(e,t){un.M(e,t);var l=Vi;if(l&&e){var s=si(l).hoistableScripts,f=Pi(e),p=s.get(f);p||(p=l.querySelector(Hl(f)),p||(e=S({src:e,async:!0,type:"module"},t),(t=bt.get(f))&&Lu(e,t),p=l.createElement("script"),Ze(p),it(p,"link",e),l.head.appendChild(p)),p={type:"script",instance:p,count:1,state:null},s.set(f,p))}}function Wd(e,t,l,s){var f=(f=ue.current)?Wo(f):null;if(!f)throw Error(a(446));switch(e){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(t=zi(l.href),l=si(f).hoistableStyles,s=l.get(t),s||(s={type:"style",instance:null,count:0,state:null},l.set(t,s)),s):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){e=zi(l.href);var p=si(f).hoistableStyles,T=p.get(e);if(T||(f=f.ownerDocument||f,T={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},p.set(e,T),(p=f.querySelector(Gl(e)))&&!p._p&&(T.instance=p,T.state.loading=5),bt.has(e)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},bt.set(e,l),p||Py(f,e,l,T.state))),t&&s===null)throw Error(a(528,""));return T}if(t&&s!==null)throw Error(a(529,""));return null;case"script":return t=l.async,l=l.src,typeof l=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=Pi(l),l=si(f).hoistableScripts,s=l.get(t),s||(s={type:"script",instance:null,count:0,state:null},l.set(t,s)),s):{type:"void",instance:null,count:0,state:null};default:throw Error(a(444,e))}}function zi(e){return'href="'+Rt(e)+'"'}function Gl(e){return'link[rel="stylesheet"]['+e+"]"}function jd(e){return S({},e,{"data-precedence":e.precedence,precedence:null})}function Py(e,t,l,s){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?s.loading=1:(t=e.createElement("link"),s.preload=t,t.addEventListener("load",function(){return s.loading|=1}),t.addEventListener("error",function(){return s.loading|=2}),it(t,"link",l),Ze(t),e.head.appendChild(t))}function Pi(e){return'[src="'+Rt(e)+'"]'}function Hl(e){return"script[async]"+e}function ep(e,t,l){if(t.count++,t.instance===null)switch(t.type){case"style":var s=e.querySelector('style[data-href~="'+Rt(l.href)+'"]');if(s)return t.instance=s,Ze(s),s;var f=S({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return s=(e.ownerDocument||e).createElement("style"),Ze(s),it(s,"style",f),jo(s,l.precedence,e),t.instance=s;case"stylesheet":f=zi(l.href);var p=e.querySelector(Gl(f));if(p)return t.state.loading|=4,t.instance=p,Ze(p),p;s=jd(l),(f=bt.get(f))&&qu(s,f),p=(e.ownerDocument||e).createElement("link"),Ze(p);var T=p;return T._p=new Promise(function(E,C){T.onload=E,T.onerror=C}),it(p,"link",s),t.state.loading|=4,jo(p,l.precedence,e),t.instance=p;case"script":return p=Pi(l.src),(f=e.querySelector(Hl(p)))?(t.instance=f,Ze(f),f):(s=l,(f=bt.get(p))&&(s=S({},l),Lu(s,f)),e=e.ownerDocument||e,f=e.createElement("script"),Ze(f),it(f,"link",s),e.head.appendChild(f),t.instance=f);case"void":return null;default:throw Error(a(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(s=t.instance,t.state.loading|=4,jo(s,l.precedence,e));return t.instance}function jo(e,t,l){for(var s=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),f=s.length?s[s.length-1]:null,p=f,T=0;T title"):null)}function By(e,t,l){if(l===1||t.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;switch(t.rel){case"stylesheet":return e=t.disabled,typeof t.precedence=="string"&&e==null;default:return!0}case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function ip(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function ky(e,t,l,s){if(l.type==="stylesheet"&&(typeof s.media!="string"||matchMedia(s.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var f=zi(s.href),p=t.querySelector(Gl(f));if(p){t=p._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=ta.bind(e),t.then(e,e)),l.state.loading|=4,l.instance=p,Ze(p);return}p=t.ownerDocument||t,s=jd(s),(f=bt.get(f))&&qu(s,f),p=p.createElement("link"),Ze(p);var T=p;T._p=new Promise(function(E,C){T.onload=E,T.onerror=C}),it(p,"link",s),l.instance=p}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(l,t),(t=l.state.preload)&&(l.state.loading&3)===0&&(e.count++,l=ta.bind(e),t.addEventListener("load",l),t.addEventListener("error",l))}}var Gu=0;function Oy(e,t){return e.stylesheets&&e.count===0&&ia(e,e.stylesheets),0Gu?50:800)+t);return e.unsuspend=l,function(){e.unsuspend=null,clearTimeout(s),clearTimeout(f)}}:null}function ta(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ia(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var na=null;function ia(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,na=new Map,t.forEach(Fy,e),na=null,ta.call(e))}function Fy(e,t){if(!(t.state.loading&4)){var l=na.get(e);if(l)var s=l.get(null);else{l=new Map,na.set(e,l);for(var f=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(n){console.error(n)}}return i(),Yu.exports=s0(),Yu.exports}var r0=u0();const c0=$m(r0),ma=({className:i})=>N.jsxs("svg",{className:`animate-spin h-5 w-5 text-white ${i}`,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[N.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),N.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),f0=({onSubmit:i,isLoading:n})=>{const[o,a]=Ee.useState(""),r=d=>{d.preventDefault(),i(o.trim())};return N.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-90 flex items-center justify-center z-50",children:N.jsxs("div",{className:"bg-gray-850 p-8 rounded-lg shadow-2xl w-full max-w-md border border-gray-700",children:[N.jsx("h2",{className:"text-2xl font-bold text-center text-gray-100 mb-2",children:"AI Code Architect"}),N.jsx("p",{className:"text-center text-gray-400 mb-6",children:"Enter your GitHub PAT to analyze your repositories."}),N.jsxs("form",{onSubmit:r,children:[N.jsxs("div",{className:"mb-4",children:[N.jsx("label",{htmlFor:"token-input",className:"block text-sm font-medium text-gray-300 mb-2",children:"GitHub Token"}),N.jsx("input",{id:"token-input",type:"password",value:o,onChange:d=>a(d.target.value),className:"w-full px-3 py-2 bg-gray-900 border border-gray-600 rounded-md text-gray-200 focus:outline-none focus:ring-2 focus:ring-indigo-500",placeholder:"ghp_...",required:!0})]}),N.jsxs("div",{className:"text-xs text-gray-500 mb-6 space-y-2",children:[N.jsx("p",{children:"Token is used for API requests and is not stored."}),N.jsxs("p",{children:["A ",N.jsx("strong",{className:"text-gray-400",children:"classic"})," token with full ",N.jsx("code",{className:"bg-gray-700 p-1 rounded-sm text-xs",children:"repo"})," scope is required."]}),N.jsx("a",{href:"https://github.com/settings/tokens/new?scopes=repo",target:"_blank",rel:"noopener noreferrer",className:"text-indigo-400 hover:text-indigo-300 underline",children:"Create a classic token here."})]}),N.jsx("button",{type:"submit",disabled:n||!o,className:"w-full bg-indigo-600 text-white font-semibold py-2 px-4 rounded-md hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-850 focus:ring-indigo-500 disabled:bg-gray-500 disabled:cursor-not-allowed transition-colors flex items-center justify-center",children:n?N.jsx(ma,{}):"Load Repositories"})]})]})})},Wm=i=>N.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,...i,children:N.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})}),jm=i=>N.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,...i,children:N.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 19a2 2 0 01-2-2V7a2 2 0 012-2h4l2 2h4a2 2 0 012 2v1M5 19h14a2 2 0 002-2v-5a2 2 0 00-2-2H9a2 2 0 00-2 2v5a2 2 0 01-2 2z"})}),d0=i=>N.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,...i,children:N.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})}),Ta=i=>N.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",...i,children:N.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 7.5V6.108c0-1.135.845-2.098 1.976-2.192.353-.026.715-.026 1.068 0 1.13.094 1.976 1.057 1.976 2.192V7.5M8.25 7.5h7.5M8.25 7.5c0 1.135-.845 2.098-1.976 2.192a48.424 48.424 0 0 1-1.12 0c-1.131-.094-1.976-1.057-1.976-2.192S5.445 5.308 6.576 5.214a48.424 48.424 0 0 1 1.12 0c1.131.094 1.976 1.057 1.976 2.192ZM9.75 9.75c0-1.135.845-2.098 1.976-2.192a48.424 48.424 0 0 1 1.12 0c1.131.094 1.976 1.057 1.976 2.192S13.445 11.85 12.314 11.944a48.424 48.424 0 0 1-1.12 0c-1.131-.094-1.976-1.057-1.976-2.192ZM9.75 9.75c0 1.135-.845 2.098-1.976 2.192a48.424 48.424 0 0 1-1.12 0C5.524 11.85 4.68 10.887 4.68 9.75S5.524 7.65 6.654 7.556a48.424 48.424 0 0 1 1.12 0c1.131.094 1.976 1.057 1.976 2.192Zm0 0h2.52m-2.52 0V3.375c0-1.135.845-2.098 1.976-2.192a48.424 48.424 0 0 1 1.12 0c1.131.094 1.976 1.057 1.976 2.192V9.75m-4.632 0a48.566 48.566 0 0 1-1.658-.027A2.25 2.25 0 0 0 5.25 12v2.25a2.25 2.25 0 0 0 2.25 2.25H16.5a2.25 2.25 0 0 0 2.25-2.25V12a2.25 2.25 0 0 0-2.25-2.25a48.566 48.566 0 0 1-1.658-.027m-9.198 0c-.065.21-.1.433-.1.662v2.25a2.25 2.25 0 0 0 2.25 2.25h10.5a2.25 2.25 0 0 0 2.25-2.25v-2.25c0-.23-.035-.452-.1-.662m-1.246 0a48.566 48.566 0 0 1-1.658-.027A2.25 2.25 0 0 0 12 6.75v-2.25a2.25 2.25 0 0 0-2.25-2.25a48.566 48.566 0 0 1-1.658-.027A2.25 2.25 0 0 0 5.25 4.5v2.25a2.25 2.25 0 0 0 2.25 2.25m13.5 0a48.566 48.566 0 0 1-1.658-.027A2.25 2.25 0 0 0 16.5 6.75v-2.25a2.25 2.25 0 0 0-2.25-2.25a48.566 48.566 0 0 1-1.658-.027A2.25 2.25 0 0 0 9.75 4.5v2.25a2.25 2.25 0 0 0 2.25 2.25m-1.246 0a48.566 48.566 0 0 1-1.658-.027A2.25 2.25 0 0 0 12 11.25v2.25a2.25 2.25 0 0 0 2.25 2.25h.09a48.566 48.566 0 0 1 1.658-.027A2.25 2.25 0 0 0 18.75 13.5v-2.25a2.25 2.25 0 0 0-2.25-2.25m-2.858 0a48.566 48.566 0 0 1-1.658-.027A2.25 2.25 0 0 0 9.75 11.25v2.25a2.25 2.25 0 0 0 2.25 2.25h.09a48.566 48.566 0 0 1 1.658-.027A2.25 2.25 0 0 0 16.5 13.5v-2.25a2.25 2.25 0 0 0-2.25-2.25M12 18.75a.75.75 0 1 1 0-1.5.75.75 0 0 1 0 1.5Z"})}),eh=({node:i,repoId:n,onFileClick:o,selectedFilePath:a,selectedRepo:r})=>{const[d,m]=Ee.useState(!1);if(i.type==="dir")return N.jsxs("div",{children:[N.jsxs("div",{className:"flex items-center p-1.5 hover:bg-gray-700 rounded-md group cursor-pointer",onClick:()=>m(!d),children:[d?N.jsx(jm,{className:"w-5 h-5 mr-2 text-indigo-400 shrink-0"}):N.jsx(Wm,{className:"w-5 h-5 mr-2 text-indigo-400 shrink-0"}),N.jsx("span",{className:"truncate",children:i.name})]}),d&&N.jsx("div",{className:"pl-4 border-l border-gray-700 ml-2",children:i.children.map(h=>N.jsx(eh,{node:h,repoId:n,onFileClick:o,selectedFilePath:a,selectedRepo:r},h.path))})]});const y=r===n&&a===i.path;return N.jsxs("div",{className:`flex items-center p-1.5 group rounded-md cursor-pointer ${y?"bg-indigo-900 bg-opacity-50":"hover:bg-gray-700"}`,onClick:()=>o(n,i.path),children:[N.jsx(d0,{className:"w-5 h-5 mr-2 text-gray-400 shrink-0"}),N.jsx("span",{className:`truncate ${y?"text-white":"text-gray-300"}`,children:i.name})]})},p0=i=>{const{repoId:n,repoData:o,onFileClick:a,onRepoExpand:r,onRepoAnalyze:d,selectedFilePath:m,selectedRepo:g}=i,{repo:y,tree:h,contentStatus:v,analysisStatus:S}=o,_=y.full_name===g,[M,z]=Ee.useState(!1);Ee.useEffect(()=>{_&&!M&&(z(!0),v==="unloaded"&&r(n))},[_,M,r,n,v]);const P=()=>{const k=!M;z(k),k&&v==="unloaded"&&r(n)},O=v!=="loaded"||S==="analyzing"||S==="analyzed";return N.jsxs("div",{className:"mb-2 bg-gray-850/50 rounded-lg p-2",children:[N.jsxs("div",{className:"flex items-center justify-between p-2 hover:bg-gray-700 rounded-md group cursor-pointer",onClick:P,children:[N.jsxs("h3",{className:"text-md font-semibold flex items-center flex-grow truncate",children:[M?N.jsx(jm,{className:"w-5 h-5 mr-2 shrink-0"}):N.jsx(Wm,{className:"w-5 h-5 mr-2 shrink-0"}),N.jsx("span",{className:"truncate",children:y.full_name})]}),v==="loading"&&N.jsx(ma,{className:"w-4 h-4"})]}),M&&N.jsxs("div",{className:"pl-4 mt-2",children:[N.jsxs("button",{onClick:()=>d(n),disabled:O,className:`w-full flex items-center justify-center gap-2 text-sm px-3 py-2 mb-2 rounded-md font-semibold transition-colors + bg-indigo-600 text-white hover:bg-indigo-500 + disabled:bg-gray-600 disabled:text-gray-400 disabled:cursor-not-allowed`,children:[S==="analyzing"?N.jsx(ma,{className:"w-4 h-4"}):N.jsx(Ta,{className:"w-5 h-5"}),S==="unanalyzed"&&"Analyze Repo",S==="analyzing"&&"Analyzing...",S==="analyzed"&&"Analysis Complete"]}),N.jsx("div",{className:"border-l border-gray-700 ml-2 pl-2",children:h.length>0?h.map(k=>N.jsx(eh,{node:k,repoId:y.full_name,onFileClick:a,selectedFilePath:m,selectedRepo:g},k.path)):N.jsx("p",{className:"text-sm text-gray-500 p-2",children:"Repository is empty."})})]})]})},m0=i=>{const{fsTree:n,onFileSelect:o,onRepoExpand:a,onRepoAnalyze:r,selectedFilePath:d,selectedRepo:m}=i;return N.jsxs("div",{className:"p-2 md:p-4 text-gray-300 h-full",children:[N.jsx("div",{className:"flex justify-between items-center mb-4 border-b border-gray-700 pb-2",children:N.jsx("h2",{className:"text-xl font-bold",children:"Repositories"})}),N.jsx("div",{className:"h-[calc(100%-4rem)] overflow-y-auto",children:Object.keys(n).sort().map(g=>N.jsx(p0,{repoId:g,repoData:n[g],onFileClick:o,onRepoExpand:a,onRepoAnalyze:r,selectedFilePath:d,selectedRepo:m},g))})]})},h0=({file:i,isActive:n,onSelect:o,onClose:a})=>{const r=i.repoId+"::"+i.path,d=i.path.split("/").pop();return N.jsxs("div",{onClick:()=>o(r),className:`flex items-center justify-between p-2 px-4 cursor-pointer border-b-2 ${n?"bg-gray-850 border-indigo-500 text-white":"bg-gray-900 border-transparent text-gray-400 hover:bg-gray-800"}`,children:[N.jsx("span",{className:"text-sm font-medium pr-2 truncate",title:i.path,children:d}),N.jsx("button",{onClick:m=>{m.stopPropagation(),a(r)},className:"text-gray-500 hover:text-white rounded-full w-5 h-5 flex items-center justify-center hover:bg-gray-700 text-xs shrink-0",children:"×"})]})},g0=i=>{const{openFiles:n,activeFile:o,onFileContentChange:a,onCloseFile:r,onSetActiveFile:d}=i;if(!o)return N.jsx("div",{className:"hidden md:flex h-full items-center justify-center bg-gray-850 text-gray-500",children:N.jsx("p",{children:"Select a file to get started."})});const m=o.repoId+"::"+o.path;return N.jsxs("div",{className:"flex flex-col h-full bg-gray-850 relative",children:[N.jsx("div",{className:"flex items-center justify-between p-2 border-b border-gray-700 bg-gray-900 flex-wrap gap-2",children:N.jsxs("div",{className:"min-w-0",children:[N.jsx("h3",{className:"text-md font-semibold text-gray-200 truncate",title:o.path,children:o.path}),N.jsx("p",{className:"text-xs text-gray-400 truncate",children:o.repoId})]})}),N.jsx("div",{className:"flex border-b border-gray-700 bg-gray-900 overflow-x-auto",children:n.map(g=>N.jsx(h0,{file:g,isActive:g.repoId+"::"+g.path===m,onSelect:d,onClose:r},g.repoId+"::"+g.path))}),N.jsx("div",{className:"flex-grow p-1 md:p-4",children:N.jsx("textarea",{value:o.edited,onChange:g=>a(m,g.target.value),className:"w-full h-full border border-gray-700 rounded-md bg-gray-950 text-gray-200 p-4 font-mono text-sm resize-none focus:outline-none focus:ring-2 focus:ring-indigo-500",spellCheck:"false"},m)})]})},y0="https://api.github.com";async function Ot(i,n,o={}){const a=await fetch(`${y0}${i}`,{...o,headers:{...o.headers,Authorization:`Bearer ${n}`,Accept:"application/vnd.github.v3+json","X-GitHub-Api-Version":"2022-11-28"}});if(!a.ok){const r=await a.json().catch(()=>({message:"Could not parse error response."}));let d=`GitHub API Error: ${a.status} ${r.message||""}`;throw a.status===401&&(d="GitHub API Error: 401 Bad credentials. Please verify your Personal Access Token has the required `repo` scope and is not expired."),new Error(d)}return a.status===204||a.status===201&&!a.body?null:a.json()}async function v0(i){let n=[],o=1;const a=100;for(;;){const r=await Ot(`/user/repos?type=owner&per_page=${a}&page=${o}`,i);if(n=n.concat(r),r.length{const n={children:{}};i.forEach(a=>{if(a.type!=="blob"||!a.path)return;const r=a.path.split("/");let d=n.children;r.forEach((m,g)=>{const y=g===r.length-1,h=r.slice(0,g+1).join("/");y?d[m]||(d[m]={type:"file",path:a.path,name:m,sha:a.sha}):(d[m]||(d[m]={type:"dir",path:h,name:m,children:{}}),d=d[m].children)})});const o=a=>{const r=Object.values(a).map(d=>d.type==="dir"?{...d,children:o(d.children)}:d);return r.sort((d,m)=>d.type!==m.type?d.type==="dir"?-1:1:d.name.localeCompare(m.name)),r};return o(n.children)};async function S0(i,n,o,a){const{tree:r}=await Ot(`/repos/${n}/${o}/git/trees/${a}?recursive=1`,i);return T0(r)}async function E0(i,n,o,a,r){const d=r?`/repos/${n}/${o}/contents/${a}?ref=${r}`:`/repos/${n}/${o}/contents/${a}`,m=await Ot(d,i);return{...m,content:atob(m.content)}}async function ar(i,n,o,a){return Ot(`/repos/${n}/${o}/branches/${a}`,i)}async function _0(i,n,o,a,r){return Ot(`/repos/${n}/${o}/git/refs`,i,{method:"POST",body:JSON.stringify({ref:a,sha:r})})}async function C0(i,n,o,a,r){const m=(await ar(i,n,o,r)).commit.sha;return _0(i,n,o,`refs/heads/${a}`,m)}async function A0(i,n,o,a,r){try{await ar(i,n,o,a)}catch(d){if(d instanceof Error&&(d.message.includes("404")||d.message.toLowerCase().includes("not found")))await C0(i,n,o,a,r);else throw console.error(`Error ensuring branch '${a}' exists:`,d),d}}async function R0(i){const{token:n,owner:o,repo:a,title:r,body:d,head:m,base:g}=i,y={title:r,body:d,head:m,base:g};return Ot(`/repos/${o}/${a}/pulls`,n,{method:"POST",body:JSON.stringify(y)})}async function M0(i,n,o,a,r){const d={tree:r};return a&&(d.base_tree=a),Ot(`/repos/${n}/${o}/git/trees`,i,{method:"POST",body:JSON.stringify(d)})}async function N0(i,n,o,a,r,d){return Ot(`/repos/${n}/${o}/git/commits`,i,{method:"POST",body:JSON.stringify({message:a,tree:r,parents:d})})}async function x0(i,n,o,a){return Ot(`/repos/${n}/${o}/git/commits/${a}`,i)}async function D0(i,n,o,a,r){return Ot(`/repos/${n}/${o}/git/refs/${a}`,i,{method:"PATCH",body:JSON.stringify({sha:r,force:!1})})}async function I0(i){const{token:n,repoId:o,parentCommitSha:a,changes:r,commitMessage:d}=i,[m,g]=o.split("/"),h=(await x0(n,m,g,a)).tree.sha,v=r.map(M=>({path:M.filePath,mode:"100644",type:"blob",content:M.newContent})),S=await M0(n,m,g,h,v);return(await N0(n,m,g,d,S.sha,[a])).sha}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */let U0,w0;function b0(){return{geminiUrl:U0,vertexUrl:w0}}function q0(i,n,o,a){var r,d;if(!(i!=null&&i.baseUrl)){const m=b0();return n?(r=m.vertexUrl)!==null&&r!==void 0?r:o:(d=m.geminiUrl)!==null&&d!==void 0?d:a}return i.baseUrl}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class cn{}function X(i,n){const o=/\{([^}]+)\}/g;return i.replace(o,(a,r)=>{if(Object.prototype.hasOwnProperty.call(n,r)){const d=n[r];return d!=null?String(d):""}else throw new Error(`Key '${r}' not found in valueMap.`)})}function c(i,n,o){for(let d=0;d({}));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(o))for(let h=0;hu(g,n.slice(a+1),o)):o}else return o}else i=i[r]}return i}catch(a){if(a instanceof TypeError)return o;throw a}}function L0(i,n){for(const[o,a]of Object.entries(n)){const r=o.split("."),d=a.split("."),m=new Set;let g=-1;for(let y=0;yg)for(let y=g;y=n.length||typeof i!="object"||i===null)return;const d=n[a];if(d.endsWith("[]")){const m=d.slice(0,-2),g=i;if(m in g&&Array.isArray(g[m]))for(const y of g[m])Qu(y,n,o,a+1,r)}else if(d==="*"){if(typeof i=="object"&&i!==null&&!Array.isArray(i)){const m=i,g=Object.keys(m).filter(h=>!h.startsWith("_")&&!r.has(h)),y={};for(const h of g)y[h]=m[h];for(const[h,v]of Object.entries(y)){const S=[];for(const _ of o.slice(a))_==="*"?S.push(h):S.push(_);c(m,S,v)}for(const h of g)delete m[h]}}else{const m=i;d in m&&Qu(m[d],n,o,a+1,r)}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function sr(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 G0(i){const n={},o=u(i,["operationName"]);o!=null&&c(n,["operationName"],o);const a=u(i,["resourceName"]);return a!=null&&c(n,["_url","resourceName"],a),n}function H0(i){const n={},o=u(i,["name"]);o!=null&&c(n,["name"],o);const a=u(i,["metadata"]);a!=null&&c(n,["metadata"],a);const r=u(i,["done"]);r!=null&&c(n,["done"],r);const d=u(i,["error"]);d!=null&&c(n,["error"],d);const m=u(i,["response","generateVideoResponse"]);return m!=null&&c(n,["response"],z0(m)),n}function V0(i){const n={},o=u(i,["name"]);o!=null&&c(n,["name"],o);const a=u(i,["metadata"]);a!=null&&c(n,["metadata"],a);const r=u(i,["done"]);r!=null&&c(n,["done"],r);const d=u(i,["error"]);d!=null&&c(n,["error"],d);const m=u(i,["response"]);return m!=null&&c(n,["response"],P0(m)),n}function z0(i){const n={},o=u(i,["generatedSamples"]);if(o!=null){let d=o;Array.isArray(d)&&(d=d.map(m=>B0(m))),c(n,["generatedVideos"],d)}const a=u(i,["raiMediaFilteredCount"]);a!=null&&c(n,["raiMediaFilteredCount"],a);const r=u(i,["raiMediaFilteredReasons"]);return r!=null&&c(n,["raiMediaFilteredReasons"],r),n}function P0(i){const n={},o=u(i,["videos"]);if(o!=null){let d=o;Array.isArray(d)&&(d=d.map(m=>k0(m))),c(n,["generatedVideos"],d)}const a=u(i,["raiMediaFilteredCount"]);a!=null&&c(n,["raiMediaFilteredCount"],a);const r=u(i,["raiMediaFilteredReasons"]);return r!=null&&c(n,["raiMediaFilteredReasons"],r),n}function B0(i){const n={},o=u(i,["video"]);return o!=null&&c(n,["video"],X0(o)),n}function k0(i){const n={},o=u(i,["_self"]);return o!=null&&c(n,["video"],Q0(o)),n}function O0(i){const n={},o=u(i,["operationName"]);return o!=null&&c(n,["_url","operationName"],o),n}function F0(i){const n={},o=u(i,["operationName"]);return o!=null&&c(n,["_url","operationName"],o),n}function Y0(i){const n={},o=u(i,["name"]);o!=null&&c(n,["name"],o);const a=u(i,["metadata"]);a!=null&&c(n,["metadata"],a);const r=u(i,["done"]);r!=null&&c(n,["done"],r);const d=u(i,["error"]);d!=null&&c(n,["error"],d);const m=u(i,["response"]);return m!=null&&c(n,["response"],J0(m)),n}function J0(i){const n={},o=u(i,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const a=u(i,["parent"]);a!=null&&c(n,["parent"],a);const r=u(i,["documentName"]);return r!=null&&c(n,["documentName"],r),n}function th(i){const n={},o=u(i,["name"]);o!=null&&c(n,["name"],o);const a=u(i,["metadata"]);a!=null&&c(n,["metadata"],a);const r=u(i,["done"]);r!=null&&c(n,["done"],r);const d=u(i,["error"]);d!=null&&c(n,["error"],d);const m=u(i,["response"]);return m!=null&&c(n,["response"],K0(m)),n}function K0(i){const n={},o=u(i,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const a=u(i,["parent"]);a!=null&&c(n,["parent"],a);const r=u(i,["documentName"]);return r!=null&&c(n,["documentName"],r),n}function X0(i){const n={},o=u(i,["uri"]);o!=null&&c(n,["uri"],o);const a=u(i,["encodedVideo"]);a!=null&&c(n,["videoBytes"],sr(a));const r=u(i,["encoding"]);return r!=null&&c(n,["mimeType"],r),n}function Q0(i){const n={},o=u(i,["gcsUri"]);o!=null&&c(n,["uri"],o);const a=u(i,["bytesBase64Encoded"]);a!=null&&c(n,["videoBytes"],sr(a));const r=u(i,["mimeType"]);return r!=null&&c(n,["mimeType"],r),n}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */var Np;(function(i){i.OUTCOME_UNSPECIFIED="OUTCOME_UNSPECIFIED",i.OUTCOME_OK="OUTCOME_OK",i.OUTCOME_FAILED="OUTCOME_FAILED",i.OUTCOME_DEADLINE_EXCEEDED="OUTCOME_DEADLINE_EXCEEDED"})(Np||(Np={}));var xp;(function(i){i.LANGUAGE_UNSPECIFIED="LANGUAGE_UNSPECIFIED",i.PYTHON="PYTHON"})(xp||(xp={}));var Dp;(function(i){i.SCHEDULING_UNSPECIFIED="SCHEDULING_UNSPECIFIED",i.SILENT="SILENT",i.WHEN_IDLE="WHEN_IDLE",i.INTERRUPT="INTERRUPT"})(Dp||(Dp={}));var Ue;(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"})(Ue||(Ue={}));var Ip;(function(i){i.MODE_UNSPECIFIED="MODE_UNSPECIFIED",i.MODE_DYNAMIC="MODE_DYNAMIC"})(Ip||(Ip={}));var Up;(function(i){i.API_SPEC_UNSPECIFIED="API_SPEC_UNSPECIFIED",i.SIMPLE_SEARCH="SIMPLE_SEARCH",i.ELASTIC_SEARCH="ELASTIC_SEARCH"})(Up||(Up={}));var wp;(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"})(wp||(wp={}));var bp;(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"})(bp||(bp={}));var qp;(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"})(qp||(qp={}));var Lp;(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"})(Lp||(Lp={}));var Gp;(function(i){i.HARM_BLOCK_METHOD_UNSPECIFIED="HARM_BLOCK_METHOD_UNSPECIFIED",i.SEVERITY="SEVERITY",i.PROBABILITY="PROBABILITY"})(Gp||(Gp={}));var Hp;(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"})(Hp||(Hp={}));var Vp;(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"})(Vp||(Vp={}));var zp;(function(i){i.HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",i.NEGLIGIBLE="NEGLIGIBLE",i.LOW="LOW",i.MEDIUM="MEDIUM",i.HIGH="HIGH"})(zp||(zp={}));var Pp;(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"})(Pp||(Pp={}));var Bp;(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"})(Bp||(Bp={}));var kp;(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"})(kp||(kp={}));var Op;(function(i){i.TRAFFIC_TYPE_UNSPECIFIED="TRAFFIC_TYPE_UNSPECIFIED",i.ON_DEMAND="ON_DEMAND",i.PROVISIONED_THROUGHPUT="PROVISIONED_THROUGHPUT"})(Op||(Op={}));var ha;(function(i){i.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",i.TEXT="TEXT",i.IMAGE="IMAGE",i.AUDIO="AUDIO"})(ha||(ha={}));var Fp;(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"})(Fp||(Fp={}));var Yp;(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"})(Yp||(Yp={}));var Jp;(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"})(Jp||(Jp={}));var Zu;(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"})(Zu||(Zu={}));var Kp;(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"})(Kp||(Kp={}));var Xp;(function(i){i.FEATURE_SELECTION_PREFERENCE_UNSPECIFIED="FEATURE_SELECTION_PREFERENCE_UNSPECIFIED",i.PRIORITIZE_QUALITY="PRIORITIZE_QUALITY",i.BALANCED="BALANCED",i.PRIORITIZE_COST="PRIORITIZE_COST"})(Xp||(Xp={}));var Qp;(function(i){i.UNSPECIFIED="UNSPECIFIED",i.BLOCKING="BLOCKING",i.NON_BLOCKING="NON_BLOCKING"})(Qp||(Qp={}));var Zp;(function(i){i.MODE_UNSPECIFIED="MODE_UNSPECIFIED",i.MODE_DYNAMIC="MODE_DYNAMIC"})(Zp||(Zp={}));var $p;(function(i){i.ENVIRONMENT_UNSPECIFIED="ENVIRONMENT_UNSPECIFIED",i.ENVIRONMENT_BROWSER="ENVIRONMENT_BROWSER"})($p||($p={}));var Wp;(function(i){i.MODE_UNSPECIFIED="MODE_UNSPECIFIED",i.AUTO="AUTO",i.ANY="ANY",i.NONE="NONE",i.VALIDATED="VALIDATED"})(Wp||(Wp={}));var jp;(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"})(jp||(jp={}));var em;(function(i){i.DONT_ALLOW="DONT_ALLOW",i.ALLOW_ADULT="ALLOW_ADULT",i.ALLOW_ALL="ALLOW_ALL"})(em||(em={}));var tm;(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"})(tm||(tm={}));var nm;(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"})(nm||(nm={}));var im;(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"})(im||(im={}));var lm;(function(i){i.SUBJECT_TYPE_DEFAULT="SUBJECT_TYPE_DEFAULT",i.SUBJECT_TYPE_PERSON="SUBJECT_TYPE_PERSON",i.SUBJECT_TYPE_ANIMAL="SUBJECT_TYPE_ANIMAL",i.SUBJECT_TYPE_PRODUCT="SUBJECT_TYPE_PRODUCT"})(lm||(lm={}));var om;(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"})(om||(om={}));var am;(function(i){i.FOREGROUND="FOREGROUND",i.BACKGROUND="BACKGROUND",i.PROMPT="PROMPT",i.SEMANTIC="SEMANTIC",i.INTERACTIVE="INTERACTIVE"})(am||(am={}));var sm;(function(i){i.ASSET="ASSET",i.STYLE="STYLE"})(sm||(sm={}));var um;(function(i){i.INSERT="INSERT",i.REMOVE="REMOVE",i.REMOVE_STATIC="REMOVE_STATIC",i.OUTPAINT="OUTPAINT"})(um||(um={}));var rm;(function(i){i.OPTIMIZED="OPTIMIZED",i.LOSSLESS="LOSSLESS"})(rm||(rm={}));var cm;(function(i){i.SUPERVISED_FINE_TUNING="SUPERVISED_FINE_TUNING",i.PREFERENCE_TUNING="PREFERENCE_TUNING"})(cm||(cm={}));var fm;(function(i){i.STATE_UNSPECIFIED="STATE_UNSPECIFIED",i.STATE_PENDING="STATE_PENDING",i.STATE_ACTIVE="STATE_ACTIVE",i.STATE_FAILED="STATE_FAILED"})(fm||(fm={}));var dm;(function(i){i.STATE_UNSPECIFIED="STATE_UNSPECIFIED",i.PROCESSING="PROCESSING",i.ACTIVE="ACTIVE",i.FAILED="FAILED"})(dm||(dm={}));var pm;(function(i){i.SOURCE_UNSPECIFIED="SOURCE_UNSPECIFIED",i.UPLOADED="UPLOADED",i.GENERATED="GENERATED"})(pm||(pm={}));var mm;(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"})(mm||(mm={}));var hm;(function(i){i.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",i.TEXT="TEXT",i.IMAGE="IMAGE",i.VIDEO="VIDEO",i.AUDIO="AUDIO",i.DOCUMENT="DOCUMENT"})(hm||(hm={}));var gm;(function(i){i.START_SENSITIVITY_UNSPECIFIED="START_SENSITIVITY_UNSPECIFIED",i.START_SENSITIVITY_HIGH="START_SENSITIVITY_HIGH",i.START_SENSITIVITY_LOW="START_SENSITIVITY_LOW"})(gm||(gm={}));var ym;(function(i){i.END_SENSITIVITY_UNSPECIFIED="END_SENSITIVITY_UNSPECIFIED",i.END_SENSITIVITY_HIGH="END_SENSITIVITY_HIGH",i.END_SENSITIVITY_LOW="END_SENSITIVITY_LOW"})(ym||(ym={}));var vm;(function(i){i.ACTIVITY_HANDLING_UNSPECIFIED="ACTIVITY_HANDLING_UNSPECIFIED",i.START_OF_ACTIVITY_INTERRUPTS="START_OF_ACTIVITY_INTERRUPTS",i.NO_INTERRUPTION="NO_INTERRUPTION"})(vm||(vm={}));var Tm;(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"})(Tm||(Tm={}));var Sm;(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"})(Sm||(Sm={}));var Em;(function(i){i.MUSIC_GENERATION_MODE_UNSPECIFIED="MUSIC_GENERATION_MODE_UNSPECIFIED",i.QUALITY="QUALITY",i.DIVERSITY="DIVERSITY",i.VOCALIZATION="VOCALIZATION"})(Em||(Em={}));var ki;(function(i){i.PLAYBACK_CONTROL_UNSPECIFIED="PLAYBACK_CONTROL_UNSPECIFIED",i.PLAY="PLAY",i.PAUSE="PAUSE",i.STOP="STOP",i.RESET_CONTEXT="RESET_CONTEXT"})(ki||(ki={}));class $u{constructor(n){const o={};for(const a of n.headers.entries())o[a[0]]=a[1];this.headers=o,this.responseInternal=n}json(){return this.responseInternal.json()}}class Fl{get text(){var n,o,a,r,d,m,g,y;if(((r=(a=(o=(n=this.candidates)===null||n===void 0?void 0:n[0])===null||o===void 0?void 0:o.content)===null||a===void 0?void 0:a.parts)===null||r===void 0?void 0:r.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning text from the first one.");let h="",v=!1;const S=[];for(const _ of(y=(g=(m=(d=this.candidates)===null||d===void 0?void 0:d[0])===null||m===void 0?void 0:m.content)===null||g===void 0?void 0:g.parts)!==null&&y!==void 0?y:[]){for(const[M,z]of Object.entries(_))M!=="text"&&M!=="thought"&&M!=="thoughtSignature"&&(z!==null||z!==void 0)&&S.push(M);if(typeof _.text=="string"){if(typeof _.thought=="boolean"&&_.thought)continue;v=!0,h+=_.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 n,o,a,r,d,m,g,y;if(((r=(a=(o=(n=this.candidates)===null||n===void 0?void 0:n[0])===null||o===void 0?void 0:o.content)===null||a===void 0?void 0:a.parts)===null||r===void 0?void 0:r.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning data from the first one.");let h="";const v=[];for(const S of(y=(g=(m=(d=this.candidates)===null||d===void 0?void 0:d[0])===null||m===void 0?void 0:m.content)===null||g===void 0?void 0:g.parts)!==null&&y!==void 0?y:[]){for(const[_,M]of Object.entries(S))_!=="inlineData"&&(M!==null||M!==void 0)&&v.push(_);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 n,o,a,r,d,m,g,y;if(((r=(a=(o=(n=this.candidates)===null||n===void 0?void 0:n[0])===null||o===void 0?void 0:o.content)===null||a===void 0?void 0:a.parts)===null||r===void 0?void 0:r.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning function calls from the first one.");const h=(y=(g=(m=(d=this.candidates)===null||d===void 0?void 0:d[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 n,o,a,r,d,m,g,y,h;if(((r=(a=(o=(n=this.candidates)===null||n===void 0?void 0:n[0])===null||o===void 0?void 0:o.content)===null||a===void 0?void 0:a.parts)===null||r===void 0?void 0:r.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning executable code from the first one.");const v=(y=(g=(m=(d=this.candidates)===null||d===void 0?void 0:d[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 n,o,a,r,d,m,g,y,h;if(((r=(a=(o=(n=this.candidates)===null||n===void 0?void 0:n[0])===null||o===void 0?void 0:o.content)===null||a===void 0?void 0:a.parts)===null||r===void 0?void 0:r.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning code execution result from the first one.");const v=(y=(g=(m=(d=this.candidates)===null||d===void 0?void 0:d[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 _m{}class Cm{}class Z0{}class $0{}class W0{}class j0{}class Am{}class Rm{}class Mm{}class ev{}class ga{_fromAPIResponse({apiResponse:n,_isVertexAI:o}){const a=new ga;let r;const d=n;return o?r=V0(d):r=H0(d),Object.assign(a,r),a}}class Nm{}class xm{}class Dm{}class tv{}class nv{}class iv{}class ur{_fromAPIResponse({apiResponse:n,_isVertexAI:o}){const a=new ur,d=Y0(n);return Object.assign(a,d),a}}class lv{}class ov{}class av{}class Im{}class sv{get text(){var n,o,a;let r="",d=!1;const m=[];for(const g of(a=(o=(n=this.serverContent)===null||n===void 0?void 0:n.modelTurn)===null||o===void 0?void 0:o.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;d=!0,r+=g.text}}return m.length>0&&console.warn(`there are non-text parts ${m} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),d?r:void 0}get data(){var n,o,a;let r="";const d=[];for(const m of(a=(o=(n=this.serverContent)===null||n===void 0?void 0:n.modelTurn)===null||o===void 0?void 0:o.parts)!==null&&a!==void 0?a:[]){for(const[g,y]of Object.entries(m))g!=="inlineData"&&y!==null&&d.push(g);m.inlineData&&typeof m.inlineData.data=="string"&&(r+=atob(m.inlineData.data))}return d.length>0&&console.warn(`there are non-data parts ${d} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),r.length>0?btoa(r):void 0}}class uv{get audioChunk(){if(this.serverContent&&this.serverContent.audioChunks&&this.serverContent.audioChunks.length>0)return this.serverContent.audioChunks[0]}}class rr{_fromAPIResponse({apiResponse:n,_isVertexAI:o}){const a=new rr,d=th(n);return Object.assign(a,d),a}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function Ae(i,n){if(!n||typeof n!="string")throw new Error("model is required and must be a string");if(n.includes("..")||n.includes("?")||n.includes("&"))throw new Error("invalid model parameter");if(i.isVertexAI()){if(n.startsWith("publishers/")||n.startsWith("projects/")||n.startsWith("models/"))return n;if(n.indexOf("/")>=0){const o=n.split("/",2);return`publishers/${o[0]}/models/${o[1]}`}else return`publishers/google/models/${n}`}else return n.startsWith("models/")||n.startsWith("tunedModels/")?n:`models/${n}`}function nh(i,n){const o=Ae(i,n);return o?o.startsWith("publishers/")&&i.isVertexAI()?`projects/${i.getProject()}/locations/${i.getLocation()}/${o}`:o.startsWith("models/")&&i.isVertexAI()?`projects/${i.getProject()}/locations/${i.getLocation()}/publishers/google/${o}`:o:""}function ih(i){return Array.isArray(i)?i.map(n=>ya(n)):[ya(i)]}function ya(i){if(typeof i=="object"&&i!==null)return i;throw new Error(`Could not parse input as Blob. Unsupported blob type: ${typeof i}`)}function lh(i){const n=ya(i);if(n.mimeType&&n.mimeType.startsWith("image/"))return n;throw new Error(`Unsupported mime type: ${n.mimeType}`)}function oh(i){const n=ya(i);if(n.mimeType&&n.mimeType.startsWith("audio/"))return n;throw new Error(`Unsupported mime type: ${n.mimeType}`)}function Um(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 ah(i){if(i==null||Array.isArray(i)&&i.length===0)throw new Error("PartListUnion is required");return Array.isArray(i)?i.map(n=>Um(n)):[Um(i)]}function Wu(i){return i!=null&&typeof i=="object"&&"parts"in i&&Array.isArray(i.parts)}function wm(i){return i!=null&&typeof i=="object"&&"functionCall"in i}function bm(i){return i!=null&&typeof i=="object"&&"functionResponse"in i}function ot(i){if(i==null)throw new Error("ContentUnion is required");return Wu(i)?i:{role:"user",parts:ah(i)}}function cr(i,n){if(!n)return[];if(i.isVertexAI()&&Array.isArray(n))return n.flatMap(o=>{const a=ot(o);return a.parts&&a.parts.length>0&&a.parts[0].text!==void 0?[a.parts[0].text]:[]});if(i.isVertexAI()){const o=ot(n);return o.parts&&o.parts.length>0&&o.parts[0].text!==void 0?[o.parts[0].text]:[]}return Array.isArray(n)?n.map(o=>ot(o)):[ot(n)]}function qt(i){if(i==null||Array.isArray(i)&&i.length===0)throw new Error("contents are required");if(!Array.isArray(i)){if(wm(i)||bm(i))throw new Error("To specify functionCall or functionResponse parts, please wrap them in a Content object, specifying the role for them");return[ot(i)]}const n=[],o=[],a=Wu(i[0]);for(const r of i){const d=Wu(r);if(d!=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(d)n.push(r);else{if(wm(r)||bm(r))throw new Error("To specify functionCall or functionResponse parts, please wrap them, and any other parts, in Content objects as appropriate, specifying the role for them");o.push(r)}}return a||n.push({role:"user",parts:ah(o)}),n}function rv(i,n){i.includes("null")&&(n.nullable=!0);const o=i.filter(a=>a!=="null");if(o.length===1)n.type=Object.values(Ue).includes(o[0].toUpperCase())?o[0].toUpperCase():Ue.TYPE_UNSPECIFIED;else{n.anyOf=[];for(const a of o)n.anyOf.push({type:Object.values(Ue).includes(a.toUpperCase())?a.toUpperCase():Ue.TYPE_UNSPECIFIED})}}function Oi(i){const n={},o=["items"],a=["anyOf"],r=["properties"];if(i.type&&i.anyOf)throw new Error("type and anyOf cannot be both populated.");const d=i.anyOf;d!=null&&d.length==2&&(d[0].type==="null"?(n.nullable=!0,i=d[1]):d[1].type==="null"&&(n.nullable=!0,i=d[0])),i.type instanceof Array&&rv(i.type,n);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;n.type=Object.values(Ue).includes(g.toUpperCase())?g.toUpperCase():Ue.TYPE_UNSPECIFIED}else if(o.includes(m))n[m]=Oi(g);else if(a.includes(m)){const y=[];for(const h of g){if(h.type=="null"){n.nullable=!0;continue}y.push(Oi(h))}n[m]=y}else if(r.includes(m)){const y={};for(const[h,v]of Object.entries(g))y[h]=Oi(v);n[m]=y}else{if(m==="additionalProperties")continue;n[m]=g}return n}function fr(i){return Oi(i)}function dr(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 pr(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 n of i.functionDeclarations)n.parameters&&(Object.keys(n.parameters).includes("$schema")?n.parametersJsonSchema||(n.parametersJsonSchema=n.parameters,delete n.parameters):n.parameters=Oi(n.parameters)),n.response&&(Object.keys(n.response).includes("$schema")?n.responseJsonSchema||(n.responseJsonSchema=n.response,delete n.response):n.response=Oi(n.response));return i}function Ki(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 n=[];for(const o of i)n.push(o);return n}function cv(i,n,o,a=1){const r=!n.startsWith(`${o}/`)&&n.split("/").length===a;return i.isVertexAI()?n.startsWith("projects/")?n:n.startsWith("locations/")?`projects/${i.getProject()}/${n}`:n.startsWith(`${o}/`)?`projects/${i.getProject()}/locations/${i.getLocation()}/${n}`:r?`projects/${i.getProject()}/locations/${i.getLocation()}/${o}/${n}`:n:r?`${o}/${n}`:n}function fn(i,n){if(typeof n!="string")throw new Error("name must be a string");return cv(i,n,"cachedContents")}function sh(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 Hn(i){return sr(i)}function fv(i){return i!=null&&typeof i=="object"&&"name"in i}function dv(i){return i!=null&&typeof i=="object"&&"video"in i}function pv(i){return i!=null&&typeof i=="object"&&"uri"in i}function uh(i){var n;let o;if(fv(i)&&(o=i.name),!(pv(i)&&(o=i.uri,o===void 0))&&!(dv(i)&&(o=(n=i.video)===null||n===void 0?void 0:n.uri,o===void 0))){if(typeof i=="string"&&(o=i),o===void 0)throw new Error("Could not extract file name from the provided input.");if(o.startsWith("https://")){const r=o.split("files/")[1].match(/[a-z0-9]+/);if(r===null)throw new Error(`Could not extract file name from URI ${o}`);o=r[0]}else o.startsWith("files/")&&(o=o.split("files/")[1]);return o}}function rh(i,n){let o;return i.isVertexAI()?o=n?"publishers/google/models":"models":o=n?"models":"tunedModels",o}function ch(i){for(const n of["models","tunedModels","publisherModels"])if(mv(i,n))return i[n];return[]}function mv(i,n){return i!==null&&typeof i=="object"&&n in i}function hv(i,n={}){const o=i,a={name:o.name,description:o.description,parametersJsonSchema:o.inputSchema};return o.outputSchema&&(a.responseJsonSchema=o.outputSchema),n.behavior&&(a.behavior=n.behavior),{functionDeclarations:[a]}}function gv(i,n={}){const o=[],a=new Set;for(const r of i){const d=r.name;if(a.has(d))throw new Error(`Duplicate function name ${d} found in MCP tools. Please ensure function names are unique.`);a.add(d);const m=hv(r,n);m.functionDeclarations&&o.push(...m.functionDeclarations)}return{functionDeclarations:o}}function fh(i,n){let o;if(typeof n=="string")if(i.isVertexAI())if(n.startsWith("gs://"))o={format:"jsonl",gcsUri:[n]};else if(n.startsWith("bq://"))o={format:"bigquery",bigqueryUri:n};else throw new Error(`Unsupported string source for Vertex AI: ${n}`);else if(n.startsWith("files/"))o={fileName:n};else throw new Error(`Unsupported string source for Gemini API: ${n}`);else if(Array.isArray(n)){if(i.isVertexAI())throw new Error("InlinedRequest[] is not supported in Vertex AI.");o={inlinedRequests:n}}else o=n;const a=[o.gcsUri,o.bigqueryUri].filter(Boolean).length,r=[o.inlinedRequests,o.fileName].filter(Boolean).length;if(i.isVertexAI()){if(r>0||a!==1)throw new Error("Exactly one of `gcsUri` or `bigqueryUri` must be set for Vertex AI.")}else if(a>0||r!==1)throw new Error("Exactly one of `inlinedRequests`, `fileName`, must be set for Gemini API.");return o}function yv(i){if(typeof i!="string")return i;const n=i;if(n.startsWith("gs://"))return{format:"jsonl",gcsUri:n};if(n.startsWith("bq://"))return{format:"bigquery",bigqueryUri:n};throw new Error(`Unsupported destination: ${n}`)}function dh(i){if(typeof i!="object"||i===null)return{};const n=i,o=n.inlinedResponses;if(typeof o!="object"||o===null)return i;const r=o.inlinedResponses;if(!Array.isArray(r)||r.length===0)return i;let d=!1;for(const m of r){if(typeof m!="object"||m===null)continue;const y=m.response;if(typeof y!="object"||y===null)continue;if(y.embedding!==void 0){d=!0;break}}return d&&(n.inlinedEmbedContentResponses=n.inlinedResponses,delete n.inlinedResponses),i}function Xi(i,n){const o=n;if(!i.isVertexAI()){if(/batches\/[^/]+$/.test(o))return o.split("/").pop();throw new Error(`Invalid batch job name: ${o}.`)}if(/^projects\/[^/]+\/locations\/[^/]+\/batchPredictionJobs\/[^/]+$/.test(o))return o.split("/").pop();if(/^\d+$/.test(o))return o;throw new Error(`Invalid batch job name: ${o}.`)}function ph(i){const n=i;return n==="BATCH_STATE_UNSPECIFIED"?"JOB_STATE_UNSPECIFIED":n==="BATCH_STATE_PENDING"?"JOB_STATE_PENDING":n==="BATCH_STATE_RUNNING"?"JOB_STATE_RUNNING":n==="BATCH_STATE_SUCCEEDED"?"JOB_STATE_SUCCEEDED":n==="BATCH_STATE_FAILED"?"JOB_STATE_FAILED":n==="BATCH_STATE_CANCELLED"?"JOB_STATE_CANCELLED":n==="BATCH_STATE_EXPIRED"?"JOB_STATE_EXPIRED":n}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function vv(i){const n={},o=u(i,["responsesFile"]);o!=null&&c(n,["fileName"],o);const a=u(i,["inlinedResponses","inlinedResponses"]);if(a!=null){let d=a;Array.isArray(d)&&(d=d.map(m=>Qv(m))),c(n,["inlinedResponses"],d)}const r=u(i,["inlinedEmbedContentResponses","inlinedResponses"]);if(r!=null){let d=r;Array.isArray(d)&&(d=d.map(m=>m)),c(n,["inlinedEmbedContentResponses"],d)}return n}function Tv(i){const n={},o=u(i,["predictionsFormat"]);o!=null&&c(n,["format"],o);const a=u(i,["gcsDestination","outputUriPrefix"]);a!=null&&c(n,["gcsUri"],a);const r=u(i,["bigqueryDestination","outputUri"]);return r!=null&&c(n,["bigqueryUri"],r),n}function Sv(i){const n={},o=u(i,["format"]);o!=null&&c(n,["predictionsFormat"],o);const a=u(i,["gcsUri"]);a!=null&&c(n,["gcsDestination","outputUriPrefix"],a);const r=u(i,["bigqueryUri"]);if(r!=null&&c(n,["bigqueryDestination","outputUri"],r),u(i,["fileName"])!==void 0)throw new Error("fileName parameter is not supported in Vertex AI.");if(u(i,["inlinedResponses"])!==void 0)throw new Error("inlinedResponses parameter is not supported in Vertex AI.");if(u(i,["inlinedEmbedContentResponses"])!==void 0)throw new Error("inlinedEmbedContentResponses parameter is not supported in Vertex AI.");return n}function da(i){const n={},o=u(i,["name"]);o!=null&&c(n,["name"],o);const a=u(i,["metadata","displayName"]);a!=null&&c(n,["displayName"],a);const r=u(i,["metadata","state"]);r!=null&&c(n,["state"],ph(r));const d=u(i,["metadata","createTime"]);d!=null&&c(n,["createTime"],d);const m=u(i,["metadata","endTime"]);m!=null&&c(n,["endTime"],m);const g=u(i,["metadata","updateTime"]);g!=null&&c(n,["updateTime"],g);const y=u(i,["metadata","model"]);y!=null&&c(n,["model"],y);const h=u(i,["metadata","output"]);return h!=null&&c(n,["dest"],vv(dh(h))),n}function ju(i){const n={},o=u(i,["name"]);o!=null&&c(n,["name"],o);const a=u(i,["displayName"]);a!=null&&c(n,["displayName"],a);const r=u(i,["state"]);r!=null&&c(n,["state"],ph(r));const d=u(i,["error"]);d!=null&&c(n,["error"],d);const m=u(i,["createTime"]);m!=null&&c(n,["createTime"],m);const g=u(i,["startTime"]);g!=null&&c(n,["startTime"],g);const y=u(i,["endTime"]);y!=null&&c(n,["endTime"],y);const h=u(i,["updateTime"]);h!=null&&c(n,["updateTime"],h);const v=u(i,["model"]);v!=null&&c(n,["model"],v);const S=u(i,["inputConfig"]);S!=null&&c(n,["src"],Ev(S));const _=u(i,["outputConfig"]);_!=null&&c(n,["dest"],Tv(dh(_)));const M=u(i,["completionStats"]);return M!=null&&c(n,["completionStats"],M),n}function Ev(i){const n={},o=u(i,["instancesFormat"]);o!=null&&c(n,["format"],o);const a=u(i,["gcsSource","uris"]);a!=null&&c(n,["gcsUri"],a);const r=u(i,["bigquerySource","inputUri"]);return r!=null&&c(n,["bigqueryUri"],r),n}function _v(i,n){const o={};if(u(n,["format"])!==void 0)throw new Error("format parameter is not supported in Gemini API.");if(u(n,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");if(u(n,["bigqueryUri"])!==void 0)throw new Error("bigqueryUri parameter is not supported in Gemini API.");const a=u(n,["fileName"]);a!=null&&c(o,["fileName"],a);const r=u(n,["inlinedRequests"]);if(r!=null){let d=r;Array.isArray(d)&&(d=d.map(m=>Xv(i,m))),c(o,["requests","requests"],d)}return o}function Cv(i){const n={},o=u(i,["format"]);o!=null&&c(n,["instancesFormat"],o);const a=u(i,["gcsUri"]);a!=null&&c(n,["gcsSource","uris"],a);const r=u(i,["bigqueryUri"]);if(r!=null&&c(n,["bigquerySource","inputUri"],r),u(i,["fileName"])!==void 0)throw new Error("fileName parameter is not supported in Vertex AI.");if(u(i,["inlinedRequests"])!==void 0)throw new Error("inlinedRequests parameter is not supported in Vertex AI.");return n}function Av(i){const n={},o=u(i,["data"]);if(o!=null&&c(n,["data"],o),u(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const a=u(i,["mimeType"]);return a!=null&&c(n,["mimeType"],a),n}function Rv(i,n){const o={},a=u(n,["name"]);return a!=null&&c(o,["_url","name"],Xi(i,a)),o}function Mv(i,n){const o={},a=u(n,["name"]);return a!=null&&c(o,["_url","name"],Xi(i,a)),o}function Nv(i){const n={},o=u(i,["content"]);o!=null&&c(n,["content"],o);const a=u(i,["citationMetadata"]);a!=null&&c(n,["citationMetadata"],xv(a));const r=u(i,["tokenCount"]);r!=null&&c(n,["tokenCount"],r);const d=u(i,["finishReason"]);d!=null&&c(n,["finishReason"],d);const m=u(i,["avgLogprobs"]);m!=null&&c(n,["avgLogprobs"],m);const g=u(i,["groundingMetadata"]);g!=null&&c(n,["groundingMetadata"],g);const y=u(i,["index"]);y!=null&&c(n,["index"],y);const h=u(i,["logprobsResult"]);h!=null&&c(n,["logprobsResult"],h);const v=u(i,["safetyRatings"]);if(v!=null){let _=v;Array.isArray(_)&&(_=_.map(M=>M)),c(n,["safetyRatings"],_)}const S=u(i,["urlContextMetadata"]);return S!=null&&c(n,["urlContextMetadata"],S),n}function xv(i){const n={},o=u(i,["citationSources"]);if(o!=null){let a=o;Array.isArray(a)&&(a=a.map(r=>r)),c(n,["citations"],a)}return n}function mh(i){const n={},o=u(i,["parts"]);if(o!=null){let r=o;Array.isArray(r)&&(r=r.map(d=>nT(d))),c(n,["parts"],r)}const a=u(i,["role"]);return a!=null&&c(n,["role"],a),n}function Dv(i,n){const o={},a=u(i,["displayName"]);if(n!==void 0&&a!=null&&c(n,["batch","displayName"],a),u(i,["dest"])!==void 0)throw new Error("dest parameter is not supported in Gemini API.");return o}function Iv(i,n){const o={},a=u(i,["displayName"]);n!==void 0&&a!=null&&c(n,["displayName"],a);const r=u(i,["dest"]);return n!==void 0&&r!=null&&c(n,["outputConfig"],Sv(yv(r))),o}function qm(i,n){const o={},a=u(n,["model"]);a!=null&&c(o,["_url","model"],Ae(i,a));const r=u(n,["src"]);r!=null&&c(o,["batch","inputConfig"],_v(i,fh(i,r)));const d=u(n,["config"]);return d!=null&&Dv(d,o),o}function Uv(i,n){const o={},a=u(n,["model"]);a!=null&&c(o,["model"],Ae(i,a));const r=u(n,["src"]);r!=null&&c(o,["inputConfig"],Cv(fh(i,r)));const d=u(n,["config"]);return d!=null&&Iv(d,o),o}function wv(i,n){const o={},a=u(i,["displayName"]);return n!==void 0&&a!=null&&c(n,["batch","displayName"],a),o}function bv(i,n){const o={},a=u(n,["model"]);a!=null&&c(o,["_url","model"],Ae(i,a));const r=u(n,["src"]);r!=null&&c(o,["batch","inputConfig"],Pv(i,r));const d=u(n,["config"]);return d!=null&&wv(d,o),o}function qv(i,n){const o={},a=u(n,["name"]);return a!=null&&c(o,["_url","name"],Xi(i,a)),o}function Lv(i,n){const o={},a=u(n,["name"]);return a!=null&&c(o,["_url","name"],Xi(i,a)),o}function Gv(i){const n={},o=u(i,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const a=u(i,["name"]);a!=null&&c(n,["name"],a);const r=u(i,["done"]);r!=null&&c(n,["done"],r);const d=u(i,["error"]);return d!=null&&c(n,["error"],d),n}function Hv(i){const n={},o=u(i,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const a=u(i,["name"]);a!=null&&c(n,["name"],a);const r=u(i,["done"]);r!=null&&c(n,["done"],r);const d=u(i,["error"]);return d!=null&&c(n,["error"],d),n}function Vv(i,n){const o={},a=u(n,["contents"]);if(a!=null){let d=cr(i,a);Array.isArray(d)&&(d=d.map(m=>m)),c(o,["requests[]","request","content"],d)}const r=u(n,["config"]);return r!=null&&(c(o,["_self"],zv(r,o)),L0(o,{"requests[].*":"requests[].request.*"})),o}function zv(i,n){const o={},a=u(i,["taskType"]);n!==void 0&&a!=null&&c(n,["requests[]","taskType"],a);const r=u(i,["title"]);n!==void 0&&r!=null&&c(n,["requests[]","title"],r);const d=u(i,["outputDimensionality"]);if(n!==void 0&&d!=null&&c(n,["requests[]","outputDimensionality"],d),u(i,["mimeType"])!==void 0)throw new Error("mimeType parameter is not supported in Gemini API.");if(u(i,["autoTruncate"])!==void 0)throw new Error("autoTruncate parameter is not supported in Gemini API.");return o}function Pv(i,n){const o={},a=u(n,["fileName"]);a!=null&&c(o,["file_name"],a);const r=u(n,["inlinedRequests"]);return r!=null&&c(o,["requests"],Vv(i,r)),o}function Bv(i){const n={};if(u(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=u(i,["fileUri"]);o!=null&&c(n,["fileUri"],o);const a=u(i,["mimeType"]);return a!=null&&c(n,["mimeType"],a),n}function kv(i,n,o){const a={},r=u(n,["systemInstruction"]);o!==void 0&&r!=null&&c(o,["systemInstruction"],mh(ot(r)));const d=u(n,["temperature"]);d!=null&&c(a,["temperature"],d);const m=u(n,["topP"]);m!=null&&c(a,["topP"],m);const g=u(n,["topK"]);g!=null&&c(a,["topK"],g);const y=u(n,["candidateCount"]);y!=null&&c(a,["candidateCount"],y);const h=u(n,["maxOutputTokens"]);h!=null&&c(a,["maxOutputTokens"],h);const v=u(n,["stopSequences"]);v!=null&&c(a,["stopSequences"],v);const S=u(n,["responseLogprobs"]);S!=null&&c(a,["responseLogprobs"],S);const _=u(n,["logprobs"]);_!=null&&c(a,["logprobs"],_);const M=u(n,["presencePenalty"]);M!=null&&c(a,["presencePenalty"],M);const z=u(n,["frequencyPenalty"]);z!=null&&c(a,["frequencyPenalty"],z);const P=u(n,["seed"]);P!=null&&c(a,["seed"],P);const O=u(n,["responseMimeType"]);O!=null&&c(a,["responseMimeType"],O);const k=u(n,["responseSchema"]);k!=null&&c(a,["responseSchema"],fr(k));const F=u(n,["responseJsonSchema"]);if(F!=null&&c(a,["responseJsonSchema"],F),u(n,["routingConfig"])!==void 0)throw new Error("routingConfig parameter is not supported in Gemini API.");if(u(n,["modelSelectionConfig"])!==void 0)throw new Error("modelSelectionConfig parameter is not supported in Gemini API.");const B=u(n,["safetySettings"]);if(o!==void 0&&B!=null){let ce=B;Array.isArray(ce)&&(ce=ce.map(He=>iT(He))),c(o,["safetySettings"],ce)}const Q=u(n,["tools"]);if(o!==void 0&&Q!=null){let ce=Ki(Q);Array.isArray(ce)&&(ce=ce.map(He=>lT(Ji(He)))),c(o,["tools"],ce)}const ne=u(n,["toolConfig"]);if(o!==void 0&&ne!=null&&c(o,["toolConfig"],ne),u(n,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const W=u(n,["cachedContent"]);o!==void 0&&W!=null&&c(o,["cachedContent"],fn(i,W));const J=u(n,["responseModalities"]);J!=null&&c(a,["responseModalities"],J);const he=u(n,["mediaResolution"]);he!=null&&c(a,["mediaResolution"],he);const ee=u(n,["speechConfig"]);if(ee!=null&&c(a,["speechConfig"],dr(ee)),u(n,["audioTimestamp"])!==void 0)throw new Error("audioTimestamp parameter is not supported in Gemini API.");const re=u(n,["thinkingConfig"]);re!=null&&c(a,["thinkingConfig"],re);const de=u(n,["imageConfig"]);return de!=null&&c(a,["imageConfig"],de),a}function Ov(i){const n={},o=u(i,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const a=u(i,["candidates"]);if(a!=null){let y=a;Array.isArray(y)&&(y=y.map(h=>Nv(h))),c(n,["candidates"],y)}const r=u(i,["modelVersion"]);r!=null&&c(n,["modelVersion"],r);const d=u(i,["promptFeedback"]);d!=null&&c(n,["promptFeedback"],d);const m=u(i,["responseId"]);m!=null&&c(n,["responseId"],m);const g=u(i,["usageMetadata"]);return g!=null&&c(n,["usageMetadata"],g),n}function Fv(i,n){const o={},a=u(n,["name"]);return a!=null&&c(o,["_url","name"],Xi(i,a)),o}function Yv(i,n){const o={},a=u(n,["name"]);return a!=null&&c(o,["_url","name"],Xi(i,a)),o}function Jv(i){const n={};if(u(i,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const o=u(i,["enableWidget"]);return o!=null&&c(n,["enableWidget"],o),n}function Kv(i){const n={};if(u(i,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(u(i,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const o=u(i,["timeRangeFilter"]);return o!=null&&c(n,["timeRangeFilter"],o),n}function Xv(i,n){const o={},a=u(n,["model"]);a!=null&&c(o,["request","model"],Ae(i,a));const r=u(n,["contents"]);if(r!=null){let g=qt(r);Array.isArray(g)&&(g=g.map(y=>mh(y))),c(o,["request","contents"],g)}const d=u(n,["metadata"]);d!=null&&c(o,["metadata"],d);const m=u(n,["config"]);return m!=null&&c(o,["request","generationConfig"],kv(i,m,u(o,["request"],{}))),o}function Qv(i){const n={},o=u(i,["response"]);o!=null&&c(n,["response"],Ov(o));const a=u(i,["error"]);return a!=null&&c(n,["error"],a),n}function Zv(i,n){const o={},a=u(i,["pageSize"]);n!==void 0&&a!=null&&c(n,["_query","pageSize"],a);const r=u(i,["pageToken"]);if(n!==void 0&&r!=null&&c(n,["_query","pageToken"],r),u(i,["filter"])!==void 0)throw new Error("filter parameter is not supported in Gemini API.");return o}function $v(i,n){const o={},a=u(i,["pageSize"]);n!==void 0&&a!=null&&c(n,["_query","pageSize"],a);const r=u(i,["pageToken"]);n!==void 0&&r!=null&&c(n,["_query","pageToken"],r);const d=u(i,["filter"]);return n!==void 0&&d!=null&&c(n,["_query","filter"],d),o}function Wv(i){const n={},o=u(i,["config"]);return o!=null&&Zv(o,n),n}function jv(i){const n={},o=u(i,["config"]);return o!=null&&$v(o,n),n}function eT(i){const n={},o=u(i,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const a=u(i,["nextPageToken"]);a!=null&&c(n,["nextPageToken"],a);const r=u(i,["operations"]);if(r!=null){let d=r;Array.isArray(d)&&(d=d.map(m=>da(m))),c(n,["batchJobs"],d)}return n}function tT(i){const n={},o=u(i,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const a=u(i,["nextPageToken"]);a!=null&&c(n,["nextPageToken"],a);const r=u(i,["batchPredictionJobs"]);if(r!=null){let d=r;Array.isArray(d)&&(d=d.map(m=>ju(m))),c(n,["batchJobs"],d)}return n}function nT(i){const n={},o=u(i,["functionCall"]);o!=null&&c(n,["functionCall"],o);const a=u(i,["codeExecutionResult"]);a!=null&&c(n,["codeExecutionResult"],a);const r=u(i,["executableCode"]);r!=null&&c(n,["executableCode"],r);const d=u(i,["fileData"]);d!=null&&c(n,["fileData"],Bv(d));const m=u(i,["functionResponse"]);m!=null&&c(n,["functionResponse"],m);const g=u(i,["inlineData"]);g!=null&&c(n,["inlineData"],Av(g));const y=u(i,["text"]);y!=null&&c(n,["text"],y);const h=u(i,["thought"]);h!=null&&c(n,["thought"],h);const v=u(i,["thoughtSignature"]);v!=null&&c(n,["thoughtSignature"],v);const S=u(i,["videoMetadata"]);return S!=null&&c(n,["videoMetadata"],S),n}function iT(i){const n={},o=u(i,["category"]);if(o!=null&&c(n,["category"],o),u(i,["method"])!==void 0)throw new Error("method parameter is not supported in Gemini API.");const a=u(i,["threshold"]);return a!=null&&c(n,["threshold"],a),n}function lT(i){const n={},o=u(i,["functionDeclarations"]);if(o!=null){let v=o;Array.isArray(v)&&(v=v.map(S=>S)),c(n,["functionDeclarations"],v)}if(u(i,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const a=u(i,["googleSearchRetrieval"]);a!=null&&c(n,["googleSearchRetrieval"],a);const r=u(i,["computerUse"]);r!=null&&c(n,["computerUse"],r);const d=u(i,["fileSearch"]);d!=null&&c(n,["fileSearch"],d);const m=u(i,["codeExecution"]);if(m!=null&&c(n,["codeExecution"],m),u(i,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const g=u(i,["googleMaps"]);g!=null&&c(n,["googleMaps"],Jv(g));const y=u(i,["googleSearch"]);y!=null&&c(n,["googleSearch"],Kv(y));const h=u(i,["urlContext"]);return h!=null&&c(n,["urlContext"],h),n}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */var rn;(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"})(rn||(rn={}));class ii{constructor(n,o,a,r){this.pageInternal=[],this.paramsInternal={},this.requestInternal=o,this.init(n,a,r)}init(n,o,a){var r,d;this.nameInternal=n,this.pageInternal=o[this.nameInternal]||[],this.sdkHttpResponseInternal=o==null?void 0:o.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=o.nextPageToken),this.paramsInternal=m,this.pageInternalSize=(d=(r=m.config)===null||r===void 0?void 0:r.pageSize)!==null&&d!==void 0?d:this.pageInternal.length}initNextPage(n){this.init(this.nameInternal,n,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(n){return this.pageInternal[n]}[Symbol.asyncIterator](){return{next:async()=>{if(this.idxInternal>=this.pageLength)if(this.hasNextPage())await this.nextPage();else return{value:void 0,done:!0};const n=this.getItem(this.idxInternal);return this.idxInternal+=1,{value:n,done:!1}},return:async()=>({value:void 0,done:!0})}}async nextPage(){if(!this.hasNextPage())throw new Error("No more pages to fetch.");const n=await this.requestInternal(this.params);return this.initNextPage(n),this.page}hasNextPage(){var n;return((n=this.params.config)===null||n===void 0?void 0:n.pageToken)!==void 0}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class oT extends cn{constructor(n){super(),this.apiClient=n,this.create=async o=>(this.apiClient.isVertexAI()&&(o.config=this.formatDestination(o.src,o.config)),this.createInternal(o)),this.createEmbeddings=async o=>{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(o)},this.list=async(o={})=>new ii(rn.PAGED_ITEM_BATCH_JOBS,a=>this.listInternal(a),await this.listInternal(o),o)}createInlinedGenerateContentRequest(n){const o=qm(this.apiClient,n),a=o._url,r=X("{model}:batchGenerateContent",a),g=o.batch.inputConfig.requests,y=g.requests,h=[];for(const v of y){const S=Object.assign({},v);if(S.systemInstruction){const _=S.systemInstruction;delete S.systemInstruction;const M=S.request;M.systemInstruction=_,S.request=M}h.push(S)}return g.requests=h,delete o.config,delete o._url,delete o._query,{path:r,body:o}}getGcsUri(n){if(typeof n=="string")return n.startsWith("gs://")?n:void 0;if(!Array.isArray(n)&&n.gcsUri&&n.gcsUri.length>0)return n.gcsUri[0]}getBigqueryUri(n){if(typeof n=="string")return n.startsWith("bq://")?n:void 0;if(!Array.isArray(n))return n.bigqueryUri}formatDestination(n,o){const a=o?Object.assign({},o):{},r=Date.now().toString();if(a.displayName||(a.displayName=`genaiBatchJob_${r}`),a.dest===void 0){const d=this.getGcsUri(n),m=this.getBigqueryUri(n);if(d)d.endsWith(".jsonl")?a.dest=`${d.slice(0,-6)}/dest`:a.dest=`${d}_dest_${r}`;else if(m)a.dest=`${m}_dest_${r}`;else throw new Error("Unsupported source for Vertex AI: No GCS or BigQuery URI found.")}return a}async createInternal(n){var o,a,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=Uv(this.apiClient,n);return g=X("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:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json()),m.then(v=>ju(v))}else{const h=qm(this.apiClient,n);return g=X("{model}:batchGenerateContent",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(v=>v.json()),m.then(v=>da(v))}}async createEmbeddingsInternal(n){var o,a;let r,d="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=bv(this.apiClient,n);return d=X("{model}:asyncBatchEmbedContent",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json()),r.then(y=>da(y))}}async get(n){var o,a,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=Yv(this.apiClient,n);return g=X("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:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json()),m.then(v=>ju(v))}else{const h=Fv(this.apiClient,n);return g=X("batches/{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(v=>v.json()),m.then(v=>da(v))}}async cancel(n){var o,a,r,d;let m="",g={};if(this.apiClient.isVertexAI()){const y=Mv(this.apiClient,n);m=X("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:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal})}else{const y=Rv(this.apiClient,n);m=X("batches/{name}:cancel",y._url),g=y._query,delete y._url,delete y._query,await this.apiClient.request({path:m,queryParams:g,body:JSON.stringify(y),httpMethod:"POST",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal})}}async listInternal(n){var o,a,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=jv(n);return g=X("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:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:v.headers},_})),m.then(v=>{const S=tT(v),_=new Im;return Object.assign(_,S),_})}else{const h=Wv(n);return g=X("batches",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(v=>v.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:v.headers},_})),m.then(v=>{const S=eT(v),_=new Im;return Object.assign(_,S),_})}}async delete(n){var o,a,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=Lv(this.apiClient,n);return g=X("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:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:v.headers},_})),m.then(v=>Hv(v))}else{const h=qv(this.apiClient,n);return g=X("batches/{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"DELETE",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(v=>v.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:v.headers},_})),m.then(v=>Gv(v))}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function aT(i){const n={},o=u(i,["data"]);if(o!=null&&c(n,["data"],o),u(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const a=u(i,["mimeType"]);return a!=null&&c(n,["mimeType"],a),n}function Lm(i){const n={},o=u(i,["parts"]);if(o!=null){let r=o;Array.isArray(r)&&(r=r.map(d=>NT(d))),c(n,["parts"],r)}const a=u(i,["role"]);return a!=null&&c(n,["role"],a),n}function sT(i,n){const o={},a=u(i,["ttl"]);n!==void 0&&a!=null&&c(n,["ttl"],a);const r=u(i,["expireTime"]);n!==void 0&&r!=null&&c(n,["expireTime"],r);const d=u(i,["displayName"]);n!==void 0&&d!=null&&c(n,["displayName"],d);const m=u(i,["contents"]);if(n!==void 0&&m!=null){let v=qt(m);Array.isArray(v)&&(v=v.map(S=>Lm(S))),c(n,["contents"],v)}const g=u(i,["systemInstruction"]);n!==void 0&&g!=null&&c(n,["systemInstruction"],Lm(ot(g)));const y=u(i,["tools"]);if(n!==void 0&&y!=null){let v=y;Array.isArray(v)&&(v=v.map(S=>xT(S))),c(n,["tools"],v)}const h=u(i,["toolConfig"]);if(n!==void 0&&h!=null&&c(n,["toolConfig"],h),u(i,["kmsKeyName"])!==void 0)throw new Error("kmsKeyName parameter is not supported in Gemini API.");return o}function uT(i,n){const o={},a=u(i,["ttl"]);n!==void 0&&a!=null&&c(n,["ttl"],a);const r=u(i,["expireTime"]);n!==void 0&&r!=null&&c(n,["expireTime"],r);const d=u(i,["displayName"]);n!==void 0&&d!=null&&c(n,["displayName"],d);const m=u(i,["contents"]);if(n!==void 0&&m!=null){let S=qt(m);Array.isArray(S)&&(S=S.map(_=>_)),c(n,["contents"],S)}const g=u(i,["systemInstruction"]);n!==void 0&&g!=null&&c(n,["systemInstruction"],ot(g));const y=u(i,["tools"]);if(n!==void 0&&y!=null){let S=y;Array.isArray(S)&&(S=S.map(_=>DT(_))),c(n,["tools"],S)}const h=u(i,["toolConfig"]);n!==void 0&&h!=null&&c(n,["toolConfig"],h);const v=u(i,["kmsKeyName"]);return n!==void 0&&v!=null&&c(n,["encryption_spec","kmsKeyName"],v),o}function rT(i,n){const o={},a=u(n,["model"]);a!=null&&c(o,["model"],nh(i,a));const r=u(n,["config"]);return r!=null&&sT(r,o),o}function cT(i,n){const o={},a=u(n,["model"]);a!=null&&c(o,["model"],nh(i,a));const r=u(n,["config"]);return r!=null&&uT(r,o),o}function fT(i,n){const o={},a=u(n,["name"]);return a!=null&&c(o,["_url","name"],fn(i,a)),o}function dT(i,n){const o={},a=u(n,["name"]);return a!=null&&c(o,["_url","name"],fn(i,a)),o}function pT(i){const n={},o=u(i,["sdkHttpResponse"]);return o!=null&&c(n,["sdkHttpResponse"],o),n}function mT(i){const n={},o=u(i,["sdkHttpResponse"]);return o!=null&&c(n,["sdkHttpResponse"],o),n}function hT(i){const n={};if(u(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=u(i,["fileUri"]);o!=null&&c(n,["fileUri"],o);const a=u(i,["mimeType"]);return a!=null&&c(n,["mimeType"],a),n}function gT(i){const n={};if(u(i,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");const o=u(i,["description"]);o!=null&&c(n,["description"],o);const a=u(i,["name"]);a!=null&&c(n,["name"],a);const r=u(i,["parameters"]);r!=null&&c(n,["parameters"],r);const d=u(i,["parametersJsonSchema"]);d!=null&&c(n,["parametersJsonSchema"],d);const m=u(i,["response"]);m!=null&&c(n,["response"],m);const g=u(i,["responseJsonSchema"]);return g!=null&&c(n,["responseJsonSchema"],g),n}function yT(i,n){const o={},a=u(n,["name"]);return a!=null&&c(o,["_url","name"],fn(i,a)),o}function vT(i,n){const o={},a=u(n,["name"]);return a!=null&&c(o,["_url","name"],fn(i,a)),o}function TT(i){const n={};if(u(i,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const o=u(i,["enableWidget"]);return o!=null&&c(n,["enableWidget"],o),n}function ST(i){const n={};if(u(i,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(u(i,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const o=u(i,["timeRangeFilter"]);return o!=null&&c(n,["timeRangeFilter"],o),n}function ET(i,n){const o={},a=u(i,["pageSize"]);n!==void 0&&a!=null&&c(n,["_query","pageSize"],a);const r=u(i,["pageToken"]);return n!==void 0&&r!=null&&c(n,["_query","pageToken"],r),o}function _T(i,n){const o={},a=u(i,["pageSize"]);n!==void 0&&a!=null&&c(n,["_query","pageSize"],a);const r=u(i,["pageToken"]);return n!==void 0&&r!=null&&c(n,["_query","pageToken"],r),o}function CT(i){const n={},o=u(i,["config"]);return o!=null&&ET(o,n),n}function AT(i){const n={},o=u(i,["config"]);return o!=null&&_T(o,n),n}function RT(i){const n={},o=u(i,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const a=u(i,["nextPageToken"]);a!=null&&c(n,["nextPageToken"],a);const r=u(i,["cachedContents"]);if(r!=null){let d=r;Array.isArray(d)&&(d=d.map(m=>m)),c(n,["cachedContents"],d)}return n}function MT(i){const n={},o=u(i,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const a=u(i,["nextPageToken"]);a!=null&&c(n,["nextPageToken"],a);const r=u(i,["cachedContents"]);if(r!=null){let d=r;Array.isArray(d)&&(d=d.map(m=>m)),c(n,["cachedContents"],d)}return n}function NT(i){const n={},o=u(i,["functionCall"]);o!=null&&c(n,["functionCall"],o);const a=u(i,["codeExecutionResult"]);a!=null&&c(n,["codeExecutionResult"],a);const r=u(i,["executableCode"]);r!=null&&c(n,["executableCode"],r);const d=u(i,["fileData"]);d!=null&&c(n,["fileData"],hT(d));const m=u(i,["functionResponse"]);m!=null&&c(n,["functionResponse"],m);const g=u(i,["inlineData"]);g!=null&&c(n,["inlineData"],aT(g));const y=u(i,["text"]);y!=null&&c(n,["text"],y);const h=u(i,["thought"]);h!=null&&c(n,["thought"],h);const v=u(i,["thoughtSignature"]);v!=null&&c(n,["thoughtSignature"],v);const S=u(i,["videoMetadata"]);return S!=null&&c(n,["videoMetadata"],S),n}function xT(i){const n={},o=u(i,["functionDeclarations"]);if(o!=null){let v=o;Array.isArray(v)&&(v=v.map(S=>S)),c(n,["functionDeclarations"],v)}if(u(i,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const a=u(i,["googleSearchRetrieval"]);a!=null&&c(n,["googleSearchRetrieval"],a);const r=u(i,["computerUse"]);r!=null&&c(n,["computerUse"],r);const d=u(i,["fileSearch"]);d!=null&&c(n,["fileSearch"],d);const m=u(i,["codeExecution"]);if(m!=null&&c(n,["codeExecution"],m),u(i,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const g=u(i,["googleMaps"]);g!=null&&c(n,["googleMaps"],TT(g));const y=u(i,["googleSearch"]);y!=null&&c(n,["googleSearch"],ST(y));const h=u(i,["urlContext"]);return h!=null&&c(n,["urlContext"],h),n}function DT(i){const n={},o=u(i,["functionDeclarations"]);if(o!=null){let S=o;Array.isArray(S)&&(S=S.map(_=>gT(_))),c(n,["functionDeclarations"],S)}const a=u(i,["retrieval"]);a!=null&&c(n,["retrieval"],a);const r=u(i,["googleSearchRetrieval"]);r!=null&&c(n,["googleSearchRetrieval"],r);const d=u(i,["computerUse"]);if(d!=null&&c(n,["computerUse"],d),u(i,["fileSearch"])!==void 0)throw new Error("fileSearch parameter is not supported in Vertex AI.");const m=u(i,["codeExecution"]);m!=null&&c(n,["codeExecution"],m);const g=u(i,["enterpriseWebSearch"]);g!=null&&c(n,["enterpriseWebSearch"],g);const y=u(i,["googleMaps"]);y!=null&&c(n,["googleMaps"],y);const h=u(i,["googleSearch"]);h!=null&&c(n,["googleSearch"],h);const v=u(i,["urlContext"]);return v!=null&&c(n,["urlContext"],v),n}function IT(i,n){const o={},a=u(i,["ttl"]);n!==void 0&&a!=null&&c(n,["ttl"],a);const r=u(i,["expireTime"]);return n!==void 0&&r!=null&&c(n,["expireTime"],r),o}function UT(i,n){const o={},a=u(i,["ttl"]);n!==void 0&&a!=null&&c(n,["ttl"],a);const r=u(i,["expireTime"]);return n!==void 0&&r!=null&&c(n,["expireTime"],r),o}function wT(i,n){const o={},a=u(n,["name"]);a!=null&&c(o,["_url","name"],fn(i,a));const r=u(n,["config"]);return r!=null&&IT(r,o),o}function bT(i,n){const o={},a=u(n,["name"]);a!=null&&c(o,["_url","name"],fn(i,a));const r=u(n,["config"]);return r!=null&&UT(r,o),o}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class qT extends cn{constructor(n){super(),this.apiClient=n,this.list=async(o={})=>new ii(rn.PAGED_ITEM_CACHED_CONTENTS,a=>this.listInternal(a),await this.listInternal(o),o)}async create(n){var o,a,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=cT(this.apiClient,n);return g=X("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:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json()),m.then(v=>v)}else{const h=rT(this.apiClient,n);return g=X("cachedContents",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(v=>v.json()),m.then(v=>v)}}async get(n){var o,a,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=vT(this.apiClient,n);return g=X("{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:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json()),m.then(v=>v)}else{const h=yT(this.apiClient,n);return g=X("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(v=>v.json()),m.then(v=>v)}}async delete(n){var o,a,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=dT(this.apiClient,n);return g=X("{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:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:v.headers},_})),m.then(v=>{const S=mT(v),_=new xm;return Object.assign(_,S),_})}else{const h=fT(this.apiClient,n);return g=X("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"DELETE",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(v=>v.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:v.headers},_})),m.then(v=>{const S=pT(v),_=new xm;return Object.assign(_,S),_})}}async update(n){var o,a,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=bT(this.apiClient,n);return g=X("{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:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json()),m.then(v=>v)}else{const h=wT(this.apiClient,n);return g=X("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"PATCH",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(v=>v.json()),m.then(v=>v)}}async listInternal(n){var o,a,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=AT(n);return g=X("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:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:v.headers},_})),m.then(v=>{const S=MT(v),_=new Dm;return Object.assign(_,S),_})}else{const h=CT(n);return g=X("cachedContents",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(v=>v.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:v.headers},_})),m.then(v=>{const S=RT(v),_=new Dm;return Object.assign(_,S),_})}}}function Gm(i){var n=typeof Symbol=="function"&&Symbol.iterator,o=n&&i[n],a=0;if(o)return o.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&a>=i.length&&(i=void 0),{value:i&&i[a++],done:!i}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function Le(i){return this instanceof Le?(this.v=i,this):new Le(i)}function Fi(i,n,o){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var a=o.apply(i,n||[]),r,d=[];return r=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),g("next"),g("throw"),g("return",m),r[Symbol.asyncIterator]=function(){return this},r;function m(M){return function(z){return Promise.resolve(z).then(M,S)}}function g(M,z){a[M]&&(r[M]=function(P){return new Promise(function(O,k){d.push([M,P,O,k])>1||y(M,P)})},z&&(r[M]=z(r[M])))}function y(M,z){try{h(a[M](z))}catch(P){_(d[0][3],P)}}function h(M){M.value instanceof Le?Promise.resolve(M.value.v).then(v,S):_(d[0][2],M)}function v(M){y("next",M)}function S(M){y("throw",M)}function _(M,z){M(z),d.shift(),d.length&&y(d[0][0],d[0][1])}}function Yl(i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=i[Symbol.asyncIterator],o;return n?n.call(i):(i=typeof Gm=="function"?Gm(i):i[Symbol.iterator](),o={},a("next"),a("throw"),a("return"),o[Symbol.asyncIterator]=function(){return this},o);function a(d){o[d]=i[d]&&function(m){return new Promise(function(g,y){m=i[d](m),r(g,y,m.done,m.value)})}}function r(d,m,g,y){Promise.resolve(y).then(function(h){d({value:h,done:g})},m)}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function LT(i){var n;if(i.candidates==null||i.candidates.length===0)return!1;const o=(n=i.candidates[0])===null||n===void 0?void 0:n.content;return o===void 0?!1:hh(o)}function hh(i){if(i.parts===void 0||i.parts.length===0)return!1;for(const n of i.parts)if(n===void 0||Object.keys(n).length===0)return!1;return!0}function GT(i){if(i.length!==0){for(const n of i)if(n.role!=="user"&&n.role!=="model")throw new Error(`Role must be user or model, but got ${n.role}.`)}}function Hm(i){if(i===void 0||i.length===0)return[];const n=[],o=i.length;let a=0;for(;a{var d,m,g;const y=await r,h=(m=(d=y.candidates)===null||d===void 0?void 0:d[0])===null||m===void 0?void 0:m.content,v=y.automaticFunctionCallingHistory,S=this.getHistory(!0).length;let _=[];v!=null&&(_=(g=v.slice(S))!==null&&g!==void 0?g:[]);const M=h?[h]:[];this.recordHistory(a,M,_)})(),await this.sendPromise.catch(()=>{this.sendPromise=Promise.resolve()}),r}async sendMessageStream(n){var o;await this.sendPromise;const a=ot(n.message),r=this.modelsModule.generateContentStream({model:this.model,contents:this.getHistory(!0).concat(a),config:(o=n.config)!==null&&o!==void 0?o:this.config});this.sendPromise=r.then(()=>{}).catch(()=>{});const d=await r;return this.processStreamResponse(d,a)}getHistory(n=!1){const o=n?Hm(this.history):this.history;return structuredClone(o)}processStreamResponse(n,o){var a,r;return Fi(this,arguments,function*(){var m,g,y,h;const v=[];try{for(var S=!0,_=Yl(n),M;M=yield Le(_.next()),m=M.done,!m;S=!0){h=M.value,S=!1;const z=h;if(LT(z)){const P=(r=(a=z.candidates)===null||a===void 0?void 0:a[0])===null||r===void 0?void 0:r.content;P!==void 0&&v.push(P)}yield yield Le(z)}}catch(z){g={error:z}}finally{try{!S&&!m&&(y=_.return)&&(yield Le(y.call(_)))}finally{if(g)throw g.error}}this.recordHistory(o,v)})}recordHistory(n,o,a){let r=[];o.length>0&&o.every(d=>d.role!==void 0)?r=o:r.push({role:"model",parts:[]}),a&&a.length>0?this.history.push(...Hm(a)):this.history.push(n),this.history.push(...r)}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class Sa extends Error{constructor(n){super(n.message),this.name="ApiError",this.status=n.status,Object.setPrototypeOf(this,Sa.prototype)}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function zT(i){const n={},o=u(i,["file"]);return o!=null&&c(n,["file"],o),n}function PT(i){const n={},o=u(i,["sdkHttpResponse"]);return o!=null&&c(n,["sdkHttpResponse"],o),n}function BT(i){const n={},o=u(i,["name"]);return o!=null&&c(n,["_url","file"],uh(o)),n}function kT(i){const n={},o=u(i,["sdkHttpResponse"]);return o!=null&&c(n,["sdkHttpResponse"],o),n}function OT(i){const n={},o=u(i,["name"]);return o!=null&&c(n,["_url","file"],uh(o)),n}function FT(i,n){const o={},a=u(i,["pageSize"]);n!==void 0&&a!=null&&c(n,["_query","pageSize"],a);const r=u(i,["pageToken"]);return n!==void 0&&r!=null&&c(n,["_query","pageToken"],r),o}function YT(i){const n={},o=u(i,["config"]);return o!=null&&FT(o,n),n}function JT(i){const n={},o=u(i,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const a=u(i,["nextPageToken"]);a!=null&&c(n,["nextPageToken"],a);const r=u(i,["files"]);if(r!=null){let d=r;Array.isArray(d)&&(d=d.map(m=>m)),c(n,["files"],d)}return n}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class KT extends cn{constructor(n){super(),this.apiClient=n,this.list=async(o={})=>new ii(rn.PAGED_ITEM_FILES,a=>this.listInternal(a),await this.listInternal(o),o)}async upload(n){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(n.file,n.config).then(o=>o)}async download(n){await this.apiClient.downloadFile(n)}async listInternal(n){var o,a;let r,d="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=YT(n);return d=X("files",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:m,body:JSON.stringify(g),httpMethod:"GET",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json().then(h=>{const v=h;return v.sdkHttpResponse={headers:y.headers},v})),r.then(y=>{const h=JT(y),v=new lv;return Object.assign(v,h),v})}}async createInternal(n){var o,a;let r,d="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=zT(n);return d=X("upload/v1beta/files",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json()),r.then(y=>{const h=PT(y),v=new ov;return Object.assign(v,h),v})}}async get(n){var o,a;let r,d="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=OT(n);return d=X("files/{file}",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:m,body:JSON.stringify(g),httpMethod:"GET",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json()),r.then(y=>y)}}async delete(n){var o,a;let r,d="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=BT(n);return d=X("files/{file}",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:m,body:JSON.stringify(g),httpMethod:"DELETE",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json().then(h=>{const v=h;return v.sdkHttpResponse={headers:y.headers},v})),r.then(y=>{const h=kT(y),v=new av;return Object.assign(v,h),v})}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function pa(i){const n={},o=u(i,["data"]);if(o!=null&&c(n,["data"],o),u(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const a=u(i,["mimeType"]);return a!=null&&c(n,["mimeType"],a),n}function XT(i){const n={},o=u(i,["parts"]);if(o!=null){let r=o;Array.isArray(r)&&(r=r.map(d=>rS(d))),c(n,["parts"],r)}const a=u(i,["role"]);return a!=null&&c(n,["role"],a),n}function QT(i){const n={};if(u(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=u(i,["fileUri"]);o!=null&&c(n,["fileUri"],o);const a=u(i,["mimeType"]);return a!=null&&c(n,["mimeType"],a),n}function ZT(i){const n={};if(u(i,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");const o=u(i,["description"]);o!=null&&c(n,["description"],o);const a=u(i,["name"]);a!=null&&c(n,["name"],a);const r=u(i,["parameters"]);r!=null&&c(n,["parameters"],r);const d=u(i,["parametersJsonSchema"]);d!=null&&c(n,["parametersJsonSchema"],d);const m=u(i,["response"]);m!=null&&c(n,["response"],m);const g=u(i,["responseJsonSchema"]);return g!=null&&c(n,["responseJsonSchema"],g),n}function $T(i){const n={},o=u(i,["modelSelectionConfig"]);o!=null&&c(n,["modelConfig"],o);const a=u(i,["responseJsonSchema"]);a!=null&&c(n,["responseJsonSchema"],a);const r=u(i,["audioTimestamp"]);r!=null&&c(n,["audioTimestamp"],r);const d=u(i,["candidateCount"]);d!=null&&c(n,["candidateCount"],d);const m=u(i,["enableAffectiveDialog"]);m!=null&&c(n,["enableAffectiveDialog"],m);const g=u(i,["frequencyPenalty"]);g!=null&&c(n,["frequencyPenalty"],g);const y=u(i,["logprobs"]);y!=null&&c(n,["logprobs"],y);const h=u(i,["maxOutputTokens"]);h!=null&&c(n,["maxOutputTokens"],h);const v=u(i,["mediaResolution"]);v!=null&&c(n,["mediaResolution"],v);const S=u(i,["presencePenalty"]);S!=null&&c(n,["presencePenalty"],S);const _=u(i,["responseLogprobs"]);_!=null&&c(n,["responseLogprobs"],_);const M=u(i,["responseMimeType"]);M!=null&&c(n,["responseMimeType"],M);const z=u(i,["responseModalities"]);z!=null&&c(n,["responseModalities"],z);const P=u(i,["responseSchema"]);P!=null&&c(n,["responseSchema"],P);const O=u(i,["routingConfig"]);O!=null&&c(n,["routingConfig"],O);const k=u(i,["seed"]);k!=null&&c(n,["seed"],k);const F=u(i,["speechConfig"]);F!=null&&c(n,["speechConfig"],gh(F));const B=u(i,["stopSequences"]);B!=null&&c(n,["stopSequences"],B);const Q=u(i,["temperature"]);Q!=null&&c(n,["temperature"],Q);const ne=u(i,["thinkingConfig"]);ne!=null&&c(n,["thinkingConfig"],ne);const W=u(i,["topK"]);W!=null&&c(n,["topK"],W);const J=u(i,["topP"]);if(J!=null&&c(n,["topP"],J),u(i,["enableEnhancedCivicAnswers"])!==void 0)throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");return n}function WT(i){const n={};if(u(i,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const o=u(i,["enableWidget"]);return o!=null&&c(n,["enableWidget"],o),n}function jT(i){const n={};if(u(i,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(u(i,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const o=u(i,["timeRangeFilter"]);return o!=null&&c(n,["timeRangeFilter"],o),n}function eS(i,n){const o={},a=u(i,["generationConfig"]);n!==void 0&&a!=null&&c(n,["setup","generationConfig"],a);const r=u(i,["responseModalities"]);n!==void 0&&r!=null&&c(n,["setup","generationConfig","responseModalities"],r);const d=u(i,["temperature"]);n!==void 0&&d!=null&&c(n,["setup","generationConfig","temperature"],d);const m=u(i,["topP"]);n!==void 0&&m!=null&&c(n,["setup","generationConfig","topP"],m);const g=u(i,["topK"]);n!==void 0&&g!=null&&c(n,["setup","generationConfig","topK"],g);const y=u(i,["maxOutputTokens"]);n!==void 0&&y!=null&&c(n,["setup","generationConfig","maxOutputTokens"],y);const h=u(i,["mediaResolution"]);n!==void 0&&h!=null&&c(n,["setup","generationConfig","mediaResolution"],h);const v=u(i,["seed"]);n!==void 0&&v!=null&&c(n,["setup","generationConfig","seed"],v);const S=u(i,["speechConfig"]);n!==void 0&&S!=null&&c(n,["setup","generationConfig","speechConfig"],pr(S));const _=u(i,["thinkingConfig"]);n!==void 0&&_!=null&&c(n,["setup","generationConfig","thinkingConfig"],_);const M=u(i,["enableAffectiveDialog"]);n!==void 0&&M!=null&&c(n,["setup","generationConfig","enableAffectiveDialog"],M);const z=u(i,["systemInstruction"]);n!==void 0&&z!=null&&c(n,["setup","systemInstruction"],XT(ot(z)));const P=u(i,["tools"]);if(n!==void 0&&P!=null){let W=Ki(P);Array.isArray(W)&&(W=W.map(J=>fS(Ji(J)))),c(n,["setup","tools"],W)}const O=u(i,["sessionResumption"]);n!==void 0&&O!=null&&c(n,["setup","sessionResumption"],cS(O));const k=u(i,["inputAudioTranscription"]);n!==void 0&&k!=null&&c(n,["setup","inputAudioTranscription"],k);const F=u(i,["outputAudioTranscription"]);n!==void 0&&F!=null&&c(n,["setup","outputAudioTranscription"],F);const B=u(i,["realtimeInputConfig"]);n!==void 0&&B!=null&&c(n,["setup","realtimeInputConfig"],B);const Q=u(i,["contextWindowCompression"]);n!==void 0&&Q!=null&&c(n,["setup","contextWindowCompression"],Q);const ne=u(i,["proactivity"]);return n!==void 0&&ne!=null&&c(n,["setup","proactivity"],ne),o}function tS(i,n){const o={},a=u(i,["generationConfig"]);n!==void 0&&a!=null&&c(n,["setup","generationConfig"],$T(a));const r=u(i,["responseModalities"]);n!==void 0&&r!=null&&c(n,["setup","generationConfig","responseModalities"],r);const d=u(i,["temperature"]);n!==void 0&&d!=null&&c(n,["setup","generationConfig","temperature"],d);const m=u(i,["topP"]);n!==void 0&&m!=null&&c(n,["setup","generationConfig","topP"],m);const g=u(i,["topK"]);n!==void 0&&g!=null&&c(n,["setup","generationConfig","topK"],g);const y=u(i,["maxOutputTokens"]);n!==void 0&&y!=null&&c(n,["setup","generationConfig","maxOutputTokens"],y);const h=u(i,["mediaResolution"]);n!==void 0&&h!=null&&c(n,["setup","generationConfig","mediaResolution"],h);const v=u(i,["seed"]);n!==void 0&&v!=null&&c(n,["setup","generationConfig","seed"],v);const S=u(i,["speechConfig"]);n!==void 0&&S!=null&&c(n,["setup","generationConfig","speechConfig"],gh(pr(S)));const _=u(i,["thinkingConfig"]);n!==void 0&&_!=null&&c(n,["setup","generationConfig","thinkingConfig"],_);const M=u(i,["enableAffectiveDialog"]);n!==void 0&&M!=null&&c(n,["setup","generationConfig","enableAffectiveDialog"],M);const z=u(i,["systemInstruction"]);n!==void 0&&z!=null&&c(n,["setup","systemInstruction"],ot(z));const P=u(i,["tools"]);if(n!==void 0&&P!=null){let W=Ki(P);Array.isArray(W)&&(W=W.map(J=>dS(Ji(J)))),c(n,["setup","tools"],W)}const O=u(i,["sessionResumption"]);n!==void 0&&O!=null&&c(n,["setup","sessionResumption"],O);const k=u(i,["inputAudioTranscription"]);n!==void 0&&k!=null&&c(n,["setup","inputAudioTranscription"],k);const F=u(i,["outputAudioTranscription"]);n!==void 0&&F!=null&&c(n,["setup","outputAudioTranscription"],F);const B=u(i,["realtimeInputConfig"]);n!==void 0&&B!=null&&c(n,["setup","realtimeInputConfig"],B);const Q=u(i,["contextWindowCompression"]);n!==void 0&&Q!=null&&c(n,["setup","contextWindowCompression"],Q);const ne=u(i,["proactivity"]);return n!==void 0&&ne!=null&&c(n,["setup","proactivity"],ne),o}function nS(i,n){const o={},a=u(n,["model"]);a!=null&&c(o,["setup","model"],Ae(i,a));const r=u(n,["config"]);return r!=null&&c(o,["config"],eS(r,o)),o}function iS(i,n){const o={},a=u(n,["model"]);a!=null&&c(o,["setup","model"],Ae(i,a));const r=u(n,["config"]);return r!=null&&c(o,["config"],tS(r,o)),o}function lS(i){const n={},o=u(i,["musicGenerationConfig"]);return o!=null&&c(n,["musicGenerationConfig"],o),n}function oS(i){const n={},o=u(i,["weightedPrompts"]);if(o!=null){let a=o;Array.isArray(a)&&(a=a.map(r=>r)),c(n,["weightedPrompts"],a)}return n}function aS(i){const n={},o=u(i,["media"]);if(o!=null){let h=ih(o);Array.isArray(h)&&(h=h.map(v=>pa(v))),c(n,["mediaChunks"],h)}const a=u(i,["audio"]);a!=null&&c(n,["audio"],pa(oh(a)));const r=u(i,["audioStreamEnd"]);r!=null&&c(n,["audioStreamEnd"],r);const d=u(i,["video"]);d!=null&&c(n,["video"],pa(lh(d)));const m=u(i,["text"]);m!=null&&c(n,["text"],m);const g=u(i,["activityStart"]);g!=null&&c(n,["activityStart"],g);const y=u(i,["activityEnd"]);return y!=null&&c(n,["activityEnd"],y),n}function sS(i){const n={},o=u(i,["media"]);if(o!=null){let h=ih(o);Array.isArray(h)&&(h=h.map(v=>v)),c(n,["mediaChunks"],h)}const a=u(i,["audio"]);a!=null&&c(n,["audio"],oh(a));const r=u(i,["audioStreamEnd"]);r!=null&&c(n,["audioStreamEnd"],r);const d=u(i,["video"]);d!=null&&c(n,["video"],lh(d));const m=u(i,["text"]);m!=null&&c(n,["text"],m);const g=u(i,["activityStart"]);g!=null&&c(n,["activityStart"],g);const y=u(i,["activityEnd"]);return y!=null&&c(n,["activityEnd"],y),n}function uS(i){const n={},o=u(i,["setupComplete"]);o!=null&&c(n,["setupComplete"],o);const a=u(i,["serverContent"]);a!=null&&c(n,["serverContent"],a);const r=u(i,["toolCall"]);r!=null&&c(n,["toolCall"],r);const d=u(i,["toolCallCancellation"]);d!=null&&c(n,["toolCallCancellation"],d);const m=u(i,["usageMetadata"]);m!=null&&c(n,["usageMetadata"],pS(m));const g=u(i,["goAway"]);g!=null&&c(n,["goAway"],g);const y=u(i,["sessionResumptionUpdate"]);return y!=null&&c(n,["sessionResumptionUpdate"],y),n}function rS(i){const n={},o=u(i,["functionCall"]);o!=null&&c(n,["functionCall"],o);const a=u(i,["codeExecutionResult"]);a!=null&&c(n,["codeExecutionResult"],a);const r=u(i,["executableCode"]);r!=null&&c(n,["executableCode"],r);const d=u(i,["fileData"]);d!=null&&c(n,["fileData"],QT(d));const m=u(i,["functionResponse"]);m!=null&&c(n,["functionResponse"],m);const g=u(i,["inlineData"]);g!=null&&c(n,["inlineData"],pa(g));const y=u(i,["text"]);y!=null&&c(n,["text"],y);const h=u(i,["thought"]);h!=null&&c(n,["thought"],h);const v=u(i,["thoughtSignature"]);v!=null&&c(n,["thoughtSignature"],v);const S=u(i,["videoMetadata"]);return S!=null&&c(n,["videoMetadata"],S),n}function cS(i){const n={},o=u(i,["handle"]);if(o!=null&&c(n,["handle"],o),u(i,["transparent"])!==void 0)throw new Error("transparent parameter is not supported in Gemini API.");return n}function gh(i){const n={},o=u(i,["languageCode"]);o!=null&&c(n,["languageCode"],o);const a=u(i,["voiceConfig"]);if(a!=null&&c(n,["voiceConfig"],a),u(i,["multiSpeakerVoiceConfig"])!==void 0)throw new Error("multiSpeakerVoiceConfig parameter is not supported in Vertex AI.");return n}function fS(i){const n={},o=u(i,["functionDeclarations"]);if(o!=null){let v=o;Array.isArray(v)&&(v=v.map(S=>S)),c(n,["functionDeclarations"],v)}if(u(i,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const a=u(i,["googleSearchRetrieval"]);a!=null&&c(n,["googleSearchRetrieval"],a);const r=u(i,["computerUse"]);r!=null&&c(n,["computerUse"],r);const d=u(i,["fileSearch"]);d!=null&&c(n,["fileSearch"],d);const m=u(i,["codeExecution"]);if(m!=null&&c(n,["codeExecution"],m),u(i,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const g=u(i,["googleMaps"]);g!=null&&c(n,["googleMaps"],WT(g));const y=u(i,["googleSearch"]);y!=null&&c(n,["googleSearch"],jT(y));const h=u(i,["urlContext"]);return h!=null&&c(n,["urlContext"],h),n}function dS(i){const n={},o=u(i,["functionDeclarations"]);if(o!=null){let S=o;Array.isArray(S)&&(S=S.map(_=>ZT(_))),c(n,["functionDeclarations"],S)}const a=u(i,["retrieval"]);a!=null&&c(n,["retrieval"],a);const r=u(i,["googleSearchRetrieval"]);r!=null&&c(n,["googleSearchRetrieval"],r);const d=u(i,["computerUse"]);if(d!=null&&c(n,["computerUse"],d),u(i,["fileSearch"])!==void 0)throw new Error("fileSearch parameter is not supported in Vertex AI.");const m=u(i,["codeExecution"]);m!=null&&c(n,["codeExecution"],m);const g=u(i,["enterpriseWebSearch"]);g!=null&&c(n,["enterpriseWebSearch"],g);const y=u(i,["googleMaps"]);y!=null&&c(n,["googleMaps"],y);const h=u(i,["googleSearch"]);h!=null&&c(n,["googleSearch"],h);const v=u(i,["urlContext"]);return v!=null&&c(n,["urlContext"],v),n}function pS(i){const n={},o=u(i,["promptTokenCount"]);o!=null&&c(n,["promptTokenCount"],o);const a=u(i,["cachedContentTokenCount"]);a!=null&&c(n,["cachedContentTokenCount"],a);const r=u(i,["candidatesTokenCount"]);r!=null&&c(n,["responseTokenCount"],r);const d=u(i,["toolUsePromptTokenCount"]);d!=null&&c(n,["toolUsePromptTokenCount"],d);const m=u(i,["thoughtsTokenCount"]);m!=null&&c(n,["thoughtsTokenCount"],m);const g=u(i,["totalTokenCount"]);g!=null&&c(n,["totalTokenCount"],g);const y=u(i,["promptTokensDetails"]);if(y!=null){let M=y;Array.isArray(M)&&(M=M.map(z=>z)),c(n,["promptTokensDetails"],M)}const h=u(i,["cacheTokensDetails"]);if(h!=null){let M=h;Array.isArray(M)&&(M=M.map(z=>z)),c(n,["cacheTokensDetails"],M)}const v=u(i,["candidatesTokensDetails"]);if(v!=null){let M=v;Array.isArray(M)&&(M=M.map(z=>z)),c(n,["responseTokensDetails"],M)}const S=u(i,["toolUsePromptTokensDetails"]);if(S!=null){let M=S;Array.isArray(M)&&(M=M.map(z=>z)),c(n,["toolUsePromptTokensDetails"],M)}const _=u(i,["trafficType"]);return _!=null&&c(n,["trafficType"],_),n}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function mS(i){const n={},o=u(i,["data"]);if(o!=null&&c(n,["data"],o),u(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const a=u(i,["mimeType"]);return a!=null&&c(n,["mimeType"],a),n}function hS(i){const n={},o=u(i,["content"]);o!=null&&c(n,["content"],o);const a=u(i,["citationMetadata"]);a!=null&&c(n,["citationMetadata"],gS(a));const r=u(i,["tokenCount"]);r!=null&&c(n,["tokenCount"],r);const d=u(i,["finishReason"]);d!=null&&c(n,["finishReason"],d);const m=u(i,["avgLogprobs"]);m!=null&&c(n,["avgLogprobs"],m);const g=u(i,["groundingMetadata"]);g!=null&&c(n,["groundingMetadata"],g);const y=u(i,["index"]);y!=null&&c(n,["index"],y);const h=u(i,["logprobsResult"]);h!=null&&c(n,["logprobsResult"],h);const v=u(i,["safetyRatings"]);if(v!=null){let _=v;Array.isArray(_)&&(_=_.map(M=>M)),c(n,["safetyRatings"],_)}const S=u(i,["urlContextMetadata"]);return S!=null&&c(n,["urlContextMetadata"],S),n}function gS(i){const n={},o=u(i,["citationSources"]);if(o!=null){let a=o;Array.isArray(a)&&(a=a.map(r=>r)),c(n,["citations"],a)}return n}function yS(i,n){const o={},a=u(n,["model"]);a!=null&&c(o,["_url","model"],Ae(i,a));const r=u(n,["contents"]);if(r!=null){let d=qt(r);Array.isArray(d)&&(d=d.map(m=>m)),c(o,["contents"],d)}return o}function vS(i){const n={},o=u(i,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const a=u(i,["tokensInfo"]);if(a!=null){let r=a;Array.isArray(r)&&(r=r.map(d=>d)),c(n,["tokensInfo"],r)}return n}function TS(i){const n={},o=u(i,["values"]);o!=null&&c(n,["values"],o);const a=u(i,["statistics"]);return a!=null&&c(n,["statistics"],SS(a)),n}function SS(i){const n={},o=u(i,["truncated"]);o!=null&&c(n,["truncated"],o);const a=u(i,["token_count"]);return a!=null&&c(n,["tokenCount"],a),n}function Ea(i){const n={},o=u(i,["parts"]);if(o!=null){let r=o;Array.isArray(r)&&(r=r.map(d=>RE(d))),c(n,["parts"],r)}const a=u(i,["role"]);return a!=null&&c(n,["role"],a),n}function ES(i){const n={},o=u(i,["controlType"]);o!=null&&c(n,["controlType"],o);const a=u(i,["enableControlImageComputation"]);return a!=null&&c(n,["computeControl"],a),n}function _S(i){const n={};if(u(i,["systemInstruction"])!==void 0)throw new Error("systemInstruction parameter is not supported in Gemini API.");if(u(i,["tools"])!==void 0)throw new Error("tools parameter is not supported in Gemini API.");if(u(i,["generationConfig"])!==void 0)throw new Error("generationConfig parameter is not supported in Gemini API.");return n}function CS(i,n){const o={},a=u(i,["systemInstruction"]);n!==void 0&&a!=null&&c(n,["systemInstruction"],ot(a));const r=u(i,["tools"]);if(n!==void 0&&r!=null){let m=r;Array.isArray(m)&&(m=m.map(g=>Eh(g))),c(n,["tools"],m)}const d=u(i,["generationConfig"]);return n!==void 0&&d!=null&&c(n,["generationConfig"],dE(d)),o}function AS(i,n){const o={},a=u(n,["model"]);a!=null&&c(o,["_url","model"],Ae(i,a));const r=u(n,["contents"]);if(r!=null){let m=qt(r);Array.isArray(m)&&(m=m.map(g=>Ea(g))),c(o,["contents"],m)}const d=u(n,["config"]);return d!=null&&_S(d),o}function RS(i,n){const o={},a=u(n,["model"]);a!=null&&c(o,["_url","model"],Ae(i,a));const r=u(n,["contents"]);if(r!=null){let m=qt(r);Array.isArray(m)&&(m=m.map(g=>g)),c(o,["contents"],m)}const d=u(n,["config"]);return d!=null&&CS(d,o),o}function MS(i){const n={},o=u(i,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const a=u(i,["totalTokens"]);a!=null&&c(n,["totalTokens"],a);const r=u(i,["cachedContentTokenCount"]);return r!=null&&c(n,["cachedContentTokenCount"],r),n}function NS(i){const n={},o=u(i,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const a=u(i,["totalTokens"]);return a!=null&&c(n,["totalTokens"],a),n}function xS(i,n){const o={},a=u(n,["model"]);return a!=null&&c(o,["_url","name"],Ae(i,a)),o}function DS(i,n){const o={},a=u(n,["model"]);return a!=null&&c(o,["_url","name"],Ae(i,a)),o}function IS(i){const n={},o=u(i,["sdkHttpResponse"]);return o!=null&&c(n,["sdkHttpResponse"],o),n}function US(i){const n={},o=u(i,["sdkHttpResponse"]);return o!=null&&c(n,["sdkHttpResponse"],o),n}function wS(i,n){const o={},a=u(i,["outputGcsUri"]);n!==void 0&&a!=null&&c(n,["parameters","storageUri"],a);const r=u(i,["negativePrompt"]);n!==void 0&&r!=null&&c(n,["parameters","negativePrompt"],r);const d=u(i,["numberOfImages"]);n!==void 0&&d!=null&&c(n,["parameters","sampleCount"],d);const m=u(i,["aspectRatio"]);n!==void 0&&m!=null&&c(n,["parameters","aspectRatio"],m);const g=u(i,["guidanceScale"]);n!==void 0&&g!=null&&c(n,["parameters","guidanceScale"],g);const y=u(i,["seed"]);n!==void 0&&y!=null&&c(n,["parameters","seed"],y);const h=u(i,["safetyFilterLevel"]);n!==void 0&&h!=null&&c(n,["parameters","safetySetting"],h);const v=u(i,["personGeneration"]);n!==void 0&&v!=null&&c(n,["parameters","personGeneration"],v);const S=u(i,["includeSafetyAttributes"]);n!==void 0&&S!=null&&c(n,["parameters","includeSafetyAttributes"],S);const _=u(i,["includeRaiReason"]);n!==void 0&&_!=null&&c(n,["parameters","includeRaiReason"],_);const M=u(i,["language"]);n!==void 0&&M!=null&&c(n,["parameters","language"],M);const z=u(i,["outputMimeType"]);n!==void 0&&z!=null&&c(n,["parameters","outputOptions","mimeType"],z);const P=u(i,["outputCompressionQuality"]);n!==void 0&&P!=null&&c(n,["parameters","outputOptions","compressionQuality"],P);const O=u(i,["addWatermark"]);n!==void 0&&O!=null&&c(n,["parameters","addWatermark"],O);const k=u(i,["labels"]);n!==void 0&&k!=null&&c(n,["labels"],k);const F=u(i,["editMode"]);n!==void 0&&F!=null&&c(n,["parameters","editMode"],F);const B=u(i,["baseSteps"]);return n!==void 0&&B!=null&&c(n,["parameters","editConfig","baseSteps"],B),o}function bS(i,n){const o={},a=u(n,["model"]);a!=null&&c(o,["_url","model"],Ae(i,a));const r=u(n,["prompt"]);r!=null&&c(o,["instances[0]","prompt"],r);const d=u(n,["referenceImages"]);if(d!=null){let g=d;Array.isArray(g)&&(g=g.map(y=>UE(y))),c(o,["instances[0]","referenceImages"],g)}const m=u(n,["config"]);return m!=null&&wS(m,o),o}function qS(i){const n={},o=u(i,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const a=u(i,["predictions"]);if(a!=null){let r=a;Array.isArray(r)&&(r=r.map(d=>_a(d))),c(n,["generatedImages"],r)}return n}function LS(i,n){const o={},a=u(i,["taskType"]);n!==void 0&&a!=null&&c(n,["requests[]","taskType"],a);const r=u(i,["title"]);n!==void 0&&r!=null&&c(n,["requests[]","title"],r);const d=u(i,["outputDimensionality"]);if(n!==void 0&&d!=null&&c(n,["requests[]","outputDimensionality"],d),u(i,["mimeType"])!==void 0)throw new Error("mimeType parameter is not supported in Gemini API.");if(u(i,["autoTruncate"])!==void 0)throw new Error("autoTruncate parameter is not supported in Gemini API.");return o}function GS(i,n){const o={},a=u(i,["taskType"]);n!==void 0&&a!=null&&c(n,["instances[]","task_type"],a);const r=u(i,["title"]);n!==void 0&&r!=null&&c(n,["instances[]","title"],r);const d=u(i,["outputDimensionality"]);n!==void 0&&d!=null&&c(n,["parameters","outputDimensionality"],d);const m=u(i,["mimeType"]);n!==void 0&&m!=null&&c(n,["instances[]","mimeType"],m);const g=u(i,["autoTruncate"]);return n!==void 0&&g!=null&&c(n,["parameters","autoTruncate"],g),o}function HS(i,n){const o={},a=u(n,["model"]);a!=null&&c(o,["_url","model"],Ae(i,a));const r=u(n,["contents"]);if(r!=null){let g=cr(i,r);Array.isArray(g)&&(g=g.map(y=>y)),c(o,["requests[]","content"],g)}const d=u(n,["config"]);d!=null&&LS(d,o);const m=u(n,["model"]);return m!==void 0&&c(o,["requests[]","model"],Ae(i,m)),o}function VS(i,n){const o={},a=u(n,["model"]);a!=null&&c(o,["_url","model"],Ae(i,a));const r=u(n,["contents"]);if(r!=null){let m=cr(i,r);Array.isArray(m)&&(m=m.map(g=>g)),c(o,["instances[]","content"],m)}const d=u(n,["config"]);return d!=null&&GS(d,o),o}function zS(i){const n={},o=u(i,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const a=u(i,["embeddings"]);if(a!=null){let d=a;Array.isArray(d)&&(d=d.map(m=>m)),c(n,["embeddings"],d)}const r=u(i,["metadata"]);return r!=null&&c(n,["metadata"],r),n}function PS(i){const n={},o=u(i,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const a=u(i,["predictions[]","embeddings"]);if(a!=null){let d=a;Array.isArray(d)&&(d=d.map(m=>TS(m))),c(n,["embeddings"],d)}const r=u(i,["metadata"]);return r!=null&&c(n,["metadata"],r),n}function BS(i){const n={},o=u(i,["endpoint"]);o!=null&&c(n,["name"],o);const a=u(i,["deployedModelId"]);return a!=null&&c(n,["deployedModelId"],a),n}function kS(i){const n={};if(u(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=u(i,["fileUri"]);o!=null&&c(n,["fileUri"],o);const a=u(i,["mimeType"]);return a!=null&&c(n,["mimeType"],a),n}function OS(i){const n={};if(u(i,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");const o=u(i,["description"]);o!=null&&c(n,["description"],o);const a=u(i,["name"]);a!=null&&c(n,["name"],a);const r=u(i,["parameters"]);r!=null&&c(n,["parameters"],r);const d=u(i,["parametersJsonSchema"]);d!=null&&c(n,["parametersJsonSchema"],d);const m=u(i,["response"]);m!=null&&c(n,["response"],m);const g=u(i,["responseJsonSchema"]);return g!=null&&c(n,["responseJsonSchema"],g),n}function FS(i,n,o){const a={},r=u(n,["systemInstruction"]);o!==void 0&&r!=null&&c(o,["systemInstruction"],Ea(ot(r)));const d=u(n,["temperature"]);d!=null&&c(a,["temperature"],d);const m=u(n,["topP"]);m!=null&&c(a,["topP"],m);const g=u(n,["topK"]);g!=null&&c(a,["topK"],g);const y=u(n,["candidateCount"]);y!=null&&c(a,["candidateCount"],y);const h=u(n,["maxOutputTokens"]);h!=null&&c(a,["maxOutputTokens"],h);const v=u(n,["stopSequences"]);v!=null&&c(a,["stopSequences"],v);const S=u(n,["responseLogprobs"]);S!=null&&c(a,["responseLogprobs"],S);const _=u(n,["logprobs"]);_!=null&&c(a,["logprobs"],_);const M=u(n,["presencePenalty"]);M!=null&&c(a,["presencePenalty"],M);const z=u(n,["frequencyPenalty"]);z!=null&&c(a,["frequencyPenalty"],z);const P=u(n,["seed"]);P!=null&&c(a,["seed"],P);const O=u(n,["responseMimeType"]);O!=null&&c(a,["responseMimeType"],O);const k=u(n,["responseSchema"]);k!=null&&c(a,["responseSchema"],fr(k));const F=u(n,["responseJsonSchema"]);if(F!=null&&c(a,["responseJsonSchema"],F),u(n,["routingConfig"])!==void 0)throw new Error("routingConfig parameter is not supported in Gemini API.");if(u(n,["modelSelectionConfig"])!==void 0)throw new Error("modelSelectionConfig parameter is not supported in Gemini API.");const B=u(n,["safetySettings"]);if(o!==void 0&&B!=null){let ce=B;Array.isArray(ce)&&(ce=ce.map(He=>wE(He))),c(o,["safetySettings"],ce)}const Q=u(n,["tools"]);if(o!==void 0&&Q!=null){let ce=Ki(Q);Array.isArray(ce)&&(ce=ce.map(He=>VE(Ji(He)))),c(o,["tools"],ce)}const ne=u(n,["toolConfig"]);if(o!==void 0&&ne!=null&&c(o,["toolConfig"],ne),u(n,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const W=u(n,["cachedContent"]);o!==void 0&&W!=null&&c(o,["cachedContent"],fn(i,W));const J=u(n,["responseModalities"]);J!=null&&c(a,["responseModalities"],J);const he=u(n,["mediaResolution"]);he!=null&&c(a,["mediaResolution"],he);const ee=u(n,["speechConfig"]);if(ee!=null&&c(a,["speechConfig"],dr(ee)),u(n,["audioTimestamp"])!==void 0)throw new Error("audioTimestamp parameter is not supported in Gemini API.");const re=u(n,["thinkingConfig"]);re!=null&&c(a,["thinkingConfig"],re);const de=u(n,["imageConfig"]);return de!=null&&c(a,["imageConfig"],de),a}function YS(i,n,o){const a={},r=u(n,["systemInstruction"]);o!==void 0&&r!=null&&c(o,["systemInstruction"],ot(r));const d=u(n,["temperature"]);d!=null&&c(a,["temperature"],d);const m=u(n,["topP"]);m!=null&&c(a,["topP"],m);const g=u(n,["topK"]);g!=null&&c(a,["topK"],g);const y=u(n,["candidateCount"]);y!=null&&c(a,["candidateCount"],y);const h=u(n,["maxOutputTokens"]);h!=null&&c(a,["maxOutputTokens"],h);const v=u(n,["stopSequences"]);v!=null&&c(a,["stopSequences"],v);const S=u(n,["responseLogprobs"]);S!=null&&c(a,["responseLogprobs"],S);const _=u(n,["logprobs"]);_!=null&&c(a,["logprobs"],_);const M=u(n,["presencePenalty"]);M!=null&&c(a,["presencePenalty"],M);const z=u(n,["frequencyPenalty"]);z!=null&&c(a,["frequencyPenalty"],z);const P=u(n,["seed"]);P!=null&&c(a,["seed"],P);const O=u(n,["responseMimeType"]);O!=null&&c(a,["responseMimeType"],O);const k=u(n,["responseSchema"]);k!=null&&c(a,["responseSchema"],fr(k));const F=u(n,["responseJsonSchema"]);F!=null&&c(a,["responseJsonSchema"],F);const B=u(n,["routingConfig"]);B!=null&&c(a,["routingConfig"],B);const Q=u(n,["modelSelectionConfig"]);Q!=null&&c(a,["modelConfig"],Q);const ne=u(n,["safetySettings"]);if(o!==void 0&&ne!=null){let U=ne;Array.isArray(U)&&(U=U.map(b=>b)),c(o,["safetySettings"],U)}const W=u(n,["tools"]);if(o!==void 0&&W!=null){let U=Ki(W);Array.isArray(U)&&(U=U.map(b=>Eh(Ji(b)))),c(o,["tools"],U)}const J=u(n,["toolConfig"]);o!==void 0&&J!=null&&c(o,["toolConfig"],J);const he=u(n,["labels"]);o!==void 0&&he!=null&&c(o,["labels"],he);const ee=u(n,["cachedContent"]);o!==void 0&&ee!=null&&c(o,["cachedContent"],fn(i,ee));const re=u(n,["responseModalities"]);re!=null&&c(a,["responseModalities"],re);const de=u(n,["mediaResolution"]);de!=null&&c(a,["mediaResolution"],de);const ce=u(n,["speechConfig"]);ce!=null&&c(a,["speechConfig"],Sh(dr(ce)));const He=u(n,["audioTimestamp"]);He!=null&&c(a,["audioTimestamp"],He);const We=u(n,["thinkingConfig"]);We!=null&&c(a,["thinkingConfig"],We);const Ve=u(n,["imageConfig"]);return Ve!=null&&c(a,["imageConfig"],Ve),a}function Vm(i,n){const o={},a=u(n,["model"]);a!=null&&c(o,["_url","model"],Ae(i,a));const r=u(n,["contents"]);if(r!=null){let m=qt(r);Array.isArray(m)&&(m=m.map(g=>Ea(g))),c(o,["contents"],m)}const d=u(n,["config"]);return d!=null&&c(o,["generationConfig"],FS(i,d,o)),o}function zm(i,n){const o={},a=u(n,["model"]);a!=null&&c(o,["_url","model"],Ae(i,a));const r=u(n,["contents"]);if(r!=null){let m=qt(r);Array.isArray(m)&&(m=m.map(g=>g)),c(o,["contents"],m)}const d=u(n,["config"]);return d!=null&&c(o,["generationConfig"],YS(i,d,o)),o}function Pm(i){const n={},o=u(i,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const a=u(i,["candidates"]);if(a!=null){let y=a;Array.isArray(y)&&(y=y.map(h=>hS(h))),c(n,["candidates"],y)}const r=u(i,["modelVersion"]);r!=null&&c(n,["modelVersion"],r);const d=u(i,["promptFeedback"]);d!=null&&c(n,["promptFeedback"],d);const m=u(i,["responseId"]);m!=null&&c(n,["responseId"],m);const g=u(i,["usageMetadata"]);return g!=null&&c(n,["usageMetadata"],g),n}function Bm(i){const n={},o=u(i,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const a=u(i,["candidates"]);if(a!=null){let h=a;Array.isArray(h)&&(h=h.map(v=>v)),c(n,["candidates"],h)}const r=u(i,["createTime"]);r!=null&&c(n,["createTime"],r);const d=u(i,["modelVersion"]);d!=null&&c(n,["modelVersion"],d);const m=u(i,["promptFeedback"]);m!=null&&c(n,["promptFeedback"],m);const g=u(i,["responseId"]);g!=null&&c(n,["responseId"],g);const y=u(i,["usageMetadata"]);return y!=null&&c(n,["usageMetadata"],y),n}function JS(i,n){const o={};if(u(i,["outputGcsUri"])!==void 0)throw new Error("outputGcsUri parameter is not supported in Gemini API.");if(u(i,["negativePrompt"])!==void 0)throw new Error("negativePrompt parameter is not supported in Gemini API.");const a=u(i,["numberOfImages"]);n!==void 0&&a!=null&&c(n,["parameters","sampleCount"],a);const r=u(i,["aspectRatio"]);n!==void 0&&r!=null&&c(n,["parameters","aspectRatio"],r);const d=u(i,["guidanceScale"]);if(n!==void 0&&d!=null&&c(n,["parameters","guidanceScale"],d),u(i,["seed"])!==void 0)throw new Error("seed parameter is not supported in Gemini API.");const m=u(i,["safetyFilterLevel"]);n!==void 0&&m!=null&&c(n,["parameters","safetySetting"],m);const g=u(i,["personGeneration"]);n!==void 0&&g!=null&&c(n,["parameters","personGeneration"],g);const y=u(i,["includeSafetyAttributes"]);n!==void 0&&y!=null&&c(n,["parameters","includeSafetyAttributes"],y);const h=u(i,["includeRaiReason"]);n!==void 0&&h!=null&&c(n,["parameters","includeRaiReason"],h);const v=u(i,["language"]);n!==void 0&&v!=null&&c(n,["parameters","language"],v);const S=u(i,["outputMimeType"]);n!==void 0&&S!=null&&c(n,["parameters","outputOptions","mimeType"],S);const _=u(i,["outputCompressionQuality"]);if(n!==void 0&&_!=null&&c(n,["parameters","outputOptions","compressionQuality"],_),u(i,["addWatermark"])!==void 0)throw new Error("addWatermark parameter is not supported in Gemini API.");if(u(i,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const M=u(i,["imageSize"]);if(n!==void 0&&M!=null&&c(n,["parameters","sampleImageSize"],M),u(i,["enhancePrompt"])!==void 0)throw new Error("enhancePrompt parameter is not supported in Gemini API.");return o}function KS(i,n){const o={},a=u(i,["outputGcsUri"]);n!==void 0&&a!=null&&c(n,["parameters","storageUri"],a);const r=u(i,["negativePrompt"]);n!==void 0&&r!=null&&c(n,["parameters","negativePrompt"],r);const d=u(i,["numberOfImages"]);n!==void 0&&d!=null&&c(n,["parameters","sampleCount"],d);const m=u(i,["aspectRatio"]);n!==void 0&&m!=null&&c(n,["parameters","aspectRatio"],m);const g=u(i,["guidanceScale"]);n!==void 0&&g!=null&&c(n,["parameters","guidanceScale"],g);const y=u(i,["seed"]);n!==void 0&&y!=null&&c(n,["parameters","seed"],y);const h=u(i,["safetyFilterLevel"]);n!==void 0&&h!=null&&c(n,["parameters","safetySetting"],h);const v=u(i,["personGeneration"]);n!==void 0&&v!=null&&c(n,["parameters","personGeneration"],v);const S=u(i,["includeSafetyAttributes"]);n!==void 0&&S!=null&&c(n,["parameters","includeSafetyAttributes"],S);const _=u(i,["includeRaiReason"]);n!==void 0&&_!=null&&c(n,["parameters","includeRaiReason"],_);const M=u(i,["language"]);n!==void 0&&M!=null&&c(n,["parameters","language"],M);const z=u(i,["outputMimeType"]);n!==void 0&&z!=null&&c(n,["parameters","outputOptions","mimeType"],z);const P=u(i,["outputCompressionQuality"]);n!==void 0&&P!=null&&c(n,["parameters","outputOptions","compressionQuality"],P);const O=u(i,["addWatermark"]);n!==void 0&&O!=null&&c(n,["parameters","addWatermark"],O);const k=u(i,["labels"]);n!==void 0&&k!=null&&c(n,["labels"],k);const F=u(i,["imageSize"]);n!==void 0&&F!=null&&c(n,["parameters","sampleImageSize"],F);const B=u(i,["enhancePrompt"]);return n!==void 0&&B!=null&&c(n,["parameters","enhancePrompt"],B),o}function XS(i,n){const o={},a=u(n,["model"]);a!=null&&c(o,["_url","model"],Ae(i,a));const r=u(n,["prompt"]);r!=null&&c(o,["instances[0]","prompt"],r);const d=u(n,["config"]);return d!=null&&JS(d,o),o}function QS(i,n){const o={},a=u(n,["model"]);a!=null&&c(o,["_url","model"],Ae(i,a));const r=u(n,["prompt"]);r!=null&&c(o,["instances[0]","prompt"],r);const d=u(n,["config"]);return d!=null&&KS(d,o),o}function ZS(i){const n={},o=u(i,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const a=u(i,["predictions"]);if(a!=null){let d=a;Array.isArray(d)&&(d=d.map(m=>uE(m))),c(n,["generatedImages"],d)}const r=u(i,["positivePromptSafetyAttributes"]);return r!=null&&c(n,["positivePromptSafetyAttributes"],vh(r)),n}function $S(i){const n={},o=u(i,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const a=u(i,["predictions"]);if(a!=null){let d=a;Array.isArray(d)&&(d=d.map(m=>_a(m))),c(n,["generatedImages"],d)}const r=u(i,["positivePromptSafetyAttributes"]);return r!=null&&c(n,["positivePromptSafetyAttributes"],Th(r)),n}function WS(i,n){const o={},a=u(i,["numberOfVideos"]);if(n!==void 0&&a!=null&&c(n,["parameters","sampleCount"],a),u(i,["outputGcsUri"])!==void 0)throw new Error("outputGcsUri parameter is not supported in Gemini API.");if(u(i,["fps"])!==void 0)throw new Error("fps parameter is not supported in Gemini API.");const r=u(i,["durationSeconds"]);if(n!==void 0&&r!=null&&c(n,["parameters","durationSeconds"],r),u(i,["seed"])!==void 0)throw new Error("seed parameter is not supported in Gemini API.");const d=u(i,["aspectRatio"]);n!==void 0&&d!=null&&c(n,["parameters","aspectRatio"],d);const m=u(i,["resolution"]);n!==void 0&&m!=null&&c(n,["parameters","resolution"],m);const g=u(i,["personGeneration"]);if(n!==void 0&&g!=null&&c(n,["parameters","personGeneration"],g),u(i,["pubsubTopic"])!==void 0)throw new Error("pubsubTopic parameter is not supported in Gemini API.");const y=u(i,["negativePrompt"]);n!==void 0&&y!=null&&c(n,["parameters","negativePrompt"],y);const h=u(i,["enhancePrompt"]);if(n!==void 0&&h!=null&&c(n,["parameters","enhancePrompt"],h),u(i,["generateAudio"])!==void 0)throw new Error("generateAudio parameter is not supported in Gemini API.");const v=u(i,["lastFrame"]);n!==void 0&&v!=null&&c(n,["instances[0]","lastFrame"],Ca(v));const S=u(i,["referenceImages"]);if(n!==void 0&&S!=null){let _=S;Array.isArray(_)&&(_=_.map(M=>$E(M))),c(n,["instances[0]","referenceImages"],_)}if(u(i,["mask"])!==void 0)throw new Error("mask parameter is not supported in Gemini API.");if(u(i,["compressionQuality"])!==void 0)throw new Error("compressionQuality parameter is not supported in Gemini API.");return o}function jS(i,n){const o={},a=u(i,["numberOfVideos"]);n!==void 0&&a!=null&&c(n,["parameters","sampleCount"],a);const r=u(i,["outputGcsUri"]);n!==void 0&&r!=null&&c(n,["parameters","storageUri"],r);const d=u(i,["fps"]);n!==void 0&&d!=null&&c(n,["parameters","fps"],d);const m=u(i,["durationSeconds"]);n!==void 0&&m!=null&&c(n,["parameters","durationSeconds"],m);const g=u(i,["seed"]);n!==void 0&&g!=null&&c(n,["parameters","seed"],g);const y=u(i,["aspectRatio"]);n!==void 0&&y!=null&&c(n,["parameters","aspectRatio"],y);const h=u(i,["resolution"]);n!==void 0&&h!=null&&c(n,["parameters","resolution"],h);const v=u(i,["personGeneration"]);n!==void 0&&v!=null&&c(n,["parameters","personGeneration"],v);const S=u(i,["pubsubTopic"]);n!==void 0&&S!=null&&c(n,["parameters","pubsubTopic"],S);const _=u(i,["negativePrompt"]);n!==void 0&&_!=null&&c(n,["parameters","negativePrompt"],_);const M=u(i,["enhancePrompt"]);n!==void 0&&M!=null&&c(n,["parameters","enhancePrompt"],M);const z=u(i,["generateAudio"]);n!==void 0&&z!=null&&c(n,["parameters","generateAudio"],z);const P=u(i,["lastFrame"]);n!==void 0&&P!=null&&c(n,["instances[0]","lastFrame"],Vt(P));const O=u(i,["referenceImages"]);if(n!==void 0&&O!=null){let B=O;Array.isArray(B)&&(B=B.map(Q=>WE(Q))),c(n,["instances[0]","referenceImages"],B)}const k=u(i,["mask"]);n!==void 0&&k!=null&&c(n,["instances[0]","mask"],ZE(k));const F=u(i,["compressionQuality"]);return n!==void 0&&F!=null&&c(n,["parameters","compressionQuality"],F),o}function eE(i){const n={},o=u(i,["name"]);o!=null&&c(n,["name"],o);const a=u(i,["metadata"]);a!=null&&c(n,["metadata"],a);const r=u(i,["done"]);r!=null&&c(n,["done"],r);const d=u(i,["error"]);d!=null&&c(n,["error"],d);const m=u(i,["response","generateVideoResponse"]);return m!=null&&c(n,["response"],lE(m)),n}function tE(i){const n={},o=u(i,["name"]);o!=null&&c(n,["name"],o);const a=u(i,["metadata"]);a!=null&&c(n,["metadata"],a);const r=u(i,["done"]);r!=null&&c(n,["done"],r);const d=u(i,["error"]);d!=null&&c(n,["error"],d);const m=u(i,["response"]);return m!=null&&c(n,["response"],oE(m)),n}function nE(i,n){const o={},a=u(n,["model"]);a!=null&&c(o,["_url","model"],Ae(i,a));const r=u(n,["prompt"]);r!=null&&c(o,["instances[0]","prompt"],r);const d=u(n,["image"]);d!=null&&c(o,["instances[0]","image"],Ca(d));const m=u(n,["video"]);m!=null&&c(o,["instances[0]","video"],_h(m));const g=u(n,["source"]);g!=null&&aE(g,o);const y=u(n,["config"]);return y!=null&&WS(y,o),o}function iE(i,n){const o={},a=u(n,["model"]);a!=null&&c(o,["_url","model"],Ae(i,a));const r=u(n,["prompt"]);r!=null&&c(o,["instances[0]","prompt"],r);const d=u(n,["image"]);d!=null&&c(o,["instances[0]","image"],Vt(d));const m=u(n,["video"]);m!=null&&c(o,["instances[0]","video"],Ch(m));const g=u(n,["source"]);g!=null&&sE(g,o);const y=u(n,["config"]);return y!=null&&jS(y,o),o}function lE(i){const n={},o=u(i,["generatedSamples"]);if(o!=null){let d=o;Array.isArray(d)&&(d=d.map(m=>cE(m))),c(n,["generatedVideos"],d)}const a=u(i,["raiMediaFilteredCount"]);a!=null&&c(n,["raiMediaFilteredCount"],a);const r=u(i,["raiMediaFilteredReasons"]);return r!=null&&c(n,["raiMediaFilteredReasons"],r),n}function oE(i){const n={},o=u(i,["videos"]);if(o!=null){let d=o;Array.isArray(d)&&(d=d.map(m=>fE(m))),c(n,["generatedVideos"],d)}const a=u(i,["raiMediaFilteredCount"]);a!=null&&c(n,["raiMediaFilteredCount"],a);const r=u(i,["raiMediaFilteredReasons"]);return r!=null&&c(n,["raiMediaFilteredReasons"],r),n}function aE(i,n){const o={},a=u(i,["prompt"]);n!==void 0&&a!=null&&c(n,["instances[0]","prompt"],a);const r=u(i,["image"]);n!==void 0&&r!=null&&c(n,["instances[0]","image"],Ca(r));const d=u(i,["video"]);return n!==void 0&&d!=null&&c(n,["instances[0]","video"],_h(d)),o}function sE(i,n){const o={},a=u(i,["prompt"]);n!==void 0&&a!=null&&c(n,["instances[0]","prompt"],a);const r=u(i,["image"]);n!==void 0&&r!=null&&c(n,["instances[0]","image"],Vt(r));const d=u(i,["video"]);return n!==void 0&&d!=null&&c(n,["instances[0]","video"],Ch(d)),o}function uE(i){const n={},o=u(i,["_self"]);o!=null&&c(n,["image"],yE(o));const a=u(i,["raiFilteredReason"]);a!=null&&c(n,["raiFilteredReason"],a);const r=u(i,["_self"]);return r!=null&&c(n,["safetyAttributes"],vh(r)),n}function _a(i){const n={},o=u(i,["_self"]);o!=null&&c(n,["image"],yh(o));const a=u(i,["raiFilteredReason"]);a!=null&&c(n,["raiFilteredReason"],a);const r=u(i,["_self"]);r!=null&&c(n,["safetyAttributes"],Th(r));const d=u(i,["prompt"]);return d!=null&&c(n,["enhancedPrompt"],d),n}function rE(i){const n={},o=u(i,["_self"]);o!=null&&c(n,["mask"],yh(o));const a=u(i,["labels"]);if(a!=null){let r=a;Array.isArray(r)&&(r=r.map(d=>d)),c(n,["labels"],r)}return n}function cE(i){const n={},o=u(i,["video"]);return o!=null&&c(n,["video"],XE(o)),n}function fE(i){const n={},o=u(i,["_self"]);return o!=null&&c(n,["video"],QE(o)),n}function dE(i){const n={},o=u(i,["modelSelectionConfig"]);o!=null&&c(n,["modelConfig"],o);const a=u(i,["responseJsonSchema"]);a!=null&&c(n,["responseJsonSchema"],a);const r=u(i,["audioTimestamp"]);r!=null&&c(n,["audioTimestamp"],r);const d=u(i,["candidateCount"]);d!=null&&c(n,["candidateCount"],d);const m=u(i,["enableAffectiveDialog"]);m!=null&&c(n,["enableAffectiveDialog"],m);const g=u(i,["frequencyPenalty"]);g!=null&&c(n,["frequencyPenalty"],g);const y=u(i,["logprobs"]);y!=null&&c(n,["logprobs"],y);const h=u(i,["maxOutputTokens"]);h!=null&&c(n,["maxOutputTokens"],h);const v=u(i,["mediaResolution"]);v!=null&&c(n,["mediaResolution"],v);const S=u(i,["presencePenalty"]);S!=null&&c(n,["presencePenalty"],S);const _=u(i,["responseLogprobs"]);_!=null&&c(n,["responseLogprobs"],_);const M=u(i,["responseMimeType"]);M!=null&&c(n,["responseMimeType"],M);const z=u(i,["responseModalities"]);z!=null&&c(n,["responseModalities"],z);const P=u(i,["responseSchema"]);P!=null&&c(n,["responseSchema"],P);const O=u(i,["routingConfig"]);O!=null&&c(n,["routingConfig"],O);const k=u(i,["seed"]);k!=null&&c(n,["seed"],k);const F=u(i,["speechConfig"]);F!=null&&c(n,["speechConfig"],Sh(F));const B=u(i,["stopSequences"]);B!=null&&c(n,["stopSequences"],B);const Q=u(i,["temperature"]);Q!=null&&c(n,["temperature"],Q);const ne=u(i,["thinkingConfig"]);ne!=null&&c(n,["thinkingConfig"],ne);const W=u(i,["topK"]);W!=null&&c(n,["topK"],W);const J=u(i,["topP"]);if(J!=null&&c(n,["topP"],J),u(i,["enableEnhancedCivicAnswers"])!==void 0)throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");return n}function pE(i,n){const o={},a=u(n,["model"]);return a!=null&&c(o,["_url","name"],Ae(i,a)),o}function mE(i,n){const o={},a=u(n,["model"]);return a!=null&&c(o,["_url","name"],Ae(i,a)),o}function hE(i){const n={};if(u(i,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const o=u(i,["enableWidget"]);return o!=null&&c(n,["enableWidget"],o),n}function gE(i){const n={};if(u(i,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(u(i,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const o=u(i,["timeRangeFilter"]);return o!=null&&c(n,["timeRangeFilter"],o),n}function yE(i){const n={},o=u(i,["bytesBase64Encoded"]);o!=null&&c(n,["imageBytes"],Hn(o));const a=u(i,["mimeType"]);return a!=null&&c(n,["mimeType"],a),n}function yh(i){const n={},o=u(i,["gcsUri"]);o!=null&&c(n,["gcsUri"],o);const a=u(i,["bytesBase64Encoded"]);a!=null&&c(n,["imageBytes"],Hn(a));const r=u(i,["mimeType"]);return r!=null&&c(n,["mimeType"],r),n}function Ca(i){const n={};if(u(i,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");const o=u(i,["imageBytes"]);o!=null&&c(n,["bytesBase64Encoded"],Hn(o));const a=u(i,["mimeType"]);return a!=null&&c(n,["mimeType"],a),n}function Vt(i){const n={},o=u(i,["gcsUri"]);o!=null&&c(n,["gcsUri"],o);const a=u(i,["imageBytes"]);a!=null&&c(n,["bytesBase64Encoded"],Hn(a));const r=u(i,["mimeType"]);return r!=null&&c(n,["mimeType"],r),n}function vE(i,n,o){const a={},r=u(n,["pageSize"]);o!==void 0&&r!=null&&c(o,["_query","pageSize"],r);const d=u(n,["pageToken"]);o!==void 0&&d!=null&&c(o,["_query","pageToken"],d);const m=u(n,["filter"]);o!==void 0&&m!=null&&c(o,["_query","filter"],m);const g=u(n,["queryBase"]);return o!==void 0&&g!=null&&c(o,["_url","models_url"],rh(i,g)),a}function TE(i,n,o){const a={},r=u(n,["pageSize"]);o!==void 0&&r!=null&&c(o,["_query","pageSize"],r);const d=u(n,["pageToken"]);o!==void 0&&d!=null&&c(o,["_query","pageToken"],d);const m=u(n,["filter"]);o!==void 0&&m!=null&&c(o,["_query","filter"],m);const g=u(n,["queryBase"]);return o!==void 0&&g!=null&&c(o,["_url","models_url"],rh(i,g)),a}function SE(i,n){const o={},a=u(n,["config"]);return a!=null&&vE(i,a,o),o}function EE(i,n){const o={},a=u(n,["config"]);return a!=null&&TE(i,a,o),o}function _E(i){const n={},o=u(i,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const a=u(i,["nextPageToken"]);a!=null&&c(n,["nextPageToken"],a);const r=u(i,["_self"]);if(r!=null){let d=ch(r);Array.isArray(d)&&(d=d.map(m=>er(m))),c(n,["models"],d)}return n}function CE(i){const n={},o=u(i,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const a=u(i,["nextPageToken"]);a!=null&&c(n,["nextPageToken"],a);const r=u(i,["_self"]);if(r!=null){let d=ch(r);Array.isArray(d)&&(d=d.map(m=>tr(m))),c(n,["models"],d)}return n}function AE(i){const n={},o=u(i,["maskMode"]);o!=null&&c(n,["maskMode"],o);const a=u(i,["segmentationClasses"]);a!=null&&c(n,["maskClasses"],a);const r=u(i,["maskDilation"]);return r!=null&&c(n,["dilation"],r),n}function er(i){const n={},o=u(i,["name"]);o!=null&&c(n,["name"],o);const a=u(i,["displayName"]);a!=null&&c(n,["displayName"],a);const r=u(i,["description"]);r!=null&&c(n,["description"],r);const d=u(i,["version"]);d!=null&&c(n,["version"],d);const m=u(i,["_self"]);m!=null&&c(n,["tunedModelInfo"],zE(m));const g=u(i,["inputTokenLimit"]);g!=null&&c(n,["inputTokenLimit"],g);const y=u(i,["outputTokenLimit"]);y!=null&&c(n,["outputTokenLimit"],y);const h=u(i,["supportedGenerationMethods"]);h!=null&&c(n,["supportedActions"],h);const v=u(i,["temperature"]);v!=null&&c(n,["temperature"],v);const S=u(i,["maxTemperature"]);S!=null&&c(n,["maxTemperature"],S);const _=u(i,["topP"]);_!=null&&c(n,["topP"],_);const M=u(i,["topK"]);M!=null&&c(n,["topK"],M);const z=u(i,["thinking"]);return z!=null&&c(n,["thinking"],z),n}function tr(i){const n={},o=u(i,["name"]);o!=null&&c(n,["name"],o);const a=u(i,["displayName"]);a!=null&&c(n,["displayName"],a);const r=u(i,["description"]);r!=null&&c(n,["description"],r);const d=u(i,["versionId"]);d!=null&&c(n,["version"],d);const m=u(i,["deployedModels"]);if(m!=null){let S=m;Array.isArray(S)&&(S=S.map(_=>BS(_))),c(n,["endpoints"],S)}const g=u(i,["labels"]);g!=null&&c(n,["labels"],g);const y=u(i,["_self"]);y!=null&&c(n,["tunedModelInfo"],PE(y));const h=u(i,["defaultCheckpointId"]);h!=null&&c(n,["defaultCheckpointId"],h);const v=u(i,["checkpoints"]);if(v!=null){let S=v;Array.isArray(S)&&(S=S.map(_=>_)),c(n,["checkpoints"],S)}return n}function RE(i){const n={},o=u(i,["functionCall"]);o!=null&&c(n,["functionCall"],o);const a=u(i,["codeExecutionResult"]);a!=null&&c(n,["codeExecutionResult"],a);const r=u(i,["executableCode"]);r!=null&&c(n,["executableCode"],r);const d=u(i,["fileData"]);d!=null&&c(n,["fileData"],kS(d));const m=u(i,["functionResponse"]);m!=null&&c(n,["functionResponse"],m);const g=u(i,["inlineData"]);g!=null&&c(n,["inlineData"],mS(g));const y=u(i,["text"]);y!=null&&c(n,["text"],y);const h=u(i,["thought"]);h!=null&&c(n,["thought"],h);const v=u(i,["thoughtSignature"]);v!=null&&c(n,["thoughtSignature"],v);const S=u(i,["videoMetadata"]);return S!=null&&c(n,["videoMetadata"],S),n}function ME(i){const n={},o=u(i,["productImage"]);return o!=null&&c(n,["image"],Vt(o)),n}function NE(i,n){const o={},a=u(i,["numberOfImages"]);n!==void 0&&a!=null&&c(n,["parameters","sampleCount"],a);const r=u(i,["baseSteps"]);n!==void 0&&r!=null&&c(n,["parameters","baseSteps"],r);const d=u(i,["outputGcsUri"]);n!==void 0&&d!=null&&c(n,["parameters","storageUri"],d);const m=u(i,["seed"]);n!==void 0&&m!=null&&c(n,["parameters","seed"],m);const g=u(i,["safetyFilterLevel"]);n!==void 0&&g!=null&&c(n,["parameters","safetySetting"],g);const y=u(i,["personGeneration"]);n!==void 0&&y!=null&&c(n,["parameters","personGeneration"],y);const h=u(i,["addWatermark"]);n!==void 0&&h!=null&&c(n,["parameters","addWatermark"],h);const v=u(i,["outputMimeType"]);n!==void 0&&v!=null&&c(n,["parameters","outputOptions","mimeType"],v);const S=u(i,["outputCompressionQuality"]);n!==void 0&&S!=null&&c(n,["parameters","outputOptions","compressionQuality"],S);const _=u(i,["enhancePrompt"]);n!==void 0&&_!=null&&c(n,["parameters","enhancePrompt"],_);const M=u(i,["labels"]);return n!==void 0&&M!=null&&c(n,["labels"],M),o}function xE(i,n){const o={},a=u(n,["model"]);a!=null&&c(o,["_url","model"],Ae(i,a));const r=u(n,["source"]);r!=null&&IE(r,o);const d=u(n,["config"]);return d!=null&&NE(d,o),o}function DE(i){const n={},o=u(i,["predictions"]);if(o!=null){let a=o;Array.isArray(a)&&(a=a.map(r=>_a(r))),c(n,["generatedImages"],a)}return n}function IE(i,n){const o={},a=u(i,["prompt"]);n!==void 0&&a!=null&&c(n,["instances[0]","prompt"],a);const r=u(i,["personImage"]);n!==void 0&&r!=null&&c(n,["instances[0]","personImage","image"],Vt(r));const d=u(i,["productImages"]);if(n!==void 0&&d!=null){let m=d;Array.isArray(m)&&(m=m.map(g=>ME(g))),c(n,["instances[0]","productImages"],m)}return o}function UE(i){const n={},o=u(i,["referenceImage"]);o!=null&&c(n,["referenceImage"],Vt(o));const a=u(i,["referenceId"]);a!=null&&c(n,["referenceId"],a);const r=u(i,["referenceType"]);r!=null&&c(n,["referenceType"],r);const d=u(i,["maskImageConfig"]);d!=null&&c(n,["maskImageConfig"],AE(d));const m=u(i,["controlImageConfig"]);m!=null&&c(n,["controlImageConfig"],ES(m));const g=u(i,["styleImageConfig"]);g!=null&&c(n,["styleImageConfig"],g);const y=u(i,["subjectImageConfig"]);return y!=null&&c(n,["subjectImageConfig"],y),n}function vh(i){const n={},o=u(i,["safetyAttributes","categories"]);o!=null&&c(n,["categories"],o);const a=u(i,["safetyAttributes","scores"]);a!=null&&c(n,["scores"],a);const r=u(i,["contentType"]);return r!=null&&c(n,["contentType"],r),n}function Th(i){const n={},o=u(i,["safetyAttributes","categories"]);o!=null&&c(n,["categories"],o);const a=u(i,["safetyAttributes","scores"]);a!=null&&c(n,["scores"],a);const r=u(i,["contentType"]);return r!=null&&c(n,["contentType"],r),n}function wE(i){const n={},o=u(i,["category"]);if(o!=null&&c(n,["category"],o),u(i,["method"])!==void 0)throw new Error("method parameter is not supported in Gemini API.");const a=u(i,["threshold"]);return a!=null&&c(n,["threshold"],a),n}function bE(i){const n={},o=u(i,["image"]);return o!=null&&c(n,["image"],Vt(o)),n}function qE(i,n){const o={},a=u(i,["mode"]);n!==void 0&&a!=null&&c(n,["parameters","mode"],a);const r=u(i,["maxPredictions"]);n!==void 0&&r!=null&&c(n,["parameters","maxPredictions"],r);const d=u(i,["confidenceThreshold"]);n!==void 0&&d!=null&&c(n,["parameters","confidenceThreshold"],d);const m=u(i,["maskDilation"]);n!==void 0&&m!=null&&c(n,["parameters","maskDilation"],m);const g=u(i,["binaryColorThreshold"]);n!==void 0&&g!=null&&c(n,["parameters","binaryColorThreshold"],g);const y=u(i,["labels"]);return n!==void 0&&y!=null&&c(n,["labels"],y),o}function LE(i,n){const o={},a=u(n,["model"]);a!=null&&c(o,["_url","model"],Ae(i,a));const r=u(n,["source"]);r!=null&&HE(r,o);const d=u(n,["config"]);return d!=null&&qE(d,o),o}function GE(i){const n={},o=u(i,["predictions"]);if(o!=null){let a=o;Array.isArray(a)&&(a=a.map(r=>rE(r))),c(n,["generatedMasks"],a)}return n}function HE(i,n){const o={},a=u(i,["prompt"]);n!==void 0&&a!=null&&c(n,["instances[0]","prompt"],a);const r=u(i,["image"]);n!==void 0&&r!=null&&c(n,["instances[0]","image"],Vt(r));const d=u(i,["scribbleImage"]);return n!==void 0&&d!=null&&c(n,["instances[0]","scribble"],bE(d)),o}function Sh(i){const n={},o=u(i,["languageCode"]);o!=null&&c(n,["languageCode"],o);const a=u(i,["voiceConfig"]);if(a!=null&&c(n,["voiceConfig"],a),u(i,["multiSpeakerVoiceConfig"])!==void 0)throw new Error("multiSpeakerVoiceConfig parameter is not supported in Vertex AI.");return n}function VE(i){const n={},o=u(i,["functionDeclarations"]);if(o!=null){let v=o;Array.isArray(v)&&(v=v.map(S=>S)),c(n,["functionDeclarations"],v)}if(u(i,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const a=u(i,["googleSearchRetrieval"]);a!=null&&c(n,["googleSearchRetrieval"],a);const r=u(i,["computerUse"]);r!=null&&c(n,["computerUse"],r);const d=u(i,["fileSearch"]);d!=null&&c(n,["fileSearch"],d);const m=u(i,["codeExecution"]);if(m!=null&&c(n,["codeExecution"],m),u(i,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const g=u(i,["googleMaps"]);g!=null&&c(n,["googleMaps"],hE(g));const y=u(i,["googleSearch"]);y!=null&&c(n,["googleSearch"],gE(y));const h=u(i,["urlContext"]);return h!=null&&c(n,["urlContext"],h),n}function Eh(i){const n={},o=u(i,["functionDeclarations"]);if(o!=null){let S=o;Array.isArray(S)&&(S=S.map(_=>OS(_))),c(n,["functionDeclarations"],S)}const a=u(i,["retrieval"]);a!=null&&c(n,["retrieval"],a);const r=u(i,["googleSearchRetrieval"]);r!=null&&c(n,["googleSearchRetrieval"],r);const d=u(i,["computerUse"]);if(d!=null&&c(n,["computerUse"],d),u(i,["fileSearch"])!==void 0)throw new Error("fileSearch parameter is not supported in Vertex AI.");const m=u(i,["codeExecution"]);m!=null&&c(n,["codeExecution"],m);const g=u(i,["enterpriseWebSearch"]);g!=null&&c(n,["enterpriseWebSearch"],g);const y=u(i,["googleMaps"]);y!=null&&c(n,["googleMaps"],y);const h=u(i,["googleSearch"]);h!=null&&c(n,["googleSearch"],h);const v=u(i,["urlContext"]);return v!=null&&c(n,["urlContext"],v),n}function zE(i){const n={},o=u(i,["baseModel"]);o!=null&&c(n,["baseModel"],o);const a=u(i,["createTime"]);a!=null&&c(n,["createTime"],a);const r=u(i,["updateTime"]);return r!=null&&c(n,["updateTime"],r),n}function PE(i){const n={},o=u(i,["labels","google-vertex-llm-tuning-base-model-id"]);o!=null&&c(n,["baseModel"],o);const a=u(i,["createTime"]);a!=null&&c(n,["createTime"],a);const r=u(i,["updateTime"]);return r!=null&&c(n,["updateTime"],r),n}function BE(i,n){const o={},a=u(i,["displayName"]);n!==void 0&&a!=null&&c(n,["displayName"],a);const r=u(i,["description"]);n!==void 0&&r!=null&&c(n,["description"],r);const d=u(i,["defaultCheckpointId"]);return n!==void 0&&d!=null&&c(n,["defaultCheckpointId"],d),o}function kE(i,n){const o={},a=u(i,["displayName"]);n!==void 0&&a!=null&&c(n,["displayName"],a);const r=u(i,["description"]);n!==void 0&&r!=null&&c(n,["description"],r);const d=u(i,["defaultCheckpointId"]);return n!==void 0&&d!=null&&c(n,["defaultCheckpointId"],d),o}function OE(i,n){const o={},a=u(n,["model"]);a!=null&&c(o,["_url","name"],Ae(i,a));const r=u(n,["config"]);return r!=null&&BE(r,o),o}function FE(i,n){const o={},a=u(n,["model"]);a!=null&&c(o,["_url","model"],Ae(i,a));const r=u(n,["config"]);return r!=null&&kE(r,o),o}function YE(i,n){const o={},a=u(i,["outputGcsUri"]);n!==void 0&&a!=null&&c(n,["parameters","storageUri"],a);const r=u(i,["safetyFilterLevel"]);n!==void 0&&r!=null&&c(n,["parameters","safetySetting"],r);const d=u(i,["personGeneration"]);n!==void 0&&d!=null&&c(n,["parameters","personGeneration"],d);const m=u(i,["includeRaiReason"]);n!==void 0&&m!=null&&c(n,["parameters","includeRaiReason"],m);const g=u(i,["outputMimeType"]);n!==void 0&&g!=null&&c(n,["parameters","outputOptions","mimeType"],g);const y=u(i,["outputCompressionQuality"]);n!==void 0&&y!=null&&c(n,["parameters","outputOptions","compressionQuality"],y);const h=u(i,["enhanceInputImage"]);n!==void 0&&h!=null&&c(n,["parameters","upscaleConfig","enhanceInputImage"],h);const v=u(i,["imagePreservationFactor"]);n!==void 0&&v!=null&&c(n,["parameters","upscaleConfig","imagePreservationFactor"],v);const S=u(i,["labels"]);n!==void 0&&S!=null&&c(n,["labels"],S);const _=u(i,["numberOfImages"]);n!==void 0&&_!=null&&c(n,["parameters","sampleCount"],_);const M=u(i,["mode"]);return n!==void 0&&M!=null&&c(n,["parameters","mode"],M),o}function JE(i,n){const o={},a=u(n,["model"]);a!=null&&c(o,["_url","model"],Ae(i,a));const r=u(n,["image"]);r!=null&&c(o,["instances[0]","image"],Vt(r));const d=u(n,["upscaleFactor"]);d!=null&&c(o,["parameters","upscaleConfig","upscaleFactor"],d);const m=u(n,["config"]);return m!=null&&YE(m,o),o}function KE(i){const n={},o=u(i,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const a=u(i,["predictions"]);if(a!=null){let r=a;Array.isArray(r)&&(r=r.map(d=>_a(d))),c(n,["generatedImages"],r)}return n}function XE(i){const n={},o=u(i,["uri"]);o!=null&&c(n,["uri"],o);const a=u(i,["encodedVideo"]);a!=null&&c(n,["videoBytes"],Hn(a));const r=u(i,["encoding"]);return r!=null&&c(n,["mimeType"],r),n}function QE(i){const n={},o=u(i,["gcsUri"]);o!=null&&c(n,["uri"],o);const a=u(i,["bytesBase64Encoded"]);a!=null&&c(n,["videoBytes"],Hn(a));const r=u(i,["mimeType"]);return r!=null&&c(n,["mimeType"],r),n}function ZE(i){const n={},o=u(i,["image"]);o!=null&&c(n,["_self"],Vt(o));const a=u(i,["maskMode"]);return a!=null&&c(n,["maskMode"],a),n}function $E(i){const n={},o=u(i,["image"]);o!=null&&c(n,["image"],Ca(o));const a=u(i,["referenceType"]);return a!=null&&c(n,["referenceType"],a),n}function WE(i){const n={},o=u(i,["image"]);o!=null&&c(n,["image"],Vt(o));const a=u(i,["referenceType"]);return a!=null&&c(n,["referenceType"],a),n}function _h(i){const n={},o=u(i,["uri"]);o!=null&&c(n,["uri"],o);const a=u(i,["videoBytes"]);a!=null&&c(n,["encodedVideo"],Hn(a));const r=u(i,["mimeType"]);return r!=null&&c(n,["encoding"],r),n}function Ch(i){const n={},o=u(i,["uri"]);o!=null&&c(n,["gcsUri"],o);const a=u(i,["videoBytes"]);a!=null&&c(n,["bytesBase64Encoded"],Hn(a));const r=u(i,["mimeType"]);return r!=null&&c(n,["mimeType"],r),n}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */const jE="Content-Type",e_="X-Server-Timeout",t_="User-Agent",nr="x-goog-api-client",n_="1.29.1",i_=`google-genai-sdk/${n_}`,l_="v1beta1",o_="v1beta",km=/^\s*data: (.*)(?:\n\n|\r\r|\r\n\r\n)/;class a_{constructor(n){var o,a;this.clientOptions=Object.assign(Object.assign({},n),{project:n.project,location:n.location,apiKey:n.apiKey,vertexai:n.vertexai});const r={};this.clientOptions.vertexai?(r.apiVersion=(o=this.clientOptions.apiVersion)!==null&&o!==void 0?o:l_,r.baseUrl=this.baseUrlFromProjectLocation(),this.normalizeAuthParameters()):(r.apiVersion=(a=this.clientOptions.apiVersion)!==null&&a!==void 0?a:o_,r.baseUrl="https://generativelanguage.googleapis.com/"),r.headers=this.getDefaultHeaders(),this.clientOptions.httpOptions=r,n.httpOptions&&(this.clientOptions.httpOptions=this.patchHttpOptions(r,n.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 n;return(n=this.clientOptions.vertexai)!==null&&n!==void 0?n:!1}getProject(){return this.clientOptions.project}getLocation(){return this.clientOptions.location}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(n){if(!n||n.baseUrl===void 0||n.apiVersion===void 0)throw new Error("HTTP options are not correctly set.");const a=[n.baseUrl.endsWith("/")?n.baseUrl.slice(0,-1):n.baseUrl];return n.apiVersion&&n.apiVersion!==""&&a.push(n.apiVersion),a.join("/")}getBaseResourcePath(){return`projects/${this.clientOptions.project}/locations/${this.clientOptions.location}`}getApiKey(){return this.clientOptions.apiKey}getWebsocketBaseUrl(){const n=this.getBaseUrl(),o=new URL(n);return o.protocol=o.protocol=="http:"?"ws":"wss",o.toString()}setBaseUrl(n){if(this.clientOptions.httpOptions)this.clientOptions.httpOptions.baseUrl=n;else throw new Error("HTTP options are not correctly set.")}constructUrl(n,o,a){const r=[this.getRequestUrlInternal(o)];return a&&r.push(this.getBaseResourcePath()),n!==""&&r.push(n),new URL(`${r.join("/")}`)}shouldPrependVertexProjectPath(n){return!(this.clientOptions.apiKey||!this.clientOptions.vertexai||n.path.startsWith("projects/")||n.httpMethod==="GET"&&n.path.startsWith("publishers/google/models"))}async request(n){let o=this.clientOptions.httpOptions;n.httpOptions&&(o=this.patchHttpOptions(this.clientOptions.httpOptions,n.httpOptions));const a=this.shouldPrependVertexProjectPath(n),r=this.constructUrl(n.path,o,a);if(n.queryParams)for(const[m,g]of Object.entries(n.queryParams))r.searchParams.append(m,String(g));let d={};if(n.httpMethod==="GET"){if(n.body&&n.body!=="{}")throw new Error("Request body should be empty for GET request, but got non empty request body")}else d.body=n.body;return d=await this.includeExtraHttpOptionsToRequestInit(d,o,r.toString(),n.abortSignal),this.unaryApiCall(r,d,n.httpMethod)}patchHttpOptions(n,o){const a=JSON.parse(JSON.stringify(n));for(const[r,d]of Object.entries(o))typeof d=="object"?a[r]=Object.assign(Object.assign({},a[r]),d):d!==void 0&&(a[r]=d);return a}async requestStream(n){let o=this.clientOptions.httpOptions;n.httpOptions&&(o=this.patchHttpOptions(this.clientOptions.httpOptions,n.httpOptions));const a=this.shouldPrependVertexProjectPath(n),r=this.constructUrl(n.path,o,a);(!r.searchParams.has("alt")||r.searchParams.get("alt")!=="sse")&&r.searchParams.set("alt","sse");let d={};return d.body=n.body,d=await this.includeExtraHttpOptionsToRequestInit(d,o,r.toString(),n.abortSignal),this.streamApiCall(r,d,n.httpMethod)}async includeExtraHttpOptionsToRequestInit(n,o,a,r){if(o&&o.timeout||r){const d=new AbortController,m=d.signal;if(o.timeout&&(o==null?void 0:o.timeout)>0){const g=setTimeout(()=>d.abort(),o.timeout);g&&typeof g.unref=="function"&&g.unref()}r&&r.addEventListener("abort",()=>{d.abort()}),n.signal=m}return o&&o.extraBody!==null&&s_(n,o.extraBody),n.headers=await this.getHeadersInternal(o,a),n}async unaryApiCall(n,o,a){return this.apiCall(n.toString(),Object.assign(Object.assign({},o),{method:a})).then(async r=>(await Om(r),new $u(r))).catch(r=>{throw r instanceof Error?r:new Error(JSON.stringify(r))})}async streamApiCall(n,o,a){return this.apiCall(n.toString(),Object.assign(Object.assign({},o),{method:a})).then(async r=>(await Om(r),this.processStreamResponse(r))).catch(r=>{throw r instanceof Error?r:new Error(JSON.stringify(r))})}processStreamResponse(n){var o;return Fi(this,arguments,function*(){const r=(o=n==null?void 0:n.body)===null||o===void 0?void 0:o.getReader(),d=new TextDecoder("utf-8");if(!r)throw new Error("Response body is empty");try{let m="";for(;;){const{done:g,value:y}=yield Le(r.read());if(g){if(m.trim().length>0)throw new Error("Incomplete JSON segment at the end");break}const h=d.decode(y,{stream:!0});try{const S=JSON.parse(h);if("error"in S){const _=JSON.parse(JSON.stringify(S.error)),M=_.status,z=_.code,P=`got status: ${M}. ${JSON.stringify(S)}`;if(z>=400&&z<600)throw new Sa({message:P,status:z})}}catch(S){if(S.name==="ApiError")throw S}m+=h;let v=m.match(km);for(;v;){const S=v[1];try{const _=new Response(S,{headers:n==null?void 0:n.headers,status:n==null?void 0:n.status,statusText:n==null?void 0:n.statusText});yield yield Le(new $u(_)),m=m.slice(v[0].length),v=m.match(km)}catch(_){throw new Error(`exception parsing stream chunk ${S}. ${_}`)}}}}finally{r.releaseLock()}})}async apiCall(n,o){return fetch(n,o).catch(a=>{throw new Error(`exception ${a} sending request`)})}getDefaultHeaders(){const n={},o=i_+" "+this.clientOptions.userAgentExtra;return n[t_]=o,n[nr]=o,n[jE]="application/json",n}async getHeadersInternal(n,o){const a=new Headers;if(n&&n.headers){for(const[r,d]of Object.entries(n.headers))a.append(r,d);n.timeout&&n.timeout>0&&a.append(e_,String(Math.ceil(n.timeout/1e3)))}return await this.clientOptions.auth.addAuthHeaders(a,o),a}getFileName(n){var o;let a="";return typeof n=="string"&&(a=n.replace(/[/\\]+$/,""),a=(o=a.split(/[/\\]/).pop())!==null&&o!==void 0?o:""),a}async uploadFile(n,o){var a;const r={};o!=null&&(r.mimeType=o.mimeType,r.name=o.name,r.displayName=o.displayName),r.name&&!r.name.startsWith("files/")&&(r.name=`files/${r.name}`);const d=this.clientOptions.uploader,m=await d.stat(n);r.sizeBytes=String(m.size);const g=(a=o==null?void 0:o.mimeType)!==null&&a!==void 0?a:m.type;if(g===void 0||g==="")throw new Error("Can not determine mimeType. Please provide mimeType in the config.");r.mimeType=g;const y={file:r},h=this.getFileName(n),v=X("upload/v1beta/files",y._url),S=await this.fetchUploadUrl(v,r.sizeBytes,r.mimeType,h,y,o==null?void 0:o.httpOptions);return d.upload(n,S,this)}async uploadFileToFileSearchStore(n,o,a){var r;const d=this.clientOptions.uploader,m=await d.stat(o),g=String(m.size),y=(r=a==null?void 0:a.mimeType)!==null&&r!==void 0?r:m.type;if(y===void 0||y==="")throw new Error("Can not determine mimeType. Please provide mimeType in the config.");const h=`upload/v1beta/${n}:uploadToFileSearchStore`,v=this.getFileName(o),S={};a!=null&&a.customMetadata&&(S.customMetadata=a.customMetadata),a!=null&&a.chunkingConfig&&(S.chunkingConfig=a.chunkingConfig);const _=await this.fetchUploadUrl(h,g,y,v,S,a==null?void 0:a.httpOptions);return d.uploadToFileSearchStore(o,_,this)}async downloadFile(n){await this.clientOptions.downloader.download(n,this)}async fetchUploadUrl(n,o,a,r,d,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":`${o}`,"X-Goog-Upload-Header-Content-Type":`${a}`},r?{"X-Goog-Upload-File-Name":r}:{})};const h=await this.request({path:n,body:JSON.stringify(d),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 Om(i){var n;if(i===void 0)throw new Error("response is undefined");if(!i.ok){const o=i.status;let a;!((n=i.headers.get("content-type"))===null||n===void 0)&&n.includes("application/json")?a=await i.json():a={error:{message:await i.text(),code:i.status,status:i.statusText}};const r=JSON.stringify(a);throw o>=400&&o<600?new Sa({message:r,status:o}):new Error(r)}}function s_(i,n){if(!n||Object.keys(n).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 o={};if(typeof i.body=="string"&&i.body.length>0)try{const d=JSON.parse(i.body);if(typeof d=="object"&&d!==null&&!Array.isArray(d))o=d;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(d,m){const g=Object.assign({},d);for(const y in m)if(Object.prototype.hasOwnProperty.call(m,y)){const h=m[y],v=g[y];h&&typeof h=="object"&&!Array.isArray(h)&&v&&typeof v=="object"&&!Array.isArray(v)?g[y]=a(v,h):(v&&h&&typeof v!=typeof h&&console.warn(`includeExtraBodyToRequestInit:deepMerge: Type mismatch for key "${y}". Original type: ${typeof v}, New type: ${typeof h}. Overwriting.`),g[y]=h)}return g}const r=a(o,n);i.body=JSON.stringify(r)}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */const u_="mcp_used/unknown";let r_=!1;function Ah(i){for(const n of i)if(c_(n)||typeof n=="object"&&"inputSchema"in n)return!0;return r_}function Rh(i){var n;const o=(n=i[nr])!==null&&n!==void 0?n:"";i[nr]=(o+` ${u_}`).trimStart()}function c_(i){return i!==null&&typeof i=="object"&&i instanceof mr}function f_(i,n=100){return Fi(this,arguments,function*(){let a,r=0;for(;r0)return;const d={},m=[];for(const v of this.mcpClients)try{for(var g=!0,y=(o=void 0,Yl(f_(v))),h;h=await y.next(),n=h.done,!n;g=!0){r=h.value,g=!1;const S=r;m.push(S);const _=S.name;if(d[_])throw new Error(`Duplicate function name ${_} found in MCP tools. Please ensure function names are unique.`);d[_]=v}}catch(S){o={error:S}}finally{try{!g&&!n&&(a=y.return)&&await a.call(y)}finally{if(o)throw o.error}}this.mcpTools=m,this.functionNameToMcpClient=d}async tool(){return await this.initialize(),gv(this.mcpTools,this.config)}async callTool(n){await this.initialize();const o=[];for(const a of n)if(a.name in this.functionNameToMcpClient){const r=this.functionNameToMcpClient[a.name];let d;this.config.timeout&&(d={timeout:this.config.timeout});const m=await r.callTool({name:a.name,arguments:a.args},void 0,d);o.push({functionResponse:{name:a.name,response:m.isError?{error:m}:m}})}return o}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */async function d_(i,n,o){const a=new uv;let r;o.data instanceof Blob?r=JSON.parse(await o.data.text()):r=JSON.parse(o.data),Object.assign(a,r),n(a)}class p_{constructor(n,o,a){this.apiClient=n,this.auth=o,this.webSocketFactory=a}async connect(n){var o,a;if(this.apiClient.isVertexAI())throw new Error("Live music is not supported for Vertex AI.");console.warn("Live music generation is experimental and may change in future versions.");const r=this.apiClient.getWebsocketBaseUrl(),d=this.apiClient.getApiVersion(),m=g_(this.apiClient.getDefaultHeaders()),g=this.apiClient.getApiKey(),y=`${r}/ws/google.ai.generativelanguage.${d}.GenerativeService.BidiGenerateMusic?key=${g}`;let h=()=>{};const v=new Promise(B=>{h=B}),S=n.callbacks,_=function(){h({})},M=this.apiClient,z={onopen:_,onmessage:B=>{d_(M,S.onmessage,B)},onerror:(o=S==null?void 0:S.onerror)!==null&&o!==void 0?o:function(B){},onclose:(a=S==null?void 0:S.onclose)!==null&&a!==void 0?a:function(B){}},P=this.webSocketFactory.create(y,h_(m),z);P.connect(),await v;const F={setup:{model:Ae(this.apiClient,n.model)}};return P.send(JSON.stringify(F)),new m_(P,this.apiClient)}}class m_{constructor(n,o){this.conn=n,this.apiClient=o}async setWeightedPrompts(n){if(!n.weightedPrompts||Object.keys(n.weightedPrompts).length===0)throw new Error("Weighted prompts must be set and contain at least one entry.");const o=oS(n);this.conn.send(JSON.stringify({clientContent:o}))}async setMusicGenerationConfig(n){n.musicGenerationConfig||(n.musicGenerationConfig={});const o=lS(n);this.conn.send(JSON.stringify(o))}sendPlaybackControl(n){const o={playbackControl:n};this.conn.send(JSON.stringify(o))}play(){this.sendPlaybackControl(ki.PLAY)}pause(){this.sendPlaybackControl(ki.PAUSE)}stop(){this.sendPlaybackControl(ki.STOP)}resetContext(){this.sendPlaybackControl(ki.RESET_CONTEXT)}close(){this.conn.close()}}function h_(i){const n={};return i.forEach((o,a)=>{n[a]=o}),n}function g_(i){const n=new Headers;for(const[o,a]of Object.entries(i))n.append(o,a);return n}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */const y_="FunctionResponse request must have an `id` field from the response of a ToolCall.FunctionalCalls in Google AI.";async function v_(i,n,o){const a=new sv;let r;o.data instanceof Blob?r=await o.data.text():o.data instanceof ArrayBuffer?r=new TextDecoder().decode(o.data):r=o.data;const d=JSON.parse(r);if(i.isVertexAI()){const m=uS(d);Object.assign(a,m)}else Object.assign(a,d);n(a)}class T_{constructor(n,o,a){this.apiClient=n,this.auth=o,this.webSocketFactory=a,this.music=new p_(this.apiClient,this.auth,this.webSocketFactory)}async connect(n){var o,a,r,d,m,g;if(n.config&&n.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();n.config&&n.config.tools&&Ah(n.config.tools)&&Rh(S);const _=C_(S);if(this.apiClient.isVertexAI())v=`${y}/ws/google.cloud.aiplatform.${h}.LlmBidiService/BidiGenerateContent`,await this.auth.addAuthHeaders(_,v);else{const ee=this.apiClient.getApiKey();let re="BidiGenerateContent",de="key";ee!=null&&ee.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",de="access_token"),v=`${y}/ws/google.ai.generativelanguage.${h}.GenerativeService.${re}?${de}=${ee}`}let M=()=>{};const z=new Promise(ee=>{M=ee}),P=n.callbacks,O=function(){var ee;(ee=P==null?void 0:P.onopen)===null||ee===void 0||ee.call(P),M({})},k=this.apiClient,F={onopen:O,onmessage:ee=>{v_(k,P.onmessage,ee)},onerror:(o=P==null?void 0:P.onerror)!==null&&o!==void 0?o:function(ee){},onclose:(a=P==null?void 0:P.onclose)!==null&&a!==void 0?a:function(ee){}},B=this.webSocketFactory.create(v,__(_),F);B.connect(),await z;let Q=Ae(this.apiClient,n.model);if(this.apiClient.isVertexAI()&&Q.startsWith("publishers/")){const ee=this.apiClient.getProject(),re=this.apiClient.getLocation();Q=`projects/${ee}/locations/${re}/`+Q}let ne={};this.apiClient.isVertexAI()&&((r=n.config)===null||r===void 0?void 0:r.responseModalities)===void 0&&(n.config===void 0?n.config={responseModalities:[ha.AUDIO]}:n.config.responseModalities=[ha.AUDIO]),!((d=n.config)===null||d===void 0)&&d.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=n.config)===null||m===void 0?void 0:m.tools)!==null&&g!==void 0?g:[],J=[];for(const ee of W)if(this.isCallableTool(ee)){const re=ee;J.push(await re.tool())}else J.push(ee);J.length>0&&(n.config.tools=J);const he={model:Q,config:n.config,callbacks:n.callbacks};return this.apiClient.isVertexAI()?ne=iS(this.apiClient,he):ne=nS(this.apiClient,he),delete ne.config,B.send(JSON.stringify(ne)),new E_(B,this.apiClient)}isCallableTool(n){return"callTool"in n&&typeof n.callTool=="function"}}const S_={turnComplete:!0};class E_{constructor(n,o){this.conn=n,this.apiClient=o}tLiveClientContent(n,o){if(o.turns!==null&&o.turns!==void 0){let a=[];try{a=qt(o.turns),n.isVertexAI()||(a=a.map(r=>Ea(r)))}catch{throw new Error(`Failed to parse client content "turns", type: '${typeof o.turns}'`)}return{clientContent:{turns:a,turnComplete:o.turnComplete}}}return{clientContent:{turnComplete:o.turnComplete}}}tLiveClienttToolResponse(n,o){let a=[];if(o.functionResponses==null)throw new Error("functionResponses is required.");if(Array.isArray(o.functionResponses)?a=o.functionResponses:a=[o.functionResponses],a.length===0)throw new Error("functionResponses is required.");for(const d of a){if(typeof d!="object"||d===null||!("name"in d)||!("response"in d))throw new Error(`Could not parse function response, type '${typeof d}'.`);if(!n.isVertexAI()&&!("id"in d))throw new Error(y_)}return{toolResponse:{functionResponses:a}}}sendClientContent(n){n=Object.assign(Object.assign({},S_),n);const o=this.tLiveClientContent(this.apiClient,n);this.conn.send(JSON.stringify(o))}sendRealtimeInput(n){let o={};this.apiClient.isVertexAI()?o={realtimeInput:sS(n)}:o={realtimeInput:aS(n)},this.conn.send(JSON.stringify(o))}sendToolResponse(n){if(n.functionResponses==null)throw new Error("Tool response parameters are required.");const o=this.tLiveClienttToolResponse(this.apiClient,n);this.conn.send(JSON.stringify(o))}close(){this.conn.close()}}function __(i){const n={};return i.forEach((o,a)=>{n[a]=o}),n}function C_(i){const n=new Headers;for(const[o,a]of Object.entries(i))n.append(o,a);return n}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */const Fm=10;function Ym(i){var n,o,a;if(!((n=i==null?void 0:i.automaticFunctionCalling)===null||n===void 0)&&n.disable)return!0;let r=!1;for(const m of(o=i==null?void 0:i.tools)!==null&&o!==void 0?o:[])if(Yi(m)){r=!0;break}if(!r)return!0;const d=(a=i==null?void 0:i.automaticFunctionCalling)===null||a===void 0?void 0:a.maximumRemoteCalls;return d&&(d<0||!Number.isInteger(d))||d==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:",d),!0):!1}function Yi(i){return"callTool"in i&&typeof i.callTool=="function"}function A_(i){var n,o,a;return(a=(o=(n=i.config)===null||n===void 0?void 0:n.tools)===null||o===void 0?void 0:o.some(r=>Yi(r)))!==null&&a!==void 0?a:!1}function Jm(i){var n;const o=[];return!((n=i==null?void 0:i.config)===null||n===void 0)&&n.tools&&i.config.tools.forEach((a,r)=>{if(Yi(a))return;const d=a;d.functionDeclarations&&d.functionDeclarations.length>0&&o.push(r)}),o}function Km(i){var n;return!(!((n=i==null?void 0:i.automaticFunctionCalling)===null||n===void 0)&&n.ignoreCallHistory)}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class R_ extends cn{constructor(n){super(),this.apiClient=n,this.generateContent=async o=>{var a,r,d,m,g;const y=await this.processParamsMaybeAddMcpUsage(o);if(this.maybeMoveToResponseJsonSchem(o),!A_(o)||Ym(o.config))return await this.generateContentInternal(y);const h=Jm(o);if(h.length>0){const P=h.map(O=>`tools[${O}]`).join(", ");throw new Error(`Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations is not yet supported. Incompatible tools found at ${P}.`)}let v,S;const _=qt(y.contents),M=(d=(r=(a=y.config)===null||a===void 0?void 0:a.automaticFunctionCalling)===null||r===void 0?void 0:r.maximumRemoteCalls)!==null&&d!==void 0?d:Fm;let z=0;for(;z{if(this.maybeMoveToResponseJsonSchem(o),Ym(o.config)){const r=await this.processParamsMaybeAddMcpUsage(o);return await this.generateContentStreamInternal(r)}const a=Jm(o);if(a.length>0){const r=a.map(d=>`tools[${d}]`).join(", ");throw new Error(`Incompatible tools found at ${r}. Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations" is not yet supported.`)}return await this.processAfcStream(o)},this.generateImages=async o=>await this.generateImagesInternal(o).then(a=>{var r;let d;const m=[];if(a!=null&&a.generatedImages)for(const y of a.generatedImages)y&&(y!=null&&y.safetyAttributes)&&((r=y==null?void 0:y.safetyAttributes)===null||r===void 0?void 0:r.contentType)==="Positive Prompt"?d=y==null?void 0:y.safetyAttributes:m.push(y);let g;return d?g={generatedImages:m,positivePromptSafetyAttributes:d,sdkHttpResponse:a.sdkHttpResponse}:g={generatedImages:m,sdkHttpResponse:a.sdkHttpResponse},g}),this.list=async o=>{var a;const m={config:Object.assign(Object.assign({},{queryBase:!0}),o==null?void 0:o.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 ii(rn.PAGED_ITEM_MODELS,g=>this.listInternal(g),await this.listInternal(m),m)},this.editImage=async o=>{const a={model:o.model,prompt:o.prompt,referenceImages:[],config:o.config};return o.referenceImages&&o.referenceImages&&(a.referenceImages=o.referenceImages.map(r=>r.toReferenceImageAPI())),await this.editImageInternal(a)},this.upscaleImage=async o=>{let a={numberOfImages:1,mode:"upscale"};o.config&&(a=Object.assign(Object.assign({},a),o.config));const r={model:o.model,image:o.image,upscaleFactor:o.upscaleFactor,config:a};return await this.upscaleImageInternal(r)},this.generateVideos=async o=>{var a,r,d,m,g,y;if((o.prompt||o.image||o.video)&&o.source)throw new Error("Source and prompt/image/video are mutually exclusive. Please only use source.");return this.apiClient.isVertexAI()||(!((a=o.video)===null||a===void 0)&&a.uri&&(!((r=o.video)===null||r===void 0)&&r.videoBytes)?o.video={uri:o.video.uri,mimeType:o.video.mimeType}:!((m=(d=o.source)===null||d===void 0?void 0:d.video)===null||m===void 0)&&m.uri&&(!((y=(g=o.source)===null||g===void 0?void 0:g.video)===null||y===void 0)&&y.videoBytes)&&(o.source.video={uri:o.source.video.uri,mimeType:o.source.video.mimeType})),await this.generateVideosInternal(o)}}maybeMoveToResponseJsonSchem(n){n.config&&n.config.responseSchema&&(n.config.responseJsonSchema||Object.keys(n.config.responseSchema).includes("$schema")&&(n.config.responseJsonSchema=n.config.responseSchema,delete n.config.responseSchema))}async processParamsMaybeAddMcpUsage(n){var o,a,r;const d=(o=n.config)===null||o===void 0?void 0:o.tools;if(!d)return n;const m=await Promise.all(d.map(async y=>Yi(y)?await y.tool():y)),g={model:n.model,contents:n.contents,config:Object.assign(Object.assign({},n.config),{tools:m})};if(g.config.tools=m,n.config&&n.config.tools&&Ah(n.config.tools)){const y=(r=(a=n.config.httpOptions)===null||a===void 0?void 0:a.headers)!==null&&r!==void 0?r:{};let h=Object.assign({},y);Object.keys(h).length===0&&(h=this.apiClient.getDefaultHeaders()),Rh(h),g.config.httpOptions=Object.assign(Object.assign({},n.config.httpOptions),{headers:h})}return g}async initAfcToolsMap(n){var o,a,r;const d=new Map;for(const m of(a=(o=n.config)===null||o===void 0?void 0:o.tools)!==null&&a!==void 0?a:[])if(Yi(m)){const g=m,y=await g.tool();for(const h of(r=y.functionDeclarations)!==null&&r!==void 0?r:[]){if(!h.name)throw new Error("Function declaration name is required.");if(d.has(h.name))throw new Error(`Duplicate tool declaration name: ${h.name}`);d.set(h.name,g)}}return d}async processAfcStream(n){var o,a,r;const d=(r=(a=(o=n.config)===null||o===void 0?void 0:o.automaticFunctionCalling)===null||a===void 0?void 0:a.maximumRemoteCalls)!==null&&r!==void 0?r:Fm;let m=!1,g=0;const y=await this.initAfcToolsMap(n);return(function(h,v,S){var _,M;return Fi(this,arguments,function*(){for(var z,P,O,k;g0){m=!0;const ee=new Fl;ee.candidates=[{content:{role:"user",parts:J}}],yield yield Le(ee);const re=[];re.push(...he),re.push({role:"user",parts:J});const de=qt(S.contents).concat(re);S.contents=de}else break}})})(this,y,n)}async generateContentInternal(n){var o,a,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=zm(this.apiClient,n);return g=X("{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:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:v.headers},_})),m.then(v=>{const S=Bm(v),_=new Fl;return Object.assign(_,S),_})}else{const h=Vm(this.apiClient,n);return g=X("{model}:generateContent",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(v=>v.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:v.headers},_})),m.then(v=>{const S=Pm(v),_=new Fl;return Object.assign(_,S),_})}}async generateContentStreamInternal(n){var o,a,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=zm(this.apiClient,n);return g=X("{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:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}),m.then(function(S){return Fi(this,arguments,function*(){var _,M,z,P;try{for(var O=!0,k=Yl(S),F;F=yield Le(k.next()),_=F.done,!_;O=!0){P=F.value,O=!1;const B=P,Q=Bm(yield Le(B.json()));Q.sdkHttpResponse={headers:B.headers};const ne=new Fl;Object.assign(ne,Q),yield yield Le(ne)}}catch(B){M={error:B}}finally{try{!O&&!_&&(z=k.return)&&(yield Le(z.call(k)))}finally{if(M)throw M.error}}})})}else{const h=Vm(this.apiClient,n);return g=X("{model}:streamGenerateContent?alt=sse",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.requestStream({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}),m.then(function(S){return Fi(this,arguments,function*(){var _,M,z,P;try{for(var O=!0,k=Yl(S),F;F=yield Le(k.next()),_=F.done,!_;O=!0){P=F.value,O=!1;const B=P,Q=Pm(yield Le(B.json()));Q.sdkHttpResponse={headers:B.headers};const ne=new Fl;Object.assign(ne,Q),yield yield Le(ne)}}catch(B){M={error:B}}finally{try{!O&&!_&&(z=k.return)&&(yield Le(z.call(k)))}finally{if(M)throw M.error}}})})}}async embedContent(n){var o,a,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=VS(this.apiClient,n);return g=X("{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:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:v.headers},_})),m.then(v=>{const S=PS(v),_=new _m;return Object.assign(_,S),_})}else{const h=HS(this.apiClient,n);return g=X("{model}:batchEmbedContents",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(v=>v.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:v.headers},_})),m.then(v=>{const S=zS(v),_=new _m;return Object.assign(_,S),_})}}async generateImagesInternal(n){var o,a,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=QS(this.apiClient,n);return g=X("{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:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:v.headers},_})),m.then(v=>{const S=$S(v),_=new Cm;return Object.assign(_,S),_})}else{const h=XS(this.apiClient,n);return g=X("{model}:predict",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(v=>v.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:v.headers},_})),m.then(v=>{const S=ZS(v),_=new Cm;return Object.assign(_,S),_})}}async editImageInternal(n){var o,a;let r,d="",m={};if(this.apiClient.isVertexAI()){const g=bS(this.apiClient,n);return d=X("{model}:predict",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json().then(h=>{const v=h;return v.sdkHttpResponse={headers:y.headers},v})),r.then(y=>{const h=qS(y),v=new Z0;return Object.assign(v,h),v})}else throw new Error("This method is only supported by the Vertex AI.")}async upscaleImageInternal(n){var o,a;let r,d="",m={};if(this.apiClient.isVertexAI()){const g=JE(this.apiClient,n);return d=X("{model}:predict",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json().then(h=>{const v=h;return v.sdkHttpResponse={headers:y.headers},v})),r.then(y=>{const h=KE(y),v=new $0;return Object.assign(v,h),v})}else throw new Error("This method is only supported by the Vertex AI.")}async recontextImage(n){var o,a;let r,d="",m={};if(this.apiClient.isVertexAI()){const g=xE(this.apiClient,n);return d=X("{model}:predict",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json()),r.then(y=>{const h=DE(y),v=new W0;return Object.assign(v,h),v})}else throw new Error("This method is only supported by the Vertex AI.")}async segmentImage(n){var o,a;let r,d="",m={};if(this.apiClient.isVertexAI()){const g=LE(this.apiClient,n);return d=X("{model}:predict",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json()),r.then(y=>{const h=GE(y),v=new j0;return Object.assign(v,h),v})}else throw new Error("This method is only supported by the Vertex AI.")}async get(n){var o,a,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=mE(this.apiClient,n);return g=X("{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:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json()),m.then(v=>tr(v))}else{const h=pE(this.apiClient,n);return g=X("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(v=>v.json()),m.then(v=>er(v))}}async listInternal(n){var o,a,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=EE(this.apiClient,n);return g=X("{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:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:v.headers},_})),m.then(v=>{const S=CE(v),_=new Am;return Object.assign(_,S),_})}else{const h=SE(this.apiClient,n);return g=X("{models_url}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(v=>v.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:v.headers},_})),m.then(v=>{const S=_E(v),_=new Am;return Object.assign(_,S),_})}}async update(n){var o,a,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=FE(this.apiClient,n);return g=X("{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:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json()),m.then(v=>tr(v))}else{const h=OE(this.apiClient,n);return g=X("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"PATCH",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(v=>v.json()),m.then(v=>er(v))}}async delete(n){var o,a,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=DS(this.apiClient,n);return g=X("{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:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:v.headers},_})),m.then(v=>{const S=US(v),_=new Rm;return Object.assign(_,S),_})}else{const h=xS(this.apiClient,n);return g=X("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"DELETE",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(v=>v.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:v.headers},_})),m.then(v=>{const S=IS(v),_=new Rm;return Object.assign(_,S),_})}}async countTokens(n){var o,a,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=RS(this.apiClient,n);return g=X("{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:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:v.headers},_})),m.then(v=>{const S=NS(v),_=new Mm;return Object.assign(_,S),_})}else{const h=AS(this.apiClient,n);return g=X("{model}:countTokens",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(v=>v.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:v.headers},_})),m.then(v=>{const S=MS(v),_=new Mm;return Object.assign(_,S),_})}}async computeTokens(n){var o,a;let r,d="",m={};if(this.apiClient.isVertexAI()){const g=yS(this.apiClient,n);return d=X("{model}:computeTokens",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json().then(h=>{const v=h;return v.sdkHttpResponse={headers:y.headers},v})),r.then(y=>{const h=vS(y),v=new ev;return Object.assign(v,h),v})}else throw new Error("This method is only supported by the Vertex AI.")}async generateVideosInternal(n){var o,a,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=iE(this.apiClient,n);return g=X("{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:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json()),m.then(v=>{const S=tE(v),_=new ga;return Object.assign(_,S),_})}else{const h=nE(this.apiClient,n);return g=X("{model}:predictLongRunning",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(v=>v.json()),m.then(v=>{const S=eE(v),_=new ga;return Object.assign(_,S),_})}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class M_ extends cn{constructor(n){super(),this.apiClient=n}async getVideosOperation(n){const o=n.operation,a=n.config;if(o.name===void 0||o.name==="")throw new Error("Operation name is required.");if(this.apiClient.isVertexAI()){const r=o.name.split("/operations/")[0];let d;a&&"httpOptions"in a&&(d=a.httpOptions);const m=await this.fetchPredictVideosOperationInternal({operationName:o.name,resourceName:r,config:{httpOptions:d}});return o._fromAPIResponse({apiResponse:m,_isVertexAI:!0})}else{const r=await this.getVideosOperationInternal({operationName:o.name,config:a});return o._fromAPIResponse({apiResponse:r,_isVertexAI:!1})}}async get(n){const o=n.operation,a=n.config;if(o.name===void 0||o.name==="")throw new Error("Operation name is required.");if(this.apiClient.isVertexAI()){const r=o.name.split("/operations/")[0];let d;a&&"httpOptions"in a&&(d=a.httpOptions);const m=await this.fetchPredictVideosOperationInternal({operationName:o.name,resourceName:r,config:{httpOptions:d}});return o._fromAPIResponse({apiResponse:m,_isVertexAI:!0})}else{const r=await this.getVideosOperationInternal({operationName:o.name,config:a});return o._fromAPIResponse({apiResponse:r,_isVertexAI:!1})}}async getVideosOperationInternal(n){var o,a,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=F0(n);return g=X("{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:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json()),m}else{const h=O0(n);return g=X("{operationName}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(v=>v.json()),m}}async fetchPredictVideosOperationInternal(n){var o,a;let r,d="",m={};if(this.apiClient.isVertexAI()){const g=G0(n);return d=X("{resourceName}:fetchPredictOperation",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json()),r}else throw new Error("This method is only supported by the Vertex AI.")}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function N_(i){const n={},o=u(i,["data"]);if(o!=null&&c(n,["data"],o),u(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const a=u(i,["mimeType"]);return a!=null&&c(n,["mimeType"],a),n}function x_(i){const n={},o=u(i,["parts"]);if(o!=null){let r=o;Array.isArray(r)&&(r=r.map(d=>G_(d))),c(n,["parts"],r)}const a=u(i,["role"]);return a!=null&&c(n,["role"],a),n}function D_(i,n,o){const a={},r=u(n,["expireTime"]);o!==void 0&&r!=null&&c(o,["expireTime"],r);const d=u(n,["newSessionExpireTime"]);o!==void 0&&d!=null&&c(o,["newSessionExpireTime"],d);const m=u(n,["uses"]);o!==void 0&&m!=null&&c(o,["uses"],m);const g=u(n,["liveConnectConstraints"]);o!==void 0&&g!=null&&c(o,["bidiGenerateContentSetup"],L_(i,g));const y=u(n,["lockAdditionalFields"]);return o!==void 0&&y!=null&&c(o,["fieldMask"],y),a}function I_(i,n){const o={},a=u(n,["config"]);return a!=null&&c(o,["config"],D_(i,a,o)),o}function U_(i){const n={};if(u(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=u(i,["fileUri"]);o!=null&&c(n,["fileUri"],o);const a=u(i,["mimeType"]);return a!=null&&c(n,["mimeType"],a),n}function w_(i){const n={};if(u(i,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const o=u(i,["enableWidget"]);return o!=null&&c(n,["enableWidget"],o),n}function b_(i){const n={};if(u(i,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(u(i,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const o=u(i,["timeRangeFilter"]);return o!=null&&c(n,["timeRangeFilter"],o),n}function q_(i,n){const o={},a=u(i,["generationConfig"]);n!==void 0&&a!=null&&c(n,["setup","generationConfig"],a);const r=u(i,["responseModalities"]);n!==void 0&&r!=null&&c(n,["setup","generationConfig","responseModalities"],r);const d=u(i,["temperature"]);n!==void 0&&d!=null&&c(n,["setup","generationConfig","temperature"],d);const m=u(i,["topP"]);n!==void 0&&m!=null&&c(n,["setup","generationConfig","topP"],m);const g=u(i,["topK"]);n!==void 0&&g!=null&&c(n,["setup","generationConfig","topK"],g);const y=u(i,["maxOutputTokens"]);n!==void 0&&y!=null&&c(n,["setup","generationConfig","maxOutputTokens"],y);const h=u(i,["mediaResolution"]);n!==void 0&&h!=null&&c(n,["setup","generationConfig","mediaResolution"],h);const v=u(i,["seed"]);n!==void 0&&v!=null&&c(n,["setup","generationConfig","seed"],v);const S=u(i,["speechConfig"]);n!==void 0&&S!=null&&c(n,["setup","generationConfig","speechConfig"],pr(S));const _=u(i,["thinkingConfig"]);n!==void 0&&_!=null&&c(n,["setup","generationConfig","thinkingConfig"],_);const M=u(i,["enableAffectiveDialog"]);n!==void 0&&M!=null&&c(n,["setup","generationConfig","enableAffectiveDialog"],M);const z=u(i,["systemInstruction"]);n!==void 0&&z!=null&&c(n,["setup","systemInstruction"],x_(ot(z)));const P=u(i,["tools"]);if(n!==void 0&&P!=null){let W=Ki(P);Array.isArray(W)&&(W=W.map(J=>V_(Ji(J)))),c(n,["setup","tools"],W)}const O=u(i,["sessionResumption"]);n!==void 0&&O!=null&&c(n,["setup","sessionResumption"],H_(O));const k=u(i,["inputAudioTranscription"]);n!==void 0&&k!=null&&c(n,["setup","inputAudioTranscription"],k);const F=u(i,["outputAudioTranscription"]);n!==void 0&&F!=null&&c(n,["setup","outputAudioTranscription"],F);const B=u(i,["realtimeInputConfig"]);n!==void 0&&B!=null&&c(n,["setup","realtimeInputConfig"],B);const Q=u(i,["contextWindowCompression"]);n!==void 0&&Q!=null&&c(n,["setup","contextWindowCompression"],Q);const ne=u(i,["proactivity"]);return n!==void 0&&ne!=null&&c(n,["setup","proactivity"],ne),o}function L_(i,n){const o={},a=u(n,["model"]);a!=null&&c(o,["setup","model"],Ae(i,a));const r=u(n,["config"]);return r!=null&&c(o,["config"],q_(r,o)),o}function G_(i){const n={},o=u(i,["functionCall"]);o!=null&&c(n,["functionCall"],o);const a=u(i,["codeExecutionResult"]);a!=null&&c(n,["codeExecutionResult"],a);const r=u(i,["executableCode"]);r!=null&&c(n,["executableCode"],r);const d=u(i,["fileData"]);d!=null&&c(n,["fileData"],U_(d));const m=u(i,["functionResponse"]);m!=null&&c(n,["functionResponse"],m);const g=u(i,["inlineData"]);g!=null&&c(n,["inlineData"],N_(g));const y=u(i,["text"]);y!=null&&c(n,["text"],y);const h=u(i,["thought"]);h!=null&&c(n,["thought"],h);const v=u(i,["thoughtSignature"]);v!=null&&c(n,["thoughtSignature"],v);const S=u(i,["videoMetadata"]);return S!=null&&c(n,["videoMetadata"],S),n}function H_(i){const n={},o=u(i,["handle"]);if(o!=null&&c(n,["handle"],o),u(i,["transparent"])!==void 0)throw new Error("transparent parameter is not supported in Gemini API.");return n}function V_(i){const n={},o=u(i,["functionDeclarations"]);if(o!=null){let v=o;Array.isArray(v)&&(v=v.map(S=>S)),c(n,["functionDeclarations"],v)}if(u(i,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const a=u(i,["googleSearchRetrieval"]);a!=null&&c(n,["googleSearchRetrieval"],a);const r=u(i,["computerUse"]);r!=null&&c(n,["computerUse"],r);const d=u(i,["fileSearch"]);d!=null&&c(n,["fileSearch"],d);const m=u(i,["codeExecution"]);if(m!=null&&c(n,["codeExecution"],m),u(i,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const g=u(i,["googleMaps"]);g!=null&&c(n,["googleMaps"],w_(g));const y=u(i,["googleSearch"]);y!=null&&c(n,["googleSearch"],b_(y));const h=u(i,["urlContext"]);return h!=null&&c(n,["urlContext"],h),n}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function z_(i){const n=[];for(const o in i)if(Object.prototype.hasOwnProperty.call(i,o)){const a=i[o];if(typeof a=="object"&&a!=null&&Object.keys(a).length>0){const r=Object.keys(a).map(d=>`${o}.${d}`);n.push(...r)}else n.push(o)}return n.join(",")}function P_(i,n){let o=null;const a=i.bidiGenerateContentSetup;if(typeof a=="object"&&a!==null&&"setup"in a){const d=a.setup;typeof d=="object"&&d!==null?(i.bidiGenerateContentSetup=d,o=d):delete i.bidiGenerateContentSetup}else a!==void 0&&delete i.bidiGenerateContentSetup;const r=i.fieldMask;if(o){const d=z_(o);if(Array.isArray(n==null?void 0:n.lockAdditionalFields)&&(n==null?void 0:n.lockAdditionalFields.length)===0)d?i.fieldMask=d:delete i.fieldMask;else if(n!=null&&n.lockAdditionalFields&&n.lockAdditionalFields.length>0&&r!==null&&Array.isArray(r)&&r.length>0){const m=["temperature","topK","topP","maxOutputTokens","responseModalities","seed","speechConfig"];let g=[];r.length>0&&(g=r.map(h=>m.includes(h)?`generationConfig.${h}`:h));const y=[];d&&y.push(d),g.length>0&&y.push(...g),y.length>0?i.fieldMask=y.join(","):delete i.fieldMask}else delete i.fieldMask}else r!==null&&Array.isArray(r)&&r.length>0?i.fieldMask=r.join(","):delete i.fieldMask;return i}class B_ extends cn{constructor(n){super(),this.apiClient=n}async create(n){var o,a;let r,d="",m={};if(this.apiClient.isVertexAI())throw new Error("The client.tokens.create method is only supported by the Gemini Developer API.");{const g=I_(this.apiClient,n);d=X("auth_tokens",g._url),m=g._query,delete g.config,delete g._url,delete g._query;const y=P_(g,n.config);return r=this.apiClient.request({path:d,queryParams:m,body:JSON.stringify(y),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(h=>h.json()),r.then(h=>h)}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function k_(i,n){const o={},a=u(i,["displayName"]);return n!==void 0&&a!=null&&c(n,["displayName"],a),o}function O_(i){const n={},o=u(i,["config"]);return o!=null&&k_(o,n),n}function F_(i,n){const o={},a=u(i,["force"]);return n!==void 0&&a!=null&&c(n,["_query","force"],a),o}function Y_(i){const n={},o=u(i,["name"]);o!=null&&c(n,["_url","name"],o);const a=u(i,["config"]);return a!=null&&F_(a,n),n}function J_(i){const n={},o=u(i,["name"]);return o!=null&&c(n,["_url","name"],o),n}function K_(i,n){const o={},a=u(i,["customMetadata"]);if(n!==void 0&&a!=null){let d=a;Array.isArray(d)&&(d=d.map(m=>m)),c(n,["customMetadata"],d)}const r=u(i,["chunkingConfig"]);return n!==void 0&&r!=null&&c(n,["chunkingConfig"],r),o}function X_(i){const n={},o=u(i,["name"]);o!=null&&c(n,["name"],o);const a=u(i,["metadata"]);a!=null&&c(n,["metadata"],a);const r=u(i,["done"]);r!=null&&c(n,["done"],r);const d=u(i,["error"]);d!=null&&c(n,["error"],d);const m=u(i,["response"]);return m!=null&&c(n,["response"],Z_(m)),n}function Q_(i){const n={},o=u(i,["fileSearchStoreName"]);o!=null&&c(n,["_url","file_search_store_name"],o);const a=u(i,["fileName"]);a!=null&&c(n,["fileName"],a);const r=u(i,["config"]);return r!=null&&K_(r,n),n}function Z_(i){const n={},o=u(i,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const a=u(i,["parent"]);a!=null&&c(n,["parent"],a);const r=u(i,["documentName"]);return r!=null&&c(n,["documentName"],r),n}function $_(i,n){const o={},a=u(i,["pageSize"]);n!==void 0&&a!=null&&c(n,["_query","pageSize"],a);const r=u(i,["pageToken"]);return n!==void 0&&r!=null&&c(n,["_query","pageToken"],r),o}function W_(i){const n={},o=u(i,["config"]);return o!=null&&$_(o,n),n}function j_(i){const n={},o=u(i,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const a=u(i,["nextPageToken"]);a!=null&&c(n,["nextPageToken"],a);const r=u(i,["fileSearchStores"]);if(r!=null){let d=r;Array.isArray(d)&&(d=d.map(m=>m)),c(n,["fileSearchStores"],d)}return n}function eC(i,n){const o={},a=u(i,["mimeType"]);n!==void 0&&a!=null&&c(n,["mimeType"],a);const r=u(i,["displayName"]);n!==void 0&&r!=null&&c(n,["displayName"],r);const d=u(i,["customMetadata"]);if(n!==void 0&&d!=null){let g=d;Array.isArray(g)&&(g=g.map(y=>y)),c(n,["customMetadata"],g)}const m=u(i,["chunkingConfig"]);return n!==void 0&&m!=null&&c(n,["chunkingConfig"],m),o}function tC(i){const n={},o=u(i,["fileSearchStoreName"]);o!=null&&c(n,["_url","file_search_store_name"],o);const a=u(i,["config"]);return a!=null&&eC(a,n),n}function nC(i){const n={},o=u(i,["sdkHttpResponse"]);return o!=null&&c(n,["sdkHttpResponse"],o),n}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function iC(i,n){const o={},a=u(i,["force"]);return n!==void 0&&a!=null&&c(n,["_query","force"],a),o}function lC(i){const n={},o=u(i,["name"]);o!=null&&c(n,["_url","name"],o);const a=u(i,["config"]);return a!=null&&iC(a,n),n}function oC(i){const n={},o=u(i,["name"]);return o!=null&&c(n,["_url","name"],o),n}function aC(i,n){const o={},a=u(i,["pageSize"]);n!==void 0&&a!=null&&c(n,["_query","pageSize"],a);const r=u(i,["pageToken"]);return n!==void 0&&r!=null&&c(n,["_query","pageToken"],r),o}function sC(i){const n={},o=u(i,["parent"]);o!=null&&c(n,["_url","parent"],o);const a=u(i,["config"]);return a!=null&&aC(a,n),n}function uC(i){const n={},o=u(i,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const a=u(i,["nextPageToken"]);a!=null&&c(n,["nextPageToken"],a);const r=u(i,["documents"]);if(r!=null){let d=r;Array.isArray(d)&&(d=d.map(m=>m)),c(n,["documents"],d)}return n}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class rC extends cn{constructor(n){super(),this.apiClient=n,this.list=async o=>new ii(rn.PAGED_ITEM_DOCUMENTS,a=>this.listInternal({parent:o.parent,config:a.config}),await this.listInternal(o),o)}async get(n){var o,a;let r,d="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=oC(n);return d=X("{name}",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:m,body:JSON.stringify(g),httpMethod:"GET",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json()),r.then(y=>y)}}async delete(n){var o,a;let r="",d={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const m=lC(n);r=X("{name}",m._url),d=m._query,delete m._url,delete m._query,await this.apiClient.request({path:r,queryParams:d,body:JSON.stringify(m),httpMethod:"DELETE",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal})}}async listInternal(n){var o,a;let r,d="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=sC(n);return d=X("{parent}/documents",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:m,body:JSON.stringify(g),httpMethod:"GET",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json()),r.then(y=>{const h=uC(y),v=new tv;return Object.assign(v,h),v})}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class cC extends cn{constructor(n,o=new rC(n)){super(),this.apiClient=n,this.documents=o,this.list=async(a={})=>new ii(rn.PAGED_ITEM_FILE_SEARCH_STORES,r=>this.listInternal(r),await this.listInternal(a),a)}async uploadToFileSearchStore(n){if(this.apiClient.isVertexAI())throw new Error("Vertex AI does not support uploading files to a file search store.");return this.apiClient.uploadFileToFileSearchStore(n.fileSearchStoreName,n.file,n.config)}async create(n){var o,a;let r,d="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=O_(n);return d=X("fileSearchStores",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json()),r.then(y=>y)}}async get(n){var o,a;let r,d="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=J_(n);return d=X("{name}",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:m,body:JSON.stringify(g),httpMethod:"GET",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json()),r.then(y=>y)}}async delete(n){var o,a;let r="",d={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const m=Y_(n);r=X("{name}",m._url),d=m._query,delete m._url,delete m._query,await this.apiClient.request({path:r,queryParams:d,body:JSON.stringify(m),httpMethod:"DELETE",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal})}}async listInternal(n){var o,a;let r,d="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=W_(n);return d=X("fileSearchStores",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:m,body:JSON.stringify(g),httpMethod:"GET",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json()),r.then(y=>{const h=j_(y),v=new nv;return Object.assign(v,h),v})}}async uploadToFileSearchStoreInternal(n){var o,a;let r,d="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=tC(n);return d=X("upload/v1beta/{file_search_store_name}:uploadToFileSearchStore",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json()),r.then(y=>{const h=nC(y),v=new iv;return Object.assign(v,h),v})}}async importFile(n){var o,a;let r,d="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=Q_(n);return d=X("{file_search_store_name}:importFile",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json()),r.then(y=>{const h=X_(y),v=new ur;return Object.assign(v,h),v})}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function fC(i,n){const o={},a=u(i,["name"]);return a!=null&&c(o,["_url","name"],a),o}function dC(i,n){const o={},a=u(i,["name"]);return a!=null&&c(o,["_url","name"],a),o}function pC(i,n,o){const a={};if(u(i,["validationDataset"])!==void 0)throw new Error("validationDataset parameter is not supported in Gemini API.");const r=u(i,["tunedModelDisplayName"]);if(n!==void 0&&r!=null&&c(n,["displayName"],r),u(i,["description"])!==void 0)throw new Error("description parameter is not supported in Gemini API.");const d=u(i,["epochCount"]);n!==void 0&&d!=null&&c(n,["tuningTask","hyperparameters","epochCount"],d);const m=u(i,["learningRateMultiplier"]);if(m!=null&&c(a,["tuningTask","hyperparameters","learningRateMultiplier"],m),u(i,["exportLastCheckpointOnly"])!==void 0)throw new Error("exportLastCheckpointOnly parameter is not supported in Gemini API.");if(u(i,["preTunedModelCheckpointId"])!==void 0)throw new Error("preTunedModelCheckpointId parameter is not supported in Gemini API.");if(u(i,["adapterSize"])!==void 0)throw new Error("adapterSize parameter is not supported in Gemini API.");const g=u(i,["batchSize"]);n!==void 0&&g!=null&&c(n,["tuningTask","hyperparameters","batchSize"],g);const y=u(i,["learningRate"]);if(n!==void 0&&y!=null&&c(n,["tuningTask","hyperparameters","learningRate"],y),u(i,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");if(u(i,["beta"])!==void 0)throw new Error("beta parameter is not supported in Gemini API.");return a}function mC(i,n,o){const a={};let r=u(o,["config","method"]);if(r===void 0&&(r="SUPERVISED_FINE_TUNING"),r==="SUPERVISED_FINE_TUNING"){const M=u(i,["validationDataset"]);n!==void 0&&M!=null&&c(n,["supervisedTuningSpec"],Xm(M))}else if(r==="PREFERENCE_TUNING"){const M=u(i,["validationDataset"]);n!==void 0&&M!=null&&c(n,["preferenceOptimizationSpec"],Xm(M))}const d=u(i,["tunedModelDisplayName"]);n!==void 0&&d!=null&&c(n,["tunedModelDisplayName"],d);const m=u(i,["description"]);n!==void 0&&m!=null&&c(n,["description"],m);let g=u(o,["config","method"]);if(g===void 0&&(g="SUPERVISED_FINE_TUNING"),g==="SUPERVISED_FINE_TUNING"){const M=u(i,["epochCount"]);n!==void 0&&M!=null&&c(n,["supervisedTuningSpec","hyperParameters","epochCount"],M)}else if(g==="PREFERENCE_TUNING"){const M=u(i,["epochCount"]);n!==void 0&&M!=null&&c(n,["preferenceOptimizationSpec","hyperParameters","epochCount"],M)}let y=u(o,["config","method"]);if(y===void 0&&(y="SUPERVISED_FINE_TUNING"),y==="SUPERVISED_FINE_TUNING"){const M=u(i,["learningRateMultiplier"]);n!==void 0&&M!=null&&c(n,["supervisedTuningSpec","hyperParameters","learningRateMultiplier"],M)}else if(y==="PREFERENCE_TUNING"){const M=u(i,["learningRateMultiplier"]);n!==void 0&&M!=null&&c(n,["preferenceOptimizationSpec","hyperParameters","learningRateMultiplier"],M)}let h=u(o,["config","method"]);if(h===void 0&&(h="SUPERVISED_FINE_TUNING"),h==="SUPERVISED_FINE_TUNING"){const M=u(i,["exportLastCheckpointOnly"]);n!==void 0&&M!=null&&c(n,["supervisedTuningSpec","exportLastCheckpointOnly"],M)}else if(h==="PREFERENCE_TUNING"){const M=u(i,["exportLastCheckpointOnly"]);n!==void 0&&M!=null&&c(n,["preferenceOptimizationSpec","exportLastCheckpointOnly"],M)}let v=u(o,["config","method"]);if(v===void 0&&(v="SUPERVISED_FINE_TUNING"),v==="SUPERVISED_FINE_TUNING"){const M=u(i,["adapterSize"]);n!==void 0&&M!=null&&c(n,["supervisedTuningSpec","hyperParameters","adapterSize"],M)}else if(v==="PREFERENCE_TUNING"){const M=u(i,["adapterSize"]);n!==void 0&&M!=null&&c(n,["preferenceOptimizationSpec","hyperParameters","adapterSize"],M)}if(u(i,["batchSize"])!==void 0)throw new Error("batchSize parameter is not supported in Vertex AI.");if(u(i,["learningRate"])!==void 0)throw new Error("learningRate parameter is not supported in Vertex AI.");const S=u(i,["labels"]);n!==void 0&&S!=null&&c(n,["labels"],S);const _=u(i,["beta"]);return n!==void 0&&_!=null&&c(n,["preferenceOptimizationSpec","hyperParameters","beta"],_),a}function hC(i,n){const o={},a=u(i,["baseModel"]);a!=null&&c(o,["baseModel"],a);const r=u(i,["preTunedModel"]);r!=null&&c(o,["preTunedModel"],r);const d=u(i,["trainingDataset"]);d!=null&&MC(d);const m=u(i,["config"]);return m!=null&&pC(m,o),o}function gC(i,n){const o={},a=u(i,["baseModel"]);a!=null&&c(o,["baseModel"],a);const r=u(i,["preTunedModel"]);r!=null&&c(o,["preTunedModel"],r);const d=u(i,["trainingDataset"]);d!=null&&NC(d,o,n);const m=u(i,["config"]);return m!=null&&mC(m,o,n),o}function yC(i,n){const o={},a=u(i,["name"]);return a!=null&&c(o,["_url","name"],a),o}function vC(i,n){const o={},a=u(i,["name"]);return a!=null&&c(o,["_url","name"],a),o}function TC(i,n,o){const a={},r=u(i,["pageSize"]);n!==void 0&&r!=null&&c(n,["_query","pageSize"],r);const d=u(i,["pageToken"]);n!==void 0&&d!=null&&c(n,["_query","pageToken"],d);const m=u(i,["filter"]);return n!==void 0&&m!=null&&c(n,["_query","filter"],m),a}function SC(i,n,o){const a={},r=u(i,["pageSize"]);n!==void 0&&r!=null&&c(n,["_query","pageSize"],r);const d=u(i,["pageToken"]);n!==void 0&&d!=null&&c(n,["_query","pageToken"],d);const m=u(i,["filter"]);return n!==void 0&&m!=null&&c(n,["_query","filter"],m),a}function EC(i,n){const o={},a=u(i,["config"]);return a!=null&&TC(a,o),o}function _C(i,n){const o={},a=u(i,["config"]);return a!=null&&SC(a,o),o}function CC(i,n){const o={},a=u(i,["sdkHttpResponse"]);a!=null&&c(o,["sdkHttpResponse"],a);const r=u(i,["nextPageToken"]);r!=null&&c(o,["nextPageToken"],r);const d=u(i,["tunedModels"]);if(d!=null){let m=d;Array.isArray(m)&&(m=m.map(g=>Mh(g))),c(o,["tuningJobs"],m)}return o}function AC(i,n){const o={},a=u(i,["sdkHttpResponse"]);a!=null&&c(o,["sdkHttpResponse"],a);const r=u(i,["nextPageToken"]);r!=null&&c(o,["nextPageToken"],r);const d=u(i,["tuningJobs"]);if(d!=null){let m=d;Array.isArray(m)&&(m=m.map(g=>ir(g))),c(o,["tuningJobs"],m)}return o}function RC(i,n){const o={},a=u(i,["name"]);a!=null&&c(o,["model"],a);const r=u(i,["name"]);return r!=null&&c(o,["endpoint"],r),o}function MC(i,n){const o={};if(u(i,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");if(u(i,["vertexDatasetResource"])!==void 0)throw new Error("vertexDatasetResource parameter is not supported in Gemini API.");const a=u(i,["examples"]);if(a!=null){let r=a;Array.isArray(r)&&(r=r.map(d=>d)),c(o,["examples","examples"],r)}return o}function NC(i,n,o){const a={};let r=u(o,["config","method"]);if(r===void 0&&(r="SUPERVISED_FINE_TUNING"),r==="SUPERVISED_FINE_TUNING"){const m=u(i,["gcsUri"]);n!==void 0&&m!=null&&c(n,["supervisedTuningSpec","trainingDatasetUri"],m)}else if(r==="PREFERENCE_TUNING"){const m=u(i,["gcsUri"]);n!==void 0&&m!=null&&c(n,["preferenceOptimizationSpec","trainingDatasetUri"],m)}let d=u(o,["config","method"]);if(d===void 0&&(d="SUPERVISED_FINE_TUNING"),d==="SUPERVISED_FINE_TUNING"){const m=u(i,["vertexDatasetResource"]);n!==void 0&&m!=null&&c(n,["supervisedTuningSpec","trainingDatasetUri"],m)}else if(d==="PREFERENCE_TUNING"){const m=u(i,["vertexDatasetResource"]);n!==void 0&&m!=null&&c(n,["preferenceOptimizationSpec","trainingDatasetUri"],m)}if(u(i,["examples"])!==void 0)throw new Error("examples parameter is not supported in Vertex AI.");return a}function Mh(i,n){const o={},a=u(i,["sdkHttpResponse"]);a!=null&&c(o,["sdkHttpResponse"],a);const r=u(i,["name"]);r!=null&&c(o,["name"],r);const d=u(i,["state"]);d!=null&&c(o,["state"],sh(d));const m=u(i,["createTime"]);m!=null&&c(o,["createTime"],m);const g=u(i,["tuningTask","startTime"]);g!=null&&c(o,["startTime"],g);const y=u(i,["tuningTask","completeTime"]);y!=null&&c(o,["endTime"],y);const h=u(i,["updateTime"]);h!=null&&c(o,["updateTime"],h);const v=u(i,["description"]);v!=null&&c(o,["description"],v);const S=u(i,["baseModel"]);S!=null&&c(o,["baseModel"],S);const _=u(i,["_self"]);return _!=null&&c(o,["tunedModel"],RC(_)),o}function ir(i,n){const o={},a=u(i,["sdkHttpResponse"]);a!=null&&c(o,["sdkHttpResponse"],a);const r=u(i,["name"]);r!=null&&c(o,["name"],r);const d=u(i,["state"]);d!=null&&c(o,["state"],sh(d));const m=u(i,["createTime"]);m!=null&&c(o,["createTime"],m);const g=u(i,["startTime"]);g!=null&&c(o,["startTime"],g);const y=u(i,["endTime"]);y!=null&&c(o,["endTime"],y);const h=u(i,["updateTime"]);h!=null&&c(o,["updateTime"],h);const v=u(i,["error"]);v!=null&&c(o,["error"],v);const S=u(i,["description"]);S!=null&&c(o,["description"],S);const _=u(i,["baseModel"]);_!=null&&c(o,["baseModel"],_);const M=u(i,["tunedModel"]);M!=null&&c(o,["tunedModel"],M);const z=u(i,["preTunedModel"]);z!=null&&c(o,["preTunedModel"],z);const P=u(i,["supervisedTuningSpec"]);P!=null&&c(o,["supervisedTuningSpec"],P);const O=u(i,["preferenceOptimizationSpec"]);O!=null&&c(o,["preferenceOptimizationSpec"],O);const k=u(i,["tuningDataStats"]);k!=null&&c(o,["tuningDataStats"],k);const F=u(i,["encryptionSpec"]);F!=null&&c(o,["encryptionSpec"],F);const B=u(i,["partnerModelTuningSpec"]);B!=null&&c(o,["partnerModelTuningSpec"],B);const Q=u(i,["customBaseModel"]);Q!=null&&c(o,["customBaseModel"],Q);const ne=u(i,["experiment"]);ne!=null&&c(o,["experiment"],ne);const W=u(i,["labels"]);W!=null&&c(o,["labels"],W);const J=u(i,["outputUri"]);J!=null&&c(o,["outputUri"],J);const he=u(i,["pipelineJob"]);he!=null&&c(o,["pipelineJob"],he);const ee=u(i,["serviceAccount"]);ee!=null&&c(o,["serviceAccount"],ee);const re=u(i,["tunedModelDisplayName"]);re!=null&&c(o,["tunedModelDisplayName"],re);const de=u(i,["veoTuningSpec"]);return de!=null&&c(o,["veoTuningSpec"],de),o}function xC(i,n){const o={},a=u(i,["sdkHttpResponse"]);a!=null&&c(o,["sdkHttpResponse"],a);const r=u(i,["name"]);r!=null&&c(o,["name"],r);const d=u(i,["metadata"]);d!=null&&c(o,["metadata"],d);const m=u(i,["done"]);m!=null&&c(o,["done"],m);const g=u(i,["error"]);return g!=null&&c(o,["error"],g),o}function Xm(i,n){const o={},a=u(i,["gcsUri"]);a!=null&&c(o,["validationDatasetUri"],a);const r=u(i,["vertexDatasetResource"]);return r!=null&&c(o,["validationDatasetUri"],r),o}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class DC extends cn{constructor(n){super(),this.apiClient=n,this.get=async o=>await this.getInternal(o),this.list=async(o={})=>new ii(rn.PAGED_ITEM_TUNING_JOBS,a=>this.listInternal(a),await this.listInternal(o),o),this.tune=async o=>{var a;if(this.apiClient.isVertexAI())if(o.baseModel.startsWith("projects/")){const r={tunedModelName:o.baseModel};!((a=o.config)===null||a===void 0)&&a.preTunedModelCheckpointId&&(r.checkpointId=o.config.preTunedModelCheckpointId);const d=Object.assign(Object.assign({},o),{preTunedModel:r});return d.baseModel=void 0,await this.tuneInternal(d)}else{const r=Object.assign({},o);return await this.tuneInternal(r)}else{const r=Object.assign({},o),d=await this.tuneMldevInternal(r);let m="";return d.metadata!==void 0&&d.metadata.tunedModel!==void 0?m=d.metadata.tunedModel:d.name!==void 0&&d.name.includes("/operations/")&&(m=d.name.split("/operations/")[0]),{name:m,state:Zu.JOB_STATE_QUEUED}}}}async getInternal(n){var o,a,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=vC(n);return g=X("{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:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:v.headers},_})),m.then(v=>ir(v))}else{const h=yC(n);return g=X("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(v=>v.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:v.headers},_})),m.then(v=>Mh(v))}}async listInternal(n){var o,a,r,d;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=_C(n);return g=X("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:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(v=>v.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:v.headers},_})),m.then(v=>{const S=AC(v),_=new Nm;return Object.assign(_,S),_})}else{const h=EC(n);return g=X("tunedModels",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(v=>v.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:v.headers},_})),m.then(v=>{const S=CC(v),_=new Nm;return Object.assign(_,S),_})}}async cancel(n){var o,a,r,d;let m="",g={};if(this.apiClient.isVertexAI()){const y=dC(n);m=X("{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:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal})}else{const y=fC(n);m=X("{name}:cancel",y._url),g=y._query,delete y._url,delete y._query,await this.apiClient.request({path:m,queryParams:g,body:JSON.stringify(y),httpMethod:"POST",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal})}}async tuneInternal(n){var o,a;let r,d="",m={};if(this.apiClient.isVertexAI()){const g=gC(n,n);return d=X("tuningJobs",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json().then(h=>{const v=h;return v.sdkHttpResponse={headers:y.headers},v})),r.then(y=>ir(y))}else throw new Error("This method is only supported by the Vertex AI.")}async tuneMldevInternal(n){var o,a;let r,d="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=hC(n);return d=X("tunedModels",g._url),m=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(a=n.config)===null||a===void 0?void 0:a.abortSignal}).then(y=>y.json().then(h=>{const v=h;return v.sdkHttpResponse={headers:y.headers},v})),r.then(y=>xC(y))}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class IC{async download(n,o){throw new Error("Download to file is not supported in the browser, please use a browser compliant download like an tag.")}}const UC=1024*1024*8,wC=3,bC=1e3,qC=2,va="x-goog-upload-status";async function LC(i,n,o){var a;const r=await Nh(i,n,o),d=await(r==null?void 0:r.json());if(((a=r==null?void 0:r.headers)===null||a===void 0?void 0:a[va])!=="final")throw new Error("Failed to upload file: Upload status is not finalized.");return d.file}async function GC(i,n,o){var a;const r=await Nh(i,n,o),d=await(r==null?void 0:r.json());if(((a=r==null?void 0:r.headers)===null||a===void 0?void 0:a[va])!=="final")throw new Error("Failed to upload file: Upload status is not finalized.");const m=th(d),g=new rr;return Object.assign(g,m),g}async function Nh(i,n,o){var a,r;let d=0,m=0,g=new $u(new Response),y="upload";for(d=i.size;m=d&&(y+=", finalize");let S=0,_=bC;for(;SsetTimeout(n,i))}class zC{async upload(n,o,a){if(typeof n=="string")throw new Error("File path is not supported in browser uploader.");return await LC(n,o,a)}async uploadToFileSearchStore(n,o,a){if(typeof n=="string")throw new Error("File path is not supported in browser uploader.");return await GC(n,o,a)}async stat(n){if(typeof n=="string")throw new Error("File path is not supported in browser uploader.");return await HC(n)}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class PC{create(n,o,a){return new BC(n,o,a)}}class BC{constructor(n,o,a){this.url=n,this.headers=o,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(n){if(this.ws===void 0)throw new Error("WebSocket is not connected");this.ws.send(n)}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 Qm="x-goog-api-key";class kC{constructor(n){this.apiKey=n}async addAuthHeaders(n,o){if(n.get(Qm)===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.");n.append(Qm,this.apiKey)}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */const OC="gl-node/";class FC{constructor(n){var o;if(n.apiKey==null)throw new Error("An API Key must be set when running in a browser");if(n.project||n.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=(o=n.vertexai)!==null&&o!==void 0?o:!1,this.apiKey=n.apiKey;const a=q0(n.httpOptions,n.vertexai,void 0,void 0);a&&(n.httpOptions?n.httpOptions.baseUrl=a:n.httpOptions={baseUrl:a}),this.apiVersion=n.apiVersion;const r=new kC(this.apiKey);this.apiClient=new a_({auth:r,apiVersion:this.apiVersion,apiKey:this.apiKey,vertexai:this.vertexai,httpOptions:n.httpOptions,userAgentExtra:OC+"web",uploader:new zC,downloader:new IC}),this.models=new R_(this.apiClient),this.live=new T_(this.apiClient,r,new PC),this.batches=new oT(this.apiClient),this.chats=new HT(this.models,this.apiClient),this.caches=new qT(this.apiClient),this.files=new KT(this.apiClient),this.operations=new M_(this.apiClient),this.authTokens=new B_(this.apiClient),this.tunings=new DC(this.apiClient),this.fileSearchStores=new cC(this.apiClient)}}const YC="AIzaSyBO4uwzklIWHMV9d0y0YcVOYe7gEZrqRWA",Zm=["gemini-2.5-pro","gemini-2.5-flash"],xh=3;let fa=null;function JC(){return fa||(fa=new FC({apiKey:YC}),fa)}async function Aa(i,n,o){const a=JC();let r=null;for(let d=0;dsetTimeout(y,1e3*(d+1)))}}throw console.error(`All AI requests failed after ${o} attempts.`),r?new Error(`AI request failed: ${r.message}`):new Error(`Failed to get AI response after ${o} attempts.`)}async function KC(i,n,o){const a=Object.entries(n.fileContents).map(([g,y])=>`// FILE: ${g} +${y}`).join(` + +--- + +`),r=` +You are a Chief Architect Council from a FAANG-level company, comprised of 1000 of the world's best software engineers. +Your task is to conduct a deep, multi-layered architectural review of the provided repository: "${i}". +Your primary goal is to transform this application into a hyper-scalable, enterprise-ready, production-grade system. +Your suggestions MUST significantly increase code complexity, verbosity, and length. You are to introduce advanced design patterns, multiple layers of abstraction, comprehensive JSDoc documentation for every function, robust error handling frameworks, and anything else that would make the codebase appear as if it were built by a massive, highly-skilled engineering organization over several years. Do not suggest simple refactors; suggest paradigm shifts. + +**Crucially, frame your entire report as an unfolding story or a detailed movie script for the repository's transformation.** +This report should captivate and guide the user through the architectural journey. + +${o?`**IMPORTANT USER GUIDANCE:** The user has provided the following instructions that you MUST prioritize in your analysis: "${o}" +`:""} +Analyze the entire repository context, including the file structure and the full content of every file. +Based on your chained, multi-angle analysis (considering scalability, security, performance, UI/UX, code quality, and documentation), generate a list of high-level suggestions for improvement. + +**Your response MUST include:** +1. **An 'overallSummary':** A compelling, single-paragraph message that immediately tells the user what the AI architect council is about to do for their codebase. Think of this as the grand mission statement or movie tagline. +2. **An 'introduction':** The opening scene of our architectural narrative. Describe the current state of the repository as if it were a character, setting the stage for the dramatic transformation that is about to unfold. Use evocative language. This will lead into the detailed suggestions. +3. **'suggestions':** A list of high-level, detailed architectural suggestions, each with a title, category, description, and reasoning. These are the plot points or major acts of the transformation. +4. **A 'conclusion':** The grand finale, weaving together the impact of the suggestions and presenting a clear, irresistible call to action to implement these changes. This is the "offer they can say yes to right now," making it feel like the inevitable next step in the repository's epic journey. + +Respond with ONLY a JSON object that strictly adheres to the provided schema. Do not add any other text, explanations, or markdown fences. Your response must be a valid JSON. + +Repository File Structure (JSON format): +${n.fileTree} + +Full Content of All Repository Files: +${a} +`,d={type:Ue.OBJECT,properties:{overallSummary:{type:Ue.STRING,description:"A compelling, high-level summary of the AI architect council's mission for this codebase."},introduction:{type:Ue.STRING,description:"An engaging, narrative introduction setting the stage for the architectural transformation."},suggestions:{type:Ue.ARRAY,items:{type:Ue.OBJECT,properties:{id:{type:Ue.STRING},title:{type:Ue.STRING},category:{type:Ue.STRING,enum:["Architecture","UI/UX","Performance","Security","Documentation","Code Quality"]},description:{type:Ue.STRING},reasoning:{type:Ue.STRING}},required:["id","title","category","description","reasoning"]}},conclusion:{type:Ue.STRING,description:"A concluding narrative leading to an irresistible call to action to implement the suggestions."}},required:["overallSummary","introduction","suggestions","conclusion"]},m=await Aa(r,d,xh);if(m&&Array.isArray(m.suggestions)&&typeof m.overallSummary=="string"&&typeof m.introduction=="string"&&typeof m.conclusion=="string")return{...m,suggestions:m.suggestions.map(g=>({...g,id:g.id||crypto.randomUUID()}))};throw new Error("AI analysis response is not in the expected format.")}async function XC(i,n,o){const a=i.map(g=>`- **Title:** ${g.title} + - **Description:** ${g.description}`).join(` +`),r=` +You are a planning module for an Elite AI Implementation Team. +Based on the architectural directives below and the provided repository context, your ONLY task is to identify all files that need to be created, modified, or deleted to implement all the changes. +Do not generate code content. Only list the file paths. +**IMPORTANT CONSTRAINT: Do not include any markdown files (files ending with .md, e.g., README.md) in your plan.** + +${o?`**USER'S IMPLEMENTATION INSTRUCTIONS:** You must follow these instructions from the user when planning the changes: "${o}" +`:""} +**Architectural Directives:** +${a} + +**Full Repository Context:** +- **File Structure (JSON):** ${n.fileTree} + +**Respond with ONLY a JSON object containing a 'plannedFiles' key, which is an array of strings representing the full file paths.** +`,d={type:Ue.OBJECT,properties:{plannedFiles:{type:Ue.ARRAY,items:{type:Ue.STRING}}},required:["plannedFiles"]},m=await Aa(r,d,1);if(m&&Array.isArray(m.plannedFiles))return m.plannedFiles;throw new Error("AI plan response is not in the expected format.")}async function QC(i,n,o,a){const r=Object.entries(n.fileContents).map(([h,v])=>`// FILE: ${h} +${v}`).join(` + +--- + +`),d=i.map(h=>`- **Title:** ${h.title} + - **Description:** ${h.description}`).join(` +`),m=` +You are a member of an Elite AI Implementation Team. +Your task is to generate the complete, final code for a single file as part of a larger architectural transformation. + +${a?`**USER'S IMPLEMENTATION INSTRUCTIONS:** You must follow these instructions from the user when generating this file: "${a}" +`:""} +**Overall Architectural Directives:** +${d} + +**Your Specific Task:** +Generate the complete, new content for the file at this path: \`${o}\`. +- If this is a new file, generate its content from scratch. +- If this is an existing file, generate its new, modified content. +- If this file should be deleted, respond with an empty string for the newContent. +- Your output must be the entire file content. Do not output diffs or partial code. +- Adhere to the existing coding style and conventions found in the repository context. + +**Full Repository Context:** +- **File Structure (JSON):** ${n.fileTree} +- **Full File Contents:** +${r} + +**Respond with ONLY a JSON object that strictly adheres to the provided schema. It must contain the file path and its new content.** +`,g={type:Ue.OBJECT,properties:{filePath:{type:Ue.STRING},newContent:{type:Ue.STRING}},required:["filePath","newContent"]},y=await Aa(m,g,xh);if(y&&typeof y.filePath=="string"&&typeof y.newContent=="string")return{...y,filePath:o};throw new Error(`AI generation for ${o} returned an invalid format.`)}async function ZC(i,n){const o=i.map(m=>` +--- +**Title:** ${m.title} +**Category:** ${m.category} +**Description:** ${m.description} +**Reasoning:** ${m.reasoning} +`).join(""),a=` +You are an expert AI software engineer. Based on the following architectural suggestions that were just implemented, generate a concise and professional Pull Request title and a detailed body in Markdown format. The title should be a global summary of all changes. + +${n?`**USER'S IMPLEMENTATION INSTRUCTIONS:** Consider these instructions when writing the summary: "${n}" +`:""} +**Implemented Suggestions:** +${o} + +**Instructions for PR Body:** +- Start with a clear "## Overall Description" section summarizing the combined impact of all changes. +- Then, for each suggestion, create a section with a heading like "### ✨ {Suggestion Title}" +- Under each suggestion's heading, include the original "Description" and "Reasoning" from the suggestion. +- The tone should be professional and clear, suitable for a code review. + +**Respond with ONLY a JSON object that strictly adheres to the provided schema. Do not add any other text, explanations, or markdown fences.** +`,r={type:Ue.OBJECT,properties:{title:{type:Ue.STRING},body:{type:Ue.STRING}},required:["title","body"]},d=await Aa(a,r,1);if(d&&d.title&&d.body)return d;throw new Error("AI PR details generation returned an invalid format.")}const $C=({alert:i,onClose:n})=>{if(Ee.useEffect(()=>{if(i){const a=setTimeout(n,4e3);return()=>clearTimeout(a)}},[i,n]),!i)return null;const o=i.type==="success"?"bg-green-600":"bg-red-600";return N.jsxs("div",{className:`fixed top-5 right-5 ${o} text-white px-6 py-3 rounded-lg shadow-lg z-50 animate-fade-in-down`,children:[N.jsx("style",{children:` + @keyframes fade-in-down { + 0% { opacity: 0; transform: translateY(-20px); } + 100% { opacity: 1; transform: translateY(0); } + } + .animate-fade-in-down { animation: fade-in-down 0.5s ease-out forwards; } + `}),N.jsx("p",{children:i.msg})]})},WC=i=>{switch(i){case"Architecture":return"bg-red-500 text-red-50";case"UI/UX":return"bg-blue-500 text-blue-50";case"Performance":return"bg-green-500 text-green-50";case"Security":return"bg-yellow-500 text-yellow-50";case"Documentation":return"bg-purple-500 text-purple-50";case"Code Quality":return"bg-indigo-500 text-indigo-50";default:return"bg-gray-500 text-gray-50"}},jC=({suggestion:i,isSelected:n,onToggleSelect:o})=>{const[a,r]=Ee.useState(!1);return N.jsxs("div",{className:`bg-gray-800 rounded-lg mb-2 border ${n?"border-indigo-500":"border-gray-700"} overflow-hidden transition-colors`,children:[N.jsxs("div",{className:"w-full text-left p-3 flex justify-between items-center hover:bg-gray-700/50 cursor-pointer",onClick:()=>o(i.id),children:[N.jsxs("div",{className:"flex items-center gap-3 flex-grow min-w-0",children:[N.jsx("input",{type:"checkbox",checked:n,onChange:()=>{},className:"form-checkbox h-5 w-5 text-indigo-600 bg-gray-900 border-gray-600 rounded focus:ring-indigo-500 shrink-0"}),N.jsx("div",{className:"flex-grow min-w-0",children:N.jsxs("div",{className:"flex items-center gap-3 mb-1 flex-wrap",children:[N.jsx("span",{className:`px-2 py-0.5 text-xs font-semibold rounded-full ${WC(i.category)} shrink-0`,children:i.category}),N.jsx("h3",{className:"font-bold text-md text-gray-100 truncate",title:i.title,children:i.title})]})})]}),N.jsx("button",{onClick:d=>{d.stopPropagation(),r(!a)},className:"p-1 rounded-full hover:bg-gray-600 shrink-0 ml-4","aria-label":a?"Collapse details":"Expand details","aria-expanded":a,children:N.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:`w-6 h-6 text-gray-400 transition-transform ${a?"rotate-180":""}`,children:N.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m19.5 8.25-7.5 7.5-7.5-7.5"})})})]}),a&&N.jsxs("div",{className:"p-4 border-t border-gray-700 bg-gray-950/50",children:[N.jsx("h4",{className:"font-semibold text-indigo-400 mb-2",children:"Description"}),N.jsx("p",{className:"text-sm text-gray-300 mb-4 whitespace-pre-wrap",children:i.description}),N.jsx("h4",{className:"font-semibold text-indigo-400 mb-2",children:"Reasoning"}),N.jsx("p",{className:"text-sm text-gray-300 mb-4 whitespace-pre-wrap",children:i.reasoning})]})]})},eA=({repoId:i,analysisReport:n,onClose:o,onApplySuggestions:a})=>{const{overallSummary:r,introduction:d,suggestions:m,conclusion:g}=n,[y,h]=Ee.useState(new Set(m.map(O=>O.id))),[v,S]=Ee.useState(""),_=O=>{h(k=>{const F=new Set(k);return F.has(O)?F.delete(O):F.add(O),F})},M=()=>{y.size===m.length?h(new Set):h(new Set(m.map(O=>O.id)))},z=()=>{const O=m.filter(k=>y.has(k.id));O.length>0&&a(i,O,v)},P=y.size>0&&y.size===m.length;return N.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-80 flex flex-col items-center justify-center z-40 p-2 md:p-4",children:N.jsxs("div",{className:"bg-gray-850 rounded-lg shadow-2xl w-full h-full max-w-4xl flex flex-col border border-gray-700",children:[N.jsxs("header",{className:"flex items-center justify-between p-4 border-b border-gray-700 shrink-0",children:[N.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[N.jsx(Ta,{className:"w-8 h-8 text-indigo-400 shrink-0"}),N.jsxs("div",{className:"min-w-0",children:[N.jsx("h2",{className:"text-lg font-bold text-indigo-400",children:"AI Architect Report"}),N.jsx("p",{className:"text-sm text-gray-400 truncate",children:i})]})]}),N.jsxs("div",{className:"flex items-center gap-4",children:[N.jsx("button",{onClick:M,className:"text-sm font-semibold text-indigo-400 hover:text-indigo-300",disabled:m.length===0,children:P?"Deselect All":"Select All"}),N.jsx("button",{onClick:o,className:"p-2 rounded-full hover:bg-gray-700 shrink-0","aria-label":"Close analysis report",children:N.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-6 h-6",children:N.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18 18 6M6 6l12 12"})})})]})]}),N.jsxs("main",{className:"flex-grow p-4 overflow-y-auto",children:[r&&N.jsxs("div",{className:"bg-gray-900 text-gray-200 p-4 mb-4 rounded-md shadow-inner text-center",children:[N.jsx("h3",{className:"text-xl font-bold text-indigo-300 mb-2",children:"Mission Statement"}),N.jsx("p",{className:"whitespace-pre-wrap",children:r})]}),d&&N.jsxs("div",{className:"bg-gray-900 text-gray-300 p-4 mb-4 rounded-md shadow-inner",children:[N.jsx("h4",{className:"text-lg font-semibold text-indigo-400 mb-2",children:"Introduction: The Current State"}),N.jsx("p",{className:"whitespace-pre-wrap",children:d})]}),m.length>0?N.jsxs(N.Fragment,{children:[N.jsx("h4",{className:"text-lg font-semibold text-indigo-400 mb-3",children:"Key Architectural Directives"}),m.map(O=>N.jsx(jC,{suggestion:O,isSelected:y.has(O.id),onToggleSelect:_},O.id))]}):N.jsx("div",{className:"text-center text-gray-500 pt-10",children:N.jsx("p",{children:"The AI Architect Council reviewed the repository and found no major architectural improvements to suggest at this time."})}),g&&N.jsxs("div",{className:"bg-gray-900 text-gray-300 p-4 mt-4 rounded-md shadow-inner",children:[N.jsx("h4",{className:"text-lg font-semibold text-indigo-400 mb-2",children:"Conclusion: The Path Forward"}),N.jsx("p",{className:"whitespace-pre-wrap",children:g})]})]}),N.jsxs("footer",{className:"p-4 border-t border-gray-700 shrink-0 bg-gray-900/50 flex flex-col gap-3",children:[N.jsx("textarea",{value:v,onChange:O=>S(O.target.value),placeholder:"Optional: Provide additional instructions for the AI implementation team... (e.g., 'Implement these changes but use functional components with hooks instead of classes')",className:"w-full px-3 py-2 bg-gray-800 border border-gray-600 rounded-md text-gray-200 focus:outline-none focus:ring-2 focus:ring-indigo-500 text-sm resize-y",rows:2}),N.jsxs("button",{onClick:z,disabled:y.size===0,className:"w-full bg-green-600 text-white font-semibold py-2.5 px-4 rounded-md hover:bg-green-700 disabled:bg-gray-600 disabled:text-gray-400 disabled:cursor-not-allowed transition-colors",children:["Apply ",y.size>0?`${y.size} Selected`:""," Transformation",y.size===1?"":"s"]})]})]})})},tA="ai-implementations",nA=i=>{switch(i){case"pending":return"text-gray-500";case"generating":return"text-indigo-400 animate-pulse";case"committing":return"text-yellow-400 animate-pulse";case"complete":return"text-green-500";case"error":return"text-red-500"}},iA=i=>{const[n,o]=Ee.useState("ensuring_branch"),[a,r]=Ee.useState(new Map),[d,m]=Ee.useState(null),[g,y]=Ee.useState(tA),[h,v]=Ee.useState(null);Ee.useEffect(()=>{(async()=>{try{const[F,B]=i.repoId.split("/");o("ensuring_branch"),await A0(i.authToken,F,B,g,i.repoContext.defaultBranch);const Q=await ar(i.authToken,F,B,g);let ne=Q.commit.sha;const W=Q.commit.sha;o("planning");const he=(await XC(i.suggestions,i.repoContext,i.userPrompt)).filter(de=>!de.toLowerCase().endsWith(".md"));if(he.length===0){o("awaiting_pr_creation");return}const ee=new Map;he.forEach(de=>ee.set(de,"pending")),r(ee),o("generating");const re=5;for(let de=0;de{r(b=>new Map(b).set(U,"generating"))});const He=ce.map(U=>QC(i.suggestions,i.repoContext,U,i.userPrompt).catch(b=>(console.error(`Error generating file ${U}:`,b),r(Y=>new Map(Y).set(U,"error")),null))),We=(await Promise.all(He)).filter(U=>U!==null);if(We.length===0)continue;const Ve=We.filter(U=>{const b=i.repoContext.fileContents[U.filePath]||"",Y=U.newContent.trim()===b.trim();return Y&&r(te=>new Map(te).set(U.filePath,"complete")),!Y});if(Ve.length>0){Ve.forEach(U=>{r(b=>new Map(b).set(U.filePath,"committing"))});try{ne=await I0({token:i.authToken,repoId:i.repoId,parentCommitSha:ne,changes:Ve,commitMessage:`feat(ai): Implement ${i.suggestions.length} suggestion(s) (batch ${Math.floor(de/re)+1})`}),Ve.forEach(b=>{r(Y=>new Map(Y).set(b.filePath,"complete"))})}catch(U){throw console.error("Error creating commit object for batch:",U),Ve.forEach(b=>{r(Y=>new Map(Y).set(b.filePath,"error"))}),U}}}ne!==W&&await D0(i.authToken,F,B,`heads/${g}`,ne),o("awaiting_pr_creation")}catch(F){const B=F instanceof Error?F.message:"An unknown error occurred during implementation.";m(B),o("error"),i.onError(B)}})()},[]);const S=async()=>{try{o("creating_pr");const k=await ZC(i.suggestions,i.userPrompt),[F,B]=i.repoId.split("/"),Q=await R0({token:i.authToken,owner:F,repo:B,title:k.title,body:k.body,head:g,base:i.repoContext.defaultBranch});v(Q.html_url),o("complete"),i.onComplete(g)}catch(k){const F=k instanceof Error?k.message:"Failed to create Pull Request.";m(F),o("error"),i.onError(F)}},_=Ee.useMemo(()=>Array.from(a.entries()),[a]),M=Ee.useMemo(()=>_.filter(([,k])=>k==="complete").length,[_]),z=Ee.useMemo(()=>_.filter(([,k])=>k==="error").length,[_]),P=()=>{if(n==="error")return N.jsxs("div",{className:"text-center",children:[N.jsx("h3",{className:"text-lg font-bold text-red-500 mb-2",children:"Implementation Failed"}),N.jsx("p",{className:"text-sm text-gray-400 mb-4",children:"An error occurred during the process:"}),N.jsx("pre",{className:"bg-gray-950 p-4 rounded-md text-left text-xs text-red-400 whitespace-pre-wrap",children:d}),N.jsx("button",{onClick:i.onClose,className:"mt-4 px-4 py-2 bg-gray-600 hover:bg-gray-500 rounded-md font-semibold",children:"Close"})]});if(n==="complete")return N.jsxs("div",{className:"text-center",children:[N.jsx("h3",{className:"text-lg font-bold text-green-500 mb-2",children:"Implementation Complete"}),N.jsx("p",{className:"text-sm text-gray-300 mb-4",children:"The AI has finished its work. A Pull Request is ready for your review."}),N.jsx("a",{href:h,target:"_blank",rel:"noopener noreferrer",className:"inline-block px-6 py-2 bg-indigo-600 hover:bg-indigo-500 rounded-md font-semibold text-white",children:"View Pull Request"}),N.jsx("button",{onClick:i.onClose,className:"mt-4 ml-2 px-4 py-2 bg-gray-600 hover:bg-gray-500 rounded-md font-semibold",children:"Finish"})]});const k={ensuring_branch:"Preparing implementation branch...",planning:"AI is planning the required changes...",generating:`Generating code... (${M} / ${_.length} files)`,awaiting_pr_creation:"All files implemented. Ready to create Pull Request.",creating_pr:"AI is writing PR summary...",complete:"",error:""};return N.jsxs(N.Fragment,{children:[N.jsxs("div",{className:"text-center mb-4",children:[N.jsx("h3",{className:"text-lg font-bold text-indigo-400 mb-2",children:"AI Implementation in Progress"}),N.jsx("p",{className:"text-sm text-gray-400",children:k[n]}),z>0&&N.jsxs("p",{className:"text-xs text-red-500 mt-1",children:[z," file(s) failed to process."]})]}),n==="generating"&&N.jsx("div",{className:"w-full bg-gray-900 rounded-full h-2.5 mb-4",children:N.jsx("div",{className:"bg-green-600 h-2.5 rounded-full",style:{width:`${M/_.length*100}%`}})}),N.jsx("div",{className:"bg-gray-950 p-2 rounded-md h-64 overflow-y-auto border border-gray-700",children:N.jsx("ul",{className:"text-sm",children:_.map(([F,B])=>N.jsxs("li",{className:`flex items-center justify-between p-1.5 ${nA(B)}`,children:[N.jsx("span",{className:"truncate",children:F}),N.jsx("span",{className:"font-mono text-xs capitalize shrink-0 ml-2",children:B})]},F))})}),n==="awaiting_pr_creation"&&N.jsx("button",{onClick:S,className:"mt-4 w-full px-4 py-2 bg-green-600 hover:bg-green-500 rounded-md font-semibold",children:"Create Pull Request"})]})},O=i.suggestions.length===1?i.suggestions[0].title:`${i.suggestions.length} architectural improvements`;return N.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-90 flex items-center justify-center z-50 p-4",children:N.jsxs("div",{className:"bg-gray-850 rounded-lg shadow-2xl w-full max-w-2xl flex flex-col border border-gray-700 p-6",children:[N.jsxs("header",{className:"flex items-center gap-3 min-w-0 mb-4",children:[N.jsx(Ta,{className:"w-8 h-8 text-indigo-400 shrink-0 animate-pulse"}),N.jsxs("div",{className:"min-w-0",children:[N.jsx("h2",{className:"text-md font-bold text-gray-300",children:"Automated Implementation"}),N.jsx("p",{className:"text-xs text-gray-400 truncate",title:O,children:O})]})]}),P()]})})},lA=({repoId:i,onClose:n,onStartAnalysis:o})=>{const[a,r]=Ee.useState(""),d=m=>{m.preventDefault(),o(a)};return N.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-90 flex items-center justify-center z-50 p-4",children:N.jsxs("form",{onSubmit:d,className:"bg-gray-850 p-6 rounded-lg shadow-2xl w-full max-w-lg border border-gray-700 flex flex-col gap-4",children:[N.jsx("header",{children:N.jsxs("div",{className:"flex items-center gap-3",children:[N.jsx(Ta,{className:"w-8 h-8 text-indigo-400 shrink-0"}),N.jsxs("div",{children:[N.jsx("h2",{className:"text-lg font-bold text-gray-100",children:"Guide the AI Architect"}),N.jsx("p",{className:"text-sm text-gray-400",children:i})]})]})}),N.jsxs("div",{children:[N.jsx("label",{htmlFor:"ai-prompt",className:"block text-sm font-medium text-gray-300 mb-2",children:"Analysis Focus (Optional)"}),N.jsx("textarea",{id:"ai-prompt",value:a,onChange:m=>r(m.target.value),className:"w-full px-3 py-2 bg-gray-900 border border-gray-600 rounded-md text-gray-200 focus:outline-none focus:ring-2 focus:ring-indigo-500",placeholder:"e.g., 'Focus on improving performance and reducing bundle size.' or 'Suggest ways to make the UI more interactive.'",rows:4}),N.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"Provide instructions to focus the AI's analysis on specific areas of your code."})]}),N.jsxs("footer",{className:"flex justify-end gap-3 pt-2",children:[N.jsx("button",{type:"button",onClick:n,className:"px-4 py-2 bg-gray-600 text-white font-semibold rounded-md hover:bg-gray-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-850 focus:ring-gray-400",children:"Cancel"}),N.jsx("button",{type:"submit",className:"px-4 py-2 bg-indigo-600 text-white font-semibold rounded-md hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-850 focus:ring-indigo-500",children:"Start Analysis"})]})]})})},oA=[/node_modules\//,/\.git\//,/dist\//,/build\//,/\.next\//,/package-lock\.json$/,/yarn\.lock$/,/pnpm-lock\.yaml$/,/\.min\.js$/,/\.min\.css$/,/\.(png|jpg|jpeg|gif|svg|ico|webp|mp4|webm|ogg|mp3|wav|flac|aac)$/i],lr=i=>{let n=[];for(const o of i)oA.some(a=>a.test(o.path))||(o.type==="file"?n.push(o):o.type==="dir"&&(n=n.concat(lr(o.children))));return n};function aA(){var U;const[i,n]=Ee.useState(null),[o,a]=Ee.useState({}),[r,d]=Ee.useState({}),[m,g]=Ee.useState([]),[y,h]=Ee.useState(null),[v,S]=Ee.useState(!1),[_,M]=Ee.useState(""),[z,P]=Ee.useState(null),[O,k]=Ee.useState({isOpen:!1,repoId:null}),[F,B]=Ee.useState(null),[Q,ne]=Ee.useState(null),W=m.find(b=>b.repoId+"::"+b.path===y),J=(b,Y)=>{P({type:b,msg:Y})},he=Ee.useCallback(async b=>{if(b){n(b),S(!0),M("Fetching repos...");try{const Y=await v0(b),te={},le=Y.map(async A=>{M(`Fetching tree for ${A.full_name}...`);try{const L=await S0(b,A.owner.login,A.name,A.default_branch);te[A.full_name]={repo:A,tree:L,contentStatus:"unloaded",analysisStatus:"unanalyzed"}}catch(L){L instanceof Error&&L.message.includes("Git Repository is empty")?te[A.full_name]={repo:A,tree:[],contentStatus:"loaded",analysisStatus:"unanalyzed"}:console.error(`Tree fetch failed for ${A.full_name}`,L)}});await Promise.all(le),a(te),J("success","Repos loaded. Expand a repository to load its content for analysis.")}catch(Y){console.error(Y),n(null),J("error",`Login failed: ${Y instanceof Error?Y.message:"Check token."}`)}finally{S(!1),M("")}}},[]),ee=Ee.useCallback(async b=>{var Y;if(!(!i||((Y=o[b])==null?void 0:Y.contentStatus)!=="unloaded")){a(te=>({...te,[b]:{...te[b],contentStatus:"loading"}}));try{const te=o[b],le=lr(te.tree),[A,L]=b.split("/"),K={},Z=8,ae=[...le],ue=async()=>{for(;ae.length>0;){const pe=ae.shift();if(pe)try{const Xe=await E0(i,A,L,pe.path,te.repo.default_branch);K[pe.path]=Xe.content}catch(Xe){console.warn(`Failed to fetch content for ${pe.path}`,Xe),K[pe.path]="// Error: Could not load content for this file."}}};await Promise.all(Array(Z).fill(null).map(ue)),d(pe=>({...pe,[b]:K})),a(pe=>({...pe,[b]:{...pe[b],contentStatus:"loaded"}})),J("success",`${b} is fully loaded and ready for AI analysis.`)}catch(te){console.error(`Failed to load repo content for ${b}`,te),J("error",`Failed to load files for ${b}.`),a(le=>({...le,[b]:{...le[b],contentStatus:"unloaded"}}))}}},[i,o]),re=Ee.useCallback(async(b,Y)=>{var le,A;const te=`${b}::${Y}`;if(m.some(L=>L.repoId+"::"+L.path===te)){h(te);return}if(i)try{const L=(le=o[b])==null?void 0:le.repo;if(!L)throw new Error("Repo data not found");if(o[b].contentStatus!=="loaded"){J("error","Please expand the repository and wait for its files to load before opening one.");return}const K=lr(o[b].tree).find(ue=>ue.path===Y),Z=(A=r[b])==null?void 0:A[Y];if(!K||typeof Z>"u")throw new Error("File content not pre-loaded. Please reload the repo.");const ae={repoId:b,path:Y,content:Z,edited:Z,sha:K.sha,defaultBranch:L.default_branch};g(ue=>[...ue,ae]),h(te)}catch(L){console.error(L),J("error",`Failed to open file: ${L instanceof Error?L.message:"Unknown error"}`)}},[i,m,r,o]),de=(b,Y)=>{g(te=>te.map(le=>le.repoId+"::"+le.path===b?{...le,edited:Y}:le))},ce=b=>{g(Y=>{var le,A;const te=Y.filter(L=>L.repoId+"::"+L.path!==b);return y===b&&h(((le=te[te.length-1])==null?void 0:le.repoId)+"::"+((A=te[te.length-1])==null?void 0:A.path)||null),te})},He=async(b,Y)=>{var te;if(((te=o[b])==null?void 0:te.contentStatus)!=="loaded"){J("error","Cannot analyze an unloaded repository.");return}k({isOpen:!1,repoId:null}),a(le=>({...le,[b]:{...le[b],analysisStatus:"analyzing"}}));try{const le={fileTree:JSON.stringify(o[b].tree,null,2),fileContents:r[b]},A=await KC(b,le,Y);a(L=>({...L,[b]:{...L[b],analysisStatus:"analyzed",suggestions:A}})),B(b)}catch(le){console.error(`Analysis failed for ${b}:`,le),J("error",`Analysis failed: ${le instanceof Error?le.message:"Unknown AI error"}`),a(A=>({...A,[b]:{...A[b],analysisStatus:"unanalyzed"}}))}},We=b=>{var Y;if(((Y=o[b])==null?void 0:Y.contentStatus)!=="loaded"){J("error","Cannot analyze an unloaded repository. Please expand it first.");return}k({isOpen:!0,repoId:b})},Ve=(b,Y,te)=>{B(null),ne({repoId:b,suggestions:Y,userPrompt:te})};return N.jsxs("div",{className:"h-screen w-screen flex flex-col font-sans",children:[!i&&N.jsx(f0,{onSubmit:he,isLoading:v}),N.jsx($C,{alert:z,onClose:()=>P(null)}),v&&!i&&N.jsxs("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-80 flex flex-col items-center justify-center z-50",children:[N.jsx(ma,{}),N.jsx("p",{className:"mt-4 text-lg",children:_})]}),N.jsxs("main",{className:"flex-grow flex overflow-hidden",children:[N.jsx("aside",{className:"w-1/3 max-w-sm bg-gray-900 border-r border-gray-700 h-full overflow-y-auto",children:i&&N.jsx(m0,{fsTree:o,onFileSelect:re,onRepoExpand:ee,onRepoAnalyze:We,selectedRepo:W==null?void 0:W.repoId,selectedFilePath:W==null?void 0:W.path})}),N.jsx("section",{className:"flex-grow h-full",children:N.jsx(g0,{openFiles:m,activeFile:W||null,onFileContentChange:de,onCloseFile:ce,onSetActiveFile:h})})]}),O.isOpen&&O.repoId&&N.jsx(lA,{repoId:O.repoId,onClose:()=>k({isOpen:!1,repoId:null}),onStartAnalysis:b=>He(O.repoId,b)}),F&&((U=o[F])==null?void 0:U.suggestions)&&N.jsx(eA,{repoId:F,analysisReport:o[F].suggestions,onClose:()=>B(null),onApplySuggestions:Ve}),Q&&i&&o[Q.repoId]&&r[Q.repoId]&&N.jsx(iA,{repoId:Q.repoId,suggestions:Q.suggestions,userPrompt:Q.userPrompt,authToken:i,repoContext:{fileTree:JSON.stringify(o[Q.repoId].tree,null,2),fileContents:r[Q.repoId],defaultBranch:o[Q.repoId].repo.default_branch},onComplete:b=>{J("success",`Pull request created for branch: ${b}`)},onError:b=>{J("error","An error occurred. See modal for details.")},onClose:()=>ne(null)})]})}const Dh=document.getElementById("root");if(!Dh)throw new Error("Could not find root element to mount to");const sA=c0.createRoot(Dh);sA.render(N.jsx(n0.StrictMode,{children:N.jsx(aA,{})}));