@alexberardi/jarvis-admin 0.1.39 → 0.1.41

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.
@@ -15,4 +15,4 @@ Please change the parent <Route path="${_}"> to <Route path="${_==="/"?"*":`${_}
15
15
  `):" "+fg(m[0]):"as no adapter specified";throw new ve("There is no suitable adapter to dispatch the request "+g,"ERR_NOT_SUPPORT")}return d}const Tx={getAdapter:XS,adapters:wd};function Uu(n){if(n.cancelToken&&n.cancelToken.throwIfRequested(),n.signal&&n.signal.aborted)throw new Ns(null,n)}function mg(n){return Uu(n),n.headers=Vt.from(n.headers),n.data=Du.call(n,n.transformRequest),["post","put","patch"].indexOf(n.method)!==-1&&n.headers.setContentType("application/x-www-form-urlencoded",!1),Tx.getAdapter(n.adapter||Ss.adapter,n)(n).then(function(i){return Uu(n),i.data=Du.call(n,n.transformResponse,i),i.headers=Vt.from(i.headers),i},function(i){return Sx(i)||(Uu(n),i&&i.response&&(i.response.data=Du.call(n,n.transformResponse,i.response),i.response.headers=Vt.from(i.response.headers))),Promise.reject(i)})}const Rx="1.13.4",uo={};["object","boolean","number","function","string","symbol"].forEach((n,r)=>{uo[n]=function(i){return typeof i===n||"a"+(r<1?"n ":" ")+n}});const hg={};uo.transitional=function(r,s,i){function d(f,m){return"[Axios v"+Rx+"] Transitional option '"+f+"'"+m+(i?". "+i:"")}return(f,m,g)=>{if(r===!1)throw new ve(d(m," has been removed"+(s?" in "+s:"")),ve.ERR_DEPRECATED);return s&&!hg[m]&&(hg[m]=!0,console.warn(d(m," has been deprecated since v"+s+" and will be removed in the near future"))),r?r(f,m,g):!0}};uo.spelling=function(r){return(s,i)=>(console.warn(`${i} is likely a misspelling of ${r}`),!0)};function FS(n,r,s){if(typeof n!="object")throw new ve("options must be an object",ve.ERR_BAD_OPTION_VALUE);const i=Object.keys(n);let d=i.length;for(;d-- >0;){const f=i[d],m=r[f];if(m){const g=n[f],v=g===void 0||m(g,f,n);if(v!==!0)throw new ve("option "+f+" must be "+v,ve.ERR_BAD_OPTION_VALUE);continue}if(s!==!0)throw new ve("Unknown option "+f,ve.ERR_BAD_OPTION)}}const $i={assertOptions:FS,validators:uo},Aa=$i.validators;let sl=class{constructor(r){this.defaults=r||{},this.interceptors={request:new ag,response:new ag}}async request(r,s){try{return await this._request(r,s)}catch(i){if(i instanceof Error){let d={};Error.captureStackTrace?Error.captureStackTrace(d):d=new Error;const f=d.stack?d.stack.replace(/^.+\n/,""):"";try{i.stack?f&&!String(i.stack).endsWith(f.replace(/^.+\n.+\n/,""))&&(i.stack+=`
