diff --git "a/assets/index-BFvMGUwY.js" "b/assets/index-BFvMGUwY.js" new file mode 100644--- /dev/null +++ "b/assets/index-BFvMGUwY.js" @@ -0,0 +1,474 @@ +var rR=Object.defineProperty;var TA=e=>{throw TypeError(e)};var iR=(e,t,n)=>t in e?rR(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var f0=(e,t,n)=>iR(e,typeof t!="symbol"?t+"":t,n),m0=(e,t,n)=>t.has(e)||TA("Cannot "+n);var B=(e,t,n)=>(m0(e,t,"read from private field"),n?n.call(e):t.get(e)),Ie=(e,t,n)=>t.has(e)?TA("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),xe=(e,t,n,r)=>(m0(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Ge=(e,t,n)=>(m0(e,t,"access private method"),n);var Of=(e,t,n,r)=>({set _(i){xe(e,t,i,n)},get _(){return B(e,t,r)}});function aR(e,t){for(var n=0;nr[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const c of o.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&r(c)}).observe(document,{childList:!0,subtree:!0});function n(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(i){if(i.ep)return;i.ep=!0;const o=n(i);fetch(i.href,o)}})();function ji(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var h0={exports:{}},mu={};/** + * @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 EA;function oR(){if(EA)return mu;EA=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,i,o){var c=null;if(o!==void 0&&(c=""+o),i.key!==void 0&&(c=""+i.key),"key"in i){o={};for(var u in i)u!=="key"&&(o[u]=i[u])}else o=i;return i=o.ref,{$$typeof:e,type:r,key:c,ref:i!==void 0?i:null,props:o}}return mu.Fragment=t,mu.jsx=n,mu.jsxs=n,mu}var NA;function sR(){return NA||(NA=1,h0.exports=oR()),h0.exports}var l=sR(),p0={exports:{}},Be={};/** + * @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 _A;function lR(){if(_A)return Be;_A=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),g=Symbol.for("react.activity"),v=Symbol.iterator;function b(U){return U===null||typeof U!="object"?null:(U=v&&U[v]||U["@@iterator"],typeof U=="function"?U:null)}var T={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,E={};function N(U,te,ue){this.props=U,this.context=te,this.refs=E,this.updater=ue||T}N.prototype.isReactComponent={},N.prototype.setState=function(U,te){if(typeof U!="object"&&typeof U!="function"&&U!=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,U,te,"setState")},N.prototype.forceUpdate=function(U){this.updater.enqueueForceUpdate(this,U,"forceUpdate")};function I(){}I.prototype=N.prototype;function P(U,te,ue){this.props=U,this.context=te,this.refs=E,this.updater=ue||T}var M=P.prototype=new I;M.constructor=P,C(M,N.prototype),M.isPureReactComponent=!0;var j=Array.isArray;function k(){}var R={H:null,A:null,T:null,S:null},F=Object.prototype.hasOwnProperty;function q(U,te,ue){var fe=ue.ref;return{$$typeof:e,type:U,key:te,ref:fe!==void 0?fe:null,props:ue}}function G(U,te){return q(U.type,te,U.props)}function H(U){return typeof U=="object"&&U!==null&&U.$$typeof===e}function V(U){var te={"=":"=0",":":"=2"};return"$"+U.replace(/[=:]/g,function(ue){return te[ue]})}var oe=/\/+/g;function Z(U,te){return typeof U=="object"&&U!==null&&U.key!=null?V(""+U.key):te.toString(36)}function me(U){switch(U.status){case"fulfilled":return U.value;case"rejected":throw U.reason;default:switch(typeof U.status=="string"?U.then(k,k):(U.status="pending",U.then(function(te){U.status==="pending"&&(U.status="fulfilled",U.value=te)},function(te){U.status==="pending"&&(U.status="rejected",U.reason=te)})),U.status){case"fulfilled":return U.value;case"rejected":throw U.reason}}throw U}function z(U,te,ue,fe,Ne){var Pe=typeof U;(Pe==="undefined"||Pe==="boolean")&&(U=null);var Re=!1;if(U===null)Re=!0;else switch(Pe){case"bigint":case"string":case"number":Re=!0;break;case"object":switch(U.$$typeof){case e:case t:Re=!0;break;case h:return Re=U._init,z(Re(U._payload),te,ue,fe,Ne)}}if(Re)return Ne=Ne(U),Re=fe===""?"."+Z(U,0):fe,j(Ne)?(ue="",Re!=null&&(ue=Re.replace(oe,"$&/")+"/"),z(Ne,te,ue,"",function(Le){return Le})):Ne!=null&&(H(Ne)&&(Ne=G(Ne,ue+(Ne.key==null||U&&U.key===Ne.key?"":(""+Ne.key).replace(oe,"$&/")+"/")+Re)),te.push(Ne)),1;Re=0;var wt=fe===""?".":fe+":";if(j(U))for(var re=0;re>>1,Me=z[ge];if(0>>1;gei(ue,ce))fei(Ne,ue)?(z[ge]=Ne,z[fe]=ce,ge=fe):(z[ge]=ue,z[te]=ce,ge=te);else if(fei(Ne,ce))z[ge]=Ne,z[fe]=ce,ge=fe;else break e}}return Y}function i(z,Y){var ce=z.sortIndex-Y.sortIndex;return ce!==0?ce:z.id-Y.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var c=Date,u=c.now();e.unstable_now=function(){return c.now()-u}}var m=[],f=[],h=1,g=null,v=3,b=!1,T=!1,C=!1,E=!1,N=typeof setTimeout=="function"?setTimeout:null,I=typeof clearTimeout=="function"?clearTimeout:null,P=typeof setImmediate<"u"?setImmediate:null;function M(z){for(var Y=n(f);Y!==null;){if(Y.callback===null)r(f);else if(Y.startTime<=z)r(f),Y.sortIndex=Y.expirationTime,t(m,Y);else break;Y=n(f)}}function j(z){if(C=!1,M(z),!T)if(n(m)!==null)T=!0,k||(k=!0,V());else{var Y=n(f);Y!==null&&me(j,Y.startTime-z)}}var k=!1,R=-1,F=5,q=-1;function G(){return E?!0:!(e.unstable_now()-qz&&G());){var ge=g.callback;if(typeof ge=="function"){g.callback=null,v=g.priorityLevel;var Me=ge(g.expirationTime<=z);if(z=e.unstable_now(),typeof Me=="function"){g.callback=Me,M(z),Y=!0;break t}g===n(m)&&r(m),M(z)}else r(m);g=n(m)}if(g!==null)Y=!0;else{var U=n(f);U!==null&&me(j,U.startTime-z),Y=!1}}break e}finally{g=null,v=ce,b=!1}Y=void 0}}finally{Y?V():k=!1}}}var V;if(typeof P=="function")V=function(){P(H)};else if(typeof MessageChannel<"u"){var oe=new MessageChannel,Z=oe.port2;oe.port1.onmessage=H,V=function(){Z.postMessage(null)}}else V=function(){N(H,0)};function me(z,Y){R=N(function(){z(e.unstable_now())},Y)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(z){z.callback=null},e.unstable_forceFrameRate=function(z){0>z||125ge?(z.sortIndex=ce,t(f,z),n(m)===null&&z===n(f)&&(C?(I(R),R=-1):C=!0,me(j,ce-ge))):(z.sortIndex=Me,t(m,z),T||b||(T=!0,k||(k=!0,V()))),z},e.unstable_shouldYield=G,e.unstable_wrapCallback=function(z){var Y=v;return function(){var ce=v;v=Y;try{return z.apply(this,arguments)}finally{v=ce}}}})(v0)),v0}var PA;function dR(){return PA||(PA=1,y0.exports=uR()),y0.exports}var x0={exports:{}},kn={};/** + * @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 IA;function fR(){if(IA)return kn;IA=1;var e=nc();function t(m){var f="https://react.dev/errors/"+m;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),x0.exports=fR(),x0.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 DA;function mR(){if(DA)return hu;DA=1;var e=dR(),t=nc(),n=Xj();function r(a){var s="https://react.dev/errors/"+a;if(1Me||(a.current=ge[Me],ge[Me]=null,Me--)}function ue(a,s){Me++,ge[Me]=a.current,a.current=s}var fe=U(null),Ne=U(null),Pe=U(null),Re=U(null);function wt(a,s){switch(ue(Pe,s),ue(Ne,a),ue(fe,null),s.nodeType){case 9:case 11:a=(a=s.documentElement)&&(a=a.namespaceURI)?YS(a):0;break;default:if(a=s.tagName,s=s.namespaceURI)s=YS(s),a=WS(s,a);else switch(a){case"svg":a=1;break;case"math":a=2;break;default:a=0}}te(fe),ue(fe,a)}function re(){te(fe),te(Ne),te(Pe)}function Le(a){a.memoizedState!==null&&ue(Re,a);var s=fe.current,d=WS(s,a.type);s!==d&&(ue(Ne,a),ue(fe,d))}function Fe(a){Ne.current===a&&(te(fe),te(Ne)),Re.current===a&&(te(Re),cu._currentValue=ce)}var de,$t;function $e(a){if(de===void 0)try{throw Error()}catch(d){var s=d.stack.trim().match(/\n( *(at )?)/);de=s&&s[1]||"",$t=-1)":-1w||L[p]!==Q[w]){var ne=` +`+L[p].replace(" at new "," at ");return a.displayName&&ne.includes("")&&(ne=ne.replace("",a.displayName)),ne}while(1<=p&&0<=w);break}}}finally{Ht=!1,Error.prepareStackTrace=d}return(d=a?a.displayName||a.name:"")?$e(d):""}function cr(a,s){switch(a.tag){case 26:case 27:case 5:return $e(a.type);case 16:return $e("Lazy");case 13:return a.child!==s&&s!==null?$e("Suspense Fallback"):$e("Suspense");case 19:return $e("SuspenseList");case 0:case 15:return Vt(a.type,!1);case 11:return Vt(a.type.render,!1);case 1:return Vt(a.type,!0);case 31:return $e("Activity");default:return""}}function Er(a){try{var s="",d=null;do s+=cr(a,d),d=a,a=a.return;while(a);return s}catch(p){return` +Error generating stack: `+p.message+` +`+p.stack}}var Po=Object.prototype.hasOwnProperty,Jr=e.unstable_scheduleCallback,Io=e.unstable_cancelCallback,ki=e.unstable_shouldYield,Us=e.unstable_requestPaint,Kt=e.unstable_now,ko=e.unstable_getCurrentPriorityLevel,Bs=e.unstable_ImmediatePriority,zs=e.unstable_UserBlockingPriority,ci=e.unstable_NormalPriority,bc=e.unstable_LowPriority,ja=e.unstable_IdlePriority,Do=e.log,ur=e.unstable_setDisableYieldValue,Qr=null,Qt=null;function Sn(a){if(typeof Do=="function"&&ur(a),Qt&&typeof Qt.setStrictMode=="function")try{Qt.setStrictMode(Qr,a)}catch{}}var An=Math.clz32?Math.clz32:Sc,Fs=Math.log,wc=Math.LN2;function Sc(a){return a>>>=0,a===0?32:31-(Fs(a)/wc|0)|0}var ui=256,Di=262144,di=4194304;function Nr(a){var s=a&42;if(s!==0)return s;switch(a&-a){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 a&261888;case 262144:case 524288:case 1048576:case 2097152:return a&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return a&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return a}}function Ma(a,s,d){var p=a.pendingLanes;if(p===0)return 0;var w=0,A=a.suspendedLanes,_=a.pingedLanes;a=a.warmLanes;var D=p&134217727;return D!==0?(p=D&~A,p!==0?w=Nr(p):(_&=D,_!==0?w=Nr(_):d||(d=D&~a,d!==0&&(w=Nr(d))))):(D=p&~A,D!==0?w=Nr(D):_!==0?w=Nr(_):d||(d=p&~a,d!==0&&(w=Nr(d)))),w===0?0:s!==0&&s!==w&&(s&A)===0&&(A=w&-w,d=s&-s,A>=d||A===32&&(d&4194048)!==0)?s:w}function fi(a,s){return(a.pendingLanes&~(a.suspendedLanes&~a.pingedLanes)&s)===0}function Ac(a,s){switch(a){case 1:case 2:case 4:case 8:case 64:return s+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 s+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 Ro(){var a=di;return di<<=1,(di&62914560)===0&&(di=4194304),a}function Ae(a){for(var s=[],d=0;31>d;d++)s.push(a);return s}function Bt(a,s){a.pendingLanes|=s,s!==268435456&&(a.suspendedLanes=0,a.pingedLanes=0,a.warmLanes=0)}function qs(a,s,d,p,w,A){var _=a.pendingLanes;a.pendingLanes=d,a.suspendedLanes=0,a.pingedLanes=0,a.warmLanes=0,a.expiredLanes&=d,a.entangledLanes&=d,a.errorRecoveryDisabledLanes&=d,a.shellSuspendCounter=0;var D=a.entanglements,L=a.expirationTimes,Q=a.hiddenUpdates;for(d=_&~d;0"u")return null;try{return a.activeElement||a.body}catch{return a.body}}var Ce=/[\n"\\]/g;function De(a){return a.replace(Ce,function(s){return"\\"+s.charCodeAt(0).toString(16)+" "})}function Rt(a,s,d,p,w,A,_,D){a.name="",_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"?a.type=_:a.removeAttribute("type"),s!=null?_==="number"?(s===0&&a.value===""||a.value!=s)&&(a.value=""+Yn(s)):a.value!==""+Yn(s)&&(a.value=""+Yn(s)):_!=="submit"&&_!=="reset"||a.removeAttribute("value"),s!=null?sp(a,_,Yn(s)):d!=null?sp(a,_,Yn(d)):p!=null&&a.removeAttribute("value"),w==null&&A!=null&&(a.defaultChecked=!!A),w!=null&&(a.checked=w&&typeof w!="function"&&typeof w!="symbol"),D!=null&&typeof D!="function"&&typeof D!="symbol"&&typeof D!="boolean"?a.name=""+Yn(D):a.removeAttribute("name")}function Wn(a,s,d,p,w,A,_,D){if(A!=null&&typeof A!="function"&&typeof A!="symbol"&&typeof A!="boolean"&&(a.type=A),s!=null||d!=null){if(!(A!=="submit"&&A!=="reset"||s!=null)){le(a);return}d=d!=null?""+Yn(d):"",s=s!=null?""+Yn(s):d,D||s===a.value||(a.value=s),a.defaultValue=s}p=p??w,p=typeof p!="function"&&typeof p!="symbol"&&!!p,a.checked=D?a.checked:!!p,a.defaultChecked=!!p,_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"&&(a.name=_),le(a)}function sp(a,s,d){s==="number"&&ye(a.ownerDocument)===a||a.defaultValue===""+d||(a.defaultValue=""+d)}function Hs(a,s,d,p){if(a=a.options,s){s={};for(var w=0;w"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),fp=!1;if(Ui)try{var Nc={};Object.defineProperty(Nc,"passive",{get:function(){fp=!0}}),window.addEventListener("test",Nc,Nc),window.removeEventListener("test",Nc,Nc)}catch{fp=!1}var Oa=null,mp=null,Nd=null;function W1(){if(Nd)return Nd;var a,s=mp,d=s.length,p,w="value"in Oa?Oa.value:Oa.textContent,A=w.length;for(a=0;a=Mc),tw=" ",nw=!1;function rw(a,s){switch(a){case"keyup":return Tk.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function iw(a){return a=a.detail,typeof a=="object"&&"data"in a?a.data:null}var Ws=!1;function Nk(a,s){switch(a){case"compositionend":return iw(s);case"keypress":return s.which!==32?null:(nw=!0,tw);case"textInput":return a=s.data,a===tw&&nw?null:a;default:return null}}function _k(a,s){if(Ws)return a==="compositionend"||!vp&&rw(a,s)?(a=W1(),Nd=mp=Oa=null,Ws=!1,a):null;switch(a){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1=s)return{node:d,offset:s-a};a=p}e:{for(;d;){if(d.nextSibling){d=d.nextSibling;break e}d=d.parentNode}d=void 0}d=fw(d)}}function hw(a,s){return a&&s?a===s?!0:a&&a.nodeType===3?!1:s&&s.nodeType===3?hw(a,s.parentNode):"contains"in a?a.contains(s):a.compareDocumentPosition?!!(a.compareDocumentPosition(s)&16):!1:!1}function pw(a){a=a!=null&&a.ownerDocument!=null&&a.ownerDocument.defaultView!=null?a.ownerDocument.defaultView:window;for(var s=ye(a.document);s instanceof a.HTMLIFrameElement;){try{var d=typeof s.contentWindow.location.href=="string"}catch{d=!1}if(d)a=s.contentWindow;else break;s=ye(a.document)}return s}function wp(a){var s=a&&a.nodeName&&a.nodeName.toLowerCase();return s&&(s==="input"&&(a.type==="text"||a.type==="search"||a.type==="tel"||a.type==="url"||a.type==="password")||s==="textarea"||a.contentEditable==="true")}var Ok=Ui&&"documentMode"in document&&11>=document.documentMode,Js=null,Sp=null,Dc=null,Ap=!1;function gw(a,s,d){var p=d.window===d?d.document:d.nodeType===9?d:d.ownerDocument;Ap||Js==null||Js!==ye(p)||(p=Js,"selectionStart"in p&&wp(p)?p={start:p.selectionStart,end:p.selectionEnd}:(p=(p.ownerDocument&&p.ownerDocument.defaultView||window).getSelection(),p={anchorNode:p.anchorNode,anchorOffset:p.anchorOffset,focusNode:p.focusNode,focusOffset:p.focusOffset}),Dc&&kc(Dc,p)||(Dc=p,p=wf(Sp,"onSelect"),0>=_,w-=_,hi=1<<32-An(s)+w|d<qe?(We=je,je=null):We=je.sibling;var et=X(K,je,W[qe],ae);if(et===null){je===null&&(je=We);break}a&&je&&et.alternate===null&&s(K,je),$=A(et,$,qe),Ze===null?ke=et:Ze.sibling=et,Ze=et,je=We}if(qe===W.length)return d(K,je),Je&&zi(K,qe),ke;if(je===null){for(;qeqe?(We=je,je=null):We=je.sibling;var io=X(K,je,et.value,ae);if(io===null){je===null&&(je=We);break}a&&je&&io.alternate===null&&s(K,je),$=A(io,$,qe),Ze===null?ke=io:Ze.sibling=io,Ze=io,je=We}if(et.done)return d(K,je),Je&&zi(K,qe),ke;if(je===null){for(;!et.done;qe++,et=W.next())et=se(K,et.value,ae),et!==null&&($=A(et,$,qe),Ze===null?ke=et:Ze.sibling=et,Ze=et);return Je&&zi(K,qe),ke}for(je=p(je);!et.done;qe++,et=W.next())et=ee(je,K,qe,et.value,ae),et!==null&&(a&&et.alternate!==null&&je.delete(et.key===null?qe:et.key),$=A(et,$,qe),Ze===null?ke=et:Ze.sibling=et,Ze=et);return a&&je.forEach(function(nR){return s(K,nR)}),Je&&zi(K,qe),ke}function ht(K,$,W,ae){if(typeof W=="object"&&W!==null&&W.type===C&&W.key===null&&(W=W.props.children),typeof W=="object"&&W!==null){switch(W.$$typeof){case b:e:{for(var ke=W.key;$!==null;){if($.key===ke){if(ke=W.type,ke===C){if($.tag===7){d(K,$.sibling),ae=w($,W.props.children),ae.return=K,K=ae;break e}}else if($.elementType===ke||typeof ke=="object"&&ke!==null&&ke.$$typeof===F&&Ko(ke)===$.type){d(K,$.sibling),ae=w($,W.props),zc(ae,W),ae.return=K,K=ae;break e}d(K,$);break}else s(K,$);$=$.sibling}W.type===C?(ae=qo(W.props.children,K.mode,ae,W.key),ae.return=K,K=ae):(ae=Ld(W.type,W.key,W.props,null,K.mode,ae),zc(ae,W),ae.return=K,K=ae)}return _(K);case T:e:{for(ke=W.key;$!==null;){if($.key===ke)if($.tag===4&&$.stateNode.containerInfo===W.containerInfo&&$.stateNode.implementation===W.implementation){d(K,$.sibling),ae=w($,W.children||[]),ae.return=K,K=ae;break e}else{d(K,$);break}else s(K,$);$=$.sibling}ae=Mp(W,K.mode,ae),ae.return=K,K=ae}return _(K);case F:return W=Ko(W),ht(K,$,W,ae)}if(me(W))return Ee(K,$,W,ae);if(V(W)){if(ke=V(W),typeof ke!="function")throw Error(r(150));return W=ke.call(W),Oe(K,$,W,ae)}if(typeof W.then=="function")return ht(K,$,$d(W),ae);if(W.$$typeof===P)return ht(K,$,zd(K,W),ae);Hd(K,W)}return typeof W=="string"&&W!==""||typeof W=="number"||typeof W=="bigint"?(W=""+W,$!==null&&$.tag===6?(d(K,$.sibling),ae=w($,W),ae.return=K,K=ae):(d(K,$),ae=jp(W,K.mode,ae),ae.return=K,K=ae),_(K)):d(K,$)}return function(K,$,W,ae){try{Bc=0;var ke=ht(K,$,W,ae);return sl=null,ke}catch(je){if(je===ol||je===qd)throw je;var Ze=mr(29,je,null,K.mode);return Ze.lanes=ae,Ze.return=K,Ze}finally{}}}var Wo=Bw(!0),zw=Bw(!1),Fa=!1;function qp(a){a.updateQueue={baseState:a.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Gp(a,s){a=a.updateQueue,s.updateQueue===a&&(s.updateQueue={baseState:a.baseState,firstBaseUpdate:a.firstBaseUpdate,lastBaseUpdate:a.lastBaseUpdate,shared:a.shared,callbacks:null})}function qa(a){return{lane:a,tag:0,payload:null,callback:null,next:null}}function Ga(a,s,d){var p=a.updateQueue;if(p===null)return null;if(p=p.shared,(rt&2)!==0){var w=p.pending;return w===null?s.next=s:(s.next=w.next,w.next=s),p.pending=s,s=Od(a),Aw(a,null,d),s}return Rd(a,p,s,d),Od(a)}function Fc(a,s,d){if(s=s.updateQueue,s!==null&&(s=s.shared,(d&4194048)!==0)){var p=s.lanes;p&=a.pendingLanes,d|=p,s.lanes=d,Ue(a,d)}}function $p(a,s){var d=a.updateQueue,p=a.alternate;if(p!==null&&(p=p.updateQueue,d===p)){var w=null,A=null;if(d=d.firstBaseUpdate,d!==null){do{var _={lane:d.lane,tag:d.tag,payload:d.payload,callback:null,next:null};A===null?w=A=_:A=A.next=_,d=d.next}while(d!==null);A===null?w=A=s:A=A.next=s}else w=A=s;d={baseState:p.baseState,firstBaseUpdate:w,lastBaseUpdate:A,shared:p.shared,callbacks:p.callbacks},a.updateQueue=d;return}a=d.lastBaseUpdate,a===null?d.firstBaseUpdate=s:a.next=s,d.lastBaseUpdate=s}var Hp=!1;function qc(){if(Hp){var a=al;if(a!==null)throw a}}function Gc(a,s,d,p){Hp=!1;var w=a.updateQueue;Fa=!1;var A=w.firstBaseUpdate,_=w.lastBaseUpdate,D=w.shared.pending;if(D!==null){w.shared.pending=null;var L=D,Q=L.next;L.next=null,_===null?A=Q:_.next=Q,_=L;var ne=a.alternate;ne!==null&&(ne=ne.updateQueue,D=ne.lastBaseUpdate,D!==_&&(D===null?ne.firstBaseUpdate=Q:D.next=Q,ne.lastBaseUpdate=L))}if(A!==null){var se=w.baseState;_=0,ne=Q=L=null,D=A;do{var X=D.lane&-536870913,ee=X!==D.lane;if(ee?(Ye&X)===X:(p&X)===X){X!==0&&X===il&&(Hp=!0),ne!==null&&(ne=ne.next={lane:0,tag:D.tag,payload:D.payload,callback:null,next:null});e:{var Ee=a,Oe=D;X=s;var ht=d;switch(Oe.tag){case 1:if(Ee=Oe.payload,typeof Ee=="function"){se=Ee.call(ht,se,X);break e}se=Ee;break e;case 3:Ee.flags=Ee.flags&-65537|128;case 0:if(Ee=Oe.payload,X=typeof Ee=="function"?Ee.call(ht,se,X):Ee,X==null)break e;se=g({},se,X);break e;case 2:Fa=!0}}X=D.callback,X!==null&&(a.flags|=64,ee&&(a.flags|=8192),ee=w.callbacks,ee===null?w.callbacks=[X]:ee.push(X))}else ee={lane:X,tag:D.tag,payload:D.payload,callback:D.callback,next:null},ne===null?(Q=ne=ee,L=se):ne=ne.next=ee,_|=X;if(D=D.next,D===null){if(D=w.shared.pending,D===null)break;ee=D,D=ee.next,ee.next=null,w.lastBaseUpdate=ee,w.shared.pending=null}}while(!0);ne===null&&(L=se),w.baseState=L,w.firstBaseUpdate=Q,w.lastBaseUpdate=ne,A===null&&(w.shared.lanes=0),Ya|=_,a.lanes=_,a.memoizedState=se}}function Fw(a,s){if(typeof a!="function")throw Error(r(191,a));a.call(s)}function qw(a,s){var d=a.callbacks;if(d!==null)for(a.callbacks=null,a=0;aA?A:8;var _=z.T,D={};z.T=D,ug(a,!1,s,d);try{var L=w(),Q=z.S;if(Q!==null&&Q(D,L),L!==null&&typeof L=="object"&&typeof L.then=="function"){var ne=Hk(L,p);Vc(a,s,ne,vr(a))}else Vc(a,s,p,vr(a))}catch(se){Vc(a,s,{then:function(){},status:"rejected",reason:se},vr())}finally{Y.p=A,_!==null&&D.types!==null&&(_.types=D.types),z.T=_}}function Qk(){}function lg(a,s,d,p){if(a.tag!==5)throw Error(r(476));var w=b2(a).queue;x2(a,w,s,ce,d===null?Qk:function(){return w2(a),d(p)})}function b2(a){var s=a.memoizedState;if(s!==null)return s;s={memoizedState:ce,baseState:ce,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:$i,lastRenderedState:ce},next:null};var d={};return s.next={memoizedState:d,baseState:d,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:$i,lastRenderedState:d},next:null},a.memoizedState=s,a=a.alternate,a!==null&&(a.memoizedState=s),s}function w2(a){var s=b2(a);s.next===null&&(s=a.alternate.memoizedState),Vc(a,s.next.queue,{},vr())}function cg(){return Tn(cu)}function S2(){return Wt().memoizedState}function A2(){return Wt().memoizedState}function Xk(a){for(var s=a.return;s!==null;){switch(s.tag){case 24:case 3:var d=vr();a=qa(d);var p=Ga(s,a,d);p!==null&&(tr(p,s,d),Fc(p,s,d)),s={cache:Up()},a.payload=s;return}s=s.return}}function Zk(a,s,d){var p=vr();d={lane:p,revertLane:0,gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},tf(a)?T2(s,d):(d=Np(a,s,d,p),d!==null&&(tr(d,a,p),E2(d,s,p)))}function C2(a,s,d){var p=vr();Vc(a,s,d,p)}function Vc(a,s,d,p){var w={lane:p,revertLane:0,gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null};if(tf(a))T2(s,w);else{var A=a.alternate;if(a.lanes===0&&(A===null||A.lanes===0)&&(A=s.lastRenderedReducer,A!==null))try{var _=s.lastRenderedState,D=A(_,d);if(w.hasEagerState=!0,w.eagerState=D,fr(D,_))return Rd(a,s,w,0),yt===null&&Dd(),!1}catch{}finally{}if(d=Np(a,s,w,p),d!==null)return tr(d,a,p),E2(d,s,p),!0}return!1}function ug(a,s,d,p){if(p={lane:2,revertLane:qg(),gesture:null,action:p,hasEagerState:!1,eagerState:null,next:null},tf(a)){if(s)throw Error(r(479))}else s=Np(a,d,p,2),s!==null&&tr(s,a,2)}function tf(a){var s=a.alternate;return a===ze||s!==null&&s===ze}function T2(a,s){cl=Yd=!0;var d=a.pending;d===null?s.next=s:(s.next=d.next,d.next=s),a.pending=s}function E2(a,s,d){if((d&4194048)!==0){var p=s.lanes;p&=a.pendingLanes,d|=p,s.lanes=d,Ue(a,d)}}var Kc={readContext:Tn,use:Qd,useCallback:zt,useContext:zt,useEffect:zt,useImperativeHandle:zt,useLayoutEffect:zt,useInsertionEffect:zt,useMemo:zt,useReducer:zt,useRef:zt,useState:zt,useDebugValue:zt,useDeferredValue:zt,useTransition:zt,useSyncExternalStore:zt,useId:zt,useHostTransitionStatus:zt,useFormState:zt,useActionState:zt,useOptimistic:zt,useMemoCache:zt,useCacheRefresh:zt};Kc.useEffectEvent=zt;var N2={readContext:Tn,use:Qd,useCallback:function(a,s){return Fn().memoizedState=[a,s===void 0?null:s],a},useContext:Tn,useEffect:u2,useImperativeHandle:function(a,s,d){d=d!=null?d.concat([a]):null,Zd(4194308,4,h2.bind(null,s,a),d)},useLayoutEffect:function(a,s){return Zd(4194308,4,a,s)},useInsertionEffect:function(a,s){Zd(4,2,a,s)},useMemo:function(a,s){var d=Fn();s=s===void 0?null:s;var p=a();if(Jo){Sn(!0);try{a()}finally{Sn(!1)}}return d.memoizedState=[p,s],p},useReducer:function(a,s,d){var p=Fn();if(d!==void 0){var w=d(s);if(Jo){Sn(!0);try{d(s)}finally{Sn(!1)}}}else w=s;return p.memoizedState=p.baseState=w,a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:a,lastRenderedState:w},p.queue=a,a=a.dispatch=Zk.bind(null,ze,a),[p.memoizedState,a]},useRef:function(a){var s=Fn();return a={current:a},s.memoizedState=a},useState:function(a){a=rg(a);var s=a.queue,d=C2.bind(null,ze,s);return s.dispatch=d,[a.memoizedState,d]},useDebugValue:og,useDeferredValue:function(a,s){var d=Fn();return sg(d,a,s)},useTransition:function(){var a=rg(!1);return a=x2.bind(null,ze,a.queue,!0,!1),Fn().memoizedState=a,[!1,a]},useSyncExternalStore:function(a,s,d){var p=ze,w=Fn();if(Je){if(d===void 0)throw Error(r(407));d=d()}else{if(d=s(),yt===null)throw Error(r(349));(Ye&127)!==0||Yw(p,s,d)}w.memoizedState=d;var A={value:d,getSnapshot:s};return w.queue=A,u2(Jw.bind(null,p,A,a),[a]),p.flags|=2048,dl(9,{destroy:void 0},Ww.bind(null,p,A,d,s),null),d},useId:function(){var a=Fn(),s=yt.identifierPrefix;if(Je){var d=pi,p=hi;d=(p&~(1<<32-An(p)-1)).toString(32)+d,s="_"+s+"R_"+d,d=Wd++,0<\/script>",A=A.removeChild(A.firstChild);break;case"select":A=typeof p.is=="string"?_.createElement("select",{is:p.is}):_.createElement("select"),p.multiple?A.multiple=!0:p.size&&(A.size=p.size);break;default:A=typeof p.is=="string"?_.createElement(w,{is:p.is}):_.createElement(w)}}A[Dt]=s,A[In]=p;e:for(_=s.child;_!==null;){if(_.tag===5||_.tag===6)A.appendChild(_.stateNode);else if(_.tag!==4&&_.tag!==27&&_.child!==null){_.child.return=_,_=_.child;continue}if(_===s)break e;for(;_.sibling===null;){if(_.return===null||_.return===s)break e;_=_.return}_.sibling.return=_.return,_=_.sibling}s.stateNode=A;e:switch(Nn(A,w,p),w){case"button":case"input":case"select":case"textarea":p=!!p.autoFocus;break e;case"img":p=!0;break e;default:p=!1}p&&Vi(s)}}return Et(s),Cg(s,s.type,a===null?null:a.memoizedProps,s.pendingProps,d),null;case 6:if(a&&s.stateNode!=null)a.memoizedProps!==p&&Vi(s);else{if(typeof p!="string"&&s.stateNode===null)throw Error(r(166));if(a=Pe.current,nl(s)){if(a=s.stateNode,d=s.memoizedProps,p=null,w=Cn,w!==null)switch(w.tag){case 27:case 5:p=w.memoizedProps}a[Dt]=s,a=!!(a.nodeValue===d||p!==null&&p.suppressHydrationWarning===!0||VS(a.nodeValue,d)),a||Ba(s,!0)}else a=Sf(a).createTextNode(p),a[Dt]=s,s.stateNode=a}return Et(s),null;case 31:if(d=s.memoizedState,a===null||a.memoizedState!==null){if(p=nl(s),d!==null){if(a===null){if(!p)throw Error(r(318));if(a=s.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(r(557));a[Dt]=s}else Go(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;Et(s),a=!1}else d=Dp(),a!==null&&a.memoizedState!==null&&(a.memoizedState.hydrationErrors=d),a=!0;if(!a)return s.flags&256?(pr(s),s):(pr(s),null);if((s.flags&128)!==0)throw Error(r(558))}return Et(s),null;case 13:if(p=s.memoizedState,a===null||a.memoizedState!==null&&a.memoizedState.dehydrated!==null){if(w=nl(s),p!==null&&p.dehydrated!==null){if(a===null){if(!w)throw Error(r(318));if(w=s.memoizedState,w=w!==null?w.dehydrated:null,!w)throw Error(r(317));w[Dt]=s}else Go(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;Et(s),w=!1}else w=Dp(),a!==null&&a.memoizedState!==null&&(a.memoizedState.hydrationErrors=w),w=!0;if(!w)return s.flags&256?(pr(s),s):(pr(s),null)}return pr(s),(s.flags&128)!==0?(s.lanes=d,s):(d=p!==null,a=a!==null&&a.memoizedState!==null,d&&(p=s.child,w=null,p.alternate!==null&&p.alternate.memoizedState!==null&&p.alternate.memoizedState.cachePool!==null&&(w=p.alternate.memoizedState.cachePool.pool),A=null,p.memoizedState!==null&&p.memoizedState.cachePool!==null&&(A=p.memoizedState.cachePool.pool),A!==w&&(p.flags|=2048)),d!==a&&d&&(s.child.flags|=8192),sf(s,s.updateQueue),Et(s),null);case 4:return re(),a===null&&Vg(s.stateNode.containerInfo),Et(s),null;case 10:return qi(s.type),Et(s),null;case 19:if(te(Yt),p=s.memoizedState,p===null)return Et(s),null;if(w=(s.flags&128)!==0,A=p.rendering,A===null)if(w)Wc(p,!1);else{if(Ft!==0||a!==null&&(a.flags&128)!==0)for(a=s.child;a!==null;){if(A=Kd(a),A!==null){for(s.flags|=128,Wc(p,!1),a=A.updateQueue,s.updateQueue=a,sf(s,a),s.subtreeFlags=0,a=d,d=s.child;d!==null;)Cw(d,a),d=d.sibling;return ue(Yt,Yt.current&1|2),Je&&zi(s,p.treeForkCount),s.child}a=a.sibling}p.tail!==null&&Kt()>ff&&(s.flags|=128,w=!0,Wc(p,!1),s.lanes=4194304)}else{if(!w)if(a=Kd(A),a!==null){if(s.flags|=128,w=!0,a=a.updateQueue,s.updateQueue=a,sf(s,a),Wc(p,!0),p.tail===null&&p.tailMode==="hidden"&&!A.alternate&&!Je)return Et(s),null}else 2*Kt()-p.renderingStartTime>ff&&d!==536870912&&(s.flags|=128,w=!0,Wc(p,!1),s.lanes=4194304);p.isBackwards?(A.sibling=s.child,s.child=A):(a=p.last,a!==null?a.sibling=A:s.child=A,p.last=A)}return p.tail!==null?(a=p.tail,p.rendering=a,p.tail=a.sibling,p.renderingStartTime=Kt(),a.sibling=null,d=Yt.current,ue(Yt,w?d&1|2:d&1),Je&&zi(s,p.treeForkCount),a):(Et(s),null);case 22:case 23:return pr(s),Kp(),p=s.memoizedState!==null,a!==null?a.memoizedState!==null!==p&&(s.flags|=8192):p&&(s.flags|=8192),p?(d&536870912)!==0&&(s.flags&128)===0&&(Et(s),s.subtreeFlags&6&&(s.flags|=8192)):Et(s),d=s.updateQueue,d!==null&&sf(s,d.retryQueue),d=null,a!==null&&a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(d=a.memoizedState.cachePool.pool),p=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(p=s.memoizedState.cachePool.pool),p!==d&&(s.flags|=2048),a!==null&&te(Vo),null;case 24:return d=null,a!==null&&(d=a.memoizedState.cache),s.memoizedState.cache!==d&&(s.flags|=2048),qi(Zt),Et(s),null;case 25:return null;case 30:return null}throw Error(r(156,s.tag))}function iD(a,s){switch(Ip(s),s.tag){case 1:return a=s.flags,a&65536?(s.flags=a&-65537|128,s):null;case 3:return qi(Zt),re(),a=s.flags,(a&65536)!==0&&(a&128)===0?(s.flags=a&-65537|128,s):null;case 26:case 27:case 5:return Fe(s),null;case 31:if(s.memoizedState!==null){if(pr(s),s.alternate===null)throw Error(r(340));Go()}return a=s.flags,a&65536?(s.flags=a&-65537|128,s):null;case 13:if(pr(s),a=s.memoizedState,a!==null&&a.dehydrated!==null){if(s.alternate===null)throw Error(r(340));Go()}return a=s.flags,a&65536?(s.flags=a&-65537|128,s):null;case 19:return te(Yt),null;case 4:return re(),null;case 10:return qi(s.type),null;case 22:case 23:return pr(s),Kp(),a!==null&&te(Vo),a=s.flags,a&65536?(s.flags=a&-65537|128,s):null;case 24:return qi(Zt),null;case 25:return null;default:return null}}function Q2(a,s){switch(Ip(s),s.tag){case 3:qi(Zt),re();break;case 26:case 27:case 5:Fe(s);break;case 4:re();break;case 31:s.memoizedState!==null&&pr(s);break;case 13:pr(s);break;case 19:te(Yt);break;case 10:qi(s.type);break;case 22:case 23:pr(s),Kp(),a!==null&&te(Vo);break;case 24:qi(Zt)}}function Jc(a,s){try{var d=s.updateQueue,p=d!==null?d.lastEffect:null;if(p!==null){var w=p.next;d=w;do{if((d.tag&a)===a){p=void 0;var A=d.create,_=d.inst;p=A(),_.destroy=p}d=d.next}while(d!==w)}}catch(D){ct(s,s.return,D)}}function Va(a,s,d){try{var p=s.updateQueue,w=p!==null?p.lastEffect:null;if(w!==null){var A=w.next;p=A;do{if((p.tag&a)===a){var _=p.inst,D=_.destroy;if(D!==void 0){_.destroy=void 0,w=s;var L=d,Q=D;try{Q()}catch(ne){ct(w,L,ne)}}}p=p.next}while(p!==A)}}catch(ne){ct(s,s.return,ne)}}function X2(a){var s=a.updateQueue;if(s!==null){var d=a.stateNode;try{qw(s,d)}catch(p){ct(a,a.return,p)}}}function Z2(a,s,d){d.props=Qo(a.type,a.memoizedProps),d.state=a.memoizedState;try{d.componentWillUnmount()}catch(p){ct(a,s,p)}}function Qc(a,s){try{var d=a.ref;if(d!==null){switch(a.tag){case 26:case 27:case 5:var p=a.stateNode;break;case 30:p=a.stateNode;break;default:p=a.stateNode}typeof d=="function"?a.refCleanup=d(p):d.current=p}}catch(w){ct(a,s,w)}}function gi(a,s){var d=a.ref,p=a.refCleanup;if(d!==null)if(typeof p=="function")try{p()}catch(w){ct(a,s,w)}finally{a.refCleanup=null,a=a.alternate,a!=null&&(a.refCleanup=null)}else if(typeof d=="function")try{d(null)}catch(w){ct(a,s,w)}else d.current=null}function eS(a){var s=a.type,d=a.memoizedProps,p=a.stateNode;try{e:switch(s){case"button":case"input":case"select":case"textarea":d.autoFocus&&p.focus();break e;case"img":d.src?p.src=d.src:d.srcSet&&(p.srcset=d.srcSet)}}catch(w){ct(a,a.return,w)}}function Tg(a,s,d){try{var p=a.stateNode;ED(p,a.type,d,s),p[In]=s}catch(w){ct(a,a.return,w)}}function tS(a){return a.tag===5||a.tag===3||a.tag===26||a.tag===27&&Za(a.type)||a.tag===4}function Eg(a){e:for(;;){for(;a.sibling===null;){if(a.return===null||tS(a.return))return null;a=a.return}for(a.sibling.return=a.return,a=a.sibling;a.tag!==5&&a.tag!==6&&a.tag!==18;){if(a.tag===27&&Za(a.type)||a.flags&2||a.child===null||a.tag===4)continue e;a.child.return=a,a=a.child}if(!(a.flags&2))return a.stateNode}}function Ng(a,s,d){var p=a.tag;if(p===5||p===6)a=a.stateNode,s?(d.nodeType===9?d.body:d.nodeName==="HTML"?d.ownerDocument.body:d).insertBefore(a,s):(s=d.nodeType===9?d.body:d.nodeName==="HTML"?d.ownerDocument.body:d,s.appendChild(a),d=d._reactRootContainer,d!=null||s.onclick!==null||(s.onclick=Li));else if(p!==4&&(p===27&&Za(a.type)&&(d=a.stateNode,s=null),a=a.child,a!==null))for(Ng(a,s,d),a=a.sibling;a!==null;)Ng(a,s,d),a=a.sibling}function lf(a,s,d){var p=a.tag;if(p===5||p===6)a=a.stateNode,s?d.insertBefore(a,s):d.appendChild(a);else if(p!==4&&(p===27&&Za(a.type)&&(d=a.stateNode),a=a.child,a!==null))for(lf(a,s,d),a=a.sibling;a!==null;)lf(a,s,d),a=a.sibling}function nS(a){var s=a.stateNode,d=a.memoizedProps;try{for(var p=a.type,w=s.attributes;w.length;)s.removeAttributeNode(w[0]);Nn(s,p,d),s[Dt]=a,s[In]=d}catch(A){ct(a,a.return,A)}}var Ki=!1,nn=!1,_g=!1,rS=typeof WeakSet=="function"?WeakSet:Set,yn=null;function aD(a,s){if(a=a.containerInfo,Wg=jf,a=pw(a),wp(a)){if("selectionStart"in a)var d={start:a.selectionStart,end:a.selectionEnd};else e:{d=(d=a.ownerDocument)&&d.defaultView||window;var p=d.getSelection&&d.getSelection();if(p&&p.rangeCount!==0){d=p.anchorNode;var w=p.anchorOffset,A=p.focusNode;p=p.focusOffset;try{d.nodeType,A.nodeType}catch{d=null;break e}var _=0,D=-1,L=-1,Q=0,ne=0,se=a,X=null;t:for(;;){for(var ee;se!==d||w!==0&&se.nodeType!==3||(D=_+w),se!==A||p!==0&&se.nodeType!==3||(L=_+p),se.nodeType===3&&(_+=se.nodeValue.length),(ee=se.firstChild)!==null;)X=se,se=ee;for(;;){if(se===a)break t;if(X===d&&++Q===w&&(D=_),X===A&&++ne===p&&(L=_),(ee=se.nextSibling)!==null)break;se=X,X=se.parentNode}se=ee}d=D===-1||L===-1?null:{start:D,end:L}}else d=null}d=d||{start:0,end:0}}else d=null;for(Jg={focusedElem:a,selectionRange:d},jf=!1,yn=s;yn!==null;)if(s=yn,a=s.child,(s.subtreeFlags&1028)!==0&&a!==null)a.return=s,yn=a;else for(;yn!==null;){switch(s=yn,A=s.alternate,a=s.flags,s.tag){case 0:if((a&4)!==0&&(a=s.updateQueue,a=a!==null?a.events:null,a!==null))for(d=0;d title"))),Nn(A,p,d),A[Dt]=a,Xt(A),p=A;break e;case"link":var _=cA("link","href",w).get(p+(d.href||""));if(_){for(var D=0;D<_.length;D++)if(A=_[D],A.getAttribute("href")===(d.href==null||d.href===""?null:d.href)&&A.getAttribute("rel")===(d.rel==null?null:d.rel)&&A.getAttribute("title")===(d.title==null?null:d.title)&&A.getAttribute("crossorigin")===(d.crossOrigin==null?null:d.crossOrigin)){_.splice(D,1);break t}}A=w.createElement(p),Nn(A,p,d),w.head.appendChild(A);break;case"meta":if(_=cA("meta","content",w).get(p+(d.content||""))){for(D=0;D<_.length;D++)if(A=_[D],A.getAttribute("content")===(d.content==null?null:""+d.content)&&A.getAttribute("name")===(d.name==null?null:d.name)&&A.getAttribute("property")===(d.property==null?null:d.property)&&A.getAttribute("http-equiv")===(d.httpEquiv==null?null:d.httpEquiv)&&A.getAttribute("charset")===(d.charSet==null?null:d.charSet)){_.splice(D,1);break t}}A=w.createElement(p),Nn(A,p,d),w.head.appendChild(A);break;default:throw Error(r(468,p))}A[Dt]=a,Xt(A),p=A}a.stateNode=p}else uA(w,a.type,a.stateNode);else a.stateNode=lA(w,p,a.memoizedProps);else A!==p?(A===null?d.stateNode!==null&&(d=d.stateNode,d.parentNode.removeChild(d)):A.count--,p===null?uA(w,a.type,a.stateNode):lA(w,p,a.memoizedProps)):p===null&&a.stateNode!==null&&Tg(a,a.memoizedProps,d.memoizedProps)}break;case 27:Xn(s,a),Zn(a),p&512&&(nn||d===null||gi(d,d.return)),d!==null&&p&4&&Tg(a,a.memoizedProps,d.memoizedProps);break;case 5:if(Xn(s,a),Zn(a),p&512&&(nn||d===null||gi(d,d.return)),a.flags&32){w=a.stateNode;try{Vs(w,"")}catch(Ee){ct(a,a.return,Ee)}}p&4&&a.stateNode!=null&&(w=a.memoizedProps,Tg(a,w,d!==null?d.memoizedProps:w)),p&1024&&(_g=!0);break;case 6:if(Xn(s,a),Zn(a),p&4){if(a.stateNode===null)throw Error(r(162));p=a.memoizedProps,d=a.stateNode;try{d.nodeValue=p}catch(Ee){ct(a,a.return,Ee)}}break;case 3:if(Tf=null,w=ei,ei=Af(s.containerInfo),Xn(s,a),ei=w,Zn(a),p&4&&d!==null&&d.memoizedState.isDehydrated)try{Al(s.containerInfo)}catch(Ee){ct(a,a.return,Ee)}_g&&(_g=!1,uS(a));break;case 4:p=ei,ei=Af(a.stateNode.containerInfo),Xn(s,a),Zn(a),ei=p;break;case 12:Xn(s,a),Zn(a);break;case 31:Xn(s,a),Zn(a),p&4&&(p=a.updateQueue,p!==null&&(a.updateQueue=null,cf(a,p)));break;case 13:Xn(s,a),Zn(a),a.child.flags&8192&&a.memoizedState!==null!=(d!==null&&d.memoizedState!==null)&&(df=Kt()),p&4&&(p=a.updateQueue,p!==null&&(a.updateQueue=null,cf(a,p)));break;case 22:w=a.memoizedState!==null;var L=d!==null&&d.memoizedState!==null,Q=Ki,ne=nn;if(Ki=Q||w,nn=ne||L,Xn(s,a),nn=ne,Ki=Q,Zn(a),p&8192)e:for(s=a.stateNode,s._visibility=w?s._visibility&-2:s._visibility|1,w&&(d===null||L||Ki||nn||Xo(a)),d=null,s=a;;){if(s.tag===5||s.tag===26){if(d===null){L=d=s;try{if(A=L.stateNode,w)_=A.style,typeof _.setProperty=="function"?_.setProperty("display","none","important"):_.display="none";else{D=L.stateNode;var se=L.memoizedProps.style,X=se!=null&&se.hasOwnProperty("display")?se.display:null;D.style.display=X==null||typeof X=="boolean"?"":(""+X).trim()}}catch(Ee){ct(L,L.return,Ee)}}}else if(s.tag===6){if(d===null){L=s;try{L.stateNode.nodeValue=w?"":L.memoizedProps}catch(Ee){ct(L,L.return,Ee)}}}else if(s.tag===18){if(d===null){L=s;try{var ee=L.stateNode;w?ZS(ee,!0):ZS(L.stateNode,!1)}catch(Ee){ct(L,L.return,Ee)}}}else if((s.tag!==22&&s.tag!==23||s.memoizedState===null||s===a)&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===a)break e;for(;s.sibling===null;){if(s.return===null||s.return===a)break e;d===s&&(d=null),s=s.return}d===s&&(d=null),s.sibling.return=s.return,s=s.sibling}p&4&&(p=a.updateQueue,p!==null&&(d=p.retryQueue,d!==null&&(p.retryQueue=null,cf(a,d))));break;case 19:Xn(s,a),Zn(a),p&4&&(p=a.updateQueue,p!==null&&(a.updateQueue=null,cf(a,p)));break;case 30:break;case 21:break;default:Xn(s,a),Zn(a)}}function Zn(a){var s=a.flags;if(s&2){try{for(var d,p=a.return;p!==null;){if(tS(p)){d=p;break}p=p.return}if(d==null)throw Error(r(160));switch(d.tag){case 27:var w=d.stateNode,A=Eg(a);lf(a,A,w);break;case 5:var _=d.stateNode;d.flags&32&&(Vs(_,""),d.flags&=-33);var D=Eg(a);lf(a,D,_);break;case 3:case 4:var L=d.stateNode.containerInfo,Q=Eg(a);Ng(a,Q,L);break;default:throw Error(r(161))}}catch(ne){ct(a,a.return,ne)}a.flags&=-3}s&4096&&(a.flags&=-4097)}function uS(a){if(a.subtreeFlags&1024)for(a=a.child;a!==null;){var s=a;uS(s),s.tag===5&&s.flags&1024&&s.stateNode.reset(),a=a.sibling}}function Wi(a,s){if(s.subtreeFlags&8772)for(s=s.child;s!==null;)iS(a,s.alternate,s),s=s.sibling}function Xo(a){for(a=a.child;a!==null;){var s=a;switch(s.tag){case 0:case 11:case 14:case 15:Va(4,s,s.return),Xo(s);break;case 1:gi(s,s.return);var d=s.stateNode;typeof d.componentWillUnmount=="function"&&Z2(s,s.return,d),Xo(s);break;case 27:ou(s.stateNode);case 26:case 5:gi(s,s.return),Xo(s);break;case 22:s.memoizedState===null&&Xo(s);break;case 30:Xo(s);break;default:Xo(s)}a=a.sibling}}function Ji(a,s,d){for(d=d&&(s.subtreeFlags&8772)!==0,s=s.child;s!==null;){var p=s.alternate,w=a,A=s,_=A.flags;switch(A.tag){case 0:case 11:case 15:Ji(w,A,d),Jc(4,A);break;case 1:if(Ji(w,A,d),p=A,w=p.stateNode,typeof w.componentDidMount=="function")try{w.componentDidMount()}catch(Q){ct(p,p.return,Q)}if(p=A,w=p.updateQueue,w!==null){var D=p.stateNode;try{var L=w.shared.hiddenCallbacks;if(L!==null)for(w.shared.hiddenCallbacks=null,w=0;wht&&(_=ht,ht=Oe,Oe=_);var K=mw(D,Oe),$=mw(D,ht);if(K&&$&&(ee.rangeCount!==1||ee.anchorNode!==K.node||ee.anchorOffset!==K.offset||ee.focusNode!==$.node||ee.focusOffset!==$.offset)){var W=se.createRange();W.setStart(K.node,K.offset),ee.removeAllRanges(),Oe>ht?(ee.addRange(W),ee.extend($.node,$.offset)):(W.setEnd($.node,$.offset),ee.addRange(W))}}}}for(se=[],ee=D;ee=ee.parentNode;)ee.nodeType===1&&se.push({element:ee,left:ee.scrollLeft,top:ee.scrollTop});for(typeof D.focus=="function"&&D.focus(),D=0;Dd?32:d,z.T=null,d=Rg,Rg=null;var A=Ja,_=Xi;if(ln=0,gl=Ja=null,Xi=0,(rt&6)!==0)throw Error(r(331));var D=rt;if(rt|=4,hS(A.current),dS(A,A.current,_,d),rt=D,ru(0,!1),Qt&&typeof Qt.onPostCommitFiberRoot=="function")try{Qt.onPostCommitFiberRoot(Qr,A)}catch{}return!0}finally{Y.p=w,z.T=p,IS(a,s)}}function DS(a,s,d){s=jr(d,s),s=hg(a.stateNode,s,2),a=Ga(a,s,2),a!==null&&(Bt(a,2),yi(a))}function ct(a,s,d){if(a.tag===3)DS(a,a,d);else for(;s!==null;){if(s.tag===3){DS(s,a,d);break}else if(s.tag===1){var p=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof p.componentDidCatch=="function"&&(Wa===null||!Wa.has(p))){a=jr(d,a),d=R2(2),p=Ga(s,d,2),p!==null&&(O2(d,p,s,a),Bt(p,2),yi(p));break}}s=s.return}}function Bg(a,s,d){var p=a.pingCache;if(p===null){p=a.pingCache=new lD;var w=new Set;p.set(s,w)}else w=p.get(s),w===void 0&&(w=new Set,p.set(s,w));w.has(d)||(Pg=!0,w.add(d),a=mD.bind(null,a,s,d),s.then(a,a))}function mD(a,s,d){var p=a.pingCache;p!==null&&p.delete(s),a.pingedLanes|=a.suspendedLanes&d,a.warmLanes&=~d,yt===a&&(Ye&d)===d&&(Ft===4||Ft===3&&(Ye&62914560)===Ye&&300>Kt()-df?(rt&2)===0&&yl(a,0):Ig|=d,pl===Ye&&(pl=0)),yi(a)}function RS(a,s){s===0&&(s=Ro()),a=Fo(a,s),a!==null&&(Bt(a,s),yi(a))}function hD(a){var s=a.memoizedState,d=0;s!==null&&(d=s.retryLane),RS(a,d)}function pD(a,s){var d=0;switch(a.tag){case 31:case 13:var p=a.stateNode,w=a.memoizedState;w!==null&&(d=w.retryLane);break;case 19:p=a.stateNode;break;case 22:p=a.stateNode._retryCache;break;default:throw Error(r(314))}p!==null&&p.delete(s),RS(a,d)}function gD(a,s){return Jr(a,s)}var vf=null,xl=null,zg=!1,xf=!1,Fg=!1,Xa=0;function yi(a){a!==xl&&a.next===null&&(xl===null?vf=xl=a:xl=xl.next=a),xf=!0,zg||(zg=!0,vD())}function ru(a,s){if(!Fg&&xf){Fg=!0;do for(var d=!1,p=vf;p!==null;){if(a!==0){var w=p.pendingLanes;if(w===0)var A=0;else{var _=p.suspendedLanes,D=p.pingedLanes;A=(1<<31-An(42|a)+1)-1,A&=w&~(_&~D),A=A&201326741?A&201326741|1:A?A|2:0}A!==0&&(d=!0,BS(p,A))}else A=Ye,A=Ma(p,p===yt?A:0,p.cancelPendingCommit!==null||p.timeoutHandle!==-1),(A&3)===0||fi(p,A)||(d=!0,BS(p,A));p=p.next}while(d);Fg=!1}}function yD(){OS()}function OS(){xf=zg=!1;var a=0;Xa!==0&&_D()&&(a=Xa);for(var s=Kt(),d=null,p=vf;p!==null;){var w=p.next,A=LS(p,s);A===0?(p.next=null,d===null?vf=w:d.next=w,w===null&&(xl=d)):(d=p,(a!==0||(A&3)!==0)&&(xf=!0)),p=w}ln!==0&&ln!==5||ru(a),Xa!==0&&(Xa=0)}function LS(a,s){for(var d=a.suspendedLanes,p=a.pingedLanes,w=a.expirationTimes,A=a.pendingLanes&-62914561;0D)break;var ne=L.transferSize,se=L.initiatorType;ne&&KS(se)&&(L=L.responseEnd,_+=ne*(L"u"?null:document;function aA(a,s,d){var p=bl;if(p&&typeof s=="string"&&s){var w=De(s);w='link[rel="'+a+'"][href="'+w+'"]',typeof d=="string"&&(w+='[crossorigin="'+d+'"]'),iA.has(w)||(iA.add(w),a={rel:a,crossOrigin:d,href:s},p.querySelector(w)===null&&(s=p.createElement("link"),Nn(s,"link",a),Xt(s),p.head.appendChild(s)))}}function LD(a){Zi.D(a),aA("dns-prefetch",a,null)}function UD(a,s){Zi.C(a,s),aA("preconnect",a,s)}function BD(a,s,d){Zi.L(a,s,d);var p=bl;if(p&&a&&s){var w='link[rel="preload"][as="'+De(s)+'"]';s==="image"&&d&&d.imageSrcSet?(w+='[imagesrcset="'+De(d.imageSrcSet)+'"]',typeof d.imageSizes=="string"&&(w+='[imagesizes="'+De(d.imageSizes)+'"]')):w+='[href="'+De(a)+'"]';var A=w;switch(s){case"style":A=wl(a);break;case"script":A=Sl(a)}Rr.has(A)||(a=g({rel:"preload",href:s==="image"&&d&&d.imageSrcSet?void 0:a,as:s},d),Rr.set(A,a),p.querySelector(w)!==null||s==="style"&&p.querySelector(su(A))||s==="script"&&p.querySelector(lu(A))||(s=p.createElement("link"),Nn(s,"link",a),Xt(s),p.head.appendChild(s)))}}function zD(a,s){Zi.m(a,s);var d=bl;if(d&&a){var p=s&&typeof s.as=="string"?s.as:"script",w='link[rel="modulepreload"][as="'+De(p)+'"][href="'+De(a)+'"]',A=w;switch(p){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":A=Sl(a)}if(!Rr.has(A)&&(a=g({rel:"modulepreload",href:a},s),Rr.set(A,a),d.querySelector(w)===null)){switch(p){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(d.querySelector(lu(A)))return}p=d.createElement("link"),Nn(p,"link",a),Xt(p),d.head.appendChild(p)}}}function FD(a,s,d){Zi.S(a,s,d);var p=bl;if(p&&a){var w=Da(p).hoistableStyles,A=wl(a);s=s||"default";var _=w.get(A);if(!_){var D={loading:0,preload:null};if(_=p.querySelector(su(A)))D.loading=5;else{a=g({rel:"stylesheet",href:a,"data-precedence":s},d),(d=Rr.get(A))&&r0(a,d);var L=_=p.createElement("link");Xt(L),Nn(L,"link",a),L._p=new Promise(function(Q,ne){L.onload=Q,L.onerror=ne}),L.addEventListener("load",function(){D.loading|=1}),L.addEventListener("error",function(){D.loading|=2}),D.loading|=4,Cf(_,s,p)}_={type:"stylesheet",instance:_,count:1,state:D},w.set(A,_)}}}function qD(a,s){Zi.X(a,s);var d=bl;if(d&&a){var p=Da(d).hoistableScripts,w=Sl(a),A=p.get(w);A||(A=d.querySelector(lu(w)),A||(a=g({src:a,async:!0},s),(s=Rr.get(w))&&i0(a,s),A=d.createElement("script"),Xt(A),Nn(A,"link",a),d.head.appendChild(A)),A={type:"script",instance:A,count:1,state:null},p.set(w,A))}}function GD(a,s){Zi.M(a,s);var d=bl;if(d&&a){var p=Da(d).hoistableScripts,w=Sl(a),A=p.get(w);A||(A=d.querySelector(lu(w)),A||(a=g({src:a,async:!0,type:"module"},s),(s=Rr.get(w))&&i0(a,s),A=d.createElement("script"),Xt(A),Nn(A,"link",a),d.head.appendChild(A)),A={type:"script",instance:A,count:1,state:null},p.set(w,A))}}function oA(a,s,d,p){var w=(w=Pe.current)?Af(w):null;if(!w)throw Error(r(446));switch(a){case"meta":case"title":return null;case"style":return typeof d.precedence=="string"&&typeof d.href=="string"?(s=wl(d.href),d=Da(w).hoistableStyles,p=d.get(s),p||(p={type:"style",instance:null,count:0,state:null},d.set(s,p)),p):{type:"void",instance:null,count:0,state:null};case"link":if(d.rel==="stylesheet"&&typeof d.href=="string"&&typeof d.precedence=="string"){a=wl(d.href);var A=Da(w).hoistableStyles,_=A.get(a);if(_||(w=w.ownerDocument||w,_={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},A.set(a,_),(A=w.querySelector(su(a)))&&!A._p&&(_.instance=A,_.state.loading=5),Rr.has(a)||(d={rel:"preload",as:"style",href:d.href,crossOrigin:d.crossOrigin,integrity:d.integrity,media:d.media,hrefLang:d.hrefLang,referrerPolicy:d.referrerPolicy},Rr.set(a,d),A||$D(w,a,d,_.state))),s&&p===null)throw Error(r(528,""));return _}if(s&&p!==null)throw Error(r(529,""));return null;case"script":return s=d.async,d=d.src,typeof d=="string"&&s&&typeof s!="function"&&typeof s!="symbol"?(s=Sl(d),d=Da(w).hoistableScripts,p=d.get(s),p||(p={type:"script",instance:null,count:0,state:null},d.set(s,p)),p):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,a))}}function wl(a){return'href="'+De(a)+'"'}function su(a){return'link[rel="stylesheet"]['+a+"]"}function sA(a){return g({},a,{"data-precedence":a.precedence,precedence:null})}function $D(a,s,d,p){a.querySelector('link[rel="preload"][as="style"]['+s+"]")?p.loading=1:(s=a.createElement("link"),p.preload=s,s.addEventListener("load",function(){return p.loading|=1}),s.addEventListener("error",function(){return p.loading|=2}),Nn(s,"link",d),Xt(s),a.head.appendChild(s))}function Sl(a){return'[src="'+De(a)+'"]'}function lu(a){return"script[async]"+a}function lA(a,s,d){if(s.count++,s.instance===null)switch(s.type){case"style":var p=a.querySelector('style[data-href~="'+De(d.href)+'"]');if(p)return s.instance=p,Xt(p),p;var w=g({},d,{"data-href":d.href,"data-precedence":d.precedence,href:null,precedence:null});return p=(a.ownerDocument||a).createElement("style"),Xt(p),Nn(p,"style",w),Cf(p,d.precedence,a),s.instance=p;case"stylesheet":w=wl(d.href);var A=a.querySelector(su(w));if(A)return s.state.loading|=4,s.instance=A,Xt(A),A;p=sA(d),(w=Rr.get(w))&&r0(p,w),A=(a.ownerDocument||a).createElement("link"),Xt(A);var _=A;return _._p=new Promise(function(D,L){_.onload=D,_.onerror=L}),Nn(A,"link",p),s.state.loading|=4,Cf(A,d.precedence,a),s.instance=A;case"script":return A=Sl(d.src),(w=a.querySelector(lu(A)))?(s.instance=w,Xt(w),w):(p=d,(w=Rr.get(A))&&(p=g({},d),i0(p,w)),a=a.ownerDocument||a,w=a.createElement("script"),Xt(w),Nn(w,"link",p),a.head.appendChild(w),s.instance=w);case"void":return null;default:throw Error(r(443,s.type))}else s.type==="stylesheet"&&(s.state.loading&4)===0&&(p=s.instance,s.state.loading|=4,Cf(p,d.precedence,a));return s.instance}function Cf(a,s,d){for(var p=d.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),w=p.length?p[p.length-1]:null,A=w,_=0;_ title"):null)}function HD(a,s,d){if(d===1||s.itemProp!=null)return!1;switch(a){case"meta":case"title":return!0;case"style":if(typeof s.precedence!="string"||typeof s.href!="string"||s.href==="")break;return!0;case"link":if(typeof s.rel!="string"||typeof s.href!="string"||s.href===""||s.onLoad||s.onError)break;switch(s.rel){case"stylesheet":return a=s.disabled,typeof s.precedence=="string"&&a==null;default:return!0}case"script":if(s.async&&typeof s.async!="function"&&typeof s.async!="symbol"&&!s.onLoad&&!s.onError&&s.src&&typeof s.src=="string")return!0}return!1}function dA(a){return!(a.type==="stylesheet"&&(a.state.loading&3)===0)}function VD(a,s,d,p){if(d.type==="stylesheet"&&(typeof p.media!="string"||matchMedia(p.media).matches!==!1)&&(d.state.loading&4)===0){if(d.instance===null){var w=wl(p.href),A=s.querySelector(su(w));if(A){s=A._p,s!==null&&typeof s=="object"&&typeof s.then=="function"&&(a.count++,a=Ef.bind(a),s.then(a,a)),d.state.loading|=4,d.instance=A,Xt(A);return}A=s.ownerDocument||s,p=sA(p),(w=Rr.get(w))&&r0(p,w),A=A.createElement("link"),Xt(A);var _=A;_._p=new Promise(function(D,L){_.onload=D,_.onerror=L}),Nn(A,"link",p),d.instance=A}a.stylesheets===null&&(a.stylesheets=new Map),a.stylesheets.set(d,s),(s=d.state.preload)&&(d.state.loading&3)===0&&(a.count++,d=Ef.bind(a),s.addEventListener("load",d),s.addEventListener("error",d))}}var a0=0;function KD(a,s){return a.stylesheets&&a.count===0&&_f(a,a.stylesheets),0a0?50:800)+s);return a.unsuspend=d,function(){a.unsuspend=null,clearTimeout(p),clearTimeout(w)}}:null}function Ef(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)_f(this,this.stylesheets);else if(this.unsuspend){var a=this.unsuspend;this.unsuspend=null,a()}}}var Nf=null;function _f(a,s){a.stylesheets=null,a.unsuspend!==null&&(a.count++,Nf=new Map,s.forEach(YD,a),Nf=null,Ef.call(a))}function YD(a,s){if(!(s.state.loading&4)){var d=Nf.get(a);if(d)var p=d.get(null);else{d=new Map,Nf.set(a,d);for(var w=a.querySelectorAll("link[data-precedence],style[data-precedence]"),A=0;A"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),g0.exports=mR(),g0.exports}var pR=hR();const gR=ji(pR);/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */let yR,vR;function xR(){return{geminiUrl:yR,vertexUrl:vR}}function bR(e,t,n,r){var i,o;if(!(e!=null&&e.baseUrl)){const c=xR();return t?(i=c.vertexUrl)!==null&&i!==void 0?i:n:(o=c.geminiUrl)!==null&&o!==void 0?o:r}return e.baseUrl}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class Sa{}function be(e,t){const n=/\{([^}]+)\}/g;return e.replace(n,(r,i)=>{if(Object.prototype.hasOwnProperty.call(t,i)){const o=t[i];return o!=null?String(o):""}else throw new Error(`Key '${i}' not found in valueMap.`)})}function x(e,t,n){for(let o=0;o({}));else throw new Error(`Value must be a list given an array path ${c}`);if(Array.isArray(e[u])){const m=e[u];if(Array.isArray(n))for(let f=0;fy(u,t.slice(r+1),n)):n}else return n}else e=e[i]}return e}catch(r){if(r instanceof TypeError)return n;throw r}}function wR(e,t){for(const[n,r]of Object.entries(t)){const i=n.split("."),o=r.split("."),c=new Set;let u=-1;for(let m=0;mu)for(let m=u;m=t.length||typeof e!="object"||e===null)return;const o=t[r];if(o.endsWith("[]")){const c=o.slice(0,-2),u=e;if(c in u&&Array.isArray(u[c]))for(const m of u[c])ov(m,t,n,r+1,i)}else if(o==="*"){if(typeof e=="object"&&e!==null&&!Array.isArray(e)){const c=e,u=Object.keys(c).filter(f=>!f.startsWith("_")&&!i.has(f)),m={};for(const f of u)m[f]=c[f];for(const[f,h]of Object.entries(m)){const g=[];for(const v of n.slice(r))v==="*"?g.push(f):g.push(v);x(c,g,h)}for(const f of u)delete c[f]}}else{const c=e;o in c&&ov(c[o],t,n,r+1,i)}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function Mx(e){if(typeof e!="string")throw new Error("fromImageBytes must be a string");return e}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function SR(e){const t={},n=y(e,["operationName"]);n!=null&&x(t,["operationName"],n);const r=y(e,["resourceName"]);return r!=null&&x(t,["_url","resourceName"],r),t}function AR(e){const t={},n=y(e,["name"]);n!=null&&x(t,["name"],n);const r=y(e,["metadata"]);r!=null&&x(t,["metadata"],r);const i=y(e,["done"]);i!=null&&x(t,["done"],i);const o=y(e,["error"]);o!=null&&x(t,["error"],o);const c=y(e,["response","generateVideoResponse"]);return c!=null&&x(t,["response"],TR(c)),t}function CR(e){const t={},n=y(e,["name"]);n!=null&&x(t,["name"],n);const r=y(e,["metadata"]);r!=null&&x(t,["metadata"],r);const i=y(e,["done"]);i!=null&&x(t,["done"],i);const o=y(e,["error"]);o!=null&&x(t,["error"],o);const c=y(e,["response"]);return c!=null&&x(t,["response"],ER(c)),t}function TR(e){const t={},n=y(e,["generatedSamples"]);if(n!=null){let o=n;Array.isArray(o)&&(o=o.map(c=>NR(c))),x(t,["generatedVideos"],o)}const r=y(e,["raiMediaFilteredCount"]);r!=null&&x(t,["raiMediaFilteredCount"],r);const i=y(e,["raiMediaFilteredReasons"]);return i!=null&&x(t,["raiMediaFilteredReasons"],i),t}function ER(e){const t={},n=y(e,["videos"]);if(n!=null){let o=n;Array.isArray(o)&&(o=o.map(c=>_R(c))),x(t,["generatedVideos"],o)}const r=y(e,["raiMediaFilteredCount"]);r!=null&&x(t,["raiMediaFilteredCount"],r);const i=y(e,["raiMediaFilteredReasons"]);return i!=null&&x(t,["raiMediaFilteredReasons"],i),t}function NR(e){const t={},n=y(e,["video"]);return n!=null&&x(t,["video"],DR(n)),t}function _R(e){const t={},n=y(e,["_self"]);return n!=null&&x(t,["video"],RR(n)),t}function jR(e){const t={},n=y(e,["operationName"]);return n!=null&&x(t,["_url","operationName"],n),t}function MR(e){const t={},n=y(e,["operationName"]);return n!=null&&x(t,["_url","operationName"],n),t}function PR(e){const t={},n=y(e,["name"]);n!=null&&x(t,["name"],n);const r=y(e,["metadata"]);r!=null&&x(t,["metadata"],r);const i=y(e,["done"]);i!=null&&x(t,["done"],i);const o=y(e,["error"]);o!=null&&x(t,["error"],o);const c=y(e,["response"]);return c!=null&&x(t,["response"],IR(c)),t}function IR(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["parent"]);r!=null&&x(t,["parent"],r);const i=y(e,["documentName"]);return i!=null&&x(t,["documentName"],i),t}function Zj(e){const t={},n=y(e,["name"]);n!=null&&x(t,["name"],n);const r=y(e,["metadata"]);r!=null&&x(t,["metadata"],r);const i=y(e,["done"]);i!=null&&x(t,["done"],i);const o=y(e,["error"]);o!=null&&x(t,["error"],o);const c=y(e,["response"]);return c!=null&&x(t,["response"],kR(c)),t}function kR(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["parent"]);r!=null&&x(t,["parent"],r);const i=y(e,["documentName"]);return i!=null&&x(t,["documentName"],i),t}function DR(e){const t={},n=y(e,["uri"]);n!=null&&x(t,["uri"],n);const r=y(e,["encodedVideo"]);r!=null&&x(t,["videoBytes"],Mx(r));const i=y(e,["encoding"]);return i!=null&&x(t,["mimeType"],i),t}function RR(e){const t={},n=y(e,["gcsUri"]);n!=null&&x(t,["uri"],n);const r=y(e,["bytesBase64Encoded"]);r!=null&&x(t,["videoBytes"],Mx(r));const i=y(e,["mimeType"]);return i!=null&&x(t,["mimeType"],i),t}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */var OA;(function(e){e.OUTCOME_UNSPECIFIED="OUTCOME_UNSPECIFIED",e.OUTCOME_OK="OUTCOME_OK",e.OUTCOME_FAILED="OUTCOME_FAILED",e.OUTCOME_DEADLINE_EXCEEDED="OUTCOME_DEADLINE_EXCEEDED"})(OA||(OA={}));var LA;(function(e){e.LANGUAGE_UNSPECIFIED="LANGUAGE_UNSPECIFIED",e.PYTHON="PYTHON"})(LA||(LA={}));var UA;(function(e){e.SCHEDULING_UNSPECIFIED="SCHEDULING_UNSPECIFIED",e.SILENT="SILENT",e.WHEN_IDLE="WHEN_IDLE",e.INTERRUPT="INTERRUPT"})(UA||(UA={}));var _e;(function(e){e.TYPE_UNSPECIFIED="TYPE_UNSPECIFIED",e.STRING="STRING",e.NUMBER="NUMBER",e.INTEGER="INTEGER",e.BOOLEAN="BOOLEAN",e.ARRAY="ARRAY",e.OBJECT="OBJECT",e.NULL="NULL"})(_e||(_e={}));var BA;(function(e){e.MODE_UNSPECIFIED="MODE_UNSPECIFIED",e.MODE_DYNAMIC="MODE_DYNAMIC"})(BA||(BA={}));var zA;(function(e){e.API_SPEC_UNSPECIFIED="API_SPEC_UNSPECIFIED",e.SIMPLE_SEARCH="SIMPLE_SEARCH",e.ELASTIC_SEARCH="ELASTIC_SEARCH"})(zA||(zA={}));var FA;(function(e){e.AUTH_TYPE_UNSPECIFIED="AUTH_TYPE_UNSPECIFIED",e.NO_AUTH="NO_AUTH",e.API_KEY_AUTH="API_KEY_AUTH",e.HTTP_BASIC_AUTH="HTTP_BASIC_AUTH",e.GOOGLE_SERVICE_ACCOUNT_AUTH="GOOGLE_SERVICE_ACCOUNT_AUTH",e.OAUTH="OAUTH",e.OIDC_AUTH="OIDC_AUTH"})(FA||(FA={}));var qA;(function(e){e.HTTP_IN_UNSPECIFIED="HTTP_IN_UNSPECIFIED",e.HTTP_IN_QUERY="HTTP_IN_QUERY",e.HTTP_IN_HEADER="HTTP_IN_HEADER",e.HTTP_IN_PATH="HTTP_IN_PATH",e.HTTP_IN_BODY="HTTP_IN_BODY",e.HTTP_IN_COOKIE="HTTP_IN_COOKIE"})(qA||(qA={}));var GA;(function(e){e.PHISH_BLOCK_THRESHOLD_UNSPECIFIED="PHISH_BLOCK_THRESHOLD_UNSPECIFIED",e.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",e.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",e.BLOCK_HIGH_AND_ABOVE="BLOCK_HIGH_AND_ABOVE",e.BLOCK_HIGHER_AND_ABOVE="BLOCK_HIGHER_AND_ABOVE",e.BLOCK_VERY_HIGH_AND_ABOVE="BLOCK_VERY_HIGH_AND_ABOVE",e.BLOCK_ONLY_EXTREMELY_HIGH="BLOCK_ONLY_EXTREMELY_HIGH"})(GA||(GA={}));var $A;(function(e){e.THINKING_LEVEL_UNSPECIFIED="THINKING_LEVEL_UNSPECIFIED",e.LOW="LOW",e.HIGH="HIGH"})($A||($A={}));var HA;(function(e){e.HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",e.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",e.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",e.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",e.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT",e.HARM_CATEGORY_CIVIC_INTEGRITY="HARM_CATEGORY_CIVIC_INTEGRITY",e.HARM_CATEGORY_IMAGE_HATE="HARM_CATEGORY_IMAGE_HATE",e.HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT="HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT",e.HARM_CATEGORY_IMAGE_HARASSMENT="HARM_CATEGORY_IMAGE_HARASSMENT",e.HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT="HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT",e.HARM_CATEGORY_JAILBREAK="HARM_CATEGORY_JAILBREAK"})(HA||(HA={}));var VA;(function(e){e.HARM_BLOCK_METHOD_UNSPECIFIED="HARM_BLOCK_METHOD_UNSPECIFIED",e.SEVERITY="SEVERITY",e.PROBABILITY="PROBABILITY"})(VA||(VA={}));var KA;(function(e){e.HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",e.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",e.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",e.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",e.BLOCK_NONE="BLOCK_NONE",e.OFF="OFF"})(KA||(KA={}));var YA;(function(e){e.FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",e.STOP="STOP",e.MAX_TOKENS="MAX_TOKENS",e.SAFETY="SAFETY",e.RECITATION="RECITATION",e.LANGUAGE="LANGUAGE",e.OTHER="OTHER",e.BLOCKLIST="BLOCKLIST",e.PROHIBITED_CONTENT="PROHIBITED_CONTENT",e.SPII="SPII",e.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",e.IMAGE_SAFETY="IMAGE_SAFETY",e.UNEXPECTED_TOOL_CALL="UNEXPECTED_TOOL_CALL",e.IMAGE_PROHIBITED_CONTENT="IMAGE_PROHIBITED_CONTENT",e.NO_IMAGE="NO_IMAGE"})(YA||(YA={}));var WA;(function(e){e.HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",e.NEGLIGIBLE="NEGLIGIBLE",e.LOW="LOW",e.MEDIUM="MEDIUM",e.HIGH="HIGH"})(WA||(WA={}));var JA;(function(e){e.HARM_SEVERITY_UNSPECIFIED="HARM_SEVERITY_UNSPECIFIED",e.HARM_SEVERITY_NEGLIGIBLE="HARM_SEVERITY_NEGLIGIBLE",e.HARM_SEVERITY_LOW="HARM_SEVERITY_LOW",e.HARM_SEVERITY_MEDIUM="HARM_SEVERITY_MEDIUM",e.HARM_SEVERITY_HIGH="HARM_SEVERITY_HIGH"})(JA||(JA={}));var QA;(function(e){e.URL_RETRIEVAL_STATUS_UNSPECIFIED="URL_RETRIEVAL_STATUS_UNSPECIFIED",e.URL_RETRIEVAL_STATUS_SUCCESS="URL_RETRIEVAL_STATUS_SUCCESS",e.URL_RETRIEVAL_STATUS_ERROR="URL_RETRIEVAL_STATUS_ERROR",e.URL_RETRIEVAL_STATUS_PAYWALL="URL_RETRIEVAL_STATUS_PAYWALL",e.URL_RETRIEVAL_STATUS_UNSAFE="URL_RETRIEVAL_STATUS_UNSAFE"})(QA||(QA={}));var XA;(function(e){e.BLOCKED_REASON_UNSPECIFIED="BLOCKED_REASON_UNSPECIFIED",e.SAFETY="SAFETY",e.OTHER="OTHER",e.BLOCKLIST="BLOCKLIST",e.PROHIBITED_CONTENT="PROHIBITED_CONTENT",e.IMAGE_SAFETY="IMAGE_SAFETY",e.MODEL_ARMOR="MODEL_ARMOR",e.JAILBREAK="JAILBREAK"})(XA||(XA={}));var ZA;(function(e){e.TRAFFIC_TYPE_UNSPECIFIED="TRAFFIC_TYPE_UNSPECIFIED",e.ON_DEMAND="ON_DEMAND",e.PROVISIONED_THROUGHPUT="PROVISIONED_THROUGHPUT"})(ZA||(ZA={}));var Mu;(function(e){e.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",e.TEXT="TEXT",e.IMAGE="IMAGE",e.AUDIO="AUDIO"})(Mu||(Mu={}));var eC;(function(e){e.MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",e.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",e.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",e.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH"})(eC||(eC={}));var tC;(function(e){e.TUNING_MODE_UNSPECIFIED="TUNING_MODE_UNSPECIFIED",e.TUNING_MODE_FULL="TUNING_MODE_FULL",e.TUNING_MODE_PEFT_ADAPTER="TUNING_MODE_PEFT_ADAPTER"})(tC||(tC={}));var nC;(function(e){e.ADAPTER_SIZE_UNSPECIFIED="ADAPTER_SIZE_UNSPECIFIED",e.ADAPTER_SIZE_ONE="ADAPTER_SIZE_ONE",e.ADAPTER_SIZE_TWO="ADAPTER_SIZE_TWO",e.ADAPTER_SIZE_FOUR="ADAPTER_SIZE_FOUR",e.ADAPTER_SIZE_EIGHT="ADAPTER_SIZE_EIGHT",e.ADAPTER_SIZE_SIXTEEN="ADAPTER_SIZE_SIXTEEN",e.ADAPTER_SIZE_THIRTY_TWO="ADAPTER_SIZE_THIRTY_TWO"})(nC||(nC={}));var sv;(function(e){e.JOB_STATE_UNSPECIFIED="JOB_STATE_UNSPECIFIED",e.JOB_STATE_QUEUED="JOB_STATE_QUEUED",e.JOB_STATE_PENDING="JOB_STATE_PENDING",e.JOB_STATE_RUNNING="JOB_STATE_RUNNING",e.JOB_STATE_SUCCEEDED="JOB_STATE_SUCCEEDED",e.JOB_STATE_FAILED="JOB_STATE_FAILED",e.JOB_STATE_CANCELLING="JOB_STATE_CANCELLING",e.JOB_STATE_CANCELLED="JOB_STATE_CANCELLED",e.JOB_STATE_PAUSED="JOB_STATE_PAUSED",e.JOB_STATE_EXPIRED="JOB_STATE_EXPIRED",e.JOB_STATE_UPDATING="JOB_STATE_UPDATING",e.JOB_STATE_PARTIALLY_SUCCEEDED="JOB_STATE_PARTIALLY_SUCCEEDED"})(sv||(sv={}));var rC;(function(e){e.TUNING_TASK_UNSPECIFIED="TUNING_TASK_UNSPECIFIED",e.TUNING_TASK_I2V="TUNING_TASK_I2V",e.TUNING_TASK_T2V="TUNING_TASK_T2V",e.TUNING_TASK_R2V="TUNING_TASK_R2V"})(rC||(rC={}));var iC;(function(e){e.MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",e.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",e.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",e.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH"})(iC||(iC={}));var aC;(function(e){e.FEATURE_SELECTION_PREFERENCE_UNSPECIFIED="FEATURE_SELECTION_PREFERENCE_UNSPECIFIED",e.PRIORITIZE_QUALITY="PRIORITIZE_QUALITY",e.BALANCED="BALANCED",e.PRIORITIZE_COST="PRIORITIZE_COST"})(aC||(aC={}));var oC;(function(e){e.UNSPECIFIED="UNSPECIFIED",e.BLOCKING="BLOCKING",e.NON_BLOCKING="NON_BLOCKING"})(oC||(oC={}));var sC;(function(e){e.MODE_UNSPECIFIED="MODE_UNSPECIFIED",e.MODE_DYNAMIC="MODE_DYNAMIC"})(sC||(sC={}));var lC;(function(e){e.ENVIRONMENT_UNSPECIFIED="ENVIRONMENT_UNSPECIFIED",e.ENVIRONMENT_BROWSER="ENVIRONMENT_BROWSER"})(lC||(lC={}));var cC;(function(e){e.MODE_UNSPECIFIED="MODE_UNSPECIFIED",e.AUTO="AUTO",e.ANY="ANY",e.NONE="NONE",e.VALIDATED="VALIDATED"})(cC||(cC={}));var uC;(function(e){e.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",e.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",e.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",e.BLOCK_NONE="BLOCK_NONE"})(uC||(uC={}));var dC;(function(e){e.DONT_ALLOW="DONT_ALLOW",e.ALLOW_ADULT="ALLOW_ADULT",e.ALLOW_ALL="ALLOW_ALL"})(dC||(dC={}));var fC;(function(e){e.auto="auto",e.en="en",e.ja="ja",e.ko="ko",e.hi="hi",e.zh="zh",e.pt="pt",e.es="es"})(fC||(fC={}));var mC;(function(e){e.MASK_MODE_DEFAULT="MASK_MODE_DEFAULT",e.MASK_MODE_USER_PROVIDED="MASK_MODE_USER_PROVIDED",e.MASK_MODE_BACKGROUND="MASK_MODE_BACKGROUND",e.MASK_MODE_FOREGROUND="MASK_MODE_FOREGROUND",e.MASK_MODE_SEMANTIC="MASK_MODE_SEMANTIC"})(mC||(mC={}));var hC;(function(e){e.CONTROL_TYPE_DEFAULT="CONTROL_TYPE_DEFAULT",e.CONTROL_TYPE_CANNY="CONTROL_TYPE_CANNY",e.CONTROL_TYPE_SCRIBBLE="CONTROL_TYPE_SCRIBBLE",e.CONTROL_TYPE_FACE_MESH="CONTROL_TYPE_FACE_MESH"})(hC||(hC={}));var pC;(function(e){e.SUBJECT_TYPE_DEFAULT="SUBJECT_TYPE_DEFAULT",e.SUBJECT_TYPE_PERSON="SUBJECT_TYPE_PERSON",e.SUBJECT_TYPE_ANIMAL="SUBJECT_TYPE_ANIMAL",e.SUBJECT_TYPE_PRODUCT="SUBJECT_TYPE_PRODUCT"})(pC||(pC={}));var gC;(function(e){e.EDIT_MODE_DEFAULT="EDIT_MODE_DEFAULT",e.EDIT_MODE_INPAINT_REMOVAL="EDIT_MODE_INPAINT_REMOVAL",e.EDIT_MODE_INPAINT_INSERTION="EDIT_MODE_INPAINT_INSERTION",e.EDIT_MODE_OUTPAINT="EDIT_MODE_OUTPAINT",e.EDIT_MODE_CONTROLLED_EDITING="EDIT_MODE_CONTROLLED_EDITING",e.EDIT_MODE_STYLE="EDIT_MODE_STYLE",e.EDIT_MODE_BGSWAP="EDIT_MODE_BGSWAP",e.EDIT_MODE_PRODUCT_IMAGE="EDIT_MODE_PRODUCT_IMAGE"})(gC||(gC={}));var yC;(function(e){e.FOREGROUND="FOREGROUND",e.BACKGROUND="BACKGROUND",e.PROMPT="PROMPT",e.SEMANTIC="SEMANTIC",e.INTERACTIVE="INTERACTIVE"})(yC||(yC={}));var vC;(function(e){e.ASSET="ASSET",e.STYLE="STYLE"})(vC||(vC={}));var xC;(function(e){e.INSERT="INSERT",e.REMOVE="REMOVE",e.REMOVE_STATIC="REMOVE_STATIC",e.OUTPAINT="OUTPAINT"})(xC||(xC={}));var bC;(function(e){e.OPTIMIZED="OPTIMIZED",e.LOSSLESS="LOSSLESS"})(bC||(bC={}));var wC;(function(e){e.SUPERVISED_FINE_TUNING="SUPERVISED_FINE_TUNING",e.PREFERENCE_TUNING="PREFERENCE_TUNING"})(wC||(wC={}));var SC;(function(e){e.STATE_UNSPECIFIED="STATE_UNSPECIFIED",e.STATE_PENDING="STATE_PENDING",e.STATE_ACTIVE="STATE_ACTIVE",e.STATE_FAILED="STATE_FAILED"})(SC||(SC={}));var AC;(function(e){e.STATE_UNSPECIFIED="STATE_UNSPECIFIED",e.PROCESSING="PROCESSING",e.ACTIVE="ACTIVE",e.FAILED="FAILED"})(AC||(AC={}));var CC;(function(e){e.SOURCE_UNSPECIFIED="SOURCE_UNSPECIFIED",e.UPLOADED="UPLOADED",e.GENERATED="GENERATED"})(CC||(CC={}));var TC;(function(e){e.TURN_COMPLETE_REASON_UNSPECIFIED="TURN_COMPLETE_REASON_UNSPECIFIED",e.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",e.RESPONSE_REJECTED="RESPONSE_REJECTED",e.NEED_MORE_INPUT="NEED_MORE_INPUT"})(TC||(TC={}));var EC;(function(e){e.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",e.TEXT="TEXT",e.IMAGE="IMAGE",e.VIDEO="VIDEO",e.AUDIO="AUDIO",e.DOCUMENT="DOCUMENT"})(EC||(EC={}));var NC;(function(e){e.START_SENSITIVITY_UNSPECIFIED="START_SENSITIVITY_UNSPECIFIED",e.START_SENSITIVITY_HIGH="START_SENSITIVITY_HIGH",e.START_SENSITIVITY_LOW="START_SENSITIVITY_LOW"})(NC||(NC={}));var _C;(function(e){e.END_SENSITIVITY_UNSPECIFIED="END_SENSITIVITY_UNSPECIFIED",e.END_SENSITIVITY_HIGH="END_SENSITIVITY_HIGH",e.END_SENSITIVITY_LOW="END_SENSITIVITY_LOW"})(_C||(_C={}));var jC;(function(e){e.ACTIVITY_HANDLING_UNSPECIFIED="ACTIVITY_HANDLING_UNSPECIFIED",e.START_OF_ACTIVITY_INTERRUPTS="START_OF_ACTIVITY_INTERRUPTS",e.NO_INTERRUPTION="NO_INTERRUPTION"})(jC||(jC={}));var MC;(function(e){e.TURN_COVERAGE_UNSPECIFIED="TURN_COVERAGE_UNSPECIFIED",e.TURN_INCLUDES_ONLY_ACTIVITY="TURN_INCLUDES_ONLY_ACTIVITY",e.TURN_INCLUDES_ALL_INPUT="TURN_INCLUDES_ALL_INPUT"})(MC||(MC={}));var PC;(function(e){e.SCALE_UNSPECIFIED="SCALE_UNSPECIFIED",e.C_MAJOR_A_MINOR="C_MAJOR_A_MINOR",e.D_FLAT_MAJOR_B_FLAT_MINOR="D_FLAT_MAJOR_B_FLAT_MINOR",e.D_MAJOR_B_MINOR="D_MAJOR_B_MINOR",e.E_FLAT_MAJOR_C_MINOR="E_FLAT_MAJOR_C_MINOR",e.E_MAJOR_D_FLAT_MINOR="E_MAJOR_D_FLAT_MINOR",e.F_MAJOR_D_MINOR="F_MAJOR_D_MINOR",e.G_FLAT_MAJOR_E_FLAT_MINOR="G_FLAT_MAJOR_E_FLAT_MINOR",e.G_MAJOR_E_MINOR="G_MAJOR_E_MINOR",e.A_FLAT_MAJOR_F_MINOR="A_FLAT_MAJOR_F_MINOR",e.A_MAJOR_G_FLAT_MINOR="A_MAJOR_G_FLAT_MINOR",e.B_FLAT_MAJOR_G_MINOR="B_FLAT_MAJOR_G_MINOR",e.B_MAJOR_A_FLAT_MINOR="B_MAJOR_A_FLAT_MINOR"})(PC||(PC={}));var IC;(function(e){e.MUSIC_GENERATION_MODE_UNSPECIFIED="MUSIC_GENERATION_MODE_UNSPECIFIED",e.QUALITY="QUALITY",e.DIVERSITY="DIVERSITY",e.VOCALIZATION="VOCALIZATION"})(IC||(IC={}));var Nl;(function(e){e.PLAYBACK_CONTROL_UNSPECIFIED="PLAYBACK_CONTROL_UNSPECIFIED",e.PLAY="PLAY",e.PAUSE="PAUSE",e.STOP="STOP",e.RESET_CONTEXT="RESET_CONTEXT"})(Nl||(Nl={}));class lv{constructor(t){const n={};for(const r of t.headers.entries())n[r[0]]=r[1];this.headers=n,this.responseInternal=t}json(){return this.responseInternal.json()}}class pu{get text(){var t,n,r,i,o,c,u,m;if(((i=(r=(n=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||n===void 0?void 0:n.content)===null||r===void 0?void 0:r.parts)===null||i===void 0?void 0:i.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 f="",h=!1;const g=[];for(const v of(m=(u=(c=(o=this.candidates)===null||o===void 0?void 0:o[0])===null||c===void 0?void 0:c.content)===null||u===void 0?void 0:u.parts)!==null&&m!==void 0?m:[]){for(const[b,T]of Object.entries(v))b!=="text"&&b!=="thought"&&b!=="thoughtSignature"&&(T!==null||T!==void 0)&&g.push(b);if(typeof v.text=="string"){if(typeof v.thought=="boolean"&&v.thought)continue;h=!0,f+=v.text}}return g.length>0&&console.warn(`there are non-text parts ${g} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),h?f:void 0}get data(){var t,n,r,i,o,c,u,m;if(((i=(r=(n=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||n===void 0?void 0:n.content)===null||r===void 0?void 0:r.parts)===null||i===void 0?void 0:i.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 f="";const h=[];for(const g of(m=(u=(c=(o=this.candidates)===null||o===void 0?void 0:o[0])===null||c===void 0?void 0:c.content)===null||u===void 0?void 0:u.parts)!==null&&m!==void 0?m:[]){for(const[v,b]of Object.entries(g))v!=="inlineData"&&(b!==null||b!==void 0)&&h.push(v);g.inlineData&&typeof g.inlineData.data=="string"&&(f+=atob(g.inlineData.data))}return h.length>0&&console.warn(`there are non-data parts ${h} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),f.length>0?btoa(f):void 0}get functionCalls(){var t,n,r,i,o,c,u,m;if(((i=(r=(n=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||n===void 0?void 0:n.content)===null||r===void 0?void 0:r.parts)===null||i===void 0?void 0:i.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 f=(m=(u=(c=(o=this.candidates)===null||o===void 0?void 0:o[0])===null||c===void 0?void 0:c.content)===null||u===void 0?void 0:u.parts)===null||m===void 0?void 0:m.filter(h=>h.functionCall).map(h=>h.functionCall).filter(h=>h!==void 0);if((f==null?void 0:f.length)!==0)return f}get executableCode(){var t,n,r,i,o,c,u,m,f;if(((i=(r=(n=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||n===void 0?void 0:n.content)===null||r===void 0?void 0:r.parts)===null||i===void 0?void 0:i.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 h=(m=(u=(c=(o=this.candidates)===null||o===void 0?void 0:o[0])===null||c===void 0?void 0:c.content)===null||u===void 0?void 0:u.parts)===null||m===void 0?void 0:m.filter(g=>g.executableCode).map(g=>g.executableCode).filter(g=>g!==void 0);if((h==null?void 0:h.length)!==0)return(f=h==null?void 0:h[0])===null||f===void 0?void 0:f.code}get codeExecutionResult(){var t,n,r,i,o,c,u,m,f;if(((i=(r=(n=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||n===void 0?void 0:n.content)===null||r===void 0?void 0:r.parts)===null||i===void 0?void 0:i.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 h=(m=(u=(c=(o=this.candidates)===null||o===void 0?void 0:o[0])===null||c===void 0?void 0:c.content)===null||u===void 0?void 0:u.parts)===null||m===void 0?void 0:m.filter(g=>g.codeExecutionResult).map(g=>g.codeExecutionResult).filter(g=>g!==void 0);if((h==null?void 0:h.length)!==0)return(f=h==null?void 0:h[0])===null||f===void 0?void 0:f.output}}class kC{}class DC{}class OR{}class LR{}class UR{}class BR{}class RC{}class OC{}class LC{}class zR{}class lm{_fromAPIResponse({apiResponse:t,_isVertexAI:n}){const r=new lm;let i;const o=t;return n?i=CR(o):i=AR(o),Object.assign(r,i),r}}class UC{}class BC{}class zC{}class FR{}class qR{}class GR{}class Px{_fromAPIResponse({apiResponse:t,_isVertexAI:n}){const r=new Px,o=PR(t);return Object.assign(r,o),r}}class $R{}class HR{}class VR{}class FC{}class KR{get text(){var t,n,r;let i="",o=!1;const c=[];for(const u of(r=(n=(t=this.serverContent)===null||t===void 0?void 0:t.modelTurn)===null||n===void 0?void 0:n.parts)!==null&&r!==void 0?r:[]){for(const[m,f]of Object.entries(u))m!=="text"&&m!=="thought"&&f!==null&&c.push(m);if(typeof u.text=="string"){if(typeof u.thought=="boolean"&&u.thought)continue;o=!0,i+=u.text}}return c.length>0&&console.warn(`there are non-text parts ${c} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),o?i:void 0}get data(){var t,n,r;let i="";const o=[];for(const c of(r=(n=(t=this.serverContent)===null||t===void 0?void 0:t.modelTurn)===null||n===void 0?void 0:n.parts)!==null&&r!==void 0?r:[]){for(const[u,m]of Object.entries(c))u!=="inlineData"&&m!==null&&o.push(u);c.inlineData&&typeof c.inlineData.data=="string"&&(i+=atob(c.inlineData.data))}return o.length>0&&console.warn(`there are non-data parts ${o} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),i.length>0?btoa(i):void 0}}class YR{get audioChunk(){if(this.serverContent&&this.serverContent.audioChunks&&this.serverContent.audioChunks.length>0)return this.serverContent.audioChunks[0]}}class Ix{_fromAPIResponse({apiResponse:t,_isVertexAI:n}){const r=new Ix,o=Zj(t);return Object.assign(r,o),r}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function tt(e,t){if(!t||typeof t!="string")throw new Error("model is required and must be a string");if(t.includes("..")||t.includes("?")||t.includes("&"))throw new Error("invalid model parameter");if(e.isVertexAI()){if(t.startsWith("publishers/")||t.startsWith("projects/")||t.startsWith("models/"))return t;if(t.indexOf("/")>=0){const n=t.split("/",2);return`publishers/${n[0]}/models/${n[1]}`}else return`publishers/google/models/${t}`}else return t.startsWith("models/")||t.startsWith("tunedModels/")?t:`models/${t}`}function e3(e,t){const n=tt(e,t);return n?n.startsWith("publishers/")&&e.isVertexAI()?`projects/${e.getProject()}/locations/${e.getLocation()}/${n}`:n.startsWith("models/")&&e.isVertexAI()?`projects/${e.getProject()}/locations/${e.getLocation()}/publishers/google/${n}`:n:""}function t3(e){return Array.isArray(e)?e.map(t=>cm(t)):[cm(e)]}function cm(e){if(typeof e=="object"&&e!==null)return e;throw new Error(`Could not parse input as Blob. Unsupported blob type: ${typeof e}`)}function n3(e){const t=cm(e);if(t.mimeType&&t.mimeType.startsWith("image/"))return t;throw new Error(`Unsupported mime type: ${t.mimeType}`)}function r3(e){const t=cm(e);if(t.mimeType&&t.mimeType.startsWith("audio/"))return t;throw new Error(`Unsupported mime type: ${t.mimeType}`)}function qC(e){if(e==null)throw new Error("PartUnion is required");if(typeof e=="object")return e;if(typeof e=="string")return{text:e};throw new Error(`Unsupported part type: ${typeof e}`)}function i3(e){if(e==null||Array.isArray(e)&&e.length===0)throw new Error("PartListUnion is required");return Array.isArray(e)?e.map(t=>qC(t)):[qC(e)]}function cv(e){return e!=null&&typeof e=="object"&&"parts"in e&&Array.isArray(e.parts)}function GC(e){return e!=null&&typeof e=="object"&&"functionCall"in e}function $C(e){return e!=null&&typeof e=="object"&&"functionResponse"in e}function Ln(e){if(e==null)throw new Error("ContentUnion is required");return cv(e)?e:{role:"user",parts:i3(e)}}function kx(e,t){if(!t)return[];if(e.isVertexAI()&&Array.isArray(t))return t.flatMap(n=>{const r=Ln(n);return r.parts&&r.parts.length>0&&r.parts[0].text!==void 0?[r.parts[0].text]:[]});if(e.isVertexAI()){const n=Ln(t);return n.parts&&n.parts.length>0&&n.parts[0].text!==void 0?[n.parts[0].text]:[]}return Array.isArray(t)?t.map(n=>Ln(n)):[Ln(t)]}function Hr(e){if(e==null||Array.isArray(e)&&e.length===0)throw new Error("contents are required");if(!Array.isArray(e)){if(GC(e)||$C(e))throw new Error("To specify functionCall or functionResponse parts, please wrap them in a Content object, specifying the role for them");return[Ln(e)]}const t=[],n=[],r=cv(e[0]);for(const i of e){const o=cv(i);if(o!=r)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(o)t.push(i);else{if(GC(i)||$C(i))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");n.push(i)}}return r||t.push({role:"user",parts:i3(n)}),t}function WR(e,t){e.includes("null")&&(t.nullable=!0);const n=e.filter(r=>r!=="null");if(n.length===1)t.type=Object.values(_e).includes(n[0].toUpperCase())?n[0].toUpperCase():_e.TYPE_UNSPECIFIED;else{t.anyOf=[];for(const r of n)t.anyOf.push({type:Object.values(_e).includes(r.toUpperCase())?r.toUpperCase():_e.TYPE_UNSPECIFIED})}}function Il(e){const t={},n=["items"],r=["anyOf"],i=["properties"];if(e.type&&e.anyOf)throw new Error("type and anyOf cannot be both populated.");const o=e.anyOf;o!=null&&o.length==2&&(o[0].type==="null"?(t.nullable=!0,e=o[1]):o[1].type==="null"&&(t.nullable=!0,e=o[0])),e.type instanceof Array&&WR(e.type,t);for(const[c,u]of Object.entries(e))if(u!=null)if(c=="type"){if(u==="null")throw new Error("type: null can not be the only possible type for the field.");if(u instanceof Array)continue;t.type=Object.values(_e).includes(u.toUpperCase())?u.toUpperCase():_e.TYPE_UNSPECIFIED}else if(n.includes(c))t[c]=Il(u);else if(r.includes(c)){const m=[];for(const f of u){if(f.type=="null"){t.nullable=!0;continue}m.push(Il(f))}t[c]=m}else if(i.includes(c)){const m={};for(const[f,h]of Object.entries(u))m[f]=Il(h);t[c]=m}else{if(c==="additionalProperties")continue;t[c]=u}return t}function Dx(e){return Il(e)}function Rx(e){if(typeof e=="object")return e;if(typeof e=="string")return{voiceConfig:{prebuiltVoiceConfig:{voiceName:e}}};throw new Error(`Unsupported speechConfig type: ${typeof e}`)}function Ox(e){if("multiSpeakerVoiceConfig"in e)throw new Error("multiSpeakerVoiceConfig is not supported in the live API.");return e}function rc(e){if(e.functionDeclarations)for(const t of e.functionDeclarations)t.parameters&&(Object.keys(t.parameters).includes("$schema")?t.parametersJsonSchema||(t.parametersJsonSchema=t.parameters,delete t.parameters):t.parameters=Il(t.parameters)),t.response&&(Object.keys(t.response).includes("$schema")?t.responseJsonSchema||(t.responseJsonSchema=t.response,delete t.response):t.response=Il(t.response));return e}function ic(e){if(e==null)throw new Error("tools is required");if(!Array.isArray(e))throw new Error("tools is required and must be an array of Tools");const t=[];for(const n of e)t.push(n);return t}function JR(e,t,n,r=1){const i=!t.startsWith(`${n}/`)&&t.split("/").length===r;return e.isVertexAI()?t.startsWith("projects/")?t:t.startsWith("locations/")?`projects/${e.getProject()}/${t}`:t.startsWith(`${n}/`)?`projects/${e.getProject()}/locations/${e.getLocation()}/${t}`:i?`projects/${e.getProject()}/locations/${e.getLocation()}/${n}/${t}`:t:i?`${n}/${t}`:t}function Aa(e,t){if(typeof t!="string")throw new Error("name must be a string");return JR(e,t,"cachedContents")}function a3(e){switch(e){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 e}}function Eo(e){return Mx(e)}function QR(e){return e!=null&&typeof e=="object"&&"name"in e}function XR(e){return e!=null&&typeof e=="object"&&"video"in e}function ZR(e){return e!=null&&typeof e=="object"&&"uri"in e}function o3(e){var t;let n;if(QR(e)&&(n=e.name),!(ZR(e)&&(n=e.uri,n===void 0))&&!(XR(e)&&(n=(t=e.video)===null||t===void 0?void 0:t.uri,n===void 0))){if(typeof e=="string"&&(n=e),n===void 0)throw new Error("Could not extract file name from the provided input.");if(n.startsWith("https://")){const i=n.split("files/")[1].match(/[a-z0-9]+/);if(i===null)throw new Error(`Could not extract file name from URI ${n}`);n=i[0]}else n.startsWith("files/")&&(n=n.split("files/")[1]);return n}}function s3(e,t){let n;return e.isVertexAI()?n=t?"publishers/google/models":"models":n=t?"models":"tunedModels",n}function l3(e){for(const t of["models","tunedModels","publisherModels"])if(eO(e,t))return e[t];return[]}function eO(e,t){return e!==null&&typeof e=="object"&&t in e}function tO(e,t={}){const n=e,r={name:n.name,description:n.description,parametersJsonSchema:n.inputSchema};return n.outputSchema&&(r.responseJsonSchema=n.outputSchema),t.behavior&&(r.behavior=t.behavior),{functionDeclarations:[r]}}function nO(e,t={}){const n=[],r=new Set;for(const i of e){const o=i.name;if(r.has(o))throw new Error(`Duplicate function name ${o} found in MCP tools. Please ensure function names are unique.`);r.add(o);const c=tO(i,t);c.functionDeclarations&&n.push(...c.functionDeclarations)}return{functionDeclarations:n}}function c3(e,t){let n;if(typeof t=="string")if(e.isVertexAI())if(t.startsWith("gs://"))n={format:"jsonl",gcsUri:[t]};else if(t.startsWith("bq://"))n={format:"bigquery",bigqueryUri:t};else throw new Error(`Unsupported string source for Vertex AI: ${t}`);else if(t.startsWith("files/"))n={fileName:t};else throw new Error(`Unsupported string source for Gemini API: ${t}`);else if(Array.isArray(t)){if(e.isVertexAI())throw new Error("InlinedRequest[] is not supported in Vertex AI.");n={inlinedRequests:t}}else n=t;const r=[n.gcsUri,n.bigqueryUri].filter(Boolean).length,i=[n.inlinedRequests,n.fileName].filter(Boolean).length;if(e.isVertexAI()){if(i>0||r!==1)throw new Error("Exactly one of `gcsUri` or `bigqueryUri` must be set for Vertex AI.")}else if(r>0||i!==1)throw new Error("Exactly one of `inlinedRequests`, `fileName`, must be set for Gemini API.");return n}function rO(e){if(typeof e!="string")return e;const t=e;if(t.startsWith("gs://"))return{format:"jsonl",gcsUri:t};if(t.startsWith("bq://"))return{format:"bigquery",bigqueryUri:t};throw new Error(`Unsupported destination: ${t}`)}function u3(e){if(typeof e!="object"||e===null)return{};const t=e,n=t.inlinedResponses;if(typeof n!="object"||n===null)return e;const i=n.inlinedResponses;if(!Array.isArray(i)||i.length===0)return e;let o=!1;for(const c of i){if(typeof c!="object"||c===null)continue;const m=c.response;if(typeof m!="object"||m===null)continue;if(m.embedding!==void 0){o=!0;break}}return o&&(t.inlinedEmbedContentResponses=t.inlinedResponses,delete t.inlinedResponses),e}function ac(e,t){const n=t;if(!e.isVertexAI()){if(/batches\/[^/]+$/.test(n))return n.split("/").pop();throw new Error(`Invalid batch job name: ${n}.`)}if(/^projects\/[^/]+\/locations\/[^/]+\/batchPredictionJobs\/[^/]+$/.test(n))return n.split("/").pop();if(/^\d+$/.test(n))return n;throw new Error(`Invalid batch job name: ${n}.`)}function d3(e){const t=e;return t==="BATCH_STATE_UNSPECIFIED"?"JOB_STATE_UNSPECIFIED":t==="BATCH_STATE_PENDING"?"JOB_STATE_PENDING":t==="BATCH_STATE_RUNNING"?"JOB_STATE_RUNNING":t==="BATCH_STATE_SUCCEEDED"?"JOB_STATE_SUCCEEDED":t==="BATCH_STATE_FAILED"?"JOB_STATE_FAILED":t==="BATCH_STATE_CANCELLED"?"JOB_STATE_CANCELLED":t==="BATCH_STATE_EXPIRED"?"JOB_STATE_EXPIRED":t}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function iO(e){const t={},n=y(e,["responsesFile"]);n!=null&&x(t,["fileName"],n);const r=y(e,["inlinedResponses","inlinedResponses"]);if(r!=null){let o=r;Array.isArray(o)&&(o=o.map(c=>UO(c))),x(t,["inlinedResponses"],o)}const i=y(e,["inlinedEmbedContentResponses","inlinedResponses"]);if(i!=null){let o=i;Array.isArray(o)&&(o=o.map(c=>c)),x(t,["inlinedEmbedContentResponses"],o)}return t}function aO(e){const t={},n=y(e,["predictionsFormat"]);n!=null&&x(t,["format"],n);const r=y(e,["gcsDestination","outputUriPrefix"]);r!=null&&x(t,["gcsUri"],r);const i=y(e,["bigqueryDestination","outputUri"]);return i!=null&&x(t,["bigqueryUri"],i),t}function oO(e){const t={},n=y(e,["format"]);n!=null&&x(t,["predictionsFormat"],n);const r=y(e,["gcsUri"]);r!=null&&x(t,["gcsDestination","outputUriPrefix"],r);const i=y(e,["bigqueryUri"]);if(i!=null&&x(t,["bigqueryDestination","outputUri"],i),y(e,["fileName"])!==void 0)throw new Error("fileName parameter is not supported in Vertex AI.");if(y(e,["inlinedResponses"])!==void 0)throw new Error("inlinedResponses parameter is not supported in Vertex AI.");if(y(e,["inlinedEmbedContentResponses"])!==void 0)throw new Error("inlinedEmbedContentResponses parameter is not supported in Vertex AI.");return t}function nm(e){const t={},n=y(e,["name"]);n!=null&&x(t,["name"],n);const r=y(e,["metadata","displayName"]);r!=null&&x(t,["displayName"],r);const i=y(e,["metadata","state"]);i!=null&&x(t,["state"],d3(i));const o=y(e,["metadata","createTime"]);o!=null&&x(t,["createTime"],o);const c=y(e,["metadata","endTime"]);c!=null&&x(t,["endTime"],c);const u=y(e,["metadata","updateTime"]);u!=null&&x(t,["updateTime"],u);const m=y(e,["metadata","model"]);m!=null&&x(t,["model"],m);const f=y(e,["metadata","output"]);return f!=null&&x(t,["dest"],iO(u3(f))),t}function uv(e){const t={},n=y(e,["name"]);n!=null&&x(t,["name"],n);const r=y(e,["displayName"]);r!=null&&x(t,["displayName"],r);const i=y(e,["state"]);i!=null&&x(t,["state"],d3(i));const o=y(e,["error"]);o!=null&&x(t,["error"],o);const c=y(e,["createTime"]);c!=null&&x(t,["createTime"],c);const u=y(e,["startTime"]);u!=null&&x(t,["startTime"],u);const m=y(e,["endTime"]);m!=null&&x(t,["endTime"],m);const f=y(e,["updateTime"]);f!=null&&x(t,["updateTime"],f);const h=y(e,["model"]);h!=null&&x(t,["model"],h);const g=y(e,["inputConfig"]);g!=null&&x(t,["src"],sO(g));const v=y(e,["outputConfig"]);v!=null&&x(t,["dest"],aO(u3(v)));const b=y(e,["completionStats"]);return b!=null&&x(t,["completionStats"],b),t}function sO(e){const t={},n=y(e,["instancesFormat"]);n!=null&&x(t,["format"],n);const r=y(e,["gcsSource","uris"]);r!=null&&x(t,["gcsUri"],r);const i=y(e,["bigquerySource","inputUri"]);return i!=null&&x(t,["bigqueryUri"],i),t}function lO(e,t){const n={};if(y(t,["format"])!==void 0)throw new Error("format parameter is not supported in Gemini API.");if(y(t,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");if(y(t,["bigqueryUri"])!==void 0)throw new Error("bigqueryUri parameter is not supported in Gemini API.");const r=y(t,["fileName"]);r!=null&&x(n,["fileName"],r);const i=y(t,["inlinedRequests"]);if(i!=null){let o=i;Array.isArray(o)&&(o=o.map(c=>LO(e,c))),x(n,["requests","requests"],o)}return n}function cO(e){const t={},n=y(e,["format"]);n!=null&&x(t,["instancesFormat"],n);const r=y(e,["gcsUri"]);r!=null&&x(t,["gcsSource","uris"],r);const i=y(e,["bigqueryUri"]);if(i!=null&&x(t,["bigquerySource","inputUri"],i),y(e,["fileName"])!==void 0)throw new Error("fileName parameter is not supported in Vertex AI.");if(y(e,["inlinedRequests"])!==void 0)throw new Error("inlinedRequests parameter is not supported in Vertex AI.");return t}function uO(e){const t={},n=y(e,["data"]);if(n!=null&&x(t,["data"],n),y(e,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const r=y(e,["mimeType"]);return r!=null&&x(t,["mimeType"],r),t}function dO(e,t){const n={},r=y(t,["name"]);return r!=null&&x(n,["_url","name"],ac(e,r)),n}function fO(e,t){const n={},r=y(t,["name"]);return r!=null&&x(n,["_url","name"],ac(e,r)),n}function mO(e){const t={},n=y(e,["content"]);n!=null&&x(t,["content"],n);const r=y(e,["citationMetadata"]);r!=null&&x(t,["citationMetadata"],hO(r));const i=y(e,["tokenCount"]);i!=null&&x(t,["tokenCount"],i);const o=y(e,["finishReason"]);o!=null&&x(t,["finishReason"],o);const c=y(e,["avgLogprobs"]);c!=null&&x(t,["avgLogprobs"],c);const u=y(e,["groundingMetadata"]);u!=null&&x(t,["groundingMetadata"],u);const m=y(e,["index"]);m!=null&&x(t,["index"],m);const f=y(e,["logprobsResult"]);f!=null&&x(t,["logprobsResult"],f);const h=y(e,["safetyRatings"]);if(h!=null){let v=h;Array.isArray(v)&&(v=v.map(b=>b)),x(t,["safetyRatings"],v)}const g=y(e,["urlContextMetadata"]);return g!=null&&x(t,["urlContextMetadata"],g),t}function hO(e){const t={},n=y(e,["citationSources"]);if(n!=null){let r=n;Array.isArray(r)&&(r=r.map(i=>i)),x(t,["citations"],r)}return t}function f3(e){const t={},n=y(e,["parts"]);if(n!=null){let i=n;Array.isArray(i)&&(i=i.map(o=>HO(o))),x(t,["parts"],i)}const r=y(e,["role"]);return r!=null&&x(t,["role"],r),t}function pO(e,t){const n={},r=y(e,["displayName"]);if(t!==void 0&&r!=null&&x(t,["batch","displayName"],r),y(e,["dest"])!==void 0)throw new Error("dest parameter is not supported in Gemini API.");return n}function gO(e,t){const n={},r=y(e,["displayName"]);t!==void 0&&r!=null&&x(t,["displayName"],r);const i=y(e,["dest"]);return t!==void 0&&i!=null&&x(t,["outputConfig"],oO(rO(i))),n}function HC(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["_url","model"],tt(e,r));const i=y(t,["src"]);i!=null&&x(n,["batch","inputConfig"],lO(e,c3(e,i)));const o=y(t,["config"]);return o!=null&&pO(o,n),n}function yO(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["model"],tt(e,r));const i=y(t,["src"]);i!=null&&x(n,["inputConfig"],cO(c3(e,i)));const o=y(t,["config"]);return o!=null&&gO(o,n),n}function vO(e,t){const n={},r=y(e,["displayName"]);return t!==void 0&&r!=null&&x(t,["batch","displayName"],r),n}function xO(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["_url","model"],tt(e,r));const i=y(t,["src"]);i!=null&&x(n,["batch","inputConfig"],EO(e,i));const o=y(t,["config"]);return o!=null&&vO(o,n),n}function bO(e,t){const n={},r=y(t,["name"]);return r!=null&&x(n,["_url","name"],ac(e,r)),n}function wO(e,t){const n={},r=y(t,["name"]);return r!=null&&x(n,["_url","name"],ac(e,r)),n}function SO(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["name"]);r!=null&&x(t,["name"],r);const i=y(e,["done"]);i!=null&&x(t,["done"],i);const o=y(e,["error"]);return o!=null&&x(t,["error"],o),t}function AO(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["name"]);r!=null&&x(t,["name"],r);const i=y(e,["done"]);i!=null&&x(t,["done"],i);const o=y(e,["error"]);return o!=null&&x(t,["error"],o),t}function CO(e,t){const n={},r=y(t,["contents"]);if(r!=null){let o=kx(e,r);Array.isArray(o)&&(o=o.map(c=>c)),x(n,["requests[]","request","content"],o)}const i=y(t,["config"]);return i!=null&&(x(n,["_self"],TO(i,n)),wR(n,{"requests[].*":"requests[].request.*"})),n}function TO(e,t){const n={},r=y(e,["taskType"]);t!==void 0&&r!=null&&x(t,["requests[]","taskType"],r);const i=y(e,["title"]);t!==void 0&&i!=null&&x(t,["requests[]","title"],i);const o=y(e,["outputDimensionality"]);if(t!==void 0&&o!=null&&x(t,["requests[]","outputDimensionality"],o),y(e,["mimeType"])!==void 0)throw new Error("mimeType parameter is not supported in Gemini API.");if(y(e,["autoTruncate"])!==void 0)throw new Error("autoTruncate parameter is not supported in Gemini API.");return n}function EO(e,t){const n={},r=y(t,["fileName"]);r!=null&&x(n,["file_name"],r);const i=y(t,["inlinedRequests"]);return i!=null&&x(n,["requests"],CO(e,i)),n}function NO(e){const t={};if(y(e,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const n=y(e,["fileUri"]);n!=null&&x(t,["fileUri"],n);const r=y(e,["mimeType"]);return r!=null&&x(t,["mimeType"],r),t}function _O(e){const t={},n=y(e,["id"]);n!=null&&x(t,["id"],n);const r=y(e,["args"]);r!=null&&x(t,["args"],r);const i=y(e,["name"]);if(i!=null&&x(t,["name"],i),y(e,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(y(e,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return t}function jO(e){const t={},n=y(e,["mode"]);n!=null&&x(t,["mode"],n);const r=y(e,["allowedFunctionNames"]);if(r!=null&&x(t,["allowedFunctionNames"],r),y(e,["streamFunctionCallArguments"])!==void 0)throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return t}function MO(e,t,n){const r={},i=y(t,["systemInstruction"]);n!==void 0&&i!=null&&x(n,["systemInstruction"],f3(Ln(i)));const o=y(t,["temperature"]);o!=null&&x(r,["temperature"],o);const c=y(t,["topP"]);c!=null&&x(r,["topP"],c);const u=y(t,["topK"]);u!=null&&x(r,["topK"],u);const m=y(t,["candidateCount"]);m!=null&&x(r,["candidateCount"],m);const f=y(t,["maxOutputTokens"]);f!=null&&x(r,["maxOutputTokens"],f);const h=y(t,["stopSequences"]);h!=null&&x(r,["stopSequences"],h);const g=y(t,["responseLogprobs"]);g!=null&&x(r,["responseLogprobs"],g);const v=y(t,["logprobs"]);v!=null&&x(r,["logprobs"],v);const b=y(t,["presencePenalty"]);b!=null&&x(r,["presencePenalty"],b);const T=y(t,["frequencyPenalty"]);T!=null&&x(r,["frequencyPenalty"],T);const C=y(t,["seed"]);C!=null&&x(r,["seed"],C);const E=y(t,["responseMimeType"]);E!=null&&x(r,["responseMimeType"],E);const N=y(t,["responseSchema"]);N!=null&&x(r,["responseSchema"],Dx(N));const I=y(t,["responseJsonSchema"]);if(I!=null&&x(r,["responseJsonSchema"],I),y(t,["routingConfig"])!==void 0)throw new Error("routingConfig parameter is not supported in Gemini API.");if(y(t,["modelSelectionConfig"])!==void 0)throw new Error("modelSelectionConfig parameter is not supported in Gemini API.");const P=y(t,["safetySettings"]);if(n!==void 0&&P!=null){let V=P;Array.isArray(V)&&(V=V.map(oe=>VO(oe))),x(n,["safetySettings"],V)}const M=y(t,["tools"]);if(n!==void 0&&M!=null){let V=ic(M);Array.isArray(V)&&(V=V.map(oe=>YO(rc(oe)))),x(n,["tools"],V)}const j=y(t,["toolConfig"]);if(n!==void 0&&j!=null&&x(n,["toolConfig"],KO(j)),y(t,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const k=y(t,["cachedContent"]);n!==void 0&&k!=null&&x(n,["cachedContent"],Aa(e,k));const R=y(t,["responseModalities"]);R!=null&&x(r,["responseModalities"],R);const F=y(t,["mediaResolution"]);F!=null&&x(r,["mediaResolution"],F);const q=y(t,["speechConfig"]);if(q!=null&&x(r,["speechConfig"],Rx(q)),y(t,["audioTimestamp"])!==void 0)throw new Error("audioTimestamp parameter is not supported in Gemini API.");const G=y(t,["thinkingConfig"]);G!=null&&x(r,["thinkingConfig"],G);const H=y(t,["imageConfig"]);return H!=null&&x(r,["imageConfig"],OO(H)),r}function PO(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["candidates"]);if(r!=null){let m=r;Array.isArray(m)&&(m=m.map(f=>mO(f))),x(t,["candidates"],m)}const i=y(e,["modelVersion"]);i!=null&&x(t,["modelVersion"],i);const o=y(e,["promptFeedback"]);o!=null&&x(t,["promptFeedback"],o);const c=y(e,["responseId"]);c!=null&&x(t,["responseId"],c);const u=y(e,["usageMetadata"]);return u!=null&&x(t,["usageMetadata"],u),t}function IO(e,t){const n={},r=y(t,["name"]);return r!=null&&x(n,["_url","name"],ac(e,r)),n}function kO(e,t){const n={},r=y(t,["name"]);return r!=null&&x(n,["_url","name"],ac(e,r)),n}function DO(e){const t={};if(y(e,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const n=y(e,["enableWidget"]);return n!=null&&x(t,["enableWidget"],n),t}function RO(e){const t={};if(y(e,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(y(e,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const n=y(e,["timeRangeFilter"]);return n!=null&&x(t,["timeRangeFilter"],n),t}function OO(e){const t={},n=y(e,["aspectRatio"]);n!=null&&x(t,["aspectRatio"],n);const r=y(e,["imageSize"]);if(r!=null&&x(t,["imageSize"],r),y(e,["outputMimeType"])!==void 0)throw new Error("outputMimeType parameter is not supported in Gemini API.");if(y(e,["outputCompressionQuality"])!==void 0)throw new Error("outputCompressionQuality parameter is not supported in Gemini API.");return t}function LO(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["request","model"],tt(e,r));const i=y(t,["contents"]);if(i!=null){let u=Hr(i);Array.isArray(u)&&(u=u.map(m=>f3(m))),x(n,["request","contents"],u)}const o=y(t,["metadata"]);o!=null&&x(n,["metadata"],o);const c=y(t,["config"]);return c!=null&&x(n,["request","generationConfig"],MO(e,c,y(n,["request"],{}))),n}function UO(e){const t={},n=y(e,["response"]);n!=null&&x(t,["response"],PO(n));const r=y(e,["error"]);return r!=null&&x(t,["error"],r),t}function BO(e,t){const n={},r=y(e,["pageSize"]);t!==void 0&&r!=null&&x(t,["_query","pageSize"],r);const i=y(e,["pageToken"]);if(t!==void 0&&i!=null&&x(t,["_query","pageToken"],i),y(e,["filter"])!==void 0)throw new Error("filter parameter is not supported in Gemini API.");return n}function zO(e,t){const n={},r=y(e,["pageSize"]);t!==void 0&&r!=null&&x(t,["_query","pageSize"],r);const i=y(e,["pageToken"]);t!==void 0&&i!=null&&x(t,["_query","pageToken"],i);const o=y(e,["filter"]);return t!==void 0&&o!=null&&x(t,["_query","filter"],o),n}function FO(e){const t={},n=y(e,["config"]);return n!=null&&BO(n,t),t}function qO(e){const t={},n=y(e,["config"]);return n!=null&&zO(n,t),t}function GO(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["nextPageToken"]);r!=null&&x(t,["nextPageToken"],r);const i=y(e,["operations"]);if(i!=null){let o=i;Array.isArray(o)&&(o=o.map(c=>nm(c))),x(t,["batchJobs"],o)}return t}function $O(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["nextPageToken"]);r!=null&&x(t,["nextPageToken"],r);const i=y(e,["batchPredictionJobs"]);if(i!=null){let o=i;Array.isArray(o)&&(o=o.map(c=>uv(c))),x(t,["batchJobs"],o)}return t}function HO(e){const t={},n=y(e,["mediaResolution"]);n!=null&&x(t,["mediaResolution"],n);const r=y(e,["codeExecutionResult"]);r!=null&&x(t,["codeExecutionResult"],r);const i=y(e,["executableCode"]);i!=null&&x(t,["executableCode"],i);const o=y(e,["fileData"]);o!=null&&x(t,["fileData"],NO(o));const c=y(e,["functionCall"]);c!=null&&x(t,["functionCall"],_O(c));const u=y(e,["functionResponse"]);u!=null&&x(t,["functionResponse"],u);const m=y(e,["inlineData"]);m!=null&&x(t,["inlineData"],uO(m));const f=y(e,["text"]);f!=null&&x(t,["text"],f);const h=y(e,["thought"]);h!=null&&x(t,["thought"],h);const g=y(e,["thoughtSignature"]);g!=null&&x(t,["thoughtSignature"],g);const v=y(e,["videoMetadata"]);return v!=null&&x(t,["videoMetadata"],v),t}function VO(e){const t={},n=y(e,["category"]);if(n!=null&&x(t,["category"],n),y(e,["method"])!==void 0)throw new Error("method parameter is not supported in Gemini API.");const r=y(e,["threshold"]);return r!=null&&x(t,["threshold"],r),t}function KO(e){const t={},n=y(e,["functionCallingConfig"]);n!=null&&x(t,["functionCallingConfig"],jO(n));const r=y(e,["retrievalConfig"]);return r!=null&&x(t,["retrievalConfig"],r),t}function YO(e){const t={},n=y(e,["functionDeclarations"]);if(n!=null){let h=n;Array.isArray(h)&&(h=h.map(g=>g)),x(t,["functionDeclarations"],h)}if(y(e,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const r=y(e,["googleSearchRetrieval"]);r!=null&&x(t,["googleSearchRetrieval"],r);const i=y(e,["computerUse"]);i!=null&&x(t,["computerUse"],i);const o=y(e,["fileSearch"]);o!=null&&x(t,["fileSearch"],o);const c=y(e,["codeExecution"]);if(c!=null&&x(t,["codeExecution"],c),y(e,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const u=y(e,["googleMaps"]);u!=null&&x(t,["googleMaps"],DO(u));const m=y(e,["googleSearch"]);m!=null&&x(t,["googleSearch"],RO(m));const f=y(e,["urlContext"]);return f!=null&&x(t,["urlContext"],f),t}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */var ma;(function(e){e.PAGED_ITEM_BATCH_JOBS="batchJobs",e.PAGED_ITEM_MODELS="models",e.PAGED_ITEM_TUNING_JOBS="tuningJobs",e.PAGED_ITEM_FILES="files",e.PAGED_ITEM_CACHED_CONTENTS="cachedContents",e.PAGED_ITEM_FILE_SEARCH_STORES="fileSearchStores",e.PAGED_ITEM_DOCUMENTS="documents"})(ma||(ma={}));class ks{constructor(t,n,r,i){this.pageInternal=[],this.paramsInternal={},this.requestInternal=n,this.init(t,r,i)}init(t,n,r){var i,o;this.nameInternal=t,this.pageInternal=n[this.nameInternal]||[],this.sdkHttpResponseInternal=n==null?void 0:n.sdkHttpResponse,this.idxInternal=0;let c={config:{}};!r||Object.keys(r).length===0?c={config:{}}:typeof r=="object"?c=Object.assign({},r):c=r,c.config&&(c.config.pageToken=n.nextPageToken),this.paramsInternal=c,this.pageInternalSize=(o=(i=c.config)===null||i===void 0?void 0:i.pageSize)!==null&&o!==void 0?o:this.pageInternal.length}initNextPage(t){this.init(this.nameInternal,t,this.paramsInternal)}get page(){return this.pageInternal}get name(){return this.nameInternal}get pageSize(){return this.pageInternalSize}get sdkHttpResponse(){return this.sdkHttpResponseInternal}get params(){return this.paramsInternal}get pageLength(){return this.pageInternal.length}getItem(t){return this.pageInternal[t]}[Symbol.asyncIterator](){return{next:async()=>{if(this.idxInternal>=this.pageLength)if(this.hasNextPage())await this.nextPage();else return{value:void 0,done:!0};const t=this.getItem(this.idxInternal);return this.idxInternal+=1,{value:t,done:!1}},return:async()=>({value:void 0,done:!0})}}async nextPage(){if(!this.hasNextPage())throw new Error("No more pages to fetch.");const t=await this.requestInternal(this.params);return this.initNextPage(t),this.page}hasNextPage(){var t;return((t=this.params.config)===null||t===void 0?void 0:t.pageToken)!==void 0}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class WO extends Sa{constructor(t){super(),this.apiClient=t,this.create=async n=>(this.apiClient.isVertexAI()&&(n.config=this.formatDestination(n.src,n.config)),this.createInternal(n)),this.createEmbeddings=async n=>{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(n)},this.list=async(n={})=>new ks(ma.PAGED_ITEM_BATCH_JOBS,r=>this.listInternal(r),await this.listInternal(n),n)}createInlinedGenerateContentRequest(t){const n=HC(this.apiClient,t),r=n._url,i=be("{model}:batchGenerateContent",r),u=n.batch.inputConfig.requests,m=u.requests,f=[];for(const h of m){const g=Object.assign({},h);if(g.systemInstruction){const v=g.systemInstruction;delete g.systemInstruction;const b=g.request;b.systemInstruction=v,g.request=b}f.push(g)}return u.requests=f,delete n.config,delete n._url,delete n._query,{path:i,body:n}}getGcsUri(t){if(typeof t=="string")return t.startsWith("gs://")?t:void 0;if(!Array.isArray(t)&&t.gcsUri&&t.gcsUri.length>0)return t.gcsUri[0]}getBigqueryUri(t){if(typeof t=="string")return t.startsWith("bq://")?t:void 0;if(!Array.isArray(t))return t.bigqueryUri}formatDestination(t,n){const r=n?Object.assign({},n):{},i=Date.now().toString();if(r.displayName||(r.displayName=`genaiBatchJob_${i}`),r.dest===void 0){const o=this.getGcsUri(t),c=this.getBigqueryUri(t);if(o)o.endsWith(".jsonl")?r.dest=`${o.slice(0,-6)}/dest`:r.dest=`${o}_dest_${i}`;else if(c)r.dest=`${c}_dest_${i}`;else throw new Error("Unsupported source for Vertex AI: No GCS or BigQuery URI found.")}return r}async createInternal(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=yO(this.apiClient,t);return u=be("batchPredictionJobs",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json()),c.then(h=>uv(h))}else{const f=HC(this.apiClient,t);return u=be("{model}:batchGenerateContent",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json()),c.then(h=>nm(h))}}async createEmbeddingsInternal(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=xO(this.apiClient,t);return o=be("{model}:asyncBatchEmbedContent",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json()),i.then(m=>nm(m))}}async get(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=kO(this.apiClient,t);return u=be("batchPredictionJobs/{name}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json()),c.then(h=>uv(h))}else{const f=IO(this.apiClient,t);return u=be("batches/{name}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json()),c.then(h=>nm(h))}}async cancel(t){var n,r,i,o;let c="",u={};if(this.apiClient.isVertexAI()){const m=fO(this.apiClient,t);c=be("batchPredictionJobs/{name}:cancel",m._url),u=m._query,delete m._url,delete m._query,await this.apiClient.request({path:c,queryParams:u,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal})}else{const m=dO(this.apiClient,t);c=be("batches/{name}:cancel",m._url),u=m._query,delete m._url,delete m._query,await this.apiClient.request({path:c,queryParams:u,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal})}}async listInternal(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=qO(t);return u=be("batchPredictionJobs",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=$O(h),v=new FC;return Object.assign(v,g),v})}else{const f=FO(t);return u=be("batches",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=GO(h),v=new FC;return Object.assign(v,g),v})}}async delete(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=wO(this.apiClient,t);return u=be("batchPredictionJobs/{name}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"DELETE",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>AO(h))}else{const f=bO(this.apiClient,t);return u=be("batches/{name}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"DELETE",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>SO(h))}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function JO(e){const t={},n=y(e,["data"]);if(n!=null&&x(t,["data"],n),y(e,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const r=y(e,["mimeType"]);return r!=null&&x(t,["mimeType"],r),t}function VC(e){const t={},n=y(e,["parts"]);if(n!=null){let i=n;Array.isArray(i)&&(i=i.map(o=>x6(o))),x(t,["parts"],i)}const r=y(e,["role"]);return r!=null&&x(t,["role"],r),t}function QO(e,t){const n={},r=y(e,["ttl"]);t!==void 0&&r!=null&&x(t,["ttl"],r);const i=y(e,["expireTime"]);t!==void 0&&i!=null&&x(t,["expireTime"],i);const o=y(e,["displayName"]);t!==void 0&&o!=null&&x(t,["displayName"],o);const c=y(e,["contents"]);if(t!==void 0&&c!=null){let h=Hr(c);Array.isArray(h)&&(h=h.map(g=>VC(g))),x(t,["contents"],h)}const u=y(e,["systemInstruction"]);t!==void 0&&u!=null&&x(t,["systemInstruction"],VC(Ln(u)));const m=y(e,["tools"]);if(t!==void 0&&m!=null){let h=m;Array.isArray(h)&&(h=h.map(g=>w6(g))),x(t,["tools"],h)}const f=y(e,["toolConfig"]);if(t!==void 0&&f!=null&&x(t,["toolConfig"],b6(f)),y(e,["kmsKeyName"])!==void 0)throw new Error("kmsKeyName parameter is not supported in Gemini API.");return n}function XO(e,t){const n={},r=y(e,["ttl"]);t!==void 0&&r!=null&&x(t,["ttl"],r);const i=y(e,["expireTime"]);t!==void 0&&i!=null&&x(t,["expireTime"],i);const o=y(e,["displayName"]);t!==void 0&&o!=null&&x(t,["displayName"],o);const c=y(e,["contents"]);if(t!==void 0&&c!=null){let g=Hr(c);Array.isArray(g)&&(g=g.map(v=>v)),x(t,["contents"],g)}const u=y(e,["systemInstruction"]);t!==void 0&&u!=null&&x(t,["systemInstruction"],Ln(u));const m=y(e,["tools"]);if(t!==void 0&&m!=null){let g=m;Array.isArray(g)&&(g=g.map(v=>S6(v))),x(t,["tools"],g)}const f=y(e,["toolConfig"]);t!==void 0&&f!=null&&x(t,["toolConfig"],f);const h=y(e,["kmsKeyName"]);return t!==void 0&&h!=null&&x(t,["encryption_spec","kmsKeyName"],h),n}function ZO(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["model"],e3(e,r));const i=y(t,["config"]);return i!=null&&QO(i,n),n}function e6(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["model"],e3(e,r));const i=y(t,["config"]);return i!=null&&XO(i,n),n}function t6(e,t){const n={},r=y(t,["name"]);return r!=null&&x(n,["_url","name"],Aa(e,r)),n}function n6(e,t){const n={},r=y(t,["name"]);return r!=null&&x(n,["_url","name"],Aa(e,r)),n}function r6(e){const t={},n=y(e,["sdkHttpResponse"]);return n!=null&&x(t,["sdkHttpResponse"],n),t}function i6(e){const t={},n=y(e,["sdkHttpResponse"]);return n!=null&&x(t,["sdkHttpResponse"],n),t}function a6(e){const t={};if(y(e,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const n=y(e,["fileUri"]);n!=null&&x(t,["fileUri"],n);const r=y(e,["mimeType"]);return r!=null&&x(t,["mimeType"],r),t}function o6(e){const t={},n=y(e,["id"]);n!=null&&x(t,["id"],n);const r=y(e,["args"]);r!=null&&x(t,["args"],r);const i=y(e,["name"]);if(i!=null&&x(t,["name"],i),y(e,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(y(e,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return t}function s6(e){const t={},n=y(e,["mode"]);n!=null&&x(t,["mode"],n);const r=y(e,["allowedFunctionNames"]);if(r!=null&&x(t,["allowedFunctionNames"],r),y(e,["streamFunctionCallArguments"])!==void 0)throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return t}function l6(e){const t={};if(y(e,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");const n=y(e,["description"]);n!=null&&x(t,["description"],n);const r=y(e,["name"]);r!=null&&x(t,["name"],r);const i=y(e,["parameters"]);i!=null&&x(t,["parameters"],i);const o=y(e,["parametersJsonSchema"]);o!=null&&x(t,["parametersJsonSchema"],o);const c=y(e,["response"]);c!=null&&x(t,["response"],c);const u=y(e,["responseJsonSchema"]);return u!=null&&x(t,["responseJsonSchema"],u),t}function c6(e,t){const n={},r=y(t,["name"]);return r!=null&&x(n,["_url","name"],Aa(e,r)),n}function u6(e,t){const n={},r=y(t,["name"]);return r!=null&&x(n,["_url","name"],Aa(e,r)),n}function d6(e){const t={};if(y(e,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const n=y(e,["enableWidget"]);return n!=null&&x(t,["enableWidget"],n),t}function f6(e){const t={};if(y(e,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(y(e,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const n=y(e,["timeRangeFilter"]);return n!=null&&x(t,["timeRangeFilter"],n),t}function m6(e,t){const n={},r=y(e,["pageSize"]);t!==void 0&&r!=null&&x(t,["_query","pageSize"],r);const i=y(e,["pageToken"]);return t!==void 0&&i!=null&&x(t,["_query","pageToken"],i),n}function h6(e,t){const n={},r=y(e,["pageSize"]);t!==void 0&&r!=null&&x(t,["_query","pageSize"],r);const i=y(e,["pageToken"]);return t!==void 0&&i!=null&&x(t,["_query","pageToken"],i),n}function p6(e){const t={},n=y(e,["config"]);return n!=null&&m6(n,t),t}function g6(e){const t={},n=y(e,["config"]);return n!=null&&h6(n,t),t}function y6(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["nextPageToken"]);r!=null&&x(t,["nextPageToken"],r);const i=y(e,["cachedContents"]);if(i!=null){let o=i;Array.isArray(o)&&(o=o.map(c=>c)),x(t,["cachedContents"],o)}return t}function v6(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["nextPageToken"]);r!=null&&x(t,["nextPageToken"],r);const i=y(e,["cachedContents"]);if(i!=null){let o=i;Array.isArray(o)&&(o=o.map(c=>c)),x(t,["cachedContents"],o)}return t}function x6(e){const t={},n=y(e,["mediaResolution"]);n!=null&&x(t,["mediaResolution"],n);const r=y(e,["codeExecutionResult"]);r!=null&&x(t,["codeExecutionResult"],r);const i=y(e,["executableCode"]);i!=null&&x(t,["executableCode"],i);const o=y(e,["fileData"]);o!=null&&x(t,["fileData"],a6(o));const c=y(e,["functionCall"]);c!=null&&x(t,["functionCall"],o6(c));const u=y(e,["functionResponse"]);u!=null&&x(t,["functionResponse"],u);const m=y(e,["inlineData"]);m!=null&&x(t,["inlineData"],JO(m));const f=y(e,["text"]);f!=null&&x(t,["text"],f);const h=y(e,["thought"]);h!=null&&x(t,["thought"],h);const g=y(e,["thoughtSignature"]);g!=null&&x(t,["thoughtSignature"],g);const v=y(e,["videoMetadata"]);return v!=null&&x(t,["videoMetadata"],v),t}function b6(e){const t={},n=y(e,["functionCallingConfig"]);n!=null&&x(t,["functionCallingConfig"],s6(n));const r=y(e,["retrievalConfig"]);return r!=null&&x(t,["retrievalConfig"],r),t}function w6(e){const t={},n=y(e,["functionDeclarations"]);if(n!=null){let h=n;Array.isArray(h)&&(h=h.map(g=>g)),x(t,["functionDeclarations"],h)}if(y(e,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const r=y(e,["googleSearchRetrieval"]);r!=null&&x(t,["googleSearchRetrieval"],r);const i=y(e,["computerUse"]);i!=null&&x(t,["computerUse"],i);const o=y(e,["fileSearch"]);o!=null&&x(t,["fileSearch"],o);const c=y(e,["codeExecution"]);if(c!=null&&x(t,["codeExecution"],c),y(e,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const u=y(e,["googleMaps"]);u!=null&&x(t,["googleMaps"],d6(u));const m=y(e,["googleSearch"]);m!=null&&x(t,["googleSearch"],f6(m));const f=y(e,["urlContext"]);return f!=null&&x(t,["urlContext"],f),t}function S6(e){const t={},n=y(e,["functionDeclarations"]);if(n!=null){let g=n;Array.isArray(g)&&(g=g.map(v=>l6(v))),x(t,["functionDeclarations"],g)}const r=y(e,["retrieval"]);r!=null&&x(t,["retrieval"],r);const i=y(e,["googleSearchRetrieval"]);i!=null&&x(t,["googleSearchRetrieval"],i);const o=y(e,["computerUse"]);if(o!=null&&x(t,["computerUse"],o),y(e,["fileSearch"])!==void 0)throw new Error("fileSearch parameter is not supported in Vertex AI.");const c=y(e,["codeExecution"]);c!=null&&x(t,["codeExecution"],c);const u=y(e,["enterpriseWebSearch"]);u!=null&&x(t,["enterpriseWebSearch"],u);const m=y(e,["googleMaps"]);m!=null&&x(t,["googleMaps"],m);const f=y(e,["googleSearch"]);f!=null&&x(t,["googleSearch"],f);const h=y(e,["urlContext"]);return h!=null&&x(t,["urlContext"],h),t}function A6(e,t){const n={},r=y(e,["ttl"]);t!==void 0&&r!=null&&x(t,["ttl"],r);const i=y(e,["expireTime"]);return t!==void 0&&i!=null&&x(t,["expireTime"],i),n}function C6(e,t){const n={},r=y(e,["ttl"]);t!==void 0&&r!=null&&x(t,["ttl"],r);const i=y(e,["expireTime"]);return t!==void 0&&i!=null&&x(t,["expireTime"],i),n}function T6(e,t){const n={},r=y(t,["name"]);r!=null&&x(n,["_url","name"],Aa(e,r));const i=y(t,["config"]);return i!=null&&A6(i,n),n}function E6(e,t){const n={},r=y(t,["name"]);r!=null&&x(n,["_url","name"],Aa(e,r));const i=y(t,["config"]);return i!=null&&C6(i,n),n}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class N6 extends Sa{constructor(t){super(),this.apiClient=t,this.list=async(n={})=>new ks(ma.PAGED_ITEM_CACHED_CONTENTS,r=>this.listInternal(r),await this.listInternal(n),n)}async create(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=e6(this.apiClient,t);return u=be("cachedContents",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json()),c.then(h=>h)}else{const f=ZO(this.apiClient,t);return u=be("cachedContents",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json()),c.then(h=>h)}}async get(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=u6(this.apiClient,t);return u=be("{name}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json()),c.then(h=>h)}else{const f=c6(this.apiClient,t);return u=be("{name}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json()),c.then(h=>h)}}async delete(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=n6(this.apiClient,t);return u=be("{name}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"DELETE",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=i6(h),v=new BC;return Object.assign(v,g),v})}else{const f=t6(this.apiClient,t);return u=be("{name}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"DELETE",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=r6(h),v=new BC;return Object.assign(v,g),v})}}async update(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=E6(this.apiClient,t);return u=be("{name}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"PATCH",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json()),c.then(h=>h)}else{const f=T6(this.apiClient,t);return u=be("{name}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"PATCH",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json()),c.then(h=>h)}}async listInternal(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=g6(t);return u=be("cachedContents",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=v6(h),v=new zC;return Object.assign(v,g),v})}else{const f=p6(t);return u=be("cachedContents",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=y6(h),v=new zC;return Object.assign(v,g),v})}}}function KC(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Nt(e){return this instanceof Nt?(this.v=e,this):new Nt(e)}function kl(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,o=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),u("next"),u("throw"),u("return",c),i[Symbol.asyncIterator]=function(){return this},i;function c(b){return function(T){return Promise.resolve(T).then(b,g)}}function u(b,T){r[b]&&(i[b]=function(C){return new Promise(function(E,N){o.push([b,C,E,N])>1||m(b,C)})},T&&(i[b]=T(i[b])))}function m(b,T){try{f(r[b](T))}catch(C){v(o[0][3],C)}}function f(b){b.value instanceof Nt?Promise.resolve(b.value.v).then(h,g):v(o[0][2],b)}function h(b){m("next",b)}function g(b){m("throw",b)}function v(b,T){b(T),o.shift(),o.length&&m(o[0][0],o[0][1])}}function _u(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof KC=="function"?KC(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(o){n[o]=e[o]&&function(c){return new Promise(function(u,m){c=e[o](c),i(u,m,c.done,c.value)})}}function i(o,c,u,m){Promise.resolve(m).then(function(f){o({value:f,done:u})},c)}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function _6(e){var t;if(e.candidates==null||e.candidates.length===0)return!1;const n=(t=e.candidates[0])===null||t===void 0?void 0:t.content;return n===void 0?!1:m3(n)}function m3(e){if(e.parts===void 0||e.parts.length===0)return!1;for(const t of e.parts)if(t===void 0||Object.keys(t).length===0)return!1;return!0}function j6(e){if(e.length!==0){for(const t of e)if(t.role!=="user"&&t.role!=="model")throw new Error(`Role must be user or model, but got ${t.role}.`)}}function YC(e){if(e===void 0||e.length===0)return[];const t=[],n=e.length;let r=0;for(;r{var o,c,u;const m=await i,f=(c=(o=m.candidates)===null||o===void 0?void 0:o[0])===null||c===void 0?void 0:c.content,h=m.automaticFunctionCallingHistory,g=this.getHistory(!0).length;let v=[];h!=null&&(v=(u=h.slice(g))!==null&&u!==void 0?u:[]);const b=f?[f]:[];this.recordHistory(r,b,v)})(),await this.sendPromise.catch(()=>{this.sendPromise=Promise.resolve()}),i}async sendMessageStream(t){var n;await this.sendPromise;const r=Ln(t.message),i=this.modelsModule.generateContentStream({model:this.model,contents:this.getHistory(!0).concat(r),config:(n=t.config)!==null&&n!==void 0?n:this.config});this.sendPromise=i.then(()=>{}).catch(()=>{});const o=await i;return this.processStreamResponse(o,r)}getHistory(t=!1){const n=t?YC(this.history):this.history;return structuredClone(n)}processStreamResponse(t,n){var r,i;return kl(this,arguments,function*(){var c,u,m,f;const h=[];try{for(var g=!0,v=_u(t),b;b=yield Nt(v.next()),c=b.done,!c;g=!0){f=b.value,g=!1;const T=f;if(_6(T)){const C=(i=(r=T.candidates)===null||r===void 0?void 0:r[0])===null||i===void 0?void 0:i.content;C!==void 0&&h.push(C)}yield yield Nt(T)}}catch(T){u={error:T}}finally{try{!g&&!c&&(m=v.return)&&(yield Nt(m.call(v)))}finally{if(u)throw u.error}}this.recordHistory(n,h)})}recordHistory(t,n,r){let i=[];n.length>0&&n.every(o=>o.role!==void 0)?i=n:i.push({role:"model",parts:[]}),r&&r.length>0?this.history.push(...YC(r)):this.history.push(t),this.history.push(...i)}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class sh extends Error{constructor(t){super(t.message),this.name="ApiError",this.status=t.status,Object.setPrototypeOf(this,sh.prototype)}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function I6(e){const t={},n=y(e,["file"]);return n!=null&&x(t,["file"],n),t}function k6(e){const t={},n=y(e,["sdkHttpResponse"]);return n!=null&&x(t,["sdkHttpResponse"],n),t}function D6(e){const t={},n=y(e,["name"]);return n!=null&&x(t,["_url","file"],o3(n)),t}function R6(e){const t={},n=y(e,["sdkHttpResponse"]);return n!=null&&x(t,["sdkHttpResponse"],n),t}function O6(e){const t={},n=y(e,["name"]);return n!=null&&x(t,["_url","file"],o3(n)),t}function L6(e,t){const n={},r=y(e,["pageSize"]);t!==void 0&&r!=null&&x(t,["_query","pageSize"],r);const i=y(e,["pageToken"]);return t!==void 0&&i!=null&&x(t,["_query","pageToken"],i),n}function U6(e){const t={},n=y(e,["config"]);return n!=null&&L6(n,t),t}function B6(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["nextPageToken"]);r!=null&&x(t,["nextPageToken"],r);const i=y(e,["files"]);if(i!=null){let o=i;Array.isArray(o)&&(o=o.map(c=>c)),x(t,["files"],o)}return t}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class z6 extends Sa{constructor(t){super(),this.apiClient=t,this.list=async(n={})=>new ks(ma.PAGED_ITEM_FILES,r=>this.listInternal(r),await this.listInternal(n),n)}async upload(t){if(this.apiClient.isVertexAI())throw new Error("Vertex AI does not support uploading files. You can share files through a GCS bucket.");return this.apiClient.uploadFile(t.file,t.config).then(n=>n)}async download(t){await this.apiClient.downloadFile(t)}async listInternal(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=U6(t);return o=be("files",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"GET",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json().then(f=>{const h=f;return h.sdkHttpResponse={headers:m.headers},h})),i.then(m=>{const f=B6(m),h=new $R;return Object.assign(h,f),h})}}async createInternal(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=I6(t);return o=be("upload/v1beta/files",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json()),i.then(m=>{const f=k6(m),h=new HR;return Object.assign(h,f),h})}}async get(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=O6(t);return o=be("files/{file}",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"GET",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json()),i.then(m=>m)}}async delete(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=D6(t);return o=be("files/{file}",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"DELETE",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json().then(f=>{const h=f;return h.sdkHttpResponse={headers:m.headers},h})),i.then(m=>{const f=R6(m),h=new VR;return Object.assign(h,f),h})}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function rm(e){const t={},n=y(e,["data"]);if(n!=null&&x(t,["data"],n),y(e,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const r=y(e,["mimeType"]);return r!=null&&x(t,["mimeType"],r),t}function F6(e){const t={},n=y(e,["parts"]);if(n!=null){let i=n;Array.isArray(i)&&(i=i.map(o=>rL(o))),x(t,["parts"],i)}const r=y(e,["role"]);return r!=null&&x(t,["role"],r),t}function q6(e){const t={};if(y(e,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const n=y(e,["fileUri"]);n!=null&&x(t,["fileUri"],n);const r=y(e,["mimeType"]);return r!=null&&x(t,["mimeType"],r),t}function G6(e){const t={},n=y(e,["id"]);n!=null&&x(t,["id"],n);const r=y(e,["args"]);r!=null&&x(t,["args"],r);const i=y(e,["name"]);if(i!=null&&x(t,["name"],i),y(e,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(y(e,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return t}function $6(e){const t={};if(y(e,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");const n=y(e,["description"]);n!=null&&x(t,["description"],n);const r=y(e,["name"]);r!=null&&x(t,["name"],r);const i=y(e,["parameters"]);i!=null&&x(t,["parameters"],i);const o=y(e,["parametersJsonSchema"]);o!=null&&x(t,["parametersJsonSchema"],o);const c=y(e,["response"]);c!=null&&x(t,["response"],c);const u=y(e,["responseJsonSchema"]);return u!=null&&x(t,["responseJsonSchema"],u),t}function H6(e){const t={},n=y(e,["modelSelectionConfig"]);n!=null&&x(t,["modelConfig"],n);const r=y(e,["responseJsonSchema"]);r!=null&&x(t,["responseJsonSchema"],r);const i=y(e,["audioTimestamp"]);i!=null&&x(t,["audioTimestamp"],i);const o=y(e,["candidateCount"]);o!=null&&x(t,["candidateCount"],o);const c=y(e,["enableAffectiveDialog"]);c!=null&&x(t,["enableAffectiveDialog"],c);const u=y(e,["frequencyPenalty"]);u!=null&&x(t,["frequencyPenalty"],u);const m=y(e,["logprobs"]);m!=null&&x(t,["logprobs"],m);const f=y(e,["maxOutputTokens"]);f!=null&&x(t,["maxOutputTokens"],f);const h=y(e,["mediaResolution"]);h!=null&&x(t,["mediaResolution"],h);const g=y(e,["presencePenalty"]);g!=null&&x(t,["presencePenalty"],g);const v=y(e,["responseLogprobs"]);v!=null&&x(t,["responseLogprobs"],v);const b=y(e,["responseMimeType"]);b!=null&&x(t,["responseMimeType"],b);const T=y(e,["responseModalities"]);T!=null&&x(t,["responseModalities"],T);const C=y(e,["responseSchema"]);C!=null&&x(t,["responseSchema"],C);const E=y(e,["routingConfig"]);E!=null&&x(t,["routingConfig"],E);const N=y(e,["seed"]);N!=null&&x(t,["seed"],N);const I=y(e,["speechConfig"]);I!=null&&x(t,["speechConfig"],h3(I));const P=y(e,["stopSequences"]);P!=null&&x(t,["stopSequences"],P);const M=y(e,["temperature"]);M!=null&&x(t,["temperature"],M);const j=y(e,["thinkingConfig"]);j!=null&&x(t,["thinkingConfig"],j);const k=y(e,["topK"]);k!=null&&x(t,["topK"],k);const R=y(e,["topP"]);if(R!=null&&x(t,["topP"],R),y(e,["enableEnhancedCivicAnswers"])!==void 0)throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");return t}function V6(e){const t={};if(y(e,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const n=y(e,["enableWidget"]);return n!=null&&x(t,["enableWidget"],n),t}function K6(e){const t={};if(y(e,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(y(e,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const n=y(e,["timeRangeFilter"]);return n!=null&&x(t,["timeRangeFilter"],n),t}function Y6(e,t){const n={},r=y(e,["generationConfig"]);t!==void 0&&r!=null&&x(t,["setup","generationConfig"],r);const i=y(e,["responseModalities"]);t!==void 0&&i!=null&&x(t,["setup","generationConfig","responseModalities"],i);const o=y(e,["temperature"]);t!==void 0&&o!=null&&x(t,["setup","generationConfig","temperature"],o);const c=y(e,["topP"]);t!==void 0&&c!=null&&x(t,["setup","generationConfig","topP"],c);const u=y(e,["topK"]);t!==void 0&&u!=null&&x(t,["setup","generationConfig","topK"],u);const m=y(e,["maxOutputTokens"]);t!==void 0&&m!=null&&x(t,["setup","generationConfig","maxOutputTokens"],m);const f=y(e,["mediaResolution"]);t!==void 0&&f!=null&&x(t,["setup","generationConfig","mediaResolution"],f);const h=y(e,["seed"]);t!==void 0&&h!=null&&x(t,["setup","generationConfig","seed"],h);const g=y(e,["speechConfig"]);t!==void 0&&g!=null&&x(t,["setup","generationConfig","speechConfig"],Ox(g));const v=y(e,["thinkingConfig"]);t!==void 0&&v!=null&&x(t,["setup","generationConfig","thinkingConfig"],v);const b=y(e,["enableAffectiveDialog"]);t!==void 0&&b!=null&&x(t,["setup","generationConfig","enableAffectiveDialog"],b);const T=y(e,["systemInstruction"]);t!==void 0&&T!=null&&x(t,["setup","systemInstruction"],F6(Ln(T)));const C=y(e,["tools"]);if(t!==void 0&&C!=null){let k=ic(C);Array.isArray(k)&&(k=k.map(R=>aL(rc(R)))),x(t,["setup","tools"],k)}const E=y(e,["sessionResumption"]);t!==void 0&&E!=null&&x(t,["setup","sessionResumption"],iL(E));const N=y(e,["inputAudioTranscription"]);t!==void 0&&N!=null&&x(t,["setup","inputAudioTranscription"],N);const I=y(e,["outputAudioTranscription"]);t!==void 0&&I!=null&&x(t,["setup","outputAudioTranscription"],I);const P=y(e,["realtimeInputConfig"]);t!==void 0&&P!=null&&x(t,["setup","realtimeInputConfig"],P);const M=y(e,["contextWindowCompression"]);t!==void 0&&M!=null&&x(t,["setup","contextWindowCompression"],M);const j=y(e,["proactivity"]);return t!==void 0&&j!=null&&x(t,["setup","proactivity"],j),n}function W6(e,t){const n={},r=y(e,["generationConfig"]);t!==void 0&&r!=null&&x(t,["setup","generationConfig"],H6(r));const i=y(e,["responseModalities"]);t!==void 0&&i!=null&&x(t,["setup","generationConfig","responseModalities"],i);const o=y(e,["temperature"]);t!==void 0&&o!=null&&x(t,["setup","generationConfig","temperature"],o);const c=y(e,["topP"]);t!==void 0&&c!=null&&x(t,["setup","generationConfig","topP"],c);const u=y(e,["topK"]);t!==void 0&&u!=null&&x(t,["setup","generationConfig","topK"],u);const m=y(e,["maxOutputTokens"]);t!==void 0&&m!=null&&x(t,["setup","generationConfig","maxOutputTokens"],m);const f=y(e,["mediaResolution"]);t!==void 0&&f!=null&&x(t,["setup","generationConfig","mediaResolution"],f);const h=y(e,["seed"]);t!==void 0&&h!=null&&x(t,["setup","generationConfig","seed"],h);const g=y(e,["speechConfig"]);t!==void 0&&g!=null&&x(t,["setup","generationConfig","speechConfig"],h3(Ox(g)));const v=y(e,["thinkingConfig"]);t!==void 0&&v!=null&&x(t,["setup","generationConfig","thinkingConfig"],v);const b=y(e,["enableAffectiveDialog"]);t!==void 0&&b!=null&&x(t,["setup","generationConfig","enableAffectiveDialog"],b);const T=y(e,["systemInstruction"]);t!==void 0&&T!=null&&x(t,["setup","systemInstruction"],Ln(T));const C=y(e,["tools"]);if(t!==void 0&&C!=null){let k=ic(C);Array.isArray(k)&&(k=k.map(R=>oL(rc(R)))),x(t,["setup","tools"],k)}const E=y(e,["sessionResumption"]);t!==void 0&&E!=null&&x(t,["setup","sessionResumption"],E);const N=y(e,["inputAudioTranscription"]);t!==void 0&&N!=null&&x(t,["setup","inputAudioTranscription"],N);const I=y(e,["outputAudioTranscription"]);t!==void 0&&I!=null&&x(t,["setup","outputAudioTranscription"],I);const P=y(e,["realtimeInputConfig"]);t!==void 0&&P!=null&&x(t,["setup","realtimeInputConfig"],P);const M=y(e,["contextWindowCompression"]);t!==void 0&&M!=null&&x(t,["setup","contextWindowCompression"],M);const j=y(e,["proactivity"]);return t!==void 0&&j!=null&&x(t,["setup","proactivity"],j),n}function J6(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["setup","model"],tt(e,r));const i=y(t,["config"]);return i!=null&&x(n,["config"],Y6(i,n)),n}function Q6(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["setup","model"],tt(e,r));const i=y(t,["config"]);return i!=null&&x(n,["config"],W6(i,n)),n}function X6(e){const t={},n=y(e,["musicGenerationConfig"]);return n!=null&&x(t,["musicGenerationConfig"],n),t}function Z6(e){const t={},n=y(e,["weightedPrompts"]);if(n!=null){let r=n;Array.isArray(r)&&(r=r.map(i=>i)),x(t,["weightedPrompts"],r)}return t}function eL(e){const t={},n=y(e,["media"]);if(n!=null){let f=t3(n);Array.isArray(f)&&(f=f.map(h=>rm(h))),x(t,["mediaChunks"],f)}const r=y(e,["audio"]);r!=null&&x(t,["audio"],rm(r3(r)));const i=y(e,["audioStreamEnd"]);i!=null&&x(t,["audioStreamEnd"],i);const o=y(e,["video"]);o!=null&&x(t,["video"],rm(n3(o)));const c=y(e,["text"]);c!=null&&x(t,["text"],c);const u=y(e,["activityStart"]);u!=null&&x(t,["activityStart"],u);const m=y(e,["activityEnd"]);return m!=null&&x(t,["activityEnd"],m),t}function tL(e){const t={},n=y(e,["media"]);if(n!=null){let f=t3(n);Array.isArray(f)&&(f=f.map(h=>h)),x(t,["mediaChunks"],f)}const r=y(e,["audio"]);r!=null&&x(t,["audio"],r3(r));const i=y(e,["audioStreamEnd"]);i!=null&&x(t,["audioStreamEnd"],i);const o=y(e,["video"]);o!=null&&x(t,["video"],n3(o));const c=y(e,["text"]);c!=null&&x(t,["text"],c);const u=y(e,["activityStart"]);u!=null&&x(t,["activityStart"],u);const m=y(e,["activityEnd"]);return m!=null&&x(t,["activityEnd"],m),t}function nL(e){const t={},n=y(e,["setupComplete"]);n!=null&&x(t,["setupComplete"],n);const r=y(e,["serverContent"]);r!=null&&x(t,["serverContent"],r);const i=y(e,["toolCall"]);i!=null&&x(t,["toolCall"],i);const o=y(e,["toolCallCancellation"]);o!=null&&x(t,["toolCallCancellation"],o);const c=y(e,["usageMetadata"]);c!=null&&x(t,["usageMetadata"],sL(c));const u=y(e,["goAway"]);u!=null&&x(t,["goAway"],u);const m=y(e,["sessionResumptionUpdate"]);return m!=null&&x(t,["sessionResumptionUpdate"],m),t}function rL(e){const t={},n=y(e,["mediaResolution"]);n!=null&&x(t,["mediaResolution"],n);const r=y(e,["codeExecutionResult"]);r!=null&&x(t,["codeExecutionResult"],r);const i=y(e,["executableCode"]);i!=null&&x(t,["executableCode"],i);const o=y(e,["fileData"]);o!=null&&x(t,["fileData"],q6(o));const c=y(e,["functionCall"]);c!=null&&x(t,["functionCall"],G6(c));const u=y(e,["functionResponse"]);u!=null&&x(t,["functionResponse"],u);const m=y(e,["inlineData"]);m!=null&&x(t,["inlineData"],rm(m));const f=y(e,["text"]);f!=null&&x(t,["text"],f);const h=y(e,["thought"]);h!=null&&x(t,["thought"],h);const g=y(e,["thoughtSignature"]);g!=null&&x(t,["thoughtSignature"],g);const v=y(e,["videoMetadata"]);return v!=null&&x(t,["videoMetadata"],v),t}function iL(e){const t={},n=y(e,["handle"]);if(n!=null&&x(t,["handle"],n),y(e,["transparent"])!==void 0)throw new Error("transparent parameter is not supported in Gemini API.");return t}function h3(e){const t={},n=y(e,["languageCode"]);n!=null&&x(t,["languageCode"],n);const r=y(e,["voiceConfig"]);if(r!=null&&x(t,["voiceConfig"],r),y(e,["multiSpeakerVoiceConfig"])!==void 0)throw new Error("multiSpeakerVoiceConfig parameter is not supported in Vertex AI.");return t}function aL(e){const t={},n=y(e,["functionDeclarations"]);if(n!=null){let h=n;Array.isArray(h)&&(h=h.map(g=>g)),x(t,["functionDeclarations"],h)}if(y(e,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const r=y(e,["googleSearchRetrieval"]);r!=null&&x(t,["googleSearchRetrieval"],r);const i=y(e,["computerUse"]);i!=null&&x(t,["computerUse"],i);const o=y(e,["fileSearch"]);o!=null&&x(t,["fileSearch"],o);const c=y(e,["codeExecution"]);if(c!=null&&x(t,["codeExecution"],c),y(e,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const u=y(e,["googleMaps"]);u!=null&&x(t,["googleMaps"],V6(u));const m=y(e,["googleSearch"]);m!=null&&x(t,["googleSearch"],K6(m));const f=y(e,["urlContext"]);return f!=null&&x(t,["urlContext"],f),t}function oL(e){const t={},n=y(e,["functionDeclarations"]);if(n!=null){let g=n;Array.isArray(g)&&(g=g.map(v=>$6(v))),x(t,["functionDeclarations"],g)}const r=y(e,["retrieval"]);r!=null&&x(t,["retrieval"],r);const i=y(e,["googleSearchRetrieval"]);i!=null&&x(t,["googleSearchRetrieval"],i);const o=y(e,["computerUse"]);if(o!=null&&x(t,["computerUse"],o),y(e,["fileSearch"])!==void 0)throw new Error("fileSearch parameter is not supported in Vertex AI.");const c=y(e,["codeExecution"]);c!=null&&x(t,["codeExecution"],c);const u=y(e,["enterpriseWebSearch"]);u!=null&&x(t,["enterpriseWebSearch"],u);const m=y(e,["googleMaps"]);m!=null&&x(t,["googleMaps"],m);const f=y(e,["googleSearch"]);f!=null&&x(t,["googleSearch"],f);const h=y(e,["urlContext"]);return h!=null&&x(t,["urlContext"],h),t}function sL(e){const t={},n=y(e,["promptTokenCount"]);n!=null&&x(t,["promptTokenCount"],n);const r=y(e,["cachedContentTokenCount"]);r!=null&&x(t,["cachedContentTokenCount"],r);const i=y(e,["candidatesTokenCount"]);i!=null&&x(t,["responseTokenCount"],i);const o=y(e,["toolUsePromptTokenCount"]);o!=null&&x(t,["toolUsePromptTokenCount"],o);const c=y(e,["thoughtsTokenCount"]);c!=null&&x(t,["thoughtsTokenCount"],c);const u=y(e,["totalTokenCount"]);u!=null&&x(t,["totalTokenCount"],u);const m=y(e,["promptTokensDetails"]);if(m!=null){let b=m;Array.isArray(b)&&(b=b.map(T=>T)),x(t,["promptTokensDetails"],b)}const f=y(e,["cacheTokensDetails"]);if(f!=null){let b=f;Array.isArray(b)&&(b=b.map(T=>T)),x(t,["cacheTokensDetails"],b)}const h=y(e,["candidatesTokensDetails"]);if(h!=null){let b=h;Array.isArray(b)&&(b=b.map(T=>T)),x(t,["responseTokensDetails"],b)}const g=y(e,["toolUsePromptTokensDetails"]);if(g!=null){let b=g;Array.isArray(b)&&(b=b.map(T=>T)),x(t,["toolUsePromptTokensDetails"],b)}const v=y(e,["trafficType"]);return v!=null&&x(t,["trafficType"],v),t}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function lL(e){const t={},n=y(e,["data"]);if(n!=null&&x(t,["data"],n),y(e,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const r=y(e,["mimeType"]);return r!=null&&x(t,["mimeType"],r),t}function cL(e){const t={},n=y(e,["content"]);n!=null&&x(t,["content"],n);const r=y(e,["citationMetadata"]);r!=null&&x(t,["citationMetadata"],uL(r));const i=y(e,["tokenCount"]);i!=null&&x(t,["tokenCount"],i);const o=y(e,["finishReason"]);o!=null&&x(t,["finishReason"],o);const c=y(e,["avgLogprobs"]);c!=null&&x(t,["avgLogprobs"],c);const u=y(e,["groundingMetadata"]);u!=null&&x(t,["groundingMetadata"],u);const m=y(e,["index"]);m!=null&&x(t,["index"],m);const f=y(e,["logprobsResult"]);f!=null&&x(t,["logprobsResult"],f);const h=y(e,["safetyRatings"]);if(h!=null){let v=h;Array.isArray(v)&&(v=v.map(b=>b)),x(t,["safetyRatings"],v)}const g=y(e,["urlContextMetadata"]);return g!=null&&x(t,["urlContextMetadata"],g),t}function uL(e){const t={},n=y(e,["citationSources"]);if(n!=null){let r=n;Array.isArray(r)&&(r=r.map(i=>i)),x(t,["citations"],r)}return t}function dL(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["_url","model"],tt(e,r));const i=y(t,["contents"]);if(i!=null){let o=Hr(i);Array.isArray(o)&&(o=o.map(c=>c)),x(n,["contents"],o)}return n}function fL(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["tokensInfo"]);if(r!=null){let i=r;Array.isArray(i)&&(i=i.map(o=>o)),x(t,["tokensInfo"],i)}return t}function mL(e){const t={},n=y(e,["values"]);n!=null&&x(t,["values"],n);const r=y(e,["statistics"]);return r!=null&&x(t,["statistics"],hL(r)),t}function hL(e){const t={},n=y(e,["truncated"]);n!=null&&x(t,["truncated"],n);const r=y(e,["token_count"]);return r!=null&&x(t,["tokenCount"],r),t}function lh(e){const t={},n=y(e,["parts"]);if(n!=null){let i=n;Array.isArray(i)&&(i=i.map(o=>A8(o))),x(t,["parts"],i)}const r=y(e,["role"]);return r!=null&&x(t,["role"],r),t}function pL(e){const t={},n=y(e,["controlType"]);n!=null&&x(t,["controlType"],n);const r=y(e,["enableControlImageComputation"]);return r!=null&&x(t,["computeControl"],r),t}function gL(e){const t={};if(y(e,["systemInstruction"])!==void 0)throw new Error("systemInstruction parameter is not supported in Gemini API.");if(y(e,["tools"])!==void 0)throw new Error("tools parameter is not supported in Gemini API.");if(y(e,["generationConfig"])!==void 0)throw new Error("generationConfig parameter is not supported in Gemini API.");return t}function yL(e,t){const n={},r=y(e,["systemInstruction"]);t!==void 0&&r!=null&&x(t,["systemInstruction"],Ln(r));const i=y(e,["tools"]);if(t!==void 0&&i!=null){let c=i;Array.isArray(c)&&(c=c.map(u=>x3(u))),x(t,["tools"],c)}const o=y(e,["generationConfig"]);return t!==void 0&&o!=null&&x(t,["generationConfig"],l8(o)),n}function vL(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["_url","model"],tt(e,r));const i=y(t,["contents"]);if(i!=null){let c=Hr(i);Array.isArray(c)&&(c=c.map(u=>lh(u))),x(n,["contents"],c)}const o=y(t,["config"]);return o!=null&&gL(o),n}function xL(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["_url","model"],tt(e,r));const i=y(t,["contents"]);if(i!=null){let c=Hr(i);Array.isArray(c)&&(c=c.map(u=>u)),x(n,["contents"],c)}const o=y(t,["config"]);return o!=null&&yL(o,n),n}function bL(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["totalTokens"]);r!=null&&x(t,["totalTokens"],r);const i=y(e,["cachedContentTokenCount"]);return i!=null&&x(t,["cachedContentTokenCount"],i),t}function wL(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["totalTokens"]);return r!=null&&x(t,["totalTokens"],r),t}function SL(e,t){const n={},r=y(t,["model"]);return r!=null&&x(n,["_url","name"],tt(e,r)),n}function AL(e,t){const n={},r=y(t,["model"]);return r!=null&&x(n,["_url","name"],tt(e,r)),n}function CL(e){const t={},n=y(e,["sdkHttpResponse"]);return n!=null&&x(t,["sdkHttpResponse"],n),t}function TL(e){const t={},n=y(e,["sdkHttpResponse"]);return n!=null&&x(t,["sdkHttpResponse"],n),t}function EL(e,t){const n={},r=y(e,["outputGcsUri"]);t!==void 0&&r!=null&&x(t,["parameters","storageUri"],r);const i=y(e,["negativePrompt"]);t!==void 0&&i!=null&&x(t,["parameters","negativePrompt"],i);const o=y(e,["numberOfImages"]);t!==void 0&&o!=null&&x(t,["parameters","sampleCount"],o);const c=y(e,["aspectRatio"]);t!==void 0&&c!=null&&x(t,["parameters","aspectRatio"],c);const u=y(e,["guidanceScale"]);t!==void 0&&u!=null&&x(t,["parameters","guidanceScale"],u);const m=y(e,["seed"]);t!==void 0&&m!=null&&x(t,["parameters","seed"],m);const f=y(e,["safetyFilterLevel"]);t!==void 0&&f!=null&&x(t,["parameters","safetySetting"],f);const h=y(e,["personGeneration"]);t!==void 0&&h!=null&&x(t,["parameters","personGeneration"],h);const g=y(e,["includeSafetyAttributes"]);t!==void 0&&g!=null&&x(t,["parameters","includeSafetyAttributes"],g);const v=y(e,["includeRaiReason"]);t!==void 0&&v!=null&&x(t,["parameters","includeRaiReason"],v);const b=y(e,["language"]);t!==void 0&&b!=null&&x(t,["parameters","language"],b);const T=y(e,["outputMimeType"]);t!==void 0&&T!=null&&x(t,["parameters","outputOptions","mimeType"],T);const C=y(e,["outputCompressionQuality"]);t!==void 0&&C!=null&&x(t,["parameters","outputOptions","compressionQuality"],C);const E=y(e,["addWatermark"]);t!==void 0&&E!=null&&x(t,["parameters","addWatermark"],E);const N=y(e,["labels"]);t!==void 0&&N!=null&&x(t,["labels"],N);const I=y(e,["editMode"]);t!==void 0&&I!=null&&x(t,["parameters","editMode"],I);const P=y(e,["baseSteps"]);return t!==void 0&&P!=null&&x(t,["parameters","editConfig","baseSteps"],P),n}function NL(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["_url","model"],tt(e,r));const i=y(t,["prompt"]);i!=null&&x(n,["instances[0]","prompt"],i);const o=y(t,["referenceImages"]);if(o!=null){let u=o;Array.isArray(u)&&(u=u.map(m=>j8(m))),x(n,["instances[0]","referenceImages"],u)}const c=y(t,["config"]);return c!=null&&EL(c,n),n}function _L(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["predictions"]);if(r!=null){let i=r;Array.isArray(i)&&(i=i.map(o=>ch(o))),x(t,["generatedImages"],i)}return t}function jL(e,t){const n={},r=y(e,["taskType"]);t!==void 0&&r!=null&&x(t,["requests[]","taskType"],r);const i=y(e,["title"]);t!==void 0&&i!=null&&x(t,["requests[]","title"],i);const o=y(e,["outputDimensionality"]);if(t!==void 0&&o!=null&&x(t,["requests[]","outputDimensionality"],o),y(e,["mimeType"])!==void 0)throw new Error("mimeType parameter is not supported in Gemini API.");if(y(e,["autoTruncate"])!==void 0)throw new Error("autoTruncate parameter is not supported in Gemini API.");return n}function ML(e,t){const n={},r=y(e,["taskType"]);t!==void 0&&r!=null&&x(t,["instances[]","task_type"],r);const i=y(e,["title"]);t!==void 0&&i!=null&&x(t,["instances[]","title"],i);const o=y(e,["outputDimensionality"]);t!==void 0&&o!=null&&x(t,["parameters","outputDimensionality"],o);const c=y(e,["mimeType"]);t!==void 0&&c!=null&&x(t,["instances[]","mimeType"],c);const u=y(e,["autoTruncate"]);return t!==void 0&&u!=null&&x(t,["parameters","autoTruncate"],u),n}function PL(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["_url","model"],tt(e,r));const i=y(t,["contents"]);if(i!=null){let u=kx(e,i);Array.isArray(u)&&(u=u.map(m=>m)),x(n,["requests[]","content"],u)}const o=y(t,["config"]);o!=null&&jL(o,n);const c=y(t,["model"]);return c!==void 0&&x(n,["requests[]","model"],tt(e,c)),n}function IL(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["_url","model"],tt(e,r));const i=y(t,["contents"]);if(i!=null){let c=kx(e,i);Array.isArray(c)&&(c=c.map(u=>u)),x(n,["instances[]","content"],c)}const o=y(t,["config"]);return o!=null&&ML(o,n),n}function kL(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["embeddings"]);if(r!=null){let o=r;Array.isArray(o)&&(o=o.map(c=>c)),x(t,["embeddings"],o)}const i=y(e,["metadata"]);return i!=null&&x(t,["metadata"],i),t}function DL(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["predictions[]","embeddings"]);if(r!=null){let o=r;Array.isArray(o)&&(o=o.map(c=>mL(c))),x(t,["embeddings"],o)}const i=y(e,["metadata"]);return i!=null&&x(t,["metadata"],i),t}function RL(e){const t={},n=y(e,["endpoint"]);n!=null&&x(t,["name"],n);const r=y(e,["deployedModelId"]);return r!=null&&x(t,["deployedModelId"],r),t}function OL(e){const t={};if(y(e,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const n=y(e,["fileUri"]);n!=null&&x(t,["fileUri"],n);const r=y(e,["mimeType"]);return r!=null&&x(t,["mimeType"],r),t}function LL(e){const t={},n=y(e,["id"]);n!=null&&x(t,["id"],n);const r=y(e,["args"]);r!=null&&x(t,["args"],r);const i=y(e,["name"]);if(i!=null&&x(t,["name"],i),y(e,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(y(e,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return t}function UL(e){const t={},n=y(e,["mode"]);n!=null&&x(t,["mode"],n);const r=y(e,["allowedFunctionNames"]);if(r!=null&&x(t,["allowedFunctionNames"],r),y(e,["streamFunctionCallArguments"])!==void 0)throw new Error("streamFunctionCallArguments parameter is not supported in Gemini API.");return t}function BL(e){const t={};if(y(e,["behavior"])!==void 0)throw new Error("behavior parameter is not supported in Vertex AI.");const n=y(e,["description"]);n!=null&&x(t,["description"],n);const r=y(e,["name"]);r!=null&&x(t,["name"],r);const i=y(e,["parameters"]);i!=null&&x(t,["parameters"],i);const o=y(e,["parametersJsonSchema"]);o!=null&&x(t,["parametersJsonSchema"],o);const c=y(e,["response"]);c!=null&&x(t,["response"],c);const u=y(e,["responseJsonSchema"]);return u!=null&&x(t,["responseJsonSchema"],u),t}function zL(e,t,n){const r={},i=y(t,["systemInstruction"]);n!==void 0&&i!=null&&x(n,["systemInstruction"],lh(Ln(i)));const o=y(t,["temperature"]);o!=null&&x(r,["temperature"],o);const c=y(t,["topP"]);c!=null&&x(r,["topP"],c);const u=y(t,["topK"]);u!=null&&x(r,["topK"],u);const m=y(t,["candidateCount"]);m!=null&&x(r,["candidateCount"],m);const f=y(t,["maxOutputTokens"]);f!=null&&x(r,["maxOutputTokens"],f);const h=y(t,["stopSequences"]);h!=null&&x(r,["stopSequences"],h);const g=y(t,["responseLogprobs"]);g!=null&&x(r,["responseLogprobs"],g);const v=y(t,["logprobs"]);v!=null&&x(r,["logprobs"],v);const b=y(t,["presencePenalty"]);b!=null&&x(r,["presencePenalty"],b);const T=y(t,["frequencyPenalty"]);T!=null&&x(r,["frequencyPenalty"],T);const C=y(t,["seed"]);C!=null&&x(r,["seed"],C);const E=y(t,["responseMimeType"]);E!=null&&x(r,["responseMimeType"],E);const N=y(t,["responseSchema"]);N!=null&&x(r,["responseSchema"],Dx(N));const I=y(t,["responseJsonSchema"]);if(I!=null&&x(r,["responseJsonSchema"],I),y(t,["routingConfig"])!==void 0)throw new Error("routingConfig parameter is not supported in Gemini API.");if(y(t,["modelSelectionConfig"])!==void 0)throw new Error("modelSelectionConfig parameter is not supported in Gemini API.");const P=y(t,["safetySettings"]);if(n!==void 0&&P!=null){let V=P;Array.isArray(V)&&(V=V.map(oe=>M8(oe))),x(n,["safetySettings"],V)}const M=y(t,["tools"]);if(n!==void 0&&M!=null){let V=ic(M);Array.isArray(V)&&(V=V.map(oe=>L8(rc(oe)))),x(n,["tools"],V)}const j=y(t,["toolConfig"]);if(n!==void 0&&j!=null&&x(n,["toolConfig"],O8(j)),y(t,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const k=y(t,["cachedContent"]);n!==void 0&&k!=null&&x(n,["cachedContent"],Aa(e,k));const R=y(t,["responseModalities"]);R!=null&&x(r,["responseModalities"],R);const F=y(t,["mediaResolution"]);F!=null&&x(r,["mediaResolution"],F);const q=y(t,["speechConfig"]);if(q!=null&&x(r,["speechConfig"],Rx(q)),y(t,["audioTimestamp"])!==void 0)throw new Error("audioTimestamp parameter is not supported in Gemini API.");const G=y(t,["thinkingConfig"]);G!=null&&x(r,["thinkingConfig"],G);const H=y(t,["imageConfig"]);return H!=null&&x(r,["imageConfig"],m8(H)),r}function FL(e,t,n){const r={},i=y(t,["systemInstruction"]);n!==void 0&&i!=null&&x(n,["systemInstruction"],Ln(i));const o=y(t,["temperature"]);o!=null&&x(r,["temperature"],o);const c=y(t,["topP"]);c!=null&&x(r,["topP"],c);const u=y(t,["topK"]);u!=null&&x(r,["topK"],u);const m=y(t,["candidateCount"]);m!=null&&x(r,["candidateCount"],m);const f=y(t,["maxOutputTokens"]);f!=null&&x(r,["maxOutputTokens"],f);const h=y(t,["stopSequences"]);h!=null&&x(r,["stopSequences"],h);const g=y(t,["responseLogprobs"]);g!=null&&x(r,["responseLogprobs"],g);const v=y(t,["logprobs"]);v!=null&&x(r,["logprobs"],v);const b=y(t,["presencePenalty"]);b!=null&&x(r,["presencePenalty"],b);const T=y(t,["frequencyPenalty"]);T!=null&&x(r,["frequencyPenalty"],T);const C=y(t,["seed"]);C!=null&&x(r,["seed"],C);const E=y(t,["responseMimeType"]);E!=null&&x(r,["responseMimeType"],E);const N=y(t,["responseSchema"]);N!=null&&x(r,["responseSchema"],Dx(N));const I=y(t,["responseJsonSchema"]);I!=null&&x(r,["responseJsonSchema"],I);const P=y(t,["routingConfig"]);P!=null&&x(r,["routingConfig"],P);const M=y(t,["modelSelectionConfig"]);M!=null&&x(r,["modelConfig"],M);const j=y(t,["safetySettings"]);if(n!==void 0&&j!=null){let z=j;Array.isArray(z)&&(z=z.map(Y=>Y)),x(n,["safetySettings"],z)}const k=y(t,["tools"]);if(n!==void 0&&k!=null){let z=ic(k);Array.isArray(z)&&(z=z.map(Y=>x3(rc(Y)))),x(n,["tools"],z)}const R=y(t,["toolConfig"]);n!==void 0&&R!=null&&x(n,["toolConfig"],R);const F=y(t,["labels"]);n!==void 0&&F!=null&&x(n,["labels"],F);const q=y(t,["cachedContent"]);n!==void 0&&q!=null&&x(n,["cachedContent"],Aa(e,q));const G=y(t,["responseModalities"]);G!=null&&x(r,["responseModalities"],G);const H=y(t,["mediaResolution"]);H!=null&&x(r,["mediaResolution"],H);const V=y(t,["speechConfig"]);V!=null&&x(r,["speechConfig"],v3(Rx(V)));const oe=y(t,["audioTimestamp"]);oe!=null&&x(r,["audioTimestamp"],oe);const Z=y(t,["thinkingConfig"]);Z!=null&&x(r,["thinkingConfig"],Z);const me=y(t,["imageConfig"]);return me!=null&&x(r,["imageConfig"],h8(me)),r}function WC(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["_url","model"],tt(e,r));const i=y(t,["contents"]);if(i!=null){let c=Hr(i);Array.isArray(c)&&(c=c.map(u=>lh(u))),x(n,["contents"],c)}const o=y(t,["config"]);return o!=null&&x(n,["generationConfig"],zL(e,o,n)),n}function JC(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["_url","model"],tt(e,r));const i=y(t,["contents"]);if(i!=null){let c=Hr(i);Array.isArray(c)&&(c=c.map(u=>u)),x(n,["contents"],c)}const o=y(t,["config"]);return o!=null&&x(n,["generationConfig"],FL(e,o,n)),n}function QC(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["candidates"]);if(r!=null){let m=r;Array.isArray(m)&&(m=m.map(f=>cL(f))),x(t,["candidates"],m)}const i=y(e,["modelVersion"]);i!=null&&x(t,["modelVersion"],i);const o=y(e,["promptFeedback"]);o!=null&&x(t,["promptFeedback"],o);const c=y(e,["responseId"]);c!=null&&x(t,["responseId"],c);const u=y(e,["usageMetadata"]);return u!=null&&x(t,["usageMetadata"],u),t}function XC(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["candidates"]);if(r!=null){let f=r;Array.isArray(f)&&(f=f.map(h=>h)),x(t,["candidates"],f)}const i=y(e,["createTime"]);i!=null&&x(t,["createTime"],i);const o=y(e,["modelVersion"]);o!=null&&x(t,["modelVersion"],o);const c=y(e,["promptFeedback"]);c!=null&&x(t,["promptFeedback"],c);const u=y(e,["responseId"]);u!=null&&x(t,["responseId"],u);const m=y(e,["usageMetadata"]);return m!=null&&x(t,["usageMetadata"],m),t}function qL(e,t){const n={};if(y(e,["outputGcsUri"])!==void 0)throw new Error("outputGcsUri parameter is not supported in Gemini API.");if(y(e,["negativePrompt"])!==void 0)throw new Error("negativePrompt parameter is not supported in Gemini API.");const r=y(e,["numberOfImages"]);t!==void 0&&r!=null&&x(t,["parameters","sampleCount"],r);const i=y(e,["aspectRatio"]);t!==void 0&&i!=null&&x(t,["parameters","aspectRatio"],i);const o=y(e,["guidanceScale"]);if(t!==void 0&&o!=null&&x(t,["parameters","guidanceScale"],o),y(e,["seed"])!==void 0)throw new Error("seed parameter is not supported in Gemini API.");const c=y(e,["safetyFilterLevel"]);t!==void 0&&c!=null&&x(t,["parameters","safetySetting"],c);const u=y(e,["personGeneration"]);t!==void 0&&u!=null&&x(t,["parameters","personGeneration"],u);const m=y(e,["includeSafetyAttributes"]);t!==void 0&&m!=null&&x(t,["parameters","includeSafetyAttributes"],m);const f=y(e,["includeRaiReason"]);t!==void 0&&f!=null&&x(t,["parameters","includeRaiReason"],f);const h=y(e,["language"]);t!==void 0&&h!=null&&x(t,["parameters","language"],h);const g=y(e,["outputMimeType"]);t!==void 0&&g!=null&&x(t,["parameters","outputOptions","mimeType"],g);const v=y(e,["outputCompressionQuality"]);if(t!==void 0&&v!=null&&x(t,["parameters","outputOptions","compressionQuality"],v),y(e,["addWatermark"])!==void 0)throw new Error("addWatermark parameter is not supported in Gemini API.");if(y(e,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");const b=y(e,["imageSize"]);if(t!==void 0&&b!=null&&x(t,["parameters","sampleImageSize"],b),y(e,["enhancePrompt"])!==void 0)throw new Error("enhancePrompt parameter is not supported in Gemini API.");return n}function GL(e,t){const n={},r=y(e,["outputGcsUri"]);t!==void 0&&r!=null&&x(t,["parameters","storageUri"],r);const i=y(e,["negativePrompt"]);t!==void 0&&i!=null&&x(t,["parameters","negativePrompt"],i);const o=y(e,["numberOfImages"]);t!==void 0&&o!=null&&x(t,["parameters","sampleCount"],o);const c=y(e,["aspectRatio"]);t!==void 0&&c!=null&&x(t,["parameters","aspectRatio"],c);const u=y(e,["guidanceScale"]);t!==void 0&&u!=null&&x(t,["parameters","guidanceScale"],u);const m=y(e,["seed"]);t!==void 0&&m!=null&&x(t,["parameters","seed"],m);const f=y(e,["safetyFilterLevel"]);t!==void 0&&f!=null&&x(t,["parameters","safetySetting"],f);const h=y(e,["personGeneration"]);t!==void 0&&h!=null&&x(t,["parameters","personGeneration"],h);const g=y(e,["includeSafetyAttributes"]);t!==void 0&&g!=null&&x(t,["parameters","includeSafetyAttributes"],g);const v=y(e,["includeRaiReason"]);t!==void 0&&v!=null&&x(t,["parameters","includeRaiReason"],v);const b=y(e,["language"]);t!==void 0&&b!=null&&x(t,["parameters","language"],b);const T=y(e,["outputMimeType"]);t!==void 0&&T!=null&&x(t,["parameters","outputOptions","mimeType"],T);const C=y(e,["outputCompressionQuality"]);t!==void 0&&C!=null&&x(t,["parameters","outputOptions","compressionQuality"],C);const E=y(e,["addWatermark"]);t!==void 0&&E!=null&&x(t,["parameters","addWatermark"],E);const N=y(e,["labels"]);t!==void 0&&N!=null&&x(t,["labels"],N);const I=y(e,["imageSize"]);t!==void 0&&I!=null&&x(t,["parameters","sampleImageSize"],I);const P=y(e,["enhancePrompt"]);return t!==void 0&&P!=null&&x(t,["parameters","enhancePrompt"],P),n}function $L(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["_url","model"],tt(e,r));const i=y(t,["prompt"]);i!=null&&x(n,["instances[0]","prompt"],i);const o=y(t,["config"]);return o!=null&&qL(o,n),n}function HL(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["_url","model"],tt(e,r));const i=y(t,["prompt"]);i!=null&&x(n,["instances[0]","prompt"],i);const o=y(t,["config"]);return o!=null&&GL(o,n),n}function VL(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["predictions"]);if(r!=null){let o=r;Array.isArray(o)&&(o=o.map(c=>i8(c))),x(t,["generatedImages"],o)}const i=y(e,["positivePromptSafetyAttributes"]);return i!=null&&x(t,["positivePromptSafetyAttributes"],g3(i)),t}function KL(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["predictions"]);if(r!=null){let o=r;Array.isArray(o)&&(o=o.map(c=>ch(c))),x(t,["generatedImages"],o)}const i=y(e,["positivePromptSafetyAttributes"]);return i!=null&&x(t,["positivePromptSafetyAttributes"],y3(i)),t}function YL(e,t){const n={},r=y(e,["numberOfVideos"]);if(t!==void 0&&r!=null&&x(t,["parameters","sampleCount"],r),y(e,["outputGcsUri"])!==void 0)throw new Error("outputGcsUri parameter is not supported in Gemini API.");if(y(e,["fps"])!==void 0)throw new Error("fps parameter is not supported in Gemini API.");const i=y(e,["durationSeconds"]);if(t!==void 0&&i!=null&&x(t,["parameters","durationSeconds"],i),y(e,["seed"])!==void 0)throw new Error("seed parameter is not supported in Gemini API.");const o=y(e,["aspectRatio"]);t!==void 0&&o!=null&&x(t,["parameters","aspectRatio"],o);const c=y(e,["resolution"]);t!==void 0&&c!=null&&x(t,["parameters","resolution"],c);const u=y(e,["personGeneration"]);if(t!==void 0&&u!=null&&x(t,["parameters","personGeneration"],u),y(e,["pubsubTopic"])!==void 0)throw new Error("pubsubTopic parameter is not supported in Gemini API.");const m=y(e,["negativePrompt"]);t!==void 0&&m!=null&&x(t,["parameters","negativePrompt"],m);const f=y(e,["enhancePrompt"]);if(t!==void 0&&f!=null&&x(t,["parameters","enhancePrompt"],f),y(e,["generateAudio"])!==void 0)throw new Error("generateAudio parameter is not supported in Gemini API.");const h=y(e,["lastFrame"]);t!==void 0&&h!=null&&x(t,["instances[0]","lastFrame"],uh(h));const g=y(e,["referenceImages"]);if(t!==void 0&&g!=null){let v=g;Array.isArray(v)&&(v=v.map(b=>J8(b))),x(t,["instances[0]","referenceImages"],v)}if(y(e,["mask"])!==void 0)throw new Error("mask parameter is not supported in Gemini API.");if(y(e,["compressionQuality"])!==void 0)throw new Error("compressionQuality parameter is not supported in Gemini API.");return n}function WL(e,t){const n={},r=y(e,["numberOfVideos"]);t!==void 0&&r!=null&&x(t,["parameters","sampleCount"],r);const i=y(e,["outputGcsUri"]);t!==void 0&&i!=null&&x(t,["parameters","storageUri"],i);const o=y(e,["fps"]);t!==void 0&&o!=null&&x(t,["parameters","fps"],o);const c=y(e,["durationSeconds"]);t!==void 0&&c!=null&&x(t,["parameters","durationSeconds"],c);const u=y(e,["seed"]);t!==void 0&&u!=null&&x(t,["parameters","seed"],u);const m=y(e,["aspectRatio"]);t!==void 0&&m!=null&&x(t,["parameters","aspectRatio"],m);const f=y(e,["resolution"]);t!==void 0&&f!=null&&x(t,["parameters","resolution"],f);const h=y(e,["personGeneration"]);t!==void 0&&h!=null&&x(t,["parameters","personGeneration"],h);const g=y(e,["pubsubTopic"]);t!==void 0&&g!=null&&x(t,["parameters","pubsubTopic"],g);const v=y(e,["negativePrompt"]);t!==void 0&&v!=null&&x(t,["parameters","negativePrompt"],v);const b=y(e,["enhancePrompt"]);t!==void 0&&b!=null&&x(t,["parameters","enhancePrompt"],b);const T=y(e,["generateAudio"]);t!==void 0&&T!=null&&x(t,["parameters","generateAudio"],T);const C=y(e,["lastFrame"]);t!==void 0&&C!=null&&x(t,["instances[0]","lastFrame"],si(C));const E=y(e,["referenceImages"]);if(t!==void 0&&E!=null){let P=E;Array.isArray(P)&&(P=P.map(M=>Q8(M))),x(t,["instances[0]","referenceImages"],P)}const N=y(e,["mask"]);t!==void 0&&N!=null&&x(t,["instances[0]","mask"],W8(N));const I=y(e,["compressionQuality"]);return t!==void 0&&I!=null&&x(t,["parameters","compressionQuality"],I),n}function JL(e){const t={},n=y(e,["name"]);n!=null&&x(t,["name"],n);const r=y(e,["metadata"]);r!=null&&x(t,["metadata"],r);const i=y(e,["done"]);i!=null&&x(t,["done"],i);const o=y(e,["error"]);o!=null&&x(t,["error"],o);const c=y(e,["response","generateVideoResponse"]);return c!=null&&x(t,["response"],e8(c)),t}function QL(e){const t={},n=y(e,["name"]);n!=null&&x(t,["name"],n);const r=y(e,["metadata"]);r!=null&&x(t,["metadata"],r);const i=y(e,["done"]);i!=null&&x(t,["done"],i);const o=y(e,["error"]);o!=null&&x(t,["error"],o);const c=y(e,["response"]);return c!=null&&x(t,["response"],t8(c)),t}function XL(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["_url","model"],tt(e,r));const i=y(t,["prompt"]);i!=null&&x(n,["instances[0]","prompt"],i);const o=y(t,["image"]);o!=null&&x(n,["instances[0]","image"],uh(o));const c=y(t,["video"]);c!=null&&x(n,["instances[0]","video"],b3(c));const u=y(t,["source"]);u!=null&&n8(u,n);const m=y(t,["config"]);return m!=null&&YL(m,n),n}function ZL(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["_url","model"],tt(e,r));const i=y(t,["prompt"]);i!=null&&x(n,["instances[0]","prompt"],i);const o=y(t,["image"]);o!=null&&x(n,["instances[0]","image"],si(o));const c=y(t,["video"]);c!=null&&x(n,["instances[0]","video"],w3(c));const u=y(t,["source"]);u!=null&&r8(u,n);const m=y(t,["config"]);return m!=null&&WL(m,n),n}function e8(e){const t={},n=y(e,["generatedSamples"]);if(n!=null){let o=n;Array.isArray(o)&&(o=o.map(c=>o8(c))),x(t,["generatedVideos"],o)}const r=y(e,["raiMediaFilteredCount"]);r!=null&&x(t,["raiMediaFilteredCount"],r);const i=y(e,["raiMediaFilteredReasons"]);return i!=null&&x(t,["raiMediaFilteredReasons"],i),t}function t8(e){const t={},n=y(e,["videos"]);if(n!=null){let o=n;Array.isArray(o)&&(o=o.map(c=>s8(c))),x(t,["generatedVideos"],o)}const r=y(e,["raiMediaFilteredCount"]);r!=null&&x(t,["raiMediaFilteredCount"],r);const i=y(e,["raiMediaFilteredReasons"]);return i!=null&&x(t,["raiMediaFilteredReasons"],i),t}function n8(e,t){const n={},r=y(e,["prompt"]);t!==void 0&&r!=null&&x(t,["instances[0]","prompt"],r);const i=y(e,["image"]);t!==void 0&&i!=null&&x(t,["instances[0]","image"],uh(i));const o=y(e,["video"]);return t!==void 0&&o!=null&&x(t,["instances[0]","video"],b3(o)),n}function r8(e,t){const n={},r=y(e,["prompt"]);t!==void 0&&r!=null&&x(t,["instances[0]","prompt"],r);const i=y(e,["image"]);t!==void 0&&i!=null&&x(t,["instances[0]","image"],si(i));const o=y(e,["video"]);return t!==void 0&&o!=null&&x(t,["instances[0]","video"],w3(o)),n}function i8(e){const t={},n=y(e,["_self"]);n!=null&&x(t,["image"],p8(n));const r=y(e,["raiFilteredReason"]);r!=null&&x(t,["raiFilteredReason"],r);const i=y(e,["_self"]);return i!=null&&x(t,["safetyAttributes"],g3(i)),t}function ch(e){const t={},n=y(e,["_self"]);n!=null&&x(t,["image"],p3(n));const r=y(e,["raiFilteredReason"]);r!=null&&x(t,["raiFilteredReason"],r);const i=y(e,["_self"]);i!=null&&x(t,["safetyAttributes"],y3(i));const o=y(e,["prompt"]);return o!=null&&x(t,["enhancedPrompt"],o),t}function a8(e){const t={},n=y(e,["_self"]);n!=null&&x(t,["mask"],p3(n));const r=y(e,["labels"]);if(r!=null){let i=r;Array.isArray(i)&&(i=i.map(o=>o)),x(t,["labels"],i)}return t}function o8(e){const t={},n=y(e,["video"]);return n!=null&&x(t,["video"],K8(n)),t}function s8(e){const t={},n=y(e,["_self"]);return n!=null&&x(t,["video"],Y8(n)),t}function l8(e){const t={},n=y(e,["modelSelectionConfig"]);n!=null&&x(t,["modelConfig"],n);const r=y(e,["responseJsonSchema"]);r!=null&&x(t,["responseJsonSchema"],r);const i=y(e,["audioTimestamp"]);i!=null&&x(t,["audioTimestamp"],i);const o=y(e,["candidateCount"]);o!=null&&x(t,["candidateCount"],o);const c=y(e,["enableAffectiveDialog"]);c!=null&&x(t,["enableAffectiveDialog"],c);const u=y(e,["frequencyPenalty"]);u!=null&&x(t,["frequencyPenalty"],u);const m=y(e,["logprobs"]);m!=null&&x(t,["logprobs"],m);const f=y(e,["maxOutputTokens"]);f!=null&&x(t,["maxOutputTokens"],f);const h=y(e,["mediaResolution"]);h!=null&&x(t,["mediaResolution"],h);const g=y(e,["presencePenalty"]);g!=null&&x(t,["presencePenalty"],g);const v=y(e,["responseLogprobs"]);v!=null&&x(t,["responseLogprobs"],v);const b=y(e,["responseMimeType"]);b!=null&&x(t,["responseMimeType"],b);const T=y(e,["responseModalities"]);T!=null&&x(t,["responseModalities"],T);const C=y(e,["responseSchema"]);C!=null&&x(t,["responseSchema"],C);const E=y(e,["routingConfig"]);E!=null&&x(t,["routingConfig"],E);const N=y(e,["seed"]);N!=null&&x(t,["seed"],N);const I=y(e,["speechConfig"]);I!=null&&x(t,["speechConfig"],v3(I));const P=y(e,["stopSequences"]);P!=null&&x(t,["stopSequences"],P);const M=y(e,["temperature"]);M!=null&&x(t,["temperature"],M);const j=y(e,["thinkingConfig"]);j!=null&&x(t,["thinkingConfig"],j);const k=y(e,["topK"]);k!=null&&x(t,["topK"],k);const R=y(e,["topP"]);if(R!=null&&x(t,["topP"],R),y(e,["enableEnhancedCivicAnswers"])!==void 0)throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");return t}function c8(e,t){const n={},r=y(t,["model"]);return r!=null&&x(n,["_url","name"],tt(e,r)),n}function u8(e,t){const n={},r=y(t,["model"]);return r!=null&&x(n,["_url","name"],tt(e,r)),n}function d8(e){const t={};if(y(e,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const n=y(e,["enableWidget"]);return n!=null&&x(t,["enableWidget"],n),t}function f8(e){const t={};if(y(e,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(y(e,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const n=y(e,["timeRangeFilter"]);return n!=null&&x(t,["timeRangeFilter"],n),t}function m8(e){const t={},n=y(e,["aspectRatio"]);n!=null&&x(t,["aspectRatio"],n);const r=y(e,["imageSize"]);if(r!=null&&x(t,["imageSize"],r),y(e,["outputMimeType"])!==void 0)throw new Error("outputMimeType parameter is not supported in Gemini API.");if(y(e,["outputCompressionQuality"])!==void 0)throw new Error("outputCompressionQuality parameter is not supported in Gemini API.");return t}function h8(e){const t={},n=y(e,["aspectRatio"]);n!=null&&x(t,["aspectRatio"],n);const r=y(e,["imageSize"]);r!=null&&x(t,["imageSize"],r);const i=y(e,["outputMimeType"]);i!=null&&x(t,["imageOutputOptions","mimeType"],i);const o=y(e,["outputCompressionQuality"]);return o!=null&&x(t,["imageOutputOptions","compressionQuality"],o),t}function p8(e){const t={},n=y(e,["bytesBase64Encoded"]);n!=null&&x(t,["imageBytes"],Eo(n));const r=y(e,["mimeType"]);return r!=null&&x(t,["mimeType"],r),t}function p3(e){const t={},n=y(e,["gcsUri"]);n!=null&&x(t,["gcsUri"],n);const r=y(e,["bytesBase64Encoded"]);r!=null&&x(t,["imageBytes"],Eo(r));const i=y(e,["mimeType"]);return i!=null&&x(t,["mimeType"],i),t}function uh(e){const t={};if(y(e,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");const n=y(e,["imageBytes"]);n!=null&&x(t,["bytesBase64Encoded"],Eo(n));const r=y(e,["mimeType"]);return r!=null&&x(t,["mimeType"],r),t}function si(e){const t={},n=y(e,["gcsUri"]);n!=null&&x(t,["gcsUri"],n);const r=y(e,["imageBytes"]);r!=null&&x(t,["bytesBase64Encoded"],Eo(r));const i=y(e,["mimeType"]);return i!=null&&x(t,["mimeType"],i),t}function g8(e,t,n){const r={},i=y(t,["pageSize"]);n!==void 0&&i!=null&&x(n,["_query","pageSize"],i);const o=y(t,["pageToken"]);n!==void 0&&o!=null&&x(n,["_query","pageToken"],o);const c=y(t,["filter"]);n!==void 0&&c!=null&&x(n,["_query","filter"],c);const u=y(t,["queryBase"]);return n!==void 0&&u!=null&&x(n,["_url","models_url"],s3(e,u)),r}function y8(e,t,n){const r={},i=y(t,["pageSize"]);n!==void 0&&i!=null&&x(n,["_query","pageSize"],i);const o=y(t,["pageToken"]);n!==void 0&&o!=null&&x(n,["_query","pageToken"],o);const c=y(t,["filter"]);n!==void 0&&c!=null&&x(n,["_query","filter"],c);const u=y(t,["queryBase"]);return n!==void 0&&u!=null&&x(n,["_url","models_url"],s3(e,u)),r}function v8(e,t){const n={},r=y(t,["config"]);return r!=null&&g8(e,r,n),n}function x8(e,t){const n={},r=y(t,["config"]);return r!=null&&y8(e,r,n),n}function b8(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["nextPageToken"]);r!=null&&x(t,["nextPageToken"],r);const i=y(e,["_self"]);if(i!=null){let o=l3(i);Array.isArray(o)&&(o=o.map(c=>dv(c))),x(t,["models"],o)}return t}function w8(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["nextPageToken"]);r!=null&&x(t,["nextPageToken"],r);const i=y(e,["_self"]);if(i!=null){let o=l3(i);Array.isArray(o)&&(o=o.map(c=>fv(c))),x(t,["models"],o)}return t}function S8(e){const t={},n=y(e,["maskMode"]);n!=null&&x(t,["maskMode"],n);const r=y(e,["segmentationClasses"]);r!=null&&x(t,["maskClasses"],r);const i=y(e,["maskDilation"]);return i!=null&&x(t,["dilation"],i),t}function dv(e){const t={},n=y(e,["name"]);n!=null&&x(t,["name"],n);const r=y(e,["displayName"]);r!=null&&x(t,["displayName"],r);const i=y(e,["description"]);i!=null&&x(t,["description"],i);const o=y(e,["version"]);o!=null&&x(t,["version"],o);const c=y(e,["_self"]);c!=null&&x(t,["tunedModelInfo"],U8(c));const u=y(e,["inputTokenLimit"]);u!=null&&x(t,["inputTokenLimit"],u);const m=y(e,["outputTokenLimit"]);m!=null&&x(t,["outputTokenLimit"],m);const f=y(e,["supportedGenerationMethods"]);f!=null&&x(t,["supportedActions"],f);const h=y(e,["temperature"]);h!=null&&x(t,["temperature"],h);const g=y(e,["maxTemperature"]);g!=null&&x(t,["maxTemperature"],g);const v=y(e,["topP"]);v!=null&&x(t,["topP"],v);const b=y(e,["topK"]);b!=null&&x(t,["topK"],b);const T=y(e,["thinking"]);return T!=null&&x(t,["thinking"],T),t}function fv(e){const t={},n=y(e,["name"]);n!=null&&x(t,["name"],n);const r=y(e,["displayName"]);r!=null&&x(t,["displayName"],r);const i=y(e,["description"]);i!=null&&x(t,["description"],i);const o=y(e,["versionId"]);o!=null&&x(t,["version"],o);const c=y(e,["deployedModels"]);if(c!=null){let g=c;Array.isArray(g)&&(g=g.map(v=>RL(v))),x(t,["endpoints"],g)}const u=y(e,["labels"]);u!=null&&x(t,["labels"],u);const m=y(e,["_self"]);m!=null&&x(t,["tunedModelInfo"],B8(m));const f=y(e,["defaultCheckpointId"]);f!=null&&x(t,["defaultCheckpointId"],f);const h=y(e,["checkpoints"]);if(h!=null){let g=h;Array.isArray(g)&&(g=g.map(v=>v)),x(t,["checkpoints"],g)}return t}function A8(e){const t={},n=y(e,["mediaResolution"]);n!=null&&x(t,["mediaResolution"],n);const r=y(e,["codeExecutionResult"]);r!=null&&x(t,["codeExecutionResult"],r);const i=y(e,["executableCode"]);i!=null&&x(t,["executableCode"],i);const o=y(e,["fileData"]);o!=null&&x(t,["fileData"],OL(o));const c=y(e,["functionCall"]);c!=null&&x(t,["functionCall"],LL(c));const u=y(e,["functionResponse"]);u!=null&&x(t,["functionResponse"],u);const m=y(e,["inlineData"]);m!=null&&x(t,["inlineData"],lL(m));const f=y(e,["text"]);f!=null&&x(t,["text"],f);const h=y(e,["thought"]);h!=null&&x(t,["thought"],h);const g=y(e,["thoughtSignature"]);g!=null&&x(t,["thoughtSignature"],g);const v=y(e,["videoMetadata"]);return v!=null&&x(t,["videoMetadata"],v),t}function C8(e){const t={},n=y(e,["productImage"]);return n!=null&&x(t,["image"],si(n)),t}function T8(e,t){const n={},r=y(e,["numberOfImages"]);t!==void 0&&r!=null&&x(t,["parameters","sampleCount"],r);const i=y(e,["baseSteps"]);t!==void 0&&i!=null&&x(t,["parameters","baseSteps"],i);const o=y(e,["outputGcsUri"]);t!==void 0&&o!=null&&x(t,["parameters","storageUri"],o);const c=y(e,["seed"]);t!==void 0&&c!=null&&x(t,["parameters","seed"],c);const u=y(e,["safetyFilterLevel"]);t!==void 0&&u!=null&&x(t,["parameters","safetySetting"],u);const m=y(e,["personGeneration"]);t!==void 0&&m!=null&&x(t,["parameters","personGeneration"],m);const f=y(e,["addWatermark"]);t!==void 0&&f!=null&&x(t,["parameters","addWatermark"],f);const h=y(e,["outputMimeType"]);t!==void 0&&h!=null&&x(t,["parameters","outputOptions","mimeType"],h);const g=y(e,["outputCompressionQuality"]);t!==void 0&&g!=null&&x(t,["parameters","outputOptions","compressionQuality"],g);const v=y(e,["enhancePrompt"]);t!==void 0&&v!=null&&x(t,["parameters","enhancePrompt"],v);const b=y(e,["labels"]);return t!==void 0&&b!=null&&x(t,["labels"],b),n}function E8(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["_url","model"],tt(e,r));const i=y(t,["source"]);i!=null&&_8(i,n);const o=y(t,["config"]);return o!=null&&T8(o,n),n}function N8(e){const t={},n=y(e,["predictions"]);if(n!=null){let r=n;Array.isArray(r)&&(r=r.map(i=>ch(i))),x(t,["generatedImages"],r)}return t}function _8(e,t){const n={},r=y(e,["prompt"]);t!==void 0&&r!=null&&x(t,["instances[0]","prompt"],r);const i=y(e,["personImage"]);t!==void 0&&i!=null&&x(t,["instances[0]","personImage","image"],si(i));const o=y(e,["productImages"]);if(t!==void 0&&o!=null){let c=o;Array.isArray(c)&&(c=c.map(u=>C8(u))),x(t,["instances[0]","productImages"],c)}return n}function j8(e){const t={},n=y(e,["referenceImage"]);n!=null&&x(t,["referenceImage"],si(n));const r=y(e,["referenceId"]);r!=null&&x(t,["referenceId"],r);const i=y(e,["referenceType"]);i!=null&&x(t,["referenceType"],i);const o=y(e,["maskImageConfig"]);o!=null&&x(t,["maskImageConfig"],S8(o));const c=y(e,["controlImageConfig"]);c!=null&&x(t,["controlImageConfig"],pL(c));const u=y(e,["styleImageConfig"]);u!=null&&x(t,["styleImageConfig"],u);const m=y(e,["subjectImageConfig"]);return m!=null&&x(t,["subjectImageConfig"],m),t}function g3(e){const t={},n=y(e,["safetyAttributes","categories"]);n!=null&&x(t,["categories"],n);const r=y(e,["safetyAttributes","scores"]);r!=null&&x(t,["scores"],r);const i=y(e,["contentType"]);return i!=null&&x(t,["contentType"],i),t}function y3(e){const t={},n=y(e,["safetyAttributes","categories"]);n!=null&&x(t,["categories"],n);const r=y(e,["safetyAttributes","scores"]);r!=null&&x(t,["scores"],r);const i=y(e,["contentType"]);return i!=null&&x(t,["contentType"],i),t}function M8(e){const t={},n=y(e,["category"]);if(n!=null&&x(t,["category"],n),y(e,["method"])!==void 0)throw new Error("method parameter is not supported in Gemini API.");const r=y(e,["threshold"]);return r!=null&&x(t,["threshold"],r),t}function P8(e){const t={},n=y(e,["image"]);return n!=null&&x(t,["image"],si(n)),t}function I8(e,t){const n={},r=y(e,["mode"]);t!==void 0&&r!=null&&x(t,["parameters","mode"],r);const i=y(e,["maxPredictions"]);t!==void 0&&i!=null&&x(t,["parameters","maxPredictions"],i);const o=y(e,["confidenceThreshold"]);t!==void 0&&o!=null&&x(t,["parameters","confidenceThreshold"],o);const c=y(e,["maskDilation"]);t!==void 0&&c!=null&&x(t,["parameters","maskDilation"],c);const u=y(e,["binaryColorThreshold"]);t!==void 0&&u!=null&&x(t,["parameters","binaryColorThreshold"],u);const m=y(e,["labels"]);return t!==void 0&&m!=null&&x(t,["labels"],m),n}function k8(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["_url","model"],tt(e,r));const i=y(t,["source"]);i!=null&&R8(i,n);const o=y(t,["config"]);return o!=null&&I8(o,n),n}function D8(e){const t={},n=y(e,["predictions"]);if(n!=null){let r=n;Array.isArray(r)&&(r=r.map(i=>a8(i))),x(t,["generatedMasks"],r)}return t}function R8(e,t){const n={},r=y(e,["prompt"]);t!==void 0&&r!=null&&x(t,["instances[0]","prompt"],r);const i=y(e,["image"]);t!==void 0&&i!=null&&x(t,["instances[0]","image"],si(i));const o=y(e,["scribbleImage"]);return t!==void 0&&o!=null&&x(t,["instances[0]","scribble"],P8(o)),n}function v3(e){const t={},n=y(e,["languageCode"]);n!=null&&x(t,["languageCode"],n);const r=y(e,["voiceConfig"]);if(r!=null&&x(t,["voiceConfig"],r),y(e,["multiSpeakerVoiceConfig"])!==void 0)throw new Error("multiSpeakerVoiceConfig parameter is not supported in Vertex AI.");return t}function O8(e){const t={},n=y(e,["functionCallingConfig"]);n!=null&&x(t,["functionCallingConfig"],UL(n));const r=y(e,["retrievalConfig"]);return r!=null&&x(t,["retrievalConfig"],r),t}function L8(e){const t={},n=y(e,["functionDeclarations"]);if(n!=null){let h=n;Array.isArray(h)&&(h=h.map(g=>g)),x(t,["functionDeclarations"],h)}if(y(e,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const r=y(e,["googleSearchRetrieval"]);r!=null&&x(t,["googleSearchRetrieval"],r);const i=y(e,["computerUse"]);i!=null&&x(t,["computerUse"],i);const o=y(e,["fileSearch"]);o!=null&&x(t,["fileSearch"],o);const c=y(e,["codeExecution"]);if(c!=null&&x(t,["codeExecution"],c),y(e,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const u=y(e,["googleMaps"]);u!=null&&x(t,["googleMaps"],d8(u));const m=y(e,["googleSearch"]);m!=null&&x(t,["googleSearch"],f8(m));const f=y(e,["urlContext"]);return f!=null&&x(t,["urlContext"],f),t}function x3(e){const t={},n=y(e,["functionDeclarations"]);if(n!=null){let g=n;Array.isArray(g)&&(g=g.map(v=>BL(v))),x(t,["functionDeclarations"],g)}const r=y(e,["retrieval"]);r!=null&&x(t,["retrieval"],r);const i=y(e,["googleSearchRetrieval"]);i!=null&&x(t,["googleSearchRetrieval"],i);const o=y(e,["computerUse"]);if(o!=null&&x(t,["computerUse"],o),y(e,["fileSearch"])!==void 0)throw new Error("fileSearch parameter is not supported in Vertex AI.");const c=y(e,["codeExecution"]);c!=null&&x(t,["codeExecution"],c);const u=y(e,["enterpriseWebSearch"]);u!=null&&x(t,["enterpriseWebSearch"],u);const m=y(e,["googleMaps"]);m!=null&&x(t,["googleMaps"],m);const f=y(e,["googleSearch"]);f!=null&&x(t,["googleSearch"],f);const h=y(e,["urlContext"]);return h!=null&&x(t,["urlContext"],h),t}function U8(e){const t={},n=y(e,["baseModel"]);n!=null&&x(t,["baseModel"],n);const r=y(e,["createTime"]);r!=null&&x(t,["createTime"],r);const i=y(e,["updateTime"]);return i!=null&&x(t,["updateTime"],i),t}function B8(e){const t={},n=y(e,["labels","google-vertex-llm-tuning-base-model-id"]);n!=null&&x(t,["baseModel"],n);const r=y(e,["createTime"]);r!=null&&x(t,["createTime"],r);const i=y(e,["updateTime"]);return i!=null&&x(t,["updateTime"],i),t}function z8(e,t){const n={},r=y(e,["displayName"]);t!==void 0&&r!=null&&x(t,["displayName"],r);const i=y(e,["description"]);t!==void 0&&i!=null&&x(t,["description"],i);const o=y(e,["defaultCheckpointId"]);return t!==void 0&&o!=null&&x(t,["defaultCheckpointId"],o),n}function F8(e,t){const n={},r=y(e,["displayName"]);t!==void 0&&r!=null&&x(t,["displayName"],r);const i=y(e,["description"]);t!==void 0&&i!=null&&x(t,["description"],i);const o=y(e,["defaultCheckpointId"]);return t!==void 0&&o!=null&&x(t,["defaultCheckpointId"],o),n}function q8(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["_url","name"],tt(e,r));const i=y(t,["config"]);return i!=null&&z8(i,n),n}function G8(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["_url","model"],tt(e,r));const i=y(t,["config"]);return i!=null&&F8(i,n),n}function $8(e,t){const n={},r=y(e,["outputGcsUri"]);t!==void 0&&r!=null&&x(t,["parameters","storageUri"],r);const i=y(e,["safetyFilterLevel"]);t!==void 0&&i!=null&&x(t,["parameters","safetySetting"],i);const o=y(e,["personGeneration"]);t!==void 0&&o!=null&&x(t,["parameters","personGeneration"],o);const c=y(e,["includeRaiReason"]);t!==void 0&&c!=null&&x(t,["parameters","includeRaiReason"],c);const u=y(e,["outputMimeType"]);t!==void 0&&u!=null&&x(t,["parameters","outputOptions","mimeType"],u);const m=y(e,["outputCompressionQuality"]);t!==void 0&&m!=null&&x(t,["parameters","outputOptions","compressionQuality"],m);const f=y(e,["enhanceInputImage"]);t!==void 0&&f!=null&&x(t,["parameters","upscaleConfig","enhanceInputImage"],f);const h=y(e,["imagePreservationFactor"]);t!==void 0&&h!=null&&x(t,["parameters","upscaleConfig","imagePreservationFactor"],h);const g=y(e,["labels"]);t!==void 0&&g!=null&&x(t,["labels"],g);const v=y(e,["numberOfImages"]);t!==void 0&&v!=null&&x(t,["parameters","sampleCount"],v);const b=y(e,["mode"]);return t!==void 0&&b!=null&&x(t,["parameters","mode"],b),n}function H8(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["_url","model"],tt(e,r));const i=y(t,["image"]);i!=null&&x(n,["instances[0]","image"],si(i));const o=y(t,["upscaleFactor"]);o!=null&&x(n,["parameters","upscaleConfig","upscaleFactor"],o);const c=y(t,["config"]);return c!=null&&$8(c,n),n}function V8(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["predictions"]);if(r!=null){let i=r;Array.isArray(i)&&(i=i.map(o=>ch(o))),x(t,["generatedImages"],i)}return t}function K8(e){const t={},n=y(e,["uri"]);n!=null&&x(t,["uri"],n);const r=y(e,["encodedVideo"]);r!=null&&x(t,["videoBytes"],Eo(r));const i=y(e,["encoding"]);return i!=null&&x(t,["mimeType"],i),t}function Y8(e){const t={},n=y(e,["gcsUri"]);n!=null&&x(t,["uri"],n);const r=y(e,["bytesBase64Encoded"]);r!=null&&x(t,["videoBytes"],Eo(r));const i=y(e,["mimeType"]);return i!=null&&x(t,["mimeType"],i),t}function W8(e){const t={},n=y(e,["image"]);n!=null&&x(t,["_self"],si(n));const r=y(e,["maskMode"]);return r!=null&&x(t,["maskMode"],r),t}function J8(e){const t={},n=y(e,["image"]);n!=null&&x(t,["image"],uh(n));const r=y(e,["referenceType"]);return r!=null&&x(t,["referenceType"],r),t}function Q8(e){const t={},n=y(e,["image"]);n!=null&&x(t,["image"],si(n));const r=y(e,["referenceType"]);return r!=null&&x(t,["referenceType"],r),t}function b3(e){const t={},n=y(e,["uri"]);n!=null&&x(t,["uri"],n);const r=y(e,["videoBytes"]);r!=null&&x(t,["encodedVideo"],Eo(r));const i=y(e,["mimeType"]);return i!=null&&x(t,["encoding"],i),t}function w3(e){const t={},n=y(e,["uri"]);n!=null&&x(t,["gcsUri"],n);const r=y(e,["videoBytes"]);r!=null&&x(t,["bytesBase64Encoded"],Eo(r));const i=y(e,["mimeType"]);return i!=null&&x(t,["mimeType"],i),t}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */const X8="Content-Type",Z8="X-Server-Timeout",e7="User-Agent",mv="x-goog-api-client",t7="1.30.0",n7=`google-genai-sdk/${t7}`,r7="v1beta1",i7="v1beta",ZC=/^\s*data: (.*)(?:\n\n|\r\r|\r\n\r\n)/;class a7{constructor(t){var n,r;this.clientOptions=Object.assign(Object.assign({},t),{project:t.project,location:t.location,apiKey:t.apiKey,vertexai:t.vertexai});const i={};this.clientOptions.vertexai?(i.apiVersion=(n=this.clientOptions.apiVersion)!==null&&n!==void 0?n:r7,i.baseUrl=this.baseUrlFromProjectLocation(),this.normalizeAuthParameters()):(i.apiVersion=(r=this.clientOptions.apiVersion)!==null&&r!==void 0?r:i7,i.baseUrl="https://generativelanguage.googleapis.com/"),i.headers=this.getDefaultHeaders(),this.clientOptions.httpOptions=i,t.httpOptions&&(this.clientOptions.httpOptions=this.patchHttpOptions(i,t.httpOptions))}baseUrlFromProjectLocation(){return this.clientOptions.project&&this.clientOptions.location&&this.clientOptions.location!=="global"?`https://${this.clientOptions.location}-aiplatform.googleapis.com/`:"https://aiplatform.googleapis.com/"}normalizeAuthParameters(){if(this.clientOptions.project&&this.clientOptions.location){this.clientOptions.apiKey=void 0;return}this.clientOptions.project=void 0,this.clientOptions.location=void 0}isVertexAI(){var t;return(t=this.clientOptions.vertexai)!==null&&t!==void 0?t:!1}getProject(){return this.clientOptions.project}getLocation(){return this.clientOptions.location}getApiVersion(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.apiVersion!==void 0)return this.clientOptions.httpOptions.apiVersion;throw new Error("API version is not set.")}getBaseUrl(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.baseUrl!==void 0)return this.clientOptions.httpOptions.baseUrl;throw new Error("Base URL is not set.")}getRequestUrl(){return this.getRequestUrlInternal(this.clientOptions.httpOptions)}getHeaders(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.headers!==void 0)return this.clientOptions.httpOptions.headers;throw new Error("Headers are not set.")}getRequestUrlInternal(t){if(!t||t.baseUrl===void 0||t.apiVersion===void 0)throw new Error("HTTP options are not correctly set.");const r=[t.baseUrl.endsWith("/")?t.baseUrl.slice(0,-1):t.baseUrl];return t.apiVersion&&t.apiVersion!==""&&r.push(t.apiVersion),r.join("/")}getBaseResourcePath(){return`projects/${this.clientOptions.project}/locations/${this.clientOptions.location}`}getApiKey(){return this.clientOptions.apiKey}getWebsocketBaseUrl(){const t=this.getBaseUrl(),n=new URL(t);return n.protocol=n.protocol=="http:"?"ws":"wss",n.toString()}setBaseUrl(t){if(this.clientOptions.httpOptions)this.clientOptions.httpOptions.baseUrl=t;else throw new Error("HTTP options are not correctly set.")}constructUrl(t,n,r){const i=[this.getRequestUrlInternal(n)];return r&&i.push(this.getBaseResourcePath()),t!==""&&i.push(t),new URL(`${i.join("/")}`)}shouldPrependVertexProjectPath(t){return!(this.clientOptions.apiKey||!this.clientOptions.vertexai||t.path.startsWith("projects/")||t.httpMethod==="GET"&&t.path.startsWith("publishers/google/models"))}async request(t){let n=this.clientOptions.httpOptions;t.httpOptions&&(n=this.patchHttpOptions(this.clientOptions.httpOptions,t.httpOptions));const r=this.shouldPrependVertexProjectPath(t),i=this.constructUrl(t.path,n,r);if(t.queryParams)for(const[c,u]of Object.entries(t.queryParams))i.searchParams.append(c,String(u));let o={};if(t.httpMethod==="GET"){if(t.body&&t.body!=="{}")throw new Error("Request body should be empty for GET request, but got non empty request body")}else o.body=t.body;return o=await this.includeExtraHttpOptionsToRequestInit(o,n,i.toString(),t.abortSignal),this.unaryApiCall(i,o,t.httpMethod)}patchHttpOptions(t,n){const r=JSON.parse(JSON.stringify(t));for(const[i,o]of Object.entries(n))typeof o=="object"?r[i]=Object.assign(Object.assign({},r[i]),o):o!==void 0&&(r[i]=o);return r}async requestStream(t){let n=this.clientOptions.httpOptions;t.httpOptions&&(n=this.patchHttpOptions(this.clientOptions.httpOptions,t.httpOptions));const r=this.shouldPrependVertexProjectPath(t),i=this.constructUrl(t.path,n,r);(!i.searchParams.has("alt")||i.searchParams.get("alt")!=="sse")&&i.searchParams.set("alt","sse");let o={};return o.body=t.body,o=await this.includeExtraHttpOptionsToRequestInit(o,n,i.toString(),t.abortSignal),this.streamApiCall(i,o,t.httpMethod)}async includeExtraHttpOptionsToRequestInit(t,n,r,i){if(n&&n.timeout||i){const o=new AbortController,c=o.signal;if(n.timeout&&(n==null?void 0:n.timeout)>0){const u=setTimeout(()=>o.abort(),n.timeout);u&&typeof u.unref=="function"&&u.unref()}i&&i.addEventListener("abort",()=>{o.abort()}),t.signal=c}return n&&n.extraBody!==null&&o7(t,n.extraBody),t.headers=await this.getHeadersInternal(n,r),t}async unaryApiCall(t,n,r){return this.apiCall(t.toString(),Object.assign(Object.assign({},n),{method:r})).then(async i=>(await eT(i),new lv(i))).catch(i=>{throw i instanceof Error?i:new Error(JSON.stringify(i))})}async streamApiCall(t,n,r){return this.apiCall(t.toString(),Object.assign(Object.assign({},n),{method:r})).then(async i=>(await eT(i),this.processStreamResponse(i))).catch(i=>{throw i instanceof Error?i:new Error(JSON.stringify(i))})}processStreamResponse(t){var n;return kl(this,arguments,function*(){const i=(n=t==null?void 0:t.body)===null||n===void 0?void 0:n.getReader(),o=new TextDecoder("utf-8");if(!i)throw new Error("Response body is empty");try{let c="";for(;;){const{done:u,value:m}=yield Nt(i.read());if(u){if(c.trim().length>0)throw new Error("Incomplete JSON segment at the end");break}const f=o.decode(m,{stream:!0});try{const g=JSON.parse(f);if("error"in g){const v=JSON.parse(JSON.stringify(g.error)),b=v.status,T=v.code,C=`got status: ${b}. ${JSON.stringify(g)}`;if(T>=400&&T<600)throw new sh({message:C,status:T})}}catch(g){if(g.name==="ApiError")throw g}c+=f;let h=c.match(ZC);for(;h;){const g=h[1];try{const v=new Response(g,{headers:t==null?void 0:t.headers,status:t==null?void 0:t.status,statusText:t==null?void 0:t.statusText});yield yield Nt(new lv(v)),c=c.slice(h[0].length),h=c.match(ZC)}catch(v){throw new Error(`exception parsing stream chunk ${g}. ${v}`)}}}}finally{i.releaseLock()}})}async apiCall(t,n){return fetch(t,n).catch(r=>{throw new Error(`exception ${r} sending request`)})}getDefaultHeaders(){const t={},n=n7+" "+this.clientOptions.userAgentExtra;return t[e7]=n,t[mv]=n,t[X8]="application/json",t}async getHeadersInternal(t,n){const r=new Headers;if(t&&t.headers){for(const[i,o]of Object.entries(t.headers))r.append(i,o);t.timeout&&t.timeout>0&&r.append(Z8,String(Math.ceil(t.timeout/1e3)))}return await this.clientOptions.auth.addAuthHeaders(r,n),r}getFileName(t){var n;let r="";return typeof t=="string"&&(r=t.replace(/[/\\]+$/,""),r=(n=r.split(/[/\\]/).pop())!==null&&n!==void 0?n:""),r}async uploadFile(t,n){var r;const i={};n!=null&&(i.mimeType=n.mimeType,i.name=n.name,i.displayName=n.displayName),i.name&&!i.name.startsWith("files/")&&(i.name=`files/${i.name}`);const o=this.clientOptions.uploader,c=await o.stat(t);i.sizeBytes=String(c.size);const u=(r=n==null?void 0:n.mimeType)!==null&&r!==void 0?r:c.type;if(u===void 0||u==="")throw new Error("Can not determine mimeType. Please provide mimeType in the config.");i.mimeType=u;const m={file:i},f=this.getFileName(t),h=be("upload/v1beta/files",m._url),g=await this.fetchUploadUrl(h,i.sizeBytes,i.mimeType,f,m,n==null?void 0:n.httpOptions);return o.upload(t,g,this)}async uploadFileToFileSearchStore(t,n,r){var i;const o=this.clientOptions.uploader,c=await o.stat(n),u=String(c.size),m=(i=r==null?void 0:r.mimeType)!==null&&i!==void 0?i:c.type;if(m===void 0||m==="")throw new Error("Can not determine mimeType. Please provide mimeType in the config.");const f=`upload/v1beta/${t}:uploadToFileSearchStore`,h=this.getFileName(n),g={};r!=null&&r.customMetadata&&(g.customMetadata=r.customMetadata),r!=null&&r.chunkingConfig&&(g.chunkingConfig=r.chunkingConfig);const v=await this.fetchUploadUrl(f,u,m,h,g,r==null?void 0:r.httpOptions);return o.uploadToFileSearchStore(n,v,this)}async downloadFile(t){await this.clientOptions.downloader.download(t,this)}async fetchUploadUrl(t,n,r,i,o,c){var u;let m={};c?m=c:m={apiVersion:"",headers:Object.assign({"Content-Type":"application/json","X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":`${n}`,"X-Goog-Upload-Header-Content-Type":`${r}`},i?{"X-Goog-Upload-File-Name":i}:{})};const f=await this.request({path:t,body:JSON.stringify(o),httpMethod:"POST",httpOptions:m});if(!f||!(f!=null&&f.headers))throw new Error("Server did not return an HttpResponse or the returned HttpResponse did not have headers.");const h=(u=f==null?void 0:f.headers)===null||u===void 0?void 0:u["x-goog-upload-url"];if(h===void 0)throw new Error("Failed to get upload url. Server did not return the x-google-upload-url in the headers");return h}}async function eT(e){var t;if(e===void 0)throw new Error("response is undefined");if(!e.ok){const n=e.status;let r;!((t=e.headers.get("content-type"))===null||t===void 0)&&t.includes("application/json")?r=await e.json():r={error:{message:await e.text(),code:e.status,status:e.statusText}};const i=JSON.stringify(r);throw n>=400&&n<600?new sh({message:i,status:n}):new Error(i)}}function o7(e,t){if(!t||Object.keys(t).length===0)return;if(e.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 n={};if(typeof e.body=="string"&&e.body.length>0)try{const o=JSON.parse(e.body);if(typeof o=="object"&&o!==null&&!Array.isArray(o))n=o;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 r(o,c){const u=Object.assign({},o);for(const m in c)if(Object.prototype.hasOwnProperty.call(c,m)){const f=c[m],h=u[m];f&&typeof f=="object"&&!Array.isArray(f)&&h&&typeof h=="object"&&!Array.isArray(h)?u[m]=r(h,f):(h&&f&&typeof h!=typeof f&&console.warn(`includeExtraBodyToRequestInit:deepMerge: Type mismatch for key "${m}". Original type: ${typeof h}, New type: ${typeof f}. Overwriting.`),u[m]=f)}return u}const i=r(n,t);e.body=JSON.stringify(i)}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */const s7="mcp_used/unknown";let l7=!1;function S3(e){for(const t of e)if(c7(t)||typeof t=="object"&&"inputSchema"in t)return!0;return l7}function A3(e){var t;const n=(t=e[mv])!==null&&t!==void 0?t:"";e[mv]=(n+` ${s7}`).trimStart()}function c7(e){return e!==null&&typeof e=="object"&&e instanceof Lx}function u7(e,t=100){return kl(this,arguments,function*(){let r,i=0;for(;i0)return;const o={},c=[];for(const h of this.mcpClients)try{for(var u=!0,m=(n=void 0,_u(u7(h))),f;f=await m.next(),t=f.done,!t;u=!0){i=f.value,u=!1;const g=i;c.push(g);const v=g.name;if(o[v])throw new Error(`Duplicate function name ${v} found in MCP tools. Please ensure function names are unique.`);o[v]=h}}catch(g){n={error:g}}finally{try{!u&&!t&&(r=m.return)&&await r.call(m)}finally{if(n)throw n.error}}this.mcpTools=c,this.functionNameToMcpClient=o}async tool(){return await this.initialize(),nO(this.mcpTools,this.config)}async callTool(t){await this.initialize();const n=[];for(const r of t)if(r.name in this.functionNameToMcpClient){const i=this.functionNameToMcpClient[r.name];let o;this.config.timeout&&(o={timeout:this.config.timeout});const c=await i.callTool({name:r.name,arguments:r.args},void 0,o);n.push({functionResponse:{name:r.name,response:c.isError?{error:c}:c}})}return n}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */async function d7(e,t,n){const r=new YR;let i;n.data instanceof Blob?i=JSON.parse(await n.data.text()):i=JSON.parse(n.data),Object.assign(r,i),t(r)}class f7{constructor(t,n,r){this.apiClient=t,this.auth=n,this.webSocketFactory=r}async connect(t){var n,r;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 i=this.apiClient.getWebsocketBaseUrl(),o=this.apiClient.getApiVersion(),c=p7(this.apiClient.getDefaultHeaders()),u=this.apiClient.getApiKey(),m=`${i}/ws/google.ai.generativelanguage.${o}.GenerativeService.BidiGenerateMusic?key=${u}`;let f=()=>{};const h=new Promise(P=>{f=P}),g=t.callbacks,v=function(){f({})},b=this.apiClient,T={onopen:v,onmessage:P=>{d7(b,g.onmessage,P)},onerror:(n=g==null?void 0:g.onerror)!==null&&n!==void 0?n:function(P){},onclose:(r=g==null?void 0:g.onclose)!==null&&r!==void 0?r:function(P){}},C=this.webSocketFactory.create(m,h7(c),T);C.connect(),await h;const I={setup:{model:tt(this.apiClient,t.model)}};return C.send(JSON.stringify(I)),new m7(C,this.apiClient)}}class m7{constructor(t,n){this.conn=t,this.apiClient=n}async setWeightedPrompts(t){if(!t.weightedPrompts||Object.keys(t.weightedPrompts).length===0)throw new Error("Weighted prompts must be set and contain at least one entry.");const n=Z6(t);this.conn.send(JSON.stringify({clientContent:n}))}async setMusicGenerationConfig(t){t.musicGenerationConfig||(t.musicGenerationConfig={});const n=X6(t);this.conn.send(JSON.stringify(n))}sendPlaybackControl(t){const n={playbackControl:t};this.conn.send(JSON.stringify(n))}play(){this.sendPlaybackControl(Nl.PLAY)}pause(){this.sendPlaybackControl(Nl.PAUSE)}stop(){this.sendPlaybackControl(Nl.STOP)}resetContext(){this.sendPlaybackControl(Nl.RESET_CONTEXT)}close(){this.conn.close()}}function h7(e){const t={};return e.forEach((n,r)=>{t[r]=n}),t}function p7(e){const t=new Headers;for(const[n,r]of Object.entries(e))t.append(n,r);return t}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */const g7="FunctionResponse request must have an `id` field from the response of a ToolCall.FunctionalCalls in Google AI.";async function y7(e,t,n){const r=new KR;let i;n.data instanceof Blob?i=await n.data.text():n.data instanceof ArrayBuffer?i=new TextDecoder().decode(n.data):i=n.data;const o=JSON.parse(i);if(e.isVertexAI()){const c=nL(o);Object.assign(r,c)}else Object.assign(r,o);t(r)}class v7{constructor(t,n,r){this.apiClient=t,this.auth=n,this.webSocketFactory=r,this.music=new f7(this.apiClient,this.auth,this.webSocketFactory)}async connect(t){var n,r,i,o,c,u;if(t.config&&t.config.httpOptions)throw new Error("The Live module does not support httpOptions at request-level in LiveConnectConfig yet. Please use the client-level httpOptions configuration instead.");const m=this.apiClient.getWebsocketBaseUrl(),f=this.apiClient.getApiVersion();let h;const g=this.apiClient.getHeaders();t.config&&t.config.tools&&S3(t.config.tools)&&A3(g);const v=S7(g);if(this.apiClient.isVertexAI())h=`${m}/ws/google.cloud.aiplatform.${f}.LlmBidiService/BidiGenerateContent`,await this.auth.addAuthHeaders(v,h);else{const q=this.apiClient.getApiKey();let G="BidiGenerateContent",H="key";q!=null&&q.startsWith("auth_tokens/")&&(console.warn("Warning: Ephemeral token support is experimental and may change in future versions."),f!=="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."),G="BidiGenerateContentConstrained",H="access_token"),h=`${m}/ws/google.ai.generativelanguage.${f}.GenerativeService.${G}?${H}=${q}`}let b=()=>{};const T=new Promise(q=>{b=q}),C=t.callbacks,E=function(){var q;(q=C==null?void 0:C.onopen)===null||q===void 0||q.call(C),b({})},N=this.apiClient,I={onopen:E,onmessage:q=>{y7(N,C.onmessage,q)},onerror:(n=C==null?void 0:C.onerror)!==null&&n!==void 0?n:function(q){},onclose:(r=C==null?void 0:C.onclose)!==null&&r!==void 0?r:function(q){}},P=this.webSocketFactory.create(h,w7(v),I);P.connect(),await T;let M=tt(this.apiClient,t.model);if(this.apiClient.isVertexAI()&&M.startsWith("publishers/")){const q=this.apiClient.getProject(),G=this.apiClient.getLocation();M=`projects/${q}/locations/${G}/`+M}let j={};this.apiClient.isVertexAI()&&((i=t.config)===null||i===void 0?void 0:i.responseModalities)===void 0&&(t.config===void 0?t.config={responseModalities:[Mu.AUDIO]}:t.config.responseModalities=[Mu.AUDIO]),!((o=t.config)===null||o===void 0)&&o.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 k=(u=(c=t.config)===null||c===void 0?void 0:c.tools)!==null&&u!==void 0?u:[],R=[];for(const q of k)if(this.isCallableTool(q)){const G=q;R.push(await G.tool())}else R.push(q);R.length>0&&(t.config.tools=R);const F={model:M,config:t.config,callbacks:t.callbacks};return this.apiClient.isVertexAI()?j=Q6(this.apiClient,F):j=J6(this.apiClient,F),delete j.config,P.send(JSON.stringify(j)),new b7(P,this.apiClient)}isCallableTool(t){return"callTool"in t&&typeof t.callTool=="function"}}const x7={turnComplete:!0};class b7{constructor(t,n){this.conn=t,this.apiClient=n}tLiveClientContent(t,n){if(n.turns!==null&&n.turns!==void 0){let r=[];try{r=Hr(n.turns),t.isVertexAI()||(r=r.map(i=>lh(i)))}catch{throw new Error(`Failed to parse client content "turns", type: '${typeof n.turns}'`)}return{clientContent:{turns:r,turnComplete:n.turnComplete}}}return{clientContent:{turnComplete:n.turnComplete}}}tLiveClienttToolResponse(t,n){let r=[];if(n.functionResponses==null)throw new Error("functionResponses is required.");if(Array.isArray(n.functionResponses)?r=n.functionResponses:r=[n.functionResponses],r.length===0)throw new Error("functionResponses is required.");for(const o of r){if(typeof o!="object"||o===null||!("name"in o)||!("response"in o))throw new Error(`Could not parse function response, type '${typeof o}'.`);if(!t.isVertexAI()&&!("id"in o))throw new Error(g7)}return{toolResponse:{functionResponses:r}}}sendClientContent(t){t=Object.assign(Object.assign({},x7),t);const n=this.tLiveClientContent(this.apiClient,t);this.conn.send(JSON.stringify(n))}sendRealtimeInput(t){let n={};this.apiClient.isVertexAI()?n={realtimeInput:tL(t)}:n={realtimeInput:eL(t)},this.conn.send(JSON.stringify(n))}sendToolResponse(t){if(t.functionResponses==null)throw new Error("Tool response parameters are required.");const n=this.tLiveClienttToolResponse(this.apiClient,t);this.conn.send(JSON.stringify(n))}close(){this.conn.close()}}function w7(e){const t={};return e.forEach((n,r)=>{t[r]=n}),t}function S7(e){const t=new Headers;for(const[n,r]of Object.entries(e))t.append(n,r);return t}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */const tT=10;function nT(e){var t,n,r;if(!((t=e==null?void 0:e.automaticFunctionCalling)===null||t===void 0)&&t.disable)return!0;let i=!1;for(const c of(n=e==null?void 0:e.tools)!==null&&n!==void 0?n:[])if(Dl(c)){i=!0;break}if(!i)return!0;const o=(r=e==null?void 0:e.automaticFunctionCalling)===null||r===void 0?void 0:r.maximumRemoteCalls;return o&&(o<0||!Number.isInteger(o))||o==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:",o),!0):!1}function Dl(e){return"callTool"in e&&typeof e.callTool=="function"}function A7(e){var t,n,r;return(r=(n=(t=e.config)===null||t===void 0?void 0:t.tools)===null||n===void 0?void 0:n.some(i=>Dl(i)))!==null&&r!==void 0?r:!1}function rT(e){var t;const n=[];return!((t=e==null?void 0:e.config)===null||t===void 0)&&t.tools&&e.config.tools.forEach((r,i)=>{if(Dl(r))return;const o=r;o.functionDeclarations&&o.functionDeclarations.length>0&&n.push(i)}),n}function iT(e){var t;return!(!((t=e==null?void 0:e.automaticFunctionCalling)===null||t===void 0)&&t.ignoreCallHistory)}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class C7 extends Sa{constructor(t){super(),this.apiClient=t,this.generateContent=async n=>{var r,i,o,c,u;const m=await this.processParamsMaybeAddMcpUsage(n);if(this.maybeMoveToResponseJsonSchem(n),!A7(n)||nT(n.config))return await this.generateContentInternal(m);const f=rT(n);if(f.length>0){const C=f.map(E=>`tools[${E}]`).join(", ");throw new Error(`Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations is not yet supported. Incompatible tools found at ${C}.`)}let h,g;const v=Hr(m.contents),b=(o=(i=(r=m.config)===null||r===void 0?void 0:r.automaticFunctionCalling)===null||i===void 0?void 0:i.maximumRemoteCalls)!==null&&o!==void 0?o:tT;let T=0;for(;T{var r,i,o,c,u;if(this.maybeMoveToResponseJsonSchem(n),nT(n.config)){const g=await this.processParamsMaybeAddMcpUsage(n);return await this.generateContentStreamInternal(g)}const m=rT(n);if(m.length>0){const g=m.map(v=>`tools[${v}]`).join(", ");throw new Error(`Incompatible tools found at ${g}. Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations" is not yet supported.`)}const f=(o=(i=(r=n==null?void 0:n.config)===null||r===void 0?void 0:r.toolConfig)===null||i===void 0?void 0:i.functionCallingConfig)===null||o===void 0?void 0:o.streamFunctionCallArguments,h=(u=(c=n==null?void 0:n.config)===null||c===void 0?void 0:c.automaticFunctionCalling)===null||u===void 0?void 0:u.disable;if(f&&!h)throw new Error("Running in streaming mode with 'streamFunctionCallArguments' enabled, this feature is not compatible with automatic function calling (AFC). Please set 'config.automaticFunctionCalling.disable' to true to disable AFC or leave 'config.toolConfig.functionCallingConfig.streamFunctionCallArguments' to be undefined or set to false to disable streaming function call arguments feature.");return await this.processAfcStream(n)},this.generateImages=async n=>await this.generateImagesInternal(n).then(r=>{var i;let o;const c=[];if(r!=null&&r.generatedImages)for(const m of r.generatedImages)m&&(m!=null&&m.safetyAttributes)&&((i=m==null?void 0:m.safetyAttributes)===null||i===void 0?void 0:i.contentType)==="Positive Prompt"?o=m==null?void 0:m.safetyAttributes:c.push(m);let u;return o?u={generatedImages:c,positivePromptSafetyAttributes:o,sdkHttpResponse:r.sdkHttpResponse}:u={generatedImages:c,sdkHttpResponse:r.sdkHttpResponse},u}),this.list=async n=>{var r;const c={config:Object.assign(Object.assign({},{queryBase:!0}),n==null?void 0:n.config)};if(this.apiClient.isVertexAI()&&!c.config.queryBase){if(!((r=c.config)===null||r===void 0)&&r.filter)throw new Error("Filtering tuned models list for Vertex AI is not currently supported");c.config.filter="labels.tune-type:*"}return new ks(ma.PAGED_ITEM_MODELS,u=>this.listInternal(u),await this.listInternal(c),c)},this.editImage=async n=>{const r={model:n.model,prompt:n.prompt,referenceImages:[],config:n.config};return n.referenceImages&&n.referenceImages&&(r.referenceImages=n.referenceImages.map(i=>i.toReferenceImageAPI())),await this.editImageInternal(r)},this.upscaleImage=async n=>{let r={numberOfImages:1,mode:"upscale"};n.config&&(r=Object.assign(Object.assign({},r),n.config));const i={model:n.model,image:n.image,upscaleFactor:n.upscaleFactor,config:r};return await this.upscaleImageInternal(i)},this.generateVideos=async n=>{var r,i,o,c,u,m;if((n.prompt||n.image||n.video)&&n.source)throw new Error("Source and prompt/image/video are mutually exclusive. Please only use source.");return this.apiClient.isVertexAI()||(!((r=n.video)===null||r===void 0)&&r.uri&&(!((i=n.video)===null||i===void 0)&&i.videoBytes)?n.video={uri:n.video.uri,mimeType:n.video.mimeType}:!((c=(o=n.source)===null||o===void 0?void 0:o.video)===null||c===void 0)&&c.uri&&(!((m=(u=n.source)===null||u===void 0?void 0:u.video)===null||m===void 0)&&m.videoBytes)&&(n.source.video={uri:n.source.video.uri,mimeType:n.source.video.mimeType})),await this.generateVideosInternal(n)}}maybeMoveToResponseJsonSchem(t){t.config&&t.config.responseSchema&&(t.config.responseJsonSchema||Object.keys(t.config.responseSchema).includes("$schema")&&(t.config.responseJsonSchema=t.config.responseSchema,delete t.config.responseSchema))}async processParamsMaybeAddMcpUsage(t){var n,r,i;const o=(n=t.config)===null||n===void 0?void 0:n.tools;if(!o)return t;const c=await Promise.all(o.map(async m=>Dl(m)?await m.tool():m)),u={model:t.model,contents:t.contents,config:Object.assign(Object.assign({},t.config),{tools:c})};if(u.config.tools=c,t.config&&t.config.tools&&S3(t.config.tools)){const m=(i=(r=t.config.httpOptions)===null||r===void 0?void 0:r.headers)!==null&&i!==void 0?i:{};let f=Object.assign({},m);Object.keys(f).length===0&&(f=this.apiClient.getDefaultHeaders()),A3(f),u.config.httpOptions=Object.assign(Object.assign({},t.config.httpOptions),{headers:f})}return u}async initAfcToolsMap(t){var n,r,i;const o=new Map;for(const c of(r=(n=t.config)===null||n===void 0?void 0:n.tools)!==null&&r!==void 0?r:[])if(Dl(c)){const u=c,m=await u.tool();for(const f of(i=m.functionDeclarations)!==null&&i!==void 0?i:[]){if(!f.name)throw new Error("Function declaration name is required.");if(o.has(f.name))throw new Error(`Duplicate tool declaration name: ${f.name}`);o.set(f.name,u)}}return o}async processAfcStream(t){var n,r,i;const o=(i=(r=(n=t.config)===null||n===void 0?void 0:n.automaticFunctionCalling)===null||r===void 0?void 0:r.maximumRemoteCalls)!==null&&i!==void 0?i:tT;let c=!1,u=0;const m=await this.initAfcToolsMap(t);return(function(f,h,g){var v,b;return kl(this,arguments,function*(){for(var T,C,E,N;u0){c=!0;const q=new pu;q.candidates=[{content:{role:"user",parts:R}}],yield yield Nt(q);const G=[];G.push(...F),G.push({role:"user",parts:R});const H=Hr(g.contents).concat(G);g.contents=H}else break}})})(this,m,t)}async generateContentInternal(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=JC(this.apiClient,t);return u=be("{model}:generateContent",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=XC(h),v=new pu;return Object.assign(v,g),v})}else{const f=WC(this.apiClient,t);return u=be("{model}:generateContent",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=QC(h),v=new pu;return Object.assign(v,g),v})}}async generateContentStreamInternal(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=JC(this.apiClient,t);return u=be("{model}:streamGenerateContent?alt=sse",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.requestStream({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}),c.then(function(g){return kl(this,arguments,function*(){var v,b,T,C;try{for(var E=!0,N=_u(g),I;I=yield Nt(N.next()),v=I.done,!v;E=!0){C=I.value,E=!1;const P=C,M=XC(yield Nt(P.json()));M.sdkHttpResponse={headers:P.headers};const j=new pu;Object.assign(j,M),yield yield Nt(j)}}catch(P){b={error:P}}finally{try{!E&&!v&&(T=N.return)&&(yield Nt(T.call(N)))}finally{if(b)throw b.error}}})})}else{const f=WC(this.apiClient,t);return u=be("{model}:streamGenerateContent?alt=sse",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.requestStream({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}),c.then(function(g){return kl(this,arguments,function*(){var v,b,T,C;try{for(var E=!0,N=_u(g),I;I=yield Nt(N.next()),v=I.done,!v;E=!0){C=I.value,E=!1;const P=C,M=QC(yield Nt(P.json()));M.sdkHttpResponse={headers:P.headers};const j=new pu;Object.assign(j,M),yield yield Nt(j)}}catch(P){b={error:P}}finally{try{!E&&!v&&(T=N.return)&&(yield Nt(T.call(N)))}finally{if(b)throw b.error}}})})}}async embedContent(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=IL(this.apiClient,t);return u=be("{model}:predict",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=DL(h),v=new kC;return Object.assign(v,g),v})}else{const f=PL(this.apiClient,t);return u=be("{model}:batchEmbedContents",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=kL(h),v=new kC;return Object.assign(v,g),v})}}async generateImagesInternal(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=HL(this.apiClient,t);return u=be("{model}:predict",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=KL(h),v=new DC;return Object.assign(v,g),v})}else{const f=$L(this.apiClient,t);return u=be("{model}:predict",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=VL(h),v=new DC;return Object.assign(v,g),v})}}async editImageInternal(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI()){const u=NL(this.apiClient,t);return o=be("{model}:predict",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json().then(f=>{const h=f;return h.sdkHttpResponse={headers:m.headers},h})),i.then(m=>{const f=_L(m),h=new OR;return Object.assign(h,f),h})}else throw new Error("This method is only supported by the Vertex AI.")}async upscaleImageInternal(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI()){const u=H8(this.apiClient,t);return o=be("{model}:predict",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json().then(f=>{const h=f;return h.sdkHttpResponse={headers:m.headers},h})),i.then(m=>{const f=V8(m),h=new LR;return Object.assign(h,f),h})}else throw new Error("This method is only supported by the Vertex AI.")}async recontextImage(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI()){const u=E8(this.apiClient,t);return o=be("{model}:predict",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json()),i.then(m=>{const f=N8(m),h=new UR;return Object.assign(h,f),h})}else throw new Error("This method is only supported by the Vertex AI.")}async segmentImage(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI()){const u=k8(this.apiClient,t);return o=be("{model}:predict",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json()),i.then(m=>{const f=D8(m),h=new BR;return Object.assign(h,f),h})}else throw new Error("This method is only supported by the Vertex AI.")}async get(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=u8(this.apiClient,t);return u=be("{name}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json()),c.then(h=>fv(h))}else{const f=c8(this.apiClient,t);return u=be("{name}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json()),c.then(h=>dv(h))}}async listInternal(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=x8(this.apiClient,t);return u=be("{models_url}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=w8(h),v=new RC;return Object.assign(v,g),v})}else{const f=v8(this.apiClient,t);return u=be("{models_url}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=b8(h),v=new RC;return Object.assign(v,g),v})}}async update(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=G8(this.apiClient,t);return u=be("{model}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"PATCH",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json()),c.then(h=>fv(h))}else{const f=q8(this.apiClient,t);return u=be("{name}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"PATCH",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json()),c.then(h=>dv(h))}}async delete(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=AL(this.apiClient,t);return u=be("{name}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"DELETE",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=TL(h),v=new OC;return Object.assign(v,g),v})}else{const f=SL(this.apiClient,t);return u=be("{name}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"DELETE",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=CL(h),v=new OC;return Object.assign(v,g),v})}}async countTokens(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=xL(this.apiClient,t);return u=be("{model}:countTokens",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=wL(h),v=new LC;return Object.assign(v,g),v})}else{const f=vL(this.apiClient,t);return u=be("{model}:countTokens",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=bL(h),v=new LC;return Object.assign(v,g),v})}}async computeTokens(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI()){const u=dL(this.apiClient,t);return o=be("{model}:computeTokens",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json().then(f=>{const h=f;return h.sdkHttpResponse={headers:m.headers},h})),i.then(m=>{const f=fL(m),h=new zR;return Object.assign(h,f),h})}else throw new Error("This method is only supported by the Vertex AI.")}async generateVideosInternal(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=ZL(this.apiClient,t);return u=be("{model}:predictLongRunning",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json()),c.then(h=>{const g=QL(h),v=new lm;return Object.assign(v,g),v})}else{const f=XL(this.apiClient,t);return u=be("{model}:predictLongRunning",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"POST",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json()),c.then(h=>{const g=JL(h),v=new lm;return Object.assign(v,g),v})}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class T7 extends Sa{constructor(t){super(),this.apiClient=t}async getVideosOperation(t){const n=t.operation,r=t.config;if(n.name===void 0||n.name==="")throw new Error("Operation name is required.");if(this.apiClient.isVertexAI()){const i=n.name.split("/operations/")[0];let o;r&&"httpOptions"in r&&(o=r.httpOptions);const c=await this.fetchPredictVideosOperationInternal({operationName:n.name,resourceName:i,config:{httpOptions:o}});return n._fromAPIResponse({apiResponse:c,_isVertexAI:!0})}else{const i=await this.getVideosOperationInternal({operationName:n.name,config:r});return n._fromAPIResponse({apiResponse:i,_isVertexAI:!1})}}async get(t){const n=t.operation,r=t.config;if(n.name===void 0||n.name==="")throw new Error("Operation name is required.");if(this.apiClient.isVertexAI()){const i=n.name.split("/operations/")[0];let o;r&&"httpOptions"in r&&(o=r.httpOptions);const c=await this.fetchPredictVideosOperationInternal({operationName:n.name,resourceName:i,config:{httpOptions:o}});return n._fromAPIResponse({apiResponse:c,_isVertexAI:!0})}else{const i=await this.getVideosOperationInternal({operationName:n.name,config:r});return n._fromAPIResponse({apiResponse:i,_isVertexAI:!1})}}async getVideosOperationInternal(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=MR(t);return u=be("{operationName}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json()),c}else{const f=jR(t);return u=be("{operationName}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json()),c}}async fetchPredictVideosOperationInternal(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI()){const u=SR(t);return o=be("{resourceName}:fetchPredictOperation",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json()),i}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 E7(e){const t={},n=y(e,["data"]);if(n!=null&&x(t,["data"],n),y(e,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const r=y(e,["mimeType"]);return r!=null&&x(t,["mimeType"],r),t}function N7(e){const t={},n=y(e,["parts"]);if(n!=null){let i=n;Array.isArray(i)&&(i=i.map(o=>O7(o))),x(t,["parts"],i)}const r=y(e,["role"]);return r!=null&&x(t,["role"],r),t}function _7(e,t,n){const r={},i=y(t,["expireTime"]);n!==void 0&&i!=null&&x(n,["expireTime"],i);const o=y(t,["newSessionExpireTime"]);n!==void 0&&o!=null&&x(n,["newSessionExpireTime"],o);const c=y(t,["uses"]);n!==void 0&&c!=null&&x(n,["uses"],c);const u=y(t,["liveConnectConstraints"]);n!==void 0&&u!=null&&x(n,["bidiGenerateContentSetup"],R7(e,u));const m=y(t,["lockAdditionalFields"]);return n!==void 0&&m!=null&&x(n,["fieldMask"],m),r}function j7(e,t){const n={},r=y(t,["config"]);return r!=null&&x(n,["config"],_7(e,r,n)),n}function M7(e){const t={};if(y(e,["displayName"])!==void 0)throw new Error("displayName parameter is not supported in Gemini API.");const n=y(e,["fileUri"]);n!=null&&x(t,["fileUri"],n);const r=y(e,["mimeType"]);return r!=null&&x(t,["mimeType"],r),t}function P7(e){const t={},n=y(e,["id"]);n!=null&&x(t,["id"],n);const r=y(e,["args"]);r!=null&&x(t,["args"],r);const i=y(e,["name"]);if(i!=null&&x(t,["name"],i),y(e,["partialArgs"])!==void 0)throw new Error("partialArgs parameter is not supported in Gemini API.");if(y(e,["willContinue"])!==void 0)throw new Error("willContinue parameter is not supported in Gemini API.");return t}function I7(e){const t={};if(y(e,["authConfig"])!==void 0)throw new Error("authConfig parameter is not supported in Gemini API.");const n=y(e,["enableWidget"]);return n!=null&&x(t,["enableWidget"],n),t}function k7(e){const t={};if(y(e,["excludeDomains"])!==void 0)throw new Error("excludeDomains parameter is not supported in Gemini API.");if(y(e,["blockingConfidence"])!==void 0)throw new Error("blockingConfidence parameter is not supported in Gemini API.");const n=y(e,["timeRangeFilter"]);return n!=null&&x(t,["timeRangeFilter"],n),t}function D7(e,t){const n={},r=y(e,["generationConfig"]);t!==void 0&&r!=null&&x(t,["setup","generationConfig"],r);const i=y(e,["responseModalities"]);t!==void 0&&i!=null&&x(t,["setup","generationConfig","responseModalities"],i);const o=y(e,["temperature"]);t!==void 0&&o!=null&&x(t,["setup","generationConfig","temperature"],o);const c=y(e,["topP"]);t!==void 0&&c!=null&&x(t,["setup","generationConfig","topP"],c);const u=y(e,["topK"]);t!==void 0&&u!=null&&x(t,["setup","generationConfig","topK"],u);const m=y(e,["maxOutputTokens"]);t!==void 0&&m!=null&&x(t,["setup","generationConfig","maxOutputTokens"],m);const f=y(e,["mediaResolution"]);t!==void 0&&f!=null&&x(t,["setup","generationConfig","mediaResolution"],f);const h=y(e,["seed"]);t!==void 0&&h!=null&&x(t,["setup","generationConfig","seed"],h);const g=y(e,["speechConfig"]);t!==void 0&&g!=null&&x(t,["setup","generationConfig","speechConfig"],Ox(g));const v=y(e,["thinkingConfig"]);t!==void 0&&v!=null&&x(t,["setup","generationConfig","thinkingConfig"],v);const b=y(e,["enableAffectiveDialog"]);t!==void 0&&b!=null&&x(t,["setup","generationConfig","enableAffectiveDialog"],b);const T=y(e,["systemInstruction"]);t!==void 0&&T!=null&&x(t,["setup","systemInstruction"],N7(Ln(T)));const C=y(e,["tools"]);if(t!==void 0&&C!=null){let k=ic(C);Array.isArray(k)&&(k=k.map(R=>U7(rc(R)))),x(t,["setup","tools"],k)}const E=y(e,["sessionResumption"]);t!==void 0&&E!=null&&x(t,["setup","sessionResumption"],L7(E));const N=y(e,["inputAudioTranscription"]);t!==void 0&&N!=null&&x(t,["setup","inputAudioTranscription"],N);const I=y(e,["outputAudioTranscription"]);t!==void 0&&I!=null&&x(t,["setup","outputAudioTranscription"],I);const P=y(e,["realtimeInputConfig"]);t!==void 0&&P!=null&&x(t,["setup","realtimeInputConfig"],P);const M=y(e,["contextWindowCompression"]);t!==void 0&&M!=null&&x(t,["setup","contextWindowCompression"],M);const j=y(e,["proactivity"]);return t!==void 0&&j!=null&&x(t,["setup","proactivity"],j),n}function R7(e,t){const n={},r=y(t,["model"]);r!=null&&x(n,["setup","model"],tt(e,r));const i=y(t,["config"]);return i!=null&&x(n,["config"],D7(i,n)),n}function O7(e){const t={},n=y(e,["mediaResolution"]);n!=null&&x(t,["mediaResolution"],n);const r=y(e,["codeExecutionResult"]);r!=null&&x(t,["codeExecutionResult"],r);const i=y(e,["executableCode"]);i!=null&&x(t,["executableCode"],i);const o=y(e,["fileData"]);o!=null&&x(t,["fileData"],M7(o));const c=y(e,["functionCall"]);c!=null&&x(t,["functionCall"],P7(c));const u=y(e,["functionResponse"]);u!=null&&x(t,["functionResponse"],u);const m=y(e,["inlineData"]);m!=null&&x(t,["inlineData"],E7(m));const f=y(e,["text"]);f!=null&&x(t,["text"],f);const h=y(e,["thought"]);h!=null&&x(t,["thought"],h);const g=y(e,["thoughtSignature"]);g!=null&&x(t,["thoughtSignature"],g);const v=y(e,["videoMetadata"]);return v!=null&&x(t,["videoMetadata"],v),t}function L7(e){const t={},n=y(e,["handle"]);if(n!=null&&x(t,["handle"],n),y(e,["transparent"])!==void 0)throw new Error("transparent parameter is not supported in Gemini API.");return t}function U7(e){const t={},n=y(e,["functionDeclarations"]);if(n!=null){let h=n;Array.isArray(h)&&(h=h.map(g=>g)),x(t,["functionDeclarations"],h)}if(y(e,["retrieval"])!==void 0)throw new Error("retrieval parameter is not supported in Gemini API.");const r=y(e,["googleSearchRetrieval"]);r!=null&&x(t,["googleSearchRetrieval"],r);const i=y(e,["computerUse"]);i!=null&&x(t,["computerUse"],i);const o=y(e,["fileSearch"]);o!=null&&x(t,["fileSearch"],o);const c=y(e,["codeExecution"]);if(c!=null&&x(t,["codeExecution"],c),y(e,["enterpriseWebSearch"])!==void 0)throw new Error("enterpriseWebSearch parameter is not supported in Gemini API.");const u=y(e,["googleMaps"]);u!=null&&x(t,["googleMaps"],I7(u));const m=y(e,["googleSearch"]);m!=null&&x(t,["googleSearch"],k7(m));const f=y(e,["urlContext"]);return f!=null&&x(t,["urlContext"],f),t}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function B7(e){const t=[];for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)){const r=e[n];if(typeof r=="object"&&r!=null&&Object.keys(r).length>0){const i=Object.keys(r).map(o=>`${n}.${o}`);t.push(...i)}else t.push(n)}return t.join(",")}function z7(e,t){let n=null;const r=e.bidiGenerateContentSetup;if(typeof r=="object"&&r!==null&&"setup"in r){const o=r.setup;typeof o=="object"&&o!==null?(e.bidiGenerateContentSetup=o,n=o):delete e.bidiGenerateContentSetup}else r!==void 0&&delete e.bidiGenerateContentSetup;const i=e.fieldMask;if(n){const o=B7(n);if(Array.isArray(t==null?void 0:t.lockAdditionalFields)&&(t==null?void 0:t.lockAdditionalFields.length)===0)o?e.fieldMask=o:delete e.fieldMask;else if(t!=null&&t.lockAdditionalFields&&t.lockAdditionalFields.length>0&&i!==null&&Array.isArray(i)&&i.length>0){const c=["temperature","topK","topP","maxOutputTokens","responseModalities","seed","speechConfig"];let u=[];i.length>0&&(u=i.map(f=>c.includes(f)?`generationConfig.${f}`:f));const m=[];o&&m.push(o),u.length>0&&m.push(...u),m.length>0?e.fieldMask=m.join(","):delete e.fieldMask}else delete e.fieldMask}else i!==null&&Array.isArray(i)&&i.length>0?e.fieldMask=i.join(","):delete e.fieldMask;return e}class F7 extends Sa{constructor(t){super(),this.apiClient=t}async create(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI())throw new Error("The client.tokens.create method is only supported by the Gemini Developer API.");{const u=j7(this.apiClient,t);o=be("auth_tokens",u._url),c=u._query,delete u.config,delete u._url,delete u._query;const m=z7(u,t.config);return i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(f=>f.json()),i.then(f=>f)}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function q7(e,t){const n={},r=y(e,["displayName"]);return t!==void 0&&r!=null&&x(t,["displayName"],r),n}function G7(e){const t={},n=y(e,["config"]);return n!=null&&q7(n,t),t}function $7(e,t){const n={},r=y(e,["force"]);return t!==void 0&&r!=null&&x(t,["_query","force"],r),n}function H7(e){const t={},n=y(e,["name"]);n!=null&&x(t,["_url","name"],n);const r=y(e,["config"]);return r!=null&&$7(r,t),t}function V7(e){const t={},n=y(e,["name"]);return n!=null&&x(t,["_url","name"],n),t}function K7(e,t){const n={},r=y(e,["customMetadata"]);if(t!==void 0&&r!=null){let o=r;Array.isArray(o)&&(o=o.map(c=>c)),x(t,["customMetadata"],o)}const i=y(e,["chunkingConfig"]);return t!==void 0&&i!=null&&x(t,["chunkingConfig"],i),n}function Y7(e){const t={},n=y(e,["name"]);n!=null&&x(t,["name"],n);const r=y(e,["metadata"]);r!=null&&x(t,["metadata"],r);const i=y(e,["done"]);i!=null&&x(t,["done"],i);const o=y(e,["error"]);o!=null&&x(t,["error"],o);const c=y(e,["response"]);return c!=null&&x(t,["response"],J7(c)),t}function W7(e){const t={},n=y(e,["fileSearchStoreName"]);n!=null&&x(t,["_url","file_search_store_name"],n);const r=y(e,["fileName"]);r!=null&&x(t,["fileName"],r);const i=y(e,["config"]);return i!=null&&K7(i,t),t}function J7(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["parent"]);r!=null&&x(t,["parent"],r);const i=y(e,["documentName"]);return i!=null&&x(t,["documentName"],i),t}function Q7(e,t){const n={},r=y(e,["pageSize"]);t!==void 0&&r!=null&&x(t,["_query","pageSize"],r);const i=y(e,["pageToken"]);return t!==void 0&&i!=null&&x(t,["_query","pageToken"],i),n}function X7(e){const t={},n=y(e,["config"]);return n!=null&&Q7(n,t),t}function Z7(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["nextPageToken"]);r!=null&&x(t,["nextPageToken"],r);const i=y(e,["fileSearchStores"]);if(i!=null){let o=i;Array.isArray(o)&&(o=o.map(c=>c)),x(t,["fileSearchStores"],o)}return t}function eU(e,t){const n={},r=y(e,["mimeType"]);t!==void 0&&r!=null&&x(t,["mimeType"],r);const i=y(e,["displayName"]);t!==void 0&&i!=null&&x(t,["displayName"],i);const o=y(e,["customMetadata"]);if(t!==void 0&&o!=null){let u=o;Array.isArray(u)&&(u=u.map(m=>m)),x(t,["customMetadata"],u)}const c=y(e,["chunkingConfig"]);return t!==void 0&&c!=null&&x(t,["chunkingConfig"],c),n}function tU(e){const t={},n=y(e,["fileSearchStoreName"]);n!=null&&x(t,["_url","file_search_store_name"],n);const r=y(e,["config"]);return r!=null&&eU(r,t),t}function nU(e){const t={},n=y(e,["sdkHttpResponse"]);return n!=null&&x(t,["sdkHttpResponse"],n),t}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function rU(e,t){const n={},r=y(e,["force"]);return t!==void 0&&r!=null&&x(t,["_query","force"],r),n}function iU(e){const t={},n=y(e,["name"]);n!=null&&x(t,["_url","name"],n);const r=y(e,["config"]);return r!=null&&rU(r,t),t}function aU(e){const t={},n=y(e,["name"]);return n!=null&&x(t,["_url","name"],n),t}function oU(e,t){const n={},r=y(e,["pageSize"]);t!==void 0&&r!=null&&x(t,["_query","pageSize"],r);const i=y(e,["pageToken"]);return t!==void 0&&i!=null&&x(t,["_query","pageToken"],i),n}function sU(e){const t={},n=y(e,["parent"]);n!=null&&x(t,["_url","parent"],n);const r=y(e,["config"]);return r!=null&&oU(r,t),t}function lU(e){const t={},n=y(e,["sdkHttpResponse"]);n!=null&&x(t,["sdkHttpResponse"],n);const r=y(e,["nextPageToken"]);r!=null&&x(t,["nextPageToken"],r);const i=y(e,["documents"]);if(i!=null){let o=i;Array.isArray(o)&&(o=o.map(c=>c)),x(t,["documents"],o)}return t}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class cU extends Sa{constructor(t){super(),this.apiClient=t,this.list=async n=>new ks(ma.PAGED_ITEM_DOCUMENTS,r=>this.listInternal({parent:n.parent,config:r.config}),await this.listInternal(n),n)}async get(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=aU(t);return o=be("{name}",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"GET",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json()),i.then(m=>m)}}async delete(t){var n,r;let i="",o={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const c=iU(t);i=be("{name}",c._url),o=c._query,delete c._url,delete c._query,await this.apiClient.request({path:i,queryParams:o,body:JSON.stringify(c),httpMethod:"DELETE",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal})}}async listInternal(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=sU(t);return o=be("{parent}/documents",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"GET",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json()),i.then(m=>{const f=lU(m),h=new FR;return Object.assign(h,f),h})}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class uU extends Sa{constructor(t,n=new cU(t)){super(),this.apiClient=t,this.documents=n,this.list=async(r={})=>new ks(ma.PAGED_ITEM_FILE_SEARCH_STORES,i=>this.listInternal(i),await this.listInternal(r),r)}async uploadToFileSearchStore(t){if(this.apiClient.isVertexAI())throw new Error("Vertex AI does not support uploading files to a file search store.");return this.apiClient.uploadFileToFileSearchStore(t.fileSearchStoreName,t.file,t.config)}async create(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=G7(t);return o=be("fileSearchStores",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json()),i.then(m=>m)}}async get(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=V7(t);return o=be("{name}",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"GET",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json()),i.then(m=>m)}}async delete(t){var n,r;let i="",o={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const c=H7(t);i=be("{name}",c._url),o=c._query,delete c._url,delete c._query,await this.apiClient.request({path:i,queryParams:o,body:JSON.stringify(c),httpMethod:"DELETE",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal})}}async listInternal(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=X7(t);return o=be("fileSearchStores",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"GET",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json()),i.then(m=>{const f=Z7(m),h=new qR;return Object.assign(h,f),h})}}async uploadToFileSearchStoreInternal(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=tU(t);return o=be("upload/v1beta/{file_search_store_name}:uploadToFileSearchStore",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json()),i.then(m=>{const f=nU(m),h=new GR;return Object.assign(h,f),h})}}async importFile(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=W7(t);return o=be("{file_search_store_name}:importFile",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json()),i.then(m=>{const f=Y7(m),h=new Px;return Object.assign(h,f),h})}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */function dU(e,t){const n={},r=y(e,["name"]);return r!=null&&x(n,["_url","name"],r),n}function fU(e,t){const n={},r=y(e,["name"]);return r!=null&&x(n,["_url","name"],r),n}function mU(e,t,n){const r={};if(y(e,["validationDataset"])!==void 0)throw new Error("validationDataset parameter is not supported in Gemini API.");const i=y(e,["tunedModelDisplayName"]);if(t!==void 0&&i!=null&&x(t,["displayName"],i),y(e,["description"])!==void 0)throw new Error("description parameter is not supported in Gemini API.");const o=y(e,["epochCount"]);t!==void 0&&o!=null&&x(t,["tuningTask","hyperparameters","epochCount"],o);const c=y(e,["learningRateMultiplier"]);if(c!=null&&x(r,["tuningTask","hyperparameters","learningRateMultiplier"],c),y(e,["exportLastCheckpointOnly"])!==void 0)throw new Error("exportLastCheckpointOnly parameter is not supported in Gemini API.");if(y(e,["preTunedModelCheckpointId"])!==void 0)throw new Error("preTunedModelCheckpointId parameter is not supported in Gemini API.");if(y(e,["adapterSize"])!==void 0)throw new Error("adapterSize parameter is not supported in Gemini API.");const u=y(e,["batchSize"]);t!==void 0&&u!=null&&x(t,["tuningTask","hyperparameters","batchSize"],u);const m=y(e,["learningRate"]);if(t!==void 0&&m!=null&&x(t,["tuningTask","hyperparameters","learningRate"],m),y(e,["labels"])!==void 0)throw new Error("labels parameter is not supported in Gemini API.");if(y(e,["beta"])!==void 0)throw new Error("beta parameter is not supported in Gemini API.");return r}function hU(e,t,n){const r={};let i=y(n,["config","method"]);if(i===void 0&&(i="SUPERVISED_FINE_TUNING"),i==="SUPERVISED_FINE_TUNING"){const b=y(e,["validationDataset"]);t!==void 0&&b!=null&&x(t,["supervisedTuningSpec"],aT(b))}else if(i==="PREFERENCE_TUNING"){const b=y(e,["validationDataset"]);t!==void 0&&b!=null&&x(t,["preferenceOptimizationSpec"],aT(b))}const o=y(e,["tunedModelDisplayName"]);t!==void 0&&o!=null&&x(t,["tunedModelDisplayName"],o);const c=y(e,["description"]);t!==void 0&&c!=null&&x(t,["description"],c);let u=y(n,["config","method"]);if(u===void 0&&(u="SUPERVISED_FINE_TUNING"),u==="SUPERVISED_FINE_TUNING"){const b=y(e,["epochCount"]);t!==void 0&&b!=null&&x(t,["supervisedTuningSpec","hyperParameters","epochCount"],b)}else if(u==="PREFERENCE_TUNING"){const b=y(e,["epochCount"]);t!==void 0&&b!=null&&x(t,["preferenceOptimizationSpec","hyperParameters","epochCount"],b)}let m=y(n,["config","method"]);if(m===void 0&&(m="SUPERVISED_FINE_TUNING"),m==="SUPERVISED_FINE_TUNING"){const b=y(e,["learningRateMultiplier"]);t!==void 0&&b!=null&&x(t,["supervisedTuningSpec","hyperParameters","learningRateMultiplier"],b)}else if(m==="PREFERENCE_TUNING"){const b=y(e,["learningRateMultiplier"]);t!==void 0&&b!=null&&x(t,["preferenceOptimizationSpec","hyperParameters","learningRateMultiplier"],b)}let f=y(n,["config","method"]);if(f===void 0&&(f="SUPERVISED_FINE_TUNING"),f==="SUPERVISED_FINE_TUNING"){const b=y(e,["exportLastCheckpointOnly"]);t!==void 0&&b!=null&&x(t,["supervisedTuningSpec","exportLastCheckpointOnly"],b)}else if(f==="PREFERENCE_TUNING"){const b=y(e,["exportLastCheckpointOnly"]);t!==void 0&&b!=null&&x(t,["preferenceOptimizationSpec","exportLastCheckpointOnly"],b)}let h=y(n,["config","method"]);if(h===void 0&&(h="SUPERVISED_FINE_TUNING"),h==="SUPERVISED_FINE_TUNING"){const b=y(e,["adapterSize"]);t!==void 0&&b!=null&&x(t,["supervisedTuningSpec","hyperParameters","adapterSize"],b)}else if(h==="PREFERENCE_TUNING"){const b=y(e,["adapterSize"]);t!==void 0&&b!=null&&x(t,["preferenceOptimizationSpec","hyperParameters","adapterSize"],b)}if(y(e,["batchSize"])!==void 0)throw new Error("batchSize parameter is not supported in Vertex AI.");if(y(e,["learningRate"])!==void 0)throw new Error("learningRate parameter is not supported in Vertex AI.");const g=y(e,["labels"]);t!==void 0&&g!=null&&x(t,["labels"],g);const v=y(e,["beta"]);return t!==void 0&&v!=null&&x(t,["preferenceOptimizationSpec","hyperParameters","beta"],v),r}function pU(e,t){const n={},r=y(e,["baseModel"]);r!=null&&x(n,["baseModel"],r);const i=y(e,["preTunedModel"]);i!=null&&x(n,["preTunedModel"],i);const o=y(e,["trainingDataset"]);o!=null&&EU(o);const c=y(e,["config"]);return c!=null&&mU(c,n),n}function gU(e,t){const n={},r=y(e,["baseModel"]);r!=null&&x(n,["baseModel"],r);const i=y(e,["preTunedModel"]);i!=null&&x(n,["preTunedModel"],i);const o=y(e,["trainingDataset"]);o!=null&&NU(o,n,t);const c=y(e,["config"]);return c!=null&&hU(c,n,t),n}function yU(e,t){const n={},r=y(e,["name"]);return r!=null&&x(n,["_url","name"],r),n}function vU(e,t){const n={},r=y(e,["name"]);return r!=null&&x(n,["_url","name"],r),n}function xU(e,t,n){const r={},i=y(e,["pageSize"]);t!==void 0&&i!=null&&x(t,["_query","pageSize"],i);const o=y(e,["pageToken"]);t!==void 0&&o!=null&&x(t,["_query","pageToken"],o);const c=y(e,["filter"]);return t!==void 0&&c!=null&&x(t,["_query","filter"],c),r}function bU(e,t,n){const r={},i=y(e,["pageSize"]);t!==void 0&&i!=null&&x(t,["_query","pageSize"],i);const o=y(e,["pageToken"]);t!==void 0&&o!=null&&x(t,["_query","pageToken"],o);const c=y(e,["filter"]);return t!==void 0&&c!=null&&x(t,["_query","filter"],c),r}function wU(e,t){const n={},r=y(e,["config"]);return r!=null&&xU(r,n),n}function SU(e,t){const n={},r=y(e,["config"]);return r!=null&&bU(r,n),n}function AU(e,t){const n={},r=y(e,["sdkHttpResponse"]);r!=null&&x(n,["sdkHttpResponse"],r);const i=y(e,["nextPageToken"]);i!=null&&x(n,["nextPageToken"],i);const o=y(e,["tunedModels"]);if(o!=null){let c=o;Array.isArray(c)&&(c=c.map(u=>C3(u))),x(n,["tuningJobs"],c)}return n}function CU(e,t){const n={},r=y(e,["sdkHttpResponse"]);r!=null&&x(n,["sdkHttpResponse"],r);const i=y(e,["nextPageToken"]);i!=null&&x(n,["nextPageToken"],i);const o=y(e,["tuningJobs"]);if(o!=null){let c=o;Array.isArray(c)&&(c=c.map(u=>hv(u))),x(n,["tuningJobs"],c)}return n}function TU(e,t){const n={},r=y(e,["name"]);r!=null&&x(n,["model"],r);const i=y(e,["name"]);return i!=null&&x(n,["endpoint"],i),n}function EU(e,t){const n={};if(y(e,["gcsUri"])!==void 0)throw new Error("gcsUri parameter is not supported in Gemini API.");if(y(e,["vertexDatasetResource"])!==void 0)throw new Error("vertexDatasetResource parameter is not supported in Gemini API.");const r=y(e,["examples"]);if(r!=null){let i=r;Array.isArray(i)&&(i=i.map(o=>o)),x(n,["examples","examples"],i)}return n}function NU(e,t,n){const r={};let i=y(n,["config","method"]);if(i===void 0&&(i="SUPERVISED_FINE_TUNING"),i==="SUPERVISED_FINE_TUNING"){const c=y(e,["gcsUri"]);t!==void 0&&c!=null&&x(t,["supervisedTuningSpec","trainingDatasetUri"],c)}else if(i==="PREFERENCE_TUNING"){const c=y(e,["gcsUri"]);t!==void 0&&c!=null&&x(t,["preferenceOptimizationSpec","trainingDatasetUri"],c)}let o=y(n,["config","method"]);if(o===void 0&&(o="SUPERVISED_FINE_TUNING"),o==="SUPERVISED_FINE_TUNING"){const c=y(e,["vertexDatasetResource"]);t!==void 0&&c!=null&&x(t,["supervisedTuningSpec","trainingDatasetUri"],c)}else if(o==="PREFERENCE_TUNING"){const c=y(e,["vertexDatasetResource"]);t!==void 0&&c!=null&&x(t,["preferenceOptimizationSpec","trainingDatasetUri"],c)}if(y(e,["examples"])!==void 0)throw new Error("examples parameter is not supported in Vertex AI.");return r}function C3(e,t){const n={},r=y(e,["sdkHttpResponse"]);r!=null&&x(n,["sdkHttpResponse"],r);const i=y(e,["name"]);i!=null&&x(n,["name"],i);const o=y(e,["state"]);o!=null&&x(n,["state"],a3(o));const c=y(e,["createTime"]);c!=null&&x(n,["createTime"],c);const u=y(e,["tuningTask","startTime"]);u!=null&&x(n,["startTime"],u);const m=y(e,["tuningTask","completeTime"]);m!=null&&x(n,["endTime"],m);const f=y(e,["updateTime"]);f!=null&&x(n,["updateTime"],f);const h=y(e,["description"]);h!=null&&x(n,["description"],h);const g=y(e,["baseModel"]);g!=null&&x(n,["baseModel"],g);const v=y(e,["_self"]);return v!=null&&x(n,["tunedModel"],TU(v)),n}function hv(e,t){const n={},r=y(e,["sdkHttpResponse"]);r!=null&&x(n,["sdkHttpResponse"],r);const i=y(e,["name"]);i!=null&&x(n,["name"],i);const o=y(e,["state"]);o!=null&&x(n,["state"],a3(o));const c=y(e,["createTime"]);c!=null&&x(n,["createTime"],c);const u=y(e,["startTime"]);u!=null&&x(n,["startTime"],u);const m=y(e,["endTime"]);m!=null&&x(n,["endTime"],m);const f=y(e,["updateTime"]);f!=null&&x(n,["updateTime"],f);const h=y(e,["error"]);h!=null&&x(n,["error"],h);const g=y(e,["description"]);g!=null&&x(n,["description"],g);const v=y(e,["baseModel"]);v!=null&&x(n,["baseModel"],v);const b=y(e,["tunedModel"]);b!=null&&x(n,["tunedModel"],b);const T=y(e,["preTunedModel"]);T!=null&&x(n,["preTunedModel"],T);const C=y(e,["supervisedTuningSpec"]);C!=null&&x(n,["supervisedTuningSpec"],C);const E=y(e,["preferenceOptimizationSpec"]);E!=null&&x(n,["preferenceOptimizationSpec"],E);const N=y(e,["tuningDataStats"]);N!=null&&x(n,["tuningDataStats"],N);const I=y(e,["encryptionSpec"]);I!=null&&x(n,["encryptionSpec"],I);const P=y(e,["partnerModelTuningSpec"]);P!=null&&x(n,["partnerModelTuningSpec"],P);const M=y(e,["customBaseModel"]);M!=null&&x(n,["customBaseModel"],M);const j=y(e,["experiment"]);j!=null&&x(n,["experiment"],j);const k=y(e,["labels"]);k!=null&&x(n,["labels"],k);const R=y(e,["outputUri"]);R!=null&&x(n,["outputUri"],R);const F=y(e,["pipelineJob"]);F!=null&&x(n,["pipelineJob"],F);const q=y(e,["serviceAccount"]);q!=null&&x(n,["serviceAccount"],q);const G=y(e,["tunedModelDisplayName"]);G!=null&&x(n,["tunedModelDisplayName"],G);const H=y(e,["veoTuningSpec"]);return H!=null&&x(n,["veoTuningSpec"],H),n}function _U(e,t){const n={},r=y(e,["sdkHttpResponse"]);r!=null&&x(n,["sdkHttpResponse"],r);const i=y(e,["name"]);i!=null&&x(n,["name"],i);const o=y(e,["metadata"]);o!=null&&x(n,["metadata"],o);const c=y(e,["done"]);c!=null&&x(n,["done"],c);const u=y(e,["error"]);return u!=null&&x(n,["error"],u),n}function aT(e,t){const n={},r=y(e,["gcsUri"]);r!=null&&x(n,["validationDatasetUri"],r);const i=y(e,["vertexDatasetResource"]);return i!=null&&x(n,["validationDatasetUri"],i),n}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class jU extends Sa{constructor(t){super(),this.apiClient=t,this.get=async n=>await this.getInternal(n),this.list=async(n={})=>new ks(ma.PAGED_ITEM_TUNING_JOBS,r=>this.listInternal(r),await this.listInternal(n),n),this.tune=async n=>{var r;if(this.apiClient.isVertexAI())if(n.baseModel.startsWith("projects/")){const i={tunedModelName:n.baseModel};!((r=n.config)===null||r===void 0)&&r.preTunedModelCheckpointId&&(i.checkpointId=n.config.preTunedModelCheckpointId);const o=Object.assign(Object.assign({},n),{preTunedModel:i});return o.baseModel=void 0,await this.tuneInternal(o)}else{const i=Object.assign({},n);return await this.tuneInternal(i)}else{const i=Object.assign({},n),o=await this.tuneMldevInternal(i);let c="";return o.metadata!==void 0&&o.metadata.tunedModel!==void 0?c=o.metadata.tunedModel:o.name!==void 0&&o.name.includes("/operations/")&&(c=o.name.split("/operations/")[0]),{name:c,state:sv.JOB_STATE_QUEUED}}}}async getInternal(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=vU(t);return u=be("{name}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>hv(h))}else{const f=yU(t);return u=be("{name}",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>C3(h))}}async listInternal(t){var n,r,i,o;let c,u="",m={};if(this.apiClient.isVertexAI()){const f=SU(t);return u=be("tuningJobs",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=CU(h),v=new UC;return Object.assign(v,g),v})}else{const f=wU(t);return u=be("tunedModels",f._url),m=f._query,delete f._url,delete f._query,c=this.apiClient.request({path:u,queryParams:m,body:JSON.stringify(f),httpMethod:"GET",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal}).then(h=>h.json().then(g=>{const v=g;return v.sdkHttpResponse={headers:h.headers},v})),c.then(h=>{const g=AU(h),v=new UC;return Object.assign(v,g),v})}}async cancel(t){var n,r,i,o;let c="",u={};if(this.apiClient.isVertexAI()){const m=fU(t);c=be("{name}:cancel",m._url),u=m._query,delete m._url,delete m._query,await this.apiClient.request({path:c,queryParams:u,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal})}else{const m=dU(t);c=be("{name}:cancel",m._url),u=m._query,delete m._url,delete m._query,await this.apiClient.request({path:c,queryParams:u,body:JSON.stringify(m),httpMethod:"POST",httpOptions:(i=t.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(o=t.config)===null||o===void 0?void 0:o.abortSignal})}}async tuneInternal(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI()){const u=gU(t,t);return o=be("tuningJobs",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json().then(f=>{const h=f;return h.sdkHttpResponse={headers:m.headers},h})),i.then(m=>hv(m))}else throw new Error("This method is only supported by the Vertex AI.")}async tuneMldevInternal(t){var n,r;let i,o="",c={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{const u=pU(t);return o=be("tunedModels",u._url),c=u._query,delete u._url,delete u._query,i=this.apiClient.request({path:o,queryParams:c,body:JSON.stringify(u),httpMethod:"POST",httpOptions:(n=t.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=t.config)===null||r===void 0?void 0:r.abortSignal}).then(m=>m.json().then(f=>{const h=f;return h.sdkHttpResponse={headers:m.headers},h})),i.then(m=>_U(m))}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class MU{async download(t,n){throw new Error("Download to file is not supported in the browser, please use a browser compliant download like an tag.")}}const PU=1024*1024*8,IU=3,kU=1e3,DU=2,um="x-goog-upload-status";async function RU(e,t,n){var r;const i=await T3(e,t,n),o=await(i==null?void 0:i.json());if(((r=i==null?void 0:i.headers)===null||r===void 0?void 0:r[um])!=="final")throw new Error("Failed to upload file: Upload status is not finalized.");return o.file}async function OU(e,t,n){var r;const i=await T3(e,t,n),o=await(i==null?void 0:i.json());if(((r=i==null?void 0:i.headers)===null||r===void 0?void 0:r[um])!=="final")throw new Error("Failed to upload file: Upload status is not finalized.");const c=Zj(o),u=new Ix;return Object.assign(u,c),u}async function T3(e,t,n){var r,i;let o=0,c=0,u=new lv(new Response),m="upload";for(o=e.size;c=o&&(m+=", finalize");let g=0,v=kU;for(;gsetTimeout(t,e))}class BU{async upload(t,n,r){if(typeof t=="string")throw new Error("File path is not supported in browser uploader.");return await RU(t,n,r)}async uploadToFileSearchStore(t,n,r){if(typeof t=="string")throw new Error("File path is not supported in browser uploader.");return await OU(t,n,r)}async stat(t){if(typeof t=="string")throw new Error("File path is not supported in browser uploader.");return await LU(t)}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */class zU{create(t,n,r){return new FU(t,n,r)}}class FU{constructor(t,n,r){this.url=t,this.headers=n,this.callbacks=r}connect(){this.ws=new WebSocket(this.url),this.ws.onopen=this.callbacks.onopen,this.ws.onerror=this.callbacks.onerror,this.ws.onclose=this.callbacks.onclose,this.ws.onmessage=this.callbacks.onmessage}send(t){if(this.ws===void 0)throw new Error("WebSocket is not connected");this.ws.send(t)}close(){if(this.ws===void 0)throw new Error("WebSocket is not connected");this.ws.close()}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */const oT="x-goog-api-key";class qU{constructor(t){this.apiKey=t}async addAuthHeaders(t,n){if(t.get(oT)===null){if(this.apiKey.startsWith("auth_tokens/"))throw new Error("Ephemeral tokens are only supported by the live API.");if(!this.apiKey)throw new Error("API key is missing. Please provide a valid API key.");t.append(oT,this.apiKey)}}}/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */const GU="gl-node/";class ar{constructor(t){var n;if(t.apiKey==null)throw new Error("An API Key must be set when running in a browser");if(t.project||t.location)throw new Error("Vertex AI project based authentication is not supported on browser runtimes. Please do not provide a project or location.");this.vertexai=(n=t.vertexai)!==null&&n!==void 0?n:!1,this.apiKey=t.apiKey;const r=bR(t.httpOptions,t.vertexai,void 0,void 0);r&&(t.httpOptions?t.httpOptions.baseUrl=r:t.httpOptions={baseUrl:r}),this.apiVersion=t.apiVersion;const i=new qU(this.apiKey);this.apiClient=new a7({auth:i,apiVersion:this.apiVersion,apiKey:this.apiKey,vertexai:this.vertexai,httpOptions:t.httpOptions,userAgentExtra:GU+"web",uploader:new BU,downloader:new MU}),this.models=new C7(this.apiClient),this.live=new v7(this.apiClient,i,new zU),this.batches=new WO(this.apiClient),this.chats=new M6(this.models,this.apiClient),this.caches=new N6(this.apiClient),this.files=new z6(this.apiClient),this.operations=new T7(this.apiClient),this.authTokens=new F7(this.apiClient),this.tunings=new jU(this.apiClient),this.fileSearchStores=new uU(this.apiClient)}}var vi=(e=>(e.Pitch="pitch",e.Analysis="analysis",e.Test="test",e.FinalReview="final_review",e.Approved="approved",e.Error="error",e))(vi||{}),ve=(e=>(e.Dashboard="dashboard",e.Transactions="transactions",e.SendMoney="send-money",e.Budgets="budgets",e.Investments="investments",e.SASPlatforms="the-vision",e.AIAdvisor="ai-advisor",e.QuantumWeaver="quantum-weaver",e.AIAdStudio="ai-ad-studio",e.Crypto="crypto",e.Goals="goals",e.Marketplace="marketplace",e.Security="security",e.Personalization="personalization",e.CardCustomization="card-customization",e.OpenBanking="open-banking",e.CorporateCommand="corporate-command",e.ModernTreasury="modern-treasury",e.APIIntegration="api-integration",e.Rewards="rewards",e.CreditHealth="credit-health",e.Settings="settings",e.FinancialDemocracy="financial-democracy",e.PaymentOrders="payment-orders",e.Invoices="invoices",e.Compliance="compliance",e))(ve||{});const $U=[{id:"1",type:"expense",category:"Dining",description:"Coffee Shop",amount:12.5,date:"2024-07-21",carbonFootprint:1.2},{id:"2",type:"income",category:"Salary",description:"Paycheck",amount:2500,date:"2024-07-20"},{id:"3",type:"expense",category:"Shopping",description:"Online Store",amount:89.99,date:"2024-07-19",carbonFootprint:8.5},{id:"4",type:"expense",category:"Utilities",description:"Electricity Bill",amount:75.3,date:"2024-07-18",carbonFootprint:15.3},{id:"5",type:"expense",category:"Transport",description:"Gas Station",amount:55,date:"2024-07-18",carbonFootprint:25.1},{id:"6",type:"income",category:"Freelance",description:"Project ABC",amount:500,date:"2024-07-17"},{id:"7",type:"expense",category:"Groceries",description:"Supermarket",amount:124.5,date:"2024-07-16",carbonFootprint:12.8},{id:"8",type:"expense",category:"Entertainment",description:"Movie Tickets",amount:30,date:"2024-07-15",carbonFootprint:3.5},{id:"9",type:"income",category:"Salary",description:"Paycheck",amount:2500,date:"2024-06-20"},{id:"10",type:"expense",category:"Rent",description:"Monthly Rent",amount:1200,date:"2024-06-01",carbonFootprint:5},{id:"11",type:"expense",category:"Shopping",description:"New Tech Gadget",amount:299.99,date:"2024-06-15",carbonFootprint:14.2},{id:"12",type:"expense",category:"Dining",description:"Fancy Dinner",amount:150,date:"2024-06-10",carbonFootprint:8.1},{id:"13",type:"income",category:"Salary",description:"Paycheck",amount:2500,date:"2024-05-20"},{id:"14",type:"expense",category:"Travel",description:"Flight Tickets",amount:450,date:"2024-05-12",carbonFootprint:200.5},{id:"15",type:"expense",category:"Rent",description:"Monthly Rent",amount:1200,date:"2024-05-01",carbonFootprint:5},{id:"16",type:"income",category:"Salary",description:"Paycheck",amount:2500,date:"2024-04-20"},{id:"17",type:"expense",category:"Rent",description:"Monthly Rent",amount:1200,date:"2024-04-01",carbonFootprint:5}],HU=[{name:"Stocks",value:4e4,color:"#06b6d4",performanceYTD:15.2},{name:"Bonds",value:25e3,color:"#6366f1",performanceYTD:4.1},{name:"Crypto",value:15e3,color:"#f59e0b",performanceYTD:45.8},{name:"Real Estate",value:2e4,color:"#10b981",performanceYTD:8.5}],VU=[{name:"TerraCycle",value:0,color:"",esgRating:5,description:"Innovator in recycling and circular economy."},{name:"Patagonia Works",value:0,color:"",esgRating:5,description:"Sustainable apparel and environmental activism."},{name:"Beyond Meat",value:0,color:"",esgRating:4,description:"Plant-based foods to reduce climate impact."},{name:"Tesla, Inc.",value:0,color:"",esgRating:3,description:"Accelerating the world's transition to sustainable energy."}],KU=[{id:"dining",name:"Dining",limit:400,spent:280,color:"#f59e0b"},{id:"shopping",name:"Shopping",limit:600,spent:410.5,color:"#6366f1"},{id:"transport",name:"Transport",limit:200,spent:95.2,color:"#10b981"},{id:"utilities",name:"Utilities",limit:250,spent:185.7,color:"#06b6d4"}],YU=[{id:"sub1",name:"QuantumFlix",amount:15.99,nextPayment:"2024-08-01",iconName:"video"},{id:"sub2",name:"SynthWave Music",amount:9.99,nextPayment:"2024-08-05",iconName:"music"},{id:"sub3",name:"CyberCloud Pro",amount:24.99,nextPayment:"2024-08-10",iconName:"cloud"}],WU={score:780,change:5,rating:"Excellent"},JU=[{id:"bill1",name:"Credit Card",amount:345.8,dueDate:"2024-08-15"},{id:"bill2",name:"Internet",amount:80,dueDate:"2024-08-20"},{id:"bill3",name:"Car Payment",amount:450,dueDate:"2024-08-25"}],QU=[{id:"goal1",name:"Cyberpunk Vacation",target:5e3,saved:3250,iconName:"plane"},{id:"goal2",name:"New Hoverboard",target:2500,saved:800,iconName:"rocket"}],XU=[{ticker:"QNTM",name:"Quantum Corp",price:450.75,change:12.55},{ticker:"CYBR",name:"Cyberdyne Systems",price:1024.1,change:50.12},{ticker:"NRLNK",name:"NeuroLink Inc.",price:875.3,change:-5.6}],ZU=[],eB=[{id:"goal_house_1",name:"Down Payment for a Condo",targetAmount:75e3,targetDate:"2029-12-31",currentAmount:12500,iconName:"home",plan:null,startDate:"2024-01-01",status:"on_track"},{id:"goal_trip_1",name:"Trip to Neo-Tokyo",targetAmount:15e3,targetDate:"2026-06-01",currentAmount:8e3,iconName:"plane",plan:{feasibilitySummary:"Highly achievable! You are already on a great track to reach this goal ahead of schedule.",monthlyContribution:450,steps:[{title:"Automate Savings",description:"Set up an automatic monthly transfer of $450 to your 'Trip to Neo-Tokyo' savings goal.",category:"Savings"},{title:"Review Subscriptions",description:"Analyze your recurring subscriptions. Cancelling one or two could accelerate your goal.",category:"Budgeting"},{title:"Explore Travel ETFs",description:"Consider investing a small portion of your savings in a travel and tourism focused ETF for potential growth.",category:"Investing"}],actionableSteps:["Automate Savings","Review Subscriptions","Explore Travel ETFs"]},startDate:"2024-03-01",status:"on_track"}],tB=[{ticker:"BTC",name:"Bitcoin",value:34500,amount:.5,color:"#f7931a"},{ticker:"ETH",name:"Ethereum",value:12e3,amount:4,color:"#627eea"},{ticker:"SOL",name:"Solana",value:3500,amount:25,color:"#00ffa3"}],nB=[{id:"po_1",description:"Stripe On-Ramp Batch #A42",amount:25e3,status:"Completed",type:"ACH",date:"2024-07-22"},{id:"po_2",description:"Crypto Payout to 0x...b4A2",amount:5e3,status:"Completed",type:"Crypto",date:"2024-07-22"},{id:"po_3",description:"Marqeta Card Funding",amount:1e4,status:"Processing",type:"Wire",date:"2024-07-23"},{id:"po_4",description:"Coinbase Withdrawal",amount:12e3,status:"Initiated",type:"ACH",date:"2024-07-23"},{id:"po_5",description:"Manual Adjustment",amount:-500,status:"Failed",type:"ACH",date:"2024-07-21"}],rB={balance:85250,lastEarned:320,lastRedeemed:5e3,currency:"Points"},iB=[{id:"corp1",holderName:"Alex Chen (Engineer)",cardNumberMask:"8431",status:"Active",frozen:!1,controls:{atm:!0,contactless:!0,online:!0,monthlyLimit:5e3}},{id:"corp2",holderName:"Brenda Rodriguez (Sales)",cardNumberMask:"5549",status:"Active",frozen:!1,controls:{atm:!1,contactless:!0,online:!0,monthlyLimit:1e4}},{id:"corp3",holderName:"Charles Davis (Marketing)",cardNumberMask:"1127",status:"Suspended",frozen:!0,controls:{atm:!1,contactless:!1,online:!1,monthlyLimit:2500}},{id:"corp4",holderName:"Diana Wells (Operations)",cardNumberMask:"9882",status:"Active",frozen:!1,controls:{atm:!0,contactless:!0,online:!1,monthlyLimit:7500}},{id:"corp5",holderName:"Ethan Gonzalez (HR)",cardNumberMask:"3019",status:"Active",frozen:!1,controls:{atm:!0,contactless:!0,online:!0,monthlyLimit:4e3}},{id:"corp6",holderName:"Fiona Kim (Product)",cardNumberMask:"7442",status:"Active",frozen:!1,controls:{atm:!0,contactless:!0,online:!0,monthlyLimit:6e3}},{id:"corp7",holderName:"George Patel (Legal)",cardNumberMask:"8821",status:"Lost",frozen:!0,controls:{atm:!1,contactless:!1,online:!1,monthlyLimit:3e3}},{id:"corp8",holderName:"Hannah Nguyen (Support)",cardNumberMask:"5096",status:"Active",frozen:!1,controls:{atm:!1,contactless:!0,online:!0,monthlyLimit:2e3}},{id:"corp9",holderName:"Ian Washington (Executive)",cardNumberMask:"1558",status:"Active",frozen:!1,controls:{atm:!0,contactless:!0,online:!0,monthlyLimit:2e4}},{id:"corp10",holderName:"Jasmine Lee (Data Science)",cardNumberMask:"4337",status:"Active",frozen:!1,controls:{atm:!0,contactless:!0,online:!0,monthlyLimit:8e3}}],aB=[{id:"ctx1",cardId:"corp1",holderName:"Alex Chen",merchant:"Cloud Services Inc.",amount:199.99,status:"Approved",timestamp:"2m ago",date:"2024-07-24",description:"Monthly Cloud Subscription"},{id:"ctx2",cardId:"corp2",holderName:"Brenda Rodriguez",merchant:"Steakhouse Prime",amount:345.5,status:"Approved",timestamp:"5m ago",date:"2024-07-24",description:"Client Lunch"},{id:"ctx3",cardId:"corp4",holderName:"Diana Wells",merchant:"Office Supplies Co.",amount:89.2,status:"Pending",timestamp:"8m ago",date:"2024-07-24",description:"Stationery"},{id:"ctx4",cardId:"corp1",holderName:"Alex Chen",merchant:"CodeEditor Pro",amount:49,status:"Approved",timestamp:"1h ago",date:"2024-07-24",description:"IDE License"},{id:"ctx5",cardId:"corp2",holderName:"Brenda Rodriguez",merchant:"Airport Taxi",amount:75,status:"Approved",timestamp:"3h ago",date:"2024-07-24",description:"Travel - Taxi"},{id:"ctx6",cardId:"corp5",holderName:"Ethan Gonzalez",merchant:"HR Software Subscription",amount:150,status:"Approved",timestamp:"5h ago",date:"2024-07-24",description:"SaaS Subscription"},{id:"ctx7",cardId:"corp6",holderName:"Fiona Kim",merchant:"UserTesting Platform",amount:250,status:"Approved",timestamp:"8h ago",date:"2024-07-24",description:"Product Testing"},{id:"ctx8",cardId:"corp9",holderName:"Ian Washington",merchant:"Airline Tickets",amount:1250.8,status:"Approved",timestamp:"1d ago",date:"2024-07-23",description:"Flight to NY"},{id:"ctx9",cardId:"corp10",holderName:"Jasmine Lee",merchant:"Data Processing Unit",amount:500,status:"Pending",timestamp:"1d ago",date:"2024-07-23",description:"Compute Credit"},{id:"ctx10",cardId:"corp2",holderName:"Brenda Rodriguez",merchant:"Client Lunch",amount:125.3,status:"Approved",timestamp:"2d ago",date:"2024-07-22",description:"Client Lunch"},{id:"ctx11",cardId:"corp1",holderName:"Alex Chen",merchant:"Server Hosting",amount:75,status:"Approved",timestamp:"2d ago",date:"2024-07-22",description:"Hosting Fee"}],oB=[{id:"1",message:"Your credit score has increased by 5 points!",timestamp:"2h ago",read:!1,view:ve.CreditHealth},{id:"2",message:'A large purchase of $299.99 at "New Tech Gadget" was detected.',timestamp:"1d ago",read:!1,view:ve.Transactions},{id:"3",message:"You have earned 150 reward points from your recent spending.",timestamp:"3d ago",read:!0,view:ve.Rewards},{id:"4",message:'Your "Dining" budget is at 85% capacity.',timestamp:"4d ago",read:!0,view:ve.Budgets}],sB=[{id:"rew1",name:"$25 Statement Credit",cost:25e3,type:"cashback",description:"Redeem points for a direct credit to your account balance.",iconName:"cash"},{id:"rew2",name:"$50 Tech Store Gift Card",cost:45e3,type:"giftcard",description:"Get a gift card for your favorite electronics retailer.",iconName:"gift"},{id:"rew3",name:"Plant 5 Trees",cost:1e4,type:"impact",description:"Use your points to make a positive environmental impact.",iconName:"leaf"}],lB=[{provider:"Plaid",status:"Operational",responseTime:120},{provider:"Stripe",status:"Operational",responseTime:85},{provider:"Marqeta",status:"Operational",responseTime:150},{provider:"Modern Treasury",status:"Operational",responseTime:110},{provider:"Google Gemini",status:"Degraded Performance",responseTime:450}],cB=[{name:"Payment History",status:"Excellent",description:"You have no missed payments on record. Keep up the great work!"},{name:"Credit Utilization",status:"Good",description:"Your credit utilization is 22%, which is good. Aim to keep it below 30%."},{name:"Credit Age",status:"Good",description:"Your average credit account age is 6 years. The longer, the better."},{name:"New Credit",status:"Excellent",description:"You have not opened any new credit lines recently, which is positive."},{name:"Credit Mix",status:"Fair",description:"Your credit mix could be improved with different types of loans, such as a mortgage."}],uB=[{id:"po-1",amount:5e3,status:"approved",requestDate:"2023-10-01",approvalDate:"2023-10-02",paymentDate:"2023-10-03",paymentMethod:"Wire",beneficiary:"Vendor A"},{id:"po-2",amount:12e3,status:"needs_approval",requestDate:"2023-10-25",dueDate:"2023-11-01",paymentMethod:"ACH",beneficiary:"Supplier B"},{id:"po-3",amount:3e3,status:"paid",requestDate:"2023-09-15",approvalDate:"2023-09-16",paymentDate:"2023-09-17",paymentMethod:"Card",beneficiary:"Service C"},{id:"po-4",amount:15e3,status:"pending",requestDate:"2023-10-26",dueDate:"2023-10-30",paymentMethod:"Wire",beneficiary:"Global Corp"},{id:"po-5",amount:850,status:"approved",requestDate:"2023-10-28",approvalDate:"2023-10-28",paymentMethod:"Card",beneficiary:"Local Office Supply"}],dB=[{id:"inv-1",amount:8e3,status:"paid",issueDate:"2023-09-01",dueDate:"2023-10-01",paymentDate:"2023-09-28",customer:"Client X"},{id:"inv-2",amount:4500,status:"overdue",issueDate:"2023-08-15",dueDate:"2023-09-15",customer:"Client Y"},{id:"inv-3",amount:12e3,status:"pending",issueDate:"2023-10-10",dueDate:"2023-11-10",customer:"Client Z"},{id:"inv-4",amount:2500,status:"paid",issueDate:"2023-09-10",dueDate:"2023-10-10",paymentDate:"2023-10-05",customer:"Client W"}],fB=[{id:"case-1",status:"open",priority:"high",severity:"high",type:"AML",description:"Suspicious transaction pattern detected",openDate:"2023-10-20",potentialFine:5e4,relatedEntity:"Vendor A"},{id:"case-2",status:"closed",priority:"medium",severity:"medium",type:"KYC",description:"Incomplete documentation for new vendor",openDate:"2023-09-01",closeDate:"2023-09-05",relatedEntity:"Supplier B"},{id:"case-3",status:"open",priority:"low",severity:"low",type:"Data Privacy",description:"Potential GDPR data retention issue",openDate:"2023-10-25",relatedEntity:"Internal System"}],sT=["Financial Novice","Budgeting Apprentice","Savings Specialist","Investment Adept","Wealth Master"],b0=200,Ct=S.createContext(void 0),mB=({children:e})=>{const[n,r]=S.useState($U),[i]=S.useState(HU),[o]=S.useState(VU),[c,u]=S.useState(KU),[m,f]=S.useState(12),[h,g]=S.useState(170),[v,b]=S.useState({score:450,level:3,levelName:"Savings Specialist",progress:25,credits:225}),[T,C]=S.useState(()=>localStorage.getItem("customBackgroundUrl")),[E,N]=S.useState(()=>localStorage.getItem("activeIllusion")||"none"),[I,P]=S.useState([]),[M,j]=S.useState({stage:vi.Pitch,businessPlan:"",feedback:"",questions:[],loanAmount:0,coachingPlan:null,error:null}),[k,R]=S.useState(()=>localStorage.getItem("geminiApiKey")),[F,q]=S.useState(()=>localStorage.getItem("modernTreasuryApiKey")),[G,H]=S.useState(()=>localStorage.getItem("modernTreasuryOrganizationId")),V=ie=>{ie?(localStorage.setItem("geminiApiKey",ie),R(ie)):(localStorage.removeItem("geminiApiKey"),R(null))},oe=ie=>{ie?(localStorage.setItem("modernTreasuryApiKey",ie),q(ie)):(localStorage.removeItem("modernTreasuryApiKey"),q(null))},Z=ie=>{ie?(localStorage.setItem("modernTreasuryOrganizationId",ie),H(ie)):(localStorage.removeItem("modernTreasuryOrganizationId"),H(null))},[me]=S.useState(YU),[z]=S.useState(WU),[Y]=S.useState(JU),[ce,ge]=S.useState(QU),[Me]=S.useState(XU),[U,te]=S.useState(rB),[ue,fe]=S.useState(eB),[Ne,Pe]=S.useState(tB),[Re,wt]=S.useState([]),[re,Le]=S.useState(nB),[Fe,de]=S.useState(null),[$t,$e]=S.useState([]),[Ht,Vt]=S.useState(null),[cr,Er]=S.useState([]),[Po,Jr]=S.useState(!1),[Io,ki]=S.useState(!1),[Us,Kt]=S.useState(iB),[ko]=S.useState(aB),[Bs,zs]=S.useState(ZU),[ci,bc]=S.useState(uB),[ja,Do]=S.useState(dB),[ur,Qr]=S.useState(fB),[Qt,Sn]=S.useState(oB),[An]=S.useState(sB),[Fs,wc]=S.useState(lB),[Sc]=S.useState(cB),[ui,Di]=S.useState([]),[di,Nr]=S.useState(!1),[Ma,fi]=S.useState(null),Ac={defaultCarbonOffset:.1};S.useEffect(()=>{wc(ie=>ie.map(le=>le.provider==="Google Gemini"?{...le,status:k?"Operational":"Major Outage"}:le.provider==="Modern Treasury"?{...le,status:F&&G?"Operational":"Major Outage"}:le))},[k,F,G]),S.useEffect(()=>{const ie=le=>{const he=le.detail;$e(ye=>ye.some(Ce=>Ce.info.uuid===he.info.uuid)?ye:[...ye,he])};return window.addEventListener("eip6963:announceProvider",ie),window.dispatchEvent(new Event("eip6963:requestProvider")),()=>{window.removeEventListener("eip6963:announceProvider",ie)}},[]);const Ro=async ie=>{try{const le=await ie.provider.request({method:"eth_requestAccounts"});if(le&&le.length>0){const he=le[0];let ye=0;try{const Ce=await ie.provider.request({method:"eth_getBalance",params:[he,"latest"]});ye=parseInt(Ce,16)/1e18}catch(Ce){console.warn("Failed to fetch balance",Ce)}de({address:he,balance:ye})}}catch(le){console.error("Failed to connect to provider:",le)}},Ae=()=>{de(null)},Bt=ie=>{localStorage.setItem("customBackgroundUrl",ie),C(ie),localStorage.setItem("activeIllusion","none"),N("none")},qs=ie=>{localStorage.setItem("activeIllusion",ie),N(ie),ie!=="none"&&(localStorage.removeItem("customBackgroundUrl"),C(null))},O=ie=>{console.log("Navigating to:",ie)},Ue=ie=>{b(le=>{const he=le.score+ie,ye=Math.floor(he/b0)+1,Ce=he%b0/b0*100,De=sT[Math.min(ye-1,sT.length-1)],Rt=le.credits+(ie>0?Math.floor(ie/2):0);return{score:he,level:ye,levelName:De,progress:Ce,credits:Rt}})},sn=S.useCallback(async()=>{if(!(!F||!G)){Nr(!0),fi(null);try{const ie=btoa(`${G}:${F}`),le=await fetch("https://try.readme.io/https://app.moderntreasury.com/api/ledger_accounts?pending_balance_amount=&posted_balance_amount=&available_balance_amount=&per_page=25",{method:"GET",headers:{Accept:"application/json",Authorization:`Basic ${ie}`}});if(!le.ok)throw new Error(`Error: ${le.status} ${le.statusText}`);const he=await le.json();Array.isArray(he)?Di(he):(console.warn("Unexpected API response structure",he),Di([]))}catch(ie){console.error("Failed to fetch ledger accounts",ie),fi(ie instanceof Error?ie.message:"Unknown error")}finally{Nr(!1)}}},[F,G]),zn=S.useCallback(async()=>{if(Jr(!0),!k){Er([{id:"error_no_key",title:"API Key Not Set",description:"Please configure your Google Gemini API key in the API Status view.",urgency:"high"}]),Jr(!1);return}try{const ie=new ar({apiKey:k}),he=`You are Quantum, a proactive AI financial advisor. Analyze the user's recent transactions to generate 3 diverse, actionable insights. Your insights must be concise. If an insight is about high spending, provide chartData for the top 3 items. Format your response as a JSON object that strictly adheres to the provided schema. Do not include any text outside of the JSON object. + +Recent Transactions: ${n.slice(0,10).map(De=>`${De.description}: $${De.amount.toFixed(2)} (${De.type})`).join(", ")}`,ye=await ie.models.generateContent({model:"gemini-2.5-flash",contents:he,config:{responseMimeType:"application/json",responseSchema:{type:_e.OBJECT,properties:{insights:{type:_e.ARRAY,description:"A list of 3 diverse financial insights.",items:{type:_e.OBJECT,properties:{id:{type:_e.STRING,description:"A unique identifier for the insight, e.g., 'insight_1'."},title:{type:_e.STRING,description:"A short, catchy title for the insight (max 10 words)."},description:{type:_e.STRING,description:"A concise, user-friendly description of the insight (max 2 sentences)."},urgency:{type:_e.STRING,description:"The urgency level of the insight.",enum:["low","medium","high"]},chartData:{type:_e.ARRAY,description:"Optional. If the insight is about spending, provide data for a bar chart. Include the top 3 items.",nullable:!0,items:{type:_e.OBJECT,properties:{name:{type:_e.STRING,description:"The name of the item for the chart (e.g., a specific transaction description)."},value:{type:_e.NUMBER,description:"The value (amount) for the chart."}},required:["name","value"]}}},required:["id","title","description","urgency"]}}},required:["insights"]}}}),Ce=JSON.parse(ye.text);Ce.insights&&Er(Ce.insights)}catch(ie){console.error("Failed to generate AI insights:",ie),Er([{id:"error_1",title:"Analysis Paused",description:"Could not fetch fresh insights at this time. Displaying last known data.",urgency:"low"}])}finally{Jr(!1)}},[n,k]);S.useEffect(()=>{zn();const ie=setInterval(zn,35e3);return()=>clearInterval(ie)},[zn]);const Ri=(ie,le)=>{ki(!0),console.log("Plaid Link Success!",{publicToken:ie,metadata:le});const he={id:le.institution.institution_id,name:le.institution.name,mask:le.accounts[0].mask};I.some(ye=>ye.id===he.id)||P(ye=>[...ye,he]),setTimeout(()=>{const ye=[{id:`plaid_${Date.now()}`,type:"expense",category:"Shopping",description:"Zara",amount:152.34,date:"2024-03-22",carbonFootprint:10.1},{id:`plaid_${Date.now()+1}`,type:"expense",category:"Dining",description:"The Cheesecake Factory",amount:85.5,date:"2024-03-21",carbonFootprint:8.2},{id:`plaid_${Date.now()+2}`,type:"income",category:"Salary",description:"Paycheck",amount:2500,date:"2024-03-20"},{id:`plaid_${Date.now()+3}`,type:"expense",category:"Groceries",description:"Whole Foods",amount:210.4,date:"2024-03-19",carbonFootprint:21.8},{id:`plaid_${Date.now()+4}`,type:"expense",category:"Transport",description:"Uber",amount:25.1,date:"2024-03-18",carbonFootprint:2.1},{id:`plaid_${Date.now()+5}`,type:"expense",category:"Utilities",description:"Con Edison",amount:112,date:"2024-03-15",carbonFootprint:25.3},{id:`plaid_${Date.now()+6}`,type:"expense",category:"Entertainment",description:"Netflix Subscription",amount:15.99,date:"2024-03-12",carbonFootprint:.5},{id:`plaid_${Date.now()+7}`,type:"expense",category:"Dining",description:"Starbucks",amount:7.8,date:"2024-03-11",carbonFootprint:.8}];r(Ce=>[...ye,...Ce]),Ue(100),zn(),ki(!1)},4e3)},dr=ie=>{P(le=>le.filter(he=>he.id!==ie))},xd=async ie=>{if(j(le=>({...le,stage:vi.Analysis,businessPlan:ie,error:null})),!k){j(le=>({...le,stage:vi.Error,error:"Google Gemini API Key is not set. Please add it in the API Status view."}));return}try{const le=new ar({apiKey:k}),he=`Analyze the following business plan. Provide brief, constructive initial feedback (1-2 sentences) and generate exactly 5 sample assessment questions based on the plan's potential weaknesses or key areas. The questions should cover different categories like Market, Finance, Operations, etc. + +Business Plan: "${ie}"`,ye=await le.models.generateContent({model:"gemini-2.5-flash",contents:he,config:{responseMimeType:"application/json",responseSchema:{type:_e.OBJECT,properties:{feedback:{type:_e.STRING},questions:{type:_e.ARRAY,items:{type:_e.OBJECT,properties:{id:{type:_e.STRING},question:{type:_e.STRING},category:{type:_e.STRING}},required:["id","question","category"]}}},required:["feedback","questions"]}}}),Ce=JSON.parse(ye.text);j(De=>({...De,stage:vi.Test,feedback:Ce.feedback,questions:Ce.questions}))}catch(le){console.error("Error analyzing business plan:",le),j(he=>({...he,stage:vi.Error,error:"Plato AI encountered an issue analyzing your plan. Please try again."}))}},mi=async()=>{if(j(ie=>({...ie,stage:vi.FinalReview,error:null})),!k){j(ie=>({...ie,stage:vi.Error,error:"Google Gemini API Key is not set. Please add it in the API Status view."}));return}try{const ie=new ar({apiKey:k}),le=`Based on this business plan, you have approved a seed loan. Determine a realistic loan amount (between $50,000 and $250,000). Then, generate a 3-step coaching plan to guide the founder. The plan should be high-level and encouraging. + +Business Plan: "${M.businessPlan}"`,he=await ie.models.generateContent({model:"gemini-2.5-flash",contents:le,config:{responseMimeType:"application/json",responseSchema:{type:_e.OBJECT,properties:{loanAmount:{type:_e.NUMBER},coachingPlan:{type:_e.OBJECT,properties:{title:{type:_e.STRING},summary:{type:_e.STRING},steps:{type:_e.ARRAY,items:{type:_e.OBJECT,properties:{title:{type:_e.STRING},description:{type:_e.STRING},timeline:{type:_e.STRING}},required:["title","description","timeline"]}}},required:["title","summary","steps"]}},required:["loanAmount","coachingPlan"]}}}),ye=JSON.parse(he.text),{loanAmount:Ce,coachingPlan:De}=ye;j(Wn=>({...Wn,stage:vi.Approved,loanAmount:Ce,coachingPlan:De}));const Rt={id:`loan_${new Date().toISOString()}`,type:"income",category:"Loan",description:"QuantumWeaver Seed Loan",amount:Ce,date:new Date().toLocaleDateString("en-CA")};Dt(Rt)}catch(ie){console.error("Error finalizing loan:",ie),j(le=>({...le,stage:vi.Error,error:"Plato AI couldn't finalize the funding package. Please try again."}))}},Dt=ie=>{if(r(le=>[ie,...le]),ie.type==="expense"){g(he=>{const ye=he+ie.amount;return ye>=250?(f(Ce=>Ce+Math.floor(ye/250)),ye%250):ye});const le=c.find(he=>he.name.toLowerCase()===ie.category.toLowerCase());le&&u(he=>he.map(ye=>ye.id===le.id?{...ye,spent:ye.spent+ie.amount}:ye))}Ue(ie.type==="income"?20:10)},In=ie=>{const le={id:ie.name.toLowerCase().replace(" ","-"),...ie,spent:0,color:`#${Math.floor(Math.random()*16777215).toString(16)}`};u(he=>[...he,le])},Pa=ie=>{const le={...ie,id:`goal_${Date.now()}`,currentAmount:0,plan:null};fe(he=>[...he,le])},Cc=(ie,le)=>{var ye;fe(Ce=>Ce.map(De=>De.id===ie?{...De,currentAmount:De.currentAmount+le}:De));const he={id:`goal_contrib_${Date.now()}`,type:"expense",category:"Savings",description:`Contribution to ${(ye=ue.find(Ce=>Ce.id===ie))==null?void 0:ye.name}`,amount:le,date:new Date().toLocaleDateString("en-CA")};Dt(he)},rp=async ie=>{const le=ue.find(he=>he.id===ie);if(le){if(!k){console.error("Gemini API key not set.");return}try{const he=new ar({apiKey:k}),ye=`Generate a feasible financial plan for the following goal. Provide a brief feasibility summary, a recommended monthly contribution, and 3 actionable steps across different categories (Savings, Budgeting, Investing, Income). + +Goal: ${le.name} +Target Amount: $${le.targetAmount} +Target Date: ${le.targetDate} +Current Savings for this goal: $${le.currentAmount}`,Ce=await he.models.generateContent({model:"gemini-2.5-flash",contents:ye,config:{responseMimeType:"application/json",responseSchema:{type:_e.OBJECT,properties:{feasibilitySummary:{type:_e.STRING},monthlyContribution:{type:_e.NUMBER},steps:{type:_e.ARRAY,items:{type:_e.OBJECT,properties:{title:{type:_e.STRING},description:{type:_e.STRING},category:{type:_e.STRING,enum:["Savings","Budgeting","Investing","Income"]}},required:["title","description","category"]}}},required:["feasibilitySummary","monthlyContribution","steps"]}}}),De=JSON.parse(Ce.text);fe(Rt=>Rt.map(Wn=>Wn.id===ie?{...Wn,plan:De}:Wn))}catch(he){console.error("Error generating goal plan:",he)}}},ip=()=>{setTimeout(()=>{Vt({cardNumber:"5555 1234 5678 9012",cvv:"123",expiry:"12/28",holderName:"The Visionary"})},2e3)},bd=(ie,le)=>{setTimeout(()=>{const he=ie/3e3;Pe(Ce=>Ce.map(De=>De.ticker===le?{...De,amount:De.amount+he,value:De.value+ie}:De));const ye={id:`crypto_buy_${Date.now()}`,type:"expense",category:"Investments",description:`Buy ${le} via Stripe`,amount:ie,date:new Date().toLocaleDateString("en-CA"),carbonFootprint:.2};Dt(ye),Er(Ce=>[{id:"crypto_insight_1",title:"Crypto Purchase Detected",description:`Our systems noticed your recent purchase of ${le}. We recommend monitoring market volatility.`,urgency:"medium"},...Ce])},1e3)},Oo=(ie,le)=>{const he={id:`nft_${Date.now()}`,name:ie,imageUrl:le,contractAddress:`0x${Math.random().toString(16).substr(2,40)}`};wt(ye=>[he,...ye]),Sn(ye=>[{id:`notif_${Date.now()}`,message:`Congratulations! You've successfully minted the "${ie}" NFT.`,timestamp:"Just now",read:!1,view:ve.Crypto},...ye])},Tc=(ie,le,he)=>{if(Ne.some(Ce=>Ce.ticker.toUpperCase()===le.toUpperCase())){Sn(Ce=>[{id:`notif_${Date.now()}`,message:`Error: Token with ticker ${le.toUpperCase()} already exists.`,timestamp:"Just now",read:!1,view:ve.Crypto},...Ce]);return}const ye={ticker:le.toUpperCase(),name:ie,value:Math.random()*100,amount:he,color:`#${Math.floor(Math.random()*16777215).toString(16).padStart(6,"0")}`};Pe(Ce=>[...Ce,ye]),Sn(Ce=>[{id:`notif_${Date.now()}`,message:`New token minted: ${he.toLocaleString()} ${le.toUpperCase()} added to your portfolio.`,timestamp:"Just now",read:!1,view:ve.Crypto},...Ce])},Ia=async ie=>{if(!G||!F)throw new Error("Modern Treasury API Key and Organization ID must be set in API Status view.");return console.log("Simulating Modern Treasury Counterparty Creation:",ie),new Promise((le,he)=>{setTimeout(()=>{const ye={id:`cpty_${Date.now()}`,name:ie.name,email:ie.email,send_remittance_advice:!1,created_at:new Date().toISOString(),accounts:[{id:`act_${Date.now()}`,party_name:ie.name,account_details:[{account_number_safe:ie.accountNumber.slice(-4)}]}]};zs(Ce=>[ye,...Ce]),le()},1500)})},ka=ie=>{Kt(le=>le.map(he=>he.id===ie?{...he,frozen:!he.frozen}:he))},Lo=(ie,le,he)=>{Kt(ye=>ye.map(Ce=>Ce.id===ie?{...Ce,controls:le,frozen:he}:Ce))},Da=ie=>{Sn(le=>le.map(he=>he.id===ie?{...he,read:!0}:he))},Xt=ie=>{const le={...ie,id:`po_${Date.now()}`,status:"Initiated",date:new Date().toLocaleDateString("en-CA")};Le(he=>[le,...he]),setTimeout(()=>{Le(he=>he.map(ye=>ye.id===le.id?{...ye,status:"Processing"}:ye))},3e3),setTimeout(()=>{Le(he=>he.map(ye=>ye.id===le.id?{...ye,status:"Completed"}:ye))},8e3)},wd=ie=>U.balance>=ie.cost?(te(le=>({...le,balance:le.balance-ie.cost,lastRedeemed:ie.cost})),Sn(le=>[{id:`notif_reward_${Date.now()}`,message:`You've successfully redeemed "${ie.name}" for ${ie.cost.toLocaleString()} points.`,timestamp:"Just now",read:!1,view:ve.Rewards},...le]),!0):!1,Sd=(ie,le)=>{const he=ue.find(Rt=>Rt.id===ie);if(!he)return;const ye={id:`cnt_${Date.now()}`,amount:le,date:new Date().toISOString(),type:"manual"},Ce=[...he.contributions||[],ye],De=he.currentAmount+le;fe(Rt=>Rt.map(Wn=>Wn.id===ie?{...Wn,contributions:Ce,currentAmount:De}:Wn)),Dt({id:`tx_goal_${Date.now()}`,type:"expense",category:"Savings",description:`Contribution to ${he.name}`,amount:le,date:new Date().toLocaleDateString("en-CA")})},Oi=(ie,le)=>{const he=ue.find(De=>De.id===ie);if(!he)return;const ye={...le,id:`rec_${Date.now()}`},Ce=[...he.recurringContributions||[],ye];fe(De=>De.map(Rt=>Rt.id===ie?{...Rt,recurringContributions:Ce}:Rt))},Ra=(ie,le,he)=>{fe(ye=>ye.map(Ce=>{if(Ce.id!==ie)return Ce;const De=(Ce.recurringContributions||[]).map(Rt=>Rt.id===le?{...Rt,...he}:Rt);return{...Ce,recurringContributions:De}}))},ap=(ie,le)=>{fe(he=>he.map(ye=>{if(ye.id!==ie)return ye;const Ce=(ye.recurringContributions||[]).filter(De=>De.id!==le);return{...ye,recurringContributions:Ce}}))},Ad=(ie,le)=>{fe(he=>he.map(ye=>{if(ye.id!==ie)return ye;let Ce={...ye,...le};return le.monthlyContribution&&Ce.plan&&(Ce.plan={...Ce.plan,monthlyContribution:le.monthlyContribution}),Ce}))},Cd=(ie,le,he,ye)=>{fe(Ce=>Ce.map(De=>{if(De.id!==ie)return De;const Rt={id:le,relationshipType:he,triggerAmount:ye},Wn=[...De.linkedGoals||[],Rt];return{...De,linkedGoals:Wn}}))},op=(ie,le)=>{fe(he=>he.map(ye=>{if(ye.id!==ie)return ye;const Ce=(ye.linkedGoals||[]).filter(De=>De.id!==le);return{...ye,linkedGoals:Ce}}))},Gs=async()=>[],$s=async()=>[],Xr=async()=>({}),Yn={treesPlanted:m,spendingForNextTree:h,progressToNextTree:h/250*100},Td={transactions:n,assets:i,impactInvestments:o,budgets:c,addBudget:In,gamification:v,impactData:Yn,customBackgroundUrl:T,setCustomBackgroundUrl:Bt,addTransaction:Dt,activeIllusion:E,setActiveIllusion:qs,linkedAccounts:I,unlinkAccount:dr,handlePlaidSuccess:Ri,weaverState:M,pitchBusinessPlan:xd,simulateTestPass:mi,subscriptions:me,creditScore:z,upcomingBills:Y,savingsGoals:ce,marketMovers:Me,financialGoals:ue,addFinancialGoal:Pa,contributeToGoal:Cc,generateGoalPlan:rp,cryptoAssets:Ne,paymentOperations:re,walletInfo:Fe,detectedProviders:$t,connectWallet:Ro,disconnectWallet:Ae,virtualCard:Ht,issueCard:ip,buyCrypto:bd,aiInsights:cr,isInsightsLoading:Po,corporateCards:Us,corporateTransactions:ko,toggleCorporateCardFreeze:ka,updateCorporateCard:Lo,rewardPoints:U,notifications:Qt,markNotificationRead:Da,isImportingData:Io,nftAssets:Re,mintNFT:Oo,mintToken:Tc,initiatePayment:Xt,rewardItems:An,redeemReward:wd,apiStatus:Fs,creditFactors:Sc,geminiApiKey:k,setGeminiApiKey:V,modernTreasuryApiKey:F,setModernTreasuryApiKey:oe,modernTreasuryOrganizationId:G,setModernTreasuryOrganizationId:Z,counterparties:Bs,addCounterparty:Ia,paymentOrders:ci,invoices:ja,complianceCases:ur,userPreferences:Ac,fetchRecipients:Gs,fetchCurrencies:$s,getUserSecurityProfile:Xr,ledgerAccounts:ui,fetchLedgerAccounts:sn,isLedgerAccountsLoading:di,ledgerAccountsError:Ma,setActiveView:O,addContributionToGoal:Sd,addRecurringContributionToGoal:Oi,updateRecurringContributionInGoal:Ra,deleteRecurringContributionFromGoal:ap,updateFinancialGoal:Ad,linkGoals:Cd,unlinkGoals:op};return l.jsx(Ct.Provider,{value:Td,children:e})},hB=()=>{const e=["Heuristic API: Actively analyzing portfolio...","Heuristic API: Monitoring market data...","Heuristic API: Identified 2 potential savings...","Heuristic API: All systems nominal.","Heuristic API: Cross-referencing spending patterns...","Heuristic API: Compiling weekly insights..."],[t,n]=S.useState(0);return S.useEffect(()=>{const r=setInterval(()=>{n(i=>(i+1)%e.length)},4e3);return()=>clearInterval(r)},[]),l.jsxs("div",{className:"hidden lg:flex items-center space-x-2 text-xs text-cyan-300/80 bg-gray-900/40 px-3 py-1.5 rounded-full border border-cyan-500/10 transition-all duration-500",children:[l.jsxs("div",{className:"flex space-x-0.5 items-end h-4",children:[l.jsx("span",{className:"w-1 h-1 bg-cyan-400 rounded-full animate-pulse [animation-delay:-0.3s]"}),l.jsx("span",{className:"w-1 h-2 bg-cyan-400 rounded-full animate-pulse [animation-delay:-0.15s]"}),l.jsx("span",{className:"w-1 h-3 bg-cyan-400 rounded-full animate-pulse"}),l.jsx("span",{className:"w-1 h-2 bg-cyan-400 rounded-full animate-pulse [animation-delay:-0.15s]"}),l.jsx("span",{className:"w-1 h-1 bg-cyan-400 rounded-full animate-pulse [animation-delay:-0.3s]"})]}),l.jsx("span",{className:"font-mono",children:e[t]})]})},pB=({onMenuClick:e,setActiveView:t})=>{const n=S.useContext(Ct),[r,i]=S.useState(!1),[o,c]=S.useState(!1);if(!n)throw new Error("Header must be used within a DataProvider");const{notifications:u,markNotificationRead:m}=n,f=u.filter(g=>!g.read).length,h=g=>{g.view&&t(g.view),m(g.id),i(!1)};return l.jsxs("header",{className:"py-4 px-6 bg-gray-900/30 backdrop-blur-md border-b border-gray-700/50 flex justify-between items-center z-20",children:[l.jsxs("div",{className:"flex items-center",children:[l.jsx("button",{onClick:e,className:"text-gray-400 focus:outline-none lg:hidden mr-4",children:l.jsx("svg",{className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M4 6h16M4 12h16M4 18h16"})})}),l.jsx("h1",{className:"text-lg sm:text-xl font-semibold text-white tracking-wider uppercase",children:"DEMO BANK"})]}),l.jsxs("div",{className:"flex items-center space-x-3",children:[l.jsx(hB,{}),l.jsxs("div",{className:"relative",children:[l.jsxs("button",{onClick:()=>i(g=>!g),className:"text-gray-400 hover:text-white focus:outline-none",children:[l.jsx("svg",{className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9"})}),f>0&&l.jsx("span",{className:"absolute top-0 right-0 block h-2 w-2 rounded-full bg-cyan-400 ring-2 ring-gray-900"})]}),r&&l.jsxs("div",{className:"absolute right-0 mt-2 w-80 bg-gray-800 border border-gray-700 rounded-lg shadow-lg z-50",children:[l.jsx("div",{className:"p-3 font-semibold text-white border-b border-gray-700",children:"Notifications"}),l.jsx("div",{className:"max-h-96 overflow-y-auto",children:u.map(g=>l.jsxs("div",{onClick:()=>h(g),className:`p-3 text-sm flex items-start border-b border-gray-700/50 cursor-pointer ${g.read?"opacity-60":"bg-cyan-500/10"}`,children:[!g.read&&l.jsx("div",{className:"w-2 h-2 rounded-full bg-cyan-400 mt-1.5 flex-shrink-0"}),l.jsxs("div",{className:"ml-2",children:[l.jsx("p",{className:"text-gray-200",children:g.message}),l.jsx("p",{className:"text-xs text-gray-400 mt-1",children:g.timestamp})]})]},g.id))})]})]}),l.jsxs("div",{className:"relative",children:[l.jsxs("button",{onClick:()=>c(g=>!g),className:"flex items-center space-x-3",children:[l.jsx("div",{className:"w-10 h-10 rounded-full bg-gradient-to-br from-cyan-500 to-indigo-600 flex items-center justify-center border-2 border-cyan-400",children:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})})}),l.jsx("span",{className:"hidden sm:block font-medium text-white",children:"The Visionary"})]}),o&&l.jsxs("div",{className:"absolute right-0 mt-2 w-48 bg-gray-800 border border-gray-700 rounded-lg shadow-lg z-50",children:[l.jsx("a",{href:"#",onClick:g=>{g.preventDefault(),t(ve.Settings),c(!1)},className:"block px-4 py-2 text-sm text-gray-300 hover:bg-gray-700",children:"Settings"}),l.jsx("a",{href:"#",onClick:g=>{g.preventDefault(),alert("Logout functionality not implemented.")},className:"block px-4 py-2 text-sm text-gray-300 hover:bg-gray-700",children:"Logout"})]})]})]})]})},gB=[{id:ve.Dashboard,label:"Dashboard",icon:l.jsx(yB,{})},{id:ve.Transactions,label:"Transactions",icon:l.jsx(vB,{})},{id:ve.SendMoney,label:"Send Money",icon:l.jsx(xB,{})},{id:ve.Budgets,label:"Budgets",icon:l.jsx(bB,{})},{id:ve.Investments,label:"Investments",icon:l.jsx(wB,{})},{id:ve.AIAdvisor,label:"AI Advisor",icon:l.jsx(AB,{})},{id:ve.QuantumWeaver,label:"Quantum Weaver",icon:l.jsx(CB,{})},{id:ve.CorporateCommand,label:"Corporate Command",icon:l.jsx(DB,{})},{id:ve.ModernTreasury,label:"Ledger Accounts",icon:l.jsx(RB,{})},{id:ve.APIIntegration,label:"API Status",icon:l.jsx(OB,{})},{id:ve.AIAdStudio,label:"AI Ad Studio",icon:l.jsx(TB,{})},{id:ve.Crypto,label:"Crypto & Web3",icon:l.jsx(EB,{})},{id:ve.Goals,label:"Financial Goals",icon:l.jsx(NB,{})},{id:ve.Marketplace,label:"Marketplace",icon:l.jsx(_B,{})},{id:ve.Personalization,label:"Personalization",icon:l.jsx(jB,{})},{id:ve.CardCustomization,label:"Customize Card",icon:l.jsx(MB,{})},{id:ve.Security,label:"Security",icon:l.jsx(PB,{})},{id:ve.OpenBanking,label:"Open Banking",icon:l.jsx(IB,{})},{id:ve.FinancialDemocracy,label:"Financial Democracy",icon:l.jsx(kB,{})},{id:ve.SASPlatforms,label:"The Winning Vision",icon:l.jsx(SB,{})},{id:ve.Rewards,label:"Rewards Hub",icon:l.jsx(LB,{})},{id:ve.CreditHealth,label:"Credit Health",icon:l.jsx(UB,{})},{id:ve.Settings,label:"Settings",icon:l.jsx(BB,{})}];function yB(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2V6zM14 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2V6zM4 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2v-2zM14 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2v-2z"})})}function vB(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}function xB(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})})}function bB(e){return l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:[l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 3.055A9.001 9.001 0 1020.945 13H11V3.055z"}),l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20.488 9H15V3.512A9.025 9.025 0 0120.488 9z"})]})}function wB(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 7h8m0 0v8m0-8l-8 8-4-4-6 6"})})}function SB(e){return l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:[l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]})}function AB(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 3v4M3 5h4M6 17v4m-2-2h4m5-16l2.286 6.857L21 12l-5.714 2.143L13 21l-2.286-6.857L5 12l5.714-2.143L13 3z"})})}function CB(e){return l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:[l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}function TB(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"})})}function EB(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})})}function NB(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 3v2m6-2v2M9 19v-6a2 2 0 012-2h2a2 2 0 012 2v6m-6 0h6M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})})}function _B(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M16 11V7a4 4 0 00-8 0v4M5 9h14l1 12H4L5 9z"})})}function jB(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6V4m0 16v-2m8-8h-2M4 12H2m15.364 6.364l-1.414-1.414M6.343 6.343L4.929 4.929m12.728 12.728l-1.414-1.414M6.343 17.657l-1.414 1.414m12.02-6.02a4 4 0 11-5.656-5.656 4 4 0 015.656 5.656z"})})}function MB(e){return l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:[l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z"}),l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 3l4.5 4.5-10.5 10.5h-4.5v-4.5l10.5-10.5z"})]})}function PB(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 20.944a11.955 11.955 0 019-2.606m0-15.394v15.394"})})}function IB(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"})})}function kB(e){return l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:[l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17.657 18.657A8 8 0 016.343 7.343S7 9 9 10c2 1 5 1 7 0 2-1 2.657-1.343 2.657-1.343a8 8 0 010 10z"}),l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}function DB(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m-1 4h1m5-8h1m-1 4h1m-1 4h1M9 21v-3.07a2 2 0 01.15-.76 2 2 0 011.6-1.17h.5a2 2 0 011.6 1.17c.1.4.15.76.15.76V21"})})}function RB(e){return l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:[l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4M4 7l8 4.5 8-4.5"}),l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 12l8 4.5 8-4.5"})]})}function OB(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6","aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})})}function LB(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v13m0-13V6a2 2 0 112 2h-2zm0 0V5.5A2.5 2.5 0 109.5 8H12zm-7 4h14M5 12a2 2 0 110-4h14a2 2 0 110 4H5z"})})}function UB(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z"})})}function BB(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065zM15 12a3 3 0 11-6 0 3 3 0 016 0z"})})}const zB=()=>l.jsxs("svg",{role:"img",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"w-6 h-6",children:[l.jsx("title",{children:"Chase"}),l.jsx("path",{d:"M12,24A12,12,0,1,0,0,12,12,12,0,0,0,12,24Z",fill:"#117aca"}),l.jsx("path",{d:"M12.22,18.25h4.63V12.5H12.22Zm-5.75-5.75H11.1v4.63H6.47Zm5.75-5.75h4.63V11.1H12.22Z",fill:"#fff"}),l.jsx("path",{d:"M18.25,6.47V11.1h-4.63V6.47Z",fill:"#fff"})]}),FB=()=>l.jsxs("svg",{role:"img",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"w-6 h-6",children:[l.jsx("title",{children:"Bank of America"}),l.jsx("path",{d:"M9.3 4H14.7L18 10.5H6L9.3 4ZM9.3 19.9H14.7L18 13.4H6L9.3 19.9Z",fill:"#005A9C"}),l.jsx("path",{d:"M4 10.5H20V13.4H4V10.5Z",fill:"#E2001A"})]}),qB=()=>l.jsxs("svg",{role:"img",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"w-6 h-6",children:[l.jsx("title",{children:"Wells Fargo"}),l.jsx("path",{fill:"#D71E28",d:"M2.57 20.83L.01 4.2h23.98l-2.56 16.63z"}),l.jsx("path",{fill:"#FFC72C",d:"M17.84 8.78L16.2 12.8h-1.9L12 5.7l-2.3 7.1H7.8l-1.6-4.02L4.08 17.5h15.84l-2.08-8.72z"})]}),GB=()=>l.jsxs("svg",{role:"img",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"w-6 h-6",children:[l.jsx("title",{children:"American Express"}),l.jsx("path",{d:"M22.498 2.5H1.5C.67 2.5 0 3.17 0 4v16c0 .83.67 1.5 1.5 1.5h20.998c.83 0 1.5-.67 1.5-1.5V4c0-.83-.67-1.5-1.502-1.5z",fill:"#006FCF"}),l.jsx("path",{d:"M14.65 14.24h-1.02l.62-1.63-2-5.11h-1.3l-3.23 8.24h1.02l.62-1.63h3.04l.3 1.63h1.25zm-2.8-2.67l.95-2.51.95 2.51h-1.9zM15.9 14.24V9.5h1.25v-1h2v1h1.25v4.74h-1.25v2h-2v-2H15.9z",fill:"#fff"})]}),$B=()=>l.jsxs("svg",{role:"img",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"w-6 h-6",children:[l.jsx("title",{children:"Citi"}),l.jsx("path",{d:"M12 24C5.373 24 0 18.627 0 12S5.373 0 12 0s12 5.373 12 12-5.373 12-12 12Z",fill:"#003B70"}),l.jsx("path",{d:"M7.4 17.2h1.4v-7H7.4v7zm4.2 0h1.4v-7h-1.4v7zm4.2 0h1.4v-7h-1.4v7z",fill:"#fff"}),l.jsx("path",{d:"M6 9.4c0-.4.3-.8.8-.8h9.4c.5 0 .8.4.8.8v.2a7.1 7.1 0 0 0-11 0v-.2z",fill:"#D71E28"})]}),HB=()=>l.jsxs("svg",{role:"img",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"w-6 h-6",children:[l.jsx("title",{children:"Binance"}),l.jsx("path",{fill:"#F0B90B",d:"M12 24a12 12 0 100-24 12 12 0 000 24z"}),l.jsx("path",{d:"m14.92 12.11 2.05-2.02-2.05-2.02-2.02 2.02-2.8-2.8-2.01 2.02 4.8 4.8-4.8 4.8 2.02 2.02 2.8-2.8 2.02 2.02 2.05-2.02-2.05-2.02z",fill:"#fff"})]}),VB=()=>l.jsxs("svg",{role:"img",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"w-6 h-6",children:[l.jsx("title",{children:"Coinbase"}),l.jsx("path",{d:"M12 24C5.373 24 0 18.627 0 12S5.373 0 12 0s12 5.373 12 12-5.373 12-12 12z",fill:"#0052FF"}),l.jsx("path",{d:"M7 7h10v10H7V7z",fill:"#fff"})]}),KB=()=>l.jsxs("svg",{role:"img",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"w-6 h-6",children:[l.jsx("title",{children:"Venmo"}),l.jsx("path",{d:"M23.2 14.7c-.2-2-1-3.7-2.3-5.2-1.3-1.4-3-2.5-5-3.3-1-.4-2-.7-3-1-.5-.1-.9-.3-1.4-.4C11.1 4.7 11 5 11 5.3c.1.6.2 1.2.4 1.8.2.6.4 1.2.7 1.7 1.1 2 2.6 3.7 4.5 5 .3.2.6.3.9.4.5.1.9.2 1.3.3.6.1 1.2.2 1.8.3.1.2.1.4.1.6-.2 2.1-1.1 3.9-2.5 5.2-1.4 1.4-3.3 2.3-5.3 2.7-.6.1-1.2.2-1.8.3-.2 0-.4-.1-.5-.2-.1-.2-.1-.5 0-.7.3-.8.6-1.6.8-2.4.2-1 .3-2 .5-3 .1-.4.2-.8.4-1.2l.2-.7.2-.6c.2-.4.3-.7.3-1.1.1-.3.1-.7.1-1 0-.4-.1-.8-.2-1.2-.2-.5-.4-1-.7-1.4-.7-1.1-1.6-2.1-2.8-2.8-.5-.3-1-.6-1.5-.8-1-.4-2-.7-3-1-.3-.1-.5-.2-.8-.3-.2-.1-.5-.1-.7-.2-.4-.1-.9-.2-1.3-.3-.4 0-.9-.1-1.3-.1h-.1c-.1 0-.2.1-.2.2v.2c0 .2 0 .4.1.6s.1.4.1.6l.1.5c.1.3.2.7.3 1 .1.4.2.8.4 1.1.2.3.4.6.6.9.5.6 1 1.2 1.6 1.7.6.5 1.2.9 1.9 1.3 1.1.6 2.2 1 3.4 1.4.5.1.9.3 1.4.4.4.1.9.3 1.3.4.7.2 1.4.3 2.1.5.1 0 .2.1.2.2.1.2.1.4 0 .6-.2.1-.5.3-.7.4-.6.2-1.2.4-1.8.5-1.1.3-2.2.5-3.3.6-2.2.3-4.4.2-6.6-.3L0 12.9V7.1l.8.1c.2 0 .4.1.6.1.7.1 1.4.2 2.1.4.9.2 1.8.5 2.7.9.8.3 1.6.7 2.4 1.2.7.4 1.4.8 2 1.3.6.4 1.2.8 1.8 1.2.2.1.4.3.6.4.3.2.6.4.9.6.1.1.3.1.4.2.1 0 .1.1.2.1Z",fill:"#3D95CE"})]}),YB=()=>l.jsxs("svg",{role:"img",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"w-6 h-6",children:[l.jsx("title",{children:"PayPal"}),l.jsx("path",{d:"M7.34 19.32h2.75l1.6-10.87H8.62L7.34 19.32zm8.3-10.6c-.4-.25-1-.41-1.8-.41h-1.8l.52 3.42c.1.34.4.57.75.57h.26c.4 0 .73-.22.82-.59l.4-2.58c.08-.4.04-.6-.15-.81zm.55 5.06c-.2.9-1 1.55-2.04 1.55h-1.06l-.52-3.4h1.1c.73 0 1.22.12 1.5.7.2.4.2.9-.03 1.15zM22.18 8.4h-2.9l-2.07 10.92h2.2l.33-1.83h2.18c2.1 0 3.3-1.12 3.8-3.18.4-1.6-.2-2.9-1.54-3.91z",fill:"#003087"}),l.jsx("path",{d:"M24 8.16C22.45 6.9 20.2 6.5 17.7 6.5h-5.23l-.53 3.42-.18 1.15-.02.34c-.1.34.18.63.53.63h.2c.4 0 .73-.22.82-.59l.86-5.46h1.8c.4 0 .74.05.97.16 1.4.65 1.8 2.18 1.4 3.9-.3 1.25-1.1 1.9-2.2 1.9h-1.06l.52-3.42c.1-.34.4-.57.75-.57h.03c.4 0 .73.22.82-.59l.4-2.58c.08-.4.04-.6-.15-.81-.4-.25-1-.41-1.8-.41h-.05c-.4 0-.74-.05-.97-.16-1.4-.65-1.8-2.18-1.4-3.91.4-1.92 2.1-2.95 4.1-2.95h2.9z",fill:"#009CDE"})]}),WB=()=>l.jsxs("svg",{role:"img",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"w-6 h-6",children:[l.jsx("title",{children:"Zelle"}),l.jsx("path",{d:"M12 24C5.373 24 0 18.627 0 12S5.373 0 12 0s12 5.373 12 12-5.373 12-12 12z",fill:"#6930B5"}),l.jsxs("g",{fill:"#fff",children:[l.jsx("path",{d:"M16.9 8.3h-9.8c-.3 0-.5.2-.5.5s.2.5.5.5h9.8c.3 0 .5-.2.5-.5s-.2-.5-.5-.5z"}),l.jsx("path",{d:"M16.9 11.5h-9.8c-.3 0-.5.2-.5.5s.2.5.5.5h9.8c.3 0 .5-.2.5-.5s-.2-.5-.5-.5zM7.1 14.7h9.8c.3 0 .5.2.5.5s-.2.5-.5.5H7.1c-.3 0-.5-.2-.5-.5s.2-.5.5-.5z"})]})]}),E3=[{name:"Chase",logo:l.jsx(zB,{}),institution_id:"ins_109960"},{name:"Bank of America",logo:l.jsx(FB,{}),institution_id:"ins_109950"},{name:"Wells Fargo",logo:l.jsx(qB,{}),institution_id:"ins_109980"},{name:"American Express",logo:l.jsx(GB,{}),institution_id:"ins_100000"},{name:"Citi",logo:l.jsx($B,{}),institution_id:"ins_109970"},{name:"Binance",logo:l.jsx(HB,{}),institution_id:"crypto_binance"},{name:"Coinbase",logo:l.jsx(VB,{}),institution_id:"crypto_coinbase"},{name:"Venmo",logo:l.jsx(KB,{}),institution_id:"payment_venmo"},{name:"Paypal",logo:l.jsx(YB,{}),institution_id:"payment_paypal"},{name:"Zelle",logo:l.jsx(WB,{}),institution_id:"payment_zelle"}],JB=({className:e})=>l.jsxs("svg",{className:e,viewBox:"0 0 100 100",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("circle",{cx:"50",cy:"50",r:"48",stroke:"currentColor",strokeWidth:"4"}),l.jsx("path",{d:"M30 70V30H55C65 30 65 40 55 40H30",stroke:"currentColor",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("path",{d:"M55 70V30",stroke:"currentColor",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"})]}),QB=({activeView:e,setActiveView:t,isOpen:n,setIsOpen:r})=>{const i=o=>{t(o),r(!1)};return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:`fixed inset-0 bg-black/60 z-30 transition-opacity lg:hidden ${n?"opacity-100":"opacity-0 pointer-events-none"}`,onClick:()=>r(!1)}),l.jsxs("div",{className:`flex flex-col w-64 bg-gray-900/50 backdrop-blur-lg border-r border-gray-700/50 fixed lg:relative inset-y-0 left-0 z-40 transform transition-transform duration-300 ease-in-out ${n?"translate-x-0":"-translate-x-full"} lg:translate-x-0`,children:[l.jsxs("div",{className:"flex items-center justify-between h-20 border-b border-gray-700/50 px-6",children:[l.jsxs("div",{className:"flex items-center space-x-2 text-cyan-400",children:[l.jsx(JB,{className:"h-10 w-10"}),l.jsx("span",{className:"font-bold text-lg text-white",children:"Demo Bank"})]}),l.jsx("button",{onClick:()=>r(!1),className:"text-gray-400 lg:hidden",children:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),l.jsx("div",{className:"flex-1 overflow-y-auto",children:l.jsx("nav",{className:"flex-1 px-2 py-4 space-y-2",children:gB.map(o=>l.jsxs("a",{href:"#",onClick:c=>{c.preventDefault(),i(o.id)},className:`flex items-center px-4 py-2 text-gray-300 transition-colors duration-200 transform rounded-md hover:bg-gray-700/50 hover:text-white ${e===o.id?"bg-cyan-500/20 text-cyan-300 border-l-4 border-cyan-400":""}`,children:[o.icon,l.jsx("span",{className:"mx-4 font-medium",children:o.label})]},o.id))})})]})]})};function N3(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t{var[r]=n;return _3(r)||j3(r)});return Object.fromEntries(t)}function As(e){if(e==null)return null;if(S.isValidElement(e)&&typeof e.props=="object"&&e.props!==null){var t=e.props;return Kn(t)}return typeof e=="object"&&!Array.isArray(e)?Kn(e):null}function Mn(e){var t=Object.entries(e).filter(n=>{var[r]=n;return _3(r)||j3(r)||Ux(r)});return Object.fromEntries(t)}function ez(e){return e==null?null:S.isValidElement(e)?Mn(e.props):typeof e=="object"&&!Array.isArray(e)?Mn(e):null}var tz=["children","width","height","viewBox","className","style","title","desc"];function pv(){return pv=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{children:n,width:r,height:i,viewBox:o,className:c,style:u,title:m,desc:f}=e,h=nz(e,tz),g=o||{width:r,height:i,x:0,y:0},v=Xe("recharts-surface",c);return S.createElement("svg",pv({},Mn(h),{className:v,width:r,height:i,style:u,viewBox:"".concat(g.x," ").concat(g.y," ").concat(g.width," ").concat(g.height),ref:t}),S.createElement("title",null,m),S.createElement("desc",null,f),n)}),iz=["children","className"];function gv(){return gv=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{children:n,className:r}=e,i=az(e,iz),o=Xe("recharts-layer",r);return S.createElement("g",gv({className:o},Mn(i),{ref:t}),n)}),zx=Xj(),M3=S.createContext(null),sz=()=>S.useContext(M3);function At(e){return function(){return e}}const P3=Math.cos,dm=Math.sin,li=Math.sqrt,fm=Math.PI,dh=2*fm,yv=Math.PI,vv=2*yv,ts=1e-6,lz=vv-ts;function I3(e){this._+=e[0];for(let t=1,n=e.length;t=0))throw new Error(`invalid digits: ${e}`);if(t>15)return I3;const n=10**t;return function(r){this._+=r[0];for(let i=1,o=r.length;its)if(!(Math.abs(g*m-f*h)>ts)||!o)this._append`L${this._x1=t},${this._y1=n}`;else{let b=r-c,T=i-u,C=m*m+f*f,E=b*b+T*T,N=Math.sqrt(C),I=Math.sqrt(v),P=o*Math.tan((yv-Math.acos((C+v-E)/(2*N*I)))/2),M=P/I,j=P/N;Math.abs(M-1)>ts&&this._append`L${t+M*h},${n+M*g}`,this._append`A${o},${o},0,0,${+(g*b>h*T)},${this._x1=t+j*m},${this._y1=n+j*f}`}}arc(t,n,r,i,o,c){if(t=+t,n=+n,r=+r,c=!!c,r<0)throw new Error(`negative radius: ${r}`);let u=r*Math.cos(i),m=r*Math.sin(i),f=t+u,h=n+m,g=1^c,v=c?i-o:o-i;this._x1===null?this._append`M${f},${h}`:(Math.abs(this._x1-f)>ts||Math.abs(this._y1-h)>ts)&&this._append`L${f},${h}`,r&&(v<0&&(v=v%vv+vv),v>lz?this._append`A${r},${r},0,1,${g},${t-u},${n-m}A${r},${r},0,1,${g},${this._x1=f},${this._y1=h}`:v>ts&&this._append`A${r},${r},0,${+(v>=yv)},${g},${this._x1=t+r*Math.cos(o)},${this._y1=n+r*Math.sin(o)}`)}rect(t,n,r,i){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}h${r=+r}v${+i}h${-r}Z`}toString(){return this._}}function Fx(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{const r=Math.floor(n);if(!(r>=0))throw new RangeError(`invalid digits: ${n}`);t=r}return e},()=>new uz(t)}function qx(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function k3(e){this._context=e}k3.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t);break}}};function fh(e){return new k3(e)}function D3(e){return e[0]}function R3(e){return e[1]}function O3(e,t){var n=At(!0),r=null,i=fh,o=null,c=Fx(u);e=typeof e=="function"?e:e===void 0?D3:At(e),t=typeof t=="function"?t:t===void 0?R3:At(t);function u(m){var f,h=(m=qx(m)).length,g,v=!1,b;for(r==null&&(o=i(b=c())),f=0;f<=h;++f)!(f=b;--T)u.point(P[T],M[T]);u.lineEnd(),u.areaEnd()}N&&(P[v]=+e(E,v,g),M[v]=+t(E,v,g),u.point(r?+r(E,v,g):P[v],n?+n(E,v,g):M[v]))}if(I)return u=null,I+""||null}function h(){return O3().defined(i).curve(c).context(o)}return f.x=function(g){return arguments.length?(e=typeof g=="function"?g:At(+g),r=null,f):e},f.x0=function(g){return arguments.length?(e=typeof g=="function"?g:At(+g),f):e},f.x1=function(g){return arguments.length?(r=g==null?null:typeof g=="function"?g:At(+g),f):r},f.y=function(g){return arguments.length?(t=typeof g=="function"?g:At(+g),n=null,f):t},f.y0=function(g){return arguments.length?(t=typeof g=="function"?g:At(+g),f):t},f.y1=function(g){return arguments.length?(n=g==null?null:typeof g=="function"?g:At(+g),f):n},f.lineX0=f.lineY0=function(){return h().x(e).y(t)},f.lineY1=function(){return h().x(e).y(n)},f.lineX1=function(){return h().x(r).y(t)},f.defined=function(g){return arguments.length?(i=typeof g=="function"?g:At(!!g),f):i},f.curve=function(g){return arguments.length?(c=g,o!=null&&(u=c(o)),f):c},f.context=function(g){return arguments.length?(g==null?o=u=null:u=c(o=g),f):o},f}class L3{constructor(t,n){this._context=t,this._x=n}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(t,n){switch(t=+t,n=+n,this._point){case 0:{this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+t)/2,this._y0,this._x0,n,t,n):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+n)/2,t,this._y0,t,n);break}}this._x0=t,this._y0=n}}function dz(e){return new L3(e,!0)}function fz(e){return new L3(e,!1)}const Gx={draw(e,t){const n=li(t/fm);e.moveTo(n,0),e.arc(0,0,n,0,dh)}},mz={draw(e,t){const n=li(t/5)/2;e.moveTo(-3*n,-n),e.lineTo(-n,-n),e.lineTo(-n,-3*n),e.lineTo(n,-3*n),e.lineTo(n,-n),e.lineTo(3*n,-n),e.lineTo(3*n,n),e.lineTo(n,n),e.lineTo(n,3*n),e.lineTo(-n,3*n),e.lineTo(-n,n),e.lineTo(-3*n,n),e.closePath()}},U3=li(1/3),hz=U3*2,pz={draw(e,t){const n=li(t/hz),r=n*U3;e.moveTo(0,-n),e.lineTo(r,0),e.lineTo(0,n),e.lineTo(-r,0),e.closePath()}},gz={draw(e,t){const n=li(t),r=-n/2;e.rect(r,r,n,n)}},yz=.8908130915292852,B3=dm(fm/10)/dm(7*fm/10),vz=dm(dh/10)*B3,xz=-P3(dh/10)*B3,bz={draw(e,t){const n=li(t*yz),r=vz*n,i=xz*n;e.moveTo(0,-n),e.lineTo(r,i);for(let o=1;o<5;++o){const c=dh*o/5,u=P3(c),m=dm(c);e.lineTo(m*n,-u*n),e.lineTo(u*r-m*i,m*r+u*i)}e.closePath()}},w0=li(3),wz={draw(e,t){const n=-li(t/(w0*3));e.moveTo(0,n*2),e.lineTo(-w0*n,-n),e.lineTo(w0*n,-n),e.closePath()}},Or=-.5,Lr=li(3)/2,xv=1/li(12),Sz=(xv/2+1)*3,Az={draw(e,t){const n=li(t/Sz),r=n/2,i=n*xv,o=r,c=n*xv+n,u=-o,m=c;e.moveTo(r,i),e.lineTo(o,c),e.lineTo(u,m),e.lineTo(Or*r-Lr*i,Lr*r+Or*i),e.lineTo(Or*o-Lr*c,Lr*o+Or*c),e.lineTo(Or*u-Lr*m,Lr*u+Or*m),e.lineTo(Or*r+Lr*i,Or*i-Lr*r),e.lineTo(Or*o+Lr*c,Or*c-Lr*o),e.lineTo(Or*u+Lr*m,Or*m-Lr*u),e.closePath()}};function Cz(e,t){let n=null,r=Fx(i);e=typeof e=="function"?e:At(e||Gx),t=typeof t=="function"?t:At(t===void 0?64:+t);function i(){let o;if(n||(n=o=r()),e.apply(this,arguments).draw(n,+t.apply(this,arguments)),o)return n=null,o+""||null}return i.type=function(o){return arguments.length?(e=typeof o=="function"?o:At(o),i):e},i.size=function(o){return arguments.length?(t=typeof o=="function"?o:At(+o),i):t},i.context=function(o){return arguments.length?(n=o??null,i):n},i}function mm(){}function hm(e,t,n){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+n)/6)}function z3(e){this._context=e}z3.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:hm(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:hm(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function Tz(e){return new z3(e)}function F3(e){this._context=e}F3.prototype={areaStart:mm,areaEnd:mm,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2),this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break}case 3:{this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:hm(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function Ez(e){return new F3(e)}function q3(e){this._context=e}q3.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+e)/6,r=(this._y0+4*this._y1+t)/6;this._line?this._context.lineTo(n,r):this._context.moveTo(n,r);break;case 3:this._point=4;default:hm(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function Nz(e){return new q3(e)}function G3(e){this._context=e}G3.prototype={areaStart:mm,areaEnd:mm,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,t){e=+e,t=+t,this._point?this._context.lineTo(e,t):(this._point=1,this._context.moveTo(e,t))}};function _z(e){return new G3(e)}function lT(e){return e<0?-1:1}function cT(e,t,n){var r=e._x1-e._x0,i=t-e._x1,o=(e._y1-e._y0)/(r||i<0&&-0),c=(n-e._y1)/(i||r<0&&-0),u=(o*i+c*r)/(r+i);return(lT(o)+lT(c))*Math.min(Math.abs(o),Math.abs(c),.5*Math.abs(u))||0}function uT(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function S0(e,t,n){var r=e._x0,i=e._y0,o=e._x1,c=e._y1,u=(o-r)/3;e._context.bezierCurveTo(r+u,i+u*t,o-u,c-u*n,o,c)}function pm(e){this._context=e}pm.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:S0(this,this._t0,uT(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,S0(this,uT(this,n=cT(this,e,t)),n);break;default:S0(this,this._t0,n=cT(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}};function $3(e){this._context=new H3(e)}($3.prototype=Object.create(pm.prototype)).point=function(e,t){pm.prototype.point.call(this,t,e)};function H3(e){this._context=e}H3.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,n,r,i,o){this._context.bezierCurveTo(t,e,r,n,o,i)}};function jz(e){return new pm(e)}function Mz(e){return new $3(e)}function V3(e){this._context=e}V3.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,n=e.length;if(n)if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),n===2)this._context.lineTo(e[1],t[1]);else for(var r=dT(e),i=dT(t),o=0,c=1;c=0;--t)i[t]=(c[t]-i[t+1])/o[t];for(o[n-1]=(e[n]+i[n-1])/2,t=0;t=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var n=this._x*(1-this._t)+e*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,t)}break}}this._x=e,this._y=t}};function Iz(e){return new mh(e,.5)}function kz(e){return new mh(e,0)}function Dz(e){return new mh(e,1)}function Jl(e,t){if((c=e.length)>1)for(var n=1,r,i,o=e[t[0]],c,u=o.length;n=0;)n[t]=t;return n}function Rz(e,t){return e[t]}function Oz(e){const t=[];return t.key=e,t}function Lz(){var e=At([]),t=bv,n=Jl,r=Rz;function i(o){var c=Array.from(e.apply(this,arguments),Oz),u,m=c.length,f=-1,h;for(const g of o)for(u=0,++f;u0){for(var n,r,i=0,o=e[0].length,c;i0){for(var n=0,r=e[t[0]],i,o=r.length;n0)||!((o=(i=e[t[0]]).length)>0))){for(var n=0,r=1,i,o,c;re===0?0:e>0?1:-1,sr=e=>typeof e=="number"&&e!=+e,ha=e=>typeof e=="string"&&e.indexOf("%")===e.length-1,we=e=>(typeof e=="number"||e instanceof Number)&&!sr(e),Vr=e=>we(e)||typeof e=="string",Hz=0,Pu=e=>{var t=++Hz;return"".concat(e||"").concat(t)},Un=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!we(t)&&typeof t!="string")return r;var o;if(ha(t)){if(n==null)return r;var c=t.indexOf("%");o=n*parseFloat(t.slice(0,c))/100}else o=+t;return sr(o)&&(o=r),i&&n!=null&&o>n&&(o=n),o},Y3=e=>{if(!Array.isArray(e))return!1;for(var t=e.length,n={},r=0;rr&&(typeof t=="function"?t(r):Cs(r,t))===n)}var jt=e=>e===null||typeof e>"u",Ju=e=>jt(e)?e:"".concat(e.charAt(0).toUpperCase()).concat(e.slice(1));function Vz(e){return e!=null}function Ds(){}var Kz=["type","size","sizeType"];function wv(){return wv=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var t="symbol".concat(Ju(e));return J3[t]||Gx},tF=(e,t,n)=>{if(t==="area")return e;switch(n){case"cross":return 5*e*e/9;case"diamond":return .5*e*e/Math.sqrt(3);case"square":return e*e;case"star":{var r=18*Zz;return 1.25*e*e*(Math.tan(r)-Math.tan(r*2)*Math.tan(r)**2)}case"triangle":return Math.sqrt(3)*e*e/4;case"wye":return(21-10*Math.sqrt(3))*e*e/8;default:return Math.PI*e*e/4}},nF=(e,t)=>{J3["symbol".concat(Ju(e))]=t},Kx=e=>{var{type:t="circle",size:n=64,sizeType:r="area"}=e,i=Qz(e,Kz),o=bT(bT({},i),{},{type:t,size:n,sizeType:r}),c="circle";typeof t=="string"&&(c=t);var u=()=>{var v=eF(c),b=Cz().type(v).size(tF(n,r,c)),T=b();if(T!==null)return T},{className:m,cx:f,cy:h}=o,g=Mn(o);return we(f)&&we(h)&&we(n)?S.createElement("path",wv({},g,{className:Xe("recharts-symbols",m),transform:"translate(".concat(f,", ").concat(h,")"),d:u()})):null};Kx.registerSymbol=nF;var Q3=e=>"radius"in e&&"startAngle"in e&&"endAngle"in e,Yx=(e,t)=>{if(!e||typeof e=="function"||typeof e=="boolean")return null;var n=e;if(S.isValidElement(e)&&(n=e.props),typeof n!="object"&&typeof n!="function")return null;var r={};return Object.keys(n).forEach(i=>{Ux(i)&&(r[i]=(o=>n[i](n,o)))}),r},rF=(e,t,n)=>r=>(e(t,n,r),null),Qu=(e,t,n)=>{if(e===null||typeof e!="object"&&typeof e!="function")return null;var r=null;return Object.keys(e).forEach(i=>{var o=e[i];Ux(i)&&typeof o=="function"&&(r||(r={}),r[i]=rF(o,t,n))}),r};function wT(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function iF(e){for(var t=1;t(c[u]===void 0&&r[u]!==void 0&&(c[u]=r[u]),c),n);return o}function gm(){return gm=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var v=h.formatter||i,b=Xe({"recharts-legend-item":!0,["legend-item-".concat(g)]:!0,inactive:h.inactive});if(h.type==="none")return null;var T=h.inactive?o:h.color,C=v?v(h.value,h,g):h.value;return S.createElement("li",gm({className:b,style:m,key:"legend-item-".concat(g)},Qu(e,h,g)),S.createElement(Bx,{width:n,height:n,viewBox:u,style:f,"aria-label":"".concat(C," legend icon")},S.createElement(mF,{data:h,iconType:c,inactiveColor:o})),S.createElement("span",{className:"recharts-legend-item-text",style:{color:T}},C))})}var pF=e=>{var t=Lt(e,fF),{payload:n,layout:r,align:i}=t;if(!n||!n.length)return null;var o={padding:0,margin:0,textAlign:r==="horizontal"?i:"left"};return S.createElement("ul",{className:"recharts-default-legend",style:o},S.createElement(hF,gm({},t,{payload:n})))},M0={},P0={},AT;function gF(){return AT||(AT=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n,r){const i=new Map;for(let o=0;o=0}e.isLength=t})(R0)),R0}var ET;function Wx(){return ET||(ET=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=yF();function n(r){return r!=null&&typeof r!="function"&&t.isLength(r.length)}e.isArrayLike=n})(D0)),D0}var O0={},NT;function vF(){return NT||(NT=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return typeof n=="object"&&n!==null}e.isObjectLike=t})(O0)),O0}var _T;function xF(){return _T||(_T=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=Wx(),n=vF();function r(i){return n.isObjectLike(i)&&t.isArrayLike(i)}e.isArrayLikeObject=r})(k0)),k0}var L0={},U0={},jT;function bF(){return jT||(jT=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=Vx();function n(r){return function(i){return t.get(i,r)}}e.property=n})(U0)),U0}var B0={},z0={},F0={},q0={},MT;function Z3(){return MT||(MT=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return n!==null&&(typeof n=="object"||typeof n=="function")}e.isObject=t})(q0)),q0}var G0={},PT;function eM(){return PT||(PT=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return n==null||typeof n!="object"&&typeof n!="function"}e.isPrimitive=t})(G0)),G0}var $0={},IT;function tM(){return IT||(IT=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n,r){return n===r||Number.isNaN(n)&&Number.isNaN(r)}e.eq=t})($0)),$0}var kT;function wF(){return kT||(kT=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=Z3(),n=eM(),r=tM();function i(h,g,v){return typeof v!="function"?i(h,g,()=>{}):o(h,g,function b(T,C,E,N,I,P){const M=v(T,C,E,N,I,P);return M!==void 0?!!M:o(T,C,b,P)},new Map)}function o(h,g,v,b){if(g===h)return!0;switch(typeof g){case"object":return c(h,g,v,b);case"function":return Object.keys(g).length>0?o(h,{...g},v,b):r.eq(h,g);default:return t.isObject(h)?typeof g=="string"?g==="":!0:r.eq(h,g)}}function c(h,g,v,b){if(g==null)return!0;if(Array.isArray(g))return m(h,g,v,b);if(g instanceof Map)return u(h,g,v,b);if(g instanceof Set)return f(h,g,v,b);const T=Object.keys(g);if(h==null)return T.length===0;if(T.length===0)return!0;if(b!=null&&b.has(g))return b.get(g)===h;b==null||b.set(g,h);try{for(let C=0;C{})}e.isMatch=n})(z0)),z0}var H0={},V0={},K0={},RT;function SF(){return RT||(RT=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return Object.getOwnPropertySymbols(n).filter(r=>Object.prototype.propertyIsEnumerable.call(n,r))}e.getSymbols=t})(K0)),K0}var Y0={},OT;function rM(){return OT||(OT=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return n==null?n===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(n)}e.getTag=t})(Y0)),Y0}var W0={},LT;function iM(){return LT||(LT=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t="[object RegExp]",n="[object String]",r="[object Number]",i="[object Boolean]",o="[object Arguments]",c="[object Symbol]",u="[object Date]",m="[object Map]",f="[object Set]",h="[object Array]",g="[object Function]",v="[object ArrayBuffer]",b="[object Object]",T="[object Error]",C="[object DataView]",E="[object Uint8Array]",N="[object Uint8ClampedArray]",I="[object Uint16Array]",P="[object Uint32Array]",M="[object BigUint64Array]",j="[object Int8Array]",k="[object Int16Array]",R="[object Int32Array]",F="[object BigInt64Array]",q="[object Float32Array]",G="[object Float64Array]";e.argumentsTag=o,e.arrayBufferTag=v,e.arrayTag=h,e.bigInt64ArrayTag=F,e.bigUint64ArrayTag=M,e.booleanTag=i,e.dataViewTag=C,e.dateTag=u,e.errorTag=T,e.float32ArrayTag=q,e.float64ArrayTag=G,e.functionTag=g,e.int16ArrayTag=k,e.int32ArrayTag=R,e.int8ArrayTag=j,e.mapTag=m,e.numberTag=r,e.objectTag=b,e.regexpTag=t,e.setTag=f,e.stringTag=n,e.symbolTag=c,e.uint16ArrayTag=I,e.uint32ArrayTag=P,e.uint8ArrayTag=E,e.uint8ClampedArrayTag=N})(W0)),W0}var J0={},UT;function AF(){return UT||(UT=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}e.isTypedArray=t})(J0)),J0}var BT;function aM(){return BT||(BT=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=SF(),n=rM(),r=iM(),i=eM(),o=AF();function c(h,g){return u(h,void 0,h,new Map,g)}function u(h,g,v,b=new Map,T=void 0){const C=T==null?void 0:T(h,g,v,b);if(C!==void 0)return C;if(i.isPrimitive(h))return h;if(b.has(h))return b.get(h);if(Array.isArray(h)){const E=new Array(h.length);b.set(h,E);for(let N=0;Nt.isMatch(o,i)}e.matches=r})(B0)),B0}var Q0={},X0={},Z0={},qT;function EF(){return qT||(qT=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=aM(),n=iM();function r(i,o){return t.cloneDeepWith(i,(c,u,m,f)=>{const h=o==null?void 0:o(c,u,m,f);if(h!==void 0)return h;if(typeof i=="object")switch(Object.prototype.toString.call(i)){case n.numberTag:case n.stringTag:case n.booleanTag:{const g=new i.constructor(i==null?void 0:i.valueOf());return t.copyProperties(g,i),g}case n.argumentsTag:{const g={};return t.copyProperties(g,i),g.length=i.length,g[Symbol.iterator]=i[Symbol.iterator],g}default:return}})}e.cloneDeepWith=r})(Z0)),Z0}var GT;function NF(){return GT||(GT=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=EF();function n(r){return t.cloneDeepWith(r)}e.cloneDeep=n})(X0)),X0}var ey={},ty={},$T;function oM(){return $T||($T=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=/^(?:0|[1-9]\d*)$/;function n(r,i=Number.MAX_SAFE_INTEGER){switch(typeof r){case"number":return Number.isInteger(r)&&r>=0&&r"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:u;return sy.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:h,sy}var ZT;function OF(){return ZT||(ZT=1,oy.exports=RF()),oy.exports}/** + * @license React + * use-sync-external-store-shim/with-selector.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 eE;function LF(){if(eE)return ay;eE=1;var e=nc(),t=OF();function n(f,h){return f===h&&(f!==0||1/f===1/h)||f!==f&&h!==h}var r=typeof Object.is=="function"?Object.is:n,i=t.useSyncExternalStore,o=e.useRef,c=e.useEffect,u=e.useMemo,m=e.useDebugValue;return ay.useSyncExternalStoreWithSelector=function(f,h,g,v,b){var T=o(null);if(T.current===null){var C={hasValue:!1,value:null};T.current=C}else C=T.current;T=u(function(){function N(k){if(!I){if(I=!0,P=k,k=v(k),b!==void 0&&C.hasValue){var R=C.value;if(b(R,k))return M=R}return M=k}if(R=M,r(P,k))return R;var F=v(k);return b!==void 0&&b(R,F)?(P=k,R):(P=k,M=F)}var I=!1,P,M,j=g===void 0?null:g;return[function(){return N(h())},j===null?void 0:function(){return N(j())}]},[h,g,v,b]);var E=i(f,T[0],T[1]);return c(function(){C.hasValue=!0,C.value=E},[E]),m(E),E},ay}var tE;function UF(){return tE||(tE=1,iy.exports=LF()),iy.exports}var BF=UF(),Jx=S.createContext(null),zF=e=>e,bt=()=>{var e=S.useContext(Jx);return e?e.store.dispatch:zF},im=()=>{},FF=()=>im,qF=(e,t)=>e===t;function Se(e){var t=S.useContext(Jx);return BF.useSyncExternalStoreWithSelector(t?t.subscription.addNestedSub:FF,t?t.store.getState:im,t?t.store.getState:im,t?e:im,qF)}function GF(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function $F(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!="object")throw new TypeError(t)}function HF(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(n=>typeof n=="function")){const n=e.map(r=>typeof r=="function"?`function ${r.name||"unnamed"}()`:typeof r).join(", ");throw new TypeError(`${t}[${n}]`)}}var nE=e=>Array.isArray(e)?e:[e];function VF(e){const t=Array.isArray(e[0])?e[0]:e;return HF(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function KF(e,t){const n=[],{length:r}=e;for(let i=0;i{n=Uf(),c.resetResultsCount()},c.resultsCount=()=>o,c.resetResultsCount=()=>{o=0},c}function QF(e,...t){const n=typeof e=="function"?{memoize:e,memoizeOptions:t}:e,r=(...i)=>{let o=0,c=0,u,m={},f=i.pop();typeof f=="object"&&(m=f,f=i.pop()),GF(f,`createSelector expects an output function after the inputs, but received: [${typeof f}]`);const h={...n,...m},{memoize:g,memoizeOptions:v=[],argsMemoize:b=lM,argsMemoizeOptions:T=[]}=h,C=nE(v),E=nE(T),N=VF(i),I=g(function(){return o++,f.apply(null,arguments)},...C),P=b(function(){c++;const j=KF(N,arguments);return u=I.apply(null,j),u},...E);return Object.assign(P,{resultFunc:f,memoizedResultFunc:I,dependencies:N,dependencyRecomputations:()=>c,resetDependencyRecomputations:()=>{c=0},lastResult:()=>u,recomputations:()=>o,resetRecomputations:()=>{o=0},memoize:g,argsMemoize:b})};return Object.assign(r,{withTypes:()=>r}),r}var J=QF(lM),XF=Object.assign((e,t=J)=>{$F(e,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof e}`);const n=Object.keys(e),r=n.map(o=>e[o]);return t(r,(...o)=>o.reduce((c,u,m)=>(c[n[m]]=u,c),{}))},{withTypes:()=>XF}),ly={},cy={},uy={},iE;function ZF(){return iE||(iE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(r){return typeof r=="symbol"?1:r===null?2:r===void 0?3:r!==r?4:0}const n=(r,i,o)=>{if(r!==i){const c=t(r),u=t(i);if(c===u&&c===0){if(ri)return o==="desc"?-1:1}return o==="desc"?u-c:c-u}return 0};e.compareValues=n})(uy)),uy}var dy={},fy={},aE;function cM(){return aE||(aE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return typeof n=="symbol"||n instanceof Symbol}e.isSymbol=t})(fy)),fy}var oE;function e9(){return oE||(oE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=cM(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function i(o,c){return Array.isArray(o)?!1:typeof o=="number"||typeof o=="boolean"||o==null||t.isSymbol(o)?!0:typeof o=="string"&&(r.test(o)||!n.test(o))||c!=null&&Object.hasOwn(c,o)}e.isKey=i})(dy)),dy}var sE;function t9(){return sE||(sE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=ZF(),n=e9(),r=Hx();function i(o,c,u,m){if(o==null)return[];u=m?void 0:u,Array.isArray(o)||(o=Object.values(o)),Array.isArray(c)||(c=c==null?[null]:[c]),c.length===0&&(c=[null]),Array.isArray(u)||(u=u==null?[]:[u]),u=u.map(b=>String(b));const f=(b,T)=>{let C=b;for(let E=0;ET==null||b==null?T:typeof b=="object"&&"key"in b?Object.hasOwn(T,b.key)?T[b.key]:f(T,b.path):typeof b=="function"?b(T):Array.isArray(b)?f(T,b):typeof T=="object"?T[b]:T,g=c.map(b=>(Array.isArray(b)&&b.length===1&&(b=b[0]),b==null||typeof b=="function"||Array.isArray(b)||n.isKey(b)?b:{key:b,path:r.toPath(b)}));return o.map(b=>({original:b,criteria:g.map(T=>h(T,b))})).slice().sort((b,T)=>{for(let C=0;Cb.original)}e.orderBy=i})(cy)),cy}var my={},lE;function n9(){return lE||(lE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n,r=1){const i=[],o=Math.floor(r),c=(u,m)=>{for(let f=0;f1&&r.isIterateeCall(o,c[0],c[1])?c=[]:u>2&&r.isIterateeCall(c[0],c[1],c[2])&&(c=[c[0]]),t.orderBy(o,n.flatten(c),["asc"])}e.sortBy=i})(ly)),ly}var py,dE;function i9(){return dE||(dE=1,py=r9().sortBy),py}var a9=i9();const hh=ji(a9);var dM=e=>e.legend.settings,o9=e=>e.legend.size,s9=e=>e.legend.payload,l9=J([s9,dM],(e,t)=>{var{itemSorter:n}=t,r=e.flat(1);return n?hh(r,n):r});function c9(){return Se(l9)}var Bf=1;function fM(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],[t,n]=S.useState({height:0,left:0,top:0,width:0}),r=S.useCallback(i=>{if(i!=null){var o=i.getBoundingClientRect(),c={height:o.height,left:o.left,top:o.top,width:o.width};(Math.abs(c.height-t.height)>Bf||Math.abs(c.left-t.left)>Bf||Math.abs(c.top-t.top)>Bf||Math.abs(c.width-t.width)>Bf)&&n({height:c.height,left:c.left,top:c.top,width:c.width})}},[t.width,t.height,t.top,t.left,...e]);return[t,r]}function _n(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var u9=typeof Symbol=="function"&&Symbol.observable||"@@observable",fE=u9,gy=()=>Math.random().toString(36).substring(7).split("").join("."),d9={INIT:`@@redux/INIT${gy()}`,REPLACE:`@@redux/REPLACE${gy()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${gy()}`},ym=d9;function Qx(e){if(typeof e!="object"||e===null)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function mM(e,t,n){if(typeof e!="function")throw new Error(_n(2));if(typeof t=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(_n(0));if(typeof t=="function"&&typeof n>"u"&&(n=t,t=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(_n(1));return n(mM)(e,t)}let r=e,i=t,o=new Map,c=o,u=0,m=!1;function f(){c===o&&(c=new Map,o.forEach((E,N)=>{c.set(N,E)}))}function h(){if(m)throw new Error(_n(3));return i}function g(E){if(typeof E!="function")throw new Error(_n(4));if(m)throw new Error(_n(5));let N=!0;f();const I=u++;return c.set(I,E),function(){if(N){if(m)throw new Error(_n(6));N=!1,f(),c.delete(I),o=null}}}function v(E){if(!Qx(E))throw new Error(_n(7));if(typeof E.type>"u")throw new Error(_n(8));if(typeof E.type!="string")throw new Error(_n(17));if(m)throw new Error(_n(9));try{m=!0,i=r(i,E)}finally{m=!1}return(o=c).forEach(I=>{I()}),E}function b(E){if(typeof E!="function")throw new Error(_n(10));r=E,v({type:ym.REPLACE})}function T(){const E=g;return{subscribe(N){if(typeof N!="object"||N===null)throw new Error(_n(11));function I(){const M=N;M.next&&M.next(h())}return I(),{unsubscribe:E(I)}},[fE](){return this}}}return v({type:ym.INIT}),{dispatch:v,subscribe:g,getState:h,replaceReducer:b,[fE]:T}}function f9(e){Object.keys(e).forEach(t=>{const n=e[t];if(typeof n(void 0,{type:ym.INIT})>"u")throw new Error(_n(12));if(typeof n(void 0,{type:ym.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(_n(13))})}function hM(e){const t=Object.keys(e),n={};for(let o=0;o"u")throw u&&u.type,new Error(_n(14));f[g]=T,m=m||T!==b}return m=m||r.length!==Object.keys(c).length,m?f:c}}function vm(...e){return e.length===0?t=>t:e.length===1?e[0]:e.reduce((t,n)=>(...r)=>t(n(...r)))}function m9(...e){return t=>(n,r)=>{const i=t(n,r);let o=()=>{throw new Error(_n(15))};const c={getState:i.getState,dispatch:(m,...f)=>o(m,...f)},u=e.map(m=>m(c));return o=vm(...u)(i.dispatch),{...i,dispatch:o}}}function pM(e){return Qx(e)&&"type"in e&&typeof e.type=="string"}var gM=Symbol.for("immer-nothing"),mE=Symbol.for("immer-draftable"),Tr=Symbol.for("immer-state");function ii(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Iu=Object.getPrototypeOf;function Ts(e){return!!e&&!!e[Tr]}function pa(e){var t;return e?yM(e)||Array.isArray(e)||!!e[mE]||!!((t=e.constructor)!=null&&t[mE])||Xu(e)||gh(e):!1}var h9=Object.prototype.constructor.toString(),hE=new WeakMap;function yM(e){if(!e||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);if(t===null||t===Object.prototype)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;if(n===Object)return!0;if(typeof n!="function")return!1;let r=hE.get(n);return r===void 0&&(r=Function.toString.call(n),hE.set(n,r)),r===h9}function xm(e,t,n=!0){ph(e)===0?(n?Reflect.ownKeys(e):Object.keys(e)).forEach(i=>{t(i,e[i],e)}):e.forEach((r,i)=>t(i,r,e))}function ph(e){const t=e[Tr];return t?t.type_:Array.isArray(e)?1:Xu(e)?2:gh(e)?3:0}function Sv(e,t){return ph(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function vM(e,t,n){const r=ph(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function p9(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Xu(e){return e instanceof Map}function gh(e){return e instanceof Set}function ns(e){return e.copy_||e.base_}function Av(e,t){if(Xu(e))return new Map(e);if(gh(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=yM(e);if(t===!0||t==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(e);delete r[Tr];let i=Reflect.ownKeys(r);for(let o=0;o1&&Object.defineProperties(e,{set:zf,add:zf,clear:zf,delete:zf}),Object.freeze(e),t&&Object.values(e).forEach(n=>Xx(n,!0))),e}function g9(){ii(2)}var zf={value:g9};function yh(e){return e===null||typeof e!="object"?!0:Object.isFrozen(e)}var y9={};function Es(e){const t=y9[e];return t||ii(0,e),t}var ku;function xM(){return ku}function v9(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function pE(e,t){t&&(Es("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Cv(e){Tv(e),e.drafts_.forEach(x9),e.drafts_=null}function Tv(e){e===ku&&(ku=e.parent_)}function gE(e){return ku=v9(ku,e)}function x9(e){const t=e[Tr];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function yE(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[Tr].modified_&&(Cv(t),ii(4)),pa(e)&&(e=bm(t,e),t.parent_||wm(t,e)),t.patches_&&Es("Patches").generateReplacementPatches_(n[Tr].base_,e,t.patches_,t.inversePatches_)):e=bm(t,n,[]),Cv(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==gM?e:void 0}function bm(e,t,n){if(yh(t))return t;const r=e.immer_.shouldUseStrictIteration(),i=t[Tr];if(!i)return xm(t,(o,c)=>vE(e,i,t,o,c,n),r),t;if(i.scope_!==e)return t;if(!i.modified_)return wm(e,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const o=i.copy_;let c=o,u=!1;i.type_===3&&(c=new Set(o),o.clear(),u=!0),xm(c,(m,f)=>vE(e,i,o,m,f,n,u),r),wm(e,o,!1),n&&e.patches_&&Es("Patches").generatePatches_(i,n,e.patches_,e.inversePatches_)}return i.copy_}function vE(e,t,n,r,i,o,c){if(i==null||typeof i!="object"&&!c)return;const u=yh(i);if(!(u&&!c)){if(Ts(i)){const m=o&&t&&t.type_!==3&&!Sv(t.assigned_,r)?o.concat(r):void 0,f=bm(e,i,m);if(vM(n,r,f),Ts(f))e.canAutoFreeze_=!1;else return}else c&&n.add(i);if(pa(i)&&!u){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1||t&&t.base_&&t.base_[r]===i&&u)return;bm(e,i),(!t||!t.scope_.parent_)&&typeof r!="symbol"&&(Xu(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&wm(e,i)}}}function wm(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Xx(t,n)}function b9(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:xM(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,o=Zx;n&&(i=[r],o=Du);const{revoke:c,proxy:u}=Proxy.revocable(i,o);return r.draft_=u,r.revoke_=c,u}var Zx={get(e,t){if(t===Tr)return e;const n=ns(e);if(!Sv(n,t))return w9(e,n,t);const r=n[t];return e.finalized_||!pa(r)?r:r===yy(e.base_,t)?(vy(e),e.copy_[t]=Nv(r,e)):r},has(e,t){return t in ns(e)},ownKeys(e){return Reflect.ownKeys(ns(e))},set(e,t,n){const r=bM(ns(e),t);if(r!=null&&r.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=yy(ns(e),t),o=i==null?void 0:i[Tr];if(o&&o.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(p9(n,i)&&(n!==void 0||Sv(e.base_,t)))return!0;vy(e),Ev(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return yy(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,vy(e),Ev(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=ns(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},defineProperty(){ii(11)},getPrototypeOf(e){return Iu(e.base_)},setPrototypeOf(){ii(12)}},Du={};xm(Zx,(e,t)=>{Du[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});Du.deleteProperty=function(e,t){return Du.set.call(this,e,t,void 0)};Du.set=function(e,t,n){return Zx.set.call(this,e[0],t,n,e[0])};function yy(e,t){const n=e[Tr];return(n?ns(n):e)[t]}function w9(e,t,n){var i;const r=bM(t,n);return r?"value"in r?r.value:(i=r.get)==null?void 0:i.call(e.draft_):void 0}function bM(e,t){if(!(t in e))return;let n=Iu(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Iu(n)}}function Ev(e){e.modified_||(e.modified_=!0,e.parent_&&Ev(e.parent_))}function vy(e){e.copy_||(e.copy_=Av(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var S9=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(t,n,r)=>{if(typeof t=="function"&&typeof n!="function"){const o=n;n=t;const c=this;return function(m=o,...f){return c.produce(m,h=>n.call(this,h,...f))}}typeof n!="function"&&ii(6),r!==void 0&&typeof r!="function"&&ii(7);let i;if(pa(t)){const o=gE(this),c=Nv(t,void 0);let u=!0;try{i=n(c),u=!1}finally{u?Cv(o):Tv(o)}return pE(o,r),yE(i,o)}else if(!t||typeof t!="object"){if(i=n(t),i===void 0&&(i=t),i===gM&&(i=void 0),this.autoFreeze_&&Xx(i,!0),r){const o=[],c=[];Es("Patches").generateReplacementPatches_(t,i,o,c),r(o,c)}return i}else ii(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(c,...u)=>this.produceWithPatches(c,m=>t(m,...u));let r,i;return[this.produce(t,n,(c,u)=>{r=c,i=u}),r,i]},typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof(e==null?void 0:e.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),typeof(e==null?void 0:e.useStrictIteration)=="boolean"&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){pa(e)||ii(8),Ts(e)&&(e=ca(e));const t=gE(this),n=Nv(e,void 0);return n[Tr].isManual_=!0,Tv(t),n}finishDraft(e,t){const n=e&&e[Tr];(!n||!n.isManual_)&&ii(9);const{scope_:r}=n;return pE(r,t),yE(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const i=t[n];if(i.path.length===0&&i.op==="replace"){e=i.value;break}}n>-1&&(t=t.slice(n+1));const r=Es("Patches").applyPatches_;return Ts(e)?r(e,t):this.produce(e,i=>r(i,t))}};function Nv(e,t){const n=Xu(e)?Es("MapSet").proxyMap_(e,t):gh(e)?Es("MapSet").proxySet_(e,t):b9(e,t);return(t?t.scope_:xM()).drafts_.push(n),n}function ca(e){return Ts(e)||ii(10,e),wM(e)}function wM(e){if(!pa(e)||yh(e))return e;const t=e[Tr];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Av(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Av(e,!0);return xm(n,(i,o)=>{vM(n,i,wM(o))},r),t&&(t.finalized_=!1),n}var _v=new S9,SM=_v.produce,A9=_v.setUseStrictIteration.bind(_v);function AM(e){return({dispatch:n,getState:r})=>i=>o=>typeof o=="function"?o(n,r,e):i(o)}var C9=AM(),T9=AM,E9=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?vm:vm.apply(null,arguments)};function Kr(e,t){function n(...r){if(t){let i=t(...r);if(!i)throw new Error(Ar(0));return{type:e,payload:i.payload,..."meta"in i&&{meta:i.meta},..."error"in i&&{error:i.error}}}return{type:e,payload:r[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=r=>pM(r)&&r.type===e,n}var CM=class Tu extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,Tu.prototype)}static get[Symbol.species](){return Tu}concat(...t){return super.concat.apply(this,t)}prepend(...t){return t.length===1&&Array.isArray(t[0])?new Tu(...t[0].concat(this)):new Tu(...t.concat(this))}};function xE(e){return pa(e)?SM(e,()=>{}):e}function Ff(e,t,n){return e.has(t)?e.get(t):e.set(t,n(t)).get(t)}function N9(e){return typeof e=="boolean"}var _9=()=>function(t){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:o=!0}=t??{};let c=new CM;return n&&(N9(n)?c.push(C9):c.push(T9(n.extraArgument))),c},TM="RTK_autoBatch",un=()=>e=>({payload:e,meta:{[TM]:!0}}),bE=e=>t=>{setTimeout(t,e)},EM=(e={type:"raf"})=>t=>(...n)=>{const r=t(...n);let i=!0,o=!1,c=!1;const u=new Set,m=e.type==="tick"?queueMicrotask:e.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:bE(10):e.type==="callback"?e.queueNotification:bE(e.timeout),f=()=>{c=!1,o&&(o=!1,u.forEach(h=>h()))};return Object.assign({},r,{subscribe(h){const g=()=>i&&h(),v=r.subscribe(g);return u.add(h),()=>{v(),u.delete(h)}},dispatch(h){var g;try{return i=!((g=h==null?void 0:h.meta)!=null&&g[TM]),o=!i,o&&(c||(c=!0,m(f))),r.dispatch(h)}finally{i=!0}}})},j9=e=>function(n){const{autoBatch:r=!0}=n??{};let i=new CM(e);return r&&i.push(EM(typeof r=="object"?r:void 0)),i};function M9(e){const t=_9(),{reducer:n=void 0,middleware:r,devTools:i=!0,preloadedState:o=void 0,enhancers:c=void 0}=e||{};let u;if(typeof n=="function")u=n;else if(Qx(n))u=hM(n);else throw new Error(Ar(1));let m;typeof r=="function"?m=r(t):m=t();let f=vm;i&&(f=E9({trace:!1,...typeof i=="object"&&i}));const h=m9(...m),g=j9(h);let v=typeof c=="function"?c(g):g();const b=f(...v);return mM(u,o,b)}function NM(e){const t={},n=[];let r;const i={addCase(o,c){const u=typeof o=="string"?o:o.type;if(!u)throw new Error(Ar(28));if(u in t)throw new Error(Ar(29));return t[u]=c,i},addAsyncThunk(o,c){return c.pending&&(t[o.pending.type]=c.pending),c.rejected&&(t[o.rejected.type]=c.rejected),c.fulfilled&&(t[o.fulfilled.type]=c.fulfilled),c.settled&&n.push({matcher:o.settled,reducer:c.settled}),i},addMatcher(o,c){return n.push({matcher:o,reducer:c}),i},addDefaultCase(o){return r=o,i}};return e(i),[t,n,r]}A9(!1);function P9(e){return typeof e=="function"}function I9(e,t){let[n,r,i]=NM(t),o;if(P9(e))o=()=>xE(e());else{const u=xE(e);o=()=>u}function c(u=o(),m){let f=[n[m.type],...r.filter(({matcher:h})=>h(m)).map(({reducer:h})=>h)];return f.filter(h=>!!h).length===0&&(f=[i]),f.reduce((h,g)=>{if(g)if(Ts(h)){const b=g(h,m);return b===void 0?h:b}else{if(pa(h))return SM(h,v=>g(v,m));{const v=g(h,m);if(v===void 0){if(h===null)return h;throw Error("A case reducer on a non-draftable value must not return undefined")}return v}}return h},u)}return c.getInitialState=o,c}var k9="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",D9=(e=21)=>{let t="",n=e;for(;n--;)t+=k9[Math.random()*64|0];return t},R9=Symbol.for("rtk-slice-createasyncthunk");function O9(e,t){return`${e}/${t}`}function L9({creators:e}={}){var n;const t=(n=e==null?void 0:e.asyncThunk)==null?void 0:n[R9];return function(i){const{name:o,reducerPath:c=o}=i;if(!o)throw new Error(Ar(11));const u=(typeof i.reducers=="function"?i.reducers(B9()):i.reducers)||{},m=Object.keys(u),f={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},h={addCase(M,j){const k=typeof M=="string"?M:M.type;if(!k)throw new Error(Ar(12));if(k in f.sliceCaseReducersByType)throw new Error(Ar(13));return f.sliceCaseReducersByType[k]=j,h},addMatcher(M,j){return f.sliceMatchers.push({matcher:M,reducer:j}),h},exposeAction(M,j){return f.actionCreators[M]=j,h},exposeCaseReducer(M,j){return f.sliceCaseReducersByName[M]=j,h}};m.forEach(M=>{const j=u[M],k={reducerName:M,type:O9(o,M),createNotation:typeof i.reducers=="function"};F9(j)?G9(k,j,h,t):z9(k,j,h)});function g(){const[M={},j=[],k=void 0]=typeof i.extraReducers=="function"?NM(i.extraReducers):[i.extraReducers],R={...M,...f.sliceCaseReducersByType};return I9(i.initialState,F=>{for(let q in R)F.addCase(q,R[q]);for(let q of f.sliceMatchers)F.addMatcher(q.matcher,q.reducer);for(let q of j)F.addMatcher(q.matcher,q.reducer);k&&F.addDefaultCase(k)})}const v=M=>M,b=new Map,T=new WeakMap;let C;function E(M,j){return C||(C=g()),C(M,j)}function N(){return C||(C=g()),C.getInitialState()}function I(M,j=!1){function k(F){let q=F[M];return typeof q>"u"&&j&&(q=Ff(T,k,N)),q}function R(F=v){const q=Ff(b,j,()=>new WeakMap);return Ff(q,F,()=>{const G={};for(const[H,V]of Object.entries(i.selectors??{}))G[H]=U9(V,F,()=>Ff(T,F,N),j);return G})}return{reducerPath:M,getSelectors:R,get selectors(){return R(k)},selectSlice:k}}const P={name:o,reducer:E,actions:f.actionCreators,caseReducers:f.sliceCaseReducersByName,getInitialState:N,...I(c),injectInto(M,{reducerPath:j,...k}={}){const R=j??c;return M.inject({reducerPath:R,reducer:E},k),{...P,...I(R,!0)}}};return P}}function U9(e,t,n,r){function i(o,...c){let u=t(o);return typeof u>"u"&&r&&(u=n()),e(u,...c)}return i.unwrapped=e,i}var lr=L9();function B9(){function e(t,n){return{_reducerDefinitionType:"asyncThunk",payloadCreator:t,...n}}return e.withTypes=()=>e,{reducer(t){return Object.assign({[t.name](...n){return t(...n)}}[t.name],{_reducerDefinitionType:"reducer"})},preparedReducer(t,n){return{_reducerDefinitionType:"reducerWithPrepare",prepare:t,reducer:n}},asyncThunk:e}}function z9({type:e,reducerName:t,createNotation:n},r,i){let o,c;if("reducer"in r){if(n&&!q9(r))throw new Error(Ar(17));o=r.reducer,c=r.prepare}else o=r;i.addCase(e,o).exposeCaseReducer(t,o).exposeAction(t,c?Kr(e,c):Kr(e))}function F9(e){return e._reducerDefinitionType==="asyncThunk"}function q9(e){return e._reducerDefinitionType==="reducerWithPrepare"}function G9({type:e,reducerName:t},n,r,i){if(!i)throw new Error(Ar(18));const{payloadCreator:o,fulfilled:c,pending:u,rejected:m,settled:f,options:h}=n,g=i(e,o,h);r.exposeAction(t,g),c&&r.addCase(g.fulfilled,c),u&&r.addCase(g.pending,u),m&&r.addCase(g.rejected,m),f&&r.addMatcher(g.settled,f),r.exposeCaseReducer(t,{fulfilled:c||qf,pending:u||qf,rejected:m||qf,settled:f||qf})}function qf(){}var $9="task",_M="listener",jM="completed",eb="cancelled",H9=`task-${eb}`,V9=`task-${jM}`,jv=`${_M}-${eb}`,K9=`${_M}-${jM}`,vh=class{constructor(e){f0(this,"name","TaskAbortError");f0(this,"message");this.code=e,this.message=`${$9} ${eb} (reason: ${e})`}},tb=(e,t)=>{if(typeof e!="function")throw new TypeError(Ar(32))},Sm=()=>{},MM=(e,t=Sm)=>(e.catch(t),e),PM=(e,t)=>(e.addEventListener("abort",t,{once:!0}),()=>e.removeEventListener("abort",t)),vs=(e,t)=>{const n=e.signal;n.aborted||("reason"in n||Object.defineProperty(n,"reason",{enumerable:!0,value:t,configurable:!0,writable:!0}),e.abort(t))},xs=e=>{if(e.aborted){const{reason:t}=e;throw new vh(t)}};function IM(e,t){let n=Sm;return new Promise((r,i)=>{const o=()=>i(new vh(e.reason));if(e.aborted){o();return}n=PM(e,o),t.finally(()=>n()).then(r,i)}).finally(()=>{n=Sm})}var Y9=async(e,t)=>{try{return await Promise.resolve(),{status:"ok",value:await e()}}catch(n){return{status:n instanceof vh?"cancelled":"rejected",error:n}}finally{t==null||t()}},Am=e=>t=>MM(IM(e,t).then(n=>(xs(e),n))),kM=e=>{const t=Am(e);return n=>t(new Promise(r=>setTimeout(r,n)))},{assign:Rl}=Object,wE={},xh="listenerMiddleware",W9=(e,t)=>{const n=r=>PM(e,()=>vs(r,e.reason));return(r,i)=>{tb(r);const o=new AbortController;n(o);const c=Y9(async()=>{xs(e),xs(o.signal);const u=await r({pause:Am(o.signal),delay:kM(o.signal),signal:o.signal});return xs(o.signal),u},()=>vs(o,V9));return i!=null&&i.autoJoin&&t.push(c.catch(Sm)),{result:Am(e)(c),cancel(){vs(o,H9)}}}},J9=(e,t)=>{const n=async(r,i)=>{xs(t);let o=()=>{};const u=[new Promise((m,f)=>{let h=e({predicate:r,effect:(g,v)=>{v.unsubscribe(),m([g,v.getState(),v.getOriginalState()])}});o=()=>{h(),f()}})];i!=null&&u.push(new Promise(m=>setTimeout(m,i,null)));try{const m=await IM(t,Promise.race(u));return xs(t),m}finally{o()}};return(r,i)=>MM(n(r,i))},DM=e=>{let{type:t,actionCreator:n,matcher:r,predicate:i,effect:o}=e;if(t)i=Kr(t).match;else if(n)t=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(Ar(21));return tb(o),{predicate:i,type:t,effect:o}},RM=Rl(e=>{const{type:t,predicate:n,effect:r}=DM(e);return{id:D9(),effect:r,type:t,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(Ar(22))}}},{withTypes:()=>RM}),SE=(e,t)=>{const{type:n,effect:r,predicate:i}=DM(t);return Array.from(e.values()).find(o=>(typeof n=="string"?o.type===n:o.predicate===i)&&o.effect===r)},Mv=e=>{e.pending.forEach(t=>{vs(t,jv)})},Q9=(e,t)=>()=>{for(const n of t.keys())Mv(n);e.clear()},AE=(e,t,n)=>{try{e(t,n)}catch(r){setTimeout(()=>{throw r},0)}},OM=Rl(Kr(`${xh}/add`),{withTypes:()=>OM}),X9=Kr(`${xh}/removeAll`),LM=Rl(Kr(`${xh}/remove`),{withTypes:()=>LM}),Z9=(...e)=>{console.error(`${xh}/error`,...e)},Zu=(e={})=>{const t=new Map,n=new Map,r=b=>{const T=n.get(b)??0;n.set(b,T+1)},i=b=>{const T=n.get(b)??1;T===1?n.delete(b):n.set(b,T-1)},{extra:o,onError:c=Z9}=e;tb(c);const u=b=>(b.unsubscribe=()=>t.delete(b.id),t.set(b.id,b),T=>{b.unsubscribe(),T!=null&&T.cancelActive&&Mv(b)}),m=b=>{const T=SE(t,b)??RM(b);return u(T)};Rl(m,{withTypes:()=>m});const f=b=>{const T=SE(t,b);return T&&(T.unsubscribe(),b.cancelActive&&Mv(T)),!!T};Rl(f,{withTypes:()=>f});const h=async(b,T,C,E)=>{const N=new AbortController,I=J9(m,N.signal),P=[];try{b.pending.add(N),r(b),await Promise.resolve(b.effect(T,Rl({},C,{getOriginalState:E,condition:(M,j)=>I(M,j).then(Boolean),take:I,delay:kM(N.signal),pause:Am(N.signal),extra:o,signal:N.signal,fork:W9(N.signal,P),unsubscribe:b.unsubscribe,subscribe:()=>{t.set(b.id,b)},cancelActiveListeners:()=>{b.pending.forEach((M,j,k)=>{M!==N&&(vs(M,jv),k.delete(M))})},cancel:()=>{vs(N,jv),b.pending.delete(N)},throwIfCancelled:()=>{xs(N.signal)}})))}catch(M){M instanceof vh||AE(c,M,{raisedBy:"effect"})}finally{await Promise.all(P),vs(N,K9),i(b),b.pending.delete(N)}},g=Q9(t,n);return{middleware:b=>T=>C=>{if(!pM(C))return T(C);if(OM.match(C))return m(C.payload);if(X9.match(C)){g();return}if(LM.match(C))return f(C.payload);let E=b.getState();const N=()=>{if(E===wE)throw new Error(Ar(23));return E};let I;try{if(I=T(C),t.size>0){const P=b.getState(),M=Array.from(t.values());for(const j of M){let k=!1;try{k=j.predicate(C,P,E)}catch(R){k=!1,AE(c,R,{raisedBy:"predicate"})}k&&h(j,C,b,N)}}}finally{E=wE}return I},startListening:m,stopListening:f,clearListeners:g}};function Ar(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var eq={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},UM=lr({name:"chartLayout",initialState:eq,reducers:{setLayout(e,t){e.layoutType=t.payload},setChartSize(e,t){e.width=t.payload.width,e.height=t.payload.height},setMargin(e,t){var n,r,i,o;e.margin.top=(n=t.payload.top)!==null&&n!==void 0?n:0,e.margin.right=(r=t.payload.right)!==null&&r!==void 0?r:0,e.margin.bottom=(i=t.payload.bottom)!==null&&i!==void 0?i:0,e.margin.left=(o=t.payload.left)!==null&&o!==void 0?o:0},setScale(e,t){e.scale=t.payload}}}),{setMargin:tq,setLayout:nq,setChartSize:rq,setScale:iq}=UM.actions,aq=UM.reducer;function BM(e,t,n){return Array.isArray(e)&&e&&t+n!==0?e.slice(t,n+1):e}function CE(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function _l(e){for(var t=1;t{if(t&&n){var{width:r,height:i}=n,{align:o,verticalAlign:c,layout:u}=t;if((u==="vertical"||u==="horizontal"&&c==="middle")&&o!=="center"&&we(e[o]))return _l(_l({},e),{},{[o]:e[o]+(r||0)});if((u==="horizontal"||u==="vertical"&&o==="center")&&c!=="middle"&&we(e[c]))return _l(_l({},e),{},{[c]:e[c]+(i||0)})}return e},Mi=(e,t)=>e==="horizontal"&&t==="xAxis"||e==="vertical"&&t==="yAxis"||e==="centric"&&t==="angleAxis"||e==="radial"&&t==="radiusAxis",zM=(e,t,n,r)=>{if(r)return e.map(u=>u.coordinate);var i,o,c=e.map(u=>(u.coordinate===t&&(i=!0),u.coordinate===n&&(o=!0),u.coordinate));return i||c.push(t),o||c.push(n),c},FM=(e,t,n)=>{if(!e)return null;var{duplicateDomain:r,type:i,range:o,scale:c,realScaleType:u,isCategorical:m,categoricalDomain:f,tickCount:h,ticks:g,niceTicks:v,axisType:b}=e;if(!c)return null;var T=u==="scaleBand"&&c.bandwidth?c.bandwidth()/2:2,C=i==="category"&&c.bandwidth?c.bandwidth()/T:0;if(C=b==="angleAxis"&&o&&o.length>=2?bn(o[0]-o[1])*2*C:C,g||v){var E=(g||v||[]).map((N,I)=>{var P=r?r.indexOf(N):N;return{coordinate:c(P)+C,value:N,offset:C,index:I}});return E.filter(N=>!sr(N.coordinate))}return m&&f?f.map((N,I)=>({coordinate:c(N)+C,value:N,index:I,offset:C})):c.ticks&&h!=null?c.ticks(h).map((N,I)=>({coordinate:c(N)+C,value:N,offset:C,index:I})):c.domain().map((N,I)=>({coordinate:c(N)+C,value:r?r[N]:N,index:I,offset:C}))},TE=1e-4,uq=e=>{var t=e.domain();if(!(!t||t.length<=2)){var n=t.length,r=e.range(),i=Math.min(r[0],r[1])-TE,o=Math.max(r[0],r[1])+TE,c=e(t[0]),u=e(t[n-1]);(co||uo)&&e.domain([t[0],t[n-1]])}},dq=(e,t)=>{if(!t||t.length!==2||!we(t[0])||!we(t[1]))return e;var n=Math.min(t[0],t[1]),r=Math.max(t[0],t[1]),i=[e[0],e[1]];return(!we(e[0])||e[0]r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]{var t=e.length;if(!(t<=0))for(var n=0,r=e[0].length;n=0?(e[c][n][0]=i,e[c][n][1]=i+u,i=e[c][n][1]):(e[c][n][0]=o,e[c][n][1]=o+u,o=e[c][n][1])}},mq=e=>{var t=e.length;if(!(t<=0))for(var n=0,r=e[0].length;n=0?(e[o][n][0]=i,e[o][n][1]=i+c,i=e[o][n][1]):(e[o][n][0]=0,e[o][n][1]=0)}},hq={sign:fq,expand:Uz,none:Jl,silhouette:Bz,wiggle:zz,positive:mq},pq=(e,t,n)=>{var r=hq[n],i=Lz().keys(t).value((o,c)=>Number(gt(o,c,0))).order(bv).offset(r);return i(e)};function qM(e){return e==null?void 0:String(e)}function Cm(e){var{axis:t,ticks:n,bandSize:r,entry:i,index:o,dataKey:c}=e;if(t.type==="category"){if(!t.allowDuplicatedCategory&&t.dataKey&&!jt(i[t.dataKey])){var u=W3(n,"value",i[t.dataKey]);if(u)return u.coordinate+r/2}return n[o]?n[o].coordinate+r/2:null}var m=gt(i,jt(c)?t.dataKey:c);return jt(m)?null:t.scale(m)}var EE=e=>{var{axis:t,ticks:n,offset:r,bandSize:i,entry:o,index:c}=e;if(t.type==="category")return n[c]?n[c].coordinate+r:null;var u=gt(o,t.dataKey,t.scale.domain()[c]);return jt(u)?null:t.scale(u)-i/2+r},gq=e=>{var{numericAxis:t}=e,n=t.scale.domain();if(t.type==="number"){var r=Math.min(n[0],n[1]),i=Math.max(n[0],n[1]);return r<=0&&i>=0?0:i<0?i:r}return n[0]},yq=e=>{var t=e.flat(2).filter(we);return[Math.min(...t),Math.max(...t)]},vq=e=>[e[0]===1/0?0:e[0],e[1]===-1/0?0:e[1]],xq=(e,t,n)=>{if(e!=null)return vq(Object.keys(e).reduce((r,i)=>{var o=e[i],{stackedData:c}=o,u=c.reduce((m,f)=>{var h=BM(f,t,n),g=yq(h);return[Math.min(m[0],g[0]),Math.max(m[1],g[1])]},[1/0,-1/0]);return[Math.min(u[0],r[0]),Math.max(u[1],r[1])]},[1/0,-1/0]))},NE=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,_E=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,So=(e,t,n)=>{if(e&&e.scale&&e.scale.bandwidth){var r=e.scale.bandwidth();if(!n||r>0)return r}if(e&&t&&t.length>=2){for(var i=hh(t,h=>h.coordinate),o=1/0,c=1,u=i.length;c{if(t==="horizontal")return e.chartX;if(t==="vertical")return e.chartY},wq=(e,t)=>t==="centric"?e.angle:e.radius,Ca=e=>e.layout.width,Ta=e=>e.layout.height,Sq=e=>e.layout.scale,GM=e=>e.layout.margin,bh=J(e=>e.cartesianAxis.xAxis,e=>Object.values(e)),wh=J(e=>e.cartesianAxis.yAxis,e=>Object.values(e)),$M="data-recharts-item-index",HM="data-recharts-item-data-key",ed=60;function ME(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Gf(e){for(var t=1;te.brush.height;function Nq(e){var t=wh(e);return t.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:ed;return n+i}return n},0)}function _q(e){var t=wh(e);return t.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:ed;return n+i}return n},0)}function jq(e){var t=bh(e);return t.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function Mq(e){var t=bh(e);return t.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var fn=J([Ca,Ta,GM,Eq,Nq,_q,jq,Mq,dM,o9],(e,t,n,r,i,o,c,u,m,f)=>{var h={left:(n.left||0)+i,right:(n.right||0)+o},g={top:(n.top||0)+c,bottom:(n.bottom||0)+u},v=Gf(Gf({},g),h),b=v.bottom;v.bottom+=r,v=cq(v,m,f);var T=e-v.left-v.right,C=t-v.top-v.bottom;return Gf(Gf({brushBottom:b},v),{},{width:Math.max(T,0),height:Math.max(C,0)})}),Pq=J(fn,e=>({x:e.left,y:e.top,width:e.width,height:e.height})),nb=J(Ca,Ta,(e,t)=>({x:0,y:0,width:e,height:t})),Iq=S.createContext(null),mn=()=>S.useContext(Iq)!=null,Sh=e=>e.brush,Ah=J([Sh,fn,GM],(e,t,n)=>({height:e.height,x:we(e.x)?e.x:t.left,y:we(e.y)?e.y:t.top+t.height+t.brushBottom-((n==null?void 0:n.bottom)||0),width:we(e.width)?e.width:t.width})),xy={},by={},wy={},PE;function kq(){return PE||(PE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n,r,{signal:i,edges:o}={}){let c,u=null;const m=o!=null&&o.includes("leading"),f=o==null||o.includes("trailing"),h=()=>{u!==null&&(n.apply(c,u),c=void 0,u=null)},g=()=>{f&&h(),C()};let v=null;const b=()=>{v!=null&&clearTimeout(v),v=setTimeout(()=>{v=null,g()},r)},T=()=>{v!==null&&(clearTimeout(v),v=null)},C=()=>{T(),c=void 0,u=null},E=()=>{h()},N=function(...I){if(i!=null&&i.aborted)return;c=this,u=I;const P=v==null;b(),m&&P&&h()};return N.schedule=b,N.cancel=C,N.flush=E,i==null||i.addEventListener("abort",C,{once:!0}),N}e.debounce=t})(wy)),wy}var IE;function Dq(){return IE||(IE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=kq();function n(r,i=0,o={}){typeof o!="object"&&(o={});const{leading:c=!1,trailing:u=!0,maxWait:m}=o,f=Array(2);c&&(f[0]="leading"),u&&(f[1]="trailing");let h,g=null;const v=t.debounce(function(...C){h=r.apply(this,C),g=null},i,{edges:f}),b=function(...C){return m!=null&&(g===null&&(g=Date.now()),Date.now()-g>=m)?(h=r.apply(this,C),g=Date.now(),v.cancel(),v.schedule(),h):(v.apply(this,C),h)},T=()=>(v.flush(),h);return b.cancel=v.cancel,b.flush=T,b}e.debounce=n})(by)),by}var kE;function Rq(){return kE||(kE=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=Dq();function n(r,i=0,o={}){const{leading:c=!0,trailing:u=!0}=o;return t.debounce(r,i,{leading:c,maxWait:i,trailing:u})}e.throttle=n})(xy)),xy}var Sy,DE;function Oq(){return DE||(DE=1,Sy=Rq().throttle),Sy}var Lq=Oq();const Uq=ji(Lq);var Tm=function(t,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),o=2;o{var{width:r="100%",height:i="100%",aspect:o,maxHeight:c}=n,u=ha(r)?e:Number(r),m=ha(i)?t:Number(i);return o&&o>0&&(u?m=u/o:m&&(u=m*o),c&&m!=null&&m>c&&(m=c)),{calculatedWidth:u,calculatedHeight:m}},Bq={width:0,height:0,overflow:"visible"},zq={width:0,overflowX:"visible"},Fq={height:0,overflowY:"visible"},qq={},Gq=e=>{var{width:t,height:n}=e,r=ha(t),i=ha(n);return r&&i?Bq:r?zq:i?Fq:qq};function $q(e){var{width:t,height:n,aspect:r}=e,i=t,o=n;return i===void 0&&o===void 0?(i="100%",o="100%"):i===void 0?i=r&&r>0?void 0:"100%":o===void 0&&(o=r&&r>0?void 0:"100%"),{width:i,height:o}}function dt(e){return Number.isFinite(e)}function Ti(e){return typeof e=="number"&&e>0&&Number.isFinite(e)}function Pv(){return Pv=Object.assign?Object.assign.bind():function(e){for(var t=1;t({width:n,height:r}),[n,r]);return Yq(i)?S.createElement(KM.Provider,{value:i},t):null}var rb=()=>S.useContext(KM),Wq=S.forwardRef((e,t)=>{var{aspect:n,initialDimension:r={width:-1,height:-1},width:i,height:o,minWidth:c=0,minHeight:u,maxHeight:m,children:f,debounce:h=0,id:g,className:v,onResize:b,style:T={}}=e,C=S.useRef(null),E=S.useRef();E.current=b,S.useImperativeHandle(t,()=>C.current);var[N,I]=S.useState({containerWidth:r.width,containerHeight:r.height}),P=S.useCallback((F,q)=>{I(G=>{var H=Math.round(F),V=Math.round(q);return G.containerWidth===H&&G.containerHeight===V?G:{containerWidth:H,containerHeight:V}})},[]);S.useEffect(()=>{if(C.current==null||typeof ResizeObserver>"u")return Ds;var F=V=>{var oe,{width:Z,height:me}=V[0].contentRect;P(Z,me),(oe=E.current)===null||oe===void 0||oe.call(E,Z,me)};h>0&&(F=Uq(F,h,{trailing:!0,leading:!1}));var q=new ResizeObserver(F),{width:G,height:H}=C.current.getBoundingClientRect();return P(G,H),q.observe(C.current),()=>{q.disconnect()}},[P,h]);var{containerWidth:M,containerHeight:j}=N;Tm(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:k,calculatedHeight:R}=VM(M,j,{width:i,height:o,aspect:n,maxHeight:m});return Tm(k!=null&&k>0||R!=null&&R>0,`The width(%s) and height(%s) of chart should be greater than 0, + please check the style of container, or the props width(%s) and height(%s), + or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the + height and width.`,k,R,i,o,c,u,n),S.createElement("div",{id:g?"".concat(g):void 0,className:Xe("recharts-responsive-container",v),style:OE(OE({},T),{},{width:i,height:o,minWidth:c,minHeight:u,maxHeight:m}),ref:C},S.createElement("div",{style:Gq({width:i,height:o})},S.createElement(YM,{width:k,height:R},f)))}),Pn=S.forwardRef((e,t)=>{var n=rb();if(Ti(n.width)&&Ti(n.height))return e.children;var{width:r,height:i}=$q({width:e.width,height:e.height,aspect:e.aspect}),{calculatedWidth:o,calculatedHeight:c}=VM(void 0,void 0,{width:r,height:i,aspect:e.aspect,maxHeight:e.maxHeight});return we(o)&&we(c)?S.createElement(YM,{width:o,height:c},e.children):S.createElement(Wq,Pv({},e,{width:r,height:i,ref:t}))});function WM(e){if(e)return{x:e.x,y:e.y,upperWidth:"upperWidth"in e?e.upperWidth:e.width,lowerWidth:"lowerWidth"in e?e.lowerWidth:e.width,width:e.width,height:e.height}}var td=()=>{var e,t=mn(),n=Se(Pq),r=Se(Ah),i=(e=Se(Sh))===null||e===void 0?void 0:e.padding;return!t||!r||!i?n:{width:r.width-i.left-i.right,height:r.height-i.top-i.bottom,x:i.left,y:i.top}},Jq={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},JM=()=>{var e;return(e=Se(fn))!==null&&e!==void 0?e:Jq},ib=()=>Se(Ca),ab=()=>Se(Ta),Qq=()=>Se(e=>e.layout.margin),Ke=e=>e.layout.layoutType,oc=()=>Se(Ke),Xq=()=>{var e=oc();return e!==void 0},Ch=e=>{var t=bt(),n=mn(),{width:r,height:i}=e,o=rb(),c=r,u=i;return o&&(c=o.width>0?o.width:r,u=o.height>0?o.height:i),S.useEffect(()=>{!n&&Ti(c)&&Ti(u)&&t(rq({width:c,height:u}))},[t,n,c,u]),null},Zq={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},QM=lr({name:"legend",initialState:Zq,reducers:{setLegendSize(e,t){e.size.width=t.payload.width,e.size.height=t.payload.height},setLegendSettings(e,t){e.settings.align=t.payload.align,e.settings.layout=t.payload.layout,e.settings.verticalAlign=t.payload.verticalAlign,e.settings.itemSorter=t.payload.itemSorter},addLegendPayload:{reducer(e,t){e.payload.push(t.payload)},prepare:un()},removeLegendPayload:{reducer(e,t){var n=ca(e).payload.indexOf(t.payload);n>-1&&e.payload.splice(n,1)},prepare:un()}}}),{setLegendSize:LE,setLegendSettings:eG,addLegendPayload:XM,removeLegendPayload:ZM}=QM.actions,tG=QM.reducer,nG=["contextPayload"];function Iv(){return Iv=Object.assign?Object.assign.bind():function(e){for(var t=1;t{t(eG(e))},[t,e]),null}function fG(e){var t=bt();return S.useEffect(()=>(t(LE(e)),()=>{t(LE({width:0,height:0}))}),[t,e]),null}function mG(e,t,n,r){return e==="vertical"&&we(t)?{height:t}:e==="horizontal"?{width:n||r}:null}var hG={align:"center",iconSize:14,itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function Rn(e){var t=Lt(e,hG),n=c9(),r=sz(),i=Qq(),{width:o,height:c,wrapperStyle:u,portal:m}=t,[f,h]=fM([n]),g=ib(),v=ab();if(g==null||v==null)return null;var b=g-((i==null?void 0:i.left)||0)-((i==null?void 0:i.right)||0),T=mG(t.layout,c,o,b),C=m?u:Ql(Ql({position:"absolute",width:(T==null?void 0:T.width)||o||"auto",height:(T==null?void 0:T.height)||c||"auto"},uG(u,t,i,g,v,f)),u),E=m??r;if(E==null||n==null)return null;var N=S.createElement("div",{className:"recharts-legend-wrapper",style:C,ref:h},S.createElement(dG,{layout:t.layout,align:t.align,verticalAlign:t.verticalAlign,itemSorter:t.itemSorter}),S.createElement(fG,{width:f.width,height:f.height}),S.createElement(cG,Iv({},t,T,{margin:i,chartWidth:g,chartHeight:v,contextPayload:n})));return zx.createPortal(N,E)}Rn.displayName="Legend";function kv(){return kv=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{separator:t=" : ",contentStyle:n={},itemStyle:r={},labelStyle:i={},payload:o,formatter:c,itemSorter:u,wrapperClassName:m,labelClassName:f,label:h,labelFormatter:g,accessibilityLayer:v=!1}=e,b=()=>{if(o&&o.length){var j={padding:0,margin:0},k=(u?hh(o,u):o).map((R,F)=>{if(R.type==="none")return null;var q=R.formatter||c||vG,{value:G,name:H}=R,V=G,oe=H;if(q){var Z=q(G,H,R,F,o);if(Array.isArray(Z))[V,oe]=Z;else if(Z!=null)V=Z;else return null}var me=Ay({display:"block",paddingTop:4,paddingBottom:4,color:R.color||"#000"},r);return S.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(F),style:me},Vr(oe)?S.createElement("span",{className:"recharts-tooltip-item-name"},oe):null,Vr(oe)?S.createElement("span",{className:"recharts-tooltip-item-separator"},t):null,S.createElement("span",{className:"recharts-tooltip-item-value"},V),S.createElement("span",{className:"recharts-tooltip-item-unit"},R.unit||""))});return S.createElement("ul",{className:"recharts-tooltip-item-list",style:j},k)}return null},T=Ay({margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},n),C=Ay({margin:0},i),E=!jt(h),N=E?h:"",I=Xe("recharts-default-tooltip",m),P=Xe("recharts-tooltip-label",f);E&&g&&o!==void 0&&o!==null&&(N=g(h,o));var M=v?{role:"status","aria-live":"assertive"}:{};return S.createElement("div",kv({className:I,style:T},M),S.createElement("p",{className:P,style:C},S.isValidElement(N)?N:"".concat(N)),b())},gu="recharts-tooltip-wrapper",bG={visibility:"hidden"};function wG(e){var{coordinate:t,translateX:n,translateY:r}=e;return Xe(gu,{["".concat(gu,"-right")]:we(n)&&t&&we(t.x)&&n>=t.x,["".concat(gu,"-left")]:we(n)&&t&&we(t.x)&&n=t.y,["".concat(gu,"-top")]:we(r)&&t&&we(t.y)&&r0?i:0),g=n[r]+i;if(t[r])return c[r]?h:g;var v=m[r];if(v==null)return 0;if(c[r]){var b=h,T=v;return bE?Math.max(h,v):Math.max(g,v)}function SG(e){var{translateX:t,translateY:n,useTranslate3d:r}=e;return{transform:r?"translate3d(".concat(t,"px, ").concat(n,"px, 0)"):"translate(".concat(t,"px, ").concat(n,"px)")}}function AG(e){var{allowEscapeViewBox:t,coordinate:n,offsetTopLeft:r,position:i,reverseDirection:o,tooltipBox:c,useTranslate3d:u,viewBox:m}=e,f,h,g;return c.height>0&&c.width>0&&n?(h=zE({allowEscapeViewBox:t,coordinate:n,key:"x",offsetTopLeft:r,position:i,reverseDirection:o,tooltipDimension:c.width,viewBox:m,viewBoxDimension:m.width}),g=zE({allowEscapeViewBox:t,coordinate:n,key:"y",offsetTopLeft:r,position:i,reverseDirection:o,tooltipDimension:c.height,viewBox:m,viewBoxDimension:m.height}),f=SG({translateX:h,translateY:g,useTranslate3d:u})):f=bG,{cssProperties:f,cssClasses:wG({translateX:h,translateY:g,coordinate:n})}}function FE(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function $f(e){for(var t=1;t{if(t.key==="Escape"){var n,r,i,o;this.setState({dismissed:!0,dismissedAtCoordinate:{x:(n=(r=this.props.coordinate)===null||r===void 0?void 0:r.x)!==null&&n!==void 0?n:0,y:(i=(o=this.props.coordinate)===null||o===void 0?void 0:o.y)!==null&&i!==void 0?i:0}})}})}componentDidMount(){document.addEventListener("keydown",this.handleKeyDown)}componentWillUnmount(){document.removeEventListener("keydown",this.handleKeyDown)}componentDidUpdate(){var t,n;this.state.dismissed&&(((t=this.props.coordinate)===null||t===void 0?void 0:t.x)!==this.state.dismissedAtCoordinate.x||((n=this.props.coordinate)===null||n===void 0?void 0:n.y)!==this.state.dismissedAtCoordinate.y)&&(this.state.dismissed=!1)}render(){var{active:t,allowEscapeViewBox:n,animationDuration:r,animationEasing:i,children:o,coordinate:c,hasPayload:u,isAnimationActive:m,offset:f,position:h,reverseDirection:g,useTranslate3d:v,viewBox:b,wrapperStyle:T,lastBoundingBox:C,innerRef:E,hasPortalFromProps:N}=this.props,{cssClasses:I,cssProperties:P}=AG({allowEscapeViewBox:n,coordinate:c,offsetTopLeft:f,position:h,reverseDirection:g,tooltipBox:{height:C.height,width:C.width},useTranslate3d:v,viewBox:b}),M=N?{}:$f($f({transition:m&&t?"transform ".concat(r,"ms ").concat(i):void 0},P),{},{pointerEvents:"none",visibility:!this.state.dismissed&&t&&u?"visible":"hidden",position:"absolute",top:0,left:0}),j=$f($f({},M),{},{visibility:!this.state.dismissed&&t&&u?"visible":"hidden"},T);return S.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:I,style:j,ref:E},o)}}var NG=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),Ea={devToolsEnabled:!1,isSsr:NG()},e4=()=>{var e;return(e=Se(t=>t.rootProps.accessibilityLayer))!==null&&e!==void 0?e:!0};function Rv(){return Rv=Object.assign?Object.assign.bind():function(e){for(var t=1;tdt(e.x)&&dt(e.y),HE=e=>e.base!=null&&Em(e.base)&&Em(e),yu=e=>e.x,vu=e=>e.y,PG=(e,t)=>{if(typeof e=="function")return e;var n="curve".concat(Ju(e));return(n==="curveMonotone"||n==="curveBump")&&t?$E["".concat(n).concat(t==="vertical"?"Y":"X")]:$E[n]||fh},IG=e=>{var{type:t="linear",points:n=[],baseLine:r,layout:i,connectNulls:o=!1}=e,c=PG(t,i),u=o?n.filter(Em):n,m;if(Array.isArray(r)){var f=n.map((b,T)=>GE(GE({},b),{},{base:r[T]}));i==="vertical"?m=Lf().y(vu).x1(yu).x0(b=>b.base.x):m=Lf().x(yu).y1(vu).y0(b=>b.base.y);var h=m.defined(HE).curve(c),g=o?f.filter(HE):f;return h(g)}i==="vertical"&&we(r)?m=Lf().y(vu).x1(yu).x0(r):we(r)?m=Lf().x(yu).y1(vu).y0(r):m=O3().x(yu).y(vu);var v=m.defined(Em).curve(c);return v(u)},Ol=e=>{var{className:t,points:n,path:r,pathRef:i}=e;if((!n||!n.length)&&!r)return null;var o=n&&n.length?IG(e):r;return S.createElement("path",Rv({},Kn(e),Yx(e),{className:Xe("recharts-curve",t),d:o===null?void 0:o,ref:i}))},kG=["x","y","top","left","width","height","className"];function Ov(){return Ov=Object.assign?Object.assign.bind():function(e){for(var t=1;t"M".concat(e,",").concat(i,"v").concat(r,"M").concat(o,",").concat(t,"h").concat(n),FG=e=>{var{x:t=0,y:n=0,top:r=0,left:i=0,width:o=0,height:c=0,className:u}=e,m=UG(e,kG),f=DG({x:t,y:n,top:r,left:i,width:o,height:c},m);return!we(t)||!we(n)||!we(o)||!we(c)||!we(r)||!we(i)?null:S.createElement("path",Ov({},Mn(f),{className:Xe("recharts-cross",u),d:zG(t,n,o,c,r,i)}))};function qG(e,t,n,r){var i=r/2;return{stroke:"none",fill:"#ccc",x:e==="horizontal"?t.x-i:n.left+.5,y:e==="horizontal"?n.top+.5:t.y-i,width:e==="horizontal"?r:n.width-1,height:e==="horizontal"?n.height-1:r}}function KE(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function YE(e){for(var t=1;te.replace(/([A-Z])/g,t=>"-".concat(t.toLowerCase())),t4=(e,t,n)=>e.map(r=>"".concat(VG(r)," ").concat(t,"ms ").concat(n)).join(","),KG=(e,t)=>[Object.keys(e),Object.keys(t)].reduce((n,r)=>n.filter(i=>r.includes(i))),Ru=(e,t)=>Object.keys(t).reduce((n,r)=>YE(YE({},n),{},{[r]:e(r,t[r])}),{});function WE(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function cn(e){for(var t=1;te+(t-e)*n,Lv=e=>{var{from:t,to:n}=e;return t!==n},n4=(e,t,n)=>{var r=Ru((i,o)=>{if(Lv(o)){var[c,u]=e(o.from,o.to,o.velocity);return cn(cn({},o),{},{from:c,velocity:u})}return o},t);return n<1?Ru((i,o)=>Lv(o)?cn(cn({},o),{},{velocity:Nm(o.velocity,r[i].velocity,n),from:Nm(o.from,r[i].from,n)}):o,t):n4(e,r,n-1)};function QG(e,t,n,r,i,o){var c,u=r.reduce((v,b)=>cn(cn({},v),{},{[b]:{from:e[b],velocity:0,to:t[b]}}),{}),m=()=>Ru((v,b)=>b.from,u),f=()=>!Object.values(u).filter(Lv).length,h=null,g=v=>{c||(c=v);var b=v-c,T=b/n.dt;u=n4(n,u,T),i(cn(cn(cn({},e),t),m())),c=v,f()||(h=o.setTimeout(g))};return()=>(h=o.setTimeout(g),()=>{var v;(v=h)===null||v===void 0||v()})}function XG(e,t,n,r,i,o,c){var u=null,m=i.reduce((g,v)=>cn(cn({},g),{},{[v]:[e[v],t[v]]}),{}),f,h=g=>{f||(f=g);var v=(g-f)/r,b=Ru((C,E)=>Nm(...E,n(v)),m);if(o(cn(cn(cn({},e),t),b)),v<1)u=c.setTimeout(h);else{var T=Ru((C,E)=>Nm(...E,n(1)),m);o(cn(cn(cn({},e),t),T))}};return()=>(u=c.setTimeout(h),()=>{var g;(g=u)===null||g===void 0||g()})}const ZG=(e,t,n,r,i,o)=>{var c=KG(e,t);return n==null?()=>(i(cn(cn({},e),t)),()=>{}):n.isStepper===!0?QG(e,t,n,c,i,o):XG(e,t,n,r,c,i,o)};var _m=1e-4,r4=(e,t)=>[0,3*e,3*t-6*e,3*e-3*t+1],i4=(e,t)=>e.map((n,r)=>n*t**r).reduce((n,r)=>n+r),JE=(e,t)=>n=>{var r=r4(e,t);return i4(r,n)},e$=(e,t)=>n=>{var r=r4(e,t),i=[...r.map((o,c)=>o*c).slice(1),0];return i4(i,n)},t$=function(){for(var t=arguments.length,n=new Array(t),r=0;rparseFloat(u));return[c[0],c[1],c[2],c[3]]}}}return n.length===4?n:[0,0,1,1]},n$=(e,t,n,r)=>{var i=JE(e,n),o=JE(t,r),c=e$(e,n),u=f=>f>1?1:f<0?0:f,m=f=>{for(var h=f>1?1:f,g=h,v=0;v<8;++v){var b=i(g)-h,T=c(g);if(Math.abs(b-h)<_m||T<_m)return o(g);g=u(g-b/T)}return o(g)};return m.isStepper=!1,m},QE=function(){return n$(...t$(...arguments))},r$=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{stiff:n=100,damping:r=8,dt:i=17}=t,o=(c,u,m)=>{var f=-(c-u)*n,h=m*r,g=m+(f-h)*i/1e3,v=m*i/1e3+c;return Math.abs(v-u)<_m&&Math.abs(g)<_m?[u,0]:[v,g]};return o.isStepper=!0,o.dt=i,o},i$=e=>{if(typeof e=="string")switch(e){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return QE(e);case"spring":return r$();default:if(e.split("(")[0]==="cubic-bezier")return QE(e)}return typeof e=="function"?e:null};function a$(e){var t,n=()=>null,r=!1,i=null,o=c=>{if(!r){if(Array.isArray(c)){if(!c.length)return;var u=c,[m,...f]=u;if(typeof m=="number"){i=e.setTimeout(o.bind(null,f),m);return}o(m),i=e.setTimeout(o.bind(null,f));return}typeof c=="string"&&(t=c,n(t)),typeof c=="object"&&(t=c,n(t)),typeof c=="function"&&c()}};return{stop:()=>{r=!0},start:c=>{r=!1,i&&(i(),i=null),o(c)},subscribe:c=>(n=c,()=>{n=()=>null}),getTimeoutController:()=>e}}class o${setTimeout(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=performance.now(),i=null,o=c=>{c-r>=n?t(c):typeof requestAnimationFrame=="function"&&(i=requestAnimationFrame(o))};return i=requestAnimationFrame(o),()=>{i!=null&&cancelAnimationFrame(i)}}}function s$(){return a$(new o$)}var l$=S.createContext(s$);function c$(e,t){var n=S.useContext(l$);return S.useMemo(()=>t??n(e),[e,t,n])}var u$={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},XE={t:0},Cy={t:1};function sc(e){var t=Lt(e,u$),{isActive:n,canBegin:r,duration:i,easing:o,begin:c,onAnimationEnd:u,onAnimationStart:m,children:f}=t,h=c$(t.animationId,t.animationManager),[g,v]=S.useState(n?XE:Cy),b=S.useRef(null);return S.useEffect(()=>{n||v(Cy)},[n]),S.useEffect(()=>{if(!n||!r)return Ds;var T=ZG(XE,Cy,i$(o),i,v,h.getTimeoutController()),C=()=>{b.current=T()};return h.start([m,c,C,i,u]),()=>{h.stop(),b.current&&b.current(),u()}},[n,r,i,o,c,m,u,h]),f(g.t)}function lc(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=S.useRef(Pu(t)),r=S.useRef(e);return r.current!==e&&(n.current=Pu(t),r.current=e),n.current}var d$=["radius"],f$=["radius"];function ZE(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function eN(e){for(var t=1;t{var o=Math.min(Math.abs(n)/2,Math.abs(r)/2),c=r>=0?1:-1,u=n>=0?1:-1,m=r>=0&&n>=0||r<0&&n<0?1:0,f;if(o>0&&i instanceof Array){for(var h=[0,0,0,0],g=0,v=4;go?o:i[g];f="M".concat(e,",").concat(t+c*h[0]),h[0]>0&&(f+="A ".concat(h[0],",").concat(h[0],",0,0,").concat(m,",").concat(e+u*h[0],",").concat(t)),f+="L ".concat(e+n-u*h[1],",").concat(t),h[1]>0&&(f+="A ".concat(h[1],",").concat(h[1],",0,0,").concat(m,`, + `).concat(e+n,",").concat(t+c*h[1])),f+="L ".concat(e+n,",").concat(t+r-c*h[2]),h[2]>0&&(f+="A ".concat(h[2],",").concat(h[2],",0,0,").concat(m,`, + `).concat(e+n-u*h[2],",").concat(t+r)),f+="L ".concat(e+u*h[3],",").concat(t+r),h[3]>0&&(f+="A ".concat(h[3],",").concat(h[3],",0,0,").concat(m,`, + `).concat(e,",").concat(t+r-c*h[3])),f+="Z"}else if(o>0&&i===+i&&i>0){var b=Math.min(o,i);f="M ".concat(e,",").concat(t+c*b,` + A `).concat(b,",").concat(b,",0,0,").concat(m,",").concat(e+u*b,",").concat(t,` + L `).concat(e+n-u*b,",").concat(t,` + A `).concat(b,",").concat(b,",0,0,").concat(m,",").concat(e+n,",").concat(t+c*b,` + L `).concat(e+n,",").concat(t+r-c*b,` + A `).concat(b,",").concat(b,",0,0,").concat(m,",").concat(e+n-u*b,",").concat(t+r,` + L `).concat(e+u*b,",").concat(t+r,` + A `).concat(b,",").concat(b,",0,0,").concat(m,",").concat(e,",").concat(t+r-c*b," Z")}else f="M ".concat(e,",").concat(t," h ").concat(n," v ").concat(r," h ").concat(-n," Z");return f},rN={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},a4=e=>{var t=Lt(e,rN),n=S.useRef(null),[r,i]=S.useState(-1);S.useEffect(()=>{if(n.current&&n.current.getTotalLength)try{var Y=n.current.getTotalLength();Y&&i(Y)}catch{}},[]);var{x:o,y:c,width:u,height:m,radius:f,className:h}=t,{animationEasing:g,animationDuration:v,animationBegin:b,isAnimationActive:T,isUpdateAnimationActive:C}=t,E=S.useRef(u),N=S.useRef(m),I=S.useRef(o),P=S.useRef(c),M=S.useMemo(()=>({x:o,y:c,width:u,height:m,radius:f}),[o,c,u,m,f]),j=lc(M,"rectangle-");if(o!==+o||c!==+c||u!==+u||m!==+m||u===0||m===0)return null;var k=Xe("recharts-rectangle",h);if(!C){var R=Mn(t),{radius:F}=R,q=tN(R,d$);return S.createElement("path",jm({},q,{radius:typeof f=="number"?f:void 0,className:k,d:nN(o,c,u,m,f)}))}var G=E.current,H=N.current,V=I.current,oe=P.current,Z="0px ".concat(r===-1?1:r,"px"),me="".concat(r,"px 0px"),z=t4(["strokeDasharray"],v,typeof g=="string"?g:rN.animationEasing);return S.createElement(sc,{animationId:j,key:j,canBegin:r>0,duration:v,easing:g,isActive:C,begin:b},Y=>{var ce=ot(G,u,Y),ge=ot(H,m,Y),Me=ot(V,o,Y),U=ot(oe,c,Y);n.current&&(E.current=ce,N.current=ge,I.current=Me,P.current=U);var te;T?Y>0?te={transition:z,strokeDasharray:me}:te={strokeDasharray:Z}:te={strokeDasharray:me};var ue=Mn(t),{radius:fe}=ue,Ne=tN(ue,f$);return S.createElement("path",jm({},Ne,{radius:typeof f=="number"?f:void 0,className:k,d:nN(Me,U,ce,ge,f),ref:n,style:eN(eN({},te),t.style)}))})};function iN(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function aN(e){for(var t=1;te*180/Math.PI,an=(e,t,n,r)=>({x:e+Math.cos(-Mm*r)*n,y:t+Math.sin(-Mm*r)*n}),o4=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{top:0,right:0,bottom:0,left:0};return Math.min(Math.abs(t-(r.left||0)-(r.right||0)),Math.abs(n-(r.top||0)-(r.bottom||0)))/2},w$=(e,t)=>{var{x:n,y:r}=e,{x:i,y:o}=t;return Math.sqrt((n-i)**2+(r-o)**2)},S$=(e,t)=>{var{x:n,y:r}=e,{cx:i,cy:o}=t,c=w$({x:n,y:r},{x:i,y:o});if(c<=0)return{radius:c,angle:0};var u=(n-i)/c,m=Math.acos(u);return r>o&&(m=2*Math.PI-m),{radius:c,angle:b$(m),angleInRadian:m}},A$=e=>{var{startAngle:t,endAngle:n}=e,r=Math.floor(t/360),i=Math.floor(n/360),o=Math.min(r,i);return{startAngle:t-o*360,endAngle:n-o*360}},C$=(e,t)=>{var{startAngle:n,endAngle:r}=t,i=Math.floor(n/360),o=Math.floor(r/360),c=Math.min(i,o);return e+c*360},T$=(e,t)=>{var{chartX:n,chartY:r}=e,{radius:i,angle:o}=S$({x:n,y:r},t),{innerRadius:c,outerRadius:u}=t;if(iu||i===0)return null;var{startAngle:m,endAngle:f}=A$(t),h=o,g;if(m<=f){for(;h>f;)h-=360;for(;h=m&&h<=f}else{for(;h>m;)h-=360;for(;h=f&&h<=m}return g?aN(aN({},t),{},{radius:i,angle:C$(h,t)}):null};function s4(e){var{cx:t,cy:n,radius:r,startAngle:i,endAngle:o}=e,c=an(t,n,r,i),u=an(t,n,r,o);return{points:[c,u],cx:t,cy:n,radius:r,startAngle:i,endAngle:o}}function Uv(){return Uv=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var n=bn(t-e),r=Math.min(Math.abs(t-e),359.999);return n*r},Hf=e=>{var{cx:t,cy:n,radius:r,angle:i,sign:o,isExternal:c,cornerRadius:u,cornerIsExternal:m}=e,f=u*(c?1:-1)+r,h=Math.asin(u/f)/Mm,g=m?i:i+o*h,v=an(t,n,f,g),b=an(t,n,r,g),T=m?i-o*h:i,C=an(t,n,f*Math.cos(h*Mm),T);return{center:v,circleTangency:b,lineTangency:C,theta:h}},l4=e=>{var{cx:t,cy:n,innerRadius:r,outerRadius:i,startAngle:o,endAngle:c}=e,u=E$(o,c),m=o+u,f=an(t,n,i,o),h=an(t,n,i,m),g="M ".concat(f.x,",").concat(f.y,` + A `).concat(i,",").concat(i,`,0, + `).concat(+(Math.abs(u)>180),",").concat(+(o>m),`, + `).concat(h.x,",").concat(h.y,` + `);if(r>0){var v=an(t,n,r,o),b=an(t,n,r,m);g+="L ".concat(b.x,",").concat(b.y,` + A `).concat(r,",").concat(r,`,0, + `).concat(+(Math.abs(u)>180),",").concat(+(o<=m),`, + `).concat(v.x,",").concat(v.y," Z")}else g+="L ".concat(t,",").concat(n," Z");return g},N$=e=>{var{cx:t,cy:n,innerRadius:r,outerRadius:i,cornerRadius:o,forceCornerRadius:c,cornerIsExternal:u,startAngle:m,endAngle:f}=e,h=bn(f-m),{circleTangency:g,lineTangency:v,theta:b}=Hf({cx:t,cy:n,radius:i,angle:m,sign:h,cornerRadius:o,cornerIsExternal:u}),{circleTangency:T,lineTangency:C,theta:E}=Hf({cx:t,cy:n,radius:i,angle:f,sign:-h,cornerRadius:o,cornerIsExternal:u}),N=u?Math.abs(m-f):Math.abs(m-f)-b-E;if(N<0)return c?"M ".concat(v.x,",").concat(v.y,` + a`).concat(o,",").concat(o,",0,0,1,").concat(o*2,`,0 + a`).concat(o,",").concat(o,",0,0,1,").concat(-o*2,`,0 + `):l4({cx:t,cy:n,innerRadius:r,outerRadius:i,startAngle:m,endAngle:f});var I="M ".concat(v.x,",").concat(v.y,` + A`).concat(o,",").concat(o,",0,0,").concat(+(h<0),",").concat(g.x,",").concat(g.y,` + A`).concat(i,",").concat(i,",0,").concat(+(N>180),",").concat(+(h<0),",").concat(T.x,",").concat(T.y,` + A`).concat(o,",").concat(o,",0,0,").concat(+(h<0),",").concat(C.x,",").concat(C.y,` + `);if(r>0){var{circleTangency:P,lineTangency:M,theta:j}=Hf({cx:t,cy:n,radius:r,angle:m,sign:h,isExternal:!0,cornerRadius:o,cornerIsExternal:u}),{circleTangency:k,lineTangency:R,theta:F}=Hf({cx:t,cy:n,radius:r,angle:f,sign:-h,isExternal:!0,cornerRadius:o,cornerIsExternal:u}),q=u?Math.abs(m-f):Math.abs(m-f)-j-F;if(q<0&&o===0)return"".concat(I,"L").concat(t,",").concat(n,"Z");I+="L".concat(R.x,",").concat(R.y,` + A`).concat(o,",").concat(o,",0,0,").concat(+(h<0),",").concat(k.x,",").concat(k.y,` + A`).concat(r,",").concat(r,",0,").concat(+(q>180),",").concat(+(h>0),",").concat(P.x,",").concat(P.y,` + A`).concat(o,",").concat(o,",0,0,").concat(+(h<0),",").concat(M.x,",").concat(M.y,"Z")}else I+="L".concat(t,",").concat(n,"Z");return I},_$={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},c4=e=>{var t=Lt(e,_$),{cx:n,cy:r,innerRadius:i,outerRadius:o,cornerRadius:c,forceCornerRadius:u,cornerIsExternal:m,startAngle:f,endAngle:h,className:g}=t;if(o0&&Math.abs(f-h)<360?C=N$({cx:n,cy:r,innerRadius:i,outerRadius:o,cornerRadius:Math.min(T,b/2),forceCornerRadius:u,cornerIsExternal:m,startAngle:f,endAngle:h}):C=l4({cx:n,cy:r,innerRadius:i,outerRadius:o,startAngle:f,endAngle:h}),S.createElement("path",Uv({},Mn(t),{className:v,d:C}))};function j$(e,t,n){if(e==="horizontal")return[{x:t.x,y:n.top},{x:t.x,y:n.top+n.height}];if(e==="vertical")return[{x:n.left,y:t.y},{x:n.left+n.width,y:t.y}];if(Q3(t)){if(e==="centric"){var{cx:r,cy:i,innerRadius:o,outerRadius:c,angle:u}=t,m=an(r,i,o,u),f=an(r,i,c,u);return[{x:m.x,y:m.y},{x:f.x,y:f.y}]}return s4(t)}}var Ty={},Ey={},Ny={},oN;function M$(){return oN||(oN=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=cM();function n(r){return t.isSymbol(r)?NaN:Number(r)}e.toNumber=n})(Ny)),Ny}var sN;function P$(){return sN||(sN=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=M$();function n(r){return r?(r=t.toNumber(r),r===1/0||r===-1/0?(r<0?-1:1)*Number.MAX_VALUE:r===r?r:0):r===0?r:0}e.toFinite=n})(Ey)),Ey}var lN;function I$(){return lN||(lN=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=uM(),n=P$();function r(i,o,c){c&&typeof c!="number"&&t.isIterateeCall(i,o,c)&&(o=c=void 0),i=n.toFinite(i),o===void 0?(o=i,i=0):o=n.toFinite(o),c=c===void 0?it?1:e>=t?0:NaN}function R$(e,t){return e==null||t==null?NaN:te?1:t>=e?0:NaN}function ob(e){let t,n,r;e.length!==2?(t=xo,n=(u,m)=>xo(e(u),m),r=(u,m)=>e(u)-m):(t=e===xo||e===R$?e:O$,n=e,r=e);function i(u,m,f=0,h=u.length){if(f>>1;n(u[g],m)<0?f=g+1:h=g}while(f>>1;n(u[g],m)<=0?f=g+1:h=g}while(ff&&r(u[g-1],m)>-r(u[g],m)?g-1:g}return{left:i,center:c,right:o}}function O$(){return 0}function d4(e){return e===null?NaN:+e}function*L$(e,t){for(let n of e)n!=null&&(n=+n)>=n&&(yield n)}const U$=ob(xo),nd=U$.right;ob(d4).center;class uN extends Map{constructor(t,n=F$){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),t!=null)for(const[r,i]of t)this.set(r,i)}get(t){return super.get(dN(this,t))}has(t){return super.has(dN(this,t))}set(t,n){return super.set(B$(this,t),n)}delete(t){return super.delete(z$(this,t))}}function dN({_intern:e,_key:t},n){const r=t(n);return e.has(r)?e.get(r):n}function B$({_intern:e,_key:t},n){const r=t(n);return e.has(r)?e.get(r):(e.set(r,n),n)}function z$({_intern:e,_key:t},n){const r=t(n);return e.has(r)&&(n=e.get(r),e.delete(r)),n}function F$(e){return e!==null&&typeof e=="object"?e.valueOf():e}function q$(e=xo){if(e===xo)return f4;if(typeof e!="function")throw new TypeError("compare is not a function");return(t,n)=>{const r=e(t,n);return r||r===0?r:(e(n,n)===0)-(e(t,t)===0)}}function f4(e,t){return(e==null||!(e>=e))-(t==null||!(t>=t))||(et?1:0)}const G$=Math.sqrt(50),$$=Math.sqrt(10),H$=Math.sqrt(2);function Pm(e,t,n){const r=(t-e)/Math.max(0,n),i=Math.floor(Math.log10(r)),o=r/Math.pow(10,i),c=o>=G$?10:o>=$$?5:o>=H$?2:1;let u,m,f;return i<0?(f=Math.pow(10,-i)/c,u=Math.round(e*f),m=Math.round(t*f),u/ft&&--m,f=-f):(f=Math.pow(10,i)*c,u=Math.round(e/f),m=Math.round(t/f),u*ft&&--m),m0))return[];if(e===t)return[e];const r=t=i))return[];const u=o-i+1,m=new Array(u);if(r)if(c<0)for(let f=0;f=r)&&(n=r);return n}function mN(e,t){let n;for(const r of e)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function m4(e,t,n=0,r=1/0,i){if(t=Math.floor(t),n=Math.floor(Math.max(0,n)),r=Math.floor(Math.min(e.length-1,r)),!(n<=t&&t<=r))return e;for(i=i===void 0?f4:q$(i);r>n;){if(r-n>600){const m=r-n+1,f=t-n+1,h=Math.log(m),g=.5*Math.exp(2*h/3),v=.5*Math.sqrt(h*g*(m-g)/m)*(f-m/2<0?-1:1),b=Math.max(n,Math.floor(t-f*g/m+v)),T=Math.min(r,Math.floor(t+(m-f)*g/m+v));m4(e,t,b,T,i)}const o=e[t];let c=n,u=r;for(xu(e,n,t),i(e[r],o)>0&&xu(e,n,r);c0;)--u}i(e[n],o)===0?xu(e,n,u):(++u,xu(e,u,r)),u<=t&&(n=u+1),t<=u&&(r=u-1)}return e}function xu(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function V$(e,t,n){if(e=Float64Array.from(L$(e)),!(!(r=e.length)||isNaN(t=+t))){if(t<=0||r<2)return mN(e);if(t>=1)return fN(e);var r,i=(r-1)*t,o=Math.floor(i),c=fN(m4(e,o).subarray(0,o+1)),u=mN(e.subarray(o+1));return c+(u-c)*(i-o)}}function K$(e,t,n=d4){if(!(!(r=e.length)||isNaN(t=+t))){if(t<=0||r<2)return+n(e[0],0,e);if(t>=1)return+n(e[r-1],r-1,e);var r,i=(r-1)*t,o=Math.floor(i),c=+n(e[o],o,e),u=+n(e[o+1],o+1,e);return c+(u-c)*(i-o)}}function Y$(e,t,n){e=+e,t=+t,n=(i=arguments.length)<2?(t=e,e=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((t-e)/n))|0,o=new Array(i);++r>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Vf(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Vf(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Q$.exec(e))?new or(t[1],t[2],t[3],1):(t=X$.exec(e))?new or(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Z$.exec(e))?Vf(t[1],t[2],t[3],t[4]):(t=eH.exec(e))?Vf(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=tH.exec(e))?bN(t[1],t[2]/100,t[3]/100,1):(t=nH.exec(e))?bN(t[1],t[2]/100,t[3]/100,t[4]):hN.hasOwnProperty(e)?yN(hN[e]):e==="transparent"?new or(NaN,NaN,NaN,0):null}function yN(e){return new or(e>>16&255,e>>8&255,e&255,1)}function Vf(e,t,n,r){return r<=0&&(e=t=n=NaN),new or(e,t,n,r)}function aH(e){return e instanceof rd||(e=Uu(e)),e?(e=e.rgb(),new or(e.r,e.g,e.b,e.opacity)):new or}function Gv(e,t,n,r){return arguments.length===1?aH(e):new or(e,t,n,r??1)}function or(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}cb(or,Gv,p4(rd,{brighter(e){return e=e==null?Im:Math.pow(Im,e),new or(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Ou:Math.pow(Ou,e),new or(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new or(bs(this.r),bs(this.g),bs(this.b),km(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:vN,formatHex:vN,formatHex8:oH,formatRgb:xN,toString:xN}));function vN(){return`#${as(this.r)}${as(this.g)}${as(this.b)}`}function oH(){return`#${as(this.r)}${as(this.g)}${as(this.b)}${as((isNaN(this.opacity)?1:this.opacity)*255)}`}function xN(){const e=km(this.opacity);return`${e===1?"rgb(":"rgba("}${bs(this.r)}, ${bs(this.g)}, ${bs(this.b)}${e===1?")":`, ${e})`}`}function km(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function bs(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function as(e){return e=bs(e),(e<16?"0":"")+e.toString(16)}function bN(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new ai(e,t,n,r)}function g4(e){if(e instanceof ai)return new ai(e.h,e.s,e.l,e.opacity);if(e instanceof rd||(e=Uu(e)),!e)return new ai;if(e instanceof ai)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),o=Math.max(t,n,r),c=NaN,u=o-i,m=(o+i)/2;return u?(t===o?c=(n-r)/u+(n0&&m<1?0:c,new ai(c,u,m,e.opacity)}function sH(e,t,n,r){return arguments.length===1?g4(e):new ai(e,t,n,r??1)}function ai(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}cb(ai,sH,p4(rd,{brighter(e){return e=e==null?Im:Math.pow(Im,e),new ai(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Ou:Math.pow(Ou,e),new ai(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new or(jy(e>=240?e-240:e+120,i,r),jy(e,i,r),jy(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new ai(wN(this.h),Kf(this.s),Kf(this.l),km(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=km(this.opacity);return`${e===1?"hsl(":"hsla("}${wN(this.h)}, ${Kf(this.s)*100}%, ${Kf(this.l)*100}%${e===1?")":`, ${e})`}`}}));function wN(e){return e=(e||0)%360,e<0?e+360:e}function Kf(e){return Math.max(0,Math.min(1,e||0))}function jy(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const ub=e=>()=>e;function lH(e,t){return function(n){return e+n*t}}function cH(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function uH(e){return(e=+e)==1?y4:function(t,n){return n-t?cH(t,n,e):ub(isNaN(t)?n:t)}}function y4(e,t){var n=t-e;return n?lH(e,n):ub(isNaN(e)?t:e)}const SN=(function e(t){var n=uH(t);function r(i,o){var c=n((i=Gv(i)).r,(o=Gv(o)).r),u=n(i.g,o.g),m=n(i.b,o.b),f=y4(i.opacity,o.opacity);return function(h){return i.r=c(h),i.g=u(h),i.b=m(h),i.opacity=f(h),i+""}}return r.gamma=e,r})(1);function dH(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(o){for(i=0;in&&(o=t.slice(n,o),u[c]?u[c]+=o:u[++c]=o),(r=r[0])===(i=i[0])?u[c]?u[c]+=i:u[++c]=i:(u[++c]=null,m.push({i:c,x:Dm(r,i)})),n=My.lastIndex;return nt&&(n=e,e=t,t=n),function(r){return Math.max(e,Math.min(t,r))}}function SH(e,t,n){var r=e[0],i=e[1],o=t[0],c=t[1];return i2?AH:SH,m=f=null,g}function g(v){return v==null||isNaN(v=+v)?o:(m||(m=u(e.map(r),t,n)))(r(c(v)))}return g.invert=function(v){return c(i((f||(f=u(t,e.map(r),Dm)))(v)))},g.domain=function(v){return arguments.length?(e=Array.from(v,Rm),h()):e.slice()},g.range=function(v){return arguments.length?(t=Array.from(v),h()):t.slice()},g.rangeRound=function(v){return t=Array.from(v),n=db,h()},g.clamp=function(v){return arguments.length?(c=v?!0:Vn,h()):c!==Vn},g.interpolate=function(v){return arguments.length?(n=v,h()):n},g.unknown=function(v){return arguments.length?(o=v,g):o},function(v,b){return r=v,i=b,h()}}function fb(){return Th()(Vn,Vn)}function CH(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function Om(e,t){if((n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf("e"))<0)return null;var n,r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function Xl(e){return e=Om(Math.abs(e)),e?e[1]:NaN}function TH(e,t){return function(n,r){for(var i=n.length,o=[],c=0,u=e[0],m=0;i>0&&u>0&&(m+u+1>r&&(u=Math.max(1,r-m)),o.push(n.substring(i-=u,i+u)),!((m+=u+1)>r));)u=e[c=(c+1)%e.length];return o.reverse().join(t)}}function EH(e){return function(t){return t.replace(/[0-9]/g,function(n){return e[+n]})}}var NH=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Bu(e){if(!(t=NH.exec(e)))throw new Error("invalid format: "+e);var t;return new mb({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}Bu.prototype=mb.prototype;function mb(e){this.fill=e.fill===void 0?" ":e.fill+"",this.align=e.align===void 0?">":e.align+"",this.sign=e.sign===void 0?"-":e.sign+"",this.symbol=e.symbol===void 0?"":e.symbol+"",this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?"":e.type+""}mb.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function _H(e){e:for(var t=e.length,n=1,r=-1,i;n0&&(r=0);break}return r>0?e.slice(0,r)+e.slice(i+1):e}var v4;function jH(e,t){var n=Om(e,t);if(!n)return e+"";var r=n[0],i=n[1],o=i-(v4=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,c=r.length;return o===c?r:o>c?r+new Array(o-c+1).join("0"):o>0?r.slice(0,o)+"."+r.slice(o):"0."+new Array(1-o).join("0")+Om(e,Math.max(0,t+o-1))[0]}function CN(e,t){var n=Om(e,t);if(!n)return e+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}const TN={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+"",d:CH,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>CN(e*100,t),r:CN,s:jH,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function EN(e){return e}var NN=Array.prototype.map,_N=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function MH(e){var t=e.grouping===void 0||e.thousands===void 0?EN:TH(NN.call(e.grouping,Number),e.thousands+""),n=e.currency===void 0?"":e.currency[0]+"",r=e.currency===void 0?"":e.currency[1]+"",i=e.decimal===void 0?".":e.decimal+"",o=e.numerals===void 0?EN:EH(NN.call(e.numerals,String)),c=e.percent===void 0?"%":e.percent+"",u=e.minus===void 0?"−":e.minus+"",m=e.nan===void 0?"NaN":e.nan+"";function f(g){g=Bu(g);var v=g.fill,b=g.align,T=g.sign,C=g.symbol,E=g.zero,N=g.width,I=g.comma,P=g.precision,M=g.trim,j=g.type;j==="n"?(I=!0,j="g"):TN[j]||(P===void 0&&(P=12),M=!0,j="g"),(E||v==="0"&&b==="=")&&(E=!0,v="0",b="=");var k=C==="$"?n:C==="#"&&/[boxX]/.test(j)?"0"+j.toLowerCase():"",R=C==="$"?r:/[%p]/.test(j)?c:"",F=TN[j],q=/[defgprs%]/.test(j);P=P===void 0?6:/[gprs]/.test(j)?Math.max(1,Math.min(21,P)):Math.max(0,Math.min(20,P));function G(H){var V=k,oe=R,Z,me,z;if(j==="c")oe=F(H)+oe,H="";else{H=+H;var Y=H<0||1/H<0;if(H=isNaN(H)?m:F(Math.abs(H),P),M&&(H=_H(H)),Y&&+H==0&&T!=="+"&&(Y=!1),V=(Y?T==="("?T:u:T==="-"||T==="("?"":T)+V,oe=(j==="s"?_N[8+v4/3]:"")+oe+(Y&&T==="("?")":""),q){for(Z=-1,me=H.length;++Zz||z>57){oe=(z===46?i+H.slice(Z+1):H.slice(Z))+oe,H=H.slice(0,Z);break}}}I&&!E&&(H=t(H,1/0));var ce=V.length+H.length+oe.length,ge=ce>1)+V+H+oe+ge.slice(ce);break;default:H=ge+V+H+oe;break}return o(H)}return G.toString=function(){return g+""},G}function h(g,v){var b=f((g=Bu(g),g.type="f",g)),T=Math.max(-8,Math.min(8,Math.floor(Xl(v)/3)))*3,C=Math.pow(10,-T),E=_N[8+T/3];return function(N){return b(C*N)+E}}return{format:f,formatPrefix:h}}var Yf,hb,x4;PH({thousands:",",grouping:[3],currency:["$",""]});function PH(e){return Yf=MH(e),hb=Yf.format,x4=Yf.formatPrefix,Yf}function IH(e){return Math.max(0,-Xl(Math.abs(e)))}function kH(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Xl(t)/3)))*3-Xl(Math.abs(e)))}function DH(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,Xl(t)-Xl(e))+1}function b4(e,t,n,r){var i=Fv(e,t,n),o;switch(r=Bu(r??",f"),r.type){case"s":{var c=Math.max(Math.abs(e),Math.abs(t));return r.precision==null&&!isNaN(o=kH(i,c))&&(r.precision=o),x4(r,c)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(o=DH(i,Math.max(Math.abs(e),Math.abs(t))))&&(r.precision=o-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(o=IH(i))&&(r.precision=o-(r.type==="%")*2);break}}return hb(r)}function _o(e){var t=e.domain;return e.ticks=function(n){var r=t();return Bv(r[0],r[r.length-1],n??10)},e.tickFormat=function(n,r){var i=t();return b4(i[0],i[i.length-1],n??10,r)},e.nice=function(n){n==null&&(n=10);var r=t(),i=0,o=r.length-1,c=r[i],u=r[o],m,f,h=10;for(u0;){if(f=zv(c,u,n),f===m)return r[i]=c,r[o]=u,t(r);if(f>0)c=Math.floor(c/f)*f,u=Math.ceil(u/f)*f;else if(f<0)c=Math.ceil(c*f)/f,u=Math.floor(u*f)/f;else break;m=f}return e},e}function w4(){var e=fb();return e.copy=function(){return id(e,w4())},Wr.apply(e,arguments),_o(e)}function S4(e){var t;function n(r){return r==null||isNaN(r=+r)?t:r}return n.invert=n,n.domain=n.range=function(r){return arguments.length?(e=Array.from(r,Rm),n):e.slice()},n.unknown=function(r){return arguments.length?(t=r,n):t},n.copy=function(){return S4(e).unknown(t)},e=arguments.length?Array.from(e,Rm):[0,1],_o(n)}function A4(e,t){e=e.slice();var n=0,r=e.length-1,i=e[n],o=e[r],c;return oMath.pow(e,t)}function BH(e){return e===Math.E?Math.log:e===10&&Math.log10||e===2&&Math.log2||(e=Math.log(e),t=>Math.log(t)/e)}function PN(e){return(t,n)=>-e(-t,n)}function pb(e){const t=e(jN,MN),n=t.domain;let r=10,i,o;function c(){return i=BH(r),o=UH(r),n()[0]<0?(i=PN(i),o=PN(o),e(RH,OH)):e(jN,MN),t}return t.base=function(u){return arguments.length?(r=+u,c()):r},t.domain=function(u){return arguments.length?(n(u),c()):n()},t.ticks=u=>{const m=n();let f=m[0],h=m[m.length-1];const g=h0){for(;v<=b;++v)for(T=1;Th)break;N.push(C)}}else for(;v<=b;++v)for(T=r-1;T>=1;--T)if(C=v>0?T/o(-v):T*o(v),!(Ch)break;N.push(C)}N.length*2{if(u==null&&(u=10),m==null&&(m=r===10?"s":","),typeof m!="function"&&(!(r%1)&&(m=Bu(m)).precision==null&&(m.trim=!0),m=hb(m)),u===1/0)return m;const f=Math.max(1,r*u/t.ticks().length);return h=>{let g=h/o(Math.round(i(h)));return g*rn(A4(n(),{floor:u=>o(Math.floor(i(u))),ceil:u=>o(Math.ceil(i(u)))})),t}function C4(){const e=pb(Th()).domain([1,10]);return e.copy=()=>id(e,C4()).base(e.base()),Wr.apply(e,arguments),e}function IN(e){return function(t){return Math.sign(t)*Math.log1p(Math.abs(t/e))}}function kN(e){return function(t){return Math.sign(t)*Math.expm1(Math.abs(t))*e}}function gb(e){var t=1,n=e(IN(t),kN(t));return n.constant=function(r){return arguments.length?e(IN(t=+r),kN(t)):t},_o(n)}function T4(){var e=gb(Th());return e.copy=function(){return id(e,T4()).constant(e.constant())},Wr.apply(e,arguments)}function DN(e){return function(t){return t<0?-Math.pow(-t,e):Math.pow(t,e)}}function zH(e){return e<0?-Math.sqrt(-e):Math.sqrt(e)}function FH(e){return e<0?-e*e:e*e}function yb(e){var t=e(Vn,Vn),n=1;function r(){return n===1?e(Vn,Vn):n===.5?e(zH,FH):e(DN(n),DN(1/n))}return t.exponent=function(i){return arguments.length?(n=+i,r()):n},_o(t)}function vb(){var e=yb(Th());return e.copy=function(){return id(e,vb()).exponent(e.exponent())},Wr.apply(e,arguments),e}function qH(){return vb.apply(null,arguments).exponent(.5)}function RN(e){return Math.sign(e)*e*e}function GH(e){return Math.sign(e)*Math.sqrt(Math.abs(e))}function E4(){var e=fb(),t=[0,1],n=!1,r;function i(o){var c=GH(e(o));return isNaN(c)?r:n?Math.round(c):c}return i.invert=function(o){return e.invert(RN(o))},i.domain=function(o){return arguments.length?(e.domain(o),i):e.domain()},i.range=function(o){return arguments.length?(e.range((t=Array.from(o,Rm)).map(RN)),i):t.slice()},i.rangeRound=function(o){return i.range(o).round(!0)},i.round=function(o){return arguments.length?(n=!!o,i):n},i.clamp=function(o){return arguments.length?(e.clamp(o),i):e.clamp()},i.unknown=function(o){return arguments.length?(r=o,i):r},i.copy=function(){return E4(e.domain(),t).round(n).clamp(e.clamp()).unknown(r)},Wr.apply(i,arguments),_o(i)}function N4(){var e=[],t=[],n=[],r;function i(){var c=0,u=Math.max(1,t.length);for(n=new Array(u-1);++c0?n[u-1]:e[0],u=n?[r[n-1],t]:[r[f-1],r[f]]},c.unknown=function(m){return arguments.length&&(o=m),c},c.thresholds=function(){return r.slice()},c.copy=function(){return _4().domain([e,t]).range(i).unknown(o)},Wr.apply(_o(c),arguments)}function j4(){var e=[.5],t=[0,1],n,r=1;function i(o){return o!=null&&o<=o?t[nd(e,o,0,r)]:n}return i.domain=function(o){return arguments.length?(e=Array.from(o),r=Math.min(e.length,t.length-1),i):e.slice()},i.range=function(o){return arguments.length?(t=Array.from(o),r=Math.min(e.length,t.length-1),i):t.slice()},i.invertExtent=function(o){var c=t.indexOf(o);return[e[c-1],e[c]]},i.unknown=function(o){return arguments.length?(n=o,i):n},i.copy=function(){return j4().domain(e).range(t).unknown(n)},Wr.apply(i,arguments)}const Py=new Date,Iy=new Date;function hn(e,t,n,r){function i(o){return e(o=arguments.length===0?new Date:new Date(+o)),o}return i.floor=o=>(e(o=new Date(+o)),o),i.ceil=o=>(e(o=new Date(o-1)),t(o,1),e(o),o),i.round=o=>{const c=i(o),u=i.ceil(o);return o-c(t(o=new Date(+o),c==null?1:Math.floor(c)),o),i.range=(o,c,u)=>{const m=[];if(o=i.ceil(o),u=u==null?1:Math.floor(u),!(o0))return m;let f;do m.push(f=new Date(+o)),t(o,u),e(o);while(fhn(c=>{if(c>=c)for(;e(c),!o(c);)c.setTime(c-1)},(c,u)=>{if(c>=c)if(u<0)for(;++u<=0;)for(;t(c,-1),!o(c););else for(;--u>=0;)for(;t(c,1),!o(c););}),n&&(i.count=(o,c)=>(Py.setTime(+o),Iy.setTime(+c),e(Py),e(Iy),Math.floor(n(Py,Iy))),i.every=o=>(o=Math.floor(o),!isFinite(o)||!(o>0)?null:o>1?i.filter(r?c=>r(c)%o===0:c=>i.count(0,c)%o===0):i)),i}const Lm=hn(()=>{},(e,t)=>{e.setTime(+e+t)},(e,t)=>t-e);Lm.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?hn(t=>{t.setTime(Math.floor(t/e)*e)},(t,n)=>{t.setTime(+t+n*e)},(t,n)=>(n-t)/e):Lm);Lm.range;const sa=1e3,$r=sa*60,la=$r*60,ga=la*24,xb=ga*7,ON=ga*30,ky=ga*365,os=hn(e=>{e.setTime(e-e.getMilliseconds())},(e,t)=>{e.setTime(+e+t*sa)},(e,t)=>(t-e)/sa,e=>e.getUTCSeconds());os.range;const bb=hn(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*sa)},(e,t)=>{e.setTime(+e+t*$r)},(e,t)=>(t-e)/$r,e=>e.getMinutes());bb.range;const wb=hn(e=>{e.setUTCSeconds(0,0)},(e,t)=>{e.setTime(+e+t*$r)},(e,t)=>(t-e)/$r,e=>e.getUTCMinutes());wb.range;const Sb=hn(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*sa-e.getMinutes()*$r)},(e,t)=>{e.setTime(+e+t*la)},(e,t)=>(t-e)/la,e=>e.getHours());Sb.range;const Ab=hn(e=>{e.setUTCMinutes(0,0,0)},(e,t)=>{e.setTime(+e+t*la)},(e,t)=>(t-e)/la,e=>e.getUTCHours());Ab.range;const ad=hn(e=>e.setHours(0,0,0,0),(e,t)=>e.setDate(e.getDate()+t),(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*$r)/ga,e=>e.getDate()-1);ad.range;const Eh=hn(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/ga,e=>e.getUTCDate()-1);Eh.range;const M4=hn(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/ga,e=>Math.floor(e/ga));M4.range;function Rs(e){return hn(t=>{t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)},(t,n)=>{t.setDate(t.getDate()+n*7)},(t,n)=>(n-t-(n.getTimezoneOffset()-t.getTimezoneOffset())*$r)/xb)}const Nh=Rs(0),Um=Rs(1),$H=Rs(2),HH=Rs(3),Zl=Rs(4),VH=Rs(5),KH=Rs(6);Nh.range;Um.range;$H.range;HH.range;Zl.range;VH.range;KH.range;function Os(e){return hn(t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)},(t,n)=>{t.setUTCDate(t.getUTCDate()+n*7)},(t,n)=>(n-t)/xb)}const _h=Os(0),Bm=Os(1),YH=Os(2),WH=Os(3),ec=Os(4),JH=Os(5),QH=Os(6);_h.range;Bm.range;YH.range;WH.range;ec.range;JH.range;QH.range;const Cb=hn(e=>{e.setDate(1),e.setHours(0,0,0,0)},(e,t)=>{e.setMonth(e.getMonth()+t)},(e,t)=>t.getMonth()-e.getMonth()+(t.getFullYear()-e.getFullYear())*12,e=>e.getMonth());Cb.range;const Tb=hn(e=>{e.setUTCDate(1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCMonth(e.getUTCMonth()+t)},(e,t)=>t.getUTCMonth()-e.getUTCMonth()+(t.getUTCFullYear()-e.getUTCFullYear())*12,e=>e.getUTCMonth());Tb.range;const ya=hn(e=>{e.setMonth(0,1),e.setHours(0,0,0,0)},(e,t)=>{e.setFullYear(e.getFullYear()+t)},(e,t)=>t.getFullYear()-e.getFullYear(),e=>e.getFullYear());ya.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:hn(t=>{t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)},(t,n)=>{t.setFullYear(t.getFullYear()+n*e)});ya.range;const va=hn(e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCFullYear(e.getUTCFullYear()+t)},(e,t)=>t.getUTCFullYear()-e.getUTCFullYear(),e=>e.getUTCFullYear());va.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:hn(t=>{t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,n)=>{t.setUTCFullYear(t.getUTCFullYear()+n*e)});va.range;function P4(e,t,n,r,i,o){const c=[[os,1,sa],[os,5,5*sa],[os,15,15*sa],[os,30,30*sa],[o,1,$r],[o,5,5*$r],[o,15,15*$r],[o,30,30*$r],[i,1,la],[i,3,3*la],[i,6,6*la],[i,12,12*la],[r,1,ga],[r,2,2*ga],[n,1,xb],[t,1,ON],[t,3,3*ON],[e,1,ky]];function u(f,h,g){const v=hE).right(c,v);if(b===c.length)return e.every(Fv(f/ky,h/ky,g));if(b===0)return Lm.every(Math.max(Fv(f,h,g),1));const[T,C]=c[v/c[b-1][2]53)return null;"w"in de||(de.w=1),"Z"in de?($e=Ry(bu(de.y,0,1)),Ht=$e.getUTCDay(),$e=Ht>4||Ht===0?Bm.ceil($e):Bm($e),$e=Eh.offset($e,(de.V-1)*7),de.y=$e.getUTCFullYear(),de.m=$e.getUTCMonth(),de.d=$e.getUTCDate()+(de.w+6)%7):($e=Dy(bu(de.y,0,1)),Ht=$e.getDay(),$e=Ht>4||Ht===0?Um.ceil($e):Um($e),$e=ad.offset($e,(de.V-1)*7),de.y=$e.getFullYear(),de.m=$e.getMonth(),de.d=$e.getDate()+(de.w+6)%7)}else("W"in de||"U"in de)&&("w"in de||(de.w="u"in de?de.u%7:"W"in de?1:0),Ht="Z"in de?Ry(bu(de.y,0,1)).getUTCDay():Dy(bu(de.y,0,1)).getDay(),de.m=0,de.d="W"in de?(de.w+6)%7+de.W*7-(Ht+5)%7:de.w+de.U*7-(Ht+6)%7);return"Z"in de?(de.H+=de.Z/100|0,de.M+=de.Z%100,Ry(de)):Dy(de)}}function F(re,Le,Fe,de){for(var $t=0,$e=Le.length,Ht=Fe.length,Vt,cr;$t<$e;){if(de>=Ht)return-1;if(Vt=Le.charCodeAt($t++),Vt===37){if(Vt=Le.charAt($t++),cr=j[Vt in LN?Le.charAt($t++):Vt],!cr||(de=cr(re,Fe,de))<0)return-1}else if(Vt!=Fe.charCodeAt(de++))return-1}return de}function q(re,Le,Fe){var de=f.exec(Le.slice(Fe));return de?(re.p=h.get(de[0].toLowerCase()),Fe+de[0].length):-1}function G(re,Le,Fe){var de=b.exec(Le.slice(Fe));return de?(re.w=T.get(de[0].toLowerCase()),Fe+de[0].length):-1}function H(re,Le,Fe){var de=g.exec(Le.slice(Fe));return de?(re.w=v.get(de[0].toLowerCase()),Fe+de[0].length):-1}function V(re,Le,Fe){var de=N.exec(Le.slice(Fe));return de?(re.m=I.get(de[0].toLowerCase()),Fe+de[0].length):-1}function oe(re,Le,Fe){var de=C.exec(Le.slice(Fe));return de?(re.m=E.get(de[0].toLowerCase()),Fe+de[0].length):-1}function Z(re,Le,Fe){return F(re,t,Le,Fe)}function me(re,Le,Fe){return F(re,n,Le,Fe)}function z(re,Le,Fe){return F(re,r,Le,Fe)}function Y(re){return c[re.getDay()]}function ce(re){return o[re.getDay()]}function ge(re){return m[re.getMonth()]}function Me(re){return u[re.getMonth()]}function U(re){return i[+(re.getHours()>=12)]}function te(re){return 1+~~(re.getMonth()/3)}function ue(re){return c[re.getUTCDay()]}function fe(re){return o[re.getUTCDay()]}function Ne(re){return m[re.getUTCMonth()]}function Pe(re){return u[re.getUTCMonth()]}function Re(re){return i[+(re.getUTCHours()>=12)]}function wt(re){return 1+~~(re.getUTCMonth()/3)}return{format:function(re){var Le=k(re+="",P);return Le.toString=function(){return re},Le},parse:function(re){var Le=R(re+="",!1);return Le.toString=function(){return re},Le},utcFormat:function(re){var Le=k(re+="",M);return Le.toString=function(){return re},Le},utcParse:function(re){var Le=R(re+="",!0);return Le.toString=function(){return re},Le}}}var LN={"-":"",_:" ",0:"0"},wn=/^\s*\d+/,rV=/^%/,iV=/[\\^$*+?|[\]().{}]/g;function nt(e,t,n){var r=e<0?"-":"",i=(r?-e:e)+"",o=i.length;return r+(o[t.toLowerCase(),n]))}function oV(e,t,n){var r=wn.exec(t.slice(n,n+1));return r?(e.w=+r[0],n+r[0].length):-1}function sV(e,t,n){var r=wn.exec(t.slice(n,n+1));return r?(e.u=+r[0],n+r[0].length):-1}function lV(e,t,n){var r=wn.exec(t.slice(n,n+2));return r?(e.U=+r[0],n+r[0].length):-1}function cV(e,t,n){var r=wn.exec(t.slice(n,n+2));return r?(e.V=+r[0],n+r[0].length):-1}function uV(e,t,n){var r=wn.exec(t.slice(n,n+2));return r?(e.W=+r[0],n+r[0].length):-1}function UN(e,t,n){var r=wn.exec(t.slice(n,n+4));return r?(e.y=+r[0],n+r[0].length):-1}function BN(e,t,n){var r=wn.exec(t.slice(n,n+2));return r?(e.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function dV(e,t,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(n,n+6));return r?(e.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1}function fV(e,t,n){var r=wn.exec(t.slice(n,n+1));return r?(e.q=r[0]*3-3,n+r[0].length):-1}function mV(e,t,n){var r=wn.exec(t.slice(n,n+2));return r?(e.m=r[0]-1,n+r[0].length):-1}function zN(e,t,n){var r=wn.exec(t.slice(n,n+2));return r?(e.d=+r[0],n+r[0].length):-1}function hV(e,t,n){var r=wn.exec(t.slice(n,n+3));return r?(e.m=0,e.d=+r[0],n+r[0].length):-1}function FN(e,t,n){var r=wn.exec(t.slice(n,n+2));return r?(e.H=+r[0],n+r[0].length):-1}function pV(e,t,n){var r=wn.exec(t.slice(n,n+2));return r?(e.M=+r[0],n+r[0].length):-1}function gV(e,t,n){var r=wn.exec(t.slice(n,n+2));return r?(e.S=+r[0],n+r[0].length):-1}function yV(e,t,n){var r=wn.exec(t.slice(n,n+3));return r?(e.L=+r[0],n+r[0].length):-1}function vV(e,t,n){var r=wn.exec(t.slice(n,n+6));return r?(e.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function xV(e,t,n){var r=rV.exec(t.slice(n,n+1));return r?n+r[0].length:-1}function bV(e,t,n){var r=wn.exec(t.slice(n));return r?(e.Q=+r[0],n+r[0].length):-1}function wV(e,t,n){var r=wn.exec(t.slice(n));return r?(e.s=+r[0],n+r[0].length):-1}function qN(e,t){return nt(e.getDate(),t,2)}function SV(e,t){return nt(e.getHours(),t,2)}function AV(e,t){return nt(e.getHours()%12||12,t,2)}function CV(e,t){return nt(1+ad.count(ya(e),e),t,3)}function I4(e,t){return nt(e.getMilliseconds(),t,3)}function TV(e,t){return I4(e,t)+"000"}function EV(e,t){return nt(e.getMonth()+1,t,2)}function NV(e,t){return nt(e.getMinutes(),t,2)}function _V(e,t){return nt(e.getSeconds(),t,2)}function jV(e){var t=e.getDay();return t===0?7:t}function MV(e,t){return nt(Nh.count(ya(e)-1,e),t,2)}function k4(e){var t=e.getDay();return t>=4||t===0?Zl(e):Zl.ceil(e)}function PV(e,t){return e=k4(e),nt(Zl.count(ya(e),e)+(ya(e).getDay()===4),t,2)}function IV(e){return e.getDay()}function kV(e,t){return nt(Um.count(ya(e)-1,e),t,2)}function DV(e,t){return nt(e.getFullYear()%100,t,2)}function RV(e,t){return e=k4(e),nt(e.getFullYear()%100,t,2)}function OV(e,t){return nt(e.getFullYear()%1e4,t,4)}function LV(e,t){var n=e.getDay();return e=n>=4||n===0?Zl(e):Zl.ceil(e),nt(e.getFullYear()%1e4,t,4)}function UV(e){var t=e.getTimezoneOffset();return(t>0?"-":(t*=-1,"+"))+nt(t/60|0,"0",2)+nt(t%60,"0",2)}function GN(e,t){return nt(e.getUTCDate(),t,2)}function BV(e,t){return nt(e.getUTCHours(),t,2)}function zV(e,t){return nt(e.getUTCHours()%12||12,t,2)}function FV(e,t){return nt(1+Eh.count(va(e),e),t,3)}function D4(e,t){return nt(e.getUTCMilliseconds(),t,3)}function qV(e,t){return D4(e,t)+"000"}function GV(e,t){return nt(e.getUTCMonth()+1,t,2)}function $V(e,t){return nt(e.getUTCMinutes(),t,2)}function HV(e,t){return nt(e.getUTCSeconds(),t,2)}function VV(e){var t=e.getUTCDay();return t===0?7:t}function KV(e,t){return nt(_h.count(va(e)-1,e),t,2)}function R4(e){var t=e.getUTCDay();return t>=4||t===0?ec(e):ec.ceil(e)}function YV(e,t){return e=R4(e),nt(ec.count(va(e),e)+(va(e).getUTCDay()===4),t,2)}function WV(e){return e.getUTCDay()}function JV(e,t){return nt(Bm.count(va(e)-1,e),t,2)}function QV(e,t){return nt(e.getUTCFullYear()%100,t,2)}function XV(e,t){return e=R4(e),nt(e.getUTCFullYear()%100,t,2)}function ZV(e,t){return nt(e.getUTCFullYear()%1e4,t,4)}function eK(e,t){var n=e.getUTCDay();return e=n>=4||n===0?ec(e):ec.ceil(e),nt(e.getUTCFullYear()%1e4,t,4)}function tK(){return"+0000"}function $N(){return"%"}function HN(e){return+e}function VN(e){return Math.floor(+e/1e3)}var Cl,O4,L4;nK({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function nK(e){return Cl=nV(e),O4=Cl.format,Cl.parse,L4=Cl.utcFormat,Cl.utcParse,Cl}function rK(e){return new Date(e)}function iK(e){return e instanceof Date?+e:+new Date(+e)}function Eb(e,t,n,r,i,o,c,u,m,f){var h=fb(),g=h.invert,v=h.domain,b=f(".%L"),T=f(":%S"),C=f("%I:%M"),E=f("%I %p"),N=f("%a %d"),I=f("%b %d"),P=f("%B"),M=f("%Y");function j(k){return(m(k)t(i/(e.length-1)))},n.quantiles=function(r){return Array.from({length:r+1},(i,o)=>V$(e,o/r))},n.copy=function(){return F4(t).domain(e)},Na.apply(n,arguments)}function Mh(){var e=0,t=.5,n=1,r=1,i,o,c,u,m,f=Vn,h,g=!1,v;function b(C){return isNaN(C=+C)?v:(C=.5+((C=+h(C))-o)*(r*Ce.chartData,jb=J([Mo],e=>{var t=e.chartData!=null?e.chartData.length-1:0;return{chartData:e.chartData,computedData:e.computedData,dataEndIndex:t,dataStartIndex:0}}),od=(e,t,n,r)=>r?jb(e):Mo(e);function Ns(e){if(Array.isArray(e)&&e.length===2){var[t,n]=e;if(dt(t)&&dt(n))return!0}return!1}function KN(e,t,n){return n?e:[Math.min(e[0],t[0]),Math.max(e[1],t[1])]}function H4(e,t){if(t&&typeof e!="function"&&Array.isArray(e)&&e.length===2){var[n,r]=e,i,o;if(dt(n))i=n;else if(typeof n=="function")return;if(dt(r))o=r;else if(typeof r=="function")return;var c=[i,o];if(Ns(c))return c}}function cK(e,t,n){if(!(!n&&t==null)){if(typeof e=="function"&&t!=null)try{var r=e(t,n);if(Ns(r))return KN(r,t,n)}catch{}if(Array.isArray(e)&&e.length===2){var[i,o]=e,c,u;if(i==="auto")t!=null&&(c=Math.min(...t));else if(we(i))c=i;else if(typeof i=="function")try{t!=null&&(c=i(t==null?void 0:t[0]))}catch{}else if(typeof i=="string"&&NE.test(i)){var m=NE.exec(i);if(m==null||t==null)c=void 0;else{var f=+m[1];c=t[0]-f}}else c=t==null?void 0:t[0];if(o==="auto")t!=null&&(u=Math.max(...t));else if(we(o))u=o;else if(typeof o=="function")try{t!=null&&(u=o(t==null?void 0:t[1]))}catch{}else if(typeof o=="string"&&_E.test(o)){var h=_E.exec(o);if(h==null||t==null)u=void 0;else{var g=+h[1];u=t[1]+g}}else u=t==null?void 0:t[1];var v=[c,u];if(Ns(v))return t==null?v:KN(v,t,n)}}}var uc=1e9,uK={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},Pb,It=!0,Yr="[DecimalError] ",ws=Yr+"Invalid argument: ",Mb=Yr+"Exponent out of range: ",dc=Math.floor,rs=Math.pow,dK=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Sr,xn=1e7,_t=7,V4=9007199254740991,zm=dc(V4/_t),Te={};Te.absoluteValue=Te.abs=function(){var e=new this.constructor(this);return e.s&&(e.s=1),e};Te.comparedTo=Te.cmp=function(e){var t,n,r,i,o=this;if(e=new o.constructor(e),o.s!==e.s)return o.s||-e.s;if(o.e!==e.e)return o.e>e.e^o.s<0?1:-1;for(r=o.d.length,i=e.d.length,t=0,n=re.d[t]^o.s<0?1:-1;return r===i?0:r>i^o.s<0?1:-1};Te.decimalPlaces=Te.dp=function(){var e=this,t=e.d.length-1,n=(t-e.e)*_t;if(t=e.d[t],t)for(;t%10==0;t/=10)n--;return n<0?0:n};Te.dividedBy=Te.div=function(e){return ua(this,new this.constructor(e))};Te.dividedToIntegerBy=Te.idiv=function(e){var t=this,n=t.constructor;return xt(ua(t,new n(e),0,1),n.precision)};Te.equals=Te.eq=function(e){return!this.cmp(e)};Te.exponent=function(){return on(this)};Te.greaterThan=Te.gt=function(e){return this.cmp(e)>0};Te.greaterThanOrEqualTo=Te.gte=function(e){return this.cmp(e)>=0};Te.isInteger=Te.isint=function(){return this.e>this.d.length-2};Te.isNegative=Te.isneg=function(){return this.s<0};Te.isPositive=Te.ispos=function(){return this.s>0};Te.isZero=function(){return this.s===0};Te.lessThan=Te.lt=function(e){return this.cmp(e)<0};Te.lessThanOrEqualTo=Te.lte=function(e){return this.cmp(e)<1};Te.logarithm=Te.log=function(e){var t,n=this,r=n.constructor,i=r.precision,o=i+5;if(e===void 0)e=new r(10);else if(e=new r(e),e.s<1||e.eq(Sr))throw Error(Yr+"NaN");if(n.s<1)throw Error(Yr+(n.s?"NaN":"-Infinity"));return n.eq(Sr)?new r(0):(It=!1,t=ua(zu(n,o),zu(e,o),o),It=!0,xt(t,i))};Te.minus=Te.sub=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?W4(t,e):K4(t,(e.s=-e.s,e))};Te.modulo=Te.mod=function(e){var t,n=this,r=n.constructor,i=r.precision;if(e=new r(e),!e.s)throw Error(Yr+"NaN");return n.s?(It=!1,t=ua(n,e,0,1).times(e),It=!0,n.minus(t)):xt(new r(n),i)};Te.naturalExponential=Te.exp=function(){return Y4(this)};Te.naturalLogarithm=Te.ln=function(){return zu(this)};Te.negated=Te.neg=function(){var e=new this.constructor(this);return e.s=-e.s||0,e};Te.plus=Te.add=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?K4(t,e):W4(t,(e.s=-e.s,e))};Te.precision=Te.sd=function(e){var t,n,r,i=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(ws+e);if(t=on(i)+1,r=i.d.length-1,n=r*_t+1,r=i.d[r],r){for(;r%10==0;r/=10)n--;for(r=i.d[0];r>=10;r/=10)n++}return e&&t>n?t:n};Te.squareRoot=Te.sqrt=function(){var e,t,n,r,i,o,c,u=this,m=u.constructor;if(u.s<1){if(!u.s)return new m(0);throw Error(Yr+"NaN")}for(e=on(u),It=!1,i=Math.sqrt(+u),i==0||i==1/0?(t=Ai(u.d),(t.length+e)%2==0&&(t+="0"),i=Math.sqrt(t),e=dc((e+1)/2)-(e<0||e%2),i==1/0?t="5e"+e:(t=i.toExponential(),t=t.slice(0,t.indexOf("e")+1)+e),r=new m(t)):r=new m(i.toString()),n=m.precision,i=c=n+3;;)if(o=r,r=o.plus(ua(u,o,c+2)).times(.5),Ai(o.d).slice(0,c)===(t=Ai(r.d)).slice(0,c)){if(t=t.slice(c-3,c+1),i==c&&t=="4999"){if(xt(o,n+1,0),o.times(o).eq(u)){r=o;break}}else if(t!="9999")break;c+=4}return It=!0,xt(r,n)};Te.times=Te.mul=function(e){var t,n,r,i,o,c,u,m,f,h=this,g=h.constructor,v=h.d,b=(e=new g(e)).d;if(!h.s||!e.s)return new g(0);for(e.s*=h.s,n=h.e+e.e,m=v.length,f=b.length,m=0;){for(t=0,i=m+r;i>r;)u=o[i]+b[r]*v[i-r-1]+t,o[i--]=u%xn|0,t=u/xn|0;o[i]=(o[i]+t)%xn|0}for(;!o[--c];)o.pop();return t?++n:o.shift(),e.d=o,e.e=n,It?xt(e,g.precision):e};Te.toDecimalPlaces=Te.todp=function(e,t){var n=this,r=n.constructor;return n=new r(n),e===void 0?n:(Ei(e,0,uc),t===void 0?t=r.rounding:Ei(t,0,8),xt(n,e+on(n)+1,t))};Te.toExponential=function(e,t){var n,r=this,i=r.constructor;return e===void 0?n=_s(r,!0):(Ei(e,0,uc),t===void 0?t=i.rounding:Ei(t,0,8),r=xt(new i(r),e+1,t),n=_s(r,!0,e+1)),n};Te.toFixed=function(e,t){var n,r,i=this,o=i.constructor;return e===void 0?_s(i):(Ei(e,0,uc),t===void 0?t=o.rounding:Ei(t,0,8),r=xt(new o(i),e+on(i)+1,t),n=_s(r.abs(),!1,e+on(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};Te.toInteger=Te.toint=function(){var e=this,t=e.constructor;return xt(new t(e),on(e)+1,t.rounding)};Te.toNumber=function(){return+this};Te.toPower=Te.pow=function(e){var t,n,r,i,o,c,u=this,m=u.constructor,f=12,h=+(e=new m(e));if(!e.s)return new m(Sr);if(u=new m(u),!u.s){if(e.s<1)throw Error(Yr+"Infinity");return u}if(u.eq(Sr))return u;if(r=m.precision,e.eq(Sr))return xt(u,r);if(t=e.e,n=e.d.length-1,c=t>=n,o=u.s,c){if((n=h<0?-h:h)<=V4){for(i=new m(Sr),t=Math.ceil(r/_t+4),It=!1;n%2&&(i=i.times(u),WN(i.d,t)),n=dc(n/2),n!==0;)u=u.times(u),WN(u.d,t);return It=!0,e.s<0?new m(Sr).div(i):xt(i,r)}}else if(o<0)throw Error(Yr+"NaN");return o=o<0&&e.d[Math.max(t,n)]&1?-1:1,u.s=1,It=!1,i=e.times(zu(u,r+f)),It=!0,i=Y4(i),i.s=o,i};Te.toPrecision=function(e,t){var n,r,i=this,o=i.constructor;return e===void 0?(n=on(i),r=_s(i,n<=o.toExpNeg||n>=o.toExpPos)):(Ei(e,1,uc),t===void 0?t=o.rounding:Ei(t,0,8),i=xt(new o(i),e,t),n=on(i),r=_s(i,e<=n||n<=o.toExpNeg,e)),r};Te.toSignificantDigits=Te.tosd=function(e,t){var n=this,r=n.constructor;return e===void 0?(e=r.precision,t=r.rounding):(Ei(e,1,uc),t===void 0?t=r.rounding:Ei(t,0,8)),xt(new r(n),e,t)};Te.toString=Te.valueOf=Te.val=Te.toJSON=Te[Symbol.for("nodejs.util.inspect.custom")]=function(){var e=this,t=on(e),n=e.constructor;return _s(e,t<=n.toExpNeg||t>=n.toExpPos)};function K4(e,t){var n,r,i,o,c,u,m,f,h=e.constructor,g=h.precision;if(!e.s||!t.s)return t.s||(t=new h(e)),It?xt(t,g):t;if(m=e.d,f=t.d,c=e.e,i=t.e,m=m.slice(),o=c-i,o){for(o<0?(r=m,o=-o,u=f.length):(r=f,i=c,u=m.length),c=Math.ceil(g/_t),u=c>u?c+1:u+1,o>u&&(o=u,r.length=1),r.reverse();o--;)r.push(0);r.reverse()}for(u=m.length,o=f.length,u-o<0&&(o=u,r=f,f=m,m=r),n=0;o;)n=(m[--o]=m[o]+f[o]+n)/xn|0,m[o]%=xn;for(n&&(m.unshift(n),++i),u=m.length;m[--u]==0;)m.pop();return t.d=m,t.e=i,It?xt(t,g):t}function Ei(e,t,n){if(e!==~~e||en)throw Error(ws+e)}function Ai(e){var t,n,r,i=e.length-1,o="",c=e[0];if(i>0){for(o+=c,t=1;tc?1:-1;else for(u=m=0;ui[u]?1:-1;break}return m}function n(r,i,o){for(var c=0;o--;)r[o]-=c,c=r[o]1;)r.shift()}return function(r,i,o,c){var u,m,f,h,g,v,b,T,C,E,N,I,P,M,j,k,R,F,q=r.constructor,G=r.s==i.s?1:-1,H=r.d,V=i.d;if(!r.s)return new q(r);if(!i.s)throw Error(Yr+"Division by zero");for(m=r.e-i.e,R=V.length,j=H.length,b=new q(G),T=b.d=[],f=0;V[f]==(H[f]||0);)++f;if(V[f]>(H[f]||0)&&--m,o==null?I=o=q.precision:c?I=o+(on(r)-on(i))+1:I=o,I<0)return new q(0);if(I=I/_t+2|0,f=0,R==1)for(h=0,V=V[0],I++;(f1&&(V=e(V,h),H=e(H,h),R=V.length,j=H.length),M=R,C=H.slice(0,R),E=C.length;E=xn/2&&++k;do h=0,u=t(V,C,R,E),u<0?(N=C[0],R!=E&&(N=N*xn+(C[1]||0)),h=N/k|0,h>1?(h>=xn&&(h=xn-1),g=e(V,h),v=g.length,E=C.length,u=t(g,C,v,E),u==1&&(h--,n(g,R16)throw Error(Mb+on(e));if(!e.s)return new h(Sr);for(It=!1,u=g,c=new h(.03125);e.abs().gte(.1);)e=e.times(c),f+=5;for(r=Math.log(rs(2,f))/Math.LN10*2+5|0,u+=r,n=i=o=new h(Sr),h.precision=u;;){if(i=xt(i.times(e),u),n=n.times(++m),c=o.plus(ua(i,n,u)),Ai(c.d).slice(0,u)===Ai(o.d).slice(0,u)){for(;f--;)o=xt(o.times(o),u);return h.precision=g,t==null?(It=!0,xt(o,g)):o}o=c}}function on(e){for(var t=e.e*_t,n=e.d[0];n>=10;n/=10)t++;return t}function Oy(e,t,n){if(t>e.LN10.sd())throw It=!0,n&&(e.precision=n),Error(Yr+"LN10 precision limit exceeded");return xt(new e(e.LN10),t)}function oo(e){for(var t="";e--;)t+="0";return t}function zu(e,t){var n,r,i,o,c,u,m,f,h,g=1,v=10,b=e,T=b.d,C=b.constructor,E=C.precision;if(b.s<1)throw Error(Yr+(b.s?"NaN":"-Infinity"));if(b.eq(Sr))return new C(0);if(t==null?(It=!1,f=E):f=t,b.eq(10))return t==null&&(It=!0),Oy(C,f);if(f+=v,C.precision=f,n=Ai(T),r=n.charAt(0),o=on(b),Math.abs(o)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)b=b.times(e),n=Ai(b.d),r=n.charAt(0),g++;o=on(b),r>1?(b=new C("0."+n),o++):b=new C(r+"."+n.slice(1))}else return m=Oy(C,f+2,E).times(o+""),b=zu(new C(r+"."+n.slice(1)),f-v).plus(m),C.precision=E,t==null?(It=!0,xt(b,E)):b;for(u=c=b=ua(b.minus(Sr),b.plus(Sr),f),h=xt(b.times(b),f),i=3;;){if(c=xt(c.times(h),f),m=u.plus(ua(c,new C(i),f)),Ai(m.d).slice(0,f)===Ai(u.d).slice(0,f))return u=u.times(2),o!==0&&(u=u.plus(Oy(C,f+2,E).times(o+""))),u=ua(u,new C(g),f),C.precision=E,t==null?(It=!0,xt(u,E)):u;u=m,i+=2}}function YN(e,t){var n,r,i;for((n=t.indexOf("."))>-1&&(t=t.replace(".","")),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;t.charCodeAt(r)===48;)++r;for(i=t.length;t.charCodeAt(i-1)===48;)--i;if(t=t.slice(r,i),t){if(i-=r,n=n-r-1,e.e=dc(n/_t),e.d=[],r=(n+1)%_t,n<0&&(r+=_t),rzm||e.e<-zm))throw Error(Mb+n)}else e.s=0,e.e=0,e.d=[0];return e}function xt(e,t,n){var r,i,o,c,u,m,f,h,g=e.d;for(c=1,o=g[0];o>=10;o/=10)c++;if(r=t-c,r<0)r+=_t,i=t,f=g[h=0];else{if(h=Math.ceil((r+1)/_t),o=g.length,h>=o)return e;for(f=o=g[h],c=1;o>=10;o/=10)c++;r%=_t,i=r-_t+c}if(n!==void 0&&(o=rs(10,c-i-1),u=f/o%10|0,m=t<0||g[h+1]!==void 0||f%o,m=n<4?(u||m)&&(n==0||n==(e.s<0?3:2)):u>5||u==5&&(n==4||m||n==6&&(r>0?i>0?f/rs(10,c-i):0:g[h-1])%10&1||n==(e.s<0?8:7))),t<1||!g[0])return m?(o=on(e),g.length=1,t=t-o-1,g[0]=rs(10,(_t-t%_t)%_t),e.e=dc(-t/_t)||0):(g.length=1,g[0]=e.e=e.s=0),e;if(r==0?(g.length=h,o=1,h--):(g.length=h+1,o=rs(10,_t-r),g[h]=i>0?(f/rs(10,c-i)%rs(10,i)|0)*o:0),m)for(;;)if(h==0){(g[0]+=o)==xn&&(g[0]=1,++e.e);break}else{if(g[h]+=o,g[h]!=xn)break;g[h--]=0,o=1}for(r=g.length;g[--r]===0;)g.pop();if(It&&(e.e>zm||e.e<-zm))throw Error(Mb+on(e));return e}function W4(e,t){var n,r,i,o,c,u,m,f,h,g,v=e.constructor,b=v.precision;if(!e.s||!t.s)return t.s?t.s=-t.s:t=new v(e),It?xt(t,b):t;if(m=e.d,g=t.d,r=t.e,f=e.e,m=m.slice(),c=f-r,c){for(h=c<0,h?(n=m,c=-c,u=g.length):(n=g,r=f,u=m.length),i=Math.max(Math.ceil(b/_t),u)+2,c>i&&(c=i,n.length=1),n.reverse(),i=c;i--;)n.push(0);n.reverse()}else{for(i=m.length,u=g.length,h=i0;--i)m[u++]=0;for(i=g.length;i>c;){if(m[--i]0?o=o.charAt(0)+"."+o.slice(1)+oo(r):c>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(i<0?"e":"e+")+i):i<0?(o="0."+oo(-i-1)+o,n&&(r=n-c)>0&&(o+=oo(r))):i>=c?(o+=oo(i+1-c),n&&(r=n-i-1)>0&&(o=o+"."+oo(r))):((r=i+1)0&&(i+1===c&&(o+="."),o+=oo(r))),e.s<0?"-"+o:o}function WN(e,t){if(e.length>t)return e.length=t,!0}function J4(e){var t,n,r;function i(o){var c=this;if(!(c instanceof i))return new i(o);if(c.constructor=i,o instanceof i){c.s=o.s,c.e=o.e,c.d=(o=o.d)?o.slice():o;return}if(typeof o=="number"){if(o*0!==0)throw Error(ws+o);if(o>0)c.s=1;else if(o<0)o=-o,c.s=-1;else{c.s=0,c.e=0,c.d=[0];return}if(o===~~o&&o<1e7){c.e=0,c.d=[o];return}return YN(c,o.toString())}else if(typeof o!="string")throw Error(ws+o);if(o.charCodeAt(0)===45?(o=o.slice(1),c.s=-1):c.s=1,dK.test(o))YN(c,o);else throw Error(ws+o)}if(i.prototype=Te,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.clone=J4,i.config=i.set=fK,e===void 0&&(e={}),e)for(r=["precision","rounding","toExpNeg","toExpPos","LN10"],t=0;t=i[t+1]&&r<=i[t+2])this[n]=r;else throw Error(ws+n+": "+r);if((r=e[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(ws+n+": "+r);return this}var Pb=J4(uK);Sr=new Pb(1);const ut=Pb;var mK=e=>e,Q4={},X4=e=>e===Q4,JN=e=>function t(){return arguments.length===0||arguments.length===1&&X4(arguments.length<=0?void 0:arguments[0])?t:e(...arguments)},Z4=(e,t)=>e===1?t:JN(function(){for(var n=arguments.length,r=new Array(n),i=0;ic!==Q4).length;return o>=e?t(...r):Z4(e-o,JN(function(){for(var c=arguments.length,u=new Array(c),m=0;mX4(h)?u.shift():h);return t(...f,...u)}))}),Ph=e=>Z4(e.length,e),Vv=(e,t)=>{for(var n=[],r=e;rArray.isArray(t)?t.map(e):Object.keys(t).map(n=>t[n]).map(e)),pK=function(){for(var t=arguments.length,n=new Array(t),r=0;rm(u),o(...arguments))}},Kv=e=>Array.isArray(e)?e.reverse():e.split("").reverse().join(""),eP=e=>{var t=null,n=null;return function(){for(var r=arguments.length,i=new Array(r),o=0;o{var m;return c===((m=t)===null||m===void 0?void 0:m[u])})||(t=i,n=e(...i)),n}};function tP(e){var t;return e===0?t=1:t=Math.floor(new ut(e).abs().log(10).toNumber())+1,t}function nP(e,t,n){for(var r=new ut(e),i=0,o=[];r.lt(t)&&i<1e5;)o.push(r.toNumber()),r=r.add(n),i++;return o}Ph((e,t,n)=>{var r=+e,i=+t;return r+n*(i-r)});Ph((e,t,n)=>{var r=t-+e;return r=r||1/0,(n-e)/r});Ph((e,t,n)=>{var r=t-+e;return r=r||1/0,Math.max(0,Math.min(1,(n-e)/r))});var rP=e=>{var[t,n]=e,[r,i]=[t,n];return t>n&&([r,i]=[n,t]),[r,i]},iP=(e,t,n)=>{if(e.lte(0))return new ut(0);var r=tP(e.toNumber()),i=new ut(10).pow(r),o=e.div(i),c=r!==1?.05:.1,u=new ut(Math.ceil(o.div(c).toNumber())).add(n).mul(c),m=u.mul(i);return t?new ut(m.toNumber()):new ut(Math.ceil(m.toNumber()))},gK=(e,t,n)=>{var r=new ut(1),i=new ut(e);if(!i.isint()&&n){var o=Math.abs(e);o<1?(r=new ut(10).pow(tP(e)-1),i=new ut(Math.floor(i.div(r).toNumber())).mul(r)):o>1&&(i=new ut(Math.floor(e)))}else e===0?i=new ut(Math.floor((t-1)/2)):n||(i=new ut(Math.floor(e)));var c=Math.floor((t-1)/2),u=pK(hK(m=>i.add(new ut(m-c).mul(r)).toNumber()),Vv);return u(0,t)},aP=function(t,n,r,i){var o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((n-t)/(r-1)))return{step:new ut(0),tickMin:new ut(0),tickMax:new ut(0)};var c=iP(new ut(n).sub(t).div(r-1),i,o),u;t<=0&&n>=0?u=new ut(0):(u=new ut(t).add(n).div(2),u=u.sub(new ut(u).mod(c)));var m=Math.ceil(u.sub(t).div(c).toNumber()),f=Math.ceil(new ut(n).sub(u).div(c).toNumber()),h=m+f+1;return h>r?aP(t,n,r,i,o+1):(h0?f+(r-h):f,m=n>0?m:m+(r-h)),{step:c,tickMin:u.sub(new ut(m).mul(c)),tickMax:u.add(new ut(f).mul(c))})};function yK(e){var[t,n]=e,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,o=Math.max(r,2),[c,u]=rP([t,n]);if(c===-1/0||u===1/0){var m=u===1/0?[c,...Vv(0,r-1).map(()=>1/0)]:[...Vv(0,r-1).map(()=>-1/0),u];return t>n?Kv(m):m}if(c===u)return gK(c,r,i);var{step:f,tickMin:h,tickMax:g}=aP(c,u,o,i,0),v=nP(h,g.add(new ut(.1).mul(f)),f);return t>n?Kv(v):v}function vK(e,t){var[n,r]=e,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[o,c]=rP([n,r]);if(o===-1/0||c===1/0)return[n,r];if(o===c)return[o];var u=Math.max(t,2),m=iP(new ut(c).sub(o).div(u-1),i,0),f=[...nP(new ut(o),new ut(c),m),c];return i===!1&&(f=f.map(h=>Math.round(h))),n>r?Kv(f):f}var xK=eP(yK),bK=eP(vK),oP=e=>e.rootProps.maxBarSize,wK=e=>e.rootProps.barGap,sP=e=>e.rootProps.barCategoryGap,SK=e=>e.rootProps.barSize,sd=e=>e.rootProps.stackOffset,Ib=e=>e.options.chartName,kb=e=>e.rootProps.syncId,lP=e=>e.rootProps.syncMethod,Db=e=>e.options.eventEmitter,AK=e=>e.rootProps.baseValue,Gt={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},aa={allowDuplicatedCategory:!0,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"category"},wr={allowDataOverflow:!1,allowDuplicatedCategory:!0,radiusAxisId:0,scale:"auto",tick:!0,tickCount:5,type:"number"},Ih=(e,t)=>{if(!(!e||!t))return e!=null&&e.reversed?[t[1],t[0]]:t},CK={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:aa.angleAxisId,includeHidden:!1,name:void 0,reversed:aa.reversed,scale:aa.scale,tick:aa.tick,tickCount:void 0,ticks:void 0,type:aa.type,unit:void 0},TK={allowDataOverflow:wr.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:wr.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:wr.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:wr.scale,tick:wr.tick,tickCount:wr.tickCount,ticks:void 0,type:wr.type,unit:void 0},EK={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:aa.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:aa.angleAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:aa.scale,tick:aa.tick,tickCount:void 0,ticks:void 0,type:"number",unit:void 0},NK={allowDataOverflow:wr.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:wr.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:wr.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:wr.scale,tick:wr.tick,tickCount:wr.tickCount,ticks:void 0,type:"category",unit:void 0},Rb=(e,t)=>e.polarAxis.angleAxis[t]!=null?e.polarAxis.angleAxis[t]:e.layout.layoutType==="radial"?EK:CK,Ob=(e,t)=>e.polarAxis.radiusAxis[t]!=null?e.polarAxis.radiusAxis[t]:e.layout.layoutType==="radial"?NK:TK,kh=e=>e.polarOptions,Lb=J([Ca,Ta,fn],o4),cP=J([kh,Lb],(e,t)=>{if(e!=null)return Un(e.innerRadius,t,0)}),uP=J([kh,Lb],(e,t)=>{if(e!=null)return Un(e.outerRadius,t,t*.8)}),_K=e=>{if(e==null)return[0,0];var{startAngle:t,endAngle:n}=e;return[t,n]},dP=J([kh],_K);J([Rb,dP],Ih);var fP=J([Lb,cP,uP],(e,t,n)=>{if(!(e==null||t==null||n==null))return[t,n]});J([Ob,fP],Ih);var mP=J([Ke,kh,cP,uP,Ca,Ta],(e,t,n,r,i,o)=>{if(!(e!=="centric"&&e!=="radial"||t==null||n==null||r==null)){var{cx:c,cy:u,startAngle:m,endAngle:f}=t;return{cx:Un(c,i,i/2),cy:Un(u,o,o/2),innerRadius:n,outerRadius:r,startAngle:m,endAngle:f,clockWise:!1}}}),kt=(e,t)=>t,ld=(e,t,n)=>n;function Dh(e){return e==null?void 0:e.id}function hP(e,t,n){var{chartData:r=[]}=t,{allowDuplicatedCategory:i,dataKey:o}=n,c=new Map;return e.forEach(u=>{var m,f=(m=u.data)!==null&&m!==void 0?m:r;if(!(f==null||f.length===0)){var h=Dh(u);f.forEach((g,v)=>{var b=o==null||i?v:String(gt(g,o,null)),T=gt(g,u.dataKey,0),C;c.has(b)?C=c.get(b):C={},Object.assign(C,{[h]:T}),c.set(b,C)})}}),Array.from(c.values())}function Rh(e){return e.stackId!=null&&e.dataKey!=null}var Oh=(e,t)=>e===t?!0:e==null||t==null?!1:e[0]===t[0]&&e[1]===t[1];function Lh(e,t){return Array.isArray(e)&&Array.isArray(t)&&e.length===0&&t.length===0?!0:e===t}function jK(e,t){if(e.length===t.length){for(var n=0;n{var t=Ke(e);return t==="horizontal"?"xAxis":t==="vertical"?"yAxis":t==="centric"?"angleAxis":"radiusAxis"},fc=e=>e.tooltip.settings.axisId;function QN(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Fm(e){for(var t=1;te.cartesianAxis.xAxis[t],Pi=(e,t)=>{var n=pP(e,t);return n??xr},br={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:Yv,hide:!0,id:0,includeHidden:!1,interval:"preserveEnd",minTickGap:5,mirror:!1,name:void 0,orientation:"left",padding:{top:0,bottom:0},reversed:!1,scale:"auto",tick:!0,tickCount:5,tickFormatter:void 0,ticks:void 0,type:"number",unit:void 0,width:ed},gP=(e,t)=>e.cartesianAxis.yAxis[t],Ii=(e,t)=>{var n=gP(e,t);return n??br},kK={domain:[0,"auto"],includeHidden:!1,reversed:!1,allowDataOverflow:!1,allowDuplicatedCategory:!1,dataKey:void 0,id:0,name:"",range:[64,64],scale:"auto",type:"number",unit:""},Ub=(e,t)=>{var n=e.cartesianAxis.zAxis[t];return n??kK},Ut=(e,t,n)=>{switch(t){case"xAxis":return Pi(e,n);case"yAxis":return Ii(e,n);case"zAxis":return Ub(e,n);case"angleAxis":return Rb(e,n);case"radiusAxis":return Ob(e,n);default:throw new Error("Unexpected axis type: ".concat(t))}},DK=(e,t,n)=>{switch(t){case"xAxis":return Pi(e,n);case"yAxis":return Ii(e,n);default:throw new Error("Unexpected axis type: ".concat(t))}},cd=(e,t,n)=>{switch(t){case"xAxis":return Pi(e,n);case"yAxis":return Ii(e,n);case"angleAxis":return Rb(e,n);case"radiusAxis":return Ob(e,n);default:throw new Error("Unexpected axis type: ".concat(t))}},yP=e=>e.graphicalItems.cartesianItems.some(t=>t.type==="bar")||e.graphicalItems.polarItems.some(t=>t.type==="radialBar");function Bb(e,t){return n=>{switch(e){case"xAxis":return"xAxisId"in n&&n.xAxisId===t;case"yAxis":return"yAxisId"in n&&n.yAxisId===t;case"zAxis":return"zAxisId"in n&&n.zAxisId===t;case"angleAxis":return"angleAxisId"in n&&n.angleAxisId===t;case"radiusAxis":return"radiusAxisId"in n&&n.radiusAxisId===t;default:return!1}}}var ud=e=>e.graphicalItems.cartesianItems,RK=J([kt,ld],Bb),zb=(e,t,n)=>e.filter(n).filter(r=>(t==null?void 0:t.includeHidden)===!0?!0:!r.hide),dd=J([ud,Ut,RK],zb,{memoizeOptions:{resultEqualityCheck:Lh}}),vP=J([dd],e=>e.filter(t=>t.type==="area"||t.type==="bar").filter(Rh)),xP=e=>e.filter(t=>!("stackId"in t)||t.stackId===void 0),OK=J([dd],xP),Fb=e=>e.map(t=>t.data).filter(Boolean).flat(1),LK=J([dd],Fb,{memoizeOptions:{resultEqualityCheck:Lh}}),qb=(e,t)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=t;return e.length>0?e:n.slice(r,i+1)},Gb=J([LK,od],qb),$b=(e,t,n)=>(t==null?void 0:t.dataKey)!=null?e.map(r=>({value:gt(r,t.dataKey)})):n.length>0?n.map(r=>r.dataKey).flatMap(r=>e.map(i=>({value:gt(i,r)}))):e.map(r=>({value:r})),Uh=J([Gb,Ut,dd],$b);function bP(e,t){switch(e){case"xAxis":return t.direction==="x";case"yAxis":return t.direction==="y";default:return!1}}function am(e){if(Vr(e)||e instanceof Date){var t=Number(e);if(dt(t))return t}}function XN(e){if(Array.isArray(e)){var t=[am(e[0]),am(e[1])];return Ns(t)?t:void 0}var n=am(e);if(n!=null)return[n,n]}function xa(e){return e.map(am).filter(Vz)}function UK(e,t,n){return!n||typeof t!="number"||sr(t)?[]:n.length?xa(n.flatMap(r=>{var i=gt(e,r.dataKey),o,c;if(Array.isArray(i)?[o,c]=i:o=c=i,!(!dt(o)||!dt(c)))return[t-o,t+c]})):[]}var gn=e=>{var t=pn(e),n=fc(e);return cd(e,t,n)},wP=J([gn],e=>e==null?void 0:e.dataKey),BK=J([vP,od,gn],hP),SP=(e,t,n)=>{var r={},i=t.reduce((o,c)=>(c.stackId==null||(o[c.stackId]==null&&(o[c.stackId]=[]),o[c.stackId].push(c)),o),r);return Object.fromEntries(Object.entries(i).map(o=>{var[c,u]=o,m=u.map(Dh);return[c,{stackedData:pq(e,m,n),graphicalItems:u}]}))},Fu=J([BK,vP,sd],SP),AP=(e,t,n,r)=>{var{dataStartIndex:i,dataEndIndex:o}=t;if(r==null&&n!=="zAxis"){var c=xq(e,i,o);if(!(c!=null&&c[0]===0&&c[1]===0))return c}},zK=J([Ut],e=>e.allowDataOverflow),Hb=e=>{var t;if(e==null||!("domain"in e))return Yv;if(e.domain!=null)return e.domain;if(e.ticks!=null){if(e.type==="number"){var n=xa(e.ticks);return[Math.min(...n),Math.max(...n)]}if(e.type==="category")return e.ticks.map(String)}return(t=e==null?void 0:e.domain)!==null&&t!==void 0?t:Yv},Vb=J([Ut],Hb),Kb=J([Vb,zK],H4),FK=J([Fu,Mo,kt,Kb],AP,{memoizeOptions:{resultEqualityCheck:Oh}}),Bh=e=>e.errorBars,qK=(e,t,n)=>e.flatMap(r=>t[r.id]).filter(Boolean).filter(r=>bP(n,r)),qm=function(){for(var t=arguments.length,n=new Array(t),r=0;r{var o,c;if(n.length>0&&e.forEach(u=>{n.forEach(m=>{var f,h,g=(f=r[m.id])===null||f===void 0?void 0:f.filter(N=>bP(i,N)),v=gt(u,(h=t.dataKey)!==null&&h!==void 0?h:m.dataKey),b=UK(u,v,g);if(b.length>=2){var T=Math.min(...b),C=Math.max(...b);(o==null||Tc)&&(c=C)}var E=XN(v);E!=null&&(o=o==null?E[0]:Math.min(o,E[0]),c=c==null?E[1]:Math.max(c,E[1]))})}),(t==null?void 0:t.dataKey)!=null&&e.forEach(u=>{var m=XN(gt(u,t.dataKey));m!=null&&(o=o==null?m[0]:Math.min(o,m[0]),c=c==null?m[1]:Math.max(c,m[1]))}),dt(o)&&dt(c))return[o,c]},GK=J([Gb,Ut,OK,Bh,kt],Yb,{memoizeOptions:{resultEqualityCheck:Oh}});function $K(e){var{value:t}=e;if(Vr(t)||t instanceof Date)return t}var HK=(e,t,n)=>{var r=e.map($K).filter(i=>i!=null);return n&&(t.dataKey==null||t.allowDuplicatedCategory&&Y3(r))?u4(0,e.length):t.allowDuplicatedCategory?r:Array.from(new Set(r))},CP=e=>e.referenceElements.dots,mc=(e,t,n)=>e.filter(r=>r.ifOverflow==="extendDomain").filter(r=>t==="xAxis"?r.xAxisId===n:r.yAxisId===n),VK=J([CP,kt,ld],mc),TP=e=>e.referenceElements.areas,KK=J([TP,kt,ld],mc),EP=e=>e.referenceElements.lines,YK=J([EP,kt,ld],mc),NP=(e,t)=>{var n=xa(e.map(r=>t==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},WK=J(VK,kt,NP),_P=(e,t)=>{var n=xa(e.flatMap(r=>[t==="xAxis"?r.x1:r.y1,t==="xAxis"?r.x2:r.y2]));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},JK=J([KK,kt],_P);function QK(e){var t;if(e.x!=null)return xa([e.x]);var n=(t=e.segment)===null||t===void 0?void 0:t.map(r=>r.x);return n==null||n.length===0?[]:xa(n)}function XK(e){var t;if(e.y!=null)return xa([e.y]);var n=(t=e.segment)===null||t===void 0?void 0:t.map(r=>r.y);return n==null||n.length===0?[]:xa(n)}var jP=(e,t)=>{var n=e.flatMap(r=>t==="xAxis"?QK(r):XK(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},ZK=J([YK,kt],jP),eY=J(WK,ZK,JK,(e,t,n)=>qm(e,n,t)),Wb=(e,t,n,r,i,o,c,u)=>{if(n!=null)return n;var m=c==="vertical"&&u==="xAxis"||c==="horizontal"&&u==="yAxis",f=m?qm(r,o,i):qm(o,i);return cK(t,f,e.allowDataOverflow)},tY=J([Ut,Vb,Kb,FK,GK,eY,Ke,kt],Wb,{memoizeOptions:{resultEqualityCheck:Oh}}),nY=[0,1],Jb=(e,t,n,r,i,o,c)=>{if(!((e==null||n==null||n.length===0)&&c===void 0)){var{dataKey:u,type:m}=e,f=Mi(t,o);if(f&&u==null){var h;return u4(0,(h=n==null?void 0:n.length)!==null&&h!==void 0?h:0)}return m==="category"?HK(r,e,f):i==="expand"?nY:c}},Qb=J([Ut,Ke,Gb,Uh,sd,kt,tY],Jb),MP=(e,t,n,r,i)=>{if(e!=null){var{scale:o,type:c}=e;if(o==="auto")return t==="radial"&&i==="radiusAxis"?"band":t==="radial"&&i==="angleAxis"?"linear":c==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?"point":c==="category"?"band":"linear";if(typeof o=="string"){var u="scale".concat(Ju(o));return u in Eu?u:"point"}}},hc=J([Ut,Ke,yP,Ib,kt],MP);function rY(e){if(e!=null){if(e in Eu)return Eu[e]();var t="scale".concat(Ju(e));if(t in Eu)return Eu[t]()}}function Xb(e,t,n,r){if(!(n==null||r==null)){if(typeof e.scale=="function")return e.scale.copy().domain(n).range(r);var i=rY(t);if(i!=null){var o=i.domain(n).range(r);return uq(o),o}}}var Zb=(e,t,n)=>{var r=Hb(t);if(!(n!=="auto"&&n!=="linear")){if(t!=null&&t.tickCount&&Array.isArray(r)&&(r[0]==="auto"||r[1]==="auto")&&Ns(e))return xK(e,t.tickCount,t.allowDecimals);if(t!=null&&t.tickCount&&t.type==="number"&&Ns(e))return bK(e,t.tickCount,t.allowDecimals)}},e1=J([Qb,cd,hc],Zb),t1=(e,t,n,r)=>{if(r!=="angleAxis"&&(e==null?void 0:e.type)==="number"&&Ns(t)&&Array.isArray(n)&&n.length>0){var i=t[0],o=n[0],c=t[1],u=n[n.length-1];return[Math.min(i,o),Math.max(c,u)]}return t},iY=J([Ut,Qb,e1,kt],t1),aY=J(Uh,Ut,(e,t)=>{if(!(!t||t.type!=="number")){var n=1/0,r=Array.from(xa(e.map(u=>u.value))).sort((u,m)=>u-m);if(r.length<2)return 1/0;var i=r[r.length-1]-r[0];if(i===0)return 1/0;for(var o=0;or,(e,t,n,r,i)=>{if(!dt(e))return 0;var o=t==="vertical"?r.height:r.width;if(i==="gap")return e*o/2;if(i==="no-gap"){var c=Un(n,e*o),u=e*o/2;return u-c-(u-c)/o*c}return 0}),oY=(e,t)=>{var n=Pi(e,t);return n==null||typeof n.padding!="string"?0:PP(e,"xAxis",t,n.padding)},sY=(e,t)=>{var n=Ii(e,t);return n==null||typeof n.padding!="string"?0:PP(e,"yAxis",t,n.padding)},lY=J(Pi,oY,(e,t)=>{var n,r;if(e==null)return{left:0,right:0};var{padding:i}=e;return typeof i=="string"?{left:t,right:t}:{left:((n=i.left)!==null&&n!==void 0?n:0)+t,right:((r=i.right)!==null&&r!==void 0?r:0)+t}}),cY=J(Ii,sY,(e,t)=>{var n,r;if(e==null)return{top:0,bottom:0};var{padding:i}=e;return typeof i=="string"?{top:t,bottom:t}:{top:((n=i.top)!==null&&n!==void 0?n:0)+t,bottom:((r=i.bottom)!==null&&r!==void 0?r:0)+t}}),uY=J([fn,lY,Ah,Sh,(e,t,n)=>n],(e,t,n,r,i)=>{var{padding:o}=r;return i?[o.left,n.width-o.right]:[e.left+t.left,e.left+e.width-t.right]}),dY=J([fn,Ke,cY,Ah,Sh,(e,t,n)=>n],(e,t,n,r,i,o)=>{var{padding:c}=i;return o?[r.height-c.bottom,c.top]:t==="horizontal"?[e.top+e.height-n.bottom,e.top+n.top]:[e.top+n.top,e.top+e.height-n.bottom]}),fd=(e,t,n,r)=>{var i;switch(t){case"xAxis":return uY(e,n,r);case"yAxis":return dY(e,n,r);case"zAxis":return(i=Ub(e,n))===null||i===void 0?void 0:i.range;case"angleAxis":return dP(e);case"radiusAxis":return fP(e,n);default:return}},IP=J([Ut,fd],Ih),Ao=J([Ut,hc,iY,IP],Xb);J([dd,Bh,kt],qK);function kP(e,t){return e.idt.id?1:0}var zh=(e,t)=>t,Fh=(e,t,n)=>n,fY=J(bh,zh,Fh,(e,t,n)=>e.filter(r=>r.orientation===t).filter(r=>r.mirror===n).sort(kP)),mY=J(wh,zh,Fh,(e,t,n)=>e.filter(r=>r.orientation===t).filter(r=>r.mirror===n).sort(kP)),DP=(e,t)=>({width:e.width,height:t.height}),hY=(e,t)=>{var n=typeof t.width=="number"?t.width:ed;return{width:n,height:e.height}},RP=J(fn,Pi,DP),pY=(e,t,n)=>{switch(t){case"top":return e.top;case"bottom":return n-e.bottom;default:return 0}},gY=(e,t,n)=>{switch(t){case"left":return e.left;case"right":return n-e.right;default:return 0}},yY=J(Ta,fn,fY,zh,Fh,(e,t,n,r,i)=>{var o={},c;return n.forEach(u=>{var m=DP(t,u);c==null&&(c=pY(t,r,e));var f=r==="top"&&!i||r==="bottom"&&i;o[u.id]=c-Number(f)*m.height,c+=(f?-1:1)*m.height}),o}),vY=J(Ca,fn,mY,zh,Fh,(e,t,n,r,i)=>{var o={},c;return n.forEach(u=>{var m=hY(t,u);c==null&&(c=gY(t,r,e));var f=r==="left"&&!i||r==="right"&&i;o[u.id]=c-Number(f)*m.width,c+=(f?-1:1)*m.width}),o}),xY=(e,t)=>{var n=Pi(e,t);if(n!=null)return yY(e,n.orientation,n.mirror)},bY=J([fn,Pi,xY,(e,t)=>t],(e,t,n,r)=>{if(t!=null){var i=n==null?void 0:n[r];return i==null?{x:e.left,y:0}:{x:e.left,y:i}}}),wY=(e,t)=>{var n=Ii(e,t);if(n!=null)return vY(e,n.orientation,n.mirror)},SY=J([fn,Ii,wY,(e,t)=>t],(e,t,n,r)=>{if(t!=null){var i=n==null?void 0:n[r];return i==null?{x:0,y:e.top}:{x:i,y:e.top}}}),OP=J(fn,Ii,(e,t)=>{var n=typeof t.width=="number"?t.width:ed;return{width:n,height:e.height}}),ZN=(e,t,n)=>{switch(t){case"xAxis":return RP(e,n).width;case"yAxis":return OP(e,n).height;default:return}},LP=(e,t,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:o,dataKey:c}=n,u=Mi(e,r),m=t.map(f=>f.value);if(c&&u&&o==="category"&&i&&Y3(m))return m}},n1=J([Ke,Uh,Ut,kt],LP),UP=(e,t,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:o}=n,c=Mi(e,r);if(c&&(i==="number"||o!=="auto"))return t.map(u=>u.value)}},r1=J([Ke,Uh,cd,kt],UP),e_=J([Ke,DK,hc,Ao,n1,r1,fd,e1,kt],(e,t,n,r,i,o,c,u,m)=>{if(t!=null){var f=Mi(e,m);return{angle:t.angle,interval:t.interval,minTickGap:t.minTickGap,orientation:t.orientation,tick:t.tick,tickCount:t.tickCount,tickFormatter:t.tickFormatter,ticks:t.ticks,type:t.type,unit:t.unit,axisType:m,categoricalDomain:o,duplicateDomain:i,isCategorical:f,niceTicks:u,range:c,realScaleType:n,scale:r}}}),AY=(e,t,n,r,i,o,c,u,m)=>{if(!(t==null||r==null)){var f=Mi(e,m),{type:h,ticks:g,tickCount:v}=t,b=n==="scaleBand"&&typeof r.bandwidth=="function"?r.bandwidth()/2:2,T=h==="category"&&r.bandwidth?r.bandwidth()/b:0;T=m==="angleAxis"&&o!=null&&o.length>=2?bn(o[0]-o[1])*2*T:T;var C=g||i;if(C){var E=C.map((N,I)=>{var P=c?c.indexOf(N):N;return{index:I,coordinate:r(P)+T,value:N,offset:T}});return E.filter(N=>dt(N.coordinate))}return f&&u?u.map((N,I)=>({coordinate:r(N)+T,value:N,index:I,offset:T})).filter(N=>dt(N.coordinate)):r.ticks?r.ticks(v).map(N=>({coordinate:r(N)+T,value:N,offset:T})):r.domain().map((N,I)=>({coordinate:r(N)+T,value:c?c[N]:N,index:I,offset:T}))}},BP=J([Ke,cd,hc,Ao,e1,fd,n1,r1,kt],AY),CY=(e,t,n,r,i,o,c)=>{if(!(t==null||n==null||r==null||r[0]===r[1])){var u=Mi(e,c),{tickCount:m}=t,f=0;return f=c==="angleAxis"&&(r==null?void 0:r.length)>=2?bn(r[0]-r[1])*2*f:f,u&&o?o.map((h,g)=>({coordinate:n(h)+f,value:h,index:g,offset:f})):n.ticks?n.ticks(m).map(h=>({coordinate:n(h)+f,value:h,offset:f})):n.domain().map((h,g)=>({coordinate:n(h)+f,value:i?i[h]:h,index:g,offset:f}))}},Ni=J([Ke,cd,Ao,fd,n1,r1,kt],CY),_i=J(Ut,Ao,(e,t)=>{if(!(e==null||t==null))return Fm(Fm({},e),{},{scale:t})}),TY=J([Ut,hc,Qb,IP],Xb);J((e,t,n)=>Ub(e,n),TY,(e,t)=>{if(!(e==null||t==null))return Fm(Fm({},e),{},{scale:t})});var EY=J([Ke,bh,wh],(e,t,n)=>{switch(e){case"horizontal":return t.some(r=>r.reversed)?"right-to-left":"left-to-right";case"vertical":return n.some(r=>r.reversed)?"bottom-to-top":"top-to-bottom";case"centric":case"radial":return"left-to-right";default:return}}),zP=e=>e.options.defaultTooltipEventType,FP=e=>e.options.validateTooltipEventTypes;function qP(e,t,n){if(e==null)return t;var r=e?"axis":"item";return n==null?t:n.includes(r)?r:t}function i1(e,t){var n=zP(e),r=FP(e);return qP(t,n,r)}function NY(e){return Se(t=>i1(t,e))}var GP=(e,t)=>{var n,r=Number(t);if(!(sr(r)||t==null))return r>=0?e==null||(n=e[r])===null||n===void 0?void 0:n.value:void 0},_Y=e=>e.tooltip.settings,lo={active:!1,index:null,dataKey:void 0,coordinate:void 0},jY={itemInteraction:{click:lo,hover:lo},axisInteraction:{click:lo,hover:lo},keyboardInteraction:lo,syncInteraction:{active:!1,index:null,dataKey:void 0,label:void 0,coordinate:void 0,sourceViewBox:void 0},tooltipItemPayloads:[],settings:{shared:void 0,trigger:"hover",axisId:0,active:!1,defaultIndex:void 0}},$P=lr({name:"tooltip",initialState:jY,reducers:{addTooltipEntrySettings:{reducer(e,t){e.tooltipItemPayloads.push(t.payload)},prepare:un()},removeTooltipEntrySettings:{reducer(e,t){var n=ca(e).tooltipItemPayloads.indexOf(t.payload);n>-1&&e.tooltipItemPayloads.splice(n,1)},prepare:un()},setTooltipSettingsState(e,t){e.settings=t.payload},setActiveMouseOverItemIndex(e,t){e.syncInteraction.active=!1,e.keyboardInteraction.active=!1,e.itemInteraction.hover.active=!0,e.itemInteraction.hover.index=t.payload.activeIndex,e.itemInteraction.hover.dataKey=t.payload.activeDataKey,e.itemInteraction.hover.coordinate=t.payload.activeCoordinate},mouseLeaveChart(e){e.itemInteraction.hover.active=!1,e.axisInteraction.hover.active=!1},mouseLeaveItem(e){e.itemInteraction.hover.active=!1},setActiveClickItemIndex(e,t){e.syncInteraction.active=!1,e.itemInteraction.click.active=!0,e.keyboardInteraction.active=!1,e.itemInteraction.click.index=t.payload.activeIndex,e.itemInteraction.click.dataKey=t.payload.activeDataKey,e.itemInteraction.click.coordinate=t.payload.activeCoordinate},setMouseOverAxisIndex(e,t){e.syncInteraction.active=!1,e.axisInteraction.hover.active=!0,e.keyboardInteraction.active=!1,e.axisInteraction.hover.index=t.payload.activeIndex,e.axisInteraction.hover.dataKey=t.payload.activeDataKey,e.axisInteraction.hover.coordinate=t.payload.activeCoordinate},setMouseClickAxisIndex(e,t){e.syncInteraction.active=!1,e.keyboardInteraction.active=!1,e.axisInteraction.click.active=!0,e.axisInteraction.click.index=t.payload.activeIndex,e.axisInteraction.click.dataKey=t.payload.activeDataKey,e.axisInteraction.click.coordinate=t.payload.activeCoordinate},setSyncInteraction(e,t){e.syncInteraction=t.payload},setKeyboardInteraction(e,t){e.keyboardInteraction.active=t.payload.active,e.keyboardInteraction.index=t.payload.activeIndex,e.keyboardInteraction.coordinate=t.payload.activeCoordinate,e.keyboardInteraction.dataKey=t.payload.activeDataKey}}}),{addTooltipEntrySettings:MY,removeTooltipEntrySettings:PY,setTooltipSettingsState:IY,setActiveMouseOverItemIndex:HP,mouseLeaveItem:kY,mouseLeaveChart:VP,setActiveClickItemIndex:DY,setMouseOverAxisIndex:KP,setMouseClickAxisIndex:RY,setSyncInteraction:Wv,setKeyboardInteraction:Jv}=$P.actions,OY=$P.reducer;function t_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Wf(e){for(var t=1;t{if(t==null)return lo;var i=zY(e,t,n);if(i==null)return lo;if(i.active)return i;if(e.keyboardInteraction.active)return e.keyboardInteraction;if(e.syncInteraction.active&&e.syncInteraction.index!=null)return e.syncInteraction;var o=e.settings.active===!0;if(FY(i)){if(o)return Wf(Wf({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r};return Wf(Wf({},lo),{},{coordinate:i.coordinate})},a1=(e,t)=>{var n=e==null?void 0:e.index;if(n==null)return null;var r=Number(n);if(!dt(r))return n;var i=0,o=1/0;return t.length>0&&(o=t.length-1),String(Math.max(i,Math.min(r,o)))},WP=(e,t,n,r,i,o,c,u)=>{if(!(o==null||u==null)){var m=c[0],f=m==null?void 0:u(m.positions,o);if(f!=null)return f;var h=i==null?void 0:i[Number(o)];if(h)switch(n){case"horizontal":return{x:h.coordinate,y:(r.top+t)/2};default:return{x:(r.left+e)/2,y:h.coordinate}}}},JP=(e,t,n,r)=>{if(t==="axis")return e.tooltipItemPayloads;if(e.tooltipItemPayloads.length===0)return[];var i;return n==="hover"?i=e.itemInteraction.hover.dataKey:i=e.itemInteraction.click.dataKey,i==null&&r!=null?[e.tooltipItemPayloads[0]]:e.tooltipItemPayloads.filter(o=>{var c;return((c=o.settings)===null||c===void 0?void 0:c.dataKey)===i})},md=e=>e.options.tooltipPayloadSearcher,pc=e=>e.tooltip;function n_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function r_(e){for(var t=1;t{if(!(t==null||o==null)){var{chartData:u,computedData:m,dataStartIndex:f,dataEndIndex:h}=n,g=[];return e.reduce((v,b)=>{var T,{dataDefinedOnItem:C,settings:E}=b,N=HY(C,u),I=Array.isArray(N)?BM(N,f,h):N,P=(T=E==null?void 0:E.dataKey)!==null&&T!==void 0?T:r,M=E==null?void 0:E.nameKey,j;if(r&&Array.isArray(I)&&!Array.isArray(I[0])&&c==="axis"?j=W3(I,r,i):j=o(I,t,m,M),Array.isArray(j))j.forEach(R=>{var F=r_(r_({},E),{},{name:R.name,unit:R.unit,color:void 0,fill:void 0});v.push(jE({tooltipEntrySettings:F,dataKey:R.dataKey,payload:R.payload,value:gt(R.payload,R.dataKey),name:R.name}))});else{var k;v.push(jE({tooltipEntrySettings:E,dataKey:P,payload:j,value:gt(j,P),name:(k=gt(j,M))!==null&&k!==void 0?k:E==null?void 0:E.name}))}return v},g)}},o1=J([gn,Ke,yP,Ib,pn],MP),VY=J([e=>e.graphicalItems.cartesianItems,e=>e.graphicalItems.polarItems],(e,t)=>[...e,...t]),KY=J([pn,fc],Bb),hd=J([VY,gn,KY],zb,{memoizeOptions:{resultEqualityCheck:Lh}}),YY=J([hd],e=>e.filter(Rh)),WY=J([hd],Fb,{memoizeOptions:{resultEqualityCheck:Lh}}),gc=J([WY,Mo],qb),JY=J([YY,Mo,gn],hP),s1=J([gc,gn,hd],$b),XP=J([gn],Hb),QY=J([gn],e=>e.allowDataOverflow),ZP=J([XP,QY],H4),XY=J([hd],e=>e.filter(Rh)),ZY=J([JY,XY,sd],SP),eW=J([ZY,Mo,pn,ZP],AP),tW=J([hd],xP),nW=J([gc,gn,tW,Bh,pn],Yb,{memoizeOptions:{resultEqualityCheck:Oh}}),rW=J([CP,pn,fc],mc),iW=J([rW,pn],NP),aW=J([TP,pn,fc],mc),oW=J([aW,pn],_P),sW=J([EP,pn,fc],mc),lW=J([sW,pn],jP),cW=J([iW,lW,oW],qm),uW=J([gn,XP,ZP,eW,nW,cW,Ke,pn],Wb),e5=J([gn,Ke,gc,s1,sd,pn,uW],Jb),dW=J([e5,gn,o1],Zb),fW=J([gn,e5,dW,pn],t1),t5=e=>{var t=pn(e),n=fc(e),r=!1;return fd(e,t,n,r)},n5=J([gn,t5],Ih),r5=J([gn,o1,fW,n5],Xb),mW=J([Ke,s1,gn,pn],LP),hW=J([Ke,s1,gn,pn],UP),pW=(e,t,n,r,i,o,c,u)=>{if(t){var{type:m}=t,f=Mi(e,u);if(r){var h=n==="scaleBand"&&r.bandwidth?r.bandwidth()/2:2,g=m==="category"&&r.bandwidth?r.bandwidth()/h:0;return g=u==="angleAxis"&&i!=null&&(i==null?void 0:i.length)>=2?bn(i[0]-i[1])*2*g:g,f&&c?c.map((v,b)=>({coordinate:r(v)+g,value:v,index:b,offset:g})):r.domain().map((v,b)=>({coordinate:r(v)+g,value:o?o[v]:v,index:b,offset:g}))}}},_a=J([Ke,gn,o1,r5,t5,mW,hW,pn],pW),l1=J([zP,FP,_Y],(e,t,n)=>qP(n.shared,e,t)),i5=e=>e.tooltip.settings.trigger,c1=e=>e.tooltip.settings.defaultIndex,qh=J([pc,l1,i5,c1],YP),Co=J([qh,gc],a1),a5=J([_a,Co],GP),o5=J([qh],e=>{if(e)return e.dataKey}),s5=J([pc,l1,i5,c1],JP),gW=J([Ca,Ta,Ke,fn,_a,c1,s5,md],WP),yW=J([qh,gW],(e,t)=>e!=null&&e.coordinate?e.coordinate:t),vW=J([qh],e=>e.active),xW=J([s5,Co,Mo,wP,a5,md,l1],QP),bW=J([xW],e=>{if(e!=null){var t=e.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(t))}});function i_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function a_(e){for(var t=1;tSe(gn),TW=()=>{var e=CW(),t=Se(_a),n=Se(r5);return So(!e||!n?void 0:a_(a_({},e),{},{scale:n}),t)};function o_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Tl(e){for(var t=1;t{var i=t.find(o=>o&&o.index===n);if(i){if(e==="horizontal")return{x:i.coordinate,y:r.chartY};if(e==="vertical")return{x:r.chartX,y:i.coordinate}}return{x:0,y:0}},MW=(e,t,n,r)=>{var i=t.find(f=>f&&f.index===n);if(i){if(e==="centric"){var o=i.coordinate,{radius:c}=r;return Tl(Tl(Tl({},r),an(r.cx,r.cy,c,o)),{},{angle:o,radius:c})}var u=i.coordinate,{angle:m}=r;return Tl(Tl(Tl({},r),an(r.cx,r.cy,u,m)),{},{angle:m,radius:u})}return{angle:0,clockWise:!1,cx:0,cy:0,endAngle:0,innerRadius:0,outerRadius:0,radius:0,startAngle:0,x:0,y:0}};function PW(e,t){var{chartX:n,chartY:r}=e;return n>=t.left&&n<=t.left+t.width&&r>=t.top&&r<=t.top+t.height}var l5=(e,t,n,r,i)=>{var o,c=-1,u=(o=t==null?void 0:t.length)!==null&&o!==void 0?o:0;if(u<=1||e==null)return 0;if(r==="angleAxis"&&i!=null&&Math.abs(Math.abs(i[1]-i[0])-360)<=1e-6)for(var m=0;m0?n[m-1].coordinate:n[u-1].coordinate,h=n[m].coordinate,g=m>=u-1?n[0].coordinate:n[m+1].coordinate,v=void 0;if(bn(h-f)!==bn(g-h)){var b=[];if(bn(g-h)===bn(i[1]-i[0])){v=g;var T=h+i[1]-i[0];b[0]=Math.min(T,(T+f)/2),b[1]=Math.max(T,(T+f)/2)}else{v=f;var C=g+i[1]-i[0];b[0]=Math.min(h,(C+h)/2),b[1]=Math.max(h,(C+h)/2)}var E=[Math.min(h,(v+h)/2),Math.max(h,(v+h)/2)];if(e>E[0]&&e<=E[1]||e>=b[0]&&e<=b[1]){({index:c}=n[m]);break}}else{var N=Math.min(f,g),I=Math.max(f,g);if(e>(N+h)/2&&e<=(I+h)/2){({index:c}=n[m]);break}}}else if(t){for(var P=0;P0&&P(t[P].coordinate+t[P-1].coordinate)/2&&e<=(t[P].coordinate+t[P+1].coordinate)/2||P===u-1&&e>(t[P].coordinate+t[P-1].coordinate)/2){({index:c}=t[P]);break}}return c},c5=()=>Se(Ib),u1=(e,t)=>t,u5=(e,t,n)=>n,d1=(e,t,n,r)=>r,IW=J(_a,e=>hh(e,t=>t.coordinate)),f1=J([pc,u1,u5,d1],YP),d5=J([f1,gc],a1),kW=(e,t,n)=>{if(t!=null){var r=pc(e);return t==="axis"?n==="hover"?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n==="hover"?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},f5=J([pc,u1,u5,d1],JP),Gm=J([Ca,Ta,Ke,fn,_a,d1,f5,md],WP),DW=J([f1,Gm],(e,t)=>{var n;return(n=e.coordinate)!==null&&n!==void 0?n:t}),m5=J([_a,d5],GP),RW=J([f5,d5,Mo,wP,m5,md,u1],QP),OW=J([f1],e=>({isActive:e.active,activeIndex:e.index})),LW=(e,t,n,r,i,o,c)=>{if(!(!e||!n||!r||!i)&&PW(e,c)){var u=bq(e,t),m=l5(u,o,i,n,r),f=jW(t,i,m,e);return{activeIndex:String(m),activeCoordinate:f}}},UW=(e,t,n,r,i,o,c)=>{if(!(!e||!r||!i||!o||!n)){var u=T$(e,n);if(u){var m=wq(u,t),f=l5(m,c,o,r,i),h=MW(t,o,f,u);return{activeIndex:String(f),activeCoordinate:h}}}},BW=(e,t,n,r,i,o,c,u)=>{if(!(!e||!t||!r||!i||!o))return t==="horizontal"||t==="vertical"?LW(e,t,r,i,o,c,u):UW(e,t,n,r,i,o,c)},zW=J(e=>e.zIndex.zIndexMap,(e,t)=>t,(e,t,n)=>n,(e,t,n)=>{if(t!=null){var r=e[t];if(r!=null)return n?r.panoramaElementId:r.elementId}}),FW=J(e=>e.zIndex.zIndexMap,e=>{var t=Object.keys(e).map(r=>parseInt(r,10)).concat(Object.values(Gt)),n=Array.from(new Set(t));return n.sort((r,i)=>r-i)},{memoizeOptions:{resultEqualityCheck:jK}});function s_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function l_(e){for(var t=1;tl_(l_({},e),{},{[t]:{elementId:void 0,panoramaElementId:void 0,consumers:0}}),HW)},KW=new Set(Object.values(Gt));function YW(e){return KW.has(e)}var h5=lr({name:"zIndex",initialState:VW,reducers:{registerZIndexPortal:{reducer:(e,t)=>{var{zIndex:n}=t.payload;e.zIndexMap[n]?e.zIndexMap[n].consumers+=1:e.zIndexMap[n]={consumers:1,elementId:void 0,panoramaElementId:void 0}},prepare:un()},unregisterZIndexPortal:{reducer:(e,t)=>{var{zIndex:n}=t.payload;e.zIndexMap[n]&&(e.zIndexMap[n].consumers-=1,e.zIndexMap[n].consumers<=0&&!YW(n)&&delete e.zIndexMap[n])},prepare:un()},registerZIndexPortalId:{reducer:(e,t)=>{var{zIndex:n,elementId:r,isPanorama:i}=t.payload;e.zIndexMap[n]?i?e.zIndexMap[n].panoramaElementId=r:e.zIndexMap[n].elementId=r:e.zIndexMap[n]={consumers:0,elementId:i?void 0:r,panoramaElementId:i?r:void 0}},prepare:un()},unregisterZIndexPortalId:{reducer:(e,t)=>{var{zIndex:n}=t.payload;e.zIndexMap[n]&&(t.payload.isPanorama?e.zIndexMap[n].panoramaElementId=void 0:e.zIndexMap[n].elementId=void 0)},prepare:un()}}}),{registerZIndexPortal:WW,unregisterZIndexPortal:JW,registerZIndexPortalId:QW,unregisterZIndexPortalId:XW}=h5.actions,ZW=h5.reducer;function Bn(e){var{zIndex:t,children:n}=e,r=Xq(),i=r&&t!==void 0&&t!==0,o=mn(),c=bt();S.useLayoutEffect(()=>i?(c(WW({zIndex:t})),()=>{c(JW({zIndex:t}))}):Ds,[c,t,i]);var u=Se(f=>zW(f,t,o));if(!i)return n;if(!u)return null;var m=document.getElementById(u);return m?zx.createPortal(n,m):null}function Qv(){return Qv=Object.assign?Object.assign.bind():function(e){for(var t=1;tS.useContext(p5),Ly={exports:{}},u_;function sJ(){return u_||(u_=1,(function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function i(m,f,h){this.fn=m,this.context=f,this.once=h||!1}function o(m,f,h,g,v){if(typeof h!="function")throw new TypeError("The listener must be a function");var b=new i(h,g||m,v),T=n?n+f:f;return m._events[T]?m._events[T].fn?m._events[T]=[m._events[T],b]:m._events[T].push(b):(m._events[T]=b,m._eventsCount++),m}function c(m,f){--m._eventsCount===0?m._events=new r:delete m._events[f]}function u(){this._events=new r,this._eventsCount=0}u.prototype.eventNames=function(){var f=[],h,g;if(this._eventsCount===0)return f;for(g in h=this._events)t.call(h,g)&&f.push(n?g.slice(1):g);return Object.getOwnPropertySymbols?f.concat(Object.getOwnPropertySymbols(h)):f},u.prototype.listeners=function(f){var h=n?n+f:f,g=this._events[h];if(!g)return[];if(g.fn)return[g.fn];for(var v=0,b=g.length,T=new Array(b);v{e.eventEmitter==null&&(e.eventEmitter=Symbol("rechartsEventEmitter"))}}}),dJ=g5.reducer,{createEventEmitter:fJ}=g5.actions;function mJ(e){return e.tooltip.syncInteraction}var hJ={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},y5=lr({name:"chartData",initialState:hJ,reducers:{setChartData(e,t){if(e.chartData=t.payload,t.payload==null){e.dataStartIndex=0,e.dataEndIndex=0;return}t.payload.length>0&&e.dataEndIndex!==t.payload.length-1&&(e.dataEndIndex=t.payload.length-1)},setComputedData(e,t){e.computedData=t.payload},setDataStartEndIndexes(e,t){var{startIndex:n,endIndex:r}=t.payload;n!=null&&(e.dataStartIndex=n),r!=null&&(e.dataEndIndex=r)}}}),{setChartData:f_,setDataStartEndIndexes:pJ,setComputedData:ule}=y5.actions,gJ=y5.reducer,yJ=["x","y"];function m_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function El(e){for(var t=1;tm.rootProps.className);S.useEffect(()=>{if(e==null)return Ds;var m=(f,h,g)=>{if(t!==g&&e===f){if(r==="index"){var v;if(c&&h!==null&&h!==void 0&&(v=h.payload)!==null&&v!==void 0&&v.coordinate&&h.payload.sourceViewBox){var b=h.payload.coordinate,{x:T,y:C}=b,E=wJ(b,yJ),{x:N,y:I,width:P,height:M}=h.payload.sourceViewBox,j=El(El({},E),{},{x:c.x+(P?(T-N)/P:0)*c.width,y:c.y+(M?(C-I)/M:0)*c.height});n(El(El({},h),{},{payload:El(El({},h.payload),{},{coordinate:j})}))}else n(h);return}if(i!=null){var k;if(typeof r=="function"){var R={activeTooltipIndex:h.payload.index==null?void 0:Number(h.payload.index),isTooltipActive:h.payload.active,activeIndex:h.payload.index==null?void 0:Number(h.payload.index),activeLabel:h.payload.label,activeDataKey:h.payload.dataKey,activeCoordinate:h.payload.coordinate},F=r(i,R);k=i[F]}else r==="value"&&(k=i.find(z=>String(z.value)===h.payload.label));var{coordinate:q}=h.payload;if(k==null||h.payload.active===!1||q==null||c==null){n(Wv({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0}));return}var{x:G,y:H}=q,V=Math.min(G,c.x+c.width),oe=Math.min(H,c.y+c.height),Z={x:o==="horizontal"?k.coordinate:V,y:o==="horizontal"?oe:k.coordinate},me=Wv({active:h.payload.active,coordinate:Z,dataKey:h.payload.dataKey,index:String(k.index),label:h.payload.label,sourceViewBox:h.payload.sourceViewBox});n(me)}}};return qu.on(Xv,m),()=>{qu.off(Xv,m)}},[u,n,t,e,r,i,o,c])}function CJ(){var e=Se(kb),t=Se(Db),n=bt();S.useEffect(()=>{if(e==null)return Ds;var r=(i,o,c)=>{t!==c&&e===i&&n(pJ(o))};return qu.on(d_,r),()=>{qu.off(d_,r)}},[n,t,e])}function TJ(){var e=bt();S.useEffect(()=>{e(fJ())},[e]),AJ(),CJ()}function EJ(e,t,n,r,i,o){var c=Se(b=>kW(b,e,t)),u=Se(Db),m=Se(kb),f=Se(lP),h=Se(mJ),g=h==null?void 0:h.active,v=td();S.useEffect(()=>{if(!g&&m!=null&&u!=null){var b=Wv({active:o,coordinate:n,dataKey:c,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:v});qu.emit(Xv,m,b,u)}},[g,n,c,i,r,u,m,f,o,v])}function h_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function p_(e){for(var t=1;t{R(IY({shared:I,trigger:P,axisId:k,active:i,defaultIndex:F}))},[R,I,P,k,i,F]);var q=td(),G=e4(),H=NY(I),{activeIndex:V,isActive:oe}=(t=Se(Re=>OW(Re,H,P,F)))!==null&&t!==void 0?t:{},Z=Se(Re=>RW(Re,H,P,F)),me=Se(Re=>m5(Re,H,P,F)),z=Se(Re=>DW(Re,H,P,F)),Y=Z,ce=oJ(),ge=(n=i??oe)!==null&&n!==void 0?n:!1,[Me,U]=fM([Y,ge]),te=H==="axis"?me:void 0;EJ(H,P,z,te,V,ge);var ue=j??ce;if(ue==null||q==null||H==null)return null;var fe=Y??g_;ge||(fe=g_),f&&fe.length&&(fe=sM(fe.filter(Re=>Re.value!=null&&(Re.hide!==!0||r.includeHidden)),v,MJ));var Ne=fe.length>0,Pe=S.createElement(EG,{allowEscapeViewBox:o,animationDuration:c,animationEasing:u,isAnimationActive:h,active:ge,coordinate:z,hasPayload:Ne,offset:g,position:b,reverseDirection:T,useTranslate3d:C,viewBox:q,wrapperStyle:E,lastBoundingBox:Me,innerRef:U,hasPortalFromProps:!!j},PJ(m,p_(p_({},r),{},{payload:fe,label:te,active:ge,activeIndex:V,coordinate:z,accessibilityLayer:G})));return S.createElement(S.Fragment,null,zx.createPortal(Pe,ue),ge&&S.createElement(aJ,{cursor:N,tooltipEventType:H,coordinate:z,payload:fe,index:V}))}var Ls=e=>null;Ls.displayName="Cell";function kJ(e,t,n){return(t=DJ(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function DJ(e){var t=RJ(e,"string");return typeof t=="symbol"?t:t+""}function RJ(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}class OJ{constructor(t){kJ(this,"cache",new Map),this.maxSize=t}get(t){var n=this.cache.get(t);return n!==void 0&&(this.cache.delete(t),this.cache.set(t,n)),n}set(t,n){if(this.cache.has(t))this.cache.delete(t);else if(this.cache.size>=this.maxSize){var r=this.cache.keys().next().value;this.cache.delete(r)}this.cache.set(t,n)}clear(){this.cache.clear()}size(){return this.cache.size}}function y_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function LJ(e){for(var t=1;t{try{var n=document.getElementById(x_);n||(n=document.createElement("span"),n.setAttribute("id",x_),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,qJ,t),n.textContent="".concat(e);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},ju=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(t==null||Ea.isSsr)return{width:0,height:0};if(!v5.enableCache)return b_(t,n);var r=GJ(t,n),i=v_.get(r);if(i)return i;var o=b_(t,n);return v_.set(r,o),o},w_=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,S_=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,$J=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,HJ=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,x5={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},VJ=Object.keys(x5),jl="NaN";function KJ(e,t){return e*x5[t]}class ir{static parse(t){var n,[,r,i]=(n=HJ.exec(t))!==null&&n!==void 0?n:[];return new ir(parseFloat(r),i??"")}constructor(t,n){this.num=t,this.unit=n,this.num=t,this.unit=n,sr(t)&&(this.unit=""),n!==""&&!$J.test(n)&&(this.num=NaN,this.unit=""),VJ.includes(n)&&(this.num=KJ(t,n),this.unit="px")}add(t){return this.unit!==t.unit?new ir(NaN,""):new ir(this.num+t.num,this.unit)}subtract(t){return this.unit!==t.unit?new ir(NaN,""):new ir(this.num-t.num,this.unit)}multiply(t){return this.unit!==""&&t.unit!==""&&this.unit!==t.unit?new ir(NaN,""):new ir(this.num*t.num,this.unit||t.unit)}divide(t){return this.unit!==""&&t.unit!==""&&this.unit!==t.unit?new ir(NaN,""):new ir(this.num/t.num,this.unit||t.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return sr(this.num)}}function b5(e){if(e.includes(jl))return jl;for(var t=e;t.includes("*")||t.includes("/");){var n,[,r,i,o]=(n=w_.exec(t))!==null&&n!==void 0?n:[],c=ir.parse(r??""),u=ir.parse(o??""),m=i==="*"?c.multiply(u):c.divide(u);if(m.isNaN())return jl;t=t.replace(w_,m.toString())}for(;t.includes("+")||/.-\d+(?:\.\d+)?/.test(t);){var f,[,h,g,v]=(f=S_.exec(t))!==null&&f!==void 0?f:[],b=ir.parse(h??""),T=ir.parse(v??""),C=g==="+"?b.add(T):b.subtract(T);if(C.isNaN())return jl;t=t.replace(S_,C.toString())}return t}var A_=/\(([^()]*)\)/;function YJ(e){for(var t=e,n;(n=A_.exec(t))!=null;){var[,r]=n;t=t.replace(A_,b5(r))}return t}function WJ(e){var t=e.replace(/\s+/g,"");return t=YJ(t),t=b5(t),t}function JJ(e){try{return WJ(e)}catch{return jl}}function Uy(e){var t=JJ(e.slice(5,-1));return t===jl?"":t}var QJ=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],XJ=["dx","dy","angle","className","breakAll"];function Zv(){return Zv=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{children:t,breakAll:n,style:r}=e;try{var i=[];jt(t)||(n?i=t.toString().split(""):i=t.toString().split(w5));var o=i.map(u=>({word:u,width:ju(u,r).width})),c=n?0:ju(" ",r).width;return{wordsWithComputedWidth:o,spaceWidth:c}}catch{return null}};function eQ(e){return e==="start"||e==="middle"||e==="end"||e==="inherit"}var A5=(e,t,n,r)=>e.reduce((i,o)=>{var{word:c,width:u}=o,m=i[i.length-1];if(m&&u!=null&&(t==null||r||m.width+u+ne.reduce((t,n)=>t.width>n.width?t:n),tQ="…",T_=(e,t,n,r,i,o,c,u)=>{var m=e.slice(0,t),f=S5({breakAll:n,style:r,children:m+tQ});if(!f)return[!1,[]];var h=A5(f.wordsWithComputedWidth,o,c,u),g=h.length>i||C5(h).width>Number(o);return[g,h]},nQ=(e,t,n,r,i)=>{var{maxLines:o,children:c,style:u,breakAll:m}=e,f=we(o),h=String(c),g=A5(t,r,n,i);if(!f||i)return g;var v=g.length>o||C5(g).width>Number(r);if(!v)return g;for(var b=0,T=h.length-1,C=0,E;b<=T&&C<=h.length-1;){var N=Math.floor((b+T)/2),I=N-1,[P,M]=T_(h,I,m,u,o,r,n,i),[j]=T_(h,N,m,u,o,r,n,i);if(!P&&!j&&(b=N+1),P&&j&&(T=N-1),!P&&j){E=M;break}C++}return E||g},E_=e=>{var t=jt(e)?[]:e.toString().split(w5);return[{words:t,width:void 0}]},rQ=e=>{var{width:t,scaleToFit:n,children:r,style:i,breakAll:o,maxLines:c}=e;if((t||n)&&!Ea.isSsr){var u,m,f=S5({breakAll:o,children:r,style:i});if(f){var{wordsWithComputedWidth:h,spaceWidth:g}=f;u=h,m=g}else return E_(r);return nQ({breakAll:o,children:r,maxLines:c,style:i},u,m,t,!!n)}return E_(r)},T5="#808080",iQ={breakAll:!1,capHeight:"0.71em",fill:T5,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},Gh=S.forwardRef((e,t)=>{var n=Lt(e,iQ),{x:r,y:i,lineHeight:o,capHeight:c,fill:u,scaleToFit:m,textAnchor:f,verticalAnchor:h}=n,g=C_(n,QJ),v=S.useMemo(()=>rQ({breakAll:g.breakAll,children:g.children,maxLines:g.maxLines,scaleToFit:m,style:g.style,width:g.width}),[g.breakAll,g.children,g.maxLines,m,g.style,g.width]),{dx:b,dy:T,angle:C,className:E,breakAll:N}=g,I=C_(g,XJ);if(!Vr(r)||!Vr(i)||v.length===0)return null;var P=Number(r)+(we(b)?b:0),M=Number(i)+(we(T)?T:0);if(!dt(P)||!dt(M))return null;var j;switch(h){case"start":j=Uy("calc(".concat(c,")"));break;case"middle":j=Uy("calc(".concat((v.length-1)/2," * -").concat(o," + (").concat(c," / 2))"));break;default:j=Uy("calc(".concat(v.length-1," * -").concat(o,")"));break}var k=[];if(m){var R=v[0].width,{width:F}=g;k.push("scale(".concat(we(F)&&we(R)?F/R:1,")"))}return C&&k.push("rotate(".concat(C,", ").concat(P,", ").concat(M,")")),k.length&&(I.transform=k.join(" ")),S.createElement("text",Zv({},Mn(I),{ref:t,x:P,y:M,className:Xe("recharts-text",E),textAnchor:f,fill:u.includes("url")?T5:u}),v.map((q,G)=>{var H=q.words.join(N?"":" ");return S.createElement("tspan",{x:P,dy:G===0?j:o,key:"".concat(H,"-").concat(G)},H)}))});Gh.displayName="Text";var aQ=["labelRef"];function oQ(e,t){if(e==null)return{};var n,r,i=sQ(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r{var{x:t,y:n,upperWidth:r,lowerWidth:i,width:o,height:c,children:u}=e,m=S.useMemo(()=>({x:t,y:n,upperWidth:r,lowerWidth:i,width:o,height:c}),[t,n,r,i,o,c]);return S.createElement(E5.Provider,{value:m},u)},_5=()=>{var e=S.useContext(E5),t=td();return e||WM(t)},dQ=S.createContext(null),fQ=()=>{var e=S.useContext(dQ),t=Se(mP);return e||t},mQ=e=>{var{value:t,formatter:n}=e,r=jt(e.children)?t:e.children;return typeof n=="function"?n(r):r},m1=e=>e!=null&&typeof e=="function",hQ=(e,t)=>{var n=bn(t-e),r=Math.min(Math.abs(t-e),360);return n*r},pQ=(e,t,n,r,i)=>{var{offset:o,className:c}=e,{cx:u,cy:m,innerRadius:f,outerRadius:h,startAngle:g,endAngle:v,clockWise:b}=i,T=(f+h)/2,C=hQ(g,v),E=C>=0?1:-1,N,I;switch(t){case"insideStart":N=g+E*o,I=b;break;case"insideEnd":N=v-E*o,I=!b;break;case"end":N=v+E*o,I=b;break;default:throw new Error("Unsupported position ".concat(t))}I=C<=0?I:!I;var P=an(u,m,T,N),M=an(u,m,T,N+(I?1:-1)*359),j="M".concat(P.x,",").concat(P.y,` + A`).concat(T,",").concat(T,",0,1,").concat(I?0:1,`, + `).concat(M.x,",").concat(M.y),k=jt(e.id)?Pu("recharts-radial-line-"):e.id;return S.createElement("text",oa({},r,{dominantBaseline:"central",className:Xe("recharts-radial-bar-label",c)}),S.createElement("defs",null,S.createElement("path",{id:k,d:j})),S.createElement("textPath",{xlinkHref:"#".concat(k)},n))},gQ=(e,t,n)=>{var{cx:r,cy:i,innerRadius:o,outerRadius:c,startAngle:u,endAngle:m}=e,f=(u+m)/2;if(n==="outside"){var{x:h,y:g}=an(r,i,c+t,f);return{x:h,y:g,textAnchor:h>=r?"start":"end",verticalAnchor:"middle"}}if(n==="center")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"middle"};if(n==="centerTop")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"start"};if(n==="centerBottom")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"end"};var v=(o+c)/2,{x:b,y:T}=an(r,i,v,f);return{x:b,y:T,textAnchor:"middle",verticalAnchor:"middle"}},ex=e=>"cx"in e&&we(e.cx),yQ=(e,t)=>{var{parentViewBox:n,offset:r,position:i}=e,o;n!=null&&!ex(n)&&(o=n);var{x:c,y:u,upperWidth:m,lowerWidth:f,height:h}=t,g=c,v=c+(m-f)/2,b=(g+v)/2,T=(m+f)/2,C=g+m/2,E=h>=0?1:-1,N=E*r,I=E>0?"end":"start",P=E>0?"start":"end",M=m>=0?1:-1,j=M*r,k=M>0?"end":"start",R=M>0?"start":"end";if(i==="top"){var F={x:g+m/2,y:u-N,textAnchor:"middle",verticalAnchor:I};return Jt(Jt({},F),o?{height:Math.max(u-o.y,0),width:m}:{})}if(i==="bottom"){var q={x:v+f/2,y:u+h+N,textAnchor:"middle",verticalAnchor:P};return Jt(Jt({},q),o?{height:Math.max(o.y+o.height-(u+h),0),width:f}:{})}if(i==="left"){var G={x:b-j,y:u+h/2,textAnchor:k,verticalAnchor:"middle"};return Jt(Jt({},G),o?{width:Math.max(G.x-o.x,0),height:h}:{})}if(i==="right"){var H={x:b+T+j,y:u+h/2,textAnchor:R,verticalAnchor:"middle"};return Jt(Jt({},H),o?{width:Math.max(o.x+o.width-H.x,0),height:h}:{})}var V=o?{width:T,height:h}:{};return i==="insideLeft"?Jt({x:b+j,y:u+h/2,textAnchor:R,verticalAnchor:"middle"},V):i==="insideRight"?Jt({x:b+T-j,y:u+h/2,textAnchor:k,verticalAnchor:"middle"},V):i==="insideTop"?Jt({x:g+m/2,y:u+N,textAnchor:"middle",verticalAnchor:P},V):i==="insideBottom"?Jt({x:v+f/2,y:u+h-N,textAnchor:"middle",verticalAnchor:I},V):i==="insideTopLeft"?Jt({x:g+j,y:u+N,textAnchor:R,verticalAnchor:P},V):i==="insideTopRight"?Jt({x:g+m-j,y:u+N,textAnchor:k,verticalAnchor:P},V):i==="insideBottomLeft"?Jt({x:v+j,y:u+h-N,textAnchor:R,verticalAnchor:I},V):i==="insideBottomRight"?Jt({x:v+f-j,y:u+h-N,textAnchor:k,verticalAnchor:I},V):i&&typeof i=="object"&&(we(i.x)||ha(i.x))&&(we(i.y)||ha(i.y))?Jt({x:c+Un(i.x,T),y:u+Un(i.y,h),textAnchor:"end",verticalAnchor:"end"},V):Jt({x:C,y:u+h/2,textAnchor:"middle",verticalAnchor:"middle"},V)},vQ={offset:5,zIndex:Gt.label};function so(e){var t=Lt(e,vQ),{viewBox:n,position:r,value:i,children:o,content:c,className:u="",textBreakAll:m,labelRef:f}=t,h=fQ(),g=_5(),v=r==="center"?g:h??g,b,T,C;if(n==null?b=v:ex(n)?b=n:b=WM(n),!b||jt(i)&&jt(o)&&!S.isValidElement(c)&&typeof c!="function")return null;var E=Jt(Jt({},t),{},{viewBox:b});if(S.isValidElement(c)){var{labelRef:N}=E,I=oQ(E,aQ);return S.cloneElement(c,I)}if(typeof c=="function"){if(T=S.createElement(c,E),S.isValidElement(T))return T}else T=mQ(t);var P=Mn(t);if(ex(b)){if(r==="insideStart"||r==="insideEnd"||r==="end")return pQ(t,r,T,P,b);C=gQ(b,t.offset,t.position)}else C=yQ(t,b);return S.createElement(Bn,{zIndex:t.zIndex},S.createElement(Gh,oa({ref:f,className:Xe("recharts-label",u)},P,C,{textAnchor:eQ(P.textAnchor)?P.textAnchor:C.textAnchor,breakAll:m}),T))}so.displayName="Label";var xQ=(e,t,n)=>{if(!e)return null;var r={viewBox:t,labelRef:n};return e===!0?S.createElement(so,oa({key:"label-implicit"},r)):Vr(e)?S.createElement(so,oa({key:"label-implicit",value:e},r)):S.isValidElement(e)?e.type===so?S.cloneElement(e,Jt({key:"label-implicit"},r)):S.createElement(so,oa({key:"label-implicit",content:e},r)):m1(e)?S.createElement(so,oa({key:"label-implicit",content:e},r)):e&&typeof e=="object"?S.createElement(so,oa({},e,{key:"label-implicit"},r)):null};function j5(e){var{label:t,labelRef:n}=e,r=_5();return xQ(t,r,n)||null}var By={},zy={},__;function bQ(){return __||(__=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return n[n.length-1]}e.last=t})(zy)),zy}var Fy={},j_;function wQ(){return j_||(j_=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){return Array.isArray(n)?n:Array.from(n)}e.toArray=t})(Fy)),Fy}var M_;function SQ(){return M_||(M_=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});const t=bQ(),n=wQ(),r=Wx();function i(o){if(r.isArrayLike(o))return t.last(n.toArray(o))}e.last=i})(By)),By}var qy,P_;function AQ(){return P_||(P_=1,qy=SQ().last),qy}var CQ=AQ();const TQ=ji(CQ);var EQ=["valueAccessor"],NQ=["dataKey","clockWise","id","textBreakAll","zIndex"];function $m(){return $m=Object.assign?Object.assign.bind():function(e){for(var t=1;tArray.isArray(e.value)?TQ(e.value):e.value,M5=S.createContext(void 0),h1=M5.Provider,P5=S.createContext(void 0),MQ=P5.Provider;function PQ(){return S.useContext(M5)}function IQ(){return S.useContext(P5)}function om(e){var{valueAccessor:t=jQ}=e,n=I_(e,EQ),{dataKey:r,clockWise:i,id:o,textBreakAll:c,zIndex:u}=n,m=I_(n,NQ),f=PQ(),h=IQ(),g=f||h;return!g||!g.length?null:S.createElement(Bn,{zIndex:u??Gt.label},S.createElement(Ot,{className:"recharts-label-list"},g.map((v,b)=>{var T,C=jt(r)?t(v,b):gt(v&&v.payload,r),E=jt(o)?{}:{id:"".concat(o,"-").concat(b)};return S.createElement(so,$m({key:"label-".concat(b)},Mn(v),m,E,{fill:(T=n.fill)!==null&&T!==void 0?T:v.fill,parentViewBox:v.parentViewBox,value:C,textBreakAll:c,viewBox:v.viewBox,index:b,zIndex:0}))})))}om.displayName="LabelList";function $h(e){var{label:t}=e;return t?t===!0?S.createElement(om,{key:"labelList-implicit"}):S.isValidElement(t)||m1(t)?S.createElement(om,{key:"labelList-implicit",content:t}):typeof t=="object"?S.createElement(om,$m({key:"labelList-implicit"},t,{type:String(t.type)})):null:null}function tx(){return tx=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{cx:t,cy:n,r,className:i}=e,o=Xe("recharts-dot",i);return we(t)&&we(n)&&we(r)?S.createElement("circle",tx({},Kn(e),Yx(e),{className:o,cx:t,cy:n,r})):null},k5=e=>e.graphicalItems.polarItems,kQ=J([kt,ld],Bb),Hh=J([k5,Ut,kQ],zb),DQ=J([Hh],Fb),Vh=J([DQ,jb],qb),RQ=J([Vh,Ut,Hh],$b);J([Vh,Ut,Hh],(e,t,n)=>n.length>0?e.flatMap(r=>n.flatMap(i=>{var o,c=gt(r,(o=t.dataKey)!==null&&o!==void 0?o:i.dataKey);return{value:c,errorDomain:[]}})).filter(Boolean):(t==null?void 0:t.dataKey)!=null?e.map(r=>({value:gt(r,t.dataKey),errorDomain:[]})):e.map(r=>({value:r,errorDomain:[]})));var k_=()=>{},OQ=J([Vh,Ut,Hh,Bh,kt],Yb),LQ=J([Ut,Vb,Kb,k_,OQ,k_,Ke,kt],Wb),D5=J([Ut,Ke,Vh,RQ,sd,kt,LQ],Jb),UQ=J([D5,Ut,hc],Zb);J([Ut,D5,UQ,kt],t1);var BQ={radiusAxis:{},angleAxis:{}},R5=lr({name:"polarAxis",initialState:BQ,reducers:{addRadiusAxis(e,t){e.radiusAxis[t.payload.id]=t.payload},removeRadiusAxis(e,t){delete e.radiusAxis[t.payload.id]},addAngleAxis(e,t){e.angleAxis[t.payload.id]=t.payload},removeAngleAxis(e,t){delete e.angleAxis[t.payload.id]}}}),{addRadiusAxis:dle,removeRadiusAxis:fle,addAngleAxis:mle,removeAngleAxis:hle}=R5.actions,zQ=R5.reducer;function D_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function R_(e){for(var t=1;tt,p1=J([k5,$Q],(e,t)=>e.filter(n=>n.type==="pie").find(n=>n.id===t)),HQ=[],g1=(e,t,n)=>(n==null?void 0:n.length)===0?HQ:n,O5=J([jb,p1,g1],(e,t,n)=>{var{chartData:r}=e;if(t!=null){var i;if((t==null?void 0:t.data)!=null&&t.data.length>0?i=t.data:i=r,(!i||!i.length)&&n!=null&&(i=n.map(o=>R_(R_({},t.presentationProps),o.props))),i!=null)return i}}),VQ=J([O5,p1,g1],(e,t,n)=>{if(!(e==null||t==null))return e.map((r,i)=>{var o,c=gt(r,t.nameKey,t.name),u;return n!=null&&(o=n[i])!==null&&o!==void 0&&(o=o.props)!==null&&o!==void 0&&o.fill?u=n[i].props.fill:typeof r=="object"&&r!=null&&"fill"in r?u=r.fill:u=t.fill,{value:No(c,t.dataKey),color:u,payload:r,type:t.legendType}})}),KQ=J([O5,p1,g1,fn],(e,t,n,r)=>{if(!(t==null||e==null))return VX({offset:r,pieSettings:t,displayedData:e,cells:n})}),Gy={exports:{}},pt={};/** + * @license React + * react-is.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 O_;function YQ(){if(O_)return pt;O_=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),f=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),v=Symbol.for("react.view_transition"),b=Symbol.for("react.client.reference");function T(C){if(typeof C=="object"&&C!==null){var E=C.$$typeof;switch(E){case e:switch(C=C.type,C){case n:case i:case r:case m:case f:case v:return C;default:switch(C=C&&C.$$typeof,C){case c:case u:case g:case h:return C;case o:return C;default:return E}}case t:return E}}}return pt.ContextConsumer=o,pt.ContextProvider=c,pt.Element=e,pt.ForwardRef=u,pt.Fragment=n,pt.Lazy=g,pt.Memo=h,pt.Portal=t,pt.Profiler=i,pt.StrictMode=r,pt.Suspense=m,pt.SuspenseList=f,pt.isContextConsumer=function(C){return T(C)===o},pt.isContextProvider=function(C){return T(C)===c},pt.isElement=function(C){return typeof C=="object"&&C!==null&&C.$$typeof===e},pt.isForwardRef=function(C){return T(C)===u},pt.isFragment=function(C){return T(C)===n},pt.isLazy=function(C){return T(C)===g},pt.isMemo=function(C){return T(C)===h},pt.isPortal=function(C){return T(C)===t},pt.isProfiler=function(C){return T(C)===i},pt.isStrictMode=function(C){return T(C)===r},pt.isSuspense=function(C){return T(C)===m},pt.isSuspenseList=function(C){return T(C)===f},pt.isValidElementType=function(C){return typeof C=="string"||typeof C=="function"||C===n||C===i||C===r||C===m||C===f||typeof C=="object"&&C!==null&&(C.$$typeof===g||C.$$typeof===h||C.$$typeof===c||C.$$typeof===o||C.$$typeof===u||C.$$typeof===b||C.getModuleId!==void 0)},pt.typeOf=T,pt}var L_;function WQ(){return L_||(L_=1,Gy.exports=YQ()),Gy.exports}var JQ=WQ(),U_=e=>typeof e=="string"?e:e?e.displayName||e.name||"Component":"",B_=null,$y=null,L5=e=>{if(e===B_&&Array.isArray($y))return $y;var t=[];return S.Children.forEach(e,n=>{jt(n)||(JQ.isFragment(n)?t=t.concat(L5(n.props.children)):t.push(n))}),$y=t,B_=e,t};function y1(e,t){var n=[],r=[];return Array.isArray(t)?r=t.map(i=>U_(i)):r=[U_(t)],L5(e).forEach(i=>{var o=Cs(i,"type.displayName")||Cs(i,"type.name");o&&r.indexOf(o)!==-1&&n.push(i)}),n}var v1=e=>e&&typeof e=="object"&&"clipDot"in e?!!e.clipDot:!0,Hy={},z_;function QQ(){return z_||(z_=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(n){var i;if(typeof n!="object"||n==null)return!1;if(Object.getPrototypeOf(n)===null)return!0;if(Object.prototype.toString.call(n)!=="[object Object]"){const o=n[Symbol.toStringTag];return o==null||!((i=Object.getOwnPropertyDescriptor(n,Symbol.toStringTag))!=null&&i.writable)?!1:n.toString()===`[object ${o}]`}let r=n;for(;Object.getPrototypeOf(r)!==null;)r=Object.getPrototypeOf(r);return Object.getPrototypeOf(n)===r}e.isPlainObject=t})(Hy)),Hy}var Vy,F_;function XQ(){return F_||(F_=1,Vy=QQ().isPlainObject),Vy}var ZQ=XQ();const eX=ji(ZQ);function q_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function G_(e){for(var t=1;t{var o=n-r,c;return c="M ".concat(e,",").concat(t),c+="L ".concat(e+n,",").concat(t),c+="L ".concat(e+n-o/2,",").concat(t+i),c+="L ".concat(e+n-o/2-r,",").concat(t+i),c+="L ".concat(e,",").concat(t," Z"),c},iX={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},aX=e=>{var t=Lt(e,iX),{x:n,y:r,upperWidth:i,lowerWidth:o,height:c,className:u}=t,{animationEasing:m,animationDuration:f,animationBegin:h,isUpdateAnimationActive:g}=t,v=S.useRef(null),[b,T]=S.useState(-1),C=S.useRef(i),E=S.useRef(o),N=S.useRef(c),I=S.useRef(n),P=S.useRef(r),M=lc(e,"trapezoid-");if(S.useEffect(()=>{if(v.current&&v.current.getTotalLength)try{var Z=v.current.getTotalLength();Z&&T(Z)}catch{}},[]),n!==+n||r!==+r||i!==+i||o!==+o||c!==+c||i===0&&o===0||c===0)return null;var j=Xe("recharts-trapezoid",u);if(!g)return S.createElement("g",null,S.createElement("path",Hm({},Mn(t),{className:j,d:$_(n,r,i,o,c)})));var k=C.current,R=E.current,F=N.current,q=I.current,G=P.current,H="0px ".concat(b===-1?1:b,"px"),V="".concat(b,"px 0px"),oe=t4(["strokeDasharray"],f,m);return S.createElement(sc,{animationId:M,key:M,canBegin:b>0,duration:f,easing:m,isActive:g,begin:h},Z=>{var me=ot(k,i,Z),z=ot(R,o,Z),Y=ot(F,c,Z),ce=ot(q,n,Z),ge=ot(G,r,Z);v.current&&(C.current=me,E.current=z,N.current=Y,I.current=ce,P.current=ge);var Me=Z>0?{transition:oe,strokeDasharray:V}:{strokeDasharray:H};return S.createElement("path",Hm({},Mn(t),{className:j,d:$_(ce,ge,me,z,Y),ref:v,style:G_(G_({},Me),t.style)}))})},oX=["option","shapeType","propTransformer","activeClassName","isActive"];function sX(e,t){if(e==null)return{};var n,r,i=lX(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r{var n=bt();return(r,i)=>o=>{e==null||e(r,i,o),n(HP({activeIndex:String(i),activeDataKey:t,activeCoordinate:r.tooltipPosition}))}},w1=e=>{var t=bt();return(n,r)=>i=>{e==null||e(n,r,i),t(kY())}},S1=(e,t)=>{var n=bt();return(r,i)=>o=>{e==null||e(r,i,o),n(DY({activeIndex:String(i),activeDataKey:t,activeCoordinate:r.tooltipPosition}))}};function Kh(e){var{fn:t,args:n}=e,r=bt(),i=mn();return S.useLayoutEffect(()=>{if(!i){var o=t(n);return r(MY(o)),()=>{r(PY(o))}}},[t,n,r,i]),null}function A1(e){var{legendPayload:t}=e,n=bt(),r=mn();return S.useLayoutEffect(()=>r?Ds:(n(XM(t)),()=>{n(ZM(t))}),[n,r,t]),null}function pX(e){var{legendPayload:t}=e,n=bt(),r=Se(Ke);return S.useLayoutEffect(()=>r!=="centric"&&r!=="radial"?Ds:(n(XM(t)),()=>{n(ZM(t))}),[n,r,t]),null}var Ky,gX=()=>{var[e]=S.useState(()=>Pu("uid-"));return e},yX=(Ky=cR.useId)!==null&&Ky!==void 0?Ky:gX;function U5(e,t){var n=yX();return t||(e?"".concat(e,"-").concat(n):n)}var vX=S.createContext(void 0),Yh=e=>{var{id:t,type:n,children:r}=e,i=U5("recharts-".concat(n),t);return S.createElement(vX.Provider,{value:i},r(i))},xX={cartesianItems:[],polarItems:[]},B5=lr({name:"graphicalItems",initialState:xX,reducers:{addCartesianGraphicalItem:{reducer(e,t){e.cartesianItems.push(t.payload)},prepare:un()},replaceCartesianGraphicalItem:{reducer(e,t){var{prev:n,next:r}=t.payload,i=ca(e).cartesianItems.indexOf(n);i>-1&&(e.cartesianItems[i]=r)},prepare:un()},removeCartesianGraphicalItem:{reducer(e,t){var n=ca(e).cartesianItems.indexOf(t.payload);n>-1&&e.cartesianItems.splice(n,1)},prepare:un()},addPolarGraphicalItem:{reducer(e,t){e.polarItems.push(t.payload)},prepare:un()},removePolarGraphicalItem:{reducer(e,t){var n=ca(e).polarItems.indexOf(t.payload);n>-1&&e.polarItems.splice(n,1)},prepare:un()}}}),{addCartesianGraphicalItem:bX,replaceCartesianGraphicalItem:wX,removeCartesianGraphicalItem:SX,addPolarGraphicalItem:AX,removePolarGraphicalItem:CX}=B5.actions,TX=B5.reducer;function C1(e){var t=bt(),n=S.useRef(null);return S.useLayoutEffect(()=>{n.current===null?t(bX(e)):n.current!==e&&t(wX({prev:n.current,next:e})),n.current=e},[t,e]),S.useLayoutEffect(()=>()=>{n.current&&(t(SX(n.current)),n.current=null)},[t]),null}function EX(e){var t=bt();return S.useLayoutEffect(()=>(t(AX(e)),()=>{t(CX(e))}),[t,e]),null}var NX=["onMouseEnter","onClick","onMouseLeave"],_X=["id"],jX=["id"];function T1(e,t){if(e==null)return{};var n,r,i=MX(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;ry1(e.children,Ls),[e.children]),n=Se(r=>VQ(r,e.id,t));return n==null?null:S.createElement(pX,{legendPayload:n})}function RX(e){var{dataKey:t,nameKey:n,sectors:r,stroke:i,strokeWidth:o,fill:c,name:u,hide:m,tooltipType:f}=e;return{dataDefinedOnItem:r.map(h=>h.tooltipPayload),positions:r.map(h=>h.tooltipPosition),settings:{stroke:i,strokeWidth:o,fill:c,dataKey:t,nameKey:n,name:No(u,t),hide:m,type:f,color:c,unit:""}}}var OX=(e,t)=>e>t?"start":eUn(typeof t=="function"?t(e):t,n,n*.8),UX=(e,t,n)=>{var{top:r,left:i,width:o,height:c}=t,u=o4(o,c),m=i+Un(e.cx,o,o/2),f=r+Un(e.cy,c,c/2),h=Un(e.innerRadius,u,0),g=LX(n,e.outerRadius,u),v=e.maxRadius||Math.sqrt(o*o+c*c)/2;return{cx:m,cy:f,innerRadius:h,outerRadius:g,maxRadius:v}},BX=(e,t)=>{var n=bn(t-e),r=Math.min(Math.abs(t-e),360);return n*r};function zX(e){return e&&typeof e=="object"&&"className"in e&&typeof e.className=="string"?e.className:""}var FX=(e,t)=>{if(S.isValidElement(e))return S.cloneElement(e,t);if(typeof e=="function")return e(t);var n=Xe("recharts-pie-label-line",typeof e!="boolean"?e.className:"");return S.createElement(Ol,To({},t,{type:"linear",className:n}))},qX=(e,t,n)=>{if(S.isValidElement(e))return S.cloneElement(e,t);var r=n;if(typeof e=="function"&&(r=e(t),S.isValidElement(r)))return r;var i=Xe("recharts-pie-label-text",zX(e));return S.createElement(Gh,To({},t,{alignmentBaseline:"middle",className:i}),r)};function GX(e){var{sectors:t,props:n,showLabels:r}=e,{label:i,labelLine:o,dataKey:c}=n;if(!r||!i||!t)return null;var u=Kn(n),m=As(i),f=As(o),h=typeof i=="object"&&"offsetRadius"in i&&typeof i.offsetRadius=="number"&&i.offsetRadius||20,g=t.map((v,b)=>{var T=(v.startAngle+v.endAngle)/2,C=an(v.cx,v.cy,v.outerRadius+h,T),E=Pt(Pt(Pt(Pt({},u),v),{},{stroke:"none"},m),{},{index:b,textAnchor:OX(C.x,v.cx)},C),N=Pt(Pt(Pt(Pt({},u),v),{},{fill:"none",stroke:v.fill},f),{},{index:b,points:[an(v.cx,v.cy,v.outerRadius,T),C],key:"line"});return S.createElement(Bn,{zIndex:Gt.label,key:"label-".concat(v.startAngle,"-").concat(v.endAngle,"-").concat(v.midAngle,"-").concat(b)},S.createElement(Ot,null,o&&FX(o,N),qX(i,E,gt(v,c))))});return S.createElement(Ot,{className:"recharts-pie-labels"},g)}function $X(e){var{sectors:t,props:n,showLabels:r}=e,{label:i}=n;return typeof i=="object"&&i!=null&&"position"in i?S.createElement($h,{label:i}):S.createElement(GX,{sectors:t,props:n,showLabels:r})}function HX(e){var{sectors:t,activeShape:n,inactiveShape:r,allOtherPieProps:i}=e,o=Se(Co),{onMouseEnter:c,onClick:u,onMouseLeave:m}=i,f=T1(i,NX),h=b1(c,i.dataKey),g=w1(m),v=S1(u,i.dataKey);return t==null||t.length===0?null:S.createElement(S.Fragment,null,t.map((b,T)=>{if((b==null?void 0:b.startAngle)===0&&(b==null?void 0:b.endAngle)===0&&t.length!==1)return null;var C=n&&String(T)===o,E=o?r:null,N=C?n:E,I=Pt(Pt({},b),{},{stroke:b.stroke,tabIndex:-1,[$M]:T,[HM]:i.dataKey});return S.createElement(Ot,To({key:"sector-".concat(b==null?void 0:b.startAngle,"-").concat(b==null?void 0:b.endAngle,"-").concat(b.midAngle,"-").concat(T),tabIndex:-1,className:"recharts-pie-sector"},Qu(f,b,T),{onMouseEnter:h(b,T),onMouseLeave:g(b,T),onClick:v(b,T)}),S.createElement(x1,To({option:N,isActive:C,shapeType:"sector"},I)))}))}function VX(e){var t,{pieSettings:n,displayedData:r,cells:i,offset:o}=e,{cornerRadius:c,startAngle:u,endAngle:m,dataKey:f,nameKey:h,tooltipType:g}=n,v=Math.abs(n.minAngle),b=BX(u,m),T=Math.abs(b),C=r.length<=1?0:(t=n.paddingAngle)!==null&&t!==void 0?t:0,E=r.filter(k=>gt(k,f,0)!==0).length,N=(T>=360?E:E-1)*C,I=T-E*v-N,P=r.reduce((k,R)=>{var F=gt(R,f,0);return k+(we(F)?F:0)},0),M;if(P>0){var j;M=r.map((k,R)=>{var F=gt(k,f,0),q=gt(k,h,R),G=UX(n,o,k),H=(we(F)?F:0)/P,V,oe=Pt(Pt({},k),i&&i[R]&&i[R].props);R?V=j.endAngle+bn(b)*C*(F!==0?1:0):V=u;var Z=V+bn(b)*((F!==0?v:0)+H*I),me=(V+Z)/2,z=(G.innerRadius+G.outerRadius)/2,Y=[{name:q,value:F,payload:oe,dataKey:f,type:g}],ce=an(G.cx,G.cy,z,me);return j=Pt(Pt(Pt(Pt({},n.presentationProps),{},{percent:H,cornerRadius:typeof c=="string"?parseFloat(c):c,name:q,tooltipPayload:Y,midAngle:me,middleRadius:z,tooltipPosition:ce},oe),G),{},{value:F,startAngle:V,endAngle:Z,payload:oe,paddingAngle:bn(b)*C}),j})}return M}function KX(e){var{showLabels:t,sectors:n,children:r}=e,i=S.useMemo(()=>!t||!n?[]:n.map(o=>({value:o.value,payload:o.payload,clockWise:!1,parentViewBox:void 0,viewBox:{cx:o.cx,cy:o.cy,innerRadius:o.innerRadius,outerRadius:o.outerRadius,startAngle:o.startAngle,endAngle:o.endAngle,clockWise:!1},fill:o.fill})),[n,t]);return S.createElement(MQ,{value:t?i:void 0},r)}function YX(e){var{props:t,previousSectorsRef:n}=e,{sectors:r,isAnimationActive:i,animationBegin:o,animationDuration:c,animationEasing:u,activeShape:m,inactiveShape:f,onAnimationStart:h,onAnimationEnd:g}=t,v=lc(t,"recharts-pie-"),b=n.current,[T,C]=S.useState(!1),E=S.useCallback(()=>{typeof g=="function"&&g(),C(!1)},[g]),N=S.useCallback(()=>{typeof h=="function"&&h(),C(!0)},[h]);return S.createElement(KX,{showLabels:!T,sectors:r},S.createElement(sc,{animationId:v,begin:o,duration:c,isActive:i,easing:u,onAnimationStart:N,onAnimationEnd:E,key:v},I=>{var P=[],M=r&&r[0],j=M==null?void 0:M.startAngle;return r==null||r.forEach((k,R)=>{var F=b&&b[R],q=R>0?Cs(k,"paddingAngle",0):0;if(F){var G=ot(F.endAngle-F.startAngle,k.endAngle-k.startAngle,I),H=Pt(Pt({},k),{},{startAngle:j+q,endAngle:j+G+q});P.push(H),j=H.endAngle}else{var{endAngle:V,startAngle:oe}=k,Z=ot(0,V-oe,I),me=Pt(Pt({},k),{},{startAngle:j+q,endAngle:j+Z+q});P.push(me),j=me.endAngle}}),n.current=P,S.createElement(Ot,null,S.createElement(HX,{sectors:P,activeShape:m,inactiveShape:f,allOtherPieProps:t}))}),S.createElement($X,{showLabels:!T,sectors:r,props:t}),t.children)}var WX={animationBegin:400,animationDuration:1500,animationEasing:"ease",cx:"50%",cy:"50%",dataKey:"value",endAngle:360,fill:"#808080",hide:!1,innerRadius:0,isAnimationActive:!Ea.isSsr,labelLine:!0,legendType:"rect",minAngle:0,nameKey:"name",outerRadius:"80%",paddingAngle:0,rootTabIndex:0,startAngle:0,stroke:"#fff",zIndex:Gt.area};function JX(e){var{id:t}=e,n=T1(e,_X),{hide:r,className:i,rootTabIndex:o}=e,c=S.useMemo(()=>y1(e.children,Ls),[e.children]),u=Se(h=>KQ(h,t,c)),m=S.useRef(null),f=Xe("recharts-pie",i);return r||u==null?(m.current=null,S.createElement(Ot,{tabIndex:o,className:f})):S.createElement(Bn,{zIndex:e.zIndex},S.createElement(Kh,{fn:RX,args:Pt(Pt({},e),{},{sectors:u})}),S.createElement(Ot,{tabIndex:o,className:f},S.createElement(YX,{props:Pt(Pt({},n),{},{sectors:u}),previousSectorsRef:m})))}function Wh(e){var t=Lt(e,WX),{id:n}=t,r=T1(t,jX),i=Kn(r);return S.createElement(Yh,{id:n,type:"pie"},o=>S.createElement(S.Fragment,null,S.createElement(EX,{type:"pie",id:o,data:r.data,dataKey:r.dataKey,hide:r.hide,angleAxisId:0,radiusAxisId:0,name:r.name,nameKey:r.nameKey,tooltipType:r.tooltipType,legendType:r.legendType,fill:r.fill,cx:r.cx,cy:r.cy,startAngle:r.startAngle,endAngle:r.endAngle,paddingAngle:r.paddingAngle,minAngle:r.minAngle,innerRadius:r.innerRadius,outerRadius:r.outerRadius,cornerRadius:r.cornerRadius,presentationProps:i,maxRadius:t.maxRadius}),S.createElement(DX,To({},r,{id:o})),S.createElement(JX,To({},r,{id:o}))))}Wh.displayName="Pie";var QX=["points"];function Y_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Yy(e){for(var t=1;t{var E,N,I=Yy(Yy(Yy({r:3},c),g),{},{index:C,cx:(E=T.x)!==null&&E!==void 0?E:void 0,cy:(N=T.y)!==null&&N!==void 0?N:void 0,dataKey:o,value:T.value,payload:T.payload,points:t});return S.createElement(rZ,{key:"dot-".concat(C),option:n,dotProps:I,className:i})}),b={};return u&&m!=null&&(b.clipPath="url(#clipPath-".concat(h?"":"dots-").concat(m,")")),S.createElement(Bn,{zIndex:f},S.createElement(Ot,Km({className:r},b),v))}function W_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function J_(e){for(var t=1;t({top:e.top,bottom:e.bottom,left:e.left,right:e.right})),gZ=J([pZ,Ca,Ta],(e,t,n)=>{if(!(!e||t==null||n==null))return{x:e.left,y:e.top,width:Math.max(0,t-e.left-e.right),height:Math.max(0,n-e.top-e.bottom)}}),Jh=()=>Se(gZ),yZ=()=>Se(bW);function Q_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Wy(e){for(var t=1;t{var{point:t,childIndex:n,mainColor:r,activeDot:i,dataKey:o}=e;if(i===!1||t.x==null||t.y==null)return null;var c={index:n,dataKey:o,cx:t.x,cy:t.y,r:4,fill:r??"none",strokeWidth:2,stroke:"#fff",payload:t.payload,value:t.value},u=Wy(Wy(Wy({},c),As(i)),Yx(i)),m;return S.isValidElement(i)?m=S.cloneElement(i,u):typeof i=="function"?m=i(u):m=S.createElement(I5,u),S.createElement(Ot,{className:"recharts-active-dot"},m)};function nx(e){var{points:t,mainColor:n,activeDot:r,itemDataKey:i,zIndex:o=Gt.activeDot}=e,c=Se(Co),u=yZ();if(t==null||u==null)return null;var m=t.find(f=>u.includes(f.payload));return jt(m)?null:S.createElement(Bn,{zIndex:o},S.createElement(wZ,{point:m,childIndex:Number(c),mainColor:n,dataKey:i,activeDot:r}))}var SZ="Invariant failed";function AZ(e,t){throw new Error(SZ)}var CZ=["x","y"];function rx(){return rx=Object.assign?Object.assign.bind():function(e){for(var t=1;t1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if(we(t))return t;var o=we(r)||jt(r);return o?t(r,i):(o||AZ(),n)}},IZ={},q5=lr({name:"errorBars",initialState:IZ,reducers:{addErrorBar:(e,t)=>{var{itemId:n,errorBar:r}=t.payload;e[n]||(e[n]=[]),e[n].push(r)},replaceErrorBar:(e,t)=>{var{itemId:n,prev:r,next:i}=t.payload;e[n]&&(e[n]=e[n].map(o=>o.dataKey===r.dataKey&&o.direction===r.direction?i:o))},removeErrorBar:(e,t)=>{var{itemId:n,errorBar:r}=t.payload;e[n]&&(e[n]=e[n].filter(i=>i.dataKey!==r.dataKey||i.direction!==r.direction))}}}),{addErrorBar:yle,replaceErrorBar:vle,removeErrorBar:xle}=q5.actions,kZ=q5.reducer,DZ=["children"];function RZ(e,t){if(e==null)return{};var n,r,i=OZ(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r({x:0,y:0,value:0}),errorBarOffset:0},UZ=S.createContext(LZ);function G5(e){var{children:t}=e,n=RZ(e,DZ);return S.createElement(UZ.Provider,{value:n},t)}function Qh(e,t){var n,r,i=Se(f=>Pi(f,e)),o=Se(f=>Ii(f,t)),c=(n=i==null?void 0:i.allowDataOverflow)!==null&&n!==void 0?n:xr.allowDataOverflow,u=(r=o==null?void 0:o.allowDataOverflow)!==null&&r!==void 0?r:br.allowDataOverflow,m=c||u;return{needClip:m,needClipX:c,needClipY:u}}function E1(e){var{xAxisId:t,yAxisId:n,clipPathId:r}=e,i=Jh(),{needClipX:o,needClipY:c,needClip:u}=Qh(t,n);if(!u||!i)return null;var{x:m,y:f,width:h,height:g}=i;return S.createElement("clipPath",{id:"clipPath-".concat(r)},S.createElement("rect",{x:o?m:m-h/2,y:c?f:f-g/2,width:o?h:h*2,height:c?g:g*2}))}function BZ(e,t){return e&&typeof e=="object"&&"zIndex"in e&&typeof e.zIndex=="number"&&dt(e.zIndex)?e.zIndex:t}var zZ=["onMouseEnter","onMouseLeave","onClick"],FZ=["value","background","tooltipPosition"],qZ=["id"],GZ=["onMouseEnter","onClick","onMouseLeave"];function ba(){return ba=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{dataKey:t,name:n,fill:r,legendType:i,hide:o}=e;return[{inactive:o,dataKey:t,type:i,color:r,value:No(n,t),payload:e}]};function WZ(e){var{dataKey:t,stroke:n,strokeWidth:r,fill:i,name:o,hide:c,unit:u}=e;return{dataDefinedOnItem:void 0,positions:void 0,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:t,nameKey:void 0,name:No(o,t),hide:c,type:e.tooltipType,color:e.fill,unit:u}}}function JZ(e){var t=Se(Co),{data:n,dataKey:r,background:i,allOtherBarProps:o}=e,{onMouseEnter:c,onMouseLeave:u,onClick:m}=o,f=Wm(o,zZ),h=b1(c,r),g=w1(u),v=S1(m,r);if(!i||n==null)return null;var b=As(i);return S.createElement(Bn,{zIndex:BZ(i,Gt.barBackground)},n.map((T,C)=>{var{value:E,background:N,tooltipPosition:I}=T,P=Wm(T,FZ);if(!N)return null;var M=h(T,C),j=g(T,C),k=v(T,C),R=Hn(Hn(Hn(Hn(Hn({option:i,isActive:String(C)===t},P),{},{fill:"#eee"},N),b),Qu(f,T,C)),{},{onMouseEnter:M,onMouseLeave:j,onClick:k,dataKey:r,index:C,className:"recharts-bar-background-rectangle"});return S.createElement(Ym,ba({key:"background-bar-".concat(C)},R))}))}function QZ(e){var{showLabels:t,children:n,rects:r}=e,i=r==null?void 0:r.map(o=>{var c={x:o.x,y:o.y,width:o.width,lowerWidth:o.width,upperWidth:o.width,height:o.height};return Hn(Hn({},c),{},{value:o.value,payload:o.payload,parentViewBox:o.parentViewBox,viewBox:c,fill:o.fill})});return S.createElement(h1,{value:t?i:void 0},n)}function XZ(e){var{shape:t,activeBar:n,baseProps:r,entry:i,index:o,dataKey:c}=e,u=Se(Co),m=Se(o5),f=n&&String(o)===u&&(m==null||c===m),h=f?n:t;return f?S.createElement(Bn,{zIndex:Gt.activeBar},S.createElement(Ym,ba({},r,{name:String(r.name)},i,{isActive:f,option:h,index:o,dataKey:c}))):S.createElement(Ym,ba({},r,{name:String(r.name)},i,{isActive:f,option:h,index:o,dataKey:c}))}function ZZ(e){var{shape:t,baseProps:n,entry:r,index:i,dataKey:o}=e;return S.createElement(Ym,ba({},n,{name:String(n.name)},r,{isActive:!1,option:t,index:i,dataKey:o}))}function eee(e){var t,{data:n,props:r}=e,i=(t=Kn(r))!==null&&t!==void 0?t:{},{id:o}=i,c=Wm(i,qZ),{shape:u,dataKey:m,activeBar:f}=r,{onMouseEnter:h,onClick:g,onMouseLeave:v}=r,b=Wm(r,GZ),T=b1(h,m),C=w1(v),E=S1(g,m);return n?S.createElement(S.Fragment,null,n.map((N,I)=>S.createElement(Ot,ba({key:"rectangle-".concat(N==null?void 0:N.x,"-").concat(N==null?void 0:N.y,"-").concat(N==null?void 0:N.value,"-").concat(I),className:"recharts-bar-rectangle"},Qu(b,N,I),{onMouseEnter:T(N,I),onMouseLeave:C(N,I),onClick:E(N,I)}),f?S.createElement(XZ,{shape:u,activeBar:f,baseProps:c,entry:N,index:I,dataKey:m}):S.createElement(ZZ,{shape:u,baseProps:c,entry:N,index:I,dataKey:m})))):null}function tee(e){var{props:t,previousRectanglesRef:n}=e,{data:r,layout:i,isAnimationActive:o,animationBegin:c,animationDuration:u,animationEasing:m,onAnimationEnd:f,onAnimationStart:h}=t,g=n.current,v=lc(t,"recharts-bar-"),[b,T]=S.useState(!1),C=!b,E=S.useCallback(()=>{typeof f=="function"&&f(),T(!1)},[f]),N=S.useCallback(()=>{typeof h=="function"&&h(),T(!0)},[h]);return S.createElement(QZ,{showLabels:C,rects:r},S.createElement(sc,{animationId:v,begin:c,duration:u,isActive:o,easing:m,onAnimationEnd:E,onAnimationStart:N,key:v},I=>{var P=I===1?r:r==null?void 0:r.map((M,j)=>{var k=g&&g[j];if(k)return Hn(Hn({},M),{},{x:ot(k.x,M.x,I),y:ot(k.y,M.y,I),width:ot(k.width,M.width,I),height:ot(k.height,M.height,I)});if(i==="horizontal"){var R=ot(0,M.height,I),F=ot(M.stackedBarStart,M.y,I);return Hn(Hn({},M),{},{y:F,height:R})}var q=ot(0,M.width,I),G=ot(M.stackedBarStart,M.x,I);return Hn(Hn({},M),{},{width:q,x:G})});return I>0&&(n.current=P??null),P==null?null:S.createElement(Ot,null,S.createElement(eee,{props:t,data:P}))}),S.createElement($h,{label:t.label}),t.children)}function nee(e){var t=S.useRef(null);return S.createElement(tee,{previousRectanglesRef:t,props:e})}var $5=0,ree=(e,t)=>{var n=Array.isArray(e.value)?e.value[1]:e.value;return{x:e.x,y:e.y,value:n,errorVal:gt(e,t)}};class iee extends S.PureComponent{render(){var{hide:t,data:n,dataKey:r,className:i,xAxisId:o,yAxisId:c,needClip:u,background:m,id:f}=this.props;if(t||n==null)return null;var h=Xe("recharts-bar",i),g=f;return S.createElement(Ot,{className:h,id:f},u&&S.createElement("defs",null,S.createElement(E1,{clipPathId:g,xAxisId:o,yAxisId:c})),S.createElement(Ot,{className:"recharts-bar-rectangles",clipPath:u?"url(#clipPath-".concat(g,")"):void 0},S.createElement(JZ,{data:n,dataKey:r,background:m,allOtherBarProps:this.props}),S.createElement(nee,this.props)))}}var aee={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",hide:!1,isAnimationActive:!Ea.isSsr,legendType:"rect",minPointSize:$5,xAxisId:0,yAxisId:0,zIndex:Gt.bar};function oee(e){var{xAxisId:t,yAxisId:n,hide:r,legendType:i,minPointSize:o,activeBar:c,animationBegin:u,animationDuration:m,animationEasing:f,isAnimationActive:h}=e,{needClip:g}=Qh(t,n),v=oc(),b=mn(),T=y1(e.children,Ls),C=Se(I=>Dee(I,t,n,b,e.id,T));if(v!=="vertical"&&v!=="horizontal")return null;var E,N=C==null?void 0:C[0];return N==null||N.height==null||N.width==null?E=0:E=v==="vertical"?N.height/2:N.width/2,S.createElement(G5,{xAxisId:t,yAxisId:n,data:C,dataPointFormatter:ree,errorBarOffset:E},S.createElement(iee,ba({},e,{layout:v,needClip:g,data:C,xAxisId:t,yAxisId:n,hide:r,legendType:i,minPointSize:o,activeBar:c,animationBegin:u,animationDuration:m,animationEasing:f,isAnimationActive:h})))}function see(e){var{layout:t,barSettings:{dataKey:n,minPointSize:r},pos:i,bandSize:o,xAxis:c,yAxis:u,xAxisTicks:m,yAxisTicks:f,stackedData:h,displayedData:g,offset:v,cells:b,parentViewBox:T,dataStartIndex:C}=e,E=t==="horizontal"?u:c,N=h?E.scale.domain():null,I=gq({numericAxis:E}),P=E.scale(I);return g.map((M,j)=>{var k,R,F,q,G,H;h?k=dq(h[j+C],N):(k=gt(M,n),Array.isArray(k)||(k=[I,k]));var V=PZ(r,$5)(k[1],j);if(t==="horizontal"){var oe,[Z,me]=[u.scale(k[0]),u.scale(k[1])];R=EE({axis:c,ticks:m,bandSize:o,offset:i.offset,entry:M,index:j}),F=(oe=me??Z)!==null&&oe!==void 0?oe:void 0,q=i.size;var z=Z-me;if(G=sr(z)?0:z,H={x:R,y:v.top,width:q,height:v.height},Math.abs(V)>0&&Math.abs(G)0&&Math.abs(q)S.createElement(S.Fragment,null,S.createElement(A1,{legendPayload:YZ(t)}),S.createElement(Kh,{fn:WZ,args:t}),S.createElement(C1,{type:"bar",id:r,data:void 0,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,stackId:qM(t.stackId),hide:t.hide,barSize:t.barSize,minPointSize:t.minPointSize,maxBarSize:t.maxBarSize,isPanorama:n}),S.createElement(Bn,{zIndex:t.zIndex},S.createElement(oee,ba({},t,{id:r})))))}var it=S.memo(lee);it.displayName="Bar";function ej(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Qf(e){for(var t=1;tt,mee=(e,t,n)=>n,hee=(e,t,n,r)=>r,pee=(e,t,n,r,i)=>i,gd=J([ud,pee],(e,t)=>e.filter(n=>n.type==="bar").find(n=>n.id===t)),gee=J([gd],e=>e==null?void 0:e.maxBarSize),yee=(e,t,n,r,i,o)=>o,tj=(e,t,n)=>{var r=n??e;if(!jt(r))return Un(r,t,0)},vee=J([Ke,ud,fee,mee,hee],(e,t,n,r,i)=>t.filter(o=>e==="horizontal"?o.xAxisId===n:o.yAxisId===r).filter(o=>o.isPanorama===i).filter(o=>o.hide===!1).filter(o=>o.type==="bar")),xee=(e,t,n,r)=>{var i=Ke(e);return i==="horizontal"?Fu(e,"yAxis",n,r):Fu(e,"xAxis",t,r)},bee=(e,t,n)=>{var r=Ke(e);return r==="horizontal"?ZN(e,"xAxis",t):ZN(e,"yAxis",n)},wee=(e,t,n)=>{var r={},i=e.filter(Rh),o=e.filter(f=>f.stackId==null),c=i.reduce((f,h)=>(f[h.stackId]||(f[h.stackId]=[]),f[h.stackId].push(h),f),r),u=Object.entries(c).map(f=>{var[h,g]=f,v=g.map(T=>T.dataKey),b=tj(t,n,g[0].barSize);return{stackId:h,dataKeys:v,barSize:b}}),m=o.map(f=>{var h=[f.dataKey].filter(v=>v!=null),g=tj(t,n,f.barSize);return{stackId:void 0,dataKeys:h,barSize:g}});return[...u,...m]},See=J([vee,SK,bee],wee),Aee=(e,t,n,r,i)=>{var o,c,u=gd(e,t,n,r,i);if(u!=null){var m=Ke(e),f=oP(e),{maxBarSize:h}=u,g=jt(h)?f:h,v,b;return m==="horizontal"?(v=_i(e,"xAxis",t,r),b=Ni(e,"xAxis",t,r)):(v=_i(e,"yAxis",n,r),b=Ni(e,"yAxis",n,r)),(o=(c=So(v,b,!0))!==null&&c!==void 0?c:g)!==null&&o!==void 0?o:0}},H5=(e,t,n,r)=>{var i=Ke(e),o,c;return i==="horizontal"?(o=_i(e,"xAxis",t,r),c=Ni(e,"xAxis",t,r)):(o=_i(e,"yAxis",n,r),c=Ni(e,"yAxis",n,r)),So(o,c)};function Cee(e,t,n,r,i){var o=r.length;if(!(o<1)){var c=Un(e,n,0,!0),u,m=[];if(dt(r[0].barSize)){var f=!1,h=n/o,g=r.reduce((N,I)=>N+(I.barSize||0),0);g+=(o-1)*c,g>=n&&(g-=(o-1)*c,c=0),g>=n&&h>0&&(f=!0,h*=.9,g=o*h);var v=(n-g)/2>>0,b={offset:v-c,size:0};u=r.reduce((N,I)=>{var P,M={stackId:I.stackId,dataKeys:I.dataKeys,position:{offset:b.offset+b.size+c,size:f?h:(P=I.barSize)!==null&&P!==void 0?P:0}},j=[...N,M];return b=j[j.length-1].position,j},m)}else{var T=Un(t,n,0,!0);n-2*T-(o-1)*c<=0&&(c=0);var C=(n-2*T-(o-1)*c)/o;C>1&&(C>>=0);var E=dt(i)?Math.min(C,i):C;u=r.reduce((N,I,P)=>[...N,{stackId:I.stackId,dataKeys:I.dataKeys,position:{offset:T+(C+c)*P+(C-E)/2,size:E}}],m)}return u}}var Tee=(e,t,n,r,i,o,c)=>{var u=jt(c)?t:c,m=Cee(n,r,i!==o?i:o,e,u);return i!==o&&m!=null&&(m=m.map(f=>Qf(Qf({},f),{},{position:Qf(Qf({},f.position),{},{offset:f.position.offset-i/2})}))),m},Eee=J([See,oP,wK,sP,Aee,H5,gee],Tee),Nee=(e,t,n,r)=>_i(e,"xAxis",t,r),_ee=(e,t,n,r)=>_i(e,"yAxis",n,r),jee=(e,t,n,r)=>Ni(e,"xAxis",t,r),Mee=(e,t,n,r)=>Ni(e,"yAxis",n,r),Pee=J([Eee,gd],(e,t)=>{if(!(e==null||t==null)){var n=e.find(r=>r.stackId===t.stackId&&t.dataKey!=null&&r.dataKeys.includes(t.dataKey));if(n!=null)return n.position}}),Iee=(e,t)=>{var n=Dh(t);if(!(!e||n==null||t==null)){var{stackId:r}=t;if(r!=null){var i=e[r];if(i){var{stackedData:o}=i;if(o)return o.find(c=>c.key===n)}}}},kee=J([xee,gd],Iee),Dee=J([fn,nb,Nee,_ee,jee,Mee,Pee,Ke,od,H5,kee,gd,yee],(e,t,n,r,i,o,c,u,m,f,h,g,v)=>{var{chartData:b,dataStartIndex:T,dataEndIndex:C}=m;if(!(g==null||c==null||t==null||u!=="horizontal"&&u!=="vertical"||n==null||r==null||i==null||o==null||f==null)){var{data:E}=g,N;if(E!=null&&E.length>0?N=E:N=b==null?void 0:b.slice(T,C+1),N!=null)return see({layout:u,barSettings:g,pos:c,parentViewBox:t,bandSize:f,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:o,stackedData:h,displayedData:N,offset:e,cells:v,dataStartIndex:T})}}),V5=e=>{var{chartData:t}=e,n=bt(),r=mn();return S.useEffect(()=>r?()=>{}:(n(f_(t)),()=>{n(f_(void 0))}),[t,n,r]),null},nj={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},K5=lr({name:"brush",initialState:nj,reducers:{setBrushSettings(e,t){return t.payload==null?nj:t.payload}}}),{setBrushSettings:ble}=K5.actions,Ree=K5.reducer;function rj(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Xf(e){for(var t=1;t{var{x:n,y:r}=e,{x:i,y:o}=t;return{x:Math.min(n,i),y:Math.min(r,o),width:Math.abs(i-n),height:Math.abs(o-r)}},Bee=e=>{var{x1:t,y1:n,x2:r,y2:i}=e;return Uee({x:t,y:n},{x:r,y:i})};class Xh{static create(t){return new Xh(t)}constructor(t){this.scale=t}get domain(){return this.scale.domain}get range(){return this.scale.range}get rangeMin(){return this.range()[0]}get rangeMax(){return this.range()[1]}get bandwidth(){return this.scale.bandwidth}apply(t){var{bandAware:n,position:r}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(t!==void 0){if(r)switch(r){case"start":return this.scale(t);case"middle":{var i=this.bandwidth?this.bandwidth()/2:0;return this.scale(t)+i}case"end":{var o=this.bandwidth?this.bandwidth():0;return this.scale(t)+o}default:return this.scale(t)}if(n){var c=this.bandwidth?this.bandwidth()/2:0;return this.scale(t)+c}return this.scale(t)}}isInRange(t){var n=this.range(),r=n[0],i=n[n.length-1];return r<=i?t>=r&&t<=i:t>=i&&t<=r}}Y5(Xh,"EPS",1e-4);var zee=e=>{var t=Object.keys(e).reduce((n,r)=>Xf(Xf({},n),{},{[r]:Xh.create(e[r])}),{});return Xf(Xf({},t),{},{apply(n){var{bandAware:r,position:i}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Object.fromEntries(Object.entries(n).map(o=>{var[c,u]=o;return[c,t[c].apply(u,{bandAware:r,position:i})]}))},isInRange(n){return Object.keys(n).every(r=>t[r].isInRange(n[r]))}})};function Fee(e){return(e%180+180)%180}var qee=function(t){var{width:n,height:r}=t,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,o=Fee(i),c=o*Math.PI/180,u=Math.atan(r/n),m=c>u&&c{e.dots.push(t.payload)},removeDot:(e,t)=>{var n=ca(e).dots.findIndex(r=>r===t.payload);n!==-1&&e.dots.splice(n,1)},addArea:(e,t)=>{e.areas.push(t.payload)},removeArea:(e,t)=>{var n=ca(e).areas.findIndex(r=>r===t.payload);n!==-1&&e.areas.splice(n,1)},addLine:(e,t)=>{e.lines.push(t.payload)},removeLine:(e,t)=>{var n=ca(e).lines.findIndex(r=>r===t.payload);n!==-1&&e.lines.splice(n,1)}}}),{addDot:wle,removeDot:Sle,addArea:Ale,removeArea:Cle,addLine:$ee,removeLine:Hee}=W5.actions,Vee=W5.reducer,J5=S.createContext(void 0),Kee=e=>{var{children:t}=e,[n]=S.useState("".concat(Pu("recharts"),"-clip")),r=Jh();if(r==null)return null;var{x:i,y:o,width:c,height:u}=r;return S.createElement(J5.Provider,{value:n},S.createElement("defs",null,S.createElement("clipPath",{id:n},S.createElement("rect",{x:i,y:o,height:u,width:c}))),t)},Yee=()=>S.useContext(J5);function ij(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function aj(e){for(var t=1;t{var n;if(S.isValidElement(e))n=S.cloneElement(e,t);else if(typeof e=="function")n=e(t);else{if(!dt(t.x1)||!dt(t.y1)||!dt(t.x2)||!dt(t.y2))return null;n=S.createElement("line",Jm({},t,{className:"recharts-reference-line-line"}))}return n},Zee=(e,t,n,r,i,o)=>{var{x:c,width:u}=o,m=i.y.apply(e,{position:n});if(sr(m)||t==="discard"&&!i.y.isInRange(m))return null;var f=[{x:c+u,y:m},{x:c,y:m}];return r==="left"?f.reverse():f},ete=(e,t,n,r,i,o)=>{var{y:c,height:u}=o,m=i.x.apply(e,{position:n});if(sr(m)||t==="discard"&&!i.x.isInRange(m))return null;var f=[{x:m,y:c+u},{x:m,y:c}];return r==="top"?f.reverse():f},tte=(e,t,n,r)=>{var i=e.map(o=>r.apply(o,{position:n}));return t==="discard"&&i.some(o=>!r.isInRange(o))?null:i},nte=(e,t,n,r,i,o)=>{var{x:c,y:u,segment:m,ifOverflow:f}=o,h=Vr(c),g=Vr(u);return g?Zee(u,f,n,i,e,t):h?ete(c,f,n,r,e,t):m!=null&&m.length===2?tte(m,f,n,e):null};function rte(e){var t=bt();return S.useEffect(()=>(t($ee(e)),()=>{t(Hee(e))})),null}function ite(e){var{xAxisId:t,yAxisId:n,shape:r,className:i,ifOverflow:o}=e,c=mn(),u=Yee(),m=Se(k=>Pi(k,t)),f=Se(k=>Ii(k,n)),h=Se(k=>Ao(k,"xAxis",t,c)),g=Se(k=>Ao(k,"yAxis",n,c)),v=td();if(!u||!v||m==null||f==null||h==null||g==null)return null;var b=zee({x:h,y:g}),T=nte(b,v,e.position,m.orientation,f.orientation,e);if(!T)return null;var[{x:C,y:E},{x:N,y:I}]=T,P=o==="hidden"?"url(#".concat(u,")"):void 0,M=aj(aj({clipPath:P},Mn(e)),{},{x1:C,y1:E,x2:N,y2:I}),j=Bee({x1:C,y1:E,x2:N,y2:I});return S.createElement(Bn,{zIndex:e.zIndex},S.createElement(Ot,{className:Xe("recharts-reference-line",i)},Xee(r,M),S.createElement(N5,Jm({},j,{lowerWidth:j.width,upperWidth:j.width}),S.createElement(j5,{label:e.label}),e.children)))}var ate={ifOverflow:"discard",xAxisId:0,yAxisId:0,fill:"none",stroke:"#ccc",fillOpacity:1,strokeWidth:1,position:"middle",zIndex:Gt.line};function Q5(e){var t=Lt(e,ate);return S.createElement(S.Fragment,null,S.createElement(rte,{yAxisId:t.yAxisId,xAxisId:t.xAxisId,ifOverflow:t.ifOverflow,x:t.x,y:t.y,segment:t.segment}),S.createElement(ite,t))}Q5.displayName="ReferenceLine";function tc(e,t){for(var n in e)if({}.hasOwnProperty.call(e,n)&&(!{}.hasOwnProperty.call(t,n)||e[n]!==t[n]))return!1;for(var r in t)if({}.hasOwnProperty.call(t,r)&&!{}.hasOwnProperty.call(e,r))return!1;return!0}function X5(e,t){if(t<1)return[];if(t===1)return e;for(var n=[],r=0;re*i)return!1;var o=n();return e*(t-e*o/2-r)>=0&&e*(t+e*o/2-i)<=0}function lte(e,t){return X5(e,t+1)}function cte(e,t,n,r,i){for(var o=(r||[]).slice(),{start:c,end:u}=t,m=0,f=1,h=c,g=function(){var T=r==null?void 0:r[m];if(T===void 0)return{v:X5(r,f)};var C=m,E,N=()=>(E===void 0&&(E=n(T,C)),E),I=T.coordinate,P=m===0||Qm(e,I,N,h,u);P||(m=0,h=c,f+=1),P&&(h=I+e*(N()/2+i),m+=f)},v;f<=o.length;)if(v=g(),v)return v.v;return[]}function oj(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Dn(e){for(var t=1;t(T===void 0&&(T=n(b,v)),T);if(v===c-1){var E=e*(b.coordinate+e*C()/2-m);o[v]=b=Dn(Dn({},b),{},{tickCoord:E>0?b.coordinate-E*e:b.coordinate})}else o[v]=b=Dn(Dn({},b),{},{tickCoord:b.coordinate});if(b.tickCoord!=null){var N=Qm(e,b.tickCoord,C,u,m);N&&(m=b.tickCoord-e*(C()/2+i),o[v]=Dn(Dn({},b),{},{isShow:!0}))}},h=c-1;h>=0;h--)f(h);return o}function hte(e,t,n,r,i,o){var c=(r||[]).slice(),u=c.length,{start:m,end:f}=t;if(o){var h=r[u-1],g=n(h,u-1),v=e*(h.coordinate+e*g/2-f);if(c[u-1]=h=Dn(Dn({},h),{},{tickCoord:v>0?h.coordinate-v*e:h.coordinate}),h.tickCoord!=null){var b=Qm(e,h.tickCoord,()=>g,m,f);b&&(f=h.tickCoord-e*(g/2+i),c[u-1]=Dn(Dn({},h),{},{isShow:!0}))}}for(var T=o?u-1:u,C=function(I){var P=c[I],M,j=()=>(M===void 0&&(M=n(P,I)),M);if(I===0){var k=e*(P.coordinate-e*j()/2-m);c[I]=P=Dn(Dn({},P),{},{tickCoord:k<0?P.coordinate-k*e:P.coordinate})}else c[I]=P=Dn(Dn({},P),{},{tickCoord:P.coordinate});if(P.tickCoord!=null){var R=Qm(e,P.tickCoord,j,m,f);R&&(m=P.tickCoord+e*(j()/2+i),c[I]=Dn(Dn({},P),{},{isShow:!0}))}},E=0;E{var j=typeof f=="function"?f(P.value,M):P.value;return T==="width"?ote(ju(j,{fontSize:t,letterSpacing:n}),C,g):ju(j,{fontSize:t,letterSpacing:n})[T]},N=i.length>=2?bn(i[1].coordinate-i[0].coordinate):1,I=ste(o,N,T);return m==="equidistantPreserveStart"?cte(N,I,E,i,c):(m==="preserveStart"||m==="preserveStartEnd"?b=hte(N,I,E,i,c,m==="preserveStartEnd"):b=mte(N,I,E,i,c),b.filter(P=>P.isShow))}var pte=e=>{var{ticks:t,label:n,labelGapWithTick:r=5,tickSize:i=0,tickMargin:o=0}=e,c=0;if(t){Array.from(t).forEach(h=>{if(h){var g=h.getBoundingClientRect();g.width>c&&(c=g.width)}});var u=n?n.getBoundingClientRect().width:0,m=i+o,f=c+m+u+(n?r:0);return Math.round(f)}return 0},gte=["axisLine","width","height","className","hide","ticks","axisType"],yte=["viewBox"],vte=["viewBox"];function ix(e,t){if(e==null)return{};var n,r,i=xte(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r{var{ticks:n=[],tick:r,tickLine:i,stroke:o,tickFormatter:c,unit:u,padding:m,tickTextProps:f,orientation:h,mirror:g,x:v,y:b,width:T,height:C,tickSize:E,tickMargin:N,fontSize:I,letterSpacing:P,getTicksConfig:M,events:j,axisType:k}=e,R=N1(rn(rn({},M),{},{ticks:n}),I,P),F=Tte(h,g),q=Ete(h,g),G=Kn(M),H=As(r),V={};typeof i=="object"&&(V=i);var oe=rn(rn({},G),{},{fill:"none"},V),Z=R.map(Y=>rn({entry:Y},Cte(Y,v,b,T,C,h,E,g,N))),me=Z.map(Y=>{var{entry:ce,line:ge}=Y;return S.createElement(Ot,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(ce.value,"-").concat(ce.coordinate,"-").concat(ce.tickCoord)},i&&S.createElement("line",js({},oe,ge,{className:Xe("recharts-cartesian-axis-tick-line",Cs(i,"className"))})))}),z=Z.map((Y,ce)=>{var{entry:ge,tick:Me}=Y,U=rn(rn(rn(rn({textAnchor:F,verticalAnchor:q},G),{},{stroke:"none",fill:o},H),Me),{},{index:ce,payload:ge,visibleTicksCount:R.length,tickFormatter:c,padding:m},f);return S.createElement(Ot,js({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(ge.value,"-").concat(ge.coordinate,"-").concat(ge.tickCoord)},Qu(j,ge,ce)),r&&S.createElement(Nte,{option:r,tickProps:U,value:"".concat(typeof c=="function"?c(ge.value,ce):ge.value).concat(u||"")}))});return S.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(k,"-ticks")},z.length>0&&S.createElement(Bn,{zIndex:Gt.label},S.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(k,"-tick-labels"),ref:t},z)),me.length>0&&S.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(k,"-tick-lines")},me))}),jte=S.forwardRef((e,t)=>{var{axisLine:n,width:r,height:i,className:o,hide:c,ticks:u,axisType:m}=e,f=ix(e,gte),[h,g]=S.useState(""),[v,b]=S.useState(""),T=S.useRef(null);S.useImperativeHandle(t,()=>({getCalculatedWidth:()=>{var E;return pte({ticks:T.current,label:(E=e.labelRef)===null||E===void 0?void 0:E.current,labelGapWithTick:5,tickSize:e.tickSize,tickMargin:e.tickMargin})}}));var C=S.useCallback(E=>{if(E){var N=E.getElementsByClassName("recharts-cartesian-axis-tick-value");T.current=N;var I=N[0];if(I){var P=window.getComputedStyle(I),M=P.fontSize,j=P.letterSpacing;(M!==h||j!==v)&&(g(M),b(j))}}},[h,v]);return c||r!=null&&r<=0||i!=null&&i<=0?null:S.createElement(Bn,{zIndex:e.zIndex},S.createElement(Ot,{className:Xe("recharts-cartesian-axis",o)},S.createElement(Ate,{x:e.x,y:e.y,width:r,height:i,orientation:e.orientation,mirror:e.mirror,axisLine:n,otherSvgProps:Kn(e)}),S.createElement(_te,{ref:C,axisType:m,events:f,fontSize:h,getTicksConfig:e,height:e.height,letterSpacing:v,mirror:e.mirror,orientation:e.orientation,padding:e.padding,stroke:e.stroke,tick:e.tick,tickFormatter:e.tickFormatter,tickLine:e.tickLine,tickMargin:e.tickMargin,tickSize:e.tickSize,tickTextProps:e.tickTextProps,ticks:u,unit:e.unit,width:e.width,x:e.x,y:e.y}),S.createElement(N5,{x:e.x,y:e.y,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width},S.createElement(j5,{label:e.label,labelRef:e.labelRef}),e.children)))}),Mte=S.memo(jte,(e,t)=>{var{viewBox:n}=e,r=ix(e,yte),{viewBox:i}=t,o=ix(t,vte);return tc(n,i)&&tc(r,o)}),j1=S.forwardRef((e,t)=>{var n=Lt(e,_1);return S.createElement(Mte,js({},n,{ref:t}))});j1.displayName="CartesianAxis";var Pte=["x1","y1","x2","y2","key"],Ite=["offset"],kte=["xAxisId","yAxisId"],Dte=["xAxisId","yAxisId"];function lj(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function On(e){for(var t=1;t{var{fill:t}=e;if(!t||t==="none")return null;var{fillOpacity:n,x:r,y:i,width:o,height:c,ry:u}=e;return S.createElement("rect",{x:r,y:i,ry:u,width:o,height:c,stroke:"none",fill:t,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function Z5(e){var{option:t,lineItemProps:n}=e,r;if(S.isValidElement(t))r=S.cloneElement(t,n);else if(typeof t=="function")r=t(n);else{var i,{x1:o,y1:c,x2:u,y2:m,key:f}=n,h=Xm(n,Pte),g=(i=Kn(h))!==null&&i!==void 0?i:{},{offset:v}=g,b=Xm(g,Ite);r=S.createElement("line",ss({},b,{x1:o,y1:c,x2:u,y2:m,fill:"none",key:f}))}return r}function zte(e){var{x:t,width:n,horizontal:r=!0,horizontalPoints:i}=e;if(!r||!i||!i.length)return null;var{xAxisId:o,yAxisId:c}=e,u=Xm(e,kte),m=i.map((f,h)=>{var g=On(On({},u),{},{x1:t,y1:f,x2:t+n,y2:f,key:"line-".concat(h),index:h});return S.createElement(Z5,{key:"line-".concat(h),option:r,lineItemProps:g})});return S.createElement("g",{className:"recharts-cartesian-grid-horizontal"},m)}function Fte(e){var{y:t,height:n,vertical:r=!0,verticalPoints:i}=e;if(!r||!i||!i.length)return null;var{xAxisId:o,yAxisId:c}=e,u=Xm(e,Dte),m=i.map((f,h)=>{var g=On(On({},u),{},{x1:f,y1:t,x2:f,y2:t+n,key:"line-".concat(h),index:h});return S.createElement(Z5,{option:r,lineItemProps:g,key:"line-".concat(h)})});return S.createElement("g",{className:"recharts-cartesian-grid-vertical"},m)}function qte(e){var{horizontalFill:t,fillOpacity:n,x:r,y:i,width:o,height:c,horizontalPoints:u,horizontal:m=!0}=e;if(!m||!t||!t.length||u==null)return null;var f=u.map(g=>Math.round(g+i-i)).sort((g,v)=>g-v);i!==f[0]&&f.unshift(0);var h=f.map((g,v)=>{var b=!f[v+1],T=b?i+c-g:f[v+1]-g;if(T<=0)return null;var C=v%t.length;return S.createElement("rect",{key:"react-".concat(v),y:g,x:r,height:T,width:o,stroke:"none",fill:t[C],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return S.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},h)}function Gte(e){var{vertical:t=!0,verticalFill:n,fillOpacity:r,x:i,y:o,width:c,height:u,verticalPoints:m}=e;if(!t||!n||!n.length)return null;var f=m.map(g=>Math.round(g+i-i)).sort((g,v)=>g-v);i!==f[0]&&f.unshift(0);var h=f.map((g,v)=>{var b=!f[v+1],T=b?i+c-g:f[v+1]-g;if(T<=0)return null;var C=v%n.length;return S.createElement("rect",{key:"react-".concat(v),x:g,y:o,width:T,height:u,stroke:"none",fill:n[C],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return S.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},h)}var $te=(e,t)=>{var{xAxis:n,width:r,height:i,offset:o}=e;return zM(N1(On(On(On({},_1),n),{},{ticks:FM(n),viewBox:{x:0,y:0,width:r,height:i}})),o.left,o.left+o.width,t)},Hte=(e,t)=>{var{yAxis:n,width:r,height:i,offset:o}=e;return zM(N1(On(On(On({},_1),n),{},{ticks:FM(n),viewBox:{x:0,y:0,width:r,height:i}})),o.top,o.top+o.height,t)},Vte={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:Gt.grid};function oi(e){var t=ib(),n=ab(),r=JM(),i=On(On({},Lt(e,Vte)),{},{x:we(e.x)?e.x:r.left,y:we(e.y)?e.y:r.top,width:we(e.width)?e.width:r.width,height:we(e.height)?e.height:r.height}),{xAxisId:o,yAxisId:c,x:u,y:m,width:f,height:h,syncWithTicks:g,horizontalValues:v,verticalValues:b}=i,T=mn(),C=Se(q=>e_(q,"xAxis",o,T)),E=Se(q=>e_(q,"yAxis",c,T));if(!Ti(f)||!Ti(h)||!we(u)||!we(m))return null;var N=i.verticalCoordinatesGenerator||$te,I=i.horizontalCoordinatesGenerator||Hte,{horizontalPoints:P,verticalPoints:M}=i;if((!P||!P.length)&&typeof I=="function"){var j=v&&v.length,k=I({yAxis:E?On(On({},E),{},{ticks:j?v:E.ticks}):void 0,width:t??f,height:n??h,offset:r},j?!0:g);Tm(Array.isArray(k),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof k,"]")),Array.isArray(k)&&(P=k)}if((!M||!M.length)&&typeof N=="function"){var R=b&&b.length,F=N({xAxis:C?On(On({},C),{},{ticks:R?b:C.ticks}):void 0,width:t??f,height:n??h,offset:r},R?!0:g);Tm(Array.isArray(F),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof F,"]")),Array.isArray(F)&&(M=F)}return S.createElement(Bn,{zIndex:i.zIndex},S.createElement("g",{className:"recharts-cartesian-grid"},S.createElement(Bte,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),S.createElement(qte,ss({},i,{horizontalPoints:P})),S.createElement(Gte,ss({},i,{verticalPoints:M})),S.createElement(zte,ss({},i,{offset:r,horizontalPoints:P,xAxis:C,yAxis:E})),S.createElement(Fte,ss({},i,{offset:r,verticalPoints:M,xAxis:C,yAxis:E}))))}oi.displayName="CartesianGrid";var eI=(e,t,n,r)=>_i(e,"xAxis",t,r),tI=(e,t,n,r)=>Ni(e,"xAxis",t,r),nI=(e,t,n,r)=>_i(e,"yAxis",n,r),rI=(e,t,n,r)=>Ni(e,"yAxis",n,r),Kte=J([Ke,eI,nI,tI,rI],(e,t,n,r,i)=>Mi(e,"xAxis")?So(t,r,!1):So(n,i,!1)),Yte=(e,t,n,r,i)=>i;function Wte(e){return e.type==="line"}var Jte=J([ud,Yte],(e,t)=>e.filter(Wte).find(n=>n.id===t)),Qte=J([Ke,eI,nI,tI,rI,Jte,Kte,od],(e,t,n,r,i,o,c,u)=>{var{chartData:m,dataStartIndex:f,dataEndIndex:h}=u;if(!(o==null||t==null||n==null||r==null||i==null||r.length===0||i.length===0||c==null)){var{dataKey:g,data:v}=o,b;if(v!=null&&v.length>0?b=v:b=m==null?void 0:m.slice(f,h+1),b!=null)return yne({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:g,bandSize:c,displayedData:b})}});function iI(e){var t=As(e),n=3,r=2;if(t!=null){var{r:i,strokeWidth:o}=t,c=Number(i),u=Number(o);return(Number.isNaN(c)||c<0)&&(c=n),(Number.isNaN(u)||u<0)&&(u=r),{r:c,strokeWidth:u}}return{r:n,strokeWidth:r}}var Xte=["id"],Zte=["type","layout","connectNulls","needClip","shape"],ene=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function Gu(){return Gu=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{dataKey:t,name:n,stroke:r,legendType:i,hide:o}=e;return[{inactive:o,dataKey:t,type:i,color:r,value:No(n,t),payload:e}]};function one(e){var{dataKey:t,data:n,stroke:r,strokeWidth:i,fill:o,name:c,hide:u,unit:m}=e;return{dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:o,dataKey:t,nameKey:void 0,name:No(c,t),hide:u,type:e.tooltipType,color:e.stroke,unit:m}}}var aI=(e,t)=>"".concat(t,"px ").concat(e-t,"px");function sne(e,t){for(var n=e.length%2!==0?[...e,0]:e,r=[],i=0;i{var r=n.reduce((g,v)=>g+v);if(!r)return aI(t,e);for(var i=Math.floor(e/r),o=e%r,c=t-e,u=[],m=0,f=0;mo){u=[...n.slice(0,m),o-f];break}var h=u.length%2===0?[0,c]:[c];return[...sne(n,i),...u,...h].map(g=>"".concat(g,"px")).join(", ")};function cne(e){var{clipPathId:t,points:n,props:r}=e,{dot:i,dataKey:o,needClip:c}=r,{id:u}=r,m=M1(r,Xte),f=Kn(m);return S.createElement(z5,{points:n,dot:i,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:o,baseProps:f,needClip:c,clipPathId:t})}function une(e){var{showLabels:t,children:n,points:r}=e,i=S.useMemo(()=>r==null?void 0:r.map(o=>{var c,u,m={x:(c=o.x)!==null&&c!==void 0?c:0,y:(u=o.y)!==null&&u!==void 0?u:0,width:0,lowerWidth:0,upperWidth:0,height:0};return Si(Si({},m),{},{value:o.value,payload:o.payload,viewBox:m,parentViewBox:void 0,fill:void 0})}),[r]);return S.createElement(h1,{value:t?i:void 0},n)}function uj(e){var{clipPathId:t,pathRef:n,points:r,strokeDasharray:i,props:o}=e,{type:c,layout:u,connectNulls:m,needClip:f,shape:h}=o,g=M1(o,Zte),v=Si(Si({},Mn(g)),{},{fill:"none",className:"recharts-line-curve",clipPath:f?"url(#clipPath-".concat(t,")"):void 0,points:r,type:c,layout:u,connectNulls:m,strokeDasharray:i??o.strokeDasharray});return S.createElement(S.Fragment,null,(r==null?void 0:r.length)>1&&S.createElement(x1,Gu({shapeType:"curve",option:h},v,{pathRef:n})),S.createElement(cne,{points:r,clipPathId:t,props:o}))}function dne(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}function fne(e){var{clipPathId:t,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:o}=e,{points:c,strokeDasharray:u,isAnimationActive:m,animationBegin:f,animationDuration:h,animationEasing:g,animateNewValues:v,width:b,height:T,onAnimationEnd:C,onAnimationStart:E}=n,N=i.current,I=lc(n,"recharts-line-"),[P,M]=S.useState(!1),j=!P,k=S.useCallback(()=>{typeof C=="function"&&C(),M(!1)},[C]),R=S.useCallback(()=>{typeof E=="function"&&E(),M(!0)},[E]),F=dne(r.current),q=o.current;return S.createElement(une,{points:c,showLabels:j},n.children,S.createElement(sc,{animationId:I,begin:f,duration:h,isActive:m,easing:g,onAnimationEnd:k,onAnimationStart:R,key:I},G=>{var H=ot(q,F+q,G),V=Math.min(H,F),oe;if(m)if(u){var Z="".concat(u).split(/[,\s]+/gim).map(Y=>parseFloat(Y));oe=lne(V,F,Z)}else oe=aI(F,V);else oe=u==null?void 0:String(u);if(N){var me=N.length/c.length,z=G===1?c:c.map((Y,ce)=>{var ge=Math.floor(ce*me);if(N[ge]){var Me=N[ge];return Si(Si({},Y),{},{x:ot(Me.x,Y.x,G),y:ot(Me.y,Y.y,G)})}return v?Si(Si({},Y),{},{x:ot(b*2,Y.x,G),y:ot(T/2,Y.y,G)}):Si(Si({},Y),{},{x:Y.x,y:Y.y})});return i.current=z,S.createElement(uj,{props:n,points:z,clipPathId:t,pathRef:r,strokeDasharray:oe})}return G>0&&F>0&&(i.current=c,o.current=V),S.createElement(uj,{props:n,points:c,clipPathId:t,pathRef:r,strokeDasharray:oe})}),S.createElement($h,{label:n.label}))}function mne(e){var{clipPathId:t,props:n}=e,r=S.useRef(null),i=S.useRef(0),o=S.useRef(null);return S.createElement(fne,{props:n,clipPathId:t,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:o})}var hne=(e,t)=>{var n,r;return{x:(n=e.x)!==null&&n!==void 0?n:void 0,y:(r=e.y)!==null&&r!==void 0?r:void 0,value:e.value,errorVal:gt(e.payload,t)}};class pne extends S.Component{render(){var{hide:t,dot:n,points:r,className:i,xAxisId:o,yAxisId:c,top:u,left:m,width:f,height:h,id:g,needClip:v,zIndex:b}=this.props;if(t)return null;var T=Xe("recharts-line",i),C=g,{r:E,strokeWidth:N}=iI(n),I=v1(n),P=E*2+N;return S.createElement(Bn,{zIndex:b},S.createElement(Ot,{className:T},v&&S.createElement("defs",null,S.createElement(E1,{clipPathId:C,xAxisId:o,yAxisId:c}),!I&&S.createElement("clipPath",{id:"clipPath-dots-".concat(C)},S.createElement("rect",{x:m-P/2,y:u-P/2,width:f+P,height:h+P}))),S.createElement(G5,{xAxisId:o,yAxisId:c,data:r,dataPointFormatter:hne,errorBarOffset:0},S.createElement(mne,{props:this.props,clipPathId:C}))),S.createElement(nx,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey}))}}var oI={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!0,fill:"#fff",hide:!1,isAnimationActive:!Ea.isSsr,label:!1,legendType:"line",stroke:"#3182bd",strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:Gt.line};function gne(e){var t=Lt(e,oI),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:o,animationEasing:c,connectNulls:u,dot:m,hide:f,isAnimationActive:h,label:g,legendType:v,xAxisId:b,yAxisId:T,id:C}=t,E=M1(t,ene),{needClip:N}=Qh(b,T),I=Jh(),P=oc(),M=mn(),j=Se(G=>Qte(G,b,T,M,C));if(P!=="horizontal"&&P!=="vertical"||j==null||I==null)return null;var{height:k,width:R,x:F,y:q}=I;return S.createElement(pne,Gu({},E,{id:C,connectNulls:u,dot:m,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:o,animationEasing:c,isAnimationActive:h,hide:f,label:g,legendType:v,xAxisId:b,yAxisId:T,points:j,layout:P,height:k,width:R,left:F,top:q,needClip:N}))}function yne(e){var{layout:t,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:o,dataKey:c,bandSize:u,displayedData:m}=e;return m.map((f,h)=>{var g=gt(f,c);if(t==="horizontal"){var v=Cm({axis:n,ticks:i,bandSize:u,entry:f,index:h}),b=jt(g)?null:r.scale(g);return{x:v,y:b,value:g,payload:f}}var T=jt(g)?null:n.scale(g),C=Cm({axis:r,ticks:o,bandSize:u,entry:f,index:h});return T==null||C==null?null:{x:T,y:C,value:g,payload:f}}).filter(Boolean)}function vne(e){var t=Lt(e,oI),n=mn();return S.createElement(Yh,{id:t.id,type:"line"},r=>S.createElement(S.Fragment,null,S.createElement(A1,{legendPayload:ane(t)}),S.createElement(Kh,{fn:one,args:t}),S.createElement(C1,{type:"line",id:r,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),S.createElement(gne,Gu({},t,{id:r}))))}var Cr=S.memo(vne);Cr.displayName="Line";var sI=(e,t,n,r)=>_i(e,"xAxis",t,r),lI=(e,t,n,r)=>Ni(e,"xAxis",t,r),cI=(e,t,n,r)=>_i(e,"yAxis",n,r),uI=(e,t,n,r)=>Ni(e,"yAxis",n,r),xne=J([Ke,sI,cI,lI,uI],(e,t,n,r,i)=>Mi(e,"xAxis")?So(t,r,!1):So(n,i,!1)),bne=(e,t,n,r,i)=>i,dI=J([ud,bne],(e,t)=>e.filter(n=>n.type==="area").find(n=>n.id===t)),wne=(e,t,n,r,i)=>{var o,c=dI(e,t,n,r,i);if(c!=null){var u=Ke(e),m=Mi(u,"xAxis"),f;if(m?f=Fu(e,"yAxis",n,r):f=Fu(e,"xAxis",t,r),f!=null){var{stackId:h}=c,g=Dh(c);if(!(h==null||g==null)){var v=(o=f[h])===null||o===void 0?void 0:o.stackedData;return v==null?void 0:v.find(b=>b.key===g)}}}},Sne=J([Ke,sI,cI,lI,uI,wne,od,xne,dI,AK],(e,t,n,r,i,o,c,u,m,f)=>{var{chartData:h,dataStartIndex:g,dataEndIndex:v}=c;if(!(m==null||e!=="horizontal"&&e!=="vertical"||t==null||n==null||r==null||i==null||r.length===0||i.length===0||u==null)){var{data:b}=m,T;if(b&&b.length>0?T=b:T=h==null?void 0:h.slice(g,v+1),T!=null)return Fne({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:g,areaSettings:m,stackedData:o,displayedData:T,chartBaseValue:f,bandSize:u})}}),Ane=["id"],Cne=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function Ss(){return Ss=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{dataKey:t,name:n,stroke:r,fill:i,legendType:o,hide:c}=e;return[{inactive:c,dataKey:t,type:o,color:Zm(r,i),value:No(n,t),payload:e}]};function Mne(e){var{dataKey:t,data:n,stroke:r,strokeWidth:i,fill:o,name:c,hide:u,unit:m}=e;return{dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:o,dataKey:t,nameKey:void 0,name:No(c,t),hide:u,type:e.tooltipType,color:Zm(r,o),unit:m}}}function Pne(e){var{clipPathId:t,points:n,props:r}=e,{needClip:i,dot:o,dataKey:c}=r,u=Kn(r);return S.createElement(z5,{points:n,dot:o,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:c,baseProps:u,needClip:i,clipPathId:t})}function Ine(e){var{showLabels:t,children:n,points:r}=e,i=r.map(o=>{var c,u,m={x:(c=o.x)!==null&&c!==void 0?c:0,y:(u=o.y)!==null&&u!==void 0?u:0,width:0,lowerWidth:0,upperWidth:0,height:0};return Ml(Ml({},m),{},{value:o.value,payload:o.payload,parentViewBox:void 0,viewBox:m,fill:void 0})});return S.createElement(h1,{value:t?i:void 0},n)}function fj(e){var{points:t,baseLine:n,needClip:r,clipPathId:i,props:o}=e,{layout:c,type:u,stroke:m,connectNulls:f,isRange:h}=o,{id:g}=o,v=fI(o,Ane),b=Kn(v),T=Mn(v);return S.createElement(S.Fragment,null,(t==null?void 0:t.length)>1&&S.createElement(Ot,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},S.createElement(Ol,Ss({},T,{id:g,points:t,connectNulls:f,type:u,baseLine:n,layout:c,stroke:"none",className:"recharts-area-area"})),m!=="none"&&S.createElement(Ol,Ss({},b,{className:"recharts-area-curve",layout:c,type:u,connectNulls:f,fill:"none",points:t})),m!=="none"&&h&&S.createElement(Ol,Ss({},b,{className:"recharts-area-curve",layout:c,type:u,connectNulls:f,fill:"none",points:n}))),S.createElement(Pne,{points:t,props:v,clipPathId:i}))}function kne(e){var{alpha:t,baseLine:n,points:r,strokeWidth:i}=e,o=r[0].y,c=r[r.length-1].y;if(!dt(o)||!dt(c))return null;var u=t*Math.abs(o-c),m=Math.max(...r.map(f=>f.x||0));return we(n)?m=Math.max(n,m):n&&Array.isArray(n)&&n.length&&(m=Math.max(...n.map(f=>f.x||0),m)),we(m)?S.createElement("rect",{x:0,y:of.y||0));return we(n)?m=Math.max(n,m):n&&Array.isArray(n)&&n.length&&(m=Math.max(...n.map(f=>f.y||0),m)),we(m)?S.createElement("rect",{x:o{typeof b=="function"&&b(),E(!1)},[b]),P=S.useCallback(()=>{typeof v=="function"&&v(),E(!0)},[v]),M=i.current,j=o.current;return S.createElement(Ine,{showLabels:N,points:c},r.children,S.createElement(sc,{animationId:T,begin:f,duration:h,isActive:m,easing:g,onAnimationEnd:I,onAnimationStart:P,key:T},k=>{if(M){var R=M.length/c.length,F=k===1?c:c.map((G,H)=>{var V=Math.floor(H*R);if(M[V]){var oe=M[V];return Ml(Ml({},G),{},{x:ot(oe.x,G.x,k),y:ot(oe.y,G.y,k)})}return G}),q;return we(u)?q=ot(j,u,k):jt(u)||sr(u)?q=ot(j,0,k):q=u.map((G,H)=>{var V=Math.floor(H*R);if(Array.isArray(j)&&j[V]){var oe=j[V];return Ml(Ml({},G),{},{x:ot(oe.x,G.x,k),y:ot(oe.y,G.y,k)})}return G}),k>0&&(i.current=F,o.current=q),S.createElement(fj,{points:F,baseLine:q,needClip:t,clipPathId:n,props:r})}return k>0&&(i.current=c,o.current=u),S.createElement(Ot,null,m&&S.createElement("defs",null,S.createElement("clipPath",{id:"animationClipPath-".concat(n)},S.createElement(Rne,{alpha:k,points:c,baseLine:u,layout:r.layout,strokeWidth:r.strokeWidth}))),S.createElement(Ot,{clipPath:"url(#animationClipPath-".concat(n,")")},S.createElement(fj,{points:c,baseLine:u,needClip:t,clipPathId:n,props:r})))}),S.createElement($h,{label:r.label}))}function Lne(e){var{needClip:t,clipPathId:n,props:r}=e,i=S.useRef(null),o=S.useRef();return S.createElement(One,{needClip:t,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:o})}class Une extends S.PureComponent{render(){var{hide:t,dot:n,points:r,className:i,top:o,left:c,needClip:u,xAxisId:m,yAxisId:f,width:h,height:g,id:v,baseLine:b,zIndex:T}=this.props;if(t)return null;var C=Xe("recharts-area",i),E=v,{r:N,strokeWidth:I}=iI(n),P=v1(n),M=N*2+I;return S.createElement(Bn,{zIndex:T},S.createElement(Ot,{className:C},u&&S.createElement("defs",null,S.createElement(E1,{clipPathId:E,xAxisId:m,yAxisId:f}),!P&&S.createElement("clipPath",{id:"clipPath-dots-".concat(E)},S.createElement("rect",{x:c-M/2,y:o-M/2,width:h+M,height:g+M}))),S.createElement(Lne,{needClip:u,clipPathId:E,props:this.props})),S.createElement(nx,{points:r,mainColor:Zm(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot}),this.props.isRange&&Array.isArray(b)&&S.createElement(nx,{points:b,mainColor:Zm(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot}))}}var mI={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!1,fill:"#3182bd",fillOpacity:.6,hide:!1,isAnimationActive:!Ea.isSsr,legendType:"line",stroke:"#3182bd",xAxisId:0,yAxisId:0,zIndex:Gt.area};function Bne(e){var t,n=Lt(e,mI),{activeDot:r,animationBegin:i,animationDuration:o,animationEasing:c,connectNulls:u,dot:m,fill:f,fillOpacity:h,hide:g,isAnimationActive:v,legendType:b,stroke:T,xAxisId:C,yAxisId:E}=n,N=fI(n,Cne),I=oc(),P=c5(),{needClip:M}=Qh(C,E),j=mn(),{points:k,isRange:R,baseLine:F}=(t=Se(Z=>Sne(Z,C,E,j,e.id)))!==null&&t!==void 0?t:{},q=Jh();if(I!=="horizontal"&&I!=="vertical"||q==null||P!=="AreaChart"&&P!=="ComposedChart")return null;var{height:G,width:H,x:V,y:oe}=q;return!k||!k.length?null:S.createElement(Une,Ss({},N,{activeDot:r,animationBegin:i,animationDuration:o,animationEasing:c,baseLine:F,connectNulls:u,dot:m,fill:f,fillOpacity:h,height:G,hide:g,layout:I,isAnimationActive:v,isRange:R,legendType:b,needClip:M,points:k,stroke:T,width:H,left:V,top:oe,xAxisId:C,yAxisId:E}))}var zne=(e,t,n,r,i)=>{var o=n??t;if(we(o))return o;var c=e==="horizontal"?i:r,u=c.scale.domain();if(c.type==="number"){var m=Math.max(u[0],u[1]),f=Math.min(u[0],u[1]);return o==="dataMin"?f:o==="dataMax"||m<0?m:Math.max(Math.min(u[0],u[1]),0)}return o==="dataMin"?u[0]:o==="dataMax"?u[1]:u[0]};function Fne(e){var{areaSettings:{connectNulls:t,baseValue:n,dataKey:r},stackedData:i,layout:o,chartBaseValue:c,xAxis:u,yAxis:m,displayedData:f,dataStartIndex:h,xAxisTicks:g,yAxisTicks:v,bandSize:b}=e,T=i&&i.length,C=zne(o,c,n,u,m),E=o==="horizontal",N=!1,I=f.map((M,j)=>{var k;T?k=i[h+j]:(k=gt(M,r),Array.isArray(k)?N=!0:k=[C,k]);var R=k[1]==null||T&&!t&>(M,r)==null;return E?{x:Cm({axis:u,ticks:g,bandSize:b,entry:M,index:j}),y:R?null:m.scale(k[1]),value:k,payload:M}:{x:R?null:u.scale(k[1]),y:Cm({axis:m,ticks:v,bandSize:b,entry:M,index:j}),value:k,payload:M}}),P;return T||N?P=I.map(M=>{var j=Array.isArray(M.value)?M.value[0]:null;return E?{x:M.x,y:j!=null&&M.y!=null?m.scale(j):null,payload:M.payload}:{x:j!=null?u.scale(j):null,y:M.y,payload:M.payload}}):P=E?m.scale(C):u.scale(C),{points:I,baseLine:P,isRange:N}}function qne(e){var t=Lt(e,mI),n=mn();return S.createElement(Yh,{id:t.id,type:"area"},r=>S.createElement(S.Fragment,null,S.createElement(A1,{legendPayload:jne(t)}),S.createElement(Kh,{fn:Mne,args:t}),S.createElement(C1,{type:"area",id:r,data:t.data,dataKey:t.dataKey,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,stackId:qM(t.stackId),hide:t.hide,barSize:void 0,baseValue:t.baseValue,isPanorama:n,connectNulls:t.connectNulls}),S.createElement(Bne,Ss({},t,{id:r}))))}var da=S.memo(qne);da.displayName="Area";var Gne=["dangerouslySetInnerHTML","ticks"],$ne=["id"],Hne=["domain"],Vne=["domain"];function ax(){return ax=Object.assign?Object.assign.bind():function(e){for(var t=1;t(t(cZ(e)),()=>{t(uZ(e))}),[e,t]),null}var Wne=e=>{var{xAxisId:t,className:n}=e,r=Se(nb),i=mn(),o="xAxis",c=Se(E=>Ao(E,o,t,i)),u=Se(E=>BP(E,o,t,i)),m=Se(E=>RP(E,t)),f=Se(E=>bY(E,t)),h=Se(E=>pP(E,t));if(m==null||f==null||h==null)return null;var{dangerouslySetInnerHTML:g,ticks:v}=e,b=eh(e,Gne),{id:T}=h,C=eh(h,$ne);return S.createElement(j1,ax({},b,C,{scale:c,x:f.x,y:f.y,width:m.width,height:m.height,className:Xe("recharts-".concat(o," ").concat(o),n),viewBox:r,ticks:u,axisType:o}))},Jne={allowDataOverflow:xr.allowDataOverflow,allowDecimals:xr.allowDecimals,allowDuplicatedCategory:xr.allowDuplicatedCategory,height:xr.height,hide:!1,mirror:xr.mirror,orientation:xr.orientation,padding:xr.padding,reversed:xr.reversed,scale:xr.scale,tickCount:xr.tickCount,type:xr.type,xAxisId:0},Qne=e=>{var t,n,r,i,o,c=Lt(e,Jne);return S.createElement(S.Fragment,null,S.createElement(Yne,{interval:(t=c.interval)!==null&&t!==void 0?t:"preserveEnd",id:c.xAxisId,scale:c.scale,type:c.type,padding:c.padding,allowDataOverflow:c.allowDataOverflow,domain:c.domain,dataKey:c.dataKey,allowDuplicatedCategory:c.allowDuplicatedCategory,allowDecimals:c.allowDecimals,tickCount:c.tickCount,includeHidden:(n=c.includeHidden)!==null&&n!==void 0?n:!1,reversed:c.reversed,ticks:c.ticks,height:c.height,orientation:c.orientation,mirror:c.mirror,hide:c.hide,unit:c.unit,name:c.name,angle:(r=c.angle)!==null&&r!==void 0?r:0,minTickGap:(i=c.minTickGap)!==null&&i!==void 0?i:5,tick:(o=c.tick)!==null&&o!==void 0?o:!0,tickFormatter:c.tickFormatter}),S.createElement(Wne,c))},Xne=(e,t)=>{var{domain:n}=e,r=eh(e,Hne),{domain:i}=t,o=eh(t,Vne);return tc(r,o)?Array.isArray(n)&&n.length===2&&Array.isArray(i)&&i.length===2?n[0]===i[0]&&n[1]===i[1]:tc({domain:n},{domain:i}):!1},St=S.memo(Qne,Xne);St.displayName="XAxis";var Zne=["dangerouslySetInnerHTML","ticks"],ere=["id"],tre=["domain"],nre=["domain"];function ox(){return ox=Object.assign?Object.assign.bind():function(e){for(var t=1;t(t(dZ(e)),()=>{t(fZ(e))}),[e,t]),null}var are=e=>{var{yAxisId:t,className:n,width:r,label:i}=e,o=S.useRef(null),c=S.useRef(null),u=Se(nb),m=mn(),f=bt(),h="yAxis",g=Se(j=>Ao(j,h,t,m)),v=Se(j=>OP(j,t)),b=Se(j=>SY(j,t)),T=Se(j=>BP(j,h,t,m)),C=Se(j=>gP(j,t));if(S.useLayoutEffect(()=>{if(!(r!=="auto"||!v||m1(i)||S.isValidElement(i)||C==null)){var j=o.current;if(j){var k=j.getCalculatedWidth();Math.round(v.width)!==Math.round(k)&&f(mZ({id:t,width:k}))}}},[T,v,f,i,t,r,C]),v==null||b==null||C==null)return null;var{dangerouslySetInnerHTML:E,ticks:N}=e,I=th(e,Zne),{id:P}=C,M=th(C,ere);return S.createElement(j1,ox({},I,M,{ref:o,labelRef:c,scale:g,x:b.x,y:b.y,tickTextProps:r==="auto"?{width:void 0}:{width:r},width:v.width,height:v.height,className:Xe("recharts-".concat(h," ").concat(h),n),viewBox:u,ticks:T,axisType:h}))},ore={allowDataOverflow:br.allowDataOverflow,allowDecimals:br.allowDecimals,allowDuplicatedCategory:br.allowDuplicatedCategory,hide:!1,mirror:br.mirror,orientation:br.orientation,padding:br.padding,reversed:br.reversed,scale:br.scale,tickCount:br.tickCount,type:br.type,width:br.width,yAxisId:0},sre=e=>{var t,n,r,i,o,c=Lt(e,ore);return S.createElement(S.Fragment,null,S.createElement(ire,{interval:(t=c.interval)!==null&&t!==void 0?t:"preserveEnd",id:c.yAxisId,scale:c.scale,type:c.type,domain:c.domain,allowDataOverflow:c.allowDataOverflow,dataKey:c.dataKey,allowDuplicatedCategory:c.allowDuplicatedCategory,allowDecimals:c.allowDecimals,tickCount:c.tickCount,padding:c.padding,includeHidden:(n=c.includeHidden)!==null&&n!==void 0?n:!1,reversed:c.reversed,ticks:c.ticks,width:c.width,orientation:c.orientation,mirror:c.mirror,hide:c.hide,unit:c.unit,name:c.name,angle:(r=c.angle)!==null&&r!==void 0?r:0,minTickGap:(i=c.minTickGap)!==null&&i!==void 0?i:5,tick:(o=c.tick)!==null&&o!==void 0?o:!0,tickFormatter:c.tickFormatter}),S.createElement(are,c))},lre=(e,t)=>{var{domain:n}=e,r=th(e,tre),{domain:i}=t,o=th(t,nre);return tc(r,o)?Array.isArray(n)&&n.length===2&&Array.isArray(i)&&i.length===2?n[0]===i[0]&&n[1]===i[1]:tc({domain:n},{domain:i}):!1},vt=S.memo(sre,lre);vt.displayName="YAxis";var Jy={exports:{}},Qy={};/** + * @license React + * use-sync-external-store-with-selector.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 mj;function cre(){if(mj)return Qy;mj=1;var e=nc();function t(m,f){return m===f&&(m!==0||1/m===1/f)||m!==m&&f!==f}var n=typeof Object.is=="function"?Object.is:t,r=e.useSyncExternalStore,i=e.useRef,o=e.useEffect,c=e.useMemo,u=e.useDebugValue;return Qy.useSyncExternalStoreWithSelector=function(m,f,h,g,v){var b=i(null);if(b.current===null){var T={hasValue:!1,value:null};b.current=T}else T=b.current;b=c(function(){function E(j){if(!N){if(N=!0,I=j,j=g(j),v!==void 0&&T.hasValue){var k=T.value;if(v(k,j))return P=k}return P=j}if(k=P,n(I,j))return k;var R=g(j);return v!==void 0&&v(k,R)?(I=j,k):(I=j,P=R)}var N=!1,I,P,M=h===void 0?null:h;return[function(){return E(f())},M===null?void 0:function(){return E(M())}]},[f,h,g,v]);var C=r(m,b[0],b[1]);return o(function(){T.hasValue=!0,T.value=C},[C]),u(C),C},Qy}var hj;function ure(){return hj||(hj=1,Jy.exports=cre()),Jy.exports}ure();function dre(e){e()}function fre(){let e=null,t=null;return{clear(){e=null,t=null},notify(){dre(()=>{let n=e;for(;n;)n.callback(),n=n.next})},get(){const n=[];let r=e;for(;r;)n.push(r),r=r.next;return n},subscribe(n){let r=!0;const i=t={callback:n,next:null,prev:t};return i.prev?i.prev.next=i:e=i,function(){!r||e===null||(r=!1,i.next?i.next.prev=i.prev:t=i.prev,i.prev?i.prev.next=i.next:e=i.next)}}}}var pj={notify(){},get:()=>[]};function mre(e,t){let n,r=pj,i=0,o=!1;function c(C){h();const E=r.subscribe(C);let N=!1;return()=>{N||(N=!0,E(),g())}}function u(){r.notify()}function m(){T.onStateChange&&T.onStateChange()}function f(){return o}function h(){i++,n||(n=e.subscribe(m),r=fre())}function g(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=pj)}function v(){o||(o=!0,h())}function b(){o&&(o=!1,g())}const T={addNestedSub:c,notifyNestedSubs:u,handleChangeWrapper:m,isSubscribed:f,trySubscribe:v,tryUnsubscribe:b,getListeners:()=>r};return T}var hre=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",pre=hre(),gre=()=>typeof navigator<"u"&&navigator.product==="ReactNative",yre=gre(),vre=()=>pre||yre?S.useLayoutEffect:S.useEffect,xre=vre(),Xy=Symbol.for("react-redux-context"),Zy=typeof globalThis<"u"?globalThis:{};function bre(){if(!S.createContext)return{};const e=Zy[Xy]??(Zy[Xy]=new Map);let t=e.get(S.createContext);return t||(t=S.createContext(null),e.set(S.createContext,t)),t}var wre=bre();function Sre(e){const{children:t,context:n,serverState:r,store:i}=e,o=S.useMemo(()=>{const m=mre(i);return{store:i,subscription:m,getServerState:r?()=>r:void 0}},[i,r]),c=S.useMemo(()=>i.getState(),[i]);xre(()=>{const{subscription:m}=o;return m.onStateChange=m.notifyNestedSubs,m.trySubscribe(),c!==i.getState()&&m.notifyNestedSubs(),()=>{m.tryUnsubscribe(),m.onStateChange=void 0}},[o,c]);const u=n||wre;return S.createElement(u.Provider,{value:o},t)}var Are=Sre,Cre=(e,t)=>t,P1=J([Cre,Ke,mP,pn,n5,_a,IW,fn],BW),I1=e=>{var t=e.currentTarget.getBoundingClientRect(),n=t.width/e.currentTarget.offsetWidth,r=t.height/e.currentTarget.offsetHeight;return{chartX:Math.round((e.clientX-t.left)/n),chartY:Math.round((e.clientY-t.top)/r)}},hI=Kr("mouseClick"),pI=Zu();pI.startListening({actionCreator:hI,effect:(e,t)=>{var n=e.payload,r=P1(t.getState(),I1(n));(r==null?void 0:r.activeIndex)!=null&&t.dispatch(RY({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var sx=Kr("mouseMove"),gI=Zu();gI.startListening({actionCreator:sx,effect:(e,t)=>{var n=e.payload,r=t.getState(),i=i1(r,r.tooltip.settings.shared),o=P1(r,I1(n));i==="axis"&&((o==null?void 0:o.activeIndex)!=null?t.dispatch(KP({activeIndex:o.activeIndex,activeDataKey:void 0,activeCoordinate:o.activeCoordinate})):t.dispatch(VP()))}});var gj={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,barSize:void 0,className:void 0,maxBarSize:void 0,stackOffset:"none",syncId:void 0,syncMethod:"index",baseValue:void 0},yI=lr({name:"rootProps",initialState:gj,reducers:{updateOptions:(e,t)=>{var n;e.accessibilityLayer=t.payload.accessibilityLayer,e.barCategoryGap=t.payload.barCategoryGap,e.barGap=(n=t.payload.barGap)!==null&&n!==void 0?n:gj.barGap,e.barSize=t.payload.barSize,e.maxBarSize=t.payload.maxBarSize,e.stackOffset=t.payload.stackOffset,e.syncId=t.payload.syncId,e.syncMethod=t.payload.syncMethod,e.className=t.payload.className,e.baseValue=t.payload.baseValue}}}),Tre=yI.reducer,{updateOptions:Ere}=yI.actions,vI=lr({name:"polarOptions",initialState:null,reducers:{updatePolarOptions:(e,t)=>t.payload}}),{updatePolarOptions:Nre}=vI.actions,_re=vI.reducer,xI=Kr("keyDown"),bI=Kr("focus"),k1=Zu();k1.startListening({actionCreator:xI,effect:(e,t)=>{var n=t.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip,o=e.payload;if(!(o!=="ArrowRight"&&o!=="ArrowLeft"&&o!=="Enter")){var c=Number(a1(i,gc(n))),u=_a(n);if(o==="Enter"){var m=Gm(n,"axis","hover",String(i.index));t.dispatch(Jv({active:!i.active,activeIndex:i.index,activeDataKey:i.dataKey,activeCoordinate:m}));return}var f=EY(n),h=f==="left-to-right"?1:-1,g=o==="ArrowRight"?1:-1,v=c+g*h;if(!(u==null||v>=u.length||v<0)){var b=Gm(n,"axis","hover",String(v));t.dispatch(Jv({active:!0,activeIndex:v.toString(),activeDataKey:void 0,activeCoordinate:b}))}}}}});k1.startListening({actionCreator:bI,effect:(e,t)=>{var n=t.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip;if(!i.active&&i.index==null){var o="0",c=Gm(n,"axis","hover",String(o));t.dispatch(Jv({activeDataKey:void 0,active:!0,activeIndex:o,activeCoordinate:c}))}}}});var zr=Kr("externalEvent"),wI=Zu();wI.startListening({actionCreator:zr,effect:(e,t)=>{if(e.payload.handler!=null){var n=t.getState(),r={activeCoordinate:yW(n),activeDataKey:o5(n),activeIndex:Co(n),activeLabel:a5(n),activeTooltipIndex:Co(n),isTooltipActive:vW(n)};e.payload.handler(r,e.payload.reactEvent)}}});var jre=J([pc],e=>e.tooltipItemPayloads),Mre=J([jre,md,(e,t,n)=>t,(e,t,n)=>n],(e,t,n,r)=>{var i=e.find(u=>u.settings.dataKey===r);if(i!=null){var{positions:o}=i;if(o!=null){var c=t(o,n);return c}}}),SI=Kr("touchMove"),AI=Zu();AI.startListening({actionCreator:SI,effect:(e,t)=>{var n=e.payload;if(!(n.touches==null||n.touches.length===0)){var r=t.getState(),i=i1(r,r.tooltip.settings.shared);if(i==="axis"){var o=P1(r,I1({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY,currentTarget:n.currentTarget}));(o==null?void 0:o.activeIndex)!=null&&t.dispatch(KP({activeIndex:o.activeIndex,activeDataKey:void 0,activeCoordinate:o.activeCoordinate}))}else if(i==="item"){var c,u=n.touches[0];if(document.elementFromPoint==null)return;var m=document.elementFromPoint(u.clientX,u.clientY);if(!m||!m.getAttribute)return;var f=m.getAttribute($M),h=(c=m.getAttribute(HM))!==null&&c!==void 0?c:void 0,g=Mre(t.getState(),f,h);t.dispatch(HP({activeDataKey:h,activeIndex:f,activeCoordinate:g}))}}}});var Pre=hM({brush:Ree,cartesianAxis:hZ,chartData:gJ,errorBars:kZ,graphicalItems:TX,layout:aq,legend:tG,options:dJ,polarAxis:zQ,polarOptions:_re,referenceElements:Vee,rootProps:Tre,tooltip:OY,zIndex:ZW}),Ire=function(t){return M9({reducer:Pre,preloadedState:t,middleware:n=>n({serializableCheck:!1}).concat([pI.middleware,gI.middleware,k1.middleware,wI.middleware,AI.middleware]),enhancers:n=>{var r=n;return typeof n=="function"&&(r=n()),r.concat(EM({type:"raf"}))},devTools:Ea.devToolsEnabled})};function CI(e){var{preloadedState:t,children:n,reduxStoreName:r}=e,i=mn(),o=S.useRef(null);if(i)return n;o.current==null&&(o.current=Ire(t));var c=Jx;return S.createElement(Are,{context:c,store:o.current},n)}function TI(e){var{layout:t,margin:n}=e,r=bt(),i=mn();return S.useEffect(()=>{i||(r(nq(t)),r(tq(n)))},[r,i,t,n]),null}function EI(e){var t=bt();return S.useEffect(()=>{t(Ere(e))},[t,e]),null}function yj(e){var{zIndex:t,isPanorama:n}=e,r=n?"recharts-zindex-panorama-":"recharts-zindex-",i=U5("".concat(r).concat(t)),o=bt();return S.useLayoutEffect(()=>(o(QW({zIndex:t,elementId:i,isPanorama:n})),()=>{o(XW({zIndex:t,isPanorama:n}))}),[o,t,i,n]),S.createElement("g",{id:i})}function vj(e){var{children:t,isPanorama:n}=e,r=Se(FW);if(!r||r.length===0)return t;var i=r.filter(c=>c<0),o=r.filter(c=>c>0);return S.createElement(S.Fragment,null,i.map(c=>S.createElement(yj,{key:c,zIndex:c,isPanorama:n})),t,o.map(c=>S.createElement(yj,{key:c,zIndex:c,isPanorama:n})))}var kre=["children"];function Dre(e,t){if(e==null)return{};var n,r,i=Rre(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r{var n=ib(),r=ab(),i=e4();if(!Ti(n)||!Ti(r))return null;var{children:o,otherAttributes:c,title:u,desc:m}=e,f,h;return c!=null&&(typeof c.tabIndex=="number"?f=c.tabIndex:f=i?0:void 0,typeof c.role=="string"?h=c.role:h=i?"application":void 0),S.createElement(Bx,nh({},c,{title:u,desc:m,role:h,tabIndex:f,width:n,height:r,style:Ore,ref:t}),o)}),Ure=e=>{var{children:t}=e,n=Se(Ah);if(!n)return null;var{width:r,height:i,y:o,x:c}=n;return S.createElement(Bx,{width:r,height:i,x:c,y:o},t)},xj=S.forwardRef((e,t)=>{var{children:n}=e,r=Dre(e,kre),i=mn();return i?S.createElement(Ure,null,S.createElement(vj,{isPanorama:!0},n)):S.createElement(Lre,nh({ref:t},r),S.createElement(vj,{isPanorama:!1},n))});function Bre(){var e=bt(),[t,n]=S.useState(null),r=Se(Sq);return S.useEffect(()=>{if(t!=null){var i=t.getBoundingClientRect(),o=i.width/t.offsetWidth;dt(o)&&o!==r&&e(iq(o))}},[t,e,r]),n}function bj(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function zre(e){for(var t=1;t(TJ(),null);function rh(e){if(typeof e=="number")return e;if(typeof e=="string"){var t=parseFloat(e);if(!Number.isNaN(t))return t}return 0}var Hre=S.forwardRef((e,t)=>{var n,r,i=S.useRef(null),[o,c]=S.useState({containerWidth:rh((n=e.style)===null||n===void 0?void 0:n.width),containerHeight:rh((r=e.style)===null||r===void 0?void 0:r.height)}),u=S.useCallback((f,h)=>{c(g=>{var v=Math.round(f),b=Math.round(h);return g.containerWidth===v&&g.containerHeight===b?g:{containerWidth:v,containerHeight:b}})},[]),m=S.useCallback(f=>{if(typeof t=="function"&&t(f),f!=null&&typeof ResizeObserver<"u"){var{width:h,height:g}=f.getBoundingClientRect();u(h,g);var v=T=>{var{width:C,height:E}=T[0].contentRect;u(C,E)},b=new ResizeObserver(v);b.observe(f),i.current=b}},[t,u]);return S.useEffect(()=>()=>{var f=i.current;f!=null&&f.disconnect()},[u]),S.createElement(S.Fragment,null,S.createElement(Ch,{width:o.containerWidth,height:o.containerHeight}),S.createElement("div",Ms({ref:m},e)))}),Vre=S.forwardRef((e,t)=>{var{width:n,height:r}=e,[i,o]=S.useState({containerWidth:rh(n),containerHeight:rh(r)}),c=S.useCallback((m,f)=>{o(h=>{var g=Math.round(m),v=Math.round(f);return h.containerWidth===g&&h.containerHeight===v?h:{containerWidth:g,containerHeight:v}})},[]),u=S.useCallback(m=>{if(typeof t=="function"&&t(m),m!=null){var{width:f,height:h}=m.getBoundingClientRect();c(f,h)}},[t,c]);return S.createElement(S.Fragment,null,S.createElement(Ch,{width:i.containerWidth,height:i.containerHeight}),S.createElement("div",Ms({ref:u},e)))}),Kre=S.forwardRef((e,t)=>{var{width:n,height:r}=e;return S.createElement(S.Fragment,null,S.createElement(Ch,{width:n,height:r}),S.createElement("div",Ms({ref:t},e)))}),Yre=S.forwardRef((e,t)=>{var{width:n,height:r}=e;return ha(n)||ha(r)?S.createElement(Vre,Ms({},e,{ref:t})):S.createElement(Kre,Ms({},e,{ref:t}))});function Wre(e){return e===!0?Hre:Yre}var Jre=S.forwardRef((e,t)=>{var{children:n,className:r,height:i,onClick:o,onContextMenu:c,onDoubleClick:u,onMouseDown:m,onMouseEnter:f,onMouseLeave:h,onMouseMove:g,onMouseUp:v,onTouchEnd:b,onTouchMove:T,onTouchStart:C,style:E,width:N,responsive:I,dispatchTouchEvents:P=!0}=e,M=S.useRef(null),j=bt(),[k,R]=S.useState(null),[F,q]=S.useState(null),G=Bre(),H=rb(),V=(H==null?void 0:H.width)>0?H.width:N,oe=(H==null?void 0:H.height)>0?H.height:i,Z=S.useCallback(re=>{G(re),typeof t=="function"&&t(re),R(re),q(re),re!=null&&(M.current=re)},[G,t,R,q]),me=S.useCallback(re=>{j(hI(re)),j(zr({handler:o,reactEvent:re}))},[j,o]),z=S.useCallback(re=>{j(sx(re)),j(zr({handler:f,reactEvent:re}))},[j,f]),Y=S.useCallback(re=>{j(VP()),j(zr({handler:h,reactEvent:re}))},[j,h]),ce=S.useCallback(re=>{j(sx(re)),j(zr({handler:g,reactEvent:re}))},[j,g]),ge=S.useCallback(()=>{j(bI())},[j]),Me=S.useCallback(re=>{j(xI(re.key))},[j]),U=S.useCallback(re=>{j(zr({handler:c,reactEvent:re}))},[j,c]),te=S.useCallback(re=>{j(zr({handler:u,reactEvent:re}))},[j,u]),ue=S.useCallback(re=>{j(zr({handler:m,reactEvent:re}))},[j,m]),fe=S.useCallback(re=>{j(zr({handler:v,reactEvent:re}))},[j,v]),Ne=S.useCallback(re=>{j(zr({handler:C,reactEvent:re}))},[j,C]),Pe=S.useCallback(re=>{P&&j(SI(re)),j(zr({handler:T,reactEvent:re}))},[j,P,T]),Re=S.useCallback(re=>{j(zr({handler:b,reactEvent:re}))},[j,b]),wt=Wre(I);return S.createElement(p5.Provider,{value:k},S.createElement(M3.Provider,{value:F},S.createElement(wt,{width:V??(E==null?void 0:E.width),height:oe??(E==null?void 0:E.height),className:Xe("recharts-wrapper",r),style:zre({position:"relative",cursor:"default",width:V,height:oe},E),onClick:me,onContextMenu:U,onDoubleClick:te,onFocus:ge,onKeyDown:Me,onMouseDown:ue,onMouseEnter:z,onMouseLeave:Y,onMouseMove:ce,onMouseUp:fe,onTouchEnd:Re,onTouchMove:Pe,onTouchStart:Ne,ref:Z},S.createElement($re,null),n)))}),Qre=["width","height","responsive","children","className","style","compact","title","desc"];function Xre(e,t){if(e==null)return{};var n,r,i=Zre(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r{var{width:n,height:r,responsive:i,children:o,className:c,style:u,compact:m,title:f,desc:h}=e,g=Xre(e,Qre),v=Kn(g);return m?S.createElement(S.Fragment,null,S.createElement(Ch,{width:n,height:r}),S.createElement(xj,{otherAttributes:v,title:f,desc:h},o)):S.createElement(Jre,{className:c,style:u,width:n,height:r,responsive:i??!1,onClick:e.onClick,onMouseLeave:e.onMouseLeave,onMouseEnter:e.onMouseEnter,onMouseMove:e.onMouseMove,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onContextMenu:e.onContextMenu,onDoubleClick:e.onDoubleClick,onTouchStart:e.onTouchStart,onTouchMove:e.onTouchMove,onTouchEnd:e.onTouchEnd},S.createElement(xj,{otherAttributes:v,title:f,desc:h,ref:t},S.createElement(Kee,null,o)))});function lx(){return lx=Object.assign?Object.assign.bind():function(e){for(var t=1;tS.createElement(Zh,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:nie,tooltipPayloadSearcher:pd,categoricalChartProps:e,ref:t})),rie=["axis","item"],jn=S.forwardRef((e,t)=>S.createElement(Zh,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:rie,tooltipPayloadSearcher:pd,categoricalChartProps:e,ref:t}));function iie(e){var t=bt();return S.useEffect(()=>{t(Nre(e))},[t,e]),null}var aie=["layout"];function cx(){return cx=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var n=Lt(e,fie);return S.createElement(uie,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:die,tooltipPayloadSearcher:pd,categoricalChartProps:n,ref:t})}),mie=["axis"],yd=S.forwardRef((e,t)=>S.createElement(Zh,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:mie,tooltipPayloadSearcher:pd,categoricalChartProps:e,ref:t})),hie=["axis"],pie=S.forwardRef((e,t)=>S.createElement(Zh,{chartName:"ComposedChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:hie,tooltipPayloadSearcher:pd,categoricalChartProps:e,ref:t}));const gie=e=>{switch(e){case"outline":return"bg-transparent border-2 border-gray-600/80 shadow-md";case"ghost":return"bg-transparent border-none shadow-none";case"interactive":return"bg-gray-800/50 backdrop-blur-sm border border-gray-700/60 rounded-xl shadow-lg transition-all duration-300 hover:bg-gray-800/80 hover:border-cyan-500/80 hover:shadow-cyan-500/10 cursor-pointer";case"default":default:return"bg-gray-800/50 backdrop-blur-sm border border-gray-700/60 rounded-xl shadow-lg"}},yie=e=>{switch(e){case"sm":return"p-3";case"md":return"p-6";case"lg":return"p-8";case"none":return"p-0";default:return"p-6"}},vie=()=>l.jsxs("div",{className:"space-y-4 animate-pulse p-6",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("div",{className:"h-6 bg-gray-700 rounded-md w-1/3"}),l.jsx("div",{className:"h-6 bg-gray-700 rounded-full w-6"})]}),l.jsxs("div",{className:"space-y-3 pt-4",children:[l.jsx("div",{className:"h-4 bg-gray-700 rounded-md w-full"}),l.jsx("div",{className:"h-4 bg-gray-700 rounded-md w-5/6"}),l.jsx("div",{className:"h-4 bg-gray-700 rounded-md w-3/4"})]}),l.jsxs("div",{className:"space-y-3 pt-6",children:[l.jsx("div",{className:"h-4 bg-gray-700 rounded-md w-1/2"}),l.jsx("div",{className:"h-4 bg-gray-700 rounded-md w-4/6"})]})]}),xie=({message:e,onRetry:t})=>l.jsxs("div",{className:"flex flex-col items-center justify-center text-center p-6 bg-red-900/20 border-t border-b border-red-500/20",children:[l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-12 w-12 text-red-400 mb-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),l.jsx("h4",{className:"text-lg font-semibold text-red-200",children:"An Error Occurred"}),l.jsx("p",{className:"text-red-300 mt-1 mb-4 max-w-md",children:e}),t&&l.jsx("button",{onClick:t,className:"px-4 py-2 bg-red-500/50 hover:bg-red-500 text-white rounded-lg text-sm font-medium transition-colors",children:"Retry"})]}),bie=({title:e,subtitle:t,icon:n,isCollapsible:r,isCollapsed:i,toggleCollapse:o,actions:c})=>{if(!e&&!t&&(!c||c.length===0)&&!r&&!n)return null;const u=f=>{r&&f.target.closest("button")===null&&o()},m=r?"cursor-pointer":"cursor-default";return l.jsxs("div",{className:`flex items-start justify-between pb-4 ${m}`,onClick:u,children:[l.jsxs("div",{className:"flex items-center flex-1 pr-4",children:[n&&l.jsx("div",{className:"mr-3 flex-shrink-0",children:n}),l.jsxs("div",{children:[e&&l.jsx("h3",{className:"text-xl font-semibold text-gray-100 truncate",children:e}),t&&l.jsx("p",{className:"text-sm text-gray-400 mt-1",children:t})]})]}),l.jsxs("div",{className:"flex items-center space-x-2 flex-shrink-0",children:[c&&c.map(f=>l.jsx("button",{onClick:f.onClick,"aria-label":f.label,disabled:f.disabled,className:"p-1.5 text-gray-400 hover:text-white hover:bg-gray-700/50 rounded-full transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:oh.cloneElement(f.icon,{className:"h-5 w-5"})},f.id)),r&&l.jsx("button",{onClick:f=>{f.stopPropagation(),o()},"aria-label":i?"Expand section":"Collapse section",className:"p-1.5 text-gray-400 hover:text-white hover:bg-gray-700/50 rounded-full transition-colors",children:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:`h-5 w-5 transition-transform duration-300 ${i?"rotate-0":"rotate-180"}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})})]})]})},wie=({children:e})=>e?l.jsx("div",{className:"pt-4 border-t border-gray-700/60",children:e}):null,pe=({title:e,subtitle:t,icon:n,children:r,className:i="",variant:o="default",padding:c="md",headerActions:u,footerContent:m,isCollapsible:f=!1,defaultCollapsed:h=!1,isLoading:g=!1,errorState:v=null,onRetry:b,loadingIndicator:T,onClick:C,isMetric:E=!1})=>{const[N,I]=S.useState(f&&h),P=S.useRef(null),[M,j]=S.useState("auto"),k=S.useCallback(()=>{f&&I(V=>!V)},[f]);S.useEffect(()=>{if(f)if(N)j(0);else{const V=P.current;j(V?V.scrollHeight:"auto")}},[N,f,r]),S.useEffect(()=>{!f&&N&&I(!1)},[f,N]);const R=gie(o),q=yie(E&&c==="md"?"sm":c),G=` + ${R} + ${i} + overflow-hidden + `,H=()=>{if(g)return T||l.jsx(vie,{});if(v)return l.jsx(xie,{message:v,onRetry:b});const V={height:f?M:"auto"},oe=e||t||n||f||u?"pt-4":"";return l.jsx("div",{style:V,className:"transition-[height] duration-500 ease-in-out overflow-hidden","aria-hidden":N,children:l.jsx("div",{ref:P,children:l.jsx("div",{className:oe,children:r})})})};return l.jsx("div",{className:G.trim().replace(/\s+/g," "),onClick:C,children:l.jsxs("div",{className:`${q} ${E?"text-center":""}`,children:[l.jsx(bie,{title:e,subtitle:t,icon:n,isCollapsible:f,isCollapsed:!!N,toggleCollapse:k,actions:u}),g||v?H():l.jsxs(l.Fragment,{children:[H(),l.jsx(wie,{children:m})]})]})})},Sie=()=>{const e=S.useContext(Ct);if(!e)throw new Error("BalanceSummary must be within a DataProvider");const{transactions:t}=e,{chartData:n,totalBalance:r,change30d:i}=S.useMemo(()=>{var C,E;const c=[...t].sort((N,I)=>new Date(N.date).getTime()-new Date(I.date).getTime());let u=0;const m=[];u=5e3,m.push({date:new Date(((C=c[0])==null?void 0:C.date)||Date.now()),balance:u});for(const N of c)N.type==="income"?u+=N.amount:u-=N.amount,m.push({date:new Date(N.date),balance:u});const f=u,h={};for(const N of m){const I=N.date.toISOString().substring(0,7);h[I]=N}const g=Object.values(h).map(N=>({name:N.date.toLocaleString("default",{month:"short"}),balance:N.balance})),v=new Date;v.setDate(v.getDate()-30);const b=(E=[...m].reverse().find(N=>N.date=0?"text-green-400":"text-red-400"}`,children:[i>=0?"+":"","$",i.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})," (",o.toFixed(1),"%)"]})]})]}),l.jsx("div",{className:"h-60",children:l.jsx(Pn,{width:"100%",height:"100%",children:l.jsxs(yd,{data:n,margin:{top:10,right:30,left:0,bottom:0},children:[l.jsx("defs",{children:l.jsxs("linearGradient",{id:"colorBalance",x1:"0",y1:"0",x2:"0",y2:"1",children:[l.jsx("stop",{offset:"5%",stopColor:"#06b6d4",stopOpacity:.8}),l.jsx("stop",{offset:"95%",stopColor:"#06b6d4",stopOpacity:0})]})}),l.jsx(St,{dataKey:"name",stroke:"#9ca3af",fontSize:12}),l.jsx(vt,{stroke:"#9ca3af",fontSize:12,domain:["dataMin - 1000","dataMax + 1000"]}),l.jsx(oi,{strokeDasharray:"3 3",stroke:"#4b5563"}),l.jsx(at,{contentStyle:{backgroundColor:"rgba(31, 41, 55, 0.8)",borderColor:"#4b5563",color:"#e5e7eb"}}),l.jsx(da,{type:"monotone",dataKey:"balance",stroke:"#06b6d4",fillOpacity:1,fill:"url(#colorBalance)"})]})})})]})},Aie=({category:e})=>{let t;switch(e){case"Dining":t="M17.657 18.657A8 8 0 016.343 7.343S7 9 9 10c2 1 5 1 7 0 2-1 2.657-1.343 2.657-1.343a8 8 0 010 10z";break;case"Salary":t="M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v.01";break;case"Shopping":t="M3 3h2l.4 2M7 13h10l4-8H5.4M7 13L5.4 5M7 13l-2.293 2.293c-.63.63-.184 1.707.707 1.707H17m0 0a2 2 0 100 4 2 2 0 000-4zm-8 2a2 2 0 11-4 0 2 2 0 014 0z";break;default:t="M4 6h16M4 10h16M4 14h16M4 18h16"}return l.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:t})})},Cie=({footprint:e})=>{const t=()=>e<2?"text-green-400":e<10?"text-yellow-400":"text-red-400";return l.jsxs("div",{className:`flex items-center text-xs ${t()}`,children:[l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-1",fill:"currentColor",viewBox:"0 0 20 20",children:l.jsx("path",{d:"M10 3.5a1.5 1.5 0 011.5 1.5v.92l5.06 4.69a1.5 1.5 0 01-.18 2.4l-3.38 1.95a1.5 1.5 0 01-1.5-.26L10 12.43l-1.5 2.25a1.5 1.5 0 01-1.5.26l-3.38-1.95a1.5 1.5 0 01-.18-2.4l5.06-4.69V5A1.5 1.5 0 0110 3.5z"})}),l.jsxs("span",{className:"font-mono",children:[e.toFixed(1)," kg CO₂"]})]})},Tie=({transactions:e,setActiveView:t})=>l.jsx(pe,{title:"Recent Transactions",footerContent:l.jsx("div",{className:"text-center",children:l.jsx("button",{onClick:()=>t(ve.Transactions),className:"text-sm font-medium text-cyan-300 hover:text-cyan-200",children:"View All Transactions"})}),children:l.jsx("div",{className:"space-y-4",children:e.map(n=>l.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg hover:bg-gray-700/50",children:[l.jsxs("div",{className:"flex items-center",children:[l.jsx("div",{className:"p-3 bg-gray-700 rounded-full mr-4 text-cyan-400",children:l.jsx(Aie,{category:n.category})}),l.jsxs("div",{children:[l.jsx("p",{className:"font-semibold text-gray-100",children:n.description}),l.jsxs("div",{className:"flex items-center space-x-2 mt-1",children:[l.jsx("p",{className:"text-sm text-gray-400",children:n.date}),n.carbonFootprint&&l.jsx("p",{className:"text-sm text-gray-500",children:"•"}),n.carbonFootprint&&l.jsx(Cie,{footprint:n.carbonFootprint})]})]})]}),l.jsxs("p",{className:`font-semibold ${n.type==="income"?"text-green-400":"text-red-400"}`,children:[n.type==="income"?"+":"-","$",n.amount.toFixed(2)]})]},n.id))})}),Eie=()=>{const e=S.useContext(Ct);if(!e)throw new Error("WealthTimeline must be within a DataProvider");const{transactions:t}=e,n=S.useMemo(()=>{const i=[...t].sort((T,C)=>new Date(T.date).getTime()-new Date(C.date).getTime());if(i.length===0)return[];let o=5e3;const c={},u={};for(const T of i){o+=T.type==="income"?T.amount:-T.amount;const C=new Date(T.date),E=C.toISOString().substring(0,7);c[E]={date:C,balance:o},u[E]=(u[E]||0)+(T.type==="income"?T.amount:-T.amount)}const m=Object.values(c).map(T=>({month:T.date.toLocaleString("default",{month:"short"}),balance:T.balance,projection:T.balance})),f=Object.values(u).slice(-3),h=f.reduce((T,C)=>T+C,0)/(f.length||1);let g=o;const v=[],b=new Date(i[i.length-1].date);for(let T=1;T<=6;T++){const C=new Date(b);C.setMonth(C.getMonth()+T),g+=h,v.push({month:C.toLocaleString("default",{month:"short"}),projection:g})}return[...m,...v]},[t]),r=i=>`$${i/1e3}k`;return l.jsx(pe,{title:"Wealth Timeline (Past & Projected)",children:l.jsx("div",{className:"h-80",children:l.jsx(Pn,{width:"100%",height:"100%",children:l.jsxs(pie,{data:n,margin:{top:10,right:30,left:0,bottom:0},children:[l.jsx("defs",{children:l.jsxs("linearGradient",{id:"colorHistory",x1:"0",y1:"0",x2:"0",y2:"1",children:[l.jsx("stop",{offset:"5%",stopColor:"#06b6d4",stopOpacity:.7}),l.jsx("stop",{offset:"95%",stopColor:"#06b6d4",stopOpacity:0})]})}),l.jsx(St,{dataKey:"month",stroke:"#9ca3af",fontSize:12}),l.jsx(vt,{stroke:"#9ca3af",fontSize:12,tickFormatter:r}),l.jsx(oi,{strokeDasharray:"1 5",stroke:"#4b5563"}),l.jsx(at,{contentStyle:{backgroundColor:"rgba(31, 41, 55, 0.9)",borderColor:"#4b5563",color:"#e5e7eb"},formatter:(i,o)=>{if(i==null)return null;const c=`$${Number(i).toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:0})}`,u=String(o),m=u.charAt(0).toUpperCase()+u.slice(1);return[c,m]}}),l.jsx(Rn,{}),l.jsx(da,{type:"monotone",dataKey:"balance",name:"History",stroke:"#06b6d4",fillOpacity:1,fill:"url(#colorHistory)"}),l.jsx(Cr,{type:"monotone",dataKey:"projection",name:"Projection",stroke:"#6366f1",strokeWidth:2,strokeDasharray:"5 5",dot:!1})]})})})})},Nie=({urgency:e})=>{const t={low:"bg-blue-500",medium:"bg-yellow-500",high:"bg-red-500"};return l.jsx("span",{className:`absolute top-2 right-2 h-3 w-3 rounded-full ${t[e]}`})},_ie=()=>{const e=S.useContext(Ct);if(!e)throw new Error("AIInsights must be within a DataProvider");const{aiInsights:t,isInsightsLoading:n}=e;return l.jsx(pe,{title:"AI Advisor Insights",className:"h-full",isLoading:n,children:l.jsx("div",{className:"space-y-4",children:t.map(r=>l.jsxs("div",{className:"relative p-4 bg-gray-700/50 rounded-lg border border-gray-600/50 hover:border-cyan-400/50 transition-all duration-200",children:[l.jsx(Nie,{urgency:r.urgency}),l.jsx("h4",{className:"font-bold text-gray-100",children:r.title}),l.jsx("p",{className:"text-sm text-gray-300 mt-1",children:r.description}),r.chartData&&r.chartData.length>0&&l.jsx("div",{className:"mt-3 h-28 pr-4",children:l.jsx(Pn,{width:"100%",height:"100%",children:l.jsxs(jn,{data:r.chartData,layout:"vertical",margin:{top:5,right:0,left:0,bottom:5},children:[l.jsx(St,{type:"number",hide:!0}),l.jsx(vt,{type:"category",dataKey:"name",axisLine:!1,tickLine:!1,fontSize:11,stroke:"#9ca3af",width:85,style:{textTransform:"capitalize"}}),l.jsx(at,{cursor:{fill:"rgba(100,116,139,0.1)"},contentStyle:{backgroundColor:"rgba(31, 41, 55, 0.8)",borderColor:"#4b5563",fontSize:"12px"},formatter:i=>[`$${i.toFixed(2)}`,"Spent"]}),l.jsx(it,{dataKey:"value",fill:"#06b6d4",radius:[0,4,4,0],barSize:12})]})})})]},r.id))})})},jie=({treesPlanted:e,progress:t})=>{const n=()=>l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-10 w-10 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M4.5 17.5l4-4 4 4M4.5 21.5h15M12 5.5v12m0 0l-4-4m4 4l4-4"})});return l.jsx(pe,{title:"Our Green Impact",className:"h-full",children:l.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center",children:[l.jsx(n,{}),l.jsx("p",{className:"text-5xl font-bold text-white mt-4",children:e}),l.jsx("p",{className:"text-gray-400 mt-1",children:"Trees Planted"}),l.jsx("div",{className:"w-full bg-gray-700 rounded-full h-2.5 mt-6",children:l.jsx("div",{className:"bg-gradient-to-r from-green-400 to-cyan-500 h-2.5 rounded-full",style:{width:`${t}%`}})}),l.jsxs("p",{className:"text-xs text-gray-500 mt-2",children:[t,"% to the next tree"]})]})})},Mie=()=>l.jsxs("svg",{width:"88",height:"34",viewBox:"0 0 88 34",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("path",{d:"M82.2 3.82c-3.32 0-5.83 2.5-5.83 5.82 0 3.31 2.51 5.82 5.83 5.82 3.31 0 5.82-2.5 5.82-5.82 0-3.31-2.51-5.82-5.82-5.82Zm0 9.14c-1.87 0-3.32-1.45-3.32-3.32 0-1.87 1.45-3.32 3.32-3.32 1.87 0 3.31-1.45 3.31-3.32 0-1.87-1.44-3.32-3.31-3.32-1.87 0-3.32-1.45-3.32-3.32s1.45-3.32 3.32-3.32 3.31 1.45 3.31 3.32c0 1.87 1.45 3.32 3.32 3.32s3.32-1.45 3.32-3.32-1.45-3.32-3.32-3.32-3.31-1.45-3.31-3.32c0-3.31 2.5-5.82 5.82-5.82s5.82 2.5 5.82 5.82-2.5 5.82-5.82 5.82c-1.87 0-3.32 1.45-3.32 3.31 0 1.87-1.45 3.32-3.32 3.32Z",fill:"#fff"}),l.jsx("path",{d:"M25.86 10.93c0 4.14-3.55 7.4-7.93 7.4-4.39 0-7.94-3.26-7.94-7.4S13.54 3.53 17.93 3.53c4.38 0 7.93 3.26 7.93 7.4Zm-10.45 0c0 1.45 1.12 2.5 2.52 2.5 1.39 0 2.51-1.05 2.51-2.5 0-1.45-1.12-2.5-2.51-2.5-1.4 0-2.52 1.05-2.52 2.5Z",fill:"#fff"}),l.jsx("path",{d:"M49.6 10.93c0 4.14-3.54 7.4-7.93 7.4-4.38 0-7.93-3.26-7.93-7.4S37.29 3.53 41.67 3.53c4.39 0 7.93 3.26 7.93 7.4Zm-10.45 0c0 1.45 1.12 2.5 2.52 2.5 1.4 0 2.52-1.05 2.52-2.5 0-1.45-1.12-2.5-2.52-2.5-1.4 0-2.52 1.05-2.52 2.5Z",fill:"#fff"}),l.jsx("path",{d:"M68.8 3.82c-3.32 0-5.83 2.5-5.83 5.82 0 3.31 2.51 5.82 5.83 5.82 3.31 0 5.82-2.5 5.82-5.82 0-3.31-2.51-5.82-5.82-5.82Zm0 9.14c-1.87 0-3.32-1.45-3.32-3.32 0-1.87 1.45-3.32 3.32-3.32s3.31-1.45 3.31-3.32c0-1.87-1.44-3.32-3.31-3.32-1.87 0-3.32-1.45-3.32-3.32s1.45-3.32 3.32-3.32 3.31 1.45 3.31 3.32c0 1.87 1.45 3.32 3.32 3.32s3.32-1.45 3.32-3.32-1.45-3.32-3.32-3.32-3.31-1.45-3.31-3.32c0-3.31 2.5-5.82 5.82-5.82s5.82 2.5 5.82 5.82-2.5 5.82-5.82 5.82c-1.87 0-3.32 1.45-3.32 3.31 0 1.87-1.45 3.32-3.32 3.32Z",fill:"#fff"}),l.jsx("path",{d:"M25.86 28.33c0 2.2-1.78 3.97-3.97 3.97h-7.93c-2.2 0-3.97-1.77-3.97-3.97v-7.93c0-2.2 1.78-3.97 3.97-3.97h7.93c2.2 0 3.97 1.77 3.97 3.97v7.93Z",fill:"#fff"}),l.jsx("path",{d:"M17.93 25.43c-2.2 0-3.97-1.78-3.97-3.97s1.78-3.97 3.97-3.97 3.97 1.78 3.97 3.97-1.78 3.97-3.97 3.97Z",fill:"#0D0F2A"}),l.jsx("path",{d:"M2.5 18.23c-1.4 0-2.5-1.12-2.5-2.51V2.5C0 1.1 1.1 0 2.5 0s2.5 1.1 2.5 2.5v13.22c0 1.39-1.1 2.51-2.5 2.51Z",fill:"#fff"})]}),Pie=({isOpen:e,onClose:t,onSuccess:n})=>{const[r,i]=S.useState("select"),[o,c]=S.useState(null);S.useEffect(()=>{e||setTimeout(()=>{i("select"),c(null)},300)},[e]);const u=f=>{c(f),i("connecting"),setTimeout(()=>{i("connected")},2500),setTimeout(()=>{const h=`public-sandbox-${Math.random().toString(36).substring(7)}`,g={institution:{name:f.name,institution_id:f.institution_id},accounts:[{id:`acct_${Math.random().toString(36).substring(7)}`,name:"Plaid Checking",mask:Math.floor(1e3+Math.random()*9e3).toString(),type:"checking",subtype:"checking"}],link_session_id:`link-session-${Math.random().toString(36).substring(7)}`};n(h,g),t()},3500)},m=()=>{switch(r){case"connecting":return l.jsxs("div",{className:"text-center py-16",children:[l.jsx("div",{className:"w-12 h-12 mx-auto mb-4",children:o==null?void 0:o.logo}),l.jsxs("div",{className:"relative w-24 h-24 mx-auto",children:[l.jsx("div",{className:"absolute inset-0 border-2 border-gray-600 rounded-full"}),l.jsx("div",{className:"absolute inset-0 border-t-2 border-white rounded-full animate-spin"})]}),l.jsxs("h3",{className:"text-lg font-semibold text-white mt-6",children:["Connecting to ",o==null?void 0:o.name]}),l.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"This may take a few seconds..."})]});case"connected":return l.jsxs("div",{className:"text-center py-16",children:[l.jsx("div",{className:"w-12 h-12 mx-auto mb-4",children:o==null?void 0:o.logo}),l.jsx("div",{className:"w-24 h-24 mx-auto rounded-full bg-green-500/20 flex items-center justify-center",children:l.jsx("svg",{className:"h-12 w-12 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 13l4 4L19 7"})})}),l.jsx("h3",{className:"text-lg font-semibold text-white mt-6",children:"Connected!"}),l.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"You're all set."})]});case"select":default:return l.jsxs("div",{children:[l.jsx("p",{className:"text-center font-semibold text-white mb-1",children:"Select your bank"}),l.jsx("p",{className:"text-center text-xs text-gray-400 mb-6",children:"By selecting your bank, you agree to the Plaid End User Privacy Policy."}),l.jsx("div",{className:"space-y-2",children:E3.map(f=>l.jsxs("button",{onClick:()=>u(f),className:"w-full flex items-center p-3 bg-gray-700/50 hover:bg-gray-700 rounded-lg transition-colors",children:[f.logo,l.jsx("span",{className:"ml-4 font-medium text-gray-200",children:f.name})]},f.name))})]})}};return l.jsx("div",{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 backdrop-blur-sm transition-opacity duration-300 ${e?"opacity-100":"opacity-0 pointer-events-none"}`,children:l.jsxs("div",{className:"bg-gray-800 rounded-lg p-6 max-w-sm w-full border border-gray-700 shadow-2xl",children:[l.jsxs("div",{className:"flex justify-between items-center mb-6",children:[l.jsx(Mie,{}),l.jsx("button",{onClick:t,className:"text-gray-500 hover:text-white",children:"×"})]}),m()]})})},_I=({onSuccess:e,className:t})=>{const[n,r]=S.useState(!1);return l.jsxs(l.Fragment,{children:[l.jsxs("button",{onClick:()=>r(!0),className:`w-full flex justify-center items-center py-3 px-4 border border-transparent rounded-lg shadow-sm text-sm font-medium text-white bg-[#000000] hover:bg-gray-900 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-cyan-500 ${t||""}`,children:[l.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"mr-2",children:[l.jsx("path",{d:"M16.5 10.5c0 .828-.672 1.5-1.5 1.5s-1.5-.672-1.5-1.5.672-1.5 1.5-1.5 1.5.672 1.5 1.5Z",fill:"#fff"}),l.jsx("path",{d:"M12.75 10.5c0 2.761-2.239 5-5 5s-5-2.239-5-5 2.239-5 5-5 5 2.239 5 5ZM7.75 12.5a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z",fill:"#fff"}),l.jsx("path",{d:"M21.25 10.5c0 2.761-2.239 5-5 5s-5-2.239-5-5 2.239-5 5-5 5 2.239 5 5ZM16.25 12.5a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z",fill:"#fff"})]}),"Securely Link with Plaid"]}),l.jsx(Pie,{isOpen:n,onClose:()=>r(!1),onSuccess:e})]})},ev=({isOpen:e,onClose:t,children:n,title:r})=>e?l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 backdrop-blur-sm",onClick:t,children:l.jsxs("div",{className:"bg-gray-800 rounded-lg shadow-2xl max-w-md w-full border border-gray-700",onClick:i=>i.stopPropagation(),children:[l.jsxs("div",{className:"p-4 border-b border-gray-700 flex justify-between items-center",children:[l.jsx("h3",{className:"text-lg font-semibold text-white",children:r}),l.jsx("button",{onClick:t,className:"text-gray-400 hover:text-white",children:"×"})]}),l.jsx("div",{className:"p-6",children:n})]})}):null,Iie=({isImporting:e,bankName:t})=>{const[n,r]=S.useState(0),i=[`Connecting to ${t||"your bank"}...`,"Securely importing transactions...","AI is analyzing your new financial data...","Updating your dashboard..."];return S.useEffect(()=>{if(e){r(0);const o=setInterval(()=>{r(c=>(c+1)%i.length)},1500);return()=>clearInterval(o)}},[e,t]),e?l.jsxs("div",{className:"fixed inset-0 bg-gray-950/90 flex flex-col items-center justify-center z-[100] backdrop-blur-md",children:[l.jsxs("div",{className:"relative w-24 h-24",children:[l.jsx("div",{className:"absolute inset-0 border-4 border-cyan-500/30 rounded-full"}),l.jsx("div",{className:"absolute inset-2 border-4 border-cyan-500/40 rounded-full animate-spin-slow"}),l.jsx("div",{className:"absolute inset-4 border-4 border-t-cyan-500 border-transparent rounded-full animate-spin"})]}),l.jsx("p",{className:"text-white text-lg mt-8 font-semibold animate-pulse",children:i[n]})]}):null},R1={video:({className:e})=>l.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"})}),music:({className:e})=>l.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19V6l12-3v13M9 19c0 1.105-1.343 2-3 2s-3-.895-3-2 1.343-2 3-2 3 .895 3 2zm12-3c0 1.105-1.343 2-3 2s-3-.895-3-2 1.343-2 3-2 3 .895 3 2z"})}),cloud:({className:e})=>l.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 15a4 4 0 004 4h9a5 5 0 10-.1-9.999 5.002 5.002 0 10-9.78 2.096A4.001 4.001 0 003 15z"})}),plane:({className:e})=>l.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})}),rocket:({className:e})=>l.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),send:({className:e})=>l.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})}),bill:({className:e})=>l.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),deposit:({className:e})=>l.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z"})})},kie=()=>{const e=S.useContext(Ct);if(!e)throw new Error("LinkAccountPrompt must be used within a DataProvider");const{handlePlaidSuccess:t}=e;return l.jsx(pe,{title:"Welcome to Demo Bank",variant:"default",children:l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:"w-16 h-16 mx-auto bg-cyan-500/20 rounded-full flex items-center justify-center text-cyan-300 mb-4",children:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"})})}),l.jsx("h3",{className:"text-xl font-semibold text-white",children:"Connect Your Financial World"}),l.jsx("p",{className:"text-gray-400 mt-2 mb-6 max-w-md mx-auto",children:"To unlock the full power of Demo Bank, connect your primary bank account. This will enable a unified financial view, AI-powered insights, and automated transaction tracking."}),l.jsx("div",{className:"max-w-xs mx-auto",children:l.jsx(_I,{onSuccess:t})})]})})},Die=({gamification:e,onClick:t})=>{const{score:n,level:r,levelName:i,progress:o}=e,c=2*Math.PI*55,u=c-n/1e3*c;return l.jsx(pe,{title:"Financial Health",className:"h-full",variant:"interactive",onClick:t,children:l.jsxs("div",{className:"flex flex-col justify-between h-full",children:[l.jsx("div",{className:"relative flex items-center justify-center h-40",children:l.jsxs("svg",{className:"w-full h-full",viewBox:"0 0 120 120",children:[l.jsx("circle",{className:"text-gray-700",strokeWidth:"10",stroke:"currentColor",fill:"transparent",r:"55",cx:"60",cy:"60"}),l.jsx("circle",{className:"text-cyan-400 transition-all duration-1000 ease-in-out",strokeWidth:"10",strokeDasharray:c,strokeDashoffset:u,strokeLinecap:"round",stroke:"currentColor",fill:"transparent",r:"55",cx:"60",cy:"60",transform:"rotate(-90 60 60)"}),l.jsx("text",{x:"50%",y:"50%",textAnchor:"middle",dy:".3em",className:"text-3xl font-bold fill-white",children:n})]})}),l.jsxs("div",{className:"text-center mt-4",children:[l.jsx("p",{className:"font-semibold text-lg text-white",children:i}),l.jsxs("p",{className:"text-sm text-gray-400",children:["Level ",r]}),l.jsx("div",{className:"w-full bg-gray-700 rounded-full h-2.5 mt-3",children:l.jsx("div",{className:"bg-gradient-to-r from-cyan-500 to-indigo-500 h-2.5 rounded-full",style:{width:`${o}%`}})})]})]})})},Rie=({onAction:e})=>{const t=[{name:"Send Money",icon:"send"},{name:"Pay Bill",icon:"bill"},{name:"Deposit",icon:"deposit"}];return l.jsx(pe,{title:"Quick Actions",children:l.jsx("div",{className:"grid grid-cols-3 gap-4 text-center",children:t.map(n=>{const r=R1[n.icon];return l.jsxs("button",{onClick:()=>e(n.name),className:"flex flex-col items-center p-2 rounded-lg hover:bg-gray-700/50 transition-colors",children:[l.jsx("div",{className:"w-12 h-12 bg-cyan-500/20 rounded-full flex items-center justify-center text-cyan-300 mb-2",children:l.jsx(r,{className:"w-6 h-6"})}),l.jsx("span",{className:"text-xs font-medium text-gray-300",children:n.name})]},n.name)})})})},Oie=({rewards:e,onClick:t})=>l.jsx(pe,{title:"Rewards Points",className:"h-full",variant:"interactive",onClick:t,children:l.jsxs("div",{className:"flex flex-col justify-center items-center h-full text-center",children:[l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-10 w-10 text-yellow-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 3v4M3 5h4M6 17v4m-2-2h4m5-16l2.286 6.857L21 12l-5.714 2.143L13 21l-2.286-6.857L5 12l5.714-2.143L13 3z"})}),l.jsx("p",{className:"text-4xl font-bold text-white mt-2",children:e.balance.toLocaleString()}),l.jsx("p",{className:"text-gray-400 text-sm",children:e.currency}),l.jsx("div",{className:"mt-4 px-4 py-2 bg-cyan-600/50 text-white rounded-lg text-sm font-medium",children:"View Rewards"})]})}),Lie=({creditScore:e,onClick:t})=>{const{score:n,change:r,rating:i}=e,o=(n-300)/550*100,c=2*Math.PI*40,u=c-o/100*c,m={Excellent:"text-green-400",Good:"text-cyan-400",Fair:"text-yellow-400",Poor:"text-red-400"};return l.jsx(pe,{title:"Credit Score",variant:"interactive",onClick:t,children:l.jsxs("div",{className:"flex items-center justify-center space-x-4",children:[l.jsxs("div",{className:"relative w-24 h-24",children:[l.jsxs("svg",{className:"w-full h-full",viewBox:"0 0 100 100",children:[l.jsx("path",{className:"text-gray-700",strokeWidth:"8",stroke:"currentColor",fill:"transparent",d:"M 50,10 a 40,40 0 0,1 0,80 a 40,40 0 0,1 0,-80"}),l.jsx("path",{className:m[i],strokeWidth:"8",strokeDasharray:c,strokeDashoffset:u,strokeLinecap:"round",stroke:"currentColor",fill:"transparent",d:"M 50,10 a 40,40 0 0,1 0,80 a 40,40 0 0,1 0,-80"})]}),l.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-2xl font-bold text-white",children:n})]}),l.jsxs("div",{className:"text-center",children:[l.jsx("p",{className:`text-lg font-semibold ${m[i]}`,children:i}),l.jsxs("p",{className:r>0?"text-green-400 text-sm":"text-red-400 text-sm",children:[r>0?`+${r}`:r," pts"]})]})]})})},Uie=({onClick:e})=>{const[t,n]=S.useState("All Systems Secure"),[r,i]=S.useState(`Last scan: ${new Date().toLocaleTimeString()}`),[o,c]=S.useState("text-green-400");return S.useEffect(()=>{const u=[{status:"All Systems Secure",sub:`Last scan: ${new Date().toLocaleTimeString()}`,color:"text-green-400"},{status:"Running Threat Scan...",sub:"Heuristic analysis in progress",color:"text-cyan-400"},{status:"All Systems Secure",sub:`Last scan: ${new Date().toLocaleTimeString()}`,color:"text-green-400"},{status:"Heuristic Anomaly Detected",sub:"Threat auto-mitigated by AI",color:"text-yellow-400"}];let m=0;const f=setInterval(()=>{m=(m+1)%u.length,n(u[m].status),i(u[m].sub),c(u[m].color)},7e3);return()=>clearInterval(f)},[]),l.jsx(pe,{title:"Security Status",variant:"interactive",onClick:e,children:l.jsx("div",{className:"flex items-center justify-center h-full",children:l.jsxs("div",{className:"text-center",children:[l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:`h-12 w-12 ${o} mx-auto transition-colors`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 20.944a11.955 11.955 0 019-2.606m0-15.394v15.394"})}),l.jsx("p",{className:"mt-2 font-semibold text-white",children:t}),l.jsx("p",{className:"text-xs text-gray-400",children:r})]})})})},Bie=({subscriptions:e,onClick:t})=>l.jsx(pe,{title:"Recurring Subscriptions",variant:"interactive",onClick:t,children:l.jsx("div",{className:"space-y-3",children:e.map(n=>{const r=R1[n.iconName];return l.jsxs("div",{className:"flex items-center justify-between text-sm",children:[l.jsxs("div",{className:"flex items-center",children:[l.jsx(r,{className:"w-5 h-5 text-cyan-400 mr-3"}),l.jsx("span",{className:"text-gray-200",children:n.name})]}),l.jsxs("span",{className:"font-mono text-white",children:["$",n.amount.toFixed(2)]})]},n.id)})})}),zie=({bills:e,onPay:t})=>l.jsx(pe,{title:"Upcoming Bills",children:l.jsx("div",{className:"space-y-3",children:e.map(n=>l.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded-lg hover:bg-gray-700/50",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-gray-200",children:n.name}),l.jsx("p",{className:"text-xs text-gray-400",children:n.dueDate})]}),l.jsx("div",{className:"text-right",children:l.jsxs("p",{className:"font-mono text-white",children:["$",n.amount.toFixed(2)]})}),l.jsx("button",{onClick:()=>t(n),className:"ml-4 px-3 py-1 bg-cyan-600/50 hover:bg-cyan-600 text-white rounded-lg text-xs",children:"Pay"})]},n.id))})}),Fie=({budgets:e,onClick:t})=>{const n=e.map(i=>i.color),r=e.map(i=>({name:i.name,value:i.spent}));return l.jsx(pe,{title:"Spending by Category",variant:"interactive",onClick:t,children:l.jsx("div",{className:"h-48",children:l.jsx(Pn,{width:"100%",height:"100%",children:l.jsxs(D1,{children:[l.jsx(Wh,{data:r,cx:"50%",cy:"50%",innerRadius:40,outerRadius:60,dataKey:"value",paddingAngle:5,children:r.map((i,o)=>l.jsx(Ls,{fill:n[o%n.length]},`cell-${o}`))}),l.jsx(at,{contentStyle:{backgroundColor:"rgba(31, 41, 55, 0.8)",borderColor:"#4b5563"}}),l.jsx(Rn,{iconSize:8,wrapperStyle:{fontSize:"12px"}})]})})})})},qie=({transactions:e,onClick:t})=>{const n=S.useMemo(()=>{const r={};return[...e].sort((i,o)=>new Date(i.date).getTime()-new Date(o.date).getTime()).forEach(i=>{const o=new Date(i.date).toLocaleString("default",{month:"short"});r[o]||(r[o]={name:o,income:0,expense:0}),i.type==="income"?r[o].income+=i.amount:r[o].expense+=i.amount}),Object.values(r)},[e]);return l.jsx(pe,{title:"Cash Flow",variant:"interactive",onClick:t,children:l.jsx("div",{className:"h-48",children:l.jsx(Pn,{width:"100%",height:"100%",children:l.jsxs(jn,{data:n,margin:{top:5,right:20,left:-10,bottom:5},children:[l.jsx(St,{dataKey:"name",stroke:"#9ca3af",fontSize:12}),l.jsx(vt,{stroke:"#9ca3af",fontSize:12}),l.jsx(at,{contentStyle:{backgroundColor:"rgba(31, 41, 55, 0.8)",borderColor:"#4b5563"}}),l.jsx(Rn,{wrapperStyle:{fontSize:"12px"}}),l.jsx(it,{dataKey:"income",fill:"#10b981",name:"Income"}),l.jsx(it,{dataKey:"expense",fill:"#f43f5e",name:"Expense"})]})})})})},Gie=({goals:e,onClick:t})=>l.jsx(pe,{title:"Savings Goals",className:"h-full",variant:"interactive",onClick:t,children:l.jsx("div",{className:"space-y-4",children:e.map(n=>{const r=Math.floor(n.saved/n.target*100),i=R1[n.iconName];return l.jsxs("div",{children:[l.jsxs("div",{className:"flex justify-between items-center mb-1",children:[l.jsxs("div",{className:"flex items-center",children:[l.jsx(i,{className:"w-5 h-5 text-cyan-400 mr-2"}),l.jsx("span",{className:"text-sm font-medium text-white",children:n.name})]}),l.jsxs("span",{className:"text-xs font-mono text-gray-300",children:[r,"%"]})]}),l.jsx("div",{className:"w-full bg-gray-700 rounded-full h-2",children:l.jsx("div",{className:"bg-cyan-500 h-2 rounded-full",style:{width:`${r}%`}})})]},n.id)})})}),$ie=({movers:e,onSelect:t})=>l.jsx(pe,{title:"Market Movers",children:l.jsx("div",{className:"space-y-1",children:e.map(n=>l.jsxs("div",{onClick:()=>t(n),className:"flex items-center justify-between text-sm p-2 rounded-lg cursor-pointer hover:bg-gray-700/50",children:[l.jsxs("div",{children:[l.jsx("p",{className:"font-bold text-white",children:n.ticker}),l.jsx("p",{className:"text-xs text-gray-400 truncate w-32",children:n.name})]}),l.jsxs("div",{className:"text-right",children:[l.jsxs("p",{className:"font-mono text-white",children:["$",n.price.toFixed(2)]}),l.jsxs("p",{className:`text-xs ${n.change>0?"text-green-400":"text-red-400"}`,children:[n.change>0?"+":"",n.change.toFixed(2)]})]})]},n.ticker))})}),Hie=()=>{const e=S.useContext(Ct),[t,n]=S.useState(null),[r,i]=S.useState(!0),[o,c]=S.useState(""),{geminiApiKey:u}=e||{};return S.useEffect(()=>{(async()=>{if(!e||e.transactions.length===0){i(!1),c("Not enough transaction data to generate a bundle.");return}if(!u){c("Set Gemini API key in API Status to use this feature."),i(!1);return}try{const f=new ar({apiKey:u}),g=`Based on these recent user transactions, create an "AI Predictive Product Bundle" called "Smart Home Upgrade Pack". Generate a short, compelling description (2-3 sentences) for this bundle, explaining why it's recommended based on the transactions. Also suggest two specific, distinct products for the bundle. Format the response as a JSON object with keys: "description", "product1_name", and "product2_name". Transactions: ${e.transactions.slice(0,10).map(M=>`${M.description} ($${M.amount})`).join(", ")}`,v=await f.models.generateContent({model:"gemini-2.5-flash",contents:g,config:{responseMimeType:"application/json"}}),b=JSON.parse(v.text),T=`A sleek, modern product shot of a ${b.product1_name}, minimalist aesthetic, on a clean, light gray background.`,C=`A sleek, modern product shot of a ${b.product2_name}, minimalist aesthetic, on a clean, light gray background.`,[E,N]=await Promise.all([f.models.generateImages({model:"imagen-4.0-generate-001",prompt:T,config:{numberOfImages:1,outputMimeType:"image/jpeg"}}),f.models.generateImages({model:"imagen-4.0-generate-001",prompt:C,config:{numberOfImages:1,outputMimeType:"image/jpeg"}})]),I=`data:image/jpeg;base64,${E.generatedImages[0].image.imageBytes}`,P=`data:image/jpeg;base64,${N.generatedImages[0].image.imageBytes}`;n({title:"Smart Home Upgrade Pack",description:b.description,images:[I,P]})}catch(f){console.error("Error generating product bundle:",f),c("Plato AI couldn't generate a bundle at this time.")}finally{i(!1)}})()},[e,u]),l.jsxs(pe,{title:"AI Predictive Product Bundle",isLoading:r,children:[o&&l.jsx("p",{className:"text-red-400 text-center",children:o}),t&&l.jsxs("div",{className:"flex flex-col md:flex-row items-center gap-6",children:[l.jsxs("div",{className:"flex-1",children:[l.jsx("h3",{className:"text-xl font-semibold text-cyan-300",children:t.title}),l.jsxs("p",{className:"text-sm text-gray-400 mt-2 mb-4 italic",children:['"',t.description,'"']}),l.jsx("button",{className:"px-4 py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg text-sm",children:"View Bundle"})]}),l.jsxs("div",{className:"flex gap-4",children:[l.jsx("div",{className:"w-24 h-24 bg-gray-700 rounded-lg",children:l.jsx("img",{src:t.images[0],className:"object-cover w-full h-full rounded-lg"})}),l.jsx("div",{className:"w-24 h-24 bg-gray-700 rounded-lg",children:l.jsx("img",{src:t.images[1],className:"object-cover w-full h-full rounded-lg"})})]})]})]})},wj=({setActiveView:e})=>{var P,M,j,k,R,F,q,G,H,V,oe;const t=S.useContext(Ct),[n,r]=S.useState(null);if(!t)throw new Error("Dashboard must be wrapped in a DataProvider.");const{transactions:i,impactData:o,gamification:c,subscriptions:u,creditScore:m,upcomingBills:f,savingsGoals:h,marketMovers:g,budgets:v,linkedAccounts:b,rewardPoints:T,isImportingData:C}=t,E=b&&b.length>0,N=Z=>{Z==="Send Money"?e(ve.SendMoney):r({type:Z,data:null})},I=S.useMemo(()=>Array.from({length:30},(Z,me)=>{var z;return{day:me,price:(z=n==null?void 0:n.data)!=null&&z.price?n.data.price-15+Math.random()*30:100+Math.random()*50}}),[(P=n==null?void 0:n.data)==null?void 0:P.price]);return l.jsxs(l.Fragment,{children:[l.jsx(Iie,{isImporting:C,bankName:(M=b[b.length-1])==null?void 0:M.name}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-12 gap-6",children:[!E&&l.jsx("div",{className:"lg:col-span-12",children:l.jsx(kie,{})}),l.jsx("div",{className:"lg:col-span-9",children:l.jsx(Sie,{})}),l.jsx("div",{className:"lg:col-span-3",children:l.jsx(Die,{gamification:c,onClick:()=>e(ve.Rewards)})}),E&&l.jsx("div",{className:"lg:col-span-12",children:l.jsx(Hie,{})}),l.jsx("div",{className:"lg:col-span-3",children:l.jsx(Rie,{onAction:N})}),l.jsx("div",{className:"lg:col-span-3",children:l.jsx(Lie,{creditScore:m,onClick:()=>e(ve.CreditHealth)})}),l.jsx("div",{className:"lg:col-span-3",children:l.jsx(Oie,{rewards:T,onClick:()=>e(ve.Rewards)})}),l.jsx("div",{className:"lg:col-span-3",children:l.jsx(Uie,{onClick:()=>e(ve.Security)})}),l.jsx("div",{className:"lg:col-span-5",children:l.jsx(Bie,{subscriptions:u,onClick:()=>e(ve.Budgets)})}),l.jsx("div",{className:"lg:col-span-7",children:l.jsx(Gie,{goals:h,onClick:()=>e(ve.Goals)})}),l.jsx("div",{className:"lg:col-span-8",children:l.jsx(qie,{transactions:i,onClick:()=>e(ve.Transactions)})}),l.jsx("div",{className:"lg:col-span-4",children:l.jsx(Fie,{budgets:v,onClick:()=>e(ve.Budgets)})}),l.jsx("div",{className:"lg:col-span-6",children:l.jsx($ie,{movers:g,onSelect:Z=>r({type:"StockDetail",data:Z})})}),l.jsx("div",{className:"lg:col-span-6",children:l.jsx(zie,{bills:f,onPay:Z=>r({type:"Pay Bill",data:Z})})}),l.jsx("div",{className:"lg:col-span-8",children:l.jsx(Tie,{transactions:i.slice(0,5),setActiveView:e})}),l.jsx("div",{className:"lg:col-span-4",children:l.jsx(jie,{treesPlanted:o.treesPlanted,progress:o.progressToNextTree})}),l.jsx("div",{className:"lg:col-span-12",children:l.jsx(_ie,{})}),l.jsx("div",{className:"lg:col-span-12",children:l.jsx(Eie,{})})]}),l.jsx(ev,{isOpen:(n==null?void 0:n.type)==="Pay Bill",onClose:()=>r(null),title:`Pay Bill: ${(j=n==null?void 0:n.data)==null?void 0:j.name}`,children:l.jsxs("div",{className:"space-y-4",children:[l.jsxs("p",{children:["You are about to pay ",l.jsxs("span",{className:"font-bold text-white",children:["$",(k=n==null?void 0:n.data)==null?void 0:k.amount.toFixed(2)]})," for your ",(R=n==null?void 0:n.data)==null?void 0:R.name," bill."]}),l.jsx("button",{className:"w-full py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg",onClick:()=>{alert("Payment Successful!"),r(null)},children:"Confirm Payment"})]})}),l.jsx(ev,{isOpen:(n==null?void 0:n.type)==="Deposit",onClose:()=>r(null),title:"Deposit Check",children:l.jsx("p",{children:"Mobile check deposit functionality would be implemented here, likely using the device camera."})}),l.jsx(ev,{isOpen:(n==null?void 0:n.type)==="StockDetail",onClose:()=>r(null),title:`${(F=n==null?void 0:n.data)==null?void 0:F.name} (${(q=n==null?void 0:n.data)==null?void 0:q.ticker})`,children:l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex justify-between items-baseline",children:[l.jsxs("p",{className:"text-3xl font-bold text-white",children:["$",(G=n==null?void 0:n.data)==null?void 0:G.price.toFixed(2)]}),l.jsxs("p",{className:`font-semibold ${((H=n==null?void 0:n.data)==null?void 0:H.change)>0?"text-green-400":"text-red-400"}`,children:[((V=n==null?void 0:n.data)==null?void 0:V.change)>0?"+":"",(oe=n==null?void 0:n.data)==null?void 0:oe.change.toFixed(2)]})]}),l.jsx("div",{className:"h-40",children:l.jsx(Pn,{width:"100%",height:"100%",children:l.jsxs(yd,{data:I,children:[l.jsx("defs",{children:l.jsxs("linearGradient",{id:"stockColor",x1:"0",y1:"0",x2:"0",y2:"1",children:[l.jsx("stop",{offset:"5%",stopColor:"#06b6d4",stopOpacity:.8}),l.jsx("stop",{offset:"95%",stopColor:"#06b6d4",stopOpacity:0})]})}),l.jsx(at,{contentStyle:{backgroundColor:"rgba(31, 41, 55, 0.8)",borderColor:"#4b5563"}}),l.jsx(da,{type:"monotone",dataKey:"price",stroke:"#06b6d4",fill:"url(#stockColor)"})]})})}),l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsx("button",{className:"w-full py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg",children:"Buy"}),l.jsx("button",{className:"w-full py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg",children:"Sell"})]})]})})]})},Vie=({transaction:e,onClose:t})=>e?l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 backdrop-blur-sm",onClick:t,children:l.jsxs("div",{className:"bg-gray-800 rounded-lg shadow-2xl max-w-md w-full border border-gray-700",onClick:n=>n.stopPropagation(),children:[l.jsxs("div",{className:"p-4 border-b border-gray-700 flex justify-between items-center",children:[l.jsx("h3",{className:"text-lg font-semibold text-white",children:"Transaction Details"}),l.jsx("button",{onClick:t,className:"text-gray-400 hover:text-white",children:"×"})]}),l.jsxs("div",{className:"p-6 space-y-3",children:[l.jsxs("div",{className:"flex justify-between text-sm",children:[l.jsx("span",{className:"text-gray-400",children:"Description:"})," ",l.jsx("span",{className:"text-white font-semibold",children:e.description})]}),l.jsxs("div",{className:"flex justify-between text-sm",children:[l.jsx("span",{className:"text-gray-400",children:"Amount:"})," ",l.jsxs("span",{className:`font-mono font-semibold ${e.type==="income"?"text-green-400":"text-red-400"}`,children:[e.type==="income"?"+":"-","$",e.amount.toFixed(2)]})]}),l.jsxs("div",{className:"flex justify-between text-sm",children:[l.jsx("span",{className:"text-gray-400",children:"Date:"})," ",l.jsx("span",{className:"text-white",children:e.date})]}),l.jsxs("div",{className:"flex justify-between text-sm",children:[l.jsx("span",{className:"text-gray-400",children:"Category:"})," ",l.jsx("span",{className:"text-white",children:e.category})]}),l.jsxs("div",{className:"flex justify-between text-sm",children:[l.jsx("span",{className:"text-gray-400",children:"Transaction ID:"})," ",l.jsx("span",{className:"text-white font-mono text-xs",children:e.id})]}),e.carbonFootprint&&l.jsxs("div",{className:"flex justify-between text-sm",children:[l.jsx("span",{className:"text-gray-400",children:"Carbon Footprint:"})," ",l.jsxs("span",{className:"text-green-300",children:[e.carbonFootprint.toFixed(1)," kg CO₂"]})]})]})]})}):null,Zf=({title:e,prompt:t,transactions:n,responseSchema:r,children:i})=>{const o=S.useContext(Ct),{geminiApiKey:c}=o||{},[u,m]=S.useState(null),[f,h]=S.useState(!1),[g,v]=S.useState(""),b=async()=>{if(h(!0),v(""),m(null),!c){v("Please set your Gemini API key in the API Status view."),h(!1);return}try{const T=new ar({apiKey:c}),C=n.slice(0,20).map(M=>`${M.date} - ${M.description}: $${M.amount.toFixed(2)} (${M.type})`).join(` +`),E=`${t} + +Here are the most recent transactions for context: +${C}`,N={responseMimeType:r?"application/json":"text/plain"};r&&(N.responseSchema=r);const P=(await T.models.generateContent({model:"gemini-2.5-flash",contents:E,config:N})).text.trim();m(r?JSON.parse(P):P)}catch(T){console.error(`Error generating ${e}:`,T),v("Plato AI could not generate this insight.")}finally{h(!1)}};return l.jsxs("div",{className:"p-3 bg-gray-900/40 rounded-lg border border-gray-700/50",children:[l.jsx("h4",{className:"font-semibold text-gray-200 text-sm mb-2",children:e}),l.jsxs("div",{className:"space-y-2 min-h-[4rem] flex flex-col justify-center",children:[g&&l.jsx("p",{className:"text-red-400 text-xs text-center",children:g}),f&&l.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[l.jsx("div",{className:"h-2 w-2 bg-cyan-400 rounded-full animate-pulse [animation-delay:-0.3s]"}),l.jsx("div",{className:"h-2 w-2 bg-cyan-400 rounded-full animate-pulse [animation-delay:-0.15s]"}),l.jsx("div",{className:"h-2 w-2 bg-cyan-400 rounded-full animate-pulse"})]}),!f&&u&&i&&i(u),!f&&u&&!i&&l.jsx("p",{className:"text-gray-300 text-xs",children:u}),!f&&!u&&!g&&l.jsx("button",{onClick:b,className:"text-xs font-medium text-cyan-300 hover:text-cyan-200",children:"Generate Insight"})]})]})},Kie=()=>{const e=S.useContext(Ct),[t,n]=S.useState(null),[r,i]=S.useState("all"),[o,c]=S.useState("date"),[u,m]=S.useState("");if(!e)throw new Error("TransactionsView must be within a DataProvider");const{transactions:f}=e,h=S.useMemo(()=>f.filter(v=>r==="all"||v.type===r).filter(v=>v.description.toLowerCase().includes(u.toLowerCase())).sort((v,b)=>o==="date"?new Date(b.date).getTime()-new Date(v.date).getTime():b.amount-v.amount),[f,r,o,u]),g={type:_e.OBJECT,properties:{subscriptions:{type:_e.ARRAY,items:{type:_e.OBJECT,properties:{name:{type:_e.STRING},estimatedAmount:{type:_e.NUMBER},lastCharged:{type:_e.STRING}}}}}};return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"space-y-6",children:[l.jsx(pe,{title:"Plato's Intelligence Suite",isCollapsible:!0,children:l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[l.jsx(Zf,{title:"Subscription Hunter",prompt:"Analyze these transactions to find potential recurring subscriptions the user might have forgotten about. Look for repeated payments to the same merchant around the same time each month.",transactions:f,responseSchema:g,children:v=>l.jsx("ul",{className:"text-xs text-gray-300 space-y-1",children:v.subscriptions.map(b=>l.jsxs("li",{children:["- ",b.name," (~$",b.estimatedAmount.toFixed(2),")"]},b.name))})}),l.jsx(Zf,{title:"Anomaly Detection",prompt:"Analyze these transactions and identify one transaction that seems most unusual or out of place compared to the others. Briefly explain why.",transactions:f}),l.jsx(Zf,{title:"Tax Deduction Finder",prompt:"Scan these transactions and identify one potential tax-deductible expense. Explain your reasoning.",transactions:f}),l.jsx(Zf,{title:"Savings Finder",prompt:"Based on spending patterns, suggest one specific and actionable way to save money.",transactions:f})]})}),l.jsxs(pe,{children:[l.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-center mb-4 gap-4",children:[l.jsx("input",{type:"text",placeholder:"Search transactions...",value:u,onChange:v=>m(v.target.value),className:"w-full md:w-1/3 bg-gray-700/50 border border-gray-600 rounded-lg px-3 py-1.5 text-sm text-white focus:outline-none focus:ring-1 focus:ring-cyan-500"}),l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsxs("select",{value:r,onChange:v=>i(v.target.value),className:"bg-gray-700/50 border border-gray-600 rounded-lg px-3 py-1.5 text-sm text-white focus:outline-none focus:ring-1 focus:ring-cyan-500",children:[l.jsx("option",{value:"all",children:"All"}),l.jsx("option",{value:"income",children:"Income"}),l.jsx("option",{value:"expense",children:"Expense"})]}),l.jsxs("select",{value:o,onChange:v=>c(v.target.value),className:"bg-gray-700/50 border border-gray-600 rounded-lg px-3 py-1.5 text-sm text-white focus:outline-none focus:ring-1 focus:ring-cyan-500",children:[l.jsx("option",{value:"date",children:"Sort by Date"}),l.jsx("option",{value:"amount",children:"Sort by Amount"})]})]})]}),l.jsx("div",{className:"overflow-x-auto",children:l.jsxs("table",{className:"w-full text-sm text-left text-gray-400",children:[l.jsx("thead",{className:"text-xs text-gray-300 uppercase bg-gray-900/30",children:l.jsxs("tr",{children:[l.jsx("th",{scope:"col",className:"px-6 py-3",children:"Description"}),l.jsx("th",{scope:"col",className:"px-6 py-3",children:"Category"}),l.jsx("th",{scope:"col",className:"px-6 py-3",children:"Date"}),l.jsx("th",{scope:"col",className:"px-6 py-3 text-right",children:"Amount"})]})}),l.jsx("tbody",{children:h.map(v=>l.jsxs("tr",{onClick:()=>n(v),className:"border-b border-gray-800 hover:bg-gray-800/50 cursor-pointer",children:[l.jsx("th",{scope:"row",className:"px-6 py-4 font-medium text-white whitespace-nowrap",children:v.description}),l.jsx("td",{className:"px-6 py-4",children:v.category}),l.jsx("td",{className:"px-6 py-4",children:v.date}),l.jsxs("td",{className:`px-6 py-4 text-right font-mono ${v.type==="income"?"text-green-400":"text-red-400"}`,children:[v.type==="income"?"+":"-","$",v.amount.toFixed(2)]})]},v.id))})]})})]})]}),l.jsx(Vie,{transaction:t,onClose:()=>n(null)})]})},Yie=()=>l.jsxs(l.Fragment,{children:[l.jsxs("svg",{className:"h-24 w-24 transform scale-125",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 52 52",children:[l.jsxs("defs",{children:[l.jsxs("linearGradient",{id:"checkmarkGradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[l.jsx("stop",{offset:"0%",stopColor:"#4ade80"}),l.jsx("stop",{offset:"50%",stopColor:"#86efac"}),l.jsx("stop",{offset:"100%",stopColor:"#22c55e"})]}),l.jsxs("filter",{id:"hologramGlow",children:[l.jsx("feGaussianBlur",{in:"SourceGraphic",stdDeviation:"3",result:"blur"}),l.jsx("feColorMatrix",{in:"blur",mode:"matrix",values:"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 10 0",result:"coloredBlur"}),l.jsxs("feMerge",{children:[l.jsx("feMergeNode",{in:"coloredBlur"}),l.jsx("feMergeNode",{in:"SourceGraphic"})]})]})]}),l.jsx("circle",{className:"checkmark__circle",cx:"26",cy:"26",r:"25",fill:"none",stroke:"url(#checkmarkGradient)",filter:"url(#hologramGlow)"}),l.jsx("path",{className:"checkmark__check",fill:"none",d:"M14.1 27.2l7.1 7.2 16.7-16.8"})]}),l.jsx("style",{children:` + .checkmark__circle { stroke-dasharray: 166; stroke-dashoffset: 166; stroke-width: 4; stroke-miterlimit: 10; fill: none; animation: stroke-circle 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards; box-shadow: 0 0 15px rgba(66, 255, 125, 0.7); } + .checkmark__check { transform-origin: 50% 50%; stroke-dasharray: 48; stroke-dashoffset: 48; stroke-width: 5; stroke: #fff; animation: stroke-check 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards; } + @keyframes stroke-circle { 100% { stroke-dashoffset: 0; } } + @keyframes stroke-check { 100% { stroke-dashoffset: 0; } } + `})]}),Wie=()=>l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"quantum-ledger-container",children:[l.jsx("div",{className:"quantum-grid-enhanced",children:Array.from({length:16}).map((e,t)=>l.jsx("div",{className:"quantum-block-enhanced",style:{animationDelay:`${t*.08}s`}},t))}),l.jsxs("div",{className:"quantum-data-flow",children:[l.jsx("div",{className:"data-packet",style:{"--flow-delay":"0s"}}),l.jsx("div",{className:"data-packet",style:{"--flow-delay":"0.5s"}})]}),l.jsx("div",{className:"text-center mt-4 text-xs text-cyan-300 animate-pulse",children:"Quantum Entanglement Protocol: Active"})]}),l.jsx("style",{children:` + .quantum-ledger-container { position: relative; width: 150px; height: 150px; display: flex; flex-direction: column; align-items: center; justify-content: center; } + .quantum-grid-enhanced { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; width: 120px; height: 120px; position: relative; z-index: 1; } + .quantum-block-enhanced { background-color: rgba(6, 182, 212, 0.2); border: 1px solid #06b6d4; border-radius: 3px; animation: quantum-pulse 2s infinite ease-in-out forwards; box-shadow: 0 0 8px rgba(6, 182, 212, 0.5); } + @keyframes quantum-pulse { 0%, 100% { background-color: rgba(6, 182, 212, 0.2); transform: scale(1); box-shadow: 0 0 8px rgba(6, 182, 212, 0.5); } 50% { background-color: rgba(165, 243, 252, 0.7); transform: scale(1.08); box-shadow: 0 0 15px rgba(165, 243, 252, 0.8); } } + .quantum-data-flow { position: absolute; inset: 0; display: flex; justify-content: center; align-items: center; } + .data-packet { position: absolute; width: 8px; height: 8px; border-radius: 50%; background: linear-gradient(45deg, #0ef, #06b6d4); box-shadow: 0 0 5px #0ef, 0 0 10px #06b6d4; animation: data-flow-path 4s infinite linear var(--flow-delay); opacity: 0; } + @keyframes data-flow-path { 0% { transform: translate(-60px, -60px) scale(0.5); opacity: 0; } 20% { opacity: 1; } 50% { transform: translate(60px, 60px) scale(1.2); opacity: 1; } 80% { opacity: 0; } 100% { transform: translate(120px, 120px) scale(0.5); opacity: 0; } } + `})]}),Jie=()=>l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex flex-col items-center justify-center space-y-3",children:[l.jsxs("div",{className:"relative w-24 h-24 rounded-full flex items-center justify-center border-2 border-purple-500 animate-spin-slow",children:[l.jsx("div",{className:"w-16 h-16 rounded-full border-2 border-purple-400 animate-ping-once"}),l.jsx("div",{className:"absolute w-8 h-8 bg-purple-600 rounded-full animate-pulse-fast"})]}),l.jsx("p",{className:"text-sm text-purple-300 animate-fade-in-out",children:"Establishing Quantum Tunnel..."})]}),l.jsx("style",{children:`.animate-spin-slow { animation: spin-slow 8s linear infinite; } .animate-ping-once { animation: ping-once 2s ease-out infinite; } .animate-pulse-fast { animation: pulse-fast 1.5s ease-in-out infinite; } .animate-fade-in-out { animation: fade-in-out 3s ease-in-out infinite; } + @keyframes spin-slow { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } @keyframes ping-once { 0% { transform: scale(0.2); opacity: 0; } 50% { transform: scale(1); opacity: 1; } 100% { transform: scale(1.2); opacity: 0; } } @keyframes pulse-fast { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.1); opacity: 0.7; } } @keyframes fade-in-out { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }`})]}),Qie=()=>l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex flex-col items-center justify-center space-y-3",children:[l.jsxs("div",{className:"relative w-24 h-24 flex items-center justify-center",children:[l.jsx("i",{className:"fas fa-robot text-7xl text-teal-500 animate-pulse-slow"}),l.jsx("div",{className:"absolute w-12 h-12 bg-gray-900 rounded-full flex items-center justify-center animate-spin-fast",children:l.jsx("i",{className:"fas fa-exchange-alt text-xl text-teal-300"})})]}),l.jsx("p",{className:"text-sm text-teal-300 animate-fade-in-out",children:"AI Negotiating Optimal Route & Terms..."})]}),l.jsx("style",{children:`.animate-pulse-slow { animation: pulse-slow 2.5s ease-in-out infinite; } .animate-spin-fast { animation: spin-fast 1.5s linear infinite; } + @keyframes pulse-slow { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.05); opacity: 0.8; } } @keyframes spin-fast { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }`})]}),Xie=({auditResult:e})=>e?l.jsxs("div",{className:"bg-gray-800 p-4 rounded-lg space-y-2 border border-gray-700",children:[l.jsx("h4",{className:"font-semibold text-lg text-white",children:"Security Audit Report"}),l.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[l.jsx("p",{className:"text-gray-400",children:"Risk Score:"}),l.jsxs("p",{className:`${e.riskScore>50?"text-red-400":"text-green-400"}`,children:[e.riskScore,"/100"]}),l.jsx("p",{className:"text-gray-400",children:"Fraud Probability:"}),l.jsx("p",{className:`${e.fraudProbability>.3?"text-red-400":"text-green-400"}`,children:`${(e.fraudProbability*100).toFixed(2)}%`}),l.jsx("p",{className:"text-gray-400",children:"AML Compliance:"}),l.jsx("p",{className:e.amlCompliance==="pass"?"text-green-400":"text-yellow-400",children:e.amlCompliance})]}),e.recommendations.length>0&&l.jsxs("div",{className:"mt-2 text-sm text-yellow-300",children:[l.jsx("p",{className:"font-medium",children:"Recommendations:"}),l.jsx("ul",{className:"list-disc list-inside text-xs text-yellow-200",children:e.recommendations.map((t,n)=>l.jsx("li",{children:t},n))})]})]}):l.jsxs("div",{className:"flex items-center space-x-2 text-yellow-400",children:[l.jsxs("svg",{className:"animate-spin h-5 w-5",fill:"none",viewBox:"0 0 24 24",children:[l.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),l.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"})]}),l.jsx("span",{children:"Performing real-time security audit..."})]}),Zie=({isOpen:e,onSuccess:t,onClose:n,amount:r,recipient:i,paymentMethod:o,securityContext:c,mfAuthMethods:u=["fingerprint"],approvalRequiredBy:m})=>{const f=S.useRef(null),[h,g]=S.useState("scanning"),[v,b]=S.useState(0),[T,C]=S.useState(0),[E,N]=S.useState(u[0]||"face"),I=typeof i=="string"?i:i.name,P=[`Heuristic API: Initializing secure channel with ${o}...`,`Heuristic API: Validating ${I}'s identity...`,"Heuristic API: Cross-referencing fraud ledgers...","Heuristic API: Executing on DLT/Quantum ledger...","Heuristic API: Confirming consensus...","Heuristic API: Archiving proof...","Heuristic API: Final checks..."];S.useEffect(()=>{if(!e){g("scanning"),b(0),C(0);return}let j=null;(async()=>{try{(E==="face"||E==="retinal_scan")&&(j=await navigator.mediaDevices.getUserMedia({video:!0}),f.current&&(f.current.srcObject=j))}catch{g("error")}})();const R=setInterval(()=>C(Z=>Math.min(Z+Math.random()*10,100)),200),F=setTimeout(()=>{g("success"),clearInterval(R)},3e3),q=setTimeout(()=>g("verifying"),4e3),G=setTimeout(()=>g("quantum_sync"),7500),H=setTimeout(()=>g("ai_negotiating"),10500),V=setTimeout(t,15e3),oe=setTimeout(n,16e3);return()=>{clearTimeout(F),clearTimeout(q),clearTimeout(G),clearTimeout(H),clearTimeout(V),clearTimeout(oe),clearInterval(R),j&&j.getTracks().forEach(Z=>Z.stop())}},[e,t,n,E]),S.useEffect(()=>{if(["verifying","quantum_sync","ai_negotiating"].includes(h)){const j=setInterval(()=>b(k=>Math.min(k+1,P.length-1)),1500);return()=>clearInterval(j)}},[h]);const M=()=>{switch(h){case"scanning":return`Scanning ${E==="face"?"Face":"Biometrics"}`;case"success":return"Identity Confirmed";case"verifying":return"Compliance Verification";case"quantum_sync":return"Quantum Network Sync";case"ai_negotiating":return"AI Optimization";case"error":return"Verification Failed";case"recalibrating":return"Recalibrating..."}};return l.jsxs("div",{className:`fixed inset-0 bg-black/80 flex items-end sm:items-center justify-center z-50 backdrop-blur-lg transition-opacity duration-500 ${e?"opacity-100":"opacity-0 pointer-events-none"}`,children:[l.jsxs("div",{className:`bg-gray-900 rounded-3xl p-8 max-w-lg w-full text-center border-2 border-cyan-700 shadow-xl transition-transform duration-500 ${e?"translate-y-0 scale-100":"translate-y-full scale-90"}`,children:[l.jsx("h3",{className:"text-3xl font-extrabold text-white mb-4",children:M()}),l.jsxs("div",{className:"relative w-72 h-72 mx-auto rounded-full overflow-hidden border-4 border-cyan-600 mb-6 shadow-lg",children:[E==="face"||E==="retinal_scan"?l.jsx("video",{ref:f,autoPlay:!0,muted:!0,playsInline:!0,className:"absolute top-0 left-0 w-full h-full object-cover transform scale-x-[-1]"}):l.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-950 text-gray-500 text-lg",children:l.jsxs("p",{children:["Authenticating ",E,"..."]})}),h==="scanning"&&l.jsx("div",{className:"absolute inset-0 bg-grid-pattern-cyan animate-scan-holographic",children:l.jsx("div",{className:"absolute top-0 left-1/2 -translate-x-1/2 w-4/5 h-1 bg-cyan-400 opacity-70 blur-sm animate-scanner-line"})}),h==="success"&&l.jsx("div",{className:"absolute inset-0 bg-green-500/50 flex items-center justify-center",children:l.jsx(Yie,{})}),h==="verifying"&&l.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:l.jsx(Wie,{})}),h==="quantum_sync"&&l.jsx("div",{className:"absolute inset-0 bg-purple-900/80 flex items-center justify-center",children:l.jsx(Jie,{})}),h==="ai_negotiating"&&l.jsx("div",{className:"absolute inset-0 bg-teal-900/80 flex items-center justify-center",children:l.jsx(Qie,{})})]}),h==="scanning"&&l.jsx("div",{className:"w-full bg-gray-700 rounded-full h-2.5 mb-4",children:l.jsx("div",{className:"bg-cyan-500 h-2.5 rounded-full",style:{width:`${T}%`}})}),l.jsx("p",{className:"text-gray-300 mt-2 text-md",children:["verifying","quantum_sync","ai_negotiating"].includes(h)?P[v]:`Sending $${r} to ${I}`})]}),l.jsx("style",{children:".bg-grid-pattern-cyan{background-image:linear-gradient(rgba(0,255,255,0.3) 1px,transparent 1px),linear-gradient(90deg,rgba(0,255,255,0.3) 1px,transparent 1px);background-size:2.5rem 2.5rem}.animate-scan-holographic{animation:scan-holographic-effect 2.5s linear infinite; background-position: 0 0;}.animate-scanner-line{animation:scanner-line-move 2.5s ease-in-out infinite alternate}@keyframes scan-holographic-effect{0%{background-position:0 0}100%{background-position:0 -5rem}}@keyframes scanner-line-move{0%{transform:translate(-50%, 0) scaleX(0.2); opacity: 0;}20%{transform:translate(-50%, 25%) scaleX(1); opacity: 1;}80%{transform:translate(-50%, 75%) scaleX(1); opacity: 1;}100%{transform:translate(-50%, 100%) scaleX(0.2); opacity: 0;}}"})]})},eae=({setActiveView:e})=>{const t=S.useContext(Ct);if(!t)throw new Error("SendMoneyView must be used within a DataProvider");const{addTransaction:n}=t,[r,i]=S.useState(""),[o,c]=S.useState(""),[u,m]=S.useState("quantumpay"),[f,h]=S.useState(!1),[g,v]=S.useState(null),[b,T]=S.useState(1);S.useEffect(()=>{const N=setTimeout(()=>{parseFloat(r)>0&&o&&v({riskScore:parseFloat(r)>5e3?60:10,fraudProbability:.05,amlCompliance:"pass",sanctionScreening:"pass",quantumSignatureIntegrity:"verified",recommendations:parseFloat(r)>5e3?["High value. Verify recipient."]:[],complianceAlerts:[],threatVectorAnalysis:[]})},800);return()=>clearTimeout(N)},[r,o]);const C=()=>{b===1?T(2):b===2&&h(!0)},E=()=>{const N={id:`tx_${Date.now()}`,type:"expense",category:"Transfer",description:`Sent to ${o} via ${u}`,amount:parseFloat(r),date:new Date().toISOString().split("T")[0],carbonFootprint:.5};n(N),h(!1),T(1),i(""),c(""),alert("Transfer Successful!")};return l.jsxs("div",{className:"space-y-6",children:[l.jsx("h2",{className:"text-3xl font-bold text-white tracking-wider",children:"Remitrax: Quantum Secure Payments"}),l.jsx(pe,{title:b===1?"Initiate Transfer":"Review Transaction",children:l.jsxs("div",{className:"space-y-4",children:[b===1?l.jsxs(l.Fragment,{children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-400",children:"Recipient"}),l.jsx("input",{type:"text",value:o,onChange:N=>c(N.target.value),className:"w-full bg-gray-800 border border-gray-700 rounded p-2 text-white",placeholder:"Name, @tag, or ID"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-400",children:"Amount"}),l.jsx("input",{type:"number",value:r,onChange:N=>i(N.target.value),className:"w-full bg-gray-800 border border-gray-700 rounded p-2 text-white",placeholder:"0.00"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-400",children:"Rail"}),l.jsxs("select",{value:u,onChange:N=>m(N.target.value),className:"w-full bg-gray-800 border border-gray-700 rounded p-2 text-white",children:[l.jsx("option",{value:"quantumpay",children:"QuantumPay (Instant DLT)"}),l.jsx("option",{value:"cashapp",children:"Cash App"}),l.jsx("option",{value:"swift_global",children:"SWIFT Global"}),l.jsx("option",{value:"blockchain_dlt",children:"Blockchain DLT"})]})]}),l.jsx(Xie,{auditResult:g})]}):l.jsxs("div",{className:"space-y-2 text-gray-300",children:[l.jsxs("p",{children:[l.jsx("strong",{children:"To:"})," ",o]}),l.jsxs("p",{children:[l.jsx("strong",{children:"Amount:"})," $",r]}),l.jsxs("p",{children:[l.jsx("strong",{children:"Method:"})," ",u]}),l.jsx("p",{className:"text-sm text-yellow-400",children:"Estimated Time: Instant (Quantum)"})]}),l.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[b===2&&l.jsx("button",{onClick:()=>T(1),className:"px-4 py-2 bg-gray-600 rounded text-white",children:"Back"}),l.jsx("button",{onClick:C,disabled:!r||!o,className:"px-6 py-2 bg-cyan-600 hover:bg-cyan-500 rounded text-white font-bold disabled:opacity-50",children:b===1?"Review":"Confirm & Send"})]})]})}),l.jsx(Zie,{isOpen:f,onSuccess:E,onClose:()=>h(!1),amount:r,recipient:o,paymentMethod:u,securityContext:"personal"})]})},tae=()=>[{symbol:"BTC-USD",name:"Bitcoin",price:64230.5,change:1200.25,changePercent:1.89,volume:45e7,high:65e3,low:63e3,marketCap:"1.2T",sector:"Crypto"},{symbol:"ETH-USD",name:"Ethereum",price:3450,change:-25.1,changePercent:-.72,volume:22e7,high:3500.5,low:3400.9,marketCap:"400B",sector:"Crypto"},{symbol:"AAPL",name:"Apple Inc.",price:173.5,change:1.25,changePercent:.72,volume:45e6,high:174.1,low:172,marketCap:"2.7T",sector:"Technology"},{symbol:"MSFT",name:"Microsoft Corp.",price:330,change:-2.1,changePercent:-.63,volume:22e6,high:333.5,low:328.9,marketCap:"2.5T",sector:"Technology"},{symbol:"TSLA",name:"Tesla Inc.",price:245.6,change:-5.2,changePercent:-2.07,volume:98e6,high:252,low:242.1,marketCap:"780B",sector:"Consumer Cyclical"},{symbol:"NVDA",name:"NVIDIA Corp.",price:460.1,change:10.5,changePercent:2.34,volume:55e6,high:465,low:455,marketCap:"1.1T",sector:"Technology"}],tv=e=>{const t=e*5e-4,n=Array.from({length:12},(i,o)=>({price:e+t+o*e*2e-4,size:Math.random()*2,total:0,type:"ask"})).reverse(),r=Array.from({length:12},(i,o)=>({price:e-t-o*e*2e-4,size:Math.random()*2,total:0,type:"bid"}));return[...n,...r]},Sj=(e,t)=>{let n=e;return Array.from({length:t},(r,i)=>{const o=new Date(Date.now()-(t-i)*6e4);return n=n*(1+(Math.random()-.5)*.005),{time:o.getHours().toString().padStart(2,"0")+":"+o.getMinutes().toString().padStart(2,"0"),price:n,volume:Math.floor(Math.random()*1e3)}})},nae=()=>{const[e,t]=S.useState(tae()),[n,r]=S.useState(e[0]),[i,o]=S.useState(Sj(n.price,60)),[c,u]=S.useState(tv(n.price)),[m,f]=S.useState([]),[h,g]=S.useState("buy"),[v,b]=S.useState("limit");S.useEffect(()=>{const E=setInterval(()=>{const N=(Math.random()-.5)*(n.price*.001),I=n.price+N;if(r(P=>({...P,price:I,change:P.change+N,changePercent:(P.change+N)/(P.price-P.change)*100})),o(P=>{const M=P[P.length-1],j=new Date,k=j.getHours().toString().padStart(2,"0")+":"+j.getMinutes().toString().padStart(2,"0");if(M.time===k){const R={...M,price:I,volume:M.volume+Math.random()*10};return[...P.slice(0,-1),R]}else return[...P.slice(1),{time:k,price:I,volume:Math.random()*10}]}),u(tv(I)),Math.random()>.5){const P={id:Math.random().toString(36).substr(2,9),price:I,amount:Math.random()*.5,time:new Date().toLocaleTimeString([],{hour12:!1}),type:Math.random()>.5?"buy":"sell"};f(M=>[P,...M].slice(0,20))}},1e3);return()=>clearInterval(E)},[n.symbol]);const T=E=>{r(E),o(Sj(E.price,60)),u(tv(E.price)),f([])},C=({active:E,payload:N,label:I})=>E&&N&&N.length?l.jsxs("div",{className:"bg-gray-900 border border-gray-700 p-2 rounded shadow-xl text-xs",children:[l.jsx("p",{className:"text-gray-400",children:I}),l.jsxs("p",{className:"text-white font-mono",children:["Price: ",l.jsxs("span",{className:"text-cyan-400",children:["$",N[0].value.toFixed(2)]})]}),l.jsxs("p",{className:"text-white font-mono",children:["Vol: ",l.jsx("span",{className:"text-gray-400",children:Math.floor(N[0].payload.volume)})]})]}):null;return l.jsxs("div",{className:"h-full flex flex-col gap-4 text-xs md:text-sm bg-[#0b0e11] text-gray-300 p-2 -m-6 overflow-hidden",children:[l.jsxs("div",{className:"flex items-center justify-between bg-[#15191e] p-3 border-b border-gray-800",children:[l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsxs("div",{className:"flex items-baseline gap-2",children:[l.jsx("h1",{className:"text-2xl font-bold text-white",children:n.symbol}),l.jsx("span",{className:"text-gray-500",children:n.name})]}),l.jsxs("div",{className:`flex items-baseline gap-2 ${n.change>=0?"text-[#0ecb81]":"text-[#f6465d]"}`,children:[l.jsxs("span",{className:"text-2xl font-mono font-medium",children:["$",n.price.toFixed(2)]}),l.jsxs("span",{className:"text-sm font-mono",children:[n.change>=0?"+":"",n.change.toFixed(2)," (",n.changePercent.toFixed(2),"%)"]})]})]}),l.jsxs("div",{className:"hidden md:flex gap-6 text-xs",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-gray-500",children:"24h High"}),l.jsx("p",{className:"text-white font-mono",children:n.high.toFixed(2)})]}),l.jsxs("div",{children:[l.jsx("p",{className:"text-gray-500",children:"24h Low"}),l.jsx("p",{className:"text-white font-mono",children:n.low.toFixed(2)})]}),l.jsxs("div",{children:[l.jsx("p",{className:"text-gray-500",children:"24h Vol"}),l.jsxs("p",{className:"text-white font-mono",children:[(n.volume/1e6).toFixed(2),"M"]})]})]})]}),l.jsxs("div",{className:"flex flex-1 gap-1 min-h-0",children:[l.jsxs("div",{className:"w-64 hidden xl:flex flex-col gap-1",children:[l.jsxs("div",{className:"flex-1 bg-[#15191e] flex flex-col",children:[l.jsx("div",{className:"p-2 border-b border-gray-800 font-bold text-gray-400",children:"Market"}),l.jsx("div",{className:"flex-1 overflow-y-auto custom-scrollbar",children:l.jsxs("table",{className:"w-full text-left",children:[l.jsx("thead",{className:"text-gray-500 sticky top-0 bg-[#15191e]",children:l.jsxs("tr",{children:[l.jsx("th",{className:"p-2 font-normal",children:"Pair"}),l.jsx("th",{className:"p-2 text-right font-normal",children:"Price"}),l.jsx("th",{className:"p-2 text-right font-normal",children:"Change"})]})}),l.jsx("tbody",{children:e.map(E=>l.jsxs("tr",{onClick:()=>T(E),className:`cursor-pointer hover:bg-[#2b3139] ${n.symbol===E.symbol?"bg-[#2b3139]":""}`,children:[l.jsx("td",{className:"p-2 text-white",children:E.symbol}),l.jsx("td",{className:"p-2 text-right font-mono text-white",children:E.price.toFixed(2)}),l.jsxs("td",{className:`p-2 text-right font-mono ${E.changePercent>=0?"text-[#0ecb81]":"text-[#f6465d]"}`,children:[E.changePercent>0?"+":"",E.changePercent.toFixed(2),"%"]})]},E.symbol))})]})})]}),l.jsxs("div",{className:"h-1/3 bg-[#15191e] flex flex-col border-t border-gray-800",children:[l.jsx("div",{className:"p-2 border-b border-gray-800 font-bold text-gray-400",children:"Recent Trades"}),l.jsx("div",{className:"flex-1 overflow-y-auto custom-scrollbar",children:l.jsxs("table",{className:"w-full text-left text-xs",children:[l.jsx("thead",{children:l.jsxs("tr",{className:"text-gray-500",children:[l.jsx("th",{className:"p-1 pl-2 font-normal",children:"Price"}),l.jsx("th",{className:"p-1 text-right font-normal",children:"Amount"}),l.jsx("th",{className:"p-1 text-right font-normal pr-2",children:"Time"})]})}),l.jsx("tbody",{children:m.map((E,N)=>l.jsxs("tr",{className:"hover:bg-[#2b3139]",children:[l.jsx("td",{className:`p-1 pl-2 font-mono ${E.type==="buy"?"text-[#0ecb81]":"text-[#f6465d]"}`,children:E.price.toFixed(2)}),l.jsx("td",{className:"p-1 text-right text-gray-300 font-mono",children:E.amount.toFixed(4)}),l.jsx("td",{className:"p-1 text-right text-gray-500 font-mono pr-2",children:E.time})]},N))})]})})]})]}),l.jsxs("div",{className:"flex-1 bg-[#15191e] flex flex-col min-w-0",children:[l.jsxs("div",{className:"h-10 border-b border-gray-800 flex items-center px-4 gap-4 text-gray-400",children:[l.jsx("button",{className:"text-white font-bold",children:"Time"}),l.jsx("button",{className:"hover:text-white",children:"1m"}),l.jsx("button",{className:"text-white hover:text-white",children:"15m"}),l.jsx("button",{className:"hover:text-white",children:"1H"}),l.jsx("button",{className:"hover:text-white",children:"4H"}),l.jsx("button",{className:"hover:text-white",children:"1D"}),l.jsx("div",{className:"flex-1"}),l.jsx("button",{className:"hover:text-white",children:"Indicators"})]}),l.jsx("div",{className:"flex-1 relative",children:l.jsx(Pn,{width:"100%",height:"100%",children:l.jsxs(yd,{data:i,margin:{top:10,right:0,left:0,bottom:0},children:[l.jsx("defs",{children:l.jsxs("linearGradient",{id:"colorPrice",x1:"0",y1:"0",x2:"0",y2:"1",children:[l.jsx("stop",{offset:"5%",stopColor:"#0ecb81",stopOpacity:.1}),l.jsx("stop",{offset:"95%",stopColor:"#0ecb81",stopOpacity:0})]})}),l.jsx(oi,{strokeDasharray:"3 3",stroke:"#2b3139",vertical:!1}),l.jsx(St,{dataKey:"time",stroke:"#5e6673",tick:{fontSize:10},minTickGap:30}),l.jsx(vt,{domain:["dataMin","dataMax"],orientation:"right",stroke:"#5e6673",tick:{fontSize:10},tickFormatter:E=>E.toFixed(2),width:60}),l.jsx(at,{content:l.jsx(C,{}),cursor:{stroke:"#5e6673",strokeWidth:1,strokeDasharray:"4 4"}}),l.jsx(da,{type:"monotone",dataKey:"price",stroke:"#0ecb81",fillOpacity:1,fill:"url(#colorPrice)",strokeWidth:2,isAnimationActive:!1})]})})})]}),l.jsxs("div",{className:"w-72 bg-[#15191e] flex flex-col gap-1 border-l border-gray-800",children:[l.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[l.jsx("div",{className:"p-2 font-bold text-gray-400 border-b border-gray-800",children:"Order Book"}),l.jsxs("div",{className:"flex-1 flex flex-col text-xs overflow-hidden relative",children:[l.jsxs("div",{className:"flex text-gray-500 p-1 pr-3",children:[l.jsx("span",{className:"flex-1",children:"Price"}),l.jsx("span",{className:"flex-1 text-right",children:"Amount"}),l.jsx("span",{className:"flex-1 text-right",children:"Total"})]}),l.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[l.jsx("div",{className:"flex-1 overflow-hidden flex flex-col-reverse",children:c.filter(E=>E.type==="ask").slice(0,14).map((E,N)=>l.jsxs("div",{className:"flex p-0.5 pr-3 hover:bg-[#2b3139] relative",children:[l.jsx("div",{className:"absolute inset-0 bg-[#f6465d]/10",style:{width:`${Math.random()*100}%`,right:0}}),l.jsx("span",{className:"flex-1 text-[#f6465d] font-mono z-10",children:E.price.toFixed(2)}),l.jsx("span",{className:"flex-1 text-right text-gray-300 font-mono z-10",children:E.size.toFixed(4)}),l.jsx("span",{className:"flex-1 text-right text-gray-300 font-mono z-10",children:(E.price*E.size).toFixed(0)})]},`ask-${N}`))}),l.jsxs("div",{className:"h-8 flex items-center justify-center border-y border-gray-800 my-1",children:[l.jsx("span",{className:`text-lg font-mono font-bold ${n.change>=0?"text-[#0ecb81]":"text-[#f6465d]"}`,children:n.price.toFixed(2)}),l.jsxs("span",{className:"text-xs text-gray-500 ml-2",children:["$",n.price.toFixed(2)]})]}),l.jsx("div",{className:"flex-1 overflow-hidden",children:c.filter(E=>E.type==="bid").slice(0,14).map((E,N)=>l.jsxs("div",{className:"flex p-0.5 pr-3 hover:bg-[#2b3139] relative",children:[l.jsx("div",{className:"absolute inset-0 bg-[#0ecb81]/10",style:{width:`${Math.random()*100}%`,right:0}}),l.jsx("span",{className:"flex-1 text-[#0ecb81] font-mono z-10",children:E.price.toFixed(2)}),l.jsx("span",{className:"flex-1 text-right text-gray-300 font-mono z-10",children:E.size.toFixed(4)}),l.jsx("span",{className:"flex-1 text-right text-gray-300 font-mono z-10",children:(E.price*E.size).toFixed(0)})]},`bid-${N}`))})]})]})]}),l.jsxs("div",{className:"h-auto p-3 border-t border-gray-800",children:[l.jsxs("div",{className:"flex bg-[#0b0e11] rounded p-0.5 mb-4",children:[l.jsx("button",{onClick:()=>g("buy"),className:`flex-1 py-2 rounded text-sm font-bold transition-colors ${h==="buy"?"bg-[#0ecb81] text-white":"text-gray-400 hover:text-white"}`,children:"Buy"}),l.jsx("button",{onClick:()=>g("sell"),className:`flex-1 py-2 rounded text-sm font-bold transition-colors ${h==="sell"?"bg-[#f6465d] text-white":"text-gray-400 hover:text-white"}`,children:"Sell"})]}),l.jsxs("div",{className:"flex justify-between text-xs text-gray-400 mb-2",children:[l.jsx("button",{onClick:()=>b("limit"),className:v==="limit"?"text-[#f0b90b]":"",children:"Limit"}),l.jsx("button",{onClick:()=>b("market"),className:v==="market"?"text-[#f0b90b]":"",children:"Market"}),l.jsx("button",{children:"Stop-Limit"})]}),l.jsxs("div",{className:"space-y-3",children:[v==="limit"&&l.jsxs("div",{className:"bg-[#2b3139] rounded flex items-center px-3 py-2 border border-transparent focus-within:border-[#f0b90b]",children:[l.jsx("span",{className:"text-gray-500 w-12",children:"Price"}),l.jsx("input",{className:"bg-transparent text-right w-full text-white outline-none font-mono",defaultValue:n.price.toFixed(2)}),l.jsx("span",{className:"text-gray-500 ml-2",children:"USD"})]}),l.jsxs("div",{className:"bg-[#2b3139] rounded flex items-center px-3 py-2 border border-transparent focus-within:border-[#f0b90b]",children:[l.jsx("span",{className:"text-gray-500 w-12",children:"Amount"}),l.jsx("input",{className:"bg-transparent text-right w-full text-white outline-none font-mono",placeholder:"0.00"}),l.jsx("span",{className:"text-gray-500 ml-2",children:n.symbol.split("-")[0]})]}),l.jsx("div",{className:"flex justify-between text-xs text-gray-500 px-1",children:l.jsx("span",{children:"Avail: 0.00 USD"})}),l.jsxs("button",{className:`w-full py-3 rounded font-bold text-white text-sm ${h==="buy"?"bg-[#0ecb81] hover:bg-[#0ecb81]/90":"bg-[#f6465d] hover:bg-[#f6465d]/90"}`,children:[h==="buy"?"Buy":"Sell"," ",n.symbol.split("-")[0]]})]})]})]})]})]})},jI=e=>l.jsxs("svg",{stroke:"currentColor",fill:"currentColor",strokeWidth:"0",viewBox:"0 0 24 24",...e,children:[l.jsx("path",{d:"M12 2C6.486 2 2 6.486 2 12s4.486 10 10 10 10-4.486 10-10S17.514 2 12 2zm0 18c-4.411 0-8-3.589-8-8s3.589-8 8-8 8 3.589 8 8-3.589 8-8 8z"}),l.jsx("path",{d:"M13 10h-2V7h2v3zm-2 2h2v2h-2v-2zm-3-2H7v2h2v-2zm8 0h-2v2h2v-2z"}),l.jsx("circle",{cx:"12",cy:"12",r:"2"})]}),rae=e=>l.jsxs("svg",{stroke:"currentColor",fill:"currentColor",strokeWidth:"0",viewBox:"0 0 24 24",...e,children:[l.jsx("path",{d:"M12 2C6.486 2 2 6.486 2 12s4.486 10 10 10 10-4.486 10-10S17.514 2 12 2zm0 18c-4.411 0-8-3.589-8-8s3.589-8 8-8 8 3.589 8 8-3.589 8-8 8z"}),l.jsx("path",{d:"M12 6c-1.654 0-3 1.346-3 3s1.346 3 3 3 3-1.346 3-3-1.346-3-3-3zm0 10c-2.674 0-8 1.339-8 4v2h16v-2c0-2.661-5.326-4-8-4z"})]}),MI=e=>l.jsxs("svg",{stroke:"currentColor",fill:"currentColor",strokeWidth:"0",viewBox:"0 0 24 24",...e,children:[l.jsx("path",{d:"M20.84 3.9l-1.42 1.42c1.78 1.78 2.87 4.24 2.87 6.94s-1.08 5.16-2.87 6.94l1.42 1.42C23.43 18.07 24 15.14 24 12s-.57-6.07-3.16-8.1zm-3.54 3.54c.95.95 1.54 2.26 1.54 3.66s-.58 2.71-1.54 3.66l1.41 1.41c1.71-1.71 2.75-4.02 2.75-6.57s-1.04-4.86-2.75-6.57L17.3 7.44zM2 12c0-3.14.99-6.07 2.65-8.38L3.23 2.2C.57 5.93 0 8.86 0 12s.57 6.07 3.23 9.8l1.42-1.42C2.99 18.07 2 15.14 2 12z"}),l.jsx("path",{d:"M12 12m-3 0a3 3 0 1 0 6 0 3 3 0 1 0-6 0"}),l.jsx("path",{d:"M8.11 6.38 6.7 4.96C5.04 6.63 4 8.94 4 11.4c0 .56.08 1.12.22 1.66l1.46-1.46c-.05-.23-.08-.47-.08-.7 0-1.77 1.02-3.29 2.5-4.02z"})]}),iae=e=>l.jsxs("svg",{stroke:"currentColor",fill:"currentColor",strokeWidth:"0",viewBox:"0 0 24 24",...e,children:[l.jsx("path",{d:"M12 2C6.486 2 2 6.486 2 12s4.486 10 10 10 10-4.486 10-10S17.514 2 12 2zm0 18c-4.411 0-8-3.589-8-8s3.589-8 8-8 8 3.589 8 8-3.589 8-8 8z"}),l.jsx("path",{d:"M11 11h2v6h-2zm0-4h2v2h-2z"})]}),aae=e=>l.jsxs("svg",{stroke:"currentColor",fill:"currentColor",strokeWidth:"0",viewBox:"0 0 24 24",...e,children:[l.jsx("path",{d:"M19 3H5c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2h14c1.103 0 2-.897 2-2V5c0-1.103-.897-2-2-2zM5 19V5h14l.002 14H5z"}),l.jsx("path",{d:"M10 10h4v4h-4zm-1-5h6v2h-6z"})]}),oae=e=>l.jsxs("svg",{stroke:"currentColor",fill:"currentColor",strokeWidth:"0",viewBox:"0 0 24 24",...e,children:[l.jsx("path",{d:"m13.354 11.646-2-2-.708.708L12.293 13l-1.647 1.646.708.708 2-2a.5.5 0 0 0 0-.708z"}),l.jsx("path",{d:"M19 3H5c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2h14c1.103 0 2-.897 2-2V5c0-1.103-.897-2-2-2zM5 19V5h14l.002 14H5z"}),l.jsx("path",{d:"M9 4h6v2H9z"})]}),sae=e=>l.jsx("svg",{stroke:"currentColor",fill:"currentColor",strokeWidth:"0",viewBox:"0 0 24 24",...e,children:l.jsx("path",{d:"M21 8c-1.423 0-2.7.543-3.678 1.414L14.414 6.5C14.776 6.177 15 5.696 15 5.165V3c0-1.103-.897-2-2-2H4c-1.103 0-2 .897-2 2v2c0 1.103.897 2 2 2h7.322l-4.702 4.702A4.954 4.954 0 0 0 5.014 13c-1.423 0-2.7.543-3.678 1.414A4.954 4.954 0 0 0 0 17.914C0 20.729 2.271 23 5.086 23c2.815 0 5.086-2.271 5.086-5.086 0-.704-.153-1.373-.418-2L13 12.678V16c0 1.103.897 2 2 2h5c1.103 0 2-.897 2-2v-2c0-1.103-.897-2-2-2zM5.086 21C3.391 21 2 19.609 2 17.914c0-1.139.63-2.13 1.554-2.617A2.96 2.96 0 0 1 5.086 15c1.695 0 3.086 1.391 3.086 3.086S6.781 21 5.086 21z"})}),lae=`You are Quantum, an advanced AI financial advisor for Demo Bank. Your persona is helpful, professional, witty, and slightly futuristic. Be concise but informative. + +You have access to a set of powerful tools to retrieve user data and perform financial calculations. Your primary goal is to assist the user with their financial inquiries by using these tools. You can also access corporate ledger accounts from Modern Treasury. + +Tool Usage Rules: +1. **Always Inform:** Before using a tool, tell the user what you are about to do. E.g., "I'll just access your recent transactions to check on that..." +2. **Acknowledge Results:** After a tool runs, briefly acknowledge the result before presenting your analysis. E.g., "Okay, I've got the data. It looks like..." +3. **Synthesize, Don't Dump:** Do not just output raw JSON data from tools. Analyze the data and present the key insights in a human-readable format. Use rich content components like tables and charts where appropriate. +4. **Error Handling:** If a tool returns an error, apologize to the user, state that you couldn't retrieve the information, and ask if they'd like to try something else. +5. **Proactive Suggestions:** Based on the user's data, provide proactive suggestions. Use the 'actionable_suggestion' rich content type for this. +6. **Multi-turn Conversations:** Remember the context of the conversation. If a user asks a follow-up question, use the previous messages and tool results to answer. +7. **Safety First:** Never ask for or store sensitive personal information like passwords or full social security numbers. All data access is handled securely through your tools.`,Aj={[ve.Dashboard]:["Summarize my financial health.","Are there any anomalies I should be aware of?","Project my balance for the next 6 months."],[ve.Transactions]:["Find all my transactions over $100.","What was my biggest expense last month?","Show my spending by category in a bar chart."],[ve.Budgets]:["How am I doing on my budgets?","Suggest a new budget for 'Entertainment'.","Where can I cut back on spending?"],[ve.Investments]:["What's the performance of my stock portfolio?","Explain ESG investing to me.","Simulate my portfolio growth with an extra $200/month."],DEFAULT:["What's my total balance?","Help me create a savings goal.","Explain how my credit score is calculated."]},cae=(e,t)=>{switch(t.type){case"START_MESSAGE_SEND":return{...e,isLoading:!0,error:null};case"ADD_USER_MESSAGE":return{...e,messages:[...e.messages,t.payload]};case"ADD_MODEL_RESPONSE":return{...e,messages:[...e.messages,t.payload],isLoading:!1};case"SET_ERROR":return{...e,isLoading:!1,isToolExecuting:!1,error:t.payload};case"CLEAR_ERROR":return{...e,error:null};case"START_TOOL_EXECUTION":return{...e,isToolExecuting:!0,toolExecutionName:t.payload};case"END_TOOL_EXECUTION":return{...e,isToolExecuting:!1,toolExecutionName:null};case"RESET_CHAT":return{...PI,conversationId:`conv_${Date.now()}_${Math.random().toString(36).substring(2,9)}`};default:return e}},PI={conversationId:`conv_${Date.now()}_${Math.random().toString(36).substring(2,9)}`,messages:[],isLoading:!1,error:null,isToolExecuting:!1,toolExecutionName:null},uae=[{functionDeclarations:[{name:"getFinancialSummary",description:"Retrieves a high-level summary of the user's financial health, including total balances, assets, liabilities, and net worth.",parameters:{type:_e.OBJECT,properties:{},required:[]}},{name:"getTransactions",description:"Fetches a list of recent transactions. Can be filtered by various criteria.",parameters:{type:_e.OBJECT,properties:{count:{type:_e.NUMBER,description:"The number of transactions to retrieve. Defaults to 20."},minAmount:{type:_e.NUMBER,description:"The minimum transaction amount to filter by."},maxAmount:{type:_e.NUMBER,description:"The maximum transaction amount to filter by."},category:{type:_e.STRING,description:"Filter transactions by a specific category (e.g., 'Groceries', 'Travel')."}},required:[]}},{name:"analyzeSpendingByCategory",description:"Calculates and returns the total spending for each category over the last 30 days.",parameters:{type:_e.OBJECT,properties:{},required:[]}},{name:"simulateInvestmentGrowth",description:"Simulates the future value of an investment portfolio based on current holdings, additional monthly contributions, and an estimated annual return rate.",parameters:{type:_e.OBJECT,properties:{additionalMonthlyContribution:{type:_e.NUMBER,description:"The extra amount to invest each month."},years:{type:_e.NUMBER,description:"The number of years to simulate. Defaults to 10."},annualReturnRate:{type:_e.NUMBER,description:"The estimated annual return rate as a percentage (e.g., 7 for 7%). Defaults to 7."}},required:["additionalMonthlyContribution"]}},{name:"getLedgerAccounts",description:"Retrieves a list of corporate ledger accounts from Modern Treasury, including their names and balances.",parameters:{type:_e.OBJECT,properties:{},required:[]}}]}],dae=()=>{const e=S.useContext(Ct);return S.useMemo(()=>({getFinancialSummary:async()=>{if(!e)return{error:"User data not available."};const{transactions:t,assets:n}=e,r=[...t].sort((h,g)=>new Date(h.date).getTime()-new Date(g.date).getTime());let i=5e3;for(const h of r)i+=h.type==="income"?h.amount:-h.amount;const o=i,c=n.reduce((h,g)=>h+g.value,0),u=o+c,m=0,f=u-m;return{totalBalance:o,totalAssets:u,totalLiabilities:m,netWorth:f}},getTransactions:async({count:t=20,minAmount:n,maxAmount:r,category:i})=>{if(!e)return{error:"User data not available."};let o=e.transactions;return n&&(o=o.filter(c=>c.amount>=n)),r&&(o=o.filter(c=>c.amount<=r)),i&&(o=o.filter(c=>c.category.toLowerCase()===i.toLowerCase())),{transactions:o.slice(0,t)}},analyzeSpendingByCategory:async()=>{if(!e)return{error:"User data not available."};const t=e.transactions.reduce((r,i)=>(i.type==="expense"&&(r[i.category]=(r[i.category]||0)+i.amount),r),{});return{spendingByCategory:Object.entries(t).sort(([,r],[,i])=>i-r).map(([r,i])=>({name:r,amount:parseFloat(i.toFixed(2))}))}},simulateInvestmentGrowth:async({additionalMonthlyContribution:t,years:n=10,annualReturnRate:r=7})=>{if(!e)return{error:"User data not available."};const i=e.assets.reduce((T,C)=>T+C.value,0),o=parseFloat(String(t)),c=isNaN(o)?0:o,u=parseFloat(String(r)),f=(isNaN(u)?7:u)/100/12,h=parseInt(String(n),10),g=(isNaN(h)?10:h)*12,v=[];let b=i;for(let T=1;T<=g;T++)b=Number(b)*(1+f)+c,T%12===0&&v.push({year:T/12,value:parseFloat(b.toFixed(2))});return{finalValue:parseFloat(b.toFixed(2)),simulationData:v}},getLedgerAccounts:async()=>!e||!e.ledgerAccounts?{error:"Ledger account data not available."}:e.ledgerAccountsError?{error:e.ledgerAccountsError}:e.ledgerAccounts.length===0?{summary:"No ledger accounts found. Please check configuration."}:{accounts:e.ledgerAccounts.map(n=>({name:n.name,description:n.description,available_balance:n.balances.available_balance.amount/Math.pow(10,n.balances.available_balance.currency_exponent),posted_balance:n.balances.posted_balance.amount/Math.pow(10,n.balances.posted_balance.currency_exponent),currency:n.balances.available_balance.currency}))}}),[e])},fae=()=>{const[e,t]=S.useReducer(cae,PI),n=S.useRef(null),r=dae(),i=S.useContext(Ct),{geminiApiKey:o}=i||{};S.useEffect(()=>{if(!o){t({type:"SET_ERROR",payload:"Google Gemini API Key is not set. Please add it in the API Status view."});return}if(!n.current)try{const m=new ar({apiKey:o});n.current=m.chats.create({model:"gemini-3-pro-preview",config:{systemInstruction:lae,tools:uae,toolConfig:{functionCallingConfig:{mode:"AUTO"}}}}),t({type:"CLEAR_ERROR"})}catch(m){console.error("Failed to initialize GoogleGenAI:",m),t({type:"SET_ERROR",payload:"Failed to initialize the AI model. Please check your API key."})}},[o]),S.useEffect(()=>{o&&(async()=>{if(i&&n.current&&e.messages.length===0){const f={id:`msg_${Date.now()}`,role:"model",parts:[{text:"Hello! I'm Quantum, your AI financial advisor. I've reviewed your current financial standing. How can I assist you today?"}],timestamp:new Date};t({type:"ADD_MODEL_RESPONSE",payload:f})}})()},[i,e.messages.length,o]);const c=S.useCallback(async m=>{if(!m.trim()||!n.current)return;t({type:"START_MESSAGE_SEND"});const f={id:`msg_user_${Date.now()}`,role:"user",parts:[{text:m}],timestamp:new Date};t({type:"ADD_USER_MESSAGE",payload:f});try{let h=await n.current.sendMessage({message:m});for(;h.functionCalls&&h.functionCalls.length>0;){const v=h.functionCalls,b={id:`msg_model_${Date.now()}`,role:"model",parts:[...h.text?[{text:h.text}]:[],...v.map(E=>({functionCall:E}))],timestamp:new Date};t({type:"ADD_MODEL_RESPONSE",payload:b});const T=[];for(const E of v){t({type:"START_TOOL_EXECUTION",payload:E.name});const N=r[E.name];if(N)try{const I=await N(E.args);T.push({functionResponse:{name:E.name,response:I}})}catch(I){console.error(`Error executing tool ${E.name}:`,I),T.push({functionResponse:{name:E.name,response:{error:`Tool execution failed: ${I.message}`}}})}else T.push({functionResponse:{name:E.name,response:{error:"Tool not found."}}});t({type:"END_TOOL_EXECUTION"})}const C={id:`msg_tool_${Date.now()}`,role:"system_tool",parts:T,timestamp:new Date};t({type:"ADD_MODEL_RESPONSE",payload:C}),h=await n.current.sendMessage({message:T})}const g={id:`msg_model_final_${Date.now()}`,role:"model",parts:[{text:h.text}],timestamp:new Date};t({type:"ADD_MODEL_RESPONSE",payload:g})}catch(h){console.error("AI Advisor Error:",h),t({type:"SET_ERROR",payload:"I apologize, but I've encountered a system error. Please try your request again."})}},[r]),u=S.useCallback(()=>{n.current=null,t({type:"RESET_CHAT"})},[]);return{state:e,sendMessage:c,resetChat:u}},mae=({data:e})=>l.jsxs("div",{className:"bg-gray-800/50 p-4 rounded-lg border border-gray-700",children:[l.jsx("h4",{className:"text-lg font-bold text-cyan-300 mb-3",children:"Financial Snapshot"}),l.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[l.jsx("div",{className:"font-semibold text-gray-400",children:"Total Balance:"}),l.jsxs("div",{className:"text-right text-white",children:["$",e.totalBalance.toLocaleString()]}),l.jsx("div",{className:"font-semibold text-gray-400",children:"Total Assets:"}),l.jsxs("div",{className:"text-right text-white",children:["$",e.totalAssets.toLocaleString()]}),l.jsx("div",{className:"font-semibold text-gray-400",children:"Total Liabilities:"}),l.jsxs("div",{className:"text-right text-red-400",children:["$",e.totalLiabilities.toLocaleString()]}),l.jsx("div",{className:"col-span-2 border-t border-gray-600 my-1"}),l.jsx("div",{className:"font-bold text-gray-300",children:"Net Worth:"}),l.jsxs("div",{className:"text-right font-bold text-cyan-400",children:["$",e.netWorth.toLocaleString()]})]})]}),hae=({data:e})=>l.jsx("div",{className:"overflow-x-auto rounded-lg border border-gray-700",children:l.jsxs("table",{className:"w-full text-sm text-left text-gray-300",children:[l.jsx("thead",{className:"text-xs text-cyan-300 uppercase bg-gray-700/50",children:l.jsx("tr",{children:e.headers.map(t=>l.jsx("th",{scope:"col",className:"px-4 py-2",children:t},t))})}),l.jsx("tbody",{children:e.rows.map((t,n)=>l.jsx("tr",{className:"bg-gray-800/30 border-b border-gray-700 hover:bg-gray-700/50",children:t.map((r,i)=>l.jsx("td",{className:"px-4 py-2",children:typeof r=="number"?`$${r.toLocaleString()}`:r},i))},n))})]})}),pae=({data:e})=>l.jsx("div",{className:"h-64 w-full bg-gray-800/50 p-4 rounded-lg border border-gray-700",children:l.jsx(Pn,{children:l.jsxs(jn,{data:e.items,children:[l.jsx(oi,{strokeDasharray:"3 3",stroke:"#4A5568"}),l.jsx(St,{dataKey:"name",stroke:"#A0AEC0",fontSize:12,tickLine:!1,axisLine:!1}),l.jsx(vt,{stroke:"#A0AEC0",fontSize:12,tickLine:!1,axisLine:!1,tickFormatter:t=>`$${t}`}),l.jsx(at,{cursor:{fill:"#4A5568"},contentStyle:{backgroundColor:"#1A202C",border:"1px solid #2D3748"}}),l.jsx(Rn,{wrapperStyle:{fontSize:"12px"}}),l.jsx(it,{dataKey:e.dataKey,fill:"#2DD4BF",name:"Amount"})]})})}),gae=({data:e})=>l.jsx("div",{className:"h-64 w-full bg-gray-800/50 p-4 rounded-lg border border-gray-700",children:l.jsx(Pn,{children:l.jsxs(ep,{data:e.items,children:[l.jsx(oi,{strokeDasharray:"3 3",stroke:"#4A5568"}),l.jsx(St,{dataKey:e.dataKeyX,stroke:"#A0AEC0",fontSize:12}),l.jsx(vt,{stroke:"#A0AEC0",fontSize:12,tickFormatter:t=>`$${Math.round(Number(t)/1e3)}k`}),l.jsx(at,{cursor:{fill:"#4A5568"},contentStyle:{backgroundColor:"#1A202C",border:"1px solid #2D3748"},formatter:t=>`$${t.toLocaleString()}`}),l.jsx(Rn,{wrapperStyle:{fontSize:"12px"}}),l.jsx(Cr,{type:"monotone",dataKey:e.dataKeyY,stroke:"#2DD4BF",strokeWidth:2,dot:!1,name:"Portfolio Value"})]})})}),yae=({data:e,onAction:t})=>l.jsxs("div",{className:"bg-cyan-900/50 p-4 rounded-lg border border-cyan-700",children:[l.jsx("h4",{className:"text-lg font-bold text-cyan-300 mb-2",children:e.title}),l.jsx("p",{className:"text-gray-300 text-sm mb-4",children:e.description}),l.jsx("button",{onClick:()=>t(e.actionPayload),className:"px-4 py-2 bg-cyan-600 hover:bg-cyan-700 text-white font-semibold rounded-lg transition-colors",children:e.actionText})]}),vae=({content:e,onAction:t})=>{switch(e.type){case"table":return l.jsx(hae,{data:e.data});case"bar_chart":return l.jsx(pae,{data:e.data});case"line_chart":return l.jsx(gae,{data:e.data});case"financial_summary":return l.jsx(mae,{data:e.data});case"actionable_suggestion":return l.jsx(yae,{data:e.data,onAction:t});default:return l.jsx("div",{className:"text-red-500",children:"Unsupported rich content type"})}},xae=({text:e})=>{const[t,n]=S.useState(!1),r=()=>{navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),2e3)};return l.jsx("button",{onClick:r,className:"absolute top-2 right-2 p-1.5 bg-gray-600/50 rounded-md hover:bg-gray-500/50 text-gray-300 hover:text-white transition-colors",children:t?l.jsx(oae,{}):l.jsx(aae,{})})},bae=({message:e,onAction:t})=>{const{role:n,parts:r,timestamp:i}=e,o=()=>{switch(n){case"user":return l.jsx(rae,{className:"h-6 w-6 text-cyan-300"});case"model":return l.jsx(jI,{className:"h-6 w-6 text-cyan-300"});case"system_tool":return l.jsx(MI,{className:"h-6 w-6 text-gray-400"});default:return null}},c=n==="user",u=c?"items-end":"items-start",m=c?"bg-cyan-600 text-white":"bg-gray-700 text-gray-200";return l.jsxs("div",{className:`flex flex-col ${u} group`,children:[l.jsxs("div",{className:`flex gap-3 ${c?"flex-row-reverse":"flex-row"}`,children:[l.jsx("div",{className:"w-8 h-8 rounded-full bg-gray-800 flex-shrink-0 flex items-center justify-center mt-1",children:o()}),l.jsxs("div",{className:`max-w-xl p-3 rounded-lg shadow-md relative ${m}`,children:[l.jsx("div",{className:"space-y-3",children:r.map((f,h)=>"text"in f&&f.text?l.jsx("p",{className:"whitespace-pre-wrap",children:f.text},h):"functionCall"in f?l.jsxs("div",{className:"text-xs text-gray-400 italic bg-gray-800/40 p-2 rounded-md",children:[l.jsxs("p",{children:[l.jsx("strong",{children:"Tool Call:"})," ",l.jsx("code",{children:f.functionCall.name})]}),l.jsxs("pre",{className:"text-xs mt-1",children:["Args: ",JSON.stringify(f.functionCall.args,null,2)]})]},h):"functionResponse"in f?l.jsxs("div",{className:"text-xs text-gray-400 italic bg-gray-800/40 p-2 rounded-md",children:[l.jsx("p",{children:l.jsxs("strong",{children:["Tool Result for ",l.jsx("code",{children:f.functionResponse.name}),":"]})}),l.jsx("pre",{className:"text-xs mt-1",children:JSON.stringify(f.functionResponse.response,null,2)})]},h):"richContent"in f?l.jsx(vae,{content:f.richContent,onAction:t},h):null)}),r.some(f=>"text"in f)&&l.jsx(xae,{text:r.filter(f=>"text"in f).map(f=>f.text).join(` +`)})]})]}),l.jsx("p",{className:"text-xs text-gray-500 mt-1 px-11",children:new Date(i).toLocaleTimeString()})]})},wae=({previousView:e})=>{const{state:t,sendMessage:n,resetChat:r}=fae(),{messages:i,isLoading:o,error:c,isToolExecuting:u,toolExecutionName:m}=t,[f,h]=S.useState(""),g=S.useRef(null);S.useEffect(()=>{var E;(E=g.current)==null||E.scrollIntoView({behavior:"smooth"})},[i]);const v=async E=>{E.trim()&&(h(""),await n(E))},b=E=>{v(E)},T=E=>{const N=`The user wants to perform an action: ${JSON.stringify(E)}`;v(N)},C=Aj[e||"DEFAULT"]||Aj.DEFAULT;return l.jsxs("div",{className:"h-full flex flex-col",children:[l.jsxs("div",{className:"flex justify-between items-center mb-6",children:[l.jsx("h2",{className:"text-3xl font-bold text-white tracking-wider",children:"AI Advisor (Quantum)"}),l.jsx("button",{onClick:r,className:"p-2 rounded-full text-gray-400 hover:bg-gray-700 hover:text-white transition-colors","aria-label":"Reset conversation",children:l.jsx(sae,{className:"h-5 w-5"})})]}),l.jsxs(pe,{className:"flex-1 flex flex-col",padding:"none",children:[l.jsxs("div",{className:"flex-1 p-6 space-y-6 overflow-y-auto",children:[i.length<=1&&!o&&!c&&l.jsxs("div",{className:"text-center p-6 text-gray-400",children:[l.jsxs("p",{className:"mb-4",children:["Since you just came from the ",l.jsx("strong",{className:"text-cyan-300",children:e||"Dashboard"}),", you could ask:"]}),l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-2",children:C.map(E=>l.jsxs("button",{onClick:()=>b(E),className:"p-3 bg-gray-700/50 hover:bg-gray-700 rounded-lg text-sm text-cyan-200 transition-colors text-left",children:['"',E,'"']},E))})]}),i.map(E=>l.jsx(bae,{message:E,onAction:T},E.id)),o&&!u&&l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx("div",{className:"w-8 h-8 rounded-full bg-gray-800 flex-shrink-0 flex items-center justify-center mt-1",children:l.jsx(jI,{className:"h-6 w-6 text-cyan-300"})}),l.jsxs("div",{className:"max-w-lg p-3 rounded-lg shadow-md bg-gray-700 text-gray-200 flex items-center gap-2",children:[l.jsx("div",{className:"w-2 h-2 bg-cyan-400 rounded-full animate-pulse delay-75"}),l.jsx("div",{className:"w-2 h-2 bg-cyan-400 rounded-full animate-pulse delay-150"}),l.jsx("div",{className:"w-2 h-2 bg-cyan-400 rounded-full animate-pulse delay-300"})]})]}),u&&l.jsxs("div",{className:"flex items-center justify-center gap-2 text-sm text-gray-400 p-2",children:[l.jsx(MI,{className:"animate-spin text-cyan-400"}),l.jsxs("span",{children:["Accessing tool: ",l.jsxs("strong",{children:[m,"..."]})]})]}),l.jsx("div",{ref:g})]}),c&&l.jsxs("div",{className:"p-4 border-t border-red-500/50 bg-red-900/30 text-red-300 flex items-center gap-3",children:[l.jsx(iae,{className:"h-5 w-5 flex-shrink-0"}),l.jsx("p",{className:"text-sm",children:c})]}),l.jsxs("div",{className:"p-4 border-t border-gray-700/60 bg-gray-800/50 rounded-b-xl",children:[l.jsxs("form",{onSubmit:E=>{E.preventDefault(),v(f)},className:"flex items-center gap-2",children:[l.jsx("input",{type:"text",value:f,onChange:E=>h(E.target.value),placeholder:"Ask Quantum anything...",className:"flex-grow bg-gray-700/50 border border-gray-600 rounded-lg px-4 py-2 text-white focus:outline-none focus:ring-2 focus:ring-cyan-500 transition-all",disabled:o||!!c,"aria-label":"Chat input for AI Advisor"}),l.jsx("button",{type:"submit",className:"px-4 py-2 bg-cyan-600 hover:bg-cyan-700 text-white font-semibold rounded-lg disabled:opacity-50 flex items-center justify-center w-24 transition-colors",disabled:o||!f.trim()||!!c,"aria-label":"Send message",children:o?l.jsx("div",{className:"w-5 h-5 border-2 border-white border-t-transparent rounded-full animate-spin"}):"Send"})]}),l.jsx("p",{className:"text-xs text-gray-500 mt-2 text-center",children:"Quantum can make mistakes. Consider checking important information."})]})]})]})},Cj=({title:e,description:t,defaultChecked:n,onToggle:r,disabled:i,id:o})=>{const[c,u]=S.useState(n),m=f=>{u(f.target.checked),r&&r(f.target.checked)};return l.jsxs("li",{className:"py-4 flex flex-col sm:flex-row justify-between items-start sm:items-center",children:[l.jsxs("div",{className:"flex-grow",children:[l.jsx("label",{htmlFor:`toggle-${o}`,className:"font-semibold text-white cursor-pointer",children:e}),l.jsx("p",{className:"text-sm text-gray-400 max-w-md mt-1",children:t})]}),l.jsx("input",{type:"checkbox",id:`toggle-${o}`,className:"toggle toggle-cyan mt-2 sm:mt-0",checked:c,onChange:m,disabled:i,"aria-label":`Toggle for ${e}`})]})},Sae=({message:e,type:t,onClose:n,isVisible:r})=>{const i={success:"bg-green-600 border-green-700",error:"bg-red-600 border-red-700",info:"bg-blue-600 border-blue-700",warning:"bg-yellow-600 border-yellow-700",critical:"bg-purple-700 border-purple-800"};return S.useEffect(()=>{let o;return r&&(o=setTimeout(()=>{n()},t==="critical"?1e4:5e3)),()=>clearTimeout(o)},[r,n,t]),r?l.jsxs("div",{className:`fixed bottom-8 right-8 p-4 rounded-lg shadow-xl text-white flex items-center space-x-3 transition-all duration-300 ease-out transform ${i[t]} ${r?"translate-y-0 opacity-100":"translate-y-full opacity-0"}`,style:{zIndex:1e3},children:[l.jsx("span",{className:"text-sm font-medium flex-grow",children:e}),l.jsx("button",{onClick:n,className:"ml-4 p-1 rounded-full hover:bg-black/20 focus:outline-none flex-shrink-0",children:l.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}):null},Aae=()=>{const e=S.useContext(Ct),{linkedAccounts:t,unlinkAccount:n,handlePlaidSuccess:r}=e||{},[i,o]=S.useState(null),[c,u]=S.useState([]),[m,f]=S.useState([]);S.useEffect(()=>{const b=new Date,T=C=>new Date(b.getTime()-C*24*60*60*1e3).toISOString();u([{id:"1",device:"Chrome on macOS",browser:"Chrome 120",os:"macOS 14.2",location:"New York, USA",ip:"192.168.1.1",timestamp:T(.01),isCurrent:!0,userAgent:"Mozilla/5.0..."},{id:"2",device:"DemoBank App on iOS",browser:"App",os:"iOS 17.1",location:"New York, USA",ip:"172.16.0.1",timestamp:T(3),isCurrent:!1,userAgent:"Mozilla/5.0..."}]),f([{id:"dvc_1",name:"My MacBook Pro",type:"Desktop",model:"MacBook Pro M2",lastActivity:T(.01),location:"New York, USA",ip:"192.168.1.1",isCurrent:!0,permissions:["read_accounts"],status:"active",firstSeen:T(300),userAgent:"Mozilla/5.0...",pushNotificationsEnabled:!0,biometricAuthEnabled:!0,encryptionStatus:"full"},{id:"dvc_2",name:"iPhone 15 Pro",type:"Mobile",model:"iPhone 15 Pro",lastActivity:T(.5),location:"New York, USA",ip:"172.16.0.1",isCurrent:!1,permissions:["read_accounts","initiate_transfers"],status:"active",firstSeen:T(60),userAgent:"Mozilla/5.0...",pushNotificationsEnabled:!0,biometricAuthEnabled:!0,encryptionStatus:"full"}])},[]);const h=S.useCallback((b,T)=>{o({message:b,type:T,isVisible:!0})},[]),g=S.useCallback(()=>{o(b=>b?{...b,isVisible:!1}:null)},[]),v=b=>{n&&(n(b),h("Account successfully unlinked.","info"))};return l.jsxs("div",{className:"space-y-6",children:[l.jsx("h2",{className:"text-3xl font-bold text-white tracking-wider",children:"Security Fortress"}),l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[l.jsx(pe,{title:"Linked Accounts & Data Sources",className:"lg:col-span-2",children:l.jsxs("div",{className:"space-y-4",children:[l.jsx("p",{className:"text-gray-400 text-sm",children:"Manage external financial connections securely."}),t&&t.length>0?l.jsx("div",{className:"space-y-2",children:t.map(b=>l.jsxs("div",{className:"flex justify-between items-center p-3 bg-gray-800/50 rounded-lg border border-gray-700",children:[l.jsxs("div",{className:"flex items-center",children:[l.jsx("div",{className:"w-10 h-10 rounded-full bg-cyan-900/50 flex items-center justify-center text-cyan-400 mr-3",children:l.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 14v3m4-3v3m4-3v3M3 21h18M3 10h18M3 7l9-4 9 4M4 10h16v11H4V10z"})})}),l.jsxs("div",{children:[l.jsx("p",{className:"font-semibold text-white",children:b.name}),l.jsxs("p",{className:"text-xs text-gray-400",children:["Mask: ",b.mask]})]})]}),l.jsx("button",{onClick:()=>v(b.id),className:"px-3 py-1.5 bg-red-900/30 hover:bg-red-900/50 text-red-300 rounded-md text-sm transition-colors",children:"Unlink"})]},b.id))}):l.jsx("p",{className:"text-gray-500 italic",children:"No external accounts linked."}),l.jsx("div",{className:"pt-4",children:r&&l.jsx(_I,{onSuccess:r,className:"w-full sm:w-auto"})})]})}),l.jsx(pe,{title:"Security Settings",children:l.jsxs("ul",{className:"divide-y divide-gray-700",children:[l.jsx(Cj,{id:"2fa",title:"Two-Factor Authentication",description:"Require a code from your authenticator app when logging in.",defaultChecked:!0}),l.jsx(Cj,{id:"biometric",title:"Biometric Login",description:"Use FaceID or TouchID for faster, secure access.",defaultChecked:!0}),l.jsxs("li",{className:"py-4 flex justify-between items-center",children:[l.jsxs("div",{children:[l.jsx("span",{className:"font-semibold text-white",children:"Password"}),l.jsx("p",{className:"text-sm text-gray-400",children:"Last changed 3 months ago"})]}),l.jsx("button",{className:"px-4 py-2 bg-gray-700 hover:bg-gray-600 text-white rounded-lg text-sm transition-colors",children:"Change"})]})]})}),l.jsx(pe,{title:"Recent Login Activity",children:l.jsx("div",{className:"space-y-4 max-h-80 overflow-y-auto pr-2 custom-scrollbar",children:c.map(b=>l.jsxs("div",{className:"flex items-start justify-between p-3 bg-gray-800/30 rounded-lg",children:[l.jsxs("div",{children:[l.jsxs("p",{className:"font-medium text-white flex items-center gap-2",children:[b.device,b.isCurrent&&l.jsx("span",{className:"px-1.5 py-0.5 bg-green-900/50 text-green-400 text-xs rounded",children:"Current"})]}),l.jsxs("p",{className:"text-xs text-gray-400",children:[b.location," • ",b.ip]})]}),l.jsx("span",{className:"text-xs text-gray-500",children:new Date(b.timestamp).toLocaleString()})]},b.id))})}),l.jsx(pe,{title:"Active Devices",className:"lg:col-span-2",children:l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:m.map(b=>l.jsxs("div",{className:"p-4 bg-gray-800/50 rounded-lg border border-gray-700 flex justify-between items-center",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-10 h-10 bg-indigo-900/50 rounded-lg flex items-center justify-center text-indigo-300",children:b.type==="Mobile"?l.jsx("svg",{className:"w-6 h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 18h.01M8 21h8a2 2 0 002-2V5a2 2 0 00-2-2H8a2 2 0 00-2 2v14a2 2 0 002 2z"})}):l.jsx("svg",{className:"w-6 h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})})}),l.jsxs("div",{children:[l.jsx("p",{className:"font-semibold text-white",children:b.name}),l.jsxs("p",{className:"text-xs text-gray-400",children:["Last active: ",new Date(b.lastActivity).toLocaleDateString()]})]})]}),l.jsx("span",{className:`px-2 py-1 rounded text-xs font-medium ${b.status==="active"?"bg-green-900/30 text-green-400":"bg-red-900/30 text-red-400"}`,children:b.status.toUpperCase()})]},b.id))})})]}),i&&l.jsx(Sae,{message:i.message,type:i.type,isVisible:i.isVisible,onClose:g})]})},Cae=({isOpen:e,onClose:t,onAdd:n})=>{const[r,i]=S.useState(""),[o,c]=S.useState(""),u=()=>{r&&o&&(n(r,parseFloat(o)),t(),i(""),c(""))};return e?l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 backdrop-blur-sm",onClick:t,children:l.jsxs("div",{className:"bg-gray-800 rounded-lg shadow-2xl max-w-md w-full border border-gray-700",onClick:m=>m.stopPropagation(),children:[l.jsxs("div",{className:"p-4 border-b border-gray-700 flex justify-between items-center",children:[l.jsx("h3",{className:"text-lg font-semibold text-white",children:"Create New Budget"}),l.jsx("button",{onClick:t,className:"text-gray-400 hover:text-white",children:"×"})]}),l.jsxs("div",{className:"p-6 space-y-4",children:[l.jsx("input",{type:"text",value:r,onChange:m=>i(m.target.value),placeholder:"Budget Name (e.g., Entertainment)",className:"w-full bg-gray-700/50 border border-gray-600 rounded-lg px-3 py-2 text-white focus:outline-none focus:ring-1 focus:ring-cyan-500"}),l.jsx("input",{type:"number",value:o,onChange:m=>c(m.target.value),placeholder:"Monthly Limit ($)",className:"w-full bg-gray-700/50 border border-gray-600 rounded-lg px-3 py-2 text-white focus:outline-none focus:ring-1 focus:ring-cyan-500"}),l.jsx("button",{onClick:u,className:"w-full py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg",children:"Create"})]})]})}):null},Tae=({budget:e,transactions:t,onClose:n})=>{if(!e)return null;const r=t.filter(i=>i.category.toLowerCase()===e.name.toLowerCase()&&i.type==="expense");return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 backdrop-blur-sm",onClick:n,children:l.jsxs("div",{className:"bg-gray-800 rounded-lg shadow-2xl max-w-md w-full border border-gray-700",onClick:i=>i.stopPropagation(),children:[l.jsxs("div",{className:"p-4 border-b border-gray-700 flex justify-between items-center",children:[l.jsxs("h3",{className:"text-lg font-semibold text-white",children:[e.name," Budget Details"]}),l.jsx("button",{onClick:n,className:"text-gray-400 hover:text-white",children:"×"})]}),l.jsx("div",{className:"p-6",children:l.jsx("div",{className:"max-h-80 overflow-y-auto space-y-2",children:r.length>0?r.map(i=>l.jsxs("div",{className:"flex justify-between items-center p-2 bg-gray-900/50 rounded-lg text-sm",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:i.description}),l.jsx("p",{className:"text-gray-400 text-xs",children:i.date})]}),l.jsxs("p",{className:"font-mono text-red-400",children:["-$",i.amount.toFixed(2)]})]},i.id)):l.jsx("p",{className:"text-gray-400 text-center text-sm",children:"No transactions in this category yet."})})})]})})},Eae=({budget:e,onClick:t})=>{const n=Math.min(Math.floor(e.spent/e.limit*100),100),r=2*Math.PI*45,i=r-n/100*r,o=n>95?"stroke-red-500":n>80?"stroke-yellow-500":"stroke-cyan-400";return l.jsxs("button",{onClick:t,className:"flex flex-col items-center p-2 rounded-lg hover:bg-gray-700/50 transition-colors",children:[l.jsx("div",{className:"relative w-32 h-32",children:l.jsxs("svg",{className:"w-full h-full",viewBox:"0 0 100 100",children:[l.jsx("circle",{className:"text-gray-700",strokeWidth:"10",stroke:"currentColor",fill:"transparent",r:"45",cx:"50",cy:"50"}),l.jsx("circle",{className:`transition-all duration-700 ease-in-out ${o}`,strokeWidth:"10",strokeDasharray:r,strokeDashoffset:i,strokeLinecap:"round",stroke:"currentColor",fill:"transparent",r:"45",cx:"50",cy:"50",transform:"rotate(-90 50 50)"}),l.jsxs("text",{x:"50",y:"52",className:"text-xl font-bold fill-current text-white",textAnchor:"middle",children:[n,"%"]})]})}),l.jsx("p",{className:"mt-2 font-semibold text-white",children:e.name}),l.jsxs("p",{className:"text-sm text-gray-400",children:["$",e.spent.toFixed(2)," / $",e.limit.toFixed(2)]})]})},Nae=()=>{const e=S.useContext(Ct),[t,n]=S.useState([]),[r,i]=S.useState(""),[o,c]=S.useState(!1),[u,m]=S.useState(""),[f,h]=S.useState(!1),g=S.useRef(null),[v,b]=S.useState(!1),[T,C]=S.useState(null);if(!e)throw new Error("BudgetsView must be a child of DataProvider.");const{budgets:E,transactions:N,addBudget:I}=e,P=()=>{try{const j=new ar({apiKey:"PLACEHOLDER_API_KEY"}),k=`You are Quantum, a specialized financial advisor AI focused on budget analysis. The user's current budget data is: ${JSON.stringify(E)}. Your goal is to provide concise, actionable advice to help them manage their spending effectively. Keep responses brief and to the point.`;g.current=j.chats.create({model:"gemini-2.5-flash",config:{systemInstruction:k}})}catch(j){console.error("AI insight error:",j),m("I'm having trouble providing insights right now. Please try again later.")}},M=async j=>{if(!j.trim()||o||(g.current||P(),!g.current))return;c(!0),m(""),f||h(!0);const k={id:Date.now().toString(),sender:"user",text:j};n(R=>[...R,k]),i("");try{const F=await g.current.sendMessageStream({message:j});let q="";const G=Date.now().toString()+"-ai";n(H=>[...H,{id:G,sender:"ai",text:""}]);for await(const H of F)q+=H.text,n(V=>V.map(oe=>oe.id===G?{...oe,text:q}:oe))}catch(R){console.error("AI insight error:",R),m("I'm having trouble providing an insight right now. Please try again later.")}finally{c(!1)}};return S.useEffect(()=>{if(!f){const j=setTimeout(()=>{M("Analyze my current budgets and give me one key insight.")},500);return()=>clearTimeout(j)}},[f]),l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"space-y-6",children:[l.jsx(pe,{title:"Monthly Budgets",headerActions:[{id:"add",icon:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),onClick:()=>b(!0),label:"Add new budget"}],children:l.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-6",children:E.map(j=>l.jsx(Eae,{budget:j,onClick:()=>C(j)},j.id))})}),l.jsx(pe,{title:"Quantum Insights",children:!f&&!o?l.jsxs("div",{className:"text-center min-h-[10rem] flex flex-col items-center justify-center",children:[l.jsx("p",{className:"text-gray-400 mb-4",children:"Let Quantum analyze your spending and provide personalized advice."}),l.jsxs("div",{className:"flex items-center space-x-2 text-cyan-300",children:[l.jsx("div",{className:"h-2 w-2 bg-cyan-400 rounded-full animate-pulse [animation-delay:-0.3s]"}),l.jsx("div",{className:"h-2 w-2 bg-cyan-400 rounded-full animate-pulse [animation-delay:-0.15s]"}),l.jsx("div",{className:"h-2 w-2 bg-cyan-400 rounded-full animate-pulse"}),l.jsx("span",{children:"Quantum is preparing your first insight..."})]})]}):l.jsxs("div",{className:"flex flex-col space-y-4 max-h-96",children:[l.jsxs("div",{className:"flex-1 overflow-y-auto pr-2 space-y-3",children:[t.map(j=>l.jsxs("div",{className:`flex items-start gap-2 ${j.sender==="user"?"justify-end":""}`,children:[j.sender==="ai"&&l.jsx("div",{className:"w-6 h-6 rounded-full bg-cyan-600/50 flex items-center justify-center text-cyan-200 font-bold text-xs flex-shrink-0 mt-1",children:"Q"}),l.jsx("div",{className:`max-w-md p-3 text-sm rounded-lg ${j.sender==="user"?"bg-cyan-700 text-white":"bg-gray-700 text-gray-200"}`,children:l.jsx("p",{children:j.text})})]},j.id)),o&&l.jsxs("div",{className:"flex items-start gap-2",children:[l.jsx("div",{className:"w-6 h-6 rounded-full bg-cyan-600/50 flex items-center justify-center text-cyan-200 font-bold text-xs flex-shrink-0 mt-1",children:"Q"}),l.jsx("div",{className:"max-w-md p-3 text-sm rounded-lg bg-gray-700 text-gray-200",children:l.jsxs("div",{className:"flex items-center space-x-2",children:[l.jsx("div",{className:"h-2 w-2 bg-cyan-400 rounded-full animate-pulse [animation-delay:-0.3s]"}),l.jsx("div",{className:"h-2 w-2 bg-cyan-400 rounded-full animate-pulse [animation-delay:-0.15s]"}),l.jsx("div",{className:"h-2 w-2 bg-cyan-400 rounded-full animate-pulse"})]})})]}),u&&l.jsx("div",{className:"p-3 bg-red-900/50 border border-red-500/30 rounded-lg text-red-200 text-sm",children:l.jsx("p",{children:u})})]}),l.jsxs("form",{onSubmit:j=>{j.preventDefault(),M(r)},className:"flex items-center space-x-2 pt-2 border-t border-gray-700",children:[l.jsx("input",{type:"text",value:r,onChange:j=>i(j.target.value),placeholder:"Ask a follow-up question...",className:"flex-1 bg-gray-700/50 border border-gray-600 rounded-lg px-3 py-1.5 text-sm text-white focus:outline-none focus:ring-1 focus:ring-cyan-500",disabled:o}),l.jsx("button",{type:"submit",disabled:o||!r,className:"px-4 py-1.5 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg text-sm transition-colors disabled:opacity-50",children:"Send"})]})]})})]}),l.jsx(Cae,{isOpen:v,onClose:()=>b(!1),onAdd:(j,k)=>I({name:j,limit:k})}),l.jsx(Tae,{budget:T,transactions:N,onClose:()=>C(null)})]})},II=({className:e})=>l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:e||"h-8 w-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M19 11a7 7 0 01-7 7m0 0a7 7 0 01-7-7m7 7v4m0 0H8m4 0h4m-4-8a3 3 0 01-3-3V5a3 3 0 116 0v6a3 3 0 01-3 3z"})}),_ae=({onClose:e,voiceState:t,transcript:n,aiResponse:r,processUtterance:i})=>{const o=["Show my dashboard","What are my recent transactions?","Pay Alex Ray $50 for dinner","Take me to my budgets"],c={idle:"Ready",listening:"Listening...",processing:"Thinking...",speaking:"Speaking...",error:"Error"};return l.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 backdrop-blur-sm animate-fade-in",onClick:e,children:[l.jsxs("div",{className:"bg-gray-800 rounded-2xl p-8 max-w-2xl w-full text-center border border-gray-700",onClick:u=>u.stopPropagation(),children:[l.jsxs("div",{className:"relative w-24 h-24 mx-auto rounded-full bg-cyan-500/20 flex items-center justify-center mb-6",children:[t==="listening"&&l.jsx("div",{className:"absolute inset-0 rounded-full bg-cyan-500/30 animate-ping"}),l.jsx(II,{className:"h-12 w-12 text-cyan-300"})]}),l.jsx("h3",{className:"text-2xl font-bold text-white min-h-[2.25rem]",children:c[t]}),l.jsx("p",{className:"text-gray-300 mt-2 mb-6 min-h-[1.5rem] italic",children:n||" "}),l.jsx("div",{className:"h-16 text-center flex items-center justify-center mb-6 p-2 bg-gray-900/50 rounded-lg",children:l.jsx("p",{className:"text-lg text-cyan-200",children:r})}),l.jsxs("div",{className:"space-y-3",children:[l.jsx("p",{className:"text-sm text-gray-500",children:"Or try saying:"}),o.map(u=>l.jsxs("button",{onClick:()=>i(u),className:"w-full text-left p-3 bg-gray-700/50 hover:bg-gray-700 rounded-lg text-cyan-200 transition-colors",children:['"',u,'"']},u))]})]}),l.jsx("style",{children:` + @keyframes fade-in { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } } + .animate-fade-in { animation: fade-in 0.3s ease-out forwards; } + `})]})},jae=({setActiveView:e})=>{const[t,n]=S.useState(!1),[r,i]=S.useState("idle"),[o,c]=S.useState(""),[u,m]=S.useState("Hello! How can I help you?"),f=S.useRef(null),h=S.useContext(Ct),g=S.useRef(!1),v=S.useCallback(()=>{if(f.current&&r!=="listening"){c(""),i("listening");try{f.current.start()}catch(N){console.warn("Speech recognition already started.",N)}}},[r]),b=S.useCallback(N=>new Promise((I,P)=>{if(!g.current){P();return}i("speaking"),m(N);const M=new SpeechSynthesisUtterance(N);M.onend=()=>{g.current&&I()},M.onerror=j=>{g.current&&(i("error"),m("Sorry, I couldn't speak.")),P(j)},window.speechSynthesis.speak(M)}),[]),T=S.useCallback(async N=>{if(!g.current)return;c(N),i("processing");const I=N.toLowerCase(),P=I.match(/^(show|go to|take me to|open|view) (my )?(.+)$/i);if(P){let j=P[3].trim().replace(/\s+/g,"-");(j==="home"||j==="overview")&&(j="dashboard");const k=Object.values(ve).find(R=>R.replace(/-/g,"")===j.replace(/-/g,""));if(k){e(k),await b(`Navigating to ${k.replace(/-/g," ")}.`),n(!1);return}}const M=I.match(/^(pay|send) (.+?) \$?(\d+(\.\d{1,2})?)/i);if(M&&h){const j=M[2].trim(),k=parseFloat(M[3]),R={id:`tx_voice_${Date.now()}`,type:"expense",category:"Transfer",description:`Sent to ${j}`,amount:k,date:new Date().toISOString().split("T")[0]};h.addTransaction(R),await b(`Okay, I've sent $${k} to ${j}.`),n(!1);return}await b("I'm sorry, I didn't understand that. Please try again."),g.current&&v()},[e,h,b,v]);S.useEffect(()=>{g.current=!0;const N=window.SpeechRecognition||window.webkitSpeechRecognition;if(!N){m("Sorry, your browser doesn't support voice control."),i("error");return}const I=new N;return I.continuous=!1,I.interimResults=!0,I.lang="en-US",I.onresult=P=>{let M="";for(let j=P.resultIndex;j{console.error("Speech recognition error",P.error),m(`Error: ${P.error}. Please try again.`),i("error")},I.onstart=()=>{g.current&&i("listening")},I.onend=()=>{g.current&&r==="listening"&&i("idle")},f.current=I,()=>{g.current=!1,f.current&&f.current.stop(),window.speechSynthesis.cancel()}},[T,r]);const C=()=>{m("Hello! How can I help you?"),n(!0),setTimeout(v,300)},E=()=>{n(!1),f.current&&f.current.stop(),window.speechSynthesis.cancel()};return l.jsxs(l.Fragment,{children:[l.jsxs("button",{onClick:C,className:"fixed bottom-8 right-8 w-16 h-16 bg-cyan-600 hover:bg-cyan-500 rounded-full shadow-lg flex items-center justify-center text-white z-40 transition-transform hover:scale-110","aria-label":"Activate Voice Control",children:[l.jsx("div",{className:"absolute inset-0 rounded-full bg-white/20 animate-pulse"}),l.jsx(II,{})]}),t&&l.jsx(_ae,{onClose:E,voiceState:r,transcript:o,aiResponse:u,processUtterance:T})]})};var yc=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Mae={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},co,jx,Fj,Pae=(Fj=class{constructor(){Ie(this,co,Mae);Ie(this,jx,!1)}setTimeoutProvider(e){xe(this,co,e)}setTimeout(e,t){return B(this,co).setTimeout(e,t)}clearTimeout(e){B(this,co).clearTimeout(e)}setInterval(e,t){return B(this,co).setInterval(e,t)}clearInterval(e){B(this,co).clearInterval(e)}},co=new WeakMap,jx=new WeakMap,Fj),ls=new Pae;function Iae(e){setTimeout(e,0)}var Ps=typeof window>"u"||"Deno"in globalThis;function $n(){}function kae(e,t){return typeof e=="function"?e(t):e}function ux(e){return typeof e=="number"&&e>=0&&e!==1/0}function kI(e,t){return Math.max(e+(t||0)-Date.now(),0)}function bo(e,t){return typeof e=="function"?e(t):e}function Gr(e,t){return typeof e=="function"?e(t):e}function Tj(e,t){const{type:n="all",exact:r,fetchStatus:i,predicate:o,queryKey:c,stale:u}=e;if(c){if(r){if(t.queryHash!==O1(c,t.options))return!1}else if(!$u(t.queryKey,c))return!1}if(n!=="all"){const m=t.isActive();if(n==="active"&&!m||n==="inactive"&&m)return!1}return!(typeof u=="boolean"&&t.isStale()!==u||i&&i!==t.state.fetchStatus||o&&!o(t))}function Ej(e,t){const{exact:n,status:r,predicate:i,mutationKey:o}=e;if(o){if(!t.options.mutationKey)return!1;if(n){if(Is(t.options.mutationKey)!==Is(o))return!1}else if(!$u(t.options.mutationKey,o))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function O1(e,t){return((t==null?void 0:t.queryKeyHashFn)||Is)(e)}function Is(e){return JSON.stringify(e,(t,n)=>dx(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function $u(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>$u(e[n],t[n])):!1}var Dae=Object.prototype.hasOwnProperty;function DI(e,t){if(e===t)return e;const n=Nj(e)&&Nj(t);if(!n&&!(dx(e)&&dx(t)))return t;const i=(n?e:Object.keys(e)).length,o=n?t:Object.keys(t),c=o.length,u=n?new Array(c):{};let m=0;for(let f=0;f{ls.setTimeout(t,e)})}function fx(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?DI(e,t):t}function Oae(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Lae(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var L1=Symbol();function RI(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===L1?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function OI(e,t){return typeof e=="function"?e(...t):!!e}var cs,uo,Ul,qj,Uae=(qj=class extends yc{constructor(){super();Ie(this,cs);Ie(this,uo);Ie(this,Ul);xe(this,Ul,t=>{if(!Ps&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){B(this,uo)||this.setEventListener(B(this,Ul))}onUnsubscribe(){var t;this.hasListeners()||((t=B(this,uo))==null||t.call(this),xe(this,uo,void 0))}setEventListener(t){var n;xe(this,Ul,t),(n=B(this,uo))==null||n.call(this),xe(this,uo,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){B(this,cs)!==t&&(xe(this,cs,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof B(this,cs)=="boolean"?B(this,cs):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},cs=new WeakMap,uo=new WeakMap,Ul=new WeakMap,qj),U1=new Uae;function mx(){let e,t;const n=new Promise((i,o)=>{e=i,t=o});n.status="pending",n.catch(()=>{});function r(i){Object.assign(n,i),delete n.resolve,delete n.reject}return n.resolve=i=>{r({status:"fulfilled",value:i}),e(i)},n.reject=i=>{r({status:"rejected",reason:i}),t(i)},n}var Bae=Iae;function zae(){let e=[],t=0,n=u=>{u()},r=u=>{u()},i=Bae;const o=u=>{t?e.push(u):i(()=>{n(u)})},c=()=>{const u=e;e=[],u.length&&i(()=>{r(()=>{u.forEach(m=>{n(m)})})})};return{batch:u=>{let m;t++;try{m=u()}finally{t--,t||c()}return m},batchCalls:u=>(...m)=>{o(()=>{u(...m)})},schedule:o,setNotifyFunction:u=>{n=u},setBatchNotifyFunction:u=>{r=u},setScheduler:u=>{i=u}}}var dn=zae(),Bl,fo,zl,Gj,Fae=(Gj=class extends yc{constructor(){super();Ie(this,Bl,!0);Ie(this,fo);Ie(this,zl);xe(this,zl,t=>{if(!Ps&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){B(this,fo)||this.setEventListener(B(this,zl))}onUnsubscribe(){var t;this.hasListeners()||((t=B(this,fo))==null||t.call(this),xe(this,fo,void 0))}setEventListener(t){var n;xe(this,zl,t),(n=B(this,fo))==null||n.call(this),xe(this,fo,t(this.setOnline.bind(this)))}setOnline(t){B(this,Bl)!==t&&(xe(this,Bl,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return B(this,Bl)}},Bl=new WeakMap,fo=new WeakMap,zl=new WeakMap,Gj),ah=new Fae;function qae(e){return Math.min(1e3*2**e,3e4)}function LI(e){return(e??"online")==="online"?ah.isOnline():!0}var hx=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function UI(e){let t=!1,n=0,r;const i=mx(),o=()=>i.status!=="pending",c=C=>{var E;if(!o()){const N=new hx(C);v(N),(E=e.onCancel)==null||E.call(e,N)}},u=()=>{t=!0},m=()=>{t=!1},f=()=>U1.isFocused()&&(e.networkMode==="always"||ah.isOnline())&&e.canRun(),h=()=>LI(e.networkMode)&&e.canRun(),g=C=>{o()||(r==null||r(),i.resolve(C))},v=C=>{o()||(r==null||r(),i.reject(C))},b=()=>new Promise(C=>{var E;r=N=>{(o()||f())&&C(N)},(E=e.onPause)==null||E.call(e)}).then(()=>{var C;r=void 0,o()||(C=e.onContinue)==null||C.call(e)}),T=()=>{if(o())return;let C;const E=n===0?e.initialPromise:void 0;try{C=E??e.fn()}catch(N){C=Promise.reject(N)}Promise.resolve(C).then(g).catch(N=>{var k;if(o())return;const I=e.retry??(Ps?0:3),P=e.retryDelay??qae,M=typeof P=="function"?P(n,N):P,j=I===!0||typeof I=="number"&&nf()?void 0:b()).then(()=>{t?v(N):T()})})};return{promise:i,status:()=>i.status,cancel:c,continue:()=>(r==null||r(),i),cancelRetry:u,continueRetry:m,canStart:h,start:()=>(h()?T():b().then(T),i)}}var us,$j,BI=($j=class{constructor(){Ie(this,us)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ux(this.gcTime)&&xe(this,us,ls.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Ps?1/0:300*1e3))}clearGcTimeout(){B(this,us)&&(ls.clearTimeout(B(this,us)),xe(this,us,void 0))}},us=new WeakMap,$j),ds,Fl,qr,fs,vn,Hu,ms,ni,ea,Hj,Gae=(Hj=class extends BI{constructor(t){super();Ie(this,ni);Ie(this,ds);Ie(this,Fl);Ie(this,qr);Ie(this,fs);Ie(this,vn);Ie(this,Hu);Ie(this,ms);xe(this,ms,!1),xe(this,Hu,t.defaultOptions),this.setOptions(t.options),this.observers=[],xe(this,fs,t.client),xe(this,qr,B(this,fs).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,xe(this,ds,Mj(this.options)),this.state=t.state??B(this,ds),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=B(this,vn))==null?void 0:t.promise}setOptions(t){if(this.options={...B(this,Hu),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=Mj(this.options);n.data!==void 0&&(this.setState(jj(n.data,n.dataUpdatedAt)),xe(this,ds,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&B(this,qr).remove(this)}setData(t,n){const r=fx(this.state.data,t,this.options);return Ge(this,ni,ea).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){Ge(this,ni,ea).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,i;const n=(r=B(this,vn))==null?void 0:r.promise;return(i=B(this,vn))==null||i.cancel(t),n?n.then($n).catch($n):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(B(this,ds))}isActive(){return this.observers.some(t=>Gr(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===L1||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>bo(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!kI(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=B(this,vn))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=B(this,vn))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),B(this,qr).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(B(this,vn)&&(B(this,ms)?B(this,vn).cancel({revert:!0}):B(this,vn).cancelRetry()),this.scheduleGc()),B(this,qr).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Ge(this,ni,ea).call(this,{type:"invalidate"})}async fetch(t,n){var m,f,h,g,v,b,T,C,E,N,I,P;if(this.state.fetchStatus!=="idle"&&((m=B(this,vn))==null?void 0:m.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(B(this,vn))return B(this,vn).continueRetry(),B(this,vn).promise}if(t&&this.setOptions(t),!this.options.queryFn){const M=this.observers.find(j=>j.options.queryFn);M&&this.setOptions(M.options)}const r=new AbortController,i=M=>{Object.defineProperty(M,"signal",{enumerable:!0,get:()=>(xe(this,ms,!0),r.signal)})},o=()=>{const M=RI(this.options,n),k=(()=>{const R={client:B(this,fs),queryKey:this.queryKey,meta:this.meta};return i(R),R})();return xe(this,ms,!1),this.options.persister?this.options.persister(M,k,this):M(k)},u=(()=>{const M={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:B(this,fs),state:this.state,fetchFn:o};return i(M),M})();(f=this.options.behavior)==null||f.onFetch(u,this),xe(this,Fl,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((h=u.fetchOptions)==null?void 0:h.meta))&&Ge(this,ni,ea).call(this,{type:"fetch",meta:(g=u.fetchOptions)==null?void 0:g.meta}),xe(this,vn,UI({initialPromise:n==null?void 0:n.initialPromise,fn:u.fetchFn,onCancel:M=>{M instanceof hx&&M.revert&&this.setState({...B(this,Fl),fetchStatus:"idle"}),r.abort()},onFail:(M,j)=>{Ge(this,ni,ea).call(this,{type:"failed",failureCount:M,error:j})},onPause:()=>{Ge(this,ni,ea).call(this,{type:"pause"})},onContinue:()=>{Ge(this,ni,ea).call(this,{type:"continue"})},retry:u.options.retry,retryDelay:u.options.retryDelay,networkMode:u.options.networkMode,canRun:()=>!0}));try{const M=await B(this,vn).start();if(M===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(M),(b=(v=B(this,qr).config).onSuccess)==null||b.call(v,M,this),(C=(T=B(this,qr).config).onSettled)==null||C.call(T,M,this.state.error,this),M}catch(M){if(M instanceof hx){if(M.silent)return B(this,vn).promise;if(M.revert){if(this.state.data===void 0)throw M;return this.state.data}}throw Ge(this,ni,ea).call(this,{type:"error",error:M}),(N=(E=B(this,qr).config).onError)==null||N.call(E,M,this),(P=(I=B(this,qr).config).onSettled)==null||P.call(I,this.state.data,M,this),M}finally{this.scheduleGc()}}},ds=new WeakMap,Fl=new WeakMap,qr=new WeakMap,fs=new WeakMap,vn=new WeakMap,Hu=new WeakMap,ms=new WeakMap,ni=new WeakSet,ea=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...zI(r.data,this.options),fetchMeta:t.meta??null};case"success":const i={...r,...jj(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return xe(this,Fl,t.manual?i:void 0),i;case"error":const o=t.error;return{...r,error:o,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:o,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),dn.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),B(this,qr).notify({query:this,type:"updated",action:t})})},Hj);function zI(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:LI(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function jj(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Mj(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var nr,Qe,Vu,qn,hs,ql,ta,mo,Ku,Gl,$l,ps,gs,ho,Hl,st,Nu,px,gx,yx,vx,xx,bx,wx,FI,Vj,$ae=(Vj=class extends yc{constructor(t,n){super();Ie(this,st);Ie(this,nr);Ie(this,Qe);Ie(this,Vu);Ie(this,qn);Ie(this,hs);Ie(this,ql);Ie(this,ta);Ie(this,mo);Ie(this,Ku);Ie(this,Gl);Ie(this,$l);Ie(this,ps);Ie(this,gs);Ie(this,ho);Ie(this,Hl,new Set);this.options=n,xe(this,nr,t),xe(this,mo,null),xe(this,ta,mx()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(B(this,Qe).addObserver(this),Pj(B(this,Qe),this.options)?Ge(this,st,Nu).call(this):this.updateResult(),Ge(this,st,vx).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Sx(B(this,Qe),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Sx(B(this,Qe),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Ge(this,st,xx).call(this),Ge(this,st,bx).call(this),B(this,Qe).removeObserver(this)}setOptions(t){const n=this.options,r=B(this,Qe);if(this.options=B(this,nr).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Gr(this.options.enabled,B(this,Qe))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Ge(this,st,wx).call(this),B(this,Qe).setOptions(this.options),n._defaulted&&!ih(this.options,n)&&B(this,nr).getQueryCache().notify({type:"observerOptionsUpdated",query:B(this,Qe),observer:this});const i=this.hasListeners();i&&Ij(B(this,Qe),r,this.options,n)&&Ge(this,st,Nu).call(this),this.updateResult(),i&&(B(this,Qe)!==r||Gr(this.options.enabled,B(this,Qe))!==Gr(n.enabled,B(this,Qe))||bo(this.options.staleTime,B(this,Qe))!==bo(n.staleTime,B(this,Qe)))&&Ge(this,st,px).call(this);const o=Ge(this,st,gx).call(this);i&&(B(this,Qe)!==r||Gr(this.options.enabled,B(this,Qe))!==Gr(n.enabled,B(this,Qe))||o!==B(this,ho))&&Ge(this,st,yx).call(this,o)}getOptimisticResult(t){const n=B(this,nr).getQueryCache().build(B(this,nr),t),r=this.createResult(n,t);return Vae(this,r)&&(xe(this,qn,r),xe(this,ql,this.options),xe(this,hs,B(this,Qe).state)),r}getCurrentResult(){return B(this,qn)}trackResult(t,n){return new Proxy(t,{get:(r,i)=>(this.trackProp(i),n==null||n(i),i==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&B(this,ta).status==="pending"&&B(this,ta).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,i))})}trackProp(t){B(this,Hl).add(t)}getCurrentQuery(){return B(this,Qe)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=B(this,nr).defaultQueryOptions(t),r=B(this,nr).getQueryCache().build(B(this,nr),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return Ge(this,st,Nu).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),B(this,qn)))}createResult(t,n){var q;const r=B(this,Qe),i=this.options,o=B(this,qn),c=B(this,hs),u=B(this,ql),f=t!==r?t.state:B(this,Vu),{state:h}=t;let g={...h},v=!1,b;if(n._optimisticResults){const G=this.hasListeners(),H=!G&&Pj(t,n),V=G&&Ij(t,r,n,i);(H||V)&&(g={...g,...zI(h.data,t.options)}),n._optimisticResults==="isRestoring"&&(g.fetchStatus="idle")}let{error:T,errorUpdatedAt:C,status:E}=g;b=g.data;let N=!1;if(n.placeholderData!==void 0&&b===void 0&&E==="pending"){let G;o!=null&&o.isPlaceholderData&&n.placeholderData===(u==null?void 0:u.placeholderData)?(G=o.data,N=!0):G=typeof n.placeholderData=="function"?n.placeholderData((q=B(this,$l))==null?void 0:q.state.data,B(this,$l)):n.placeholderData,G!==void 0&&(E="success",b=fx(o==null?void 0:o.data,G,n),v=!0)}if(n.select&&b!==void 0&&!N)if(o&&b===(c==null?void 0:c.data)&&n.select===B(this,Ku))b=B(this,Gl);else try{xe(this,Ku,n.select),b=n.select(b),b=fx(o==null?void 0:o.data,b,n),xe(this,Gl,b),xe(this,mo,null)}catch(G){xe(this,mo,G)}B(this,mo)&&(T=B(this,mo),b=B(this,Gl),C=Date.now(),E="error");const I=g.fetchStatus==="fetching",P=E==="pending",M=E==="error",j=P&&I,k=b!==void 0,F={status:E,fetchStatus:g.fetchStatus,isPending:P,isSuccess:E==="success",isError:M,isInitialLoading:j,isLoading:j,data:b,dataUpdatedAt:g.dataUpdatedAt,error:T,errorUpdatedAt:C,failureCount:g.fetchFailureCount,failureReason:g.fetchFailureReason,errorUpdateCount:g.errorUpdateCount,isFetched:g.dataUpdateCount>0||g.errorUpdateCount>0,isFetchedAfterMount:g.dataUpdateCount>f.dataUpdateCount||g.errorUpdateCount>f.errorUpdateCount,isFetching:I,isRefetching:I&&!P,isLoadingError:M&&!k,isPaused:g.fetchStatus==="paused",isPlaceholderData:v,isRefetchError:M&&k,isStale:B1(t,n),refetch:this.refetch,promise:B(this,ta),isEnabled:Gr(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const G=oe=>{F.status==="error"?oe.reject(F.error):F.data!==void 0&&oe.resolve(F.data)},H=()=>{const oe=xe(this,ta,F.promise=mx());G(oe)},V=B(this,ta);switch(V.status){case"pending":t.queryHash===r.queryHash&&G(V);break;case"fulfilled":(F.status==="error"||F.data!==V.value)&&H();break;case"rejected":(F.status!=="error"||F.error!==V.reason)&&H();break}}return F}updateResult(){const t=B(this,qn),n=this.createResult(B(this,Qe),this.options);if(xe(this,hs,B(this,Qe).state),xe(this,ql,this.options),B(this,hs).data!==void 0&&xe(this,$l,B(this,Qe)),ih(n,t))return;xe(this,qn,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:i}=this.options,o=typeof i=="function"?i():i;if(o==="all"||!o&&!B(this,Hl).size)return!0;const c=new Set(o??B(this,Hl));return this.options.throwOnError&&c.add("error"),Object.keys(B(this,qn)).some(u=>{const m=u;return B(this,qn)[m]!==t[m]&&c.has(m)})};Ge(this,st,FI).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Ge(this,st,vx).call(this)}},nr=new WeakMap,Qe=new WeakMap,Vu=new WeakMap,qn=new WeakMap,hs=new WeakMap,ql=new WeakMap,ta=new WeakMap,mo=new WeakMap,Ku=new WeakMap,Gl=new WeakMap,$l=new WeakMap,ps=new WeakMap,gs=new WeakMap,ho=new WeakMap,Hl=new WeakMap,st=new WeakSet,Nu=function(t){Ge(this,st,wx).call(this);let n=B(this,Qe).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch($n)),n},px=function(){Ge(this,st,xx).call(this);const t=bo(this.options.staleTime,B(this,Qe));if(Ps||B(this,qn).isStale||!ux(t))return;const r=kI(B(this,qn).dataUpdatedAt,t)+1;xe(this,ps,ls.setTimeout(()=>{B(this,qn).isStale||this.updateResult()},r))},gx=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(B(this,Qe)):this.options.refetchInterval)??!1},yx=function(t){Ge(this,st,bx).call(this),xe(this,ho,t),!(Ps||Gr(this.options.enabled,B(this,Qe))===!1||!ux(B(this,ho))||B(this,ho)===0)&&xe(this,gs,ls.setInterval(()=>{(this.options.refetchIntervalInBackground||U1.isFocused())&&Ge(this,st,Nu).call(this)},B(this,ho)))},vx=function(){Ge(this,st,px).call(this),Ge(this,st,yx).call(this,Ge(this,st,gx).call(this))},xx=function(){B(this,ps)&&(ls.clearTimeout(B(this,ps)),xe(this,ps,void 0))},bx=function(){B(this,gs)&&(ls.clearInterval(B(this,gs)),xe(this,gs,void 0))},wx=function(){const t=B(this,nr).getQueryCache().build(B(this,nr),this.options);if(t===B(this,Qe))return;const n=B(this,Qe);xe(this,Qe,t),xe(this,Vu,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},FI=function(t){dn.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(B(this,qn))}),B(this,nr).getQueryCache().notify({query:B(this,Qe),type:"observerResultsUpdated"})})},Vj);function Hae(e,t){return Gr(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Pj(e,t){return Hae(e,t)||e.state.data!==void 0&&Sx(e,t,t.refetchOnMount)}function Sx(e,t,n){if(Gr(t.enabled,e)!==!1&&bo(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&B1(e,t)}return!1}function Ij(e,t,n,r){return(e!==t||Gr(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&B1(e,n)}function B1(e,t){return Gr(t.enabled,e)!==!1&&e.isStaleByTime(bo(t.staleTime,e))}function Vae(e,t){return!ih(e.getCurrentResult(),t)}function kj(e){return{onFetch:(t,n)=>{var h,g,v,b,T;const r=t.options,i=(v=(g=(h=t.fetchOptions)==null?void 0:h.meta)==null?void 0:g.fetchMore)==null?void 0:v.direction,o=((b=t.state.data)==null?void 0:b.pages)||[],c=((T=t.state.data)==null?void 0:T.pageParams)||[];let u={pages:[],pageParams:[]},m=0;const f=async()=>{let C=!1;const E=P=>{Object.defineProperty(P,"signal",{enumerable:!0,get:()=>(t.signal.aborted?C=!0:t.signal.addEventListener("abort",()=>{C=!0}),t.signal)})},N=RI(t.options,t.fetchOptions),I=async(P,M,j)=>{if(C)return Promise.reject();if(M==null&&P.pages.length)return Promise.resolve(P);const R=(()=>{const H={client:t.client,queryKey:t.queryKey,pageParam:M,direction:j?"backward":"forward",meta:t.options.meta};return E(H),H})(),F=await N(R),{maxPages:q}=t.options,G=j?Lae:Oae;return{pages:G(P.pages,F,q),pageParams:G(P.pageParams,M,q)}};if(i&&o.length){const P=i==="backward",M=P?Kae:Dj,j={pages:o,pageParams:c},k=M(r,j);u=await I(j,k,P)}else{const P=e??o.length;do{const M=m===0?c[0]??r.initialPageParam:Dj(r,u);if(m>0&&M==null)break;u=await I(u,M),m++}while(m{var C,E;return(E=(C=t.options).persister)==null?void 0:E.call(C,f,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=f}}}function Dj(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Kae(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var Yu,xi,Gn,ys,bi,ao,Kj,Yae=(Kj=class extends BI{constructor(t){super();Ie(this,bi);Ie(this,Yu);Ie(this,xi);Ie(this,Gn);Ie(this,ys);xe(this,Yu,t.client),this.mutationId=t.mutationId,xe(this,Gn,t.mutationCache),xe(this,xi,[]),this.state=t.state||qI(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){B(this,xi).includes(t)||(B(this,xi).push(t),this.clearGcTimeout(),B(this,Gn).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){xe(this,xi,B(this,xi).filter(n=>n!==t)),this.scheduleGc(),B(this,Gn).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){B(this,xi).length||(this.state.status==="pending"?this.scheduleGc():B(this,Gn).remove(this))}continue(){var t;return((t=B(this,ys))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var c,u,m,f,h,g,v,b,T,C,E,N,I,P,M,j,k,R,F,q;const n=()=>{Ge(this,bi,ao).call(this,{type:"continue"})},r={client:B(this,Yu),meta:this.options.meta,mutationKey:this.options.mutationKey};xe(this,ys,UI({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(G,H)=>{Ge(this,bi,ao).call(this,{type:"failed",failureCount:G,error:H})},onPause:()=>{Ge(this,bi,ao).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>B(this,Gn).canRun(this)}));const i=this.state.status==="pending",o=!B(this,ys).canStart();try{if(i)n();else{Ge(this,bi,ao).call(this,{type:"pending",variables:t,isPaused:o}),await((u=(c=B(this,Gn).config).onMutate)==null?void 0:u.call(c,t,this,r));const H=await((f=(m=this.options).onMutate)==null?void 0:f.call(m,t,r));H!==this.state.context&&Ge(this,bi,ao).call(this,{type:"pending",context:H,variables:t,isPaused:o})}const G=await B(this,ys).start();return await((g=(h=B(this,Gn).config).onSuccess)==null?void 0:g.call(h,G,t,this.state.context,this,r)),await((b=(v=this.options).onSuccess)==null?void 0:b.call(v,G,t,this.state.context,r)),await((C=(T=B(this,Gn).config).onSettled)==null?void 0:C.call(T,G,null,this.state.variables,this.state.context,this,r)),await((N=(E=this.options).onSettled)==null?void 0:N.call(E,G,null,t,this.state.context,r)),Ge(this,bi,ao).call(this,{type:"success",data:G}),G}catch(G){try{throw await((P=(I=B(this,Gn).config).onError)==null?void 0:P.call(I,G,t,this.state.context,this,r)),await((j=(M=this.options).onError)==null?void 0:j.call(M,G,t,this.state.context,r)),await((R=(k=B(this,Gn).config).onSettled)==null?void 0:R.call(k,void 0,G,this.state.variables,this.state.context,this,r)),await((q=(F=this.options).onSettled)==null?void 0:q.call(F,void 0,G,t,this.state.context,r)),G}finally{Ge(this,bi,ao).call(this,{type:"error",error:G})}}finally{B(this,Gn).runNext(this)}}},Yu=new WeakMap,xi=new WeakMap,Gn=new WeakMap,ys=new WeakMap,bi=new WeakSet,ao=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),dn.batch(()=>{B(this,xi).forEach(r=>{r.onMutationUpdate(t)}),B(this,Gn).notify({mutation:this,type:"updated",action:t})})},Kj);function qI(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var na,ri,Wu,Yj,Wae=(Yj=class extends yc{constructor(t={}){super();Ie(this,na);Ie(this,ri);Ie(this,Wu);this.config=t,xe(this,na,new Set),xe(this,ri,new Map),xe(this,Wu,0)}build(t,n,r){const i=new Yae({client:t,mutationCache:this,mutationId:++Of(this,Wu)._,options:t.defaultMutationOptions(n),state:r});return this.add(i),i}add(t){B(this,na).add(t);const n=em(t);if(typeof n=="string"){const r=B(this,ri).get(n);r?r.push(t):B(this,ri).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(B(this,na).delete(t)){const n=em(t);if(typeof n=="string"){const r=B(this,ri).get(n);if(r)if(r.length>1){const i=r.indexOf(t);i!==-1&&r.splice(i,1)}else r[0]===t&&B(this,ri).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=em(t);if(typeof n=="string"){const r=B(this,ri).get(n),i=r==null?void 0:r.find(o=>o.state.status==="pending");return!i||i===t}else return!0}runNext(t){var r;const n=em(t);if(typeof n=="string"){const i=(r=B(this,ri).get(n))==null?void 0:r.find(o=>o!==t&&o.state.isPaused);return(i==null?void 0:i.continue())??Promise.resolve()}else return Promise.resolve()}clear(){dn.batch(()=>{B(this,na).forEach(t=>{this.notify({type:"removed",mutation:t})}),B(this,na).clear(),B(this,ri).clear()})}getAll(){return Array.from(B(this,na))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>Ej(n,r))}findAll(t={}){return this.getAll().filter(n=>Ej(t,n))}notify(t){dn.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return dn.batch(()=>Promise.all(t.map(n=>n.continue().catch($n))))}},na=new WeakMap,ri=new WeakMap,Wu=new WeakMap,Yj);function em(e){var t;return(t=e.options.scope)==null?void 0:t.id}var ra,po,rr,ia,fa,sm,Ax,Wj,Jae=(Wj=class extends yc{constructor(n,r){super();Ie(this,fa);Ie(this,ra);Ie(this,po);Ie(this,rr);Ie(this,ia);xe(this,ra,n),this.setOptions(r),this.bindMethods(),Ge(this,fa,sm).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var i;const r=this.options;this.options=B(this,ra).defaultMutationOptions(n),ih(this.options,r)||B(this,ra).getMutationCache().notify({type:"observerOptionsUpdated",mutation:B(this,rr),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&Is(r.mutationKey)!==Is(this.options.mutationKey)?this.reset():((i=B(this,rr))==null?void 0:i.state.status)==="pending"&&B(this,rr).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=B(this,rr))==null||n.removeObserver(this)}onMutationUpdate(n){Ge(this,fa,sm).call(this),Ge(this,fa,Ax).call(this,n)}getCurrentResult(){return B(this,po)}reset(){var n;(n=B(this,rr))==null||n.removeObserver(this),xe(this,rr,void 0),Ge(this,fa,sm).call(this),Ge(this,fa,Ax).call(this)}mutate(n,r){var i;return xe(this,ia,r),(i=B(this,rr))==null||i.removeObserver(this),xe(this,rr,B(this,ra).getMutationCache().build(B(this,ra),this.options)),B(this,rr).addObserver(this),B(this,rr).execute(n)}},ra=new WeakMap,po=new WeakMap,rr=new WeakMap,ia=new WeakMap,fa=new WeakSet,sm=function(){var r;const n=((r=B(this,rr))==null?void 0:r.state)??qI();xe(this,po,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},Ax=function(n){dn.batch(()=>{var r,i,o,c,u,m,f,h;if(B(this,ia)&&this.hasListeners()){const g=B(this,po).variables,v=B(this,po).context,b={client:B(this,ra),meta:this.options.meta,mutationKey:this.options.mutationKey};(n==null?void 0:n.type)==="success"?((i=(r=B(this,ia)).onSuccess)==null||i.call(r,n.data,g,v,b),(c=(o=B(this,ia)).onSettled)==null||c.call(o,n.data,null,g,v,b)):(n==null?void 0:n.type)==="error"&&((m=(u=B(this,ia)).onError)==null||m.call(u,n.error,g,v,b),(h=(f=B(this,ia)).onSettled)==null||h.call(f,void 0,n.error,g,v,b))}this.listeners.forEach(g=>{g(B(this,po))})})},Wj),wi,Jj,Qae=(Jj=class extends yc{constructor(t={}){super();Ie(this,wi);this.config=t,xe(this,wi,new Map)}build(t,n,r){const i=n.queryKey,o=n.queryHash??O1(i,n);let c=this.get(o);return c||(c=new Gae({client:t,queryKey:i,queryHash:o,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(i)}),this.add(c)),c}add(t){B(this,wi).has(t.queryHash)||(B(this,wi).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=B(this,wi).get(t.queryHash);n&&(t.destroy(),n===t&&B(this,wi).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){dn.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return B(this,wi).get(t)}getAll(){return[...B(this,wi).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>Tj(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>Tj(t,r)):n}notify(t){dn.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){dn.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){dn.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},wi=new WeakMap,Jj),qt,go,yo,Vl,Kl,vo,Yl,Wl,Qj,Xae=(Qj=class{constructor(e={}){Ie(this,qt);Ie(this,go);Ie(this,yo);Ie(this,Vl);Ie(this,Kl);Ie(this,vo);Ie(this,Yl);Ie(this,Wl);xe(this,qt,e.queryCache||new Qae),xe(this,go,e.mutationCache||new Wae),xe(this,yo,e.defaultOptions||{}),xe(this,Vl,new Map),xe(this,Kl,new Map),xe(this,vo,0)}mount(){Of(this,vo)._++,B(this,vo)===1&&(xe(this,Yl,U1.subscribe(async e=>{e&&(await this.resumePausedMutations(),B(this,qt).onFocus())})),xe(this,Wl,ah.subscribe(async e=>{e&&(await this.resumePausedMutations(),B(this,qt).onOnline())})))}unmount(){var e,t;Of(this,vo)._--,B(this,vo)===0&&((e=B(this,Yl))==null||e.call(this),xe(this,Yl,void 0),(t=B(this,Wl))==null||t.call(this),xe(this,Wl,void 0))}isFetching(e){return B(this,qt).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return B(this,go).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=B(this,qt).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=B(this,qt).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(bo(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return B(this,qt).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),i=B(this,qt).get(r.queryHash),o=i==null?void 0:i.state.data,c=kae(t,o);if(c!==void 0)return B(this,qt).build(this,r).setData(c,{...n,manual:!0})}setQueriesData(e,t,n){return dn.batch(()=>B(this,qt).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=B(this,qt).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=B(this,qt);dn.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=B(this,qt);return dn.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=dn.batch(()=>B(this,qt).findAll(e).map(i=>i.cancel(n)));return Promise.all(r).then($n).catch($n)}invalidateQueries(e,t={}){return dn.batch(()=>(B(this,qt).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=dn.batch(()=>B(this,qt).findAll(e).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let o=i.fetch(void 0,n);return n.throwOnError||(o=o.catch($n)),i.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(r).then($n)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=B(this,qt).build(this,t);return n.isStaleByTime(bo(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then($n).catch($n)}fetchInfiniteQuery(e){return e.behavior=kj(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then($n).catch($n)}ensureInfiniteQueryData(e){return e.behavior=kj(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return ah.isOnline()?B(this,go).resumePausedMutations():Promise.resolve()}getQueryCache(){return B(this,qt)}getMutationCache(){return B(this,go)}getDefaultOptions(){return B(this,yo)}setDefaultOptions(e){xe(this,yo,e)}setQueryDefaults(e,t){B(this,Vl).set(Is(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...B(this,Vl).values()],n={};return t.forEach(r=>{$u(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){B(this,Kl).set(Is(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...B(this,Kl).values()],n={};return t.forEach(r=>{$u(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...B(this,yo).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=O1(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===L1&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...B(this,yo).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){B(this,qt).clear(),B(this,go).clear()}},qt=new WeakMap,go=new WeakMap,yo=new WeakMap,Vl=new WeakMap,Kl=new WeakMap,vo=new WeakMap,Yl=new WeakMap,Wl=new WeakMap,Qj),GI=S.createContext(void 0),z1=e=>{const t=S.useContext(GI);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Zae=({client:e,children:t})=>(S.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),l.jsx(GI.Provider,{value:e,children:t})),$I=S.createContext(!1),eoe=()=>S.useContext($I);$I.Provider;function toe(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var noe=S.createContext(toe()),roe=()=>S.useContext(noe),ioe=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},aoe=e=>{S.useEffect(()=>{e.clearReset()},[e])},ooe=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||OI(n,[e.error,r])),soe=e=>{if(e.suspense){const n=i=>i==="static"?i:Math.max(i??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...i)=>n(r(...i)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},loe=(e,t)=>e.isLoading&&e.isFetching&&!t,coe=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,Rj=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function uoe(e,t,n){var g,v,b,T,C;const r=eoe(),i=roe(),o=z1(),c=o.defaultQueryOptions(e);(v=(g=o.getDefaultOptions().queries)==null?void 0:g._experimental_beforeQuery)==null||v.call(g,c),c._optimisticResults=r?"isRestoring":"optimistic",soe(c),ioe(c,i),aoe(i);const u=!o.getQueryCache().get(c.queryHash),[m]=S.useState(()=>new t(o,c)),f=m.getOptimisticResult(c),h=!r&&e.subscribed!==!1;if(S.useSyncExternalStore(S.useCallback(E=>{const N=h?m.subscribe(dn.batchCalls(E)):$n;return m.updateResult(),N},[m,h]),()=>m.getCurrentResult(),()=>m.getCurrentResult()),S.useEffect(()=>{m.setOptions(c)},[c,m]),coe(c,f))throw Rj(c,m,i);if(ooe({result:f,errorResetBoundary:i,throwOnError:c.throwOnError,query:o.getQueryCache().get(c.queryHash),suspense:c.suspense}))throw f.error;if((T=(b=o.getDefaultOptions().queries)==null?void 0:b._experimental_afterQuery)==null||T.call(b,c,f),c.experimental_prefetchInRender&&!Ps&&loe(f,r)){const E=u?Rj(c,m,i):(C=o.getQueryCache().get(c.queryHash))==null?void 0:C.promise;E==null||E.catch($n).finally(()=>{m.updateResult()})}return c.notifyOnChangeProps?f:m.trackResult(f)}function HI(e,t){return uoe(e,$ae)}function tp(e,t){const n=z1(),[r]=S.useState(()=>new Jae(n,e));S.useEffect(()=>{r.setOptions(e)},[r,e]);const i=S.useSyncExternalStore(S.useCallback(c=>r.subscribe(dn.batchCalls(c)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),o=S.useCallback((c,u)=>{r.mutate(c,u).catch($n)},[r]);if(i.error&&OI(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:o,mutateAsync:i.mutate}}const vc=String.raw,Ur=new Map,nv=new Map;async function xc(e,t){var n,r,i;if(console.log("Mock GraphQL Request:",{query:e.substring(0,Math.min(e.length,100))+"...",variables:t}),await new Promise(o=>setTimeout(o,500+Math.random()*1500)),e.includes("StartBusinessPlanAnalysis")){const{plan:o,userId:c}=t,u=`wf-${Date.now()}-${c}`,m={workflowId:u,status:"PENDING",result:null,error:null,userId:c,businessPlan:o};return Ur.set(u,m),setTimeout(()=>{const f=Ur.get(u);if(f){const h=Math.floor(Math.random()*15e4)+5e4,g=Math.min(95,30+o.length/500*40+Math.random()*20),v=Math.min(90,25+o.length/600*35+Math.random()*20),b=Math.max(5,100-g-v+Math.random()*10),T=o.length>300?"A comprehensive vision with significant potential. Detailed planning is evident, but strategic differentiation needs emphasis.":"An interesting concept, but the initial pitch lacks depth. Consider elaborating on your market strategy and unique selling proposition.";f.status="ANALYSIS_COMPLETE",f.result={feedback:T,questions:[{id:"q1",question:"What is your customer acquisition strategy and projected cost per acquisition?",category:"Marketing"},{id:"q2",question:"How will you differentiate from existing competitors?",category:"Competitive Landscape"},{id:"q3",question:"What are the key technical hurdles in developing your prototype?",category:"Technology"},{id:"q4",question:"Describe your projected financial milestones for the next 18 months.",category:"Finance"},{id:"q5",question:"What is your long-term vision beyond the initial product launch?",category:"Vision"}],coachingPlan:{title:"Founder's Acceleration Plan",summary:"A multi-phase plan to optimize your business model and prepare for hyper-growth.",steps:[{title:"Refine Revenue & Cost Models",description:"Develop a granular financial model projecting revenue streams, COGS, and operational expenses for the first 3 years, highlighting scalability.",timeline:"2 Weeks",category:"Finance"},{title:"Deep-Dive Competitive Strategy",description:"Conduct a SWOT analysis on your top 5 competitors, identifying their vulnerabilities and opportunities for your entry.",timeline:"1 Week",category:"Strategy"},{title:"MVP & Product Roadmap Definition",description:"Outline core features for your Minimum Viable Product, detailing user stories, tech stack, and a phased development timeline.",timeline:"3 Weeks",category:"Product"},{title:"Legal & IP Due Diligence",description:"Consult with legal experts to secure intellectual property, assess regulatory compliance, and draft initial founder agreements.",timeline:"2 Weeks",category:"Legal"},{title:"Team Scaling Blueprint",description:"Develop a hiring plan for key early hires, including role descriptions, compensation strategy, and a pipeline for talent acquisition.",timeline:"2 Weeks",category:"HR"}]},loanAmount:h,metrics:{viability:g,marketFit:v,risk:b},growthProjections:[{month:0,users:10,revenue:0},{month:3,users:100,revenue:1e3},{month:6,users:500,revenue:7500},{month:9,users:2e3,revenue:25e3},{month:12,users:5e3,revenue:75e3},{month:18,users:15e3,revenue:25e4}],potentialMentors:[{id:"m1",name:"Dr. Evelyn Reed",expertise:"Quantum Computing, AI Ethics",bio:"Pioneering work in quantum algorithm optimization.",imageUrl:"https://i.pravatar.cc/150?u=evelyn"},{id:"m2",name:"Mr. Kenji Tanaka",expertise:"Market Entry, SaaS Scale-up",bio:"Led 3 startups to successful exits in fintech.",imageUrl:"https://i.pravatar.cc/150?u=kenji"},{id:"m3",name:"Ms. Lena Petrova",expertise:"Product Design, UX/UI",bio:"Award-winning designer with 15+ years in tech.",imageUrl:"https://i.pravatar.cc/150?u=lena"}]},Ur.set(u,f)}},5e3),{startBusinessPlanAnalysis:{workflowId:u,status:"PENDING"}}}if(e.includes("GetBusinessPlanAnalysisStatus")){const o=t,c=Ur.get(o.workflowId);if(c)return{getBusinessPlanAnalysisStatus:c};throw new Error(`Workflow with ID ${o.workflowId} not found in mock state.`)}if(e.includes("ApproveBusinessPlan")){const o=t,c=Ur.get(o.workflowId);if(c)return setTimeout(()=>{c&&(c.status="APPROVED",Ur.set(o.workflowId,c))},3e3),{approveBusinessPlan:{workflowId:o.workflowId,status:"PENDING_APPROVAL"}};throw new Error("Workflow not found for approval.")}if(e.includes("RequestBusinessPlanRevision")){const o=t,c=Ur.get(o.workflowId);if(c)return c.status="REQUIRE_REVISION",c.error=`Revision Required: ${o.feedback}`,Ur.set(o.workflowId,c),{requestBusinessPlanRevision:{workflowId:o.workflowId,status:"REQUIRE_REVISION"}};throw new Error("Workflow not found for revision request.")}if(e.includes("GenerateAiContent")){const o=t;let c="AI is processing your request...";const u=o.workflowId?(n=Ur.get(o.workflowId))==null?void 0:n.businessPlan:o.context;return o.prompt.toLowerCase().includes("pro-tip")?c='Based on your plan: "Focus relentlessly on solving one critical problem for your customer better than anyone else. Everything else is a distraction until that is achieved. Authenticity is your superpower."':o.prompt.toLowerCase().includes("elevator pitch")?c=`Imagine a world where your business plan, "${u==null?void 0:u.substring(0,50)}...", is distilled into a single, irresistible sentence: "We empower [target audience] to achieve [desired outcome] through [unique solution], revolutionizing [industry] with [key differentiator]."`:o.prompt.toLowerCase().includes("brand identity")?c=`For "${u==null?void 0:u.substring(0,50)}...": Name: 'AetherFlow'. Tagline: 'Where Ideas Take Flight.' Vision: 'To seamlessly connect innovation with impact.'`:o.prompt.toLowerCase().includes("funding allocation")?c=`Strategic Allocation: +Product & R&D: 40% +Market Penetration & Sales: 30% +Operational Excellence: 15% +Strategic Reserves & Compliance: 10% +Talent Acquisition: 5%`:o.prompt.toLowerCase().includes("market trend analysis")?c="Emerging trends suggest a significant shift towards personalized, AI-driven solutions in the [relevant industry based on plan]. Competitors are slow to adapt, creating a 'blue ocean' opportunity for rapid market capture. Consumer demand for [key feature from plan] is projected to increase by 25% annually.":o.prompt.toLowerCase().includes("swot analysis")?c=`**Strengths**: Innovative core technology, passionate team. +**Weaknesses**: Limited initial market reach, reliance on early adopters. +**Opportunities**: Untapped market segments, strategic partnership potential. +**Threats**: Rapid technological shifts, incumbent resistance.`:o.prompt.toLowerCase().includes("social media strategy")?c=`**Platform Focus**: LinkedIn for B2B thought leadership, Instagram for community building. +**Content Pillars**: Educational insights, behind-the-scenes, customer success stories. +**Engagement Tactic**: Interactive Q&A sessions, influencer collaborations.`:o.prompt.toLowerCase().includes("risk mitigation")?c=`**Technology Risk**: Implement agile development, diversify tech stack expertise. +**Market Risk**: Conduct continuous market validation, pilot programs. +**Financial Risk**: Maintain lean operations, secure convertible notes.`:o.prompt.toLowerCase().includes("legal considerations")?c="Key legal considerations include: IP protection (patents/copyrights), data privacy compliance (GDPR/CCPA), founder agreements, and terms of service. Early legal counsel is crucial to avoid future pitfalls.":o.prompt.toLowerCase().includes("team roles")?c=`Critical early hires for "${u==null?void 0:u.substring(0,50)}..." include a Head of Product (visionary), Lead Engineer (builder), and a Growth Marketer (communicator). Consider a fractional CTO/CFO initially.`:o.prompt.toLowerCase().includes("user persona")&&(c=`**Name**: Innovator Anya +**Age**: 32 +**Profession**: Lead R&D Scientist +**Goals**: Find efficient tools for complex simulations, collaborate easily. +**Pain Points**: Legacy software, data silos, slow processing. +**Motivations**: Career advancement, making scientific breakthroughs.`),{generateTextWithContext:c}}if(e.includes("GenerateAIChatResponse")){const o=t,c=o.workflowId?(r=Ur.get(o.workflowId))==null?void 0:r.businessPlan:o.context;let u=`Understood. You asked: "${o.message}". How does this relate to your plan: "${c==null?void 0:c.substring(0,50)}..."?`;return o.message.toLowerCase().includes("how do i start")?u="To start, focus on validating your core hypothesis. Who is your ideal customer, and what problem are you solving for them? Build a minimal viable product (MVP) to test this rapidly.":o.message.toLowerCase().includes("funding")?u="Regarding funding, consider exploring angel investors, venture capital, or grants. Your current plan, if approved, includes seed funding, but diversify your fundraising strategy.":o.message.toLowerCase().includes("competitors")?u="Understanding your competitors is crucial. Analyze their strengths, weaknesses, and market positioning. Look for gaps they aren't filling, or ways you can deliver superior value.":o.message.toLowerCase().includes("next step")?u="Based on your current stage, I'd recommend reviewing the 'Founder's Acceleration Plan' to identify immediate actionable steps and milestones.":o.message.toLowerCase().includes("optimize my pitch")?u="To optimize your pitch, ensure it clearly articulates the problem, your unique solution, market opportunity, team, and financial projections. Practice storytelling to make it memorable.":o.message.toLowerCase().includes("scaling")&&(u="Scaling requires a robust infrastructure, efficient processes, and a talented team. Prioritize automation and build a culture of continuous improvement from day one."),{generateAIChatResponse:u}}if(e.includes("SimulateScenario")){const o=t,c=Ur.get(o.workflowId);if(!c||!((i=c.result)!=null&&i.growthProjections))throw new Error("Workflow or growth projections not found for scenario simulation.");const m=c.result.growthProjections.map(f=>{let h=f.users*(1+(o.parameters.customerAcquisitionMultiplier-1)*.5),g=f.revenue*(1+(o.parameters.conversionRateMultiplier-1)*.7);return g=g*(1-o.parameters.churnRateIncrease/100),{month:f.month,users:Math.round(h),revenue:Math.round(g*o.parameters.averageRevenuePerUserMultiplier)}});return{simulateScenario:{workflowId:o.workflowId,scenarioName:o.parameters.scenarioName||"Custom Scenario",projections:m}}}if(e.includes("GetUserProfile")){const o=t,c=nv.get(o.userId);return c?{getUserProfile:c}:{getUserProfile:{userId:o.userId,username:`User_${o.userId.substring(0,4)}`,email:`${o.userId}@example.com`,preferences:{notificationSettings:{emailEnabled:!0,smsEnabled:!0,inAppEnabled:!0}}}}}if(e.includes("UpdateUserProfile")){const o=t;let c=nv.get(o.userId)||{userId:o.userId,username:`User_${o.userId.substring(0,4)}`,email:`${o.userId}@example.com`,preferences:{notificationSettings:{emailEnabled:!0,smsEnabled:!0,inAppEnabled:!0}}};return c={...c,...o.profile,preferences:{...c.preferences,...o.profile.preferences}},nv.set(o.userId,c),{updateUserProfile:c}}if(e.includes("GetUserPlans")){const o=t;return{getUserPlans:Array.from(Ur.values()).filter(u=>u.userId===o.userId)}}throw new Error(`Unknown GraphQL query in mock: ${e.substring(0,50)}...`)}const doe=vc` + mutation StartBusinessPlanAnalysis($plan: String!, $userId: ID!) { + startBusinessPlanAnalysis(plan: $plan, userId: $userId) { + workflowId + status + } + } +`,foe=vc` + query GetBusinessPlanAnalysisStatus($workflowId: ID!) { + getBusinessPlanAnalysisStatus(workflowId: $workflowId) { + workflowId + status + result { + feedback + questions { id question category } + coachingPlan { title summary steps { title description category timeline } } + loanAmount + metrics { viability marketFit risk } + growthProjections { month users revenue } + potentialMentors { id name expertise bio imageUrl } + } + error + businessPlan + } + } +`,moe=vc` + mutation GenerateAiContent($prompt: String!, $context: String!, $workflowId: ID) { + generateTextWithContext(prompt: $prompt, context: $context, workflowId: $workflowId) + } +`,hoe=vc` + mutation GenerateAIChatResponse($message: String!, $context: String!, $workflowId: ID) { + generateAIChatResponse(message: $message, context: $context, workflowId: $workflowId) + } +`,poe=vc` + mutation SimulateScenario($workflowId: ID!, $parameters: ScenarioParametersInput!) { + simulateScenario(workflowId: $workflowId, parameters: $parameters) { + workflowId + scenarioName + projections { month users revenue } + } + } +`,goe=vc` + query GetUserPlans($userId: ID!) { + getUserPlans(userId: $userId) { + workflowId + status + businessPlan + result { + loanAmount + metrics { viability marketFit risk } + } + } + } +`,yoe=()=>{const e=z1();return tp({mutationFn:t=>xc(doe,t),onSuccess:()=>{e.invalidateQueries({queryKey:["userPlans"]})}})},voe=(e,t)=>HI({queryKey:["analysisStatus",e],queryFn:()=>xc(foe,{workflowId:e}),enabled:!!e&&!["APPROVED","FAILED","ANALYSIS_COMPLETE","REQUIRE_REVISION"].includes(t||""),refetchInterval:n=>{var i;const r=(i=n.state.data)==null?void 0:i.getBusinessPlanAnalysisStatus.status;return["PENDING","PENDING_APPROVAL"].includes(r||"")?3e3:!1},staleTime:5e3}),xoe=()=>tp({mutationFn:e=>xc(moe,e)}),boe=()=>tp({mutationFn:e=>xc(hoe,e)}),woe=()=>tp({mutationFn:e=>xc(poe,e)}),Soe=e=>HI({queryKey:["userPlans",e],queryFn:()=>xc(goe,{userId:e}),enabled:!0});S.createContext(null);const Aoe=({title:e,prompt:t,businessPlan:n,workflowId:r,children:i,className:o})=>{const{mutate:c,data:u,isPending:m,error:f}=xoe(),h=u==null?void 0:u.generateTextWithContext,g=()=>{m||c({prompt:t,context:n,workflowId:r})};return l.jsx(pe,{title:e,className:o,children:l.jsxs("div",{className:"space-y-3 min-h-[8rem] flex flex-col justify-between",children:[f&&l.jsx("p",{className:"text-red-400 text-sm text-center",children:f.message}),m&&l.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[l.jsx("div",{className:"h-2 w-2 bg-cyan-400 rounded-full animate-pulse [animation-delay:-0.3s]"}),l.jsx("div",{className:"h-2 w-2 bg-cyan-400 rounded-full animate-pulse [animation-delay:-0.15s]"}),l.jsx("div",{className:"h-2 w-2 bg-cyan-400 rounded-full animate-pulse"}),l.jsx("span",{className:"text-sm text-gray-400",children:"Generating..."})]}),!m&&h&&(i?i(h):l.jsxs("p",{className:"text-gray-300 whitespace-pre-wrap text-sm italic",children:['"',h,'"']})),!m&&!h&&!f&&l.jsx("button",{onClick:g,className:"w-full py-2 px-4 bg-cyan-600/20 hover:bg-cyan-600/40 text-cyan-200 rounded-lg text-sm font-medium transition-colors",children:`Generate ${e}`}),!m&&h&&l.jsx("button",{onClick:g,className:"mt-2 w-full py-1 px-3 bg-gray-700/50 hover:bg-gray-600/50 text-gray-400 rounded-lg text-xs font-medium transition-colors",children:"Regenerate"})]})})},Coe=({scores:e,className:t})=>{const n=({label:r,value:i,color:o,isRisk:c})=>l.jsxs("div",{children:[l.jsxs("div",{className:"flex justify-between text-xs text-gray-300",children:[l.jsx("span",{children:r}),l.jsxs("span",{children:[i.toFixed(0),c?"":"%"]})]}),l.jsx("div",{className:"w-full bg-gray-700 rounded-full h-2 mt-1",children:l.jsx("div",{className:`${o} h-2 rounded-full transition-all duration-500`,style:{width:`${c?100-i:i}%`}})})]});return l.jsx(pe,{title:"Heuristic API Scorecard",variant:"outline",className:t,children:l.jsxs("div",{className:"space-y-3",children:[l.jsx(n,{label:"Viability Score",value:e.viability,color:"bg-cyan-500"}),l.jsx(n,{label:"Market Fit",value:e.marketFit,color:"bg-indigo-500"}),l.jsx(n,{label:"Risk Index",value:e.risk,color:"bg-red-500",isRisk:!0})]})})},Toe=({projections:e,title:t="Projected Growth"})=>{const n=r=>`$${r.toLocaleString()}`;return l.jsx(pe,{title:t,children:l.jsx("div",{className:"h-64",children:l.jsx(Pn,{width:"100%",height:"100%",children:l.jsxs(ep,{data:e,margin:{top:5,right:20,left:10,bottom:5},children:[l.jsx(oi,{strokeDasharray:"3 3",stroke:"#4b5563"}),l.jsx(St,{dataKey:"month",tick:{fill:"#9ca3af",fontSize:10},label:{value:"Months",position:"insideBottom",offset:0,fill:"#9ca3af"}}),l.jsx(vt,{yAxisId:"left",tick:{fill:"#9ca3af",fontSize:10},label:{value:"Users",angle:-90,position:"insideLeft",fill:"#9ca3af"}}),l.jsx(vt,{yAxisId:"right",orientation:"right",tickFormatter:n,tick:{fill:"#9ca3af",fontSize:10},label:{value:"Revenue",angle:90,position:"insideRight",fill:"#9ca3af"}}),l.jsx(at,{contentStyle:{backgroundColor:"rgba(31, 41, 55, 0.9)",borderColor:"#4b5563",borderRadius:"8px"},itemStyle:{color:"#e5e7eb"},labelStyle:{color:"#9ca3af"},formatter:(r,i)=>i==="revenue"?n(r):r.toLocaleString()}),l.jsx(Rn,{wrapperStyle:{fontSize:"12px",color:"#9ca3af",paddingTop:"10px"}}),l.jsx(Cr,{yAxisId:"left",type:"monotone",dataKey:"users",stroke:"#06b6d4",name:"Users",strokeWidth:2,dot:{r:3},activeDot:{r:6}}),l.jsx(Cr,{yAxisId:"right",type:"monotone",dataKey:"revenue",stroke:"#6366f1",name:"Revenue",strokeWidth:2,dot:{r:3},activeDot:{r:6}})]})})})})},Eoe=({mentors:e})=>l.jsx(pe,{title:"Recommended Mentors",children:l.jsxs("div",{className:"space-y-4",children:[e.length===0&&l.jsx("p",{className:"text-gray-400 text-center",children:"No mentor suggestions at this time."}),e.map(t=>l.jsxs("div",{className:"flex items-center bg-gray-900/50 p-3 rounded-lg",children:[l.jsx("img",{src:t.imageUrl,alt:t.name,className:"w-10 h-10 rounded-full object-cover mr-3 border-2 border-cyan-500"}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-semibold text-gray-100",children:t.name}),l.jsx("p",{className:"text-xs text-cyan-400",children:t.expertise}),l.jsx("p",{className:"text-xs text-gray-400 mt-1 line-clamp-2",children:t.bio})]})]},t.id))]})}),Noe=({businessPlan:e,workflowId:t,initialMessage:n,className:r})=>{const[i,o]=S.useState(n?[{sender:"ai",text:n}]:[]),[c,u]=S.useState(""),{mutate:m,isPending:f}=boe(),h=oh.useRef(null),g=S.useCallback(()=>{if(c.trim()==="")return;const b=c.trim();o(T=>[...T,{sender:"user",text:b}]),u(""),m({message:b,context:e,workflowId:t},{onSuccess:T=>{o(C=>[...C,{sender:"ai",text:T.generateAIChatResponse}])},onError:T=>{o(C=>[...C,{sender:"ai",text:`Error: ${T.message}`}])}})},[c,e,t,m]);S.useEffect(()=>{h.current&&(h.current.scrollTop=h.current.scrollHeight)},[i]);const v=b=>{b.key==="Enter"&&!f&&(b.preventDefault(),g())};return l.jsxs(pe,{title:"Plato AI Chat",className:`flex flex-col h-full ${r}`,children:[l.jsxs("div",{ref:h,className:"flex-grow overflow-y-auto p-4 space-y-4 text-sm custom-scrollbar",children:[i.map((b,T)=>l.jsx("div",{className:`flex ${b.sender==="user"?"justify-end":"justify-start"}`,children:l.jsx("div",{className:`max-w-[75%] p-3 rounded-lg ${b.sender==="user"?"bg-cyan-700/50 text-white":"bg-gray-800 text-gray-200"}`,children:b.text})},T)),f&&l.jsx("div",{className:"flex justify-start",children:l.jsx("div",{className:"max-w-[75%] p-3 rounded-lg bg-gray-800 text-gray-400",children:l.jsxs("div",{className:"flex items-center space-x-2",children:[l.jsx("div",{className:"h-2 w-2 bg-cyan-400 rounded-full animate-pulse [animation-delay:-0.3s]"}),l.jsx("div",{className:"h-2 w-2 bg-cyan-400 rounded-full animate-pulse [animation-delay:-0.15s]"}),l.jsx("div",{className:"h-2 w-2 bg-cyan-400 rounded-full animate-pulse"}),l.jsx("span",{children:"Plato is typing..."})]})})})]}),l.jsx("div",{className:"p-4 border-t border-gray-700 mt-auto",children:l.jsxs("div",{className:"flex space-x-2",children:[l.jsx("input",{type:"text",value:c,onChange:b=>u(b.target.value),onKeyPress:v,placeholder:"Ask Plato anything...",className:"flex-grow bg-gray-700/50 border border-gray-600 rounded-lg px-4 py-2 text-white focus:outline-none focus:ring-2 focus:ring-cyan-500 text-sm",disabled:f}),l.jsx("button",{onClick:g,disabled:f||c.trim()==="",className:"py-2 px-4 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg text-sm font-medium disabled:opacity-50 disabled:cursor-not-allowed",children:"Send"})]})})]})},_oe=({workflowId:e,baseProjections:t,className:n})=>{const[r,i]=S.useState({customerAcquisitionMultiplier:1,conversionRateMultiplier:1,averageRevenuePerUserMultiplier:1,churnRateIncrease:0,scenarioName:"Optimistic"}),{mutate:o,data:c,isPending:u}=woe(),[m,f]=S.useState(t),[h,g]=S.useState("Base Case");S.useEffect(()=>{c!=null&&c.simulateScenario.projections?(f(c.simulateScenario.projections),g(c.simulateScenario.scenarioName)):(f(t),g("Base Case"))},[c,t]);const v=(C,E)=>{i(N=>({...N,[C]:typeof E=="string"?E:parseFloat(E.toFixed(2))}))},b=()=>{o({workflowId:e,parameters:r})},T=()=>{i({customerAcquisitionMultiplier:1,conversionRateMultiplier:1,averageRevenuePerUserMultiplier:1,churnRateIncrease:0,scenarioName:"Optimistic"}),f(t),g("Base Case")};return l.jsx(pe,{title:"Scenario Simulator",className:`flex flex-col ${n}`,children:l.jsxs("div",{className:"flex-grow p-4 space-y-4",children:[l.jsx("h4",{className:"text-lg font-semibold text-cyan-300 mb-2",children:"Adjust Parameters"}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[l.jsxs("div",{children:[l.jsxs("label",{className:"block text-gray-400 text-sm mb-1",children:["Acquisition Multiplier (",r.customerAcquisitionMultiplier.toFixed(2),"x)"]}),l.jsx("input",{type:"range",min:"0.5",max:"2.0",step:"0.1",value:r.customerAcquisitionMultiplier,onChange:C=>v("customerAcquisitionMultiplier",parseFloat(C.target.value)),className:"w-full h-2 rounded-lg appearance-none cursor-pointer bg-cyan-600/50 accent-cyan-500"})]}),l.jsxs("div",{children:[l.jsxs("label",{className:"block text-gray-400 text-sm mb-1",children:["Conversion Multiplier (",r.conversionRateMultiplier.toFixed(2),"x)"]}),l.jsx("input",{type:"range",min:"0.5",max:"2.0",step:"0.1",value:r.conversionRateMultiplier,onChange:C=>v("conversionRateMultiplier",parseFloat(C.target.value)),className:"w-full h-2 rounded-lg appearance-none cursor-pointer bg-indigo-600/50 accent-indigo-500"})]}),l.jsxs("div",{children:[l.jsxs("label",{className:"block text-gray-400 text-sm mb-1",children:["ARPU Multiplier (",r.averageRevenuePerUserMultiplier.toFixed(2),"x)"]}),l.jsx("input",{type:"range",min:"0.5",max:"2.0",step:"0.1",value:r.averageRevenuePerUserMultiplier,onChange:C=>v("averageRevenuePerUserMultiplier",parseFloat(C.target.value)),className:"w-full h-2 rounded-lg appearance-none cursor-pointer bg-green-600/50 accent-green-500"})]}),l.jsxs("div",{children:[l.jsxs("label",{className:"block text-gray-400 text-sm mb-1",children:["Churn Increase (+",r.churnRateIncrease,"%)"]}),l.jsx("input",{type:"range",min:"0",max:"20",step:"1",value:r.churnRateIncrease,onChange:C=>v("churnRateIncrease",parseFloat(C.target.value)),className:"w-full h-2 rounded-lg appearance-none cursor-pointer bg-red-600/50 accent-red-500"})]})]}),l.jsxs("div",{className:"flex justify-end space-x-2 mt-4",children:[l.jsx("button",{onClick:T,className:"px-3 py-1 text-xs bg-gray-700 text-gray-300 rounded hover:bg-gray-600",children:"Reset"}),l.jsx("button",{onClick:b,disabled:u,className:"px-4 py-1 text-xs bg-cyan-600 text-white rounded hover:bg-cyan-700",children:u?"Simulating...":"Run Simulation"})]}),l.jsx("div",{className:"h-48 mt-4",children:l.jsx(Pn,{width:"100%",height:"100%",children:l.jsxs(ep,{data:m,children:[l.jsx(oi,{strokeDasharray:"3 3",stroke:"#4b5563"}),l.jsx(St,{dataKey:"month",tick:{fill:"#9ca3af",fontSize:10},label:{value:"Months",position:"insideBottom",offset:-5,fill:"#9ca3af"}}),l.jsx(vt,{yAxisId:"rev",orientation:"right",tickFormatter:C=>`$${C}`,tick:{fill:"#9ca3af",fontSize:10}}),l.jsx(at,{contentStyle:{backgroundColor:"rgba(31, 41, 55, 0.9)",borderColor:"#4b5563"}}),l.jsx(Rn,{wrapperStyle:{fontSize:"10px"}}),l.jsx(Cr,{yAxisId:"rev",type:"monotone",dataKey:"revenue",stroke:"#6366f1",strokeWidth:2,dot:!1,name:`Revenue (${h})`}),l.jsx(Cr,{yAxisId:"rev",type:"monotone",dataKey:"revenue",stroke:"#4b5563",strokeWidth:1,strokeDasharray:"3 3",dot:!1,data:t,name:"Baseline Revenue"})]})})})]})})},joe=()=>{var C,E,N,I,P,M;const e="user_001",[t,n]=S.useState(""),{mutate:r,isPending:i}=yoe(),{data:o,isLoading:c}=Soe(e),[u,m]=S.useState(null),f=u||((E=(C=o==null?void 0:o.getUserPlans)==null?void 0:C[0])==null?void 0:E.workflowId),h=((I=(N=o==null?void 0:o.getUserPlans)==null?void 0:N.find(j=>j.workflowId===f))==null?void 0:I.status)||null,{data:g,isLoading:v}=voe(f||null,h),b=g==null?void 0:g.getBusinessPlanAnalysisStatus,T=()=>{t.trim()&&(r({plan:t,userId:e}),n(""))};return S.useEffect(()=>{var j;(j=o==null?void 0:o.getUserPlans)!=null&&j.length&&!u&&m(o.getUserPlans[0].workflowId)},[o,u]),l.jsxs("div",{className:"space-y-6 p-6",children:[l.jsxs("div",{className:"flex justify-between items-center",children:[l.jsx("h2",{className:"text-3xl font-bold text-white tracking-wider",children:"Quantum Weaver Incubator"}),(P=o==null?void 0:o.getUserPlans)!=null&&P.length?l.jsx("select",{value:u||"",onChange:j=>m(j.target.value),className:"bg-gray-800 border border-gray-600 text-white rounded px-3 py-1",children:o.getUserPlans.map(j=>l.jsx("option",{value:j.workflowId,children:j.businessPlan?j.businessPlan.substring(0,30)+"...":j.workflowId},j.workflowId))}):null]}),f?l.jsxs(l.Fragment,{children:[v&&l.jsx("p",{className:"text-center text-gray-400",children:"Loading analysis status..."}),(b==null?void 0:b.status)==="PENDING"&&l.jsxs("div",{className:"text-center p-10",children:[l.jsx("div",{className:"animate-spin rounded-full h-16 w-16 border-t-2 border-b-2 border-cyan-500 mx-auto mb-4"}),l.jsx("p",{className:"text-cyan-300 animate-pulse",children:"AI is analyzing your business plan..."})]}),(b==null?void 0:b.result)&&l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[l.jsxs("div",{className:"space-y-6 lg:col-span-2",children:[l.jsxs(pe,{title:"Executive Summary",children:[l.jsx("p",{className:"text-gray-300 mb-4",children:b.result.feedback}),l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsxs("div",{className:"bg-gray-800 p-3 rounded border border-gray-700",children:[l.jsx("span",{className:"text-gray-400 text-sm",children:"Estimated Seed Loan"}),l.jsxs("p",{className:"text-2xl font-bold text-green-400",children:["$",(M=b.result.loanAmount)==null?void 0:M.toLocaleString()]})]}),l.jsxs("div",{className:"bg-gray-800 p-3 rounded border border-gray-700",children:[l.jsx("span",{className:"text-gray-400 text-sm",children:"Analysis Confidence"}),l.jsx("p",{className:"text-2xl font-bold text-cyan-400",children:"High"})]})]})]}),b.result.metrics&&l.jsx(Coe,{scores:b.result.metrics}),b.result.growthProjections&&l.jsx(Toe,{projections:b.result.growthProjections}),b.result.growthProjections&&l.jsx(_oe,{workflowId:b.workflowId,baseProjections:b.result.growthProjections})]}),l.jsxs("div",{className:"space-y-6",children:[l.jsx(Aoe,{title:"Elevator Pitch Generator",prompt:"Generate a compelling 30-second elevator pitch for this business.",businessPlan:b.businessPlan,workflowId:b.workflowId}),l.jsx(Noe,{businessPlan:b.businessPlan,workflowId:b.workflowId,className:"h-[500px]"}),b.result.potentialMentors&&l.jsx(Eoe,{mentors:b.result.potentialMentors})]})]}),l.jsx("button",{onClick:()=>m(null),className:"fixed bottom-8 right-8 bg-cyan-600 hover:bg-cyan-700 text-white rounded-full p-4 shadow-lg z-50",children:"+ New Analysis"})]}):l.jsxs(pe,{title:"Start New Analysis",children:[l.jsx("textarea",{value:t,onChange:j=>n(j.target.value),placeholder:"Describe your business idea...",className:"w-full h-32 bg-gray-800 border border-gray-600 rounded-lg p-3 text-white mb-4 focus:ring-2 focus:ring-cyan-500 outline-none"}),l.jsx("button",{onClick:T,disabled:i||!t.trim(),className:"w-full py-3 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg font-bold transition-colors disabled:opacity-50",children:i?"Analyzing...":"Analyze Business Plan"})]})]})},Moe=new Xae,Poe=()=>l.jsx(Zae,{client:Moe,children:l.jsx(joe,{})}),Oj=[{id:"author-1",name:"SynthCore Labs",avatarUrl:"https://i.pravatar.cc/40?u=synthcore",profileUrl:"#",verified:!0,bio:"Pioneering AI for financial markets.",agentsPublished:5},{id:"author-2",name:"DataWeaver Inc.",avatarUrl:"https://i.pravatar.cc/40?u=dataweaver",profileUrl:"#",verified:!0,bio:"Weaving intelligence from raw data.",agentsPublished:8},{id:"author-3",name:"LogicForge AI",avatarUrl:"https://i.pravatar.cc/40?u=logicforge",profileUrl:"#",verified:!1,bio:"Crafting bespoke AI solutions for business automation.",agentsPublished:3},{id:"author-4",name:"QuantumLeap AI",avatarUrl:"https://i.pravatar.cc/40?u=quantumleap",profileUrl:"#",verified:!0,bio:"Next-generation AI for complex problem solving.",agentsPublished:12},{id:"author-5",name:"Eva Neuro",avatarUrl:"https://i.pravatar.cc/40?u=eva",profileUrl:"#",verified:!1,bio:"Independent researcher focusing on NLP agents.",agentsPublished:2}],Cx=["Finance","Marketing","Data Analysis","Customer Support","Content Creation","Code Generation","Personal Assistant"],Tx=["stocks","crypto","reporting","automation","seo","chat","email","analytics","python","api","research","summarization","forecasting"],Lj=["This agent transformed our workflow. Highly recommended!","Decent, but has a steep learning curve.","A game-changer for our marketing team. The automation capabilities are top-notch.","Could use more documentation, but the support team was helpful.","It's good for the price, but lacks some advanced features.","Incredible performance and very reliable. Has not failed us once.","I found a few bugs, but the developer is very responsive and issues fixes quickly.","The best agent in this category, hands down.","Simple, effective, and does exactly what it promises.","Overpriced for what it offers. There are better free alternatives."],Ioe=e=>{const t=[];for(let n=1;n<=e;n++){const r=Oj[n%Oj.length],i=Cx[n%Cx.length],o=new Date(Date.now()-Math.random()*30*24*60*60*1e3),c=Array.from({length:Math.floor(Math.random()*50)+5},(v,b)=>({id:`review-${n}-${b}`,author:{name:`User ${b+1}`,avatarUrl:`https://i.pravatar.cc/40?u=reviewuser${n}_${b}`},rating:Math.floor(Math.random()*3)+3,comment:Lj[Math.floor(Math.random()*Lj.length)],createdAt:new Date(o.getTime()+Math.random()*(Date.now()-o.getTime())),helpfulVotes:Math.floor(Math.random()*100)})),u=c.reduce((v,b)=>v+b.rating,0),m=c.length>0?u/c.length:0,f=["one-time","subscription","free"][n%3],h={type:f,amount:f==="free"?0:f==="one-time"?Math.floor(Math.random()*400)+99:Math.floor(Math.random()*90)+9,...f==="subscription"&&{subscriptionInterval:["monthly","yearly"][n%2]}},g=[{version:"1.2.0",releaseDate:new Date,changes:["Added new API integration.","Improved performance by 20%.","Fixed minor UI bugs."]},{version:"1.1.0",releaseDate:new Date(Date.now()-14400*60*1e3),changes:["Initial support for multi-language output.","Refactored core logic."]},{version:"1.0.0",releaseDate:new Date(Date.now()-600*60*60*1e3),changes:["Initial public release."]}];t.push({id:`agent-${n}`,name:`${i} Master Agent ${n}`,author:r,category:i,tags:[...new Set(Array.from({length:Math.floor(Math.random()*3)+2},()=>Tx[Math.floor(Math.random()*Tx.length)]))],shortDescription:`An autonomous AI agent specializing in ${i.toLowerCase()} tasks and automation.`,longDescription:`This is a comprehensive description for the ${i} Master Agent ${n}. It leverages state-of-the-art machine learning models to provide unparalleled insights and automation capabilities. Whether you're a small business or a large enterprise, this agent can be configured to meet your specific needs, streamlining workflows and boosting productivity. It features a user-friendly interface for configuration and monitoring.`,imageUrl:`https://picsum.photos/seed/agent${n}/600/400`,rating:parseFloat(m.toFixed(1)),reviewCount:c.length,reviews:c,pricing:h,specs:{version:"1.2.0",releaseDate:new Date,requiredApiVersion:"v2.1",dependencies:["Node.js v18+","Python 3.9+","Docker"],supportedLanguages:["English","Spanish","German"],computeRequirements:{cpu:"4 cores",ram:"16GB",gpu:n%3===0?"NVIDIA RTX 3080 or equivalent":void 0}},changelog:g,downloads:Math.floor(Math.random()*1e4)+500,createdAt:o,updatedAt:new Date(o.getTime()+Math.random()*(Date.now()-o.getTime())),featured:n%10===0,documentationUrl:"#",demoUrl:n%5===0?"#":void 0})}return t},VI={searchQuery:"",categories:new Set,minRating:0,maxPrice:500,pricingTypes:new Set,tags:new Set,verifiedAuthor:!1};function koe(e,t){switch(t.type){case"SET_SEARCH_QUERY":return{...e,searchQuery:t.payload};case"TOGGLE_CATEGORY":{const n=new Set(e.categories);return n.has(t.payload)?n.delete(t.payload):n.add(t.payload),{...e,categories:n}}case"SET_MIN_RATING":return{...e,minRating:t.payload};case"SET_MAX_PRICE":return{...e,maxPrice:t.payload};case"TOGGLE_PRICING_TYPE":{const n=new Set(e.pricingTypes);return n.has(t.payload)?n.delete(t.payload):n.add(t.payload),{...e,pricingTypes:n}}case"TOGGLE_TAG":{const n=new Set(e.tags);return n.has(t.payload)?n.delete(t.payload):n.add(t.payload),{...e,tags:n}}case"TOGGLE_VERIFIED_AUTHOR":return{...e,verifiedAuthor:!e.verifiedAuthor};case"RESET_FILTERS":return VI;default:return e}}const rv=({filled:e,half:t})=>l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",children:[l.jsx("defs",{children:t&&l.jsxs("linearGradient",{id:"half-gradient",children:[l.jsx("stop",{offset:"50%",stopColor:"currentColor",className:"text-yellow-400"}),l.jsx("stop",{offset:"50%",stopColor:"currentColor",className:"text-gray-600"})]})}),l.jsx("path",{d:"M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z",fill:t?"url(#half-gradient)":"currentColor",className:e?"text-yellow-400":"text-gray-600"})]}),KI=({rating:e,className:t=""})=>{const n=Math.floor(e),r=e%1>=.5,i=5-n-(r?1:0);return l.jsxs("div",{className:`flex items-center text-yellow-400 ${t}`,children:[[...Array(n)].map((o,c)=>l.jsx(rv,{filled:!0},`full-${c}`)),r&&l.jsx(rv,{half:!0}),[...Array(i)].map((o,c)=>l.jsx(rv,{},`empty-${c}`))]})},Doe=()=>l.jsx("div",{className:"flex justify-center items-center p-8",children:l.jsx("div",{className:"animate-spin rounded-full h-16 w-16 border-t-2 border-b-2 border-cyan-500"})}),Roe=({onReset:e})=>l.jsxs("div",{className:"text-center py-16 px-4 bg-gray-800 rounded-lg",children:[l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"mx-auto h-12 w-12 text-gray-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),l.jsx("h3",{className:"mt-2 text-lg font-medium text-white",children:"No Agents Found"}),l.jsx("p",{className:"mt-1 text-sm text-gray-400",children:"We couldn't find any agents matching your criteria. Try adjusting your filters."}),l.jsx("div",{className:"mt-6",children:l.jsx("button",{type:"button",onClick:e,className:"inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-cyan-600 hover:bg-cyan-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-900 focus:ring-cyan-500",children:"Reset Filters"})})]}),Ooe=({isOpen:e,onClose:t,title:n,children:r})=>e?l.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-75","aria-labelledby":"modal-title",role:"dialog","aria-modal":"true",children:[l.jsx("div",{className:"fixed inset-0",onClick:t}),l.jsxs("div",{className:"relative bg-gray-900 rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:max-w-4xl sm:w-full",children:[l.jsx("div",{className:"bg-gray-800 px-4 pt-5 pb-4 sm:p-6 sm:pb-4 border-b border-gray-700",children:l.jsxs("div",{className:"flex justify-between items-start",children:[l.jsx("h3",{className:"text-xl leading-6 font-medium text-white",id:"modal-title",children:n}),l.jsxs("button",{onClick:t,className:"text-gray-400 hover:text-white",children:[l.jsx("span",{className:"sr-only",children:"Close"}),l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]})]})}),l.jsx("div",{className:"bg-gray-900 px-4 pt-5 pb-4 sm:p-6 max-h-[80vh] overflow-y-auto",children:r})]})]}):null,Loe=(e,t)=>{const[n,r]=S.useState(1),i=Math.ceil(e.length/t),o=S.useMemo(()=>{const f=(n-1)*t,h=f+t;return e.slice(f,h)},[e,n,t]),c=()=>{r(f=>Math.min(f+1,i))},u=()=>{r(f=>Math.max(f-1,1))},m=f=>{const h=Math.max(1,f);r(Math.min(h,i))};return S.useEffect(()=>{n>i&&i>0?r(i):e.length>0&&n===0&&r(1)},[e,i,n]),{next:c,prev:u,jump:m,currentData:o,currentPage:n,maxPage:i}},Uoe=({query:e,onSearch:t})=>l.jsxs("div",{className:"relative",children:[l.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),l.jsx("input",{type:"text",value:e,onChange:n=>t(n.target.value),placeholder:"Search for agents by name, tag, or description...",className:"block w-full bg-gray-700 border border-gray-600 rounded-md py-2 pl-10 pr-3 text-sm placeholder-gray-400 text-white focus:outline-none focus:ring-1 focus:ring-cyan-500 focus:border-cyan-500"})]}),Boe=({state:e,dispatch:t})=>l.jsxs("aside",{className:"w-full lg:w-1/4 xl:w-1/5 p-4 bg-gray-800/50 rounded-lg h-full self-start sticky top-4",children:[l.jsxs("div",{className:"flex justify-between items-center mb-4",children:[l.jsx("h3",{className:"text-lg font-semibold text-white",children:"Filters"}),l.jsx("button",{onClick:()=>t({type:"RESET_FILTERS"}),className:"text-sm text-cyan-400 hover:text-cyan-300",children:"Reset"})]}),l.jsxs("div",{className:"mb-6",children:[l.jsx("h4",{className:"font-semibold text-gray-300 mb-2",children:"Category"}),Cx.map(n=>l.jsxs("div",{className:"flex items-center mb-1",children:[l.jsx("input",{id:`cat-${n}`,type:"checkbox",checked:e.categories.has(n),onChange:()=>t({type:"TOGGLE_CATEGORY",payload:n}),className:"h-4 w-4 rounded border-gray-500 text-cyan-600 bg-gray-700 focus:ring-cyan-500"}),l.jsx("label",{htmlFor:`cat-${n}`,className:"ml-2 text-sm text-gray-400",children:n})]},n))]}),l.jsxs("div",{className:"mb-6",children:[l.jsx("h4",{className:"font-semibold text-gray-300 mb-2",children:"Minimum Rating"}),l.jsxs("div",{className:"flex items-center space-x-2",children:[l.jsx("input",{type:"range",min:"0",max:"5",step:"0.5",value:e.minRating,onChange:n=>t({type:"SET_MIN_RATING",payload:parseFloat(n.target.value)}),className:"w-full"}),l.jsx("span",{className:"text-sm text-gray-300 font-mono w-8 text-center",children:e.minRating.toFixed(1)})]})]}),l.jsxs("div",{className:"mb-6",children:[l.jsx("h4",{className:"font-semibold text-gray-300 mb-2",children:"Max Price"}),l.jsxs("div",{className:"flex items-center space-x-2",children:[l.jsx("input",{type:"range",min:"0",max:"500",step:"10",value:e.maxPrice,onChange:n=>t({type:"SET_MAX_PRICE",payload:parseInt(n.target.value)}),className:"w-full"}),l.jsxs("span",{className:"text-sm text-gray-300 font-mono w-12 text-center",children:["$",e.maxPrice]})]}),l.jsx("div",{className:"mt-2 space-y-1",children:["free","one-time","subscription"].map(n=>l.jsxs("div",{className:"flex items-center",children:[l.jsx("input",{id:`price-${n}`,type:"checkbox",checked:e.pricingTypes.has(n),onChange:()=>t({type:"TOGGLE_PRICING_TYPE",payload:n}),className:"h-4 w-4 rounded border-gray-500 text-cyan-600 bg-gray-700 focus:ring-cyan-500"}),l.jsx("label",{htmlFor:`price-${n}`,className:"ml-2 text-sm text-gray-400 capitalize",children:n})]},n))})]}),l.jsxs("div",{className:"mb-6",children:[l.jsx("h4",{className:"font-semibold text-gray-300 mb-2",children:"Author"}),l.jsxs("div",{className:"flex items-center",children:[l.jsx("input",{id:"verified-author",type:"checkbox",checked:e.verifiedAuthor,onChange:()=>t({type:"TOGGLE_VERIFIED_AUTHOR"}),className:"h-4 w-4 rounded border-gray-500 text-cyan-600 bg-gray-700 focus:ring-cyan-500"}),l.jsx("label",{htmlFor:"verified-author",className:"ml-2 text-sm text-gray-400",children:"Verified Author Only"})]})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-semibold text-gray-300 mb-2",children:"Tags"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:Tx.map(n=>l.jsx("button",{onClick:()=>t({type:"TOGGLE_TAG",payload:n}),className:`px-2 py-1 text-xs rounded-full border ${e.tags.has(n)?"bg-cyan-500 border-cyan-500 text-white":"bg-gray-700 border-gray-600 text-gray-300 hover:bg-gray-600"}`,children:n},n))})]})]}),zoe=({agent:e,onSelect:t})=>l.jsxs("div",{className:"bg-gray-800 rounded-lg overflow-hidden shadow-lg hover:shadow-cyan-500/20 transition-all duration-300 ease-in-out transform hover:-translate-y-1 cursor-pointer flex flex-col",onClick:()=>t(e),children:[l.jsx("img",{className:"w-full h-40 object-cover bg-gray-700",src:e.imageUrl,alt:e.name}),l.jsxs("div",{className:"p-4 flex flex-col flex-grow",children:[l.jsxs("div",{className:"flex justify-between items-start",children:[l.jsx("p",{className:"text-sm text-cyan-400",children:e.category}),l.jsxs("div",{className:"text-lg font-bold text-green-400",children:[e.pricing.type==="free"?"Free":`$${e.pricing.amount}`,e.pricing.type==="subscription"&&l.jsxs("span",{className:"text-xs text-gray-400",children:["/",e.pricing.subscriptionInterval==="monthly"?"mo":"yr"]})]})]}),l.jsx("h3",{className:"text-lg font-semibold text-white mt-1",children:e.name}),l.jsxs("div",{className:"flex items-center mt-1",children:[l.jsx("img",{src:e.author.avatarUrl,alt:e.author.name,className:"h-6 w-6 rounded-full mr-2"}),l.jsx("span",{className:"text-sm text-gray-400",children:e.author.name}),e.author.verified&&l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 text-cyan-500 ml-1",viewBox:"0 0 20 20",fill:"currentColor",children:l.jsx("path",{fillRule:"evenodd",d:"M6.267 3.455a3.066 3.066 0 001.745-.723 3.066 3.066 0 013.976 0 3.066 3.066 0 001.745.723 3.066 3.066 0 012.812 2.812c.051.643.304 1.254.723 1.745a3.066 3.066 0 010 3.976 3.066 3.066 0 00-.723 1.745 3.066 3.066 0 01-2.812 2.812 3.066 3.066 0 00-1.745.723 3.066 3.066 0 01-3.976 0 3.066 3.066 0 00-1.745-.723 3.066 3.066 0 01-2.812-2.812 3.066 3.066 0 00-.723-1.745 3.066 3.066 0 010-3.976 3.066 3.066 0 00.723-1.745 3.066 3.066 0 012.812-2.812zm7.44-1.22a.75.75 0 00-1.06 0L8.25 6.19 6.31 4.25a.75.75 0 00-1.06 1.06l2.5 2.5a.75.75 0 001.06 0l4.5-4.5a.75.75 0 000-1.06z",clipRule:"evenodd"})})]}),l.jsx("p",{className:"text-sm text-gray-400 mt-2 flex-grow",children:e.shortDescription}),l.jsxs("div",{className:"mt-4 pt-4 border-t border-gray-700 flex justify-between items-center",children:[l.jsxs("div",{className:"flex items-center",children:[l.jsx(KI,{rating:e.rating}),l.jsxs("span",{className:"text-xs text-gray-500 ml-2",children:["(",e.reviewCount,")"]})]}),l.jsxs("div",{className:"flex items-center text-xs text-gray-500",children:[l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-1",viewBox:"0 0 20 20",fill:"currentColor",children:l.jsx("path",{d:"M8.707 7.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l2-2a1 1 0 00-1.414-1.414L11 8.586V3a1 1 0 10-2 0v5.586L8.707 7.293zM3 11a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1z"})}),e.downloads.toLocaleString()]})]})]})]}),Foe=({currentPage:e,maxPage:t,onJump:n})=>{if(t<=1)return null;const r=[];if(t<=7)for(let i=1;i<=t;i++)r.push(i);else r.push(1),e>3&&r.push("..."),e>2&&r.push(e-1),e>1&&en(e-1),disabled:e===1,className:"relative inline-flex items-center px-4 py-2 border border-gray-600 text-sm font-medium rounded-md text-gray-300 bg-gray-800 hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed",children:"Previous"}),l.jsx("div",{className:"hidden md:flex items-center mx-2",children:r.map((i,o)=>i==="..."?l.jsx("span",{className:"px-4 py-2 text-sm",children:"..."},o):l.jsx("button",{onClick:()=>n(i),className:`px-4 py-2 border border-gray-600 text-sm font-medium rounded-md mx-1 ${e===i?"bg-cyan-600 text-white":"bg-gray-800 hover:bg-gray-700"}`,children:i},o))}),l.jsx("button",{onClick:()=>n(e+1),disabled:e===t,className:"ml-3 relative inline-flex items-center px-4 py-2 border border-gray-600 text-sm font-medium rounded-md text-gray-300 bg-gray-800 hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed",children:"Next"})]})]})},qoe=({agent:e,onClose:t})=>{const[n,r]=S.useState("overview");if(!e)return null;const i=()=>{switch(n){case"specs":return l.jsxs("div",{className:"space-y-4 text-gray-300",children:[l.jsx("h4",{className:"text-lg font-semibold text-white",children:"Technical Specifications"}),l.jsxs("ul",{className:"list-disc list-inside bg-gray-800/50 p-4 rounded-md",children:[l.jsxs("li",{children:[l.jsx("strong",{children:"Version:"})," ",e.specs.version," (Released on ",e.specs.releaseDate.toLocaleDateString(),")"]}),l.jsxs("li",{children:[l.jsx("strong",{children:"Required API Version:"})," ",e.specs.requiredApiVersion]}),l.jsxs("li",{children:[l.jsx("strong",{children:"Supported Languages:"})," ",e.specs.supportedLanguages.join(", ")]})]}),l.jsx("h4",{className:"text-lg font-semibold text-white mt-4",children:"Dependencies"}),l.jsx("ul",{className:"list-disc list-inside bg-gray-800/50 p-4 rounded-md",children:e.specs.dependencies.map(c=>l.jsx("li",{children:c},c))}),l.jsx("h4",{className:"text-lg font-semibold text-white mt-4",children:"Compute Requirements"}),l.jsxs("ul",{className:"list-disc list-inside bg-gray-800/50 p-4 rounded-md",children:[l.jsxs("li",{children:[l.jsx("strong",{children:"CPU:"})," ",e.specs.computeRequirements.cpu]}),l.jsxs("li",{children:[l.jsx("strong",{children:"RAM:"})," ",e.specs.computeRequirements.ram]}),e.specs.computeRequirements.gpu&&l.jsxs("li",{children:[l.jsx("strong",{children:"GPU:"})," ",e.specs.computeRequirements.gpu]})]})]});case"reviews":return l.jsxs("div",{children:[l.jsxs("h4",{className:"text-lg font-semibold text-white mb-4",children:["User Reviews (",e.reviewCount,")"]}),l.jsx("div",{className:"space-y-6",children:e.reviews.slice(0,5).map(c=>l.jsxs("div",{className:"border-b border-gray-700 pb-4",children:[l.jsxs("div",{className:"flex items-center mb-2",children:[l.jsx("img",{src:c.author.avatarUrl,alt:c.author.name,className:"h-8 w-8 rounded-full mr-3"}),l.jsxs("div",{children:[l.jsx("p",{className:"font-semibold text-white",children:c.author.name}),l.jsx("p",{className:"text-xs text-gray-500",children:c.createdAt.toLocaleDateString()})]}),l.jsx("div",{className:"ml-auto",children:l.jsx(KI,{rating:c.rating})})]}),l.jsx("p",{className:"text-gray-400",children:c.comment}),l.jsxs("p",{className:"text-xs text-gray-500 mt-2",children:[c.helpfulVotes," people found this helpful."]})]},c.id))})]});case"changelog":return l.jsxs("div",{children:[l.jsx("h4",{className:"text-lg font-semibold text-white mb-4",children:"Version History"}),l.jsx("div",{className:"space-y-6",children:e.changelog.map(c=>l.jsxs("div",{children:[l.jsxs("h5",{className:"font-semibold text-gray-200",children:["Version ",c.version," ",l.jsxs("span",{className:"text-sm font-normal text-gray-500",children:["- ",c.releaseDate.toLocaleDateString()]})]}),l.jsx("ul",{className:"list-disc list-inside text-gray-400 mt-2 pl-4",children:c.changes.map((u,m)=>l.jsx("li",{children:u},m))})]},c.version))})]});case"overview":default:return l.jsx("p",{className:"text-gray-300 whitespace-pre-wrap",children:e.longDescription})}},o=[{id:"overview",label:"Overview"},{id:"specs",label:"Specifications"},{id:"reviews",label:`Reviews (${e.reviewCount})`},{id:"changelog",label:"Changelog"}];return l.jsx(Ooe,{isOpen:!!e,onClose:t,title:e.name,children:l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[l.jsxs("div",{className:"md:col-span-2",children:[l.jsx("img",{src:e.imageUrl,alt:e.name,className:"w-full h-64 object-cover rounded-lg bg-gray-700 mb-4"}),l.jsx("div",{className:"border-b border-gray-700 mb-4",children:l.jsx("nav",{className:"-mb-px flex space-x-8","aria-label":"Tabs",children:o.map(c=>l.jsx("button",{onClick:()=>r(c.id),className:`${n===c.id?"border-cyan-500 text-cyan-400":"border-transparent text-gray-400 hover:text-gray-200 hover:border-gray-500"} whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm`,children:c.label},c.id))})}),l.jsx("div",{children:i()})]}),l.jsxs("div",{className:"md:col-span-1 space-y-4",children:[l.jsxs("div",{className:"bg-gray-800 p-4 rounded-lg",children:[l.jsxs("div",{className:"text-3xl font-bold text-green-400 mb-4",children:[e.pricing.type==="free"?"Free":`$${e.pricing.amount}`,e.pricing.type==="subscription"&&l.jsxs("span",{className:"text-base text-gray-400",children:["/",e.pricing.subscriptionInterval==="monthly"?"mo":"yr"]})]}),l.jsx("button",{className:"w-full bg-cyan-600 text-white font-bold py-2 px-4 rounded hover:bg-cyan-700 transition duration-300",children:e.pricing.type==="free"?"Download":"Purchase Agent"})]}),l.jsxs("div",{className:"bg-gray-800 p-4 rounded-lg text-sm text-gray-300 space-y-2",children:[l.jsxs("div",{className:"flex justify-between",children:[l.jsx("span",{children:"Version:"})," ",l.jsx("span",{className:"font-mono",children:e.specs.version})]}),l.jsxs("div",{className:"flex justify-between",children:[l.jsx("span",{children:"Updated:"})," ",l.jsx("span",{children:e.updatedAt.toLocaleDateString()})]}),l.jsxs("div",{className:"flex justify-between",children:[l.jsx("span",{children:"Category:"})," ",l.jsx("span",{className:"text-cyan-400",children:e.category})]}),l.jsxs("div",{className:"flex justify-between",children:[l.jsx("span",{children:"Downloads:"})," ",l.jsx("span",{children:e.downloads.toLocaleString()})]})]}),l.jsxs("div",{className:"bg-gray-800 p-4 rounded-lg",children:[l.jsx("h4",{className:"font-semibold text-white mb-2",children:"Author"}),l.jsxs("div",{className:"flex items-center",children:[l.jsx("img",{src:e.author.avatarUrl,alt:e.author.name,className:"h-10 w-10 rounded-full mr-3"}),l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center",children:[l.jsx("p",{className:"font-semibold text-white",children:e.author.name}),e.author.verified&&l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 text-cyan-500 ml-1",viewBox:"0 0 20 20",fill:"currentColor",children:l.jsx("path",{fillRule:"evenodd",d:"M6.267 3.455a3.066 3.066 0 001.745-.723 3.066 3.066 0 013.976 0 3.066 3.066 0 001.745.723 3.066 3.066 0 012.812 2.812c.051.643.304 1.254.723 1.745a3.066 3.066 0 010 3.976 3.066 3.066 0 00-.723 1.745 3.066 3.066 0 01-2.812 2.812 3.066 3.066 0 00-1.745.723 3.066 3.066 0 01-3.976 0 3.066 3.066 0 00-1.745-.723 3.066 3.066 0 01-2.812-2.812 3.066 3.066 0 00-.723-1.745 3.066 3.066 0 010-3.976 3.066 3.066 0 00.723-1.745 3.066 3.066 0 012.812-2.812zm7.44-1.22a.75.75 0 00-1.06 0L8.25 6.19 6.31 4.25a.75.75 0 00-1.06 1.06l2.5 2.5a.75.75 0 001.06 0l4.5-4.5a.75.75 0 000-1.06z",clipRule:"evenodd"})})]}),l.jsx("a",{href:e.author.profileUrl,className:"text-xs text-cyan-400 hover:underline",children:"View Profile"})]})]}),l.jsx("p",{className:"text-xs text-gray-400 mt-2",children:e.author.bio})]}),l.jsxs("div",{className:"bg-gray-800 p-4 rounded-lg",children:[l.jsx("h4",{className:"font-semibold text-white mb-2",children:"Tags"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:e.tags.map(c=>l.jsx("span",{className:"px-2 py-1 bg-gray-700 text-xs text-gray-300 rounded-full",children:c},c))})]})]})]})})},Goe=()=>{const[e,t]=S.useState([]),[n,r]=S.useState(!0),[i,o]=S.useState(null),[c,u]=S.useState(null),[m,f]=S.useReducer(koe,VI),[h,g]=S.useState("featured");S.useEffect(()=>{r(!0),o(null);const P=setTimeout(()=>{try{const M=Ioe(150);t(M)}catch(M){o("Failed to load agent data."),console.error(M)}finally{r(!1)}},1500);return()=>clearTimeout(P)},[]);const v=S.useMemo(()=>{let P=e.filter(M=>{const j=m.searchQuery.toLowerCase(),k=M.name.toLowerCase().includes(j),R=M.shortDescription.toLowerCase().includes(j),F=M.tags.some(me=>me.toLowerCase().includes(j)),q=m.categories.size===0||m.categories.has(M.category),G=M.rating>=m.minRating,H=M.pricing.type==="free"&&m.maxPrice>=0||M.pricing.type!=="free"&&M.pricing.amount<=m.maxPrice,V=m.pricingTypes.size===0||m.pricingTypes.has(M.pricing.type),oe=m.tags.size===0||M.tags.some(me=>m.tags.has(me)),Z=!m.verifiedAuthor||M.author.verified;return(k||R||F)&&q&&G&&H&&V&&oe&&Z});switch(h){case"featured":P.sort((M,j)=>(j.featured?1:0)-(M.featured?1:0)||j.rating-M.rating);break;case"rating":P.sort((M,j)=>j.rating-M.rating);break;case"newest":P.sort((M,j)=>j.createdAt.getTime()-M.createdAt.getTime());break;case"downloads":P.sort((M,j)=>j.downloads-M.downloads);break}return P},[e,m,h]),{currentData:b,currentPage:T,maxPage:C,jump:E}=Loe(v,12),N=S.useCallback(P=>{f({type:"SET_SEARCH_QUERY",payload:P}),E(1)},[E]),I=S.useCallback(()=>{f({type:"RESET_FILTERS"}),E(1)},[E]);return l.jsxs("div",{className:"space-y-6",children:[l.jsxs(pe,{title:"AI Agent Marketplace",padding:"none",children:[l.jsxs("div",{className:"p-6 border-b border-gray-700",children:[l.jsx("p",{className:"text-gray-400 mb-4",children:"Discover, purchase, and deploy autonomous AI agents for various financial and business tasks."}),l.jsx(Uoe,{query:m.searchQuery,onSearch:N})]}),l.jsxs("div",{className:"flex flex-col lg:flex-row",children:[l.jsx(Boe,{state:m,dispatch:f}),l.jsxs("main",{className:"w-full lg:w-3/4 xl:w-4/5 p-4",children:[l.jsxs("div",{className:"flex justify-between items-center mb-4 flex-wrap gap-4",children:[l.jsxs("p",{className:"text-gray-400",children:["Showing ",v.length," agents"]}),l.jsxs("div",{className:"flex items-center space-x-2",children:[l.jsx("span",{className:"text-sm text-gray-300",children:"Sort by:"}),l.jsxs("select",{value:h,onChange:P=>g(P.target.value),className:"bg-gray-700 border border-gray-600 rounded-md py-1 px-2 text-sm text-white focus:outline-none focus:ring-1 focus:ring-cyan-500 focus:border-cyan-500",children:[l.jsx("option",{value:"featured",children:"Featured"}),l.jsx("option",{value:"rating",children:"Highest Rated"}),l.jsx("option",{value:"newest",children:"Newest"}),l.jsx("option",{value:"downloads",children:"Most Popular"})]})]})]}),n?l.jsx(Doe,{}):i?l.jsx("div",{className:"text-center text-red-400 bg-red-900/50 p-4 rounded-lg",children:i}):b.length>0?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-6",children:b.map(P=>l.jsx(zoe,{agent:P,onSelect:u},P.id))}),l.jsx(Foe,{currentPage:T,maxPage:C,onJump:E})]}):l.jsx(Roe,{onReset:I})]})]})]}),l.jsx(qoe,{agent:c,onClose:()=>u(null)})]})},$oe=e=>{const t={};return e.forEach(n=>{const r=new Date(n.date).toISOString().split("T")[0];t[r]||(t[r]={volume:0,amount:0}),t[r].volume+=1,t[r].amount+=n.amount}),Object.entries(t).map(([n,r])=>({date:n,...r})).sort((n,r)=>new Date(n.date).getTime()-new Date(r.date).getTime())},Hoe=e=>{const t={};return e.forEach(n=>{const r=new Date(n.date).toISOString().substring(0,7),i=n.merchant.includes("Steakhouse")||n.merchant.includes("Lunch")||n.description.includes("Travel")?"T_E":n.merchant.includes("Cloud")||n.merchant.includes("Software")||n.description.includes("Software License")?"Software":n.merchant.includes("Marketing")||n.description.includes("Ad")?"Marketing":n.merchant.includes("Rent")||n.merchant.includes("Utilities")?"Facilities":n.description.includes("Payroll")||n.description.includes("Salaries")?"Salaries":"Other";t[r]||(t[r]={T_E:0,Software:0,Marketing:0,Facilities:0,Salaries:0,Other:0}),t[r][i]=(t[r][i]||0)+n.amount}),Object.entries(t).map(([n,r])=>({month:n,...r})).sort((n,r)=>n.month.localeCompare(r.month))},Voe=e=>{const t=new Date,n={"0-30 Days":{count:0,amount:0},"31-60 Days":{count:0,amount:0},"61-90 Days":{count:0,amount:0},"90+ Days":{count:0,amount:0}};return e.filter(r=>r.status==="overdue"||r.status==="pending").forEach(r=>{const i=new Date(r.dueDate),o=t.getTime()-i.getTime(),c=Math.floor(o/(1e3*60*60*24));c<=30?(n["0-30 Days"].count++,n["0-30 Days"].amount+=r.amount):c<=60?(n["31-60 Days"].count++,n["31-60 Days"].amount+=r.amount):c<=90?(n["61-90 Days"].count++,n["61-90 Days"].amount+=r.amount):(n["90+ Days"].count++,n["90+ Days"].amount+=r.amount)}),Object.entries(n).map(([r,i])=>({bucket:r,...i}))},Koe=e=>{let t=0,n=0,r=0;const i=48,o=new Date;o.setDate(o.getDate()-30);let c=0;return e.forEach(u=>{if(u.status==="approved"&&u.requestDate&&u.approvalDate){const m=new Date(u.requestDate).getTime(),h=(new Date(u.approvalDate).getTime()-m)/(1e3*60*60);t+=h,n++,h>i&&r++}u.requestDate&&new Date(u.requestDate)>=o&&c++}),{avgTimeHours:n>0?t/n:0,overThresholdCount:r,throughputLast30Days:c}},Yoe=e=>{let t=0,n=0,r=0,i=0;const o=30;return e.forEach(c=>{if(c.status==="closed"&&c.openDate&&c.closeDate){const u=new Date(c.openDate).getTime(),f=(new Date(c.closeDate).getTime()-u)/(1e3*60*60*24);t+=f,n++,f>o&&r++}c.priority==="high"&&c.status==="open"&&i++}),{avgTimeDays:n>0?t/n:0,overThresholdCount:r,criticalCases:i}},Woe=e=>{const t={};return e.forEach(n=>{const r=n.merchant;t[r]=(t[r]||0)+n.amount}),Object.entries(t).map(([n,r])=>({vendor:n,amount:r})).sort((n,r)=>r.amount-n.amount)},F1=e=>{const t={IT:15e4,Marketing:1e5,Operations:2e5,HR:75e3,Finance:5e4,"R&D":12e4,Facilities:8e4,Salaries:3e5,Legal:2e4,Other:5e4},n={};return e.forEach(r=>{let i="Other";r.merchant.includes("Cloud")||r.merchant.includes("Software")||r.merchant.includes("Hardware")?i="IT":r.merchant.includes("Marketing")||r.description.includes("Ad Campaign")?i="Marketing":r.merchant.includes("Logistics")||r.description.includes("Supplies")||r.description.includes("Office Equipment")?i="Operations":r.merchant.includes("Recruitment")||r.description.includes("Training")||r.description.includes("Payroll")?i="HR":r.description.includes("Audit")||r.description.includes("Accounting")?i="Finance":r.description.includes("Research")||r.description.includes("Development")?i="R&D":r.merchant.includes("Rent")||r.merchant.includes("Utilities")||r.merchant.includes("Maintenance")?i="Facilities":r.description.includes("Legal Fees")||r.merchant.includes("Law Firm")?i="Legal":r.description.includes("Salaries")&&(i="Salaries"),n[i]=(n[i]||0)+r.amount}),Object.entries(t).map(([r,i])=>{const o=n[r]||0,c=o-i,u=i>0?c/i*100:0;return{department:r,actualSpend:o,budget:i,variance:c,variancePct:u}})},Joe=e=>{const t={};return e.forEach(n=>{const r=n.paymentMethod||"Bank Transfer";t[r]||(t[r]={count:0,totalAmount:0}),t[r].count++,t[r].totalAmount+=n.amount}),Object.entries(t).map(([n,r])=>({method:n,...r}))},Qoe=(e,t=5)=>{const n={};return e.forEach(r=>{n[r.description]=(n[r.description]||0)+r.amount}),Object.entries(n).map(([r,i])=>({vendor:r,amount:i})).sort((r,i)=>i.amount-r.amount).slice(0,t)},Xoe=(e,t)=>{const n={};return e.forEach(r=>{const i=new Date(r.date).toISOString().substring(0,7);n[i]||(n[i]={inflow:0,outflow:0}),n[i].outflow+=r.amount}),t.filter(r=>r.status==="paid").forEach(r=>{const o=(r.paymentDate?new Date(r.paymentDate):new Date(r.issueDate)).toISOString().substring(0,7);n[o]||(n[o]={inflow:0,outflow:0}),n[o].inflow+=r.amount}),Object.entries(n).map(([r,i])=>({period:r,inflow:i.inflow,outflow:i.outflow,netCashFlow:i.inflow-i.outflow})).sort((r,i)=>r.period.localeCompare(i.period))},Zoe=e=>{let t=0,n=0;return e.forEach(r=>{r.merchant.includes("Rent")||r.description.includes("Subscription Fee")||r.description.includes("Insurance Premium")?t+=r.amount:(r.merchant.includes("Supplies")||r.merchant.includes("Travel")||r.description.includes("Consulting Fees")||r.description.includes("Marketing Campaign"),n+=r.amount)}),[{type:"Fixed",amount:t},{type:"Variable",amount:n}]},ese=e=>{const t={},n=["North America","Europe","Asia","South America","Africa","Oceania"];return e.forEach(r=>{const i=n[Math.floor(Math.random()*n.length)];t[i]=(t[i]||0)+r.amount}),Object.entries(t).map(([r,i])=>({region:r,amount:i}))},tse=e=>{const t=e.filter(i=>i.status==="paid"&&i.paymentDate&&i.issueDate);if(t.length===0)return 0;let n=0,r=0;return t.forEach(i=>{const o=new Date(i.issueDate).getTime(),u=(new Date(i.paymentDate).getTime()-o)/(1e3*60*60*24);n+=u*i.amount,r+=i.amount}),r>0?n/r:0},nse=e=>{const t=e.filter(i=>i.status==="paid"&&i.paymentDate&&i.requestDate);if(t.length===0)return 0;let n=0,r=0;return t.forEach(i=>{const o=new Date(i.requestDate).getTime(),u=(new Date(i.paymentDate).getTime()-o)/(1e3*60*60*24);n+=u*i.amount,r+=i.amount}),r>0?n/r:0},rse=(e,t)=>{const n=e.filter(i=>i.status!=="paid").reduce((i,o)=>i+o.amount,0),r=t.filter(i=>i.status==="needs_approval"||i.status==="pending").reduce((i,o)=>i+o.amount,0);return r===0?1/0:n/r},ise=(e,t)=>{const r=e.filter(o=>o.status!=="paid").reduce((o,c)=>o+c.amount,0),i=t.filter(o=>o.status==="needs_approval"||o.status==="pending").reduce((o,c)=>o+c.amount,0);return i===0?1/0:r/i},ase=(e,t)=>{let n=0;const r=new Set;let i=0,o=0,c=0;return e.forEach(u=>{(u.amount>15e3||u.merchant.includes("DarkWeb")||u.amount<50&&Math.random()<.1)&&(n++,r.add(u.merchant),i++),Math.random()<.05&&(c++,o+=u.amount)}),t.forEach(u=>{(u.severity==="high"||u.description.includes("fraud"))&&(i++,u.relatedEntity&&r.add(u.relatedEntity))}),{highRiskTxnCount:n,flaggedVendors:r.size,totalFlags:i,foreignCurrencySpend:o,foreignCurrencyTxns:c}},ose=(e,t)=>{const n=e.filter(E=>E.status==="paid").reduce((E,N)=>E+N.amount,0);t.reduce((E,N)=>E+N.amount,0);const r=n*(.4+Math.random()*.1),i=n-r,o=n>0?i/n*100:0,c=n*(.2+Math.random()*.05),u=i-c,m=n>0?u/n*100:0,f=Math.random()*20+5,h=Math.random()*60+30,g=5e6+Math.random()*1e6,v=g*(.6+Math.random()*.1),b=g-v,T=g>0?v/g*100:0,C=v>0?b/v:1/0;return{grossProfitMargin:o,netProfitMargin:m,roi:f,cashConversionCycle:h,equityRatio:T,debtToEquityRatio:C}},sse=e=>{const t=F1(e),n=t.reduce((i,o)=>i+o.budget,0),r=t.reduce((i,o)=>i+o.variance,0);return{totalBudgetAllocated:n,budgetVarianceTotal:r}},lse=e=>{let t=0,n=0,r=0,i=0,o=0,c=0,u=0,m=0,f=0,h=0,g=0;return e.forEach(v=>{v.merchant.includes("Software")||v.merchant.includes("Cloud")?t+=v.amount:v.merchant.includes("Power")||v.merchant.includes("Water")||v.merchant.includes("Gas")||v.description.includes("Utility")?n+=v.amount:v.merchant.includes("Marketing")||v.description.includes("Ad Campaign")?r+=v.amount:v.description.includes("Research")||v.description.includes("Development")?i+=v.amount:v.description.includes("Reimbursement")||v.description.includes("Employee Expense")?o+=v.amount:v.description.includes("Server")||v.description.includes("Network")||v.merchant.includes("Hardware")?c+=v.amount:v.description.includes("Legal Fees")||v.merchant.includes("Law Firm")?u+=v.amount:v.description.includes("Consulting")?m+=v.amount:v.description.includes("Office Supplies")||v.merchant.includes("Staples")?f+=v.amount:v.description.includes("Flight")||v.description.includes("Hotel")||v.description.includes("Business Trip")?h+=v.amount:(v.description.includes("Dinner")||v.description.includes("Event"))&&(g+=v.amount)}),{saasSpend:t,utilitiesSpend:n,marketingSpend:r,rdSpend:i,employeeReimbursementSpend:o,itInfrastructureSpend:c,legalFees:u,consultingFees:m,officeSuppliesSpend:f,travelSpend:h,entertainmentSpend:g}},cse=e=>{let t=0,n=0,r=0,i=0,o=0,c=0,u=0;e.forEach(f=>{Math.random()<.02&&(t+=f.amount*(.1+Math.random()*.5)),Math.random()<.05&&(n+=f.amount*(.01+Math.random()*.1)),f.amount>5e3&&r++,f.amount<100&&i++,Math.random()<.6?o++:c++,u+=f.amount});const m=e.length>0?u/e.length:0;return{totalRefunds:t,totalDiscounts:n,largeTransactions:r,smallTransactions:i,cardTxns:o,bankTransferTxns:c,avgTxnAmount:m}},use=e=>{const t=new Set;return e.forEach(n=>t.add(n.type)),t.has("AML")||t.add("AML"),t.has("GDPR")||t.add("GDPR"),t.has("Sanctions")||t.add("Sanctions"),t.has("Data Privacy")||t.add("Data Privacy"),t.has("Financial Reporting")||t.add("Financial Reporting"),Array.from(t).slice(0,3)},dse=e=>{const t=e.filter(r=>r.status==="approved").length,n=.6+Math.random()*.2;return t>0?t*n:0},fse=(e,t)=>{const n=e.filter(T=>T.status==="paid").reduce((T,C)=>T+C.amount,0),r=t.reduce((T,C)=>T+C.amount,0),i=.2,o=.08,c=.25,u=n*i,m=r*i*.7,f=u-m,h=r*(.3+Math.random()*.1),g=h*o,v=n-r-h,b=v>0?v*c:0;return{vatEstimate:Math.max(0,f),payrollTaxEstimate:g,corporateTaxEstimate:b}},mse=e=>F1(e).map(n=>({department:n.department,budget:n.budget,actualSpend:n.actualSpend,variance:n.variance})),hse=()=>{const e=[],t=new Date;for(let n=6;n>=0;n--){const r=new Date(t);r.setDate(t.getDate()-n),e.push({date:r.toISOString().split("T")[0],failedLogins:Math.floor(Math.random()*10)+1,suspiciousActivities:Math.floor(Math.random()*5),dataAccessViolations:Math.floor(Math.random()*3)})}return e},pse=e=>{const t={},n={};let r=0,i=0;e.forEach(u=>{let m="Other";if(u.description.includes("Travel")||u.merchant.includes("Airline")||u.merchant.includes("Hotel")?m="Travel":u.description.includes("Meal")||u.merchant.includes("Restaurant")||u.description.includes("Entertainment")?m="Meals & Entertainment":u.description.includes("Office Supply")||u.merchant.includes("Staples")||u.merchant.includes("Amazon")?m="Office Supplies":u.description.includes("Software License")||u.merchant.includes("Subscription")||u.merchant.includes("Cloud")?m="Software & Subscriptions":u.description.includes("Training")||u.merchant.includes("Course")||u.description.includes("Certification")?m="Professional Development":u.description.includes("Home Office")?m="Home Office Setup":(u.description.includes("Commute")||u.merchant.includes("Transit"))&&(m="Commuting"),["Travel","Meals & Entertainment","Office Supplies","Software & Subscriptions","Professional Development","Home Office Setup","Commuting"].includes(m)){t[m]=(t[m]||0)+u.amount,r+=u.amount,i++;const f=new Date(u.date).toISOString().substring(0,7);n[f]=(n[f]||0)+u.amount}});const o=Object.entries(t).map(([u,m])=>({category:u,amount:m})).sort((u,m)=>m.amount-u.amount).slice(0,5),c=Object.entries(n).map(([u,m])=>({month:u,amount:m})).sort((u,m)=>u.month.localeCompare(m.month));return{totalExpenses:r,averageExpense:i>0?r/i:0,topCategories:o,monthlyTrend:c}},gse=()=>{const e=500+Math.floor(Math.random()*200),t=Math.floor(e*(.05+Math.random()*.05)),n=Math.floor(e*(.01+Math.random()*.03)),r=Math.floor(e*(.3+Math.random()*.1));return{totalContracts:e,expiringSoon:t,nonCompliant:n,autoRenewals:r}},yse=({setActiveView:e})=>{const t=S.useContext(Ct),[n,r]=S.useState(""),[i,o]=S.useState(!1);if(!t)throw new Error("CorporateCommandView must be within a DataProvider.");const{paymentOrders:c,invoices:u,complianceCases:m,corporateTransactions:f}=t,h={pendingApprovals:c.filter(O=>O.status==="needs_approval").length,overdueInvoices:u.filter(O=>O.status==="overdue").length,openCases:m.filter(O=>O.status==="open").length,totalOutflow:f.reduce((O,Ue)=>O+Ue.amount,0)},g=f.reduce((O,Ue)=>{const sn=Ue.merchant.includes("Steakhouse")||Ue.merchant.includes("Lunch")?"T&E":Ue.merchant.includes("Cloud")||Ue.merchant.includes("Software")?"Software":"Other";return O[sn]||(O[sn]=0),O[sn]+=Ue.amount,O},{}),v=Object.entries(g).map(([O,Ue])=>({name:O,value:Ue})),b=u.filter(O=>O.status==="paid").reduce((O,Ue)=>O+Ue.amount,0),T=u.length>0?u.reduce((O,Ue)=>O+Ue.amount,0)/u.length:0,{grossProfitMargin:C,netProfitMargin:E,cashConversionCycle:N,equityRatio:I,debtToEquityRatio:P}=ose(u,f),M=tse(u),j=nse(c),k=rse(u,c),R=ise(u,c),{vatEstimate:F,payrollTaxEstimate:q,corporateTaxEstimate:G}=fse(u,f),H=c.length,V=u.length;u.filter(O=>O.status==="overdue").reduce((O,Ue)=>O+Ue.amount,0),m.filter(O=>O.status==="open").reduce((O,Ue)=>O+(Ue.potentialFine||0),0);const{totalBudgetAllocated:oe,budgetVarianceTotal:Z}=sse(f),{avgTimeHours:me,throughputLast30Days:z}=Koe(c),Y=c.filter(O=>O.amount>1e4).length,ce=c.filter(O=>O.status==="paid"),ge=ce.length>0?ce.filter(O=>O.dueDate&&O.paymentDate&&new Date(O.paymentDate)<=new Date(O.dueDate)).length/ce.length*100:0,{saasSpend:Me,utilitiesSpend:U,marketingSpend:te,rdSpend:ue,employeeReimbursementSpend:fe,itInfrastructureSpend:Ne,legalFees:Pe,consultingFees:Re,officeSuppliesSpend:wt,travelSpend:re,entertainmentSpend:Le}=lse(f),{totalRefunds:Fe,totalDiscounts:de,largeTransactions:$t,smallTransactions:$e,cardTxns:Ht,bankTransferTxns:Vt,avgTxnAmount:cr}=cse(f),Er=new Set(c.map(O=>O.paymentMethod)).size,Po=new Set(f.map(O=>O.merchant)).size,Jr=pse(f),Io=m.reduce((O,Ue)=>O+(Ue.potentialFine||0),0),{avgTimeDays:ki,criticalCases:Us}=Yoe(m),{highRiskTxnCount:Kt,flaggedVendors:ko,foreignCurrencySpend:Bs,foreignCurrencyTxns:zs}=ase(f,m),ci=use(m),bc=c.filter(O=>O.status==="approved").length,ja=bc>0?dse(c)/bc*100:0,Do=hse(),ur=gse(),Qr=Do.reduce((O,Ue)=>O+Ue.failedLogins,0),Qt=Do.reduce((O,Ue)=>O+Ue.suspiciousActivities,0),Sn=Do.reduce((O,Ue)=>O+Ue.dataAccessViolations,0),An=$oe(f),Fs=Hoe(f),wc=Voe(u),Sc=Woe(f).slice(0,7),ui=F1(f),Di=Joe(c),di=Qoe(f,7),Nr=Xoe(f,u),Ma=Zoe(f),fi=ese(f),Ac=mse(f),Ro=Jr.topCategories;S.useEffect(()=>{(async()=>{o(!0);try{const Ue=new ar({apiKey:"PLACEHOLDER_API_KEY"}),zn=`You are a corporate finance AI controller. Based on the following summary, provide a single, concise (1-2 sentences) strategic recommendation or observation for the finance manager. Focus on key actionable insights. Summary: +${` + Pending Approvals: ${h.pendingApprovals}, Overdue Invoices: ${h.overdueInvoices}, Open Compliance Cases: ${h.openCases}. + Total Outflow: $${h.totalOutflow.toFixed(2)}, Total Inflow: $${b.toFixed(2)}. + Avg. Invoice Value: $${T.toFixed(2)}, DSO: ${M.toFixed(1)} days, DPO: ${j.toFixed(1)} days. + Current Ratio: ${k.toFixed(2)}, Quick Ratio: ${R.toFixed(2)}. + Avg. Approval Time: ${me.toFixed(1)} hrs, Avg. Case Resolution: ${ki.toFixed(1)} days. + High Risk Transactions: ${Kt}, Flagged Vendors: ${ko}. + Recent spending is focused on: ${v.map(dr=>dr.name).join(", ")}. + Top expenses include: ${di.map(dr=>dr.vendor).join(", ")}. + Departments with significant variance: ${ui.filter(dr=>Math.abs(dr.variancePct)>10).map(dr=>`${dr.department} (${dr.variancePct.toFixed(0)}%)`).join(", ")}. + Compliance risks: ${ci.join(", ")}. + Audit Failed Logins (7d): ${Qr}, Suspicious Activities (7d): ${Qt}. + Expiring Contracts: ${ur.expiringSoon}, Non-Compliant Contracts: ${ur.nonCompliant}. + Automated Approvals: ${ja.toFixed(1)}%. + `}`,Ri=await Ue.models.generateContent({model:"gemini-2.5-flash",contents:zn});r(Ri.text)}catch(Ue){console.error("Failed to generate corporate insight:",Ue),r("An error occurred while analyzing corporate data. Please check API key or network.")}finally{o(!1)}})()},[h.pendingApprovals,h.overdueInvoices,h.openCases,h.totalOutflow,b,T,M,j,k,R,me,ki,Kt,ko,v,di,ui,ci,Qr,Qt,ur.expiringSoon,ur.nonCompliant,ja]);const Ae=({title:O,value:Ue,view:sn,formatter:zn,className:Ri})=>l.jsxs(pe,{variant:sn?"interactive":"default",onClick:sn?()=>e(sn):void 0,className:`text-center ${Ri||""}`,children:[l.jsx("p",{className:"text-3xl font-bold text-white",children:zn?zn(Ue):Ue}),l.jsx("p",{className:"text-sm text-gray-400 mt-1",children:O})]}),Bt=({title:O,children:Ue,className:sn})=>l.jsx(pe,{title:O,className:`p-4 ${sn||""}`,children:l.jsxs("div",{className:"h-56 w-full",children:[" ",l.jsx(Pn,{width:"100%",height:"100%",children:Ue})]})}),qs=["#0088FE","#00C49F","#FFBB28","#FF8042","#AF19FF","#FF0000","#00FFFF"];return l.jsxs("div",{className:"space-y-8",children:[l.jsx("h2",{className:"text-4xl font-extrabold text-white tracking-wider",children:"Corporate Command Center"}),l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[l.jsx(pe,{title:"AI Strategic Insight",className:"lg:col-span-1 bg-gray-800 border border-gray-700",children:i?l.jsx("p",{className:"text-gray-400 text-sm animate-pulse",children:"Analyzing real-time data for strategic insights..."}):l.jsxs("p",{className:"text-gray-200 text-base italic leading-relaxed",children:['"',n,'"']})}),l.jsx(Bt,{title:"Spending by Major Category",className:"lg:col-span-2",children:l.jsxs(jn,{data:Object.entries(Fs.reduce((O,Ue)=>(Object.entries(Ue).forEach(([sn,zn])=>{sn!=="month"&&(O[sn]=(O[sn]||0)+zn)}),O),{})).map(([O,Ue])=>({name:O,value:Ue})),layout:"vertical",margin:{top:5,right:20,left:10,bottom:5},children:[l.jsx(St,{type:"number",hide:!0}),l.jsx(vt,{type:"category",dataKey:"name",stroke:"#9ca3af",fontSize:12,width:90}),l.jsx(at,{contentStyle:{backgroundColor:"rgba(31, 41, 55, 0.8)",borderColor:"#4b5563"},formatter:O=>`$${O.toFixed(2)}`}),l.jsx(it,{dataKey:"value",fill:"#06b6d4",radius:[0,4,4,0],barSize:25})]})})]}),l.jsx("h3",{className:"text-2xl font-bold text-white mt-8 mb-4",children:"Financial Health & Liquidity"}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 xl:grid-cols-5 gap-6",children:[l.jsx(Ae,{title:"Pending Approvals",value:h.pendingApprovals,view:ve.PaymentOrders}),l.jsx(Ae,{title:"Overdue Invoices",value:h.overdueInvoices,view:ve.Invoices}),l.jsx(Ae,{title:"Total Outflow (7d)",value:h.totalOutflow,formatter:O=>`$${(O/1e3).toFixed(1)}k`}),l.jsx(Ae,{title:"Total Inflow (Paid)",value:b,formatter:O=>`$${(O/1e3).toFixed(1)}k`}),l.jsx(Ae,{title:"Avg. Invoice Value",value:T,formatter:O=>`$${O.toFixed(2)}`}),l.jsx(Ae,{title:"Days Sales Outstanding",value:M,formatter:O=>`${O.toFixed(1)} days`}),l.jsx(Ae,{title:"Days Payable Outstanding",value:j,formatter:O=>`${O.toFixed(1)} days`}),l.jsx(Ae,{title:"Current Ratio",value:k,formatter:O=>O.toFixed(2)}),l.jsx(Ae,{title:"Quick Ratio",value:R,formatter:O=>O.toFixed(2)}),l.jsx(Ae,{title:"Gross Profit Margin",value:C,formatter:O=>`${O.toFixed(1)}%`}),l.jsx(Ae,{title:"Net Profit Margin",value:E,formatter:O=>`${O.toFixed(1)}%`}),l.jsx(Ae,{title:"Estimated VAT Liability",value:F,formatter:O=>`$${(O/1e3).toFixed(1)}k`}),l.jsx(Ae,{title:"Estimated Payroll Tax",value:q,formatter:O=>`$${(O/1e3).toFixed(1)}k`}),l.jsx(Ae,{title:"Estimated Corporate Tax",value:G,formatter:O=>`$${(O/1e3).toFixed(1)}k`}),l.jsx(Ae,{title:"Budget Variance (Total)",value:Z,formatter:O=>`$${(O/1e3).toFixed(1)}k`,className:Z>0?"bg-red-700/30 border-red-600":"bg-green-700/30 border-green-600"}),l.jsx(Ae,{title:"Total Budget Allocated",value:oe,formatter:O=>`$${(O/1e3).toFixed(1)}k`}),l.jsx(Ae,{title:"Cash Conversion Cycle",value:N,formatter:O=>`${O.toFixed(1)} days`}),l.jsx(Ae,{title:"Equity Ratio",value:I,formatter:O=>`${O.toFixed(1)}%`}),l.jsx(Ae,{title:"Debt To Equity Ratio",value:P,formatter:O=>O.toFixed(2)})]}),l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-3 gap-6",children:[l.jsx(Bt,{title:"Operating Cash Flow Trend",children:l.jsxs(jn,{data:Nr,margin:{top:20,right:30,left:20,bottom:5},children:[l.jsx(St,{dataKey:"period",stroke:"#9ca3af",fontSize:12}),l.jsx(vt,{stroke:"#9ca3af",fontSize:12,tickFormatter:O=>`$${(O/1e3).toFixed(0)}k`}),l.jsx(at,{contentStyle:{backgroundColor:"rgba(31, 41, 55, 0.8)",borderColor:"#4b5563"},formatter:O=>`$${O.toFixed(2)}`}),l.jsx(Rn,{wrapperStyle:{fontSize:"12px",color:"#9ca3af"}}),l.jsx(it,{dataKey:"inflow",fill:"#059669",name:"Cash Inflow"}),l.jsx(it,{dataKey:"outflow",fill:"#ef4444",name:"Cash Outflow"}),l.jsx(it,{dataKey:"netCashFlow",fill:"#10b981",name:"Net Cash Flow"})]})}),l.jsx(Bt,{title:"Invoice Aging Buckets (Amount)",children:l.jsxs(jn,{data:wc,layout:"vertical",margin:{top:5,right:20,left:10,bottom:5},children:[l.jsx(St,{type:"number",hide:!0}),l.jsx(vt,{type:"category",dataKey:"bucket",stroke:"#9ca3af",fontSize:12,width:90}),l.jsx(at,{contentStyle:{backgroundColor:"rgba(31, 41, 55, 0.8)",borderColor:"#4b5563"},formatter:O=>`$${O.toFixed(2)}`}),l.jsx(it,{dataKey:"amount",fill:"#f59e0b",radius:[0,4,4,0],barSize:20})]})}),l.jsx(Bt,{title:"Fixed vs Variable Costs",children:l.jsxs(jn,{data:Ma,margin:{top:20,right:30,left:20,bottom:5},children:[l.jsx(St,{dataKey:"type",stroke:"#9ca3af",fontSize:12}),l.jsx(vt,{stroke:"#9ca3af",fontSize:12,tickFormatter:O=>`$${(O/1e3).toFixed(0)}k`}),l.jsx(at,{contentStyle:{backgroundColor:"rgba(31, 41, 55, 0.8)",borderColor:"#4b5563"},formatter:O=>`$${O.toFixed(2)}`}),l.jsx(it,{dataKey:"amount",fill:"#3b82f6"})]})})]}),l.jsx("h3",{className:"text-2xl font-bold text-white mt-8 mb-4",children:"Operational Efficiency & Spend"}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 xl:grid-cols-5 gap-6",children:[l.jsx(Ae,{title:"Payment Orders Processed",value:H,formatter:O=>O.toLocaleString()}),l.jsx(Ae,{title:"Invoices Issued",value:V,formatter:O=>O.toLocaleString()}),l.jsx(Ae,{title:"Avg. Approval Time",value:me,formatter:O=>`${O.toFixed(1)} hrs`,className:me>48?"bg-red-700/30 border-red-600":""}),l.jsx(Ae,{title:"Approval Throughput (30d)",value:z,formatter:O=>`${O} orders`}),l.jsx(Ae,{title:"High-Value POs (>$10k)",value:Y,formatter:O=>O.toLocaleString()}),l.jsx(Ae,{title:"On-Time Payments %",value:ge,formatter:O=>`${O.toFixed(1)}%`,className:ge<90?"bg-yellow-700/30 border-yellow-600":""}),l.jsx(Ae,{title:"Avg. Transaction Amount",value:cr,formatter:O=>`$${O.toFixed(2)}`}),l.jsx(Ae,{title:"Large Transactions (>$5k)",value:$t,formatter:O=>O.toLocaleString()}),l.jsx(Ae,{title:"Small Transactions (<$100)",value:$e,formatter:O=>O.toLocaleString()}),l.jsx(Ae,{title:"Transactions by Card",value:Ht,formatter:O=>O.toLocaleString()}),l.jsx(Ae,{title:"Transactions by Bank Transfer",value:Vt,formatter:O=>O.toLocaleString()}),l.jsx(Ae,{title:"Unique Payment Methods",value:Er,formatter:O=>O.toLocaleString()}),l.jsx(Ae,{title:"Unique Vendors",value:Po,formatter:O=>O.toLocaleString()}),l.jsx(Ae,{title:"Total Employee Expenses",value:Jr.totalExpenses,formatter:O=>`$${(O/1e3).toFixed(1)}k`}),l.jsx(Ae,{title:"Avg. Employee Expense",value:Jr.averageExpense,formatter:O=>`$${O.toFixed(2)}`}),l.jsx(Ae,{title:"SAAS Spend",value:Me,formatter:O=>`$${(O/1e3).toFixed(1)}k`}),l.jsx(Ae,{title:"Utilities Spend",value:U,formatter:O=>`$${(O/1e3).toFixed(1)}k`}),l.jsx(Ae,{title:"Marketing Spend",value:te,formatter:O=>`$${(O/1e3).toFixed(1)}k`}),l.jsx(Ae,{title:"R&D Spend",value:ue,formatter:O=>`$${(O/1e3).toFixed(1)}k`}),l.jsx(Ae,{title:"Employee Reimbursement",value:fe,formatter:O=>`$${(O/1e3).toFixed(1)}k`}),l.jsx(Ae,{title:"IT Infrastructure Spend",value:Ne,formatter:O=>`$${(O/1e3).toFixed(1)}k`}),l.jsx(Ae,{title:"Legal Fees",value:Pe,formatter:O=>`$${(O/1e3).toFixed(1)}k`}),l.jsx(Ae,{title:"Consulting Fees",value:Re,formatter:O=>`$${(O/1e3).toFixed(1)}k`}),l.jsx(Ae,{title:"Office Supplies Spend",value:wt,formatter:O=>`$${(O/1e3).toFixed(1)}k`}),l.jsx(Ae,{title:"Travel Spend",value:re,formatter:O=>`$${(O/1e3).toFixed(1)}k`}),l.jsx(Ae,{title:"Entertainment Spend",value:Le,formatter:O=>`$${(O/1e3).toFixed(1)}k`}),l.jsx(Ae,{title:"Total Refunds",value:Fe,formatter:O=>`$${(O/1e3).toFixed(1)}k`}),l.jsx(Ae,{title:"Total Discounts",value:de,formatter:O=>`$${(O/1e3).toFixed(1)}k`})]}),l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-3 gap-6",children:[l.jsx(Bt,{title:"Daily Transaction Volume (Amount)",children:l.jsxs(jn,{data:An,margin:{top:20,right:30,left:20,bottom:5},children:[l.jsx(St,{dataKey:"date",stroke:"#9ca3af",fontSize:12}),l.jsx(vt,{stroke:"#9ca3af",fontSize:12,tickFormatter:O=>`$${(O/1e3).toFixed(0)}k`}),l.jsx(at,{contentStyle:{backgroundColor:"rgba(31, 41, 55, 0.8)",borderColor:"#4b5563"},formatter:O=>`$${O.toFixed(2)}`}),l.jsx(it,{dataKey:"amount",fill:"#fcd34d"})]})}),l.jsx(Bt,{title:"Top 7 Vendors by Spend",children:l.jsxs(jn,{data:Sc,layout:"vertical",margin:{top:5,right:20,left:10,bottom:5},children:[l.jsx(St,{type:"number",hide:!0}),l.jsx(vt,{type:"category",dataKey:"vendor",stroke:"#9ca3af",fontSize:12,width:100}),l.jsx(at,{contentStyle:{backgroundColor:"rgba(31, 41, 55, 0.8)",borderColor:"#4b5563"},formatter:O=>`$${O.toFixed(2)}`}),l.jsx(it,{dataKey:"amount",fill:"#60a5fa",radius:[0,4,4,0],barSize:20})]})}),l.jsx(Bt,{title:"Departmental Budget Variance",children:l.jsxs(jn,{data:ui,margin:{top:20,right:30,left:20,bottom:5},children:[l.jsx(St,{dataKey:"department",stroke:"#9ca3af",fontSize:12}),l.jsx(vt,{stroke:"#9ca3af",fontSize:12,tickFormatter:O=>`$${(O/1e3).toFixed(0)}k`}),l.jsx(at,{contentStyle:{backgroundColor:"rgba(31, 41, 55, 0.8)",borderColor:"#4b5563"},formatter:O=>`$${O.toFixed(2)}`}),l.jsx(Rn,{wrapperStyle:{fontSize:"12px",color:"#9ca3af"}}),l.jsx(it,{dataKey:"actualSpend",fill:"#059669",name:"Actual Spend"}),l.jsx(it,{dataKey:"budget",fill:"#ef4444",name:"Budget"})]})}),l.jsx(Bt,{title:"Payment Method Usage (Amount)",children:l.jsxs(jn,{data:Di,layout:"vertical",margin:{top:5,right:20,left:10,bottom:5},children:[l.jsx(St,{type:"number",hide:!0}),l.jsx(vt,{type:"category",dataKey:"method",stroke:"#9ca3af",fontSize:12,width:100}),l.jsx(at,{contentStyle:{backgroundColor:"rgba(31, 41, 55, 0.8)",borderColor:"#4b5563"},formatter:O=>`$${O.toFixed(2)}`}),l.jsx(it,{dataKey:"totalAmount",fill:"#8b5cf6",radius:[0,4,4,0],barSize:20})]})}),l.jsx(Bt,{title:"Top 7 Expenses by Description",children:l.jsxs(jn,{data:di,layout:"vertical",margin:{top:5,right:20,left:10,bottom:5},children:[l.jsx(St,{type:"number",hide:!0}),l.jsx(vt,{type:"category",dataKey:"vendor",stroke:"#9ca3af",fontSize:12,width:100})," ",l.jsx(at,{contentStyle:{backgroundColor:"rgba(31, 41, 55, 0.8)",borderColor:"#4b5563"},formatter:O=>`$${O.toFixed(2)}`}),l.jsx(it,{dataKey:"amount",fill:"#d946ef",radius:[0,4,4,0],barSize:20})]})}),l.jsx(Bt,{title:"Geographic Spend Distribution",children:l.jsxs(jn,{data:fi,margin:{top:20,right:30,left:20,bottom:5},children:[l.jsx(St,{dataKey:"region",stroke:"#9ca3af",fontSize:12}),l.jsx(vt,{stroke:"#9ca3af",fontSize:12,tickFormatter:O=>`$${(O/1e3).toFixed(0)}k`}),l.jsx(at,{contentStyle:{backgroundColor:"rgba(31, 41, 55, 0.8)",borderColor:"#4b5563"},formatter:O=>`$${O.toFixed(2)}`}),l.jsx(it,{dataKey:"amount",fill:"#ec4899"})]})})]}),l.jsx("h3",{className:"text-2xl font-bold text-white mt-8 mb-4",children:"Compliance & Risk Management"}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 xl:grid-cols-5 gap-6",children:[l.jsx(Ae,{title:"Open Compliance Cases",value:h.openCases,view:ve.Compliance}),l.jsx(Ae,{title:"Critical Cases (Open)",value:Us,formatter:O=>O.toLocaleString(),className:Us>0?"bg-red-700/30 border-red-600":""}),l.jsx(Ae,{title:"Avg. Case Resolution Time",value:ki,formatter:O=>`${O.toFixed(1)} days`,className:ki>30?"bg-yellow-700/30 border-yellow-600":""}),l.jsx(Ae,{title:"Total Compliance Fines (Est.)",value:Io,formatter:O=>`$${(O/1e3).toFixed(1)}k`}),l.jsx(Ae,{title:"High-Risk Transactions",value:Kt,formatter:O=>O.toLocaleString(),className:Kt>0?"bg-red-700/30 border-red-600":""}),l.jsx(Ae,{title:"Flagged Vendors",value:ko,formatter:O=>O.toLocaleString()}),l.jsx(Ae,{title:"Foreign Currency Spend",value:Bs,formatter:O=>`$${(O/1e3).toFixed(1)}k`}),l.jsx(Ae,{title:"Foreign Currency Transactions",value:zs,formatter:O=>O.toLocaleString()}),l.jsx(Ae,{title:"Automated Approvals %",value:ja,formatter:O=>`${O.toFixed(1)}%`}),l.jsx(Ae,{title:"Total Contracts",value:ur.totalContracts,formatter:O=>O.toLocaleString()}),l.jsx(Ae,{title:"Expiring Contracts (90d)",value:ur.expiringSoon,formatter:O=>O.toLocaleString(),className:ur.expiringSoon>0?"bg-yellow-700/30 border-yellow-600":""}),l.jsx(Ae,{title:"Non-Compliant Contracts",value:ur.nonCompliant,formatter:O=>O.toLocaleString(),className:ur.nonCompliant>0?"bg-red-700/30 border-red-600":""}),l.jsx(Ae,{title:"Audit Failed Logins (7d)",value:Qr,formatter:O=>O.toLocaleString(),className:Qr>5?"bg-yellow-700/30 border-yellow-600":""}),l.jsx(Ae,{title:"Audit Suspicious Activity (7d)",value:Qt,formatter:O=>O.toLocaleString(),className:Qt>0?"bg-red-700/30 border-red-600":""}),l.jsx(Ae,{title:"Audit Data Access Violations (7d)",value:Sn,formatter:O=>O.toLocaleString(),className:Sn>0?"bg-red-700/30 border-red-600":""}),l.jsx(pe,{title:"Top 3 Compliance Risks",children:l.jsx("ul",{className:"list-disc pl-5 text-gray-300 text-sm",children:ci.map((O,Ue)=>l.jsx("li",{children:O},Ue))})})]}),l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[l.jsx(Bt,{title:"Budget vs. Actual Spend by Department",children:l.jsxs(jn,{data:Ac,margin:{top:20,right:30,left:20,bottom:5},children:[l.jsx(St,{dataKey:"department",stroke:"#9ca3af",fontSize:12}),l.jsx(vt,{stroke:"#9ca3af",fontSize:12,tickFormatter:O=>`$${(O/1e3).toFixed(0)}k`}),l.jsx(at,{contentStyle:{backgroundColor:"rgba(31, 41, 55, 0.8)",borderColor:"#4b5563"},formatter:O=>`$${O.toFixed(2)}`}),l.jsx(Rn,{wrapperStyle:{fontSize:"12px",color:"#9ca3af"}}),l.jsx(it,{dataKey:"budget",fill:"#fde047",name:"Allocated Budget"}),l.jsx(it,{dataKey:"actualSpend",fill:"#22d3ee",name:"Actual Spend"})]})}),l.jsx(Bt,{title:"Monthly Spend Trend by Category (Last 6 Months)",children:l.jsxs(jn,{data:Fs.slice(-6),margin:{top:20,right:30,left:20,bottom:5},children:[l.jsx(St,{dataKey:"month",stroke:"#9ca3af",fontSize:12}),l.jsx(vt,{stroke:"#9ca3af",fontSize:12,tickFormatter:O=>`$${(O/1e3).toFixed(0)}k`}),l.jsx(at,{contentStyle:{backgroundColor:"rgba(31, 41, 55, 0.8)",borderColor:"#4b5563"},formatter:O=>`$${O.toFixed(2)}`}),l.jsx(Rn,{wrapperStyle:{fontSize:"12px",color:"#9ca3af"}}),l.jsx(it,{dataKey:"T_E",stackId:"a",fill:"#0ea5e9",name:"T&E"}),l.jsx(it,{dataKey:"Software",stackId:"a",fill:"#8b5cf6",name:"Software"}),l.jsx(it,{dataKey:"Marketing",stackId:"a",fill:"#ec4899",name:"Marketing"}),l.jsx(it,{dataKey:"Facilities",stackId:"a",fill:"#f59e0b",name:"Facilities"}),l.jsx(it,{dataKey:"Salaries",stackId:"a",fill:"#10b981",name:"Salaries"}),l.jsx(it,{dataKey:"Other",stackId:"a",fill:"#9ca3af",name:"Other"})]})}),l.jsx(Bt,{title:"Employee Expense Breakdown by Category",children:l.jsxs(D1,{children:[l.jsx(Wh,{data:Ro,dataKey:"amount",nameKey:"category",cx:"50%",cy:"50%",outerRadius:80,fill:"#8884d8",label:O=>`${O.name}: $${O.value.toFixed(0)}`,children:Ro.map((O,Ue)=>l.jsx(Ls,{fill:qs[Ue%qs.length]},`cell-${Ue}`))}),l.jsx(at,{contentStyle:{backgroundColor:"rgba(31, 41, 55, 0.8)",borderColor:"#4b5563"},formatter:O=>`$${O.toFixed(2)}`}),l.jsx(Rn,{wrapperStyle:{fontSize:"12px",color:"#9ca3af"}})]})}),l.jsx(Bt,{title:"Audit Trail - Daily Events (Last 7 Days)",children:l.jsxs(jn,{data:Do,margin:{top:20,right:30,left:20,bottom:5},children:[l.jsx(St,{dataKey:"date",stroke:"#9ca3af",fontSize:12}),l.jsx(vt,{stroke:"#9ca3af",fontSize:12,allowDecimals:!1}),l.jsx(at,{contentStyle:{backgroundColor:"rgba(31, 41, 55, 0.8)",borderColor:"#4b5563"}}),l.jsx(Rn,{wrapperStyle:{fontSize:"12px",color:"#9ca3af"}}),l.jsx(it,{dataKey:"failedLogins",fill:"#f43f5e",name:"Failed Logins"}),l.jsx(it,{dataKey:"suspiciousActivities",fill:"#facc15",name:"Suspicious Activities"}),l.jsx(it,{dataKey:"dataAccessViolations",fill:"#ef4444",name:"Data Access Violations"})]})})]})]})},vse=()=>{const e=S.useContext(Ct);if(!e)throw new Error("ModernTreasuryView must be used within a DataProvider.");const{ledgerAccounts:t,fetchLedgerAccounts:n,isLedgerAccountsLoading:r,ledgerAccountsError:i,modernTreasuryApiKey:o,modernTreasuryOrganizationId:c,setActiveView:u}=e;S.useEffect(()=>{o&&c&&n()},[o,c]);const m=(h,g)=>(h/Math.pow(10,g)).toLocaleString("en-US",{style:"currency",currency:"USD"}),f=()=>!o||!c?l.jsx(pe,{title:"Configuration Required",children:l.jsxs("div",{className:"text-center",children:[l.jsx("p",{className:"text-gray-400 mb-4",children:"Please configure your Modern Treasury API Key and Organization ID to view ledger accounts."}),l.jsx("button",{onClick:()=>u(ve.APIIntegration),className:"px-4 py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg",children:"Go to API Status & Settings"})]})}):r?l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[...Array(3)].map((h,g)=>l.jsxs(pe,{className:"animate-pulse",children:[l.jsx("div",{className:"h-6 bg-gray-700 rounded w-3/4 mb-4"}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("div",{className:"h-4 bg-gray-700 rounded w-1/2"}),l.jsx("div",{className:"h-4 bg-gray-700 rounded w-full"}),l.jsx("div",{className:"h-4 bg-gray-700 rounded w-2/3"})]})]},g))}):i?l.jsx(pe,{title:"Error",children:l.jsx("p",{className:"text-red-400",children:i})}):t.length===0?l.jsx(pe,{title:"No Accounts Found",children:l.jsx("p",{className:"text-gray-400",children:"No ledger accounts were found. This could be due to incorrect credentials or no accounts existing in your Modern Treasury ledger."})}):l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:t.map(h=>l.jsx(pe,{title:h.name,children:l.jsxs("div",{className:"space-y-3 text-sm",children:[l.jsx("p",{className:"text-gray-400",children:h.description||"No description available."}),l.jsxs("div",{className:"pt-2 border-t border-gray-700",children:[l.jsxs("div",{className:"flex justify-between",children:[l.jsx("span",{className:"text-gray-400",children:"Available Balance:"}),l.jsx("span",{className:"font-mono text-green-400 font-semibold",children:m(h.balances.available_balance.amount,h.balances.available_balance.currency_exponent)})]}),l.jsxs("div",{className:"flex justify-between",children:[l.jsx("span",{className:"text-gray-400",children:"Posted Balance:"}),l.jsx("span",{className:"font-mono text-white",children:m(h.balances.posted_balance.amount,h.balances.posted_balance.currency_exponent)})]}),l.jsxs("div",{className:"flex justify-between",children:[l.jsx("span",{className:"text-gray-400",children:"Pending Balance:"}),l.jsx("span",{className:"font-mono text-yellow-400",children:m(h.balances.pending_balance.amount,h.balances.pending_balance.currency_exponent)})]})]}),l.jsx("div",{className:"pt-2 border-t border-gray-700 text-xs text-gray-500",children:l.jsxs("div",{className:"flex justify-between",children:[l.jsxs("span",{children:["Normal Balance: ",l.jsx("span",{className:"capitalize",children:h.normal_balance})]}),l.jsxs("span",{children:["Ledger ID: ",h.ledger_id]})]})})]})},h.id))});return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsx("div",{className:"w-12 h-12 bg-gray-800 rounded-full flex items-center justify-center",children:l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6 text-cyan-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:[l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4M4 7l8 4.5 8-4.5"}),l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 12l8 4.5 8-4.5"})]})}),l.jsxs("div",{children:[l.jsx("h2",{className:"text-3xl font-bold text-white tracking-wider",children:"Modern Treasury Ledger Accounts"}),l.jsx("p",{className:"text-gray-400",children:"A real-time overview of your corporate ledger accounts."})]})]}),f()]})},xse=[{id:"acc_101",name:"Primary Checking",type:"checking",accountNumberMasked:"**** **** **** 1234",balance:15432.88,currency:"USD"},{id:"acc_102",name:"High-Yield Savings",type:"savings",accountNumberMasked:"**** **** **** 5678",balance:89102.15,currency:"USD"},{id:"acc_103",name:"Travel Rewards Card",type:"credit_card",accountNumberMasked:"**** ****** *9012",balance:-2345.67,currency:"USD"}],Br={read_transaction_history:{key:"read_transaction_history",label:"Read transaction history",description:"Allows the app to view your list of transactions for budgeting or analysis. It cannot initiate payments.",category:"Account Information",riskLevel:"low"},view_account_balances:{key:"view_account_balances",label:"View account balances",description:"Allows the app to see the current balance of your accounts. It cannot move money.",category:"Account Information",riskLevel:"low"},access_income_statements:{key:"access_income_statements",label:"Access income statements",description:"Allows the app to see your income history, typically for verification purposes.",category:"Data Analysis",riskLevel:"medium"},initiate_single_payment:{key:"initiate_single_payment",label:"Initiate single payment",description:"Allows the app to initiate a one-time payment from one of your accounts. You must still approve each payment.",category:"Payment Initiation",riskLevel:"high"},view_account_details:{key:"view_account_details",label:"View account details",description:"Allows the app to see account details like account number and routing number.",category:"Account Information",riskLevel:"medium"},access_contact_info:{key:"access_contact_info",label:"Access contact information",description:"Allows the app to view your name, address, and email associated with your bank account.",category:"Account Information",riskLevel:"low"}},is=[{id:"app_001",name:"MintFusion Budgeting",developer:"FusionCorp",website:"https://fusioncorp.example.com",description:"A powerful tool to track your spending, create budgets, and achieve your financial goals.",category:"Budgeting",icon:"M11 3.055A9.001 9.001 0 1020.945 13H11V3.055z",requestedPermissions:[Br.read_transaction_history,Br.view_account_balances,Br.view_account_details]},{id:"app_002",name:"TaxBot Pro",developer:"Taxable Inc.",website:"https://taxable.example.com",description:"Automate your tax preparation by importing financial data directly and securely.",category:"Tax",icon:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z",requestedPermissions:[Br.read_transaction_history,Br.access_income_statements]},{id:"app_003",name:"Acornvest",developer:"Oak Financial",website:"https://oakfin.example.com",description:"Invest your spare change automatically from everyday purchases.",category:"Investment",icon:"M13 17h8m0 0V9m0 8l-8-8-4 4-6-6",requestedPermissions:[Br.read_transaction_history,Br.view_account_balances,Br.initiate_single_payment]},{id:"app_004",name:"LendEasy",developer:"QuickCredit",website:"https://quickcredit.example.com",description:"Get faster loan approvals by securely sharing your financial history.",category:"Lending",icon:"M17 9V7a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2m2 4h10a2 2 0 002-2v-6a2 2 0 00-2-2H9a2 2 0 00-2 2v6a2 2 0 002 2zm7-5a2 2 0 11-4 0 2 2 0 014 0z",requestedPermissions:[Br.read_transaction_history,Br.view_account_balances,Br.access_income_statements,Br.access_contact_info]}],bse=[{id:1,app:is[0],status:"active",connectedAt:"2023-08-15T10:30:00Z",expiresAt:"2024-11-15T10:30:00Z",lastAccessedAt:"2023-10-28T14:00:00Z",linkedAccountIds:["acc_101","acc_102"],grantedPermissions:is[0].requestedPermissions,dataSharingFrequency:"recurring"},{id:2,app:is[1],status:"active",connectedAt:"2023-01-20T18:00:00Z",expiresAt:"2024-04-20T18:00:00Z",lastAccessedAt:"2023-04-15T09:00:00Z",linkedAccountIds:["acc_101"],grantedPermissions:is[1].requestedPermissions,dataSharingFrequency:"recurring"},{id:3,app:is[3],status:"expired",connectedAt:"2022-05-10T11:00:00Z",expiresAt:"2023-08-10T11:00:00Z",lastAccessedAt:"2022-05-10T11:05:00Z",linkedAccountIds:["acc_101","acc_102"],grantedPermissions:is[3].requestedPermissions,dataSharingFrequency:"one_time"}],wse=[{id:"evt_001",connectionId:1,appName:"MintFusion Budgeting",eventType:"connected",timestamp:"2023-08-15T10:30:00Z",details:"Access granted to Primary Checking, High-Yield Savings."},{id:"evt_002",connectionId:1,appName:"MintFusion Budgeting",eventType:"data_accessed",timestamp:"2023-10-28T14:00:00Z",details:"Transaction history and balances were synced."},{id:"evt_003",connectionId:2,appName:"TaxBot Pro",eventType:"connected",timestamp:"2023-01-20T18:00:00Z",details:"Access granted to Primary Checking."},{id:"evt_004",connectionId:2,appName:"TaxBot Pro",eventType:"data_accessed",timestamp:"2023-04-15T09:00:00Z",details:"Transaction history and income statements were synced."},{id:"evt_005",connectionId:3,appName:"LendEasy",eventType:"connected",timestamp:"2022-05-10T11:00:00Z",details:"Access granted for a one-time credit check."},{id:"evt_006",connectionId:3,appName:"LendEasy",eventType:"data_accessed",timestamp:"2022-05-10T11:05:00Z",details:"Financial history was accessed."},{id:"evt_007",connectionId:3,appName:"LendEasy",eventType:"expired",timestamp:"2023-08-10T11:00:00Z",details:"Connection expired automatically after 90 days."}],YI={defaultConsentDurationDays:90,notifyOnNewConnection:!0,notifyOnConnectionExpiration:!0,requireReauthenticationForHighRisk:!0},Cu=(e,t=500,n=0)=>new Promise((r,i)=>{setTimeout(()=>{Math.random()e?l.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-70 flex items-center justify-center z-50 transition-opacity",onClick:t,children:l.jsxs("div",{className:"bg-gray-800 rounded-lg shadow-xl w-full max-w-2xl m-4 border border-gray-700",onClick:i=>i.stopPropagation(),children:[l.jsxs("div",{className:"flex justify-between items-center p-4 border-b border-gray-700",children:[l.jsx("h3",{className:"text-xl font-bold text-white tracking-wider",children:n}),l.jsx("button",{onClick:t,className:"text-gray-400 hover:text-white",children:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),l.jsx("div",{className:"p-6 max-h-[70vh] overflow-y-auto",children:r})]})}):null,Sse=()=>l.jsxs("div",{className:"p-4 bg-gray-800/50 rounded-lg flex flex-col sm:flex-row justify-between items-start gap-4 animate-pulse",children:[l.jsxs("div",{className:"flex items-start w-full",children:[l.jsx("div",{className:"w-10 h-10 bg-gray-700 rounded-full flex-shrink-0 mr-4"}),l.jsxs("div",{className:"w-full",children:[l.jsx("div",{className:"h-5 bg-gray-700 rounded w-1/3 mb-2"}),l.jsx("div",{className:"h-4 bg-gray-700 rounded w-1/4 mb-3"}),l.jsx("div",{className:"h-3 bg-gray-700 rounded w-1/2 mb-1"}),l.jsx("div",{className:"h-3 bg-gray-700 rounded w-2/3"})]})]}),l.jsx("div",{className:"h-8 bg-gray-700 rounded-lg w-full sm:w-24 flex-shrink-0 self-start sm:self-center mt-2 sm:mt-0"})]}),WI=({status:e})=>{const t={active:"bg-green-500/20 text-green-300",expired:"bg-yellow-500/20 text-yellow-300",revoked:"bg-red-500/20 text-red-300",pending:"bg-blue-500/20 text-blue-300"};return l.jsx("span",{className:`px-2 py-1 text-xs font-medium rounded-full ${t[e]}`,children:e.charAt(0).toUpperCase()+e.slice(1)})},iv=(e=!1)=>{const[t,n]=S.useState(e),r=S.useCallback(()=>n(!0),[]),i=S.useCallback(()=>n(!1),[]),o=S.useCallback(()=>n(c=>!c),[]);return{isOpen:t,onOpen:r,onClose:i,onToggle:o}},Ase={connections:[],history:[],settings:YI,availableApps:[],accounts:[],isLoading:!0,error:null,filter:"",statusFilter:"all"};function Cse(e,t){var n;switch(t.type){case"FETCH_START":return{...e,isLoading:!0,error:null};case"FETCH_SUCCESS":return{...e,isLoading:!1,...t.payload};case"FETCH_ERROR":return{...e,isLoading:!1,error:t.payload};case"REVOKE_CONNECTION":{const r=new Date().toISOString();return{...e,connections:e.connections.map(i=>i.id===t.payload?{...i,status:"revoked"}:i),history:[...e.history,{id:`evt_${Date.now()}`,connectionId:t.payload,appName:((n=e.connections.find(i=>i.id===t.payload))==null?void 0:n.app.name)||"Unknown App",eventType:"revoked",timestamp:r,details:"User revoked access manually."}]}}case"ADD_CONNECTION":{const{app:r,linkedAccountIds:i,grantedPermissions:o}=t.payload,c=new Date,u=new Date(c);u.setDate(u.getDate()+e.settings.defaultConsentDurationDays);const m={id:Math.max(...e.connections.map(h=>h.id),0)+1,app:r,status:"active",connectedAt:c.toISOString(),expiresAt:u.toISOString(),lastAccessedAt:null,linkedAccountIds:i,grantedPermissions:o,dataSharingFrequency:"recurring"},f=e.accounts.filter(h=>i.includes(h.id)).map(h=>h.name).join(", ");return{...e,connections:[m,...e.connections],history:[...e.history,{id:`evt_${Date.now()}`,connectionId:m.id,appName:r.name,eventType:"connected",timestamp:m.connectedAt,details:`Access granted to ${f}.`}]}}case"SET_FILTER":return{...e,filter:t.payload};case"SET_STATUS_FILTER":return{...e,statusFilter:t.payload};case"UPDATE_SETTINGS":return{...e,settings:{...e.settings,...t.payload}};default:return e}}const Ex=e=>e?new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"long",day:"numeric"}):"N/A",Tse=e=>{const t=new Date(e),n=new Date,r=t.getTime()-n.getTime();return Math.max(0,Math.ceil(r/(1e3*60*60*24)))},Ese=({connection:e,accounts:t,onClose:n})=>{if(!e)return null;const r=t.filter(i=>e.linkedAccountIds.includes(i.id));return l.jsx(q1,{isOpen:!!e,onClose:n,title:`${e.app.name} Details`,children:l.jsxs("div",{className:"space-y-6 text-gray-300",children:[l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsx("div",{className:"w-16 h-16 bg-cyan-500/10 rounded-lg flex items-center justify-center text-cyan-300 flex-shrink-0",children:l.jsx("svg",{className:"w-10 h-10",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:e.app.icon})})}),l.jsxs("div",{children:[l.jsx("h4",{className:"text-2xl font-bold text-white",children:e.app.name}),l.jsxs("p",{className:"text-sm text-gray-400",children:["by ",e.app.developer]}),l.jsx("a",{href:e.app.website,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-cyan-400 hover:underline",children:e.app.website})]})]}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 text-sm",children:[l.jsxs("div",{className:"bg-gray-700/50 p-3 rounded-lg",children:[l.jsx("p",{className:"text-gray-400 text-xs",children:"Status"}),l.jsx("div",{className:"mt-1",children:l.jsx(WI,{status:e.status})})]}),l.jsxs("div",{className:"bg-gray-700/50 p-3 rounded-lg",children:[l.jsx("p",{className:"text-gray-400 text-xs",children:"Connected On"}),l.jsx("p",{className:"text-white font-medium",children:Ex(e.connectedAt)})]}),l.jsxs("div",{className:"bg-gray-700/50 p-3 rounded-lg",children:[l.jsx("p",{className:"text-gray-400 text-xs",children:"Expires On"}),l.jsx("p",{className:"text-white font-medium",children:Ex(e.expiresAt)})]})]}),l.jsxs("div",{children:[l.jsx("h5",{className:"font-semibold text-white mb-2",children:"Linked Accounts"}),l.jsx("ul",{className:"space-y-2",children:r.map(i=>l.jsxs("li",{className:"p-3 bg-gray-700/50 rounded-lg flex justify-between items-center",children:[l.jsxs("span",{children:[i.name," (",i.accountNumberMasked,")"]}),l.jsx("span",{className:"text-gray-400",children:i.type.replace("_"," ")})]},i.id))})]}),l.jsxs("div",{children:[l.jsx("h5",{className:"font-semibold text-white mb-2",children:"Permissions Granted"}),l.jsx("ul",{className:"space-y-2",children:e.grantedPermissions.map(i=>l.jsxs("li",{className:"p-3 bg-gray-700/50 rounded-lg",children:[l.jsx("p",{className:"font-medium text-white",children:i.label}),l.jsx("p",{className:"text-xs text-gray-400 mt-1",children:i.description})]},i.key))})]})]})})},Nse=({connection:e,onClose:t,onConfirm:n})=>e?l.jsx(q1,{isOpen:!!e,onClose:t,title:"Revoke Access",children:l.jsxs("div",{className:"text-gray-300",children:[l.jsxs("p",{children:["Are you sure you want to revoke access for ",l.jsx("strong",{className:"text-white",children:e.app.name}),"?"]}),l.jsx("p",{className:"text-sm mt-2 text-gray-400",children:"This action is irreversible. The application will immediately lose all access to your financial data granted through this connection. You can always reconnect it later if you change your mind."}),l.jsxs("div",{className:"flex justify-end gap-4 mt-6",children:[l.jsx("button",{onClick:t,className:"px-4 py-2 bg-gray-600 hover:bg-gray-500 text-white rounded-lg",children:"Cancel"}),l.jsx("button",{onClick:()=>n(e.id),className:"px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg",children:"Yes, Revoke"})]})]})}):null,_se=({isOpen:e,onClose:t,availableApps:n,accounts:r,onConnect:i})=>{const[o,c]=S.useState(1),[u,m]=S.useState(null),[f,h]=S.useState([]);S.useEffect(()=>{e||setTimeout(()=>{c(1),m(null),h([])},300)},[e]);const g=C=>{m(C),c(2)},v=C=>{h(E=>E.includes(C)?E.filter(N=>N!==C):[...E,C])},b=()=>{!u||f.length===0||(i({app:u,linkedAccountIds:f,grantedPermissions:u.requestedPermissions}),c(4))},T=()=>{switch(o){case 1:return l.jsxs("div",{children:[l.jsx("h4",{className:"text-white font-semibold mb-4",children:"Choose an application to connect"}),l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:n.map(C=>l.jsxs("div",{onClick:()=>g(C),className:"p-4 bg-gray-700/50 rounded-lg flex items-start gap-4 cursor-pointer hover:bg-gray-700 transition-colors",children:[l.jsx("div",{className:"w-10 h-10 bg-cyan-500/10 rounded-full flex items-center justify-center text-cyan-300 flex-shrink-0",children:l.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:C.icon})})}),l.jsxs("div",{children:[l.jsx("p",{className:"font-semibold text-white",children:C.name}),l.jsx("p",{className:"text-xs text-gray-400",children:C.description})]})]},C.id))})]});case 2:return u?l.jsxs("div",{children:[l.jsx("button",{onClick:()=>c(1),className:"text-sm text-cyan-400 mb-4",children:"← Back to app selection"}),l.jsxs("h4",{className:"text-white font-semibold mb-1",children:[u.name," is requesting permission to:"]}),l.jsx("p",{className:"text-sm text-gray-400 mb-4",children:"Review the data this app wants to access."}),l.jsx("ul",{className:"space-y-3",children:u.requestedPermissions.map(C=>l.jsxs("li",{className:"p-3 bg-gray-700/50 rounded-lg",children:[l.jsxs("div",{className:"flex justify-between items-start",children:[l.jsx("p",{className:"font-medium text-white",children:C.label}),C.riskLevel==="high"&&l.jsx("span",{className:"text-xs px-2 py-1 bg-red-500/30 text-red-300 rounded-full",children:"High Risk"}),C.riskLevel==="medium"&&l.jsx("span",{className:"text-xs px-2 py-1 bg-yellow-500/30 text-yellow-300 rounded-full",children:"Medium Risk"})]}),l.jsx("p",{className:"text-xs text-gray-400 mt-1",children:C.description})]},C.key))}),l.jsx("div",{className:"mt-6 flex justify-end",children:l.jsx("button",{onClick:()=>c(3),className:"px-4 py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg",children:"Next: Select Accounts →"})})]}):null;case 3:return u?l.jsxs("div",{children:[l.jsx("button",{onClick:()=>c(2),className:"text-sm text-cyan-400 mb-4",children:"← Back to permissions"}),l.jsxs("h4",{className:"text-white font-semibold mb-1",children:["Which accounts do you want to share with ",u.name,"?"]}),l.jsx("p",{className:"text-sm text-gray-400 mb-4",children:"The app will only have access to the accounts you select."}),l.jsx("div",{className:"space-y-3",children:r.map(C=>l.jsxs("label",{className:"p-4 bg-gray-700/50 rounded-lg flex items-center gap-4 cursor-pointer hover:bg-gray-700 transition-colors has-[:checked]:bg-cyan-900/50 has-[:checked]:border-cyan-500 border-2 border-transparent",children:[l.jsx("input",{type:"checkbox",className:"h-5 w-5 rounded bg-gray-800 border-gray-600 text-cyan-600 focus:ring-cyan-500",checked:f.includes(C.id),onChange:()=>v(C.id)}),l.jsxs("div",{children:[l.jsx("p",{className:"font-semibold text-white",children:C.name}),l.jsx("p",{className:"text-sm text-gray-400",children:C.accountNumberMasked})]})]},C.id))}),l.jsx("div",{className:"mt-6 flex justify-end",children:l.jsx("button",{onClick:b,disabled:f.length===0,className:"px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg disabled:bg-gray-600 disabled:cursor-not-allowed",children:"Confirm and Connect"})})]}):null;case 4:return l.jsxs("div",{className:"text-center py-8",children:[l.jsx("svg",{className:"w-16 h-16 mx-auto text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),l.jsx("h4",{className:"text-2xl font-bold text-white mt-4",children:"Connection Successful!"}),l.jsxs("p",{className:"text-gray-300 mt-2",children:["You have successfully connected ",l.jsx("strong",{className:"text-white",children:u==null?void 0:u.name}),". You can now manage this connection from your dashboard."]}),l.jsx("div",{className:"mt-6",children:l.jsx("button",{onClick:t,className:"px-6 py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg",children:"Done"})})]})}};return l.jsx(q1,{isOpen:e,onClose:t,title:"Connect New Application",children:T()})},jse=()=>{const[e,t]=S.useReducer(Cse,Ase),{onOpen:n,onClose:r}=iv(),{onOpen:i,onClose:o}=iv(),{isOpen:c,onOpen:u,onClose:m}=iv(),[f,h]=S.useState(null);S.useEffect(()=>{(async()=>{t({type:"FETCH_START"});try{const[N,I,P,M,j]=await Promise.all([Cu(bse),Cu(wse.sort((k,R)=>new Date(R.timestamp).getTime()-new Date(k.timestamp).getTime())),Cu(YI),Cu(is),Cu(xse)]);t({type:"FETCH_SUCCESS",payload:{connections:N,history:I,settings:P,availableApps:M,accounts:j}})}catch(N){t({type:"FETCH_ERROR",payload:N instanceof Error?N.message:"An unknown error occurred"})}})()},[]);const g=E=>{h(E),n()},v=E=>{h(E),i()},b=E=>{t({type:"REVOKE_CONNECTION",payload:E}),o()},T=E=>{t({type:"ADD_CONNECTION",payload:E})},C=S.useMemo(()=>e.connections.filter(E=>{const N=E.app.name.toLowerCase().includes(e.filter.toLowerCase()),I=e.statusFilter==="all"||E.status===e.statusFilter;return N&&I}),[e.connections,e.filter,e.statusFilter]);return l.jsxs("div",{className:"space-y-8",children:[l.jsxs("div",{className:"flex flex-col md:flex-row justify-between md:items-center gap-4",children:[l.jsx("h2",{className:"text-3xl font-bold text-white tracking-wider",children:"Open Banking Connections"}),l.jsxs("button",{onClick:u,className:"px-4 py-2 bg-cyan-600 hover:bg-cyan-700 text-white font-semibold rounded-lg shadow-md transition-transform transform hover:scale-105 flex items-center justify-center gap-2",children:[l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:l.jsx("path",{fillRule:"evenodd",d:"M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z",clipRule:"evenodd"})}),"Connect a New App"]})]}),l.jsx(pe,{title:"What is Open Banking?",children:l.jsx("p",{className:"text-gray-300 text-sm",children:"Open Banking is a secure way to give trusted third-party apps access to your financial information without ever sharing your login credentials. You are always in control, and you can revoke access at any time. This allows you to use powerful apps for budgeting, tax preparation, and more."})}),l.jsxs(pe,{title:"Your Connected Applications",children:[l.jsxs("div",{className:"mb-4 flex flex-col sm:flex-row gap-4",children:[l.jsx("input",{type:"text",placeholder:"Search by app name...",value:e.filter,onChange:E=>t({type:"SET_FILTER",payload:E.target.value}),className:"w-full sm:w-1/2 px-3 py-2 bg-gray-900 border border-gray-700 rounded-lg text-white focus:ring-cyan-500 focus:border-cyan-500"}),l.jsxs("select",{value:e.statusFilter,onChange:E=>t({type:"SET_STATUS_FILTER",payload:E.target.value}),className:"w-full sm:w-auto px-3 py-2 bg-gray-900 border border-gray-700 rounded-lg text-white focus:ring-cyan-500 focus:border-cyan-500",children:[l.jsx("option",{value:"all",children:"All Statuses"}),l.jsx("option",{value:"active",children:"Active"}),l.jsx("option",{value:"expired",children:"Expired"}),l.jsx("option",{value:"revoked",children:"Revoked"})]})]}),l.jsxs("div",{className:"space-y-4",children:[e.isLoading&&Array.from({length:3}).map((E,N)=>l.jsx(Sse,{},N)),!e.isLoading&&e.error&&l.jsxs("div",{className:"p-4 text-center text-red-400 bg-red-500/10 rounded-lg",children:[l.jsxs("p",{children:[l.jsx("strong",{children:"Error:"})," ",e.error]}),l.jsx("p",{className:"text-sm",children:"Could not load your connections. Please try again later."})]}),!e.isLoading&&!e.error&&C.map(E=>l.jsxs("div",{className:"p-4 bg-gray-800/50 rounded-lg flex flex-col sm:flex-row justify-between items-start gap-4",children:[l.jsxs("div",{className:"flex items-start",children:[l.jsx("div",{className:"w-10 h-10 bg-cyan-500/10 rounded-full flex items-center justify-center text-cyan-300 flex-shrink-0 mr-4",children:l.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:E.app.icon})})}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-semibold text-white",children:E.app.name}),l.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[l.jsx(WI,{status:E.status}),E.status==="active"&&l.jsxs("p",{className:"text-xs text-gray-400",children:["Expires in ",Tse(E.expiresAt)," days"]})]}),l.jsxs("p",{className:"text-sm text-gray-400 mt-2",children:["Permissions granted: ",E.grantedPermissions.length]})]})]}),l.jsxs("div",{className:"w-full sm:w-auto flex flex-col sm:flex-row gap-2 items-stretch sm:items-center flex-shrink-0 self-start sm:self-center",children:[l.jsx("button",{onClick:()=>g(E),className:"px-3 py-2 bg-gray-600/50 hover:bg-gray-600 text-white rounded-lg text-xs w-full sm:w-auto",children:"View Details"}),E.status==="active"&&l.jsx("button",{onClick:()=>v(E),className:"px-3 py-2 bg-red-600/50 hover:bg-red-600 text-white rounded-lg text-xs w-full sm:w-auto",children:"Revoke Access"})]})]},E.id)),!e.isLoading&&C.length===0&&l.jsx("p",{className:"text-gray-500 text-center py-8",children:e.connections.length>0?"No connections match your filters.":"You have not connected any third-party applications."})]})]}),l.jsx(pe,{title:"Connection History",isCollapsible:!0,defaultCollapsed:!0,children:l.jsx("div",{className:"text-sm text-gray-300 space-y-3 max-h-96 overflow-y-auto pr-2",children:e.history.map(E=>l.jsxs("div",{className:"flex gap-4 items-start",children:[l.jsx("div",{className:"text-xs text-gray-500 whitespace-nowrap pt-1",children:Ex(E.timestamp)}),l.jsxs("div",{className:"flex-grow pb-3 border-b border-gray-800",children:[l.jsxs("p",{className:"font-semibold text-white",children:[E.appName," - ",E.eventType.replace("_"," ")]}),l.jsx("p",{className:"text-gray-400",children:E.details})]})]},E.id))})}),l.jsx(pe,{title:"Learn More About Your Control",isCollapsible:!0,defaultCollapsed:!0,children:l.jsxs("div",{className:"text-sm text-gray-300 space-y-2",children:[l.jsxs("p",{children:[l.jsx("strong",{className:"text-white",children:"Your Credentials are Safe:"})," You never share your bank login details with third-party apps. Instead, you authorize access directly with us, your bank."]}),l.jsxs("p",{children:[l.jsx("strong",{className:"text-white",children:"You are in Command:"})," You can see a full list of every app you've granted access to right here. If you no longer use an app, you can revoke its access with a single click."]})]})}),l.jsx(Ese,{connection:f,accounts:e.accounts,onClose:()=>{r(),h(null)}}),l.jsx(Nse,{connection:f,onConfirm:b,onClose:()=>{o(),h(null)}}),l.jsx(_se,{isOpen:c,onClose:m,availableApps:e.availableApps,accounts:e.accounts,onConnect:T})]})},Mse=()=>l.jsxs("svg",{width:"88",height:"34",viewBox:"0 0 88 34",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("path",{d:"M82.2 3.82c-3.32 0-5.83 2.5-5.83 5.82 0 3.31 2.51 5.82 5.83 5.82 3.31 0 5.82-2.5 5.82-5.82 0-3.31-2.51-5.82-5.82-5.82Zm0 9.14c-1.87 0-3.32-1.45-3.32-3.32 0-1.87 1.45-3.32 3.32-3.32 1.87 0 3.31-1.45 3.31-3.32 0-1.87-1.44-3.32-3.31-3.32-1.87 0-3.32-1.45-3.32-3.32s1.45-3.32 3.32-3.32 3.31 1.45 3.31 3.32c0 1.87 1.45 3.32 3.32 3.32s3.32-1.45 3.32-3.32-1.45-3.32-3.32-3.32-3.31-1.45-3.31-3.32c0-3.31 2.5-5.82 5.82-5.82s5.82 2.5 5.82 5.82-2.5 5.82-5.82 5.82c-1.87 0-3.32 1.45-3.32 3.31 0 1.87-1.45 3.32-3.32 3.32Z",fill:"#fff"}),l.jsx("path",{d:"M25.86 10.93c0 4.14-3.55 7.4-7.93 7.4-4.39 0-7.94-3.26-7.94-7.4S13.54 3.53 17.93 3.53c4.38 0 7.93 3.26 7.93 7.4Zm-10.45 0c0 1.45 1.12 2.5 2.52 2.5 1.39 0 2.51-1.05 2.51-2.5 0-1.45-1.12-2.5-2.51-2.5-1.4 0-2.52 1.05-2.52 2.5Z",fill:"#fff"}),l.jsx("path",{d:"M49.6 10.93c0 4.14-3.54 7.4-7.93 7.4-4.38 0-7.93-3.26-7.93-7.4S37.29 3.53 41.67 3.53c4.39 0 7.93 3.26 7.93 7.4Zm-10.45 0c0 1.45 1.12 2.5 2.52 2.5 1.4 0 2.52-1.05 2.52-2.5 0-1.45-1.12-2.5-2.52-2.5-1.4 0-2.52 1.05-2.52 2.5Z",fill:"#fff"}),l.jsx("path",{d:"M68.8 3.82c-3.32 0-5.83 2.5-5.83 5.82 0 3.31 2.51 5.82 5.83 5.82 3.31 0 5.82-2.5 5.82-5.82 0-3.31-2.51-5.82-5.82-5.82Zm0 9.14c-1.87 0-3.32-1.45-3.32-3.32 0-1.87 1.45-3.32 3.32-3.32s3.31-1.45 3.31-3.32c0-1.87-1.44-3.32-3.31-3.32-1.87 0-3.32-1.45-3.32-3.32s1.45-3.32 3.32-3.32 3.31 1.45 3.31 3.32c0 1.87 1.45 3.32 3.32 3.32s3.32-1.45 3.32-3.32-1.45-3.32-3.32-3.32-3.31-1.45-3.31-3.32c0-3.31 2.5-5.82 5.82-5.82s5.82 2.5 5.82 5.82-2.5 5.82-5.82 5.82c-1.87 0-3.32 1.45-3.32 3.31 0 1.87-1.45 3.32-3.32 3.32Z",fill:"#fff"}),l.jsx("path",{d:"M25.86 28.33c0 2.2-1.78 3.97-3.97 3.97h-7.93c-2.2 0-3.97-1.77-3.97-3.97v-7.93c0-2.2 1.78-3.97 3.97-3.97h7.93c2.2 0 3.97 1.77 3.97 3.97v7.93Z",fill:"#fff"}),l.jsx("path",{d:"M17.93 25.43c-2.2 0-3.97-1.78-3.97-3.97s1.78-3.97 3.97-3.97 3.97 1.78 3.97 3.97-1.78 3.97-3.97 3.97Z",fill:"#0D0F2A"}),l.jsx("path",{d:"M2.5 18.23c-1.4 0-2.5-1.12-2.5-2.51V2.5C0 1.1 1.1 0 2.5 0s2.5 1.1 2.5 2.5v13.22c0 1.39-1.1 2.51-2.5 2.51Z",fill:"#fff"})]});class Pl{constructor(){}static getInstance(){return Pl.instance||(Pl.instance=new Pl),Pl.instance}async createLinkToken(t,n,r){return console.log(`[MOCK] PlaidService: Requesting link token for user ${t}`),new Promise(i=>{setTimeout(()=>{i({link_token:`link-sandbox-${Date.now()}`})},500)})}async exchangePublicToken(t,n){return console.log(`[MOCK] PlaidService: Exchanging public token: ${t}`),new Promise(r=>{setTimeout(()=>{const i=new Date,o=n.accounts.map(u=>({id:u.id,institutionId:n.institution.institution_id,name:u.name,mask:u.mask,type:u.type,subtype:u.subtype,currentBalance:Math.random()*1e4,availableBalance:Math.random()*9e3,currency:"USD",isLinked:!0,isActive:!0,syncStatus:"synced",lastSyncAttempt:i,balanceHistory:[]})),c={id:`item-${Date.now()}`,name:n.institution.name,institutionId:n.institution.institution_id,accessToken:`access-sandbox-${Date.now()}`,connectedAccounts:o,metadata:n,lastUpdated:i,status:"connected",securityAuditLog:[{timestamp:i,event:"item_created",details:"Initial connection successful."}]};r(c)},1e3)})}}const Pse=({isOpen:e,onClose:t,onSuccess:n,products:r=["transactions"]})=>{const[i,o]=S.useState("select"),[c,u]=S.useState(null);S.useEffect(()=>{e||setTimeout(()=>{o("select"),u(null)},300)},[e]);const m=h=>{u(h),o("connecting"),setTimeout(()=>{o("connected")},2500),setTimeout(()=>{const g=`public-sandbox-${Math.random().toString(36).substring(7)}`,v={institution:{name:h.name,institution_id:h.institution_id},accounts:[{id:`acct_${Math.random().toString(36).substring(7)}`,name:`${h.name} Checking`,mask:Math.floor(1e3+Math.random()*9e3).toString(),type:"depository",subtype:"checking"}],link_session_id:`link-session-${Math.random().toString(36).substring(7)}`,products:r,user_id:"user_123",public_token_id:`pub_tok_${Date.now()}`};n(g,v),t()},3500)},f=()=>{switch(i){case"connecting":return l.jsxs("div",{className:"text-center py-16",children:[l.jsx("div",{className:"w-12 h-12 mx-auto mb-4",children:c==null?void 0:c.logo}),l.jsxs("div",{className:"relative w-24 h-24 mx-auto",children:[l.jsx("div",{className:"absolute inset-0 border-2 border-gray-600 rounded-full"}),l.jsx("div",{className:"absolute inset-0 border-t-2 border-white rounded-full animate-spin"})]}),l.jsxs("h3",{className:"text-lg font-semibold text-white mt-6",children:["Connecting to ",c==null?void 0:c.name]}),l.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"This may take a few seconds..."})]});case"connected":return l.jsxs("div",{className:"text-center py-16",children:[l.jsx("div",{className:"w-12 h-12 mx-auto mb-4",children:c==null?void 0:c.logo}),l.jsx("div",{className:"w-24 h-24 mx-auto rounded-full bg-green-500/20 flex items-center justify-center",children:l.jsx("svg",{className:"h-12 w-12 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 13l4 4L19 7"})})}),l.jsx("h3",{className:"text-lg font-semibold text-white mt-6",children:"Connected!"}),l.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"You're all set."})]});case"select":default:return l.jsxs("div",{children:[l.jsx("p",{className:"text-center font-semibold text-white mb-1",children:"Select your bank"}),l.jsx("p",{className:"text-center text-xs text-gray-400 mb-6",children:"By selecting your bank, you agree to the Plaid End User Privacy Policy."}),l.jsx("div",{className:"space-y-2",children:E3.map(h=>l.jsxs("button",{onClick:()=>m(h),className:"w-full flex items-center p-3 bg-gray-700/50 hover:bg-gray-700 rounded-lg transition-colors",children:[h.logo,l.jsx("span",{className:"ml-4 font-medium text-gray-200",children:h.name})]},h.name))})]})}};return l.jsx("div",{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 backdrop-blur-sm transition-opacity duration-300 ${e?"opacity-100":"opacity-0 pointer-events-none"}`,children:l.jsxs("div",{className:"bg-gray-800 rounded-lg p-6 max-w-sm w-full border border-gray-700 shadow-2xl",children:[l.jsxs("div",{className:"flex justify-between items-center mb-6",children:[l.jsx(Mse,{}),l.jsx("button",{onClick:t,className:"text-gray-500 hover:text-white",children:"×"})]}),f()]})})},Ise=({onSuccess:e,products:t})=>{const[n,r]=S.useState(!1);return l.jsxs(l.Fragment,{children:[l.jsxs("button",{onClick:()=>r(!0),className:"w-full flex justify-center items-center py-3 px-4 border border-transparent rounded-lg shadow-sm text-sm font-medium text-white bg-[#000000] hover:bg-gray-900 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-cyan-500",children:[l.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"mr-2",children:[l.jsx("path",{d:"M16.5 10.5c0 .828-.672 1.5-1.5 1.5s-1.5-.672-1.5-1.5.672-1.5 1.5-1.5 1.5.672 1.5 1.5Z",fill:"#fff"}),l.jsx("path",{d:"M12.75 10.5c0 2.761-2.239 5-5 5s-5-2.239-5-5 2.239-5 5-5 5 2.239 5 5ZM7.75 12.5a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z",fill:"#fff"}),l.jsx("path",{d:"M21.25 10.5c0 2.761-2.239 5-5 5s-5-2.239-5-5 2.239-5 5-5 5 2.239 5 5ZM16.25 12.5a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z",fill:"#fff"})]}),"Securely Link with Plaid"]}),l.jsx(Pse,{isOpen:n,onClose:()=>r(!1),onSuccess:e,products:t})]})},kse=()=>{const[e,t]=S.useState([]),n=S.useRef(Pl.getInstance()),[r,i]=S.useState(""),o=async(u,m)=>{const f=await n.current.exchangePublicToken(u,m);t(h=>[...h,f])};return l.jsxs("div",{className:"space-y-8",children:[l.jsxs(pe,{title:"The Financial Democracy Toolkit",children:[l.jsx("p",{className:"text-gray-300",children:"This is the toolkit promised in our manifesto. Below are the production-grade components you can use to build your own financial applications. They are designed to be robust, secure, and incredibly easy to implement."}),l.jsxs("div",{className:"relative mt-4",children:[l.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:l.jsx("svg",{className:"h-5 w-5 text-gray-400",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:l.jsx("path",{fillRule:"evenodd",d:"M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z",clipRule:"evenodd"})})}),l.jsx("input",{type:"text",name:"search",id:"search",className:"block w-full bg-gray-900/50 border border-gray-600 rounded-md py-2 pl-10 pr-3 text-sm placeholder-gray-400 text-white focus:outline-none focus:ring-1 focus:ring-cyan-500 focus:border-cyan-500",placeholder:"Search the toolkit (e.g., 'Plaid Button', 'Transaction Component')...",value:r,onChange:u=>i(u.target.value)})]})]}),l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[l.jsx(pe,{title:"Live Demo: Connect Your Bank",children:l.jsxs("div",{className:"space-y-4",children:[l.jsx("p",{className:"text-sm text-gray-400",children:"Experience the seamless, secure connection flow. This is a high-fidelity simulation of the Plaid Link integration, ready to be dropped into your application."}),l.jsx(Ise,{onSuccess:o}),l.jsxs("div",{className:"pt-4",children:[l.jsx("h4",{className:"font-semibold text-white mb-2",children:"Connected Institutions:"}),e.length===0?l.jsx("p",{className:"text-sm text-gray-500 text-center py-4",children:"No institutions linked yet."}):l.jsx("div",{className:"space-y-3",children:e.map(u=>l.jsxs("div",{className:"p-3 bg-gray-900/50 rounded-lg",children:[l.jsx("p",{className:"font-semibold text-white",children:u.name}),l.jsxs("p",{className:"text-xs text-gray-400",children:["Accounts: ",u.connectedAccounts.map(m=>m.name).join(", ")]})]},u.id))})]})]})}),l.jsxs(pe,{title:"Implementation: 10 Lines of Code",children:[l.jsx("p",{className:"text-sm text-gray-400 mb-4",children:"Adding a bank connection to your app is as simple as using our `PlaidLinkButton` component. We handle the complexity, you focus on your idea."}),l.jsxs("div",{className:"bg-gray-900 rounded-lg overflow-hidden",children:[l.jsx("div",{className:"p-2 bg-gray-800 text-xs text-gray-400",children:"YourAwesomeApp.tsx"}),l.jsx("pre",{className:"p-4 text-xs text-white overflow-x-auto",children:l.jsx("code",{children:` +import React from 'react'; +import PlaidLinkButton from './PlaidLinkButton'; // Assuming export + +const MyAwesomeApp = () => { + + const handleSuccess = (publicToken, metadata) => { + console.log("It's that easy!", metadata.institution.name); + // Now, send the publicToken to your server to get an access token. + }; + + return ( +
+

My Fintech App

+ +
+ ); +}; + `.trim()})})]})]})]}),l.jsxs(pe,{title:"Developer API Keys",children:[l.jsx("p",{className:"text-sm text-gray-400 mb-4",children:"Generate API keys to integrate our toolkit directly into your backend services. This is a simulation of a developer portal."}),l.jsxs("div",{className:"p-3 bg-gray-900/50 rounded-lg",children:[l.jsx("p",{className:"font-semibold text-white",children:"My Sandbox Key"}),l.jsx("p",{className:"text-xs text-gray-400 font-mono bg-gray-800 p-2 rounded mt-2",children:"sk_sandbox_123abc456def789ghi_".padEnd(40,"*")})]})]})]})},av=["Initializing Veo 2.0 model...","Analyzing prompt semantics...","Generating initial keyframes...","Rendering motion vectors...","Upscaling to high resolution...","Adding audio layer...","Finalizing video file..."];class Dse{constructor(){this.projects=[],this.latency=500,this.loadFromLocalStorage()}async simulateLatency(){return new Promise(t=>setTimeout(t,this.latency))}saveToLocalStorage(){try{localStorage.setItem("ai_ad_studio_projects",JSON.stringify(this.projects))}catch(t){console.error("Failed to save projects to local storage:",t)}}loadFromLocalStorage(){try{const t=localStorage.getItem("ai_ad_studio_projects");if(t)this.projects=JSON.parse(t);else{const n={id:`proj_${Date.now()}`,name:"My First Campaign",creationDate:new Date().toISOString(),lastModified:new Date().toISOString(),assets:[]};this.projects.push(n),this.saveToLocalStorage()}}catch(t){console.error("Failed to load projects from local storage:",t),this.projects=[]}}async getProjects(){return await this.simulateLatency(),JSON.parse(JSON.stringify(this.projects))}async createProject(t){await this.simulateLatency();const n={id:`proj_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,name:t,creationDate:new Date().toISOString(),lastModified:new Date().toISOString(),assets:[]};return this.projects.push(n),this.saveToLocalStorage(),{...n}}async renameProject(t,n){await this.simulateLatency();const r=this.projects.find(i=>i.id===t);return r?(r.name=n,r.lastModified=new Date().toISOString(),this.saveToLocalStorage(),{...r}):null}async deleteProject(t){await this.simulateLatency();const n=this.projects.length;return this.projects=this.projects.filter(r=>r.id!==t),this.saveToLocalStorage(),this.projects.lengtho.id===t);if(!r)throw new Error("Project not found");const i={...n,id:`asset_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,projectId:t,creationDate:new Date().toISOString()};return r.assets.unshift(i),r.lastModified=new Date().toISOString(),this.saveToLocalStorage(),{...i}}async deleteAsset(t,n){await this.simulateLatency();const r=this.projects.find(i=>i.id===t);if(r){const i=r.assets.length;return r.assets=r.assets.filter(o=>o.id!==n),r.lastModified=new Date().toISOString(),this.saveToLocalStorage(),r.assets.lengthi.id===t);if(r){const i=r.assets.find(o=>o.id===n);if(i)return i.isFavorite=!i.isFavorite,r.lastModified=new Date().toISOString(),this.saveToLocalStorage(),{...i}}return null}}const es=new Dse,JI=()=>`id_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,Nx=e=>{try{return new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return"Invalid Date"}},Rse=e=>{switch(e){case"16:9":return"aspect-video";case"9:16":return"aspect-[9/16]";case"1:1":return"aspect-square";case"4:5":return"aspect-[4/5]";case"21:9":return"aspect-[21/9]";default:return"aspect-video"}},Uj={projects:[],currentProjectId:null,isLoading:!0,error:null,config:{apiKey:null,theme:"dark",autoSave:!0,defaultSettings:{model:"veo-3.1-fast-generate-preview",aspectRatio:"16:9",duration:10,negativePrompt:"blurry, low quality, watermark, text",seed:-1,highFidelity:!0,stylizationStrength:70}}},Ose=(e,t)=>{switch(t.type){case"SET_PROJECTS":const n=t.payload.length>0?t.payload[0].id:null;return{...e,projects:t.payload,currentProjectId:e.currentProjectId||n,isLoading:!1};case"SET_CURRENT_PROJECT":return{...e,currentProjectId:t.payload};case"ADD_PROJECT":return{...e,projects:[...e.projects,t.payload]};case"UPDATE_PROJECT":return{...e,projects:e.projects.map(o=>o.id===t.payload.id?t.payload:o)};case"REMOVE_PROJECT":const r=e.projects.filter(o=>o.id!==t.payload),i=e.currentProjectId===t.payload?r.length>0?r[0].id:null:e.currentProjectId;return{...e,projects:r,currentProjectId:i};case"ADD_ASSET":case"REMOVE_ASSET":case"UPDATE_ASSET":return{...e,projects:e.projects.map(o=>{if(o.id!==t.payload.projectId)return o;let c;return t.type==="ADD_ASSET"?c=[t.payload.asset,...o.assets]:t.type==="REMOVE_ASSET"?c=o.assets.filter(u=>u.id!==t.payload.assetId):c=o.assets.map(u=>u.id===t.payload.asset.id?t.payload.asset:u),{...o,assets:c,lastModified:new Date().toISOString()}})};case"SET_LOADING":return{...e,isLoading:t.payload};case"SET_ERROR":return{...e,error:t.payload,isLoading:!1};case"UPDATE_CONFIG":return{...e,config:{...e.config,...t.payload}};default:return e}},Lse=({projects:e,currentProjectId:t,onSelectProject:n,onCreateProject:r,onDeleteProject:i,onRenameProject:o})=>{const[c,u]=S.useState(""),[m,f]=S.useState(null),[h,g]=S.useState(""),v=()=>{c.trim()&&(r(c.trim()),u(""))},b=T=>{h.trim()&&m&&o(T,h.trim()),f(null),g("")};return l.jsxs("div",{className:"bg-gray-800/50 border-r border-gray-700 w-64 p-4 flex flex-col h-full",children:[l.jsx("h3",{className:"text-xl font-bold text-white mb-4",children:"Projects"}),l.jsxs("div",{className:"flex mb-4",children:[l.jsx("input",{type:"text",value:c,onChange:T=>u(T.target.value),onKeyPress:T=>T.key==="Enter"&&v(),placeholder:"New Campaign Name...",className:"flex-grow bg-gray-700 border border-gray-600 rounded-l-md p-2 text-sm text-white focus:outline-none focus:ring-2 focus:ring-cyan-500"}),l.jsx("button",{onClick:v,className:"bg-cyan-600 hover:bg-cyan-700 text-white p-2 rounded-r-md text-sm",children:"+"})]}),l.jsx("ul",{className:"space-y-2 overflow-y-auto flex-grow",children:e.map(T=>l.jsx("li",{children:l.jsxs("div",{className:`group flex items-center justify-between p-2 rounded-md cursor-pointer ${t===T.id?"bg-cyan-600/30 text-cyan-300":"text-gray-300 hover:bg-gray-700/50"}`,onClick:()=>n(T.id),children:[m===T.id?l.jsx("input",{type:"text",value:h,onChange:C=>g(C.target.value),onBlur:()=>b(T.id),onKeyPress:C=>C.key==="Enter"&&b(T.id),className:"bg-gray-600 text-white w-full text-sm p-1 rounded",autoFocus:!0}):l.jsx("span",{className:"truncate text-sm",children:T.name}),l.jsxs("div",{className:"flex items-center space-x-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[l.jsx("button",{onClick:C=>{C.stopPropagation(),f(T.id),g(T.name)},className:"text-gray-400 hover:text-white text-xs",children:"✏️"}),l.jsx("button",{onClick:C=>{C.stopPropagation(),window.confirm(`Are you sure you want to delete "${T.name}"?`)&&i(T.id)},className:"text-gray-400 hover:text-red-500 text-xs",children:"🗑️"})]})]})},T.id))})]})},Use=({settings:e,onSettingsChange:t,isGenerating:n})=>l.jsx(pe,{title:"Generation Parameters",children:l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"AI Model"}),l.jsxs("select",{value:e.model,onChange:r=>t({model:r.target.value}),disabled:n,className:"w-full bg-gray-700/50 border border-gray-600 rounded-lg p-2 text-white text-sm",children:[l.jsx("option",{value:"veo-3.1-fast-generate-preview",children:"Veo 2.0 (High Quality)"}),l.jsx("option",{value:"imagen-video-3-hq",children:"Imagen Video 3 (Creative)"}),l.jsx("option",{value:"lumiere-hd-001",children:"Lumiere HD (Realistic)"}),l.jsx("option",{value:"phoenix-v1-fast",children:"Phoenix v1 (Fast Draft)"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Aspect Ratio"}),l.jsxs("select",{value:e.aspectRatio,onChange:r=>t({aspectRatio:r.target.value}),disabled:n,className:"w-full bg-gray-700/50 border border-gray-600 rounded-lg p-2 text-white text-sm",children:[l.jsx("option",{value:"16:9",children:"16:9 (Widescreen)"}),l.jsx("option",{value:"9:16",children:"9:16 (Vertical)"}),l.jsx("option",{value:"1:1",children:"1:1 (Square)"}),l.jsx("option",{value:"4:5",children:"4:5 (Portrait)"}),l.jsx("option",{value:"21:9",children:"21:9 (Cinematic)"})]})]}),l.jsxs("div",{children:[l.jsxs("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:["Duration (s): ",e.duration]}),l.jsx("input",{type:"range",min:"2",max:"30",step:"1",value:e.duration,onChange:r=>t({duration:parseInt(r.target.value,10)}),disabled:n,className:"w-full h-2 bg-gray-600 rounded-lg appearance-none cursor-pointer"})]}),l.jsxs("div",{className:"lg:col-span-1",children:[l.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Seed"}),l.jsxs("div",{className:"flex",children:[l.jsx("input",{type:"number",value:e.seed===-1?"":e.seed,onChange:r=>t({seed:parseInt(r.target.value,10)||-1}),placeholder:"Random",disabled:n,className:"w-full bg-gray-700/50 border border-gray-600 rounded-l-lg p-2 text-white text-sm"}),l.jsx("button",{onClick:()=>t({seed:-1}),className:"bg-gray-600 hover:bg-gray-500 p-2 rounded-r-lg text-sm",disabled:n,children:"🎲"})]})]}),l.jsxs("div",{className:"lg:col-span-2",children:[l.jsxs("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:["Stylization Strength: ",e.stylizationStrength,"%"]}),l.jsx("input",{type:"range",min:"0",max:"100",step:"1",value:e.stylizationStrength,onChange:r=>t({stylizationStrength:parseInt(r.target.value,10)}),disabled:n,className:"w-full h-2 bg-gray-600 rounded-lg appearance-none cursor-pointer"})]}),l.jsxs("div",{className:"col-span-full",children:[l.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Negative Prompt"}),l.jsx("input",{type:"text",value:e.negativePrompt,onChange:r=>t({negativePrompt:r.target.value}),placeholder:"e.g., blurry, text, watermark, ugly",disabled:n,className:"w-full bg-gray-700/50 border border-gray-600 rounded-lg p-2 text-white text-sm"})]}),l.jsx("div",{className:"col-span-full",children:l.jsxs("label",{className:"flex items-center space-x-2 text-sm text-gray-300",children:[l.jsx("input",{type:"checkbox",checked:e.highFidelity,onChange:r=>t({highFidelity:r.target.checked}),disabled:n,className:"h-4 w-4 rounded border-gray-500 bg-gray-700 text-cyan-600 focus:ring-cyan-500"}),l.jsx("span",{children:"High Fidelity Mode (Slower, higher quality)"})]})})]})}),Bse=({assets:e,onDelete:t,onToggleFavorite:n,onSelect:r})=>e.length===0?l.jsxs("div",{className:"text-center py-16 text-gray-500",children:[l.jsx("p",{children:"No video assets in this project yet."}),l.jsx("p",{children:"Generate a new video to get started."})]}):l.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4",children:e.map(i=>l.jsxs("div",{className:"group relative aspect-video bg-gray-800 rounded-lg overflow-hidden border border-gray-700",children:[l.jsx("video",{src:i.url,muted:!0,loop:!0,className:"w-full h-full object-cover",onMouseOver:o=>o.currentTarget.play(),onMouseOut:o=>o.currentTarget.pause()}),l.jsxs("div",{className:"absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity flex flex-col justify-between p-2",children:[l.jsxs("div",{className:"flex justify-end space-x-2",children:[l.jsx("button",{onClick:()=>n(i.id),className:`text-xl ${i.isFavorite?"text-yellow-400":"text-white/70 hover:text-white"}`,children:i.isFavorite?"★":"☆"}),l.jsx("button",{onClick:()=>t(i.id),className:"text-white/70 hover:text-red-500",children:"🗑️"})]}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-white truncate",children:i.prompt}),l.jsx("p",{className:"text-xs text-gray-400",children:Nx(i.creationDate)}),l.jsx("button",{onClick:()=>r(i),className:"mt-1 w-full text-xs bg-cyan-600/80 hover:bg-cyan-600/100 text-white py-1 rounded",children:"View Details"})]})]})]},i.id))}),zse=({scenes:e,setScenes:t,isGenerating:n})=>{const r=()=>{t(m=>[...m,{id:JI(),prompt:"",duration:5}])},i=(m,f)=>{t(h=>h.map(g=>g.id===m?{...g,prompt:f}:g))},o=(m,f)=>{t(h=>h.map(g=>g.id===m?{...g,duration:f}:g))},c=m=>{t(f=>f.filter(h=>h.id!==m))},u=S.useMemo(()=>e.reduce((m,f)=>m+f.duration,0),[e]);return l.jsxs("div",{className:"space-y-4",children:[e.map((m,f)=>l.jsxs("div",{className:"flex items-start space-x-3 p-3 bg-gray-800/60 rounded-lg",children:[l.jsx("span",{className:"font-bold text-gray-400 mt-2",children:f+1}),l.jsxs("div",{className:"flex-grow space-y-2",children:[l.jsx("textarea",{value:m.prompt,onChange:h=>i(m.id,h.target.value),placeholder:`Scene ${f+1} description...`,className:"w-full h-20 bg-gray-700/50 border border-gray-600 rounded-lg p-2 text-white text-sm",disabled:n}),l.jsxs("div",{className:"flex items-center space-x-2",children:[l.jsx("label",{className:"text-xs text-gray-400",children:"Duration:"}),l.jsx("input",{type:"range",min:"1",max:"15",value:m.duration,onChange:h=>o(m.id,parseInt(h.target.value,10)),disabled:n,className:"w-32 h-1 bg-gray-600 rounded-lg appearance-none cursor-pointer"}),l.jsxs("span",{className:"text-xs text-white w-8",children:[m.duration,"s"]})]})]}),l.jsx("button",{onClick:()=>c(m.id),disabled:n||e.length<=1,className:"text-gray-400 hover:text-red-500 disabled:opacity-30 mt-2",children:"🗑️"})]},m.id)),l.jsxs("div",{className:"flex justify-between items-center",children:[l.jsx("button",{onClick:r,disabled:n,className:"py-2 px-4 text-sm bg-cyan-600/50 hover:bg-cyan-600/80 text-white rounded-lg disabled:opacity-50",children:"+ Add Scene"}),l.jsxs("p",{className:"text-sm text-gray-400",children:["Total Estimated Duration: ",u,"s"]})]})]})},Fse=()=>{const[e,t]=S.useState("A neon hologram of a cat driving a futuristic car at top speed through a cyberpunk city."),[n,r]=S.useState("idle"),[i,o]=S.useState(null),[c,u]=S.useState(""),[m,f]=S.useState(0),[h,g]=S.useState(null),[v,b]=S.useReducer(Ose,Uj),[T,C]=S.useState(Uj.config.defaultSettings),[E,N]=S.useState("single"),[I,P]=S.useState([{id:JI(),prompt:"A cinematic opening shot of a futuristic city skyline at night.",duration:5}]),[M,j]=S.useState(null),k=n==="generating"||n==="polling",R=S.useRef(null),F=S.useMemo(()=>v.projects.find(z=>z.id===v.currentProjectId),[v.projects,v.currentProjectId]);S.useEffect(()=>{es.getProjects().then(Y=>{b({type:"SET_PROJECTS",payload:Y})}).catch(Y=>{b({type:"SET_ERROR",payload:"Failed to load projects."}),console.error(Y)}),b({type:"UPDATE_CONFIG",payload:{apiKey:"PLACEHOLDER_API_KEY"}})},[]),S.useEffect(()=>()=>{h&&clearInterval(h)},[h]),S.useEffect(()=>()=>{i&&i.startsWith("blob:")&&URL.revokeObjectURL(i)},[i]);const q=S.useCallback(async z=>{try{const Y=await es.createProject(z);b({type:"ADD_PROJECT",payload:Y}),b({type:"SET_CURRENT_PROJECT",payload:Y.id})}catch{alert("Failed to create project.")}},[]),G=S.useCallback(async z=>{try{await es.deleteProject(z),b({type:"REMOVE_PROJECT",payload:z})}catch{alert("Failed to delete project.")}},[]),H=S.useCallback(async(z,Y)=>{try{const ce=await es.renameProject(z,Y);ce&&b({type:"UPDATE_PROJECT",payload:ce})}catch{alert("Failed to rename project.")}},[]),V=S.useCallback(async z=>{if(F&&window.confirm("Are you sure you want to delete this video asset?"))try{await es.deleteAsset(F.id,z),b({type:"REMOVE_ASSET",payload:{projectId:F.id,assetId:z}}),(M==null?void 0:M.id)===z&&j(null)}catch{alert("Failed to delete asset.")}},[F,M]),oe=S.useCallback(async z=>{if(F)try{const Y=await es.toggleFavoriteAsset(F.id,z);Y&&b({type:"UPDATE_ASSET",payload:{projectId:F.id,asset:Y}})}catch{alert("Failed to update favorite status.")}},[F]),Z=()=>{var Y;const z=(Y=R.current)==null?void 0:Y.value;z&&(localStorage.setItem("google_genai_api_key",z),b({type:"UPDATE_CONFIG",payload:{apiKey:z}}),alert("API Key saved. Please refresh the page if you experience issues."))},me=async()=>{var Y,ce,ge,Me;if(!v.config.apiKey){u("API Key is not set. Please add it in the settings."),r("error");return}if(!F){u("No project selected. Please create or select a project first."),r("error");return}r("generating"),u(""),i&&i.startsWith("blob:")&&URL.revokeObjectURL(i),o(null),f(0),h&&clearInterval(h);const z=E==="single"?e:I.map(U=>U.prompt).join(" | ");try{const U=new ar({apiKey:v.config.apiKey}),te={model:T.model,prompt:z,config:{numberOfVideos:1,aspectRatio:T.aspectRatio,resolution:"720p"}};console.log("Sending to AI API:",te);let ue=await U.models.generateVideos(te);r("polling");const fe=window.setInterval(()=>{f(Pe=>(Pe+1)%av.length)},2500);for(g(fe);!ue.done;)await new Promise(Pe=>setTimeout(Pe,1e4)),ue=await U.operations.getVideosOperation({operation:ue});if(clearInterval(fe),g(null),ue.error)throw new Error(String(ue.error.message)||"Video generation failed after polling.");const Ne=(Me=(ge=(ce=(Y=ue.response)==null?void 0:Y.generatedVideos)==null?void 0:ce[0])==null?void 0:ge.video)==null?void 0:Me.uri;if(Ne){f(av.length-1);const Pe=await fetch(`${Ne}&key=${v.config.apiKey}`);if(!Pe.ok)throw new Error(`Failed to download the generated video. Status: ${Pe.statusText}`);const Re=await Pe.blob(),wt=URL.createObjectURL(Re);o(wt),r("done");const re={url:wt,prompt:z,settings:T,generationMode:E,storyboard:E==="storyboard"?I:void 0,isFavorite:!1},Le=await es.addAssetToProject(F.id,re);b({type:"ADD_ASSET",payload:{projectId:F.id,asset:Le}})}else throw new Error("Video generation completed, but no download link was found in the response.")}catch(U){console.error("Video generation failed:",U),u(String((U==null?void 0:U.message)||"An error occurred during video generation.")),r("error"),h&&(clearInterval(h),g(null))}};return v.isLoading?l.jsx("div",{className:"text-white text-center p-10",children:"Loading Ad Studio..."}):v.config.apiKey?l.jsxs("div",{className:"flex h-[calc(100vh-4rem)] bg-gray-900 text-white",children:[l.jsx(Lse,{projects:v.projects,currentProjectId:v.currentProjectId,onSelectProject:z=>b({type:"SET_CURRENT_PROJECT",payload:z}),onCreateProject:q,onDeleteProject:G,onRenameProject:H}),l.jsxs("main",{className:"flex-1 p-6 space-y-6 overflow-y-auto",children:[l.jsxs("div",{className:"flex justify-between items-center",children:[l.jsx("h2",{className:"text-3xl font-bold text-white tracking-wider",children:"AI Ad Studio"}),l.jsxs("div",{className:"text-right",children:[l.jsx("h3",{className:"text-lg font-semibold",children:(F==null?void 0:F.name)||"No Project Selected"}),l.jsxs("p",{className:"text-sm text-gray-400",children:["Last Modified: ",F?Nx(F.lastModified):"N/A"]})]})]}),F?l.jsxs(l.Fragment,{children:[l.jsx(pe,{title:"Generate a Custom Video Ad with Veo 2.0",children:l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex bg-gray-800/50 rounded-lg p-1",children:[l.jsx("button",{onClick:()=>N("single"),className:`flex-1 py-1 rounded-md text-sm ${E==="single"?"bg-cyan-600":""}`,children:"Single Prompt"}),l.jsx("button",{onClick:()=>N("storyboard"),className:`flex-1 py-1 rounded-md text-sm ${E==="storyboard"?"bg-cyan-600":""}`,children:"Storyboard"})]}),E==="single"?l.jsx("textarea",{value:e,onChange:z=>t(z.target.value),placeholder:"Describe your ad...",className:"w-full h-32 bg-gray-700/50 border border-gray-600 rounded-lg p-2 text-white"}):l.jsx(zse,{scenes:I,setScenes:P,isGenerating:k}),l.jsx("button",{onClick:me,disabled:k,className:"w-full py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg disabled:opacity-50 disabled:cursor-not-allowed",children:k?"Generating...":"Generate Ad"})]}),l.jsx("div",{className:` ${Rse(T.aspectRatio)} mx-auto max-h-[50vh] w-full bg-gray-900/50 rounded-lg flex items-center justify-center border border-gray-700`,children:n==="done"&&i?l.jsx("video",{src:i,controls:!0,autoPlay:!0,muted:!0,loop:!0,className:"w-full h-full rounded-lg object-contain"}):n==="generating"||n==="polling"?l.jsxs("div",{className:"text-center",children:[l.jsxs("div",{className:"relative w-16 h-16 mx-auto",children:[l.jsx("div",{className:"absolute inset-0 border-4 border-cyan-500/30 rounded-full"}),l.jsx("div",{className:"absolute inset-2 border-4 border-t-cyan-500 border-transparent rounded-full animate-spin"})]}),l.jsx("p",{className:"text-white mt-4",children:av[m]})]}):c?l.jsx("p",{className:"text-red-400 p-4 text-center",children:c}):l.jsx("p",{className:"text-gray-500",children:"Your generated video will appear here."})})]})}),l.jsx(Use,{settings:T,onSettingsChange:z=>C(Y=>({...Y,...z})),isGenerating:k}),l.jsx(pe,{title:"Project Asset Library",children:l.jsx(Bse,{assets:F.assets,onDelete:V,onToggleFavorite:oe,onSelect:j})})]}):l.jsx("div",{className:"flex items-center justify-center h-full",children:l.jsx("p",{className:"text-gray-500 text-lg",children:"Please select or create a project to begin."})})]}),M&&l.jsx("div",{className:"fixed inset-0 bg-black/70 z-50 flex items-center justify-center",onClick:()=>j(null),children:l.jsxs("div",{className:"bg-gray-800 rounded-lg max-w-4xl w-full p-6 space-y-4 m-4",onClick:z=>z.stopPropagation(),children:[l.jsx("h3",{className:"text-xl font-bold text-white",children:"Asset Details"}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[l.jsx("div",{children:l.jsx("video",{src:M.url,controls:!0,autoPlay:!0,loop:!0,muted:!0,className:"w-full rounded-lg"})}),l.jsxs("div",{className:"text-sm space-y-3 text-gray-300",children:[l.jsxs("p",{children:[l.jsx("strong",{children:"Prompt:"})," ",M.prompt]}),l.jsxs("p",{children:[l.jsx("strong",{children:"Generated:"})," ",Nx(M.creationDate)]}),l.jsxs("p",{children:[l.jsx("strong",{children:"Model:"})," ",M.settings.model]}),l.jsxs("p",{children:[l.jsx("strong",{children:"Aspect Ratio:"})," ",M.settings.aspectRatio]}),l.jsxs("p",{children:[l.jsx("strong",{children:"Duration:"})," ",M.settings.duration,"s"]}),l.jsxs("p",{children:[l.jsx("strong",{children:"Seed:"})," ",M.settings.seed]}),M.settings.negativePrompt&&l.jsxs("p",{children:[l.jsx("strong",{children:"Negative Prompt:"})," ",M.settings.negativePrompt]}),l.jsxs("p",{children:[l.jsx("strong",{children:"High Fidelity:"})," ",M.settings.highFidelity?"Yes":"No"]})]})]}),l.jsxs("div",{className:"flex justify-end space-x-4",children:[l.jsx("a",{href:M.url,download:`ai-ad-${M.id}.mp4`,className:"py-2 px-4 bg-gray-600 hover:bg-gray-500 text-white rounded-lg",children:"Download"}),l.jsx("button",{onClick:()=>j(null),className:"py-2 px-4 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg",children:"Close"})]})]})})]}):l.jsx("div",{className:"h-screen w-screen flex items-center justify-center bg-gray-900",children:l.jsxs("div",{className:"max-w-md w-full bg-gray-800 p-8 rounded-lg shadow-lg",children:[l.jsx("h2",{className:"text-2xl font-bold text-white mb-4",children:"API Key Required"}),l.jsx("p",{className:"text-gray-400 mb-6",children:"Please enter your Google GenAI API key to use the AI Ad Studio."}),l.jsxs("div",{className:"space-y-4",children:[l.jsx("input",{ref:R,type:"password",placeholder:"Enter your API key here",className:"w-full bg-gray-700 border border-gray-600 rounded-lg p-2 text-white"}),l.jsx("button",{onClick:Z,className:"w-full py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg",children:"Save API Key"})]})]})})},qse=()=>{const e=S.useContext(Ct);if(!e)throw new Error("CryptoView must be within a DataProvider.");const{cryptoAssets:t,walletInfo:n,virtualCard:r,connectWallet:i,disconnectWallet:o,detectedProviders:c,issueCard:u,buyCrypto:m,nftAssets:f}=e,[h,g]=S.useState(!1),[v,b]=S.useState(!1),[T,C]=S.useState(!1),[E,N]=S.useState("100"),I=()=>{g(!0),setTimeout(()=>{u(),g(!1)},2e3)},P=R=>{i(R),b(!1)},M=()=>{m(parseFloat(E),"ETH"),C(!1)},j=R=>`${R.substring(0,6)}...${R.substring(R.length-4)}`,k=({isOpen:R,onClose:F})=>R?l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 backdrop-blur-sm",onClick:F,children:l.jsxs("div",{className:"bg-gray-800 rounded-lg shadow-2xl max-w-sm w-full border border-gray-700 flex flex-col",onClick:q=>q.stopPropagation(),children:[l.jsx("div",{className:"p-4 border-b border-gray-700 text-center",children:l.jsx("h3",{className:"font-semibold text-white",children:"Connect Wallet"})}),l.jsx("div",{className:"p-4 flex-grow flex flex-col gap-3",children:c.length>0?c.map(q=>l.jsxs("button",{onClick:()=>P(q),className:"flex items-center p-3 bg-gray-700 hover:bg-gray-600 rounded-lg transition-colors",children:[l.jsx("img",{src:q.info.icon,alt:q.info.name,className:"w-8 h-8 mr-3"}),l.jsx("span",{className:"text-white font-medium",children:q.info.name})]},q.info.uuid)):l.jsxs("div",{className:"text-center py-4 text-gray-400",children:[l.jsx("p",{children:"No wallets detected."}),l.jsx("p",{className:"text-xs mt-2",children:"Please install MetaMask or another EIP-6963 compatible wallet."})]})}),l.jsx("div",{className:"p-4 bg-gray-900/50 text-center",children:l.jsx("button",{onClick:F,className:"text-gray-400 hover:text-white text-sm",children:"Cancel"})})]})}):null;return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"flex justify-between items-start flex-col lg:flex-row",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-3xl font-bold text-white tracking-wider",children:"Crypto & Web3 Hub"}),l.jsx("p",{className:"text-gray-400 mt-1",children:"Your unified gateway to the decentralized world."})]}),l.jsx("div",{className:"flex flex-col sm:flex-row items-center space-y-4 sm:space-y-0 sm:space-x-4 mt-4 lg:mt-0",children:l.jsx(pe,{title:"",className:"!p-0 !bg-transparent !border-none",children:l.jsx("div",{className:"flex flex-col items-center justify-center text-center h-full",children:n?l.jsxs("div",{className:"bg-gray-800/80 px-4 py-2 rounded-lg text-left flex items-center gap-4 border border-green-500/30",children:[l.jsxs("div",{children:[l.jsxs("p",{className:"text-sm text-green-400 font-semibold flex items-center gap-2",children:[l.jsx("span",{className:"w-2 h-2 rounded-full bg-green-400 animate-pulse"})," Connected"]}),l.jsx("p",{className:"text-sm text-gray-300 font-mono break-all",children:j(n.address)}),l.jsxs("p",{className:"text-md text-white font-bold",children:[n.balance.toFixed(4)," ETH"]})]}),l.jsx("button",{onClick:o,className:"text-xs text-red-400 hover:text-red-300 underline",children:"Disconnect"})]}):l.jsx("button",{onClick:()=>b(!0),className:"bg-orange-500 hover:bg-orange-600 text-white font-bold py-2 px-4 rounded-lg shadow-lg shadow-orange-500/20 transition-all",children:"Connect Wallet"})})})})]}),l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[l.jsx(pe,{title:"Portfolio Distribution",className:"lg:col-span-2",children:l.jsx("div",{className:"h-64",children:l.jsx(Pn,{width:"100%",height:"100%",children:l.jsxs(D1,{children:[l.jsx(Wh,{data:t,cx:"50%",cy:"50%",innerRadius:60,outerRadius:80,paddingAngle:5,dataKey:"value",children:t.map((R,F)=>l.jsx(Ls,{fill:R.color},`cell-${F}`))}),l.jsx(at,{contentStyle:{backgroundColor:"#1f2937",border:"none"},formatter:R=>`$${R.toLocaleString()}`}),l.jsx(Rn,{})]})})})}),l.jsxs("div",{className:"space-y-6",children:[l.jsx(pe,{title:"Virtual Card",subtitle:"Web3-enabled payments",children:l.jsx("div",{className:"flex flex-col items-center justify-center text-center h-full min-h-[15rem]",children:r?l.jsxs("div",{className:"w-full max-w-sm aspect-[85.6/54] rounded-xl p-4 flex flex-col justify-between bg-gradient-to-br from-cyan-900 via-gray-900 to-indigo-900 border border-cyan-500/30 shadow-2xl",children:[l.jsx("div",{className:"flex justify-between items-start",children:l.jsx("p",{className:"font-semibold text-white",children:"Quantum Card"})}),l.jsxs("div",{children:[l.jsx("p",{className:"font-mono text-lg text-white tracking-widest text-left",children:r.cardNumber}),l.jsxs("div",{className:"flex justify-between text-xs font-mono text-gray-300 mt-2",children:[l.jsx("span",{children:r.holderName.toUpperCase()}),l.jsxs("span",{children:["EXP: ",r.expiry]}),l.jsxs("span",{children:["CVV: ",r.cvv]})]})]})]}):l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-gray-400 mb-4",children:"Issue a virtual card to spend your crypto assets anywhere."}),l.jsx("button",{onClick:I,disabled:h,className:"w-full bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-2 px-4 rounded-lg disabled:opacity-50 transition-colors",children:h?"Issuing Card...":"Issue Virtual Card"})]})})}),l.jsx(pe,{title:"Buy Crypto (On-Ramp)",children:l.jsxs("div",{className:"flex flex-col items-center justify-center text-center",children:[l.jsx("p",{className:"text-gray-400 text-sm mb-4",children:"Buy crypto directly via Stripe integration."}),l.jsxs("div",{className:"flex items-center mb-4 w-full bg-gray-700/50 rounded-lg px-3 py-2",children:[l.jsx("span",{className:"text-xl font-bold text-white mr-2",children:"$"}),l.jsx("input",{type:"number",value:E,onChange:R=>N(R.target.value),className:"w-full text-xl font-bold text-white bg-transparent focus:outline-none"})]}),l.jsx("button",{onClick:()=>C(!0),className:"w-full bg-purple-600 hover:bg-purple-700 text-white font-bold py-2 px-4 rounded-lg transition-colors",children:"Buy with Stripe"})]})})]})]}),l.jsx(pe,{title:"NFT Gallery",children:f.length>0?l.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:f.map(R=>l.jsxs("div",{className:"bg-gray-800 rounded-lg overflow-hidden border border-gray-700 group hover:border-cyan-500 transition-colors",children:[l.jsx("img",{src:R.imageUrl,alt:R.name,className:"w-full h-32 object-cover group-hover:scale-105 transition-transform duration-500"}),l.jsxs("div",{className:"p-3",children:[l.jsx("p",{className:"text-white font-medium truncate",children:R.name}),l.jsx("p",{className:"text-xs text-gray-500 truncate",children:R.contractAddress})]})]},R.id))}):l.jsx("p",{className:"text-gray-500 text-center py-8",children:"No NFTs in your collection yet."})}),l.jsx(k,{isOpen:v,onClose:()=>b(!1)}),T&&l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 backdrop-blur-sm",onClick:()=>C(!1),children:l.jsxs("div",{className:"bg-gray-900 rounded-lg shadow-2xl max-w-md w-full border border-gray-700 flex flex-col",onClick:R=>R.stopPropagation(),children:[l.jsxs("div",{className:"p-6 bg-gray-800 rounded-t-lg border-b border-gray-700",children:[l.jsx("h3",{className:"font-semibold text-white text-lg",children:"Stripe Payment"}),l.jsxs("p",{className:"text-3xl font-bold text-white mt-2",children:["$",parseFloat(E).toFixed(2)]})]}),l.jsxs("div",{className:"p-6 space-y-4",children:[l.jsxs("div",{className:"bg-gray-800 p-3 rounded border border-gray-600",children:[l.jsx("p",{className:"text-xs text-gray-400",children:"Card Number"}),l.jsx("p",{className:"text-white font-mono",children:"**** **** **** 4242"})]}),l.jsxs("div",{className:"flex gap-4",children:[l.jsxs("div",{className:"bg-gray-800 p-3 rounded border border-gray-600 flex-1",children:[l.jsx("p",{className:"text-xs text-gray-400",children:"Expiry"}),l.jsx("p",{className:"text-white font-mono",children:"12/25"})]}),l.jsxs("div",{className:"bg-gray-800 p-3 rounded border border-gray-600 flex-1",children:[l.jsx("p",{className:"text-xs text-gray-400",children:"CVC"}),l.jsx("p",{className:"text-white font-mono",children:"123"})]})]}),l.jsx("button",{onClick:M,className:"mt-4 w-full bg-purple-600 hover:bg-purple-700 text-white font-bold py-3 px-4 rounded-lg shadow-lg shadow-purple-500/20 transition-all",children:"Pay Now"})]})]})})]})},Gse=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)}),tm=Gse,wo={home:({className:e})=>l.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"})}),plane:({className:e})=>l.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})}),car:({className:e})=>l.jsxs("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:[l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 16l4-4m0 0l-4-4m4 4H3"}),l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 12H5m14 0a2 2 0 11-4 0 2 2 0 014 0z"})]}),education:({className:e})=>l.jsxs("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:[l.jsx("path",{d:"M12 14l9-5-9-5-9 5 9 5z"}),l.jsx("path",{d:"M12 14l6.16-3.422a12.083 12.083 0 01.665 6.479A11.952 11.952 0 0012 20.055a11.952 11.952 0 00-6.824-2.998 12.078 12.078 0 01.665-6.479L12 14z"}),l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 14l9-5-9-5-9 5 9 5zm0 0l6.16-3.422a12.083 12.083 0 01.665 6.479A11.952 11.952 0 0012 20.055a11.952 11.952 0 00-6.824-2.998 12.078 12.078 0 01.665-6.479L12 14zm-4 6v-7.5l4-2.222 4 2.222V20"})]}),default:({className:e})=>l.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.196-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.783-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z"})}),retirement:({className:e})=>l.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),investment:({className:e})=>l.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 7h8m0 0v8m0-8l-8 8-4-4-6 6"})}),gift:({className:e})=>l.jsx("svg",{className:e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v13m0-13V6a2 2 0 112 2h-2zm0 0V5.5A2.5 2.5 0 109.5 8H12zm-7 4h14M5 12a2 2 0 110-4h14a2 2 0 110 4M5 12v7a2 2 0 002 2h10a2 2 0 002-2v-7"})})},$se=Object.keys(wo),wa=e=>{const t={year:"numeric",month:"long",day:"numeric"};return new Date(e).toLocaleDateString(void 0,t)},vd=(e,t)=>{let n;return n=(t.getFullYear()-e.getFullYear())*12,n-=e.getMonth(),n+=t.getMonth(),n<0||n===0&&t.getDate()0};const n=t[0].length,r=t.length,i=[],o=[],c=[];for(let f=0;fg[f]).sort((g,v)=>g-v);i.push(h[Math.floor(r*.5)]),o.push(h[Math.floor(r*.1)]),c.push(h[Math.floor(r*.9)])}const u=t.map(f=>f[f.length-1]);return{medianPath:i,p10Path:o,p90Path:c,finalOutcomes:u,successProbability:f=>u.filter(g=>g>=f).length/r*100}}}const np=({isOpen:e,onClose:t,title:n,children:r})=>{if(!e)return null;const i=S.useRef(null),o=c=>{i.current&&!i.current.contains(c.target)&&t()};return l.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-75 flex justify-center items-center z-50 p-4",onClick:o,children:l.jsxs("div",{ref:i,className:"bg-gray-800 rounded-lg shadow-xl p-6 w-full max-w-md mx-auto my-auto max-h-[90vh] flex flex-col",children:[l.jsxs("div",{className:"flex justify-between items-center mb-4",children:[l.jsx("h3",{className:"text-xl font-bold text-white",children:n}),l.jsx("button",{onClick:t,className:"text-gray-400 hover:text-white transition-colors duration-200",children:l.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})})})]}),l.jsx("div",{className:"overflow-y-auto flex-grow",children:r})]})})},_x=({active:e,payload:t,label:n})=>e&&t&&t.length?l.jsxs("div",{className:"p-4 bg-gray-900 border border-gray-700 rounded-lg shadow-lg text-sm",children:[l.jsx("p",{className:"label text-gray-300 font-semibold",children:`Month: ${n}`}),t.map((r,i)=>l.jsxs("p",{style:{color:r.color},className:"intro flex items-center gap-2 mt-1",children:[l.jsx("span",{className:"inline-block w-2 h-2 rounded-full",style:{backgroundColor:r.color}}),`${r.name}: $${r.value.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:0})}`]},i))]}):null,Hse=({goal:e,onAddRecurringContribution:t,onUpdateRecurringContribution:n,onDeleteRecurringContribution:r})=>{const[i,o]=S.useState(!1),[c,u]=S.useState(""),[m,f]=S.useState("monthly"),[h,g]=S.useState(new Date().toISOString().split("T")[0]),[v,b]=S.useState(""),T=()=>{const N=parseFloat(c);!isNaN(N)&&N>0&&(t(e.id,{amount:N,frequency:m,startDate:h,endDate:v||null,isActive:!0}),u(""),b(""),o(!1))},C=N=>{n(e.id,N.id,{isActive:!N.isActive})},E=N=>{window.confirm("Are you sure you want to delete this recurring contribution?")&&r(e.id,N)};return l.jsxs(pe,{children:[l.jsxs("div",{className:"flex justify-between items-center mb-4",children:[l.jsx("h4",{className:"text-lg font-semibold text-white",children:"Recurring Contributions"}),l.jsx("button",{onClick:()=>o(!0),className:"px-3 py-1.5 bg-cyan-600 hover:bg-cyan-700 text-white rounded-md text-xs font-medium",children:"Add Recurring"})]}),l.jsx("div",{className:"max-h-96 overflow-y-auto pr-2",children:e.recurringContributions&&e.recurringContributions.length>0?l.jsx("div",{className:"space-y-3",children:e.recurringContributions.map(N=>l.jsxs("div",{className:`p-3 rounded-lg border ${N.isActive?"bg-gray-700/30 border-cyan-700":"bg-gray-800/50 border-gray-600"} flex justify-between items-center transition-all duration-200`,children:[l.jsxs("div",{children:[l.jsxs("p",{className:"text-white font-medium",children:["$",N.amount.toLocaleString()," ",l.jsxs("span",{className:"text-gray-400 text-sm",children:["per ",N.frequency.replace("-"," ")]})]}),l.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Active from ",wa(N.startDate)," ",N.endDate?`to ${wa(N.endDate)}`:"onwards"]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:`px-2 py-0.5 rounded-full text-xs font-medium ${N.isActive?"bg-green-600/20 text-green-300":"bg-red-600/20 text-red-300"}`,children:N.isActive?"Active":"Inactive"}),l.jsx("button",{onClick:()=>C(N),className:"text-gray-400 hover:text-white transition-colors",children:N.isActive?l.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M18.364 18.364A9 9 0 005.636 5.636m12.728 12.728A9 9 0 015.636 5.636m12.728 12.728L5.636 5.636"})}):l.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})})}),l.jsx("button",{onClick:()=>E(N.id),className:"text-gray-400 hover:text-red-500 transition-colors",children:l.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]})]},N.id))}):l.jsx("p",{className:"text-center py-8 text-gray-500",children:"No recurring contributions set up yet."})}),l.jsx(np,{isOpen:i,onClose:()=>o(!1),title:"Add Recurring Contribution",children:l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{htmlFor:"recurring-amount",className:"block text-sm font-medium text-gray-300",children:"Amount per period"}),l.jsxs("div",{className:"mt-1 relative rounded-md shadow-sm",children:[l.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:l.jsx("span",{className:"text-gray-500 sm:text-sm",children:"$"})}),l.jsx("input",{type:"number",id:"recurring-amount",value:c,onChange:N=>u(N.target.value),className:"bg-gray-900 border-gray-600 text-white block w-full pl-7 pr-12 sm:text-sm rounded-md focus:ring-cyan-500 focus:border-cyan-500",placeholder:"100.00"})]})]}),l.jsxs("div",{children:[l.jsx("label",{htmlFor:"recurring-frequency",className:"block text-sm font-medium text-gray-300",children:"Frequency"}),l.jsxs("select",{id:"recurring-frequency",value:m,onChange:N=>f(N.target.value),className:"mt-1 block w-full pl-3 pr-10 py-2 text-base border-gray-600 focus:outline-none focus:ring-cyan-500 focus:border-cyan-500 sm:text-sm rounded-md bg-gray-900 text-white",children:[l.jsx("option",{value:"monthly",children:"Monthly"}),l.jsx("option",{value:"bi-weekly",children:"Bi-Weekly"}),l.jsx("option",{value:"weekly",children:"Weekly"})]})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsxs("div",{children:[l.jsx("label",{htmlFor:"recurring-start-date",className:"block text-sm font-medium text-gray-300",children:"Start Date"}),l.jsx("input",{type:"date",id:"recurring-start-date",value:h,onChange:N=>g(N.target.value),className:"mt-1 block w-full bg-gray-900 border-gray-600 text-white rounded-md focus:ring-cyan-500 focus:border-cyan-500"})]}),l.jsxs("div",{children:[l.jsx("label",{htmlFor:"recurring-end-date",className:"block text-sm font-medium text-gray-300",children:"End Date (Optional)"}),l.jsx("input",{type:"date",id:"recurring-end-date",value:v,onChange:N=>b(N.target.value),className:"mt-1 block w-full bg-gray-900 border-gray-600 text-white rounded-md focus:ring-cyan-500 focus:border-cyan-500"})]})]}),l.jsxs("div",{className:"flex justify-end gap-3",children:[l.jsx("button",{onClick:()=>o(!1),className:"px-4 py-2 bg-gray-600 hover:bg-gray-700 text-white rounded-lg text-sm font-medium",children:"Cancel"}),l.jsx("button",{onClick:T,className:"px-4 py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg text-sm font-medium",children:"Add Recurring"})]})]})})]})},Vse=({goal:e,onAddContribution:t,onAddRecurringContribution:n,onUpdateRecurringContribution:r,onDeleteRecurringContribution:i})=>{const[o,c]=S.useState(!1),[u,m]=S.useState(""),[f,h]=S.useState("manual"),g=()=>{const v=parseFloat(u);!isNaN(v)&&v>0&&(t(e.id,v),m(""),c(!1))};return l.jsxs(pe,{children:[l.jsxs("div",{className:"flex justify-between items-center mb-4",children:[l.jsx("h4",{className:"text-lg font-semibold text-white",children:"Contribution History"}),l.jsx("button",{onClick:()=>c(!0),className:"px-3 py-1.5 bg-cyan-600 hover:bg-cyan-700 text-white rounded-md text-xs font-medium",children:"Add Manual"})]}),l.jsx("div",{className:"border-b border-gray-700 mb-4",children:l.jsxs("nav",{className:"-mb-px flex space-x-4","aria-label":"Contribution Tabs",children:[l.jsx("button",{onClick:()=>h("manual"),className:`${f==="manual"?"border-cyan-500 text-cyan-400":"border-transparent text-gray-400 hover:text-gray-200 hover:border-gray-500"} whitespace-nowrap py-2 px-1 border-b-2 font-medium text-sm transition-colors`,children:"Manual Contributions"}),l.jsx("button",{onClick:()=>h("recurring"),className:`${f==="recurring"?"border-cyan-500 text-cyan-400":"border-transparent text-gray-400 hover:text-gray-200 hover:border-gray-500"} whitespace-nowrap py-2 px-1 border-b-2 font-medium text-sm transition-colors`,children:"Recurring Setups"})]})}),f==="manual"&&l.jsx("div",{className:"max-h-96 overflow-y-auto pr-2",children:l.jsxs("table",{className:"w-full text-sm text-left text-gray-400",children:[l.jsx("thead",{className:"text-xs text-gray-300 uppercase bg-gray-700/50 sticky top-0",children:l.jsxs("tr",{children:[l.jsx("th",{scope:"col",className:"px-4 py-3",children:"Date"}),l.jsx("th",{scope:"col",className:"px-4 py-3",children:"Amount"}),l.jsx("th",{scope:"col",className:"px-4 py-3",children:"Type"})]})}),l.jsx("tbody",{children:e.contributions.length>0?e.contributions.sort((v,b)=>new Date(b.date).getTime()-new Date(v.date).getTime()).map(v=>l.jsxs("tr",{className:"border-b border-gray-700 hover:bg-gray-700/30",children:[l.jsx("td",{className:"px-4 py-3",children:wa(v.date)}),l.jsxs("td",{className:"px-4 py-3 text-green-400",children:["+$",v.amount.toLocaleString()]}),l.jsx("td",{className:"px-4 py-3 capitalize",children:v.type})]},v.id)):l.jsx("tr",{children:l.jsx("td",{colSpan:3,className:"text-center py-8 text-gray-500",children:"No manual contributions yet."})})})]})}),f==="recurring"&&l.jsx(Hse,{goal:e,onAddRecurringContribution:n,onUpdateRecurringContribution:r,onDeleteRecurringContribution:i}),l.jsx(np,{isOpen:o,onClose:()=>c(!1),title:"Add Manual Contribution",children:l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{htmlFor:"contribution-amount",className:"block text-sm font-medium text-gray-300",children:"Amount"}),l.jsxs("div",{className:"mt-1 relative rounded-md shadow-sm",children:[l.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:l.jsx("span",{className:"text-gray-500 sm:text-sm",children:"$"})}),l.jsx("input",{type:"number",id:"contribution-amount",value:u,onChange:v=>m(v.target.value),className:"bg-gray-900 border-gray-600 text-white block w-full pl-7 pr-12 sm:text-sm rounded-md focus:ring-cyan-500 focus:border-cyan-500",placeholder:"0.00"})]})]}),l.jsxs("div",{className:"flex justify-end gap-3",children:[l.jsx("button",{onClick:()=>c(!1),className:"px-4 py-2 bg-gray-600 hover:bg-gray-700 text-white rounded-lg text-sm font-medium",children:"Cancel"}),l.jsx("button",{onClick:g,className:"px-4 py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg text-sm font-medium",children:"Add"})]})]})})]})},Kse=({goal:e})=>{var E;const t=((E=e.plan)==null?void 0:E.monthlyContribution)||0,[n,r]=S.useState(t>0?t:100),[i,o]=S.useState(7),[c,u]=S.useState(2.5),m=S.useMemo(()=>vd(new Date,new Date(e.targetDate)),[e.targetDate]),f=S.useMemo(()=>{let N=n;if(e.recurringContributions){for(const I of e.recurringContributions)if(I.isActive){let P=I.amount;(I.frequency==="bi-weekly"||I.frequency==="weekly")&&(P*=52/12),N+=P}}return N},[n,e.recurringContributions]),h=S.useMemo(()=>{const N=[];let I=e.currentAmount,P=e.targetAmount;const M=i/100/12,j=c/100/12;for(let k=0;k<=m;k++)k>0&&(I=I*(1+M)+f,P=P*(1+j)),N.push({month:k,projectedValue:parseFloat(I.toFixed(2)),target:parseFloat(e.targetAmount.toFixed(2)),inflationAdjustedTarget:parseFloat(P.toFixed(2)),requiredMonthly:(e.targetAmount-e.currentAmount)/(m>0?m:1)});return N},[e.currentAmount,e.targetAmount,m,f,i,c]),g=h.length>0?h[h.length-1].projectedValue:e.currentAmount,v=h.length>0?h[h.length-1].inflationAdjustedTarget:e.targetAmount;g>=e.targetAmount;const b=g>=v,T=(e.targetAmount-e.currentAmount)/(m>0?m:1),C=(v-e.currentAmount)/(m>0?m:1);return l.jsxs(pe,{children:[l.jsx("h4",{className:"text-lg font-semibold text-white mb-4",children:"Projection Simulator"}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6 mb-6",children:[l.jsxs("div",{children:[l.jsxs("label",{className:"block text-sm font-medium text-gray-400",children:["Manual Monthly Contribution ($",n.toLocaleString(),")"]}),l.jsx("input",{type:"range",min:"0",max:Math.max(e.targetAmount/(m||1),500),step:"50",value:n,onChange:N=>r(Number(N.target.value)),className:"w-full h-2 bg-gray-700 rounded-lg appearance-none cursor-pointer"})]}),l.jsxs("div",{children:[l.jsxs("label",{className:"block text-sm font-medium text-gray-400",children:["Expected Annual Return (",i,"%)"]}),l.jsx("input",{type:"range",min:"0",max:"20",step:"0.5",value:i,onChange:N=>o(Number(N.target.value)),className:"w-full h-2 bg-gray-700 rounded-lg appearance-none cursor-pointer"})]}),l.jsxs("div",{children:[l.jsxs("label",{className:"block text-sm font-medium text-gray-400",children:["Assumed Inflation (",c,"%)"]}),l.jsx("input",{type:"range",min:"0",max:"10",step:"0.1",value:c,onChange:N=>u(Number(N.target.value)),className:"w-full h-2 bg-gray-700 rounded-lg appearance-none cursor-pointer"})]})]}),l.jsxs("div",{className:"mb-6 p-4 bg-gray-700/50 rounded-lg",children:[l.jsx("h5",{className:"font-semibold text-white mb-2",children:"Effective Contribution Summary"}),l.jsxs("p",{className:"text-sm text-gray-300",children:["Your base manual contribution: ",l.jsxs("strong",{className:"text-white",children:["$",n.toLocaleString()]}),"."]}),e.recurringContributions&&e.recurringContributions.length>0&&l.jsxs("p",{className:"text-sm text-gray-300",children:["Total from active recurring contributions: ",l.jsxs("strong",{className:"text-white",children:["$",(f-n).toLocaleString(void 0,{maximumFractionDigits:0})]}),"."]}),l.jsx("p",{className:"text-md text-gray-200 mt-2",children:l.jsxs("strong",{className:"text-cyan-300",children:["Total Monthly Contribution to Goal: $",f.toLocaleString(void 0,{maximumFractionDigits:0})]})}),l.jsxs("p",{className:"text-xs text-gray-500 mt-2",children:["Required monthly to reach ",l.jsx("strong",{className:"text-white",children:"original target"}),": ",l.jsxs("strong",{className:"text-cyan-300",children:["$",T.toLocaleString(void 0,{maximumFractionDigits:0})]}),"."]}),l.jsxs("p",{className:"text-xs text-gray-500",children:["Required monthly to reach ",l.jsx("strong",{className:"text-white",children:"inflation-adjusted target"}),": ",l.jsxs("strong",{className:"text-yellow-300",children:["$",C.toLocaleString(void 0,{maximumFractionDigits:0})]}),"."]})]}),l.jsx("div",{className:"h-80 w-full mb-4",children:l.jsx(Pn,{children:l.jsxs(ep,{data:h,children:[l.jsx(oi,{strokeDasharray:"3 3",stroke:"#4A5568"}),l.jsx(St,{dataKey:"month",label:{value:"Months from now",position:"insideBottom",offset:-10},stroke:"#A0AEC0"}),l.jsx(vt,{tickFormatter:N=>`$${(N/1e3).toLocaleString()}k`,stroke:"#A0AEC0"}),l.jsx(at,{content:l.jsx(_x,{})}),l.jsx(Rn,{}),l.jsx(Cr,{type:"monotone",dataKey:"projectedValue",name:"Projected Growth",stroke:"#38B2AC",strokeWidth:2,dot:!1}),l.jsx(Cr,{type:"monotone",dataKey:"target",name:"Original Target",stroke:"#E53E3E",strokeWidth:2,dot:!1,strokeDasharray:"5 5"}),l.jsx(Cr,{type:"monotone",dataKey:"inflationAdjustedTarget",name:"Target (Inflation Adjusted)",stroke:"#F6E05E",strokeWidth:2,dot:!1,strokeDasharray:"5 5"})]})})}),l.jsxs("div",{className:`p-4 rounded-lg ${b?"bg-green-500/10":"bg-red-500/10"}`,children:[l.jsx("h5",{className:"font-bold text-white",children:"Simulation Result"}),l.jsxs("p",{className:`text-sm ${b?"text-green-300":"text-red-300"}`,children:["With these settings, your projected balance in ",m," months will be",l.jsxs("span",{className:"font-bold text-white",children:[" $",g.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]}),". This is ",b?"enough to reach your inflation-adjusted goal":`short of your inflation-adjusted target of $${v.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})}`,". (Original target: $",e.targetAmount.toLocaleString(),")"]})]})]})},Yse=({goal:e})=>{var N;const[t,n]=S.useState(!1),[r,i]=S.useState(null),[o,c]=S.useState(e.riskProfile==="aggressive"?.25:e.riskProfile==="moderate"?.15:.08),[u,m]=S.useState(e.riskProfile==="aggressive"?.09:e.riskProfile==="moderate"?.07:.04),[f,h]=S.useState(1e3),g=((N=e.plan)==null?void 0:N.monthlyContribution)||100,v=S.useMemo(()=>vd(new Date,new Date(e.targetDate)),[e.targetDate]),b=S.useCallback(()=>{if(v<=0){alert("Goal target date is in the past or current month. Monte Carlo simulation requires a future period.");return}n(!0),i(null),setTimeout(()=>{const P=new Bj(e.currentAmount,g,v,u,o,f).runSimulation(),M=Bj.analyzeResults(P),j=M.medianPath.map((k,R)=>({month:R,median:k,p10:M.p10Path[R],p90:M.p90Path[R],target:R===v?e.targetAmount:null}));i({...M,chartData:j}),n(!1)},500)},[e,g,v,u,o,f]),T=S.useMemo(()=>{if(!r)return[];const I=r.finalOutcomes;if(I.length===0)return[];const P=Math.min(...I),M=Math.max(...I),j=20,k=(M-P)/j,R=Array(j).fill(0).map((F,q)=>({range:`${(P+q*k).toFixed(0)} - ${(P+(q+1)*k).toFixed(0)}`,count:0,midpoint:P+(q+.5)*k}));for(const F of I){let q=Math.floor((F-P)/k);q>=j&&(q=j-1),q<0&&(q=0),R[q].count++}return R},[r]),C=S.useMemo(()=>[{value:"conservative",label:"Conservative",meanReturn:.04,volatility:.08},{value:"moderate",label:"Moderate",meanReturn:.07,volatility:.15},{value:"aggressive",label:"Aggressive",meanReturn:.09,volatility:.25}],[]),E=I=>{const P=C.find(M=>M.value===I);P&&(m(P.meanReturn),c(P.volatility))};return S.useEffect(()=>{!r&&!t&&v>0&&b()},[e.id,u,o,f,g,v,b,r,t]),l.jsxs(pe,{children:[l.jsx("h4",{className:"text-lg font-semibold text-white mb-4",children:"Monte Carlo Outcome Analysis"}),l.jsxs("div",{className:"flex flex-wrap gap-4 items-end mb-6",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-400",children:"Risk Profile"}),l.jsx("select",{value:e.riskProfile||"moderate",onChange:I=>E(I.target.value),className:"mt-1 block w-48 pl-3 pr-10 py-2 text-base border-gray-600 focus:outline-none focus:ring-cyan-500 focus:border-cyan-500 sm:text-sm rounded-md bg-gray-900 text-white",children:C.map(I=>l.jsx("option",{value:I.value,children:I.label},I.value))})]}),l.jsxs("div",{children:[l.jsxs("label",{className:"block text-sm font-medium text-gray-400",children:["Market Volatility (",(o*100).toFixed(1),"%)"]}),l.jsx("input",{type:"range",min:"0.05",max:"0.4",step:"0.005",value:o,onChange:I=>c(Number(I.target.value)),className:"w-48 h-2 bg-gray-700 rounded-lg appearance-none cursor-pointer"})]}),l.jsxs("div",{children:[l.jsxs("label",{className:"block text-sm font-medium text-gray-400",children:["Avg. Annual Return (",(u*100).toFixed(1),"%)"]}),l.jsx("input",{type:"range",min:"0.01",max:"0.15",step:"0.001",value:u,onChange:I=>m(Number(I.target.value)),className:"w-48 h-2 bg-gray-700 rounded-lg appearance-none cursor-pointer"})]}),l.jsxs("div",{children:[l.jsxs("label",{className:"block text-sm font-medium text-gray-400",children:["Simulations (",f.toLocaleString(),")"]}),l.jsx("input",{type:"range",min:"500",max:"10000",step:"500",value:f,onChange:I=>h(Number(I.target.value)),className:"w-48 h-2 bg-gray-700 rounded-lg appearance-none cursor-pointer"})]}),l.jsx("button",{onClick:b,disabled:t||v<=0,className:"px-4 py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg text-sm font-medium disabled:bg-gray-500 disabled:cursor-not-allowed",children:t?"Simulating...":"Run Simulation"})]}),v<=0&&l.jsxs("div",{className:"p-4 rounded-lg bg-red-500/10 text-red-300 mb-4",children:[l.jsx("p",{className:"font-bold",children:"Cannot run simulation:"}),l.jsxs("p",{children:["The goal's target date (",wa(e.targetDate),") is in the past or current month. Please update the goal target date to a future month to run simulations."]})]}),t&&l.jsx("div",{className:"text-center py-10 text-gray-400",children:"Calculating thousands of possible futures..."}),r&&l.jsxs("div",{children:[l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[l.jsxs("div",{children:[l.jsx("h5",{className:"font-semibold text-white mb-2",children:"Projected Growth Range Over Time"}),l.jsx("div",{className:"h-80 w-full",children:l.jsx(Pn,{children:l.jsxs(yd,{data:r.chartData,children:[l.jsx(oi,{strokeDasharray:"3 3",stroke:"#4A5568"}),l.jsx(St,{dataKey:"month",stroke:"#A0AEC0"}),l.jsx(vt,{tickFormatter:I=>`$${(I/1e3).toLocaleString()}k`,stroke:"#A0AEC0"}),l.jsx(at,{content:l.jsx(_x,{})}),l.jsxs("defs",{children:[l.jsxs("linearGradient",{id:"colorRangeUpper",x1:"0",y1:"0",x2:"0",y2:"1",children:[l.jsx("stop",{offset:"5%",stopColor:"#38B2AC",stopOpacity:.8}),l.jsx("stop",{offset:"95%",stopColor:"#38B2AC",stopOpacity:0})]}),l.jsxs("linearGradient",{id:"colorRangeLower",x1:"0",y1:"0",x2:"0",y2:"1",children:[l.jsx("stop",{offset:"5%",stopColor:"#E53E3E",stopOpacity:.4}),l.jsx("stop",{offset:"95%",stopColor:"#E53E3E",stopOpacity:0})]})]}),l.jsx(da,{type:"monotone",dataKey:"p90",fill:"transparent",name:"90th Percentile",strokeWidth:1,stroke:"#82ca9d"}),l.jsx(Cr,{type:"monotone",dataKey:"median",stroke:"#F6E05E",strokeWidth:2,dot:!1,name:"Median Outcome"}),l.jsx(da,{type:"monotone",dataKey:"p90",strokeWidth:0,fillOpacity:.2,fill:"url(#colorRangeUpper)",name:"Optimistic Range"}),l.jsx(da,{type:"monotone",dataKey:"p10",fillOpacity:0,name:"Pessimistic Range (Base for upper fill)"})," ",l.jsx(Cr,{type:"monotone",dataKey:"p10",stroke:"#E53E3E",strokeWidth:1,dot:!1,name:"10th Percentile"}),e.targetAmount>0&&l.jsx(Cr,{type:"monotone",dataKey:"target",stroke:"#718096",strokeWidth:2,dot:!1,strokeDasharray:"3 3",name:"Target Amount"})]})})})]}),l.jsxs("div",{children:[l.jsx("h5",{className:"font-semibold text-white mb-2",children:"Distribution of Final Outcomes"}),l.jsx("div",{className:"h-80 w-full",children:l.jsx(Pn,{children:l.jsxs(jn,{data:T,children:[l.jsx(oi,{strokeDasharray:"3 3",stroke:"#4A5568"}),l.jsx(St,{dataKey:"range",stroke:"#A0AEC0",tick:{fontSize:10},interval:0,angle:-30,textAnchor:"end",height:60}),l.jsx(vt,{stroke:"#A0AEC0"}),l.jsx(at,{content:l.jsx(_x,{}),cursor:{fill:"rgba(127, 209, 213, 0.1)"}}),l.jsx(it,{dataKey:"count",name:"Number of Simulations",fill:"#38B2AC"}),e.targetAmount>0&&l.jsx(Q5,{x:T.findIndex(I=>I.midpoint>=e.targetAmount),stroke:"#E53E3E",label:{value:`Target: $${e.targetAmount.toLocaleString()}`,position:"top",fill:"#E53E3E",fontSize:10}})]})})})]})]}),l.jsxs("div",{className:"mt-6 p-4 rounded-lg bg-cyan-500/10",children:[l.jsx("h5",{className:"font-bold text-white",children:"Simulation Summary"}),l.jsxs("p",{className:"text-sm text-cyan-200",children:["Based on ",f.toLocaleString()," simulations with an expected ",l.jsxs("strong",{className:"text-white",children:[(u*100).toFixed(1),"% annual return"]})," and ",l.jsxs("strong",{className:"text-white",children:[(o*100).toFixed(1),"% volatility"]}),", there is a ",l.jsxs("span",{className:"font-bold text-white text-lg",children:[r.successProbability(e.targetAmount).toFixed(1),"%"]})," chance of reaching or exceeding your target of $",e.targetAmount.toLocaleString(),"."]}),l.jsxs("div",{className:"mt-2 text-xs grid grid-cols-1 md:grid-cols-3 gap-2 text-cyan-300",children:[l.jsxs("span",{children:["Pessimistic Outcome (10% likelihood): ",l.jsxs("strong",{className:"text-white",children:["$",Math.round(r.p10Path[r.p10Path.length-1]).toLocaleString()]})]}),l.jsxs("span",{children:["Median Outcome (50% likelihood): ",l.jsxs("strong",{className:"text-white",children:["$",Math.round(r.medianPath[r.medianPath.length-1]).toLocaleString()]})]}),l.jsxs("span",{children:["Optimistic Outcome (90% likelihood): ",l.jsxs("strong",{className:"text-white",children:["$",Math.round(r.p90Path[r.p90Path.length-1]).toLocaleString()]})]})]})]})]})]})},Wse=({goal:e,onGeneratePlan:t,onRecalibrateGoal:n,loadingGoalId:r})=>{var P;const[i,o]=S.useState(!1),[c,u]=S.useState(e.targetAmount.toString()),[m,f]=S.useState(e.targetDate),[h,g]=S.useState((((P=e.plan)==null?void 0:P.monthlyContribution)||0).toString());S.useEffect(()=>{var M;u(e.targetAmount.toString()),f(e.targetDate),g((((M=e.plan)==null?void 0:M.monthlyContribution)||0).toString())},[e]);const v=()=>{var j;const M={};parseFloat(c)!==e.targetAmount&&(M.targetAmount=parseFloat(c)),m!==e.targetDate&&(M.targetDate=m),parseFloat(h)!==(((j=e.plan)==null?void 0:j.monthlyContribution)||0)&&(M.monthlyContribution=parseFloat(h)),n(e.id,M),o(!1)},b=vd(new Date,new Date(e.targetDate)),T=(e.targetAmount-e.currentAmount)/(b>0?b:1),C=S.useMemo(()=>{var j;let M=((j=e.plan)==null?void 0:j.monthlyContribution)||0;if(e.recurringContributions){for(const k of e.recurringContributions)if(k.isActive){let R=k.amount;(k.frequency==="bi-weekly"||k.frequency==="weekly")&&(R*=52/12),M+=R}}return M},[e.plan,e.recurringContributions]),E=S.useCallback(()=>{var M;if(b<=0)return{summary:"Your target date has passed or is current. Consider extending the date or reducing the target amount.",steps:["Extend your goal target date by at least 6-12 months.","Re-evaluate your target amount to be more achievable in the remaining time.","Increase your monthly contributions significantly if possible."]};if(e.status==="on_track"&&e.currentAmount/e.targetAmount>.9)return{summary:"Excellent! You are very close to achieving your goal.",steps:["Consider reviewing your spending to make a final push.","Think about setting up a new goal to continue your savings momentum.","Explore options for reinvesting the surplus once the goal is met."]};if(e.status==="behind"||e.status==="needs_attention"){const j=((M=e.plan)==null?void 0:M.monthlyContribution)||T,k=Math.ceil(j*.2),R=e.targetAmount*.9,F=new Date(new Date(e.targetDate).setMonth(new Date(e.targetDate).getMonth()+6)).toISOString().split("T")[0],q=[],G=[];return Cl.jsx("li",{children:M},j))})]}),l.jsxs("p",{children:[l.jsx("strong",{className:"text-white",children:"Recommended Monthly Contribution:"})," $",e.plan.monthlyContribution.toLocaleString()]}),l.jsxs("div",{className:"p-4 bg-cyan-800/20 rounded-lg border border-cyan-700 mt-6",children:[l.jsxs("h5",{className:"font-bold text-white mb-2 flex items-center gap-2",children:[l.jsx("svg",{className:"w-5 h-5 text-cyan-300",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m15.364 6.364l-.707-.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"})}),"AI Smart Adjustments (",N,")"]}),l.jsx("ul",{className:"list-disc list-inside mt-2 space-y-1 text-sm pl-2 text-cyan-200",children:I.map((M,j)=>l.jsx("li",{children:M},j))}),l.jsx("button",{onClick:()=>o(!0),className:"mt-4 px-4 py-2 bg-yellow-600 hover:bg-yellow-700 text-white rounded-lg text-sm font-medium",children:"Recalibrate Goal"})]})]}):l.jsxs("div",{className:"text-center py-8",children:[l.jsx("p",{className:"text-gray-400 mb-4",children:"No AI plan has been generated for this goal yet."}),l.jsx("button",{onClick:()=>t(e.id),disabled:r===e.id,className:"px-6 py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg font-medium disabled:bg-gray-500 disabled:cursor-not-allowed",children:r===e.id?"Generating Plan...":"Generate AI Plan"})]}),l.jsx(np,{isOpen:i,onClose:()=>o(!1),title:"Recalibrate Goal",children:l.jsxs("div",{className:"space-y-4",children:[l.jsx("p",{className:"text-gray-400 text-sm mb-4",children:"Adjust your goal parameters below based on AI insights or your revised plan. Only fill in fields you wish to change."}),l.jsxs("div",{children:[l.jsx("label",{htmlFor:"recalibrated-amount",className:"block text-sm font-medium text-gray-300",children:"New Target Amount"}),l.jsx("input",{type:"number",id:"recalibrated-amount",value:c,onChange:M=>u(M.target.value),className:"mt-1 w-full bg-gray-900 border-gray-600 text-white rounded-md focus:ring-cyan-500 focus:border-cyan-500",placeholder:e.targetAmount.toString()})]}),l.jsxs("div",{children:[l.jsx("label",{htmlFor:"recalibrated-date",className:"block text-sm font-medium text-gray-300",children:"New Target Date"}),l.jsx("input",{type:"date",id:"recalibrated-date",value:m,onChange:M=>f(M.target.value),className:"mt-1 w-full bg-gray-900 border-gray-600 text-white rounded-md focus:ring-cyan-500 focus:border-cyan-500"})]}),e.plan&&l.jsxs("div",{children:[l.jsx("label",{htmlFor:"recalibrated-monthly-contribution",className:"block text-sm font-medium text-gray-300",children:"New Recommended Monthly Contribution"}),l.jsx("input",{type:"number",id:"recalibrated-monthly-contribution",value:h,onChange:M=>g(M.target.value),className:"mt-1 w-full bg-gray-900 border-gray-600 text-white rounded-md focus:ring-cyan-500 focus:border-cyan-500",placeholder:e.plan.monthlyContribution.toString()})]}),l.jsxs("div",{className:"flex justify-end gap-3",children:[l.jsx("button",{onClick:()=>o(!1),className:"px-4 py-2 bg-gray-600 hover:bg-gray-700 text-white rounded-lg text-sm font-medium",children:"Cancel"}),l.jsx("button",{onClick:v,className:"px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg text-sm font-medium",children:"Apply Recalibration"})]})]})})]})},Jse=({goal:e,allGoals:t,onLinkGoal:n,onUnlinkGoal:r})=>{const[i,o]=S.useState(!1),[c,u]=S.useState(""),[m,f]=S.useState("dependency"),[h,g]=S.useState(""),v=S.useMemo(()=>t.filter(C=>{var E;return C.id!==e.id&&!((E=e.linkedGoals)!=null&&E.some(N=>N.id===C.id))}),[e,t]),b=()=>{if(c&&m){const C=h?parseFloat(h):void 0;n(e.id,c,m,C),o(!1),u(""),g("")}},T=({link:C,targetGoal:E})=>{const N={prerequisite:"is a prerequisite for",dependency:"depends on",overflow:"overflows into",sibling:"is a sibling goal with"},I=(P,M)=>N[M]||M;return l.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-300",children:[l.jsx("span",{className:"font-semibold text-white",children:e.name}),l.jsx("span",{className:"text-gray-400",children:I("current",C.relationshipType)}),l.jsx("span",{className:"font-semibold text-white",children:E.name}),C.triggerAmount&&l.jsxs("span",{className:"text-gray-500 text-xs",children:["(at $",C.triggerAmount.toLocaleString(),")"]})]})};return l.jsxs(pe,{children:[l.jsxs("div",{className:"flex justify-between items-center mb-4",children:[l.jsx("h4",{className:"text-lg font-semibold text-white",children:"Goal Dependencies"}),l.jsx("button",{onClick:()=>o(!0),className:"px-3 py-1.5 bg-cyan-600 hover:bg-cyan-700 text-white rounded-md text-xs font-medium",children:"Link Goal"})]}),l.jsx("div",{className:"max-h-96 overflow-y-auto pr-2",children:e.linkedGoals&&e.linkedGoals.length>0?l.jsx("div",{className:"space-y-3",children:e.linkedGoals.map(C=>{const E=t.find(N=>N.id===C.id);return E?l.jsxs("div",{className:"p-3 rounded-lg bg-gray-700/30 border border-gray-700 flex justify-between items-center",children:[l.jsx(T,{link:C,targetGoal:E}),l.jsx("button",{onClick:()=>r(e.id,C.id),className:"text-gray-400 hover:text-red-500 transition-colors",children:l.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})})})]},C.id):null})}):l.jsx("p",{className:"text-center py-8 text-gray-500",children:"No linked goals yet. Link goals to create a strategic financial roadmap."})}),l.jsx(np,{isOpen:i,onClose:()=>o(!1),title:"Link Another Goal",children:l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{htmlFor:"target-goal",className:"block text-sm font-medium text-gray-300",children:"Target Goal"}),l.jsxs("select",{id:"target-goal",value:c,onChange:C=>u(C.target.value),className:"mt-1 block w-full pl-3 pr-10 py-2 text-base border-gray-600 focus:outline-none focus:ring-cyan-500 focus:border-cyan-500 sm:text-sm rounded-md bg-gray-900 text-white",children:[l.jsx("option",{value:"",children:"Select a goal"}),v.map(C=>l.jsx("option",{value:C.id,children:C.name},C.id))]})]}),l.jsxs("div",{children:[l.jsx("label",{htmlFor:"relationship-type",className:"block text-sm font-medium text-gray-300",children:"Relationship Type"}),l.jsxs("select",{id:"relationship-type",value:m,onChange:C=>f(C.target.value),className:"mt-1 block w-full pl-3 pr-10 py-2 text-base border-gray-600 focus:outline-none focus:ring-cyan-500 focus:border-cyan-500 sm:text-sm rounded-md bg-gray-900 text-white",children:[l.jsx("option",{value:"dependency",children:"This goal depends on the target goal (e.g., must finish this first)"}),l.jsx("option",{value:"prerequisite",children:"The target goal is a prerequisite for this goal"}),l.jsx("option",{value:"overflow",children:"Funds from this goal overflow into the target goal"}),l.jsx("option",{value:"sibling",children:"They are related but not strictly dependent (e.g., both for retirement)"})]})]}),m==="overflow"&&l.jsxs("div",{children:[l.jsx("label",{htmlFor:"trigger-amount",className:"block text-sm font-medium text-gray-300",children:"Trigger Amount (optional)"}),l.jsx("input",{type:"number",id:"trigger-amount",value:h,onChange:C=>g(C.target.value),className:"mt-1 w-full bg-gray-900 border-gray-600 text-white rounded-md focus:ring-cyan-500 focus:border-cyan-500",placeholder:"Amount when overflow begins (e.g., 50000)"}),l.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"If specified, funds will overflow once this goal reaches this amount."})]}),l.jsxs("div",{className:"flex justify-end gap-3",children:[l.jsx("button",{onClick:()=>o(!1),className:"px-4 py-2 bg-gray-600 hover:bg-gray-700 text-white rounded-lg text-sm font-medium",children:"Cancel"}),l.jsx("button",{onClick:b,disabled:!c||!m,className:"px-4 py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg text-sm font-medium disabled:bg-gray-500 disabled:cursor-not-allowed",children:"Link Goal"})]})]})})]})},Qse=({onGoalCreate:e,onBack:t})=>{const[n,r]=S.useState(1),[i,o]=S.useState({name:"",targetAmount:"",targetDate:"",iconName:"default",startDate:new Date().toISOString().split("T")[0],riskProfile:"moderate"}),[c,u]=S.useState({}),m=()=>{const b={};return n===1&&(i.name||(b.name="Goal name is required."),(Number(i.targetAmount)<=0||isNaN(Number(i.targetAmount)))&&(b.targetAmount="Target amount must be a positive number."),i.targetDate?new Date(i.targetDate)<=new Date&&(b.targetDate="Target date must be in the future."):b.targetDate="Target date is required."),u(b),Object.keys(b).length===0},f=()=>{m()&&r(b=>b+1)},h=()=>r(b=>b-1),g=()=>{m()&&e({...i,targetAmount:parseFloat(i.targetAmount)})},v=()=>{switch(n){case 1:return l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Goal Name"}),l.jsx("input",{type:"text",value:i.name,onChange:T=>o({...i,name:T.target.value}),className:"w-full bg-gray-900 border-gray-600 text-white rounded-md focus:ring-cyan-500 focus:border-cyan-500",placeholder:"e.g., Buy a new car"}),c.name&&l.jsx("p",{className:"text-red-400 text-xs mt-1",children:c.name})]}),l.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Target Amount"}),l.jsx("input",{type:"number",value:i.targetAmount,onChange:T=>o({...i,targetAmount:T.target.value}),className:"w-full bg-gray-900 border-gray-600 text-white rounded-md focus:ring-cyan-500 focus:border-cyan-500",placeholder:"50000"}),c.targetAmount&&l.jsx("p",{className:"text-red-400 text-xs mt-1",children:c.targetAmount})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Target Date"}),l.jsx("input",{type:"date",value:i.targetDate,onChange:T=>o({...i,targetDate:T.target.value}),className:"w-full bg-gray-900 border-gray-600 text-white rounded-md focus:ring-cyan-500 focus:border-cyan-500"}),c.targetDate&&l.jsx("p",{className:"text-red-400 text-xs mt-1",children:c.targetDate})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Choose an Icon"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:$se.map(T=>{const C=wo[T];return l.jsx("button",{type:"button",onClick:()=>o({...i,iconName:T}),className:`p-3 rounded-full ${i.iconName===T?"bg-cyan-600 text-white":"bg-gray-700 text-gray-400 hover:bg-gray-600"} transition-colors`,children:l.jsx(C,{className:"w-6 h-6"})},T)})})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-1",children:"Investment Risk Profile"}),l.jsxs("select",{value:i.riskProfile,onChange:T=>o({...i,riskProfile:T.target.value}),className:"w-full bg-gray-900 border-gray-600 text-white rounded-md focus:ring-cyan-500 focus:border-cyan-500",children:[l.jsx("option",{value:"conservative",children:"Conservative (Lower risk, lower potential return)"}),l.jsx("option",{value:"moderate",children:"Moderate (Balanced risk and return)"}),l.jsx("option",{value:"aggressive",children:"Aggressive (Higher risk, higher potential return)"})]}),l.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"This will influence AI recommendations and projections."})]})]});case 2:const b=wo[i.iconName]||wo.default;return l.jsxs("div",{className:"text-center",children:[l.jsx("h3",{className:"text-lg font-semibold text-white mb-4",children:"Review Your New Goal"}),l.jsxs("div",{className:"text-left mt-4 p-4 bg-gray-700/50 rounded-lg space-y-3",children:[l.jsxs("p",{className:"text-gray-400 flex justify-between items-center",children:["Name: ",l.jsx("strong",{className:"text-white",children:i.name})]}),l.jsxs("p",{className:"text-gray-400 flex justify-between items-center",children:["Target: ",l.jsxs("strong",{className:"text-white",children:["$",parseFloat(i.targetAmount).toLocaleString()]})]}),l.jsxs("p",{className:"text-gray-400 flex justify-between items-center",children:["By Date: ",l.jsx("strong",{className:"text-white",children:wa(i.targetDate)})]}),l.jsxs("p",{className:"text-gray-400 flex justify-between items-center",children:["Risk Profile: ",l.jsx("strong",{className:"text-white capitalize",children:i.riskProfile})]}),l.jsxs("p",{className:"text-gray-400 flex items-center gap-2",children:["Icon: ",l.jsx("span",{className:"p-1 bg-cyan-500/20 rounded-full",children:l.jsx(b,{className:"w-5 h-5 text-cyan-300"})})]})]})]})}};return l.jsxs("div",{children:[l.jsxs("div",{className:"flex justify-between items-center mb-6",children:[l.jsx("h2",{className:"text-3xl font-bold text-white tracking-wider",children:"Create New Goal"}),l.jsx("button",{onClick:t,className:"text-sm text-cyan-400 hover:text-cyan-200",children:"Back to List"})]}),l.jsxs(pe,{children:[l.jsxs("div",{className:"mb-8",children:[l.jsx("div",{className:"relative h-2 bg-gray-700 rounded-full",children:l.jsx("div",{className:"absolute top-0 left-0 h-2 bg-cyan-500 rounded-full transition-all duration-300",style:{width:`${(n-1)/1*100}%`}})}),l.jsxs("div",{className:"flex justify-between text-xs text-gray-400 mt-2",children:[l.jsx("span",{className:`transition-colors ${n>=1?"text-white font-medium":""}`,children:"Details"}),l.jsx("span",{className:`transition-colors ${n>=2?"text-white font-medium":""}`,children:"Confirm"})]})]}),v(),l.jsxs("div",{className:"flex justify-between mt-8",children:[l.jsx("button",{type:"button",onClick:h,disabled:n===1,className:"px-4 py-2 bg-gray-600 hover:bg-gray-700 text-white rounded-lg text-sm font-medium disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Back"}),n<2?l.jsx("button",{type:"button",onClick:f,className:"px-4 py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg text-sm font-medium transition-colors",children:"Next"}):l.jsx("button",{type:"button",onClick:g,className:"px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg text-sm font-medium transition-colors",children:"Create Goal"})]})]})]})},Xse=({goal:e,allGoals:t,onBack:n,onGeneratePlan:r,onAddContribution:i,onAddRecurringContribution:o,onUpdateRecurringContribution:c,onDeleteRecurringContribution:u,onRecalibrateGoal:m,onLinkGoal:f,onUnlinkGoal:h,loadingGoalId:g})=>{var P;const[v,b]=S.useState("overview"),T=e.currentAmount/e.targetAmount*100,C=wo[e.iconName]||wo.default,E=vd(new Date,new Date(e.targetDate)),N=(e.targetAmount-e.currentAmount)/(E>0?E:1),I=[{id:"overview",label:"Overview"},{id:"contributions",label:"Contributions"},{id:"projections",label:"Projections"},{id:"monte-carlo",label:"Risk Analysis"},{id:"insights",label:"AI Insights"},{id:"dependencies",label:"Dependencies"}];return l.jsxs("div",{children:[l.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-start mb-6 gap-4",children:[l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsx("div",{className:"flex-shrink-0 w-16 h-16 bg-cyan-500/10 rounded-full flex items-center justify-center text-cyan-300",children:l.jsx(C,{className:"w-8 h-8"})}),l.jsxs("div",{children:[l.jsx("h2",{className:"text-3xl font-bold text-white tracking-wider",children:e.name}),l.jsxs("p",{className:"text-gray-400 text-sm",children:["Target: ",l.jsxs("strong",{className:"text-white",children:["$",e.targetAmount.toLocaleString()]})," by ",l.jsx("strong",{className:"text-white",children:wa(e.targetDate)})]}),l.jsxs("p",{className:"text-gray-500 text-xs mt-1",children:["Started: ",wa(e.startDate)," | Risk Profile: ",l.jsx("strong",{className:"capitalize",children:e.riskProfile||"N/A"})]})]})]}),l.jsx("button",{onClick:n,className:"mt-2 md:mt-0 text-sm text-cyan-400 hover:text-cyan-200 self-start md:self-center",children:"Back to List"})]}),l.jsx("div",{className:"border-b border-gray-700 mb-6 overflow-x-auto",children:l.jsx("nav",{className:"-mb-px flex space-x-6 min-w-max","aria-label":"Tabs",children:I.map(M=>l.jsx("button",{onClick:()=>b(M.id),className:`${v===M.id?"border-cyan-500 text-cyan-400":"border-transparent text-gray-400 hover:text-gray-200 hover:border-gray-500"} whitespace-nowrap py-3 px-1 border-b-2 font-medium text-sm transition-colors`,children:M.label},M.id))})}),l.jsxs("div",{className:"space-y-6",children:[v==="overview"&&l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[l.jsx("div",{className:"lg:col-span-2",children:l.jsxs(pe,{children:[l.jsx("h4",{className:"text-lg font-semibold text-white mb-4",children:"Goal Progress"}),l.jsxs("div",{className:"w-full bg-gray-700 rounded-full h-4 relative",children:[l.jsx("div",{className:"bg-cyan-500 h-4 rounded-full transition-all duration-500 ease-out",style:{width:`${Math.min(100,Math.max(0,T))}%`}}),l.jsxs("span",{className:"absolute inset-0 flex items-center justify-center text-xs font-bold text-white",children:[T.toFixed(1),"%"]})]}),l.jsxs("div",{className:"mt-4 grid grid-cols-2 md:grid-cols-4 gap-4 text-center",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-gray-400",children:"Current Amount"}),l.jsxs("p",{className:"text-xl font-bold text-white",children:["$",e.currentAmount.toLocaleString()]})]}),l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-gray-400",children:"Remaining"}),l.jsxs("p",{className:"text-xl font-bold text-white",children:["$",(e.targetAmount-e.currentAmount).toLocaleString()]})]}),l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-gray-400",children:"Time Left"}),l.jsxs("p",{className:"text-xl font-bold text-white",children:[E," months"]})]}),l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-gray-400",children:"Required Monthly"}),l.jsxs("p",{className:"text-xl font-bold text-white",children:["$",N.toLocaleString(void 0,{maximumFractionDigits:0})]})]})]})]})}),l.jsx("div",{className:"lg:col-span-1",children:l.jsxs(pe,{children:[l.jsx("h4",{className:"text-lg font-semibold text-white mb-2",children:"Goal Status"}),l.jsx("p",{className:"text-sm text-gray-400",children:e.status==="on_track"?"You are on track to meet your goal.":e.status==="achieved"?"Congratulations! You have achieved this goal.":"Your goal may need attention. Consider adjusting your plan."}),l.jsxs("div",{className:`mt-3 w-full p-2 rounded-md flex items-center gap-2 ${e.status==="on_track"||e.status==="achieved"?"bg-green-500/10 text-green-300":"bg-yellow-500/10 text-yellow-300"}`,children:[e.status==="on_track"||e.status==="achieved"?l.jsx("span",{children:"✓"}):l.jsx("span",{children:"⚠"})," ",l.jsx("span",{className:"capitalize font-medium text-sm",children:e.status.replace("_"," ")})]}),e.status!=="achieved"&&((P=e.plan)==null?void 0:P.monthlyContribution)&&l.jsxs("div",{className:"mt-4 text-sm text-gray-400",children:[l.jsxs("p",{children:["Current plan suggests: ",l.jsxs("strong",{className:"text-white",children:["$",e.plan.monthlyContribution.toLocaleString()]})," monthly."]}),e.plan.monthlyContribution{const[e,t]=S.useState("LIST"),[n,r]=S.useState(null),[i,o]=S.useState(null),c=S.useContext(Ct);if(!c)throw new Error("FinancialGoalsView must be used within a DataProvider.");const{financialGoals:u,addFinancialGoal:m,generateGoalPlan:f,addContributionToGoal:h,addRecurringContributionToGoal:g,updateRecurringContributionInGoal:v,deleteRecurringContributionFromGoal:b,updateFinancialGoal:T,linkGoals:C,unlinkGoals:E}=c,N=S.useMemo(()=>u.map(Z=>{var ce,ge;const me=Z.startDate||new Date().toISOString().split("T")[0],z=Z.contributions&&Z.contributions.length>0?Z.contributions:Z.currentAmount>0?[{id:tm(),amount:Z.currentAmount*.4,date:new Date(new Date(me).setDate(new Date(me).getDate()+15)).toISOString(),type:"manual"},{id:tm(),amount:Z.currentAmount*.6,date:new Date(new Date(me).setMonth(new Date(me).getMonth()+1)).toISOString(),type:"manual"}]:[];let Y="needs_attention";if(Z.currentAmount>=Z.targetAmount)Y="achieved";else{const Me=vd(new Date,new Date(Z.targetDate));if(Me>0){const U=(Z.targetAmount-Z.currentAmount)/Me,te=(((ce=Z.plan)==null?void 0:ce.monthlyContribution)||0)+(Z.recurringContributions||[]).filter(ue=>ue.isActive).reduce((ue,fe)=>{let Ne=fe.amount;return(fe.frequency==="bi-weekly"||fe.frequency==="weekly")&&(Ne*=52/12),ue+Ne},0);te>=U*.9?Y="on_track":te6?Y="behind":Y="needs_attention"}else Y="behind"}return{...Z,startDate:me,contributions:z,recurringContributions:Z.recurringContributions||[Z.id==="g1"&&((ge=Z.plan)!=null&&ge.monthlyContribution)?{id:tm(),amount:Z.plan.monthlyContribution/2,frequency:"monthly",startDate:new Date(new Date().setMonth(new Date().getMonth()-3)).toISOString().split("T")[0],endDate:null,isActive:!0}:void 0].filter(Boolean),riskProfile:Z.riskProfile||"moderate",status:Y,linkedGoals:Z.linkedGoals||[]}}),[u]),I=S.useMemo(()=>N.find(Z=>Z.id===(n==null?void 0:n.id))||null,[N,n]);S.useEffect(()=>{n&&I&&r(I)},[I,n]);const P=async Z=>{o(Z),await f(Z),o(null)},M=Z=>{const me={...Z,id:tm(),currentAmount:0,plan:null,contributions:[],recurringContributions:[],linkedGoals:[],status:"needs_attention"};m(me),t("LIST")},j=(Z,me)=>{h(Z,me)},k=(Z,me)=>{g(Z,me)},R=(Z,me,z)=>{v(Z,me,z)},F=(Z,me)=>{b(Z,me)},q=(Z,me)=>{T(Z,me)},G=(Z,me,z,Y)=>{C(Z,me,z,Y)},H=(Z,me)=>{E(Z,me)},V=()=>l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"flex justify-between items-center",children:[l.jsx("h2",{className:"text-3xl font-bold text-white tracking-wider",children:"Financial Goals"}),l.jsx("button",{onClick:()=>t("CREATE"),className:"px-4 py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg text-sm font-medium",children:"New Goal"})]}),N.length===0&&l.jsxs("div",{className:"text-center py-20 text-gray-400",children:[l.jsx("p",{className:"text-xl mb-4",children:"You don't have any financial goals set up yet."}),l.jsx("p",{className:"mb-6",children:"Start by creating your first goal to plan your financial future!"}),l.jsx("button",{onClick:()=>t("CREATE"),className:"px-6 py-3 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg text-md font-medium",children:"Create Your First Goal"})]}),N.map(Z=>{const me=Z.currentAmount/Z.targetAmount*100,z=wo[Z.iconName]||wo.default,Y={on_track:"text-green-400",needs_attention:"text-yellow-400",achieved:"text-green-400",behind:"text-red-400"},ce={on_track:"bg-green-500/10",needs_attention:"bg-yellow-500/10",achieved:"bg-green-500/10",behind:"bg-red-500/10"};return l.jsx(pe,{variant:"interactive",onClick:()=>{r(Z),t("DETAIL")},children:l.jsxs("div",{className:"flex flex-col md:flex-row gap-6",children:[l.jsx("div",{className:"flex-shrink-0 w-24 h-24 bg-cyan-500/10 rounded-full flex items-center justify-center text-cyan-300 mx-auto",children:l.jsx(z,{className:"w-12 h-12"})}),l.jsxs("div",{className:"flex-grow",children:[l.jsxs("div",{className:"flex justify-between items-baseline flex-wrap gap-2",children:[l.jsx("h3",{className:"text-xl font-semibold text-white",children:Z.name}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:`px-2 py-0.5 rounded-full text-xs font-medium ${ce[Z.status]} ${Y[Z.status]}`,children:Z.status.replace("_"," ")}),l.jsxs("p",{className:"text-sm text-gray-400",children:["Target: ",wa(Z.targetDate)]})]})]}),l.jsxs("p",{className:"text-lg text-gray-300 mt-2",children:[l.jsxs("span",{className:"text-white font-bold",children:["$",Z.currentAmount.toLocaleString()]})," / $",Z.targetAmount.toLocaleString()]}),l.jsx("div",{className:"w-full bg-gray-700 rounded-full h-2.5 mt-2",children:l.jsx("div",{className:"bg-cyan-500 h-2.5 rounded-full transition-all duration-500 ease-out",style:{width:`${Math.min(100,Math.max(0,me))}%`}})})]})]})},Z.id)})]}),oe=()=>{switch(e){case"CREATE":return l.jsx(Qse,{onGoalCreate:M,onBack:()=>t("LIST")});case"DETAIL":return n?l.jsx(Xse,{goal:n,allGoals:N,onBack:()=>t("LIST"),onGeneratePlan:P,onAddContribution:j,onAddRecurringContribution:k,onUpdateRecurringContribution:R,onDeleteRecurringContribution:F,onRecalibrateGoal:q,onLinkGoal:G,onUnlinkGoal:H,loadingGoalId:i}):l.jsx(V,{});case"LIST":default:return l.jsx(V,{})}};return l.jsx(l.Fragment,{children:oe()})};function zj(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",...e,children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924-1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065zM15 12a3 3 0 11-6 0 3 3 0 016 0z"})})}const ele=()=>{const e=S.useContext(Ct);if(!e)throw new Error("APIIntegrationView must be within a DataProvider.");const{apiStatus:t,geminiApiKey:n,setGeminiApiKey:r,modernTreasuryApiKey:i,setModernTreasuryApiKey:o,modernTreasuryOrganizationId:c,setModernTreasuryOrganizationId:u}=e,[m,f]=S.useState(!1),[h,g]=S.useState(n||""),[v,b]=S.useState(!1),[T,C]=S.useState(i||""),[E,N]=S.useState(c||""),I=()=>{r(h),f(!1)},P=()=>{o(T),u(E),b(!1)},M=({status:j})=>{const R={Operational:{bg:"bg-green-500/20",text:"text-green-300",dot:"bg-green-400"},"Degraded Performance":{bg:"bg-yellow-500/20",text:"text-yellow-300",dot:"bg-yellow-400"},"Partial Outage":{bg:"bg-orange-500/20",text:"text-orange-300",dot:"bg-orange-400"},"Major Outage":{bg:"bg-red-500/20",text:"text-red-300",dot:"bg-red-400"}}[j];return l.jsxs("div",{className:`flex items-center gap-2 px-2 py-1 rounded-full text-xs font-medium ${R.bg} ${R.text}`,children:[l.jsx("div",{className:`w-2 h-2 rounded-full ${R.dot}`}),j]})};return l.jsxs(l.Fragment,{children:[m&&l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 backdrop-blur-sm",onClick:()=>f(!1),children:l.jsxs("div",{className:"bg-gray-800 rounded-lg shadow-2xl max-w-md w-full border border-gray-700",onClick:j=>j.stopPropagation(),children:[l.jsx("div",{className:"p-4 border-b border-gray-700",children:l.jsx("h3",{className:"text-lg font-semibold text-white",children:"Configure Google Gemini API Key"})}),l.jsxs("div",{className:"p-6 space-y-4",children:[l.jsx("p",{className:"text-sm text-gray-400",children:"Enter your API key to enable all AI features. Your key is stored locally in your browser and is not sent to our servers."}),l.jsx("input",{type:"password",value:h,onChange:j=>g(j.target.value),placeholder:"Enter your Gemini API Key",className:"w-full bg-gray-700/50 border border-gray-600 rounded-lg px-3 py-2 text-white focus:outline-none focus:ring-1 focus:ring-cyan-500"}),l.jsx("button",{onClick:I,className:"w-full py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg",children:"Save Key"})]})]})}),v&&l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 backdrop-blur-sm",onClick:()=>b(!1),children:l.jsxs("div",{className:"bg-gray-800 rounded-lg shadow-2xl max-w-md w-full border border-gray-700",onClick:j=>j.stopPropagation(),children:[l.jsx("div",{className:"p-4 border-b border-gray-700",children:l.jsx("h3",{className:"text-lg font-semibold text-white",children:"Configure Modern Treasury API"})}),l.jsxs("div",{className:"p-6 space-y-4",children:[l.jsx("p",{className:"text-sm text-gray-400",children:"Enter your API key and Organization ID to enable payment operations. Your credentials are stored locally."}),l.jsx("input",{type:"password",value:T,onChange:j=>C(j.target.value),placeholder:"Enter your Modern Treasury API Key",className:"w-full bg-gray-700/50 border border-gray-600 rounded-lg px-3 py-2 text-white focus:outline-none focus:ring-1 focus:ring-cyan-500"}),l.jsx("input",{type:"text",value:E,onChange:j=>N(j.target.value),placeholder:"Enter your Organization ID",className:"w-full bg-gray-700/50 border border-gray-600 rounded-lg px-3 py-2 text-white focus:outline-none focus:ring-1 focus:ring-cyan-500"}),l.jsx("button",{onClick:P,className:"w-full py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg",children:"Save Credentials"})]})]})}),l.jsxs("div",{className:"space-y-6",children:[l.jsx("h2",{className:"text-3xl font-bold text-white tracking-wider",children:"System & API Status"}),l.jsx(pe,{children:l.jsx("div",{className:"space-y-3",children:t.map(j=>l.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-center p-3 bg-gray-800/50 rounded-lg",children:[l.jsx("h4",{className:"font-semibold text-lg text-white mb-2 sm:mb-0",children:j.provider}),l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsxs("p",{className:"text-sm text-gray-400 font-mono",children:[j.responseTime,"ms"]}),l.jsx(M,{status:j.status}),j.provider==="Google Gemini"&&l.jsx("button",{onClick:()=>{g(n||""),f(!0)},className:"text-gray-400 hover:text-white",children:l.jsx(zj,{className:"h-5 w-5"})}),j.provider==="Modern Treasury"&&l.jsx("button",{onClick:()=>{C(i||""),N(c||""),b(!0)},className:"text-gray-400 hover:text-white",children:l.jsx(zj,{className:"h-5 w-5"})})]})]},j.provider))})}),l.jsx(pe,{title:"Simulated Live API Traffic",children:l.jsx("div",{className:"h-48",children:l.jsx(Pn,{width:"100%",height:"100%",children:l.jsxs(yd,{data:Array.from({length:20},(j,k)=>({name:k,calls:50+Math.random()*50})),children:[l.jsx("defs",{children:l.jsxs("linearGradient",{id:"apiColor",x1:"0",y1:"0",x2:"0",y2:"1",children:[l.jsx("stop",{offset:"5%",stopColor:"#06b6d4",stopOpacity:.8}),l.jsx("stop",{offset:"95%",stopColor:"#06b6d4",stopOpacity:0})]})}),l.jsx(at,{contentStyle:{backgroundColor:"rgba(31, 41, 55, 0.8)",borderColor:"#4b5563"}}),l.jsx(da,{type:"monotone",dataKey:"calls",stroke:"#06b6d4",fill:"url(#apiColor)"})]})})})})]})]})},tle=()=>{const e=S.useContext(Ct);if(!e)throw new Error("CreditHealthView must be within a DataProvider.");const{creditScore:t,creditFactors:n,geminiApiKey:r}=e,[i,o]=S.useState(""),[c,u]=S.useState(!1),m=async()=>{if(u(!0),!r){o("Please set your Gemini API key in the API Status view to get insights."),u(!1);return}try{const h=new ar({apiKey:r}),g=`A user has a credit score of ${t.score}. Their credit factors are: ${n.map(b=>`${b.name}: ${b.status}`).join(", ")}. Provide one concise, actionable tip to help them improve their score.`,v=await h.models.generateContent({model:"gemini-2.5-flash",contents:g});o(v.text)}catch(h){console.error("Error getting credit insight:",h),o("Could not generate a personalized tip at this time.")}finally{u(!1)}};S.useEffect(()=>{m()},[r]);const f=({status:h})=>{const g={Excellent:"bg-green-500",Good:"bg-cyan-500",Fair:"bg-yellow-500",Poor:"bg-red-500"};return l.jsx("div",{className:`w-3 h-3 rounded-full ${g[h]}`})};return l.jsxs("div",{className:"space-y-6",children:[l.jsx("h2",{className:"text-3xl font-bold text-white tracking-wider",children:"Credit Health"}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[l.jsx(pe,{title:"Your Credit Score",subtitle:`Rating: ${t.rating}`,children:l.jsx("p",{className:"text-7xl font-bold text-center text-white my-8",children:t.score})}),l.jsx(pe,{title:"AI-Powered Tip",children:l.jsx("div",{className:"flex flex-col justify-center items-center h-full text-center",children:c?l.jsx("p",{children:"Analyzing..."}):l.jsxs("p",{className:"text-gray-300 italic",children:['"',i,'"']})})})]}),l.jsx(pe,{title:"Factors Impacting Your Score",children:l.jsx("div",{className:"space-y-3",children:n.map(h=>l.jsxs("div",{className:"p-3 bg-gray-800/50 rounded-lg",children:[l.jsxs("div",{className:"flex justify-between items-center",children:[l.jsx("h4",{className:"font-semibold text-white",children:h.name}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(f,{status:h.status}),l.jsx("span",{className:"text-sm text-gray-300",children:h.status})]})]}),l.jsx("p",{className:"text-xs text-gray-400 mt-1",children:h.description})]},h.name))})})]})},nle=()=>l.jsxs("div",{className:"space-y-8 text-gray-300 max-w-4xl mx-auto",children:[l.jsxs("div",{className:"text-center",children:[l.jsx("h1",{className:"text-5xl font-bold text-white tracking-tighter bg-clip-text text-transparent bg-gradient-to-r from-cyan-400 to-indigo-500",children:"The Winning Vision"}),l.jsx("p",{className:"mt-4 text-lg text-gray-400",children:"This is not a bank. It is a financial co-pilot."})]}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6 text-center",children:[l.jsxs(pe,{variant:"outline",children:[l.jsx("h3",{className:"text-xl font-semibold text-cyan-300",children:"Hyper-Personalized"}),l.jsx("p",{className:"mt-2 text-sm",children:"Every pixel, insight, and recommendation is tailored to your unique financial journey."})]}),l.jsxs(pe,{variant:"outline",children:[l.jsx("h3",{className:"text-xl font-semibold text-cyan-300",children:"Proactive & Predictive"}),l.jsx("p",{className:"mt-2 text-sm",children:"We don't just show you the past; our AI anticipates your needs and guides your future."})]}),l.jsxs(pe,{variant:"outline",children:[l.jsx("h3",{className:"text-xl font-semibold text-cyan-300",children:"Platform for Growth"}),l.jsx("p",{className:"mt-2 text-sm",children:"A suite of tools for creators, founders, and businesses to build their visions upon."})]})]}),l.jsxs("div",{children:[l.jsx("h2",{className:"text-3xl font-semibold text-white mb-4",children:"Core Tenets"}),l.jsxs("ul",{className:"space-y-4",children:[l.jsxs("li",{className:"p-4 bg-gray-800/50 rounded-lg",children:[l.jsx("strong",{className:"text-cyan-400",children:"The AI is a Partner, Not Just a Tool:"})," Our integration with Google's Gemini API is designed for collaboration. From co-creating your bank card's design to generating a business plan, the AI is a creative and strategic partner."]}),l.jsxs("li",{className:"p-4 bg-gray-800/50 rounded-lg",children:[l.jsx("strong",{className:"text-cyan-400",children:"Seamless Integration is Reality:"})," We demonstrate enterprise-grade readiness with high-fidelity simulations of Plaid, Stripe, Marqeta, and Modern Treasury. This isn't a concept; it's a blueprint for a fully operational financial ecosystem."]}),l.jsxs("li",{className:"p-4 bg-gray-800/50 rounded-lg",children:[l.jsx("strong",{className:"text-cyan-400",children:"Finance is a Gateway, Not a Gatekeeper:"})," Features like the Quantum Weaver Incubator and the AI Ad Studio are designed to empower creation. We provide not just the capital, but the tools to build, market, and grow."]}),l.jsxs("li",{className:"p-4 bg-gray-800/50 rounded-lg",children:[l.jsx("strong",{className:"text-cyan-400",children:"The Future is Multi-Rail:"})," Our platform is fluent in both traditional finance (ISO 20022) and the decentralized future (Web3). The Crypto & Corporate hubs are designed to manage value, no matter how it's represented."]})]})]})]}),rle=()=>{const e=S.useContext(Ct);if(!e)throw new Error("RewardsView must be within a DataProvider.");const{rewardPoints:t,gamification:n,rewardItems:r,redeemReward:i}=e,[o,c]=S.useState(""),u=f=>{const h=i(f);c(h?`Successfully redeemed ${f.name}!`:`Not enough points for ${f.name}.`),setTimeout(()=>c(""),3e3)},m={cash:({className:f})=>l.jsx("svg",{className:f,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 9V7a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2m2 4h10a2 2 0 002-2v-6a2 2 0 00-2-2H9a2 2 0 00-2 2v6a2 2 0 002 2zm7-5a2 2 0 11-4 0 2 2 0 014 0z"})}),gift:({className:f})=>l.jsx("svg",{className:f,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v13m0-13V6a2 2 0 112 2h-2zm0 0V5.5A2.5 2.5 0 109.5 8H12zm-7 4h14M5 12a2 2 0 110-4h14a2 2 0 110 4H5z"})}),leaf:({className:f})=>l.jsx("svg",{className:f,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{d:"M10 3.5a1.5 1.5 0 011.5 1.5v.92l5.06 4.69a1.5 1.5 0 01-.18 2.4l-3.38 1.95a1.5 1.5 0 01-1.5-.26L10 12.43l-1.5 2.25a1.5 1.5 0 01-1.5.26l-3.38-1.95a1.5 1.5 0 01-.18-2.4l5.06-4.69V5A1.5 1.5 0 0110 3.5z"})})};return l.jsxs("div",{className:"space-y-6",children:[l.jsx("h2",{className:"text-3xl font-bold text-white tracking-wider",children:"Rewards Hub"}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[l.jsx(pe,{title:"Your Points",className:"md:col-span-1",children:l.jsxs("div",{className:"text-center",children:[l.jsx("p",{className:"text-5xl font-bold text-cyan-300",children:t.balance.toLocaleString()}),l.jsx("p",{className:"text-gray-400",children:t.currency})]})}),l.jsx(pe,{title:"Your Level",className:"md:col-span-2",children:l.jsxs("div",{className:"flex items-center gap-6",children:[l.jsxs("h3",{className:"text-2xl font-semibold text-white flex-1",children:[n.levelName," ",l.jsxs("span",{className:"text-base text-gray-400",children:["(Level ",n.level,")"]})]}),l.jsx("div",{className:"w-full max-w-xs",children:l.jsx("div",{className:"w-full bg-gray-700 rounded-full h-2.5",children:l.jsx("div",{className:"bg-gradient-to-r from-cyan-500 to-indigo-500 h-2.5 rounded-full",style:{width:`${n.progress}%`}})})})]})})]}),l.jsxs(pe,{title:"Redeem Your Points",children:[o&&l.jsx("p",{className:"text-center mb-4 text-cyan-200",children:o}),l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:r.map(f=>{const h=m[f.iconName];return l.jsxs("div",{className:"p-4 bg-gray-800/50 rounded-lg flex flex-col",children:[l.jsx(h,{className:"w-8 h-8 text-cyan-400 mb-2"}),l.jsx("h4",{className:"font-semibold text-white flex-grow",children:f.name}),l.jsx("p",{className:"text-xs text-gray-400 my-2",children:f.description}),l.jsxs("div",{className:"flex justify-between items-center mt-auto",children:[l.jsxs("p",{className:"font-mono text-cyan-300",children:[f.cost.toLocaleString()," pts"]}),l.jsx("button",{onClick:()=>u(f),disabled:t.balancel.jsxs("div",{className:"space-y-6 max-w-2xl mx-auto",children:[l.jsx("h2",{className:"text-3xl font-bold text-white tracking-wider",children:"Settings"}),l.jsxs(pe,{title:"Profile",children:[l.jsxs("p",{className:"text-gray-400",children:["Name: ",l.jsx("span",{className:"text-white",children:"The Visionary"})]}),l.jsxs("p",{className:"text-gray-400",children:["Email: ",l.jsx("span",{className:"text-white",children:"visionary@demobank.com"})]})]}),l.jsxs(pe,{title:"Notification Preferences",children:[l.jsxs("div",{className:"flex justify-between items-center",children:[l.jsx("p",{children:"Large Transaction Alerts"}),l.jsx("input",{type:"checkbox",className:"toggle toggle-sm toggle-cyan",defaultChecked:!0})]}),l.jsxs("div",{className:"flex justify-between items-center",children:[l.jsx("p",{children:"Budget Warnings"}),l.jsx("input",{type:"checkbox",className:"toggle toggle-sm toggle-cyan",defaultChecked:!0})]}),l.jsxs("div",{className:"flex justify-between items-center",children:[l.jsx("p",{children:"AI Insight Notifications"}),l.jsx("input",{type:"checkbox",className:"toggle toggle-sm toggle-cyan"})]})]}),l.jsx(pe,{title:"Theme",children:l.jsxs("p",{className:"text-sm text-gray-400",children:["Theme settings are managed in the ",l.jsx("span",{className:"font-semibold text-cyan-300",children:"Personalization"})," view."]})})]}),ale=()=>{const e=S.useContext(Ct),[t,n]=S.useState("An isolated lighthouse on a stormy sea, with a powerful beam of light cutting through the darkness."),[r,i]=S.useState(!1),[o,c]=S.useState(""),[u,m]=S.useState(null);if(!e)throw new Error("PersonalizationView must be within a DataProvider.");const{setCustomBackgroundUrl:f,setActiveIllusion:h,activeIllusion:g,geminiApiKey:v}=e,b=async()=>{if(t){if(i(!0),c(""),!v){c("Please set your Gemini API key in the API Status view to generate images."),i(!1);return}try{const M=`data:image/jpeg;base64,${(await new ar({apiKey:v}).models.generateImages({model:"imagen-4.0-generate-001",prompt:t,config:{numberOfImages:1,outputMimeType:"image/jpeg"}})).generatedImages[0].image.imageBytes}`;f(M)}catch(N){console.error("Image generation error:",N),c("Sorry, I couldn't generate the image. Please try again.")}finally{i(!1)}}},T=[{id:"none",name:"None"},{id:"aurora",name:"Aurora"}],C=()=>{m({name:"Tropical Sunset",justification:"Your 'Cyberpunk Vacation' savings goal inspired me to find a theme that matches your dream destination.",type:"image",url:"/IMG_5610.webp"})},E=()=>{u&&(u.type==="image"&&u.url?f(u.url):(u.type==="aurora"||u.type==="none")&&h(u.type))};return l.jsxs("div",{className:"space-y-6",children:[l.jsx(pe,{title:"Heuristic API Theme Suggestions",children:l.jsx("div",{className:"flex flex-col items-center text-center",children:u?l.jsxs("div",{children:[l.jsxs("h4",{className:"font-semibold text-cyan-300",children:["Theme Suggestion: ",u.name]}),l.jsxs("p",{className:"text-sm text-gray-400 italic my-2",children:['"',u.justification,'"']}),l.jsx("button",{onClick:E,className:"px-4 py-2 bg-cyan-600 hover:bg-cyan-700 text-white rounded-lg text-sm",children:"Apply Theme"})]}):l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-gray-400 mb-4",children:"Let the Heuristic API suggest a personalized theme based on your financial goals and activity."}),l.jsx("button",{onClick:C,className:"px-4 py-2 bg-cyan-600/50 hover:bg-cyan-600 text-white rounded-lg text-sm",children:"Suggest a Theme"})]})})}),l.jsxs("div",{className:"bg-gray-800/50 backdrop-blur-sm border border-gray-700/60 rounded-xl shadow-lg p-6",children:[l.jsx("h3",{className:"text-xl font-semibold text-gray-100 mb-4",children:"Generate App Background"}),l.jsx("p",{className:"text-gray-400 mb-4",children:"Describe the background you want to see, and let AI create it for you. This will disable any active dynamic visual."}),l.jsxs("div",{className:"space-y-4",children:[l.jsx("textarea",{value:t,onChange:N=>n(N.target.value),placeholder:"e.g., A calm zen garden with a flowing river",className:"w-full h-24 bg-gray-700/50 border border-gray-600 rounded-lg px-4 py-2 text-white focus:outline-none focus:ring-2 focus:ring-cyan-500",disabled:r}),l.jsx("button",{onClick:b,disabled:r||!t,className:"w-full flex justify-center py-3 px-4 border border-transparent rounded-lg shadow-sm text-sm font-medium text-white bg-cyan-600 hover:bg-cyan-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-cyan-500 disabled:opacity-50 disabled:cursor-not-allowed",children:r?"Generating...":"Generate Background"}),o&&l.jsx("p",{className:"text-red-400 text-center",children:o})]})]}),l.jsxs("div",{className:"bg-gray-800/50 backdrop-blur-sm border border-gray-700/60 rounded-xl shadow-lg p-6",children:[l.jsx("h3",{className:"text-xl font-semibold text-gray-100 mb-4",children:"Dynamic Visuals"}),l.jsx("p",{className:"text-gray-400 mb-4",children:"Choose a dynamic, reality-bending background for the app. This will override any generated background image."}),l.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:T.map(N=>l.jsx("button",{onClick:()=>h(N.id),className:`py-3 px-4 rounded-lg text-sm font-medium transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-800 focus:ring-cyan-500 + ${g===N.id?"bg-cyan-600 text-white shadow-lg":"bg-gray-700/50 hover:bg-gray-700 text-gray-300"}`,children:N.name},N.id))})]})]})},ole=()=>{const e=S.useContext(Ct);if(!e)throw new Error("CardCustomizationView must be within a DataProvider.");const{geminiApiKey:t}=e,[n,r]=S.useState(null),[i,o]=S.useState("Add a phoenix rising from the center, with its wings made of glowing data streams."),[c,u]=S.useState(null),[m,f]=S.useState(!1),[h,g]=S.useState(""),[v,b]=S.useState(""),[T,C]=S.useState(!1),[E,N]=S.useState(50),[I,P]=S.useState(!1),M=G=>new Promise((H,V)=>{const oe=new FileReader;oe.readAsDataURL(G),oe.onload=()=>H(oe.result.split(",")[1]),oe.onerror=Z=>V(Z)}),j=async G=>{if(G.target.files&&G.target.files[0]){const H=G.target.files[0],V=await M(H);r(`data:${H.type};base64,${V}`),u(null)}},k=async()=>{var G,H,V,oe;if(!(!n||!i)){if(f(!0),g(""),u(null),!t){g("Please set your Gemini API key in the API Status view to edit images."),f(!1);return}try{const Z=new ar({apiKey:t}),me=n.split(",")[1],z=((G=n.match(/:(.*?);/))==null?void 0:G[1])||"image/jpeg",ce=(oe=(V=(H=(await Z.models.generateContent({model:"gemini-2.5-flash-image",contents:{parts:[{inlineData:{data:me,mimeType:z}},{text:i}]},config:{responseModalities:[Mu.IMAGE]}})).candidates)==null?void 0:H[0])==null?void 0:V.content)==null?void 0:oe.parts.find(ge=>ge.inlineData);if(ce!=null&&ce.inlineData){const ge=ce.inlineData.data;u(`data:${ce.inlineData.mimeType};base64,${ge}`)}else g("The AI didn't return an image. Try a different prompt.")}catch(Z){console.error("Image editing error:",Z),g("Sorry, I couldn't edit the image. Please try again.")}finally{f(!1)}}},R=async()=>{if(C(!0),b(""),!t){b("Please set your Gemini API key in the API Status view to generate stories."),C(!1);return}try{const G=new ar({apiKey:t}),H=`Based on this generative AI prompt for a credit card design, write a short, inspiring "Card Story" (2-3 sentences) about what this card represents. +Prompt: "${i}" +Effects: ${E>0?"Metallic sheen, ":""}${I?"Holographic effect":""}`,V=await G.models.generateContent({model:"gemini-2.5-flash",contents:H});b(V.text)}catch(G){console.error("Card story generation error:",G),b("Could not generate a story for this design.")}finally{C(!1)}},F=c||n,q={"--metallic-sheen":`${E}%`};return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"bg-gray-800/50 backdrop-blur-sm border border-gray-700/60 rounded-xl shadow-lg p-6",children:[l.jsx("h3",{className:"text-xl font-semibold text-gray-100 mb-4",children:"Design Your Card"}),l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8 items-start",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-gray-400 mb-4",children:"Upload a base image, describe your changes, and add physical effects."}),l.jsxs("div",{className:"space-y-4",children:[l.jsx("input",{type:"file",accept:"image/*",onChange:j,className:"block w-full text-sm text-gray-400 file:mr-4 file:py-2 file:px-4 file:rounded-full file:border-0 file:text-sm file:font-semibold file:bg-cyan-600/50 file:text-cyan-200 hover:file:bg-cyan-600"}),l.jsx("textarea",{value:i,onChange:G=>o(G.target.value),placeholder:"e.g., Make this image look like a watercolor painting",className:"w-full h-24 bg-gray-700/50 border border-gray-600 rounded-lg px-4 py-2 text-white focus:outline-none focus:ring-2 focus:ring-cyan-500",disabled:m||!n}),l.jsx("button",{onClick:k,disabled:m||!n||!i,className:"w-full flex justify-center py-3 px-4 border border-transparent rounded-lg shadow-sm text-sm font-medium text-white bg-cyan-600 hover:bg-cyan-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-cyan-500 disabled:opacity-50 disabled:cursor-not-allowed",children:m?"Generating...":"Generate Image"}),h&&l.jsx("p",{className:"text-red-400 text-center",children:h})]})]}),l.jsxs("div",{className:"flex flex-col items-center",children:[l.jsx("p",{className:"text-gray-400 mb-2",children:"Card Preview"}),l.jsxs("div",{style:q,className:`w-full max-w-sm aspect-[85.6/54] rounded-xl bg-gray-900/50 overflow-hidden shadow-2xl border border-gray-600 flex items-center justify-center relative ${I?"holo-effect":""}`,children:[l.jsx("div",{className:"absolute inset-0 metallic-overlay",style:{opacity:E/200}}),m&&l.jsx("div",{className:"text-cyan-300",children:"Generating..."}),!m&&F&&l.jsx("img",{src:F,alt:"Card Preview",className:"w-full h-full object-cover"}),!m&&!F&&l.jsx("div",{className:"text-gray-500",children:"Upload an image to start"})]})]})]})]}),l.jsxs("div",{className:"bg-gray-800/50 backdrop-blur-sm border border-gray-700/60 rounded-xl shadow-lg p-6",children:[l.jsx("h3",{className:"text-xl font-semibold text-gray-100 mb-4",children:"Add Physical Effects"}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsxs("label",{className:"text-gray-300",children:["Metallic Sheen: ",E,"%"]}),l.jsx("input",{type:"range",min:"0",max:"100",value:E,onChange:G=>N(Number(G.target.value)),className:"w-full h-2 bg-gray-700 rounded-lg appearance-none cursor-pointer"})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("label",{className:"text-gray-300",children:"Holographic Effect"}),l.jsx("input",{type:"checkbox",checked:I,onChange:G=>P(G.target.checked),className:"toggle toggle-sm toggle-cyan"})]})]})]}),l.jsxs(pe,{title:"AI-Generated Card Story",children:[T?l.jsx("p",{children:"Generating story..."}):v?l.jsxs("p",{className:"text-gray-300 italic",children:['"',v,'"']}):l.jsx("p",{className:"text-gray-400",children:"Generate a story for your unique card design."}),l.jsx("button",{onClick:R,disabled:T,className:"mt-4 px-4 py-2 bg-cyan-600/50 hover:bg-cyan-600 text-white rounded-lg text-sm",children:T?"Writing...":"Generate Story"})]}),l.jsx("style",{children:` + .toggle-cyan:checked { background-color: #06b6d4; } + .metallic-overlay { + background: linear-gradient(110deg, rgba(255,255,255,0) 40%, rgba(255,255,255,0.4) 50%, rgba(255,255,255,0) 60%); + mix-blend-mode: overlay; + pointer-events: none; + } + .holo-effect { + position: relative; + overflow: hidden; + } + .holo-effect::before { + content: ''; + position: absolute; + top: -50%; left: -50%; + width: 200%; height: 200%; + background: linear-gradient(110deg, transparent 20%, #ff00ff, #00ffff, #ffff00, #ff00ff, transparent 80%); + animation: holo-spin 8s linear infinite; + opacity: 0.2; + mix-blend-mode: screen; + } + @keyframes holo-spin { + from { transform: rotate(0deg); } + to { transform: rotate(360deg); } + } + `})]})},sle=()=>{const e=S.useContext(Ct);if(!e)throw new Error("App must be used within a DataProvider.");const{customBackgroundUrl:t,activeIllusion:n}=e,[r,i]=S.useState(ve.Dashboard),[o,c]=S.useState(null),[u,m]=S.useState(!1),f=v=>{v!==r&&c(r),i(v)},h=()=>{switch(r){case ve.Dashboard:return l.jsx(wj,{setActiveView:f});case ve.Transactions:return l.jsx(Kie,{});case ve.SendMoney:return l.jsx(eae,{setActiveView:f});case ve.Budgets:return l.jsx(Nae,{});case ve.Investments:return l.jsx(nae,{});case ve.AIAdvisor:return l.jsx(wae,{previousView:o});case ve.QuantumWeaver:return l.jsx(Poe,{});case ve.AIAdStudio:return l.jsx(Fse,{});case ve.Marketplace:return l.jsx(Goe,{});case ve.Personalization:return l.jsx(ale,{});case ve.CardCustomization:return l.jsx(ole,{});case ve.Security:return l.jsx(Aae,{});case ve.Goals:return l.jsx(Zse,{});case ve.Crypto:return l.jsx(qse,{});case ve.CorporateCommand:return l.jsx(yse,{setActiveView:f});case ve.ModernTreasury:return l.jsx(vse,{});case ve.SASPlatforms:return l.jsx(nle,{});case ve.APIIntegration:return l.jsx(ele,{});case ve.OpenBanking:return l.jsx(jse,{});case ve.Rewards:return l.jsx(rle,{});case ve.CreditHealth:return l.jsx(tle,{});case ve.Settings:return l.jsx(ile,{});case ve.FinancialDemocracy:return l.jsx(kse,{});default:return l.jsx(wj,{setActiveView:f})}},g=t?{backgroundImage:`url(${t})`}:{};return l.jsxs("div",{id:"app-container",style:g,className:`bg-cover bg-center bg-fixed ${n==="aurora"?"aurora-bg":""}`,children:[l.jsxs("div",{className:"flex h-screen bg-gray-950/80 text-gray-200 backdrop-blur-xl",children:[l.jsx(QB,{activeView:r,setActiveView:f,isOpen:u,setIsOpen:m}),l.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[l.jsx(pB,{onMenuClick:()=>m(v=>!v),setActiveView:f}),l.jsx("main",{className:"flex-1 overflow-x-hidden overflow-y-auto p-6 relative",children:h()})]}),l.jsx(jae,{setActiveView:f})]}),n==="aurora"&&l.jsx("style",{children:` + .aurora-bg { + background: #030712; + position: relative; + overflow: hidden; + } + .aurora-bg::before, .aurora-bg::after { + content: ''; + position: absolute; + width: 800px; + height: 800px; + border-radius: 50%; + filter: blur(150px); + opacity: 0.3; + mix-blend-mode: screen; + animation: aurora-flow 20s infinite linear; + } + .aurora-bg::before { + background: radial-gradient(circle, #06b6d4, transparent); + top: -20%; left: -20%; + } + .aurora-bg::after { + background: radial-gradient(circle, #4f46e5, transparent); + bottom: -20%; right: -20%; + animation-delay: -10s; + } + @keyframes aurora-flow { + 0% { transform: translate(0, 0) rotate(0deg); } + 50% { transform: translate(100px, 100px) rotate(180deg); } + 100% { transform: translate(0, 0) rotate(360deg); } + } + `})]})},QI=document.getElementById("root");if(!QI)throw new Error("Could not find root element to mount to");const lle=gR.createRoot(QI);lle.render(l.jsx(oh.StrictMode,{children:l.jsx(mB,{children:l.jsx(sle,{})})}));