@jean2/client 1.0.0 → 1.0.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.
Files changed (33) hide show
  1. package/dist/assets/SessionContent-w-YQzt9T.js +9 -0
  2. package/dist/assets/{SessionMenuButton-CfDBJE0r.js → SessionMenuButton-Bg83zT6G.js} +1 -1
  3. package/dist/assets/{ThemeProvider-DWTAR83t.js → ThemeProvider-Da23NPAS.js} +1 -1
  4. package/dist/assets/_serverId-B4Rjk4iQ.js +12 -0
  5. package/dist/assets/{_serverId-D7fl2Don.js → _serverId-BwsJG6SV.js} +1 -1
  6. package/dist/assets/{_serverId-Z_onznBB.js → _serverId-COhNW61b.js} +2 -2
  7. package/dist/assets/_sessionId-CMkepspM.js +1 -0
  8. package/dist/assets/_sessionId-xZ5q7S0b.js +1 -0
  9. package/dist/assets/alert-qqwNRgnw.js +31 -0
  10. package/dist/assets/badge-CwZd07eA.js +45 -0
  11. package/dist/assets/{confirmation-dialog-CcyiA31R.js → confirmation-dialog-DGPNPL5O.js} +1 -1
  12. package/dist/assets/index-BDTQdmk9.js +10 -0
  13. package/dist/assets/index-DF4q2PgJ.css +2 -0
  14. package/dist/assets/overview-CEkUAF73.js +1 -0
  15. package/dist/assets/{platform-Be8afd__.js → platform-5d-ZQG2e.js} +1 -1
  16. package/dist/assets/{popover-DDHwMxwz.js → popover-BaZzl6-v.js} +1 -1
  17. package/dist/assets/{scroll-area-C-KPh_XU.js → scroll-area-16Gq00WS.js} +1 -1
  18. package/dist/assets/{sidebar-BNTVPq06.js → sidebar-DmGZgZwK.js} +1 -1
  19. package/dist/assets/src-BiLzKNfl.js +1 -0
  20. package/dist/assets/workspace-B-9b8A58.js +1 -0
  21. package/dist/index.html +6 -6
  22. package/package.json +1 -1
  23. package/dist/assets/SessionContent-6BakydNj.js +0 -9
  24. package/dist/assets/_serverId-B47rZ3cs.js +0 -12
  25. package/dist/assets/_sessionId-CJ6VLUC_.js +0 -1
  26. package/dist/assets/_sessionId-CMQvBPmZ.js +0 -1
  27. package/dist/assets/alert-DjGCaOkT.js +0 -31
  28. package/dist/assets/badge-CxHTOx9D.js +0 -45
  29. package/dist/assets/index-CGdDNSI7.js +0 -10
  30. package/dist/assets/index-QW5PCSUz.css +0 -2
  31. package/dist/assets/overview-GjLiY4UT.js +0 -1
  32. package/dist/assets/src-9dJwbSJY.js +0 -1
  33. package/dist/assets/workspace-DVaW6FBq.js +0 -1
