diff --git "a/assets/index-DxeF4e-j.js" "b/assets/index-DxeF4e-j.js" new file mode 100644--- /dev/null +++ "b/assets/index-DxeF4e-j.js" @@ -0,0 +1,270 @@ +(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const d of r)if(d.type==="childList")for(const p of d.addedNodes)p.tagName==="LINK"&&p.rel==="modulepreload"&&s(p)}).observe(document,{childList:!0,subtree:!0});function o(r){const d={};return r.integrity&&(d.integrity=r.integrity),r.referrerPolicy&&(d.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?d.credentials="include":r.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function s(r){if(r.ep)return;r.ep=!0;const d=o(r);fetch(r.href,d)}})();function eh(l){return l&&l.__esModule&&Object.prototype.hasOwnProperty.call(l,"default")?l.default:l}var tr={exports:{}},co={};/** + * @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 xm;function Jy(){if(xm)return co;xm=1;var l=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function o(s,r,d){var p=null;if(d!==void 0&&(p=""+d),r.key!==void 0&&(p=""+r.key),"key"in r){d={};for(var g in r)g!=="key"&&(d[g]=r[g])}else d=r;return r=d.ref,{$$typeof:l,type:s,key:p,ref:r!==void 0?r:null,props:d}}return co.Fragment=n,co.jsx=o,co.jsxs=o,co}var Mm;function Oy(){return Mm||(Mm=1,tr.exports=Jy()),tr.exports}var C=Oy(),nr={exports:{}},fe={};/** + * @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 Nm;function Fy(){if(Nm)return fe;Nm=1;var l=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),d=Symbol.for("react.consumer"),p=Symbol.for("react.context"),g=Symbol.for("react.forward_ref"),y=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),T=Symbol.for("react.lazy"),S=Symbol.for("react.activity"),_=Symbol.iterator;function R(M){return M===null||typeof M!="object"?null:(M=_&&M[_]||M["@@iterator"],typeof M=="function"?M:null)}var H={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},V=Object.assign,Y={};function J(M,q,O){this.props=M,this.context=q,this.refs=Y,this.updater=O||H}J.prototype.isReactComponent={},J.prototype.setState=function(M,q){if(typeof M!="object"&&typeof M!="function"&&M!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,M,q,"setState")},J.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function X(){}X.prototype=J.prototype;function P(M,q,O){this.props=M,this.context=q,this.refs=Y,this.updater=O||H}var K=P.prototype=new X;K.constructor=P,V(K,J.prototype),K.isPureReactComponent=!0;var te=Array.isArray;function le(){}var F={H:null,A:null,T:null,S:null},ve=Object.prototype.hasOwnProperty;function $(M,q,O){var Q=O.ref;return{$$typeof:l,type:M,key:q,ref:Q!==void 0?Q:null,props:O}}function Te(M,q){return $(M.type,q,M.props)}function Me(M){return typeof M=="object"&&M!==null&&M.$$typeof===l}function pe(M){var q={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(O){return q[O]})}var Ke=/\/+/g;function st(M,q){return typeof M=="object"&&M!==null&&M.key!=null?pe(""+M.key):q.toString(36)}function Oe(M){switch(M.status){case"fulfilled":return M.value;case"rejected":throw M.reason;default:switch(typeof M.status=="string"?M.then(le,le):(M.status="pending",M.then(function(q){M.status==="pending"&&(M.status="fulfilled",M.value=q)},function(q){M.status==="pending"&&(M.status="rejected",M.reason=q)})),M.status){case"fulfilled":return M.value;case"rejected":throw M.reason}}throw M}function I(M,q,O,Q,ce){var ye=typeof M;(ye==="undefined"||ye==="boolean")&&(M=null);var Ne=!1;if(M===null)Ne=!0;else switch(ye){case"bigint":case"string":case"number":Ne=!0;break;case"object":switch(M.$$typeof){case l:case n:Ne=!0;break;case T:return Ne=M._init,I(Ne(M._payload),q,O,Q,ce)}}if(Ne)return ce=ce(M),Ne=Q===""?"."+st(M,0):Q,te(ce)?(O="",Ne!=null&&(O=Ne.replace(Ke,"$&/")+"/"),I(ce,q,O,"",function(ll){return ll})):ce!=null&&(Me(ce)&&(ce=Te(ce,O+(ce.key==null||M&&M.key===ce.key?"":(""+ce.key).replace(Ke,"$&/")+"/")+Ne)),q.push(ce)),1;Ne=0;var ct=Q===""?".":Q+":";if(te(M))for(var Qe=0;Qe>>1,Se=I[re];if(0>>1;rer(O,B))Qr(ce,O)?(I[re]=ce,I[Q]=B,re=Q):(I[re]=O,I[q]=B,re=q);else if(Qr(ce,B))I[re]=ce,I[Q]=B,re=Q;else break e}}return k}function r(I,k){var B=I.sortIndex-k.sortIndex;return B!==0?B:I.id-k.id}if(l.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var d=performance;l.unstable_now=function(){return d.now()}}else{var p=Date,g=p.now();l.unstable_now=function(){return p.now()-g}}var y=[],h=[],T=1,S=null,_=3,R=!1,H=!1,V=!1,Y=!1,J=typeof setTimeout=="function"?setTimeout:null,X=typeof clearTimeout=="function"?clearTimeout:null,P=typeof setImmediate<"u"?setImmediate:null;function K(I){for(var k=o(h);k!==null;){if(k.callback===null)s(h);else if(k.startTime<=I)s(h),k.sortIndex=k.expirationTime,n(y,k);else break;k=o(h)}}function te(I){if(V=!1,K(I),!H)if(o(y)!==null)H=!0,le||(le=!0,pe());else{var k=o(h);k!==null&&Oe(te,k.startTime-I)}}var le=!1,F=-1,ve=5,$=-1;function Te(){return Y?!0:!(l.unstable_now()-$I&&Te());){var re=S.callback;if(typeof re=="function"){S.callback=null,_=S.priorityLevel;var Se=re(S.expirationTime<=I);if(I=l.unstable_now(),typeof Se=="function"){S.callback=Se,K(I),k=!0;break t}S===o(y)&&s(y),K(I)}else s(y);S=o(y)}if(S!==null)k=!0;else{var M=o(h);M!==null&&Oe(te,M.startTime-I),k=!1}}break e}finally{S=null,_=B,R=!1}k=void 0}}finally{k?pe():le=!1}}}var pe;if(typeof P=="function")pe=function(){P(Me)};else if(typeof MessageChannel<"u"){var Ke=new MessageChannel,st=Ke.port2;Ke.port1.onmessage=Me,pe=function(){st.postMessage(null)}}else pe=function(){J(Me,0)};function Oe(I,k){F=J(function(){I(l.unstable_now())},k)}l.unstable_IdlePriority=5,l.unstable_ImmediatePriority=1,l.unstable_LowPriority=4,l.unstable_NormalPriority=3,l.unstable_Profiling=null,l.unstable_UserBlockingPriority=2,l.unstable_cancelCallback=function(I){I.callback=null},l.unstable_forceFrameRate=function(I){0>I||125re?(I.sortIndex=B,n(h,I),o(y)===null&&I===o(h)&&(V?(X(F),F=-1):V=!0,Oe(te,B-re))):(I.sortIndex=Se,n(y,I),H||R||(H=!0,le||(le=!0,pe()))),I},l.unstable_shouldYield=Te,l.unstable_wrapCallback=function(I){var k=_;return function(){var B=_;_=k;try{return I.apply(this,arguments)}finally{_=B}}}})(or)),or}var Dm;function Qy(){return Dm||(Dm=1,ir.exports=Ky()),ir.exports}var ar={exports:{}},Tt={};/** + * @license React + * react-dom.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var wm;function Zy(){if(wm)return Tt;wm=1;var l=vr();function n(y){var h="https://react.dev/errors/"+y;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(l)}catch(n){console.error(n)}}return l(),ar.exports=Zy(),ar.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 Im;function Wy(){if(Im)return fo;Im=1;var l=Qy(),n=vr(),o=$y();function s(e){var t="https://react.dev/errors/"+e;if(1Se||(e.current=re[Se],re[Se]=null,Se--)}function O(e,t){Se++,re[Se]=e.current,e.current=t}var Q=M(null),ce=M(null),ye=M(null),Ne=M(null);function ct(e,t){switch(O(ye,t),O(ce,e),O(Q,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Kd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Kd(t),e=Qd(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}q(Q),O(Q,e)}function Qe(){q(Q),q(ce),q(ye)}function ll(e){e.memoizedState!==null&&O(Ne,e);var t=Q.current,i=Qd(t,e.type);t!==i&&(O(ce,e),O(Q,i))}function Al(e){ce.current===e&&(q(Q),q(ce)),Ne.current===e&&(q(Ne),ao._currentValue=B)}var yi,go;function fn(e){if(yi===void 0)try{throw Error()}catch(i){var t=i.stack.trim().match(/\n( *(at )?)/);yi=t&&t[1]||"",go=-1)":-1f||A[a]!==D[f]){var L=` +`+A[a].replace(" at new "," at ");return e.displayName&&L.includes("")&&(L=L.replace("",e.displayName)),L}while(1<=a&&0<=f);break}}}finally{xl=!1,Error.prepareStackTrace=i}return(i=e?e.displayName||e.name:"")?fn(i):""}function Z(e,t){switch(e.tag){case 26:case 27:case 5:return fn(e.type);case 16:return fn("Lazy");case 13:return e.child!==t&&t!==null?fn("Suspense Fallback"):fn("Suspense");case 19:return fn("SuspenseList");case 0:case 15:return vi(e.type,!1);case 11:return vi(e.type.render,!1);case 1:return vi(e.type,!0);case 31:return fn("Activity");default:return""}}function ae(e){try{var t="",i=null;do t+=Z(e,i),i=e,e=e.return;while(e);return t}catch(a){return` +Error generating stack: `+a.message+` +`+a.stack}}var de=Object.prototype.hasOwnProperty,ie=l.unstable_scheduleCallback,ue=l.unstable_cancelCallback,ge=l.unstable_shouldYield,ln=l.unstable_requestPaint,Fe=l.unstable_now,Ze=l.unstable_getCurrentPriorityLevel,_t=l.unstable_ImmediatePriority,Pe=l.unstable_UserBlockingPriority,Be=l.unstable_NormalPriority,Ct=l.unstable_LowPriority,on=l.unstable_IdlePriority,an=l.log,At=l.unstable_setDisableYieldValue,Re=null,Ue=null;function ft(e){if(typeof an=="function"&&At(e),Ue&&typeof Ue.setStrictMode=="function")try{Ue.setStrictMode(Re,e)}catch{}}var ot=Math.clz32?Math.clz32:Nr,ka=Math.log,yo=Math.LN2;function Nr(e){return e>>>=0,e===0?32:31-(ka(e)/yo|0)|0}var dt=256,vt=262144,Ut=4194304;function il(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function vo(e,t,i){var a=e.pendingLanes;if(a===0)return 0;var f=0,m=e.suspendedLanes,v=e.pingedLanes;e=e.warmLanes;var E=a&134217727;return E!==0?(a=E&~m,a!==0?f=il(a):(v&=E,v!==0?f=il(v):i||(i=E&~e,i!==0&&(f=il(i))))):(E=a&~m,E!==0?f=il(E):v!==0?f=il(v):i||(i=a&~e,i!==0&&(f=il(i)))),f===0?0:t!==0&&t!==f&&(t&m)===0&&(m=f&-f,i=t&-t,m>=i||m===32&&(i&4194048)!==0)?t:f}function Ti(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function wh(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Rr(){var e=Ut;return Ut<<=1,(Ut&62914560)===0&&(Ut=4194304),e}function Ya(e){for(var t=[],i=0;31>i;i++)t.push(e);return t}function Si(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Uh(e,t,i,a,f,m){var v=e.pendingLanes;e.pendingLanes=i,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=i,e.entangledLanes&=i,e.errorRecoveryDisabledLanes&=i,e.shellSuspendCounter=0;var E=e.entanglements,A=e.expirationTimes,D=e.hiddenUpdates;for(i=v&~i;0"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var zh=/[\n"\\]/g;function kt(e){return e.replace(zh,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function Qa(e,t,i,a,f,m,v,E){e.name="",v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"?e.type=v:e.removeAttribute("type"),t!=null?v==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+Pt(t)):e.value!==""+Pt(t)&&(e.value=""+Pt(t)):v!=="submit"&&v!=="reset"||e.removeAttribute("value"),t!=null?Za(e,v,Pt(t)):i!=null?Za(e,v,Pt(i)):a!=null&&e.removeAttribute("value"),f==null&&m!=null&&(e.defaultChecked=!!m),f!=null&&(e.checked=f&&typeof f!="function"&&typeof f!="symbol"),E!=null&&typeof E!="function"&&typeof E!="symbol"&&typeof E!="boolean"?e.name=""+Pt(E):e.removeAttribute("name")}function Pr(e,t,i,a,f,m,v,E){if(m!=null&&typeof m!="function"&&typeof m!="symbol"&&typeof m!="boolean"&&(e.type=m),t!=null||i!=null){if(!(m!=="submit"&&m!=="reset"||t!=null)){Ka(e);return}i=i!=null?""+Pt(i):"",t=t!=null?""+Pt(t):i,E||t===e.value||(e.value=t),e.defaultValue=t}a=a??f,a=typeof a!="function"&&typeof a!="symbol"&&!!a,e.checked=E?e.checked:!!a,e.defaultChecked=!!a,v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"&&(e.name=v),Ka(e)}function Za(e,t,i){t==="number"&&Eo(e.ownerDocument)===e||e.defaultValue===""+i||(e.defaultValue=""+i)}function wl(e,t,i,a){if(e=e.options,t){t={};for(var f=0;f"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),ts=!1;if(pn)try{var Ai={};Object.defineProperty(Ai,"passive",{get:function(){ts=!0}}),window.addEventListener("test",Ai,Ai),window.removeEventListener("test",Ai,Ai)}catch{ts=!1}var Un=null,ns=null,Co=null;function Kr(){if(Co)return Co;var e,t=ns,i=t.length,a,f="value"in Un?Un.value:Un.textContent,m=f.length;for(e=0;e=Ni),ec=" ",tc=!1;function nc(e,t){switch(e){case"keyup":return dg.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function lc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Ll=!1;function pg(e,t){switch(e){case"compositionend":return lc(t);case"keypress":return t.which!==32?null:(tc=!0,ec);case"textInput":return e=t.data,e===ec&&tc?null:e;default:return null}}function hg(e,t){if(Ll)return e==="compositionend"||!ss&&nc(e,t)?(e=Kr(),Co=ns=Un=null,Ll=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:i,offset:t-e};e=a}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=fc(i)}}function mc(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?mc(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function pc(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Eo(e.document);t instanceof e.HTMLIFrameElement;){try{var i=typeof t.contentWindow.location.href=="string"}catch{i=!1}if(i)e=t.contentWindow;else break;t=Eo(e.document)}return t}function cs(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}var Cg=pn&&"documentMode"in document&&11>=document.documentMode,Gl=null,fs=null,wi=null,ds=!1;function hc(e,t,i){var a=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;ds||Gl==null||Gl!==Eo(a)||(a=Gl,"selectionStart"in a&&cs(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}),wi&&Di(wi,a)||(wi=a,a=ga(fs,"onSelect"),0>=v,f-=v,sn=1<<32-ot(t)+f|i<he?(Ae=ee,ee=null):Ae=ee.sibling;var De=w(N,ee,b[he],G);if(De===null){ee===null&&(ee=Ae);break}e&&ee&&De.alternate===null&&t(N,ee),x=m(De,x,he),be===null?oe=De:be.sibling=De,be=De,ee=Ae}if(he===b.length)return i(N,ee),xe&&gn(N,he),oe;if(ee===null){for(;hehe?(Ae=ee,ee=null):Ae=ee.sibling;var el=w(N,ee,De.value,G);if(el===null){ee===null&&(ee=Ae);break}e&&ee&&el.alternate===null&&t(N,ee),x=m(el,x,he),be===null?oe=el:be.sibling=el,be=el,ee=Ae}if(De.done)return i(N,ee),xe&&gn(N,he),oe;if(ee===null){for(;!De.done;he++,De=b.next())De=z(N,De.value,G),De!==null&&(x=m(De,x,he),be===null?oe=De:be.sibling=De,be=De);return xe&&gn(N,he),oe}for(ee=a(ee);!De.done;he++,De=b.next())De=U(ee,N,he,De.value,G),De!==null&&(e&&De.alternate!==null&&ee.delete(De.key===null?he:De.key),x=m(De,x,he),be===null?oe=De:be.sibling=De,be=De);return e&&ee.forEach(function(Yy){return t(N,Yy)}),xe&&gn(N,he),oe}function ze(N,x,b,G){if(typeof b=="object"&&b!==null&&b.type===V&&b.key===null&&(b=b.props.children),typeof b=="object"&&b!==null){switch(b.$$typeof){case R:e:{for(var oe=b.key;x!==null;){if(x.key===oe){if(oe=b.type,oe===V){if(x.tag===7){i(N,x.sibling),G=f(x,b.props.children),G.return=N,N=G;break e}}else if(x.elementType===oe||typeof oe=="object"&&oe!==null&&oe.$$typeof===ve&&hl(oe)===x.type){i(N,x.sibling),G=f(x,b.props),Hi(G,b),G.return=N,N=G;break e}i(N,x);break}else t(N,x);x=x.sibling}b.type===V?(G=cl(b.props.children,N.mode,G,b.key),G.return=N,N=G):(G=Io(b.type,b.key,b.props,null,N.mode,G),Hi(G,b),G.return=N,N=G)}return v(N);case H:e:{for(oe=b.key;x!==null;){if(x.key===oe)if(x.tag===4&&x.stateNode.containerInfo===b.containerInfo&&x.stateNode.implementation===b.implementation){i(N,x.sibling),G=f(x,b.children||[]),G.return=N,N=G;break e}else{i(N,x);break}else t(N,x);x=x.sibling}G=Ts(b,N.mode,G),G.return=N,N=G}return v(N);case ve:return b=hl(b),ze(N,x,b,G)}if(Oe(b))return W(N,x,b,G);if(pe(b)){if(oe=pe(b),typeof oe!="function")throw Error(s(150));return b=oe.call(b),se(N,x,b,G)}if(typeof b.then=="function")return ze(N,x,Bo(b),G);if(b.$$typeof===P)return ze(N,x,Go(N,b),G);Po(N,b)}return typeof b=="string"&&b!==""||typeof b=="number"||typeof b=="bigint"?(b=""+b,x!==null&&x.tag===6?(i(N,x.sibling),G=f(x,b),G.return=N,N=G):(i(N,x),G=vs(b,N.mode,G),G.return=N,N=G),v(N)):i(N,x)}return function(N,x,b,G){try{Gi=0;var oe=ze(N,x,b,G);return Xl=null,oe}catch(ee){if(ee===Fl||ee===zo)throw ee;var be=qt(29,ee,null,N.mode);return be.lanes=G,be.return=N,be}finally{}}}var yl=zc(!0),Vc=zc(!1),Hn=!1;function ws(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Us(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function zn(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Vn(e,t,i){var a=e.updateQueue;if(a===null)return null;if(a=a.shared,(Ie&2)!==0){var f=a.pending;return f===null?t.next=t:(t.next=f.next,f.next=t),a.pending=t,t=Uo(e),_c(e,null,i),t}return wo(e,a,t,i),Uo(e)}function zi(e,t,i){if(t=t.updateQueue,t!==null&&(t=t.shared,(i&4194048)!==0)){var a=t.lanes;a&=e.pendingLanes,i|=a,t.lanes=i,Dr(e,i)}}function Is(e,t){var i=e.updateQueue,a=e.alternate;if(a!==null&&(a=a.updateQueue,i===a)){var f=null,m=null;if(i=i.firstBaseUpdate,i!==null){do{var v={lane:i.lane,tag:i.tag,payload:i.payload,callback:null,next:null};m===null?f=m=v:m=m.next=v,i=i.next}while(i!==null);m===null?f=m=t:m=m.next=t}else f=m=t;i={baseState:a.baseState,firstBaseUpdate:f,lastBaseUpdate:m,shared:a.shared,callbacks:a.callbacks},e.updateQueue=i;return}e=i.lastBaseUpdate,e===null?i.firstBaseUpdate=t:e.next=t,i.lastBaseUpdate=t}var qs=!1;function Vi(){if(qs){var e=Ol;if(e!==null)throw e}}function Bi(e,t,i,a){qs=!1;var f=e.updateQueue;Hn=!1;var m=f.firstBaseUpdate,v=f.lastBaseUpdate,E=f.shared.pending;if(E!==null){f.shared.pending=null;var A=E,D=A.next;A.next=null,v===null?m=D:v.next=D,v=A;var L=e.alternate;L!==null&&(L=L.updateQueue,E=L.lastBaseUpdate,E!==v&&(E===null?L.firstBaseUpdate=D:E.next=D,L.lastBaseUpdate=A))}if(m!==null){var z=f.baseState;v=0,L=D=A=null,E=m;do{var w=E.lane&-536870913,U=w!==E.lane;if(U?(Ce&w)===w:(a&w)===w){w!==0&&w===Jl&&(qs=!0),L!==null&&(L=L.next={lane:0,tag:E.tag,payload:E.payload,callback:null,next:null});e:{var W=e,se=E;w=t;var ze=i;switch(se.tag){case 1:if(W=se.payload,typeof W=="function"){z=W.call(ze,z,w);break e}z=W;break e;case 3:W.flags=W.flags&-65537|128;case 0:if(W=se.payload,w=typeof W=="function"?W.call(ze,z,w):W,w==null)break e;z=S({},z,w);break e;case 2:Hn=!0}}w=E.callback,w!==null&&(e.flags|=64,U&&(e.flags|=8192),U=f.callbacks,U===null?f.callbacks=[w]:U.push(w))}else U={lane:w,tag:E.tag,payload:E.payload,callback:E.callback,next:null},L===null?(D=L=U,A=z):L=L.next=U,v|=w;if(E=E.next,E===null){if(E=f.shared.pending,E===null)break;U=E,E=U.next,U.next=null,f.lastBaseUpdate=U,f.shared.pending=null}}while(!0);L===null&&(A=z),f.baseState=A,f.firstBaseUpdate=D,f.lastBaseUpdate=L,m===null&&(f.shared.lanes=0),Jn|=v,e.lanes=v,e.memoizedState=z}}function Bc(e,t){if(typeof e!="function")throw Error(s(191,e));e.call(t)}function Pc(e,t){var i=e.callbacks;if(i!==null)for(e.callbacks=null,e=0;em?m:8;var v=I.T,E={};I.T=E,js(e,!1,t,i);try{var A=f(),D=I.S;if(D!==null&&D(E,A),A!==null&&typeof A=="object"&&typeof A.then=="function"){var L=Ug(A,a);Yi(e,t,L,Vt(e))}else Yi(e,t,a,Vt(e))}catch(z){Yi(e,t,{then:function(){},status:"rejected",reason:z},Vt())}finally{k.p=m,v!==null&&E.types!==null&&(v.types=E.types),I.T=v}}function zg(){}function $s(e,t,i,a){if(e.tag!==5)throw Error(s(476));var f=Sf(e).queue;Tf(e,f,t,B,i===null?zg:function(){return Ef(e),i(a)})}function Sf(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:B,baseState:B,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Sn,lastRenderedState:B},next:null};var i={};return t.next={memoizedState:i,baseState:i,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Sn,lastRenderedState:i},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Ef(e){var t=Sf(e);t.next===null&&(t=e.alternate.memoizedState),Yi(e,t.next.queue,{},Vt())}function Ws(){return ht(ao)}function _f(){return et().memoizedState}function Cf(){return et().memoizedState}function Vg(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var i=Vt();e=zn(i);var a=Vn(t,e,i);a!==null&&(wt(a,t,i),zi(a,t,i)),t={cache:Ns()},e.payload=t;return}t=t.return}}function Bg(e,t,i){var a=Vt();i={lane:a,revertLane:0,gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},$o(e)?xf(t,i):(i=gs(e,t,i,a),i!==null&&(wt(i,e,a),Mf(i,t,a)))}function Af(e,t,i){var a=Vt();Yi(e,t,i,a)}function Yi(e,t,i,a){var f={lane:a,revertLane:0,gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null};if($o(e))xf(t,f);else{var m=e.alternate;if(e.lanes===0&&(m===null||m.lanes===0)&&(m=t.lastRenderedReducer,m!==null))try{var v=t.lastRenderedState,E=m(v,i);if(f.hasEagerState=!0,f.eagerState=E,It(E,v))return wo(e,t,f,0),Ve===null&&Do(),!1}catch{}finally{}if(i=gs(e,t,f,a),i!==null)return wt(i,e,a),Mf(i,t,a),!0}return!1}function js(e,t,i,a){if(a={lane:2,revertLane:wu(),gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},$o(e)){if(t)throw Error(s(479))}else t=gs(e,i,a,2),t!==null&&wt(t,e,2)}function $o(e){var t=e.alternate;return e===me||t!==null&&t===me}function xf(e,t){Ql=Jo=!0;var i=e.pending;i===null?t.next=t:(t.next=i.next,i.next=t),e.pending=t}function Mf(e,t,i){if((i&4194048)!==0){var a=t.lanes;a&=e.pendingLanes,i|=a,t.lanes=i,Dr(e,i)}}var Ji={readContext:ht,use:Xo,useCallback:$e,useContext:$e,useEffect:$e,useImperativeHandle:$e,useLayoutEffect:$e,useInsertionEffect:$e,useMemo:$e,useReducer:$e,useRef:$e,useState:$e,useDebugValue:$e,useDeferredValue:$e,useTransition:$e,useSyncExternalStore:$e,useId:$e,useHostTransitionStatus:$e,useFormState:$e,useActionState:$e,useOptimistic:$e,useMemoCache:$e,useCacheRefresh:$e};Ji.useEffectEvent=$e;var Nf={readContext:ht,use:Xo,useCallback:function(e,t){return Et().memoizedState=[e,t===void 0?null:t],e},useContext:ht,useEffect:cf,useImperativeHandle:function(e,t,i){i=i!=null?i.concat([e]):null,Qo(4194308,4,pf.bind(null,t,e),i)},useLayoutEffect:function(e,t){return Qo(4194308,4,e,t)},useInsertionEffect:function(e,t){Qo(4,2,e,t)},useMemo:function(e,t){var i=Et();t=t===void 0?null:t;var a=e();if(vl){ft(!0);try{e()}finally{ft(!1)}}return i.memoizedState=[a,t],a},useReducer:function(e,t,i){var a=Et();if(i!==void 0){var f=i(t);if(vl){ft(!0);try{i(t)}finally{ft(!1)}}}else f=t;return a.memoizedState=a.baseState=f,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:f},a.queue=e,e=e.dispatch=Bg.bind(null,me,e),[a.memoizedState,e]},useRef:function(e){var t=Et();return e={current:e},t.memoizedState=e},useState:function(e){e=Fs(e);var t=e.queue,i=Af.bind(null,me,t);return t.dispatch=i,[e.memoizedState,i]},useDebugValue:Qs,useDeferredValue:function(e,t){var i=Et();return Zs(i,e,t)},useTransition:function(){var e=Fs(!1);return e=Tf.bind(null,me,e.queue,!0,!1),Et().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,i){var a=me,f=Et();if(xe){if(i===void 0)throw Error(s(407));i=i()}else{if(i=t(),Ve===null)throw Error(s(349));(Ce&127)!==0||Xc(a,t,i)}f.memoizedState=i;var m={value:i,getSnapshot:t};return f.queue=m,cf(Qc.bind(null,a,m,e),[e]),a.flags|=2048,$l(9,{destroy:void 0},Kc.bind(null,a,m,i,t),null),i},useId:function(){var e=Et(),t=Ve.identifierPrefix;if(xe){var i=un,a=sn;i=(a&~(1<<32-ot(a)-1)).toString(32)+i,t="_"+t+"R_"+i,i=Oo++,0<\/script>",m=m.removeChild(m.firstChild);break;case"select":m=typeof a.is=="string"?v.createElement("select",{is:a.is}):v.createElement("select"),a.multiple?m.multiple=!0:a.size&&(m.size=a.size);break;default:m=typeof a.is=="string"?v.createElement(f,{is:a.is}):v.createElement(f)}}m[mt]=t,m[xt]=a;e:for(v=t.child;v!==null;){if(v.tag===5||v.tag===6)m.appendChild(v.stateNode);else if(v.tag!==4&&v.tag!==27&&v.child!==null){v.child.return=v,v=v.child;continue}if(v===t)break e;for(;v.sibling===null;){if(v.return===null||v.return===t)break e;v=v.return}v.sibling.return=v.return,v=v.sibling}t.stateNode=m;e:switch(yt(m,f,a),f){case"button":case"input":case"select":case"textarea":a=!!a.autoFocus;break e;case"img":a=!0;break e;default:a=!1}a&&_n(t)}}return Ye(t),mu(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,i),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==a&&_n(t);else{if(typeof a!="string"&&t.stateNode===null)throw Error(s(166));if(e=ye.current,kl(t)){if(e=t.stateNode,i=t.memoizedProps,a=null,f=pt,f!==null)switch(f.tag){case 27:case 5:a=f.memoizedProps}e[mt]=t,e=!!(e.nodeValue===i||a!==null&&a.suppressHydrationWarning===!0||Fd(e.nodeValue,i)),e||Ln(t,!0)}else e=ya(e).createTextNode(a),e[mt]=t,t.stateNode=e}return Ye(t),null;case 31:if(i=t.memoizedState,e===null||e.memoizedState!==null){if(a=kl(t),i!==null){if(e===null){if(!a)throw Error(s(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(s(557));e[mt]=t}else fl(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Ye(t),e=!1}else i=Cs(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=i),e=!0;if(!e)return t.flags&256?(Gt(t),t):(Gt(t),null);if((t.flags&128)!==0)throw Error(s(558))}return Ye(t),null;case 13:if(a=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(f=kl(t),a!==null&&a.dehydrated!==null){if(e===null){if(!f)throw Error(s(318));if(f=t.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(s(317));f[mt]=t}else fl(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Ye(t),f=!1}else f=Cs(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=f),f=!0;if(!f)return t.flags&256?(Gt(t),t):(Gt(t),null)}return Gt(t),(t.flags&128)!==0?(t.lanes=i,t):(i=a!==null,e=e!==null&&e.memoizedState!==null,i&&(a=t.child,f=null,a.alternate!==null&&a.alternate.memoizedState!==null&&a.alternate.memoizedState.cachePool!==null&&(f=a.alternate.memoizedState.cachePool.pool),m=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(m=a.memoizedState.cachePool.pool),m!==f&&(a.flags|=2048)),i!==e&&i&&(t.child.flags|=8192),na(t,t.updateQueue),Ye(t),null);case 4:return Qe(),e===null&&Lu(t.stateNode.containerInfo),Ye(t),null;case 10:return vn(t.type),Ye(t),null;case 19:if(q(je),a=t.memoizedState,a===null)return Ye(t),null;if(f=(t.flags&128)!==0,m=a.rendering,m===null)if(f)Fi(a,!1);else{if(We!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(m=Yo(e),m!==null){for(t.flags|=128,Fi(a,!1),e=m.updateQueue,t.updateQueue=e,na(t,e),t.subtreeFlags=0,e=i,i=t.child;i!==null;)Cc(i,e),i=i.sibling;return O(je,je.current&1|2),xe&&gn(t,a.treeForkCount),t.child}e=e.sibling}a.tail!==null&&Fe()>sa&&(t.flags|=128,f=!0,Fi(a,!1),t.lanes=4194304)}else{if(!f)if(e=Yo(m),e!==null){if(t.flags|=128,f=!0,e=e.updateQueue,t.updateQueue=e,na(t,e),Fi(a,!0),a.tail===null&&a.tailMode==="hidden"&&!m.alternate&&!xe)return Ye(t),null}else 2*Fe()-a.renderingStartTime>sa&&i!==536870912&&(t.flags|=128,f=!0,Fi(a,!1),t.lanes=4194304);a.isBackwards?(m.sibling=t.child,t.child=m):(e=a.last,e!==null?e.sibling=m:t.child=m,a.last=m)}return a.tail!==null?(e=a.tail,a.rendering=e,a.tail=e.sibling,a.renderingStartTime=Fe(),e.sibling=null,i=je.current,O(je,f?i&1|2:i&1),xe&&gn(t,a.treeForkCount),e):(Ye(t),null);case 22:case 23:return Gt(t),Gs(),a=t.memoizedState!==null,e!==null?e.memoizedState!==null!==a&&(t.flags|=8192):a&&(t.flags|=8192),a?(i&536870912)!==0&&(t.flags&128)===0&&(Ye(t),t.subtreeFlags&6&&(t.flags|=8192)):Ye(t),i=t.updateQueue,i!==null&&na(t,i.retryQueue),i=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(i=e.memoizedState.cachePool.pool),a=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(a=t.memoizedState.cachePool.pool),a!==i&&(t.flags|=2048),e!==null&&q(pl),null;case 24:return i=null,e!==null&&(i=e.memoizedState.cache),t.memoizedState.cache!==i&&(t.flags|=2048),vn(tt),Ye(t),null;case 25:return null;case 30:return null}throw Error(s(156,t.tag))}function Og(e,t){switch(Es(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return vn(tt),Qe(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Al(t),null;case 31:if(t.memoizedState!==null){if(Gt(t),t.alternate===null)throw Error(s(340));fl()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Gt(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(s(340));fl()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return q(je),null;case 4:return Qe(),null;case 10:return vn(t.type),null;case 22:case 23:return Gt(t),Gs(),e!==null&&q(pl),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return vn(tt),null;case 25:return null;default:return null}}function $f(e,t){switch(Es(t),t.tag){case 3:vn(tt),Qe();break;case 26:case 27:case 5:Al(t);break;case 4:Qe();break;case 31:t.memoizedState!==null&&Gt(t);break;case 13:Gt(t);break;case 19:q(je);break;case 10:vn(t.type);break;case 22:case 23:Gt(t),Gs(),e!==null&&q(pl);break;case 24:vn(tt)}}function Xi(e,t){try{var i=t.updateQueue,a=i!==null?i.lastEffect:null;if(a!==null){var f=a.next;i=f;do{if((i.tag&e)===e){a=void 0;var m=i.create,v=i.inst;a=m(),v.destroy=a}i=i.next}while(i!==f)}}catch(E){Le(t,t.return,E)}}function kn(e,t,i){try{var a=t.updateQueue,f=a!==null?a.lastEffect:null;if(f!==null){var m=f.next;a=m;do{if((a.tag&e)===e){var v=a.inst,E=v.destroy;if(E!==void 0){v.destroy=void 0,f=t;var A=i,D=E;try{D()}catch(L){Le(f,A,L)}}}a=a.next}while(a!==m)}}catch(L){Le(t,t.return,L)}}function Wf(e){var t=e.updateQueue;if(t!==null){var i=e.stateNode;try{Pc(t,i)}catch(a){Le(e,e.return,a)}}}function jf(e,t,i){i.props=Tl(e.type,e.memoizedProps),i.state=e.memoizedState;try{i.componentWillUnmount()}catch(a){Le(e,t,a)}}function Ki(e,t){try{var i=e.ref;if(i!==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 i=="function"?e.refCleanup=i(a):i.current=a}}catch(f){Le(e,t,f)}}function rn(e,t){var i=e.ref,a=e.refCleanup;if(i!==null)if(typeof a=="function")try{a()}catch(f){Le(e,t,f)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof i=="function")try{i(null)}catch(f){Le(e,t,f)}else i.current=null}function ed(e){var t=e.type,i=e.memoizedProps,a=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":i.autoFocus&&a.focus();break e;case"img":i.src?a.src=i.src:i.srcSet&&(a.srcset=i.srcSet)}}catch(f){Le(e,e.return,f)}}function pu(e,t,i){try{var a=e.stateNode;my(a,e.type,i,t),a[xt]=t}catch(f){Le(e,e.return,f)}}function td(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Qn(e.type)||e.tag===4}function hu(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||td(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Qn(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 gu(e,t,i){var a=e.tag;if(a===5||a===6)e=e.stateNode,t?(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i).insertBefore(e,t):(t=i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,t.appendChild(e),i=i._reactRootContainer,i!=null||t.onclick!==null||(t.onclick=mn));else if(a!==4&&(a===27&&Qn(e.type)&&(i=e.stateNode,t=null),e=e.child,e!==null))for(gu(e,t,i),e=e.sibling;e!==null;)gu(e,t,i),e=e.sibling}function la(e,t,i){var a=e.tag;if(a===5||a===6)e=e.stateNode,t?i.insertBefore(e,t):i.appendChild(e);else if(a!==4&&(a===27&&Qn(e.type)&&(i=e.stateNode),e=e.child,e!==null))for(la(e,t,i),e=e.sibling;e!==null;)la(e,t,i),e=e.sibling}function nd(e){var t=e.stateNode,i=e.memoizedProps;try{for(var a=e.type,f=t.attributes;f.length;)t.removeAttributeNode(f[0]);yt(t,a,i),t[mt]=e,t[xt]=i}catch(m){Le(e,e.return,m)}}var Cn=!1,it=!1,yu=!1,ld=typeof WeakSet=="function"?WeakSet:Set,rt=null;function Fg(e,t){if(e=e.containerInfo,zu=Aa,e=pc(e),cs(e)){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{i=(i=e.ownerDocument)&&i.defaultView||window;var a=i.getSelection&&i.getSelection();if(a&&a.rangeCount!==0){i=a.anchorNode;var f=a.anchorOffset,m=a.focusNode;a=a.focusOffset;try{i.nodeType,m.nodeType}catch{i=null;break e}var v=0,E=-1,A=-1,D=0,L=0,z=e,w=null;t:for(;;){for(var U;z!==i||f!==0&&z.nodeType!==3||(E=v+f),z!==m||a!==0&&z.nodeType!==3||(A=v+a),z.nodeType===3&&(v+=z.nodeValue.length),(U=z.firstChild)!==null;)w=z,z=U;for(;;){if(z===e)break t;if(w===i&&++D===f&&(E=v),w===m&&++L===a&&(A=v),(U=z.nextSibling)!==null)break;z=w,w=z.parentNode}z=U}i=E===-1||A===-1?null:{start:E,end:A}}else i=null}i=i||{start:0,end:0}}else i=null;for(Vu={focusedElem:e,selectionRange:i},Aa=!1,rt=t;rt!==null;)if(t=rt,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,rt=e;else for(;rt!==null;){switch(t=rt,m=t.alternate,e=t.flags,t.tag){case 0:if((e&4)!==0&&(e=t.updateQueue,e=e!==null?e.events:null,e!==null))for(i=0;i title"))),yt(m,a,i),m[mt]=e,ut(m),a=m;break e;case"link":var v=rm("link","href",f).get(a+(i.href||""));if(v){for(var E=0;Eze&&(v=ze,ze=se,se=v);var N=dc(E,se),x=dc(E,ze);if(N&&x&&(U.rangeCount!==1||U.anchorNode!==N.node||U.anchorOffset!==N.offset||U.focusNode!==x.node||U.focusOffset!==x.offset)){var b=z.createRange();b.setStart(N.node,N.offset),U.removeAllRanges(),se>ze?(U.addRange(b),U.extend(x.node,x.offset)):(b.setEnd(x.node,x.offset),U.addRange(b))}}}}for(z=[],U=E;U=U.parentNode;)U.nodeType===1&&z.push({element:U,left:U.scrollLeft,top:U.scrollTop});for(typeof E.focus=="function"&&E.focus(),E=0;Ei?32:i,I.T=null,i=Au,Au=null;var m=Fn,v=Rn;if(at=0,ni=Fn=null,Rn=0,(Ie&6)!==0)throw Error(s(331));var E=Ie;if(Ie|=4,pd(m.current),fd(m,m.current,v,i),Ie=E,eo(0,!1),Ue&&typeof Ue.onPostCommitFiberRoot=="function")try{Ue.onPostCommitFiberRoot(Re,m)}catch{}return!0}finally{k.p=f,I.T=a,Ud(e,t)}}function qd(e,t,i){t=Jt(i,t),t=lu(e.stateNode,t,2),e=Vn(e,t,2),e!==null&&(Si(e,2),cn(e))}function Le(e,t,i){if(e.tag===3)qd(e,e,i);else for(;t!==null;){if(t.tag===3){qd(t,e,i);break}else if(t.tag===1){var a=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof a.componentDidCatch=="function"&&(On===null||!On.has(a))){e=Jt(i,e),i=Lf(2),a=Vn(t,i,2),a!==null&&(Gf(i,a,t,e),Si(a,2),cn(a));break}}t=t.return}}function Ru(e,t,i){var a=e.pingCache;if(a===null){a=e.pingCache=new Qg;var f=new Set;a.set(t,f)}else f=a.get(t),f===void 0&&(f=new Set,a.set(t,f));f.has(i)||(Su=!0,f.add(i),e=ey.bind(null,e,t,i),t.then(e,e))}function ey(e,t,i){var a=e.pingCache;a!==null&&a.delete(t),e.pingedLanes|=e.suspendedLanes&i,e.warmLanes&=~i,Ve===e&&(Ce&i)===i&&(We===4||We===3&&(Ce&62914560)===Ce&&300>Fe()-aa?(Ie&2)===0&&li(e,0):Eu|=i,ti===Ce&&(ti=0)),cn(e)}function Ld(e,t){t===0&&(t=Rr()),e=rl(e,t),e!==null&&(Si(e,t),cn(e))}function ty(e){var t=e.memoizedState,i=0;t!==null&&(i=t.retryLane),Ld(e,i)}function ny(e,t){var i=0;switch(e.tag){case 31:case 13:var a=e.stateNode,f=e.memoizedState;f!==null&&(i=f.retryLane);break;case 19:a=e.stateNode;break;case 22:a=e.stateNode._retryCache;break;default:throw Error(s(314))}a!==null&&a.delete(t),Ld(e,i)}function ly(e,t){return ie(e,t)}var ma=null,oi=null,bu=!1,pa=!1,Du=!1,Kn=0;function cn(e){e!==oi&&e.next===null&&(oi===null?ma=oi=e:oi=oi.next=e),pa=!0,bu||(bu=!0,oy())}function eo(e,t){if(!Du&&pa){Du=!0;do for(var i=!1,a=ma;a!==null;){if(e!==0){var f=a.pendingLanes;if(f===0)var m=0;else{var v=a.suspendedLanes,E=a.pingedLanes;m=(1<<31-ot(42|e)+1)-1,m&=f&~(v&~E),m=m&201326741?m&201326741|1:m?m|2:0}m!==0&&(i=!0,Vd(a,m))}else m=Ce,m=vo(a,a===Ve?m:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),(m&3)===0||Ti(a,m)||(i=!0,Vd(a,m));a=a.next}while(i);Du=!1}}function iy(){Gd()}function Gd(){pa=bu=!1;var e=0;Kn!==0&&hy()&&(e=Kn);for(var t=Fe(),i=null,a=ma;a!==null;){var f=a.next,m=Hd(a,t);m===0?(a.next=null,i===null?ma=f:i.next=f,f===null&&(oi=i)):(i=a,(e!==0||(m&3)!==0)&&(pa=!0)),a=f}at!==0&&at!==5||eo(e),Kn!==0&&(Kn=0)}function Hd(e,t){for(var i=e.suspendedLanes,a=e.pingedLanes,f=e.expirationTimes,m=e.pendingLanes&-62914561;0E)break;var L=A.transferSize,z=A.initiatorType;L&&Xd(z)&&(A=A.responseEnd,v+=L*(A"u"?null:document;function om(e,t,i){var a=ai;if(a&&typeof t=="string"&&t){var f=kt(t);f='link[rel="'+e+'"][href="'+f+'"]',typeof i=="string"&&(f+='[crossorigin="'+i+'"]'),im.has(f)||(im.add(f),e={rel:e,crossOrigin:i,href:t},a.querySelector(f)===null&&(t=a.createElement("link"),yt(t,"link",e),ut(t),a.head.appendChild(t)))}}function Ay(e){bn.D(e),om("dns-prefetch",e,null)}function xy(e,t){bn.C(e,t),om("preconnect",e,t)}function My(e,t,i){bn.L(e,t,i);var a=ai;if(a&&e&&t){var f='link[rel="preload"][as="'+kt(t)+'"]';t==="image"&&i&&i.imageSrcSet?(f+='[imagesrcset="'+kt(i.imageSrcSet)+'"]',typeof i.imageSizes=="string"&&(f+='[imagesizes="'+kt(i.imageSizes)+'"]')):f+='[href="'+kt(e)+'"]';var m=f;switch(t){case"style":m=si(e);break;case"script":m=ui(e)}Zt.has(m)||(e=S({rel:"preload",href:t==="image"&&i&&i.imageSrcSet?void 0:e,as:t},i),Zt.set(m,e),a.querySelector(f)!==null||t==="style"&&a.querySelector(io(m))||t==="script"&&a.querySelector(oo(m))||(t=a.createElement("link"),yt(t,"link",e),ut(t),a.head.appendChild(t)))}}function Ny(e,t){bn.m(e,t);var i=ai;if(i&&e){var a=t&&typeof t.as=="string"?t.as:"script",f='link[rel="modulepreload"][as="'+kt(a)+'"][href="'+kt(e)+'"]',m=f;switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":m=ui(e)}if(!Zt.has(m)&&(e=S({rel:"modulepreload",href:e},t),Zt.set(m,e),i.querySelector(f)===null)){switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(i.querySelector(oo(m)))return}a=i.createElement("link"),yt(a,"link",e),ut(a),i.head.appendChild(a)}}}function Ry(e,t,i){bn.S(e,t,i);var a=ai;if(a&&e){var f=bl(a).hoistableStyles,m=si(e);t=t||"default";var v=f.get(m);if(!v){var E={loading:0,preload:null};if(v=a.querySelector(io(m)))E.loading=5;else{e=S({rel:"stylesheet",href:e,"data-precedence":t},i),(i=Zt.get(m))&&Fu(e,i);var A=v=a.createElement("link");ut(A),yt(A,"link",e),A._p=new Promise(function(D,L){A.onload=D,A.onerror=L}),A.addEventListener("load",function(){E.loading|=1}),A.addEventListener("error",function(){E.loading|=2}),E.loading|=4,Ta(v,t,a)}v={type:"stylesheet",instance:v,count:1,state:E},f.set(m,v)}}}function by(e,t){bn.X(e,t);var i=ai;if(i&&e){var a=bl(i).hoistableScripts,f=ui(e),m=a.get(f);m||(m=i.querySelector(oo(f)),m||(e=S({src:e,async:!0},t),(t=Zt.get(f))&&Xu(e,t),m=i.createElement("script"),ut(m),yt(m,"link",e),i.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},a.set(f,m))}}function Dy(e,t){bn.M(e,t);var i=ai;if(i&&e){var a=bl(i).hoistableScripts,f=ui(e),m=a.get(f);m||(m=i.querySelector(oo(f)),m||(e=S({src:e,async:!0,type:"module"},t),(t=Zt.get(f))&&Xu(e,t),m=i.createElement("script"),ut(m),yt(m,"link",e),i.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},a.set(f,m))}}function am(e,t,i,a){var f=(f=ye.current)?va(f):null;if(!f)throw Error(s(446));switch(e){case"meta":case"title":return null;case"style":return typeof i.precedence=="string"&&typeof i.href=="string"?(t=si(i.href),i=bl(f).hoistableStyles,a=i.get(t),a||(a={type:"style",instance:null,count:0,state:null},i.set(t,a)),a):{type:"void",instance:null,count:0,state:null};case"link":if(i.rel==="stylesheet"&&typeof i.href=="string"&&typeof i.precedence=="string"){e=si(i.href);var m=bl(f).hoistableStyles,v=m.get(e);if(v||(f=f.ownerDocument||f,v={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},m.set(e,v),(m=f.querySelector(io(e)))&&!m._p&&(v.instance=m,v.state.loading=5),Zt.has(e)||(i={rel:"preload",as:"style",href:i.href,crossOrigin:i.crossOrigin,integrity:i.integrity,media:i.media,hrefLang:i.hrefLang,referrerPolicy:i.referrerPolicy},Zt.set(e,i),m||wy(f,e,i,v.state))),t&&a===null)throw Error(s(528,""));return v}if(t&&a!==null)throw Error(s(529,""));return null;case"script":return t=i.async,i=i.src,typeof i=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=ui(i),i=bl(f).hoistableScripts,a=i.get(t),a||(a={type:"script",instance:null,count:0,state:null},i.set(t,a)),a):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,e))}}function si(e){return'href="'+kt(e)+'"'}function io(e){return'link[rel="stylesheet"]['+e+"]"}function sm(e){return S({},e,{"data-precedence":e.precedence,precedence:null})}function wy(e,t,i,a){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?a.loading=1:(t=e.createElement("link"),a.preload=t,t.addEventListener("load",function(){return a.loading|=1}),t.addEventListener("error",function(){return a.loading|=2}),yt(t,"link",i),ut(t),e.head.appendChild(t))}function ui(e){return'[src="'+kt(e)+'"]'}function oo(e){return"script[async]"+e}function um(e,t,i){if(t.count++,t.instance===null)switch(t.type){case"style":var a=e.querySelector('style[data-href~="'+kt(i.href)+'"]');if(a)return t.instance=a,ut(a),a;var f=S({},i,{"data-href":i.href,"data-precedence":i.precedence,href:null,precedence:null});return a=(e.ownerDocument||e).createElement("style"),ut(a),yt(a,"style",f),Ta(a,i.precedence,e),t.instance=a;case"stylesheet":f=si(i.href);var m=e.querySelector(io(f));if(m)return t.state.loading|=4,t.instance=m,ut(m),m;a=sm(i),(f=Zt.get(f))&&Fu(a,f),m=(e.ownerDocument||e).createElement("link"),ut(m);var v=m;return v._p=new Promise(function(E,A){v.onload=E,v.onerror=A}),yt(m,"link",a),t.state.loading|=4,Ta(m,i.precedence,e),t.instance=m;case"script":return m=ui(i.src),(f=e.querySelector(oo(m)))?(t.instance=f,ut(f),f):(a=i,(f=Zt.get(m))&&(a=S({},i),Xu(a,f)),e=e.ownerDocument||e,f=e.createElement("script"),ut(f),yt(f,"link",a),e.head.appendChild(f),t.instance=f);case"void":return null;default:throw Error(s(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(a=t.instance,t.state.loading|=4,Ta(a,i.precedence,e));return t.instance}function Ta(e,t,i){for(var a=i.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),f=a.length?a[a.length-1]:null,m=f,v=0;v title"):null)}function Uy(e,t,i){if(i===1||t.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;switch(t.rel){case"stylesheet":return e=t.disabled,typeof t.precedence=="string"&&e==null;default:return!0}case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function fm(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function Iy(e,t,i,a){if(i.type==="stylesheet"&&(typeof a.media!="string"||matchMedia(a.media).matches!==!1)&&(i.state.loading&4)===0){if(i.instance===null){var f=si(a.href),m=t.querySelector(io(f));if(m){t=m._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=Ea.bind(e),t.then(e,e)),i.state.loading|=4,i.instance=m,ut(m);return}m=t.ownerDocument||t,a=sm(a),(f=Zt.get(f))&&Fu(a,f),m=m.createElement("link"),ut(m);var v=m;v._p=new Promise(function(E,A){v.onload=E,v.onerror=A}),yt(m,"link",a),i.instance=m}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(i,t),(t=i.state.preload)&&(i.state.loading&3)===0&&(e.count++,i=Ea.bind(e),t.addEventListener("load",i),t.addEventListener("error",i))}}var Ku=0;function qy(e,t){return e.stylesheets&&e.count===0&&Ca(e,e.stylesheets),0Ku?50:800)+t);return e.unsuspend=i,function(){e.unsuspend=null,clearTimeout(a),clearTimeout(f)}}:null}function Ea(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Ca(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var _a=null;function Ca(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,_a=new Map,t.forEach(Ly,e),_a=null,Ea.call(e))}function Ly(e,t){if(!(t.state.loading&4)){var i=_a.get(e);if(i)var a=i.get(null);else{i=new Map,_a.set(e,i);for(var f=e.querySelectorAll("link[data-precedence],style[data-precedence]"),m=0;m"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(l)}catch(n){console.error(n)}}return l(),lr.exports=Wy(),lr.exports}var e0=jy();const t0=eh(e0),tn=({className:l})=>C.jsxs("svg",{className:`animate-spin h-5 w-5 text-white ${l}`,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[C.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),C.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"})]}),n0=({onSubmit:l,isLoading:n})=>{const[o,s]=ne.useState(""),r=d=>{d.preventDefault(),l(o.trim())};return C.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-90 flex items-center justify-center z-50",children:C.jsxs("div",{className:"bg-gray-850 p-8 rounded-lg shadow-2xl w-full max-w-md border border-gray-700",children:[C.jsx("h2",{className:"text-2xl font-bold text-center text-gray-100 mb-2",children:"GitHub AI Code Editor"}),C.jsx("p",{className:"text-center text-gray-400 mb-6",children:"Enter your Personal Access Token to begin."}),C.jsxs("form",{onSubmit:r,children:[C.jsxs("div",{className:"mb-4",children:[C.jsx("label",{htmlFor:"token",className:"block text-sm font-medium text-gray-300 mb-2",children:"GitHub Token"}),C.jsx("input",{id:"token",type:"password",value:o,onChange:d=>s(d.target.value),className:"w-full px-3 py-2 bg-gray-900 border border-gray-600 rounded-md text-gray-200 focus:outline-none focus:ring-2 focus:ring-indigo-500",placeholder:"ghp_...",required:!0})]}),C.jsxs("div",{className:"text-xs text-gray-500 mb-6 space-y-2",children:[C.jsx("p",{children:"Your token is used only for API requests and is not stored."}),C.jsxs("p",{children:["A ",C.jsx("strong",{className:"text-gray-400",children:"classic"})," token with the full ",C.jsx("code",{className:"bg-gray-700 p-1 rounded-sm text-xs",children:"repo"})," scope is required. Fine-grained tokens are not supported."]}),C.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."})]}),C.jsx("button",{type:"submit",disabled:n||!o,className:"w-full bg-indigo-600 text-white font-semibold py-2 px-4 rounded-md hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-850 focus:ring-indigo-500 disabled:bg-gray-500 disabled:cursor-not-allowed transition-colors flex items-center justify-center",children:n?C.jsx(tn,{}):"Load Repositories"})]})]})})},th=l=>C.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,...l,children:C.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"})}),nh=l=>C.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,...l,children:C.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"})}),l0=l=>C.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,...l,children:C.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"})}),i0=l=>C.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",...l,children:C.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"})}),o0=l=>C.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",...l,children:C.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})}),lh=({node:l,repoFullName:n,onFileClick:o,selectedFilePath:s,selectedRepo:r,selectedFiles:d,onFileSelection:p,onDirectorySelection:g})=>{const[y,h]=ne.useState(!1),T=ne.useRef(null),S=l.type==="dir";ne.useEffect(()=>{if(S&&T.current){const V=Mr(l.children).map(J=>`${n}::${J}`);if(V.length===0){T.current.indeterminate=!1,T.current.checked=!1;return}const Y=V.filter(J=>d.has(J)).length;Y>0&&Y{if(S)g(l.children,n,V.target.checked);else{const Y=`${n}::${l.path}`;p(Y,V.target.checked)}};if(S)return C.jsxs("div",{children:[C.jsxs("div",{className:"flex items-center p-1.5 hover:bg-gray-700 rounded-md group",children:[C.jsx("input",{type:"checkbox",ref:T,onChange:_,className:"mr-2 h-4 w-4 rounded bg-gray-800 border-gray-600 text-amber-500 focus:ring-amber-600"}),C.jsxs("div",{className:"flex items-center cursor-pointer flex-grow",onClick:()=>h(!y),children:[y?C.jsx(nh,{className:"w-5 h-5 mr-2 text-indigo-400"}):C.jsx(th,{className:"w-5 h-5 mr-2 text-indigo-400"}),C.jsx("span",{children:l.name})]})]}),y&&C.jsx("div",{className:"pl-6 border-l border-gray-700 ml-4",children:l.children.map(V=>C.jsx(lh,{node:V,repoFullName:n,onFileClick:o,selectedFilePath:s,selectedRepo:r,selectedFiles:d,onFileSelection:p,onDirectorySelection:g},V.path))})]});const R=d.has(`${n}::${l.path}`),H=r===n&&s===l.path;return C.jsxs("div",{className:`flex items-center p-1.5 group rounded-md ${H?"bg-indigo-900 bg-opacity-50":"hover:bg-gray-700"}`,children:[C.jsx("input",{type:"checkbox",checked:R,onChange:_,className:"mr-2 h-4 w-4 rounded bg-gray-800 border-gray-600 text-amber-500 focus:ring-amber-600"}),C.jsxs("div",{className:"flex items-center cursor-pointer flex-grow",onClick:()=>o(n,l.path),children:[C.jsx(l0,{className:"w-5 h-5 mr-2 text-gray-400"}),C.jsx("span",{className:H?"text-white":"text-gray-300",children:l.name})]})]})},a0=l=>{const{repo:n,tree:o,onFileClick:s,selectedFilePath:r,selectedRepo:d,selectedFiles:p,onFileSelection:g,onDirectorySelection:y}=l,h=n.full_name===d,[T,S]=ne.useState(h);return ne.useEffect(()=>{h&&!T&&S(!0)},[h,T]),C.jsxs("div",{className:"mb-2",children:[C.jsx("div",{className:"flex items-center justify-between p-2 hover:bg-gray-700 rounded-md group",children:C.jsxs("h3",{className:"text-lg font-semibold cursor-pointer flex items-center flex-grow",onClick:()=>S(!T),children:[T?C.jsx(nh,{className:"w-5 h-5 mr-2"}):C.jsx(th,{className:"w-5 h-5 mr-2"}),n.full_name]})}),T&&C.jsx("div",{className:"pl-4 border-l border-gray-700 ml-2",children:o.map(_=>C.jsx(lh,{node:_,repoFullName:n.full_name,onFileClick:s,selectedFilePath:r,selectedRepo:d,selectedFiles:p,onFileSelection:g,onDirectorySelection:y},_.path))})]})},s0=({fileTree:l,onFileSelect:n,onStartMultiEdit:o,onStartNewProject:s,selectedFilePath:r,selectedRepo:d,selectedFiles:p,onFileSelection:g,onDirectorySelection:y})=>C.jsxs("div",{className:"p-4 text-gray-300 h-full flex flex-col",children:[C.jsxs("div",{className:"flex justify-between items-center mb-4 border-b border-gray-700 pb-2 flex-shrink-0",children:[C.jsx("h2",{className:"text-xl font-bold",children:"Repositories"}),C.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:[C.jsx(o0,{className:"w-4 h-4"}),"New AI Project"]})]}),C.jsxs("div",{className:"flex-grow overflow-y-auto",children:[p.size>0&&C.jsx("div",{className:"mb-4 sticky top-0 bg-gray-900 py-2 z-10",children:C.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:[C.jsx(i0,{className:"w-5 h-5"}),"AI Edit ",p.size," Selected File",p.size>1?"s":""]})}),Object.keys(l).sort().map(h=>C.jsx(a0,{repo:l[h].repo,tree:l[h].tree,onFileClick:n,selectedFilePath:r,selectedRepo:d,selectedFiles:p,onFileSelection:g,onDirectorySelection:y},h))]})]}),u0=({onClose:l,onSubmit:n,isLoading:o})=>{const[s,r]=ne.useState(""),d=async p=>{p.preventDefault(),!(!s.trim()||o)&&(await n(s),l())};return C.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-70 flex items-center justify-center z-50",onClick:l,children:C.jsxs("div",{className:"bg-gray-850 p-6 rounded-lg shadow-2xl w-full max-w-lg border border-gray-700",onClick:p=>p.stopPropagation(),children:[C.jsx("h2",{className:"text-xl font-bold text-indigo-400 mb-4",children:"AI Assistant"}),C.jsxs("form",{onSubmit:d,children:[C.jsx("p",{className:"text-gray-400 mb-2 text-sm",children:"Describe the changes you want to make to the code:"}),C.jsx("textarea",{value:s,onChange:p=>r(p.target.value),placeholder:"e.g., 'Refactor this function to use async/await'",className:"w-full h-40 bg-gray-900 p-3 rounded-md mb-4 text-sm border border-gray-600 focus:outline-none focus:ring-2 focus:ring-indigo-500 resize-none",autoFocus:!0}),C.jsxs("div",{className:"flex justify-end gap-4",children:[C.jsx("button",{type:"button",onClick:l,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"}),C.jsx("button",{type:"submit",disabled:o||!s.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-[120px]",children:o?C.jsx(tn,{}):"Generate Edit"})]})]})]})})},r0=({onClose:l,onCommit:n,isLoading:o,defaultMessage:s})=>{const[r,d]=ne.useState(s);ne.useEffect(()=>{d(s)},[s]);const p=async g=>{g.preventDefault(),!(!r.trim()||o)&&await n(r)};return C.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-70 flex items-center justify-center z-50",onClick:l,children:C.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:[C.jsx("h2",{className:"text-xl font-bold text-green-400 mb-4",children:"Commit Changes"}),C.jsxs("form",{onSubmit:p,children:[C.jsx("p",{className:"text-gray-400 mb-2 text-sm",children:"Enter a commit message:"}),C.jsx("input",{type:"text",value:r,onChange:g=>d(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}),C.jsxs("div",{className:"flex justify-end gap-4",children:[C.jsx("button",{type:"button",onClick:l,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"}),C.jsx("button",{type:"submit",disabled:o||!r.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?C.jsx(tn,{}):"Commit"})]})]})]})})},c0=l=>C.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",...l,children:C.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"})}),f0=({file:l,isActive:n,onSelect:o,onClose:s})=>{const r=l.content!==l.editedContent,d=l.repoFullName+"::"+l.path,p=l.path.split("/").pop();return C.jsxs("div",{onClick:()=>o(d),className:`flex items-center justify-between p-2 px-4 cursor-pointer border-b-2 ${n?"bg-gray-850 border-indigo-500 text-white":"bg-gray-900 border-transparent text-gray-400 hover:bg-gray-800"}`,children:[C.jsx("span",{className:"text-sm font-medium pr-2",children:p}),C.jsxs("div",{className:"flex items-center",children:[r&&C.jsx("div",{className:"w-2 h-2 bg-yellow-400 rounded-full mr-2"}),C.jsx("button",{onClick:g=>{g.stopPropagation(),s(d)},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:"×"})]})]})},d0=({openFiles:l,activeFile:n,onCommit:o,onAiEdit:s,onFileContentChange:r,onCloseFile:d,onSetActiveFile:p,isLoading:g,branches:y,currentBranch:h,onBranchChange:T,onCreateBranch:S,onCreatePullRequest:_})=>{const[R,H]=ne.useState(!1),[V,Y]=ne.useState(!1),[J,X]=ne.useState(""),[P,K]=ne.useState(!1),[te,le]=ne.useState(!1),[F,ve]=ne.useState(""),[$,Te]=ne.useState("");ne.useEffect(()=>{if(n){const B=`Update ${n.path}`;ve(B)}},[n]);const Me=n?n.editedContent!==n.content:!1,pe=async B=>{if(!B.trim()||!n)return;const re=n.repoFullName+"::"+n.path;let Se="";const M=()=>Se;r(re,"");const q=Q=>{Se+=Q,r(re,Se)};await s(n.content,B,q,M);const O=Se.replace(/^```(?:\w*\n)?/,"").replace(/\n?```$/,"").trim();O?r(re,O):r(re,Se)},Ke=async B=>{!B.trim()||!n||(await o(B),Y(!1))},st=async()=>{J.trim()&&(await S(J),X(""),K(!1))},Oe=async()=>{F.trim()&&(await _(F,$),le(!1),Te(""))};if(!n)return C.jsx("div",{className:"flex-grow flex items-center justify-center bg-gray-850 text-gray-500",children:C.jsx("p",{children:"Select a file from the explorer to begin editing."})});const I=n.repoFullName+"::"+n.path,k=`Update ${n.path}`;return C.jsxs("div",{className:"flex flex-col h-full bg-gray-850 relative",children:[C.jsxs("div",{className:"flex items-center justify-between p-2 border-b border-gray-700 bg-gray-900 flex-wrap gap-2",children:[C.jsxs("div",{children:[C.jsx("h3",{className:"text-md font-semibold text-gray-200",children:n.path}),C.jsx("p",{className:"text-xs text-gray-400",children:n.repoFullName})]}),C.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsx("select",{id:"branch-select",value:h||"",onChange:B=>T(B.target.value),disabled:g,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:y.map(B=>C.jsx("option",{value:B.name,children:B.name},B.name))}),P?C.jsxs("div",{className:"flex gap-2 items-center",children:[C.jsx("input",{type:"text",value:J,onChange:B=>X(B.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"}),C.jsx("button",{onClick:st,disabled:g||!J.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"}),C.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"})]}):C.jsx("button",{onClick:()=>K(!0),className:"text-sm text-cyan-400 hover:underline px-3 py-1.5",disabled:g,children:"New Branch"})]}),C.jsx("button",{onClick:()=>Y(!0),disabled:g||!Me,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"}),h&&h!==n.defaultBranch&&C.jsx("button",{onClick:()=>le(!te),className:"bg-cyan-600 text-white font-semibold py-2 px-4 rounded-md hover:bg-cyan-700 disabled:bg-gray-500",disabled:g,children:te?"Cancel PR":"Create Pull Request"})]})]}),te&&C.jsxs("div",{className:"p-4 bg-gray-800 border-b border-gray-700",children:[C.jsx("h4",{className:"font-semibold mb-2 text-gray-200",children:"New Pull Request"}),C.jsxs("p",{className:"text-xs text-gray-400 mb-2",children:["From ",C.jsx("code",{className:"bg-gray-700 p-1 rounded-sm text-xs",children:h})," into ",C.jsx("code",{className:"bg-gray-700 p-1 rounded-sm text-xs",children:n.defaultBranch})]}),C.jsx("input",{type:"text",value:F,onChange:B=>ve(B.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"}),C.jsx("textarea",{value:$,onChange:B=>Te(B.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"}),C.jsx("div",{className:"flex gap-2",children:C.jsx("button",{onClick:Oe,disabled:g||!F.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:g?C.jsx(tn,{className:"h-4 w-4"}):"Submit Pull Request"})})]}),C.jsx("div",{className:"flex border-b border-gray-700 bg-gray-900 overflow-x-auto",children:l.map(B=>C.jsx(f0,{file:B,isActive:B.repoFullName+"::"+B.path===I,onSelect:p,onClose:d},B.repoFullName+"::"+B.path))}),C.jsx("div",{className:"flex-grow p-4",children:C.jsx("textarea",{value:n.editedContent,onChange:B=>r(I,B.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"},I)}),C.jsx("button",{onClick:()=>H(!0),className:"absolute bottom-6 right-6 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","aria-label":"Edit with AI",children:C.jsx(c0,{className:"h-6 w-6"})}),R&&C.jsx(u0,{onClose:()=>H(!1),onSubmit:pe,isLoading:g}),V&&C.jsx(r0,{onClose:()=>Y(!1),onCommit:Ke,isLoading:g,defaultMessage:k})]})},m0="https://api.github.com";async function tl(l,n,o={}){const s=await fetch(`${m0}${l}`,{...o,headers:{...o.headers,Authorization:`Bearer ${n}`,Accept:"application/vnd.github.v3+json","X-GitHub-Api-Version":"2022-11-28"}});if(!s.ok){const r=await s.json();throw new Error(`GitHub API Error: ${s.status} ${r.message||""}`)}return s.status===204||s.status===201&&!s.body?null:s.json()}async function p0(l){let n=[],o=1;const s=100;for(;;){const r=await tl(`/user/repos?type=owner&per_page=${s}&page=${o}`,l);if(n=n.concat(r),r.length{const n={children:{}};l.forEach(s=>{if(s.type!=="blob")return;const r=s.path.split("/");let d=n.children;r.forEach((p,g)=>{const y=g===r.length-1,h=r.slice(0,g+1).join("/");y?d[p]||(d[p]={type:"file",path:s.path,name:p}):(d[p]||(d[p]={type:"dir",path:h,name:p,children:{}}),d=d[p].children)})});const o=s=>{const r=Object.values(s).map(d=>{if(d.type==="dir"){const p=o(d.children);return{...d,children:p}}return d});return r.sort((d,p)=>d.type!==p.type?d.type==="dir"?-1:1:d.name.localeCompare(p.name)),r};return o(n.children)};async function Lm(l,n,o,s){const{tree:r}=await tl(`/repos/${n}/${o}/git/trees/${s}?recursive=1`,l);return h0(r)}async function wa(l,n,o,s,r){const d=r?`/repos/${n}/${o}/contents/${s}?ref=${r}`:`/repos/${n}/${o}/contents/${s}`,p=await tl(d,l);return{...p,content:atob(p.content)}}async function Gm(l,n,o){return tl(`/repos/${n}/${o}/branches?per_page=100`,l)}async function g0(l,n,o,s,r){const d={ref:`refs/heads/${s}`,sha:r};return tl(`/repos/${n}/${o}/git/refs`,l,{method:"POST",body:JSON.stringify(d),headers:{"Content-Type":"application/json"}})}async function y0({token:l,name:n,description:o,isPrivate:s}){return tl("/user/repos",l,{method:"POST",body:JSON.stringify({name:n,description:o,private:s,auto_init:!0}),headers:{"Content-Type":"application/json"}})}function v0(l){return btoa(unescape(encodeURIComponent(l)))}async function sr({token:l,owner:n,repo:o,branch:s,path:r,content:d,message:p,sha:g}){const y={message:p,content:v0(d),...g&&{sha:g},branch:s};return(await tl(`/repos/${n}/${o}/contents/${r}`,l,{method:"PUT",body:JSON.stringify(y),headers:{"Content-Type":"application/json"}})).content.sha}async function T0({token:l,owner:n,repo:o,title:s,body:r,head:d,base:p}){const g={title:s,body:r,head:d,base:p};return tl(`/repos/${n}/${o}/pulls`,l,{method:"POST",body:JSON.stringify(g),headers:{"Content-Type":"application/json"}})}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */let S0,E0;function _0(){return{geminiUrl:S0,vertexUrl:E0}}function C0(l,n,o,s){var r,d;if(!(l!=null&&l.baseUrl)){const p=_0();return n?(r=p.vertexUrl)!==null&&r!==void 0?r:o:(d=p.geminiUrl)!==null&&d!==void 0?d:s}return l.baseUrl}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class Cl{}function j(l,n){const o=/\{([^}]+)\}/g;return l.replace(o,(s,r)=>{if(Object.prototype.hasOwnProperty.call(n,r)){const d=n[r];return d!=null?String(d):""}else throw new Error(`Key '${r}' not found in valueMap.`)})}function c(l,n,o){for(let d=0;d({}));else throw new Error(`Value must be a list given an array path ${p}`);if(Array.isArray(l[g])){const y=l[g];if(Array.isArray(o))for(let h=0;hu(g,n.slice(s+1),o)):o}else return o}else l=l[r]}return l}catch(s){if(s instanceof TypeError)return o;throw s}}function A0(l,n){for(const[o,s]of Object.entries(n)){const r=o.split("."),d=s.split("."),p=new Set;let g=-1;for(let y=0;yg)for(let y=g;y=n.length||typeof l!="object"||l===null)return;const d=n[s];if(d.endsWith("[]")){const p=d.slice(0,-2),g=l;if(p in g&&Array.isArray(g[p]))for(const y of g[p])rr(y,n,o,s+1,r)}else if(d==="*"){if(typeof l=="object"&&l!==null&&!Array.isArray(l)){const p=l,g=Object.keys(p).filter(h=>!h.startsWith("_")&&!r.has(h)),y={};for(const h of g)y[h]=p[h];for(const[h,T]of Object.entries(y)){const S=[];for(const _ of o.slice(s))_==="*"?S.push(h):S.push(_);c(p,S,T)}for(const h of g)delete p[h]}}else{const p=l;d in p&&rr(p[d],n,o,s+1,r)}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function Tr(l){if(typeof l!="string")throw new Error("fromImageBytes must be a string");return l}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function x0(l){const n={},o=u(l,["operationName"]);o!=null&&c(n,["operationName"],o);const s=u(l,["resourceName"]);return s!=null&&c(n,["_url","resourceName"],s),n}function M0(l){const n={},o=u(l,["name"]);o!=null&&c(n,["name"],o);const s=u(l,["metadata"]);s!=null&&c(n,["metadata"],s);const r=u(l,["done"]);r!=null&&c(n,["done"],r);const d=u(l,["error"]);d!=null&&c(n,["error"],d);const p=u(l,["response","generateVideoResponse"]);return p!=null&&c(n,["response"],R0(p)),n}function N0(l){const n={},o=u(l,["name"]);o!=null&&c(n,["name"],o);const s=u(l,["metadata"]);s!=null&&c(n,["metadata"],s);const r=u(l,["done"]);r!=null&&c(n,["done"],r);const d=u(l,["error"]);d!=null&&c(n,["error"],d);const p=u(l,["response"]);return p!=null&&c(n,["response"],b0(p)),n}function R0(l){const n={},o=u(l,["generatedSamples"]);if(o!=null){let d=o;Array.isArray(d)&&(d=d.map(p=>D0(p))),c(n,["generatedVideos"],d)}const s=u(l,["raiMediaFilteredCount"]);s!=null&&c(n,["raiMediaFilteredCount"],s);const r=u(l,["raiMediaFilteredReasons"]);return r!=null&&c(n,["raiMediaFilteredReasons"],r),n}function b0(l){const n={},o=u(l,["videos"]);if(o!=null){let d=o;Array.isArray(d)&&(d=d.map(p=>w0(p))),c(n,["generatedVideos"],d)}const s=u(l,["raiMediaFilteredCount"]);s!=null&&c(n,["raiMediaFilteredCount"],s);const r=u(l,["raiMediaFilteredReasons"]);return r!=null&&c(n,["raiMediaFilteredReasons"],r),n}function D0(l){const n={},o=u(l,["video"]);return o!=null&&c(n,["video"],q0(o)),n}function w0(l){const n={},o=u(l,["_self"]);return o!=null&&c(n,["video"],L0(o)),n}function U0(l){const n={},o=u(l,["operationName"]);return o!=null&&c(n,["_url","operationName"],o),n}function I0(l){const n={},o=u(l,["operationName"]);return o!=null&&c(n,["_url","operationName"],o),n}function q0(l){const n={},o=u(l,["uri"]);o!=null&&c(n,["uri"],o);const s=u(l,["encodedVideo"]);s!=null&&c(n,["videoBytes"],Tr(s));const r=u(l,["encoding"]);return r!=null&&c(n,["mimeType"],r),n}function L0(l){const n={},o=u(l,["gcsUri"]);o!=null&&c(n,["uri"],o);const s=u(l,["bytesBase64Encoded"]);s!=null&&c(n,["videoBytes"],Tr(s));const r=u(l,["mimeType"]);return r!=null&&c(n,["mimeType"],r),n}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */var Hm;(function(l){l.OUTCOME_UNSPECIFIED="OUTCOME_UNSPECIFIED",l.OUTCOME_OK="OUTCOME_OK",l.OUTCOME_FAILED="OUTCOME_FAILED",l.OUTCOME_DEADLINE_EXCEEDED="OUTCOME_DEADLINE_EXCEEDED"})(Hm||(Hm={}));var zm;(function(l){l.LANGUAGE_UNSPECIFIED="LANGUAGE_UNSPECIFIED",l.PYTHON="PYTHON"})(zm||(zm={}));var Bt;(function(l){l.TYPE_UNSPECIFIED="TYPE_UNSPECIFIED",l.STRING="STRING",l.NUMBER="NUMBER",l.INTEGER="INTEGER",l.BOOLEAN="BOOLEAN",l.ARRAY="ARRAY",l.OBJECT="OBJECT",l.NULL="NULL"})(Bt||(Bt={}));var Vm;(function(l){l.HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",l.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",l.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT",l.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",l.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",l.HARM_CATEGORY_CIVIC_INTEGRITY="HARM_CATEGORY_CIVIC_INTEGRITY",l.HARM_CATEGORY_IMAGE_HATE="HARM_CATEGORY_IMAGE_HATE",l.HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT="HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT",l.HARM_CATEGORY_IMAGE_HARASSMENT="HARM_CATEGORY_IMAGE_HARASSMENT",l.HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT="HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT"})(Vm||(Vm={}));var Bm;(function(l){l.HARM_BLOCK_METHOD_UNSPECIFIED="HARM_BLOCK_METHOD_UNSPECIFIED",l.SEVERITY="SEVERITY",l.PROBABILITY="PROBABILITY"})(Bm||(Bm={}));var Pm;(function(l){l.HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",l.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",l.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",l.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",l.BLOCK_NONE="BLOCK_NONE",l.OFF="OFF"})(Pm||(Pm={}));var km;(function(l){l.MODE_UNSPECIFIED="MODE_UNSPECIFIED",l.MODE_DYNAMIC="MODE_DYNAMIC"})(km||(km={}));var Ym;(function(l){l.AUTH_TYPE_UNSPECIFIED="AUTH_TYPE_UNSPECIFIED",l.NO_AUTH="NO_AUTH",l.API_KEY_AUTH="API_KEY_AUTH",l.HTTP_BASIC_AUTH="HTTP_BASIC_AUTH",l.GOOGLE_SERVICE_ACCOUNT_AUTH="GOOGLE_SERVICE_ACCOUNT_AUTH",l.OAUTH="OAUTH",l.OIDC_AUTH="OIDC_AUTH"})(Ym||(Ym={}));var Jm;(function(l){l.API_SPEC_UNSPECIFIED="API_SPEC_UNSPECIFIED",l.SIMPLE_SEARCH="SIMPLE_SEARCH",l.ELASTIC_SEARCH="ELASTIC_SEARCH"})(Jm||(Jm={}));var Om;(function(l){l.URL_RETRIEVAL_STATUS_UNSPECIFIED="URL_RETRIEVAL_STATUS_UNSPECIFIED",l.URL_RETRIEVAL_STATUS_SUCCESS="URL_RETRIEVAL_STATUS_SUCCESS",l.URL_RETRIEVAL_STATUS_ERROR="URL_RETRIEVAL_STATUS_ERROR",l.URL_RETRIEVAL_STATUS_PAYWALL="URL_RETRIEVAL_STATUS_PAYWALL",l.URL_RETRIEVAL_STATUS_UNSAFE="URL_RETRIEVAL_STATUS_UNSAFE"})(Om||(Om={}));var Fm;(function(l){l.FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",l.STOP="STOP",l.MAX_TOKENS="MAX_TOKENS",l.SAFETY="SAFETY",l.RECITATION="RECITATION",l.LANGUAGE="LANGUAGE",l.OTHER="OTHER",l.BLOCKLIST="BLOCKLIST",l.PROHIBITED_CONTENT="PROHIBITED_CONTENT",l.SPII="SPII",l.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",l.IMAGE_SAFETY="IMAGE_SAFETY",l.UNEXPECTED_TOOL_CALL="UNEXPECTED_TOOL_CALL",l.IMAGE_PROHIBITED_CONTENT="IMAGE_PROHIBITED_CONTENT",l.NO_IMAGE="NO_IMAGE"})(Fm||(Fm={}));var Xm;(function(l){l.HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",l.NEGLIGIBLE="NEGLIGIBLE",l.LOW="LOW",l.MEDIUM="MEDIUM",l.HIGH="HIGH"})(Xm||(Xm={}));var Km;(function(l){l.HARM_SEVERITY_UNSPECIFIED="HARM_SEVERITY_UNSPECIFIED",l.HARM_SEVERITY_NEGLIGIBLE="HARM_SEVERITY_NEGLIGIBLE",l.HARM_SEVERITY_LOW="HARM_SEVERITY_LOW",l.HARM_SEVERITY_MEDIUM="HARM_SEVERITY_MEDIUM",l.HARM_SEVERITY_HIGH="HARM_SEVERITY_HIGH"})(Km||(Km={}));var Qm;(function(l){l.BLOCKED_REASON_UNSPECIFIED="BLOCKED_REASON_UNSPECIFIED",l.SAFETY="SAFETY",l.OTHER="OTHER",l.BLOCKLIST="BLOCKLIST",l.PROHIBITED_CONTENT="PROHIBITED_CONTENT",l.IMAGE_SAFETY="IMAGE_SAFETY"})(Qm||(Qm={}));var Zm;(function(l){l.TRAFFIC_TYPE_UNSPECIFIED="TRAFFIC_TYPE_UNSPECIFIED",l.ON_DEMAND="ON_DEMAND",l.PROVISIONED_THROUGHPUT="PROVISIONED_THROUGHPUT"})(Zm||(Zm={}));var La;(function(l){l.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",l.TEXT="TEXT",l.IMAGE="IMAGE",l.AUDIO="AUDIO"})(La||(La={}));var $m;(function(l){l.MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",l.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",l.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",l.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH"})($m||($m={}));var cr;(function(l){l.JOB_STATE_UNSPECIFIED="JOB_STATE_UNSPECIFIED",l.JOB_STATE_QUEUED="JOB_STATE_QUEUED",l.JOB_STATE_PENDING="JOB_STATE_PENDING",l.JOB_STATE_RUNNING="JOB_STATE_RUNNING",l.JOB_STATE_SUCCEEDED="JOB_STATE_SUCCEEDED",l.JOB_STATE_FAILED="JOB_STATE_FAILED",l.JOB_STATE_CANCELLING="JOB_STATE_CANCELLING",l.JOB_STATE_CANCELLED="JOB_STATE_CANCELLED",l.JOB_STATE_PAUSED="JOB_STATE_PAUSED",l.JOB_STATE_EXPIRED="JOB_STATE_EXPIRED",l.JOB_STATE_UPDATING="JOB_STATE_UPDATING",l.JOB_STATE_PARTIALLY_SUCCEEDED="JOB_STATE_PARTIALLY_SUCCEEDED"})(cr||(cr={}));var Wm;(function(l){l.TUNING_MODE_UNSPECIFIED="TUNING_MODE_UNSPECIFIED",l.TUNING_MODE_FULL="TUNING_MODE_FULL",l.TUNING_MODE_PEFT_ADAPTER="TUNING_MODE_PEFT_ADAPTER"})(Wm||(Wm={}));var jm;(function(l){l.ADAPTER_SIZE_UNSPECIFIED="ADAPTER_SIZE_UNSPECIFIED",l.ADAPTER_SIZE_ONE="ADAPTER_SIZE_ONE",l.ADAPTER_SIZE_TWO="ADAPTER_SIZE_TWO",l.ADAPTER_SIZE_FOUR="ADAPTER_SIZE_FOUR",l.ADAPTER_SIZE_EIGHT="ADAPTER_SIZE_EIGHT",l.ADAPTER_SIZE_SIXTEEN="ADAPTER_SIZE_SIXTEEN",l.ADAPTER_SIZE_THIRTY_TWO="ADAPTER_SIZE_THIRTY_TWO"})(jm||(jm={}));var ep;(function(l){l.TUNING_TASK_UNSPECIFIED="TUNING_TASK_UNSPECIFIED",l.TUNING_TASK_I2V="TUNING_TASK_I2V",l.TUNING_TASK_T2V="TUNING_TASK_T2V"})(ep||(ep={}));var tp;(function(l){l.FEATURE_SELECTION_PREFERENCE_UNSPECIFIED="FEATURE_SELECTION_PREFERENCE_UNSPECIFIED",l.PRIORITIZE_QUALITY="PRIORITIZE_QUALITY",l.BALANCED="BALANCED",l.PRIORITIZE_COST="PRIORITIZE_COST"})(tp||(tp={}));var np;(function(l){l.UNSPECIFIED="UNSPECIFIED",l.BLOCKING="BLOCKING",l.NON_BLOCKING="NON_BLOCKING"})(np||(np={}));var lp;(function(l){l.MODE_UNSPECIFIED="MODE_UNSPECIFIED",l.MODE_DYNAMIC="MODE_DYNAMIC"})(lp||(lp={}));var ip;(function(l){l.ENVIRONMENT_UNSPECIFIED="ENVIRONMENT_UNSPECIFIED",l.ENVIRONMENT_BROWSER="ENVIRONMENT_BROWSER"})(ip||(ip={}));var op;(function(l){l.MODE_UNSPECIFIED="MODE_UNSPECIFIED",l.AUTO="AUTO",l.ANY="ANY",l.NONE="NONE",l.VALIDATED="VALIDATED"})(op||(op={}));var ap;(function(l){l.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",l.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",l.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",l.BLOCK_NONE="BLOCK_NONE"})(ap||(ap={}));var sp;(function(l){l.DONT_ALLOW="DONT_ALLOW",l.ALLOW_ADULT="ALLOW_ADULT",l.ALLOW_ALL="ALLOW_ALL"})(sp||(sp={}));var up;(function(l){l.auto="auto",l.en="en",l.ja="ja",l.ko="ko",l.hi="hi",l.zh="zh",l.pt="pt",l.es="es"})(up||(up={}));var rp;(function(l){l.MASK_MODE_DEFAULT="MASK_MODE_DEFAULT",l.MASK_MODE_USER_PROVIDED="MASK_MODE_USER_PROVIDED",l.MASK_MODE_BACKGROUND="MASK_MODE_BACKGROUND",l.MASK_MODE_FOREGROUND="MASK_MODE_FOREGROUND",l.MASK_MODE_SEMANTIC="MASK_MODE_SEMANTIC"})(rp||(rp={}));var cp;(function(l){l.CONTROL_TYPE_DEFAULT="CONTROL_TYPE_DEFAULT",l.CONTROL_TYPE_CANNY="CONTROL_TYPE_CANNY",l.CONTROL_TYPE_SCRIBBLE="CONTROL_TYPE_SCRIBBLE",l.CONTROL_TYPE_FACE_MESH="CONTROL_TYPE_FACE_MESH"})(cp||(cp={}));var fp;(function(l){l.SUBJECT_TYPE_DEFAULT="SUBJECT_TYPE_DEFAULT",l.SUBJECT_TYPE_PERSON="SUBJECT_TYPE_PERSON",l.SUBJECT_TYPE_ANIMAL="SUBJECT_TYPE_ANIMAL",l.SUBJECT_TYPE_PRODUCT="SUBJECT_TYPE_PRODUCT"})(fp||(fp={}));var dp;(function(l){l.EDIT_MODE_DEFAULT="EDIT_MODE_DEFAULT",l.EDIT_MODE_INPAINT_REMOVAL="EDIT_MODE_INPAINT_REMOVAL",l.EDIT_MODE_INPAINT_INSERTION="EDIT_MODE_INPAINT_INSERTION",l.EDIT_MODE_OUTPAINT="EDIT_MODE_OUTPAINT",l.EDIT_MODE_CONTROLLED_EDITING="EDIT_MODE_CONTROLLED_EDITING",l.EDIT_MODE_STYLE="EDIT_MODE_STYLE",l.EDIT_MODE_BGSWAP="EDIT_MODE_BGSWAP",l.EDIT_MODE_PRODUCT_IMAGE="EDIT_MODE_PRODUCT_IMAGE"})(dp||(dp={}));var mp;(function(l){l.FOREGROUND="FOREGROUND",l.BACKGROUND="BACKGROUND",l.PROMPT="PROMPT",l.SEMANTIC="SEMANTIC",l.INTERACTIVE="INTERACTIVE"})(mp||(mp={}));var pp;(function(l){l.ASSET="ASSET",l.STYLE="STYLE"})(pp||(pp={}));var hp;(function(l){l.INSERT="INSERT",l.REMOVE="REMOVE",l.REMOVE_STATIC="REMOVE_STATIC",l.OUTPAINT="OUTPAINT"})(hp||(hp={}));var gp;(function(l){l.OPTIMIZED="OPTIMIZED",l.LOSSLESS="LOSSLESS"})(gp||(gp={}));var yp;(function(l){l.STATE_UNSPECIFIED="STATE_UNSPECIFIED",l.PROCESSING="PROCESSING",l.ACTIVE="ACTIVE",l.FAILED="FAILED"})(yp||(yp={}));var vp;(function(l){l.SOURCE_UNSPECIFIED="SOURCE_UNSPECIFIED",l.UPLOADED="UPLOADED",l.GENERATED="GENERATED"})(vp||(vp={}));var Tp;(function(l){l.TURN_COMPLETE_REASON_UNSPECIFIED="TURN_COMPLETE_REASON_UNSPECIFIED",l.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",l.RESPONSE_REJECTED="RESPONSE_REJECTED",l.NEED_MORE_INPUT="NEED_MORE_INPUT"})(Tp||(Tp={}));var Sp;(function(l){l.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",l.TEXT="TEXT",l.IMAGE="IMAGE",l.VIDEO="VIDEO",l.AUDIO="AUDIO",l.DOCUMENT="DOCUMENT"})(Sp||(Sp={}));var Ep;(function(l){l.START_SENSITIVITY_UNSPECIFIED="START_SENSITIVITY_UNSPECIFIED",l.START_SENSITIVITY_HIGH="START_SENSITIVITY_HIGH",l.START_SENSITIVITY_LOW="START_SENSITIVITY_LOW"})(Ep||(Ep={}));var _p;(function(l){l.END_SENSITIVITY_UNSPECIFIED="END_SENSITIVITY_UNSPECIFIED",l.END_SENSITIVITY_HIGH="END_SENSITIVITY_HIGH",l.END_SENSITIVITY_LOW="END_SENSITIVITY_LOW"})(_p||(_p={}));var Cp;(function(l){l.ACTIVITY_HANDLING_UNSPECIFIED="ACTIVITY_HANDLING_UNSPECIFIED",l.START_OF_ACTIVITY_INTERRUPTS="START_OF_ACTIVITY_INTERRUPTS",l.NO_INTERRUPTION="NO_INTERRUPTION"})(Cp||(Cp={}));var Ap;(function(l){l.TURN_COVERAGE_UNSPECIFIED="TURN_COVERAGE_UNSPECIFIED",l.TURN_INCLUDES_ONLY_ACTIVITY="TURN_INCLUDES_ONLY_ACTIVITY",l.TURN_INCLUDES_ALL_INPUT="TURN_INCLUDES_ALL_INPUT"})(Ap||(Ap={}));var xp;(function(l){l.SCHEDULING_UNSPECIFIED="SCHEDULING_UNSPECIFIED",l.SILENT="SILENT",l.WHEN_IDLE="WHEN_IDLE",l.INTERRUPT="INTERRUPT"})(xp||(xp={}));var Mp;(function(l){l.SCALE_UNSPECIFIED="SCALE_UNSPECIFIED",l.C_MAJOR_A_MINOR="C_MAJOR_A_MINOR",l.D_FLAT_MAJOR_B_FLAT_MINOR="D_FLAT_MAJOR_B_FLAT_MINOR",l.D_MAJOR_B_MINOR="D_MAJOR_B_MINOR",l.E_FLAT_MAJOR_C_MINOR="E_FLAT_MAJOR_C_MINOR",l.E_MAJOR_D_FLAT_MINOR="E_MAJOR_D_FLAT_MINOR",l.F_MAJOR_D_MINOR="F_MAJOR_D_MINOR",l.G_FLAT_MAJOR_E_FLAT_MINOR="G_FLAT_MAJOR_E_FLAT_MINOR",l.G_MAJOR_E_MINOR="G_MAJOR_E_MINOR",l.A_FLAT_MAJOR_F_MINOR="A_FLAT_MAJOR_F_MINOR",l.A_MAJOR_G_FLAT_MINOR="A_MAJOR_G_FLAT_MINOR",l.B_FLAT_MAJOR_G_MINOR="B_FLAT_MAJOR_G_MINOR",l.B_MAJOR_A_FLAT_MINOR="B_MAJOR_A_FLAT_MINOR"})(Mp||(Mp={}));var Np;(function(l){l.MUSIC_GENERATION_MODE_UNSPECIFIED="MUSIC_GENERATION_MODE_UNSPECIFIED",l.QUALITY="QUALITY",l.DIVERSITY="DIVERSITY",l.VOCALIZATION="VOCALIZATION"})(Np||(Np={}));var ci;(function(l){l.PLAYBACK_CONTROL_UNSPECIFIED="PLAYBACK_CONTROL_UNSPECIFIED",l.PLAY="PLAY",l.PAUSE="PAUSE",l.STOP="STOP",l.RESET_CONTEXT="RESET_CONTEXT"})(ci||(ci={}));class fr{constructor(n){const o={};for(const s of n.headers.entries())o[s[0]]=s[1];this.headers=o,this.responseInternal=n}json(){return this.responseInternal.json()}}class mo{get text(){var n,o,s,r,d,p,g,y;if(((r=(s=(o=(n=this.candidates)===null||n===void 0?void 0:n[0])===null||o===void 0?void 0:o.content)===null||s===void 0?void 0:s.parts)===null||r===void 0?void 0:r.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning text from the first one.");let h="",T=!1;const S=[];for(const _ of(y=(g=(p=(d=this.candidates)===null||d===void 0?void 0:d[0])===null||p===void 0?void 0:p.content)===null||g===void 0?void 0:g.parts)!==null&&y!==void 0?y:[]){for(const[R,H]of Object.entries(_))R!=="text"&&R!=="thought"&&(H!==null||H!==void 0)&&S.push(R);if(typeof _.text=="string"){if(typeof _.thought=="boolean"&&_.thought)continue;T=!0,h+=_.text}}return S.length>0&&console.warn(`there are non-text parts ${S} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),T?h:void 0}get data(){var n,o,s,r,d,p,g,y;if(((r=(s=(o=(n=this.candidates)===null||n===void 0?void 0:n[0])===null||o===void 0?void 0:o.content)===null||s===void 0?void 0:s.parts)===null||r===void 0?void 0:r.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning data from the first one.");let h="";const T=[];for(const S of(y=(g=(p=(d=this.candidates)===null||d===void 0?void 0:d[0])===null||p===void 0?void 0:p.content)===null||g===void 0?void 0:g.parts)!==null&&y!==void 0?y:[]){for(const[_,R]of Object.entries(S))_!=="inlineData"&&(R!==null||R!==void 0)&&T.push(_);S.inlineData&&typeof S.inlineData.data=="string"&&(h+=atob(S.inlineData.data))}return T.length>0&&console.warn(`there are non-data parts ${T} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),h.length>0?btoa(h):void 0}get functionCalls(){var n,o,s,r,d,p,g,y;if(((r=(s=(o=(n=this.candidates)===null||n===void 0?void 0:n[0])===null||o===void 0?void 0:o.content)===null||s===void 0?void 0:s.parts)===null||r===void 0?void 0:r.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning function calls from the first one.");const h=(y=(g=(p=(d=this.candidates)===null||d===void 0?void 0:d[0])===null||p===void 0?void 0:p.content)===null||g===void 0?void 0:g.parts)===null||y===void 0?void 0:y.filter(T=>T.functionCall).map(T=>T.functionCall).filter(T=>T!==void 0);if((h==null?void 0:h.length)!==0)return h}get executableCode(){var n,o,s,r,d,p,g,y,h;if(((r=(s=(o=(n=this.candidates)===null||n===void 0?void 0:n[0])===null||o===void 0?void 0:o.content)===null||s===void 0?void 0:s.parts)===null||r===void 0?void 0:r.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning executable code from the first one.");const T=(y=(g=(p=(d=this.candidates)===null||d===void 0?void 0:d[0])===null||p===void 0?void 0:p.content)===null||g===void 0?void 0:g.parts)===null||y===void 0?void 0:y.filter(S=>S.executableCode).map(S=>S.executableCode).filter(S=>S!==void 0);if((T==null?void 0:T.length)!==0)return(h=T==null?void 0:T[0])===null||h===void 0?void 0:h.code}get codeExecutionResult(){var n,o,s,r,d,p,g,y,h;if(((r=(s=(o=(n=this.candidates)===null||n===void 0?void 0:n[0])===null||o===void 0?void 0:o.content)===null||s===void 0?void 0:s.parts)===null||r===void 0?void 0:r.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning code execution result from the first one.");const T=(y=(g=(p=(d=this.candidates)===null||d===void 0?void 0:d[0])===null||p===void 0?void 0:p.content)===null||g===void 0?void 0:g.parts)===null||y===void 0?void 0:y.filter(S=>S.codeExecutionResult).map(S=>S.codeExecutionResult).filter(S=>S!==void 0);if((T==null?void 0:T.length)!==0)return(h=T==null?void 0:T[0])===null||h===void 0?void 0:h.output}}class Rp{}class bp{}class G0{}class H0{}class z0{}class V0{}class Dp{}class wp{}class Up{}class B0{}class Ga{_fromAPIResponse({apiResponse:n,isVertexAI:o}){const s=new Ga;let r;const d=n;return o?r=N0(d):r=M0(d),Object.assign(s,r),s}}class Ip{}class qp{}class Lp{}class P0{}class k0{}class Y0{}class Gp{}class J0{get text(){var n,o,s;let r="",d=!1;const p=[];for(const g of(s=(o=(n=this.serverContent)===null||n===void 0?void 0:n.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&&p.push(y);if(typeof g.text=="string"){if(typeof g.thought=="boolean"&&g.thought)continue;d=!0,r+=g.text}}return p.length>0&&console.warn(`there are non-text parts ${p} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),d?r:void 0}get data(){var n,o,s;let r="";const d=[];for(const p of(s=(o=(n=this.serverContent)===null||n===void 0?void 0:n.modelTurn)===null||o===void 0?void 0:o.parts)!==null&&s!==void 0?s:[]){for(const[g,y]of Object.entries(p))g!=="inlineData"&&y!==null&&d.push(g);p.inlineData&&typeof p.inlineData.data=="string"&&(r+=atob(p.inlineData.data))}return d.length>0&&console.warn(`there are non-data parts ${d} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),r.length>0?btoa(r):void 0}}class O0{get audioChunk(){if(this.serverContent&&this.serverContent.audioChunks&&this.serverContent.audioChunks.length>0)return this.serverContent.audioChunks[0]}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function we(l,n){if(!n||typeof n!="string")throw new Error("model is required and must be a string");if(l.isVertexAI()){if(n.startsWith("publishers/")||n.startsWith("projects/")||n.startsWith("models/"))return n;if(n.indexOf("/")>=0){const o=n.split("/",2);return`publishers/${o[0]}/models/${o[1]}`}else return`publishers/google/models/${n}`}else return n.startsWith("models/")||n.startsWith("tunedModels/")?n:`models/${n}`}function ih(l,n){const o=we(l,n);return o?o.startsWith("publishers/")&&l.isVertexAI()?`projects/${l.getProject()}/locations/${l.getLocation()}/${o}`:o.startsWith("models/")&&l.isVertexAI()?`projects/${l.getProject()}/locations/${l.getLocation()}/publishers/google/${o}`:o:""}function oh(l){return Array.isArray(l)?l.map(n=>Ha(n)):[Ha(l)]}function Ha(l){if(typeof l=="object"&&l!==null)return l;throw new Error(`Could not parse input as Blob. Unsupported blob type: ${typeof l}`)}function ah(l){const n=Ha(l);if(n.mimeType&&n.mimeType.startsWith("image/"))return n;throw new Error(`Unsupported mime type: ${n.mimeType}`)}function sh(l){const n=Ha(l);if(n.mimeType&&n.mimeType.startsWith("audio/"))return n;throw new Error(`Unsupported mime type: ${n.mimeType}`)}function Hp(l){if(l==null)throw new Error("PartUnion is required");if(typeof l=="object")return l;if(typeof l=="string")return{text:l};throw new Error(`Unsupported part type: ${typeof l}`)}function uh(l){if(l==null||Array.isArray(l)&&l.length===0)throw new Error("PartListUnion is required");return Array.isArray(l)?l.map(n=>Hp(n)):[Hp(l)]}function dr(l){return l!=null&&typeof l=="object"&&"parts"in l&&Array.isArray(l.parts)}function zp(l){return l!=null&&typeof l=="object"&&"functionCall"in l}function Vp(l){return l!=null&&typeof l=="object"&&"functionResponse"in l}function St(l){if(l==null)throw new Error("ContentUnion is required");return dr(l)?l:{role:"user",parts:uh(l)}}function Sr(l,n){if(!n)return[];if(l.isVertexAI()&&Array.isArray(n))return n.flatMap(o=>{const s=St(o);return s.parts&&s.parts.length>0&&s.parts[0].text!==void 0?[s.parts[0].text]:[]});if(l.isVertexAI()){const o=St(n);return o.parts&&o.parts.length>0&&o.parts[0].text!==void 0?[o.parts[0].text]:[]}return Array.isArray(n)?n.map(o=>St(o)):[St(n)]}function $t(l){if(l==null||Array.isArray(l)&&l.length===0)throw new Error("contents are required");if(!Array.isArray(l)){if(zp(l)||Vp(l))throw new Error("To specify functionCall or functionResponse parts, please wrap them in a Content object, specifying the role for them");return[St(l)]}const n=[],o=[],s=dr(l[0]);for(const r of l){const d=dr(r);if(d!=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(d)n.push(r);else{if(zp(r)||Vp(r))throw new Error("To specify functionCall or functionResponse parts, please wrap them, and any other parts, in Content objects as appropriate, specifying the role for them");o.push(r)}}return s||n.push({role:"user",parts:uh(o)}),n}function F0(l,n){l.includes("null")&&(n.nullable=!0);const o=l.filter(s=>s!=="null");if(o.length===1)n.type=Object.values(Bt).includes(o[0].toUpperCase())?o[0].toUpperCase():Bt.TYPE_UNSPECIFIED;else{n.anyOf=[];for(const s of o)n.anyOf.push({type:Object.values(Bt).includes(s.toUpperCase())?s.toUpperCase():Bt.TYPE_UNSPECIFIED})}}function fi(l){const n={},o=["items"],s=["anyOf"],r=["properties"];if(l.type&&l.anyOf)throw new Error("type and anyOf cannot be both populated.");const d=l.anyOf;d!=null&&d.length==2&&(d[0].type==="null"?(n.nullable=!0,l=d[1]):d[1].type==="null"&&(n.nullable=!0,l=d[0])),l.type instanceof Array&&F0(l.type,n);for(const[p,g]of Object.entries(l))if(g!=null)if(p=="type"){if(g==="null")throw new Error("type: null can not be the only possible type for the field.");if(g instanceof Array)continue;n.type=Object.values(Bt).includes(g.toUpperCase())?g.toUpperCase():Bt.TYPE_UNSPECIFIED}else if(o.includes(p))n[p]=fi(g);else if(s.includes(p)){const y=[];for(const h of g){if(h.type=="null"){n.nullable=!0;continue}y.push(fi(h))}n[p]=y}else if(r.includes(p)){const y={};for(const[h,T]of Object.entries(g))y[h]=fi(T);n[p]=y}else{if(p==="additionalProperties")continue;n[p]=g}return n}function Er(l){return fi(l)}function _r(l){if(typeof l=="object")return l;if(typeof l=="string")return{voiceConfig:{prebuiltVoiceConfig:{voiceName:l}}};throw new Error(`Unsupported speechConfig type: ${typeof l}`)}function Cr(l){if("multiSpeakerVoiceConfig"in l)throw new Error("multiSpeakerVoiceConfig is not supported in the live API.");return l}function pi(l){if(l.functionDeclarations)for(const n of l.functionDeclarations)n.parameters&&(Object.keys(n.parameters).includes("$schema")?n.parametersJsonSchema||(n.parametersJsonSchema=n.parameters,delete n.parameters):n.parameters=fi(n.parameters)),n.response&&(Object.keys(n.response).includes("$schema")?n.responseJsonSchema||(n.responseJsonSchema=n.response,delete n.response):n.response=fi(n.response));return l}function hi(l){if(l==null)throw new Error("tools is required");if(!Array.isArray(l))throw new Error("tools is required and must be an array of Tools");const n=[];for(const o of l)n.push(o);return n}function X0(l,n,o,s=1){const r=!n.startsWith(`${o}/`)&&n.split("/").length===s;return l.isVertexAI()?n.startsWith("projects/")?n:n.startsWith("locations/")?`projects/${l.getProject()}/${n}`:n.startsWith(`${o}/`)?`projects/${l.getProject()}/locations/${l.getLocation()}/${n}`:r?`projects/${l.getProject()}/locations/${l.getLocation()}/${o}/${n}`:n:r?`${o}/${n}`:n}function Dn(l,n){if(typeof n!="string")throw new Error("name must be a string");return X0(l,n,"cachedContents")}function rh(l){switch(l){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 l}}function nl(l){return Tr(l)}function K0(l){return l!=null&&typeof l=="object"&&"name"in l}function Q0(l){return l!=null&&typeof l=="object"&&"video"in l}function Z0(l){return l!=null&&typeof l=="object"&&"uri"in l}function ch(l){var n;let o;if(K0(l)&&(o=l.name),!(Z0(l)&&(o=l.uri,o===void 0))&&!(Q0(l)&&(o=(n=l.video)===null||n===void 0?void 0:n.uri,o===void 0))){if(typeof l=="string"&&(o=l),o===void 0)throw new Error("Could not extract file name from the provided input.");if(o.startsWith("https://")){const r=o.split("files/")[1].match(/[a-z0-9]+/);if(r===null)throw new Error(`Could not extract file name from URI ${o}`);o=r[0]}else o.startsWith("files/")&&(o=o.split("files/")[1]);return o}}function fh(l,n){let o;return l.isVertexAI()?o=n?"publishers/google/models":"models":o=n?"models":"tunedModels",o}function dh(l){for(const n of["models","tunedModels","publisherModels"])if($0(l,n))return l[n];return[]}function $0(l,n){return l!==null&&typeof l=="object"&&n in l}function W0(l,n={}){const o=l,s={name:o.name,description:o.description,parametersJsonSchema:o.inputSchema};return o.outputSchema&&(s.responseJsonSchema=o.outputSchema),n.behavior&&(s.behavior=n.behavior),{functionDeclarations:[s]}}function j0(l,n={}){const o=[],s=new Set;for(const r of l){const d=r.name;if(s.has(d))throw new Error(`Duplicate function name ${d} found in MCP tools. Please ensure function names are unique.`);s.add(d);const p=W0(r,n);p.functionDeclarations&&o.push(...p.functionDeclarations)}return{functionDeclarations:o}}function mh(l,n){let o;if(typeof n=="string")if(l.isVertexAI())if(n.startsWith("gs://"))o={format:"jsonl",gcsUri:[n]};else if(n.startsWith("bq://"))o={format:"bigquery",bigqueryUri:n};else throw new Error(`Unsupported string source for Vertex AI: ${n}`);else if(n.startsWith("files/"))o={fileName:n};else throw new Error(`Unsupported string source for Gemini API: ${n}`);else if(Array.isArray(n)){if(l.isVertexAI())throw new Error("InlinedRequest[] is not supported in Vertex AI.");o={inlinedRequests:n}}else o=n;const s=[o.gcsUri,o.bigqueryUri].filter(Boolean).length,r=[o.inlinedRequests,o.fileName].filter(Boolean).length;if(l.isVertexAI()){if(r>0||s!==1)throw new Error("Exactly one of `gcsUri` or `bigqueryUri` must be set for Vertex AI.")}else if(s>0||r!==1)throw new Error("Exactly one of `inlinedRequests`, `fileName`, must be set for Gemini API.");return o}function ev(l){if(typeof l!="string")return l;const n=l;if(n.startsWith("gs://"))return{format:"jsonl",gcsUri:n};if(n.startsWith("bq://"))return{format:"bigquery",bigqueryUri:n};throw new Error(`Unsupported destination: ${n}`)}function ph(l){if(typeof l!="object"||l===null)return{};const n=l,o=n.inlinedResponses;if(typeof o!="object"||o===null)return l;const r=o.inlinedResponses;if(!Array.isArray(r)||r.length===0)return l;let d=!1;for(const p of r){if(typeof p!="object"||p===null)continue;const y=p.response;if(typeof y!="object"||y===null)continue;if(y.embedding!==void 0){d=!0;break}}return d&&(n.inlinedEmbedContentResponses=n.inlinedResponses,delete n.inlinedResponses),l}function gi(l,n){const o=n;if(!l.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 hh(l){const n=l;return n==="BATCH_STATE_UNSPECIFIED"?"JOB_STATE_UNSPECIFIED":n==="BATCH_STATE_PENDING"?"JOB_STATE_PENDING":n==="BATCH_STATE_RUNNING"?"JOB_STATE_RUNNING":n==="BATCH_STATE_SUCCEEDED"?"JOB_STATE_SUCCEEDED":n==="BATCH_STATE_FAILED"?"JOB_STATE_FAILED":n==="BATCH_STATE_CANCELLED"?"JOB_STATE_CANCELLED":n==="BATCH_STATE_EXPIRED"?"JOB_STATE_EXPIRED":n}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function tv(l){const n={},o=u(l,["responsesFile"]);o!=null&&c(n,["fileName"],o);const s=u(l,["inlinedResponses","inlinedResponses"]);if(s!=null){let d=s;Array.isArray(d)&&(d=d.map(p=>Uv(p))),c(n,["inlinedResponses"],d)}const r=u(l,["inlinedEmbedContentResponses","inlinedResponses"]);if(r!=null){let d=r;Array.isArray(d)&&(d=d.map(p=>p)),c(n,["inlinedEmbedContentResponses"],d)}return n}function nv(l){const n={},o=u(l,["predictionsFormat"]);o!=null&&c(n,["format"],o);const s=u(l,["gcsDestination","outputUriPrefix"]);s!=null&&c(n,["gcsUri"],s);const r=u(l,["bigqueryDestination","outputUri"]);return r!=null&&c(n,["bigqueryUri"],r),n}function lv(l){const n={},o=u(l,["format"]);o!=null&&c(n,["predictionsFormat"],o);const s=u(l,["gcsUri"]);s!=null&&c(n,["gcsDestination","outputUriPrefix"],s);const r=u(l,["bigqueryUri"]);if(r!=null&&c(n,["bigqueryDestination","outputUri"],r),u(l,["fileName"])!==void 0)throw new Error("fileName parameter is not supported in Vertex AI.");if(u(l,["inlinedResponses"])!==void 0)throw new Error("inlinedResponses parameter is not supported in Vertex AI.");if(u(l,["inlinedEmbedContentResponses"])!==void 0)throw new Error("inlinedEmbedContentResponses parameter is not supported in Vertex AI.");return n}function Ia(l){const n={},o=u(l,["name"]);o!=null&&c(n,["name"],o);const s=u(l,["metadata","displayName"]);s!=null&&c(n,["displayName"],s);const r=u(l,["metadata","state"]);r!=null&&c(n,["state"],hh(r));const d=u(l,["metadata","createTime"]);d!=null&&c(n,["createTime"],d);const p=u(l,["metadata","endTime"]);p!=null&&c(n,["endTime"],p);const g=u(l,["metadata","updateTime"]);g!=null&&c(n,["updateTime"],g);const y=u(l,["metadata","model"]);y!=null&&c(n,["model"],y);const h=u(l,["metadata","output"]);return h!=null&&c(n,["dest"],tv(ph(h))),n}function mr(l){const n={},o=u(l,["name"]);o!=null&&c(n,["name"],o);const s=u(l,["displayName"]);s!=null&&c(n,["displayName"],s);const r=u(l,["state"]);r!=null&&c(n,["state"],hh(r));const d=u(l,["error"]);d!=null&&c(n,["error"],d);const p=u(l,["createTime"]);p!=null&&c(n,["createTime"],p);const g=u(l,["startTime"]);g!=null&&c(n,["startTime"],g);const y=u(l,["endTime"]);y!=null&&c(n,["endTime"],y);const h=u(l,["updateTime"]);h!=null&&c(n,["updateTime"],h);const T=u(l,["model"]);T!=null&&c(n,["model"],T);const S=u(l,["inputConfig"]);S!=null&&c(n,["src"],iv(S));const _=u(l,["outputConfig"]);return _!=null&&c(n,["dest"],nv(ph(_))),n}function iv(l){const n={},o=u(l,["instancesFormat"]);o!=null&&c(n,["format"],o);const s=u(l,["gcsSource","uris"]);s!=null&&c(n,["gcsUri"],s);const r=u(l,["bigquerySource","inputUri"]);return r!=null&&c(n,["bigqueryUri"],r),n}function ov(l,n){const o={};if(u(n,["format"])!==void 0)throw new Error("format parameter is not supported in Gemini API.");if(u(n,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");if(u(n,["bigqueryUri"])!==void 0)throw new Error("bigqueryUri parameter is not supported in Gemini API.");const s=u(n,["fileName"]);s!=null&&c(o,["fileName"],s);const r=u(n,["inlinedRequests"]);if(r!=null){let d=r;Array.isArray(d)&&(d=d.map(p=>wv(l,p))),c(o,["requests","requests"],d)}return o}function av(l){const n={},o=u(l,["format"]);o!=null&&c(n,["instancesFormat"],o);const s=u(l,["gcsUri"]);s!=null&&c(n,["gcsSource","uris"],s);const r=u(l,["bigqueryUri"]);if(r!=null&&c(n,["bigquerySource","inputUri"],r),u(l,["fileName"])!==void 0)throw new Error("fileName parameter is not supported in Vertex AI.");if(u(l,["inlinedRequests"])!==void 0)throw new Error("inlinedRequests parameter is not supported in Vertex AI.");return n}function sv(l){const n={};if(u(l,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=u(l,["data"]);o!=null&&c(n,["data"],o);const s=u(l,["mimeType"]);return s!=null&&c(n,["mimeType"],s),n}function uv(l,n){const o={},s=u(n,["name"]);return s!=null&&c(o,["_url","name"],gi(l,s)),o}function rv(l,n){const o={},s=u(n,["name"]);return s!=null&&c(o,["_url","name"],gi(l,s)),o}function cv(l){const n={},o=u(l,["content"]);o!=null&&c(n,["content"],o);const s=u(l,["citationMetadata"]);s!=null&&c(n,["citationMetadata"],fv(s));const r=u(l,["tokenCount"]);r!=null&&c(n,["tokenCount"],r);const d=u(l,["finishReason"]);d!=null&&c(n,["finishReason"],d);const p=u(l,["urlContextMetadata"]);p!=null&&c(n,["urlContextMetadata"],p);const g=u(l,["avgLogprobs"]);g!=null&&c(n,["avgLogprobs"],g);const y=u(l,["groundingMetadata"]);y!=null&&c(n,["groundingMetadata"],y);const h=u(l,["index"]);h!=null&&c(n,["index"],h);const T=u(l,["logprobsResult"]);T!=null&&c(n,["logprobsResult"],T);const S=u(l,["safetyRatings"]);if(S!=null){let _=S;Array.isArray(_)&&(_=_.map(R=>R)),c(n,["safetyRatings"],_)}return n}function fv(l){const n={},o=u(l,["citationSources"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(r=>r)),c(n,["citations"],s)}return n}function gh(l){const n={},o=u(l,["parts"]);if(o!=null){let r=o;Array.isArray(r)&&(r=r.map(d=>Vv(d))),c(n,["parts"],r)}const s=u(l,["role"]);return s!=null&&c(n,["role"],s),n}function dv(l,n){const o={},s=u(l,["displayName"]);if(n!==void 0&&s!=null&&c(n,["batch","displayName"],s),u(l,["dest"])!==void 0)throw new Error("dest parameter is not supported in Gemini API.");return o}function mv(l,n){const o={},s=u(l,["displayName"]);n!==void 0&&s!=null&&c(n,["displayName"],s);const r=u(l,["dest"]);return n!==void 0&&r!=null&&c(n,["outputConfig"],lv(ev(r))),o}function Bp(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],we(l,s));const r=u(n,["src"]);r!=null&&c(o,["batch","inputConfig"],ov(l,mh(l,r)));const d=u(n,["config"]);return d!=null&&dv(d,o),o}function pv(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["model"],we(l,s));const r=u(n,["src"]);r!=null&&c(o,["inputConfig"],av(mh(l,r)));const d=u(n,["config"]);return d!=null&&mv(d,o),o}function hv(l,n){const o={},s=u(l,["displayName"]);return n!==void 0&&s!=null&&c(n,["batch","displayName"],s),o}function gv(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],we(l,s));const r=u(n,["src"]);r!=null&&c(o,["batch","inputConfig"],Cv(l,r));const d=u(n,["config"]);return d!=null&&hv(d,o),o}function yv(l,n){const o={},s=u(n,["name"]);return s!=null&&c(o,["_url","name"],gi(l,s)),o}function vv(l,n){const o={},s=u(n,["name"]);return s!=null&&c(o,["_url","name"],gi(l,s)),o}function Tv(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["name"]);s!=null&&c(n,["name"],s);const r=u(l,["done"]);r!=null&&c(n,["done"],r);const d=u(l,["error"]);return d!=null&&c(n,["error"],d),n}function Sv(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["name"]);s!=null&&c(n,["name"],s);const r=u(l,["done"]);r!=null&&c(n,["done"],r);const d=u(l,["error"]);return d!=null&&c(n,["error"],d),n}function Ev(l,n){const o={},s=u(n,["contents"]);if(s!=null){let d=Sr(l,s);Array.isArray(d)&&(d=d.map(p=>p)),c(o,["requests[]","request","content"],d)}const r=u(n,["config"]);return r!=null&&(c(o,["_self"],_v(r,o)),A0(o,{"requests[].*":"requests[].request.*"})),o}function _v(l,n){const o={},s=u(l,["taskType"]);n!==void 0&&s!=null&&c(n,["requests[]","taskType"],s);const r=u(l,["title"]);n!==void 0&&r!=null&&c(n,["requests[]","title"],r);const d=u(l,["outputDimensionality"]);if(n!==void 0&&d!=null&&c(n,["requests[]","outputDimensionality"],d),u(l,["mimeType"])!==void 0)throw new Error("mimeType parameter is not supported in Gemini API.");if(u(l,["autoTruncate"])!==void 0)throw new Error("autoTruncate parameter is not supported in Gemini API.");return o}function Cv(l,n){const o={},s=u(n,["fileName"]);s!=null&&c(o,["file_name"],s);const r=u(n,["inlinedRequests"]);return r!=null&&c(o,["requests"],Ev(l,r)),o}function Av(l){const n={};if(u(l,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=u(l,["fileUri"]);o!=null&&c(n,["fileUri"],o);const s=u(l,["mimeType"]);return s!=null&&c(n,["mimeType"],s),n}function xv(l,n,o){const s={},r=u(n,["systemInstruction"]);o!==void 0&&r!=null&&c(o,["systemInstruction"],gh(St(r)));const d=u(n,["temperature"]);d!=null&&c(s,["temperature"],d);const p=u(n,["topP"]);p!=null&&c(s,["topP"],p);const g=u(n,["topK"]);g!=null&&c(s,["topK"],g);const y=u(n,["candidateCount"]);y!=null&&c(s,["candidateCount"],y);const h=u(n,["maxOutputTokens"]);h!=null&&c(s,["maxOutputTokens"],h);const T=u(n,["stopSequences"]);T!=null&&c(s,["stopSequences"],T);const S=u(n,["responseLogprobs"]);S!=null&&c(s,["responseLogprobs"],S);const _=u(n,["logprobs"]);_!=null&&c(s,["logprobs"],_);const R=u(n,["presencePenalty"]);R!=null&&c(s,["presencePenalty"],R);const H=u(n,["frequencyPenalty"]);H!=null&&c(s,["frequencyPenalty"],H);const V=u(n,["seed"]);V!=null&&c(s,["seed"],V);const Y=u(n,["responseMimeType"]);Y!=null&&c(s,["responseMimeType"],Y);const J=u(n,["responseSchema"]);J!=null&&c(s,["responseSchema"],Er(J));const X=u(n,["responseJsonSchema"]);if(X!=null&&c(s,["responseJsonSchema"],X),u(n,["routingConfig"])!==void 0)throw new Error("routingConfig parameter is not supported in Gemini API.");if(u(n,["modelSelectionConfig"])!==void 0)throw new Error("modelSelectionConfig parameter is not supported in Gemini API.");const P=u(n,["safetySettings"]);if(o!==void 0&&P!=null){let pe=P;Array.isArray(pe)&&(pe=pe.map(Ke=>Bv(Ke))),c(o,["safetySettings"],pe)}const K=u(n,["tools"]);if(o!==void 0&&K!=null){let pe=hi(K);Array.isArray(pe)&&(pe=pe.map(Ke=>Pv(pi(Ke)))),c(o,["tools"],pe)}const te=u(n,["toolConfig"]);if(o!==void 0&&te!=null&&c(o,["toolConfig"],te),u(n,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const le=u(n,["cachedContent"]);o!==void 0&&le!=null&&c(o,["cachedContent"],Dn(l,le));const F=u(n,["responseModalities"]);F!=null&&c(s,["responseModalities"],F);const ve=u(n,["mediaResolution"]);ve!=null&&c(s,["mediaResolution"],ve);const $=u(n,["speechConfig"]);if($!=null&&c(s,["speechConfig"],_r($)),u(n,["audioTimestamp"])!==void 0)throw new Error("audioTimestamp parameter is not supported in Gemini API.");const Te=u(n,["thinkingConfig"]);Te!=null&&c(s,["thinkingConfig"],Te);const Me=u(n,["imageConfig"]);return Me!=null&&c(s,["imageConfig"],Me),s}function Mv(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["candidates"]);if(s!=null){let y=s;Array.isArray(y)&&(y=y.map(h=>cv(h))),c(n,["candidates"],y)}const r=u(l,["modelVersion"]);r!=null&&c(n,["modelVersion"],r);const d=u(l,["promptFeedback"]);d!=null&&c(n,["promptFeedback"],d);const p=u(l,["responseId"]);p!=null&&c(n,["responseId"],p);const g=u(l,["usageMetadata"]);return g!=null&&c(n,["usageMetadata"],g),n}function Nv(l,n){const o={},s=u(n,["name"]);return s!=null&&c(o,["_url","name"],gi(l,s)),o}function Rv(l,n){const o={},s=u(n,["name"]);return s!=null&&c(o,["_url","name"],gi(l,s)),o}function bv(l){const n={};if(u(l,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const o=u(l,["enableWidget"]);return o!=null&&c(n,["enableWidget"],o),n}function Dv(l){const n={},o=u(l,["timeRangeFilter"]);if(o!=null&&c(n,["timeRangeFilter"],o),u(l,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");return n}function wv(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["request","model"],we(l,s));const r=u(n,["contents"]);if(r!=null){let g=$t(r);Array.isArray(g)&&(g=g.map(y=>gh(y))),c(o,["request","contents"],g)}const d=u(n,["metadata"]);d!=null&&c(o,["metadata"],d);const p=u(n,["config"]);return p!=null&&c(o,["request","generationConfig"],xv(l,p,u(o,["request"],{}))),o}function Uv(l){const n={},o=u(l,["response"]);o!=null&&c(n,["response"],Mv(o));const s=u(l,["error"]);return s!=null&&c(n,["error"],s),n}function Iv(l,n){const o={},s=u(l,["pageSize"]);n!==void 0&&s!=null&&c(n,["_query","pageSize"],s);const r=u(l,["pageToken"]);if(n!==void 0&&r!=null&&c(n,["_query","pageToken"],r),u(l,["filter"])!==void 0)throw new Error("filter parameter is not supported in Gemini API.");return o}function qv(l,n){const o={},s=u(l,["pageSize"]);n!==void 0&&s!=null&&c(n,["_query","pageSize"],s);const r=u(l,["pageToken"]);n!==void 0&&r!=null&&c(n,["_query","pageToken"],r);const d=u(l,["filter"]);return n!==void 0&&d!=null&&c(n,["_query","filter"],d),o}function Lv(l){const n={},o=u(l,["config"]);return o!=null&&Iv(o,n),n}function Gv(l){const n={},o=u(l,["config"]);return o!=null&&qv(o,n),n}function Hv(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["nextPageToken"]);s!=null&&c(n,["nextPageToken"],s);const r=u(l,["operations"]);if(r!=null){let d=r;Array.isArray(d)&&(d=d.map(p=>Ia(p))),c(n,["batchJobs"],d)}return n}function zv(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["nextPageToken"]);s!=null&&c(n,["nextPageToken"],s);const r=u(l,["batchPredictionJobs"]);if(r!=null){let d=r;Array.isArray(d)&&(d=d.map(p=>mr(p))),c(n,["batchJobs"],d)}return n}function Vv(l){const n={},o=u(l,["videoMetadata"]);o!=null&&c(n,["videoMetadata"],o);const s=u(l,["thought"]);s!=null&&c(n,["thought"],s);const r=u(l,["inlineData"]);r!=null&&c(n,["inlineData"],sv(r));const d=u(l,["fileData"]);d!=null&&c(n,["fileData"],Av(d));const p=u(l,["thoughtSignature"]);p!=null&&c(n,["thoughtSignature"],p);const g=u(l,["functionCall"]);g!=null&&c(n,["functionCall"],g);const y=u(l,["codeExecutionResult"]);y!=null&&c(n,["codeExecutionResult"],y);const h=u(l,["executableCode"]);h!=null&&c(n,["executableCode"],h);const T=u(l,["functionResponse"]);T!=null&&c(n,["functionResponse"],T);const S=u(l,["text"]);return S!=null&&c(n,["text"],S),n}function Bv(l){const n={};if(u(l,["method"])!==void 0)throw new Error("method parameter is not supported in Gemini API.");const o=u(l,["category"]);o!=null&&c(n,["category"],o);const s=u(l,["threshold"]);return s!=null&&c(n,["threshold"],s),n}function Pv(l){const n={},o=u(l,["functionDeclarations"]);if(o!=null){let h=o;Array.isArray(h)&&(h=h.map(T=>T)),c(n,["functionDeclarations"],h)}if(u(l,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const s=u(l,["googleSearch"]);s!=null&&c(n,["googleSearch"],Dv(s));const r=u(l,["googleSearchRetrieval"]);if(r!=null&&c(n,["googleSearchRetrieval"],r),u(l,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const d=u(l,["googleMaps"]);d!=null&&c(n,["googleMaps"],bv(d));const p=u(l,["urlContext"]);p!=null&&c(n,["urlContext"],p);const g=u(l,["computerUse"]);g!=null&&c(n,["computerUse"],g);const y=u(l,["codeExecution"]);return y!=null&&c(n,["codeExecution"],y),n}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */var _l;(function(l){l.PAGED_ITEM_BATCH_JOBS="batchJobs",l.PAGED_ITEM_MODELS="models",l.PAGED_ITEM_TUNING_JOBS="tuningJobs",l.PAGED_ITEM_FILES="files",l.PAGED_ITEM_CACHED_CONTENTS="cachedContents"})(_l||(_l={}));class ho{constructor(n,o,s,r){this.pageInternal=[],this.paramsInternal={},this.requestInternal=o,this.init(n,s,r)}init(n,o,s){var r,d;this.nameInternal=n,this.pageInternal=o[this.nameInternal]||[],this.sdkHttpResponseInternal=o==null?void 0:o.sdkHttpResponse,this.idxInternal=0;let p={config:{}};!s||Object.keys(s).length===0?p={config:{}}:typeof s=="object"?p=Object.assign({},s):p=s,p.config&&(p.config.pageToken=o.nextPageToken),this.paramsInternal=p,this.pageInternalSize=(d=(r=p.config)===null||r===void 0?void 0:r.pageSize)!==null&&d!==void 0?d:this.pageInternal.length}initNextPage(n){this.init(this.nameInternal,n,this.paramsInternal)}get page(){return this.pageInternal}get name(){return this.nameInternal}get pageSize(){return this.pageInternalSize}get sdkHttpResponse(){return this.sdkHttpResponseInternal}get params(){return this.paramsInternal}get pageLength(){return this.pageInternal.length}getItem(n){return this.pageInternal[n]}[Symbol.asyncIterator](){return{next:async()=>{if(this.idxInternal>=this.pageLength)if(this.hasNextPage())await this.nextPage();else return{value:void 0,done:!0};const n=this.getItem(this.idxInternal);return this.idxInternal+=1,{value:n,done:!1}},return:async()=>({value:void 0,done:!0})}}async nextPage(){if(!this.hasNextPage())throw new Error("No more pages to fetch.");const n=await this.requestInternal(this.params);return this.initNextPage(n),this.page}hasNextPage(){var n;return((n=this.params.config)===null||n===void 0?void 0:n.pageToken)!==void 0}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class kv extends Cl{constructor(n){super(),this.apiClient=n,this.create=async o=>(this.apiClient.isVertexAI()&&(o.config=this.formatDestination(o.src,o.config)),this.createInternal(o)),this.createEmbeddings=async o=>{if(console.warn("batches.createEmbeddings() is experimental and may change without notice."),this.apiClient.isVertexAI())throw new Error("Vertex AI does not support batches.createEmbeddings.");return this.createEmbeddingsInternal(o)},this.list=async(o={})=>new ho(_l.PAGED_ITEM_BATCH_JOBS,s=>this.listInternal(s),await this.listInternal(o),o)}createInlinedGenerateContentRequest(n){const o=Bp(this.apiClient,n),s=o._url,r=j("{model}:batchGenerateContent",s),g=o.batch.inputConfig.requests,y=g.requests,h=[];for(const T of y){const S=Object.assign({},T);if(S.systemInstruction){const _=S.systemInstruction;delete S.systemInstruction;const R=S.request;R.systemInstruction=_,S.request=R}h.push(S)}return g.requests=h,delete o.config,delete o._url,delete o._query,{path:r,body:o}}getGcsUri(n){if(typeof n=="string")return n.startsWith("gs://")?n:void 0;if(!Array.isArray(n)&&n.gcsUri&&n.gcsUri.length>0)return n.gcsUri[0]}getBigqueryUri(n){if(typeof n=="string")return n.startsWith("bq://")?n:void 0;if(!Array.isArray(n))return n.bigqueryUri}formatDestination(n,o){const s=o?Object.assign({},o):{},r=Date.now().toString();if(s.displayName||(s.displayName=`genaiBatchJob_${r}`),s.dest===void 0){const d=this.getGcsUri(n),p=this.getBigqueryUri(n);if(d)d.endsWith(".jsonl")?s.dest=`${d.slice(0,-6)}/dest`:s.dest=`${d}_dest_${r}`;else if(p)s.dest=`${p}_dest_${r}`;else throw new Error("Unsupported source for Vertex AI: No GCS or BigQuery URI found.")}return s}async createInternal(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=pv(this.apiClient,n);return g=j("batchPredictionJobs",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json()),p.then(T=>mr(T))}else{const h=Bp(this.apiClient,n);return g=j("{model}:batchGenerateContent",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json()),p.then(T=>Ia(T))}}async createEmbeddingsInternal(n){var o,s;let r,d="",p={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=gv(this.apiClient,n);return d=j("{model}:asyncBatchEmbedContent",g._url),p=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:p,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json()),r.then(y=>Ia(y))}}async get(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=Rv(this.apiClient,n);return g=j("batchPredictionJobs/{name}",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json()),p.then(T=>mr(T))}else{const h=Nv(this.apiClient,n);return g=j("batches/{name}",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json()),p.then(T=>Ia(T))}}async cancel(n){var o,s,r,d;let p="",g={};if(this.apiClient.isVertexAI()){const y=rv(this.apiClient,n);p=j("batchPredictionJobs/{name}:cancel",y._url),g=y._query,delete y._url,delete y._query,await this.apiClient.request({path:p,queryParams:g,body:JSON.stringify(y),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal})}else{const y=uv(this.apiClient,n);p=j("batches/{name}:cancel",y._url),g=y._query,delete y._url,delete y._query,await this.apiClient.request({path:p,queryParams:g,body:JSON.stringify(y),httpMethod:"POST",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal})}}async listInternal(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=Gv(n);return g=j("batchPredictionJobs",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),p.then(T=>{const S=zv(T),_=new Gp;return Object.assign(_,S),_})}else{const h=Lv(n);return g=j("batches",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),p.then(T=>{const S=Hv(T),_=new Gp;return Object.assign(_,S),_})}}async delete(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=vv(this.apiClient,n);return g=j("batchPredictionJobs/{name}",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"DELETE",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),p.then(T=>Sv(T))}else{const h=yv(this.apiClient,n);return g=j("batches/{name}",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"DELETE",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),p.then(T=>Tv(T))}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function Yv(l){const n={};if(u(l,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=u(l,["data"]);o!=null&&c(n,["data"],o);const s=u(l,["mimeType"]);return s!=null&&c(n,["mimeType"],s),n}function Pp(l){const n={},o=u(l,["parts"]);if(o!=null){let r=o;Array.isArray(r)&&(r=r.map(d=>cT(d))),c(n,["parts"],r)}const s=u(l,["role"]);return s!=null&&c(n,["role"],s),n}function Jv(l,n){const o={},s=u(l,["ttl"]);n!==void 0&&s!=null&&c(n,["ttl"],s);const r=u(l,["expireTime"]);n!==void 0&&r!=null&&c(n,["expireTime"],r);const d=u(l,["displayName"]);n!==void 0&&d!=null&&c(n,["displayName"],d);const p=u(l,["contents"]);if(n!==void 0&&p!=null){let T=$t(p);Array.isArray(T)&&(T=T.map(S=>Pp(S))),c(n,["contents"],T)}const g=u(l,["systemInstruction"]);n!==void 0&&g!=null&&c(n,["systemInstruction"],Pp(St(g)));const y=u(l,["tools"]);if(n!==void 0&&y!=null){let T=y;Array.isArray(T)&&(T=T.map(S=>fT(S))),c(n,["tools"],T)}const h=u(l,["toolConfig"]);if(n!==void 0&&h!=null&&c(n,["toolConfig"],h),u(l,["kmsKeyName"])!==void 0)throw new Error("kmsKeyName parameter is not supported in Gemini API.");return o}function Ov(l,n){const o={},s=u(l,["ttl"]);n!==void 0&&s!=null&&c(n,["ttl"],s);const r=u(l,["expireTime"]);n!==void 0&&r!=null&&c(n,["expireTime"],r);const d=u(l,["displayName"]);n!==void 0&&d!=null&&c(n,["displayName"],d);const p=u(l,["contents"]);if(n!==void 0&&p!=null){let S=$t(p);Array.isArray(S)&&(S=S.map(_=>_)),c(n,["contents"],S)}const g=u(l,["systemInstruction"]);n!==void 0&&g!=null&&c(n,["systemInstruction"],St(g));const y=u(l,["tools"]);if(n!==void 0&&y!=null){let S=y;Array.isArray(S)&&(S=S.map(_=>dT(_))),c(n,["tools"],S)}const h=u(l,["toolConfig"]);n!==void 0&&h!=null&&c(n,["toolConfig"],h);const T=u(l,["kmsKeyName"]);return n!==void 0&&T!=null&&c(n,["encryption_spec","kmsKeyName"],T),o}function Fv(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["model"],ih(l,s));const r=u(n,["config"]);return r!=null&&Jv(r,o),o}function Xv(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["model"],ih(l,s));const r=u(n,["config"]);return r!=null&&Ov(r,o),o}function Kv(l,n){const o={},s=u(n,["name"]);return s!=null&&c(o,["_url","name"],Dn(l,s)),o}function Qv(l,n){const o={},s=u(n,["name"]);return s!=null&&c(o,["_url","name"],Dn(l,s)),o}function Zv(l){const n={},o=u(l,["sdkHttpResponse"]);return o!=null&&c(n,["sdkHttpResponse"],o),n}function $v(l){const n={},o=u(l,["sdkHttpResponse"]);return o!=null&&c(n,["sdkHttpResponse"],o),n}function Wv(l){const n={};if(u(l,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=u(l,["fileUri"]);o!=null&&c(n,["fileUri"],o);const s=u(l,["mimeType"]);return s!=null&&c(n,["mimeType"],s),n}function jv(l){const n={};if(u(l,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");const o=u(l,["description"]);o!=null&&c(n,["description"],o);const s=u(l,["name"]);s!=null&&c(n,["name"],s);const r=u(l,["parameters"]);r!=null&&c(n,["parameters"],r);const d=u(l,["parametersJsonSchema"]);d!=null&&c(n,["parametersJsonSchema"],d);const p=u(l,["response"]);p!=null&&c(n,["response"],p);const g=u(l,["responseJsonSchema"]);return g!=null&&c(n,["responseJsonSchema"],g),n}function eT(l,n){const o={},s=u(n,["name"]);return s!=null&&c(o,["_url","name"],Dn(l,s)),o}function tT(l,n){const o={},s=u(n,["name"]);return s!=null&&c(o,["_url","name"],Dn(l,s)),o}function nT(l){const n={};if(u(l,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const o=u(l,["enableWidget"]);return o!=null&&c(n,["enableWidget"],o),n}function lT(l){const n={},o=u(l,["timeRangeFilter"]);if(o!=null&&c(n,["timeRangeFilter"],o),u(l,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");return n}function iT(l,n){const o={},s=u(l,["pageSize"]);n!==void 0&&s!=null&&c(n,["_query","pageSize"],s);const r=u(l,["pageToken"]);return n!==void 0&&r!=null&&c(n,["_query","pageToken"],r),o}function oT(l,n){const o={},s=u(l,["pageSize"]);n!==void 0&&s!=null&&c(n,["_query","pageSize"],s);const r=u(l,["pageToken"]);return n!==void 0&&r!=null&&c(n,["_query","pageToken"],r),o}function aT(l){const n={},o=u(l,["config"]);return o!=null&&iT(o,n),n}function sT(l){const n={},o=u(l,["config"]);return o!=null&&oT(o,n),n}function uT(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["nextPageToken"]);s!=null&&c(n,["nextPageToken"],s);const r=u(l,["cachedContents"]);if(r!=null){let d=r;Array.isArray(d)&&(d=d.map(p=>p)),c(n,["cachedContents"],d)}return n}function rT(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["nextPageToken"]);s!=null&&c(n,["nextPageToken"],s);const r=u(l,["cachedContents"]);if(r!=null){let d=r;Array.isArray(d)&&(d=d.map(p=>p)),c(n,["cachedContents"],d)}return n}function cT(l){const n={},o=u(l,["videoMetadata"]);o!=null&&c(n,["videoMetadata"],o);const s=u(l,["thought"]);s!=null&&c(n,["thought"],s);const r=u(l,["inlineData"]);r!=null&&c(n,["inlineData"],Yv(r));const d=u(l,["fileData"]);d!=null&&c(n,["fileData"],Wv(d));const p=u(l,["thoughtSignature"]);p!=null&&c(n,["thoughtSignature"],p);const g=u(l,["functionCall"]);g!=null&&c(n,["functionCall"],g);const y=u(l,["codeExecutionResult"]);y!=null&&c(n,["codeExecutionResult"],y);const h=u(l,["executableCode"]);h!=null&&c(n,["executableCode"],h);const T=u(l,["functionResponse"]);T!=null&&c(n,["functionResponse"],T);const S=u(l,["text"]);return S!=null&&c(n,["text"],S),n}function fT(l){const n={},o=u(l,["functionDeclarations"]);if(o!=null){let h=o;Array.isArray(h)&&(h=h.map(T=>T)),c(n,["functionDeclarations"],h)}if(u(l,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const s=u(l,["googleSearch"]);s!=null&&c(n,["googleSearch"],lT(s));const r=u(l,["googleSearchRetrieval"]);if(r!=null&&c(n,["googleSearchRetrieval"],r),u(l,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const d=u(l,["googleMaps"]);d!=null&&c(n,["googleMaps"],nT(d));const p=u(l,["urlContext"]);p!=null&&c(n,["urlContext"],p);const g=u(l,["computerUse"]);g!=null&&c(n,["computerUse"],g);const y=u(l,["codeExecution"]);return y!=null&&c(n,["codeExecution"],y),n}function dT(l){const n={},o=u(l,["functionDeclarations"]);if(o!=null){let S=o;Array.isArray(S)&&(S=S.map(_=>jv(_))),c(n,["functionDeclarations"],S)}const s=u(l,["retrieval"]);s!=null&&c(n,["retrieval"],s);const r=u(l,["googleSearch"]);r!=null&&c(n,["googleSearch"],r);const d=u(l,["googleSearchRetrieval"]);d!=null&&c(n,["googleSearchRetrieval"],d);const p=u(l,["enterpriseWebSearch"]);p!=null&&c(n,["enterpriseWebSearch"],p);const g=u(l,["googleMaps"]);g!=null&&c(n,["googleMaps"],g);const y=u(l,["urlContext"]);y!=null&&c(n,["urlContext"],y);const h=u(l,["computerUse"]);h!=null&&c(n,["computerUse"],h);const T=u(l,["codeExecution"]);return T!=null&&c(n,["codeExecution"],T),n}function mT(l,n){const o={},s=u(l,["ttl"]);n!==void 0&&s!=null&&c(n,["ttl"],s);const r=u(l,["expireTime"]);return n!==void 0&&r!=null&&c(n,["expireTime"],r),o}function pT(l,n){const o={},s=u(l,["ttl"]);n!==void 0&&s!=null&&c(n,["ttl"],s);const r=u(l,["expireTime"]);return n!==void 0&&r!=null&&c(n,["expireTime"],r),o}function hT(l,n){const o={},s=u(n,["name"]);s!=null&&c(o,["_url","name"],Dn(l,s));const r=u(n,["config"]);return r!=null&&mT(r,o),o}function gT(l,n){const o={},s=u(n,["name"]);s!=null&&c(o,["_url","name"],Dn(l,s));const r=u(n,["config"]);return r!=null&&pT(r,o),o}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class yT extends Cl{constructor(n){super(),this.apiClient=n,this.list=async(o={})=>new ho(_l.PAGED_ITEM_CACHED_CONTENTS,s=>this.listInternal(s),await this.listInternal(o),o)}async create(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=Xv(this.apiClient,n);return g=j("cachedContents",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json()),p.then(T=>T)}else{const h=Fv(this.apiClient,n);return g=j("cachedContents",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json()),p.then(T=>T)}}async get(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=tT(this.apiClient,n);return g=j("{name}",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json()),p.then(T=>T)}else{const h=eT(this.apiClient,n);return g=j("{name}",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json()),p.then(T=>T)}}async delete(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=Qv(this.apiClient,n);return g=j("{name}",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"DELETE",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),p.then(T=>{const S=$v(T),_=new qp;return Object.assign(_,S),_})}else{const h=Kv(this.apiClient,n);return g=j("{name}",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"DELETE",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),p.then(T=>{const S=Zv(T),_=new qp;return Object.assign(_,S),_})}}async update(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=gT(this.apiClient,n);return g=j("{name}",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"PATCH",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json()),p.then(T=>T)}else{const h=hT(this.apiClient,n);return g=j("{name}",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"PATCH",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json()),p.then(T=>T)}}async listInternal(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=sT(n);return g=j("cachedContents",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),p.then(T=>{const S=rT(T),_=new Lp;return Object.assign(_,S),_})}else{const h=aT(n);return g=j("cachedContents",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),p.then(T=>{const S=uT(T),_=new Lp;return Object.assign(_,S),_})}}}function kp(l){var n=typeof Symbol=="function"&&Symbol.iterator,o=n&&l[n],s=0;if(o)return o.call(l);if(l&&typeof l.length=="number")return{next:function(){return l&&s>=l.length&&(l=void 0),{value:l&&l[s++],done:!l}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function Je(l){return this instanceof Je?(this.v=l,this):new Je(l)}function di(l,n,o){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=o.apply(l,n||[]),r,d=[];return r=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),g("next"),g("throw"),g("return",p),r[Symbol.asyncIterator]=function(){return this},r;function p(R){return function(H){return Promise.resolve(H).then(R,S)}}function g(R,H){s[R]&&(r[R]=function(V){return new Promise(function(Y,J){d.push([R,V,Y,J])>1||y(R,V)})},H&&(r[R]=H(r[R])))}function y(R,H){try{h(s[R](H))}catch(V){_(d[0][3],V)}}function h(R){R.value instanceof Je?Promise.resolve(R.value.v).then(T,S):_(d[0][2],R)}function T(R){y("next",R)}function S(R){y("throw",R)}function _(R,H){R(H),d.shift(),d.length&&y(d[0][0],d[0][1])}}function po(l){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=l[Symbol.asyncIterator],o;return n?n.call(l):(l=typeof kp=="function"?kp(l):l[Symbol.iterator](),o={},s("next"),s("throw"),s("return"),o[Symbol.asyncIterator]=function(){return this},o);function s(d){o[d]=l[d]&&function(p){return new Promise(function(g,y){p=l[d](p),r(g,y,p.done,p.value)})}}function r(d,p,g,y){Promise.resolve(y).then(function(h){d({value:h,done:g})},p)}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function vT(l){var n;if(l.candidates==null||l.candidates.length===0)return!1;const o=(n=l.candidates[0])===null||n===void 0?void 0:n.content;return o===void 0?!1:yh(o)}function yh(l){if(l.parts===void 0||l.parts.length===0)return!1;for(const n of l.parts)if(n===void 0||Object.keys(n).length===0)return!1;return!0}function TT(l){if(l.length!==0){for(const n of l)if(n.role!=="user"&&n.role!=="model")throw new Error(`Role must be user or model, but got ${n.role}.`)}}function Yp(l){if(l===void 0||l.length===0)return[];const n=[],o=l.length;let s=0;for(;s{var d,p,g;const y=await r,h=(p=(d=y.candidates)===null||d===void 0?void 0:d[0])===null||p===void 0?void 0:p.content,T=y.automaticFunctionCallingHistory,S=this.getHistory(!0).length;let _=[];T!=null&&(_=(g=T.slice(S))!==null&&g!==void 0?g:[]);const R=h?[h]:[];this.recordHistory(s,R,_)})(),await this.sendPromise.catch(()=>{this.sendPromise=Promise.resolve()}),r}async sendMessageStream(n){var o;await this.sendPromise;const s=St(n.message),r=this.modelsModule.generateContentStream({model:this.model,contents:this.getHistory(!0).concat(s),config:(o=n.config)!==null&&o!==void 0?o:this.config});this.sendPromise=r.then(()=>{}).catch(()=>{});const d=await r;return this.processStreamResponse(d,s)}getHistory(n=!1){const o=n?Yp(this.history):this.history;return structuredClone(o)}processStreamResponse(n,o){var s,r;return di(this,arguments,function*(){var p,g,y,h;const T=[];try{for(var S=!0,_=po(n),R;R=yield Je(_.next()),p=R.done,!p;S=!0){h=R.value,S=!1;const H=h;if(vT(H)){const V=(r=(s=H.candidates)===null||s===void 0?void 0:s[0])===null||r===void 0?void 0:r.content;V!==void 0&&T.push(V)}yield yield Je(H)}}catch(H){g={error:H}}finally{try{!S&&!p&&(y=_.return)&&(yield Je(y.call(_)))}finally{if(g)throw g.error}}this.recordHistory(o,T)})}recordHistory(n,o,s){let r=[];o.length>0&&o.every(d=>d.role!==void 0)?r=o:r.push({role:"model",parts:[]}),s&&s.length>0?this.history.push(...Yp(s)):this.history.push(n),this.history.push(...r)}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class za extends Error{constructor(n){super(n.message),this.name="ApiError",this.status=n.status,Object.setPrototypeOf(this,za.prototype)}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function _T(l){const n={},o=u(l,["file"]);return o!=null&&c(n,["file"],o),n}function CT(l){const n={},o=u(l,["sdkHttpResponse"]);return o!=null&&c(n,["sdkHttpResponse"],o),n}function AT(l){const n={},o=u(l,["name"]);return o!=null&&c(n,["_url","file"],ch(o)),n}function xT(l){const n={},o=u(l,["sdkHttpResponse"]);return o!=null&&c(n,["sdkHttpResponse"],o),n}function MT(l){const n={},o=u(l,["name"]);return o!=null&&c(n,["_url","file"],ch(o)),n}function NT(l,n){const o={},s=u(l,["pageSize"]);n!==void 0&&s!=null&&c(n,["_query","pageSize"],s);const r=u(l,["pageToken"]);return n!==void 0&&r!=null&&c(n,["_query","pageToken"],r),o}function RT(l){const n={},o=u(l,["config"]);return o!=null&&NT(o,n),n}function bT(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["nextPageToken"]);s!=null&&c(n,["nextPageToken"],s);const r=u(l,["files"]);if(r!=null){let d=r;Array.isArray(d)&&(d=d.map(p=>p)),c(n,["files"],d)}return n}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class DT extends Cl{constructor(n){super(),this.apiClient=n,this.list=async(o={})=>new ho(_l.PAGED_ITEM_FILES,s=>this.listInternal(s),await this.listInternal(o),o)}async upload(n){if(this.apiClient.isVertexAI())throw new Error("Vertex AI does not support uploading files. You can share files through a GCS bucket.");return this.apiClient.uploadFile(n.file,n.config).then(o=>o)}async download(n){await this.apiClient.downloadFile(n)}async listInternal(n){var o,s;let r,d="",p={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=RT(n);return d=j("files",g._url),p=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:p,body:JSON.stringify(g),httpMethod:"GET",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json().then(h=>{const T=h;return T.sdkHttpResponse={headers:y.headers},T})),r.then(y=>{const h=bT(y),T=new P0;return Object.assign(T,h),T})}}async createInternal(n){var o,s;let r,d="",p={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=_T(n);return d=j("upload/v1beta/files",g._url),p=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:p,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json()),r.then(y=>{const h=CT(y),T=new k0;return Object.assign(T,h),T})}}async get(n){var o,s;let r,d="",p={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=MT(n);return d=j("files/{file}",g._url),p=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:p,body:JSON.stringify(g),httpMethod:"GET",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json()),r.then(y=>y)}}async delete(n){var o,s;let r,d="",p={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=AT(n);return d=j("files/{file}",g._url),p=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:p,body:JSON.stringify(g),httpMethod:"DELETE",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json().then(h=>{const T=h;return T.sdkHttpResponse={headers:y.headers},T})),r.then(y=>{const h=xT(y),T=new Y0;return Object.assign(T,h),T})}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function qa(l){const n={};if(u(l,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=u(l,["data"]);o!=null&&c(n,["data"],o);const s=u(l,["mimeType"]);return s!=null&&c(n,["mimeType"],s),n}function wT(l){const n={},o=u(l,["parts"]);if(o!=null){let r=o;Array.isArray(r)&&(r=r.map(d=>FT(d))),c(n,["parts"],r)}const s=u(l,["role"]);return s!=null&&c(n,["role"],s),n}function UT(l){const n={};if(u(l,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=u(l,["fileUri"]);o!=null&&c(n,["fileUri"],o);const s=u(l,["mimeType"]);return s!=null&&c(n,["mimeType"],s),n}function IT(l){const n={};if(u(l,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");const o=u(l,["description"]);o!=null&&c(n,["description"],o);const s=u(l,["name"]);s!=null&&c(n,["name"],s);const r=u(l,["parameters"]);r!=null&&c(n,["parameters"],r);const d=u(l,["parametersJsonSchema"]);d!=null&&c(n,["parametersJsonSchema"],d);const p=u(l,["response"]);p!=null&&c(n,["response"],p);const g=u(l,["responseJsonSchema"]);return g!=null&&c(n,["responseJsonSchema"],g),n}function qT(l){const n={},o=u(l,["modelSelectionConfig"]);o!=null&&c(n,["modelConfig"],o);const s=u(l,["audioTimestamp"]);s!=null&&c(n,["audioTimestamp"],s);const r=u(l,["candidateCount"]);r!=null&&c(n,["candidateCount"],r);const d=u(l,["enableAffectiveDialog"]);d!=null&&c(n,["enableAffectiveDialog"],d);const p=u(l,["frequencyPenalty"]);p!=null&&c(n,["frequencyPenalty"],p);const g=u(l,["logprobs"]);g!=null&&c(n,["logprobs"],g);const y=u(l,["maxOutputTokens"]);y!=null&&c(n,["maxOutputTokens"],y);const h=u(l,["mediaResolution"]);h!=null&&c(n,["mediaResolution"],h);const T=u(l,["presencePenalty"]);T!=null&&c(n,["presencePenalty"],T);const S=u(l,["responseJsonSchema"]);S!=null&&c(n,["responseJsonSchema"],S);const _=u(l,["responseLogprobs"]);_!=null&&c(n,["responseLogprobs"],_);const R=u(l,["responseMimeType"]);R!=null&&c(n,["responseMimeType"],R);const H=u(l,["responseModalities"]);H!=null&&c(n,["responseModalities"],H);const V=u(l,["responseSchema"]);V!=null&&c(n,["responseSchema"],V);const Y=u(l,["routingConfig"]);Y!=null&&c(n,["routingConfig"],Y);const J=u(l,["seed"]);J!=null&&c(n,["seed"],J);const X=u(l,["speechConfig"]);X!=null&&c(n,["speechConfig"],vh(X));const P=u(l,["stopSequences"]);P!=null&&c(n,["stopSequences"],P);const K=u(l,["temperature"]);K!=null&&c(n,["temperature"],K);const te=u(l,["thinkingConfig"]);te!=null&&c(n,["thinkingConfig"],te);const le=u(l,["topK"]);le!=null&&c(n,["topK"],le);const F=u(l,["topP"]);return F!=null&&c(n,["topP"],F),n}function LT(l){const n={};if(u(l,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const o=u(l,["enableWidget"]);return o!=null&&c(n,["enableWidget"],o),n}function GT(l){const n={},o=u(l,["timeRangeFilter"]);if(o!=null&&c(n,["timeRangeFilter"],o),u(l,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");return n}function HT(l,n){const o={},s=u(l,["generationConfig"]);n!==void 0&&s!=null&&c(n,["setup","generationConfig"],s);const r=u(l,["responseModalities"]);n!==void 0&&r!=null&&c(n,["setup","generationConfig","responseModalities"],r);const d=u(l,["temperature"]);n!==void 0&&d!=null&&c(n,["setup","generationConfig","temperature"],d);const p=u(l,["topP"]);n!==void 0&&p!=null&&c(n,["setup","generationConfig","topP"],p);const g=u(l,["topK"]);n!==void 0&&g!=null&&c(n,["setup","generationConfig","topK"],g);const y=u(l,["maxOutputTokens"]);n!==void 0&&y!=null&&c(n,["setup","generationConfig","maxOutputTokens"],y);const h=u(l,["mediaResolution"]);n!==void 0&&h!=null&&c(n,["setup","generationConfig","mediaResolution"],h);const T=u(l,["seed"]);n!==void 0&&T!=null&&c(n,["setup","generationConfig","seed"],T);const S=u(l,["speechConfig"]);n!==void 0&&S!=null&&c(n,["setup","generationConfig","speechConfig"],Cr(S));const _=u(l,["thinkingConfig"]);n!==void 0&&_!=null&&c(n,["setup","generationConfig","thinkingConfig"],_);const R=u(l,["enableAffectiveDialog"]);n!==void 0&&R!=null&&c(n,["setup","generationConfig","enableAffectiveDialog"],R);const H=u(l,["systemInstruction"]);n!==void 0&&H!=null&&c(n,["setup","systemInstruction"],wT(St(H)));const V=u(l,["tools"]);if(n!==void 0&&V!=null){let le=hi(V);Array.isArray(le)&&(le=le.map(F=>KT(pi(F)))),c(n,["setup","tools"],le)}const Y=u(l,["sessionResumption"]);n!==void 0&&Y!=null&&c(n,["setup","sessionResumption"],XT(Y));const J=u(l,["inputAudioTranscription"]);n!==void 0&&J!=null&&c(n,["setup","inputAudioTranscription"],J);const X=u(l,["outputAudioTranscription"]);n!==void 0&&X!=null&&c(n,["setup","outputAudioTranscription"],X);const P=u(l,["realtimeInputConfig"]);n!==void 0&&P!=null&&c(n,["setup","realtimeInputConfig"],P);const K=u(l,["contextWindowCompression"]);n!==void 0&&K!=null&&c(n,["setup","contextWindowCompression"],K);const te=u(l,["proactivity"]);return n!==void 0&&te!=null&&c(n,["setup","proactivity"],te),o}function zT(l,n){const o={},s=u(l,["generationConfig"]);n!==void 0&&s!=null&&c(n,["setup","generationConfig"],qT(s));const r=u(l,["responseModalities"]);n!==void 0&&r!=null&&c(n,["setup","generationConfig","responseModalities"],r);const d=u(l,["temperature"]);n!==void 0&&d!=null&&c(n,["setup","generationConfig","temperature"],d);const p=u(l,["topP"]);n!==void 0&&p!=null&&c(n,["setup","generationConfig","topP"],p);const g=u(l,["topK"]);n!==void 0&&g!=null&&c(n,["setup","generationConfig","topK"],g);const y=u(l,["maxOutputTokens"]);n!==void 0&&y!=null&&c(n,["setup","generationConfig","maxOutputTokens"],y);const h=u(l,["mediaResolution"]);n!==void 0&&h!=null&&c(n,["setup","generationConfig","mediaResolution"],h);const T=u(l,["seed"]);n!==void 0&&T!=null&&c(n,["setup","generationConfig","seed"],T);const S=u(l,["speechConfig"]);n!==void 0&&S!=null&&c(n,["setup","generationConfig","speechConfig"],vh(Cr(S)));const _=u(l,["thinkingConfig"]);n!==void 0&&_!=null&&c(n,["setup","generationConfig","thinkingConfig"],_);const R=u(l,["enableAffectiveDialog"]);n!==void 0&&R!=null&&c(n,["setup","generationConfig","enableAffectiveDialog"],R);const H=u(l,["systemInstruction"]);n!==void 0&&H!=null&&c(n,["setup","systemInstruction"],St(H));const V=u(l,["tools"]);if(n!==void 0&&V!=null){let le=hi(V);Array.isArray(le)&&(le=le.map(F=>QT(pi(F)))),c(n,["setup","tools"],le)}const Y=u(l,["sessionResumption"]);n!==void 0&&Y!=null&&c(n,["setup","sessionResumption"],Y);const J=u(l,["inputAudioTranscription"]);n!==void 0&&J!=null&&c(n,["setup","inputAudioTranscription"],J);const X=u(l,["outputAudioTranscription"]);n!==void 0&&X!=null&&c(n,["setup","outputAudioTranscription"],X);const P=u(l,["realtimeInputConfig"]);n!==void 0&&P!=null&&c(n,["setup","realtimeInputConfig"],P);const K=u(l,["contextWindowCompression"]);n!==void 0&&K!=null&&c(n,["setup","contextWindowCompression"],K);const te=u(l,["proactivity"]);return n!==void 0&&te!=null&&c(n,["setup","proactivity"],te),o}function VT(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["setup","model"],we(l,s));const r=u(n,["config"]);return r!=null&&c(o,["config"],HT(r,o)),o}function BT(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["setup","model"],we(l,s));const r=u(n,["config"]);return r!=null&&c(o,["config"],zT(r,o)),o}function PT(l){const n={},o=u(l,["musicGenerationConfig"]);return o!=null&&c(n,["musicGenerationConfig"],o),n}function kT(l){const n={},o=u(l,["weightedPrompts"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(r=>r)),c(n,["weightedPrompts"],s)}return n}function YT(l){const n={},o=u(l,["media"]);if(o!=null){let h=oh(o);Array.isArray(h)&&(h=h.map(T=>qa(T))),c(n,["mediaChunks"],h)}const s=u(l,["audio"]);s!=null&&c(n,["audio"],qa(sh(s)));const r=u(l,["audioStreamEnd"]);r!=null&&c(n,["audioStreamEnd"],r);const d=u(l,["video"]);d!=null&&c(n,["video"],qa(ah(d)));const p=u(l,["text"]);p!=null&&c(n,["text"],p);const g=u(l,["activityStart"]);g!=null&&c(n,["activityStart"],g);const y=u(l,["activityEnd"]);return y!=null&&c(n,["activityEnd"],y),n}function JT(l){const n={},o=u(l,["media"]);if(o!=null){let h=oh(o);Array.isArray(h)&&(h=h.map(T=>T)),c(n,["mediaChunks"],h)}const s=u(l,["audio"]);s!=null&&c(n,["audio"],sh(s));const r=u(l,["audioStreamEnd"]);r!=null&&c(n,["audioStreamEnd"],r);const d=u(l,["video"]);d!=null&&c(n,["video"],ah(d));const p=u(l,["text"]);p!=null&&c(n,["text"],p);const g=u(l,["activityStart"]);g!=null&&c(n,["activityStart"],g);const y=u(l,["activityEnd"]);return y!=null&&c(n,["activityEnd"],y),n}function OT(l){const n={},o=u(l,["setupComplete"]);o!=null&&c(n,["setupComplete"],o);const s=u(l,["serverContent"]);s!=null&&c(n,["serverContent"],s);const r=u(l,["toolCall"]);r!=null&&c(n,["toolCall"],r);const d=u(l,["toolCallCancellation"]);d!=null&&c(n,["toolCallCancellation"],d);const p=u(l,["usageMetadata"]);p!=null&&c(n,["usageMetadata"],ZT(p));const g=u(l,["goAway"]);g!=null&&c(n,["goAway"],g);const y=u(l,["sessionResumptionUpdate"]);return y!=null&&c(n,["sessionResumptionUpdate"],y),n}function FT(l){const n={},o=u(l,["videoMetadata"]);o!=null&&c(n,["videoMetadata"],o);const s=u(l,["thought"]);s!=null&&c(n,["thought"],s);const r=u(l,["inlineData"]);r!=null&&c(n,["inlineData"],qa(r));const d=u(l,["fileData"]);d!=null&&c(n,["fileData"],UT(d));const p=u(l,["thoughtSignature"]);p!=null&&c(n,["thoughtSignature"],p);const g=u(l,["functionCall"]);g!=null&&c(n,["functionCall"],g);const y=u(l,["codeExecutionResult"]);y!=null&&c(n,["codeExecutionResult"],y);const h=u(l,["executableCode"]);h!=null&&c(n,["executableCode"],h);const T=u(l,["functionResponse"]);T!=null&&c(n,["functionResponse"],T);const S=u(l,["text"]);return S!=null&&c(n,["text"],S),n}function XT(l){const n={},o=u(l,["handle"]);if(o!=null&&c(n,["handle"],o),u(l,["transparent"])!==void 0)throw new Error("transparent parameter is not supported in Gemini API.");return n}function vh(l){const n={},o=u(l,["voiceConfig"]);if(o!=null&&c(n,["voiceConfig"],o),u(l,["multiSpeakerVoiceConfig"])!==void 0)throw new Error("multiSpeakerVoiceConfig parameter is not supported in Vertex AI.");const s=u(l,["languageCode"]);return s!=null&&c(n,["languageCode"],s),n}function KT(l){const n={},o=u(l,["functionDeclarations"]);if(o!=null){let h=o;Array.isArray(h)&&(h=h.map(T=>T)),c(n,["functionDeclarations"],h)}if(u(l,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const s=u(l,["googleSearch"]);s!=null&&c(n,["googleSearch"],GT(s));const r=u(l,["googleSearchRetrieval"]);if(r!=null&&c(n,["googleSearchRetrieval"],r),u(l,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const d=u(l,["googleMaps"]);d!=null&&c(n,["googleMaps"],LT(d));const p=u(l,["urlContext"]);p!=null&&c(n,["urlContext"],p);const g=u(l,["computerUse"]);g!=null&&c(n,["computerUse"],g);const y=u(l,["codeExecution"]);return y!=null&&c(n,["codeExecution"],y),n}function QT(l){const n={},o=u(l,["functionDeclarations"]);if(o!=null){let S=o;Array.isArray(S)&&(S=S.map(_=>IT(_))),c(n,["functionDeclarations"],S)}const s=u(l,["retrieval"]);s!=null&&c(n,["retrieval"],s);const r=u(l,["googleSearch"]);r!=null&&c(n,["googleSearch"],r);const d=u(l,["googleSearchRetrieval"]);d!=null&&c(n,["googleSearchRetrieval"],d);const p=u(l,["enterpriseWebSearch"]);p!=null&&c(n,["enterpriseWebSearch"],p);const g=u(l,["googleMaps"]);g!=null&&c(n,["googleMaps"],g);const y=u(l,["urlContext"]);y!=null&&c(n,["urlContext"],y);const h=u(l,["computerUse"]);h!=null&&c(n,["computerUse"],h);const T=u(l,["codeExecution"]);return T!=null&&c(n,["codeExecution"],T),n}function ZT(l){const n={},o=u(l,["promptTokenCount"]);o!=null&&c(n,["promptTokenCount"],o);const s=u(l,["cachedContentTokenCount"]);s!=null&&c(n,["cachedContentTokenCount"],s);const r=u(l,["candidatesTokenCount"]);r!=null&&c(n,["responseTokenCount"],r);const d=u(l,["toolUsePromptTokenCount"]);d!=null&&c(n,["toolUsePromptTokenCount"],d);const p=u(l,["thoughtsTokenCount"]);p!=null&&c(n,["thoughtsTokenCount"],p);const g=u(l,["totalTokenCount"]);g!=null&&c(n,["totalTokenCount"],g);const y=u(l,["promptTokensDetails"]);if(y!=null){let R=y;Array.isArray(R)&&(R=R.map(H=>H)),c(n,["promptTokensDetails"],R)}const h=u(l,["cacheTokensDetails"]);if(h!=null){let R=h;Array.isArray(R)&&(R=R.map(H=>H)),c(n,["cacheTokensDetails"],R)}const T=u(l,["candidatesTokensDetails"]);if(T!=null){let R=T;Array.isArray(R)&&(R=R.map(H=>H)),c(n,["responseTokensDetails"],R)}const S=u(l,["toolUsePromptTokensDetails"]);if(S!=null){let R=S;Array.isArray(R)&&(R=R.map(H=>H)),c(n,["toolUsePromptTokensDetails"],R)}const _=u(l,["trafficType"]);return _!=null&&c(n,["trafficType"],_),n}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function $T(l){const n={};if(u(l,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=u(l,["data"]);o!=null&&c(n,["data"],o);const s=u(l,["mimeType"]);return s!=null&&c(n,["mimeType"],s),n}function WT(l){const n={},o=u(l,["content"]);o!=null&&c(n,["content"],o);const s=u(l,["citationMetadata"]);s!=null&&c(n,["citationMetadata"],jT(s));const r=u(l,["tokenCount"]);r!=null&&c(n,["tokenCount"],r);const d=u(l,["finishReason"]);d!=null&&c(n,["finishReason"],d);const p=u(l,["urlContextMetadata"]);p!=null&&c(n,["urlContextMetadata"],p);const g=u(l,["avgLogprobs"]);g!=null&&c(n,["avgLogprobs"],g);const y=u(l,["groundingMetadata"]);y!=null&&c(n,["groundingMetadata"],y);const h=u(l,["index"]);h!=null&&c(n,["index"],h);const T=u(l,["logprobsResult"]);T!=null&&c(n,["logprobsResult"],T);const S=u(l,["safetyRatings"]);if(S!=null){let _=S;Array.isArray(_)&&(_=_.map(R=>R)),c(n,["safetyRatings"],_)}return n}function jT(l){const n={},o=u(l,["citationSources"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(r=>r)),c(n,["citations"],s)}return n}function eS(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],we(l,s));const r=u(n,["contents"]);if(r!=null){let d=$t(r);Array.isArray(d)&&(d=d.map(p=>p)),c(o,["contents"],d)}return o}function tS(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["tokensInfo"]);if(s!=null){let r=s;Array.isArray(r)&&(r=r.map(d=>d)),c(n,["tokensInfo"],r)}return n}function nS(l){const n={},o=u(l,["values"]);o!=null&&c(n,["values"],o);const s=u(l,["statistics"]);return s!=null&&c(n,["statistics"],lS(s)),n}function lS(l){const n={},o=u(l,["truncated"]);o!=null&&c(n,["truncated"],o);const s=u(l,["token_count"]);return s!=null&&c(n,["tokenCount"],s),n}function Va(l){const n={},o=u(l,["parts"]);if(o!=null){let r=o;Array.isArray(r)&&(r=r.map(d=>uE(d))),c(n,["parts"],r)}const s=u(l,["role"]);return s!=null&&c(n,["role"],s),n}function iS(l){const n={},o=u(l,["controlType"]);o!=null&&c(n,["controlType"],o);const s=u(l,["enableControlImageComputation"]);return s!=null&&c(n,["computeControl"],s),n}function oS(l){const n={};if(u(l,["systemInstruction"])!==void 0)throw new Error("systemInstruction parameter is not supported in Gemini API.");if(u(l,["tools"])!==void 0)throw new Error("tools parameter is not supported in Gemini API.");if(u(l,["generationConfig"])!==void 0)throw new Error("generationConfig parameter is not supported in Gemini API.");return n}function aS(l,n){const o={},s=u(l,["systemInstruction"]);n!==void 0&&s!=null&&c(n,["systemInstruction"],St(s));const r=u(l,["tools"]);if(n!==void 0&&r!=null){let p=r;Array.isArray(p)&&(p=p.map(g=>Ch(g))),c(n,["tools"],p)}const d=u(l,["generationConfig"]);return n!==void 0&&d!=null&&c(n,["generationConfig"],QS(d)),o}function sS(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],we(l,s));const r=u(n,["contents"]);if(r!=null){let p=$t(r);Array.isArray(p)&&(p=p.map(g=>Va(g))),c(o,["contents"],p)}const d=u(n,["config"]);return d!=null&&oS(d),o}function uS(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],we(l,s));const r=u(n,["contents"]);if(r!=null){let p=$t(r);Array.isArray(p)&&(p=p.map(g=>g)),c(o,["contents"],p)}const d=u(n,["config"]);return d!=null&&aS(d,o),o}function rS(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["totalTokens"]);s!=null&&c(n,["totalTokens"],s);const r=u(l,["cachedContentTokenCount"]);return r!=null&&c(n,["cachedContentTokenCount"],r),n}function cS(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["totalTokens"]);return s!=null&&c(n,["totalTokens"],s),n}function fS(l,n){const o={},s=u(n,["model"]);return s!=null&&c(o,["_url","name"],we(l,s)),o}function dS(l,n){const o={},s=u(n,["model"]);return s!=null&&c(o,["_url","name"],we(l,s)),o}function mS(l){const n={},o=u(l,["sdkHttpResponse"]);return o!=null&&c(n,["sdkHttpResponse"],o),n}function pS(l){const n={},o=u(l,["sdkHttpResponse"]);return o!=null&&c(n,["sdkHttpResponse"],o),n}function hS(l,n){const o={},s=u(l,["outputGcsUri"]);n!==void 0&&s!=null&&c(n,["parameters","storageUri"],s);const r=u(l,["negativePrompt"]);n!==void 0&&r!=null&&c(n,["parameters","negativePrompt"],r);const d=u(l,["numberOfImages"]);n!==void 0&&d!=null&&c(n,["parameters","sampleCount"],d);const p=u(l,["aspectRatio"]);n!==void 0&&p!=null&&c(n,["parameters","aspectRatio"],p);const g=u(l,["guidanceScale"]);n!==void 0&&g!=null&&c(n,["parameters","guidanceScale"],g);const y=u(l,["seed"]);n!==void 0&&y!=null&&c(n,["parameters","seed"],y);const h=u(l,["safetyFilterLevel"]);n!==void 0&&h!=null&&c(n,["parameters","safetySetting"],h);const T=u(l,["personGeneration"]);n!==void 0&&T!=null&&c(n,["parameters","personGeneration"],T);const S=u(l,["includeSafetyAttributes"]);n!==void 0&&S!=null&&c(n,["parameters","includeSafetyAttributes"],S);const _=u(l,["includeRaiReason"]);n!==void 0&&_!=null&&c(n,["parameters","includeRaiReason"],_);const R=u(l,["language"]);n!==void 0&&R!=null&&c(n,["parameters","language"],R);const H=u(l,["outputMimeType"]);n!==void 0&&H!=null&&c(n,["parameters","outputOptions","mimeType"],H);const V=u(l,["outputCompressionQuality"]);n!==void 0&&V!=null&&c(n,["parameters","outputOptions","compressionQuality"],V);const Y=u(l,["addWatermark"]);n!==void 0&&Y!=null&&c(n,["parameters","addWatermark"],Y);const J=u(l,["labels"]);n!==void 0&&J!=null&&c(n,["labels"],J);const X=u(l,["editMode"]);n!==void 0&&X!=null&&c(n,["parameters","editMode"],X);const P=u(l,["baseSteps"]);return n!==void 0&&P!=null&&c(n,["parameters","editConfig","baseSteps"],P),o}function gS(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],we(l,s));const r=u(n,["prompt"]);r!=null&&c(o,["instances[0]","prompt"],r);const d=u(n,["referenceImages"]);if(d!=null){let g=d;Array.isArray(g)&&(g=g.map(y=>pE(y))),c(o,["instances[0]","referenceImages"],g)}const p=u(n,["config"]);return p!=null&&hS(p,o),o}function yS(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["predictions"]);if(s!=null){let r=s;Array.isArray(r)&&(r=r.map(d=>Ba(d))),c(n,["generatedImages"],r)}return n}function vS(l,n){const o={},s=u(l,["taskType"]);n!==void 0&&s!=null&&c(n,["requests[]","taskType"],s);const r=u(l,["title"]);n!==void 0&&r!=null&&c(n,["requests[]","title"],r);const d=u(l,["outputDimensionality"]);if(n!==void 0&&d!=null&&c(n,["requests[]","outputDimensionality"],d),u(l,["mimeType"])!==void 0)throw new Error("mimeType parameter is not supported in Gemini API.");if(u(l,["autoTruncate"])!==void 0)throw new Error("autoTruncate parameter is not supported in Gemini API.");return o}function TS(l,n){const o={},s=u(l,["taskType"]);n!==void 0&&s!=null&&c(n,["instances[]","task_type"],s);const r=u(l,["title"]);n!==void 0&&r!=null&&c(n,["instances[]","title"],r);const d=u(l,["outputDimensionality"]);n!==void 0&&d!=null&&c(n,["parameters","outputDimensionality"],d);const p=u(l,["mimeType"]);n!==void 0&&p!=null&&c(n,["instances[]","mimeType"],p);const g=u(l,["autoTruncate"]);return n!==void 0&&g!=null&&c(n,["parameters","autoTruncate"],g),o}function SS(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],we(l,s));const r=u(n,["contents"]);if(r!=null){let g=Sr(l,r);Array.isArray(g)&&(g=g.map(y=>y)),c(o,["requests[]","content"],g)}const d=u(n,["config"]);d!=null&&vS(d,o);const p=u(n,["model"]);return p!==void 0&&c(o,["requests[]","model"],we(l,p)),o}function ES(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],we(l,s));const r=u(n,["contents"]);if(r!=null){let p=Sr(l,r);Array.isArray(p)&&(p=p.map(g=>g)),c(o,["instances[]","content"],p)}const d=u(n,["config"]);return d!=null&&TS(d,o),o}function _S(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["embeddings"]);if(s!=null){let d=s;Array.isArray(d)&&(d=d.map(p=>p)),c(n,["embeddings"],d)}const r=u(l,["metadata"]);return r!=null&&c(n,["metadata"],r),n}function CS(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["predictions[]","embeddings"]);if(s!=null){let d=s;Array.isArray(d)&&(d=d.map(p=>nS(p))),c(n,["embeddings"],d)}const r=u(l,["metadata"]);return r!=null&&c(n,["metadata"],r),n}function AS(l){const n={},o=u(l,["endpoint"]);o!=null&&c(n,["name"],o);const s=u(l,["deployedModelId"]);return s!=null&&c(n,["deployedModelId"],s),n}function xS(l){const n={};if(u(l,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=u(l,["fileUri"]);o!=null&&c(n,["fileUri"],o);const s=u(l,["mimeType"]);return s!=null&&c(n,["mimeType"],s),n}function MS(l){const n={};if(u(l,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");const o=u(l,["description"]);o!=null&&c(n,["description"],o);const s=u(l,["name"]);s!=null&&c(n,["name"],s);const r=u(l,["parameters"]);r!=null&&c(n,["parameters"],r);const d=u(l,["parametersJsonSchema"]);d!=null&&c(n,["parametersJsonSchema"],d);const p=u(l,["response"]);p!=null&&c(n,["response"],p);const g=u(l,["responseJsonSchema"]);return g!=null&&c(n,["responseJsonSchema"],g),n}function NS(l,n,o){const s={},r=u(n,["systemInstruction"]);o!==void 0&&r!=null&&c(o,["systemInstruction"],Va(St(r)));const d=u(n,["temperature"]);d!=null&&c(s,["temperature"],d);const p=u(n,["topP"]);p!=null&&c(s,["topP"],p);const g=u(n,["topK"]);g!=null&&c(s,["topK"],g);const y=u(n,["candidateCount"]);y!=null&&c(s,["candidateCount"],y);const h=u(n,["maxOutputTokens"]);h!=null&&c(s,["maxOutputTokens"],h);const T=u(n,["stopSequences"]);T!=null&&c(s,["stopSequences"],T);const S=u(n,["responseLogprobs"]);S!=null&&c(s,["responseLogprobs"],S);const _=u(n,["logprobs"]);_!=null&&c(s,["logprobs"],_);const R=u(n,["presencePenalty"]);R!=null&&c(s,["presencePenalty"],R);const H=u(n,["frequencyPenalty"]);H!=null&&c(s,["frequencyPenalty"],H);const V=u(n,["seed"]);V!=null&&c(s,["seed"],V);const Y=u(n,["responseMimeType"]);Y!=null&&c(s,["responseMimeType"],Y);const J=u(n,["responseSchema"]);J!=null&&c(s,["responseSchema"],Er(J));const X=u(n,["responseJsonSchema"]);if(X!=null&&c(s,["responseJsonSchema"],X),u(n,["routingConfig"])!==void 0)throw new Error("routingConfig parameter is not supported in Gemini API.");if(u(n,["modelSelectionConfig"])!==void 0)throw new Error("modelSelectionConfig parameter is not supported in Gemini API.");const P=u(n,["safetySettings"]);if(o!==void 0&&P!=null){let pe=P;Array.isArray(pe)&&(pe=pe.map(Ke=>hE(Ke))),c(o,["safetySettings"],pe)}const K=u(n,["tools"]);if(o!==void 0&&K!=null){let pe=hi(K);Array.isArray(pe)&&(pe=pe.map(Ke=>EE(pi(Ke)))),c(o,["tools"],pe)}const te=u(n,["toolConfig"]);if(o!==void 0&&te!=null&&c(o,["toolConfig"],te),u(n,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const le=u(n,["cachedContent"]);o!==void 0&&le!=null&&c(o,["cachedContent"],Dn(l,le));const F=u(n,["responseModalities"]);F!=null&&c(s,["responseModalities"],F);const ve=u(n,["mediaResolution"]);ve!=null&&c(s,["mediaResolution"],ve);const $=u(n,["speechConfig"]);if($!=null&&c(s,["speechConfig"],_r($)),u(n,["audioTimestamp"])!==void 0)throw new Error("audioTimestamp parameter is not supported in Gemini API.");const Te=u(n,["thinkingConfig"]);Te!=null&&c(s,["thinkingConfig"],Te);const Me=u(n,["imageConfig"]);return Me!=null&&c(s,["imageConfig"],Me),s}function RS(l,n,o){const s={},r=u(n,["systemInstruction"]);o!==void 0&&r!=null&&c(o,["systemInstruction"],St(r));const d=u(n,["temperature"]);d!=null&&c(s,["temperature"],d);const p=u(n,["topP"]);p!=null&&c(s,["topP"],p);const g=u(n,["topK"]);g!=null&&c(s,["topK"],g);const y=u(n,["candidateCount"]);y!=null&&c(s,["candidateCount"],y);const h=u(n,["maxOutputTokens"]);h!=null&&c(s,["maxOutputTokens"],h);const T=u(n,["stopSequences"]);T!=null&&c(s,["stopSequences"],T);const S=u(n,["responseLogprobs"]);S!=null&&c(s,["responseLogprobs"],S);const _=u(n,["logprobs"]);_!=null&&c(s,["logprobs"],_);const R=u(n,["presencePenalty"]);R!=null&&c(s,["presencePenalty"],R);const H=u(n,["frequencyPenalty"]);H!=null&&c(s,["frequencyPenalty"],H);const V=u(n,["seed"]);V!=null&&c(s,["seed"],V);const Y=u(n,["responseMimeType"]);Y!=null&&c(s,["responseMimeType"],Y);const J=u(n,["responseSchema"]);J!=null&&c(s,["responseSchema"],Er(J));const X=u(n,["responseJsonSchema"]);X!=null&&c(s,["responseJsonSchema"],X);const P=u(n,["routingConfig"]);P!=null&&c(s,["routingConfig"],P);const K=u(n,["modelSelectionConfig"]);K!=null&&c(s,["modelConfig"],K);const te=u(n,["safetySettings"]);if(o!==void 0&&te!=null){let I=te;Array.isArray(I)&&(I=I.map(k=>k)),c(o,["safetySettings"],I)}const le=u(n,["tools"]);if(o!==void 0&&le!=null){let I=hi(le);Array.isArray(I)&&(I=I.map(k=>Ch(pi(k)))),c(o,["tools"],I)}const F=u(n,["toolConfig"]);o!==void 0&&F!=null&&c(o,["toolConfig"],F);const ve=u(n,["labels"]);o!==void 0&&ve!=null&&c(o,["labels"],ve);const $=u(n,["cachedContent"]);o!==void 0&&$!=null&&c(o,["cachedContent"],Dn(l,$));const Te=u(n,["responseModalities"]);Te!=null&&c(s,["responseModalities"],Te);const Me=u(n,["mediaResolution"]);Me!=null&&c(s,["mediaResolution"],Me);const pe=u(n,["speechConfig"]);pe!=null&&c(s,["speechConfig"],_h(_r(pe)));const Ke=u(n,["audioTimestamp"]);Ke!=null&&c(s,["audioTimestamp"],Ke);const st=u(n,["thinkingConfig"]);st!=null&&c(s,["thinkingConfig"],st);const Oe=u(n,["imageConfig"]);return Oe!=null&&c(s,["imageConfig"],Oe),s}function Jp(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],we(l,s));const r=u(n,["contents"]);if(r!=null){let p=$t(r);Array.isArray(p)&&(p=p.map(g=>Va(g))),c(o,["contents"],p)}const d=u(n,["config"]);return d!=null&&c(o,["generationConfig"],NS(l,d,o)),o}function Op(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],we(l,s));const r=u(n,["contents"]);if(r!=null){let p=$t(r);Array.isArray(p)&&(p=p.map(g=>g)),c(o,["contents"],p)}const d=u(n,["config"]);return d!=null&&c(o,["generationConfig"],RS(l,d,o)),o}function Fp(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["candidates"]);if(s!=null){let y=s;Array.isArray(y)&&(y=y.map(h=>WT(h))),c(n,["candidates"],y)}const r=u(l,["modelVersion"]);r!=null&&c(n,["modelVersion"],r);const d=u(l,["promptFeedback"]);d!=null&&c(n,["promptFeedback"],d);const p=u(l,["responseId"]);p!=null&&c(n,["responseId"],p);const g=u(l,["usageMetadata"]);return g!=null&&c(n,["usageMetadata"],g),n}function Xp(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["candidates"]);if(s!=null){let h=s;Array.isArray(h)&&(h=h.map(T=>T)),c(n,["candidates"],h)}const r=u(l,["createTime"]);r!=null&&c(n,["createTime"],r);const d=u(l,["modelVersion"]);d!=null&&c(n,["modelVersion"],d);const p=u(l,["promptFeedback"]);p!=null&&c(n,["promptFeedback"],p);const g=u(l,["responseId"]);g!=null&&c(n,["responseId"],g);const y=u(l,["usageMetadata"]);return y!=null&&c(n,["usageMetadata"],y),n}function bS(l,n){const o={};if(u(l,["outputGcsUri"])!==void 0)throw new Error("outputGcsUri parameter is not supported in Gemini API.");if(u(l,["negativePrompt"])!==void 0)throw new Error("negativePrompt parameter is not supported in Gemini API.");const s=u(l,["numberOfImages"]);n!==void 0&&s!=null&&c(n,["parameters","sampleCount"],s);const r=u(l,["aspectRatio"]);n!==void 0&&r!=null&&c(n,["parameters","aspectRatio"],r);const d=u(l,["guidanceScale"]);if(n!==void 0&&d!=null&&c(n,["parameters","guidanceScale"],d),u(l,["seed"])!==void 0)throw new Error("seed parameter is not supported in Gemini API.");const p=u(l,["safetyFilterLevel"]);n!==void 0&&p!=null&&c(n,["parameters","safetySetting"],p);const g=u(l,["personGeneration"]);n!==void 0&&g!=null&&c(n,["parameters","personGeneration"],g);const y=u(l,["includeSafetyAttributes"]);n!==void 0&&y!=null&&c(n,["parameters","includeSafetyAttributes"],y);const h=u(l,["includeRaiReason"]);n!==void 0&&h!=null&&c(n,["parameters","includeRaiReason"],h);const T=u(l,["language"]);n!==void 0&&T!=null&&c(n,["parameters","language"],T);const S=u(l,["outputMimeType"]);n!==void 0&&S!=null&&c(n,["parameters","outputOptions","mimeType"],S);const _=u(l,["outputCompressionQuality"]);if(n!==void 0&&_!=null&&c(n,["parameters","outputOptions","compressionQuality"],_),u(l,["addWatermark"])!==void 0)throw new Error("addWatermark parameter is not supported in Gemini API.");if(u(l,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const R=u(l,["imageSize"]);if(n!==void 0&&R!=null&&c(n,["parameters","sampleImageSize"],R),u(l,["enhancePrompt"])!==void 0)throw new Error("enhancePrompt parameter is not supported in Gemini API.");return o}function DS(l,n){const o={},s=u(l,["outputGcsUri"]);n!==void 0&&s!=null&&c(n,["parameters","storageUri"],s);const r=u(l,["negativePrompt"]);n!==void 0&&r!=null&&c(n,["parameters","negativePrompt"],r);const d=u(l,["numberOfImages"]);n!==void 0&&d!=null&&c(n,["parameters","sampleCount"],d);const p=u(l,["aspectRatio"]);n!==void 0&&p!=null&&c(n,["parameters","aspectRatio"],p);const g=u(l,["guidanceScale"]);n!==void 0&&g!=null&&c(n,["parameters","guidanceScale"],g);const y=u(l,["seed"]);n!==void 0&&y!=null&&c(n,["parameters","seed"],y);const h=u(l,["safetyFilterLevel"]);n!==void 0&&h!=null&&c(n,["parameters","safetySetting"],h);const T=u(l,["personGeneration"]);n!==void 0&&T!=null&&c(n,["parameters","personGeneration"],T);const S=u(l,["includeSafetyAttributes"]);n!==void 0&&S!=null&&c(n,["parameters","includeSafetyAttributes"],S);const _=u(l,["includeRaiReason"]);n!==void 0&&_!=null&&c(n,["parameters","includeRaiReason"],_);const R=u(l,["language"]);n!==void 0&&R!=null&&c(n,["parameters","language"],R);const H=u(l,["outputMimeType"]);n!==void 0&&H!=null&&c(n,["parameters","outputOptions","mimeType"],H);const V=u(l,["outputCompressionQuality"]);n!==void 0&&V!=null&&c(n,["parameters","outputOptions","compressionQuality"],V);const Y=u(l,["addWatermark"]);n!==void 0&&Y!=null&&c(n,["parameters","addWatermark"],Y);const J=u(l,["labels"]);n!==void 0&&J!=null&&c(n,["labels"],J);const X=u(l,["imageSize"]);n!==void 0&&X!=null&&c(n,["parameters","sampleImageSize"],X);const P=u(l,["enhancePrompt"]);return n!==void 0&&P!=null&&c(n,["parameters","enhancePrompt"],P),o}function wS(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],we(l,s));const r=u(n,["prompt"]);r!=null&&c(o,["instances[0]","prompt"],r);const d=u(n,["config"]);return d!=null&&bS(d,o),o}function US(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],we(l,s));const r=u(n,["prompt"]);r!=null&&c(o,["instances[0]","prompt"],r);const d=u(n,["config"]);return d!=null&&DS(d,o),o}function IS(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["predictions"]);if(s!=null){let d=s;Array.isArray(d)&&(d=d.map(p=>OS(p))),c(n,["generatedImages"],d)}const r=u(l,["positivePromptSafetyAttributes"]);return r!=null&&c(n,["positivePromptSafetyAttributes"],Sh(r)),n}function qS(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["predictions"]);if(s!=null){let d=s;Array.isArray(d)&&(d=d.map(p=>Ba(p))),c(n,["generatedImages"],d)}const r=u(l,["positivePromptSafetyAttributes"]);return r!=null&&c(n,["positivePromptSafetyAttributes"],Eh(r)),n}function LS(l,n){const o={},s=u(l,["numberOfVideos"]);if(n!==void 0&&s!=null&&c(n,["parameters","sampleCount"],s),u(l,["outputGcsUri"])!==void 0)throw new Error("outputGcsUri parameter is not supported in Gemini API.");if(u(l,["fps"])!==void 0)throw new Error("fps parameter is not supported in Gemini API.");const r=u(l,["durationSeconds"]);if(n!==void 0&&r!=null&&c(n,["parameters","durationSeconds"],r),u(l,["seed"])!==void 0)throw new Error("seed parameter is not supported in Gemini API.");const d=u(l,["aspectRatio"]);n!==void 0&&d!=null&&c(n,["parameters","aspectRatio"],d);const p=u(l,["resolution"]);n!==void 0&&p!=null&&c(n,["parameters","resolution"],p);const g=u(l,["personGeneration"]);if(n!==void 0&&g!=null&&c(n,["parameters","personGeneration"],g),u(l,["pubsubTopic"])!==void 0)throw new Error("pubsubTopic parameter is not supported in Gemini API.");const y=u(l,["negativePrompt"]);n!==void 0&&y!=null&&c(n,["parameters","negativePrompt"],y);const h=u(l,["enhancePrompt"]);if(n!==void 0&&h!=null&&c(n,["parameters","enhancePrompt"],h),u(l,["generateAudio"])!==void 0)throw new Error("generateAudio parameter is not supported in Gemini API.");const T=u(l,["lastFrame"]);n!==void 0&&T!=null&&c(n,["instances[0]","lastFrame"],Pa(T));const S=u(l,["referenceImages"]);if(n!==void 0&&S!=null){let _=S;Array.isArray(_)&&(_=_.map(R=>qE(R))),c(n,["instances[0]","referenceImages"],_)}if(u(l,["mask"])!==void 0)throw new Error("mask parameter is not supported in Gemini API.");if(u(l,["compressionQuality"])!==void 0)throw new Error("compressionQuality parameter is not supported in Gemini API.");return o}function GS(l,n){const o={},s=u(l,["numberOfVideos"]);n!==void 0&&s!=null&&c(n,["parameters","sampleCount"],s);const r=u(l,["outputGcsUri"]);n!==void 0&&r!=null&&c(n,["parameters","storageUri"],r);const d=u(l,["fps"]);n!==void 0&&d!=null&&c(n,["parameters","fps"],d);const p=u(l,["durationSeconds"]);n!==void 0&&p!=null&&c(n,["parameters","durationSeconds"],p);const g=u(l,["seed"]);n!==void 0&&g!=null&&c(n,["parameters","seed"],g);const y=u(l,["aspectRatio"]);n!==void 0&&y!=null&&c(n,["parameters","aspectRatio"],y);const h=u(l,["resolution"]);n!==void 0&&h!=null&&c(n,["parameters","resolution"],h);const T=u(l,["personGeneration"]);n!==void 0&&T!=null&&c(n,["parameters","personGeneration"],T);const S=u(l,["pubsubTopic"]);n!==void 0&&S!=null&&c(n,["parameters","pubsubTopic"],S);const _=u(l,["negativePrompt"]);n!==void 0&&_!=null&&c(n,["parameters","negativePrompt"],_);const R=u(l,["enhancePrompt"]);n!==void 0&&R!=null&&c(n,["parameters","enhancePrompt"],R);const H=u(l,["generateAudio"]);n!==void 0&&H!=null&&c(n,["parameters","generateAudio"],H);const V=u(l,["lastFrame"]);n!==void 0&&V!=null&&c(n,["instances[0]","lastFrame"],nn(V));const Y=u(l,["referenceImages"]);if(n!==void 0&&Y!=null){let P=Y;Array.isArray(P)&&(P=P.map(K=>LE(K))),c(n,["instances[0]","referenceImages"],P)}const J=u(l,["mask"]);n!==void 0&&J!=null&&c(n,["instances[0]","mask"],IE(J));const X=u(l,["compressionQuality"]);return n!==void 0&&X!=null&&c(n,["parameters","compressionQuality"],X),o}function HS(l){const n={},o=u(l,["name"]);o!=null&&c(n,["name"],o);const s=u(l,["metadata"]);s!=null&&c(n,["metadata"],s);const r=u(l,["done"]);r!=null&&c(n,["done"],r);const d=u(l,["error"]);d!=null&&c(n,["error"],d);const p=u(l,["response","generateVideoResponse"]);return p!=null&&c(n,["response"],PS(p)),n}function zS(l){const n={},o=u(l,["name"]);o!=null&&c(n,["name"],o);const s=u(l,["metadata"]);s!=null&&c(n,["metadata"],s);const r=u(l,["done"]);r!=null&&c(n,["done"],r);const d=u(l,["error"]);d!=null&&c(n,["error"],d);const p=u(l,["response"]);return p!=null&&c(n,["response"],kS(p)),n}function VS(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],we(l,s));const r=u(n,["prompt"]);r!=null&&c(o,["instances[0]","prompt"],r);const d=u(n,["image"]);d!=null&&c(o,["instances[0]","image"],Pa(d));const p=u(n,["video"]);p!=null&&c(o,["instances[0]","video"],Ah(p));const g=u(n,["source"]);g!=null&&YS(g,o);const y=u(n,["config"]);return y!=null&&LS(y,o),o}function BS(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],we(l,s));const r=u(n,["prompt"]);r!=null&&c(o,["instances[0]","prompt"],r);const d=u(n,["image"]);d!=null&&c(o,["instances[0]","image"],nn(d));const p=u(n,["video"]);p!=null&&c(o,["instances[0]","video"],xh(p));const g=u(n,["source"]);g!=null&&JS(g,o);const y=u(n,["config"]);return y!=null&&GS(y,o),o}function PS(l){const n={},o=u(l,["generatedSamples"]);if(o!=null){let d=o;Array.isArray(d)&&(d=d.map(p=>XS(p))),c(n,["generatedVideos"],d)}const s=u(l,["raiMediaFilteredCount"]);s!=null&&c(n,["raiMediaFilteredCount"],s);const r=u(l,["raiMediaFilteredReasons"]);return r!=null&&c(n,["raiMediaFilteredReasons"],r),n}function kS(l){const n={},o=u(l,["videos"]);if(o!=null){let d=o;Array.isArray(d)&&(d=d.map(p=>KS(p))),c(n,["generatedVideos"],d)}const s=u(l,["raiMediaFilteredCount"]);s!=null&&c(n,["raiMediaFilteredCount"],s);const r=u(l,["raiMediaFilteredReasons"]);return r!=null&&c(n,["raiMediaFilteredReasons"],r),n}function YS(l,n){const o={},s=u(l,["prompt"]);n!==void 0&&s!=null&&c(n,["instances[0]","prompt"],s);const r=u(l,["image"]);n!==void 0&&r!=null&&c(n,["instances[0]","image"],Pa(r));const d=u(l,["video"]);return n!==void 0&&d!=null&&c(n,["instances[0]","video"],Ah(d)),o}function JS(l,n){const o={},s=u(l,["prompt"]);n!==void 0&&s!=null&&c(n,["instances[0]","prompt"],s);const r=u(l,["image"]);n!==void 0&&r!=null&&c(n,["instances[0]","image"],nn(r));const d=u(l,["video"]);return n!==void 0&&d!=null&&c(n,["instances[0]","video"],xh(d)),o}function OS(l){const n={},o=u(l,["_self"]);o!=null&&c(n,["image"],eE(o));const s=u(l,["raiFilteredReason"]);s!=null&&c(n,["raiFilteredReason"],s);const r=u(l,["_self"]);return r!=null&&c(n,["safetyAttributes"],Sh(r)),n}function Ba(l){const n={},o=u(l,["_self"]);o!=null&&c(n,["image"],Th(o));const s=u(l,["raiFilteredReason"]);s!=null&&c(n,["raiFilteredReason"],s);const r=u(l,["_self"]);r!=null&&c(n,["safetyAttributes"],Eh(r));const d=u(l,["prompt"]);return d!=null&&c(n,["enhancedPrompt"],d),n}function FS(l){const n={},o=u(l,["_self"]);o!=null&&c(n,["mask"],Th(o));const s=u(l,["labels"]);if(s!=null){let r=s;Array.isArray(r)&&(r=r.map(d=>d)),c(n,["labels"],r)}return n}function XS(l){const n={},o=u(l,["video"]);return o!=null&&c(n,["video"],wE(o)),n}function KS(l){const n={},o=u(l,["_self"]);return o!=null&&c(n,["video"],UE(o)),n}function QS(l){const n={},o=u(l,["modelSelectionConfig"]);o!=null&&c(n,["modelConfig"],o);const s=u(l,["audioTimestamp"]);s!=null&&c(n,["audioTimestamp"],s);const r=u(l,["candidateCount"]);r!=null&&c(n,["candidateCount"],r);const d=u(l,["enableAffectiveDialog"]);d!=null&&c(n,["enableAffectiveDialog"],d);const p=u(l,["frequencyPenalty"]);p!=null&&c(n,["frequencyPenalty"],p);const g=u(l,["logprobs"]);g!=null&&c(n,["logprobs"],g);const y=u(l,["maxOutputTokens"]);y!=null&&c(n,["maxOutputTokens"],y);const h=u(l,["mediaResolution"]);h!=null&&c(n,["mediaResolution"],h);const T=u(l,["presencePenalty"]);T!=null&&c(n,["presencePenalty"],T);const S=u(l,["responseJsonSchema"]);S!=null&&c(n,["responseJsonSchema"],S);const _=u(l,["responseLogprobs"]);_!=null&&c(n,["responseLogprobs"],_);const R=u(l,["responseMimeType"]);R!=null&&c(n,["responseMimeType"],R);const H=u(l,["responseModalities"]);H!=null&&c(n,["responseModalities"],H);const V=u(l,["responseSchema"]);V!=null&&c(n,["responseSchema"],V);const Y=u(l,["routingConfig"]);Y!=null&&c(n,["routingConfig"],Y);const J=u(l,["seed"]);J!=null&&c(n,["seed"],J);const X=u(l,["speechConfig"]);X!=null&&c(n,["speechConfig"],_h(X));const P=u(l,["stopSequences"]);P!=null&&c(n,["stopSequences"],P);const K=u(l,["temperature"]);K!=null&&c(n,["temperature"],K);const te=u(l,["thinkingConfig"]);te!=null&&c(n,["thinkingConfig"],te);const le=u(l,["topK"]);le!=null&&c(n,["topK"],le);const F=u(l,["topP"]);return F!=null&&c(n,["topP"],F),n}function ZS(l,n){const o={},s=u(n,["model"]);return s!=null&&c(o,["_url","name"],we(l,s)),o}function $S(l,n){const o={},s=u(n,["model"]);return s!=null&&c(o,["_url","name"],we(l,s)),o}function WS(l){const n={};if(u(l,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const o=u(l,["enableWidget"]);return o!=null&&c(n,["enableWidget"],o),n}function jS(l){const n={},o=u(l,["timeRangeFilter"]);if(o!=null&&c(n,["timeRangeFilter"],o),u(l,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");return n}function eE(l){const n={},o=u(l,["bytesBase64Encoded"]);o!=null&&c(n,["imageBytes"],nl(o));const s=u(l,["mimeType"]);return s!=null&&c(n,["mimeType"],s),n}function Th(l){const n={},o=u(l,["gcsUri"]);o!=null&&c(n,["gcsUri"],o);const s=u(l,["bytesBase64Encoded"]);s!=null&&c(n,["imageBytes"],nl(s));const r=u(l,["mimeType"]);return r!=null&&c(n,["mimeType"],r),n}function Pa(l){const n={};if(u(l,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");const o=u(l,["imageBytes"]);o!=null&&c(n,["bytesBase64Encoded"],nl(o));const s=u(l,["mimeType"]);return s!=null&&c(n,["mimeType"],s),n}function nn(l){const n={},o=u(l,["gcsUri"]);o!=null&&c(n,["gcsUri"],o);const s=u(l,["imageBytes"]);s!=null&&c(n,["bytesBase64Encoded"],nl(s));const r=u(l,["mimeType"]);return r!=null&&c(n,["mimeType"],r),n}function tE(l,n,o){const s={},r=u(n,["pageSize"]);o!==void 0&&r!=null&&c(o,["_query","pageSize"],r);const d=u(n,["pageToken"]);o!==void 0&&d!=null&&c(o,["_query","pageToken"],d);const p=u(n,["filter"]);o!==void 0&&p!=null&&c(o,["_query","filter"],p);const g=u(n,["queryBase"]);return o!==void 0&&g!=null&&c(o,["_url","models_url"],fh(l,g)),s}function nE(l,n,o){const s={},r=u(n,["pageSize"]);o!==void 0&&r!=null&&c(o,["_query","pageSize"],r);const d=u(n,["pageToken"]);o!==void 0&&d!=null&&c(o,["_query","pageToken"],d);const p=u(n,["filter"]);o!==void 0&&p!=null&&c(o,["_query","filter"],p);const g=u(n,["queryBase"]);return o!==void 0&&g!=null&&c(o,["_url","models_url"],fh(l,g)),s}function lE(l,n){const o={},s=u(n,["config"]);return s!=null&&tE(l,s,o),o}function iE(l,n){const o={},s=u(n,["config"]);return s!=null&&nE(l,s,o),o}function oE(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["nextPageToken"]);s!=null&&c(n,["nextPageToken"],s);const r=u(l,["_self"]);if(r!=null){let d=dh(r);Array.isArray(d)&&(d=d.map(p=>pr(p))),c(n,["models"],d)}return n}function aE(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["nextPageToken"]);s!=null&&c(n,["nextPageToken"],s);const r=u(l,["_self"]);if(r!=null){let d=dh(r);Array.isArray(d)&&(d=d.map(p=>hr(p))),c(n,["models"],d)}return n}function sE(l){const n={},o=u(l,["maskMode"]);o!=null&&c(n,["maskMode"],o);const s=u(l,["segmentationClasses"]);s!=null&&c(n,["maskClasses"],s);const r=u(l,["maskDilation"]);return r!=null&&c(n,["dilation"],r),n}function pr(l){const n={},o=u(l,["name"]);o!=null&&c(n,["name"],o);const s=u(l,["displayName"]);s!=null&&c(n,["displayName"],s);const r=u(l,["description"]);r!=null&&c(n,["description"],r);const d=u(l,["version"]);d!=null&&c(n,["version"],d);const p=u(l,["_self"]);p!=null&&c(n,["tunedModelInfo"],_E(p));const g=u(l,["inputTokenLimit"]);g!=null&&c(n,["inputTokenLimit"],g);const y=u(l,["outputTokenLimit"]);y!=null&&c(n,["outputTokenLimit"],y);const h=u(l,["supportedGenerationMethods"]);return h!=null&&c(n,["supportedActions"],h),n}function hr(l){const n={},o=u(l,["name"]);o!=null&&c(n,["name"],o);const s=u(l,["displayName"]);s!=null&&c(n,["displayName"],s);const r=u(l,["description"]);r!=null&&c(n,["description"],r);const d=u(l,["versionId"]);d!=null&&c(n,["version"],d);const p=u(l,["deployedModels"]);if(p!=null){let S=p;Array.isArray(S)&&(S=S.map(_=>AS(_))),c(n,["endpoints"],S)}const g=u(l,["labels"]);g!=null&&c(n,["labels"],g);const y=u(l,["_self"]);y!=null&&c(n,["tunedModelInfo"],CE(y));const h=u(l,["defaultCheckpointId"]);h!=null&&c(n,["defaultCheckpointId"],h);const T=u(l,["checkpoints"]);if(T!=null){let S=T;Array.isArray(S)&&(S=S.map(_=>_)),c(n,["checkpoints"],S)}return n}function uE(l){const n={},o=u(l,["videoMetadata"]);o!=null&&c(n,["videoMetadata"],o);const s=u(l,["thought"]);s!=null&&c(n,["thought"],s);const r=u(l,["inlineData"]);r!=null&&c(n,["inlineData"],$T(r));const d=u(l,["fileData"]);d!=null&&c(n,["fileData"],xS(d));const p=u(l,["thoughtSignature"]);p!=null&&c(n,["thoughtSignature"],p);const g=u(l,["functionCall"]);g!=null&&c(n,["functionCall"],g);const y=u(l,["codeExecutionResult"]);y!=null&&c(n,["codeExecutionResult"],y);const h=u(l,["executableCode"]);h!=null&&c(n,["executableCode"],h);const T=u(l,["functionResponse"]);T!=null&&c(n,["functionResponse"],T);const S=u(l,["text"]);return S!=null&&c(n,["text"],S),n}function rE(l){const n={},o=u(l,["productImage"]);return o!=null&&c(n,["image"],nn(o)),n}function cE(l,n){const o={},s=u(l,["numberOfImages"]);n!==void 0&&s!=null&&c(n,["parameters","sampleCount"],s);const r=u(l,["baseSteps"]);n!==void 0&&r!=null&&c(n,["parameters","editConfig","baseSteps"],r);const d=u(l,["outputGcsUri"]);n!==void 0&&d!=null&&c(n,["parameters","storageUri"],d);const p=u(l,["seed"]);n!==void 0&&p!=null&&c(n,["parameters","seed"],p);const g=u(l,["safetyFilterLevel"]);n!==void 0&&g!=null&&c(n,["parameters","safetySetting"],g);const y=u(l,["personGeneration"]);n!==void 0&&y!=null&&c(n,["parameters","personGeneration"],y);const h=u(l,["addWatermark"]);n!==void 0&&h!=null&&c(n,["parameters","addWatermark"],h);const T=u(l,["outputMimeType"]);n!==void 0&&T!=null&&c(n,["parameters","outputOptions","mimeType"],T);const S=u(l,["outputCompressionQuality"]);n!==void 0&&S!=null&&c(n,["parameters","outputOptions","compressionQuality"],S);const _=u(l,["enhancePrompt"]);n!==void 0&&_!=null&&c(n,["parameters","enhancePrompt"],_);const R=u(l,["labels"]);return n!==void 0&&R!=null&&c(n,["labels"],R),o}function fE(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],we(l,s));const r=u(n,["source"]);r!=null&&mE(r,o);const d=u(n,["config"]);return d!=null&&cE(d,o),o}function dE(l){const n={},o=u(l,["predictions"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(r=>Ba(r))),c(n,["generatedImages"],s)}return n}function mE(l,n){const o={},s=u(l,["prompt"]);n!==void 0&&s!=null&&c(n,["instances[0]","prompt"],s);const r=u(l,["personImage"]);n!==void 0&&r!=null&&c(n,["instances[0]","personImage","image"],nn(r));const d=u(l,["productImages"]);if(n!==void 0&&d!=null){let p=d;Array.isArray(p)&&(p=p.map(g=>rE(g))),c(n,["instances[0]","productImages"],p)}return o}function pE(l){const n={},o=u(l,["referenceImage"]);o!=null&&c(n,["referenceImage"],nn(o));const s=u(l,["referenceId"]);s!=null&&c(n,["referenceId"],s);const r=u(l,["referenceType"]);r!=null&&c(n,["referenceType"],r);const d=u(l,["maskImageConfig"]);d!=null&&c(n,["maskImageConfig"],sE(d));const p=u(l,["controlImageConfig"]);p!=null&&c(n,["controlImageConfig"],iS(p));const g=u(l,["styleImageConfig"]);g!=null&&c(n,["styleImageConfig"],g);const y=u(l,["subjectImageConfig"]);return y!=null&&c(n,["subjectImageConfig"],y),n}function Sh(l){const n={},o=u(l,["safetyAttributes","categories"]);o!=null&&c(n,["categories"],o);const s=u(l,["safetyAttributes","scores"]);s!=null&&c(n,["scores"],s);const r=u(l,["contentType"]);return r!=null&&c(n,["contentType"],r),n}function Eh(l){const n={},o=u(l,["safetyAttributes","categories"]);o!=null&&c(n,["categories"],o);const s=u(l,["safetyAttributes","scores"]);s!=null&&c(n,["scores"],s);const r=u(l,["contentType"]);return r!=null&&c(n,["contentType"],r),n}function hE(l){const n={};if(u(l,["method"])!==void 0)throw new Error("method parameter is not supported in Gemini API.");const o=u(l,["category"]);o!=null&&c(n,["category"],o);const s=u(l,["threshold"]);return s!=null&&c(n,["threshold"],s),n}function gE(l){const n={},o=u(l,["image"]);return o!=null&&c(n,["image"],nn(o)),n}function yE(l,n){const o={},s=u(l,["mode"]);n!==void 0&&s!=null&&c(n,["parameters","mode"],s);const r=u(l,["maxPredictions"]);n!==void 0&&r!=null&&c(n,["parameters","maxPredictions"],r);const d=u(l,["confidenceThreshold"]);n!==void 0&&d!=null&&c(n,["parameters","confidenceThreshold"],d);const p=u(l,["maskDilation"]);n!==void 0&&p!=null&&c(n,["parameters","maskDilation"],p);const g=u(l,["binaryColorThreshold"]);n!==void 0&&g!=null&&c(n,["parameters","binaryColorThreshold"],g);const y=u(l,["labels"]);return n!==void 0&&y!=null&&c(n,["labels"],y),o}function vE(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],we(l,s));const r=u(n,["source"]);r!=null&&SE(r,o);const d=u(n,["config"]);return d!=null&&yE(d,o),o}function TE(l){const n={},o=u(l,["predictions"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(r=>FS(r))),c(n,["generatedMasks"],s)}return n}function SE(l,n){const o={},s=u(l,["prompt"]);n!==void 0&&s!=null&&c(n,["instances[0]","prompt"],s);const r=u(l,["image"]);n!==void 0&&r!=null&&c(n,["instances[0]","image"],nn(r));const d=u(l,["scribbleImage"]);return n!==void 0&&d!=null&&c(n,["instances[0]","scribble"],gE(d)),o}function _h(l){const n={},o=u(l,["voiceConfig"]);if(o!=null&&c(n,["voiceConfig"],o),u(l,["multiSpeakerVoiceConfig"])!==void 0)throw new Error("multiSpeakerVoiceConfig parameter is not supported in Vertex AI.");const s=u(l,["languageCode"]);return s!=null&&c(n,["languageCode"],s),n}function EE(l){const n={},o=u(l,["functionDeclarations"]);if(o!=null){let h=o;Array.isArray(h)&&(h=h.map(T=>T)),c(n,["functionDeclarations"],h)}if(u(l,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const s=u(l,["googleSearch"]);s!=null&&c(n,["googleSearch"],jS(s));const r=u(l,["googleSearchRetrieval"]);if(r!=null&&c(n,["googleSearchRetrieval"],r),u(l,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const d=u(l,["googleMaps"]);d!=null&&c(n,["googleMaps"],WS(d));const p=u(l,["urlContext"]);p!=null&&c(n,["urlContext"],p);const g=u(l,["computerUse"]);g!=null&&c(n,["computerUse"],g);const y=u(l,["codeExecution"]);return y!=null&&c(n,["codeExecution"],y),n}function Ch(l){const n={},o=u(l,["functionDeclarations"]);if(o!=null){let S=o;Array.isArray(S)&&(S=S.map(_=>MS(_))),c(n,["functionDeclarations"],S)}const s=u(l,["retrieval"]);s!=null&&c(n,["retrieval"],s);const r=u(l,["googleSearch"]);r!=null&&c(n,["googleSearch"],r);const d=u(l,["googleSearchRetrieval"]);d!=null&&c(n,["googleSearchRetrieval"],d);const p=u(l,["enterpriseWebSearch"]);p!=null&&c(n,["enterpriseWebSearch"],p);const g=u(l,["googleMaps"]);g!=null&&c(n,["googleMaps"],g);const y=u(l,["urlContext"]);y!=null&&c(n,["urlContext"],y);const h=u(l,["computerUse"]);h!=null&&c(n,["computerUse"],h);const T=u(l,["codeExecution"]);return T!=null&&c(n,["codeExecution"],T),n}function _E(l){const n={},o=u(l,["baseModel"]);o!=null&&c(n,["baseModel"],o);const s=u(l,["createTime"]);s!=null&&c(n,["createTime"],s);const r=u(l,["updateTime"]);return r!=null&&c(n,["updateTime"],r),n}function CE(l){const n={},o=u(l,["labels","google-vertex-llm-tuning-base-model-id"]);o!=null&&c(n,["baseModel"],o);const s=u(l,["createTime"]);s!=null&&c(n,["createTime"],s);const r=u(l,["updateTime"]);return r!=null&&c(n,["updateTime"],r),n}function AE(l,n){const o={},s=u(l,["displayName"]);n!==void 0&&s!=null&&c(n,["displayName"],s);const r=u(l,["description"]);n!==void 0&&r!=null&&c(n,["description"],r);const d=u(l,["defaultCheckpointId"]);return n!==void 0&&d!=null&&c(n,["defaultCheckpointId"],d),o}function xE(l,n){const o={},s=u(l,["displayName"]);n!==void 0&&s!=null&&c(n,["displayName"],s);const r=u(l,["description"]);n!==void 0&&r!=null&&c(n,["description"],r);const d=u(l,["defaultCheckpointId"]);return n!==void 0&&d!=null&&c(n,["defaultCheckpointId"],d),o}function ME(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","name"],we(l,s));const r=u(n,["config"]);return r!=null&&AE(r,o),o}function NE(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],we(l,s));const r=u(n,["config"]);return r!=null&&xE(r,o),o}function RE(l,n){const o={},s=u(l,["outputGcsUri"]);n!==void 0&&s!=null&&c(n,["parameters","storageUri"],s);const r=u(l,["includeRaiReason"]);n!==void 0&&r!=null&&c(n,["parameters","includeRaiReason"],r);const d=u(l,["outputMimeType"]);n!==void 0&&d!=null&&c(n,["parameters","outputOptions","mimeType"],d);const p=u(l,["outputCompressionQuality"]);n!==void 0&&p!=null&&c(n,["parameters","outputOptions","compressionQuality"],p);const g=u(l,["enhanceInputImage"]);n!==void 0&&g!=null&&c(n,["parameters","upscaleConfig","enhanceInputImage"],g);const y=u(l,["imagePreservationFactor"]);n!==void 0&&y!=null&&c(n,["parameters","upscaleConfig","imagePreservationFactor"],y);const h=u(l,["labels"]);n!==void 0&&h!=null&&c(n,["labels"],h);const T=u(l,["numberOfImages"]);n!==void 0&&T!=null&&c(n,["parameters","sampleCount"],T);const S=u(l,["mode"]);return n!==void 0&&S!=null&&c(n,["parameters","mode"],S),o}function bE(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["_url","model"],we(l,s));const r=u(n,["image"]);r!=null&&c(o,["instances[0]","image"],nn(r));const d=u(n,["upscaleFactor"]);d!=null&&c(o,["parameters","upscaleConfig","upscaleFactor"],d);const p=u(n,["config"]);return p!=null&&RE(p,o),o}function DE(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["predictions"]);if(s!=null){let r=s;Array.isArray(r)&&(r=r.map(d=>Ba(d))),c(n,["generatedImages"],r)}return n}function wE(l){const n={},o=u(l,["uri"]);o!=null&&c(n,["uri"],o);const s=u(l,["encodedVideo"]);s!=null&&c(n,["videoBytes"],nl(s));const r=u(l,["encoding"]);return r!=null&&c(n,["mimeType"],r),n}function UE(l){const n={},o=u(l,["gcsUri"]);o!=null&&c(n,["uri"],o);const s=u(l,["bytesBase64Encoded"]);s!=null&&c(n,["videoBytes"],nl(s));const r=u(l,["mimeType"]);return r!=null&&c(n,["mimeType"],r),n}function IE(l){const n={},o=u(l,["image"]);o!=null&&c(n,["_self"],nn(o));const s=u(l,["maskMode"]);return s!=null&&c(n,["maskMode"],s),n}function qE(l){const n={},o=u(l,["image"]);o!=null&&c(n,["image"],Pa(o));const s=u(l,["referenceType"]);return s!=null&&c(n,["referenceType"],s),n}function LE(l){const n={},o=u(l,["image"]);o!=null&&c(n,["image"],nn(o));const s=u(l,["referenceType"]);return s!=null&&c(n,["referenceType"],s),n}function Ah(l){const n={},o=u(l,["uri"]);o!=null&&c(n,["uri"],o);const s=u(l,["videoBytes"]);s!=null&&c(n,["encodedVideo"],nl(s));const r=u(l,["mimeType"]);return r!=null&&c(n,["encoding"],r),n}function xh(l){const n={},o=u(l,["uri"]);o!=null&&c(n,["gcsUri"],o);const s=u(l,["videoBytes"]);s!=null&&c(n,["bytesBase64Encoded"],nl(s));const r=u(l,["mimeType"]);return r!=null&&c(n,["mimeType"],r),n}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */const GE="Content-Type",HE="X-Server-Timeout",zE="User-Agent",gr="x-goog-api-client",VE="1.25.0",BE=`google-genai-sdk/${VE}`,PE="v1beta1",kE="v1beta",Kp=/^\s*data: (.*)(?:\n\n|\r\r|\r\n\r\n)/;class YE{constructor(n){var o,s;this.clientOptions=Object.assign(Object.assign({},n),{project:n.project,location:n.location,apiKey:n.apiKey,vertexai:n.vertexai});const r={};this.clientOptions.vertexai?(r.apiVersion=(o=this.clientOptions.apiVersion)!==null&&o!==void 0?o:PE,r.baseUrl=this.baseUrlFromProjectLocation(),this.normalizeAuthParameters()):(r.apiVersion=(s=this.clientOptions.apiVersion)!==null&&s!==void 0?s:kE,r.baseUrl="https://generativelanguage.googleapis.com/"),r.headers=this.getDefaultHeaders(),this.clientOptions.httpOptions=r,n.httpOptions&&(this.clientOptions.httpOptions=this.patchHttpOptions(r,n.httpOptions))}baseUrlFromProjectLocation(){return this.clientOptions.project&&this.clientOptions.location&&this.clientOptions.location!=="global"?`https://${this.clientOptions.location}-aiplatform.googleapis.com/`:"https://aiplatform.googleapis.com/"}normalizeAuthParameters(){if(this.clientOptions.project&&this.clientOptions.location){this.clientOptions.apiKey=void 0;return}this.clientOptions.project=void 0,this.clientOptions.location=void 0}isVertexAI(){var n;return(n=this.clientOptions.vertexai)!==null&&n!==void 0?n:!1}getProject(){return this.clientOptions.project}getLocation(){return this.clientOptions.location}getApiVersion(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.apiVersion!==void 0)return this.clientOptions.httpOptions.apiVersion;throw new Error("API version is not set.")}getBaseUrl(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.baseUrl!==void 0)return this.clientOptions.httpOptions.baseUrl;throw new Error("Base URL is not set.")}getRequestUrl(){return this.getRequestUrlInternal(this.clientOptions.httpOptions)}getHeaders(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.headers!==void 0)return this.clientOptions.httpOptions.headers;throw new Error("Headers are not set.")}getRequestUrlInternal(n){if(!n||n.baseUrl===void 0||n.apiVersion===void 0)throw new Error("HTTP options are not correctly set.");const s=[n.baseUrl.endsWith("/")?n.baseUrl.slice(0,-1):n.baseUrl];return n.apiVersion&&n.apiVersion!==""&&s.push(n.apiVersion),s.join("/")}getBaseResourcePath(){return`projects/${this.clientOptions.project}/locations/${this.clientOptions.location}`}getApiKey(){return this.clientOptions.apiKey}getWebsocketBaseUrl(){const n=this.getBaseUrl(),o=new URL(n);return o.protocol=o.protocol=="http:"?"ws":"wss",o.toString()}setBaseUrl(n){if(this.clientOptions.httpOptions)this.clientOptions.httpOptions.baseUrl=n;else throw new Error("HTTP options are not correctly set.")}constructUrl(n,o,s){const r=[this.getRequestUrlInternal(o)];return s&&r.push(this.getBaseResourcePath()),n!==""&&r.push(n),new URL(`${r.join("/")}`)}shouldPrependVertexProjectPath(n){return!(this.clientOptions.apiKey||!this.clientOptions.vertexai||n.path.startsWith("projects/")||n.httpMethod==="GET"&&n.path.startsWith("publishers/google/models"))}async request(n){let o=this.clientOptions.httpOptions;n.httpOptions&&(o=this.patchHttpOptions(this.clientOptions.httpOptions,n.httpOptions));const s=this.shouldPrependVertexProjectPath(n),r=this.constructUrl(n.path,o,s);if(n.queryParams)for(const[p,g]of Object.entries(n.queryParams))r.searchParams.append(p,String(g));let d={};if(n.httpMethod==="GET"){if(n.body&&n.body!=="{}")throw new Error("Request body should be empty for GET request, but got non empty request body")}else d.body=n.body;return d=await this.includeExtraHttpOptionsToRequestInit(d,o,n.abortSignal),this.unaryApiCall(r,d,n.httpMethod)}patchHttpOptions(n,o){const s=JSON.parse(JSON.stringify(n));for(const[r,d]of Object.entries(o))typeof d=="object"?s[r]=Object.assign(Object.assign({},s[r]),d):d!==void 0&&(s[r]=d);return s}async requestStream(n){let o=this.clientOptions.httpOptions;n.httpOptions&&(o=this.patchHttpOptions(this.clientOptions.httpOptions,n.httpOptions));const s=this.shouldPrependVertexProjectPath(n),r=this.constructUrl(n.path,o,s);(!r.searchParams.has("alt")||r.searchParams.get("alt")!=="sse")&&r.searchParams.set("alt","sse");let d={};return d.body=n.body,d=await this.includeExtraHttpOptionsToRequestInit(d,o,n.abortSignal),this.streamApiCall(r,d,n.httpMethod)}async includeExtraHttpOptionsToRequestInit(n,o,s){if(o&&o.timeout||s){const r=new AbortController,d=r.signal;if(o.timeout&&(o==null?void 0:o.timeout)>0){const p=setTimeout(()=>r.abort(),o.timeout);p&&typeof p.unref=="function"&&p.unref()}s&&s.addEventListener("abort",()=>{r.abort()}),n.signal=d}return o&&o.extraBody!==null&&JE(n,o.extraBody),n.headers=await this.getHeadersInternal(o),n}async unaryApiCall(n,o,s){return this.apiCall(n.toString(),Object.assign(Object.assign({},o),{method:s})).then(async r=>(await Qp(r),new fr(r))).catch(r=>{throw r instanceof Error?r:new Error(JSON.stringify(r))})}async streamApiCall(n,o,s){return this.apiCall(n.toString(),Object.assign(Object.assign({},o),{method:s})).then(async r=>(await Qp(r),this.processStreamResponse(r))).catch(r=>{throw r instanceof Error?r:new Error(JSON.stringify(r))})}processStreamResponse(n){var o;return di(this,arguments,function*(){const r=(o=n==null?void 0:n.body)===null||o===void 0?void 0:o.getReader(),d=new TextDecoder("utf-8");if(!r)throw new Error("Response body is empty");try{let p="";for(;;){const{done:g,value:y}=yield Je(r.read());if(g){if(p.trim().length>0)throw new Error("Incomplete JSON segment at the end");break}const h=d.decode(y,{stream:!0});try{const S=JSON.parse(h);if("error"in S){const _=JSON.parse(JSON.stringify(S.error)),R=_.status,H=_.code,V=`got status: ${R}. ${JSON.stringify(S)}`;if(H>=400&&H<600)throw new za({message:V,status:H})}}catch(S){if(S.name==="ApiError")throw S}p+=h;let T=p.match(Kp);for(;T;){const S=T[1];try{const _=new Response(S,{headers:n==null?void 0:n.headers,status:n==null?void 0:n.status,statusText:n==null?void 0:n.statusText});yield yield Je(new fr(_)),p=p.slice(T[0].length),T=p.match(Kp)}catch(_){throw new Error(`exception parsing stream chunk ${S}. ${_}`)}}}}finally{r.releaseLock()}})}async apiCall(n,o){return fetch(n,o).catch(s=>{throw new Error(`exception ${s} sending request`)})}getDefaultHeaders(){const n={},o=BE+" "+this.clientOptions.userAgentExtra;return n[zE]=o,n[gr]=o,n[GE]="application/json",n}async getHeadersInternal(n){const o=new Headers;if(n&&n.headers){for(const[s,r]of Object.entries(n.headers))o.append(s,r);n.timeout&&n.timeout>0&&o.append(HE,String(Math.ceil(n.timeout/1e3)))}return await this.clientOptions.auth.addAuthHeaders(o),o}async uploadFile(n,o){var s;const r={};o!=null&&(r.mimeType=o.mimeType,r.name=o.name,r.displayName=o.displayName),r.name&&!r.name.startsWith("files/")&&(r.name=`files/${r.name}`);const d=this.clientOptions.uploader,p=await d.stat(n);r.sizeBytes=String(p.size);const g=(s=o==null?void 0:o.mimeType)!==null&&s!==void 0?s:p.type;if(g===void 0||g==="")throw new Error("Can not determine mimeType. Please provide mimeType in the config.");r.mimeType=g;const y=await this.fetchUploadUrl(r,o);return d.upload(n,y,this)}async downloadFile(n){await this.clientOptions.downloader.download(n,this)}async fetchUploadUrl(n,o){var s;let r={};o!=null&&o.httpOptions?r=o.httpOptions:r={apiVersion:"",headers:{"Content-Type":"application/json","X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":`${n.sizeBytes}`,"X-Goog-Upload-Header-Content-Type":`${n.mimeType}`}};const d={file:n},p=await this.request({path:j("upload/v1beta/files",d._url),body:JSON.stringify(d),httpMethod:"POST",httpOptions:r});if(!p||!(p!=null&&p.headers))throw new Error("Server did not return an HttpResponse or the returned HttpResponse did not have headers.");const g=(s=p==null?void 0:p.headers)===null||s===void 0?void 0:s["x-goog-upload-url"];if(g===void 0)throw new Error("Failed to get upload url. Server did not return the x-google-upload-url in the headers");return g}}async function Qp(l){var n;if(l===void 0)throw new Error("response is undefined");if(!l.ok){const o=l.status;let s;!((n=l.headers.get("content-type"))===null||n===void 0)&&n.includes("application/json")?s=await l.json():s={error:{message:await l.text(),code:l.status,status:l.statusText}};const r=JSON.stringify(s);throw o>=400&&o<600?new za({message:r,status:o}):new Error(r)}}function JE(l,n){if(!n||Object.keys(n).length===0)return;if(l.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 l.body=="string"&&l.body.length>0)try{const d=JSON.parse(l.body);if(typeof d=="object"&&d!==null&&!Array.isArray(d))o=d;else{console.warn("includeExtraBodyToRequestInit: Original request body is valid JSON but not a non-array object. Skip applying extraBody to the request body.");return}}catch{console.warn("includeExtraBodyToRequestInit: Original request body is not valid JSON. Skip applying extraBody to the request body.");return}function s(d,p){const g=Object.assign({},d);for(const y in p)if(Object.prototype.hasOwnProperty.call(p,y)){const h=p[y],T=g[y];h&&typeof h=="object"&&!Array.isArray(h)&&T&&typeof T=="object"&&!Array.isArray(T)?g[y]=s(T,h):(T&&h&&typeof T!=typeof h&&console.warn(`includeExtraBodyToRequestInit:deepMerge: Type mismatch for key "${y}". Original type: ${typeof T}, New type: ${typeof h}. Overwriting.`),g[y]=h)}return g}const r=s(o,n);l.body=JSON.stringify(r)}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */const OE="mcp_used/unknown";let FE=!1;function Mh(l){for(const n of l)if(XE(n)||typeof n=="object"&&"inputSchema"in n)return!0;return FE}function Nh(l){var n;const o=(n=l[gr])!==null&&n!==void 0?n:"";l[gr]=(o+` ${OE}`).trimStart()}function XE(l){return l!==null&&typeof l=="object"&&l instanceof Ar}function KE(l,n=100){return di(this,arguments,function*(){let s,r=0;for(;r0)return;const d={},p=[];for(const T of this.mcpClients)try{for(var g=!0,y=(o=void 0,po(KE(T))),h;h=await y.next(),n=h.done,!n;g=!0){r=h.value,g=!1;const S=r;p.push(S);const _=S.name;if(d[_])throw new Error(`Duplicate function name ${_} found in MCP tools. Please ensure function names are unique.`);d[_]=T}}catch(S){o={error:S}}finally{try{!g&&!n&&(s=y.return)&&await s.call(y)}finally{if(o)throw o.error}}this.mcpTools=p,this.functionNameToMcpClient=d}async tool(){return await this.initialize(),j0(this.mcpTools,this.config)}async callTool(n){await this.initialize();const o=[];for(const s of n)if(s.name in this.functionNameToMcpClient){const r=this.functionNameToMcpClient[s.name];let d;this.config.timeout&&(d={timeout:this.config.timeout});const p=await r.callTool({name:s.name,arguments:s.args},void 0,d);o.push({functionResponse:{name:s.name,response:p.isError?{error:p}:p}})}return o}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */async function QE(l,n,o){const s=new O0;let r;o.data instanceof Blob?r=JSON.parse(await o.data.text()):r=JSON.parse(o.data),Object.assign(s,r),n(s)}class ZE{constructor(n,o,s){this.apiClient=n,this.auth=o,this.webSocketFactory=s}async connect(n){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 r=this.apiClient.getWebsocketBaseUrl(),d=this.apiClient.getApiVersion(),p=jE(this.apiClient.getDefaultHeaders()),g=this.apiClient.getApiKey(),y=`${r}/ws/google.ai.generativelanguage.${d}.GenerativeService.BidiGenerateMusic?key=${g}`;let h=()=>{};const T=new Promise(P=>{h=P}),S=n.callbacks,_=function(){h({})},R=this.apiClient,H={onopen:_,onmessage:P=>{QE(R,S.onmessage,P)},onerror:(o=S==null?void 0:S.onerror)!==null&&o!==void 0?o:function(P){},onclose:(s=S==null?void 0:S.onclose)!==null&&s!==void 0?s:function(P){}},V=this.webSocketFactory.create(y,WE(p),H);V.connect(),await T;const X={setup:{model:we(this.apiClient,n.model)}};return V.send(JSON.stringify(X)),new $E(V,this.apiClient)}}class $E{constructor(n,o){this.conn=n,this.apiClient=o}async setWeightedPrompts(n){if(!n.weightedPrompts||Object.keys(n.weightedPrompts).length===0)throw new Error("Weighted prompts must be set and contain at least one entry.");const o=kT(n);this.conn.send(JSON.stringify({clientContent:o}))}async setMusicGenerationConfig(n){n.musicGenerationConfig||(n.musicGenerationConfig={});const o=PT(n);this.conn.send(JSON.stringify(o))}sendPlaybackControl(n){const o={playbackControl:n};this.conn.send(JSON.stringify(o))}play(){this.sendPlaybackControl(ci.PLAY)}pause(){this.sendPlaybackControl(ci.PAUSE)}stop(){this.sendPlaybackControl(ci.STOP)}resetContext(){this.sendPlaybackControl(ci.RESET_CONTEXT)}close(){this.conn.close()}}function WE(l){const n={};return l.forEach((o,s)=>{n[s]=o}),n}function jE(l){const n=new Headers;for(const[o,s]of Object.entries(l))n.append(o,s);return n}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */const e_="FunctionResponse request must have an `id` field from the response of a ToolCall.FunctionalCalls in Google AI.";async function t_(l,n,o){const s=new J0;let r;o.data instanceof Blob?r=await o.data.text():o.data instanceof ArrayBuffer?r=new TextDecoder().decode(o.data):r=o.data;const d=JSON.parse(r);if(l.isVertexAI()){const p=OT(d);Object.assign(s,p)}else Object.assign(s,d);n(s)}class n_{constructor(n,o,s){this.apiClient=n,this.auth=o,this.webSocketFactory=s,this.music=new ZE(this.apiClient,this.auth,this.webSocketFactory)}async connect(n){var o,s,r,d,p,g;if(n.config&&n.config.httpOptions)throw new Error("The Live module does not support httpOptions at request-level in LiveConnectConfig yet. Please use the client-level httpOptions configuration instead.");const y=this.apiClient.getWebsocketBaseUrl(),h=this.apiClient.getApiVersion();let T;const S=this.apiClient.getHeaders();n.config&&n.config.tools&&Mh(n.config.tools)&&Nh(S);const _=a_(S);if(this.apiClient.isVertexAI())T=`${y}/ws/google.cloud.aiplatform.${h}.LlmBidiService/BidiGenerateContent`,await this.auth.addAuthHeaders(_);else{const $=this.apiClient.getApiKey();let Te="BidiGenerateContent",Me="key";$!=null&&$.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."),Te="BidiGenerateContentConstrained",Me="access_token"),T=`${y}/ws/google.ai.generativelanguage.${h}.GenerativeService.${Te}?${Me}=${$}`}let R=()=>{};const H=new Promise($=>{R=$}),V=n.callbacks,Y=function(){var $;($=V==null?void 0:V.onopen)===null||$===void 0||$.call(V),R({})},J=this.apiClient,X={onopen:Y,onmessage:$=>{t_(J,V.onmessage,$)},onerror:(o=V==null?void 0:V.onerror)!==null&&o!==void 0?o:function($){},onclose:(s=V==null?void 0:V.onclose)!==null&&s!==void 0?s:function($){}},P=this.webSocketFactory.create(T,o_(_),X);P.connect(),await H;let K=we(this.apiClient,n.model);if(this.apiClient.isVertexAI()&&K.startsWith("publishers/")){const $=this.apiClient.getProject(),Te=this.apiClient.getLocation();K=`projects/${$}/locations/${Te}/`+K}let te={};this.apiClient.isVertexAI()&&((r=n.config)===null||r===void 0?void 0:r.responseModalities)===void 0&&(n.config===void 0?n.config={responseModalities:[La.AUDIO]}:n.config.responseModalities=[La.AUDIO]),!((d=n.config)===null||d===void 0)&&d.generationConfig&&console.warn("Setting `LiveConnectConfig.generation_config` is deprecated, please set the fields on `LiveConnectConfig` directly. This will become an error in a future version (not before Q3 2025).");const le=(g=(p=n.config)===null||p===void 0?void 0:p.tools)!==null&&g!==void 0?g:[],F=[];for(const $ of le)if(this.isCallableTool($)){const Te=$;F.push(await Te.tool())}else F.push($);F.length>0&&(n.config.tools=F);const ve={model:K,config:n.config,callbacks:n.callbacks};return this.apiClient.isVertexAI()?te=BT(this.apiClient,ve):te=VT(this.apiClient,ve),delete te.config,P.send(JSON.stringify(te)),new i_(P,this.apiClient)}isCallableTool(n){return"callTool"in n&&typeof n.callTool=="function"}}const l_={turnComplete:!0};class i_{constructor(n,o){this.conn=n,this.apiClient=o}tLiveClientContent(n,o){if(o.turns!==null&&o.turns!==void 0){let s=[];try{s=$t(o.turns),n.isVertexAI()||(s=s.map(r=>Va(r)))}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(n,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 d of s){if(typeof d!="object"||d===null||!("name"in d)||!("response"in d))throw new Error(`Could not parse function response, type '${typeof d}'.`);if(!n.isVertexAI()&&!("id"in d))throw new Error(e_)}return{toolResponse:{functionResponses:s}}}sendClientContent(n){n=Object.assign(Object.assign({},l_),n);const o=this.tLiveClientContent(this.apiClient,n);this.conn.send(JSON.stringify(o))}sendRealtimeInput(n){let o={};this.apiClient.isVertexAI()?o={realtimeInput:JT(n)}:o={realtimeInput:YT(n)},this.conn.send(JSON.stringify(o))}sendToolResponse(n){if(n.functionResponses==null)throw new Error("Tool response parameters are required.");const o=this.tLiveClienttToolResponse(this.apiClient,n);this.conn.send(JSON.stringify(o))}close(){this.conn.close()}}function o_(l){const n={};return l.forEach((o,s)=>{n[s]=o}),n}function a_(l){const n=new Headers;for(const[o,s]of Object.entries(l))n.append(o,s);return n}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */const Zp=10;function $p(l){var n,o,s;if(!((n=l==null?void 0:l.automaticFunctionCalling)===null||n===void 0)&&n.disable)return!0;let r=!1;for(const p of(o=l==null?void 0:l.tools)!==null&&o!==void 0?o:[])if(mi(p)){r=!0;break}if(!r)return!0;const d=(s=l==null?void 0:l.automaticFunctionCalling)===null||s===void 0?void 0:s.maximumRemoteCalls;return d&&(d<0||!Number.isInteger(d))||d==0?(console.warn("Invalid maximumRemoteCalls value provided for automatic function calling. Disabled automatic function calling. Please provide a valid integer value greater than 0. maximumRemoteCalls provided:",d),!0):!1}function mi(l){return"callTool"in l&&typeof l.callTool=="function"}function s_(l){var n,o,s;return(s=(o=(n=l.config)===null||n===void 0?void 0:n.tools)===null||o===void 0?void 0:o.some(r=>mi(r)))!==null&&s!==void 0?s:!1}function u_(l){var n,o,s;return(s=(o=(n=l.config)===null||n===void 0?void 0:n.tools)===null||o===void 0?void 0:o.some(r=>!mi(r)))!==null&&s!==void 0?s:!1}function Wp(l){var n;return!(!((n=l==null?void 0:l.automaticFunctionCalling)===null||n===void 0)&&n.ignoreCallHistory)}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class r_ extends Cl{constructor(n){super(),this.apiClient=n,this.generateContent=async o=>{var s,r,d,p,g;const y=await this.processParamsMaybeAddMcpUsage(o);if(this.maybeMoveToResponseJsonSchem(o),!s_(o)||$p(o.config))return await this.generateContentInternal(y);if(u_(o))throw new Error("Automatic function calling with CallableTools and Tools is not yet supported.");let h,T;const S=$t(y.contents),_=(d=(r=(s=y.config)===null||s===void 0?void 0:s.automaticFunctionCalling)===null||r===void 0?void 0:r.maximumRemoteCalls)!==null&&d!==void 0?d:Zp;let R=0;for(;R<_&&(h=await this.generateContentInternal(y),!(!h.functionCalls||h.functionCalls.length===0));){const H=h.candidates[0].content,V=[];for(const Y of(g=(p=o.config)===null||p===void 0?void 0:p.tools)!==null&&g!==void 0?g:[])if(mi(Y)){const X=await Y.callTool(h.functionCalls);V.push(...X)}R++,T={role:"user",parts:V},y.contents=$t(y.contents),y.contents.push(H),y.contents.push(T),Wp(y.config)&&(S.push(H),S.push(T))}return Wp(y.config)&&(h.automaticFunctionCallingHistory=S),h},this.generateContentStream=async o=>{if(this.maybeMoveToResponseJsonSchem(o),$p(o.config)){const s=await this.processParamsMaybeAddMcpUsage(o);return await this.generateContentStreamInternal(s)}else return await this.processAfcStream(o)},this.generateImages=async o=>await this.generateImagesInternal(o).then(s=>{var r;let d;const p=[];if(s!=null&&s.generatedImages)for(const y of s.generatedImages)y&&(y!=null&&y.safetyAttributes)&&((r=y==null?void 0:y.safetyAttributes)===null||r===void 0?void 0:r.contentType)==="Positive Prompt"?d=y==null?void 0:y.safetyAttributes:p.push(y);let g;return d?g={generatedImages:p,positivePromptSafetyAttributes:d,sdkHttpResponse:s.sdkHttpResponse}:g={generatedImages:p,sdkHttpResponse:s.sdkHttpResponse},g}),this.list=async o=>{var s;const p={config:Object.assign(Object.assign({},{queryBase:!0}),o==null?void 0:o.config)};if(this.apiClient.isVertexAI()&&!p.config.queryBase){if(!((s=p.config)===null||s===void 0)&&s.filter)throw new Error("Filtering tuned models list for Vertex AI is not currently supported");p.config.filter="labels.tune-type:*"}return new ho(_l.PAGED_ITEM_MODELS,g=>this.listInternal(g),await this.listInternal(p),p)},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(r=>r.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 r={model:o.model,image:o.image,upscaleFactor:o.upscaleFactor,config:s};return await this.upscaleImageInternal(r)},this.generateVideos=async o=>{var s,r,d,p,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&&(!((r=o.video)===null||r===void 0)&&r.videoBytes)?o.video={uri:o.video.uri,mimeType:o.video.mimeType}:!((p=(d=o.source)===null||d===void 0?void 0:d.video)===null||p===void 0)&&p.uri&&(!((y=(g=o.source)===null||g===void 0?void 0:g.video)===null||y===void 0)&&y.videoBytes)&&(o.source.video={uri:o.source.video.uri,mimeType:o.source.video.mimeType})),await this.generateVideosInternal(o)}}maybeMoveToResponseJsonSchem(n){n.config&&n.config.responseSchema&&(n.config.responseJsonSchema||Object.keys(n.config.responseSchema).includes("$schema")&&(n.config.responseJsonSchema=n.config.responseSchema,delete n.config.responseSchema))}async processParamsMaybeAddMcpUsage(n){var o,s,r;const d=(o=n.config)===null||o===void 0?void 0:o.tools;if(!d)return n;const p=await Promise.all(d.map(async y=>mi(y)?await y.tool():y)),g={model:n.model,contents:n.contents,config:Object.assign(Object.assign({},n.config),{tools:p})};if(g.config.tools=p,n.config&&n.config.tools&&Mh(n.config.tools)){const y=(r=(s=n.config.httpOptions)===null||s===void 0?void 0:s.headers)!==null&&r!==void 0?r:{};let h=Object.assign({},y);Object.keys(h).length===0&&(h=this.apiClient.getDefaultHeaders()),Nh(h),g.config.httpOptions=Object.assign(Object.assign({},n.config.httpOptions),{headers:h})}return g}async initAfcToolsMap(n){var o,s,r;const d=new Map;for(const p of(s=(o=n.config)===null||o===void 0?void 0:o.tools)!==null&&s!==void 0?s:[])if(mi(p)){const g=p,y=await g.tool();for(const h of(r=y.functionDeclarations)!==null&&r!==void 0?r:[]){if(!h.name)throw new Error("Function declaration name is required.");if(d.has(h.name))throw new Error(`Duplicate tool declaration name: ${h.name}`);d.set(h.name,g)}}return d}async processAfcStream(n){var o,s,r;const d=(r=(s=(o=n.config)===null||o===void 0?void 0:o.automaticFunctionCalling)===null||s===void 0?void 0:s.maximumRemoteCalls)!==null&&r!==void 0?r:Zp;let p=!1,g=0;const y=await this.initAfcToolsMap(n);return(function(h,T,S){var _,R;return di(this,arguments,function*(){for(var H,V,Y,J;g0){p=!0;const $=new mo;$.candidates=[{content:{role:"user",parts:F}}],yield yield Je($);const Te=[];Te.push(...ve),Te.push({role:"user",parts:F});const Me=$t(S.contents).concat(Te);S.contents=Me}else break}})})(this,y,n)}async generateContentInternal(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=Op(this.apiClient,n);return g=j("{model}:generateContent",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),p.then(T=>{const S=Xp(T),_=new mo;return Object.assign(_,S),_})}else{const h=Jp(this.apiClient,n);return g=j("{model}:generateContent",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),p.then(T=>{const S=Fp(T),_=new mo;return Object.assign(_,S),_})}}async generateContentStreamInternal(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=Op(this.apiClient,n);return g=j("{model}:streamGenerateContent?alt=sse",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.requestStream({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}),p.then(function(S){return di(this,arguments,function*(){var _,R,H,V;try{for(var Y=!0,J=po(S),X;X=yield Je(J.next()),_=X.done,!_;Y=!0){V=X.value,Y=!1;const P=V,K=Xp(yield Je(P.json()));K.sdkHttpResponse={headers:P.headers};const te=new mo;Object.assign(te,K),yield yield Je(te)}}catch(P){R={error:P}}finally{try{!Y&&!_&&(H=J.return)&&(yield Je(H.call(J)))}finally{if(R)throw R.error}}})})}else{const h=Jp(this.apiClient,n);return g=j("{model}:streamGenerateContent?alt=sse",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.requestStream({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}),p.then(function(S){return di(this,arguments,function*(){var _,R,H,V;try{for(var Y=!0,J=po(S),X;X=yield Je(J.next()),_=X.done,!_;Y=!0){V=X.value,Y=!1;const P=V,K=Fp(yield Je(P.json()));K.sdkHttpResponse={headers:P.headers};const te=new mo;Object.assign(te,K),yield yield Je(te)}}catch(P){R={error:P}}finally{try{!Y&&!_&&(H=J.return)&&(yield Je(H.call(J)))}finally{if(R)throw R.error}}})})}}async embedContent(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=ES(this.apiClient,n);return g=j("{model}:predict",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),p.then(T=>{const S=CS(T),_=new Rp;return Object.assign(_,S),_})}else{const h=SS(this.apiClient,n);return g=j("{model}:batchEmbedContents",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),p.then(T=>{const S=_S(T),_=new Rp;return Object.assign(_,S),_})}}async generateImagesInternal(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=US(this.apiClient,n);return g=j("{model}:predict",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),p.then(T=>{const S=qS(T),_=new bp;return Object.assign(_,S),_})}else{const h=wS(this.apiClient,n);return g=j("{model}:predict",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),p.then(T=>{const S=IS(T),_=new bp;return Object.assign(_,S),_})}}async editImageInternal(n){var o,s;let r,d="",p={};if(this.apiClient.isVertexAI()){const g=gS(this.apiClient,n);return d=j("{model}:predict",g._url),p=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:p,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json().then(h=>{const T=h;return T.sdkHttpResponse={headers:y.headers},T})),r.then(y=>{const h=yS(y),T=new G0;return Object.assign(T,h),T})}else throw new Error("This method is only supported by the Vertex AI.")}async upscaleImageInternal(n){var o,s;let r,d="",p={};if(this.apiClient.isVertexAI()){const g=bE(this.apiClient,n);return d=j("{model}:predict",g._url),p=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:p,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json().then(h=>{const T=h;return T.sdkHttpResponse={headers:y.headers},T})),r.then(y=>{const h=DE(y),T=new H0;return Object.assign(T,h),T})}else throw new Error("This method is only supported by the Vertex AI.")}async recontextImage(n){var o,s;let r,d="",p={};if(this.apiClient.isVertexAI()){const g=fE(this.apiClient,n);return d=j("{model}:predict",g._url),p=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:p,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json()),r.then(y=>{const h=dE(y),T=new z0;return Object.assign(T,h),T})}else throw new Error("This method is only supported by the Vertex AI.")}async segmentImage(n){var o,s;let r,d="",p={};if(this.apiClient.isVertexAI()){const g=vE(this.apiClient,n);return d=j("{model}:predict",g._url),p=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:p,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json()),r.then(y=>{const h=TE(y),T=new V0;return Object.assign(T,h),T})}else throw new Error("This method is only supported by the Vertex AI.")}async get(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=$S(this.apiClient,n);return g=j("{name}",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json()),p.then(T=>hr(T))}else{const h=ZS(this.apiClient,n);return g=j("{name}",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json()),p.then(T=>pr(T))}}async listInternal(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=iE(this.apiClient,n);return g=j("{models_url}",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),p.then(T=>{const S=aE(T),_=new Dp;return Object.assign(_,S),_})}else{const h=lE(this.apiClient,n);return g=j("{models_url}",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),p.then(T=>{const S=oE(T),_=new Dp;return Object.assign(_,S),_})}}async update(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=NE(this.apiClient,n);return g=j("{model}",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"PATCH",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json()),p.then(T=>hr(T))}else{const h=ME(this.apiClient,n);return g=j("{name}",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"PATCH",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json()),p.then(T=>pr(T))}}async delete(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=dS(this.apiClient,n);return g=j("{name}",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"DELETE",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),p.then(T=>{const S=pS(T),_=new wp;return Object.assign(_,S),_})}else{const h=fS(this.apiClient,n);return g=j("{name}",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"DELETE",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),p.then(T=>{const S=mS(T),_=new wp;return Object.assign(_,S),_})}}async countTokens(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=uS(this.apiClient,n);return g=j("{model}:countTokens",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),p.then(T=>{const S=cS(T),_=new Up;return Object.assign(_,S),_})}else{const h=sS(this.apiClient,n);return g=j("{model}:countTokens",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),p.then(T=>{const S=rS(T),_=new Up;return Object.assign(_,S),_})}}async computeTokens(n){var o,s;let r,d="",p={};if(this.apiClient.isVertexAI()){const g=eS(this.apiClient,n);return d=j("{model}:computeTokens",g._url),p=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:p,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json().then(h=>{const T=h;return T.sdkHttpResponse={headers:y.headers},T})),r.then(y=>{const h=tS(y),T=new B0;return Object.assign(T,h),T})}else throw new Error("This method is only supported by the Vertex AI.")}async generateVideosInternal(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=BS(this.apiClient,n);return g=j("{model}:predictLongRunning",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json()),p.then(T=>{const S=zS(T),_=new Ga;return Object.assign(_,S),_})}else{const h=VS(this.apiClient,n);return g=j("{model}:predictLongRunning",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"POST",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json()),p.then(T=>{const S=HS(T),_=new Ga;return Object.assign(_,S),_})}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class c_ extends Cl{constructor(n){super(),this.apiClient=n}async getVideosOperation(n){const o=n.operation,s=n.config;if(o.name===void 0||o.name==="")throw new Error("Operation name is required.");if(this.apiClient.isVertexAI()){const r=o.name.split("/operations/")[0];let d;s&&"httpOptions"in s&&(d=s.httpOptions);const p=await this.fetchPredictVideosOperationInternal({operationName:o.name,resourceName:r,config:{httpOptions:d}});return o._fromAPIResponse({apiResponse:p,isVertexAI:!0})}else{const r=await this.getVideosOperationInternal({operationName:o.name,config:s});return o._fromAPIResponse({apiResponse:r,isVertexAI:!1})}}async get(n){const o=n.operation,s=n.config;if(o.name===void 0||o.name==="")throw new Error("Operation name is required.");if(this.apiClient.isVertexAI()){const r=o.name.split("/operations/")[0];let d;s&&"httpOptions"in s&&(d=s.httpOptions);const p=await this.fetchPredictVideosOperationInternal({operationName:o.name,resourceName:r,config:{httpOptions:d}});return o._fromAPIResponse({apiResponse:p,isVertexAI:!0})}else{const r=await this.getVideosOperationInternal({operationName:o.name,config:s});return o._fromAPIResponse({apiResponse:r,isVertexAI:!1})}}async getVideosOperationInternal(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=I0(n);return g=j("{operationName}",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json()),p}else{const h=U0(n);return g=j("{operationName}",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json()),p}}async fetchPredictVideosOperationInternal(n){var o,s;let r,d="",p={};if(this.apiClient.isVertexAI()){const g=x0(n);return d=j("{resourceName}:fetchPredictOperation",g._url),p=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:p,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json()),r}else throw new Error("This method is only supported by the Vertex AI.")}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function f_(l){const n={};if(u(l,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=u(l,["data"]);o!=null&&c(n,["data"],o);const s=u(l,["mimeType"]);return s!=null&&c(n,["mimeType"],s),n}function d_(l){const n={},o=u(l,["parts"]);if(o!=null){let r=o;Array.isArray(r)&&(r=r.map(d=>S_(d))),c(n,["parts"],r)}const s=u(l,["role"]);return s!=null&&c(n,["role"],s),n}function m_(l,n,o){const s={},r=u(n,["expireTime"]);o!==void 0&&r!=null&&c(o,["expireTime"],r);const d=u(n,["newSessionExpireTime"]);o!==void 0&&d!=null&&c(o,["newSessionExpireTime"],d);const p=u(n,["uses"]);o!==void 0&&p!=null&&c(o,["uses"],p);const g=u(n,["liveConnectConstraints"]);o!==void 0&&g!=null&&c(o,["bidiGenerateContentSetup"],T_(l,g));const y=u(n,["lockAdditionalFields"]);return o!==void 0&&y!=null&&c(o,["fieldMask"],y),s}function p_(l,n){const o={},s=u(n,["config"]);return s!=null&&c(o,["config"],m_(l,s,o)),o}function h_(l){const n={};if(u(l,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const o=u(l,["fileUri"]);o!=null&&c(n,["fileUri"],o);const s=u(l,["mimeType"]);return s!=null&&c(n,["mimeType"],s),n}function g_(l){const n={};if(u(l,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const o=u(l,["enableWidget"]);return o!=null&&c(n,["enableWidget"],o),n}function y_(l){const n={},o=u(l,["timeRangeFilter"]);if(o!=null&&c(n,["timeRangeFilter"],o),u(l,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");return n}function v_(l,n){const o={},s=u(l,["generationConfig"]);n!==void 0&&s!=null&&c(n,["setup","generationConfig"],s);const r=u(l,["responseModalities"]);n!==void 0&&r!=null&&c(n,["setup","generationConfig","responseModalities"],r);const d=u(l,["temperature"]);n!==void 0&&d!=null&&c(n,["setup","generationConfig","temperature"],d);const p=u(l,["topP"]);n!==void 0&&p!=null&&c(n,["setup","generationConfig","topP"],p);const g=u(l,["topK"]);n!==void 0&&g!=null&&c(n,["setup","generationConfig","topK"],g);const y=u(l,["maxOutputTokens"]);n!==void 0&&y!=null&&c(n,["setup","generationConfig","maxOutputTokens"],y);const h=u(l,["mediaResolution"]);n!==void 0&&h!=null&&c(n,["setup","generationConfig","mediaResolution"],h);const T=u(l,["seed"]);n!==void 0&&T!=null&&c(n,["setup","generationConfig","seed"],T);const S=u(l,["speechConfig"]);n!==void 0&&S!=null&&c(n,["setup","generationConfig","speechConfig"],Cr(S));const _=u(l,["thinkingConfig"]);n!==void 0&&_!=null&&c(n,["setup","generationConfig","thinkingConfig"],_);const R=u(l,["enableAffectiveDialog"]);n!==void 0&&R!=null&&c(n,["setup","generationConfig","enableAffectiveDialog"],R);const H=u(l,["systemInstruction"]);n!==void 0&&H!=null&&c(n,["setup","systemInstruction"],d_(St(H)));const V=u(l,["tools"]);if(n!==void 0&&V!=null){let le=hi(V);Array.isArray(le)&&(le=le.map(F=>__(pi(F)))),c(n,["setup","tools"],le)}const Y=u(l,["sessionResumption"]);n!==void 0&&Y!=null&&c(n,["setup","sessionResumption"],E_(Y));const J=u(l,["inputAudioTranscription"]);n!==void 0&&J!=null&&c(n,["setup","inputAudioTranscription"],J);const X=u(l,["outputAudioTranscription"]);n!==void 0&&X!=null&&c(n,["setup","outputAudioTranscription"],X);const P=u(l,["realtimeInputConfig"]);n!==void 0&&P!=null&&c(n,["setup","realtimeInputConfig"],P);const K=u(l,["contextWindowCompression"]);n!==void 0&&K!=null&&c(n,["setup","contextWindowCompression"],K);const te=u(l,["proactivity"]);return n!==void 0&&te!=null&&c(n,["setup","proactivity"],te),o}function T_(l,n){const o={},s=u(n,["model"]);s!=null&&c(o,["setup","model"],we(l,s));const r=u(n,["config"]);return r!=null&&c(o,["config"],v_(r,o)),o}function S_(l){const n={},o=u(l,["videoMetadata"]);o!=null&&c(n,["videoMetadata"],o);const s=u(l,["thought"]);s!=null&&c(n,["thought"],s);const r=u(l,["inlineData"]);r!=null&&c(n,["inlineData"],f_(r));const d=u(l,["fileData"]);d!=null&&c(n,["fileData"],h_(d));const p=u(l,["thoughtSignature"]);p!=null&&c(n,["thoughtSignature"],p);const g=u(l,["functionCall"]);g!=null&&c(n,["functionCall"],g);const y=u(l,["codeExecutionResult"]);y!=null&&c(n,["codeExecutionResult"],y);const h=u(l,["executableCode"]);h!=null&&c(n,["executableCode"],h);const T=u(l,["functionResponse"]);T!=null&&c(n,["functionResponse"],T);const S=u(l,["text"]);return S!=null&&c(n,["text"],S),n}function E_(l){const n={},o=u(l,["handle"]);if(o!=null&&c(n,["handle"],o),u(l,["transparent"])!==void 0)throw new Error("transparent parameter is not supported in Gemini API.");return n}function __(l){const n={},o=u(l,["functionDeclarations"]);if(o!=null){let h=o;Array.isArray(h)&&(h=h.map(T=>T)),c(n,["functionDeclarations"],h)}if(u(l,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const s=u(l,["googleSearch"]);s!=null&&c(n,["googleSearch"],y_(s));const r=u(l,["googleSearchRetrieval"]);if(r!=null&&c(n,["googleSearchRetrieval"],r),u(l,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const d=u(l,["googleMaps"]);d!=null&&c(n,["googleMaps"],g_(d));const p=u(l,["urlContext"]);p!=null&&c(n,["urlContext"],p);const g=u(l,["computerUse"]);g!=null&&c(n,["computerUse"],g);const y=u(l,["codeExecution"]);return y!=null&&c(n,["codeExecution"],y),n}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function C_(l){const n=[];for(const o in l)if(Object.prototype.hasOwnProperty.call(l,o)){const s=l[o];if(typeof s=="object"&&s!=null&&Object.keys(s).length>0){const r=Object.keys(s).map(d=>`${o}.${d}`);n.push(...r)}else n.push(o)}return n.join(",")}function A_(l,n){let o=null;const s=l.bidiGenerateContentSetup;if(typeof s=="object"&&s!==null&&"setup"in s){const d=s.setup;typeof d=="object"&&d!==null?(l.bidiGenerateContentSetup=d,o=d):delete l.bidiGenerateContentSetup}else s!==void 0&&delete l.bidiGenerateContentSetup;const r=l.fieldMask;if(o){const d=C_(o);if(Array.isArray(n==null?void 0:n.lockAdditionalFields)&&(n==null?void 0:n.lockAdditionalFields.length)===0)d?l.fieldMask=d:delete l.fieldMask;else if(n!=null&&n.lockAdditionalFields&&n.lockAdditionalFields.length>0&&r!==null&&Array.isArray(r)&&r.length>0){const p=["temperature","topK","topP","maxOutputTokens","responseModalities","seed","speechConfig"];let g=[];r.length>0&&(g=r.map(h=>p.includes(h)?`generationConfig.${h}`:h));const y=[];d&&y.push(d),g.length>0&&y.push(...g),y.length>0?l.fieldMask=y.join(","):delete l.fieldMask}else delete l.fieldMask}else r!==null&&Array.isArray(r)&&r.length>0?l.fieldMask=r.join(","):delete l.fieldMask;return l}class x_ extends Cl{constructor(n){super(),this.apiClient=n}async create(n){var o,s;let r,d="",p={};if(this.apiClient.isVertexAI())throw new Error("The client.tokens.create method is only supported by the Gemini Developer API.");{const g=p_(this.apiClient,n);d=j("auth_tokens",g._url),p=g._query,delete g.config,delete g._url,delete g._query;const y=A_(g,n.config);return r=this.apiClient.request({path:d,queryParams:p,body:JSON.stringify(y),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(h=>h.json()),r.then(h=>h)}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function M_(l){const n={},o=u(l,["name"]);return o!=null&&c(n,["_url","name"],o),n}function N_(l){const n={},o=u(l,["name"]);return o!=null&&c(n,["_url","name"],o),n}function R_(l,n){const o={};if(u(l,["validationDataset"])!==void 0)throw new Error("validationDataset parameter is not supported in Gemini API.");const s=u(l,["tunedModelDisplayName"]);if(n!==void 0&&s!=null&&c(n,["displayName"],s),u(l,["description"])!==void 0)throw new Error("description parameter is not supported in Gemini API.");const r=u(l,["epochCount"]);n!==void 0&&r!=null&&c(n,["tuningTask","hyperparameters","epochCount"],r);const d=u(l,["learningRateMultiplier"]);if(d!=null&&c(o,["tuningTask","hyperparameters","learningRateMultiplier"],d),u(l,["exportLastCheckpointOnly"])!==void 0)throw new Error("exportLastCheckpointOnly parameter is not supported in Gemini API.");if(u(l,["preTunedModelCheckpointId"])!==void 0)throw new Error("preTunedModelCheckpointId parameter is not supported in Gemini API.");if(u(l,["adapterSize"])!==void 0)throw new Error("adapterSize parameter is not supported in Gemini API.");const p=u(l,["batchSize"]);n!==void 0&&p!=null&&c(n,["tuningTask","hyperparameters","batchSize"],p);const g=u(l,["learningRate"]);if(n!==void 0&&g!=null&&c(n,["tuningTask","hyperparameters","learningRate"],g),u(l,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");return o}function b_(l,n){const o={},s=u(l,["validationDataset"]);n!==void 0&&s!=null&&c(n,["supervisedTuningSpec"],J_(s,o));const r=u(l,["tunedModelDisplayName"]);n!==void 0&&r!=null&&c(n,["tunedModelDisplayName"],r);const d=u(l,["description"]);n!==void 0&&d!=null&&c(n,["description"],d);const p=u(l,["epochCount"]);n!==void 0&&p!=null&&c(n,["supervisedTuningSpec","hyperParameters","epochCount"],p);const g=u(l,["learningRateMultiplier"]);n!==void 0&&g!=null&&c(n,["supervisedTuningSpec","hyperParameters","learningRateMultiplier"],g);const y=u(l,["exportLastCheckpointOnly"]);n!==void 0&&y!=null&&c(n,["supervisedTuningSpec","exportLastCheckpointOnly"],y);const h=u(l,["adapterSize"]);if(n!==void 0&&h!=null&&c(n,["supervisedTuningSpec","hyperParameters","adapterSize"],h),u(l,["batchSize"])!==void 0)throw new Error("batchSize parameter is not supported in Vertex AI.");if(u(l,["learningRate"])!==void 0)throw new Error("learningRate parameter is not supported in Vertex AI.");const T=u(l,["labels"]);return n!==void 0&&T!=null&&c(n,["labels"],T),o}function D_(l){const n={},o=u(l,["baseModel"]);o!=null&&c(n,["baseModel"],o);const s=u(l,["preTunedModel"]);s!=null&&c(n,["preTunedModel"],s);const r=u(l,["trainingDataset"]);r!=null&&c(n,["tuningTask","trainingData"],P_(r));const d=u(l,["config"]);return d!=null&&R_(d,n),n}function w_(l){const n={},o=u(l,["baseModel"]);o!=null&&c(n,["baseModel"],o);const s=u(l,["preTunedModel"]);s!=null&&c(n,["preTunedModel"],s);const r=u(l,["trainingDataset"]);r!=null&&c(n,["supervisedTuningSpec","trainingDatasetUri"],k_(r,n));const d=u(l,["config"]);return d!=null&&b_(d,n),n}function U_(l){const n={},o=u(l,["name"]);return o!=null&&c(n,["_url","name"],o),n}function I_(l){const n={},o=u(l,["name"]);return o!=null&&c(n,["_url","name"],o),n}function q_(l,n){const o={},s=u(l,["pageSize"]);n!==void 0&&s!=null&&c(n,["_query","pageSize"],s);const r=u(l,["pageToken"]);n!==void 0&&r!=null&&c(n,["_query","pageToken"],r);const d=u(l,["filter"]);return n!==void 0&&d!=null&&c(n,["_query","filter"],d),o}function L_(l,n){const o={},s=u(l,["pageSize"]);n!==void 0&&s!=null&&c(n,["_query","pageSize"],s);const r=u(l,["pageToken"]);n!==void 0&&r!=null&&c(n,["_query","pageToken"],r);const d=u(l,["filter"]);return n!==void 0&&d!=null&&c(n,["_query","filter"],d),o}function G_(l){const n={},o=u(l,["config"]);return o!=null&&q_(o,n),n}function H_(l){const n={},o=u(l,["config"]);return o!=null&&L_(o,n),n}function z_(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["nextPageToken"]);s!=null&&c(n,["nextPageToken"],s);const r=u(l,["tunedModels"]);if(r!=null){let d=r;Array.isArray(d)&&(d=d.map(p=>Rh(p))),c(n,["tuningJobs"],d)}return n}function V_(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["nextPageToken"]);s!=null&&c(n,["nextPageToken"],s);const r=u(l,["tuningJobs"]);if(r!=null){let d=r;Array.isArray(d)&&(d=d.map(p=>yr(p))),c(n,["tuningJobs"],d)}return n}function B_(l){const n={},o=u(l,["name"]);o!=null&&c(n,["model"],o);const s=u(l,["name"]);return s!=null&&c(n,["endpoint"],s),n}function P_(l){const n={};if(u(l,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");if(u(l,["vertexDatasetResource"])!==void 0)throw new Error("vertexDatasetResource parameter is not supported in Gemini API.");const o=u(l,["examples"]);if(o!=null){let s=o;Array.isArray(s)&&(s=s.map(r=>r)),c(n,["examples","examples"],s)}return n}function k_(l,n){const o={},s=u(l,["gcsUri"]);n!==void 0&&s!=null&&c(n,["supervisedTuningSpec","trainingDatasetUri"],s);const r=u(l,["vertexDatasetResource"]);if(n!==void 0&&r!=null&&c(n,["supervisedTuningSpec","trainingDatasetUri"],r),u(l,["examples"])!==void 0)throw new Error("examples parameter is not supported in Vertex AI.");return o}function Rh(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["name"]);s!=null&&c(n,["name"],s);const r=u(l,["state"]);r!=null&&c(n,["state"],rh(r));const d=u(l,["createTime"]);d!=null&&c(n,["createTime"],d);const p=u(l,["tuningTask","startTime"]);p!=null&&c(n,["startTime"],p);const g=u(l,["tuningTask","completeTime"]);g!=null&&c(n,["endTime"],g);const y=u(l,["updateTime"]);y!=null&&c(n,["updateTime"],y);const h=u(l,["description"]);h!=null&&c(n,["description"],h);const T=u(l,["baseModel"]);T!=null&&c(n,["baseModel"],T);const S=u(l,["_self"]);S!=null&&c(n,["tunedModel"],B_(S));const _=u(l,["customBaseModel"]);_!=null&&c(n,["customBaseModel"],_);const R=u(l,["experiment"]);R!=null&&c(n,["experiment"],R);const H=u(l,["labels"]);H!=null&&c(n,["labels"],H);const V=u(l,["outputUri"]);V!=null&&c(n,["outputUri"],V);const Y=u(l,["pipelineJob"]);Y!=null&&c(n,["pipelineJob"],Y);const J=u(l,["serviceAccount"]);J!=null&&c(n,["serviceAccount"],J);const X=u(l,["tunedModelDisplayName"]);X!=null&&c(n,["tunedModelDisplayName"],X);const P=u(l,["veoTuningSpec"]);return P!=null&&c(n,["veoTuningSpec"],P),n}function yr(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["name"]);s!=null&&c(n,["name"],s);const r=u(l,["state"]);r!=null&&c(n,["state"],rh(r));const d=u(l,["createTime"]);d!=null&&c(n,["createTime"],d);const p=u(l,["startTime"]);p!=null&&c(n,["startTime"],p);const g=u(l,["endTime"]);g!=null&&c(n,["endTime"],g);const y=u(l,["updateTime"]);y!=null&&c(n,["updateTime"],y);const h=u(l,["error"]);h!=null&&c(n,["error"],h);const T=u(l,["description"]);T!=null&&c(n,["description"],T);const S=u(l,["baseModel"]);S!=null&&c(n,["baseModel"],S);const _=u(l,["tunedModel"]);_!=null&&c(n,["tunedModel"],_);const R=u(l,["preTunedModel"]);R!=null&&c(n,["preTunedModel"],R);const H=u(l,["supervisedTuningSpec"]);H!=null&&c(n,["supervisedTuningSpec"],H);const V=u(l,["tuningDataStats"]);V!=null&&c(n,["tuningDataStats"],V);const Y=u(l,["encryptionSpec"]);Y!=null&&c(n,["encryptionSpec"],Y);const J=u(l,["partnerModelTuningSpec"]);J!=null&&c(n,["partnerModelTuningSpec"],J);const X=u(l,["customBaseModel"]);X!=null&&c(n,["customBaseModel"],X);const P=u(l,["experiment"]);P!=null&&c(n,["experiment"],P);const K=u(l,["labels"]);K!=null&&c(n,["labels"],K);const te=u(l,["outputUri"]);te!=null&&c(n,["outputUri"],te);const le=u(l,["pipelineJob"]);le!=null&&c(n,["pipelineJob"],le);const F=u(l,["serviceAccount"]);F!=null&&c(n,["serviceAccount"],F);const ve=u(l,["tunedModelDisplayName"]);ve!=null&&c(n,["tunedModelDisplayName"],ve);const $=u(l,["veoTuningSpec"]);return $!=null&&c(n,["veoTuningSpec"],$),n}function Y_(l){const n={},o=u(l,["sdkHttpResponse"]);o!=null&&c(n,["sdkHttpResponse"],o);const s=u(l,["name"]);s!=null&&c(n,["name"],s);const r=u(l,["metadata"]);r!=null&&c(n,["metadata"],r);const d=u(l,["done"]);d!=null&&c(n,["done"],d);const p=u(l,["error"]);return p!=null&&c(n,["error"],p),n}function J_(l,n){const o={},s=u(l,["gcsUri"]);s!=null&&c(o,["validationDatasetUri"],s);const r=u(l,["vertexDatasetResource"]);return n!==void 0&&r!=null&&c(n,["supervisedTuningSpec","trainingDatasetUri"],r),o}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class O_ extends Cl{constructor(n){super(),this.apiClient=n,this.get=async o=>await this.getInternal(o),this.list=async(o={})=>new ho(_l.PAGED_ITEM_TUNING_JOBS,s=>this.listInternal(s),await this.listInternal(o),o),this.tune=async o=>{var s;if(this.apiClient.isVertexAI())if(o.baseModel.startsWith("projects/")){const r={tunedModelName:o.baseModel};!((s=o.config)===null||s===void 0)&&s.preTunedModelCheckpointId&&(r.checkpointId=o.config.preTunedModelCheckpointId);const d=Object.assign(Object.assign({},o),{preTunedModel:r});return d.baseModel=void 0,await this.tuneInternal(d)}else{const r=Object.assign({},o);return await this.tuneInternal(r)}else{const r=Object.assign({},o),d=await this.tuneMldevInternal(r);let p="";return d.metadata!==void 0&&d.metadata.tunedModel!==void 0?p=d.metadata.tunedModel:d.name!==void 0&&d.name.includes("/operations/")&&(p=d.name.split("/operations/")[0]),{name:p,state:cr.JOB_STATE_QUEUED}}}}async getInternal(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=I_(n);return g=j("{name}",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),p.then(T=>yr(T))}else{const h=U_(n);return g=j("{name}",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),p.then(T=>Rh(T))}}async listInternal(n){var o,s,r,d;let p,g="",y={};if(this.apiClient.isVertexAI()){const h=H_(n);return g=j("tuningJobs",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),p.then(T=>{const S=V_(T),_=new Ip;return Object.assign(_,S),_})}else{const h=G_(n);return g=j("tunedModels",h._url),y=h._query,delete h._url,delete h._query,p=this.apiClient.request({path:g,queryParams:y,body:JSON.stringify(h),httpMethod:"GET",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal}).then(T=>T.json().then(S=>{const _=S;return _.sdkHttpResponse={headers:T.headers},_})),p.then(T=>{const S=z_(T),_=new Ip;return Object.assign(_,S),_})}}async cancel(n){var o,s,r,d;let p="",g={};if(this.apiClient.isVertexAI()){const y=N_(n);p=j("{name}:cancel",y._url),g=y._query,delete y._url,delete y._query,await this.apiClient.request({path:p,queryParams:g,body:JSON.stringify(y),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal})}else{const y=M_(n);p=j("{name}:cancel",y._url),g=y._query,delete y._url,delete y._query,await this.apiClient.request({path:p,queryParams:g,body:JSON.stringify(y),httpMethod:"POST",httpOptions:(r=n.config)===null||r===void 0?void 0:r.httpOptions,abortSignal:(d=n.config)===null||d===void 0?void 0:d.abortSignal})}}async tuneInternal(n){var o,s;let r,d="",p={};if(this.apiClient.isVertexAI()){const g=w_(n);return d=j("tuningJobs",g._url),p=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:p,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json().then(h=>{const T=h;return T.sdkHttpResponse={headers:y.headers},T})),r.then(y=>yr(y))}else throw new Error("This method is only supported by the Vertex AI.")}async tuneMldevInternal(n){var o,s;let r,d="",p={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const g=D_(n);return d=j("tunedModels",g._url),p=g._query,delete g._url,delete g._query,r=this.apiClient.request({path:d,queryParams:p,body:JSON.stringify(g),httpMethod:"POST",httpOptions:(o=n.config)===null||o===void 0?void 0:o.httpOptions,abortSignal:(s=n.config)===null||s===void 0?void 0:s.abortSignal}).then(y=>y.json().then(h=>{const T=h;return T.sdkHttpResponse={headers:y.headers},T})),r.then(y=>Y_(y))}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class F_{async download(n,o){throw new Error("Download to file is not supported in the browser, please use a browser compliant download like an tag.")}}const X_=1024*1024*8,K_=3,Q_=1e3,Z_=2,ur="x-goog-upload-status";async function $_(l,n,o){var s,r,d;let p=0,g=0,y=new fr(new Response),h="upload";for(p=l.size;g=p&&(h+=", finalize");let R=0,H=Q_;for(;RsetTimeout(n,l))}class eC{async upload(n,o,s){if(typeof n=="string")throw new Error("File path is not supported in browser uploader.");return await $_(n,o,s)}async stat(n){if(typeof n=="string")throw new Error("File path is not supported in browser uploader.");return await W_(n)}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class tC{create(n,o,s){return new nC(n,o,s)}}class nC{constructor(n,o,s){this.url=n,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(n){if(this.ws===void 0)throw new Error("WebSocket is not connected");this.ws.send(n)}close(){if(this.ws===void 0)throw new Error("WebSocket is not connected");this.ws.close()}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */const jp="x-goog-api-key";class lC{constructor(n){this.apiKey=n}async addAuthHeaders(n){if(n.get(jp)===null){if(this.apiKey.startsWith("auth_tokens/"))throw new Error("Ephemeral tokens are only supported by the live API.");if(!this.apiKey)throw new Error("API key is missing. Please provide a valid API key.");n.append(jp,this.apiKey)}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */const iC="gl-node/";class oC{constructor(n){var o;if(n.apiKey==null)throw new Error("An API Key must be set when running in a browser");if(n.project||n.location)throw new Error("Vertex AI project based authentication is not supported on browser runtimes. Please do not provide a project or location.");this.vertexai=(o=n.vertexai)!==null&&o!==void 0?o:!1,this.apiKey=n.apiKey;const s=C0(n.httpOptions,n.vertexai,void 0,void 0);s&&(n.httpOptions?n.httpOptions.baseUrl=s:n.httpOptions={baseUrl:s}),this.apiVersion=n.apiVersion;const r=new lC(this.apiKey);this.apiClient=new YE({auth:r,apiVersion:this.apiVersion,apiKey:this.apiKey,vertexai:this.vertexai,httpOptions:n.httpOptions,userAgentExtra:iC+"web",uploader:new eC,downloader:new F_}),this.models=new r_(this.apiClient),this.live=new n_(this.apiClient,r,new tC),this.batches=new kv(this.apiClient),this.chats=new ST(this.models,this.apiClient),this.caches=new yT(this.apiClient),this.files=new DT(this.apiClient),this.operations=new c_(this.apiClient),this.authTokens=new x_(this.apiClient),this.tunings=new O_(this.apiClient)}}const aC="AIzaSyCl4hPv_njJ9qLytv1QNPE3MmCFZJr9Wgk";let Ua=null;function bh(){return Ua||(Ua=new oC({apiKey:aC}),Ua)}async function xr(l,n,o){var p,g;let r=l,d=0;for(;d<5;){d++;try{const h=await bh().models.generateContentStream({model:"gemini-2.5-flash",contents:r});let T=null;for await(const _ of h){T=_;const R=_.text;R&&n(R)}if(((g=(p=T==null?void 0:T.candidates)==null?void 0:p[0])==null?void 0:g.finishReason)==="MAX_TOKENS")r=` +You were in the middle of generating a code file, but you were cut off because of a token limit. +Here is the code you have generated so far: +--- +${o()} +--- +Please continue generating the code exactly where you left off. +DO NOT repeat any of the code from above. +DO NOT add any explanations, introductory text, or markdown code fences. Just output the rest of the code. +Continuation: +`;else return}catch(y){throw console.error("Error calling Gemini API:",y),y instanceof Error?new Error(`AI request failed: ${y.message}`):new Error("Failed to get response from AI due to an unknown error.")}}if(d>=5)throw console.warn("Reached max attempts for code generation continuation."),new Error("AI failed to generate complete file after multiple attempts. The content may be incomplete.")}async function sC(l,n,o,s){const r=` +You are an expert code assistant. Your task is to modify the provided code based on the user's instruction. +You MUST return only the complete, updated code block. Do not add any explanations, introductory text, or markdown code fences like \`\`\`. + +Instruction: +${n} + +--- + +Original Code: +${l} + +--- + +Updated Code: +`;await xr(r,o,s)}async function uC(l,n,o,s,r){const d=` +You are an expert AI programmer executing a high-level directive across an entire codebase. +For the file located at \`${o}\`, apply the following overall instruction: +"${n}" + +Your task is to significantly enhance and expand this specific file based on the instruction. +- Add new features, classes, and functions that are relevant to the file's purpose and the main instruction. The goal is to substantially increase the file's value and content. +- You MUST NOT change or remove any existing import statements. +- Any new top-level functions, classes, or variables you create MUST be exported. +- Your changes should be mindful of the entire repository's architecture. Create code that can intelligently interact with other modules. +- Adhere strictly to the coding style and language of the original file. + +Return ONLY the complete, updated code for the file. Do not include any explanations, markdown fences, or other text outside of the code itself. + +--- +Original Code from \`${o}\`: +${l} +--- + +Updated Code: +`;await xr(d,s,r)}async function rC(l){const n=bh(),o=` +You are a senior software architect. Based on the user's request, create a file and folder structure for a new software project. +Your output MUST be a JSON object that adheres to the provided schema. +Do not include any explanations or markdown. Just the JSON object. +For each file, provide a concise, one-sentence description of its purpose. This description will be used to generate the file's content later. + +User Request: +"${l}" +`,r=(await n.models.generateContent({model:"gemini-2.5-flash",contents:o,config:{responseMimeType:"application/json",responseSchema:{type:Bt.OBJECT,properties:{files:{type:Bt.ARRAY,items:{type:Bt.OBJECT,properties:{path:{type:Bt.STRING},description:{type:Bt.STRING}},required:["path","description"]}}},required:["files"]}}})).text.trim();try{const d=JSON.parse(r);if(d&&Array.isArray(d.files))return d;throw new Error("Invalid structure in parsed JSON.")}catch(d){throw console.error("Failed to parse project plan JSON:",r,d),new Error("AI failed to generate a valid project plan.")}}async function cC(l,n,o,s,r){const d=` +You are an expert AI programmer. You are building a new project based on the overall goal: "${l}". +Your current task is to generate the complete code for the file at this path: \`${n}\`. +The purpose of this file is: "${o}". + +You are generating this file from scratch. +Return ONLY the complete code for the file. Do not include any explanations, markdown fences, or other text outside of the code itself. +Adhere to best practices for the technologies involved. +If you are generating a package.json, ensure it contains valid JSON. + +--- +Generated Code for \`${n}\`: +`;await xr(d,s,r)}const fC=({alert:l,onClose:n})=>{if(ne.useEffect(()=>{if(l){const s=setTimeout(()=>{n()},4e3);return()=>clearTimeout(s)}},[l,n]),!l)return null;const o=l.type==="success"?"bg-green-600":"bg-red-600";return C.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:[C.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; + } + `}),C.jsx("p",{children:l.message})]})},dC=({fileCount:l,onClose:n,onSubmit:o})=>{const[s,r]=ne.useState(""),[d,p]=ne.useState(!1),g=async y=>{y.preventDefault(),!(!s.trim()||d)&&(p(!0),await o(s))};return C.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-70 flex items-center justify-center z-50",onClick:n,children:C.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:[C.jsx("h2",{className:"text-xl font-bold text-amber-400 mb-2",children:"Multi-File AI Edit"}),C.jsxs("p",{className:"text-gray-400 mb-4",children:[l," file",l>1?"s":""," selected for editing."]}),C.jsxs("div",{className:"bg-red-900 border border-red-700 text-red-200 p-3 rounded-md mb-6 text-sm",children:[C.jsxs("p",{children:[C.jsx("strong",{children:"Warning:"})," This is an experimental feature. It will:"]}),C.jsxs("ul",{className:"list-disc list-inside mt-2",children:[C.jsxs("li",{children:["Commit changes directly to the ",C.jsx("strong",{children:"current branch"})," for each repository."]}),C.jsxs("li",{children:["Process up to ",C.jsx("strong",{children:"5 files concurrently"})," based on your instruction."]}),C.jsx("li",{children:"This may take a long time and consume significant API resources for a large number of files."})]}),C.jsx("p",{className:"mt-2",children:"It is highly recommended to create a new branch before starting and to review all changes carefully."})]}),C.jsxs("form",{onSubmit:g,children:[C.jsxs("div",{className:"mb-4",children:[C.jsx("label",{htmlFor:"instruction",className:"block text-sm font-medium text-gray-300 mb-2",children:"High-Level Instruction for All Selected Files"}),C.jsx("textarea",{id:"instruction",value:s,onChange:y=>r(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})]}),C.jsxs("div",{className:"flex justify-end gap-4 mt-6",children:[C.jsx("button",{type:"button",onClick:n,className:"px-4 py-2 bg-gray-600 text-white font-semibold rounded-md hover:bg-gray-700 disabled:opacity-50",disabled:d,children:"Cancel"}),C.jsx("button",{type:"submit",disabled:d||!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:d?C.jsx(tn,{}):"Start AI Edit"})]})]})]})})},mC=({status:l})=>{switch(l){case"queued":return C.jsx("div",{title:"Queued",className:"w-4 h-4 rounded-full bg-gray-600 flex-shrink-0"});case"processing":return C.jsx(tn,{className:"w-4 h-4 text-blue-400"});case"success":return C.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 C.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 C.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}},pC=({jobs:l,onClose:n,isComplete:o})=>{const s=l.filter(g=>g.status==="success"||g.status==="skipped"||g.status==="failed").length,r=l.filter(g=>g.status==="success").length,d=l.length>0?s/l.length*100:0,p=l.filter(g=>g.status==="processing");return C.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-80 flex items-center justify-center z-50",children:C.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:[C.jsxs("div",{className:"flex justify-between items-center mb-4 flex-shrink-0",children:[C.jsx("h2",{className:"text-2xl font-bold text-amber-400",children:"AI Bulk Edit Progress"}),o&&C.jsx("button",{onClick:n,className:"px-4 py-2 bg-gray-600 text-white font-semibold rounded-md hover:bg-gray-700",children:"Close"})]}),C.jsxs("div",{className:"mb-4 flex-shrink-0",children:[C.jsxs("div",{className:"flex justify-between text-sm text-gray-300 mb-1",children:[C.jsx("span",{children:`Overall Progress (${s} / ${l.length})`}),C.jsxs("span",{children:[r," successful"]})]}),C.jsx("div",{className:"w-full bg-gray-700 rounded-full h-2.5",children:C.jsx("div",{className:"bg-amber-500 h-2.5 rounded-full transition-all duration-300 ease-in-out",style:{width:`${d}%`}})})]}),C.jsxs("div",{className:"grid grid-cols-3 gap-4 flex-grow min-h-0",children:[C.jsxs("div",{className:"col-span-1 bg-gray-900 rounded-md p-4 overflow-y-auto",children:[C.jsx("h3",{className:"text-lg font-semibold mb-2 text-gray-200",children:"File Queue"}),C.jsx("ul",{className:"space-y-1",children:l.map(g=>C.jsxs("li",{className:"flex items-center justify-between text-sm p-1.5 bg-gray-800 rounded",children:[C.jsxs("div",{className:"flex items-center gap-3 overflow-hidden",children:[C.jsx(mC,{status:g.status}),C.jsx("span",{className:"truncate",title:g.path,children:g.path})]}),g.status==="failed"&&C.jsx("span",{className:"text-red-400 text-xs truncate ml-2 cursor-pointer",title:g.error||"Unknown error",children:"Error"})]},g.id))})]}),C.jsxs("div",{className:"col-span-2 bg-gray-900 rounded-md p-4 flex flex-col",children:[C.jsxs("h3",{className:"text-lg font-semibold mb-2 text-gray-200",children:["Live Workstream (",p.length," active)"]}),p.length>0?C.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 flex-grow min-h-0",children:p.slice(0,5).map(g=>C.jsxs("div",{className:"flex-grow flex flex-col min-h-0 bg-gray-850 rounded-lg p-2",children:[C.jsxs("p",{className:"text-blue-300 font-mono text-xs mb-2 truncate",title:g.path,children:["Processing: ",C.jsx("span",{className:"font-bold",children:g.path.split("/").pop()})]}),C.jsx("div",{className:"bg-gray-950 rounded p-2 flex-grow overflow-y-auto",children:C.jsx("pre",{className:"text-xs text-gray-300 whitespace-pre-wrap break-words",children:C.jsx("code",{children:g.content})})})]},g.id))}):C.jsx("div",{className:"flex items-center justify-center h-full text-gray-500",children:o?"All jobs complete.":"Waiting for next job..."})]})]})]})})},hC=({onClose:l,onSubmit:n})=>{const[o,s]=ne.useState(""),[r,d]=ne.useState(""),[p,g]=ne.useState(!0),[y,h]=ne.useState(!1),[T,S]=ne.useState(""),_=async R=>{if(R.preventDefault(),S(""),!(!o.trim()||!r.trim()||y)){h(!0);try{await n(o.trim().replace(/\s+/g,"-"),r,p)}catch(H){S(H instanceof Error?H.message:"An unknown error occurred."),h(!1)}}};return C.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-70 flex items-center justify-center z-50",onClick:l,children:C.jsxs("div",{className:"bg-gray-850 p-6 rounded-lg shadow-2xl w-full max-w-2xl border border-gray-700",onClick:R=>R.stopPropagation(),children:[C.jsx("h2",{className:"text-xl font-bold text-indigo-400 mb-4",children:"New AI Project"}),C.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."}),C.jsxs("form",{onSubmit:_,children:[C.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-4",children:[C.jsxs("div",{className:"md:col-span-2",children:[C.jsx("label",{htmlFor:"repoName",className:"block text-sm font-medium text-gray-300 mb-2",children:"New Repository Name"}),C.jsx("input",{id:"repoName",type:"text",value:o,onChange:R=>s(R.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})]}),C.jsxs("div",{children:[C.jsx("label",{htmlFor:"repoVisibility",className:"block text-sm font-medium text-gray-300 mb-2",children:"Visibility"}),C.jsxs("select",{id:"repoVisibility",value:p?"private":"public",onChange:R=>g(R.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:[C.jsx("option",{value:"private",children:"Private"}),C.jsx("option",{value:"public",children:"Public"})]})]})]}),C.jsxs("div",{className:"mb-4",children:[C.jsx("label",{htmlFor:"prompt",className:"block text-sm font-medium text-gray-300 mb-2",children:"Project Description"}),C.jsx("textarea",{id:"prompt",value:r,onChange:R=>d(R.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})]}),T&&C.jsx("p",{className:"text-red-400 text-sm mb-4",children:T}),C.jsxs("div",{className:"flex justify-end gap-4",children:[C.jsx("button",{type:"button",onClick:l,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"}),C.jsx("button",{type:"submit",disabled:y||!o.trim()||!r.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?C.jsx(tn,{}):"Generate Project"})]})]})]})})},gC=({status:l})=>{switch(l){case"queued":return C.jsx("div",{title:"Queued",className:"w-4 h-4 rounded-full bg-gray-600 flex-shrink-0"});case"generating":return C.jsx(tn,{className:"w-4 h-4 text-blue-400"});case"committing":return C.jsx(tn,{className:"w-4 h-4 text-yellow-400"});case"success":return C.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 C.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}},yC=({jobs:l,statusMessage:n,onClose:o,isComplete:s})=>{const r=l.filter(y=>y.status==="success"||y.status==="failed").length,d=l.filter(y=>y.status==="success").length,p=l.length>0?r/l.length*100:0,g=l.find(y=>y.status==="generating"||y.status==="committing");return C.jsx("div",{className:"fixed inset-0 bg-gray-950 bg-opacity-80 flex items-center justify-center z-50",children:C.jsxs("div",{className:"bg-gray-850 p-6 rounded-lg shadow-2xl w-full max-w-4xl h-[75vh] flex flex-col border border-gray-700",children:[C.jsxs("div",{className:"flex justify-between items-center mb-4 flex-shrink-0",children:[C.jsx("h2",{className:"text-2xl font-bold text-indigo-400",children:"AI Project Generation"}),s&&C.jsx("button",{onClick:o,className:"px-4 py-2 bg-gray-600 text-white font-semibold rounded-md hover:bg-gray-700",children:"Close"})]}),C.jsxs("div",{className:"mb-4 flex-shrink-0",children:[C.jsxs("div",{className:"flex justify-between text-sm text-gray-300 mb-1",children:[C.jsxs("span",{className:"flex items-center gap-2",children:[!s&&C.jsx(tn,{className:"h-4 w-4"}),n]}),C.jsx("span",{children:`${d} / ${l.length} files successful`})]}),C.jsx("div",{className:"w-full bg-gray-700 rounded-full h-2.5",children:C.jsx("div",{className:"bg-indigo-500 h-2.5 rounded-full transition-all duration-300 ease-in-out",style:{width:`${p}%`}})})]}),C.jsxs("div",{className:"grid grid-cols-3 gap-4 flex-grow min-h-0",children:[C.jsxs("div",{className:"col-span-1 bg-gray-900 rounded-md p-4 overflow-y-auto",children:[C.jsx("h3",{className:"text-lg font-semibold mb-2 text-gray-200",children:"File Plan"}),C.jsx("ul",{className:"space-y-1",children:l.map(y=>C.jsxs("li",{className:"flex items-center justify-between text-sm p-1.5 bg-gray-800 rounded",children:[C.jsxs("div",{className:"flex items-center gap-3 overflow-hidden",children:[C.jsx(gC,{status:y.status}),C.jsx("span",{className:"truncate",title:y.path,children:y.path})]}),y.status==="failed"&&C.jsx("span",{className:"text-red-400 text-xs truncate ml-2 cursor-pointer",title:y.error||"Unknown error",children:"Error"})]},y.id))})]}),C.jsxs("div",{className:"col-span-2 bg-gray-900 rounded-md p-4 flex flex-col",children:[C.jsx("h3",{className:"text-lg font-semibold mb-2 text-gray-200",children:"Live Generation"}),g?C.jsxs("div",{className:"flex-grow flex flex-col min-h-0 bg-gray-850 rounded-lg p-2",children:[C.jsxs("p",{className:"text-blue-300 font-mono text-xs mb-2 truncate",title:g.path,children:[g.status==="generating"?"Generating":"Committing",": ",C.jsx("span",{className:"font-bold",children:g.path})]}),C.jsx("div",{className:"bg-gray-950 rounded p-2 flex-grow overflow-y-auto",children:C.jsx("pre",{className:"text-xs text-gray-300 whitespace-pre-wrap break-words",children:C.jsx("code",{children:g.content})})})]}):C.jsx("div",{className:"flex items-center justify-center h-full text-gray-500",children:s?"All files generated.":"Waiting to generate..."})]})]})]})})},Mr=l=>{let n=[];for(const o of l)o.type==="file"?n.push(o.path):o.type==="dir"&&(n=n.concat(Mr(o.children)));return n};function vC(){const[l,n]=ne.useState(null),[o,s]=ne.useState({}),[r,d]=ne.useState([]),[p,g]=ne.useState(null),[y,h]=ne.useState(!1),[T,S]=ne.useState(""),[_,R]=ne.useState(null),[H,V]=ne.useState({}),[Y,J]=ne.useState({}),[X,P]=ne.useState(!1),[K,te]=ne.useState(new Set),[le,F]=ne.useState(!1),[ve,$]=ne.useState([]),[Te,Me]=ne.useState(!1),[pe,Ke]=ne.useState(!1),[st,Oe]=ne.useState([]),[I,k]=ne.useState(""),B=r.find(Z=>Z.repoFullName+"::"+Z.path===p),re=B?Y[B.repoFullName]:null,Se=B?H[B.repoFullName]||[]:[],M=ne.useCallback(async Z=>{if(Z){n(Z),h(!0),S("Fetching repositories...");try{const ae=await p0(Z),de={},ie=ae.map(async ue=>{S(`Processing ${ue.owner.login}/${ue.name}...`);try{de[ue.full_name]={repo:ue,tree:[]};const ge=await Lm(Z,ue.owner.login,ue.name,ue.default_branch);de[ue.full_name].tree=ge}catch(ge){console.error(`Failed to fetch tree for ${ue.full_name}`,ge)}});await Promise.all(ie),s(de),q("success","Successfully loaded all repositories.")}catch(ae){console.error(ae),n(null),q("error",`Login failed. ${ae instanceof Error?ae.message:"Please check your token and permissions."}`)}finally{h(!1),S("")}}},[]),q=(Z,ae)=>{R({type:Z,message:ae})},O=ne.useCallback(async(Z,ae,de)=>{var ue;const ie=`${Z}::${ae}`;if(r.some(ge=>ge.repoFullName+"::"+ge.path===ie)){g(ie);return}if(l){h(!0),S(`Loading ${ae}...`);try{const[ge,ln]=Z.split("/"),Fe=(ue=o[Z])==null?void 0:ue.repo;if(!Fe)throw new Error("Repository data not found");if(!H[Z]){S("Fetching branches...");const Be=await Gm(l,ge,ln);V(Ct=>({...Ct,[Z]:Be}))}const Ze=de||Y[Z]||Fe.default_branch;J(Be=>({...Be,[Z]:Ze})),S(`Loading ${ae} from branch ${Ze}...`);const _t=await wa(l,ge,ln,ae,Ze),Pe={repoFullName:Z,path:_t.path,content:_t.content,editedContent:_t.content,sha:_t.sha,defaultBranch:Fe.default_branch};d(Be=>[...Be,Pe]),g(ie)}catch(ge){console.error(ge),q("error",`Failed to load file: ${ae}`)}finally{h(!1),S("")}}},[l,o,r,H,Y]),Q=ne.useCallback(Z=>{const ae=r.findIndex(ie=>ie.repoFullName+"::"+ie.path===Z);if(ae===-1)return;const de=r.filter(ie=>ie.repoFullName+"::"+ie.path!==Z);if(d(de),p===Z)if(de.length===0)g(null);else{const ie=Math.max(0,ae-1),ue=de[ie];g(ue.repoFullName+"::"+ue.path)}},[r,p]),ce=ne.useCallback(Z=>{g(Z)},[]),ye=ne.useCallback((Z,ae)=>{d(de=>de.map(ie=>ie.repoFullName+"::"+ie.path===Z?{...ie,editedContent:ae}:ie))},[]),Ne=ne.useCallback(async(Z,ae,de,ie)=>{h(!0),S("AI is editing the code...");try{await sC(Z,ae,de,ie),q("success","AI edit complete.")}catch(ue){console.error("AI Edit Error:",ue);const ge=typeof ue=="string"?ue:ue instanceof Error?ue.message:"An unknown AI error occurred.";q("error",`AI Error: ${ge}`)}finally{h(!1),S("")}},[]),ct=ne.useCallback(async Z=>{if(!(!l||!B||!re)){h(!0),S("Committing changes...");try{const[ae,de]=B.repoFullName.split("/");await sr({token:l,owner:ae,repo:de,branch:re,path:B.path,content:B.editedContent,message:Z,sha:B.sha});const ie=await wa(l,ae,de,B.path,re);d(ue=>ue.map(ge=>ge.repoFullName+"::"+ge.path===p?{...ge,content:ie.content,editedContent:ie.content,sha:ie.sha}:ge)),q("success","Commit successful!")}catch(ae){console.error(ae),q("error",`Failed to commit changes: ${ae.message}`)}finally{h(!1),S("")}}},[l,B,re,p]),Qe=ne.useCallback(Z=>{if(B){const ae=B.repoFullName;J(ue=>({...ue,[ae]:Z}));const de=r.filter(ue=>ue.repoFullName===ae),ie=r.filter(ue=>ue.repoFullName!==ae);d(ie),g(ie[0]?ie[0].repoFullName+"::"+ie[0].path:null),de.forEach(ue=>{O(ue.repoFullName,ue.path,Z)})}},[B,r,O]),ll=ne.useCallback(async Z=>{if(!(!l||!B||!re)){h(!0),S(`Creating branch ${Z}...`);try{const[ae,de]=B.repoFullName.split("/"),ie=Se.find(ge=>ge.name===re);if(!ie)throw new Error("Base branch not found");await g0(l,ae,de,Z,ie.commit.sha);const ue=await Gm(l,ae,de);V(ge=>({...ge,[B.repoFullName]:ue})),J(ge=>({...ge,[B.repoFullName]:Z})),q("success",`Branch '${Z}' created successfully.`)}catch(ae){console.error(ae),q("error",`Failed to create branch: ${ae.message}`)}finally{h(!1),S("")}}},[l,B,re,Se]),Al=ne.useCallback(async(Z,ae)=>{if(!(!l||!B||!re)){h(!0),S("Creating pull request...");try{const[de,ie]=B.repoFullName.split("/"),ue=await T0({token:l,owner:de,repo:ie,title:Z,body:ae,head:re,base:B.defaultBranch});q("success",`Successfully created Pull Request #${ue.number}!`),window.open(ue.html_url,"_blank")}catch(de){console.error(de),q("error",`Failed to create pull request: ${de.message}`)}finally{h(!1),S("")}}},[l,B,re]),yi=ne.useCallback((Z,ae)=>{te(de=>{const ie=new Set(de);return ae?ie.add(Z):ie.delete(Z),ie})},[]),go=ne.useCallback((Z,ae,de)=>{const ie=Mr(Z);te(ue=>{const ge=new Set(ue);for(const ln of ie){const Fe=`${ae}::${ln}`;de?ge.add(Fe):ge.delete(Fe)}return ge})},[]),fn=ne.useCallback(async Z=>{if(!l||K.size===0)return;P(!1);const de=[...K].map(Ze=>{const[_t,Pe]=Ze.split("::");return{id:Ze,repoFullName:_t,path:Pe,status:"queued",content:"",error:null}});$(de),F(!0),te(new Set);const ie=async Ze=>{var At;$(Re=>Re.map(Ue=>Ue.id===Ze?{...Ue,status:"processing"}:Ue));const _t=de.find(Re=>Re.id===Ze);if(!_t||!l)return;const{repoFullName:Pe,path:Be}=_t,[Ct,on]=Pe.split("/"),an=(At=o[Pe])==null?void 0:At.repo;if(!an){$(Re=>Re.map(Ue=>Ue.id===Ze?{...Ue,status:"failed",error:"Repo data not found"}:Ue));return}try{const Re=Y[Pe]||an.default_branch,Ue=await wa(l,Ct,on,Be,Re);let ft="";const ot=()=>ft,ka=dt=>{ft+=dt,$(vt=>vt.map(Ut=>Ut.id===Ze?{...Ut,content:ft}:Ut))};if(await uC(Ue.content,Z,Be,ka,ot),ft.trim()===Ue.content.trim()||ft.trim()===""){$(dt=>dt.map(vt=>vt.id===Ze?{...vt,status:"skipped"}:vt));return}await sr({token:l,owner:Ct,repo:on,branch:Re,path:Be,content:ft,message:`[AI] Edit: ${Be}`,sha:Ue.sha}),$(dt=>dt.map(vt=>vt.id===Ze?{...vt,status:"success"}:vt));const yo=`${Pe}::${Be}`;if(r.some(dt=>dt.repoFullName+"::"+dt.path===yo)){const dt=await wa(l,Ct,on,Be,Re);d(vt=>vt.map(Ut=>Ut.repoFullName+"::"+Ut.path===yo?{...Ut,content:dt.content,editedContent:dt.content,sha:dt.sha}:Ut))}}catch(Re){const Ue=Re instanceof Error?Re.message:"An unknown error occurred.";$(ft=>ft.map(ot=>ot.id===Ze?{...ot,status:"failed",error:Ue}:ot))}},ue=5,ge=[...de],ln=async()=>{for(;ge.length>0;){const Ze=ge.shift();Ze&&await ie(Ze.id)}},Fe=Array(ue).fill(null).map(ln);await Promise.all(Fe),q("success","Multi-file edit process completed.")},[l,K,o,Y,r]),xl=ne.useCallback(async Z=>{if(l)try{const ae=await Lm(l,Z.owner.login,Z.name,Z.default_branch);s(de=>({...de,[Z.full_name]:{repo:Z,tree:ae}}))}catch(ae){console.error(`Failed to refresh tree for new repo ${Z.full_name}`,ae),q("error","Project generated, but failed to refresh file explorer.")}},[l]),vi=ne.useCallback(async(Z,ae,de)=>{if(!l)return;Me(!1),Ke(!0),Oe([]);let ie=null;try{k(`Creating repository '${Z}'...`),ie=await y0({token:l,name:Z,description:ae,isPrivate:de}),q("success",`Repository '${ie.full_name}' created.`),k("Asking AI to plan project structure...");const ge=(await rC(ae)).files.map(Pe=>({id:Pe.path,path:Pe.path,description:Pe.description,status:"queued",content:"",error:null}));Oe(ge),k(`Generating ${ge.length} files...`);const ln=async Pe=>{const Be=ge.find(At=>At.id===Pe);if(!Be||!l||!ie)return;Oe(At=>At.map(Re=>Re.id===Pe?{...Re,status:"generating"}:Re));let Ct="";const on=()=>Ct,an=At=>{Ct+=At,Oe(Re=>Re.map(Ue=>Ue.id===Pe?{...Ue,content:Ct}:Ue))};await cC(ae,Be.path,Be.description,an,on),Oe(At=>At.map(Re=>Re.id===Pe?{...Re,status:"committing"}:Re)),await sr({token:l,owner:ie.owner.login,repo:ie.name,branch:ie.default_branch,path:Be.path,content:Ct,message:`[AI] Create ${Be.path}`}),Oe(At=>At.map(Re=>Re.id===Pe?{...Re,status:"success"}:Re))},Fe=5,Ze=[...ge],_t=async()=>{for(;Ze.length>0;){const Pe=Ze.shift();if(Pe)try{await ln(Pe.id)}catch(Be){const Ct=Be instanceof Error?Be.message:"An unknown error occurred.";Oe(on=>on.map(an=>an.id===Pe.id?{...an,status:"failed",error:Ct}:an))}}};await Promise.all(Array(Fe).fill(null).map(_t)),k("Finalizing..."),await xl(ie),q("success",`Project '${ie.full_name}' generated successfully!`)}catch(ue){const ge=ue instanceof Error?ue.message:"An unknown error occurred.";q("error",`Project generation failed: ${ge}`);return}},[l,xl]);return C.jsxs("div",{className:"flex h-screen font-sans",children:[l?C.jsxs(C.Fragment,{children:[C.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:C.jsx(s0,{fileTree:o,onFileSelect:O,onStartMultiEdit:()=>P(!0),onStartNewProject:()=>Me(!0),selectedRepo:B==null?void 0:B.repoFullName,selectedFilePath:B==null?void 0:B.path,selectedFiles:K,onFileSelection:yi,onDirectorySelection:go})}),C.jsx("main",{className:"flex-grow h-full",children:C.jsx(d0,{openFiles:r,activeFile:B||null,onCommit:ct,onAiEdit:Ne,onFileContentChange:ye,onCloseFile:Q,onSetActiveFile:ce,isLoading:y,branches:Se,currentBranch:re,onBranchChange:Qe,onCreateBranch:ll,onCreatePullRequest:Al})})]}):C.jsx(n0,{onSubmit:M,isLoading:y}),y&&!le&&C.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:[C.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; + } + `}),C.jsx(tn,{}),C.jsx("p",{children:T})]}),_&&C.jsx(fC,{alert:_,onClose:()=>R(null)}),Te&&C.jsx(hC,{onClose:()=>Me(!1),onSubmit:vi}),X&&C.jsx(dC,{fileCount:K.size,onClose:()=>P(!1),onSubmit:fn}),le&&C.jsx(pC,{jobs:ve,onClose:()=>F(!1),isComplete:!ve.some(Z=>Z.status==="processing"||Z.status==="queued")}),pe&&C.jsx(yC,{jobs:st,statusMessage:I,onClose:()=>Ke(!1),isComplete:st.length>0&&!st.some(Z=>Z.status==="generating"||Z.status==="queued"||Z.status==="committing")})]})}const Dh=document.getElementById("root");if(!Dh)throw new Error("Could not find root element to mount to");const TC=t0.createRoot(Dh);TC.render(C.jsx(Xy.StrictMode,{children:C.jsx(vC,{})}));