16
16
  `+f):i.stack=f}catch{}}throw i}}_request(r,s){typeof r=="string"?(s=s||{},s.url=r):s=r||{},s=cl(this.defaults,s);const{transitional:i,paramsSerializer:d,headers:f}=s;i!==void 0&&$i.assertOptions(i,{silentJSONParsing:Aa.transitional(Aa.boolean),forcedJSONParsing:Aa.transitional(Aa.boolean),clarifyTimeoutError:Aa.transitional(Aa.boolean)},!1),d!=null&&(G.isFunction(d)?s.paramsSerializer={serialize:d}:$i.assertOptions(d,{encode:Aa.function,serialize:Aa.function},!0)),s.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?s.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:s.allowAbsoluteUrls=!0),$i.assertOptions(s,{baseUrl:Aa.spelling("baseURL"),withXsrfToken:Aa.spelling("withXSRFToken")},!0),s.method=(s.method||this.defaults.method||"get").toLowerCase();let m=f&&G.merge(f.common,f[s.method]);f&&G.forEach(["delete","get","head","post","put","patch","common"],N=>{delete f[N]}),s.headers=Vt.concat(m,f);const g=[];let v=!0;this.interceptors.request.forEach(function(j){typeof j.runWhen=="function"&&j.runWhen(s)===!1||(v=v&&j.synchronous,g.unshift(j.fulfilled,j.rejected))});const x=[];this.interceptors.response.forEach(function(j){x.push(j.fulfilled,j.rejected)});let y,p=0,w;if(!v){const N=[mg.bind(this),void 0];for(N.unshift(...g),N.push(...x),w=N.length,y=Promise.resolve(s);p<w;)y=y.then(N[p++],N[p++]);return y}w=g.length;let M=s;for(;p<w;){const N=g[p++],j=g[p++];try{M=N(M)}catch(R){j.call(this,R);break}}try{y=mg.call(this,M)}catch(N){return Promise.reject(N)}for(p=0,w=x.length;p<w;)y=y.then(x[p++],x[p++]);return y}getUri(r){r=cl(this.defaults,r);const s=wx(r.baseURL,r.url,r.allowAbsoluteUrls);return vx(s,r.params,r.paramsSerializer)}};G.forEach(["delete","get","head","options"],function(r){sl.prototype[r]=function(s,i){return this.request(cl(i||{},{method:r,url:s,data:(i||{}).data}))}});G.forEach(["post","put","patch"],function(r){function s(i){return function(f,m,g){return this.request(cl(g||{},{method:r,headers:i?{"Content-Type":"multipart/form-data"}:{},url:f,data:m}))}}sl.prototype[r]=s(),sl.prototype[r+"Form"]=s(!0)});let KS=class Cx{constructor(r){if(typeof r!="function")throw new TypeError("executor must be a function.");let s;this.promise=new Promise(function(f){s=f});const i=this;this.promise.then(d=>{if(!i._listeners)return;let f=i._listeners.length;for(;f-- >0;)i._listeners[f](d);i._listeners=null}),this.promise.then=d=>{let f;const m=new Promise(g=>{i.subscribe(g),f=g}).then(d);return m.cancel=function(){i.unsubscribe(f)},m},r(function(f,m,g){i.reason||(i.reason=new Ns(f,m,g),s(i.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(r){if(this.reason){r(this.reason);return}this._listeners?this._listeners.push(r):this._listeners=[r]}unsubscribe(r){if(!this._listeners)return;const s=this._listeners.indexOf(r);s!==-1&&this._listeners.splice(s,1)}toAbortSignal(){const r=new AbortController,s=i=>{r.abort(i)};return this.subscribe(s),r.signal.unsubscribe=()=>this.unsubscribe(s),r.signal}static source(){let r;return{token:new Cx(function(d){r=d}),cancel:r}}};function ZS(n){return function(s){return n.apply(null,s)}}function JS(n){return G.isObject(n)&&n.isAxiosError===!0}const ad={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(ad).forEach(([n,r])=>{ad[r]=n});function _x(n){const r=new sl(n),s=ix(sl.prototype.request,r);return G.extend(s,sl.prototype,r,{allOwnKeys:!0}),G.extend(s,r,null,{allOwnKeys:!0}),s.create=function(d){return _x(cl(n,d))},s}const nt=_x(Ss);nt.Axios=sl;nt.CanceledError=Ns;nt.CancelToken=KS;nt.isCancel=Sx;nt.VERSION=Rx;nt.toFormData=co;nt.AxiosError=ve;nt.Cancel=nt.CanceledError;nt.all=function(r){return Promise.all(r)};nt.spread=ZS;nt.isAxiosError=JS;nt.mergeConfig=cl;nt.AxiosHeaders=Vt;nt.formToJSON=n=>bx(G.isHTMLForm(n)?new FormData(n):n);nt.getAdapter=Tx.getAdapter;nt.HttpStatusCode=ad;nt.default=nt;const{Axios:KE,AxiosError:ZE,CanceledError:JE,isCancel:$E,CancelToken:PE,VERSION:IE,all:WE,Cancel:e4,isAxiosError:t4,spread:a4,toFormData:n4,AxiosHeaders:l4,HttpStatusCode:r4,formToJSON:s4,getAdapter:i4,mergeConfig:o4}=nt,Ce=nt.create({baseURL:""});function tr(n){n?Ce.defaults.headers.common.Authorization=`Bearer ${n}`:delete Ce.defaults.headers.common.Authorization}let nd=null;function $S(n){nd=n}let Mx=null;function PS(n){Mx=n}Ce.interceptors.request.use(n=>{if(!n.headers.Authorization){const r=localStorage.getItem("jarvis-admin:access_token")??localStorage.getItem("access_token");r&&(n.headers.Authorization=`Bearer ${r}`)}return n});Ce.interceptors.response.use(n=>n,async n=>{const r=n.config;if(r.url?.startsWith("/api/auth/"))return Promise.reject(n);if(n.response?.status===401&&!r._retry&&nd){r._retry=!0;const s=await nd();if(s)return r.headers.Authorization=`Bearer ${s}`,Ce(r);Mx?.()}return Promise.reject(n)});async function IS(){const{data:n}=await Ce.get("/api/auth/setup-status");return n}async function Ax(n,r,s){const{data:i}=await Ce.post("/api/auth/setup",{email:n,password:r,username:s});return i}async function WS(n,r){const{data:s}=await Ce.post("/api/auth/login",{email:n,password:r});return s}async function eN(n){const{data:r}=await Ce.post("/api/auth/refresh",{refresh_token:n});return r}const Ox=S.createContext(void 0),us="jarvis-admin:access_token",Wl="jarvis-admin:refresh_token",Gi="jarvis-admin:user",tN=600*1e3;function aN({children:n}){const[r,s]=S.useState(()=>{const v=localStorage.getItem(us),x=localStorage.getItem(Wl),y=localStorage.getItem(Gi);if(v&&x&&y)try{const p=JSON.parse(y);return tr(v),{user:p,accessToken:v,refreshToken:x,isAuthenticated:!0,isLoading:!1,error:null}}catch{}return{user:null,accessToken:null,refreshToken:null,isAuthenticated:!1,isLoading:!1,error:null}}),i=S.useCallback(()=>{localStorage.removeItem(us),localStorage.removeItem(Wl),localStorage.removeItem(Gi),tr(null),s({user:null,accessToken:null,refreshToken:null,isAuthenticated:!1,isLoading:!1,error:null})},[]),d=S.useCallback(async()=>{const v=localStorage.getItem(Wl);if(!v)return null;try{const x=await eN(v),y=x.access_token,p=x.refresh_token??v;return localStorage.setItem(us,y),localStorage.setItem(Wl,p),tr(y),s(w=>({...w,accessToken:y,refreshToken:p})),y}catch{return i(),null}},[i]);S.useEffect(()=>{$S(d),PS(i)},[d,i]),S.useEffect(()=>{if(!r.isAuthenticated)return;const v=setInterval(()=>{d()},tN);return()=>clearInterval(v)},[r.isAuthenticated,d]);const f=S.useCallback(async(v,x)=>{s(y=>({...y,error:null,isLoading:!0}));try{const y=await WS(v,x);if(!y.user.is_superuser){s(p=>({...p,isLoading:!1,error:"Admin access required. This account is not a superuser."}));return}localStorage.setItem(us,y.access_token),localStorage.setItem(Wl,y.refresh_token),localStorage.setItem(Gi,JSON.stringify(y.user)),tr(y.access_token),s({user:y.user,accessToken:y.access_token,refreshToken:y.refresh_token,isAuthenticated:!0,isLoading:!1,error:null})}catch(y){const p=y?.response?.data?.detail??"Login failed";s(w=>({...w,isLoading:!1,error:p}))}},[]),m=S.useCallback(async(v,x,y)=>{s(p=>({...p,error:null,isLoading:!0}));try{const p=await Ax(v,x,y);localStorage.setItem(us,p.access_token),localStorage.setItem(Wl,p.refresh_token),localStorage.setItem(Gi,JSON.stringify(p.user)),tr(p.access_token),s({user:p.user,accessToken:p.access_token,refreshToken:p.refresh_token,isAuthenticated:!0,isLoading:!1,error:null})}catch(p){const w=p?.response?.data?.detail??"Setup failed";s(M=>({...M,isLoading:!1,error:w}))}},[]),g=S.useMemo(()=>({state:r,login:f,setup:m,logout:i}),[r,f,m,i]);return c.jsx(Ox.Provider,{value:g,children:n})}function jd(){const n=S.useContext(Ox);if(!n)throw new Error("useAuth must be used within AuthProvider");return n}const zx=(...n)=>n.filter((r,s,i)=>!!r&&r.trim()!==""&&i.indexOf(r)===s).join(" ").trim();const nN=n=>n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const lN=n=>n.replace(/^([A-Z])|[\s-_]+(\w)/g,(r,s,i)=>i?i.toUpperCase():s.toLowerCase());const pg=n=>{const r=lN(n);return r.charAt(0).toUpperCase()+r.slice(1)};var rN={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const sN=n=>{for(const r in n)if(r.startsWith("aria-")||r==="role"||r==="title")return!0;return!1};const iN=S.forwardRef(({color:n="currentColor",size:r=24,strokeWidth:s=2,absoluteStrokeWidth:i,className:d="",children:f,iconNode:m,...g},v)=>S.createElement("svg",{ref:v,...rN,width:r,height:r,stroke:n,strokeWidth:i?Number(s)*24/Number(r):s,className:zx("lucide",d),...!f&&!sN(g)&&{"aria-hidden":"true"},...g},[...m.map(([x,y])=>S.createElement(x,y)),...Array.isArray(f)?f:[f]]));const Ne=(n,r)=>{const s=S.forwardRef(({className:i,...d},f)=>S.createElement(iN,{ref:f,iconNode:r,className:zx(`lucide-${nN(pg(n))}`,`lucide-${n}`,i),...d}));return s.displayName=pg(n),s};const oN=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],cN=Ne("box",oN);const uN=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],ld=Ne("brain",uN);const dN=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Ed=Ne("check",dN);const fN=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Td=Ne("chevron-down",fN);const mN=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],kx=Ne("chevron-right",mN);const hN=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],Dx=Ne("circle-alert",hN);const pN=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]],Ux=Ne("circle-arrow-up",pN);const gN=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],xN=Ne("circle-check-big",gN);const vN=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],bt=Ne("circle-check",vN);const yN=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],Pi=Ne("circle-x",yN);const bN=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],lr=Ne("circle",bN);const SN=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Lx=Ne("copy",SN);const NN=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],ps=Ne("cpu",NN);const wN=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],jN=Ne("database",wN);const EN=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],fs=Ne("download",EN);const TN=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],RN=Ne("external-link",TN);const CN=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],_N=Ne("file-text",CN);const MN=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]],Bx=Ne("git-merge",MN);const AN=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],ON=Ne("globe",AN);const zN=[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]],Rd=Ne("hard-drive",zN);const kN=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],DN=Ne("info",kN);const UN=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],LN=Ne("key",UN);const BN=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],HN=Ne("layout-dashboard",BN);const qN=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],ua=Ne("loader-circle",qN);const GN=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],Cd=Ne("lock",GN);const QN=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],VN=Ne("log-out",QN);const YN=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],XN=Ne("monitor",YN);const FN=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],KN=Ne("moon",FN);const ZN=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],JN=Ne("pencil",ZN);const $N=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],PN=Ne("play",$N);const IN=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],WN=Ne("plus",IN);const ew=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],da=Ne("refresh-cw",ew);const tw=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],fo=Ne("rotate-ccw",tw);const aw=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],Hx=Ne("rotate-cw",aw);const nw=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],lw=Ne("search",nw);const rw=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],_d=Ne("server",rw);const sw=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],qx=Ne("settings",sw);const iw=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],ow=Ne("sparkles",iw);const cw=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],uw=Ne("sun",cw);const dw=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],Gx=Ne("trash-2",dw);const fw=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],fa=Ne("triangle-alert",fw);const mw=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Qx=Ne("x",mw);const hw=[["path",{d:"M10.513 4.856 13.12 2.17a.5.5 0 0 1 .86.46l-1.377 4.317",key:"193nxd"}],["path",{d:"M15.656 10H20a1 1 0 0 1 .78 1.63l-1.72 1.773",key:"27a7lr"}],["path",{d:"M16.273 16.273 10.88 21.83a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14H4a1 1 0 0 1-.78-1.63l4.507-4.643",key:"1e0qe9"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],pw=Ne("zap-off",hw);const gw=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],xw=Ne("zap",gw);function Vx(n){var r,s,i="";if(typeof n=="string"||typeof n=="number")i+=n;else if(typeof n=="object")if(Array.isArray(n)){var d=n.length;for(r=0;r<d;r++)n[r]&&(s=Vx(n[r]))&&(i&&(i+=" "),i+=s)}else for(s in n)n[s]&&(i&&(i+=" "),i+=s);return i}function vw(){for(var n,r,s=0,i="",d=arguments.length;s<d;s++)(n=arguments[s])&&(r=Vx(n))&&(i&&(i+=" "),i+=r);return i}const yw=(n,r)=>{const s=new Array(n.length+r.length);for(let i=0;i<n.length;i++)s[i]=n[i];for(let i=0;i<r.length;i++)s[n.length+i]=r[i];return s},bw=(n,r)=>({classGroupId:n,validator:r}),Yx=(n=new Map,r=null,s)=>({nextPart:n,validators:r,classGroupId:s}),no="-",gg=[],Sw="arbitrary..",Nw=n=>{const r=jw(n),{conflictingClassGroups:s,conflictingClassGroupModifiers:i}=n;return{getClassGroupId:m=>{if(m.startsWith("[")&&m.endsWith("]"))return ww(m);const g=m.split(no),v=g[0]===""&&g.length>1?1:0;return Xx(g,v,r)},getConflictingClassGroupIds:(m,g)=>{if(g){const v=i[m],x=s[m];return v?x?yw(x,v):v:x||gg}return s[m]||gg}}},Xx=(n,r,s)=>{if(n.length-r===0)return s.classGroupId;const d=n[r],f=s.nextPart.get(d);if(f){const x=Xx(n,r+1,f);if(x)return x}const m=s.validators;if(m===null)return;const g=r===0?n.join(no):n.slice(r).join(no),v=m.length;for(let x=0;x<v;x++){const y=m[x];if(y.validator(g))return y.classGroupId}},ww=n=>n.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const r=n.slice(1,-1),s=r.indexOf(":"),i=r.slice(0,s);return i?Sw+i:void 0})(),jw=n=>{const{theme:r,classGroups:s}=n;return Ew(s,r)},Ew=(n,r)=>{const s=Yx();for(const i in n){const d=n[i];Md(d,s,i,r)}return s},Md=(n,r,s,i)=>{const d=n.length;for(let f=0;f<d;f++){const m=n[f];Tw(m,r,s,i)}},Tw=(n,r,s,i)=>{if(typeof n=="string"){Rw(n,r,s);return}if(typeof n=="function"){Cw(n,r,s,i);return}_w(n,r,s,i)},Rw=(n,r,s)=>{const i=n===""?r:Fx(r,n);i.classGroupId=s},Cw=(n,r,s,i)=>{if(Mw(n)){Md(n(i),r,s,i);return}r.validators===null&&(r.validators=[]),r.validators.push(bw(s,n))},_w=(n,r,s,i)=>{const d=Object.entries(n),f=d.length;for(let m=0;m<f;m++){const[g,v]=d[m];Md(v,Fx(r,g),s,i)}},Fx=(n,r)=>{let s=n;const i=r.split(no),d=i.length;for(let f=0;f<d;f++){const m=i[f];let g=s.nextPart.get(m);g||(g=Yx(),s.nextPart.set(m,g)),s=g}return s},Mw=n=>"isThemeGetter"in n&&n.isThemeGetter===!0,Aw=n=>{if(n<1)return{get:()=>{},set:()=>{}};let r=0,s=Object.create(null),i=Object.create(null);const d=(f,m)=>{s[f]=m,r++,r>n&&(r=0,i=s,s=Object.create(null))};return{get(f){let m=s[f];if(m!==void 0)return m;if((m=i[f])!==void 0)return d(f,m),m},set(f,m){f in s?s[f]=m:d(f,m)}}},rd="!",xg=":",Ow=[],vg=(n,r,s,i,d)=>({modifiers:n,hasImportantModifier:r,baseClassName:s,maybePostfixModifierPosition:i,isExternal:d}),zw=n=>{const{prefix:r,experimentalParseClassName:s}=n;let i=d=>{const f=[];let m=0,g=0,v=0,x;const y=d.length;for(let j=0;j<y;j++){const R=d[j];if(m===0&&g===0){if(R===xg){f.push(d.slice(v,j)),v=j+1;continue}if(R==="/"){x=j;continue}}R==="["?m++:R==="]"?m--:R==="("?g++:R===")"&&g--}const p=f.length===0?d:d.slice(v);let w=p,M=!1;p.endsWith(rd)?(w=p.slice(0,-1),M=!0):p.startsWith(rd)&&(w=p.slice(1),M=!0);const N=x&&x>v?x-v:void 0;return vg(f,M,w,N)};if(r){const d=r+xg,f=i;i=m=>m.startsWith(d)?f(m.slice(d.length)):vg(Ow,!1,m,void 0,!0)}if(s){const d=i;i=f=>s({className:f,parseClassName:d})}return i},kw=n=>{const r=new Map;return n.orderSensitiveModifiers.forEach((s,i)=>{r.set(s,1e6+i)}),s=>{const i=[];let d=[];for(let f=0;f<s.length;f++){const m=s[f],g=m[0]==="[",v=r.has(m);g||v?(d.length>0&&(d.sort(),i.push(...d),d=[]),i.push(m)):d.push(m)}return d.length>0&&(d.sort(),i.push(...d)),i}},Dw=n=>({cache:Aw(n.cacheSize),parseClassName:zw(n),sortModifiers:kw(n),...Nw(n)}),Uw=/\s+/,Lw=(n,r)=>{const{parseClassName:s,getClassGroupId:i,getConflictingClassGroupIds:d,sortModifiers:f}=r,m=[],g=n.trim().split(Uw);let v="";for(let x=g.length-1;x>=0;x-=1){const y=g[x],{isExternal:p,modifiers:w,hasImportantModifier:M,baseClassName:N,maybePostfixModifierPosition:j}=s(y);if(p){v=y+(v.length>0?" "+v:v);continue}let R=!!j,k=i(R?N.substring(0,j):N);if(!k){if(!R){v=y+(v.length>0?" "+v:v);continue}if(k=i(N),!k){v=y+(v.length>0?" "+v:v);continue}R=!1}const _=w.length===0?"":w.length===1?w[0]:f(w).join(":"),B=M?_+rd:_,O=B+k;if(m.indexOf(O)>-1)continue;m.push(O);const P=d(k,R);for(let I=0;I<P.length;++I){const ee=P[I];m.push(B+ee)}v=y+(v.length>0?" "+v:v)}return v},Bw=(...n)=>{let r=0,s,i,d="";for(;r<n.length;)(s=n[r++])&&(i=Kx(s))&&(d&&(d+=" "),d+=i);return d},Kx=n=>{if(typeof n=="string")return n;let r,s="";for(let i=0;i<n.length;i++)n[i]&&(r=Kx(n[i]))&&(s&&(s+=" "),s+=r);return s},Hw=(n,...r)=>{let s,i,d,f;const m=v=>{const x=r.reduce((y,p)=>p(y),n());return s=Dw(x),i=s.cache.get,d=s.cache.set,f=g,g(v)},g=v=>{const x=i(v);if(x)return x;const y=Lw(v,s);return d(v,y),y};return f=m,(...v)=>f(Bw(...v))},qw=[],ut=n=>{const r=s=>s[n]||qw;return r.isThemeGetter=!0,r},Zx=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Jx=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Gw=/^\d+\/\d+$/,Qw=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Vw=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Yw=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Xw=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Fw=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,er=n=>Gw.test(n),Te=n=>!!n&&!Number.isNaN(Number(n)),Mn=n=>!!n&&Number.isInteger(Number(n)),Lu=n=>n.endsWith("%")&&Te(n.slice(0,-1)),Ia=n=>Qw.test(n),Kw=()=>!0,Zw=n=>Vw.test(n)&&!Yw.test(n),$x=()=>!1,Jw=n=>Xw.test(n),$w=n=>Fw.test(n),Pw=n=>!ce(n)&&!ue(n),Iw=n=>ur(n,Wx,$x),ce=n=>Zx.test(n),nl=n=>ur(n,ev,Zw),Bu=n=>ur(n,nj,Te),yg=n=>ur(n,Px,$x),Ww=n=>ur(n,Ix,$w),Qi=n=>ur(n,tv,Jw),ue=n=>Jx.test(n),ds=n=>dr(n,ev),ej=n=>dr(n,lj),bg=n=>dr(n,Px),tj=n=>dr(n,Wx),aj=n=>dr(n,Ix),Vi=n=>dr(n,tv,!0),ur=(n,r,s)=>{const i=Zx.exec(n);return i?i[1]?r(i[1]):s(i[2]):!1},dr=(n,r,s=!1)=>{const i=Jx.exec(n);return i?i[1]?r(i[1]):s:!1},Px=n=>n==="position"||n==="percentage",Ix=n=>n==="image"||n==="url",Wx=n=>n==="length"||n==="size"||n==="bg-size",ev=n=>n==="length",nj=n=>n==="number",lj=n=>n==="family-name",tv=n=>n==="shadow",rj=()=>{const n=ut("color"),r=ut("font"),s=ut("text"),i=ut("font-weight"),d=ut("tracking"),f=ut("leading"),m=ut("breakpoint"),g=ut("container"),v=ut("spacing"),x=ut("radius"),y=ut("shadow"),p=ut("inset-shadow"),w=ut("text-shadow"),M=ut("drop-shadow"),N=ut("blur"),j=ut("perspective"),R=ut("aspect"),k=ut("ease"),_=ut("animate"),B=()=>["auto","avoid","all","avoid-page","page","left","right","column"],O=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],P=()=>[...O(),ue,ce],I=()=>["auto","hidden","clip","visible","scroll"],ee=()=>["auto","contain","none"],$=()=>[ue,ce,v],W=()=>[er,"full","auto",...$()],re=()=>[Mn,"none","subgrid",ue,ce],se=()=>["auto",{span:["full",Mn,ue,ce]},Mn,ue,ce],ie=()=>[Mn,"auto",ue,ce],Ae=()=>["auto","min","max","fr",ue,ce],De=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],Be=()=>["start","end","center","stretch","center-safe","end-safe"],z=()=>["auto",...$()],Z=()=>[er,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...$()],F=()=>[n,ue,ce],xe=()=>[...O(),bg,yg,{position:[ue,ce]}],ge=()=>["no-repeat",{repeat:["","x","y","space","round"]}],T=()=>["auto","cover","contain",tj,Iw,{size:[ue,ce]}],Q=()=>[Lu,ds,nl],V=()=>["","none","full",x,ue,ce],J=()=>["",Te,ds,nl],le=()=>["solid","dashed","dotted","double"],me=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],fe=()=>[Te,Lu,bg,yg],be=()=>["","none",N,ue,ce],H=()=>["none",Te,ue,ce],te=()=>["none",Te,ue,ce],Ee=()=>[Te,ue,ce],Re=()=>[er,"full",...$()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Ia],breakpoint:[Ia],color:[Kw],container:[Ia],"drop-shadow":[Ia],ease:["in","out","in-out"],font:[Pw],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Ia],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Ia],shadow:[Ia],spacing:["px",Te],text:[Ia],"text-shadow":[Ia],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",er,ce,ue,R]}],container:["container"],columns:[{columns:[Te,ce,ue,g]}],"break-after":[{"break-after":B()}],"break-before":[{"break-before":B()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:P()}],overflow:[{overflow:I()}],"overflow-x":[{"overflow-x":I()}],"overflow-y":[{"overflow-y":I()}],overscroll:[{overscroll:ee()}],"overscroll-x":[{"overscroll-x":ee()}],"overscroll-y":[{"overscroll-y":ee()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:W()}],"inset-x":[{"inset-x":W()}],"inset-y":[{"inset-y":W()}],start:[{start:W()}],end:[{end:W()}],top:[{top:W()}],right:[{right:W()}],bottom:[{bottom:W()}],left:[{left:W()}],visibility:["visible","invisible","collapse"],z:[{z:[Mn,"auto",ue,ce]}],basis:[{basis:[er,"full","auto",g,...$()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Te,er,"auto","initial","none",ce]}],grow:[{grow:["",Te,ue,ce]}],shrink:[{shrink:["",Te,ue,ce]}],order:[{order:[Mn,"first","last","none",ue,ce]}],"grid-cols":[{"grid-cols":re()}],"col-start-end":[{col:se()}],"col-start":[{"col-start":ie()}],"col-end":[{"col-end":ie()}],"grid-rows":[{"grid-rows":re()}],"row-start-end":[{row:se()}],"row-start":[{"row-start":ie()}],"row-end":[{"row-end":ie()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":Ae()}],"auto-rows":[{"auto-rows":Ae()}],gap:[{gap:$()}],"gap-x":[{"gap-x":$()}],"gap-y":[{"gap-y":$()}],"justify-content":[{justify:[...De(),"normal"]}],"justify-items":[{"justify-items":[...Be(),"normal"]}],"justify-self":[{"justify-self":["auto",...Be()]}],"align-content":[{content:["normal",...De()]}],"align-items":[{items:[...Be(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...Be(),{baseline:["","last"]}]}],"place-content":[{"place-content":De()}],"place-items":[{"place-items":[...Be(),"baseline"]}],"place-self":[{"place-self":["auto",...Be()]}],p:[{p:$()}],px:[{px:$()}],py:[{py:$()}],ps:[{ps:$()}],pe:[{pe:$()}],pt:[{pt:$()}],pr:[{pr:$()}],pb:[{pb:$()}],pl:[{pl:$()}],m:[{m:z()}],mx:[{mx:z()}],my:[{my:z()}],ms:[{ms:z()}],me:[{me:z()}],mt:[{mt:z()}],mr:[{mr:z()}],mb:[{mb:z()}],ml:[{ml:z()}],"space-x":[{"space-x":$()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":$()}],"space-y-reverse":["space-y-reverse"],size:[{size:Z()}],w:[{w:[g,"screen",...Z()]}],"min-w":[{"min-w":[g,"screen","none",...Z()]}],"max-w":[{"max-w":[g,"screen","none","prose",{screen:[m]},...Z()]}],h:[{h:["screen","lh",...Z()]}],"min-h":[{"min-h":["screen","lh","none",...Z()]}],"max-h":[{"max-h":["screen","lh",...Z()]}],"font-size":[{text:["base",s,ds,nl]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[i,ue,Bu]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Lu,ce]}],"font-family":[{font:[ej,ce,r]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[d,ue,ce]}],"line-clamp":[{"line-clamp":[Te,"none",ue,Bu]}],leading:[{leading:[f,...$()]}],"list-image":[{"list-image":["none",ue,ce]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",ue,ce]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:F()}],"text-color":[{text:F()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...le(),"wavy"]}],"text-decoration-thickness":[{decoration:[Te,"from-font","auto",ue,nl]}],"text-decoration-color":[{decoration:F()}],"underline-offset":[{"underline-offset":[Te,"auto",ue,ce]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:$()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ue,ce]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",ue,ce]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:xe()}],"bg-repeat":[{bg:ge()}],"bg-size":[{bg:T()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Mn,ue,ce],radial:["",ue,ce],conic:[Mn,ue,ce]},aj,Ww]}],"bg-color":[{bg:F()}],"gradient-from-pos":[{from:Q()}],"gradient-via-pos":[{via:Q()}],"gradient-to-pos":[{to:Q()}],"gradient-from":[{from:F()}],"gradient-via":[{via:F()}],"gradient-to":[{to:F()}],rounded:[{rounded:V()}],"rounded-s":[{"rounded-s":V()}],"rounded-e":[{"rounded-e":V()}],"rounded-t":[{"rounded-t":V()}],"rounded-r":[{"rounded-r":V()}],"rounded-b":[{"rounded-b":V()}],"rounded-l":[{"rounded-l":V()}],"rounded-ss":[{"rounded-ss":V()}],"rounded-se":[{"rounded-se":V()}],"rounded-ee":[{"rounded-ee":V()}],"rounded-es":[{"rounded-es":V()}],"rounded-tl":[{"rounded-tl":V()}],"rounded-tr":[{"rounded-tr":V()}],"rounded-br":[{"rounded-br":V()}],"rounded-bl":[{"rounded-bl":V()}],"border-w":[{border:J()}],"border-w-x":[{"border-x":J()}],"border-w-y":[{"border-y":J()}],"border-w-s":[{"border-s":J()}],"border-w-e":[{"border-e":J()}],"border-w-t":[{"border-t":J()}],"border-w-r":[{"border-r":J()}],"border-w-b":[{"border-b":J()}],"border-w-l":[{"border-l":J()}],"divide-x":[{"divide-x":J()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":J()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...le(),"hidden","none"]}],"divide-style":[{divide:[...le(),"hidden","none"]}],"border-color":[{border:F()}],"border-color-x":[{"border-x":F()}],"border-color-y":[{"border-y":F()}],"border-color-s":[{"border-s":F()}],"border-color-e":[{"border-e":F()}],"border-color-t":[{"border-t":F()}],"border-color-r":[{"border-r":F()}],"border-color-b":[{"border-b":F()}],"border-color-l":[{"border-l":F()}],"divide-color":[{divide:F()}],"outline-style":[{outline:[...le(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Te,ue,ce]}],"outline-w":[{outline:["",Te,ds,nl]}],"outline-color":[{outline:F()}],shadow:[{shadow:["","none",y,Vi,Qi]}],"shadow-color":[{shadow:F()}],"inset-shadow":[{"inset-shadow":["none",p,Vi,Qi]}],"inset-shadow-color":[{"inset-shadow":F()}],"ring-w":[{ring:J()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:F()}],"ring-offset-w":[{"ring-offset":[Te,nl]}],"ring-offset-color":[{"ring-offset":F()}],"inset-ring-w":[{"inset-ring":J()}],"inset-ring-color":[{"inset-ring":F()}],"text-shadow":[{"text-shadow":["none",w,Vi,Qi]}],"text-shadow-color":[{"text-shadow":F()}],opacity:[{opacity:[Te,ue,ce]}],"mix-blend":[{"mix-blend":[...me(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":me()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Te]}],"mask-image-linear-from-pos":[{"mask-linear-from":fe()}],"mask-image-linear-to-pos":[{"mask-linear-to":fe()}],"mask-image-linear-from-color":[{"mask-linear-from":F()}],"mask-image-linear-to-color":[{"mask-linear-to":F()}],"mask-image-t-from-pos":[{"mask-t-from":fe()}],"mask-image-t-to-pos":[{"mask-t-to":fe()}],"mask-image-t-from-color":[{"mask-t-from":F()}],"mask-image-t-to-color":[{"mask-t-to":F()}],"mask-image-r-from-pos":[{"mask-r-from":fe()}],"mask-image-r-to-pos":[{"mask-r-to":fe()}],"mask-image-r-from-color":[{"mask-r-from":F()}],"mask-image-r-to-color":[{"mask-r-to":F()}],"mask-image-b-from-pos":[{"mask-b-from":fe()}],"mask-image-b-to-pos":[{"mask-b-to":fe()}],"mask-image-b-from-color":[{"mask-b-from":F()}],"mask-image-b-to-color":[{"mask-b-to":F()}],"mask-image-l-from-pos":[{"mask-l-from":fe()}],"mask-image-l-to-pos":[{"mask-l-to":fe()}],"mask-image-l-from-color":[{"mask-l-from":F()}],"mask-image-l-to-color":[{"mask-l-to":F()}],"mask-image-x-from-pos":[{"mask-x-from":fe()}],"mask-image-x-to-pos":[{"mask-x-to":fe()}],"mask-image-x-from-color":[{"mask-x-from":F()}],"mask-image-x-to-color":[{"mask-x-to":F()}],"mask-image-y-from-pos":[{"mask-y-from":fe()}],"mask-image-y-to-pos":[{"mask-y-to":fe()}],"mask-image-y-from-color":[{"mask-y-from":F()}],"mask-image-y-to-color":[{"mask-y-to":F()}],"mask-image-radial":[{"mask-radial":[ue,ce]}],"mask-image-radial-from-pos":[{"mask-radial-from":fe()}],"mask-image-radial-to-pos":[{"mask-radial-to":fe()}],"mask-image-radial-from-color":[{"mask-radial-from":F()}],"mask-image-radial-to-color":[{"mask-radial-to":F()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":O()}],"mask-image-conic-pos":[{"mask-conic":[Te]}],"mask-image-conic-from-pos":[{"mask-conic-from":fe()}],"mask-image-conic-to-pos":[{"mask-conic-to":fe()}],"mask-image-conic-from-color":[{"mask-conic-from":F()}],"mask-image-conic-to-color":[{"mask-conic-to":F()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:xe()}],"mask-repeat":[{mask:ge()}],"mask-size":[{mask:T()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",ue,ce]}],filter:[{filter:["","none",ue,ce]}],blur:[{blur:be()}],brightness:[{brightness:[Te,ue,ce]}],contrast:[{contrast:[Te,ue,ce]}],"drop-shadow":[{"drop-shadow":["","none",M,Vi,Qi]}],"drop-shadow-color":[{"drop-shadow":F()}],grayscale:[{grayscale:["",Te,ue,ce]}],"hue-rotate":[{"hue-rotate":[Te,ue,ce]}],invert:[{invert:["",Te,ue,ce]}],saturate:[{saturate:[Te,ue,ce]}],sepia:[{sepia:["",Te,ue,ce]}],"backdrop-filter":[{"backdrop-filter":["","none",ue,ce]}],"backdrop-blur":[{"backdrop-blur":be()}],"backdrop-brightness":[{"backdrop-brightness":[Te,ue,ce]}],"backdrop-contrast":[{"backdrop-contrast":[Te,ue,ce]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Te,ue,ce]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Te,ue,ce]}],"backdrop-invert":[{"backdrop-invert":["",Te,ue,ce]}],"backdrop-opacity":[{"backdrop-opacity":[Te,ue,ce]}],"backdrop-saturate":[{"backdrop-saturate":[Te,ue,ce]}],"backdrop-sepia":[{"backdrop-sepia":["",Te,ue,ce]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":$()}],"border-spacing-x":[{"border-spacing-x":$()}],"border-spacing-y":[{"border-spacing-y":$()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",ue,ce]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Te,"initial",ue,ce]}],ease:[{ease:["linear","initial",k,ue,ce]}],delay:[{delay:[Te,ue,ce]}],animate:[{animate:["none",_,ue,ce]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[j,ue,ce]}],"perspective-origin":[{"perspective-origin":P()}],rotate:[{rotate:H()}],"rotate-x":[{"rotate-x":H()}],"rotate-y":[{"rotate-y":H()}],"rotate-z":[{"rotate-z":H()}],scale:[{scale:te()}],"scale-x":[{"scale-x":te()}],"scale-y":[{"scale-y":te()}],"scale-z":[{"scale-z":te()}],"scale-3d":["scale-3d"],skew:[{skew:Ee()}],"skew-x":[{"skew-x":Ee()}],"skew-y":[{"skew-y":Ee()}],transform:[{transform:[ue,ce,"","none","gpu","cpu"]}],"transform-origin":[{origin:P()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Re()}],"translate-x":[{"translate-x":Re()}],"translate-y":[{"translate-y":Re()}],"translate-z":[{"translate-z":Re()}],"translate-none":["translate-none"],accent:[{accent:F()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:F()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",ue,ce]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":$()}],"scroll-mx":[{"scroll-mx":$()}],"scroll-my":[{"scroll-my":$()}],"scroll-ms":[{"scroll-ms":$()}],"scroll-me":[{"scroll-me":$()}],"scroll-mt":[{"scroll-mt":$()}],"scroll-mr":[{"scroll-mr":$()}],"scroll-mb":[{"scroll-mb":$()}],"scroll-ml":[{"scroll-ml":$()}],"scroll-p":[{"scroll-p":$()}],"scroll-px":[{"scroll-px":$()}],"scroll-py":[{"scroll-py":$()}],"scroll-ps":[{"scroll-ps":$()}],"scroll-pe":[{"scroll-pe":$()}],"scroll-pt":[{"scroll-pt":$()}],"scroll-pr":[{"scroll-pr":$()}],"scroll-pb":[{"scroll-pb":$()}],"scroll-pl":[{"scroll-pl":$()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",ue,ce]}],fill:[{fill:["none",...F()]}],"stroke-w":[{stroke:[Te,ds,nl,Bu]}],stroke:[{stroke:["none",...F()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},sj=Hw(rj);function ne(...n){return sj(vw(n))}async function ij(){const{data:n}=await Ce.get("/api/system/info");return n}function oj(){return Oa({queryKey:["system-info"],queryFn:ij,staleTime:6e4})}function cj(n){const r=Math.floor(n/86400),s=Math.floor(n%86400/3600);if(r>0)return`${r}d ${s}h`;const i=Math.floor(n%3600/60);return s>0?`${s}h ${i}m`:`${i}m`}function uj(){const{data:n}=oj();return n?c.jsxs("div",{className:"border-t border-[var(--color-border)] px-3 py-2 text-[10px] text-[var(--color-text-muted)]",children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx(ps,{size:10}),c.jsxs("span",{children:[n.cpuCount," cores"]}),c.jsx("span",{className:"mx-0.5",children:"|"}),c.jsx(Rd,{size:10}),c.jsxs("span",{children:[Math.round(n.totalMemoryMb/1024),"GB"]})]}),c.jsxs("div",{className:"mt-0.5",children:[n.hostname," · up ",cj(n.uptime)," · v",n.version]})]}):null}const dj=[{label:"Dashboard",icon:HN,path:"/dashboard"},{label:"Settings",icon:qx,path:"/settings"},{label:"Services",icon:_d,path:"/services"},{label:"Models",icon:cN,path:"/models"},{label:"Nodes",icon:ps,path:"/nodes"}];function fj(){return c.jsxs("aside",{className:"flex w-56 flex-col border-r border-[var(--color-border)] bg-[var(--color-surface)]",children:[c.jsx("div",{className:"flex h-14 items-center border-b border-[var(--color-border)] px-4",children:c.jsx("span",{className:"text-lg font-bold text-[var(--color-primary)]",children:"Jarvis"})}),c.jsx("nav",{className:"flex-1 space-y-1 p-2",children:dj.map(n=>c.jsxs(Kg,{to:n.path,className:({isActive:r})=>ne("flex items-center gap-3 rounded-lg px-3 py-2 text-sm font-medium transition-colors",r?"bg-[var(--color-primary)]/10 text-[var(--color-primary)]":"text-[var(--color-text-muted)] hover:bg-[var(--color-surface-alt)] hover:text-[var(--color-text)]"),children:[c.jsx(n.icon,{size:18}),n.label]},n.path))}),c.jsx(uj,{})]})}function mj(){const{state:n,logout:r}=jd(),{theme:s,toggleTheme:i}=b2();return c.jsxs("header",{className:"flex h-14 items-center justify-between border-b border-[var(--color-border)] bg-[var(--color-surface)] px-6",children:[c.jsx("h2",{className:"text-sm font-medium text-[var(--color-text-muted)]",children:"Admin Dashboard"}),c.jsxs("div",{className:"flex items-center gap-3",children:[n.user&&c.jsx("span",{className:"text-sm text-[var(--color-text-muted)]",children:n.user.email}),c.jsx("button",{onClick:i,className:"rounded-lg p-2 text-[var(--color-text-muted)] hover:bg-[var(--color-surface-alt)]",title:`Switch to ${s==="dark"?"light":"dark"} mode`,children:s==="dark"?c.jsx(uw,{size:18}):c.jsx(KN,{size:18})}),c.jsx("button",{onClick:r,className:"rounded-lg p-2 text-[var(--color-text-muted)] hover:bg-[var(--color-surface-alt)] hover:text-red-500",title:"Logout",children:c.jsx(VN,{size:18})})]})]})}function hj(){const{state:n}=jd();return n.isLoading?c.jsx("div",{className:"flex min-h-screen items-center justify-center bg-[var(--color-background)]",children:c.jsx("p",{className:"text-[var(--color-text-muted)]",children:"Loading..."})}):n.isAuthenticated?c.jsxs("div",{className:"flex h-screen bg-[var(--color-background)]",children:[c.jsx(fj,{}),c.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[c.jsx(mj,{}),c.jsx("main",{className:"flex-1 overflow-y-auto p-6",children:c.jsx(T0,{})})]})]}):c.jsx(Wi,{to:"/login",replace:!0})}function pj(){const{state:n,login:r,setup:s}=jd(),i=tn(),[d,f]=S.useState("loading"),[m,g]=S.useState(""),[v,x]=S.useState(""),[y,p]=S.useState(""),[w,M]=S.useState(""),[N,j]=S.useState(null);if(S.useEffect(()=>{let O=!1;async function P(){try{const{data:I}=await Ce.get("/api/setup/status");if(!O&&!I.configured){i("/setup",{replace:!0});return}}catch{if(!O){i("/setup",{replace:!0});return}}try{const I=await IS();O||f(I.needs_setup?"setup":"login")}catch{O||f("login")}}return P(),()=>{O=!0}},[i]),n.isAuthenticated)return c.jsx(Wi,{to:"/settings",replace:!0});const R=O=>{O.preventDefault(),r(m,y)},k=O=>{if(O.preventDefault(),j(null),y!==w){j("Passwords do not match");return}if(y.length<8){j("Password must be at least 8 characters");return}s(m,y,v||void 0)},_=ne("w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2","text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]","outline-none focus:ring-2 focus:ring-[var(--color-primary)]"),B=N??n.error;return d==="loading"?c.jsx("div",{className:"flex min-h-screen items-center justify-center bg-[var(--color-background)]",children:c.jsx("div",{className:"w-full max-w-sm rounded-xl border border-[var(--color-border)] bg-[var(--color-surface)] p-8 shadow-lg",children:c.jsx("div",{className:"flex justify-center",children:c.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-[var(--color-border)] border-t-[var(--color-primary)]"})})})}):c.jsx("div",{className:"flex min-h-screen items-center justify-center bg-[var(--color-background)]",children:c.jsx("div",{className:"w-full max-w-sm rounded-xl border border-[var(--color-border)] bg-[var(--color-surface)] p-8 shadow-lg",children:d==="setup"?c.jsxs(c.Fragment,{children:[c.jsx("h1",{className:"mb-1 text-center text-2xl font-bold text-[var(--color-text)]",children:"Welcome to Jarvis"}),c.jsx("p",{className:"mb-6 text-center text-sm text-[var(--color-text-muted)]",children:"Set up your first administrator account to get started."}),c.jsxs("form",{onSubmit:k,className:"space-y-4",children:[c.jsxs("div",{children:[c.jsx("label",{htmlFor:"email",className:"mb-1 block text-sm text-[var(--color-text-muted)]",children:"Email"}),c.jsx("input",{id:"email",type:"email",required:!0,autoComplete:"email",value:m,onChange:O=>g(O.target.value),className:_,placeholder:"admin@example.com"})]}),c.jsxs("div",{children:[c.jsx("label",{htmlFor:"username",className:"mb-1 block text-sm text-[var(--color-text-muted)]",children:"Username"}),c.jsx("input",{id:"username",type:"text",required:!0,autoComplete:"username",value:v,onChange:O=>x(O.target.value),className:_,placeholder:"admin"})]}),c.jsxs("div",{children:[c.jsx("label",{htmlFor:"password",className:"mb-1 block text-sm text-[var(--color-text-muted)]",children:"Password"}),c.jsx("input",{id:"password",type:"password",required:!0,minLength:8,autoComplete:"new-password",value:y,onChange:O=>p(O.target.value),className:_})]}),c.jsxs("div",{children:[c.jsx("label",{htmlFor:"confirm-password",className:"mb-1 block text-sm text-[var(--color-text-muted)]",children:"Confirm Password"}),c.jsx("input",{id:"confirm-password",type:"password",required:!0,minLength:8,autoComplete:"new-password",value:w,onChange:O=>M(O.target.value),className:_})]}),B&&c.jsx("p",{className:"rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-500",children:B}),c.jsx("button",{type:"submit",disabled:n.isLoading,className:ne("w-full rounded-lg bg-[var(--color-primary)] px-4 py-2 font-medium text-white","hover:opacity-90 disabled:opacity-50","transition-opacity"),children:n.isLoading?"Creating account...":"Create Admin Account"})]})]}):c.jsxs(c.Fragment,{children:[c.jsx("h1",{className:"mb-6 text-center text-2xl font-bold text-[var(--color-text)]",children:"Jarvis Admin"}),c.jsxs("form",{onSubmit:R,className:"space-y-4",children:[c.jsxs("div",{children:[c.jsx("label",{htmlFor:"email",className:"mb-1 block text-sm text-[var(--color-text-muted)]",children:"Email"}),c.jsx("input",{id:"email",type:"email",required:!0,autoComplete:"email",value:m,onChange:O=>g(O.target.value),className:_,placeholder:"admin@example.com"})]}),c.jsxs("div",{children:[c.jsx("label",{htmlFor:"password",className:"mb-1 block text-sm text-[var(--color-text-muted)]",children:"Password"}),c.jsx("input",{id:"password",type:"password",required:!0,autoComplete:"current-password",value:y,onChange:O=>p(O.target.value),className:_})]}),B&&c.jsx("p",{className:"rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-500",children:B}),c.jsx("button",{type:"submit",disabled:n.isLoading,className:ne("w-full rounded-lg bg-[var(--color-primary)] px-4 py-2 font-medium text-white","hover:opacity-90 disabled:opacity-50","transition-opacity"),children:n.isLoading?"Signing in...":"Sign in"})]})]})})})}async function gj(){const{data:n}=await Ce.get("/api/settings/");return n}async function xj(n,r,s){const{data:i}=await Ce.put(`/api/settings/${encodeURIComponent(n)}/${r}`,{value:s});return i}function vj(){return Oa({queryKey:["settings"],queryFn:gj,staleTime:3e4})}function yj(){const n=ma();return Na({mutationFn:({serviceName:r,key:s,value:i})=>xj(r,s,i),onSuccess:()=>{n.invalidateQueries({queryKey:["settings"]})}})}function bj({setting:n,onSave:r,onCancel:s,isSaving:i}){const[d,f]=S.useState(()=>n.value_type==="json"?JSON.stringify(n.value,null,2):n.value_type==="bool"?"":String(n.value??"")),[m,g]=S.useState(()=>!!n.value),[v,x]=S.useState(null),y=!!n.options?.length,p=y&&!n.options.includes(d),[w,M]=S.useState(p),N=R=>{R.preventDefault();let k;switch(n.value_type){case"bool":k=m;break;case"int":if(k=parseInt(d,10),isNaN(k)){x("Must be a whole number");return}x(null);break;case"float":if(k=parseFloat(d),isNaN(k)){x("Must be a number");return}x(null);break;case"json":try{k=JSON.parse(d),x(null)}catch{x("Invalid JSON");return}break;default:k=d}r(k)},j=ne("w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-1.5","text-sm text-[var(--color-text)] outline-none focus:ring-2 focus:ring-[var(--color-primary)]");return c.jsxs("form",{onSubmit:N,className:"flex items-center gap-2",children:[y?c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("select",{value:w?"__other__":d,onChange:R=>{R.target.value==="__other__"?(M(!0),f("")):(M(!1),f(R.target.value))},className:ne(j,"max-w-xs"),children:[n.options.map(R=>c.jsx("option",{value:String(R),children:String(R)},String(R))),c.jsx("option",{value:"__other__",children:"Other..."})]}),w&&c.jsx("input",{type:"text",value:d,onChange:R=>f(R.target.value),placeholder:"Custom value",className:ne(j,"max-w-xs"),autoFocus:!0})]}):n.value_type==="bool"?c.jsx("button",{type:"button",onClick:()=>g(R=>!R),className:ne("relative h-6 w-11 rounded-full transition-colors",m?"bg-[var(--color-primary)]":"bg-[var(--color-border)]"),children:c.jsx("span",{className:ne("absolute left-0.5 top-0.5 h-5 w-5 rounded-full bg-white transition-transform",m&&"translate-x-5")})}):n.value_type==="json"?c.jsxs("div",{className:"flex-1",children:[c.jsx("textarea",{value:d,onChange:R=>{f(R.target.value),x(null)},rows:4,className:ne(j,"font-mono text-xs")}),v&&c.jsx("p",{className:"mt-1 text-xs text-red-500",children:v})]}):c.jsxs("div",{children:[c.jsx("input",{type:n.value_type==="int"||n.value_type==="float"?"number":n.is_secret?"password":"text",step:n.value_type==="float"?"any":void 0,value:d,onChange:R=>{f(R.target.value),x(null)},className:ne(j,"max-w-xs")}),v&&c.jsx("p",{className:"mt-1 text-xs text-red-500",children:v})]}),c.jsx("button",{type:"submit",disabled:i,className:"rounded-lg bg-[var(--color-primary)] px-3 py-1.5 text-xs font-medium text-white hover:opacity-90 disabled:opacity-50",children:i?"Saving...":"Save"}),c.jsx("button",{type:"button",onClick:s,className:"rounded-lg border border-[var(--color-border)] px-3 py-1.5 text-xs text-[var(--color-text-muted)] hover:bg-[var(--color-surface-alt)]",children:"Cancel"})]})}function Sj(n){return n.is_secret?"********":n.value===null||n.value===void 0?"(not set)":n.value_type==="json"?JSON.stringify(n.value):String(n.value)}const Nj={string:"bg-blue-500/10 text-blue-500",int:"bg-emerald-500/10 text-emerald-500",float:"bg-emerald-500/10 text-emerald-500",bool:"bg-amber-500/10 text-amber-500",json:"bg-purple-500/10 text-purple-500"};function wj({setting:n,serviceName:r,onRestartService:s}){const[i,d]=S.useState(!1),f=yj(),m=g=>{f.mutate({serviceName:r,key:n.key,value:g},{onSuccess:v=>{d(!1),v.requires_reload?Xe.warning(`Setting updated. ${r} requires a restart to apply.`,s?{action:{label:"Restart",onClick:s}}:void 0):Xe.success("Setting updated")},onError:v=>{Xe.error(`Failed to update: ${v.message}`)}})};return c.jsxs("div",{className:"flex items-start justify-between gap-4 rounded-lg px-3 py-2 hover:bg-[var(--color-surface-alt)]",children:[c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("code",{className:"text-sm font-medium text-[var(--color-text)]",children:n.key}),c.jsx("span",{className:ne("rounded px-1.5 py-0.5 text-[10px] font-medium",Nj[n.value_type]??"bg-gray-500/10 text-gray-500"),children:n.value_type}),n.from_db&&c.jsx("span",{title:"Stored in database",children:c.jsx(jN,{size:12,className:"text-[var(--color-tertiary)]"})}),n.requires_reload&&c.jsx("span",{title:"Requires service restart",children:c.jsx(fa,{size:12,className:"text-amber-500"})})]}),n.description&&c.jsx("p",{className:"mt-0.5 text-xs text-[var(--color-text-muted)]",children:n.description}),i?c.jsx("div",{className:"mt-2",children:c.jsx(bj,{setting:n,onSave:m,onCancel:()=>d(!1),isSaving:f.isPending})}):c.jsx("p",{className:"mt-1 font-mono text-xs text-[var(--color-text-muted)]",children:Sj(n)})]}),!i&&c.jsx("button",{onClick:()=>d(!0),className:"shrink-0 rounded-lg p-1.5 text-[var(--color-text-muted)] hover:bg-[var(--color-surface-alt)] hover:text-[var(--color-primary)]",title:"Edit",children:c.jsx(JN,{size:14})})]})}function jj({category:n,settings:r,serviceName:s,onRestartService:i}){const[d,f]=S.useState(!0);return c.jsxs("div",{children:[c.jsxs("button",{onClick:()=>f(m=>!m),className:"flex w-full items-center gap-2 px-3 py-1.5 text-xs font-semibold uppercase tracking-wider text-[var(--color-text-muted)] hover:text-[var(--color-text)]",children:[d?c.jsx(Td,{size:14}):c.jsx(kx,{size:14}),n,c.jsxs("span",{className:"font-normal",children:["(",r.length,")"]})]}),d&&c.jsx("div",{className:"space-y-0.5",children:r.map(m=>c.jsx(wj,{setting:m,serviceName:s,onRestartService:i},m.key))})]})}async function Ej(){const{data:n}=await Ce.get("/api/containers");return n}async function Tj(n){const{data:r}=await Ce.post(`/api/containers/${n}/restart`);return r}function av(){return Oa({queryKey:["containers"],queryFn:Ej,staleTime:1e4,refetchInterval:1e4})}function nv(){const n=ma();return Na({mutationFn:r=>Tj(r),onSuccess:()=>{n.invalidateQueries({queryKey:["containers"]})}})}function Rj({result:n,defaultExpanded:r=!1}){const[s,i]=S.useState(r),{data:d}=av(),f=nv(),m=S.useCallback(()=>{const v=d?.containers.find(x=>x.name.includes(n.service_name)||x.name.includes(n.service_name.replace("jarvis-","")));v?f.mutate(v.id,{onSuccess:()=>Xe.success(`${n.service_name} is restarting...`),onError:x=>Xe.error(`Restart failed: ${x.message}`)}):Xe.error(`Could not find container for ${n.service_name}`)},[d,n.service_name,f]),g=S.useMemo(()=>{const v=new Map;for(const x of n.settings){const y=v.get(x.category)??[];v.set(x.category,[...y,x])}return v},[n]);return c.jsxs("div",{className:"overflow-hidden rounded-xl border border-[var(--color-border)] bg-[var(--color-surface)]",children:[c.jsxs("button",{onClick:()=>i(v=>!v),className:"flex w-full items-center gap-3 px-4 py-3 text-left hover:bg-[var(--color-surface-alt)]",children:[s?c.jsx(Td,{size:18,className:"text-[var(--color-text-muted)]"}):c.jsx(kx,{size:18,className:"text-[var(--color-text-muted)]"}),c.jsx("span",{className:"font-medium text-[var(--color-text)]",children:n.service_name}),n.success?c.jsx(bt,{size:16,className:"text-[var(--color-secondary)]"}):c.jsx(Pi,{size:16,className:"text-red-500"}),c.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:n.success?`${n.settings.length} settings`:n.error??"Error"}),n.latency_ms!=null&&c.jsxs("span",{className:ne("ml-auto text-xs",n.latency_ms>500?"text-amber-500":"text-[var(--color-text-muted)]"),children:[Math.round(n.latency_ms),"ms"]})]}),s&&n.success&&c.jsx("div",{className:"space-y-2 border-t border-[var(--color-border)] px-2 py-3",children:[...g.entries()].map(([v,x])=>c.jsx(jj,{category:v,settings:x,serviceName:n.service_name,onRestartService:m},v))}),s&&!n.success&&c.jsx("div",{className:"border-t border-[var(--color-border)] px-4 py-3",children:c.jsx("p",{className:"text-sm text-red-500",children:n.error??"Failed to fetch settings"})})]})}function Cj(){const{data:n,isLoading:r,isError:s,error:i,refetch:d,isFetching:f}=vj(),[m,g]=S.useState(""),v=S.useMemo(()=>{if(!n)return[];if(!m.trim())return n.services;const x=m.toLowerCase();return n.services.map(y=>({...y,settings:y.settings.filter(p=>p.key.toLowerCase().includes(x)||p.category.toLowerCase().includes(x)||(p.description?.toLowerCase().includes(x)??!1))})).filter(y=>y.settings.length>0||y.service_name.toLowerCase().includes(x))},[n,m]);return r?c.jsx("div",{className:"flex items-center justify-center py-20",children:c.jsx(da,{className:"animate-spin text-[var(--color-primary)]",size:24})}):s?c.jsxs("div",{className:"py-20 text-center",children:[c.jsx("p",{className:"mb-2 text-red-500",children:"Failed to load settings"}),c.jsx("p",{className:"mb-4 text-sm text-[var(--color-text-muted)]",children:i?.message??"Unknown error"}),c.jsx("button",{onClick:()=>d(),className:"rounded-lg bg-[var(--color-primary)] px-4 py-2 text-sm text-white hover:opacity-90",children:"Retry"})]}):c.jsxs("div",{className:"mx-auto max-w-4xl space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("h1",{className:"text-xl font-bold text-[var(--color-text)]",children:"Settings"}),c.jsxs("div",{className:"flex items-center gap-2 text-xs text-[var(--color-text-muted)]",children:[n&&c.jsxs("span",{children:[n.successful_services,"/",n.total_services," services"]}),c.jsx("button",{onClick:()=>d(),disabled:f,className:ne("rounded-lg p-1.5 hover:bg-[var(--color-surface-alt)]",f&&"animate-spin"),title:"Refresh",children:c.jsx(da,{size:14})})]})]}),c.jsxs("div",{className:"relative",children:[c.jsx(lw,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--color-text-muted)]"}),c.jsx("input",{type:"text",value:m,onChange:x=>g(x.target.value),placeholder:"Search settings...",className:ne("w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] py-2 pl-9 pr-3","text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]","outline-none focus:ring-2 focus:ring-[var(--color-primary)]")})]}),c.jsxs("div",{className:"space-y-3",children:[v.map((x,y)=>c.jsx(Rj,{result:x,defaultExpanded:y===0},x.service_name)),v.length===0&&c.jsx("p",{className:"py-8 text-center text-sm text-[var(--color-text-muted)]",children:m?"No settings match your search":"No services found"})]})]})}async function _j(){const{data:n}=await Ce.get("/api/services/registry");return n}async function Mj(n){const{data:r}=await Ce.post("/api/services/register",n);return r}async function Aj(n){const{data:r}=await Ce.post("/api/services/rotate-key",n);return r}async function Oj(n){const{data:r}=await Ce.post("/api/services/probe",n);return r}async function zj(n){const{data:r}=await Ce.post("/api/services/register",{services:[{name:n.name,host:n.host,port:n.port,scheme:n.scheme,health_path:n.health_path,description:n.description}]});return r}async function kj(n){await Ce.delete(`/api/services/${encodeURIComponent(n)}`)}async function Dj(){const{data:n}=await Ce.get("/api/services/suggestions");return n}function Uj(){return Oa({queryKey:["service-registry"],queryFn:_j,staleTime:3e4})}function Lj(){const n=ma();return Na({mutationFn:Mj,onSuccess:()=>{n.invalidateQueries({queryKey:["service-registry"]})}})}function Bj(){const n=ma();return Na({mutationFn:Aj,onSuccess:()=>{n.invalidateQueries({queryKey:["service-registry"]})}})}function Hj(){const n=ma();return Na({mutationFn:zj,onSuccess:()=>{n.invalidateQueries({queryKey:["service-registry"]})}})}function qj(){const n=ma();return Na({mutationFn:kj,onSuccess:()=>{n.invalidateQueries({queryKey:["service-registry"]})}})}function Gj(){return Oa({queryKey:["service-suggestions"],queryFn:Dj,staleTime:6e4})}function Sg({ok:n,label:r}){return c.jsxs("span",{className:ne("inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium",n?"bg-green-500/10 text-green-600 dark:text-green-400":"bg-[var(--color-surface-alt)] text-[var(--color-text-muted)]"),children:[n?c.jsx(Ed,{size:12}):c.jsx(Qx,{size:12}),r]})}function Qj({status:n,error:r,latency:s}){return n==="idle"?null:n==="probing"?c.jsx("span",{className:"flex items-center gap-1 text-xs text-[var(--color-text-muted)]",children:c.jsx(ua,{size:12,className:"animate-spin"})}):n==="healthy"?c.jsxs("span",{className:"flex items-center gap-1 text-xs text-green-600 dark:text-green-400",children:[c.jsx(lr,{size:8,fill:"currentColor"}),s!=null&&`${s}ms`]}):c.jsxs("span",{className:"flex items-center gap-1 text-xs text-red-500",title:r,children:[c.jsx(lr,{size:8,fill:"currentColor"}),r||"Unreachable"]})}function Vj({entry:n,checked:r,host:s,port:i,scheme:d,onToggle:f,onHostChange:m,onPortChange:g,onSchemeChange:v,onHostBlur:x,onPortBlur:y,onRotateKey:p,onDelete:w,disabled:M,rotating:N,deleting:j,healthStatus:R,healthError:k,healthLatency:_}){return c.jsxs("div",{className:ne("flex flex-wrap items-center gap-3 rounded-lg border border-[var(--color-border)] p-3","bg-[var(--color-surface)] transition-colors",r&&"border-[var(--color-primary)]/30 bg-[var(--color-primary)]/5"),children:[c.jsx("input",{type:"checkbox",checked:r,onChange:f,disabled:M,className:"h-4 w-4 rounded border-[var(--color-border)] accent-[var(--color-primary)]"}),c.jsxs("div",{className:"min-w-[180px] flex-1",children:[c.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-[var(--color-text)]",children:[n.name,n.custom&&c.jsx("span",{className:"rounded-full bg-blue-500/10 px-1.5 py-0.5 text-[10px] font-medium text-blue-600 dark:text-blue-400",children:"custom"})]}),c.jsx("div",{className:"text-xs text-[var(--color-text-muted)]",children:n.description})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Sg,{ok:n.config_registered,label:"Config"}),c.jsx(Sg,{ok:n.auth_registered,label:"Auth"}),n.custom&&w&&c.jsxs("button",{onClick:w,disabled:M||j,className:ne("inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium","bg-red-500/10 text-red-600 dark:text-red-400","hover:bg-red-500/20","disabled:opacity-50"),title:"Remove custom service",children:[c.jsx(Gx,{size:12,className:j?"animate-spin":""}),"Remove"]}),n.auth_registered&&c.jsxs("button",{onClick:p,disabled:M||N,className:ne("inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium","bg-[var(--color-surface-alt)] text-[var(--color-text-muted)]","hover:bg-[var(--color-primary)]/10 hover:text-[var(--color-primary)]","disabled:opacity-50"),title:"Rotate app key",children:[c.jsx(Hx,{size:12,className:N?"animate-spin":""}),"Rotate Key"]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("button",{type:"button",onClick:()=>{const B=["http","https","mqtt"],O=B[(B.indexOf(d)+1)%B.length];v(O)},disabled:M,className:ne("rounded border px-1.5 py-1 text-xs font-mono",d==="https"?"border-green-500/40 bg-green-500/10 text-green-600 dark:text-green-400":d==="mqtt"?"border-purple-500/40 bg-purple-500/10 text-purple-600 dark:text-purple-400":"border-[var(--color-border)] bg-[var(--color-background)] text-[var(--color-text-muted)]","disabled:opacity-50"),title:"Toggle scheme",children:d}),c.jsx("input",{type:"text",value:s,onChange:B=>m(B.target.value),onBlur:x,disabled:M,placeholder:"host",className:ne("w-36 rounded border border-[var(--color-border)] bg-[var(--color-background)] px-2 py-1","text-xs text-[var(--color-text)] outline-none focus:ring-1 focus:ring-[var(--color-primary)]","disabled:opacity-50")}),c.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:":"}),c.jsx("input",{type:"number",value:i,onChange:B=>g(Number(B.target.value)),onBlur:y,disabled:M,className:ne("w-20 rounded border border-[var(--color-border)] bg-[var(--color-background)] px-2 py-1","text-xs text-[var(--color-text)] outline-none focus:ring-1 focus:ring-[var(--color-primary)]","disabled:opacity-50")}),c.jsx(Qj,{status:R,error:k,latency:_})]})]})}const Ng={name:"",host:"localhost",port:"",scheme:"http",health_path:"/health",description:""};function Yj(){const{data:n,isLoading:r,isError:s,error:i,refetch:d,isFetching:f}=Uj(),m=Lj(),g=Bj(),v=Hj(),x=qj(),{data:y}=Gj(),[p,w]=S.useState({}),[M,N]=S.useState(null),[j,R]=S.useState(null),[k,_]=S.useState(null),[B,O]=S.useState(null),[P,I]=S.useState(null),[ee,$]=S.useState({}),[W,re]=S.useState(!1),[se,ie]=S.useState(Ng),[Ae,De]=S.useState(!1),Be=S.useRef(null),z=S.useMemo(()=>new Set(n?.services.map(H=>H.name)??[]),[n]),Z=S.useMemo(()=>{const te=(y?.suggestions??[]).filter(Re=>!z.has(Re.id));if(!se.name.trim())return te;const Ee=se.name.toLowerCase();return te.filter(Re=>Re.id.toLowerCase().includes(Ee)||Re.name.toLowerCase().includes(Ee)||Re.description.toLowerCase().includes(Ee))},[y,z,se.name]),F=S.useCallback(H=>{ie({name:H.id,description:H.description,host:"localhost",port:String(H.port),scheme:"http",health_path:H.healthCheck}),De(!1)},[]);S.useEffect(()=>{const H=te=>{Be.current&&!Be.current.contains(te.target)&&De(!1)};return document.addEventListener("mousedown",H),()=>document.removeEventListener("mousedown",H)},[]);const xe=S.useCallback(H=>{if(p[H])return p[H];const te=n?.services.find(Ee=>Ee.name===H);return te?{checked:te.config_registered,host:te.current_host??"localhost",port:te.current_port??te.default_port,scheme:te.current_scheme??"http"}:{checked:!1,host:"localhost",port:0,scheme:"http"}},[p,n]),ge=S.useCallback((H,te)=>{w(Ee=>{const Re=Ee[H]??{checked:!1,host:"localhost",port:0};return{...Ee,[H]:{...Re,...te}}})},[]),T=S.useCallback(async(H,te,Ee,Re,ha="http")=>{if(!(!te||!Ee)){$(ot=>({...ot,[H]:{status:"probing"}}));try{const ot=await Oj({host:te,port:Ee,health_path:Re,scheme:ha});$(zn=>({...zn,[H]:{status:ot.healthy?"healthy":"unhealthy",error:ot.error??void 0,latency:ot.latency_ms??void 0}}))}catch{$(ot=>({...ot,[H]:{status:"unhealthy",error:"Request failed"}}))}}},[]),Q=S.useCallback(()=>{if(!n)return;const H=n.services.filter(te=>xe(te.name).checked).map(te=>{const Ee=xe(te.name);return{name:te.name,host:Ee.host,port:Ee.port,scheme:Ee.scheme}});if(H.length===0){Xe.error("No services selected");return}N(null),R(null),m.mutate({services:H},{onSuccess:te=>{N(te.results);const Ee=te.results.filter(ha=>ha.config_ok&&ha.auth_ok).length,Re=te.results.length;Ee===Re?Xe.success(`All ${Re} services registered`):Xe.warning(`${Ee}/${Re} services registered successfully`)},onError:te=>{Xe.error(`Registration failed: ${te.message}`)}})},[n,xe,m]),V=S.useCallback(H=>{_(H),R(null),g.mutate({service_name:H},{onSuccess:te=>{R(te),_(null),Xe.success(`Key rotated for ${H}`)},onError:te=>{_(null),Xe.error(`Key rotation failed: ${te.message}`)}})},[g]),J=S.useCallback(H=>{O(H),x.mutate(H,{onSuccess:()=>{O(null),Xe.success(`Removed ${H}`)},onError:te=>{O(null),Xe.error(`Failed to remove: ${te.message}`)}})},[x]),le=S.useCallback(()=>{const H=parseInt(se.port,10);if(!se.name.trim()){Xe.error("Service name is required");return}if(!H||H<1||H>65535){Xe.error("Port must be between 1 and 65535");return}v.mutate({name:se.name.trim(),host:se.host.trim()||"localhost",port:H,scheme:se.scheme,health_path:se.health_path.trim()||"/health",description:se.description.trim()},{onSuccess:te=>{const Ee=te.results[0];Ee?.config_ok?(Xe.success(`Added ${se.name.trim()}`),ie(Ng),re(!1)):Xe.error(`Failed to add: ${Ee?.error??"Unknown error"}`)},onError:te=>{Xe.error(`Failed to add service: ${te.message}`)}})},[se,v]),me=S.useCallback(H=>{navigator.clipboard.writeText(H).then(()=>{I(H),setTimeout(()=>I(null),2e3)})},[]),fe=n?.services.filter(H=>xe(H.name).checked).length??0,be=M?.some(H=>H.env_written)||j?.env_written===!0;return r?c.jsx("div",{className:"flex items-center justify-center py-20",children:c.jsx(da,{className:"animate-spin text-[var(--color-primary)]",size:24})}):s?c.jsxs("div",{className:"py-20 text-center",children:[c.jsx("p",{className:"mb-2 text-red-500",children:"Failed to load service registry"}),c.jsx("p",{className:"mb-4 text-sm text-[var(--color-text-muted)]",children:i?.message??"Unknown error"}),c.jsx("button",{onClick:()=>d(),className:"rounded-lg bg-[var(--color-primary)] px-4 py-2 text-sm text-white hover:opacity-90",children:"Retry"})]}):c.jsxs("div",{className:"mx-auto max-w-4xl space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("h1",{className:"text-xl font-bold text-[var(--color-text)]",children:"Services"}),c.jsx("span",{className:"rounded-full bg-[var(--color-surface-alt)] px-2.5 py-0.5 text-xs font-medium text-[var(--color-text-muted)]",children:n?.services.length??0})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("button",{onClick:()=>re(H=>!H),className:ne("flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-medium",W?"bg-[var(--color-surface-alt)] text-[var(--color-text)]":"bg-[var(--color-primary)] text-white hover:opacity-90"),children:[W?c.jsx(Qx,{size:14}):c.jsx(WN,{size:14}),W?"Cancel":"Add Service"]}),c.jsx("button",{onClick:()=>d(),disabled:f,className:ne("rounded-lg p-1.5 text-[var(--color-text-muted)] hover:bg-[var(--color-surface-alt)]",f&&"animate-spin"),title:"Refresh",children:c.jsx(da,{size:14})})]})]}),W&&c.jsxs("div",{className:"rounded-lg border border-[var(--color-primary)]/30 bg-[var(--color-primary)]/5 p-4",children:[c.jsx("h2",{className:"mb-3 text-sm font-semibold text-[var(--color-text)]",children:"Add Service"}),c.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[c.jsxs("div",{ref:Be,className:"relative",children:[c.jsx("label",{className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"Service"}),c.jsxs("div",{className:"relative",children:[c.jsx("input",{type:"text",value:se.name,onChange:H=>{ie(te=>({...te,name:H.target.value})),De(!0)},onFocus:()=>De(!0),placeholder:"Select or type a service name...",className:ne("w-full rounded border border-[var(--color-border)] bg-[var(--color-background)] px-2.5 py-1.5 pr-8","text-sm text-[var(--color-text)] outline-none focus:ring-1 focus:ring-[var(--color-primary)]")}),c.jsx("button",{type:"button",onClick:()=>De(H=>!H),className:"absolute right-1.5 top-1/2 -translate-y-1/2 rounded p-0.5 text-[var(--color-text-muted)] hover:text-[var(--color-text)]",children:c.jsx(Td,{size:14})})]}),Ae&&Z.length>0&&c.jsx("div",{className:"absolute z-10 mt-1 max-h-48 w-full overflow-y-auto rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] shadow-lg",children:Z.map(H=>c.jsxs("button",{type:"button",onClick:()=>F(H),className:"flex w-full flex-col px-3 py-2 text-left hover:bg-[var(--color-surface-alt)]",children:[c.jsxs("span",{className:"text-sm font-medium text-[var(--color-text)]",children:[H.name,c.jsxs("span",{className:"ml-2 font-normal text-[var(--color-text-muted)]",children:[":",H.port]})]}),c.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:H.description})]},H.id))})]}),c.jsxs("div",{children:[c.jsx("label",{className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"Description"}),c.jsx("input",{type:"text",value:se.description,onChange:H=>ie(te=>({...te,description:H.target.value})),placeholder:"e.g. Camera streaming via WebRTC",className:ne("w-full rounded border border-[var(--color-border)] bg-[var(--color-background)] px-2.5 py-1.5","text-sm text-[var(--color-text)] outline-none focus:ring-1 focus:ring-[var(--color-primary)]")})]}),c.jsxs("div",{children:[c.jsx("label",{className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"Host"}),c.jsx("input",{type:"text",value:se.host,onChange:H=>ie(te=>({...te,host:H.target.value})),placeholder:"localhost",className:ne("w-full rounded border border-[var(--color-border)] bg-[var(--color-background)] px-2.5 py-1.5","text-sm text-[var(--color-text)] outline-none focus:ring-1 focus:ring-[var(--color-primary)]")})]}),c.jsxs("div",{className:"flex gap-3",children:[c.jsxs("div",{className:"flex-1",children:[c.jsx("label",{className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"Port"}),c.jsx("input",{type:"number",value:se.port,onChange:H=>ie(te=>({...te,port:H.target.value})),placeholder:"e.g. 1984",className:ne("w-full rounded border border-[var(--color-border)] bg-[var(--color-background)] px-2.5 py-1.5","text-sm text-[var(--color-text)] outline-none focus:ring-1 focus:ring-[var(--color-primary)]")})]}),c.jsxs("div",{className:"w-20",children:[c.jsx("label",{className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"Scheme"}),c.jsxs("select",{value:se.scheme,onChange:H=>ie(te=>({...te,scheme:H.target.value})),className:ne("w-full rounded border border-[var(--color-border)] bg-[var(--color-background)] px-2 py-1.5","text-sm text-[var(--color-text)] outline-none focus:ring-1 focus:ring-[var(--color-primary)]"),children:[c.jsx("option",{value:"http",children:"http"}),c.jsx("option",{value:"https",children:"https"}),c.jsx("option",{value:"mqtt",children:"mqtt"})]})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"Health Path"}),c.jsx("input",{type:"text",value:se.health_path,onChange:H=>ie(te=>({...te,health_path:H.target.value})),placeholder:"/health",className:ne("w-full rounded border border-[var(--color-border)] bg-[var(--color-background)] px-2.5 py-1.5","text-sm text-[var(--color-text)] outline-none focus:ring-1 focus:ring-[var(--color-primary)]")})]})]}),c.jsx("div",{className:"mt-3 flex justify-end",children:c.jsx("button",{onClick:le,disabled:v.isPending||!se.name.trim()||!se.port,className:ne("rounded-lg bg-[var(--color-primary)] px-4 py-1.5 text-sm font-medium text-white","hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50"),children:v.isPending?"Adding...":"Add Service"})})]}),c.jsx("div",{className:"space-y-2",children:n?.services.map(H=>{const te=xe(H.name),Ee=ee[H.name]??{status:"idle"};return c.jsx(Vj,{entry:H,checked:te.checked,host:te.host,port:te.port,scheme:te.scheme,onToggle:()=>{const Re=!te.checked;ge(H.name,{...te,checked:Re}),Re?T(H.name,te.host,te.port,H.health_path,te.scheme):$(ha=>({...ha,[H.name]:{status:"idle"}}))},onHostChange:Re=>ge(H.name,{...te,host:Re}),onPortChange:Re=>ge(H.name,{...te,port:Re}),onSchemeChange:Re=>ge(H.name,{...te,scheme:Re}),onHostBlur:()=>{te.checked&&T(H.name,te.host,te.port,H.health_path,te.scheme)},onPortBlur:()=>{te.checked&&T(H.name,te.host,te.port,H.health_path,te.scheme)},onRotateKey:()=>V(H.name),onDelete:()=>J(H.name),disabled:m.isPending,rotating:k===H.name,deleting:B===H.name,healthStatus:Ee.status,healthError:Ee.error,healthLatency:Ee.latency},H.name)})}),c.jsx("button",{onClick:Q,disabled:m.isPending||fe===0,className:ne("rounded-lg bg-[var(--color-primary)] px-4 py-2 text-sm font-medium text-white","hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50"),children:m.isPending?"Registering...":`Register Selected (${fe})`}),j&&c.jsx(Xj,{serviceName:j.service_name,appKey:j.app_key,envWritten:j.env_written,copiedKey:P,onCopy:me,label:"Rotated Key"}),M&&c.jsxs("div",{className:"space-y-2 rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[c.jsx("h2",{className:"text-sm font-semibold text-[var(--color-text)]",children:"Registration Results"}),M.map(H=>c.jsxs("div",{className:ne("flex flex-wrap items-center gap-3 rounded-lg border p-3 text-sm",H.config_ok&&H.auth_ok?"border-green-500/20 bg-green-500/5":"border-yellow-500/20 bg-yellow-500/5"),children:[c.jsx("span",{className:"min-w-[180px] font-medium text-[var(--color-text)]",children:H.name}),c.jsxs("span",{className:ne("text-xs",H.config_ok?"text-green-600 dark:text-green-400":"text-red-500"),children:["Config: ",H.config_ok?"OK":"Failed"]}),c.jsxs("span",{className:ne("text-xs",H.auth_ok?"text-green-600 dark:text-green-400":"text-red-500"),children:["Auth: ",H.auth_ok?H.auth_created?"Created":"Exists":"Failed"]}),H.env_written!==null&&c.jsxs("span",{className:ne("text-xs",H.env_written?"text-green-600 dark:text-green-400":"text-red-500"),children:[".env: ",H.env_written?"Written":"Failed"]}),H.error&&c.jsxs("span",{className:"flex items-center gap-1 text-xs text-yellow-600 dark:text-yellow-400",children:[c.jsx(fa,{size:12}),H.error]}),H.auth_created&&H.app_key&&c.jsxs("div",{className:"mt-1 w-full",children:[c.jsxs("div",{className:"mb-1 flex items-center gap-1 text-xs font-medium text-yellow-600 dark:text-yellow-400",children:[c.jsx(fa,{size:12}),"App key (shown once only):"]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("code",{className:"flex-1 overflow-x-auto rounded bg-[var(--color-background)] px-2 py-1 font-mono text-xs text-[var(--color-text)]",children:H.app_key}),c.jsx("button",{onClick:()=>me(H.app_key),className:"rounded p-1 hover:bg-[var(--color-surface-alt)]",title:"Copy to clipboard",children:P===H.app_key?c.jsx(Ed,{size:14,className:"text-green-500"}):c.jsx(Lx,{size:14,className:"text-[var(--color-text-muted)]"})})]})]})]},H.name))]}),be&&c.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-blue-500/20 bg-blue-500/5 p-3",children:[c.jsx(DN,{size:16,className:"mt-0.5 shrink-0 text-blue-500"}),c.jsx("p",{className:"text-sm text-[var(--color-text)]",children:"Services whose .env files were updated need to be restarted to pick up the new credentials. Restart each affected service's container or process."})]})]})}function Xj({serviceName:n,appKey:r,envWritten:s,copiedKey:i,onCopy:d,label:f}){return c.jsxs("div",{className:"space-y-2 rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[c.jsxs("h2",{className:"text-sm font-semibold text-[var(--color-text)]",children:[f,": ",n]}),c.jsxs("div",{className:"rounded-lg border border-green-500/20 bg-green-500/5 p-3",children:[s!==null&&c.jsxs("span",{className:ne("mb-2 inline-block text-xs",s?"text-green-600 dark:text-green-400":"text-red-500"),children:[".env: ",s?"Written":"Failed"]}),c.jsxs("div",{children:[c.jsxs("div",{className:"mb-1 flex items-center gap-1 text-xs font-medium text-yellow-600 dark:text-yellow-400",children:[c.jsx(fa,{size:12}),"New app key (shown once only):"]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("code",{className:"flex-1 overflow-x-auto rounded bg-[var(--color-background)] px-2 py-1 font-mono text-xs text-[var(--color-text)]",children:r}),c.jsx("button",{onClick:()=>d(r),className:"rounded p-1 hover:bg-[var(--color-surface-alt)]",title:"Copy to clipboard",children:i===r?c.jsx(Ed,{size:14,className:"text-green-500"}):c.jsx(Lx,{size:14,className:"text-[var(--color-text-muted)]"})})]})]})]})]})}async function Fj(){const{data:n}=await Ce.get("/api/llm-setup/status");return n}async function Kj(n){const{data:r}=await Ce.post("/api/llm-setup/configure",{settings:n});return r}async function Zj(n,r,s){const{data:i}=await Ce.post("/api/llm-setup/download",{repo:n,filename:r,token:s});return i}function Jj(){return Oa({queryKey:["llm-status"],queryFn:Fj,staleTime:3e4,retry:1})}function lv(){const n=ma();return Na({mutationFn:r=>Kj(r),onSuccess:()=>{n.invalidateQueries({queryKey:["llm-status"]}),n.invalidateQueries({queryKey:["containers"]})}})}function $j(){return Na({mutationFn:({repo:n,filename:r,token:s})=>Zj(n,r,s)})}async function Ad(){const{data:n}=await Ce.get("/api/install/status");return n}async function Pj(n){const r=n?.length?{services:n.join(",")}:{},{data:s}=await Ce.get("/api/install/preflight",{params:r});return s}async function Ij(){const{data:n}=await Ce.get("/api/install/hardware");return n}async function wg(n){const{data:r}=await Ce.post("/api/install/generate",n);return r}async function rv(){const{data:n}=await Ce.get("/api/install/registry");return n}async function Wj(){const{data:n}=await Ce.get("/api/install/defaults");return n}const eE={running:"bg-emerald-500",exited:"bg-red-500",restarting:"bg-amber-500",paused:"bg-amber-500",created:"bg-gray-400",dead:"bg-red-700"};function tE(n){return n.match(/^Up (.+)$/)?.[1]??null}function jg({container:n,onRestart:r,isRestarting:s}){const i=tE(n.status),d=n.ports.find(f=>f.public)?.public;return c.jsxs("div",{className:"overflow-hidden rounded-xl border border-[var(--color-border)] bg-[var(--color-surface)]",children:[c.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[c.jsx("div",{className:ne("h-2.5 w-2.5 rounded-full",eE[n.state]??"bg-gray-400")}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("p",{className:"truncate text-sm font-medium text-[var(--color-text)]",children:n.displayName??n.name}),n.description&&c.jsx("p",{className:"truncate text-xs text-[var(--color-text-muted)]",children:n.description})]}),c.jsx("span",{className:ne("rounded-full px-2 py-0.5 text-xs font-medium",n.state==="running"?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400":"bg-red-500/10 text-red-600 dark:text-red-400"),children:n.state})]}),c.jsx("div",{className:"border-t border-[var(--color-border)] px-4 py-2",children:c.jsxs("div",{className:"flex items-center justify-between text-xs text-[var(--color-text-muted)]",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[i&&c.jsxs("span",{children:["Up ",i]}),d&&c.jsxs("span",{children:[":",d]})]}),c.jsxs("div",{className:"flex items-center gap-1",children:[d&&c.jsx("a",{href:`http://localhost:${d}/health`,target:"_blank",rel:"noopener noreferrer",className:"rounded p-1 hover:bg-[var(--color-surface-alt)]",title:"Open health endpoint",children:c.jsx(RN,{size:13})}),c.jsx("button",{onClick:()=>r(n.id),disabled:s,className:ne("rounded p-1 hover:bg-[var(--color-surface-alt)]",s&&"animate-spin"),title:"Restart",children:c.jsx(Hx,{size:13})})]})]})})]})}async function aE(){const{data:n}=await Ce.get("/api/update/check");return n}function sv(){return Oa({queryKey:["update-check"],queryFn:aE,staleTime:300*1e3,retry:1,refetchOnWindowFocus:!1})}const Eg="jarvis-update-dismissed-version";function Tg(){const n=tn(),{data:r}=sv(),[s,i]=S.useState(()=>r?.latestVersion?localStorage.getItem(Eg)===r.latestVersion:!1);return!r?.updateAvailable||s?null:c.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-green-500/30 bg-green-500/5 p-4",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(Ux,{size:20,className:"text-green-500"}),c.jsxs("div",{children:[c.jsxs("p",{className:"text-sm font-medium text-[var(--color-text)]",children:["Jarvis v",r.latestVersion," available"]}),c.jsxs("p",{className:"text-xs text-[var(--color-text-muted)]",children:["You have v",r.currentVersion]})]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[r.releaseUrl&&c.jsx("a",{href:r.releaseUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text)]",children:"Release notes"}),c.jsx("button",{onClick:()=>{localStorage.setItem(Eg,r.latestVersion),i(!0)},className:"text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text)]",children:"Dismiss"}),c.jsx("button",{onClick:()=>n("/update"),className:"rounded-lg bg-green-600 px-3 py-1.5 text-xs text-white hover:opacity-90",children:"Update"})]})]})}const Hu="jarvis-admin:llm-setup-dismissed";function nE(){const n=tn(),[r,s]=S.useState(!1),{data:i,isLoading:d,isError:f,error:m,refetch:g,isFetching:v}=av(),x=nv(),y=Jj(),[p,w]=S.useState(()=>!!localStorage.getItem(Hu));S.useEffect(()=>{Ad().then(_=>{_.deployMode==="compose-export"&&s(!0)}).catch(()=>{})},[]);const M=!!y.data&&!y.data.configured&&!p,N=_=>{x.mutate(_,{onSuccess:()=>Xe.success("Container restart initiated"),onError:B=>Xe.error(`Restart failed: ${B.message}`)})};if(r)return c.jsxs("div",{className:"mx-auto max-w-4xl space-y-4",children:[c.jsx("h1",{className:"text-xl font-bold text-[var(--color-text)]",children:"Dashboard"}),c.jsx(Tg,{}),M&&c.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-[var(--color-primary)]/30 bg-[var(--color-primary)]/5 p-4",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(ld,{size:20,className:"text-[var(--color-primary)]"}),c.jsxs("div",{children:[c.jsx("p",{className:"text-sm font-medium text-[var(--color-text)]",children:"LLM not configured"}),c.jsx("p",{className:"text-xs text-[var(--color-text-muted)]",children:"Set up a language model to enable voice command processing"})]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("button",{onClick:()=>{localStorage.setItem(Hu,"true"),w(!0)},className:"text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text)]",children:"Dismiss"}),c.jsx("button",{onClick:()=>n("/llm-setup"),className:"rounded-lg bg-[var(--color-primary)] px-3 py-1.5 text-xs text-white hover:opacity-90",children:"Set up LLM"})]})]}),c.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-8 text-center",children:[c.jsx(_d,{size:32,className:"mx-auto mb-3 text-[var(--color-text-muted)]"}),c.jsx("p",{className:"text-sm font-medium text-[var(--color-text)]",children:"Running in Docker Compose mode"}),c.jsx("p",{className:"mt-1 text-xs text-[var(--color-text-muted)]",children:"Container management is handled by your Docker environment (TrueNAS, Portainer, etc.). Use your platform's tools to view container status, logs, and restarts."})]})]});if(d)return c.jsx("div",{className:"flex items-center justify-center py-20",children:c.jsx(da,{className:"animate-spin text-[var(--color-primary)]",size:24})});if(f)return c.jsxs("div",{className:"py-20 text-center",children:[c.jsx("p",{className:"mb-2 text-red-500",children:"Failed to load containers"}),c.jsx("p",{className:"mb-4 text-sm text-[var(--color-text-muted)]",children:m?.message??"Unknown error"}),c.jsx("button",{onClick:()=>g(),className:"rounded-lg bg-[var(--color-primary)] px-4 py-2 text-sm text-white hover:opacity-90",children:"Retry"})]});const j=i?.containers??[],R=j.filter(_=>_.state==="running"),k=j.filter(_=>_.state!=="running");return c.jsxs("div",{className:"mx-auto max-w-4xl space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("h1",{className:"text-xl font-bold text-[var(--color-text)]",children:"Dashboard"}),c.jsxs("div",{className:"flex items-center gap-2 text-xs text-[var(--color-text-muted)]",children:[c.jsxs("span",{children:[R.length,"/",j.length," running"]}),c.jsx("button",{onClick:()=>g(),disabled:v,className:ne("rounded-lg p-1.5 hover:bg-[var(--color-surface-alt)]",v&&"animate-spin"),title:"Refresh",children:c.jsx(da,{size:14})})]})]}),c.jsx(Tg,{}),M&&c.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-[var(--color-primary)]/30 bg-[var(--color-primary)]/5 p-4",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(ld,{size:20,className:"text-[var(--color-primary)]"}),c.jsxs("div",{children:[c.jsx("p",{className:"text-sm font-medium text-[var(--color-text)]",children:"LLM not configured"}),c.jsx("p",{className:"text-xs text-[var(--color-text-muted)]",children:"Set up a language model to enable voice command processing"})]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("button",{onClick:()=>{localStorage.setItem(Hu,"true"),w(!0)},className:"text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text)]",children:"Dismiss"}),c.jsx("button",{onClick:()=>n("/llm-setup"),className:"rounded-lg bg-[var(--color-primary)] px-3 py-1.5 text-xs text-white hover:opacity-90",children:"Set up LLM"})]})]}),c.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(Bx,{size:20,className:"text-[var(--color-text-muted)]"}),c.jsxs("div",{children:[c.jsx("p",{className:"text-sm font-medium text-[var(--color-text)]",children:"Sync compose to latest registry"}),c.jsx("p",{className:"text-xs text-[var(--color-text-muted)]",children:"Regenerate docker-compose.yml and apply changes — adds new background workers and services without recreating unchanged containers"})]})]}),c.jsx("button",{onClick:()=>n("/reconcile"),className:"rounded-lg border border-[var(--color-border)] px-3 py-1.5 text-xs text-[var(--color-text)] hover:bg-[var(--color-surface-alt)]",children:"Sync now"})]}),j.length===0&&c.jsx("div",{className:"py-12 text-center",children:c.jsx("p",{className:"text-sm text-[var(--color-text-muted)]",children:i?.error?i.error:"No Jarvis containers found. Is Docker running?"})}),R.length>0&&c.jsxs("div",{className:"space-y-2",children:[c.jsx("h2",{className:"text-xs font-semibold uppercase tracking-wider text-[var(--color-text-muted)]",children:"Running"}),c.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:R.map(_=>c.jsx(jg,{container:_,onRestart:N,isRestarting:x.isPending&&x.variables===_.id},_.id))})]}),k.length>0&&c.jsxs("div",{className:"space-y-2",children:[c.jsx("h2",{className:"text-xs font-semibold uppercase tracking-wider text-[var(--color-text-muted)]",children:"Stopped"}),c.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:k.map(_=>c.jsx(jg,{container:_,onRestart:N,isRestarting:x.isPending&&x.variables===_.id},_.id))})]})]})}async function lE(){const{data:n}=await Ce.get("/api/nodes");return n}async function rE(n){const{data:r}=await Ce.get(`/api/nodes/${n}/nodes`);return r}async function sE(n){const{data:r}=await Ce.post(`/api/nodes/${n}/train-adapter`);return r}function iE(){return Oa({queryKey:["households"],queryFn:lE,staleTime:3e4})}function oE(n){return Oa({queryKey:["household-nodes",n],queryFn:()=>rE(n),enabled:!!n,staleTime:3e4})}function cE(){const n=ma();return Na({mutationFn:sE,onSuccess:()=>{n.invalidateQueries({queryKey:["household-nodes"]})}})}function uE({node:n,onTrain:r,isTraining:s}){return c.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[c.jsxs("div",{className:"flex items-start justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ps,{size:16,className:"text-[var(--color-text-muted)]"}),c.jsx("span",{className:"font-medium text-[var(--color-text)]",children:n.name})]}),c.jsxs("span",{className:ne("inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium",n.is_active?"bg-green-500/10 text-green-500":"bg-red-500/10 text-red-500"),children:[n.is_active?c.jsx(xw,{size:10}):c.jsx(pw,{size:10}),n.is_active?"Active":"Inactive"]})]}),c.jsxs("div",{className:"mt-3 space-y-1 text-xs text-[var(--color-text-muted)]",children:[c.jsxs("p",{children:[c.jsx("span",{className:"font-medium",children:"ID:"})," ",n.node_id]}),n.services.length>0&&c.jsxs("p",{children:[c.jsx("span",{className:"font-medium",children:"Services:"})," ",n.services.join(", ")]})]}),c.jsx("div",{className:"mt-4",children:c.jsx("button",{onClick:()=>r(n.node_id),disabled:s||!n.is_active,className:ne("rounded-lg px-3 py-1.5 text-xs font-medium transition-colors",s||!n.is_active?"cursor-not-allowed bg-[var(--color-surface-alt)] text-[var(--color-text-muted)]":"bg-[var(--color-primary)] text-white hover:opacity-90"),children:s?c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx(da,{size:12,className:"animate-spin"}),"Training..."]}):"Train Adapter"})})]})}function dE({householdId:n,householdName:r}){const{data:s,isLoading:i,isError:d}=oE(n),f=cE(),m=g=>{f.mutate(g,{onSuccess:v=>Xe.success(`Training triggered for ${g} (request: ${v.request_id.slice(0,8)}...)`),onError:v=>Xe.error(`Training failed: ${v.message}`)})};return c.jsxs("div",{className:"space-y-2",children:[c.jsx("h2",{className:"text-xs font-semibold uppercase tracking-wider text-[var(--color-text-muted)]",children:r}),i&&c.jsx("div",{className:"flex items-center justify-center py-8",children:c.jsx(da,{className:"animate-spin text-[var(--color-primary)]",size:18})}),d&&c.jsx("p",{className:"py-4 text-center text-sm text-red-500",children:"Failed to load nodes"}),s&&s.length===0&&c.jsx("p",{className:"py-4 text-center text-sm text-[var(--color-text-muted)]",children:"No nodes registered in this household"}),s&&s.length>0&&c.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:s.map(g=>c.jsx(uE,{node:g,onTrain:m,isTraining:f.isPending&&f.variables===g.node_id},g.node_id))})]})}function fE(){const{data:n,isLoading:r,isError:s,error:i,refetch:d,isFetching:f}=iE();return r?c.jsx("div",{className:"flex items-center justify-center py-20",children:c.jsx(da,{className:"animate-spin text-[var(--color-primary)]",size:24})}):s?c.jsxs("div",{className:"py-20 text-center",children:[c.jsx("p",{className:"mb-2 text-red-500",children:"Failed to load households"}),c.jsx("p",{className:"mb-4 text-sm text-[var(--color-text-muted)]",children:i?.message??"Unknown error"}),c.jsx("button",{onClick:()=>d(),className:"rounded-lg bg-[var(--color-primary)] px-4 py-2 text-sm text-white hover:opacity-90",children:"Retry"})]}):c.jsxs("div",{className:"mx-auto max-w-4xl space-y-6",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("h1",{className:"text-xl font-bold text-[var(--color-text)]",children:"Nodes"}),c.jsx("button",{onClick:()=>d(),disabled:f,className:ne("rounded-lg p-1.5 hover:bg-[var(--color-surface-alt)]",f&&"animate-spin"),title:"Refresh",children:c.jsx(da,{size:14,className:"text-[var(--color-text-muted)]"})})]}),(!n||n.length===0)&&c.jsx("div",{className:"py-12 text-center",children:c.jsx("p",{className:"text-sm text-[var(--color-text-muted)]",children:"No households found. Register a household in jarvis-auth first."})}),n?.map(m=>c.jsx(dE,{householdId:m.id,householdName:m.name},m.id))]})}async function mE(){const{data:n}=await Ce.get("/api/models/installed");return n.models}async function hE(n){const{data:r}=await Ce.post("/api/models/download",n);return r}async function pE(n){await Ce.delete(`/api/models/${encodeURIComponent(n)}`)}function gE(){return Oa({queryKey:["models","installed"],queryFn:mE,staleTime:1e4})}function iv(){const n=ma();return Na({mutationFn:r=>hE(r),onSuccess:()=>{n.invalidateQueries({queryKey:["models","installed"]})}})}function xE(){const n=ma();return Na({mutationFn:r=>pE(r),onSuccess:()=>{n.invalidateQueries({queryKey:["models","installed"]})}})}const ar=[{id:"qwen3-4b",displayName:"Qwen 3 4B",hfRepoVllm:"Qwen/Qwen3-4B-AWQ",hfRepoGguf:"Qwen/Qwen3-4B-GGUF",ggufFilename:"Qwen3-4B-Q4_K_M.gguf",chatFormat:"qwen3",contextWindow:40960,sizeVllm:"2.5GB",sizeGguf:"2.5GB",vramMb:4096,gated:!1,quantization:"awq",promptProvider:"Qwen25MediumUntrained"},{id:"qwen3-8b",displayName:"Qwen 3 8B",hfRepoVllm:"Qwen/Qwen3-8B-AWQ",hfRepoGguf:"Qwen/Qwen3-8B-GGUF",ggufFilename:"Qwen3-8B-Q4_K_M.gguf",chatFormat:"qwen3",contextWindow:40960,sizeVllm:"5.7GB",sizeGguf:"5GB",vramMb:7168,gated:!1,quantization:"awq",promptProvider:"Qwen25MediumUntrained"},{id:"qwen3-14b",displayName:"Qwen 3 14B",hfRepoVllm:"Qwen/Qwen3-14B-AWQ",hfRepoGguf:"Qwen/Qwen3-14B-GGUF",ggufFilename:"Qwen3-14B-Q4_K_M.gguf",chatFormat:"qwen3",contextWindow:40960,sizeVllm:"9.4GB",sizeGguf:"9GB",vramMb:12288,gated:!1,quantization:"awq",promptProvider:"Qwen3LargeUntrained"},{id:"qwen25-7b",displayName:"Qwen 2.5 7B Instruct",hfRepoVllm:"Qwen/Qwen2.5-7B-Instruct-AWQ",hfRepoGguf:"Qwen/Qwen2.5-7B-Instruct-GGUF",ggufFilename:"qwen2.5-7b-instruct-q4_k_m.gguf",chatFormat:"chatml",contextWindow:32768,sizeVllm:"4.7GB",sizeGguf:"4.7GB",vramMb:6144,gated:!1,quantization:"awq",promptProvider:"Qwen25MediumUntrained"},{id:"llama-3.1-8b",displayName:"Llama 3.1 8B Instruct",hfRepoVllm:"hugging-quants/Meta-Llama-3.1-8B-Instruct-AWQ-INT4",hfRepoGguf:"lmstudio-community/Meta-Llama-3.1-8B-Instruct-GGUF",ggufFilename:"Meta-Llama-3.1-8B-Instruct-Q4_K_M.gguf",chatFormat:"llama3",contextWindow:131072,sizeVllm:"5.4GB",sizeGguf:"5GB",vramMb:7168,gated:!1,quantization:"awq",promptProvider:"Llama31MediumUntrained"},{id:"hermes-3-8b",displayName:"Hermes 3 Llama 3.1 8B",hfRepoVllm:"solidrust/Hermes-3-Llama-3.1-8B-AWQ",hfRepoGguf:"NousResearch/Hermes-3-Llama-3.1-8B-GGUF",ggufFilename:"Hermes-3-Llama-3.1-8B.Q4_K_M.gguf",chatFormat:"chatml",contextWindow:131072,sizeVllm:"5.4GB",sizeGguf:"4.9GB",vramMb:7168,gated:!1,quantization:"awq",promptProvider:"HermesMediumUntrained"}];function vE(){const[n,r]=S.useState(""),[s,i]=S.useState(""),[d,f]=S.useState(""),[m,g]=S.useState(null),{data:v,isLoading:x}=gE(),y=iv(),p=xE();function w(j,R){const k=`${j}/${R??""}`;g(k),y.mutate({repo:j,filename:R||void 0,token:n||void 0},{onSuccess:_=>{Xe.success(_.message),g(null)},onError:_=>{Xe.error(_ instanceof Error?_.message:"Download failed"),g(null)}})}function M(j){confirm(`Delete ${j}?`)&&p.mutate(j,{onSuccess:()=>Xe.success(`Deleted ${j}`),onError:()=>Xe.error("Failed to delete")})}function N(){s&&w(s,d)}return c.jsxs("div",{className:"mx-auto max-w-4xl space-y-8 p-6",children:[c.jsxs("div",{children:[c.jsx("h1",{className:"text-2xl font-bold text-[var(--color-text)]",children:"Models"}),c.jsx("p",{className:"text-sm text-[var(--color-text-muted)]",children:"Manage LLM models on the inference server"})]}),c.jsxs("section",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[c.jsx(LN,{size:16,className:"text-[var(--color-text-muted)]"}),c.jsx("h2",{className:"text-sm font-semibold text-[var(--color-text)]",children:"HuggingFace Token"}),c.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:"(optional, for gated models)"})]}),c.jsx("input",{type:"password",value:n,onChange:j=>r(j.target.value),placeholder:"hf_...",className:"w-full rounded-md border border-[var(--color-border)] bg-[var(--color-background)] px-3 py-2 text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]"})]}),c.jsxs("section",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[c.jsx(Rd,{size:16,className:"text-[var(--color-text-muted)]"}),c.jsx("h2",{className:"text-sm font-semibold text-[var(--color-text)]",children:"Installed Models"})]}),x?c.jsx("p",{className:"text-sm text-[var(--color-text-muted)]",children:"Loading..."}):v?.length?c.jsx("div",{className:"space-y-2",children:v.map(j=>c.jsxs("div",{className:"flex items-center justify-between rounded-md border border-[var(--color-border)] px-3 py-2",children:[c.jsxs("div",{children:[c.jsx("span",{className:"text-sm font-medium text-[var(--color-text)]",children:j.name}),c.jsx("span",{className:"ml-2 text-xs text-[var(--color-text-muted)]",children:j.sizeFormatted})]}),c.jsx("button",{onClick:()=>M(j.name),disabled:p.isPending,className:"rounded p-1 text-[var(--color-text-muted)] hover:bg-red-500/10 hover:text-red-500",children:c.jsx(Gx,{size:14})})]},j.name))}):c.jsx("p",{className:"text-sm text-[var(--color-text-muted)]",children:"No models installed yet"})]}),c.jsxs("section",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[c.jsx(ow,{size:16,className:"text-[var(--color-text-muted)]"}),c.jsx("h2",{className:"text-sm font-semibold text-[var(--color-text)]",children:"Suggested Models"})]}),c.jsx("div",{className:"space-y-3",children:ar.map(j=>{const R=v?.some(k=>k.name===j.ggufFilename||k.name.includes(j.ggufFilename));return c.jsxs("div",{className:"flex items-center justify-between rounded-md border border-[var(--color-border)] px-4 py-3",children:[c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-sm font-medium text-[var(--color-text)]",children:j.displayName}),c.jsxs("span",{className:"rounded bg-[var(--color-surface-alt)] px-1.5 py-0.5 text-xs text-[var(--color-text-muted)]",children:["~",j.sizeGguf]}),R&&c.jsx("span",{className:"rounded bg-green-500/10 px-1.5 py-0.5 text-xs text-green-500",children:"installed"})]}),c.jsxs("p",{className:"text-xs text-[var(--color-text-muted)]",children:[j.hfRepoGguf," / ",j.ggufFilename]}),c.jsxs("p",{className:"text-xs text-[var(--color-text-muted)]",children:["Prompt provider: ",c.jsx("code",{className:"text-[var(--color-primary)]",children:j.promptProvider})]})]}),c.jsxs("button",{onClick:()=>w(j.hfRepoGguf,j.ggufFilename),disabled:m!==null,className:ne("ml-4 flex items-center gap-1 rounded-md px-3 py-1.5 text-sm font-medium transition-colors",R?"border border-[var(--color-border)] text-[var(--color-text-muted)] hover:bg-[var(--color-surface-alt)]":"bg-[var(--color-primary)] text-white hover:opacity-90"),children:[c.jsx(fs,{size:14}),m===`${j.hfRepoGguf}/${j.ggufFilename}`?"Downloading...":R?"Re-download":"Download"]})]},j.id)})})]}),c.jsxs("section",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[c.jsx(fs,{size:16,className:"text-[var(--color-text-muted)]"}),c.jsx("h2",{className:"text-sm font-semibold text-[var(--color-text)]",children:"Download from HuggingFace"})]}),c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{children:[c.jsx("label",{className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"Repository (e.g. Qwen/Qwen3-14B-GGUF)"}),c.jsx("input",{value:s,onChange:j=>i(j.target.value),placeholder:"owner/repo-name",className:"w-full rounded-md border border-[var(--color-border)] bg-[var(--color-background)] px-3 py-2 text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"Filename (optional — downloads specific file instead of full repo)"}),c.jsx("input",{value:d,onChange:j=>f(j.target.value),placeholder:"model-name.gguf",className:"w-full rounded-md border border-[var(--color-border)] bg-[var(--color-background)] px-3 py-2 text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]"})]}),c.jsxs("button",{onClick:N,disabled:!s||m!==null,className:"flex items-center gap-2 rounded-md bg-[var(--color-primary)] px-4 py-2 text-sm font-medium text-white transition-colors hover:opacity-90 disabled:opacity-50",children:[c.jsx(fs,{size:14}),m===`${s}/${d}`?"Downloading...":"Download"]})]})]})]})}const qu={preflight:"Checking prerequisites",download:"Downloading update",binary:"Updating binary",restarting:"Restarting admin server",compose:"Updating configuration",pull:"Pulling images",restart:"Restarting services",verify:"Verifying health",done:"Complete"};function yE(){const n=tn(),{data:r,isLoading:s}=sv(),[i,d]=S.useState("idle"),[f,m]=S.useState([]),[g,v]=S.useState(null),x=S.useRef(null),y=S.useCallback(M=>{m(N=>[...N,M])},[]);S.useEffect(()=>{x.current&&(x.current.scrollTop=x.current.scrollHeight)},[f]);async function p(){d("preflight"),m([]),v(null);try{const M=localStorage.getItem("jarvis-admin:access_token")??localStorage.getItem("access_token"),N=await fetch("/api/update/apply",{method:"POST",headers:{Authorization:`Bearer ${M}`}});if(!N.ok||!N.body){const _=await N.text();throw new Error(_||`HTTP ${N.status}`)}const j=N.body.getReader(),R=new TextDecoder;let k="";for(;;){const{done:_,value:B}=await j.read();if(_)break;k+=R.decode(B,{stream:!0});const O=k.split(`
