@jean2/client 0.7.2 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/ServerContext-D9RfmQC6.js +1 -0
- package/dist/assets/SessionContent-DAoBLNGO.js +9 -0
- package/dist/assets/SessionMenuButton-B9RQW_iM.css +1 -0
- package/dist/assets/SessionMenuButton-BRiMfAN5.js +9 -0
- package/dist/assets/ThemeProvider-JPllbGvS.js +1 -0
- package/dist/assets/_serverId-Bd-hxE5e.js +2 -0
- package/dist/assets/_serverId-CsnPjy9K.js +12 -0
- package/dist/assets/_serverId-XYC72_6_.js +1 -0
- package/dist/assets/_sessionId-C96NK5UN.js +1 -0
- package/dist/assets/_sessionId-DdW2fnoe.js +1 -0
- package/dist/assets/alert-DeW1kArF.js +31 -0
- package/dist/assets/badge-DUoauaaV.js +45 -0
- package/dist/assets/confirmation-dialog-DeIbHoOu.js +1 -0
- package/dist/assets/core-CblztWA2.js +1 -0
- package/dist/assets/createLucideIcon-BaO6wACO.js +1 -0
- package/dist/assets/dropdown-menu-kSrbs3Xk.js +1 -0
- package/dist/assets/event-qUXFERHS.js +1 -0
- package/dist/assets/index-0foRHKn1.js +10 -0
- package/dist/assets/index-Bv9FJWM6.css +2 -0
- package/dist/assets/jsx-runtime-D-oznMWL.js +1 -0
- package/dist/assets/overview-ZVTPIcDN.js +1 -0
- package/dist/assets/overview-b6wqapV-.js +1 -0
- package/dist/assets/platform-Bn4qAxt4.js +1 -0
- package/dist/assets/popover-DqniPNsl.js +1 -0
- package/dist/assets/preload-helper-CYlqXMwt.js +1 -0
- package/dist/assets/react-DcCgrBX5.js +1 -0
- package/dist/assets/routes-BbfnvJnQ.js +1 -0
- package/dist/assets/scroll-area-DVew28V6.js +1 -0
- package/dist/assets/server-BNi58bIU.js +1 -0
- package/dist/assets/servers-CGl9kUR2.js +1 -0
- package/dist/assets/src-w2G0llvL.js +1 -0
- package/dist/assets/triangle-alert-DxjucLze.js +1 -0
- package/dist/assets/useNavigate-5b_LZg00.js +1 -0
- package/dist/assets/useParams-BODsv_8k.js +1 -0
- package/dist/assets/useRouterState-FezJSBQO.js +1 -0
- package/dist/assets/workspace-B2-0-561.js +1 -0
- package/dist/assets/workspace-BfFnK9TP.js +1 -0
- package/dist/index.html +13 -2
- package/package.json +1 -1
- package/dist/assets/index-D7f1FQwE.js +0 -630
- package/dist/assets/index-DaA31Q4k.css +0 -32
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e,t}from"./jsx-runtime-D-oznMWL.js";import{t as n}from"./react-DcCgrBX5.js";var r=e(n(),1),i=t(),a=`jean2-theme`,o=`neutral`,s=`system`,c=(0,r.createContext)({mode:s,scheme:o,setMode:()=>null,setScheme:()=>null,resolvedMode:`dark`});function l(){return window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}function u(e){return e===`system`?l():e}function d(e){let t=localStorage.getItem(a);if(!t||![`light`,`dark`,`system`].includes(t))return null;let n={mode:t,scheme:o};return localStorage.setItem(e,JSON.stringify(n)),localStorage.removeItem(a),n}function f({children:e,defaultMode:t=s,defaultScheme:n=o,storageKey:a=`jean2-theme-settings`,...l}){let[f,p]=(0,r.useState)(()=>{let e=d(a);if(e)return e;let r=localStorage.getItem(a);if(r)try{let e=JSON.parse(r);if(typeof e==`object`&&e&&`mode`in e&&`scheme`in e)return e}catch{}return{mode:t,scheme:n}}),[m,h]=(0,r.useState)(()=>u(f.mode)),g=(0,r.useCallback)((e,t)=>{let n=window.document.documentElement,r=u(e);n.classList.remove(`light`,`dark`),n.classList.remove(`neutral`,`ocean`,`forest`,`sunset`,`amethyst`),n.classList.add(r),n.classList.add(t),h(r)},[]);(0,r.useEffect)(()=>{g(f.mode,f.scheme)},[f,g]),(0,r.useEffect)(()=>{if(f.mode!==`system`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=()=>{g(f.mode,f.scheme)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[f.mode,f.scheme,g]);let _=(0,r.useCallback)(e=>{let t={...f,mode:e};p(t),localStorage.setItem(a,JSON.stringify(t))},[f,a]),v=(0,r.useCallback)(e=>{let t={...f,scheme:e};p(t),localStorage.setItem(a,JSON.stringify(t))},[f,a]),y={mode:f.mode,scheme:f.scheme,setMode:_,setScheme:v,resolvedMode:m};return(0,i.jsx)(c.Provider,{...l,value:y,children:e})}var p=()=>{let e=(0,r.useContext)(c);if(e===void 0)throw Error(`useTheme must be used within a ThemeProvider`);return e};export{p as n,f as t};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./_serverId-CsnPjy9K.js","./dropdown-menu-kSrbs3Xk.js","./src-w2G0llvL.js","./jsx-runtime-D-oznMWL.js","./react-DcCgrBX5.js","./badge-DUoauaaV.js","./createLucideIcon-BaO6wACO.js","./platform-Bn4qAxt4.js","./useParams-BODsv_8k.js","./servers-CGl9kUR2.js","./preload-helper-CYlqXMwt.js","./scroll-area-DVew28V6.js","./popover-DqniPNsl.js","./useNavigate-5b_LZg00.js","./useRouterState-FezJSBQO.js","./alert-DeW1kArF.js","./server-BNi58bIU.js","./ThemeProvider-JPllbGvS.js","./ServerContext-D9RfmQC6.js","./_serverId-XYC72_6_.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{i as e,t}from"./jsx-runtime-D-oznMWL.js";import{t as n}from"./react-DcCgrBX5.js";import{i as r,n as i,r as a}from"./src-w2G0llvL.js";import{D as o,O as s,_ as c,b as l,d as ee,k as te,u as ne,x as u,y as d}from"./servers-CGl9kUR2.js";import{E as f,a as re,c as p,f as ie,h as ae,m,n as h,s as g,t as _,v,y as oe}from"./useParams-BODsv_8k.js";import{n as y,t as b}from"./preload-helper-CYlqXMwt.js";import{t as x}from"./useNavigate-5b_LZg00.js";var se=`Error preloading route! ☝️`,S=class{get to(){return this._to}get id(){return this._id}get path(){return this._path}get fullPath(){return this._fullPath}constructor(e){if(this.init=e=>{var t,n;this.originalIndex=e.originalIndex;let r=this.options,i=!(r!=null&&r.path)&&!(r!=null&&r.id);this.parentRoute=(t=(n=this.options).getParentRoute)==null?void 0:t.call(n),i?this._path=p:this.parentRoute||f();let a=i?p:r==null?void 0:r.path;a&&a!==`/`&&(a=v(a));let o=(r==null?void 0:r.id)||a,s=i?p:m([this.parentRoute.id===`__root__`?``:this.parentRoute.id,o]);a===`__root__`&&(a=`/`),s!==`__root__`&&(s=m([`/`,s]));let c=s===`__root__`?`/`:m([this.parentRoute.fullPath,a]);this._path=a,this._id=s,this._fullPath=c,this._to=oe(c)},this.addChildren=e=>this._addFileChildren(e),this._addFileChildren=e=>(Array.isArray(e)&&(this.children=e),typeof e==`object`&&e&&(this.children=Object.values(e)),this),this._addFileTypes=()=>this,this.updateLoader=e=>(Object.assign(this.options,e),this),this.update=e=>(Object.assign(this.options,e),this),this.lazy=e=>(this.lazyFn=e,this),this.redirect=e=>g({from:this.fullPath,...e}),this.options=e||{},this.isRoot=!(e!=null&&e.getParentRoute),e!=null&&e.id&&e!=null&&e.path)throw Error(`Route cannot have both an 'id' and a 'path' option.`)}},C=class extends S{constructor(e){super(e)}};function w(e){let{select:t,...n}=e;return h({...n,select:e=>t?t(e.loaderDeps):e.loaderDeps})}function T(e){return h({from:e.from,strict:e.strict,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.search):t.search})}function E(e){return h({...e,select:t=>e.select?e.select(t.context):t.context})}var D=e(n(),1),O=t(),ce=e(r(),1);function k(e,t){var n,r,i;let a=ee(),o=s(t),{activeProps:u,inactiveProps:f,activeOptions:p,to:m,preload:h,preloadDelay:g,preloadIntentProximity:_,hashScrollIntoView:v,replace:oe,startTransition:y,resetScroll:b,viewTransition:x,children:S,target:C,disabled:w,style:T,className:E,onClick:O,onBlur:k,onFocus:N,onMouseEnter:P,onMouseLeave:F,onTouchStart:I,ignoreBlocker:L,params:_e,search:R,hash:z,state:B,mask:ve,reloadDocument:ye,unsafeRelative:be,from:xe,_fromLocation:Se,...Ce}=e,V=re(),H=D.useMemo(()=>e,[a,e.from,e._fromLocation,e.hash,e.to,e.search,e.params,e.state,e.mask,e.unsafeRelative]),U=ne(a.stores.location,e=>e,(e,t)=>e.href===t.href),W=D.useMemo(()=>{let e={_fromLocation:U,...H};return a.buildLocation(e)},[a,U,H]),we=W.maskedLocation?W.maskedLocation.publicHref:W.publicHref,Te=W.maskedLocation?W.maskedLocation.external:W.external,G=D.useMemo(()=>me(we,Te,a.history,w),[w,Te,we,a.history]),K=D.useMemo(()=>{if(G!=null&&G.external)return l(G.href,a.protocolAllowlist)?void 0:G.href;if(!he(m)&&!(typeof m!=`string`||m.indexOf(`:`)===-1))try{return new URL(m),l(m,a.protocolAllowlist)?void 0:m}catch{}},[m,G,a.protocolAllowlist]),q=D.useMemo(()=>{var e;if(K)return!1;if(p!=null&&p.exact){if(!ie(U.pathname,W.pathname,a.basepath))return!1}else{let e=ae(U.pathname,a.basepath),t=ae(W.pathname,a.basepath);if(!(e.startsWith(t)&&(e.length===t.length||e[t.length]===`/`)))return!1}return((e=p==null?void 0:p.includeSearch)==null||e)&&!c(U.search,W.search,{partial:!(p!=null&&p.exact),ignoreUndefined:!(p!=null&&p.explicitUndefined)})?!1:p!=null&&p.includeHash?V&&U.hash===W.hash:!0},[p==null?void 0:p.exact,p==null?void 0:p.explicitUndefined,p==null?void 0:p.includeHash,p==null?void 0:p.includeSearch,U,K,V,W.hash,W.pathname,W.search,a.basepath]),J=q?(n=d(u,{}))==null?le:n:A,Y=q||(r=d(f,{}))==null?A:r,Ee=[E,J.className,Y.className].filter(Boolean).join(` `),De=(T||J.style||Y.style)&&{...T,...J.style,...Y.style},[Oe,ke]=D.useState(!1),Ae=D.useRef(!1),X=e.reloadDocument||K?!1:h==null?a.options.defaultPreload:h,Z=(i=g==null?a.options.defaultPreloadDelay:g)==null?0:i,Q=D.useCallback(()=>{a.preloadRoute({...H,_builtLocation:W}).catch(e=>{console.warn(e),console.warn(se)})},[a,H,W]);te(o,D.useCallback(e=>{e!=null&&e.isIntersecting&&Q()},[Q]),pe,{disabled:!!w||X!==`viewport`}),D.useEffect(()=>{Ae.current||!w&&X===`render`&&(Q(),Ae.current=!0)},[w,Q,X]);let je=e=>{let t=e.currentTarget.getAttribute(`target`),n=C===void 0?t:C;if(!w&&!ge(e)&&!e.defaultPrevented&&(!n||n===`_self`)&&e.button===0){e.preventDefault(),(0,ce.flushSync)(()=>{ke(!0)});let t=a.subscribe(`onResolved`,()=>{t(),ke(!1)});a.navigate({...H,replace:oe,resetScroll:b,hashScrollIntoView:v,startTransition:y,viewTransition:x,ignoreBlocker:L})}};if(K)return{...Ce,ref:o,href:K,...S&&{children:S},...C&&{target:C},...w&&{disabled:w},...T&&{style:T},...E&&{className:E},...O&&{onClick:O},...k&&{onBlur:k},...N&&{onFocus:N},...P&&{onMouseEnter:P},...F&&{onMouseLeave:F},...I&&{onTouchStart:I}};let Me=e=>{if(w||X!==`intent`)return;if(!Z){Q();return}let t=e.currentTarget;if(j.has(t))return;let n=setTimeout(()=>{j.delete(t),Q()},Z);j.set(t,n)},Ne=e=>{w||X!==`intent`||Q()},$=e=>{if(w||!X||!Z)return;let t=e.currentTarget,n=j.get(t);n&&(clearTimeout(n),j.delete(t))};return{...Ce,...J,...Y,href:G==null?void 0:G.href,ref:o,onClick:M([O,je]),onBlur:M([k,$]),onFocus:M([N,Me]),onMouseEnter:M([P,Me]),onMouseLeave:M([F,$]),onTouchStart:M([I,Ne]),disabled:!!w,target:C,...De&&{style:De},...Ee&&{className:Ee},...w&&ue,...q&&de,...V&&Oe&&fe}}var A={},le={className:`active`},ue={role:`link`,"aria-disabled":!0},de={"data-status":`active`,"aria-current":`page`},fe={"data-transitioning":`transitioning`},j=new WeakMap,pe={rootMargin:`100px`},M=e=>t=>{for(let n of e)if(n){if(t.defaultPrevented)return;n(t)}};function me(e,t,n,r){if(!r)return t?{href:e,external:!0}:{href:n.createHref(e)||`/`,external:!1}}function he(e){if(typeof e!=`string`)return!1;let t=e.charCodeAt(0);return t===47?e.charCodeAt(1)!==47:t===46}var N=D.forwardRef((e,t)=>{let{_asChild:n,...r}=e,{type:i,...a}=k(r,t),o=typeof r.children==`function`?r.children({isActive:a[`data-status`]===`active`}):r.children;if(!n){let{disabled:e,...t}=a;return D.createElement(`a`,t,o)}return D.createElement(n,a,o)});function ge(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}var P=class extends S{constructor(e){super(e),this.useMatch=e=>h({select:e==null?void 0:e.select,from:this.id,structuralSharing:e==null?void 0:e.structuralSharing}),this.useRouteContext=e=>E({...e,from:this.id}),this.useSearch=e=>T({select:e==null?void 0:e.select,structuralSharing:e==null?void 0:e.structuralSharing,from:this.id}),this.useParams=e=>_({select:e==null?void 0:e.select,structuralSharing:e==null?void 0:e.structuralSharing,from:this.id}),this.useLoaderDeps=e=>w({...e,from:this.id}),this.useLoaderData=e=>y({...e,from:this.id}),this.useNavigate=()=>x({from:this.fullPath}),this.Link=D.forwardRef((e,t)=>(0,O.jsx)(N,{ref:t,from:this.fullPath,...e}))}};function F(e){return new P(e)}function I(){return e=>_e(e)}var L=class extends C{constructor(e){super(e),this.useMatch=e=>h({select:e==null?void 0:e.select,from:this.id,structuralSharing:e==null?void 0:e.structuralSharing}),this.useRouteContext=e=>E({...e,from:this.id}),this.useSearch=e=>T({select:e==null?void 0:e.select,structuralSharing:e==null?void 0:e.structuralSharing,from:this.id}),this.useParams=e=>_({select:e==null?void 0:e.select,structuralSharing:e==null?void 0:e.structuralSharing,from:this.id}),this.useLoaderDeps=e=>w({...e,from:this.id}),this.useLoaderData=e=>y({...e,from:this.id}),this.useNavigate=()=>x({from:this.fullPath}),this.Link=D.forwardRef((e,t)=>(0,O.jsx)(N,{ref:t,from:this.fullPath,...e}))}};function _e(e){return new L(e)}function R(e){return typeof e==`object`?new z(e,{silent:!0}).createRoute(e):new z(e,{silent:!0}).createRoute}var z=class{constructor(e,t){this.path=e,this.createRoute=e=>{let t=F(e);return t.isRoot=!1,t},this.silent=t==null?void 0:t.silent}};function B(e,t){let n,r,i,a,s=()=>(n||(n=e().then(e=>{n=void 0,r=e[t==null?`default`:t]}).catch(e=>{if(i=e,u(i)&&i instanceof Error&&typeof window<`u`&&typeof sessionStorage<`u`){let e=`tanstack_router_reload:${i.message}`;sessionStorage.getItem(e)||(sessionStorage.setItem(e,`1`),a=!0)}})),n),c=function(e){if(a)throw window.location.reload(),new Promise(()=>{});if(i)throw i;if(!r)if(o)o(s());else throw s();return D.createElement(r,e)};return c.preload=s,c}async function ve(e,t,n){return new i(new a({url:e,token:t})).loadAll({signal:n})}var ye=R(`/server/$serverId`)({beforeLoad:({params:e,context:t})=>{let n=t.serverRegistry.getServer(e.serverId);if(!n){let e=t.serverRegistry.getServers();throw e.length>0?g({to:`/server/$serverId`,params:{serverId:e[0].id},replace:!0,throw:!0}):g({to:`/`,replace:!0,throw:!0})}return{server:n}},loader:async({params:e,context:t,abortController:n})=>{let r=t.serverRegistry.getServer(e.serverId);if(!r)throw g({to:`/`,replace:!0,throw:!0});try{return await ve(r.url,r.token,n.signal)}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)throw e;let t=e instanceof Error?e.message:String(e);throw Error(`Failed to connect to server: ${t}`,{cause:e})}},component:B(()=>b(()=>import(`./_serverId-CsnPjy9K.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]),import.meta.url),`component`),errorComponent:B(()=>b(()=>import(`./_serverId-XYC72_6_.js`),__vite__mapDeps([19,3,9,4]),import.meta.url),`errorComponent`),pendingComponent:()=>(0,O.jsx)(`div`,{className:`w-full flex items-center justify-center min-h-screen bg-background text-foreground`,children:(0,O.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,O.jsx)(`div`,{className:`h-8 w-8 border-2 border-muted-foreground/30 border-t-muted-foreground rounded-full animate-spin mx-auto`}),(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Connecting to server...`})]})})});export{I as i,B as n,R as r,ye as t};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./event-qUXFERHS.js","./core-CblztWA2.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{i as e,t}from"./jsx-runtime-D-oznMWL.js";import{t as n}from"./react-DcCgrBX5.js";import{t as r}from"./src-w2G0llvL.js";import{n as i}from"./ThemeProvider-JPllbGvS.js";import{E as a,d as o,u as s}from"./servers-CGl9kUR2.js";import{t as c}from"./useParams-BODsv_8k.js";import{a as l,n as u,r as d,t as f}from"./platform-Bn4qAxt4.js";import{n as p,t as m}from"./preload-helper-CYlqXMwt.js";import{t as h}from"./useNavigate-5b_LZg00.js";import{t as g}from"./useRouterState-FezJSBQO.js";import{a as _,i as v,n as y,r as b}from"./ServerContext-D9RfmQC6.js";import{$ as x,B as S,H as C,I as w,J as T,L as E,Q as D,R as ee,V as O,X as k,Z as A,a as te,at as j,c as M,ct as N,d as P,dt as F,f as I,ft as ne,h as re,ht as L,i as ie,it as ae,l as oe,lt as se,mt as ce,n as le,o as ue,p as R,pt as de,q as fe,r as pe,rt as z,s as me,st as B,t as V,tt as he,u as H,ut as U,x as ge}from"./badge-DUoauaaV.js";import{t as W}from"./createLucideIcon-BaO6wACO.js";import{_ as G,a as _e,c as ve,d as ye,f as be,g as xe,h as Se,i as Ce,l as K,m as we,n as Te,p as Ee,r as De,s as Oe,t as ke,u as q}from"./alert-DeW1kArF.js";import{_ as Ae,a as je,c as Me,d as Ne,f as Pe,g as J,h as Fe,i as Ie,l as Le,o as Re,p as ze,r as Be,s as Ve,t as He,u as Ue,v as We,x as Ge,y as Ke}from"./popover-DqniPNsl.js";import{A as qe,C as Je,D as Ye,E as Xe,F as Ze,I as Qe,L as $e,O as et,P as tt,R as nt,S as rt,T as it,_ as at,a as ot,b as st,h as ct,i as lt,j as ut,k as dt,l as ft,m as pt,o as mt,r as ht,s as gt,t as _t,u as vt,v as yt,w as bt}from"./dropdown-menu-kSrbs3Xk.js";import{t as xt}from"./server-BNi58bIU.js";import{n as St,t as Ct}from"./scroll-area-DVew28V6.js";var Y=e(n(),1);function wt(e){let t=o(),n=(0,Y.useRef)(void 0);return s(t.stores.location,r=>{var i;let o=e!=null&&e.select?e.select(r):r;if((i=e==null?void 0:e.structuralSharing)==null?t.options.defaultStructuralSharing:i){let e=a(n.current,o);return n.current=e,e}return o})}var Tt=W(`boxes`,[[`path`,{d:`M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z`,key:`lc1i9w`}],[`path`,{d:`m7 16.5-4.74-2.85`,key:`1o9zyk`}],[`path`,{d:`m7 16.5 5-3`,key:`va8pkn`}],[`path`,{d:`M7 16.5v5.17`,key:`jnp8gn`}],[`path`,{d:`M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z`,key:`8zsnat`}],[`path`,{d:`m17 16.5-5-3`,key:`8arw3v`}],[`path`,{d:`m17 16.5 4.74-2.85`,key:`8rfmw`}],[`path`,{d:`M17 16.5v5.17`,key:`k6z78m`}],[`path`,{d:`M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z`,key:`1xygjf`}],[`path`,{d:`M12 8 7.26 5.15`,key:`1vbdud`}],[`path`,{d:`m12 8 4.74-2.85`,key:`3rx089`}],[`path`,{d:`M12 13.5V8`,key:`1io7kd`}]]),Et=W(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Dt=W(`file-exclamation-point`,[[`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:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Ot=W(`file-question-mark`,[[`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:`M12 17h.01`,key:`p32p05`}],[`path`,{d:`M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3`,key:`mhlwft`}]]),kt=W(`file-x-corner`,[[`path`,{d:`M11 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5`,key:`1jo35a`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m15 17 5 5`,key:`36xl1x`}],[`path`,{d:`m20 17-5 5`,key:`vdz27y`}]]),At=W(`key`,[[`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`}]]),jt=W(`keyboard`,[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]),Mt=W(`layers`,[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]]),Nt=W(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),Pt=W(`layout-list`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}],[`path`,{d:`M14 4h7`,key:`3xa0d5`}],[`path`,{d:`M14 9h7`,key:`1icrd9`}],[`path`,{d:`M14 15h7`,key:`1mj8o2`}],[`path`,{d:`M14 20h7`,key:`11slyb`}]]),Ft=W(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),It=W(`monitor`,[[`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`}]]),Lt=W(`moon`,[[`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`}]]),Rt=W(`palette`,[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]),zt=W(`plug-zap`,[[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m18 3-4 4h6l-4 4`,key:`16psg9`}]]),Bt=W(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),Vt=W(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),Ht=W(`sun`,[[`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`}]]),Ut=W(`unplug`,[[`path`,{d:`m19 5 3-3`,key:`yk6iyv`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z`,key:`1snsnr`}]]),Wt=W(`volume-2`,[[`path`,{d:`M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z`,key:`uqj9uw`}],[`path`,{d:`M16 9a5 5 0 0 1 0 6`,key:`1q6k2b`}],[`path`,{d:`M19.364 18.364a9 9 0 0 0 0-12.728`,key:`ijwkga`}]]),Gt=W(`volume-x`,[[`path`,{d:`M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z`,key:`uqj9uw`}],[`line`,{x1:`22`,x2:`16`,y1:`9`,y2:`15`,key:`1ewh16`}],[`line`,{x1:`16`,x2:`22`,y1:`9`,y2:`15`,key:`5ykzw1`}]]),X=t();function Kt({children:e}){let t=p({from:`/server/$serverId`,strict:!1,structuralSharing:!0}),n=c({from:`/server/$serverId`,strict:!1}).serverId;return(0,Y.useLayoutEffect)(()=>{if(!t)return;let e=(t.models||[]).filter(e=>{var t;return(t=e.runtimeStatus)==null?void 0:t.usable});z.getState().hydrate(n==null?``:n,{workspaces:t.workspaces,preconfigs:t.preconfigs,prompts:t.prompts,models:e,defaultModel:t.defaultModel||`gpt-4o`,defaultProvider:t.defaultProvider||`openai`,providers:t.providers});let r=localStorage.getItem(`activeWorkspaceId`),i=t.workspaces;if(r){let e=i.find(e=>e.id===r);e?z.getState().setActiveWorkspace(e):i.length>0&&z.getState().setActiveWorkspace(i[0])}else i.length>0&&z.getState().setActiveWorkspace(i[0])},[t,n]),(0,Y.useEffect)(()=>()=>{ae(),z.getState().clearAll()},[]),t?(0,X.jsx)(X.Fragment,{children:e}):(0,X.jsx)(`div`,{className:`flex items-center justify-center min-h-screen bg-background text-foreground`,children:(0,X.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,X.jsx)(`div`,{className:`h-8 w-8 border-2 border-muted-foreground/30 border-t-muted-foreground rounded-full animate-spin mx-auto`}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading server data...`})]})})}var qt=e=>Symbol.iterator in e,Jt=e=>`entries`in e,Yt=(e,t)=>{let n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(let[e,t]of n)if(!r.has(e)||!Object.is(t,r.get(e)))return!1;return!0},Xt=(e,t)=>{let n=e[Symbol.iterator](),r=t[Symbol.iterator](),i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(!Object.is(i.value,a.value))return!1;i=n.next(),a=r.next()}return!!i.done&&!!a.done};function Zt(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:qt(e)&&qt(t)?Jt(e)&&Jt(t)?Yt(e,t):Xt(e,t):Yt({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function Z(e){let t=Y.useRef(void 0);return n=>{let r=e(n);return Zt(t.current,r)?t.current:t.current=r}}function Qt(e,t){let{session:n}=e,{setSessions:r,setCurrentSession:i,setMessagesBySession:a,setPartsBySession:o,setSessionUsage:s,setCurrentModel:c,setSelectedVariant:l,pendingSessionCreateRef:u,sessionAccessTimesRef:d,partIdIndexRef:f,defaultModel:p}=t;if(r(e=>[n,...e]),u.current){var m;i(n),a({[n.id]:[]}),o({[n.id]:{}}),f.current.clear(),s({promptTokens:0,completionTokens:0,totalTokens:0}),c(n.selectedModel||p),l((m=n.selectedVariant)==null?null:m),u.current=!1,t.navigateToSession(n.id)}d.current.set(n.id,Date.now())}function $t(e,t){var n;let{session:r,messages:i,usage:a,isRunning:o}=e,{setCurrentSession:s,removeInterruptedSession:c,addStreamingSession:l,removeStreamingSession:u,skipFinishSoundSessionIdsRef:d,setMessagesBySession:f,setPartsBySession:p,setSessionUsage:m,setCurrentModel:h,setSelectedVariant:g,sessionAccessTimesRef:_,partIdIndexRef:v,models:y,defaultModel:b,clearCompletion:x}=t;if(s(r),c(r.id),x(r.id),o?l(r.id):(u(r.id),d.current.add(r.id)),i){f({[r.id]:i.map(e=>e.message)}),p(()=>{let e={};e[r.id]={};for(let t of i)e[r.id][t.message.id]=t.parts;return e}),v.current.clear();for(let e of i)for(let t=0;t<e.parts.length;t++)v.current.set(e.parts[t].id,{sessionId:r.id,messageId:e.message.id,index:t})}m(a==null?{promptTokens:0,completionTokens:0,totalTokens:0}:a),h(r.selectedModel||b),g(r.selectedVariant||null);let S=r.selectedModel||b,C=(n=y.find(e=>e.id===S))==null?void 0:n.variants;r.selectedVariant&&C&&!C[r.selectedVariant]&&g(null),_.current.set(r.id,Date.now())}function en(e,t){let{sessionId:n}=e,{setSessions:r,setMessagesBySession:i,setPartsBySession:a,setCurrentSession:o,partIdIndexRef:s,partAppendRafRef:c,pendingPartAppendsRef:l,sessionAccessTimesRef:u,currentSessionIdRef:d,clearCompletion:f}=t;r(e=>e.map(e=>e.id===n?{...e,status:`closed`}:e)),f(n),d.current===n&&(c.current!==null&&(cancelAnimationFrame(c.current),c.current=null),l.current.clear()),i(e=>{let t={...e};return delete t[n],t}),a(e=>{let t={...e};return delete t[n],t});for(let[e,t]of s.current)t.sessionId===n&&s.current.delete(e);u.current.delete(n),d.current===n&&(o(null),t.navigateToParent())}function tn(e,t){let{session:n}=e,{setSessions:r,setCurrentSession:i,currentSessionIdRef:a}=t;r(e=>e.map(e=>e.id===n.id?n:e)),a.current===n.id&&i(n)}function nn(e,t){let{sessionId:n}=e,{setSessions:r,setMessagesBySession:i,setPartsBySession:a,removeInterruptedSession:o,partIdIndexRef:s,sessionAccessTimesRef:c,setCurrentSession:l,currentSessionIdRef:u,clearCompletion:d}=t;r(e=>e.filter(e=>e.id!==n)),d(n),i(e=>{let t={...e};return delete t[n],t}),a(e=>{let t={...e};return delete t[n],t}),o(n);for(let[e,t]of s.current)t.sessionId===n&&s.current.delete(e);c.current.delete(n),u.current===n&&(l(null),t.navigateToParent())}function rn(e,t){let{session:n}=e,{setSessions:r,setCurrentSession:i,setSelectedVariant:a,setCurrentModel:o,currentSessionIdRef:s}=t;r(e=>e.map(e=>e.id===n.id?n:e)),s.current===n.id&&(i(n),n.selectedVariant!==void 0&&a(n.selectedVariant),n.selectedModel&&o(n.selectedModel))}function an(e,t){let{session:n}=e,{setSessions:r,setCurrentSession:i,currentSessionIdRef:a}=t;r(e=>e.map(e=>e.id===n.id?n:e)),a.current===n.id&&i(n)}function on(e,t){let{sessionId:n,result:r}=e,{addInterruptedSession:i,skipFinishSoundSessionIdsRef:a,removeStreamingSession:o}=t;i(n),a.current.add(n),o(n),r.cascadedTo.length>0&&console.log(`Session ${n} interrupted. Cascaded to:`,r.cascadedTo)}function sn(e,t){let{sessionId:n,revertedTo:r,removed:i}=e;r.messageId===null?console.log(`Session ${n} cleared (all ${i.messageIds.length} messages removed)`):console.log(`Session ${n} reverted to message ${r.messageId}, removed ${i.messageIds.length} messages`)}function cn(e,t){let{forkedSession:n,messages:r}=e,{setSessions:i,setCurrentSession:a,setMessagesBySession:o,setPartsBySession:s,setSessionUsage:c,sessionAccessTimesRef:l,partIdIndexRef:u,clearCompletion:d}=t;i(e=>[n,...e]),o({[n.id]:r.map(e=>e.message)}),s(()=>{let e={};e[n.id]={};for(let t of r)e[n.id][t.message.id]=t.parts;return e}),u.current.clear();for(let e of r)for(let t=0;t<e.parts.length;t++)u.current.set(e.parts[t].id,{sessionId:n.id,messageId:e.message.id,index:t});a(n),t.navigateToSession(n.id),c({promptTokens:0,completionTokens:0,totalTokens:0}),l.current.set(n.id,Date.now()),d(n.id)}function ln(e,t){let{sessionId:n,messages:r}=e,{setMessagesBySession:i,setPartsBySession:a,partIdIndexRef:o,partAppendRafRef:s,skipFinishSoundSessionIdsRef:c,removeStreamingSession:l,sessionAccessTimesRef:u,flushPendingPartAppends:d,currentSessionIdRef:f,clearCompletion:p}=t;if(f.current===n&&(s.current!==null&&(cancelAnimationFrame(s.current),s.current=null),d()),f.current===n){i({[n]:r.map(e=>e.message)}),a(()=>{let e={};e[n]={};for(let t of r)e[n][t.message.id]=t.parts;return e}),o.current.clear();for(let e of r)for(let t=0;t<e.parts.length;t++)o.current.set(e.parts[t].id,{sessionId:n,messageId:e.message.id,index:t})}c.current.add(n),l(n),u.current.set(n,Date.now()),p(n)}var Q={"session.created":Qt,"session.resumed":$t,"session.closed":en,"session.reopened":tn,"session.deleted":nn,"session.updated":rn,"session.renamed":an,"session.interrupted":on,"session.reverted":sn,"session.forked":cn,"session.state":ln};function un(e,t){let{message:n}=e,{setMessagesBySession:r,setPartsBySession:i,addStreamingSession:a,removeInterruptedSession:o,currentSessionIdRef:s,clearCompletion:c}=t;c(n.sessionId),n.sessionId===s.current&&(r(e=>({...e,[n.sessionId]:[...e[n.sessionId]||[],n]})),i(e=>({...e,[n.sessionId]:{...e[n.sessionId],[n.id]:[]}}))),n.sessionId===s.current&&`status`in n&&n.status===`streaming`&&(a(n.sessionId),o(n.sessionId))}function dn(e,t){let{message:n}=e,{setMessagesBySession:r,removeStreamingSession:i,partAppendRafRef:a,partAppendTimeoutRef:o,flushPendingPartAppends:s,currentSessionIdRef:c,sessionsRef:l,setCompletion:u,chatFinishSoundEnabledRef:d,playChatFinishSound:f}=t;if(n.sessionId===c.current&&(`status`in n&&n.status!==`streaming`&&(a.current!==null&&(cancelAnimationFrame(a.current),a.current=null),o.current!==null&&(clearTimeout(o.current),o.current=null),s()),r(e=>({...e,[n.sessionId]:(e[n.sessionId]||[]).map(e=>e.id===n.id?n:e)}))),`status`in n&&n.status!==`streaming`){i(n.sessionId);let e=l.current.find(e=>e.id===n.sessionId);if(e&&e.parentId===null){let e=Date.now();u(n.sessionId,{type:`flash-only`,flashStartedAt:e}),d.current&&f()}}}function fn(e,t){let{sessionId:n,part:r}=e,{setPartsBySession:i,partIdIndexRef:a,currentSessionIdRef:o,clearCompletion:s}=t;if(s(n),n===o.current){i(e=>{let t=e[n]||{},i=t[r.messageId]||[];return{...e,[n]:{...t,[r.messageId]:[...i,r]}}});let e=0;for(let t of a.current.values())t.sessionId===n&&t.messageId===r.messageId&&(e=Math.max(e,t.index+1));a.current.set(r.id,{sessionId:n,messageId:r.messageId,index:e})}}function pn(e,t){let{sessionId:n,part:r}=e,{setPartsBySession:i,partIdIndexRef:a,currentSessionIdRef:o,clearCompletion:s}=t;if(s(n),n===o.current){let e=a.current.get(r.id);i(e?t=>{let n=t[e.sessionId];if(!n)return t;let i=n[e.messageId];if(!i)return t;let a=[...i];return a[e.index]=r,{...t,[e.sessionId]:{...n,[e.messageId]:a}}}:e=>{let t=e[n]||{},i=t[r.messageId]||[];return{...e,[n]:{...t,[r.messageId]:i.map(e=>e.id===r.id?r:e)}}})}}function mn(e,t){let{sessionId:n,partId:r,delta:i}=e,{addStreamingSession:a,pendingPartAppendsRef:o,partAppendRafRef:s,lastPartAppendFlushAtRef:c,partAppendTimeoutRef:l,interruptedSessions:u,currentSessionIdRef:d,flushPendingPartAppends:f,clearCompletion:p}=t;if(p(n),n===d.current&&!u.has(n)&&a(n),n===d.current){let e=o.current.get(r);o.current.set(r,(e||``)+i);let t=Date.now()-c.current;if(t<50){if(l.current===null){let e=50-t;l.current=setTimeout(()=>{l.current=null,s.current===null&&(s.current=requestAnimationFrame(()=>{f()}))},e)}}else s.current===null&&(s.current=requestAnimationFrame(()=>{f()}))}}function hn(e,t){let{sessionId:n,usage:r,model:i}=e,{setSessionUsage:a,setCurrentModel:o,currentSessionIdRef:s}=t;n===s.current&&(a({promptTokens:r.promptTokens,completionTokens:r.completionTokens,totalTokens:r.totalTokens}),o(i))}function gn(e,t){let{sessionId:n}=e,{setCompactionSuccess:r,currentSessionIdRef:i}=t;n===i.current&&r(!0)}function _n(e,t){let{code:n,message:r}=e;console.error(`Server error:`,n,r)}var vn={"message.created":un,"message.updated":dn,"part.created":fn,"part.updated":pn,"part.append":mn,"chat.usage":hn,"compaction.complete":gn,error:_n};function yn(e,t){let{permissions:n}=e,{setPermissions:r}=t;r(n)}function bn(e,t){let{approvals:n}=e,{mergePendingPermissions:r}=t;r(n.map(e=>({toolCallId:e.toolCallId,sessionId:e.sessionId,toolName:e.toolName,args:e.args,permissionType:e.permissionType,permissionKey:e.permissionKey,message:e.message,details:e.details,dangerous:e.dangerous,childSessionId:e.childSessionId,subagentName:e.subagentName})))}function xn(e,t){let{permissionId:n}=e,{setPermissions:r}=t;r(e=>e.map(e=>e.id===n?{...e,revokedAt:new Date().toISOString()}:e))}function Sn(e,t){let{setPermissions:n}=t;n(e=>{let t=new Date().toISOString();return e.map(e=>({...e,revokedAt:t}))})}function Cn(e,t){let{sessionId:n,toolCallId:r,toolName:i,args:a,permissionType:o,permissionKey:s,message:c,details:l,dangerous:u,childSessionId:d,subagentName:f}=e,{addPendingPermission:p,sessionsRef:m,notifiedToolCallIdsRef:h,permissionSoundEnabledRef:g,playPermissionSound:_}=t;p({toolCallId:r,sessionId:n,toolName:i,args:a,permissionType:o,permissionKey:s,message:c,details:l,dangerous:u,childSessionId:d,subagentName:f});let v=m.current.find(e=>e.id===n);(v==null?void 0:v.parentId)===null&&g.current&&!h.current.has(r)&&(_(),h.current.add(r))}function wn(e,t){let{toolCallId:n}=e,{removePendingPermissionByToolCallId:r}=t;r(n)}function Tn(e,t){let{sessionId:n,messages:r}=e,{setQueuedMessagesForSession:i}=t;i(n,r)}function En(e,t){let{sessionId:n,message:r}=e,{addQueuedMessage:i}=t;i(n,r)}function Dn(e,t){let{sessionId:n,queueId:r}=e,{removeQueuedMessageById:i}=t;i(n,r)}function On(e,t){let{sessionId:n,queueId:r}=e,{removeQueuedMessageById:i}=t;i(n,r)}var kn={"permission.list":yn,"permissions.sync":bn,"permission.revoked":xn,"permission.all_revoked":Sn,"permission.request":Cn,"permission.granted":wn,"queue.list":Tn,"queue.added":En,"queue.removed":Dn,"queue.sending":On};function An(e,t){let{provider:n,connected:r,authorizationUrl:i,error:a}=e,{setProviderStatuses:o}=t;o(e=>e.find(e=>e.provider===n)?e.map(e=>e.provider===n?{...e,connected:r,authorizationUrl:i,error:a}:e):[...e,{provider:n,connected:r,authorizationUrl:i,error:a}])}function jn(e,t){let{provider:n,connected:r,connectedAt:i,accountId:a}=e,{setProviderStatuses:o}=t;o(e=>e.map(e=>e.provider===n?{...e,connected:r,connectedAt:i,accountId:a}:e))}var Mn={"provider.status":An,"provider.connected":jn};function Nn(e,t){let n=()=>t.current,r=[];function i(t,n){e.on(t,n),r.push({event:t,handler:n})}return i(`session.created`,e=>{Q[`session.created`]({type:`session.created`,session:e},n())}),i(`session.resumed`,(e,t,r,i)=>{Q[`session.resumed`]({type:`session.resumed`,session:e,messages:t,usage:r,isRunning:i},n())}),i(`session.closed`,e=>{Q[`session.closed`]({type:`session.closed`,sessionId:e},n())}),i(`session.reopened`,e=>{Q[`session.reopened`]({type:`session.reopened`,session:e},n())}),i(`session.deleted`,e=>{Q[`session.deleted`]({type:`session.deleted`,sessionId:e},n())}),i(`session.updated`,e=>{Q[`session.updated`]({type:`session.updated`,session:e},n())}),i(`session.renamed`,e=>{Q[`session.renamed`]({type:`session.renamed`,session:e},n())}),i(`session.interrupted`,(e,t)=>{Q[`session.interrupted`]({type:`session.interrupted`,sessionId:e,result:t},n())}),i(`session.reverted`,(e,t,r)=>{Q[`session.reverted`]({type:`session.reverted`,sessionId:e,revertedTo:t,removed:r},n())}),i(`session.forked`,(e,t,r)=>{Q[`session.forked`]({type:`session.forked`,originalSessionId:e,forkedSession:t,messages:r},n())}),i(`session.state`,(e,t)=>{Q[`session.state`]({type:`session.state`,sessionId:e,messages:t},n())}),i(`message.created`,e=>{vn[`message.created`]({type:`message.created`,message:e},n())}),i(`message.updated`,e=>{vn[`message.updated`]({type:`message.updated`,message:e},n())}),i(`part.created`,(e,t)=>{vn[`part.created`]({type:`part.created`,sessionId:e,part:t},n())}),i(`part.updated`,(e,t)=>{vn[`part.updated`]({type:`part.updated`,sessionId:e,part:t},n())}),i(`part.append`,(e,t,r,i)=>{vn[`part.append`]({type:`part.append`,sessionId:e,partId:t,field:r,delta:i},n())}),i(`chat.usage`,(e,t,r)=>{vn[`chat.usage`]({type:`chat.usage`,sessionId:e,usage:t,model:r},n())}),i(`compaction.complete`,(e,t)=>{vn[`compaction.complete`]({type:`compaction.complete`,sessionId:e,tokensUsed:t},n())}),i(`permission.list`,(e,t)=>{kn[`permission.list`]({type:`permission.list`,workspaceId:e,permissions:t},n())}),i(`permissions.sync`,e=>{kn[`permissions.sync`]({type:`permissions.sync`,approvals:e},n())}),i(`permission.revoked`,e=>{kn[`permission.revoked`]({type:`permission.revoked`,permissionId:e},n())}),i(`permission.all_revoked`,(e,t)=>{kn[`permission.all_revoked`]({type:`permission.all_revoked`,workspaceId:e,count:t},n())}),i(`permission.request`,(e,t,r,i,a,o,s,c,l,u,d)=>{kn[`permission.request`]({type:`permission.request`,sessionId:e,childSessionId:t,subagentName:r,toolCallId:i,toolName:a,args:o,permissionType:s,permissionKey:c,message:l,details:u,dangerous:d},n())}),i(`permission.granted`,(e,t)=>{kn[`permission.granted`]({type:`permission.granted`,toolCallId:e,cached:t},n())}),i(`queue.list`,(e,t)=>{kn[`queue.list`]({type:`queue.list`,sessionId:e,messages:t},n())}),i(`queue.added`,(e,t)=>{kn[`queue.added`]({type:`queue.added`,sessionId:e,message:t},n())}),i(`queue.removed`,(e,t)=>{kn[`queue.removed`]({type:`queue.removed`,sessionId:e,queueId:t},n())}),i(`queue.sending`,(e,t)=>{kn[`queue.sending`]({type:`queue.sending`,sessionId:e,queueId:t},n())}),i(`provider.status`,(e,t,r,i)=>{Mn[`provider.status`]({type:`provider.status`,provider:e,connected:t,authorizationUrl:r,error:i},n())}),i(`provider.connected`,(e,t,r,i)=>{Mn[`provider.connected`]({type:`provider.connected`,provider:e,connected:t,connectedAt:r,accountId:i},n())}),i(`error`,(e,t)=>{vn.error({type:`error`,code:e,message:t},n())}),()=>{for(let{event:t,handler:n}of r)e.off(t,n)}}var Pn=1e4,Fn=3e4,In=1e3;function Ln({apiToken:e,serverUrl:t,currentSessionIdRef:n,handlerContextRef:i,clearPendingPermissions:a,handleLogout:o,clientRef:s}){let c=(0,Y.useRef)(null),l=s==null?c:s,[u,d]=(0,Y.useState)(0),f=(0,Y.useCallback)(()=>{k.getState().setRetryCount(0),k.getState().setConnectionTimedOut(!1),k.getState().setNextRetryIn(0),d(e=>e+1)},[]),p=k(e=>e.connected),m=k(e=>e.connectionTimedOut);return(0,Y.useEffect)(()=>{if(!e||!t)return;let s=new r({url:t,token:e,autoSyncPermissions:!1});l.current=s,s.on(`connected`,()=>{k.getState().setConnected(!0),k.getState().setAuthError(null),k.getState().setRetryCount(0),k.getState().setConnectionTimedOut(!1),a(),n.current&&s.sessions.resume(n.current),s.permissions.sync()}),s.on(`disconnected`,e=>{k.getState().setConnected(!1),e.code===1008||e.code===401?o():k.getState().setConnectionTimedOut(!0)}),s.on(`error.connection`,e=>{console.error(`WebSocket error:`,e)});let c=Nn(s,i);return s.connect().catch(e=>{console.error(`Connection failed:`,e)}),()=>{c(),s.dispose(),l.current===s&&(l.current=null)}},[e,t,u]),(0,Y.useEffect)(()=>{if(e&&t&&!p&&!m){let e=setTimeout(()=>{k.getState().connected||k.getState().setConnectionTimedOut(!0)},Pn);return()=>clearTimeout(e)}},[e,t,u,p,m]),(0,Y.useEffect)(()=>{if(!m||p||!e||!t)return;let n=k.getState().retryCount,r=Math.min(In*2**n,Fn),i=Math.floor(r/1e3);k.getState().setNextRetryIn(i);let a=setInterval(()=>{--i,k.getState().setNextRetryIn(Math.max(0,i))},1e3),o=setTimeout(()=>{k.getState().setRetryCount(e=>e+1),d(e=>e+1)},r);return()=>{clearInterval(a),clearTimeout(o)}},[e,t,u,p,m]),(0,Y.useEffect)(()=>{let n=()=>{if(!e||!t)return;let n=l.current;n&&n.connected||(k.getState().setConnected(!1),k.getState().setRetryCount(0),k.getState().setConnectionTimedOut(!1),d(e=>e+1))};return window.addEventListener(`online`,n),()=>window.removeEventListener(`online`,n)},[e,t]),(0,Y.useEffect)(()=>{let n=()=>{var n;if(document.visibilityState!==`visible`)return;let r=l.current;r&&((n=r.ws)==null?void 0:n.readyState)===WebSocket.OPEN||!e||!t||(k.getState().setRetryCount(0),k.getState().setConnectionTimedOut(!1),d(e=>e+1))};return document.addEventListener(`visibilitychange`,n),()=>document.removeEventListener(`visibilitychange`,n)},[e,t]),{clientRef:l,retry:f}}function Rn({clientRef:e,currentSession:t,sessions:n,workspaces:r,activeWorkspace:i,currentModel:a,streamingSessionIds:o,isCompacting:s,primaryPreconfigs:c,setActiveWorkspace:l,setCompactionSuccess:u,setCurrentModel:d,setSelectedVariant:f,removePendingPermissionByToolCallId:p,removePendingPermissionsBySessionId:m,clearStreamingSessions:h,pendingSessionCreateRef:g,partAppendRafRef:_,pendingPartAppendsRef:v,skipFinishSoundSessionIdsRef:y,navigate:b,serverId:x,viewPath:S}){let C=(0,Y.useCallback)((t,n)=>{let r=e.current;g.current=!0,_.current!==null&&(cancelAnimationFrame(_.current),_.current=null),v.current.clear(),r&&r.connected&&r.sessions.create({preconfigId:t,title:n,workspaceId:i==null?void 0:i.id}),u(!1)},[e,_,v,g,i,u]),w=(0,Y.useCallback)(t=>{let a=e.current;m(t),y.current=new Set(k.getState().streamingSessionIds),h(),u(!1);let o=n.find(e=>e.id===t);if(o!=null&&o.workspaceId&&o.workspaceId!==(i==null?void 0:i.id)){let e=r.find(e=>e.id===o.workspaceId);e&&l(e)}_.current!==null&&(cancelAnimationFrame(_.current),_.current=null),v.current.clear(),a&&a.connected&&a.sessions.resume(t),b({to:`/server/$serverId${S}/session/$sessionId`,params:{serverId:x,sessionId:t}})},[e,_,v,y,n,r,i,l,m,h,u,b,x,S]),T=(0,Y.useCallback)(t=>{let n=e.current;n&&n.connected&&n.sessions.close(t)},[e]),E=(0,Y.useCallback)((t,n)=>{let r=e.current;r&&r.connected&&r.sessions.revert(t,n)},[e]),D=(0,Y.useCallback)((t,n)=>{let r=e.current;r&&r.connected&&r.sessions.fork(t,n)},[e]),ee=(0,Y.useCallback)(t=>{let n=e.current;n&&n.connected&&n.sessions.compact(t)},[e]),O=(0,Y.useCallback)(t=>{let n=e.current;n&&n.connected&&n.sessions.reopen(t)},[e]),A=(0,Y.useCallback)(t=>{let n=e.current;n&&n.connected&&n.sessions.delete(t)},[e]),te=(0,Y.useCallback)(n=>{let r=e.current;r&&r.connected&&t&&r.sessions.update(t.id,{preconfigId:n})},[e,t]),j=(0,Y.useCallback)((n,r)=>{let i=e.current;d(n),f(null),i&&i.connected&&t&&i.sessions.updateModel(t.id,{modelId:n,providerId:r})},[e,t,d,f]),M=(0,Y.useCallback)(n=>{let r=e.current;r&&r.connected&&t&&(r.sessions.updateModel(t.id,{modelId:t.selectedModel||a,providerId:t.selectedProvider||`openai`,variant:n==null?void 0:n}),f(n))},[e,t,a,f]),N=(0,Y.useCallback)((t,n)=>{let r=e.current;r&&r.connected&&r.sessions.rename(t,n)},[e]),P=(0,Y.useCallback)(()=>{t!=null&&t.parentId&&w(t.parentId)},[t,w]),F=(0,Y.useCallback)((t,n,r)=>{let i=e.current;i&&i.connected&&i.queue.add(t,n,r)},[e]);return{createSession:C,resumeSession:w,closeSession:T,reopenSession:O,permanentlyDeleteSession:A,handleRenameSession:N,revertSession:E,forkSession:D,compactSession:ee,addToQueue:F,removeFromQueue:(0,Y.useCallback)(t=>{let n=e.current;n&&n.connected&&n.queue.remove(t)},[e]),sendChatMessage:(0,Y.useCallback)((n,r)=>{let i=e.current;!t||s||(t.runningAt||o.has(t.id)?F(t.id,n,r):i&&i.connected&&i.chat.send(t.id,n,r?{attachments:r}:void 0))},[e,t,o,s,F]),handlePermissionResponse:(0,Y.useCallback)((t,n,r)=>{let i=e.current;p(t),i&&i.connected&&i.permissions.respond(t,n,r)},[e,p]),handleInterruptSession:(0,Y.useCallback)(()=>{let n=e.current;n&&n.connected&&t&&n.sessions.interrupt(t.id)},[e,t]),updateSessionPreconfig:te,updateSessionModel:j,updateSessionVariant:M,handleNavigateBack:P,refreshPermissions:(0,Y.useCallback)(()=>{let t=e.current;t&&t.connected&&i&&t.permissions.list(i.id)},[e,i]),createSessionInWorkspace:(0,Y.useCallback)(t=>{var n;let i=e.current;l(r.find(e=>e.id===t)||null),g.current=!0,_.current!==null&&(cancelAnimationFrame(_.current),_.current=null),v.current.clear();let a=(n=c[0])==null?void 0:n.id;i&&i.connected&&i.sessions.create({preconfigId:a,workspaceId:t}),u(!1)},[e,_,v,g,r,c,l,u]),revokePermission:(0,Y.useCallback)(t=>{let n=e.current;n&&n.connected&&n.permissions.revoke(t)},[e]),revokeAllPermissions:(0,Y.useCallback)(t=>{let n=e.current;n&&n.connected&&n.permissions.revokeAll(t)},[e])}}var zn={chatFinish:``+new URL(`chat-finish-Kb8mnIhV.mp3`,import.meta.url).href,chatPermission:``+new URL(`chat-permission-BltPnMpz.mp3`,import.meta.url).href};function Bn(){let e=(0,Y.useRef)(null),t=(0,Y.useRef)({}),n=(0,Y.useRef)(!1),r=(0,Y.useRef)(null),i=(0,Y.useRef)(0),a=(0,Y.useCallback)(async()=>{let n=e.current;return(!n||n.state===`closed`)&&(n=new AudioContext,e.current=n,t.current={}),n.state===`suspended`&&await n.resume(),n},[]),o=(0,Y.useCallback)(async(e,n)=>{if(t.current[e]){var r;return(r=t.current[e])==null?null:r}try{let r=await fetch(zn[e]);if(!r.ok)throw Error(`HTTP ${r.status}`);let i=await r.arrayBuffer(),a=await n.decodeAudioData(i);return t.current[e]=a,a}catch(t){return console.warn(`[useNotificationSound] Failed to load`,e,t),null}},[]),s=(0,Y.useCallback)((e,t)=>{try{let n=t.createBufferSource();n.buffer=e,n.connect(t.destination),n.start(0)}catch(e){console.warn(`[useNotificationSound] Playback error`,e)}},[]),c=(0,Y.useCallback)(async()=>{if(n.current)return;let e=await a();if(e.state!==`running`)return;let t=r.current;if(r.current=null,t){let n=await o(t,e);n&&s(n,e)}n.current=!0},[a,o,s]),l=(0,Y.useCallback)(()=>{let e=()=>{document.removeEventListener(`click`,e),document.removeEventListener(`keydown`,e),document.removeEventListener(`touchstart`,e),c()};document.addEventListener(`click`,e),document.addEventListener(`keydown`,e),document.addEventListener(`touchstart`,e)},[c]),d=(0,Y.useCallback)(async e=>{if(n.current){let t=await a();if(t.state!==`running`)return;let n=await o(e,t);n&&s(n,t);return}r.current=e,l()},[a,o,s,l]),p=(0,Y.useCallback)(async e=>{if(f()){let n=Date.now();if(n>i.current)try{var t;await((t=window.__JEAN2_ELECTRON__)==null?void 0:t.playSound(e)),i.current=n+1e3;return}catch(e){console.warn(`[useNotificationSound] Electron native playback failed, falling back to Web Audio`,e)}await d(e);return}if(u()){let t=Date.now();if(t>i.current)try{let{invoke:t}=await m(async()=>{let{invoke:e}=await import(`./core-CblztWA2.js`);return{invoke:e}},[],import.meta.url);await t(`play_sound`,{soundKey:e});return}catch(n){let r=n instanceof Error?n.message:String(n);console.warn(`[useNotificationSound] Native playback failed for ${e}, error: ${r}`),i.current=t+1e3}await d(e);return}await d(e)},[d]),h=(0,Y.useCallback)(()=>{p(`chatFinish`)},[p]),g=(0,Y.useCallback)(()=>{p(`chatPermission`)},[p]);return(0,Y.useEffect)(()=>()=>{let t=e.current;t&&t.state!==`closed`&&t.close(),e.current=null},[]),{playChatFinishSound:h,playPermissionSound:g,playSound:p}}function Vn({serverId:e,activeServer:t,navigate:n,removeFromQuickConnectionsByWorkspace:r,quickConnections:i}){var a,o,s;let l=(0,Y.useRef)(null),u=(0,Y.useRef)(null),d=(0,Y.useRef)([]),f=(0,Y.useRef)({}),p=(0,Y.useRef)(new Map),m=(0,Y.useRef)(0),h=(0,Y.useRef)(new Set),_=(0,Y.useRef)(new Map),v=(0,Y.useRef)(new Map),b=(0,Y.useRef)(null),x=(0,Y.useRef)(0),S=(0,Y.useRef)(null),C=(0,Y.useRef)(new Set),w=(0,Y.useRef)(!1),T=(0,Y.useRef)(null),{sessions:E,setSessions:ee}=j(Z(e=>({sessions:e.sessions,setSessions:e.setSessions}))),{setCurrentSession:O}=j(Z(e=>({setCurrentSession:e.setCurrentSession}))),{setMessagesBySession:te,setPartsBySession:M}=j(Z(e=>({setMessagesBySession:e.setMessagesBySession,setPartsBySession:e.setPartsBySession}))),N=c({from:`/server/$serverId`,strict:!1}),P=N==null?void 0:N.sessionId,F=g({select:e=>e.location.pathname}).includes(`/overview`)?`/overview`:`/workspace`,I=(0,Y.useMemo)(()=>{var e;return P?(e=E.find(e=>e.id===P))==null?null:e:null},[P,E]),ne=P!=null&&I==null;(0,Y.useEffect)(()=>{let e=j.getState().currentSession;(I==null?void 0:I.id)!==(e==null?void 0:e.id)&&O(I)},[I,O]);let re=I==null?void 0:I.id,L=j(Z(e=>re&&e.messagesBySession[re]||[])),ie=j(Z(e=>re&&e.partsBySession[re]||{}));(0,Y.useLayoutEffect)(()=>{f.current=j.getState().messagesBySession});let{streamingSessionIds:ae,interruptedSessions:oe,addStreamingSession:se,removeStreamingSession:ce,addInterruptedSession:le,removeInterruptedSession:ue}=k(Z(e=>({streamingSessionIds:e.streamingSessionIds,interruptedSessions:e.interruptedSessions,addStreamingSession:e.addStreamingSession,removeStreamingSession:e.removeStreamingSession,addInterruptedSession:e.addInterruptedSession,removeInterruptedSession:e.removeInterruptedSession}))),{sessionUsage:R,currentModel:de,selectedVariant:fe,setSessionUsage:pe,setCurrentModel:me,setSelectedVariant:B}=j(Z(e=>({sessionUsage:e.sessionUsage,currentModel:e.currentModel,selectedVariant:e.selectedVariant,setSessionUsage:e.setSessionUsage,setCurrentModel:e.setCurrentModel,setSelectedVariant:e.setSelectedVariant}))),{workspaces:V,preconfigs:he,prompts:H,models:U,defaultModel:ge}=z(Z(e=>({workspaces:e.workspaces,preconfigs:e.preconfigs,prompts:e.prompts,models:e.models,defaultModel:e.defaultModel}))),W=z(e=>e.activeWorkspace),G=U,_e=ge;(0,Y.useEffect)(()=>{var e;let t=(e=G.find(e=>e.id===de))==null?void 0:e.variants;fe&&t&&!t[fe]&&B(null)},[de,fe,G,B]);let{setCompletion:ve,clearCompletion:ye,clearAllCompletions:be}=tt(Z(e=>({setCompletion:e.setCompletion,clearCompletion:e.clearCompletion,clearAllCompletions:e.clearAllCompletions}))),{chatFinishSoundEnabled:xe,permissionSoundEnabled:Se}=A(Z(e=>({chatFinishSoundEnabled:e.chatFinishSoundEnabled,permissionSoundEnabled:e.permissionSoundEnabled}))),Ce=(0,Y.useRef)(Se);(0,Y.useLayoutEffect)(()=>{Ce.current=Se},[Se]);let K=(0,Y.useRef)(xe);(0,Y.useLayoutEffect)(()=>{K.current=xe},[xe]);let[we,Te]=(0,Y.useState)([]),[Ee,De]=(0,Y.useState)([]),{pendingPermissions:Oe,clearPendingPermissions:ke,mergePendingPermissions:q,addPendingPermission:Ae,removePendingPermissionByToolCallId:je,removePendingPermissionsBySessionId:Me}=D(Z(e=>({pendingPermissions:e.pendingPermissions,clearPendingPermissions:e.clearPendingPermissions,mergePendingPermissions:e.mergePendingPermissions,addPendingPermission:e.addPendingPermission,removePendingPermissionByToolCallId:e.removePendingPermissionByToolCallId,removePendingPermissionsBySessionId:e.removePendingPermissionsBySessionId}))),{queuedMessages:Ne,clearQueuedMessages:Pe,setQueuedMessagesForSession:J,addQueuedMessage:Fe,removeQueuedMessageById:Ie}=j(Z(e=>({queuedMessages:e.queuedMessages,clearQueuedMessages:e.clearQueuedMessages,setQueuedMessagesForSession:e.setQueuedMessagesForSession,addQueuedMessage:e.addQueuedMessage,removeQueuedMessageById:e.removeQueuedMessageById}))),Le=k(e=>e.authError),Re=k(e=>e.connectionTimedOut),ze=k(e=>e.retryCount),Be=k(e=>e.nextRetryIn),Ve=k(e=>e.connected),He=(a=I==null?void 0:I.compacting)==null?!1:a,{compactionSuccess:Ue,setCompactionSuccess:We}=j(Z(e=>({compactionSuccess:e.compactionSuccess,setCompactionSuccess:e.setCompactionSuccess}))),{playChatFinishSound:Ge,playPermissionSound:Ke}=Bn(),qe=(0,Y.useCallback)(()=>{if(b.current!==null&&(cancelAnimationFrame(b.current),b.current=null),S.current!==null&&(clearTimeout(S.current),S.current=null),v.current.size===0)return;let e=new Map(v.current);v.current.clear(),x.current=Date.now(),M(t=>{let n={...t},r=!1;for(let[t,i]of e){let e=_.current.get(t);if(!e)continue;let a=n[e.sessionId];if(!a)continue;let o=a[e.messageId];if(!o)continue;let s=o[e.index];if(!s||s.type!==`text`&&s.type!==`reasoning`)continue;r=!0;let c=[...o];c[e.index]={...s,text:s.text+i},n[e.sessionId]={...a,[e.messageId]:c}}return r?n:t})},[M]);(0,Y.useLayoutEffect)(()=>{let e=j.getState().getMessagesBySessionKeysCount();if(e<=m.current){m.current=e;return}if(m.current=e,e<=1)return;let t=f.current,n=Object.keys(t);for(;n.length>1;){let e=null,t=1/0;for(let r of n){if(r===(I==null?void 0:I.id))continue;let n=p.current.get(r);n!==void 0&&n<t&&(t=n,e=r)}if(!e)break;p.current.delete(e);for(let[t,n]of _.current)n.sessionId===e&&_.current.delete(t);n.splice(n.indexOf(e),1),te(t=>{if(!(e in t))return t;let n={...t};return delete n[e],n}),M(t=>{if(!(e in t))return t;let n={...t};return delete n[e],n})}},[I,te,M]);let Je=(o=t==null?void 0:t.token)==null?null:o,Ye=(s=t==null?void 0:t.url)==null?null:s,Xe=l.current;(0,Y.useEffect)(()=>{var e;u.current=(e=I==null?void 0:I.id)==null?null:e},[I]),(0,Y.useEffect)(()=>{h.current.clear()},[I==null?void 0:I.id]),(0,Y.useLayoutEffect)(()=>{d.current=E},[E]);let Ze=(0,Y.useCallback)(e=>e===re?L.map(e=>({message:e,parts:(ie[e.id]||[]).sort((e,t)=>e.createdAt-t.createdAt)})):[],[re,L,ie]),{removeServer:Qe}=y(),$e=(0,Y.useCallback)(()=>{var e;t&&(Qe(t.id),n({to:`/`})),(e=l.current)==null||e.dispose(),k.getState().resetConnection()},[t,Qe,n,l]),{retry:et}=Ln({apiToken:Je,serverUrl:Ye,currentSessionIdRef:u,handlerContextRef:T,clearPendingPermissions:ke,handleLogout:$e,clientRef:l}),nt=(0,Y.useCallback)(()=>{et()},[et]),rt=async(t,r,i)=>{var a;let o=(a=l.current)==null?void 0:a.httpClient;if(!o)return;let s=(await o.post(`/workspaces`,{name:t,path:r,isVirtual:i})).workspace;return z.getState().setWorkspaces([...z.getState().workspaces,s]),z.getState().setActiveWorkspace(s),localStorage.setItem(`activeWorkspaceId`,s.id),O(null),n({to:`/server/$serverId/workspace`,params:{serverId:e}}),s},it=(0,Y.useCallback)(t=>{z.getState().setActiveWorkspace(t),localStorage.setItem(`activeWorkspaceId`,t.id),O(null),n({to:`/server/$serverId/workspace`,params:{serverId:e}})},[O,n,e]),at=async t=>{var i;let a=(i=l.current)==null?void 0:i.httpClient;if(!a)return;let o=[];try{o=(await a.delete(`/workspaces/${t}`)).deletedSessions}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`Failed to delete workspace:`,t);return}r(t),I&&(I.workspaceId===t||o.includes(I.id))&&(O(null),n({to:`/server/$serverId/workspace`,params:{serverId:e}})),ee(e=>e.filter(e=>!o.includes(e.id))),te(e=>{let t={...e};return o.forEach(e=>delete t[e]),t}),M(e=>{let t={...e};return o.forEach(e=>delete t[e]),t}),o.forEach(e=>p.current.delete(e));for(let[e,t]of _.current)o.includes(t.sessionId)&&_.current.delete(e);let s=z.getState().workspaces;z.getState().setWorkspaces(s.filter(e=>e.id!==t));let c=z.getState().activeWorkspace;if((c==null?void 0:c.id)===t){let e=s.filter(e=>e.id!==t)[0]||null;z.getState().setActiveWorkspace(e),e?localStorage.setItem(`activeWorkspaceId`,e.id):localStorage.removeItem(`activeWorkspaceId`)}},ot=async(e,t)=>{var n;let r=(n=l.current)==null?void 0:n.httpClient;if(r)try{var i;let n=(await r.patch(`/workspaces/${e}`,{name:t})).workspace,a=z.getState().workspaces;z.getState().setWorkspaces(a.map(t=>t.id===e?n:t)),((i=z.getState().activeWorkspace)==null?void 0:i.id)===e&&z.getState().setActiveWorkspace(n)}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`Failed to rename workspace:`,t);return}},st=async()=>{await rt(`Workspace ${V.length+1}`,`~/.jean2/workspaces/${crypto.randomUUID()}`,!0)},ct=async e=>{await rt(e.split(`/`).pop()||e.split(`\\`).pop()||`Workspace`,e,!1)};(0,Y.useLayoutEffect)(()=>{T.current={setSessions:ee,setCurrentSession:O,setMessagesBySession:te,setPartsBySession:M,setSessionUsage:pe,setCurrentModel:me,setSelectedVariant:B,addStreamingSession:se,removeStreamingSession:ce,addInterruptedSession:le,removeInterruptedSession:ue,setQueuedMessagesForSession:J,addQueuedMessage:Fe,removeQueuedMessageById:Ie,clearPendingPermissions:ke,clearQueuedMessages:Pe,setCompactionSuccess:We,setCompletion:ve,clearCompletion:ye,clearAllCompletions:be,pendingSessionCreateRef:w,sessionAccessTimesRef:p,partIdIndexRef:_,partAppendRafRef:b,pendingPartAppendsRef:v,lastPartAppendFlushAtRef:x,partAppendTimeoutRef:S,skipFinishSoundSessionIdsRef:C,currentSessionIdRef:u,models:z.getState().models,defaultModel:z.getState().defaultModel,interruptedSessions:oe,sessionsRef:d,flushPendingPartAppends:qe,setProviderStatuses:De,setPermissions:Te,mergePendingPermissions:q,addPendingPermission:Ae,removePendingPermissionByToolCallId:je,notifiedToolCallIdsRef:h,permissionSoundEnabledRef:Ce,playPermissionSound:Ke,chatFinishSoundEnabledRef:K,playChatFinishSound:Ge,navigateToSession:t=>{n({to:`/server/$serverId${F}/session/$sessionId`,params:{serverId:e,sessionId:t}})},navigateToParent:()=>{n({to:`/server/$serverId${F}`,params:{serverId:e}})},serverId:e}});let lt=he.filter(e=>e.mode!==`subagent`),{createSession:ut,resumeSession:dt,closeSession:ft,reopenSession:pt,permanentlyDeleteSession:mt,handleRenameSession:ht,revertSession:gt,forkSession:_t,compactSession:vt,removeFromQueue:yt,sendChatMessage:bt,handlePermissionResponse:xt,handleInterruptSession:St,updateSessionPreconfig:Ct,updateSessionModel:wt,updateSessionVariant:Tt,handleNavigateBack:Et,refreshPermissions:Dt,createSessionInWorkspace:Ot,revokePermission:kt,revokeAllPermissions:At}=Rn({clientRef:l,currentSession:I,sessions:E,workspaces:V,activeWorkspace:W,currentModel:de,streamingSessionIds:ae,isCompacting:He,primaryPreconfigs:lt,setActiveWorkspace:e=>z.getState().setActiveWorkspace(e),setCompactionSuccess:We,setCurrentModel:me,setSelectedVariant:B,removePendingPermissionByToolCallId:je,removePendingPermissionsBySessionId:Me,clearStreamingSessions:k.getState().clearStreamingSessions,pendingSessionCreateRef:w,partAppendRafRef:b,pendingPartAppendsRef:v,skipFinishSoundSessionIdsRef:C,navigate:n,serverId:e,viewPath:F}),jt=E.filter(e=>e.workspaceId===(W==null?void 0:W.id)),Mt=i.filter(e=>e.serverId===(t==null?void 0:t.id)&&e.workspaceId).map(e=>e.workspaceId);return{connected:Ve,authError:Le,connectionTimedOut:Re,retryCount:ze,nextRetryIn:Be,serverUrl:Ye,apiToken:Je,sdkClient:Xe,currentSession:I,sessions:E,workspaceSessions:jt,messagesWithParts:I?Ze(I.id):[],pendingPermissions:Oe,queuedMessages:Ne,sessionUsage:R,currentModel:de,selectedVariant:fe,isCompacting:He,compactionSuccess:Ue,isPrimarySession:!(I!=null&&I.parentId),isSessionLoading:ne,workspaces:V,activeWorkspace:W,preconfigs:he,primaryPreconfigs:lt,prompts:H,models:G,defaultModel:_e,streamingSessionIds:ae,createSession:ut,resumeSession:dt,closeSession:ft,reopenSession:pt,permanentlyDeleteSession:mt,handleRenameSession:ht,revertSession:gt,forkSession:_t,compactSession:vt,removeFromQueue:yt,sendChatMessage:bt,handlePermissionResponse:xt,handleInterruptSession:St,updateSessionPreconfig:Ct,updateSessionModel:wt,updateSessionVariant:Tt,handleNavigateBack:Et,refreshPermissions:Dt,createSessionInWorkspace:Ot,revokePermission:kt,revokeAllPermissions:At,selectWorkspace:it,renameWorkspace:ot,handleCreateVirtualWorkspace:st,handleCreatePhysicalWorkspace:ct,deleteWorkspace:at,handleLogout:$e,handleRetry:nt,favoritedWorkspaceIds:Mt,setCompactionSuccess:We,permissions:we}}function Hn(e){let t=Y.useRef({value:e,previous:e});return Y.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Un=`Label`,Wn=Y.forwardRef((e,t)=>(0,X.jsx)(C.label,{...e,ref:t,onMouseDown:t=>{var n;t.target.closest(`button, input, select, textarea`)||((n=e.onMouseDown)==null||n.call(e,t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));Wn.displayName=Un;var Gn=Wn,Kn=`Progress`,qn=100,[Jn,Yn]=O(Kn),[Xn,Zn]=Jn(Kn),Qn=Y.forwardRef((e,t)=>{let{__scopeProgress:n,value:r=null,max:i,getValueLabel:a=tr,...o}=e;(i||i===0)&&!ir(i)&&console.error(or(`${i}`,`Progress`));let s=ir(i)?i:qn;r!==null&&!ar(r,s)&&console.error(sr(`${r}`,`Progress`));let c=ar(r,s)?r:null,l=rr(c)?a(c,s):void 0;return(0,X.jsx)(Xn,{scope:n,value:c,max:s,children:(0,X.jsx)(C.div,{"aria-valuemax":s,"aria-valuemin":0,"aria-valuenow":rr(c)?c:void 0,"aria-valuetext":l,role:`progressbar`,"data-state":nr(c,s),"data-value":c==null?void 0:c,"data-max":s,...o,ref:t})})});Qn.displayName=Kn;var $n=`ProgressIndicator`,er=Y.forwardRef((e,t)=>{var n;let{__scopeProgress:r,...i}=e,a=Zn($n,r);return(0,X.jsx)(C.div,{"data-state":nr(a.value,a.max),"data-value":(n=a.value)==null?void 0:n,"data-max":a.max,...i,ref:t})});er.displayName=$n;function tr(e,t){return`${Math.round(e/t*100)}%`}function nr(e,t){return e==null?`indeterminate`:e===t?`complete`:`loading`}function rr(e){return typeof e==`number`}function ir(e){return rr(e)&&!isNaN(e)&&e>0}function ar(e,t){return rr(e)&&!isNaN(e)&&e<=t&&e>=0}function or(e,t){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${t}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${qn}\`.`}function sr(e,t){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${t}\`. The \`value\` prop must be:
|
|
3
|
+
- a positive number
|
|
4
|
+
- less than the value passed to \`max\` (or ${qn} if no \`max\` prop is set)
|
|
5
|
+
- \`null\` or \`undefined\` if the progress is indeterminate.
|
|
6
|
+
|
|
7
|
+
Defaulting to \`null\`.`}var cr=Qn,lr=er,ur=`Switch`,[dr,fr]=O(ur),[pr,mr]=dr(ur),hr=Y.forwardRef((e,t)=>{let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c=`on`,onCheckedChange:l,form:u,...d}=e,[f,p]=Y.useState(null),m=fe(t,e=>p(e)),h=Y.useRef(!1),g=f?u||!!f.closest(`form`):!0,[_,v]=ee({prop:i,defaultProp:a==null?!1:a,onChange:l,caller:ur});return(0,X.jsxs)(pr,{scope:n,checked:_,disabled:s,children:[(0,X.jsx)(C.button,{type:`button`,role:`switch`,"aria-checked":_,"aria-required":o,"data-state":br(_),"data-disabled":s?``:void 0,disabled:s,value:c,...d,ref:m,onClick:S(e.onClick,e=>{v(e=>!e),g&&(h.current=e.isPropagationStopped(),h.current||e.stopPropagation())})}),g&&(0,X.jsx)(yr,{control:f,bubbles:!h.current,name:r,value:c,checked:_,required:o,disabled:s,form:u,style:{transform:`translateX(-100%)`}})]})});hr.displayName=ur;var gr=`SwitchThumb`,_r=Y.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=mr(gr,n);return(0,X.jsx)(C.span,{"data-state":br(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});_r.displayName=gr;var vr=`SwitchBubbleInput`,yr=Y.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{let o=Y.useRef(null),s=fe(o,a),c=Hn(n),l=ge(t);return Y.useEffect(()=>{let e=o.current;if(!e)return;let t=window.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(t,`checked`).set;if(c!==n&&i){let t=new Event(`click`,{bubbles:r});i.call(e,n),e.dispatchEvent(t)}},[c,n,r]),(0,X.jsx)(`input`,{type:`checkbox`,"aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:s,style:{...i.style,...l,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0}})});yr.displayName=vr;function br(e){return e?`checked`:`unchecked`}var xr=hr,Sr=_r,Cr=`Tabs`,[wr,Tr]=O(Cr,[dt]),Er=dt(),[Dr,Or]=wr(Cr),kr=Y.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=qe(s),[d,f]=ee({prop:r,onChange:i,defaultProp:a==null?``:a,caller:Cr});return(0,X.jsx)(Dr,{scope:n,baseId:w(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,X.jsx)(C.div,{dir:u,"data-orientation":o,...l,ref:t})})});kr.displayName=Cr;var Ar=`TabsList`,jr=Y.forwardRef((e,t)=>{let{__scopeTabs:n,loop:r=!0,...i}=e,a=Or(Ar,n),o=Er(n);return(0,X.jsx)(et,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,X.jsx)(C.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})});jr.displayName=Ar;var Mr=`TabsTrigger`,Nr=Y.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=Or(Mr,n),s=Er(n),c=Ir(o.baseId,r),l=Lr(o.baseId,r),u=r===o.value;return(0,X.jsx)(Ye,{asChild:!0,...s,focusable:!i,active:u,children:(0,X.jsx)(C.button,{type:`button`,role:`tab`,"aria-selected":u,"aria-controls":l,"data-state":u?`active`:`inactive`,"data-disabled":i?``:void 0,disabled:i,id:c,...a,ref:t,onMouseDown:S(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?o.onValueChange(r):e.preventDefault()}),onKeyDown:S(e.onKeyDown,e=>{[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:S(e.onFocus,()=>{let e=o.activationMode!==`manual`;!u&&!i&&e&&o.onValueChange(r)})})})});Nr.displayName=Mr;var Pr=`TabsContent`,Fr=Y.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=Or(Pr,n),c=Ir(s.baseId,r),l=Lr(s.baseId,r),u=r===s.value,d=Y.useRef(u);return Y.useEffect(()=>{let e=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,X.jsx)(E,{present:i||u,children:({present:n})=>(0,X.jsx)(C.div,{"data-state":u?`active`:`inactive`,"data-orientation":s.orientation,role:`tabpanel`,"aria-labelledby":c,hidden:!n,id:l,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:d.current?`0s`:void 0},children:n&&a})})});Fr.displayName=Pr;function Ir(e,t){return`${e}-trigger-${t}`}function Lr(e,t){return`${e}-content-${t}`}var Rr=kr,zr=jr,Br=Nr,Vr=Fr;function Hr({compact:e,onOpenAddServer:t}){var n,r;let[i,a]=(0,Y.useState)(!1),o=h(),{servers:s}=y(),l=(n=c({from:`/server/$serverId`}).serverId)==null?null:n,u=e=>{o({to:`/server/$serverId`,params:{serverId:e}}),a(!1)};if(e){var d;return(0,X.jsxs)(He,{open:i,onOpenChange:a,children:[(0,X.jsx)(Ie,{asChild:!0,children:(0,X.jsxs)(I,{variant:`ghost`,size:`sm`,role:`combobox`,"aria-expanded":i,"aria-label":`Select server`,className:`gap-1.5 px-2 h-8 font-semibold hover:bg-accent`,children:[(0,X.jsx)(xt,{className:`size-4 flex-shrink-0 text-muted-foreground`}),(0,X.jsx)(`span`,{className:`truncate`,children:((d=s.find(e=>e.id===l))==null?void 0:d.name)||`Select server`}),(0,X.jsx)(Ge,{className:`size-3 shrink-0 opacity-50`})]})}),(0,X.jsx)(Be,{className:`w-[240px] p-0 max-h-[80vh]`,children:(0,X.jsxs)(je,{children:[(0,X.jsx)(Me,{placeholder:`Search server...`}),(0,X.jsxs)(Ue,{className:`max-h-[50vh] overflow-y-auto`,children:[(0,X.jsx)(Re,{children:`No server found.`}),(0,X.jsx)(Ve,{heading:`Servers`,children:s.map(e=>(0,X.jsxs)(Le,{onSelect:()=>u(e.id),className:`justify-between`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(xt,{className:`size-4 text-muted-foreground`}),(0,X.jsx)(`span`,{children:e.name})]}),(0,X.jsx)(L,{className:R(`size-4`,l===e.id?`opacity-100`:`opacity-0`)})]},e.id))}),(0,X.jsx)(Ne,{}),(0,X.jsx)(Ve,{children:(0,X.jsxs)(Le,{onSelect:()=>{t(),a(!1)},children:[(0,X.jsx)(se,{className:`size-4`,"data-icon":`inline-start`}),`Add Server...`]})})]})]})})]})}return(0,X.jsxs)(He,{open:i,onOpenChange:a,children:[(0,X.jsx)(Ie,{asChild:!0,children:(0,X.jsxs)(I,{variant:`outline`,role:`combobox`,"aria-expanded":i,"aria-label":`Select server`,className:`w-full justify-between h-9`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 overflow-hidden`,children:[(0,X.jsx)(xt,{className:`size-4 flex-shrink-0 text-muted-foreground`}),(0,X.jsx)(`span`,{className:`truncate`,children:((r=s.find(e=>e.id===l))==null?void 0:r.name)||`Select server`})]}),(0,X.jsx)(Ge,{className:`ml-auto size-4 shrink-0 opacity-50`})]})}),(0,X.jsx)(Be,{className:`w-[240px] p-0 max-h-[80vh]`,children:(0,X.jsxs)(je,{children:[(0,X.jsx)(Me,{placeholder:`Search server...`}),(0,X.jsxs)(Ue,{className:`max-h-[50vh] overflow-y-auto`,children:[(0,X.jsx)(Re,{children:`No server found.`}),(0,X.jsx)(Ve,{heading:`Servers`,children:s.map(e=>(0,X.jsxs)(Le,{onSelect:()=>u(e.id),className:`justify-between`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(xt,{className:`size-4 text-muted-foreground`}),(0,X.jsx)(`span`,{children:e.name})]}),(0,X.jsx)(L,{className:R(`size-4`,l===e.id?`opacity-100`:`opacity-0`)})]},e.id))}),(0,X.jsx)(Ne,{}),(0,X.jsx)(Ve,{children:(0,X.jsxs)(Le,{onSelect:()=>{t(),a(!1)},children:[(0,X.jsx)(se,{className:`size-4`,"data-icon":`inline-start`}),`Add Server...`]})})]})]})})]})}function Ur(){let e=o(),t=c({from:`/server/$serverId`,strict:!1}),n=k(e=>e.connected),r=A(e=>e.setShowSettings),i=A(e=>e.setShowConfiguration),a=A(e=>e.setShowAddServer),s=wt().pathname.includes(`/overview`);return(0,X.jsxs)(X.Fragment,{children:[f()&&(0,X.jsx)(`div`,{className:`block md:hidden h-[30px] shrink-0 z-[60]`,style:{WebkitAppRegion:`drag`}}),(0,X.jsxs)(`header`,{className:`md:hidden flex items-center justify-between p-3 border-b border-border bg-background sticky top-0 z-[60] shrink-0`,style:{paddingTop:`calc(0.75rem + env(safe-area-inset-top, 0px))`},children:[(0,X.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[` `,(0,X.jsx)(Hr,{compact:!0,onOpenAddServer:()=>a(!0)}),` `,(0,X.jsx)(`button`,{className:`flex items-center justify-center size-5 rounded-md hover:bg-accent transition-colors`,title:n?`Connected`:`Disconnected`,children:(0,X.jsx)(`span`,{className:`size-2 rounded-full ${n?`bg-success`:`bg-destructive`}`})})]})}),(0,X.jsx)(me,{children:(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsxs)(_t,{children:[(0,X.jsxs)(te,{children:[(0,X.jsx)(M,{asChild:!0,children:(0,X.jsx)(mt,{asChild:!0,children:(0,X.jsx)(I,{variant:`ghost`,size:`icon-sm`,children:s?(0,X.jsx)(Nt,{className:`w-4 h-4`}):(0,X.jsx)(Pt,{className:`w-4 h-4`})})})}),(0,X.jsx)(ue,{children:`View`})]}),(0,X.jsxs)(ht,{align:`end`,className:`w-48 min-w-48`,children:[(0,X.jsxs)(lt,{onClick:()=>e.navigate({to:`/server/$serverId/workspace`,params:{serverId:t.serverId}}),children:[(0,X.jsx)(`span`,{className:`flex-1`,children:`Single workspace`}),!s&&(0,X.jsx)(L,{className:`size-4`})]}),(0,X.jsxs)(lt,{onClick:()=>e.navigate({to:`/server/$serverId/overview`,params:{serverId:t.serverId}}),children:[(0,X.jsx)(`span`,{className:`flex-1`,children:`Overview`}),s&&(0,X.jsx)(L,{className:`size-4`})]})]})]}),(0,X.jsxs)(_t,{children:[(0,X.jsxs)(te,{children:[(0,X.jsx)(M,{asChild:!0,children:(0,X.jsx)(mt,{asChild:!0,children:(0,X.jsx)(I,{variant:`ghost`,size:`icon-sm`,children:(0,X.jsx)(nt,{className:`w-4 h-4`})})})}),(0,X.jsx)(ue,{children:`More`})]}),(0,X.jsxs)(ht,{align:`end`,className:`w-48 min-w-48`,children:[(0,X.jsxs)(lt,{onClick:()=>i(!0),children:[(0,X.jsx)(Vt,{className:`mr-2 h-4 w-4`}),`Configuration`]}),(0,X.jsx)(ot,{}),(0,X.jsxs)(lt,{onClick:()=>r(!0),children:[(0,X.jsx)(ve,{className:`mr-2 h-4 w-4`}),`Settings`]})]})]})]})})]}),f()&&(0,X.jsx)(`div`,{className:`hidden md:block h-[30px] shrink-0`,style:{WebkitAppRegion:`drag`}}),(0,X.jsxs)(`header`,{className:`hidden md:flex items-center justify-between p-3 border-b border-border bg-sidebar h-11 shrink-0${f()&&d()?` pr-36`:``}`,children:[(0,X.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(Hr,{compact:!0,onOpenAddServer:()=>a(!0)}),(0,X.jsx)(`button`,{className:`flex items-center justify-center size-5 rounded-md hover:bg-accent transition-colors`,title:n?`Connected`:`Disconnected`,children:(0,X.jsx)(`span`,{className:`size-2 rounded-full ${n?`bg-success`:`bg-destructive`}`})})]})}),(0,X.jsx)(me,{children:(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,style:f()?{WebkitAppRegion:`no-drag`}:void 0,children:[(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(te,{children:[(0,X.jsx)(M,{asChild:!0,children:(0,X.jsx)(I,{variant:`ghost`,size:`icon-sm`,onClick:()=>e.navigate({to:`/server/$serverId/workspace`,params:{serverId:t.serverId}}),className:s?``:`bg-sidebar-accent text-sidebar-accent-foreground`,children:(0,X.jsx)(Pt,{className:`h-4 w-4`})})}),(0,X.jsx)(ue,{children:`Single workspace`})]}),(0,X.jsxs)(te,{children:[(0,X.jsx)(M,{asChild:!0,children:(0,X.jsx)(I,{variant:`ghost`,size:`icon-sm`,onClick:()=>e.navigate({to:`/server/$serverId/overview`,params:{serverId:t.serverId}}),className:s?`bg-sidebar-accent text-sidebar-accent-foreground`:``,children:(0,X.jsx)(Nt,{className:`h-4 w-4`})})}),(0,X.jsx)(ue,{children:`Overview`})]})]}),(0,X.jsxs)(_t,{children:[(0,X.jsxs)(te,{children:[(0,X.jsx)(M,{asChild:!0,children:(0,X.jsx)(mt,{asChild:!0,children:(0,X.jsx)(I,{variant:`ghost`,size:`icon-sm`,children:(0,X.jsx)(nt,{className:`w-4 h-4`})})})}),(0,X.jsx)(ue,{children:`More`})]}),(0,X.jsxs)(ht,{align:`end`,className:`w-48 min-w-48`,children:[(0,X.jsxs)(lt,{onClick:()=>i(!0),children:[(0,X.jsx)(Vt,{className:`mr-2 h-4 w-4`}),`Configuration`]}),(0,X.jsx)(ot,{}),(0,X.jsxs)(lt,{onClick:()=>r(!0),children:[(0,X.jsx)(ve,{className:`mr-2 h-4 w-4`}),`Settings`]})]})]})]})})]})]})}var Wr,Gr=400,Kr=typeof navigator<`u`&&((Wr=navigator.platform)==null?void 0:Wr.toUpperCase().includes(`MAC`))===!0;function qr(){for(let e of[`[data-slot="dialog-overlay"][data-state="open"]`,`[data-slot="dialog-content"][data-state="open"]`,`[role="dialog"][data-state="open"]`])if(document.querySelector(e))return!0;let e=document.querySelectorAll(`[role="dialog"]`);for(let t of e)if(t instanceof HTMLElement&&Jr(t))return!0;return!1}function Jr(e){if(!e.isConnected)return!1;let t=window.getComputedStyle(e);return t.display!==`none`&&t.visibility!==`hidden`&&parseFloat(t.opacity)>0&&e.getBoundingClientRect().width>0&&e.getBoundingClientRect().height>0}function Yr(){var e,t;let n=document.activeElement;return n?!!((e=n.hasAttribute)!=null&&e.call(n,`data-chat-input`)||(t=n.closest)!=null&&t.call(n,`[data-chat-input="true"]`)):!1}function Xr(e){let t=(0,Y.useRef)(e);(0,Y.useLayoutEffect)(()=>{t.current=e});let n=(0,Y.useRef)({lastEscTime:0,armed:!1});(0,Y.useEffect)(()=>{let e=e=>{if(e.isComposing||e.repeat||e.key===`Escape`&&qr())return;let{onCloseFocusedPanel:r,onFocusChatInput:i,onStopStreaming:a,onOpenSidebar:o,onOpenTerminal:s,onOpenFilesPanel:c,onNewWindow:l,onNewSession:u,onToggleViewMode:d,onToggleAutoFollow:p}=t.current;if(e.shiftKey&&e.key===`Escape`){e.preventDefault(),r();return}if(e.key===`Escape`&&!e.metaKey&&!e.ctrlKey){let t=Yr(),r=Date.now(),{lastEscTime:o,armed:s}=n.current,c=r-o;if(t&&s&&c<Gr){e.preventDefault(),n.current={lastEscTime:0,armed:!1},a();return}if(t){n.current={lastEscTime:r,armed:!0};return}e.preventDefault(),i();return}let m=e.target,h=m.tagName===`INPUT`||m.tagName===`TEXTAREA`||m.isContentEditable,g=e.metaKey||e.ctrlKey;if(!(h&&!g)){if(!f()||!Kr){if(g&&e.code===`Digit1`){e.preventDefault(),o();return}if(g&&e.code===`KeyT`){e.preventDefault(),s();return}}if(g&&e.code===`Digit2`){e.preventDefault(),c();return}if(g&&e.shiftKey&&e.code===`KeyN`){e.preventDefault(),l();return}if(g&&e.code===`KeyN`){e.preventDefault(),u();return}if(g&&e.code===`KeyO`){e.preventDefault(),d();return}if(g&&e.shiftKey&&e.code===`KeyF`){e.preventDefault(),p();return}}};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[])}function Zr({sidebarRef:e,terminalPanelRef:t,filesPanelRef:n,chatInputRef:r,activeWorkspace:i,primaryPreconfigs:a,handleInterruptSession:s,serverId:c,createSession:l,setSidebarOpen:d,onToggleAutoFollow:p}){let h=(0,Y.useCallback)(()=>{d(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{var t;(t=e.current)==null||t.focusSessionPanel()})})},[d,e]),g=(0,Y.useCallback)(()=>{ut.getState().setShowTerminalPanel(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{var e;(e=t.current)==null||e.focus()})})},[t]),_=(0,Y.useRef)(h);(0,Y.useLayoutEffect)(()=>{_.current=h});let v=(0,Y.useRef)(g);(0,Y.useLayoutEffect)(()=>{v.current=g});let y=(0,Y.useCallback)(()=>{ut.getState().setShowTerminalPanel(!1)},[]),b=(0,Y.useCallback)(()=>{requestAnimationFrame(()=>{var e;(e=n.current)==null||e.focus()})},[n]),x=(0,Y.useRef)(b);(0,Y.useLayoutEffect)(()=>{x.current=b});let S=(0,Y.useCallback)(()=>{var e;(e=r.current)==null||e.focus()},[r]),C=(0,Y.useCallback)(()=>{i&&a[0]&&l(a[0].id)},[i,a,l]),w=(0,Y.useCallback)(async()=>{if(f()){var e;(e=window.__JEAN2_ELECTRON__)==null||e.createWindow()}else if(u()){let{invoke:e}=await m(async()=>{let{invoke:e}=await import(`./core-CblztWA2.js`);return{invoke:e}},[],import.meta.url);e(`create_new_window`).catch(()=>{})}},[]),T=o();Xr({onOpenSidebar:()=>_.current(),onOpenTerminal:()=>v.current(),onOpenFilesPanel:()=>x.current(),onNewSession:C,onNewWindow:w,onToggleViewMode:(0,Y.useCallback)(()=>{T.state.location.pathname.includes(`/overview`)?T.navigate({to:`/server/$serverId/workspace`,params:{serverId:c}}):T.navigate({to:`/server/$serverId/overview`,params:{serverId:c}})},[T,c]),onCloseFocusedPanel:(0,Y.useCallback)(()=>{let e=document.activeElement;e!=null&&e.closest(`[data-terminal-panel]`)?y():e!=null&&e.closest(`[data-panel-id="files"]`)?ut.getState().setShowFilesPanel(!1):e!=null&&e.closest(`[data-sidebar="sidebar"]`)&&d(!1)},[y,d]),onFocusChatInput:S,onStopStreaming:(0,Y.useCallback)(()=>{s()},[s]),onToggleAutoFollow:()=>p==null?void 0:p()}),(0,Y.useLayoutEffect)(()=>{if(f()){var e;return(e=window.__JEAN2_ELECTRON__)==null?void 0:e.onAccelerator(e=>{e===`open-sidebar`?_.current():e===`open-terminal`&&v.current()})}if(!u())return;let t=!1,n=[];return(async()=>{let{listen:e}=await m(async()=>{let{listen:e}=await import(`./event-qUXFERHS.js`);return{listen:e}},__vite__mapDeps([0,1]),import.meta.url);try{let r=await e(`jean2://accelerator/open-sidebar`,()=>{_.current()});if(t){r();return}n.push(r)}catch(e){console.error(`Failed to register open-sidebar accelerator listener:`,e)}try{let r=await e(`jean2://accelerator/open-terminal`,()=>{v.current()});if(t){r();return}n.push(r)}catch(e){console.error(`Failed to register open-terminal accelerator listener:`,e)}})(),()=>{t=!0,n.forEach(e=>e())}},[])}function Qr(e){let{setOpen:t}=rt(),n=z(e=>e.activeWorkspace),r=z(e=>e.preconfigs).filter(e=>e.mode!==`subagent`);return Zr({...e,activeWorkspace:n,primaryPreconfigs:r,setSidebarOpen:t}),null}var $r={".ts":{icon:q,color:`text-blue-500`},".tsx":{icon:q,color:`text-blue-500`},".js":{icon:q,color:`text-yellow-500`},".jsx":{icon:q,color:`text-yellow-500`},".json":{icon:q,color:`text-yellow-600`},".md":{icon:q,color:`text-gray-500`},".css":{icon:q,color:`text-purple-500`},".html":{icon:q,color:`text-orange-500`}};function ei({entry:e,workspaceId:t,parentPath:n,depth:r,onFileSelect:i,showHidden:a=!0,sdkClient:o}){let[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)([]),[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(!1),h=n?`${n}/${e.path}`:e.path,g=e.type===`directory`,_=async()=>{if(!(p||d||!o)){f(!0);try{u((await o.http.files.browse(t,h,{showHidden:a})).files||[]),m(!0)}catch(e){console.error(`Failed to load children:`,e)}finally{f(!1)}}},v=e=>{var t;(t=document.activeElement)==null||t.focus(),c(e),e&&g&&_()},y=t=>{t.currentTarget.focus(),!g&&i&&i({...e,path:h})},b=e=>{e.key===`Enter`&&(e.preventDefault(),y(e))},x=e.extension?$r[e.extension]:null,S=g?s?$e:F:(x==null?void 0:x.icon)||q,C=g?`text-amber-500`:(x==null?void 0:x.color)||`text-muted-foreground`;return g?(0,X.jsxs)(le,{open:s,onOpenChange:v,children:[(0,X.jsx)(ie,{asChild:!0,children:(0,X.jsxs)(`button`,{"data-file-node":!0,"data-file-type":`directory`,"data-file-is-open":s||void 0,className:R(`flex items-center gap-2 w-full min-w-0 overflow-hidden rounded-md p-2 text-left text-sm`,`hover:bg-sidebar-accent hover:text-sidebar-accent-foreground`,`focus:ring-1 focus:ring-inset ring-sidebar-ring outline-hidden`,`[&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate`),style:{paddingLeft:`${r*12+8}px`},children:[d?(0,X.jsx)(U,{className:`w-3 h-3 animate-spin shrink-0`}):(0,X.jsx)(ce,{className:R(`w-3 h-3 shrink-0 transition-transform`,s&&`rotate-90`)}),(0,X.jsx)(S,{className:C}),(0,X.jsx)(`div`,{className:`flex-1 min-w-0 truncate`,children:e.name})]})}),(0,X.jsx)(pe,{children:l.map(e=>(0,X.jsx)(ei,{entry:e,workspaceId:t,parentPath:h,depth:r+1,onFileSelect:i,showHidden:a,sdkClient:o},`${h}/${e.path}`))})]}):(0,X.jsxs)(`button`,{"data-file-node":!0,"data-file-type":`file`,onClick:y,onKeyDown:b,className:R(`flex items-center gap-2 w-full min-w-0 overflow-hidden rounded-md p-2 text-left text-sm`,`hover:bg-sidebar-accent hover:text-sidebar-accent-foreground`,`focus:ring-1 focus:ring-inset ring-sidebar-ring outline-hidden`,`[&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate`),style:{paddingLeft:`${r*12+8}px`},children:[(0,X.jsx)(S,{className:C}),(0,X.jsx)(`div`,{className:`flex-1 min-w-0 truncate`,children:e.name})]})}var ti=(0,Y.forwardRef)(({workspaceId:e,sdkClient:t,onFileSelect:n,showHidden:r=!0,width:i},a)=>{let[o,s]=(0,Y.useState)([]),[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(!0),[f,p]=(0,Y.useState)(null),m=(0,Y.useRef)(null),h=(0,Y.useCallback)(async()=>{if(t){d(!0),p(null);try{let n=await t.http.files.browse(e,void 0,{showHidden:r});s(n.files),l(n.currentPath||``)}catch(e){p(e instanceof Error?e.message:`Failed to load files`)}finally{d(!1)}}},[e,r,t]);(0,Y.useEffect)(()=>{h()},[h]),(0,Y.useImperativeHandle)(a,()=>({refresh:h,focus:()=>{let e=m.current;if(!e)return;let t=e.querySelector(`[data-file-node]`);t?t.focus():e.focus()}}),[h]);let g=(0,Y.useCallback)(e=>{let t=m.current;if(!t)return;let n=Array.from(t.querySelectorAll(`[data-file-node]`));if(n.length===0)return;let r=n.indexOf(document.activeElement);switch(e.key){case`ArrowDown`:var i;e.preventDefault(),(i=n[r<n.length-1?r+1:0])==null||i.focus();break;case`ArrowUp`:var a;e.preventDefault(),(a=n[r>0?r-1:n.length-1])==null||a.focus();break;case`ArrowRight`:{e.preventDefault();let t=document.activeElement;if(!t)break;if(t.getAttribute(`data-file-type`)===`directory`)if(t.getAttribute(`data-file-is-open`)!==`true`)t.click();else{var o;let e=r<n.length-1?r+1:-1;e>=0&&((o=n[e])==null||o.focus())}else{var s;let e=r<n.length-1?r+1:-1;e>=0&&((s=n[e])==null||s.focus())}break}case`ArrowLeft`:{e.preventDefault();let t=document.activeElement;if(!t)break;if(t.getAttribute(`data-file-type`)===`directory`)if(t.getAttribute(`data-file-is-open`)===`true`)t.click();else{var c;let e=r>0?r-1:-1;e>=0&&((c=n[e])==null||c.focus())}else{var l;let e=r>0?r-1:-1;e>=0&&((l=n[e])==null||l.focus())}break}case`Enter`:document.activeElement instanceof HTMLButtonElement&&document.activeElement.click();break;case`Escape`:var u;e.preventDefault(),(u=document.activeElement)==null||u.blur();break}},[]);return u?(0,X.jsxs)(`div`,{className:`flex items-center justify-center h-32 text-muted-foreground`,children:[(0,X.jsx)(U,{className:`w-4 h-4 animate-spin mr-2`}),`Loading files...`]}):f?(0,X.jsxs)(`div`,{className:`p-4 text-sm text-destructive`,children:[f,(0,X.jsx)(I,{variant:`ghost`,size:`sm`,onClick:h,className:`ml-2`,children:(0,X.jsx)(K,{className:`w-3 h-3`})})]}):o.length===0?(0,X.jsxs)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:[`Empty workspace`,(0,X.jsx)(I,{variant:`ghost`,size:`sm`,onClick:h,className:`ml-2`,children:(0,X.jsx)(K,{className:`w-3 h-3`})})]}):(0,X.jsx)(`div`,{ref:m,tabIndex:-1,onKeyDown:g,className:`flex-1 min-h-0 min-w-0 w-full outline-none`,children:(0,X.jsx)(Ct,{className:`h-full`,children:(0,X.jsx)(`div`,{className:`px-2 pb-2 w-full min-w-0`,style:i?{width:`${i-8}px`}:void 0,children:(0,X.jsx)(`div`,{className:`space-y-0.5 min-w-0`,children:o.map(i=>(0,X.jsx)(ei,{entry:i,workspaceId:e,parentPath:c,depth:0,onFileSelect:n,showHidden:r,sdkClient:t},i.path))})})})})});ti.displayName=`FileTree`;var ni=_e.oneDark;function ri({content:e,path:t,language:n,showLineNumbers:r=!0}){return(0,X.jsx)(`div`,{className:R(`h-full overflow-auto bg-[#282c34] chat-transcript-scrollbar`),style:{WebkitOverflowScrolling:`touch`},children:(0,X.jsx)(Ce,{theme:ni,code:e,language:n||`plaintext`,children:({style:e,tokens:t,getLineProps:n,getTokenProps:i})=>(0,X.jsx)(`pre`,{className:`text-sm p-4 min-h-full font-mono`,style:e,children:t.map((e,t)=>(0,X.jsxs)(`div`,{...n({line:e}),className:`table-row`,children:[r&&(0,X.jsx)(`span`,{className:`table-cell pr-4 text-right select-none opacity-50 text-xs w-12`,children:t+1}),(0,X.jsx)(`span`,{className:`table-cell`,children:e.map((e,t)=>(0,X.jsx)(`span`,{...i({token:e})},t))})]},t))})})})}function ii({icon:e,title:t,reason:n,name:r}){return(0,X.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full text-center p-8`,children:[(0,X.jsx)(e,{className:`size-10 text-muted-foreground mb-4`}),(0,X.jsx)(`p`,{className:`text-sm font-medium mb-1`,children:t}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground mb-2`,children:n}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r})]})}function ai({preview:e}){return e.kind===`markdown`?(0,X.jsx)(`div`,{className:`h-full overflow-auto p-6 chat-transcript-scrollbar`,style:{WebkitOverflowScrolling:`touch`},children:(0,X.jsx)(De,{children:e.content})}):e.kind===`code`?(0,X.jsx)(ri,{content:e.content,path:e.path,language:e.language,showLineNumbers:!0}):e.kind===`text`?(0,X.jsx)(ri,{content:e.content,path:e.path,language:e.language,showLineNumbers:!1}):e.kind===`binary`?(0,X.jsx)(ii,{icon:kt,title:`Binary file`,reason:e.reason,name:e.name}):e.kind===`unsupported`?(0,X.jsx)(ii,{icon:Ot,title:`Unsupported file`,reason:e.reason,name:e.name}):e.kind===`too_large`?(0,X.jsx)(ii,{icon:Dt,title:`File too large`,reason:e.reason,name:e.name}):null}var oi=(0,Y.forwardRef)(({sdkClient:e},t)=>{let n=re(),r=(0,Y.useRef)(null),i=ut(e=>e.filesPanelWidth),a=ut(e=>e.showFilesPanel),o=ut(e=>e.setShowFilesPanel),s=z(e=>e.activeWorkspace),c=s==null?void 0:s.id,l=(0,Y.useCallback)(()=>{o(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{var e;(e=r.current)==null||e.focus()})})},[o]);(0,Y.useImperativeHandle)(t,()=>({focus:l}),[l]);let u=A(e=>e.openFilePreview),d=(0,Y.useCallback)(e=>{e.type===`file`&&c&&u({workspaceId:c,path:e.path,name:e.name})},[c,u]);return c?n?(0,X.jsx)(Je,{open:a,onOpenChange:e=>!e&&o(!1),children:(0,X.jsxs)(bt,{side:`right`,className:`w-72 p-0 bg-sidebar [&>button]:hidden`,children:[(0,X.jsx)(it,{className:`sr-only`,children:(0,X.jsx)(Xe,{children:`Files`})}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between p-3 border-b border-border`,children:[(0,X.jsx)(`span`,{className:`font-semibold text-sm text-sidebar-foreground`,children:`Files`}),(0,X.jsx)(I,{variant:`ghost`,size:`icon-sm`,onClick:()=>o(!1),children:(0,X.jsx)(B,{className:`size-4`})})]}),(0,X.jsx)(`div`,{className:`flex flex-1 flex-col min-h-0 overflow-hidden`,children:(0,X.jsx)(ti,{ref:r,workspaceId:c,sdkClient:e,showHidden:!0,onFileSelect:d},c)})]})}):(0,X.jsx)(st,{panelId:`files`,defaultOpen:!0,className:`w-0 shrink-0`,style:{"--sidebar-width":`${i}px`},children:(0,X.jsxs)(ft,{side:`right`,isOpen:a,children:[(0,X.jsx)(gt,{side:`right`,panelId:`files`}),(0,X.jsx)(pt,{children:(0,X.jsx)(ct,{children:(0,X.jsx)(yt,{children:(0,X.jsxs)(at,{className:`w-full justify-between`,onClick:()=>{var e;return(e=r.current)==null?void 0:e.refresh()},children:[(0,X.jsx)(`span`,{className:`text-sm font-semibold`,children:`Files`}),(0,X.jsx)(K,{className:`size-4`})]})})})}),(0,X.jsx)(vt,{className:`overflow-hidden`,children:(0,X.jsx)(ti,{ref:r,workspaceId:c,sdkClient:e,showHidden:!0,width:i,onFileSelect:d},c)})]})}):null});oi.displayName=`FilesPanel`;function si({className:e,orientation:t=`horizontal`,...n}){return(0,X.jsx)(Rr,{"data-slot":`tabs`,"data-orientation":t,className:R(`group/tabs flex gap-2 data-horizontal:flex-col`,e),...n})}var ci=T(`group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function li({className:e,variant:t=`default`,...n}){return(0,X.jsx)(zr,{"data-slot":`tabs-list`,"data-variant":t,className:R(ci({variant:t}),e),...n})}function ui({className:e,...t}){return(0,X.jsx)(Br,{"data-slot":`tabs-trigger`,className:R(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent`,`data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100`,e),...t})}function di({className:e,...t}){return(0,X.jsx)(Vr,{"data-slot":`tabs-content`,className:R(`flex-1 text-sm outline-none`,e),...t})}function $({className:e,...t}){return(0,X.jsx)(Gn,{"data-slot":`label`,className:R(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}function fi({token:e,onLogout:t}){return(0,X.jsxs)(`div`,{className:`flex items-center gap-3 p-2 rounded-md bg-muted`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:`Token:`}),(0,X.jsx)(`code`,{className:`font-mono text-foreground bg-background px-1.5 py-0.5 rounded text-[10px]`,children:v(e)})]}),(0,X.jsx)(I,{variant:`destructive`,size:`sm`,onClick:t,title:`Disconnect and clear token`,children:`Logout`})]})}function pi({className:e,value:t,...n}){return(0,X.jsx)(cr,{"data-slot":`progress`,className:R(`relative flex h-1 w-full items-center overflow-x-hidden rounded-full bg-muted`,e),...n,children:(0,X.jsx)(lr,{"data-slot":`progress-indicator`,className:`size-full flex-1 bg-primary transition-all`,style:{transform:`translateX(-${100-(t||0)}%)`}})})}var mi=`0.8.3`;function hi(e){let t=e.trim().match(/^v?(\d+)\.(\d+)\.(\d+)$/);return t?[parseInt(t[1],10),parseInt(t[2],10),parseInt(t[3],10)]:null}function gi(e,t){let n=hi(e),r=hi(t);if(!n&&!r)return 0;if(!n)return-1;if(!r)return 1;for(let e=0;e<3;e++)if(n[e]!==r[e])return n[e]-r[e];return 0}function _i(e,t){return t?gi(e,t)>=0?`up-to-date`:`update-available`:`unknown`}var vi=`rabbyte-tech/jean2`,yi=300*1e3,bi=1e4,xi=new Map;function Si(e){let t=xi.get(e);return t?Date.now()-t.timestamp>yi?(xi.delete(e),null):t.value:null}function Ci(e,t){xi.set(e,{value:t,timestamp:Date.now()})}function wi(){xi.clear()}async function Ti(e,t){let n=new AbortController,r=setTimeout(()=>n.abort(),t);try{return await fetch(e,{signal:n.signal})}finally{clearTimeout(r)}}async function Ei(){let e=Si(`latest-server`);if(e)return e;try{let e=await Ti(`https://raw.githubusercontent.com/${vi}/refs/heads/main/packages/server/VERSION`,bi);if(!e.ok)return null;let t=(await e.text()).trim();return/^\d+\.\d+\.\d+$/.test(t)?(Ci(`latest-server`,t),t):null}catch{return null}}async function Di(){let e=Si(`latest-client`);if(e)return e;try{let e=await Ti(`https://api.github.com/repos/${vi}/releases?per_page=20`,bi);if(!e.ok)return null;let t=(await e.json()).find(e=>e.tag_name.startsWith(`client/`)&&!e.prerelease);if(!t)return null;let n=t.tag_name.replace(/^client\/v?/,``);return/^\d+\.\d+\.\d+$/.test(n)?(Ci(`latest-client`,n),n):null}catch{return null}}var Oi=!!window.__JEAN2_ELECTRON__;function ki(e){if(!e)return``;let t=Math.floor((Date.now()-e)/1e3);if(t<10)return`just now`;if(t<60)return`${t}s ago`;let n=Math.floor(t/60);return n<60?`${n}m ago`:`${Math.floor(n/60)}h ago`}function Ai({status:e}){return e===`up-to-date`?(0,X.jsxs)(`span`,{className:`text-xs text-green-500 flex items-center gap-1`,children:[(0,X.jsx)(`span`,{className:`inline-block size-1.5 rounded-full bg-green-500`}),`Up to date`]}):e===`update-available`?(0,X.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded-full bg-amber-500/10 text-amber-600 dark:text-amber-400`,children:`Update available`}):(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Unknown`})}function ji({state:e}){switch(e.status){case`idle`:return(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[`v`,mi]}),(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Unknown`})]});case`checking`:return(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[`v`,mi]}),(0,X.jsx)(K,{className:`size-3.5 animate-spin text-muted-foreground`})]});case`available`:return(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[`v`,mi]}),(0,X.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded-full bg-amber-500/10 text-amber-600 dark:text-amber-400`,children:`Update available`})]});case`not-available`:return(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[`v`,mi]}),(0,X.jsxs)(`span`,{className:`text-xs text-green-500 flex items-center gap-1`,children:[(0,X.jsx)(`span`,{className:`inline-block size-1.5 rounded-full bg-green-500`}),`Up to date`]})]});case`downloading`:return(0,X.jsxs)(`div`,{className:`flex flex-col gap-1 items-end min-w-40`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[`v`,mi]}),(0,X.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Downloading... `,Math.round(e.percent),`%`]})]}),(0,X.jsx)(pi,{value:e.percent,className:`w-full h-1`})]});case`downloaded`:return(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[`v`,mi]}),(0,X.jsxs)(`span`,{className:`text-xs text-green-500 flex items-center gap-1`,children:[(0,X.jsx)(`span`,{className:`inline-block size-1.5 rounded-full bg-green-500`}),`Update ready — restart to install`]})]});case`error`:return(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[`v`,mi]}),(0,X.jsx)(`span`,{className:`text-xs text-red-500`,children:e.message})]})}}function Mi({sdkClient:e,enabled:t}){let n=(0,Y.useRef)(0),[r,i]=(0,Y.useState)({serverVersion:null,latestServer:null,latestClient:null,loading:!0,lastChecked:null,fetchError:null}),[a,o]=(0,Y.useState)({status:`idle`}),s=(0,Y.useCallback)(async(t=!1)=>{t&&wi();let r=++n.current;i(e=>({...e,loading:!0,fetchError:null}));try{let t=await Promise.allSettled([e?e.httpClient.get(`/info`).then(e=>e.version).catch(()=>null):Promise.resolve(null),Ei(),Oi?Promise.resolve(null):Di()]);if(n.current!==r)return;i({serverVersion:t[0].status===`fulfilled`?t[0].value:null,latestServer:t[1].status===`fulfilled`?t[1].value:null,latestClient:t[2].status===`fulfilled`?t[2].value:null,loading:!1,lastChecked:Date.now(),fetchError:null})}catch{if(n.current!==r)return;i(e=>({...e,loading:!1,fetchError:`Unable to check for updates`}))}},[e]);(0,Y.useEffect)(()=>{t&&s()},[s,t]),(0,Y.useEffect)(()=>{if(!(!Oi||!window.__JEAN2_ELECTRON__))return window.__JEAN2_ELECTRON__.onUpdaterEvent(e=>{let{type:t,data:n}=e;switch(t){case`checking`:o({status:`checking`});break;case`available`:o({status:`available`,version:n.version});break;case`not-available`:o({status:`not-available`,version:n.version});break;case`download-progress`:{let e=n;o({status:`downloading`,percent:e.percent,transferred:e.transferred,total:e.total});break}case`downloaded`:o({status:`downloaded`,version:n.version});break;case`error`:o({status:`error`,message:n.message});break}})},[]);let c=_i(mi,r.latestClient),l=e&&r.serverVersion?_i(r.serverVersion,r.latestServer):`unknown`,u=()=>{Oi&&window.__JEAN2_ELECTRON__?(o({status:`checking`}),window.__JEAN2_ELECTRON__.checkForUpdates()):s(!0)},d=a.status===`checking`||a.status===`downloading`;return(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)($,{className:`text-sm font-medium`,children:`Versions`}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Check for updates to client and server`})]}),(0,X.jsx)(H,{}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:`Client`}),Oi?(0,X.jsx)(ji,{state:a}):r.loading?(0,X.jsx)(oe,{className:`h-5 w-32`}):(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[`v`,mi]}),(0,X.jsx)(Ai,{status:c})]})]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:`Server`}),r.loading?(0,X.jsx)(oe,{className:`h-5 w-32`}):r.serverVersion?(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[`v`,r.serverVersion]}),(0,X.jsx)(Ai,{status:l})]}):(0,X.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Not connected`})]}),!Oi&&(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:`Latest`}),r.loading?(0,X.jsx)(oe,{className:`h-5 w-48`}):(0,X.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[r.latestServer?`v${r.latestServer} (server)`:``,r.latestServer&&r.latestClient&&` · `,r.latestClient?`v${r.latestClient} (client)`:``,!r.latestServer&&!r.latestClient&&`Unknown`]})]})]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[r.lastChecked&&!r.loading&&!d&&(0,X.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Last checked: `,ki(r.lastChecked)]}),(0,X.jsxs)(I,{variant:`outline`,size:`sm`,onClick:u,disabled:r.loading||d,className:`ml-auto`,children:[(0,X.jsx)(K,{className:`size-3.5 ${r.loading||d?`animate-spin`:``}`}),`Check for Updates`]})]})]})}var Ni={neutral:{label:`Neutral`,colors:[`bg-zinc-400`,`bg-zinc-600`,`bg-zinc-800`]},ocean:{label:`Ocean`,colors:[`bg-sky-300`,`bg-sky-500`,`bg-slate-700`]},forest:{label:`Forest`,colors:[`bg-emerald-300`,`bg-emerald-500`,`bg-green-800`]},sunset:{label:`Sunset`,colors:[`bg-orange-300`,`bg-amber-500`,`bg-orange-800`]},amethyst:{label:`Amethyst`,colors:[`bg-violet-300`,`bg-violet-500`,`bg-purple-800`]}};function Pi({scheme:e,currentScheme:t,onClick:n}){let r=e===t,i=Ni[e];return(0,X.jsxs)(`button`,{type:`button`,onClick:()=>n(e),className:`
|
|
8
|
+
flex flex-col items-center gap-1.5 p-2 rounded-lg border transition-all
|
|
9
|
+
${r?`border-primary bg-primary/5`:`border-border bg-transparent hover:bg-muted/50`}
|
|
10
|
+
`,title:i.label,children:[(0,X.jsx)(`div`,{className:`flex gap-0.5`,children:i.colors.map((e,t)=>(0,X.jsx)(`div`,{className:`w-4 h-4 rounded-full ${e}`},t))}),(0,X.jsx)(`span`,{className:`text-[10px] text-muted-foreground capitalize`,children:e})]})}function Fi({open:e,onOpenChange:t,apiToken:n,onLogout:r,sdkClient:a}){var o;let{mode:s,scheme:c,setMode:l,setScheme:u}=i(),{chatFinishSoundEnabled:d,setChatFinishSoundEnabled:f,permissionSoundEnabled:p,setPermissionSoundEnabled:m}=A(Z(e=>({chatFinishSoundEnabled:e.chatFinishSoundEnabled,setChatFinishSoundEnabled:e.setChatFinishSoundEnabled,permissionSoundEnabled:e.permissionSoundEnabled,setPermissionSoundEnabled:e.setPermissionSoundEnabled}))),h=((o=navigator.userAgentData)==null?void 0:o.platform)===`macOS`||/mac|iphone|ipad|ipod/i.test(navigator.userAgent)?`⌘`:`Ctrl`;return(0,X.jsx)(ze,{open:e,onOpenChange:t,children:(0,X.jsxs)(Fe,{className:`sm:max-w-[700px] max-h-[80vh]`,children:[(0,X.jsxs)(We,{children:[(0,X.jsx)(Ke,{children:`Settings`}),(0,X.jsx)(J,{children:`Manage your preferences`})]}),(0,X.jsxs)(si,{defaultValue:`account`,className:`mt-4`,children:[(0,X.jsxs)(li,{className:`grid w-full grid-cols-3`,children:[(0,X.jsxs)(ui,{value:`account`,children:[(0,X.jsx)(Oe,{className:`size-4 sm:size-3`,"data-icon":`inline-start`}),(0,X.jsx)(`span`,{className:`hidden sm:inline`,children:`Account`})]}),(0,X.jsxs)(ui,{value:`appearance`,children:[(0,X.jsx)(Rt,{className:`size-4 sm:size-3`,"data-icon":`inline-start`}),(0,X.jsx)(`span`,{className:`hidden sm:inline`,children:`Appearance`})]}),(0,X.jsxs)(ui,{value:`keybinds`,children:[(0,X.jsx)(jt,{className:`size-4 sm:size-3`,"data-icon":`inline-start`}),(0,X.jsx)(`span`,{className:`hidden sm:inline`,children:`Keybinds`})]})]}),(0,X.jsx)(di,{value:`account`,className:`mt-4`,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)($,{className:`text-sm font-medium`,children:`Session`}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground mb-3`,children:`Manage your current session`}),n?(0,X.jsx)(fi,{token:n,onLogout:r}):(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No active session`})]}),(0,X.jsx)(H,{}),(0,X.jsx)(Mi,{sdkClient:a,enabled:e})]})}),(0,X.jsx)(di,{value:`appearance`,className:`mt-4`,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)($,{className:`text-sm font-medium`,children:`Mode`}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground mb-3`,children:`Choose light, dark, or system theme`}),(0,X.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,X.jsxs)(I,{variant:s===`light`?`default`:`outline`,className:`justify-start`,onClick:()=>l(`light`),children:[(0,X.jsx)(Ht,{className:`size-4`,"data-icon":`inline-start`}),`Light`]}),(0,X.jsxs)(I,{variant:s===`dark`?`default`:`outline`,className:`justify-start`,onClick:()=>l(`dark`),children:[(0,X.jsx)(Lt,{className:`size-4`,"data-icon":`inline-start`}),`Dark`]}),(0,X.jsxs)(I,{variant:s===`system`?`default`:`outline`,className:`justify-start`,onClick:()=>l(`system`),children:[(0,X.jsx)(It,{className:`size-4`,"data-icon":`inline-start`}),`System`]})]})]}),(0,X.jsx)(H,{}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)($,{className:`text-sm font-medium mb-3 block`,children:`Notification Sounds`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(Wt,{className:`size-4 text-muted-foreground`}),(0,X.jsx)(`span`,{className:`text-sm`,children:`Chat completion`})]}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>f(!d),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${d?`bg-primary`:`bg-muted`}`,children:(0,X.jsx)(`span`,{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${d?`translate-x-6`:`translate-x-1`}`})})]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(Gt,{className:`size-4 text-muted-foreground`}),(0,X.jsx)(`span`,{className:`text-sm`,children:`Permission requests`})]}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>m(!p),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${p?`bg-primary`:`bg-muted`}`,children:(0,X.jsx)(`span`,{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${p?`translate-x-6`:`translate-x-1`}`})})]})]})]}),(0,X.jsx)(H,{}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)($,{className:`text-sm font-medium`,children:`Color Scheme`}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground mb-3`,children:`Choose your preferred color palette`}),(0,X.jsxs)(`div`,{className:`grid grid-cols-5 gap-2`,children:[(0,X.jsx)(Pi,{scheme:`neutral`,currentScheme:c,onClick:u}),(0,X.jsx)(Pi,{scheme:`ocean`,currentScheme:c,onClick:u}),(0,X.jsx)(Pi,{scheme:`forest`,currentScheme:c,onClick:u}),(0,X.jsx)(Pi,{scheme:`sunset`,currentScheme:c,onClick:u}),(0,X.jsx)(Pi,{scheme:`amethyst`,currentScheme:c,onClick:u})]})]})]})}),(0,X.jsx)(di,{value:`keybinds`,className:`mt-4`,children:(0,X.jsx)(`div`,{className:`flex flex-col gap-2`,children:[{keys:[h,`1`],description:`Open session list`},{keys:[h,`2`],description:`Open files panel`},{keys:[h,`T`],description:`Open terminal`},{keys:[h,`O`],description:`Toggle overview mode`},{keys:[h,`N`],description:`New session`},{keys:[h,`Shift`,`N`],description:`New window`},{keys:[h,`Shift`,`F`],description:`Toggle follow/free mode`},{keys:[`Shift`,`Esc`],description:`Close focused panel`},{keys:[`Shift`,`Enter`],description:`New line in input`},{keys:[`Enter`],description:`Send message`},{keys:[`↑`,`↓`,`←`,`→`],description:`Navigate sessions`},{keys:[`Esc`],description:`Focus chat input`},{keys:[`Esc`,`Esc`],description:`Stop streaming (chat input focused)`}].map((e,t)=>(0,X.jsxs)(`div`,{className:`flex items-center justify-between py-1`,children:[(0,X.jsx)(`div`,{className:`flex items-center gap-1`,children:e.keys.map((t,n)=>(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`kbd`,{className:`font-mono bg-muted rounded px-2 py-1 text-xs`,children:t}),n<e.keys.length-1&&(0,X.jsx)(`span`,{className:`mx-1 text-muted-foreground`,children:`+`})]},n))}),(0,X.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:e.description})]},t))})})]})]})})}function Ii({status:e}){switch(e.status){case`connected`:return(0,X.jsxs)(V,{variant:`default`,className:`bg-green-600`,children:[(0,X.jsx)(de,{className:`size-3 mr-1`}),`Connected`]});case`disabled`:return(0,X.jsxs)(V,{variant:`secondary`,children:[(0,X.jsx)(ne,{className:`size-3 mr-1`}),`Disabled`]});case`failed`:return(0,X.jsxs)(V,{variant:`destructive`,children:[(0,X.jsx)(xe,{className:`size-3 mr-1`}),`Failed`]});case`needs_auth`:return(0,X.jsxs)(V,{variant:`outline`,className:`border-yellow-500 text-yellow-600`,children:[(0,X.jsx)(xe,{className:`size-3 mr-1`}),`Needs Auth`]});case`needs_client_registration`:return(0,X.jsxs)(V,{variant:`outline`,className:`border-orange-500 text-orange-600`,children:[(0,X.jsx)(xe,{className:`size-3 mr-1`}),`Needs Registration`]});default:return(0,X.jsx)(V,{variant:`secondary`,children:`Unknown`})}}function Li({open:e,onOpenChange:t,workspaceId:n,workspacePath:r,sdkClient:i}){let[a,o]=(0,Y.useState)({}),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(null),p=(0,Y.useCallback)(async()=>{if(!(!n||!i)){c(!0),f(null);try{o((await i.http.mcp.getStatus(n)).status||{})}catch(e){f(e instanceof Error?e.message:`Unknown error`)}finally{c(!1)}}},[n,i]);(0,Y.useEffect)(()=>{e&&n&&p()},[e,n,p]);let m=async e=>{if(!(!n||!i)){u(e);try{await i.http.mcp.connect(n,e),await p()}catch(e){f(e instanceof Error?e.message:`Unknown error`)}finally{u(null)}}},h=async e=>{if(!(!n||!i)){u(e);try{await i.http.mcp.disconnect(n,e),await p()}catch(e){f(e instanceof Error?e.message:`Unknown error`)}finally{u(null)}}},g=async e=>{if(!(!n||!i)){u(e);try{let t=await i.http.mcp.startAuth(n,e);t.authorizationUrl&&window.open(t.authorizationUrl,`_blank`),await p()}catch(e){f(e instanceof Error?e.message:`Unknown error`)}finally{u(null)}}},_=Object.entries(a);return(0,X.jsx)(ze,{open:e,onOpenChange:t,children:(0,X.jsxs)(Fe,{className:`sm:max-w-[600px] max-h-[80vh]`,children:[(0,X.jsxs)(We,{children:[(0,X.jsxs)(Ke,{className:`flex items-center gap-2`,children:[(0,X.jsx)(xt,{className:`size-5`}),`MCP Servers`]}),(0,X.jsx)(J,{children:`Manage Model Context Protocol servers for this workspace`})]}),(0,X.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[d&&(0,X.jsxs)(ke,{variant:`destructive`,children:[(0,X.jsx)(xe,{className:`size-4`}),(0,X.jsx)(Te,{children:d})]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Configure servers in `,(0,X.jsx)(`code`,{className:`text-xs bg-muted px-1 rounded`,children:`.jean2/mcp.json`})]}),(0,X.jsx)(I,{variant:`outline`,size:`sm`,onClick:p,disabled:s,children:(0,X.jsx)(K,{className:`size-4 ${s?`animate-spin`:``}`})})]}),(0,X.jsx)(Ct,{className:`h-[400px]`,children:s&&_.length===0?(0,X.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,X.jsx)(U,{className:`size-6 animate-spin text-muted-foreground`})}):_.length===0?(0,X.jsxs)(`div`,{className:`text-center py-8 text-muted-foreground`,children:[(0,X.jsx)(xt,{className:`size-12 mx-auto mb-3 opacity-50`}),(0,X.jsx)(`p`,{className:`font-medium`,children:`No MCP servers configured`}),(0,X.jsxs)(`p`,{className:`text-sm mt-1`,children:[`Create `,(0,X.jsx)(`code`,{className:`text-xs bg-muted px-1 rounded`,children:`.jean2/mcp.json`}),` in your workspace to add servers.`]})]}):(0,X.jsx)(`div`,{className:`space-y-3`,children:_.map(([e,{config:t,status:n}])=>{var r;return(0,X.jsxs)(`div`,{className:`border rounded-lg p-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,X.jsx)(xt,{className:`size-5 text-muted-foreground mt-0.5`}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`font-medium`,children:e}),(0,X.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:(t==null?void 0:t.type)===`local`?(0,X.jsxs)(`span`,{children:[`Local - `,((r=t.command)==null?void 0:r[0])||`command`]}):(t==null?void 0:t.type)===`remote`?(0,X.jsxs)(`span`,{className:`flex items-center gap-1`,children:[`Remote - `,t.url]}):`Unknown type`}),n.status===`failed`&&`error`in n&&(0,X.jsx)(ke,{variant:`destructive`,className:`mt-2 py-2`,children:(0,X.jsx)(Te,{className:`text-xs`,children:n.error})}),n.status===`needs_client_registration`&&`error`in n&&(0,X.jsx)(ke,{className:`mt-2 py-2 border-orange-500`,children:(0,X.jsx)(Te,{className:`text-xs`,children:n.error})})]})]}),(0,X.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,X.jsx)(Ii,{status:n})})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 mt-3 pt-3 border-t`,children:[n.status===`connected`&&(0,X.jsxs)(I,{variant:`outline`,size:`sm`,onClick:()=>h(e),disabled:l===e,children:[l===e?(0,X.jsx)(U,{className:`size-4 animate-spin`}):(0,X.jsx)(zt,{className:`size-4`}),(0,X.jsx)(`span`,{className:`ml-1`,children:`Disconnect`})]}),(n.status===`disabled`||n.status===`failed`)&&(0,X.jsxs)(I,{variant:`outline`,size:`sm`,onClick:()=>m(e),disabled:l===e,children:[l===e?(0,X.jsx)(U,{className:`size-4 animate-spin`}):(0,X.jsx)(Bt,{className:`size-4`}),(0,X.jsx)(`span`,{className:`ml-1`,children:`Connect`})]}),n.status===`needs_auth`&&(0,X.jsxs)(I,{variant:`default`,size:`sm`,onClick:()=>g(e),disabled:l===e,children:[l===e?(0,X.jsx)(U,{className:`size-4 animate-spin`}):(0,X.jsx)(Ee,{className:`size-4`}),(0,X.jsx)(`span`,{className:`ml-1`,children:`Authenticate`})]})]})]},e)})})})]})]})})}function Ri({sdkClient:e}){let[t,n]=(0,Y.useState)([]),[r,i]=(0,Y.useState)(!0),[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(``),[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(null),h=(0,Y.useCallback)(async()=>{if(e){i(!0),o(null);try{n((await e.http.providers.listCredentials()).providers)}catch(e){o(e instanceof Error?e.message:`Failed to load providers`)}finally{i(!1)}}},[e]);(0,Y.useEffect)(()=>{h()},[h]);let g=async t=>{if(l.trim()){m(t);try{await e.http.providers.setCredential(t,{apiKey:l.trim()}),c(null),u(``),f(!1),await h()}catch(e){o(e instanceof Error?e.message:`Failed to set key`)}finally{m(null)}}},_=async t=>{m(t);try{await e.http.providers.clearCredential(t),await h()}catch(e){o(e instanceof Error?e.message:`Failed to clear key`)}finally{m(null)}},v={anthropic:`Anthropic`,google:`Google`,minimax:`MiniMax`,openai:`OpenAI`,openrouter:`OpenRouter`,zhipu:`Z.AI`,"zhipu-coding":`Z.AI Coding`},y=e=>v[e]||e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `);return r?(0,X.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,X.jsx)(U,{className:`size-6 animate-spin text-muted-foreground`})}):a&&t.length===0?(0,X.jsx)(`div`,{className:`p-4 text-sm text-destructive`,children:a}):(0,X.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Manage API keys for LLM providers. Keys are stored in ~/.jean2/.env and never exposed to the client.`}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground mt-2`,children:`OAuth-based providers are managed in the OAuth tab.`}),a&&(0,X.jsx)(`div`,{className:`p-2 rounded bg-destructive/10 text-sm text-destructive`,children:a}),(0,X.jsx)(`div`,{className:`space-y-2`,children:t.map(e=>(0,X.jsxs)(`div`,{className:`flex items-center justify-between p-3 rounded-lg border`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(At,{className:`size-4 text-muted-foreground`}),(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:y(e.provider)}),(0,X.jsx)(V,{variant:e.configured?`default`:`secondary`,children:e.configured?`Configured`:`Not set`})]}),(0,X.jsx)(`div`,{className:`flex items-center gap-2`,children:s===e.provider?(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(P,{type:d?`text`:`password`,value:l,onChange:e=>u(e.target.value),placeholder:`Enter API key...`,className:`w-full sm:w-48 h-8 text-sm pr-8`,onKeyDown:t=>{t.key===`Enter`&&g(e.provider),t.key===`Escape`&&(c(null),u(``))},autoFocus:!0}),(0,X.jsx)(I,{type:`button`,variant:`ghost`,size:`icon`,className:`absolute right-0 top-0 h-8 w-8`,onClick:()=>f(!d),children:d?(0,X.jsx)(Et,{className:`size-3`}):(0,X.jsx)(be,{className:`size-3`})})]}),(0,X.jsx)(I,{size:`sm`,onClick:()=>g(e.provider),disabled:!l.trim()||p===e.provider,children:p===e.provider?(0,X.jsx)(U,{className:`size-3 animate-spin`}):(0,X.jsx)(L,{className:`size-3`})}),(0,X.jsx)(I,{size:`sm`,variant:`ghost`,onClick:()=>{c(null),u(``)},children:(0,X.jsx)(B,{className:`size-3`})})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(I,{size:`sm`,variant:`outline`,onClick:()=>{c(e.provider),u(``),f(!1)},disabled:p===e.provider,children:e.configured?`Update`:`Set Key`}),e.configured&&(0,X.jsx)(I,{size:`sm`,variant:`ghost`,onClick:()=>_(e.provider),disabled:p===e.provider,children:p===e.provider?(0,X.jsx)(U,{className:`size-3 animate-spin`}):(0,X.jsx)(N,{className:`size-3`})})]})})]},e.provider))})]})}function zi({sdkClient:e}){let[t,n]=(0,Y.useState)([]),[r,i]=(0,Y.useState)(!0),[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)({}),[d,f]=(0,Y.useState)(null),p=(0,Y.useCallback)(async()=>{if(e){i(!0),o(null);try{n((await e.http.providers.list()).providers||[])}catch(e){o(e instanceof Error?e.message:`Failed to load providers`)}finally{i(!1)}}},[e]);(0,Y.useEffect)(()=>{p()},[p]);let m=async t=>{c(t),u(e=>({...e,[t]:``})),o(null);try{let n=await e.http.providers.connect(t);if(n.authorizationUrl){let e=n.authorizationUrl;u(n=>({...n,[t]:e}))}}catch(e){o(e instanceof Error?e.message:`Failed to connect provider`),u(e=>({...e,[t]:``}))}finally{c(null)}},h=async t=>{o(null);try{await e.http.providers.disconnect(t),await p()}catch(e){o(e instanceof Error?e.message:`Failed to disconnect provider`)}},g=async(e,t)=>{try{await navigator.clipboard.writeText(e),f(t),setTimeout(()=>f(null),2e3)}catch{}};return r?(0,X.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,X.jsx)(U,{className:`size-6 animate-spin text-muted-foreground`})}):(0,X.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Connect subscription-based providers using OAuth. No API keys needed.`}),a&&(0,X.jsx)(`div`,{className:`p-2 rounded bg-destructive/10 text-sm text-destructive`,children:a}),t.length===0?(0,X.jsx)(`div`,{className:`text-center py-8 text-sm text-muted-foreground`,children:`No OAuth providers available.`}):(0,X.jsx)(`div`,{className:`flex flex-col gap-3`,children:t.map(e=>(0,X.jsxs)(`div`,{className:`rounded-lg border p-3 sm:p-4 space-y-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`div`,{className:`size-2 rounded-full ${e.connected?`bg-green-500`:`bg-muted-foreground`}`}),(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:e.displayName||e.provider})]}),e.connected&&(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Connected`})]}),e.error&&(0,X.jsx)(`p`,{className:`text-xs text-destructive`,children:e.error}),e.connected&&e.connectedAt&&(0,X.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Connected `,new Date(e.connectedAt).toLocaleDateString()]}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[!e.connected&&!l[e.provider]&&(0,X.jsxs)(I,{size:`sm`,onClick:()=>m(e.provider),disabled:s===e.provider,children:[s===e.provider?(0,X.jsx)(U,{className:`size-3 animate-spin`}):null,`Connect`]}),e.connected&&(0,X.jsxs)(I,{variant:`destructive`,size:`sm`,onClick:()=>h(e.provider),children:[(0,X.jsx)(Ut,{className:`size-3`}),(0,X.jsx)(`span`,{className:`hidden sm:inline`,children:`Disconnect`})]})]}),!e.connected&&l[e.provider]&&(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Open this URL in your browser to complete the connection:`}),(0,X.jsx)(`div`,{className:`rounded-md bg-muted p-2`,children:(0,X.jsx)(`a`,{href:l[e.provider],target:`_blank`,rel:`noopener noreferrer`,className:`font-mono text-xs text-blue-500 underline break-all`,children:l[e.provider]})}),(0,X.jsxs)(I,{variant:`outline`,size:`sm`,onClick:()=>g(l[e.provider],e.provider),children:[d===e.provider?(0,X.jsx)(L,{className:`size-3`}):(0,X.jsx)(Se,{className:`size-3`}),d===e.provider?`Copied`:`Copy URL`]})]})]},e.provider))})]})}function Bi({className:e,size:t=`default`,...n}){return(0,X.jsx)(xr,{"data-slot":`switch`,"data-size":t,className:R(`peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50`,e),...n,children:(0,X.jsx)(Sr,{"data-slot":`switch-thumb`,className:`pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground`})})}function Vi({open:e,onOpenChange:t,title:n,description:r,confirmLabel:i=`Confirm`,cancelLabel:a=`Cancel`,variant:o=`default`,onConfirm:s,onCancel:c}){return(0,X.jsx)(ze,{open:e,onOpenChange:t,children:(0,X.jsxs)(Fe,{className:`sm:max-w-[425px]`,children:[(0,X.jsxs)(We,{children:[(0,X.jsx)(Ke,{children:n}),(0,X.jsx)(J,{children:r})]}),(0,X.jsxs)(Ae,{children:[(0,X.jsx)(I,{variant:`outline`,onClick:()=>{c==null||c(),t(!1)},children:a}),(0,X.jsx)(I,{variant:o===`destructive`?`destructive`:`default`,onClick:()=>{s(),t(!1)},children:i})]})]})})}function Hi({tier:e}){let{variant:t,icon:n}={budget:{variant:`secondary`,icon:(0,X.jsx)(`span`,{className:`text-[10px] font-bold`,children:`B`})},standard:{variant:`default`,icon:(0,X.jsx)(`span`,{className:`text-[10px] font-bold`,children:`S`})},premium:{variant:`outline`,icon:(0,X.jsx)(St,{className:`size-2.5`})}}[e];return(0,X.jsxs)(V,{variant:t,className:`text-[10px] gap-0.5`,children:[n,(0,X.jsx)(`span`,{className:`hidden sm:inline`,children:e})]})}function Ui({status:e}){return e.usable?(0,X.jsxs)(V,{variant:`default`,className:`bg-emerald-500/20 text-emerald-600 dark:text-emerald-400 border-emerald-500/30 text-[10px]`,children:[(0,X.jsx)(L,{className:`size-2.5`}),(0,X.jsx)(`span`,{className:`hidden sm:inline`,children:`Usable`})]}):e.providerSupported&&!e.providerConfigured?(0,X.jsxs)(V,{variant:`secondary`,className:`text-[10px]`,children:[(0,X.jsx)(xe,{className:`size-2.5`}),(0,X.jsx)(`span`,{className:`hidden sm:inline`,children:`Needs config`})]}):(0,X.jsxs)(V,{variant:`outline`,className:`text-[10px] text-muted-foreground`,children:[(0,X.jsx)(B,{className:`size-2.5`}),(0,X.jsx)(`span`,{className:`hidden sm:inline`,children:`Unsupported`})]})}var Wi={id:``,name:``},Gi={id:``,name:``,contextWindow:128e3,maxOutputTokens:void 0,tier:`standard`};function Ki({sdkClient:e}){var t,n,r;let[i,a]=(0,Y.useState)(null),[o,s]=(0,Y.useState)(!0),[c,l]=(0,Y.useState)(null),[u,d]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)(Wi),[g,_]=(0,Y.useState)(!1),[v,y]=(0,Y.useState)(null),[b,x]=(0,Y.useState)(!1),[S,C]=(0,Y.useState)(null),[w,T]=(0,Y.useState)(null),[E,D]=(0,Y.useState)(Gi),[ee,O]=(0,Y.useState)(!1),[k,A]=(0,Y.useState)(null),[te,j]=(0,Y.useState)(!1),[M,F]=(0,Y.useState)({}),[ne,re]=(0,Y.useState)(!1),[ie,ae]=(0,Y.useState)({defaultProvider:``,defaultModel:``}),[oe,ue]=(0,Y.useState)(!1);function R(e,t,n){var r;let i={...(r=e.capabilities)==null?void 0:r.input};i[t]=n;let a=i.text||i.image||i.video||Array.isArray(i.file)&&i.file.length>0;return{...e,capabilities:a?{input:i}:void 0}}function de(e,t){var n;let r=t.trim()?t.split(`,`).map(e=>e.trim()).filter(Boolean):void 0,i={...(n=e.capabilities)==null?void 0:n.input,file:r},a=i.text||i.image||i.video||Array.isArray(i.file)&&i.file.length>0;return{...e,capabilities:a?{input:i}:void 0}}let fe=()=>{let e={...E.variants||{}},t=`new`,n=1;for(;e[t];)t=`new-${n++}`;e[t]={providerOptions:{}},D(t=>({...t,variants:e}))},z=e=>{let t={...E.variants||{}};delete t[e];let n=Object.keys(t);D(e=>({...e,variants:n.length>0?t:void 0}))},me=(e,t)=>{if(e===t)return;let n={...E.variants||{}};if(n[t]&&t!==e)return;let r=n[e];delete n[e],n[t]=r,D(e=>({...e,variants:Object.keys(n).length>0?n:void 0}))},he=(e,t)=>{try{let n=JSON.parse(t);if(typeof n!=`object`||Array.isArray(n)){F(t=>({...t,[e]:!0}));return}let r={...E.variants||{}};r[e]={providerOptions:n},D(e=>({...e,variants:r})),F(t=>({...t,[e]:!1}))}catch{F(t=>({...t,[e]:!0}))}},[ge,W]=(0,Y.useState)(new Set),G=(0,Y.useCallback)(async()=>{if(e){s(!0),l(null);try{let t=await e.http.config.models.get();a(t),ae({defaultProvider:t.defaultProvider,defaultModel:t.defaultModel})}catch(e){l(e instanceof Error?e.message:`Failed to load models config`)}finally{s(!1)}}},[e]);(0,Y.useEffect)(()=>{G()},[G]);let _e=()=>{p(!0),d(null),h(Wi)},ve=e=>{d(e.id),p(!1),h({id:e.id,name:e.name})},ye=async()=>{if(!(!m.id.trim()||!m.name.trim())){_(!0),l(null);try{if(f){let t={id:m.id.trim(),name:m.name.trim()};await e.http.config.models.createProvider(t)}else{let t={name:m.name.trim()};await e.http.config.models.updateProvider(u,t)}p(!1),d(null),await G()}catch(e){l(e instanceof Error?e.message:`Failed to save provider`)}finally{_(!1)}}},be=async()=>{if(v){x(!0),l(null);try{await e.http.config.models.deleteProvider(v),y(null),await G()}catch(e){l(e instanceof Error?e.message:`Failed to delete provider`)}finally{x(!1)}}},xe=e=>{T(e),C(null),D(Gi),F({})},Se=e=>{C({providerId:e.providerId,modelId:e.id}),T(null),D({id:e.id,name:e.name,contextWindow:e.contextWindow,maxOutputTokens:e.maxOutputTokens,tier:e.tier,variants:e.variants,capabilities:e.capabilities}),F({})},Ce=async t=>{if(!(!E.id.trim()||!E.name.trim())){O(!0),l(null);try{if(w){let n={id:E.id.trim(),name:E.name.trim(),contextWindow:E.contextWindow,maxOutputTokens:E.maxOutputTokens,tier:E.tier,variants:E.variants,capabilities:E.capabilities};await e.http.config.models.createModel(t,n)}else{let n={name:E.name.trim(),contextWindow:E.contextWindow,maxOutputTokens:E.maxOutputTokens,tier:E.tier,variants:E.variants,capabilities:E.capabilities};await e.http.config.models.updateModel(t,S.modelId,n)}T(null),C(null),await G()}catch(e){l(e instanceof Error?e.message:`Failed to save model`)}finally{O(!1)}}},K=async()=>{if(k){j(!0),l(null);try{await e.http.config.models.deleteModel(k.providerId,k.modelId),A(null),await G()}catch(e){l(e instanceof Error?e.message:`Failed to delete model`)}finally{j(!1)}}},we=async()=>{ue(!0),l(null);try{await e.http.config.models.setDefaults({defaultProvider:ie.defaultProvider,defaultModel:ie.defaultModel}),re(!1),await G()}catch(e){l(e instanceof Error?e.message:`Failed to save defaults`)}finally{ue(!1)}},Te=e=>{W(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Ee=[];if(i==null||i.providers.forEach(e=>{e.models.forEach(t=>{Ee.push({providerId:e.id,providerName:e.name,modelId:t.id,modelName:t.name})})}),o)return(0,X.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,X.jsx)(U,{className:`size-6 animate-spin text-muted-foreground`})});if(f||u){let e=i==null?void 0:i.providers.find(e=>e.id===u);return(0,X.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-medium`,children:f?`New Provider`:`Edit: ${(e==null?void 0:e.name)||u}`}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(I,{size:`sm`,onClick:ye,disabled:g||!m.id.trim()||!m.name.trim(),children:[g?(0,X.jsx)(U,{className:`size-3 animate-spin`}):(0,X.jsx)(L,{className:`size-3`}),`Save`]}),(0,X.jsx)(I,{size:`sm`,variant:`ghost`,onClick:()=>{p(!1),d(null)},children:(0,X.jsx)(B,{className:`size-3`})})]})]}),c&&(0,X.jsx)(`div`,{className:`p-2 rounded bg-destructive/10 text-sm text-destructive`,children:c}),(0,X.jsxs)(`div`,{className:`space-y-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)($,{className:`text-xs`,children:`Provider ID`}),(0,X.jsx)(P,{value:m.id,onChange:e=>h(t=>({...t,id:e.target.value})),disabled:!f,placeholder:`e.g., openai`,className:`mt-1 font-mono`}),!f&&(0,X.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-1`,children:`ID cannot be changed`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)($,{className:`text-xs`,children:`Name`}),(0,X.jsx)(P,{value:m.name,onChange:e=>h(t=>({...t,name:e.target.value})),placeholder:`e.g., OpenAI`,className:`mt-1`})]})]})]})}if(w||S){var De,Oe,ke,q,Ae,je,Me,Ne,J;let e=w||(S==null?void 0:S.providerId)||``,t=i==null?void 0:i.providers.find(t=>t.id===e),n=!w&&S?t==null?void 0:t.models.find(e=>e.id===S.modelId):null;return(0,X.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-medium`,children:w?`New Model (${(t==null?void 0:t.name)||e})`:`Edit: ${(n==null?void 0:n.name)||(S==null?void 0:S.modelId)}`}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(I,{size:`sm`,onClick:()=>Ce(e),disabled:ee||!E.id.trim()||!E.name.trim()||Object.values(M).some(Boolean),children:[ee?(0,X.jsx)(U,{className:`size-3 animate-spin`}):(0,X.jsx)(L,{className:`size-3`}),`Save`]}),(0,X.jsx)(I,{size:`sm`,variant:`ghost`,onClick:()=>{T(null),C(null)},children:(0,X.jsx)(B,{className:`size-3`})})]})]}),c&&(0,X.jsx)(`div`,{className:`p-2 rounded bg-destructive/10 text-sm text-destructive`,children:c}),(0,X.jsxs)(`div`,{className:`space-y-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)($,{className:`text-xs`,children:`Model ID`}),(0,X.jsx)(P,{value:E.id,onChange:e=>D(t=>({...t,id:e.target.value})),disabled:!w,placeholder:`e.g., gpt-4o`,className:`mt-1 font-mono`}),!w&&(0,X.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-1`,children:`ID cannot be changed`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)($,{className:`text-xs`,children:`Display Name`}),(0,X.jsx)(P,{value:E.name,onChange:e=>D(t=>({...t,name:e.target.value})),placeholder:`e.g., GPT-4o`,className:`mt-1`})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)($,{className:`text-xs`,children:`Context Window`}),(0,X.jsx)(P,{type:`number`,value:E.contextWindow,onChange:e=>D(t=>({...t,contextWindow:parseInt(e.target.value)||0})),min:1,className:`mt-1`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)($,{className:`text-xs`,children:`Max Output Tokens`}),(0,X.jsx)(P,{type:`number`,value:(De=E.maxOutputTokens)==null?``:De,onChange:e=>D(t=>({...t,maxOutputTokens:e.target.value?parseInt(e.target.value):void 0})),min:1,placeholder:`Optional`,className:`mt-1`})]})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)($,{className:`text-xs`,children:`Tier`}),(0,X.jsxs)(`select`,{value:E.tier,onChange:e=>D(t=>({...t,tier:e.target.value})),className:`mt-1 h-8 w-full rounded-lg border border-input bg-transparent px-2.5 text-sm`,children:[(0,X.jsx)(`option`,{value:`budget`,children:`Budget`}),(0,X.jsx)(`option`,{value:`standard`,children:`Standard`}),(0,X.jsx)(`option`,{value:`premium`,children:`Premium`})]})]}),(0,X.jsx)(H,{className:`my-2`}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)($,{className:`text-xs font-medium`,children:`Capabilities`}),(0,X.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,X.jsxs)(`label`,{className:`flex items-center gap-1.5 cursor-pointer`,children:[(0,X.jsx)(Bi,{checked:(Oe=(ke=E.capabilities)==null||(ke=ke.input)==null?void 0:ke.text)==null?!1:Oe,onCheckedChange:e=>D(t=>R(t,`text`,e))}),(0,X.jsx)(`span`,{className:`text-xs`,children:`Text`})]}),(0,X.jsxs)(`label`,{className:`flex items-center gap-1.5 cursor-pointer`,children:[(0,X.jsx)(Bi,{checked:(q=(Ae=E.capabilities)==null||(Ae=Ae.input)==null?void 0:Ae.image)==null?!1:q,onCheckedChange:e=>D(t=>R(t,`image`,e))}),(0,X.jsx)(`span`,{className:`text-xs`,children:`Image`})]}),(0,X.jsxs)(`label`,{className:`flex items-center gap-1.5 cursor-pointer`,children:[(0,X.jsx)(Bi,{checked:(je=(Me=E.capabilities)==null||(Me=Me.input)==null?void 0:Me.video)==null?!1:je,onCheckedChange:e=>D(t=>R(t,`video`,e))}),(0,X.jsx)(`span`,{className:`text-xs`,children:`Video`})]})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)($,{className:`text-xs`,children:`File Types (MIME, comma-separated)`}),(0,X.jsx)(P,{value:(Ne=(J=E.capabilities)==null||(J=J.input)==null||(J=J.file)==null?void 0:J.join(`, `))==null?``:Ne,onChange:e=>D(t=>de(t,e.target.value)),placeholder:`e.g., application/pdf, text/csv`,className:`mt-1 font-mono text-xs`})]})]}),(0,X.jsx)(H,{className:`my-2`}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)($,{className:`text-xs font-medium`,children:`Variants`}),(0,X.jsxs)(I,{type:`button`,size:`sm`,variant:`ghost`,onClick:fe,children:[(0,X.jsx)(se,{className:`size-3`}),`Add Variant`]})]}),E.variants&&Object.keys(E.variants).length>0?(0,X.jsx)(`div`,{className:`space-y-2`,children:Object.entries(E.variants).map(([e,t])=>(0,X.jsxs)(`div`,{className:`border rounded p-2 space-y-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(P,{value:e,onChange:t=>me(e,t.target.value),placeholder:`variant name`,className:`h-7 text-xs font-mono w-24`}),(0,X.jsx)(`div`,{className:`flex-1`}),(0,X.jsx)(I,{type:`button`,size:`icon-xs`,variant:`ghost`,onClick:()=>z(e),children:(0,X.jsx)(N,{className:`size-3`})})]}),(0,X.jsx)(Pe,{value:JSON.stringify(t.providerOptions,null,2),onChange:t=>he(e,t.target.value),placeholder:`{}`,className:`font-mono text-xs min-h-[60px]`,rows:3}),M[e]&&(0,X.jsx)(`p`,{className:`text-[10px] text-destructive`,children:`Invalid JSON`})]},e))}):(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No variants configured`})]})]})]})}return(0,X.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,X.jsxs)(`div`,{className:`border rounded-lg p-3 space-y-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsxs)(`h3`,{className:`text-sm font-medium flex items-center gap-2`,children:[(0,X.jsx)(Tt,{className:`size-4`}),`Default Model`]}),(0,X.jsx)(I,{size:`sm`,variant:`ghost`,onClick:()=>re(!ne),children:ne?(0,X.jsx)(B,{className:`size-3`}):(0,X.jsx)(Qe,{className:`size-3`})})]}),ne?(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)($,{className:`text-xs`,children:`Default Provider`}),(0,X.jsxs)(`select`,{value:ie.defaultProvider,onChange:e=>ae(t=>({...t,defaultProvider:e.target.value,defaultModel:``})),className:`mt-1 h-8 w-full rounded-lg border border-input bg-transparent px-2.5 text-sm`,children:[(0,X.jsx)(`option`,{value:``,children:`Select provider...`}),i==null?void 0:i.providers.map(e=>(0,X.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)($,{className:`text-xs`,children:`Default Model`}),(0,X.jsxs)(`select`,{value:ie.defaultModel,onChange:e=>ae(t=>({...t,defaultModel:e.target.value})),className:`mt-1 h-8 w-full rounded-lg border border-input bg-transparent px-2.5 text-sm`,children:[(0,X.jsx)(`option`,{value:``,children:`Select model...`}),i==null||(t=i.providers.find(e=>e.id===ie.defaultProvider))==null?void 0:t.models.map(e=>(0,X.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,X.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,X.jsx)(I,{size:`sm`,variant:`ghost`,onClick:()=>re(!1),children:`Cancel`}),(0,X.jsxs)(I,{size:`sm`,onClick:we,disabled:oe||!ie.defaultProvider||!ie.defaultModel,children:[oe?(0,X.jsx)(U,{className:`size-3 animate-spin`}):(0,X.jsx)(L,{className:`size-3`}),`Save`]})]})]}):(0,X.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:i!=null&&i.defaultProvider&&i!=null&&i.defaultModel?(0,X.jsxs)(`span`,{children:[((n=i.providers.find(e=>e.id===i.defaultProvider))==null?void 0:n.name)||i.defaultProvider,` /`,` `,((r=i.providers.find(e=>e.id===i.defaultProvider))==null||(r=r.models.find(e=>e.id===i.defaultModel))==null?void 0:r.name)||i.defaultModel]}):(0,X.jsx)(`span`,{className:`italic`,children:`Not configured`})})]}),c&&(0,X.jsx)(`div`,{className:`p-2 rounded bg-destructive/10 text-sm text-destructive`,children:c}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[(i==null?void 0:i.providers.length)||0,` provider`,((i==null?void 0:i.providers.length)||0)===1?``:`s`]}),(0,X.jsxs)(I,{size:`sm`,onClick:_e,children:[(0,X.jsx)(se,{className:`size-3`}),(0,X.jsx)(`span`,{className:`hidden sm:inline`,children:`Add Provider`})]})]}),(i==null?void 0:i.providers.length)===0?(0,X.jsx)(`div`,{className:`text-center py-8 text-sm text-muted-foreground`,children:`No providers configured. Add one to get started.`}):(0,X.jsx)(`div`,{className:`space-y-2`,children:i==null?void 0:i.providers.map(e=>{let t=ge.has(e.id),n=e.id===i.defaultProvider;return(0,X.jsxs)(le,{open:!t,onOpenChange:()=>Te(e.id),className:`border rounded-lg`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between w-full px-3 py-2 text-left hover:bg-muted/50 transition-colors cursor-pointer`,onClick:()=>Te(e.id),children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,X.jsx)(ce,{className:`size-4 transition-transform ${t?``:`rotate-90`}`}),(0,X.jsx)(`span`,{className:`text-sm font-medium truncate`,children:e.name}),(0,X.jsxs)(V,{variant:`secondary`,className:`text-[10px] shrink-0`,children:[e.models.length,` model`,e.models.length===1?``:`s`]}),n&&(0,X.jsx)(V,{variant:`outline`,className:`text-[10px] shrink-0`,children:`Default`})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(I,{size:`icon-xs`,variant:`ghost`,onClick:()=>xe(e.id),title:`Add model`,children:(0,X.jsx)(se,{className:`size-3`})}),(0,X.jsx)(I,{size:`icon-xs`,variant:`ghost`,onClick:()=>ve(e),title:`Edit provider`,children:(0,X.jsx)(Qe,{className:`size-3`})}),(0,X.jsx)(I,{size:`icon-xs`,variant:`ghost`,onClick:()=>y(e.id),title:`Delete provider`,children:(0,X.jsx)(N,{className:`size-3`})})]})]}),(0,X.jsx)(pe,{children:(0,X.jsx)(`div`,{className:`border-t px-3 py-2 space-y-1 bg-muted/30`,children:e.models.length===0?(0,X.jsx)(`div`,{className:`text-sm text-muted-foreground py-2 pl-6`,children:`No models. Add one to get started.`}):e.models.map(e=>{var t,n,r,a;let o=e.id===i.defaultModel&&e.providerId===i.defaultProvider;return(0,X.jsxs)(`div`,{className:`flex items-center justify-between py-1.5 pl-6 pr-2 rounded hover:bg-background`,children:[(0,X.jsxs)(`div`,{className:`flex-1 min-w-0 flex flex-col gap-0.5`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,X.jsx)(`span`,{className:`text-sm truncate`,children:e.name}),(0,X.jsx)(Hi,{tier:e.tier}),(0,X.jsx)(Ui,{status:e.runtimeStatus}),o&&(0,X.jsxs)(V,{variant:`outline`,className:`text-[10px]`,children:[(0,X.jsx)(St,{className:`size-2.5`}),(0,X.jsx)(`span`,{className:`hidden sm:inline`,children:`Default`})]})]}),(0,X.jsxs)(`div`,{className:`hidden sm:flex items-center gap-2`,children:[(0,X.jsx)(`code`,{className:`text-[10px] text-muted-foreground bg-muted px-1 rounded`,children:e.id}),((t=e.capabilities)==null||(t=t.input)==null?void 0:t.text)&&(0,X.jsx)(V,{variant:`outline`,className:`text-[10px] px-1.5 py-0`,children:`Text`}),((n=e.capabilities)==null||(n=n.input)==null?void 0:n.image)&&(0,X.jsx)(V,{variant:`outline`,className:`text-[10px] px-1.5 py-0`,children:`Image`}),((r=e.capabilities)==null||(r=r.input)==null?void 0:r.video)&&(0,X.jsx)(V,{variant:`outline`,className:`text-[10px] px-1.5 py-0`,children:`Video`}),((a=e.capabilities)==null||(a=a.input)==null?void 0:a.file)&&e.capabilities.input.file.length>0&&(0,X.jsxs)(V,{variant:`outline`,className:`text-[10px] px-1.5 py-0`,children:[`Files (`,e.capabilities.input.file.length,`)`]}),e.variants&&Object.keys(e.variants).length>0&&(0,X.jsxs)(V,{variant:`secondary`,className:`text-[10px] px-1.5 py-0`,children:[Object.keys(e.variants).length,` variant`,Object.keys(e.variants).length===1?``:`s`]})]})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,X.jsx)(I,{size:`icon-xs`,variant:`ghost`,onClick:()=>Se(e),title:`Edit model`,children:(0,X.jsx)(Qe,{className:`size-2.5`})}),(0,X.jsx)(I,{size:`icon-xs`,variant:`ghost`,onClick:()=>A({providerId:e.providerId,modelId:e.id}),title:`Delete model`,children:(0,X.jsx)(N,{className:`size-2.5`})})]})]},e.id)})})})]},e.id)})}),(0,X.jsx)(Vi,{open:v!==null,onOpenChange:e=>{e||y(null)},title:`Delete Provider`,description:`Are you sure you want to delete "${v}"? All models under this provider will be removed.${(i==null?void 0:i.defaultProvider)===v?` Warning: This is the current default provider.`:``}`,confirmLabel:`Delete`,variant:`destructive`,onConfirm:be}),(0,X.jsx)(Vi,{open:k!==null,onOpenChange:e=>{e||A(null)},title:`Delete Model`,description:`Are you sure you want to delete "${k==null?void 0:k.modelId}"?${(i==null?void 0:i.defaultModel)===(k==null?void 0:k.modelId)&&(i==null?void 0:i.defaultProvider)===(k==null?void 0:k.providerId)?` Warning: This is the current default model.`:``}`,confirmLabel:`Delete`,variant:`destructive`,onConfirm:K})]})}function qi({sdkClient:e}){let[t,n]=(0,Y.useState)([]),[r,i]=(0,Y.useState)(!0),[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(``),[p,m]=(0,Y.useState)(``),[h,g]=(0,Y.useState)(!1),[_,v]=(0,Y.useState)(null),y=(0,Y.useCallback)(async()=>{if(e){i(!0),o(null);try{n((await e.http.config.prompts.list()).prompts)}catch(e){o(e instanceof Error?e.message:`Failed to load prompts`)}finally{i(!1)}}},[e]);(0,Y.useEffect)(()=>{y()},[y]);let b=()=>{u(!0),c(null),f(``),m(`# New Prompt
|
|
11
|
+
|
|
12
|
+
`)},x=e=>{c(e),u(!1),f(e.name),m(e.content)};return l||s?(0,X.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(I,{variant:`ghost`,size:`icon`,onClick:()=>{u(!1),c(null),f(``),m(``)},children:(0,X.jsx)(G,{className:`size-4`})}),(0,X.jsx)(`h3`,{className:`text-sm font-medium`,children:l?`New Prompt`:`Edit: ${s==null?void 0:s.name}`})]}),(0,X.jsx)(I,{size:`sm`,onClick:async()=>{if(d.trim()){g(!0),o(null);try{l?await e.http.config.prompts.create({name:d.trim(),content:p}):s&&await e.http.config.prompts.update(s.name,{content:p}),u(!1),c(null),await y()}catch(e){o(e instanceof Error?e.message:`Failed to save prompt`)}finally{g(!1)}}},disabled:h||!d.trim(),children:h?(0,X.jsx)(U,{className:`size-3 animate-spin`}):`Save`})]}),a&&(0,X.jsx)(`div`,{className:`p-2 rounded bg-destructive/10 text-sm text-destructive`,children:a}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`text-sm font-medium mb-1 block`,children:`Name`}),(0,X.jsx)(P,{value:d,onChange:e=>f(e.target.value),disabled:!l,placeholder:`prompt-name`,className:`font-mono`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`text-sm font-medium mb-1 block`,children:`Content (Markdown)`}),(0,X.jsx)(`textarea`,{value:p,onChange:e=>m(e.target.value),className:`w-full h-64 p-3 rounded-lg border bg-background font-mono text-sm resize-y`,placeholder:`# Prompt Title\\n\\nPrompt content here...`})]})]}):r?(0,X.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,X.jsx)(U,{className:`size-6 animate-spin text-muted-foreground`})}):(0,X.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[t.length,` prompt`,t.length===1?``:`s`]}),(0,X.jsxs)(I,{size:`sm`,onClick:b,children:[(0,X.jsx)(se,{className:`size-3`,"data-icon":`inline-start`}),`New Prompt`]})]}),a&&(0,X.jsx)(`div`,{className:`p-2 rounded bg-destructive/10 text-sm text-destructive`,children:a}),t.length===0?(0,X.jsx)(`div`,{className:`text-center py-8 text-sm text-muted-foreground`,children:`No prompts yet. Create one to get started.`}):(0,X.jsx)(`div`,{className:`space-y-2`,children:t.map(e=>(0,X.jsxs)(`div`,{className:`flex items-center justify-between p-3 rounded-lg border hover:bg-muted/50 cursor-pointer`,onClick:()=>x(e),children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,X.jsx)(ye,{className:`size-4 text-muted-foreground shrink-0`}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`div`,{className:`text-sm font-medium truncate`,children:e.name}),e.description&&(0,X.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:e.description})]})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,X.jsx)(I,{size:`icon`,variant:`ghost`,className:`size-8`,onClick:t=>{t.stopPropagation(),x(e)},children:(0,X.jsx)(Qe,{className:`size-3`})}),(0,X.jsx)(I,{size:`icon`,variant:`ghost`,className:`size-8`,onClick:t=>{t.stopPropagation(),v(e.name)},children:(0,X.jsx)(N,{className:`size-3`})})]})]},e.name))}),(0,X.jsx)(Vi,{open:_!==null,onOpenChange:e=>{e||v(null)},title:`Delete Prompt`,description:`Are you sure you want to delete the prompt "${_}"? This cannot be undone.`,confirmLabel:`Delete`,variant:`destructive`,onConfirm:async()=>{if(_)try{await e.http.config.prompts.delete(_),v(null),await y()}catch(e){o(e instanceof Error?e.message:`Failed to delete prompt`)}}})]})}var Ji=[{value:`primary`,label:`Primary`},{value:`subagent`,label:`Subagent`},{value:`both`,label:`Both`}],Yi={name:``,description:``,systemPrompt:``,mode:`primary`,model:``,provider:``,variant:``,tools:[],temperature:``,canSpawnSubagentsMode:`none`,canSpawnSubagentsList:[],skills:[],isDefault:!1};function Xi({sdkClient:e}){let[t,n]=(0,Y.useState)([]),[r,i]=(0,Y.useState)(!0),[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(Yi),[p,m]=(0,Y.useState)(!1),[h,g]=(0,Y.useState)(null),[_,v]=(0,Y.useState)(!1),[y,b]=(0,Y.useState)([]),[x,S]=(0,Y.useState)(``),[C,w]=(0,Y.useState)(``),[T,E]=(0,Y.useState)(``),D=z(e=>e.models),[ee,O]=(0,Y.useState)(!1),k=d.model?D.find(e=>e.id===d.model):null,A=k!=null&&k.variants?Object.keys(k.variants):[],te=D.reduce((e,t)=>{let n=t.providerName||t.providerId;return e[n]||(e[n]=[]),e[n].push(t),e},{}),j=t.filter(e=>{var t;let n=(t=e.mode)==null?`primary`:t,r=n===`subagent`||n===`both`,i=!s||e.id!==s.id;return r&&i}),M=(0,Y.useCallback)(async()=>{if(e){i(!0),o(null);try{n((await e.http.preconfigs.list()).preconfigs)}catch(e){o(e instanceof Error?e.message:`Failed to load preconfigs`)}finally{i(!1)}}},[e]);(0,Y.useEffect)(()=>{M()},[M]),(0,Y.useEffect)(()=>{e&&e.http.tools.list().then(e=>b(e.tools||[])).catch(()=>{})},[e]);let F=()=>{u(!0),c(null),f(Yi),S(``),w(``),E(``),O(!1)},ne=e=>{var t,n,r;c(e),u(!1),f({name:e.name,description:e.description||``,systemPrompt:e.systemPrompt||``,mode:e.mode||`primary`,model:e.model||``,provider:e.provider||``,variant:e.variant||``,tools:(t=e.tools)==null?[]:t,temperature:((n=e.settings)==null?void 0:n.temperature)==null?``:String(e.settings.temperature),canSpawnSubagentsMode:e.canSpawnSubagents===!0?`all`:e.canSpawnSubagents===!1||e.canSpawnSubagents===null||e.canSpawnSubagents===void 0?`none`:`specific`,canSpawnSubagentsList:Array.isArray(e.canSpawnSubagents)?e.canSpawnSubagents:[],skills:(r=e.skills)==null?[]:r,isDefault:e.isDefault}),S(``),w(``),E(``)};return l||s?(0,X.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(I,{variant:`ghost`,size:`icon`,onClick:()=>{u(!1),c(null),f(Yi),S(``),w(``),E(``),O(!1)},children:(0,X.jsx)(G,{className:`size-4`})}),(0,X.jsx)(`h3`,{className:`text-sm font-medium`,children:l?`New Preconfig`:`Edit: ${s==null?void 0:s.name}`})]}),(0,X.jsx)(I,{size:`sm`,onClick:async()=>{if(d.name.trim()){m(!0),o(null);try{let t=null;if(d.temperature.trim()){let e=parseFloat(d.temperature);if(isNaN(e)||e<.1||e>.9){o(`Temperature must be between 0.1 and 0.9`),m(!1);return}t={temperature:e}}let n=null;n=d.canSpawnSubagentsMode===`all`?!0:d.canSpawnSubagentsMode===`specific`?d.canSpawnSubagentsList.length>0?d.canSpawnSubagentsList:[]:!1;let r={name:d.name.trim(),description:d.description.trim(),systemPrompt:d.systemPrompt,mode:d.mode,model:d.model.trim()||null,provider:d.provider.trim()||null,variant:d.variant.trim()||null,tools:d.tools.length>0?d.tools:null,settings:t,canSpawnSubagents:n,skills:d.skills.length>0?d.skills:null,isDefault:d.isDefault,format:`md`};l?await e.http.preconfigs.create(r):s&&await e.http.preconfigs.update(s.id,r),u(!1),c(null),await M()}catch(e){o(e instanceof Error?e.message:`Failed to save preconfig`)}finally{m(!1)}}},disabled:p||!d.name.trim(),children:p?(0,X.jsx)(U,{className:`size-3 animate-spin`}):`Save`})]}),a&&(0,X.jsx)(`div`,{className:`p-2 rounded bg-destructive/10 text-sm text-destructive`,children:a}),(0,X.jsxs)(`div`,{className:`space-y-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)($,{className:`text-sm`,children:`Name`}),(0,X.jsx)(P,{value:d.name,onChange:e=>f({...d,name:e.target.value}),placeholder:`My Agent`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)($,{className:`text-sm`,children:`Description`}),(0,X.jsx)(P,{value:d.description,onChange:e=>f({...d,description:e.target.value}),placeholder:`Description...`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)($,{className:`text-sm`,children:`Mode`}),(0,X.jsx)(`select`,{value:d.mode,onChange:e=>f({...d,mode:e.target.value}),className:`w-full h-9 rounded-md border bg-background px-3 text-sm`,children:Ji.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-3`,children:[(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)($,{className:`text-sm`,children:`Model`}),(0,X.jsxs)(He,{open:ee,onOpenChange:O,children:[(0,X.jsx)(Ie,{asChild:!0,children:(0,X.jsxs)(I,{variant:`outline`,role:`combobox`,"aria-expanded":ee,className:`w-full justify-between font-mono text-sm h-9`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 truncate`,children:[(0,X.jsx)(we,{className:`size-4 shrink-0 text-muted-foreground`}),k?(0,X.jsx)(`span`,{className:`truncate`,children:k.name}):(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:`Use server default`})]}),(0,X.jsx)(Ge,{className:`size-3 shrink-0 opacity-50`})]})}),(0,X.jsx)(Be,{className:`w-[280px] p-0`,align:`start`,children:(0,X.jsxs)(je,{children:[(0,X.jsx)(Me,{placeholder:`Search models...`}),(0,X.jsxs)(Ue,{className:`max-h-[50vh] overflow-y-auto`,children:[(0,X.jsx)(Re,{children:`No model found.`}),(0,X.jsx)(Ve,{children:(0,X.jsxs)(Le,{onSelect:()=>{f(e=>({...e,model:``,provider:``,variant:``})),O(!1)},className:`justify-between`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:`Use server default`}),!d.model&&(0,X.jsx)(L,{className:`size-4`})]})}),Object.entries(te).map(([e,t])=>(0,X.jsx)(Ve,{heading:e,children:t.map(e=>(0,X.jsxs)(Le,{value:`${e.name} ${e.id}`,onSelect:()=>{f(t=>({...t,model:e.id,provider:e.providerId,variant:``})),O(!1)},className:`justify-between`,children:[(0,X.jsx)(`span`,{className:`truncate`,children:e.name}),(0,X.jsx)(L,{className:R(`size-4 shrink-0`,d.model===e.id?`opacity-100`:`opacity-0`)})]},e.id))},e))]})]})})]}),(0,X.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Provider is set automatically based on the selected model`})]}),A.length>0&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)($,{className:`text-sm`,children:`Variant`}),(0,X.jsxs)(`select`,{value:d.variant,onChange:e=>f(t=>({...t,variant:e.target.value})),className:`w-full h-9 rounded-md border bg-background px-3 text-sm`,children:[(0,X.jsx)(`option`,{value:``,children:`Default`}),A.map(e=>(0,X.jsx)(`option`,{value:e,children:e},e))]}),(0,X.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-1`,children:`Model variant from models.json (e.g., reasoning effort)`})]})]}),(0,X.jsx)(H,{className:`my-1`}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)($,{className:`text-sm`,children:`Default Preconfig`}),(0,X.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Only one preconfig can be the default`})]}),(0,X.jsx)(Bi,{checked:d.isDefault,onCheckedChange:e=>f({...d,isDefault:e})})]}),(0,X.jsx)(H,{className:`my-1`}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)($,{className:`text-sm`,children:`Tools`}),(0,X.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:d.tools.length===0?`No tools selected — all available tools will be enabled`:`${d.tools.length} tool${d.tools.length===1?``:`s`} selected`}),y.length>0&&(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:y.map(e=>{let t=d.tools.includes(e.name);return(0,X.jsxs)(`button`,{type:`button`,onClick:()=>{f(n=>({...n,tools:t?n.tools.filter(t=>t!==e.name):[...n.tools,e.name]}))},className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-xs border transition-colors ${t?`bg-primary text-primary-foreground border-primary`:`bg-background border-border hover:bg-muted`}`,title:e.description,children:[t&&(0,X.jsx)(L,{className:`size-2.5`}),e.name]},e.name)})}),(0,X.jsx)(`div`,{className:`flex gap-1.5`,children:(0,X.jsx)(P,{value:x,onChange:e=>S(e.target.value),placeholder:`Add custom tool ID...`,className:`h-7 text-xs font-mono`,onKeyDown:e=>{if(e.key===`Enter`&&x.trim()){e.preventDefault();let t=x.trim();d.tools.includes(t)||f(e=>({...e,tools:[...e.tools,t]})),S(``)}}})}),d.tools.filter(e=>!y.some(t=>t.name===e)).length>0&&(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:d.tools.filter(e=>!y.some(t=>t.name===e)).map(e=>(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-xs bg-primary/10 border border-primary/30`,children:[e,(0,X.jsx)(`button`,{type:`button`,onClick:()=>f(t=>({...t,tools:t.tools.filter(t=>t!==e)})),className:`hover:text-destructive`,children:(0,X.jsx)(B,{className:`size-2.5`})})]},e))})]}),(0,X.jsx)(H,{className:`my-1`}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)($,{className:`text-sm`,children:`Temperature`}),(0,X.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Model sampling temperature (0.1–0.9). Leave empty to use server default.`}),(0,X.jsx)(P,{type:`number`,value:d.temperature,onChange:e=>f({...d,temperature:e.target.value}),placeholder:`0.2`,min:`0.1`,max:`0.9`,step:`0.1`,className:`font-mono`})]}),(0,X.jsx)(H,{className:`my-1`}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)($,{className:`text-sm`,children:`Can Spawn Subagents`}),(0,X.jsxs)(`select`,{value:d.canSpawnSubagentsMode,onChange:e=>f({...d,canSpawnSubagentsMode:e.target.value}),className:`w-full h-9 rounded-md border bg-background px-3 text-sm`,children:[(0,X.jsx)(`option`,{value:`none`,children:`No — cannot spawn subagents`}),(0,X.jsx)(`option`,{value:`all`,children:`Yes — all available subagents`}),(0,X.jsx)(`option`,{value:`specific`,children:`Specific — choose which subagents`})]}),d.canSpawnSubagentsMode===`specific`&&(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Select from available subagents or enter a preconfig ID manually`}),j.length>0&&(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:j.map(e=>{let t=d.canSpawnSubagentsList.includes(e.id);return(0,X.jsxs)(`button`,{type:`button`,onClick:()=>{f(n=>({...n,canSpawnSubagentsList:t?n.canSpawnSubagentsList.filter(t=>t!==e.id):[...n.canSpawnSubagentsList,e.id]}))},className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-xs border transition-colors ${t?`bg-primary text-primary-foreground border-primary`:`bg-background border-border hover:bg-muted`}`,title:e.description||e.id,children:[t&&(0,X.jsx)(L,{className:`size-2.5`}),e.name]},e.id)})}),(0,X.jsx)(`div`,{className:`flex gap-1.5`,children:(0,X.jsx)(P,{value:C,onChange:e=>w(e.target.value),placeholder:`Preconfig ID...`,className:`h-7 text-xs font-mono`,onKeyDown:e=>{if(e.key===`Enter`&&C.trim()){e.preventDefault();let t=C.trim();d.canSpawnSubagentsList.includes(t)||f(e=>({...e,canSpawnSubagentsList:[...e.canSpawnSubagentsList,t]})),w(``)}}})}),d.canSpawnSubagentsList.filter(e=>!j.some(t=>t.id===e)).length>0&&(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:d.canSpawnSubagentsList.filter(e=>!j.some(t=>t.id===e)).map(e=>(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-xs bg-primary/10 border border-primary/30 font-mono`,children:[e,(0,X.jsx)(`button`,{type:`button`,onClick:()=>f(t=>({...t,canSpawnSubagentsList:t.canSpawnSubagentsList.filter(t=>t!==e)})),className:`hover:text-destructive`,children:(0,X.jsx)(B,{className:`size-2.5`})})]},e))})]})]}),(0,X.jsx)(H,{className:`my-1`}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)($,{className:`text-sm`,children:`Skills`}),(0,X.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:d.skills.length===0?`No skills selected — all available skills will be enabled`:`${d.skills.length} skill${d.skills.length===1?``:`s`} selected`}),(0,X.jsx)(`div`,{className:`flex gap-1.5`,children:(0,X.jsx)(P,{value:T,onChange:e=>E(e.target.value),placeholder:`Skill name...`,className:`h-7 text-xs font-mono`,onKeyDown:e=>{if(e.key===`Enter`&&T.trim()){e.preventDefault();let t=T.trim();d.skills.includes(t)||f(e=>({...e,skills:[...e.skills,t]})),E(``)}}})}),d.skills.length>0&&(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:d.skills.map(e=>(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-xs bg-primary/10 border border-primary/30`,children:[e,(0,X.jsx)(`button`,{type:`button`,onClick:()=>f(t=>({...t,skills:t.skills.filter(t=>t!==e)})),className:`hover:text-destructive`,children:(0,X.jsx)(B,{className:`size-2.5`})})]},e))})]}),(0,X.jsx)(H,{className:`my-1`}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)($,{className:`text-sm`,children:`System Prompt`}),(0,X.jsx)(`textarea`,{value:d.systemPrompt,onChange:e=>f({...d,systemPrompt:e.target.value}),className:`w-full h-48 p-3 rounded-lg border bg-background text-sm resize-y`,placeholder:`System prompt content...`})]})]})]}):r?(0,X.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,X.jsx)(U,{className:`size-6 animate-spin text-muted-foreground`})}):(0,X.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[t.length,` preconfig`,t.length===1?``:`s`]}),(0,X.jsxs)(I,{size:`sm`,onClick:F,children:[(0,X.jsx)(se,{className:`size-3`}),(0,X.jsx)(`span`,{className:`hidden sm:inline`,children:`New Preconfig`})]})]}),a&&(0,X.jsx)(`div`,{className:`p-2 rounded bg-destructive/10 text-sm text-destructive`,children:a}),t.length===0?(0,X.jsx)(`div`,{className:`text-center py-8 text-sm text-muted-foreground`,children:`No preconfigs yet. Create one to get started.`}):(0,X.jsx)(`div`,{className:`space-y-2`,children:t.map(e=>(0,X.jsxs)(`div`,{className:`flex items-center justify-between p-2.5 sm:p-3 rounded-lg border hover:bg-muted/50 cursor-pointer`,onClick:()=>ne(e),children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 sm:gap-3 flex-1 min-w-0`,children:[(0,X.jsx)(Mt,{className:`size-4 text-muted-foreground shrink-0 hidden sm:block`}),(0,X.jsxs)(`div`,{className:`flex flex-col flex-1 min-w-0 gap-0.5 sm:gap-1 overflow-hidden`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 min-w-0`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium truncate`,children:e.name}),e.isDefault&&(0,X.jsxs)(V,{variant:`default`,className:`text-[10px] px-1 sm:px-1.5 py-0`,children:[(0,X.jsx)(St,{className:`size-2.5 sm:mr-0.5`}),(0,X.jsx)(`span`,{className:`hidden sm:inline`,children:`Default`})]}),e.mode&&e.mode!==`primary`&&(0,X.jsxs)(V,{variant:`secondary`,className:`text-[10px] px-1 sm:px-1.5 py-0`,children:[(0,X.jsx)(`span`,{className:`hidden sm:inline`,children:e.mode}),(0,X.jsx)(`span`,{className:`sm:hidden`,children:e.mode===`subagent`?`SA`:`B`})]})]}),e.description&&(0,X.jsx)(`div`,{className:`text-xs text-muted-foreground line-clamp-1`,children:e.description})]})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-0.5 sm:gap-1 shrink-0`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(I,{size:`icon-xs`,variant:`ghost`,onClick:()=>ne(e),title:`Edit preconfig`,children:(0,X.jsx)(Qe,{className:`size-3`})}),!e.isDefault&&(0,X.jsx)(I,{size:`icon-xs`,variant:`ghost`,onClick:()=>g(e.id),title:`Delete preconfig`,children:(0,X.jsx)(N,{className:`size-3`})})]})]},e.id))}),(0,X.jsx)(Vi,{open:h!==null,onOpenChange:e=>{e||g(null)},title:`Delete Preconfig`,description:`Are you sure you want to delete this preconfig? This cannot be undone.`,confirmLabel:`Delete`,variant:`destructive`,onConfirm:async()=>{if(h){v(!0);try{await e.http.preconfigs.delete(h),g(null),await M()}catch(e){o(e instanceof Error?e.message:`Failed to delete preconfig`)}finally{v(!1)}}}})]})}function Zi({open:e,onOpenChange:t,sdkClient:n}){return(0,X.jsx)(ze,{open:e,onOpenChange:t,children:(0,X.jsxs)(Fe,{className:`max-w-[calc(100vw-1rem)] sm:max-w-[800px] max-h-[calc(100dvh-2rem)] sm:max-h-[85vh]`,children:[(0,X.jsxs)(We,{children:[(0,X.jsx)(Ke,{children:`Configuration`}),(0,X.jsx)(J,{children:`Manage credentials, OAuth providers, models, prompts, and preconfigs`})]}),(0,X.jsxs)(si,{defaultValue:`providers`,className:`mt-4`,children:[(0,X.jsxs)(li,{className:`grid w-full grid-cols-5`,children:[(0,X.jsxs)(ui,{value:`providers`,children:[(0,X.jsx)(At,{className:`size-4`,"data-icon":`inline-start`}),(0,X.jsx)(`span`,{className:`hidden sm:inline`,children:`Credentials`})]}),(0,X.jsxs)(ui,{value:`oauth`,children:[(0,X.jsx)(Ft,{className:`size-4`,"data-icon":`inline-start`}),(0,X.jsx)(`span`,{className:`hidden sm:inline`,children:`OAuth`})]}),(0,X.jsxs)(ui,{value:`models`,children:[(0,X.jsx)(Tt,{className:`size-4`,"data-icon":`inline-start`}),(0,X.jsx)(`span`,{className:`hidden sm:inline`,children:`Models`})]}),(0,X.jsxs)(ui,{value:`prompts`,children:[(0,X.jsx)(ye,{className:`size-4`,"data-icon":`inline-start`}),(0,X.jsx)(`span`,{className:`hidden sm:inline`,children:`Prompts`})]}),(0,X.jsxs)(ui,{value:`preconfigs`,children:[(0,X.jsx)(Mt,{className:`size-4`,"data-icon":`inline-start`}),(0,X.jsx)(`span`,{className:`hidden sm:inline`,children:`Preconfigs`})]})]}),(0,X.jsx)(di,{value:`providers`,className:`mt-4`,children:(0,X.jsx)(Ct,{className:`h-[calc(100dvh-14rem)] sm:h-[500px]`,children:(0,X.jsx)(Ri,{sdkClient:n})})}),(0,X.jsx)(di,{value:`oauth`,className:`mt-4`,children:(0,X.jsx)(Ct,{className:`h-[calc(100dvh-14rem)] sm:h-[500px]`,children:(0,X.jsx)(zi,{sdkClient:n})})}),(0,X.jsx)(di,{value:`models`,className:`mt-4`,children:(0,X.jsx)(Ct,{className:`h-[calc(100dvh-14rem)] sm:h-[500px]`,children:(0,X.jsx)(Ki,{sdkClient:n})})}),(0,X.jsx)(di,{value:`prompts`,className:`mt-4`,children:(0,X.jsx)(Ct,{className:`h-[calc(100dvh-14rem)] sm:h-[500px]`,children:(0,X.jsx)(qi,{sdkClient:n})})}),(0,X.jsx)(di,{value:`preconfigs`,className:`mt-4`,children:(0,X.jsx)(Ct,{className:`h-[calc(100dvh-14rem)] sm:h-[500px]`,children:(0,X.jsx)(Xi,{sdkClient:n})})})]})]})})}function Qi(e){return new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}function $i({permission:e,onRevoke:t}){let n=!!e.revokedAt;return(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-3 border-b border-border last:border-0`,children:[(0,X.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,X.jsxs)(V,{variant:n?`outline`:`secondary`,children:[(0,X.jsx)(Ze,{className:`size-3`,"data-icon":`inline-start`}),e.permissionType]}),n&&(0,X.jsx)(V,{variant:`outline`,className:`text-muted-foreground`,children:`Revoked`})]}),(0,X.jsx)(`p`,{className:`text-sm font-mono truncate text-muted-foreground`,children:e.permissionKey}),(0,X.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:[`Granted `,Qi(e.grantedAt),e.revokedAt&&` • Revoked ${Qi(e.revokedAt)}`]})]}),!n&&(0,X.jsx)(I,{variant:`ghost`,size:`icon`,onClick:()=>t(e.id),className:`size-8 text-destructive hover:text-destructive`,children:(0,X.jsx)(N,{className:`size-4`})})]})}function ea({open:e,onOpenChange:t,permissions:n,onRefreshPermissions:r,onRevokePermission:i,onRevokeAllPermissions:a,workspaceName:o}){let[s,c]=(0,Y.useState)(!1),l=n.filter(e=>!e.revokedAt),u=n.filter(e=>e.revokedAt);return(0,X.jsxs)(ze,{open:e,onOpenChange:t,children:[(0,X.jsxs)(Fe,{className:`sm:max-w-[600px] max-h-[80vh]`,children:[(0,X.jsxs)(We,{children:[(0,X.jsxs)(Ke,{className:`flex items-center gap-2`,children:[(0,X.jsx)(Ze,{className:`size-5`}),`Workspace Permissions`]}),(0,X.jsx)(J,{children:o?`Manage tool permissions for ${o}`:`Manage tool permissions for this workspace`})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)($,{className:`text-sm font-medium`,children:`Always-allowed Operations`}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Tools you've approved to run without asking`})]}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(I,{variant:`outline`,size:`icon`,onClick:r,className:`size-8`,children:(0,X.jsx)(K,{className:`size-4`})}),l.length>0&&(0,X.jsxs)(I,{variant:`destructive`,size:`sm`,onClick:()=>c(!0),children:[(0,X.jsx)(N,{className:`size-4`,"data-icon":`inline-start`}),`Revoke All`]})]})]}),(0,X.jsx)(H,{}),(0,X.jsxs)(Ct,{className:`h-[350px]`,children:[l.length===0&&u.length===0&&(0,X.jsxs)(`div`,{className:`text-center py-8 text-muted-foreground text-sm`,children:[`No permissions granted yet.`,(0,X.jsx)(`br`,{}),`Approve tool requests with "Always allow" to add them here.`]}),l.length>0&&(0,X.jsxs)(`div`,{className:`mb-4`,children:[(0,X.jsxs)(`h4`,{className:`text-xs uppercase text-muted-foreground mb-2 font-medium`,children:[`Active (`,l.length,`)`]}),l.map(e=>(0,X.jsx)($i,{permission:e,onRevoke:i},e.id))]}),u.length>0&&(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`h4`,{className:`text-xs uppercase text-muted-foreground mb-2 font-medium`,children:[`Revoked (`,u.length,`)`]}),u.map(e=>(0,X.jsx)($i,{permission:e,onRevoke:i},e.id))]})]})]})]}),(0,X.jsx)(Vi,{open:s,onOpenChange:c,title:`Revoke All Permissions`,description:`This will revoke all always-allowed permissions for this workspace. You'll need to approve these tools again when they're used.`,confirmLabel:`Revoke All`,variant:`destructive`,onConfirm:()=>{a(),c(!1)}})]})}function ta({open:e,onOpenChange:t,editServer:n}){let r=h(),{addServer:i,editServer:a}=y(),[o,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(!1),[m,g]=(0,Y.useState)(null),v=n!=null;return(0,Y.useEffect)(()=>{n?(s(n.name),l(n.url),d(n.token)):(s(``),l(`localhost:8742`),d(``)),g(null),p(!1)},[n,e]),(0,X.jsx)(ze,{open:e,onOpenChange:t,children:(0,X.jsxs)(Fe,{className:`sm:max-w-[425px]`,children:[(0,X.jsxs)(We,{children:[(0,X.jsx)(Ke,{children:v?`Edit Server`:`Add Server`}),(0,X.jsx)(J,{children:v?`Update server details`:`Enter your server details`})]}),(0,X.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),g(null);let s=o.trim(),l=c.trim(),d=u.trim();if(!s){g(`Name is required`);return}if(!l){g(`Server URL is required`);return}if(!d){g(`API token is required`);return}if(!b(d)){g(`Token must be 64 hexadecimal characters`);return}let f=_(l);v?(a(n.id,{name:s,url:f,token:d}),t(!1)):(r({to:`/server/$serverId`,params:{serverId:i(s,f,d).id}}),t(!1))},children:[(0,X.jsxs)(`div`,{className:`grid gap-4 py-4`,children:[(0,X.jsxs)(`div`,{className:`grid gap-2`,children:[(0,X.jsx)($,{htmlFor:`server-name`,children:`Name`}),(0,X.jsx)(P,{id:`server-name`,value:o,onChange:e=>s(e.target.value),placeholder:`My Server`})]}),(0,X.jsxs)(`div`,{className:`grid gap-2`,children:[(0,X.jsx)($,{htmlFor:`server-url`,children:`Server URL`}),(0,X.jsx)(P,{id:`server-url`,value:c,onChange:e=>l(e.target.value),placeholder:`localhost:8742`})]}),(0,X.jsxs)(`div`,{className:`grid gap-2`,children:[(0,X.jsx)($,{htmlFor:`server-token`,children:`API Token`}),(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(P,{id:`server-token`,type:f?`text`:`password`,value:u,onChange:e=>d(e.target.value),placeholder:`64-character hex string`,className:`pr-10`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>p(!f),className:`absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-transparent`,children:f?(0,X.jsx)(Et,{className:`size-4 text-muted-foreground`}):(0,X.jsx)(be,{className:`size-4 text-muted-foreground`})})]})]}),m&&(0,X.jsx)(`p`,{className:`text-sm text-destructive`,children:m})]}),(0,X.jsxs)(Ae,{children:[(0,X.jsx)(I,{type:`button`,variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,X.jsx)(I,{type:`submit`,children:v?`Save`:`Add`})]})]})]})})}function na({workspaceId:e,path:t,sdkClient:n,enabled:r}){let[i,a]=(0,Y.useState)(null),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),u=(0,Y.useRef)(null),d=(0,Y.useCallback)(async()=>{if(!r||!e||!t||!n)return;u.current&&u.current.abort();let i=new AbortController;u.current=i,s(!0),l(null);try{a(await n.http.files.preview(e,t,{signal:i.signal})),s(!1)}catch(e){if(e instanceof Error&&e.name===`AbortError`)return;l(e instanceof Error?e.message:`Unknown error occurred`),a(null),s(!1)}},[r,e,t,n]),f=(0,Y.useCallback)(()=>{d()},[d]);return(0,Y.useEffect)(()=>(d(),()=>{u.current&&u.current.abort()}),[d]),{data:i,loading:o,error:c,reload:f}}function ra({workspaceId:e,target:t,sdkClient:n,open:r,onOpenChange:i}){let{data:a,loading:o,error:s,reload:c}=na({workspaceId:e,path:t==null?void 0:t.path,sdkClient:n,enabled:r&&!!t&&!!e});return t?(0,X.jsx)(ze,{open:r,onOpenChange:i,children:(0,X.jsxs)(Fe,{showCloseButton:!0,className:`sm:max-w-5xl w-[min(92vw,1100px)] h-[85vh] flex flex-col p-0 gap-0`,children:[(0,X.jsxs)(We,{className:`px-6 pt-5 pb-3 border-b border-border shrink-0`,children:[(0,X.jsx)(Ke,{className:`text-base font-semibold truncate`,children:t.name}),(0,X.jsx)(J,{className:`text-xs text-muted-foreground truncate`,children:t.path}),a&&(0,X.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5`,children:[(0,X.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground capitalize`,children:a.kind}),(0,X.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:`read-only`}),(0,X.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[(e=>e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`)(a.size),a.language&&` · ${a.language}`]})]})]}),(0,X.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-hidden`,children:[o&&(0,X.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,X.jsx)(U,{className:`size-5 animate-spin text-muted-foreground`})}),s&&!o&&(0,X.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full text-center p-8`,children:[(0,X.jsx)(xe,{className:`size-8 text-muted-foreground mb-3`}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground mb-3`,children:s}),(0,X.jsxs)(I,{variant:`outline`,size:`sm`,onClick:c,children:[(0,X.jsx)(K,{className:`size-3.5 mr-1.5`}),`Retry`]})]}),a&&!o&&!s&&(0,X.jsx)(ai,{preview:a})]})]})}):null}function ia({apiToken:e,sdkClient:t,permissions:n,onLogout:r,onRefreshPermissions:i,onRevokePermission:a,onRevokeAllPermissions:o,onConfigurationClose:s}){let c=z(e=>e.activeWorkspace),{showSettings:l,showMCPDialog:u,showConfiguration:d,showWorkspacePermissions:f,showAddServer:p,editServerData:m,setShowSettings:h,setShowMCPDialog:g,setShowConfiguration:_,setShowWorkspacePermissions:v,setShowAddServer:y,setEditServerData:b}=A(Z(e=>({showSettings:e.showSettings,showMCPDialog:e.showMCPDialog,showConfiguration:e.showConfiguration,showWorkspacePermissions:e.showWorkspacePermissions,showAddServer:e.showAddServer,editServerData:e.editServerData,setShowSettings:e.setShowSettings,setShowMCPDialog:e.setShowMCPDialog,setShowConfiguration:e.setShowConfiguration,setShowWorkspacePermissions:e.setShowWorkspacePermissions,setShowAddServer:e.setShowAddServer,setEditServerData:e.setEditServerData}))),{filePreviewTarget:x,closeFilePreview:S}=A(Z(e=>({filePreviewTarget:e.filePreviewTarget,closeFilePreview:e.closeFilePreview})));return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Fi,{open:l,onOpenChange:h,apiToken:e,onLogout:r,sdkClient:t}),(0,X.jsx)(Li,{open:u,onOpenChange:g,workspaceId:c==null?void 0:c.id,workspacePath:c==null?void 0:c.path,sdkClient:t}),(0,X.jsx)(ea,{open:f,onOpenChange:v,permissions:n,onRefreshPermissions:i,onRevokePermission:a,onRevokeAllPermissions:()=>{c!=null&&c.id&&o(c.id)},workspaceName:c==null?void 0:c.name}),(0,X.jsx)(Zi,{open:d,onOpenChange:e=>{_(e),e||s()},sdkClient:t}),(0,X.jsx)(ta,{open:p,onOpenChange:e=>{y(e),e||b(null)},editServer:m}),(0,X.jsx)(ra,{workspaceId:c==null?void 0:c.id,target:x,sdkClient:t,open:x!==null,onOpenChange:e=>{e||S()}})]})}function aa(){var e;let t=o(),n=c({from:`/server/$serverId`,strict:!1}).serverId,{servers:r,removeFromQuickConnectionsByWorkspace:i,quickConnections:a}=y(),s=Vn({serverId:n,activeServer:(e=r.find(e=>e.id===n))==null?null:e,navigate:e=>t.navigate({to:e.to,params:e.params}),removeFromQuickConnectionsByWorkspace:i,quickConnections:a}),u=(0,Y.useRef)(null),d=(0,Y.useRef)(null),p=(0,Y.useRef)(null),m=(0,Y.useRef)(null),h=(0,Y.useRef)(null),g=(0,Y.useRef)(null),{showFilesPanel:_,filesPanelWidth:v,sessionsPanelWidth:b}=ut(Z(e=>({showFilesPanel:e.showFilesPanel,filesPanelWidth:e.filesPanelWidth,sessionsPanelWidth:e.sessionsPanelWidth}))),S={sidebarRef:m,chatInputRef:u,terminalPanelRef:d,filesPanelRef:p,scrollToBottomRef:h,autoFollowToggleRef:g};return(0,X.jsxs)(st,{panelId:`sessions`,defaultOpen:!0,className:`flex-col`,style:{"--sidebar-width":`${b}px`,"--header-height":f()?`4.625rem`:`2.75rem`},children:[(0,X.jsx)(Ur,{}),(0,X.jsxs)(`div`,{className:`flex flex-1 min-h-0`,children:[(0,X.jsx)(x.Provider,{value:s,children:(0,X.jsx)(he.Provider,{value:S,children:(0,X.jsx)(l,{})})}),(0,X.jsx)(oi,{ref:p,sdkClient:s.sdkClient}),(0,X.jsx)(`div`,{"data-panel-gap":`files`,className:`relative bg-transparent transition-[width] duration-200 ease-linear shrink-0 ${_?``:`w-0`}`,style:{width:_?v:0}})]}),(0,X.jsx)(Qr,{sidebarRef:m,terminalPanelRef:d,filesPanelRef:p,chatInputRef:u,handleInterruptSession:s.handleInterruptSession,serverId:n,createSession:s.createSession,onToggleAutoFollow:()=>{var e;return(e=g.current)==null?void 0:e.toggle()}}),(0,X.jsx)(ia,{apiToken:s.apiToken,sdkClient:s.sdkClient,permissions:s.permissions,onLogout:s.handleLogout,onRefreshPermissions:s.refreshPermissions,onRevokePermission:s.revokePermission,onRevokeAllPermissions:s.revokeAllPermissions,onConfigurationClose:()=>t.invalidate()})]})}var oa=()=>(0,X.jsx)(Kt,{children:(0,X.jsx)(aa,{})});export{oa as component};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./jsx-runtime-D-oznMWL.js";import{d as t,i as n,n as r}from"./servers-CGl9kUR2.js";import{t as i}from"./_serverId-Bd-hxE5e.js";var a=e();function o({error:e,reset:o}){let s=t(),c=i.useParams().serverId,l=n().filter(e=>e.id!==c),u=l.length>0;return(0,a.jsx)(`div`,{className:`flex w-full items-center justify-center min-h-screen bg-background text-foreground`,children:(0,a.jsxs)(`div`,{className:`text-center space-y-4 p-8 max-w-lg w-full`,children:[(0,a.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Server Connection Error`}),(0,a.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:e instanceof Error?e.message:`An unknown error occurred`}),(0,a.jsxs)(`div`,{className:`space-y-2 pt-2`,children:[(0,a.jsx)(`button`,{onClick:()=>o(),className:`w-full px-4 py-2 rounded-md bg-primary text-primary-foreground text-sm font-medium hover:bg-primary/90`,children:`Retry`}),u&&(0,a.jsx)(`button`,{onClick:()=>{l.length>0?s.navigate({to:`/server/$serverId`,params:{serverId:l[0].id},replace:!0}):s.navigate({to:`/`,replace:!0})},className:`w-full px-4 py-2 rounded-md border border-border bg-background text-foreground text-sm font-medium hover:bg-accent`,children:`Switch Server`}),(0,a.jsx)(`button`,{onClick:()=>{c&&r(c),s.navigate({to:`/`,replace:!0})},className:`w-full px-4 py-2 rounded-md border border-destructive/50 text-destructive text-sm font-medium hover:bg-destructive/10`,children:`Remove This Server`}),(0,a.jsx)(`button`,{onClick:()=>{s.navigate({to:`/`,replace:!0})},className:`w-full px-4 py-2 rounded-md text-muted-foreground text-sm font-medium hover:text-foreground hover:bg-accent`,children:`Go to Home`})]})]})})}export{o as errorComponent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./SessionContent-DAoBLNGO.js";var t=e;export{t as component};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./SessionContent-DAoBLNGO.js";var t=e;export{t as component};
|