@@ -0,0 +1 @@
1
+ import{i as e,r as t}from"./compiler-runtime-DZXZ41-q.js";var n=e((e=>{var n=t();function r(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function i(){}var a={d:{f:i,r:function(){throw Error(r(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},o=Symbol.for(`react.portal`);function s(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var c=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,e.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(r(299));return s(e,t,null,n)},e.flushSync=function(e){var t=c.T,n=a.p;try{if(c.T=null,a.p=2,e)return e()}finally{c.T=t,a.p=n,a.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,a.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&a.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin),i=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?a.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:i,fetchPriority:o}):n===`script`&&a.d.X(e,{crossOrigin:r,integrity:i,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=l(t.as,t.crossOrigin);a.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t==null&&a.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin);a.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=l(t.as,t.crossOrigin);a.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else a.d.m(e)},e.requestFormReset=function(e){a.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return c.H.useFormState(e,t,n)},e.useFormStatus=function(){return c.H.useHostTransitionStatus()},e.version=`19.2.4`})),r=e(((e,t)=>{function r(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(r)}catch(e){console.error(e)}}r(),t.exports=n()}));function i(e){"@babel/helpers - typeof";return i=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},i(e)}function a(e,t){if(i(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(i(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function o(e){var t=a(e,`string`);return i(t)==`symbol`?t:t+``}function s(e,t,n){return(t=o(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var c=class{constructor(){s(this,`listeners`,new Map)}on(e,t){let n=this.listeners.get(e);return n||(n=new Set,this.listeners.set(e,n)),n.add(t),this}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};return this.on(e,n)}off(e,t){let n=this.listeners.get(e);return n&&(n.delete(t),n.size===0&&this.listeners.delete(e)),this}emit(e,...t){let n=this.listeners.get(e);if(!n||n.size===0)return!1;for(let r of n)try{r(...t)}catch(t){console.error(`Error in event handler for "${e}":`,t)}return!0}removeAllListeners(e){return e===void 0?this.listeners.clear():this.listeners.delete(e),this}listenerCount(e){var t,n;return(t=(n=this.listeners.get(e))==null?void 0:n.size)==null?0:t}eventNames(){return Array.from(this.listeners.keys())}};function l(e,t){switch(t.type){case`client.registered`:e.emit(`client.registered`,t.client,t.connectionId,t.serverTime);break;case`client.rejected`:e.emit(`client.rejected`,t.code,t.message);break;case`session.created`:e.emit(`session.created`,t.session);break;case`session.resumed`:e.emit(`session.resumed`,t.session,t.messages,t.usage,t.isRunning,t.control);break;case`session.control.updated`:e.emit(`session.control.updated`,t.control,t.reason);break;case`session.action_rejected`:e.emit(`session.action_rejected`,t.sessionId,t.action,t.code,t.message,t.control);break;case`session.closed`:e.emit(`session.closed`,t.sessionId);break;case`session.reopened`:e.emit(`session.reopened`,t.session);break;case`session.deleted`:e.emit(`session.deleted`,t.sessionId);break;case`session.updated`:e.emit(`session.updated`,t.session);break;case`session.renamed`:e.emit(`session.renamed`,t.session);break;case`session.interrupted`:e.emit(`session.interrupted`,t.sessionId,t.result);break;case`session.reverted`:e.emit(`session.reverted`,t.sessionId,t.revertedTo,t.removed);break;case`session.forked`:e.emit(`session.forked`,t.originalSessionId,t.forkedSession,t.messages);break;case`session.state`:e.emit(`session.state`,t.sessionId,t.messages);break;case`message.created`:e.emit(`message.created`,t.message);break;case`message.updated`:e.emit(`message.updated`,t.message);break;case`part.created`:e.emit(`part.created`,t.sessionId,t.part);break;case`part.updated`:e.emit(`part.updated`,t.sessionId,t.part);break;case`part.append`:e.emit(`part.append`,t.sessionId,t.partId,t.field,t.delta);break;case`chat.usage`:e.emit(`chat.usage`,t.sessionId,t.usage,t.model,t.variant);break;case`compaction.complete`:e.emit(`compaction.complete`,t.sessionId,t.tokensUsed);break;case`permission.list`:e.emit(`permission.list`,t.workspaceId,t.grants);break;case`permission.revoked`:e.emit(`permission.revoked`,t.grantId);break;case`permission.all_revoked`:e.emit(`permission.all_revoked`,t.workspaceId,t.count);break;case`queue.list`:e.emit(`queue.list`,t.sessionId,t.messages);break;case`queue.added`:e.emit(`queue.added`,t.sessionId,t.message);break;case`queue.removed`:e.emit(`queue.removed`,t.sessionId,t.queueId);break;case`queue.sending`:e.emit(`queue.sending`,t.sessionId,t.queueId);break;case`provider.status`:e.emit(`provider.status`,t.provider,t.connected,t.authorizationUrl,t.error);break;case`provider.connected`:e.emit(`provider.connected`,t.provider,t.connected,t.connectedAt,t.accountId);break;case`ask.request`:e.emit(`ask.request`,t.sessionId,t.toolCallId,t.toolName,t.ask,t.requestId,t.authority);break;case`ask.response_rejected`:e.emit(`ask.response_rejected`,t.sessionId,t.toolCallId,t.requestId,t.code,t.message);break;case`ask.timeout`:e.emit(`ask.timeout`,t.sessionId,t.toolCallId,t.requestId);break;case`ask.pending_sync`:e.emit(`ask.pending_sync`,t.sessionId,t.requests);break;case`error`:e.emit(`error`,t.code,t.message);break;case`error.rate_limit`:e.emit(`error.rate_limit`,t.code,t.message,t.retryAfterMs),e.emit(`error`,t.code,t.message);break;case`error.server`:e.emit(`error.server`,t.code,t.message,t.retryAfterMs),e.emit(`error`,t.code,t.message);break;case`error.timeout`:e.emit(`error.timeout`,t.code,t.message,t.retryAfterMs),e.emit(`error`,t.code,t.message);break;case`error.auth`:e.emit(`error.auth`,t.code,t.message),e.emit(`error`,t.code,t.message);break;case`error.invalid_request`:e.emit(`error.invalid_request`,t.code,t.message),e.emit(`error`,t.code,t.message);break;case`error.context_overflow`:e.emit(`error.context_overflow`,t.code,t.message),e.emit(`error`,t.code,t.message);break;case`ping`:return;default:console.warn(`Unknown server message type: ${t.type}`);break}e.emit(`*`,{source:`server`,type:t.type,raw:t})}var u=class extends Error{constructor(e,t){super(e,t),this.name=`Jean2Error`}},d=class extends u{constructor(e,t){super(e,t),this.name=`ConnectionError`}},f=class extends u{constructor(e,t){super(e,t),this.name=`AuthError`}},p=class extends u{constructor(e,t,n){super(e,n),s(this,`retryAfterMs`,void 0),this.name=`RateLimitError`,this.retryAfterMs=t}},m=class extends u{constructor(e,t,n){super(e,n),s(this,`statusCode`,void 0),this.name=`ServerError`,this.statusCode=t}},h=class extends u{constructor(e,t=400,n){super(e,n),s(this,`statusCode`,void 0),this.name=`ValidationError`,this.statusCode=t}},g=class e{constructor(e){s(this,`_ws`,null),s(this,`config`,void 0),s(this,`_state`,`disconnected`),s(this,`onOpen`,null),s(this,`onMessage`,null),s(this,`onClose`,null),s(this,`onError`,null),s(this,`heartbeatTimer`,null),s(this,`missedHeartbeats`,0),this.config=e}async connect(){return new Promise((e,t)=>{var n,r;let i=(n=this.config.wsConstructor)==null?globalThis.WebSocket:n,a=this.buildWsUrl();this._state=`connecting`,this._ws=new i(a);let o=(r=this.config.connectionTimeout)==null?1e4:r,s=setTimeout(()=>{var e;(e=this._ws)==null||e.close(1e3,`Connection timeout`),t(new d(`Connection timeout (${o}ms)`))},o);this._ws.onopen=()=>{var t;clearTimeout(s),this._state=`connected`,this.startHeartbeatMonitor(),(t=this.onOpen)==null||t.call(this),e()},this._ws.onmessage=e=>{try{var t;let n=JSON.parse(String(e.data));if(n.type===`ping`){this.resetHeartbeat(),this.send({type:`pong`});return}this.resetHeartbeat(),(t=this.onMessage)==null||t.call(this,n)}catch(e){var n;let t=e instanceof Error?e.message:String(e);(n=this.onError)==null||n.call(this,Error(`Failed to parse WebSocket message: ${t}`))}},this._ws.onclose=e=>{var n;clearTimeout(s),this.stopHeartbeatMonitor(),this._state=`disconnected`,this._ws!==null&&t(new d(`Connection closed before open: code=${e.code}, reason=${e.reason}`)),this._ws=null,(n=this.onClose)==null||n.call(this,e.code,e.reason,e.wasClean)},this._ws.onerror=()=>{var e;clearTimeout(s),(e=this.onError)==null||e.call(this,Error(`WebSocket error`)),t(new d(`WebSocket error`))}})}send(e){if(!this._ws||this._ws.readyState!==WebSocket.OPEN)throw new d(`WebSocket is not connected`);this._ws.send(JSON.stringify(e))}async disconnect(){if(!this._ws)return;let e=this._ws;if(e.readyState===WebSocket.CLOSING||e.readyState===WebSocket.CLOSED){this._state=`disconnected`,this._ws=null;return}return new Promise(t=>{this._state=`disconnecting`;let n=()=>{e.removeEventListener(`close`,n),t()};e.addEventListener(`close`,n),e.close(1e3,`Client disconnect`)})}dispose(){this.stopHeartbeatMonitor(),this.onOpen=null,this.onMessage=null,this.onClose=null,this.onError=null,this._ws&&(this._ws.onopen=null,this._ws.onmessage=null,this._ws.onclose=null,this._ws.onerror=null,this._ws.close(),this._ws=null),this._state=`disconnected`}get connected(){return this._state===`connected`}get readyState(){var e,t;return(e=(t=this._ws)==null?void 0:t.readyState)==null?WebSocket.CLOSED:e}get ws(){return this._ws}resetHeartbeat(){this.missedHeartbeats=0}startHeartbeatMonitor(){this.stopHeartbeatMonitor(),this.missedHeartbeats=0,this.heartbeatTimer=setInterval(()=>{this.missedHeartbeats++,this.missedHeartbeats>=4&&(this.stopHeartbeatMonitor(),this._ws&&this._ws.close(1e3,`Heartbeat timeout`))},e.HEARTBEAT_TIMEOUT_MS)}stopHeartbeatMonitor(){this.heartbeatTimer!==null&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null)}buildWsUrl(){return`${this.config.url.startsWith(`https`)?`wss`:`ws`}://${this.config.url.replace(/^https?:\/\//,``)}/ws?token=${encodeURIComponent(this.config.token)}`}};s(g,`HEARTBEAT_TIMEOUT_MS`,12e4);var _=class{constructor(e){s(this,`baseUrl`,void 0),s(this,`token`,void 0);let t=e.apiBase||`/api`;this.baseUrl=`${e.url.startsWith(`https`)?`https`:`http`}://${e.url.replace(/^https?:\/\//,``)}${t}`,this.token=e.token}async request(e,t={}){let{method:n=`GET`,body:r,headers:i={},signal:a,params:o}=t,s=`${this.baseUrl}${e}`;if(o){let e=new URLSearchParams(o);s+=`?${e.toString()}`}let c={...i};r!==void 0&&!(r instanceof FormData)&&(c[`Content-Type`]=`application/json`),c.Authorization=`Bearer ${this.token}`;let l=await fetch(s,{method:n,headers:c,body:r instanceof FormData?r:r?JSON.stringify(r):void 0,signal:a});if(l.status===401)throw new f(`Authentication failed. Your token may be invalid or expired.`);if(l.status===429){let e=l.headers.get(`Retry-After`);throw new p(`Too many requests`,e?parseInt(e,10)*1e3:void 0)}if(!l.ok){let e=`HTTP ${l.status}`;try{let t=await l.json();t.message&&(e=t.message)}catch{}throw l.status>=500?new m(e,l.status):new h(e,l.status)}let u=l.headers.get(`Content-Type`);return u!=null&&u.includes(`application/json`)?l.json():l}get(e,t){return this.request(e,{...t,method:`GET`})}post(e,t,n){return this.request(e,{...n,method:`POST`,body:t})}put(e,t,n){return this.request(e,{...n,method:`PUT`,body:t})}patch(e,t,n){return this.request(e,{...n,method:`PATCH`,body:t})}delete(e,t){return this.request(e,{...t,method:`DELETE`})}static async verifyToken(e,t){let n=e.startsWith(`https`)?`https`:`http`,r=e.replace(/^https?:\/\//,``);try{return(await fetch(`${n}://${r}/api/auth/verify`,{headers:{Authorization:`Bearer ${t}`}})).status===200}catch(e){throw new d(`Failed to reach server for auth verification: ${e instanceof Error?e.message:String(e)}`)}}},v=class{constructor(e){this.send=e}create(e){this.send({type:`session.create`,...e})}resume(e){this.send({type:`session.resume`,sessionId:e})}close(e){this.send({type:`session.close`,sessionId:e})}update(e,t){this.send({type:`session.update`,sessionId:e,...t})}updateModel(e,t){this.send({type:`session.update_model`,sessionId:e,...t})}reopen(e){this.send({type:`session.reopen`,sessionId:e})}delete(e){this.send({type:`session.delete`,sessionId:e})}rename(e,t){this.send({type:`session.rename`,sessionId:e,title:t})}compact(e){this.send({type:`session.compact`,sessionId:e})}revert(e,t){this.send({type:`session.revert`,sessionId:e,messageId:t})}fork(e,t,n){this.send({type:`session.fork`,sessionId:e,messageId:t,title:n})}interrupt(e,t){this.send({type:`session.interrupt`,sessionId:e,reason:t})}},y=class{constructor(e){this._send=e}send(e,t,n){let r={type:`chat.message`,sessionId:e,content:t};n!=null&&n.attachments&&n.attachments.length>0&&(r.attachments=n.attachments),this._send(r)}},b=class{constructor(e){this.send=e}list(e,t){this.send({type:`permission.list`,workspaceId:e,includeRevoked:t})}revoke(e){this.send({type:`permission.revoke`,grantId:e})}revokeAll(e){this.send({type:`permission.revoke_all`,workspaceId:e})}},x=class{constructor(e){this.send=e}add(e,t,n){let r=n;this.send({type:`queue.add`,sessionId:e,content:t,...r&&r.length>0?{attachments:r}:{}})}remove(e){this.send({type:`queue.remove`,queueId:e})}},S=class{constructor(e){this.send=e}connect(e){this.send({type:`provider.connect`,provider:e})}disconnect(e){this.send({type:`provider.disconnect`,provider:e})}},C=class{constructor(e){s(this,`send`,void 0),this.send=e}claim(e){this.send({type:`session.control.claim`,sessionId:e})}release(e){this.send({type:`session.control.release`,sessionId:e})}requestTakeover(e){this.send({type:`session.control.request_takeover`,sessionId:e})}respondTakeover(e,t,n){this.send({type:`session.control.respond_takeover`,sessionId:e,requesterClientId:t,decision:n})}},w={INPUT:1,RESIZE:2,CLOSE:3,OUTPUT:4,EXIT:5,ERROR:6,INIT_ACK:7,TITLE:8};function T(e,t){let n=new Uint8Array(1+t.length);return n[0]=e,n.set(t,1),n}var E=class extends c{constructor(e,t,n){super(),s(this,`ws`,void 0),s(this,`_session`,void 0),s(this,`_closed`,!1),s(this,`_disposed`,!1),s(this,`_preInitOutput`,[]),this.ws=e,this._session=t,n&&(this._preInitOutput=n),this.ws.binaryType=`arraybuffer`,this.ws.onmessage=this.handleMessage.bind(this),this.ws.onclose=this.handleClose.bind(this),this.ws.onerror=this.handleError.bind(this)}on(e,t){let n=super.on(e,t);return e===`output`&&this.flushPreInitOutput(),n}flushPreInitOutput(){if(this._preInitOutput.length===0)return;let e=this._preInitOutput;this._preInitOutput=[];for(let t of e){if(this._closed)break;this.emit(`output`,t)}}handleMessage(e){if(this._closed)return;let t=new Uint8Array(e.data);if(t.length<1)return;let n=t[0],r=t.slice(1);switch(n){case w.OUTPUT:this.emit(`output`,r);break;case w.EXIT:{let e=0;if(r.length>0)try{let t=JSON.parse(new TextDecoder().decode(r));e=typeof t.exitCode==`number`?t.exitCode:0}catch{e=0}this._session={...this._session,status:`exited`,exitCode:e},this.emit(`exit`,e);break}case w.TITLE:{let e=`Terminal`;if(r.length>0)try{let t=JSON.parse(new TextDecoder().decode(r));e=typeof t.title==`string`?t.title:`Terminal`}catch{e=`Terminal`}this._session={...this._session,title:e},this.emit(`title`,e);break}case w.ERROR:{let e=new TextDecoder().decode(r),t=Error(e||`Terminal error`);this.emit(`error`,t);break}case w.CLOSE:this.doClose();break;default:break}}handleClose(e){this._closed||(this._closed=!0,this.emit(`close`))}handleError(){if(!this._closed){let e=Error(`WebSocket error`);this.emit(`error`,e)}}doClose(){if(!this._closed){this._closed=!0;try{this.ws.close(1e3,`Client close`)}catch{}this.emit(`close`),this.cleanupHandlers()}}cleanupHandlers(){this._disposed||(this._disposed=!0,this.ws.onmessage=null,this.ws.onclose=null,this.ws.onerror=null)}dispatchFrame(e){this.handleMessage({data:e.buffer})}write(e){if(this._closed||this.ws.readyState!==WebSocket.OPEN)return;let t;t=typeof e==`string`?new TextEncoder().encode(e):e,this.ws.send(T(w.INPUT,t))}resize(e,t){if(this._closed||this.ws.readyState!==WebSocket.OPEN)return;let n=JSON.stringify({cols:e,rows:t}),r=new TextEncoder().encode(n);this.ws.send(T(w.RESIZE,r))}close(){this._closed||(this.ws.readyState===WebSocket.OPEN&&this.ws.send(T(w.CLOSE,new Uint8Array)),this.doClose())}dispose(){if(this.cleanupHandlers(),!this._closed){this._closed=!0;try{this.ws.close(1e3,`Disposed`)}catch{}}this.removeAllListeners()}get session(){return this._session}get sessionId(){return this._session.sessionId}get pid(){return this._session.pid}get cwd(){return this._session.cwd}get shell(){return this._session.shell}get cols(){return this._session.cols}get rows(){return this._session.rows}get title(){return this._session.title}get status(){return this._session.status}get exitCode(){return this._session.exitCode}get isReconnect(){return this._session.isReconnect}get closed(){return this._closed}},D=class extends c{constructor(e){super(),s(this,`ws`,void 0),s(this,`_closed`,!1),s(this,`_disposed`,!1),this.ws=e,this.ws.onmessage=this.handleMessage.bind(this),this.ws.onclose=this.handleClose.bind(this),this.ws.onerror=this.handleError.bind(this)}handleMessage(e){if(this._closed)return;let t=e.data;if(typeof t!=`string`)return;let n;try{n=JSON.parse(t)}catch{return}switch(n.type){case`snapshot`:this.emit(`snapshot`,n.sessions);break;case`created`:this.emit(`created`,n.session);break;case`destroyed`:this.emit(`destroyed`,n.sessionId);break;case`exited`:this.emit(`exited`,n.sessionId,n.exitCode);break;case`title_changed`:this.emit(`title_changed`,n.sessionId,n.title);break;case`status_changed`:this.emit(`status_changed`,n.sessionId,n.status);break}}handleClose(e){this._closed||(this._closed=!0,this.emit(`close`))}handleError(){if(!this._closed){let e=Error(`WebSocket error`);this.emit(`error`,e)}}close(){if(!this._closed){this._closed=!0;try{this.ws.close(1e3,`Client close`)}catch{}this.cleanupHandlers()}}dispose(){if(this.cleanupHandlers(),this.ws.readyState===WebSocket.OPEN||this.ws.readyState===WebSocket.CONNECTING)try{this.ws.close(1e3,`Disposed`)}catch{}this._closed||(this._closed=!0,this.emit(`close`)),this.removeAllListeners()}cleanupHandlers(){this._disposed||(this._disposed=!0,this.ws.onmessage=null,this.ws.onclose=null,this.ws.onerror=null)}get closed(){return this._closed}},O=class{constructor(e){s(this,`config`,void 0),this.config={connectTimeout:1e4,...e}}async connect(e){var t;let n=(t=this.config.wsConstructor)==null?globalThis.WebSocket:t,r=this.config.url.startsWith(`https`)?`wss`:`ws`,i=this.config.url.replace(/^https?:\/\//,``),a=new URLSearchParams({token:this.config.token,cwd:e.cwd,workspaceId:e.workspaceId});e.shell&&a.set(`shell`,e.shell),e.sessionId&&a.set(`sessionId`,e.sessionId);let o=`${r}://${i}/ws/terminal?${a.toString()}`;return new Promise((e,t)=>{var r;let i=new n(o);i.binaryType=`arraybuffer`;let a=(r=this.config.connectTimeout)==null?1e4:r,s=!1,c=t=>{s||(s=!0,clearTimeout(u),e(t))},l=e=>{s||(s=!0,clearTimeout(u),t(e))},u=setTimeout(()=>{i.close(),l(new d(`Terminal connection timeout (${a}ms)`))},a);i.onopen=()=>{};let f=[];i.onmessage=e=>{let t=new Uint8Array(e.data);if(t.length<1)return;let n=t[0],r=t.slice(1);if(n===w.INIT_ACK)try{let e=new E(i,JSON.parse(new TextDecoder().decode(r)),f.filter(e=>e.opcode===w.OUTPUT).map(e=>e.data));for(let t of f)t.opcode!==w.OUTPUT&&e.dispatchFrame(t.data);c(e)}catch(e){i.close(),l(new d(`Failed to parse terminal init: ${e instanceof Error?e.message:String(e)}`))}else if(n===w.ERROR){i.close();let e=`Terminal connection failed`;try{e=JSON.parse(new TextDecoder().decode(r)).message||e}catch{}l(new d(e))}else f.push({opcode:n,data:t})},i.onerror=()=>{i.close(),l(new d(`Terminal WebSocket error`))},i.onclose=()=>{l(new d(`Terminal connection closed before init`))}})}async subscribeEvents(e){var t;let n=(t=this.config.wsConstructor)==null?globalThis.WebSocket:t,r=`${this.config.url.startsWith(`https`)?`wss`:`ws`}://${this.config.url.replace(/^https?:\/\//,``)}/ws/terminal/events?${new URLSearchParams({token:this.config.token,workspaceId:e}).toString()}`;return new Promise((e,t)=>{var i;let a=new n(r),o=(i=this.config.connectTimeout)==null?1e4:i,s=!1,c=t=>{s||(s=!0,clearTimeout(u),e(t))},l=e=>{s||(s=!0,clearTimeout(u),t(e))},u=setTimeout(()=>{a.close(),l(new d(`Terminal events subscription timeout (${o}ms)`))},o);a.onopen=()=>{};let f=null;a.onmessage=e=>{if(s)return;let t=e.data;if(typeof t!=`string`)return;let n;try{n=JSON.parse(t)}catch{return}n.type===`snapshot`&&(f||(f=new D(a)),c({conn:f,initialSessions:n.sessions}))},a.onerror=()=>{a.close(),l(new d(`Terminal events WebSocket error`))},a.onclose=()=>{s||l(new d(`Terminal events connection closed before snapshot`))}})}},k=class{constructor(e){this.http=e}async list(e){return this.http.get(`/sessions`,{params:e!=null&&e.status?{status:e.status}:void 0,signal:e==null?void 0:e.signal})}async create(e){let{signal:t,...n}=e==null?{}:e;return this.http.post(`/sessions`,n,{signal:t})}async get(e,t){return this.http.get(`/sessions/${encodeURIComponent(e)}`,{signal:t==null?void 0:t.signal})}async update(e,t,n){return this.http.put(`/sessions/${encodeURIComponent(e)}`,t,{signal:n==null?void 0:n.signal})}async delete(e,t){return this.http.delete(`/sessions/${encodeURIComponent(e)}`,{signal:t==null?void 0:t.signal})}async listMessages(e,t){return this.http.get(`/sessions/${encodeURIComponent(e)}/messages`,{signal:t==null?void 0:t.signal})}async listGrouped(e){let t={workspaceIds:e.workspaceIds.join(`,`)};return e.status&&(t.status=e.status),e.rootOnly&&(t.rootOnly=`true`),this.http.get(`/sessions/grouped`,{params:t,signal:e.signal})}async listByWorkspace(e){let t={};return e.status&&(t.status=e.status),e.rootOnly&&(t.rootOnly=`true`),this.http.get(`/workspaces/${encodeURIComponent(e.workspaceId)}/sessions`,{params:t,signal:e.signal})}},A=class{constructor(e){this.http=e}async list(e){return this.http.get(`/workspaces`,{signal:e==null?void 0:e.signal})}async create(e){let{signal:t,...n}=e==null?{}:e;return this.http.post(`/workspaces`,n,{signal:t})}async get(e,t){return this.http.get(`/workspaces/${encodeURIComponent(e)}`,{signal:t==null?void 0:t.signal})}async update(e,t,n){return this.http.patch(`/workspaces/${encodeURIComponent(e)}`,t,{signal:n==null?void 0:n.signal})}async delete(e,t){return this.http.delete(`/workspaces/${encodeURIComponent(e)}`,{signal:t==null?void 0:t.signal})}async listSessions(e,t){return this.http.get(`/workspaces/${encodeURIComponent(e)}/sessions`,{signal:t==null?void 0:t.signal})}},j=class{constructor(e){this.http=e}async list(e){return this.http.get(`/models`,{signal:e==null?void 0:e.signal})}},M=class{constructor(e){this.http=e}async list(e){return this.http.get(`/tools`,{signal:e==null?void 0:e.signal})}async get(e,t){return this.http.get(`/tools/${encodeURIComponent(e)}`,{signal:t==null?void 0:t.signal})}async listEnvVars(e){return this.http.get(`/tools/env`,{signal:e==null?void 0:e.signal})}async setEnvVar(e,t,n){return this.http.put(`/tools/env/${encodeURIComponent(e)}`,t,{signal:n==null?void 0:n.signal})}async clearEnvVar(e,t){return this.http.delete(`/tools/env/${encodeURIComponent(e)}`,{signal:t==null?void 0:t.signal})}},N=class{constructor(e){this.http=e}async list(e){return this.http.get(`/providers`,{signal:e==null?void 0:e.signal})}async getStatus(e,t){return this.http.get(`/providers/${encodeURIComponent(e)}/status`,{signal:t==null?void 0:t.signal})}async connect(e,t){return this.http.post(`/providers/${encodeURIComponent(e)}/connect`,void 0,{signal:t==null?void 0:t.signal})}async disconnect(e,t){return this.http.delete(`/providers/${encodeURIComponent(e)}`,{signal:t==null?void 0:t.signal})}async listCredentials(e){return this.http.get(`/config/providers`,{signal:e==null?void 0:e.signal})}async setCredential(e,t,n){return this.http.put(`/config/providers/${encodeURIComponent(e)}`,t,{signal:n==null?void 0:n.signal})}async clearCredential(e,t){return this.http.delete(`/config/providers/${encodeURIComponent(e)}`,{signal:t==null?void 0:t.signal})}},P=class{constructor(e){this.http=e}async list(e){return this.http.get(`/preconfigs`,{signal:e==null?void 0:e.signal})}async create(e){let{signal:t,...n}=e==null?{}:e;return this.http.post(`/preconfigs`,n,{signal:t})}async get(e,t){return this.http.get(`/preconfigs/${encodeURIComponent(e)}`,{signal:t==null?void 0:t.signal})}async update(e,t,n){return this.http.put(`/preconfigs/${encodeURIComponent(e)}`,t,{signal:n==null?void 0:n.signal})}async delete(e,t){return this.http.delete(`/preconfigs/${encodeURIComponent(e)}`,{signal:t==null?void 0:t.signal})}},F=class{constructor(e){this.http=e}async list(e){return this.http.get(`/prompts`,{signal:e==null?void 0:e.signal})}},I=class{constructor(e){this.http=e}async browse(e,t,n){let r={};return t!==void 0&&(r.path=t),(n==null?void 0:n.showHidden)!==void 0&&(r.showHidden=String(n.showHidden)),(n==null?void 0:n.limit)!==void 0&&(r.limit=String(n.limit)),this.http.get(`/workspaces/${encodeURIComponent(e)}/files`,{params:Object.keys(r).length>0?r:void 0,signal:n==null?void 0:n.signal})}async search(e,t,n){let r={search:t};return(n==null?void 0:n.limit)!==void 0&&(r.limit=String(n.limit)),(n==null?void 0:n.showHidden)!==void 0&&(r.showHidden=String(n.showHidden)),this.http.get(`/workspaces/${encodeURIComponent(e)}/files`,{params:r,signal:n==null?void 0:n.signal})}async preview(e,t,n){return this.http.get(`/workspaces/${encodeURIComponent(e)}/file-preview`,{params:{path:t},signal:n==null?void 0:n.signal})}async browseFs(e,t){return this.http.get(`/fs/browse`,{params:e===void 0?void 0:{path:e},signal:t==null?void 0:t.signal})}async parent(e,t){return this.http.get(`/fs/parent`,{params:{path:e},signal:t==null?void 0:t.signal})}async drives(e){return this.http.get(`/fs/drives`,{signal:e==null?void 0:e.signal})}},L=class{constructor(e){this.http=e}async list(e,t){return this.http.get(`/sessions/${encodeURIComponent(e)}/attachments`,{signal:t==null?void 0:t.signal})}async upload(e,t,n){let r=new FormData;r.append(`file`,t);let{signal:i}=n==null?{}:n;return this.http.post(`/sessions/${encodeURIComponent(e)}/attachments`,r,{signal:i})}getUrl(e,t,n){return`/api/sessions/${encodeURIComponent(e)}/attachments/${encodeURIComponent(t)}/content?key=${encodeURIComponent(n)}`}},R=class{constructor(e){this.http=e}async list(e,t){return this.http.get(`/workspaces/${encodeURIComponent(e)}/terminals`,{signal:t==null?void 0:t.signal})}async create(e,t){let{signal:n,body:r}=t==null?{}:t;return this.http.post(`/workspaces/${encodeURIComponent(e)}/terminals`,r==null?{}:r,{signal:n})}async get(e,t,n){return this.http.get(`/workspaces/${encodeURIComponent(e)}/terminals/${encodeURIComponent(t)}`,{signal:n==null?void 0:n.signal})}async delete(e,t,n){return this.http.delete(`/workspaces/${encodeURIComponent(e)}/terminals/${encodeURIComponent(t)}`,{signal:n==null?void 0:n.signal})}},z=class{constructor(e){this.http=e}async getStatus(e,t){return this.http.get(`/workspaces/${encodeURIComponent(e)}/mcp/status`,{signal:t==null?void 0:t.signal})}async connect(e,t,n){let{signal:r}=n==null?{}:n;return this.http.post(`/workspaces/${encodeURIComponent(e)}/mcp/connect`,{name:t},{signal:r})}async disconnect(e,t,n){let{signal:r}=n==null?{}:n;return this.http.post(`/workspaces/${encodeURIComponent(e)}/mcp/disconnect`,{name:t},{signal:r})}async startAuth(e,t,n){let{signal:r}=n==null?{}:n;return this.http.post(`/workspaces/${encodeURIComponent(e)}/mcp/auth`,{name:t},{signal:r})}async finishAuth(e,t,n,r){let{signal:i}=r==null?{}:r;return this.http.post(`/workspaces/${encodeURIComponent(e)}/mcp/auth/callback`,{name:t,code:n},{signal:i})}},B=class{constructor(e){this.http=e}async get(e){return this.http.get(`/config/models`,{signal:e==null?void 0:e.signal})}async createProvider(e,t){return this.http.post(`/config/models/providers`,e,{signal:t==null?void 0:t.signal})}async updateProvider(e,t,n){return this.http.put(`/config/models/providers/${encodeURIComponent(e)}`,t,{signal:n==null?void 0:n.signal})}async deleteProvider(e,t){return this.http.delete(`/config/models/providers/${encodeURIComponent(e)}`,{signal:t==null?void 0:t.signal})}async createModel(e,t,n){return this.http.post(`/config/models/providers/${encodeURIComponent(e)}/models`,t,{signal:n==null?void 0:n.signal})}async updateModel(e,t,n,r){return this.http.put(`/config/models/providers/${encodeURIComponent(e)}/models/${encodeURIComponent(t)}`,n,{signal:r==null?void 0:r.signal})}async deleteModel(e,t,n){return this.http.delete(`/config/models/providers/${encodeURIComponent(e)}/models/${encodeURIComponent(t)}`,{signal:n==null?void 0:n.signal})}async setDefaults(e,t){return this.http.put(`/config/models/defaults`,e,{signal:t==null?void 0:t.signal})}},V=class{constructor(e){this.http=e}async list(e){return this.http.get(`/config/prompts`,{signal:e==null?void 0:e.signal})}async get(e,t){return this.http.get(`/config/prompts/${encodeURIComponent(e)}`,{signal:t==null?void 0:t.signal})}async create(e,t){return this.http.post(`/config/prompts`,e,{signal:t==null?void 0:t.signal})}async update(e,t,n){return this.http.put(`/config/prompts/${encodeURIComponent(e)}`,t,{signal:n==null?void 0:n.signal})}async delete(e,t){return this.http.delete(`/config/prompts/${encodeURIComponent(e)}`,{signal:t==null?void 0:t.signal})}},H=class{constructor(e){s(this,`models`,void 0),s(this,`prompts`,void 0),this.models=new B(e),this.prompts=new V(e)}},U=class{constructor(e){s(this,`sessions`,void 0),s(this,`workspaces`,void 0),s(this,`models`,void 0),s(this,`tools`,void 0),s(this,`providers`,void 0),s(this,`preconfigs`,void 0),s(this,`prompts`,void 0),s(this,`files`,void 0),s(this,`attachments`,void 0),s(this,`terminals`,void 0),s(this,`mcp`,void 0),s(this,`config`,void 0),this.sessions=new k(e),this.workspaces=new A(e),this.models=new j(e),this.tools=new M(e),this.providers=new N(e),this.preconfigs=new P(e),this.prompts=new F(e),this.files=new I(e),this.attachments=new L(e),this.terminals=new R(e),this.mcp=new z(e),this.config=new H(e)}async loadAll(e){let[t,n,r,i,a]=await Promise.all([this.workspaces.list(e),this.preconfigs.list(e),this.prompts.list(e),this.models.list(e),this.providers.list(e)]);return{workspaces:t.workspaces,preconfigs:n.preconfigs,prompts:r.prompts,models:i.models,defaultModel:i.defaultModel,defaultProvider:i.defaultProvider,providers:a.providers}}},W=class extends c{constructor(e){super(),s(this,`config`,void 0),s(this,`transport`,void 0),s(this,`_httpClient`,void 0),s(this,`_state`,`disconnected`),s(this,`_connectionId`,null),s(this,`_registeredClient`,null),s(this,`sessions`,void 0),s(this,`chat`,void 0),s(this,`permissions`,void 0),s(this,`queue`,void 0),s(this,`providers`,void 0),s(this,`control`,void 0),s(this,`http`,void 0),s(this,`terminal`,void 0),this.config=e,this.transport=new g({url:e.url,token:e.token,wsConstructor:e.wsConstructor,connectionTimeout:e.connectionTimeout}),this._httpClient=new _({url:e.url,token:e.token,apiBase:e.apiBase});let t=this.transport.send.bind(this.transport);this.sessions=new v(t),this.chat=new y(t),this.permissions=new b(t),this.queue=new x(t),this.providers=new S(t),this.control=new C(t),this.http=new U(this._httpClient),this.terminal=new O({url:e.url,token:e.token,wsConstructor:e.wsConstructor}),this.transport.onOpen=()=>{this._state=`connected`,this._connectionId=null,this._registeredClient=null,this.config.clientDescriptor&&this.send({type:`client.register`,client:this.config.clientDescriptor}),this.emit(`connected`),this.emit(`*`,{source:`lifecycle`,type:`connected`,payload:void 0})},this.transport.onMessage=e=>{e.type===`client.registered`&&(this._connectionId=e.connectionId,this._registeredClient=e.client),l(this,e)},this.transport.onClose=(e,t,n)=>{let r=this._state;this._state=`disconnected`,r!==`disconnected`&&(this.emit(`disconnected`,{code:e,reason:t,wasClean:n}),this.emit(`*`,{source:`lifecycle`,type:`disconnected`,payload:{code:e,reason:t,wasClean:n}}))},this.transport.onError=e=>{this.emit(`error.connection`,e),this.emit(`*`,{source:`lifecycle`,type:`error.connection`,payload:e})}}async connect(){this._state=`connecting`,await this.transport.connect()}async disconnect(){this._state=`disconnecting`,await this.transport.disconnect()}async dispose(){await this.disconnect(),this.transport.dispose(),this.removeAllListeners()}get state(){return this._state}get connected(){return this._state===`connected`}get ws(){return this.transport.ws}get httpClient(){return this._httpClient}get connectionId(){return this._connectionId}get registeredClient(){return this._registeredClient}get clientId(){var e,t;return(e=(t=this._registeredClient)==null?void 0:t.clientId)==null?null:e}send(e){this.transport.send(e)}};export{r as i,U as n,_ as r,W as t};
@@ -0,0 +1 @@
1
+ import{n as e,o as t,r as n,t as r}from"./compiler-runtime-DZXZ41-q.js";import{a as i}from"./platform-5d-ZQG2e.js";import{Et as a,St as o,Tt as s,_t as c,a as l,b as u,bt as d,c as f,d as ee,ft as p,ht as m,i as h,n as g,r as _,s as v,t as y,ut as b,v as x,vt as te,xt as S,y as C}from"./badge-CwZd07eA.js";import{t as w}from"./createLucideIcon-BYAVpx9Z.js";import{n as T,t as ne}from"./confirmation-dialog-DGPNPL5O.js";import{a as E,i as D,n as O,o as re,r as k,s as A,t as j}from"./SessionMenuButton-Bg83zT6G.js";import{_ as M,a as N,b as P,c as F,d as I,h as L,i as ie,l as R,o as ae,p as z,r as oe,s as B,t as V,u as H,v as U,x as W,y as G}from"./popover-BaZzl6-v.js";import{E as K,O as q,a as se,c as J,d as Y,f as X,l as ce,o as le,s as ue}from"./sidebar-DmGZgZwK.js";import{n as de,t as Z}from"./scroll-area-16Gq00WS.js";var fe=w(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),pe=w(`hard-drive`,[[`path`,{d:`M10 16h.01`,key:`1bzywj`}],[`path`,{d:`M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`18tbho`}],[`path`,{d:`M21.946 12.013H2.054`,key:`zqlbp7`}],[`path`,{d:`M6 16h.01`,key:`1pmjb7`}]]),me=r(),Q=t(n(),1);function he(e){let t=(0,me.c)(9),{sdkClient:n,workspaceId:r,connected:i}=e,[a,o]=(0,Q.useState)(!0),[s,c]=(0,Q.useState)(null),l=m(ge),u,d;t[0]!==i||t[1]!==n||t[2]!==l||t[3]!==r?(u=()=>{if(!r){l([]),o(!1);return}if(!n){o(!1);return}if(!i){o(!1);return}let e=!1;return o(!0),c(null),n.http.sessions.listByWorkspace({workspaceId:r}).then(t=>{e||(l(t.sessions),o(!1))}).catch(t=>{if(e)return;let n=t instanceof Error?t.message:String(t);console.error(`Failed to load workspace sessions:`,n),c(n),o(!1)}),()=>{e=!0}},d=[n,i,r,l],t[0]=i,t[1]=n,t[2]=l,t[3]=r,t[4]=u,t[5]=d):(u=t[4],d=t[5]),(0,Q.useEffect)(u,d);let f;return t[6]!==s||t[7]!==a?(f={isLoading:a,error:s},t[6]=s,t[7]=a,t[8]=f):f=t[8],f}function ge(e){return e.setSessions}function _e(...e){return e.map((e,t)=>t===0?e.replace(/\/+$/,``):e.replace(/^\/+|\/+$/g,``)).filter(Boolean).join(`/`)}var $=e();function ve({open:e,onOpenChange:t,onSelect:n,initialPath:r,title:i=`Select Folder`,sdkClient:s}){var c;let[l,d]=(0,Q.useState)(r||``),[f,ee]=(0,Q.useState)([]),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(0),[_,v]=(0,Q.useState)(null),[y,b]=(0,Q.useState)(``),[te,w]=(0,Q.useState)(!1),[T,ne]=(0,Q.useState)([]),[E,D]=(0,Q.useState)(!1),O=(0,Q.useRef)(null),re=(0,Q.useRef)(null),k=(0,Q.useCallback)(async e=>{if(s){m(!0),v(null),g(0),b(``),D(!1);try{var t;let n=await s.http.files.browseFs(e);ee(n.files.filter(e=>e.type===`directory`)),d(n.currentPath),w((t=n.isRoot)==null?!1:t)}catch(e){v(e instanceof Error?e.message:`Failed to load directory`),ee([])}finally{m(!1)}}},[s]),A=(0,Q.useCallback)(async()=>{if(s)try{ne((await s.http.files.drives()).drives||[])}catch{}},[s]);(0,Q.useEffect)(()=>{e&&(k(r||``),A())},[e,r,k,A]),(0,Q.useEffect)(()=>{g(0)},[y]);let j=f.filter(e=>e.name.toLowerCase().includes(y.toLowerCase())),N=(c=j[h])==null?null:c,F=(0,Q.useCallback)(e=>_e(l,e.name),[l]),I=N?F(N):l,ie=!N,R=async()=>{if(s){m(!0),v(null);try{var e;let t=await s.http.files.parent(l);ee(t.files.filter(e=>e.type===`directory`)),d(t.currentPath),w((e=t.isRoot)==null?!1:e),g(0),b(``)}catch(e){v(e instanceof Error?e.message:`Failed to navigate up`)}finally{m(!1)}}},ae=()=>{I&&(n(I),t(!1))},oe=e=>{k(F(e))},B=e=>{if(j.length!==0)switch(e.key){case`ArrowDown`:e.preventDefault(),g(e=>Math.min(e+1,j.length-1));break;case`ArrowRight`:j[h]&&(e.preventDefault(),oe(j[h]));break;case`ArrowUp`:e.preventDefault(),g(e=>Math.max(e-1,0));break;case`Enter`:e.preventDefault(),ae();break;case`Escape`:y&&(e.preventDefault(),b(``));break}};(0,Q.useEffect)(()=>{if(re.current&&j.length>0){let e=re.current.children[h];e&&e.scrollIntoView({block:`nearest`})}},[h,j.length]),(0,Q.useEffect)(()=>{e&&setTimeout(()=>{var e;return(e=O.current)==null?void 0:e.focus()},100)},[e]),(0,Q.useEffect)(()=>{D(!1)},[l]);let V=(e,t=50)=>{if(e.length<=t)return e;let n=e.split(/[/\\]/);return n.length<=2?e:`.../`+n.slice(-2).join(`/`)};return(0,$.jsx)(z,{open:e,onOpenChange:t,children:(0,$.jsxs)(L,{className:`sm:max-w-lg`,onKeyDown:B,children:[(0,$.jsx)(U,{children:(0,$.jsx)(G,{children:i})}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 p-2 bg-muted rounded-md`,children:[(0,$.jsx)(C,{variant:`ghost`,size:`icon`,className:`h-7 w-7 flex-shrink-0`,onClick:R,disabled:p||!l||te,children:(0,$.jsx)(fe,{className:`w-4 h-4`})}),T.length>1&&(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(C,{variant:`ghost`,size:`icon`,className:`h-7 w-7 flex-shrink-0`,onClick:()=>D(e=>!e),disabled:p,children:(0,$.jsx)(pe,{className:`w-4 h-4`})}),E&&(0,$.jsx)(`div`,{className:`absolute top-full left-0 mt-1 bg-popover border rounded-md shadow-md z-50 min-w-[120px]`,children:T.map(e=>(0,$.jsxs)(`button`,{onClick:()=>{k(e),D(!1)},className:u(`flex items-center gap-2 w-full px-3 py-1.5 text-sm text-left hover:bg-muted`,l===e&&`bg-primary/20 text-primary font-medium`),children:[(0,$.jsx)(o,{className:`w-3.5 h-3.5 text-amber-500`}),e]},e))})]}),(0,$.jsx)(`span`,{className:`flex-1 text-sm font-mono truncate`,title:I,children:N?(0,$.jsx)(`span`,{className:`text-primary`,children:V(F(N),45)}):V(l)||`Home`})]}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(P,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground`}),(0,$.jsx)(x,{ref:O,placeholder:`Filter folders...`,value:y,onChange:e=>b(e.target.value),className:`pl-8`})]}),(0,$.jsx)(Z,{className:`h-64 border rounded-md`,children:p?(0,$.jsxs)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground`,children:[(0,$.jsx)(S,{className:`w-4 h-4 animate-spin mr-2`}),`Loading...`]}):_?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`text-destructive`,children:_}),(0,$.jsx)(C,{variant:`ghost`,size:`sm`,onClick:()=>k(l),className:`mt-2`,children:`Retry`})]}):j.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full text-muted-foreground text-sm`,children:[(0,$.jsx)(o,{className:`w-8 h-8 mb-2 opacity-50`}),y?`No matching folders`:`No folders in this directory`]}):(0,$.jsx)(`div`,{className:`p-1`,ref:re,children:j.map((e,t)=>(0,$.jsxs)(`button`,{onClick:()=>g(t),onDoubleClick:()=>oe(e),className:u(`flex items-center gap-2 w-full px-2 py-1.5 rounded text-sm text-left`,`hover:bg-muted`,t===h&&`bg-primary/20 text-primary font-medium ring-1 ring-primary/50`),children:[(0,$.jsx)(o,{className:`w-4 h-4 text-amber-500 flex-shrink-0`}),(0,$.jsx)(`span`,{className:`truncate flex-1`,children:e.name}),t===h&&(0,$.jsx)(a,{className:`w-4 h-4 text-primary`})]},e.path))})}),_&&(0,$.jsx)(`p`,{className:`text-xs text-destructive`,children:_})]}),(0,$.jsxs)(M,{children:[(0,$.jsx)(C,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,$.jsx)(C,{onClick:ae,disabled:!I||p,children:ie?`Use This Folder`:`Add Selected Folder`})]})]})})}function ye(e){let t=(0,me.c)(67),{workspaces:n,activeWorkspace:r,onSelectWorkspace:i,onCreateVirtualWorkspace:s,onCreatePhysicalWorkspace:c,isWorkspaceFavorited:p,onToggleFavorite:m,onDeleteWorkspace:h,onRenameWorkspace:g,sdkClient:_}=e,[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(null),[E,D]=(0,Q.useState)(null),[O,re]=(0,Q.useState)(``),k=(0,Q.useRef)(null),j,M;t[0]===E?(j=t[1],M=t[2]):(j=()=>{E&&k.current&&(k.current.focus(),k.current.select())},M=[E],t[0]=E,t[1]=j,t[2]=M),(0,Q.useEffect)(j,M);let P;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(P=e=>{re(e.name),D(e.id)},t[3]=P):P=t[3];let L=P,z;t[4]!==g||t[5]!==O||t[6]!==E?(z=()=>{let e=O.trim();e&&E&&g(E,e),D(null)},t[4]=g,t[5]=O,t[6]=E,t[7]=z):z=t[7];let U=z,G;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(G=()=>{D(null)},t[8]=G):G=t[8];let se=G,J;t[9]===(r==null?void 0:r.isVirtual)?J=t[10]:(J=r!=null&&r.isVirtual?(0,$.jsx)(A,{className:`size-4 flex-shrink-0 text-muted-foreground`}):(0,$.jsx)(o,{className:`size-4 flex-shrink-0 text-muted-foreground`}),t[9]=r==null?void 0:r.isVirtual,t[10]=J);let Y=(r==null?void 0:r.name)||`Select workspace`,X;t[11]===Y?X=t[12]:(X=(0,$.jsx)(`span`,{className:`truncate`,children:Y}),t[11]=Y,t[12]=X);let ce;t[13]!==J||t[14]!==X?(ce=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 overflow-hidden`,children:[J,X]}),t[13]=J,t[14]=X,t[15]=ce):ce=t[15];let le;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,$.jsx)(W,{className:`ml-auto size-4 shrink-0 opacity-50`}),t[16]=le):le=t[16];let ue;t[17]!==y||t[18]!==ce?(ue=(0,$.jsx)(ie,{asChild:!0,children:(0,$.jsxs)(C,{variant:`outline`,role:`combobox`,"aria-expanded":y,"aria-label":`Select workspace`,className:`w-full justify-between h-9`,children:[ce,le]})}),t[17]=y,t[18]=ce,t[19]=ue):ue=t[19];let Z;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(Z=(0,$.jsx)(F,{placeholder:`Search workspace...`}),t[20]=Z):Z=t[20];let fe;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(fe=(0,$.jsx)(ae,{children:`No workspace found.`}),t[21]=fe):fe=t[21];let pe;t[22]!==(r==null?void 0:r.id)||t[23]!==U||t[24]!==p||t[25]!==i||t[26]!==m||t[27]!==O||t[28]!==E||t[29]!==n?(pe=n.map(e=>(0,$.jsxs)(R,{showCheck:!1,onSelect:()=>{E!==e.id&&(i(e),b(!1))},children:[(0,$.jsx)(`div`,{className:`flex-1 min-w-0 flex items-center gap-2`,children:E===e.id?(0,$.jsx)(`input`,{ref:k,type:`text`,value:O,onChange:e=>re(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),U()):e.key===`Escape`?(e.preventDefault(),se()):[`ArrowUp`,`ArrowDown`].includes(e.key)&&e.stopPropagation()},onBlur:U,onClick:xe,className:`flex-1 min-w-0 h-6 px-1 text-sm bg-background border border-input rounded focus:outline-none focus:ring-2 focus:ring-ring`}):(0,$.jsxs)($.Fragment,{children:[e.isVirtual?(0,$.jsx)(A,{className:`size-4 flex-shrink-0 text-muted-foreground`}):(0,$.jsx)(o,{className:`size-4 flex-shrink-0 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.name})]})}),(0,$.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,$.jsx)(`button`,{className:`p-1 rounded hover:bg-secondary transition-colors`,onClick:t=>{t.stopPropagation(),m(e.id,e.name)},title:p(e.id)?`Remove from favorites`:`Add to favorites`,children:p(e.id)?(0,$.jsx)(de,{className:`size-4 fill-primary text-primary`}):(0,$.jsx)(de,{className:`size-4 text-muted-foreground`})}),(0,$.jsx)(a,{className:u(`size-4`,(r==null?void 0:r.id)===e.id?`opacity-100`:`opacity-0`)}),(0,$.jsxs)(l,{children:[(0,$.jsx)(ee,{asChild:!0,children:(0,$.jsxs)(`button`,{className:`p-1 rounded hover:bg-secondary transition-colors`,onClick:be,children:[(0,$.jsx)(q,{className:`size-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Workspace actions`})]})}),(0,$.jsxs)(v,{align:`end`,children:[(0,$.jsxs)(f,{onClick:t=>{t.stopPropagation(),L(e)},children:[(0,$.jsx)(K,{className:`size-4`}),`Rename`]}),(0,$.jsxs)(f,{onClick:t=>{t.stopPropagation(),T(e)},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(te,{className:`size-4`}),`Delete`]})]})]})]})]},e.id)),t[22]=r==null?void 0:r.id,t[23]=U,t[24]=p,t[25]=i,t[26]=m,t[27]=O,t[28]=E,t[29]=n,t[30]=pe):pe=t[30];let he;t[31]===pe?he=t[32]:(he=(0,$.jsx)(B,{heading:`Workspaces`,children:pe}),t[31]=pe,t[32]=he);let ge;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,$.jsx)(I,{}),t[33]=ge):ge=t[33];let _e;t[34]===s?_e=t[35]:(_e=()=>{s(),b(!1)},t[34]=s,t[35]=_e);let ye;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(ye=(0,$.jsx)(d,{className:`size-4`,"data-icon":`inline-start`}),t[36]=ye):ye=t[36];let Se;t[37]===_e?Se=t[38]:(Se=(0,$.jsxs)(R,{onSelect:_e,children:[ye,`Create virtual workspace`]}),t[37]=_e,t[38]=Se);let Ce;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=(0,$.jsxs)(R,{onSelect:()=>{b(!1),S(!0)},children:[(0,$.jsx)(o,{className:`size-4`,"data-icon":`inline-start`}),`Add existing folder`]}),t[39]=Ce):Ce=t[39];let we;t[40]===Se?we=t[41]:(we=(0,$.jsxs)(B,{children:[Se,Ce]}),t[40]=Se,t[41]=we);let Te;t[42]!==he||t[43]!==we?(Te=(0,$.jsx)(oe,{className:`w-[240px] p-0 max-h-[80vh]`,children:(0,$.jsxs)(N,{children:[Z,(0,$.jsxs)(H,{className:`max-h-[50vh] overflow-y-auto`,children:[fe,he,ge,we]})]})}),t[42]=he,t[43]=we,t[44]=Te):Te=t[44];let Ee;t[45]!==y||t[46]!==ue||t[47]!==Te?(Ee=(0,$.jsxs)(V,{open:y,onOpenChange:b,children:[ue,Te]}),t[45]=y,t[46]=ue,t[47]=Te,t[48]=Ee):Ee=t[48];let De;t[49]===c?De=t[50]:(De=e=>{c(e),S(!1)},t[49]=c,t[50]=De);let Oe;t[51]!==_||t[52]!==x||t[53]!==De?(Oe=(0,$.jsx)(ve,{open:x,onOpenChange:S,onSelect:De,title:`Select Workspace Folder`,sdkClient:_}),t[51]=_,t[52]=x,t[53]=De,t[54]=Oe):Oe=t[54];let ke=w!==null,Ae;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(Ae=e=>!e&&T(null),t[55]=Ae):Ae=t[55];let je=w?`Are you sure you want to delete "${w.name}"? This will permanently remove the workspace and all associated Jean data, including sessions, messages, and temporary files. The actual files in "${w.name}" on disk will not be deleted.`:``,Me;t[56]!==h||t[57]!==w?(Me=()=>{w&&(h(w.id),T(null))},t[56]=h,t[57]=w,t[58]=Me):Me=t[58];let Ne;t[59]!==ke||t[60]!==je||t[61]!==Me?(Ne=(0,$.jsx)(ne,{open:ke,onOpenChange:Ae,title:`Delete Workspace`,description:je,confirmLabel:`Delete`,variant:`destructive`,onConfirm:Me}),t[59]=ke,t[60]=je,t[61]=Me,t[62]=Ne):Ne=t[62];let Pe;return t[63]!==Ee||t[64]!==Oe||t[65]!==Ne?(Pe=(0,$.jsxs)($.Fragment,{children:[Ee,Oe,Ne]}),t[63]=Ee,t[64]=Oe,t[65]=Ne,t[66]=Pe):Pe=t[66],Pe}function be(e){return e.stopPropagation()}function xe(e){return e.stopPropagation()}function Se(e){let t=(0,me.c)(56),{activeSessions:n,archivedSessions:r,childrenMap:i,sessionDerivedValues:a,currentSessionId:o,onResumeSession:u,onCloseSession:d,onReopenSession:p,onDeleteSession:m,onRenameSession:b,onBulkCloseSessions:x,onBulkDeleteSessions:S}=e,[w,E]=(0,Q.useState)(!1),D;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(D=new Set,t[0]=D):D=t[0];let[O,k]=(0,Q.useState)(D),[A,M]=(0,Q.useState)(!1),N;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(N=e=>{k(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},t[1]=N):N=t[1];let P=N,F;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(F=()=>{E(De),k(new Set)},t[2]=F):F=t[2];let I=F,L;t[3]===n?L=t[4]:(L=()=>{k(new Set(n.map(Ee)))},t[3]=n,t[4]=L);let ie=L,R;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(R=()=>{k(new Set)},t[5]=R):R=t[5];let ae=R,z;t[6]!==x||t[7]!==O?(z=()=>{O.size>0&&(x(O),k(new Set),E(!1))},t[6]=x,t[7]=O,t[8]=z):z=t[8];let oe=z,B;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(B=()=>{E(!1),k(new Set)},t[9]=B):B=t[9];let V=B,H;t[10]!==r||t[11]!==S?(H=()=>{let e=new Set(r.map(Te));e.size>0&&S(e),M(!1)},t[10]=r,t[11]=S,t[12]=H):H=t[12];let U=H,W,G;t[13]===w?(W=t[14],G=t[15]):(G=()=>{if(!w)return;let e=e=>{e.key===`Escape`&&V()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},W=[w,V],t[13]=w,t[14]=W,t[15]=G),(0,Q.useEffect)(G,W);let K;t[16]!==n||t[17]!==i||t[18]!==o||t[19]!==d||t[20]!==m||t[21]!==b||t[22]!==p||t[23]!==u||t[24]!==ie||t[25]!==O||t[26]!==w||t[27]!==a?(K=(0,$.jsx)(g,{defaultOpen:!0,className:`group/collapsible`,children:(0,$.jsxs)(se,{children:[(0,$.jsx)(ue,{asChild:!0,children:(0,$.jsx)(h,{asChild:!0,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between w-full`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(s,{className:`size-3 transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90`}),`Active`]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[w&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:O.size>0?(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),O.size===n.length?ae():ie()},className:`hover:underline cursor-pointer`,children:O.size===n.length?`Deselect all`:`Select all`}):(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),ie()},className:`hover:underline cursor-pointer`,children:`Select all`})}),(0,$.jsx)(y,{variant:`secondary`,children:n.length}),(0,$.jsxs)(l,{children:[(0,$.jsx)(ee,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:we,className:`p-1 rounded-md hover:bg-sidebar-accent hover:text-sidebar-accent-foreground transition-colors`,title:`Session actions`,children:(0,$.jsx)(q,{className:`size-4`})})}),(0,$.jsx)(v,{align:`end`,className:`min-w-48`,children:w?(0,$.jsxs)(f,{onClick:e=>{e.stopPropagation(),V()},children:[(0,$.jsx)(c,{className:`size-4`}),`Cancel selection`]}):(0,$.jsxs)(f,{onClick:e=>{e.stopPropagation(),I()},children:[(0,$.jsx)(re,{className:`size-4`}),`Select to archive`]})})]})]})]})})}),(0,$.jsx)(_,{children:(0,$.jsx)(le,{children:(0,$.jsx)(ce,{children:n.map(e=>(0,$.jsx)(j,{session:e,childrenMap:i,sessionDerivedValues:a,isActive:o===e.id,currentSessionId:o,onResumeSession:u,onCloseSession:d,onReopenSession:p,onDeleteSession:m,onRename:b,selectionMode:w,selected:O.has(e.id),onToggleSelect:P},e.id))})})})]})}),t[16]=n,t[17]=i,t[18]=o,t[19]=d,t[20]=m,t[21]=b,t[22]=p,t[23]=u,t[24]=ie,t[25]=O,t[26]=w,t[27]=a,t[28]=K):K=t[28];let J;t[29]!==r||t[30]!==i||t[31]!==o||t[32]!==d||t[33]!==m||t[34]!==b||t[35]!==p||t[36]!==u||t[37]!==a?(J=r.length>0&&(0,$.jsx)(g,{defaultOpen:!0,className:`group/collapsible`,children:(0,$.jsxs)(se,{children:[(0,$.jsx)(ue,{asChild:!0,children:(0,$.jsx)(h,{asChild:!0,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between w-full`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(s,{className:`size-3 transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90`}),`Archived`]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(y,{variant:`secondary`,children:r.length}),(0,$.jsxs)(l,{children:[(0,$.jsx)(ee,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:Ce,className:`p-1 rounded-md hover:bg-sidebar-accent hover:text-sidebar-accent-foreground transition-colors`,title:`Archived actions`,children:(0,$.jsx)(q,{className:`size-4`})})}),(0,$.jsx)(v,{align:`end`,className:`min-w-48`,children:(0,$.jsxs)(f,{onClick:e=>{e.stopPropagation(),M(!0)},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(te,{className:`size-4`}),`Delete all`]})})]})]})]})})}),(0,$.jsx)(_,{children:(0,$.jsx)(le,{children:(0,$.jsx)(ce,{children:r.map(e=>(0,$.jsx)(j,{session:e,childrenMap:i,sessionDerivedValues:a,isActive:o===e.id,currentSessionId:o,onResumeSession:u,onCloseSession:d,onReopenSession:p,onDeleteSession:m,onRename:b},e.id))})})})]})}),t[29]=r,t[30]=i,t[31]=o,t[32]=d,t[33]=m,t[34]=b,t[35]=p,t[36]=u,t[37]=a,t[38]=J):J=t[38];let Y;t[39]!==n.length||t[40]!==r.length?(Y=n.length===0&&r.length===0&&(0,$.jsxs)(`div`,{className:`p-4 text-center text-sm text-muted-foreground`,children:[`No sessions yet.`,(0,$.jsx)(`br`,{}),`Start a new chat to begin.`]}),t[39]=n.length,t[40]=r.length,t[41]=Y):Y=t[41];let X;t[42]!==oe||t[43]!==O.size||t[44]!==w?(X=w&&O.size>0&&(0,$.jsxs)(`div`,{className:`sticky bottom-0 bg-sidebar border-t px-2 py-1.5 flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground truncate min-w-0`,children:[O.size,` selected`]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,$.jsx)(C,{variant:`outline`,size:`icon`,onClick:oe,title:`Archive`,className:`size-7`,children:(0,$.jsx)(T,{className:`size-4`})}),(0,$.jsx)(C,{variant:`ghost`,size:`icon`,onClick:V,title:`Cancel`,className:`size-7`,children:(0,$.jsx)(c,{className:`size-4`})})]})]}),t[42]=oe,t[43]=O.size,t[44]=w,t[45]=X):X=t[45];let de=`This will permanently delete ${r.length} archived session${r.length===1?``:`s`}. This action cannot be undone.`,Z;t[46]!==A||t[47]!==U||t[48]!==de?(Z=(0,$.jsx)(ne,{open:A,onOpenChange:M,title:`Delete all archived sessions?`,description:de,confirmLabel:`Delete all`,variant:`destructive`,onConfirm:U}),t[46]=A,t[47]=U,t[48]=de,t[49]=Z):Z=t[49];let fe;return t[50]!==K||t[51]!==J||t[52]!==Y||t[53]!==X||t[54]!==Z?(fe=(0,$.jsxs)($.Fragment,{children:[K,J,Y,X,Z]}),t[50]=K,t[51]=J,t[52]=Y,t[53]=X,t[54]=Z,t[55]=fe):fe=t[55],fe}function Ce(e){return e.stopPropagation()}function we(e){return e.stopPropagation()}function Te(e){return e.id}function Ee(e){return e.id}function De(e){return!e}function Oe(){var e,t,n;let r=(0,me.c)(61),a=b(),o=O(),{sidebarRef:s,chatInputRef:c,terminalPanelRef:l}=p(),{sdkClient:u,primaryPreconfigs:f,createSession:ee,resumeSession:m,closeSession:h,reopenSession:g,permanentlyDeleteSession:_,handleRenameSession:v,selectWorkspace:y,handleCreateVirtualWorkspace:x,handleCreatePhysicalWorkspace:te,deleteWorkspace:S,renameWorkspace:C}=a,w=(e=(t=o.activeWorkspace)==null?void 0:t.id)==null?null:e,T;r[0]!==u||r[1]!==o.connected||r[2]!==w?(T={sdkClient:u,workspaceId:w,connected:o.connected},r[0]=u,r[1]=o.connected,r[2]=w,r[3]=T):T=r[3],he(T);let ne=o.activeSessions,re=o.archivedSessions,A;r[4]!==S||r[5]!==te||r[6]!==x||r[7]!==C||r[8]!==u||r[9]!==y||r[10]!==o.activeWorkspace||r[11]!==o.handleToggleWorkspaceFavorite||r[12]!==o.isWorkspaceFavorited||r[13]!==o.workspaces?(A=(0,$.jsx)(`div`,{className:`p-2 space-y-2`,children:(0,$.jsx)(ye,{workspaces:o.workspaces,activeWorkspace:o.activeWorkspace,onSelectWorkspace:y,onCreateVirtualWorkspace:x,onCreatePhysicalWorkspace:te,isWorkspaceFavorited:o.isWorkspaceFavorited,onToggleFavorite:o.handleToggleWorkspaceFavorite,onDeleteWorkspace:S,onRenameWorkspace:C,sdkClient:u})}),r[4]=S,r[5]=te,r[6]=x,r[7]=C,r[8]=u,r[9]=y,r[10]=o.activeWorkspace,r[11]=o.handleToggleWorkspaceFavorite,r[12]=o.isWorkspaceFavorited,r[13]=o.workspaces,r[14]=A):A=r[14];let j;if(r[15]!==ee||r[16]!==((n=f[0])==null?void 0:n.id)){var M;j=()=>{var e;return ee((e=f[0])==null?void 0:e.id)},r[15]=ee,r[16]=(M=f[0])==null?void 0:M.id,r[17]=j}else j=r[17];let N=!o.connected,P,F;r[18]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(d,{className:`size-4`,"data-icon":`inline-start`}),F=(0,$.jsx)(`span`,{children:`New Chat`}),r[18]=P,r[19]=F):(P=r[18],F=r[19]);let I;r[20]!==j||r[21]!==N?(I=(0,$.jsx)(ce,{children:(0,$.jsx)(X,{children:(0,$.jsxs)(Y,{onClick:j,disabled:N,className:`w-full`,children:[P,F]})})}),r[20]=j,r[21]=N,r[22]=I):I=r[22];let L;r[23]!==A||r[24]!==I?(L=(0,$.jsxs)(J,{children:[A,I]}),r[23]=A,r[24]=I,r[25]=L):L=r[25];let ie=L,R;r[26]===h?R=r[27]:(R=e=>{e.forEach(e=>h(e))},r[26]=h,r[27]=R);let ae=R,z;r[28]===_?z=r[29]:(z=e=>{e.forEach(e=>_(e))},r[28]=_,r[29]=z);let oe=z,B;r[30]!==ne||r[31]!==re||r[32]!==h||r[33]!==ae||r[34]!==oe||r[35]!==v||r[36]!==_||r[37]!==g||r[38]!==m||r[39]!==o.childrenMap||r[40]!==o.currentSessionId||r[41]!==o.sessionDerivedValues?(B=(0,$.jsx)(Se,{activeSessions:ne,archivedSessions:re,childrenMap:o.childrenMap,sessionDerivedValues:o.sessionDerivedValues,currentSessionId:o.currentSessionId,onResumeSession:m,onCloseSession:h,onReopenSession:g,onDeleteSession:_,onRenameSession:v,onBulkCloseSessions:ae,onBulkDeleteSessions:oe}),r[30]=ne,r[31]=re,r[32]=h,r[33]=ae,r[34]=oe,r[35]=v,r[36]=_,r[37]=g,r[38]=m,r[39]=o.childrenMap,r[40]=o.currentSessionId,r[41]=o.sessionDerivedValues,r[42]=B):B=r[42];let V=B,H;r[43]!==c||r[44]!==o.currentSessionId?(H=()=>{if(o.currentSessionId){var e;(e=c.current)==null||e.focus()}},r[43]=c,r[44]=o.currentSessionId,r[45]=H):H=r[45];let U;r[46]!==V||r[47]!==o.currentSessionId||r[48]!==ie||r[49]!==s||r[50]!==H?(U=(0,$.jsx)(E,{ref:s,header:ie,currentSessionId:o.currentSessionId,onEscape:H,children:V}),r[46]=V,r[47]=o.currentSessionId,r[48]=ie,r[49]=s,r[50]=H,r[51]=U):U=r[51];let W;r[52]===Symbol.for(`react.memo_cache_sentinel`)?(W={paddingTop:`calc(0.5rem + env(safe-area-inset-top, 0px))`,paddingBottom:`calc(0.5rem + env(safe-area-inset-bottom, 0px))`},r[52]=W):W=r[52];let G,K;r[53]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,$.jsx)(D,{}),K=(0,$.jsx)(i,{}),r[53]=G,r[54]=K):(G=r[53],K=r[54]);let q;r[55]!==u||r[56]!==l?(q=(0,$.jsx)(`main`,{className:`flex-1 flex flex-col overflow-hidden min-h-0 p-2`,style:W,children:(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col overflow-hidden min-h-0 rounded-xl bg-background shadow-sm ring-1 ring-border`,children:[G,K,(0,$.jsx)(k,{sdkClient:u,terminalPanelRef:l})]})}),r[55]=u,r[56]=l,r[57]=q):q=r[57];let se;return r[58]!==U||r[59]!==q?(se=(0,$.jsxs)($.Fragment,{children:[U,q]}),r[58]=U,r[59]=q,r[60]=se):se=r[60],se}var ke=Oe;export{ke as component};
package/dist/index.html CHANGED
@@ -38,18 +38,18 @@
38
38
  root.classList.add(mode, scheme);
39
39
  })();
40
40
  </script>
41
- <script type="module" crossorigin src="./assets/index-CGdDNSI7.js"></script>
41
+ <script type="module" crossorigin src="./assets/index-BDTQdmk9.js"></script>
42
42
  <link rel="modulepreload" crossorigin href="./assets/compiler-runtime-DZXZ41-q.js">
43
- <link rel="modulepreload" crossorigin href="./assets/src-9dJwbSJY.js">
43
+ <link rel="modulepreload" crossorigin href="./assets/src-BiLzKNfl.js">
44
44
  <link rel="modulepreload" crossorigin href="./assets/servers-GmYSnzvH.js">
45
45
  <link rel="modulepreload" crossorigin href="./assets/useParams-RuFKFrOo.js">
46
46
  <link rel="modulepreload" crossorigin href="./assets/preload-helper-D-tEmku_.js">
47
- <link rel="modulepreload" crossorigin href="./assets/platform-Be8afd__.js">
47
+ <link rel="modulepreload" crossorigin href="./assets/platform-5d-ZQG2e.js">
48
48
  <link rel="modulepreload" crossorigin href="./assets/useNavigate-Dxc8FNpV.js">
49
- <link rel="modulepreload" crossorigin href="./assets/_serverId-Z_onznBB.js">
50
- <link rel="modulepreload" crossorigin href="./assets/ThemeProvider-DWTAR83t.js">
49
+ <link rel="modulepreload" crossorigin href="./assets/_serverId-COhNW61b.js">
50
+ <link rel="modulepreload" crossorigin href="./assets/ThemeProvider-Da23NPAS.js">
51
51
  <link rel="modulepreload" crossorigin href="./assets/ServerContext-CBFiY6IH.js">
52
- <link rel="stylesheet" crossorigin href="./assets/index-QW5PCSUz.css">
52
+ <link rel="stylesheet" crossorigin href="./assets/index-DF4q2PgJ.css">
53
53
  </head>
54
54
  <body>
55
55
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jean2/client",
3
- "version": "1.0.0",
3
+ "version": "1.0.3",
4
4
  "description": "Jean2 AI Agent Client - Run the Jean2 web UI locally via npx",
5
5
  "private": false,
6
6
  "type": "module",
@@ -1,9 +0,0 @@
1
- import{n as e,o as t,r as n,t as r}from"./compiler-runtime-DZXZ41-q.js";import{i}from"./src-9dJwbSJY.js";import{$ as a,Ct as o,Dt as s,Et as c,J as l,Q as u,S as d,Tt as f,Y as p,Z as m,_ as h,_t as g,a as _,b as v,bt as y,c as b,ct as x,d as S,f as C,ft as w,h as T,ht as E,i as D,j as O,jt as k,l as A,m as j,n as M,ot as N,p as P,pt as F,r as I,rt as L,s as R,st as z,t as ee,u as B,ut as te,v as V,vt as H,wt as U,x as ne,xt as re,y as W,yt as G}from"./badge-CxHTOx9D.js";import{t as K}from"./createLucideIcon-BYAVpx9Z.js";import{n as ie,t as ae}from"./confirmation-dialog-CcyiA31R.js";import{C as oe,S as se,_ as ce,a as q,b as le,c as ue,d as de,f as fe,g as pe,h as me,i as he,l as ge,m as _e,n as ve,o as ye,p as be,r as xe,s as Se,t as J,u as Ce,v as we,x as Te,y as Ee}from"./alert-DjGCaOkT.js";import{a as Y,b as De,c as Oe,f as ke,i as X,l as Ae,n as je,o as Me,r as Ne,s as Pe,t as Fe,u as Ie,x as Le}from"./popover-DDHwMxwz.js";import{i as Re,n as ze,r as Be,t as Ve}from"./triangle-alert-BOCjiWM3.js";function He(e){return e.role===`assistant`}var Ue=K(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),We=K(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),Ge=K(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),Ke=K(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),qe=K(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Je=K(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Ye=K(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Xe=K(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),Ze=K(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),Qe=K(`file-pen`,[[`path`,{d:`M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34`,key:`o6klzx`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z`,key:`zhnas1`}]]),$e=K(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),et=K(`hand`,[[`path`,{d:`M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2`,key:`1fvzgz`}],[`path`,{d:`M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2`,key:`1kc0my`}],[`path`,{d:`M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8`,key:`10h0bg`}],[`path`,{d:`M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15`,key:`1s1gnw`}]]),tt=K(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),nt=K(`message-square`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]),rt=K(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]),it=K(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),at=K(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),ot=K(`shield-off`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]),st=K(`undo-2`,[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]),ct=K(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),lt=K(`wifi`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M2 8.82a15 15 0 0 1 20 0`,key:`dnpr2z`}],[`path`,{d:`M5 12.859a10 10 0 0 1 14 0`,key:`1x1e6c`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}]]),Z=t(n(),1),Q=e(),ut=`Checkbox`,[dt,ft]=u(ut),[pt,mt]=dt(ut);function ht(e){let{__scopeCheckbox:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:l,value:u=`on`,internal_do_not_use_render:d}=e,[f,m]=p({prop:n,defaultProp:i==null?!1:i,onChange:c,caller:ut}),[h,g]=Z.useState(null),[_,v]=Z.useState(null),y=Z.useRef(!1),b=h?!!o||!!h.closest(`form`):!0,x={checked:f,disabled:a,setChecked:m,control:h,setControl:g,name:s,form:o,value:u,hasConsumerStoppedPropagationRef:y,required:l,defaultChecked:wt(i)?!1:i,isFormControl:b,bubbleInput:_,setBubbleInput:v};return(0,Q.jsx)(pt,{scope:t,...x,children:Ct(d)?d(x):r})}var gt=`CheckboxTrigger`,_t=Z.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},i)=>{let{control:o,value:s,disabled:c,checked:l,required:u,setControl:d,setChecked:f,hasConsumerStoppedPropagationRef:p,isFormControl:h,bubbleInput:g}=mt(gt,e),_=L(i,d),v=Z.useRef(l);return Z.useEffect(()=>{let e=o==null?void 0:o.form;if(e){let t=()=>f(v.current);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[o,f]),(0,Q.jsx)(a.button,{type:`button`,role:`checkbox`,"aria-checked":wt(l)?`mixed`:l,"aria-required":u,"data-state":Tt(l),"data-disabled":c?``:void 0,disabled:c,value:s,...r,ref:_,onKeyDown:m(t,e=>{e.key===`Enter`&&e.preventDefault()}),onClick:m(n,e=>{f(e=>wt(e)?!0:!e),g&&h&&(p.current=e.isPropagationStopped(),p.current||e.stopPropagation())})})});_t.displayName=gt;var vt=Z.forwardRef((e,t)=>{let{__scopeCheckbox:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...d}=e;return(0,Q.jsx)(ht,{__scopeCheckbox:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(_t,{...d,ref:t,__scopeCheckbox:n}),e&&(0,Q.jsx)(St,{__scopeCheckbox:n})]})})});vt.displayName=ut;var yt=`CheckboxIndicator`,bt=Z.forwardRef((e,t)=>{let{__scopeCheckbox:n,forceMount:r,...i}=e,o=mt(yt,n);return(0,Q.jsx)(l,{present:r||wt(o.checked)||o.checked===!0,children:(0,Q.jsx)(a.span,{"data-state":Tt(o.checked),"data-disabled":o.disabled?``:void 0,...i,ref:t,style:{pointerEvents:`none`,...e.style}})})});bt.displayName=yt;var xt=`CheckboxBubbleInput`,St=Z.forwardRef(({__scopeCheckbox:e,...t},n)=>{let{control:r,hasConsumerStoppedPropagationRef:i,checked:o,defaultChecked:s,required:c,disabled:l,name:u,value:d,form:f,bubbleInput:p,setBubbleInput:m}=mt(xt,e),h=L(n,m),g=Se(o),_=O(r);Z.useEffect(()=>{let e=p;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=!i.current;if(g!==o&&n){let t=new Event(`click`,{bubbles:r});e.indeterminate=wt(o),n.call(e,wt(o)?!1:o),e.dispatchEvent(t)}},[p,g,o,i]);let v=Z.useRef(wt(o)?!1:o);return(0,Q.jsx)(a.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:s==null?v.current:s,required:c,disabled:l,name:u,value:d,form:f,...t,tabIndex:-1,ref:h,style:{...t.style,..._,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})});St.displayName=xt;function Ct(e){return typeof e==`function`}function wt(e){return e===`indeterminate`}function Tt(e){return wt(e)?`indeterminate`:e?`checked`:`unchecked`}var $=r();function Et(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsxs)(`div`,{className:`flex flex-col h-full items-center justify-center gap-4 text-muted-foreground`,children:[(0,Q.jsx)(re,{className:`size-8 animate-spin`}),(0,Q.jsx)(`p`,{className:`text-sm`,children:`Loading conversation...`})]}),e[0]=t):t=e[0],t}function Dt(e){let t=(0,$.c)(3),{message:n}=e,r=n===void 0?`Connecting to server...`:n,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsx)(re,{className:`size-8 animate-spin`}),t[0]=i):i=t[0];let a;return t[1]===r?a=t[2]:(a=(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-4 text-muted-foreground`,children:[i,(0,Q.jsx)(`p`,{className:`text-sm`,children:r})]}),t[1]=r,t[2]=a),a}var Ot=e=>{let t=(0,$.c)(26),{serverUrl:n,authError:r,retryCount:i,nextRetryIn:a,onRetry:o,onLogout:s}=e,c,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(ct,{className:`size-12 text-destructive mb-4`}),l=(0,Q.jsx)(`h2`,{className:`text-xl font-semibold text-foreground mb-2`,children:`Unable to connect to server`}),t[0]=c,t[1]=l):(c=t[0],l=t[1]);let u=r||`Please check that the server is running.`,d;t[2]===u?d=t[3]:(d=(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground mb-4 max-w-[400px]`,children:u}),t[2]=u,t[3]=d);let f;t[4]===n?f=t[5]:(f=n&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mb-6 font-mono bg-muted px-3 py-1.5 rounded`,children:n}),t[4]=n,t[5]=f);let p;t[6]===a?p=t[7]:(p=(0,Q.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Retrying in `,a,`s...`]}),t[6]=a,t[7]=p);let m;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Q.jsx)(be,{className:`size-4 mr-2`,"data-icon":`inline-start`}),t[8]=m):m=t[8];let h;t[9]===o?h=t[10]:(h=(0,Q.jsxs)(W,{onClick:o,variant:`default`,children:[m,`Retry Now`]}),t[9]=o,t[10]=h);let g;t[11]===s?g=t[12]:(g=(0,Q.jsx)(W,{onClick:s,variant:`ghost`,children:`Change Server`}),t[11]=s,t[12]=g);let _;t[13]!==h||t[14]!==g?(_=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[h,g]}),t[13]=h,t[14]=g,t[15]=_):_=t[15];let v;t[16]===i?v=t[17]:(v=i>0&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Retry attempt: `,i]}),t[16]=i,t[17]=v);let y;t[18]!==_||t[19]!==v||t[20]!==p?(y=(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[p,_,v]}),t[18]=_,t[19]=v,t[20]=p,t[21]=y):y=t[21];let b;return t[22]!==y||t[23]!==d||t[24]!==f?(b=(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center min-h-[400px] px-4 text-center`,children:[c,l,d,f,y]}),t[22]=y,t[23]=d,t[24]=f,t[25]=b):b=t[25],b};function kt(e){return e>=1e6?(e/1e6).toFixed(1)+`M`:e>=1e3?(e/1e3).toFixed(1)+`k`:e.toString()}function At(e){return e>=60?`critical`:e>=40?`warning`:`normal`}function jt(e){let t=(0,$.c)(21),{totalTokens:n,contextWindow:r}=e,i=n===void 0?0:n,a=r===void 0?0:r,[o,s]=(0,Z.useState)(!1),c=i===0?0:a,l;t[0]!==c||t[1]!==i?(l=c===0?0:Math.min(100,Math.round(i/c*100)),t[0]=c,t[1]=i,t[2]=l):l=t[2];let u=l,d=At(u),f=2*Math.PI*8,p=f*(1-u/100),m=u===0?`text-muted-foreground/30`:d===`critical`?`text-destructive`:d===`warning`?`text-warning`:`text-primary`,h;t[3]===o?h=t[4]:(h=()=>s(!o),t[3]=o,t[4]=h);let g;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Q.jsx)(`circle`,{cx:`10`,cy:`10`,r:8,stroke:`currentColor`,className:`text-muted-foreground/20`,strokeWidth:`3`}),t[5]=g):g=t[5];let _;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(_={transition:`stroke-dashoffset 0.3s ease`},t[6]=_):_=t[6];let v;t[7]!==m||t[8]!==p?(v=(0,Q.jsxs)(`svg`,{viewBox:`0 0 20 20`,className:`size-5`,fill:`none`,children:[g,(0,Q.jsx)(`circle`,{cx:`10`,cy:`10`,r:8,stroke:`currentColor`,className:m,strokeWidth:`3`,strokeDasharray:f,strokeDashoffset:p,strokeLinecap:`round`,transform:`rotate(-90 10 10)`,style:_})]}),t[7]=m,t[8]=p,t[9]=v):v=t[9];let y;t[10]!==c||t[11]!==u||t[12]!==o||t[13]!==i?(y=o?`${kt(i)}/${kt(c)}`:`${u}%`,t[10]=c,t[11]=u,t[12]=o,t[13]=i,t[14]=y):y=t[14];let b;t[15]===y?b=t[16]:(b=(0,Q.jsx)(`span`,{className:`text-xs font-mono text-muted-foreground`,children:y}),t[15]=y,t[16]=b);let x;return t[17]!==h||t[18]!==v||t[19]!==b?(x=(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 cursor-pointer select-none`,onClick:h,children:[v,b]}),t[17]=h,t[18]=v,t[19]=b,t[20]=x):x=t[20],x}function Mt(e){switch(e){case`budget`:return`$`;case`standard`:return`$$`;case`premium`:return`$$$`;default:return``}}function Nt(e){let t=(0,$.c)(79),{models:n,selectedModelId:r,onChangeModel:i,disabled:a,compact:o,iconOnly:s}=e,l=o===void 0?!1:o,u=s===void 0?!1:s,[d,f]=(0,Z.useState)(!1),p,m,h,g,_,y,b,x,S,C,w,T,E;if(t[0]!==l||t[1]!==a||t[2]!==u||t[3]!==n||t[4]!==i||t[5]!==d||t[6]!==r){y=Symbol.for(`react.early_return_sentinel`);bb0:{let e=n.reduce(Pt,{}),o=e=>{let t=n.find(t=>t.id===e);t&&(i(e,t.providerId),f(!1))},s;if(t[20]!==n||t[21]!==r){let e;t[23]===r?e=t[24]:(e=e=>e.id===r,t[23]=r,t[24]=e),s=n.find(e),t[20]=n,t[21]=r,t[22]=s}else s=t[22];let D=s;if(u){let n;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsx)(le,{className:`size-4 text-muted-foreground`}),t[25]=n):n=t[25];let i;t[26]!==a||t[27]!==d?(i=(0,Q.jsx)(X,{asChild:!0,children:(0,Q.jsx)(W,{variant:`ghost`,size:`icon-sm`,role:`combobox`,"aria-expanded":d,"aria-label":`Select model`,disabled:a,children:n})}),t[26]=a,t[27]=d,t[28]=i):i=t[28];let s;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsx)(Oe,{placeholder:`Search model...`}),t[29]=s):s=t[29];let l;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Q.jsx)(Me,{children:`No model found.`}),t[30]=l):l=t[30];let u=(0,Q.jsxs)(Ie,{className:`max-h-[50vh] overflow-y-auto`,children:[l,Object.entries(e).map(e=>{let[t,n]=e;return(0,Q.jsx)(Pe,{heading:t,children:n.map(e=>(0,Q.jsxs)(Ae,{value:e.id,onSelect:()=>o(e.id),className:`justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{children:e.name}),(0,Q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:Mt(e.tier)})]}),(0,Q.jsx)(c,{className:v(`size-4`,r===e.id?`opacity-100`:`opacity-0`)})]},e.id))},t)})]}),p;t[31]===u?p=t[32]:(p=(0,Q.jsx)(Ne,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(Y,{children:[s,u]})}),t[31]=u,t[32]=p);let m;t[33]!==d||t[34]!==i||t[35]!==p?(m=(0,Q.jsxs)(Fe,{open:d,onOpenChange:f,children:[i,p]}),t[33]=d,t[34]=i,t[35]=p,t[36]=m):m=t[36],y=m;break bb0}if(l){let n,i;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsx)(le,{className:`size-4 flex-shrink-0 text-muted-foreground`}),i=(0,Q.jsx)(Le,{className:`size-3 shrink-0 opacity-50`}),t[37]=n,t[38]=i):(n=t[37],i=t[38]);let s;t[39]!==a||t[40]!==d?(s=(0,Q.jsx)(X,{asChild:!0,children:(0,Q.jsxs)(W,{variant:`ghost`,size:`sm`,role:`combobox`,"aria-expanded":d,"aria-label":`Select model`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,disabled:a,children:[n,i]})}),t[39]=a,t[40]=d,t[41]=s):s=t[41];let l;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Q.jsx)(Oe,{placeholder:`Search model...`}),t[42]=l):l=t[42];let u;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Q.jsx)(Me,{children:`No model found.`}),t[43]=u):u=t[43];let p=(0,Q.jsxs)(Ie,{className:`max-h-[50vh] overflow-y-auto`,children:[u,Object.entries(e).map(e=>{let[t,n]=e;return(0,Q.jsx)(Pe,{heading:t,children:n.map(e=>(0,Q.jsxs)(Ae,{value:e.id,onSelect:()=>o(e.id),className:`justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{children:e.name}),(0,Q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:Mt(e.tier)})]}),(0,Q.jsx)(c,{className:v(`size-4`,r===e.id?`opacity-100`:`opacity-0`)})]},e.id))},t)})]}),m;t[44]===p?m=t[45]:(m=(0,Q.jsx)(Ne,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(Y,{children:[l,p]})}),t[44]=p,t[45]=m);let h;t[46]!==d||t[47]!==s||t[48]!==m?(h=(0,Q.jsxs)(Fe,{open:d,onOpenChange:f,children:[s,m]}),t[46]=d,t[47]=s,t[48]=m,t[49]=h):h=t[49],y=h;break bb0}g=Fe,T=d,E=f;let O;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Q.jsx)(le,{className:`size-4 flex-shrink-0 text-muted-foreground`}),t[50]=O):O=t[50];let k=(D==null?void 0:D.name)||`Select model`,A;t[51]===k?A=t[52]:(A=(0,Q.jsx)(`span`,{className:`truncate`,children:k}),t[51]=k,t[52]=A);let j;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,Q.jsx)(Le,{className:`size-3 shrink-0 opacity-50`}),t[53]=j):j=t[53],t[54]!==a||t[55]!==d||t[56]!==A?(_=(0,Q.jsx)(X,{asChild:!0,children:(0,Q.jsxs)(W,{variant:`ghost`,size:`sm`,role:`combobox`,"aria-expanded":d,"aria-label":`Select model`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,disabled:a,children:[O,A,j]})}),t[54]=a,t[55]=d,t[56]=A,t[57]=_):_=t[57],h=Ne,w=`w-[240px] p-0`,m=Y,t[58]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Q.jsx)(Oe,{placeholder:`Search model...`}),t[58]=C):C=t[58],p=Ie,b=`max-h-[50vh] overflow-y-auto`,t[59]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Q.jsx)(Me,{children:`No model found.`}),t[59]=x):x=t[59],S=Object.entries(e).map(e=>{let[t,n]=e;return(0,Q.jsx)(Pe,{heading:t,children:n.map(e=>(0,Q.jsxs)(Ae,{value:e.id,onSelect:()=>o(e.id),className:`justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{children:e.name}),(0,Q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:Mt(e.tier)})]}),(0,Q.jsx)(c,{className:v(`size-4`,r===e.id?`opacity-100`:`opacity-0`)})]},e.id))},t)})}t[0]=l,t[1]=a,t[2]=u,t[3]=n,t[4]=i,t[5]=d,t[6]=r,t[7]=p,t[8]=m,t[9]=h,t[10]=g,t[11]=_,t[12]=y,t[13]=b,t[14]=x,t[15]=S,t[16]=C,t[17]=w,t[18]=T,t[19]=E}else p=t[7],m=t[8],h=t[9],g=t[10],_=t[11],y=t[12],b=t[13],x=t[14],S=t[15],C=t[16],w=t[17],T=t[18],E=t[19];if(y!==Symbol.for(`react.early_return_sentinel`))return y;let D;t[60]!==p||t[61]!==b||t[62]!==x||t[63]!==S?(D=(0,Q.jsxs)(p,{className:b,children:[x,S]}),t[60]=p,t[61]=b,t[62]=x,t[63]=S,t[64]=D):D=t[64];let O;t[65]!==m||t[66]!==D||t[67]!==C?(O=(0,Q.jsxs)(m,{children:[C,D]}),t[65]=m,t[66]=D,t[67]=C,t[68]=O):O=t[68];let k;t[69]!==h||t[70]!==O||t[71]!==w?(k=(0,Q.jsx)(h,{className:w,children:O}),t[69]=h,t[70]=O,t[71]=w,t[72]=k):k=t[72];let A;return t[73]!==g||t[74]!==_||t[75]!==k||t[76]!==T||t[77]!==E?(A=(0,Q.jsxs)(g,{open:T,onOpenChange:E,children:[_,k]}),t[73]=g,t[74]=_,t[75]=k,t[76]=T,t[77]=E,t[78]=A):A=t[78],A}function Pt(e,t){return e[t.providerName]||(e[t.providerName]=[]),e[t.providerName].push(t),e}var Ft={low:`Low`,medium:`Medium`,high:`High`,xhigh:`X-High`,minimal:`Minimal`,max:`Max`};function It(e){return Ft[e]||e.charAt(0).toUpperCase()+e.slice(1)}function Lt(e){let t=(0,$.c)(69),{variants:n,selectedVariant:r,onChangeVariant:i,disabled:a,compact:o,iconOnly:s}=e,l=o===void 0?!1:o,u=s===void 0?!1:s,[d,f]=(0,Z.useState)(!1);if(!n||Object.keys(n).length===0)return null;let p,m,h,g,_,y,b;if(t[0]!==i||t[1]!==r||t[2]!==n){let e=Object.keys(n),a;t[10]===i?a=t[11]:(a=e=>{i(e===`__none__`?null:e),f(!1)},t[10]=i,t[11]=a);let o=a,s;t[12]===r?s=t[13]:(s=r?It(r):`Default`,t[12]=r,t[13]=s),h=s,m=Y,t[14]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Q.jsx)(Oe,{placeholder:`Search...`}),t[14]=b):b=t[14],p=Ie,g=`max-h-[50vh] overflow-y-auto`;let l;t[15]===o?l=t[16]:(l=()=>o(`__none__`),t[15]=o,t[16]=l);let u;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Q.jsx)(`span`,{children:`Default`}),t[17]=u):u=t[17];let d=r===null?`opacity-100`:`opacity-0`,x;t[18]===d?x=t[19]:(x=v(`size-4`,d),t[18]=d,t[19]=x);let S;t[20]===x?S=t[21]:(S=(0,Q.jsx)(c,{className:x}),t[20]=x,t[21]=S),t[22]!==S||t[23]!==l?(_=(0,Q.jsxs)(Ae,{value:`__none__`,onSelect:l,className:`justify-between`,children:[u,S]},`__none__`),t[22]=S,t[23]=l,t[24]=_):_=t[24],y=e.map(e=>(0,Q.jsxs)(Ae,{value:e,onSelect:()=>o(e),className:`justify-between`,children:[(0,Q.jsx)(`span`,{children:It(e)}),(0,Q.jsx)(c,{className:v(`size-4`,r===e?`opacity-100`:`opacity-0`)})]},e)),t[0]=i,t[1]=r,t[2]=n,t[3]=p,t[4]=m,t[5]=h,t[6]=g,t[7]=_,t[8]=y,t[9]=b}else p=t[3],m=t[4],h=t[5],g=t[6],_=t[7],y=t[8],b=t[9];let x;t[25]!==p||t[26]!==g||t[27]!==_||t[28]!==y?(x=(0,Q.jsxs)(p,{className:g,children:[_,y]}),t[25]=p,t[26]=g,t[27]=_,t[28]=y,t[29]=x):x=t[29];let S;t[30]!==m||t[31]!==b||t[32]!==x?(S=(0,Q.jsxs)(m,{children:[b,x]}),t[30]=m,t[31]=b,t[32]=x,t[33]=S):S=t[33];let C=S;if(u){let e;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(Ge,{className:`size-4 text-muted-foreground`}),t[34]=e):e=t[34];let n;t[35]!==a||t[36]!==d?(n=(0,Q.jsx)(X,{asChild:!0,children:(0,Q.jsx)(W,{variant:`ghost`,size:`icon-sm`,role:`combobox`,"aria-expanded":d,"aria-label":`Select variant`,disabled:a,children:e})}),t[35]=a,t[36]=d,t[37]=n):n=t[37];let r;t[38]===C?r=t[39]:(r=(0,Q.jsx)(Ne,{className:`w-[240px] p-0`,children:C}),t[38]=C,t[39]=r);let i;return t[40]!==d||t[41]!==n||t[42]!==r?(i=(0,Q.jsxs)(Fe,{open:d,onOpenChange:f,children:[n,r]}),t[40]=d,t[41]=n,t[42]=r,t[43]=i):i=t[43],i}if(l){let e,n;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsx)(Ge,{className:`size-4 flex-shrink-0 text-muted-foreground`}),e=(0,Q.jsx)(Le,{className:`size-3 shrink-0 opacity-50`}),t[44]=e,t[45]=n):(e=t[44],n=t[45]);let r;t[46]!==a||t[47]!==d?(r=(0,Q.jsx)(X,{asChild:!0,children:(0,Q.jsxs)(W,{variant:`ghost`,size:`sm`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,role:`combobox`,"aria-expanded":d,"aria-label":`Select variant`,disabled:a,children:[n,e]})}),t[46]=a,t[47]=d,t[48]=r):r=t[48];let i;t[49]===C?i=t[50]:(i=(0,Q.jsx)(Ne,{className:`w-[240px] p-0`,children:C}),t[49]=C,t[50]=i);let o;return t[51]!==d||t[52]!==r||t[53]!==i?(o=(0,Q.jsxs)(Fe,{open:d,onOpenChange:f,children:[r,i]}),t[51]=d,t[52]=r,t[53]=i,t[54]=o):o=t[54],o}let w;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Q.jsx)(Ge,{className:`size-4 flex-shrink-0 text-muted-foreground`}),t[55]=w):w=t[55];let T;t[56]===h?T=t[57]:(T=(0,Q.jsx)(`span`,{className:`truncate`,children:h}),t[56]=h,t[57]=T);let E;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Q.jsx)(Le,{className:`size-3 shrink-0 opacity-50`}),t[58]=E):E=t[58];let D;t[59]!==a||t[60]!==d||t[61]!==T?(D=(0,Q.jsx)(X,{asChild:!0,children:(0,Q.jsxs)(W,{variant:`ghost`,size:`sm`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,role:`combobox`,"aria-expanded":d,"aria-label":`Select variant`,disabled:a,children:[w,T,E]})}),t[59]=a,t[60]=d,t[61]=T,t[62]=D):D=t[62];let O;t[63]===C?O=t[64]:(O=(0,Q.jsx)(Ne,{className:`w-[240px] p-0`,children:C}),t[63]=C,t[64]=O);let k;return t[65]!==d||t[66]!==D||t[67]!==O?(k=(0,Q.jsxs)(Fe,{open:d,onOpenChange:f,children:[D,O]}),t[65]=d,t[66]=D,t[67]=O,t[68]=k):k=t[68],k}function Rt(e){let t=(0,$.c)(66),{preconfigs:n,selectedPreconfigId:r,onChangePreconfig:i,disabled:a,compact:o,iconOnly:s}=e,l=o===void 0?!1:o,u=s===void 0?!1:s,[d,f]=(0,Z.useState)(!1),p;if(t[0]!==n||t[1]!==r){let e;t[3]===r?e=t[4]:(e=e=>e.id===r,t[3]=r,t[4]=e),p=n.find(e),t[0]=n,t[1]=r,t[2]=p}else p=t[2];let m=p,h;t[5]===i?h=t[6]:(h=e=>{i(e),f(!1)},t[5]=i,t[6]=h);let g=h;if(u){let e;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(fe,{className:`size-4 text-muted-foreground`}),t[7]=e):e=t[7];let i;t[8]!==a||t[9]!==d?(i=(0,Q.jsx)(X,{asChild:!0,children:(0,Q.jsx)(W,{variant:`ghost`,size:`icon-sm`,role:`combobox`,"aria-expanded":d,"aria-label":`Select config`,disabled:a,children:e})}),t[8]=a,t[9]=d,t[10]=i):i=t[10];let o;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Q.jsx)(Oe,{placeholder:`Search config...`}),t[11]=o):o=t[11];let s;if(t[12]!==g||t[13]!==n||t[14]!==r){let e;t[16]!==g||t[17]!==r?(e=e=>(0,Q.jsxs)(Ae,{onSelect:()=>g(e.id),className:`justify-between`,children:[(0,Q.jsxs)(`span`,{children:[e.name,e.isDefault&&(0,Q.jsx)(`span`,{className:`ml-1 text-muted-foreground text-xs`,children:`(default)`})]}),(0,Q.jsx)(c,{className:v(`size-4`,r===e.id?`opacity-100`:`opacity-0`)})]},e.id),t[16]=g,t[17]=r,t[18]=e):e=t[18],s=n.map(e),t[12]=g,t[13]=n,t[14]=r,t[15]=s}else s=t[15];let l;t[19]===s?l=t[20]:(l=(0,Q.jsx)(Ne,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(Y,{children:[o,(0,Q.jsx)(Ie,{className:`max-h-[50vh] overflow-y-auto`,children:s})]})}),t[19]=s,t[20]=l);let u;return t[21]!==d||t[22]!==i||t[23]!==l?(u=(0,Q.jsxs)(Fe,{open:d,onOpenChange:f,children:[i,l]}),t[21]=d,t[22]=i,t[23]=l,t[24]=u):u=t[24],u}if(l){let e,i;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(fe,{className:`size-4 flex-shrink-0 text-muted-foreground`}),i=(0,Q.jsx)(Le,{className:`size-3 shrink-0 opacity-50`}),t[25]=e,t[26]=i):(e=t[25],i=t[26]);let o;t[27]!==a||t[28]!==d?(o=(0,Q.jsx)(X,{asChild:!0,children:(0,Q.jsxs)(W,{variant:`ghost`,size:`sm`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,role:`combobox`,"aria-expanded":d,"aria-label":`Select config`,disabled:a,children:[e,i]})}),t[27]=a,t[28]=d,t[29]=o):o=t[29];let s;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsx)(Oe,{placeholder:`Search config...`}),t[30]=s):s=t[30];let l;if(t[31]!==g||t[32]!==n||t[33]!==r){let e;t[35]!==g||t[36]!==r?(e=e=>(0,Q.jsxs)(Ae,{onSelect:()=>g(e.id),className:`justify-between`,children:[(0,Q.jsxs)(`span`,{children:[e.name,e.isDefault&&(0,Q.jsx)(`span`,{className:`ml-1 text-muted-foreground text-xs`,children:`(default)`})]}),(0,Q.jsx)(c,{className:v(`size-4`,r===e.id?`opacity-100`:`opacity-0`)})]},e.id),t[35]=g,t[36]=r,t[37]=e):e=t[37],l=n.map(e),t[31]=g,t[32]=n,t[33]=r,t[34]=l}else l=t[34];let u;t[38]===l?u=t[39]:(u=(0,Q.jsx)(Ne,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(Y,{children:[s,(0,Q.jsx)(Ie,{className:`max-h-[50vh] overflow-y-auto`,children:l})]})}),t[38]=l,t[39]=u);let p;return t[40]!==d||t[41]!==u||t[42]!==o?(p=(0,Q.jsxs)(Fe,{open:d,onOpenChange:f,children:[o,u]}),t[40]=d,t[41]=u,t[42]=o,t[43]=p):p=t[43],p}let _;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Q.jsx)(fe,{className:`size-4 flex-shrink-0 text-muted-foreground`}),t[44]=_):_=t[44];let y=(m==null?void 0:m.name)||`Select config`,b;t[45]===y?b=t[46]:(b=(0,Q.jsx)(`span`,{className:`truncate`,children:y}),t[45]=y,t[46]=b);let x;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Q.jsx)(Le,{className:`size-3 shrink-0 opacity-50`}),t[47]=x):x=t[47];let S;t[48]!==a||t[49]!==d||t[50]!==b?(S=(0,Q.jsx)(X,{asChild:!0,children:(0,Q.jsxs)(W,{variant:`ghost`,size:`sm`,className:`h-8 gap-1.5 px-2 text-muted-foreground hover:bg-accent`,role:`combobox`,"aria-expanded":d,"aria-label":`Select config`,disabled:a,children:[_,b,x]})}),t[48]=a,t[49]=d,t[50]=b,t[51]=S):S=t[51];let C;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Q.jsx)(Oe,{placeholder:`Search config...`}),t[52]=C):C=t[52];let w;if(t[53]!==g||t[54]!==n||t[55]!==r){let e;t[57]!==g||t[58]!==r?(e=e=>(0,Q.jsxs)(Ae,{onSelect:()=>g(e.id),className:`justify-between`,children:[(0,Q.jsxs)(`span`,{children:[e.name,e.isDefault&&(0,Q.jsx)(`span`,{className:`ml-1 text-muted-foreground text-xs`,children:`(default)`})]}),(0,Q.jsx)(c,{className:v(`size-4`,r===e.id?`opacity-100`:`opacity-0`)})]},e.id),t[57]=g,t[58]=r,t[59]=e):e=t[59],w=n.map(e),t[53]=g,t[54]=n,t[55]=r,t[56]=w}else w=t[56];let T;t[60]===w?T=t[61]:(T=(0,Q.jsx)(Ne,{className:`w-[240px] p-0`,children:(0,Q.jsxs)(Y,{children:[C,(0,Q.jsx)(Ie,{className:`max-h-[50vh] overflow-y-auto`,children:w})]})}),t[60]=w,t[61]=T);let E;return t[62]!==d||t[63]!==T||t[64]!==S?(E=(0,Q.jsxs)(Fe,{open:d,onOpenChange:f,children:[S,T]}),t[62]=d,t[63]=T,t[64]=S,t[65]=E):E=t[65],E}function zt(e){switch(e){case`uncontrolled`:return{icon:G,tooltip:`No active controller`,label:`No client currently controls this session.`,ariaLabel:`Session control: no active controller`,variant:`ghost`,iconClass:`text-muted-foreground/60`};case`controller`:return{icon:G,tooltip:`You control this session`,label:`You are controlling this session.`,ariaLabel:`Session control: you control this session`,variant:`ghost`,iconClass:`text-muted-foreground`};case`observer`:return{icon:we,tooltip:`Controlled on another device`,label:`Another client is controlling this session.`,ariaLabel:`Session control: controlled on another device`,variant:`ghost`,iconClass:`text-muted-foreground`};case`takeover_controller`:return{icon:et,tooltip:`Another client requested control`,label:`Another client wants to take control of this session.`,ariaLabel:`Session control: takeover requested`,variant:`ghost`,iconClass:`text-orange-500`};case`takeover_requester`:return{icon:et,tooltip:`Takeover request pending`,label:`Your control request is waiting for approval.`,ariaLabel:`Session control: takeover request pending`,variant:`ghost`,iconClass:`text-orange-500`};case`grace`:return{icon:lt,tooltip:`Waiting for previous controller to reconnect`,label:`The previous controller may still reconnect.`,ariaLabel:`Session control: waiting for reconnect`,variant:`ghost`,iconClass:`text-yellow-500`}}}function Bt(e){let t=(0,$.c)(54),{uiState:n,sessionId:r,pendingRequesterClientId:i,onClaimControl:a,onReleaseControl:o,onRequestTakeover:s,onRespondTakeover:c}=e,l;t[0]===n?l=t[1]:(l=zt(n),t[0]=n,t[1]=l);let u=l,d=u.icon;if(!(n===`uncontrolled`&&a||n===`controller`&&o||n===`observer`&&s||n===`takeover_controller`&&c)){let e=`size-4 ${u.iconClass}`,n;t[2]!==d||t[3]!==e?(n=(0,Q.jsx)(d,{className:e}),t[2]=d,t[3]=e,t[4]=n):n=t[4];let r;t[5]!==u.ariaLabel||t[6]!==n?(r=(0,Q.jsx)(T,{asChild:!0,children:(0,Q.jsx)(W,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0 hover:bg-accent`,"aria-label":u.ariaLabel,children:n})}),t[5]=u.ariaLabel,t[6]=n,t[7]=r):r=t[7];let i;t[8]===u.tooltip?i=t[9]:(i=(0,Q.jsx)(P,{children:u.tooltip}),t[8]=u.tooltip,t[9]=i);let a;return t[10]!==r||t[11]!==i?(a=(0,Q.jsxs)(C,{children:[r,i]}),t[10]=r,t[11]=i,t[12]=a):a=t[12],a}let f=`size-4 ${u.iconClass}`,p;t[13]!==d||t[14]!==f?(p=(0,Q.jsx)(d,{className:f}),t[13]=d,t[14]=f,t[15]=p):p=t[15];let m;t[16]!==u.ariaLabel||t[17]!==u.variant||t[18]!==p?(m=(0,Q.jsx)(T,{asChild:!0,children:(0,Q.jsx)(S,{asChild:!0,children:(0,Q.jsx)(W,{variant:u.variant,size:`sm`,className:`h-8 w-8 p-0 hover:bg-accent`,"aria-label":u.ariaLabel,children:p})})}),t[16]=u.ariaLabel,t[17]=u.variant,t[18]=p,t[19]=m):m=t[19];let h;t[20]===u.tooltip?h=t[21]:(h=(0,Q.jsx)(P,{children:u.tooltip}),t[20]=u.tooltip,t[21]=h);let g;t[22]!==m||t[23]!==h?(g=(0,Q.jsxs)(C,{children:[m,h]}),t[22]=m,t[23]=h,t[24]=g):g=t[24];let v;t[25]===u.label?v=t[26]:(v=(0,Q.jsx)(A,{children:u.label}),t[25]=u.label,t[26]=v);let y;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Q.jsx)(B,{}),t[27]=y):y=t[27];let x;t[28]!==a||t[29]!==r||t[30]!==n?(x=n===`uncontrolled`&&a&&(0,Q.jsxs)(b,{onClick:()=>a(r),children:[(0,Q.jsx)(G,{className:`size-4`}),`Claim control`]}),t[28]=a,t[29]=r,t[30]=n,t[31]=x):x=t[31];let w;t[32]!==o||t[33]!==r||t[34]!==n?(w=n===`controller`&&o&&(0,Q.jsxs)(b,{onClick:()=>o(r),children:[(0,Q.jsx)(G,{className:`size-4`}),`Release control`]}),t[32]=o,t[33]=r,t[34]=n,t[35]=w):w=t[35];let E;t[36]!==s||t[37]!==r||t[38]!==n?(E=n===`observer`&&s&&(0,Q.jsxs)(b,{onClick:()=>s(r),children:[(0,Q.jsx)(et,{className:`size-4`}),`Request control`]}),t[36]=s,t[37]=r,t[38]=n,t[39]=E):E=t[39];let D;t[40]!==c||t[41]!==i||t[42]!==r||t[43]!==n?(D=n===`takeover_controller`&&c&&i&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(b,{onClick:()=>c(r,i,`approve`),children:[(0,Q.jsx)(G,{className:`size-4 text-green-600`}),`Approve`]}),(0,Q.jsxs)(b,{variant:`destructive`,onClick:()=>c(r,i,`deny`),children:[(0,Q.jsx)(G,{className:`size-4`}),`Deny`]})]}),t[40]=c,t[41]=i,t[42]=r,t[43]=n,t[44]=D):D=t[44];let O;t[45]!==w||t[46]!==E||t[47]!==D||t[48]!==v||t[49]!==x?(O=(0,Q.jsxs)(R,{align:`end`,sideOffset:4,className:`w-56`,children:[v,y,x,w,E,D]}),t[45]=w,t[46]=E,t[47]=D,t[48]=v,t[49]=x,t[50]=O):O=t[50];let k;return t[51]!==O||t[52]!==g?(k=(0,Q.jsxs)(_,{children:[g,O]}),t[51]=O,t[52]=g,t[53]=k):k=t[53],k}function Vt(e,t){return!e||e===`uncontrolled`?`uncontrolled`:e===`grace`?`grace`:e===`takeover_requested`?t?`takeover_controller`:`takeover_requester`:e===`controlled`?t?`controller`:`observer`:`uncontrolled`}function Ht(e){var t;let n=(0,$.c)(110),{session:r,preconfigs:i,models:a,usage:o,modelName:s,onChangePreconfig:c,onChangeModel:l,onChangeVariant:u,onRename:f,onNavigateBack:p,isStreaming:m,onInterrupt:g,onCompact:_,isCompacting:v,canCompact:y,selectedVariant:b,variants:x,onClaimControl:S,onReleaseControl:w,onRequestTakeover:E,onRespondTakeover:D}=e,[O,k]=(0,Z.useState)(!1),[A,M]=(0,Z.useState)(r.title||``),N=(0,Z.useRef)(null),F=d(),I=ne(),L;n[0]===r.id?L=n[1]:(L=e=>e.controlBySessionId[r.id],n[0]=r.id,n[1]=L);let R=ue(L),z=ge(Ut),B=(R==null?void 0:R.status)===`controlled`||(R==null?void 0:R.status)===`takeover_requested`,te=B&&R.controllerClientId===z,V=B&&R.controllerClientId!==z,H=R==null?void 0:R.status,U;n[2]!==te||n[3]!==H?(U=Vt(H,te),n[2]=te,n[3]=H,n[4]=U):U=n[4];let re=U,G,K;n[5]===O?(G=n[6],K=n[7]):(G=()=>{O&&N.current&&(N.current.focus(),N.current.select())},K=[O],n[5]=O,n[6]=G,n[7]=K),(0,Z.useEffect)(G,K);let ae;n[8]===r.title?ae=n[9]:(ae=()=>{M(r.title||``),k(!0)},n[8]=r.title,n[9]=ae);let se=ae,ce;n[10]!==A||n[11]!==f||n[12]!==r.id||n[13]!==r.title?(ce=()=>{let e=A.trim();e&&e!==r.title&&f(r.id,e),k(!1)},n[10]=A,n[11]=f,n[12]=r.id,n[13]=r.title,n[14]=ce):ce=n[14];let q=ce,le;n[15]!==q||n[16]!==r.title?(le=e=>{e.key===`Enter`?q():e.key===`Escape`&&(M(r.title||``),k(!1))},n[15]=q,n[16]=r.title,n[17]=le):le=n[17];let de=le,fe;if(n[18]!==s||n[19]!==i||n[20]!==r.preconfigId||n[21]!==r.selectedModel){var pe;fe=r.selectedModel||((pe=i.find(e=>e.id===r.preconfigId))==null?void 0:pe.model)||s,n[18]=s,n[19]=i,n[20]=r.preconfigId,n[21]=r.selectedModel,n[22]=fe}else fe=n[22];let me=fe,he;if(n[23]!==a||n[24]!==me){let e;n[26]===me?e=n[27]:(e=e=>e.id===me,n[26]=me,n[27]=e),he=a.find(e),n[23]=a,n[24]=me,n[25]=he}else he=n[25];let _e=he,ve=_e==null?void 0:_e.contextWindow,ye;n[28]!==p||n[29]!==r.parentId?(ye=r.parentId&&p&&(0,Q.jsxs)(W,{variant:`ghost`,size:`sm`,onClick:p,className:`h-7`,children:[(0,Q.jsx)(oe,{className:`size-4`,"data-icon":`inline-start`}),`Back`]}),n[28]=p,n[29]=r.parentId,n[30]=ye):ye=n[30];let be;n[31]!==A||n[32]!==de||n[33]!==se||n[34]!==q||n[35]!==O||n[36]!==r.title?(be=O?(0,Q.jsx)(`input`,{ref:N,type:`text`,value:A,onChange:e=>M(e.target.value),onBlur:q,onKeyDown:de,className:`text-base font-semibold bg-background border border-primary rounded px-2 py-0.5 outline-none min-w-0 flex-1`,autoFocus:!0}):(0,Q.jsx)(`h2`,{className:`text-base font-semibold cursor-pointer px-2 py-0.5 -mx-2 rounded hover:bg-accent transition-colors truncate min-w-0`,onDoubleClick:se,children:r.title||`Untitled Session`}),n[31]=A,n[32]=de,n[33]=se,n[34]=q,n[35]=O,n[36]=r.title,n[37]=be):be=n[37];let xe;n[38]!==ve||n[39]!==F||n[40]!==s||n[41]!==o.completionTokens||n[42]!==o.promptTokens||n[43]!==o.totalTokens?(xe=(0,Q.jsx)(jt,{promptTokens:o.promptTokens,completionTokens:o.completionTokens,totalTokens:o.totalTokens,contextWindow:ve,modelName:s,compact:F}),n[38]=ve,n[39]=F,n[40]=s,n[41]=o.completionTokens,n[42]=o.promptTokens,n[43]=o.totalTokens,n[44]=xe):xe=n[44];let Se;n[45]===r.status?Se=n[46]:(Se=r.status===`closed`&&(0,Q.jsxs)(ee,{variant:`secondary`,children:[(0,Q.jsx)(ie,{className:`size-3`,"data-icon":`inline-start`}),`Archived`]}),n[45]=r.status,n[46]=Se);let J;n[47]!==ye||n[48]!==be||n[49]!==xe||n[50]!==Se?(J=(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[ye,be,xe,Se]}),n[47]=ye,n[48]=be,n[49]=xe,n[50]=Se,n[51]=J):J=n[51];let Ce;n[52]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=(0,Q.jsx)(h,{className:`md:hidden`}),n[52]=Ce):Ce=n[52];let we=r.status===`closed`||!!r.parentId||V,Te;n[53]!==I||n[54]!==F||n[55]!==a||n[56]!==l||n[57]!==me||n[58]!==we?(Te=(0,Q.jsx)(Nt,{models:a,selectedModelId:me,onChangeModel:l,disabled:we,iconOnly:F,compact:I}),n[53]=I,n[54]=F,n[55]=a,n[56]=l,n[57]=me,n[58]=we,n[59]=Te):Te=n[59];let Ee=r.status===`closed`||!!r.parentId||V,Y;n[60]!==I||n[61]!==F||n[62]!==u||n[63]!==b||n[64]!==Ee||n[65]!==x?(Y=(0,Q.jsx)(Lt,{variants:x,selectedVariant:b,onChangeVariant:u,disabled:Ee,iconOnly:F,compact:I}),n[60]=I,n[61]=F,n[62]=u,n[63]=b,n[64]=Ee,n[65]=x,n[66]=Y):Y=n[66];let De=r.status===`closed`||!!r.parentId||V,Oe;n[67]!==I||n[68]!==F||n[69]!==c||n[70]!==i||n[71]!==r.preconfigId||n[72]!==De?(Oe=(0,Q.jsx)(Rt,{preconfigs:i,selectedPreconfigId:r.preconfigId,onChangePreconfig:c,disabled:De,iconOnly:F,compact:I}),n[67]=I,n[68]=F,n[69]=c,n[70]=i,n[71]=r.preconfigId,n[72]=De,n[73]=Oe):Oe=n[73];let ke;n[74]===Symbol.for(`react.memo_cache_sentinel`)?(ke=(0,Q.jsx)(h,{orientation:`vertical`,className:`hidden md:block`}),n[74]=ke):ke=n[74];let X;if(n[75]!==(R==null||(t=R.pendingTakeover)==null?void 0:t.requestedByClientId)||n[76]!==re||n[77]!==z||n[78]!==S||n[79]!==w||n[80]!==E||n[81]!==D||n[82]!==r.id){var Ae,je;X=z&&(0,Q.jsx)(Bt,{uiState:re,sessionId:r.id,pendingRequesterClientId:R==null||(Ae=R.pendingTakeover)==null?void 0:Ae.requestedByClientId,onClaimControl:S,onReleaseControl:w,onRequestTakeover:E,onRespondTakeover:D}),n[75]=R==null||(je=R.pendingTakeover)==null?void 0:je.requestedByClientId,n[76]=re,n[77]=z,n[78]=S,n[79]=w,n[80]=E,n[81]=D,n[82]=r.id,n[83]=X}else X=n[83];let Me;n[84]!==y||n[85]!==v||n[86]!==m||n[87]!==_?(Me=_&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(C,{children:[(0,Q.jsx)(T,{asChild:!0,children:(0,Q.jsx)(W,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0 text-muted-foreground hover:bg-accent`,onClick:_,disabled:m||v||!y,children:(0,Q.jsx)(rt,{className:`size-4`})})}),(0,Q.jsx)(P,{children:v?`Compacting...`:`Compact older messages`})]}),(0,Q.jsx)(h,{orientation:`vertical`,className:`hidden md:block`})]}),n[84]=y,n[85]=v,n[86]=m,n[87]=_,n[88]=Me):Me=n[88];let Ne=m?`destructive`:`ghost`,Pe=`h-8 w-8 p-0 hover:bg-accent${m?``:` text-muted-foreground opacity-60 hover:opacity-100`}`,Fe=!g||V,Ie;n[89]===Symbol.for(`react.memo_cache_sentinel`)?(Ie=(0,Q.jsx)(ze,{className:`size-4`}),n[89]=Ie):Ie=n[89];let Le;n[90]!==g||n[91]!==Ne||n[92]!==Pe||n[93]!==Fe?(Le=(0,Q.jsx)(T,{asChild:!0,children:(0,Q.jsx)(W,{variant:Ne,size:`sm`,className:Pe,onClick:g,disabled:Fe,children:Ie})}),n[90]=g,n[91]=Ne,n[92]=Pe,n[93]=Fe,n[94]=Le):Le=n[94];let Re=m?`Interrupt operation`:`Interrupt`,Be;n[95]===Re?Be=n[96]:(Be=(0,Q.jsx)(P,{children:Re}),n[95]=Re,n[96]=Be);let Ve;n[97]!==Le||n[98]!==Be?(Ve=(0,Q.jsxs)(C,{children:[Le,Be]}),n[97]=Le,n[98]=Be,n[99]=Ve):Ve=n[99];let He;n[100]!==Te||n[101]!==Y||n[102]!==Oe||n[103]!==X||n[104]!==Me||n[105]!==Ve?(He=(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 sm:gap-4 flex-wrap md:flex-nowrap shrink-0`,children:[Te,Y,Oe,ke,X,Me,Ve]}),n[100]=Te,n[101]=Y,n[102]=Oe,n[103]=X,n[104]=Me,n[105]=Ve,n[106]=He):He=n[106];let Ue;return n[107]!==J||n[108]!==He?(Ue=(0,Q.jsx)(`header`,{className:`flex flex-col border-b border-border bg-card`,children:(0,Q.jsx)(j,{delayDuration:300,children:(0,Q.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center md:justify-between px-4 py-1 gap-1`,children:[J,Ce,He]})})}),n[107]=J,n[108]=He,n[109]=Ue):Ue=n[109],Ue}function Ut(e){return e.clientId}function Wt(e){let t=(0,$.c)(25),{prompts:n,query:r,selectedIndex:i,onSelect:a}=e,o,s,c,l;if(t[0]!==a||t[1]!==n||t[2]!==r||t[3]!==i){l=Symbol.for(`react.early_return_sentinel`);bb0:{let e;if(t[8]===r?e=t[9]:(e=e=>e.name.toLowerCase().includes(r.toLowerCase()),t[8]=r,t[9]=e),o=n.filter(e),o.length===0){let e;t[10]===r?e=t[11]:(e=(0,Q.jsxs)(`div`,{className:`p-2 text-xs text-muted-foreground`,children:[`No prompts matching "/`,r,`"`]}),t[10]=r,t[11]=e),l=e;break bb0}s=`p-1`;let u;t[12]!==a||t[13]!==i?(u=(e,t)=>(0,Q.jsxs)(`button`,{onClick:()=>a(e),className:v(`flex items-center gap-2 w-full px-2 py-1.5 rounded text-sm text-left`,`hover:bg-muted`,t===i&&`bg-primary/20 text-primary font-medium ring-1 ring-primary/50`),children:[(0,Q.jsx)(nt,{className:`w-4 h-4 text-muted-foreground flex-shrink-0`}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`font-mono text-xs`,children:[`/`,e.name]}),(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:e.description})]})]},e.name),t[12]=a,t[13]=i,t[14]=u):u=t[14],c=o.map(u)}t[0]=a,t[1]=n,t[2]=r,t[3]=i,t[4]=o,t[5]=s,t[6]=c,t[7]=l}else o=t[4],s=t[5],c=t[6],l=t[7];if(l!==Symbol.for(`react.early_return_sentinel`))return l;let u=o.length===1?``:`s`,d;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Q.jsx)(`kbd`,{className:`ml-1 px-1 py-0.5 bg-muted rounded text-[10px]`,children:`↑↓`}),t[15]=d):d=t[15];let f;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Q.jsx)(`kbd`,{className:`ml-1 px-1 py-0.5 bg-muted rounded text-[10px]`,children:`↵`}),t[16]=f):f=t[16];let p;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Q.jsx)(`kbd`,{className:`ml-1 px-1 py-0.5 bg-muted rounded text-[10px]`,children:`esc`}),t[17]=p):p=t[17];let m;t[18]!==o.length||t[19]!==u?(m=(0,Q.jsxs)(`div`,{className:`mt-1 pt-1 border-t text-xs text-muted-foreground px-2`,children:[o.length,` prompt`,u,` •`,d,` navigate`,f,` select`,p,` close`]}),t[18]=o.length,t[19]=u,t[20]=m):m=t[20];let h;return t[21]!==s||t[22]!==c||t[23]!==m?(h=(0,Q.jsxs)(`div`,{className:s,children:[c,m]}),t[21]=s,t[22]=c,t[23]=m,t[24]=h):h=t[24],h}function Gt(e){let t=(0,$.c)(26),{id:n,kind:r,filename:i,size:a,previewUrl:o,isUploading:s,onRemove:c}=e,l=s&&`opacity-50`,u;t[0]===l?u=t[1]:(u=v(`flex items-center gap-2 px-2 py-1.5 bg-muted rounded-lg border border-border max-w-[180px]`,l),t[0]=l,t[1]=u);let d;t[2]!==i||t[3]!==r||t[4]!==o?(d=r===`image`&&o?(0,Q.jsx)(`img`,{src:o,alt:i,className:`size-8 rounded object-cover shrink-0`}):r===`image`?(0,Q.jsx)(tt,{className:`size-4 text-muted-foreground shrink-0`}):(0,Q.jsx)(pe,{className:`size-4 text-muted-foreground shrink-0`}),t[2]=i,t[3]=r,t[4]=o,t[5]=d):d=t[5];let f;t[6]===i?f=t[7]:(f=(0,Q.jsx)(`div`,{className:`text-xs truncate`,children:i}),t[6]=i,t[7]=f);let p;t[8]===a?p=t[9]:(p=Kt(a),t[8]=a,t[9]=p);let m;t[10]===p?m=t[11]:(m=(0,Q.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:p}),t[10]=p,t[11]=m);let h;t[12]!==f||t[13]!==m?(h=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[f,m]}),t[12]=f,t[13]=m,t[14]=h):h=t[14];let _;t[15]!==n||t[16]!==c?(_=()=>c(n),t[15]=n,t[16]=c,t[17]=_):_=t[17];let y;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Q.jsx)(g,{className:`size-3 text-muted-foreground`}),t[18]=y):y=t[18];let b;t[19]===_?b=t[20]:(b=(0,Q.jsx)(`button`,{type:`button`,onClick:_,className:`shrink-0 p-0.5 hover:bg-accent rounded`,children:y}),t[19]=_,t[20]=b);let x;return t[21]!==b||t[22]!==u||t[23]!==d||t[24]!==h?(x=(0,Q.jsxs)(`div`,{className:u,children:[d,h,b]}),t[21]=b,t[22]=u,t[23]=d,t[24]=h,t[25]=x):x=t[25],x}function Kt(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function qt(e){let t=(0,$.c)(28),{path:n,onRemove:r,onPreview:i}=e,a;t[0]===n?a=t[1]:(a=n.split(`/`).pop()||n,t[0]=n,t[1]=a);let o=a,s;t[2]===n?s=t[3]:(s=n.slice(0,n.lastIndexOf(`/`)+1),t[2]=n,t[3]=s);let c=s,l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,Q.jsx)(pe,{className:`size-4 text-primary shrink-0`}),t[4]=l):l=t[4];let u;t[5]!==i||t[6]!==n?(u=()=>i==null?void 0:i(n),t[5]=i,t[6]=n,t[7]=u):u=t[7];let d;t[8]===c?d=t[9]:(d=(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:c}),t[8]=c,t[9]=d);let f;t[10]===o?f=t[11]:(f=(0,Q.jsx)(`span`,{children:o}),t[10]=o,t[11]=f);let p;t[12]!==d||t[13]!==f?(p=(0,Q.jsxs)(`div`,{className:`text-xs truncate`,children:[d,f]}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let m;t[15]!==u||t[16]!==p?(m=(0,Q.jsx)(`button`,{type:`button`,onClick:u,className:`min-w-0 flex-1 text-left cursor-pointer`,children:p}),t[15]=u,t[16]=p,t[17]=m):m=t[17];let h;t[18]!==r||t[19]!==n?(h=()=>r(n),t[18]=r,t[19]=n,t[20]=h):h=t[20];let _=`Remove ${o}`,v;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Q.jsx)(g,{className:`size-3 text-muted-foreground`}),t[21]=v):v=t[21];let y;t[22]!==_||t[23]!==h?(y=(0,Q.jsx)(`button`,{type:`button`,onClick:h,"aria-label":_,className:`shrink-0 p-0.5 hover:bg-accent rounded`,children:v}),t[22]=_,t[23]=h,t[24]=y):y=t[24];let b;return t[25]!==y||t[26]!==m?(b=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 bg-primary/15 rounded-lg border border-primary/30 max-w-[220px]`,children:[l,m,y]}),t[25]=y,t[26]=m,t[27]=b):b=t[27],b}function Jt(e){let t=(0,$.c)(11),{debounceMs:n}=e,[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(!1),s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=[],t[0]=s):s=t[0];let[c,l]=(0,Z.useState)(s),u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=e=>{let t={type:`file`,path:e.path,display:e.name};return l(e=>[...e,t]),o(!1),i(``),t},t[1]=u):u=t[1];let d=u,f=Yt,p;t[2]===c?p=t[3]:(p=e=>{let t=/@([^\s@]+)/g,n=[],r;for(;(r=t.exec(e))!==null;){let e=r[1];c.some(t=>t.path===e)&&!n.some(t=>t.path===e)&&n.push({type:`file`,path:e,display:e.split(`/`).pop()||e})}return n},t[2]=c,t[3]=p);let m=p,h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>l([]),t[4]=h):h=t[4];let g;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(g=e=>{l(t=>t.filter(t=>t.path!==e))},t[5]=g):g=t[5];let _;return t[6]!==m||t[7]!==c||t[8]!==r||t[9]!==a?(_={query:r,setQuery:i,showAutocomplete:a,setShowAutocomplete:o,mentions:c,handleFileSelect:d,insertMention:f,extractMentions:m,clearMentions:h,removeMention:g},t[6]=m,t[7]=c,t[8]=r,t[9]=a,t[10]=_):_=t[10],_}function Yt(e,t,n){let r=e.lastIndexOf(`@`,t);return r===-1?{text:e,cursorPos:t}:{text:e.slice(0,r)+`@${n.path}`+e.slice(t),cursorPos:r+n.path.length+1}}function Xt(e){return`${s}${e}`}function Zt(e,t){if(!(typeof window>`u`))try{localStorage.setItem(Xt(e),JSON.stringify({text:t,updatedAt:Date.now()}))}catch(e){console.warn(`Error saving draft:`,e)}}function Qt(e){if(typeof window>`u`)return``;try{let t=localStorage.getItem(Xt(e));if(t===null)return``;let n=JSON.parse(t);return typeof n.text!=`string`||typeof n.updatedAt!=`number`||Date.now()-n.updatedAt>2592e6?(localStorage.removeItem(Xt(e)),``):n.text}catch{return``}}function $t(e){if(!(typeof window>`u`))try{localStorage.removeItem(Xt(e))}catch(e){console.warn(`Error clearing draft:`,e)}}function en(){k()}function tn(e){let t=(0,$.c)(12),[n,r]=(0,Z.useState)(``),i=(0,Z.useRef)(void 0),a=(0,Z.useRef)(``),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=[],t[0]=o):o=t[0],(0,Z.useEffect)(nn,o);let s;t[1]===e?s=t[2]:(s=t=>{r(t),a.current=t,e!==void 0&&(t===``?$t(e):Zt(e,t))},t[1]=e,t[2]=s);let c=s,l;t[3]===e?l=t[4]:(l=()=>{r(``),a.current=``,e!==void 0&&$t(e)},t[3]=e,t[4]=l);let u=l,d,f;t[5]===e?(d=t[6],f=t[7]):(d=()=>{let t=i.current;if(t!==void 0&&t!==e){let e=a.current;e!==``&&Zt(t,e)}if(e!==void 0){let t=Qt(e);a.current=t,r(t)}else a.current=``,r(``);i.current=e},f=[e],t[5]=e,t[6]=d,t[7]=f),(0,Z.useEffect)(d,f);let p;return t[8]!==u||t[9]!==n||t[10]!==c?(p={input:n,setInput:c,clearInput:u},t[8]=u,t[9]=n,t[10]=c,t[11]=p):p=t[11],p}function nn(){en()}function rn(e,t){return t?e.content.includes(`ARG`)?e.content.replace(`ARG`,t):`${e.content}\n${t}`:e.content}function an(e){let t=e.trimStart();if(!t.startsWith(`/`))return null;let n=t.indexOf(` `);return n===-1?{command:t.slice(1),rest:``}:{command:t.slice(1,n),rest:t.slice(n+1).trim()}}var on=(0,Z.forwardRef)(function({onSendMessage:e,disabled:t,isStreaming:n,onStopStreaming:r,placeholder:i=`Type a message...`,workspaceId:a,sdkClient:o,prompts:s=[],sessionId:c,modelSupportsImage:l},u){let{input:d,setInput:f,clearInput:p}=tn(c),[m,h]=(0,Z.useState)(0),[g,_]=(0,Z.useState)([]),[y,b]=(0,Z.useState)(0),[x,S]=(0,Z.useState)(`none`),[C,w]=(0,Z.useState)(``),[T,E]=(0,Z.useState)([]),[D,O]=(0,Z.useState)(!1),k=(0,Z.useRef)(null),A=(0,Z.useRef)(null);(0,Z.useImperativeHandle)(u,()=>({focus:()=>{var e;return(e=k.current)==null?void 0:e.focus()}}),[]);let{query:j,setQuery:M,showAutocomplete:N,setShowAutocomplete:P,mentions:I,handleFileSelect:L,insertMention:R,clearMentions:ee,removeMention:B}=Jt({workspaceId:a||``}),te=z(e=>e.openFilePreview),V=F(e=>e.activeWorkspace);(0,Z.useEffect)(()=>{if(I.length===0)return;let e=new Set(I.map(e=>e.path)),t=/@([^\s@]+)/g,n,r=new Set;for(;(n=t.exec(d))!==null;)e.has(n[1])&&r.add(n[1]);for(let e of I)r.has(e.path)||B(e.path)},[d,I,B]),(0,Z.useEffect)(()=>{b(0)},[g,C,s]),(0,Z.useEffect)(()=>{let e=k.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,150)}px`)},[d]);let H=s.filter(e=>e.name.toLowerCase().includes(C.toLowerCase())),U=x===`prompts`&&s.length>0,ne=x===`files`&&N&&!!a,re=(0,Z.useCallback)(e=>{let t=e.target.value,n=e.target.selectionStart||0;f(t),h(n);let r=t.lastIndexOf(`/`,n);if(r!==-1){let e=r>0?t[r-1]:`
2
- `,i=t.slice(r+1,n);if((e===`
3
- `||e===` `||e===``)&&!i.includes(` `)){w(i),S(`prompts`);return}}let i=t.lastIndexOf(`@`,n);if(i!==-1){let e=t.slice(i+1,n);if(!e.includes(` `)){M(e),P(!0),S(`files`);return}}S(`none`),P(!1)},[M,P,f]),G=(0,Z.useCallback)(e=>{let t=R(d,m,L(e));f(t.text),S(`none`),P(!1),_([]),setTimeout(()=>{k.current&&(k.current.focus(),k.current.setSelectionRange(t.cursorPos,t.cursorPos))},0)},[d,m,L,R,P,f]),K=(0,Z.useCallback)(e=>{let t=d.lastIndexOf(`/`,m),n=d.slice(0,t),r=d.slice(t+1),i=r.indexOf(` `),a=i===-1?``:r.slice(i),o=`${n}/${e.name}${a}`,s=t+1+e.name.length+0;f(o),S(`none`),setTimeout(()=>{k.current&&(k.current.focus(),k.current.setSelectionRange(s,s))},0)},[d,m,f]),ie=(0,Z.useCallback)(()=>{for(let e of T)e.previewUrl&&URL.revokeObjectURL(e.previewUrl);E([]),p(),ee()},[T,p,ee]),ae=(0,Z.useCallback)(async e=>{if(!o||!c)return null;try{let t=await(o==null?void 0:o.http.attachments.upload(c,e));return{id:crypto.randomUUID(),kind:t.kind,filename:t.filename,size:t.size,previewUrl:e.type.startsWith(`image/`)?URL.createObjectURL(e):void 0,uploadedId:t.id,uploadedKind:t.kind}}catch(e){return console.error(`Upload error:`,e),null}},[o,c]),oe=(0,Z.useCallback)(e=>{E(t=>{let n=t.find(t=>t.id===e);return n!=null&&n.previewUrl&&URL.revokeObjectURL(n.previewUrl),t.filter(t=>t.id!==e)})},[]),se=(0,Z.useCallback)(e=>{let t=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),n=RegExp(`@${t}`,`g`);f(d.replace(n,``).replace(/\s+/g,` `).trim()),B(e)},[d,f,B]),ce=(0,Z.useCallback)(e=>{V!=null&&V.id&&te({workspaceId:V.id,path:e,name:e.split(`/`).pop()||e})},[V==null?void 0:V.id,te]),q=(0,Z.useCallback)(async e=>{let t=Array.from(e);for(let e of t){if(e.size>20*1024*1024)continue;let t=e.type.startsWith(`image/`)?`image`:e.type.startsWith(`video/`)?`video`:`file`,n={id:crypto.randomUUID(),kind:t,filename:e.name,size:e.size,previewUrl:e.type.startsWith(`image/`)?URL.createObjectURL(e):void 0,isUploading:!0};E(e=>[...e,n]);let r=await ae(e);E(r?e=>e.map(e=>e.id===n.id?(e.previewUrl&&e.previewUrl!==r.previewUrl&&URL.revokeObjectURL(e.previewUrl),{...r,isUploading:!1}):e):e=>e.filter(e=>e.id!==n.id))}},[ae]),le=(0,Z.useCallback)(e=>{var t;let n=(t=e.clipboardData)==null?void 0:t.files;n&&n.length>0&&(e.preventDefault(),q(n))},[q]),ue=(0,Z.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),O(!0)},[]),de=(0,Z.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),O(!1)},[]),fe=(0,Z.useCallback)(e=>{var t;e.preventDefault(),e.stopPropagation(),O(!1);let n=(t=e.dataTransfer)==null?void 0:t.files;n&&n.length>0&&q(n)},[q]),pe=async n=>{n==null||n.preventDefault();let r=d.trim();if(!r&&T.length===0||t)return;let i=an(d);if(i){let t=s.find(e=>e.name===i.command);if(t){let n=rn(t,i.rest),r=T.filter(e=>e.uploadedId).map(e=>({id:e.uploadedId,kind:e.uploadedKind}));e(n,r.length>0?r:void 0),ie();return}}let a=T.filter(e=>e.uploadedId).map(e=>({id:e.uploadedId,kind:e.uploadedKind}));e(r||``,a.length>0?a:void 0),ie()},me=e=>{if(!e.nativeEvent.isComposing){if(U&&H.length>0)switch(e.key){case`ArrowDown`:e.preventDefault(),b(e=>Math.min(e+1,H.length-1));return;case`ArrowUp`:e.preventDefault(),b(e=>Math.max(e-1,0));return;case`Enter`:if(e.shiftKey)return;e.preventDefault(),H[y]&&K(H[y]);return;case`Tab`:e.preventDefault(),H[y]&&K(H[y]);return;case`Escape`:e.preventDefault(),S(`none`);return}if(ne&&g.length>0)switch(e.key){case`ArrowDown`:e.preventDefault(),b(e=>Math.min(e+1,g.length-1));return;case`ArrowUp`:e.preventDefault(),b(e=>Math.max(e-1,0));return;case`Enter`:e.preventDefault(),g[y]&&G(g[y]);return;case`Escape`:e.preventDefault(),P(!1),S(`none`);return;case`Tab`:e.preventDefault(),g[y]&&G(g[y]);return}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),pe())}},he=(0,Z.useCallback)(e=>{_(e)},[]);if(n&&r)return(0,Q.jsx)(`div`,{className:`p-4 border-t border-border bg-card`,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-center gap-3`,children:[(0,Q.jsxs)(`div`,{className:`animate-pulse flex items-center gap-2 text-muted-foreground`,children:[(0,Q.jsx)(`div`,{className:`size-2 rounded-full bg-primary animate-bounce`}),(0,Q.jsx)(`div`,{className:`size-2 rounded-full bg-primary animate-bounce [animation-delay:0.1s]`}),(0,Q.jsx)(`div`,{className:`size-2 rounded-full bg-primary animate-bounce [animation-delay:0.2s]`}),(0,Q.jsx)(`span`,{className:`text-sm ml-2`,children:`Generating...`})]}),(0,Q.jsxs)(W,{variant:`outline`,size:`sm`,onClick:r,children:[(0,Q.jsx)(ze,{className:`size-4`,"data-icon":`inline-start`}),`Stop`]})]})});let ge=d.trim(),_e=T.some(e=>e.isUploading),ve=!(ge||T.length>0)||t||_e;return(0,Q.jsxs)(`form`,{onSubmit:pe,onDragOver:ue,onDragLeave:de,onDrop:fe,className:v(`p-4 border-t border-border bg-card`,D&&`ring-2 ring-primary`),children:[(T.length>0||!n)&&(0,Q.jsx)(`div`,{className:`flex gap-2 flex-wrap mb-2`,children:T.map(e=>(0,Q.jsx)(Gt,{id:e.id,kind:e.kind,filename:e.filename,size:e.size,previewUrl:e.previewUrl,isUploading:e.isUploading,onRemove:oe},e.id))}),T.length>0&&l===!1&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-2 text-xs text-amber-600 dark:text-amber-400`,children:[(0,Q.jsx)(Ve,{className:`size-3 shrink-0`}),(0,Q.jsx)(`span`,{children:`This model will not inspect images directly. They will be sent as file paths instead.`})]}),I.length>0&&(0,Q.jsx)(`div`,{className:`flex gap-2 flex-wrap mb-2`,children:I.map(e=>(0,Q.jsx)(qt,{path:e.path,onRemove:se,onPreview:ce},e.path))}),(0,Q.jsxs)(`div`,{className:`flex gap-3 items-end`,children:[(0,Q.jsx)(`div`,{className:`flex-1 relative`,children:(0,Q.jsxs)(Fe,{open:U||ne,onOpenChange:e=>{e||(S(`none`),P(!1))},children:[(0,Q.jsx)(je,{asChild:!0,children:(0,Q.jsx)(ke,{ref:k,value:d,onChange:re,onKeyDown:me,onPaste:le,placeholder:i,disabled:t,className:v(`min-h-[44px] max-h-[150px] resize-none pr-12 chat-input-scrollbar`,`focus-visible:ring-1`),rows:1,"data-chat-input":`true`})}),(0,Q.jsx)(Ne,{className:`w-72 p-0`,align:`start`,side:`top`,sideOffset:8,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),children:ne?(0,Q.jsx)(ye,{workspaceId:a||``,searchQuery:j,selectedIndex:y,onSelect:G,onFilesChange:he,sdkClient:o}):(0,Q.jsx)(Wt,{prompts:s,query:C,selectedIndex:y,onSelect:K})})]})}),(0,Q.jsx)(`button`,{type:`button`,className:`flex items-center justify-center size-11 rounded-md text-muted-foreground hover:text-foreground hover:bg-accent transition-colors disabled:opacity-50 disabled:pointer-events-none`,onClick:()=>{var e;return(e=A.current)==null?void 0:e.click()},disabled:t,children:(0,Q.jsx)(it,{className:`size-4`})}),(0,Q.jsx)(`input`,{ref:A,type:`file`,accept:`image/*,video/*,.pdf,.doc,.docx,.txt,.csv,.json,.xml,.md`,multiple:!0,className:`hidden`,onChange:e=>{e.target.files&&q(e.target.files),e.target.value=``}}),(0,Q.jsx)(W,{type:`submit`,disabled:ve,size:`default`,className:`h-11`,children:(0,Q.jsx)(at,{className:`size-4`})})]}),(0,Q.jsxs)(`div`,{className:`mt-2 text-xs text-muted-foreground text-center hidden sm:flex items-center justify-center gap-1`,children:[(0,Q.jsx)(`kbd`,{className:`px-1.5 py-0.5 bg-muted rounded text-[10px]`,children:`/`}),(0,Q.jsx)(`span`,{children:`prompts`}),(0,Q.jsx)(`span`,{className:`mx-2`,children:`•`}),(0,Q.jsx)(`kbd`,{className:`px-1.5 py-0.5 bg-muted rounded text-[10px]`,children:`@`}),(0,Q.jsx)(`span`,{children:`files`}),(0,Q.jsx)(`span`,{className:`mx-2`,children:`•`}),(0,Q.jsx)(`kbd`,{className:`px-1.5 py-0.5 bg-muted rounded text-[10px]`,children:`Enter`}),(0,Q.jsx)(`span`,{children:`to send`}),(0,Q.jsx)(`span`,{className:`mx-2`,children:`•`}),(0,Q.jsx)(`kbd`,{className:`px-1.5 py-0.5 bg-muted rounded text-[10px]`,children:`Shift + Enter`}),(0,Q.jsx)(`span`,{children:`for new line`})]})]})});function sn(e){return e.startsWith(`https://`)?`https`:`http`}function cn(e,t){return`${sn(e)}://${e.replace(/^https?:\/\//,``)}${t}`}function ln(e){let t=(0,$.c)(3),n=(0,Z.useRef)(e),r;t[0]===e?r=t[1]:(r=()=>{n.current=e},t[0]=e,t[1]=r),(0,Z.useLayoutEffect)(r);let i;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(...e)=>{let t=e;return n.current(...t)},t[2]=i):i=t[2],i}var un=t(i(),1);function dn(e,t,n){var r;let i=(r=n.initialDeps)==null?[]:r,a,o=!0;function s(){var r,s,c;let l;n.key&&(r=n.debug)!=null&&r.call(n)&&(l=Date.now());let u=e();if(!(u.length!==i.length||u.some((e,t)=>i[t]!==e)))return a;i=u;let d;if(n.key&&(s=n.debug)!=null&&s.call(n)&&(d=Date.now()),a=t(...u),n.key&&(c=n.debug)!=null&&c.call(n)){let e=Math.round((Date.now()-l)*100)/100,t=Math.round((Date.now()-d)*100)/100,r=t/16,i=(e,t)=>{for(e=String(e);e.length<t;)e=` `+e;return e};console.info(`%c⏱ ${i(t,5)} /${i(e,5)} ms`,`
4
- font-size: .6rem;
5
- font-weight: bold;
6
- color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n==null?void 0:n.key)}return n!=null&&n.onChange&&!(o&&n.skipInitialOnChange)&&n.onChange(a),o=!1,a}return s.updateDeps=e=>{i=e},s}function fn(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var pn=(e,t)=>Math.abs(e-t)<1.01,mn=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},hn=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},gn=e=>e,_n=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let e=t;e<=n;e++)r.push(e);return r},vn=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(hn(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e!=null&&e.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(hn(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},yn={passive:!0},bn=typeof window>`u`?!0:`onscrollend`in window,xn=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=0,a=e.options.useScrollendEvent&&bn?()=>void 0:mn(r,()=>{t(i,!1)},e.options.isScrollingResetDelay),o=r=>()=>{let{horizontal:o,isRtl:s}=e.options;i=o?n.scrollLeft*(s&&-1||1):n.scrollTop,a(),t(i,r)},s=o(!0),c=o(!1);n.addEventListener(`scroll`,s,yn);let l=e.options.useScrollendEvent&&bn;return l&&n.addEventListener(`scrollend`,c,yn),()=>{n.removeEventListener(`scroll`,s),l&&n.removeEventListener(`scrollend`,c)}},Sn=(e,t,n)=>{if(t!=null&&t.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},Cn=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;let o=e+t;(a=(i=r.scrollElement)==null?void 0:i.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:o,behavior:n})},wn=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var e,t,n,r;return(e=(r=(n=(t=this.targetWindow)==null?void 0:t.performance)==null?void 0:n.now)==null?void 0:r.call(n))==null?Date.now():e},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>{var n;return(n=t())==null?void 0:n.observe(e,{box:`border-box`})},unobserve:e=>{var n;return(n=t())==null?void 0:n.unobserve(e)}}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([t,n])=>{n===void 0&&delete e[t]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:gn,rangeExtractor:_n,onChange:()=>{},measureElement:Sn,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...e}},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=dn(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var e;let t=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==t){if(this.cleanup(),!t){this.maybeNotify();return}if(this.scrollElement=t,this.scrollElement&&`ownerDocument`in this.scrollElement)this.targetWindow=this.scrollElement.ownerDocument.defaultView;else{var n;this.targetWindow=(n=(e=this.scrollElement)==null?void 0:e.window)==null?null:n}this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>{var e;return this.options.enabled?(this.scrollRect=(e=this.scrollRect)==null?this.options.initialRect:e,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0)},this.getScrollOffset=()=>{var e;return this.options.enabled?(this.scrollOffset=(e=this.scrollOffset)==null?typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset:e,this.scrollOffset):(this.scrollOffset=null,0)},this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=dn(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(e,t,n,r,i,a)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a}),{key:!1}),this.getMeasurements=dn(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a},o)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let s=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1);let c=this.measurementsCache.slice(0,s),l=Array(a).fill(void 0);for(let e=0;e<s;e++){let t=c[e];t&&(l[t.lane]=e)}for(let i=s;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,u;if(a!==void 0&&this.options.lanes>1){s=a;let e=l[s],r=e===void 0?void 0:c[e];u=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?c[i-1]:this.getFurthestMeasurement(c,i);u=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(i,s)}let d=o.get(e),f=typeof d==`number`?d:this.options.estimateSize(i),p=u+f;c[i]={index:i,start:u,size:f,end:p,key:e,lane:s},l[s]=i}return this.measurementsCache=c,c},{key:!1,debug:()=>this.options.debug}),this.calculateRange=dn(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?En({measurements:e,outerSize:t,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=dn(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{var t,n;if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let r=(t=this.scrollState.index)==null?(n=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:n.index:t;if(r!==void 0&&this.range){let t=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),n=Math.max(0,r-t),i=Math.min(this.options.count-1,r+t);return e>=n&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{var n,r;let i=this.measurementsCache[e];if(!i)return;let a=t-((n=this.itemSizeCache.get(i.key))==null?i.size:n);a!==0&&(((r=this.scrollState)==null?void 0:r.behavior)!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?i.start<this.getScrollOffset()+this.scrollAdjustments:this.shouldAdjustScrollPositionOnItemSizeChange(i,a,this))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=a,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(i.index),this.itemSizeCache=new Map(this.itemSizeCache.set(i.key,t)),this.notify(!1))},this.getVirtualItems=dn(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length!==0)return fn(t[Tn(0,t.length-1,e=>fn(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t);this.scrollState={index:null,align:t,behavior:n,startedAt:this.now(),lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e;this.scrollState={index:null,align:`start`,behavior:t,startedAt:this.now(),lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{var e;let t=this.getMeasurements(),n;if(t.length===0)n=this.options.paddingStart;else if(this.options.lanes===1){var r;n=(r=(e=t[t.length-1])==null?void 0:e.end)==null?0:r}else{let e=Array(this.options.lanes).fill(null),r=t.length-1;for(;r>=0&&e.some(e=>e===null);){let n=t[r];e[n.lane]===null&&(e[n.lane]=n.end),r--}n=Math.max(...e.filter(e=>e!==null))}return Math.max(n-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&pn(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.scrollState=null;return}}else this.scrollState.stableFrames=0,n&&(this.scrollState.lastTargetOffset=t,this.scrollState.behavior=`auto`,this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}));this.scheduleScrollReconcile()}},Tn=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function En({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){let i=e.length-1,a=t=>e[t].start;if(e.length<=r)return{startIndex:0,endIndex:i};let o=Tn(0,i,a,n),s=o;if(r===1)for(;s<i&&e[s].end<n+t;)s++;else if(r>1){let a=Array(r).fill(0);for(;s<i&&a.some(e=>e<n+t);){let t=e[s];a[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(i,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var Dn=typeof document<`u`?Z.useLayoutEffect:Z.useEffect;function On({useFlushSync:e=!0,...t}){let n=Z.useReducer(()=>({}),{})[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,un.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=Z.useState(()=>new wn(r));return i.setOptions(r),Dn(()=>i._didMount(),[]),Dn(()=>i._willUpdate()),i}function kn(e){return On({observeElementRect:vn,observeElementOffset:xn,scrollToFn:Cn,...e})}function An(e){let t=(0,$.c)(50),{message:n,textContent:r,children:i,isQueued:a,onRemove:o,onRevert:s,canRevert:l,onFork:u,canFork:d,isClearAll:f}=e,p=a===void 0?!1:a,m=l===void 0?!1:l,h=d===void 0?!1:d,_=f===void 0?!1:f,[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(!1),T=n.role===`user`,E;t[0]===r?E=t[1]:(E=async()=>{let e=r||``;await navigator.clipboard.writeText(e),b(!0),setTimeout(()=>b(!1),2e3)},t[0]=r,t[1]=E);let D=E,O=T?`items-end`:`items-start`,k;t[2]===O?k=t[3]:(k=v(`flex flex-col gap-1 animate-slide-up min-w-0`,O),t[2]=O,t[3]=k);let A=T?`mr-3`:`ml-3`,j;t[4]===A?j=t[5]:(j=v(`flex items-center gap-1.5 text-xs uppercase tracking-wide text-muted-foreground`,A),t[4]=A,t[5]=j);let M;t[6]!==h||t[7]!==m||t[8]!==y||t[9]!==D||t[10]!==p||t[11]!==T||t[12]!==n.role||t[13]!==u||t[14]!==s?(M=T?(0,Q.jsxs)(Q.Fragment,{children:[!p&&(0,Q.jsxs)(Q.Fragment,{children:[m&&s&&(0,Q.jsx)(W,{variant:`ghost`,size:`icon`,onClick:()=>S(!0),className:`size-5 text-muted-foreground hover:text-foreground`,title:`Revert to this point`,children:(0,Q.jsx)(st,{className:`size-3`})}),h&&u&&(0,Q.jsx)(W,{variant:`ghost`,size:`icon`,onClick:()=>w(!0),className:`size-5 text-muted-foreground hover:text-foreground`,title:`Fork from this point`,children:(0,Q.jsx)($e,{className:`size-3`})}),(0,Q.jsx)(W,{variant:`ghost`,size:`icon`,onClick:D,className:`size-5 text-muted-foreground hover:text-foreground`,children:y?(0,Q.jsx)(c,{className:`size-3`}):(0,Q.jsx)(Te,{className:`size-3`})})]}),(0,Q.jsx)(de,{className:`size-3`}),n.role]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(We,{className:`size-3`}),n.role,(0,Q.jsx)(W,{variant:`ghost`,size:`icon`,onClick:D,className:`size-5 text-muted-foreground hover:text-foreground`,children:y?(0,Q.jsx)(c,{className:`size-3`}):(0,Q.jsx)(Te,{className:`size-3`})})]}),t[6]=h,t[7]=m,t[8]=y,t[9]=D,t[10]=p,t[11]=T,t[12]=n.role,t[13]=u,t[14]=s,t[15]=M):M=t[15];let N;t[16]!==M||t[17]!==j?(N=(0,Q.jsx)(`div`,{className:j,children:M}),t[16]=M,t[17]=j,t[18]=N):N=t[18];let P=T?`max-w-[90%]`:`max-w-full`,F=p?`bg-muted border-2 border-dashed border-muted-foreground/30 opacity-80`:T?`bg-primary text-primary-foreground rounded-br-md`:`bg-card text-card-foreground border border-border rounded-bl-md`,I;t[19]!==P||t[20]!==F?(I=v(`rounded-2xl px-4 py-3 relative group min-w-0 overflow-hidden`,P,F),t[19]=P,t[20]=F,t[21]=I):I=t[21];let L;t[22]!==p||t[23]!==o?(L=p&&(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-2 pb-2 border-b border-muted-foreground/20`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(Xe,{className:`size-3 animate-pulse`}),(0,Q.jsx)(`span`,{children:`Pending`})]}),o&&(0,Q.jsx)(W,{variant:`ghost`,size:`icon`,onClick:o,className:`size-6 text-muted-foreground hover:text-destructive hover:bg-destructive/10`,title:`Remove from queue`,children:(0,Q.jsx)(g,{className:`size-3`})})]}),t[22]=p,t[23]=o,t[24]=L):L=t[24];let R;t[25]===i?R=t[26]:(R=(0,Q.jsx)(`div`,{className:`min-w-0`,children:i}),t[25]=i,t[26]=R);let z;t[27]!==I||t[28]!==L||t[29]!==R?(z=(0,Q.jsxs)(`div`,{className:I,children:[L,R]}),t[27]=I,t[28]=L,t[29]=R,t[30]=z):z=t[30];let ee=_?`Clear Conversation`:`Revert Conversation`,B=_?`This will delete all messages in this session, leaving it completely empty. Are you sure you want to continue?`:`This will delete this message and all messages after it. Are you sure you want to continue?`,te=_?`Clear All`:`Revert`,V;t[31]===s?V=t[32]:(V=()=>{s==null||s()},t[31]=s,t[32]=V);let H;t[33]!==x||t[34]!==ee||t[35]!==B||t[36]!==te||t[37]!==V?(H=(0,Q.jsx)(ae,{open:x,onOpenChange:S,title:ee,description:B,confirmLabel:te,cancelLabel:`Cancel`,onConfirm:V,variant:`destructive`}),t[33]=x,t[34]=ee,t[35]=B,t[36]=te,t[37]=V,t[38]=H):H=t[38];let U;t[39]===u?U=t[40]:(U=()=>{u==null||u()},t[39]=u,t[40]=U);let ne;t[41]!==C||t[42]!==U?(ne=(0,Q.jsx)(ae,{open:C,onOpenChange:w,title:`Fork Conversation`,description:`This will create a new session with messages up to and including this point. The original session will be unchanged.`,confirmLabel:`Fork`,cancelLabel:`Cancel`,onConfirm:U}),t[41]=C,t[42]=U,t[43]=ne):ne=t[43];let re;return t[44]!==N||t[45]!==z||t[46]!==H||t[47]!==ne||t[48]!==k?(re=(0,Q.jsxs)(`div`,{className:k,children:[N,z,H,ne]}),t[44]=N,t[45]=z,t[46]=H,t[47]=ne,t[48]=k,t[49]=re):re=t[49],re}var jn=q.oneDark;function Mn(e){var t;let n=(t=e.split(`.`).pop())==null?void 0:t.toLowerCase();return{ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,json:`json`,md:`markdown`,css:`css`,html:`html`,py:`python`,go:`go`,rs:`rust`,sh:`bash`,yaml:`yaml`,yml:`yaml`}[n||``]||n||`text`}var Nn=(0,Z.memo)(function(e){let t=(0,$.c)(28),{type:n,content:r,lineNumber:i,newLineNumber:a,language:o}=e,s=n===`added`&&`bg-green-500/20`,c=n===`removed`&&`bg-red-500/20`,l=n===`context`&&`bg-muted/30`,u;t[0]!==s||t[1]!==c||t[2]!==l?(u=v(`flex font-mono text-xs`,s,c,l),t[0]=s,t[1]=c,t[2]=l,t[3]=u):u=t[3];let d=u,f=n===`added`&&`text-green-400`,p=n===`removed`&&`text-red-400`,m=n===`context`&&`text-muted-foreground/50`,h;t[4]!==f||t[5]!==p||t[6]!==m?(h=v(`font-bold w-4 select-none`,f,p,m),t[4]=f,t[5]=p,t[6]=m,t[7]=h):h=t[7];let g=h,_=i==null?``:i,y;t[8]===_?y=t[9]:(y=(0,Q.jsx)(`span`,{className:`w-10 text-right pr-2 text-muted-foreground select-none border-r border-white/10`,children:_}),t[8]=_,t[9]=y);let b=a==null?``:a,x;t[10]===b?x=t[11]:(x=(0,Q.jsx)(`span`,{className:`w-10 text-right pr-2 text-muted-foreground select-none border-r border-white/10`,children:b}),t[10]=b,t[11]=x);let S=n===`added`&&`+`,C=n===`removed`&&`-`,w=n===`context`&&` `,T;t[12]!==g||t[13]!==S||t[14]!==C||t[15]!==w?(T=(0,Q.jsxs)(`span`,{className:g,children:[S,C,w]}),t[12]=g,t[13]=S,t[14]=C,t[15]=w,t[16]=T):T=t[16];let E;t[17]!==r||t[18]!==o?(E=(0,Q.jsx)(he,{theme:jn,code:r,language:o,children:Fn}),t[17]=r,t[18]=o,t[19]=E):E=t[19];let D;t[20]!==T||t[21]!==E?(D=(0,Q.jsxs)(`span`,{className:`pl-2 flex-1 whitespace-pre flex`,children:[T,E]}),t[20]=T,t[21]=E,t[22]=D):D=t[22];let O;return t[23]!==y||t[24]!==x||t[25]!==D||t[26]!==d?(O=(0,Q.jsxs)(`div`,{className:d,children:[y,x,D]}),t[23]=y,t[24]=x,t[25]=D,t[26]=d,t[27]=O):O=t[27],O}),Pn=(0,Z.memo)(function(e){let t=(0,$.c)(33),{hunks:n,path:r,language:i,additions:a,deletions:o}=e,[s,c]=(0,Z.useState)(!0),l;t[0]!==r||t[1]!==i?(l=i||Mn(r),t[0]=r,t[1]=i,t[2]=l):l=t[2];let u=l,d=z(In),p=F(Ln),m;t[3]!==p||t[4]!==d||t[5]!==r?(m=()=>{p&&d({workspaceId:p.id,path:r,name:r.split(`/`).pop()||r})},t[3]=p,t[4]=d,t[5]=r,t[6]=m):m=t[6];let h=m,g;t[7]===s?g=t[8]:(g=()=>c(!s),t[7]=s,t[8]=g);let _;t[9]===s?_=t[10]:(_=s?(0,Q.jsx)(Ke,{className:`size-3`}):(0,Q.jsx)(f,{className:`size-3`}),t[9]=s,t[10]=_);let v;t[11]!==g||t[12]!==_?(v=(0,Q.jsx)(`button`,{onClick:g,className:`px-1 py-1 hover:bg-muted rounded`,children:_}),t[11]=g,t[12]=_,t[13]=v):v=t[13];let y;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Q.jsx)(ce,{className:`size-3`}),t[14]=y):y=t[14];let b;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Q.jsx)(Ee,{className:`size-2.5 opacity-0 group-hover/path:opacity-100 transition-opacity`}),t[15]=b):b=t[15];let x;t[16]!==h||t[17]!==r?(x=(0,Q.jsxs)(`button`,{type:`button`,onClick:h,className:`flex items-center gap-1 font-mono pr-2 hover:text-foreground transition-colors cursor-pointer rounded px-1 py-0.5 -mx-1 hover:bg-muted`,title:`Open file preview`,children:[r,b]}),t[16]=h,t[17]=r,t[18]=x):x=t[18];let S;t[19]!==a||t[20]!==o?(S=a!==void 0&&o!==void 0&&(0,Q.jsxs)(`span`,{className:`ml-auto mr-2 text-muted-foreground`,children:[`+`,a,` -`,o]}),t[19]=a,t[20]=o,t[21]=S):S=t[21];let C;t[22]!==v||t[23]!==x||t[24]!==S?(C=(0,Q.jsxs)(`div`,{className:`group/path flex items-center gap-2 px-1 bg-muted/50 text-xs text-muted-foreground`,children:[v,y,x,S]}),t[22]=v,t[23]=x,t[24]=S,t[25]=C):C=t[25];let w;t[26]!==s||t[27]!==n||t[28]!==u?(w=s&&(0,Q.jsx)(`div`,{style:{backgroundColor:`#282c34`},children:n.map((e,t)=>(0,Q.jsx)(`div`,{className:`divide-y divide-white/5`,children:e.changes.map((e,t)=>(0,Q.jsx)(Nn,{...e,language:u},t))},t))}),t[26]=s,t[27]=n,t[28]=u,t[29]=w):w=t[29];let T;return t[30]!==C||t[31]!==w?(T=(0,Q.jsx)(`div`,{className:`visualization-container overflow-x-auto border border-white/10 rounded-md`,children:(0,Q.jsxs)(`div`,{children:[C,w]})}),t[30]=C,t[31]=w,t[32]=T):T=t[32],T});function Fn(e){let{tokens:t,getTokenProps:n}=e;return(0,Q.jsx)(Q.Fragment,{children:t.map((e,t)=>(0,Q.jsx)(`span`,{children:e.map((e,t)=>(0,Q.jsx)(`span`,{...n({token:e})},t))},t))})}function In(e){return e.openFilePreview}function Ln(e){return e.activeWorkspace}var Rn=q.oneDark,zn=20;function Bn(e){var t;let n=(t=e.split(`.`).pop())==null?void 0:t.toLowerCase();return{ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,json:`json`,md:`markdown`,css:`css`,html:`html`,py:`python`,go:`go`,rs:`rust`,sh:`bash`,yaml:`yaml`,yml:`yaml`}[n||``]||n||`text`}var Vn=(0,Z.memo)(e=>{let t=(0,$.c)(46),{content:n,path:r,language:i,created:a,highlightLines:o}=e,s;t[0]===o?s=t[1]:(s=o===void 0?[]:o,t[0]=o,t[1]=s);let l=s,[u,d]=(0,Z.useState)(!1),p=z(Hn),m=F(Un),h;t[2]!==m||t[3]!==p||t[4]!==r?(h=()=>{m&&p({workspaceId:m.id,path:r,name:r.split(`/`).pop()||r})},t[2]=m,t[3]=p,t[4]=r,t[5]=h):h=t[5];let g=h,_;t[6]!==i||t[7]!==r?(_=i||Bn(r),t[6]=i,t[7]=r,t[8]=_):_=t[8];let v=_,y;t[9]===l?y=t[10]:(y=new Set(l),t[9]=l,t[10]=y);let b=y,x;t[11]===n?x=t[12]:(x=n.split(`
7
- `),t[11]=n,t[12]=x);let S=x.length,C;t[13]===u?C=t[14]:(C=()=>d(!u),t[13]=u,t[14]=C);let w;t[15]===u?w=t[16]:(w=u?(0,Q.jsx)(Ke,{className:`size-3`}):(0,Q.jsx)(f,{className:`size-3`}),t[15]=u,t[16]=w);let T;t[17]!==C||t[18]!==w?(T=(0,Q.jsx)(`button`,{onClick:C,className:`flex items-center gap-2 px-2 py-1 hover:bg-muted`,children:w}),t[17]=C,t[18]=w,t[19]=T):T=t[19];let E;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Q.jsx)(ce,{className:`size-3`}),t[20]=E):E=t[20];let D;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Q.jsx)(Ee,{className:`size-2.5 opacity-0 group-hover/path:opacity-100 transition-opacity`}),t[21]=D):D=t[21];let O;t[22]!==g||t[23]!==r?(O=(0,Q.jsxs)(`button`,{type:`button`,onClick:g,className:`flex items-center gap-1 font-mono pr-2 hover:text-foreground transition-colors cursor-pointer rounded px-1 py-0.5 -mx-1 hover:bg-muted`,title:`Open file preview`,children:[r,D]}),t[22]=g,t[23]=r,t[24]=O):O=t[24];let k;t[25]!==u||t[26]!==S?(k=!u&&(0,Q.jsxs)(`span`,{className:`text-xs text-muted-foreground/70`,children:[S,` lines`]}),t[25]=u,t[26]=S,t[27]=k):k=t[27];let A;t[28]===a?A=t[29]:(A=a===!1?(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 text-warning ml-auto mr-2`,children:[(0,Q.jsx)(se,{className:`size-3`}),`Overwrote`]}):(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 text-success ml-auto mr-2`,children:[(0,Q.jsx)(c,{className:`size-3`}),`Created`]}),t[28]=a,t[29]=A);let j;t[30]!==O||t[31]!==k||t[32]!==A||t[33]!==T?(j=(0,Q.jsxs)(`div`,{className:`group/path flex items-center gap-2 px-1 bg-muted/50 text-xs text-muted-foreground`,children:[T,E,O,k,A]}),t[30]=O,t[31]=k,t[32]=A,t[33]=T,t[34]=j):j=t[34];let M;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(M={backgroundColor:`#282c34`},t[35]=M):M=t[35];let N;t[36]!==u||t[37]!==b?(N=e=>{let{tokens:t,getTokenProps:n}=e;return(0,Q.jsx)(Q.Fragment,{children:(u?t:t.slice(0,zn)).map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex font-mono text-xs ${b.has(t+1)?`bg-yellow-500/20`:``}`,children:[(0,Q.jsx)(`span`,{className:`w-10 text-right pr-2 text-muted-foreground select-none border-r border-white/10`,children:t+1}),(0,Q.jsx)(`span`,{className:`pl-2 flex-1 whitespace-pre`,children:e.map((e,t)=>(0,Q.jsx)(`span`,{...n({token:e})},t))})]},t))})},t[36]=u,t[37]=b,t[38]=N):N=t[38];let P;t[39]!==n||t[40]!==v||t[41]!==N?(P=(0,Q.jsx)(`div`,{style:M,children:(0,Q.jsx)(he,{theme:Rn,code:n,language:v,children:N})}),t[39]=n,t[40]=v,t[41]=N,t[42]=P):P=t[42];let I;return t[43]!==j||t[44]!==P?(I=(0,Q.jsx)(`div`,{className:`visualization-container overflow-x-auto border border-white/10 rounded-md`,children:(0,Q.jsxs)(`div`,{children:[j,P]})}),t[43]=j,t[44]=P,t[45]=I):I=t[45],I});function Hn(e){return e.openFilePreview}function Un(e){return e.activeWorkspace}function Wn(e){let t=(0,$.c)(3),{message:n}=e,r=n===void 0?`Success`:n,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsx)(U,{className:`size-4`}),t[0]=i):i=t[0];let a;return t[1]===r?a=t[2]:(a=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[i,(0,Q.jsx)(`span`,{className:`break-all`,children:r})]}),t[1]=r,t[2]=a),a}var Gn={edit:Qe,plus:y,trash:H,search:De};function Kn(e){let t=(0,$.c)(7),{text:n}=e,[r,i]=(0,Z.useState)(!1),a;t[0]===n?a=t[1]:(a=async()=>{await navigator.clipboard.writeText(n),i(!0),setTimeout(()=>i(!1),1500)},t[0]=n,t[1]=a);let o=a,s;t[2]===r?s=t[3]:(s=r?(0,Q.jsx)(`span`,{className:`text-success text-xs`,children:`Copied!`}):(0,Q.jsx)(Te,{className:`size-3`}),t[2]=r,t[3]=s);let c;return t[4]!==o||t[5]!==s?(c=(0,Q.jsx)(`button`,{onClick:o,className:`text-muted-foreground hover:text-foreground transition-colors`,title:`Copy path`,children:s}),t[4]=o,t[5]=s,t[6]=c):c=t[6],c}function qn(e){let t=(0,$.c)(16),{title:n,groups:r,files:i,total:a}=e,o;t[0]===i?o=t[1]:(o=i||[],t[0]=i,t[1]=o);let s;t[2]===o?s=t[3]:(s={label:`Files`,files:o,icon:void 0},t[2]=o,t[3]=s);let c=s,l;t[4]!==c||t[5]!==i||t[6]!==r?(l=r||(i?[c]:[]),t[4]=c,t[5]=i,t[6]=r,t[7]=l):l=t[7];let u=l;if(u.length===0)return null;let d;t[8]!==n||t[9]!==a?(d=n&&(0,Q.jsxs)(`div`,{className:`text-sm font-medium text-foreground`,children:[n,a!==void 0&&(0,Q.jsxs)(`span`,{className:`ml-2 text-muted-foreground`,children:[`(`,a,` files)`]})]}),t[8]=n,t[9]=a,t[10]=d):d=t[10];let f;t[11]===u?f=t[12]:(f=u.map(Jn),t[11]=u,t[12]=f);let p;return t[13]!==d||t[14]!==f?(p=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[d,f]}),t[13]=d,t[14]=f,t[15]=p):p=t[15],p}function Jn(e,t){return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[e.icon&&(0,Q.jsx)(`span`,{className:`flex items-center`,children:(()=>{let t=Gn[e.icon];return(0,Q.jsx)(t,{className:`size-3`})})()}),(0,Q.jsx)(`span`,{children:e.label}),(0,Q.jsxs)(`span`,{className:`text-muted-foreground/50`,children:[`(`,e.files.length,`)`]})]}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-0.5 pl-5`,children:e.files.map(Yn)})]},t)}function Yn(e,t){return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs group`,children:[(0,Q.jsx)(ce,{className:`size-3 text-muted-foreground shrink-0`}),(0,Q.jsx)(`span`,{className:`font-mono text-foreground/80 truncate`,children:e.path}),e.line!==void 0&&(0,Q.jsxs)(`span`,{className:`text-muted-foreground shrink-0`,children:[`:`,e.line]}),e.action&&(0,Q.jsx)(`span`,{className:v(`text-xs px-1 rounded shrink-0`,e.action===`created`&&`bg-success/20 text-success`,e.action===`modified`&&`bg-warning/20 text-warning`,e.action===`deleted`&&`bg-destructive/20 text-destructive`),children:e.action}),(0,Q.jsx)(Kn,{text:e.path})]},t)}function Xn(e){let t=(0,$.c)(15),{command:n,stdout:r,stderr:i,exitCode:a}=e,o=a===0,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`$ `}),t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,Q.jsxs)(`div`,{className:`font-mono text-xs text-muted-foreground truncate flex-1 mr-2`,children:[s,(0,Q.jsx)(`span`,{className:`text-foreground`,children:n})]}),t[1]=n,t[2]=c);let l=`text-xs font-mono px-2 py-0.5 rounded ${o?`bg-muted text-muted-foreground`:`bg-red-500/20 text-red-400`}`,u;t[3]!==a||t[4]!==l?(u=(0,Q.jsxs)(`span`,{className:l,children:[`[`,a,`]`]}),t[3]=a,t[4]=l,t[5]=u):u=t[5];let d;t[6]!==c||t[7]!==u?(d=(0,Q.jsxs)(`div`,{className:`bg-muted px-3 py-2 flex items-center justify-between`,children:[c,u]}),t[6]=c,t[7]=u,t[8]=d):d=t[8];let f;t[9]!==i||t[10]!==r?(f=(r||i)&&(0,Q.jsxs)(`div`,{className:`bg-black px-3 py-2 font-mono text-xs overflow-x-auto`,children:[r&&(0,Q.jsx)(`pre`,{className:`text-gray-300 whitespace-pre-wrap`,children:r}),i&&(0,Q.jsx)(`pre`,{className:`text-red-400 whitespace-pre-wrap mt-1`,children:i})]}),t[9]=i,t[10]=r,t[11]=f):f=t[11];let p;return t[12]!==d||t[13]!==f?(p=(0,Q.jsxs)(`div`,{className:`visualization-container border border-white/10 rounded-md overflow-hidden`,children:[d,f]}),t[12]=d,t[13]=f,t[14]=p):p=t[14],p}var Zn={pending:{icon:Ye,color:`text-muted-foreground`},in_progress:{icon:re,color:`text-warning`,animate:!0},completed:{icon:U,color:`text-success`},cancelled:{icon:o,color:`text-destructive`}},Qn={high:{label:`high`,className:`bg-destructive/20 text-destructive`},medium:{label:``,className:``},low:{label:`low`,className:`text-muted-foreground`}};function $n(e){let t=(0,$.c)(13),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===r?i=t[1]:(i=r.filter(rr),t[0]=r,t[1]=i);let a=i.length;r.filter(nr),r.filter(tr);let o;t[2]!==a||t[3]!==r.length||t[4]!==n?(o=(n||r.length>0)&&(0,Q.jsxs)(`div`,{className:`text-sm font-medium text-foreground`,children:[n||`Todo List`,(0,Q.jsxs)(`span`,{className:`ml-2 text-muted-foreground`,children:[`(`,r.length,`)`]}),a>0&&(0,Q.jsxs)(`span`,{className:`ml-2 text-success text-xs`,children:[a,` completed`]})]}),t[2]=a,t[3]=r.length,t[4]=n,t[5]=o):o=t[5];let s;t[6]===r?s=t[7]:(s=r.map(er),t[6]=r,t[7]=s);let c;t[8]===s?c=t[9]:(c=(0,Q.jsx)(`div`,{className:`flex flex-col gap-1 w-full`,children:s}),t[8]=s,t[9]=c);let l;return t[10]!==o||t[11]!==c?(l=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 w-full overflow-hidden`,children:[o,c]}),t[10]=o,t[11]=c,t[12]=l):l=t[12],l}function er(e,t){let n=Zn[e.status],r=n.icon,i=Qn[e.priority];return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm min-w-0`,children:[(0,Q.jsx)(r,{className:v(`size-4 shrink-0`,n.color,n.animate&&`animate-spin`)}),(0,Q.jsx)(`span`,{className:v(`flex-1 break-all`,e.status===`completed`&&`line-through text-muted-foreground`,e.status===`cancelled`&&`text-muted-foreground`),children:e.content}),i.label&&e.priority===`high`&&(0,Q.jsx)(`span`,{className:v(`text-xs px-1.5 py-0.5 rounded shrink-0`,i.className),children:i.label}),e.priority===`low`&&e.status!==`completed`&&e.status!==`cancelled`&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:i.label})]},t)}function tr(e){return e.status===`pending`}function nr(e){return e.status===`in_progress`}function rr(e){return e.status===`completed`}var ir=(0,Z.memo)(function(e){let t=(0,$.c)(38),{visualization:n}=e;if(!n)return null;switch(n.type){case`diff`:{let e;return t[0]!==n.additions||t[1]!==n.deletions||t[2]!==n.hunks||t[3]!==n.language||t[4]!==n.matchInfo||t[5]!==n.path?(e=(0,Q.jsx)(Pn,{path:n.path,hunks:n.hunks,language:n.language,additions:n.additions,deletions:n.deletions,matchInfo:n.matchInfo}),t[0]=n.additions,t[1]=n.deletions,t[2]=n.hunks,t[3]=n.language,t[4]=n.matchInfo,t[5]=n.path,t[6]=e):e=t[6],e}case`diffs`:{let e;t[7]===n.items?e=t[8]:(e=n.items.map(ar),t[7]=n.items,t[8]=e);let r;return t[9]===e?r=t[10]:(r=(0,Q.jsx)(`div`,{className:`space-y-3`,children:e}),t[9]=e,t[10]=r),r}case`code`:{let e;return t[11]!==n.content||t[12]!==n.created||t[13]!==n.highlightLines||t[14]!==n.language||t[15]!==n.path?(e=(0,Q.jsx)(Vn,{path:n.path,content:n.content,language:n.language,created:n.created,highlightLines:n.highlightLines}),t[11]=n.content,t[12]=n.created,t[13]=n.highlightLines,t[14]=n.language,t[15]=n.path,t[16]=e):e=t[16],e}case`file-list`:{let e;return t[17]!==n.files||t[18]!==n.groups||t[19]!==n.title||t[20]!==n.total?(e=(0,Q.jsx)(qn,{title:n.title,groups:n.groups,files:n.files,total:n.total}),t[17]=n.files,t[18]=n.groups,t[19]=n.title,t[20]=n.total,t[21]=e):e=t[21],e}case`table`:{let e;t[22]===n.rows?e=t[23]:(e=JSON.stringify(n.rows,null,2),t[22]=n.rows,t[23]=e);let r;return t[24]===e?r=t[25]:(r=(0,Q.jsx)(`pre`,{className:`text-xs bg-muted/50 border rounded-md p-2 overflow-x-auto`,children:e}),t[24]=e,t[25]=r),r}case`markdown`:{let e;return t[26]===n.content?e=t[27]:(e=(0,Q.jsx)(`div`,{className:`prose prose-sm dark:prose-invert`,children:n.content}),t[26]=n.content,t[27]=e),e}case`none`:{let e;return t[28]===n.message?e=t[29]:(e=(0,Q.jsx)(Wn,{message:n.message}),t[28]=n.message,t[29]=e),e}case`shell-output`:{let e;return t[30]!==n.command||t[31]!==n.exitCode||t[32]!==n.stderr||t[33]!==n.stdout?(e=(0,Q.jsx)(Xn,{command:n.command,stdout:n.stdout,stderr:n.stderr,exitCode:n.exitCode}),t[30]=n.command,t[31]=n.exitCode,t[32]=n.stderr,t[33]=n.stdout,t[34]=e):e=t[34],e}case`todo-list`:{let e;return t[35]!==n.items||t[36]!==n.title?(e=(0,Q.jsx)($n,{title:n.title,items:n.items}),t[35]=n.items,t[36]=n.title,t[37]=e):e=t[37],e}default:return null}});function ar(e,t){return(0,Q.jsx)(Pn,{path:e.path,hunks:e.hunks,language:e.language,additions:e.additions,deletions:e.deletions,matchInfo:e.matchInfo},`${e.path}-${t}`)}function or(e){let t=(0,$.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=v(`peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-colors outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary`,n),t[3]=n,t[4]=i);let a;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Q.jsx)(bt,{"data-slot":`checkbox-indicator`,className:`grid place-content-center text-current transition-none [&>svg]:size-3.5`,children:(0,Q.jsx)(c,{})}),t[5]=a):a=t[5];let o;return t[6]!==r||t[7]!==i?(o=(0,Q.jsx)(vt,{"data-slot":`checkbox`,className:i,...r,children:a}),t[6]=r,t[7]=i,t[8]=o):o=t[8],o}function sr(e){let t=(0,$.c)(16),{question:n,onSelect:r}=e,[i,a]=(0,Z.useState)(null),o;t[0]===n.description?o=t[1]:(o=n.description&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n.description}),t[0]=n.description,t[1]=o);let s;if(t[2]!==n.options||t[3]!==i){let e;t[5]===i?e=t[6]:(e=e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>a(e.value),className:`flex flex-col items-start gap-1 p-3 rounded-lg border transition-colors text-left ${i===e.value?`border-primary bg-primary/10 ring-1 ring-primary/30`:`border-border hover:border-primary/50 hover:bg-muted/50`}`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 w-full`,children:[(0,Q.jsx)(`div`,{className:`size-4 rounded-full border-2 flex items-center justify-center transition-colors ${i===e.value?`border-primary bg-primary`:`border-muted-foreground`}`,children:i===e.value&&(0,Q.jsx)(`div`,{className:`size-2 rounded-full bg-primary-foreground`})}),(0,Q.jsx)(`span`,{className:`font-medium`,children:e.label})]}),e.description&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground pl-6`,children:e.description})]},e.value),t[5]=i,t[6]=e),s=n.options.map(e),t[2]=n.options,t[3]=i,t[4]=s}else s=t[4];let c;t[7]===s?c=t[8]:(c=(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:s}),t[7]=s,t[8]=c);let l;t[9]!==r||t[10]!==i?(l=i!==null&&(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(W,{size:`sm`,onClick:()=>r(i),children:`Confirm`})}),t[9]=r,t[10]=i,t[11]=l):l=t[11];let u;return t[12]!==o||t[13]!==c||t[14]!==l?(u=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[o,c,l]}),t[12]=o,t[13]=c,t[14]=l,t[15]=u):u=t[15],u}function cr(e){let t=(0,$.c)(36),{question:n,onSelect:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=new Set,t[0]=i):i=t[0];let[a,o]=(0,Z.useState)(i),s;t[1]===n.max?s=t[2]:(s=e=>{o(t=>{let r=new Set(t);if(r.has(e))r.delete(e);else{if(n.max&&r.size>=n.max)return t;r.add(e)}return r})},t[1]=n.max,t[2]=s);let c=s,l;t[3]!==r||t[4]!==n.min||t[5]!==a?(l=()=>{let e=Array.from(a);n.min&&e.length<n.min||r(e)},t[3]=r,t[4]=n.min,t[5]=a,t[6]=l):l=t[6];let u=l,d=!n.min||a.size>=n.min,f=n.max?a.size>=n.max:!1,p;t[7]===n.description?p=t[8]:(p=n.description&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n.description}),t[7]=n.description,t[8]=p);let m;if(t[9]!==f||t[10]!==n.options||t[11]!==a||t[12]!==c){let e;t[14]!==f||t[15]!==a||t[16]!==c?(e=e=>{let t=f&&!a.has(e.value);return(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>c(e.value),disabled:t,className:`flex flex-col items-start gap-1 p-3 rounded-lg border transition-colors text-left ${t?`border-border opacity-50 cursor-not-allowed`:a.has(e.value)?`border-primary bg-primary/5 hover:bg-primary/10`:`border-border hover:border-primary/50 hover:bg-muted/50`}`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 w-full`,children:[(0,Q.jsx)(or,{checked:a.has(e.value),disabled:t,onCheckedChange:()=>c(e.value),className:`pointer-events-none`}),(0,Q.jsx)(`span`,{className:`font-medium pointer-events-none`,children:e.label})]}),e.description&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground pl-6`,children:e.description})]},e.value)},t[14]=f,t[15]=a,t[16]=c,t[17]=e):e=t[17],m=n.options.map(e),t[9]=f,t[10]=n.options,t[11]=a,t[12]=c,t[13]=m}else m=t[13];let h;t[18]===m?h=t[19]:(h=(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:m}),t[18]=m,t[19]=h);let g;t[20]!==n.max||t[21]!==n.min?(g=n.min!==void 0&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Select at least `,n.min,` option`,n.min>1?`s`:``,n.max!==void 0&&` (up to ${n.max})`]}),t[20]=n.max,t[21]=n.min,t[22]=g):g=t[22];let _;t[23]!==n.max||t[24]!==n.min?(_=n.max!==void 0&&!n.min&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Select up to `,n.max,` option`,n.max>1?`s`:``]}),t[23]=n.max,t[24]=n.min,t[25]=_):_=t[25];let v=!d,y;t[26]!==u||t[27]!==a.size||t[28]!==v?(y=(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsxs)(W,{size:`sm`,onClick:u,disabled:v,children:[`Confirm Selection (`,a.size,`)`]})}),t[26]=u,t[27]=a.size,t[28]=v,t[29]=y):y=t[29];let b;return t[30]!==y||t[31]!==p||t[32]!==h||t[33]!==g||t[34]!==_?(b=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[p,h,g,_,y]}),t[30]=y,t[31]=p,t[32]=h,t[33]=g,t[34]=_,t[35]=b):b=t[35],b}function lr(e){let t=(0,$.c)(26),{question:n,onSubmit:r}=e,[i,a]=(0,Z.useState)(n.defaultValue||``),o;t[0]===n.description?o=t[1]:(o=n.description&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n.description}),t[0]=n.description,t[1]=o);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=e=>a(e.target.value),t[2]=s):s=t[2];let c;t[3]!==n.placeholder||t[4]!==i?(c=(0,Q.jsx)(V,{type:`text`,value:i,onChange:s,placeholder:n.placeholder}),t[3]=n.placeholder,t[4]=i,t[5]=c):c=t[5];let l;t[6]!==r||t[7]!==i?(l=(0,Q.jsx)(W,{variant:`outline`,size:`sm`,onClick:()=>r(i),children:`Skip`}),t[6]=r,t[7]=i,t[8]=l):l=t[8];let u;t[9]!==r||t[10]!==i?(u=()=>r(i),t[9]=r,t[10]=i,t[11]=u):u=t[11];let d;t[12]===i?d=t[13]:(d=i.trim(),t[12]=i,t[13]=d);let f=d.length===0,p;t[14]!==u||t[15]!==f?(p=(0,Q.jsx)(W,{size:`sm`,onClick:u,disabled:f,children:`Submit`}),t[14]=u,t[15]=f,t[16]=p):p=t[16];let m;t[17]!==l||t[18]!==p?(m=(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[l,p]}),t[17]=l,t[18]=p,t[19]=m):m=t[19];let h;t[20]!==c||t[21]!==m?(h=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[c,m]}),t[20]=c,t[21]=m,t[22]=h):h=t[22];let g;return t[23]!==o||t[24]!==h?(g=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[o,h]}),t[23]=o,t[24]=h,t[25]=g):g=t[25],g}function ur(e){var t;let n=(0,$.c)(22),{question:r,onConfirm:i}=e,a=(t=r.defaultValue)==null?!1:t,[o,s]=(0,Z.useState)(null),c;n[0]===r.description?c=n[1]:(c=r.description&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r.description}),n[0]=r.description,n[1]=c);let l=o===!1?`default`:`outline`,u;n[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>s(!1),n[2]=u):u=n[2];let d=a?`No`:`Cancel`,f;n[3]!==l||n[4]!==d?(f=(0,Q.jsx)(W,{variant:l,size:`sm`,onClick:u,children:d}),n[3]=l,n[4]=d,n[5]=f):f=n[5];let p=o===!0?`default`:`outline`,m;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>s(!0),n[6]=m):m=n[6];let h=a?`Yes`:`Confirm`,g;n[7]!==p||n[8]!==h?(g=(0,Q.jsx)(W,{variant:p,size:`sm`,onClick:m,children:h}),n[7]=p,n[8]=h,n[9]=g):g=n[9];let _;n[10]!==f||n[11]!==g?(_=(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[f,g]}),n[10]=f,n[11]=g,n[12]=_):_=n[12];let v;n[13]!==i||n[14]!==o?(v=o!==null&&(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(W,{size:`sm`,onClick:()=>i(o),children:`Submit`})}),n[13]=i,n[14]=o,n[15]=v):v=n[15];let y;n[16]!==_||n[17]!==v?(y=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[_,v]}),n[16]=_,n[17]=v,n[18]=y):y=n[18];let b;return n[19]!==c||n[20]!==y?(b=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[c,y]}),n[19]=c,n[20]=y,n[21]=b):b=n[21],b}function dr(e){let t=(0,$.c)(29),{question:n,onSubmit:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={},t[0]=i):i=t[0];let[a,o]=(0,Z.useState)(i),s;if(t[1]!==a||t[2]!==n.questions){let e;t[4]===a?e=t[5]:(e=(e,t)=>a[t]!==void 0,t[4]=a,t[5]=e),s=n.questions.every(e),t[1]=a,t[2]=n.questions,t[3]=s}else s=t[3];let c=s,l;t[6]!==a||t[7]!==r||t[8]!==n.questions?(l=()=>{r({type:`form`,answers:n.questions.map((e,t)=>({question:e.question,answer:a[t]}))})},t[6]=a,t[7]=r,t[8]=n.questions,t[9]=l):l=t[9];let u=l,d;t[10]===n.description?d=t[11]:(d=n.description&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n.description}),t[10]=n.description,t[11]=d);let f;if(t[12]!==n.questions){let e;t[14]===n.questions.length?e=t[15]:(e=(e,t)=>(0,Q.jsxs)(`div`,{className:`border-l-2 border-primary/30 pl-3`,children:[(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground mb-2`,children:[`Question `,t+1,` of `,n.questions.length]}),(0,Q.jsx)(fr,{question:e,onAnswer:e=>o(n=>({...n,[t]:e}))})]},t),t[14]=n.questions.length,t[15]=e),f=n.questions.map(e),t[12]=n.questions,t[13]=f}else f=t[13];let p;t[16]===f?p=t[17]:(p=(0,Q.jsx)(`div`,{className:`flex flex-col gap-4`,children:f}),t[16]=f,t[17]=p);let m=!c,h;t[18]===a?h=t[19]:(h=Object.keys(a),t[18]=a,t[19]=h);let g;t[20]!==u||t[21]!==n.questions.length||t[22]!==m||t[23]!==h.length?(g=(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsxs)(W,{size:`sm`,onClick:u,disabled:m,children:[`Submit All (`,h.length,`/`,n.questions.length,`)`]})}),t[20]=u,t[21]=n.questions.length,t[22]=m,t[23]=h.length,t[24]=g):g=t[24];let _;return t[25]!==d||t[26]!==p||t[27]!==g?(_=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d,p,g]}),t[25]=d,t[26]=p,t[27]=g,t[28]=_):_=t[28],_}function fr(e){let t=(0,$.c)(61),{question:n,onAnswer:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=new Set,t[0]=i):i=t[0];let[a,o]=(0,Z.useState)(i),[s,c]=(0,Z.useState)(null);switch(n.type){case`single_select`:{let e;t[1]===n.question?e=t[2]:(e=(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:n.question}),t[1]=n.question,t[2]=e);let i;if(t[3]!==r||t[4]!==n.options||t[5]!==a){let e;t[7]!==r||t[8]!==a?(e=e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{o(new Set([e.value])),r(e.value)},className:`px-3 py-1.5 text-xs rounded-md border transition-colors ${a.has(e.value)?`border-primary bg-primary/10`:`border-border hover:border-primary/50`}`,children:e.label},e.value),t[7]=r,t[8]=a,t[9]=e):e=t[9],i=n.options.map(e),t[3]=r,t[4]=n.options,t[5]=a,t[6]=i}else i=t[6];let s;t[10]===i?s=t[11]:(s=(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:i}),t[10]=i,t[11]=s);let c;return t[12]!==e||t[13]!==s?(c=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e,s]}),t[12]=e,t[13]=s,t[14]=c):c=t[14],c}case`multi_select`:{let e;t[15]!==r||t[16]!==n.max?(e=e=>{o(t=>{let i=new Set(t);if(i.has(e))i.delete(e);else if(!n.max||i.size<n.max)i.add(e);else return t;return r(Array.from(i)),i})},t[15]=r,t[16]=n.max,t[17]=e):e=t[17];let i=e,s;t[18]===n.question?s=t[19]:(s=(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:n.question}),t[18]=n.question,t[19]=s);let c;if(t[20]!==n.options||t[21]!==a||t[22]!==i){let e;t[24]!==a||t[25]!==i?(e=e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>i(e.value),className:`px-3 py-1.5 text-xs rounded-md border transition-colors ${a.has(e.value)?`border-primary bg-primary/10`:`border-border hover:border-primary/50`}`,children:e.label},e.value),t[24]=a,t[25]=i,t[26]=e):e=t[26],c=n.options.map(e),t[20]=n.options,t[21]=a,t[22]=i,t[23]=c}else c=t[23];let l;t[27]===c?l=t[28]:(l=(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:c}),t[27]=c,t[28]=l);let u;return t[29]!==s||t[30]!==l?(u=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[s,l]}),t[29]=s,t[30]=l,t[31]=u):u=t[31],u}case`text`:{let e;t[32]===n.question?e=t[33]:(e=(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:n.question}),t[32]=n.question,t[33]=e);let i;t[34]===r?i=t[35]:(i=e=>r(e.target.value),t[34]=r,t[35]=i);let a;t[36]!==n.defaultValue||t[37]!==n.placeholder||t[38]!==i?(a=(0,Q.jsx)(V,{type:`text`,placeholder:n.placeholder,defaultValue:n.defaultValue,onChange:i}),t[36]=n.defaultValue,t[37]=n.placeholder,t[38]=i,t[39]=a):a=t[39];let o;return t[40]!==e||t[41]!==a?(o=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e,a]}),t[40]=e,t[41]=a,t[42]=o):o=t[42],o}case`confirm`:{let e;t[43]===n.question?e=t[44]:(e=(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:n.question}),t[43]=n.question,t[44]=e);let i=s===!1?`default`:`outline`,a;t[45]===r?a=t[46]:(a=()=>{c(!1),r(!1)},t[45]=r,t[46]=a);let o;t[47]!==i||t[48]!==a?(o=(0,Q.jsx)(W,{variant:i,size:`sm`,onClick:a,children:`No`}),t[47]=i,t[48]=a,t[49]=o):o=t[49];let l=s===!0?`default`:`outline`,u;t[50]===r?u=t[51]:(u=()=>{c(!0),r(!0)},t[50]=r,t[51]=u);let d;t[52]!==l||t[53]!==u?(d=(0,Q.jsx)(W,{variant:l,size:`sm`,onClick:u,children:`Yes`}),t[52]=l,t[53]=u,t[54]=d):d=t[54];let f;t[55]!==o||t[56]!==d?(f=(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[o,d]}),t[55]=o,t[56]=d,t[57]=f):f=t[57];let p;return t[58]!==e||t[59]!==f?(p=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e,f]}),t[58]=e,t[59]=f,t[60]=p):p=t[60],p}}}function pr(e){var t,n,r,i;let a=(0,$.c)(79),{ask:o,onRespond:s}=e,c;a[0]===Symbol.for(`react.memo_cache_sentinel`)?(c={none:`text-muted-foreground`,low:`text-success`,medium:`text-warning`,high:`text-destructive`,critical:`text-destructive`},a[0]=c):c=a[0];let l=c,u=(t=o.intents)==null?void 0:t[0],d=(n=o.action)==null?u==null?void 0:u.action:n,f=(r=(i=o.resource)==null?u==null?void 0:u.resource:i)==null?`shell-command`:r,p=d===`read`?`Reading`:d===`write`?`Writing to`:d===`delete`?`Deleting`:d===`request`?`Requesting`:d===`execute`?`Executing`:null,m,h,g,_,v,y,b,x,S,C,w,T;if(a[1]!==o.allowedScopes||a[2]!==o.description||a[3]!==o.metadata||a[4]!==o.paths||a[5]!==o.risk||a[6]!==d||a[7]!==f||a[8]!==s||a[9]!==p||a[10]!==u){var E;let e=(E=o.allowedScopes)==null?[`once`,`session`,`workspace`]:E,t=(u==null?void 0:u.persistable)===!1?u.nonPersistableReason:void 0,n={};f===`file`&&d===`read`?(n.session=`Allow for This Session`,n.workspace=`Always Allow Reading This File`):f===`file`&&d===`write`?(n.session=`Allow for This Session`,n.workspace=`Always Allow Writing This File`):f===`file`&&d===`delete`?n.session=`Allow for This Session`:f===`network`?(n.session=`Allow for This Session`,n.workspace=`Always Allow This Network Request`):f===`shell-command`&&(n.session=`Allow for This Session`);let r=e=>{if(n[e])return n[e];switch(e){case`once`:return`Allow Once`;case`session`:return`Allow for This Session`;case`workspace`:return`Allow for Workspace`;case`always`:return`Allow for Workspace`;default:return`Allow (${e})`}};if(a[23]!==o.description||a[24]!==o.metadata||a[25]!==o.paths||a[26]!==o.risk||a[27]!==f||a[28]!==p||a[29]!==(u==null?void 0:u.targets)){var D;let e=(D=u==null?void 0:u.targets)==null?[]:D,t=e.length>0?e.map(hr):[],n;a[37]!==o.metadata||a[38]!==f?(n=()=>{var e;return f!==`shell-command`||typeof((e=o.metadata)==null?void 0:e.command)!=`string`?null:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground mb-1`,children:`Command`}),(0,Q.jsx)(`pre`,{className:`text-xs bg-muted/50 border rounded-md p-2 overflow-x-auto whitespace-pre-wrap break-all font-mono`,children:o.metadata.command})]})},a[37]=o.metadata,a[38]=f,a[39]=n):n=a[39];let r=n,i;a[40]!==o.paths||a[41]!==f||a[42]!==p?(i=()=>{let e=o.paths,t=f===`file`||f===`path`||f===`directory`;return!e||e.length===0||!t?null:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground mb-1`,children:p==null?`Accessing`:p}),(0,Q.jsx)(`pre`,{className:`text-xs bg-muted/50 border rounded-md p-2 overflow-x-auto whitespace-pre-wrap break-all font-mono`,children:e.join(`
8
- `)})]})},a[40]=o.paths,a[41]=f,a[42]=p,a[43]=i):i=a[43];let s=i,c;a[44]!==o.metadata||a[45]!==f?(c=()=>{var e;return f!==`network`||typeof((e=o.metadata)==null?void 0:e.url)!=`string`?null:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground mb-1`,children:`URL`}),(0,Q.jsx)(`pre`,{className:`text-xs bg-muted/50 border rounded-md p-2 overflow-x-auto whitespace-pre-wrap break-all font-mono`,children:o.metadata.url})]})},a[44]=o.metadata,a[45]=f,a[46]=c):c=a[46];let d=c,g=()=>t.length===0||f===`shell-command`?null:(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.map(mr)});if(x=`flex flex-col gap-3`,a[47]===o.description?S=a[48]:(S=o.description&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o.description}),a[47]=o.description,a[48]=S),a[49]!==o.risk){var O,k;C=o.risk&&(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Q.jsxs)(`span`,{className:`text-xs font-medium uppercase ${(O=l[(k=o.risk)==null?`none`:k])==null?`text-muted-foreground`:O}`,children:[`Risk: `,o.risk]})}),a[49]=o.risk,a[50]=C}else C=a[50];a[51]===r?w=a[52]:(w=r(),a[51]=r,a[52]=w),a[53]===s?T=a[54]:(T=s(),a[53]=s,a[54]=T),a[55]===d?m=a[56]:(m=d(),a[55]=d,a[56]=m),h=g(),a[23]=o.description,a[24]=o.metadata,a[25]=o.paths,a[26]=o.risk,a[27]=f,a[28]=p,a[29]=u==null?void 0:u.targets,a[30]=m,a[31]=h,a[32]=x,a[33]=S,a[34]=C,a[35]=w,a[36]=T}else m=a[30],h=a[31],x=a[32],S=a[33],C=a[34],w=a[35],T=a[36];if(a[57]!==o.description||a[58]!==o.metadata){var A;g=(A=o.metadata)!=null&&A.description&&typeof o.metadata.description==`string`&&!o.description?(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o.metadata.description}):null,a[57]=o.description,a[58]=o.metadata,a[59]=g}else g=a[59];a[60]===t?_=a[61]:(_=t&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground italic`,children:[`This command is too dynamic to save as a reusable permission (`,t,`).`]}),a[60]=t,a[61]=_),v=`flex flex-wrap gap-2`,a[62]===s?y=a[63]:(y=(0,Q.jsx)(W,{variant:`destructive`,size:`sm`,onClick:()=>s({type:`permission`,grant:`deny`}),children:`Block`}),a[62]=s,a[63]=y),b=e.map(e=>(0,Q.jsx)(W,{variant:e===`workspace`?`default`:`outline`,size:`sm`,onClick:()=>s({type:`permission`,grant:e}),children:r(e)},e)),a[1]=o.allowedScopes,a[2]=o.description,a[3]=o.metadata,a[4]=o.paths,a[5]=o.risk,a[6]=d,a[7]=f,a[8]=s,a[9]=p,a[10]=u,a[11]=m,a[12]=h,a[13]=g,a[14]=_,a[15]=v,a[16]=y,a[17]=b,a[18]=x,a[19]=S,a[20]=C,a[21]=w,a[22]=T}else m=a[11],h=a[12],g=a[13],_=a[14],v=a[15],y=a[16],b=a[17],x=a[18],S=a[19],C=a[20],w=a[21],T=a[22];let j;a[64]!==v||a[65]!==y||a[66]!==b?(j=(0,Q.jsxs)(`div`,{className:v,children:[y,b]}),a[64]=v,a[65]=y,a[66]=b,a[67]=j):j=a[67];let M;return a[68]!==m||a[69]!==h||a[70]!==g||a[71]!==_||a[72]!==j||a[73]!==x||a[74]!==S||a[75]!==C||a[76]!==w||a[77]!==T?(M=(0,Q.jsxs)(`div`,{className:x,children:[S,C,w,T,m,h,g,_,j]}),a[68]=m,a[69]=h,a[70]=g,a[71]=_,a[72]=j,a[73]=x,a[74]=S,a[75]=C,a[76]=w,a[77]=T,a[78]=M):M=a[78],M}function mr(e,t){return(0,Q.jsx)(`code`,{className:`text-xs bg-muted/50 border rounded px-1.5 py-0.5 font-mono`,children:e},t)}function hr(e){return e.target.split(`/`).pop()||e.target}function gr(e){let t=(0,$.c)(15),{ask:n,onRespond:r}=e,i;t[0]===n.capability?i=t[1]:(i=(0,Q.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Client capability request: `,(0,Q.jsx)(`code`,{className:`text-xs bg-muted px-1.5 py-0.5 rounded`,children:n.capability})]}),t[0]=n.capability,t[1]=i);let a;t[2]===n.metadata?a=t[3]:(a=n.metadata&&(0,Q.jsx)(`pre`,{className:`text-xs bg-background border rounded-md p-2 overflow-x-auto`,children:JSON.stringify(n.metadata,null,2)}),t[2]=n.metadata,t[3]=a);let o;t[4]===r?o=t[5]:(o=(0,Q.jsx)(W,{variant:`outline`,size:`sm`,onClick:()=>r(void 0),children:`Not Available`}),t[4]=r,t[5]=o);let s;t[6]===r?s=t[7]:(s=(0,Q.jsx)(W,{size:`sm`,onClick:()=>r(null),children:`Confirm`}),t[6]=r,t[7]=s);let c;t[8]!==o||t[9]!==s?(c=(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[o,s]}),t[8]=o,t[9]=s,t[10]=c):c=t[10];let l;return t[11]!==i||t[12]!==a||t[13]!==c?(l=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[i,a,c]}),t[11]=i,t[12]=a,t[13]=c,t[14]=l):l=t[14],l}function _r(e){let t=(0,$.c)(78),{request:n,onRespond:r}=e,{toolCallId:i,toolName:a,ask:o,requestId:s}=n,c;t[0]!==r||t[1]!==s||t[2]!==i?(c=e=>{r(i,{type:`single_select`,value:e},s)},t[0]=r,t[1]=s,t[2]=i,t[3]=c):c=t[3];let l=c,u;t[4]!==r||t[5]!==s||t[6]!==i?(u=e=>{r(i,{type:`multi_select`,values:e},s)},t[4]=r,t[5]=s,t[6]=i,t[7]=u):u=t[7];let d=u,f;t[8]!==r||t[9]!==s||t[10]!==i?(f=e=>{r(i,{type:`text`,value:e},s)},t[8]=r,t[9]=s,t[10]=i,t[11]=f):f=t[11];let p=f,m;t[12]!==r||t[13]!==s||t[14]!==i?(m=e=>{r(i,{type:`confirm`,confirmed:e},s)},t[12]=r,t[13]=s,t[14]=i,t[15]=m):m=t[15];let h=m,g;t[16]!==r||t[17]!==s||t[18]!==i?(g=e=>{r(i,e,s)},t[16]=r,t[17]=s,t[18]=i,t[19]=g):g=t[19];let _=g,v;t[20]!==r||t[21]!==s||t[22]!==i?(v=e=>{r(i,e,s)},t[20]=r,t[21]=s,t[22]=i,t[23]=v):v=t[23];let y=v,b;t[24]!==o.capability||t[25]!==o.type||t[26]!==r||t[27]!==s||t[28]!==i?(b=e=>{r(i,{type:`client_capability`,capability:o.type===`client_capability`?o.capability:``,result:e},s)},t[24]=o.capability,t[25]=o.type,t[26]=r,t[27]=s,t[28]=i,t[29]=b):b=t[29];let x=b,S;bb0:{if(`type`in o)switch(o.type){case`single_select`:case`multi_select`:case`text`:case`confirm`:case`form`:{let e;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(e={icon:Je,borderClass:`border-primary/30 bg-primary/5`,iconClass:`text-primary`},t[30]=e):e=t[30],S=e;break bb0}case`permission`:{let e;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(e={icon:G,borderClass:`border-warning/30 bg-warning/5`,iconClass:`text-warning`},t[31]=e):e=t[31],S=e;break bb0}case`client_capability`:{let e;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(e={icon:_e,borderClass:`border-info/30 bg-info/5`,iconClass:`text-info`},t[32]=e):e=t[32],S=e;break bb0}}let e;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(e={icon:G,borderClass:`border-warning/30 bg-warning/5`,iconClass:`text-warning`},t[33]=e):e=t[33],S=e}let C=S,w=C.icon,T=`border ${C.borderClass} rounded-lg p-4 flex flex-col gap-4`,E=`flex items-start gap-2 ${C.iconClass}`,D;t[34]===w?D=t[35]:(D=(0,Q.jsx)(w,{className:`size-4 mt-0.5 shrink-0`}),t[34]=w,t[35]=D);let O;t[36]===a?O=t[37]:(O=(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground uppercase tracking-wide`,children:a}),t[36]=a,t[37]=O);let k;t[38]===o?k=t[39]:(k=`question`in o&&(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:o.question}),t[38]=o,t[39]=k);let A;t[40]!==O||t[41]!==k?(A=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[O,k]}),t[40]=O,t[41]=k,t[42]=A):A=t[42];let j;t[43]!==E||t[44]!==D||t[45]!==A?(j=(0,Q.jsxs)(`div`,{className:E,children:[D,A]}),t[43]=E,t[44]=D,t[45]=A,t[46]=j):j=t[46];let M;t[47]!==o||t[48]!==l?(M=o.type===`single_select`&&(0,Q.jsx)(sr,{question:o,onSelect:l}),t[47]=o,t[48]=l,t[49]=M):M=t[49];let N;t[50]!==o||t[51]!==d?(N=o.type===`multi_select`&&(0,Q.jsx)(cr,{question:o,onSelect:d}),t[50]=o,t[51]=d,t[52]=N):N=t[52];let P;t[53]!==o||t[54]!==p?(P=o.type===`text`&&(0,Q.jsx)(lr,{question:o,onSubmit:p}),t[53]=o,t[54]=p,t[55]=P):P=t[55];let F;t[56]!==o||t[57]!==h?(F=o.type===`confirm`&&(0,Q.jsx)(ur,{question:o,onConfirm:h}),t[56]=o,t[57]=h,t[58]=F):F=t[58];let I;t[59]!==o||t[60]!==_?(I=o.type===`form`&&(0,Q.jsx)(dr,{question:o,onSubmit:_}),t[59]=o,t[60]=_,t[61]=I):I=t[61];let L;t[62]!==o||t[63]!==y?(L=(o.type===`permission`||!(`type`in o))&&(0,Q.jsx)(pr,{ask:o,onRespond:y}),t[62]=o,t[63]=y,t[64]=L):L=t[64];let R;t[65]!==o||t[66]!==x?(R=o.type===`client_capability`&&(0,Q.jsx)(gr,{ask:o,onRespond:x}),t[65]=o,t[66]=x,t[67]=R):R=t[67];let z;return t[68]!==j||t[69]!==M||t[70]!==N||t[71]!==P||t[72]!==F||t[73]!==I||t[74]!==L||t[75]!==R||t[76]!==T?(z=(0,Q.jsxs)(`div`,{className:T,children:[j,M,N,P,F,I,L,R]}),t[68]=j,t[69]=M,t[70]=N,t[71]=P,t[72]=F,t[73]=I,t[74]=L,t[75]=R,t[76]=T,t[77]=z):z=t[77],z}var vr=1536,yr=(0,Z.memo)(function(e){let t=(0,$.c)(16),{content:n,className:r}=e,[i,a]=(0,Z.useState)(!1),o;t[0]===n?o=t[1]:(o=new Blob([n]),t[0]=n,t[1]=o);let s=o.size,c=s>vr,l=c?n.slice(0,vr)+`
9
- ...`:null;if(!c){let e;return t[2]!==r||t[3]!==n?(e=(0,Q.jsx)(`pre`,{className:r,children:n}),t[2]=r,t[3]=n,t[4]=e):e=t[4],e}let u;t[5]===s?u=t[6]:(u=s>1048576?`${(s/1048576).toFixed(1)} MB`:s>1024?`${(s/1024).toFixed(1)} KB`:`${s} bytes`,t[5]=s,t[6]=u);let d=u,f=i?n:l,p;t[7]!==r||t[8]!==f?(p=(0,Q.jsx)(`pre`,{className:r,children:f}),t[7]=r,t[8]=f,t[9]=p):p=t[9];let m;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>a(Tr),t[10]=m):m=t[10];let h=i?`Show less`:`Show full output (${d})`,g;t[11]===h?g=t[12]:(g=(0,Q.jsx)(`button`,{type:`button`,className:`text-xs text-muted-foreground hover:text-foreground mt-1 transition-colors cursor-pointer`,onClick:m,children:h}),t[11]=h,t[12]=g);let _;return t[13]!==p||t[14]!==g?(_=(0,Q.jsxs)(`div`,{children:[p,g]}),t[13]=p,t[14]=g,t[15]=_):_=t[15],_});function br(e){switch(e){case`pending`:return(0,Q.jsx)(Xe,{className:`size-3 text-warning`});case`running`:return(0,Q.jsx)(re,{className:`size-3 text-warning animate-spin`});case`completed`:return(0,Q.jsx)(U,{className:`size-3 text-success`});case`error`:return(0,Q.jsx)(o,{className:`size-3 text-destructive`});case`interrupted`:return(0,Q.jsx)(Re,{className:`size-3 text-warning`});default:return null}}function xr(e){if(e.name!==`task`)return null;let t=e.state;if(`childSessionId`in t&&t.childSessionId)return t.childSessionId;let n=`output`in t?t.output:`partialOutput`in t?t.partialOutput:null;if(n&&typeof n==`string`){let e=n.match(/task_id:\s*([a-f0-9-]{36})/i);if(e)return e[1]}return null}function Sr(e){if(e&&typeof e==`object`&&`_visualization`in e)return e._visualization}function Cr(e,t){let n=new Set,r=[e];for(;r.length>0;){let e=r.shift();for(let i of t)i.parentId===e&&!n.has(i.id)&&(n.add(i.id),r.push(i.id))}return n}var wr=(0,Z.memo)(function({part:e,pendingAskRequests:t,onAskResponse:n,onNavigateToSubagent:r}){let[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),l=e.state,u=l.status,d=(0,Z.useMemo)(()=>{if(!i)return``;try{return JSON.stringify(l.input,null,2)}catch{return String(l.input)}},[l.input,i]),p=(0,Z.useMemo)(()=>!i||u!==`completed`||!(`output`in l)?null:typeof l.output==`string`?l.output:JSON.stringify(l.output,null,2),[u,l,i]),m=u===`completed`&&`output`in l?Sr(l.output):void 0,h=xr(e),g=E(e=>e.sessions),_=[];if(u===`pending`||u===`running`){let n=t.find(t=>t.toolCallId===e.callId);if(n&&_.push(n),h){let n=Cr(h,g);n.add(h);let r=t.filter(t=>{let r=t.originSessionId&&n.has(t.originSessionId),i=t.sessionId===h;return(r||i)&&t.toolCallId!==e.callId});_.push(...r)}}let v=async()=>{if(`output`in l){let e=typeof l.output==`string`?l.output:JSON.stringify(l.output,null,2);await navigator.clipboard.writeText(e),s(!0),setTimeout(()=>s(!1),2e3)}},y=(()=>{try{let e=JSON.stringify(l.input);return e.length>50?e.slice(0,47)+`...`:e}catch{return String(l.input)}})();return(0,Q.jsxs)(`div`,{className:`my-1`,children:[(0,Q.jsxs)(M,{open:i,onOpenChange:a,children:[(0,Q.jsx)(D,{asChild:!0,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 py-1 cursor-pointer hover:text-foreground transition-colors text-muted-foreground`,children:[i?(0,Q.jsx)(Ke,{className:`size-4 text-muted-foreground`}):(0,Q.jsx)(f,{className:`size-4 text-muted-foreground`}),(0,Q.jsx)(Ce,{className:`size-3`}),(0,Q.jsx)(`span`,{className:`text-xs truncate max-w-[120px] sm:max-w-none`,children:e.name}),!i&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground font-mono truncate flex-1 min-w-0 sm:max-w-[200px] hidden sm:block`,children:y}),(0,Q.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[br(u),h&&r&&(0,Q.jsxs)(W,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 sm:w-auto sm:px-2`,onClick:e=>{e.stopPropagation(),r(h)},title:`View session`,children:[(0,Q.jsx)(Ee,{className:`size-3`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline ml-1`,children:`View`})]})]})]})}),i&&(0,Q.jsx)(I,{children:(0,Q.jsxs)(`div`,{className:`pl-5 pb-2 flex flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground mb-1`,children:`Input`}),(0,Q.jsx)(yr,{content:d,className:`text-xs bg-background border rounded-md p-2 overflow-x-auto whitespace-pre-wrap break-words`})]}),(u===`running`||u===`completed`||u===`interrupted`)&&h&&r&&(0,Q.jsxs)(W,{variant:`outline`,className:`w-full`,size:`sm`,onClick:()=>r(h),children:[(0,Q.jsx)(Ee,{className:`size-4`,"data-icon":`inline-start`}),u===`running`?`Watch Subagent`:`View Session`]}),u===`completed`&&p!==null&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,Q.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground`,children:`Output`}),(0,Q.jsx)(W,{variant:`ghost`,size:`icon`,onClick:v,className:`size-6`,children:o?(0,Q.jsx)(c,{className:`size-3 text-success`}):(0,Q.jsx)(Te,{className:`size-3`})})]}),(0,Q.jsx)(yr,{content:p,className:`text-xs bg-success/10 border border-success/20 rounded-md p-2 overflow-x-auto whitespace-pre-wrap break-words`})]}),u===`error`&&`error`in l&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground mb-1`,children:`Error`}),(0,Q.jsx)(`pre`,{className:`text-xs bg-destructive/10 border border-destructive/20 rounded-md p-2 overflow-x-auto whitespace-pre-wrap break-words text-destructive`,children:l.error})]})]})})]}),_.length>0&&(0,Q.jsx)(`div`,{className:`mt-2 flex flex-col gap-2`,children:_.map(e=>{var t;return(0,Q.jsx)(_r,{request:e,onRespond:n},(t=e.requestId)==null?e.toolCallId:t)})}),u===`completed`&&m&&(0,Q.jsx)(`div`,{className:`mt-2`,children:(0,Q.jsx)(ir,{visualization:m})})]})},(e,t)=>{if(e.part!==t.part||e.onNavigateToSubagent!==t.onNavigateToSubagent||e.onAskResponse!==t.onAskResponse||e.pendingAskRequests.find(t=>t.toolCallId===e.part.callId)!==t.pendingAskRequests.find(e=>e.toolCallId===t.part.callId))return!1;let n=xr(e.part),r=xr(t.part);if(n||r){let i=e.pendingAskRequests.filter(e=>e.originSessionId===n||e.originSessionId===r||e.sessionId===n||e.sessionId===r),a=t.pendingAskRequests.filter(e=>e.originSessionId===n||e.originSessionId===r||e.sessionId===n||e.sessionId===r);if(i.length!==a.length||i.some((e,t)=>e!==a[t]))return!1}return!0});function Tr(e){return!e}var Er=60,Dr=300,Or=16;function kr(e){if(e.length===0)return!1;let t=e[e.length-1];return He(t.message)&&t.message.status===`streaming`}function Ar(e){return e.filter(e=>e.type===`text`).map(e=>e.text).join(``)}function jr(e,t){let n=t.findIndex(t=>t.message.id===e);if(n<0)return null;if(n===0)return e;for(let e=n-1;e>=0;e--){let n=t[e];if(n.message.role===`assistant`&&n.message.status!==`streaming`)return n.message.id}return null}function Mr(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-foreground bg-muted rounded-lg px-3 py-2 border border-border shadow-sm`,children:[(0,Q.jsx)(rt,{className:`size-4 animate-pulse`}),(0,Q.jsx)(`span`,{children:`Compacting conversation...`})]}),e[0]=t):t=e[0],t}function Nr(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-green-700 dark:text-green-400 bg-green-500/15 rounded-lg px-3 py-2 border border-green-500/30 shadow-sm`,children:[(0,Q.jsx)(qe,{className:`size-4`}),(0,Q.jsx)(`span`,{children:`Compaction complete`})]}),e[0]=t):t=e[0],t}function Pr(e){let t=(0,$.c)(8),{message:n,textContent:r,onRetry:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs uppercase tracking-wide text-destructive ml-3`,children:[(0,Q.jsx)(Ve,{className:`size-3`}),`Compaction Failed`]}),t[0]=a):a=t[0];let o=r||n.error||`Compaction failed. The conversation could not be summarized.`,s;t[1]===o?s=t[2]:(s=(0,Q.jsx)(`p`,{className:`text-sm text-destructive/90`,children:o}),t[1]=o,t[2]=s);let c;t[3]===i?c=t[4]:(c=i&&(0,Q.jsxs)(W,{variant:`outline`,size:`sm`,onClick:i,className:`mt-2 h-7 text-xs gap-1.5`,children:[(0,Q.jsx)(Be,{className:`size-3`}),`Retry`]}),t[3]=i,t[4]=c);let l;return t[5]!==s||t[6]!==c?(l=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0`,children:[a,(0,Q.jsxs)(`div`,{className:`rounded-2xl px-4 py-3 max-w-full bg-destructive/10 border border-destructive/30 rounded-bl-md`,children:[s,c]})]}),t[5]=s,t[6]=c,t[7]=l):l=t[7],l}function Fr(e,t){var n;return(e==null?void 0:e.split(`/`).pop())||(t==null||(n=t.split(`.`).pop())==null?void 0:n.toLowerCase())||``}function Ir(e){let t=(0,$.c)(15),{part:n}=e,[r,i]=(0,Z.useState)(!1),a=n.overflow?`overflow`:n.auto?`auto`:`manual`,o;t[0]===r?o=t[1]:(o=()=>i(!r),t[0]=r,t[1]=o);let s;t[2]===r?s=t[3]:(s=r?(0,Q.jsx)(Ke,{className:`size-3`}):(0,Q.jsx)(f,{className:`size-3`}),t[2]=r,t[3]=s);let c=a===`overflow`?`Context overflow`:a===`auto`?`Auto`:`Manual`,l;t[4]===c?l=t[5]:(l=(0,Q.jsxs)(`span`,{className:`border-b border-dashed border-muted-foreground/40 pb-px`,children:[c,` compaction`]}),t[4]=c,t[5]=l);let u;t[6]!==o||t[7]!==s||t[8]!==l?(u=(0,Q.jsxs)(`button`,{onClick:o,className:`flex items-center gap-2 text-xs text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,children:[s,l]}),t[6]=o,t[7]=s,t[8]=l,t[9]=u):u=t[9];let d;t[10]===r?d=t[11]:(d=r&&(0,Q.jsx)(`div`,{className:`mt-2 text-xs text-muted-foreground italic`,children:`Summary available in the assistant message below`}),t[10]=r,t[11]=d);let p;return t[12]!==u||t[13]!==d?(p=(0,Q.jsxs)(`div`,{className:`flex flex-col items-center py-3`,children:[u,d]}),t[12]=u,t[13]=d,t[14]=p):p=t[14],p}var Lr=(0,Z.memo)(function(e){let t=(0,$.c)(15),{parts:n,pendingAskRequests:r,onAskResponse:i,onNavigateToSubagent:a,inverted:o,serverUrl:s}=e,c=o===void 0?!1:o,l;if(t[0]!==c||t[1]!==i||t[2]!==a||t[3]!==n||t[4]!==r||t[5]!==s){let e=[...n].sort(Br),o;t[7]!==c||t[8]!==i||t[9]!==a||t[10]!==r||t[11]!==s?(o=e=>{switch(e.type){case`text`:return(0,Q.jsx)(`div`,{className:`min-w-0`,children:(0,Q.jsx)(xe,{inverted:c,children:e.text||`...`})},e.id);case`reasoning`:return(0,Q.jsx)(`div`,{className:`visualization-container text-muted-foreground text-sm italic border-l-2 border-muted-foreground/30 pl-3 my-2 wrap-break-word`,children:e.text},e.id);case`tool`:return(0,Q.jsx)(wr,{part:e,pendingAskRequests:r,onAskResponse:i,onNavigateToSubagent:a},e.id);case`image`:return(0,Q.jsx)(`img`,{src:s?cn(s,e.url):e.url,alt:``,className:v(`max-w-full max-h-64 rounded-xl mt-2 object-contain`,c&&`ring-2 ring-white/20`)},e.id);case`file`:{let t=s?cn(s,e.url):e.url,n=Fr(e.mimeType,e.filename),r=e.filename||``,i=r.length>30?r.slice(0,27)+`...`:r||`unnamed`;return(0,Q.jsxs)(`a`,{href:t,className:v(`mt-2 p-2 rounded-lg text-sm flex items-center gap-2 transition-colors`,c?`bg-white/15 hover:bg-white/25 text-primary-foreground`:`bg-muted hover:bg-accent`),target:`_blank`,rel:`noopener noreferrer`,children:[(0,Q.jsx)(pe,{className:`size-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`truncate`,children:i}),n&&(0,Q.jsx)(`span`,{className:v(`px-1.5 py-0.5 rounded text-[10px] font-semibold uppercase tracking-wide ml-auto shrink-0`,c?`bg-white/25 text-primary-foreground`:`bg-secondary text-secondary-foreground`),children:n}),(0,Q.jsx)(Ze,{className:`size-3.5 shrink-0 opacity-60`})]},e.id)}default:return null}},t[7]=c,t[8]=i,t[9]=a,t[10]=r,t[11]=s,t[12]=o):o=t[12],l=e.map(o),t[0]=c,t[1]=i,t[2]=a,t[3]=n,t[4]=r,t[5]=s,t[6]=l}else l=t[6];let u;return t[13]===l?u=t[14]:(u=(0,Q.jsx)(Q.Fragment,{children:l}),t[13]=l,t[14]=u),u},(e,t)=>!(e.parts!==t.parts||e.inverted!==t.inverted||e.onNavigateToSubagent!==t.onNavigateToSubagent||e.serverUrl!==t.serverUrl||e.pendingAskRequests!==t.pendingAskRequests)),Rr=(0,Z.memo)(function(e){let t=(0,$.c)(47),{item:n,messagesWithParts:r,sessionId:i,pendingAskRequests:a,onAskResponse:o,onNavigateToSubagent:s,onRemoveFromQueue:c,onRevert:l,onFork:u,isMainActiveSession:d,isCompacting:f,onCompact:p,serverUrl:m}=e,h=d===void 0?!1:d,g=f===void 0?!1:f,_;t[0]===n.parts?_=t[1]:(_=n.parts.find(Vr),t[0]=n.parts,t[1]=_);let v=_;if(He(n.message)&&n.message.mode===`compact_failed`){let e=n.message,r;t[2]===n.parts?r=t[3]:(r=Ar(n.parts),t[2]=n.parts,t[3]=r);let i=h&&!g?p:void 0,a;return t[4]!==e||t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(Pr,{message:e,textContent:r,onRetry:i}),t[4]=e,t[5]=r,t[6]=i,t[7]=a):a=t[7],a}if(v){let e;return t[8]===v?e=t[9]:(e=(0,Q.jsx)(Ir,{part:v}),t[8]=v,t[9]=e),e}let y=!n.isQueued&&n.message.role===`user`,b;t[10]!==y||t[11]!==n.message.id||t[12]!==r?(b=y?jr(n.message.id,r):null,t[10]=y,t[11]=n.message.id,t[12]=r,t[13]=b):b=t[13];let x=b,S=x===n.message.id,C=n.message,w;t[14]===n.parts?w=t[15]:(w=Ar(n.parts),t[14]=n.parts,t[15]=w);let T;t[16]!==n.isQueued||t[17]!==n.queueId||t[18]!==c?(T=n.isQueued?()=>c(n.queueId):void 0,t[16]=n.isQueued,t[17]=n.queueId,t[18]=c,t[19]=T):T=t[19];let E=y&&x!==null,D;t[20]!==l||t[21]!==x||t[22]!==i?(D=x?()=>l==null?void 0:l(i,x):void 0,t[20]=l,t[21]=x,t[22]=i,t[23]=D):D=t[23];let O=y&&x!==null,k;t[24]!==n.message.id||t[25]!==u||t[26]!==x||t[27]!==i?(k=x?()=>u==null?void 0:u(i,n.message.id):void 0,t[24]=n.message.id,t[25]=u,t[26]=x,t[27]=i,t[28]=k):k=t[28];let A;t[29]!==n.message.role||t[30]!==n.parts||t[31]!==o||t[32]!==s||t[33]!==a||t[34]!==m?(A=n.parts.length===0?(0,Q.jsx)(`span`,{className:`opacity-50`,children:`...`}):(0,Q.jsx)(Lr,{parts:n.parts,pendingAskRequests:a,onAskResponse:o,onNavigateToSubagent:s,inverted:n.message.role===`user`,serverUrl:m}),t[29]=n.message.role,t[30]=n.parts,t[31]=o,t[32]=s,t[33]=a,t[34]=m,t[35]=A):A=t[35];let j;return t[36]!==S||t[37]!==n.isQueued||t[38]!==n.message||t[39]!==O||t[40]!==k||t[41]!==A||t[42]!==w||t[43]!==T||t[44]!==E||t[45]!==D?(j=(0,Q.jsx)(An,{message:C,textContent:w,isQueued:n.isQueued,onRemove:T,canRevert:E,onRevert:D,canFork:O,onFork:k,isClearAll:S,children:A}),t[36]=S,t[37]=n.isQueued,t[38]=n.message,t[39]=O,t[40]=k,t[41]=A,t[42]=w,t[43]=T,t[44]=E,t[45]=D,t[46]=j):j=t[46],j});function zr({displayItems:e,messagesWithParts:t,sessionId:n,sessionStatus:r,pendingAskRequests:i,isCompacting:a=!1,compactionSuccess:o=!1,onClearCompactionSuccess:s,onAskResponse:c,onNavigateToSubagent:l,onRemoveFromQueue:u,onRevert:d,onFork:f,onCompact:p,isMainActiveSession:m=!1,autoFollow:h=!0,onAutoScrollChange:g,scrollToBottomRef:_,serverUrl:v}){var y,b;let x=(0,Z.useRef)(null),[S,C]=(0,Z.useState)(!1),w=(0,Z.useRef)(h),T=(0,Z.useRef)(e.length),E=(0,Z.useRef)(0),D=(0,Z.useRef)(!1),O=(0,Z.useRef)(!1),k=(0,Z.useRef)(``),A=(0,Z.useCallback)(e=>{if(e.length===0)return``;let t=e[e.length-1],n=t.parts.filter(e=>e.type===`text`).reduce((e,t)=>e+t.text.length,0);return`${t.message.id}:${He(t.message)?t.message.status:`n/a`}:${t.parts.length}:${n}`},[]),j=(0,Z.useRef)(null),M=(0,Z.useRef)(null),N=(0,Z.useRef)(new Map),P=(0,Z.useRef)(e);P.current=e;let F=(0,Z.useCallback)(e=>{let t=P.current[e];if(!t)return Er+Or;if(t.message.role===`assistant`){let e=100;return t.parts.some(e=>{var t,n;return e.type===`text`&&((t=e.text)==null?void 0:t.includes("```"))||e.type===`tool`&&((n=e.state.input)==null?void 0:n.command)})&&(e=180),t.parts.some(e=>e.type===`tool`)&&(e=Math.max(e,150)),t.parts.some(e=>e.type===`compaction`)&&(e=60),t.message.mode===`compact_failed`&&(e=100),Math.min(Math.max(e+Or,Er+Or),Dr+Or)}let n=t.parts.length>1?80:60;return Math.min(Math.max(n+Or,Er+Or),Dr+Or)},[]);(0,Z.useLayoutEffect)(()=>{let e=x.current;if(!e)return;let t=requestAnimationFrame(()=>{e.querySelectorAll(`[data-index]`).forEach(e=>{let t=e.getAttribute(`data-index`);if(t===null)return;let n=parseInt(t,10);N.current.set(n,e.offsetHeight)})});return()=>cancelAnimationFrame(t)},[e.length]);let I=(0,Z.useRef)(null);(0,Z.useLayoutEffect)(()=>{let e=x.current;if(!e)return;I.current&&I.current.disconnect();let t=new ResizeObserver(e=>{e.forEach(e=>{let t=e.target,n=t.getAttribute(`data-index`);if(n===null)return;let r=parseInt(n,10),i=t.offsetHeight;N.current.set(r,i)})});return I.current=t,e.querySelectorAll(`[data-index]`).forEach(e=>t.observe(e)),()=>t.disconnect()},[e.length]);let L=kn({count:e.length,getScrollElement:()=>x.current,estimateSize:F,overscan:5,getItemKey:t=>{var n,r;let i=e[t];return(n=i==null||(r=i.message)==null?void 0:r.id)==null?`fallback-${t}`:n}});(0,Z.useLayoutEffect)(()=>{w.current=h,T.current=e.length,E.current=0,D.current=!1,k.current=``,e.length!==0&&(L.scrollToIndex(e.length-1,{align:`end`}),D.current=!0)},[n]),(0,Z.useEffect)(()=>{let e=x.current;if(!e)return;let t=e=>{w.current&&e.deltaY<0&&(w.current=!1,g==null||g(!1))};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[g]);let R=ln(()=>{if(O.current)return;let e=x.current;if(e)if(w.current){let{scrollTop:t,scrollHeight:n,clientHeight:r}=e;n-t-r>0&&(O.current=!0,e.scrollTop=n,requestAnimationFrame(()=>{O.current=!1}))}else{let{scrollTop:t,scrollHeight:n,clientHeight:r}=e;n-t-r<=5&&(w.current=!0,g==null||g(!0))}});(0,Z.useLayoutEffect)(()=>{C(a)},[a]);let z=A(e);(0,Z.useLayoutEffect)(()=>{let t=e.length,n=T.current,r=t!==n,i=z,a=i!==k.current;k.current=i;let o=t-1,s=0;if(o>=0){var c;s=(c=N.current.get(o))==null?0:c}let l=E.current,u=o>=0&&s>l&&l>0;if(T.current=t,E.current=s,!(t===0||!r&&!a&&!u)){if(n===0&&t>0&&l===0&&!D.current){L.scrollToIndex(t-1,{align:`end`}),D.current=!0;return}w.current&&(x.current.scrollTop=x.current.scrollHeight)}},[e.length,z,L]),(0,Z.useEffect)(()=>{var t;let n=L.getVirtualItems(),r=n.length-1;if(r<0)return;let i=n[r],a=(t=x.current)==null?void 0:t.querySelector(`[data-index="${i.index}"]`);if(j.current&&j.current.disconnect(),a&&(M.current=a,!(!kr(e)||!w.current)))return j.current=new ResizeObserver(t=>{w.current&&kr(e)&&requestAnimationFrame(()=>{w.current&&(x.current.scrollTop=x.current.scrollHeight)})}),j.current.observe(a),()=>{j.current&&(j.current.disconnect(),j.current=null)}},[e,L]),(0,Z.useEffect)(()=>{if(o){let e=setTimeout(()=>{s==null||s()},3e3);return()=>clearTimeout(e)}},[o,s]),(0,Z.useLayoutEffect)(()=>{_&&(_.current=()=>{w.current=!0,O.current=!0,x.current.scrollTop=x.current.scrollHeight,requestAnimationFrame(()=>{O.current=!1})})},[_]),(0,Z.useLayoutEffect)(()=>{w.current=h},[h]);let ee=L.getVirtualItems();return(0,Q.jsxs)(`div`,{ref:x,className:`flex-1 min-h-0 overflow-y-auto relative chat-transcript-scrollbar`,style:{WebkitOverflowScrolling:`touch`},onScroll:R,children:[S&&(0,Q.jsx)(`div`,{className:`sticky top-0 z-10 px-4 pt-4 pb-1 bg-gradient-to-b from-background via-background/95 to-transparent`,children:(0,Q.jsx)(Mr,{})}),o&&(0,Q.jsx)(`div`,{className:`sticky top-0 z-10 px-4 pt-4 pb-1 bg-gradient-to-b from-background via-background/95 to-transparent`,children:(0,Q.jsx)(Nr,{})}),r===`closed`&&(0,Q.jsx)(J,{className:`mx-4 mt-4`,children:(0,Q.jsx)(ve,{children:`This session is archived. You can reopen it from the sidebar.`})}),(0,Q.jsx)(`div`,{className:`relative w-full`,style:{height:`${L.getTotalSize()}px`},children:e.length===0?(0,Q.jsxs)(`div`,{className:`text-center py-16 text-muted-foreground px-4`,children:[(0,Q.jsx)(`p`,{className:`text-lg mb-2`,children:`Start a conversation`}),(0,Q.jsx)(`p`,{className:`text-sm`,children:`Send a message below to begin.`})]}):(0,Q.jsx)(`div`,{className:`absolute top-0 left-0 w-full`,style:{transform:`translateY(${(y=(b=ee[0])==null?void 0:b.start)==null?0:y}px)`},children:ee.map(r=>{let o=e[r.index];return(0,Q.jsx)(`div`,{"data-index":r.index,ref:L.measureElement,className:`px-4 py-4`,children:(0,Q.jsx)(Rr,{item:o,messagesWithParts:t,sessionId:n,pendingAskRequests:i,onAskResponse:c,onNavigateToSubagent:l,onRemoveFromQueue:u,onRevert:d,onFork:f,isMainActiveSession:m,isCompacting:a,onCompact:p,serverUrl:v})},o.message.id)})})})]})}function Br(e,t){return e.createdAt-t.createdAt}function Vr(e){return e.type===`compaction`}function Hr(e,t,n){let r=e.map(e=>({message:e.message,parts:e.parts,isQueued:!1})),i=t.map(e=>{let t=(e.attachments||[]).map(t=>{var r;let i=n(e.sessionId,t.id,(r=t.accessKey)==null?``:r);return t.kind===`image`?{id:`${e.id}-att-${t.id}`,messageId:e.id,createdAt:e.createdAt,type:`image`,url:i,mimeType:t.mimeType}:{id:`${e.id}-att-${t.id}`,messageId:e.id,createdAt:e.createdAt,type:`file`,url:i,mimeType:t.mimeType||``,filename:t.filename}});return{message:{id:e.id,role:`user`,sessionId:e.sessionId,createdAt:e.createdAt},parts:[...t,...e.content.trim()?[{id:`${e.id}-part`,messageId:e.id,createdAt:e.createdAt,type:`text`,text:e.content}]:[]],isQueued:!0,queueId:e.id}}),a=[...r].sort((e,t)=>e.message.createdAt-t.message.createdAt),o=[...i].sort((e,t)=>e.message.createdAt-t.message.createdAt);return[...a,...o]}function Ur(e){var t;let n=(0,$.c)(94),{session:r,messagesWithParts:i,queuedMessages:a,preconfigs:o,prompts:s,models:c,defaultModel:l,onSendMessage:u,onRemoveFromQueue:d,onChangePreconfig:f,onChangeModel:p,onChangeVariant:m,pendingAskRequests:h,onAskResponse:g,onRename:_,usage:v,modelName:y,modelSupportsImage:b,onNavigateToSubagent:x,onNavigateBack:S,isStreaming:C,onInterrupt:w,onRevert:T,onFork:E,onCompact:D,isCompacting:O,compactionSuccess:k,onClearCompactionSuccess:A,serverUrl:j,sdkClient:M,selectedVariant:N,variants:P,inputRef:F,scrollToBottomRef:I,autoFollowToggleRef:L,onClaimControl:R,onReleaseControl:z,onRequestTakeover:ee,onRespondTakeover:B}=e,te=!r.parentId&&r.status===`active`,V;n[0]===r.id?V=n[1]:(V=e=>e.controlBySessionId[r.id],n[0]=r.id,n[1]=V);let H=ue(V),U=ge(Gr),ne=(H==null?void 0:H.status)===`controlled`&&H.controllerClientId!==U,re=(H==null?void 0:H.status)===`grace`,W=ne||re,[G,K]=(0,Z.useState)(null),ie=(0,Z.useRef)(null),ae;n[2]===Symbol.for(`react.memo_cache_sentinel`)?(ae=e=>{ie.current&&clearTimeout(ie.current),K(e),ie.current=setTimeout(()=>{K(null),ie.current=null},4e3)},n[2]=ae):ae=n[2];let oe=ae,se,ce;n[3]===Symbol.for(`react.memo_cache_sentinel`)?(se=()=>()=>{ie.current&&clearTimeout(ie.current)},ce=[],n[3]=se,n[4]=ce):(se=n[3],ce=n[4]),(0,Z.useEffect)(se,ce);let q,le;n[5]===r.id?(q=n[6],le=n[7]):(q=()=>{let e=null;return ue.subscribe(t=>{t.lastActionRejection!==e&&(e=t.lastActionRejection,e&&e.sessionId===r.id&&oe(e.message))})},le=[r.id,oe],n[5]=r.id,n[6]=q,n[7]=le),(0,Z.useEffect)(q,le);let[de,fe]=(0,Z.useState)(!0),pe;n[8]===I?pe=n[9]:(pe=()=>{fe(e=>{let t=!e;if(t){var n;I==null||(n=I.current)==null||n.call(I)}return t})},n[8]=I,n[9]=pe);let he=pe,_e,ve;n[10]!==L||n[11]!==he?(_e=()=>{L&&(L.current={toggle:()=>{he()}})},ve=[L,he],n[10]=L,n[11]=he,n[12]=_e,n[13]=ve):(_e=n[12],ve=n[13]),(0,Z.useEffect)(_e,ve);let ye=(t=M==null?void 0:M.http.attachments.getUrl)==null?Wr:t,be;n[14]!==i||n[15]!==a||n[16]!==ye?(be=Hr(i,a,ye),n[14]=i,n[15]=a,n[16]=ye,n[17]=be):be=n[17];let xe=be,Se=i.length>=2,J;n[18]!==l||n[19]!==O||n[20]!==C||n[21]!==y||n[22]!==c||n[23]!==p||n[24]!==f||n[25]!==m||n[26]!==R||n[27]!==D||n[28]!==w||n[29]!==S||n[30]!==z||n[31]!==_||n[32]!==ee||n[33]!==B||n[34]!==o||n[35]!==N||n[36]!==r||n[37]!==Se||n[38]!==v||n[39]!==P?(J=(0,Q.jsx)(Ht,{session:r,preconfigs:o,models:c,defaultModel:l,usage:v,modelName:y,onChangePreconfig:f,onChangeModel:p,onChangeVariant:m,onRename:_,onNavigateBack:S,isStreaming:C,onInterrupt:w,onCompact:D,isCompacting:O,canCompact:Se,selectedVariant:N,variants:P,onClaimControl:R,onReleaseControl:z,onRequestTakeover:ee,onRespondTakeover:B}),n[18]=l,n[19]=O,n[20]=C,n[21]=y,n[22]=c,n[23]=p,n[24]=f,n[25]=m,n[26]=R,n[27]=D,n[28]=w,n[29]=S,n[30]=z,n[31]=_,n[32]=ee,n[33]=B,n[34]=o,n[35]=N,n[36]=r,n[37]=Se,n[38]=v,n[39]=P,n[40]=J):J=n[40];let Ce;n[41]!==E||n[42]!==T||n[43]!==de||n[44]!==k||n[45]!==xe||n[46]!==O||n[47]!==te||n[48]!==i||n[49]!==g||n[50]!==A||n[51]!==D||n[52]!==x||n[53]!==d||n[54]!==h||n[55]!==I||n[56]!==j||n[57]!==r.id||n[58]!==r.status?(Ce=(0,Q.jsx)(zr,{displayItems:xe,messagesWithParts:i,sessionId:r.id,sessionStatus:r.status,pendingAskRequests:h,isCompacting:O,compactionSuccess:k,onClearCompactionSuccess:A,onAskResponse:g,onNavigateToSubagent:x,onRemoveFromQueue:d,onRevert:T,onFork:E,onCompact:D,isMainActiveSession:te,autoFollow:de,onAutoScrollChange:fe,scrollToBottomRef:I,serverUrl:j}),n[41]=E,n[42]=T,n[43]=de,n[44]=k,n[45]=xe,n[46]=O,n[47]=te,n[48]=i,n[49]=g,n[50]=A,n[51]=D,n[52]=x,n[53]=d,n[54]=h,n[55]=I,n[56]=j,n[57]=r.id,n[58]=r.status,n[59]=Ce):Ce=n[59];let Te=de?`Auto-follow enabled (Cmd+Shift+F)`:`Auto-follow disabled (Cmd+Shift+F)`,Ee;n[60]===de?Ee=n[61]:(Ee=de?(0,Q.jsx)(Ue,{className:`size-3.5`}):(0,Q.jsx)(we,{className:`size-3.5`}),n[60]=de,n[61]=Ee);let Y;n[62]!==he||n[63]!==Te||n[64]!==Ee?(Y=(0,Q.jsx)(`button`,{onClick:he,className:`absolute bottom-4 right-4 z-50 flex items-center p-1.5 text-xs rounded-full transition-colors cursor-pointer bg-background/80 backdrop-blur-sm hover:bg-background border border-border/50 shadow-sm pointer-events-auto`,title:Te,children:Ee}),n[62]=he,n[63]=Te,n[64]=Ee,n[65]=Y):Y=n[65];let De;n[66]!==Ce||n[67]!==Y?(De=(0,Q.jsxs)(`div`,{className:`relative flex flex-col flex-1 min-h-0`,children:[Ce,Y]}),n[66]=Ce,n[67]=Y,n[68]=De):De=n[68];let Oe;n[69]!==F||n[70]!==O||n[71]!==W||n[72]!==b||n[73]!==u||n[74]!==s||n[75]!==M||n[76]!==r.id||n[77]!==r.parentId||n[78]!==r.status||n[79]!==r.workspaceId?(Oe=r.status===`active`&&!r.parentId&&(0,Q.jsx)(on,{ref:F,onSendMessage:u,disabled:O||W,workspaceId:r.workspaceId,sdkClient:M,prompts:s,sessionId:r.id,modelSupportsImage:b}),n[69]=F,n[70]=O,n[71]=W,n[72]=b,n[73]=u,n[74]=s,n[75]=M,n[76]=r.id,n[77]=r.parentId,n[78]=r.status,n[79]=r.workspaceId,n[80]=Oe):Oe=n[80];let ke;n[81]===r.parentId?ke=n[82]:(ke=r.parentId&&(0,Q.jsxs)(`div`,{className:`p-4 border-t border-border bg-muted/50 text-center flex items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,Q.jsx)(me,{className:`size-4`}),`This is a subagent session (read-only)`]}),n[81]=r.parentId,n[82]=ke);let X;n[83]===ne?X=n[84]:(X=ne&&(0,Q.jsxs)(`div`,{className:`px-4 py-2 border-t border-border bg-muted/30 text-center flex items-center justify-center gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(ot,{className:`size-3.5`}),`You are observing this session. Input is disabled.`]}),n[83]=ne,n[84]=X);let Ae;n[85]===G?Ae=n[86]:(Ae=G&&(0,Q.jsxs)(`div`,{className:`px-4 py-2 border-t border-orange-500/30 bg-orange-50 dark:bg-orange-950/30 text-center flex items-center justify-center gap-2 text-xs text-orange-600 dark:text-orange-400`,children:[(0,Q.jsx)(ot,{className:`size-3.5`}),G]}),n[85]=G,n[86]=Ae);let je;return n[87]!==J||n[88]!==De||n[89]!==Oe||n[90]!==ke||n[91]!==X||n[92]!==Ae?(je=(0,Q.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-0 relative`,children:[J,De,Oe,ke,X,Ae]}),n[87]=J,n[88]=De,n[89]=Oe,n[90]=ke,n[91]=X,n[92]=Ae,n[93]=je):je=n[93],je}function Wr(e,t,n){return`/api/sessions/${encodeURIComponent(e)}/attachments/${encodeURIComponent(t)}/content?key=${encodeURIComponent(n)}`}function Gr(e){return e.clientId}function Kr(e){var t,n,r;let i=(0,$.c)(77),{serverUrl:a,messagesWithParts:o,inputRef:s,sdkClient:c,onRetry:l,onLogout:u,onSendMessage:d,onRemoveFromQueue:f,onChangePreconfig:p,onChangeModel:m,onChangeVariant:h,onAskResponse:g,onRename:_,onNavigateToSubagent:v,onNavigateBack:y,onInterrupt:b,onRevert:S,onFork:C,onCompact:w,onClearCompactionSuccess:T,scrollToBottomRef:D,autoFollowToggleRef:O,onClaimControl:k,onReleaseControl:A,onRequestTakeover:j,onRespondTakeover:M}=e,P=N(di),I=N(ui),L=N(li),R=N(ci),z=N(si),ee=N(oi),B=E(ai),te=E(ii),V=E(ri),H=E(ni),U=E(ti),ne=E(ei),re=F($r),G=F(Qr),K=F(Zr),ie=F(Xr),ae=x(Yr),oe;i[0]===re?oe=i[1]:(oe=re.filter(Jr),i[0]=re,i[1]=oe);let se=oe,ce=!(B!=null&&B.parentId),q=(t=B==null?void 0:B.compacting)==null?!1:t,le;i[2]===p?le=i[3]:(le=e=>{p(e)},i[2]=p,i[3]=le);let ue=le,de;i[4]===h?de=i[5]:(de=e=>{h(e)},i[4]=h,i[5]=de);let fe=de,pe;i[6]===b?pe=i[7]:(pe=()=>{b()},i[6]=b,i[7]=pe);let me=pe;if(!P){if(L){let e;return i[8]!==I||i[9]!==z||i[10]!==u||i[11]!==l||i[12]!==R||i[13]!==a?(e=(0,Q.jsx)(`div`,{className:`flex w-full h-full items-center justify-center bg-background`,children:(0,Q.jsx)(Ot,{serverUrl:a,authError:I,retryCount:R,nextRetryIn:z,onRetry:l,onLogout:u})}),i[8]=I,i[9]=z,i[10]=u,i[11]=l,i[12]=R,i[13]=a,i[14]=e):e=i[14],e}let e;i[15]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(Dt,{}),i[15]=e):e=i[15];let t;return i[16]===u?t=i[17]:(t=(0,Q.jsxs)(`div`,{className:`flex flex-col w-full h-full items-center justify-center bg-background gap-4`,children:[e,(0,Q.jsx)(W,{variant:`ghost`,size:`sm`,onClick:u,className:`text-muted-foreground`,children:`Change Server`})]}),i[16]=u,i[17]=t),t}if(!B){let e;return i[18]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-center text-muted-foreground px-6`,children:[(0,Q.jsx)(`h2`,{className:`mb-2`,children:`Select or create a session`}),(0,Q.jsx)(`p`,{children:`Choose a session from the sidebar or create a new one to start chatting.`})]}),i[18]=e):e=i[18],e}let he;i[19]===o?he=i[20]:(he=o.filter(qr),i[19]=o,i[20]=he);let ge=he.length>=2,_e;if(i[21]!==H||i[22]!==K){let e;i[24]===H?e=i[25]:(e=e=>e.id===H,i[24]=H,i[25]=e),_e=K.find(e),i[21]=H,i[22]=K,i[23]=_e}else _e=i[23];let ve=_e,ye;i[26]!==B.id||i[27]!==te?(ye=te[B.id]||[],i[26]=B.id,i[27]=te,i[28]=ye):ye=i[28];let be=ce?se:re,xe=ve==null?void 0:ve.variants,Se=(n=ve==null||(r=ve.capabilities)==null||(r=r.input)==null?void 0:r.image)==null?!1:n,J;i[29]!==B.id||i[30]!==B.runningAt||i[31]!==ee?(J=ee.has(B.id)||!!B.runningAt,i[29]=B.id,i[30]=B.runningAt,i[31]=ee,i[32]=J):J=i[32];let Ce;i[33]!==ge||i[34]!==B.id||i[35]!==w?(Ce=ge?()=>w(B.id):void 0,i[33]=ge,i[34]=B.id,i[35]=w,i[36]=Ce):Ce=i[36];let we=a==null?void 0:a,Te;return i[37]!==O||i[38]!==ne||i[39]!==H||i[40]!==B||i[41]!==ie||i[42]!==ue||i[43]!==fe||i[44]!==me||i[45]!==s||i[46]!==q||i[47]!==o||i[48]!==K||i[49]!==g||i[50]!==m||i[51]!==k||i[52]!==T||i[53]!==C||i[54]!==y||i[55]!==v||i[56]!==A||i[57]!==f||i[58]!==_||i[59]!==j||i[60]!==M||i[61]!==S||i[62]!==d||i[63]!==ae||i[64]!==G||i[65]!==D||i[66]!==c||i[67]!==U||i[68]!==V||i[69]!==Se||i[70]!==J||i[71]!==Ce||i[72]!==we||i[73]!==ye||i[74]!==be||i[75]!==xe?(Te=(0,Q.jsx)(Ur,{inputRef:s,session:B,messagesWithParts:o,queuedMessages:ye,preconfigs:be,prompts:G,models:K,defaultModel:ie,onSendMessage:d,onRemoveFromQueue:f,onChangePreconfig:ue,onChangeModel:m,onChangeVariant:fe,selectedVariant:U,variants:xe,pendingAskRequests:ae,onAskResponse:g,onRename:_,usage:V,modelName:H,modelSupportsImage:Se,onNavigateToSubagent:v,onNavigateBack:y,isStreaming:J,onInterrupt:me,onRevert:S,onFork:C,onCompact:Ce,isCompacting:q,compactionSuccess:ne,onClearCompactionSuccess:T,serverUrl:we,sdkClient:c,scrollToBottomRef:D,autoFollowToggleRef:O,onClaimControl:k,onReleaseControl:A,onRequestTakeover:j,onRespondTakeover:M}),i[37]=O,i[38]=ne,i[39]=H,i[40]=B,i[41]=ie,i[42]=ue,i[43]=fe,i[44]=me,i[45]=s,i[46]=q,i[47]=o,i[48]=K,i[49]=g,i[50]=m,i[51]=k,i[52]=T,i[53]=C,i[54]=y,i[55]=v,i[56]=A,i[57]=f,i[58]=_,i[59]=j,i[60]=M,i[61]=S,i[62]=d,i[63]=ae,i[64]=G,i[65]=D,i[66]=c,i[67]=U,i[68]=V,i[69]=Se,i[70]=J,i[71]=Ce,i[72]=we,i[73]=ye,i[74]=be,i[75]=xe,i[76]=Te):Te=i[76],Te}function qr(e){return e.message.role!==`system`}function Jr(e){return e.mode!==`subagent`}function Yr(e){return e.pendingRequests}function Xr(e){return e.defaultModel}function Zr(e){return e.models}function Qr(e){return e.prompts}function $r(e){return e.preconfigs}function ei(e){return e.compactionSuccess}function ti(e){return e.selectedVariant}function ni(e){return e.currentModel}function ri(e){return e.sessionUsage}function ii(e){return e.queuedMessages}function ai(e){return e.currentSession}function oi(e){return e.streamingSessionIds}function si(e){return e.nextRetryIn}function ci(e){return e.retryCount}function li(e){return e.connectionTimedOut}function ui(e){return e.authError}function di(e){return e.connected}function fi(){let e=(0,$.c)(30),t=te(),{chatInputRef:n,scrollToBottomRef:r,autoFollowToggleRef:i}=w(),{sdkClient:a,messagesWithParts:o,serverUrl:s,currentSession:c,isSessionLoading:l,resumeSession:u,revertSession:d,forkSession:f,compactSession:p,removeFromQueue:m,sendChatMessage:h,handleAskResponse:g,handleInterruptSession:_,updateSessionPreconfig:v,updateSessionModel:y,updateSessionVariant:b,handleNavigateBack:x,handleRenameSession:S,setCompactionSuccess:C}=t;if(l){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsx)(Et,{}),e[0]=t):t=e[0],t}if(!c)return null;let T;e[1]===C?T=e[2]:(T=()=>C(!1),e[1]=C,e[2]=T);let E;return e[3]!==i||e[4]!==n||e[5]!==p||e[6]!==f||e[7]!==g||e[8]!==_||e[9]!==x||e[10]!==S||e[11]!==o||e[12]!==m||e[13]!==u||e[14]!==d||e[15]!==r||e[16]!==a||e[17]!==h||e[18]!==s||e[19]!==t.claimControl||e[20]!==t.handleLogout||e[21]!==t.handleRetry||e[22]!==t.releaseControl||e[23]!==t.requestTakeover||e[24]!==t.respondTakeover||e[25]!==T||e[26]!==y||e[27]!==v||e[28]!==b?(E=(0,Q.jsx)(Kr,{sdkClient:a,inputRef:n,messagesWithParts:o,serverUrl:s,onRetry:t.handleRetry,onLogout:t.handleLogout,onSendMessage:h,onRemoveFromQueue:m,onChangePreconfig:v,onChangeModel:y,onChangeVariant:b,onAskResponse:g,onRename:S,onNavigateToSubagent:u,onNavigateBack:x,onInterrupt:_,onRevert:d,onFork:f,onCompact:p,onClearCompactionSuccess:T,scrollToBottomRef:r,autoFollowToggleRef:i,onClaimControl:t.claimControl,onReleaseControl:t.releaseControl,onRequestTakeover:t.requestTakeover,onRespondTakeover:t.respondTakeover}),e[3]=i,e[4]=n,e[5]=p,e[6]=f,e[7]=g,e[8]=_,e[9]=x,e[10]=S,e[11]=o,e[12]=m,e[13]=u,e[14]=d,e[15]=r,e[16]=a,e[17]=h,e[18]=s,e[19]=t.claimControl,e[20]=t.handleLogout,e[21]=t.handleRetry,e[22]=t.releaseControl,e[23]=t.requestTakeover,e[24]=t.respondTakeover,e[25]=T,e[26]=y,e[27]=v,e[28]=b,e[29]=E):E=e[29],E}export{fi as t};