diff --git "a/assets/index-D1k2P-CQ.js" "b/assets/index-D1k2P-CQ.js" new file mode 100644--- /dev/null +++ "b/assets/index-D1k2P-CQ.js" @@ -0,0 +1,360 @@ +(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const u of document.querySelectorAll('link[rel="modulepreload"]'))s(u);new MutationObserver(u=>{for(const f of u)if(f.type==="childList")for(const m of f.addedNodes)m.tagName==="LINK"&&m.rel==="modulepreload"&&s(m)}).observe(document,{childList:!0,subtree:!0});function o(u){const f={};return u.integrity&&(f.integrity=u.integrity),u.referrerPolicy&&(f.referrerPolicy=u.referrerPolicy),u.crossOrigin==="use-credentials"?f.credentials="include":u.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f}function s(u){if(u.ep)return;u.ep=!0;const f=o(u);fetch(u.href,f)}})();function xh(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Ru={exports:{}},Uo={};/** + * @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 Pp;function p0(){if(Pp)return Uo;Pp=1;var i=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function o(s,u,f){var m=null;if(f!==void 0&&(m=""+f),u.key!==void 0&&(m=""+u.key),"key"in u){f={};for(var g in u)g!=="key"&&(f[g]=u[g])}else f=u;return u=f.ref,{$$typeof:i,type:s,key:m,ref:u!==void 0?u:null,props:f}}return Uo.Fragment=t,Uo.jsx=o,Uo.jsxs=o,Uo}var zp;function m0(){return zp||(zp=1,Ru.exports=p0()),Ru.exports}var S=m0(),Mu={exports:{}},ye={};/** + * @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 Vp;function h0(){if(Vp)return ye;Vp=1;var i=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),u=Symbol.for("react.profiler"),f=Symbol.for("react.consumer"),m=Symbol.for("react.context"),g=Symbol.for("react.forward_ref"),y=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),E=Symbol.for("react.activity"),C=Symbol.iterator;function x(R){return R===null||typeof R!="object"?null:(R=C&&R[C]||R["@@iterator"],typeof R=="function"?R:null)}var P={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},q=Object.assign,V={};function Y(R,z,O){this.props=R,this.context=z,this.refs=V,this.updater=O||P}Y.prototype.isReactComponent={},Y.prototype.setState=function(R,z){if(typeof R!="object"&&typeof R!="function"&&R!=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,R,z,"setState")},Y.prototype.forceUpdate=function(R){this.updater.enqueueForceUpdate(this,R,"forceUpdate")};function j(){}j.prototype=Y.prototype;function k(R,z,O){this.props=R,this.context=z,this.refs=V,this.updater=O||P}var Z=k.prototype=new j;Z.constructor=k,q(Z,Y.prototype),Z.isPureReactComponent=!0;var ae=Array.isArray;function se(){}var K={H:null,A:null,T:null,S:null},Ae=Object.prototype.hasOwnProperty;function ee(R,z,O){var te=O.ref;return{$$typeof:i,type:R,key:z,ref:te!==void 0?te:null,props:O}}function Ee(R,z){return ee(R.type,z,R.props)}function be(R){return typeof R=="object"&&R!==null&&R.$$typeof===i}function Te(R){var z={"=":"=0",":":"=2"};return"$"+R.replace(/[=:]/g,function(O){return z[O]})}var ut=/\/+/g;function yt(R,z){return typeof R=="object"&&R!==null&&R.key!=null?Te(""+R.key):z.toString(36)}function ct(R){switch(R.status){case"fulfilled":return R.value;case"rejected":throw R.reason;default:switch(typeof R.status=="string"?R.then(se,se):(R.status="pending",R.then(function(z){R.status==="pending"&&(R.status="fulfilled",R.value=z)},function(z){R.status==="pending"&&(R.status="rejected",R.reason=z)})),R.status){case"fulfilled":return R.value;case"rejected":throw R.reason}}throw R}function w(R,z,O,te,de){var Ce=typeof R;(Ce==="undefined"||Ce==="boolean")&&(R=null);var Ue=!1;if(R===null)Ue=!0;else switch(Ce){case"bigint":case"string":case"number":Ue=!0;break;case"object":switch(R.$$typeof){case i:case t:Ue=!0;break;case v:return Ue=R._init,w(Ue(R._payload),z,O,te,de)}}if(Ue)return de=de(R),Ue=te===""?"."+yt(R,0):te,ae(de)?(O="",Ue!=null&&(O=Ue.replace(ut,"$&/")+"/"),w(de,z,O,"",function(Kn){return Kn})):de!=null&&(be(de)&&(de=Ee(de,O+(de.key==null||R&&R.key===de.key?"":(""+de.key).replace(ut,"$&/")+"/")+Ue)),z.push(de)),1;Ue=0;var xt=te===""?".":te+":";if(ae(R))for(var lt=0;lt>>1,Ke=w[He];if(0>>1;Heu(O,ce))teu(de,O)?(w[He]=de,w[te]=ce,He=te):(w[He]=O,w[z]=ce,He=z);else if(teu(de,ce))w[He]=de,w[te]=ce,He=te;else break e}}return F}function u(w,F){var ce=w.sortIndex-F.sortIndex;return ce!==0?ce:w.id-F.id}if(i.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var f=performance;i.unstable_now=function(){return f.now()}}else{var m=Date,g=m.now();i.unstable_now=function(){return m.now()-g}}var y=[],h=[],v=1,E=null,C=3,x=!1,P=!1,q=!1,V=!1,Y=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,k=typeof setImmediate<"u"?setImmediate:null;function Z(w){for(var F=o(h);F!==null;){if(F.callback===null)s(h);else if(F.startTime<=w)s(h),F.sortIndex=F.expirationTime,t(y,F);else break;F=o(h)}}function ae(w){if(q=!1,Z(w),!P)if(o(y)!==null)P=!0,se||(se=!0,Te());else{var F=o(h);F!==null&&ct(ae,F.startTime-w)}}var se=!1,K=-1,Ae=5,ee=-1;function Ee(){return V?!0:!(i.unstable_now()-eew&&Ee());){var He=E.callback;if(typeof He=="function"){E.callback=null,C=E.priorityLevel;var Ke=He(E.expirationTime<=w);if(w=i.unstable_now(),typeof Ke=="function"){E.callback=Ke,Z(w),F=!0;break t}E===o(y)&&s(y),Z(w)}else s(y);E=o(y)}if(E!==null)F=!0;else{var R=o(h);R!==null&&ct(ae,R.startTime-w),F=!1}}break e}finally{E=null,C=ce,x=!1}F=void 0}}finally{F?Te():se=!1}}}var Te;if(typeof k=="function")Te=function(){k(be)};else if(typeof MessageChannel<"u"){var ut=new MessageChannel,yt=ut.port2;ut.port1.onmessage=be,Te=function(){yt.postMessage(null)}}else Te=function(){Y(be,0)};function ct(w,F){K=Y(function(){w(i.unstable_now())},F)}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(w){w.callback=null},i.unstable_forceFrameRate=function(w){0>w||125He?(w.sortIndex=ce,t(h,w),o(y)===null&&w===o(h)&&(q?(j(K),K=-1):q=!0,ct(ae,ce-He))):(w.sortIndex=Ke,t(y,w),P||x||(P=!0,se||(se=!0,Te()))),w},i.unstable_shouldYield=Ee,i.unstable_wrapCallback=function(w){var F=C;return function(){var ce=C;C=F;try{return w.apply(this,arguments)}finally{C=ce}}}})(Iu)),Iu}var Fp;function v0(){return Fp||(Fp=1,bu.exports=y0()),bu.exports}var Du={exports:{}},bt={};/** + * @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 Op;function T0(){if(Op)return bt;Op=1;var i=Bu();function t(y){var h="https://react.dev/errors/"+y;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(t){console.error(t)}}return i(),Du.exports=T0(),Du.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 Jp;function E0(){if(Jp)return Lo;Jp=1;var i=v0(),t=Bu(),o=S0();function s(e){var n="https://react.dev/errors/"+e;if(1Ke||(e.current=He[Ke],He[Ke]=null,Ke--)}function O(e,n){Ke++,He[Ke]=e.current,e.current=n}var te=R(null),de=R(null),Ce=R(null),Ue=R(null);function xt(e,n){switch(O(Ce,n),O(de,e),O(te,null),n.nodeType){case 9:case 11:e=(e=n.documentElement)&&(e=e.namespaceURI)?ap(e):0;break;default:if(e=n.tagName,n=n.namespaceURI)n=ap(n),e=rp(n,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}z(te),O(te,e)}function lt(){z(te),z(de),z(Ce)}function Kn(e){e.memoizedState!==null&&O(Ue,e);var n=te.current,l=rp(n,e.type);n!==l&&(O(de,e),O(te,l))}function mn(e){de.current===e&&(z(te),z(de)),Ue.current===e&&(z(Ue),wo._currentValue=ce)}var Ji,Zt;function _n(e){if(Ji===void 0)try{throw Error()}catch(l){var n=l.stack.trim().match(/\n( *(at )?)/);Ji=n&&n[1]||"",Zt=-1)":-1d||A[a]!==I[d]){var L=` +`+A[a].replace(" at new "," at ");return e.displayName&&L.includes("")&&(L=L.replace("",e.displayName)),L}while(1<=a&&0<=d);break}}}finally{Ki=!1,Error.prepareStackTrace=l}return(l=e?e.displayName||e.name:"")?_n(l):""}function Po(e,n){switch(e.tag){case 26:case 27:case 5:return _n(e.type);case 16:return _n("Lazy");case 13:return e.child!==n&&n!==null?_n("Suspense Fallback"):_n("Suspense");case 19:return _n("SuspenseList");case 0:case 15:return kl(e.type,!1);case 11:return kl(e.type.render,!1);case 1:return kl(e.type,!0);case 31:return _n("Activity");default:return""}}function zo(e){try{var n="",l=null;do n+=Po(e,l),l=e,e=e.return;while(e);return n}catch(a){return` +Error generating stack: `+a.message+` +`+a.stack}}var Xi=Object.prototype.hasOwnProperty,Bl=i.unstable_scheduleCallback,An=i.unstable_cancelCallback,pa=i.unstable_shouldYield,Vo=i.unstable_requestPaint,Dt=i.unstable_now,Fl=i.unstable_getCurrentPriorityLevel,me=i.unstable_ImmediatePriority,qt=i.unstable_UserBlockingPriority,Xn=i.unstable_NormalPriority,ma=i.unstable_LowPriority,je=i.unstable_IdlePriority,Ol=i.log,ha=i.unstable_setDisableYieldValue,Ai=null,vt=null;function hn(e){if(typeof Ol=="function"&&ha(e),vt&&typeof vt.setStrictMode=="function")try{vt.setStrictMode(Ai,e)}catch{}}var Ut=Math.clz32?Math.clz32:va,ga=Math.log,ya=Math.LN2;function va(e){return e>>>=0,e===0?32:31-(ga(e)/ya|0)|0}var Qi=256,Qn=262144,Zi=4194304;function gn(e){var n=e&42;if(n!==0)return n;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function $i(e,n,l){var a=e.pendingLanes;if(a===0)return 0;var d=0,p=e.suspendedLanes,T=e.pingedLanes;e=e.warmLanes;var _=a&134217727;return _!==0?(a=_&~p,a!==0?d=gn(a):(T&=_,T!==0?d=gn(T):l||(l=_&~e,l!==0&&(d=gn(l))))):(_=a&~p,_!==0?d=gn(_):T!==0?d=gn(T):l||(l=a&~e,l!==0&&(d=gn(l)))),d===0?0:n!==0&&n!==d&&(n&p)===0&&(p=d&-d,l=n&-n,p>=l||p===32&&(l&4194048)!==0)?n:d}function xi(e,n){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&n)===0}function Ta(e,n){switch(e){case 1:case 2:case 4:case 8:case 64:return n+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function ko(){var e=Zi;return Zi<<=1,(Zi&62914560)===0&&(Zi=4194304),e}function Ni(e){for(var n=[],l=0;31>l;l++)n.push(e);return n}function Ri(e,n){e.pendingLanes|=n,n!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function J(e,n,l,a,d,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.entanglements,A=e.expirationTimes,I=e.hiddenUpdates;for(l=T&~l;0"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var ag=/[\n"\\]/g;function Wt(e){return e.replace(ag,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function Ea(e,n,l,a,d,p,T,_){e.name="",T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"?e.type=T:e.removeAttribute("type"),n!=null?T==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+$t(n)):e.value!==""+$t(n)&&(e.value=""+$t(n)):T!=="submit"&&T!=="reset"||e.removeAttribute("value"),n!=null?Ca(e,T,$t(n)):l!=null?Ca(e,T,$t(l)):a!=null&&e.removeAttribute("value"),d==null&&p!=null&&(e.defaultChecked=!!p),d!=null&&(e.checked=d&&typeof d!="function"&&typeof d!="symbol"),_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"?e.name=""+$t(_):e.removeAttribute("name")}function ec(e,n,l,a,d,p,T,_){if(p!=null&&typeof p!="function"&&typeof p!="symbol"&&typeof p!="boolean"&&(e.type=p),n!=null||l!=null){if(!(p!=="submit"&&p!=="reset"||n!=null)){Sa(e);return}l=l!=null?""+$t(l):"",n=n!=null?""+$t(n):l,_||n===e.value||(e.value=n),e.defaultValue=n}a=a??d,a=typeof a!="function"&&typeof a!="symbol"&&!!a,e.checked=_?e.checked:!!a,e.defaultChecked=!!a,T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"&&(e.name=T),Sa(e)}function Ca(e,n,l){n==="number"&&Fo(e.ownerDocument)===e||e.defaultValue===""+l||(e.defaultValue=""+l)}function ji(e,n,l,a){if(e=e.options,n){n={};for(var d=0;d"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ra=!1;if(Rn)try{var Jl={};Object.defineProperty(Jl,"passive",{get:function(){Ra=!0}}),window.addEventListener("test",Jl,Jl),window.removeEventListener("test",Jl,Jl)}catch{Ra=!1}var jn=null,Ma=null,Yo=null;function ac(){if(Yo)return Yo;var e,n=Ma,l=n.length,a,d="value"in jn?jn.value:jn.textContent,p=d.length;for(e=0;e=Ql),pc=" ",mc=!1;function hc(e,n){switch(e){case"keyup":return qg.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function gc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var il=!1;function Hg(e,n){switch(e){case"compositionend":return gc(n);case"keypress":return n.which!==32?null:(mc=!0,pc);case"textInput":return e=n.data,e===pc&&mc?null:e;default:return null}}function Pg(e,n){if(il)return e==="compositionend"||!Ua&&hc(e,n)?(e=ac(),Yo=Ma=jn=null,il=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1=n)return{node:l,offset:n-e};e=a}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=Ac(l)}}function Nc(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Nc(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function Rc(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var n=Fo(e.document);n instanceof e.HTMLIFrameElement;){try{var l=typeof n.contentWindow.location.href=="string"}catch{l=!1}if(l)e=n.contentWindow;else break;n=Fo(e.document)}return n}function Ga(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}var Jg=Rn&&"documentMode"in document&&11>=document.documentMode,ll=null,Ha=null,jl=null,Pa=!1;function Mc(e,n,l){var a=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Pa||ll==null||ll!==Fo(a)||(a=ll,"selectionStart"in a&&Ga(a)?a={start:a.selectionStart,end:a.selectionEnd}:(a=(a.ownerDocument&&a.ownerDocument.defaultView||window).getSelection(),a={anchorNode:a.anchorNode,anchorOffset:a.anchorOffset,focusNode:a.focusNode,focusOffset:a.focusOffset}),jl&&Wl(jl,a)||(jl=a,a=Ps(Ha,"onSelect"),0>=T,d-=T,Tn=1<<32-Ut(n)+d|l<Se?(we=oe,oe=null):we=oe.sibling;var Ve=D(M,oe,b[Se],G);if(Ve===null){oe===null&&(oe=we);break}e&&oe&&Ve.alternate===null&&n(M,oe),N=p(Ve,N,Se),ze===null?re=Ve:ze.sibling=Ve,ze=Ve,oe=we}if(Se===b.length)return l(M,oe),Ie&&wn(M,Se),re;if(oe===null){for(;SeSe?(we=oe,oe=null):we=oe.sibling;var Ei=D(M,oe,Ve.value,G);if(Ei===null){oe===null&&(oe=we);break}e&&oe&&Ei.alternate===null&&n(M,oe),N=p(Ei,N,Se),ze===null?re=Ei:ze.sibling=Ei,ze=Ei,oe=we}if(Ve.done)return l(M,oe),Ie&&wn(M,Se),re;if(oe===null){for(;!Ve.done;Se++,Ve=b.next())Ve=H(M,Ve.value,G),Ve!==null&&(N=p(Ve,N,Se),ze===null?re=Ve:ze.sibling=Ve,ze=Ve);return Ie&&wn(M,Se),re}for(oe=a(oe);!Ve.done;Se++,Ve=b.next())Ve=U(oe,M,Se,Ve.value,G),Ve!==null&&(e&&Ve.alternate!==null&&oe.delete(Ve.key===null?Se:Ve.key),N=p(Ve,N,Se),ze===null?re=Ve:ze.sibling=Ve,ze=Ve);return e&&oe.forEach(function(d0){return n(M,d0)}),Ie&&wn(M,Se),re}function nt(M,N,b,G){if(typeof b=="object"&&b!==null&&b.type===q&&b.key===null&&(b=b.props.children),typeof b=="object"&&b!==null){switch(b.$$typeof){case x:e:{for(var re=b.key;N!==null;){if(N.key===re){if(re=b.type,re===q){if(N.tag===7){l(M,N.sibling),G=d(N,b.props.children),G.return=M,M=G;break e}}else if(N.elementType===re||typeof re=="object"&&re!==null&&re.$$typeof===Ae&&Pi(re)===N.type){l(M,N.sibling),G=d(N,b.props),oo(G,b),G.return=M,M=G;break e}l(M,N);break}else n(M,N);N=N.sibling}b.type===q?(G=Ui(b.props.children,M.mode,G,b.key),G.return=M,M=G):(G=ts(b.type,b.key,b.props,null,M.mode,G),oo(G,b),G.return=M,M=G)}return T(M);case P:e:{for(re=b.key;N!==null;){if(N.key===re)if(N.tag===4&&N.stateNode.containerInfo===b.containerInfo&&N.stateNode.implementation===b.implementation){l(M,N.sibling),G=d(N,b.children||[]),G.return=M,M=G;break e}else{l(M,N);break}else n(M,N);N=N.sibling}G=Ya(b,M.mode,G),G.return=M,M=G}return T(M);case Ae:return b=Pi(b),nt(M,N,b,G)}if(ct(b))return ie(M,N,b,G);if(Te(b)){if(re=Te(b),typeof re!="function")throw Error(s(150));return b=re.call(b),ue(M,N,b,G)}if(typeof b.then=="function")return nt(M,N,rs(b),G);if(b.$$typeof===k)return nt(M,N,ls(M,b),G);us(M,b)}return typeof b=="string"&&b!==""||typeof b=="number"||typeof b=="bigint"?(b=""+b,N!==null&&N.tag===6?(l(M,N.sibling),G=d(N,b),G.return=M,M=G):(l(M,N),G=Oa(b,M.mode,G),G.return=M,M=G),T(M)):l(M,N)}return function(M,N,b,G){try{lo=0;var re=nt(M,N,b,G);return hl=null,re}catch(oe){if(oe===ml||oe===ss)throw oe;var ze=Ot(29,oe,null,M.mode);return ze.lanes=G,ze.return=M,ze}finally{}}}var Vi=$c(!0),Wc=$c(!1),li=!1;function ir(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function lr(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function oi(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function si(e,n,l){var a=e.updateQueue;if(a===null)return null;if(a=a.shared,(Je&2)!==0){var d=a.pending;return d===null?n.next=n:(n.next=d.next,d.next=n),a.pending=n,n=es(e),qc(e,null,l),n}return jo(e,a,n,l),es(e)}function so(e,n,l){if(n=n.updateQueue,n!==null&&(n=n.shared,(l&4194048)!==0)){var a=n.lanes;a&=e.pendingLanes,l|=a,n.lanes=l,ne(e,l)}}function or(e,n){var l=e.updateQueue,a=e.alternate;if(a!==null&&(a=a.updateQueue,l===a)){var d=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?d=p=T:p=p.next=T,l=l.next}while(l!==null);p===null?d=p=n:p=p.next=n}else d=p=n;l={baseState:a.baseState,firstBaseUpdate:d,lastBaseUpdate:p,shared:a.shared,callbacks:a.callbacks},e.updateQueue=l;return}e=l.lastBaseUpdate,e===null?l.firstBaseUpdate=n:e.next=n,l.lastBaseUpdate=n}var sr=!1;function ao(){if(sr){var e=pl;if(e!==null)throw e}}function ro(e,n,l,a){sr=!1;var d=e.updateQueue;li=!1;var p=d.firstBaseUpdate,T=d.lastBaseUpdate,_=d.shared.pending;if(_!==null){d.shared.pending=null;var A=_,I=A.next;A.next=null,T===null?p=I:T.next=I,T=A;var L=e.alternate;L!==null&&(L=L.updateQueue,_=L.lastBaseUpdate,_!==T&&(_===null?L.firstBaseUpdate=I:_.next=I,L.lastBaseUpdate=A))}if(p!==null){var H=d.baseState;T=0,L=I=A=null,_=p;do{var D=_.lane&-536870913,U=D!==_.lane;if(U?(Me&D)===D:(a&D)===D){D!==0&&D===dl&&(sr=!0),L!==null&&(L=L.next={lane:0,tag:_.tag,payload:_.payload,callback:null,next:null});e:{var ie=e,ue=_;D=n;var nt=l;switch(ue.tag){case 1:if(ie=ue.payload,typeof ie=="function"){H=ie.call(nt,H,D);break e}H=ie;break e;case 3:ie.flags=ie.flags&-65537|128;case 0:if(ie=ue.payload,D=typeof ie=="function"?ie.call(nt,H,D):ie,D==null)break e;H=E({},H,D);break e;case 2:li=!0}}D=_.callback,D!==null&&(e.flags|=64,U&&(e.flags|=8192),U=d.callbacks,U===null?d.callbacks=[D]:U.push(D))}else U={lane:D,tag:_.tag,payload:_.payload,callback:_.callback,next:null},L===null?(I=L=U,A=H):L=L.next=U,T|=D;if(_=_.next,_===null){if(_=d.shared.pending,_===null)break;U=_,_=U.next,U.next=null,d.lastBaseUpdate=U,d.shared.pending=null}}while(!0);L===null&&(A=H),d.baseState=A,d.firstBaseUpdate=I,d.lastBaseUpdate=L,p===null&&(d.shared.lanes=0),fi|=T,e.lanes=T,e.memoizedState=H}}function jc(e,n){if(typeof e!="function")throw Error(s(191,e));e.call(n)}function ef(e,n){var l=e.callbacks;if(l!==null)for(e.callbacks=null,e=0;ep?p:8;var T=w.T,_={};w.T=_,xr(e,!1,n,l);try{var A=d(),I=w.S;if(I!==null&&I(_,A),A!==null&&typeof A=="object"&&typeof A.then=="function"){var L=ty(A,a);fo(e,n,L,Qt(e))}else fo(e,n,a,Qt(e))}catch(H){fo(e,n,{then:function(){},status:"rejected",reason:H},Qt())}finally{F.p=p,T!==null&&_.types!==null&&(T.types=_.types),w.T=T}}function ay(){}function _r(e,n,l,a){if(e.tag!==5)throw Error(s(476));var d=Uf(e).queue;Df(e,d,n,ce,l===null?ay:function(){return Lf(e),l(a)})}function Uf(e){var n=e.memoizedState;if(n!==null)return n;n={memoizedState:ce,baseState:ce,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Un,lastRenderedState:ce},next:null};var l={};return n.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Un,lastRenderedState:l},next:null},e.memoizedState=n,e=e.alternate,e!==null&&(e.memoizedState=n),n}function Lf(e){var n=Uf(e);n.next===null&&(n=e.alternate.memoizedState),fo(e,n.next.queue,{},Qt())}function Ar(){return Rt(wo)}function qf(){return gt().memoizedState}function Gf(){return gt().memoizedState}function ry(e){for(var n=e.return;n!==null;){switch(n.tag){case 24:case 3:var l=Qt();e=oi(l);var a=si(n,e,l);a!==null&&(kt(a,n,l),so(a,n,l)),n={cache:ja()},e.payload=n;return}n=n.return}}function uy(e,n,l){var a=Qt();l={lane:a,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Ts(e)?Pf(n,l):(l=Ba(e,n,l,a),l!==null&&(kt(l,e,a),zf(l,n,a)))}function Hf(e,n,l){var a=Qt();fo(e,n,l,a)}function fo(e,n,l,a){var d={lane:a,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(Ts(e))Pf(n,d);else{var p=e.alternate;if(e.lanes===0&&(p===null||p.lanes===0)&&(p=n.lastRenderedReducer,p!==null))try{var T=n.lastRenderedState,_=p(T,l);if(d.hasEagerState=!0,d.eagerState=_,Ft(_,T))return jo(e,n,d,0),it===null&&Wo(),!1}catch{}finally{}if(l=Ba(e,n,d,a),l!==null)return kt(l,e,a),zf(l,n,a),!0}return!1}function xr(e,n,l,a){if(a={lane:2,revertLane:iu(),gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Ts(e)){if(n)throw Error(s(479))}else n=Ba(e,l,a,2),n!==null&&kt(n,e,2)}function Ts(e){var n=e.alternate;return e===ve||n!==null&&n===ve}function Pf(e,n){yl=ds=!0;var l=e.pending;l===null?n.next=n:(n.next=l.next,l.next=n),e.pending=n}function zf(e,n,l){if((l&4194048)!==0){var a=n.lanes;a&=e.pendingLanes,l|=a,n.lanes=l,ne(e,l)}}var po={readContext:Rt,use:hs,useCallback:dt,useContext:dt,useEffect:dt,useImperativeHandle:dt,useLayoutEffect:dt,useInsertionEffect:dt,useMemo:dt,useReducer:dt,useRef:dt,useState:dt,useDebugValue:dt,useDeferredValue:dt,useTransition:dt,useSyncExternalStore:dt,useId:dt,useHostTransitionStatus:dt,useFormState:dt,useActionState:dt,useOptimistic:dt,useMemoCache:dt,useCacheRefresh:dt};po.useEffectEvent=dt;var Vf={readContext:Rt,use:hs,useCallback:function(e,n){return Lt().memoizedState=[e,n===void 0?null:n],e},useContext:Rt,useEffect:_f,useImperativeHandle:function(e,n,l){l=l!=null?l.concat([e]):null,ys(4194308,4,Rf.bind(null,n,e),l)},useLayoutEffect:function(e,n){return ys(4194308,4,e,n)},useInsertionEffect:function(e,n){ys(4,2,e,n)},useMemo:function(e,n){var l=Lt();n=n===void 0?null:n;var a=e();if(ki){hn(!0);try{e()}finally{hn(!1)}}return l.memoizedState=[a,n],a},useReducer:function(e,n,l){var a=Lt();if(l!==void 0){var d=l(n);if(ki){hn(!0);try{l(n)}finally{hn(!1)}}}else d=n;return a.memoizedState=a.baseState=d,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:d},a.queue=e,e=e.dispatch=uy.bind(null,ve,e),[a.memoizedState,e]},useRef:function(e){var n=Lt();return e={current:e},n.memoizedState=e},useState:function(e){e=vr(e);var n=e.queue,l=Hf.bind(null,ve,n);return n.dispatch=l,[e.memoizedState,l]},useDebugValue:Er,useDeferredValue:function(e,n){var l=Lt();return Cr(l,e,n)},useTransition:function(){var e=vr(!1);return e=Df.bind(null,ve,e.queue,!0,!1),Lt().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,n,l){var a=ve,d=Lt();if(Ie){if(l===void 0)throw Error(s(407));l=l()}else{if(l=n(),it===null)throw Error(s(349));(Me&127)!==0||af(a,n,l)}d.memoizedState=l;var p={value:l,getSnapshot:n};return d.queue=p,_f(uf.bind(null,a,p,e),[e]),a.flags|=2048,Tl(9,{destroy:void 0},rf.bind(null,a,p,l,n),null),l},useId:function(){var e=Lt(),n=it.identifierPrefix;if(Ie){var l=Sn,a=Tn;l=(a&~(1<<32-Ut(a)-1)).toString(32)+l,n="_"+n+"R_"+l,l=ps++,0<\/script>",p=p.removeChild(p.firstChild);break;case"select":p=typeof a.is=="string"?T.createElement("select",{is:a.is}):T.createElement("select"),a.multiple?p.multiple=!0:a.size&&(p.size=a.size);break;default:p=typeof a.is=="string"?T.createElement(d,{is:a.is}):T.createElement(d)}}p[pe]=n,p[Ge]=a;e:for(T=n.child;T!==null;){if(T.tag===5||T.tag===6)p.appendChild(T.stateNode);else if(T.tag!==4&&T.tag!==27&&T.child!==null){T.child.return=T,T=T.child;continue}if(T===n)break e;for(;T.sibling===null;){if(T.return===null||T.return===n)break e;T=T.return}T.sibling.return=T.return,T=T.sibling}n.stateNode=p;e:switch(wt(p,d,a),d){case"button":case"input":case"select":case"textarea":a=!!a.autoFocus;break e;case"img":a=!0;break e;default:a=!1}a&&qn(n)}}return at(n),zr(n,n.type,e===null?null:e.memoizedProps,n.pendingProps,l),null;case 6:if(e&&n.stateNode!=null)e.memoizedProps!==a&&qn(n);else{if(typeof a!="string"&&n.stateNode===null)throw Error(s(166));if(e=Ce.current,cl(n)){if(e=n.stateNode,l=n.memoizedProps,a=null,d=Nt,d!==null)switch(d.tag){case 27:case 5:a=d.memoizedProps}e[pe]=n,e=!!(e.nodeValue===l||a!==null&&a.suppressHydrationWarning===!0||op(e.nodeValue,l)),e||ni(n,!0)}else e=zs(e).createTextNode(a),e[pe]=n,n.stateNode=e}return at(n),null;case 31:if(l=n.memoizedState,e===null||e.memoizedState!==null){if(a=cl(n),l!==null){if(e===null){if(!a)throw Error(s(318));if(e=n.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(s(557));e[pe]=n}else Li(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;at(n),e=!1}else l=Qa(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=l),e=!0;if(!e)return n.flags&256?(Jt(n),n):(Jt(n),null);if((n.flags&128)!==0)throw Error(s(558))}return at(n),null;case 13:if(a=n.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(d=cl(n),a!==null&&a.dehydrated!==null){if(e===null){if(!d)throw Error(s(318));if(d=n.memoizedState,d=d!==null?d.dehydrated:null,!d)throw Error(s(317));d[pe]=n}else Li(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;at(n),d=!1}else d=Qa(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=d),d=!0;if(!d)return n.flags&256?(Jt(n),n):(Jt(n),null)}return Jt(n),(n.flags&128)!==0?(n.lanes=l,n):(l=a!==null,e=e!==null&&e.memoizedState!==null,l&&(a=n.child,d=null,a.alternate!==null&&a.alternate.memoizedState!==null&&a.alternate.memoizedState.cachePool!==null&&(d=a.alternate.memoizedState.cachePool.pool),p=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(p=a.memoizedState.cachePool.pool),p!==d&&(a.flags|=2048)),l!==e&&l&&(n.child.flags|=8192),As(n,n.updateQueue),at(n),null);case 4:return lt(),e===null&&au(n.stateNode.containerInfo),at(n),null;case 10:return In(n.type),at(n),null;case 19:if(z(ht),a=n.memoizedState,a===null)return at(n),null;if(d=(n.flags&128)!==0,p=a.rendering,p===null)if(d)ho(a,!1);else{if(pt!==0||e!==null&&(e.flags&128)!==0)for(e=n.child;e!==null;){if(p=fs(e),p!==null){for(n.flags|=128,ho(a,!1),e=p.updateQueue,n.updateQueue=e,As(n,e),n.subtreeFlags=0,e=l,l=n.child;l!==null;)Gc(l,e),l=l.sibling;return O(ht,ht.current&1|2),Ie&&wn(n,a.treeForkCount),n.child}e=e.sibling}a.tail!==null&&Dt()>ws&&(n.flags|=128,d=!0,ho(a,!1),n.lanes=4194304)}else{if(!d)if(e=fs(p),e!==null){if(n.flags|=128,d=!0,e=e.updateQueue,n.updateQueue=e,As(n,e),ho(a,!0),a.tail===null&&a.tailMode==="hidden"&&!p.alternate&&!Ie)return at(n),null}else 2*Dt()-a.renderingStartTime>ws&&l!==536870912&&(n.flags|=128,d=!0,ho(a,!1),n.lanes=4194304);a.isBackwards?(p.sibling=n.child,n.child=p):(e=a.last,e!==null?e.sibling=p:n.child=p,a.last=p)}return a.tail!==null?(e=a.tail,a.rendering=e,a.tail=e.sibling,a.renderingStartTime=Dt(),e.sibling=null,l=ht.current,O(ht,d?l&1|2:l&1),Ie&&wn(n,a.treeForkCount),e):(at(n),null);case 22:case 23:return Jt(n),rr(),a=n.memoizedState!==null,e!==null?e.memoizedState!==null!==a&&(n.flags|=8192):a&&(n.flags|=8192),a?(l&536870912)!==0&&(n.flags&128)===0&&(at(n),n.subtreeFlags&6&&(n.flags|=8192)):at(n),l=n.updateQueue,l!==null&&As(n,l.retryQueue),l=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(l=e.memoizedState.cachePool.pool),a=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(a=n.memoizedState.cachePool.pool),a!==l&&(n.flags|=2048),e!==null&&z(Hi),null;case 24:return l=null,e!==null&&(l=e.memoizedState.cache),n.memoizedState.cache!==l&&(n.flags|=2048),In(Tt),at(n),null;case 25:return null;case 30:return null}throw Error(s(156,n.tag))}function my(e,n){switch(Ka(n),n.tag){case 1:return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return In(Tt),lt(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 26:case 27:case 5:return mn(n),null;case 31:if(n.memoizedState!==null){if(Jt(n),n.alternate===null)throw Error(s(340));Li()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 13:if(Jt(n),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(s(340));Li()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return z(ht),null;case 4:return lt(),null;case 10:return In(n.type),null;case 22:case 23:return Jt(n),rr(),e!==null&&z(Hi),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 24:return In(Tt),null;case 25:return null;default:return null}}function cd(e,n){switch(Ka(n),n.tag){case 3:In(Tt),lt();break;case 26:case 27:case 5:mn(n);break;case 4:lt();break;case 31:n.memoizedState!==null&&Jt(n);break;case 13:Jt(n);break;case 19:z(ht);break;case 10:In(n.type);break;case 22:case 23:Jt(n),rr(),e!==null&&z(Hi);break;case 24:In(Tt)}}function go(e,n){try{var l=n.updateQueue,a=l!==null?l.lastEffect:null;if(a!==null){var d=a.next;l=d;do{if((l.tag&e)===e){a=void 0;var p=l.create,T=l.inst;a=p(),T.destroy=a}l=l.next}while(l!==d)}}catch(_){We(n,n.return,_)}}function ui(e,n,l){try{var a=n.updateQueue,d=a!==null?a.lastEffect:null;if(d!==null){var p=d.next;a=p;do{if((a.tag&e)===e){var T=a.inst,_=T.destroy;if(_!==void 0){T.destroy=void 0,d=n;var A=l,I=_;try{I()}catch(L){We(d,A,L)}}}a=a.next}while(a!==p)}}catch(L){We(n,n.return,L)}}function fd(e){var n=e.updateQueue;if(n!==null){var l=e.stateNode;try{ef(n,l)}catch(a){We(e,e.return,a)}}}function dd(e,n,l){l.props=Bi(e.type,e.memoizedProps),l.state=e.memoizedState;try{l.componentWillUnmount()}catch(a){We(e,n,a)}}function yo(e,n){try{var l=e.ref;if(l!==null){switch(e.tag){case 26:case 27:case 5:var a=e.stateNode;break;case 30:a=e.stateNode;break;default:a=e.stateNode}typeof l=="function"?e.refCleanup=l(a):l.current=a}}catch(d){We(e,n,d)}}function En(e,n){var l=e.ref,a=e.refCleanup;if(l!==null)if(typeof a=="function")try{a()}catch(d){We(e,n,d)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(d){We(e,n,d)}else l.current=null}function pd(e){var n=e.type,l=e.memoizedProps,a=e.stateNode;try{e:switch(n){case"button":case"input":case"select":case"textarea":l.autoFocus&&a.focus();break e;case"img":l.src?a.src=l.src:l.srcSet&&(a.srcset=l.srcSet)}}catch(d){We(e,e.return,d)}}function Vr(e,n,l){try{var a=e.stateNode;Gy(a,e.type,l,n),a[Ge]=n}catch(d){We(e,e.return,d)}}function md(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&gi(e.type)||e.tag===4}function kr(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||md(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&&gi(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 Br(e,n,l){var a=e.tag;if(a===5||a===6)e=e.stateNode,n?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(e,n):(n=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,n.appendChild(e),l=l._reactRootContainer,l!=null||n.onclick!==null||(n.onclick=Nn));else if(a!==4&&(a===27&&gi(e.type)&&(l=e.stateNode,n=null),e=e.child,e!==null))for(Br(e,n,l),e=e.sibling;e!==null;)Br(e,n,l),e=e.sibling}function xs(e,n,l){var a=e.tag;if(a===5||a===6)e=e.stateNode,n?l.insertBefore(e,n):l.appendChild(e);else if(a!==4&&(a===27&&gi(e.type)&&(l=e.stateNode),e=e.child,e!==null))for(xs(e,n,l),e=e.sibling;e!==null;)xs(e,n,l),e=e.sibling}function hd(e){var n=e.stateNode,l=e.memoizedProps;try{for(var a=e.type,d=n.attributes;d.length;)n.removeAttributeNode(d[0]);wt(n,a,l),n[pe]=e,n[Ge]=l}catch(p){We(e,e.return,p)}}var Gn=!1,Ct=!1,Fr=!1,gd=typeof WeakSet=="function"?WeakSet:Set,At=null;function hy(e,n){if(e=e.containerInfo,cu=Js,e=Rc(e),Ga(e)){if("selectionStart"in e)var l={start:e.selectionStart,end:e.selectionEnd};else e:{l=(l=e.ownerDocument)&&l.defaultView||window;var a=l.getSelection&&l.getSelection();if(a&&a.rangeCount!==0){l=a.anchorNode;var d=a.anchorOffset,p=a.focusNode;a=a.focusOffset;try{l.nodeType,p.nodeType}catch{l=null;break e}var T=0,_=-1,A=-1,I=0,L=0,H=e,D=null;t:for(;;){for(var U;H!==l||d!==0&&H.nodeType!==3||(_=T+d),H!==p||a!==0&&H.nodeType!==3||(A=T+a),H.nodeType===3&&(T+=H.nodeValue.length),(U=H.firstChild)!==null;)D=H,H=U;for(;;){if(H===e)break t;if(D===l&&++I===d&&(_=T),D===p&&++L===a&&(A=T),(U=H.nextSibling)!==null)break;H=D,D=H.parentNode}H=U}l=_===-1||A===-1?null:{start:_,end:A}}else l=null}l=l||{start:0,end:0}}else l=null;for(fu={focusedElem:e,selectionRange:l},Js=!1,At=n;At!==null;)if(n=At,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,At=e;else for(;At!==null;){switch(n=At,p=n.alternate,e=n.flags,n.tag){case 0:if((e&4)!==0&&(e=n.updateQueue,e=e!==null?e.events:null,e!==null))for(l=0;l title"))),wt(p,a,l),p[pe]=e,Ye(p),a=p;break e;case"link":var T=Cp("link","href",d).get(a+(l.href||""));if(T){for(var _=0;_nt&&(T=nt,nt=ue,ue=T);var M=xc(_,ue),N=xc(_,nt);if(M&&N&&(U.rangeCount!==1||U.anchorNode!==M.node||U.anchorOffset!==M.offset||U.focusNode!==N.node||U.focusOffset!==N.offset)){var b=H.createRange();b.setStart(M.node,M.offset),U.removeAllRanges(),ue>nt?(U.addRange(b),U.extend(N.node,N.offset)):(b.setEnd(N.node,N.offset),U.addRange(b))}}}}for(H=[],U=_;U=U.parentNode;)U.nodeType===1&&H.push({element:U,left:U.scrollLeft,top:U.scrollTop});for(typeof _.focus=="function"&&_.focus(),_=0;_l?32:l,w.T=null,l=Zr,Zr=null;var p=pi,T=kn;if(_t=0,Al=pi=null,kn=0,(Je&6)!==0)throw Error(s(331));var _=Je;if(Je|=4,Rd(p.current),Ad(p,p.current,T,l),Je=_,_o(0,!1),vt&&typeof vt.onPostCommitFiberRoot=="function")try{vt.onPostCommitFiberRoot(Ai,p)}catch{}return!0}finally{F.p=d,w.T=a,Yd(e,n)}}function Kd(e,n,l){n=en(l,n),n=wr(e.stateNode,n,2),e=si(e,n,2),e!==null&&(Ri(e,2),Cn(e))}function We(e,n,l){if(e.tag===3)Kd(e,e,l);else for(;n!==null;){if(n.tag===3){Kd(n,e,l);break}else if(n.tag===1){var a=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof a.componentDidCatch=="function"&&(di===null||!di.has(a))){e=en(l,e),l=Xf(2),a=si(n,l,2),a!==null&&(Qf(l,a,n,e),Ri(a,2),Cn(a));break}}n=n.return}}function eu(e,n,l){var a=e.pingCache;if(a===null){a=e.pingCache=new vy;var d=new Set;a.set(n,d)}else d=a.get(n),d===void 0&&(d=new Set,a.set(n,d));d.has(l)||(Jr=!0,d.add(l),e=_y.bind(null,e,n,l),n.then(e,e))}function _y(e,n,l){var a=e.pingCache;a!==null&&a.delete(n),e.pingedLanes|=e.suspendedLanes&l,e.warmLanes&=~l,it===e&&(Me&l)===l&&(pt===4||pt===3&&(Me&62914560)===Me&&300>Dt()-Ms?(Je&2)===0&&xl(e,0):Kr|=l,_l===Me&&(_l=0)),Cn(e)}function Xd(e,n){n===0&&(n=ko()),e=Di(e,n),e!==null&&(Ri(e,n),Cn(e))}function Ay(e){var n=e.memoizedState,l=0;n!==null&&(l=n.retryLane),Xd(e,l)}function xy(e,n){var l=0;switch(e.tag){case 31:case 13:var a=e.stateNode,d=e.memoizedState;d!==null&&(l=d.retryLane);break;case 19:a=e.stateNode;break;case 22:a=e.stateNode._retryCache;break;default:throw Error(s(314))}a!==null&&a.delete(n),Xd(e,l)}function Ny(e,n){return Bl(e,n)}var qs=null,Rl=null,tu=!1,Gs=!1,nu=!1,hi=0;function Cn(e){e!==Rl&&e.next===null&&(Rl===null?qs=Rl=e:Rl=Rl.next=e),Gs=!0,tu||(tu=!0,My())}function _o(e,n){if(!nu&&Gs){nu=!0;do for(var l=!1,a=qs;a!==null;){if(e!==0){var d=a.pendingLanes;if(d===0)var p=0;else{var T=a.suspendedLanes,_=a.pingedLanes;p=(1<<31-Ut(42|e)+1)-1,p&=d&~(T&~_),p=p&201326741?p&201326741|1:p?p|2:0}p!==0&&(l=!0,Wd(a,p))}else p=Me,p=$i(a,a===it?p:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),(p&3)===0||xi(a,p)||(l=!0,Wd(a,p));a=a.next}while(l);nu=!1}}function Ry(){Qd()}function Qd(){Gs=tu=!1;var e=0;hi!==0&&Py()&&(e=hi);for(var n=Dt(),l=null,a=qs;a!==null;){var d=a.next,p=Zd(a,n);p===0?(a.next=null,l===null?qs=d:l.next=d,d===null&&(Rl=l)):(l=a,(e!==0||(p&3)!==0)&&(Gs=!0)),a=d}_t!==0&&_t!==5||_o(e),hi!==0&&(hi=0)}function Zd(e,n){for(var l=e.suspendedLanes,a=e.pingedLanes,d=e.expirationTimes,p=e.pendingLanes&-62914561;0_)break;var L=A.transferSize,H=A.initiatorType;L&&sp(H)&&(A=A.responseEnd,T+=L*(A<_?1:(_-I)/(A-I)))}if(--a,n+=8*(p+T)/(d.duration/1e3),e++,10"u"?null:document;function vp(e,n,l){var a=Ml;if(a&&typeof n=="string"&&n){var d=Wt(n);d='link[rel="'+e+'"][href="'+d+'"]',typeof l=="string"&&(d+='[crossorigin="'+l+'"]'),yp.has(d)||(yp.add(d),e={rel:e,crossOrigin:l,href:n},a.querySelector(d)===null&&(n=a.createElement("link"),wt(n,"link",e),Ye(n),a.head.appendChild(n)))}}function Ky(e){Bn.D(e),vp("dns-prefetch",e,null)}function Xy(e,n){Bn.C(e,n),vp("preconnect",e,n)}function Qy(e,n,l){Bn.L(e,n,l);var a=Ml;if(a&&e&&n){var d='link[rel="preload"][as="'+Wt(n)+'"]';n==="image"&&l&&l.imageSrcSet?(d+='[imagesrcset="'+Wt(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(d+='[imagesizes="'+Wt(l.imageSizes)+'"]')):d+='[href="'+Wt(e)+'"]';var p=d;switch(n){case"style":p=wl(e);break;case"script":p=bl(e)}an.has(p)||(e=E({rel:"preload",href:n==="image"&&l&&l.imageSrcSet?void 0:e,as:n},l),an.set(p,e),a.querySelector(d)!==null||n==="style"&&a.querySelector(Ro(p))||n==="script"&&a.querySelector(Mo(p))||(n=a.createElement("link"),wt(n,"link",e),Ye(n),a.head.appendChild(n)))}}function Zy(e,n){Bn.m(e,n);var l=Ml;if(l&&e){var a=n&&typeof n.as=="string"?n.as:"script",d='link[rel="modulepreload"][as="'+Wt(a)+'"][href="'+Wt(e)+'"]',p=d;switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":p=bl(e)}if(!an.has(p)&&(e=E({rel:"modulepreload",href:e},n),an.set(p,e),l.querySelector(d)===null)){switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(Mo(p)))return}a=l.createElement("link"),wt(a,"link",e),Ye(a),l.head.appendChild(a)}}}function $y(e,n,l){Bn.S(e,n,l);var a=Ml;if(a&&e){var d=Ze(a).hoistableStyles,p=wl(e);n=n||"default";var T=d.get(p);if(!T){var _={loading:0,preload:null};if(T=a.querySelector(Ro(p)))_.loading=5;else{e=E({rel:"stylesheet",href:e,"data-precedence":n},l),(l=an.get(p))&&vu(e,l);var A=T=a.createElement("link");Ye(A),wt(A,"link",e),A._p=new Promise(function(I,L){A.onload=I,A.onerror=L}),A.addEventListener("load",function(){_.loading|=1}),A.addEventListener("error",function(){_.loading|=2}),_.loading|=4,ks(T,n,a)}T={type:"stylesheet",instance:T,count:1,state:_},d.set(p,T)}}}function Wy(e,n){Bn.X(e,n);var l=Ml;if(l&&e){var a=Ze(l).hoistableScripts,d=bl(e),p=a.get(d);p||(p=l.querySelector(Mo(d)),p||(e=E({src:e,async:!0},n),(n=an.get(d))&&Tu(e,n),p=l.createElement("script"),Ye(p),wt(p,"link",e),l.head.appendChild(p)),p={type:"script",instance:p,count:1,state:null},a.set(d,p))}}function jy(e,n){Bn.M(e,n);var l=Ml;if(l&&e){var a=Ze(l).hoistableScripts,d=bl(e),p=a.get(d);p||(p=l.querySelector(Mo(d)),p||(e=E({src:e,async:!0,type:"module"},n),(n=an.get(d))&&Tu(e,n),p=l.createElement("script"),Ye(p),wt(p,"link",e),l.head.appendChild(p)),p={type:"script",instance:p,count:1,state:null},a.set(d,p))}}function Tp(e,n,l,a){var d=(d=Ce.current)?Vs(d):null;if(!d)throw Error(s(446));switch(e){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(n=wl(l.href),l=Ze(d).hoistableStyles,a=l.get(n),a||(a={type:"style",instance:null,count:0,state:null},l.set(n,a)),a):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){e=wl(l.href);var p=Ze(d).hoistableStyles,T=p.get(e);if(T||(d=d.ownerDocument||d,T={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},p.set(e,T),(p=d.querySelector(Ro(e)))&&!p._p&&(T.instance=p,T.state.loading=5),an.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},an.set(e,l),p||e0(d,e,l,T.state))),n&&a===null)throw Error(s(528,""));return T}if(n&&a!==null)throw Error(s(529,""));return null;case"script":return n=l.async,l=l.src,typeof l=="string"&&n&&typeof n!="function"&&typeof n!="symbol"?(n=bl(l),l=Ze(d).hoistableScripts,a=l.get(n),a||(a={type:"script",instance:null,count:0,state:null},l.set(n,a)),a):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,e))}}function wl(e){return'href="'+Wt(e)+'"'}function Ro(e){return'link[rel="stylesheet"]['+e+"]"}function Sp(e){return E({},e,{"data-precedence":e.precedence,precedence:null})}function e0(e,n,l,a){e.querySelector('link[rel="preload"][as="style"]['+n+"]")?a.loading=1:(n=e.createElement("link"),a.preload=n,n.addEventListener("load",function(){return a.loading|=1}),n.addEventListener("error",function(){return a.loading|=2}),wt(n,"link",l),Ye(n),e.head.appendChild(n))}function bl(e){return'[src="'+Wt(e)+'"]'}function Mo(e){return"script[async]"+e}function Ep(e,n,l){if(n.count++,n.instance===null)switch(n.type){case"style":var a=e.querySelector('style[data-href~="'+Wt(l.href)+'"]');if(a)return n.instance=a,Ye(a),a;var d=E({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return a=(e.ownerDocument||e).createElement("style"),Ye(a),wt(a,"style",d),ks(a,l.precedence,e),n.instance=a;case"stylesheet":d=wl(l.href);var p=e.querySelector(Ro(d));if(p)return n.state.loading|=4,n.instance=p,Ye(p),p;a=Sp(l),(d=an.get(d))&&vu(a,d),p=(e.ownerDocument||e).createElement("link"),Ye(p);var T=p;return T._p=new Promise(function(_,A){T.onload=_,T.onerror=A}),wt(p,"link",a),n.state.loading|=4,ks(p,l.precedence,e),n.instance=p;case"script":return p=bl(l.src),(d=e.querySelector(Mo(p)))?(n.instance=d,Ye(d),d):(a=l,(d=an.get(p))&&(a=E({},l),Tu(a,d)),e=e.ownerDocument||e,d=e.createElement("script"),Ye(d),wt(d,"link",a),e.head.appendChild(d),n.instance=d);case"void":return null;default:throw Error(s(443,n.type))}else n.type==="stylesheet"&&(n.state.loading&4)===0&&(a=n.instance,n.state.loading|=4,ks(a,l.precedence,e));return n.instance}function ks(e,n,l){for(var a=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),d=a.length?a[a.length-1]:null,p=d,T=0;T title"):null)}function t0(e,n,l){if(l===1||n.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof n.precedence!="string"||typeof n.href!="string"||n.href==="")break;return!0;case"link":if(typeof n.rel!="string"||typeof n.href!="string"||n.href===""||n.onLoad||n.onError)break;switch(n.rel){case"stylesheet":return e=n.disabled,typeof n.precedence=="string"&&e==null;default:return!0}case"script":if(n.async&&typeof n.async!="function"&&typeof n.async!="symbol"&&!n.onLoad&&!n.onError&&n.src&&typeof n.src=="string")return!0}return!1}function Ap(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function n0(e,n,l,a){if(l.type==="stylesheet"&&(typeof a.media!="string"||matchMedia(a.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var d=wl(a.href),p=n.querySelector(Ro(d));if(p){n=p._p,n!==null&&typeof n=="object"&&typeof n.then=="function"&&(e.count++,e=Fs.bind(e),n.then(e,e)),l.state.loading|=4,l.instance=p,Ye(p);return}p=n.ownerDocument||n,a=Sp(a),(d=an.get(d))&&vu(a,d),p=p.createElement("link"),Ye(p);var T=p;T._p=new Promise(function(_,A){T.onload=_,T.onerror=A}),wt(p,"link",a),l.instance=p}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(l,n),(n=l.state.preload)&&(l.state.loading&3)===0&&(e.count++,l=Fs.bind(e),n.addEventListener("load",l),n.addEventListener("error",l))}}var Su=0;function i0(e,n){return e.stylesheets&&e.count===0&&Ys(e,e.stylesheets),0Su?50:800)+n);return e.unsuspend=l,function(){e.unsuspend=null,clearTimeout(a),clearTimeout(d)}}:null}function Fs(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Ys(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Os=null;function Ys(e,n){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Os=new Map,n.forEach(l0,e),Os=null,Fs.call(e))}function l0(e,n){if(!(n.state.loading&4)){var l=Os.get(e);if(l)var a=l.get(null);else{l=new Map,Os.set(e,l);for(var d=e.querySelectorAll("link[data-precedence],style[data-precedence]"),p=0;p"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(t){console.error(t)}}return i(),wu.exports=E0(),wu.exports}var _0=C0();const A0=xh(_0),ot=({className:i})=>S.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:[S.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),S.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"})]}),x0=({onSubmit:i,isLoading:t})=>{var y;const[o,s]=B.useState(""),[u,f]=B.useState(!1);B.useEffect(()=>{var h;(h=window.aistudio)!=null&&h.hasSelectedApiKey?window.aistudio.hasSltedApiKey().then(f):f(!0)},[]);const m=async()=>{var h;(h=window.aistudio)!=null&&h.openSelectKey&&(await window.aistudio.openSelectKey(),f(!0))},g=h=>{h.preventDefault(),i(o.trim())};return S.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-90 flex items-center justify-center z-50",children:S.jsxs("div",{className:"bg-gray-850 p-8 rounded-lg shadow-2xl w-full max-w-md border border-gray-700",children:[S.jsx("h2",{className:"text-2xl font-bold text-center text-gray-100 mb-2",children:"INIFINITE AI by James Burvel O'Callaghan III"}),S.jsx("p",{className:"text-center text-gray-400 mb-6",children:"Enter your credentials to begin."}),S.jsxs("form",{onSubmit:g,children:[S.jsxs("div",{className:"mb-4",children:[S.jsx("label",{htmlFor:"token",className:"block text-sm font-medium text-gray-300 mb-2",children:"GitHub Token"}),S.jsx("input",{id:"token",type:"password",value:o,onChange:h=>s(h.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})]}),S.jsxs("div",{className:"mb-6",children:[S.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Gemini API Key"}),S.jsxs("div",{className:"flex items-center gap-3",children:[S.jsx("div",{className:"flex-grow px-3 py-2 bg-gray-900 border border-gray-600 rounded-md text-gray-400 text-sm flex items-center",children:u?S.jsxs("span",{className:"text-green-400 flex items-center gap-2",children:[S.jsx("span",{className:"w-2 h-2 rounded-full bg-green-400"}),"Key Active"]}):S.jsx("span",{className:"text-gray-500",children:"No key selected"})}),((y=window.aistudio)==null?void 0:y.openSelectKey)&&S.jsx("button",{type:"button",onClick:m,className:"bg-indigo-600 text-white px-3 py-2 rounded-md hover:bg-indigo-700 text-sm font-medium transition-colors",children:u?"Change":"Select"})]}),S.jsxs("p",{className:"text-xs text-gray-500 mt-2",children:["A paid API key is required. ",S.jsx("a",{href:"https://ai.google.dev/gemini-api/docs/billing",target:"_blank",rel:"noopener noreferrer",className:"text-indigo-400 hover:underline",children:"Billing info"}),"."]})]}),S.jsxs("div",{className:"text-xs text-gray-500 mb-6 space-y-2",children:[S.jsx("p",{children:"Your GitHub token is used only for API requests and is not stored."}),S.jsxs("p",{children:["A ",S.jsx("strong",{className:"text-gray-400",children:"classic"})," token with the full ",S.jsx("code",{className:"bg-gray-700 p-1 rounded-sm text-xs",children:"repo"})," scope is required."]}),S.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 new classic token here."})]}),S.jsx("button",{type:"submit",disabled:t||!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:t?S.jsx(ot,{}):"Load Repositories"})]})]})})},Nh=i=>S.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:S.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"})}),Rh=i=>S.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:S.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"})}),N0=i=>S.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:S.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"})}),Fu=i=>S.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",...i,children:S.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"})}),R0=i=>S.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",...i,children:S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})}),M0=i=>S.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",...i,children:[S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.53 16.122a3 3 0 00-3.483 0w-6.036a3 3 0 013.483 0 3 3 0 003.483 0 3 3 0 013.483 0M9.53 16.122a3 3 0 00-3.483 0M9.53 16.122a3 3 0 013.483 0m0 0a3 3 0 013.483 0m0 0a3 3 0 003.483 0m-3.483 0a3 3 0 00-3.483 0m3.483 0a3 3 0 01-3.483 0m-9.75-6.322a3 3 0 013.483 0m0 0a3 3 0 003.483 0m0 0a3 3 0 013.483 0m0 0a3 3 0 003.483 0m-3.483 0a3 3 0 00-3.483 0m3.483 0a3 3 0 01-3.483 0"}),S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 12c0-3.359-2.34-6.14-5.46-6.918-1.217-.27-2.513-.44-3.856-.523a8.705 8.705 0 00-4.33 0c-1.343.083-2.64.253-3.856.523C-2.34 5.86-4.5 8.641-4.5 12c0 3.359 2.34 6.14 5.46 6.918 1.217.27 2.513.44 3.856.523a8.705 8.705 0 004.33 0c1.343-.083 2.64-.253 3.856-.523C17.16 18.14 19.5 15.359 19.5 12z"})]}),Mh=({node:i,repoFullName:t,onFileClick:o,selectedFilePath:s,selectedRepo:u,selectedFiles:f,onFileSelection:m,onDirectorySelection:g})=>{const[y,h]=B.useState(!1),v=B.useRef(null),E=i.type==="dir";B.useEffect(()=>{if(E&&v.current){const q=sa(i.children).map(Y=>`${t}::${Y}`);if(q.length===0){v.current.indeterminate=!1,v.current.checked=!1;return}const V=q.filter(Y=>f.has(Y)).length;V>0&&V{if(E)g(i.children,t,q.target.checked);else{const V=`${t}::${i.path}`;m(V,q.target.checked)}};if(E)return S.jsxs("div",{children:[S.jsxs("div",{className:"flex items-center p-1.5 hover:bg-gray-700 rounded-md group",children:[S.jsx("input",{type:"checkbox",ref:v,onChange:C,className:"mr-2 h-4 w-4 rounded bg-gray-800 border-gray-600 text-amber-500 focus:ring-amber-600"}),S.jsxs("div",{className:"flex items-center cursor-pointer flex-grow",onClick:()=>h(!y),children:[y?S.jsx(Rh,{className:"w-5 h-5 mr-2 text-indigo-400"}):S.jsx(Nh,{className:"w-5 h-5 mr-2 text-indigo-400"}),S.jsx("span",{children:i.name})]})]}),y&&S.jsx("div",{className:"pl-6 border-l border-gray-700 ml-4",children:i.children.map(q=>S.jsx(Mh,{node:q,repoFullName:t,onFileClick:o,selectedFilePath:s,selectedRepo:u,selectedFiles:f,onFileSelection:m,onDirectorySelection:g},q.path))})]});const x=f.has(`${t}::${i.path}`),P=u===t&&s===i.path;return S.jsxs("div",{className:`flex items-center p-1.5 group rounded-md ${P?"bg-indigo-900 bg-opacity-50":"hover:bg-gray-700"}`,children:[S.jsx("input",{type:"checkbox",checked:x,onChange:C,className:"mr-2 h-4 w-4 rounded bg-gray-800 border-gray-600 text-amber-500 focus:ring-amber-600"}),S.jsxs("div",{className:"flex items-center cursor-pointer flex-grow",onClick:()=>o(t,i.path),children:[S.jsx(N0,{className:"w-5 h-5 mr-2 text-gray-400"}),S.jsx("span",{className:P?"text-white":"text-gray-300",children:i.name})]})]})},w0=i=>{const{repo:t,tree:o,onFileClick:s,selectedFilePath:u,selectedRepo:f,selectedFiles:m,onFileSelection:g,onDirectorySelection:y}=i,h=t.full_name===f,[v,E]=B.useState(h);return B.useEffect(()=>{h&&!v&&E(!0)},[h,v]),S.jsxs("div",{className:"mb-2",children:[S.jsx("div",{className:"flex items-center justify-between p-2 hover:bg-gray-700 rounded-md group",children:S.jsxs("h3",{className:"text-lg font-semibold cursor-pointer flex items-center flex-grow",onClick:()=>E(!v),children:[v?S.jsx(Rh,{className:"w-5 h-5 mr-2"}):S.jsx(Nh,{className:"w-5 h-5 mr-2"}),t.full_name]})}),v&&S.jsx("div",{className:"pl-4 border-l border-gray-700 ml-2",children:o.map(C=>S.jsx(Mh,{node:C,repoFullName:t.full_name,onFileClick:s,selectedFilePath:u,selectedRepo:f,selectedFiles:m,onFileSelection:g,onDirectorySelection:y},C.path))})]})},b0=({fileTree:i,onFileSelect:t,onStartMultiEdit:o,onStartNewProject:s,onStartProjectExpansion:u,selectedFilePath:f,selectedRepo:m,selectedFiles:g,onFileSelection:y,onDirectorySelection:h})=>S.jsxs("div",{className:"p-4 text-gray-300 h-full flex flex-col",children:[S.jsxs("div",{className:"flex justify-between items-center mb-4 border-b border-gray-700 pb-2 flex-shrink-0",children:[S.jsx("h2",{className:"text-xl font-bold",children:"Repositories"}),S.jsxs("button",{onClick:s,className:"flex items-center gap-2 text-sm bg-indigo-600 text-white font-semibold py-1 px-3 rounded-md hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-900 focus:ring-indigo-500 transition-colors",title:"Generate a new project with AI",children:[S.jsx(R0,{className:"w-4 h-4"}),"New AI Project"]})]}),S.jsxs("div",{className:"flex-grow overflow-y-auto",children:[g.size>0&&S.jsxs("div",{className:"mb-4 sticky top-0 bg-gray-900 py-2 z-10 space-y-2",children:[S.jsxs("button",{onClick:o,className:"w-full flex items-center justify-center gap-2 bg-amber-600 text-white font-semibold py-2 px-4 rounded-md hover:bg-amber-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-900 focus:ring-amber-500 transition-colors",children:[S.jsx(Fu,{className:"w-5 h-5"}),"AI Edit ",g.size," Selected File",g.size>1?"s":""]}),S.jsxs("button",{onClick:u,disabled:g.size!==1,className:"w-full flex items-center justify-center gap-2 bg-purple-600 text-white font-semibold py-2 px-4 rounded-md hover:bg-purple-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-900 focus:ring-purple-500 transition-colors disabled:bg-gray-600 disabled:cursor-not-allowed",title:g.size!==1?"You must select exactly 1 file to use this feature.":"Expand the project based on this seed file.",children:[S.jsx(M0,{className:"w-5 h-5"}),"Expand Project (Seed)"]})]}),Object.keys(i).sort().map(v=>S.jsx(w0,{repo:i[v].repo,tree:i[v].tree,onFileClick:t,selectedFilePath:f,selectedRepo:m,selectedFiles:g,onFileSelection:y,onDirectorySelection:h},v))]})]}),I0=({onClose:i,onCommit:t,isLoading:o,defaultMessage:s})=>{const[u,f]=B.useState(s);B.useEffect(()=>{f(s)},[s]);const m=async g=>{g.preventDefault(),!(!u.trim()||o)&&await t(u)};return S.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-70 flex items-center justify-center z-50",onClick:i,children:S.jsxs("div",{className:"bg-gray-850 p-6 rounded-lg shadow-2xl w-full max-w-lg border border-gray-700",onClick:g=>g.stopPropagation(),children:[S.jsx("h2",{className:"text-xl font-bold text-green-400 mb-4",children:"Commit Changes"}),S.jsxs("form",{onSubmit:m,children:[S.jsx("p",{className:"text-gray-400 mb-2 text-sm",children:"Enter a commit message:"}),S.jsx("input",{type:"text",value:u,onChange:g=>f(g.target.value),className:"w-full bg-gray-900 p-3 rounded-md mb-4 text-sm border border-gray-600 focus:outline-none focus:ring-2 focus:ring-green-500",autoFocus:!0}),S.jsxs("div",{className:"flex justify-end gap-4",children:[S.jsx("button",{type:"button",onClick:i,className:"px-4 py-2 bg-gray-600 text-white font-semibold rounded-md hover:bg-gray-700 disabled:opacity-50",disabled:o,children:"Cancel"}),S.jsx("button",{type:"submit",disabled:o||!u.trim(),className:"px-4 py-2 bg-green-600 text-white font-semibold rounded-md hover:bg-green-700 disabled:bg-gray-500 disabled:cursor-not-allowed transition-colors flex items-center justify-center min-w-[120px]",children:o?S.jsx(ot,{}):"Commit"})]})]})]})})},D0=i=>S.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",...i,children:S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.456 2.456L21.75 6l-1.035.259a3.375 3.375 0 00-2.456 2.456zM16.898 20.562L16.5 21.75l-.398-1.188a2.25 2.25 0 00-1.423-1.423L13.5 18.75l1.188-.398a2.25 2.25 0 001.423-1.423L16.5 15.75l.398 1.188a2.25 2.25 0 001.423 1.423L19.5 18.75l-1.188.398a2.25 2.25 0 00-1.423 1.423z"})}),U0=({file:i,isActive:t,onSelect:o,onClose:s})=>{const u=i.content!==i.editedContent,f=i.repoFullName+"::"+i.path,m=i.path.split("/").pop();return S.jsxs("div",{onClick:()=>o(f),className:`flex items-center justify-between p-2 px-4 cursor-pointer border-b-2 ${t?"bg-gray-850 border-indigo-500 text-white":"bg-gray-900 border-transparent text-gray-400 hover:bg-gray-800"}`,children:[S.jsx("span",{className:"text-sm font-medium pr-2",children:m}),S.jsxs("div",{className:"flex items-center",children:[u&&S.jsx("div",{className:"w-2 h-2 bg-yellow-400 rounded-full mr-2"}),S.jsx("button",{onClick:g=>{g.stopPropagation(),s(f)},className:"text-gray-500 hover:text-white rounded-full w-5 h-5 flex items-center justify-center hover:bg-gray-700 text-xs",children:"×"})]})]})},L0=({openFiles:i,activeFile:t,onCommit:o,onAdvancedAiEdit:s,onSimpleAiEditRequest:u,onFileContentChange:f,onCloseFile:m,onSetActiveFile:g,isLoading:y,branches:h,currentBranch:v,onBranchChange:E,onCreateBranch:C,onCreatePullRequest:x})=>{const[P,q]=B.useState(!1),[V,Y]=B.useState(""),[j,k]=B.useState(!1),[Z,ae]=B.useState(!1),[se,K]=B.useState(""),[Ae,ee]=B.useState("");B.useEffect(()=>{if(t){const w=`Update ${t.path}`;K(w)}},[t]);const Ee=t?t.editedContent!==t.content:!1,be=async w=>{!w.trim()||!t||(await o(w),q(!1))},Te=async()=>{V.trim()&&(await C(V),Y(""),k(!1))},ut=async()=>{se.trim()&&(await x(se,Ae),ae(!1),ee(""))};if(!t)return S.jsx("div",{className:"flex-grow flex items-center justify-center bg-gray-850 text-gray-500",children:S.jsx("p",{children:"Select a file from the explorer to begin editing."})});const yt=t.repoFullName+"::"+t.path,ct=`Update ${t.path}`;return S.jsxs("div",{className:"flex flex-col h-full bg-gray-850 relative",children:[S.jsxs("div",{className:"flex items-center justify-between p-2 border-b border-gray-700 bg-gray-900 flex-wrap gap-2",children:[S.jsxs("div",{children:[S.jsx("h3",{className:"text-md font-semibold text-gray-200",children:t.path}),S.jsx("p",{className:"text-xs text-gray-400",children:t.repoFullName})]}),S.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("select",{id:"branch-select",value:v||"",onChange:w=>E(w.target.value),disabled:y,className:"bg-gray-800 p-2 rounded-md text-sm border border-gray-700 focus:outline-none focus:ring-2 focus:ring-cyan-500",children:h.map(w=>S.jsx("option",{value:w.name,children:w.name},w.name))}),j?S.jsxs("div",{className:"flex gap-2 items-center",children:[S.jsx("input",{type:"text",value:V,onChange:w=>Y(w.target.value),placeholder:"new-branch-name",className:"bg-gray-800 p-2 rounded-md text-sm border border-gray-700 focus:outline-none focus:ring-2 focus:ring-cyan-500"}),S.jsx("button",{onClick:Te,disabled:y||!V.trim(),className:"text-sm bg-cyan-600 text-white font-semibold py-1 px-2 rounded hover:bg-cyan-700 disabled:bg-gray-500",children:"Create"}),S.jsx("button",{onClick:()=>k(!1),className:"text-sm bg-gray-600 text-white font-semibold py-1 px-2 rounded hover:bg-gray-700",children:"X"})]}):S.jsx("button",{onClick:()=>k(!0),className:"text-sm text-cyan-400 hover:underline px-3 py-1.5",disabled:y,children:"New Branch"})]}),S.jsx("button",{onClick:()=>q(!0),disabled:y||!Ee,className:"bg-green-600 text-white font-semibold py-2 px-4 rounded-md hover:bg-green-700 disabled:bg-gray-500 disabled:cursor-not-allowed",children:"Commit Active File"}),v&&v!==t.defaultBranch&&S.jsx("button",{onClick:()=>ae(!Z),className:"bg-cyan-600 text-white font-semibold py-2 px-4 rounded-md hover:bg-cyan-700 disabled:bg-gray-500",disabled:y,children:Z?"Cancel PR":"Create Pull Request"})]})]}),Z&&S.jsxs("div",{className:"p-4 bg-gray-800 border-b border-gray-700",children:[S.jsx("h4",{className:"font-semibold mb-2 text-gray-200",children:"New Pull Request"}),S.jsxs("p",{className:"text-xs text-gray-400 mb-2",children:["From ",S.jsx("code",{className:"bg-gray-700 p-1 rounded-sm text-xs",children:v})," into ",S.jsx("code",{className:"bg-gray-700 p-1 rounded-sm text-xs",children:t.defaultBranch})]}),S.jsx("input",{type:"text",value:se,onChange:w=>K(w.target.value),placeholder:"Pull request title",className:"w-full bg-gray-900 p-2 rounded-md mb-2 text-sm border border-gray-600 focus:outline-none focus:ring-2 focus:ring-cyan-500"}),S.jsx("textarea",{value:Ae,onChange:w=>ee(w.target.value),placeholder:"Describe your changes...",className:"w-full h-24 bg-gray-900 p-2 rounded-md mb-2 text-sm border border-gray-600 focus:outline-none focus:ring-2 focus:ring-cyan-500 resize-none"}),S.jsx("div",{className:"flex gap-2",children:S.jsx("button",{onClick:ut,disabled:y||!se.trim(),className:"text-sm bg-cyan-600 text-white font-semibold py-1 px-2 rounded hover:bg-cyan-700 disabled:bg-gray-500 flex items-center justify-center",children:y?S.jsx(ot,{className:"h-4 w-4"}):"Submit Pull Request"})})]}),S.jsx("div",{className:"flex border-b border-gray-700 bg-gray-900 overflow-x-auto",children:i.map(w=>S.jsx(U0,{file:w,isActive:w.repoFullName+"::"+w.path===yt,onSelect:g,onClose:m},w.repoFullName+"::"+w.path))}),S.jsx("div",{className:"flex-grow p-4",children:S.jsx("textarea",{value:t.editedContent,onChange:w=>f(yt,w.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"},yt)}),S.jsxs("div",{className:"absolute bottom-6 right-6 flex flex-col gap-3",children:[S.jsx("button",{onClick:s,className:"bg-indigo-600 text-white rounded-full p-4 shadow-lg hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-4 focus:ring-offset-gray-850 focus:ring-indigo-500 transition-transform hover:scale-110",title:"Advanced AI Edit (Repository-Aware)","aria-label":"Advanced Edit with AI",children:S.jsx(D0,{className:"h-6 w-6"})}),S.jsx("button",{onClick:u,className:"bg-cyan-600 text-white rounded-full p-4 shadow-lg hover:bg-cyan-700 focus:outline-none focus:ring-2 focus:ring-offset-4 focus:ring-offset-gray-850 focus:ring-cyan-500 transition-transform hover:scale-110",title:"Simple AI Edit (Rewrite Active File)","aria-label":"Simple Rewrite with AI",children:S.jsx(Fu,{className:"h-6 w-6"})})]}),P&&S.jsx(I0,{onClose:()=>q(!1),onCommit:be,isLoading:y,defaultMessage:ct})]})},q0="https://api.github.com";async function Bt(i,t,o={}){var u;const s=await fetch(`${q0}${i}`,{...o,headers:{...o.headers,Authorization:`Bearer ${t}`,Accept:"application/vnd.github.v3+json","X-GitHub-Api-Version":"2022-11-28"}});if(!s.ok){if((u=s.headers.get("content-type"))!=null&&u.includes("text/plain")){const m=await s.text();throw new Error(`GitHub API Error: ${s.status} ${m}`)}const f=await s.json();throw new Error(`GitHub API Error: ${s.status} ${f.message||""}`)}return s.status===204||s.status===201&&!s.body?null:o.headers&&o.headers.Accept==="application/vnd.github.v3.raw"?s.text():s.json()}async function G0(i){let t=[],o=1;const s=100;for(;;){const u=await Bt(`/user/repos?type=owner&per_page=${s}&page=${o}`,i);if(t=t.concat(u),u.length{const t={children:{}};i.forEach(s=>{if(s.type!=="blob")return;const u=s.path.split("/");let f=t.children;u.forEach((m,g)=>{const y=g===u.length-1,h=u.slice(0,g+1).join("/");y?f[m]||(f[m]={type:"file",path:s.path,name:m}):(f[m]||(f[m]={type:"dir",path:h,name:m,children:{}}),f=f[m].children)})});const o=s=>{const u=Object.values(s).map(f=>{if(f.type==="dir"){const m=o(f.children);return{...f,children:m}}return f});return u.sort((f,m)=>f.type!==m.type?f.type==="dir"?-1:1:f.name.localeCompare(m.name)),u};return o(t.children)};async function js(i,t,o,s){const{tree:u}=await Bt(`/repos/${t}/${o}/git/trees/${s}?recursive=1`,i);return H0(u)}async function Fn(i,t,o,s,u){const f=u?`/repos/${t}/${o}/contents/${s}?ref=${u}`:`/repos/${t}/${o}/contents/${s}`,m=await Bt(f,i);return{...m,content:atob(m.content)}}async function Xp(i,t,o){return Bt(`/repos/${t}/${o}/branches?per_page=100`,i)}async function P0(i,t,o,s,u){const f={ref:`refs/heads/${s}`,sha:u};return Bt(`/repos/${t}/${o}/git/refs`,i,{method:"POST",body:JSON.stringify(f),headers:{"Content-Type":"application/json"}})}async function z0({token:i,name:t,description:o,isPrivate:s}){return Bt("/user/repos",i,{method:"POST",body:JSON.stringify({name:t,description:o,private:s,auto_init:!0}),headers:{"Content-Type":"application/json"}})}function V0(i){return btoa(unescape(encodeURIComponent(i)))}async function Dl({token:i,owner:t,repo:o,branch:s,path:u,content:f,message:m,sha:g}){const y={message:m,content:V0(f),...g&&{sha:g},branch:s};return(await Bt(`/repos/${t}/${o}/contents/${u}`,i,{method:"PUT",body:JSON.stringify(y),headers:{"Content-Type":"application/json"}})).content.sha}async function k0({token:i,owner:t,repo:o,title:s,body:u,head:f,base:m}){const g={title:s,body:u,head:f,base:m};return Bt(`/repos/${t}/${o}/pulls`,i,{method:"POST",body:JSON.stringify(g),headers:{"Content-Type":"application/json"}})}async function B0(i,t,o){return Bt(`/repos/${t}/${o}/actions/workflows`,i)}async function F0(i,t,o,s,u){const f={ref:u};return Bt(`/repos/${t}/${o}/actions/workflows/${s}/dispatches`,i,{method:"POST",body:JSON.stringify(f),headers:{"Content-Type":"application/json"}})}async function O0(i,t,o,s,u){return Bt(`/repos/${t}/${o}/actions/workflows/${s}/runs?branch=${encodeURIComponent(u)}`,i)}async function Y0(i,t,o,s){return Bt(`/repos/${t}/${o}/actions/runs/${s}`,i)}async function J0(i,t,o,s){const u=await Bt(`/repos/${t}/${o}/actions/runs/${s}/jobs`,i),f=u.jobs.filter(y=>y.conclusion==="failure"),m=f.length>0?f:u.jobs;let g="";for(const y of m)try{const h=await Bt(`/repos/${t}/${o}/actions/jobs/${y.id}/logs`,i,{headers:{Accept:"application/vnd.github.v3.raw"}});g+=` + +--- LOGS FOR JOB ${y.id} (Conclusion: ${y.conclusion}) --- + +${h}`}catch(h){console.error(`Could not fetch logs for job ${y.id}`,h),g+=` + +--- FAILED TO FETCH LOGS FOR JOB ${y.id} ---`}return g}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */let K0,X0;function Q0(){return{geminiUrl:K0,vertexUrl:X0}}function Z0(i,t,o,s){var u,f;if(!(i!=null&&i.baseUrl)){const m=Q0();return t?(u=m.vertexUrl)!==null&&u!==void 0?u:o:(f=m.geminiUrl)!==null&&f!==void 0?f:s}return i.baseUrl}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class Yn{}function $(i,t){const o=/\{([^}]+)\}/g;return i.replace(o,(s,u)=>{if(Object.prototype.hasOwnProperty.call(t,u)){const f=t[u];return f!=null?String(f):""}else throw new Error(`Key '${u}' not found in valueMap.`)})}function c(i,t,o){for(let f=0;f({}));else throw new Error(`Value must be a list given an array path ${m}`);if(Array.isArray(i[g])){const y=i[g];if(Array.isArray(o))for(let h=0;hr(g,t.slice(s+1),o)):o}else return o}else i=i[u]}return i}catch(s){if(s instanceof TypeError)return o;throw s}}function $0(i,t){for(const[o,s]of Object.entries(t)){const u=o.split("."),f=s.split("."),m=new Set;let g=-1;for(let y=0;yg)for(let y=g;y=t.length||typeof i!="object"||i===null)return;const f=t[s];if(f.endsWith("[]")){const m=f.slice(0,-2),g=i;if(m in g&&Array.isArray(g[m]))for(const y of g[m])Uu(y,t,o,s+1,u)}else if(f==="*"){if(typeof i=="object"&&i!==null&&!Array.isArray(i)){const m=i,g=Object.keys(m).filter(h=>!h.startsWith("_")&&!u.has(h)),y={};for(const h of g)y[h]=m[h];for(const[h,v]of Object.entries(y)){const E=[];for(const C of o.slice(s))C==="*"?E.push(h):E.push(C);c(m,E,v)}for(const h of g)delete m[h]}}else{const m=i;f in m&&Uu(m[f],t,o,s+1,u)}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function Ou(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 W0(i){const t={},o=r(i,["operationName"]);o!=null&&c(t,["operationName"],o);const s=r(i,["resourceName"]);return s!=null&&c(t,["_url","resourceName"],s),t}function j0(i){const t={},o=r(i,["name"]);o!=null&&c(t,["name"],o);const s=r(i,["metadata"]);s!=null&&c(t,["metadata"],s);const u=r(i,["done"]);u!=null&&c(t,["done"],u);const f=r(i,["error"]);f!=null&&c(t,["error"],f);const m=r(i,["response","generateVideoResponse"]);return m!=null&&c(t,["response"],tv(m)),t}function ev(i){const t={},o=r(i,["name"]);o!=null&&c(t,["name"],o);const s=r(i,["metadata"]);s!=null&&c(t,["metadata"],s);const u=r(i,["done"]);u!=null&&c(t,["done"],u);const f=r(i,["error"]);f!=null&&c(t,["error"],f);const m=r(i,["response"]);return m!=null&&c(t,["response"],nv(m)),t}function tv(i){const t={},o=r(i,["generatedSamples"]);if(o!=null){let f=o;Array.isArray(f)&&(f=f.map(m=>iv(m))),c(t,["generatedVideos"],f)}const s=r(i,["raiMediaFilteredCount"]);s!=null&&c(t,["raiMediaFilteredCount"],s);const u=r(i,["raiMediaFilteredReasons"]);return u!=null&&c(t,["raiMediaFilteredReasons"],u),t}function nv(i){const t={},o=r(i,["videos"]);if(o!=null){let f=o;Array.isArray(f)&&(f=f.map(m=>lv(m))),c(t,["generatedVideos"],f)}const s=r(i,["raiMediaFilteredCount"]);s!=null&&c(t,["raiMediaFilteredCount"],s);const u=r(i,["raiMediaFilteredReasons"]);return u!=null&&c(t,["raiMediaFilteredReasons"],u),t}function iv(i){const t={},o=r(i,["video"]);return o!=null&&c(t,["video"],cv(o)),t}function lv(i){const t={},o=r(i,["_self"]);return o!=null&&c(t,["video"],fv(o)),t}function ov(i){const t={},o=r(i,["operationName"]);return o!=null&&c(t,["_url","operationName"],o),t}function sv(i){const t={},o=r(i,["operationName"]);return o!=null&&c(t,["_url","operationName"],o),t}function av(i){const t={},o=r(i,["name"]);o!=null&&c(t,["name"],o);const s=r(i,["metadata"]);s!=null&&c(t,["metadata"],s);const u=r(i,["done"]);u!=null&&c(t,["done"],u);const f=r(i,["error"]);f!=null&&c(t,["error"],f);const m=r(i,["response"]);return m!=null&&c(t,["response"],rv(m)),t}function rv(i){const t={},o=r(i,["sdkHttpResponse"]);o!=null&&c(t,["sdkHttpResponse"],o);const s=r(i,["parent"]);s!=null&&c(t,["parent"],s);const u=r(i,["documentName"]);return u!=null&&c(t,["documentName"],u),t}function wh(i){const t={},o=r(i,["name"]);o!=null&&c(t,["name"],o);const s=r(i,["metadata"]);s!=null&&c(t,["metadata"],s);const u=r(i,["done"]);u!=null&&c(t,["done"],u);const f=r(i,["error"]);f!=null&&c(t,["error"],f);const m=r(i,["response"]);return m!=null&&c(t,["response"],uv(m)),t}function uv(i){const t={},o=r(i,["sdkHttpResponse"]);o!=null&&c(t,["sdkHttpResponse"],o);const s=r(i,["parent"]);s!=null&&c(t,["parent"],s);const u=r(i,["documentName"]);return u!=null&&c(t,["documentName"],u),t}function cv(i){const t={},o=r(i,["uri"]);o!=null&&c(t,["uri"],o);const s=r(i,["encodedVideo"]);s!=null&&c(t,["videoBytes"],Ou(s));const u=r(i,["encoding"]);return u!=null&&c(t,["mimeType"],u),t}function fv(i){const t={},o=r(i,["gcsUri"]);o!=null&&c(t,["uri"],o);const s=r(i,["bytesBase64Encoded"]);s!=null&&c(t,["videoBytes"],Ou(s));const u=r(i,["mimeType"]);return u!=null&&c(t,["mimeType"],u),t}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */var Qp;(function(i){i.OUTCOME_UNSPECIFIED="OUTCOME_UNSPECIFIED",i.OUTCOME_OK="OUTCOME_OK",i.OUTCOME_FAILED="OUTCOME_FAILED",i.OUTCOME_DEADLINE_EXCEEDED="OUTCOME_DEADLINE_EXCEEDED"})(Qp||(Qp={}));var Zp;(function(i){i.LANGUAGE_UNSPECIFIED="LANGUAGE_UNSPECIFIED",i.PYTHON="PYTHON"})(Zp||(Zp={}));var $p;(function(i){i.SCHEDULING_UNSPECIFIED="SCHEDULING_UNSPECIFIED",i.SILENT="SILENT",i.WHEN_IDLE="WHEN_IDLE",i.INTERRUPT="INTERRUPT"})($p||($p={}));var De;(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"})(De||(De={}));var Wp;(function(i){i.MODE_UNSPECIFIED="MODE_UNSPECIFIED",i.MODE_DYNAMIC="MODE_DYNAMIC"})(Wp||(Wp={}));var jp;(function(i){i.API_SPEC_UNSPECIFIED="API_SPEC_UNSPECIFIED",i.SIMPLE_SEARCH="SIMPLE_SEARCH",i.ELASTIC_SEARCH="ELASTIC_SEARCH"})(jp||(jp={}));var em;(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"})(em||(em={}));var tm;(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"})(tm||(tm={}));var nm;(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"})(nm||(nm={}));var im;(function(i){i.THINKING_LEVEL_UNSPECIFIED="THINKING_LEVEL_UNSPECIFIED",i.LOW="LOW",i.HIGH="HIGH"})(im||(im={}));var lm;(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"})(lm||(lm={}));var om;(function(i){i.HARM_BLOCK_METHOD_UNSPECIFIED="HARM_BLOCK_METHOD_UNSPECIFIED",i.SEVERITY="SEVERITY",i.PROBABILITY="PROBABILITY"})(om||(om={}));var sm;(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"})(sm||(sm={}));var am;(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"})(am||(am={}));var rm;(function(i){i.HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",i.NEGLIGIBLE="NEGLIGIBLE",i.LOW="LOW",i.MEDIUM="MEDIUM",i.HIGH="HIGH"})(rm||(rm={}));var um;(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"})(um||(um={}));var cm;(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"})(cm||(cm={}));var fm;(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"})(fm||(fm={}));var dm;(function(i){i.TRAFFIC_TYPE_UNSPECIFIED="TRAFFIC_TYPE_UNSPECIFIED",i.ON_DEMAND="ON_DEMAND",i.PROVISIONED_THROUGHPUT="PROVISIONED_THROUGHPUT"})(dm||(dm={}));var na;(function(i){i.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",i.TEXT="TEXT",i.IMAGE="IMAGE",i.AUDIO="AUDIO"})(na||(na={}));var pm;(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"})(pm||(pm={}));var mm;(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"})(mm||(mm={}));var hm;(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"})(hm||(hm={}));var Lu;(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"})(Lu||(Lu={}));var gm;(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"})(gm||(gm={}));var ym;(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"})(ym||(ym={}));var vm;(function(i){i.FEATURE_SELECTION_PREFERENCE_UNSPECIFIED="FEATURE_SELECTION_PREFERENCE_UNSPECIFIED",i.PRIORITIZE_QUALITY="PRIORITIZE_QUALITY",i.BALANCED="BALANCED",i.PRIORITIZE_COST="PRIORITIZE_COST"})(vm||(vm={}));var Tm;(function(i){i.UNSPECIFIED="UNSPECIFIED",i.BLOCKING="BLOCKING",i.NON_BLOCKING="NON_BLOCKING"})(Tm||(Tm={}));var Sm;(function(i){i.MODE_UNSPECIFIED="MODE_UNSPECIFIED",i.MODE_DYNAMIC="MODE_DYNAMIC"})(Sm||(Sm={}));var Em;(function(i){i.ENVIRONMENT_UNSPECIFIED="ENVIRONMENT_UNSPECIFIED",i.ENVIRONMENT_BROWSER="ENVIRONMENT_BROWSER"})(Em||(Em={}));var Cm;(function(i){i.MODE_UNSPECIFIED="MODE_UNSPECIFIED",i.AUTO="AUTO",i.ANY="ANY",i.NONE="NONE",i.VALIDATED="VALIDATED"})(Cm||(Cm={}));var _m;(function(i){i.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",i.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",i.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",i.BLOCK_NONE="BLOCK_NONE"})(_m||(_m={}));var Am;(function(i){i.DONT_ALLOW="DONT_ALLOW",i.ALLOW_ADULT="ALLOW_ADULT",i.ALLOW_ALL="ALLOW_ALL"})(Am||(Am={}));var xm;(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"})(xm||(xm={}));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 Rm;(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"})(Rm||(Rm={}));var Mm;(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"})(Mm||(Mm={}));var wm;(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"})(wm||(wm={}));var bm;(function(i){i.FOREGROUND="FOREGROUND",i.BACKGROUND="BACKGROUND",i.PROMPT="PROMPT",i.SEMANTIC="SEMANTIC",i.INTERACTIVE="INTERACTIVE"})(bm||(bm={}));var Im;(function(i){i.ASSET="ASSET",i.STYLE="STYLE"})(Im||(Im={}));var Dm;(function(i){i.INSERT="INSERT",i.REMOVE="REMOVE",i.REMOVE_STATIC="REMOVE_STATIC",i.OUTPAINT="OUTPAINT"})(Dm||(Dm={}));var Um;(function(i){i.OPTIMIZED="OPTIMIZED",i.LOSSLESS="LOSSLESS"})(Um||(Um={}));var Lm;(function(i){i.SUPERVISED_FINE_TUNING="SUPERVISED_FINE_TUNING",i.PREFERENCE_TUNING="PREFERENCE_TUNING"})(Lm||(Lm={}));var qm;(function(i){i.STATE_UNSPECIFIED="STATE_UNSPECIFIED",i.STATE_PENDING="STATE_PENDING",i.STATE_ACTIVE="STATE_ACTIVE",i.STATE_FAILED="STATE_FAILED"})(qm||(qm={}));var Gm;(function(i){i.STATE_UNSPECIFIED="STATE_UNSPECIFIED",i.PROCESSING="PROCESSING",i.ACTIVE="ACTIVE",i.FAILED="FAILED"})(Gm||(Gm={}));var Hm;(function(i){i.SOURCE_UNSPECIFIED="SOURCE_UNSPECIFIED",i.UPLOADED="UPLOADED",i.GENERATED="GENERATED"})(Hm||(Hm={}));var Pm;(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"})(Pm||(Pm={}));var zm;(function(i){i.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",i.TEXT="TEXT",i.IMAGE="IMAGE",i.VIDEO="VIDEO",i.AUDIO="AUDIO",i.DOCUMENT="DOCUMENT"})(zm||(zm={}));var Vm;(function(i){i.START_SENSITIVITY_UNSPECIFIED="START_SENSITIVITY_UNSPECIFIED",i.START_SENSITIVITY_HIGH="START_SENSITIVITY_HIGH",i.START_SENSITIVITY_LOW="START_SENSITIVITY_LOW"})(Vm||(Vm={}));var km;(function(i){i.END_SENSITIVITY_UNSPECIFIED="END_SENSITIVITY_UNSPECIFIED",i.END_SENSITIVITY_HIGH="END_SENSITIVITY_HIGH",i.END_SENSITIVITY_LOW="END_SENSITIVITY_LOW"})(km||(km={}));var Bm;(function(i){i.ACTIVITY_HANDLING_UNSPECIFIED="ACTIVITY_HANDLING_UNSPECIFIED",i.START_OF_ACTIVITY_INTERRUPTS="START_OF_ACTIVITY_INTERRUPTS",i.NO_INTERRUPTION="NO_INTERRUPTION"})(Bm||(Bm={}));var Fm;(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"})(Fm||(Fm={}));var Om;(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"})(Om||(Om={}));var Ym;(function(i){i.MUSIC_GENERATION_MODE_UNSPECIFIED="MUSIC_GENERATION_MODE_UNSPECIFIED",i.QUALITY="QUALITY",i.DIVERSITY="DIVERSITY",i.VOCALIZATION="VOCALIZATION"})(Ym||(Ym={}));var Ll;(function(i){i.PLAYBACK_CONTROL_UNSPECIFIED="PLAYBACK_CONTROL_UNSPECIFIED",i.PLAY="PLAY",i.PAUSE="PAUSE",i.STOP="STOP",i.RESET_CONTEXT="RESET_CONTEXT"})(Ll||(Ll={}));class qu{constructor(t){const o={};for(const s of t.headers.entries())o[s[0]]=s[1];this.headers=o,this.responseInternal=t}json(){return this.responseInternal.json()}}class qo{get text(){var t,o,s,u,f,m,g,y;if(((u=(s=(o=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||o===void 0?void 0:o.content)===null||s===void 0?void 0:s.parts)===null||u===void 0?void 0:u.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning text from the first one.");let h="",v=!1;const E=[];for(const C of(y=(g=(m=(f=this.candidates)===null||f===void 0?void 0:f[0])===null||m===void 0?void 0:m.content)===null||g===void 0?void 0:g.parts)!==null&&y!==void 0?y:[]){for(const[x,P]of Object.entries(C))x!=="text"&&x!=="thought"&&x!=="thoughtSignature"&&(P!==null||P!==void 0)&&E.push(x);if(typeof C.text=="string"){if(typeof C.thought=="boolean"&&C.thought)continue;v=!0,h+=C.text}}return E.length>0&&console.warn(`there are non-text parts ${E} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),v?h:void 0}get data(){var t,o,s,u,f,m,g,y;if(((u=(s=(o=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||o===void 0?void 0:o.content)===null||s===void 0?void 0:s.parts)===null||u===void 0?void 0:u.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning data from the first one.");let h="";const v=[];for(const E of(y=(g=(m=(f=this.candidates)===null||f===void 0?void 0:f[0])===null||m===void 0?void 0:m.content)===null||g===void 0?void 0:g.parts)!==null&&y!==void 0?y:[]){for(const[C,x]of Object.entries(E))C!=="inlineData"&&(x!==null||x!==void 0)&&v.push(C);E.inlineData&&typeof E.inlineData.data=="string"&&(h+=atob(E.inlineData.data))}return v.length>0&&console.warn(`there are non-data parts ${v} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),h.length>0?btoa(h):void 0}get functionCalls(){var t,o,s,u,f,m,g,y;if(((u=(s=(o=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||o===void 0?void 0:o.content)===null||s===void 0?void 0:s.parts)===null||u===void 0?void 0:u.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning function calls from the first one.");const h=(y=(g=(m=(f=this.candidates)===null||f===void 0?void 0:f[0])===null||m===void 0?void 0:m.content)===null||g===void 0?void 0:g.parts)===null||y===void 0?void 0:y.filter(v=>v.functionCall).map(v=>v.functionCall).filter(v=>v!==void 0);if((h==null?void 0:h.length)!==0)return h}get executableCode(){var t,o,s,u,f,m,g,y,h;if(((u=(s=(o=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||o===void 0?void 0:o.content)===null||s===void 0?void 0:s.parts)===null||u===void 0?void 0:u.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning executable code from the first one.");const v=(y=(g=(m=(f=this.candidates)===null||f===void 0?void 0:f[0])===null||m===void 0?void 0:m.content)===null||g===void 0?void 0:g.parts)===null||y===void 0?void 0:y.filter(E=>E.executableCode).map(E=>E.executableCode).filter(E=>E!==void 0);if((v==null?void 0:v.length)!==0)return(h=v==null?void 0:v[0])===null||h===void 0?void 0:h.code}get codeExecutionResult(){var t,o,s,u,f,m,g,y,h;if(((u=(s=(o=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||o===void 0?void 0:o.content)===null||s===void 0?void 0:s.parts)===null||u===void 0?void 0:u.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning code execution result from the first one.");const v=(y=(g=(m=(f=this.candidates)===null||f===void 0?void 0:f[0])===null||m===void 0?void 0:m.content)===null||g===void 0?void 0:g.parts)===null||y===void 0?void 0:y.filter(E=>E.codeExecutionResult).map(E=>E.codeExecutionResult).filter(E=>E!==void 0);if((v==null?void 0:v.length)!==0)return(h=v==null?void 0:v[0])===null||h===void 0?void 0:h.output}}class Jm{}class Km{}class dv{}class pv{}class mv{}class hv{}class Xm{}class Qm{}class Zm{}class gv{}class ia{_fromAPIResponse({apiResponse:t,_isVertexAI:o}){const s=new ia;let u;const f=t;return o?u=ev(f):u=j0(f),Object.assign(s,u),s}}class $m{}class Wm{}class jm{}class eh{}class yv{}class vv{}class Tv{}class Yu{_fromAPIResponse({apiResponse:t,_isVertexAI:o}){const s=new Yu,f=av(t);return Object.assign(s,f),s}}class Sv{}class Ev{}class Cv{}class th{}class _v{get text(){var t,o,s;let u="",f=!1;const m=[];for(const g of(s=(o=(t=this.serverContent)===null||t===void 0?void 0:t.modelTurn)===null||o===void 0?void 0:o.parts)!==null&&s!==void 0?s:[]){for(const[y,h]of Object.entries(g))y!=="text"&&y!=="thought"&&h!==null&&m.push(y);if(typeof g.text=="string"){if(typeof g.thought=="boolean"&&g.thought)continue;f=!0,u+=g.text}}return m.length>0&&console.warn(`there are non-text parts ${m} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),f?u:void 0}get data(){var t,o,s;let u="";const f=[];for(const m of(s=(o=(t=this.serverContent)===null||t===void 0?void 0:t.modelTurn)===null||o===void 0?void 0:o.parts)!==null&&s!==void 0?s:[]){for(const[g,y]of Object.entries(m))g!=="inlineData"&&y!==null&&f.push(g);m.inlineData&&typeof m.inlineData.data=="string"&&(u+=atob(m.inlineData.data))}return f.length>0&&console.warn(`there are non-data parts ${f} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),u.length>0?btoa(u):void 0}}class Av{get audioChunk(){if(this.serverContent&&this.serverContent.audioChunks&&this.serverContent.audioChunks.length>0)return this.serverContent.audioChunks[0]}}class Ju{_fromAPIResponse({apiResponse:t,_isVertexAI:o}){const s=new Ju,f=wh(t);return Object.assign(s,f),s}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function ke(i,t){if(!t||typeof t!="string")throw new Error("model is required and must be a string");if(t.includes("..")||t.includes("?")||t.includes("&"))throw new Error("invalid model parameter");if(i.isVertexAI()){if(t.startsWith("publishers/")||t.startsWith("projects/")||t.startsWith("models/"))return t;if(t.indexOf("/")>=0){const o=t.split("/",2);return`publishers/${o[0]}/models/${o[1]}`}else return`publishers/google/models/${t}`}else return t.startsWith("models/")||t.startsWith("tunedModels/")?t:`models/${t}`}function bh(i,t){const o=ke(i,t);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(t=>la(t)):[la(i)]}function la(i){if(typeof i=="object"&&i!==null)return i;throw new Error(`Could not parse input as Blob. Unsupported blob type: ${typeof i}`)}function Dh(i){const t=la(i);if(t.mimeType&&t.mimeType.startsWith("image/"))return t;throw new Error(`Unsupported mime type: ${t.mimeType}`)}function Uh(i){const t=la(i);if(t.mimeType&&t.mimeType.startsWith("audio/"))return t;throw new Error(`Unsupported mime type: ${t.mimeType}`)}function nh(i){if(i==null)throw new Error("PartUnion is required");if(typeof i=="object")return i;if(typeof i=="string")return{text:i};throw new Error(`Unsupported part type: ${typeof i}`)}function Lh(i){if(i==null||Array.isArray(i)&&i.length===0)throw new Error("PartListUnion is required");return Array.isArray(i)?i.map(t=>nh(t)):[nh(i)]}function Gu(i){return i!=null&&typeof i=="object"&&"parts"in i&&Array.isArray(i.parts)}function ih(i){return i!=null&&typeof i=="object"&&"functionCall"in i}function lh(i){return i!=null&&typeof i=="object"&&"functionResponse"in i}function It(i){if(i==null)throw new Error("ContentUnion is required");return Gu(i)?i:{role:"user",parts:Lh(i)}}function Ku(i,t){if(!t)return[];if(i.isVertexAI()&&Array.isArray(t))return t.flatMap(o=>{const s=It(o);return s.parts&&s.parts.length>0&&s.parts[0].text!==void 0?[s.parts[0].text]:[]});if(i.isVertexAI()){const o=It(t);return o.parts&&o.parts.length>0&&o.parts[0].text!==void 0?[o.parts[0].text]:[]}return Array.isArray(t)?t.map(o=>It(o)):[It(t)]}function rn(i){if(i==null||Array.isArray(i)&&i.length===0)throw new Error("contents are required");if(!Array.isArray(i)){if(ih(i)||lh(i))throw new Error("To specify functionCall or functionResponse parts, please wrap them in a Content object, specifying the role for them");return[It(i)]}const t=[],o=[],s=Gu(i[0]);for(const u of i){const f=Gu(u);if(f!=s)throw new Error("Mixing Content and Parts is not supported, please group the parts into a the appropriate Content objects and specify the roles for them");if(f)t.push(u);else{if(ih(u)||lh(u))throw new Error("To specify functionCall or functionResponse parts, please wrap them, and any other parts, in Content objects as appropriate, specifying the role for them");o.push(u)}}return s||t.push({role:"user",parts:Lh(o)}),t}function xv(i,t){i.includes("null")&&(t.nullable=!0);const o=i.filter(s=>s!=="null");if(o.length===1)t.type=Object.values(De).includes(o[0].toUpperCase())?o[0].toUpperCase():De.TYPE_UNSPECIFIED;else{t.anyOf=[];for(const s of o)t.anyOf.push({type:Object.values(De).includes(s.toUpperCase())?s.toUpperCase():De.TYPE_UNSPECIFIED})}}function ql(i){const t={},o=["items"],s=["anyOf"],u=["properties"];if(i.type&&i.anyOf)throw new Error("type and anyOf cannot be both populated.");const f=i.anyOf;f!=null&&f.length==2&&(f[0].type==="null"?(t.nullable=!0,i=f[1]):f[1].type==="null"&&(t.nullable=!0,i=f[0])),i.type instanceof Array&&xv(i.type,t);for(const[m,g]of Object.entries(i))if(g!=null)if(m=="type"){if(g==="null")throw new Error("type: null can not be the only possible type for the field.");if(g instanceof Array)continue;t.type=Object.values(De).includes(g.toUpperCase())?g.toUpperCase():De.TYPE_UNSPECIFIED}else if(o.includes(m))t[m]=ql(g);else if(s.includes(m)){const y=[];for(const h of g){if(h.type=="null"){t.nullable=!0;continue}y.push(ql(h))}t[m]=y}else if(u.includes(m)){const y={};for(const[h,v]of Object.entries(g))y[h]=ql(v);t[m]=y}else{if(m==="additionalProperties")continue;t[m]=g}return t}function Xu(i){return ql(i)}function Qu(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 Zu(i){if("multiSpeakerVoiceConfig"in i)throw new Error("multiSpeakerVoiceConfig is not supported in the live API.");return i}function Pl(i){if(i.functionDeclarations)for(const t of i.functionDeclarations)t.parameters&&(Object.keys(t.parameters).includes("$schema")?t.parametersJsonSchema||(t.parametersJsonSchema=t.parameters,delete t.parameters):t.parameters=ql(t.parameters)),t.response&&(Object.keys(t.response).includes("$schema")?t.responseJsonSchema||(t.responseJsonSchema=t.response,delete t.response):t.response=ql(t.response));return i}function zl(i){if(i==null)throw new Error("tools is required");if(!Array.isArray(i))throw new Error("tools is required and must be an array of Tools");const t=[];for(const o of i)t.push(o);return t}function Nv(i,t,o,s=1){const u=!t.startsWith(`${o}/`)&&t.split("/").length===s;return i.isVertexAI()?t.startsWith("projects/")?t:t.startsWith("locations/")?`projects/${i.getProject()}/${t}`:t.startsWith(`${o}/`)?`projects/${i.getProject()}/locations/${i.getLocation()}/${t}`:u?`projects/${i.getProject()}/locations/${i.getLocation()}/${o}/${t}`:t:u?`${o}/${t}`:t}function Jn(i,t){if(typeof t!="string")throw new Error("name must be a string");return Nv(i,t,"cachedContents")}function qh(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 _i(i){return Ou(i)}function Rv(i){return i!=null&&typeof i=="object"&&"name"in i}function Mv(i){return i!=null&&typeof i=="object"&&"video"in i}function wv(i){return i!=null&&typeof i=="object"&&"uri"in i}function Gh(i){var t;let o;if(Rv(i)&&(o=i.name),!(wv(i)&&(o=i.uri,o===void 0))&&!(Mv(i)&&(o=(t=i.video)===null||t===void 0?void 0:t.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 u=o.split("files/")[1].match(/[a-z0-9]+/);if(u===null)throw new Error(`Could not extract file name from URI ${o}`);o=u[0]}else o.startsWith("files/")&&(o=o.split("files/")[1]);return o}}function Hh(i,t){let o;return i.isVertexAI()?o=t?"publishers/google/models":"models":o=t?"models":"tunedModels",o}function Ph(i){for(const t of["models","tunedModels","publisherModels"])if(bv(i,t))return i[t];return[]}function bv(i,t){return i!==null&&typeof i=="object"&&t in i}function Iv(i,t={}){const o=i,s={name:o.name,description:o.description,parametersJsonSchema:o.inputSchema};return o.outputSchema&&(s.responseJsonSchema=o.outputSchema),t.behavior&&(s.behavior=t.behavior),{functionDeclarations:[s]}}function Dv(i,t={}){const o=[],s=new Set;for(const u of i){const f=u.name;if(s.has(f))throw new Error(`Duplicate function name ${f} found in MCP tools. Please ensure function names are unique.`);s.add(f);const m=Iv(u,t);m.functionDeclarations&&o.push(...m.functionDeclarations)}return{functionDeclarations:o}}function zh(i,t){let o;if(typeof t=="string")if(i.isVertexAI())if(t.startsWith("gs://"))o={format:"jsonl",gcsUri:[t]};else if(t.startsWith("bq://"))o={format:"bigquery",bigqueryUri:t};else throw new Error(`Unsupported string source for Vertex AI: ${t}`);else if(t.startsWith("files/"))o={fileName:t};else throw new Error(`Unsupported string source for Gemini API: ${t}`);else if(Array.isArray(t)){if(i.isVertexAI())throw new Error("InlinedRequest[] is not supported in Vertex AI.");o={inlinedRequests:t}}else o=t;const s=[o.gcsUri,o.bigqueryUri].filter(Boolean).length,u=[o.inlinedRequests,o.fileName].filter(Boolean).length;if(i.isVertexAI()){if(u>0||s!==1)throw new Error("Exactly one of `gcsUri` or `bigqueryUri` must be set for Vertex AI.")}else if(s>0||u!==1)throw new Error("Exactly one of `inlinedRequests`, `fileName`, must be set for Gemini API.");return o}function Uv(i){if(typeof i!="string")return i;const t=i;if(t.startsWith("gs://"))return{format:"jsonl",gcsUri:t};if(t.startsWith("bq://"))return{format:"bigquery",bigqueryUri:t};throw new Error(`Unsupported destination: ${t}`)}function Vh(i){if(typeof i!="object"||i===null)return{};const t=i,o=t.inlinedResponses;if(typeof o!="object"||o===null)return i;const u=o.inlinedResponses;if(!Array.isArray(u)||u.length===0)return i;let f=!1;for(const m of u){if(typeof m!="object"||m===null)continue;const y=m.response;if(typeof y!="object"||y===null)continue;if(y.embedding!==void 0){f=!0;break}}return f&&(t.inlinedEmbedContentResponses=t.inlinedResponses,delete t.inlinedResponses),i}function Vl(i,t){const o=t;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 kh(i){const t=i;return t==="BATCH_STATE_UNSPECIFIED"?"JOB_STATE_UNSPECIFIED":t==="BATCH_STATE_PENDING"?"JOB_STATE_PENDING":t==="BATCH_STATE_RUNNING"?"JOB_STATE_RUNNING":t==="BATCH_STATE_SUCCEEDED"?"JOB_STATE_SUCCEEDED":t==="BATCH_STATE_FAILED"?"JOB_STATE_FAILED":t==="BATCH_STATE_CANCELLED"?"JOB_STATE_CANCELLED":t==="BATCH_STATE_EXPIRED"?"JOB_STATE_EXPIRED":t}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function Lv(i){const t={},o=r(i,["responsesFile"]);o!=null&&c(t,["fileName"],o);const s=r(i,["inlinedResponses","inlinedResponses"]);if(s!=null){let f=s;Array.isArray(f)&&(f=f.map(m=>mT(m))),c(t,["inlinedResponses"],f)}const u=r(i,["inlinedEmbedContentResponses","inlinedResponses"]);if(u!=null){let f=u;Array.isArray(f)&&(f=f.map(m=>m)),c(t,["inlinedEmbedContentResponses"],f)}return t}function qv(i){const t={},o=r(i,["predictionsFormat"]);o!=null&&c(t,["format"],o);const s=r(i,["gcsDestination","outputUriPrefix"]);s!=null&&c(t,["gcsUri"],s);const u=r(i,["bigqueryDestination","outputUri"]);return u!=null&&c(t,["bigqueryUri"],u),t}function Gv(i){const t={},o=r(i,["format"]);o!=null&&c(t,["predictionsFormat"],o);const s=r(i,["gcsUri"]);s!=null&&c(t,["gcsDestination","outputUriPrefix"],s);const u=r(i,["bigqueryUri"]);if(u!=null&&c(t,["bigqueryDestination","outputUri"],u),r(i,["fileName"])!==void 0)throw new Error("fileName parameter is not supported in Vertex AI.");if(r(i,["inlinedResponses"])!==void 0)throw new Error("inlinedResponses parameter is not supported in Vertex AI.");if(r(i,["inlinedEmbedContentResponses"])!==void 0)throw new Error("inlinedEmbedContentResponses parameter is not supported in Vertex AI.");return t}function ea(i){const t={},o=r(i,["name"]);o!=null&&c(t,["name"],o);const s=r(i,["metadata","displayName"]);s!=null&&c(t,["displayName"],s);const u=r(i,["metadata","state"]);u!=null&&c(t,["state"],kh(u));const f=r(i,["metadata","createTime"]);f!=null&&c(t,["createTime"],f);const m=r(i,["metadata","endTime"]);m!=null&&c(t,["endTime"],m);const g=r(i,["metadata","updateTime"]);g!=null&&c(t,["updateTime"],g);const y=r(i,["metadata","model"]);y!=null&&c(t,["model"],y);const h=r(i,["metadata","output"]);return h!=null&&c(t,["dest"],Lv(Vh(h))),t}function Hu(i){const t={},o=r(i,["name"]);o!=null&&c(t,["name"],o);const s=r(i,["displayName"]);s!=null&&c(t,["displayName"],s);const u=r(i,["state"]);u!=null&&c(t,["state"],kh(u));const f=r(i,["error"]);f!=null&&c(t,["error"],f);const m=r(i,["createTime"]);m!=null&&c(t,["createTime"],m);const g=r(i,["startTime"]);g!=null&&c(t,["startTime"],g);const y=r(i,["endTime"]);y!=null&&c(t,["endTime"],y);const h=r(i,["updateTime"]);h!=null&&c(t,["updateTime"],h);const v=r(i,["model"]);v!=null&&c(t,["model"],v);const E=r(i,["inputConfig"]);E!=null&&c(t,["src"],Hv(E));const C=r(i,["outputConfig"]);C!=null&&c(t,["dest"],qv(Vh(C)));const x=r(i,["completionStats"]);return x!=null&&c(t,["completionStats"],x),t}function Hv(i){const t={},o=r(i,["instancesFormat"]);o!=null&&c(t,["format"],o);const s=r(i,["gcsSource","uris"]);s!=null&&c(t,["gcsUri"],s);const u=r(i,["bigquerySource","inputUri"]);return u!=null&&c(t,["bigqueryUri"],u),t}function Pv(i,t){const o={};if(r(t,["format"])!==void 0)throw new Error("format parameter is not supported in Gemini API.");if(r(t,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");if(r(t,["bigqueryUri"])!==void 0)throw new Error("bigqueryUri parameter is not supported in Gemini API.");const s=r(t,["fileName"]);s!=null&&c(o,["fileName"],s);const u=r(t,["inlinedRequests"]);if(u!=null){let f=u;Array.isArray(f)&&(f=f.map(m=>pT(i,m))),c(o,["requests","requests"],f)}return o}function zv(i){const t={},o=r(i,["format"]);o!=null&&c(t,["instancesFormat"],o);const s=r(i,["gcsUri"]);s!=null&&c(t,["gcsSource","uris"],s);const u=r(i,["bigqueryUri"]);if(u!=null&&c(t,["bigquerySource","inputUri"],u),r(i,["fileName"])!==void 0)throw new Error("fileName parameter is not supported in Vertex AI.");if(r(i,["inlinedRequests"])!==void 0)throw new Error("inlinedRequests parameter is not supported in Vertex AI.");return t}function Vv(i){const t={},o=r(i,["data"]);if(o!=null&&c(t,["data"],o),r(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const s=r(i,["mimeType"]);return s!=null&&c(t,["mimeType"],s),t}function kv(i,t){const o={},s=r(t,["name"]);return s!=null&&c(o,["_url","name"],Vl(i,s)),o}function Bv(i,t){const o={},s=r(t,["name"]);return s!=null&&c(o,["_url","name"],Vl(i,s)),o}function Fv(i){const t={},o=r(i,["content"]);o!=null&&c(t,["content"],o);const s=r(i,["citationMetadata"]);s!=null&&c(t,["citationMetadata"],Ov(s));const u=r(i,["tokenCount"]);u!=null&&c(t,["tokenCount"],u);const f=r(i,["finishReason"]);f!=null&&c(t,["finishReason"],f);const m=r(i,["avgLogprobs"]);m!=null&&c(t,["avgLogprobs"],m);const g=r(i,["groundingMetadata"]);g!=null&&c(t,["groundingMetadata"],g);const y=r(i,["index"]);y!=null&&c(t,["index"],y);const h=r(i,["logprobsResult"]);h!=null&&c(t,["logprobsResult"],h);const v=r(i,["safetyRatings"]);if(v!=null){let C=v;Array.isArray(C)&&(C=C.map(x=>x)),c(t,["safetyRatings"],C)}const E=r(i,["urlContextMetadata"]);return E!=null&&c(t,["urlContextMetadata"],E),t}function Ov(i){const t={},o=r(i,["citationSources"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(u=>u)),c(t,["citations"],s)}return t}function Bh(i){const t={},o=r(i,["parts"]);if(o!=null){let u=o;Array.isArray(u)&&(u=u.map(f=>ET(f))),c(t,["parts"],u)}const s=r(i,["role"]);return s!=null&&c(t,["role"],s),t}function Yv(i,t){const o={},s=r(i,["displayName"]);if(t!==void 0&&s!=null&&c(t,["batch","displayName"],s),r(i,["dest"])!==void 0)throw new Error("dest parameter is not supported in Gemini API.");return o}function Jv(i,t){const o={},s=r(i,["displayName"]);t!==void 0&&s!=null&&c(t,["displayName"],s);const u=r(i,["dest"]);return t!==void 0&&u!=null&&c(t,["outputConfig"],Gv(Uv(u))),o}function oh(i,t){const o={},s=r(t,["model"]);s!=null&&c(o,["_url","model"],ke(i,s));const u=r(t,["src"]);u!=null&&c(o,["batch","inputConfig"],Pv(i,zh(i,u)));const f=r(t,["config"]);return f!=null&&Yv(f,o),o}function Kv(i,t){const o={},s=r(t,["model"]);s!=null&&c(o,["model"],ke(i,s));const u=r(t,["src"]);u!=null&&c(o,["inputConfig"],zv(zh(i,u)));const f=r(t,["config"]);return f!=null&&Jv(f,o),o}function Xv(i,t){const o={},s=r(i,["displayName"]);return t!==void 0&&s!=null&&c(t,["batch","displayName"],s),o}function Qv(i,t){const o={},s=r(t,["model"]);s!=null&&c(o,["_url","model"],ke(i,s));const u=r(t,["src"]);u!=null&&c(o,["batch","inputConfig"],nT(i,u));const f=r(t,["config"]);return f!=null&&Xv(f,o),o}function Zv(i,t){const o={},s=r(t,["name"]);return s!=null&&c(o,["_url","name"],Vl(i,s)),o}function $v(i,t){const o={},s=r(t,["name"]);return s!=null&&c(o,["_url","name"],Vl(i,s)),o}function Wv(i){const t={},o=r(i,["sdkHttpResponse"]);o!=null&&c(t,["sdkHttpResponse"],o);const s=r(i,["name"]);s!=null&&c(t,["name"],s);const u=r(i,["done"]);u!=null&&c(t,["done"],u);const f=r(i,["error"]);return f!=null&&c(t,["error"],f),t}function jv(i){const t={},o=r(i,["sdkHttpResponse"]);o!=null&&c(t,["sdkHttpResponse"],o);const s=r(i,["name"]);s!=null&&c(t,["name"],s);const u=r(i,["done"]);u!=null&&c(t,["done"],u);const f=r(i,["error"]);return f!=null&&c(t,["error"],f),t}function eT(i,t){const o={},s=r(t,["contents"]);if(s!=null){let f=Ku(i,s);Array.isArray(f)&&(f=f.map(m=>m)),c(o,["requests[]","request","content"],f)}const u=r(t,["config"]);return u!=null&&(c(o,["_self"],tT(u,o)),$0(o,{"requests[].*":"requests[].request.*"})),o}function tT(i,t){const o={},s=r(i,["taskType"]);t!==void 0&&s!=null&&c(t,["requests[]","taskType"],s);const u=r(i,["title"]);t!==void 0&&u!=null&&c(t,["requests[]","title"],u);const f=r(i,["outputDimensionality"]);if(t!==void 0&&f!=null&&c(t,["requests[]","outputDimensionality"],f),r(i,["mimeType"])!==void 0)throw new Error("mimeType parameter is not supported in Gemini API.");if(r(i,["autoTruncate"])!==void 0)throw new Error("autoTruncate parameter is not supported in Gemini API.");return o}function nT(i,t){const o={},s=r(t,["fileName"]);s!=null&&c(o,["file_name"],s);const u=r(t,["inlinedRequests"]);return u!=null&&c(o,["requests"],eT(i,u)),o}function iT(i){const t={};if(r(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=r(i,["fileUri"]);o!=null&&c(t,["fileUri"],o);const s=r(i,["mimeType"]);return s!=null&&c(t,["mimeType"],s),t}function lT(i){const t={},o=r(i,["id"]);o!=null&&c(t,["id"],o);const s=r(i,["args"]);s!=null&&c(t,["args"],s);const u=r(i,["name"]);if(u!=null&&c(t,["name"],u),r(i,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(r(i,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return t}function oT(i){const t={},o=r(i,["mode"]);o!=null&&c(t,["mode"],o);const s=r(i,["allowedFunctionNames"]);if(s!=null&&c(t,["allowedFunctionNames"],s),r(i,["streamFunctionCallArguments"])!==void 0)throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return t}function sT(i,t,o){const s={},u=r(t,["systemInstruction"]);o!==void 0&&u!=null&&c(o,["systemInstruction"],Bh(It(u)));const f=r(t,["temperature"]);f!=null&&c(s,["temperature"],f);const m=r(t,["topP"]);m!=null&&c(s,["topP"],m);const g=r(t,["topK"]);g!=null&&c(s,["topK"],g);const y=r(t,["candidateCount"]);y!=null&&c(s,["candidateCount"],y);const h=r(t,["maxOutputTokens"]);h!=null&&c(s,["maxOutputTokens"],h);const v=r(t,["stopSequences"]);v!=null&&c(s,["stopSequences"],v);const E=r(t,["responseLogprobs"]);E!=null&&c(s,["responseLogprobs"],E);const C=r(t,["logprobs"]);C!=null&&c(s,["logprobs"],C);const x=r(t,["presencePenalty"]);x!=null&&c(s,["presencePenalty"],x);const P=r(t,["frequencyPenalty"]);P!=null&&c(s,["frequencyPenalty"],P);const q=r(t,["seed"]);q!=null&&c(s,["seed"],q);const V=r(t,["responseMimeType"]);V!=null&&c(s,["responseMimeType"],V);const Y=r(t,["responseSchema"]);Y!=null&&c(s,["responseSchema"],Xu(Y));const j=r(t,["responseJsonSchema"]);if(j!=null&&c(s,["responseJsonSchema"],j),r(t,["routingConfig"])!==void 0)throw new Error("routingConfig parameter is not supported in Gemini API.");if(r(t,["modelSelectionConfig"])!==void 0)throw new Error("modelSelectionConfig parameter is not supported in Gemini API.");const k=r(t,["safetySettings"]);if(o!==void 0&&k!=null){let Te=k;Array.isArray(Te)&&(Te=Te.map(ut=>CT(ut))),c(o,["safetySettings"],Te)}const Z=r(t,["tools"]);if(o!==void 0&&Z!=null){let Te=zl(Z);Array.isArray(Te)&&(Te=Te.map(ut=>AT(Pl(ut)))),c(o,["tools"],Te)}const ae=r(t,["toolConfig"]);if(o!==void 0&&ae!=null&&c(o,["toolConfig"],_T(ae)),r(t,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const se=r(t,["cachedContent"]);o!==void 0&&se!=null&&c(o,["cachedContent"],Jn(i,se));const K=r(t,["responseModalities"]);K!=null&&c(s,["responseModalities"],K);const Ae=r(t,["mediaResolution"]);Ae!=null&&c(s,["mediaResolution"],Ae);const ee=r(t,["speechConfig"]);if(ee!=null&&c(s,["speechConfig"],Qu(ee)),r(t,["audioTimestamp"])!==void 0)throw new Error("audioTimestamp parameter is not supported in Gemini API.");const Ee=r(t,["thinkingConfig"]);Ee!=null&&c(s,["thinkingConfig"],Ee);const be=r(t,["imageConfig"]);return be!=null&&c(s,["imageConfig"],dT(be)),s}function aT(i){const t={},o=r(i,["sdkHttpResponse"]);o!=null&&c(t,["sdkHttpResponse"],o);const s=r(i,["candidates"]);if(s!=null){let y=s;Array.isArray(y)&&(y=y.map(h=>Fv(h))),c(t,["candidates"],y)}const u=r(i,["modelVersion"]);u!=null&&c(t,["modelVersion"],u);const f=r(i,["promptFeedback"]);f!=null&&c(t,["promptFeedback"],f);const m=r(i,["responseId"]);m!=null&&c(t,["responseId"],m);const g=r(i,["usageMetadata"]);return g!=null&&c(t,["usageMetadata"],g),t}function rT(i,t){const o={},s=r(t,["name"]);return s!=null&&c(o,["_url","name"],Vl(i,s)),o}function uT(i,t){const o={},s=r(t,["name"]);return s!=null&&c(o,["_url","name"],Vl(i,s)),o}function cT(i){const t={};if(r(i,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const o=r(i,["enableWidget"]);return o!=null&&c(t,["enableWidget"],o),t}function fT(i){const t={};if(r(i,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(r(i,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const o=r(i,["timeRangeFilter"]);return o!=null&&c(t,["timeRangeFilter"],o),t}function dT(i){const t={},o=r(i,["aspectRatio"]);o!=null&&c(t,["aspectRatio"],o);const s=r(i,["imageSize"]);if(s!=null&&c(t,["imageSize"],s),r(i,["outputMimeType"])!==void 0)throw new Error("outputMimeType parameter is not supported in Gemini API.");if(r(i,["outputCompressionQuality"])!==void 0)throw new Error("outputCompressionQuality parameter is not supported in Gemini API.");return t}function pT(i,t){const o={},s=r(t,["model"]);s!=null&&c(o,["request","model"],ke(i,s));const u=r(t,["contents"]);if(u!=null){let g=rn(u);Array.isArray(g)&&(g=g.map(y=>Bh(y))),c(o,["request","contents"],g)}const f=r(t,["metadata"]);f!=null&&c(o,["metadata"],f);const m=r(t,["config"]);return m!=null&&c(o,["request","generationConfig"],sT(i,m,r(o,["request"],{}))),o}function mT(i){const t={},o=r(i,["response"]);o!=null&&c(t,["response"],aT(o));const s=r(i,["error"]);return s!=null&&c(t,["error"],s),t}function hT(i,t){const o={},s=r(i,["pageSize"]);t!==void 0&&s!=null&&c(t,["_query","pageSize"],s);const u=r(i,["pageToken"]);if(t!==void 0&&u!=null&&c(t,["_query","pageToken"],u),r(i,["filter"])!==void 0)throw new Error("filter parameter is not supported in Gemini API.");return o}function gT(i,t){const o={},s=r(i,["pageSize"]);t!==void 0&&s!=null&&c(t,["_query","pageSize"],s);const u=r(i,["pageToken"]);t!==void 0&&u!=null&&c(t,["_query","pageToken"],u);const f=r(i,["filter"]);return t!==void 0&&f!=null&&c(t,["_query","filter"],f),o}function yT(i){const t={},o=r(i,["config"]);return o!=null&&hT(o,t),t}function vT(i){const t={},o=r(i,["config"]);return o!=null&&gT(o,t),t}function TT(i){const t={},o=r(i,["sdkHttpResponse"]);o!=null&&c(t,["sdkHttpResponse"],o);const s=r(i,["nextPageToken"]);s!=null&&c(t,["nextPageToken"],s);const u=r(i,["operations"]);if(u!=null){let f=u;Array.isArray(f)&&(f=f.map(m=>ea(m))),c(t,["batchJobs"],f)}return t}function ST(i){const t={},o=r(i,["sdkHttpResponse"]);o!=null&&c(t,["sdkHttpResponse"],o);const s=r(i,["nextPageToken"]);s!=null&&c(t,["nextPageToken"],s);const u=r(i,["batchPredictionJobs"]);if(u!=null){let f=u;Array.isArray(f)&&(f=f.map(m=>Hu(m))),c(t,["batchJobs"],f)}return t}function ET(i){const t={},o=r(i,["mediaResolution"]);o!=null&&c(t,["mediaResolution"],o);const s=r(i,["codeExecutionResult"]);s!=null&&c(t,["codeExecutionResult"],s);const u=r(i,["executableCode"]);u!=null&&c(t,["executableCode"],u);const f=r(i,["fileData"]);f!=null&&c(t,["fileData"],iT(f));const m=r(i,["functionCall"]);m!=null&&c(t,["functionCall"],lT(m));const g=r(i,["functionResponse"]);g!=null&&c(t,["functionResponse"],g);const y=r(i,["inlineData"]);y!=null&&c(t,["inlineData"],Vv(y));const h=r(i,["text"]);h!=null&&c(t,["text"],h);const v=r(i,["thought"]);v!=null&&c(t,["thought"],v);const E=r(i,["thoughtSignature"]);E!=null&&c(t,["thoughtSignature"],E);const C=r(i,["videoMetadata"]);return C!=null&&c(t,["videoMetadata"],C),t}function CT(i){const t={},o=r(i,["category"]);if(o!=null&&c(t,["category"],o),r(i,["method"])!==void 0)throw new Error("method parameter is not supported in Gemini API.");const s=r(i,["threshold"]);return s!=null&&c(t,["threshold"],s),t}function _T(i){const t={},o=r(i,["functionCallingConfig"]);o!=null&&c(t,["functionCallingConfig"],oT(o));const s=r(i,["retrievalConfig"]);return s!=null&&c(t,["retrievalConfig"],s),t}function AT(i){const t={},o=r(i,["functionDeclarations"]);if(o!=null){let v=o;Array.isArray(v)&&(v=v.map(E=>E)),c(t,["functionDeclarations"],v)}if(r(i,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const s=r(i,["googleSearchRetrieval"]);s!=null&&c(t,["googleSearchRetrieval"],s);const u=r(i,["computerUse"]);u!=null&&c(t,["computerUse"],u);const f=r(i,["fileSearch"]);f!=null&&c(t,["fileSearch"],f);const m=r(i,["codeExecution"]);if(m!=null&&c(t,["codeExecution"],m),r(i,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const g=r(i,["googleMaps"]);g!=null&&c(t,["googleMaps"],cT(g));const y=r(i,["googleSearch"]);y!=null&&c(t,["googleSearch"],fT(y));const h=r(i,["urlContext"]);return h!=null&&c(t,["urlContext"],h),t}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */var On;(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"})(On||(On={}));class Yi{constructor(t,o,s,u){this.pageInternal=[],this.paramsInternal={},this.requestInternal=o,this.init(t,s,u)}init(t,o,s){var u,f;this.nameInternal=t,this.pageInternal=o[this.nameInternal]||[],this.sdkHttpResponseInternal=o==null?void 0:o.sdkHttpResponse,this.idxInternal=0;let m={config:{}};!s||Object.keys(s).length===0?m={config:{}}:typeof s=="object"?m=Object.assign({},s):m=s,m.config&&(m.config.pageToken=o.nextPageToken),this.paramsInternal=m,this.pageInternalSize=(f=(u=m.config)===null||u===void 0?void 0:u.pageSize)!==null&&f!==void 0?f:this.pageInternal.length}initNextPage(t){this.init(this.nameInternal,t,this.paramsInternal)}get page(){return this.pageInternal}get name(){return this.nameInternal}get pageSize(){return this.pageInternalSize}get sdkHttpResponse(){return this.sdkHttpResponseInternal}get params(){return this.paramsInternal}get pageLength(){return this.pageInternal.length}getItem(t){return this.pageInternal[t]}[Symbol.asyncIterator](){return{next:async()=>{if(this.idxInternal>=this.pageLength)if(this.hasNextPage())await this.nextPage();else return{value:void 0,done:!0};const t=this.getItem(this.idxInternal);return this.idxInternal+=1,{value:t,done:!1}},return:async()=>({value:void 0,done:!0})}}async nextPage(){if(!this.hasNextPage())throw new Error("No more pages to fetch.");const t=await this.requestInternal(this.params);return this.initNextPage(t),this.page}hasNextPage(){var t;return((t=this.params.config)===null||t===void 0?void 0:t.pageToken)!==void 0}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class xT extends Yn{constructor(t){super(),this.apiClient=t,this.list=async(o={})=>new Yi(On.PAGED_ITEM_BATCH_JOBS,s=>this.listInternal(s),await this.listInternal(o),o),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)}}createInlinedGenerateContentRequest(t){const o=oh(this.apiClient,t),s=o._url,u=$("{model}:batchGenerateContent",s),g=o.batch.inputConfig.requests,y=g.requests,h=[];for(const v of y){const E=Object.assign({},v);if(E.systemInstruction){const C=E.systemInstruction;delete E.systemInstruction;const x=E.request;x.systemInstruction=C,E.request=x}h.push(E)}return g.requests=h,delete o.config,delete o._url,delete o._query,{path:u,body:o}}getGcsUri(t){if(typeof t=="string")return t.startsWith("gs://")?t:void 0;if(!Array.isArray(t)&&t.gcsUri&&t.gcsUri.length>0)return t.gcsUri[0]}getBigqueryUri(t){if(typeof t=="string")return t.startsWith("bq://")?t:void 0;if(!Array.isArray(t))return t.bigqueryUri}formatDestination(t,o){const s=o?Object.assign({},o):{},u=Date.now().toString();if(s.displayName||(s.displayName=`genaiBatchJob_${u}`),s.dest===void 0){const f=this.getGcsUri(t),m=this.getBigqueryUri(t);if(f)f.endsWith(".jsonl")?s.dest=`${f.slice(0,-6)}/dest`:s.dest=`${f}_dest_${u}`;else if(m)s.dest=`${m}_dest_${u}`;else throw new Error("Unsupported source for Vertex AI: No GCS or BigQuery URI found.")}return s}async createInternal(t){var o,s,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=Kv(this.apiClient,t);return g=$("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=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json()),m.then(v=>Hu(v))}else{const h=oh(this.apiClient,t);return g=$("{model}:batchGenerateContent",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(u=t.config)===null||u===void 0?void 0:u.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json()),m.then(v=>ea(v))}}async createEmbeddingsInternal(t){var o,s;let u,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=Qv(this.apiClient,t);return f=$("{model}:asyncBatchEmbedContent",g._url),m=g._query,delete g._url,delete g._query,u=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json()),u.then(y=>ea(y))}}async get(t){var o,s,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=uT(this.apiClient,t);return g=$("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=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json()),m.then(v=>Hu(v))}else{const h=rT(this.apiClient,t);return g=$("batches/{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(u=t.config)===null||u===void 0?void 0:u.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json()),m.then(v=>ea(v))}}async cancel(t){var o,s,u,f;let m="",g={};if(this.apiClient.isVertexAI()){const y=Bv(this.apiClient,t);m=$("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=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal})}else{const y=kv(this.apiClient,t);m=$("batches/{name}:cancel",y._url),g=y._query,delete y._url,delete y._query,await this.apiClient.request({path:m,queryParams:g,body:JSON.stringify(y),httpMethod:"POST",httpOptions:(u=t.config)===null||u===void 0?void 0:u.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal})}}async listInternal(t){var o,s,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=vT(t);return g=$("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=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json().then(E=>{const C=E;return C.sdkHttpResponse={headers:v.headers},C})),m.then(v=>{const E=ST(v),C=new th;return Object.assign(C,E),C})}else{const h=yT(t);return g=$("batches",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(u=t.config)===null||u===void 0?void 0:u.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json().then(E=>{const C=E;return C.sdkHttpResponse={headers:v.headers},C})),m.then(v=>{const E=TT(v),C=new th;return Object.assign(C,E),C})}}async delete(t){var o,s,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=$v(this.apiClient,t);return g=$("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=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json().then(E=>{const C=E;return C.sdkHttpResponse={headers:v.headers},C})),m.then(v=>jv(v))}else{const h=Zv(this.apiClient,t);return g=$("batches/{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"DELETE",httpOptions:(u=t.config)===null||u===void 0?void 0:u.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json().then(E=>{const C=E;return C.sdkHttpResponse={headers:v.headers},C})),m.then(v=>Wv(v))}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function NT(i){const t={},o=r(i,["data"]);if(o!=null&&c(t,["data"],o),r(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const s=r(i,["mimeType"]);return s!=null&&c(t,["mimeType"],s),t}function sh(i){const t={},o=r(i,["parts"]);if(o!=null){let u=o;Array.isArray(u)&&(u=u.map(f=>QT(f))),c(t,["parts"],u)}const s=r(i,["role"]);return s!=null&&c(t,["role"],s),t}function RT(i,t){const o={},s=r(i,["ttl"]);t!==void 0&&s!=null&&c(t,["ttl"],s);const u=r(i,["expireTime"]);t!==void 0&&u!=null&&c(t,["expireTime"],u);const f=r(i,["displayName"]);t!==void 0&&f!=null&&c(t,["displayName"],f);const m=r(i,["contents"]);if(t!==void 0&&m!=null){let v=rn(m);Array.isArray(v)&&(v=v.map(E=>sh(E))),c(t,["contents"],v)}const g=r(i,["systemInstruction"]);t!==void 0&&g!=null&&c(t,["systemInstruction"],sh(It(g)));const y=r(i,["tools"]);if(t!==void 0&&y!=null){let v=y;Array.isArray(v)&&(v=v.map(E=>$T(E))),c(t,["tools"],v)}const h=r(i,["toolConfig"]);if(t!==void 0&&h!=null&&c(t,["toolConfig"],ZT(h)),r(i,["kmsKeyName"])!==void 0)throw new Error("kmsKeyName parameter is not supported in Gemini API.");return o}function MT(i,t){const o={},s=r(i,["ttl"]);t!==void 0&&s!=null&&c(t,["ttl"],s);const u=r(i,["expireTime"]);t!==void 0&&u!=null&&c(t,["expireTime"],u);const f=r(i,["displayName"]);t!==void 0&&f!=null&&c(t,["displayName"],f);const m=r(i,["contents"]);if(t!==void 0&&m!=null){let E=rn(m);Array.isArray(E)&&(E=E.map(C=>C)),c(t,["contents"],E)}const g=r(i,["systemInstruction"]);t!==void 0&&g!=null&&c(t,["systemInstruction"],It(g));const y=r(i,["tools"]);if(t!==void 0&&y!=null){let E=y;Array.isArray(E)&&(E=E.map(C=>WT(C))),c(t,["tools"],E)}const h=r(i,["toolConfig"]);t!==void 0&&h!=null&&c(t,["toolConfig"],h);const v=r(i,["kmsKeyName"]);return t!==void 0&&v!=null&&c(t,["encryption_spec","kmsKeyName"],v),o}function wT(i,t){const o={},s=r(t,["model"]);s!=null&&c(o,["model"],bh(i,s));const u=r(t,["config"]);return u!=null&&RT(u,o),o}function bT(i,t){const o={},s=r(t,["model"]);s!=null&&c(o,["model"],bh(i,s));const u=r(t,["config"]);return u!=null&&MT(u,o),o}function IT(i,t){const o={},s=r(t,["name"]);return s!=null&&c(o,["_url","name"],Jn(i,s)),o}function DT(i,t){const o={},s=r(t,["name"]);return s!=null&&c(o,["_url","name"],Jn(i,s)),o}function UT(i){const t={},o=r(i,["sdkHttpResponse"]);return o!=null&&c(t,["sdkHttpResponse"],o),t}function LT(i){const t={},o=r(i,["sdkHttpResponse"]);return o!=null&&c(t,["sdkHttpResponse"],o),t}function qT(i){const t={};if(r(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=r(i,["fileUri"]);o!=null&&c(t,["fileUri"],o);const s=r(i,["mimeType"]);return s!=null&&c(t,["mimeType"],s),t}function GT(i){const t={},o=r(i,["id"]);o!=null&&c(t,["id"],o);const s=r(i,["args"]);s!=null&&c(t,["args"],s);const u=r(i,["name"]);if(u!=null&&c(t,["name"],u),r(i,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(r(i,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return t}function HT(i){const t={},o=r(i,["mode"]);o!=null&&c(t,["mode"],o);const s=r(i,["allowedFunctionNames"]);if(s!=null&&c(t,["allowedFunctionNames"],s),r(i,["streamFunctionCallArguments"])!==void 0)throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return t}function PT(i){const t={};if(r(i,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");const o=r(i,["description"]);o!=null&&c(t,["description"],o);const s=r(i,["name"]);s!=null&&c(t,["name"],s);const u=r(i,["parameters"]);u!=null&&c(t,["parameters"],u);const f=r(i,["parametersJsonSchema"]);f!=null&&c(t,["parametersJsonSchema"],f);const m=r(i,["response"]);m!=null&&c(t,["response"],m);const g=r(i,["responseJsonSchema"]);return g!=null&&c(t,["responseJsonSchema"],g),t}function zT(i,t){const o={},s=r(t,["name"]);return s!=null&&c(o,["_url","name"],Jn(i,s)),o}function VT(i,t){const o={},s=r(t,["name"]);return s!=null&&c(o,["_url","name"],Jn(i,s)),o}function kT(i){const t={};if(r(i,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const o=r(i,["enableWidget"]);return o!=null&&c(t,["enableWidget"],o),t}function BT(i){const t={};if(r(i,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(r(i,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const o=r(i,["timeRangeFilter"]);return o!=null&&c(t,["timeRangeFilter"],o),t}function FT(i,t){const o={},s=r(i,["pageSize"]);t!==void 0&&s!=null&&c(t,["_query","pageSize"],s);const u=r(i,["pageToken"]);return t!==void 0&&u!=null&&c(t,["_query","pageToken"],u),o}function OT(i,t){const o={},s=r(i,["pageSize"]);t!==void 0&&s!=null&&c(t,["_query","pageSize"],s);const u=r(i,["pageToken"]);return t!==void 0&&u!=null&&c(t,["_query","pageToken"],u),o}function YT(i){const t={},o=r(i,["config"]);return o!=null&&FT(o,t),t}function JT(i){const t={},o=r(i,["config"]);return o!=null&&OT(o,t),t}function KT(i){const t={},o=r(i,["sdkHttpResponse"]);o!=null&&c(t,["sdkHttpResponse"],o);const s=r(i,["nextPageToken"]);s!=null&&c(t,["nextPageToken"],s);const u=r(i,["cachedContents"]);if(u!=null){let f=u;Array.isArray(f)&&(f=f.map(m=>m)),c(t,["cachedContents"],f)}return t}function XT(i){const t={},o=r(i,["sdkHttpResponse"]);o!=null&&c(t,["sdkHttpResponse"],o);const s=r(i,["nextPageToken"]);s!=null&&c(t,["nextPageToken"],s);const u=r(i,["cachedContents"]);if(u!=null){let f=u;Array.isArray(f)&&(f=f.map(m=>m)),c(t,["cachedContents"],f)}return t}function QT(i){const t={},o=r(i,["mediaResolution"]);o!=null&&c(t,["mediaResolution"],o);const s=r(i,["codeExecutionResult"]);s!=null&&c(t,["codeExecutionResult"],s);const u=r(i,["executableCode"]);u!=null&&c(t,["executableCode"],u);const f=r(i,["fileData"]);f!=null&&c(t,["fileData"],qT(f));const m=r(i,["functionCall"]);m!=null&&c(t,["functionCall"],GT(m));const g=r(i,["functionResponse"]);g!=null&&c(t,["functionResponse"],g);const y=r(i,["inlineData"]);y!=null&&c(t,["inlineData"],NT(y));const h=r(i,["text"]);h!=null&&c(t,["text"],h);const v=r(i,["thought"]);v!=null&&c(t,["thought"],v);const E=r(i,["thoughtSignature"]);E!=null&&c(t,["thoughtSignature"],E);const C=r(i,["videoMetadata"]);return C!=null&&c(t,["videoMetadata"],C),t}function ZT(i){const t={},o=r(i,["functionCallingConfig"]);o!=null&&c(t,["functionCallingConfig"],HT(o));const s=r(i,["retrievalConfig"]);return s!=null&&c(t,["retrievalConfig"],s),t}function $T(i){const t={},o=r(i,["functionDeclarations"]);if(o!=null){let v=o;Array.isArray(v)&&(v=v.map(E=>E)),c(t,["functionDeclarations"],v)}if(r(i,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const s=r(i,["googleSearchRetrieval"]);s!=null&&c(t,["googleSearchRetrieval"],s);const u=r(i,["computerUse"]);u!=null&&c(t,["computerUse"],u);const f=r(i,["fileSearch"]);f!=null&&c(t,["fileSearch"],f);const m=r(i,["codeExecution"]);if(m!=null&&c(t,["codeExecution"],m),r(i,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const g=r(i,["googleMaps"]);g!=null&&c(t,["googleMaps"],kT(g));const y=r(i,["googleSearch"]);y!=null&&c(t,["googleSearch"],BT(y));const h=r(i,["urlContext"]);return h!=null&&c(t,["urlContext"],h),t}function WT(i){const t={},o=r(i,["functionDeclarations"]);if(o!=null){let E=o;Array.isArray(E)&&(E=E.map(C=>PT(C))),c(t,["functionDeclarations"],E)}const s=r(i,["retrieval"]);s!=null&&c(t,["retrieval"],s);const u=r(i,["googleSearchRetrieval"]);u!=null&&c(t,["googleSearchRetrieval"],u);const f=r(i,["computerUse"]);if(f!=null&&c(t,["computerUse"],f),r(i,["fileSearch"])!==void 0)throw new Error("fileSearch parameter is not supported in Vertex AI.");const m=r(i,["codeExecution"]);m!=null&&c(t,["codeExecution"],m);const g=r(i,["enterpriseWebSearch"]);g!=null&&c(t,["enterpriseWebSearch"],g);const y=r(i,["googleMaps"]);y!=null&&c(t,["googleMaps"],y);const h=r(i,["googleSearch"]);h!=null&&c(t,["googleSearch"],h);const v=r(i,["urlContext"]);return v!=null&&c(t,["urlContext"],v),t}function jT(i,t){const o={},s=r(i,["ttl"]);t!==void 0&&s!=null&&c(t,["ttl"],s);const u=r(i,["expireTime"]);return t!==void 0&&u!=null&&c(t,["expireTime"],u),o}function eS(i,t){const o={},s=r(i,["ttl"]);t!==void 0&&s!=null&&c(t,["ttl"],s);const u=r(i,["expireTime"]);return t!==void 0&&u!=null&&c(t,["expireTime"],u),o}function tS(i,t){const o={},s=r(t,["name"]);s!=null&&c(o,["_url","name"],Jn(i,s));const u=r(t,["config"]);return u!=null&&jT(u,o),o}function nS(i,t){const o={},s=r(t,["name"]);s!=null&&c(o,["_url","name"],Jn(i,s));const u=r(t,["config"]);return u!=null&&eS(u,o),o}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class iS extends Yn{constructor(t){super(),this.apiClient=t,this.list=async(o={})=>new Yi(On.PAGED_ITEM_CACHED_CONTENTS,s=>this.listInternal(s),await this.listInternal(o),o)}async create(t){var o,s,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=bT(this.apiClient,t);return g=$("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=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json()),m.then(v=>v)}else{const h=wT(this.apiClient,t);return g=$("cachedContents",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(u=t.config)===null||u===void 0?void 0:u.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json()),m.then(v=>v)}}async get(t){var o,s,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=VT(this.apiClient,t);return g=$("{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=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json()),m.then(v=>v)}else{const h=zT(this.apiClient,t);return g=$("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(u=t.config)===null||u===void 0?void 0:u.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json()),m.then(v=>v)}}async delete(t){var o,s,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=DT(this.apiClient,t);return g=$("{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=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json().then(E=>{const C=E;return C.sdkHttpResponse={headers:v.headers},C})),m.then(v=>{const E=LT(v),C=new jm;return Object.assign(C,E),C})}else{const h=IT(this.apiClient,t);return g=$("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"DELETE",httpOptions:(u=t.config)===null||u===void 0?void 0:u.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json().then(E=>{const C=E;return C.sdkHttpResponse={headers:v.headers},C})),m.then(v=>{const E=UT(v),C=new jm;return Object.assign(C,E),C})}}async update(t){var o,s,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=nS(this.apiClient,t);return g=$("{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=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json()),m.then(v=>v)}else{const h=tS(this.apiClient,t);return g=$("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"PATCH",httpOptions:(u=t.config)===null||u===void 0?void 0:u.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json()),m.then(v=>v)}}async listInternal(t){var o,s,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=JT(t);return g=$("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=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json().then(E=>{const C=E;return C.sdkHttpResponse={headers:v.headers},C})),m.then(v=>{const E=XT(v),C=new eh;return Object.assign(C,E),C})}else{const h=YT(t);return g=$("cachedContents",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(u=t.config)===null||u===void 0?void 0:u.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json().then(E=>{const C=E;return C.sdkHttpResponse={headers:v.headers},C})),m.then(v=>{const E=KT(v),C=new eh;return Object.assign(C,E),C})}}}function ah(i){var t=typeof Symbol=="function"&&Symbol.iterator,o=t&&i[t],s=0;if(o)return o.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&s>=i.length&&(i=void 0),{value:i&&i[s++],done:!i}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function rt(i){return this instanceof rt?(this.v=i,this):new rt(i)}function Gl(i,t,o){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=o.apply(i,t||[]),u,f=[];return u=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),g("next"),g("throw"),g("return",m),u[Symbol.asyncIterator]=function(){return this},u;function m(x){return function(P){return Promise.resolve(P).then(x,E)}}function g(x,P){s[x]&&(u[x]=function(q){return new Promise(function(V,Y){f.push([x,q,V,Y])>1||y(x,q)})},P&&(u[x]=P(u[x])))}function y(x,P){try{h(s[x](P))}catch(q){C(f[0][3],q)}}function h(x){x.value instanceof rt?Promise.resolve(x.value.v).then(v,E):C(f[0][2],x)}function v(x){y("next",x)}function E(x){y("throw",x)}function C(x,P){x(P),f.shift(),f.length&&y(f[0][0],f[0][1])}}function Ho(i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=i[Symbol.asyncIterator],o;return t?t.call(i):(i=typeof ah=="function"?ah(i):i[Symbol.iterator](),o={},s("next"),s("throw"),s("return"),o[Symbol.asyncIterator]=function(){return this},o);function s(f){o[f]=i[f]&&function(m){return new Promise(function(g,y){m=i[f](m),u(g,y,m.done,m.value)})}}function u(f,m,g,y){Promise.resolve(y).then(function(h){f({value:h,done:g})},m)}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function lS(i){var t;if(i.candidates==null||i.candidates.length===0)return!1;const o=(t=i.candidates[0])===null||t===void 0?void 0:t.content;return o===void 0?!1:Fh(o)}function Fh(i){if(i.parts===void 0||i.parts.length===0)return!1;for(const t of i.parts)if(t===void 0||Object.keys(t).length===0)return!1;return!0}function oS(i){if(i.length!==0){for(const t of i)if(t.role!=="user"&&t.role!=="model")throw new Error(`Role must be user or model, but got ${t.role}.`)}}function rh(i){if(i===void 0||i.length===0)return[];const t=[],o=i.length;let s=0;for(;s{var f,m,g;const y=await u,h=(m=(f=y.candidates)===null||f===void 0?void 0:f[0])===null||m===void 0?void 0:m.content,v=y.automaticFunctionCallingHistory,E=this.getHistory(!0).length;let C=[];v!=null&&(C=(g=v.slice(E))!==null&&g!==void 0?g:[]);const x=h?[h]:[];this.recordHistory(s,x,C)})(),await this.sendPromise.catch(()=>{this.sendPromise=Promise.resolve()}),u}async sendMessageStream(t){var o;await this.sendPromise;const s=It(t.message),u=this.modelsModule.generateContentStream({model:this.model,contents:this.getHistory(!0).concat(s),config:(o=t.config)!==null&&o!==void 0?o:this.config});this.sendPromise=u.then(()=>{}).catch(()=>{});const f=await u;return this.processStreamResponse(f,s)}getHistory(t=!1){const o=t?rh(this.history):this.history;return structuredClone(o)}processStreamResponse(t,o){var s,u;return Gl(this,arguments,function*(){var m,g,y,h;const v=[];try{for(var E=!0,C=Ho(t),x;x=yield rt(C.next()),m=x.done,!m;E=!0){h=x.value,E=!1;const P=h;if(lS(P)){const q=(u=(s=P.candidates)===null||s===void 0?void 0:s[0])===null||u===void 0?void 0:u.content;q!==void 0&&v.push(q)}yield yield rt(P)}}catch(P){g={error:P}}finally{try{!E&&!m&&(y=C.return)&&(yield rt(y.call(C)))}finally{if(g)throw g.error}}this.recordHistory(o,v)})}recordHistory(t,o,s){let u=[];o.length>0&&o.every(f=>f.role!==void 0)?u=o:u.push({role:"model",parts:[]}),s&&s.length>0?this.history.push(...rh(s)):this.history.push(t),this.history.push(...u)}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class aa extends Error{constructor(t){super(t.message),this.name="ApiError",this.status=t.status,Object.setPrototypeOf(this,aa.prototype)}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function rS(i){const t={},o=r(i,["file"]);return o!=null&&c(t,["file"],o),t}function uS(i){const t={},o=r(i,["sdkHttpResponse"]);return o!=null&&c(t,["sdkHttpResponse"],o),t}function cS(i){const t={},o=r(i,["name"]);return o!=null&&c(t,["_url","file"],Gh(o)),t}function fS(i){const t={},o=r(i,["sdkHttpResponse"]);return o!=null&&c(t,["sdkHttpResponse"],o),t}function dS(i){const t={},o=r(i,["name"]);return o!=null&&c(t,["_url","file"],Gh(o)),t}function pS(i,t){const o={},s=r(i,["pageSize"]);t!==void 0&&s!=null&&c(t,["_query","pageSize"],s);const u=r(i,["pageToken"]);return t!==void 0&&u!=null&&c(t,["_query","pageToken"],u),o}function mS(i){const t={},o=r(i,["config"]);return o!=null&&pS(o,t),t}function hS(i){const t={},o=r(i,["sdkHttpResponse"]);o!=null&&c(t,["sdkHttpResponse"],o);const s=r(i,["nextPageToken"]);s!=null&&c(t,["nextPageToken"],s);const u=r(i,["files"]);if(u!=null){let f=u;Array.isArray(f)&&(f=f.map(m=>m)),c(t,["files"],f)}return t}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class gS extends Yn{constructor(t){super(),this.apiClient=t,this.list=async(o={})=>new Yi(On.PAGED_ITEM_FILES,s=>this.listInternal(s),await this.listInternal(o),o)}async upload(t){if(this.apiClient.isVertexAI())throw new Error("Vertex AI does not support uploading files. You can share files through a GCS bucket.");return this.apiClient.uploadFile(t.file,t.config).then(o=>o)}async download(t){await this.apiClient.downloadFile(t)}async listInternal(t){var o,s;let u,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=mS(t);return f=$("files",g._url),m=g._query,delete g._url,delete g._query,u=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"GET",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json().then(h=>{const v=h;return v.sdkHttpResponse={headers:y.headers},v})),u.then(y=>{const h=hS(y),v=new Sv;return Object.assign(v,h),v})}}async createInternal(t){var o,s;let u,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=rS(t);return f=$("upload/v1beta/files",g._url),m=g._query,delete g._url,delete g._query,u=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json()),u.then(y=>{const h=uS(y),v=new Ev;return Object.assign(v,h),v})}}async get(t){var o,s;let u,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=dS(t);return f=$("files/{file}",g._url),m=g._query,delete g._url,delete g._query,u=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"GET",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json()),u.then(y=>y)}}async delete(t){var o,s;let u,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=cS(t);return f=$("files/{file}",g._url),m=g._query,delete g._url,delete g._query,u=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"DELETE",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json().then(h=>{const v=h;return v.sdkHttpResponse={headers:y.headers},v})),u.then(y=>{const h=fS(y),v=new Cv;return Object.assign(v,h),v})}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function ta(i){const t={},o=r(i,["data"]);if(o!=null&&c(t,["data"],o),r(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const s=r(i,["mimeType"]);return s!=null&&c(t,["mimeType"],s),t}function yS(i){const t={},o=r(i,["parts"]);if(o!=null){let u=o;Array.isArray(u)&&(u=u.map(f=>US(f))),c(t,["parts"],u)}const s=r(i,["role"]);return s!=null&&c(t,["role"],s),t}function vS(i){const t={};if(r(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=r(i,["fileUri"]);o!=null&&c(t,["fileUri"],o);const s=r(i,["mimeType"]);return s!=null&&c(t,["mimeType"],s),t}function TS(i){const t={},o=r(i,["id"]);o!=null&&c(t,["id"],o);const s=r(i,["args"]);s!=null&&c(t,["args"],s);const u=r(i,["name"]);if(u!=null&&c(t,["name"],u),r(i,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(r(i,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return t}function SS(i){const t={};if(r(i,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");const o=r(i,["description"]);o!=null&&c(t,["description"],o);const s=r(i,["name"]);s!=null&&c(t,["name"],s);const u=r(i,["parameters"]);u!=null&&c(t,["parameters"],u);const f=r(i,["parametersJsonSchema"]);f!=null&&c(t,["parametersJsonSchema"],f);const m=r(i,["response"]);m!=null&&c(t,["response"],m);const g=r(i,["responseJsonSchema"]);return g!=null&&c(t,["responseJsonSchema"],g),t}function ES(i){const t={},o=r(i,["modelSelectionConfig"]);o!=null&&c(t,["modelConfig"],o);const s=r(i,["responseJsonSchema"]);s!=null&&c(t,["responseJsonSchema"],s);const u=r(i,["audioTimestamp"]);u!=null&&c(t,["audioTimestamp"],u);const f=r(i,["candidateCount"]);f!=null&&c(t,["candidateCount"],f);const m=r(i,["enableAffectiveDialog"]);m!=null&&c(t,["enableAffectiveDialog"],m);const g=r(i,["frequencyPenalty"]);g!=null&&c(t,["frequencyPenalty"],g);const y=r(i,["logprobs"]);y!=null&&c(t,["logprobs"],y);const h=r(i,["maxOutputTokens"]);h!=null&&c(t,["maxOutputTokens"],h);const v=r(i,["mediaResolution"]);v!=null&&c(t,["mediaResolution"],v);const E=r(i,["presencePenalty"]);E!=null&&c(t,["presencePenalty"],E);const C=r(i,["responseLogprobs"]);C!=null&&c(t,["responseLogprobs"],C);const x=r(i,["responseMimeType"]);x!=null&&c(t,["responseMimeType"],x);const P=r(i,["responseModalities"]);P!=null&&c(t,["responseModalities"],P);const q=r(i,["responseSchema"]);q!=null&&c(t,["responseSchema"],q);const V=r(i,["routingConfig"]);V!=null&&c(t,["routingConfig"],V);const Y=r(i,["seed"]);Y!=null&&c(t,["seed"],Y);const j=r(i,["speechConfig"]);j!=null&&c(t,["speechConfig"],Oh(j));const k=r(i,["stopSequences"]);k!=null&&c(t,["stopSequences"],k);const Z=r(i,["temperature"]);Z!=null&&c(t,["temperature"],Z);const ae=r(i,["thinkingConfig"]);ae!=null&&c(t,["thinkingConfig"],ae);const se=r(i,["topK"]);se!=null&&c(t,["topK"],se);const K=r(i,["topP"]);if(K!=null&&c(t,["topP"],K),r(i,["enableEnhancedCivicAnswers"])!==void 0)throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");return t}function CS(i){const t={};if(r(i,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const o=r(i,["enableWidget"]);return o!=null&&c(t,["enableWidget"],o),t}function _S(i){const t={};if(r(i,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(r(i,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const o=r(i,["timeRangeFilter"]);return o!=null&&c(t,["timeRangeFilter"],o),t}function AS(i,t){const o={},s=r(i,["generationConfig"]);t!==void 0&&s!=null&&c(t,["setup","generationConfig"],s);const u=r(i,["responseModalities"]);t!==void 0&&u!=null&&c(t,["setup","generationConfig","responseModalities"],u);const f=r(i,["temperature"]);t!==void 0&&f!=null&&c(t,["setup","generationConfig","temperature"],f);const m=r(i,["topP"]);t!==void 0&&m!=null&&c(t,["setup","generationConfig","topP"],m);const g=r(i,["topK"]);t!==void 0&&g!=null&&c(t,["setup","generationConfig","topK"],g);const y=r(i,["maxOutputTokens"]);t!==void 0&&y!=null&&c(t,["setup","generationConfig","maxOutputTokens"],y);const h=r(i,["mediaResolution"]);t!==void 0&&h!=null&&c(t,["setup","generationConfig","mediaResolution"],h);const v=r(i,["seed"]);t!==void 0&&v!=null&&c(t,["setup","generationConfig","seed"],v);const E=r(i,["speechConfig"]);t!==void 0&&E!=null&&c(t,["setup","generationConfig","speechConfig"],Zu(E));const C=r(i,["thinkingConfig"]);t!==void 0&&C!=null&&c(t,["setup","generationConfig","thinkingConfig"],C);const x=r(i,["enableAffectiveDialog"]);t!==void 0&&x!=null&&c(t,["setup","generationConfig","enableAffectiveDialog"],x);const P=r(i,["systemInstruction"]);t!==void 0&&P!=null&&c(t,["setup","systemInstruction"],yS(It(P)));const q=r(i,["tools"]);if(t!==void 0&&q!=null){let se=zl(q);Array.isArray(se)&&(se=se.map(K=>qS(Pl(K)))),c(t,["setup","tools"],se)}const V=r(i,["sessionResumption"]);t!==void 0&&V!=null&&c(t,["setup","sessionResumption"],LS(V));const Y=r(i,["inputAudioTranscription"]);t!==void 0&&Y!=null&&c(t,["setup","inputAudioTranscription"],Y);const j=r(i,["outputAudioTranscription"]);t!==void 0&&j!=null&&c(t,["setup","outputAudioTranscription"],j);const k=r(i,["realtimeInputConfig"]);t!==void 0&&k!=null&&c(t,["setup","realtimeInputConfig"],k);const Z=r(i,["contextWindowCompression"]);t!==void 0&&Z!=null&&c(t,["setup","contextWindowCompression"],Z);const ae=r(i,["proactivity"]);return t!==void 0&&ae!=null&&c(t,["setup","proactivity"],ae),o}function xS(i,t){const o={},s=r(i,["generationConfig"]);t!==void 0&&s!=null&&c(t,["setup","generationConfig"],ES(s));const u=r(i,["responseModalities"]);t!==void 0&&u!=null&&c(t,["setup","generationConfig","responseModalities"],u);const f=r(i,["temperature"]);t!==void 0&&f!=null&&c(t,["setup","generationConfig","temperature"],f);const m=r(i,["topP"]);t!==void 0&&m!=null&&c(t,["setup","generationConfig","topP"],m);const g=r(i,["topK"]);t!==void 0&&g!=null&&c(t,["setup","generationConfig","topK"],g);const y=r(i,["maxOutputTokens"]);t!==void 0&&y!=null&&c(t,["setup","generationConfig","maxOutputTokens"],y);const h=r(i,["mediaResolution"]);t!==void 0&&h!=null&&c(t,["setup","generationConfig","mediaResolution"],h);const v=r(i,["seed"]);t!==void 0&&v!=null&&c(t,["setup","generationConfig","seed"],v);const E=r(i,["speechConfig"]);t!==void 0&&E!=null&&c(t,["setup","generationConfig","speechConfig"],Oh(Zu(E)));const C=r(i,["thinkingConfig"]);t!==void 0&&C!=null&&c(t,["setup","generationConfig","thinkingConfig"],C);const x=r(i,["enableAffectiveDialog"]);t!==void 0&&x!=null&&c(t,["setup","generationConfig","enableAffectiveDialog"],x);const P=r(i,["systemInstruction"]);t!==void 0&&P!=null&&c(t,["setup","systemInstruction"],It(P));const q=r(i,["tools"]);if(t!==void 0&&q!=null){let se=zl(q);Array.isArray(se)&&(se=se.map(K=>GS(Pl(K)))),c(t,["setup","tools"],se)}const V=r(i,["sessionResumption"]);t!==void 0&&V!=null&&c(t,["setup","sessionResumption"],V);const Y=r(i,["inputAudioTranscription"]);t!==void 0&&Y!=null&&c(t,["setup","inputAudioTranscription"],Y);const j=r(i,["outputAudioTranscription"]);t!==void 0&&j!=null&&c(t,["setup","outputAudioTranscription"],j);const k=r(i,["realtimeInputConfig"]);t!==void 0&&k!=null&&c(t,["setup","realtimeInputConfig"],k);const Z=r(i,["contextWindowCompression"]);t!==void 0&&Z!=null&&c(t,["setup","contextWindowCompression"],Z);const ae=r(i,["proactivity"]);return t!==void 0&&ae!=null&&c(t,["setup","proactivity"],ae),o}function NS(i,t){const o={},s=r(t,["model"]);s!=null&&c(o,["setup","model"],ke(i,s));const u=r(t,["config"]);return u!=null&&c(o,["config"],AS(u,o)),o}function RS(i,t){const o={},s=r(t,["model"]);s!=null&&c(o,["setup","model"],ke(i,s));const u=r(t,["config"]);return u!=null&&c(o,["config"],xS(u,o)),o}function MS(i){const t={},o=r(i,["musicGenerationConfig"]);return o!=null&&c(t,["musicGenerationConfig"],o),t}function wS(i){const t={},o=r(i,["weightedPrompts"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(u=>u)),c(t,["weightedPrompts"],s)}return t}function bS(i){const t={},o=r(i,["media"]);if(o!=null){let h=Ih(o);Array.isArray(h)&&(h=h.map(v=>ta(v))),c(t,["mediaChunks"],h)}const s=r(i,["audio"]);s!=null&&c(t,["audio"],ta(Uh(s)));const u=r(i,["audioStreamEnd"]);u!=null&&c(t,["audioStreamEnd"],u);const f=r(i,["video"]);f!=null&&c(t,["video"],ta(Dh(f)));const m=r(i,["text"]);m!=null&&c(t,["text"],m);const g=r(i,["activityStart"]);g!=null&&c(t,["activityStart"],g);const y=r(i,["activityEnd"]);return y!=null&&c(t,["activityEnd"],y),t}function IS(i){const t={},o=r(i,["media"]);if(o!=null){let h=Ih(o);Array.isArray(h)&&(h=h.map(v=>v)),c(t,["mediaChunks"],h)}const s=r(i,["audio"]);s!=null&&c(t,["audio"],Uh(s));const u=r(i,["audioStreamEnd"]);u!=null&&c(t,["audioStreamEnd"],u);const f=r(i,["video"]);f!=null&&c(t,["video"],Dh(f));const m=r(i,["text"]);m!=null&&c(t,["text"],m);const g=r(i,["activityStart"]);g!=null&&c(t,["activityStart"],g);const y=r(i,["activityEnd"]);return y!=null&&c(t,["activityEnd"],y),t}function DS(i){const t={},o=r(i,["setupComplete"]);o!=null&&c(t,["setupComplete"],o);const s=r(i,["serverContent"]);s!=null&&c(t,["serverContent"],s);const u=r(i,["toolCall"]);u!=null&&c(t,["toolCall"],u);const f=r(i,["toolCallCancellation"]);f!=null&&c(t,["toolCallCancellation"],f);const m=r(i,["usageMetadata"]);m!=null&&c(t,["usageMetadata"],HS(m));const g=r(i,["goAway"]);g!=null&&c(t,["goAway"],g);const y=r(i,["sessionResumptionUpdate"]);return y!=null&&c(t,["sessionResumptionUpdate"],y),t}function US(i){const t={},o=r(i,["mediaResolution"]);o!=null&&c(t,["mediaResolution"],o);const s=r(i,["codeExecutionResult"]);s!=null&&c(t,["codeExecutionResult"],s);const u=r(i,["executableCode"]);u!=null&&c(t,["executableCode"],u);const f=r(i,["fileData"]);f!=null&&c(t,["fileData"],vS(f));const m=r(i,["functionCall"]);m!=null&&c(t,["functionCall"],TS(m));const g=r(i,["functionResponse"]);g!=null&&c(t,["functionResponse"],g);const y=r(i,["inlineData"]);y!=null&&c(t,["inlineData"],ta(y));const h=r(i,["text"]);h!=null&&c(t,["text"],h);const v=r(i,["thought"]);v!=null&&c(t,["thought"],v);const E=r(i,["thoughtSignature"]);E!=null&&c(t,["thoughtSignature"],E);const C=r(i,["videoMetadata"]);return C!=null&&c(t,["videoMetadata"],C),t}function LS(i){const t={},o=r(i,["handle"]);if(o!=null&&c(t,["handle"],o),r(i,["transparent"])!==void 0)throw new Error("transparent parameter is not supported in Gemini API.");return t}function Oh(i){const t={},o=r(i,["languageCode"]);o!=null&&c(t,["languageCode"],o);const s=r(i,["voiceConfig"]);if(s!=null&&c(t,["voiceConfig"],s),r(i,["multiSpeakerVoiceConfig"])!==void 0)throw new Error("multiSpeakerVoiceConfig parameter is not supported in Vertex AI.");return t}function qS(i){const t={},o=r(i,["functionDeclarations"]);if(o!=null){let v=o;Array.isArray(v)&&(v=v.map(E=>E)),c(t,["functionDeclarations"],v)}if(r(i,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const s=r(i,["googleSearchRetrieval"]);s!=null&&c(t,["googleSearchRetrieval"],s);const u=r(i,["computerUse"]);u!=null&&c(t,["computerUse"],u);const f=r(i,["fileSearch"]);f!=null&&c(t,["fileSearch"],f);const m=r(i,["codeExecution"]);if(m!=null&&c(t,["codeExecution"],m),r(i,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const g=r(i,["googleMaps"]);g!=null&&c(t,["googleMaps"],CS(g));const y=r(i,["googleSearch"]);y!=null&&c(t,["googleSearch"],_S(y));const h=r(i,["urlContext"]);return h!=null&&c(t,["urlContext"],h),t}function GS(i){const t={},o=r(i,["functionDeclarations"]);if(o!=null){let E=o;Array.isArray(E)&&(E=E.map(C=>SS(C))),c(t,["functionDeclarations"],E)}const s=r(i,["retrieval"]);s!=null&&c(t,["retrieval"],s);const u=r(i,["googleSearchRetrieval"]);u!=null&&c(t,["googleSearchRetrieval"],u);const f=r(i,["computerUse"]);if(f!=null&&c(t,["computerUse"],f),r(i,["fileSearch"])!==void 0)throw new Error("fileSearch parameter is not supported in Vertex AI.");const m=r(i,["codeExecution"]);m!=null&&c(t,["codeExecution"],m);const g=r(i,["enterpriseWebSearch"]);g!=null&&c(t,["enterpriseWebSearch"],g);const y=r(i,["googleMaps"]);y!=null&&c(t,["googleMaps"],y);const h=r(i,["googleSearch"]);h!=null&&c(t,["googleSearch"],h);const v=r(i,["urlContext"]);return v!=null&&c(t,["urlContext"],v),t}function HS(i){const t={},o=r(i,["promptTokenCount"]);o!=null&&c(t,["promptTokenCount"],o);const s=r(i,["cachedContentTokenCount"]);s!=null&&c(t,["cachedContentTokenCount"],s);const u=r(i,["candidatesTokenCount"]);u!=null&&c(t,["responseTokenCount"],u);const f=r(i,["toolUsePromptTokenCount"]);f!=null&&c(t,["toolUsePromptTokenCount"],f);const m=r(i,["thoughtsTokenCount"]);m!=null&&c(t,["thoughtsTokenCount"],m);const g=r(i,["totalTokenCount"]);g!=null&&c(t,["totalTokenCount"],g);const y=r(i,["promptTokensDetails"]);if(y!=null){let x=y;Array.isArray(x)&&(x=x.map(P=>P)),c(t,["promptTokensDetails"],x)}const h=r(i,["cacheTokensDetails"]);if(h!=null){let x=h;Array.isArray(x)&&(x=x.map(P=>P)),c(t,["cacheTokensDetails"],x)}const v=r(i,["candidatesTokensDetails"]);if(v!=null){let x=v;Array.isArray(x)&&(x=x.map(P=>P)),c(t,["responseTokensDetails"],x)}const E=r(i,["toolUsePromptTokensDetails"]);if(E!=null){let x=E;Array.isArray(x)&&(x=x.map(P=>P)),c(t,["toolUsePromptTokensDetails"],x)}const C=r(i,["trafficType"]);return C!=null&&c(t,["trafficType"],C),t}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function PS(i){const t={},o=r(i,["data"]);if(o!=null&&c(t,["data"],o),r(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const s=r(i,["mimeType"]);return s!=null&&c(t,["mimeType"],s),t}function zS(i){const t={},o=r(i,["content"]);o!=null&&c(t,["content"],o);const s=r(i,["citationMetadata"]);s!=null&&c(t,["citationMetadata"],VS(s));const u=r(i,["tokenCount"]);u!=null&&c(t,["tokenCount"],u);const f=r(i,["finishReason"]);f!=null&&c(t,["finishReason"],f);const m=r(i,["avgLogprobs"]);m!=null&&c(t,["avgLogprobs"],m);const g=r(i,["groundingMetadata"]);g!=null&&c(t,["groundingMetadata"],g);const y=r(i,["index"]);y!=null&&c(t,["index"],y);const h=r(i,["logprobsResult"]);h!=null&&c(t,["logprobsResult"],h);const v=r(i,["safetyRatings"]);if(v!=null){let C=v;Array.isArray(C)&&(C=C.map(x=>x)),c(t,["safetyRatings"],C)}const E=r(i,["urlContextMetadata"]);return E!=null&&c(t,["urlContextMetadata"],E),t}function VS(i){const t={},o=r(i,["citationSources"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(u=>u)),c(t,["citations"],s)}return t}function kS(i,t){const o={},s=r(t,["model"]);s!=null&&c(o,["_url","model"],ke(i,s));const u=r(t,["contents"]);if(u!=null){let f=rn(u);Array.isArray(f)&&(f=f.map(m=>m)),c(o,["contents"],f)}return o}function BS(i){const t={},o=r(i,["sdkHttpResponse"]);o!=null&&c(t,["sdkHttpResponse"],o);const s=r(i,["tokensInfo"]);if(s!=null){let u=s;Array.isArray(u)&&(u=u.map(f=>f)),c(t,["tokensInfo"],u)}return t}function FS(i){const t={},o=r(i,["values"]);o!=null&&c(t,["values"],o);const s=r(i,["statistics"]);return s!=null&&c(t,["statistics"],OS(s)),t}function OS(i){const t={},o=r(i,["truncated"]);o!=null&&c(t,["truncated"],o);const s=r(i,["token_count"]);return s!=null&&c(t,["tokenCount"],s),t}function ra(i){const t={},o=r(i,["parts"]);if(o!=null){let u=o;Array.isArray(u)&&(u=u.map(f=>jE(f))),c(t,["parts"],u)}const s=r(i,["role"]);return s!=null&&c(t,["role"],s),t}function YS(i){const t={},o=r(i,["controlType"]);o!=null&&c(t,["controlType"],o);const s=r(i,["enableControlImageComputation"]);return s!=null&&c(t,["computeControl"],s),t}function JS(i){const t={};if(r(i,["systemInstruction"])!==void 0)throw new Error("systemInstruction parameter is not supported in Gemini API.");if(r(i,["tools"])!==void 0)throw new Error("tools parameter is not supported in Gemini API.");if(r(i,["generationConfig"])!==void 0)throw new Error("generationConfig parameter is not supported in Gemini API.");return t}function KS(i,t){const o={},s=r(i,["systemInstruction"]);t!==void 0&&s!=null&&c(t,["systemInstruction"],It(s));const u=r(i,["tools"]);if(t!==void 0&&u!=null){let m=u;Array.isArray(m)&&(m=m.map(g=>Qh(g))),c(t,["tools"],m)}const f=r(i,["generationConfig"]);return t!==void 0&&f!=null&&c(t,["generationConfig"],PE(f)),o}function XS(i,t){const o={},s=r(t,["model"]);s!=null&&c(o,["_url","model"],ke(i,s));const u=r(t,["contents"]);if(u!=null){let m=rn(u);Array.isArray(m)&&(m=m.map(g=>ra(g))),c(o,["contents"],m)}const f=r(t,["config"]);return f!=null&&JS(f),o}function QS(i,t){const o={},s=r(t,["model"]);s!=null&&c(o,["_url","model"],ke(i,s));const u=r(t,["contents"]);if(u!=null){let m=rn(u);Array.isArray(m)&&(m=m.map(g=>g)),c(o,["contents"],m)}const f=r(t,["config"]);return f!=null&&KS(f,o),o}function ZS(i){const t={},o=r(i,["sdkHttpResponse"]);o!=null&&c(t,["sdkHttpResponse"],o);const s=r(i,["totalTokens"]);s!=null&&c(t,["totalTokens"],s);const u=r(i,["cachedContentTokenCount"]);return u!=null&&c(t,["cachedContentTokenCount"],u),t}function $S(i){const t={},o=r(i,["sdkHttpResponse"]);o!=null&&c(t,["sdkHttpResponse"],o);const s=r(i,["totalTokens"]);return s!=null&&c(t,["totalTokens"],s),t}function WS(i,t){const o={},s=r(t,["model"]);return s!=null&&c(o,["_url","name"],ke(i,s)),o}function jS(i,t){const o={},s=r(t,["model"]);return s!=null&&c(o,["_url","name"],ke(i,s)),o}function eE(i){const t={},o=r(i,["sdkHttpResponse"]);return o!=null&&c(t,["sdkHttpResponse"],o),t}function tE(i){const t={},o=r(i,["sdkHttpResponse"]);return o!=null&&c(t,["sdkHttpResponse"],o),t}function nE(i,t){const o={},s=r(i,["outputGcsUri"]);t!==void 0&&s!=null&&c(t,["parameters","storageUri"],s);const u=r(i,["negativePrompt"]);t!==void 0&&u!=null&&c(t,["parameters","negativePrompt"],u);const f=r(i,["numberOfImages"]);t!==void 0&&f!=null&&c(t,["parameters","sampleCount"],f);const m=r(i,["aspectRatio"]);t!==void 0&&m!=null&&c(t,["parameters","aspectRatio"],m);const g=r(i,["guidanceScale"]);t!==void 0&&g!=null&&c(t,["parameters","guidanceScale"],g);const y=r(i,["seed"]);t!==void 0&&y!=null&&c(t,["parameters","seed"],y);const h=r(i,["safetyFilterLevel"]);t!==void 0&&h!=null&&c(t,["parameters","safetySetting"],h);const v=r(i,["personGeneration"]);t!==void 0&&v!=null&&c(t,["parameters","personGeneration"],v);const E=r(i,["includeSafetyAttributes"]);t!==void 0&&E!=null&&c(t,["parameters","includeSafetyAttributes"],E);const C=r(i,["includeRaiReason"]);t!==void 0&&C!=null&&c(t,["parameters","includeRaiReason"],C);const x=r(i,["language"]);t!==void 0&&x!=null&&c(t,["parameters","language"],x);const P=r(i,["outputMimeType"]);t!==void 0&&P!=null&&c(t,["parameters","outputOptions","mimeType"],P);const q=r(i,["outputCompressionQuality"]);t!==void 0&&q!=null&&c(t,["parameters","outputOptions","compressionQuality"],q);const V=r(i,["addWatermark"]);t!==void 0&&V!=null&&c(t,["parameters","addWatermark"],V);const Y=r(i,["labels"]);t!==void 0&&Y!=null&&c(t,["labels"],Y);const j=r(i,["editMode"]);t!==void 0&&j!=null&&c(t,["parameters","editMode"],j);const k=r(i,["baseSteps"]);return t!==void 0&&k!=null&&c(t,["parameters","editConfig","baseSteps"],k),o}function iE(i,t){const o={},s=r(t,["model"]);s!=null&&c(o,["_url","model"],ke(i,s));const u=r(t,["prompt"]);u!=null&&c(o,["instances[0]","prompt"],u);const f=r(t,["referenceImages"]);if(f!=null){let g=f;Array.isArray(g)&&(g=g.map(y=>oC(y))),c(o,["instances[0]","referenceImages"],g)}const m=r(t,["config"]);return m!=null&&nE(m,o),o}function lE(i){const t={},o=r(i,["sdkHttpResponse"]);o!=null&&c(t,["sdkHttpResponse"],o);const s=r(i,["predictions"]);if(s!=null){let u=s;Array.isArray(u)&&(u=u.map(f=>ua(f))),c(t,["generatedImages"],u)}return t}function oE(i,t){const o={},s=r(i,["taskType"]);t!==void 0&&s!=null&&c(t,["requests[]","taskType"],s);const u=r(i,["title"]);t!==void 0&&u!=null&&c(t,["requests[]","title"],u);const f=r(i,["outputDimensionality"]);if(t!==void 0&&f!=null&&c(t,["requests[]","outputDimensionality"],f),r(i,["mimeType"])!==void 0)throw new Error("mimeType parameter is not supported in Gemini API.");if(r(i,["autoTruncate"])!==void 0)throw new Error("autoTruncate parameter is not supported in Gemini API.");return o}function sE(i,t){const o={},s=r(i,["taskType"]);t!==void 0&&s!=null&&c(t,["instances[]","task_type"],s);const u=r(i,["title"]);t!==void 0&&u!=null&&c(t,["instances[]","title"],u);const f=r(i,["outputDimensionality"]);t!==void 0&&f!=null&&c(t,["parameters","outputDimensionality"],f);const m=r(i,["mimeType"]);t!==void 0&&m!=null&&c(t,["instances[]","mimeType"],m);const g=r(i,["autoTruncate"]);return t!==void 0&&g!=null&&c(t,["parameters","autoTruncate"],g),o}function aE(i,t){const o={},s=r(t,["model"]);s!=null&&c(o,["_url","model"],ke(i,s));const u=r(t,["contents"]);if(u!=null){let g=Ku(i,u);Array.isArray(g)&&(g=g.map(y=>y)),c(o,["requests[]","content"],g)}const f=r(t,["config"]);f!=null&&oE(f,o);const m=r(t,["model"]);return m!==void 0&&c(o,["requests[]","model"],ke(i,m)),o}function rE(i,t){const o={},s=r(t,["model"]);s!=null&&c(o,["_url","model"],ke(i,s));const u=r(t,["contents"]);if(u!=null){let m=Ku(i,u);Array.isArray(m)&&(m=m.map(g=>g)),c(o,["instances[]","content"],m)}const f=r(t,["config"]);return f!=null&&sE(f,o),o}function uE(i){const t={},o=r(i,["sdkHttpResponse"]);o!=null&&c(t,["sdkHttpResponse"],o);const s=r(i,["embeddings"]);if(s!=null){let f=s;Array.isArray(f)&&(f=f.map(m=>m)),c(t,["embeddings"],f)}const u=r(i,["metadata"]);return u!=null&&c(t,["metadata"],u),t}function cE(i){const t={},o=r(i,["sdkHttpResponse"]);o!=null&&c(t,["sdkHttpResponse"],o);const s=r(i,["predictions[]","embeddings"]);if(s!=null){let f=s;Array.isArray(f)&&(f=f.map(m=>FS(m))),c(t,["embeddings"],f)}const u=r(i,["metadata"]);return u!=null&&c(t,["metadata"],u),t}function fE(i){const t={},o=r(i,["endpoint"]);o!=null&&c(t,["name"],o);const s=r(i,["deployedModelId"]);return s!=null&&c(t,["deployedModelId"],s),t}function dE(i){const t={};if(r(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=r(i,["fileUri"]);o!=null&&c(t,["fileUri"],o);const s=r(i,["mimeType"]);return s!=null&&c(t,["mimeType"],s),t}function pE(i){const t={},o=r(i,["id"]);o!=null&&c(t,["id"],o);const s=r(i,["args"]);s!=null&&c(t,["args"],s);const u=r(i,["name"]);if(u!=null&&c(t,["name"],u),r(i,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(r(i,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return t}function mE(i){const t={},o=r(i,["mode"]);o!=null&&c(t,["mode"],o);const s=r(i,["allowedFunctionNames"]);if(s!=null&&c(t,["allowedFunctionNames"],s),r(i,["streamFunctionCallArguments"])!==void 0)throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return t}function hE(i){const t={};if(r(i,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");const o=r(i,["description"]);o!=null&&c(t,["description"],o);const s=r(i,["name"]);s!=null&&c(t,["name"],s);const u=r(i,["parameters"]);u!=null&&c(t,["parameters"],u);const f=r(i,["parametersJsonSchema"]);f!=null&&c(t,["parametersJsonSchema"],f);const m=r(i,["response"]);m!=null&&c(t,["response"],m);const g=r(i,["responseJsonSchema"]);return g!=null&&c(t,["responseJsonSchema"],g),t}function gE(i,t,o){const s={},u=r(t,["systemInstruction"]);o!==void 0&&u!=null&&c(o,["systemInstruction"],ra(It(u)));const f=r(t,["temperature"]);f!=null&&c(s,["temperature"],f);const m=r(t,["topP"]);m!=null&&c(s,["topP"],m);const g=r(t,["topK"]);g!=null&&c(s,["topK"],g);const y=r(t,["candidateCount"]);y!=null&&c(s,["candidateCount"],y);const h=r(t,["maxOutputTokens"]);h!=null&&c(s,["maxOutputTokens"],h);const v=r(t,["stopSequences"]);v!=null&&c(s,["stopSequences"],v);const E=r(t,["responseLogprobs"]);E!=null&&c(s,["responseLogprobs"],E);const C=r(t,["logprobs"]);C!=null&&c(s,["logprobs"],C);const x=r(t,["presencePenalty"]);x!=null&&c(s,["presencePenalty"],x);const P=r(t,["frequencyPenalty"]);P!=null&&c(s,["frequencyPenalty"],P);const q=r(t,["seed"]);q!=null&&c(s,["seed"],q);const V=r(t,["responseMimeType"]);V!=null&&c(s,["responseMimeType"],V);const Y=r(t,["responseSchema"]);Y!=null&&c(s,["responseSchema"],Xu(Y));const j=r(t,["responseJsonSchema"]);if(j!=null&&c(s,["responseJsonSchema"],j),r(t,["routingConfig"])!==void 0)throw new Error("routingConfig parameter is not supported in Gemini API.");if(r(t,["modelSelectionConfig"])!==void 0)throw new Error("modelSelectionConfig parameter is not supported in Gemini API.");const k=r(t,["safetySettings"]);if(o!==void 0&&k!=null){let Te=k;Array.isArray(Te)&&(Te=Te.map(ut=>sC(ut))),c(o,["safetySettings"],Te)}const Z=r(t,["tools"]);if(o!==void 0&&Z!=null){let Te=zl(Z);Array.isArray(Te)&&(Te=Te.map(ut=>pC(Pl(ut)))),c(o,["tools"],Te)}const ae=r(t,["toolConfig"]);if(o!==void 0&&ae!=null&&c(o,["toolConfig"],dC(ae)),r(t,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const se=r(t,["cachedContent"]);o!==void 0&&se!=null&&c(o,["cachedContent"],Jn(i,se));const K=r(t,["responseModalities"]);K!=null&&c(s,["responseModalities"],K);const Ae=r(t,["mediaResolution"]);Ae!=null&&c(s,["mediaResolution"],Ae);const ee=r(t,["speechConfig"]);if(ee!=null&&c(s,["speechConfig"],Qu(ee)),r(t,["audioTimestamp"])!==void 0)throw new Error("audioTimestamp parameter is not supported in Gemini API.");const Ee=r(t,["thinkingConfig"]);Ee!=null&&c(s,["thinkingConfig"],Ee);const be=r(t,["imageConfig"]);return be!=null&&c(s,["imageConfig"],FE(be)),s}function yE(i,t,o){const s={},u=r(t,["systemInstruction"]);o!==void 0&&u!=null&&c(o,["systemInstruction"],It(u));const f=r(t,["temperature"]);f!=null&&c(s,["temperature"],f);const m=r(t,["topP"]);m!=null&&c(s,["topP"],m);const g=r(t,["topK"]);g!=null&&c(s,["topK"],g);const y=r(t,["candidateCount"]);y!=null&&c(s,["candidateCount"],y);const h=r(t,["maxOutputTokens"]);h!=null&&c(s,["maxOutputTokens"],h);const v=r(t,["stopSequences"]);v!=null&&c(s,["stopSequences"],v);const E=r(t,["responseLogprobs"]);E!=null&&c(s,["responseLogprobs"],E);const C=r(t,["logprobs"]);C!=null&&c(s,["logprobs"],C);const x=r(t,["presencePenalty"]);x!=null&&c(s,["presencePenalty"],x);const P=r(t,["frequencyPenalty"]);P!=null&&c(s,["frequencyPenalty"],P);const q=r(t,["seed"]);q!=null&&c(s,["seed"],q);const V=r(t,["responseMimeType"]);V!=null&&c(s,["responseMimeType"],V);const Y=r(t,["responseSchema"]);Y!=null&&c(s,["responseSchema"],Xu(Y));const j=r(t,["responseJsonSchema"]);j!=null&&c(s,["responseJsonSchema"],j);const k=r(t,["routingConfig"]);k!=null&&c(s,["routingConfig"],k);const Z=r(t,["modelSelectionConfig"]);Z!=null&&c(s,["modelConfig"],Z);const ae=r(t,["safetySettings"]);if(o!==void 0&&ae!=null){let w=ae;Array.isArray(w)&&(w=w.map(F=>F)),c(o,["safetySettings"],w)}const se=r(t,["tools"]);if(o!==void 0&&se!=null){let w=zl(se);Array.isArray(w)&&(w=w.map(F=>Qh(Pl(F)))),c(o,["tools"],w)}const K=r(t,["toolConfig"]);o!==void 0&&K!=null&&c(o,["toolConfig"],K);const Ae=r(t,["labels"]);o!==void 0&&Ae!=null&&c(o,["labels"],Ae);const ee=r(t,["cachedContent"]);o!==void 0&&ee!=null&&c(o,["cachedContent"],Jn(i,ee));const Ee=r(t,["responseModalities"]);Ee!=null&&c(s,["responseModalities"],Ee);const be=r(t,["mediaResolution"]);be!=null&&c(s,["mediaResolution"],be);const Te=r(t,["speechConfig"]);Te!=null&&c(s,["speechConfig"],Xh(Qu(Te)));const ut=r(t,["audioTimestamp"]);ut!=null&&c(s,["audioTimestamp"],ut);const yt=r(t,["thinkingConfig"]);yt!=null&&c(s,["thinkingConfig"],yt);const ct=r(t,["imageConfig"]);return ct!=null&&c(s,["imageConfig"],OE(ct)),s}function uh(i,t){const o={},s=r(t,["model"]);s!=null&&c(o,["_url","model"],ke(i,s));const u=r(t,["contents"]);if(u!=null){let m=rn(u);Array.isArray(m)&&(m=m.map(g=>ra(g))),c(o,["contents"],m)}const f=r(t,["config"]);return f!=null&&c(o,["generationConfig"],gE(i,f,o)),o}function ch(i,t){const o={},s=r(t,["model"]);s!=null&&c(o,["_url","model"],ke(i,s));const u=r(t,["contents"]);if(u!=null){let m=rn(u);Array.isArray(m)&&(m=m.map(g=>g)),c(o,["contents"],m)}const f=r(t,["config"]);return f!=null&&c(o,["generationConfig"],yE(i,f,o)),o}function fh(i){const t={},o=r(i,["sdkHttpResponse"]);o!=null&&c(t,["sdkHttpResponse"],o);const s=r(i,["candidates"]);if(s!=null){let y=s;Array.isArray(y)&&(y=y.map(h=>zS(h))),c(t,["candidates"],y)}const u=r(i,["modelVersion"]);u!=null&&c(t,["modelVersion"],u);const f=r(i,["promptFeedback"]);f!=null&&c(t,["promptFeedback"],f);const m=r(i,["responseId"]);m!=null&&c(t,["responseId"],m);const g=r(i,["usageMetadata"]);return g!=null&&c(t,["usageMetadata"],g),t}function dh(i){const t={},o=r(i,["sdkHttpResponse"]);o!=null&&c(t,["sdkHttpResponse"],o);const s=r(i,["candidates"]);if(s!=null){let h=s;Array.isArray(h)&&(h=h.map(v=>v)),c(t,["candidates"],h)}const u=r(i,["createTime"]);u!=null&&c(t,["createTime"],u);const f=r(i,["modelVersion"]);f!=null&&c(t,["modelVersion"],f);const m=r(i,["promptFeedback"]);m!=null&&c(t,["promptFeedback"],m);const g=r(i,["responseId"]);g!=null&&c(t,["responseId"],g);const y=r(i,["usageMetadata"]);return y!=null&&c(t,["usageMetadata"],y),t}function vE(i,t){const o={};if(r(i,["outputGcsUri"])!==void 0)throw new Error("outputGcsUri parameter is not supported in Gemini API.");if(r(i,["negativePrompt"])!==void 0)throw new Error("negativePrompt parameter is not supported in Gemini API.");const s=r(i,["numberOfImages"]);t!==void 0&&s!=null&&c(t,["parameters","sampleCount"],s);const u=r(i,["aspectRatio"]);t!==void 0&&u!=null&&c(t,["parameters","aspectRatio"],u);const f=r(i,["guidanceScale"]);if(t!==void 0&&f!=null&&c(t,["parameters","guidanceScale"],f),r(i,["seed"])!==void 0)throw new Error("seed parameter is not supported in Gemini API.");const m=r(i,["safetyFilterLevel"]);t!==void 0&&m!=null&&c(t,["parameters","safetySetting"],m);const g=r(i,["personGeneration"]);t!==void 0&&g!=null&&c(t,["parameters","personGeneration"],g);const y=r(i,["includeSafetyAttributes"]);t!==void 0&&y!=null&&c(t,["parameters","includeSafetyAttributes"],y);const h=r(i,["includeRaiReason"]);t!==void 0&&h!=null&&c(t,["parameters","includeRaiReason"],h);const v=r(i,["language"]);t!==void 0&&v!=null&&c(t,["parameters","language"],v);const E=r(i,["outputMimeType"]);t!==void 0&&E!=null&&c(t,["parameters","outputOptions","mimeType"],E);const C=r(i,["outputCompressionQuality"]);if(t!==void 0&&C!=null&&c(t,["parameters","outputOptions","compressionQuality"],C),r(i,["addWatermark"])!==void 0)throw new Error("addWatermark parameter is not supported in Gemini API.");if(r(i,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const x=r(i,["imageSize"]);if(t!==void 0&&x!=null&&c(t,["parameters","sampleImageSize"],x),r(i,["enhancePrompt"])!==void 0)throw new Error("enhancePrompt parameter is not supported in Gemini API.");return o}function TE(i,t){const o={},s=r(i,["outputGcsUri"]);t!==void 0&&s!=null&&c(t,["parameters","storageUri"],s);const u=r(i,["negativePrompt"]);t!==void 0&&u!=null&&c(t,["parameters","negativePrompt"],u);const f=r(i,["numberOfImages"]);t!==void 0&&f!=null&&c(t,["parameters","sampleCount"],f);const m=r(i,["aspectRatio"]);t!==void 0&&m!=null&&c(t,["parameters","aspectRatio"],m);const g=r(i,["guidanceScale"]);t!==void 0&&g!=null&&c(t,["parameters","guidanceScale"],g);const y=r(i,["seed"]);t!==void 0&&y!=null&&c(t,["parameters","seed"],y);const h=r(i,["safetyFilterLevel"]);t!==void 0&&h!=null&&c(t,["parameters","safetySetting"],h);const v=r(i,["personGeneration"]);t!==void 0&&v!=null&&c(t,["parameters","personGeneration"],v);const E=r(i,["includeSafetyAttributes"]);t!==void 0&&E!=null&&c(t,["parameters","includeSafetyAttributes"],E);const C=r(i,["includeRaiReason"]);t!==void 0&&C!=null&&c(t,["parameters","includeRaiReason"],C);const x=r(i,["language"]);t!==void 0&&x!=null&&c(t,["parameters","language"],x);const P=r(i,["outputMimeType"]);t!==void 0&&P!=null&&c(t,["parameters","outputOptions","mimeType"],P);const q=r(i,["outputCompressionQuality"]);t!==void 0&&q!=null&&c(t,["parameters","outputOptions","compressionQuality"],q);const V=r(i,["addWatermark"]);t!==void 0&&V!=null&&c(t,["parameters","addWatermark"],V);const Y=r(i,["labels"]);t!==void 0&&Y!=null&&c(t,["labels"],Y);const j=r(i,["imageSize"]);t!==void 0&&j!=null&&c(t,["parameters","sampleImageSize"],j);const k=r(i,["enhancePrompt"]);return t!==void 0&&k!=null&&c(t,["parameters","enhancePrompt"],k),o}function SE(i,t){const o={},s=r(t,["model"]);s!=null&&c(o,["_url","model"],ke(i,s));const u=r(t,["prompt"]);u!=null&&c(o,["instances[0]","prompt"],u);const f=r(t,["config"]);return f!=null&&vE(f,o),o}function EE(i,t){const o={},s=r(t,["model"]);s!=null&&c(o,["_url","model"],ke(i,s));const u=r(t,["prompt"]);u!=null&&c(o,["instances[0]","prompt"],u);const f=r(t,["config"]);return f!=null&&TE(f,o),o}function CE(i){const t={},o=r(i,["sdkHttpResponse"]);o!=null&&c(t,["sdkHttpResponse"],o);const s=r(i,["predictions"]);if(s!=null){let f=s;Array.isArray(f)&&(f=f.map(m=>LE(m))),c(t,["generatedImages"],f)}const u=r(i,["positivePromptSafetyAttributes"]);return u!=null&&c(t,["positivePromptSafetyAttributes"],Jh(u)),t}function _E(i){const t={},o=r(i,["sdkHttpResponse"]);o!=null&&c(t,["sdkHttpResponse"],o);const s=r(i,["predictions"]);if(s!=null){let f=s;Array.isArray(f)&&(f=f.map(m=>ua(m))),c(t,["generatedImages"],f)}const u=r(i,["positivePromptSafetyAttributes"]);return u!=null&&c(t,["positivePromptSafetyAttributes"],Kh(u)),t}function AE(i,t){const o={},s=r(i,["numberOfVideos"]);if(t!==void 0&&s!=null&&c(t,["parameters","sampleCount"],s),r(i,["outputGcsUri"])!==void 0)throw new Error("outputGcsUri parameter is not supported in Gemini API.");if(r(i,["fps"])!==void 0)throw new Error("fps parameter is not supported in Gemini API.");const u=r(i,["durationSeconds"]);if(t!==void 0&&u!=null&&c(t,["parameters","durationSeconds"],u),r(i,["seed"])!==void 0)throw new Error("seed parameter is not supported in Gemini API.");const f=r(i,["aspectRatio"]);t!==void 0&&f!=null&&c(t,["parameters","aspectRatio"],f);const m=r(i,["resolution"]);t!==void 0&&m!=null&&c(t,["parameters","resolution"],m);const g=r(i,["personGeneration"]);if(t!==void 0&&g!=null&&c(t,["parameters","personGeneration"],g),r(i,["pubsubTopic"])!==void 0)throw new Error("pubsubTopic parameter is not supported in Gemini API.");const y=r(i,["negativePrompt"]);t!==void 0&&y!=null&&c(t,["parameters","negativePrompt"],y);const h=r(i,["enhancePrompt"]);if(t!==void 0&&h!=null&&c(t,["parameters","enhancePrompt"],h),r(i,["generateAudio"])!==void 0)throw new Error("generateAudio parameter is not supported in Gemini API.");const v=r(i,["lastFrame"]);t!==void 0&&v!=null&&c(t,["instances[0]","lastFrame"],ca(v));const E=r(i,["referenceImages"]);if(t!==void 0&&E!=null){let C=E;Array.isArray(C)&&(C=C.map(x=>NC(x))),c(t,["instances[0]","referenceImages"],C)}if(r(i,["mask"])!==void 0)throw new Error("mask parameter is not supported in Gemini API.");if(r(i,["compressionQuality"])!==void 0)throw new Error("compressionQuality parameter is not supported in Gemini API.");return o}function xE(i,t){const o={},s=r(i,["numberOfVideos"]);t!==void 0&&s!=null&&c(t,["parameters","sampleCount"],s);const u=r(i,["outputGcsUri"]);t!==void 0&&u!=null&&c(t,["parameters","storageUri"],u);const f=r(i,["fps"]);t!==void 0&&f!=null&&c(t,["parameters","fps"],f);const m=r(i,["durationSeconds"]);t!==void 0&&m!=null&&c(t,["parameters","durationSeconds"],m);const g=r(i,["seed"]);t!==void 0&&g!=null&&c(t,["parameters","seed"],g);const y=r(i,["aspectRatio"]);t!==void 0&&y!=null&&c(t,["parameters","aspectRatio"],y);const h=r(i,["resolution"]);t!==void 0&&h!=null&&c(t,["parameters","resolution"],h);const v=r(i,["personGeneration"]);t!==void 0&&v!=null&&c(t,["parameters","personGeneration"],v);const E=r(i,["pubsubTopic"]);t!==void 0&&E!=null&&c(t,["parameters","pubsubTopic"],E);const C=r(i,["negativePrompt"]);t!==void 0&&C!=null&&c(t,["parameters","negativePrompt"],C);const x=r(i,["enhancePrompt"]);t!==void 0&&x!=null&&c(t,["parameters","enhancePrompt"],x);const P=r(i,["generateAudio"]);t!==void 0&&P!=null&&c(t,["parameters","generateAudio"],P);const q=r(i,["lastFrame"]);t!==void 0&&q!=null&&c(t,["instances[0]","lastFrame"],pn(q));const V=r(i,["referenceImages"]);if(t!==void 0&&V!=null){let k=V;Array.isArray(k)&&(k=k.map(Z=>RC(Z))),c(t,["instances[0]","referenceImages"],k)}const Y=r(i,["mask"]);t!==void 0&&Y!=null&&c(t,["instances[0]","mask"],xC(Y));const j=r(i,["compressionQuality"]);return t!==void 0&&j!=null&&c(t,["parameters","compressionQuality"],j),o}function NE(i){const t={},o=r(i,["name"]);o!=null&&c(t,["name"],o);const s=r(i,["metadata"]);s!=null&&c(t,["metadata"],s);const u=r(i,["done"]);u!=null&&c(t,["done"],u);const f=r(i,["error"]);f!=null&&c(t,["error"],f);const m=r(i,["response","generateVideoResponse"]);return m!=null&&c(t,["response"],bE(m)),t}function RE(i){const t={},o=r(i,["name"]);o!=null&&c(t,["name"],o);const s=r(i,["metadata"]);s!=null&&c(t,["metadata"],s);const u=r(i,["done"]);u!=null&&c(t,["done"],u);const f=r(i,["error"]);f!=null&&c(t,["error"],f);const m=r(i,["response"]);return m!=null&&c(t,["response"],IE(m)),t}function ME(i,t){const o={},s=r(t,["model"]);s!=null&&c(o,["_url","model"],ke(i,s));const u=r(t,["prompt"]);u!=null&&c(o,["instances[0]","prompt"],u);const f=r(t,["image"]);f!=null&&c(o,["instances[0]","image"],ca(f));const m=r(t,["video"]);m!=null&&c(o,["instances[0]","video"],Zh(m));const g=r(t,["source"]);g!=null&&DE(g,o);const y=r(t,["config"]);return y!=null&&AE(y,o),o}function wE(i,t){const o={},s=r(t,["model"]);s!=null&&c(o,["_url","model"],ke(i,s));const u=r(t,["prompt"]);u!=null&&c(o,["instances[0]","prompt"],u);const f=r(t,["image"]);f!=null&&c(o,["instances[0]","image"],pn(f));const m=r(t,["video"]);m!=null&&c(o,["instances[0]","video"],$h(m));const g=r(t,["source"]);g!=null&&UE(g,o);const y=r(t,["config"]);return y!=null&&xE(y,o),o}function bE(i){const t={},o=r(i,["generatedSamples"]);if(o!=null){let f=o;Array.isArray(f)&&(f=f.map(m=>GE(m))),c(t,["generatedVideos"],f)}const s=r(i,["raiMediaFilteredCount"]);s!=null&&c(t,["raiMediaFilteredCount"],s);const u=r(i,["raiMediaFilteredReasons"]);return u!=null&&c(t,["raiMediaFilteredReasons"],u),t}function IE(i){const t={},o=r(i,["videos"]);if(o!=null){let f=o;Array.isArray(f)&&(f=f.map(m=>HE(m))),c(t,["generatedVideos"],f)}const s=r(i,["raiMediaFilteredCount"]);s!=null&&c(t,["raiMediaFilteredCount"],s);const u=r(i,["raiMediaFilteredReasons"]);return u!=null&&c(t,["raiMediaFilteredReasons"],u),t}function DE(i,t){const o={},s=r(i,["prompt"]);t!==void 0&&s!=null&&c(t,["instances[0]","prompt"],s);const u=r(i,["image"]);t!==void 0&&u!=null&&c(t,["instances[0]","image"],ca(u));const f=r(i,["video"]);return t!==void 0&&f!=null&&c(t,["instances[0]","video"],Zh(f)),o}function UE(i,t){const o={},s=r(i,["prompt"]);t!==void 0&&s!=null&&c(t,["instances[0]","prompt"],s);const u=r(i,["image"]);t!==void 0&&u!=null&&c(t,["instances[0]","image"],pn(u));const f=r(i,["video"]);return t!==void 0&&f!=null&&c(t,["instances[0]","video"],$h(f)),o}function LE(i){const t={},o=r(i,["_self"]);o!=null&&c(t,["image"],YE(o));const s=r(i,["raiFilteredReason"]);s!=null&&c(t,["raiFilteredReason"],s);const u=r(i,["_self"]);return u!=null&&c(t,["safetyAttributes"],Jh(u)),t}function ua(i){const t={},o=r(i,["_self"]);o!=null&&c(t,["image"],Yh(o));const s=r(i,["raiFilteredReason"]);s!=null&&c(t,["raiFilteredReason"],s);const u=r(i,["_self"]);u!=null&&c(t,["safetyAttributes"],Kh(u));const f=r(i,["prompt"]);return f!=null&&c(t,["enhancedPrompt"],f),t}function qE(i){const t={},o=r(i,["_self"]);o!=null&&c(t,["mask"],Yh(o));const s=r(i,["labels"]);if(s!=null){let u=s;Array.isArray(u)&&(u=u.map(f=>f)),c(t,["labels"],u)}return t}function GE(i){const t={},o=r(i,["video"]);return o!=null&&c(t,["video"],_C(o)),t}function HE(i){const t={},o=r(i,["_self"]);return o!=null&&c(t,["video"],AC(o)),t}function PE(i){const t={},o=r(i,["modelSelectionConfig"]);o!=null&&c(t,["modelConfig"],o);const s=r(i,["responseJsonSchema"]);s!=null&&c(t,["responseJsonSchema"],s);const u=r(i,["audioTimestamp"]);u!=null&&c(t,["audioTimestamp"],u);const f=r(i,["candidateCount"]);f!=null&&c(t,["candidateCount"],f);const m=r(i,["enableAffectiveDialog"]);m!=null&&c(t,["enableAffectiveDialog"],m);const g=r(i,["frequencyPenalty"]);g!=null&&c(t,["frequencyPenalty"],g);const y=r(i,["logprobs"]);y!=null&&c(t,["logprobs"],y);const h=r(i,["maxOutputTokens"]);h!=null&&c(t,["maxOutputTokens"],h);const v=r(i,["mediaResolution"]);v!=null&&c(t,["mediaResolution"],v);const E=r(i,["presencePenalty"]);E!=null&&c(t,["presencePenalty"],E);const C=r(i,["responseLogprobs"]);C!=null&&c(t,["responseLogprobs"],C);const x=r(i,["responseMimeType"]);x!=null&&c(t,["responseMimeType"],x);const P=r(i,["responseModalities"]);P!=null&&c(t,["responseModalities"],P);const q=r(i,["responseSchema"]);q!=null&&c(t,["responseSchema"],q);const V=r(i,["routingConfig"]);V!=null&&c(t,["routingConfig"],V);const Y=r(i,["seed"]);Y!=null&&c(t,["seed"],Y);const j=r(i,["speechConfig"]);j!=null&&c(t,["speechConfig"],Xh(j));const k=r(i,["stopSequences"]);k!=null&&c(t,["stopSequences"],k);const Z=r(i,["temperature"]);Z!=null&&c(t,["temperature"],Z);const ae=r(i,["thinkingConfig"]);ae!=null&&c(t,["thinkingConfig"],ae);const se=r(i,["topK"]);se!=null&&c(t,["topK"],se);const K=r(i,["topP"]);if(K!=null&&c(t,["topP"],K),r(i,["enableEnhancedCivicAnswers"])!==void 0)throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");return t}function zE(i,t){const o={},s=r(t,["model"]);return s!=null&&c(o,["_url","name"],ke(i,s)),o}function VE(i,t){const o={},s=r(t,["model"]);return s!=null&&c(o,["_url","name"],ke(i,s)),o}function kE(i){const t={};if(r(i,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const o=r(i,["enableWidget"]);return o!=null&&c(t,["enableWidget"],o),t}function BE(i){const t={};if(r(i,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(r(i,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const o=r(i,["timeRangeFilter"]);return o!=null&&c(t,["timeRangeFilter"],o),t}function FE(i){const t={},o=r(i,["aspectRatio"]);o!=null&&c(t,["aspectRatio"],o);const s=r(i,["imageSize"]);if(s!=null&&c(t,["imageSize"],s),r(i,["outputMimeType"])!==void 0)throw new Error("outputMimeType parameter is not supported in Gemini API.");if(r(i,["outputCompressionQuality"])!==void 0)throw new Error("outputCompressionQuality parameter is not supported in Gemini API.");return t}function OE(i){const t={},o=r(i,["aspectRatio"]);o!=null&&c(t,["aspectRatio"],o);const s=r(i,["imageSize"]);s!=null&&c(t,["imageSize"],s);const u=r(i,["outputMimeType"]);u!=null&&c(t,["imageOutputOptions","mimeType"],u);const f=r(i,["outputCompressionQuality"]);return f!=null&&c(t,["imageOutputOptions","compressionQuality"],f),t}function YE(i){const t={},o=r(i,["bytesBase64Encoded"]);o!=null&&c(t,["imageBytes"],_i(o));const s=r(i,["mimeType"]);return s!=null&&c(t,["mimeType"],s),t}function Yh(i){const t={},o=r(i,["gcsUri"]);o!=null&&c(t,["gcsUri"],o);const s=r(i,["bytesBase64Encoded"]);s!=null&&c(t,["imageBytes"],_i(s));const u=r(i,["mimeType"]);return u!=null&&c(t,["mimeType"],u),t}function ca(i){const t={};if(r(i,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");const o=r(i,["imageBytes"]);o!=null&&c(t,["bytesBase64Encoded"],_i(o));const s=r(i,["mimeType"]);return s!=null&&c(t,["mimeType"],s),t}function pn(i){const t={},o=r(i,["gcsUri"]);o!=null&&c(t,["gcsUri"],o);const s=r(i,["imageBytes"]);s!=null&&c(t,["bytesBase64Encoded"],_i(s));const u=r(i,["mimeType"]);return u!=null&&c(t,["mimeType"],u),t}function JE(i,t,o){const s={},u=r(t,["pageSize"]);o!==void 0&&u!=null&&c(o,["_query","pageSize"],u);const f=r(t,["pageToken"]);o!==void 0&&f!=null&&c(o,["_query","pageToken"],f);const m=r(t,["filter"]);o!==void 0&&m!=null&&c(o,["_query","filter"],m);const g=r(t,["queryBase"]);return o!==void 0&&g!=null&&c(o,["_url","models_url"],Hh(i,g)),s}function KE(i,t,o){const s={},u=r(t,["pageSize"]);o!==void 0&&u!=null&&c(o,["_query","pageSize"],u);const f=r(t,["pageToken"]);o!==void 0&&f!=null&&c(o,["_query","pageToken"],f);const m=r(t,["filter"]);o!==void 0&&m!=null&&c(o,["_query","filter"],m);const g=r(t,["queryBase"]);return o!==void 0&&g!=null&&c(o,["_url","models_url"],Hh(i,g)),s}function XE(i,t){const o={},s=r(t,["config"]);return s!=null&&JE(i,s,o),o}function QE(i,t){const o={},s=r(t,["config"]);return s!=null&&KE(i,s,o),o}function ZE(i){const t={},o=r(i,["sdkHttpResponse"]);o!=null&&c(t,["sdkHttpResponse"],o);const s=r(i,["nextPageToken"]);s!=null&&c(t,["nextPageToken"],s);const u=r(i,["_self"]);if(u!=null){let f=Ph(u);Array.isArray(f)&&(f=f.map(m=>Pu(m))),c(t,["models"],f)}return t}function $E(i){const t={},o=r(i,["sdkHttpResponse"]);o!=null&&c(t,["sdkHttpResponse"],o);const s=r(i,["nextPageToken"]);s!=null&&c(t,["nextPageToken"],s);const u=r(i,["_self"]);if(u!=null){let f=Ph(u);Array.isArray(f)&&(f=f.map(m=>zu(m))),c(t,["models"],f)}return t}function WE(i){const t={},o=r(i,["maskMode"]);o!=null&&c(t,["maskMode"],o);const s=r(i,["segmentationClasses"]);s!=null&&c(t,["maskClasses"],s);const u=r(i,["maskDilation"]);return u!=null&&c(t,["dilation"],u),t}function Pu(i){const t={},o=r(i,["name"]);o!=null&&c(t,["name"],o);const s=r(i,["displayName"]);s!=null&&c(t,["displayName"],s);const u=r(i,["description"]);u!=null&&c(t,["description"],u);const f=r(i,["version"]);f!=null&&c(t,["version"],f);const m=r(i,["_self"]);m!=null&&c(t,["tunedModelInfo"],mC(m));const g=r(i,["inputTokenLimit"]);g!=null&&c(t,["inputTokenLimit"],g);const y=r(i,["outputTokenLimit"]);y!=null&&c(t,["outputTokenLimit"],y);const h=r(i,["supportedGenerationMethods"]);h!=null&&c(t,["supportedActions"],h);const v=r(i,["temperature"]);v!=null&&c(t,["temperature"],v);const E=r(i,["maxTemperature"]);E!=null&&c(t,["maxTemperature"],E);const C=r(i,["topP"]);C!=null&&c(t,["topP"],C);const x=r(i,["topK"]);x!=null&&c(t,["topK"],x);const P=r(i,["thinking"]);return P!=null&&c(t,["thinking"],P),t}function zu(i){const t={},o=r(i,["name"]);o!=null&&c(t,["name"],o);const s=r(i,["displayName"]);s!=null&&c(t,["displayName"],s);const u=r(i,["description"]);u!=null&&c(t,["description"],u);const f=r(i,["versionId"]);f!=null&&c(t,["version"],f);const m=r(i,["deployedModels"]);if(m!=null){let E=m;Array.isArray(E)&&(E=E.map(C=>fE(C))),c(t,["endpoints"],E)}const g=r(i,["labels"]);g!=null&&c(t,["labels"],g);const y=r(i,["_self"]);y!=null&&c(t,["tunedModelInfo"],hC(y));const h=r(i,["defaultCheckpointId"]);h!=null&&c(t,["defaultCheckpointId"],h);const v=r(i,["checkpoints"]);if(v!=null){let E=v;Array.isArray(E)&&(E=E.map(C=>C)),c(t,["checkpoints"],E)}return t}function jE(i){const t={},o=r(i,["mediaResolution"]);o!=null&&c(t,["mediaResolution"],o);const s=r(i,["codeExecutionResult"]);s!=null&&c(t,["codeExecutionResult"],s);const u=r(i,["executableCode"]);u!=null&&c(t,["executableCode"],u);const f=r(i,["fileData"]);f!=null&&c(t,["fileData"],dE(f));const m=r(i,["functionCall"]);m!=null&&c(t,["functionCall"],pE(m));const g=r(i,["functionResponse"]);g!=null&&c(t,["functionResponse"],g);const y=r(i,["inlineData"]);y!=null&&c(t,["inlineData"],PS(y));const h=r(i,["text"]);h!=null&&c(t,["text"],h);const v=r(i,["thought"]);v!=null&&c(t,["thought"],v);const E=r(i,["thoughtSignature"]);E!=null&&c(t,["thoughtSignature"],E);const C=r(i,["videoMetadata"]);return C!=null&&c(t,["videoMetadata"],C),t}function eC(i){const t={},o=r(i,["productImage"]);return o!=null&&c(t,["image"],pn(o)),t}function tC(i,t){const o={},s=r(i,["numberOfImages"]);t!==void 0&&s!=null&&c(t,["parameters","sampleCount"],s);const u=r(i,["baseSteps"]);t!==void 0&&u!=null&&c(t,["parameters","baseSteps"],u);const f=r(i,["outputGcsUri"]);t!==void 0&&f!=null&&c(t,["parameters","storageUri"],f);const m=r(i,["seed"]);t!==void 0&&m!=null&&c(t,["parameters","seed"],m);const g=r(i,["safetyFilterLevel"]);t!==void 0&&g!=null&&c(t,["parameters","safetySetting"],g);const y=r(i,["personGeneration"]);t!==void 0&&y!=null&&c(t,["parameters","personGeneration"],y);const h=r(i,["addWatermark"]);t!==void 0&&h!=null&&c(t,["parameters","addWatermark"],h);const v=r(i,["outputMimeType"]);t!==void 0&&v!=null&&c(t,["parameters","outputOptions","mimeType"],v);const E=r(i,["outputCompressionQuality"]);t!==void 0&&E!=null&&c(t,["parameters","outputOptions","compressionQuality"],E);const C=r(i,["enhancePrompt"]);t!==void 0&&C!=null&&c(t,["parameters","enhancePrompt"],C);const x=r(i,["labels"]);return t!==void 0&&x!=null&&c(t,["labels"],x),o}function nC(i,t){const o={},s=r(t,["model"]);s!=null&&c(o,["_url","model"],ke(i,s));const u=r(t,["source"]);u!=null&&lC(u,o);const f=r(t,["config"]);return f!=null&&tC(f,o),o}function iC(i){const t={},o=r(i,["predictions"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(u=>ua(u))),c(t,["generatedImages"],s)}return t}function lC(i,t){const o={},s=r(i,["prompt"]);t!==void 0&&s!=null&&c(t,["instances[0]","prompt"],s);const u=r(i,["personImage"]);t!==void 0&&u!=null&&c(t,["instances[0]","personImage","image"],pn(u));const f=r(i,["productImages"]);if(t!==void 0&&f!=null){let m=f;Array.isArray(m)&&(m=m.map(g=>eC(g))),c(t,["instances[0]","productImages"],m)}return o}function oC(i){const t={},o=r(i,["referenceImage"]);o!=null&&c(t,["referenceImage"],pn(o));const s=r(i,["referenceId"]);s!=null&&c(t,["referenceId"],s);const u=r(i,["referenceType"]);u!=null&&c(t,["referenceType"],u);const f=r(i,["maskImageConfig"]);f!=null&&c(t,["maskImageConfig"],WE(f));const m=r(i,["controlImageConfig"]);m!=null&&c(t,["controlImageConfig"],YS(m));const g=r(i,["styleImageConfig"]);g!=null&&c(t,["styleImageConfig"],g);const y=r(i,["subjectImageConfig"]);return y!=null&&c(t,["subjectImageConfig"],y),t}function Jh(i){const t={},o=r(i,["safetyAttributes","categories"]);o!=null&&c(t,["categories"],o);const s=r(i,["safetyAttributes","scores"]);s!=null&&c(t,["scores"],s);const u=r(i,["contentType"]);return u!=null&&c(t,["contentType"],u),t}function Kh(i){const t={},o=r(i,["safetyAttributes","categories"]);o!=null&&c(t,["categories"],o);const s=r(i,["safetyAttributes","scores"]);s!=null&&c(t,["scores"],s);const u=r(i,["contentType"]);return u!=null&&c(t,["contentType"],u),t}function sC(i){const t={},o=r(i,["category"]);if(o!=null&&c(t,["category"],o),r(i,["method"])!==void 0)throw new Error("method parameter is not supported in Gemini API.");const s=r(i,["threshold"]);return s!=null&&c(t,["threshold"],s),t}function aC(i){const t={},o=r(i,["image"]);return o!=null&&c(t,["image"],pn(o)),t}function rC(i,t){const o={},s=r(i,["mode"]);t!==void 0&&s!=null&&c(t,["parameters","mode"],s);const u=r(i,["maxPredictions"]);t!==void 0&&u!=null&&c(t,["parameters","maxPredictions"],u);const f=r(i,["confidenceThreshold"]);t!==void 0&&f!=null&&c(t,["parameters","confidenceThreshold"],f);const m=r(i,["maskDilation"]);t!==void 0&&m!=null&&c(t,["parameters","maskDilation"],m);const g=r(i,["binaryColorThreshold"]);t!==void 0&&g!=null&&c(t,["parameters","binaryColorThreshold"],g);const y=r(i,["labels"]);return t!==void 0&&y!=null&&c(t,["labels"],y),o}function uC(i,t){const o={},s=r(t,["model"]);s!=null&&c(o,["_url","model"],ke(i,s));const u=r(t,["source"]);u!=null&&fC(u,o);const f=r(t,["config"]);return f!=null&&rC(f,o),o}function cC(i){const t={},o=r(i,["predictions"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(u=>qE(u))),c(t,["generatedMasks"],s)}return t}function fC(i,t){const o={},s=r(i,["prompt"]);t!==void 0&&s!=null&&c(t,["instances[0]","prompt"],s);const u=r(i,["image"]);t!==void 0&&u!=null&&c(t,["instances[0]","image"],pn(u));const f=r(i,["scribbleImage"]);return t!==void 0&&f!=null&&c(t,["instances[0]","scribble"],aC(f)),o}function Xh(i){const t={},o=r(i,["languageCode"]);o!=null&&c(t,["languageCode"],o);const s=r(i,["voiceConfig"]);if(s!=null&&c(t,["voiceConfig"],s),r(i,["multiSpeakerVoiceConfig"])!==void 0)throw new Error("multiSpeakerVoiceConfig parameter is not supported in Vertex AI.");return t}function dC(i){const t={},o=r(i,["functionCallingConfig"]);o!=null&&c(t,["functionCallingConfig"],mE(o));const s=r(i,["retrievalConfig"]);return s!=null&&c(t,["retrievalConfig"],s),t}function pC(i){const t={},o=r(i,["functionDeclarations"]);if(o!=null){let v=o;Array.isArray(v)&&(v=v.map(E=>E)),c(t,["functionDeclarations"],v)}if(r(i,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const s=r(i,["googleSearchRetrieval"]);s!=null&&c(t,["googleSearchRetrieval"],s);const u=r(i,["computerUse"]);u!=null&&c(t,["computerUse"],u);const f=r(i,["fileSearch"]);f!=null&&c(t,["fileSearch"],f);const m=r(i,["codeExecution"]);if(m!=null&&c(t,["codeExecution"],m),r(i,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const g=r(i,["googleMaps"]);g!=null&&c(t,["googleMaps"],kE(g));const y=r(i,["googleSearch"]);y!=null&&c(t,["googleSearch"],BE(y));const h=r(i,["urlContext"]);return h!=null&&c(t,["urlContext"],h),t}function Qh(i){const t={},o=r(i,["functionDeclarations"]);if(o!=null){let E=o;Array.isArray(E)&&(E=E.map(C=>hE(C))),c(t,["functionDeclarations"],E)}const s=r(i,["retrieval"]);s!=null&&c(t,["retrieval"],s);const u=r(i,["googleSearchRetrieval"]);u!=null&&c(t,["googleSearchRetrieval"],u);const f=r(i,["computerUse"]);if(f!=null&&c(t,["computerUse"],f),r(i,["fileSearch"])!==void 0)throw new Error("fileSearch parameter is not supported in Vertex AI.");const m=r(i,["codeExecution"]);m!=null&&c(t,["codeExecution"],m);const g=r(i,["enterpriseWebSearch"]);g!=null&&c(t,["enterpriseWebSearch"],g);const y=r(i,["googleMaps"]);y!=null&&c(t,["googleMaps"],y);const h=r(i,["googleSearch"]);h!=null&&c(t,["googleSearch"],h);const v=r(i,["urlContext"]);return v!=null&&c(t,["urlContext"],v),t}function mC(i){const t={},o=r(i,["baseModel"]);o!=null&&c(t,["baseModel"],o);const s=r(i,["createTime"]);s!=null&&c(t,["createTime"],s);const u=r(i,["updateTime"]);return u!=null&&c(t,["updateTime"],u),t}function hC(i){const t={},o=r(i,["labels","google-vertex-llm-tuning-base-model-id"]);o!=null&&c(t,["baseModel"],o);const s=r(i,["createTime"]);s!=null&&c(t,["createTime"],s);const u=r(i,["updateTime"]);return u!=null&&c(t,["updateTime"],u),t}function gC(i,t){const o={},s=r(i,["displayName"]);t!==void 0&&s!=null&&c(t,["displayName"],s);const u=r(i,["description"]);t!==void 0&&u!=null&&c(t,["description"],u);const f=r(i,["defaultCheckpointId"]);return t!==void 0&&f!=null&&c(t,["defaultCheckpointId"],f),o}function yC(i,t){const o={},s=r(i,["displayName"]);t!==void 0&&s!=null&&c(t,["displayName"],s);const u=r(i,["description"]);t!==void 0&&u!=null&&c(t,["description"],u);const f=r(i,["defaultCheckpointId"]);return t!==void 0&&f!=null&&c(t,["defaultCheckpointId"],f),o}function vC(i,t){const o={},s=r(t,["model"]);s!=null&&c(o,["_url","name"],ke(i,s));const u=r(t,["config"]);return u!=null&&gC(u,o),o}function TC(i,t){const o={},s=r(t,["model"]);s!=null&&c(o,["_url","model"],ke(i,s));const u=r(t,["config"]);return u!=null&&yC(u,o),o}function SC(i,t){const o={},s=r(i,["outputGcsUri"]);t!==void 0&&s!=null&&c(t,["parameters","storageUri"],s);const u=r(i,["safetyFilterLevel"]);t!==void 0&&u!=null&&c(t,["parameters","safetySetting"],u);const f=r(i,["personGeneration"]);t!==void 0&&f!=null&&c(t,["parameters","personGeneration"],f);const m=r(i,["includeRaiReason"]);t!==void 0&&m!=null&&c(t,["parameters","includeRaiReason"],m);const g=r(i,["outputMimeType"]);t!==void 0&&g!=null&&c(t,["parameters","outputOptions","mimeType"],g);const y=r(i,["outputCompressionQuality"]);t!==void 0&&y!=null&&c(t,["parameters","outputOptions","compressionQuality"],y);const h=r(i,["enhanceInputImage"]);t!==void 0&&h!=null&&c(t,["parameters","upscaleConfig","enhanceInputImage"],h);const v=r(i,["imagePreservationFactor"]);t!==void 0&&v!=null&&c(t,["parameters","upscaleConfig","imagePreservationFactor"],v);const E=r(i,["labels"]);t!==void 0&&E!=null&&c(t,["labels"],E);const C=r(i,["numberOfImages"]);t!==void 0&&C!=null&&c(t,["parameters","sampleCount"],C);const x=r(i,["mode"]);return t!==void 0&&x!=null&&c(t,["parameters","mode"],x),o}function EC(i,t){const o={},s=r(t,["model"]);s!=null&&c(o,["_url","model"],ke(i,s));const u=r(t,["image"]);u!=null&&c(o,["instances[0]","image"],pn(u));const f=r(t,["upscaleFactor"]);f!=null&&c(o,["parameters","upscaleConfig","upscaleFactor"],f);const m=r(t,["config"]);return m!=null&&SC(m,o),o}function CC(i){const t={},o=r(i,["sdkHttpResponse"]);o!=null&&c(t,["sdkHttpResponse"],o);const s=r(i,["predictions"]);if(s!=null){let u=s;Array.isArray(u)&&(u=u.map(f=>ua(f))),c(t,["generatedImages"],u)}return t}function _C(i){const t={},o=r(i,["uri"]);o!=null&&c(t,["uri"],o);const s=r(i,["encodedVideo"]);s!=null&&c(t,["videoBytes"],_i(s));const u=r(i,["encoding"]);return u!=null&&c(t,["mimeType"],u),t}function AC(i){const t={},o=r(i,["gcsUri"]);o!=null&&c(t,["uri"],o);const s=r(i,["bytesBase64Encoded"]);s!=null&&c(t,["videoBytes"],_i(s));const u=r(i,["mimeType"]);return u!=null&&c(t,["mimeType"],u),t}function xC(i){const t={},o=r(i,["image"]);o!=null&&c(t,["_self"],pn(o));const s=r(i,["maskMode"]);return s!=null&&c(t,["maskMode"],s),t}function NC(i){const t={},o=r(i,["image"]);o!=null&&c(t,["image"],ca(o));const s=r(i,["referenceType"]);return s!=null&&c(t,["referenceType"],s),t}function RC(i){const t={},o=r(i,["image"]);o!=null&&c(t,["image"],pn(o));const s=r(i,["referenceType"]);return s!=null&&c(t,["referenceType"],s),t}function Zh(i){const t={},o=r(i,["uri"]);o!=null&&c(t,["uri"],o);const s=r(i,["videoBytes"]);s!=null&&c(t,["encodedVideo"],_i(s));const u=r(i,["mimeType"]);return u!=null&&c(t,["encoding"],u),t}function $h(i){const t={},o=r(i,["uri"]);o!=null&&c(t,["gcsUri"],o);const s=r(i,["videoBytes"]);s!=null&&c(t,["bytesBase64Encoded"],_i(s));const u=r(i,["mimeType"]);return u!=null&&c(t,["mimeType"],u),t}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function MC(i,t){const o={},s=r(i,["displayName"]);return t!==void 0&&s!=null&&c(t,["displayName"],s),o}function wC(i){const t={},o=r(i,["config"]);return o!=null&&MC(o,t),t}function bC(i,t){const o={},s=r(i,["force"]);return t!==void 0&&s!=null&&c(t,["_query","force"],s),o}function IC(i){const t={},o=r(i,["name"]);o!=null&&c(t,["_url","name"],o);const s=r(i,["config"]);return s!=null&&bC(s,t),t}function DC(i){const t={},o=r(i,["name"]);return o!=null&&c(t,["_url","name"],o),t}function UC(i,t){const o={},s=r(i,["customMetadata"]);if(t!==void 0&&s!=null){let f=s;Array.isArray(f)&&(f=f.map(m=>m)),c(t,["customMetadata"],f)}const u=r(i,["chunkingConfig"]);return t!==void 0&&u!=null&&c(t,["chunkingConfig"],u),o}function LC(i){const t={},o=r(i,["name"]);o!=null&&c(t,["name"],o);const s=r(i,["metadata"]);s!=null&&c(t,["metadata"],s);const u=r(i,["done"]);u!=null&&c(t,["done"],u);const f=r(i,["error"]);f!=null&&c(t,["error"],f);const m=r(i,["response"]);return m!=null&&c(t,["response"],GC(m)),t}function qC(i){const t={},o=r(i,["fileSearchStoreName"]);o!=null&&c(t,["_url","file_search_store_name"],o);const s=r(i,["fileName"]);s!=null&&c(t,["fileName"],s);const u=r(i,["config"]);return u!=null&&UC(u,t),t}function GC(i){const t={},o=r(i,["sdkHttpResponse"]);o!=null&&c(t,["sdkHttpResponse"],o);const s=r(i,["parent"]);s!=null&&c(t,["parent"],s);const u=r(i,["documentName"]);return u!=null&&c(t,["documentName"],u),t}function HC(i,t){const o={},s=r(i,["pageSize"]);t!==void 0&&s!=null&&c(t,["_query","pageSize"],s);const u=r(i,["pageToken"]);return t!==void 0&&u!=null&&c(t,["_query","pageToken"],u),o}function PC(i){const t={},o=r(i,["config"]);return o!=null&&HC(o,t),t}function zC(i){const t={},o=r(i,["sdkHttpResponse"]);o!=null&&c(t,["sdkHttpResponse"],o);const s=r(i,["nextPageToken"]);s!=null&&c(t,["nextPageToken"],s);const u=r(i,["fileSearchStores"]);if(u!=null){let f=u;Array.isArray(f)&&(f=f.map(m=>m)),c(t,["fileSearchStores"],f)}return t}function Wh(i,t){const o={},s=r(i,["mimeType"]);t!==void 0&&s!=null&&c(t,["mimeType"],s);const u=r(i,["displayName"]);t!==void 0&&u!=null&&c(t,["displayName"],u);const f=r(i,["customMetadata"]);if(t!==void 0&&f!=null){let g=f;Array.isArray(g)&&(g=g.map(y=>y)),c(t,["customMetadata"],g)}const m=r(i,["chunkingConfig"]);return t!==void 0&&m!=null&&c(t,["chunkingConfig"],m),o}function VC(i){const t={},o=r(i,["fileSearchStoreName"]);o!=null&&c(t,["_url","file_search_store_name"],o);const s=r(i,["config"]);return s!=null&&Wh(s,t),t}function kC(i){const t={},o=r(i,["sdkHttpResponse"]);return o!=null&&c(t,["sdkHttpResponse"],o),t}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */const BC="Content-Type",FC="X-Server-Timeout",OC="User-Agent",Vu="x-goog-api-client",YC="1.31.0",JC=`google-genai-sdk/${YC}`,KC="v1beta1",XC="v1beta",ph=/^\s*data: (.*)(?:\n\n|\r\r|\r\n\r\n)/;class QC{constructor(t){var o,s;this.clientOptions=Object.assign(Object.assign({},t),{project:t.project,location:t.location,apiKey:t.apiKey,vertexai:t.vertexai});const u={};this.clientOptions.vertexai?(u.apiVersion=(o=this.clientOptions.apiVersion)!==null&&o!==void 0?o:KC,u.baseUrl=this.baseUrlFromProjectLocation(),this.normalizeAuthParameters()):(u.apiVersion=(s=this.clientOptions.apiVersion)!==null&&s!==void 0?s:XC,u.baseUrl="https://generativelanguage.googleapis.com/"),u.headers=this.getDefaultHeaders(),this.clientOptions.httpOptions=u,t.httpOptions&&(this.clientOptions.httpOptions=this.patchHttpOptions(u,t.httpOptions))}baseUrlFromProjectLocation(){return this.clientOptions.project&&this.clientOptions.location&&this.clientOptions.location!=="global"?`https://${this.clientOptions.location}-aiplatform.googleapis.com/`:"https://aiplatform.googleapis.com/"}normalizeAuthParameters(){if(this.clientOptions.project&&this.clientOptions.location){this.clientOptions.apiKey=void 0;return}this.clientOptions.project=void 0,this.clientOptions.location=void 0}isVertexAI(){var t;return(t=this.clientOptions.vertexai)!==null&&t!==void 0?t:!1}getProject(){return this.clientOptions.project}getLocation(){return this.clientOptions.location}getApiVersion(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.apiVersion!==void 0)return this.clientOptions.httpOptions.apiVersion;throw new Error("API version is not set.")}getBaseUrl(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.baseUrl!==void 0)return this.clientOptions.httpOptions.baseUrl;throw new Error("Base URL is not set.")}getRequestUrl(){return this.getRequestUrlInternal(this.clientOptions.httpOptions)}getHeaders(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.headers!==void 0)return this.clientOptions.httpOptions.headers;throw new Error("Headers are not set.")}getRequestUrlInternal(t){if(!t||t.baseUrl===void 0||t.apiVersion===void 0)throw new Error("HTTP options are not correctly set.");const s=[t.baseUrl.endsWith("/")?t.baseUrl.slice(0,-1):t.baseUrl];return t.apiVersion&&t.apiVersion!==""&&s.push(t.apiVersion),s.join("/")}getBaseResourcePath(){return`projects/${this.clientOptions.project}/locations/${this.clientOptions.location}`}getApiKey(){return this.clientOptions.apiKey}getWebsocketBaseUrl(){const t=this.getBaseUrl(),o=new URL(t);return o.protocol=o.protocol=="http:"?"ws":"wss",o.toString()}setBaseUrl(t){if(this.clientOptions.httpOptions)this.clientOptions.httpOptions.baseUrl=t;else throw new Error("HTTP options are not correctly set.")}constructUrl(t,o,s){const u=[this.getRequestUrlInternal(o)];return s&&u.push(this.getBaseResourcePath()),t!==""&&u.push(t),new URL(`${u.join("/")}`)}shouldPrependVertexProjectPath(t){return!(this.clientOptions.apiKey||!this.clientOptions.vertexai||t.path.startsWith("projects/")||t.httpMethod==="GET"&&t.path.startsWith("publishers/google/models"))}async request(t){let o=this.clientOptions.httpOptions;t.httpOptions&&(o=this.patchHttpOptions(this.clientOptions.httpOptions,t.httpOptions));const s=this.shouldPrependVertexProjectPath(t),u=this.constructUrl(t.path,o,s);if(t.queryParams)for(const[m,g]of Object.entries(t.queryParams))u.searchParams.append(m,String(g));let f={};if(t.httpMethod==="GET"){if(t.body&&t.body!=="{}")throw new Error("Request body should be empty for GET request, but got non empty request body")}else f.body=t.body;return f=await this.includeExtraHttpOptionsToRequestInit(f,o,u.toString(),t.abortSignal),this.unaryApiCall(u,f,t.httpMethod)}patchHttpOptions(t,o){const s=JSON.parse(JSON.stringify(t));for(const[u,f]of Object.entries(o))typeof f=="object"?s[u]=Object.assign(Object.assign({},s[u]),f):f!==void 0&&(s[u]=f);return s}async requestStream(t){let o=this.clientOptions.httpOptions;t.httpOptions&&(o=this.patchHttpOptions(this.clientOptions.httpOptions,t.httpOptions));const s=this.shouldPrependVertexProjectPath(t),u=this.constructUrl(t.path,o,s);(!u.searchParams.has("alt")||u.searchParams.get("alt")!=="sse")&&u.searchParams.set("alt","sse");let f={};return f.body=t.body,f=await this.includeExtraHttpOptionsToRequestInit(f,o,u.toString(),t.abortSignal),this.streamApiCall(u,f,t.httpMethod)}async includeExtraHttpOptionsToRequestInit(t,o,s,u){if(o&&o.timeout||u){const f=new AbortController,m=f.signal;if(o.timeout&&(o==null?void 0:o.timeout)>0){const g=setTimeout(()=>f.abort(),o.timeout);g&&typeof g.unref=="function"&&g.unref()}u&&u.addEventListener("abort",()=>{f.abort()}),t.signal=m}return o&&o.extraBody!==null&&ZC(t,o.extraBody),t.headers=await this.getHeadersInternal(o,s),t}async unaryApiCall(t,o,s){return this.apiCall(t.toString(),Object.assign(Object.assign({},o),{method:s})).then(async u=>(await mh(u),new qu(u))).catch(u=>{throw u instanceof Error?u:new Error(JSON.stringify(u))})}async streamApiCall(t,o,s){return this.apiCall(t.toString(),Object.assign(Object.assign({},o),{method:s})).then(async u=>(await mh(u),this.processStreamResponse(u))).catch(u=>{throw u instanceof Error?u:new Error(JSON.stringify(u))})}processStreamResponse(t){var o;return Gl(this,arguments,function*(){const u=(o=t==null?void 0:t.body)===null||o===void 0?void 0:o.getReader(),f=new TextDecoder("utf-8");if(!u)throw new Error("Response body is empty");try{let m="";for(;;){const{done:g,value:y}=yield rt(u.read());if(g){if(m.trim().length>0)throw new Error("Incomplete JSON segment at the end");break}const h=f.decode(y,{stream:!0});try{const E=JSON.parse(h);if("error"in E){const C=JSON.parse(JSON.stringify(E.error)),x=C.status,P=C.code,q=`got status: ${x}. ${JSON.stringify(E)}`;if(P>=400&&P<600)throw new aa({message:q,status:P})}}catch(E){if(E.name==="ApiError")throw E}m+=h;let v=m.match(ph);for(;v;){const E=v[1];try{const C=new Response(E,{headers:t==null?void 0:t.headers,status:t==null?void 0:t.status,statusText:t==null?void 0:t.statusText});yield yield rt(new qu(C)),m=m.slice(v[0].length),v=m.match(ph)}catch(C){throw new Error(`exception parsing stream chunk ${E}. ${C}`)}}}}finally{u.releaseLock()}})}async apiCall(t,o){return fetch(t,o).catch(s=>{throw new Error(`exception ${s} sending request`)})}getDefaultHeaders(){const t={},o=JC+" "+this.clientOptions.userAgentExtra;return t[OC]=o,t[Vu]=o,t[BC]="application/json",t}async getHeadersInternal(t,o){const s=new Headers;if(t&&t.headers){for(const[u,f]of Object.entries(t.headers))s.append(u,f);t.timeout&&t.timeout>0&&s.append(FC,String(Math.ceil(t.timeout/1e3)))}return await this.clientOptions.auth.addAuthHeaders(s,o),s}getFileName(t){var o;let s="";return typeof t=="string"&&(s=t.replace(/[/\\]+$/,""),s=(o=s.split(/[/\\]/).pop())!==null&&o!==void 0?o:""),s}async uploadFile(t,o){var s;const u={};o!=null&&(u.mimeType=o.mimeType,u.name=o.name,u.displayName=o.displayName),u.name&&!u.name.startsWith("files/")&&(u.name=`files/${u.name}`);const f=this.clientOptions.uploader,m=await f.stat(t);u.sizeBytes=String(m.size);const g=(s=o==null?void 0:o.mimeType)!==null&&s!==void 0?s:m.type;if(g===void 0||g==="")throw new Error("Can not determine mimeType. Please provide mimeType in the config.");u.mimeType=g;const y={file:u},h=this.getFileName(t),v=$("upload/v1beta/files",y._url),E=await this.fetchUploadUrl(v,u.sizeBytes,u.mimeType,h,y,o==null?void 0:o.httpOptions);return f.upload(t,E,this)}async uploadFileToFileSearchStore(t,o,s){var u;const f=this.clientOptions.uploader,m=await f.stat(o),g=String(m.size),y=(u=s==null?void 0:s.mimeType)!==null&&u!==void 0?u:m.type;if(y===void 0||y==="")throw new Error("Can not determine mimeType. Please provide mimeType in the config.");const h=`upload/v1beta/${t}:uploadToFileSearchStore`,v=this.getFileName(o),E={};s!=null&&Wh(s,E);const C=await this.fetchUploadUrl(h,g,y,v,E,s==null?void 0:s.httpOptions);return f.uploadToFileSearchStore(o,C,this)}async downloadFile(t){await this.clientOptions.downloader.download(t,this)}async fetchUploadUrl(t,o,s,u,f,m){var g;let y={};m?y=m:y={apiVersion:"",headers:Object.assign({"Content-Type":"application/json","X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":`${o}`,"X-Goog-Upload-Header-Content-Type":`${s}`},u?{"X-Goog-Upload-File-Name":u}:{})};const h=await this.request({path:t,body:JSON.stringify(f),httpMethod:"POST",httpOptions:y});if(!h||!(h!=null&&h.headers))throw new Error("Server did not return an HttpResponse or the returned HttpResponse did not have headers.");const v=(g=h==null?void 0:h.headers)===null||g===void 0?void 0:g["x-goog-upload-url"];if(v===void 0)throw new Error("Failed to get upload url. Server did not return the x-google-upload-url in the headers");return v}}async function mh(i){var t;if(i===void 0)throw new Error("response is undefined");if(!i.ok){const o=i.status;let s;!((t=i.headers.get("content-type"))===null||t===void 0)&&t.includes("application/json")?s=await i.json():s={error:{message:await i.text(),code:i.status,status:i.statusText}};const u=JSON.stringify(s);throw o>=400&&o<600?new aa({message:u,status:o}):new Error(u)}}function ZC(i,t){if(!t||Object.keys(t).length===0)return;if(i.body instanceof Blob){console.warn("includeExtraBodyToRequestInit: extraBody provided but current request body is a Blob. extraBody will be ignored as merging is not supported for Blob bodies.");return}let o={};if(typeof i.body=="string"&&i.body.length>0)try{const f=JSON.parse(i.body);if(typeof f=="object"&&f!==null&&!Array.isArray(f))o=f;else{console.warn("includeExtraBodyToRequestInit: Original request body is valid JSON but not a non-array object. Skip applying extraBody to the request body.");return}}catch{console.warn("includeExtraBodyToRequestInit: Original request body is not valid JSON. Skip applying extraBody to the request body.");return}function s(f,m){const g=Object.assign({},f);for(const y in m)if(Object.prototype.hasOwnProperty.call(m,y)){const h=m[y],v=g[y];h&&typeof h=="object"&&!Array.isArray(h)&&v&&typeof v=="object"&&!Array.isArray(v)?g[y]=s(v,h):(v&&h&&typeof v!=typeof h&&console.warn(`includeExtraBodyToRequestInit:deepMerge: Type mismatch for key "${y}". Original type: ${typeof v}, New type: ${typeof h}. Overwriting.`),g[y]=h)}return g}const u=s(o,t);i.body=JSON.stringify(u)}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */const $C="mcp_used/unknown";let WC=!1;function jh(i){for(const t of i)if(jC(t)||typeof t=="object"&&"inputSchema"in t)return!0;return WC}function eg(i){var t;const o=(t=i[Vu])!==null&&t!==void 0?t:"";i[Vu]=(o+` ${$C}`).trimStart()}function jC(i){return i!==null&&typeof i=="object"&&i instanceof $u}function e_(i,t=100){return Gl(this,arguments,function*(){let s,u=0;for(;u0)return;const f={},m=[];for(const v of this.mcpClients)try{for(var g=!0,y=(o=void 0,Ho(e_(v))),h;h=await y.next(),t=h.done,!t;g=!0){u=h.value,g=!1;const E=u;m.push(E);const C=E.name;if(f[C])throw new Error(`Duplicate function name ${C} found in MCP tools. Please ensure function names are unique.`);f[C]=v}}catch(E){o={error:E}}finally{try{!g&&!t&&(s=y.return)&&await s.call(y)}finally{if(o)throw o.error}}this.mcpTools=m,this.functionNameToMcpClient=f}async tool(){return await this.initialize(),Dv(this.mcpTools,this.config)}async callTool(t){await this.initialize();const o=[];for(const s of t)if(s.name in this.functionNameToMcpClient){const u=this.functionNameToMcpClient[s.name];let f;this.config.timeout&&(f={timeout:this.config.timeout});const m=await u.callTool({name:s.name,arguments:s.args},void 0,f);o.push({functionResponse:{name:s.name,response:m.isError?{error:m}:m}})}return o}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */async function t_(i,t,o){const s=new Av;let u;o.data instanceof Blob?u=JSON.parse(await o.data.text()):u=JSON.parse(o.data),Object.assign(s,u),t(s)}class n_{constructor(t,o,s){this.apiClient=t,this.auth=o,this.webSocketFactory=s}async connect(t){var o,s;if(this.apiClient.isVertexAI())throw new Error("Live music is not supported for Vertex AI.");console.warn("Live music generation is experimental and may change in future versions.");const u=this.apiClient.getWebsocketBaseUrl(),f=this.apiClient.getApiVersion(),m=o_(this.apiClient.getDefaultHeaders()),g=this.apiClient.getApiKey(),y=`${u}/ws/google.ai.generativelanguage.${f}.GenerativeService.BidiGenerateMusic?key=${g}`;let h=()=>{};const v=new Promise(k=>{h=k}),E=t.callbacks,C=function(){h({})},x=this.apiClient,P={onopen:C,onmessage:k=>{t_(x,E.onmessage,k)},onerror:(o=E==null?void 0:E.onerror)!==null&&o!==void 0?o:function(k){},onclose:(s=E==null?void 0:E.onclose)!==null&&s!==void 0?s:function(k){}},q=this.webSocketFactory.create(y,l_(m),P);q.connect(),await v;const j={setup:{model:ke(this.apiClient,t.model)}};return q.send(JSON.stringify(j)),new i_(q,this.apiClient)}}class i_{constructor(t,o){this.conn=t,this.apiClient=o}async setWeightedPrompts(t){if(!t.weightedPrompts||Object.keys(t.weightedPrompts).length===0)throw new Error("Weighted prompts must be set and contain at least one entry.");const o=wS(t);this.conn.send(JSON.stringify({clientContent:o}))}async setMusicGenerationConfig(t){t.musicGenerationConfig||(t.musicGenerationConfig={});const o=MS(t);this.conn.send(JSON.stringify(o))}sendPlaybackControl(t){const o={playbackControl:t};this.conn.send(JSON.stringify(o))}play(){this.sendPlaybackControl(Ll.PLAY)}pause(){this.sendPlaybackControl(Ll.PAUSE)}stop(){this.sendPlaybackControl(Ll.STOP)}resetContext(){this.sendPlaybackControl(Ll.RESET_CONTEXT)}close(){this.conn.close()}}function l_(i){const t={};return i.forEach((o,s)=>{t[s]=o}),t}function o_(i){const t=new Headers;for(const[o,s]of Object.entries(i))t.append(o,s);return t}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */const s_="FunctionResponse request must have an `id` field from the response of a ToolCall.FunctionalCalls in Google AI.";async function a_(i,t,o){const s=new _v;let u;o.data instanceof Blob?u=await o.data.text():o.data instanceof ArrayBuffer?u=new TextDecoder().decode(o.data):u=o.data;const f=JSON.parse(u);if(i.isVertexAI()){const m=DS(f);Object.assign(s,m)}else Object.assign(s,f);t(s)}class r_{constructor(t,o,s){this.apiClient=t,this.auth=o,this.webSocketFactory=s,this.music=new n_(this.apiClient,this.auth,this.webSocketFactory)}async connect(t){var o,s,u,f,m,g;if(t.config&&t.config.httpOptions)throw new Error("The Live module does not support httpOptions at request-level in LiveConnectConfig yet. Please use the client-level httpOptions configuration instead.");const y=this.apiClient.getWebsocketBaseUrl(),h=this.apiClient.getApiVersion();let v;const E=this.apiClient.getHeaders();t.config&&t.config.tools&&jh(t.config.tools)&&eg(E);const C=d_(E);if(this.apiClient.isVertexAI())v=`${y}/ws/google.cloud.aiplatform.${h}.LlmBidiService/BidiGenerateContent`,await this.auth.addAuthHeaders(C,v);else{const ee=this.apiClient.getApiKey();let Ee="BidiGenerateContent",be="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."),Ee="BidiGenerateContentConstrained",be="access_token"),v=`${y}/ws/google.ai.generativelanguage.${h}.GenerativeService.${Ee}?${be}=${ee}`}let x=()=>{};const P=new Promise(ee=>{x=ee}),q=t.callbacks,V=function(){var ee;(ee=q==null?void 0:q.onopen)===null||ee===void 0||ee.call(q),x({})},Y=this.apiClient,j={onopen:V,onmessage:ee=>{a_(Y,q.onmessage,ee)},onerror:(o=q==null?void 0:q.onerror)!==null&&o!==void 0?o:function(ee){},onclose:(s=q==null?void 0:q.onclose)!==null&&s!==void 0?s:function(ee){}},k=this.webSocketFactory.create(v,f_(C),j);k.connect(),await P;let Z=ke(this.apiClient,t.model);if(this.apiClient.isVertexAI()&&Z.startsWith("publishers/")){const ee=this.apiClient.getProject(),Ee=this.apiClient.getLocation();Z=`projects/${ee}/locations/${Ee}/`+Z}let ae={};this.apiClient.isVertexAI()&&((u=t.config)===null||u===void 0?void 0:u.responseModalities)===void 0&&(t.config===void 0?t.config={responseModalities:[na.AUDIO]}:t.config.responseModalities=[na.AUDIO]),!((f=t.config)===null||f===void 0)&&f.generationConfig&&console.warn("Setting `LiveConnectConfig.generation_config` is deprecated, please set the fields on `LiveConnectConfig` directly. This will become an error in a future version (not before Q3 2025).");const se=(g=(m=t.config)===null||m===void 0?void 0:m.tools)!==null&&g!==void 0?g:[],K=[];for(const ee of se)if(this.isCallableTool(ee)){const Ee=ee;K.push(await Ee.tool())}else K.push(ee);K.length>0&&(t.config.tools=K);const Ae={model:Z,config:t.config,callbacks:t.callbacks};return this.apiClient.isVertexAI()?ae=RS(this.apiClient,Ae):ae=NS(this.apiClient,Ae),delete ae.config,k.send(JSON.stringify(ae)),new c_(k,this.apiClient)}isCallableTool(t){return"callTool"in t&&typeof t.callTool=="function"}}const u_={turnComplete:!0};class c_{constructor(t,o){this.conn=t,this.apiClient=o}tLiveClientContent(t,o){if(o.turns!==null&&o.turns!==void 0){let s=[];try{s=rn(o.turns),t.isVertexAI()||(s=s.map(u=>ra(u)))}catch{throw new Error(`Failed to parse client content "turns", type: '${typeof o.turns}'`)}return{clientContent:{turns:s,turnComplete:o.turnComplete}}}return{clientContent:{turnComplete:o.turnComplete}}}tLiveClienttToolResponse(t,o){let s=[];if(o.functionResponses==null)throw new Error("functionResponses is required.");if(Array.isArray(o.functionResponses)?s=o.functionResponses:s=[o.functionResponses],s.length===0)throw new Error("functionResponses is required.");for(const f of s){if(typeof f!="object"||f===null||!("name"in f)||!("response"in f))throw new Error(`Could not parse function response, type '${typeof f}'.`);if(!t.isVertexAI()&&!("id"in f))throw new Error(s_)}return{toolResponse:{functionResponses:s}}}sendClientContent(t){t=Object.assign(Object.assign({},u_),t);const o=this.tLiveClientContent(this.apiClient,t);this.conn.send(JSON.stringify(o))}sendRealtimeInput(t){let o={};this.apiClient.isVertexAI()?o={realtimeInput:IS(t)}:o={realtimeInput:bS(t)},this.conn.send(JSON.stringify(o))}sendToolResponse(t){if(t.functionResponses==null)throw new Error("Tool response parameters are required.");const o=this.tLiveClienttToolResponse(this.apiClient,t);this.conn.send(JSON.stringify(o))}close(){this.conn.close()}}function f_(i){const t={};return i.forEach((o,s)=>{t[s]=o}),t}function d_(i){const t=new Headers;for(const[o,s]of Object.entries(i))t.append(o,s);return t}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */const hh=10;function gh(i){var t,o,s;if(!((t=i==null?void 0:i.automaticFunctionCalling)===null||t===void 0)&&t.disable)return!0;let u=!1;for(const m of(o=i==null?void 0:i.tools)!==null&&o!==void 0?o:[])if(Hl(m)){u=!0;break}if(!u)return!0;const f=(s=i==null?void 0:i.automaticFunctionCalling)===null||s===void 0?void 0:s.maximumRemoteCalls;return f&&(f<0||!Number.isInteger(f))||f==0?(console.warn("Invalid maximumRemoteCalls value provided for automatic function calling. Disabled automatic function calling. Please provide a valid integer value greater than 0. maximumRemoteCalls provided:",f),!0):!1}function Hl(i){return"callTool"in i&&typeof i.callTool=="function"}function p_(i){var t,o,s;return(s=(o=(t=i.config)===null||t===void 0?void 0:t.tools)===null||o===void 0?void 0:o.some(u=>Hl(u)))!==null&&s!==void 0?s:!1}function yh(i){var t;const o=[];return!((t=i==null?void 0:i.config)===null||t===void 0)&&t.tools&&i.config.tools.forEach((s,u)=>{if(Hl(s))return;const f=s;f.functionDeclarations&&f.functionDeclarations.length>0&&o.push(u)}),o}function vh(i){var t;return!(!((t=i==null?void 0:i.automaticFunctionCalling)===null||t===void 0)&&t.ignoreCallHistory)}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class m_ extends Yn{constructor(t){super(),this.apiClient=t,this.generateContent=async o=>{var s,u,f,m,g;const y=await this.processParamsMaybeAddMcpUsage(o);if(this.maybeMoveToResponseJsonSchem(o),!p_(o)||gh(o.config))return await this.generateContentInternal(y);const h=yh(o);if(h.length>0){const q=h.map(V=>`tools[${V}]`).join(", ");throw new Error(`Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations is not yet supported. Incompatible tools found at ${q}.`)}let v,E;const C=rn(y.contents),x=(f=(u=(s=y.config)===null||s===void 0?void 0:s.automaticFunctionCalling)===null||u===void 0?void 0:u.maximumRemoteCalls)!==null&&f!==void 0?f:hh;let P=0;for(;P{var s,u,f,m,g;if(this.maybeMoveToResponseJsonSchem(o),gh(o.config)){const E=await this.processParamsMaybeAddMcpUsage(o);return await this.generateContentStreamInternal(E)}const y=yh(o);if(y.length>0){const E=y.map(C=>`tools[${C}]`).join(", ");throw new Error(`Incompatible tools found at ${E}. Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations" is not yet supported.`)}const h=(f=(u=(s=o==null?void 0:o.config)===null||s===void 0?void 0:s.toolConfig)===null||u===void 0?void 0:u.functionCallingConfig)===null||f===void 0?void 0:f.streamFunctionCallArguments,v=(g=(m=o==null?void 0:o.config)===null||m===void 0?void 0:m.automaticFunctionCalling)===null||g===void 0?void 0:g.disable;if(h&&!v)throw new Error("Running in streaming mode with 'streamFunctionCallArguments' enabled, this feature is not compatible with automatic function calling (AFC). Please set 'config.automaticFunctionCalling.disable' to true to disable AFC or leave 'config.toolConfig.functionCallingConfig.streamFunctionCallArguments' to be undefined or set to false to disable streaming function call arguments feature.");return await this.processAfcStream(o)},this.generateImages=async o=>await this.generateImagesInternal(o).then(s=>{var u;let f;const m=[];if(s!=null&&s.generatedImages)for(const y of s.generatedImages)y&&(y!=null&&y.safetyAttributes)&&((u=y==null?void 0:y.safetyAttributes)===null||u===void 0?void 0:u.contentType)==="Positive Prompt"?f=y==null?void 0:y.safetyAttributes:m.push(y);let g;return f?g={generatedImages:m,positivePromptSafetyAttributes:f,sdkHttpResponse:s.sdkHttpResponse}:g={generatedImages:m,sdkHttpResponse:s.sdkHttpResponse},g}),this.list=async o=>{var s;const m={config:Object.assign(Object.assign({},{queryBase:!0}),o==null?void 0:o.config)};if(this.apiClient.isVertexAI()&&!m.config.queryBase){if(!((s=m.config)===null||s===void 0)&&s.filter)throw new Error("Filtering tuned models list for Vertex AI is not currently supported");m.config.filter="labels.tune-type:*"}return new Yi(On.PAGED_ITEM_MODELS,g=>this.listInternal(g),await this.listInternal(m),m)},this.editImage=async o=>{const s={model:o.model,prompt:o.prompt,referenceImages:[],config:o.config};return o.referenceImages&&o.referenceImages&&(s.referenceImages=o.referenceImages.map(u=>u.toReferenceImageAPI())),await this.editImageInternal(s)},this.upscaleImage=async o=>{let s={numberOfImages:1,mode:"upscale"};o.config&&(s=Object.assign(Object.assign({},s),o.config));const u={model:o.model,image:o.image,upscaleFactor:o.upscaleFactor,config:s};return await this.upscaleImageInternal(u)},this.generateVideos=async o=>{var s,u,f,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()||(!((s=o.video)===null||s===void 0)&&s.uri&&(!((u=o.video)===null||u===void 0)&&u.videoBytes)?o.video={uri:o.video.uri,mimeType:o.video.mimeType}:!((m=(f=o.source)===null||f===void 0?void 0:f.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(t){t.config&&t.config.responseSchema&&(t.config.responseJsonSchema||Object.keys(t.config.responseSchema).includes("$schema")&&(t.config.responseJsonSchema=t.config.responseSchema,delete t.config.responseSchema))}async processParamsMaybeAddMcpUsage(t){var o,s,u;const f=(o=t.config)===null||o===void 0?void 0:o.tools;if(!f)return t;const m=await Promise.all(f.map(async y=>Hl(y)?await y.tool():y)),g={model:t.model,contents:t.contents,config:Object.assign(Object.assign({},t.config),{tools:m})};if(g.config.tools=m,t.config&&t.config.tools&&jh(t.config.tools)){const y=(u=(s=t.config.httpOptions)===null||s===void 0?void 0:s.headers)!==null&&u!==void 0?u:{};let h=Object.assign({},y);Object.keys(h).length===0&&(h=this.apiClient.getDefaultHeaders()),eg(h),g.config.httpOptions=Object.assign(Object.assign({},t.config.httpOptions),{headers:h})}return g}async initAfcToolsMap(t){var o,s,u;const f=new Map;for(const m of(s=(o=t.config)===null||o===void 0?void 0:o.tools)!==null&&s!==void 0?s:[])if(Hl(m)){const g=m,y=await g.tool();for(const h of(u=y.functionDeclarations)!==null&&u!==void 0?u:[]){if(!h.name)throw new Error("Function declaration name is required.");if(f.has(h.name))throw new Error(`Duplicate tool declaration name: ${h.name}`);f.set(h.name,g)}}return f}async processAfcStream(t){var o,s,u;const f=(u=(s=(o=t.config)===null||o===void 0?void 0:o.automaticFunctionCalling)===null||s===void 0?void 0:s.maximumRemoteCalls)!==null&&u!==void 0?u:hh;let m=!1,g=0;const y=await this.initAfcToolsMap(t);return(function(h,v,E){var C,x;return Gl(this,arguments,function*(){for(var P,q,V,Y;g0){m=!0;const ee=new qo;ee.candidates=[{content:{role:"user",parts:K}}],yield yield rt(ee);const Ee=[];Ee.push(...Ae),Ee.push({role:"user",parts:K});const be=rn(E.contents).concat(Ee);E.contents=be}else break}})})(this,y,t)}async generateContentInternal(t){var o,s,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=ch(this.apiClient,t);return g=$("{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=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json().then(E=>{const C=E;return C.sdkHttpResponse={headers:v.headers},C})),m.then(v=>{const E=dh(v),C=new qo;return Object.assign(C,E),C})}else{const h=uh(this.apiClient,t);return g=$("{model}:generateContent",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(u=t.config)===null||u===void 0?void 0:u.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json().then(E=>{const C=E;return C.sdkHttpResponse={headers:v.headers},C})),m.then(v=>{const E=fh(v),C=new qo;return Object.assign(C,E),C})}}async generateContentStreamInternal(t){var o,s,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=ch(this.apiClient,t);return g=$("{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=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}),m.then(function(E){return Gl(this,arguments,function*(){var C,x,P,q;try{for(var V=!0,Y=Ho(E),j;j=yield rt(Y.next()),C=j.done,!C;V=!0){q=j.value,V=!1;const k=q,Z=dh(yield rt(k.json()));Z.sdkHttpResponse={headers:k.headers};const ae=new qo;Object.assign(ae,Z),yield yield rt(ae)}}catch(k){x={error:k}}finally{try{!V&&!C&&(P=Y.return)&&(yield rt(P.call(Y)))}finally{if(x)throw x.error}}})})}else{const h=uh(this.apiClient,t);return g=$("{model}:streamGenerateContent?alt=sse",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.requestStream({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(u=t.config)===null||u===void 0?void 0:u.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}),m.then(function(E){return Gl(this,arguments,function*(){var C,x,P,q;try{for(var V=!0,Y=Ho(E),j;j=yield rt(Y.next()),C=j.done,!C;V=!0){q=j.value,V=!1;const k=q,Z=fh(yield rt(k.json()));Z.sdkHttpResponse={headers:k.headers};const ae=new qo;Object.assign(ae,Z),yield yield rt(ae)}}catch(k){x={error:k}}finally{try{!V&&!C&&(P=Y.return)&&(yield rt(P.call(Y)))}finally{if(x)throw x.error}}})})}}async embedContent(t){var o,s,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=rE(this.apiClient,t);return g=$("{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=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json().then(E=>{const C=E;return C.sdkHttpResponse={headers:v.headers},C})),m.then(v=>{const E=cE(v),C=new Jm;return Object.assign(C,E),C})}else{const h=aE(this.apiClient,t);return g=$("{model}:batchEmbedContents",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(u=t.config)===null||u===void 0?void 0:u.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json().then(E=>{const C=E;return C.sdkHttpResponse={headers:v.headers},C})),m.then(v=>{const E=uE(v),C=new Jm;return Object.assign(C,E),C})}}async generateImagesInternal(t){var o,s,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=EE(this.apiClient,t);return g=$("{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=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json().then(E=>{const C=E;return C.sdkHttpResponse={headers:v.headers},C})),m.then(v=>{const E=_E(v),C=new Km;return Object.assign(C,E),C})}else{const h=SE(this.apiClient,t);return g=$("{model}:predict",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(u=t.config)===null||u===void 0?void 0:u.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json().then(E=>{const C=E;return C.sdkHttpResponse={headers:v.headers},C})),m.then(v=>{const E=CE(v),C=new Km;return Object.assign(C,E),C})}}async editImageInternal(t){var o,s;let u,f="",m={};if(this.apiClient.isVertexAI()){const g=iE(this.apiClient,t);return f=$("{model}:predict",g._url),m=g._query,delete g._url,delete g._query,u=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json().then(h=>{const v=h;return v.sdkHttpResponse={headers:y.headers},v})),u.then(y=>{const h=lE(y),v=new dv;return Object.assign(v,h),v})}else throw new Error("This method is only supported by the Vertex AI.")}async upscaleImageInternal(t){var o,s;let u,f="",m={};if(this.apiClient.isVertexAI()){const g=EC(this.apiClient,t);return f=$("{model}:predict",g._url),m=g._query,delete g._url,delete g._query,u=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json().then(h=>{const v=h;return v.sdkHttpResponse={headers:y.headers},v})),u.then(y=>{const h=CC(y),v=new pv;return Object.assign(v,h),v})}else throw new Error("This method is only supported by the Vertex AI.")}async recontextImage(t){var o,s;let u,f="",m={};if(this.apiClient.isVertexAI()){const g=nC(this.apiClient,t);return f=$("{model}:predict",g._url),m=g._query,delete g._url,delete g._query,u=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json()),u.then(y=>{const h=iC(y),v=new mv;return Object.assign(v,h),v})}else throw new Error("This method is only supported by the Vertex AI.")}async segmentImage(t){var o,s;let u,f="",m={};if(this.apiClient.isVertexAI()){const g=uC(this.apiClient,t);return f=$("{model}:predict",g._url),m=g._query,delete g._url,delete g._query,u=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json()),u.then(y=>{const h=cC(y),v=new hv;return Object.assign(v,h),v})}else throw new Error("This method is only supported by the Vertex AI.")}async get(t){var o,s,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=VE(this.apiClient,t);return g=$("{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=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json()),m.then(v=>zu(v))}else{const h=zE(this.apiClient,t);return g=$("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(u=t.config)===null||u===void 0?void 0:u.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json()),m.then(v=>Pu(v))}}async listInternal(t){var o,s,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=QE(this.apiClient,t);return g=$("{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=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json().then(E=>{const C=E;return C.sdkHttpResponse={headers:v.headers},C})),m.then(v=>{const E=$E(v),C=new Xm;return Object.assign(C,E),C})}else{const h=XE(this.apiClient,t);return g=$("{models_url}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(u=t.config)===null||u===void 0?void 0:u.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json().then(E=>{const C=E;return C.sdkHttpResponse={headers:v.headers},C})),m.then(v=>{const E=ZE(v),C=new Xm;return Object.assign(C,E),C})}}async update(t){var o,s,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=TC(this.apiClient,t);return g=$("{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=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json()),m.then(v=>zu(v))}else{const h=vC(this.apiClient,t);return g=$("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"PATCH",httpOptions:(u=t.config)===null||u===void 0?void 0:u.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json()),m.then(v=>Pu(v))}}async delete(t){var o,s,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=jS(this.apiClient,t);return g=$("{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=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json().then(E=>{const C=E;return C.sdkHttpResponse={headers:v.headers},C})),m.then(v=>{const E=tE(v),C=new Qm;return Object.assign(C,E),C})}else{const h=WS(this.apiClient,t);return g=$("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"DELETE",httpOptions:(u=t.config)===null||u===void 0?void 0:u.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json().then(E=>{const C=E;return C.sdkHttpResponse={headers:v.headers},C})),m.then(v=>{const E=eE(v),C=new Qm;return Object.assign(C,E),C})}}async countTokens(t){var o,s,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=QS(this.apiClient,t);return g=$("{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=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json().then(E=>{const C=E;return C.sdkHttpResponse={headers:v.headers},C})),m.then(v=>{const E=$S(v),C=new Zm;return Object.assign(C,E),C})}else{const h=XS(this.apiClient,t);return g=$("{model}:countTokens",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(u=t.config)===null||u===void 0?void 0:u.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json().then(E=>{const C=E;return C.sdkHttpResponse={headers:v.headers},C})),m.then(v=>{const E=ZS(v),C=new Zm;return Object.assign(C,E),C})}}async computeTokens(t){var o,s;let u,f="",m={};if(this.apiClient.isVertexAI()){const g=kS(this.apiClient,t);return f=$("{model}:computeTokens",g._url),m=g._query,delete g._url,delete g._query,u=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json().then(h=>{const v=h;return v.sdkHttpResponse={headers:y.headers},v})),u.then(y=>{const h=BS(y),v=new gv;return Object.assign(v,h),v})}else throw new Error("This method is only supported by the Vertex AI.")}async generateVideosInternal(t){var o,s,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=wE(this.apiClient,t);return g=$("{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=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json()),m.then(v=>{const E=RE(v),C=new ia;return Object.assign(C,E),C})}else{const h=ME(this.apiClient,t);return g=$("{model}:predictLongRunning",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(u=t.config)===null||u===void 0?void 0:u.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json()),m.then(v=>{const E=NE(v),C=new ia;return Object.assign(C,E),C})}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class h_ extends Yn{constructor(t){super(),this.apiClient=t}async getVideosOperation(t){const o=t.operation,s=t.config;if(o.name===void 0||o.name==="")throw new Error("Operation name is required.");if(this.apiClient.isVertexAI()){const u=o.name.split("/operations/")[0];let f;s&&"httpOptions"in s&&(f=s.httpOptions);const m=await this.fetchPredictVideosOperationInternal({operationName:o.name,resourceName:u,config:{httpOptions:f}});return o._fromAPIResponse({apiResponse:m,_isVertexAI:!0})}else{const u=await this.getVideosOperationInternal({operationName:o.name,config:s});return o._fromAPIResponse({apiResponse:u,_isVertexAI:!1})}}async get(t){const o=t.operation,s=t.config;if(o.name===void 0||o.name==="")throw new Error("Operation name is required.");if(this.apiClient.isVertexAI()){const u=o.name.split("/operations/")[0];let f;s&&"httpOptions"in s&&(f=s.httpOptions);const m=await this.fetchPredictVideosOperationInternal({operationName:o.name,resourceName:u,config:{httpOptions:f}});return o._fromAPIResponse({apiResponse:m,_isVertexAI:!0})}else{const u=await this.getVideosOperationInternal({operationName:o.name,config:s});return o._fromAPIResponse({apiResponse:u,_isVertexAI:!1})}}async getVideosOperationInternal(t){var o,s,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=sv(t);return g=$("{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=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json()),m}else{const h=ov(t);return g=$("{operationName}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(u=t.config)===null||u===void 0?void 0:u.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json()),m}}async fetchPredictVideosOperationInternal(t){var o,s;let u,f="",m={};if(this.apiClient.isVertexAI()){const g=W0(t);return f=$("{resourceName}:fetchPredictOperation",g._url),m=g._query,delete g._url,delete g._query,u=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json()),u}else throw new Error("This method is only supported by the Vertex AI.")}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function g_(i){const t={},o=r(i,["data"]);if(o!=null&&c(t,["data"],o),r(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const s=r(i,["mimeType"]);return s!=null&&c(t,["mimeType"],s),t}function y_(i){const t={},o=r(i,["parts"]);if(o!=null){let u=o;Array.isArray(u)&&(u=u.map(f=>N_(f))),c(t,["parts"],u)}const s=r(i,["role"]);return s!=null&&c(t,["role"],s),t}function v_(i,t,o){const s={},u=r(t,["expireTime"]);o!==void 0&&u!=null&&c(o,["expireTime"],u);const f=r(t,["newSessionExpireTime"]);o!==void 0&&f!=null&&c(o,["newSessionExpireTime"],f);const m=r(t,["uses"]);o!==void 0&&m!=null&&c(o,["uses"],m);const g=r(t,["liveConnectConstraints"]);o!==void 0&&g!=null&&c(o,["bidiGenerateContentSetup"],x_(i,g));const y=r(t,["lockAdditionalFields"]);return o!==void 0&&y!=null&&c(o,["fieldMask"],y),s}function T_(i,t){const o={},s=r(t,["config"]);return s!=null&&c(o,["config"],v_(i,s,o)),o}function S_(i){const t={};if(r(i,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=r(i,["fileUri"]);o!=null&&c(t,["fileUri"],o);const s=r(i,["mimeType"]);return s!=null&&c(t,["mimeType"],s),t}function E_(i){const t={},o=r(i,["id"]);o!=null&&c(t,["id"],o);const s=r(i,["args"]);s!=null&&c(t,["args"],s);const u=r(i,["name"]);if(u!=null&&c(t,["name"],u),r(i,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(r(i,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return t}function C_(i){const t={};if(r(i,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const o=r(i,["enableWidget"]);return o!=null&&c(t,["enableWidget"],o),t}function __(i){const t={};if(r(i,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(r(i,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const o=r(i,["timeRangeFilter"]);return o!=null&&c(t,["timeRangeFilter"],o),t}function A_(i,t){const o={},s=r(i,["generationConfig"]);t!==void 0&&s!=null&&c(t,["setup","generationConfig"],s);const u=r(i,["responseModalities"]);t!==void 0&&u!=null&&c(t,["setup","generationConfig","responseModalities"],u);const f=r(i,["temperature"]);t!==void 0&&f!=null&&c(t,["setup","generationConfig","temperature"],f);const m=r(i,["topP"]);t!==void 0&&m!=null&&c(t,["setup","generationConfig","topP"],m);const g=r(i,["topK"]);t!==void 0&&g!=null&&c(t,["setup","generationConfig","topK"],g);const y=r(i,["maxOutputTokens"]);t!==void 0&&y!=null&&c(t,["setup","generationConfig","maxOutputTokens"],y);const h=r(i,["mediaResolution"]);t!==void 0&&h!=null&&c(t,["setup","generationConfig","mediaResolution"],h);const v=r(i,["seed"]);t!==void 0&&v!=null&&c(t,["setup","generationConfig","seed"],v);const E=r(i,["speechConfig"]);t!==void 0&&E!=null&&c(t,["setup","generationConfig","speechConfig"],Zu(E));const C=r(i,["thinkingConfig"]);t!==void 0&&C!=null&&c(t,["setup","generationConfig","thinkingConfig"],C);const x=r(i,["enableAffectiveDialog"]);t!==void 0&&x!=null&&c(t,["setup","generationConfig","enableAffectiveDialog"],x);const P=r(i,["systemInstruction"]);t!==void 0&&P!=null&&c(t,["setup","systemInstruction"],y_(It(P)));const q=r(i,["tools"]);if(t!==void 0&&q!=null){let se=zl(q);Array.isArray(se)&&(se=se.map(K=>M_(Pl(K)))),c(t,["setup","tools"],se)}const V=r(i,["sessionResumption"]);t!==void 0&&V!=null&&c(t,["setup","sessionResumption"],R_(V));const Y=r(i,["inputAudioTranscription"]);t!==void 0&&Y!=null&&c(t,["setup","inputAudioTranscription"],Y);const j=r(i,["outputAudioTranscription"]);t!==void 0&&j!=null&&c(t,["setup","outputAudioTranscription"],j);const k=r(i,["realtimeInputConfig"]);t!==void 0&&k!=null&&c(t,["setup","realtimeInputConfig"],k);const Z=r(i,["contextWindowCompression"]);t!==void 0&&Z!=null&&c(t,["setup","contextWindowCompression"],Z);const ae=r(i,["proactivity"]);return t!==void 0&&ae!=null&&c(t,["setup","proactivity"],ae),o}function x_(i,t){const o={},s=r(t,["model"]);s!=null&&c(o,["setup","model"],ke(i,s));const u=r(t,["config"]);return u!=null&&c(o,["config"],A_(u,o)),o}function N_(i){const t={},o=r(i,["mediaResolution"]);o!=null&&c(t,["mediaResolution"],o);const s=r(i,["codeExecutionResult"]);s!=null&&c(t,["codeExecutionResult"],s);const u=r(i,["executableCode"]);u!=null&&c(t,["executableCode"],u);const f=r(i,["fileData"]);f!=null&&c(t,["fileData"],S_(f));const m=r(i,["functionCall"]);m!=null&&c(t,["functionCall"],E_(m));const g=r(i,["functionResponse"]);g!=null&&c(t,["functionResponse"],g);const y=r(i,["inlineData"]);y!=null&&c(t,["inlineData"],g_(y));const h=r(i,["text"]);h!=null&&c(t,["text"],h);const v=r(i,["thought"]);v!=null&&c(t,["thought"],v);const E=r(i,["thoughtSignature"]);E!=null&&c(t,["thoughtSignature"],E);const C=r(i,["videoMetadata"]);return C!=null&&c(t,["videoMetadata"],C),t}function R_(i){const t={},o=r(i,["handle"]);if(o!=null&&c(t,["handle"],o),r(i,["transparent"])!==void 0)throw new Error("transparent parameter is not supported in Gemini API.");return t}function M_(i){const t={},o=r(i,["functionDeclarations"]);if(o!=null){let v=o;Array.isArray(v)&&(v=v.map(E=>E)),c(t,["functionDeclarations"],v)}if(r(i,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const s=r(i,["googleSearchRetrieval"]);s!=null&&c(t,["googleSearchRetrieval"],s);const u=r(i,["computerUse"]);u!=null&&c(t,["computerUse"],u);const f=r(i,["fileSearch"]);f!=null&&c(t,["fileSearch"],f);const m=r(i,["codeExecution"]);if(m!=null&&c(t,["codeExecution"],m),r(i,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const g=r(i,["googleMaps"]);g!=null&&c(t,["googleMaps"],C_(g));const y=r(i,["googleSearch"]);y!=null&&c(t,["googleSearch"],__(y));const h=r(i,["urlContext"]);return h!=null&&c(t,["urlContext"],h),t}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function w_(i){const t=[];for(const o in i)if(Object.prototype.hasOwnProperty.call(i,o)){const s=i[o];if(typeof s=="object"&&s!=null&&Object.keys(s).length>0){const u=Object.keys(s).map(f=>`${o}.${f}`);t.push(...u)}else t.push(o)}return t.join(",")}function b_(i,t){let o=null;const s=i.bidiGenerateContentSetup;if(typeof s=="object"&&s!==null&&"setup"in s){const f=s.setup;typeof f=="object"&&f!==null?(i.bidiGenerateContentSetup=f,o=f):delete i.bidiGenerateContentSetup}else s!==void 0&&delete i.bidiGenerateContentSetup;const u=i.fieldMask;if(o){const f=w_(o);if(Array.isArray(t==null?void 0:t.lockAdditionalFields)&&(t==null?void 0:t.lockAdditionalFields.length)===0)f?i.fieldMask=f:delete i.fieldMask;else if(t!=null&&t.lockAdditionalFields&&t.lockAdditionalFields.length>0&&u!==null&&Array.isArray(u)&&u.length>0){const m=["temperature","topK","topP","maxOutputTokens","responseModalities","seed","speechConfig"];let g=[];u.length>0&&(g=u.map(h=>m.includes(h)?`generationConfig.${h}`:h));const y=[];f&&y.push(f),g.length>0&&y.push(...g),y.length>0?i.fieldMask=y.join(","):delete i.fieldMask}else delete i.fieldMask}else u!==null&&Array.isArray(u)&&u.length>0?i.fieldMask=u.join(","):delete i.fieldMask;return i}class I_ extends Yn{constructor(t){super(),this.apiClient=t}async create(t){var o,s;let u,f="",m={};if(this.apiClient.isVertexAI())throw new Error("The client.tokens.create method is only supported by the Gemini Developer API.");{const g=T_(this.apiClient,t);f=$("auth_tokens",g._url),m=g._query,delete g.config,delete g._url,delete g._query;const y=b_(g,t.config);return u=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(y),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(h=>h.json()),u.then(h=>h)}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function D_(i,t){const o={},s=r(i,["force"]);return t!==void 0&&s!=null&&c(t,["_query","force"],s),o}function U_(i){const t={},o=r(i,["name"]);o!=null&&c(t,["_url","name"],o);const s=r(i,["config"]);return s!=null&&D_(s,t),t}function L_(i){const t={},o=r(i,["name"]);return o!=null&&c(t,["_url","name"],o),t}function q_(i,t){const o={},s=r(i,["pageSize"]);t!==void 0&&s!=null&&c(t,["_query","pageSize"],s);const u=r(i,["pageToken"]);return t!==void 0&&u!=null&&c(t,["_query","pageToken"],u),o}function G_(i){const t={},o=r(i,["parent"]);o!=null&&c(t,["_url","parent"],o);const s=r(i,["config"]);return s!=null&&q_(s,t),t}function H_(i){const t={},o=r(i,["sdkHttpResponse"]);o!=null&&c(t,["sdkHttpResponse"],o);const s=r(i,["nextPageToken"]);s!=null&&c(t,["nextPageToken"],s);const u=r(i,["documents"]);if(u!=null){let f=u;Array.isArray(f)&&(f=f.map(m=>m)),c(t,["documents"],f)}return t}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class P_ extends Yn{constructor(t){super(),this.apiClient=t,this.list=async o=>new Yi(On.PAGED_ITEM_DOCUMENTS,s=>this.listInternal({parent:o.parent,config:s.config}),await this.listInternal(o),o)}async get(t){var o,s;let u,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=L_(t);return f=$("{name}",g._url),m=g._query,delete g._url,delete g._query,u=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"GET",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json()),u.then(y=>y)}}async delete(t){var o,s;let u="",f={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const m=U_(t);u=$("{name}",m._url),f=m._query,delete m._url,delete m._query,await this.apiClient.request({path:u,queryParams:f,body:JSON.stringify(m),httpMethod:"DELETE",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal})}}async listInternal(t){var o,s;let u,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=G_(t);return f=$("{parent}/documents",g._url),m=g._query,delete g._url,delete g._query,u=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"GET",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json()),u.then(y=>{const h=H_(y),v=new yv;return Object.assign(v,h),v})}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class z_ extends Yn{constructor(t,o=new P_(t)){super(),this.apiClient=t,this.documents=o,this.list=async(s={})=>new Yi(On.PAGED_ITEM_FILE_SEARCH_STORES,u=>this.listInternal(u),await this.listInternal(s),s)}async uploadToFileSearchStore(t){if(this.apiClient.isVertexAI())throw new Error("Vertex AI does not support uploading files to a file search store.");return this.apiClient.uploadFileToFileSearchStore(t.fileSearchStoreName,t.file,t.config)}async create(t){var o,s;let u,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=wC(t);return f=$("fileSearchStores",g._url),m=g._query,delete g._url,delete g._query,u=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json()),u.then(y=>y)}}async get(t){var o,s;let u,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=DC(t);return f=$("{name}",g._url),m=g._query,delete g._url,delete g._query,u=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"GET",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json()),u.then(y=>y)}}async delete(t){var o,s;let u="",f={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const m=IC(t);u=$("{name}",m._url),f=m._query,delete m._url,delete m._query,await this.apiClient.request({path:u,queryParams:f,body:JSON.stringify(m),httpMethod:"DELETE",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal})}}async listInternal(t){var o,s;let u,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=PC(t);return f=$("fileSearchStores",g._url),m=g._query,delete g._url,delete g._query,u=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"GET",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json()),u.then(y=>{const h=zC(y),v=new vv;return Object.assign(v,h),v})}}async uploadToFileSearchStoreInternal(t){var o,s;let u,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=VC(t);return f=$("upload/v1beta/{file_search_store_name}:uploadToFileSearchStore",g._url),m=g._query,delete g._url,delete g._query,u=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json()),u.then(y=>{const h=kC(y),v=new Tv;return Object.assign(v,h),v})}}async importFile(t){var o,s;let u,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=qC(t);return f=$("{file_search_store_name}:importFile",g._url),m=g._query,delete g._url,delete g._query,u=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json()),u.then(y=>{const h=LC(y),v=new Yu;return Object.assign(v,h),v})}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function V_(i,t){const o={},s=r(i,["name"]);return s!=null&&c(o,["_url","name"],s),o}function k_(i,t){const o={},s=r(i,["name"]);return s!=null&&c(o,["_url","name"],s),o}function B_(i,t){const o={},s=r(i,["sdkHttpResponse"]);return s!=null&&c(o,["sdkHttpResponse"],s),o}function F_(i,t){const o={},s=r(i,["sdkHttpResponse"]);return s!=null&&c(o,["sdkHttpResponse"],s),o}function O_(i,t,o){const s={};if(r(i,["validationDataset"])!==void 0)throw new Error("validationDataset parameter is not supported in Gemini API.");const u=r(i,["tunedModelDisplayName"]);if(t!==void 0&&u!=null&&c(t,["displayName"],u),r(i,["description"])!==void 0)throw new Error("description parameter is not supported in Gemini API.");const f=r(i,["epochCount"]);t!==void 0&&f!=null&&c(t,["tuningTask","hyperparameters","epochCount"],f);const m=r(i,["learningRateMultiplier"]);if(m!=null&&c(s,["tuningTask","hyperparameters","learningRateMultiplier"],m),r(i,["exportLastCheckpointOnly"])!==void 0)throw new Error("exportLastCheckpointOnly parameter is not supported in Gemini API.");if(r(i,["preTunedModelCheckpointId"])!==void 0)throw new Error("preTunedModelCheckpointId parameter is not supported in Gemini API.");if(r(i,["adapterSize"])!==void 0)throw new Error("adapterSize parameter is not supported in Gemini API.");const g=r(i,["batchSize"]);t!==void 0&&g!=null&&c(t,["tuningTask","hyperparameters","batchSize"],g);const y=r(i,["learningRate"]);if(t!==void 0&&y!=null&&c(t,["tuningTask","hyperparameters","learningRate"],y),r(i,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");if(r(i,["beta"])!==void 0)throw new Error("beta parameter is not supported in Gemini API.");return s}function Y_(i,t,o){const s={};let u=r(o,["config","method"]);if(u===void 0&&(u="SUPERVISED_FINE_TUNING"),u==="SUPERVISED_FINE_TUNING"){const x=r(i,["validationDataset"]);t!==void 0&&x!=null&&c(t,["supervisedTuningSpec"],Th(x))}else if(u==="PREFERENCE_TUNING"){const x=r(i,["validationDataset"]);t!==void 0&&x!=null&&c(t,["preferenceOptimizationSpec"],Th(x))}const f=r(i,["tunedModelDisplayName"]);t!==void 0&&f!=null&&c(t,["tunedModelDisplayName"],f);const m=r(i,["description"]);t!==void 0&&m!=null&&c(t,["description"],m);let g=r(o,["config","method"]);if(g===void 0&&(g="SUPERVISED_FINE_TUNING"),g==="SUPERVISED_FINE_TUNING"){const x=r(i,["epochCount"]);t!==void 0&&x!=null&&c(t,["supervisedTuningSpec","hyperParameters","epochCount"],x)}else if(g==="PREFERENCE_TUNING"){const x=r(i,["epochCount"]);t!==void 0&&x!=null&&c(t,["preferenceOptimizationSpec","hyperParameters","epochCount"],x)}let y=r(o,["config","method"]);if(y===void 0&&(y="SUPERVISED_FINE_TUNING"),y==="SUPERVISED_FINE_TUNING"){const x=r(i,["learningRateMultiplier"]);t!==void 0&&x!=null&&c(t,["supervisedTuningSpec","hyperParameters","learningRateMultiplier"],x)}else if(y==="PREFERENCE_TUNING"){const x=r(i,["learningRateMultiplier"]);t!==void 0&&x!=null&&c(t,["preferenceOptimizationSpec","hyperParameters","learningRateMultiplier"],x)}let h=r(o,["config","method"]);if(h===void 0&&(h="SUPERVISED_FINE_TUNING"),h==="SUPERVISED_FINE_TUNING"){const x=r(i,["exportLastCheckpointOnly"]);t!==void 0&&x!=null&&c(t,["supervisedTuningSpec","exportLastCheckpointOnly"],x)}else if(h==="PREFERENCE_TUNING"){const x=r(i,["exportLastCheckpointOnly"]);t!==void 0&&x!=null&&c(t,["preferenceOptimizationSpec","exportLastCheckpointOnly"],x)}let v=r(o,["config","method"]);if(v===void 0&&(v="SUPERVISED_FINE_TUNING"),v==="SUPERVISED_FINE_TUNING"){const x=r(i,["adapterSize"]);t!==void 0&&x!=null&&c(t,["supervisedTuningSpec","hyperParameters","adapterSize"],x)}else if(v==="PREFERENCE_TUNING"){const x=r(i,["adapterSize"]);t!==void 0&&x!=null&&c(t,["preferenceOptimizationSpec","hyperParameters","adapterSize"],x)}if(r(i,["batchSize"])!==void 0)throw new Error("batchSize parameter is not supported in Vertex AI.");if(r(i,["learningRate"])!==void 0)throw new Error("learningRate parameter is not supported in Vertex AI.");const E=r(i,["labels"]);t!==void 0&&E!=null&&c(t,["labels"],E);const C=r(i,["beta"]);return t!==void 0&&C!=null&&c(t,["preferenceOptimizationSpec","hyperParameters","beta"],C),s}function J_(i,t){const o={},s=r(i,["baseModel"]);s!=null&&c(o,["baseModel"],s);const u=r(i,["preTunedModel"]);u!=null&&c(o,["preTunedModel"],u);const f=r(i,["trainingDataset"]);f!=null&&iA(f);const m=r(i,["config"]);return m!=null&&O_(m,o),o}function K_(i,t){const o={},s=r(i,["baseModel"]);s!=null&&c(o,["baseModel"],s);const u=r(i,["preTunedModel"]);u!=null&&c(o,["preTunedModel"],u);const f=r(i,["trainingDataset"]);f!=null&&lA(f,o,t);const m=r(i,["config"]);return m!=null&&Y_(m,o,t),o}function X_(i,t){const o={},s=r(i,["name"]);return s!=null&&c(o,["_url","name"],s),o}function Q_(i,t){const o={},s=r(i,["name"]);return s!=null&&c(o,["_url","name"],s),o}function Z_(i,t,o){const s={},u=r(i,["pageSize"]);t!==void 0&&u!=null&&c(t,["_query","pageSize"],u);const f=r(i,["pageToken"]);t!==void 0&&f!=null&&c(t,["_query","pageToken"],f);const m=r(i,["filter"]);return t!==void 0&&m!=null&&c(t,["_query","filter"],m),s}function $_(i,t,o){const s={},u=r(i,["pageSize"]);t!==void 0&&u!=null&&c(t,["_query","pageSize"],u);const f=r(i,["pageToken"]);t!==void 0&&f!=null&&c(t,["_query","pageToken"],f);const m=r(i,["filter"]);return t!==void 0&&m!=null&&c(t,["_query","filter"],m),s}function W_(i,t){const o={},s=r(i,["config"]);return s!=null&&Z_(s,o),o}function j_(i,t){const o={},s=r(i,["config"]);return s!=null&&$_(s,o),o}function eA(i,t){const o={},s=r(i,["sdkHttpResponse"]);s!=null&&c(o,["sdkHttpResponse"],s);const u=r(i,["nextPageToken"]);u!=null&&c(o,["nextPageToken"],u);const f=r(i,["tunedModels"]);if(f!=null){let m=f;Array.isArray(m)&&(m=m.map(g=>tg(g))),c(o,["tuningJobs"],m)}return o}function tA(i,t){const o={},s=r(i,["sdkHttpResponse"]);s!=null&&c(o,["sdkHttpResponse"],s);const u=r(i,["nextPageToken"]);u!=null&&c(o,["nextPageToken"],u);const f=r(i,["tuningJobs"]);if(f!=null){let m=f;Array.isArray(m)&&(m=m.map(g=>ku(g))),c(o,["tuningJobs"],m)}return o}function nA(i,t){const o={},s=r(i,["name"]);s!=null&&c(o,["model"],s);const u=r(i,["name"]);return u!=null&&c(o,["endpoint"],u),o}function iA(i,t){const o={};if(r(i,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");if(r(i,["vertexDatasetResource"])!==void 0)throw new Error("vertexDatasetResource parameter is not supported in Gemini API.");const s=r(i,["examples"]);if(s!=null){let u=s;Array.isArray(u)&&(u=u.map(f=>f)),c(o,["examples","examples"],u)}return o}function lA(i,t,o){const s={};let u=r(o,["config","method"]);if(u===void 0&&(u="SUPERVISED_FINE_TUNING"),u==="SUPERVISED_FINE_TUNING"){const m=r(i,["gcsUri"]);t!==void 0&&m!=null&&c(t,["supervisedTuningSpec","trainingDatasetUri"],m)}else if(u==="PREFERENCE_TUNING"){const m=r(i,["gcsUri"]);t!==void 0&&m!=null&&c(t,["preferenceOptimizationSpec","trainingDatasetUri"],m)}let f=r(o,["config","method"]);if(f===void 0&&(f="SUPERVISED_FINE_TUNING"),f==="SUPERVISED_FINE_TUNING"){const m=r(i,["vertexDatasetResource"]);t!==void 0&&m!=null&&c(t,["supervisedTuningSpec","trainingDatasetUri"],m)}else if(f==="PREFERENCE_TUNING"){const m=r(i,["vertexDatasetResource"]);t!==void 0&&m!=null&&c(t,["preferenceOptimizationSpec","trainingDatasetUri"],m)}if(r(i,["examples"])!==void 0)throw new Error("examples parameter is not supported in Vertex AI.");return s}function tg(i,t){const o={},s=r(i,["sdkHttpResponse"]);s!=null&&c(o,["sdkHttpResponse"],s);const u=r(i,["name"]);u!=null&&c(o,["name"],u);const f=r(i,["state"]);f!=null&&c(o,["state"],qh(f));const m=r(i,["createTime"]);m!=null&&c(o,["createTime"],m);const g=r(i,["tuningTask","startTime"]);g!=null&&c(o,["startTime"],g);const y=r(i,["tuningTask","completeTime"]);y!=null&&c(o,["endTime"],y);const h=r(i,["updateTime"]);h!=null&&c(o,["updateTime"],h);const v=r(i,["description"]);v!=null&&c(o,["description"],v);const E=r(i,["baseModel"]);E!=null&&c(o,["baseModel"],E);const C=r(i,["_self"]);return C!=null&&c(o,["tunedModel"],nA(C)),o}function ku(i,t){const o={},s=r(i,["sdkHttpResponse"]);s!=null&&c(o,["sdkHttpResponse"],s);const u=r(i,["name"]);u!=null&&c(o,["name"],u);const f=r(i,["state"]);f!=null&&c(o,["state"],qh(f));const m=r(i,["createTime"]);m!=null&&c(o,["createTime"],m);const g=r(i,["startTime"]);g!=null&&c(o,["startTime"],g);const y=r(i,["endTime"]);y!=null&&c(o,["endTime"],y);const h=r(i,["updateTime"]);h!=null&&c(o,["updateTime"],h);const v=r(i,["error"]);v!=null&&c(o,["error"],v);const E=r(i,["description"]);E!=null&&c(o,["description"],E);const C=r(i,["baseModel"]);C!=null&&c(o,["baseModel"],C);const x=r(i,["tunedModel"]);x!=null&&c(o,["tunedModel"],x);const P=r(i,["preTunedModel"]);P!=null&&c(o,["preTunedModel"],P);const q=r(i,["supervisedTuningSpec"]);q!=null&&c(o,["supervisedTuningSpec"],q);const V=r(i,["preferenceOptimizationSpec"]);V!=null&&c(o,["preferenceOptimizationSpec"],V);const Y=r(i,["tuningDataStats"]);Y!=null&&c(o,["tuningDataStats"],Y);const j=r(i,["encryptionSpec"]);j!=null&&c(o,["encryptionSpec"],j);const k=r(i,["partnerModelTuningSpec"]);k!=null&&c(o,["partnerModelTuningSpec"],k);const Z=r(i,["customBaseModel"]);Z!=null&&c(o,["customBaseModel"],Z);const ae=r(i,["experiment"]);ae!=null&&c(o,["experiment"],ae);const se=r(i,["labels"]);se!=null&&c(o,["labels"],se);const K=r(i,["outputUri"]);K!=null&&c(o,["outputUri"],K);const Ae=r(i,["pipelineJob"]);Ae!=null&&c(o,["pipelineJob"],Ae);const ee=r(i,["serviceAccount"]);ee!=null&&c(o,["serviceAccount"],ee);const Ee=r(i,["tunedModelDisplayName"]);Ee!=null&&c(o,["tunedModelDisplayName"],Ee);const be=r(i,["veoTuningSpec"]);return be!=null&&c(o,["veoTuningSpec"],be),o}function oA(i,t){const o={},s=r(i,["sdkHttpResponse"]);s!=null&&c(o,["sdkHttpResponse"],s);const u=r(i,["name"]);u!=null&&c(o,["name"],u);const f=r(i,["metadata"]);f!=null&&c(o,["metadata"],f);const m=r(i,["done"]);m!=null&&c(o,["done"],m);const g=r(i,["error"]);return g!=null&&c(o,["error"],g),o}function Th(i,t){const o={},s=r(i,["gcsUri"]);s!=null&&c(o,["validationDatasetUri"],s);const u=r(i,["vertexDatasetResource"]);return u!=null&&c(o,["validationDatasetUri"],u),o}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class sA extends Yn{constructor(t){super(),this.apiClient=t,this.list=async(o={})=>new Yi(On.PAGED_ITEM_TUNING_JOBS,s=>this.listInternal(s),await this.listInternal(o),o),this.get=async o=>await this.getInternal(o),this.tune=async o=>{var s;if(this.apiClient.isVertexAI())if(o.baseModel.startsWith("projects/")){const u={tunedModelName:o.baseModel};!((s=o.config)===null||s===void 0)&&s.preTunedModelCheckpointId&&(u.checkpointId=o.config.preTunedModelCheckpointId);const f=Object.assign(Object.assign({},o),{preTunedModel:u});return f.baseModel=void 0,await this.tuneInternal(f)}else{const u=Object.assign({},o);return await this.tuneInternal(u)}else{const u=Object.assign({},o),f=await this.tuneMldevInternal(u);let m="";return f.metadata!==void 0&&f.metadata.tunedModel!==void 0?m=f.metadata.tunedModel:f.name!==void 0&&f.name.includes("/operations/")&&(m=f.name.split("/operations/")[0]),{name:m,state:Lu.JOB_STATE_QUEUED}}}}async getInternal(t){var o,s,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=Q_(t);return g=$("{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=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json().then(E=>{const C=E;return C.sdkHttpResponse={headers:v.headers},C})),m.then(v=>ku(v))}else{const h=X_(t);return g=$("{name}",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(u=t.config)===null||u===void 0?void 0:u.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json().then(E=>{const C=E;return C.sdkHttpResponse={headers:v.headers},C})),m.then(v=>tg(v))}}async listInternal(t){var o,s,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=j_(t);return g=$("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=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json().then(E=>{const C=E;return C.sdkHttpResponse={headers:v.headers},C})),m.then(v=>{const E=tA(v),C=new $m;return Object.assign(C,E),C})}else{const h=W_(t);return g=$("tunedModels",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(u=t.config)===null||u===void 0?void 0:u.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json().then(E=>{const C=E;return C.sdkHttpResponse={headers:v.headers},C})),m.then(v=>{const E=eA(v),C=new $m;return Object.assign(C,E),C})}}async cancel(t){var o,s,u,f;let m,g="",y={};if(this.apiClient.isVertexAI()){const h=k_(t);return g=$("{name}:cancel",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(v=>v.json().then(E=>{const C=E;return C.sdkHttpResponse={headers:v.headers},C})),m.then(v=>{const E=F_(v),C=new Wm;return Object.assign(C,E),C})}else{const h=V_(t);return g=$("{name}:cancel",h._url),y=h._query,delete h._url,delete h._query,m=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(u=t.config)===null||u===void 0?void 0:u.httpOptions,abortSignal:(f=t.config)===null||f===void 0?void 0:f.abortSignal}).then(v=>v.json().then(E=>{const C=E;return C.sdkHttpResponse={headers:v.headers},C})),m.then(v=>{const E=B_(v),C=new Wm;return Object.assign(C,E),C})}}async tuneInternal(t){var o,s;let u,f="",m={};if(this.apiClient.isVertexAI()){const g=K_(t,t);return f=$("tuningJobs",g._url),m=g._query,delete g._url,delete g._query,u=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json().then(h=>{const v=h;return v.sdkHttpResponse={headers:y.headers},v})),u.then(y=>ku(y))}else throw new Error("This method is only supported by the Vertex AI.")}async tuneMldevInternal(t){var o,s;let u,f="",m={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=J_(t);return f=$("tunedModels",g._url),m=g._query,delete g._url,delete g._query,u=this.apiClient.request({path:f,queryParams:m,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=t.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=t.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json().then(h=>{const v=h;return v.sdkHttpResponse={headers:y.headers},v})),u.then(y=>oA(y))}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class aA{async download(t,o){throw new Error("Download to file is not supported in the browser, please use a browser compliant download like an tag.")}}const rA=1024*1024*8,uA=3,cA=1e3,fA=2,oa="x-goog-upload-status";async function dA(i,t,o){var s;const u=await ng(i,t,o),f=await(u==null?void 0:u.json());if(((s=u==null?void 0:u.headers)===null||s===void 0?void 0:s[oa])!=="final")throw new Error("Failed to upload file: Upload status is not finalized.");return f.file}async function pA(i,t,o){var s;const u=await ng(i,t,o),f=await(u==null?void 0:u.json());if(((s=u==null?void 0:u.headers)===null||s===void 0?void 0:s[oa])!=="final")throw new Error("Failed to upload file: Upload status is not finalized.");const m=wh(f),g=new Ju;return Object.assign(g,m),g}async function ng(i,t,o){var s,u;let f=0,m=0,g=new qu(new Response),y="upload";for(f=i.size;m=f&&(y+=", finalize");let E=0,C=cA;for(;EsetTimeout(t,i))}class gA{async upload(t,o,s){if(typeof t=="string")throw new Error("File path is not supported in browser uploader.");return await dA(t,o,s)}async uploadToFileSearchStore(t,o,s){if(typeof t=="string")throw new Error("File path is not supported in browser uploader.");return await pA(t,o,s)}async stat(t){if(typeof t=="string")throw new Error("File path is not supported in browser uploader.");return await mA(t)}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class yA{create(t,o,s){return new vA(t,o,s)}}class vA{constructor(t,o,s){this.url=t,this.headers=o,this.callbacks=s}connect(){this.ws=new WebSocket(this.url),this.ws.onopen=this.callbacks.onopen,this.ws.onerror=this.callbacks.onerror,this.ws.onclose=this.callbacks.onclose,this.ws.onmessage=this.callbacks.onmessage}send(t){if(this.ws===void 0)throw new Error("WebSocket is not connected");this.ws.send(t)}close(){if(this.ws===void 0)throw new Error("WebSocket is not connected");this.ws.close()}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */const Sh="x-goog-api-key";class TA{constructor(t){this.apiKey=t}async addAuthHeaders(t,o){if(t.get(Sh)===null){if(this.apiKey.startsWith("auth_tokens/"))throw new Error("Ephemeral tokens are only supported by the live API.");if(!this.apiKey)throw new Error("API key is missing. Please provide a valid API key.");t.append(Sh,this.apiKey)}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */const SA="gl-node/";class ig{constructor(t){var o;if(t.apiKey==null)throw new Error("An API Key must be set when running in a browser");if(t.project||t.location)throw new Error("Vertex AI project based authentication is not supported on browser runtimes. Please do not provide a project or location.");this.vertexai=(o=t.vertexai)!==null&&o!==void 0?o:!1,this.apiKey=t.apiKey;const s=Z0(t.httpOptions,t.vertexai,void 0,void 0);s&&(t.httpOptions?t.httpOptions.baseUrl=s:t.httpOptions={baseUrl:s}),this.apiVersion=t.apiVersion,this.httpOptions=t.httpOptions;const u=new TA(this.apiKey);this.apiClient=new QC({auth:u,apiVersion:this.apiVersion,apiKey:this.apiKey,vertexai:this.vertexai,httpOptions:this.httpOptions,userAgentExtra:SA+"web",uploader:new gA,downloader:new aA}),this.models=new m_(this.apiClient),this.live=new r_(this.apiClient,u,new yA),this.batches=new xT(this.apiClient),this.chats=new sS(this.models,this.apiClient),this.caches=new iS(this.apiClient),this.files=new gS(this.apiClient),this.operations=new h_(this.apiClient),this.authTokens=new I_(this.apiClient),this.tunings=new sA(this.apiClient),this.fileSearchStores=new z_(this.apiClient)}}const Ci=["gemini-2.5-pro","gemini-2.5-flash","gemini-2.5-flash-lite","gemini-2.5-flash-preview-09-2025","gemini-2.5-flash-lite-preview-09-2025"],Eh=["gemini-2.5-flash","gemini-2.5-flash-lite","gemini-2.5-flash-preview-09-2025","gemini-2.5-flash-lite-preview-09-2025"],EA=1e6,lg=(i,t)=>{let o="",s=EA;const u=i.map(g=>{const v=`--- START OF FILE ${g.path} --- +`+g.content+` +`;return{...g,fullContent:v,length:v.length}}),f=t?u.find(g=>g.path===t):null,m=u.filter(g=>!t||g.path!==t);f&&f.length<=s&&(o+=f.fullContent,s-=f.length);for(const g of m)if(g.length<=s)o+=g.fullContent,s-=g.length;else break;return o},Ul=i=>{if(!i)return"";let t=i.trim();const o=/^```\w*\s*\n/,s=/\n```$/;return t=t.replace(o,""),t=t.replace(s,""),t.trim()};async function fa(i,t,o,s){const f=await new ig({apiKey:"PLACEHOLDER_API_KEY"}).models.generateContentStream({model:i,contents:[{role:"user",parts:[{text:t}]}],config:{temperature:.1,topP:.95,topK:64}});for await(const m of f)m.text&&o(m.text)}async function da(i,t,o){const u=await new ig({apiKey:"PLACEHOLDER_API_KEY"}).models.generateContent({model:i,contents:[{role:"user",parts:[{text:t}]}],config:{responseMimeType:"application/json",responseSchema:o,temperature:0,topP:.95,topK:64}});if(u.text)return JSON.parse(u.text.trim());throw new Error("AI returned an empty response.")}const Ch=async(i,t,o,s,u,f)=>{const m=` + You are an expert AI programmer. Your task is to modify a file based on a high-level instruction. + + **CRITICAL RULE: Your entire response must be ONLY the raw source code for the file.** + - Do NOT output markdown code fences (like \`\`\`tsx), any explanatory text, or any preamble. + - Your response will be saved directly to a file, so it must be 100% valid code. + - If the instruction does not require any changes to this specific file, return the original content verbatim. + - Ensure the new code is syntactically correct and preserves the overall structure and logic where appropriate. + + Instruction: "${t}" + File Path: "${o}" + Original Content: + --- + ${i} + --- + `;await fa(f,m,s)},CA=async(i,t)=>{const o=` + You are a 10x software architect. A user wants to create a new project. + Your task is to analyze their prompt and generate a file structure and a brief description for each file. + - The user prompt is: "${i}" + - Based on the prompt, create a logical file structure. + - For each file, provide a concise one-sentence description of its purpose. + - The output must be a JSON object that adheres to the provided schema. + - Only include files that would contain code or text. Do not include directories as separate entries. + - Be comprehensive. Create all the necessary files for a basic, runnable version of the described project. + `,s={type:De.OBJECT,properties:{files:{type:De.ARRAY,description:"A list of files to be created for the project.",items:{type:De.OBJECT,properties:{path:{type:De.STRING,description:'The full path of the file, including directories. E.g., "src/components/Button.tsx".'},description:{type:De.STRING,description:"A concise, one-sentence description of what this file will contain or its purpose."}},required:["path","description"]}}},required:["files"]};return da(t,o,s)},_h=async(i,t,o,s,u,f)=>{const m=` + You are an expert AI programmer generating code for a new project. + The overall project goal is: "${i}" + You are creating the file at this path: "${t}" + The purpose of this file is: "${o}" + + Your task is to generate the complete, production-quality code for this single file. + + **CRITICAL RULE: Your entire response must be ONLY the raw source code for the file.** + - Do NOT output markdown code fences (like \`\`\`tsx), any explanatory text, or any preamble. + - Your response will be saved directly to a file, so it must be 100% valid code. + - The code should be fully functional and align with the file's described purpose within the larger project. + `;await fa(f,m,s)},_A=async(i,t,o)=>{const s=i.map(m=>`--- START OF SEED FILE ${m.path} --- +${m.content} +`).join(""),u=` + You are a god-tier AI software architect and massive scale project generator. + Your task is to take a single seed file and generate a massive project expansion around it. + The user's high-level goal is: "${t}" + + You have been given the content of the SEED FILE. + Based on this seed, you must generate a comprehensive plan to create a huge number of new files to build out a complete, production-grade system. + + **OBJECTIVES:** + 1. Analyze the seed file to understand the core domain and patterns. + 2. Plan a massive expansion. Do not hold back. Create as many files as necessary to make this a rich, fully-featured application. + 3. 'filesToCreate': A list of NEW files. Assign an agent index (0-7) to each for parallel creation. + 4. 'filesToEdit': MUST BE EMPTY. Do not touch the seed file. The seed file is immutable. + + Your response must be a JSON object adhering to the provided schema. + + Here is the SEED FILE context: + ${s} + `,f={type:De.OBJECT,properties:{filesToEdit:{type:De.ARRAY,description:"A list of existing files to modify.",items:{type:De.OBJECT,properties:{path:{type:De.STRING,description:"Path of the file to edit."},changes:{type:De.STRING,description:"Detailed, step-by-step instructions for the code modifications."}},required:["path","changes"]}},filesToCreate:{type:De.ARRAY,description:"A list of new files to create.",items:{type:De.OBJECT,properties:{path:{type:De.STRING,description:"Full path of the new file to create."},description:{type:De.STRING,description:"Detailed description of the new file's purpose and content."},agentIndex:{type:De.NUMBER,description:"Agent index (0-7) assigned to create this file."}},required:["path","description","agentIndex"]}}}};return da(o,u,f)},AA=async(i,t,o,s,u)=>{const f=` + You are an AI code assistant. Rewrite the following file content based on the user's instruction. + + **CRITICAL RULE: Your entire response must be ONLY the new, complete file content.** + - Do NOT output markdown code fences (e.g., \`\`\`). + - The output will be saved directly to a file, so it must be clean. + + Instruction: "${t}" + File Path: "${o}" + Original Content: + --- + ${i} + --- + `;await fa(u,f,s)},xA=async(i,t,o,s)=>{const u=lg(o,t),f=` + You are an autonomous AI software engineer. Your task is to implement a user's request by planning a series of file edits. + + **CRITICAL DIRECTIVE:** + You have complete and unrestricted access to the full source code of every file in the repository, provided below. + You MUST use this context to inform your plan. Do not, under any circumstances, claim you cannot see a file or that the code is incomplete. Base your entire plan on the provided code. + + **User Request:** "${i}" + (The user was viewing this file when they made the request: "${t}") + + **Your Task:** + 1. **Reasoning:** First, in a few sentences, explain your plan. Describe which files you will edit and why, outlining your high-level strategy to fulfill the user request. This reasoning is critical for the user to understand your thought process. + 2. **filesToEdit:** Second, create a precise list of files to edit. For each file, provide a detailed, step-by-step description of the exact changes needed. This is not the code itself, but a set of instructions for another AI to execute. Be specific. For example, instead of "update the function," say "in the 'handleSubmit' function, add a new 'if' condition to check for 'user.id' before calling the API." + + Your output must be a single JSON object that strictly follows the provided schema. + + **These are the existing files in the app:** + ${u} + `,m={type:De.OBJECT,properties:{reasoning:{type:De.STRING,description:"A high-level explanation of your plan, which files you will edit, and why."},filesToEdit:{type:De.ARRAY,description:"A list of files to modify and the specific changes for each.",items:{type:De.OBJECT,properties:{path:{type:De.STRING,description:"Path of the file to edit."},changes:{type:De.STRING,description:"Detailed, step-by-step instructions for the code modifications."}},required:["path","changes"]}}},required:["reasoning","filesToEdit"]};return da(s,f,m)},NA=async(i,t,o,s,u)=>{const f=` + You are an expert AI programmer. Your task is to meticulously modify a single file based on a detailed change instruction. + + **CRITICAL RULE: Your entire response must be ONLY the new, complete, raw source code for the file.** + - Do NOT output markdown code fences (like \`\`\`tsx), any explanatory text, or any preamble. + - Your response will be saved directly to a file, so it must be 100% valid code. + - Follow the instructions exactly to produce the final version of the file. + + Instruction: "${t}" + File Path: "${o}" + Original Content: + --- + ${i} + --- + `;await fa(u,f,s)},RA=async(i,t,o,s,u)=>{const f=lg(t),m=o.map(h=>`I previously tried to edit "${h.path}" to have this content: +--- +${h.newContent} +--- +`).join(` +`),g=` + You are an autonomous AI software engineer. Your previous attempt to modify the code resulted in a failed build. Your task is to analyze the build logs, understand the error, and create a NEW plan to fix it. + + **CRITICAL DIRECTIVE:** + You have complete and unrestricted access to the full source code of every file in the repository, provided below. + You MUST use this context. Do not claim you cannot see a file or that the code is truncated. Your fix must be based on the actual code provided. + + **Original User Request:** "${i}" + + **Build Error Logs:** + --- + ${s} + --- + + **My Previous (Failed) Edits:** + ${m} + + **Your Corrective Task:** + 1. **Analyze & Reason:** Read the build logs and my previous edits. In a few sentences, explain the root cause of the build failure. Then, describe your new plan to fix the code. + 2. **filesToEdit:** Create a new, precise list of files to edit to fix the error. For each file, provide a detailed, step-by-step description of the exact changes needed. This plan will completely replace the previous one. If you need to revert a change in one file and edit another, specify both actions. + + Your output must be a single JSON object that strictly follows the provided schema. + + **These are the current files in the app (reflecting your previous failed attempt):** + ${f} + `,y={type:De.OBJECT,properties:{reasoning:{type:De.STRING,description:"An analysis of the build failure and a high-level explanation of your new plan to fix it."},filesToEdit:{type:De.ARRAY,description:"A new list of files to modify and the specific changes for each to fix the build.",items:{type:De.OBJECT,properties:{path:{type:De.STRING,description:"Path of the file to edit."},changes:{type:De.STRING,description:"Detailed, step-by-step instructions for the new code modifications."}},required:["path","changes"]}}},required:["reasoning","filesToEdit"]};return da(u,g,y)},MA=({alert:i,onClose:t})=>{if(B.useEffect(()=>{if(i){const s=setTimeout(()=>{t()},4e3);return()=>clearTimeout(s)}},[i,t]),!i)return null;const o=i.type==="success"?"bg-green-600":"bg-red-600";return S.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:[S.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; + } + `}),S.jsx("p",{children:i.message})]})},wA=({fileCount:i,onClose:t,onSubmit:o})=>{const[s,u]=B.useState(""),[f,m]=B.useState(!1),g=async y=>{y.preventDefault(),!(!s.trim()||f)&&(m(!0),await o(s))};return S.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-70 flex items-center justify-center z-50",onClick:t,children:S.jsxs("div",{className:"bg-gray-850 p-6 rounded-lg shadow-2xl w-full max-w-2xl border border-gray-700",onClick:y=>y.stopPropagation(),children:[S.jsx("h2",{className:"text-xl font-bold text-amber-400 mb-2",children:"Multi-File AI Edit"}),S.jsxs("p",{className:"text-gray-400 mb-4",children:[i," file",i>1?"s":""," selected for editing."]}),S.jsxs("div",{className:"bg-red-900 border border-red-700 text-red-200 p-3 rounded-md mb-6 text-sm",children:[S.jsxs("p",{children:[S.jsx("strong",{children:"Warning:"})," This is an experimental feature. It will:"]}),S.jsxs("ul",{className:"list-disc list-inside mt-2",children:[S.jsxs("li",{children:["Commit changes directly to the ",S.jsx("strong",{children:"current branch"})," for each repository."]}),S.jsx("li",{children:"Process up to 8 files concurrently using a pool of AI workers."}),S.jsx("li",{children:"Each worker starts a new job every 31 seconds to manage rate limits."}),S.jsx("li",{children:"If a file fails, it will automatically retry with a different AI model (including fallback models) until it succeeds."})]}),S.jsx("p",{className:"mt-2",children:"It is highly recommended to create a new branch before starting and to review all changes carefully."})]}),S.jsxs("form",{onSubmit:g,children:[S.jsxs("div",{className:"mb-4",children:[S.jsx("label",{htmlFor:"instruction",className:"block text-sm font-medium text-gray-300 mb-2",children:"High-Level Instruction for All Selected Files"}),S.jsx("textarea",{id:"instruction",value:s,onChange:y=>u(y.target.value),placeholder:"e.g., 'Refactor all selected components to use functional components and hooks.'",className:"w-full h-32 bg-gray-900 p-3 rounded-md text-sm border border-gray-600 focus:outline-none focus:ring-2 focus:ring-amber-500 resize-none",autoFocus:!0})]}),S.jsxs("div",{className:"flex justify-end gap-4 mt-6",children:[S.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 bg-gray-600 text-white font-semibold rounded-md hover:bg-gray-700 disabled:opacity-50",disabled:f,children:"Cancel"}),S.jsx("button",{type:"submit",disabled:f||!s.trim(),className:"px-6 py-2 bg-amber-600 text-white font-semibold rounded-md hover:bg-amber-700 disabled:bg-gray-500 disabled:cursor-not-allowed transition-colors flex items-center justify-center min-w-[120px]",children:f?S.jsx(ot,{}):"Start AI Edit"})]})]})]})})},bA=({status:i})=>{switch(i){case"queued":return S.jsx("div",{title:"Queued",className:"w-4 h-4 rounded-full bg-gray-600 flex-shrink-0"});case"processing":return S.jsx(ot,{className:"w-4 h-4 text-blue-400"});case"retrying":return S.jsx(ot,{className:"w-4 h-4 text-orange-400"});case"success":return S.jsx("div",{title:"Success",className:"w-4 h-4 rounded-full bg-green-500 flex items-center justify-center text-white text-xs font-bold flex-shrink-0",children:"✓"});case"skipped":return S.jsx("div",{title:"Skipped",className:"w-4 h-4 rounded-full bg-yellow-500 flex items-center justify-center text-black text-xs font-bold flex-shrink-0",children:"-"});case"failed":return S.jsx("div",{title:"Failed",className:"w-4 h-4 rounded-full bg-red-500 flex items-center justify-center text-white text-xs font-bold flex-shrink-0",children:"!"});default:return null}},IA=({jobs:i,onClose:t,isComplete:o})=>{const s=i.filter(g=>g.status==="success"||g.status==="skipped"||g.status==="failed").length,u=i.filter(g=>g.status==="success").length,f=i.length>0?s/i.length*100:0,m=i.filter(g=>g.status==="processing"||g.status==="retrying");return S.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-80 flex items-center justify-center z-50",children:S.jsxs("div",{className:"bg-gray-850 p-6 rounded-lg shadow-2xl w-full max-w-6xl h-[90vh] flex flex-col border border-gray-700",children:[S.jsxs("div",{className:"flex justify-between items-center mb-4 flex-shrink-0",children:[S.jsx("h2",{className:"text-2xl font-bold text-amber-400",children:"AI Bulk Edit Progress"}),o&&S.jsx("button",{onClick:t,className:"px-4 py-2 bg-gray-600 text-white font-semibold rounded-md hover:bg-gray-700",children:"Close"})]}),S.jsxs("div",{className:"mb-4 flex-shrink-0",children:[S.jsxs("div",{className:"flex justify-between text-sm text-gray-300 mb-1",children:[S.jsx("span",{children:`Overall Progress (${s} / ${i.length})`}),S.jsxs("span",{children:[u," successful"]})]}),S.jsx("div",{className:"w-full bg-gray-700 rounded-full h-2.5",children:S.jsx("div",{className:"bg-amber-500 h-2.5 rounded-full transition-all duration-300 ease-in-out",style:{width:`${f}%`}})})]}),S.jsxs("div",{className:"grid grid-cols-3 gap-4 flex-grow min-h-0",children:[S.jsxs("div",{className:"col-span-1 bg-gray-900 rounded-md p-4 overflow-y-auto",children:[S.jsx("h3",{className:"text-lg font-semibold mb-2 text-gray-200",children:"File Queue"}),S.jsx("ul",{className:"space-y-1",children:i.map(g=>S.jsxs("li",{className:"flex items-center justify-between text-sm p-1.5 bg-gray-800 rounded",children:[S.jsxs("div",{className:"flex items-center gap-3 overflow-hidden",children:[S.jsx(bA,{status:g.status}),S.jsx("span",{className:"truncate",title:g.path,children:g.path})]}),(g.status==="failed"||g.status==="retrying")&&S.jsx("span",{className:"text-red-400 text-xs truncate ml-2 cursor-pointer",title:g.error||"Unknown error",children:g.error})]},g.id))})]}),S.jsxs("div",{className:"col-span-2 bg-gray-900 rounded-md p-4 flex flex-col",children:[S.jsxs("h3",{className:"text-lg font-semibold mb-2 text-gray-200",children:["Live Workstream (",m.length," active)"]}),m.length>0?S.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2 flex-grow min-h-0",children:m.slice(0,8).map(g=>S.jsxs("div",{className:"flex-grow flex flex-col min-h-0 bg-gray-850 rounded-lg p-2",children:[S.jsxs("p",{className:"text-blue-300 font-mono text-xs mb-2 truncate",title:g.path,children:[g.status==="retrying"?"Retrying":"Processing",": ",S.jsx("span",{className:"font-bold",children:g.path.split("/").pop()})]}),S.jsx("div",{className:"bg-gray-950 rounded p-2 flex-grow overflow-y-auto",children:S.jsx("pre",{className:"text-xs text-gray-300 whitespace-pre-wrap break-words",children:S.jsx("code",{children:g.content})})})]},g.id))}):S.jsx("div",{className:"flex items-center justify-center h-full text-gray-500",children:o?"All jobs complete.":"Waiting for next job..."})]})]})]})})},DA=({onClose:i,onSubmit:t})=>{const[o,s]=B.useState(""),[u,f]=B.useState(""),[m,g]=B.useState(!0),[y,h]=B.useState(!1),[v,E]=B.useState(""),C=async x=>{if(x.preventDefault(),E(""),!(!o.trim()||!u.trim()||y)){h(!0);try{await t(o.trim().replace(/\s+/g,"-"),u,m)}catch(P){E(P instanceof Error?P.message:"An unknown error occurred."),h(!1)}}};return S.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-70 flex items-center justify-center z-50",onClick:i,children:S.jsxs("div",{className:"bg-gray-850 p-6 rounded-lg shadow-2xl w-full max-w-2xl border border-gray-700",onClick:x=>x.stopPropagation(),children:[S.jsx("h2",{className:"text-xl font-bold text-indigo-400 mb-4",children:"New AI Project"}),S.jsx("p",{className:"text-gray-400 mb-6 text-sm",children:"Describe the project you want to build. The AI will create a new repository, plan the file structure, and generate all the necessary code."}),S.jsxs("form",{onSubmit:C,children:[S.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-4",children:[S.jsxs("div",{className:"md:col-span-2",children:[S.jsx("label",{htmlFor:"repoName",className:"block text-sm font-medium text-gray-300 mb-2",children:"New Repository Name"}),S.jsx("input",{id:"repoName",type:"text",value:o,onChange:x=>s(x.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:"my-new-ai-project",required:!0,autoFocus:!0})]}),S.jsxs("div",{children:[S.jsx("label",{htmlFor:"repoVisibility",className:"block text-sm font-medium text-gray-300 mb-2",children:"Visibility"}),S.jsxs("select",{id:"repoVisibility",value:m?"private":"public",onChange:x=>g(x.target.value==="private"),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",children:[S.jsx("option",{value:"private",children:"Private"}),S.jsx("option",{value:"public",children:"Public"})]})]})]}),S.jsxs("div",{className:"mb-4",children:[S.jsx("label",{htmlFor:"prompt",className:"block text-sm font-medium text-gray-300 mb-2",children:"Project Description"}),S.jsx("textarea",{id:"prompt",value:u,onChange:x=>f(x.target.value),placeholder:"e.g., 'A simple to-do list app using React, TypeScript, and Tailwind CSS. It should have a main component to display and add tasks.'",className:"w-full h-40 bg-gray-900 p-3 rounded-md text-sm border border-gray-600 focus:outline-none focus:ring-2 focus:ring-indigo-500 resize-none",required:!0})]}),v&&S.jsx("p",{className:"text-red-400 text-sm mb-4",children:v}),S.jsxs("div",{className:"flex justify-end gap-4",children:[S.jsx("button",{type:"button",onClick:i,className:"px-4 py-2 bg-gray-600 text-white font-semibold rounded-md hover:bg-gray-700 disabled:opacity-50",disabled:y,children:"Cancel"}),S.jsx("button",{type:"submit",disabled:y||!o.trim()||!u.trim(),className:"px-4 py-2 bg-indigo-600 text-white font-semibold rounded-md hover:bg-indigo-700 disabled:bg-gray-500 disabled:cursor-not-allowed transition-colors flex items-center justify-center min-w-[150px]",children:y?S.jsx(ot,{}):"Generate Project"})]})]})]})})},UA=({status:i})=>{switch(i){case"queued":return S.jsx("div",{title:"Queued",className:"w-4 h-4 rounded-full bg-gray-600 flex-shrink-0"});case"generating":return S.jsx(ot,{className:"w-4 h-4 text-blue-400"});case"committing":return S.jsx(ot,{className:"w-4 h-4 text-yellow-400"});case"retrying":return S.jsx(ot,{className:"w-4 h-4 text-orange-400"});case"success":return S.jsx("div",{title:"Success",className:"w-4 h-4 rounded-full bg-green-500 flex items-center justify-center text-white text-xs font-bold flex-shrink-0",children:"✓"});case"failed":return S.jsx("div",{title:"Failed",className:"w-4 h-4 rounded-full bg-red-500 flex items-center justify-center text-white text-xs font-bold flex-shrink-0",children:"!"});default:return null}},LA=({jobs:i,statusMessage:t,onClose:o,isComplete:s})=>{const u=i.filter(y=>y.status==="success"||y.status==="failed").length,f=i.filter(y=>y.status==="success").length,m=i.length>0?u/i.length*100:0,g=i.filter(y=>y.status==="generating"||y.status==="committing"||y.status==="retrying");return S.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-80 flex items-center justify-center z-50",children:S.jsxs("div",{className:"bg-gray-850 p-6 rounded-lg shadow-2xl w-full max-w-6xl h-[90vh] flex flex-col border border-gray-700",children:[S.jsxs("div",{className:"flex justify-between items-center mb-4 flex-shrink-0",children:[S.jsx("h2",{className:"text-2xl font-bold text-indigo-400",children:"AI Project Generation"}),s&&S.jsx("button",{onClick:o,className:"px-4 py-2 bg-gray-600 text-white font-semibold rounded-md hover:bg-gray-700",children:"Close"})]}),S.jsxs("div",{className:"mb-4 flex-shrink-0",children:[S.jsxs("div",{className:"flex justify-between text-sm text-gray-300 mb-1",children:[S.jsxs("span",{className:"flex items-center gap-2",children:[!s&&S.jsx(ot,{className:"h-4 w-4"}),t]}),S.jsx("span",{children:`${f} / ${i.length} files successful`})]}),S.jsx("div",{className:"w-full bg-gray-700 rounded-full h-2.5",children:S.jsx("div",{className:"bg-indigo-500 h-2.5 rounded-full transition-all duration-300 ease-in-out",style:{width:`${m}%`}})})]}),S.jsxs("div",{className:"grid grid-cols-3 gap-4 flex-grow min-h-0",children:[S.jsxs("div",{className:"col-span-1 bg-gray-900 rounded-md p-4 overflow-y-auto",children:[S.jsx("h3",{className:"text-lg font-semibold mb-2 text-gray-200",children:"File Plan"}),S.jsx("ul",{className:"space-y-1",children:i.map(y=>S.jsxs("li",{className:"flex items-center justify-between text-sm p-1.5 bg-gray-800 rounded",children:[S.jsxs("div",{className:"flex items-center gap-3 overflow-hidden",children:[S.jsx(UA,{status:y.status}),S.jsx("span",{className:"truncate",title:y.path,children:y.path})]}),(y.status==="failed"||y.status==="retrying")&&S.jsx("span",{className:"text-red-400 text-xs truncate ml-2 cursor-pointer",title:y.error||"Unknown error",children:y.error})]},y.id))})]}),S.jsxs("div",{className:"col-span-2 bg-gray-900 rounded-md p-4 flex flex-col",children:[S.jsxs("h3",{className:"text-lg font-semibold mb-2 text-gray-200",children:["Live Generation (",g.length," active)"]}),g.length>0?S.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2 flex-grow min-h-0",children:g.slice(0,8).map(y=>S.jsxs("div",{className:"flex-grow flex flex-col min-h-0 bg-gray-850 rounded-lg p-2",children:[S.jsxs("p",{className:"text-blue-300 font-mono text-xs mb-2 truncate",title:y.path,children:[y.status.charAt(0).toUpperCase()+y.status.slice(1),": ",S.jsx("span",{className:"font-bold",children:y.path})]}),S.jsx("div",{className:"bg-gray-950 rounded p-2 flex-grow overflow-y-auto",children:S.jsx("pre",{className:"text-xs text-gray-300 whitespace-pre-wrap break-words",children:S.jsx("code",{children:y.content})})})]},y.id))}):S.jsx("div",{className:"flex items-center justify-center h-full text-gray-500",children:s?"All files generated.":"Waiting to generate..."})]})]})]})})},qA=({onClose:i,onSubmit:t})=>{const[o,s]=B.useState(""),[u,f]=B.useState(!1),m=async g=>{g.preventDefault(),!(!o.trim()||u)&&(f(!0),await t(o))};return S.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-70 flex items-center justify-center z-50",onClick:i,children:S.jsxs("div",{className:"bg-gray-850 p-6 rounded-lg shadow-2xl w-full max-w-2xl border border-gray-700",onClick:g=>g.stopPropagation(),children:[S.jsx("h2",{className:"text-xl font-bold text-purple-400 mb-2",children:"Project Expansion (Seed Mode)"}),S.jsxs("p",{className:"text-gray-400 mb-4",children:["You've selected a ",S.jsx("strong",{children:"single seed file"}),". Describe your high-level goal, and the AI will generate a massive amount of ",S.jsx("strong",{children:"new files"})," to expand this project. The seed file itself will not be modified."]}),S.jsxs("form",{onSubmit:m,children:[S.jsxs("div",{className:"mb-4",children:[S.jsx("label",{htmlFor:"prompt",className:"block text-sm font-medium text-gray-300 mb-2",children:"High-Level Expansion Goal"}),S.jsx("textarea",{id:"prompt",value:o,onChange:g=>s(g.target.value),placeholder:"e.g., 'Add a complete user authentication system with sign-up, login, and profile pages. Also add a dashboard to visualize data from the existing components.'",className:"w-full h-40 bg-gray-900 p-3 rounded-md text-sm border border-gray-600 focus:outline-none focus:ring-2 focus:ring-purple-500 resize-none",autoFocus:!0})]}),S.jsxs("div",{className:"flex justify-end gap-4 mt-6",children:[S.jsx("button",{type:"button",onClick:i,className:"px-4 py-2 bg-gray-600 text-white font-semibold rounded-md hover:bg-gray-700 disabled:opacity-50",disabled:u,children:"Cancel"}),S.jsx("button",{type:"submit",disabled:u||!o.trim(),className:"px-6 py-2 bg-purple-600 text-white font-semibold rounded-md hover:bg-purple-700 disabled:bg-gray-500 disabled:cursor-not-allowed transition-colors flex items-center justify-center min-w-[120px]",children:u?S.jsx(ot,{}):"Unleash Agents"})]})]})]})})},GA=({status:i})=>{switch(i){case"queued":return S.jsx("div",{title:"Queued",className:"w-4 h-4 rounded-full bg-gray-600 flex-shrink-0"});case"generating":return S.jsx(ot,{className:"w-4 h-4 text-blue-400"});case"committing":return S.jsx(ot,{className:"w-4 h-4 text-yellow-400"});case"retrying":return S.jsx(ot,{className:"w-4 h-4 text-orange-400"});case"success":return S.jsx("div",{title:"Success",className:"w-4 h-4 rounded-full bg-green-500 flex items-center justify-center text-white text-xs font-bold flex-shrink-0",children:"✓"});case"failed":return S.jsx("div",{title:"Failed",className:"w-4 h-4 rounded-full bg-red-500 flex items-center justify-center text-white text-xs font-bold flex-shrink-0",children:"!"});default:return null}},Ah=({title:i,isActive:t,isComplete:o})=>S.jsxs("div",{className:"flex items-center gap-2",children:[t&&S.jsx(ot,{className:"h-4 w-4"}),o&&S.jsx("div",{className:"w-4 h-4 rounded-full bg-green-500 flex items-center justify-center text-white text-xs font-bold flex-shrink-0",children:"✓"}),S.jsx("span",{className:t?"text-purple-300":o?"text-gray-300":"text-gray-500",children:i})]}),HA=({jobs:i,phase:t,onClose:o,isComplete:s})=>{const u=i.filter(h=>h.status==="success"||h.status==="failed").length,f=i.filter(h=>h.status==="success").length,m=i.length>0?u/i.length*100:0,g=i.filter(h=>h.status==="generating"||h.status==="committing"||h.status==="retrying"),y=()=>{switch(t){case"planning":return"Master agent is analyzing the seed file and planning massive expansion...";case"generating":return`Executing plan: ${i.length} file operations...`;case"complete":return"Project expansion complete!";default:return"Initializing..."}};return S.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-80 flex items-center justify-center z-50",children:S.jsxs("div",{className:"bg-gray-850 p-6 rounded-lg shadow-2xl w-full max-w-7xl h-[90vh] flex flex-col border border-gray-700",children:[S.jsxs("div",{className:"flex justify-between items-center mb-4 flex-shrink-0",children:[S.jsx("h2",{className:"text-2xl font-bold text-purple-400",children:"AI Project Expansion"}),s&&S.jsx("button",{onClick:o,className:"px-4 py-2 bg-gray-600 text-white font-semibold rounded-md hover:bg-gray-700",children:"Close"})]}),S.jsxs("div",{className:"mb-4 flex-shrink-0 space-y-3",children:[S.jsxs("div",{className:"flex items-center justify-around p-2 bg-gray-900 rounded-md",children:[S.jsx(Ah,{title:"1. Planning",isActive:t==="planning",isComplete:["generating","complete"].includes(t)}),S.jsx("div",{className:"flex-grow h-px bg-gray-700 mx-4"}),S.jsx(Ah,{title:"2. Execution",isActive:t==="generating",isComplete:t==="complete"})]}),S.jsxs("div",{className:"flex justify-between text-sm text-gray-300 mb-1",children:[S.jsxs("span",{className:"flex items-center gap-2",children:[t!=="complete"&&S.jsx(ot,{className:"h-4 w-4"}),y()]}),S.jsx("span",{children:`${f} / ${i.length} file operations successful`})]}),S.jsx("div",{className:"w-full bg-gray-700 rounded-full h-2.5",children:S.jsx("div",{className:"bg-purple-500 h-2.5 rounded-full transition-all duration-300 ease-in-out",style:{width:`${m}%`}})})]}),t==="planning"?S.jsx("div",{className:"flex-grow min-h-0 bg-gray-900 rounded-md p-4 flex items-center justify-center",children:S.jsxs("div",{className:"text-center text-gray-400",children:[S.jsx(ot,{className:"h-8 w-8 mx-auto mb-4"}),S.jsx("p",{children:"Master agent is analyzing the seed file..."}),S.jsx("p",{className:"text-sm text-gray-500",children:"This may take a few moments."})]})}):S.jsxs("div",{className:"grid grid-cols-3 gap-4 flex-grow min-h-0",children:[S.jsxs("div",{className:"col-span-1 bg-gray-900 rounded-md p-4 overflow-y-auto",children:[S.jsxs("h3",{className:"text-lg font-semibold mb-2 text-gray-200",children:["Execution Plan (",i.length," Operations)"]}),S.jsx("ul",{className:"space-y-1",children:i.map(h=>S.jsxs("li",{className:"flex items-center justify-between text-sm p-1.5 bg-gray-800 rounded",children:[S.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[S.jsx(GA,{status:h.status}),h.type==="edit"?S.jsx("span",{className:"text-xs font-mono text-yellow-400 bg-yellow-900 px-1.5 py-0.5 rounded flex-shrink-0",children:"[EDIT]"}):S.jsx("span",{className:"text-xs font-mono text-green-400 bg-green-900 px-1.5 py-0.5 rounded flex-shrink-0",children:"[NEW]"}),S.jsx("span",{className:"truncate",title:h.path,children:h.path})]}),(h.status==="failed"||h.status==="retrying")&&S.jsx("span",{className:"text-red-400 text-xs truncate ml-2 cursor-pointer",title:h.error||"Unknown error",children:h.error})]},h.id))})]}),S.jsxs("div",{className:"col-span-2 bg-gray-900 rounded-md p-4 flex flex-col",children:[S.jsxs("h3",{className:"text-lg font-semibold mb-2 text-gray-200",children:["Live Workstream (",g.length," active)"]}),g.length>0?S.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2 flex-grow min-h-0",children:g.slice(0,8).map(h=>S.jsxs("div",{className:"flex-grow flex flex-col min-h-0 bg-gray-850 rounded-lg p-2",children:[S.jsxs("p",{className:"text-blue-300 font-mono text-xs mb-2 truncate",title:h.path,children:["Agent ",h.agentIndex," ",h.status==="generating"?"Generating":"Committing",": ",S.jsx("span",{className:"font-bold",children:h.path.split("/").pop()})]}),S.jsx("div",{className:"bg-gray-950 rounded p-2 flex-grow overflow-y-auto",children:S.jsx("pre",{className:"text-xs text-gray-300 whitespace-pre-wrap break-words",children:S.jsx("code",{children:h.content})})})]},h.id))}):S.jsx("div",{className:"flex items-center justify-center h-full text-gray-500",children:s?"All jobs complete.":"Waiting for next job..."})]})]})]})})},PA=({onClose:i,onSubmit:t,token:o,repoFullName:s})=>{const[u,f]=B.useState(""),[m,g]=B.useState(!1),[y,h]=B.useState([]),[v,E]=B.useState(""),[C,x]=B.useState(!0);B.useEffect(()=>{(async()=>{if(o&&s)try{x(!0);const[V,Y]=s.split("/"),k=(await B0(o,V,Y)).workflows.filter(Z=>Z.state==="active");h(k),k.length>0&&E(String(k[0].id))}catch(V){console.error("Failed to fetch workflows",V)}finally{x(!1)}})()},[o,s]);const P=async q=>{q.preventDefault(),!(!u.trim()||m||!v)&&(g(!0),await t(u,v))};return S.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-70 flex items-center justify-center z-50",onClick:i,children:S.jsxs("div",{className:"bg-gray-850 p-6 rounded-lg shadow-2xl w-full max-w-2xl border border-gray-700",onClick:q=>q.stopPropagation(),children:[S.jsx("h2",{className:"text-xl font-bold text-indigo-400 mb-4",children:"Advanced AI Edit & Test"}),S.jsxs("div",{className:"bg-blue-900 border border-blue-700 text-blue-200 p-4 rounded-md mb-6 text-sm space-y-2",children:[S.jsx("p",{children:S.jsx("strong",{children:"This is a powerful, repository-aware AI agent."})}),S.jsxs("ul",{className:"list-disc list-inside",children:[S.jsx("li",{children:"It analyzes your entire repository for context."}),S.jsx("li",{children:"It can edit multiple files to fulfill your request."}),S.jsxs("li",{children:["It will ",S.jsx("strong",{children:"commit changes and run a GitHub Actions workflow"})," to verify its work."]}),S.jsx("li",{children:"If the build fails, it will analyze the logs and attempt to fix its own mistakes."})]})]}),S.jsxs("form",{onSubmit:P,children:[S.jsxs("div",{className:"mb-4",children:[S.jsx("label",{htmlFor:"instruction-advanced",className:"block text-sm font-medium text-gray-300 mb-2",children:"Your Request"}),S.jsx("textarea",{id:"instruction-advanced",value:u,onChange:q=>f(q.target.value),placeholder:"e.g., 'Refactor the authentication logic to use a context provider instead of prop drilling.'",className:"w-full h-40 bg-gray-900 p-3 rounded-md text-sm border border-gray-600 focus:outline-none focus:ring-2 focus:ring-indigo-500 resize-none",autoFocus:!0})]}),S.jsxs("div",{className:"mb-6",children:[S.jsx("label",{htmlFor:"workflow-select",className:"block text-sm font-medium text-gray-300 mb-2",children:"Select Workflow for Verification"}),C?S.jsxs("div",{className:"flex items-center gap-2 text-gray-400",children:[S.jsx(ot,{className:"w-4 h-4"}),S.jsx("span",{children:"Loading workflows..."})]}):y.length>0?S.jsx("select",{id:"workflow-select",value:v,onChange:q=>E(q.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",children:y.map(q=>S.jsxs("option",{value:q.id,children:[q.name," (",q.path.split("/").pop(),")"]},q.id))}):S.jsx("p",{className:"text-sm text-yellow-400 bg-yellow-900 p-2 rounded-md",children:"No active GitHub Actions workflows found in this repository."})]}),S.jsxs("div",{className:"flex justify-end gap-4",children:[S.jsx("button",{type:"button",onClick:i,className:"px-4 py-2 bg-gray-600 text-white font-semibold rounded-md hover:bg-gray-700 disabled:opacity-50",disabled:m,children:"Cancel"}),S.jsx("button",{type:"submit",disabled:m||!u.trim()||!v,className:"px-4 py-2 bg-indigo-600 text-white font-semibold rounded-md hover:bg-indigo-700 disabled:bg-gray-500 disabled:cursor-not-allowed transition-colors flex items-center justify-center min-w-[120px]",children:m?S.jsx(ot,{}):"Execute & Test"})]})]})]})})},zA=({status:i})=>{switch(i){case"planning":case"editing":return S.jsx(ot,{className:"w-4 h-4 text-blue-400"});case"verifying":return S.jsx(ot,{className:"w-4 h-4 text-yellow-400"});case"committing":return S.jsx(ot,{className:"w-4 h-4 text-orange-400"});case"success":return S.jsx("div",{title:"Success",className:"w-4 h-4 rounded-full bg-green-500 flex items-center justify-center text-white text-xs font-bold flex-shrink-0",children:"✓"});case"failed":return S.jsx("div",{title:"Failed",className:"w-4 h-4 rounded-full bg-red-500 flex items-center justify-center text-white text-xs font-bold flex-shrink-0",children:"!"});default:return S.jsx("div",{title:"Pending",className:"w-4 h-4 rounded-full bg-gray-600 flex-shrink-0"})}},Go=({title:i,isActive:t,isComplete:o})=>S.jsxs("div",{className:"flex items-center gap-2",children:[t&&S.jsx(ot,{className:"h-4 w-4"}),o&&S.jsx("div",{className:"w-4 h-4 rounded-full bg-green-500 flex items-center justify-center text-white text-xs font-bold flex-shrink-0",children:"✓"}),S.jsx("span",{className:t?"text-indigo-300":o?"text-gray-300":"text-gray-500",children:i})]}),VA=({jobs:i,phase:t,verificationAttempt:o,buildLogs:s,workflowRunUrl:u,aiThought:f,deploymentUrl:m,onClose:g,isComplete:y})=>{const h=i.filter(x=>x.status==="success").length,v=i.length>0?h/i.length*100:0,E=()=>{switch(t){case"analyzing":return"Analyzing repository context...";case"planning":return"AI is creating an edit plan...";case"editing":return`AI is editing ${i.length} file(s)...`;case"committing":return"Committing changes to trigger workflow...";case"triggering_workflow":return"Triggering GitHub Actions workflow...";case"waiting_for_workflow":return`Running CI build (Attempt ${o})...`;case"analyzing_failure":return`Build failed (Attempt ${o}). Analyzing logs for correction...`;case"complete":return"Advanced edit complete and verified!";default:return"Initializing..."}},C=i.find(x=>x.status==="editing")||i.find(x=>x.status==="committing")||i[i.length-1];return S.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-80 flex items-center justify-center z-50",children:S.jsxs("div",{className:"bg-gray-850 p-6 rounded-lg shadow-2xl w-full max-w-7xl h-[90vh] flex flex-col border border-gray-700",children:[S.jsxs("div",{className:"flex justify-between items-center mb-4 flex-shrink-0",children:[S.jsxs("div",{className:"flex items-center gap-4",children:[S.jsx("h2",{className:"text-2xl font-bold text-indigo-400",children:"Advanced AI Edit & Test"}),u&&S.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-cyan-400 hover:underline",children:"View Workflow Run"})]}),y&&S.jsx("button",{onClick:g,className:"px-4 py-2 bg-gray-600 text-white font-semibold rounded-md hover:bg-gray-700",children:"Close"})]}),S.jsxs("div",{className:"mb-4 flex-shrink-0 space-y-3",children:[S.jsxs("div",{className:"grid grid-cols-5 items-center justify-around p-2 bg-gray-900 rounded-md text-sm",children:[S.jsx(Go,{title:"1. Plan",isActive:t==="analyzing"||t==="planning",isComplete:!["idle","analyzing","planning"].includes(t)}),S.jsx("div",{className:"flex-grow h-px bg-gray-700 mx-2"}),S.jsx(Go,{title:"2. Edit",isActive:t==="editing",isComplete:!["idle","analyzing","planning","editing"].includes(t)}),S.jsx("div",{className:"flex-grow h-px bg-gray-700 mx-2"}),S.jsx(Go,{title:"3. Commit",isActive:t==="committing",isComplete:!["idle","analyzing","planning","editing","committing"].includes(t)}),S.jsx("div",{className:"flex-grow h-px bg-gray-700 mx-2"}),S.jsx(Go,{title:"4. Verify (CI)",isActive:t==="triggering_workflow"||t==="waiting_for_workflow"||t==="analyzing_failure",isComplete:t==="complete"}),S.jsx("div",{className:"flex-grow h-px bg-gray-700 mx-2"}),S.jsx(Go,{title:"5. Done",isActive:!1,isComplete:t==="complete"})]}),S.jsxs("div",{className:"flex justify-between text-sm text-gray-300 mb-1",children:[S.jsx("span",{className:"flex items-center gap-2",children:E()}),S.jsx("span",{children:`${h} / ${i.length} files committed`})]}),S.jsx("div",{className:"w-full bg-gray-700 rounded-full h-2.5",children:S.jsx("div",{className:"bg-indigo-500 h-2.5 rounded-full transition-all duration-300 ease-in-out",style:{width:`${v}%`}})})]}),f&&S.jsxs("div",{className:"mb-4 p-4 bg-gray-900 rounded-md border border-gray-700",children:[S.jsxs("h3",{className:"text-lg font-semibold mb-2 text-indigo-300 flex items-center gap-2",children:[S.jsx(Fu,{className:"w-5 h-5"}),"AI Thought Process"]}),S.jsx("p",{className:"text-gray-300 text-sm whitespace-pre-wrap font-mono",children:f})]}),S.jsxs("div",{className:"grid grid-cols-2 gap-4 flex-grow min-h-0",children:[S.jsxs("div",{className:"bg-gray-900 rounded-md p-4 flex flex-col",children:[S.jsxs("h3",{className:"text-lg font-semibold mb-2 text-gray-200",children:["Affected Files (",i.length,")"]}),S.jsx("ul",{className:"space-y-1 overflow-y-auto",children:i.map(x=>S.jsxs("li",{className:"flex items-center justify-between text-sm p-1.5 bg-gray-800 rounded",children:[S.jsxs("div",{className:"flex items-center gap-3 overflow-hidden",children:[S.jsx(zA,{status:x.status}),S.jsx("span",{className:"truncate",title:x.path,children:x.path})]}),x.error&&S.jsx("span",{className:"text-yellow-400 text-xs truncate ml-2 cursor-pointer",title:x.error,children:x.error})]},x.id))})]}),S.jsx("div",{className:"bg-gray-900 rounded-md p-4 flex flex-col",children:y&&m?S.jsxs(S.Fragment,{children:[S.jsx("h3",{className:"text-lg font-semibold mb-2 text-green-400",children:"Live Deployment Preview"}),S.jsxs("div",{className:"bg-yellow-900 border border-yellow-700 text-yellow-200 p-3 rounded-md mb-4 text-sm",children:[S.jsx("p",{children:"GitHub Pages may prevent embedding. If the panel below is blank, please use the direct link."}),S.jsx("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"text-cyan-400 hover:underline font-semibold mt-2 inline-block",children:"Open Live Site in New Tab →"})]}),S.jsx("div",{className:"flex-grow bg-white rounded-md overflow-hidden border-4 border-gray-700",children:S.jsx("iframe",{src:m,title:"Live Deployment",className:"w-full h-full border-0",sandbox:"allow-scripts allow-same-origin"})})]}):t==="analyzing_failure"&&s?S.jsxs(S.Fragment,{children:[S.jsx("h3",{className:"text-lg font-semibold mb-2 text-red-400",children:"Build Failure Logs"}),S.jsx("div",{className:"bg-black rounded p-2 flex-grow overflow-y-auto",children:S.jsx("pre",{className:"text-xs text-gray-300 whitespace-pre-wrap break-words font-mono",children:S.jsx("code",{children:s})})})]}):S.jsxs(S.Fragment,{children:[S.jsx("h3",{className:"text-lg font-semibold mb-2 text-gray-200",children:"Live Code Generation"}),C?S.jsxs("div",{className:"flex-grow flex flex-col min-h-0 bg-gray-850 rounded-lg p-2",children:[S.jsxs("p",{className:"text-blue-300 font-mono text-xs mb-2 truncate",title:C.path,children:["Current focus: ",S.jsx("span",{className:"font-bold",children:C.path})]}),S.jsx("div",{className:"bg-gray-950 rounded p-2 flex-grow overflow-y-auto",children:S.jsx("pre",{className:"text-xs text-gray-300 whitespace-pre-wrap break-words",children:S.jsx("code",{children:C.content})})})]}):S.jsx("div",{className:"flex items-center justify-center h-full text-gray-500",children:S.jsx("p",{children:"Waiting for plan..."})})]})})]})]})})},kA=({onClose:i,onSubmit:t})=>{const[o,s]=B.useState(""),[u,f]=B.useState(!1),m=async g=>{g.preventDefault(),!(!o.trim()||u)&&(f(!0),await t(o))};return S.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-70 flex items-center justify-center z-50",onClick:i,children:S.jsxs("div",{className:"bg-gray-850 p-6 rounded-lg shadow-2xl w-full max-w-2xl border border-gray-700",onClick:g=>g.stopPropagation(),children:[S.jsx("h2",{className:"text-xl font-bold text-cyan-400 mb-4",children:"Simple AI Edit"}),S.jsx("p",{className:"text-gray-400 mb-6 text-sm",children:"Describe how you want to change the current file. The AI will rewrite the file's content directly in the editor. This edit is not automatically committed."}),S.jsxs("form",{onSubmit:m,children:[S.jsxs("div",{className:"mb-4",children:[S.jsx("label",{htmlFor:"instruction-simple",className:"block text-sm font-medium text-gray-300 mb-2",children:"Instruction"}),S.jsx("textarea",{id:"instruction-simple",value:o,onChange:g=>s(g.target.value),placeholder:"e.g., 'Convert this to an async function and add a try/catch block.'",className:"w-full h-32 bg-gray-900 p-3 rounded-md text-sm border border-gray-600 focus:outline-none focus:ring-2 focus:ring-cyan-500 resize-none",autoFocus:!0})]}),S.jsxs("div",{className:"flex justify-end gap-4 mt-6",children:[S.jsx("button",{type:"button",onClick:i,className:"px-4 py-2 bg-gray-600 text-white font-semibold rounded-md hover:bg-gray-700 disabled:opacity-50",disabled:u,children:"Cancel"}),S.jsx("button",{type:"submit",disabled:u||!o.trim(),className:"px-6 py-2 bg-cyan-600 text-white font-semibold rounded-md hover:bg-cyan-700 disabled:bg-gray-500 disabled:cursor-not-allowed transition-colors flex items-center justify-center min-w-[120px]",children:u?S.jsx(ot,{}):"Rewrite Code"})]})]})]})})},sa=i=>{let t=[];for(const o of i)o.type==="file"?t.push(o.path):o.type==="dir"&&(t=t.concat(sa(o.children)));return t};function BA(){const[i,t]=B.useState(null),[o,s]=B.useState({}),[u,f]=B.useState([]),[m,g]=B.useState(null),[y,h]=B.useState(!1),[v,E]=B.useState(""),[C,x]=B.useState(null),[P,q]=B.useState({}),[V,Y]=B.useState({}),[j,k]=B.useState(!1),[Z,ae]=B.useState(new Set),[se,K]=B.useState(!1),[Ae,ee]=B.useState([]),[Ee,be]=B.useState(!1),[Te,ut]=B.useState(!1),[yt,ct]=B.useState([]),[w,F]=B.useState(""),[ce,He]=B.useState(!1),[Ke,R]=B.useState(!1),[z,O]=B.useState([]),[te,de]=B.useState("idle"),[Ce,Ue]=B.useState(!1),[xt,lt]=B.useState(!1),[Kn,mn]=B.useState([]),[Ji,Zt]=B.useState("idle"),[_n,Ki]=B.useState(0),[kl,Po]=B.useState(null),[zo,Xi]=B.useState(null),[Bl,An]=B.useState(null),[pa,Vo]=B.useState(null),[Dt,Fl]=B.useState(!1),me=u.find(J=>J.repoFullName+"::"+J.path===m),qt=me?V[me.repoFullName]:null,Xn=me?P[me.repoFullName]||[]:[],ma=B.useCallback(async J=>{if(J){t(J),h(!0),E("Fetching repositories...");try{const W=await G0(J),ne={},X=W.map(async Q=>{E(`Processing ${Q.owner.login}/${Q.name}...`);try{ne[Q.full_name]={repo:Q,tree:[]};const le=await js(J,Q.owner.login,Q.name,Q.default_branch);ne[Q.full_name].tree=le}catch(le){console.error(`Failed to fetch tree for ${Q.full_name}`,le)}});await Promise.all(X),s(ne),je("success","Successfully loaded all repositories.")}catch(W){console.error(W),t(null),je("error",`Login failed. ${W instanceof Error?W.message:"Please check your token and permissions."}`)}finally{h(!1),E("")}}},[]),je=(J,W)=>{x({type:J,message:W})},Ol=B.useCallback(async(J,W,ne)=>{var Q;const X=`${J}::${W}`;if(u.some(le=>le.repoFullName+"::"+le.path===X)){g(X);return}if(i){h(!0),E(`Loading ${W}...`);try{const[le,qe]=J.split("/"),ge=(Q=o[J])==null?void 0:Q.repo;if(!ge)throw new Error("Repository data not found");if(!P[J]){E("Fetching branches...");const Be=await Xp(i,le,qe);q(_e=>({..._e,[J]:Be}))}const Pe=ne||V[J]||ge.default_branch;Y(Be=>({...Be,[J]:Pe})),E(`Loading ${W} from branch ${Pe}...`);const pe=await Fn(i,le,qe,W,Pe),Ge={repoFullName:J,path:pe.path,content:pe.content,editedContent:pe.content,sha:pe.sha,defaultBranch:ge.default_branch};f(Be=>[...Be,Ge]),g(X)}catch(le){console.error(le),je("error",`Failed to load file: ${W}`)}finally{h(!1),E("")}}},[i,o,u,P,V]),ha=B.useCallback(J=>{const W=u.findIndex(X=>X.repoFullName+"::"+X.path===J);if(W===-1)return;const ne=u.filter(X=>X.repoFullName+"::"+X.path!==J);if(f(ne),m===J)if(ne.length===0)g(null);else{const X=Math.max(0,W-1),Q=ne[X];g(Q.repoFullName+"::"+Q.path)}},[u,m]),Ai=B.useCallback(J=>{g(J)},[]),vt=B.useCallback((J,W)=>{f(ne=>ne.map(X=>X.repoFullName+"::"+X.path===J?{...X,editedContent:W}:X))},[]),hn=B.useCallback(async J=>{if(!(!i||!me||!qt)){h(!0),E("Committing changes...");try{const[W,ne]=me.repoFullName.split("/");await Dl({token:i,owner:W,repo:ne,branch:qt,path:me.path,content:me.editedContent,message:J,sha:me.sha});const X=await Fn(i,W,ne,me.path,qt);f(Q=>Q.map(le=>le.repoFullName+"::"+le.path===m?{...le,content:X.content,editedContent:X.content,sha:X.sha}:le)),je("success","Commit successful!")}catch(W){console.error(W),je("error",`Failed to commit changes: ${W.message}`)}finally{h(!1),E("")}}},[i,me,qt,m]),Ut=B.useCallback(J=>{if(me){const W=me.repoFullName;Y(Q=>({...Q,[W]:J}));const ne=u.filter(Q=>Q.repoFullName===W),X=u.filter(Q=>Q.repoFullName!==W);f(X),g(X[0]?X[0].repoFullName+"::"+X[0].path:null),ne.forEach(Q=>{Ol(Q.repoFullName,Q.path,J)})}},[me,u,Ol]),ga=B.useCallback(async J=>{if(!(!i||!me||!qt)){h(!0),E(`Creating branch ${J}...`);try{const[W,ne]=me.repoFullName.split("/"),X=Xn.find(le=>le.name===qt);if(!X)throw new Error("Base branch not found");await P0(i,W,ne,J,X.commit.sha);const Q=await Xp(i,W,ne);q(le=>({...le,[me.repoFullName]:Q})),Y(le=>({...le,[me.repoFullName]:J})),je("success",`Branch '${J}' created successfully.`)}catch(W){console.error(W),je("error",`Failed to create branch: ${W.message}`)}finally{h(!1),E("")}}},[i,me,qt,Xn]),ya=B.useCallback(async(J,W)=>{if(!(!i||!me||!qt)){h(!0),E("Creating pull request...");try{const[ne,X]=me.repoFullName.split("/"),Q=await k0({token:i,owner:ne,repo:X,title:J,body:W,head:qt,base:me.defaultBranch});je("success",`Successfully created Pull Request #${Q.number}!`),window.open(Q.html_url,"_blank")}catch(ne){console.error(ne),je("error",`Failed to create pull request: ${ne.message}`)}finally{h(!1),E("")}}},[i,me,qt]),va=B.useCallback((J,W)=>{ae(ne=>{const X=new Set(ne);return W?X.add(J):X.delete(J),X})},[]),Qi=B.useCallback((J,W,ne)=>{const X=sa(J);ae(Q=>{const le=new Set(Q);for(const qe of X){const ge=`${W}::${qe}`;ne?le.add(ge):le.delete(ge)}return le})},[]),Qn=async(J,W,ne,X)=>{const Q=[...J],le=Ci.length,qe=async Pe=>{const pe=Ci[Pe],Ge=[pe,...Ci.filter(Be=>Be!==pe),...Eh];for(;;){const Be=Q.shift();if(!Be)break;(async()=>{let _e=0;for(;;){const Xe=Ge[_e%Ge.length];try{const mt=_e===0?X.processing:X.retrying;ne(he=>he.map(fe=>fe.id===Be.id?{...fe,status:mt,error:`Attempt ${_e+1} with ${Xe.split("/").pop()}`}:fe)),await W(Be,Xe);break}catch(mt){console.error(`Attempt ${_e+1} for job ${Be.id} with model ${Xe} failed. Retrying...`,mt),_e++,await new Promise(he=>setTimeout(he,2e3))}}})(),await new Promise(_e=>setTimeout(_e,3e3))}},ge=[];for(let Pe=0;Pe{if(!i||Z.size===0)return;k(!1);const ne=[...Z].map(Q=>{const[le,qe]=Q.split("::");return{id:Q,repoFullName:le,path:qe,status:"queued",content:"",error:null}});ee(ne),K(!0),ae(new Set),await Qn(ne,async(Q,le)=>{var Be;if(!i)throw new Error("Token not available");const{repoFullName:qe,path:ge}=Q,[Pe,pe]=qe.split("/"),Ge=(Be=o[qe])==null?void 0:Be.repo;if(!Ge){ee(_e=>_e.map(Xe=>Xe.id===Q.id?{...Xe,status:"failed",error:"Repo data not found"}:Xe));return}try{const _e=V[qe]||Ge.default_branch,Xe=await Fn(i,Pe,pe,ge,_e);let mt="";const he=Oe=>{mt+=Oe,ee(xe=>xe.map(Ze=>Ze.id===Q.id?{...Ze,content:mt}:Ze))};await Ch(Xe.content,J,ge,he,()=>mt,le);const fe=Ul(mt);if(fe.trim()===Xe.content.trim()||fe.trim()===""){ee(Oe=>Oe.map(xe=>xe.id===Q.id?{...xe,status:"skipped"}:xe));return}await Dl({token:i,owner:Pe,repo:pe,branch:_e,path:ge,content:fe,message:`[AI] Edit: ${ge}`,sha:Xe.sha}),ee(Oe=>Oe.map(xe=>xe.id===Q.id?{...xe,status:"success"}:xe));const Qe=`${qe}::${ge}`;if(u.some(Oe=>Oe.repoFullName+"::"+Oe.path===Qe)){const Oe=await Fn(i,Pe,pe,ge,_e);f(xe=>xe.map(Ze=>Ze.repoFullName+"::"+Ze.path===Qe?{...Ze,content:Oe.content,editedContent:Oe.content,sha:Oe.sha}:Ze))}}catch(_e){const Xe=_e instanceof Error?_e.message:"An unknown error occurred.";throw ee(mt=>mt.map(he=>he.id===Q.id?{...he,status:"failed",error:Xe}:he)),_e}},ee,{processing:"processing",retrying:"retrying",failed:"failed"}),je("success","Multi-file edit process completed.")},[i,Z,o,V,u]),gn=B.useCallback(async J=>{if(i)try{const W=await js(i,J.owner.login,J.name,J.default_branch);s(ne=>({...ne,[J.full_name]:{repo:J,tree:W}}))}catch(W){console.error(`Failed to refresh tree for new repo ${J.full_name}`,W),je("error","Project generated, but failed to refresh file explorer.")}},[i]),$i=B.useCallback(async(J,W,ne)=>{if(i){be(!1),ut(!0),ct([]);try{F(`Creating repository '${J}'...`);const X=await z0({token:i,name:J,description:W,isPrivate:ne});je("success",`Repository '${X.full_name}' created.`),F("Asking AI to plan project structure...");const le=(await CA(W,Ci[0])).files.map(ge=>({id:ge.path,path:ge.path,description:ge.description,status:"queued",content:"",error:null}));ct(le),F(`Generating ${le.length} files...`),await Qn(le,async(ge,Pe)=>{if(!i||!X)throw new Error("Token or repo not available");try{let pe="";const Ge=_e=>{pe+=_e,ct(Xe=>Xe.map(mt=>mt.id===ge.id?{...mt,content:pe}:mt))};await _h(W,ge.path,ge.description,Ge,()=>pe,Pe);const Be=Ul(pe);ct(_e=>_e.map(Xe=>Xe.id===ge.id?{...Xe,status:"committing"}:Xe)),await Dl({token:i,owner:X.owner.login,repo:X.name,branch:X.default_branch,path:ge.path,content:Be,message:`[AI] Create ${ge.path}`}),ct(_e=>_e.map(Xe=>Xe.id===ge.id?{...Xe,status:"success"}:Xe))}catch(pe){const Ge=pe instanceof Error?pe.message:"An unknown error occurred.";throw ct(Be=>Be.map(_e=>_e.id===ge.id?{..._e,status:"failed",error:Ge}:_e)),pe}},ct,{processing:"generating",retrying:"retrying",failed:"failed"}),F("Finalizing..."),await gn(X),je("success",`Project '${X.full_name}' generated successfully!`)}catch(X){const Q=X instanceof Error?X.message:"An unknown error occurred.";je("error",`Project generation failed: ${Q}`),ut(!1)}}},[i,gn]),xi=B.useCallback(()=>{if(Z.size!==1){je("error","Please select exactly 1 seed file to expand the project.");return}if(new Set([...Z].map(W=>W.split("::")[0])).size>1){je("error","All selected files must be from the same repository.");return}He(!0)},[Z]),Ta=B.useCallback(async J=>{var qe;if(!i)return;He(!1),R(!0),de("planning"),O([]);const W=[...Z],ne=W[0].split("::")[0],[X,Q]=ne.split("/"),le=(qe=o[ne])==null?void 0:qe.repo;if(!le){je("error","Could not find repository data for selection."),R(!1);return}try{de("planning");const ge=V[ne]||le.default_branch,Pe=await Promise.all(W.map(async he=>{const fe=he.split("::")[1],Qe=await Fn(i,X,Q,fe,ge);return{path:fe,content:Qe.content}})),pe=await _A(Pe,J,Ci[0]);if((!pe.filesToEdit||pe.filesToEdit.length===0)&&(!pe.filesToCreate||pe.filesToCreate.length===0))throw new Error("The AI failed to produce a valid expansion plan.");const Ge=(pe.filesToEdit||[]).map((he,fe)=>({id:`edit::${he.path}`,path:he.path,type:"edit",description:he.changes,agentIndex:fe%Ci.length,status:"queued",content:"",error:null})),Be=(pe.filesToCreate||[]).map(he=>({id:`create::${he.path}`,path:he.path,type:"create",description:he.description,agentIndex:he.agentIndex,status:"queued",content:"",error:null})),_e=[...Ge,...Be];if(_e.length===0){je("success","AI determined no changes were needed for this expansion."),R(!1);return}O(_e),de("generating"),await Qn(_e,async(he,fe)=>{if(!i)throw new Error("Token not available");try{if(he.type==="edit"){const Qe=await Fn(i,X,Q,he.path,ge);let Fe="";const Oe=Ze=>{Fe+=Ze,O(Ye=>Ye.map(Zn=>Zn.id===he.id?{...Zn,content:Fe}:Zn))};await Ch(Qe.content,he.description,he.path,Oe,()=>Fe,fe);const xe=Ul(Fe);xe.trim()&&xe.trim()!==Qe.content.trim()&&(O(Ze=>Ze.map(Ye=>Ye.id===he.id?{...Ye,status:"committing"}:Ye)),await Dl({token:i,owner:X,repo:Q,branch:ge,path:he.path,content:xe,message:`[AI Expansion] Modify ${he.path}`,sha:Qe.sha}))}else{let Qe="";const Fe=xe=>{Qe+=xe,O(Ze=>Ze.map(Ye=>Ye.id===he.id?{...Ye,content:Qe}:Ye))};await _h(J,he.path,he.description,Fe,()=>Qe,fe);const Oe=Ul(Qe);O(xe=>xe.map(Ze=>Ze.id===he.id?{...Ze,status:"committing"}:Ze)),await Dl({token:i,owner:X,repo:Q,branch:ge,path:he.path,content:Oe,message:`[AI Expansion] Create ${he.path}`})}O(Qe=>Qe.map(Fe=>Fe.id===he.id?{...Fe,status:"success"}:Fe))}catch(Qe){const Fe=Qe instanceof Error?Qe.message:"An unknown error occurred.";throw O(Oe=>Oe.map(xe=>xe.id===he.id?{...xe,status:"failed",error:Fe}:xe)),Qe}},O,{processing:"generating",retrying:"retrying",failed:"failed"}),de("complete"),je("success","Project expansion complete! Refreshing file tree...");const mt=await js(i,X,Q,ge);s(he=>({...he,[ne]:{...he[ne],tree:mt}}))}catch(ge){const Pe=ge instanceof Error?ge.message:"An unknown error occurred.";je("error",`Project expansion failed: ${Pe}`),de("idle"),R(!1)}},[i,Z,o,V]),ko=B.useCallback(async J=>{if(!i||!me)return;const W=me.editedContent;Fl(!1);const ne=me.repoFullName+"::"+me.path;vt(ne,"");let X="";const Q=le=>{X+=le,vt(ne,X)};try{await AA(W,J,me.path,Q,Ci[0]);const le=X,qe=Ul(le);le!==qe&&vt(ne,qe)}catch(le){const qe=le instanceof Error?le.message:"An unknown error occurred.";je("error",`Simple AI edit failed: ${qe}`),vt(ne,W)}},[i,me,vt]),Ni=async J=>{const W=[...Ci,...Eh];let ne=null;for(const X of W)try{return await J(X)}catch(Q){console.warn(`Action failed with model ${X}, trying next...`,Q),ne=Q}throw ne||new Error("All models failed to execute the action.")},Ri=B.useCallback(async(J,W)=>{if(!(!i||!me)){Ue(!1),lt(!0),mn([]),Zt("analyzing"),Ki(0),Po(null),Xi(null),An(null),Vo(null);try{const{repoFullName:ne}=me,X=o[ne];if(!X)throw new Error("Repo data not found");const[Q,le]=ne.split("/"),qe=V[ne]||X.repo.default_branch,ge=sa(X.tree),Pe=await Promise.all(ge.map(async fe=>{const Qe=await Fn(i,Q,le,fe,qe);return{path:fe,content:Qe.content,sha:Qe.sha}}));Zt("planning"),An("Analyzing repository and forming a plan...");const pe=await Ni(fe=>xA(J,me.path,Pe,fe));An(pe.reasoning);let Ge=pe.filesToEdit;if(Ge.length===0){je("success","AI determined no changes were needed."),lt(!1);return}const Be=new Map(Pe.map(fe=>[fe.path,fe.sha])),_e=new Map(Pe.map(fe=>[fe.path,fe.content])),Xe=5;for(let fe=0;fe({id:Le.path,path:Le.path,status:"editing",content:"",error:fe>0?`Correction attempt #${fe}`:null}));mn(Qe);const Fe=new Map;for(const Le of Ge){const un=_e.get(Le.path);if(un===void 0)throw new Error(`Could not find original content for file: ${Le.path}`);let $n="";const Wi=Mi=>{$n+=Mi,mn(vn=>vn.map(Wn=>Wn.path===Le.path?{...Wn,content:$n}:Wn))};await Ni(Mi=>NA(un,Le.changes,Le.path,Wi,Mi)),Fe.set(Le.path,Ul($n))}Zt("committing");for(const[Le,un]of Fe.entries()){mn(Mi=>Mi.map(vn=>vn.path===Le?{...vn,status:"committing"}:vn));const $n=Be.get(Le),Wi=await Dl({token:i,owner:Q,repo:le,branch:qe,path:Le,content:un,message:`[AI Attempt ${fe+1}] ${J}`,sha:$n});Be.set(Le,Wi)}Zt("triggering_workflow"),await F0(i,Q,le,W,qe),await new Promise(Le=>setTimeout(Le,5e3)),Zt("waiting_for_workflow");const Oe=await O0(i,Q,le,W,qe);if(Oe.workflow_runs.length===0)throw new Error("Could not find workflow run after triggering. Check GitHub Actions tab.");const xe=Oe.workflow_runs[0].id;Xi(Oe.workflow_runs[0].html_url);let Ze=null;for(;Ze=await Y0(i,Q,le,xe),Ze.status!=="completed";)await new Promise(Le=>setTimeout(Le,1e4));if(Ze.conclusion==="success"){je("success",`AI changes verified by CI after ${fe+1} attempt(s).`);const Le=`https://${Q}.github.io/${le}/`;Vo(Le);break}Zt("analyzing_failure"),An("Build failed. Analyzing logs to find the root cause and formulate a fix...");const Ye=await J0(i,Q,le,xe);Po(Ye);const Zn=await Promise.all(ge.map(async Le=>{const un=await Fn(i,Q,le,Le,qe);return{path:Le,content:un.content,sha:un.sha}})),Bo=Array.from(Fe.entries()).map(([Le,un])=>({path:Le,newContent:un})),yn=await Ni(Le=>RA(J,Zn,Bo,Ye,Le));if(An(yn.reasoning),Ge=yn.filesToEdit,fe===Xe-1)throw new Error("AI failed to produce a valid fix after multiple attempts.")}Zt("complete"),je("success","Advanced AI edit completed and verified by CI!");const mt=Kn.map(fe=>({...fe,status:"success"}));mn(mt);const he=await js(i,Q,le,qe);s(fe=>({...fe,[ne]:{...fe[ne],tree:he}}));for(const fe of mt)if(u.some(Fe=>Fe.repoFullName+"::"+Fe.path==`${ne}::${fe.path}`)){const Fe=await Fn(i,Q,le,fe.path,qe);f(Oe=>Oe.map(xe=>xe.repoFullName+"::"+xe.path==`${ne}::${fe.path}`?{...xe,content:Fe.content,editedContent:Fe.content,sha:Fe.sha}:xe))}}catch(ne){const X=ne instanceof Error?ne.message:"An unknown error occurred.";je("error",`Advanced AI edit failed: ${X}`),Zt("idle"),lt(!1)}}},[i,me,o,V,u]);return S.jsxs("div",{className:"flex h-screen font-sans",children:[i?S.jsxs(S.Fragment,{children:[S.jsx("aside",{className:"w-1/4 max-w-sm min-w-[300px] bg-gray-900 overflow-y-auto border-r border-gray-700 h-full",children:S.jsx(b0,{fileTree:o,onFileSelect:Ol,onStartMultiEdit:()=>k(!0),onStartNewProject:()=>be(!0),onStartProjectExpansion:xi,selectedRepo:me==null?void 0:me.repoFullName,selectedFilePath:me==null?void 0:me.path,selectedFiles:Z,onFileSelection:va,onDirectorySelection:Qi})}),S.jsx("main",{className:"flex-grow h-full",children:S.jsx(L0,{openFiles:u,activeFile:me||null,onCommit:hn,onAdvancedAiEdit:()=>Ue(!0),onSimpleAiEditRequest:()=>Fl(!0),onFileContentChange:vt,onCloseFile:ha,onSetActiveFile:Ai,isLoading:y,branches:Xn,currentBranch:qt,onBranchChange:Ut,onCreateBranch:ga,onCreatePullRequest:ya})})]}):S.jsx(x0,{onSubmit:ma,isLoading:y}),y&&!se&&S.jsxs("div",{className:"fixed top-5 left-1/2 -translate-x-1/2 bg-gray-800 text-white px-6 py-3 rounded-lg shadow-lg z-50 flex items-center gap-4 animate-fade-in-down",children:[S.jsx("style",{children:` + @keyframes fade-in-down { + 0% { + opacity: 0; + transform: translate(-50%, -20px); + } + 100% { + opacity: 1; + transform: translate(-50%, 0); + } + } + .animate-fade-in-down { + animation: fade-in-down 0.5s ease-out forwards; + } + `}),S.jsx(ot,{}),S.jsx("p",{children:v})]}),C&&S.jsx(MA,{alert:C,onClose:()=>x(null)}),Ee&&S.jsx(DA,{onClose:()=>be(!1),onSubmit:$i}),ce&&S.jsx(qA,{onClose:()=>He(!1),onSubmit:Ta}),Ce&&me&&S.jsx(PA,{onClose:()=>Ue(!1),onSubmit:Ri,token:i,repoFullName:me.repoFullName}),Dt&&me&&S.jsx(kA,{onClose:()=>Fl(!1),onSubmit:ko}),j&&S.jsx(wA,{fileCount:Z.size,onClose:()=>k(!1),onSubmit:Zi}),se&&S.jsx(IA,{jobs:Ae,onClose:()=>K(!1),isComplete:!Ae.some(J=>J.status==="processing"||J.status==="queued"||J.status==="retrying")}),Te&&S.jsx(LA,{jobs:yt,statusMessage:w,onClose:()=>ut(!1),isComplete:yt.length>0&&!yt.some(J=>["generating","queued","committing","retrying"].includes(J.status))}),Ke&&S.jsx(HA,{phase:te,jobs:z,onClose:()=>R(!1),isComplete:te==="complete"}),xt&&S.jsx(VA,{phase:Ji,jobs:Kn,verificationAttempt:_n,buildLogs:kl,workflowRunUrl:zo,aiThought:Bl,deploymentUrl:pa,onClose:()=>lt(!1),isComplete:Ji==="complete"})]})}const og=document.getElementById("root");if(!og)throw new Error("Could not find root element to mount to");const FA=A0.createRoot(og);FA.render(S.jsx(g0.StrictMode,{children:S.jsx(BA,{})}));