@amd-gaia/agent-ui 0.26.0-rc.1 → 0.26.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AdvancedSettings-D8P_x4lg.js → AdvancedSettings-DhQOkz13.js} +1 -1
- package/dist/assets/{ConnectorsPane-Byq5_CvM.js → ConnectorsPane-DZSS3unX.js} +1 -1
- package/dist/assets/{DocumentLibrary-B8SHRZpL.js → DocumentLibrary-Bxi2x5Ry.js} +1 -1
- package/dist/assets/{FileBrowser-OU9tD0Ek.js → FileBrowser-lOETG5oo.js} +1 -1
- package/dist/assets/{MemoryDashboard-D2A5sTz6.js → MemoryDashboard-Evh8x9AG.js} +1 -1
- package/dist/assets/{MobileAccessModal-BgeK3LK3.js → MobileAccessModal-jZP8OcFv.js} +1 -1
- package/dist/assets/{ScheduleManager-Bye5OV6N.js → ScheduleManager-CoagpVqW.js} +1 -1
- package/dist/assets/{index-Cw3Kx9eq.js → index-D8wu2yy4.js} +3 -3
- package/dist/index.html +1 -1
- package/dist/sw.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ConnectorsPane-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ConnectorsPane-DZSS3unX.js","./rolldown-runtime-XKyaHtl9.js","./useT-C0ow1Kps.js","./api-9RdlUJAP.js","./ConnectorsPane-CzLYXGMl.css","./AdvancedSettings-DhQOkz13.js","./MemoryDashboard-Evh8x9AG.js","./zap-D2mvP3-6.js","./MemoryDashboard-DwrWAXi6.css","./ScheduleManager-CoagpVqW.js","./ScheduleManager-CjHJ4NbD.css","./DocumentLibrary-Bxi2x5Ry.js","./DocumentLibrary-CM6o8j2T.css","./FileBrowser-lOETG5oo.js","./FileBrowser-Cna3BsT7.css","./MobileAccessModal-jZP8OcFv.js","./MobileAccessModal-BkVDm3YG.css"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{n as e,r as t,t as n}from"./rolldown-runtime-XKyaHtl9.js";import{A as r,B as i,C as a,D as o,E as s,F as c,G as l,H as u,I as d,J as f,K as p,L as m,M as h,N as g,O as _,R as v,S as y,T as b,U as x,V as S,W as C,_ as w,a as T,b as E,c as D,d as O,f as k,g as A,h as j,j as M,k as N,l as P,m as F,n as I,o as L,p as ee,q as R,r as z,s as B,t as te,u as V,v as ne,w as re,x as ie,y as ae,z as oe}from"./useT-C0ow1Kps.js";import{$ as H,$n as U,$t as se,A as W,An as G,B as ce,Bn as le,Bt as ue,C as de,D as fe,Dt as pe,E as me,En as he,Et as ge,F as _e,Fn as ve,Ft as ye,G as be,Gn as xe,Gt as Se,Hn as Ce,Ht as we,In as Te,It as Ee,J as De,Jn as Oe,Jt as ke,K as Ae,Kn as je,L as Me,Ln as Ne,Lt as Pe,M as Fe,Mn as Ie,Mt as Le,N as Re,Nn as ze,Nt as Be,O as Ve,On as He,Ot as Ue,P as We,Pn as Ge,Pt as Ke,Qn as qe,Qt as Je,R as Ye,Rn as Xe,Rt as Ze,S as Qe,St as $e,T as et,Tt as tt,U as nt,Un as rt,Ut as it,V as at,Vn as ot,Vt as st,W as ct,Wn as lt,Wt as ut,X as dt,Xn as ft,Xt as pt,Y as mt,Yn as ht,Z as gt,Zn as _t,Zt as vt,_ as yt,_t as bt,a as xt,an as St,b as Ct,bt as wt,c as Tt,cn as Et,ct as Dt,d as Ot,dn as kt,dt as At,en as jt,er as Mt,et as Nt,fn as Pt,ft as Ft,g as It,gt as Lt,h as Rt,ht as zt,i as Bt,in as Vt,it as Ht,j as Ut,jn as Wt,jt as Gt,k as Kt,kn as qt,kt as Jt,l as Yt,ln as Xt,lt as Zt,m as Qt,mn as $t,mt as en,nn as tn,nt as nn,o as rn,on as an,ot as on,p as sn,pt as cn,q as ln,qn as un,qt as dn,r as fn,rn as pn,rt as mn,s as hn,sn as gn,st as _n,t as vn,tn as yn,tr as bn,tt as xn,u as Sn,un as Cn,ut as wn,v as Tn,vt as En,w as Dn,x as On,xn as kn,yt as An,z as jn,zn as Mn,zt as Nn}from"./api-9RdlUJAP.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Pn=n((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}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(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Fn=n(((e,t)=>{t.exports=Pn()})),In=n((e=>{var t=f();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`),o=Symbol.for(`react.recoverable`),s=Symbol.for(`react.optimistic_key`);function c(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:r===s?s:``+r,children:e,containerInfo:t,implementation:n}}var l=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.browser=function(e){return{$$typeof:o,_reason:e}},e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return c(e,t,null,r)},e.flushSync=function(e){var t=l.T,n=i.p;try{if(l.T=null,i.p=2,e)return e()}finally{l.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=u(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}}else t??i.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=u(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}else i.d.m(e)}},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return l.H.useFormState(e,t,n)},e.useFormStatus=function(){return l.H.useHostTransitionStatus()},e.version=`19.3.1`})),Ln=n(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=In()})),Rn=n((e=>{var t=Fn(),n=f(),r=Ln();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}function p(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&p(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function m(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function h(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function g(e){var t=[null,null],n=m(e);return n===null||_(t,e,n.child,{foundSelf:!1}),t}function _(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&_(e,t,n.child,r))return!0;n=n.sibling}return!1}function v(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(i(559))}}var y=null,b=null;function x(e,t,n){return e===n||e===t&&(y=e,!0)}function S(e,t,n){return e===n?(b=e,!1):e===t&&(b!==null&&(y=e),!0)}function C(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function w(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var T=Object.assign,E=Symbol.for(`react.element`),D=Symbol.for(`react.transitional.element`),O=Symbol.for(`react.portal`),k=Symbol.for(`react.fragment`),A=Symbol.for(`react.strict_mode`),j=Symbol.for(`react.profiler`),M=Symbol.for(`react.consumer`),N=Symbol.for(`react.context`),P=Symbol.for(`react.forward_ref`),F=Symbol.for(`react.suspense`),I=Symbol.for(`react.suspense_list`),L=Symbol.for(`react.memo`),ee=Symbol.for(`react.lazy`),R=Symbol.for(`react.activity`),z=Symbol.for(`react.legacy_hidden`),B=Symbol.for(`react.memo_cache_sentinel`),te=Symbol.for(`react.view_transition`),V=Symbol.for(`react.recoverable`),ne=Symbol.iterator;function re(e){return typeof e!=`object`||!e?null:(e=ne&&e[ne]||e[`@@iterator`],typeof e==`function`?e:null)}var ie=Symbol.for(`react.client.reference`);function ae(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ie?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case k:return`Fragment`;case j:return`Profiler`;case A:return`StrictMode`;case F:return`Suspense`;case I:return`SuspenseList`;case R:return`Activity`;case te:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case O:return`Portal`;case N:return e.displayName||`Context`;case M:return(e._context.displayName||`Context`)+`.Consumer`;case P:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case L:return t=e.displayName||null,t===null?ae(e.type)||`Memo`:t;case ee:t=e._payload,e=e._init;try{return ae(e(t))}catch{}}return null}var oe=Array.isArray,H=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,U=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,se={pending:!1,data:null,method:null,action:null},W=[],G=-1;function ce(e){return{current:e}}function le(e){0>G||(e.current=W[G],W[G]=null,G--)}function ue(e,t){G++,W[G]=e.current,e.current=t}var de=ce(null),fe=ce(null),pe=ce(null),me=ce(null);function he(e,t){switch(ue(pe,t),ue(fe,e),ue(de,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?dp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=dp(t),e=fp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}le(de),ue(de,e)}function ge(){le(de),le(fe),le(pe)}function _e(e){var t=e.memoizedState;t!==null&&(ch._currentValue=t.memoizedState,ue(me,e)),t=de.current;var n=fp(t,e.type);t!==n&&(ue(fe,e),ue(de,n))}function ve(e){fe.current===e&&(le(de),le(fe)),me.current===e&&(le(me),ch._currentValue=se)}var ye,be;function xe(e){if(ye===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ye=t&&t[1]||``,be=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+ye+e+be}var Se=!1;function Ce(e,t){if(!e||Se)return``;Se=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}n=!1;try{var i=Object.getOwnPropertyDescriptor(e.prototype,`props`);Object.defineProperty(e.prototype,"props",{configurable:!0,set:function(){throw Error()}}),n=!0,new e}finally{n&&(i===void 0?delete e.prototype.props:Object.defineProperty(e.prototype,"props",i))}}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
@@ -57,7 +57,7 @@ Error generating stack: `+e.message+`
|
|
|
57
57
|
`)}function FC(e,t){return e?new Date(e).toLocaleString(te(t),{month:`short`,day:`numeric`,year:`numeric`,hour:`numeric`,minute:`2-digit`,second:`2-digit`,hour12:!0}):``}var IC=`Cancelled.`,LC=[[`This answer was interrupted when GAIA closed. Send again to retry.`,`msg.cutOff.interrupted`],[`This answer was interrupted before it finished. Send again to retry.`,`msg.cutOff.cancelled`],[`This answer ended before GAIA could save a reply. Send again to retry.`,`msg.cutOff.noReply`]],RC=/(?:^|\n\n)Before it stopped, it had started these tools: (.+)\.$/;function zC(e){let t=e.trim(),n=LC.find(([e])=>t.endsWith(e));if(!n)return null;t=t.slice(0,-n[0].length).trimEnd();let r=RC.exec(t);return r&&(t=t.slice(0,r.index).trimEnd()),{body:t,notice:n[1],tools:r?r[1]:null}}function BC(e,t){return t?`stopped`:zC(e)?`interrupted`:void 0}function VC({message:e,isStreaming:t,agentSteps:n,agentStepsActive:r,cards:i,onDelete:a,onResend:o,extraActions:s,onTryAgain:c,latencyMs:l,liveStatus:u,toolStatus:d,awaitingUser:f}){let p=T();ls();let m=(0,J.useMemo)(()=>e.role===`assistant`&&!t&&n?xC(n,e.content):{steps:n,echoed:!1},[n,e.content,e.role,t]),h=e.role===`assistant`&&(m.echoed||e.failed===!0||yC(e.content)),g=e.role===`assistant`?e.stopState??(e.content.trim()===IC?`stopped`:void 0):void 0,_=(0,J.useMemo)(()=>e.role===`assistant`&&!t?zC(e.content):null,[e.content,e.role,t]),v=(0,J.useMemo)(()=>e.role===`user`?e.content:NC(_?_.body:e.content,!!t),[e.content,e.role,t,_]),y=`${e.session_id}:${e.id}`,[b,x]=(0,J.useState)(!1),[S,C]=(0,J.useState)(!1),w=e.role===`user`&&my(e.content),[E,O]=(0,J.useState)(!1),k=(0,J.useId)(),A=(0,J.useRef)(null),j=(0,J.useRef)(!1),M=(0,J.useCallback)(()=>{E&&(j.current=!0),O(!E)},[E]);(0,J.useEffect)(()=>{!E&&j.current&&(j.current=!1,A.current?.scrollIntoView?.({block:`nearest`}))},[E]);let N=(0,J.useRef)(null),F=(0,J.useRef)(null);(0,J.useEffect)(()=>()=>{N.current&&clearTimeout(N.current),F.current&&clearTimeout(F.current)},[]);let I=(0,J.useCallback)(()=>{if(navigator.clipboard?.writeText)navigator.clipboard.writeText(e.content).catch(()=>{});else{let t=document.createElement(`textarea`);t.value=e.content,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select(),document.execCommand(`copy`),document.body.removeChild(t)}x(!0),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>x(!1),2e3)},[e.content]),L=(0,J.useCallback)(()=>{S?(C(!1),F.current&&clearTimeout(F.current),a?.(e.id)):(C(!0),F.current&&clearTimeout(F.current),F.current=setTimeout(()=>C(!1),3e3))},[S,e.id,a]),ee=(0,J.useCallback)(()=>{o?.(e)},[e,o]),R=e.created_at?p(e.role===`user`?`msg.sent`:`msg.replied`,{time:FC(e.created_at,p)}):void 0;return P(`div`,{className:`msg msg-${e.role} ${h?`msg-error`:``}`,title:R,children:V(`div`,{className:`msg-inner`,children:[V(`div`,{className:`msg-header`,children:[P(`div`,{className:`msg-header-left`}),!t&&V(`div`,{className:`msg-actions`,children:[e.role===`user`&&o&&P(`button`,{className:`msg-action-btn`,onClick:ee,title:p(`msg.resend`),"aria-label":p(`msg.resend`),children:P(Pa,{size:12})}),s,e.role===`assistant`&&!h&&v.trim()&&P(TS,{messageId:y,content:v}),P(`button`,{className:`msg-copy ${b?`copied`:``}`,onClick:I,title:p(b?`msg.copied`:`msg.copy`),"aria-label":p(b?`msg.copiedAria`:`msg.copy`),children:P(b?pr:zr,{size:12})}),a&&P(`button`,{className:`msg-action-btn msg-delete ${S?`confirm`:``}`,onClick:L,title:p(S?`msg.confirmDelete`:`msg.delete`),"aria-label":p(S?`msg.confirmDeleteAria`:`msg.delete`),children:P(co,{size:12})})]})]}),V(`div`,{className:`msg-body`,children:[e.role===`assistant`&&(m.steps&&m.steps.length>0||t)&&P(eb,{steps:m.steps??[],isActive:r??!1,running:!!t,awaitingUser:f,toolStatus:t?d:null,answer:t?void 0:v,liveLine:t&&P(hC,{active:!!r||!v,label:u,awaitingUser:f})}),h&&V(`div`,{className:`error-banner`,children:[P(q,{size:14}),P(`span`,{children:p(`msg.error`)})]}),(e.cards??i)?.map((e,t)=>P(gx,{render:e.render,data:e.data},t)),w?V(D.Fragment,{children:[P(`div`,{ref:A,id:k,className:`msg-collapsible${E?``:` is-collapsed`}`,children:P(ow,{content:v})}),P(gy,{expanded:E,onToggle:M,controls:k,collapsedLabel:p.hint(p(`msg.showAll`),hy(e.content)),expandedLabel:p(`msg.showLess`),className:`msg-expand-toggle`})]}):!(g&&v.trim()===IC)&&P(ow,{content:v,showCursor:t&&!!v&&!r,isStreaming:t}),g&&V(`div`,{className:`msg-stopped${g===`unconfirmed`||e.stopError?` is-unconfirmed`:``}`,role:`note`,children:[P(io,{size:9,fill:`currentColor`,"aria-hidden":`true`}),P(`span`,{children:g===`unconfirmed`?p(`msg.stoppedUnconfirmed`):e.stopError?p(`msg.stoppedError`,{error:e.stopError}):p(`msg.stopped`)})]}),_&&P(`p`,{className:`msg-cut-off`,role:`note`,children:p.compose(e=>_.tools?`${e(`msg.cutOff.toolsRan`,{tools:_.tools})} ${e(_.notice)}`:e(_.notice))}),c&&!t&&V(`button`,{type:`button`,className:`msg-try-again`,onClick:c,children:[P(Ra,{size:12,"aria-hidden":`true`}),p(`msg.tryAgain`)]}),e.role===`assistant`&&!t&&($S(e.content)||$S(e.failureText??``))&&P(tC,{classes:vC,note:p(`msg.reportNote`)}),e.role===`assistant`&&!t&&Sb(v)&&P(Eb,{content:v}),e.role===`assistant`&&!t&&(e.stats||l!=null||e.created_at)&&V(`div`,{className:`msg-stats`,"aria-label":p(`msg.about`),children:[e.created_at&&P(`span`,{className:`msg-stats-ts`,title:p(`msg.timestamp`),children:FC(e.created_at,p)}),e.stats?.retried&&e.stats.model&&P(`span`,{title:`This answer was kept from Retry with… (${e.stats.model})`,children:ds(e.stats.model)}),P(Tx,{latencyMs:l,stats:e.stats,ended:BC(e.content,g)})]}),e.role===`assistant`&&!t&&e.id>0&&e.session_id&&P(uS,{sessionId:e.session_id,messageId:e.id}),e.role===`assistant`&&P(ES,{messageId:y}),e.role===`assistant`&&P(DS,{messageId:y})]})]})})}var HC=(0,J.createContext)(!1);function UC({lang:e,code:t}){let n=T(),[r,i]=(0,J.useState)(!1),[a,o]=(0,J.useState)(!1),s=(0,J.useContext)(HC),c=(0,J.useId)(),l=py(t),u=l>(s?20:25),d=u&&!a,f=(0,J.useRef)(null);(0,J.useEffect)(()=>()=>{f.current&&clearTimeout(f.current)},[]);let p=(0,J.useCallback)(()=>{if(navigator.clipboard?.writeText)navigator.clipboard.writeText(t).catch(()=>{});else{let e=document.createElement(`textarea`);e.value=t,e.style.position=`fixed`,e.style.opacity=`0`,document.body.appendChild(e),e.select(),document.execCommand(`copy`),document.body.removeChild(e)}i(!0),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>i(!1),2e3)},[t]);return V(`div`,{className:`code-block${d?` is-collapsed`:``}`,dir:`ltr`,children:[V(`div`,{className:`code-header`,children:[P(`span`,{className:`code-lang`,children:e||`code`}),V(`button`,{className:`code-copy ${r?`copied`:``}`,onClick:p,title:n(r?`msg.copied`:`code.copy`),"aria-label":n(r?`msg.copiedAria`:`code.copyAria`),children:[P(r?pr:zr,{size:13}),P(`span`,{children:n(r?`code.copied`:`code.copy`)})]})]}),P(`pre`,{id:c,children:P(`code`,{children:t})}),u&&P(gy,{expanded:a,onToggle:()=>o(e=>!e),controls:c,collapsedLabel:`Expand (${l.toLocaleString(`en-US`)} lines)`,expandedLabel:`Collapse`,className:`code-expand-toggle`})]})}var WC=/(?<=["\u201c])[A-Z]:[\\/][^*?"<>|\r\n\u201c\u201d]+(?=["\u201d])|\b[A-Z]:[\\/](?=[^\s*?"<>|,;)}\]\\/])(?:[^\s*?"<>|,;)}\]\\/]+(?:(?: +(?:[^\s*?"<>|,;:)}\]\\/]+|\([^\s*?"<>|,;:)}\]\\/]+\)))+\\|[\\/]))*(?:(?:[^\s*?"<>|,;:.)}\]\\/]+ +){1,2}[^\s*?"<>|,;)}\]\\/]+\.[A-Za-z0-9]{1,5}\b|[^\s*?"<>|,;)}\]\\/]+)?/gi,GC=/[.:!']+$/,KC=RegExp(`^(?:${WC.source})$`,`i`);function qC(e){if(typeof e!=`string`)return null;let t=e.trim();return KC.test(t)?t:null}function JC({path:e}){let t=t=>{t.preventDefault(),En(e).catch(e=>{d.ui.error(`Failed to open path`,e)})};return V(`span`,{className:`file-path-link`,dir:`ltr`,onClick:t,title:`Open in file explorer: ${e}`,role:`button`,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t(e))},children:[P(yi,{size:12,className:`file-path-icon`}),e]})}function YC(e){return[...e.matchAll(new RegExp(WC.source,`gi`))].map(t=>{let n=t.index+t[0].length,r=`"“`.includes(e[t.index-1]??`
|
|
58
58
|
`)&&`"”`.includes(e[n]??`
|
|
59
59
|
`);return{start:t.index,path:r?t[0]:t[0].replace(GC,``)}})}function XC(e){let t=[],n=0;for(let{start:r,path:i}of YC(e))r>n&&t.push(e.slice(n,r)),t.push(P(JC,{path:i},r)),n=r+i.length;return t.length===0?e:(n<e.length&&t.push(e.slice(n)),P(D.Fragment,{children:t}))}var ZC=(0,J.createContext)(oC([]));function QC({doc:e,page:t,t:n}){return V(`a`,{className:`citation-link`,href:me(e.id,t),target:`_blank`,rel:`noopener noreferrer`,dir:`ltr`,title:t?n(`citation.openPage`,{page:t}):n(`citation.open`,{name:e.filename}),"data-doc-id":e.id,"data-page":t,children:[P(hi,{size:12,className:`citation-icon`,"aria-hidden":`true`}),e.filename]})}function $C({doc:e,page:t,label:n,t:r}){return P(`a`,{className:`citation-page`,href:me(e.id,t),target:`_blank`,rel:`noopener noreferrer`,title:r(`citation.openPage`,{page:t}),"data-doc-id":e.id,"data-page":t,children:n})}function ew(e,t){let n=cC(e,t)[0];return mC(n?t.slice(0,n.start):t)}function tw(e,t,n,r){let i=YC(e),a=cC(t,e).filter(e=>!i.some(t=>t.start<e.start&&e.start<t.start+t.path.length)),o=[],s=(t,r,i)=>{for(let a of r){let r=i+a.start,s=i+a.end;o.push({start:r,end:s,node:P($C,{doc:t,page:a.page,label:e.slice(r,s),t:n},`p${r}`)})}};if(r&&s(r,mC(e.slice(0,a[0]?.start??e.length)),0),a.forEach((t,r)=>{let i=mC(e.slice(t.end,a[r+1]?.start??e.length));o.push({start:t.start,end:t.end,node:P(QC,{doc:t.doc,page:i[0]?.page,t:n},`c${t.start}`)}),s(t.doc,i,t.end)}),o.length===0)return XC(e);o.sort((e,t)=>e.start-t.start);let c=[],l=0;for(let t of o)t.start>l&&c.push(P(J.Fragment,{children:XC(e.slice(l,t.start))},`t${l}`)),c.push(t.node),l=t.end;return l<e.length&&c.push(P(J.Fragment,{children:XC(e.slice(l))},`t${l}`)),P(D.Fragment,{children:c})}function nw(e,t){return typeof t==`string`?sC(e,t):null}function rw({children:e}){let t=(0,J.useContext)(ZC),n=T(),r=J.Children.toArray(e),i=null,a=r.map((e,a)=>{if(typeof e==`string`){let r=tw(e,t,n,i);return i=null,P(J.Fragment,{children:r},`s${a}`)}if(i=null,J.isValidElement(e)&&e.type===iw){let o=nw(t,e.props.children);if(o){let e=r[a+1],s=typeof e==`string`?ew(t,e):[];return i=o,P(QC,{doc:o,page:s[0]?.page,t:n},`k${a}`)}}return e});return P(D.Fragment,{children:a})}function iw({className:e,children:t,node:n,...r}){let i=(0,J.useContext)(ZC),a=T(),o=nw(i,t);if(o)return P(QC,{doc:o,t:a});let s=qC(t);return s?P(JC,{path:s}):P(`code`,{className:`inline-code`,dir:`ltr`,...r,children:t})}var aw={code:iw,pre({children:e}){let t=J.Children.toArray(e)[0];if(J.isValidElement(t)&&(t.type===`code`||t.props?.className!==void 0||typeof t.props?.children==`string`)){let e=t.props,n=e?.className||``,r=/language-([\w-]+)/.exec(n),i=String(e?.children||``).replace(/\n$/,``),a=r?.[1]||``;return P(UC,{lang:a,code:i})}return P(`pre`,{dir:`ltr`,children:e})},table({children:e}){return P(`div`,{className:`md-table-wrap`,children:P(`table`,{className:`md-table`,dir:`auto`,children:e})})},a({href:e,children:t}){return P(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`md-link`,children:t})},p({children:e}){return P(`p`,{className:`md-p`,dir:`auto`,children:P(rw,{children:e})})},h1({children:e}){return P(`h2`,{className:`md-h2`,dir:`auto`,children:P(rw,{children:e})})},h2({children:e}){return P(`h3`,{className:`md-h3`,dir:`auto`,children:P(rw,{children:e})})},h3({children:e}){return P(`h4`,{className:`md-h4`,dir:`auto`,children:P(rw,{children:e})})},h4({children:e}){return P(`h5`,{className:`md-h4`,dir:`auto`,children:P(rw,{children:e})})},ul({children:e}){return P(`ul`,{className:`md-ul`,dir:`auto`,children:e})},ol({children:e,start:t}){return P(`ol`,{className:`md-ol`,start:t,dir:`auto`,children:e})},li({children:e}){return P(`li`,{className:`md-li`,dir:`auto`,children:P(rw,{children:e})})},blockquote({children:e}){return P(`blockquote`,{className:`md-blockquote`,dir:`auto`,children:P(rw,{children:e})})},hr(){return P(`hr`,{className:`md-hr`})},td({children:e}){return P(`td`,{dir:`auto`,children:P(rw,{children:e})})},th({children:e}){return P(`th`,{dir:`auto`,children:P(rw,{children:e})})}};function ow({content:e,showCursor:t,isStreaming:n=!1}){let r=k(e=>e.documents),i=(0,J.useMemo)(()=>oC(r),[r]);return!e&&!t?null:!e&&t?P(`span`,{className:`cursor`}):P(HC.Provider,{value:n,children:P(ZC.Provider,{value:i,children:V(`div`,{className:`md-content`,children:[P(Vh,{remarkPlugins:[Jv,$v,ty],disallowedElements:[...Kh],urlTransform:Jh,components:aw,children:e}),t&&P(`span`,{className:`cursor`})]})})})}function sw(e){return e.type===`status`&&e.status===`working`&&!e.phase&&(e.message??``).startsWith(`Model is processing`)}function cw(e){return e.phase===`loading_tools`?I()(`chat.loadingTools`):(e.message||``).trim()}function lw(e,t){let n=++t.current,r=Date.now();switch(e.type){case`thinking`:return{id:n,type:`thinking`,label:`Thinking`,detail:e.content,active:!0,timestamp:r};case`commentary`:return{id:n,type:`commentary`,label:`Commentary`,detail:e.content,active:!1,timestamp:r};case`tool_start`:return{id:n,type:`tool`,label:`Using tool`,tool:e.tool,detail:e.detail,narration:e.narration,active:!0,timestamp:r,mcpServer:e.mcp_server,mcpServerLabel:e.mcp_server_label,mcpTool:e.mcp_tool};case`skill_use`:return{id:n,type:`tool`,label:`Using tool`,tool:`use_skill`,detail:e.skill,narration:`Using skill: ${e.skill}`,active:!1,success:!0,timestamp:r};case`plan`:return{id:n,type:`plan`,label:`Created plan`,planSteps:e.steps,planNarrations:e.step_narrations,currentStep:e.current_step,active:!1,success:!0,timestamp:r};case`step`:return{id:n,type:`status`,label:`Step ${e.step}${e.total?` of ${e.total}`:``}`,active:!0,timestamp:r};case`status`:return e.message?.startsWith(`Agent: `)?null:{id:n,type:`status`,label:e.message||e.status||`Working`,active:e.status===`working`,...e.status===`warning`?{success:!1}:{},timestamp:r};case`agent_error`:return{id:n,type:`error`,label:`Error`,detail:e.content,success:!1,active:!1,timestamp:r};case`policy_alert`:{let t=e.tool||`unknown tool`,i=e.reason||e.message||e.content||`Tool execution was blocked by governance policy.`;return{id:n,type:`policy_alert`,label:`Policy blocked ${t}`,detail:i,tool:t,decision:e.decision||`BLOCK`,reason:i,ruleIds:e.rule_ids??[],policyVersion:e.policy_version,receiptId:e.receipt_id,success:!1,active:!1,timestamp:r}}default:return null}}var uw=new Set([`tool`,`waiting`]);function dw(e){return e.livePhase&&!uw.has(e.livePhase)?e.liveStatus:null}function fw(e,t){let n=k.getState(),r=e.status,i=cw(e);if(e.phase===`recording_found`&&e.section!=null){n.addRecordingSection({section:e.section,sections:e.sections??e.section,start:e.start??``,end:e.end??``,summary:e.summary??``,items:e.items??[]});return}if(e.phase===`recording`&&e.stage!=null){n.setRecordingStage(e.stage,{state:e.state??0,percent:e.percent,etaSeconds:e.eta_seconds});return}if(e.phase&&i&&n.setLiveStatus(i,e.phase),e.phase===`waiting`||sw(e)||i.toLowerCase().startsWith(`executing `)||r!==`working`&&r!==`warning`&&r!==`info`)return;let a=n.agentSteps[n.agentSteps.length-1];if(a&&a.type===`status`&&a.active){n.updateLastAgentStep({label:i||`Working`,detail:i});return}if(a&&a.type===`thinking`&&a.active){n.updateLastAgentStep({label:i||`Thinking`});return}let o=lw({...e,message:i},t);o&&n.addAgentStep(o)}var pw=/\s*\{\s*"?(?:tool|thought|goal)"?\s*:\s*"[^"]*"[^}]*(?:"?tool_args"?\s*:\s*\{[^}]*\})?\s*\}/g;function mw(e){let t=e.trim();if(!t.startsWith(`{`)||!t.includes(`"thought"`)&&!t.includes(`"answer"`)&&!t.includes(`"goal"`))return e;try{let e=JSON.parse(t);if(e.answer!==void 0)return String(e.answer)}catch{}let n=t.indexOf(`"answer"`);if(n===-1)return``;let r=t.indexOf(`:`,n+8);if(r===-1)return``;let i=r+1;for(;i<t.length&&/\s/.test(t[i]);)i++;if(i>=t.length||t[i]!==`"`)return``;let a=t.slice(i+1);return a.endsWith(`"}`)?a=a.slice(0,-2):a.endsWith(`"`)&&(a=a.slice(0,-1)),a.replace(/\\"/g,`"`).replace(/\\n/g,`
|
|
60
|
-
`).replace(/\\\\/g,`\\`)}function hw(e,t){if(e.type!==`agent_error`||e.recoverable!==!0)return!1;let n=t[t.length-1];return!n||n.type!==`tool`?!1:n.success===!1||!!n.active&&n.success==null}function gw(e){let t=(e||[]).filter(e=>typeof e.render==`string`&&e.render.length>0).map(e=>({render:e.render,data:e.data}));return t.length>0?t:void 0}function _w(e){return(e||[]).map(e=>{let t=e.agentSteps||e.agent_steps||void 0;return{...e,agentSteps:t,cards:e.cards||gw(t),stats:e.stats||e.inference_stats||void 0,turnSummary:e.turnSummary||e.turn_summary||void 0,stopState:e.stopState??(e.stopped?`stopped`:void 0)}})}function vw(e,t,n){let r=e.find(e=>e.id===n.id&&e.role===`user`);if(r)return r;let i=t.findIndex(e=>e.id===n.id);if(i<0)throw Error(`Message ${n.id} is no longer in this chat.`);let a=new Set(e.map(e=>e.id)),o=i-1;for(;o>=0&&!a.has(t[o].id);)o--;let s=o<0?0:e.findIndex(e=>e.id===t[o].id)+1,c=e.slice(s).filter(e=>e.role===`user`),l=0;for(let e of t.slice(o+1,i))e.role===`user`&&c[l]?.content===e.content&&l++;return c[l]?.content===n.content?c[l]:null}function yw(e,t){return!!e&&e.role===`assistant`&&!!t.failureText&&e.content.trim()===t.failureText.trim()}function bw(e,t,n){let r=e.slice(e.findIndex(e=>e.id===t.id)+1);return r.length===0||r.length===1&&(r[0].id===n.id||yw(r[0],n))}function xw(e,t){let n=e[e.length-1],r=t[t.length-1];if(!n?.failed||!yw(r,n))return t;let i=e=>[...e].reverse().find(e=>e.role===`user`)?.content;return i(e)===i(t)?[...t.slice(0,-1),{...r,failed:!0,failureText:n.failureText}]:t}function Sw(e){return`policy-receipt-${encodeURIComponent(e)}`}function Cw(e){let t=e.content.trim();return!t||e.stopState||e.failed||e.failure||yC(t)?!1:!xC(e.agentSteps??[],t).echoed}function ww(){(0,J.useEffect)(()=>{let e=!0,t=async()=>{try{let t=await dS();e&&t&&wS.getState().setSettings(t)}catch(e){d.ui.error(`Could not load the read-aloud settings; replies will not be read automatically`,e)}};return t(),window.addEventListener(`focus`,t),()=>{e=!1,window.removeEventListener(`focus`,t)}},[])}var Tw=[`download`,`decode`,`transcribe`,`voices`,`prepare`,`analyze`],Ew=0,Dw=5;function Ow(e,t){return e==null?``:e<60?t(`recording.leftUnderMinute`):t(`recording.leftMinutes`,{minutes:Math.ceil(e/60)})}function kw(e){return Tw.map((e,t)=>t).filter(t=>t!==Ew&&t!==Dw||t in e)}function Aw({state:e}){return e===1?P(pr,{size:14,"aria-hidden":`true`}):e===2?P(ua,{size:14,"aria-hidden":`true`}):P(`span`,{className:`recording-progress-dot`,"aria-hidden":`true`})}function jw({index:e,stage:t}){let n=T(),r=n(`recording.stage.${Tw[e]}`),i=t?.state===0,a=t?.percent,o=i?Ow(t?.etaSeconds,n):``,s=t?.state===2?n(`recording.skipped`):o;return V(`li`,{className:`recording-progress-row${i?` is-running`:``}${t?``:` is-waiting`}${t?.state===1?` is-done`:``}`,children:[P(`span`,{className:`recording-progress-mark`,children:P(Aw,{state:t?.state})}),P(`span`,{className:`recording-progress-label`,children:r}),i&&a!=null&&V(`bdi`,{className:`recording-progress-percent`,dir:`ltr`,children:[a,`%`]}),s&&P(`span`,{className:`recording-progress-left`,children:s}),i&&P(`div`,{className:`recording-progress-track${a==null?` is-indeterminate`:``}`,role:`progressbar`,"aria-label":r,"aria-valuemin":a==null?void 0:0,"aria-valuemax":a==null?void 0:100,"aria-valuenow":a??void 0,children:P(`div`,{className:`recording-progress-fill`,style:a==null?void 0:{inlineSize:`${a}%`}})})]})}var Mw=120;function Nw(e){let t=[];return Object.values(e).sort((e,t)=>e.section-t.section).map(e=>{let n=e.items.filter(e=>{let n=e.title.trim().toLowerCase(),r=t.some(t=>t.title===n&&Math.abs(t.seconds-e.seconds)<Mw);return r||t.push({title:n,seconds:e.seconds}),!r});return{...e,items:n}})}function Pw({sections:e}){let t=T(),n=Nw(e),r=n[0]?.sections??0;return V(`section`,{className:`recording-found`,"aria-label":t(`recording.found.title`),children:[V(`h4`,{className:`recording-found-title`,children:[t(`recording.found.title`),P(`span`,{className:`recording-found-count`,children:t(`recording.found.count`,{done:n.length,total:r})})]}),n.map(e=>V(`div`,{className:`recording-found-section`,children:[V(`p`,{className:`recording-found-span`,children:[V(`bdi`,{dir:`ltr`,className:`recording-found-time`,children:[e.start,`–`,e.end]}),e.summary&&P(`span`,{dir:`auto`,children:e.summary})]}),e.items.length>0&&P(`ul`,{className:`recording-found-items`,children:e.items.map(e=>V(`li`,{children:[P(`bdi`,{dir:`ltr`,className:`recording-found-time`,children:e.start}),P(`span`,{dir:`auto`,children:e.title})]},`${e.seconds}-${e.title}`))})]},e.section))]})}function Fw(){let e=T(),t=k(e=>e.recordingStages),n=k(e=>e.recordingSections);return t?V(`section`,{className:`recording-progress`,"aria-label":e(`recording.title`),children:[P(`ol`,{className:`recording-progress-list`,children:kw(t).map(e=>P(jw,{index:e,stage:t[e]},e))}),n&&P(Pw,{sections:n})]}):null}var Iw=5e3,Lw=2e3,Rw=3e4,zw=6e4;function Bw(e){return e?.init_state===`initializing`?!e.init_tasks||e.init_tasks.some(e=>e.status===`pending`||e.status===`running`):!1}function Vw(e){return e.lemonade_running?`up`:e.lemonade_error?`unresponsive`:`down`}function Hw(e){return e.kind===`slow`||e.kind===`error`||e.kind===`ok`&&Vw(e.status)===`unresponsive`}function Uw(e){let t=e.kind===`ok`?e.status.download_progress?.state:void 0;return t===`downloading`||t===`starting`}function Ww(e){let t=null,n=0,r=!1,i=null,a=0,o=null,s=async()=>{let e={controller:new AbortController,cancelled:!1};o=e;let{controller:t}=e,n=setTimeout(()=>t.abort(),zw);try{return{kind:`ok`,status:await Nt(t.signal)}}catch(n){if(e.cancelled)return null;if(t.signal.aborted)return{kind:`slow`};let r=n?.httpStatus;return r===504?{kind:`slow`}:n?.name===`ApiError`&&typeof r==`number`&&r!==502?{kind:`error`,httpStatus:r,message:n.message}:{kind:`unreachable`,error:n}}finally{clearTimeout(n),o===e&&(o=null)}},c=()=>{if(t)return t;let i=s().then(t=>{if(t!==null){n=Hw(t)?n+1:0,r=Uw(t);try{e(t)}catch(e){d.system.error(`Could not apply the system status; the next poll will try again`,e)}}}).finally(()=>{t===i&&(t=null)});return t=i,i},l=()=>Math.min((r?Lw:Iw)*2**n,Rw),u=e=>{c().finally(()=>{e===a&&(i=setTimeout(()=>u(e),l()))})};return{check:c,start:()=>{let e=++a;return u(e),()=>{e===a&&(a++,i&&clearTimeout(i),i=null,o&&(o.cancelled=!0,o.controller.abort(),o=null,t=null))}}}}var Gw=1e3,Kw=15e3,qw=null,Jw=null,Yw=Gw,Xw=0,Zw=null;function Qw(){if(qw)return qw;let e=Date.now();return qw=yn().then(t=>k.getState().setActiveRuns(t,e)).catch(e=>{d.api.warn(`Could not read which chats are running`,e),Mx(e)&&k.getState().loseActiveRuns()}).finally(()=>{qw=null}),qw}function $w(){let e=k.getState();return e.isStreaming||e.runningSessionIds.length>0}function eT(){return $w()?(Yw=Gw,Gw):(Yw=Math.min(Yw*2,Kw),Yw)}function tT(e){Qw().then(()=>{e===Xw&&(Jw=setTimeout(()=>tT(e),eT()))})}function nT(){Zw&&(Jw&&clearTimeout(Jw),Jw=null,Yw=Gw,tT(++Xw))}function rT(){Zw?.();let e=k.subscribe((e,t)=>{e.isStreaming&&!t.isStreaming&&nT()}),t=()=>nT();window.addEventListener(`focus`,t);let n=()=>{Xw++,Jw&&clearTimeout(Jw),Jw=null,e(),window.removeEventListener(`focus`,t),Zw===n&&(Zw=null)};return Zw=n,Yw=Gw,tT(++Xw),n}var iT=3e3,aT=new Set,oT=new Map,sT=new Set,cT=null;function lT(e,t=Date.now()){oT.set(e,t)}function uT(e){let t=k.getState();return t.activeRunsAt>0&&t.activeRunsAt>=(oT.get(e)??0)&&!t.runningSessionIds.includes(e)&&!t.queuedSessionIds.includes(e)}function dT(e){return sT.add(e),()=>{sT.delete(e),cT?.()}}function fT(e){return e instanceof Error?WS(e)??(e.message||`Unknown error`):String(e)}function pT(e){let t=e?.httpStatus;return typeof t==`number`?t:void 0}function mT(e){let t=pT(e);return t===409||t===429}function hT(e){d.chat.warn(`Chat ${e} no longer exists; dropping its queued messages`),k.getState().updateQueue(e,()=>[])}function gT(e){k.getState().setQueueHold(e,!0),setTimeout(()=>k.getState().setQueueHold(e,!1),iT)}function _T(e,t,n){return pT(n)===409&&(d.chat.info(`Chat ${e} was busy; queueing the message to try again`),k.getState().updateQueue(e,e=>ee(e,t,`queued`)),gT(e),!0)}async function vT(e,t,n){let r=k.getState;if(aT.has(e)||r().queueHolds[e])return;let i=r().messageQueues[e]??[];if(i.some(e=>e.state===`sending`))return;let a=A(i);if(a||w(i)){aT.add(e);try{if(a){let t;try{t=await Vt(e)}catch(t){if(pT(t)===409){d.chat.info(`Chat ${e} is answering again; its queue waits for that turn to end`);return}if(pT(t)===404){hT(e);return}d.chat.error(`Could not learn what chat ${e}'s last reply did with the messages added to it`,t),r().updateQueue(e,e=>F(e,`GAIA could not say whether it read this message: ${fT(t)}`));return}r().updateQueue(e,e=>E(e,t))}let i=w(r().messageQueues[e]??[]);if(!i||!n())return;r().updateQueue(e,e=>ae(e,i.id,`queued`,`starting`));let o;try{o=await t(e,i.text)}catch(e){o={kind:`failed`,error:fT(e)}}if(o.kind===`accepted`){lT(e),r().updateQueue(e,e=>ie(e,i.id)),nT();return}if(o.kind===`busy`){d.chat.info(`Queued message found chat ${e} busy; holding it`),r().updateQueue(e,e=>ne(e,i.id)),gT(e);return}if(o.kind===`gone`){hT(e);return}d.chat.error(`Queued message for chat ${e} was not sent: ${o.error}`),r().updateQueue(e,e=>ne(e,i.id,o.error))}finally{aT.delete(e)}}}function yT(e){return e.type!==`status`||e.phase!==`waiting`}var bT=(e,t)=>new Promise(n=>{let r=!1,i=null,a=!1,o=e=>{r||(r=!0,e.kind===`accepted`&&(i?i.abort():a=!0),n(e))},s=()=>o({kind:`accepted`});d.chat.info(`Sending queued message for chat ${e} in the background`),i=Be(e,t,{onChunk:s,onAgentEvent:e=>{yT(e)&&s()},onDone:s,onError:e=>{VS(e)?s():mT(e)?o({kind:`busy`}):pT(e)===404?o({kind:`gone`}):o({kind:`failed`,error:fT(e)})}}),a&&i.abort()});function xT(e=bT){let t=()=>{let t=k.getState();if(!Bw(t.systemStatus))for(let n of Object.keys(t.messageQueues))!sT.has(n)&&uT(n)&&vT(n,e,()=>!sT.has(n))},n=k.subscribe((e,n)=>{(e.messageQueues!==n.messageQueues||e.queueHolds!==n.queueHolds||e.activeRunsAt!==n.activeRunsAt||e.runningSessionIds!==n.runningSessionIds||e.systemStatus!==n.systemStatus)&&t()});return cT=t,t(),()=>{n(),cT===t&&(cT=null)}}var ST=new Set([`.3g2`,`.3gp`,`.asf`,`.avi`,`.divx`,`.f4v`,`.flv`,`.m2ts`,`.m2v`,`.m4v`,`.mkv`,`.mov`,`.mp4`,`.mpeg`,`.mpg`,`.mts`,`.mxf`,`.ogv`,`.rm`,`.rmvb`,`.vob`,`.webm`,`.wmv`]),CT=new Set([`.aac`,`.ac3`,`.aif`,`.aiff`,`.amr`,`.ape`,`.au`,`.caf`,`.dts`,`.eac3`,`.flac`,`.m4a`,`.m4b`,`.mka`,`.mp2`,`.mp3`,`.oga`,`.ogg`,`.opus`,`.spx`,`.wav`,`.wma`,`.wv`]);function wT(e){let t=e.lastIndexOf(`.`);return t<0?``:e.slice(t).toLowerCase()}function TT(e){return ST.has(wT(e))}function ET(e){let t=wT(e);return ST.has(t)||CT.has(t)}var DT=`https://github.com/amd/gaia/issues/new`,OT=[{label:`Image`,extensions:new Set([`.ico`,`.heic`,`.heif`]),message:`This image format cannot be indexed.`,alternatives:[`Convert it to PNG or JPEG — GAIA reads the text in those images`],featureTitle:`Support HEIC and ICO image indexing`},{label:`Video`,extensions:ST,message:`Video files can't go in the document library.`,alternatives:[`Attach the video to a chat, and GAIA will transcribe it`],featureTitle:`Support video files in the document library`},{label:`Audio`,extensions:CT,message:`Audio files can't go in the document library.`,alternatives:[`Attach the recording to a chat, and GAIA will transcribe it`],featureTitle:`Support audio files in the document library`},{label:`Archive`,extensions:new Set([`.zip`,`.rar`,`.7z`,`.tar`,`.gz`,`.bz2`,`.xz`,`.tgz`]),message:`Archive files must be extracted before indexing.`,alternatives:[`Extract the archive contents to a folder`,`Then index the folder or individual files from the Document Library`],featureTitle:`Support automatic archive extraction for indexing`},{label:`Executable`,extensions:new Set([`.exe`,`.msi`,`.dll`,`.so`,`.app`,`.dmg`,`.bin`,`.com`]),message:`Executable and binary files cannot be indexed.`,alternatives:[`Index source code files (.py, .js, .ts, .java, etc.) instead`,`Index documentation or README files from the project`],featureTitle:`Support binary file analysis`},{label:`Database`,extensions:new Set([`.sqlite`,`.db`,`.mdb`,`.accdb`,`.dbf`]),message:`Database files are not supported for direct indexing.`,alternatives:[`Export data to CSV or JSON format, then index those files`,`Use SQL queries to extract relevant data to a text file`],featureTitle:`Support database file indexing`},{label:`Microsoft Office`,extensions:new Set([`.doc`,`.ppt`,`.xls`]),message:`Legacy Office formats (.doc, legacy PowerPoint .ppt, legacy Excel .xls) are not supported — GAIA reads only the modern XML-based formats. Modern Word (.docx), PowerPoint (.pptx), and Excel (.xlsx) are supported.`,alternatives:[`Re-save as .docx — GAIA indexes modern Word documents directly`,`Save modern PowerPoint as .pptx — GAIA indexes .pptx directly`,`Re-save legacy .xls workbooks as .xlsx — GAIA supports modern Excel files`],featureTitle:`Support legacy Microsoft Office (doc, ppt, xls) indexing`}];function kT(e){let t=e.toLowerCase().startsWith(`.`)?e.toLowerCase():`.${e.toLowerCase()}`;for(let e of OT)if(e.extensions.has(t))return e;return null}var AT=new Set(`.pdf,.pptx,.docx,.epub,.png,.jpg,.jpeg,.webp,.bmp,.gif,.tif,.tiff,.txt,.md,.mdx,.markdown,.rst,.csv,.json,.xlsx,.html,.htm,.xml,.svg,.yaml,.yml,.py,.js,.ts,.java,.c,.cpp,.h,.rs,.go,.rb,.sh,.bat,.ps1,.log,.cfg,.ini,.toml`.split(`,`));function jT(e){let t=e.toLowerCase().startsWith(`.`)?e.toLowerCase():`.${e.toLowerCase()}`;return AT.has(t)}function MT(){let e=navigator.userAgent;return`**Environment:**\n- GAIA Version: 0.26.0rc1\n- Platform: ${navigator.platform||`unknown`}\n- User Agent: ${e}\n- Interface: Agent UI (Web)`}function NT(e,t){let n=[`## Feature Description`,``,t||`I would like GAIA to support: **${e}**`,``,`## Use Case`,``,`_Describe how you would use this feature:_`,``,`## Current Workaround`,``,`_Is there a workaround you are currently using?_`,``,`---`,MT(),``,`_Submitted from GAIA Agent UI_`].join(`
|
|
60
|
+
`).replace(/\\\\/g,`\\`)}function hw(e,t){if(e.type!==`agent_error`||e.recoverable!==!0)return!1;let n=t[t.length-1];return!n||n.type!==`tool`?!1:n.success===!1||!!n.active&&n.success==null}function gw(e){let t=(e||[]).filter(e=>typeof e.render==`string`&&e.render.length>0).map(e=>({render:e.render,data:e.data}));return t.length>0?t:void 0}function _w(e){return(e||[]).map(e=>{let t=e.agentSteps||e.agent_steps||void 0;return{...e,agentSteps:t,cards:e.cards||gw(t),stats:e.stats||e.inference_stats||void 0,turnSummary:e.turnSummary||e.turn_summary||void 0,stopState:e.stopState??(e.stopped?`stopped`:void 0)}})}function vw(e,t,n){let r=e.find(e=>e.id===n.id&&e.role===`user`);if(r)return r;let i=t.findIndex(e=>e.id===n.id);if(i<0)throw Error(`Message ${n.id} is no longer in this chat.`);let a=new Set(e.map(e=>e.id)),o=i-1;for(;o>=0&&!a.has(t[o].id);)o--;let s=o<0?0:e.findIndex(e=>e.id===t[o].id)+1,c=e.slice(s).filter(e=>e.role===`user`),l=0;for(let e of t.slice(o+1,i))e.role===`user`&&c[l]?.content===e.content&&l++;return c[l]?.content===n.content?c[l]:null}function yw(e,t){return!!e&&e.role===`assistant`&&!!t.failureText&&e.content.trim()===t.failureText.trim()}function bw(e,t,n){let r=e.slice(e.findIndex(e=>e.id===t.id)+1);return r.length===0||r.length===1&&(r[0].id===n.id||yw(r[0],n))}function xw(e,t){let n=e[e.length-1],r=t[t.length-1];if(!n?.failed||!yw(r,n))return t;let i=e=>[...e].reverse().find(e=>e.role===`user`)?.content;return i(e)===i(t)?[...t.slice(0,-1),{...r,failed:!0,failureText:n.failureText}]:t}function Sw(e){return`policy-receipt-${encodeURIComponent(e)}`}function Cw(e){let t=e.content.trim();return!t||e.stopState||e.failed||e.failure||yC(t)?!1:!xC(e.agentSteps??[],t).echoed}function ww(){(0,J.useEffect)(()=>{let e=!0,t=async()=>{try{let t=await dS();e&&t&&wS.getState().setSettings(t)}catch(e){d.ui.error(`Could not load the read-aloud settings; replies will not be read automatically`,e)}};return t(),window.addEventListener(`focus`,t),()=>{e=!1,window.removeEventListener(`focus`,t)}},[])}var Tw=[`download`,`decode`,`transcribe`,`voices`,`prepare`,`analyze`],Ew=0,Dw=5;function Ow(e,t){return e==null?``:e<60?t(`recording.leftUnderMinute`):t(`recording.leftMinutes`,{minutes:Math.ceil(e/60)})}function kw(e){return Tw.map((e,t)=>t).filter(t=>t!==Ew&&t!==Dw||t in e)}function Aw({state:e}){return e===1?P(pr,{size:14,"aria-hidden":`true`}):e===2?P(ua,{size:14,"aria-hidden":`true`}):P(`span`,{className:`recording-progress-dot`,"aria-hidden":`true`})}function jw({index:e,stage:t}){let n=T(),r=n(`recording.stage.${Tw[e]}`),i=t?.state===0,a=t?.percent,o=i?Ow(t?.etaSeconds,n):``,s=t?.state===2?n(`recording.skipped`):o;return V(`li`,{className:`recording-progress-row${i?` is-running`:``}${t?``:` is-waiting`}${t?.state===1?` is-done`:``}`,children:[P(`span`,{className:`recording-progress-mark`,children:P(Aw,{state:t?.state})}),P(`span`,{className:`recording-progress-label`,children:r}),i&&a!=null&&V(`bdi`,{className:`recording-progress-percent`,dir:`ltr`,children:[a,`%`]}),s&&P(`span`,{className:`recording-progress-left`,children:s}),i&&P(`div`,{className:`recording-progress-track${a==null?` is-indeterminate`:``}`,role:`progressbar`,"aria-label":r,"aria-valuemin":a==null?void 0:0,"aria-valuemax":a==null?void 0:100,"aria-valuenow":a??void 0,children:P(`div`,{className:`recording-progress-fill`,style:a==null?void 0:{inlineSize:`${a}%`}})})]})}var Mw=120;function Nw(e){let t=[];return Object.values(e).sort((e,t)=>e.section-t.section).map(e=>{let n=e.items.filter(e=>{let n=e.title.trim().toLowerCase(),r=t.some(t=>t.title===n&&Math.abs(t.seconds-e.seconds)<Mw);return r||t.push({title:n,seconds:e.seconds}),!r});return{...e,items:n}})}function Pw({sections:e}){let t=T(),n=Nw(e),r=n[0]?.sections??0;return V(`section`,{className:`recording-found`,"aria-label":t(`recording.found.title`),children:[V(`h4`,{className:`recording-found-title`,children:[t(`recording.found.title`),P(`span`,{className:`recording-found-count`,children:t(`recording.found.count`,{done:n.length,total:r})})]}),n.map(e=>V(`div`,{className:`recording-found-section`,children:[V(`p`,{className:`recording-found-span`,children:[V(`bdi`,{dir:`ltr`,className:`recording-found-time`,children:[e.start,`–`,e.end]}),e.summary&&P(`span`,{dir:`auto`,children:e.summary})]}),e.items.length>0&&P(`ul`,{className:`recording-found-items`,children:e.items.map(e=>V(`li`,{children:[P(`bdi`,{dir:`ltr`,className:`recording-found-time`,children:e.start}),P(`span`,{dir:`auto`,children:e.title})]},`${e.seconds}-${e.title}`))})]},e.section))]})}function Fw(){let e=T(),t=k(e=>e.recordingStages),n=k(e=>e.recordingSections);return t?V(`section`,{className:`recording-progress`,"aria-label":e(`recording.title`),children:[P(`ol`,{className:`recording-progress-list`,children:kw(t).map(e=>P(jw,{index:e,stage:t[e]},e))}),n&&P(Pw,{sections:n})]}):null}var Iw=5e3,Lw=2e3,Rw=3e4,zw=6e4;function Bw(e){return e?.init_state===`initializing`?!e.init_tasks||e.init_tasks.some(e=>e.status===`pending`||e.status===`running`):!1}function Vw(e){return e.lemonade_running?`up`:e.lemonade_error?`unresponsive`:`down`}function Hw(e){return e.kind===`slow`||e.kind===`error`||e.kind===`ok`&&Vw(e.status)===`unresponsive`}function Uw(e){let t=e.kind===`ok`?e.status.download_progress?.state:void 0;return t===`downloading`||t===`starting`}function Ww(e){let t=null,n=0,r=!1,i=null,a=0,o=null,s=async()=>{let e={controller:new AbortController,cancelled:!1};o=e;let{controller:t}=e,n=setTimeout(()=>t.abort(),zw);try{return{kind:`ok`,status:await Nt(t.signal)}}catch(n){if(e.cancelled)return null;if(t.signal.aborted)return{kind:`slow`};let r=n?.httpStatus;return r===504?{kind:`slow`}:n?.name===`ApiError`&&typeof r==`number`&&r!==502?{kind:`error`,httpStatus:r,message:n.message}:{kind:`unreachable`,error:n}}finally{clearTimeout(n),o===e&&(o=null)}},c=()=>{if(t)return t;let i=s().then(t=>{if(t!==null){n=Hw(t)?n+1:0,r=Uw(t);try{e(t)}catch(e){d.system.error(`Could not apply the system status; the next poll will try again`,e)}}}).finally(()=>{t===i&&(t=null)});return t=i,i},l=()=>Math.min((r?Lw:Iw)*2**n,Rw),u=e=>{c().finally(()=>{e===a&&(i=setTimeout(()=>u(e),l()))})};return{check:c,start:()=>{let e=++a;return u(e),()=>{e===a&&(a++,i&&clearTimeout(i),i=null,o&&(o.cancelled=!0,o.controller.abort(),o=null,t=null))}}}}var Gw=1e3,Kw=15e3,qw=null,Jw=null,Yw=Gw,Xw=0,Zw=null;function Qw(){if(qw)return qw;let e=Date.now();return qw=yn().then(t=>k.getState().setActiveRuns(t,e)).catch(e=>{d.api.warn(`Could not read which chats are running`,e),Mx(e)&&k.getState().loseActiveRuns()}).finally(()=>{qw=null}),qw}function $w(){let e=k.getState();return e.isStreaming||e.runningSessionIds.length>0}function eT(){return $w()?(Yw=Gw,Gw):(Yw=Math.min(Yw*2,Kw),Yw)}function tT(e){Qw().then(()=>{e===Xw&&(Jw=setTimeout(()=>tT(e),eT()))})}function nT(){Zw&&(Jw&&clearTimeout(Jw),Jw=null,Yw=Gw,tT(++Xw))}function rT(){Zw?.();let e=k.subscribe((e,t)=>{e.isStreaming&&!t.isStreaming&&nT()}),t=()=>nT();window.addEventListener(`focus`,t);let n=()=>{Xw++,Jw&&clearTimeout(Jw),Jw=null,e(),window.removeEventListener(`focus`,t),Zw===n&&(Zw=null)};return Zw=n,Yw=Gw,tT(++Xw),n}var iT=3e3,aT=new Set,oT=new Map,sT=new Set,cT=null;function lT(e,t=Date.now()){oT.set(e,t)}function uT(e){let t=k.getState();return t.activeRunsAt>0&&t.activeRunsAt>=(oT.get(e)??0)&&!t.runningSessionIds.includes(e)&&!t.queuedSessionIds.includes(e)}function dT(e){return sT.add(e),()=>{sT.delete(e),cT?.()}}function fT(e){return e instanceof Error?WS(e)??(e.message||`Unknown error`):String(e)}function pT(e){let t=e?.httpStatus;return typeof t==`number`?t:void 0}function mT(e){let t=pT(e);return t===409||t===429}function hT(e){d.chat.warn(`Chat ${e} no longer exists; dropping its queued messages`),k.getState().updateQueue(e,()=>[])}function gT(e){k.getState().setQueueHold(e,!0),setTimeout(()=>k.getState().setQueueHold(e,!1),iT)}function _T(e,t,n){return pT(n)===409&&(d.chat.info(`Chat ${e} was busy; queueing the message to try again`),k.getState().updateQueue(e,e=>ee(e,t,`queued`)),gT(e),!0)}async function vT(e,t,n){let r=k.getState;if(aT.has(e)||r().queueHolds[e])return;let i=r().messageQueues[e]??[];if(i.some(e=>e.state===`sending`))return;let a=A(i);if(a||w(i)){aT.add(e);try{if(a){let t;try{t=await Vt(e)}catch(t){if(pT(t)===409){d.chat.info(`Chat ${e} is answering again; its queue waits for that turn to end`);return}if(pT(t)===404){hT(e);return}d.chat.error(`Could not learn what chat ${e}'s last reply did with the messages added to it`,t),r().updateQueue(e,e=>F(e,`GAIA could not say whether it read this message: ${fT(t)}`));return}r().updateQueue(e,e=>E(e,t))}let i=w(r().messageQueues[e]??[]);if(!i||!n())return;r().updateQueue(e,e=>ae(e,i.id,`queued`,`starting`));let o;try{o=await t(e,i.text)}catch(e){o={kind:`failed`,error:fT(e)}}if(o.kind===`accepted`){lT(e),r().updateQueue(e,e=>ie(e,i.id)),nT();return}if(o.kind===`busy`){d.chat.info(`Queued message found chat ${e} busy; holding it`),r().updateQueue(e,e=>ne(e,i.id)),gT(e);return}if(o.kind===`gone`){hT(e);return}d.chat.error(`Queued message for chat ${e} was not sent: ${o.error}`),r().updateQueue(e,e=>ne(e,i.id,o.error))}finally{aT.delete(e)}}}function yT(e){return e.type!==`status`||e.phase!==`waiting`}var bT=(e,t)=>new Promise(n=>{let r=!1,i=null,a=!1,o=e=>{r||(r=!0,e.kind===`accepted`&&(i?i.abort():a=!0),n(e))},s=()=>o({kind:`accepted`});d.chat.info(`Sending queued message for chat ${e} in the background`),i=Be(e,t,{onChunk:s,onAgentEvent:e=>{yT(e)&&s()},onDone:s,onError:e=>{VS(e)?s():mT(e)?o({kind:`busy`}):pT(e)===404?o({kind:`gone`}):o({kind:`failed`,error:fT(e)})}}),a&&i.abort()});function xT(e=bT){let t=()=>{let t=k.getState();if(!Bw(t.systemStatus))for(let n of Object.keys(t.messageQueues))!sT.has(n)&&uT(n)&&vT(n,e,()=>!sT.has(n))},n=k.subscribe((e,n)=>{(e.messageQueues!==n.messageQueues||e.queueHolds!==n.queueHolds||e.activeRunsAt!==n.activeRunsAt||e.runningSessionIds!==n.runningSessionIds||e.systemStatus!==n.systemStatus)&&t()});return cT=t,t(),()=>{n(),cT===t&&(cT=null)}}var ST=new Set([`.3g2`,`.3gp`,`.asf`,`.avi`,`.divx`,`.f4v`,`.flv`,`.m2ts`,`.m2v`,`.m4v`,`.mkv`,`.mov`,`.mp4`,`.mpeg`,`.mpg`,`.mts`,`.mxf`,`.ogv`,`.rm`,`.rmvb`,`.vob`,`.webm`,`.wmv`]),CT=new Set([`.aac`,`.ac3`,`.aif`,`.aiff`,`.amr`,`.ape`,`.au`,`.caf`,`.dts`,`.eac3`,`.flac`,`.m4a`,`.m4b`,`.mka`,`.mp2`,`.mp3`,`.oga`,`.ogg`,`.opus`,`.spx`,`.wav`,`.wma`,`.wv`]);function wT(e){let t=e.lastIndexOf(`.`);return t<0?``:e.slice(t).toLowerCase()}function TT(e){return ST.has(wT(e))}function ET(e){let t=wT(e);return ST.has(t)||CT.has(t)}var DT=`https://github.com/amd/gaia/issues/new`,OT=[{label:`Image`,extensions:new Set([`.ico`,`.heic`,`.heif`]),message:`This image format cannot be indexed.`,alternatives:[`Convert it to PNG or JPEG — GAIA reads the text in those images`],featureTitle:`Support HEIC and ICO image indexing`},{label:`Video`,extensions:ST,message:`Video files can't go in the document library.`,alternatives:[`Attach the video to a chat, and GAIA will transcribe it`],featureTitle:`Support video files in the document library`},{label:`Audio`,extensions:CT,message:`Audio files can't go in the document library.`,alternatives:[`Attach the recording to a chat, and GAIA will transcribe it`],featureTitle:`Support audio files in the document library`},{label:`Archive`,extensions:new Set([`.zip`,`.rar`,`.7z`,`.tar`,`.gz`,`.bz2`,`.xz`,`.tgz`]),message:`Archive files must be extracted before indexing.`,alternatives:[`Extract the archive contents to a folder`,`Then index the folder or individual files from the Document Library`],featureTitle:`Support automatic archive extraction for indexing`},{label:`Executable`,extensions:new Set([`.exe`,`.msi`,`.dll`,`.so`,`.app`,`.dmg`,`.bin`,`.com`]),message:`Executable and binary files cannot be indexed.`,alternatives:[`Index source code files (.py, .js, .ts, .java, etc.) instead`,`Index documentation or README files from the project`],featureTitle:`Support binary file analysis`},{label:`Database`,extensions:new Set([`.sqlite`,`.db`,`.mdb`,`.accdb`,`.dbf`]),message:`Database files are not supported for direct indexing.`,alternatives:[`Export data to CSV or JSON format, then index those files`,`Use SQL queries to extract relevant data to a text file`],featureTitle:`Support database file indexing`},{label:`Microsoft Office`,extensions:new Set([`.doc`,`.ppt`,`.xls`]),message:`Legacy Office formats (.doc, legacy PowerPoint .ppt, legacy Excel .xls) are not supported — GAIA reads only the modern XML-based formats. Modern Word (.docx), PowerPoint (.pptx), and Excel (.xlsx) are supported.`,alternatives:[`Re-save as .docx — GAIA indexes modern Word documents directly`,`Save modern PowerPoint as .pptx — GAIA indexes .pptx directly`,`Re-save legacy .xls workbooks as .xlsx — GAIA supports modern Excel files`],featureTitle:`Support legacy Microsoft Office (doc, ppt, xls) indexing`}];function kT(e){let t=e.toLowerCase().startsWith(`.`)?e.toLowerCase():`.${e.toLowerCase()}`;for(let e of OT)if(e.extensions.has(t))return e;return null}var AT=new Set(`.pdf,.pptx,.docx,.epub,.png,.jpg,.jpeg,.webp,.bmp,.gif,.tif,.tiff,.txt,.md,.mdx,.markdown,.rst,.csv,.json,.xlsx,.html,.htm,.xml,.svg,.yaml,.yml,.py,.js,.ts,.java,.c,.cpp,.h,.rs,.go,.rb,.sh,.bat,.ps1,.log,.cfg,.ini,.toml`.split(`,`));function jT(e){let t=e.toLowerCase().startsWith(`.`)?e.toLowerCase():`.${e.toLowerCase()}`;return AT.has(t)}function MT(){let e=navigator.userAgent;return`**Environment:**\n- GAIA Version: 0.26.0rc2\n- Platform: ${navigator.platform||`unknown`}\n- User Agent: ${e}\n- Interface: Agent UI (Web)`}function NT(e,t){let n=[`## Feature Description`,``,t||`I would like GAIA to support: **${e}**`,``,`## Use Case`,``,`_Describe how you would use this feature:_`,``,`## Current Workaround`,``,`_Is there a workaround you are currently using?_`,``,`---`,MT(),``,`_Submitted from GAIA Agent UI_`].join(`
|
|
61
61
|
`);return`${DT}?${new URLSearchParams({title:`[Feature] ${e}`,body:n,labels:`enhancement,agent-ui`}).toString()}`}function PT(e,t){let n=[`## Bug Description`,``,t||e,``,`## Steps to Reproduce`,``,`1. Open GAIA Agent UI`,`2. _Describe what you did:_`,`3. `,``,`## Expected Behavior`,``,`_What did you expect to happen?_`,``,`## Actual Behavior`,``,`_What happened instead?_`,``,`---`,MT(),``,`_Submitted from GAIA Agent UI_`].join(`
|
|
62
62
|
`);return`${DT}?${new URLSearchParams({title:`[Bug] ${e}`,body:n,labels:`bug,agent-ui`}).toString()}`}var FT={corrupted:`The file looks damaged. Re-download or re-export it, then index the new copy.`,encrypted:`The PDF needs a password to open. Save a copy without the password, then index that.`,empty:`The PDF has no readable text, which usually means it is a scan. Run OCR on it, then index it again.`,empty_file:`This file is empty. Add content to it, then index it again.`,unsupported_workbook:`This is an old .xls workbook or has a password. Open it in Excel, save a copy as .xlsx without a password, then index that.`};function IT(e,t){return e.startsWith(t)?e.slice(t.length).trim():e}function LT({filename:e,error:t,status:n,kind:r,onDismiss:i,timeout:a=15e3}){let o=(0,J.useRef)(null);(0,J.useEffect)(()=>(a>0&&(o.current=setTimeout(i,a)),()=>{o.current&&clearTimeout(o.current)}),[i,a]);let s=e.includes(`.`)?`.`+e.split(`.`).pop()?.toLowerCase():``,c=s?kT(s):null,l=t.toLowerCase().includes(`unsupported file type`)||t.toLowerCase().includes(`not supported for indexing`)||t.toLowerCase().includes(`file type not allowed`)||c!==null,u=t.toLowerCase().includes(`fetch`)||t.toLowerCase().includes(`network`)||t.toLowerCase().includes(`connect`),d,f,p,m=Cr,h=r?FT[r]:void 0;return h?(d=`"${e}" can't be read`,f=h,p=null,m=q):n===404?(d=`"${e}" doesn't exist`,f=IT(t,`File not found:`),p=null,m=q):n===403?(d=`GAIA can't read files in that location`,f=`${t} Or drop the file here instead (up to 20 MB) and GAIA keeps its own copy.`,p=null,m=q):l&&c?(d=`${c.label} files not supported`,f=c.message,p=NT(c.featureTitle),m=q):l&&!s?(d=`"${e}" has no file extension`,f=IT(t,`File type not allowed:`),p=null,m=q):l?(d=`File type not supported: ${s}`,f=`This file format cannot be indexed. Supported: PDF, DOCX, PPTX, XLSX, EPUB, images (PNG, JPG, WEBP, ...), TXT, MD, CSV, JSON, HTML, XML, YAML, and 30+ code file formats.`,p=NT(`Support ${s} file indexing`),m=q):u?(d=`Connection error`,f=`Could not reach the GAIA server. Make sure the backend is running.`,p=PT(`Upload connection error for ${e}`),m=Cr):(d=`Failed to index "${e}"`,f=t||`An unexpected error occurred during indexing.`,p=PT(`Indexing error: ${t.slice(0,80)}`),m=ar),V(`div`,{className:`upload-error-toast`,role:`alert`,children:[P(m,{size:16}),V(`div`,{className:`upload-error-content`,children:[P(`div`,{className:`upload-error-title`,children:d}),V(`div`,{className:`upload-error-detail`,children:[f,p&&` `,p===null?null:l?P(`a`,{href:p,target:`_blank`,rel:`noopener noreferrer`,children:`Request this feature →`}):P(`a`,{href:p,target:`_blank`,rel:`noopener noreferrer`,children:`Report this issue →`})]})]}),P(`button`,{className:`upload-error-dismiss`,onClick:i,"aria-label":`Dismiss`,children:P(So,{size:14})})]})}function RT(e,t){let n=e=>t.some(t=>t.id===e&&t.configured),r=Cb(e);return r===`google`?n(`google`):r===`microsoft`?n(`microsoft`):r===`microsoft_work`?n(`microsoft_work`):n(`google`)||n(`microsoft`)||n(`microsoft_work`)}function zT(e,t){let n=e=>t.some(t=>t.id===e&&t.configured),r=Cb(e);return r===`google`?`Google`:r===`microsoft`?`Microsoft`:r===`microsoft_work`?`Microsoft 365`:n(`google`)?`Google`:n(`microsoft`)?`Microsoft`:n(`microsoft_work`)?`Microsoft 365`:`Google`}var BT=4e3;function VT({content:e,onRetry:t}){let[n,r]=(0,J.useState)([]),[i,a]=(0,J.useState)(!1),o=(0,J.useCallback)(()=>{he().then(e=>r(e.connectors||[])).catch(e=>d.ui.warn(`ConnectorRetryBanner: connector fetch failed`,e))},[]),s=RT(e,n);if((0,J.useEffect)(()=>{o();let e=()=>o();return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[o]),(0,J.useEffect)(()=>{if(s)return;let e=setInterval(o,BT);return()=>clearInterval(e)},[s,o]),!s||i)return null;let c=zT(e,n);return V(`div`,{className:`connector-retry-banner`,role:`status`,children:[P(Dr,{size:14,className:`connector-retry-banner__icon`}),V(`span`,{className:`connector-retry-banner__text`,children:[c,` connected since this reply — ask again to run it now.`]}),V(`button`,{type:`button`,className:`connector-retry-banner__btn`,onClick:()=>{a(!0),t()},children:[P(Pa,{size:12}),P(`span`,{children:`Ask again`})]}),P(`button`,{type:`button`,className:`connector-retry-banner__dismiss`,onClick:()=>a(!0),"aria-label":`Dismiss`,children:`×`})]})}function HT(e){return e.isMedia?TT(e.name)?pi:si:hi}var UT=240,WT=1e5;function GT({value:e,onChange:t,onSubmit:n,onStop:r,streaming:i=!1,stopping:a=!1,queueWhileStreaming:o=!1,disabledReason:s,attachments:c,placeholder:l,autoFocus:u,inputRef:d,leftControls:f,rightControls:p}){let m=T(),h=(0,J.useRef)(null),g=d??h,_=(0,J.useRef)(null),v=!!s,y=e.trim().length>0||c.hasUploaded,b=c.compose(e.trim()).length,x=b>WT,S=!v&&(!i||o)&&!c.uploading&&y&&!x,C=s||l||m(`composer.placeholder`);(0,J.useLayoutEffect)(()=>{let e=g.current;if(!e)return;let t=()=>{e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,UT)}px`};if(t(),typeof ResizeObserver>`u`)return;let n=e.clientWidth,r=new ResizeObserver(()=>{e.clientWidth!==n&&(n=e.clientWidth,t())});return r.observe(e),()=>r.disconnect()},[e,C,g]);let w=(0,J.useCallback)(e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),S&&n())},[S,n]),E=(0,J.useCallback)(e=>{e.dataTransfer?.files?.length&&(e.preventDefault(),e.stopPropagation(),c.addFiles(Array.from(e.dataTransfer.files)))},[c]);return V(`div`,{className:`composer${v?` composer-disabled`:``}`,onDrop:E,onDragOver:e=>{e.dataTransfer?.types?.includes(`Files`)&&e.preventDefault()},children:[c.attachments.length>0&&P(`ul`,{className:`composer-attachments`,"aria-label":m(`composer.attached`),children:c.attachments.map(e=>{let t=HT(e);return V(`li`,{className:`composer-attachment${e.error?` has-error`:``}${e.isMedia?` is-media`:``}`,children:[e.isImage&&e.url?P(`img`,{src:e.url,alt:``,className:`composer-attachment-thumb`}):P(t,{size:14,"aria-hidden":`true`}),P(`span`,{className:`composer-attachment-name`,title:e.name,dir:`auto`,children:e.name}),e.uploading&&P(`span`,{className:`composer-attachment-state`,children:e.progress===void 0?m(`composer.uploading`):m(`composer.uploadingPercent`,{percent:e.progress})}),e.uploaded&&e.isMedia&&P(`span`,{className:`composer-attachment-state`,children:m(`composer.mediaReady`)}),e.error&&P(`span`,{className:`composer-attachment-state`,role:`alert`,title:e.error,children:e.error}),P(`button`,{type:`button`,className:`composer-icon-btn`,onClick:()=>c.remove(e.id),"aria-label":m(`composer.remove`,{name:e.name}),children:P(So,{size:12})})]},e.id)})}),P(`textarea`,{ref:g,className:`composer-input`,value:e,onChange:e=>t(e.target.value),onKeyDown:w,onPaste:e=>{c.handlePaste(e)},placeholder:C,rows:1,disabled:v,autoFocus:u,"aria-label":m(`composer.message`),dir:`auto`}),x&&V(`p`,{className:`composer-limit-error`,role:`alert`,children:[m(`composer.tooLong`,{sent:b.toLocaleString(),max:1e5.toLocaleString()}),` `,m(`composer.tooLongHint`)]}),V(`div`,{className:`composer-row`,children:[V(`div`,{className:`composer-row-left`,children:[P(`button`,{type:`button`,className:`composer-icon-btn`,onClick:()=>_.current?.click(),disabled:v,"aria-label":m(`composer.attach`),title:m(`composer.attach`),children:P(Ma,{size:16})}),P(`input`,{ref:_,type:`file`,multiple:!0,hidden:!0,onChange:e=>{e.target.files&&c.addFiles(Array.from(e.target.files)),e.target.value=``}}),f]}),V(`div`,{className:`composer-row-right`,children:[p,i&&o&&y&&P(`button`,{type:`button`,className:`composer-send`,onClick:n,disabled:!S,"aria-label":m(`composer.queue`),title:m(`composer.queueTitle`),children:P(Yn,{size:16})}),i?P(`button`,{type:`button`,className:`composer-send is-stop`,onClick:r,disabled:a,"aria-label":m(`composer.stop`),title:a?m(`composer.stopping`):m.hint(m(`composer.stop`),`Esc`),children:P(io,{size:12,fill:`currentColor`})}):P(`button`,{type:`button`,className:`composer-send`,onClick:n,disabled:!S,"aria-label":m(`composer.send`),title:m.hint(m(`composer.send`),`Enter`),children:P(Yn,{size:16})})]})]})]})}var KT=8,qT=8;function JT({label:e,warning:t,children:n,id:r,pinned:i=!1,onUnpin:a,tabIndex:o}){let s=(0,J.useId)(),c=r??s,l=(0,J.useRef)(null),u=(0,J.useRef)(null),[d,f]=(0,J.useState)(!1),p=d||i,[m,h]=(0,J.useState)(null);return(0,J.useLayoutEffect)(()=>{if(!p){h(null);return}let e=l.current?.getBoundingClientRect(),t=u.current?.getBoundingClientRect(),n=l.current?.closest(`[role="dialog"]`)?.getBoundingClientRect()??e;if(!e||!t||!n)return;let r=window.innerWidth,i=window.innerHeight,a,o;n.right+KT+t.width<=r-qT?(a=n.right+KT,o=e.top+e.height/2-t.height/2):n.left-KT-t.width>=qT?(a=n.left-KT-t.width,o=e.top+e.height/2-t.height/2):(a=Math.min(Math.max(qT,e.right-t.width),r-qT-t.width),o=e.top-KT-t.height>=qT?e.top-KT-t.height:e.bottom+KT),o=Math.min(Math.max(qT,o),i-qT-t.height),h({left:a,top:o})},[p]),(0,J.useEffect)(()=>{if(!p)return;let e=()=>{f(!1),a?.()};return window.addEventListener(`scroll`,e,!0),()=>window.removeEventListener(`scroll`,e,!0)},[p,a]),V(D.Fragment,{children:[P(`button`,{ref:l,type:`button`,className:`info-bubble-icon${t?` is-warning`:``}`,"aria-label":e,tabIndex:o,"aria-describedby":p?c:void 0,onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),onFocus:()=>f(!0),onBlur:()=>f(!1),onClick:e=>{e.stopPropagation(),f(e=>!e)},onKeyDown:e=>{e.key===`Escape`&&p&&(e.stopPropagation(),f(!1))},children:P(Vi,{size:13,"aria-hidden":`true`})}),p&&(0,Qx.createPortal)(P(`div`,{ref:u,id:c,role:`tooltip`,className:`info-bubble`,style:m?{left:m.left,top:m.top}:{left:0,top:0,visibility:`hidden`},children:n}),document.body)]})}function YT(e){return e<.1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function XT(e,t=z){return e?t(`settings.price.perMillion`,{input:YT(e.input_per_million),output:YT(e.output_per_million)}):t(`settings.price.unknown`)}function ZT(e){return`$${e.toFixed(2)}`}var QT=2e3,$T=`waiting_for_os_permission`,eE=5;function tE(e,t){let n=e.rank?`#${e.rank} ${e.note??``}`.trim():null;return t?[n,XT(e.price)].filter(e=>!!e):[Ss(e.placement),e.size_gb?`${e.size_gb} GB`:null,e.tokens_per_second?`${Math.round(e.tokens_per_second)} tok/s on this PC`:null,n,e.custom?`added by you`:null].filter(e=>!!e)}function nE({m:e,onDownload:t,busy:n}){if(Ts(e)){let t=Math.round(e.download_progress?.percent??0);return V(`span`,{className:`model-state is-downloading`,title:`Downloading, ${t}%`,children:[P(K,{size:12,className:`spin`,"aria-hidden":`true`}),` `,t,`%`]})}let r=ws(e);return r===`not_downloaded`?P(`button`,{type:`button`,className:`model-state-btn`,onClick:e=>{e.stopPropagation(),t()},disabled:n,"aria-label":`Download ${e.display_name??e.id}`,title:xs.not_downloaded,tabIndex:-1,children:P(qr,{size:13,"aria-hidden":`true`})}):r===`loaded`?P(`span`,{className:`model-state is-loaded`,role:`img`,"aria-label":xs.loaded,title:xs.loaded}):P(`span`,{className:`model-state is-ready`,title:xs.downloaded,children:`Ready`})}function rE(){let e=cs(e=>e.active),t=cs(e=>e.select),n=cs(e=>e.queued),r=cs(e=>e.queue),i=cs(e=>e.queueError),a=cs(e=>e.rememberNames);cs(e=>e.names);let o=hs(),s=k(t=>gs(e,t.sessions,t.currentSessionId)),c=k(e=>e.isStreaming),l=k(e=>e.openSettings),u=(0,J.useRef)(null),[d,f]=(0,J.useState)(!1),[p,m]=(0,J.useState)(null),[h,g]=(0,J.useState)(0),[_,v]=(0,J.useState)(null),[y,b]=(0,J.useState)(null),[x,S]=(0,J.useState)(null),[C,w]=(0,J.useState)(null),[T,E]=(0,J.useState)(null),[D,O]=(0,J.useState)(0),[A,j]=(0,J.useState)(null),M=(0,J.useRef)(0),N=(0,J.useRef)(null),F=(0,J.useId)(),I=(0,J.useRef)(null),L=(0,J.useRef)(null),[ee,R]=(0,J.useState)(null),[z,B]=(0,J.useState)(null),te=(0,J.useCallback)(()=>B(null),[]),ne=(0,J.useCallback)(()=>f(!1),[]),re=(0,J.useRef)(!1),ie=(0,J.useCallback)(async(e=!1)=>{e||(re.current=!1,v(null),m(null));try{let{providers:t,lemonade_error:n}=await wn();if(n)throw Error(n);let r=t.filter(e=>!e.remote||e.models_discovered||e.id===`fireworks`||e.registered),i=await Promise.all(r.map(async e=>{if(e.remote&&!e.models_discovered)return{provider:e,models:[]};try{return{provider:e,models:(await Zt(e.id)).models}}catch(t){return{provider:e,models:[],error:Px(t)}}}));a(i.flatMap(e=>e.models)),g(i.flatMap(e=>e.models).filter(e=>e.available===!1).length),e||(re.current=!0),m(i.map(e=>({...e,models:e.models.filter(e=>e.available!==!1)})))}catch(e){v(Px(e))}},[a]);(0,J.useEffect)(()=>{d&&(b(null),R(null),B(null),ie())},[d,ie]),(0,J.useEffect)(()=>{if(!d||!p||!re.current)return;let e=I.current?.querySelector(`[role="option"][tabindex="0"]`);e&&(re.current=!1,e.focus(),e.scrollIntoView?.({block:`nearest`}))},[d,p]),(0,J.useEffect)(()=>{y&&L.current?.scrollIntoView?.({block:`nearest`})},[y]);let ae=e=>{if(e.altKey||e.ctrlKey||e.metaKey)return;let t=Array.from(I.current?.querySelectorAll(`[role="option"]:not(:disabled)`)??[]);if(!t.length)return;let n=t.indexOf(document.activeElement),r;switch(e.key){case`ArrowDown`:r=n<0?0:Math.min(n+1,t.length-1);break;case`ArrowUp`:r=n<0?t.length-1:Math.max(n-1,0);break;case`Home`:r=0;break;case`End`:r=t.length-1;break;case`ArrowRight`:case`i`:{let r=n<0?void 0:t[n].dataset.row;if(!r)return;e.preventDefault(),B(t=>e.key===`i`&&t===r?null:r);return}case`ArrowLeft`:e.preventDefault(),B(null);return;default:return}e.preventDefault(),t[r].focus(),t[r].scrollIntoView?.({block:`nearest`})},oe=!!p?.some(e=>e.models.some(Ts)),H=!!p?.some(e=>e.provider.key_state===$T);(0,J.useEffect)(()=>{if(!(d||T)||!(oe||T||H))return;let e=setInterval(()=>{ie(!0)},QT);return()=>clearInterval(e)},[d,oe,T,H,ie]);let U=(0,J.useCallback)(async e=>{w(e),O(e=>e+1),v(null);try{await fe(e),await ie(!0)}catch(t){E(t=>t?.model===e?null:t),v(Px(t))}finally{w(null),O(e=>e-1)}},[ie]),se=(0,J.useCallback)(async(n,i)=>{if(i.remote&&!e?.remote&&y?.model!==n)return b({model:n,provider:i}),null;if(b(null),c)return r(n===e?.model?null:n),f(!1),null;S(n),v(null);try{return await t(n),j(null),f(!1),null}catch(e){let t=Px(e);return v(t),t}finally{S(null)}},[e?.model,e?.remote,y,r,t,c]);(0,J.useEffect)(()=>{if(!T||!p||D>0)return;let{model:e,provider:t}=T,n=()=>(N.current!==p&&(N.current=p,M.current+=1),M.current>=eE),r=p.flatMap(e=>e.models).find(t=>t.id===e);if(!r){if(!n())return;E(null),j(`${ds(e)} is no longer in the model list, so it wasn't switched to.`);return}if(Ts(r)){M.current=0;return}let i=r.download_progress;if(i?.state===`error`)E(null),j(`Downloading ${ds(e)} failed: ${i.message??`no reason given`}`);else if(i?.state!==`complete`&&ws(r)===`not_downloaded`){if(!n())return;E(null),j(`The download of ${ds(e)} never started. Try the download button again.`)}else E(null),se(e,t).then(t=>{t&&j(`${ds(e)} downloaded, but switching to it failed: ${t}`)})},[p,T,D,se]);let W=p?.flatMap(({provider:e,models:t})=>[...e.remote&&!e.models_discovered?[`key:${e.id}`]:[],...t.filter(e=>x===null&&!Ts(e)).map(e=>e.id)])??[],G=n??e?.model,ce=ee&&W.includes(ee)?ee:G&&W.includes(G)?G:W[0],le=e=>({role:`option`,tabIndex:e===ce?0:-1,"data-row":e,onFocus:()=>R(e),onBlur:()=>B(null)}),ue=o?.remote?Fr:o?Ur:kr,de=s?ds(s):`Model`,pe=`${de}${o?` · ${o.label}`:``}`,me=Object.fromEntries((p??[]).map(e=>[e.provider.id,ys(e.models)])),he=e?.downloaded===!1&&s===e.model,ge=A||i||(n?`${ds(n)} is used from your next message.`:e?.config_error?e.config_error:he?`${de} isn't downloaded yet. Open the list to download it.`:o?o.description?.replace(/`/g,``)??(o.remote?`Runs on ${o.label} — chat history leaves this PC`:`Runs on this PC`):ms);return V(`div`,{className:`composer-chip-wrap`,children:[V(`button`,{ref:u,type:`button`,className:`composer-chip${he||i||A?` is-warning`:``}`,onClick:()=>f(e=>!e),"aria-haspopup":`dialog`,"aria-expanded":d,title:ge,children:[P(ue,{size:13,"aria-hidden":`true`}),P(`span`,{className:`composer-chip-label`,dir:`auto`,children:pe}),n&&V(`span`,{className:`composer-chip-next`,children:[`→ `,ds(n),` next`]}),he&&P(qr,{size:12,"aria-label":`Not downloaded`}),A&&P(Cr,{size:12,"aria-label":`Model switch failed`}),P(hr,{size:12,"aria-hidden":`true`})]}),V(Ro,{open:d,onClose:ne,anchor:u,label:`Choose a model`,align:`end`,children:[c&&V(`div`,{className:`popover-message`,role:`status`,children:[`This reply keeps `,s?ds(s):`its model`,`. A model you pick here is used from your next message.`]}),A&&P(`div`,{className:`popover-message is-error`,role:`alert`,children:A}),i&&P(`div`,{className:`popover-message is-error`,role:`alert`,children:i}),_&&P(`div`,{className:`popover-message is-error`,role:`alert`,children:_}),!p&&!_&&V(`div`,{className:`popover-message`,children:[P(K,{size:13,className:`spin`}),` Loading models…`]}),p&&P(`div`,{ref:I,role:`listbox`,"aria-label":`Models`,onKeyDown:ae,children:p.map(({provider:t,models:r,error:i})=>V(`div`,{role:`group`,"aria-labelledby":`${F}-${t.id}`,children:[P(`div`,{className:`popover-heading`,id:`${F}-${t.id}`,children:t.name}),i&&P(`div`,{className:`popover-message is-error`,children:i}),t.key_state===$T?V(`div`,{className:`popover-message`,role:`status`,children:[P(K,{size:13,className:`spin`,"aria-hidden":`true`}),` `,t.key_message]}):t.remote&&!t.models_discovered&&V(`button`,{type:`button`,className:`popover-item`,...le(`key:${t.id}`),"aria-selected":!1,onClick:()=>{f(!1),l(`model`,t.id)},children:[P(`span`,{className:`popover-item-check`,children:P(Ui,{size:13,"aria-hidden":`true`})}),V(`span`,{className:`popover-item-body`,children:[P(`span`,{className:`popover-item-title`,children:`Add your key`}),V(`span`,{className:`popover-item-note`,children:[`Connect `,t.name,` in Settings`]})]})]}),!i&&r.length===0&&t.models_discovered!==!1&&P(`div`,{className:`popover-message`,children:`No models yet.`}),r.map(r=>{let i=us(n??e?.model,r.id),a=!t.remote&&ws(r)===`not_downloaded`,o=me[t.id][r.id],s=tE(r,t.remote),c=`${F}-info-${t.id}-${r.id}`;return V(J.Fragment,{children:[V(`div`,{className:`popover-row`,children:[V(`button`,{type:`button`,className:`popover-item`,onClick:()=>{a?(M.current=0,j(null),E({model:r.id,provider:t}),U(r.id)):(E(null),se(r.id,t))},disabled:x!==null||Ts(r),...le(r.id),"aria-selected":i,"aria-describedby":z===r.id?c:void 0,children:[P(`span`,{className:`popover-item-check`,"aria-hidden":`true`,children:x===r.id?P(K,{size:13,className:`spin`}):i?P(pr,{size:13}):null}),P(`span`,{className:`popover-item-body`,children:P(`span`,{className:`popover-item-title`,children:o})})]}),V(JT,{label:`About ${o}`,warning:!!r.placement?.warning,id:c,pinned:z===r.id,onUnpin:te,tabIndex:-1,children:[P(`div`,{className:`info-bubble-title`,children:o}),s.length>0&&P(`ul`,{className:`info-bubble-lines`,children:s.map(e=>P(`li`,{children:e},e))}),r.placement?.warning&&P(`ul`,{className:`info-bubble-lines`,children:P(`li`,{className:`is-warning`,children:r.placement.warning})}),P(`div`,{className:`info-bubble-id`,children:r.id})]}),P(`span`,{className:`popover-row-state`,children:!t.remote&&P(nE,{m:r,busy:C!==null,onDownload:()=>void U(r.id)})})]}),y?.model===r.id&&y.provider.id===t.id&&V(`div`,{ref:L,className:`popover-message`,role:`alert`,children:[y.provider.privacy_notice,` `,V(`button`,{type:`button`,className:`link-btn`,onClick:()=>se(y.model,y.provider),children:[`Use `,ds(y.model)]})]})]},r.id)})]},t.id))}),h>0&&V(`button`,{type:`button`,className:`popover-item`,onClick:()=>{f(!1),l(`model`)},children:[P(`span`,{className:`popover-item-check`}),P(`span`,{className:`popover-item-body`,children:V(`span`,{className:`popover-item-note`,children:[h,` `,h===1?`model isn’t`:`models aren’t`,` available on this PC — see why in Settings`]})})]}),P(`div`,{className:`popover-divider`}),V(`button`,{type:`button`,className:`popover-item`,onClick:()=>{f(!1),l(`model`)},children:[P(`span`,{className:`popover-item-check`,children:P(Zi,{size:13,"aria-hidden":`true`})}),V(`span`,{className:`popover-item-body`,children:[P(`span`,{className:`popover-item-title`,children:`Add a model from a link…`}),P(`span`,{className:`popover-item-note`,children:`Any GGUF chat model on Hugging Face`})]})]}),V(`button`,{type:`button`,className:`popover-item`,onClick:()=>{f(!1),l(`model`)},children:[P(`span`,{className:`popover-item-check`}),P(`span`,{className:`popover-item-body`,children:P(`span`,{className:`popover-item-title`,children:`Providers and keys…`})})]})]})]})}function iE(e,t,n){if(e==null||!t(e))throw Error(`the server sent no ${n}`);return e}var aE=e=>e.startsWith(`.`);function oE({onPick:e,onClose:t}){let n=T(),[r,i]=(0,J.useState)(null),[a,o]=(0,J.useState)(``),[s,c]=(0,J.useState)(null),[l,u]=(0,J.useState)(!1),[d,f]=(0,J.useState)(!1);Io(!0,t);let p=(0,J.useRef)(null);aS(p,!0);let m=(0,J.useCallback)(e=>{u(!0),c(null),Promise.resolve().then(()=>Ot(e)).then(e=>{let t=iE(e,e=>Array.isArray(e.entries),`folder listing`);i(t),o(t.current_path)}).catch(e=>c(e instanceof vn?e.detail||e.message:String(e))).finally(()=>u(!1))},[]);(0,J.useEffect)(()=>m(),[m]);let h=r?.entries.filter(e=>e.type===`folder`)??[],g=d?h:h.filter(e=>!aE(e.name));return P(`div`,{className:`modal-overlay`,onClick:t,children:V(`div`,{ref:p,className:`modal-panel sp-picker`,role:`dialog`,"aria-modal":`true`,"aria-label":n(`pick.label`),onClick:e=>e.stopPropagation(),children:[V(`div`,{className:`modal-header`,children:[P(`h3`,{children:n(`pick.title`)}),P(`button`,{type:`button`,className:`btn-icon`,onClick:t,"aria-label":n(`sp.closeShort`),children:P(So,{size:18})})]}),V(`div`,{className:`modal-body sp-picker-body`,children:[P(`p`,{className:`sp-meta`,children:n(`pick.note`)}),V(`form`,{className:`sp-picker-path`,onSubmit:e=>{e.preventDefault(),a.trim()&&m(a.trim())},children:[P(`input`,{value:a,onChange:e=>o(e.target.value),"aria-label":n(`pick.path`),spellCheck:!1,dir:`ltr`}),P(`button`,{type:`submit`,className:`sp-action`,children:n(`pick.go`)})]}),r&&V(`div`,{className:`sp-picker-quick`,children:[r.quick_links.map(e=>P(`button`,{type:`button`,className:`sp-action`,onClick:()=>m(e.path),children:e.name},e.path)),V(`label`,{className:`sp-picker-hidden`,children:[P(`input`,{type:`checkbox`,checked:d,onChange:e=>f(e.target.checked)}),n(`pick.showHidden`)]})]}),V(`ul`,{className:`sp-picker-list`,"aria-busy":l,children:[r?.parent_path&&P(`li`,{children:V(`button`,{type:`button`,onClick:()=>m(r.parent_path??void 0),children:[P(Yn,{size:13,"aria-hidden":`true`}),` `,n(`pick.up`)]})}),g.map(e=>P(`li`,{children:V(`button`,{type:`button`,onClick:()=>m(e.path),children:[P(Ti,{size:13,"aria-hidden":`true`}),` `,e.name]})},e.path)),r&&g.length===0&&P(`li`,{className:`sp-meta`,children:n(h.length>0?`pick.onlyHidden`:`pick.none`)}),l&&V(`li`,{className:`sp-meta`,children:[P(K,{size:12,className:`spin`,"aria-hidden":`true`}),` `,n(`pick.loading`)]})]}),s&&P(`p`,{className:`sp-error`,role:`alert`,children:s})]}),V(`div`,{className:`sp-picker-actions`,children:[P(`button`,{type:`button`,className:`btn-secondary`,onClick:t,children:n(`sp.cancel`)}),P(`button`,{type:`button`,className:`btn-primary`,disabled:!r,onClick:()=>r&&e(r.current_path),children:n(`pick.use`)})]})]})})}function sE(e){let[t,n]=(0,J.useState)(!1),[r,i]=(0,J.useState)(null);return{open:t=>{i(null);let r=window.gaiaAPI?.dialog;r?r.pickFolder(t).then(t=>{t&&e(t)}).catch(e=>i(`Couldn't open the folder picker: ${e instanceof Error?e.message:String(e)}`)):n(!0)},picker:t?P(oE,{onPick:t=>{n(!1),e(t)},onClose:()=>n(!1)}):null,error:r}}var cE=new Map;function lE(e){let t=cE.get(e);return t||(t={env:null,error:null,inFlight:null,version:0,listeners:new Set},cE.set(e,t)),t}function uE(e,t,n){let r=lE(e);r.env=t??r.env,r.error=n,r.listeners.forEach(e=>e())}function dE(e){let t=lE(e);if(t.inFlight)return t.inFlight;let n=t.version;return t.inFlight=Promise.resolve().then(()=>Me(e)).then(r=>{let i=iE(r,e=>Array.isArray(e.folders),`chat's environment`);t.version===n&&uE(e,i,null)}).catch(t=>uE(e,null,t instanceof Error?t.message:String(t))).finally(()=>{t.inFlight=null}),t.inFlight}function fE(e){let[,t]=(0,J.useState)(0);(0,J.useEffect)(()=>{let n=lE(e),r=()=>t(e=>e+1);return n.listeners.add(r),!n.env&&!n.inFlight&&dE(e),()=>{n.listeners.delete(r)}},[e]);let n=(0,J.useCallback)(()=>dE(e),[e]),r=(0,J.useCallback)(async t=>{let n=await t();return lE(e).version+=1,uE(e,n,null),n},[e]),i=lE(e);return{env:i.env,error:i.error,refresh:n,change:r}}var pE=e=>e.split(/[\\/]/).filter(Boolean).pop()??e;function mE({folder:e,disabled:t}){let n=k(e=>e.draftFolder),r=k(e=>e.setDraftFolder),{open:i,picker:a,error:o}=sE(r),s=e.gaia_folder?`GAIA works in its own folder, ${e.path}.`:`GAIA works in ${e.path}.`;return e.choosable?V(D.Fragment,{children:[V(`button`,{type:`button`,className:`new-chat-folder is-button${n?` is-on`:``}`,onClick:()=>i(e.path),disabled:t,"aria-haspopup":`dialog`,"aria-label":n?`Folder for this chat: ${e.name}, plus ${pE(n)}`:`Folder for this chat: ${e.name}`,title:n?`This chat can read and write ${n}. Click to pick another folder.`:`${s} Click to give this chat another folder.`,children:[P(Ti,{size:13,"aria-hidden":`true`}),P(`span`,{className:`new-chat-folder-name`,dir:`auto`,children:n?`${e.name} + ${pE(n)}`:e.name}),P(hr,{size:12,"aria-hidden":`true`})]}),n&&P(`button`,{type:`button`,className:`btn-icon-sm new-chat-folder-clear`,onClick:()=>r(null),disabled:t,"aria-label":`Don't give this chat ${pE(n)}`,title:`Don't add this folder`,children:P(So,{size:12})}),o&&P(`span`,{className:`new-chat-folder-error`,role:`alert`,children:o}),a]}):V(`span`,{className:`new-chat-folder`,title:e.gaia_folder?`${s} Attach a file or start GAIA from a project folder to work there.`:s,children:[P(Ti,{size:13,"aria-hidden":`true`}),P(`span`,{className:`new-chat-folder-name`,dir:`auto`,children:e.name})]})}function hE({sessionId:e,onOpen:t}){let{env:n}=fE(e),r=n?.folders.find(e=>e.source===`working_folder`);if(!r)return null;let i=pE(r.path);return V(`button`,{type:`button`,className:`composer-chip folder-chip`,title:`GAIA works in ${r.path}`,"aria-label":`Working folder ${i}, show the chat's folders`,onClick:t,children:[P(Ti,{size:13,"aria-hidden":`true`}),P(`span`,{className:`composer-chip-label`,dir:`auto`,children:i})]})}var gE=`gaia:permission-mode`;function _E(e,t){window.dispatchEvent(new CustomEvent(gE,{detail:{sessionId:e,mode:t}}))}function vE(e,t){let n=(0,J.useRef)(t);n.current=t,(0,J.useEffect)(()=>{if(!e)return;let t=t=>{let r=t.detail;r?.sessionId===e&&n.current(r.mode)};return window.addEventListener(gE,t),()=>window.removeEventListener(gE,t)},[e])}var yE=[{mode:`ask`,label:`perm.ask`,note:`perm.askNote`},{mode:`full_access`,label:`perm.full`,note:`perm.fullNote`}];function bE({sessionId:e,disabled:t}){let n=T(),r=k(e=>e.draftPermissionMode),i=k(e=>e.setDraftPermissionMode),[a,o]=(0,J.useState)(e?`ask`:r),[s,c]=(0,J.useState)(!1),[l,u]=(0,J.useState)(!1),[d,f]=(0,J.useState)(null),p=(0,J.useRef)(null);(0,J.useEffect)(()=>{if(!e){o(r);return}let t=!1;return St(e).then(e=>{t||o(e.mode)}).catch(e=>{t||f(Px(e))}),()=>{t=!0}},[e,r]),vE(e,o);let m=(0,J.useCallback)(async t=>{if(t===`full_access`&&!l)u(!0);else{f(null);try{if(e){let n=(await Pt(e,t)).mode;o(n),_E(e,n)}else i(t),o(t);c(!1)}catch(t){f(Px(t)),e&&St(e).then(e=>o(e.mode)).catch(e=>f(t=>`${t??``} Couldn't re-read the saved mode: ${Px(e)}`.trim()))}finally{u(!1)}}},[l,e,i]),h=a===`full_access`,_=h?Wa:Ka;return V(`div`,{className:`composer-chip-wrap`,children:[V(`button`,{ref:p,type:`button`,className:`composer-chip${h?` is-warning`:``}`,onClick:()=>{u(!1),c(e=>!e)},disabled:t,"aria-haspopup":`dialog`,"aria-expanded":s,"aria-label":n(`perm.chipAria`,{mode:g(h?`perm.fullLower`:`perm.askLower`)}),children:[P(_,{size:13,"aria-hidden":`true`}),P(`span`,{className:`composer-chip-label`,dir:`auto`,children:n(h?`perm.full`:`env.ask`)}),P(hr,{size:12,"aria-hidden":`true`})]}),V(Ro,{open:s,onClose:()=>c(!1),anchor:p,label:n(`env.permission`),children:[yE.map(e=>V(`button`,{type:`button`,className:`popover-item`,onClick:()=>m(e.mode),"aria-pressed":a===e.mode,children:[P(`span`,{className:`popover-item-check`,"aria-hidden":`true`,children:a===e.mode&&P(pr,{size:13})}),V(`span`,{className:`popover-item-body`,children:[P(`span`,{className:`popover-item-title`,children:n(e.label)}),P(`span`,{className:`popover-item-note`,children:n(e.note)})]})]},e.mode)),l&&V(`div`,{className:`popover-message`,role:`alert`,children:[n(`env.fullAccessWarn`),` `,P(`button`,{type:`button`,className:`link-btn`,onClick:()=>m(`full_access`),children:n(`env.turnOn`)})]}),d&&P(`div`,{className:`popover-message is-error`,role:`alert`,children:d})]})]})}var xE={sending:`Adding to the running reply…`,delivered:`Added to the running reply. GAIA reads it at its next step.`,queued:`Queued. Sends when this reply ends.`};function SE(e,t){return e?xE.queued:t?`GAIA is still busy in this chat. Trying again in a few seconds.`:`Sending next.`}function CE({items:e,onRemove:t,onSteer:n,onRetry:r,replying:i=!0,busyRetry:a=!1}){let o=e.filter(e=>e.state!==`starting`);return o.length===0?null:P(`ul`,{className:`queued-messages`,"aria-label":`Messages waiting to send`,"aria-live":`polite`,children:o.map(e=>V(`li`,{className:`queued-message is-${e.state}`,children:[e.state===`failed`?P(Cr,{size:12,"aria-hidden":`true`}):e.state===`queued`?P(Nr,{size:12,"aria-hidden":`true`}):P(Vr,{size:12,"aria-hidden":`true`}),P(`span`,{className:`queued-message-text`,title:e.text,children:e.text}),P(`span`,{className:`queued-message-state`,title:e.error,children:e.state===`failed`?`Not sent. ${e.error??``}`.trim():e.state===`queued`?i&&e.note||SE(i,a):xE[e.state]}),e.state===`failed`&&V(`button`,{type:`button`,className:`queued-message-steer`,onClick:()=>r(e.id),"aria-label":`Send again: ${e.text}`,children:[P(Ra,{size:11,"aria-hidden":`true`}),` Send again`]}),e.state===`queued`&&n&&P(`button`,{type:`button`,className:`queued-message-steer`,onClick:()=>n(e.id),title:`GAIA reads it at its next step, without starting over. It may not answer it separately.`,children:`Add to this reply`}),(e.state===`queued`||e.state===`failed`)&&P(`button`,{type:`button`,className:`queued-message-remove`,onClick:()=>t(e.id),"aria-label":`Remove queued message: ${e.text}`,title:`Remove`,children:P(So,{size:12})})]},e.id))})}var wE=e=>e.toLocaleString(`en-US`);function TE({n:e}){let t=T();if(e==null)return P(`span`,{className:`cp-unknown`,children:t(`ctx.unknown`)});let n=e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(+(e<1e4))}K`:`${(e/1e6).toFixed(1).replace(/\.0$/,``)}M`;return P(`span`,{title:t(`ctx.tokens`,{n:wE(e)}),dir:`ltr`,children:n})}function EE({s:e}){let t=T();if(e==null)return P(`span`,{className:`cp-unknown`,children:t(`ctx.unknown`)});let n=e<.1?e===0?`0 s`:`<0.1 s`:e<10?`${e.toFixed(1)} s`:`${Math.round(e)} s`;return P(`span`,{title:`${(e*1e3).toFixed(0)} ms`,dir:`ltr`,children:n})}function DE({r:e}){let t=T();return e==null?P(`span`,{className:`cp-unknown`,children:t(`ctx.unknown`)}):P(`span`,{title:t(`ctx.rateTitle`,{n:e}),children:t(`ctx.rate`,{n:Math.round(e).toLocaleString(`en-US`)})})}var OE=(e,t)=>t>0?Math.round(e/t*100):0,kE=(e,t)=>{let n=OE(e,t);return n===0&&e>0?`<1`:String(n)},AE=(e,t)=>t&&e!=null?Math.floor(e/t*100):null,jE=256;function ME(e,t=z){if(e.provider===`unknown`)return t(`ctx.unknown`);if(e.provider===`cloud`)return t(`ctx.cloud`);if(e.provider!==`local`)return t(`ctx.cloudVia`,{provider:bs(e.provider)});if(!e.device)return e.loaded===!1?t(`ctx.notLoadedNow`):t(`ctx.unknown`);let n=e.device.toUpperCase(),r=e.backend===`npu`?`FLM`:e.backend;return r&&r!==e.device?`${n} · ${r.charAt(0).toUpperCase()}${r.slice(1)}`:n}function NE({label:e,children:t,hint:n}){return V(`div`,{className:`cp-row`,title:n,children:[P(`dt`,{children:e}),P(`dd`,{children:t})]})}function PE({t:e}){let t=T();if(e.model_seconds==null||e.gaia_seconds==null)return V(NE,{label:t(`ctx.took`),children:[P(EE,{s:e.wall_seconds}),` · `,t.bare(`ctx.split`),` `,P(`span`,{className:`cp-unknown`,children:t(`ctx.unknown`)})]});let n=[{key:`model`,label:t(`ctx.inModel`),s:e.model_seconds},{key:`tools`,label:t(`ctx.runningTools`),s:e.tool_seconds},{key:`waiting`,label:t(`ctx.waitingOnYou`),s:e.waiting_seconds},{key:`gaia`,label:t(`ctx.gaiaItself`),s:e.own_seconds??0}];return V(D.Fragment,{children:[P(NE,{label:t(`ctx.took`),hint:t(`ctx.tookHint`),children:P(EE,{s:e.wall_seconds})}),P(`div`,{className:`cp-stack`,"aria-hidden":`true`,children:n.map(t=>P(`span`,{className:`cp-time-${t.key}`,style:{width:`${OE(t.s,e.wall_seconds)}%`}},t.key))}),V(`dl`,{className:`cp-rows cp-indent`,children:[P(NE,{label:t(`ctx.inModel`),children:P(EE,{s:e.model_seconds})}),P(NE,{label:t(`ctx.inGaia`),hint:t(`ctx.inGaiaHint`),children:P(EE,{s:e.gaia_seconds})}),n.slice(1).filter(e=>e.s>0).map(e=>V(NE,{label:`· ${e.label}`,children:[P(`span`,{className:`swatch cp-time-${e.key}`,"aria-hidden":`true`}),` `,P(EE,{s:e.s})]},e.key))]})]})}function FE({why:e}){let t=T();return P(`span`,{className:`cp-unknown`,title:e,children:t(`ctx.unknown`)})}var IE={server:`ctx.src.server`,client:`ctx.src.client`};function LE(e,t){return e?t(IE[e]):void 0}function RE({turn:e}){let t=T(),n=AE(e.tokens_cached,e.tokens_in),r=e.unknown??{},i=e.tools.map(e=>`${e.name??t(`ctx.toolOutside`)}: ${e.seconds??`?`} s`).join(`
|
|
63
63
|
`);return V(D.Fragment,{children:[P(PE,{t:e.time}),V(`dl`,{className:`cp-rows`,children:[P(NE,{label:t(`ctx.firstWord`),hint:LE(e.first_token_source,t),children:e.first_token_seconds==null?P(FE,{why:r.first_token_seconds}):V(D.Fragment,{children:[t.bare(`ctx.in`),` `,P(EE,{s:e.first_token_seconds})]})}),P(NE,{label:t(`ctx.readingPrompt`),hint:t(`ctx.readingHint`),children:e.tokens_new!=null&&e.tokens_new<jE?P(`span`,{title:t(`ctx.tooFewTitle`),children:t(`ctx.onlyNew`,{n:e.tokens_new})}):e.prefill_tokens_per_second==null?P(FE,{why:r.prefill_tokens_per_second}):V(D.Fragment,{children:[P(DE,{r:e.prefill_tokens_per_second}),e.prefill_source===`client`&&P(`span`,{className:`cp-chip`,title:t(`ctx.approxTitle`),children:t(`ctx.approx`)})]})}),P(NE,{label:t(`ctx.writing`),hint:LE(e.generation_source,t)??t(`ctx.writingHint`),children:e.generation_tokens_per_second==null?P(FE,{why:r.generation_tokens_per_second}):P(DE,{r:e.generation_tokens_per_second})}),P(NE,{label:t(`ctx.tokensInOut`),hint:r.tokens,children:V(`span`,{dir:`ltr`,children:[P(TE,{n:e.tokens_in}),` → `,P(TE,{n:e.tokens_out})]})}),P(NE,{label:t(`ctx.cache`),hint:t(`ctx.cacheHint`),children:e.tokens_cached==null?P(FE,{why:r.tokens_cached}):V(D.Fragment,{children:[P(TE,{n:e.tokens_cached}),n!=null&&` (${n}%)`]})}),P(NE,{label:t(`ctx.modelCalls`),children:e.model_calls}),P(NE,{label:t(`ctx.toolCalls`),hint:i||void 0,children:e.tool_calls===0&&!e.tool_seconds_total?t(`ctx.none`):V(D.Fragment,{children:[e.tool_calls,` · `,P(EE,{s:e.tool_seconds_total??0})]})}),P(NE,{label:t(`ctx.loads`),children:e.loads.length===0?t(`ctx.none`):V(`span`,{title:e.loads.map(e=>`${e.model}${e.replaced?.length?` replaced ${e.replaced.join(`, `)}`:``}: ${e.seconds} s`).join(`
|
|
@@ -78,6 +78,6 @@ Error generating stack: `+e.message+`
|
|
|
78
78
|
`);return(0,J.useEffect)(()=>{let e=r.current;e&&i.current&&(e.scrollTop=e.scrollHeight)},[a]),P(`pre`,{ref:r,id:n,className:t,dir:`ltr`,tabIndex:0,onScroll:e=>{let t=e.currentTarget;i.current=t.scrollHeight-t.scrollTop-t.clientHeight<8},children:a})}var mM=1e9,hM={downloading:0,verifying:1,failed:2,ready:3,unchecked:3,cancelled:4,queued:5,skipped:6};function gM(e){return e.roles.includes(`embedding`)?0:e.roles.includes(`chat`)?1:2}function _M(e){return[...e].filter(e=>e.state!==`skipped`).sort((e,t)=>hM[e.state]-hM[t.state]||gM(e)-gM(t))}var vM=/^\s*(Downloading:|Downloaded\b|\[[=\-\s>#]*\])/;function yM(e){return e.some(e=>e.trim()&&!vM.test(e))}var bM={queued:`setup.state.queued`,downloading:`setup.state.downloading`,verifying:`setup.state.verifying`,ready:`setup.state.ready`,failed:`setup.state.failed`,skipped:`setup.state.skipped`,cancelled:`setup.state.cancelled`,unchecked:`setup.state.unchecked`};function xM(e){return e?e.state===`running`||e.state===`verifying`||!!e.models?.some(e=>e.state===`downloading`||e.state===`queued`||e.state===`verifying`):!1}function SM(e,t,n,r){switch(e.error_kind){case`network`:return r(`setup.fail.network`,{name:t});case`disk_full`:{let i=Math.max(0,e.bytes_total-e.bytes_done)/1e9,a=n==null?i:Math.max(.1,i-n);return r(`setup.fail.diskFull`,{name:t,done:MS(e.bytes_done),need:$(a)})}case`verify`:return r(`setup.fail.verify`,{name:t});case`memory`:return r(`setup.fail.testMemory`,{name:t});case`stuck`:return r(`setup.fail.testStuck`,{name:t});case`answer`:return r(`setup.fail.testAnswer`,{name:t});case`window`:return r(`setup.fail.testWindow`,{name:t});case`path_too_long`:return r(`setup.fail.pathTooLong`,{name:t});default:return r(`setup.fail.lemonade`,{name:t})}}function CM({model:e,name:t,estimate:n,now:r,freeGb:i,onRetry:a,onResume:o,onSkip:s,onRestart:c,busy:l,retryLater:u,checking:d,checkingFor:f}){let p=T(),m=(0,J.useId)(),h=(0,J.useId)(),[g,_]=(0,J.useState)(!1),v=e.log??[],y=e.bytes_total>0?Math.min(100,e.bytes_done/e.bytes_total*100):e.state===`ready`?100:0,b=p(bM[e.state]),x=e.retrying_until?Math.max(0,Math.round(e.retrying_until-r/1e3)):0,S=e.state===`downloading`&&!x?n?.stalledFor??0:0,C=e.state===`verifying`&&d||e.state===`downloading`&&!x&&S<15,w;if(e.state===`downloading`){let t=PS(p.locale,e.bytes_total>0?`${MS(e.bytes_done)} / ${MS(e.bytes_total)}`:MS(e.bytes_done));if(x>0)w=p(`setup.progress.retrying`,{n:String(x)});else if(S>=60)w=p(`setup.progress.stuck`);else if(S>=15)w=p(`setup.progress.stalled`,{n:`15`});else if(n?.speed&&n.eta!=null){let{speed:e,eta:r}=n;w=p.compose(n=>`${t} · ${PS(p.locale,NS(e))} · ${FS(r,n)}`)}else w=p.compose(e=>`${t} · ${e(`setup.progress.estimating`)}`)}else w=e.state===`verifying`?d?f>=10?p(`setup.progress.checkingFor`,{n:String(f)}):p(`setup.progress.checkingLoad`):p(`setup.progress.waitingCheck`):e.state===`ready`?e.bytes_total?MS(e.bytes_total):``:e.state===`unchecked`?p(`setup.progress.unchecked`):e.state===`cancelled`?e.bytes_done>0?p(`setup.progress.keptPartial`,{done:MS(e.bytes_done)}):``:e.state===`queued`&&e.bytes_total?MS(e.bytes_total):``;let E=e.state===`downloading`?p.compose(t=>[t(`setup.progress.percent`,{n:String(Math.floor(y))}),e.bytes_total?t(`setup.progress.of`,{done:MS(e.bytes_done),total:MS(e.bytes_total)}):null,n?.eta==null?null:IS(n.eta,t)].filter(Boolean).join(`, `)):b;return V(`li`,{className:`dl-row is-${e.state}${C?` is-live`:``}${S>=15?` is-stalled`:``}`,children:[V(`div`,{className:`dl-row-head`,children:[P(`span`,{className:`dl-icon`,"aria-hidden":`true`,children:e.state===`ready`||e.state===`unchecked`?P(pr,{size:14}):e.state===`failed`?P(Cr,{size:14}):e.state===`cancelled`?P(Sa,{size:13}):P(`span`,{className:`dl-dot`})}),P(`span`,{className:`dl-name`,children:P(`bdi`,{title:e.id,children:t})}),P(`span`,{className:`dl-state`,children:b}),e.state===`downloading`&&V(`bdi`,{className:`dl-pct`,children:[Math.floor(y),`%`]}),e.state!==`failed`&&yM(v)&&P(`button`,{type:`button`,className:`dl-log-toggle`,onClick:()=>_(e=>!e),"aria-expanded":g,"aria-controls":h,"aria-label":p(`setup.progress.logFor`,{name:t}),title:p(`setup.progress.logFor`,{name:t}),children:P(yr,{size:14,className:g?`is-open`:``,"aria-hidden":`true`})})]}),P(`div`,{className:`dl-track`,role:`progressbar`,"aria-label":p(`setup.progress.rowLabel`,{name:t,state:b}),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":C&&e.state===`verifying`?void 0:Math.floor(y),"aria-valuetext":E,children:P(`span`,{className:`dl-fill`,style:{inlineSize:`${e.state===`verifying`?100:y}%`}})}),w&&P(`p`,{className:`dl-detail`,children:P(`bdi`,{children:w})}),g&&e.state!==`failed`&&yM(v)&&P(pM,{lines:v,id:h,className:`dl-log`}),e.state===`failed`&&V(`div`,{className:`dl-fail`,children:[P(`p`,{className:`dl-error`,id:m,children:SM(e,t,i,p)}),(v.length>0||e.error)&&V(`details`,{className:`dl-details`,children:[P(`summary`,{children:p(`setup.progress.details`)}),P(`pre`,{dir:`ltr`,children:v.length>0?v.join(`
|
|
79
79
|
`):e.error})]}),u?P(`p`,{className:`dl-detail`,children:p(`setup.progress.retryLater`)}):V(`div`,{className:`setup-row`,children:[a&&V(`button`,{type:`button`,className:`btn-primary`,disabled:l,onClick:()=>a(e.id,e.error_kind),"aria-describedby":m,children:[P(Ra,{size:13,"aria-hidden":`true`}),` `,p(`setup.progress.retry`)]}),s&&P(`button`,{type:`button`,className:`btn-secondary`,disabled:l,onClick:()=>s(e.id),children:p(`setup.progress.skipModel`)})]})]}),e.state===`cancelled`&&o&&P(`div`,{className:`setup-row`,children:P(`button`,{type:`button`,className:`btn-secondary`,disabled:l,onClick:()=>o(e.id),children:p(`setup.progress.resume`)})}),S>=60&&c&&P(`div`,{className:`setup-row`,children:V(`button`,{type:`button`,className:`btn-secondary`,disabled:l,onClick:c,children:[P(Ra,{size:13,"aria-hidden":`true`}),` `,p(`setup.progress.retry`)]})})]})}function wM({status:e,names:t,freeGb:n=null,onCancel:r,onRetry:i,onResume:a,onResumeAll:o,onSkip:s,onRestart:c,busy:l=!1,retryLater:u=!1,labelledBy:d}){let f=T(),p=KA(),m=(0,J.useMemo)(()=>_M(e.models??[]),[e.models]),h=(0,J.useRef)(new Map),g=(0,J.useRef)(new Map),_=(0,J.useRef)(new RS),v=(0,J.useRef)(!1),[y,b]=(0,J.useState)(()=>Date.now()),[x,S]=(0,J.useState)(!1),[C,w]=(0,J.useState)(null),E=i&&((e,t)=>{let n=m.find(t=>t.id===e);t===`verify`&&n?w(n):i(e,t)}),[D,O]=(0,J.useState)(``),[k,A]=(0,J.useState)(``),j=(0,J.useRef)(null),M=e.state===`verifying`||e.state!==`running`&&m.some(e=>e.state===`verifying`),N=(0,J.useRef)(new Map);(0,J.useEffect)(()=>{if(!p||!(m.some(e=>e.retrying_until)||M))return;let e=setInterval(()=>b(Date.now()),1e3);return()=>clearInterval(e)},[m,p,M]);let F=e.overall,{estimates:I,overallEstimate:L}=(0,J.useMemo)(()=>{let e=Date.now(),t={};for(let n of m){if(n.state!==`downloading`){h.current.delete(n.id);continue}let r=h.current.get(n.id),i=n.downloaded_before_gb??null;(!r||g.current.get(n.id)!==i)&&(r=new RS,h.current.set(n.id,r),g.current.set(n.id,i)),t[n.id]=r.update(n.bytes_done,n.bytes_total,e)}let n=m.some(e=>e.state===`downloading`);n&&!v.current&&(_.current=new RS),v.current=n;let r=m.filter(e=>e.state===`downloading`||e.state===`queued`).reduce((e,t)=>e+Math.max(0,t.bytes_total-t.bytes_done),0);return{estimates:t,overallEstimate:n&&F?_.current.update(F.bytes_done,F.bytes_done+r,e):void 0}},[m,F]);(0,J.useEffect)(()=>{let e=new Map(m.map(e=>[e.id,e.state])),n=Math.floor((F?.percent??0)/25),r=j.current;if(j.current={states:e,quarter:n},!r)return;let i=[];for(let e of m){if(r.states.get(e.id)===e.state)continue;let n=t[e.id]??e.id;e.state===`failed`?A(f(`setup.progress.announceFailed`,{name:n})):i.push(f(`setup.progress.announceState`,{name:n,state:f(bM[e.state])}))}n>r.quarter&&n>0&&n<4&&i.push(f(`setup.progress.announceOverall`,{n:String(n*25)})),i.length&&O(i.join(`. `))},[m,F?.percent,t,f]);let ee=e=>{if(!M)return N.current.delete(e),0;let t=Date.now(),n=N.current.get(e)??t;return N.current.set(e,n),Math.floor((t-n)/1e3)},R=xM(e),z=m.filter(e=>e.state===`cancelled`),B=F?.failed??m.filter(e=>e.state===`failed`).length,te=F?.percent??0,ne=()=>{(F?.bytes_done??0)>mM?S(!0):r?.()},re=f.compose(e=>[e(`setup.progress.overallPct`,{n:String(te)}),F&&F.bytes_total>0?e(`setup.progress.of`,{done:MS(F.bytes_done),total:MS(F.bytes_total)}):null,R&&L?.speed?PS(f.locale,NS(L.speed)):null,R?L?.eta==null?e(`setup.progress.estimating`):e(`setup.progress.left`,{eta:FS(L.eta,e)}):null,B>0?e(`setup.progress.failedCount`,{n:String(B)}):null].filter(Boolean).join(` · `));return V(`section`,{className:`dl${p?``:` is-paused`}`,"aria-labelledby":d,children:[V(`div`,{className:`dl-overall`,children:[P(`p`,{className:`dl-overall-line`,children:P(`bdi`,{children:re})}),P(`div`,{className:`dl-track is-overall${m.some(e=>e.state===`downloading`)?` is-live`:``}`,role:`progressbar`,"aria-label":f(`setup.progress.overallLabel`),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":te,"aria-valuetext":f(`setup.progress.percent`,{n:String(te)}),children:P(`span`,{className:`dl-fill`,style:{inlineSize:`${te}%`}})})]}),P(`ul`,{className:`dl-list`,children:m.map(e=>P(CM,{model:e,name:t[e.id]??e.id,estimate:I[e.id],now:y,freeGb:n,onRetry:E,onResume:R?void 0:a,onSkip:s,onRestart:c,busy:l,retryLater:u,checking:M,checkingFor:ee(e.id)},e.id))}),R&&P(`p`,{className:`setup-hint dl-controls`,children:f(`setup.progress.keepsGoing`)}),(R&&r||!R&&z.length>0&&o)&&V(Uj,{children:[R&&r&&P(`button`,{type:`button`,className:`btn-secondary`,onClick:ne,disabled:l,children:f(`setup.progress.cancel`)}),!R&&z.length>0&&o&&P(`button`,{type:`button`,className:`btn-primary`,onClick:o,disabled:l,children:f(`setup.progress.resumeAll`)})]}),P(`span`,{className:`visually-hidden`,"aria-live":`polite`,children:D}),P(`span`,{className:`visually-hidden`,role:`alert`,children:k}),x&&P(Wj,{title:f(`setup.progress.cancelTitle`),confirmLabel:f(`setup.progress.cancelConfirm`),cancelLabel:f(`setup.progress.cancelKeep`),onConfirm:()=>{S(!1),r?.()},onCancel:()=>S(!1),children:P(`p`,{children:f(`setup.progress.cancelBody`)})}),C&&P(Wj,{title:f(`setup.redownload.title`,{name:t[C.id]??C.id}),confirmLabel:f(`setup.redownload.confirm`),cancelLabel:f(`setup.redownload.keep`),onConfirm:()=>{let e=C;w(null),i?.(e.id,`verify`)},onCancel:()=>w(null),children:P(`p`,{children:f(`setup.redownload.body`,{name:t[C.id]??C.id,size:MS(C.bytes_total)})})})]})}var TM=[`check`,`download`,`test`],EM={root:`setup-report`,button:`btn-secondary setup-report-button`,hint:`setup-hint`,error:`setup-error`};function DM({run:e,before:t={}}){let n=T(),[r,i]=(0,J.useState)(()=>new Set),a=e=>i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),o=n=>[...t[n]??[],...e?.logs?.[n]??[]],s=TM.filter(e=>o(e).length>0);return V(`section`,{className:`setup-logs`,"aria-label":n(`setup.logs.title`),children:[s.map(e=>{let t=o(e),i=r.has(e);return V(`div`,{className:`setup-log`,children:[V(`button`,{type:`button`,className:`setup-log-toggle`,onClick:()=>a(e),"aria-expanded":i,children:[P(yr,{size:13,className:i?`is-open`:``,"aria-hidden":`true`}),` `,n(`setup.logs.${e}`)]}),i&&P(pM,{lines:t,className:`setup-log-pre`})]},e)}),P(tC,{classes:EM,note:n(`setup.logs.reportNote`)})]})}function OM(){let e=T(),t=k(e=>e.locale),n=k(e=>e.setLocale);return V(`label`,{className:`setup-language`,children:[P(Gi,{size:14,"aria-hidden":`true`}),P(`span`,{className:`visually-hidden`,children:e(`settings.language`)}),P(`select`,{value:t,onChange:e=>n(e.target.value),children:b.map(({meta:e})=>P(`option`,{value:e.code,lang:e.code,dir:e.dir,children:M(e)},e.code))})]})}var kM={driver:[`setup.npu.problem.driver`,`setup.npu.fix.driver`],device:[`setup.npu.problem.device`,`setup.npu.fix.device`],firmware:[`setup.npu.problem.firmware`,`setup.npu.fix.firmware`],access:[`setup.npu.problem.access`,`setup.npu.fix.access`],memlock:[`setup.npu.problem.memlock`,`setup.npu.fix.memlock`],runtime:[`setup.npu.problem.runtime`,`setup.npu.fix.runtime`]},AM={cancelled:`setup.npu.fixError.cancelled`,timeout:`setup.npu.fixError.timeout`,not_authorized:`setup.npu.fixError.notAuthorized`,no_pkexec:`setup.npu.fixError.noPkexec`};function jM({problem:e}){let t=T(),n=kM[e.code];if(!n)return V(`li`,{children:[P(`strong`,{children:e.title}),` `,e.fix]});let r=e.params,i=n[1];e.code===`access`&&r.group&&(i=`setup.npu.fix.accessGroup`);let a=n[0];return e.code===`memlock`&&r.fix===`restart`&&(a=`setup.npu.problem.memlockStill`,i=`setup.npu.fix.memlockRestart`),e.code===`memlock`&&r.fix===`stuck`&&(a=`setup.npu.problem.memlockStuck`,i=`setup.npu.fix.memlockStuck`),V(`li`,{children:[P(`strong`,{children:t(a,{device:r.device??``,limit:r.limit??``,version:r.version??``,detail:r.detail??``})}),` `,t(i,{group:r.group??``})]})}function MM({problems:e,disabled:t,onRecheck:n,id:r=`setup-npu-problems`}){let i=T(),[a,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(null),l=e.some(e=>e.code===`memlock`&&e.params.fix===`apply`),u=async(e,t)=>{o(!0),c(null);try{await e(),n?.()}catch(e){let n=e instanceof vn?e.body?.code:void 0,r=n&&n in AM?AM[n]:t;c(i(r))}finally{o(!1)}};return V(`div`,{className:`setup-npu-problems`,id:r,role:`note`,children:[P(`p`,{children:i(`setup.npu.notReady`)}),P(`ul`,{children:e.map(e=>P(jM,{problem:e},e.code))}),P(`p`,{className:`setup-hint`,children:i(`setup.npu.meanwhile`)}),s&&P(`p`,{className:`setup-npu-error`,role:`alert`,children:s}),V(`div`,{className:`setup-npu-actions`,children:[l&&P(`button`,{type:`button`,className:`btn-primary`,disabled:t||a,onClick:()=>void u(Ne,`setup.npu.fixError.failed`),children:i(`setup.npu.fixMemlock`)}),n&&P(`button`,{type:`button`,className:`btn-secondary`,disabled:t||a,onClick:()=>void u(lt,`setup.npu.recheckFailed`),children:i(`setup.npu.recheck`)})]})]})}async function NM(){let e=await be();e.reachable&&(e.available_backends??[]).some(e=>e.name===`vulkan`)&&(e.preferred_backend??e.default_backend)!==`vulkan`&&await Pe(`vulkan`)}function PM({plan:e,selection:t,onSelection:n,disabled:r=!1,onRecheck:i}){let a=T(),o=YA(e),s=e.npu?.present&&!e.npu.ready?e.npu.problems:[],c=s.length?void 0:o.find(e=>QA(e)&&e.gaia_model&&e.chat_choice&&e.fits!==!1)??o.find(e=>QA(e)&&e.chat_choice&&e.downloaded&&!$A(e)),l=!s.length&&!c&&o.some(e=>QA(e)&&e.fit_code===`npu`),u=!!o.find(e=>e.id===t.defaultChat&&QA(e)),d=mj(e).defaultChat,f=d&&!o.find(e=>e.id===d&&QA(e))?d:o.find(e=>e.chat_choice&&e.gaia_model&&e.support===`verified`&&!QA(e))?.id,p=e=>{e===`npu`&&c&&!u&&n(ij(t,o,c.id)),e===`gpu`&&u&&f&&n(ij(t,o,f))},m=[{id:`gpu`,label:a(`setup.backend.gpu`)},...c?[{id:`npu`,label:a(`setup.backend.npu`)}]:[],...s.length?[{id:`npu`,label:a(`setup.backend.npu`),unavailable:!0}]:[]],h=u?`npu`:`gpu`;return V(`section`,{className:`setup-backend`,"aria-labelledby":`setup-backend-title`,children:[P(`h3`,{className:`mc-job-title`,id:`setup-backend-title`,children:a(`setup.backend.title`)}),P(`div`,{className:`segmented`,role:`radiogroup`,"aria-labelledby":`setup-backend-title`,children:m.map(e=>P(`button`,{type:`button`,role:`radio`,"aria-checked":h===e.id,"aria-describedby":e.unavailable?`setup-npu-problems`:void 0,className:h===e.id?`is-active`:``,disabled:r||e.unavailable,onClick:()=>p(e.id),children:P(`bdi`,{children:e.label})},e.id))}),s.length>0?P(MM,{problems:s,disabled:r,onRecheck:i}):P(`p`,{className:`setup-hint`,children:a(c?`setup.backend.hint`:l?`setup.backend.hintNpuUnusable`:`setup.backend.hintNoNpu`)})]})}var FM=({children:e})=>P(`bdi`,{dir:`ltr`,children:e});function IM({label:e,children:t}){return V(`div`,{className:`found-row`,children:[P(`dt`,{children:e}),P(`dd`,{children:t})]})}function LM(e){return e.family?`${e.name} (${e.family})`:e.name}var RM=[[`llamacpp`,`llama.cpp`],[`flm`,`FastFlowLM`],[`whispercpp`,`whisper.cpp`],[`kokoro`,`Kokoro`],[`sd-cpp`,`stable-diffusion.cpp`]],zM=new Set([`llamacpp`,`flm`]);function BM(e){let t=[];for(let[n,r]of RM){let i=(e.backends??[]).find(e=>e.recipe===n&&e.default);i&&i.state!==`unsupported`&&t.push({name:r,b:i})}return t}function VM(e,t){return e?e.kind===`release_candidate`&&e.rc?`${e.version.replace(/rc\d+$/,``)} RC ${e.rc}`:e.kind===`source`&&e.commit?`${e.version} (${e.commit})`:e.version:t??null}var HM={release:`release`,release_candidate:`release candidate`,local:`local build`,source:`from source`};function UM(e,t){let n=e.system,r=e=>(n?.devices??[]).filter(t=>t.available&&e(t.kind)),i=r(e=>e.endsWith(`gpu`)),a=r(e=>e.endsWith(`npu`)),o=BM(e);return{sys:n,cpu:r(e=>e===`cpu`)[0],gpus:i,npus:a,runsOn:i[0]?.name??t?.gpu_name??null,npu:a[0]??null,runtimes:o,gaia:VM(n?.gaia_build,n?.gaia_version),build:n?.gaia_build?.kind??null,software:[VM(n?.gaia_build,n?.gaia_version)?`GAIA ${VM(n?.gaia_build,n?.gaia_version)}`:null,n?.lemonade_version?`Lemonade ${n.lemonade_version}`:null,...o.filter(({b:e})=>zM.has(e.recipe)&&GM(e)).map(({name:e,b:t})=>`${e} ${t.version??t.backend}`)].filter(e=>!!e),totalMemory:AS(n?.physical_memory,t?.ram_gb),freeGb:e.disk?.free_gb??t?.disk_free_gb??null,modelsPath:e.disk?.path??null,gaiaHome:n?.gaia_home??null}}var WM={installed:`installed`,update_required:`installed, updates on first use`},GM=e=>e.state===`installed`||e.state===`update_required`,KM={chat:`setup.job.chat`,vision:`setup.job.vision`,embedding:`setup.job.documents`,speech:`setup.job.speech`,voice:`setup.job.voice`,image_creation:`setup.job.images`};function qM(e,t){let n=UM(e,t),r=e.lemonade.mode===`external`?`the user's own`:`GAIA's own`;return[`GAIA: ${n.gaia??`unknown`}${n.build?`, ${HM[n.build]}`:``} (agent ${n.sys?.agent_version??`not installed yet`})`,`Model server: ${r} Lemonade ${n.sys?.lemonade_version??`(version not reported)`}${e.lemonade.url?` at ${e.lemonade.url}`:``}`,...n.runtimes.map(({name:e,b:t})=>`${e}: ${t.backend}${t.version?` ${t.version}`:``} (${WM[t.state??``]??`not installed`})`),`OS: ${n.sys?.os??t?.os??`unknown`}`,`Processor: ${n.cpu?.name??n.sys?.processor??`unknown`}${n.cpu?.cores?` (${n.cpu.cores} cores, ${n.cpu.threads??n.cpu.cores} threads)`:``}`,`Graphics: ${n.gpus.map(LM).join(`; `)||t?.gpu_name||`none found`}`,`NPU: ${n.npus.map(LM).join(`; `)||`none found`}`,`Memory: ${n.totalMemory??`unknown`}${e.capacity_gb==null?``:`, ${$(e.capacity_gb)} for models${e.memory_source?` (${e.memory_source})`:``}`}`,`Models folder: ${n.modelsPath??`unknown`}${n.freeGb==null?``:` (${$(n.freeGb)} free)`}`,`GAIA data and logs: ${n.gaiaHome??`unknown`}`].join(`
|
|
80
80
|
`)}function JM({plan:e,hardware:t,onChangeMemory:n}){let r=T(),i=UM(e,t),[a,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(null),[l,u]=(0,J.useState)(null),d=async e=>{u(null);try{await En(e,!1)}catch(e){u(r(`setup.found.openFailed`,{error:e instanceof Error?e.message:String(e)}))}},f=P(`span`,{className:`found-muted`,children:r(`setup.found.unknown`)}),p=[...t?.blockers??[],...(t?.warnings??[]).filter(e=>t?.lemonade_running||!/\bNPU\b/.test(e))],m=(0,J.useRef)(null);(0,J.useEffect)(()=>()=>{m.current&&clearTimeout(m.current)},[]);let h=e=>{c(e),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>c(null),2e3)};return V(`section`,{className:`setup-card found`,"aria-label":r(`setup.found.title`),children:[V(`div`,{className:`found-head`,children:[P(`h3`,{className:`mc-job-title`,children:r(`setup.found.title`)}),P(`button`,{type:`button`,className:`found-copy`,onClick:()=>{navigator.clipboard.writeText(qM(e,t)).then(()=>h(`done`),e=>{console.warn(`[DetectedSummary] could not copy the details`,e),h(`failed`)})},"aria-label":r(`setup.found.copy`),title:r(`setup.found.copy`),children:P(s===`done`?pr:zr,{size:14,"aria-hidden":`true`})}),s&&P(`span`,{className:`found-copied`,role:`status`,children:r(s===`done`?`setup.found.copied`:`setup.found.copyFailed`)})]}),V(`dl`,{className:`found-glance`,children:[V(IM,{label:r(`setup.found.runsOn`),children:[i.runsOn?P(FM,{children:i.runsOn}):f,i.npu&&P(`span`,{className:`found-chip`,children:P(FM,{children:`NPU`})})]}),V(IM,{label:r(`setup.found.memory`),children:[e.capacity_gb!=null&&i.totalMemory?r(`setup.found.memoryOf`,{size:$(e.capacity_gb),total:i.totalMemory}):e.capacity_gb==null?i.totalMemory?P(FM,{children:i.totalMemory}):f:P(FM,{children:$(e.capacity_gb)}),n&&P(`button`,{type:`button`,className:`link-btn found-link`,onClick:n,children:r(`setup.found.changeMemory`)})]}),P(IM,{label:r(`setup.found.space`),children:i.freeGb==null?f:P(FM,{children:$(i.freeGb)})}),V(IM,{label:r(`setup.found.software`),children:[i.software.length?P(FM,{children:i.software.join(` · `)}):f,i.build&&i.build!==`release`&&P(`span`,{className:`found-chip`,children:r(`setup.found.build.${i.build}`)})]})]}),V(`div`,{className:`found-paths`,children:[[[`setup.found.modelsFolder`,i.modelsPath],[`setup.found.gaiaFolder`,i.gaiaHome]].map(([e,t])=>t&&V(`button`,{type:`button`,className:`link-btn found-open`,onClick:()=>void d(t),title:t,children:[P(yi,{size:13,"aria-hidden":`true`}),` `,r(e)]},e)),l&&P(`p`,{className:`setup-error`,role:`alert`,children:l})]}),p.length>0&&V(`details`,{className:`dl-details found-warnings`,children:[V(`summary`,{children:[P(Cr,{size:13,"aria-hidden":`true`}),` `,r(`setup.found.noticed`)]}),P(`ul`,{children:p.map(e=>P(`li`,{children:P(FM,{children:e})},e))})]}),V(`button`,{type:`button`,className:`setup-log-toggle found-more`,onClick:()=>o(e=>!e),"aria-expanded":a,children:[P(yr,{size:13,className:a?`is-open`:``,"aria-hidden":`true`}),` `,r(`setup.found.details`)]}),a&&V(`div`,{className:`found-details`,children:[P(`h4`,{className:`found-group`,children:r(`setup.found.software`)}),V(`dl`,{className:`found-list`,children:[V(IM,{label:P(FM,{children:`GAIA`}),children:[i.gaia?P(FM,{children:i.gaia}):f,i.build&&i.build!==`release`&&P(`span`,{className:`found-chip`,children:r(`setup.found.build.${i.build}`)})]}),P(IM,{label:r(`setup.found.agent`),children:i.sys?.agent_version?P(FM,{children:i.sys.agent_version}):P(`span`,{className:`found-muted`,children:r(`setup.found.agentLater`)})}),V(IM,{label:r(`setup.found.server`),children:[e.lemonade.mode===`external`?r(`setup.found.serverYours`):r(`setup.found.serverOwn`),i.sys?.lemonade_version&&V(D.Fragment,{children:[` `,P(FM,{children:i.sys.lemonade_version})]}),e.lemonade.url&&P(`span`,{className:`found-sub`,children:P(FM,{children:e.lemonade.url})})]})]}),P(`h4`,{className:`found-group`,children:r(`setup.found.runtime`)}),i.runtimes.length?P(`div`,{className:`found-table-wrap`,children:V(`table`,{className:`found-table`,children:[P(`thead`,{className:`visually-hidden`,children:V(`tr`,{children:[P(`th`,{scope:`col`,children:r(`setup.found.col.runtime`)}),P(`th`,{scope:`col`,children:r(`setup.found.col.device`)}),P(`th`,{scope:`col`,children:r(`setup.found.col.version`)}),P(`th`,{scope:`col`,children:r(`setup.found.col.state`)})]})}),P(`tbody`,{children:i.runtimes.map(({name:e,b:t})=>V(`tr`,{children:[P(`th`,{scope:`row`,children:P(FM,{children:e})}),P(`td`,{children:P(FM,{children:t.backend})}),P(`td`,{children:P(FM,{children:t.version??``})}),P(`td`,{className:GM(t)?`is-installed`:void 0,children:r(GM(t)?`setup.pc.backend.installed`:`setup.pc.backend.available`)})]},t.recipe))})]})}):P(`p`,{className:`found-muted`,children:r(`setup.found.unknown`)}),P(`h4`,{className:`found-group`,children:r(`setup.found.models`)}),(e.catalog??[]).length?P(`div`,{className:`found-table-wrap`,children:V(`table`,{className:`found-table`,children:[P(`thead`,{className:`visually-hidden`,children:V(`tr`,{children:[P(`th`,{scope:`col`,children:r(`setup.found.col.model`)}),P(`th`,{scope:`col`,children:r(`setup.found.col.job`)}),P(`th`,{scope:`col`,children:r(`setup.found.col.tested`)}),P(`th`,{scope:`col`,children:r(`setup.found.col.size`)}),P(`th`,{scope:`col`,children:r(`setup.found.col.state`)})]})}),P(`tbody`,{children:(e.catalog??[]).map(e=>V(`tr`,{children:[P(`th`,{scope:`row`,title:e.id,children:P(`bdi`,{children:e.name})}),P(`td`,{children:e.roles.map(e=>r(KM[e])).join(` · `)}),V(`td`,{children:[e.support===`verified`&&P(`span`,{className:`mc-chip is-verified`,children:r(`setup.label.verified`)}),e.support===`untested`&&P(`span`,{className:`mc-chip is-untested`,children:r(`setup.label.untested`)})]}),P(`td`,{children:P(FM,{children:e.full_size_gb??e.size_gb?$(e.full_size_gb??e.size_gb):``})}),P(`td`,{className:e.downloaded?`is-installed`:void 0,children:r(e.downloaded?`setup.models.status.onPc`:`setup.found.notDownloaded`)})]},e.id))})]})}):P(`p`,{className:`found-muted`,children:r(`setup.found.unknown`)}),P(`h4`,{className:`found-group`,children:r(`setup.found.hardware`)}),V(`dl`,{className:`found-list`,children:[P(IM,{label:r(`setup.found.os`),children:i.sys?.os??t?.os?P(FM,{children:i.sys?.os??t?.os}):f}),V(IM,{label:r(`setup.found.cpu`),children:[i.cpu||i.sys?.processor?P(FM,{children:i.cpu?.name??i.sys?.processor}):f,i.cpu?.cores?P(`span`,{className:`found-sub`,children:r(`setup.found.cores`,{cores:String(i.cpu.cores),threads:String(i.cpu.threads??i.cpu.cores)})}):null]}),P(IM,{label:r(`setup.found.gpu`),children:i.gpus.length?P(FM,{children:i.gpus.map(LM).join(`; `)}):P(`span`,{className:`found-muted`,children:r(`setup.found.none`)})}),P(IM,{label:r(`setup.found.npu`),children:i.npus.length?P(FM,{children:i.npus.map(LM).join(`; `)}):P(`span`,{className:`found-muted`,children:r(`setup.found.none`)})})]})]})]})}function YM({state:e}){return e===`done`?P(pr,{size:13,"aria-hidden":`true`}):e===`active`?P(K,{size:13,className:`spin`,"aria-hidden":`true`}):P(e===`failed`?So:e===`question`?kr:jr,{size:13,"aria-hidden":`true`})}function XM({hardware:e,hardwareError:t,plan:n,serverRun:r,awaitingChoice:i=!1}){let a=T(),[o,s]=(0,J.useState)(!1),c=!!n?.lemonade.reachable,l=r?.state===`failed`||r?.state===`cancelled`,u=a(n?.lemonade.mode===`external`?`setup.found.serverYours`:`setup.found.serverOwn`),d=n?.system?.lemonade_version?a(`setup.checks.serverFound`,{version:n.system.lemonade_version,whose:u}):u,f=e?`done`:t?`failed`:`active`,p=[e?.gpu_name,e?.npu_detected?a(`setup.checks.npu`):null].filter(Boolean).join(` · `),m=t?null:n?.capacity_gb==null?c?AS(n?.system?.physical_memory,e?.ram_gb):null:$(n.capacity_gb),h=t?`failed`:m?`done`:l?`failed`:i?`waiting`:`active`,g=[{id:`device`,label:a(`setup.checks.device`),value:t?`${a(`setup.system.unread`)} ${t}`:p||null,state:f},{id:`memory`,label:a(`setup.found.memory`),value:m,state:h},{id:`disk`,label:a(`setup.checks.disk`),value:e?.disk_free_gb==null?null:a(`setup.checks.diskValue`,{size:PS(a.locale,`${Math.round(e.disk_free_gb)} GB`)}),state:f},{id:`server`,label:a(`setup.checks.server`),value:c?d:i?a(`setup.checks.serverChoose`):null,state:c?`done`:l?`failed`:i?`question`:e?`active`:`waiting`},{id:`models`,label:a(`setup.checks.backends`),value:c&&n?.catalog?a(`setup.checks.backendsValue`,{models:String(n.catalog.length),downloaded:String(n.catalog.filter(e=>e.downloaded).length)}):null,state:c&&n?.catalog?`done`:c?`active`:`waiting`}],_=g.filter(e=>e.state===`done`).length,v=Math.round(_/g.length*100),y=P(`ul`,{className:`setup-rows`,id:`setup-check-rows`,children:g.map(e=>V(`li`,{className:`setup-result is-${e.state}`,children:[P(YM,{state:e.state}),P(`span`,{className:`setup-result-label`,children:e.label}),e.value&&P(`bdi`,{className:`setup-result-value`,children:e.value})]},e.id))});return _===g.length?V(`section`,{className:`setup-card setup-checks-done`,"aria-label":a(`setup.check.title`),children:[P(`p`,{className:`setup-result is-done`,role:`status`,children:V(`button`,{type:`button`,className:`setup-checks-toggle`,"aria-expanded":o,"aria-controls":`setup-check-rows`,onClick:()=>s(e=>!e),children:[P(pr,{size:13,"aria-hidden":`true`}),P(`span`,{className:`setup-result-label`,children:a(`setup.checks.allPassed`,{n:String(g.length)})}),P(yr,{size:13,className:o?`is-open`:``,"aria-hidden":`true`})]})}),o&&y]}):V(`section`,{className:`setup-card`,"aria-label":a(`setup.check.title`),children:[V(`div`,{className:`setup-bar-head`,children:[P(`span`,{children:a(`setup.checks.count`,{done:String(_),total:String(g.length)})}),V(`bdi`,{dir:`ltr`,children:[v,`%`]})]}),P(`progress`,{className:`setup-progress`,max:100,value:v,"aria-label":a(`setup.check.title`)}),y]})}function ZM({steps:e}){let t=T();return V(`nav`,{className:`setup-rail`,"aria-label":t(`setup.rail.label`),children:[P(`p`,{className:`setup-rail-title`,children:t(`setup.title`)}),P(`ol`,{className:`setup-rail-list`,children:e.map((e,t)=>{let n=e.status===`done`?P(pr,{size:13,"aria-hidden":`true`}):e.status===`active`?P(K,{size:13,className:`spin`,"aria-hidden":`true`}):e.status===`failed`?P(Cr,{size:13,"aria-hidden":`true`}):t+1,r=V(D.Fragment,{children:[P(`span`,{className:`setup-rail-num`,children:n}),P(`span`,{children:e.label})]}),i=`setup-rail-step is-${e.status}${e.shown?` is-shown`:``}`,a=e.shown?`step`:void 0;return P(`li`,{children:e.onOpen?P(`button`,{type:`button`,className:i,onClick:e.onOpen,children:r}):P(`span`,{className:i,"aria-current":a,children:r})},e.id)})})]})}var QM={memory:`setup.test.why.memory`,broken:`setup.test.why.broken`,stuck:`setup.test.why.stuck`,missing:`setup.test.why.missing`,agent:`setup.test.why.agent`,answer:`setup.test.why.answer`,window:`setup.test.why.window`};function $M(e,t){return t(`setup.test.job.${e}`)}function eN({state:e}){return e===`passed`?P(pr,{size:13,"aria-hidden":`true`}):e===`running`?P(K,{size:13,className:`spin`,"aria-hidden":`true`}):P(e===`failed`?So:e===`skipped`?ua:jr,{size:13,"aria-hidden":`true`})}function tN(e,t){return e.state===`running`?t(`setup.test.running`):e.state===`failed`?t(`setup.test.failed`):e.state===`skipped`?t(`setup.test.skipped`):e.seconds==null?t(`setup.test.passed`):t(`setup.test.passedIn`,{seconds:String(Math.round(e.seconds))})}function nN({run:e,expected:t,names:n,catalog:r,onRetry:i,onChooseAnother:a,onCancel:o,onDownloadAgain:s,busy:c}){let l=T(),u=e.tests??[],d=new Set(u.map(e=>e.job)),f=t.filter(e=>!d.has(e)),p=u.filter(e=>e.state!==`running`).length,m=Math.max(u.length+f.length,1),h=Math.round(p/m*100),g=u.filter(e=>e.state===`failed`).filter(e=>!r.find(t=>t.id===e.subject)?.roles.some(e=>[`speech`,`voice`,`image_creation`].includes(e))),_=e.state===`failed`||e.state===`cancelled`,v=s?[...new Set(g.filter(e=>e.kind===`broken`&&e.subject).map(e=>e.subject))]:[],[y,b]=(0,J.useState)(null),x=r.find(e=>e.id===y)?.full_size_gb,S=_&&e.components?.agent===`failed`,C=g.some(e=>e.subject&&e.kind!==`missing`);return V(D.Fragment,{children:[V(`section`,{className:`setup-card`,"aria-label":l(`setup.test.title`),children:[V(`div`,{className:`setup-bar-head`,children:[P(`span`,{children:l(`setup.test.count`,{done:String(p),total:String(m)})}),V(`bdi`,{dir:`ltr`,children:[h,`%`]})]}),P(`progress`,{className:`setup-progress`,max:100,value:h,"aria-label":l(`setup.test.title`)}),V(`ul`,{className:`setup-rows`,children:[u.map(e=>V(`li`,{className:`setup-result is-${e.state}`,children:[P(eN,{state:e.state}),V(`span`,{className:`setup-result-label`,children:[$M(e.job,l),e.subject&&V(`bdi`,{className:`setup-result-model`,children:[` `,n[e.subject]??e.subject]})]}),P(`span`,{className:`setup-result-value`,children:tN(e,l)}),e.error&&V(`div`,{className:`setup-result-error`,children:[P(`p`,{children:l(e.kind===`broken`&&!s?`setup.test.why.brokenYours`:QM[e.kind??``]??`setup.test.why.other`)}),V(`details`,{className:`dl-details`,children:[P(`summary`,{children:l(`setup.progress.details`)}),P(`pre`,{dir:`ltr`,children:e.error})]})]})]},`${e.job}:${e.subject??``}`)),f.map(e=>e===`agent`&&S?V(`li`,{className:`setup-result is-failed`,children:[P(eN,{state:`failed`}),P(`span`,{className:`setup-result-label`,children:$M(e,l)}),P(`span`,{className:`setup-result-value`,children:l(`setup.test.failed`)}),P(`div`,{className:`setup-result-error`,children:P(`p`,{children:l(`setup.test.why.hub`)})})]},e):V(`li`,{className:`setup-result is-waiting`,children:[P(eN,{state:`waiting`}),P(`span`,{className:`setup-result-label`,children:$M(e,l)}),P(`span`,{className:`setup-result-value`,children:l(`setup.test.waiting`)})]},e))]})]}),e.state===`verifying`&&o&&P(Uj,{children:P(`button`,{type:`button`,className:`btn-secondary`,onClick:o,disabled:c,children:l(`setup.progress.cancel`)})}),_&&V(`div`,{className:`setup-failure`,role:`alert`,children:[P(`p`,{children:e.state===`cancelled`?l(`setup.test.cancelled`):g.some(e=>e.kind===`memory`)?l(`setup.test.failedMemory`):l(`setup.test.failedHelp`)}),V(Uj,{children:[C&&a&&P(`button`,{type:`button`,className:`btn-secondary`,onClick:a,disabled:c,children:l(`setup.test.chooseAnother`)}),P(`button`,{type:`button`,className:v.length?`btn-secondary`:`btn-primary`,onClick:i,disabled:c,children:l(`setup.test.tryAgain`)}),v.map(e=>P(`button`,{type:`button`,className:`btn-primary setup-wrap-btn`,onClick:()=>b(e),disabled:c,children:v.length===1?l(`setup.test.downloadItAgain`):l(`setup.test.downloadAgain`,{name:n[e]??e})},e))]})]}),y&&P(Wj,{title:l(`setup.redownload.title`,{name:n[y]??y}),confirmLabel:l(`setup.redownload.confirm`),cancelLabel:l(`setup.redownload.keep`),onConfirm:()=>{let e=y;b(null),s?.(e)},onCancel:()=>b(null),children:P(`p`,{children:l(`setup.redownload.body`,{name:n[y]??y,size:x==null?``:$(x)})})})]})}var rN=`https://app.fireworks.ai/settings/users/api-keys`,iN=`https://amd-gaia.ai/docs/guides/llm-gateway`,aN=[{id:`local`,title:`setup.where.local`,note:`setup.where.localNote`},{id:`fireworks`,title:`Fireworks AI`,note:`setup.where.fireworksNote`},{id:`amd`,title:`AMD LLM Gateway`,note:`setup.where.amdNote`}];function oN(e,t){return N(e.title)?t(e.title):e.title}var sN=1e3,cN=`gaia-setup-choice`;function lN(){try{let e=localStorage.getItem(cN);return e===`local`||e===`fireworks`||e===`amd`?e:null}catch(e){return console.warn(`[SetupScreen] could not read the saved provider choice`,e),null}}function uN(e){try{localStorage.setItem(cN,e)}catch(e){console.warn(`[SetupScreen] could not save the provider choice; a reload will ask again`,e)}}var dN=[`ok`,`needs_key`,`too_old`];function fN({onChosen:e,onNothingToOffer:t,onFound:n,canInstallOwn:r=!0}){let i=T(),[a,o]=(0,J.useState)(null),[s,c]=(0,J.useState)(null),[l,u]=(0,J.useState)([]),[d,f]=(0,J.useState)(!1),[p,m]=(0,J.useState)(``),[h,g]=(0,J.useState)(!1),[_,v]=(0,J.useState)(!1),[y,b]=(0,J.useState)(null),[x,S]=(0,J.useState)(null),[C,w]=(0,J.useState)(null),E=(0,J.useRef)(!0),O=(0,J.useCallback)(async()=>{c(null);try{let e=await ce();if(!e.offer){t?.();return}f(!0);let{found:r,unchecked:i=[]}=await et();if(!E.current)return;u(r?[]:i),r&&dN.includes(r.status)?(o({target:e,found:r}),n?.(r),g(r.status===`needs_key`),r.status===`too_old`&&t?.()):i.length===0&&t?.()}catch(e){E.current&&c(e instanceof Error?e.message:String(e))}finally{E.current&&f(!1)}},[t,n]);(0,J.useEffect)(()=>(E.current=!0,O(),()=>{E.current=!1}),[O]);let k=(0,J.useCallback)(async t=>{if(a){b(t),S(null);try{await Ee(t===`external`?{mode:t,base_url:a.found.url,api_key:p.trim()||void 0}:{mode:t}),m(``),w(t),e(t)}catch(e){VA(e)&&g(!0),S(e instanceof Error?e.message:String(e))}finally{b(null)}}},[a,p,e]);if(s||l.length>0)return V(D.Fragment,{children:[P(`p`,{className:`setup-hint`,children:s?i(`setup.offer.checkFailed`):i(`setup.offer.noAnswer`,{url:l.join(`, `)})}),s&&V(`details`,{className:`dl-details`,children:[P(`summary`,{children:i(`setup.progress.details`)}),P(`pre`,{dir:`ltr`,children:s})]}),V(Uj,{children:[V(`button`,{type:`button`,className:`btn-secondary`,disabled:d,onClick:()=>void O(),children:[d&&P(K,{size:13,className:`spin`}),` `,i(`setup.offer.checkAgain`)]}),t&&r&&P(`button`,{type:`button`,className:`btn-primary`,disabled:d,onClick:t,children:i(`setup.offer.useOwn`)})]})]});if(!a)return d?V(`p`,{className:`setup-hint`,role:`status`,children:[P(K,{size:13,className:`spin`,"aria-hidden":`true`}),` `,i(`setup.offer.looking`)]}):null;let{target:A,found:j}=a;return C?P(`p`,{className:`setup-hint`,role:`status`,children:C===`external`?i(`setup.offer.usingYours`,{url:j.url}):i(`setup.offer.usingOwn`)}):j.status===`too_old`?V(`p`,{className:`setup-hint`,role:`status`,children:[i(`setup.offer.tooOld`),` `,V(`bdi`,{dir:`ltr`,className:`setup-choice-note`,children:[`Lemonade `,j.version??``,` · `,j.url]})]}):V(`form`,{id:`setup-lemonade-form`,className:`setup-lemonade`,"aria-label":i(`setup.offer.label`),onSubmit:e=>{e.preventDefault(),k(`external`)},children:[P(`span`,{className:`setup-choice-title`,children:i(`setup.offer.title`)}),P(`span`,{className:`setup-choice-note`,children:V(`bdi`,{dir:`ltr`,children:[`Lemonade`,j.version?` ${j.version}`:``,` · `,j.url]})}),V(`button`,{type:`button`,className:`setup-log-toggle setup-offer-more`,onClick:()=>v(e=>!e),"aria-expanded":_,"aria-controls":`setup-offer-detail`,children:[P(yr,{size:13,className:_?`is-open`:``,"aria-hidden":`true`}),` `,i(`setup.offer.whatGaiaDoes`)]}),_&&P(`p`,{className:`setup-choice-note`,id:`setup-offer-detail`,children:i(`setup.offer.whatGaiaDoesText`)}),h&&P(`input`,{className:`settings-input`,type:`password`,autoComplete:`off`,value:p,onChange:e=>m(e.target.value),placeholder:i(`setup.offer.keyPlaceholder`),"aria-label":i(`setup.offer.keyLabel`)}),x&&(h?P(`p`,{className:`setup-error`,role:`alert`,children:i(`setup.offer.keyRejected`)}):P(mN,{text:x})),V(Uj,{children:[V(`button`,{type:`submit`,form:`setup-lemonade-form`,className:`btn-secondary`,disabled:!!y||h&&!p.trim(),children:[y===`external`&&P(K,{size:13,className:`spin`}),` `,i(`setup.offer.useMine`)]}),V(`button`,{type:`button`,className:`btn-primary`,disabled:!!y,onClick:()=>void k(`gaia`),children:[y===`gaia`&&P(K,{size:13,className:`spin`}),` `,i(`setup.offer.useOwn`)]})]})]})}function pN({problem:e,onRetry:t,onUseGaia:n}){let r=T(),i=e.kind===`server_too_old`&&e.use_gaia;return V(D.Fragment,{children:[e.start&&V(`details`,{className:`dl-details`,children:[P(`summary`,{children:r(`setup.server.howToStart`)}),P(`pre`,{dir:`ltr`,children:e.start})]}),V(Uj,{children:[P(`button`,{type:`button`,className:i?`btn-secondary`:`btn-primary`,onClick:t,children:r(`setup.tryAgain`)}),e.use_gaia&&P(`button`,{type:`button`,className:i?`btn-primary`:`btn-secondary`,onClick:n,children:r(`setup.server.useGaia`)})]}),e.use_gaia&&P(`p`,{className:`setup-hint`,children:r(`setup.server.useGaiaNote`)}),e.use_gaia&&e.env_url&&P(`p`,{className:`setup-hint`,children:r(`setup.server.envIgnoredNote`,{url:e.env_url})})]})}function mN({text:e}){let t=T();return V(`div`,{className:`setup-error`,role:`alert`,children:[P(`p`,{children:t(`setup.failedLead`)}),V(`details`,{className:`dl-details`,children:[P(`summary`,{children:t(`setup.progress.details`)}),P(`pre`,{dir:`ltr`,children:e})]})]})}function hN({run:e}){let t=T();return e.problem?V(`div`,{className:`setup-error`,role:`alert`,children:[P(`p`,{children:t(e.problem.kind===`server_too_old`?`setup.server.tooOld`:`setup.server.unreachable`)}),V(`details`,{className:`dl-details`,children:[P(`summary`,{children:t(`setup.progress.details`)}),P(`pre`,{dir:`ltr`,children:e.problem.message})]})]}):V(`div`,{className:`setup-error`,role:`alert`,children:[P(`p`,{children:t(e.components?.server===`failed`?`setup.server.ownFailed`:`setup.stopped`)}),e.error&&V(`details`,{className:`dl-details`,children:[P(`summary`,{children:t(`setup.progress.details`)}),P(`pre`,{dir:`ltr`,children:e.error})]})]})}var gN=[`check`,`plan`,`key`,`models`,`gpu`,`download`,`test`,`ready`];function _N(e){return e instanceof Error?e.message:String(e)}function vN({onReady:e,onClose:t}){let n=T(),r=cs(e=>e.refresh),i=cs(e=>e.select),[a,o]=(0,J.useState)(`local`),[s,c]=(0,J.useState)(`check`),[l,u]=(0,J.useState)(!1),[d,f]=(0,J.useState)(`models`),[p,m]=(0,J.useState)(null),[h,g]=(0,J.useState)(null),[_,v]=(0,J.useState)(()=>new Set([`check`])),y=(0,J.useRef)(`check`),[b,x]=(0,J.useState)(null),[S,C]=(0,J.useState)(null),[w,E]=(0,J.useState)(null),[O,k]=(0,J.useState)(null),[A,j]=(0,J.useState)(null),[M,N]=(0,J.useState)(``),[F,I]=(0,J.useState)({busy:!1,error:null,done:!1}),[L,ee]=(0,J.useState)(null),[R,z]=(0,J.useState)(null),[B,te]=(0,J.useState)(null),[ne,re]=(0,J.useState)(null),[ie,ae]=(0,J.useState)(null),[oe,H]=(0,J.useState)(null),[U,se]=(0,J.useState)(!1),[W,G]=(0,J.useState)(null),[ue,de]=(0,J.useState)(!1),[fe,pe]=(0,J.useState)(!1),[me,he]=(0,J.useState)(null),[ge,_e]=(0,J.useState)(!1),[ye,be]=(0,J.useState)(null),[xe,Se]=(0,J.useState)([]),[we,Te]=(0,J.useState)([]),[Ee,De]=(0,J.useState)([]),[ke,Ae]=(0,J.useState)(!1),[Me,Ne]=(0,J.useState)(!1),Pe=(0,J.useRef)({gaiaLemonade:!1,options:{}}),Fe=(0,J.useRef)(null),Le=(0,J.useRef)(!1),Re=(0,J.useRef)(!1),[ze,Be]=(0,J.useState)(!1),[Ve,He]=(0,J.useState)(!1),Ue=(0,J.useCallback)(()=>He(!0),[]),[We,Ge]=(0,J.useState)(null),[Ke,qe]=(0,J.useState)(null),Je=(0,J.useRef)(!0);(0,J.useEffect)(()=>(Je.current=!0,()=>{Je.current=!1}),[]);let{network:Ye,providers:Ze,recheck:Qe}=sM(),$e=Ze.find(e=>e.id===a&&e.key_source===`environment`&&e.key_hint),et=e=>e===`amd`&&Ye?.reachable===!1,tt=a!==`local`,nt=w?.server_only?w:null,it=w&&!w.server_only?w:null,at=w?.state===`running`||w?.state===`verifying`,st=it?.state===`ready`,ct=xM(w),lt=!(it?.models??[]).some(e=>e.state===`downloading`||e.state===`queued`)&&((it?.tests?.length??0)>0||it?.state===`verifying`),ut=(0,J.useCallback)(()=>{C(null),le().then(x).catch(e=>C(_N(e)))},[]),dt=(0,J.useRef)(0),pt=(0,J.useCallback)(async()=>{let e=++dt.current;z(null);try{let t=await ot();return e===dt.current?(ee(t),t):null}catch(t){return e===dt.current&&z(_N(t)),null}},[]),mt=(0,J.useCallback)(async()=>{try{let e=await Xe();Je.current&&H(e??null)}catch(e){console.warn(`[SetupScreen] GPU memory could not be read; the step stays hidden`,e)}},[]),gt=t!=null;(0,J.useEffect)(()=>{ce().then(e=>Ae(e.source===`config`)).catch(e=>console.warn(`[SetupScreen] could not read which Lemonade GAIA uses`,e)),ut(),pt(),Ce().then(e=>{(e.state!==`idle`||e.models?.length)&&(gt&&e.state!==`running`&&e.state!==`verifying`||(E(e),e.server_only||c(`download`),e.skip_chat_model&&o(lN()===`amd`?`amd`:`fireworks`)))}).catch(e=>j(_N(e))).finally(()=>Be(!0))},[ut,pt,gt]),(0,J.useEffect)(()=>{L?.catalog&&L.lemonade.reachable&&(te(e=>e??uj(L)),mt(),!w&&L.catalog.some(e=>e.partial&&e.selected)&&_e(!0))},[L,mt,w]);let _t=(0,J.useCallback)(()=>{Fe.current&&clearInterval(Fe.current),Fe.current=null},[]),vt=(w?.models??[]).filter(e=>e.state===`failed`&&e.error_kind===`disk_full`).length;(0,J.useEffect)(()=>{vt>0&&pt()},[vt,pt]);let yt=(0,J.useCallback)(async()=>{try{let e=await Ce();if(k(null),e.state===`idle`&&!e.models?.length){E(null),c(`plan`),Ne(!0),pt();return}E(e)}catch(e){k(_N(e))}},[pt,n]);(0,J.useEffect)(()=>(!ct&&!O||(Fe.current=setInterval(()=>{yt()},sN)),_t),[ct,O,yt,_t]),(0,J.useEffect)(()=>{nt&&nt.state===`ready`&&(ut(),pt())},[nt,nt?.state,ut,pt]),(0,J.useEffect)(()=>{st&&(ut(),pt().then(e=>{e&&ae(e)}),mt())},[st,ut,pt,mt]);let bt=(0,J.useRef)(!1),xt=(0,J.useCallback)(async(e=!1,t={})=>{if(bt.current)return!1;bt.current=!0,j(null),he(null),_e(!1),Ne(!1);try{uN(a),Pe.current={gaiaLemonade:e,options:t};let n=await ft(tt,e,t);E(n),g(null);let r=t.extraModels??[];return r.length&&De(e=>e.filter(e=>!r.includes(e))),t.serverOnly||c(`download`),e&&Ae(!1),!0}catch(e){let t=Oe(e);if(t)return G({kind:`server`,detail:t,then:`run`}),!1;if(e instanceof vn&&e.httpStatus===409){let e=await Ce().catch(()=>null);if(e&&(e.state===`running`||e.state===`verifying`))return E(e),g(null),e.server_only||c(`download`),!0}return j(_N(e)),!1}finally{bt.current=!1}},[a,tt]);(0,J.useEffect)(()=>{s===`check`&&ze&&Ve&&L&&!L.lemonade.reachable&&!w&&!Le.current&&(Le.current=!0,xt(!1,{serverOnly:!0}))},[s,ze,Ve,L,w,xt]);let St=!!(B&&L?.catalog&&L.lemonade.reachable&&(b||S)),Ct=(0,J.useCallback)(()=>{let{gaiaLemonade:e,options:t}=Pe.current;xt(e,t)},[xt]),wt=(0,J.useCallback)((e,t=L)=>{re(t);let n=t&&B&&!tt?bj(t,B):[];return xt(!1,{acknowledgeLowDisk:e,keepTrying:U,extraModels:n})},[L,B,tt,U,xt]),[Tt,Et]=(0,J.useState)(!1),Dt=(0,J.useRef)(!1),Ot=(0,J.useCallback)(async(e,t=ue)=>{if(!L||!B||Dt.current)return;he(null),Et(e);let r=YA(L),i=tt?[]:vj(r,B).filter(e=>!e.downloaded||e.id===B.defaultChat),a=i.find($A);if(a){let e=a.id===B.defaultChat?`setup.models.cantRun.chat`:`setup.models.cantRun.other`;he(n(e,{name:a.name,why:Oj(a,n)}))}else if(!tt&&!t&&i.length>0&&i.every(e=>e.need_gb!=null))G({kind:`no_fit`,models:i});else{pe(!0),Dt.current=!0;try{let n=L;if(!tt&&B.defaultChat&&B.defaultChat!==n.chat_model.id)try{n=await Wt(B.defaultChat,t)}catch(e){let t=Oe(e);if(t){G({kind:`server`,detail:t,then:`chat`});return}throw e}if(!tt){await NM();let e=oj(r,B);e!==(n.vision_model??null)&&(n=await Ie(e));for(let e of yj(n,B))n=await ht(e.id,e.skipped)}ee(n),await wt(e,n)}catch(e){he(_N(e))}finally{Dt.current=!1,pe(!1)}}},[L,B,tt,ue,wt,n]),kt=(0,J.useCallback)(e=>{he(null),s===`download`?g(e===y.current?null:e):(g(null),c(e===`test`||e===`ready`?`download`:e))},[s]),At=(0,J.useCallback)(()=>{h??o(`local`),kt(`plan`)},[kt,h]),jt=(0,J.useCallback)(()=>{at&&h!=null||(o(`local`),u(!0),kt(`models`))},[kt,at,h]),Mt=(0,J.useCallback)(()=>{at&&h!=null||(u(!1),o(lN()===`amd`?`amd`:`fireworks`),kt(`key`))},[kt,at,h]),Nt=!!oe?.applies,Pt=(0,J.useCallback)(()=>{kt((h??s)===`gpu`?d:`plan`)},[d,kt,h,s]),Ft=(0,J.useCallback)(e=>{f(e),kt(`gpu`)},[kt]),It=(0,J.useRef)({prev:null,next:null});(0,J.useEffect)(()=>{let e=e=>{if(!e.altKey||W||(e.target instanceof Element?e.target:null)?.closest(`input, textarea, select, [contenteditable="true"]`))return;let t=e.key===`ArrowLeft`?It.current.prev:e.key===`ArrowRight`?It.current.next:null;t&&(e.preventDefault(),kt(t))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[kt,W]);let Lt=(0,J.useCallback)(async()=>{try{await qt(),await yt()}catch(e){he(_N(e))}},[yt]),zt=(0,J.useCallback)(async(e,t)=>{he(null),pe(!0);try{t===`verify`&&await je(e),t===`disk_full`&&pt();try{E(await ve(e,{keepTrying:U}))}catch(t){let n=Oe(t);if(!n)throw t;G({kind:`server`,detail:n,then:`retry`,id:e})}}catch(e){he(_N(e))}finally{pe(!1)}},[U,pt]),Bt=(0,J.useCallback)(async e=>{he(null),pe(!0);try{L?.catalog?.find(t=>t.id===e)?.planned&&ee(await ht(e,!0)),E(t=>t&&{...t,models:t.models?.map(t=>t.id===e?{...t,state:`skipped`}:t)});let{options:t}=Pe.current;Pe.current.options={...t,extraModels:t.extraModels?.filter(t=>t!==e)},te(t=>t&&t.ticked.has(e)?fj(t,YA(L),e,!1):t)}catch(e){he(_N(e))}finally{pe(!1)}},[L]),Vt=(0,J.useCallback)(async()=>{await Lt(),Ct()},[Lt,Ct]),Ht=(0,J.useCallback)(async()=>{if(!at){I({busy:!0,error:null,done:!1});try{await Rt(a,{api_key:!ke&&M||void 0},e=>I({busy:!0,error:null,done:!1,waiting:e}),()=>!Je.current);let{models:e}=await Zt(a),t=e.find(e=>e.rank===1)??e[0];if(!t)throw Error(n(`setup.key.noModels`));await i(t.id),be(t.id),N(``),I({busy:!1,error:null,done:!0}),wt(!1)}catch(e){I({busy:!1,error:_N(e),done:!1})}}},[a,M,i,ke,wt,n,at]),Ut=(0,J.useCallback)(e=>{uN(e),o(e),I({busy:!1,error:null,done:!1})},[]);(0,J.useEffect)(()=>{if(!st||we.length===0||Re.current)return;let e=we;Re.current=!0,xt(!1,{keepTrying:U,extraModels:e}).then(t=>{Re.current=!1,Te(t=>t.filter(t=>!e.includes(t))),t||De(t=>[...t,...e.filter(e=>!t.includes(e))])})},[st,we,U,xt]);let Gt=st&&we.length===0,Kt=tt?ye:it?.chat_model??(L&&!L.decided_after_server?L.chat_model.id:null),Jt=(0,J.useCallback)(async t=>{he(null);try{!tt&&Kt&&await i(Kt),await r()}catch(e){he(_N(e));return}e(t)},[Kt,tt,e,r,i]);(0,J.useEffect)(()=>{Gt&&rt().then(e=>Se(e.cards)).catch(e=>console.warn(`[SetupScreen] no first tasks to offer`,e))},[Gt]);let Yt=(0,J.useMemo)(()=>{let e={};for(let t of L?.catalog??[])e[t.id]=t.name;return e},[L]),Xt=w?.state===`failed`||w?.state===`cancelled`,Qt=it&&(it.state===`failed`||it.state===`cancelled`)&&(it.models??[]).length>0&&(it.models??[]).every(e=>e.state===`ready`||e.state===`skipped`||e.state===`verifying`||e.state===`unchecked`)&&!ct,$t=!!it&&Xt&&!it.problem&&Object.values(it.components??{}).includes(`failed`),en=YA(L),tn=B?hj(en,B):[],nn=L&&B?_j(L,B):null,rn=en.find(e=>e.id===B?.defaultChat),an=!!b&&!b.compatible&&b.blockers.length>0,on=Gt?`ready`:s===`download`&<?`test`:s;y.current=on;let sn=h??on;(0,J.useEffect)(()=>{v(e=>e.has(sn)?e:new Set(e).add(sn))},[sn]);let cn=(0,J.useRef)(!0);(0,J.useEffect)(()=>{if(cn.current){cn.current=!1;return}let e=document.querySelector(`.setup-inner`);e&&(e.scrollTop=0),document.getElementById(`setup-title`)?.focus({preventScroll:!0})},[sn]);let ln=[{id:`check`,label:n(`setup.check.title`),key:`setup.check.title`},{id:`plan`,label:n(`setup.plan.step`),key:`setup.plan.step`},{id:`download`,label:n(`setup.download.step`),key:`setup.download.step`},{id:`test`,label:n(`setup.test.step`),key:`setup.test.step`},{id:`ready`,label:n(`setup.ready.step`),key:`setup.ready.step`}],un=e=>e===`models`||e===`key`?`plan`:e===`gpu`?d===`check`?`check`:`plan`:e,dn=tt?`key`:l?`models`:`plan`,fn=ln.findIndex(e=>e.id===un(on)),pn=e=>e===`download`||e===`test`||e===`ready`,mn=[];if(b){let e=[L?.system?.physical_memory?`${AS(L.system.physical_memory,null)} installed`:null,b.ram_gb==null?null:`${b.ram_gb} GB the OS can use`].filter(Boolean).join(`, `),t=b.disk_free_gb==null?null:`${Math.round(b.disk_free_gb)} GB free on disk`;mn.push(`This PC: ${[b.gpu_name,b.npu_detected?`NPU`:null].filter(Boolean).join(`, `)||`no GPU reported`}`+[e,t].filter(Boolean).map(e=>`; ${e}`).join(``))}else S&&mn.push(`Couldn't read this PC: ${S}`);We&&(mn.push(`Found your Lemonade${We.version?` ${We.version}`:``} at ${We.url}`),mn.push(Ke===`external`?`You chose your own Lemonade`:Ke===`gaia`?`You chose GAIA's own Lemonade`:`Waiting for you to choose which Lemonade GAIA uses`)),L&&(!We||Ke)?mn.push(L.lemonade.reachable?`Model server answering at ${L.lemonade.url??`its address`}`:`No model server answering yet`):R&&mn.push(`Couldn't read the model list: ${R}`);let hn=(e,t)=>t<=fn||_.has(e)&&!pn(e),gn=ln.map((e,t)=>({id:e.id,label:e.label,status:t<fn?`done`:t>fn?`pending`:on===`ready`?`done`:Xt&&(on===`download`||on===`test`||on===`check`)?`failed`:at&&(on===`download`||on===`test`)?`active`:`current`,shown:e.id===un(sn),onOpen:e.id!==un(sn)&&hn(e.id,t)?()=>kt(e.id===`plan`?dn:e.id):void 0})),_n=ln.findIndex(e=>e.id===un(sn)),yn=sn===`gpu`&&d===`check`?.5:gN.indexOf(sn),bn=(0,J.useRef)(yn),xn=(0,J.useRef)(`forward`);bn.current!==yn&&(xn.current=yn>bn.current?`forward`:`back`,bn.current=yn);let Sn=sn===`gpu`?d:sn===`models`||sn===`key`?`plan`:_n>0?ln[_n-1].id===`plan`?dn:ln[_n-1].id:null,Cn=(sn!==`gpu`&&_n>=0&&_n<ln.length-1&&hn(ln[_n+1].id,_n+1)?ln[_n+1].id:null)??(h==null?sn===`check`&&St?`plan`:sn===`gpu`?d:null:null);It.current={prev:Sn,next:Cn};let wn=sn===`gpu`||sn===`models`||sn===`key`,Tn=h!=null&&at,En=[`server`];tt||En.push(`chat`),!tt&&B&&nj(en,B)&&En.push(`vision`),B&&en.some(e=>ZA(e)&&B.ticked.has(e.id))&&En.push(`embedding`);for(let e of en)B&&ej(e)&&B.ticked.has(e.id)&&!e.downloaded&&En.push(e.roles[0]);En.push(`agent`);let Dn=B&&!tt?en.filter(e=>ej(e)&&!B.ticked.has(e.id)&&!e.downloaded&&(tj(rn)||!e.roles.includes(`image_creation`))):[],On=en.find(e=>e.fit_code===`memory`&&e.chat_choice&&e.support===`verified`);return V(`main`,{className:`setup`,"aria-labelledby":`setup-title`,children:[P(ZM,{steps:gn}),P(Hj,{value:p,children:V(`div`,{className:`setup-pane`,children:[V(`div`,{className:`setup-inner`,children:[_n>=0&&V(`nav`,{className:`setup-topnav`,"aria-label":n(`setup.nav.label`),children:[P(`button`,{type:`button`,className:`setup-arrow`,onClick:()=>Sn&&kt(Sn),disabled:!Sn,"aria-label":n(`setup.nav.prev`),children:P(_r,{size:16,"aria-hidden":`true`})}),P(`button`,{type:`button`,className:`setup-arrow`,onClick:()=>Cn&&kt(Cn),disabled:!Cn,"aria-label":n(`setup.nav.next`),children:P(yr,{size:16,"aria-hidden":`true`})}),P(`span`,{children:P(`bdi`,{children:n(`setup.nav.stepOf`,{n:String(_n+1),total:String(ln.length)})})}),h!=null&&h!==on&&P(`button`,{type:`button`,className:`link-btn`,onClick:()=>g(null),children:n.compose(e=>e(`setup.nav.toLive`,{step:e(ln.find(e=>e.id===on)?.key??`setup.download.step`)}))}),P(OM,{})]}),ge&&s!==`download`&&V(`div`,{className:`setup-banner`,role:`status`,children:[P(Vi,{size:14,"aria-hidden":`true`}),P(`span`,{children:n(`setup.resume.banner`)})]}),Me&&s!==`download`&&P(`p`,{className:`setup-hint`,role:`status`,children:n(`setup.interrupted`)}),V(`div`,{className:`setup-stage is-${xn.current}`,children:[sn===`check`&&V(D.Fragment,{children:[P(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(St?`setup.check.headingDone`:`setup.check.heading`)}),P(`p`,{className:`setup-lede`,children:n(St?`setup.check.ledeDone`:`setup.check.lede`)}),P(XM,{hardware:b,hardwareError:S,plan:L,serverRun:nt,awaitingChoice:!!We&&!Ve}),St&&L&&P(JM,{plan:L,hardware:b,onChangeMemory:Nt&&h==null?()=>Ft(`check`):void 0}),St&&h==null&&!(We&&!Ve)&&P(Uj,{children:P(`button`,{type:`button`,className:`btn-primary`,onClick:()=>kt(`plan`),children:n(`setup.continue`)})}),nt&&Xt&&V(D.Fragment,{children:[P(hN,{run:nt}),nt.problem?P(pN,{problem:nt.problem,onRetry:()=>void xt(!1,{serverOnly:!0}),onUseGaia:()=>void xt(!0,{serverOnly:!0})}):P(Uj,{children:P(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void xt(!!nt.gaia_lemonade,{serverOnly:!0}),children:n(`setup.tryAgain`)})})]}),R&&!L&&V(D.Fragment,{children:[P(mN,{text:R}),V(Uj,{children:[P(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void xt(!1,{keepTrying:U}),children:n(`setup.models.useRecommended`)}),P(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void pt(),children:n(`setup.tryAgain`)})]}),P(`p`,{className:`setup-hint`,children:n(`setup.models.useRecommendedNote`)})]}),A&&P(mN,{text:A}),A&&!nt&&L&&!L.lemonade.reachable&&P(Uj,{children:P(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void xt(!1,{serverOnly:!0}),children:n(`setup.tryAgain`)})}),ze&&L&&(!L.lemonade.reachable&&!nt||St&&h==null&&L.lemonade.mode!==`external`)&&P(fN,{onNothingToOffer:Ue,canInstallOwn:!L.lemonade.reachable&&!nt,onFound:Ge,onChosen:e=>{Ae(e===`external`),qe(e),He(!0),ut(),pt()}})]}),sn===`plan`&&L&&B&&V(D.Fragment,{children:[P(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.plan.title`)}),P(`p`,{className:`setup-lede`,children:n(`setup.plan.lede`)}),V(`section`,{className:`setup-hero`,"aria-label":n(`setup.plan.label`),children:[P(`p`,{className:`setup-eyebrow`,children:B.chatChosen?n(`setup.plan.yours`):n(`setup.plan.recommended`)}),P(`p`,{className:`setup-hero-title`,children:P(`bdi`,{children:n(`setup.plan.run`,{name:rn?.name??``})})}),V(`dl`,{className:`setup-facts`,children:[V(`div`,{children:[P(`dt`,{children:n(`setup.summary.download`)}),P(`dd`,{children:P(`bdi`,{dir:`ltr`,children:$(gj(L,B).downloadGb??0)})})]}),V(`div`,{children:[P(`dt`,{children:n(`setup.plan.runsOn`)}),P(`dd`,{children:P(`bdi`,{children:rn&&QA(rn)?n(`setup.checks.npu`):b?.gpu_name??n(`setup.plan.cpu`)})})]}),V(`div`,{children:[P(`dt`,{children:n(`setup.plan.diskAfter`)}),P(`dd`,{children:P(`bdi`,{dir:`ltr`,children:gj(L,B).afterGb==null?`—`:$(Math.max(0,gj(L,B).afterGb))})})]})]}),V(`ul`,{className:`setup-reasons`,children:[!B.chatChosen&&P(`li`,{children:n(`setup.plan.why.evaluated`)}),rn?.need_gb!=null&&rn.capacity_gb!=null&&rn.fits&&P(`li`,{children:n(`setup.plan.why.fits`,{need:jS(rn.need_gb),have:jS(rn.capacity_gb)})}),P(`li`,{children:n(`setup.plan.why.private`)}),rn&&QA(rn)&&P(`li`,{children:n(`setup.plan.why.noImagesNpu`)}),On&&On.id!==rn?.id&&On.need_gb!=null&&On.capacity_gb!=null&&P(`li`,{children:n(`setup.plan.why.bigger`,{name:On.name,need:jS(On.need_gb),have:jS(On.capacity_gb)})})]}),P(Uj,{children:V(`button`,{type:`button`,className:`btn-primary`,onClick:()=>nn?G({kind:`low_disk`}):void Ot(!1),disabled:fe||an||Tn,children:[fe&&P(K,{size:13,className:`spin`,"aria-hidden":`true`}),` `,tn.length?n(`setup.plan.start`):n(`setup.plan.startNoDownload`)]})}),V(`div`,{className:`setup-row`,children:[P(`button`,{type:`button`,className:`link-btn`,onClick:jt,disabled:Tn,children:n(`setup.plan.customize`)}),P(`button`,{type:`button`,className:`link-btn`,onClick:Mt,disabled:Tn,children:n(`setup.plan.cloud`)}),t&&P(`button`,{type:`button`,className:`link-btn`,onClick:t,children:n(`setup.backToGaia`)})]}),an&&V(`div`,{className:`setup-error`,role:`alert`,children:[P(`p`,{children:n(`setup.blocked`)}),V(`details`,{className:`dl-details`,children:[P(`summary`,{children:n(`setup.progress.details`)}),P(`pre`,{dir:`ltr`,children:b?.blockers.join(`
|
|
81
|
-
`)})]})]}),nn&&P(`p`,{className:`setup-error`,role:`alert`,children:n(`setup.summary.short`,{need:$(nn.needGb),free:$(nn.freeGb),drive:n(`setup.summary.theDrive`),freeUp:$(nn.freeUpGb)})}),(me??A)&&P(mN,{text:me??A})]}),V(`details`,{className:`setup-disclosure`,children:[P(`summary`,{children:n(`setup.plan.whatDownloads`)}),P(fM,{plan:L,models:tn})]})]}),sn===`gpu`&&oe&&V(D.Fragment,{children:[P(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.gpu.title`)}),P(`p`,{className:`setup-lede`,children:n(`setup.gpu.lede`)}),P($j,{status:oe,onStatus:H,mode:`setup`,headingId:`setup-title`,names:Yt,onBack:Pt,onSkip:()=>kt(d),onContinue:()=>kt(d)})]}),sn===`models`&&V(D.Fragment,{children:[P(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.models.title`)}),L&&B&&P(PM,{plan:L,selection:B,onSelection:te,disabled:fe||Tn,onRecheck:()=>void pt()}),Nt&&oe?.total_gb!=null&&oe.gpu_gb!=null&&V(`p`,{className:`setup-hint setup-gpu-option`,children:[n(`setup.models.gpu`,{gpu:$(oe.gpu_gb),total:$(oe.total_gb)}),` `,P(`button`,{type:`button`,className:`link-btn`,onClick:()=>Ft(`models`),disabled:fe||Tn,children:n(`setup.found.changeMemory`)})]}),P(eM,{plan:L,planError:R,onRetryPlan:()=>void pt(),onUseRecommended:()=>void xt(!1,{keepTrying:U}),selection:B,onSelection:te,cloud:!1,keepTrying:U,onKeepTrying:se,onBack:Pt,onContinue:e=>void Ot(e),busy:fe||Tn,error:me??A})]}),sn===`key`&&V(`form`,{id:`setup-key-form`,onSubmit:e=>{e.preventDefault(),Ht()},className:`setup-form`,children:[P(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.key.title`)}),P(`div`,{className:`setup-choices`,role:`radiogroup`,"aria-label":n(`setup.key.provider`),children:aN.filter(e=>e.id!==`local`).map(e=>V(`button`,{type:`button`,role:`radio`,"aria-checked":a===e.id,className:`setup-choice${a===e.id?` is-active`:``}${et(e.id)?` is-disabled`:``}`,onClick:()=>Ut(e.id),disabled:F.busy||et(e.id),children:[P(Fr,{size:16,"aria-hidden":`true`}),V(`span`,{children:[P(`span`,{className:`setup-choice-title`,children:P(`bdi`,{children:oN(e,n)})}),P(`span`,{className:`setup-choice-note`,children:et(e.id)?n(`setup.key.gatewayOff`):n(e.note)})]})]},e.id))}),Ye?.reachable===!1&&P(`button`,{type:`button`,className:`link-btn setup-start`,onClick:Qe,children:n(`setup.key.checkAgain`)}),a===`fireworks`&&!ke&&V(`section`,{className:`setup-card`,children:[P(`h3`,{className:`mc-job-title`,children:n(`setup.key.getOne`)}),V(`ol`,{className:`setup-key-steps`,children:[P(`li`,{children:P(`a`,{href:rN,target:`_blank`,rel:`noreferrer`,children:n(`setup.key.step1`)})}),P(`li`,{children:n(`setup.key.step2`)}),P(`li`,{children:n(`setup.key.step3`)})]})]}),a===`amd`&&!ke&&P(`section`,{className:`setup-card`,children:P(`p`,{className:`setup-hint`,children:P(`a`,{href:iN,target:`_blank`,rel:`noreferrer`,children:n(`setup.key.gatewayHelp`)})})}),P(HA,{provider:a,limit:3}),P(`p`,{className:`setup-hint`,children:n(ke?`setup.key.usersServer`:`setup.key.where`)}),P(`div`,{className:`setup-row`,children:!ke&&P(`input`,{className:`settings-input`,type:`password`,autoComplete:`off`,value:M,onChange:e=>N(e.target.value),placeholder:n(`setup.key.placeholder`),"aria-label":n(`setup.key.label`)})}),$e&&!ke&&!M&&P(`p`,{className:`setup-hint`,role:`status`,children:n(`setup.key.foundEnv`,{name:$e.name,hint:$e.key_hint??``})}),F.busy&&!F.waiting&&P(`p`,{className:`setup-hint`,role:`status`,children:n(`setup.key.testing`)}),F.busy&&F.waiting&&P(`p`,{className:`setup-hint`,role:`status`,children:F.waiting}),F.error&&P(`p`,{className:`setup-error`,role:`alert`,children:F.error}),V(Uj,{children:[P(`button`,{type:`button`,className:`btn-secondary`,onClick:At,disabled:F.busy,children:n(`setup.back`)}),V(`button`,{type:`submit`,form:`setup-key-form`,className:`btn-primary`,disabled:F.busy||et(a)||Tn,children:[F.busy&&P(K,{size:13,className:`spin`}),` `,n(`setup.key.connect`)]})]})]}),sn===`download`&&!it&&V(D.Fragment,{children:[P(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.download.title`)}),P(`p`,{className:`setup-lede`,children:n(`setup.download.lede`)}),V(`p`,{className:`setup-hint`,role:`status`,children:[P(K,{size:13,className:`spin`,"aria-hidden":`true`}),` `,n(`setup.download.starting`)]})]}),sn===`download`&&it&&V(D.Fragment,{children:[P(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.download.title`)}),P(`p`,{className:`setup-lede`,children:n(`setup.download.lede`)}),L&&P(`section`,{className:`setup-card`,"aria-label":n(`setup.contents.title`),children:P(fM,{plan:L,run:it,onRetry:Ct,retryDisabled:fe})}),(it.models?.length??0)>0?P(`div`,{className:O?`is-stale`:void 0,children:P(wM,{status:{...it,overall:xj(it,ne??L)},names:Yt,freeGb:L?.disk?.free_gb??null,onCancel:()=>void Lt(),onRetry:(e,t)=>void zt(e,t),onResume:e=>void zt(e,null),onResumeAll:Ct,onSkip:e=>void Bt(e),onRestart:()=>void Vt(),busy:fe||!!O,retryLater:at,labelledBy:`setup-title`})}):at?V(`p`,{className:`setup-hint`,role:`status`,children:[P(K,{size:13,className:`spin`,"aria-hidden":`true`}),` `,n(`setup.download.working`)]}):null,Dn.length>0&&V(`section`,{className:`setup-card`,"aria-label":n(`setup.optional.title`),children:[P(`h3`,{className:`mc-job-title`,children:n(`setup.optional.title`)}),P(`p`,{className:`setup-hint`,children:n(`setup.optional.lede`)}),P(`ul`,{className:`setup-rows`,children:Dn.map(e=>{let t=we.includes(e.id);return V(`li`,{className:`setup-result is-waiting`,children:[P(`span`,{className:`setup-result-label`,children:n(`setup.purpose.${e.roles[0]}`)}),V(`span`,{className:`setup-result-value`,children:[P(`bdi`,{dir:`ltr`,children:e.size_gb==null?n(`setup.contents.sizeOnDownload`):$(e.size_gb)}),P(`button`,{type:`button`,className:`btn-secondary`,"aria-pressed":t,onClick:()=>Te(n=>t?n.filter(t=>t!==e.id):[...n,e.id]),children:n(t?`setup.optional.added`:`setup.optional.add`)})]})]},e.id)})})]}),O&&V(D.Fragment,{children:[P(`p`,{className:`setup-error`,role:`alert`,children:n(`setup.lostContact`,{error:O})}),P(Uj,{children:P(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void yt(),children:n(`setup.reconnect`)})})]}),Xt&&Qt&&!$t&&it.state===`failed`&&!it.model_failed&&(it.problem?P(pN,{problem:it.problem,onRetry:Ct,onUseGaia:()=>void xt(!0,Pe.current.options)}):V(`div`,{className:`setup-error`,role:`alert`,children:[P(`p`,{children:n(`setup.download.stoppedBeforeCheck`)}),it.error&&V(`details`,{className:`dl-details`,children:[P(`summary`,{children:n(`setup.progress.details`)}),P(`pre`,{dir:`ltr`,children:it.error})]})]})),Xt&&Qt&&!$t&&V(D.Fragment,{children:[P(`p`,{className:`setup-hint`,children:n(`setup.download.finishNote`)}),P(Uj,{children:P(`button`,{type:`button`,className:`btn-primary`,onClick:Ct,disabled:fe,children:n(`setup.finish`)})})]}),Xt&&!Qt&&!$t&&!(it.models??[]).some(e=>e.state===`failed`||e.state===`cancelled`)&&V(D.Fragment,{children:[P(hN,{run:it}),it.problem?P(pN,{problem:it.problem,onRetry:Ct,onUseGaia:()=>void xt(!0,Pe.current.options)}):P(Uj,{children:P(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void xt(!!it.gaia_lemonade,Pe.current.options),children:n(`setup.tryAgain`)})})]}),(me||A)&&P(mN,{text:me??A})]}),sn===`test`&&it&&V(D.Fragment,{children:[P(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.test.title`)}),P(`p`,{className:`setup-lede`,children:n(`setup.test.lede`)}),P(nN,{run:it,expected:En,names:Yt,catalog:en,onRetry:Ct,onChooseAnother:tt?void 0:jt,onCancel:()=>void Lt(),onDownloadAgain:L?.lemonade.mode===`external`?void 0:e=>void zt(e,`verify`),busy:fe}),Xt&&it.error&&!(it.tests??[]).some(e=>e.error===it.error)&&V(`details`,{className:`dl-details`,children:[P(`summary`,{children:n(`setup.progress.details`)}),P(`pre`,{dir:`ltr`,children:it.error})]}),(me||A)&&P(mN,{text:me??A})]}),sn===`ready`&&V(D.Fragment,{children:[P(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.ready.heading`)}),V(`div`,{className:`setup-done`,role:`status`,children:[P(`div`,{className:`setup-done-head`,children:Kt&&P(`p`,{children:n(tt?`setup.ready.answersCloud`:`setup.ready.answersLocal`,{model:tt?vs(Kt):Yt[Kt]??ie?.catalog?.find(e=>e.id===Kt)?.name??vs(Kt)})})}),P(Uj,{children:P(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void Jt(),autoFocus:!0,children:n(`setup.ready.start`)})}),!tt&&ie&&P(tM,{plan:ie,chatModel:Kt,gpu:oe}),A&&P(mN,{text:A}),(it?.tests??[]).filter(e=>e.state===`failed`).map(e=>P(`p`,{className:`setup-failed-extra`,role:`alert`,children:n(`setup.ready.extraFailed`,{job:n(`setup.test.job.${e.job}`)})},`${e.job}:${e.subject??``}`)),Ee.length>0&&!W&&P(`p`,{className:`setup-failed-extra`,role:`alert`,children:n(`setup.ready.extraNotFetched`,{names:Ee.map(e=>Yt[e]??e).join(`, `)})}),xe.length>0&&V(D.Fragment,{children:[P(`p`,{className:`setup-hint`,children:n(`setup.ready.tasks`)}),P(oM,{cards:xe,onPick:e=>void Jt(e)})]})]})]})]},sn),t&&!at&&sn!==`plan`&&sn!==`ready`&&P(`div`,{className:`setup-row`,children:P(`button`,{type:`button`,className:`link-btn setup-close`,onClick:t,children:n(`setup.backToGaia`)})}),Tn&&(wn||sn===`plan`)&&P(`p`,{className:`setup-hint`,role:`status`,children:n(`setup.nav.runGoing`)}),P(DM,{run:w,before:{check:mn}})]}),P(`div`,{className:`setup-footer`,ref:m})]})}),W?.kind===`no_fit`&&P(Wj,{title:W.models.length===1?n(`setup.confirm.noFitOne`,{name:W.models[0].name}):n(`setup.confirm.noFitMany`),confirmLabel:n(`setup.confirm.downloadAnyway`),cancelLabel:n(`setup.confirm.pickSmaller`),onConfirm:()=>{G(null),de(!0),Ot(Tt,!0)},onCancel:()=>G(null),children:W.models.map(e=>V(`p`,{children:[P(`bdi`,{children:e.name}),`: `,Oj(e,n)]},e.id))}),W?.kind===`low_disk`&&nn&&P(Wj,{title:n(`setup.confirm.lowDiskTitle`),confirmLabel:n(`setup.confirm.downloadAnyway`),cancelLabel:n(`setup.confirm.changeModels`),onConfirm:()=>{G(null),Ot(!0)},onCancel:()=>{G(null),jt()},children:P(`p`,{children:n(`setup.summary.short`,{need:$(nn.needGb),free:$(nn.freeGb),drive:n(`setup.summary.theDrive`),freeUp:$(nn.freeUpGb)})})}),W?.kind===`server`&&P(Wj,{title:W.detail.code===`low_disk`?n(`setup.confirm.lowDiskTitle`):n(`setup.confirm.noFitServerTitle`),confirmLabel:W.detail.code===`low_disk`?n(`setup.confirm.downloadAnyway`):n(`setup.confirm.useAnyway`),cancelLabel:n(`setup.confirm.changeModels`),onConfirm:()=>{let e=W;if(G(null),e.then===`chat`)de(!0),Ot(Tt,!0);else if(e.then===`retry`)ve(e.id,{keepTrying:U,acknowledgeLowDisk:!0}).then(E).catch(e=>he(_N(e)));else{let{gaiaLemonade:e,options:t}=Pe.current;xt(e,{...t,acknowledgeLowDisk:!0})}},onCancel:()=>{let e=W;G(null),e.then!==`retry`&&!st&&jt()},children:P(`p`,{children:W.detail.message})})]})}function yN(e,t,n){let r=(0,J.useRef)(n);(0,J.useEffect)(()=>{r.current=n});let i=(0,J.useRef)(!1),a=(0,J.useRef)(null);if(t&&!i.current){let e=document.activeElement;a.current=e instanceof HTMLElement?e:null}(0,J.useEffect)(()=>{if(!t)return;i.current=!0;let n=a.current,o=e.current;if(o&&!o.contains(document.activeElement)){let e=r.current?.()??iS(o)[0];e?e.focus():(o.hasAttribute(`tabindex`)||o.setAttribute(`tabindex`,`-1`),o.focus())}return()=>{i.current=!1;let e=document.activeElement;(!e||e===document.body||o?.contains(e))&&n?.isConnected&&n.focus()}},[e,t])}function bN({title:e,titleId:t,count:n,hint:r,defaultOpen:i=!1,forceOpen:a=!1,children:o}){let[s,c]=(0,J.useState)(i);return V(`details`,{className:`settings-disclosure`,open:s||a,onToggle:e=>{a||c(e.currentTarget.open)},children:[V(`summary`,{onClick:e=>{a&&e.preventDefault()},children:[P(hr,{size:15,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),V(`span`,{className:`settings-disclosure-text`,children:[P(`span`,{className:`settings-disclosure-title`,id:t,tabIndex:t?-1:void 0,children:e}),r&&P(`span`,{className:`settings-disclosure-hint`,children:r})]}),n!=null&&P(`bdi`,{dir:`ltr`,className:`settings-disclosure-count`,children:n})]}),P(`div`,{className:`settings-disclosure-body`,children:o})]})}var xN=g(Tc()?`settings.desktop.menuBar`:`settings.desktop.tray`),SN=[{key:`minimizeToTray`,label:`settings.desktop.keepRunning`,hint:`settings.desktop.keepRunningHint`},{key:`startOnLogin`,label:`settings.desktop.startOnLogin`,hint:`settings.desktop.startOnLoginHint`},{key:`startMinimized`,label:`settings.desktop.startMinimized`,hint:`settings.desktop.startMinimizedHint`}],CN=new Set([`startMinimized`]),wN={minimizeToTray:`settings.desktop.keepRunningNoTray`};function TN(e){return e?.reason===`no-host`?`settings.desktop.noTray`:e?.reason===`check-failed`?`settings.desktop.noTrayCheckFailed`:null}function EN(){let e=T(),t=window.gaiaAPI?.tray,[n,r]=(0,J.useState)(null),[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(null);(0,J.useEffect)(()=>{t&&t.getConfig().then(e=>{r(e.tray),a(e.host)}).catch(t=>s(e(`settings.desktop.readFailed`,{reason:t instanceof Error?t.message:String(t)})))},[t,e]);let u=(0,J.useCallback)(async e=>{if(t&&n&&c===null){l(e),s(null);try{let i=await t.setConfig({tray:{[e]:!n[e]}});r(i.tray),a(i.host)}catch(e){s(e instanceof Error?e.message:String(e))}finally{l(null)}}},[t,n,c]);if(!t)return null;let d=TN(i);return P(bN,{title:e(`settings.desktop.title`),children:V(`div`,{className:`settings-field`,role:`group`,"aria-labelledby":`desktop-app-label`,children:[P(`span`,{className:`settings-label`,id:`desktop-app-label`,children:e(`settings.desktop.title`)}),SN.map(({key:t,label:r,hint:i})=>{let a=CN.has(t)?d:null,o=d&&wN[t]||i;return V(`div`,{children:[V(`label`,{className:`setting-row`,children:[P(`span`,{children:e(r,{tray:xN})}),V(`span`,{className:`toggle-switch`,children:[P(`input`,{type:`checkbox`,role:`switch`,checked:!a&&!!n?.[t],"aria-describedby":`desktop-${t}-hint`,onChange:()=>void u(t),disabled:!!a||!n||c!==null&&c!==t,"aria-busy":c===t,"aria-label":e(r,{tray:xN})}),P(`span`,{className:`toggle-track`})]})]}),P(`p`,{className:`settings-hint`,id:`desktop-${t}-hint`,children:a?e(a):e(o,{tray:xN})})]},t)}),o&&P(`p`,{className:`settings-error`,role:`alert`,children:o})]})})}function DN(){return window.gaiaUpdater}var ON={status:`idle`,version:null,progress:0,releaseNotes:null,error:null,currentVersion:null,pinnedVersion:null,autoUpdate:!1,includePrereleases:!1};function kN(){let[e,t]=(0,J.useState)({...ON});return(0,J.useEffect)(()=>{let e=DN();if(!e)return;let n=!0;e.getStatus().then(e=>{n&&e&&t(e)}).catch(()=>{});let r=e.onStatusChange(e=>{n&&e&&t(e)});return()=>{n=!1;try{r()}catch{}}},[]),e}var AN=`gaia-update-error:`;function jN(e,t){let n=`update.err.${e}`;return N(n)?g(n,t??{}):null}function MN(e){let t=e instanceof Error?e.message:String(e),n=t.indexOf(AN);if(n<0)return t.replace(/^Error invoking remote method '[^']+': (?:Error: )?/,``);let r;try{r=JSON.parse(t.slice(n+18))}catch{return t.slice(0,n)+t.slice(n+18)}let i=jN(r.code,r.params)??r.message??r.code,a=r.note&&jN(r.note.code,r.note.params);return a?g(`update.err.withNote`,{error:i,note:a}):i}function NN(e,t){let n=MN(e);return typeof n==`object`?t(n.ref,n.params):String(n)}function PN(){return window.gaiaUpdater}function FN({onClose:e}){let t=T(),[n,r]=(0,J.useState)({kind:`loading`}),i=(0,J.useRef)(null);(0,J.useEffect)(()=>{let e=PN();e?e.listReleases().then(e=>{r(Array.isArray(e)?{kind:`list`,releases:e}:{kind:`error`,message:e.error})}).catch(()=>{r({kind:`error`,message:`Couldn't reach GitHub to list releases — check your connection; you can still download installers from the Releases page.`})}):r({kind:`error`,message:`Couldn't reach GitHub to list releases — check your connection; you can still download installers from the Releases page.`})},[]),Io(!0,e),aS(i,!0),(0,J.useEffect)(()=>{let e=i.current;e&&e.querySelector(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`)?.focus()},[]),(0,J.useEffect)(()=>{let e=i.current;if(!e)return;function t(t){if(t.key!==`Tab`||!e)return;let n=e.querySelectorAll(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`);if(n.length===0)return;let r=n[0],i=n[n.length-1];t.shiftKey?document.activeElement===r&&(t.preventDefault(),i?.focus()):document.activeElement===i&&(t.preventDefault(),r?.focus())}return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[]);function a(e,t){e.isCurrent||r({kind:`confirm`,release:e,releases:t})}async function o(n){r({kind:`installing`});let i=PN();if(!i)r({kind:`error`,message:t(`update.picker.noBridge`)});else try{await i.installVersion(n.tag),e()}catch(e){r({kind:`error`,message:t(`update.picker.failed`,{reason:MN(e)})})}}function s(e){if(!e)return``;try{return new Date(e).toLocaleDateString(te(t),{year:`numeric`,month:`short`,day:`numeric`})}catch{return e}}return P(`div`,{className:`version-picker-overlay`,onClick:t=>{t.target===t.currentTarget&&e()},children:V(`div`,{className:`version-picker-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":t(`update.picker.title`),ref:i,children:[V(`div`,{className:`version-picker-header`,children:[P(`h3`,{children:t(`update.picker.title`)}),P(`button`,{className:`version-picker-close`,onClick:e,"aria-label":t(`update.picker.close`),type:`button`,children:`×`})]}),V(`div`,{className:`version-picker-body`,children:[n.kind===`loading`&&V(`div`,{className:`version-picker-loading`,"aria-busy":`true`,children:[P(`span`,{className:`version-picker-spinner`}),t(`update.picker.loading`)]}),n.kind===`error`&&V(`div`,{className:`version-picker-error`,children:[P(`p`,{children:n.message}),P(`p`,{children:P(`a`,{href:`https://github.com/amd/gaia/releases`,target:`_blank`,rel:`noreferrer`,children:t(`update.picker.browse`)})})]}),n.kind===`list`&&P(`ul`,{className:`version-picker-list`,role:`listbox`,"aria-label":t(`update.picker.listAria`),children:n.releases.map(e=>P(`li`,{children:V(`button`,{type:`button`,className:`version-picker-row`,"data-version":e.version,"aria-label":e.isCurrent?t(`update.picker.rowInstalled`,{version:e.version}):e.isPinned?t(`update.picker.rowPinned`,{version:e.version}):e.version,"aria-disabled":e.isCurrent?`true`:`false`,onClick:()=>a(e,n.releases),disabled:e.isCurrent,children:[P(`span`,{className:`vp-version`,children:e.version}),P(`span`,{className:`vp-date`,children:s(e.date)}),e.isCurrent&&P(`span`,{className:`vp-badge vp-badge-current`,children:t(`update.picker.installed`)}),e.isPinned&&!e.isCurrent&&P(`span`,{className:`vp-badge vp-badge-pinned`,children:t(`update.picker.pinned`)}),!e.isCurrent&&P(`span`,{className:`vp-arrow`,"aria-hidden":`true`,children:`›`})]})},e.tag))}),n.kind===`list`&&V(`p`,{className:`version-picker-more`,children:[t(`update.picker.recent`,{n:n.releases.length}),` `,P(`a`,{href:`https://github.com/amd/gaia/releases`,target:`_blank`,rel:`noreferrer`,children:t(`update.picker.browseAll`)})]}),n.kind===`confirm`&&V(`div`,{className:`version-picker-confirm`,children:[P(`p`,{children:t(`update.picker.confirm`,{version:n.release.version})}),P(`p`,{className:`vp-confirm-note`,children:t(`update.picker.confirmNote`,{version:n.release.version})}),V(`div`,{className:`vp-confirm-actions`,children:[P(`button`,{type:`button`,className:`vp-btn-cancel`,onClick:()=>r({kind:`list`,releases:n.releases}),children:t(`update.picker.back`)}),P(`button`,{type:`button`,className:`vp-btn-confirm`,onClick:()=>o(n.release),children:t(`update.picker.install`)})]})]}),n.kind===`installing`&&V(`div`,{className:`version-picker-loading`,"aria-busy":`true`,children:[P(`span`,{className:`version-picker-spinner`}),t(`update.picker.starting`)]})]})]})})}var IN=`https://github.com/amd/gaia/releases`;function LN(e){return/^\d+\.\d+\.\d+-/.test(e??``)}function RN(e,t){let n=e.version??``;switch(e.status){case`checking`:return t(`update.status.checking`);case`available`:return t(`update.status.available`,{version:n});case`downloading`:return e.preparing?t(`update.status.preparing`,{version:n}):t(`update.status.downloading`,{version:n,pct:e.progress});case`downloaded`:return t(`update.status.downloaded`,{version:n});case`error`:return t(`update.status.error`,{reason:e.error??t(`update.status.unknownError`)});case`no-channel`:return e.error??t(`update.status.noChannel`);case`disabled`:return t(`update.status.disabled`);default:return t(`update.status.upToDate`)}}function zN(){let e=kN(),t=T(),n=DN(),[r,i]=(0,J.useState)(!1),[a,o]=(0,J.useState)(null),[s,c]=(0,J.useState)(!1);if(!n)return null;async function l(e,r){if(n){i(!0),o(null);try{await r(n)}catch(n){d.system.error(`${e} failed`,n),o(t(`update.settings.failed`,{action:g(e),reason:MN(n)}))}finally{i(!1)}}}let u=e.status===`disabled`,f=r||e.status===`checking`||e.status===`downloading`,p=`${t(`update.settings.running`,{version:e.currentVersion??t(`update.settings.unknownVersion`)})} ${RN(e,t)}`,m=[`available`,`downloaded`,`error`].includes(e.status)||!!e.pinnedVersion||!!e.installFailed||!!e.configError||!!a;return P(bN,{title:t(`update.settings.title`),titleId:`updates-label`,hint:p,forceOpen:m,children:V(`div`,{className:`settings-field`,role:`group`,"aria-labelledby":`updates-label`,children:[P(`p`,{className:`visually-hidden`,role:`status`,children:p}),V(`label`,{className:`setting-row`,children:[P(`span`,{children:t(`update.settings.auto`)}),V(`span`,{className:`toggle-switch`,children:[P(`input`,{type:`checkbox`,role:`switch`,checked:e.autoUpdate,"aria-describedby":`updates-auto-hint`,"aria-label":t(`update.settings.auto`),"aria-busy":r,disabled:u,onChange:()=>{r||l(`update.action.saveAuto`,t=>t.setAutoUpdate(!e.autoUpdate))}}),P(`span`,{className:`toggle-track`})]})]}),P(`p`,{className:`settings-hint`,id:`updates-auto-hint`,children:t(`update.settings.autoHint`)}),V(`label`,{className:`setting-row`,children:[P(`span`,{children:t(`update.settings.rc`)}),V(`span`,{className:`toggle-switch`,children:[P(`input`,{type:`checkbox`,role:`switch`,checked:!!e.includePrereleases,"aria-describedby":`updates-rc-hint`,"aria-label":t(`update.settings.rc`),"aria-busy":r,disabled:u,onChange:()=>{r||l(`update.action.saveRc`,t=>t.setIncludePrereleases(!e.includePrereleases))}}),P(`span`,{className:`toggle-track`})]})]}),V(`p`,{className:`settings-hint`,id:`updates-rc-hint`,children:[t(`update.settings.rcHint`),LN(e.currentVersion)&&` ${t(`update.settings.rcHintRunning`)}`]}),e.pinnedVersion&&V(`p`,{className:`settings-hint`,children:[t(`update.settings.pinned`,{version:e.pinnedVersion}),` `,P(`button`,{type:`button`,className:`btn-secondary`,disabled:r,onClick:()=>void l(`update.action.resume`,e=>e.resumeUpdates()),children:t(`update.settings.unpin`)})]}),V(`div`,{className:`setting-actions`,children:[e.status===`available`&&!e.pinnedVersion&&P(`button`,{type:`button`,className:`btn-primary`,disabled:r,onClick:()=>void l(`update.action.download`,e=>e.downloadUpdate()),children:t(`update.settings.updateTo`,{version:e.version??``})}),e.status===`downloaded`&&P(`button`,{type:`button`,className:`btn-primary`,disabled:r,onClick:()=>void l(`update.action.restart`,e=>e.restart()),children:t(`update.settings.restart`)}),P(`button`,{type:`button`,className:`btn-secondary`,disabled:f||u,onClick:()=>void l(`update.action.check`,e=>e.check()),children:t(`update.settings.check`)}),P(`button`,{type:`button`,className:`btn-secondary`,disabled:f||u,onClick:()=>c(!0),children:t(`update.settings.pick`)}),e.previousVersion&&P(`button`,{type:`button`,className:`btn-secondary`,"aria-describedby":`updates-back-hint`,disabled:f||u,onClick:()=>void l(`update.action.goBack`,e=>e.revertUpdate()),children:t(`update.settings.goBack`,{version:e.previousVersion})})]}),e.previousVersion&&P(`p`,{className:`settings-hint`,id:`updates-back-hint`,children:t(`update.settings.goBackHint`)}),e.installFailed&&P(`p`,{className:`settings-error`,role:`alert`,children:t(`update.settings.installFailed`,{...e.installFailed,url:IN})}),e.lastCheckError&&P(`p`,{className:`settings-hint`,children:t(`update.settings.lastCheckError`,{reason:e.lastCheckError})}),e.configError&&P(`p`,{className:`settings-error`,role:`alert`,children:e.configError}),a&&P(`p`,{className:`settings-error`,role:`alert`,children:a}),s&&P(FN,{onClose:()=>c(!1)})]})})}var BN=[{value:`light`,label:`settings.theme.light`},{value:`dark`,label:`settings.theme.dark`},{value:`system`,label:`settings.theme.system`}],VN={default:`palette.default`,stone:`palette.stone`,marble:`palette.marble`,glacier:`palette.glacier`,forest:`palette.forest`,sage:`palette.sage`,basalt:`palette.basalt`,gold:`palette.gold`,dusk:`palette.dusk`,custom:`settings.colors.custom`},HN=[[`Enter`,`settings.shortcut.send`],[`Shift+Enter`,`settings.shortcut.newLine`],[`Esc`,`settings.shortcut.stop`],[`Mod+Shift+O`,`settings.shortcut.newChat`],[`Mod+K`,`settings.shortcut.search`],[`Mod+B`,`settings.shortcut.sidebar`],[`Mod+,`,`settings.shortcut.settings`]];function UN(){let e=T(),t=k(e=>e.locale),n=k(e=>e.setLocale),r=k(e=>e.themePreference),i=k(e=>e.setThemePreference),a=k(e=>e.palette),o=k(e=>e.setPalette),s=k(e=>e.customColors),c=k(e=>e.setCustomColors),l=GO(e=>e.visible),u=GO(e=>e.setVisible),d=e=>t=>c({...s,[e]:t.target.value.toUpperCase()});return V(`div`,{className:`settings-pane`,children:[P(`h2`,{className:`settings-pane-title`,children:e(`settings.section.general`)}),V(`div`,{className:`settings-field`,children:[P(`label`,{className:`settings-label`,htmlFor:`ui-language`,children:e(`settings.language`)}),P(`select`,{id:`ui-language`,className:`settings-input`,value:t,onChange:e=>n(e.target.value),children:b.map(({meta:e})=>P(`option`,{value:e.code,lang:e.code,dir:e.dir,children:M(e)},e.code))}),P(`span`,{className:`settings-hint`,children:e(`settings.languageHint`)})]}),V(`div`,{className:`settings-field`,children:[P(`span`,{className:`settings-label`,id:`appearance-label`,children:e(`settings.appearance`)}),P(`div`,{className:`segmented`,role:`radiogroup`,"aria-labelledby":`appearance-label`,children:BN.map(t=>P(`button`,{type:`button`,role:`radio`,"aria-checked":r===t.value,className:r===t.value?`is-active`:``,onClick:()=>i(t.value),children:e(t.label)},t.value))})]}),V(`div`,{className:`settings-field`,children:[V(`label`,{className:`setting-row`,children:[P(`span`,{children:e(`resources.settings`)}),V(`span`,{className:`toggle-switch`,children:[P(`input`,{type:`checkbox`,checked:l,onChange:e=>u(e.target.checked),"aria-label":e(`resources.settings`),"aria-describedby":`resources-hint`}),P(`span`,{className:`toggle-track`})]})]}),P(`span`,{className:`settings-hint`,id:`resources-hint`,children:e(`resources.settingsHint`)})]}),V(bN,{title:e(`settings.colors`),titleId:`palette-label`,defaultOpen:a===`custom`,children:[V(`div`,{className:`palette-grid`,role:`radiogroup`,"aria-labelledby":`palette-label`,children:[oe.map(t=>V(`button`,{type:`button`,role:`radio`,"aria-checked":a===t.id,className:`palette-tile${a===t.id?` is-active`:``}`,onClick:()=>o(t.id),children:[P(`span`,{className:`palette-swatch`,"aria-hidden":`true`,children:t.swatch.map(e=>P(`i`,{style:{background:e}},e))}),e(VN[t.id])]},t.id)),V(`button`,{type:`button`,role:`radio`,"aria-checked":a===`custom`,className:`palette-tile${a===`custom`?` is-active`:``}`,onClick:()=>o(`custom`),children:[V(`span`,{className:`palette-swatch`,"aria-hidden":`true`,children:[P(`i`,{style:{background:s.base}}),P(`i`,{style:{background:s.accent}})]}),e(`settings.colors.custom`)]})]}),a===`custom`&&V(`div`,{className:`palette-custom`,children:[V(`label`,{className:`palette-color`,htmlFor:`custom-accent`,children:[P(`input`,{id:`custom-accent`,type:`color`,value:s.accent,onChange:d(`accent`)}),V(`span`,{children:[e(`settings.colors.accent`),P(`small`,{children:e(`settings.colors.accentHint`)})]})]}),V(`label`,{className:`palette-color`,htmlFor:`custom-base`,children:[P(`input`,{id:`custom-base`,type:`color`,value:s.base,onChange:d(`base`)}),V(`span`,{children:[e(`settings.colors.base`),P(`small`,{children:e(`settings.colors.baseHint`)})]})]}),P(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>c(v),children:e(`settings.colors.reset`)}),P(`p`,{className:`settings-hint`,children:e(`settings.colors.hint`)})]})]}),P(EN,{}),P(zN,{}),P(bN,{title:e(`settings.shortcuts`),children:P(`dl`,{className:`shortcut-list`,children:HN.map(([t,n])=>V(`div`,{className:`shortcut-row`,children:[P(`dt`,{children:P(`kbd`,{children:kc(t)})}),P(`dd`,{children:e(n)})]},t))})})]})}function WN(e){return/not reachable|not answering|model server at|ConnectionPool|NewConnectionError|Connection refused|Max retries/i.test(e)}function GN(e){return/gaia init/i.test(e??``)}function KN(e){return!!e&&!e.lemonade_running&&(GN(e.start_command)||GN(e.start_instruction))}function qN({className:e=`btn-secondary`}){let t=T();return P(`button`,{type:`button`,className:e,onClick:()=>window.dispatchEvent(new CustomEvent(`gaia:set-up-local`)),children:t(`settings.errors.setUpLocal`)})}function JN({message:e,onRetry:t}){let n=T(),r=k(e=>KN(e.systemStatus));return WN(e)?V(`div`,{className:`settings-notice`,role:`alert`,children:[P(`strong`,{children:n(r?`settings.errors.notInstalledTitle`:`settings.errors.serverDownTitle`)}),P(`p`,{children:n(r?`settings.errors.notInstalled`:`settings.errors.serverDown`)}),r&&P(qN,{className:`btn-primary`}),t&&P(`button`,{type:`button`,className:`btn-secondary`,onClick:t,children:n(`settings.key.checkAgain`)}),V(`details`,{className:`settings-more`,children:[V(`summary`,{children:[P(hr,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,n(`settings.errors.details`)]}),P(`bdi`,{dir:`ltr`,className:`settings-notice-raw`,children:e})]})]}):P(`p`,{className:`settings-error`,role:`alert`,children:e})}function YN({onAdded:e}){let t=T(),[n,r]=(0,J.useState)(``),[i,a]=(0,J.useState)(``),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(null),[u,d]=(0,J.useState)(null),f=(0,J.useRef)(``),p=(0,J.useCallback)(async e=>{let t=n.trim();f.current=t,l(`check`),d(null);try{let n=await sn(t,e);if(f.current!==t)return;s(n),a(n.file??e)}catch(e){if(f.current!==t)return;s(null),d(e instanceof Error?e.message:String(e))}finally{l(null)}},[n]),m=(0,J.useCallback)(async()=>{l(`add`),d(null);try{let{report:o}=await xt(n.trim(),i);r(``),a(``),s(null),e(o.display_name??o.model_id??t(`settings.custom.theModel`))}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(null)}},[e,i,n,t]);return V(`form`,{className:`settings-field custom-model-add`,onSubmit:e=>{e.preventDefault(),p(``)},children:[P(`label`,{className:`visually-hidden`,htmlFor:`custom-model-url`,children:t(`settings.custom.title`)}),P(`span`,{className:`settings-hint`,children:t(`settings.custom.hint`)}),V(`div`,{className:`settings-row`,children:[P(`input`,{id:`custom-model-url`,className:`settings-input`,type:`url`,inputMode:`url`,dir:`ltr`,spellCheck:!1,autoComplete:`off`,value:n,readOnly:c!==null,onChange:e=>{r(e.target.value),s(null),a(``),f.current=``},placeholder:`https://huggingface.co/unsloth/Qwen3-4B-Instruct-2507-GGUF`}),V(`button`,{type:`submit`,className:`btn-secondary`,disabled:c!==null||!n.trim(),children:[c===`check`?P(K,{size:13,className:`spin`}):null,` `,t(`settings.custom.check`)]})]}),o&&(()=>{let e=P(`ul`,{className:`custom-model-checks`,"aria-label":t(`settings.custom.checks`),children:o.checks.map(e=>V(`li`,{className:e.ok?`is-ok`:`is-failed`,children:[e.ok?P(pr,{size:13,"aria-label":t(`settings.custom.passed`)}):P(So,{size:13,"aria-label":t(`settings.custom.failed`)}),V(`bdi`,{children:[P(`strong`,{children:e.label}),` — `,e.detail]})]},e.id))});return o.ok?V(`details`,{className:`custom-model-checks-summary`,children:[V(`summary`,{children:[P(pr,{size:13,"aria-hidden":`true`}),` `,t(`settings.custom.allPassed`,{n:o.checks.length})]}),e]}):e})(),o&&o.warnings.length>0&&P(`ul`,{className:`custom-model-checks`,"aria-label":t(`settings.custom.warnings`),children:o.warnings.map(e=>V(`li`,{className:`is-warning`,children:[P(q,{size:13,"aria-label":t(`settings.custom.warning`)}),` `,P(`bdi`,{children:e})]},e))}),o&&o.variants.length>1&&V(`div`,{className:`settings-row`,children:[P(`label`,{className:`settings-hint`,htmlFor:`custom-model-quant`,children:t(`settings.custom.quantization`)}),P(`select`,{id:`custom-model-quant`,className:`settings-input`,value:i,onChange:e=>void p(e.target.value),disabled:c!==null,children:o.variants.map(e=>V(`option`,{value:e.file,children:[e.quant,` · `,e.size_gb,` GB`,e.fits?``:` · ${t.bare(`settings.custom.tooLarge`)}`]},e.file))})]}),o?.ok&&V(`div`,{className:`settings-row`,children:[V(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void m(),disabled:c!==null,children:[c===`add`?P(K,{size:13,className:`spin`}):null,` `,t(`settings.custom.add`,{name:o.display_name??``})]}),P(`span`,{className:`settings-hint`,children:t(`settings.model.sizeDownload`,{size:`${o.size_gb} GB`})})]}),u&&P(JN,{message:u})]})}function XN(e){return e instanceof Error?e.message:String(e)}function ZN(e,t){return e.size===t.size&&[...e].every(e=>t.has(e))}function QN({downloadsSlot:e}){let t=T(),[n,r]=(0,J.useState)(null),[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(null),[u,d]=(0,J.useState)(!1),[f,p]=(0,J.useState)(null),[m,h]=(0,J.useState)(!1),[g,_]=(0,J.useState)(null),[v,y]=(0,J.useState)(null),b=Ls(e=>e.status),x=Ls(e=>e.started),S=(0,J.useMemo)(()=>Ps(b,x),[b,x]),C=Ls(e=>e.error),w=Ls(e=>e.refresh),E=Ls(e=>e.enqueue),O=Ls(e=>e.cancel),k=(0,J.useCallback)(async(e=!1)=>{a(null);try{let t=await ot();r(t),s(n=>e||!n?uj(t):n)}catch(e){a(XN(e))}},[]);(0,J.useEffect)(()=>{k(!0),w(),(async()=>{try{_(await Xe()??null)}catch(e){y(XN(e))}})()},[k,w]);let A=(S?.models??[]).filter(e=>e.state===`ready`).map(e=>e.id).join(`,`),j=(0,J.useRef)(A);(0,J.useEffect)(()=>{A!==j.current&&(j.current=A,k(!0))},[A,k]);let M=(0,J.useMemo)(()=>{let e={};for(let t of S?.models??[])e[t.id]=t;return e},[S]),N=(0,J.useMemo)(()=>{let e={};for(let t of n?.catalog??[])e[t.id]=t.name;return e},[n]),F=(0,J.useMemo)(()=>n?uj(n):null,[n]),I=YA(n),L=n&&o?hj(I,o).filter(e=>M[e.id]?.state!==`downloading`):[],ee=L.reduce((e,t)=>e+(t.size_gb??0),0),R=!!n&&!!o&&!!F&&(!ZN(o.ticked,F.ticked)||o.defaultChat!==F.defaultChat||L.length>0),z=(0,J.useCallback)(async(e,i)=>{if(!n||!o)return;if(p(null),!e){let e=vj(I,o).filter(e=>!e.downloaded||e.id===o.defaultChat);if(e.length>0&&e.every(e=>e.need_gb!=null)){l({kind:`no_fit`,models:e});return}}let a=_j(n,o);if(a&&!i)l({kind:`low_disk`,message:a.drop?t(`setup.summary.shortDrop`,{need:$(a.needGb),free:$(a.freeGb),drive:Mj(n.disk?.path??null)??t(`setup.summary.theDrive`),freeUp:$(a.freeUpGb),name:a.drop.name,saves:$(a.drop.size_gb??0)}):t(`setup.summary.short`,{need:$(a.needGb),free:$(a.freeGb),drive:Mj(n.disk?.path??null)??t(`setup.summary.theDrive`),freeUp:$(a.freeUpGb)})});else{d(!0);try{let i=n;if(o.defaultChat&&o.defaultChat!==i.chat_model.id)try{i=await Wt(o.defaultChat,e||m)}catch(e){let t=Oe(e);if(t){l({kind:`server`,detail:t});return}throw e}for(let e of yj(i,o))i=await ht(e.id,e.skipped);let a=hj(YA(i),o).map(e=>e.id).filter(e=>M[e]?.state!==`downloading`);r(i),s({...o,defaultChat:i.chat_model.id}),cs.getState().refresh(),a.length&&await E(a,{acknowledgeLowDisk:!0}),p({ok:!0,text:t(`settings.models.applied`)})}catch(e){p({ok:!1,text:XN(e)})}finally{d(!1)}}},[n,o,I,m,M,E,t]),B=(0,J.useCallback)(async e=>{l(null),d(!0),p(null);try{let n=await je(e.id);Uo(),r(n),s(uj(n)),p({ok:!0,text:t(`settings.models.removed`,{name:e.name,size:$(n.freed_gb)})})}catch(e){p({ok:!1,text:XN(e)})}finally{d(!1)}},[t]),te=(0,J.useCallback)((e,t)=>{(async()=>{try{t===`verify`&&await je(e),await E([e])}catch(e){p({ok:!1,text:XN(e)})}})()},[E]),ne=!!S&&(S.models?.length??0)>0&&(xM(S)||S.models.some(e=>e.state!==`skipped`))&&S&&V(`section`,{className:`settings-field models-pane-section`,"aria-labelledby":`settings-downloads-title`,children:[P(`span`,{className:`settings-label`,id:`settings-downloads-title`,children:t(`settings.models.downloads`)}),P(wM,{status:S,names:N,freeGb:n?.disk?.free_gb??null,onCancel:()=>void O(),onRetry:te,onResume:e=>void E([e]),onResumeAll:()=>void E((S.models??[]).filter(e=>e.state===`cancelled`).map(e=>e.id))}),C&&P(`p`,{className:`settings-error`,role:`alert`,children:C})]});return V(D.Fragment,{children:[P(bN,{title:t(`settings.models.manage`),hint:t(`settings.models.manageHint`),forceOpen:!!i||f?.ok===!1,children:V(`section`,{className:`settings-field models-pane-section`,"aria-labelledby":`settings-models-title`,children:[P(`span`,{className:`visually-hidden`,id:`settings-models-title`,children:t(`settings.models.title`)}),P(`p`,{className:`settings-hint`,children:t(`settings.models.lede`)}),i&&P(JN,{message:i}),n&&!n.lemonade.reachable&&P(`p`,{className:`settings-hint`,children:t(`settings.models.unavailable`)}),!n&&!i&&V(`p`,{className:`settings-hint`,children:[P(K,{size:13,className:`spin`,"aria-hidden":`true`}),` `,t(`setup.models.loading`)]}),n&&n.lemonade.reachable&&o&&V(D.Fragment,{children:[P(Pj,{plan:n,selection:o,onToggle:(e,t)=>s(fj(o,I,e,t)),onDefaultChat:e=>s(pj(o,I,e)),labelledBy:`settings-models-title`,place:`settings`,disabled:u,progress:M,rowActions:e=>e.downloaded&&e.id!==o.defaultChat?P(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>l({kind:`remove`,entry:e}),disabled:u||M[e.id]?.state===`downloading`,"aria-label":t(`settings.models.removeAria`,{name:e.name}),children:t(`settings.models.remove`)}):null}),P(jj,{plan:n,selection:o}),P(`div`,{className:`models-apply`,children:V(`button`,{type:`button`,className:`btn-primary`,disabled:!R||u,onClick:()=>void z(!1,!1),children:[u&&P(K,{size:13,className:`spin`,"aria-hidden":`true`}),u?t(`settings.models.applying`):L.length>0?t(`settings.models.applyDownload`,{size:$(Math.round(ee*10)/10)}):t(`settings.models.apply`)]})})]}),f?.ok&&P(`p`,{className:`settings-ok`,role:`status`,children:f.text}),f&&!f.ok&&P(JN,{message:f.text})]})}),(g?.applies||v&&!WN(v))&&P(bN,{title:t(`gpu.settingsTitle`),titleId:`settings-gpu-title`,defaultOpen:!!g?.pending||!!v,children:V(`section`,{className:`settings-field models-pane-section`,"aria-labelledby":`settings-gpu-title`,children:[v&&P(`p`,{className:`settings-error`,role:`alert`,children:v}),g?.applies&&P($j,{status:g,onStatus:_,mode:`settings`,names:N,headingId:`settings-gpu-title`})]})}),e?(0,Qx.createPortal)(ne,e):e===void 0&&ne,c?.kind===`remove`&&P(Wj,{title:t(`settings.models.removeTitle`,{name:c.entry.name}),confirmLabel:t(`settings.models.removeConfirm`),cancelLabel:t(`settings.models.keep`),danger:!0,onConfirm:()=>void B(c.entry),onCancel:()=>l(null),children:P(`p`,{children:XA(c.entry)?t(`settings.models.removeVision`,{size:$(c.entry.full_size_gb??0)}):t(`settings.models.removeBody`,{size:$(c.entry.full_size_gb??0)})})}),c?.kind===`no_fit`&&P(Wj,{title:c.models.length===1?t(`setup.confirm.noFitOne`,{name:c.models[0].name}):t(`setup.confirm.noFitMany`),confirmLabel:t(`setup.confirm.downloadAnyway`),cancelLabel:t(`setup.confirm.pickSmaller`),onConfirm:()=>{l(null),h(!0),z(!0,!1)},onCancel:()=>l(null),children:c.models.map(e=>V(`p`,{children:[P(`bdi`,{children:e.name}),`: `,Oj(e,t)]},e.id))}),c?.kind===`low_disk`&&P(Wj,{title:t(`setup.confirm.lowDiskTitle`),confirmLabel:t(`setup.confirm.downloadAnyway`),cancelLabel:t(`setup.confirm.changeModels`),onConfirm:()=>{l(null),z(!0,!0)},onCancel:()=>l(null),children:P(`p`,{children:c.message})}),c?.kind===`server`&&P(Wj,{title:t(`setup.confirm.noFitServerTitle`),confirmLabel:t(`setup.confirm.useAnyway`),cancelLabel:t(`setup.confirm.changeModels`),onConfirm:()=>{l(null),h(!0),z(!0,!1)},onCancel:()=>l(null),children:P(`p`,{children:c.detail.message})})]})}var $N=`auto`;function eP({model:e}){let t=T(),[n,r]=(0,J.useState)(null),[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(null);(0,J.useEffect)(()=>{r(null),a(null),l(null),_e(e).then(r).catch(e=>a(e instanceof Error?e.message:String(e)))},[e]);let u=(0,J.useCallback)(async n=>{s(!0),a(null),l(null);try{let i=await Ke(e,n===$N?null:Number(n));r(i);let a={name:i.display_name,size:i.chosen?Cs(i.chosen):g(`settings.ctx.automaticSize`)},o=i.reload?.reason;i.reload?.started?l(t(`settings.ctx.reloading`,a)):l(o===`already_loaded`?t(`settings.ctx.alreadyLoaded`,a):o===`warm_up`?t(`settings.ctx.warmUp`,a):o===`busy`?t(`settings.ctx.busy`,a):o===`not_gaias_server`?t(`settings.ctx.ownServer`,a):t(o===`restarting`?`settings.ctx.restarting`:`settings.ctx.nextLoad`))}catch(e){a(e instanceof Error?e.message:String(e))}finally{s(!1)}},[e,t]);if(i&&!n)return WN(i)?P(`p`,{className:`settings-hint`,children:t(`settings.ctx.serverDown`)}):P(`p`,{className:`settings-error`,role:`alert`,children:i});if(!n)return V(`p`,{className:`settings-hint`,children:[P(K,{size:13,className:`spin`}),` `,t(`settings.ctx.checking`)]});let d=n.chosen==null?$N:String(n.chosen),f=n.chosen!=null&&n.loaded_ctx!=null&&n.loaded_ctx!==n.chosen;return V(D.Fragment,{children:[V(`div`,{className:`model-in-use-field`,children:[P(`label`,{className:`settings-label`,htmlFor:`ctx-size`,children:t(`settings.ctx.label`)}),V(`select`,{id:`ctx-size`,className:`settings-input`,value:d,onChange:e=>void u(e.target.value),disabled:o||n.options.length===0,children:[P(`option`,{value:$N,children:n.automatic?t.bare(`settings.ctx.automaticAt`,{size:Cs(n.automatic)}):t.bare(`settings.ctx.automatic`)}),n.options.map(e=>P(`option`,{value:String(e),children:t.bare(`settings.ctx.tokens`,{size:Cs(e)})},e))]})]}),n.note&&P(`span`,{className:`settings-hint`,children:P(`bdi`,{children:n.note})}),!n.note&&!!n.max_fit&&V(`details`,{className:`settings-more`,children:[V(`summary`,{children:[P(hr,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,t(`settings.ctx.about`)]}),P(`span`,{className:`settings-hint`,children:t(`settings.ctx.explain`,{size:Cs(n.max_fit),name:n.display_name,memory:n.memory_source})})]}),f&&P(`span`,{className:`settings-hint`,children:t(`settings.ctx.loadedAt`,{size:Cs(n.loaded_ctx)})}),o&&V(`span`,{className:`settings-hint`,children:[P(K,{size:13,className:`spin`}),` `,t(`settings.ctx.applying`)]}),c&&P(`p`,{className:`settings-ok`,role:`status`,children:c}),i&&P(`p`,{className:`settings-error`,role:`alert`,children:i})]})}function tP({row:e,providerName:t,choices:n,labels:r,disabled:i,onSwitch:a}){let o=T(),s=cs(e=>e.active),c=s?.model??null,l=!!s?.remote,u=n.some(e=>us(c,e.id)),d=s?.downloaded??e?.downloaded,f=l?null:e?.state===`loaded`?o(`settings.model.loaded`):d===!0?o(`settings.model.downloaded`):d===!1?o(`settings.model.notDownloaded`):null,p=e?.placement?.device;return V(`section`,{className:`settings-card model-in-use`,"aria-label":o(`settings.model.inUseTitle`),children:[P(`span`,{className:`model-in-use-label`,children:o(`settings.model.inUseTitle`)}),c?P(`bdi`,{className:`model-in-use-name`,title:c,children:e?.display_name||s?.display_name||ds(c)}):P(`span`,{className:`settings-hint`,children:o(`settings.model.noneInUse`)}),s?.config_error&&P(`p`,{className:`settings-error`,role:`alert`,children:P(`bdi`,{children:s.config_error})}),c&&!l&&e?.available===!1&&P(`p`,{className:`settings-error`,role:`alert`,children:o(`settings.model.inUseCantRun`)}),c&&V(`span`,{className:`model-chips`,children:[l&&P(`span`,{className:`model-badge is-device`,children:o(`settings.model.cloud`)}),l&&t&&P(`bdi`,{className:`model-badge is-ready`,children:t}),p&&P(`span`,{className:`model-badge is-device`,children:p.toUpperCase()}),f&&P(`span`,{className:`model-badge ${e?.state===`loaded`?`is-loaded`:`is-ready`}`,children:f}),e?.fits===!0&&P(`span`,{className:`model-badge is-fit`,children:o(`settings.model.fits`)}),!!e?.size_gb&&V(`bdi`,{dir:`ltr`,className:`model-badge is-size`,children:[e.size_gb,` GB`]}),l&&!!e?.context_length&&P(`span`,{className:`model-badge is-ready`,children:o(`settings.model.contextChip`,{size:Cs(e.context_length)})})]}),(n.length>1||n.length===1&&!u)&&V(`div`,{className:`model-in-use-field`,children:[P(`label`,{className:`settings-label`,htmlFor:`model-switch`,children:o(`settings.model.switch`)}),V(`select`,{id:`model-switch`,className:`settings-input`,value:u?n.find(e=>us(c,e.id))?.id:``,onChange:e=>a(e.target.value),disabled:i,children:[!u&&P(`option`,{value:``,disabled:!0,children:o.bare(`settings.model.switchPlaceholder`)}),n.map(e=>P(`option`,{value:e.id,children:r[e.id]},e.id))]})]}),c&&!l&&s?.downloaded!==!1&&P(eP,{model:c})]})}function nP({model:e,label:t,current:n,remote:r,busy:i,confirmingRemove:a,onUse:o,onDownload:s,onAskRemove:c,onKeep:l,onRemove:u,onNpuRecheck:d}){let f=T(),p=Ts(e)?e.download_progress:null,m=e.placement?.label,h=f.compose(t=>[m&&(e.placement?.source===`expected`?t(`settings.model.expected`,{label:m}):m),e.size_gb?t(e.downloaded?`settings.model.sizeOnDisk`:`settings.model.sizeDownload`,{size:`${e.size_gb} GB`}):null,e.tokens_per_second?t(`settings.model.speed`,{speed:`${Math.round(e.tokens_per_second)} tok/s`}):null,!e.placement&&e.context_length?t(`settings.model.contextTokens`,{size:e.context_length.toLocaleString()}):null].filter(Boolean).join(` · `)),g=!!(e.display_name||h||e.evidence||e.custom&&e.source_url);return V(`li`,{className:`model-row${n?` is-current`:``}`,children:[V(`div`,{className:`model-row-text`,children:[P(`bdi`,{className:`model-row-name`,title:e.id,children:t}),V(`div`,{className:`model-chips`,children:[e.placement?.device&&P(`span`,{className:`model-badge is-device`,children:e.placement.device.toUpperCase()}),e.rank&&V(`span`,{className:`model-badge is-rank`,children:[V(`bdi`,{dir:`ltr`,children:[`#`,e.rank]}),` `,e.note]}),e.state===`loaded`&&P(`span`,{className:`model-badge is-loaded`,children:f(`settings.model.loaded`)}),e.fits===!0&&e.available!==!1&&P(`span`,{className:`model-badge is-fit`,children:f(`settings.model.fits`)}),e.custom&&P(`span`,{className:`model-badge is-custom`,children:f(`settings.model.custom`)}),!!e.size_gb&&V(`bdi`,{dir:`ltr`,className:`model-badge is-size`,children:[e.size_gb,` GB`]}),g&&V(`details`,{className:`settings-more`,children:[V(`summary`,{children:[P(hr,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,f(`settings.model.details`)]}),e.display_name&&P(`span`,{className:`model-row-meta`,children:P(`bdi`,{children:e.id})}),h&&P(`span`,{className:`model-row-meta`,children:h}),e.evidence&&P(`span`,{className:`model-row-meta`,children:f(`settings.model.measured`,{evidence:e.evidence})}),e.custom&&e.source_url&&P(`span`,{className:`model-row-meta`,children:f(`settings.model.from`,{url:e.source_url})})]})]}),r&&P(`span`,{className:`model-row-meta${e.price?``:` is-unknown-price`}`,children:XT(e.price,f)}),e.placement?.warning&&P(`span`,{className:`model-row-meta is-warning`,role:`alert`,children:P(`bdi`,{children:e.placement.warning})}),e.npu_problems?.length?P(MM,{problems:e.npu_problems,disabled:i!==null,onRecheck:d,id:`npu-problems-${e.id}`}):e.unavailable_reason&&P(`span`,{className:`model-row-meta`,children:f(`settings.model.cantRun`,{reason:e.unavailable_reason})}),p&&P(`progress`,{max:100,value:p.percent,"aria-label":f(`settings.model.downloadingAria`,{name:t})})]}),V(`div`,{className:`model-row-actions`,children:[e.custom&&!n&&!p&&(a?V(D.Fragment,{children:[V(`button`,{type:`button`,className:`btn-danger`,onClick:u,disabled:i!==null,children:[i===`rm:${e.id}`?P(K,{size:13,className:`spin`}):null,e.downloaded?f(`settings.model.removeDownload`):f(`settings.models.remove`)]}),P(`button`,{type:`button`,className:`btn-secondary`,onClick:l,disabled:i!==null,children:f(`settings.models.keep`)})]}):P(`button`,{type:`button`,className:`btn-secondary`,onClick:c,disabled:i!==null,"aria-label":f(`settings.models.removeAria`,{name:t}),children:f(`settings.models.remove`)})),n&&e.available===!1?P(`span`,{className:`model-row-current is-blocked`,children:f(`settings.model.inUseBlocked`)}):n?V(`span`,{className:`model-row-current`,children:[P(pr,{size:13,"aria-hidden":`true`}),` `,f(`settings.model.inUse`)]}):e.available===!1?null:p?V(`span`,{className:`model-row-current`,children:[P(K,{size:13,className:`spin`}),` `,p.message?P(`bdi`,{children:p.message}):V(`bdi`,{dir:`ltr`,children:[Math.round(p.percent),`%`]})]}):e.downloaded?V(`button`,{type:`button`,className:`btn-secondary`,onClick:o,disabled:i!==null,"aria-label":f(`settings.model.useAria`,{name:t}),children:[i===e.id?P(K,{size:13,className:`spin`}):null,` `,f(`settings.model.use`)]}):V(`button`,{type:`button`,className:`btn-secondary`,onClick:s,disabled:i!==null,"aria-label":f(`settings.model.downloadAria`,{name:t}),children:[i===`dl:${e.id}`?P(K,{size:13,className:`spin`}):null,` `,f(`settings.model.download`)]})]})]})}function rP(){let e=T(),[t,n]=(0,J.useState)(null),[r,i]=(0,J.useState)(null),[a,o]=(0,J.useState)(``),[s,c]=(0,J.useState)(!1),l=(0,J.useCallback)(async e=>{c(!0),i(null);try{let t=await e();n(t),o(t.limit_usd==null?``:String(t.limit_usd))}catch(e){i(e instanceof Error?e.message:String(e))}finally{c(!1)}},[]);if((0,J.useEffect)(()=>{l(H)},[l]),!t)return r?P(`p`,{className:`settings-error`,role:`alert`,children:r}):V(`p`,{className:`settings-hint`,children:[P(K,{size:13,className:`spin`}),` `,e(`settings.spend.loading`)]});let u=t.limit_usd,d=a.trim()===``?null:Number(a),f=d===null||Number.isFinite(d)&&d>0,p=d!==u;return V(`section`,{className:`settings-field spending`,"aria-label":e(`settings.spend.aria`),children:[P(`span`,{className:`settings-label`,children:e(`settings.spend.title`)}),V(`p`,{className:`spending-total`,children:[P(`bdi`,{dir:`ltr`,children:P(`strong`,{children:ZT(t.total_usd)})}),u!=null&&V(D.Fragment,{children:[` `,e(`settings.spend.ofLimit`,{limit:ZT(u)})]}),V(`span`,{className:`settings-hint`,children:[` · `,e.plural(`settings.spend.turns`,t.turns)]})]}),t.unpriced_turns>0&&P(`p`,{className:`settings-hint`,children:e.plural(`settings.spend.unpriced`,t.unpriced_turns)}),t.unreported_turns>0&&P(`p`,{className:`settings-hint`,children:e.plural(`settings.spend.unreported`,t.unreported_turns)}),t.state===`near`&&V(`p`,{className:`spending-warning`,role:`status`,children:[P(q,{size:13,"aria-hidden":`true`}),` `,e(`settings.spend.near`)]}),t.state===`reached`&&V(`div`,{className:`spending-warning`,role:`alert`,children:[V(`p`,{children:[P(q,{size:13,"aria-hidden":`true`}),` `,e(`settings.spend.reached`)]}),P(`button`,{type:`button`,className:`btn-secondary`,disabled:s,onClick:()=>void l(hn),children:e(`settings.spend.allow`)})]}),t.state===`allowed_over`&&P(`p`,{className:`settings-hint`,children:e(`settings.spend.allowed`)}),V(`form`,{className:`settings-row`,onSubmit:e=>{e.preventDefault(),f&&p&&l(()=>Ze(d))},children:[P(`label`,{className:`spending-limit-label`,htmlFor:`spend-limit`,children:e(`settings.spend.limit`)}),P(`input`,{id:`spend-limit`,className:`settings-input`,type:`number`,min:`0.01`,step:`0.01`,inputMode:`decimal`,placeholder:e.bare(`settings.spend.noLimit`),value:a,onChange:e=>o(e.target.value),"aria-invalid":!f}),V(`button`,{type:`submit`,className:`btn-secondary`,disabled:s||!f||!p,children:[s?P(K,{size:13,className:`spin`}):null,` `,e(`settings.advanced.save`)]}),u!=null&&P(`button`,{type:`button`,className:`btn-secondary`,disabled:s,onClick:()=>void l(()=>Ze(null)),children:e(`settings.spend.removeLimit`)})]}),P(`span`,{className:`settings-hint`,children:e(`settings.spend.how`)}),r&&P(`p`,{className:`settings-error`,role:`alert`,children:r})]})}var iP=2e3;function aP(e,t){return e.key_source===`environment`?t(`settings.key.setIn`,{name:e.env_var??``}):`••••••••••••••••••••${e.key_hint?` ${e.key_hint}`:``}`}function oP(){let e=T(),t=cs(e=>e.active),n=cs(e=>e.select),r=cs(e=>e.refresh),i=cs(e=>e.rememberNames),[a,o]=(0,J.useState)(null),[s,c]=(0,J.useState)(null),l=k(e=>e.settingsProvider),[u,d]=(0,J.useState)(l??t?.provider??`local`),[f,p]=(0,J.useState)(null),[m,h]=(0,J.useState)(null),[g,_]=(0,J.useState)(``),[v,y]=(0,J.useState)(!1),[b,x]=(0,J.useState)(``),[S,C]=(0,J.useState)(!1),[w,E]=(0,J.useState)(!1),[O,A]=(0,J.useState)({base_url:``,auth_header_name:``,auth_header_prefix:``}),[j,M]=(0,J.useState)(null),[N,F]=(0,J.useState)(null),[I,L]=(0,J.useState)(null),[ee,R]=(0,J.useState)(null),[z,B]=(0,J.useState)(!1),[te,ne]=(0,J.useState)(null),[re,ie]=(0,J.useState)(null),ae=(0,J.useRef)(u);ae.current=u;let oe=(0,J.useRef)(!0);(0,J.useEffect)(()=>(oe.current=!0,()=>{oe.current=!1}),[]);let H=a?.find(e=>e.id===u)??null,U=e=>e?.network?.reachable===!1,se=!!H&&(!H.remote||!!H.models_discovered),W=(0,J.useCallback)(async()=>{c(null);try{let e=await wn();o(e.providers),e.lemonade_error&&c(e.lemonade_error)}catch(e){c(e instanceof Error?e.message:String(e))}},[]),G=(0,J.useCallback)(async(e,t=!1)=>{t||(p(null),h(null));try{let t=await Zt(e);i(t.models),p(t.models),F(t.memory_gb?`${t.memory_gb} GB (${t.memory_source})`:t.capacity_error??null)}catch(e){h(e instanceof Error?e.message:String(e))}},[i]);(0,J.useEffect)(()=>{W()},[W]);let ce=!!a?.some(e=>e.key_state===`waiting_for_os_permission`);(0,J.useEffect)(()=>{if(!ce)return;let e=setInterval(()=>{W()},iP);return()=>clearInterval(e)},[ce,W]);let le=t?.provider;(0,J.useEffect)(()=>{le&&!l&&d(le)},[le,l]),(0,J.useEffect)(()=>{x(``),C(!1),E(!1),L(null),_(``),y(!1),B(!1)},[u]),(0,J.useEffect)(()=>{se?G(u):p(null)},[u,se,G]);let ue=(0,J.useCallback)(async()=>{if(H){M(`connect`),L(null);try{let t=u===`amd`?{api_key:b||void 0,...Object.fromEntries(Object.entries(O).filter(([,e])=>e!==``))}:{api_key:b||void 0},n=()=>!oe.current||ae.current!==u,r=await Rt(u,t,e=>{n()||L({ok:!0,text:e})},n);if(n())return;x(``),C(!1),L({ok:!0,text:r.remember_error?e(`settings.key.sessionOnly`,{reason:r.remember_error}):r.known_models?e(`settings.key.knownModels`,{name:H.name}):r.remembered?e(`settings.key.kept`):e(`settings.key.connectedDone`)}),await W()}catch(e){oe.current&&ae.current===u&&L({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{oe.current&&M(null)}}},[O,u,b,W,H,e]),de=(0,J.useCallback)(async()=>{M(`forget`),E(!1),L(null);try{await Kt(u),L({ok:!0,text:e(`settings.key.cleared`)}),await W(),await r()}catch(e){L({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{M(null)}},[u,W,r,e]),pe=(0,J.useCallback)(async t=>{M(t),L(null);try{await n(t),L({ok:!0,text:e(`settings.model.switched`,{name:ds(t)})}),await G(u,!0)}catch(e){L({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{M(null)}},[u,G,n,e]),me=(0,J.useCallback)(async e=>{M(`dl:${e}`),L(null),B(!1);try{await fe(e),await G(`local`,!0)}catch(e){L({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{M(null)}},[G]),he=(0,J.useCallback)(async t=>{M(`rm:${t}`),L(null);try{let n=await tt(t);R(null);let i=n.cleared.includes(`last_model`)?`settings.model.removedLast`:n.cleared.includes(`default_model`)?`settings.model.removedDefault`:`settings.model.removed`;L({ok:!0,text:e(i,{name:n.display_name})}),await G(`local`,!0),await r()}catch(e){L({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{M(null)}},[G,r,e]),ge=(0,J.useCallback)(async t=>{L({ok:!0,text:e(`settings.model.added`,{name:t})}),B(!0),await G(`local`,!0)},[G,e]),_e=!!f?.some(Ts);(0,J.useEffect)(()=>{if(_e)return()=>{r()}},[_e,r]),(0,J.useEffect)(()=>{if(u!==`local`||!_e)return;let e=setInterval(()=>{G(`local`,!0)},iP);return()=>clearInterval(e)},[_e,u,G]);let ve=t?.model,ye=f?.find(e=>us(ve,e.id));(0,J.useEffect)(()=>{ye&&ne(ye)},[ye]);let be=(0,J.useMemo)(()=>{let e=g.trim().toLowerCase();return(f??[]).filter(t=>!e||t.id.toLowerCase().includes(e)||(t.display_name??``).toLowerCase().includes(e))},[f,g]),xe=be.filter(e=>e.available!==!1),Se=u===`fireworks`&&!v&&!g.trim()&&xe.some(e=>e.rank!==null),Ce=e=>e.rank!==null||e.id===t?.model,we=Se?xe.filter(Ce):xe,Te=Se?xe.filter(e=>!Ce(e)):[],Ee=be.filter(e=>e.available===!1),De=ys(f??[]),Oe=!!g.trim(),ke=e=>us(t?.model,e.id),Ae=H?.id===`local`,je=we.filter(e=>e.downloaded).sort((e,t)=>Number(ke(t))-Number(ke(e))),Me=we.filter(e=>!e.downloaded),Ne=(f??[]).filter(e=>e.available!==!1&&e.downloaded),Pe=Ne.filter(Ce),Fe=u===`fireworks`&&Pe.some(e=>e.rank!==null)?Pe:Ne,Ie=e=>P(nP,{model:e,label:De[e.id],current:ke(e),remote:!!H?.remote,busy:j,confirmingRemove:ee===e.id,onUse:()=>void pe(e.id),onDownload:()=>void me(e.id),onAskRemove:()=>R(e.id),onKeep:()=>R(null),onRemove:()=>void he(e.id),onNpuRecheck:()=>void G(u,!0)},e.id);return V(`div`,{className:`settings-pane`,children:[P(`h2`,{className:`settings-pane-title`,children:e(`settings.section.model`)}),P(tP,{row:ye??(us(te?.id,t?.model)?te:null),providerName:a?.find(e=>e.id===t?.provider)?.name??null,choices:se?Fe:[],labels:De,disabled:j!==null,onSwitch:e=>void pe(e)}),P(`div`,{className:`provider-tabs`,role:`radiogroup`,"aria-label":e(`settings.model.whereRuns`),children:(a??[{id:`local`,name:`Local`,remote:!1}]).map(t=>V(`button`,{type:`button`,role:`radio`,"aria-checked":u===t.id,className:`provider-tab${u===t.id?` is-active`:``}${U(t)?` is-disabled`:``}`,onClick:()=>d(t.id),disabled:U(t)&&u!==t.id,title:U(t)?t.network?.detail??void 0:void 0,children:[t.remote?P(Fr,{size:14,"aria-hidden":`true`}):P(Ur,{size:14,"aria-hidden":`true`}),P(`span`,{children:t.name}),t.remote&&t.models_discovered&&P(`span`,{className:`provider-tab-dot`,"aria-label":e(`settings.key.connectedDot`)})]},t.id))}),s&&P(JN,{message:s,onRetry:()=>{W(),G(u)}}),H&&V(`section`,{className:`settings-card`,"aria-label":H.name,children:[H.remote&&P(`p`,{className:`settings-note`,children:P(`bdi`,{children:H.privacy_notice})}),V(`details`,{className:`settings-more`,children:[V(`summary`,{children:[P(hr,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,e(`settings.model.howItWorks`)]}),P(`p`,{className:`settings-hint`,children:e(`settings.model.lede`)}),Ae&&P(`p`,{className:`settings-hint`,children:P(`bdi`,{children:H.privacy_notice})}),Ae&&P(`p`,{className:`settings-hint`,children:e(`settings.model.devices`)}),Ae&&N&&P(`p`,{className:`settings-hint`,children:e(`settings.model.memory`,{memory:N})})]}),H.remote&&!se&&V(`div`,{className:`settings-field`,children:[P(`span`,{className:`settings-label`,children:e(`settings.model.prices`)}),P(HA,{provider:H.id})]}),U(H)&&V(`div`,{className:`settings-field`,children:[P(`p`,{className:`settings-error`,role:`alert`,children:H.network?.detail}),P(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void W(),children:e(`settings.key.checkAgain`)})]}),H.remote&&!U(H)&&V(`form`,{className:`settings-field`,onSubmit:e=>{e.preventDefault(),ue()},children:[V(`div`,{className:`settings-row settings-row-between`,children:[P(`span`,{className:`settings-label`,children:e(`settings.key.title`)}),H.key_source&&P(`span`,{className:`settings-key-status ${se?`settings-ok`:`settings-error`}`,children:e(se?`settings.key.connected`:`settings.key.notConnected`)})]}),!H.key_source&&P(`span`,{className:`settings-hint`,children:H.key_state===`waiting_for_os_permission`?H.key_message??e(`settings.key.waitingOs`):e(`settings.key.none`)}),H.id===`amd`&&(!H.key_source||S)&&V(`div`,{className:`settings-grid`,children:[P(`input`,{className:`settings-input`,placeholder:e(`settings.key.gatewayPlaceholder`),value:O.base_url,onChange:e=>A({...O,base_url:e.target.value}),"aria-label":e(`settings.key.gatewayUrl`)}),P(`input`,{className:`settings-input`,placeholder:e(`settings.key.headerPlaceholder`),value:O.auth_header_name,onChange:e=>A({...O,auth_header_name:e.target.value}),"aria-label":e(`settings.key.headerName`)})]}),H.key_source&&!S?V(`div`,{className:`settings-row`,children:[P(`input`,{className:`settings-input settings-key-masked`,readOnly:!0,value:aP(H,e),"aria-label":e(`settings.key.savedAria`,{name:H.name})}),!se&&V(`button`,{type:`submit`,className:`btn-primary`,disabled:j!==null,children:[j===`connect`?P(K,{size:13,className:`spin`}):null,e(`settings.key.reconnect`)]}),(H.key_source!==`environment`||H.key_from_gaia_env)&&(w?V(D.Fragment,{children:[P(`span`,{className:`settings-hint`,children:e(`settings.key.removeAsk`)}),P(`button`,{type:`button`,className:`btn-danger`,onClick:()=>void de(),disabled:j!==null,children:e(`settings.models.remove`)}),P(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>E(!1),children:e(`settings.models.keep`)})]}):V(D.Fragment,{children:[P(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>C(!0),disabled:j!==null,children:e(`settings.key.replace`)}),H.key_source!==`environment`&&P(`button`,{type:`button`,className:`btn-secondary settings-key-remove`,onClick:()=>E(!0),disabled:j!==null,"aria-label":e(`settings.key.remove`),title:e(`settings.key.remove`),children:P(co,{size:14,"aria-hidden":`true`})})]}))]}):V(`div`,{className:`settings-row`,children:[P(`input`,{className:`settings-input`,type:`password`,autoComplete:`off`,spellCheck:!1,autoFocus:S,value:b,onChange:e=>x(e.target.value),placeholder:e(S?`settings.key.pasteNew`:`settings.key.paste`),"aria-label":e(`settings.key.fieldAria`,{name:H.name})}),V(`button`,{type:`submit`,className:`btn-primary`,disabled:j!==null||!b,children:[j===`connect`?P(K,{size:13,className:`spin`}):null,e(S?`settings.key.save`:`settings.key.connect`)]}),S&&P(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{x(``),C(!1)},disabled:j!==null,children:e(`settings.key.cancel`)})]}),H.key_source&&!se&&!H.error&&!S&&P(`p`,{className:`settings-hint`,children:e(`settings.key.notConnectedHint`,{name:H.name})}),H.error&&P(`p`,{className:`settings-error`,role:`alert`,children:H.error})]}),I?.ok&&P(`p`,{className:`settings-ok`,role:`status`,children:I.text}),I&&!I.ok&&P(JN,{message:I.text}),H.known_models&&P(`p`,{className:`settings-hint`,role:`status`,children:e(`settings.key.knownList`,{name:H.name})}),Ae&&P(`div`,{className:`models-downloads-slot`,ref:ie}),se&&V(`div`,{className:`settings-field`,children:[P(`span`,{className:`settings-label`,children:e(`settings.model.models`)}),(f?.length??0)>6&&P(`input`,{className:`settings-input`,type:`search`,value:g,onChange:e=>_(e.target.value),placeholder:e(`settings.model.search`),"aria-label":e(`settings.model.search`)}),m&&!(s&&WN(m))&&P(JN,{message:m}),!f&&!m&&V(`p`,{className:`settings-hint`,children:[P(K,{size:13,className:`spin`}),` `,e(`settings.loading`)]}),f&&be.length===0&&!m&&P(`p`,{className:`settings-hint`,children:e(Oe||!Ae?`settings.model.noMatch`:`settings.model.noModels`)}),Ae?V(D.Fragment,{children:[je.length>0&&P(bN,{title:e(`settings.model.groupDownloaded`),count:je.length,defaultOpen:!0,forceOpen:Oe,children:P(`ul`,{className:`model-list`,children:je.map(Ie)})}),Me.length>0&&P(bN,{title:e(`settings.model.groupAvailable`),count:Me.length,defaultOpen:je.length===0,forceOpen:Oe||z||Me.some(Ts),children:P(`ul`,{className:`model-list`,children:Me.map(Ie)})})]}):P(`ul`,{className:`model-list`,children:we.map(Ie)}),Se&&Te.length>0&&P(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>y(!0),children:e(`settings.model.showAll`)}),u===`fireworks`&&v&&!Oe&&P(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>y(!1),children:e(`settings.model.showRecommended`)}),Ee.length>0&&P(bN,{title:e(`settings.model.groupUnavailable`),count:Ee.length,forceOpen:Oe,children:P(`ul`,{className:`model-list`,children:Ee.map(Ie)})})]}),Ae&&se&&P(bN,{title:e(`settings.custom.title`),children:P(YN,{onAdded:e=>void ge(e)})}),Ae&&se&&P(QN,{downloadsSlot:re}),H.remote&&P(rP,{})]})]})}function sP(){let e=T(),t=k(e=>e.sessions),[n,r]=(0,J.useState)(null),[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(null),u=(0,J.useCallback)(async()=>{l(null);try{let e=await an();r(e.sessions),a(e.default_mode),k.getState().setDefaultPermissionMode(e.default_mode)}catch(e){l(e instanceof Error?e.message:String(e))}},[]);(0,J.useEffect)(()=>{u()},[u]);let d=(0,J.useCallback)(async e=>{l(null);try{await e(),await u()}catch(e){l(e instanceof Error?e.message:String(e))}},[u]),f=(0,J.useCallback)(async e=>{s(!1),await d(()=>kt(e))},[d]),p=()=>{i===`full_access`?f(`ask`):s(e=>!e)},m=e=>t.find(t=>t.id===e)?.title??e;return V(`div`,{className:`settings-pane`,children:[P(`h2`,{className:`settings-pane-title`,children:e(`settings.section.permissions`)}),P(`p`,{className:`settings-pane-lede`,children:e(`settings.permissions.lede`)}),V(`details`,{className:`settings-more`,children:[V(`summary`,{children:[P(hr,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,e(`settings.model.howItWorks`)]}),P(`p`,{className:`settings-hint`,children:e(`settings.permissions.perChat`)})]}),V(`section`,{className:`settings-card`,"aria-label":e(`settings.permissions.newChats`),children:[V(`label`,{className:`setting-row`,children:[P(`span`,{className:`settings-label`,children:e(`settings.permissions.fullAccess`)}),V(`span`,{className:`toggle-switch`,children:[P(`input`,{type:`checkbox`,checked:i===`full_access`,onChange:p,disabled:i===null,"aria-label":e(`settings.permissions.fullAccess`)}),P(`span`,{className:`toggle-track`})]})]}),P(`p`,{className:`settings-hint`,children:e(i===`full_access`?`settings.permissions.on`:`settings.permissions.off`)}),o&&V(`div`,{className:`settings-warning`,role:`alert`,children:[P(`p`,{children:e(`settings.permissions.warning`)}),V(`div`,{className:`settings-row`,children:[P(`button`,{type:`button`,className:`btn-danger`,onClick:()=>void f(`full_access`),children:e(`settings.permissions.turnOn`)}),P(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>s(!1),children:e(`settings.key.cancel`)})]})]})]}),c&&P(`p`,{className:`settings-error`,role:`alert`,children:c}),n&&n.length===0&&P(`p`,{className:`settings-hint`,children:e(`settings.permissions.none`)}),!!n?.length&&P(bN,{title:e(`settings.permissions.chats`),count:n.length,defaultOpen:!0,children:n.map(t=>V(`section`,{className:`settings-field permission-chat`,"aria-label":m(t.session_id),children:[V(`div`,{className:`settings-row settings-row-between`,children:[P(`bdi`,{className:`settings-label`,children:m(t.session_id)}),t.mode===`full_access`&&P(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>d(async()=>{let e=(await Pt(t.session_id,`ask`)).mode;_E(t.session_id,e)}),children:e(`settings.permissions.turnOff`)})]}),t.grants.length>0&&P(`ul`,{className:`grant-list`,children:t.grants.map(n=>V(`li`,{className:`grant-row`,children:[P(`code`,{children:n.label}),P(`button`,{type:`button`,className:`link-btn`,onClick:()=>d(()=>Xt(t.session_id,n.key)),"aria-label":e(`settings.permissions.revokeAria`,{name:n.label}),children:e(`settings.permissions.revoke`)})]},n.key))}),t.grants.length>1&&P(`button`,{type:`button`,className:`link-btn`,onClick:()=>d(()=>Xt(t.session_id)),children:e(`settings.permissions.revokeAll`)})]},t.session_id))})]})}var cP={path:`~/.gaia/skills`},lP=[{source:`agent-bundled`,title:`settings.skills.bundled`,note:`settings.skills.bundledNote`},{source:`user`,title:`settings.skills.yours`,note:`settings.skills.yoursNote`,empty:`settings.skills.yoursEmpty`,params:cP},{source:`claude-project`,title:`settings.skills.project`,note:`settings.skills.projectNote`,params:{path:`.claude/skills`}},{source:`claude-import`,title:`settings.skills.import`,note:`settings.skills.importNote`}];function uP({onUseSkill:e}){let t=T(),[n,r]=(0,J.useState)(null),[i,a]=(0,J.useState)({}),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(``);(0,J.useEffect)(()=>{let e=!1;return cn().then(t=>{e||(r(t.skills),a(t.invalid))}).catch(t=>{e||s(t instanceof Error?t.message:String(t))}),()=>{e=!0}},[]);let u=c.trim().toLowerCase(),d=(n??[]).filter(e=>!u||e.name.toLowerCase().includes(u)||e.description.toLowerCase().includes(u)),f=n?.every(e=>lP.some(t=>t.source===e.source))??!1,p=n=>V(`li`,{className:`skill-row`,children:[V(`div`,{className:`skill-row-text`,children:[V(`span`,{className:`skill-row-name`,children:[n.name,n.version&&V(`span`,{className:`skill-row-meta`,children:[` v`,n.version]}),n.always_on&&V(`span`,{className:`skill-row-meta`,children:[` · `,t(`settings.skills.alwaysOn`)]})]}),P(`span`,{className:`skill-row-desc`,children:P(`bdi`,{children:n.description})})]}),!n.always_on&&P(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>e(n.name),"aria-label":t(`settings.skills.useAria`,{name:n.name}),children:t(`settings.model.use`)})]},n.name);return V(`div`,{className:`settings-pane`,children:[P(`h2`,{className:`settings-pane-title`,children:t(`settings.section.skills`)}),P(`p`,{className:`settings-pane-lede`,children:t(`settings.skills.lede`)}),V(`details`,{className:`settings-more`,children:[V(`summary`,{children:[P(hr,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,t(`settings.model.howItWorks`)]}),P(`p`,{className:`settings-hint`,children:t(`settings.skills.how`,cP)})]}),o&&P(`p`,{className:`settings-error`,role:`alert`,children:o}),!n&&!o&&V(`p`,{className:`settings-hint`,children:[P(K,{size:13,className:`spin`}),` `,t(`settings.loading`)]}),n&&n.length>6&&P(`input`,{className:`settings-input`,type:`search`,value:c,onChange:e=>l(e.target.value),placeholder:t(`settings.skills.search`),"aria-label":t(`settings.skills.search`)}),n&&n.length===0&&P(`p`,{className:`settings-hint`,children:t(`settings.skills.none`)}),f?lP.map(e=>{let r=d.filter(t=>t.source===e.source),i=(n??[]).filter(t=>t.source===e.source).length;return r.length===0&&(u||!e.empty)?null:P(bN,{title:t(e.title),count:i,hint:t(e.note,e.params),defaultOpen:e.source===`user`,forceOpen:!!u,children:P(`section`,{"aria-label":t(e.title),children:r.length===0?P(`p`,{className:`settings-hint`,children:e.empty&&t(e.empty,e.params)}):P(`ul`,{className:`skill-list`,children:r.map(p)})})},e.source)}):P(`ul`,{className:`skill-list`,children:d.map(p)}),Object.keys(i).length>0&&V(`div`,{className:`settings-card`,role:`alert`,children:[P(`span`,{className:`settings-label`,children:t(`settings.skills.skipped`)}),P(`ul`,{className:`grant-list`,children:Object.entries(i).map(([e,t])=>V(`li`,{children:[P(`bdi`,{dir:`ltr`,children:P(`code`,{children:e})}),` — `,P(`bdi`,{children:t})]},e))})]})]})}function dP(){let e=T(),t=k(e=>e.setShowMemoryDashboard),n=k(e=>e.closeSettings),[r,i]=(0,J.useState)(null),[a,o]=(0,J.useState)(null),[s,c]=(0,J.useState)(!1);(0,J.useEffect)(()=>{dA().then(i).catch(e=>o(e instanceof Error?e.message:String(e)))},[]);let l=(0,J.useCallback)(async()=>{if(r){c(!0),o(null);try{i(await fA({memory_enabled:!r.memory_enabled}))}catch(e){o(e instanceof Error?e.message:String(e))}finally{c(!1)}}},[r]);return V(`div`,{className:`settings-pane`,children:[P(`h2`,{className:`settings-pane-title`,children:e(`settings.section.memory`)}),P(`p`,{className:`settings-pane-lede`,children:e(`settings.memory.lede`)}),V(`section`,{className:`settings-card`,"aria-label":e(`settings.section.memory`),children:[V(`label`,{className:`setting-row`,children:[P(`span`,{children:e(`settings.memory.remember`)}),V(`span`,{className:`toggle-switch`,children:[P(`input`,{type:`checkbox`,checked:!!r?.memory_enabled,onChange:()=>void l(),disabled:!r||s,"aria-label":e(`settings.memory.remember`)}),P(`span`,{className:`toggle-track`})]})]}),a&&P(`p`,{className:`settings-error`,role:`alert`,children:a}),V(`div`,{className:`settings-row settings-row-between`,children:[P(`span`,{className:`settings-hint`,children:e(`settings.memory.dashboardHint`)}),P(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{n(),t(!0)},children:e(`settings.memory.dashboard`)})]})]})]})}function fP(e,t,n){if(!/^\d+$/.test(e.trim()))return!1;let r=Number(e);return r>=t&&r<=n}function pP(e){return e<1048576?`${Math.ceil(e/1024)} KB`:`${(e/1048576).toFixed(1)} MB`}function mP(){let e=T(),[t,n]=(0,J.useState)(null),[r,i]=(0,J.useState)(``),[a,o]=(0,J.useState)(``),[s,c]=(0,J.useState)(null),[l,u]=(0,J.useState)(!1);(0,J.useEffect)(()=>{mn().then(e=>{n(e),i(String(e.retention_days)),o(String(e.max_mb))},t=>c({ok:!1,text:e(`settings.undo.readFailed`,{reason:t instanceof Error?t.message:String(t)})}))},[e]);let[d,f]=(0,J.useState)({days:!1,mb:!1}),p=!fP(r,1,365)||d.days,m=!fP(a,10,1e5)||d.mb,h=t!==null&&(r!==String(t.retention_days)||a!==String(t.max_mb)),g=async()=>{if(!(p||m)){u(!0),c(null);try{let t=await dn(Number(r),Number(a));n(t),c({ok:!0,text:e(`settings.undo.saved`)})}catch(t){let n=t instanceof vn&&t.httpStatus===422?t.fields:[],r=n.includes(`retention_days`),i=n.includes(`max_mb`);r||i?(f({days:r,mb:i}),c({ok:!1,text:e(`settings.undo.fix`)})):c({ok:!1,text:t instanceof Error?t.message:String(t)})}finally{u(!1)}}};return V(`div`,{className:`settings-field`,"aria-label":e(`settings.privacy.undo`),children:[P(`span`,{className:`settings-label`,children:e(`settings.privacy.undo`)}),P(`p`,{className:`settings-hint`,children:e(`settings.undo.hint`)}),t&&V(D.Fragment,{children:[V(`div`,{className:`setting-row`,children:[P(`label`,{htmlFor:`undo-days`,children:e(`settings.undo.days`)}),P(`input`,{id:`undo-days`,type:`number`,className:`model-input undo-history-input`,min:1,max:365,value:r,"aria-invalid":p,"aria-describedby":p?`undo-days-error`:void 0,onChange:e=>{i(e.target.value),f(e=>({...e,days:!1}))}})]}),p&&P(`p`,{id:`undo-days-error`,className:`settings-error`,children:e(`settings.undo.daysError`)}),V(`div`,{className:`setting-row`,children:[P(`label`,{htmlFor:`undo-mb`,children:e(`settings.undo.mb`)}),P(`input`,{id:`undo-mb`,type:`number`,className:`model-input undo-history-input`,min:10,max:1e5,value:a,"aria-invalid":m,"aria-describedby":m?`undo-mb-error`:void 0,onChange:e=>{o(e.target.value),f(e=>({...e,mb:!1}))}})]}),m&&P(`p`,{id:`undo-mb-error`,className:`settings-error`,children:e(`settings.undo.mbError`)}),V(`div`,{className:`setting-row setting-row-path`,children:[P(`span`,{children:e(`settings.undo.inUse`)}),V(`span`,{children:[e.plural(`settings.undo.used`,t.turns,{size:pP(t.used_bytes)}),` `,P(`bdi`,{dir:`ltr`,children:P(`code`,{className:`setting-path`,children:t.path})})]})]}),P(`button`,{type:`button`,className:`btn-model-save`,onClick:()=>void g(),disabled:!h||l||p||m,children:e(l?`settings.models.applying`:`settings.advanced.save`)})]}),s&&P(`p`,{className:s.ok?`settings-ok`:`settings-error`,role:s.ok?`status`:`alert`,children:s.text})]})}var hP={root:`settings-report`,button:`btn-secondary`,hint:`settings-hint`,error:`settings-error`};function gP(){let e=T(),t=k(e=>e.sessions),n=k(e=>e.removeSession),r=hs(),i=k(e=>e.systemStatus?.data_dir),[a,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(null),l=(0,J.useRef)(null);(0,J.useEffect)(()=>()=>{l.current&&clearTimeout(l.current)},[]);let u=(0,J.useCallback)(async()=>{if(!a){o(!0),l.current=setTimeout(()=>o(!1),4e3);return}o(!1);let r=[];for(let e of t)try{await de(e.id),n(e.id)}catch(t){r.push(`${e.title}: ${t instanceof Error?t.message:t}`)}c(r.length?{ok:!1,text:e(`settings.privacy.deleteFailed`,{n:r.length,reason:r.join(`; `)})}:{ok:!0,text:e(`settings.privacy.deleted`)})},[a,n,t,e]);return V(`div`,{className:`settings-pane`,children:[P(`h2`,{className:`settings-pane-title`,children:e(`settings.section.privacy`)}),V(`section`,{className:`settings-card`,"aria-label":e(`settings.privacy.whereTitle`),children:[P(`p`,{className:`settings-note`,children:e(`settings.privacy.stays`)}),P(`p`,{className:r?.remote?`settings-note`:`settings-hint`,children:r?.remote?e(`settings.privacy.remote`,{name:r.label}):e(r?`settings.privacy.local`:`settings.privacy.unknown`)}),i&&V(`div`,{className:`setting-row setting-row-path`,children:[P(`span`,{children:e(`settings.privacy.dataFolder`)}),P(`bdi`,{dir:`ltr`,className:`setting-path`,children:i})]})]}),V(`section`,{className:`settings-card`,"aria-label":e(`settings.privacy.reportTitle`),children:[P(`p`,{className:`settings-note`,children:e(`settings.privacy.reportNote`)}),P(tC,{classes:hP})]}),P(bN,{title:e(`settings.privacy.undo`),children:P(mP,{})}),V(`section`,{className:`settings-card`,"aria-label":e(`settings.privacy.deleteTitle`),children:[P(`p`,{className:`danger-warning`,children:t.length===0?e(`settings.privacy.nothingToDelete`):e(`settings.privacy.deleteWarning`)}),P(`button`,{type:`button`,className:`btn-danger`,onClick:()=>void u(),disabled:t.length===0,children:e(a?`settings.privacy.deleteConfirm`:`settings.privacy.delete`)})]}),s&&P(`p`,{className:s.ok?`settings-ok`:`settings-error`,role:s.ok?`status`:`alert`,children:s.text})]})}var _P=[{id:`needs_approval`,label:`settings.alerts.approval`},{id:`question`,label:`settings.alerts.question`},{id:`finished`,label:`settings.alerts.finished`}],vP=[{value:`banner`,label:`settings.alerts.banner`},{value:`badge`,label:`settings.alerts.badge`},{value:`off`,label:`settings.alerts.off`}],yP=[0,10,20,30,50];function bP(){return typeof Notification>`u`?`unsupported`:Notification.permission}function xP(){let e=T(),t=lc(),n=!!window.gaiaAPI,[r,i]=(0,J.useState)(bP),a=Object.values(t.modes).includes(`banner`);return V(`div`,{className:`settings-pane`,children:[P(`h2`,{className:`settings-pane-title`,children:e(`settings.section.notifications`)}),P(`p`,{className:`settings-pane-lede`,children:e(`settings.alerts.lede`)}),V(`section`,{className:`settings-card`,"aria-label":e(`settings.alerts.when`),children:[_P.map(n=>V(`div`,{className:`setting-row`,children:[P(`span`,{id:`alert-${n.id}`,children:e(n.label)}),P(`div`,{className:`segmented`,role:`radiogroup`,"aria-labelledby":`alert-${n.id}`,children:vP.map(r=>P(`button`,{type:`button`,role:`radio`,"aria-checked":t.modes[n.id]===r.value,className:t.modes[n.id]===r.value?`is-active`:``,onClick:()=>t.setMode(n.id,r.value),children:e(r.label)},r.value))})]},n.id)),!n&&a&&r!==`granted`&&(r==="default"?P(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{Notification.requestPermission().then(i).catch(e=>{console.error(`[alerts] Notification permission request failed`,e),i(bP())})},children:e(`settings.alerts.allow`)}):P(`p`,{className:`settings-error`,role:`alert`,children:e(r===`unsupported`?`settings.alerts.unsupported`:`settings.alerts.blocked`)})),V(`label`,{className:`setting-row`,children:[P(`span`,{children:e(`settings.alerts.sound`)}),V(`span`,{className:`toggle-switch`,children:[P(`input`,{type:`checkbox`,checked:t.sound,onChange:()=>t.update({sound:!t.sound}),"aria-label":e(`settings.alerts.sound`)}),P(`span`,{className:`toggle-track`})]})]}),n&&V(`label`,{className:`setting-row`,children:[P(`span`,{children:e(`settings.alerts.flash`)}),V(`span`,{className:`toggle-switch`,children:[P(`input`,{type:`checkbox`,checked:t.flash,onChange:()=>t.update({flash:!t.flash}),"aria-label":e(`settings.alerts.flash`)}),P(`span`,{className:`toggle-track`})]})]})]}),V(`section`,{className:`settings-card`,"aria-labelledby":`keep-awake-title`,children:[P(`h3`,{className:`settings-label`,id:`keep-awake-title`,children:e(`settings.alerts.keepAwakeTitle`)}),n?V(D.Fragment,{children:[V(`label`,{className:`setting-row`,children:[P(`span`,{children:e(`settings.alerts.keepAwake`)}),V(`span`,{className:`toggle-switch`,children:[P(`input`,{type:`checkbox`,checked:t.keepAwake,onChange:()=>t.update({keepAwake:!t.keepAwake}),"aria-label":e(`settings.alerts.keepAwake`)}),P(`span`,{className:`toggle-track`})]})]}),V(`div`,{className:`setting-row`,children:[P(`label`,{htmlFor:`battery-floor`,children:e(`settings.alerts.battery`)}),P(`select`,{id:`battery-floor`,className:`settings-input settings-select-compact`,value:t.batteryFloor,disabled:!t.keepAwake,onChange:e=>t.update({batteryFloor:Number(e.target.value)}),children:yP.map(t=>P(`option`,{value:t,children:t===0?e.bare(`settings.alerts.never`):`${t}%`},t))})]}),P(`p`,{className:`settings-hint`,children:e(`settings.alerts.screen`)})]}):P(`p`,{className:`settings-hint`,children:e(`settings.alerts.desktopOnly`)})]})]})}var SP=[50,75,100,125,150,175,200],CP=[{accent:`american`,gender:`female`},{accent:`american`,gender:`male`},{accent:`british`,gender:`female`},{accent:`british`,gender:`male`}],wP=`settings:preview`,TP=`Hello, I'm GAIA. This is how I'll read my replies to you.`;function EP(e){return e instanceof vn?e.detail||e.message:String(e)}function DP(){let e=T(),t=wS(e=>e.settings),n=wS(e=>e.setSettings),r=wS(e=>e.read),i=wS(e=>e.stop),a=wS(e=>e.messageId===wP),o=wS(e=>e.messageId===wP&&e.status===`loading`),[s,c]=(0,J.useState)(null),[l,u]=(0,J.useState)(null),[d,f]=(0,J.useState)(!1);(0,J.useEffect)(()=>{dS().then(n).catch(e=>c(EP(e)))},[n]);let p=e=>{f(!0),u(null),wS.getState().messageId===wP&&i(),fS(e).then(n).catch(e=>u(EP(e))).finally(()=>f(!1))};return s?V(`div`,{className:`settings-pane`,children:[P(`h2`,{className:`settings-pane-title`,children:e(`settings.section.voice`)}),P(`p`,{className:`settings-error`,role:`alert`,children:e(`readAloud.settings.loadFailed`,{reason:s})})]}):t?V(`div`,{className:`settings-pane`,children:[P(`h2`,{className:`settings-pane-title`,children:e(`settings.section.voice`)}),P(`p`,{className:`settings-pane-lede`,children:e(`readAloud.settings.lede`)}),V(`div`,{className:`settings-field`,children:[P(`label`,{className:`settings-label`,htmlFor:`read-aloud-voice`,children:e(`readAloud.settings.voice`)}),V(`div`,{className:`read-aloud-voice-row`,children:[P(`select`,{id:`read-aloud-voice`,className:`settings-input`,value:t.voice,disabled:d,onChange:e=>p({voice:e.target.value}),children:CP.map(n=>P(`optgroup`,{label:e(`readAloud.group.${n.accent}.${n.gender}`),children:t.voices.filter(e=>e.accent===n.accent&&e.gender===n.gender).map(e=>P(`option`,{value:e.id,lang:`en`,children:e.name},e.id))},`${n.accent}-${n.gender}`))}),V(`button`,{type:`button`,className:`btn-secondary`,"aria-pressed":a,disabled:d,onClick:()=>a?i():void r(wP,TP),children:[o?P(K,{size:13,className:`spin`}):P(a?io:go,{size:13}),e(a?`readAloud.stop`:`readAloud.settings.preview`)]})]}),P(`span`,{className:`settings-hint`,children:e(`readAloud.settings.englishOnly`)}),P(DS,{messageId:wP})]}),V(`div`,{className:`settings-field`,children:[P(`label`,{className:`settings-label`,htmlFor:`read-aloud-speed`,children:e(`readAloud.settings.speed`)}),P(`select`,{id:`read-aloud-speed`,className:`settings-input`,value:t.speed,disabled:d,onChange:e=>p({speed:Number(e.target.value)}),children:(SP.includes(t.speed)?SP:[...SP,t.speed].sort((e,t)=>e-t)).map(t=>P(`option`,{value:t,children:t===100?e.bare(`readAloud.settings.normalSpeed`):`${(t/100).toLocaleString(e.locale)}×`},t))})]}),V(`label`,{className:`setting-row`,children:[P(`span`,{children:e(`readAloud.settings.auto`)}),V(`span`,{className:`toggle-switch`,children:[P(`input`,{type:`checkbox`,checked:t.auto,disabled:d,onChange:()=>p({auto:!t.auto}),"aria-label":e(`readAloud.settings.auto`)}),P(`span`,{className:`toggle-track`})]})]}),P(`p`,{className:`settings-hint`,children:e(`readAloud.settings.shared`)}),l&&P(`p`,{className:`settings-error`,role:`alert`,children:e(`readAloud.settings.saveFailed`,{reason:l})})]}):V(`p`,{className:`settings-hint`,children:[P(K,{size:13,className:`spin`}),` `,e(`settings.loading`)]})}function OP(){let e=T(),t=k(e=>e.openSettings),n=k(e=>e.closeSettings),r=k(e=>e.runSetupAgain),[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(null),[u,d]=(0,J.useState)(!1);(0,J.useEffect)(()=>{ot().then(a).catch(e=>l(e instanceof Error?e.message:String(e))),le().then(s).catch(e=>l(e instanceof Error?e.message:String(e)))},[]);let f=i?.catalog?.find(e=>e.id===i.chat_model.id),p=(i?.catalog??[]).filter(e=>e.downloaded),m=p.reduce((e,t)=>e+(t.full_size_gb??0),0),h=[o?.gpu_name,o?.npu_detected?e(`setup.checks.npu`):null].filter(Boolean).join(` · `),g=[{title:e(`settings.setup.where`),rows:[{label:e(`settings.setup.chatRuns`),value:f?.name??null,section:`model`},{label:e(`settings.setup.cloudKeys`),value:null,section:`model`}]},{title:e(`setup.pc.step`),rows:[{label:e(`settings.setup.detected`),value:[h,o?.ram_gb==null?null:`${o.ram_gb} GB`].filter(Boolean).join(` · `)||null,section:`advanced`},{label:e(`settings.setup.server`),value:i?.lemonade.mode===`external`?e(`settings.setup.serverYours`):e(`settings.setup.serverOwn`),section:`advanced`},{label:e(`setup.gpu.title`),value:null,section:`model`}]},{title:e(`setup.models.step`),rows:[{label:e(`settings.setup.models`),value:i?.catalog?e(`settings.setup.modelsValue`,{n:String(p.length),size:$(m)}):null,section:`model`},{label:e(`settings.setup.context`),value:null,section:`model`}]},{title:e(`settings.setup.after`),rows:[{label:e(`settings.section.connectors`),value:null,section:`connectors`},{label:e(`settings.section.memory`),value:null,section:`memory`},{label:e(`settings.language`),value:null,section:`general`},{label:e(`settings.setup.signIn`),value:null,section:`general`}]}];return V(`div`,{className:`settings-pane`,children:[P(`h2`,{className:`settings-pane-title`,children:e(`settings.section.setup`)}),P(`p`,{className:`settings-hint`,children:e(`settings.setup.lede`)}),V(`div`,{className:`settings-setup-status`,children:[V(`span`,{children:[P(`strong`,{children:e(`settings.setup.ready`)}),f&&V(`span`,{className:`settings-hint`,children:[` `,P(`bdi`,{children:e(`settings.setup.running`,{name:f.name})})]})]}),P(`button`,{type:`button`,className:`btn-secondary`,"data-testid":`setup-run-again`,onClick:()=>d(!0),children:e(`settings.setup.runAgain`)})]}),c&&P(`p`,{className:`setup-error`,role:`alert`,children:c}),g.map(e=>V(`section`,{className:`settings-setup-group`,"aria-label":e.title,children:[P(`h3`,{className:`settings-label`,children:e.title}),e.rows.map(e=>V(`button`,{type:`button`,className:`settings-setup-row`,onClick:()=>t(e.section),children:[V(`span`,{children:[P(`span`,{className:`settings-setup-row-label`,children:e.label}),e.value&&P(`bdi`,{className:`settings-hint settings-setup-row-value`,children:e.value})]}),P(yr,{size:14,className:`settings-setup-chevron`,"aria-hidden":`true`})]},e.label))]},e.title)),u&&P(Wj,{title:e(`settings.setup.confirmTitle`),confirmLabel:e(`settings.setup.confirmYes`),cancelLabel:e(`setup.again.notNow`),onConfirm:()=>{d(!1),n(),r(!0)},onCancel:()=>d(!1),children:P(`p`,{children:e(`settings.setup.confirmBody`)})})]})}var kP=`modulepreload`,AP=function(e,t){return new URL(e,t).href},jP={},MP=function(e){return e.pathname.endsWith(`.css`)},NP=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},PP=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=AP(t,n);let r=s(t),i=MP(r);return NP(jP,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:kP,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},FP=(0,J.lazy)(()=>PP(()=>import(`./ConnectorsPane-Byq5_CvM.js`).then(e=>({default:e.ConnectorsPane})),__vite__mapDeps([0,1,2,3,4]),import.meta.url)),IP=(0,J.lazy)(()=>PP(()=>import(`./AdvancedSettings-D8P_x4lg.js`).then(e=>({default:e.AdvancedSettings})),__vite__mapDeps([5,1,2,3]),import.meta.url)),LP=[`general`,`setup`,`model`,`permissions`,`skills`,`connectors`,`memory`,`notifications`,`voice`,`privacy`,`advanced`];function RP({onUseSkill:e}){let t=T(),n=k(e=>e.settingsSection),r=k(e=>e.openSettings),i=k(e=>e.closeSettings),a=(0,J.useRef)(null),o=n!==null;if(Io(o,i),aS(a,o),yN(a,o,()=>a.current?.querySelector(`.settings-nav-item.is-active`)),!n)return null;let s=(()=>{switch(n){case`general`:return P(UN,{});case`setup`:return P(OP,{});case`model`:return P(oP,{});case`permissions`:return P(sP,{});case`skills`:return P(uP,{onUseSkill:t=>{i(),e(t)}});case`connectors`:return P(FP,{});case`memory`:return P(dP,{});case`notifications`:return P(xP,{});case`voice`:return P(DP,{});case`privacy`:return P(gP,{});case`advanced`:return P(IP,{})}})();return P(`div`,{className:`settings-overlay`,onMouseDown:e=>{e.target===e.currentTarget&&i()},children:V(`div`,{ref:a,className:`settings-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":t(`settings.title`),children:[V(`nav`,{className:`settings-nav`,"aria-label":t(`settings.sections`),children:[P(`h1`,{className:`settings-nav-title`,children:t(`settings.title`)}),LP.map(e=>P(`button`,{type:`button`,"data-section":e,className:`settings-nav-item${n===e?` is-active`:``}`,"aria-current":n===e?`page`:void 0,onClick:t=>{t.currentTarget.focus(),r(e)},children:t(`settings.section.${e}`)},e))]}),V(`div`,{className:`settings-body`,children:[P(`button`,{type:`button`,className:`settings-close`,onClick:i,"aria-label":t(`settings.close`),children:P(So,{size:18})}),P(`div`,{className:`settings-scroll`,children:P(J.Suspense,{fallback:V(`p`,{className:`settings-hint`,children:[P(K,{size:13,className:`spin`}),` `,t(`settings.loading`)]}),children:s})})]})]})})}var zP=p((e,t)=>({lifecycle:null,restartError:null,apply:n=>{n.apiBase&&B(n.apiBase),e({lifecycle:n,restartError:n.status===`running`?null:t().restartError})},restart:async()=>{let n=window.gaiaAPI?.backend;if(!n)throw Error(`Restart GAIA needs the desktop app.`);e({restartError:null});try{t().apply(await n.restart())}catch(t){d.system.error(`Restart GAIA failed`,t),e({restartError:t instanceof Error?t.message:String(t)})}}}));function BP(e){let t=window.gaiaAPI?.backend;if(!t)return()=>{};let n=t=>{let n=zP.getState().lifecycle?.status;zP.getState().apply(t),t.status===`running`&&n&&n!==`running`&&e()},r=t.onState(n);return t.getState().then(n).catch(e=>d.system.error(`Could not read the backend state from the desktop app`,e)),r}function VP(e,t){let[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(!1),[o,s]=(0,J.useState)(null),c=(0,J.useRef)(null),l=(0,J.useRef)(null),u=(0,J.useRef)(null),f=(0,J.useCallback)(()=>{c.current&&=(clearTimeout(c.current),null),l.current&&=(clearTimeout(l.current),null),u.current&&=(clearInterval(u.current),null)},[]);(0,J.useEffect)(()=>f,[f]);let p=(0,J.useCallback)((e,t)=>{u.current&&clearInterval(u.current),u.current=setInterval(async()=>{try{let n=await Nt();t===`load`?n.model_loaded?.toLowerCase()===e.toLowerCase()&&(r(!1),c.current&&=(clearTimeout(c.current),null),u.current&&=(clearInterval(u.current),null)):(n.model_downloaded===!0||n.model_loaded?.toLowerCase()===e.toLowerCase())&&(a(!1),l.current&&=(clearTimeout(l.current),null),u.current&&=(clearInterval(u.current),null))}catch{}},Lc)},[]),m=e??`Gemma-4-E4B-it-GGUF`;return(0,J.useEffect)(()=>s(null),[m]),{isLoadingModel:n,isDownloadingModel:i,downloadError:o,loadModel:(0,J.useCallback)(async(e,t)=>{let n=e??m,i=t??32768;r(!0);try{if(!await zt(n,i)){r(!1);return}d.system.info(`Load model triggered: ${n} (ctx=${i})`),c.current&&clearTimeout(c.current),c.current=setTimeout(()=>r(!1),Fc),p(n,`load`)}catch(e){d.system.error(`Failed to trigger model load`,e),r(!1)}},[m,t,p]),downloadModel:(0,J.useCallback)(async(e=!1,t,n=!1)=>{let r=t??m;a(!0),s(null);try{await fe(r,e,n),d.system.info(`Download model triggered: ${r} (force=${e})`),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>a(!1),Ic),p(r,`download`)}catch(e){d.system.error(`Failed to trigger model download`,e),s(e instanceof Error?e.message:String(e)),a(!1)}},[m,p])}}function HP({onRetry:e,label:t,busyLabel:n=`Checking…`}){let[r,i]=(0,J.useState)(!1);return P(`button`,{className:`connection-banner__retry`,onClick:()=>{i(!0),Promise.resolve(e()).finally(()=>i(!1))},disabled:r,children:r?n:t})}function UP(e){return`${Math.floor(e/60)}:${String(e%60).padStart(2,`0`)}`}function WP({lifecycle:e}){let t=T(),n=zP(e=>e.restart),r=zP(e=>e.restartError),i=e.status===`restarting`,[a,o]=(0,J.useState)(()=>Date.now());if((0,J.useEffect)(()=>{if(!i)return;o(Date.now());let e=setInterval(()=>o(Date.now()),1e3);return()=>clearInterval(e)},[i]),i){let n=e.since?Math.max(0,Math.floor((a-e.since)/1e3)):0;return V(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[P(`div`,{className:`connection-banner__icon`,children:P(K,{size:16,className:`connection-banner__spinner`})}),V(`div`,{className:`connection-banner__text`,dir:`auto`,children:[t(`banner.restarting`),` `,P(`bdi`,{dir:`ltr`,className:`connection-banner__timer`,children:UP(n)}),` `,P(`span`,{className:`connection-banner__hint`,children:t(`banner.restartingHint`)})]})]})}return V(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[P(`div`,{className:`connection-banner__icon`,children:P(q,{size:16})}),V(`div`,{className:`connection-banner__text`,dir:`auto`,children:[t(`banner.restartStopped`),` `,P(`span`,{className:`connection-banner__hint`,children:r?t(`banner.restartFailed`,{error:r}):t(`banner.restartStoppedHint`)})]}),P(HP,{onRetry:n,label:t(`banner.restartButton`),busyLabel:t(`banner.restartingShort`)})]})}function GP({onRetry:e,backendSlow:t=!1,backendError:n=null}){let r=T(),{backendConnected:i,systemStatus:a,currentSessionId:o,messages:s}=k(),c=zP(e=>e.lifecycle),[l,u]=(0,J.useState)(!1),d=!!o&&s.length>0,f=a?.default_model_name??`Gemma-4-E4B-it-GGUF`,{isDownloadingModel:p,downloadError:m,downloadModel:h}=VP(f),g=cs(e=>e.pickLoad),_=cs(e=>e.retryPickLoad),v=cs(e=>e.dismissPickLoad);ls();let y=(0,J.useRef)(a?.lemonade_running),b=(0,J.useRef)(a?.model_downloaded),x=(0,J.useRef)(a?.context_size_sufficient),S=(0,J.useRef)(a?.expected_model_loaded);if((0,J.useEffect)(()=>{if(d)return;let e=a?.lemonade_running,t=a?.model_downloaded,n=a?.context_size_sufficient,r=a?.expected_model_loaded,i=!1;y.current!==e&&(y.current=e,e===!1&&(i=!0)),b.current!==t&&(b.current=t,t===!1&&(i=!0)),x.current!==n&&(x.current=n,n===!1&&(i=!0)),S.current!==r&&(S.current=r,r===!1&&(i=!0)),i&&u(!1)},[a,d]),c&&c.status!==`running`)return P(WP,{lifecycle:c});let C=a?.download_progress??null,w=C?.model_name||f;if(p||C?.state===`downloading`||C?.state===`starting`||C?.state===`error`){let e=C?.total_bytes?`${(C.total_bytes/1e9).toFixed(1)} GB`:`large download`,t=C?.state===`error`;return V(`div`,{className:`connection-banner ${t?`connection-banner--error`:`connection-banner--warning`}`,role:t?`alert`:`status`,children:[P(`div`,{className:`connection-banner__icon`,children:P(t?q:qr,{size:16})}),P(`div`,{className:`connection-banner__text`,dir:`auto`,children:t?V(D.Fragment,{children:[`Download of `,P(`strong`,{children:w}),` failed.`,` `,(m??C?.message)&&P(`span`,{className:`connection-banner__hint`,children:m??C?.message})]}):V(D.Fragment,{children:[`Downloading `,P(`strong`,{children:w}),` (`,e,`).`,C?.state===`downloading`&&C.file&&V(D.Fragment,{children:[` `,V(`span`,{className:`connection-banner__hint`,children:[`File `,C.file_index,` / `,C.total_files,`: `,P(`code`,{children:C.file})]})]})]})}),t?P(`button`,{className:`connection-banner__retry`,onClick:()=>h(!1,w,!a?.model_loaded),children:`Retry`}):P(`span`,{className:`connection-banner__loading connection-banner__progress`,children:C&&C.state===`downloading`&&C.total_bytes>0?V(D.Fragment,{children:[P(`span`,{className:`connection-banner__progress-bar`,role:`progressbar`,"aria-valuenow":C.percent,"aria-valuemin":0,"aria-valuemax":100,"aria-label":`Download progress`,children:P(`span`,{className:`connection-banner__progress-fill`,style:{width:`${C.percent}%`}})}),V(`span`,{className:`connection-banner__progress-label`,children:[C.percent,`% ·`,` `,(C.downloaded_bytes/1e9).toFixed(2),` /`,` `,(C.total_bytes/1e9).toFixed(2),` GB`]})]}):V(D.Fragment,{children:[P(K,{size:13,className:`connection-banner__spinner`}),C?.state===`starting`?C.message??`Starting download…`:`Downloading…`]})}),t&&P(`button`,{className:`connection-banner__dismiss`,onClick:()=>u(!0),"aria-label":`Dismiss`,children:P(So,{size:14})})]})}if(g){let e=ds(g.model);return g.error?V(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[P(`div`,{className:`connection-banner__icon`,children:P(q,{size:16})}),V(`div`,{className:`connection-banner__text`,dir:`auto`,children:[r(`banner.pickLoad.failed`,{model:e}),` `,P(`span`,{className:`connection-banner__hint`,dir:`auto`,children:g.error.key?r(g.error.key,{reason:g.error.reason}):g.error.reason})]}),P(HP,{onRetry:_,label:r(`banner.pickLoad.retry`)}),P(`button`,{className:`connection-banner__dismiss`,onClick:v,"aria-label":r(`banner.dismiss`),children:P(So,{size:14})})]}):V(`div`,{className:`connection-banner connection-banner--init`,role:`status`,children:[P(`div`,{className:`connection-banner__icon`,children:P(K,{size:16,className:`connection-banner__spinner`})}),V(`div`,{className:`connection-banner__text`,dir:`auto`,children:[r(`banner.pickLoad.loading`,{model:e}),` `,P(`bdi`,{dir:`ltr`,children:r(`banner.pickLoad.seconds`,{s:g.seconds})}),` `,P(`span`,{className:`connection-banner__hint`,children:r(`banner.pickLoad.canType`)})]})]})}if(Bw(a)&&!t&&!n){let e=a?.init_tasks?.find(e=>e.status===`running`)?.name||`Preparing AI system`;return V(`div`,{className:`connection-banner connection-banner--init`,role:`status`,children:[P(`div`,{className:`connection-banner__icon`,children:P(K,{size:16,className:`connection-banner__spinner`})}),V(`div`,{className:`connection-banner__text`,dir:`auto`,children:[e,V(`span`,{className:`thinking-dots`,children:[P(`span`,{children:`.`}),P(`span`,{children:`.`}),P(`span`,{children:`.`})]})]})]})}if(l||d)return null;if(!i)return V(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[P(`div`,{className:`connection-banner__icon`,children:P(vo,{size:16})}),V(`div`,{className:`connection-banner__text`,dir:`auto`,children:[r(`banner.unreachable`),` `,P(`span`,{className:`connection-banner__hint`,children:r(`banner.unreachableHint`)})]}),e&&P(HP,{onRetry:e,label:`Retry`})]});if(n)return V(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[P(`div`,{className:`connection-banner__icon`,children:P(q,{size:16})}),V(`div`,{className:`connection-banner__text`,dir:`auto`,children:[`GAIA's backend answered with an error (`,n,`).`,` `,P(`span`,{className:`connection-banner__hint`,children:`It may be overloaded. GAIA keeps checking; if it lasts, restart GAIA.`})]}),e&&P(HP,{onRetry:e,label:`Check again`})]});if(t)return V(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[P(`div`,{className:`connection-banner__icon`,children:P(q,{size:16})}),V(`div`,{className:`connection-banner__text`,dir:`auto`,children:[`GAIA is slow to answer.`,` `,P(`span`,{className:`connection-banner__hint`,children:`It may be busy with another chat or app. GAIA keeps checking.`})]}),e&&P(HP,{onRetry:e,label:`Check again`})]});if(a?.config_error)return V(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[P(`div`,{className:`connection-banner__icon`,children:P(q,{size:16})}),V(`div`,{className:`connection-banner__text`,dir:`auto`,children:[`GAIA settings could not be loaded.`,` `,P(`span`,{className:`connection-banner__hint`,children:a.config_error})]}),e&&P(HP,{onRetry:e,label:`Check again`})]});if(a&&!a.lemonade_running){let t=Vw(a)===`unresponsive`,n=KN(a);return V(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[P(`div`,{className:`connection-banner__icon`,children:P(q,{size:16})}),V(`div`,{className:`connection-banner__text`,dir:`auto`,children:[t?`The model server is not answering (${a.lemonade_error}). It may be busy with another app or loading a model.`:r(`banner.serverStopped`),` `,n?P(`span`,{className:`connection-banner__hint`,children:r(`banner.finishSetup`)}):a.start_command?V(`span`,{className:`connection-banner__hint`,children:[t?`If it stays this way, restart it: `:`To start it by hand, run `,P(`code`,{children:a.start_command})]}):a.start_instruction&&P(`span`,{className:`connection-banner__hint`,children:a.start_instruction})]}),n&&P(qN,{className:`connection-banner__retry`}),e&&P(HP,{onRetry:e,label:r(`settings.key.checkAgain`)}),P(`button`,{className:`connection-banner__dismiss`,onClick:()=>u(!0),"aria-label":`Dismiss`,children:P(So,{size:14})})]})}if(a&&a.lemonade_running&&a.model_loaded&&a.context_size_sufficient===!1){let t=a.model_context_size??0;return V(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[P(`div`,{className:`connection-banner__icon`,children:P(qi,{size:16})}),V(`div`,{className:`connection-banner__text`,dir:`auto`,children:[`LLM context window is too small (`,t.toLocaleString(),` tokens;`,` `,Nc.toLocaleString(),` required).`,` `,P(`span`,{className:`connection-banner__hint`,children:`Reload it with a larger context in Settings → Advanced.`})]}),e&&P(HP,{onRetry:e,label:`Check again`}),P(`button`,{className:`connection-banner__dismiss`,onClick:()=>u(!0),"aria-label":`Dismiss`,children:P(So,{size:14})})]})}return null}function KP(){let e=kN(),t=T(),[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(null),o=(0,J.useCallback)(e=>{let n=DN();n&&(a(null),n[e]().catch(n=>{d.system.error(`Update ${e} failed`,n),a(NN(n,t))}))},[t]);if(n)return null;let s=e.installFailed?t(`update.chip.installFailedDetail`,e.installFailed):null,c=e.status===`downloading`||e.status===`downloaded`;if(e.startFailed&&e.previousVersion&&!c)return V(`div`,{className:`update-chip update-chip--error`,role:`status`,children:[P(q,{size:13,className:`update-chip__icon`}),P(`span`,{className:`update-chip__label`,title:i??void 0,children:t(i?`update.chip.updateFailed`:`update.chip.startFailed`)}),P(`button`,{type:`button`,className:`update-chip__action`,onClick:()=>o(`revertUpdate`),children:t(`update.chip.goBack`,{version:e.previousVersion})}),P(`button`,{type:`button`,className:`update-chip__dismiss`,onClick:()=>r(!0),"aria-label":t(`update.chip.dismissError`),children:P(So,{size:11})})]});let l=e.status===`available`||e.status===`downloaded`;if(s&&!l)return V(`div`,{className:`update-chip update-chip--error`,role:`status`,title:s??void 0,children:[P(q,{size:13,className:`update-chip__icon`}),P(`span`,{className:`update-chip__label`,children:t(`update.chip.installFailed`)}),P(`button`,{type:`button`,className:`update-chip__dismiss`,onClick:()=>r(!0),"aria-label":t(`update.chip.dismissError`),children:P(So,{size:11})})]});if(e.status===`idle`||e.status===`checking`||e.status===`disabled`||e.status===`no-channel`)return null;if(e.status===`downloading`){let n=Math.max(0,Math.min(100,e.progress));return V(`div`,{className:`update-chip update-chip--downloading`,role:`status`,"aria-live":`polite`,title:t(`update.chip.downloadingTitle`,{version:e.version??``}),children:[P(qr,{size:13,className:`update-chip__icon`}),P(`span`,{className:`update-chip__label`,children:e.preparing?t(`update.chip.preparing`):t(`update.chip.downloading`,{pct:n})})]})}return e.status===`available`?V(`div`,{className:`update-chip update-chip--available`,role:`status`,title:i||s||e.releaseNotes||t(`update.chip.availableTitle`),children:[P(qr,{size:13,className:`update-chip__icon`}),P(`span`,{className:`update-chip__label`,children:i?t(`update.chip.updateFailed`):s?t(`update.chip.installFailed`):t(`update.chip.available`,{version:e.version??``})}),!e.pinnedVersion&&P(`button`,{type:`button`,className:`update-chip__action`,onClick:()=>o(`downloadUpdate`),children:t(`update.chip.updateNow`)}),P(`button`,{type:`button`,className:`update-chip__dismiss`,onClick:()=>r(!0),"aria-label":t(`update.chip.dismiss`),children:P(So,{size:11})})]}):e.status===`downloaded`?V(`div`,{className:`update-chip update-chip--ready`,role:`status`,"aria-live":`polite`,children:[P(Pa,{size:13,className:`update-chip__icon`}),P(`button`,{type:`button`,className:`update-chip__action`,onClick:()=>o(`restart`),title:i||s||t(`update.chip.restartTitle`),children:t(i?`update.chip.restartFailed`:s?`update.chip.installFailedRetry`:`update.chip.ready`)})]}):e.status===`error`?V(`div`,{className:`update-chip update-chip--error`,role:`status`,title:e.error||t(`update.chip.checkFailed`),children:[P(q,{size:13,className:`update-chip__icon`}),P(`span`,{className:`update-chip__label`,children:t(`update.chip.checkFailed`)}),P(`button`,{type:`button`,className:`update-chip__dismiss`,onClick:()=>r(!0),"aria-label":t(`update.chip.dismissError`),children:P(So,{size:11})})]}):null}var qP={permission_request:{icon:P(Wa,{size:16}),colorClass:`notif-type-permission`},policy_alert:{icon:P(Wa,{size:16}),colorClass:`notif-type-policy`},security_alert:{icon:P(q,{size:16}),colorClass:`notif-type-security`},status_change:{icon:P(Tr,{size:16}),colorClass:`notif-type-status`},info:{icon:P(Vi,{size:16}),colorClass:`notif-type-info`},error:{icon:P(Cr,{size:16}),colorClass:`notif-type-error`}};function JP(e,t){let n=Date.now()-e,r=Math.floor(n/1e3);if(r<60)return t(`time.justNow`);let i=Math.floor(r/60);if(i<60)return t(`time.minutesAgo`,{n:i});let a=Math.floor(i/60);if(a<24)return t(`time.hoursAgo`,{n:a});let o=Math.floor(a/24);return o<7?t(`time.daysAgo`,{n:o}):new Date(e).toLocaleDateString(te(t),{month:`short`,day:`numeric`})}function YP({onClose:e}){let t=T(),n=Qs(ko(ec)),r=Qs($s),i=Qs(e=>e.markRead),a=Qs(e=>e.markAllRead),o=Qs(e=>e.clearAll),s=Qs(e=>e.dismiss),c=Qs(e=>e.respondToPermission),l=Qs(e=>e.typeFilter),u=Qs(e=>e.setTypeFilter),d=(0,J.useCallback)(e=>{i(e)},[i]),f=(0,J.useCallback)(e=>{c(e.id,`allow`).catch(e=>console.error(`[NotificationCenter] allow failed:`,e))},[c]),p=(0,J.useCallback)(e=>{c(e.id,`deny`).catch(e=>console.error(`[NotificationCenter] deny failed:`,e))},[c]);Io(!0,e);let m=[{key:null,label:t(`notifications.filter.all`)},{key:`permission_request`,label:t(`notifications.filter.permissions`)},{key:`policy_alert`,label:t(`notifications.filter.policy`)},{key:`error`,label:t(`notifications.filter.errors`)},{key:`security_alert`,label:t(`notifications.filter.security`)},{key:`status_change`,label:t(`notifications.filter.status`)},{key:`info`,label:t(`notifications.filter.info`)}];return V(`div`,{className:`notification-center`,role:`dialog`,"aria-label":t(`notifications.dialogAria`),children:[V(`div`,{className:`notification-center-header`,children:[V(`div`,{className:`notification-center-title-row`,children:[P(`h2`,{className:`notification-center-title`,children:t(`notifications.title`)}),r>0&&P(`span`,{className:`notification-center-badge`,children:r})]}),P(`button`,{className:`btn-icon notification-center-close`,onClick:e,"aria-label":t(`notifications.close`),children:P(So,{size:18})})]}),P(`div`,{className:`notification-filter-bar`,role:`tablist`,"aria-label":t(`notifications.filterAria`),children:m.map(e=>P(`button`,{role:`tab`,"aria-selected":l===e.key,className:`notification-filter-tab ${l===e.key?`active`:``}`,onClick:()=>u(e.key),children:e.label},e.key??`all`))}),P(`div`,{className:`notification-list`,children:n.length===0?V(`div`,{className:`notification-empty`,children:[P($n,{size:40,strokeWidth:1.2}),P(`span`,{children:t(`notifications.empty`)})]}):n.map(e=>{let n=qP[e.type],r=e.type===`permission_request`&&e.tool?Ks(e,t,ny):null;return V(`div`,{className:`notification-item ${e.read?``:`unread`} ${n.colorClass}`,id:e.type===`policy_alert`&&e.receiptId?`policy-receipt-${encodeURIComponent(e.receiptId)}`:void 0,onClick:()=>d(e.id),role:`button`,tabIndex:0,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&d(e.id)},children:[!e.read&&P(`span`,{className:`notification-unread-dot`}),P(`span`,{className:`notification-icon`,children:n.icon}),V(`div`,{className:`notification-content`,children:[V(`div`,{className:`notification-content-header`,children:[P(`span`,{className:`notification-agent`,dir:`auto`,children:e.agentName}),P(`span`,{className:`notification-time`,children:JP(e.timestamp,t)})]}),r?V(D.Fragment,{children:[P(`span`,{className:`notification-title`,children:P(ay,{text:r.heading})}),P(`span`,{className:`notification-message`,children:P(ay,{text:r.question})})]}):V(D.Fragment,{children:[e.title&&P(`span`,{className:`notification-title`,children:e.title}),P(`span`,{className:`notification-message`,children:e.message})]}),e.type===`permission_request`&&e.tool&&e.tool!==`allow_path_access`&&V(`span`,{className:`notification-tool`,children:[t(`activity.policy.tool`),`: `,P(`code`,{dir:`ltr`,children:e.tool})]}),e.type===`policy_alert`&&V(`div`,{className:`notification-policy-details`,children:[e.tool&&V(`span`,{className:`notification-tool`,children:[t(`activity.policy.tool`),`: `,P(`code`,{dir:`ltr`,children:e.tool})]}),e.reason&&V(`span`,{className:`notification-policy-reason`,children:[t(`notifications.reason`),`: `,e.reason]}),e.ruleIds&&e.ruleIds.length>0&&V(`span`,{className:`notification-tool`,children:[t(`activity.policy.rules`),`: `,P(`code`,{dir:`ltr`,children:e.ruleIds.join(`, `)})]}),e.policyVersion&&V(`span`,{className:`notification-tool`,children:[t(`activity.policy.policy`),`: `,P(`code`,{dir:`ltr`,children:e.policyVersion})]}),V(`span`,{className:`notification-tool`,children:[t(`activity.policy.receipt`),`:`,` `,e.receiptId?P(`code`,{dir:`ltr`,children:e.receiptId}):P(`em`,{children:t(`activity.policy.receiptUnavailable`)})]})]}),e.type===`permission_request`&&!e.response&&V(`div`,{className:`notification-actions`,children:[V(`button`,{className:`notification-action-btn notification-action-allow`,onClick:t=>{t.stopPropagation(),f(e)},children:[P(pr,{size:14}),t(`notifications.approve`)]}),V(`button`,{className:`notification-action-btn notification-action-deny`,onClick:t=>{t.stopPropagation(),p(e)},children:[P(So,{size:14}),t(`notifications.deny`)]})]}),e.type===`permission_request`&&e.response&&P(`span`,{className:`notification-response-badge ${e.response===`allow`?`response-allow`:`response-deny`}`,children:e.response===`allow`?t(`notifications.approved`):t(`notifications.denied`)})]}),P(`button`,{className:`notification-dismiss`,onClick:t=>{t.stopPropagation(),s(e.id)},"aria-label":t(`notifications.dismiss`),children:P(So,{size:14})})]},e.id)})}),n.length>0&&V(`div`,{className:`notification-center-footer`,children:[V(`button`,{className:`notification-footer-btn`,onClick:a,disabled:r===0,children:[P(pr,{size:14}),t(`notifications.markAllRead`)]}),V(`button`,{className:`notification-footer-btn notification-footer-clear`,onClick:o,children:[P(co,{size:14}),t(`notifications.clear`)]})]})]})}var XP=1500,ZP=e=>new Promise(t=>setTimeout(t,e));async function QP({onProgress:e,isCancelled:t=()=>!1,pollMs:n=XP}={}){try{await on(ok)}catch(e){if(e?.httpStatus!==409)throw e;let t=await Ut(ok).catch(()=>null);if(!t||t.status===`completed`||t.status===`failed`)throw e}for(;!t();){let t=await Ut(ok);if(e?.(t),t.status===`completed`)return;if(t.status===`failed`)throw Error(t.error||`The GAIA agent could not be installed.`);await ZP(n)}}function $P({onInstalled:e,noBuild:t=!1}){let n=T(),[r,i]=(0,J.useState)({kind:`idle`}),a=(0,J.useRef)(!1);(0,J.useEffect)(()=>()=>{a.current=!0},[]);let o=(0,J.useCallback)(async()=>{i({kind:`installing`,percent:0});try{if(await QP({isCancelled:()=>a.current,onProgress:e=>{a.current||i({kind:`installing`,percent:e.percent??0})}}),a.current)return;await e(),a.current||i({kind:`idle`})}catch(e){a.current||i({kind:`failed`,error:e instanceof Error?e.message:String(e)})}},[e]);return t?P(`div`,{className:`app-notice is-warning`,role:`status`,children:P(`span`,{children:n(`agentNotice.noBuild`)})}):V(`div`,{className:`app-notice is-warning`,role:`status`,children:[r.kind===`installing`?P(`span`,{children:n(`agentNotice.installing`,{percent:Math.round(r.percent)})}):r.kind===`failed`?P(`span`,{children:n(`agentNotice.failed`,{error:r.error})}):P(`span`,{children:n(`agentNotice.missing`)}),r.kind!==`installing`&&P(`button`,{type:`button`,className:`link-btn`,onClick:()=>void o(),children:r.kind===`failed`?n(`agentNotice.retry`):n(`agentNotice.install`)})]})}function eF(e,t){if(!(e instanceof Error))return t;let n=e.message,r=n.match(/API \d+: (.+)/);if(r)try{let e=JSON.parse(r[1]);if(e.detail)return e.detail}catch{}return n}function tF(e,t){let{addNotification:n}=Qs.getState();for(let r of t)r.error_count<=(e[r.id]??0)||!r.last_error||n({id:`schedule-error-${r.id}-${r.error_count}`,type:`error`,agentId:`scheduler`,agentName:`GAIA`,title:`Scheduled task "${r.name}" failed`,message:r.last_error,timestamp:Date.now(),read:!1,dismissed:!1,priority:`high`,...r.session_id?{sessionId:r.session_id}:{}})}var nF=p((e,t)=>({schedules:[],loading:!1,error:null,actionError:null,selectedSchedule:null,results:[],resultsLoading:!1,errorCounts:null,loadSchedules:async()=>{t().schedules.length===0&&!t().error&&e({loading:!0}),e({error:null});try{let n=(await At()).schedules||[],r=t().errorCounts;r&&tF(r,n),e({schedules:n,loading:!1,errorCounts:Object.fromEntries(n.map(e=>[e.id,e.error_count]))})}catch(t){d.api.error(`Failed to load schedules`,t),e({error:`Failed to load schedules`,loading:!1})}},createSchedule:async(t,n,r)=>{try{let i=await yt(t,n,r);e(e=>({schedules:[...e.schedules,i],actionError:null}))}catch(e){throw d.api.error(`Failed to create schedule`,e),e}},updateScheduleStatus:async(t,n)=>{try{let r=await ut(t,n);e(e=>({schedules:e.schedules.map(e=>e.name===t?r:e),actionError:null}))}catch(n){d.api.error(`Failed to update schedule "${t}"`,n),e({actionError:eF(n,`Failed to update schedule`)})}},runScheduleNow:async t=>{try{let n=await Jt(t);e(e=>({schedules:e.schedules.map(e=>e.name===t?n:e),actionError:null}))}catch(n){d.api.error(`Failed to run schedule "${t}" now`,n),e({actionError:eF(n,`Could not run the schedule now`)})}},deleteSchedule:async t=>{try{await Qe(t),e(e=>({schedules:e.schedules.filter(e=>e.name!==t),selectedSchedule:e.selectedSchedule===t?null:e.selectedSchedule,actionError:null}))}catch(n){d.api.error(`Failed to delete schedule "${t}"`,n),e({actionError:eF(n,`Failed to delete schedule`)})}},selectSchedule:n=>{e({selectedSchedule:n,results:[],resultsLoading:!1}),n&&t().loadResults(n)},loadResults:async n=>{e({resultsLoading:!0});try{let r=await De(n);if(t().selectedSchedule!==n)return;e({results:r.results||[],resultsLoading:!1})}catch(r){if(d.api.error(`Failed to load results for "${n}"`,r),t().selectedSchedule!==n)return;e({results:[],resultsLoading:!1})}},dismissActionError:()=>e({actionError:null})})),rF=new Set([`loading_model`,`downloading_model`,`model_retry`,`waiting`]),iF=5;function aF(e,t){return{id:e,title:t.get(e)?.title??`Untitled chat`}}function oF(e){let t=new Map(e.sessions.map(e=>[e.id,e])),n=e.isStreaming&&e.currentSessionId!==null,r=[...e.runningSessionIds];n&&!r.includes(e.currentSessionId)&&r.push(e.currentSessionId);let i=new Set(r),a=new Set(e.notifications.filter(e=>e.type===`permission_request`&&!e.response&&!e.dismissed&&e.sessionId&&i.has(e.sessionId)).map(e=>e.sessionId)),o=[...a].map(e=>({...aF(e,t),reason:`approval`}));n&&e.awaitingUser&&!a.has(e.currentSessionId)&&o.push({...aF(e.currentSessionId,t),reason:`answer`});for(let[n,r]of Object.entries(e.awaitingBySession))o.some(e=>e.id===n)||o.push({...aF(n,t),reason:r===`question`?`answer`:`approval`});let s=n&&!e.awaitingUser&&e.livePhase&&rF.has(e.livePhase)?e.liveStatus:null,c=e.systemStatus,l=null;if(c?.default_model_is_cloud&&c.default_model_name)l={name:c.default_model_name,where:`cloud`};else if(c?.model_loaded){let e=c.model_labels?.includes(`cloud`),t=c.model_device&&c.model_device!==`none`?c.model_device:null;l={name:c.model_loaded,where:e?`cloud`:t}}let u=[...e.sessions].sort((e,t)=>t.updated_at.localeCompare(e.updated_at)).slice(0,iF).map(e=>aF(e.id,t));return{backendConnected:e.backendConnected,modelServerRunning:c&&!c.default_model_is_cloud?c.lemonade_running:null,model:l,waitingOnModel:s||null,running:r.map(e=>aF(e,t)),needsYou:o,recent:u}}function sF(e){let t=(0,J.useRef)(e);t.current=e,(0,J.useEffect)(()=>{let e=window.gaiaAPI?.tray;if(!e)return;let n=``,r=null,i=()=>{let t=k.getState(),i={backendConnected:t.backendConnected,systemStatus:t.systemStatus,sessions:t.sessions,runningSessionIds:t.runningSessionIds,awaitingBySession:t.awaitingBySession,currentSessionId:t.currentSessionId,isStreaming:t.isStreaming,awaitingUser:t.awaitingUser,liveStatus:t.liveStatus,livePhase:t.livePhase,notifications:Qs.getState().notifications},a=r;if(r=i,a&&Object.keys(i).every(e=>i[e]===a[e]))return;let o=oF(i),s=JSON.stringify(o);s!==n&&(n=s,e.setActivity(o).catch(e=>{n=``,d.system.error(`The tray could not take the app state`,e)}))};i();let a=k.subscribe(i),o=Qs.subscribe(i),s=e.onCommand(e=>{switch(e.type){case`open-chat`:t.current.openChat(e.sessionId);break;case`new-chat`:t.current.newChat();break;case`open-settings`:k.getState().openSettings(e.section);break;case`refresh-status`:t.current.refreshStatus();break;default:d.system.error(`Unknown tray command`,e)}});return()=>{a(),o(),s()}},[])}function cF(){(0,J.useEffect)(()=>{let e=window.gaiaAPI;if(!e)return;let t=Qs.getState().addNotification,n=[e.notification.onNotification(t),e.notification.onPermissionRequest(t),e.tray.onNavigate(e=>{let t=typeof e==`string`&&e.startsWith(`session:`)?e.slice(8):null;if(!t)return;let n=k.getState();n.currentSessionId!==t&&n.setMessages([]),n.setCurrentSession(t)})];return()=>n.forEach(e=>e())},[])}function lF(e,t,n){let r=window.gaiaAPI;if(r){r.notification.show({title:t,body:n,sessionId:e}).then(e=>{e||d.system.warn(`This OS has no desktop notifications; the badge still counts it.`)}).catch(e=>d.system.error(`Could not show the desktop notification`,e));return}if(typeof Notification>`u`){d.system.warn(`This browser has no notifications; the alert was not shown.`);return}if(Notification.permission!==`granted`){d.system.warn(`Browser notifications are ${Notification.permission}; allow them in Settings → Notifications.`);return}let i=new Notification(t,{body:n,tag:`gaia-${e}`});i.onclick=()=>{window.focus(),k.getState().setCurrentSession(e)}}function uF(){let[e,t]=(0,J.useState)(null);return(0,J.useEffect)(()=>{let e=navigator;if(!e.getBattery)return;let n=null,r=()=>{n&&t({charging:n.charging,level:n.level})};return e.getBattery().then(e=>{n=e,r(),e.addEventListener(`levelchange`,r),e.addEventListener(`chargingchange`,r)}).catch(e=>d.system.warn(`Battery level unavailable; keep-awake ignores the battery policy.`,e)),()=>{n?.removeEventListener(`levelchange`,r),n?.removeEventListener(`chargingchange`,r)}},[]),e}function dF(){cF();let e=k(e=>e.runningSessionIds),t=k(e=>e.awaitingBySession),n=k(e=>e.sessions),r=k(e=>e.currentSessionId),i=Qs(ko(nc)),a=lc(),o=uF(),s=(0,J.useRef)(null),c=gc(e,t,i),l=JSON.stringify(c);(0,J.useEffect)(()=>{let e=JSON.parse(l),t=s.current;if(s.current=e,t===null)return;let{sessions:n,currentSessionId:r}=k.getState(),i=document.hasFocus(),o=!1;for(let{sessionId:s,event:c}of _c(t,e)){let e=n.find(e=>e.id===s);if(e?.kind===`eval`||e?.kind===`scheduled`)continue;let t=a.modes[c];if(!(t===`off`||bc(s,r,i))&&(o=!0,t===`banner`)){if(c!==`finished`){let{title:t,body:n}=yc(c,e);lF(s,t,n)}else mt(s).then(e=>{k.getState().updateSessionInList(s,e);let{title:t,body:n}=yc(c,e);lF(s,t,n)}).catch(t=>{d.system.error(`Could not read how chat ${s} ended`,t);let{title:n,body:r}=yc(c,{...e,last_run_status:null});lF(s,n,r)})}}if(o){if(a.sound)try{Cc()}catch(e){d.system.warn(`Alert sound not played`,e)}a.flash&&!i&&window.gaiaAPI&&window.gaiaAPI.notification.flash().catch(e=>d.system.error(`Could not flash the taskbar button`,e))}},[l,a.modes,a.sound,a.flash]);let u=xc(n,c,a.modes,r);(0,J.useEffect)(()=>{window.gaiaAPI?.notification.setAttentionCount(u).catch(e=>d.system.error(`Could not update the taskbar badge`,e))},[u]);let f=a.keepAwake&&e.length>0&&Sc(o,a.batteryFloor);(0,J.useEffect)(()=>{window.gaiaAPI?.power.setKeepAwake(f).catch(e=>d.system.error(`Could not change keep-awake`,e))},[f])}function fF(e){if(e<=0)return`0 B`;let t=1024,n=[`B`,`KB`,`MB`,`GB`],r=Math.min(Math.floor(Math.log(e)/Math.log(t)),n.length-1);return parseFloat((e/t**r).toFixed(1))+` `+n[r]}function pF(e){return e.replace(/-/g,``).slice(0,7)}function mF(e,t){let n=t.replace(/^#/,``).toLowerCase();if(!n||n.length<4)return null;let r=e.find(e=>e.id.replace(/-/g,``).toLowerCase().startsWith(n));return r?r.id:null}function hF(e,t,n){return!e||t&&(e===t||e===pF(t))?null:n.some(t=>t.id===e)?e:mF(n,e)}function gF(e){return new URLSearchParams(e.search).get(`session`)||e.hash.replace(/^#/,``)||null}var _F=`gaia:last-session`;function vF(e){try{e?localStorage.setItem(_F,e):localStorage.removeItem(_F)}catch(e){d.ui.warn(`Could not save the open chat for the next launch`,e)}}function yF(){try{return localStorage.getItem(_F)}catch(e){return d.ui.warn(`Could not read the chat open at last launch`,e),null}}var bF=1e3,xF=3e4;function SF(e,{initialMs:t=bF,maxMs:n=xF,onError:r}={}){let i=t,a=0,o=null,s=!1,c=!1,l=!1,u=()=>{l||c||s||(o&&=(clearTimeout(o),null),s=!0,a+=1,e().then(()=>{c=!0}).catch(e=>{l||(r?.(e,a),o=setTimeout(()=>{o=null,u()},i),i=Math.min(i*2,n))}).finally(()=>{s=!1}))};return u(),{kick:()=>{o&&u()},stop:()=>{l=!0,o&&clearTimeout(o),o=null},done:()=>c}}function CF(e,t,n){return e&&!t&&!n}var wF=(0,J.lazy)(()=>PP(()=>import(`./MemoryDashboard-D2A5sTz6.js`).then(e=>({default:e.MemoryDashboard})),__vite__mapDeps([6,1,2,7,8]),import.meta.url)),TF=(0,J.lazy)(()=>PP(()=>import(`./ScheduleManager-Bye5OV6N.js`).then(e=>({default:e.ScheduleManager})),__vite__mapDeps([9,1,2,7,3,10]),import.meta.url)),EF=(0,J.lazy)(()=>PP(()=>import(`./DocumentLibrary-B8SHRZpL.js`).then(e=>({default:e.DocumentLibrary})),__vite__mapDeps([11,1,2,3,12]),import.meta.url)),DF=(0,J.lazy)(()=>PP(()=>import(`./FileBrowser-OU9tD0Ek.js`).then(e=>({default:e.FileBrowser})),__vite__mapDeps([13,1,2,3,14]),import.meta.url)),OF=(0,J.lazy)(()=>PP(()=>import(`./MobileAccessModal-BgeK3LK3.js`).then(e=>({default:e.MobileAccessModal})),__vite__mapDeps([15,1,2,3,16]),import.meta.url)),kF=3,AF=3e5,jF=6e3,MF=6e4,NF=e=>e instanceof TypeError,PF=e=>new Promise(t=>setTimeout(t,e)),FF=3e5,IF=class extends Error{};async function LF(){let e=Date.now()+FF;for(;;){let t=await Ce();if(t.state===`ready`)return;if(t.state===`failed`||t.state===`cancelled`)throw new IF(t.error||I().bare(`setup.upgrading.stopped`));if(Date.now()>=e)throw Error(I().bare(`setup.upgrading.slow`));await PF(bF)}}function RF(){return P(`div`,{className:`loading-spinner`,role:`status`,"aria-label":`Loading`})}var zF=e=>e===1||e%10==0;function BF(){let e=T(),t=k(e=>e.currentSessionId),n=k(e=>e.setSessions),r=k(e=>e.setCurrentSession),i=k(e=>e.addSession),a=k(e=>e.setMessages),o=k(e=>e.showDocLibrary),s=k(e=>e.showFileBrowser),c=k(e=>e.showMemoryDashboard),l=k(e=>e.showSchedules),u=k(e=>e.sidebarOpen),f=k(e=>e.sidebarCollapsed),p=k(e=>e.setSidebarOpen),h=k(e=>e.setSystemStatus),g=k(e=>e.setBackendConnected),_=k(e=>e.setAgents),v=k(e=>e.agents),y=k(e=>e.setPendingPrompt),b=k(e=>e.setDefaultPermissionMode),x=k(e=>e.openSettings),S=k(e=>e.settingsSection),C=k(e=>e.syncSystemTheme),w=cs(e=>e.restoreNotice),E=cs(e=>e.dismissRestoreNotice),D=Qs(e=>e.showPanel),O=k(e=>e.systemStatus?.initialized===!0),A=(0,J.useRef)(!1),j=Qs(e=>e.setShowPanel);(0,J.useEffect)(()=>{if(!w?.ok)return;let e=setTimeout(E,jF);return()=>clearTimeout(e)},[w,E]);let[M,N]=(0,J.useState)({state:`checking`}),F=k(e=>e.setupAgain),I=k(e=>e.runSetupAgain),ee=(0,J.useRef)(M);ee.current=M;let[R,z]=(0,J.useState)(!1),B=(0,J.useRef)(R);B.current=R;let[te,ne]=(0,J.useState)(!1),[re,ie]=(0,J.useState)(!1),ae=te||R&&!sk(v),oe=(0,J.useRef)(ae);oe.current=ae;let[H,se]=(0,J.useState)(null),[W,ce]=(0,J.useState)(``),[le,de]=(0,J.useState)(0),[fe,pe]=(0,J.useState)(!1),[me,he]=(0,J.useState)(!1),[ge,_e]=(0,J.useState)(null),[ve,ye]=(0,J.useState)(null),be=(0,J.useRef)(async()=>{}),xe=(0,J.useRef)(async()=>{}),Se=(0,J.useCallback)(async(e=!1,t=!1)=>{e||N({state:`checking`});let n=0;try{for(;;){await cs.getState().refresh();let e=!!cs.getState().active?.remote,r;try{r=await G(e)}catch(e){if(!t||!NF(e)||n>=MF)throw e;await PF(bF),n+=bF;continue}if(!r.ready&&r.stage===`upgrade`){N({state:`upgrading`});let t=await Ce();(!t.upgrade_embedded||t.state!==`running`&&t.state!==`verifying`)&&await ft(e,!1,{upgradeEmbedded:!0}),await LF(),r=await G(e)}n>0&&await Promise.all([be.current(),xe.current()]),ie(!!r.no_agent_build),N(r.ready?{state:`ready`}:{state:`needed`,check:r});return}}catch(e){let t=e instanceof Error?e.message:String(e);if(e instanceof IF){d.system.warn(`Updating the local model server failed`,e),N({state:`unknown`,error:t,upgradeFailed:!0});return}d.system.warn(`Setup check could not be answered`,e),N({state:`unknown`,error:t})}},[]),we=(0,J.useRef)(0),Te=(0,J.useCallback)(async()=>{let e=++we.current,t=(await _n()).agents||[];e===we.current&&(_(t),z(!0),sk(t)&&ne(!1))},[_]),Ee=(0,J.useCallback)(()=>{let e=B.current;z(!1),Te().catch(t=>{d.api.warn(`Agent list unavailable after setup`,t),e&&z(!0)})},[Te]);(0,J.useEffect)(()=>{let e=()=>{oe.current&&Te().catch(e=>d.api.warn(`Agent list unavailable`,e))};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[Te]);let De=(0,J.useCallback)(async()=>{b((await an()).default_mode)},[b]),Oe=(0,J.useRef)([]);(0,J.useEffect)(()=>{m(`0.26.0rc1`),Se(!1,!0);let e=[SF(Te,{onError:(e,t)=>{zF(t)&&d.api.warn(`Agent list unavailable (attempt ${t}); retrying`,e)}}),SF(De,{onError:(e,t)=>{zF(t)&&d.api.warn(`Default permission mode unavailable (attempt ${t}); retrying`,e)}})];return Oe.current=e,()=>e.forEach(e=>e.stop())},[Se,Te,De]);let ke=(0,J.useCallback)(()=>{Oe.current.forEach(e=>e.kick()),cs.getState().retryNow(),xe.current();let e=ee.current;e.state===`unknown`&&!e.upgradeFailed&&Se(!0)},[Se]),Ae=(0,J.useRef)(ke);Ae.current=ke;let je=(0,J.useRef)(0),Me=(0,J.useRef)(0),Ne=(0,J.useRef)(null),Pe=(0,J.useRef)(!1),[Fe,Ie]=(0,J.useState)(!1),[Le,Re]=(0,J.useState)(null),ze=(0,J.useCallback)(e=>{if(e.kind===`unreachable`){d.system.warn(`System status check failed`,e.error),Pe.current=!0,Me.current=0,Ne.current=null,Ie(!1),Re(null),g(!1),h(null);return}if(e.kind===`error`){d.system.warn(`System status answered HTTP ${e.httpStatus}`,e.message),Pe.current&&Ae.current(),Pe.current=!1,Me.current=0,Ne.current=null,Ie(!1),Re(`HTTP ${e.httpStatus}: ${e.message}`),g(!0);return}if(e.kind===`slow`){if(Me.current+=1,Ne.current??=Date.now(),Re(null),d.system.warn(`System status did not answer in time (${Me.current} in a row)`),Date.now()-Ne.current>=AF){Ie(!1),g(!1),h(null);return}g(!0),(Pe.current||Me.current>=kF)&&Ie(!0);return}let{status:t}=e;Pe.current&&Ae.current(),Pe.current=!1,Me.current=0,Ne.current=null,Ie(!1),Re(null),g(!0),je.current=t.lemonade_running?0:je.current+1;let n=k.getState().systemStatus;t.lemonade_running||je.current>=kF||!n?.lemonade_running?h(t):h({...n,download_progress:t.download_progress})},[g,h]),Be=(0,J.useRef)(ze);Be.current=ze;let[Ve]=(0,J.useState)(()=>Ww(e=>Be.current(e))),He=Ve.check;be.current=He,(0,J.useEffect)(()=>hk(Ve.start),[Ve]),(0,J.useEffect)(()=>BP(()=>{He()}),[He]);let Ue=(0,J.useRef)(``);(0,J.useEffect)(()=>{let e=e=>Ft().then(t=>{let r=t.sessions||[];if(!e&&r.length===0&&k.getState().sessions.length>0)return;let i=r.map(e=>`${e.id}|${e.updated_at}|${e.title}|${e.inference_remote}|${e.inference_provider}|${e.inference_description}|${e.effective_model}|${e.unread}|${e.pinned}|${e.last_run_status}|${e.kind}`).join(`
|
|
81
|
+
`)})]})]}),nn&&P(`p`,{className:`setup-error`,role:`alert`,children:n(`setup.summary.short`,{need:$(nn.needGb),free:$(nn.freeGb),drive:n(`setup.summary.theDrive`),freeUp:$(nn.freeUpGb)})}),(me??A)&&P(mN,{text:me??A})]}),V(`details`,{className:`setup-disclosure`,children:[P(`summary`,{children:n(`setup.plan.whatDownloads`)}),P(fM,{plan:L,models:tn})]})]}),sn===`gpu`&&oe&&V(D.Fragment,{children:[P(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.gpu.title`)}),P(`p`,{className:`setup-lede`,children:n(`setup.gpu.lede`)}),P($j,{status:oe,onStatus:H,mode:`setup`,headingId:`setup-title`,names:Yt,onBack:Pt,onSkip:()=>kt(d),onContinue:()=>kt(d)})]}),sn===`models`&&V(D.Fragment,{children:[P(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.models.title`)}),L&&B&&P(PM,{plan:L,selection:B,onSelection:te,disabled:fe||Tn,onRecheck:()=>void pt()}),Nt&&oe?.total_gb!=null&&oe.gpu_gb!=null&&V(`p`,{className:`setup-hint setup-gpu-option`,children:[n(`setup.models.gpu`,{gpu:$(oe.gpu_gb),total:$(oe.total_gb)}),` `,P(`button`,{type:`button`,className:`link-btn`,onClick:()=>Ft(`models`),disabled:fe||Tn,children:n(`setup.found.changeMemory`)})]}),P(eM,{plan:L,planError:R,onRetryPlan:()=>void pt(),onUseRecommended:()=>void xt(!1,{keepTrying:U}),selection:B,onSelection:te,cloud:!1,keepTrying:U,onKeepTrying:se,onBack:Pt,onContinue:e=>void Ot(e),busy:fe||Tn,error:me??A})]}),sn===`key`&&V(`form`,{id:`setup-key-form`,onSubmit:e=>{e.preventDefault(),Ht()},className:`setup-form`,children:[P(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.key.title`)}),P(`div`,{className:`setup-choices`,role:`radiogroup`,"aria-label":n(`setup.key.provider`),children:aN.filter(e=>e.id!==`local`).map(e=>V(`button`,{type:`button`,role:`radio`,"aria-checked":a===e.id,className:`setup-choice${a===e.id?` is-active`:``}${et(e.id)?` is-disabled`:``}`,onClick:()=>Ut(e.id),disabled:F.busy||et(e.id),children:[P(Fr,{size:16,"aria-hidden":`true`}),V(`span`,{children:[P(`span`,{className:`setup-choice-title`,children:P(`bdi`,{children:oN(e,n)})}),P(`span`,{className:`setup-choice-note`,children:et(e.id)?n(`setup.key.gatewayOff`):n(e.note)})]})]},e.id))}),Ye?.reachable===!1&&P(`button`,{type:`button`,className:`link-btn setup-start`,onClick:Qe,children:n(`setup.key.checkAgain`)}),a===`fireworks`&&!ke&&V(`section`,{className:`setup-card`,children:[P(`h3`,{className:`mc-job-title`,children:n(`setup.key.getOne`)}),V(`ol`,{className:`setup-key-steps`,children:[P(`li`,{children:P(`a`,{href:rN,target:`_blank`,rel:`noreferrer`,children:n(`setup.key.step1`)})}),P(`li`,{children:n(`setup.key.step2`)}),P(`li`,{children:n(`setup.key.step3`)})]})]}),a===`amd`&&!ke&&P(`section`,{className:`setup-card`,children:P(`p`,{className:`setup-hint`,children:P(`a`,{href:iN,target:`_blank`,rel:`noreferrer`,children:n(`setup.key.gatewayHelp`)})})}),P(HA,{provider:a,limit:3}),P(`p`,{className:`setup-hint`,children:n(ke?`setup.key.usersServer`:`setup.key.where`)}),P(`div`,{className:`setup-row`,children:!ke&&P(`input`,{className:`settings-input`,type:`password`,autoComplete:`off`,value:M,onChange:e=>N(e.target.value),placeholder:n(`setup.key.placeholder`),"aria-label":n(`setup.key.label`)})}),$e&&!ke&&!M&&P(`p`,{className:`setup-hint`,role:`status`,children:n(`setup.key.foundEnv`,{name:$e.name,hint:$e.key_hint??``})}),F.busy&&!F.waiting&&P(`p`,{className:`setup-hint`,role:`status`,children:n(`setup.key.testing`)}),F.busy&&F.waiting&&P(`p`,{className:`setup-hint`,role:`status`,children:F.waiting}),F.error&&P(`p`,{className:`setup-error`,role:`alert`,children:F.error}),V(Uj,{children:[P(`button`,{type:`button`,className:`btn-secondary`,onClick:At,disabled:F.busy,children:n(`setup.back`)}),V(`button`,{type:`submit`,form:`setup-key-form`,className:`btn-primary`,disabled:F.busy||et(a)||Tn,children:[F.busy&&P(K,{size:13,className:`spin`}),` `,n(`setup.key.connect`)]})]})]}),sn===`download`&&!it&&V(D.Fragment,{children:[P(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.download.title`)}),P(`p`,{className:`setup-lede`,children:n(`setup.download.lede`)}),V(`p`,{className:`setup-hint`,role:`status`,children:[P(K,{size:13,className:`spin`,"aria-hidden":`true`}),` `,n(`setup.download.starting`)]})]}),sn===`download`&&it&&V(D.Fragment,{children:[P(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.download.title`)}),P(`p`,{className:`setup-lede`,children:n(`setup.download.lede`)}),L&&P(`section`,{className:`setup-card`,"aria-label":n(`setup.contents.title`),children:P(fM,{plan:L,run:it,onRetry:Ct,retryDisabled:fe})}),(it.models?.length??0)>0?P(`div`,{className:O?`is-stale`:void 0,children:P(wM,{status:{...it,overall:xj(it,ne??L)},names:Yt,freeGb:L?.disk?.free_gb??null,onCancel:()=>void Lt(),onRetry:(e,t)=>void zt(e,t),onResume:e=>void zt(e,null),onResumeAll:Ct,onSkip:e=>void Bt(e),onRestart:()=>void Vt(),busy:fe||!!O,retryLater:at,labelledBy:`setup-title`})}):at?V(`p`,{className:`setup-hint`,role:`status`,children:[P(K,{size:13,className:`spin`,"aria-hidden":`true`}),` `,n(`setup.download.working`)]}):null,Dn.length>0&&V(`section`,{className:`setup-card`,"aria-label":n(`setup.optional.title`),children:[P(`h3`,{className:`mc-job-title`,children:n(`setup.optional.title`)}),P(`p`,{className:`setup-hint`,children:n(`setup.optional.lede`)}),P(`ul`,{className:`setup-rows`,children:Dn.map(e=>{let t=we.includes(e.id);return V(`li`,{className:`setup-result is-waiting`,children:[P(`span`,{className:`setup-result-label`,children:n(`setup.purpose.${e.roles[0]}`)}),V(`span`,{className:`setup-result-value`,children:[P(`bdi`,{dir:`ltr`,children:e.size_gb==null?n(`setup.contents.sizeOnDownload`):$(e.size_gb)}),P(`button`,{type:`button`,className:`btn-secondary`,"aria-pressed":t,onClick:()=>Te(n=>t?n.filter(t=>t!==e.id):[...n,e.id]),children:n(t?`setup.optional.added`:`setup.optional.add`)})]})]},e.id)})})]}),O&&V(D.Fragment,{children:[P(`p`,{className:`setup-error`,role:`alert`,children:n(`setup.lostContact`,{error:O})}),P(Uj,{children:P(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void yt(),children:n(`setup.reconnect`)})})]}),Xt&&Qt&&!$t&&it.state===`failed`&&!it.model_failed&&(it.problem?P(pN,{problem:it.problem,onRetry:Ct,onUseGaia:()=>void xt(!0,Pe.current.options)}):V(`div`,{className:`setup-error`,role:`alert`,children:[P(`p`,{children:n(`setup.download.stoppedBeforeCheck`)}),it.error&&V(`details`,{className:`dl-details`,children:[P(`summary`,{children:n(`setup.progress.details`)}),P(`pre`,{dir:`ltr`,children:it.error})]})]})),Xt&&Qt&&!$t&&V(D.Fragment,{children:[P(`p`,{className:`setup-hint`,children:n(`setup.download.finishNote`)}),P(Uj,{children:P(`button`,{type:`button`,className:`btn-primary`,onClick:Ct,disabled:fe,children:n(`setup.finish`)})})]}),Xt&&!Qt&&!$t&&!(it.models??[]).some(e=>e.state===`failed`||e.state===`cancelled`)&&V(D.Fragment,{children:[P(hN,{run:it}),it.problem?P(pN,{problem:it.problem,onRetry:Ct,onUseGaia:()=>void xt(!0,Pe.current.options)}):P(Uj,{children:P(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void xt(!!it.gaia_lemonade,Pe.current.options),children:n(`setup.tryAgain`)})})]}),(me||A)&&P(mN,{text:me??A})]}),sn===`test`&&it&&V(D.Fragment,{children:[P(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.test.title`)}),P(`p`,{className:`setup-lede`,children:n(`setup.test.lede`)}),P(nN,{run:it,expected:En,names:Yt,catalog:en,onRetry:Ct,onChooseAnother:tt?void 0:jt,onCancel:()=>void Lt(),onDownloadAgain:L?.lemonade.mode===`external`?void 0:e=>void zt(e,`verify`),busy:fe}),Xt&&it.error&&!(it.tests??[]).some(e=>e.error===it.error)&&V(`details`,{className:`dl-details`,children:[P(`summary`,{children:n(`setup.progress.details`)}),P(`pre`,{dir:`ltr`,children:it.error})]}),(me||A)&&P(mN,{text:me??A})]}),sn===`ready`&&V(D.Fragment,{children:[P(`h1`,{id:`setup-title`,className:`setup-title`,tabIndex:-1,children:n(`setup.ready.heading`)}),V(`div`,{className:`setup-done`,role:`status`,children:[P(`div`,{className:`setup-done-head`,children:Kt&&P(`p`,{children:n(tt?`setup.ready.answersCloud`:`setup.ready.answersLocal`,{model:tt?vs(Kt):Yt[Kt]??ie?.catalog?.find(e=>e.id===Kt)?.name??vs(Kt)})})}),P(Uj,{children:P(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void Jt(),autoFocus:!0,children:n(`setup.ready.start`)})}),!tt&&ie&&P(tM,{plan:ie,chatModel:Kt,gpu:oe}),A&&P(mN,{text:A}),(it?.tests??[]).filter(e=>e.state===`failed`).map(e=>P(`p`,{className:`setup-failed-extra`,role:`alert`,children:n(`setup.ready.extraFailed`,{job:n(`setup.test.job.${e.job}`)})},`${e.job}:${e.subject??``}`)),Ee.length>0&&!W&&P(`p`,{className:`setup-failed-extra`,role:`alert`,children:n(`setup.ready.extraNotFetched`,{names:Ee.map(e=>Yt[e]??e).join(`, `)})}),xe.length>0&&V(D.Fragment,{children:[P(`p`,{className:`setup-hint`,children:n(`setup.ready.tasks`)}),P(oM,{cards:xe,onPick:e=>void Jt(e)})]})]})]})]},sn),t&&!at&&sn!==`plan`&&sn!==`ready`&&P(`div`,{className:`setup-row`,children:P(`button`,{type:`button`,className:`link-btn setup-close`,onClick:t,children:n(`setup.backToGaia`)})}),Tn&&(wn||sn===`plan`)&&P(`p`,{className:`setup-hint`,role:`status`,children:n(`setup.nav.runGoing`)}),P(DM,{run:w,before:{check:mn}})]}),P(`div`,{className:`setup-footer`,ref:m})]})}),W?.kind===`no_fit`&&P(Wj,{title:W.models.length===1?n(`setup.confirm.noFitOne`,{name:W.models[0].name}):n(`setup.confirm.noFitMany`),confirmLabel:n(`setup.confirm.downloadAnyway`),cancelLabel:n(`setup.confirm.pickSmaller`),onConfirm:()=>{G(null),de(!0),Ot(Tt,!0)},onCancel:()=>G(null),children:W.models.map(e=>V(`p`,{children:[P(`bdi`,{children:e.name}),`: `,Oj(e,n)]},e.id))}),W?.kind===`low_disk`&&nn&&P(Wj,{title:n(`setup.confirm.lowDiskTitle`),confirmLabel:n(`setup.confirm.downloadAnyway`),cancelLabel:n(`setup.confirm.changeModels`),onConfirm:()=>{G(null),Ot(!0)},onCancel:()=>{G(null),jt()},children:P(`p`,{children:n(`setup.summary.short`,{need:$(nn.needGb),free:$(nn.freeGb),drive:n(`setup.summary.theDrive`),freeUp:$(nn.freeUpGb)})})}),W?.kind===`server`&&P(Wj,{title:W.detail.code===`low_disk`?n(`setup.confirm.lowDiskTitle`):n(`setup.confirm.noFitServerTitle`),confirmLabel:W.detail.code===`low_disk`?n(`setup.confirm.downloadAnyway`):n(`setup.confirm.useAnyway`),cancelLabel:n(`setup.confirm.changeModels`),onConfirm:()=>{let e=W;if(G(null),e.then===`chat`)de(!0),Ot(Tt,!0);else if(e.then===`retry`)ve(e.id,{keepTrying:U,acknowledgeLowDisk:!0}).then(E).catch(e=>he(_N(e)));else{let{gaiaLemonade:e,options:t}=Pe.current;xt(e,{...t,acknowledgeLowDisk:!0})}},onCancel:()=>{let e=W;G(null),e.then!==`retry`&&!st&&jt()},children:P(`p`,{children:W.detail.message})})]})}function yN(e,t,n){let r=(0,J.useRef)(n);(0,J.useEffect)(()=>{r.current=n});let i=(0,J.useRef)(!1),a=(0,J.useRef)(null);if(t&&!i.current){let e=document.activeElement;a.current=e instanceof HTMLElement?e:null}(0,J.useEffect)(()=>{if(!t)return;i.current=!0;let n=a.current,o=e.current;if(o&&!o.contains(document.activeElement)){let e=r.current?.()??iS(o)[0];e?e.focus():(o.hasAttribute(`tabindex`)||o.setAttribute(`tabindex`,`-1`),o.focus())}return()=>{i.current=!1;let e=document.activeElement;(!e||e===document.body||o?.contains(e))&&n?.isConnected&&n.focus()}},[e,t])}function bN({title:e,titleId:t,count:n,hint:r,defaultOpen:i=!1,forceOpen:a=!1,children:o}){let[s,c]=(0,J.useState)(i);return V(`details`,{className:`settings-disclosure`,open:s||a,onToggle:e=>{a||c(e.currentTarget.open)},children:[V(`summary`,{onClick:e=>{a&&e.preventDefault()},children:[P(hr,{size:15,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),V(`span`,{className:`settings-disclosure-text`,children:[P(`span`,{className:`settings-disclosure-title`,id:t,tabIndex:t?-1:void 0,children:e}),r&&P(`span`,{className:`settings-disclosure-hint`,children:r})]}),n!=null&&P(`bdi`,{dir:`ltr`,className:`settings-disclosure-count`,children:n})]}),P(`div`,{className:`settings-disclosure-body`,children:o})]})}var xN=g(Tc()?`settings.desktop.menuBar`:`settings.desktop.tray`),SN=[{key:`minimizeToTray`,label:`settings.desktop.keepRunning`,hint:`settings.desktop.keepRunningHint`},{key:`startOnLogin`,label:`settings.desktop.startOnLogin`,hint:`settings.desktop.startOnLoginHint`},{key:`startMinimized`,label:`settings.desktop.startMinimized`,hint:`settings.desktop.startMinimizedHint`}],CN=new Set([`startMinimized`]),wN={minimizeToTray:`settings.desktop.keepRunningNoTray`};function TN(e){return e?.reason===`no-host`?`settings.desktop.noTray`:e?.reason===`check-failed`?`settings.desktop.noTrayCheckFailed`:null}function EN(){let e=T(),t=window.gaiaAPI?.tray,[n,r]=(0,J.useState)(null),[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(null);(0,J.useEffect)(()=>{t&&t.getConfig().then(e=>{r(e.tray),a(e.host)}).catch(t=>s(e(`settings.desktop.readFailed`,{reason:t instanceof Error?t.message:String(t)})))},[t,e]);let u=(0,J.useCallback)(async e=>{if(t&&n&&c===null){l(e),s(null);try{let i=await t.setConfig({tray:{[e]:!n[e]}});r(i.tray),a(i.host)}catch(e){s(e instanceof Error?e.message:String(e))}finally{l(null)}}},[t,n,c]);if(!t)return null;let d=TN(i);return P(bN,{title:e(`settings.desktop.title`),children:V(`div`,{className:`settings-field`,role:`group`,"aria-labelledby":`desktop-app-label`,children:[P(`span`,{className:`settings-label`,id:`desktop-app-label`,children:e(`settings.desktop.title`)}),SN.map(({key:t,label:r,hint:i})=>{let a=CN.has(t)?d:null,o=d&&wN[t]||i;return V(`div`,{children:[V(`label`,{className:`setting-row`,children:[P(`span`,{children:e(r,{tray:xN})}),V(`span`,{className:`toggle-switch`,children:[P(`input`,{type:`checkbox`,role:`switch`,checked:!a&&!!n?.[t],"aria-describedby":`desktop-${t}-hint`,onChange:()=>void u(t),disabled:!!a||!n||c!==null&&c!==t,"aria-busy":c===t,"aria-label":e(r,{tray:xN})}),P(`span`,{className:`toggle-track`})]})]}),P(`p`,{className:`settings-hint`,id:`desktop-${t}-hint`,children:a?e(a):e(o,{tray:xN})})]},t)}),o&&P(`p`,{className:`settings-error`,role:`alert`,children:o})]})})}function DN(){return window.gaiaUpdater}var ON={status:`idle`,version:null,progress:0,releaseNotes:null,error:null,currentVersion:null,pinnedVersion:null,autoUpdate:!1,includePrereleases:!1};function kN(){let[e,t]=(0,J.useState)({...ON});return(0,J.useEffect)(()=>{let e=DN();if(!e)return;let n=!0;e.getStatus().then(e=>{n&&e&&t(e)}).catch(()=>{});let r=e.onStatusChange(e=>{n&&e&&t(e)});return()=>{n=!1;try{r()}catch{}}},[]),e}var AN=`gaia-update-error:`;function jN(e,t){let n=`update.err.${e}`;return N(n)?g(n,t??{}):null}function MN(e){let t=e instanceof Error?e.message:String(e),n=t.indexOf(AN);if(n<0)return t.replace(/^Error invoking remote method '[^']+': (?:Error: )?/,``);let r;try{r=JSON.parse(t.slice(n+18))}catch{return t.slice(0,n)+t.slice(n+18)}let i=jN(r.code,r.params)??r.message??r.code,a=r.note&&jN(r.note.code,r.note.params);return a?g(`update.err.withNote`,{error:i,note:a}):i}function NN(e,t){let n=MN(e);return typeof n==`object`?t(n.ref,n.params):String(n)}function PN(){return window.gaiaUpdater}function FN({onClose:e}){let t=T(),[n,r]=(0,J.useState)({kind:`loading`}),i=(0,J.useRef)(null);(0,J.useEffect)(()=>{let e=PN();e?e.listReleases().then(e=>{r(Array.isArray(e)?{kind:`list`,releases:e}:{kind:`error`,message:e.error})}).catch(()=>{r({kind:`error`,message:`Couldn't reach GitHub to list releases — check your connection; you can still download installers from the Releases page.`})}):r({kind:`error`,message:`Couldn't reach GitHub to list releases — check your connection; you can still download installers from the Releases page.`})},[]),Io(!0,e),aS(i,!0),(0,J.useEffect)(()=>{let e=i.current;e&&e.querySelector(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`)?.focus()},[]),(0,J.useEffect)(()=>{let e=i.current;if(!e)return;function t(t){if(t.key!==`Tab`||!e)return;let n=e.querySelectorAll(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`);if(n.length===0)return;let r=n[0],i=n[n.length-1];t.shiftKey?document.activeElement===r&&(t.preventDefault(),i?.focus()):document.activeElement===i&&(t.preventDefault(),r?.focus())}return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[]);function a(e,t){e.isCurrent||r({kind:`confirm`,release:e,releases:t})}async function o(n){r({kind:`installing`});let i=PN();if(!i)r({kind:`error`,message:t(`update.picker.noBridge`)});else try{await i.installVersion(n.tag),e()}catch(e){r({kind:`error`,message:t(`update.picker.failed`,{reason:MN(e)})})}}function s(e){if(!e)return``;try{return new Date(e).toLocaleDateString(te(t),{year:`numeric`,month:`short`,day:`numeric`})}catch{return e}}return P(`div`,{className:`version-picker-overlay`,onClick:t=>{t.target===t.currentTarget&&e()},children:V(`div`,{className:`version-picker-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":t(`update.picker.title`),ref:i,children:[V(`div`,{className:`version-picker-header`,children:[P(`h3`,{children:t(`update.picker.title`)}),P(`button`,{className:`version-picker-close`,onClick:e,"aria-label":t(`update.picker.close`),type:`button`,children:`×`})]}),V(`div`,{className:`version-picker-body`,children:[n.kind===`loading`&&V(`div`,{className:`version-picker-loading`,"aria-busy":`true`,children:[P(`span`,{className:`version-picker-spinner`}),t(`update.picker.loading`)]}),n.kind===`error`&&V(`div`,{className:`version-picker-error`,children:[P(`p`,{children:n.message}),P(`p`,{children:P(`a`,{href:`https://github.com/amd/gaia/releases`,target:`_blank`,rel:`noreferrer`,children:t(`update.picker.browse`)})})]}),n.kind===`list`&&P(`ul`,{className:`version-picker-list`,role:`listbox`,"aria-label":t(`update.picker.listAria`),children:n.releases.map(e=>P(`li`,{children:V(`button`,{type:`button`,className:`version-picker-row`,"data-version":e.version,"aria-label":e.isCurrent?t(`update.picker.rowInstalled`,{version:e.version}):e.isPinned?t(`update.picker.rowPinned`,{version:e.version}):e.version,"aria-disabled":e.isCurrent?`true`:`false`,onClick:()=>a(e,n.releases),disabled:e.isCurrent,children:[P(`span`,{className:`vp-version`,children:e.version}),P(`span`,{className:`vp-date`,children:s(e.date)}),e.isCurrent&&P(`span`,{className:`vp-badge vp-badge-current`,children:t(`update.picker.installed`)}),e.isPinned&&!e.isCurrent&&P(`span`,{className:`vp-badge vp-badge-pinned`,children:t(`update.picker.pinned`)}),!e.isCurrent&&P(`span`,{className:`vp-arrow`,"aria-hidden":`true`,children:`›`})]})},e.tag))}),n.kind===`list`&&V(`p`,{className:`version-picker-more`,children:[t(`update.picker.recent`,{n:n.releases.length}),` `,P(`a`,{href:`https://github.com/amd/gaia/releases`,target:`_blank`,rel:`noreferrer`,children:t(`update.picker.browseAll`)})]}),n.kind===`confirm`&&V(`div`,{className:`version-picker-confirm`,children:[P(`p`,{children:t(`update.picker.confirm`,{version:n.release.version})}),P(`p`,{className:`vp-confirm-note`,children:t(`update.picker.confirmNote`,{version:n.release.version})}),V(`div`,{className:`vp-confirm-actions`,children:[P(`button`,{type:`button`,className:`vp-btn-cancel`,onClick:()=>r({kind:`list`,releases:n.releases}),children:t(`update.picker.back`)}),P(`button`,{type:`button`,className:`vp-btn-confirm`,onClick:()=>o(n.release),children:t(`update.picker.install`)})]})]}),n.kind===`installing`&&V(`div`,{className:`version-picker-loading`,"aria-busy":`true`,children:[P(`span`,{className:`version-picker-spinner`}),t(`update.picker.starting`)]})]})]})})}var IN=`https://github.com/amd/gaia/releases`;function LN(e){return/^\d+\.\d+\.\d+-/.test(e??``)}function RN(e,t){let n=e.version??``;switch(e.status){case`checking`:return t(`update.status.checking`);case`available`:return t(`update.status.available`,{version:n});case`downloading`:return e.preparing?t(`update.status.preparing`,{version:n}):t(`update.status.downloading`,{version:n,pct:e.progress});case`downloaded`:return t(`update.status.downloaded`,{version:n});case`error`:return t(`update.status.error`,{reason:e.error??t(`update.status.unknownError`)});case`no-channel`:return e.error??t(`update.status.noChannel`);case`disabled`:return t(`update.status.disabled`);default:return t(`update.status.upToDate`)}}function zN(){let e=kN(),t=T(),n=DN(),[r,i]=(0,J.useState)(!1),[a,o]=(0,J.useState)(null),[s,c]=(0,J.useState)(!1);if(!n)return null;async function l(e,r){if(n){i(!0),o(null);try{await r(n)}catch(n){d.system.error(`${e} failed`,n),o(t(`update.settings.failed`,{action:g(e),reason:MN(n)}))}finally{i(!1)}}}let u=e.status===`disabled`,f=r||e.status===`checking`||e.status===`downloading`,p=`${t(`update.settings.running`,{version:e.currentVersion??t(`update.settings.unknownVersion`)})} ${RN(e,t)}`,m=[`available`,`downloaded`,`error`].includes(e.status)||!!e.pinnedVersion||!!e.installFailed||!!e.configError||!!a;return P(bN,{title:t(`update.settings.title`),titleId:`updates-label`,hint:p,forceOpen:m,children:V(`div`,{className:`settings-field`,role:`group`,"aria-labelledby":`updates-label`,children:[P(`p`,{className:`visually-hidden`,role:`status`,children:p}),V(`label`,{className:`setting-row`,children:[P(`span`,{children:t(`update.settings.auto`)}),V(`span`,{className:`toggle-switch`,children:[P(`input`,{type:`checkbox`,role:`switch`,checked:e.autoUpdate,"aria-describedby":`updates-auto-hint`,"aria-label":t(`update.settings.auto`),"aria-busy":r,disabled:u,onChange:()=>{r||l(`update.action.saveAuto`,t=>t.setAutoUpdate(!e.autoUpdate))}}),P(`span`,{className:`toggle-track`})]})]}),P(`p`,{className:`settings-hint`,id:`updates-auto-hint`,children:t(`update.settings.autoHint`)}),V(`label`,{className:`setting-row`,children:[P(`span`,{children:t(`update.settings.rc`)}),V(`span`,{className:`toggle-switch`,children:[P(`input`,{type:`checkbox`,role:`switch`,checked:!!e.includePrereleases,"aria-describedby":`updates-rc-hint`,"aria-label":t(`update.settings.rc`),"aria-busy":r,disabled:u,onChange:()=>{r||l(`update.action.saveRc`,t=>t.setIncludePrereleases(!e.includePrereleases))}}),P(`span`,{className:`toggle-track`})]})]}),V(`p`,{className:`settings-hint`,id:`updates-rc-hint`,children:[t(`update.settings.rcHint`),LN(e.currentVersion)&&` ${t(`update.settings.rcHintRunning`)}`]}),e.pinnedVersion&&V(`p`,{className:`settings-hint`,children:[t(`update.settings.pinned`,{version:e.pinnedVersion}),` `,P(`button`,{type:`button`,className:`btn-secondary`,disabled:r,onClick:()=>void l(`update.action.resume`,e=>e.resumeUpdates()),children:t(`update.settings.unpin`)})]}),V(`div`,{className:`setting-actions`,children:[e.status===`available`&&!e.pinnedVersion&&P(`button`,{type:`button`,className:`btn-primary`,disabled:r,onClick:()=>void l(`update.action.download`,e=>e.downloadUpdate()),children:t(`update.settings.updateTo`,{version:e.version??``})}),e.status===`downloaded`&&P(`button`,{type:`button`,className:`btn-primary`,disabled:r,onClick:()=>void l(`update.action.restart`,e=>e.restart()),children:t(`update.settings.restart`)}),P(`button`,{type:`button`,className:`btn-secondary`,disabled:f||u,onClick:()=>void l(`update.action.check`,e=>e.check()),children:t(`update.settings.check`)}),P(`button`,{type:`button`,className:`btn-secondary`,disabled:f||u,onClick:()=>c(!0),children:t(`update.settings.pick`)}),e.previousVersion&&P(`button`,{type:`button`,className:`btn-secondary`,"aria-describedby":`updates-back-hint`,disabled:f||u,onClick:()=>void l(`update.action.goBack`,e=>e.revertUpdate()),children:t(`update.settings.goBack`,{version:e.previousVersion})})]}),e.previousVersion&&P(`p`,{className:`settings-hint`,id:`updates-back-hint`,children:t(`update.settings.goBackHint`)}),e.installFailed&&P(`p`,{className:`settings-error`,role:`alert`,children:t(`update.settings.installFailed`,{...e.installFailed,url:IN})}),e.lastCheckError&&P(`p`,{className:`settings-hint`,children:t(`update.settings.lastCheckError`,{reason:e.lastCheckError})}),e.configError&&P(`p`,{className:`settings-error`,role:`alert`,children:e.configError}),a&&P(`p`,{className:`settings-error`,role:`alert`,children:a}),s&&P(FN,{onClose:()=>c(!1)})]})})}var BN=[{value:`light`,label:`settings.theme.light`},{value:`dark`,label:`settings.theme.dark`},{value:`system`,label:`settings.theme.system`}],VN={default:`palette.default`,stone:`palette.stone`,marble:`palette.marble`,glacier:`palette.glacier`,forest:`palette.forest`,sage:`palette.sage`,basalt:`palette.basalt`,gold:`palette.gold`,dusk:`palette.dusk`,custom:`settings.colors.custom`},HN=[[`Enter`,`settings.shortcut.send`],[`Shift+Enter`,`settings.shortcut.newLine`],[`Esc`,`settings.shortcut.stop`],[`Mod+Shift+O`,`settings.shortcut.newChat`],[`Mod+K`,`settings.shortcut.search`],[`Mod+B`,`settings.shortcut.sidebar`],[`Mod+,`,`settings.shortcut.settings`]];function UN(){let e=T(),t=k(e=>e.locale),n=k(e=>e.setLocale),r=k(e=>e.themePreference),i=k(e=>e.setThemePreference),a=k(e=>e.palette),o=k(e=>e.setPalette),s=k(e=>e.customColors),c=k(e=>e.setCustomColors),l=GO(e=>e.visible),u=GO(e=>e.setVisible),d=e=>t=>c({...s,[e]:t.target.value.toUpperCase()});return V(`div`,{className:`settings-pane`,children:[P(`h2`,{className:`settings-pane-title`,children:e(`settings.section.general`)}),V(`div`,{className:`settings-field`,children:[P(`label`,{className:`settings-label`,htmlFor:`ui-language`,children:e(`settings.language`)}),P(`select`,{id:`ui-language`,className:`settings-input`,value:t,onChange:e=>n(e.target.value),children:b.map(({meta:e})=>P(`option`,{value:e.code,lang:e.code,dir:e.dir,children:M(e)},e.code))}),P(`span`,{className:`settings-hint`,children:e(`settings.languageHint`)})]}),V(`div`,{className:`settings-field`,children:[P(`span`,{className:`settings-label`,id:`appearance-label`,children:e(`settings.appearance`)}),P(`div`,{className:`segmented`,role:`radiogroup`,"aria-labelledby":`appearance-label`,children:BN.map(t=>P(`button`,{type:`button`,role:`radio`,"aria-checked":r===t.value,className:r===t.value?`is-active`:``,onClick:()=>i(t.value),children:e(t.label)},t.value))})]}),V(`div`,{className:`settings-field`,children:[V(`label`,{className:`setting-row`,children:[P(`span`,{children:e(`resources.settings`)}),V(`span`,{className:`toggle-switch`,children:[P(`input`,{type:`checkbox`,checked:l,onChange:e=>u(e.target.checked),"aria-label":e(`resources.settings`),"aria-describedby":`resources-hint`}),P(`span`,{className:`toggle-track`})]})]}),P(`span`,{className:`settings-hint`,id:`resources-hint`,children:e(`resources.settingsHint`)})]}),V(bN,{title:e(`settings.colors`),titleId:`palette-label`,defaultOpen:a===`custom`,children:[V(`div`,{className:`palette-grid`,role:`radiogroup`,"aria-labelledby":`palette-label`,children:[oe.map(t=>V(`button`,{type:`button`,role:`radio`,"aria-checked":a===t.id,className:`palette-tile${a===t.id?` is-active`:``}`,onClick:()=>o(t.id),children:[P(`span`,{className:`palette-swatch`,"aria-hidden":`true`,children:t.swatch.map(e=>P(`i`,{style:{background:e}},e))}),e(VN[t.id])]},t.id)),V(`button`,{type:`button`,role:`radio`,"aria-checked":a===`custom`,className:`palette-tile${a===`custom`?` is-active`:``}`,onClick:()=>o(`custom`),children:[V(`span`,{className:`palette-swatch`,"aria-hidden":`true`,children:[P(`i`,{style:{background:s.base}}),P(`i`,{style:{background:s.accent}})]}),e(`settings.colors.custom`)]})]}),a===`custom`&&V(`div`,{className:`palette-custom`,children:[V(`label`,{className:`palette-color`,htmlFor:`custom-accent`,children:[P(`input`,{id:`custom-accent`,type:`color`,value:s.accent,onChange:d(`accent`)}),V(`span`,{children:[e(`settings.colors.accent`),P(`small`,{children:e(`settings.colors.accentHint`)})]})]}),V(`label`,{className:`palette-color`,htmlFor:`custom-base`,children:[P(`input`,{id:`custom-base`,type:`color`,value:s.base,onChange:d(`base`)}),V(`span`,{children:[e(`settings.colors.base`),P(`small`,{children:e(`settings.colors.baseHint`)})]})]}),P(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>c(v),children:e(`settings.colors.reset`)}),P(`p`,{className:`settings-hint`,children:e(`settings.colors.hint`)})]})]}),P(EN,{}),P(zN,{}),P(bN,{title:e(`settings.shortcuts`),children:P(`dl`,{className:`shortcut-list`,children:HN.map(([t,n])=>V(`div`,{className:`shortcut-row`,children:[P(`dt`,{children:P(`kbd`,{children:kc(t)})}),P(`dd`,{children:e(n)})]},t))})})]})}function WN(e){return/not reachable|not answering|model server at|ConnectionPool|NewConnectionError|Connection refused|Max retries/i.test(e)}function GN(e){return/gaia init/i.test(e??``)}function KN(e){return!!e&&!e.lemonade_running&&(GN(e.start_command)||GN(e.start_instruction))}function qN({className:e=`btn-secondary`}){let t=T();return P(`button`,{type:`button`,className:e,onClick:()=>window.dispatchEvent(new CustomEvent(`gaia:set-up-local`)),children:t(`settings.errors.setUpLocal`)})}function JN({message:e,onRetry:t}){let n=T(),r=k(e=>KN(e.systemStatus));return WN(e)?V(`div`,{className:`settings-notice`,role:`alert`,children:[P(`strong`,{children:n(r?`settings.errors.notInstalledTitle`:`settings.errors.serverDownTitle`)}),P(`p`,{children:n(r?`settings.errors.notInstalled`:`settings.errors.serverDown`)}),r&&P(qN,{className:`btn-primary`}),t&&P(`button`,{type:`button`,className:`btn-secondary`,onClick:t,children:n(`settings.key.checkAgain`)}),V(`details`,{className:`settings-more`,children:[V(`summary`,{children:[P(hr,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,n(`settings.errors.details`)]}),P(`bdi`,{dir:`ltr`,className:`settings-notice-raw`,children:e})]})]}):P(`p`,{className:`settings-error`,role:`alert`,children:e})}function YN({onAdded:e}){let t=T(),[n,r]=(0,J.useState)(``),[i,a]=(0,J.useState)(``),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(null),[u,d]=(0,J.useState)(null),f=(0,J.useRef)(``),p=(0,J.useCallback)(async e=>{let t=n.trim();f.current=t,l(`check`),d(null);try{let n=await sn(t,e);if(f.current!==t)return;s(n),a(n.file??e)}catch(e){if(f.current!==t)return;s(null),d(e instanceof Error?e.message:String(e))}finally{l(null)}},[n]),m=(0,J.useCallback)(async()=>{l(`add`),d(null);try{let{report:o}=await xt(n.trim(),i);r(``),a(``),s(null),e(o.display_name??o.model_id??t(`settings.custom.theModel`))}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(null)}},[e,i,n,t]);return V(`form`,{className:`settings-field custom-model-add`,onSubmit:e=>{e.preventDefault(),p(``)},children:[P(`label`,{className:`visually-hidden`,htmlFor:`custom-model-url`,children:t(`settings.custom.title`)}),P(`span`,{className:`settings-hint`,children:t(`settings.custom.hint`)}),V(`div`,{className:`settings-row`,children:[P(`input`,{id:`custom-model-url`,className:`settings-input`,type:`url`,inputMode:`url`,dir:`ltr`,spellCheck:!1,autoComplete:`off`,value:n,readOnly:c!==null,onChange:e=>{r(e.target.value),s(null),a(``),f.current=``},placeholder:`https://huggingface.co/unsloth/Qwen3-4B-Instruct-2507-GGUF`}),V(`button`,{type:`submit`,className:`btn-secondary`,disabled:c!==null||!n.trim(),children:[c===`check`?P(K,{size:13,className:`spin`}):null,` `,t(`settings.custom.check`)]})]}),o&&(()=>{let e=P(`ul`,{className:`custom-model-checks`,"aria-label":t(`settings.custom.checks`),children:o.checks.map(e=>V(`li`,{className:e.ok?`is-ok`:`is-failed`,children:[e.ok?P(pr,{size:13,"aria-label":t(`settings.custom.passed`)}):P(So,{size:13,"aria-label":t(`settings.custom.failed`)}),V(`bdi`,{children:[P(`strong`,{children:e.label}),` — `,e.detail]})]},e.id))});return o.ok?V(`details`,{className:`custom-model-checks-summary`,children:[V(`summary`,{children:[P(pr,{size:13,"aria-hidden":`true`}),` `,t(`settings.custom.allPassed`,{n:o.checks.length})]}),e]}):e})(),o&&o.warnings.length>0&&P(`ul`,{className:`custom-model-checks`,"aria-label":t(`settings.custom.warnings`),children:o.warnings.map(e=>V(`li`,{className:`is-warning`,children:[P(q,{size:13,"aria-label":t(`settings.custom.warning`)}),` `,P(`bdi`,{children:e})]},e))}),o&&o.variants.length>1&&V(`div`,{className:`settings-row`,children:[P(`label`,{className:`settings-hint`,htmlFor:`custom-model-quant`,children:t(`settings.custom.quantization`)}),P(`select`,{id:`custom-model-quant`,className:`settings-input`,value:i,onChange:e=>void p(e.target.value),disabled:c!==null,children:o.variants.map(e=>V(`option`,{value:e.file,children:[e.quant,` · `,e.size_gb,` GB`,e.fits?``:` · ${t.bare(`settings.custom.tooLarge`)}`]},e.file))})]}),o?.ok&&V(`div`,{className:`settings-row`,children:[V(`button`,{type:`button`,className:`btn-primary`,onClick:()=>void m(),disabled:c!==null,children:[c===`add`?P(K,{size:13,className:`spin`}):null,` `,t(`settings.custom.add`,{name:o.display_name??``})]}),P(`span`,{className:`settings-hint`,children:t(`settings.model.sizeDownload`,{size:`${o.size_gb} GB`})})]}),u&&P(JN,{message:u})]})}function XN(e){return e instanceof Error?e.message:String(e)}function ZN(e,t){return e.size===t.size&&[...e].every(e=>t.has(e))}function QN({downloadsSlot:e}){let t=T(),[n,r]=(0,J.useState)(null),[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(null),[u,d]=(0,J.useState)(!1),[f,p]=(0,J.useState)(null),[m,h]=(0,J.useState)(!1),[g,_]=(0,J.useState)(null),[v,y]=(0,J.useState)(null),b=Ls(e=>e.status),x=Ls(e=>e.started),S=(0,J.useMemo)(()=>Ps(b,x),[b,x]),C=Ls(e=>e.error),w=Ls(e=>e.refresh),E=Ls(e=>e.enqueue),O=Ls(e=>e.cancel),k=(0,J.useCallback)(async(e=!1)=>{a(null);try{let t=await ot();r(t),s(n=>e||!n?uj(t):n)}catch(e){a(XN(e))}},[]);(0,J.useEffect)(()=>{k(!0),w(),(async()=>{try{_(await Xe()??null)}catch(e){y(XN(e))}})()},[k,w]);let A=(S?.models??[]).filter(e=>e.state===`ready`).map(e=>e.id).join(`,`),j=(0,J.useRef)(A);(0,J.useEffect)(()=>{A!==j.current&&(j.current=A,k(!0))},[A,k]);let M=(0,J.useMemo)(()=>{let e={};for(let t of S?.models??[])e[t.id]=t;return e},[S]),N=(0,J.useMemo)(()=>{let e={};for(let t of n?.catalog??[])e[t.id]=t.name;return e},[n]),F=(0,J.useMemo)(()=>n?uj(n):null,[n]),I=YA(n),L=n&&o?hj(I,o).filter(e=>M[e.id]?.state!==`downloading`):[],ee=L.reduce((e,t)=>e+(t.size_gb??0),0),R=!!n&&!!o&&!!F&&(!ZN(o.ticked,F.ticked)||o.defaultChat!==F.defaultChat||L.length>0),z=(0,J.useCallback)(async(e,i)=>{if(!n||!o)return;if(p(null),!e){let e=vj(I,o).filter(e=>!e.downloaded||e.id===o.defaultChat);if(e.length>0&&e.every(e=>e.need_gb!=null)){l({kind:`no_fit`,models:e});return}}let a=_j(n,o);if(a&&!i)l({kind:`low_disk`,message:a.drop?t(`setup.summary.shortDrop`,{need:$(a.needGb),free:$(a.freeGb),drive:Mj(n.disk?.path??null)??t(`setup.summary.theDrive`),freeUp:$(a.freeUpGb),name:a.drop.name,saves:$(a.drop.size_gb??0)}):t(`setup.summary.short`,{need:$(a.needGb),free:$(a.freeGb),drive:Mj(n.disk?.path??null)??t(`setup.summary.theDrive`),freeUp:$(a.freeUpGb)})});else{d(!0);try{let i=n;if(o.defaultChat&&o.defaultChat!==i.chat_model.id)try{i=await Wt(o.defaultChat,e||m)}catch(e){let t=Oe(e);if(t){l({kind:`server`,detail:t});return}throw e}for(let e of yj(i,o))i=await ht(e.id,e.skipped);let a=hj(YA(i),o).map(e=>e.id).filter(e=>M[e]?.state!==`downloading`);r(i),s({...o,defaultChat:i.chat_model.id}),cs.getState().refresh(),a.length&&await E(a,{acknowledgeLowDisk:!0}),p({ok:!0,text:t(`settings.models.applied`)})}catch(e){p({ok:!1,text:XN(e)})}finally{d(!1)}}},[n,o,I,m,M,E,t]),B=(0,J.useCallback)(async e=>{l(null),d(!0),p(null);try{let n=await je(e.id);Uo(),r(n),s(uj(n)),p({ok:!0,text:t(`settings.models.removed`,{name:e.name,size:$(n.freed_gb)})})}catch(e){p({ok:!1,text:XN(e)})}finally{d(!1)}},[t]),te=(0,J.useCallback)((e,t)=>{(async()=>{try{t===`verify`&&await je(e),await E([e])}catch(e){p({ok:!1,text:XN(e)})}})()},[E]),ne=!!S&&(S.models?.length??0)>0&&(xM(S)||S.models.some(e=>e.state!==`skipped`))&&S&&V(`section`,{className:`settings-field models-pane-section`,"aria-labelledby":`settings-downloads-title`,children:[P(`span`,{className:`settings-label`,id:`settings-downloads-title`,children:t(`settings.models.downloads`)}),P(wM,{status:S,names:N,freeGb:n?.disk?.free_gb??null,onCancel:()=>void O(),onRetry:te,onResume:e=>void E([e]),onResumeAll:()=>void E((S.models??[]).filter(e=>e.state===`cancelled`).map(e=>e.id))}),C&&P(`p`,{className:`settings-error`,role:`alert`,children:C})]});return V(D.Fragment,{children:[P(bN,{title:t(`settings.models.manage`),hint:t(`settings.models.manageHint`),forceOpen:!!i||f?.ok===!1,children:V(`section`,{className:`settings-field models-pane-section`,"aria-labelledby":`settings-models-title`,children:[P(`span`,{className:`visually-hidden`,id:`settings-models-title`,children:t(`settings.models.title`)}),P(`p`,{className:`settings-hint`,children:t(`settings.models.lede`)}),i&&P(JN,{message:i}),n&&!n.lemonade.reachable&&P(`p`,{className:`settings-hint`,children:t(`settings.models.unavailable`)}),!n&&!i&&V(`p`,{className:`settings-hint`,children:[P(K,{size:13,className:`spin`,"aria-hidden":`true`}),` `,t(`setup.models.loading`)]}),n&&n.lemonade.reachable&&o&&V(D.Fragment,{children:[P(Pj,{plan:n,selection:o,onToggle:(e,t)=>s(fj(o,I,e,t)),onDefaultChat:e=>s(pj(o,I,e)),labelledBy:`settings-models-title`,place:`settings`,disabled:u,progress:M,rowActions:e=>e.downloaded&&e.id!==o.defaultChat?P(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>l({kind:`remove`,entry:e}),disabled:u||M[e.id]?.state===`downloading`,"aria-label":t(`settings.models.removeAria`,{name:e.name}),children:t(`settings.models.remove`)}):null}),P(jj,{plan:n,selection:o}),P(`div`,{className:`models-apply`,children:V(`button`,{type:`button`,className:`btn-primary`,disabled:!R||u,onClick:()=>void z(!1,!1),children:[u&&P(K,{size:13,className:`spin`,"aria-hidden":`true`}),u?t(`settings.models.applying`):L.length>0?t(`settings.models.applyDownload`,{size:$(Math.round(ee*10)/10)}):t(`settings.models.apply`)]})})]}),f?.ok&&P(`p`,{className:`settings-ok`,role:`status`,children:f.text}),f&&!f.ok&&P(JN,{message:f.text})]})}),(g?.applies||v&&!WN(v))&&P(bN,{title:t(`gpu.settingsTitle`),titleId:`settings-gpu-title`,defaultOpen:!!g?.pending||!!v,children:V(`section`,{className:`settings-field models-pane-section`,"aria-labelledby":`settings-gpu-title`,children:[v&&P(`p`,{className:`settings-error`,role:`alert`,children:v}),g?.applies&&P($j,{status:g,onStatus:_,mode:`settings`,names:N,headingId:`settings-gpu-title`})]})}),e?(0,Qx.createPortal)(ne,e):e===void 0&&ne,c?.kind===`remove`&&P(Wj,{title:t(`settings.models.removeTitle`,{name:c.entry.name}),confirmLabel:t(`settings.models.removeConfirm`),cancelLabel:t(`settings.models.keep`),danger:!0,onConfirm:()=>void B(c.entry),onCancel:()=>l(null),children:P(`p`,{children:XA(c.entry)?t(`settings.models.removeVision`,{size:$(c.entry.full_size_gb??0)}):t(`settings.models.removeBody`,{size:$(c.entry.full_size_gb??0)})})}),c?.kind===`no_fit`&&P(Wj,{title:c.models.length===1?t(`setup.confirm.noFitOne`,{name:c.models[0].name}):t(`setup.confirm.noFitMany`),confirmLabel:t(`setup.confirm.downloadAnyway`),cancelLabel:t(`setup.confirm.pickSmaller`),onConfirm:()=>{l(null),h(!0),z(!0,!1)},onCancel:()=>l(null),children:c.models.map(e=>V(`p`,{children:[P(`bdi`,{children:e.name}),`: `,Oj(e,t)]},e.id))}),c?.kind===`low_disk`&&P(Wj,{title:t(`setup.confirm.lowDiskTitle`),confirmLabel:t(`setup.confirm.downloadAnyway`),cancelLabel:t(`setup.confirm.changeModels`),onConfirm:()=>{l(null),z(!0,!0)},onCancel:()=>l(null),children:P(`p`,{children:c.message})}),c?.kind===`server`&&P(Wj,{title:t(`setup.confirm.noFitServerTitle`),confirmLabel:t(`setup.confirm.useAnyway`),cancelLabel:t(`setup.confirm.changeModels`),onConfirm:()=>{l(null),h(!0),z(!0,!1)},onCancel:()=>l(null),children:P(`p`,{children:c.detail.message})})]})}var $N=`auto`;function eP({model:e}){let t=T(),[n,r]=(0,J.useState)(null),[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(null);(0,J.useEffect)(()=>{r(null),a(null),l(null),_e(e).then(r).catch(e=>a(e instanceof Error?e.message:String(e)))},[e]);let u=(0,J.useCallback)(async n=>{s(!0),a(null),l(null);try{let i=await Ke(e,n===$N?null:Number(n));r(i);let a={name:i.display_name,size:i.chosen?Cs(i.chosen):g(`settings.ctx.automaticSize`)},o=i.reload?.reason;i.reload?.started?l(t(`settings.ctx.reloading`,a)):l(o===`already_loaded`?t(`settings.ctx.alreadyLoaded`,a):o===`warm_up`?t(`settings.ctx.warmUp`,a):o===`busy`?t(`settings.ctx.busy`,a):o===`not_gaias_server`?t(`settings.ctx.ownServer`,a):t(o===`restarting`?`settings.ctx.restarting`:`settings.ctx.nextLoad`))}catch(e){a(e instanceof Error?e.message:String(e))}finally{s(!1)}},[e,t]);if(i&&!n)return WN(i)?P(`p`,{className:`settings-hint`,children:t(`settings.ctx.serverDown`)}):P(`p`,{className:`settings-error`,role:`alert`,children:i});if(!n)return V(`p`,{className:`settings-hint`,children:[P(K,{size:13,className:`spin`}),` `,t(`settings.ctx.checking`)]});let d=n.chosen==null?$N:String(n.chosen),f=n.chosen!=null&&n.loaded_ctx!=null&&n.loaded_ctx!==n.chosen;return V(D.Fragment,{children:[V(`div`,{className:`model-in-use-field`,children:[P(`label`,{className:`settings-label`,htmlFor:`ctx-size`,children:t(`settings.ctx.label`)}),V(`select`,{id:`ctx-size`,className:`settings-input`,value:d,onChange:e=>void u(e.target.value),disabled:o||n.options.length===0,children:[P(`option`,{value:$N,children:n.automatic?t.bare(`settings.ctx.automaticAt`,{size:Cs(n.automatic)}):t.bare(`settings.ctx.automatic`)}),n.options.map(e=>P(`option`,{value:String(e),children:t.bare(`settings.ctx.tokens`,{size:Cs(e)})},e))]})]}),n.note&&P(`span`,{className:`settings-hint`,children:P(`bdi`,{children:n.note})}),!n.note&&!!n.max_fit&&V(`details`,{className:`settings-more`,children:[V(`summary`,{children:[P(hr,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,t(`settings.ctx.about`)]}),P(`span`,{className:`settings-hint`,children:t(`settings.ctx.explain`,{size:Cs(n.max_fit),name:n.display_name,memory:n.memory_source})})]}),f&&P(`span`,{className:`settings-hint`,children:t(`settings.ctx.loadedAt`,{size:Cs(n.loaded_ctx)})}),o&&V(`span`,{className:`settings-hint`,children:[P(K,{size:13,className:`spin`}),` `,t(`settings.ctx.applying`)]}),c&&P(`p`,{className:`settings-ok`,role:`status`,children:c}),i&&P(`p`,{className:`settings-error`,role:`alert`,children:i})]})}function tP({row:e,providerName:t,choices:n,labels:r,disabled:i,onSwitch:a}){let o=T(),s=cs(e=>e.active),c=s?.model??null,l=!!s?.remote,u=n.some(e=>us(c,e.id)),d=s?.downloaded??e?.downloaded,f=l?null:e?.state===`loaded`?o(`settings.model.loaded`):d===!0?o(`settings.model.downloaded`):d===!1?o(`settings.model.notDownloaded`):null,p=e?.placement?.device;return V(`section`,{className:`settings-card model-in-use`,"aria-label":o(`settings.model.inUseTitle`),children:[P(`span`,{className:`model-in-use-label`,children:o(`settings.model.inUseTitle`)}),c?P(`bdi`,{className:`model-in-use-name`,title:c,children:e?.display_name||s?.display_name||ds(c)}):P(`span`,{className:`settings-hint`,children:o(`settings.model.noneInUse`)}),s?.config_error&&P(`p`,{className:`settings-error`,role:`alert`,children:P(`bdi`,{children:s.config_error})}),c&&!l&&e?.available===!1&&P(`p`,{className:`settings-error`,role:`alert`,children:o(`settings.model.inUseCantRun`)}),c&&V(`span`,{className:`model-chips`,children:[l&&P(`span`,{className:`model-badge is-device`,children:o(`settings.model.cloud`)}),l&&t&&P(`bdi`,{className:`model-badge is-ready`,children:t}),p&&P(`span`,{className:`model-badge is-device`,children:p.toUpperCase()}),f&&P(`span`,{className:`model-badge ${e?.state===`loaded`?`is-loaded`:`is-ready`}`,children:f}),e?.fits===!0&&P(`span`,{className:`model-badge is-fit`,children:o(`settings.model.fits`)}),!!e?.size_gb&&V(`bdi`,{dir:`ltr`,className:`model-badge is-size`,children:[e.size_gb,` GB`]}),l&&!!e?.context_length&&P(`span`,{className:`model-badge is-ready`,children:o(`settings.model.contextChip`,{size:Cs(e.context_length)})})]}),(n.length>1||n.length===1&&!u)&&V(`div`,{className:`model-in-use-field`,children:[P(`label`,{className:`settings-label`,htmlFor:`model-switch`,children:o(`settings.model.switch`)}),V(`select`,{id:`model-switch`,className:`settings-input`,value:u?n.find(e=>us(c,e.id))?.id:``,onChange:e=>a(e.target.value),disabled:i,children:[!u&&P(`option`,{value:``,disabled:!0,children:o.bare(`settings.model.switchPlaceholder`)}),n.map(e=>P(`option`,{value:e.id,children:r[e.id]},e.id))]})]}),c&&!l&&s?.downloaded!==!1&&P(eP,{model:c})]})}function nP({model:e,label:t,current:n,remote:r,busy:i,confirmingRemove:a,onUse:o,onDownload:s,onAskRemove:c,onKeep:l,onRemove:u,onNpuRecheck:d}){let f=T(),p=Ts(e)?e.download_progress:null,m=e.placement?.label,h=f.compose(t=>[m&&(e.placement?.source===`expected`?t(`settings.model.expected`,{label:m}):m),e.size_gb?t(e.downloaded?`settings.model.sizeOnDisk`:`settings.model.sizeDownload`,{size:`${e.size_gb} GB`}):null,e.tokens_per_second?t(`settings.model.speed`,{speed:`${Math.round(e.tokens_per_second)} tok/s`}):null,!e.placement&&e.context_length?t(`settings.model.contextTokens`,{size:e.context_length.toLocaleString()}):null].filter(Boolean).join(` · `)),g=!!(e.display_name||h||e.evidence||e.custom&&e.source_url);return V(`li`,{className:`model-row${n?` is-current`:``}`,children:[V(`div`,{className:`model-row-text`,children:[P(`bdi`,{className:`model-row-name`,title:e.id,children:t}),V(`div`,{className:`model-chips`,children:[e.placement?.device&&P(`span`,{className:`model-badge is-device`,children:e.placement.device.toUpperCase()}),e.rank&&V(`span`,{className:`model-badge is-rank`,children:[V(`bdi`,{dir:`ltr`,children:[`#`,e.rank]}),` `,e.note]}),e.state===`loaded`&&P(`span`,{className:`model-badge is-loaded`,children:f(`settings.model.loaded`)}),e.fits===!0&&e.available!==!1&&P(`span`,{className:`model-badge is-fit`,children:f(`settings.model.fits`)}),e.custom&&P(`span`,{className:`model-badge is-custom`,children:f(`settings.model.custom`)}),!!e.size_gb&&V(`bdi`,{dir:`ltr`,className:`model-badge is-size`,children:[e.size_gb,` GB`]}),g&&V(`details`,{className:`settings-more`,children:[V(`summary`,{children:[P(hr,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,f(`settings.model.details`)]}),e.display_name&&P(`span`,{className:`model-row-meta`,children:P(`bdi`,{children:e.id})}),h&&P(`span`,{className:`model-row-meta`,children:h}),e.evidence&&P(`span`,{className:`model-row-meta`,children:f(`settings.model.measured`,{evidence:e.evidence})}),e.custom&&e.source_url&&P(`span`,{className:`model-row-meta`,children:f(`settings.model.from`,{url:e.source_url})})]})]}),r&&P(`span`,{className:`model-row-meta${e.price?``:` is-unknown-price`}`,children:XT(e.price,f)}),e.placement?.warning&&P(`span`,{className:`model-row-meta is-warning`,role:`alert`,children:P(`bdi`,{children:e.placement.warning})}),e.npu_problems?.length?P(MM,{problems:e.npu_problems,disabled:i!==null,onRecheck:d,id:`npu-problems-${e.id}`}):e.unavailable_reason&&P(`span`,{className:`model-row-meta`,children:f(`settings.model.cantRun`,{reason:e.unavailable_reason})}),p&&P(`progress`,{max:100,value:p.percent,"aria-label":f(`settings.model.downloadingAria`,{name:t})})]}),V(`div`,{className:`model-row-actions`,children:[e.custom&&!n&&!p&&(a?V(D.Fragment,{children:[V(`button`,{type:`button`,className:`btn-danger`,onClick:u,disabled:i!==null,children:[i===`rm:${e.id}`?P(K,{size:13,className:`spin`}):null,e.downloaded?f(`settings.model.removeDownload`):f(`settings.models.remove`)]}),P(`button`,{type:`button`,className:`btn-secondary`,onClick:l,disabled:i!==null,children:f(`settings.models.keep`)})]}):P(`button`,{type:`button`,className:`btn-secondary`,onClick:c,disabled:i!==null,"aria-label":f(`settings.models.removeAria`,{name:t}),children:f(`settings.models.remove`)})),n&&e.available===!1?P(`span`,{className:`model-row-current is-blocked`,children:f(`settings.model.inUseBlocked`)}):n?V(`span`,{className:`model-row-current`,children:[P(pr,{size:13,"aria-hidden":`true`}),` `,f(`settings.model.inUse`)]}):e.available===!1?null:p?V(`span`,{className:`model-row-current`,children:[P(K,{size:13,className:`spin`}),` `,p.message?P(`bdi`,{children:p.message}):V(`bdi`,{dir:`ltr`,children:[Math.round(p.percent),`%`]})]}):e.downloaded?V(`button`,{type:`button`,className:`btn-secondary`,onClick:o,disabled:i!==null,"aria-label":f(`settings.model.useAria`,{name:t}),children:[i===e.id?P(K,{size:13,className:`spin`}):null,` `,f(`settings.model.use`)]}):V(`button`,{type:`button`,className:`btn-secondary`,onClick:s,disabled:i!==null,"aria-label":f(`settings.model.downloadAria`,{name:t}),children:[i===`dl:${e.id}`?P(K,{size:13,className:`spin`}):null,` `,f(`settings.model.download`)]})]})]})}function rP(){let e=T(),[t,n]=(0,J.useState)(null),[r,i]=(0,J.useState)(null),[a,o]=(0,J.useState)(``),[s,c]=(0,J.useState)(!1),l=(0,J.useCallback)(async e=>{c(!0),i(null);try{let t=await e();n(t),o(t.limit_usd==null?``:String(t.limit_usd))}catch(e){i(e instanceof Error?e.message:String(e))}finally{c(!1)}},[]);if((0,J.useEffect)(()=>{l(H)},[l]),!t)return r?P(`p`,{className:`settings-error`,role:`alert`,children:r}):V(`p`,{className:`settings-hint`,children:[P(K,{size:13,className:`spin`}),` `,e(`settings.spend.loading`)]});let u=t.limit_usd,d=a.trim()===``?null:Number(a),f=d===null||Number.isFinite(d)&&d>0,p=d!==u;return V(`section`,{className:`settings-field spending`,"aria-label":e(`settings.spend.aria`),children:[P(`span`,{className:`settings-label`,children:e(`settings.spend.title`)}),V(`p`,{className:`spending-total`,children:[P(`bdi`,{dir:`ltr`,children:P(`strong`,{children:ZT(t.total_usd)})}),u!=null&&V(D.Fragment,{children:[` `,e(`settings.spend.ofLimit`,{limit:ZT(u)})]}),V(`span`,{className:`settings-hint`,children:[` · `,e.plural(`settings.spend.turns`,t.turns)]})]}),t.unpriced_turns>0&&P(`p`,{className:`settings-hint`,children:e.plural(`settings.spend.unpriced`,t.unpriced_turns)}),t.unreported_turns>0&&P(`p`,{className:`settings-hint`,children:e.plural(`settings.spend.unreported`,t.unreported_turns)}),t.state===`near`&&V(`p`,{className:`spending-warning`,role:`status`,children:[P(q,{size:13,"aria-hidden":`true`}),` `,e(`settings.spend.near`)]}),t.state===`reached`&&V(`div`,{className:`spending-warning`,role:`alert`,children:[V(`p`,{children:[P(q,{size:13,"aria-hidden":`true`}),` `,e(`settings.spend.reached`)]}),P(`button`,{type:`button`,className:`btn-secondary`,disabled:s,onClick:()=>void l(hn),children:e(`settings.spend.allow`)})]}),t.state===`allowed_over`&&P(`p`,{className:`settings-hint`,children:e(`settings.spend.allowed`)}),V(`form`,{className:`settings-row`,onSubmit:e=>{e.preventDefault(),f&&p&&l(()=>Ze(d))},children:[P(`label`,{className:`spending-limit-label`,htmlFor:`spend-limit`,children:e(`settings.spend.limit`)}),P(`input`,{id:`spend-limit`,className:`settings-input`,type:`number`,min:`0.01`,step:`0.01`,inputMode:`decimal`,placeholder:e.bare(`settings.spend.noLimit`),value:a,onChange:e=>o(e.target.value),"aria-invalid":!f}),V(`button`,{type:`submit`,className:`btn-secondary`,disabled:s||!f||!p,children:[s?P(K,{size:13,className:`spin`}):null,` `,e(`settings.advanced.save`)]}),u!=null&&P(`button`,{type:`button`,className:`btn-secondary`,disabled:s,onClick:()=>void l(()=>Ze(null)),children:e(`settings.spend.removeLimit`)})]}),P(`span`,{className:`settings-hint`,children:e(`settings.spend.how`)}),r&&P(`p`,{className:`settings-error`,role:`alert`,children:r})]})}var iP=2e3;function aP(e,t){return e.key_source===`environment`?t(`settings.key.setIn`,{name:e.env_var??``}):`••••••••••••••••••••${e.key_hint?` ${e.key_hint}`:``}`}function oP(){let e=T(),t=cs(e=>e.active),n=cs(e=>e.select),r=cs(e=>e.refresh),i=cs(e=>e.rememberNames),[a,o]=(0,J.useState)(null),[s,c]=(0,J.useState)(null),l=k(e=>e.settingsProvider),[u,d]=(0,J.useState)(l??t?.provider??`local`),[f,p]=(0,J.useState)(null),[m,h]=(0,J.useState)(null),[g,_]=(0,J.useState)(``),[v,y]=(0,J.useState)(!1),[b,x]=(0,J.useState)(``),[S,C]=(0,J.useState)(!1),[w,E]=(0,J.useState)(!1),[O,A]=(0,J.useState)({base_url:``,auth_header_name:``,auth_header_prefix:``}),[j,M]=(0,J.useState)(null),[N,F]=(0,J.useState)(null),[I,L]=(0,J.useState)(null),[ee,R]=(0,J.useState)(null),[z,B]=(0,J.useState)(!1),[te,ne]=(0,J.useState)(null),[re,ie]=(0,J.useState)(null),ae=(0,J.useRef)(u);ae.current=u;let oe=(0,J.useRef)(!0);(0,J.useEffect)(()=>(oe.current=!0,()=>{oe.current=!1}),[]);let H=a?.find(e=>e.id===u)??null,U=e=>e?.network?.reachable===!1,se=!!H&&(!H.remote||!!H.models_discovered),W=(0,J.useCallback)(async()=>{c(null);try{let e=await wn();o(e.providers),e.lemonade_error&&c(e.lemonade_error)}catch(e){c(e instanceof Error?e.message:String(e))}},[]),G=(0,J.useCallback)(async(e,t=!1)=>{t||(p(null),h(null));try{let t=await Zt(e);i(t.models),p(t.models),F(t.memory_gb?`${t.memory_gb} GB (${t.memory_source})`:t.capacity_error??null)}catch(e){h(e instanceof Error?e.message:String(e))}},[i]);(0,J.useEffect)(()=>{W()},[W]);let ce=!!a?.some(e=>e.key_state===`waiting_for_os_permission`);(0,J.useEffect)(()=>{if(!ce)return;let e=setInterval(()=>{W()},iP);return()=>clearInterval(e)},[ce,W]);let le=t?.provider;(0,J.useEffect)(()=>{le&&!l&&d(le)},[le,l]),(0,J.useEffect)(()=>{x(``),C(!1),E(!1),L(null),_(``),y(!1),B(!1)},[u]),(0,J.useEffect)(()=>{se?G(u):p(null)},[u,se,G]);let ue=(0,J.useCallback)(async()=>{if(H){M(`connect`),L(null);try{let t=u===`amd`?{api_key:b||void 0,...Object.fromEntries(Object.entries(O).filter(([,e])=>e!==``))}:{api_key:b||void 0},n=()=>!oe.current||ae.current!==u,r=await Rt(u,t,e=>{n()||L({ok:!0,text:e})},n);if(n())return;x(``),C(!1),L({ok:!0,text:r.remember_error?e(`settings.key.sessionOnly`,{reason:r.remember_error}):r.known_models?e(`settings.key.knownModels`,{name:H.name}):r.remembered?e(`settings.key.kept`):e(`settings.key.connectedDone`)}),await W()}catch(e){oe.current&&ae.current===u&&L({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{oe.current&&M(null)}}},[O,u,b,W,H,e]),de=(0,J.useCallback)(async()=>{M(`forget`),E(!1),L(null);try{await Kt(u),L({ok:!0,text:e(`settings.key.cleared`)}),await W(),await r()}catch(e){L({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{M(null)}},[u,W,r,e]),pe=(0,J.useCallback)(async t=>{M(t),L(null);try{await n(t),L({ok:!0,text:e(`settings.model.switched`,{name:ds(t)})}),await G(u,!0)}catch(e){L({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{M(null)}},[u,G,n,e]),me=(0,J.useCallback)(async e=>{M(`dl:${e}`),L(null),B(!1);try{await fe(e),await G(`local`,!0)}catch(e){L({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{M(null)}},[G]),he=(0,J.useCallback)(async t=>{M(`rm:${t}`),L(null);try{let n=await tt(t);R(null);let i=n.cleared.includes(`last_model`)?`settings.model.removedLast`:n.cleared.includes(`default_model`)?`settings.model.removedDefault`:`settings.model.removed`;L({ok:!0,text:e(i,{name:n.display_name})}),await G(`local`,!0),await r()}catch(e){L({ok:!1,text:e instanceof Error?e.message:String(e)})}finally{M(null)}},[G,r,e]),ge=(0,J.useCallback)(async t=>{L({ok:!0,text:e(`settings.model.added`,{name:t})}),B(!0),await G(`local`,!0)},[G,e]),_e=!!f?.some(Ts);(0,J.useEffect)(()=>{if(_e)return()=>{r()}},[_e,r]),(0,J.useEffect)(()=>{if(u!==`local`||!_e)return;let e=setInterval(()=>{G(`local`,!0)},iP);return()=>clearInterval(e)},[_e,u,G]);let ve=t?.model,ye=f?.find(e=>us(ve,e.id));(0,J.useEffect)(()=>{ye&&ne(ye)},[ye]);let be=(0,J.useMemo)(()=>{let e=g.trim().toLowerCase();return(f??[]).filter(t=>!e||t.id.toLowerCase().includes(e)||(t.display_name??``).toLowerCase().includes(e))},[f,g]),xe=be.filter(e=>e.available!==!1),Se=u===`fireworks`&&!v&&!g.trim()&&xe.some(e=>e.rank!==null),Ce=e=>e.rank!==null||e.id===t?.model,we=Se?xe.filter(Ce):xe,Te=Se?xe.filter(e=>!Ce(e)):[],Ee=be.filter(e=>e.available===!1),De=ys(f??[]),Oe=!!g.trim(),ke=e=>us(t?.model,e.id),Ae=H?.id===`local`,je=we.filter(e=>e.downloaded).sort((e,t)=>Number(ke(t))-Number(ke(e))),Me=we.filter(e=>!e.downloaded),Ne=(f??[]).filter(e=>e.available!==!1&&e.downloaded),Pe=Ne.filter(Ce),Fe=u===`fireworks`&&Pe.some(e=>e.rank!==null)?Pe:Ne,Ie=e=>P(nP,{model:e,label:De[e.id],current:ke(e),remote:!!H?.remote,busy:j,confirmingRemove:ee===e.id,onUse:()=>void pe(e.id),onDownload:()=>void me(e.id),onAskRemove:()=>R(e.id),onKeep:()=>R(null),onRemove:()=>void he(e.id),onNpuRecheck:()=>void G(u,!0)},e.id);return V(`div`,{className:`settings-pane`,children:[P(`h2`,{className:`settings-pane-title`,children:e(`settings.section.model`)}),P(tP,{row:ye??(us(te?.id,t?.model)?te:null),providerName:a?.find(e=>e.id===t?.provider)?.name??null,choices:se?Fe:[],labels:De,disabled:j!==null,onSwitch:e=>void pe(e)}),P(`div`,{className:`provider-tabs`,role:`radiogroup`,"aria-label":e(`settings.model.whereRuns`),children:(a??[{id:`local`,name:`Local`,remote:!1}]).map(t=>V(`button`,{type:`button`,role:`radio`,"aria-checked":u===t.id,className:`provider-tab${u===t.id?` is-active`:``}${U(t)?` is-disabled`:``}`,onClick:()=>d(t.id),disabled:U(t)&&u!==t.id,title:U(t)?t.network?.detail??void 0:void 0,children:[t.remote?P(Fr,{size:14,"aria-hidden":`true`}):P(Ur,{size:14,"aria-hidden":`true`}),P(`span`,{children:t.name}),t.remote&&t.models_discovered&&P(`span`,{className:`provider-tab-dot`,"aria-label":e(`settings.key.connectedDot`)})]},t.id))}),s&&P(JN,{message:s,onRetry:()=>{W(),G(u)}}),H&&V(`section`,{className:`settings-card`,"aria-label":H.name,children:[H.remote&&P(`p`,{className:`settings-note`,children:P(`bdi`,{children:H.privacy_notice})}),V(`details`,{className:`settings-more`,children:[V(`summary`,{children:[P(hr,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,e(`settings.model.howItWorks`)]}),P(`p`,{className:`settings-hint`,children:e(`settings.model.lede`)}),Ae&&P(`p`,{className:`settings-hint`,children:P(`bdi`,{children:H.privacy_notice})}),Ae&&P(`p`,{className:`settings-hint`,children:e(`settings.model.devices`)}),Ae&&N&&P(`p`,{className:`settings-hint`,children:e(`settings.model.memory`,{memory:N})})]}),H.remote&&!se&&V(`div`,{className:`settings-field`,children:[P(`span`,{className:`settings-label`,children:e(`settings.model.prices`)}),P(HA,{provider:H.id})]}),U(H)&&V(`div`,{className:`settings-field`,children:[P(`p`,{className:`settings-error`,role:`alert`,children:H.network?.detail}),P(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>void W(),children:e(`settings.key.checkAgain`)})]}),H.remote&&!U(H)&&V(`form`,{className:`settings-field`,onSubmit:e=>{e.preventDefault(),ue()},children:[V(`div`,{className:`settings-row settings-row-between`,children:[P(`span`,{className:`settings-label`,children:e(`settings.key.title`)}),H.key_source&&P(`span`,{className:`settings-key-status ${se?`settings-ok`:`settings-error`}`,children:e(se?`settings.key.connected`:`settings.key.notConnected`)})]}),!H.key_source&&P(`span`,{className:`settings-hint`,children:H.key_state===`waiting_for_os_permission`?H.key_message??e(`settings.key.waitingOs`):e(`settings.key.none`)}),H.id===`amd`&&(!H.key_source||S)&&V(`div`,{className:`settings-grid`,children:[P(`input`,{className:`settings-input`,placeholder:e(`settings.key.gatewayPlaceholder`),value:O.base_url,onChange:e=>A({...O,base_url:e.target.value}),"aria-label":e(`settings.key.gatewayUrl`)}),P(`input`,{className:`settings-input`,placeholder:e(`settings.key.headerPlaceholder`),value:O.auth_header_name,onChange:e=>A({...O,auth_header_name:e.target.value}),"aria-label":e(`settings.key.headerName`)})]}),H.key_source&&!S?V(`div`,{className:`settings-row`,children:[P(`input`,{className:`settings-input settings-key-masked`,readOnly:!0,value:aP(H,e),"aria-label":e(`settings.key.savedAria`,{name:H.name})}),!se&&V(`button`,{type:`submit`,className:`btn-primary`,disabled:j!==null,children:[j===`connect`?P(K,{size:13,className:`spin`}):null,e(`settings.key.reconnect`)]}),(H.key_source!==`environment`||H.key_from_gaia_env)&&(w?V(D.Fragment,{children:[P(`span`,{className:`settings-hint`,children:e(`settings.key.removeAsk`)}),P(`button`,{type:`button`,className:`btn-danger`,onClick:()=>void de(),disabled:j!==null,children:e(`settings.models.remove`)}),P(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>E(!1),children:e(`settings.models.keep`)})]}):V(D.Fragment,{children:[P(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>C(!0),disabled:j!==null,children:e(`settings.key.replace`)}),H.key_source!==`environment`&&P(`button`,{type:`button`,className:`btn-secondary settings-key-remove`,onClick:()=>E(!0),disabled:j!==null,"aria-label":e(`settings.key.remove`),title:e(`settings.key.remove`),children:P(co,{size:14,"aria-hidden":`true`})})]}))]}):V(`div`,{className:`settings-row`,children:[P(`input`,{className:`settings-input`,type:`password`,autoComplete:`off`,spellCheck:!1,autoFocus:S,value:b,onChange:e=>x(e.target.value),placeholder:e(S?`settings.key.pasteNew`:`settings.key.paste`),"aria-label":e(`settings.key.fieldAria`,{name:H.name})}),V(`button`,{type:`submit`,className:`btn-primary`,disabled:j!==null||!b,children:[j===`connect`?P(K,{size:13,className:`spin`}):null,e(S?`settings.key.save`:`settings.key.connect`)]}),S&&P(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{x(``),C(!1)},disabled:j!==null,children:e(`settings.key.cancel`)})]}),H.key_source&&!se&&!H.error&&!S&&P(`p`,{className:`settings-hint`,children:e(`settings.key.notConnectedHint`,{name:H.name})}),H.error&&P(`p`,{className:`settings-error`,role:`alert`,children:H.error})]}),I?.ok&&P(`p`,{className:`settings-ok`,role:`status`,children:I.text}),I&&!I.ok&&P(JN,{message:I.text}),H.known_models&&P(`p`,{className:`settings-hint`,role:`status`,children:e(`settings.key.knownList`,{name:H.name})}),Ae&&P(`div`,{className:`models-downloads-slot`,ref:ie}),se&&V(`div`,{className:`settings-field`,children:[P(`span`,{className:`settings-label`,children:e(`settings.model.models`)}),(f?.length??0)>6&&P(`input`,{className:`settings-input`,type:`search`,value:g,onChange:e=>_(e.target.value),placeholder:e(`settings.model.search`),"aria-label":e(`settings.model.search`)}),m&&!(s&&WN(m))&&P(JN,{message:m}),!f&&!m&&V(`p`,{className:`settings-hint`,children:[P(K,{size:13,className:`spin`}),` `,e(`settings.loading`)]}),f&&be.length===0&&!m&&P(`p`,{className:`settings-hint`,children:e(Oe||!Ae?`settings.model.noMatch`:`settings.model.noModels`)}),Ae?V(D.Fragment,{children:[je.length>0&&P(bN,{title:e(`settings.model.groupDownloaded`),count:je.length,defaultOpen:!0,forceOpen:Oe,children:P(`ul`,{className:`model-list`,children:je.map(Ie)})}),Me.length>0&&P(bN,{title:e(`settings.model.groupAvailable`),count:Me.length,defaultOpen:je.length===0,forceOpen:Oe||z||Me.some(Ts),children:P(`ul`,{className:`model-list`,children:Me.map(Ie)})})]}):P(`ul`,{className:`model-list`,children:we.map(Ie)}),Se&&Te.length>0&&P(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>y(!0),children:e(`settings.model.showAll`)}),u===`fireworks`&&v&&!Oe&&P(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>y(!1),children:e(`settings.model.showRecommended`)}),Ee.length>0&&P(bN,{title:e(`settings.model.groupUnavailable`),count:Ee.length,forceOpen:Oe,children:P(`ul`,{className:`model-list`,children:Ee.map(Ie)})})]}),Ae&&se&&P(bN,{title:e(`settings.custom.title`),children:P(YN,{onAdded:e=>void ge(e)})}),Ae&&se&&P(QN,{downloadsSlot:re}),H.remote&&P(rP,{})]})]})}function sP(){let e=T(),t=k(e=>e.sessions),[n,r]=(0,J.useState)(null),[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(null),u=(0,J.useCallback)(async()=>{l(null);try{let e=await an();r(e.sessions),a(e.default_mode),k.getState().setDefaultPermissionMode(e.default_mode)}catch(e){l(e instanceof Error?e.message:String(e))}},[]);(0,J.useEffect)(()=>{u()},[u]);let d=(0,J.useCallback)(async e=>{l(null);try{await e(),await u()}catch(e){l(e instanceof Error?e.message:String(e))}},[u]),f=(0,J.useCallback)(async e=>{s(!1),await d(()=>kt(e))},[d]),p=()=>{i===`full_access`?f(`ask`):s(e=>!e)},m=e=>t.find(t=>t.id===e)?.title??e;return V(`div`,{className:`settings-pane`,children:[P(`h2`,{className:`settings-pane-title`,children:e(`settings.section.permissions`)}),P(`p`,{className:`settings-pane-lede`,children:e(`settings.permissions.lede`)}),V(`details`,{className:`settings-more`,children:[V(`summary`,{children:[P(hr,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,e(`settings.model.howItWorks`)]}),P(`p`,{className:`settings-hint`,children:e(`settings.permissions.perChat`)})]}),V(`section`,{className:`settings-card`,"aria-label":e(`settings.permissions.newChats`),children:[V(`label`,{className:`setting-row`,children:[P(`span`,{className:`settings-label`,children:e(`settings.permissions.fullAccess`)}),V(`span`,{className:`toggle-switch`,children:[P(`input`,{type:`checkbox`,checked:i===`full_access`,onChange:p,disabled:i===null,"aria-label":e(`settings.permissions.fullAccess`)}),P(`span`,{className:`toggle-track`})]})]}),P(`p`,{className:`settings-hint`,children:e(i===`full_access`?`settings.permissions.on`:`settings.permissions.off`)}),o&&V(`div`,{className:`settings-warning`,role:`alert`,children:[P(`p`,{children:e(`settings.permissions.warning`)}),V(`div`,{className:`settings-row`,children:[P(`button`,{type:`button`,className:`btn-danger`,onClick:()=>void f(`full_access`),children:e(`settings.permissions.turnOn`)}),P(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>s(!1),children:e(`settings.key.cancel`)})]})]})]}),c&&P(`p`,{className:`settings-error`,role:`alert`,children:c}),n&&n.length===0&&P(`p`,{className:`settings-hint`,children:e(`settings.permissions.none`)}),!!n?.length&&P(bN,{title:e(`settings.permissions.chats`),count:n.length,defaultOpen:!0,children:n.map(t=>V(`section`,{className:`settings-field permission-chat`,"aria-label":m(t.session_id),children:[V(`div`,{className:`settings-row settings-row-between`,children:[P(`bdi`,{className:`settings-label`,children:m(t.session_id)}),t.mode===`full_access`&&P(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>d(async()=>{let e=(await Pt(t.session_id,`ask`)).mode;_E(t.session_id,e)}),children:e(`settings.permissions.turnOff`)})]}),t.grants.length>0&&P(`ul`,{className:`grant-list`,children:t.grants.map(n=>V(`li`,{className:`grant-row`,children:[P(`code`,{children:n.label}),P(`button`,{type:`button`,className:`link-btn`,onClick:()=>d(()=>Xt(t.session_id,n.key)),"aria-label":e(`settings.permissions.revokeAria`,{name:n.label}),children:e(`settings.permissions.revoke`)})]},n.key))}),t.grants.length>1&&P(`button`,{type:`button`,className:`link-btn`,onClick:()=>d(()=>Xt(t.session_id)),children:e(`settings.permissions.revokeAll`)})]},t.session_id))})]})}var cP={path:`~/.gaia/skills`},lP=[{source:`agent-bundled`,title:`settings.skills.bundled`,note:`settings.skills.bundledNote`},{source:`user`,title:`settings.skills.yours`,note:`settings.skills.yoursNote`,empty:`settings.skills.yoursEmpty`,params:cP},{source:`claude-project`,title:`settings.skills.project`,note:`settings.skills.projectNote`,params:{path:`.claude/skills`}},{source:`claude-import`,title:`settings.skills.import`,note:`settings.skills.importNote`}];function uP({onUseSkill:e}){let t=T(),[n,r]=(0,J.useState)(null),[i,a]=(0,J.useState)({}),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(``);(0,J.useEffect)(()=>{let e=!1;return cn().then(t=>{e||(r(t.skills),a(t.invalid))}).catch(t=>{e||s(t instanceof Error?t.message:String(t))}),()=>{e=!0}},[]);let u=c.trim().toLowerCase(),d=(n??[]).filter(e=>!u||e.name.toLowerCase().includes(u)||e.description.toLowerCase().includes(u)),f=n?.every(e=>lP.some(t=>t.source===e.source))??!1,p=n=>V(`li`,{className:`skill-row`,children:[V(`div`,{className:`skill-row-text`,children:[V(`span`,{className:`skill-row-name`,children:[n.name,n.version&&V(`span`,{className:`skill-row-meta`,children:[` v`,n.version]}),n.always_on&&V(`span`,{className:`skill-row-meta`,children:[` · `,t(`settings.skills.alwaysOn`)]})]}),P(`span`,{className:`skill-row-desc`,children:P(`bdi`,{children:n.description})})]}),!n.always_on&&P(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>e(n.name),"aria-label":t(`settings.skills.useAria`,{name:n.name}),children:t(`settings.model.use`)})]},n.name);return V(`div`,{className:`settings-pane`,children:[P(`h2`,{className:`settings-pane-title`,children:t(`settings.section.skills`)}),P(`p`,{className:`settings-pane-lede`,children:t(`settings.skills.lede`)}),V(`details`,{className:`settings-more`,children:[V(`summary`,{children:[P(hr,{size:13,className:`settings-disclosure-chevron`,"aria-hidden":`true`}),` `,t(`settings.model.howItWorks`)]}),P(`p`,{className:`settings-hint`,children:t(`settings.skills.how`,cP)})]}),o&&P(`p`,{className:`settings-error`,role:`alert`,children:o}),!n&&!o&&V(`p`,{className:`settings-hint`,children:[P(K,{size:13,className:`spin`}),` `,t(`settings.loading`)]}),n&&n.length>6&&P(`input`,{className:`settings-input`,type:`search`,value:c,onChange:e=>l(e.target.value),placeholder:t(`settings.skills.search`),"aria-label":t(`settings.skills.search`)}),n&&n.length===0&&P(`p`,{className:`settings-hint`,children:t(`settings.skills.none`)}),f?lP.map(e=>{let r=d.filter(t=>t.source===e.source),i=(n??[]).filter(t=>t.source===e.source).length;return r.length===0&&(u||!e.empty)?null:P(bN,{title:t(e.title),count:i,hint:t(e.note,e.params),defaultOpen:e.source===`user`,forceOpen:!!u,children:P(`section`,{"aria-label":t(e.title),children:r.length===0?P(`p`,{className:`settings-hint`,children:e.empty&&t(e.empty,e.params)}):P(`ul`,{className:`skill-list`,children:r.map(p)})})},e.source)}):P(`ul`,{className:`skill-list`,children:d.map(p)}),Object.keys(i).length>0&&V(`div`,{className:`settings-card`,role:`alert`,children:[P(`span`,{className:`settings-label`,children:t(`settings.skills.skipped`)}),P(`ul`,{className:`grant-list`,children:Object.entries(i).map(([e,t])=>V(`li`,{children:[P(`bdi`,{dir:`ltr`,children:P(`code`,{children:e})}),` — `,P(`bdi`,{children:t})]},e))})]})]})}function dP(){let e=T(),t=k(e=>e.setShowMemoryDashboard),n=k(e=>e.closeSettings),[r,i]=(0,J.useState)(null),[a,o]=(0,J.useState)(null),[s,c]=(0,J.useState)(!1);(0,J.useEffect)(()=>{dA().then(i).catch(e=>o(e instanceof Error?e.message:String(e)))},[]);let l=(0,J.useCallback)(async()=>{if(r){c(!0),o(null);try{i(await fA({memory_enabled:!r.memory_enabled}))}catch(e){o(e instanceof Error?e.message:String(e))}finally{c(!1)}}},[r]);return V(`div`,{className:`settings-pane`,children:[P(`h2`,{className:`settings-pane-title`,children:e(`settings.section.memory`)}),P(`p`,{className:`settings-pane-lede`,children:e(`settings.memory.lede`)}),V(`section`,{className:`settings-card`,"aria-label":e(`settings.section.memory`),children:[V(`label`,{className:`setting-row`,children:[P(`span`,{children:e(`settings.memory.remember`)}),V(`span`,{className:`toggle-switch`,children:[P(`input`,{type:`checkbox`,checked:!!r?.memory_enabled,onChange:()=>void l(),disabled:!r||s,"aria-label":e(`settings.memory.remember`)}),P(`span`,{className:`toggle-track`})]})]}),a&&P(`p`,{className:`settings-error`,role:`alert`,children:a}),V(`div`,{className:`settings-row settings-row-between`,children:[P(`span`,{className:`settings-hint`,children:e(`settings.memory.dashboardHint`)}),P(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{n(),t(!0)},children:e(`settings.memory.dashboard`)})]})]})]})}function fP(e,t,n){if(!/^\d+$/.test(e.trim()))return!1;let r=Number(e);return r>=t&&r<=n}function pP(e){return e<1048576?`${Math.ceil(e/1024)} KB`:`${(e/1048576).toFixed(1)} MB`}function mP(){let e=T(),[t,n]=(0,J.useState)(null),[r,i]=(0,J.useState)(``),[a,o]=(0,J.useState)(``),[s,c]=(0,J.useState)(null),[l,u]=(0,J.useState)(!1);(0,J.useEffect)(()=>{mn().then(e=>{n(e),i(String(e.retention_days)),o(String(e.max_mb))},t=>c({ok:!1,text:e(`settings.undo.readFailed`,{reason:t instanceof Error?t.message:String(t)})}))},[e]);let[d,f]=(0,J.useState)({days:!1,mb:!1}),p=!fP(r,1,365)||d.days,m=!fP(a,10,1e5)||d.mb,h=t!==null&&(r!==String(t.retention_days)||a!==String(t.max_mb)),g=async()=>{if(!(p||m)){u(!0),c(null);try{let t=await dn(Number(r),Number(a));n(t),c({ok:!0,text:e(`settings.undo.saved`)})}catch(t){let n=t instanceof vn&&t.httpStatus===422?t.fields:[],r=n.includes(`retention_days`),i=n.includes(`max_mb`);r||i?(f({days:r,mb:i}),c({ok:!1,text:e(`settings.undo.fix`)})):c({ok:!1,text:t instanceof Error?t.message:String(t)})}finally{u(!1)}}};return V(`div`,{className:`settings-field`,"aria-label":e(`settings.privacy.undo`),children:[P(`span`,{className:`settings-label`,children:e(`settings.privacy.undo`)}),P(`p`,{className:`settings-hint`,children:e(`settings.undo.hint`)}),t&&V(D.Fragment,{children:[V(`div`,{className:`setting-row`,children:[P(`label`,{htmlFor:`undo-days`,children:e(`settings.undo.days`)}),P(`input`,{id:`undo-days`,type:`number`,className:`model-input undo-history-input`,min:1,max:365,value:r,"aria-invalid":p,"aria-describedby":p?`undo-days-error`:void 0,onChange:e=>{i(e.target.value),f(e=>({...e,days:!1}))}})]}),p&&P(`p`,{id:`undo-days-error`,className:`settings-error`,children:e(`settings.undo.daysError`)}),V(`div`,{className:`setting-row`,children:[P(`label`,{htmlFor:`undo-mb`,children:e(`settings.undo.mb`)}),P(`input`,{id:`undo-mb`,type:`number`,className:`model-input undo-history-input`,min:10,max:1e5,value:a,"aria-invalid":m,"aria-describedby":m?`undo-mb-error`:void 0,onChange:e=>{o(e.target.value),f(e=>({...e,mb:!1}))}})]}),m&&P(`p`,{id:`undo-mb-error`,className:`settings-error`,children:e(`settings.undo.mbError`)}),V(`div`,{className:`setting-row setting-row-path`,children:[P(`span`,{children:e(`settings.undo.inUse`)}),V(`span`,{children:[e.plural(`settings.undo.used`,t.turns,{size:pP(t.used_bytes)}),` `,P(`bdi`,{dir:`ltr`,children:P(`code`,{className:`setting-path`,children:t.path})})]})]}),P(`button`,{type:`button`,className:`btn-model-save`,onClick:()=>void g(),disabled:!h||l||p||m,children:e(l?`settings.models.applying`:`settings.advanced.save`)})]}),s&&P(`p`,{className:s.ok?`settings-ok`:`settings-error`,role:s.ok?`status`:`alert`,children:s.text})]})}var hP={root:`settings-report`,button:`btn-secondary`,hint:`settings-hint`,error:`settings-error`};function gP(){let e=T(),t=k(e=>e.sessions),n=k(e=>e.removeSession),r=hs(),i=k(e=>e.systemStatus?.data_dir),[a,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(null),l=(0,J.useRef)(null);(0,J.useEffect)(()=>()=>{l.current&&clearTimeout(l.current)},[]);let u=(0,J.useCallback)(async()=>{if(!a){o(!0),l.current=setTimeout(()=>o(!1),4e3);return}o(!1);let r=[];for(let e of t)try{await de(e.id),n(e.id)}catch(t){r.push(`${e.title}: ${t instanceof Error?t.message:t}`)}c(r.length?{ok:!1,text:e(`settings.privacy.deleteFailed`,{n:r.length,reason:r.join(`; `)})}:{ok:!0,text:e(`settings.privacy.deleted`)})},[a,n,t,e]);return V(`div`,{className:`settings-pane`,children:[P(`h2`,{className:`settings-pane-title`,children:e(`settings.section.privacy`)}),V(`section`,{className:`settings-card`,"aria-label":e(`settings.privacy.whereTitle`),children:[P(`p`,{className:`settings-note`,children:e(`settings.privacy.stays`)}),P(`p`,{className:r?.remote?`settings-note`:`settings-hint`,children:r?.remote?e(`settings.privacy.remote`,{name:r.label}):e(r?`settings.privacy.local`:`settings.privacy.unknown`)}),i&&V(`div`,{className:`setting-row setting-row-path`,children:[P(`span`,{children:e(`settings.privacy.dataFolder`)}),P(`bdi`,{dir:`ltr`,className:`setting-path`,children:i})]})]}),V(`section`,{className:`settings-card`,"aria-label":e(`settings.privacy.reportTitle`),children:[P(`p`,{className:`settings-note`,children:e(`settings.privacy.reportNote`)}),P(tC,{classes:hP})]}),P(bN,{title:e(`settings.privacy.undo`),children:P(mP,{})}),V(`section`,{className:`settings-card`,"aria-label":e(`settings.privacy.deleteTitle`),children:[P(`p`,{className:`danger-warning`,children:t.length===0?e(`settings.privacy.nothingToDelete`):e(`settings.privacy.deleteWarning`)}),P(`button`,{type:`button`,className:`btn-danger`,onClick:()=>void u(),disabled:t.length===0,children:e(a?`settings.privacy.deleteConfirm`:`settings.privacy.delete`)})]}),s&&P(`p`,{className:s.ok?`settings-ok`:`settings-error`,role:s.ok?`status`:`alert`,children:s.text})]})}var _P=[{id:`needs_approval`,label:`settings.alerts.approval`},{id:`question`,label:`settings.alerts.question`},{id:`finished`,label:`settings.alerts.finished`}],vP=[{value:`banner`,label:`settings.alerts.banner`},{value:`badge`,label:`settings.alerts.badge`},{value:`off`,label:`settings.alerts.off`}],yP=[0,10,20,30,50];function bP(){return typeof Notification>`u`?`unsupported`:Notification.permission}function xP(){let e=T(),t=lc(),n=!!window.gaiaAPI,[r,i]=(0,J.useState)(bP),a=Object.values(t.modes).includes(`banner`);return V(`div`,{className:`settings-pane`,children:[P(`h2`,{className:`settings-pane-title`,children:e(`settings.section.notifications`)}),P(`p`,{className:`settings-pane-lede`,children:e(`settings.alerts.lede`)}),V(`section`,{className:`settings-card`,"aria-label":e(`settings.alerts.when`),children:[_P.map(n=>V(`div`,{className:`setting-row`,children:[P(`span`,{id:`alert-${n.id}`,children:e(n.label)}),P(`div`,{className:`segmented`,role:`radiogroup`,"aria-labelledby":`alert-${n.id}`,children:vP.map(r=>P(`button`,{type:`button`,role:`radio`,"aria-checked":t.modes[n.id]===r.value,className:t.modes[n.id]===r.value?`is-active`:``,onClick:()=>t.setMode(n.id,r.value),children:e(r.label)},r.value))})]},n.id)),!n&&a&&r!==`granted`&&(r==="default"?P(`button`,{type:`button`,className:`btn-secondary`,onClick:()=>{Notification.requestPermission().then(i).catch(e=>{console.error(`[alerts] Notification permission request failed`,e),i(bP())})},children:e(`settings.alerts.allow`)}):P(`p`,{className:`settings-error`,role:`alert`,children:e(r===`unsupported`?`settings.alerts.unsupported`:`settings.alerts.blocked`)})),V(`label`,{className:`setting-row`,children:[P(`span`,{children:e(`settings.alerts.sound`)}),V(`span`,{className:`toggle-switch`,children:[P(`input`,{type:`checkbox`,checked:t.sound,onChange:()=>t.update({sound:!t.sound}),"aria-label":e(`settings.alerts.sound`)}),P(`span`,{className:`toggle-track`})]})]}),n&&V(`label`,{className:`setting-row`,children:[P(`span`,{children:e(`settings.alerts.flash`)}),V(`span`,{className:`toggle-switch`,children:[P(`input`,{type:`checkbox`,checked:t.flash,onChange:()=>t.update({flash:!t.flash}),"aria-label":e(`settings.alerts.flash`)}),P(`span`,{className:`toggle-track`})]})]})]}),V(`section`,{className:`settings-card`,"aria-labelledby":`keep-awake-title`,children:[P(`h3`,{className:`settings-label`,id:`keep-awake-title`,children:e(`settings.alerts.keepAwakeTitle`)}),n?V(D.Fragment,{children:[V(`label`,{className:`setting-row`,children:[P(`span`,{children:e(`settings.alerts.keepAwake`)}),V(`span`,{className:`toggle-switch`,children:[P(`input`,{type:`checkbox`,checked:t.keepAwake,onChange:()=>t.update({keepAwake:!t.keepAwake}),"aria-label":e(`settings.alerts.keepAwake`)}),P(`span`,{className:`toggle-track`})]})]}),V(`div`,{className:`setting-row`,children:[P(`label`,{htmlFor:`battery-floor`,children:e(`settings.alerts.battery`)}),P(`select`,{id:`battery-floor`,className:`settings-input settings-select-compact`,value:t.batteryFloor,disabled:!t.keepAwake,onChange:e=>t.update({batteryFloor:Number(e.target.value)}),children:yP.map(t=>P(`option`,{value:t,children:t===0?e.bare(`settings.alerts.never`):`${t}%`},t))})]}),P(`p`,{className:`settings-hint`,children:e(`settings.alerts.screen`)})]}):P(`p`,{className:`settings-hint`,children:e(`settings.alerts.desktopOnly`)})]})]})}var SP=[50,75,100,125,150,175,200],CP=[{accent:`american`,gender:`female`},{accent:`american`,gender:`male`},{accent:`british`,gender:`female`},{accent:`british`,gender:`male`}],wP=`settings:preview`,TP=`Hello, I'm GAIA. This is how I'll read my replies to you.`;function EP(e){return e instanceof vn?e.detail||e.message:String(e)}function DP(){let e=T(),t=wS(e=>e.settings),n=wS(e=>e.setSettings),r=wS(e=>e.read),i=wS(e=>e.stop),a=wS(e=>e.messageId===wP),o=wS(e=>e.messageId===wP&&e.status===`loading`),[s,c]=(0,J.useState)(null),[l,u]=(0,J.useState)(null),[d,f]=(0,J.useState)(!1);(0,J.useEffect)(()=>{dS().then(n).catch(e=>c(EP(e)))},[n]);let p=e=>{f(!0),u(null),wS.getState().messageId===wP&&i(),fS(e).then(n).catch(e=>u(EP(e))).finally(()=>f(!1))};return s?V(`div`,{className:`settings-pane`,children:[P(`h2`,{className:`settings-pane-title`,children:e(`settings.section.voice`)}),P(`p`,{className:`settings-error`,role:`alert`,children:e(`readAloud.settings.loadFailed`,{reason:s})})]}):t?V(`div`,{className:`settings-pane`,children:[P(`h2`,{className:`settings-pane-title`,children:e(`settings.section.voice`)}),P(`p`,{className:`settings-pane-lede`,children:e(`readAloud.settings.lede`)}),V(`div`,{className:`settings-field`,children:[P(`label`,{className:`settings-label`,htmlFor:`read-aloud-voice`,children:e(`readAloud.settings.voice`)}),V(`div`,{className:`read-aloud-voice-row`,children:[P(`select`,{id:`read-aloud-voice`,className:`settings-input`,value:t.voice,disabled:d,onChange:e=>p({voice:e.target.value}),children:CP.map(n=>P(`optgroup`,{label:e(`readAloud.group.${n.accent}.${n.gender}`),children:t.voices.filter(e=>e.accent===n.accent&&e.gender===n.gender).map(e=>P(`option`,{value:e.id,lang:`en`,children:e.name},e.id))},`${n.accent}-${n.gender}`))}),V(`button`,{type:`button`,className:`btn-secondary`,"aria-pressed":a,disabled:d,onClick:()=>a?i():void r(wP,TP),children:[o?P(K,{size:13,className:`spin`}):P(a?io:go,{size:13}),e(a?`readAloud.stop`:`readAloud.settings.preview`)]})]}),P(`span`,{className:`settings-hint`,children:e(`readAloud.settings.englishOnly`)}),P(DS,{messageId:wP})]}),V(`div`,{className:`settings-field`,children:[P(`label`,{className:`settings-label`,htmlFor:`read-aloud-speed`,children:e(`readAloud.settings.speed`)}),P(`select`,{id:`read-aloud-speed`,className:`settings-input`,value:t.speed,disabled:d,onChange:e=>p({speed:Number(e.target.value)}),children:(SP.includes(t.speed)?SP:[...SP,t.speed].sort((e,t)=>e-t)).map(t=>P(`option`,{value:t,children:t===100?e.bare(`readAloud.settings.normalSpeed`):`${(t/100).toLocaleString(e.locale)}×`},t))})]}),V(`label`,{className:`setting-row`,children:[P(`span`,{children:e(`readAloud.settings.auto`)}),V(`span`,{className:`toggle-switch`,children:[P(`input`,{type:`checkbox`,checked:t.auto,disabled:d,onChange:()=>p({auto:!t.auto}),"aria-label":e(`readAloud.settings.auto`)}),P(`span`,{className:`toggle-track`})]})]}),P(`p`,{className:`settings-hint`,children:e(`readAloud.settings.shared`)}),l&&P(`p`,{className:`settings-error`,role:`alert`,children:e(`readAloud.settings.saveFailed`,{reason:l})})]}):V(`p`,{className:`settings-hint`,children:[P(K,{size:13,className:`spin`}),` `,e(`settings.loading`)]})}function OP(){let e=T(),t=k(e=>e.openSettings),n=k(e=>e.closeSettings),r=k(e=>e.runSetupAgain),[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(null),[u,d]=(0,J.useState)(!1);(0,J.useEffect)(()=>{ot().then(a).catch(e=>l(e instanceof Error?e.message:String(e))),le().then(s).catch(e=>l(e instanceof Error?e.message:String(e)))},[]);let f=i?.catalog?.find(e=>e.id===i.chat_model.id),p=(i?.catalog??[]).filter(e=>e.downloaded),m=p.reduce((e,t)=>e+(t.full_size_gb??0),0),h=[o?.gpu_name,o?.npu_detected?e(`setup.checks.npu`):null].filter(Boolean).join(` · `),g=[{title:e(`settings.setup.where`),rows:[{label:e(`settings.setup.chatRuns`),value:f?.name??null,section:`model`},{label:e(`settings.setup.cloudKeys`),value:null,section:`model`}]},{title:e(`setup.pc.step`),rows:[{label:e(`settings.setup.detected`),value:[h,o?.ram_gb==null?null:`${o.ram_gb} GB`].filter(Boolean).join(` · `)||null,section:`advanced`},{label:e(`settings.setup.server`),value:i?.lemonade.mode===`external`?e(`settings.setup.serverYours`):e(`settings.setup.serverOwn`),section:`advanced`},{label:e(`setup.gpu.title`),value:null,section:`model`}]},{title:e(`setup.models.step`),rows:[{label:e(`settings.setup.models`),value:i?.catalog?e(`settings.setup.modelsValue`,{n:String(p.length),size:$(m)}):null,section:`model`},{label:e(`settings.setup.context`),value:null,section:`model`}]},{title:e(`settings.setup.after`),rows:[{label:e(`settings.section.connectors`),value:null,section:`connectors`},{label:e(`settings.section.memory`),value:null,section:`memory`},{label:e(`settings.language`),value:null,section:`general`},{label:e(`settings.setup.signIn`),value:null,section:`general`}]}];return V(`div`,{className:`settings-pane`,children:[P(`h2`,{className:`settings-pane-title`,children:e(`settings.section.setup`)}),P(`p`,{className:`settings-hint`,children:e(`settings.setup.lede`)}),V(`div`,{className:`settings-setup-status`,children:[V(`span`,{children:[P(`strong`,{children:e(`settings.setup.ready`)}),f&&V(`span`,{className:`settings-hint`,children:[` `,P(`bdi`,{children:e(`settings.setup.running`,{name:f.name})})]})]}),P(`button`,{type:`button`,className:`btn-secondary`,"data-testid":`setup-run-again`,onClick:()=>d(!0),children:e(`settings.setup.runAgain`)})]}),c&&P(`p`,{className:`setup-error`,role:`alert`,children:c}),g.map(e=>V(`section`,{className:`settings-setup-group`,"aria-label":e.title,children:[P(`h3`,{className:`settings-label`,children:e.title}),e.rows.map(e=>V(`button`,{type:`button`,className:`settings-setup-row`,onClick:()=>t(e.section),children:[V(`span`,{children:[P(`span`,{className:`settings-setup-row-label`,children:e.label}),e.value&&P(`bdi`,{className:`settings-hint settings-setup-row-value`,children:e.value})]}),P(yr,{size:14,className:`settings-setup-chevron`,"aria-hidden":`true`})]},e.label))]},e.title)),u&&P(Wj,{title:e(`settings.setup.confirmTitle`),confirmLabel:e(`settings.setup.confirmYes`),cancelLabel:e(`setup.again.notNow`),onConfirm:()=>{d(!1),n(),r(!0)},onCancel:()=>d(!1),children:P(`p`,{children:e(`settings.setup.confirmBody`)})})]})}var kP=`modulepreload`,AP=function(e,t){return new URL(e,t).href},jP={},MP=function(e){return e.pathname.endsWith(`.css`)},NP=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},PP=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=AP(t,n);let r=s(t),i=MP(r);return NP(jP,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:kP,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},FP=(0,J.lazy)(()=>PP(()=>import(`./ConnectorsPane-DZSS3unX.js`).then(e=>({default:e.ConnectorsPane})),__vite__mapDeps([0,1,2,3,4]),import.meta.url)),IP=(0,J.lazy)(()=>PP(()=>import(`./AdvancedSettings-DhQOkz13.js`).then(e=>({default:e.AdvancedSettings})),__vite__mapDeps([5,1,2,3]),import.meta.url)),LP=[`general`,`setup`,`model`,`permissions`,`skills`,`connectors`,`memory`,`notifications`,`voice`,`privacy`,`advanced`];function RP({onUseSkill:e}){let t=T(),n=k(e=>e.settingsSection),r=k(e=>e.openSettings),i=k(e=>e.closeSettings),a=(0,J.useRef)(null),o=n!==null;if(Io(o,i),aS(a,o),yN(a,o,()=>a.current?.querySelector(`.settings-nav-item.is-active`)),!n)return null;let s=(()=>{switch(n){case`general`:return P(UN,{});case`setup`:return P(OP,{});case`model`:return P(oP,{});case`permissions`:return P(sP,{});case`skills`:return P(uP,{onUseSkill:t=>{i(),e(t)}});case`connectors`:return P(FP,{});case`memory`:return P(dP,{});case`notifications`:return P(xP,{});case`voice`:return P(DP,{});case`privacy`:return P(gP,{});case`advanced`:return P(IP,{})}})();return P(`div`,{className:`settings-overlay`,onMouseDown:e=>{e.target===e.currentTarget&&i()},children:V(`div`,{ref:a,className:`settings-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":t(`settings.title`),children:[V(`nav`,{className:`settings-nav`,"aria-label":t(`settings.sections`),children:[P(`h1`,{className:`settings-nav-title`,children:t(`settings.title`)}),LP.map(e=>P(`button`,{type:`button`,"data-section":e,className:`settings-nav-item${n===e?` is-active`:``}`,"aria-current":n===e?`page`:void 0,onClick:t=>{t.currentTarget.focus(),r(e)},children:t(`settings.section.${e}`)},e))]}),V(`div`,{className:`settings-body`,children:[P(`button`,{type:`button`,className:`settings-close`,onClick:i,"aria-label":t(`settings.close`),children:P(So,{size:18})}),P(`div`,{className:`settings-scroll`,children:P(J.Suspense,{fallback:V(`p`,{className:`settings-hint`,children:[P(K,{size:13,className:`spin`}),` `,t(`settings.loading`)]}),children:s})})]})]})})}var zP=p((e,t)=>({lifecycle:null,restartError:null,apply:n=>{n.apiBase&&B(n.apiBase),e({lifecycle:n,restartError:n.status===`running`?null:t().restartError})},restart:async()=>{let n=window.gaiaAPI?.backend;if(!n)throw Error(`Restart GAIA needs the desktop app.`);e({restartError:null});try{t().apply(await n.restart())}catch(t){d.system.error(`Restart GAIA failed`,t),e({restartError:t instanceof Error?t.message:String(t)})}}}));function BP(e){let t=window.gaiaAPI?.backend;if(!t)return()=>{};let n=t=>{let n=zP.getState().lifecycle?.status;zP.getState().apply(t),t.status===`running`&&n&&n!==`running`&&e()},r=t.onState(n);return t.getState().then(n).catch(e=>d.system.error(`Could not read the backend state from the desktop app`,e)),r}function VP(e,t){let[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(!1),[o,s]=(0,J.useState)(null),c=(0,J.useRef)(null),l=(0,J.useRef)(null),u=(0,J.useRef)(null),f=(0,J.useCallback)(()=>{c.current&&=(clearTimeout(c.current),null),l.current&&=(clearTimeout(l.current),null),u.current&&=(clearInterval(u.current),null)},[]);(0,J.useEffect)(()=>f,[f]);let p=(0,J.useCallback)((e,t)=>{u.current&&clearInterval(u.current),u.current=setInterval(async()=>{try{let n=await Nt();t===`load`?n.model_loaded?.toLowerCase()===e.toLowerCase()&&(r(!1),c.current&&=(clearTimeout(c.current),null),u.current&&=(clearInterval(u.current),null)):(n.model_downloaded===!0||n.model_loaded?.toLowerCase()===e.toLowerCase())&&(a(!1),l.current&&=(clearTimeout(l.current),null),u.current&&=(clearInterval(u.current),null))}catch{}},Lc)},[]),m=e??`Gemma-4-E4B-it-GGUF`;return(0,J.useEffect)(()=>s(null),[m]),{isLoadingModel:n,isDownloadingModel:i,downloadError:o,loadModel:(0,J.useCallback)(async(e,t)=>{let n=e??m,i=t??32768;r(!0);try{if(!await zt(n,i)){r(!1);return}d.system.info(`Load model triggered: ${n} (ctx=${i})`),c.current&&clearTimeout(c.current),c.current=setTimeout(()=>r(!1),Fc),p(n,`load`)}catch(e){d.system.error(`Failed to trigger model load`,e),r(!1)}},[m,t,p]),downloadModel:(0,J.useCallback)(async(e=!1,t,n=!1)=>{let r=t??m;a(!0),s(null);try{await fe(r,e,n),d.system.info(`Download model triggered: ${r} (force=${e})`),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>a(!1),Ic),p(r,`download`)}catch(e){d.system.error(`Failed to trigger model download`,e),s(e instanceof Error?e.message:String(e)),a(!1)}},[m,p])}}function HP({onRetry:e,label:t,busyLabel:n=`Checking…`}){let[r,i]=(0,J.useState)(!1);return P(`button`,{className:`connection-banner__retry`,onClick:()=>{i(!0),Promise.resolve(e()).finally(()=>i(!1))},disabled:r,children:r?n:t})}function UP(e){return`${Math.floor(e/60)}:${String(e%60).padStart(2,`0`)}`}function WP({lifecycle:e}){let t=T(),n=zP(e=>e.restart),r=zP(e=>e.restartError),i=e.status===`restarting`,[a,o]=(0,J.useState)(()=>Date.now());if((0,J.useEffect)(()=>{if(!i)return;o(Date.now());let e=setInterval(()=>o(Date.now()),1e3);return()=>clearInterval(e)},[i]),i){let n=e.since?Math.max(0,Math.floor((a-e.since)/1e3)):0;return V(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[P(`div`,{className:`connection-banner__icon`,children:P(K,{size:16,className:`connection-banner__spinner`})}),V(`div`,{className:`connection-banner__text`,dir:`auto`,children:[t(`banner.restarting`),` `,P(`bdi`,{dir:`ltr`,className:`connection-banner__timer`,children:UP(n)}),` `,P(`span`,{className:`connection-banner__hint`,children:t(`banner.restartingHint`)})]})]})}return V(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[P(`div`,{className:`connection-banner__icon`,children:P(q,{size:16})}),V(`div`,{className:`connection-banner__text`,dir:`auto`,children:[t(`banner.restartStopped`),` `,P(`span`,{className:`connection-banner__hint`,children:r?t(`banner.restartFailed`,{error:r}):t(`banner.restartStoppedHint`)})]}),P(HP,{onRetry:n,label:t(`banner.restartButton`),busyLabel:t(`banner.restartingShort`)})]})}function GP({onRetry:e,backendSlow:t=!1,backendError:n=null}){let r=T(),{backendConnected:i,systemStatus:a,currentSessionId:o,messages:s}=k(),c=zP(e=>e.lifecycle),[l,u]=(0,J.useState)(!1),d=!!o&&s.length>0,f=a?.default_model_name??`Gemma-4-E4B-it-GGUF`,{isDownloadingModel:p,downloadError:m,downloadModel:h}=VP(f),g=cs(e=>e.pickLoad),_=cs(e=>e.retryPickLoad),v=cs(e=>e.dismissPickLoad);ls();let y=(0,J.useRef)(a?.lemonade_running),b=(0,J.useRef)(a?.model_downloaded),x=(0,J.useRef)(a?.context_size_sufficient),S=(0,J.useRef)(a?.expected_model_loaded);if((0,J.useEffect)(()=>{if(d)return;let e=a?.lemonade_running,t=a?.model_downloaded,n=a?.context_size_sufficient,r=a?.expected_model_loaded,i=!1;y.current!==e&&(y.current=e,e===!1&&(i=!0)),b.current!==t&&(b.current=t,t===!1&&(i=!0)),x.current!==n&&(x.current=n,n===!1&&(i=!0)),S.current!==r&&(S.current=r,r===!1&&(i=!0)),i&&u(!1)},[a,d]),c&&c.status!==`running`)return P(WP,{lifecycle:c});let C=a?.download_progress??null,w=C?.model_name||f;if(p||C?.state===`downloading`||C?.state===`starting`||C?.state===`error`){let e=C?.total_bytes?`${(C.total_bytes/1e9).toFixed(1)} GB`:`large download`,t=C?.state===`error`;return V(`div`,{className:`connection-banner ${t?`connection-banner--error`:`connection-banner--warning`}`,role:t?`alert`:`status`,children:[P(`div`,{className:`connection-banner__icon`,children:P(t?q:qr,{size:16})}),P(`div`,{className:`connection-banner__text`,dir:`auto`,children:t?V(D.Fragment,{children:[`Download of `,P(`strong`,{children:w}),` failed.`,` `,(m??C?.message)&&P(`span`,{className:`connection-banner__hint`,children:m??C?.message})]}):V(D.Fragment,{children:[`Downloading `,P(`strong`,{children:w}),` (`,e,`).`,C?.state===`downloading`&&C.file&&V(D.Fragment,{children:[` `,V(`span`,{className:`connection-banner__hint`,children:[`File `,C.file_index,` / `,C.total_files,`: `,P(`code`,{children:C.file})]})]})]})}),t?P(`button`,{className:`connection-banner__retry`,onClick:()=>h(!1,w,!a?.model_loaded),children:`Retry`}):P(`span`,{className:`connection-banner__loading connection-banner__progress`,children:C&&C.state===`downloading`&&C.total_bytes>0?V(D.Fragment,{children:[P(`span`,{className:`connection-banner__progress-bar`,role:`progressbar`,"aria-valuenow":C.percent,"aria-valuemin":0,"aria-valuemax":100,"aria-label":`Download progress`,children:P(`span`,{className:`connection-banner__progress-fill`,style:{width:`${C.percent}%`}})}),V(`span`,{className:`connection-banner__progress-label`,children:[C.percent,`% ·`,` `,(C.downloaded_bytes/1e9).toFixed(2),` /`,` `,(C.total_bytes/1e9).toFixed(2),` GB`]})]}):V(D.Fragment,{children:[P(K,{size:13,className:`connection-banner__spinner`}),C?.state===`starting`?C.message??`Starting download…`:`Downloading…`]})}),t&&P(`button`,{className:`connection-banner__dismiss`,onClick:()=>u(!0),"aria-label":`Dismiss`,children:P(So,{size:14})})]})}if(g){let e=ds(g.model);return g.error?V(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[P(`div`,{className:`connection-banner__icon`,children:P(q,{size:16})}),V(`div`,{className:`connection-banner__text`,dir:`auto`,children:[r(`banner.pickLoad.failed`,{model:e}),` `,P(`span`,{className:`connection-banner__hint`,dir:`auto`,children:g.error.key?r(g.error.key,{reason:g.error.reason}):g.error.reason})]}),P(HP,{onRetry:_,label:r(`banner.pickLoad.retry`)}),P(`button`,{className:`connection-banner__dismiss`,onClick:v,"aria-label":r(`banner.dismiss`),children:P(So,{size:14})})]}):V(`div`,{className:`connection-banner connection-banner--init`,role:`status`,children:[P(`div`,{className:`connection-banner__icon`,children:P(K,{size:16,className:`connection-banner__spinner`})}),V(`div`,{className:`connection-banner__text`,dir:`auto`,children:[r(`banner.pickLoad.loading`,{model:e}),` `,P(`bdi`,{dir:`ltr`,children:r(`banner.pickLoad.seconds`,{s:g.seconds})}),` `,P(`span`,{className:`connection-banner__hint`,children:r(`banner.pickLoad.canType`)})]})]})}if(Bw(a)&&!t&&!n){let e=a?.init_tasks?.find(e=>e.status===`running`)?.name||`Preparing AI system`;return V(`div`,{className:`connection-banner connection-banner--init`,role:`status`,children:[P(`div`,{className:`connection-banner__icon`,children:P(K,{size:16,className:`connection-banner__spinner`})}),V(`div`,{className:`connection-banner__text`,dir:`auto`,children:[e,V(`span`,{className:`thinking-dots`,children:[P(`span`,{children:`.`}),P(`span`,{children:`.`}),P(`span`,{children:`.`})]})]})]})}if(l||d)return null;if(!i)return V(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[P(`div`,{className:`connection-banner__icon`,children:P(vo,{size:16})}),V(`div`,{className:`connection-banner__text`,dir:`auto`,children:[r(`banner.unreachable`),` `,P(`span`,{className:`connection-banner__hint`,children:r(`banner.unreachableHint`)})]}),e&&P(HP,{onRetry:e,label:`Retry`})]});if(n)return V(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[P(`div`,{className:`connection-banner__icon`,children:P(q,{size:16})}),V(`div`,{className:`connection-banner__text`,dir:`auto`,children:[`GAIA's backend answered with an error (`,n,`).`,` `,P(`span`,{className:`connection-banner__hint`,children:`It may be overloaded. GAIA keeps checking; if it lasts, restart GAIA.`})]}),e&&P(HP,{onRetry:e,label:`Check again`})]});if(t)return V(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[P(`div`,{className:`connection-banner__icon`,children:P(q,{size:16})}),V(`div`,{className:`connection-banner__text`,dir:`auto`,children:[`GAIA is slow to answer.`,` `,P(`span`,{className:`connection-banner__hint`,children:`It may be busy with another chat or app. GAIA keeps checking.`})]}),e&&P(HP,{onRetry:e,label:`Check again`})]});if(a?.config_error)return V(`div`,{className:`connection-banner connection-banner--error`,role:`alert`,children:[P(`div`,{className:`connection-banner__icon`,children:P(q,{size:16})}),V(`div`,{className:`connection-banner__text`,dir:`auto`,children:[`GAIA settings could not be loaded.`,` `,P(`span`,{className:`connection-banner__hint`,children:a.config_error})]}),e&&P(HP,{onRetry:e,label:`Check again`})]});if(a&&!a.lemonade_running){let t=Vw(a)===`unresponsive`,n=KN(a);return V(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[P(`div`,{className:`connection-banner__icon`,children:P(q,{size:16})}),V(`div`,{className:`connection-banner__text`,dir:`auto`,children:[t?`The model server is not answering (${a.lemonade_error}). It may be busy with another app or loading a model.`:r(`banner.serverStopped`),` `,n?P(`span`,{className:`connection-banner__hint`,children:r(`banner.finishSetup`)}):a.start_command?V(`span`,{className:`connection-banner__hint`,children:[t?`If it stays this way, restart it: `:`To start it by hand, run `,P(`code`,{children:a.start_command})]}):a.start_instruction&&P(`span`,{className:`connection-banner__hint`,children:a.start_instruction})]}),n&&P(qN,{className:`connection-banner__retry`}),e&&P(HP,{onRetry:e,label:r(`settings.key.checkAgain`)}),P(`button`,{className:`connection-banner__dismiss`,onClick:()=>u(!0),"aria-label":`Dismiss`,children:P(So,{size:14})})]})}if(a&&a.lemonade_running&&a.model_loaded&&a.context_size_sufficient===!1){let t=a.model_context_size??0;return V(`div`,{className:`connection-banner connection-banner--warning`,role:`status`,children:[P(`div`,{className:`connection-banner__icon`,children:P(qi,{size:16})}),V(`div`,{className:`connection-banner__text`,dir:`auto`,children:[`LLM context window is too small (`,t.toLocaleString(),` tokens;`,` `,Nc.toLocaleString(),` required).`,` `,P(`span`,{className:`connection-banner__hint`,children:`Reload it with a larger context in Settings → Advanced.`})]}),e&&P(HP,{onRetry:e,label:`Check again`}),P(`button`,{className:`connection-banner__dismiss`,onClick:()=>u(!0),"aria-label":`Dismiss`,children:P(So,{size:14})})]})}return null}function KP(){let e=kN(),t=T(),[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(null),o=(0,J.useCallback)(e=>{let n=DN();n&&(a(null),n[e]().catch(n=>{d.system.error(`Update ${e} failed`,n),a(NN(n,t))}))},[t]);if(n)return null;let s=e.installFailed?t(`update.chip.installFailedDetail`,e.installFailed):null,c=e.status===`downloading`||e.status===`downloaded`;if(e.startFailed&&e.previousVersion&&!c)return V(`div`,{className:`update-chip update-chip--error`,role:`status`,children:[P(q,{size:13,className:`update-chip__icon`}),P(`span`,{className:`update-chip__label`,title:i??void 0,children:t(i?`update.chip.updateFailed`:`update.chip.startFailed`)}),P(`button`,{type:`button`,className:`update-chip__action`,onClick:()=>o(`revertUpdate`),children:t(`update.chip.goBack`,{version:e.previousVersion})}),P(`button`,{type:`button`,className:`update-chip__dismiss`,onClick:()=>r(!0),"aria-label":t(`update.chip.dismissError`),children:P(So,{size:11})})]});let l=e.status===`available`||e.status===`downloaded`;if(s&&!l)return V(`div`,{className:`update-chip update-chip--error`,role:`status`,title:s??void 0,children:[P(q,{size:13,className:`update-chip__icon`}),P(`span`,{className:`update-chip__label`,children:t(`update.chip.installFailed`)}),P(`button`,{type:`button`,className:`update-chip__dismiss`,onClick:()=>r(!0),"aria-label":t(`update.chip.dismissError`),children:P(So,{size:11})})]});if(e.status===`idle`||e.status===`checking`||e.status===`disabled`||e.status===`no-channel`)return null;if(e.status===`downloading`){let n=Math.max(0,Math.min(100,e.progress));return V(`div`,{className:`update-chip update-chip--downloading`,role:`status`,"aria-live":`polite`,title:t(`update.chip.downloadingTitle`,{version:e.version??``}),children:[P(qr,{size:13,className:`update-chip__icon`}),P(`span`,{className:`update-chip__label`,children:e.preparing?t(`update.chip.preparing`):t(`update.chip.downloading`,{pct:n})})]})}return e.status===`available`?V(`div`,{className:`update-chip update-chip--available`,role:`status`,title:i||s||e.releaseNotes||t(`update.chip.availableTitle`),children:[P(qr,{size:13,className:`update-chip__icon`}),P(`span`,{className:`update-chip__label`,children:i?t(`update.chip.updateFailed`):s?t(`update.chip.installFailed`):t(`update.chip.available`,{version:e.version??``})}),!e.pinnedVersion&&P(`button`,{type:`button`,className:`update-chip__action`,onClick:()=>o(`downloadUpdate`),children:t(`update.chip.updateNow`)}),P(`button`,{type:`button`,className:`update-chip__dismiss`,onClick:()=>r(!0),"aria-label":t(`update.chip.dismiss`),children:P(So,{size:11})})]}):e.status===`downloaded`?V(`div`,{className:`update-chip update-chip--ready`,role:`status`,"aria-live":`polite`,children:[P(Pa,{size:13,className:`update-chip__icon`}),P(`button`,{type:`button`,className:`update-chip__action`,onClick:()=>o(`restart`),title:i||s||t(`update.chip.restartTitle`),children:t(i?`update.chip.restartFailed`:s?`update.chip.installFailedRetry`:`update.chip.ready`)})]}):e.status===`error`?V(`div`,{className:`update-chip update-chip--error`,role:`status`,title:e.error||t(`update.chip.checkFailed`),children:[P(q,{size:13,className:`update-chip__icon`}),P(`span`,{className:`update-chip__label`,children:t(`update.chip.checkFailed`)}),P(`button`,{type:`button`,className:`update-chip__dismiss`,onClick:()=>r(!0),"aria-label":t(`update.chip.dismissError`),children:P(So,{size:11})})]}):null}var qP={permission_request:{icon:P(Wa,{size:16}),colorClass:`notif-type-permission`},policy_alert:{icon:P(Wa,{size:16}),colorClass:`notif-type-policy`},security_alert:{icon:P(q,{size:16}),colorClass:`notif-type-security`},status_change:{icon:P(Tr,{size:16}),colorClass:`notif-type-status`},info:{icon:P(Vi,{size:16}),colorClass:`notif-type-info`},error:{icon:P(Cr,{size:16}),colorClass:`notif-type-error`}};function JP(e,t){let n=Date.now()-e,r=Math.floor(n/1e3);if(r<60)return t(`time.justNow`);let i=Math.floor(r/60);if(i<60)return t(`time.minutesAgo`,{n:i});let a=Math.floor(i/60);if(a<24)return t(`time.hoursAgo`,{n:a});let o=Math.floor(a/24);return o<7?t(`time.daysAgo`,{n:o}):new Date(e).toLocaleDateString(te(t),{month:`short`,day:`numeric`})}function YP({onClose:e}){let t=T(),n=Qs(ko(ec)),r=Qs($s),i=Qs(e=>e.markRead),a=Qs(e=>e.markAllRead),o=Qs(e=>e.clearAll),s=Qs(e=>e.dismiss),c=Qs(e=>e.respondToPermission),l=Qs(e=>e.typeFilter),u=Qs(e=>e.setTypeFilter),d=(0,J.useCallback)(e=>{i(e)},[i]),f=(0,J.useCallback)(e=>{c(e.id,`allow`).catch(e=>console.error(`[NotificationCenter] allow failed:`,e))},[c]),p=(0,J.useCallback)(e=>{c(e.id,`deny`).catch(e=>console.error(`[NotificationCenter] deny failed:`,e))},[c]);Io(!0,e);let m=[{key:null,label:t(`notifications.filter.all`)},{key:`permission_request`,label:t(`notifications.filter.permissions`)},{key:`policy_alert`,label:t(`notifications.filter.policy`)},{key:`error`,label:t(`notifications.filter.errors`)},{key:`security_alert`,label:t(`notifications.filter.security`)},{key:`status_change`,label:t(`notifications.filter.status`)},{key:`info`,label:t(`notifications.filter.info`)}];return V(`div`,{className:`notification-center`,role:`dialog`,"aria-label":t(`notifications.dialogAria`),children:[V(`div`,{className:`notification-center-header`,children:[V(`div`,{className:`notification-center-title-row`,children:[P(`h2`,{className:`notification-center-title`,children:t(`notifications.title`)}),r>0&&P(`span`,{className:`notification-center-badge`,children:r})]}),P(`button`,{className:`btn-icon notification-center-close`,onClick:e,"aria-label":t(`notifications.close`),children:P(So,{size:18})})]}),P(`div`,{className:`notification-filter-bar`,role:`tablist`,"aria-label":t(`notifications.filterAria`),children:m.map(e=>P(`button`,{role:`tab`,"aria-selected":l===e.key,className:`notification-filter-tab ${l===e.key?`active`:``}`,onClick:()=>u(e.key),children:e.label},e.key??`all`))}),P(`div`,{className:`notification-list`,children:n.length===0?V(`div`,{className:`notification-empty`,children:[P($n,{size:40,strokeWidth:1.2}),P(`span`,{children:t(`notifications.empty`)})]}):n.map(e=>{let n=qP[e.type],r=e.type===`permission_request`&&e.tool?Ks(e,t,ny):null;return V(`div`,{className:`notification-item ${e.read?``:`unread`} ${n.colorClass}`,id:e.type===`policy_alert`&&e.receiptId?`policy-receipt-${encodeURIComponent(e.receiptId)}`:void 0,onClick:()=>d(e.id),role:`button`,tabIndex:0,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&d(e.id)},children:[!e.read&&P(`span`,{className:`notification-unread-dot`}),P(`span`,{className:`notification-icon`,children:n.icon}),V(`div`,{className:`notification-content`,children:[V(`div`,{className:`notification-content-header`,children:[P(`span`,{className:`notification-agent`,dir:`auto`,children:e.agentName}),P(`span`,{className:`notification-time`,children:JP(e.timestamp,t)})]}),r?V(D.Fragment,{children:[P(`span`,{className:`notification-title`,children:P(ay,{text:r.heading})}),P(`span`,{className:`notification-message`,children:P(ay,{text:r.question})})]}):V(D.Fragment,{children:[e.title&&P(`span`,{className:`notification-title`,children:e.title}),P(`span`,{className:`notification-message`,children:e.message})]}),e.type===`permission_request`&&e.tool&&e.tool!==`allow_path_access`&&V(`span`,{className:`notification-tool`,children:[t(`activity.policy.tool`),`: `,P(`code`,{dir:`ltr`,children:e.tool})]}),e.type===`policy_alert`&&V(`div`,{className:`notification-policy-details`,children:[e.tool&&V(`span`,{className:`notification-tool`,children:[t(`activity.policy.tool`),`: `,P(`code`,{dir:`ltr`,children:e.tool})]}),e.reason&&V(`span`,{className:`notification-policy-reason`,children:[t(`notifications.reason`),`: `,e.reason]}),e.ruleIds&&e.ruleIds.length>0&&V(`span`,{className:`notification-tool`,children:[t(`activity.policy.rules`),`: `,P(`code`,{dir:`ltr`,children:e.ruleIds.join(`, `)})]}),e.policyVersion&&V(`span`,{className:`notification-tool`,children:[t(`activity.policy.policy`),`: `,P(`code`,{dir:`ltr`,children:e.policyVersion})]}),V(`span`,{className:`notification-tool`,children:[t(`activity.policy.receipt`),`:`,` `,e.receiptId?P(`code`,{dir:`ltr`,children:e.receiptId}):P(`em`,{children:t(`activity.policy.receiptUnavailable`)})]})]}),e.type===`permission_request`&&!e.response&&V(`div`,{className:`notification-actions`,children:[V(`button`,{className:`notification-action-btn notification-action-allow`,onClick:t=>{t.stopPropagation(),f(e)},children:[P(pr,{size:14}),t(`notifications.approve`)]}),V(`button`,{className:`notification-action-btn notification-action-deny`,onClick:t=>{t.stopPropagation(),p(e)},children:[P(So,{size:14}),t(`notifications.deny`)]})]}),e.type===`permission_request`&&e.response&&P(`span`,{className:`notification-response-badge ${e.response===`allow`?`response-allow`:`response-deny`}`,children:e.response===`allow`?t(`notifications.approved`):t(`notifications.denied`)})]}),P(`button`,{className:`notification-dismiss`,onClick:t=>{t.stopPropagation(),s(e.id)},"aria-label":t(`notifications.dismiss`),children:P(So,{size:14})})]},e.id)})}),n.length>0&&V(`div`,{className:`notification-center-footer`,children:[V(`button`,{className:`notification-footer-btn`,onClick:a,disabled:r===0,children:[P(pr,{size:14}),t(`notifications.markAllRead`)]}),V(`button`,{className:`notification-footer-btn notification-footer-clear`,onClick:o,children:[P(co,{size:14}),t(`notifications.clear`)]})]})]})}var XP=1500,ZP=e=>new Promise(t=>setTimeout(t,e));async function QP({onProgress:e,isCancelled:t=()=>!1,pollMs:n=XP}={}){try{await on(ok)}catch(e){if(e?.httpStatus!==409)throw e;let t=await Ut(ok).catch(()=>null);if(!t||t.status===`completed`||t.status===`failed`)throw e}for(;!t();){let t=await Ut(ok);if(e?.(t),t.status===`completed`)return;if(t.status===`failed`)throw Error(t.error||`The GAIA agent could not be installed.`);await ZP(n)}}function $P({onInstalled:e,noBuild:t=!1}){let n=T(),[r,i]=(0,J.useState)({kind:`idle`}),a=(0,J.useRef)(!1);(0,J.useEffect)(()=>()=>{a.current=!0},[]);let o=(0,J.useCallback)(async()=>{i({kind:`installing`,percent:0});try{if(await QP({isCancelled:()=>a.current,onProgress:e=>{a.current||i({kind:`installing`,percent:e.percent??0})}}),a.current)return;await e(),a.current||i({kind:`idle`})}catch(e){a.current||i({kind:`failed`,error:e instanceof Error?e.message:String(e)})}},[e]);return t?P(`div`,{className:`app-notice is-warning`,role:`status`,children:P(`span`,{children:n(`agentNotice.noBuild`)})}):V(`div`,{className:`app-notice is-warning`,role:`status`,children:[r.kind===`installing`?P(`span`,{children:n(`agentNotice.installing`,{percent:Math.round(r.percent)})}):r.kind===`failed`?P(`span`,{children:n(`agentNotice.failed`,{error:r.error})}):P(`span`,{children:n(`agentNotice.missing`)}),r.kind!==`installing`&&P(`button`,{type:`button`,className:`link-btn`,onClick:()=>void o(),children:r.kind===`failed`?n(`agentNotice.retry`):n(`agentNotice.install`)})]})}function eF(e,t){if(!(e instanceof Error))return t;let n=e.message,r=n.match(/API \d+: (.+)/);if(r)try{let e=JSON.parse(r[1]);if(e.detail)return e.detail}catch{}return n}function tF(e,t){let{addNotification:n}=Qs.getState();for(let r of t)r.error_count<=(e[r.id]??0)||!r.last_error||n({id:`schedule-error-${r.id}-${r.error_count}`,type:`error`,agentId:`scheduler`,agentName:`GAIA`,title:`Scheduled task "${r.name}" failed`,message:r.last_error,timestamp:Date.now(),read:!1,dismissed:!1,priority:`high`,...r.session_id?{sessionId:r.session_id}:{}})}var nF=p((e,t)=>({schedules:[],loading:!1,error:null,actionError:null,selectedSchedule:null,results:[],resultsLoading:!1,errorCounts:null,loadSchedules:async()=>{t().schedules.length===0&&!t().error&&e({loading:!0}),e({error:null});try{let n=(await At()).schedules||[],r=t().errorCounts;r&&tF(r,n),e({schedules:n,loading:!1,errorCounts:Object.fromEntries(n.map(e=>[e.id,e.error_count]))})}catch(t){d.api.error(`Failed to load schedules`,t),e({error:`Failed to load schedules`,loading:!1})}},createSchedule:async(t,n,r)=>{try{let i=await yt(t,n,r);e(e=>({schedules:[...e.schedules,i],actionError:null}))}catch(e){throw d.api.error(`Failed to create schedule`,e),e}},updateScheduleStatus:async(t,n)=>{try{let r=await ut(t,n);e(e=>({schedules:e.schedules.map(e=>e.name===t?r:e),actionError:null}))}catch(n){d.api.error(`Failed to update schedule "${t}"`,n),e({actionError:eF(n,`Failed to update schedule`)})}},runScheduleNow:async t=>{try{let n=await Jt(t);e(e=>({schedules:e.schedules.map(e=>e.name===t?n:e),actionError:null}))}catch(n){d.api.error(`Failed to run schedule "${t}" now`,n),e({actionError:eF(n,`Could not run the schedule now`)})}},deleteSchedule:async t=>{try{await Qe(t),e(e=>({schedules:e.schedules.filter(e=>e.name!==t),selectedSchedule:e.selectedSchedule===t?null:e.selectedSchedule,actionError:null}))}catch(n){d.api.error(`Failed to delete schedule "${t}"`,n),e({actionError:eF(n,`Failed to delete schedule`)})}},selectSchedule:n=>{e({selectedSchedule:n,results:[],resultsLoading:!1}),n&&t().loadResults(n)},loadResults:async n=>{e({resultsLoading:!0});try{let r=await De(n);if(t().selectedSchedule!==n)return;e({results:r.results||[],resultsLoading:!1})}catch(r){if(d.api.error(`Failed to load results for "${n}"`,r),t().selectedSchedule!==n)return;e({results:[],resultsLoading:!1})}},dismissActionError:()=>e({actionError:null})})),rF=new Set([`loading_model`,`downloading_model`,`model_retry`,`waiting`]),iF=5;function aF(e,t){return{id:e,title:t.get(e)?.title??`Untitled chat`}}function oF(e){let t=new Map(e.sessions.map(e=>[e.id,e])),n=e.isStreaming&&e.currentSessionId!==null,r=[...e.runningSessionIds];n&&!r.includes(e.currentSessionId)&&r.push(e.currentSessionId);let i=new Set(r),a=new Set(e.notifications.filter(e=>e.type===`permission_request`&&!e.response&&!e.dismissed&&e.sessionId&&i.has(e.sessionId)).map(e=>e.sessionId)),o=[...a].map(e=>({...aF(e,t),reason:`approval`}));n&&e.awaitingUser&&!a.has(e.currentSessionId)&&o.push({...aF(e.currentSessionId,t),reason:`answer`});for(let[n,r]of Object.entries(e.awaitingBySession))o.some(e=>e.id===n)||o.push({...aF(n,t),reason:r===`question`?`answer`:`approval`});let s=n&&!e.awaitingUser&&e.livePhase&&rF.has(e.livePhase)?e.liveStatus:null,c=e.systemStatus,l=null;if(c?.default_model_is_cloud&&c.default_model_name)l={name:c.default_model_name,where:`cloud`};else if(c?.model_loaded){let e=c.model_labels?.includes(`cloud`),t=c.model_device&&c.model_device!==`none`?c.model_device:null;l={name:c.model_loaded,where:e?`cloud`:t}}let u=[...e.sessions].sort((e,t)=>t.updated_at.localeCompare(e.updated_at)).slice(0,iF).map(e=>aF(e.id,t));return{backendConnected:e.backendConnected,modelServerRunning:c&&!c.default_model_is_cloud?c.lemonade_running:null,model:l,waitingOnModel:s||null,running:r.map(e=>aF(e,t)),needsYou:o,recent:u}}function sF(e){let t=(0,J.useRef)(e);t.current=e,(0,J.useEffect)(()=>{let e=window.gaiaAPI?.tray;if(!e)return;let n=``,r=null,i=()=>{let t=k.getState(),i={backendConnected:t.backendConnected,systemStatus:t.systemStatus,sessions:t.sessions,runningSessionIds:t.runningSessionIds,awaitingBySession:t.awaitingBySession,currentSessionId:t.currentSessionId,isStreaming:t.isStreaming,awaitingUser:t.awaitingUser,liveStatus:t.liveStatus,livePhase:t.livePhase,notifications:Qs.getState().notifications},a=r;if(r=i,a&&Object.keys(i).every(e=>i[e]===a[e]))return;let o=oF(i),s=JSON.stringify(o);s!==n&&(n=s,e.setActivity(o).catch(e=>{n=``,d.system.error(`The tray could not take the app state`,e)}))};i();let a=k.subscribe(i),o=Qs.subscribe(i),s=e.onCommand(e=>{switch(e.type){case`open-chat`:t.current.openChat(e.sessionId);break;case`new-chat`:t.current.newChat();break;case`open-settings`:k.getState().openSettings(e.section);break;case`refresh-status`:t.current.refreshStatus();break;default:d.system.error(`Unknown tray command`,e)}});return()=>{a(),o(),s()}},[])}function cF(){(0,J.useEffect)(()=>{let e=window.gaiaAPI;if(!e)return;let t=Qs.getState().addNotification,n=[e.notification.onNotification(t),e.notification.onPermissionRequest(t),e.tray.onNavigate(e=>{let t=typeof e==`string`&&e.startsWith(`session:`)?e.slice(8):null;if(!t)return;let n=k.getState();n.currentSessionId!==t&&n.setMessages([]),n.setCurrentSession(t)})];return()=>n.forEach(e=>e())},[])}function lF(e,t,n){let r=window.gaiaAPI;if(r){r.notification.show({title:t,body:n,sessionId:e}).then(e=>{e||d.system.warn(`This OS has no desktop notifications; the badge still counts it.`)}).catch(e=>d.system.error(`Could not show the desktop notification`,e));return}if(typeof Notification>`u`){d.system.warn(`This browser has no notifications; the alert was not shown.`);return}if(Notification.permission!==`granted`){d.system.warn(`Browser notifications are ${Notification.permission}; allow them in Settings → Notifications.`);return}let i=new Notification(t,{body:n,tag:`gaia-${e}`});i.onclick=()=>{window.focus(),k.getState().setCurrentSession(e)}}function uF(){let[e,t]=(0,J.useState)(null);return(0,J.useEffect)(()=>{let e=navigator;if(!e.getBattery)return;let n=null,r=()=>{n&&t({charging:n.charging,level:n.level})};return e.getBattery().then(e=>{n=e,r(),e.addEventListener(`levelchange`,r),e.addEventListener(`chargingchange`,r)}).catch(e=>d.system.warn(`Battery level unavailable; keep-awake ignores the battery policy.`,e)),()=>{n?.removeEventListener(`levelchange`,r),n?.removeEventListener(`chargingchange`,r)}},[]),e}function dF(){cF();let e=k(e=>e.runningSessionIds),t=k(e=>e.awaitingBySession),n=k(e=>e.sessions),r=k(e=>e.currentSessionId),i=Qs(ko(nc)),a=lc(),o=uF(),s=(0,J.useRef)(null),c=gc(e,t,i),l=JSON.stringify(c);(0,J.useEffect)(()=>{let e=JSON.parse(l),t=s.current;if(s.current=e,t===null)return;let{sessions:n,currentSessionId:r}=k.getState(),i=document.hasFocus(),o=!1;for(let{sessionId:s,event:c}of _c(t,e)){let e=n.find(e=>e.id===s);if(e?.kind===`eval`||e?.kind===`scheduled`)continue;let t=a.modes[c];if(!(t===`off`||bc(s,r,i))&&(o=!0,t===`banner`)){if(c!==`finished`){let{title:t,body:n}=yc(c,e);lF(s,t,n)}else mt(s).then(e=>{k.getState().updateSessionInList(s,e);let{title:t,body:n}=yc(c,e);lF(s,t,n)}).catch(t=>{d.system.error(`Could not read how chat ${s} ended`,t);let{title:n,body:r}=yc(c,{...e,last_run_status:null});lF(s,n,r)})}}if(o){if(a.sound)try{Cc()}catch(e){d.system.warn(`Alert sound not played`,e)}a.flash&&!i&&window.gaiaAPI&&window.gaiaAPI.notification.flash().catch(e=>d.system.error(`Could not flash the taskbar button`,e))}},[l,a.modes,a.sound,a.flash]);let u=xc(n,c,a.modes,r);(0,J.useEffect)(()=>{window.gaiaAPI?.notification.setAttentionCount(u).catch(e=>d.system.error(`Could not update the taskbar badge`,e))},[u]);let f=a.keepAwake&&e.length>0&&Sc(o,a.batteryFloor);(0,J.useEffect)(()=>{window.gaiaAPI?.power.setKeepAwake(f).catch(e=>d.system.error(`Could not change keep-awake`,e))},[f])}function fF(e){if(e<=0)return`0 B`;let t=1024,n=[`B`,`KB`,`MB`,`GB`],r=Math.min(Math.floor(Math.log(e)/Math.log(t)),n.length-1);return parseFloat((e/t**r).toFixed(1))+` `+n[r]}function pF(e){return e.replace(/-/g,``).slice(0,7)}function mF(e,t){let n=t.replace(/^#/,``).toLowerCase();if(!n||n.length<4)return null;let r=e.find(e=>e.id.replace(/-/g,``).toLowerCase().startsWith(n));return r?r.id:null}function hF(e,t,n){return!e||t&&(e===t||e===pF(t))?null:n.some(t=>t.id===e)?e:mF(n,e)}function gF(e){return new URLSearchParams(e.search).get(`session`)||e.hash.replace(/^#/,``)||null}var _F=`gaia:last-session`;function vF(e){try{e?localStorage.setItem(_F,e):localStorage.removeItem(_F)}catch(e){d.ui.warn(`Could not save the open chat for the next launch`,e)}}function yF(){try{return localStorage.getItem(_F)}catch(e){return d.ui.warn(`Could not read the chat open at last launch`,e),null}}var bF=1e3,xF=3e4;function SF(e,{initialMs:t=bF,maxMs:n=xF,onError:r}={}){let i=t,a=0,o=null,s=!1,c=!1,l=!1,u=()=>{l||c||s||(o&&=(clearTimeout(o),null),s=!0,a+=1,e().then(()=>{c=!0}).catch(e=>{l||(r?.(e,a),o=setTimeout(()=>{o=null,u()},i),i=Math.min(i*2,n))}).finally(()=>{s=!1}))};return u(),{kick:()=>{o&&u()},stop:()=>{l=!0,o&&clearTimeout(o),o=null},done:()=>c}}function CF(e,t,n){return e&&!t&&!n}var wF=(0,J.lazy)(()=>PP(()=>import(`./MemoryDashboard-Evh8x9AG.js`).then(e=>({default:e.MemoryDashboard})),__vite__mapDeps([6,1,2,7,8]),import.meta.url)),TF=(0,J.lazy)(()=>PP(()=>import(`./ScheduleManager-CoagpVqW.js`).then(e=>({default:e.ScheduleManager})),__vite__mapDeps([9,1,2,7,3,10]),import.meta.url)),EF=(0,J.lazy)(()=>PP(()=>import(`./DocumentLibrary-Bxi2x5Ry.js`).then(e=>({default:e.DocumentLibrary})),__vite__mapDeps([11,1,2,3,12]),import.meta.url)),DF=(0,J.lazy)(()=>PP(()=>import(`./FileBrowser-lOETG5oo.js`).then(e=>({default:e.FileBrowser})),__vite__mapDeps([13,1,2,3,14]),import.meta.url)),OF=(0,J.lazy)(()=>PP(()=>import(`./MobileAccessModal-jZP8OcFv.js`).then(e=>({default:e.MobileAccessModal})),__vite__mapDeps([15,1,2,3,16]),import.meta.url)),kF=3,AF=3e5,jF=6e3,MF=6e4,NF=e=>e instanceof TypeError,PF=e=>new Promise(t=>setTimeout(t,e)),FF=3e5,IF=class extends Error{};async function LF(){let e=Date.now()+FF;for(;;){let t=await Ce();if(t.state===`ready`)return;if(t.state===`failed`||t.state===`cancelled`)throw new IF(t.error||I().bare(`setup.upgrading.stopped`));if(Date.now()>=e)throw Error(I().bare(`setup.upgrading.slow`));await PF(bF)}}function RF(){return P(`div`,{className:`loading-spinner`,role:`status`,"aria-label":`Loading`})}var zF=e=>e===1||e%10==0;function BF(){let e=T(),t=k(e=>e.currentSessionId),n=k(e=>e.setSessions),r=k(e=>e.setCurrentSession),i=k(e=>e.addSession),a=k(e=>e.setMessages),o=k(e=>e.showDocLibrary),s=k(e=>e.showFileBrowser),c=k(e=>e.showMemoryDashboard),l=k(e=>e.showSchedules),u=k(e=>e.sidebarOpen),f=k(e=>e.sidebarCollapsed),p=k(e=>e.setSidebarOpen),h=k(e=>e.setSystemStatus),g=k(e=>e.setBackendConnected),_=k(e=>e.setAgents),v=k(e=>e.agents),y=k(e=>e.setPendingPrompt),b=k(e=>e.setDefaultPermissionMode),x=k(e=>e.openSettings),S=k(e=>e.settingsSection),C=k(e=>e.syncSystemTheme),w=cs(e=>e.restoreNotice),E=cs(e=>e.dismissRestoreNotice),D=Qs(e=>e.showPanel),O=k(e=>e.systemStatus?.initialized===!0),A=(0,J.useRef)(!1),j=Qs(e=>e.setShowPanel);(0,J.useEffect)(()=>{if(!w?.ok)return;let e=setTimeout(E,jF);return()=>clearTimeout(e)},[w,E]);let[M,N]=(0,J.useState)({state:`checking`}),F=k(e=>e.setupAgain),I=k(e=>e.runSetupAgain),ee=(0,J.useRef)(M);ee.current=M;let[R,z]=(0,J.useState)(!1),B=(0,J.useRef)(R);B.current=R;let[te,ne]=(0,J.useState)(!1),[re,ie]=(0,J.useState)(!1),ae=te||R&&!sk(v),oe=(0,J.useRef)(ae);oe.current=ae;let[H,se]=(0,J.useState)(null),[W,ce]=(0,J.useState)(``),[le,de]=(0,J.useState)(0),[fe,pe]=(0,J.useState)(!1),[me,he]=(0,J.useState)(!1),[ge,_e]=(0,J.useState)(null),[ve,ye]=(0,J.useState)(null),be=(0,J.useRef)(async()=>{}),xe=(0,J.useRef)(async()=>{}),Se=(0,J.useCallback)(async(e=!1,t=!1)=>{e||N({state:`checking`});let n=0;try{for(;;){await cs.getState().refresh();let e=!!cs.getState().active?.remote,r;try{r=await G(e)}catch(e){if(!t||!NF(e)||n>=MF)throw e;await PF(bF),n+=bF;continue}if(!r.ready&&r.stage===`upgrade`){N({state:`upgrading`});let t=await Ce();(!t.upgrade_embedded||t.state!==`running`&&t.state!==`verifying`)&&await ft(e,!1,{upgradeEmbedded:!0}),await LF(),r=await G(e)}n>0&&await Promise.all([be.current(),xe.current()]),ie(!!r.no_agent_build),N(r.ready?{state:`ready`}:{state:`needed`,check:r});return}}catch(e){let t=e instanceof Error?e.message:String(e);if(e instanceof IF){d.system.warn(`Updating the local model server failed`,e),N({state:`unknown`,error:t,upgradeFailed:!0});return}d.system.warn(`Setup check could not be answered`,e),N({state:`unknown`,error:t})}},[]),we=(0,J.useRef)(0),Te=(0,J.useCallback)(async()=>{let e=++we.current,t=(await _n()).agents||[];e===we.current&&(_(t),z(!0),sk(t)&&ne(!1))},[_]),Ee=(0,J.useCallback)(()=>{let e=B.current;z(!1),Te().catch(t=>{d.api.warn(`Agent list unavailable after setup`,t),e&&z(!0)})},[Te]);(0,J.useEffect)(()=>{let e=()=>{oe.current&&Te().catch(e=>d.api.warn(`Agent list unavailable`,e))};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[Te]);let De=(0,J.useCallback)(async()=>{b((await an()).default_mode)},[b]),Oe=(0,J.useRef)([]);(0,J.useEffect)(()=>{m(`0.26.0rc2`),Se(!1,!0);let e=[SF(Te,{onError:(e,t)=>{zF(t)&&d.api.warn(`Agent list unavailable (attempt ${t}); retrying`,e)}}),SF(De,{onError:(e,t)=>{zF(t)&&d.api.warn(`Default permission mode unavailable (attempt ${t}); retrying`,e)}})];return Oe.current=e,()=>e.forEach(e=>e.stop())},[Se,Te,De]);let ke=(0,J.useCallback)(()=>{Oe.current.forEach(e=>e.kick()),cs.getState().retryNow(),xe.current();let e=ee.current;e.state===`unknown`&&!e.upgradeFailed&&Se(!0)},[Se]),Ae=(0,J.useRef)(ke);Ae.current=ke;let je=(0,J.useRef)(0),Me=(0,J.useRef)(0),Ne=(0,J.useRef)(null),Pe=(0,J.useRef)(!1),[Fe,Ie]=(0,J.useState)(!1),[Le,Re]=(0,J.useState)(null),ze=(0,J.useCallback)(e=>{if(e.kind===`unreachable`){d.system.warn(`System status check failed`,e.error),Pe.current=!0,Me.current=0,Ne.current=null,Ie(!1),Re(null),g(!1),h(null);return}if(e.kind===`error`){d.system.warn(`System status answered HTTP ${e.httpStatus}`,e.message),Pe.current&&Ae.current(),Pe.current=!1,Me.current=0,Ne.current=null,Ie(!1),Re(`HTTP ${e.httpStatus}: ${e.message}`),g(!0);return}if(e.kind===`slow`){if(Me.current+=1,Ne.current??=Date.now(),Re(null),d.system.warn(`System status did not answer in time (${Me.current} in a row)`),Date.now()-Ne.current>=AF){Ie(!1),g(!1),h(null);return}g(!0),(Pe.current||Me.current>=kF)&&Ie(!0);return}let{status:t}=e;Pe.current&&Ae.current(),Pe.current=!1,Me.current=0,Ne.current=null,Ie(!1),Re(null),g(!0),je.current=t.lemonade_running?0:je.current+1;let n=k.getState().systemStatus;t.lemonade_running||je.current>=kF||!n?.lemonade_running?h(t):h({...n,download_progress:t.download_progress})},[g,h]),Be=(0,J.useRef)(ze);Be.current=ze;let[Ve]=(0,J.useState)(()=>Ww(e=>Be.current(e))),He=Ve.check;be.current=He,(0,J.useEffect)(()=>hk(Ve.start),[Ve]),(0,J.useEffect)(()=>BP(()=>{He()}),[He]);let Ue=(0,J.useRef)(``);(0,J.useEffect)(()=>{let e=e=>Ft().then(t=>{let r=t.sessions||[];if(!e&&r.length===0&&k.getState().sessions.length>0)return;let i=r.map(e=>`${e.id}|${e.updated_at}|${e.title}|${e.inference_remote}|${e.inference_provider}|${e.inference_description}|${e.effective_model}|${e.unread}|${e.pinned}|${e.last_run_status}|${e.kind}`).join(`
|
|
82
82
|
`);if(i===Ue.current)return;Ue.current=i,n(r);let a=cs.getState().active?.model;a&&r.some(e=>e.effective_model&&e.effective_model!==a)&&cs.getState().refresh()}).catch(t=>{e&&d.system.error(`Could not load chats`,t)});xe.current=()=>e(!1),e(!0);let t=setInterval(()=>void e(!1),5e3);return()=>clearInterval(t)},[n]),(0,J.useEffect)(()=>rT(),[]),(0,J.useEffect)(()=>{let e=()=>{nF.getState().loadSchedules()};e();let t=setInterval(e,3e4);return()=>clearInterval(t)},[]),(0,J.useEffect)(()=>xT(),[]),dF();let We=(0,J.useRef)(!1),Ge=(0,J.useRef)(!1);(0,J.useEffect)(()=>{let e=()=>{let e=gF(window.location),{currentSessionId:t,sessions:n}=k.getState(),i=hF(e,t,n);return i&&(r(i),a([])),i},t=()=>{if(We.current||(We.current=!0,e()||k.getState().currentSessionId))return;if(window.location.hash){window.history.replaceState(null,``,window.location.pathname+window.location.search);return}if(Ge.current||Mt(`new-chat`))return;let{sessions:t}=k.getState(),n=hF(yF(),null,t);n&&(r(n),a([]))},n=k.subscribe(e=>{e.sessions.length>0&&t()});return k.getState().sessions.length>0&&t(),window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{n(),window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[r,a]),(0,J.useEffect)(()=>{let e=null,t=2e3,n=!1,i=null,o=()=>{n||(e=new EventSource(`${L()}/sessions/events`),e.onopen=()=>{t=2e3},e.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch(e){d.api.warn(`Malformed session event`,e);return}t.type===`set_active_session`&&t.session_id&&t.session_id!==k.getState().currentSessionId&&(r(t.session_id),a([]))},e.onerror=()=>{e?.close(),e=null,!n&&(i=setTimeout(o,t),t=Math.min(t*2,3e4))})};return o(),()=>{n=!0,i&&clearTimeout(i),e?.close()}},[r,a]),(0,J.useEffect)(()=>{if(We.current&&vF(t),t){let e=pF(t);window.location.hash!==`#${e}`&&window.history.replaceState(null,``,`#${e}`)}else We.current&&window.location.hash&&window.history.replaceState(null,``,window.location.pathname+window.location.search)},[t]);let Ke=(0,J.useCallback)(async e=>{if(se(null),!await Go(`chat`))return ce(e),!1;let t=k.getState(),n;try{n=await Tn({title:`New Task`,agent_type:ok,document_ids:t.draftDocumentIds,private:t.draftPrivate,folders:t.draftFolder?[t.draftFolder]:[]})}catch(e){throw ck(e)?(ne(!0),Error(`The GAIA agent isn't installed. Install it from the notice above, then send again.`)):e}oe.current&&(ne(!1),Te().catch(e=>d.api.warn(`Agent list unavailable`,e))),t.defaultPermissionModeKnown||(await De().catch(e=>d.api.warn(`Default permission mode unavailable; using the chip's mode`,e)),t=k.getState()),t.clearDraftDocuments(),t.setDraftPrivate(!1),t.setDraftFolder(null);let o=null;try{await Pt(n.id,t.draftPermissionMode)}catch(e){o=e}return U(_t),o&&!n.private&&bn(qe(n.id),e),i(n),r(n.id),a([]),ce(``),o?(se(`The chat was created, but its permission mode could not be set, so your message was not sent${n.private?``:` — it is in the chat's box`}: ${o instanceof Error?o.message:o}`),!1):(t.resetDraftPermissionMode(),y({sessionId:n.id,text:e}),!0)},[i,r,a,y,Te,De]),Je=(0,J.useCallback)(()=>{let e=k.getState(),t=e.currentSessionId;t&&jc(t,e)&&Mc(t),e.setShowMemoryDashboard(!1),e.setShowSchedules(!1),Ge.current=!0,r(null),a([]),de(e=>e+1)},[r,a]);sF({openChat:(0,J.useCallback)(e=>{let t=k.getState();t.closeSettings(),e!==t.currentSessionId&&(Mc(t.currentSessionId),a([])),r(e)},[r,a]),newChat:(0,J.useCallback)(()=>{k.getState().closeSettings(),Je()},[Je]),refreshStatus:()=>void He()});let Ye=(0,J.useCallback)(e=>{Je(),Ke(`Load the \`${e}\` skill, then tell me briefly what it lets you do.`).catch(e=>se(e instanceof Error?e.message:String(e)))},[Je,Ke]),Xe=(0,J.useCallback)(e=>{N({state:`ready`}),Ee(),He(),e&&(e.needs_input?ce(e.prompt):Ke(e.prompt).catch(e=>se(e instanceof Error?e.message:String(e))))},[He,Ke,Ee]),Ze=(0,J.useCallback)(()=>{N({state:`ready`}),He()},[He]);(0,J.useEffect)(()=>{let e=()=>{k.getState().closeSettings(),N({state:`addingLocal`})};return window.addEventListener(`gaia:set-up-local`,e),()=>window.removeEventListener(`gaia:set-up-local`,e)},[]),(0,J.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&(e.shiftKey&&e.key.toLowerCase()===`o`?(e.preventDefault(),Je()):!e.shiftKey&&e.key.toLowerCase()===`k`?(e.preventDefault(),window.dispatchEvent(new CustomEvent(`gaia:focus-search`))):!e.shiftKey&&e.key.toLowerCase()===`b`?(e.preventDefault(),k.getState().toggleSidebarCollapsed()):!e.shiftKey&&e.key===`,`&&(e.preventDefault(),x()))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Je,x]),(0,J.useEffect)(()=>{let e=window.matchMedia?.(`(max-width: 768px)`);if(!e)return;let t=()=>p(!e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[p]),(0,J.useEffect)(()=>{if(typeof window.matchMedia!=`function`)return;let e=window.matchMedia(`(prefers-color-scheme: light)`);return e.addEventListener(`change`,C),()=>e.removeEventListener(`change`,C)},[C]),(0,J.useEffect)(()=>{xn().then(e=>he(e.active===!0)).catch(e=>d.system.debug(`Mobile access unavailable`,e))},[]);let Qe=(0,J.useCallback)(async()=>{if(pe(!0),_e(null),me)ye(null);else try{let e=await Nn(),t=e.reason===`ngrok_not_installed`;if(ye(t?e.installCommands??[]:null),t)return;e.error?_e(e.error):he(!0)}catch(e){ye(null),_e(e instanceof Error?e.message:`Could not start mobile access`)}},[me]),$e=(0,J.useCallback)(async()=>{try{await ue(),he(!1),pe(!1)}catch(e){_e(e instanceof Error?e.message:`Could not stop mobile access`)}},[]);jD(e=>{e?Qe():$e()}),(0,J.useEffect)(()=>{kD(me)},[me]);let et=typeof window<`u`&&window.innerWidth<=768,tt=CF(M.state===`checking`,O,A.current);if(!tt&&M.state!==`needed`&&(A.current=!0),tt)return P(`div`,{className:`app`,children:V(`main`,{className:`startup`,role:`status`,"aria-label":`Starting GAIA`,children:[P(`div`,{className:`loading-spinner`,"aria-hidden":`true`}),P(`p`,{className:`startup-text`,children:`Starting GAIA…`})]})});if(M.state===`upgrading`)return P(`div`,{className:`app`,children:V(`main`,{className:`startup`,role:`status`,"aria-live":`polite`,"aria-label":e(`setup.upgrading.notice`),children:[P(`div`,{className:`loading-spinner`,"aria-hidden":`true`}),P(`p`,{className:`startup-text`,children:e(`setup.upgrading.notice`)})]})});if(M.state===`needed`||M.state===`addingLocal`||F){let e=F?()=>I(!1):M.state===`addingLocal`?Ze:void 0;return V(`div`,{className:`app`,children:[P(vN,{onReady:e=>{I(!1),Xe(e)},onClose:e}),P(BA,{}),P(KP,{})]})}let nt=c?P(J.Suspense,{fallback:P(RF,{}),children:P(wF,{})}):t?P(Dk,{sessionId:t},t):P(FA,{onSend:Ke,initialText:W,focusRequest:le},W);return V(`div`,{className:`app`,children:[!u&&P(`button`,{className:`sidebar-toggle`,onClick:()=>p(!0),"aria-label":`Open sidebar`,children:P(oa,{size:18})}),P(`div`,{className:`sidebar-overlay ${u?`visible`:``}`,onClick:()=>p(!1),"aria-hidden":`true`}),P(ol,{onNewChat:Je,onMobileAccess:et?void 0:()=>void Qe(),tunnelActive:me}),V(`div`,{className:`main-content`,children:[M.state===`ready`&&P(GP,{onRetry:He,backendSlow:Fe,backendError:Le}),M.state===`unknown`&&(M.upgradeFailed?V(`div`,{className:`app-notice is-warning`,role:`status`,children:[P(`span`,{children:e(`setup.upgrading.failed`,{error:M.error})}),P(`button`,{type:`button`,className:`link-btn`,onClick:()=>void Se(),children:e(`setup.upgrading.retry`)})]}):V(`div`,{className:`app-notice is-warning`,role:`status`,children:[P(`span`,{children:e(`setup.unknown.failed`,{error:M.error})}),P(`button`,{type:`button`,className:`link-btn`,onClick:()=>void Se(),children:e(`setup.unknown.retry`)})]})),(!u||f)&&P(Rs,{placement:`main`}),ae&&P($P,{onInstalled:Te,noBuild:re}),w&&V(`div`,{className:`app-notice${w.ok?``:` is-warning`}`,role:`status`,children:[P(`span`,{children:w.message}),!w.ok&&P(`button`,{type:`button`,className:`link-btn`,onClick:()=>{E(),x(`model`)},children:`Pick a model`}),P(`button`,{type:`button`,className:`app-notice-close`,onClick:E,"aria-label":`Dismiss`,children:P(So,{size:14})})]}),nt]}),l&&P(J.Suspense,{fallback:null,children:P(TF,{})}),o&&P(J.Suspense,{fallback:null,children:P(EF,{})}),s&&P(J.Suspense,{fallback:null,children:P(DF,{onStartChat:Ke})}),D&&P(`div`,{className:`notification-center-popover`,children:P(YP,{onClose:()=>j(!1)})}),fe&&P(J.Suspense,{fallback:null,children:P(OF,{isOpen:fe,onClose:()=>pe(!1),onStop:()=>void $e(),error:ge,setupCommands:ve,onRetry:()=>void Qe()})}),S&&P(RP,{onUseSkill:Ye}),P(BA,{}),P(KP,{}),H&&P(`div`,{className:`toast`,role:`alert`,children:H})]})}var VF=`agent-refresh`,HF={"pre-checks":`engine.stage.preChecks`,"ensure-uv":`engine.stage.ensureUv`,"create-venv":`engine.stage.createVenv`,"install-package":`engine.stage.installPackage`,verify:`engine.stage.verify`,[VF]:`engine.stage.agentRefresh`,start:`engine.stage.start`},UF={disk:`engine.hint.disk`,network:`engine.hint.network`,tls:`engine.hint.tls`,locked:`engine.hint.locked`,daemon:`engine.hint.daemon`};function WF(e,t){if(!e)return t(`engine.stage.neutral`);let n=HF[e];return n?t(n):(console.warn(`[EngineInstallScreen] install stage "${e}" has no label`),t(`engine.stage.neutral`))}function GF(e,t){return e.reason?t(UF[e.reason]):t(e.stage===VF?`engine.hint.agent`:`engine.hint.other`)}function KF(e){return e.reason===`locked`&&e.lockedBy?.length?e.lockedBy:null}function qF(e,t){let n=e.name??String(e.pid),r=e.folder;return e.isGaia?r?t(`engine.locked.gaia`,{name:n,folder:r}):t(`engine.locked.gaiaNoFolder`,{name:n}):r?t(`engine.locked.other`,{name:n,folder:r}):t(`engine.locked.otherNoFolder`,{name:n})}function JF({status:e}){let t=T(),n=WF(e.stage,t);return V(`div`,{className:`engine-progress`,role:`status`,children:[V(`div`,{className:`engine-progress-head`,children:[P(`span`,{children:n}),e.percent!==null&&V(`bdi`,{dir:`ltr`,children:[e.percent,`%`]})]}),P(`progress`,{className:`engine-bar`,"aria-label":n,max:100,value:e.percent??void 0})]})}function YF({error:e,busy:t,notice:n,onRetry:r,onCloseLockers:i,onContinue:a,onRevert:o,onOpenLog:s}){let c=T(),l=KF(e),u=l!==null&&l.every(e=>e.isGaia),d=(l?.length??0)>1;return V(`div`,{className:`engine-failure`,children:[V(`div`,{role:`alert`,children:[l?V(D.Fragment,{children:[l.map(e=>P(`p`,{className:`engine-hint`,children:qF(e,c)},e.pid)),!u&&P(`p`,{className:`engine-hint`,children:c(d?`engine.locked.closeThenMany`:`engine.locked.closeThen`)})]}):P(`p`,{className:`engine-hint`,children:GF(e,c)}),P(`p`,{className:`engine-error`,children:P(`bdi`,{dir:`ltr`,children:e.message})})]}),u&&P(`button`,{type:`button`,className:`btn-primary engine-retry`,disabled:t,onClick:i,autoFocus:!0,children:c(d?`engine.locked.closeMany`:`engine.locked.close`)}),P(`button`,{type:`button`,className:`${u?`btn-secondary`:`btn-primary`} engine-retry`,disabled:t,onClick:r,autoFocus:!u,children:c(`engine.tryAgain`)}),e.stage===VF&&P(`button`,{type:`button`,className:`btn-secondary engine-retry`,disabled:t,onClick:a,children:c(`engine.continueWithout`)}),e.previousVersion&&P(`button`,{type:`button`,className:`btn-secondary engine-retry`,disabled:t,onClick:o,children:c(`update.chip.goBack`,{version:e.previousVersion})}),n&&P(`p`,{className:`engine-error`,role:`alert`,children:P(`bdi`,{dir:`ltr`,children:n})}),V(`details`,{className:`engine-details`,children:[P(`summary`,{children:c(`engine.details`)}),P(`pre`,{className:`engine-log`,dir:`ltr`,children:e.logTail.join(`
|
|
83
83
|
`)}),P(`button`,{type:`button`,className:`btn-secondary`,onClick:s,children:c(`engine.openLog`)})]})]})}function XF(){let e=T(),[t,n]=(0,J.useState)({phase:`running`,stage:null,percent:null,message:``,error:null}),[r,i]=(0,J.useState)(!1),[a,o]=(0,J.useState)(null),s=(0,J.useCallback)(e=>{console.error(`[EngineInstallScreen] the desktop app did not answer`,e),o(e instanceof Error?e.message:String(e))},[]);(0,J.useEffect)(()=>{let e=window.gaiaInstall,t=e.onProgress(n);return e.status().then(n).catch(s),t},[s]);let c=(0,J.useCallback)(()=>{i(!0),o(null),window.gaiaInstall.retry().catch(s).finally(()=>i(!1))},[s]),l=(0,J.useCallback)(()=>{i(!0),o(null),window.gaiaInstall.closeLockingPrograms().catch(s).finally(()=>i(!1))},[s]),u=(0,J.useCallback)(()=>{i(!0),o(null),window.gaiaInstall.continueWithoutAgentUpdate().catch(s).finally(()=>i(!1))},[s]),d=(0,J.useCallback)(()=>{i(!0),o(null),window.gaiaInstall.revert().then(e=>{e||i(!1)}).catch(e=>{s(e),i(!1)})},[s]),f=(0,J.useCallback)(()=>{o(null),window.gaiaInstall.openLogFile().then(e=>{e.ok||o(e.message)}).catch(s)},[s]),{error:p}=t,m=t.phase===`failed`&&p,h=e(m?p.stage===VF?`engine.failed.agentTitle`:`engine.failed.title`:`engine.title`);return P(`div`,{className:`app`,children:P(`main`,{className:`engine`,children:V(`div`,{className:`engine-inner`,children:[P(`h1`,{className:`engine-title`,children:h}),m?P(YF,{error:p,busy:r,notice:a,onRetry:c,onCloseLockers:l,onContinue:u,onRevert:d,onOpenLog:f}):V(D.Fragment,{children:[P(`p`,{className:`engine-lede`,children:e(`engine.lede`)}),P(JF,{status:t}),a&&P(`p`,{className:`engine-error`,role:`alert`,children:P(`bdi`,{dir:`ltr`,children:a})})]})]})})})}function ZF(){return!!window.gaiaInstall&&new URLSearchParams(window.location.search).get(`engine`)===`install`}async function QF(e){if(!e.isProduction||e.protocol!==`https:`&&e.protocol!==`http:`||!e.serviceWorker)return!1;try{return await e.serviceWorker.register(`./sw.js`,{scope:`./`}),!0}catch(e){return console.error(`[pwa] Service worker registration failed, so the UI is not cached for an installed app:`,e),!1}}Vs(),u();var $F=localStorage.getItem(`gaia-chat-theme`);S(x($F===`light`||$F===`dark`?$F:`system`));var eI=k.getState();i(eI.palette,eI.customColors,eI.theme),s(eI.locale),C(),l(),Co.createRoot(document.getElementById(`root`)).render(P(J.StrictMode,{children:ZF()?P(XF,{}):P(BF,{})})),window.addEventListener(`load`,()=>{QF({isProduction:!0,protocol:window.location.protocol,serviceWorker:`serviceWorker`in navigator?navigator.serviceWorker:void 0})});export{Ec as $,Zk as A,Gr as At,iA as B,_r as Bt,qk as C,yi as Ct,hA as D,Zr as Dt,Yk as E,ti as Et,gA as F,Dr as Ft,fA as G,mA as H,pr as Ht,sA as I,Tr as It,kT as J,FT as K,cA as L,Cr as Lt,Uk as M,zr as Mt,Xk as N,Nr as Nt,Gk as O,Yr as Ot,eA as P,jr as Pt,Nc as Q,rA as R,xr as Rt,Jk as S,Ti as St,tA as T,hi as Tt,yA as U,rr as Ut,oA as V,hr as Vt,Qk as W,Yn as Wt,aS as X,jT as Y,Pc as Z,uA as _,fa as _t,JN as a,mo as at,Kk as b,Zi as bt,KN as c,co as ct,VA as d,Ba as dt,ds as et,EA as f,Ra as ft,lA as g,Sa as gt,pA as h,Ea as ht,PP as i,bo as it,dA as j,Ur as jt,Wk as k,qr as kt,bN as l,eo as lt,bA as m,Ma as mt,nF as n,Io as nt,qN as o,fo as ot,vA as p,Pa as pt,LT as q,VP as r,So as rt,GN as s,q as st,fF as t,Go as tt,yN as u,Qa as ut,nA as v,K as vt,$k as w,_i as wt,xA as x,Fi as xt,_A as y,ta as yt,aA as z,yr as zt};
|