17
17
  `);k=O.pop()??"";for(const P of O)if(P.startsWith("data: "))try{const I=JSON.parse(P.slice(6));if(I.phase&&d(I.phase),I.message&&y({text:I.message,phase:I.phase}),I.stream&&I.text&&y({text:I.text.trim()}),I.restart){d("restarting"),y({text:"Admin server restarting with new version..."}),await bE(r?.latestVersion??""),d("done"),y({text:"Upgrade complete!"});return}if(I.done&&I.code!==0)throw new Error(I.error??"Upgrade failed");I.done&&I.code===0&&d("done")}catch(I){if(I instanceof SyntaxError)continue;throw I}}}catch(M){const N=M instanceof Error?M.message:String(M);v(N),d("error"),y({text:`Error: ${N}`})}}if(s)return c.jsx("div",{className:"flex min-h-[50vh] items-center justify-center",children:c.jsx(ua,{size:24,className:"animate-spin text-[var(--color-primary)]"})});const w=Object.keys(qu).filter(M=>{const N=Object.keys(qu),j=N.indexOf(i);return N.indexOf(M)<j});return c.jsxs("div",{className:"mx-auto max-w-3xl space-y-6 p-6",children:[c.jsxs("div",{children:[c.jsx("h1",{className:"text-2xl font-bold text-[var(--color-text)]",children:"Update Jarvis"}),r?.updateAvailable?c.jsxs("p",{className:"text-sm text-[var(--color-text-muted)]",children:["v",r.currentVersion," → v",r.latestVersion]}):c.jsxs("p",{className:"text-sm text-[var(--color-text-muted)]",children:["You're running the latest version (v",r?.currentVersion??"?",")"]})]}),i!=="idle"&&c.jsx("div",{className:"space-y-2 rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:Object.entries(qu).map(([M,N])=>{const j=M===i,R=w.includes(M),k=M===i&&i==="error";return c.jsxs("div",{className:"flex items-center gap-2",children:[R?c.jsx(bt,{size:16,className:"text-green-500"}):k?c.jsx(fa,{size:16,className:"text-red-500"}):j?c.jsx(ua,{size:16,className:"animate-spin text-[var(--color-primary)]"}):c.jsx("div",{className:"h-4 w-4 rounded-full border border-[var(--color-border)]"}),c.jsx("span",{className:ne("text-sm",j?"font-medium text-[var(--color-text)]":"text-[var(--color-text-muted)]",R&&"text-green-500"),children:N})]},M)})}),f.length>0&&c.jsx("div",{ref:x,className:"max-h-64 overflow-y-auto rounded-lg border border-[var(--color-border)] bg-[#0d1117] p-3 font-mono text-xs text-gray-300",children:f.map((M,N)=>c.jsx("div",{children:M.text},N))}),g&&c.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-red-500/10 px-3 py-2",children:[c.jsx(fa,{size:14,className:"text-red-500"}),c.jsx("span",{className:"text-sm text-red-500",children:g})]}),c.jsxs("div",{className:"flex gap-3",children:[i==="idle"&&r?.updateAvailable&&c.jsxs("button",{onClick:p,className:"flex items-center gap-2 rounded-lg bg-green-600 px-4 py-2 text-sm font-medium text-white hover:opacity-90",children:[c.jsx(Ux,{size:16}),"Update to v",r.latestVersion]}),i==="done"&&c.jsxs("button",{onClick:()=>n("/dashboard"),className:"flex items-center gap-2 rounded-lg bg-[var(--color-primary)] px-4 py-2 text-sm font-medium text-white hover:opacity-90",children:[c.jsx(bt,{size:16}),"Go to Dashboard"]}),i==="error"&&c.jsxs("button",{onClick:p,className:"flex items-center gap-2 rounded-lg bg-[var(--color-primary)] px-4 py-2 text-sm font-medium text-white hover:opacity-90",children:[c.jsx(da,{size:16}),"Retry"]})]})]})}async function bE(n,r=6e4){const s=Date.now()+r;for(;Date.now()<s;){await new Promise(i=>setTimeout(i,2e3));try{const i=await fetch("/health");if(i.ok){const d=await i.json();if(d.version&&d.version!=="0.0.0-dev")return}}catch{}}throw new Error("Admin server did not restart within 60 seconds")}const Gu={regenerate:"Regenerating compose from registry",apply:"Applying changes (docker compose up)",done:"Complete"};function SE(){const n=tn(),r=localStorage.getItem("jarvis-admin:access_token")??localStorage.getItem("access_token"),[s,i]=S.useState("loading_options"),[d,f]=S.useState([]),[m,g]=S.useState(null),v=S.useRef(null),[x,y]=S.useState([]),[p,w]=S.useState(!1),[M,N]=S.useState("https://relay.jarvisautomation.io"),j=S.useCallback(B=>{f(O=>[...O,B])},[]);S.useEffect(()=>{v.current&&(v.current.scrollTop=v.current.scrollHeight)},[d]),S.useEffect(()=>{async function B(){try{const O=await fetch("/api/install/reconcile/options",{headers:{Authorization:`Bearer ${r}`}});if(!O.ok)throw new Error(`HTTP ${O.status}`);const P=await O.json();y(P.services),w(P.relayEnabled),N(P.relayUrl||"https://relay.jarvisautomation.io"),i("options")}catch(O){g(O instanceof Error?O.message:"Failed to load options"),i("error")}}B()},[r]);function R(B){y(O=>O.map(P=>P.id===B?{...P,enabled:!P.enabled}:P))}async function k(){i("regenerate"),f([]),g(null);const B=x.filter(O=>O.enabled).map(O=>O.id);try{const O=await fetch("/api/install/reconcile",{method:"POST",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json"},body:JSON.stringify({enabledModules:B,relayEnabled:p,relayUrl:M})});if(!O.ok||!O.body){const $=await O.text();throw new Error($||`HTTP ${O.status}`)}const P=O.body.getReader(),I=new TextDecoder;let ee="";for(;;){const{done:$,value:W}=await P.read();if($)break;ee+=I.decode(W,{stream:!0});const re=ee.split(`
18
- `);ee=re.pop()??"";for(const se of re)if(se.startsWith("data: "))try{const ie=JSON.parse(se.slice(6));if(ie.phase&&i(ie.phase),ie.message&&j({text:ie.message,phase:ie.phase}),ie.stream&&ie.text&&j({text:ie.text.trim()}),ie.done&&ie.code!==0)throw new Error(ie.message??"Reconcile failed")}catch(ie){if(ie instanceof SyntaxError)continue;throw ie}}}catch(O){const P=O instanceof Error?O.message:String(O);g(P),i("error"),j({text:`Error: ${P}`})}}const _=Object.keys(Gu).filter(B=>{const O=Object.keys(Gu),P=O.indexOf(s);return O.indexOf(B)<P});return c.jsxs("div",{className:"mx-auto max-w-3xl space-y-6 p-6",children:[c.jsxs("div",{children:[c.jsx("h1",{className:"text-2xl font-bold text-[var(--color-text)]",children:"Sync Compose"}),c.jsxs("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:["Regenerate ",c.jsx("code",{className:"rounded bg-[var(--color-surface)] px-1.5 py-0.5 text-xs",children:"docker-compose.yml"})," from the latest service registry and apply changes to the running stack."]})]}),s==="loading_options"&&c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx(ua,{size:32,className:"animate-spin text-[var(--color-primary)]"})}),s==="options"&&c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[c.jsx("h2",{className:"mb-3 text-sm font-semibold text-[var(--color-text)]",children:"Services"}),c.jsx("div",{className:"space-y-2",children:x.map(B=>c.jsxs("button",{onClick:()=>R(B.id),className:"flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left hover:bg-[var(--color-bg-secondary)] transition-colors",children:[B.enabled?c.jsx(bt,{size:18,className:"shrink-0 text-[var(--color-primary)]"}):c.jsx(lr,{size:18,className:"shrink-0 text-[var(--color-text-muted)]"}),c.jsxs("div",{className:"min-w-0",children:[c.jsx("div",{className:"text-sm font-medium text-[var(--color-text)]",children:B.name}),c.jsx("div",{className:"text-xs text-[var(--color-text-muted)]",children:B.description})]})]},B.id))})]}),c.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[c.jsx("h2",{className:"mb-3 text-sm font-semibold text-[var(--color-text)]",children:"Integrations"}),c.jsxs("button",{onClick:()=>w(!p),className:"flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left hover:bg-[var(--color-bg-secondary)] transition-colors",children:[p?c.jsx(bt,{size:18,className:"shrink-0 text-[var(--color-primary)]"}):c.jsx(lr,{size:18,className:"shrink-0 text-[var(--color-text-muted)]"}),c.jsxs("div",{className:"min-w-0",children:[c.jsx("div",{className:"text-sm font-medium text-[var(--color-text)]",children:"Jarvis Relay"}),c.jsx("div",{className:"text-xs text-[var(--color-text-muted)]",children:"Routes OAuth callbacks through a cloud relay for external providers (Google, Spotify, etc.)"})]})]}),p&&c.jsxs("div",{className:"mt-2 px-3",children:[c.jsx("label",{className:"text-xs font-medium text-[var(--color-text-muted)]",children:"Relay URL"}),c.jsx("input",{type:"url",value:M,onChange:B=>N(B.target.value),placeholder:"https://relay.jarvisautomation.io",className:"mt-1 w-full rounded-md border border-[var(--color-border)] bg-[var(--color-bg)] px-3 py-1.5 text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]"})]})]})]}),s!=="loading_options"&&s!=="options"&&c.jsx("div",{className:"space-y-2 rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:Object.entries(Gu).map(([B,O])=>{const P=B===s,I=_.includes(B),ee=B===s&&s==="error";return c.jsxs("div",{className:"flex items-center gap-2",children:[I?c.jsx(bt,{size:16,className:"text-green-500"}):ee?c.jsx(fa,{size:16,className:"text-red-500"}):P?c.jsx(ua,{size:16,className:"animate-spin text-[var(--color-primary)]"}):c.jsx("div",{className:"h-4 w-4 rounded-full border border-[var(--color-border)]"}),c.jsx("span",{className:ne("text-sm",P?"font-medium text-[var(--color-text)]":"text-[var(--color-text-muted)]",I&&"text-green-500"),children:O})]},B)})}),d.length>0&&c.jsx("div",{ref:v,className:"max-h-64 overflow-y-auto rounded-lg border border-[var(--color-border)] bg-[#0d1117] p-3 font-mono text-xs text-gray-300",children:d.map((B,O)=>c.jsx("div",{children:B.text},O))}),m&&c.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-red-500/10 px-3 py-2",children:[c.jsx(fa,{size:14,className:"text-red-500"}),c.jsx("span",{className:"text-sm text-red-500",children:m})]}),c.jsxs("div",{className:"flex gap-3",children:[s==="options"&&c.jsxs("button",{onClick:k,className:"flex items-center gap-2 rounded-lg bg-[var(--color-primary)] px-4 py-2 text-sm font-medium text-white hover:opacity-90",children:[c.jsx(Bx,{size:16}),"Sync now"]}),s==="done"&&c.jsxs("button",{onClick:()=>n("/dashboard"),className:"flex items-center gap-2 rounded-lg bg-[var(--color-primary)] px-4 py-2 text-sm font-medium text-white hover:opacity-90",children:[c.jsx(bt,{size:16}),"Back to dashboard"]}),s==="error"&&c.jsxs("button",{onClick:k,className:"flex items-center gap-2 rounded-lg bg-[var(--color-primary)] px-4 py-2 text-sm font-medium text-white hover:opacity-90",children:[c.jsx(da,{size:16}),"Retry"]})]})]})}function NE(){return c.jsxs("div",{className:"flex min-h-[60vh] flex-col items-center justify-center",children:[c.jsx("h1",{className:"mb-2 text-4xl font-bold text-[var(--color-text)]",children:"404"}),c.jsx("p",{className:"mb-4 text-[var(--color-text-muted)]",children:"Page not found"}),c.jsx(hd,{to:"/settings",className:"text-[var(--color-primary)] underline hover:opacity-80",children:"Go to Settings"})]})}const wE=7,jE={currentStep:0,totalSteps:wE,enabledModules:[],portOverrides:{},infraPortOverrides:{},secrets:{},dbUser:"jarvis",whisperModel:"base.en",llmInterface:"Qwen25MediumUntrained",deploymentMode:"local",deploymentTarget:"standard",remoteLlmUrl:"",remoteWhisperUrl:"",platform:"linux",hardware:null,relayEnabled:!1,installRunning:!1,installComplete:!1};function EE(n,r,s){return Math.max(r,Math.min(s,n))}function TE(n,r){switch(r.type){case"SET_STEP":return{...n,currentStep:EE(r.step,0,n.totalSteps-1)};case"NEXT_STEP":return{...n,currentStep:Math.min(n.currentStep+1,n.totalSteps-1)};case"PREV_STEP":return{...n,currentStep:Math.max(n.currentStep-1,0)};case"SET_ENABLED_MODULES":return{...n,enabledModules:r.modules};case"TOGGLE_MODULE":{if(r.enabled){const s=n.enabledModules.includes(r.serviceId)?n.enabledModules:[...n.enabledModules,r.serviceId];return{...n,enabledModules:s}}return{...n,enabledModules:n.enabledModules.filter(s=>s!==r.serviceId)}}case"SET_PORT_OVERRIDE":return{...n,portOverrides:{...n.portOverrides,[r.serviceId]:r.port}};case"SET_INFRA_PORT_OVERRIDE":return{...n,infraPortOverrides:{...n.infraPortOverrides,[r.infraId]:r.port}};case"SET_SECRET":return{...n,secrets:{...n.secrets,[r.name]:r.value}};case"SET_SECRETS":return{...n,secrets:r.secrets};case"SET_DB_USER":return{...n,dbUser:r.user};case"SET_WHISPER_MODEL":return{...n,whisperModel:r.model};case"SET_LLM_INTERFACE":return{...n,llmInterface:r.interfaceId};case"SET_DEPLOYMENT_MODE":return{...n,deploymentMode:r.mode};case"SET_DEPLOYMENT_TARGET":return{...n,deploymentTarget:r.target};case"SET_REMOTE_LLM_URL":return{...n,remoteLlmUrl:r.url};case"SET_REMOTE_WHISPER_URL":return{...n,remoteWhisperUrl:r.url};case"SET_PLATFORM":return{...n,platform:r.platform};case"SET_HARDWARE":return{...n,hardware:r.hardware,platform:r.hardware.platform};case"SET_RELAY_ENABLED":return{...n,relayEnabled:r.enabled};case"SET_INSTALL_RUNNING":return{...n,installRunning:r.running};case"SET_INSTALL_COMPLETE":return{...n,installRunning:!1,installComplete:!0};default:return n}}const ov=S.createContext(null);function RE({children:n}){const[r,s]=S.useReducer(TE,jE);return c.jsx(ov.Provider,{value:{state:r,dispatch:s},children:n})}function ul(){const n=S.useContext(ov);if(!n)throw new Error("useWizard must be used within a WizardProvider");return n}function CE(){const{state:n,dispatch:r}=ul(),[s,i]=S.useState(null),[d,f]=S.useState(!0),[m,g]=S.useState(!1);function v(){f(!0),g(!1),Ad().then(y=>{i(y);const p=y.reason==="docker_not_found";g(p),r(p?{type:"SET_INSTALL_RUNNING",running:!0}:{type:"SET_INSTALL_RUNNING",running:!1})}).catch(()=>{i({configured:!1,reason:"error"}),g(!0),r({type:"SET_INSTALL_RUNNING",running:!0})}).finally(()=>f(!1))}S.useEffect(()=>{v()},[]);const x=s&&s.reason!=="docker_not_found";return c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-xl font-bold text-[var(--color-text)]",children:"Welcome to Jarvis"}),c.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:"Let's get your personal voice assistant up and running. This wizard will guide you through selecting services, configuring hardware, and starting everything up."})]}),c.jsx("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] p-4",children:c.jsxs("div",{className:"flex items-center gap-3",children:[d?c.jsx(ua,{size:20,className:"animate-spin text-[var(--color-primary)]"}):x?c.jsx(bt,{size:20,className:"text-green-500"}):c.jsx(Dx,{size:20,className:"text-red-500"}),c.jsxs("div",{className:"flex-1",children:[c.jsx("p",{className:"text-sm font-medium text-[var(--color-text)]",children:d?"Checking Docker...":x?"Docker is running":"Docker not found"}),!d&&!x&&c.jsxs("div",{className:"mt-1 space-y-1",children:[c.jsx("p",{className:"text-xs text-red-400",children:"Docker is required to run Jarvis services."}),c.jsxs("p",{className:"text-xs text-[var(--color-text-muted)]",children:["Install"," ",c.jsx("a",{href:"https://www.docker.com/products/docker-desktop/",target:"_blank",rel:"noopener noreferrer",className:"text-[var(--color-primary)] underline hover:no-underline",children:"Docker Desktop"})," ","for your platform, start it, then click Retry."]})]})]}),m&&!d&&c.jsxs("button",{type:"button",onClick:v,className:"flex items-center gap-1 rounded-md border border-[var(--color-border)] px-2 py-1 text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text)]",children:[c.jsx(fo,{size:12}),"Retry"]})]})}),c.jsxs("div",{children:[c.jsx("label",{className:"mb-2 block text-sm font-medium text-[var(--color-text)]",children:"Deployment Mode"}),c.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[c.jsxs("button",{type:"button",onClick:()=>r({type:"SET_DEPLOYMENT_MODE",mode:"local"}),className:ne("flex flex-col items-center gap-2 rounded-lg border p-4 transition-colors",n.deploymentMode==="local"?"border-[var(--color-primary)] bg-[var(--color-primary)]/10":"border-[var(--color-border)] hover:border-[var(--color-primary)]/50"),children:[c.jsx(XN,{size:24,className:"text-[var(--color-primary)]"}),c.jsx("span",{className:"text-sm font-medium text-[var(--color-text)]",children:"Local"}),c.jsx("span",{className:"text-xs text-center text-[var(--color-text-muted)]",children:"Everything on this machine"})]}),c.jsxs("button",{type:"button",onClick:()=>r({type:"SET_DEPLOYMENT_MODE",mode:"remote-llm"}),className:ne("flex flex-col items-center gap-2 rounded-lg border p-4 transition-colors",n.deploymentMode==="remote-llm"?"border-[var(--color-primary)] bg-[var(--color-primary)]/10":"border-[var(--color-border)] hover:border-[var(--color-primary)]/50"),children:[c.jsx(_d,{size:24,className:"text-[var(--color-primary)]"}),c.jsx("span",{className:"text-sm font-medium text-[var(--color-text)]",children:"Remote LLM"}),c.jsx("span",{className:"text-xs text-center text-[var(--color-text-muted)]",children:"LLM on separate GPU machine"})]})]})]})]})}const Yi=[{label:"None / CPU only",gpu:null,gpuType:"none",vramMb:null,backends:["gguf"],defaultBackend:"gguf"},{label:"NVIDIA RTX 4090 (24 GB)",gpu:"NVIDIA RTX 4090",gpuType:"nvidia",vramMb:24576,backends:["gguf","vllm"],defaultBackend:"gguf"},{label:"NVIDIA RTX 4080 (16 GB)",gpu:"NVIDIA RTX 4080",gpuType:"nvidia",vramMb:16384,backends:["gguf","vllm"],defaultBackend:"gguf"},{label:"NVIDIA RTX 4070 Ti (12 GB)",gpu:"NVIDIA RTX 4070 Ti",gpuType:"nvidia",vramMb:12288,backends:["gguf","vllm"],defaultBackend:"gguf"},{label:"NVIDIA RTX 3090 (24 GB)",gpu:"NVIDIA RTX 3090",gpuType:"nvidia",vramMb:24576,backends:["gguf","vllm"],defaultBackend:"gguf"},{label:"NVIDIA RTX 3080 (10 GB)",gpu:"NVIDIA RTX 3080",gpuType:"nvidia",vramMb:10240,backends:["gguf","vllm"],defaultBackend:"gguf"},{label:"NVIDIA RTX 3070 (8 GB)",gpu:"NVIDIA RTX 3070",gpuType:"nvidia",vramMb:8192,backends:["gguf","vllm"],defaultBackend:"gguf"},{label:"NVIDIA A100 (80 GB)",gpu:"NVIDIA A100",gpuType:"nvidia",vramMb:81920,backends:["gguf","vllm"],defaultBackend:"vllm"},{label:"NVIDIA A100 (40 GB)",gpu:"NVIDIA A100",gpuType:"nvidia",vramMb:40960,backends:["gguf","vllm"],defaultBackend:"vllm"},{label:"NVIDIA Tesla T4 (16 GB)",gpu:"NVIDIA Tesla T4",gpuType:"nvidia",vramMb:16384,backends:["gguf","vllm"],defaultBackend:"gguf"},{label:"AMD RX 9070 XT — Vulkan (16 GB)",gpu:"AMD RX 9070 XT",gpuType:"amd",vramMb:16384,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 9070 — Vulkan (12 GB)",gpu:"AMD RX 9070",gpuType:"amd",vramMb:12288,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 7900 XTX — Vulkan (24 GB)",gpu:"AMD RX 7900 XTX",gpuType:"amd",vramMb:24576,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 7900 XT — Vulkan (20 GB)",gpu:"AMD RX 7900 XT",gpuType:"amd",vramMb:20480,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 7800 XT — Vulkan (16 GB)",gpu:"AMD RX 7800 XT",gpuType:"amd",vramMb:16384,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 7600 — Vulkan (8 GB)",gpu:"AMD RX 7600",gpuType:"amd",vramMb:8192,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 9070 XT — ROCm (16 GB)",gpu:"AMD RX 9070 XT",gpuType:"amd-rocm",vramMb:16384,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 9070 — ROCm (12 GB)",gpu:"AMD RX 9070",gpuType:"amd-rocm",vramMb:12288,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 7900 XTX — ROCm (24 GB)",gpu:"AMD RX 7900 XTX",gpuType:"amd-rocm",vramMb:24576,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 7900 XT — ROCm (20 GB)",gpu:"AMD RX 7900 XT",gpuType:"amd-rocm",vramMb:20480,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 7800 XT — ROCm (16 GB)",gpu:"AMD RX 7800 XT",gpuType:"amd-rocm",vramMb:16384,backends:["gguf"],defaultBackend:"gguf"},{label:"Apple M4 Max (128 GB unified)",gpu:"Apple M4 Max",gpuType:"apple",vramMb:131072,backends:["gguf","mlx"],defaultBackend:"gguf"},{label:"Apple M4 Max (64 GB unified)",gpu:"Apple M4 Max",gpuType:"apple",vramMb:65536,backends:["gguf","mlx"],defaultBackend:"gguf"},{label:"Apple M4 Pro (48 GB unified)",gpu:"Apple M4 Pro",gpuType:"apple",vramMb:49152,backends:["gguf","mlx"],defaultBackend:"gguf"},{label:"Apple M4 Pro (24 GB unified)",gpu:"Apple M4 Pro",gpuType:"apple",vramMb:24576,backends:["gguf","mlx"],defaultBackend:"gguf"},{label:"Apple M2 Max (32 GB unified)",gpu:"Apple M2 Max",gpuType:"apple",vramMb:32768,backends:["gguf","mlx"],defaultBackend:"gguf"},{label:"Apple M2 Pro (16 GB unified)",gpu:"Apple M2 Pro",gpuType:"apple",vramMb:16384,backends:["gguf","mlx"],defaultBackend:"gguf"},{label:"Apple M1 (16 GB unified)",gpu:"Apple M1",gpuType:"apple",vramMb:16384,backends:["gguf","mlx"],defaultBackend:"gguf"},{label:"Apple M1 (8 GB unified)",gpu:"Apple M1",gpuType:"apple",vramMb:8192,backends:["gguf","mlx"],defaultBackend:"gguf"},{label:"Other (enter VRAM manually)",gpu:"Other",gpuType:"none",vramMb:null,backends:["gguf"],defaultBackend:"gguf"}];function _E(){const{state:n,dispatch:r}=ul(),[s,i]=S.useState(!n.hardware),[d,f]=S.useState(!1),[m,g]=S.useState(0),[v,x]=S.useState("");S.useEffect(()=>{n.hardware||Ij().then(w=>{r({type:"SET_HARDWARE",hardware:w}),w.recommendedBackend==="remote"&&n.deploymentMode==="local"&&r({type:"SET_DEPLOYMENT_MODE",mode:"remote-llm"})}).catch(()=>{}).finally(()=>i(!1))},[]);function y(w,M){const N=Yi[w];if(!n.hardware)return;const j=N.gpu==="Other"?(parseInt(M??v,10)||0)*1024:N.vramMb,R={...n.hardware,gpuName:N.gpu,gpuVramMb:j||null,gpuType:N.gpuType,recommendedBackends:[...N.backends],recommendedBackend:N.defaultBackend};r({type:"SET_HARDWARE",hardware:R})}const p=n.hardware;return s?c.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[c.jsx(ua,{size:32,className:"animate-spin text-[var(--color-primary)]"}),c.jsx("p",{className:"mt-3 text-sm text-[var(--color-text-muted)]",children:"Detecting hardware..."})]}):c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-xl font-bold text-[var(--color-text)]",children:"Hardware Detection"}),c.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:"We detected the following hardware. This determines which LLM backend to use."})]}),p&&c.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[c.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] p-4",children:[c.jsxs("div",{className:"flex items-center gap-2 text-[var(--color-text-muted)]",children:[c.jsx(ps,{size:16}),c.jsx("span",{className:"text-xs font-medium uppercase",children:"Platform"})]}),c.jsxs("p",{className:"mt-1 text-sm font-medium text-[var(--color-text)]",children:[p.platform==="darwin"?"macOS":"Linux"," (",p.arch,")"]})]}),c.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] p-4",children:[c.jsxs("div",{className:"flex items-center gap-2 text-[var(--color-text-muted)]",children:[c.jsx(Rd,{size:16}),c.jsx("span",{className:"text-xs font-medium uppercase",children:"Memory"})]}),c.jsxs("p",{className:"mt-1 text-sm font-medium text-[var(--color-text)]",children:[p.totalMemoryGb," GB RAM"]})]}),c.jsxs("div",{className:"col-span-2 rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] p-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center gap-2 text-[var(--color-text-muted)]",children:[c.jsx(ps,{size:16}),c.jsx("span",{className:"text-xs font-medium uppercase",children:"GPU"})]}),c.jsx("p",{className:"mt-1 text-sm font-medium text-[var(--color-text)]",children:p.gpuName??"No GPU detected"}),p.gpuVramMb!=null&&p.gpuVramMb>0&&c.jsxs("p",{className:"text-xs text-[var(--color-text-muted)]",children:[Math.round(p.gpuVramMb/1024)," GB VRAM"]})]}),c.jsx("button",{type:"button",onClick:()=>f(!d),className:"text-xs font-medium text-[var(--color-primary)] hover:underline",children:d?"Cancel":"Override"})]}),d&&c.jsxs("div",{className:"mt-3 space-y-3 border-t border-[var(--color-border)] pt-3",children:[c.jsxs("div",{children:[c.jsx("label",{htmlFor:"gpu-select",className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"Select GPU"}),c.jsx("select",{id:"gpu-select",value:m,onChange:w=>{const M=parseInt(w.target.value,10);g(M),Yi[M].gpu!=="Other"&&(y(M),f(!1))},className:ne("w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2","text-sm text-[var(--color-text)]","outline-none focus:ring-2 focus:ring-[var(--color-primary)]"),children:Yi.map((w,M)=>c.jsx("option",{value:M,children:w.label},`${w.label}-${M}`))})]}),Yi[m].gpu==="Other"&&c.jsxs("div",{className:"flex items-end gap-2",children:[c.jsxs("div",{className:"flex-1",children:[c.jsx("label",{htmlFor:"custom-vram",className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"VRAM (GB)"}),c.jsx("input",{id:"custom-vram",type:"number",min:1,max:512,value:v,onChange:w=>x(w.target.value),placeholder:"e.g. 24",className:ne("w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2","text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]","outline-none focus:ring-2 focus:ring-[var(--color-primary)]")})]}),c.jsx("button",{type:"button",disabled:!v||parseInt(v,10)<=0,onClick:()=>{y(m,v),f(!1)},className:ne("rounded-lg px-4 py-2 text-sm font-medium","bg-[var(--color-primary)] text-white","disabled:cursor-not-allowed disabled:opacity-50"),children:"Apply"})]})]})]}),c.jsxs("div",{className:"col-span-2 rounded-lg border border-[var(--color-primary)]/30 bg-[var(--color-primary)]/5 p-4",children:[c.jsxs("p",{className:"text-sm font-medium text-[var(--color-text)]",children:["Recommended: ",c.jsx("span",{className:"text-[var(--color-primary)]",children:p.recommendedBackend.toUpperCase()})]}),p.recommendedBackends.length>1&&c.jsxs("p",{className:"mt-0.5 text-xs text-[var(--color-text-muted)]",children:["Available backends: ",p.recommendedBackends.join(", ")]})]})]}),n.deploymentMode==="remote-llm"&&c.jsxs("div",{className:"space-y-3",children:[c.jsx("h3",{className:"text-sm font-medium text-[var(--color-text)]",children:"Remote Service URLs"}),c.jsxs("div",{children:[c.jsx("label",{htmlFor:"remote-llm",className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"LLM Proxy URL"}),c.jsx("input",{id:"remote-llm",type:"url",value:n.remoteLlmUrl,onChange:w=>r({type:"SET_REMOTE_LLM_URL",url:w.target.value}),placeholder:"http://192.168.1.100:7704",className:ne("w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2","text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]","outline-none focus:ring-2 focus:ring-[var(--color-primary)]")})]}),c.jsxs("div",{children:[c.jsx("label",{htmlFor:"remote-whisper",className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"Whisper URL (optional)"}),c.jsx("input",{id:"remote-whisper",type:"url",value:n.remoteWhisperUrl,onChange:w=>r({type:"SET_REMOTE_WHISPER_URL",url:w.target.value}),placeholder:"http://192.168.1.100:7706",className:ne("w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2","text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]","outline-none focus:ring-2 focus:ring-[var(--color-primary)]")})]})]})]})}function ME(){const{state:n,dispatch:r}=ul(),[s,i]=S.useState(null),[d,f]=S.useState(!0);if(S.useEffect(()=>{Promise.all([rv(),Wj()]).then(([x,y])=>{i(x),n.enabledModules.length===0&&r({type:"SET_ENABLED_MODULES",modules:y.enabledModules})}).catch(()=>{}).finally(()=>f(!1))},[]),d||!s)return c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx(ua,{size:32,className:"animate-spin text-[var(--color-primary)]"})});const{core:m,recommended:g,optional:v}=AE(s.services);return c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-xl font-bold text-[var(--color-text)]",children:"Select Services"}),c.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:"Core services are always included. Toggle recommended and optional services."})]}),c.jsx(Qu,{title:"Core",subtitle:"Always included",services:m,enabled:m.map(x=>x.id),locked:!0}),c.jsx(Qu,{title:"Recommended",subtitle:"Enabled by default",services:g,enabled:n.enabledModules,onToggle:(x,y)=>r({type:"TOGGLE_MODULE",serviceId:x,enabled:y}),platform:n.platform}),v.length>0&&c.jsx(Qu,{title:"Optional",subtitle:"Off by default",services:v,enabled:n.enabledModules,onToggle:(x,y)=>r({type:"TOGGLE_MODULE",serviceId:x,enabled:y})}),c.jsxs("div",{children:[c.jsxs("div",{className:"mb-2 flex items-baseline gap-2",children:[c.jsx("h3",{className:"text-sm font-medium text-[var(--color-text)]",children:"Integrations"}),c.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:"Cloud services"})]}),c.jsxs("button",{type:"button",onClick:()=>r({type:"SET_RELAY_ENABLED",enabled:!n.relayEnabled}),className:ne("flex w-full items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors",n.relayEnabled?"border-[var(--color-primary)]/30 bg-[var(--color-primary)]/5":"border-[var(--color-border)] hover:border-[var(--color-primary)]/30"),children:[n.relayEnabled?c.jsx(bt,{size:16,className:"shrink-0 text-[var(--color-primary)]"}):c.jsx(lr,{size:16,className:"shrink-0 text-[var(--color-text-muted)]"}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-sm font-medium text-[var(--color-text)]",children:"Jarvis Relay"}),c.jsx(ON,{size:12,className:"text-[var(--color-text-muted)]"})]}),c.jsx("p",{className:"text-xs text-[var(--color-text-muted)]",children:"Routes OAuth callbacks through a cloud relay for external providers (Google, Spotify, etc.)"})]})]})]})]})}function AE(n){return{core:n.filter(r=>r.category==="core"),recommended:n.filter(r=>r.category==="recommended"),optional:n.filter(r=>r.category==="optional")}}function Qu({title:n,subtitle:r,services:s,enabled:i,locked:d,onToggle:f,platform:m}){return c.jsxs("div",{children:[c.jsxs("div",{className:"mb-2 flex items-baseline gap-2",children:[c.jsx("h3",{className:"text-sm font-medium text-[var(--color-text)]",children:n}),c.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:r})]}),c.jsx("div",{className:"space-y-1",children:s.map(g=>{const v=i.includes(g.id),x=g.nativeOnly&&m==="darwin";return c.jsxs("button",{type:"button",disabled:d,onClick:()=>f?.(g.id,!v),className:ne("flex w-full items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors",v?"border-[var(--color-primary)]/30 bg-[var(--color-primary)]/5":"border-[var(--color-border)] hover:border-[var(--color-primary)]/30",d&&"cursor-default"),children:[d?c.jsx(Cd,{size:16,className:"shrink-0 text-[var(--color-text-muted)]"}):v?c.jsx(bt,{size:16,className:"shrink-0 text-[var(--color-primary)]"}):c.jsx(lr,{size:16,className:"shrink-0 text-[var(--color-text-muted)]"}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-sm font-medium text-[var(--color-text)]",children:g.name}),c.jsxs("span",{className:"text-xs text-[var(--color-text-muted)]",children:[":",g.port]}),x&&c.jsx("span",{className:"rounded bg-amber-500/10 px-1.5 py-0.5 text-[10px] font-medium text-amber-500",children:"Native"})]}),c.jsx("p",{className:"truncate text-xs text-[var(--color-text-muted)]",children:g.description})]})]},g.id)})})]})}function OE(){const{state:n}=ul(),[r,s]=S.useState(null);if(S.useEffect(()=>{rv().then(s).catch(()=>{})},[]),!r)return c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx(ua,{size:32,className:"animate-spin text-[var(--color-primary)]"})});const i=r.services.filter(p=>p.category==="core"),d=r.services.filter(p=>p.category!=="core"&&n.enabledModules.includes(p.id)),f=[...i,...d],m=new Map;for(const p of f){const w=n.portOverrides[p.id]??p.port,M=m.get(w)??[];m.set(w,[...M,p.name])}const g=[...m.entries()].filter(([,p])=>p.length>1),v=f.filter(p=>p.database).length,x=f.filter(p=>p.nativeOnly&&n.platform==="darwin"),y=f.filter(p=>!(p.nativeOnly&&n.platform==="darwin"));return c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-xl font-bold text-[var(--color-text)]",children:"Review Configuration"}),c.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:"Review your selections before installing."})]}),c.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[c.jsx(Vu,{label:"Docker Services",value:y.length}),c.jsx(Vu,{label:"Native Services",value:x.length}),c.jsx(Vu,{label:"Databases",value:v})]}),c.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] p-4",children:[c.jsx("p",{className:"text-xs font-medium uppercase text-[var(--color-text-muted)]",children:"Deployment Mode"}),c.jsx("p",{className:"mt-1 text-sm font-medium text-[var(--color-text)]",children:n.deploymentMode==="local"?"Local (all services on this machine)":"Remote LLM"}),n.deploymentMode==="remote-llm"&&n.remoteLlmUrl&&c.jsxs("p",{className:"mt-0.5 text-xs text-[var(--color-text-muted)]",children:["LLM: ",n.remoteLlmUrl]})]}),c.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] overflow-hidden",children:[c.jsx("div",{className:"border-b border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2",children:c.jsxs("span",{className:"text-xs font-medium text-[var(--color-text-muted)]",children:["Services (",f.length,")"]})}),c.jsx("div",{className:"divide-y divide-[var(--color-border)]",children:f.map(p=>c.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(bt,{size:14,className:"text-green-500"}),c.jsx("span",{className:"text-sm text-[var(--color-text)]",children:p.name})]}),c.jsxs("span",{className:"text-xs text-[var(--color-text-muted)]",children:[":",n.portOverrides[p.id]??p.port]})]},p.id))})]}),n.relayEnabled&&c.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] p-4",children:[c.jsx("p",{className:"text-xs font-medium uppercase text-[var(--color-text-muted)]",children:"Jarvis Relay"}),c.jsx("p",{className:"mt-1 text-sm font-medium text-[var(--color-text)]",children:"Enabled"}),c.jsx("p",{className:"mt-0.5 text-xs text-[var(--color-text-muted)]",children:"https://relay.jarvisautomation.io"})]}),g.length>0&&c.jsxs("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 p-4",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(fa,{size:16,className:"text-amber-500"}),c.jsx("span",{className:"text-sm font-medium text-amber-500",children:"Port Conflicts"})]}),g.map(([p,w])=>c.jsxs("p",{className:"mt-1 text-xs text-[var(--color-text-muted)]",children:["Port ",p,": ",w.join(", ")]},p))]})]})}function Vu({label:n,value:r}){return c.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] p-3 text-center",children:[c.jsx("p",{className:"text-2xl font-bold text-[var(--color-primary)]",children:r}),c.jsx("p",{className:"text-xs text-[var(--color-text-muted)]",children:n})]})}function Rg(){const[n,r]=S.useState({lines:[],running:!1,done:!1,exitCode:null,error:null,redirect:null}),s=S.useRef(null),i=S.useCallback((f,m)=>(s.current?.close(),r({lines:[],running:!0,done:!1,exitCode:null,error:null,redirect:null}),new Promise((g,v)=>{const x=new EventSource(f);s.current=x,x.onmessage=y=>{try{const p=JSON.parse(y.data);if(m&&m(p),"done"in p){if(r(w=>({...w,running:!1,done:!0,exitCode:p.code,redirect:p.redirect??null})),x.close(),p.code===0)g(p.code);else{const w=p.error?String(p.error):`Process exited with code ${p.code}`;v(new Error(w))}return}if("stream"in p&&"text"in p){const w={stream:p.stream,text:p.text,timestamp:Date.now()};r(M=>({...M,lines:[...M.lines,w]}))}}catch{}},x.onerror=()=>{const y=s.current===null;r(p=>({...p,running:!1,error:p.done?null:"Connection lost"})),x.close(),y||v(new Error("Connection lost"))}})),[]),d=S.useCallback(()=>{s.current?.close(),s.current=null,r(f=>({...f,running:!1}))},[]);return{...n,run:i,stop:d}}function Cg({lines:n,running:r,title:s,className:i}){const d=S.useRef(null),f=S.useRef(!0);S.useEffect(()=>{const g=d.current;!g||!f.current||(g.scrollTop=g.scrollHeight)},[n]);function m(){const g=d.current;if(!g)return;const v=g.scrollHeight-g.scrollTop-g.clientHeight;f.current=v<50}return c.jsxs("div",{className:ne("flex flex-col rounded-lg border border-[var(--color-border)] overflow-hidden",i),children:[s&&c.jsxs("div",{className:"flex items-center gap-2 border-b border-[var(--color-border)] bg-[var(--color-surface)] px-3 py-2",children:[c.jsx("span",{className:"text-xs font-medium text-[var(--color-text-muted)]",children:s}),r&&c.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-green-500"})]}),c.jsxs("div",{ref:d,onScroll:m,className:"h-64 overflow-y-auto bg-[#0d1117] p-3 font-mono text-xs leading-5",children:[n.length===0&&!r&&c.jsx("span",{className:"text-gray-500",children:"Waiting for output..."}),n.map((g,v)=>c.jsx("div",{className:ne("whitespace-pre-wrap break-all",g.stream==="stderr"?"text-yellow-400":"text-gray-300"),children:g.text},v)),r&&c.jsx("span",{className:"inline-block h-4 w-1.5 animate-pulse bg-gray-400"})]})]})}function zE(){const{state:n,dispatch:r}=ul(),s=Rg(),i=Rg(),[d,f]=S.useState("idle"),[m,g]=S.useState(null),[v,x]=S.useState(null),[y,p]=S.useState({}),[w,M]=S.useState({}),[N,j]=S.useState(null),[R,k]=S.useState(null);S.useEffect(()=>{const W=i.redirect;if(d!=="done"||!W)return;k(5);const re=setInterval(()=>{k(se=>se===null||se<=1?(clearInterval(re),window.location.href=W,0):se-1)},1e3);return()=>clearInterval(re)},[d,i.redirect]);const _=S.useCallback(async()=>{f("preflight"),x(null),g(null);try{const W=await Pj(n.enabledModules);return x(W),W.canProceed?!0:(g("Pre-flight checks failed. Fix the issues above and retry."),f("error"),j("preflight"),!1)}catch(W){return g(`Pre-flight check failed: ${W instanceof Error?W.message:String(W)}`),f("error"),j("preflight"),!1}},[n.enabledModules]);async function B(){g(null),p({}),j(null),r({type:"SET_INSTALL_RUNNING",running:!0});try{if(!await _()){r({type:"SET_INSTALL_RUNNING",running:!1});return}f("generating"),await wg(n),f("pulling"),await s.run("/api/install/pull"),f("starting"),await i.run("/api/install/start",re=>{if(re.phase==="health"&&typeof re.service=="string"&&p(se=>({...se,[re.service]:{healthy:re.healthy,error:re.error}})),re.serviceHealth&&typeof re.serviceHealth=="object"){const se=re.serviceHealth;p(ie=>({...ie,...se}))}}),f("done"),r({type:"SET_INSTALL_COMPLETE"})}catch(W){g(W instanceof Error?W.message:String(W)),f("error"),j(d),r({type:"SET_INSTALL_RUNNING",running:!1})}}async function O(){if(N==="preflight"){if(g(null),r({type:"SET_INSTALL_RUNNING",running:!0}),!await _()){r({type:"SET_INSTALL_RUNNING",running:!1});return}try{f("generating"),await wg(n),f("pulling"),await s.run("/api/install/pull"),f("starting"),await i.run("/api/install/start",re=>{if(re.phase==="health"&&typeof re.service=="string"&&p(se=>({...se,[re.service]:{healthy:re.healthy,error:re.error}})),re.serviceHealth&&typeof re.serviceHealth=="object"){const se=re.serviceHealth;p(ie=>({...ie,...se}))}}),f("done"),r({type:"SET_INSTALL_COMPLETE"})}catch(re){g(re instanceof Error?re.message:String(re)),f("error"),r({type:"SET_INSTALL_RUNNING",running:!1})}}else B()}async function P(W){try{const re=await fetch(`/api/containers/${W}/logs`);if(re.ok){const se=await re.text();M(ie=>({...ie,[W]:se}))}else M(se=>({...se,[W]:`Failed to fetch logs: HTTP ${re.status}`}))}catch(re){M(se=>({...se,[W]:`Failed to fetch logs: ${re instanceof Error?re.message:String(re)}`}))}}const I=[{key:"preflight",label:"Pre-flight checks"},{key:"generating",label:"Generate configuration"},{key:"pulling",label:"Pull Docker images"},{key:"starting",label:"Start services"}],$=I.map(W=>W.key).indexOf(d);return c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-xl font-bold text-[var(--color-text)]",children:"Install"}),c.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:d==="idle"?"Ready to install. This will pull Docker images and start all services.":d==="done"?i.redirect?`Installation complete! Redirecting to your admin dashboard in ${R??"..."}s...`:"Installation complete! All services are running.":d==="error"?"Installation encountered an error.":"Installing..."})]}),v&&c.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] overflow-hidden",children:[c.jsx("div",{className:"border-b border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2",children:c.jsx("span",{className:"text-xs font-medium text-[var(--color-text-muted)]",children:"Pre-flight Checks"})}),c.jsx("div",{className:"divide-y divide-[var(--color-border)]",children:v.checks.map(W=>c.jsx("div",{className:"flex items-center justify-between px-3 py-2",children:c.jsxs("div",{className:"flex items-center gap-2",children:[W.status==="pass"?c.jsx(bt,{size:14,className:"text-green-500"}):W.status==="warn"?c.jsx(fa,{size:14,className:"text-amber-500"}):c.jsx(Pi,{size:14,className:"text-red-500"}),c.jsxs("div",{children:[c.jsx("span",{className:"text-sm text-[var(--color-text)]",children:W.name}),c.jsx("p",{className:"text-xs text-[var(--color-text-muted)]",children:W.message}),W.details&&W.status!=="pass"&&c.jsx("p",{className:"text-xs text-[var(--color-text-muted)] opacity-60",children:W.details})]})]})},W.name))})]}),c.jsx("div",{className:"space-y-2",children:I.map((W,re)=>{const se=W.key===d,ie=$>re||d==="done",Ae=d==="error"&&W.key===N;return c.jsxs("div",{className:"flex items-center gap-3",children:[ie?c.jsx(bt,{size:18,className:"text-green-500"}):Ae?c.jsx(Pi,{size:18,className:"text-red-500"}):se?c.jsx(ua,{size:18,className:"animate-spin text-[var(--color-primary)]"}):c.jsx("div",{className:"h-[18px] w-[18px] rounded-full border-2 border-[var(--color-border)]"}),c.jsx("span",{className:ne("text-sm",ie?"text-green-500":se?"font-medium text-[var(--color-text)]":"text-[var(--color-text-muted)]"),children:W.label})]},W.key)})}),(d==="starting"||d==="done"||d==="error")&&Object.keys(y).length>0&&c.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] overflow-hidden",children:[c.jsx("div",{className:"border-b border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2",children:c.jsx("span",{className:"text-xs font-medium text-[var(--color-text-muted)]",children:"Service Status"})}),c.jsx("div",{className:"divide-y divide-[var(--color-border)]",children:Object.entries(y).map(([W,re])=>c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[c.jsx("span",{className:"text-sm text-[var(--color-text)]",children:W}),c.jsxs("div",{className:"flex items-center gap-2",children:[!re.healthy&&c.jsxs("button",{type:"button",onClick:()=>P(W),className:"flex items-center gap-1 text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text)]",children:[c.jsx(_N,{size:12}),"Logs"]}),re.healthy?c.jsx(bt,{size:14,className:"text-green-500"}):c.jsx(Pi,{size:14,className:"text-red-500"})]})]}),re.error&&c.jsx("p",{className:"px-3 pb-2 text-xs text-red-400",children:re.error}),w[W]&&c.jsx("div",{className:"mx-3 mb-2 max-h-32 overflow-auto rounded bg-[var(--color-background)] p-2 text-xs font-mono text-[var(--color-text-muted)]",children:c.jsx("pre",{className:"whitespace-pre-wrap",children:w[W]})})]},W))})]}),(s.lines.length>0||s.running)&&c.jsx(Cg,{lines:s.lines,running:s.running,title:"docker compose pull"}),(i.lines.length>0||i.running)&&c.jsx(Cg,{lines:i.lines,running:i.running,title:"docker compose up -d"}),m&&c.jsx("div",{className:"rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-500",children:m}),(d==="idle"||d==="error")&&c.jsxs("button",{type:"button",onClick:d==="error"?O:B,className:ne("flex w-full items-center justify-center gap-2 rounded-lg bg-[var(--color-primary)] px-4 py-3 font-medium text-white","hover:opacity-90 transition-opacity"),children:[d==="error"?c.jsx(fo,{size:18}):c.jsx(PN,{size:18}),d==="error"?"Retry Installation":"Start Installation"]})]})}function kE(){const{state:n,dispatch:r}=ul(),s=lv(),i=iv(),[d,f]=S.useState("select"),[m,g]=S.useState(null),[v,x]=S.useState("GGUF"),[y,p]=S.useState(""),[w,M]=S.useState(null);if(n.deploymentMode==="remote-llm")return c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-xl font-bold text-[var(--color-text)]",children:"LLM Configuration"}),c.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:"Your LLM is configured to use a remote server."})]}),c.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-green-500/30 bg-green-500/5 p-4",children:[c.jsx(bt,{size:20,className:"text-green-500"}),c.jsxs("div",{children:[c.jsx("p",{className:"text-sm font-medium text-[var(--color-text)]",children:"Remote LLM configured"}),c.jsx("p",{className:"text-xs text-[var(--color-text-muted)]",children:n.remoteLlmUrl})]})]})]});if(n.platform==="darwin")return c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-xl font-bold text-[var(--color-text)]",children:"LLM Configuration"}),c.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:"On macOS, the LLM proxy runs natively to access Metal/MLX. Configure it from the dashboard after setup, or run it directly from the jarvis-llm-proxy-api directory."})]}),c.jsx("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 p-4 text-sm text-amber-500",children:"macOS native LLM proxy is not yet available as a pip package. Model download through this wizard requires the LLM proxy running in Docker."})]});const N=O=>{g(O),M(null),O.gated&&!y.trim()?f("token"):R(O,y.trim())},j=()=>{if(!y.trim()){M("HuggingFace token is required for gated models");return}m&&R(m,y)},R=async(O,P)=>{f("downloading"),M(null);const I=v==="GGUF"?O.hfRepoGguf:O.hfRepoVllm,ee=v==="GGUF"?O.ggufFilename:void 0;try{await i.mutateAsync({repo:I,filename:ee,token:P||void 0}),await k(O)}catch($){M(`Download failed: ${$.message}`),f("select")}},k=async O=>{f("configuring");const I={"model.main.name":v==="GGUF"?`.models/${O.ggufFilename}`:`.models/${O.hfRepoVllm.split("/").pop()}`,"model.main.backend":v,"model.main.chat_format":O.chatFormat,"model.main.context_window":O.contextWindow,"llm.interface":O.promptProvider};v==="GGUF"&&(I["inference.gguf.n_gpu_layers"]=-1),v==="VLLM"&&O.quantization&&(I["inference.vllm.quantization"]=O.quantization);try{await s.mutateAsync(I),r({type:"SET_LLM_INTERFACE",interfaceId:O.promptProvider}),f("done")}catch(ee){M(`Configuration failed: ${ee.message}`),f("select")}},_=n.hardware?.gpuVramMb,B=_?ar.filter(O=>O.vramMb<=_):ar;return c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-xl font-bold text-[var(--color-text)]",children:"LLM Setup"}),c.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:d==="done"?"Model configured. The LLM proxy is restarting with the new model.":"Select and download a language model for Jarvis."})]}),w&&c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-red-500/30 bg-red-500/10 p-3 text-sm text-red-500",children:[c.jsx(fa,{size:16,className:"mt-0.5 shrink-0"}),w]}),m&&c.jsxs("button",{type:"button",onClick:()=>R(m,y),className:ne("flex w-full items-center justify-center gap-2 rounded-lg border border-[var(--color-border)] px-4 py-2 text-sm","hover:bg-[var(--color-surface-alt)] transition-colors"),children:[c.jsx(fo,{size:14}),"Retry Download"]})]}),d==="select"&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm font-medium text-[var(--color-text)]",children:"Backend"}),c.jsx("div",{className:"flex gap-2",children:["GGUF","VLLM"].map(O=>c.jsx("button",{type:"button",onClick:()=>x(O),className:ne("rounded-md px-3 py-1 text-xs font-medium transition-colors",v===O?"bg-[var(--color-primary)] text-white":"bg-[var(--color-surface-alt)] text-[var(--color-text-muted)] hover:text-[var(--color-text)]"),children:O==="VLLM"?"vLLM":O},O))})]}),c.jsxs("div",{children:[c.jsx("label",{htmlFor:"hf-token",className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"HuggingFace Token (optional — speeds up downloads, required for gated models)"}),c.jsx("input",{id:"hf-token",type:"password",value:y,onChange:O=>p(O.target.value),placeholder:"hf_...",className:ne("w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2","text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]","outline-none focus:ring-2 focus:ring-[var(--color-primary)]")})]}),c.jsxs("div",{className:"space-y-2",children:[B.map(O=>c.jsxs("button",{type:"button",onClick:()=>N(O),className:ne("flex w-full items-center justify-between rounded-lg border border-[var(--color-border)] p-3 text-left transition-colors","hover:border-[var(--color-primary)] hover:bg-[var(--color-surface-alt)]"),children:[c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-sm font-medium text-[var(--color-text)]",children:O.displayName}),O.gated&&c.jsxs("span",{className:"flex items-center gap-0.5 rounded bg-yellow-500/15 px-1.5 py-0.5 text-[10px] font-medium text-yellow-600 dark:text-yellow-400",children:[c.jsx(Cd,{size:10}),"Gated"]})]}),c.jsxs("p",{className:"mt-0.5 text-xs text-[var(--color-text-muted)]",children:[O.promptProvider," · ",O.contextWindow.toLocaleString()," ctx"]})]}),c.jsxs("span",{className:"text-xs text-[var(--color-text-muted)]",children:["~",v==="GGUF"?O.sizeGguf:O.sizeVllm]})]},O.id)),B.length===0&&c.jsxs("p",{className:"py-4 text-center text-sm text-[var(--color-text-muted)]",children:["No models fit your available VRAM (",_?Math.round(_/1024)+" GB":"unknown","). Consider using Remote LLM mode."]}),_&&B.length<ar.length&&c.jsxs("p",{className:"text-xs text-[var(--color-text-muted)]",children:["Showing ",B.length," of ",ar.length," models that fit your ",Math.round(_/1024)," GB VRAM."]})]})]}),d==="token"&&m&&c.jsxs("div",{className:"space-y-4",children:[c.jsxs("p",{className:"text-sm text-[var(--color-text-muted)]",children:[c.jsx("strong",{children:m.displayName})," is a gated model. Accept the license on HuggingFace and paste your access token below."]}),c.jsx("input",{type:"password",value:y,onChange:O=>p(O.target.value),placeholder:"hf_...",className:ne("w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2","text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]","outline-none focus:ring-2 focus:ring-[var(--color-primary)]")}),c.jsxs("div",{className:"flex justify-between",children:[c.jsx("button",{type:"button",onClick:()=>{f("select"),M(null)},className:"text-sm text-[var(--color-text-muted)] hover:text-[var(--color-text)]",children:"Back"}),c.jsx("button",{type:"button",onClick:j,className:"rounded-lg bg-[var(--color-primary)] px-4 py-2 text-sm text-white hover:opacity-90",children:"Download"})]})]}),d==="downloading"&&c.jsxs("div",{className:"flex flex-col items-center py-8",children:[c.jsx(fs,{className:"mb-4 animate-bounce text-[var(--color-primary)]",size:32}),c.jsxs("p",{className:"text-sm font-medium text-[var(--color-text)]",children:["Downloading ",m?.displayName,"..."]}),c.jsxs("p",{className:"mt-1 text-xs text-[var(--color-text-muted)]",children:["~",v==="GGUF"?m?.sizeGguf:m?.sizeVllm," · This may take several minutes"]})]}),d==="configuring"&&c.jsxs("div",{className:"flex flex-col items-center py-8",children:[c.jsx(ua,{className:"mb-4 animate-spin text-[var(--color-primary)]",size:32}),c.jsx("p",{className:"text-sm font-medium text-[var(--color-text)]",children:"Configuring model and prompt provider..."})]}),d==="done"&&m&&c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-green-500/30 bg-green-500/5 p-4",children:[c.jsx(bt,{size:20,className:"text-green-500"}),c.jsxs("div",{children:[c.jsxs("p",{className:"text-sm font-medium text-[var(--color-text)]",children:[m.displayName," configured"]}),c.jsxs("p",{className:"text-xs text-[var(--color-text-muted)]",children:["Backend: ",v," · Prompt provider: ",m.promptProvider]})]})]}),c.jsxs("p",{className:"text-xs text-[var(--color-text-muted)]",children:["The LLM proxy is restarting with the new model. It may take a minute to load. Command Center will automatically use the ",c.jsx("strong",{children:m.promptProvider})," prompt provider for optimized command parsing."]})]})]})}function DE(){const[n,r]=S.useState(""),[s,i]=S.useState(""),[d,f]=S.useState(""),[m,g]=S.useState(""),[v,x]=S.useState(!1),[y,p]=S.useState(!1),[w,M]=S.useState(null),N=s===d,j=n&&s&&d&&m&&N&&!v;async function R(){if(j){x(!0),M(null);try{const _=await Ax(n,s,m);tr(_.access_token),localStorage.setItem("access_token",_.access_token),localStorage.setItem("refresh_token",_.refresh_token),p(!0)}catch(_){const B=_?.response?.data?.error??(_ instanceof Error?_.message:"Failed to create account");M(B)}finally{x(!1)}}}if(y)return c.jsxs("div",{className:"space-y-6",children:[c.jsx("div",{children:c.jsx("h2",{className:"text-xl font-bold text-[var(--color-text)]",children:"Account Created"})}),c.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-green-500/30 bg-green-500/5 p-4",children:[c.jsx(bt,{size:20,className:"text-green-500"}),c.jsxs("div",{children:[c.jsx("p",{className:"text-sm font-medium text-[var(--color-text)]",children:"Superuser account created"}),c.jsx("p",{className:"text-xs text-[var(--color-text-muted)]",children:n})]})]}),c.jsx("p",{className:"text-sm text-[var(--color-text-muted)]",children:`You're logged in. Click "Next" to configure your LLM model.`})]});const k=ne("w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2","text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]","outline-none focus:ring-2 focus:ring-[var(--color-primary)]");return c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-xl font-bold text-[var(--color-text)]",children:"Create Account"}),c.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:"Create your superuser account. This will be the admin for your Jarvis instance."})]}),c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{children:[c.jsx("label",{htmlFor:"display-name",className:"mb-1 block text-sm text-[var(--color-text-muted)]",children:"Display Name"}),c.jsx("input",{id:"display-name",type:"text",value:m,onChange:_=>g(_.target.value),className:k,placeholder:"Alex"})]}),c.jsxs("div",{children:[c.jsx("label",{htmlFor:"email",className:"mb-1 block text-sm text-[var(--color-text-muted)]",children:"Email"}),c.jsx("input",{id:"email",type:"email",value:n,onChange:_=>r(_.target.value),className:k,placeholder:"admin@example.com"})]}),c.jsxs("div",{children:[c.jsx("label",{htmlFor:"password",className:"mb-1 block text-sm text-[var(--color-text-muted)]",children:"Password"}),c.jsx("input",{id:"password",type:"password",value:s,onChange:_=>i(_.target.value),className:k,placeholder:"Choose a strong password"})]}),c.jsxs("div",{children:[c.jsx("label",{htmlFor:"confirm-password",className:"mb-1 block text-sm text-[var(--color-text-muted)]",children:"Confirm Password"}),c.jsx("input",{id:"confirm-password",type:"password",value:d,onChange:_=>f(_.target.value),className:ne(k,d&&!N&&"ring-2 ring-red-500"),placeholder:"Confirm password"}),d&&!N&&c.jsx("p",{className:"mt-1 text-xs text-red-500",children:"Passwords don't match"})]})]}),w&&c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-red-500/10 px-3 py-2",children:[c.jsx(Dx,{size:14,className:"text-red-500 shrink-0"}),c.jsx("span",{className:"text-sm text-red-500",children:w})]}),c.jsxs("button",{type:"button",onClick:R,disabled:!j,className:ne("flex w-full items-center justify-center gap-2 rounded-lg border border-[var(--color-border)] px-4 py-2 text-sm","hover:bg-[var(--color-surface-alt)] transition-colors","disabled:opacity-50"),children:[c.jsx(fo,{size:14}),"Retry"]})]}),!w&&c.jsx("button",{type:"button",onClick:R,disabled:!j,className:ne("w-full rounded-lg bg-[var(--color-primary)] px-4 py-2 font-medium text-white","hover:opacity-90 disabled:opacity-50 transition-opacity"),children:v?"Creating...":"Create Superuser Account"})]})}const Xi=[{label:"Welcome",component:CE},{label:"Hardware",component:_E},{label:"Services",component:ME},{label:"Review",component:OE},{label:"Install",component:zE},{label:"Account",component:DE},{label:"LLM",component:kE}],UE=5;function LE({skipToAccount:n}){const{state:r,dispatch:s}=ul();S.useEffect(()=>{n&&s({type:"SET_STEP",step:UE})},[n,s]);const i=tn(),d=Xi[r.currentStep].component,f=r.currentStep===0,m=r.currentStep===Xi.length-1,x=r.currentStep===4&&!r.installComplete,y=r.installRunning||x;function p(){m?i("/login"):s({type:"NEXT_STEP"})}function w(){s({type:"PREV_STEP"})}return c.jsx("div",{className:"flex min-h-screen items-center justify-center bg-[var(--color-background)] p-4",children:c.jsxs("div",{className:"w-full max-w-2xl",children:[c.jsx("div",{className:"mb-6 flex items-center justify-center gap-1",children:Xi.map((M,N)=>c.jsxs("button",{type:"button",onClick:()=>!y&&s({type:"SET_STEP",step:N}),disabled:y,className:ne("flex items-center gap-1",y&&"cursor-not-allowed"),children:[c.jsx("div",{className:ne("flex h-7 w-7 items-center justify-center rounded-full text-xs font-medium transition-colors",N===r.currentStep?"bg-[var(--color-primary)] text-white":N<r.currentStep?"bg-[var(--color-primary)]/20 text-[var(--color-primary)]":"bg-[var(--color-surface-alt)] text-[var(--color-text-muted)]"),children:N+1}),c.jsx("span",{className:ne("hidden text-xs sm:inline",N===r.currentStep?"font-medium text-[var(--color-text)]":"text-[var(--color-text-muted)]"),children:M.label}),N<Xi.length-1&&c.jsx("div",{className:ne("mx-1 h-px w-4 sm:w-6",N<r.currentStep?"bg-[var(--color-primary)]/30":"bg-[var(--color-border)]")})]},M.label))}),c.jsx("div",{className:"rounded-xl border border-[var(--color-border)] bg-[var(--color-surface)] p-6 shadow-lg",children:c.jsx(d,{})}),c.jsxs("div",{className:"mt-4 flex justify-between",children:[c.jsx("button",{type:"button",onClick:w,disabled:f||y,className:ne("rounded-lg border border-[var(--color-border)] px-4 py-2 text-sm","hover:bg-[var(--color-surface-alt)] transition-colors","disabled:invisible"),children:"Back"}),c.jsx("button",{type:"button",onClick:p,disabled:y,className:ne("rounded-lg bg-[var(--color-primary)] px-6 py-2 text-sm font-medium text-white","hover:opacity-90 transition-opacity","disabled:opacity-50 disabled:cursor-not-allowed"),children:m?"Finish":"Next"})]})]})})}function BE({skipToAccount:n}){return c.jsx(RE,{children:c.jsx(LE,{skipToAccount:n})})}function HE(){const n=tn(),r=lv(),s=$j(),[i,d]=S.useState("select"),[f,m]=S.useState(null),[g,v]=S.useState("GGUF"),[x,y]=S.useState(""),[p,w]=S.useState(null),M=_=>{m(_),_.gated?d("token"):j(_,"")},N=()=>{if(!x.trim()){w("HuggingFace token is required for gated models");return}w(null),f&&j(f,x)},j=async(_,B)=>{d("download"),w(null);const O=g==="GGUF"?_.hfRepoGguf:_.hfRepoVllm,P=g==="GGUF"?_.ggufFilename:void 0;try{await s.mutateAsync({repo:O,filename:P,token:B||void 0}),R(_)}catch(I){w(`Download failed: ${I.message}`),d("select")}},R=async _=>{d("configure"),w(null);const O={"model.main.name":g==="GGUF"?`.models/${_.ggufFilename}`:`.models/${_.hfRepoVllm.split("/").pop()}`,"model.main.backend":g,"model.main.chat_format":_.chatFormat,"model.main.context_window":_.contextWindow};g==="GGUF"&&(O["inference.gguf.n_gpu_layers"]=-1),g==="VLLM"&&_.quantization&&(O["inference.vllm.quantization"]=_.quantization);try{await r.mutateAsync(O),d("done"),Xe.success("LLM configured successfully")}catch(P){w(`Configuration failed: ${P.message}`),d("select")}},k=()=>{n("/dashboard")};return c.jsx("div",{className:"flex min-h-screen items-center justify-center bg-[var(--color-bg)] p-4",children:c.jsxs("div",{className:"w-full max-w-2xl rounded-xl border border-[var(--color-border)] bg-[var(--color-surface)] p-8 shadow-lg",children:[c.jsxs("div",{className:"mb-8 text-center",children:[c.jsx(ld,{className:"mx-auto mb-3 text-[var(--color-primary)]",size:40}),c.jsx("h1",{className:"text-2xl font-bold text-[var(--color-text)]",children:"LLM Setup"}),c.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:"Configure a local language model for Jarvis"})]}),c.jsx("div",{className:"mb-8 flex items-center justify-center gap-2",children:["select","download","configure","done"].map((_,B)=>{const O=i==="token"?"select":i,P=["select","download","configure","done"];return c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("div",{className:ne("h-2 w-2 rounded-full",O===_?"bg-[var(--color-primary)]":P.indexOf(O)>B?"bg-green-500":"bg-[var(--color-border)]")}),B<3&&c.jsx("div",{className:"h-px w-8 bg-[var(--color-border)]"})]},_)})}),p&&c.jsxs("div",{className:"mb-6 flex items-start gap-2 rounded-lg border border-red-500/30 bg-red-500/10 p-3 text-sm text-red-500",children:[c.jsx(fa,{size:16,className:"mt-0.5 shrink-0"}),p]}),i==="select"&&c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[c.jsx("h2",{className:"text-sm font-semibold text-[var(--color-text)]",children:"Select a model"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx("button",{onClick:()=>v("GGUF"),className:ne("rounded-md px-3 py-1 text-xs font-medium transition-colors",g==="GGUF"?"bg-[var(--color-primary)] text-white":"bg-[var(--color-surface-alt)] text-[var(--color-text-muted)] hover:text-[var(--color-text)]"),children:"GGUF"}),c.jsx("button",{onClick:()=>v("VLLM"),className:ne("rounded-md px-3 py-1 text-xs font-medium transition-colors",g==="VLLM"?"bg-[var(--color-primary)] text-white":"bg-[var(--color-surface-alt)] text-[var(--color-text-muted)] hover:text-[var(--color-text)]"),children:"vLLM"})]})]}),c.jsx("div",{className:"grid gap-3",children:ar.map(_=>c.jsxs("button",{onClick:()=>M(_),className:ne("flex items-center justify-between rounded-lg border border-[var(--color-border)] p-4 text-left transition-colors","hover:border-[var(--color-primary)] hover:bg-[var(--color-surface-alt)]"),children:[c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"font-medium text-[var(--color-text)]",children:_.displayName}),_.gated&&c.jsxs("span",{className:"flex items-center gap-1 rounded bg-yellow-500/15 px-1.5 py-0.5 text-[10px] font-medium text-yellow-600 dark:text-yellow-400",children:[c.jsx(Cd,{size:10}),"Gated"]})]}),c.jsxs("p",{className:"mt-0.5 text-xs text-[var(--color-text-muted)]",children:[_.quantization?`${_.quantization.toUpperCase()} 4-bit`:_.chatFormat," · ",_.contextWindow.toLocaleString()," ctx"]})]}),c.jsxs("span",{className:"text-sm text-[var(--color-text-muted)]",children:["~",g==="GGUF"?_.sizeGguf:_.sizeVllm]})]},_.id))}),c.jsx("div",{className:"flex justify-end pt-2",children:c.jsx("button",{onClick:k,className:"text-sm text-[var(--color-text-muted)] hover:text-[var(--color-text)]",children:"Skip for now"})})]}),i==="token"&&f&&c.jsxs("div",{className:"space-y-4",children:[c.jsx("h2",{className:"text-sm font-semibold text-[var(--color-text)]",children:"HuggingFace Access Required"}),c.jsxs("p",{className:"text-sm text-[var(--color-text-muted)]",children:[c.jsx("strong",{children:f.displayName})," is a gated model. You need to:"]}),c.jsxs("ol",{className:"list-inside list-decimal space-y-1 text-sm text-[var(--color-text-muted)]",children:[c.jsx("li",{children:"Visit the model page on huggingface.co and accept the license agreement"}),c.jsx("li",{children:"Create an access token at huggingface.co/settings/tokens"}),c.jsx("li",{children:"Paste your token below"})]}),c.jsx("input",{type:"password",value:x,onChange:_=>y(_.target.value),placeholder:"hf_...",className:ne("w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-bg)] px-3 py-2","text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]","outline-none focus:ring-2 focus:ring-[var(--color-primary)]")}),c.jsxs("div",{className:"flex justify-between",children:[c.jsx("button",{onClick:()=>{d("select"),w(null)},className:"text-sm text-[var(--color-text-muted)] hover:text-[var(--color-text)]",children:"Back"}),c.jsx("button",{onClick:N,className:"rounded-lg bg-[var(--color-primary)] px-4 py-2 text-sm text-white hover:opacity-90",children:"Continue"})]})]}),i==="download"&&c.jsxs("div",{className:"flex flex-col items-center py-8",children:[c.jsx(fs,{className:"mb-4 animate-bounce text-[var(--color-primary)]",size:32}),c.jsx("h2",{className:"text-lg font-semibold text-[var(--color-text)]",children:"Downloading model..."}),c.jsxs("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:[f?.displayName," ","(~",g==="GGUF"?f?.sizeGguf:f?.sizeVllm,")"]}),c.jsx("p",{className:"mt-4 text-xs text-[var(--color-text-muted)]",children:"This may take several minutes depending on your connection"})]}),i==="configure"&&c.jsxs("div",{className:"flex flex-col items-center py-8",children:[c.jsx(qx,{className:"mb-4 animate-spin text-[var(--color-primary)]",size:32}),c.jsx("h2",{className:"text-lg font-semibold text-[var(--color-text)]",children:"Configuring..."}),c.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:"Writing settings and restarting LLM proxy"})]}),i==="done"&&c.jsxs("div",{className:"flex flex-col items-center py-8",children:[c.jsx(xN,{className:"mb-4 text-green-500",size:40}),c.jsx("h2",{className:"text-lg font-semibold text-[var(--color-text)]",children:"LLM Ready"}),c.jsxs("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:[f?.displayName," configured on ",g]}),c.jsx("p",{className:"mt-1 text-xs text-[var(--color-text-muted)]",children:"The model service is restarting. It may take a minute to load the model."}),c.jsx("button",{onClick:()=>n("/dashboard"),className:"mt-6 rounded-lg bg-[var(--color-primary)] px-6 py-2 text-sm text-white hover:opacity-90",children:"Go to Dashboard"})]}),(s.isPending||r.isPending)&&i!=="download"&&i!=="configure"&&c.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",children:c.jsx(ua,{className:"animate-spin text-white",size:32})})]})})}const qE=new O1;function GE(){const[n,r]=S.useState(!0),[s,i]=S.useState(!1),[d,f]=S.useState(!1);return S.useEffect(()=>{Ad().then(m=>{m.state==="deployed-needs-account"?(f(!0),i(!0)):i(!m.configured)}).catch(()=>{i(!1)}).finally(()=>r(!1))},[]),n?c.jsx("div",{className:"flex min-h-screen items-center justify-center bg-[var(--color-background)]",children:c.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-[var(--color-primary)] border-t-transparent"})}):c.jsxs(C0,{children:[c.jsx(qt,{path:"/setup",element:c.jsx(BE,{skipToAccount:d})}),c.jsx(qt,{path:"/login",element:c.jsx(pj,{})}),c.jsx(qt,{path:"/llm-setup",element:c.jsx(HE,{})}),c.jsxs(qt,{element:c.jsx(hj,{}),children:[c.jsx(qt,{path:"/dashboard",element:c.jsx(nE,{})}),c.jsx(qt,{path:"/settings",element:c.jsx(Cj,{})}),c.jsx(qt,{path:"/services",element:c.jsx(Yj,{})}),c.jsx(qt,{path:"/models",element:c.jsx(vE,{})}),c.jsx(qt,{path:"/update",element:c.jsx(yE,{})}),c.jsx(qt,{path:"/reconcile",element:c.jsx(SE,{})}),c.jsx(qt,{path:"/nodes",element:c.jsx(fE,{})}),c.jsx(qt,{path:"/",element:s?c.jsx(Wi,{to:"/setup",replace:!0}):c.jsx(Wi,{to:"/dashboard",replace:!0})}),c.jsx(qt,{path:"*",element:c.jsx(NE,{})})]})]})}function QE(){return c.jsx(y2,{children:c.jsx(z1,{client:qE,children:c.jsxs(aN,{children:[c.jsx(I0,{children:c.jsx(GE,{})}),c.jsx(x2,{position:"bottom-right",richColors:!0})]})})})}Cb.createRoot(document.getElementById("root")).render(c.jsx(S.StrictMode,{children:c.jsx(QE,{})}));
18
+ `);ee=re.pop()??"";for(const se of re)if(se.startsWith("data: "))try{const ie=JSON.parse(se.slice(6));if(ie.phase&&i(ie.phase),ie.message&&j({text:ie.message,phase:ie.phase}),ie.stream&&ie.text&&j({text:ie.text.trim()}),ie.done&&ie.code!==0)throw new Error(ie.message??"Reconcile failed")}catch(ie){if(ie instanceof SyntaxError)continue;throw ie}}}catch(O){const P=O instanceof Error?O.message:String(O);g(P),i("error"),j({text:`Error: ${P}`})}}const _=Object.keys(Gu).filter(B=>{const O=Object.keys(Gu),P=O.indexOf(s);return O.indexOf(B)<P});return c.jsxs("div",{className:"mx-auto max-w-3xl space-y-6 p-6",children:[c.jsxs("div",{children:[c.jsx("h1",{className:"text-2xl font-bold text-[var(--color-text)]",children:"Sync Compose"}),c.jsxs("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:["Regenerate ",c.jsx("code",{className:"rounded bg-[var(--color-surface)] px-1.5 py-0.5 text-xs",children:"docker-compose.yml"})," from the latest service registry and apply changes to the running stack."]})]}),s==="loading_options"&&c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx(ua,{size:32,className:"animate-spin text-[var(--color-primary)]"})}),s==="options"&&c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[c.jsx("h2",{className:"mb-3 text-sm font-semibold text-[var(--color-text)]",children:"Services"}),c.jsx("div",{className:"space-y-2",children:x.map(B=>c.jsxs("button",{onClick:()=>R(B.id),className:"flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left hover:bg-[var(--color-bg-secondary)] transition-colors",children:[B.enabled?c.jsx(bt,{size:18,className:"shrink-0 text-[var(--color-primary)]"}):c.jsx(lr,{size:18,className:"shrink-0 text-[var(--color-text-muted)]"}),c.jsxs("div",{className:"min-w-0",children:[c.jsx("div",{className:"text-sm font-medium text-[var(--color-text)]",children:B.name}),c.jsx("div",{className:"text-xs text-[var(--color-text-muted)]",children:B.description})]})]},B.id))})]}),c.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:[c.jsx("h2",{className:"mb-3 text-sm font-semibold text-[var(--color-text)]",children:"Integrations"}),c.jsxs("button",{onClick:()=>w(!p),className:"flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left hover:bg-[var(--color-bg-secondary)] transition-colors",children:[p?c.jsx(bt,{size:18,className:"shrink-0 text-[var(--color-primary)]"}):c.jsx(lr,{size:18,className:"shrink-0 text-[var(--color-text-muted)]"}),c.jsxs("div",{className:"min-w-0",children:[c.jsx("div",{className:"text-sm font-medium text-[var(--color-text)]",children:"Jarvis Relay"}),c.jsx("div",{className:"text-xs text-[var(--color-text-muted)]",children:"Routes OAuth callbacks through a cloud relay for external providers (Google, Spotify, etc.)"})]})]}),p&&c.jsxs("div",{className:"mt-2 px-3",children:[c.jsx("label",{className:"text-xs font-medium text-[var(--color-text-muted)]",children:"Relay URL"}),c.jsx("input",{type:"url",value:M,onChange:B=>N(B.target.value),placeholder:"https://relay.jarvisautomation.io",className:"mt-1 w-full rounded-md border border-[var(--color-border)] bg-[var(--color-bg)] px-3 py-1.5 text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]"})]})]})]}),s!=="loading_options"&&s!=="options"&&c.jsx("div",{className:"space-y-2 rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-4",children:Object.entries(Gu).map(([B,O])=>{const P=B===s,I=_.includes(B),ee=B===s&&s==="error";return c.jsxs("div",{className:"flex items-center gap-2",children:[I?c.jsx(bt,{size:16,className:"text-green-500"}):ee?c.jsx(fa,{size:16,className:"text-red-500"}):P?c.jsx(ua,{size:16,className:"animate-spin text-[var(--color-primary)]"}):c.jsx("div",{className:"h-4 w-4 rounded-full border border-[var(--color-border)]"}),c.jsx("span",{className:ne("text-sm",P?"font-medium text-[var(--color-text)]":"text-[var(--color-text-muted)]",I&&"text-green-500"),children:O})]},B)})}),d.length>0&&c.jsx("div",{ref:v,className:"max-h-64 overflow-y-auto rounded-lg border border-[var(--color-border)] bg-[#0d1117] p-3 font-mono text-xs text-gray-300",children:d.map((B,O)=>c.jsx("div",{children:B.text},O))}),m&&c.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-red-500/10 px-3 py-2",children:[c.jsx(fa,{size:14,className:"text-red-500"}),c.jsx("span",{className:"text-sm text-red-500",children:m})]}),c.jsxs("div",{className:"flex gap-3",children:[s==="options"&&c.jsxs("button",{onClick:k,className:"flex items-center gap-2 rounded-lg bg-[var(--color-primary)] px-4 py-2 text-sm font-medium text-white hover:opacity-90",children:[c.jsx(Bx,{size:16}),"Sync now"]}),(s==="options"||s==="regenerate"||s==="apply"||s==="done")&&c.jsxs("button",{onClick:()=>n("/dashboard"),disabled:s==="regenerate"||s==="apply",className:"flex items-center gap-2 rounded-lg border border-[var(--color-border)] px-4 py-2 text-sm font-medium text-[var(--color-text)] hover:bg-[var(--color-surface-alt)] disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent",children:[c.jsx(bt,{size:16}),"Back to dashboard"]}),s==="error"&&c.jsxs("button",{onClick:k,className:"flex items-center gap-2 rounded-lg bg-[var(--color-primary)] px-4 py-2 text-sm font-medium text-white hover:opacity-90",children:[c.jsx(da,{size:16}),"Retry"]})]})]})}function NE(){return c.jsxs("div",{className:"flex min-h-[60vh] flex-col items-center justify-center",children:[c.jsx("h1",{className:"mb-2 text-4xl font-bold text-[var(--color-text)]",children:"404"}),c.jsx("p",{className:"mb-4 text-[var(--color-text-muted)]",children:"Page not found"}),c.jsx(hd,{to:"/settings",className:"text-[var(--color-primary)] underline hover:opacity-80",children:"Go to Settings"})]})}const wE=7,jE={currentStep:0,totalSteps:wE,enabledModules:[],portOverrides:{},infraPortOverrides:{},secrets:{},dbUser:"jarvis",whisperModel:"base.en",llmInterface:"Qwen25MediumUntrained",deploymentMode:"local",deploymentTarget:"standard",remoteLlmUrl:"",remoteWhisperUrl:"",platform:"linux",hardware:null,relayEnabled:!1,installRunning:!1,installComplete:!1};function EE(n,r,s){return Math.max(r,Math.min(s,n))}function TE(n,r){switch(r.type){case"SET_STEP":return{...n,currentStep:EE(r.step,0,n.totalSteps-1)};case"NEXT_STEP":return{...n,currentStep:Math.min(n.currentStep+1,n.totalSteps-1)};case"PREV_STEP":return{...n,currentStep:Math.max(n.currentStep-1,0)};case"SET_ENABLED_MODULES":return{...n,enabledModules:r.modules};case"TOGGLE_MODULE":{if(r.enabled){const s=n.enabledModules.includes(r.serviceId)?n.enabledModules:[...n.enabledModules,r.serviceId];return{...n,enabledModules:s}}return{...n,enabledModules:n.enabledModules.filter(s=>s!==r.serviceId)}}case"SET_PORT_OVERRIDE":return{...n,portOverrides:{...n.portOverrides,[r.serviceId]:r.port}};case"SET_INFRA_PORT_OVERRIDE":return{...n,infraPortOverrides:{...n.infraPortOverrides,[r.infraId]:r.port}};case"SET_SECRET":return{...n,secrets:{...n.secrets,[r.name]:r.value}};case"SET_SECRETS":return{...n,secrets:r.secrets};case"SET_DB_USER":return{...n,dbUser:r.user};case"SET_WHISPER_MODEL":return{...n,whisperModel:r.model};case"SET_LLM_INTERFACE":return{...n,llmInterface:r.interfaceId};case"SET_DEPLOYMENT_MODE":return{...n,deploymentMode:r.mode};case"SET_DEPLOYMENT_TARGET":return{...n,deploymentTarget:r.target};case"SET_REMOTE_LLM_URL":return{...n,remoteLlmUrl:r.url};case"SET_REMOTE_WHISPER_URL":return{...n,remoteWhisperUrl:r.url};case"SET_PLATFORM":return{...n,platform:r.platform};case"SET_HARDWARE":return{...n,hardware:r.hardware,platform:r.hardware.platform};case"SET_RELAY_ENABLED":return{...n,relayEnabled:r.enabled};case"SET_INSTALL_RUNNING":return{...n,installRunning:r.running};case"SET_INSTALL_COMPLETE":return{...n,installRunning:!1,installComplete:!0};default:return n}}const ov=S.createContext(null);function RE({children:n}){const[r,s]=S.useReducer(TE,jE);return c.jsx(ov.Provider,{value:{state:r,dispatch:s},children:n})}function ul(){const n=S.useContext(ov);if(!n)throw new Error("useWizard must be used within a WizardProvider");return n}function CE(){const{state:n,dispatch:r}=ul(),[s,i]=S.useState(null),[d,f]=S.useState(!0),[m,g]=S.useState(!1);function v(){f(!0),g(!1),Ad().then(y=>{i(y);const p=y.reason==="docker_not_found";g(p),r(p?{type:"SET_INSTALL_RUNNING",running:!0}:{type:"SET_INSTALL_RUNNING",running:!1})}).catch(()=>{i({configured:!1,reason:"error"}),g(!0),r({type:"SET_INSTALL_RUNNING",running:!0})}).finally(()=>f(!1))}S.useEffect(()=>{v()},[]);const x=s&&s.reason!=="docker_not_found";return c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-xl font-bold text-[var(--color-text)]",children:"Welcome to Jarvis"}),c.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:"Let's get your personal voice assistant up and running. This wizard will guide you through selecting services, configuring hardware, and starting everything up."})]}),c.jsx("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] p-4",children:c.jsxs("div",{className:"flex items-center gap-3",children:[d?c.jsx(ua,{size:20,className:"animate-spin text-[var(--color-primary)]"}):x?c.jsx(bt,{size:20,className:"text-green-500"}):c.jsx(Dx,{size:20,className:"text-red-500"}),c.jsxs("div",{className:"flex-1",children:[c.jsx("p",{className:"text-sm font-medium text-[var(--color-text)]",children:d?"Checking Docker...":x?"Docker is running":"Docker not found"}),!d&&!x&&c.jsxs("div",{className:"mt-1 space-y-1",children:[c.jsx("p",{className:"text-xs text-red-400",children:"Docker is required to run Jarvis services."}),c.jsxs("p",{className:"text-xs text-[var(--color-text-muted)]",children:["Install"," ",c.jsx("a",{href:"https://www.docker.com/products/docker-desktop/",target:"_blank",rel:"noopener noreferrer",className:"text-[var(--color-primary)] underline hover:no-underline",children:"Docker Desktop"})," ","for your platform, start it, then click Retry."]})]})]}),m&&!d&&c.jsxs("button",{type:"button",onClick:v,className:"flex items-center gap-1 rounded-md border border-[var(--color-border)] px-2 py-1 text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text)]",children:[c.jsx(fo,{size:12}),"Retry"]})]})}),c.jsxs("div",{children:[c.jsx("label",{className:"mb-2 block text-sm font-medium text-[var(--color-text)]",children:"Deployment Mode"}),c.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[c.jsxs("button",{type:"button",onClick:()=>r({type:"SET_DEPLOYMENT_MODE",mode:"local"}),className:ne("flex flex-col items-center gap-2 rounded-lg border p-4 transition-colors",n.deploymentMode==="local"?"border-[var(--color-primary)] bg-[var(--color-primary)]/10":"border-[var(--color-border)] hover:border-[var(--color-primary)]/50"),children:[c.jsx(XN,{size:24,className:"text-[var(--color-primary)]"}),c.jsx("span",{className:"text-sm font-medium text-[var(--color-text)]",children:"Local"}),c.jsx("span",{className:"text-xs text-center text-[var(--color-text-muted)]",children:"Everything on this machine"})]}),c.jsxs("button",{type:"button",onClick:()=>r({type:"SET_DEPLOYMENT_MODE",mode:"remote-llm"}),className:ne("flex flex-col items-center gap-2 rounded-lg border p-4 transition-colors",n.deploymentMode==="remote-llm"?"border-[var(--color-primary)] bg-[var(--color-primary)]/10":"border-[var(--color-border)] hover:border-[var(--color-primary)]/50"),children:[c.jsx(_d,{size:24,className:"text-[var(--color-primary)]"}),c.jsx("span",{className:"text-sm font-medium text-[var(--color-text)]",children:"Remote LLM"}),c.jsx("span",{className:"text-xs text-center text-[var(--color-text-muted)]",children:"LLM on separate GPU machine"})]})]})]})]})}const Yi=[{label:"None / CPU only",gpu:null,gpuType:"none",vramMb:null,backends:["gguf"],defaultBackend:"gguf"},{label:"NVIDIA RTX 4090 (24 GB)",gpu:"NVIDIA RTX 4090",gpuType:"nvidia",vramMb:24576,backends:["gguf","vllm"],defaultBackend:"gguf"},{label:"NVIDIA RTX 4080 (16 GB)",gpu:"NVIDIA RTX 4080",gpuType:"nvidia",vramMb:16384,backends:["gguf","vllm"],defaultBackend:"gguf"},{label:"NVIDIA RTX 4070 Ti (12 GB)",gpu:"NVIDIA RTX 4070 Ti",gpuType:"nvidia",vramMb:12288,backends:["gguf","vllm"],defaultBackend:"gguf"},{label:"NVIDIA RTX 3090 (24 GB)",gpu:"NVIDIA RTX 3090",gpuType:"nvidia",vramMb:24576,backends:["gguf","vllm"],defaultBackend:"gguf"},{label:"NVIDIA RTX 3080 (10 GB)",gpu:"NVIDIA RTX 3080",gpuType:"nvidia",vramMb:10240,backends:["gguf","vllm"],defaultBackend:"gguf"},{label:"NVIDIA RTX 3070 (8 GB)",gpu:"NVIDIA RTX 3070",gpuType:"nvidia",vramMb:8192,backends:["gguf","vllm"],defaultBackend:"gguf"},{label:"NVIDIA A100 (80 GB)",gpu:"NVIDIA A100",gpuType:"nvidia",vramMb:81920,backends:["gguf","vllm"],defaultBackend:"vllm"},{label:"NVIDIA A100 (40 GB)",gpu:"NVIDIA A100",gpuType:"nvidia",vramMb:40960,backends:["gguf","vllm"],defaultBackend:"vllm"},{label:"NVIDIA Tesla T4 (16 GB)",gpu:"NVIDIA Tesla T4",gpuType:"nvidia",vramMb:16384,backends:["gguf","vllm"],defaultBackend:"gguf"},{label:"AMD RX 9070 XT — Vulkan (16 GB)",gpu:"AMD RX 9070 XT",gpuType:"amd",vramMb:16384,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 9070 — Vulkan (12 GB)",gpu:"AMD RX 9070",gpuType:"amd",vramMb:12288,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 7900 XTX — Vulkan (24 GB)",gpu:"AMD RX 7900 XTX",gpuType:"amd",vramMb:24576,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 7900 XT — Vulkan (20 GB)",gpu:"AMD RX 7900 XT",gpuType:"amd",vramMb:20480,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 7800 XT — Vulkan (16 GB)",gpu:"AMD RX 7800 XT",gpuType:"amd",vramMb:16384,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 7600 — Vulkan (8 GB)",gpu:"AMD RX 7600",gpuType:"amd",vramMb:8192,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 9070 XT — ROCm (16 GB)",gpu:"AMD RX 9070 XT",gpuType:"amd-rocm",vramMb:16384,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 9070 — ROCm (12 GB)",gpu:"AMD RX 9070",gpuType:"amd-rocm",vramMb:12288,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 7900 XTX — ROCm (24 GB)",gpu:"AMD RX 7900 XTX",gpuType:"amd-rocm",vramMb:24576,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 7900 XT — ROCm (20 GB)",gpu:"AMD RX 7900 XT",gpuType:"amd-rocm",vramMb:20480,backends:["gguf"],defaultBackend:"gguf"},{label:"AMD RX 7800 XT — ROCm (16 GB)",gpu:"AMD RX 7800 XT",gpuType:"amd-rocm",vramMb:16384,backends:["gguf"],defaultBackend:"gguf"},{label:"Apple M4 Max (128 GB unified)",gpu:"Apple M4 Max",gpuType:"apple",vramMb:131072,backends:["gguf","mlx"],defaultBackend:"gguf"},{label:"Apple M4 Max (64 GB unified)",gpu:"Apple M4 Max",gpuType:"apple",vramMb:65536,backends:["gguf","mlx"],defaultBackend:"gguf"},{label:"Apple M4 Pro (48 GB unified)",gpu:"Apple M4 Pro",gpuType:"apple",vramMb:49152,backends:["gguf","mlx"],defaultBackend:"gguf"},{label:"Apple M4 Pro (24 GB unified)",gpu:"Apple M4 Pro",gpuType:"apple",vramMb:24576,backends:["gguf","mlx"],defaultBackend:"gguf"},{label:"Apple M2 Max (32 GB unified)",gpu:"Apple M2 Max",gpuType:"apple",vramMb:32768,backends:["gguf","mlx"],defaultBackend:"gguf"},{label:"Apple M2 Pro (16 GB unified)",gpu:"Apple M2 Pro",gpuType:"apple",vramMb:16384,backends:["gguf","mlx"],defaultBackend:"gguf"},{label:"Apple M1 (16 GB unified)",gpu:"Apple M1",gpuType:"apple",vramMb:16384,backends:["gguf","mlx"],defaultBackend:"gguf"},{label:"Apple M1 (8 GB unified)",gpu:"Apple M1",gpuType:"apple",vramMb:8192,backends:["gguf","mlx"],defaultBackend:"gguf"},{label:"Other (enter VRAM manually)",gpu:"Other",gpuType:"none",vramMb:null,backends:["gguf"],defaultBackend:"gguf"}];function _E(){const{state:n,dispatch:r}=ul(),[s,i]=S.useState(!n.hardware),[d,f]=S.useState(!1),[m,g]=S.useState(0),[v,x]=S.useState("");S.useEffect(()=>{n.hardware||Ij().then(w=>{r({type:"SET_HARDWARE",hardware:w}),w.recommendedBackend==="remote"&&n.deploymentMode==="local"&&r({type:"SET_DEPLOYMENT_MODE",mode:"remote-llm"})}).catch(()=>{}).finally(()=>i(!1))},[]);function y(w,M){const N=Yi[w];if(!n.hardware)return;const j=N.gpu==="Other"?(parseInt(M??v,10)||0)*1024:N.vramMb,R={...n.hardware,gpuName:N.gpu,gpuVramMb:j||null,gpuType:N.gpuType,recommendedBackends:[...N.backends],recommendedBackend:N.defaultBackend};r({type:"SET_HARDWARE",hardware:R})}const p=n.hardware;return s?c.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[c.jsx(ua,{size:32,className:"animate-spin text-[var(--color-primary)]"}),c.jsx("p",{className:"mt-3 text-sm text-[var(--color-text-muted)]",children:"Detecting hardware..."})]}):c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-xl font-bold text-[var(--color-text)]",children:"Hardware Detection"}),c.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:"We detected the following hardware. This determines which LLM backend to use."})]}),p&&c.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[c.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] p-4",children:[c.jsxs("div",{className:"flex items-center gap-2 text-[var(--color-text-muted)]",children:[c.jsx(ps,{size:16}),c.jsx("span",{className:"text-xs font-medium uppercase",children:"Platform"})]}),c.jsxs("p",{className:"mt-1 text-sm font-medium text-[var(--color-text)]",children:[p.platform==="darwin"?"macOS":"Linux"," (",p.arch,")"]})]}),c.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] p-4",children:[c.jsxs("div",{className:"flex items-center gap-2 text-[var(--color-text-muted)]",children:[c.jsx(Rd,{size:16}),c.jsx("span",{className:"text-xs font-medium uppercase",children:"Memory"})]}),c.jsxs("p",{className:"mt-1 text-sm font-medium text-[var(--color-text)]",children:[p.totalMemoryGb," GB RAM"]})]}),c.jsxs("div",{className:"col-span-2 rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] p-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center gap-2 text-[var(--color-text-muted)]",children:[c.jsx(ps,{size:16}),c.jsx("span",{className:"text-xs font-medium uppercase",children:"GPU"})]}),c.jsx("p",{className:"mt-1 text-sm font-medium text-[var(--color-text)]",children:p.gpuName??"No GPU detected"}),p.gpuVramMb!=null&&p.gpuVramMb>0&&c.jsxs("p",{className:"text-xs text-[var(--color-text-muted)]",children:[Math.round(p.gpuVramMb/1024)," GB VRAM"]})]}),c.jsx("button",{type:"button",onClick:()=>f(!d),className:"text-xs font-medium text-[var(--color-primary)] hover:underline",children:d?"Cancel":"Override"})]}),d&&c.jsxs("div",{className:"mt-3 space-y-3 border-t border-[var(--color-border)] pt-3",children:[c.jsxs("div",{children:[c.jsx("label",{htmlFor:"gpu-select",className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"Select GPU"}),c.jsx("select",{id:"gpu-select",value:m,onChange:w=>{const M=parseInt(w.target.value,10);g(M),Yi[M].gpu!=="Other"&&(y(M),f(!1))},className:ne("w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2","text-sm text-[var(--color-text)]","outline-none focus:ring-2 focus:ring-[var(--color-primary)]"),children:Yi.map((w,M)=>c.jsx("option",{value:M,children:w.label},`${w.label}-${M}`))})]}),Yi[m].gpu==="Other"&&c.jsxs("div",{className:"flex items-end gap-2",children:[c.jsxs("div",{className:"flex-1",children:[c.jsx("label",{htmlFor:"custom-vram",className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"VRAM (GB)"}),c.jsx("input",{id:"custom-vram",type:"number",min:1,max:512,value:v,onChange:w=>x(w.target.value),placeholder:"e.g. 24",className:ne("w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2","text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]","outline-none focus:ring-2 focus:ring-[var(--color-primary)]")})]}),c.jsx("button",{type:"button",disabled:!v||parseInt(v,10)<=0,onClick:()=>{y(m,v),f(!1)},className:ne("rounded-lg px-4 py-2 text-sm font-medium","bg-[var(--color-primary)] text-white","disabled:cursor-not-allowed disabled:opacity-50"),children:"Apply"})]})]})]}),c.jsxs("div",{className:"col-span-2 rounded-lg border border-[var(--color-primary)]/30 bg-[var(--color-primary)]/5 p-4",children:[c.jsxs("p",{className:"text-sm font-medium text-[var(--color-text)]",children:["Recommended: ",c.jsx("span",{className:"text-[var(--color-primary)]",children:p.recommendedBackend.toUpperCase()})]}),p.recommendedBackends.length>1&&c.jsxs("p",{className:"mt-0.5 text-xs text-[var(--color-text-muted)]",children:["Available backends: ",p.recommendedBackends.join(", ")]})]})]}),n.deploymentMode==="remote-llm"&&c.jsxs("div",{className:"space-y-3",children:[c.jsx("h3",{className:"text-sm font-medium text-[var(--color-text)]",children:"Remote Service URLs"}),c.jsxs("div",{children:[c.jsx("label",{htmlFor:"remote-llm",className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"LLM Proxy URL"}),c.jsx("input",{id:"remote-llm",type:"url",value:n.remoteLlmUrl,onChange:w=>r({type:"SET_REMOTE_LLM_URL",url:w.target.value}),placeholder:"http://192.168.1.100:7704",className:ne("w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2","text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]","outline-none focus:ring-2 focus:ring-[var(--color-primary)]")})]}),c.jsxs("div",{children:[c.jsx("label",{htmlFor:"remote-whisper",className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"Whisper URL (optional)"}),c.jsx("input",{id:"remote-whisper",type:"url",value:n.remoteWhisperUrl,onChange:w=>r({type:"SET_REMOTE_WHISPER_URL",url:w.target.value}),placeholder:"http://192.168.1.100:7706",className:ne("w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2","text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]","outline-none focus:ring-2 focus:ring-[var(--color-primary)]")})]})]})]})}function ME(){const{state:n,dispatch:r}=ul(),[s,i]=S.useState(null),[d,f]=S.useState(!0);if(S.useEffect(()=>{Promise.all([rv(),Wj()]).then(([x,y])=>{i(x),n.enabledModules.length===0&&r({type:"SET_ENABLED_MODULES",modules:y.enabledModules})}).catch(()=>{}).finally(()=>f(!1))},[]),d||!s)return c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx(ua,{size:32,className:"animate-spin text-[var(--color-primary)]"})});const{core:m,recommended:g,optional:v}=AE(s.services);return c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-xl font-bold text-[var(--color-text)]",children:"Select Services"}),c.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:"Core services are always included. Toggle recommended and optional services."})]}),c.jsx(Qu,{title:"Core",subtitle:"Always included",services:m,enabled:m.map(x=>x.id),locked:!0}),c.jsx(Qu,{title:"Recommended",subtitle:"Enabled by default",services:g,enabled:n.enabledModules,onToggle:(x,y)=>r({type:"TOGGLE_MODULE",serviceId:x,enabled:y}),platform:n.platform}),v.length>0&&c.jsx(Qu,{title:"Optional",subtitle:"Off by default",services:v,enabled:n.enabledModules,onToggle:(x,y)=>r({type:"TOGGLE_MODULE",serviceId:x,enabled:y})}),c.jsxs("div",{children:[c.jsxs("div",{className:"mb-2 flex items-baseline gap-2",children:[c.jsx("h3",{className:"text-sm font-medium text-[var(--color-text)]",children:"Integrations"}),c.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:"Cloud services"})]}),c.jsxs("button",{type:"button",onClick:()=>r({type:"SET_RELAY_ENABLED",enabled:!n.relayEnabled}),className:ne("flex w-full items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors",n.relayEnabled?"border-[var(--color-primary)]/30 bg-[var(--color-primary)]/5":"border-[var(--color-border)] hover:border-[var(--color-primary)]/30"),children:[n.relayEnabled?c.jsx(bt,{size:16,className:"shrink-0 text-[var(--color-primary)]"}):c.jsx(lr,{size:16,className:"shrink-0 text-[var(--color-text-muted)]"}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-sm font-medium text-[var(--color-text)]",children:"Jarvis Relay"}),c.jsx(ON,{size:12,className:"text-[var(--color-text-muted)]"})]}),c.jsx("p",{className:"text-xs text-[var(--color-text-muted)]",children:"Routes OAuth callbacks through a cloud relay for external providers (Google, Spotify, etc.)"})]})]})]})]})}function AE(n){return{core:n.filter(r=>r.category==="core"),recommended:n.filter(r=>r.category==="recommended"),optional:n.filter(r=>r.category==="optional")}}function Qu({title:n,subtitle:r,services:s,enabled:i,locked:d,onToggle:f,platform:m}){return c.jsxs("div",{children:[c.jsxs("div",{className:"mb-2 flex items-baseline gap-2",children:[c.jsx("h3",{className:"text-sm font-medium text-[var(--color-text)]",children:n}),c.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:r})]}),c.jsx("div",{className:"space-y-1",children:s.map(g=>{const v=i.includes(g.id),x=g.nativeOnly&&m==="darwin";return c.jsxs("button",{type:"button",disabled:d,onClick:()=>f?.(g.id,!v),className:ne("flex w-full items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors",v?"border-[var(--color-primary)]/30 bg-[var(--color-primary)]/5":"border-[var(--color-border)] hover:border-[var(--color-primary)]/30",d&&"cursor-default"),children:[d?c.jsx(Cd,{size:16,className:"shrink-0 text-[var(--color-text-muted)]"}):v?c.jsx(bt,{size:16,className:"shrink-0 text-[var(--color-primary)]"}):c.jsx(lr,{size:16,className:"shrink-0 text-[var(--color-text-muted)]"}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-sm font-medium text-[var(--color-text)]",children:g.name}),c.jsxs("span",{className:"text-xs text-[var(--color-text-muted)]",children:[":",g.port]}),x&&c.jsx("span",{className:"rounded bg-amber-500/10 px-1.5 py-0.5 text-[10px] font-medium text-amber-500",children:"Native"})]}),c.jsx("p",{className:"truncate text-xs text-[var(--color-text-muted)]",children:g.description})]})]},g.id)})})]})}function OE(){const{state:n}=ul(),[r,s]=S.useState(null);if(S.useEffect(()=>{rv().then(s).catch(()=>{})},[]),!r)return c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx(ua,{size:32,className:"animate-spin text-[var(--color-primary)]"})});const i=r.services.filter(p=>p.category==="core"),d=r.services.filter(p=>p.category!=="core"&&n.enabledModules.includes(p.id)),f=[...i,...d],m=new Map;for(const p of f){const w=n.portOverrides[p.id]??p.port,M=m.get(w)??[];m.set(w,[...M,p.name])}const g=[...m.entries()].filter(([,p])=>p.length>1),v=f.filter(p=>p.database).length,x=f.filter(p=>p.nativeOnly&&n.platform==="darwin"),y=f.filter(p=>!(p.nativeOnly&&n.platform==="darwin"));return c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-xl font-bold text-[var(--color-text)]",children:"Review Configuration"}),c.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:"Review your selections before installing."})]}),c.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[c.jsx(Vu,{label:"Docker Services",value:y.length}),c.jsx(Vu,{label:"Native Services",value:x.length}),c.jsx(Vu,{label:"Databases",value:v})]}),c.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] p-4",children:[c.jsx("p",{className:"text-xs font-medium uppercase text-[var(--color-text-muted)]",children:"Deployment Mode"}),c.jsx("p",{className:"mt-1 text-sm font-medium text-[var(--color-text)]",children:n.deploymentMode==="local"?"Local (all services on this machine)":"Remote LLM"}),n.deploymentMode==="remote-llm"&&n.remoteLlmUrl&&c.jsxs("p",{className:"mt-0.5 text-xs text-[var(--color-text-muted)]",children:["LLM: ",n.remoteLlmUrl]})]}),c.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] overflow-hidden",children:[c.jsx("div",{className:"border-b border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2",children:c.jsxs("span",{className:"text-xs font-medium text-[var(--color-text-muted)]",children:["Services (",f.length,")"]})}),c.jsx("div",{className:"divide-y divide-[var(--color-border)]",children:f.map(p=>c.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(bt,{size:14,className:"text-green-500"}),c.jsx("span",{className:"text-sm text-[var(--color-text)]",children:p.name})]}),c.jsxs("span",{className:"text-xs text-[var(--color-text-muted)]",children:[":",n.portOverrides[p.id]??p.port]})]},p.id))})]}),n.relayEnabled&&c.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] p-4",children:[c.jsx("p",{className:"text-xs font-medium uppercase text-[var(--color-text-muted)]",children:"Jarvis Relay"}),c.jsx("p",{className:"mt-1 text-sm font-medium text-[var(--color-text)]",children:"Enabled"}),c.jsx("p",{className:"mt-0.5 text-xs text-[var(--color-text-muted)]",children:"https://relay.jarvisautomation.io"})]}),g.length>0&&c.jsxs("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 p-4",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(fa,{size:16,className:"text-amber-500"}),c.jsx("span",{className:"text-sm font-medium text-amber-500",children:"Port Conflicts"})]}),g.map(([p,w])=>c.jsxs("p",{className:"mt-1 text-xs text-[var(--color-text-muted)]",children:["Port ",p,": ",w.join(", ")]},p))]})]})}function Vu({label:n,value:r}){return c.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] p-3 text-center",children:[c.jsx("p",{className:"text-2xl font-bold text-[var(--color-primary)]",children:r}),c.jsx("p",{className:"text-xs text-[var(--color-text-muted)]",children:n})]})}function Rg(){const[n,r]=S.useState({lines:[],running:!1,done:!1,exitCode:null,error:null,redirect:null}),s=S.useRef(null),i=S.useCallback((f,m)=>(s.current?.close(),r({lines:[],running:!0,done:!1,exitCode:null,error:null,redirect:null}),new Promise((g,v)=>{const x=new EventSource(f);s.current=x,x.onmessage=y=>{try{const p=JSON.parse(y.data);if(m&&m(p),"done"in p){if(r(w=>({...w,running:!1,done:!0,exitCode:p.code,redirect:p.redirect??null})),x.close(),p.code===0)g(p.code);else{const w=p.error?String(p.error):`Process exited with code ${p.code}`;v(new Error(w))}return}if("stream"in p&&"text"in p){const w={stream:p.stream,text:p.text,timestamp:Date.now()};r(M=>({...M,lines:[...M.lines,w]}))}}catch{}},x.onerror=()=>{const y=s.current===null;r(p=>({...p,running:!1,error:p.done?null:"Connection lost"})),x.close(),y||v(new Error("Connection lost"))}})),[]),d=S.useCallback(()=>{s.current?.close(),s.current=null,r(f=>({...f,running:!1}))},[]);return{...n,run:i,stop:d}}function Cg({lines:n,running:r,title:s,className:i}){const d=S.useRef(null),f=S.useRef(!0);S.useEffect(()=>{const g=d.current;!g||!f.current||(g.scrollTop=g.scrollHeight)},[n]);function m(){const g=d.current;if(!g)return;const v=g.scrollHeight-g.scrollTop-g.clientHeight;f.current=v<50}return c.jsxs("div",{className:ne("flex flex-col rounded-lg border border-[var(--color-border)] overflow-hidden",i),children:[s&&c.jsxs("div",{className:"flex items-center gap-2 border-b border-[var(--color-border)] bg-[var(--color-surface)] px-3 py-2",children:[c.jsx("span",{className:"text-xs font-medium text-[var(--color-text-muted)]",children:s}),r&&c.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-green-500"})]}),c.jsxs("div",{ref:d,onScroll:m,className:"h-64 overflow-y-auto bg-[#0d1117] p-3 font-mono text-xs leading-5",children:[n.length===0&&!r&&c.jsx("span",{className:"text-gray-500",children:"Waiting for output..."}),n.map((g,v)=>c.jsx("div",{className:ne("whitespace-pre-wrap break-all",g.stream==="stderr"?"text-yellow-400":"text-gray-300"),children:g.text},v)),r&&c.jsx("span",{className:"inline-block h-4 w-1.5 animate-pulse bg-gray-400"})]})]})}function zE(){const{state:n,dispatch:r}=ul(),s=Rg(),i=Rg(),[d,f]=S.useState("idle"),[m,g]=S.useState(null),[v,x]=S.useState(null),[y,p]=S.useState({}),[w,M]=S.useState({}),[N,j]=S.useState(null),[R,k]=S.useState(null);S.useEffect(()=>{const W=i.redirect;if(d!=="done"||!W)return;k(5);const re=setInterval(()=>{k(se=>se===null||se<=1?(clearInterval(re),window.location.href=W,0):se-1)},1e3);return()=>clearInterval(re)},[d,i.redirect]);const _=S.useCallback(async()=>{f("preflight"),x(null),g(null);try{const W=await Pj(n.enabledModules);return x(W),W.canProceed?!0:(g("Pre-flight checks failed. Fix the issues above and retry."),f("error"),j("preflight"),!1)}catch(W){return g(`Pre-flight check failed: ${W instanceof Error?W.message:String(W)}`),f("error"),j("preflight"),!1}},[n.enabledModules]);async function B(){g(null),p({}),j(null),r({type:"SET_INSTALL_RUNNING",running:!0});try{if(!await _()){r({type:"SET_INSTALL_RUNNING",running:!1});return}f("generating"),await wg(n),f("pulling"),await s.run("/api/install/pull"),f("starting"),await i.run("/api/install/start",re=>{if(re.phase==="health"&&typeof re.service=="string"&&p(se=>({...se,[re.service]:{healthy:re.healthy,error:re.error}})),re.serviceHealth&&typeof re.serviceHealth=="object"){const se=re.serviceHealth;p(ie=>({...ie,...se}))}}),f("done"),r({type:"SET_INSTALL_COMPLETE"})}catch(W){g(W instanceof Error?W.message:String(W)),f("error"),j(d),r({type:"SET_INSTALL_RUNNING",running:!1})}}async function O(){if(N==="preflight"){if(g(null),r({type:"SET_INSTALL_RUNNING",running:!0}),!await _()){r({type:"SET_INSTALL_RUNNING",running:!1});return}try{f("generating"),await wg(n),f("pulling"),await s.run("/api/install/pull"),f("starting"),await i.run("/api/install/start",re=>{if(re.phase==="health"&&typeof re.service=="string"&&p(se=>({...se,[re.service]:{healthy:re.healthy,error:re.error}})),re.serviceHealth&&typeof re.serviceHealth=="object"){const se=re.serviceHealth;p(ie=>({...ie,...se}))}}),f("done"),r({type:"SET_INSTALL_COMPLETE"})}catch(re){g(re instanceof Error?re.message:String(re)),f("error"),r({type:"SET_INSTALL_RUNNING",running:!1})}}else B()}async function P(W){try{const re=await fetch(`/api/containers/${W}/logs`);if(re.ok){const se=await re.text();M(ie=>({...ie,[W]:se}))}else M(se=>({...se,[W]:`Failed to fetch logs: HTTP ${re.status}`}))}catch(re){M(se=>({...se,[W]:`Failed to fetch logs: ${re instanceof Error?re.message:String(re)}`}))}}const I=[{key:"preflight",label:"Pre-flight checks"},{key:"generating",label:"Generate configuration"},{key:"pulling",label:"Pull Docker images"},{key:"starting",label:"Start services"}],$=I.map(W=>W.key).indexOf(d);return c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-xl font-bold text-[var(--color-text)]",children:"Install"}),c.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:d==="idle"?"Ready to install. This will pull Docker images and start all services.":d==="done"?i.redirect?`Installation complete! Redirecting to your admin dashboard in ${R??"..."}s...`:"Installation complete! All services are running.":d==="error"?"Installation encountered an error.":"Installing..."})]}),v&&c.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] overflow-hidden",children:[c.jsx("div",{className:"border-b border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2",children:c.jsx("span",{className:"text-xs font-medium text-[var(--color-text-muted)]",children:"Pre-flight Checks"})}),c.jsx("div",{className:"divide-y divide-[var(--color-border)]",children:v.checks.map(W=>c.jsx("div",{className:"flex items-center justify-between px-3 py-2",children:c.jsxs("div",{className:"flex items-center gap-2",children:[W.status==="pass"?c.jsx(bt,{size:14,className:"text-green-500"}):W.status==="warn"?c.jsx(fa,{size:14,className:"text-amber-500"}):c.jsx(Pi,{size:14,className:"text-red-500"}),c.jsxs("div",{children:[c.jsx("span",{className:"text-sm text-[var(--color-text)]",children:W.name}),c.jsx("p",{className:"text-xs text-[var(--color-text-muted)]",children:W.message}),W.details&&W.status!=="pass"&&c.jsx("p",{className:"text-xs text-[var(--color-text-muted)] opacity-60",children:W.details})]})]})},W.name))})]}),c.jsx("div",{className:"space-y-2",children:I.map((W,re)=>{const se=W.key===d,ie=$>re||d==="done",Ae=d==="error"&&W.key===N;return c.jsxs("div",{className:"flex items-center gap-3",children:[ie?c.jsx(bt,{size:18,className:"text-green-500"}):Ae?c.jsx(Pi,{size:18,className:"text-red-500"}):se?c.jsx(ua,{size:18,className:"animate-spin text-[var(--color-primary)]"}):c.jsx("div",{className:"h-[18px] w-[18px] rounded-full border-2 border-[var(--color-border)]"}),c.jsx("span",{className:ne("text-sm",ie?"text-green-500":se?"font-medium text-[var(--color-text)]":"text-[var(--color-text-muted)]"),children:W.label})]},W.key)})}),(d==="starting"||d==="done"||d==="error")&&Object.keys(y).length>0&&c.jsxs("div",{className:"rounded-lg border border-[var(--color-border)] overflow-hidden",children:[c.jsx("div",{className:"border-b border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2",children:c.jsx("span",{className:"text-xs font-medium text-[var(--color-text-muted)]",children:"Service Status"})}),c.jsx("div",{className:"divide-y divide-[var(--color-border)]",children:Object.entries(y).map(([W,re])=>c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[c.jsx("span",{className:"text-sm text-[var(--color-text)]",children:W}),c.jsxs("div",{className:"flex items-center gap-2",children:[!re.healthy&&c.jsxs("button",{type:"button",onClick:()=>P(W),className:"flex items-center gap-1 text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text)]",children:[c.jsx(_N,{size:12}),"Logs"]}),re.healthy?c.jsx(bt,{size:14,className:"text-green-500"}):c.jsx(Pi,{size:14,className:"text-red-500"})]})]}),re.error&&c.jsx("p",{className:"px-3 pb-2 text-xs text-red-400",children:re.error}),w[W]&&c.jsx("div",{className:"mx-3 mb-2 max-h-32 overflow-auto rounded bg-[var(--color-background)] p-2 text-xs font-mono text-[var(--color-text-muted)]",children:c.jsx("pre",{className:"whitespace-pre-wrap",children:w[W]})})]},W))})]}),(s.lines.length>0||s.running)&&c.jsx(Cg,{lines:s.lines,running:s.running,title:"docker compose pull"}),(i.lines.length>0||i.running)&&c.jsx(Cg,{lines:i.lines,running:i.running,title:"docker compose up -d"}),m&&c.jsx("div",{className:"rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-500",children:m}),(d==="idle"||d==="error")&&c.jsxs("button",{type:"button",onClick:d==="error"?O:B,className:ne("flex w-full items-center justify-center gap-2 rounded-lg bg-[var(--color-primary)] px-4 py-3 font-medium text-white","hover:opacity-90 transition-opacity"),children:[d==="error"?c.jsx(fo,{size:18}):c.jsx(PN,{size:18}),d==="error"?"Retry Installation":"Start Installation"]})]})}function kE(){const{state:n,dispatch:r}=ul(),s=lv(),i=iv(),[d,f]=S.useState("select"),[m,g]=S.useState(null),[v,x]=S.useState("GGUF"),[y,p]=S.useState(""),[w,M]=S.useState(null);if(n.deploymentMode==="remote-llm")return c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-xl font-bold text-[var(--color-text)]",children:"LLM Configuration"}),c.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:"Your LLM is configured to use a remote server."})]}),c.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-green-500/30 bg-green-500/5 p-4",children:[c.jsx(bt,{size:20,className:"text-green-500"}),c.jsxs("div",{children:[c.jsx("p",{className:"text-sm font-medium text-[var(--color-text)]",children:"Remote LLM configured"}),c.jsx("p",{className:"text-xs text-[var(--color-text-muted)]",children:n.remoteLlmUrl})]})]})]});if(n.platform==="darwin")return c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-xl font-bold text-[var(--color-text)]",children:"LLM Configuration"}),c.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:"On macOS, the LLM proxy runs natively to access Metal/MLX. Configure it from the dashboard after setup, or run it directly from the jarvis-llm-proxy-api directory."})]}),c.jsx("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 p-4 text-sm text-amber-500",children:"macOS native LLM proxy is not yet available as a pip package. Model download through this wizard requires the LLM proxy running in Docker."})]});const N=O=>{g(O),M(null),O.gated&&!y.trim()?f("token"):R(O,y.trim())},j=()=>{if(!y.trim()){M("HuggingFace token is required for gated models");return}m&&R(m,y)},R=async(O,P)=>{f("downloading"),M(null);const I=v==="GGUF"?O.hfRepoGguf:O.hfRepoVllm,ee=v==="GGUF"?O.ggufFilename:void 0;try{await i.mutateAsync({repo:I,filename:ee,token:P||void 0}),await k(O)}catch($){M(`Download failed: ${$.message}`),f("select")}},k=async O=>{f("configuring");const I={"model.main.name":v==="GGUF"?`.models/${O.ggufFilename}`:`.models/${O.hfRepoVllm.split("/").pop()}`,"model.main.backend":v,"model.main.chat_format":O.chatFormat,"model.main.context_window":O.contextWindow,"llm.interface":O.promptProvider};v==="GGUF"&&(I["inference.gguf.n_gpu_layers"]=-1),v==="VLLM"&&O.quantization&&(I["inference.vllm.quantization"]=O.quantization);try{await s.mutateAsync(I),r({type:"SET_LLM_INTERFACE",interfaceId:O.promptProvider}),f("done")}catch(ee){M(`Configuration failed: ${ee.message}`),f("select")}},_=n.hardware?.gpuVramMb,B=_?ar.filter(O=>O.vramMb<=_):ar;return c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-xl font-bold text-[var(--color-text)]",children:"LLM Setup"}),c.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:d==="done"?"Model configured. The LLM proxy is restarting with the new model.":"Select and download a language model for Jarvis."})]}),w&&c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-red-500/30 bg-red-500/10 p-3 text-sm text-red-500",children:[c.jsx(fa,{size:16,className:"mt-0.5 shrink-0"}),w]}),m&&c.jsxs("button",{type:"button",onClick:()=>R(m,y),className:ne("flex w-full items-center justify-center gap-2 rounded-lg border border-[var(--color-border)] px-4 py-2 text-sm","hover:bg-[var(--color-surface-alt)] transition-colors"),children:[c.jsx(fo,{size:14}),"Retry Download"]})]}),d==="select"&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm font-medium text-[var(--color-text)]",children:"Backend"}),c.jsx("div",{className:"flex gap-2",children:["GGUF","VLLM"].map(O=>c.jsx("button",{type:"button",onClick:()=>x(O),className:ne("rounded-md px-3 py-1 text-xs font-medium transition-colors",v===O?"bg-[var(--color-primary)] text-white":"bg-[var(--color-surface-alt)] text-[var(--color-text-muted)] hover:text-[var(--color-text)]"),children:O==="VLLM"?"vLLM":O},O))})]}),c.jsxs("div",{children:[c.jsx("label",{htmlFor:"hf-token",className:"mb-1 block text-xs text-[var(--color-text-muted)]",children:"HuggingFace Token (optional — speeds up downloads, required for gated models)"}),c.jsx("input",{id:"hf-token",type:"password",value:y,onChange:O=>p(O.target.value),placeholder:"hf_...",className:ne("w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2","text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]","outline-none focus:ring-2 focus:ring-[var(--color-primary)]")})]}),c.jsxs("div",{className:"space-y-2",children:[B.map(O=>c.jsxs("button",{type:"button",onClick:()=>N(O),className:ne("flex w-full items-center justify-between rounded-lg border border-[var(--color-border)] p-3 text-left transition-colors","hover:border-[var(--color-primary)] hover:bg-[var(--color-surface-alt)]"),children:[c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-sm font-medium text-[var(--color-text)]",children:O.displayName}),O.gated&&c.jsxs("span",{className:"flex items-center gap-0.5 rounded bg-yellow-500/15 px-1.5 py-0.5 text-[10px] font-medium text-yellow-600 dark:text-yellow-400",children:[c.jsx(Cd,{size:10}),"Gated"]})]}),c.jsxs("p",{className:"mt-0.5 text-xs text-[var(--color-text-muted)]",children:[O.promptProvider," · ",O.contextWindow.toLocaleString()," ctx"]})]}),c.jsxs("span",{className:"text-xs text-[var(--color-text-muted)]",children:["~",v==="GGUF"?O.sizeGguf:O.sizeVllm]})]},O.id)),B.length===0&&c.jsxs("p",{className:"py-4 text-center text-sm text-[var(--color-text-muted)]",children:["No models fit your available VRAM (",_?Math.round(_/1024)+" GB":"unknown","). Consider using Remote LLM mode."]}),_&&B.length<ar.length&&c.jsxs("p",{className:"text-xs text-[var(--color-text-muted)]",children:["Showing ",B.length," of ",ar.length," models that fit your ",Math.round(_/1024)," GB VRAM."]})]})]}),d==="token"&&m&&c.jsxs("div",{className:"space-y-4",children:[c.jsxs("p",{className:"text-sm text-[var(--color-text-muted)]",children:[c.jsx("strong",{children:m.displayName})," is a gated model. Accept the license on HuggingFace and paste your access token below."]}),c.jsx("input",{type:"password",value:y,onChange:O=>p(O.target.value),placeholder:"hf_...",className:ne("w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2","text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]","outline-none focus:ring-2 focus:ring-[var(--color-primary)]")}),c.jsxs("div",{className:"flex justify-between",children:[c.jsx("button",{type:"button",onClick:()=>{f("select"),M(null)},className:"text-sm text-[var(--color-text-muted)] hover:text-[var(--color-text)]",children:"Back"}),c.jsx("button",{type:"button",onClick:j,className:"rounded-lg bg-[var(--color-primary)] px-4 py-2 text-sm text-white hover:opacity-90",children:"Download"})]})]}),d==="downloading"&&c.jsxs("div",{className:"flex flex-col items-center py-8",children:[c.jsx(fs,{className:"mb-4 animate-bounce text-[var(--color-primary)]",size:32}),c.jsxs("p",{className:"text-sm font-medium text-[var(--color-text)]",children:["Downloading ",m?.displayName,"..."]}),c.jsxs("p",{className:"mt-1 text-xs text-[var(--color-text-muted)]",children:["~",v==="GGUF"?m?.sizeGguf:m?.sizeVllm," · This may take several minutes"]})]}),d==="configuring"&&c.jsxs("div",{className:"flex flex-col items-center py-8",children:[c.jsx(ua,{className:"mb-4 animate-spin text-[var(--color-primary)]",size:32}),c.jsx("p",{className:"text-sm font-medium text-[var(--color-text)]",children:"Configuring model and prompt provider..."})]}),d==="done"&&m&&c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-green-500/30 bg-green-500/5 p-4",children:[c.jsx(bt,{size:20,className:"text-green-500"}),c.jsxs("div",{children:[c.jsxs("p",{className:"text-sm font-medium text-[var(--color-text)]",children:[m.displayName," configured"]}),c.jsxs("p",{className:"text-xs text-[var(--color-text-muted)]",children:["Backend: ",v," · Prompt provider: ",m.promptProvider]})]})]}),c.jsxs("p",{className:"text-xs text-[var(--color-text-muted)]",children:["The LLM proxy is restarting with the new model. It may take a minute to load. Command Center will automatically use the ",c.jsx("strong",{children:m.promptProvider})," prompt provider for optimized command parsing."]})]})]})}function DE(){const[n,r]=S.useState(""),[s,i]=S.useState(""),[d,f]=S.useState(""),[m,g]=S.useState(""),[v,x]=S.useState(!1),[y,p]=S.useState(!1),[w,M]=S.useState(null),N=s===d,j=n&&s&&d&&m&&N&&!v;async function R(){if(j){x(!0),M(null);try{const _=await Ax(n,s,m);tr(_.access_token),localStorage.setItem("access_token",_.access_token),localStorage.setItem("refresh_token",_.refresh_token),p(!0)}catch(_){const B=_?.response?.data?.error??(_ instanceof Error?_.message:"Failed to create account");M(B)}finally{x(!1)}}}if(y)return c.jsxs("div",{className:"space-y-6",children:[c.jsx("div",{children:c.jsx("h2",{className:"text-xl font-bold text-[var(--color-text)]",children:"Account Created"})}),c.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-green-500/30 bg-green-500/5 p-4",children:[c.jsx(bt,{size:20,className:"text-green-500"}),c.jsxs("div",{children:[c.jsx("p",{className:"text-sm font-medium text-[var(--color-text)]",children:"Superuser account created"}),c.jsx("p",{className:"text-xs text-[var(--color-text-muted)]",children:n})]})]}),c.jsx("p",{className:"text-sm text-[var(--color-text-muted)]",children:`You're logged in. Click "Next" to configure your LLM model.`})]});const k=ne("w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-alt)] px-3 py-2","text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]","outline-none focus:ring-2 focus:ring-[var(--color-primary)]");return c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-xl font-bold text-[var(--color-text)]",children:"Create Account"}),c.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:"Create your superuser account. This will be the admin for your Jarvis instance."})]}),c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{children:[c.jsx("label",{htmlFor:"display-name",className:"mb-1 block text-sm text-[var(--color-text-muted)]",children:"Display Name"}),c.jsx("input",{id:"display-name",type:"text",value:m,onChange:_=>g(_.target.value),className:k,placeholder:"Alex"})]}),c.jsxs("div",{children:[c.jsx("label",{htmlFor:"email",className:"mb-1 block text-sm text-[var(--color-text-muted)]",children:"Email"}),c.jsx("input",{id:"email",type:"email",value:n,onChange:_=>r(_.target.value),className:k,placeholder:"admin@example.com"})]}),c.jsxs("div",{children:[c.jsx("label",{htmlFor:"password",className:"mb-1 block text-sm text-[var(--color-text-muted)]",children:"Password"}),c.jsx("input",{id:"password",type:"password",value:s,onChange:_=>i(_.target.value),className:k,placeholder:"Choose a strong password"})]}),c.jsxs("div",{children:[c.jsx("label",{htmlFor:"confirm-password",className:"mb-1 block text-sm text-[var(--color-text-muted)]",children:"Confirm Password"}),c.jsx("input",{id:"confirm-password",type:"password",value:d,onChange:_=>f(_.target.value),className:ne(k,d&&!N&&"ring-2 ring-red-500"),placeholder:"Confirm password"}),d&&!N&&c.jsx("p",{className:"mt-1 text-xs text-red-500",children:"Passwords don't match"})]})]}),w&&c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-red-500/10 px-3 py-2",children:[c.jsx(Dx,{size:14,className:"text-red-500 shrink-0"}),c.jsx("span",{className:"text-sm text-red-500",children:w})]}),c.jsxs("button",{type:"button",onClick:R,disabled:!j,className:ne("flex w-full items-center justify-center gap-2 rounded-lg border border-[var(--color-border)] px-4 py-2 text-sm","hover:bg-[var(--color-surface-alt)] transition-colors","disabled:opacity-50"),children:[c.jsx(fo,{size:14}),"Retry"]})]}),!w&&c.jsx("button",{type:"button",onClick:R,disabled:!j,className:ne("w-full rounded-lg bg-[var(--color-primary)] px-4 py-2 font-medium text-white","hover:opacity-90 disabled:opacity-50 transition-opacity"),children:v?"Creating...":"Create Superuser Account"})]})}const Xi=[{label:"Welcome",component:CE},{label:"Hardware",component:_E},{label:"Services",component:ME},{label:"Review",component:OE},{label:"Install",component:zE},{label:"Account",component:DE},{label:"LLM",component:kE}],UE=5;function LE({skipToAccount:n}){const{state:r,dispatch:s}=ul();S.useEffect(()=>{n&&s({type:"SET_STEP",step:UE})},[n,s]);const i=tn(),d=Xi[r.currentStep].component,f=r.currentStep===0,m=r.currentStep===Xi.length-1,x=r.currentStep===4&&!r.installComplete,y=r.installRunning||x;function p(){m?i("/login"):s({type:"NEXT_STEP"})}function w(){s({type:"PREV_STEP"})}return c.jsx("div",{className:"flex min-h-screen items-center justify-center bg-[var(--color-background)] p-4",children:c.jsxs("div",{className:"w-full max-w-2xl",children:[c.jsx("div",{className:"mb-6 flex items-center justify-center gap-1",children:Xi.map((M,N)=>c.jsxs("button",{type:"button",onClick:()=>!y&&s({type:"SET_STEP",step:N}),disabled:y,className:ne("flex items-center gap-1",y&&"cursor-not-allowed"),children:[c.jsx("div",{className:ne("flex h-7 w-7 items-center justify-center rounded-full text-xs font-medium transition-colors",N===r.currentStep?"bg-[var(--color-primary)] text-white":N<r.currentStep?"bg-[var(--color-primary)]/20 text-[var(--color-primary)]":"bg-[var(--color-surface-alt)] text-[var(--color-text-muted)]"),children:N+1}),c.jsx("span",{className:ne("hidden text-xs sm:inline",N===r.currentStep?"font-medium text-[var(--color-text)]":"text-[var(--color-text-muted)]"),children:M.label}),N<Xi.length-1&&c.jsx("div",{className:ne("mx-1 h-px w-4 sm:w-6",N<r.currentStep?"bg-[var(--color-primary)]/30":"bg-[var(--color-border)]")})]},M.label))}),c.jsx("div",{className:"rounded-xl border border-[var(--color-border)] bg-[var(--color-surface)] p-6 shadow-lg",children:c.jsx(d,{})}),c.jsxs("div",{className:"mt-4 flex justify-between",children:[c.jsx("button",{type:"button",onClick:w,disabled:f||y,className:ne("rounded-lg border border-[var(--color-border)] px-4 py-2 text-sm","hover:bg-[var(--color-surface-alt)] transition-colors","disabled:invisible"),children:"Back"}),c.jsx("button",{type:"button",onClick:p,disabled:y,className:ne("rounded-lg bg-[var(--color-primary)] px-6 py-2 text-sm font-medium text-white","hover:opacity-90 transition-opacity","disabled:opacity-50 disabled:cursor-not-allowed"),children:m?"Finish":"Next"})]})]})})}function BE({skipToAccount:n}){return c.jsx(RE,{children:c.jsx(LE,{skipToAccount:n})})}function HE(){const n=tn(),r=lv(),s=$j(),[i,d]=S.useState("select"),[f,m]=S.useState(null),[g,v]=S.useState("GGUF"),[x,y]=S.useState(""),[p,w]=S.useState(null),M=_=>{m(_),_.gated?d("token"):j(_,"")},N=()=>{if(!x.trim()){w("HuggingFace token is required for gated models");return}w(null),f&&j(f,x)},j=async(_,B)=>{d("download"),w(null);const O=g==="GGUF"?_.hfRepoGguf:_.hfRepoVllm,P=g==="GGUF"?_.ggufFilename:void 0;try{await s.mutateAsync({repo:O,filename:P,token:B||void 0}),R(_)}catch(I){w(`Download failed: ${I.message}`),d("select")}},R=async _=>{d("configure"),w(null);const O={"model.main.name":g==="GGUF"?`.models/${_.ggufFilename}`:`.models/${_.hfRepoVllm.split("/").pop()}`,"model.main.backend":g,"model.main.chat_format":_.chatFormat,"model.main.context_window":_.contextWindow};g==="GGUF"&&(O["inference.gguf.n_gpu_layers"]=-1),g==="VLLM"&&_.quantization&&(O["inference.vllm.quantization"]=_.quantization);try{await r.mutateAsync(O),d("done"),Xe.success("LLM configured successfully")}catch(P){w(`Configuration failed: ${P.message}`),d("select")}},k=()=>{n("/dashboard")};return c.jsx("div",{className:"flex min-h-screen items-center justify-center bg-[var(--color-bg)] p-4",children:c.jsxs("div",{className:"w-full max-w-2xl rounded-xl border border-[var(--color-border)] bg-[var(--color-surface)] p-8 shadow-lg",children:[c.jsxs("div",{className:"mb-8 text-center",children:[c.jsx(ld,{className:"mx-auto mb-3 text-[var(--color-primary)]",size:40}),c.jsx("h1",{className:"text-2xl font-bold text-[var(--color-text)]",children:"LLM Setup"}),c.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:"Configure a local language model for Jarvis"})]}),c.jsx("div",{className:"mb-8 flex items-center justify-center gap-2",children:["select","download","configure","done"].map((_,B)=>{const O=i==="token"?"select":i,P=["select","download","configure","done"];return c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("div",{className:ne("h-2 w-2 rounded-full",O===_?"bg-[var(--color-primary)]":P.indexOf(O)>B?"bg-green-500":"bg-[var(--color-border)]")}),B<3&&c.jsx("div",{className:"h-px w-8 bg-[var(--color-border)]"})]},_)})}),p&&c.jsxs("div",{className:"mb-6 flex items-start gap-2 rounded-lg border border-red-500/30 bg-red-500/10 p-3 text-sm text-red-500",children:[c.jsx(fa,{size:16,className:"mt-0.5 shrink-0"}),p]}),i==="select"&&c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[c.jsx("h2",{className:"text-sm font-semibold text-[var(--color-text)]",children:"Select a model"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx("button",{onClick:()=>v("GGUF"),className:ne("rounded-md px-3 py-1 text-xs font-medium transition-colors",g==="GGUF"?"bg-[var(--color-primary)] text-white":"bg-[var(--color-surface-alt)] text-[var(--color-text-muted)] hover:text-[var(--color-text)]"),children:"GGUF"}),c.jsx("button",{onClick:()=>v("VLLM"),className:ne("rounded-md px-3 py-1 text-xs font-medium transition-colors",g==="VLLM"?"bg-[var(--color-primary)] text-white":"bg-[var(--color-surface-alt)] text-[var(--color-text-muted)] hover:text-[var(--color-text)]"),children:"vLLM"})]})]}),c.jsx("div",{className:"grid gap-3",children:ar.map(_=>c.jsxs("button",{onClick:()=>M(_),className:ne("flex items-center justify-between rounded-lg border border-[var(--color-border)] p-4 text-left transition-colors","hover:border-[var(--color-primary)] hover:bg-[var(--color-surface-alt)]"),children:[c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"font-medium text-[var(--color-text)]",children:_.displayName}),_.gated&&c.jsxs("span",{className:"flex items-center gap-1 rounded bg-yellow-500/15 px-1.5 py-0.5 text-[10px] font-medium text-yellow-600 dark:text-yellow-400",children:[c.jsx(Cd,{size:10}),"Gated"]})]}),c.jsxs("p",{className:"mt-0.5 text-xs text-[var(--color-text-muted)]",children:[_.quantization?`${_.quantization.toUpperCase()} 4-bit`:_.chatFormat," · ",_.contextWindow.toLocaleString()," ctx"]})]}),c.jsxs("span",{className:"text-sm text-[var(--color-text-muted)]",children:["~",g==="GGUF"?_.sizeGguf:_.sizeVllm]})]},_.id))}),c.jsx("div",{className:"flex justify-end pt-2",children:c.jsx("button",{onClick:k,className:"text-sm text-[var(--color-text-muted)] hover:text-[var(--color-text)]",children:"Skip for now"})})]}),i==="token"&&f&&c.jsxs("div",{className:"space-y-4",children:[c.jsx("h2",{className:"text-sm font-semibold text-[var(--color-text)]",children:"HuggingFace Access Required"}),c.jsxs("p",{className:"text-sm text-[var(--color-text-muted)]",children:[c.jsx("strong",{children:f.displayName})," is a gated model. You need to:"]}),c.jsxs("ol",{className:"list-inside list-decimal space-y-1 text-sm text-[var(--color-text-muted)]",children:[c.jsx("li",{children:"Visit the model page on huggingface.co and accept the license agreement"}),c.jsx("li",{children:"Create an access token at huggingface.co/settings/tokens"}),c.jsx("li",{children:"Paste your token below"})]}),c.jsx("input",{type:"password",value:x,onChange:_=>y(_.target.value),placeholder:"hf_...",className:ne("w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-bg)] px-3 py-2","text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]","outline-none focus:ring-2 focus:ring-[var(--color-primary)]")}),c.jsxs("div",{className:"flex justify-between",children:[c.jsx("button",{onClick:()=>{d("select"),w(null)},className:"text-sm text-[var(--color-text-muted)] hover:text-[var(--color-text)]",children:"Back"}),c.jsx("button",{onClick:N,className:"rounded-lg bg-[var(--color-primary)] px-4 py-2 text-sm text-white hover:opacity-90",children:"Continue"})]})]}),i==="download"&&c.jsxs("div",{className:"flex flex-col items-center py-8",children:[c.jsx(fs,{className:"mb-4 animate-bounce text-[var(--color-primary)]",size:32}),c.jsx("h2",{className:"text-lg font-semibold text-[var(--color-text)]",children:"Downloading model..."}),c.jsxs("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:[f?.displayName," ","(~",g==="GGUF"?f?.sizeGguf:f?.sizeVllm,")"]}),c.jsx("p",{className:"mt-4 text-xs text-[var(--color-text-muted)]",children:"This may take several minutes depending on your connection"})]}),i==="configure"&&c.jsxs("div",{className:"flex flex-col items-center py-8",children:[c.jsx(qx,{className:"mb-4 animate-spin text-[var(--color-primary)]",size:32}),c.jsx("h2",{className:"text-lg font-semibold text-[var(--color-text)]",children:"Configuring..."}),c.jsx("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:"Writing settings and restarting LLM proxy"})]}),i==="done"&&c.jsxs("div",{className:"flex flex-col items-center py-8",children:[c.jsx(xN,{className:"mb-4 text-green-500",size:40}),c.jsx("h2",{className:"text-lg font-semibold text-[var(--color-text)]",children:"LLM Ready"}),c.jsxs("p",{className:"mt-1 text-sm text-[var(--color-text-muted)]",children:[f?.displayName," configured on ",g]}),c.jsx("p",{className:"mt-1 text-xs text-[var(--color-text-muted)]",children:"The model service is restarting. It may take a minute to load the model."}),c.jsx("button",{onClick:()=>n("/dashboard"),className:"mt-6 rounded-lg bg-[var(--color-primary)] px-6 py-2 text-sm text-white hover:opacity-90",children:"Go to Dashboard"})]}),(s.isPending||r.isPending)&&i!=="download"&&i!=="configure"&&c.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",children:c.jsx(ua,{className:"animate-spin text-white",size:32})})]})})}const qE=new O1;function GE(){const[n,r]=S.useState(!0),[s,i]=S.useState(!1),[d,f]=S.useState(!1);return S.useEffect(()=>{Ad().then(m=>{m.state==="deployed-needs-account"?(f(!0),i(!0)):i(!m.configured)}).catch(()=>{i(!1)}).finally(()=>r(!1))},[]),n?c.jsx("div",{className:"flex min-h-screen items-center justify-center bg-[var(--color-background)]",children:c.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-[var(--color-primary)] border-t-transparent"})}):c.jsxs(C0,{children:[c.jsx(qt,{path:"/setup",element:c.jsx(BE,{skipToAccount:d})}),c.jsx(qt,{path:"/login",element:c.jsx(pj,{})}),c.jsx(qt,{path:"/llm-setup",element:c.jsx(HE,{})}),c.jsxs(qt,{element:c.jsx(hj,{}),children:[c.jsx(qt,{path:"/dashboard",element:c.jsx(nE,{})}),c.jsx(qt,{path:"/settings",element:c.jsx(Cj,{})}),c.jsx(qt,{path:"/services",element:c.jsx(Yj,{})}),c.jsx(qt,{path:"/models",element:c.jsx(vE,{})}),c.jsx(qt,{path:"/update",element:c.jsx(yE,{})}),c.jsx(qt,{path:"/reconcile",element:c.jsx(SE,{})}),c.jsx(qt,{path:"/nodes",element:c.jsx(fE,{})}),c.jsx(qt,{path:"/",element:s?c.jsx(Wi,{to:"/setup",replace:!0}):c.jsx(Wi,{to:"/dashboard",replace:!0})}),c.jsx(qt,{path:"*",element:c.jsx(NE,{})})]})]})}function QE(){return c.jsx(y2,{children:c.jsx(z1,{client:qE,children:c.jsxs(aN,{children:[c.jsx(I0,{children:c.jsx(GE,{})}),c.jsx(x2,{position:"bottom-right",richColors:!0})]})})})}Cb.createRoot(document.getElementById("root")).render(c.jsx(S.StrictMode,{children:c.jsx(QE,{})}));