@adhdev/daemon-standalone 0.9.77-rc.3 → 0.9.77-rc.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/daemon-standalone",
3
- "version": "0.9.77-rc.3",
3
+ "version": "0.9.77-rc.30",
4
4
  "description": "ADHDev standalone daemon — embedded HTTP/WS server for local dashboard",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -1,9 +1,9 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/terminal-BeBmUW3m.js","assets/vendor-CLec0455.js","assets/terminal-6GBZ9nXN.css"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/terminal-B-dmfv31.js","assets/vendor-CLec0455.js","assets/terminal-6GBZ9nXN.css"])))=>i.map(i=>d[i]);
2
2
  var eu=Object.defineProperty;var tu=(e,t,r)=>t in e?eu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Je=(e,t,r)=>tu(e,typeof t!="symbol"?t+"":t,r);import{r as i,j as s,M as Xa,a as su,b as ru,c as nu,R as Ct,d as fr,t as au,e as ou,u as Os,D as iu,f as Na,g as Ca,h as Ja,i as cu,k as lu,B as du,l as uu,m as qt,N as Ta,n as mu}from"./vendor-CLec0455.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))n(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const c of o.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&n(c)}).observe(document,{childList:!0,subtree:!0});function r(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function n(a){if(a.ep)return;a.ep=!0;const o=r(a);fetch(a.href,o)}})();function fu(e={}){const t=Math.max(1,Math.floor(e.capacity||200)),r=[];return{record(n){const a={id:`webdbg_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`,ts:Date.now(),...n,payload:n.payload?{...n.payload}:{}};return r.push(a),r.length>t&&r.splice(0,r.length-t),a},list(n={}){const a=Math.max(1,Math.floor(n.limit||100));return r.filter(o=>!n.interactionId||o.interactionId===n.interactionId).filter(o=>!n.topic||o.topic===n.topic).filter(o=>!n.kind||o.kind===n.kind).slice(-a).map(o=>({...o,payload:o.payload?{...o.payload}:{}}))},clear(){r.splice(0,r.length)}}}const Rs=fu();function qo(e){const t={};for(const r of e)r.transport&&(t[r.transport]=(t[r.transport]||0)+1);return{count:e.length,ids:e.map(r=>r.id),statuses:e.map(r=>String(r.status||"unknown")),transports:t}}function pu(e,t){return typeof e=="string"&&e.trim().length>0&&e!==t}function pc(e,t){return e?t?{...t,...e,messages:[],activeModal:null,inputContent:e.inputContent??t.inputContent}:e??null:t??null}function rr(e,t){const r=pu(e.providerName,e.providerType)?e.providerName:void 0;return{...e,parentId:e.parentId??(t==null?void 0:t.parentSessionId)??null,providerSessionId:e.providerSessionId??(t==null?void 0:t.providerSessionId),providerName:r??(t==null?void 0:t.providerName)??(t==null?void 0:t.cliName)??(t==null?void 0:t.type)??e.providerName??e.providerType,title:e.title??(t==null?void 0:t.title)??r??(t==null?void 0:t.providerName)??e.providerName??e.providerType,workspace:e.workspace??(t==null?void 0:t.workspace)??null,mode:e.mode??(t==null?void 0:t.mode),capabilities:e.capabilities??(t==null?void 0:t.sessionCapabilities)??(t==null?void 0:t.capabilities)??[],cdpConnected:e.cdpConnected??(t==null?void 0:t.cdpConnected),activeChat:pc(e.activeChat,t==null?void 0:t.activeChat),controlValues:e.controlValues??(t==null?void 0:t.controlValues),providerControls:e.providerControls??(t==null?void 0:t.providerControls),summaryMetadata:e.summaryMetadata??(t==null?void 0:t.summaryMetadata),runtimeWriteOwner:e.runtimeWriteOwner??(t==null?void 0:t.runtimeWriteOwner),runtimeAttachedClients:e.runtimeAttachedClients??(t==null?void 0:t.runtimeAttachedClients),lastMessagePreview:e.lastMessagePreview??(t==null?void 0:t.lastMessagePreview),lastMessageRole:e.lastMessageRole??(t==null?void 0:t.lastMessageRole),lastMessageAt:e.lastMessageAt??(t==null?void 0:t.lastMessageAt),lastMessageHash:e.lastMessageHash??(t==null?void 0:t.lastMessageHash),unread:e.unread??(t==null?void 0:t.unread),lastSeenAt:e.lastSeenAt??(t==null?void 0:t.lastSeenAt),inboxBucket:e.inboxBucket??(t==null?void 0:t.inboxBucket),completionMarker:e.completionMarker??(t==null?void 0:t.completionMarker),seenCompletionMarker:e.seenCompletionMarker??(t==null?void 0:t.seenCompletionMarker),surfaceHidden:e.surfaceHidden??(t==null?void 0:t.surfaceHidden),resume:e.resume??(t==null?void 0:t.resume),runtimeKey:e.runtimeKey??(t==null?void 0:t.runtimeKey),runtimeDisplayName:e.runtimeDisplayName??(t==null?void 0:t.runtimeDisplayName),runtimeWorkspaceLabel:e.runtimeWorkspaceLabel??(t==null?void 0:t.runtimeWorkspaceLabel),settings:e.settings??(t==null?void 0:t.settings)}}function hc(e,t,r){if(!(t!=null&&t.length))return(r==null?void 0:r.preserveMissing)===!1&&Array.isArray(t)?t:e;if(!(e!=null&&e.length))return t;const n=t.map(a=>{const o=e.find(c=>c.id===a.id);return o?rr(a,o):a});if((r==null?void 0:r.preserveMissing)!==!1){const a=new Set(t.map(o=>o.id));for(const o of e)a.has(o.id)||n.push(o)}return n}function Yo(e){return!!e&&typeof e=="object"&&"text"in e}function Qa(e,t){const r=(t==null?void 0:t.joiner)??" ",n=(t==null?void 0:t.normalizeWhitespace)??!1;let a="";return typeof e=="string"?a=e:Array.isArray(e)?a=e.map(o=>typeof o=="string"?o:Yo(o)?String(o.text||""):"").join(r):Yo(e)?a=String(e.text||""):a=String(e||""),n?a.replace(/\s+/g," ").trim():a}function Ls(e){return Qa(e,{normalizeWhitespace:!0})}const xc=i.createContext({ides:[],updateRouteChats:()=>{},initialLoaded:!1,toasts:[],setToasts:()=>{},wsStatus:"connected",isConnected:!0,connectionStates:{},connectionTransports:{},showReconnected:!1,userName:void 0,setUserName:()=>{},isP2PActive:!1,p2pStates:{},userRole:void 0,connectionRetryStatuses:void 0}),bc=i.createContext({injectEntries:()=>{},markLoaded:()=>{},getIdes:()=>[]});function Xo(e){var r,n;let t=0;return e.activeChat!==void 0&&(t+=4),(r=e.childSessions)!=null&&r.length&&(t+=2),e.workspace&&(t+=1),e.machine&&(t+=1),(n=e.agents)!=null&&n.length&&(t+=1),t}function gc(e,t,r){if(r.type!=="adhdev-daemon")return r;const n={...r},a=t.version??r.version??e.version,o=t.serverVersion??e.serverVersion??r.serverVersion,c=t.versionMismatch===!0||e.versionMismatch===!0,l=t.versionUpdateRequired===!0||e.versionUpdateRequired===!0,d=t.versionUpdateReason??e.versionUpdateReason??r.versionUpdateReason;return a&&(n.version=a),o&&(n.serverVersion=o),d&&(n.versionUpdateReason=d),a&&o&&a===o?(delete n.versionMismatch,delete n.serverVersion,delete n.versionUpdateRequired,delete n.versionUpdateReason,n):((t.versionMismatch===!0||c&&a&&o&&a!==o)&&(n.versionMismatch=!0),l&&(n.versionUpdateRequired=!0),n)}function hu(e){let t=2166136261;for(let r=0;r<e.length;r+=1)t^=e.charCodeAt(r),t=Math.imul(t,16777619)>>>0;return t.toString(16).padStart(8,"0")}function En(e){if(!e||typeof e!="object")return"";const t=e,r=hu(Ls(t.content).slice(0,512));return[String(t.id||""),String(t._localId||""),String(t._turnKey||""),String(t.index??""),String(t.role||""),String(t.receivedAt??t.timestamp??""),r].join(":")}function xu(e,t){if(!Array.isArray(e))return e;if(t!=null&&t.has(e))return{count:e.length,sharedRef:!0};let r=2166136261;for(const n of e){const a=En(n);for(let o=0;o<a.length;o+=1)r^=a.charCodeAt(o),r=Math.imul(r,16777619)>>>0}return{count:e.length,hash:r.toString(16).padStart(8,"0"),first:En(e[0]),last:En(e[e.length-1])}}function Ia(e){return!!e&&typeof e=="object"&&"messages"in e&&("activeModal"in e||"inputContent"in e||"status"in e)}function Aa(e,t,r){if(!e||!t||typeof e!="object"||typeof t!="object")return;if(Ia(e)&&Ia(t)){const c=e.messages;Array.isArray(c)&&c===t.messages&&r.add(c)}if(Array.isArray(e)&&Array.isArray(t)){const c=Math.min(e.length,t.length);for(let l=0;l<c;l+=1)Aa(e[l],t[l],r);return}const n=e,a=t,o=new Set([...Object.keys(n),...Object.keys(a)]);for(const c of o)c!=="messages"&&Aa(n[c],a[c],r)}function or(e,t){return Array.isArray(e)?e.map(r=>or(r,t)):!e||typeof e!="object"?e:Ia(e)?Object.fromEntries(Object.entries(e).filter(([n])=>n!=="timestamp"&&n!=="_lastUpdate").sort(([n],[a])=>n.localeCompare(a)).map(([n,a])=>[n,n==="messages"?xu(a,t):or(a,t)])):Object.fromEntries(Object.entries(e).filter(([r])=>r!=="timestamp"&&r!=="_lastUpdate").sort(([r],[n])=>r.localeCompare(n)).map(([r,n])=>[r,or(n,t)]))}function bu(e,t){try{const r=new WeakSet;return Aa(e,t,r),JSON.stringify(or(e,r))===JSON.stringify(or(t,r))}catch{return!1}}function Ma(e,t,r){return bu(e,t)?(e._lastUpdate=r,typeof t.timestamp=="number"&&(e.timestamp=t.timestamp),e):t}function yc(e){var t;return e.daemonId||((t=e.id)==null?void 0:t.split(":")[0])||e.id}function gu(e,t,r){t[r]!==void 0&&(e[r]=t[r])}function Jo(e,t,r,n){var l;const a=(l=t.chats)!=null&&l.length?t.chats:e.chats,o=hc(e.childSessions,t.childSessions,{preserveMissing:n}),c=pc(t.activeChat,e.activeChat);return gc(e,t,{...e,...t,chats:a,childSessions:o,activeChat:c,_lastUpdate:r})}function yu(e,t,r){var a,o;const n={};t.status&&t.status!==e.status&&(n.status=t.status),t.cdpConnected!==void 0&&(n.cdpConnected=t.cdpConnected),t.childSessions!==void 0&&(n.childSessions=hc(e.childSessions,t.childSessions,{preserveMissing:r})),(a=t.chats)!=null&&a.length&&!((o=e.chats)!=null&&o.length)&&(n.chats=t.chats);for(const c of["title","workspace","providerSessionId","parentSessionId","sessionKind","sessionCapabilities","controlValues","providerControls","summaryMetadata","lastMessagePreview","lastMessageRole","lastMessageAt","lastMessageHash","lastUpdated","unread","lastSeenAt","inboxBucket","completionMarker","seenCompletionMarker","surfaceHidden","runtimeKey","runtimeDisplayName","runtimeWorkspaceLabel","runtimeWriteOwner","runtimeAttachedClients","version","serverVersion","versionUpdateReason","versionUpdateRequired","updateCommand","updatePolicy","updateChannel","releaseChannel"])gu(n,t,c);return t.machineNickname!==void 0&&t.machineNickname!==e.machineNickname&&(n.machineNickname=t.machineNickname),t.versionMismatch===!0&&(n.versionMismatch=!0),n}function vu(e,t,r,n){const a=yu(e,t,n),o=Object.keys(a).length>0?gc(e,t,{...e,...a,_lastUpdate:r}):{...e,_lastUpdate:r};return Ma(e,o,r)}function wu(e){const t=new Set(e.map(o=>o.id)),r=new Set,n=new Set,a=new Set;for(const o of e){const c=yc(o);c&&r.add(c),c&&o.type!=="adhdev-daemon"&&n.add(c),c&&o.type==="adhdev-daemon"&&o._sessionListAuthoritative&&a.add(c)}return{incomingIds:t,incomingDaemonIds:r,daemonIdsWithSessionEntries:n,daemonIdsWithAuthoritativeSessionList:a}}function ju(e,t,r,n,a,o){return!a.has(t)||!o.has(t)||n.has(e.id)?!1:e.transport==="pty"||e.transport==="acp"?r>1e4:e.transport==="cdp-page"?r>3e4:!1}function ku(e,t,r,n,a){return e.transport?r.has(t)&&!n.has(t)?!0:a.has(t):!1}function Su(e,t,r){var u,p;const n=Date.now(),a=new Set((r==null?void 0:r.authoritativeDaemonIds)||[]);if(t.length===0)return e.map(x=>({...x,_lastUpdate:n}));const o=new Map;for(const x of t)o.set(x.id,x);const{incomingIds:c,incomingDaemonIds:l,daemonIdsWithSessionEntries:d,daemonIdsWithAuthoritativeSessionList:m}=wu(e);for(const x of e){const k=o.get(x.id);if(!k){o.set(x.id,{...x,_lastUpdate:n});continue}const b=Xo(x),f=Xo(k),g=yc(x),y=!a.has(g);if(b>f){const S=Jo(k,x,n,y);o.set(x.id,Ma(k,S,n));continue}if(b<f){o.set(x.id,vu(k,x,n,y));continue}const h=x.timestamp||n,T=k._lastUpdate||k.timestamp||0;if(h>=T){const S=Jo(k,x,n,y);o.set(x.id,Ma(k,S,n));continue}(u=x.chats)!=null&&u.length&&!((p=k.chats)!=null&&p.length)&&o.set(x.id,{...k,chats:x.chats})}for(const[x,k]of o){const b=k.daemonId||x.split(":")[0];if(!l.has(b))continue;if(a.has(b)&&m.has(b)&&!c.has(x)){o.delete(x);continue}const f=n-(k._lastUpdate||k.timestamp||0);ju(k,b,f,c,a,d)&&o.delete(x)}for(const[x,k]of o){const b=k.daemonId||x.split(":")[0];if(ku(k,b,l,d,o))continue;n-(k._lastUpdate||k.timestamp||0)>3e5&&k.status!=="online"&&o.delete(x)}return Array.from(o.values())}function Nu(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r+=1)if(e[r]!==t[r])return!1;return!0}function Cu({children:e,connectionOverrides:t}){const[r,n]=i.useState([]),[a,o]=i.useState(!1),[c,l]=i.useState([]),[d,m]=i.useState(void 0),u=i.useRef(r);i.useEffect(()=>{u.current=r},[r]);const p=i.useCallback((y,h)=>{n(T=>{let S=!1;const v=T.map(A=>A.id!==y||A.chats===h?A:(S=!0,{...A,chats:h}));return S?v:T})},[]),x=i.useCallback((y,h)=>{n(T=>{const S=T.length===0?y:Su(y,T,h),v=!Nu(T,S);return v&&Rs.record({kind:"dashboard.entries_applied",payload:{incoming:qo(y),next:qo(S)}}),v?S:T})},[]),k=i.useCallback(()=>o(!0),[]),b=i.useMemo(()=>({injectEntries:x,markLoaded:k,getIdes:()=>u.current}),[x,k]),f=t,g=i.useMemo(()=>({ides:r,updateRouteChats:p,initialLoaded:a,toasts:c,setToasts:l,wsStatus:(f==null?void 0:f.wsStatus)??"connected",isConnected:(f==null?void 0:f.isConnected)??!0,connectionStates:(f==null?void 0:f.connectionStates)??{},connectionTransports:(f==null?void 0:f.connectionTransports)??{},showReconnected:(f==null?void 0:f.showReconnected)??!1,retryConnection:f==null?void 0:f.retryConnection,retryServerConnection:f==null?void 0:f.retryServerConnection,connectionLoginUrl:f==null?void 0:f.connectionLoginUrl,isP2PActive:(f==null?void 0:f.isP2PActive)??!1,p2pStates:(f==null?void 0:f.p2pStates)??{},userRole:f==null?void 0:f.userRole,connectionRetryStatuses:f==null?void 0:f.connectionRetryStatuses,userName:d,setUserName:m}),[r,p,a,c,f==null?void 0:f.wsStatus,f==null?void 0:f.isConnected,f==null?void 0:f.connectionStates,f==null?void 0:f.connectionTransports,f==null?void 0:f.showReconnected,f==null?void 0:f.retryConnection,f==null?void 0:f.retryServerConnection,f==null?void 0:f.connectionLoginUrl,f==null?void 0:f.isP2PActive,f==null?void 0:f.p2pStates,f==null?void 0:f.userRole,f==null?void 0:f.connectionRetryStatuses,d]);return s.jsx(bc.Provider,{value:b,children:s.jsx(xc.Provider,{value:g,children:e})})}function es(){return i.useContext(xc)}function pr(){return i.useContext(bc)}function vc(e){const{baseUrl:t,getToken:r,onUnauthorized:n}=e;function a(l){return l.startsWith("http")?l:`${t}${l.startsWith("/")?"":"/"}${l}`}function o(l){const d=r==null?void 0:r(),m=a(l),u=l.startsWith("http")?new URL(m):new URL(m,typeof window<"u"?window.location.origin:"http://localhost");return d&&u.searchParams.set("token",d),!l.startsWith("http")&&!t?`${u.pathname}${u.search}${u.hash}`:u.toString()}async function c(l,d={}){const m={"Content-Type":"application/json",...d.headers||{}},u=r==null?void 0:r();u&&(m.Authorization=`Bearer ${u}`);const p=a(l),x=new AbortController,k=setTimeout(()=>x.abort(),15e3);try{const b=await fetch(p,{...d,headers:m,signal:x.signal});if(b.status===401)throw n==null||n(),new Error("Unauthorized");if(!b.ok){const f=await b.json().catch(()=>({error:b.statusText}));throw new Error(f.error||`API Error: ${b.status}`)}return b.json()}finally{clearTimeout(k)}}return{getDaemons:()=>c("/api/v1/daemons"),getDaemonStatus:l=>c(`/api/v1/daemons/${l}/status`),sendCommand:(l,d,m={})=>c(`/api/v1/daemons/${l}/command`,{method:"POST",body:JSON.stringify({type:d,payload:m})}),execTerminal:(l,d,m)=>c(`/api/v1/daemons/${l}/terminal`,{method:"POST",body:JSON.stringify({command:d,name:m})}),sendAgentMessage:(l,d,m)=>c(`/api/v1/shortcuts/${l}/chat`,{method:"POST",body:JSON.stringify({agentType:d,message:m})}),getAgentStatus:l=>c(`/api/v1/shortcuts/${l}/status`),approveAgent:(l,d,m)=>c(`/api/v1/shortcuts/${l}/approve`,{method:"POST",body:JSON.stringify({agentType:d,action:m?"approve":"reject"})}),getMuxState:l=>c(`/api/v1/mux/${encodeURIComponent(l)}/state`),getMuxSocketInfo:l=>c(`/api/v1/mux/${encodeURIComponent(l)}/socket-info`),controlMux:(l,d,m={})=>c(`/api/v1/mux/${encodeURIComponent(l)}/control`,{method:"POST",body:JSON.stringify({type:d,payload:m})}),getMuxEventsUrl:l=>o(`/api/v1/mux/${encodeURIComponent(l)}/events`),getRuntimeEventsUrl:l=>o(`/api/v1/runtime/${encodeURIComponent(l)}/events`),request:c}}const Tu=vc({baseUrl:"http://localhost:3847"}),Iu=i.createContext(Tu);function Au({client:e,children:t}){return s.jsx(Iu.Provider,{value:e,children:t})}const Mu={sendCommand:async()=>{throw new Error("TransportContext not initialized")}},wc=i.createContext(Mu);function Ru({value:e,children:t}){return s.jsx(wc.Provider,{value:e,children:t})}function gt(){return i.useContext(wc)}function Lu(e){let t=2166136261;for(const r of e){const n=String(r||"");for(let a=0;a<n.length;a+=1)t^=n.charCodeAt(a),t=Math.imul(t,16777619)>>>0;t^=255,t=Math.imul(t,16777619)>>>0}return t.toString(16).padStart(8,"0")}function Pu(e){try{return JSON.stringify(e??"")}catch{return String(e??"")}}function _u(e){return e?Lu([String(e.id||""),String(e.index??""),String(e.role||""),String(e.receivedAt??e.timestamp??""),Pu(e.content)]):""}const We={size:18};function jc({size:e=We.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),s.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),s.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),s.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1"})]})}function Za({size:e=We.size,className:t}){return s.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:s.jsx("polyline",{points:"15 18 9 12 15 6"})})}function Jt({size:e=We.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("rect",{x:"2",y:"2",width:"20",height:"8",rx:"2"}),s.jsx("rect",{x:"2",y:"14",width:"20",height:"8",rx:"2"}),s.jsx("circle",{cx:"6",cy:"6",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"6",cy:"18",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("line",{x1:"10",y1:"6",x2:"18",y2:"6"}),s.jsx("line",{x1:"10",y1:"18",x2:"18",y2:"18"})]})}function kc({size:e=We.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),s.jsx("circle",{cx:"9",cy:"7",r:"4"}),s.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),s.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}function Du({size:e=We.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),s.jsx("circle",{cx:"12",cy:"7",r:"4"})]})}function Eu({size:e=We.size,className:t}){return s.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:s.jsx("path",{d:"M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4"})})}function Sc({size:e=We.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("path",{d:"M4 19.5A2.5 2.5 0 0 1 6.5 17H20"}),s.jsx("path",{d:"M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z"}),s.jsx("line",{x1:"9",y1:"7",x2:"16",y2:"7"}),s.jsx("line",{x1:"9",y1:"11",x2:"14",y2:"11"})]})}function $u({size:e=We.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"}),s.jsx("rect",{x:"8",y:"2",width:"8",height:"4",rx:"1"}),s.jsx("line",{x1:"8",y1:"10",x2:"16",y2:"10"}),s.jsx("line",{x1:"8",y1:"14",x2:"14",y2:"14"}),s.jsx("line",{x1:"8",y1:"18",x2:"12",y2:"18"})]})}function vn({size:e=We.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}function Nc({size:e=We.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),s.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]})}function Bu({size:e=We.size,className:t}){return s.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:s.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"})})}function zt({size:e=We.size,className:t}){return s.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:s.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function It({size:e=We.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),s.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"}),s.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"})]})}function eo({size:e=We.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),s.jsx("polyline",{points:"14 2 14 8 20 8"}),s.jsx("line",{x1:"8",y1:"13",x2:"16",y2:"13"}),s.jsx("line",{x1:"8",y1:"17",x2:"13",y2:"17"})]})}function Ku({size:e=We.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function hs({size:e=We.size,className:t}){return s.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:s.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}function gr({size:e=We.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("polyline",{points:"23 4 23 10 17 10"}),s.jsx("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})}function hr({size:e=We.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),s.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),s.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]})}function Ps({size:e=We.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("path",{d:"M12 22v-5"}),s.jsx("path",{d:"M9 8V2"}),s.jsx("path",{d:"M15 8V2"}),s.jsx("path",{d:"M18 8v5a6 6 0 0 1-12 0V8z"})]})}function Ar({size:e=We.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("circle",{cx:"12",cy:"5",r:"2"}),s.jsx("circle",{cx:"5",cy:"19",r:"2"}),s.jsx("circle",{cx:"19",cy:"19",r:"2"}),s.jsx("line",{x1:"12",y1:"7",x2:"5",y2:"17"}),s.jsx("line",{x1:"12",y1:"7",x2:"19",y2:"17"}),s.jsx("line",{x1:"5",y1:"19",x2:"19",y2:"19"})]})}function Ou({size:e=We.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("polygon",{points:"12 2 2 7 12 12 22 7 12 2"}),s.jsx("polyline",{points:"2 12 12 17 22 12"}),s.jsx("polyline",{points:"2 17 12 22 22 17"})]})}function Cc({size:e=We.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),s.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}function to({size:e=We.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("path",{d:"M17.94 17.94A10.94 10.94 0 0 1 12 20C5 20 1 12 1 12a21.8 21.8 0 0 1 5.06-5.94"}),s.jsx("path",{d:"M9.9 4.24A10.93 10.93 0 0 1 12 4c7 0 11 8 11 8a21.77 21.77 0 0 1-2.16 3.19"}),s.jsx("path",{d:"M14.12 14.12a3 3 0 1 1-4.24-4.24"}),s.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}function Tc({size:e=We.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]})}function Wu({size:e=We.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("line",{x1:"18",y1:"20",x2:"18",y2:"10"}),s.jsx("line",{x1:"12",y1:"20",x2:"12",y2:"4"}),s.jsx("line",{x1:"6",y1:"20",x2:"6",y2:"14"})]})}function so({size:e=We.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("polyline",{points:"4 17 10 11 4 5"}),s.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}function Fu({size:e=We.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),s.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"})]})}function ro({size:e=We.size,className:t}){return s.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:s.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})})}function Ic({size:e=We.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),s.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function yt({size:e=We.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function Hu({size:e=We.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z"}),s.jsx("path",{d:"M12 15l-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z"}),s.jsx("path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0"}),s.jsx("path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5"})]})}function Uu({size:e=We.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("rect",{x:"3",y:"8",width:"18",height:"12",rx:"2"}),s.jsx("path",{d:"M12 2v6"}),s.jsx("circle",{cx:"8.5",cy:"14",r:"1.5",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"15.5",cy:"14",r:"1.5",fill:"currentColor",stroke:"none"})]})}function zu({size:e=We.size,className:t}){return s.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:s.jsx("path",{d:"M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z"})})}function Vu({size:e=We.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("rect",{x:"9",y:"10",width:"6",height:"12",rx:"1"}),s.jsx("path",{d:"M12 2c-1.5 2-3 3.5-3 5a3 3 0 0 0 6 0c0-1.5-1.5-3-3-5z"})]})}function wn({size:e=We.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),s.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]})}function Gu({size:e=We.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("circle",{cx:"12",cy:"12",r:"5"}),s.jsx("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),s.jsx("line",{x1:"12",y1:"21",x2:"12",y2:"23"}),s.jsx("line",{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"}),s.jsx("line",{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"}),s.jsx("line",{x1:"1",y1:"12",x2:"3",y2:"12"}),s.jsx("line",{x1:"21",y1:"12",x2:"23",y2:"12"}),s.jsx("line",{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"}),s.jsx("line",{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"})]})}function qu({size:e=We.size,className:t}){return s.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:s.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})})}function Yu({size:e=We.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",ry:"2"}),s.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"}),s.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"})]})}function Xu({size:e=We.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),s.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]})}function Ju({size:e=We.size,className:t}){return s.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:s.jsx("polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2"})})}function Qu({size:e=We.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),s.jsx("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07"})]})}function Zu({size:e=We.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("path",{d:"M14.5 10c-.83 0-1.5-.89-1.5-2s.67-2 1.5-2 1.5.89 1.5 2-.67 2-1.5 2z"}),s.jsx("path",{d:"M9.5 10c-.83 0-1.5-.89-1.5-2s.67-2 1.5-2 1.5.89 1.5 2-.67 2-1.5 2z"}),s.jsx("path",{d:"M19.35 6.07A16.03 16.03 0 0 0 15 4a.84.84 0 0 0-.46.33 11 11 0 0 0-.74 1.5 15.68 15.68 0 0 0-3.6 0 11.23 11.23 0 0 0-.74-1.5A.84.84 0 0 0 9 4a16.03 16.03 0 0 0-4.35 2.07A16.8 16.8 0 0 0 2 15a16.22 16.22 0 0 0 4 3c.12.08.27.06.37-.04a11.14 11.14 0 0 0 1.2-1.92.35.35 0 0 0-.18-.46 10.4 10.4 0 0 1-1.63-.78.36.36 0 0 1 .03-.6 6.8 6.8 0 0 0 .32-.24.36.36 0 0 1 .37-.04c2.2.98 4.6.98 6.8 0a.36.36 0 0 1 .37.04c.1.08.21.16.32.24a.36.36 0 0 1 .03.6 10.4 10.4 0 0 1-1.63.78.35.35 0 0 0-.18.46c.39.67.8 1.3 1.2 1.92a.37.37 0 0 0 .37.04 16.22 16.22 0 0 0 4-3 16.8 16.8 0 0 0-2.65-8.93z"})]})}function em({size:e=We.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("rect",{x:"2",y:"7",width:"15",height:"14",rx:"2"}),s.jsx("path",{d:"M13 2h9v9"}),s.jsx("path",{d:"M22 2L13 11"})]})}function tm({size:e=We.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("polyline",{points:"9 14 4 9 9 4"}),s.jsx("path",{d:"M20 20v-7a4 4 0 0 0-4-4H4"})]})}function sm({size:e=We.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),s.jsx("line",{x1:"6",y1:"8",x2:"6.01",y2:"8"}),s.jsx("line",{x1:"10",y1:"8",x2:"10.01",y2:"8"}),s.jsx("line",{x1:"14",y1:"8",x2:"14.01",y2:"8"}),s.jsx("line",{x1:"18",y1:"8",x2:"18.01",y2:"8"}),s.jsx("line",{x1:"6",y1:"12",x2:"6.01",y2:"12"}),s.jsx("line",{x1:"10",y1:"12",x2:"10.01",y2:"12"}),s.jsx("line",{x1:"14",y1:"12",x2:"14.01",y2:"12"}),s.jsx("line",{x1:"18",y1:"12",x2:"18.01",y2:"12"}),s.jsx("line",{x1:"7",y1:"16",x2:"17",y2:"16"})]})}function rm({size:e=We.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("rect",{x:"2",y:"6",width:"13",height:"13",rx:"2"}),s.jsx("path",{d:"M9 6V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2"})]})}function nm({size:e=We.size,className:t}){return s.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),s.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"21"}),s.jsx("line",{x1:"3",y1:"12",x2:"12",y2:"12"})]})}const no="adhdev_chat_activity_visible",Qo=new Set(["hidden","debug","internal"]),Zo=new Set(["visible","user","chat"]),am=new Set(["debug","trace","internal"]),om=new Set(["tool_call","terminal_command","runtime_activity"]),im=new Set(["runtime_status","provider_chrome","control"]),cm=new Set(["thought","tool","terminal"]);function Ac(e){const t=e.meta;return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function js(e){return typeof e=="string"?e.trim().toLowerCase():""}function $n(e,t,r){return e[r]??(t==null?void 0:t[r])}function ei(e,t,r){const n=e;return r.some(a=>n[a]===!0||(t==null?void 0:t[a])===!0)}function lm(e,t){const r=js(e.kind);return r||(t==="tool"?"tool":"standard")}function Bn(e,t,r){const n=Ac(e),a=typeof(n==null?void 0:n.label)=="string"?n.label.trim():"";return a||(t==="terminal"||r==="terminal_command"?"Terminal":t==="tool"||r==="tool_call"?"Tool":t==="thought"?"Thought":r==="runtime_activity"?"Runtime":"Activity")}function dm(e){const t=e.content;return Array.isArray(t)&&t.some(r=>!!r&&typeof r=="object"&&r.type!=="text")}function ao(e){if(!e)return{surface:"internal",isUserFacing:!1,isActivityFacing:!1,isInternal:!0,role:"",kind:"standard",label:"Internal"};const t=Ac(e),r=js(e.role),n=lm(e,r),a=js($n(e,t,"visibility")),o=js(e.transcriptVisibility??(t==null?void 0:t.transcriptVisibility)??a),c=js($n(e,t,"audience")),l=js($n(e,t,"source")),d=Qo.has(a)||Qo.has(o)||am.has(c)||ei(e,t,["internal","isInternal","debug","statusOnly","controlOnly"]),m=Zo.has(a)||Zo.has(o)||c==="chat"||ei(e,t,["userFacing"]),u=cm.has(n)||om.has(l);if(d)return{surface:u?"activity":"internal",isUserFacing:!1,isActivityFacing:u,isInternal:!u,role:r,kind:n,label:Bn(e,n,l)};if(m)return{surface:"chat",isUserFacing:!0,isActivityFacing:!1,isInternal:!1,role:r,kind:n,label:Bn(e,n,l)};if((r==="system"||n==="system")&&dm(e))return{surface:"chat",isUserFacing:!0,isActivityFacing:!1,isInternal:!1,role:r,kind:n,label:"Chat"};if(im.has(l)||r==="system"||n==="system")return{surface:"internal",isUserFacing:!1,isActivityFacing:!1,isInternal:!0,role:r,kind:n,label:"Internal"};if(u)return{surface:"activity",isUserFacing:!1,isActivityFacing:!0,isInternal:!1,role:r,kind:n,label:Bn(e,n,l)};const p=(r==="user"||r==="human"||r==="assistant")&&(n==="standard"||n==="");return{surface:p?"chat":"internal",isUserFacing:p,isActivityFacing:!1,isInternal:!p,role:r,kind:n,label:p?"Chat":"Internal"}}function um(e){return(Array.isArray(e)?e:[]).filter(t=>ao(t).isUserFacing)}function Mc(e){return(Array.isArray(e)?e:[]).filter(t=>ao(t).isActivityFacing)}function mm(e,t,r){return!r||t.length===0?e:[...e,...t].sort((n,a)=>{const o=Number(n.receivedAt??n.timestamp??0)||0,c=Number(a.receivedAt??a.timestamp??0)||0;if(o!==c)return o-c;const l=Number(n.index??0)||0,d=Number(a.index??0)||0;return l-d})}function ti(e=typeof localStorage<"u"?localStorage:void 0){try{return(e==null?void 0:e.getItem(no))==="1"}catch{return!1}}function fm(e,t=typeof localStorage<"u"?localStorage:void 0){try{t==null||t.setItem(no,e?"1":"0")}catch{}}const Rc=[su,{singleTilde:!1}],Lc=[Rc,ru,nu],pm=[Rc],oo=200,hm=80,si=650,Us=new Map;function nn(e,t){if(!e)return!1;const r=String(e.messageFingerprint||"");return r?r===String(t||""):!0}function xm(e,t){if(!Array.isArray(e)||e.length===0)return"0:empty";const r=String(t||"").trim();if(r)return`${e.length}:${r}`;const n=e[e.length-1];return`${e.length}:${_u(n)}`}function bm(e,t,r,n){return e||!t?!1:nn(r,n)}function gm({scrollTop:e,scrollHeight:t,clientHeight:r,topThresholdPx:n=hm,bottomThresholdPx:a=oo}){const o=Math.max(0,Number(e)||0),c=Math.max(0,Number(t)||0),l=Math.max(0,Number(r)||0);return Math.max(0,c-l)<=0?{showTop:!1,showBottom:!1}:{showTop:o>n,showBottom:Math.max(0,c-o-l)>a}}function ym(e){return gm({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight})}function nr(e,t=oo){return!!e&&e.fromBottom>=t}function vm(e,t){return nn(e,t)?!nr(e):!0}function wm({hasSelection:e,userScrolledUp:t,hasChatContentChanged:r=!0}){return!(e||t||!r)}function jm({hasSelection:e,userScrolledUp:t,contextAutoScrollActive:r}){return e?!1:r||!t}function Kn(e,t){const r=Math.max(0,e.scrollHeight-e.clientHeight-t.fromBottom);e.scrollTop=Number.isFinite(r)?r:t.top}function Pc(e){return e?new Date(e).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0}):""}function km(e,t,r){return Number(e.receivedAt||r[an(e,t)]||0)||0}function _c(e){return/[`*_#[\]()>-]|https?:\/\/|\n\s*[-*]\s|\n\s*\d+\.\s|\|/.test(e)}function Sm(e){return Array.isArray(e)&&e.some(t=>!!t&&typeof t=="object"&&"type"in t)}function zs(e,t){if(!e)return t;try{return(e.startsWith("file://")?new URL(e).pathname:e).split(/[\\/]/).filter(Boolean).pop()||t}catch{return e.split(/[\\/]/).filter(Boolean).pop()||t}}function On(e){if(typeof e.uri=="string"&&e.uri)return e.uri;if(typeof e.data=="string"&&e.data&&typeof e.mimeType=="string"&&e.mimeType)return`data:${e.mimeType};base64,${e.data}`}function Mr(e,t,r){return s.jsxs("div",{className:"rounded-md border border-border-subtle p-2 text-sm",role:"note",children:[s.jsx("span",{className:"font-medium",children:e}),t?s.jsx("span",{className:"ml-1 break-all",children:t}):null,r?s.jsx("div",{className:"mt-1 opacity-80",style:{whiteSpace:"pre-wrap"},children:r}):null]})}function ri(e,t){return e?t?s.jsx("pre",{className:"chat-preformatted",children:e}):_c(e)?s.jsx(Xa,{remarkPlugins:Lc,children:e}):s.jsx("div",{style:{whiteSpace:"pre-wrap"},children:e}):null}function Vs({parts:e,renderAsPreformatted:t}){return s.jsx("div",{className:"flex flex-col gap-2",children:e.map((r,n)=>{if(r.type==="text")return s.jsx("div",{children:ri(String(r.text||""),t)},`text-${n}`);if(r.type==="image"){const a=On(r),o=r.alt||r.description||zs(r.uri,"image");return a?s.jsx("img",{src:a,alt:o,className:"max-w-full rounded-md border border-border-subtle"},`image-${n}`):s.jsx("div",{children:Mr("Image",o,r.mimeType)},`image-fallback-${n}`)}if(r.type==="audio"){const a=On(r);return a?s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("audio",{controls:!0,src:a,className:"max-w-full"}),r.transcript?s.jsx("div",{className:"text-sm opacity-80",style:{whiteSpace:"pre-wrap"},children:r.transcript}):null]},`audio-${n}`):s.jsx("div",{children:Mr("Audio",zs(r.uri,"audio"),r.transcript||r.mimeType)},`audio-fallback-${n}`)}if(r.type==="video"){const a=On(r),o=r.title||r.name||r.alt||zs(r.uri,"video"),c=[r.transcript,r.description,r.mimeType].filter(Boolean).join(`
3
3
  `);return s.jsxs("div",{className:"flex flex-col gap-1",children:[a?s.jsx("video",{controls:!0,src:a,poster:r.posterUri,className:"max-w-full rounded-md border border-border-subtle"}):Mr("Video",o,c),a&&c?s.jsx("div",{className:"text-sm opacity-80",style:{whiteSpace:"pre-wrap"},children:c}):null]},`video-${n}`)}if(r.type==="resource_link"){const a=r.title||r.name||zs(r.uri,"resource"),o=[r.description,r.mimeType].filter(Boolean).join(`
4
4
  `);return s.jsxs("div",{className:"flex flex-col gap-1",children:[r.uri?s.jsx("a",{href:r.uri,target:"_blank",rel:"noreferrer",download:!0,className:"underline break-all",children:a}):Mr("Resource",a,o),r.uri&&o?s.jsx("div",{className:"text-sm opacity-80",style:{whiteSpace:"pre-wrap"},children:o}):null]},`resource-link-${n}`)}if(r.type==="resource"&&r.resource){const a=zs(r.resource.uri,"resource");if(r.resource.text)return s.jsxs("div",{className:"rounded-md border border-border-subtle p-2",children:[s.jsx("div",{className:"text-[11px] opacity-70 mb-1",children:a}),ri(r.resource.text,!0)]},`resource-${n}`);if(r.resource.uri)return s.jsx("a",{href:r.resource.uri,target:"_blank",rel:"noreferrer",className:"underline break-all",children:a},`resource-uri-${n}`)}return null})})}function an(e,t){const r=e,n=Qa(e.content,{joiner:`
5
5
  `});return[e.id?`id:${e.id}`:"",r._localId?`local:${r._localId}`:"",r._turnKey?`turn:${r._turnKey}`:"",typeof e.index=="number"?`msgIndex:${e.index}`:"",e.role?`role:${e.role}`:"",n?`content:${n.slice(0,80)}`:"",`fallback:${t}`].filter(Boolean).join("|")}const Nm=i.memo(function({log:t}){return s.jsxs("div",{className:"self-center chat-msg-action",children:[s.jsx(Xa,{remarkPlugins:pm,children:t.text}),s.jsx("span",{className:"action-time",children:Pc(t.timestamp)})]})},(e,t)=>e.log===t.log),Cm=i.memo(function({message:t,receivedAt:r,agentName:n,userName:a,isCliMode:o,isTextExpanded:c,onToggleTextExpanded:l}){var w,j,B;const d=(t.role||"").toLowerCase(),m=d==="user"||d==="human",u=t.kind||(d==="tool"?"tool":"standard"),p=ao(t),x=Sm(t.content)?t.content:null,k=!!(x!=null&&x.some(P=>P.type!=="text")),b=Qa(t.content,{joiner:`
6
- `});if(p.isActivityFacing&&u!=="thought"&&u!=="tool"&&u!=="terminal"){const P=p.label||"Activity";return s.jsxs("div",{className:"self-start chat-msg-activity","data-chat-activity-row":"true",children:[s.jsxs("div",{className:"chat-msg-activity-meta","aria-label":"Activity message",children:[s.jsx("span",{className:"activity-dot"}),s.jsx("span",{children:P})]}),k&&x?s.jsx("div",{className:"chat-msg-activity-body",children:s.jsx(Vs,{parts:x,renderAsPreformatted:!1})}):s.jsx("div",{className:"chat-msg-activity-body",style:{whiteSpace:"pre-wrap"},children:b})]})}if(u==="thought"){const P=typeof((w=t.meta)==null?void 0:w.label)=="string"?t.meta.label:"Thought";return s.jsxs("div",{className:"self-start chat-msg-thought","data-chat-activity-row":p.isActivityFacing?"true":void 0,children:[s.jsxs("div",{className:"chat-msg-header",children:[s.jsx(zu,{size:13}),s.jsx("span",{children:P})]}),s.jsx("div",{className:"chat-msg-body",children:b})]})}if(u==="tool")return s.jsxs("div",{className:"self-start chat-msg-tool","data-chat-activity-row":p.isActivityFacing?"true":void 0,children:[s.jsxs("div",{className:"chat-msg-tool-meta","aria-label":"Tool message",children:[s.jsx("span",{className:"tool-icon",children:"⏺"}),s.jsx("span",{className:"tool-label",children:"Tool"})]}),k&&x?s.jsx("div",{className:"tool-text w-full",children:s.jsx(Vs,{parts:x,renderAsPreformatted:!1})}):s.jsx("div",{className:"tool-text w-full",style:{whiteSpace:"pre-wrap"},children:b})]});if(u==="terminal"){const P=(j=t.meta)!=null&&j.isRunning?"⏳":"✅",I=typeof((B=t.meta)==null?void 0:B.label)=="string"?t.meta.label:"Ran command";return s.jsxs("div",{className:"self-start chat-msg-terminal","data-chat-activity-row":p.isActivityFacing?"true":void 0,children:[s.jsxs("div",{className:"chat-msg-header",children:[s.jsx("span",{children:P}),s.jsx("span",{children:I})]}),k&&x?s.jsx("div",{className:"chat-msg-body",children:s.jsx(Vs,{parts:x,renderAsPreformatted:!0})}):s.jsx("pre",{className:"chat-msg-body",children:b})]})}if(u==="system")return s.jsx("div",{className:"self-center chat-msg-system",children:k&&x?s.jsx(Vs,{parts:x,renderAsPreformatted:!1}):b.slice(0,100)});const f=t.meta,y=(typeof(f==null?void 0:f.renderMode)=="string"?f.renderMode.trim():"")==="preformatted",h=b,T=!1,S=h,v=y,A=!v&&_c(S),M=["chat-message-row",m?"chat-message-row-user self-end":"chat-message-row-assistant self-start"].join(" ");return s.jsx("div",{className:M,children:(h||k||m)&&s.jsxs("div",{className:`chat-bubble ${m?"chat-bubble-user":"chat-bubble-assistant"}`,children:[s.jsxs("div",{className:`chat-bubble-header ${h||k?"mb-1.5":"mb-0"}`,children:[s.jsx("span",{className:"chat-sender",children:m?a||"You":t.senderName||n}),r!=null&&s.jsx("span",{className:"chat-time",children:Pc(r)})]}),(h||k)&&s.jsx("div",{className:"chat-markdown",children:k&&x?s.jsx(Vs,{parts:x,renderAsPreformatted:v}):v?s.jsx("pre",{className:"chat-preformatted",children:S}):A?s.jsx(Xa,{remarkPlugins:Lc,children:S}):s.jsx("div",{style:{whiteSpace:"pre-wrap"},children:S})}),T]})})},(e,t)=>e.message===t.message&&e.receivedAt===t.receivedAt&&e.agentName===t.agentName&&e.userName===t.userName&&e.isCliMode===t.isCliMode&&e.isTextExpanded===t.isTextExpanded),Tm=i.forwardRef(function({messages:t,actionLogs:r,agentName:n="Agent",userName:a,isCliMode:o=!1,isWorking:c=!1,contextKey:l="",receivedAtMap:d={},lastMessageHash:m,showActivityMessages:u=!1,emptyState:p,onLoadMore:x,isLoadingMore:k,hasMoreHistory:b,hiddenLiveCount:f=0,loadError:g,scrollToBottomRequestNonce:y,isVisible:h=!0},T){const S=i.useRef(null),v=i.useRef(null),A=i.useRef(null),M=i.useRef(0),w=i.useRef(""),j=i.useRef(""),B=i.useRef(!1),P=i.useRef(null),I=i.useRef(!1),O=i.useRef(null),F=i.useRef(!1),[L,C]=i.useState(new Set),[N,K]=i.useState({showTop:!1,showBottom:!1}),_=i.useRef(!1),D=i.useRef(!1),H=i.useRef(h),J=i.useRef(h),be=i.useRef(null);J.current=h;const ce=()=>{const oe=S.current;return oe?oe.scrollHeight-oe.scrollTop-oe.clientHeight<oo:!0},Q=i.useCallback(()=>{const oe=S.current,q=oe?ym(oe):{showTop:!1,showBottom:!1};K(Se=>Se.showTop===q.showTop&&Se.showBottom===q.showBottom?Se:q)},[]),U=i.useCallback((oe="auto")=>{var Se;const q=S.current;q&&(q.scrollTo({top:q.scrollHeight,behavior:oe}),(Se=q.ownerDocument.defaultView)==null||Se.requestAnimationFrame(()=>Q()))},[Q]),le=i.useCallback((oe="auto")=>{var Se;const q=S.current;q&&(q.scrollTo({top:0,behavior:oe}),(Se=q.ownerDocument.defaultView)==null||Se.requestAnimationFrame(()=>Q()))},[Q]),pe=i.useCallback(()=>{var Le;const oe=S.current,q=(Le=window.getSelection)==null?void 0:Le.call(window);if(!oe||!q||q.rangeCount===0||q.isCollapsed){F.current=!1;return}const Se=q.anchorNode,Ie=q.focusNode;F.current=!!(Se&&Ie&&oe.contains(Se)&&oe.contains(Ie))},[]),Y=i.useMemo(()=>{const oe=um(t),q=Mc(t);return mm(oe,q,u)},[t,u]),de=Y.length===t.length?m:void 0,ge=xm(Y,de),se=i.useCallback(()=>{const oe=S.current;if(!oe||!l||!J.current)return;const q={top:oe.scrollTop,fromBottom:Math.max(0,oe.scrollHeight-oe.scrollTop-oe.clientHeight),messageFingerprint:ge};be.current={contextKey:l,snapshot:q},Us.set(l,q)},[l,ge]),ue=i.useCallback((oe="auto")=>{P.current!=null&&cancelAnimationFrame(P.current),P.current=requestAnimationFrame(()=>{P.current=null,U(oe)})},[U]),ke=i.useCallback(()=>{_.current=!1,I.current=!0,D.current=!0,O.current!=null&&window.clearTimeout(O.current),O.current=window.setTimeout(()=>{I.current=!1,O.current=null},si)},[]);i.useEffect(()=>{const oe=!B.current,q=j.current!==l;if(j.current=l,oe||q){B.current=!0;const Ie=l?Us.get(l):null,Le=!!Ie&&nn(Ie,ge);_.current=Le?nr(Ie):!1,I.current=vm(Ie,ge),F.current||(Le?requestAnimationFrame(()=>{const Me=S.current;Me&&(Kn(Me,Ie),_.current=nr(Ie),Q(),D.current=!0)}):ue("auto")),M.current=Y.length,w.current=ge;return}Y.length>M.current;const Se=ge!==w.current;wm({hasSelection:F.current,userScrolledUp:_.current,hasChatContentChanged:Se})&&ue("auto"),M.current=Y.length,w.current=ge},[ge,l,Y.length,ue,Q]),i.useEffect(()=>{y&&(ke(),F.current||ue("auto"))},[ke,ue,y]),i.useEffect(()=>{const oe=H.current;oe&&!h&&se(),J.current=h,H.current=h;const q=l?Us.get(l):null;if(bm(oe,h,q,ge)){if(!q)return;_.current=nr(q),I.current=!1,F.current||requestAnimationFrame(()=>{const Se=S.current;Se&&(Kn(Se,q),Q())});return}},[h,l,ge,ke,se,ue,Q]),i.useEffect(()=>()=>{const oe=be.current;oe&&Us.set(oe.contextKey,oe.snapshot),P.current!=null&&cancelAnimationFrame(P.current),O.current!=null&&window.clearTimeout(O.current)},[]),i.useEffect(()=>{const oe=v.current,q=S.current;if(!oe||!q)return;const Se=()=>{O.current!=null&&window.clearTimeout(O.current),O.current=window.setTimeout(()=>{I.current=!1,O.current=null},si)},Ie=new ResizeObserver(()=>{Q();const Le=I.current;jm({hasSelection:F.current,userScrolledUp:_.current,contextAutoScrollActive:Le})&&(ue("auto"),Le&&Se())});return Ie.observe(oe),q!==oe&&Ie.observe(q),()=>{Ie.disconnect(),O.current!=null&&(window.clearTimeout(O.current),O.current=null)}},[ue,l,Q]),i.useImperativeHandle(T,()=>({scrollToBottom:(oe="smooth")=>{U(oe)}}),[U]),i.useEffect(()=>{const oe=S.current;if(!oe)return;let q;const Se=()=>{se(),clearTimeout(q),q=setTimeout(()=>{_.current=!ce(),Q()},50)};return oe.addEventListener("scroll",Se,{passive:!0}),()=>{oe.removeEventListener("scroll",Se),clearTimeout(q)}},[se,Q]),i.useEffect(()=>(document.addEventListener("selectionchange",pe),()=>document.removeEventListener("selectionchange",pe)),[pe]);const fe=i.useRef(0),ye=i.useRef(!1);i.useEffect(()=>{const oe=S.current;if(!oe||!ye.current||fe.current===0)return;const q=oe.scrollHeight-fe.current;q>0&&(oe.scrollTop=q),Q(),se(),fe.current=0,ye.current=!1},[Y.length,se,Q]),i.useEffect(()=>{if(D.current||!l)return;const oe=Us.get(l),q=S.current;if(!(!oe||!q)){if(!nn(oe,ge)){U("auto"),D.current=!0;return}Kn(q,oe),_.current=nr(oe),Q(),D.current=!0}},[l,ge,Y.length,U,Q]);const ae=()=>{const oe=S.current;oe&&(fe.current=oe.scrollHeight),ye.current=!0,x==null||x()},he=()=>{_.current=!0,le("smooth"),se()},ie=()=>{ke(),U("smooth"),se()},me=i.useMemo(()=>{const oe=Y.map((Le,Me)=>({type:"message",data:Le,index:Me,ts:km(Le,Me,d)}));if(!r||r.length===0)return oe;const q=[...r].sort((Le,Me)=>Le.timestamp-Me.timestamp).map((Le,Me)=>({type:"action",data:Le,index:Me,ts:Le.timestamp})),Se=[];let Ie=0;for(const Le of oe){for(;Ie<q.length&&Le.ts>0&&q[Ie].ts<Le.ts;)Se.push(q[Ie++]);Se.push(Le)}for(;Ie<q.length;)Se.push(q[Ie++]);return Se},[Y,r,d]),Z=f>0||!!b,ve=f>0?`↑ Show ${Math.min(f,80)} earlier messages${f>80?` (${f} hidden)`:""}`:g?`↻ ${g}`:"↑ Load older messages";return s.jsxs("div",{className:"chat-scroll-frame",children:[s.jsx("div",{ref:S,"data-chat-scroll":!0,className:"chat-container",children:s.jsxs("div",{ref:v,className:"chat-container-content",children:[k&&s.jsx("div",{className:"text-center py-3 text-text-muted text-xs opacity-60 animate-pulse",children:"Loading older messages..."}),Z&&!k&&s.jsx("div",{className:"text-center py-2",children:s.jsx("button",{type:"button",onClick:ae,className:`text-[11px] rounded-xl px-4 py-1.5 cursor-pointer border transition-all ${g&&f===0?"bg-transparent border-yellow-500/30 text-yellow-400 opacity-80 hover:opacity-100":"bg-transparent border-border-subtle text-text-muted opacity-70 hover:opacity-100 hover:border-accent/40"}`,children:ve})}),me.length===0&&!Z&&(p||s.jsx("div",{className:"text-center mt-16 opacity-20 text-[13px]",children:"Waiting for messages..."})),me.map(oe=>{if(oe.type==="action"){const Ce=oe.data;return s.jsx(Nm,{log:Ce},`action-${oe.index}`)}const q=oe.data,Se=oe.index,Ie=an(q,Se),Le=q.receivedAt||d[Ie],Me=`${l}-${Ie}`,$=L.has(Me);return s.jsx(Cm,{message:q,receivedAt:Le,agentName:n,userName:a,isCliMode:o,isTextExpanded:$,onToggleTextExpanded:()=>C(Ce=>{const Pe=new Set(Ce);return $?Pe.delete(Me):Pe.add(Me),Pe})},`msg-${Ie}`)}),c&&s.jsx("div",{className:"self-start chat-typing-wrapper",children:s.jsxs("div",{className:"typing-indicator",children:[s.jsx("div",{className:"dot"}),s.jsx("div",{className:"dot"}),s.jsx("div",{className:"dot"}),s.jsx("span",{className:"text-[11px] text-text-muted ml-1",children:"Agent generating..."})]})}),s.jsx("div",{className:"min-h-10",ref:A})]})}),(N.showTop||N.showBottom)&&s.jsxs("div",{className:"chat-scroll-jump-controls","aria-label":"Chat scroll shortcuts",children:[N.showTop&&s.jsx("button",{type:"button",className:"chat-scroll-jump-button",onClick:he,"aria-label":"Jump to oldest messages",title:"Jump to top",children:"↑ Top"}),N.showBottom&&s.jsx("button",{type:"button",className:"chat-scroll-jump-button chat-scroll-jump-button-primary",onClick:ie,"aria-label":"Jump to latest messages",title:"Jump to bottom",children:"↓ Latest"})]})]})}),Im=i.memo(Tm,(e,t)=>e.messages===t.messages&&e.actionLogs===t.actionLogs&&e.agentName===t.agentName&&e.userName===t.userName&&e.isCliMode===t.isCliMode&&e.isWorking===t.isWorking&&e.contextKey===t.contextKey&&e.receivedAtMap===t.receivedAtMap&&e.lastMessageHash===t.lastMessageHash&&e.showActivityMessages===t.showActivityMessages&&e.emptyState===t.emptyState&&e.onLoadMore===t.onLoadMore&&e.isLoadingMore===t.isLoadingMore&&e.hasMoreHistory===t.hasMoreHistory&&e.hiddenLiveCount===t.hiddenLiveCount&&e.loadError===t.loadError&&e.scrollToBottomRequestNonce===t.scrollToBottomRequestNonce&&e.isVisible===t.isVisible),Am="modulepreload",Mm=function(e){return"/"+e},ni={},Rm=function(t,r,n){let a=Promise.resolve();if(r&&r.length>0){document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),l=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));a=Promise.allSettled(r.map(d=>{if(d=Mm(d),d in ni)return;ni[d]=!0;const m=d.endsWith(".css"),u=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${u}`))return;const p=document.createElement("link");if(p.rel=m?"stylesheet":Am,m||(p.as="script"),p.crossOrigin="",p.href=d,l&&p.setAttribute("nonce",l),document.head.appendChild(p),m)return new Promise((x,k)=>{p.addEventListener("load",x),p.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${d}`)))})}))}function o(c){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=c,window.dispatchEvent(l),!l.defaultPrevented)throw c}return a.then(c=>{for(const l of c||[])l.status==="rejected"&&o(l.reason);return t().catch(o)})};let ai=!1;const Dc=i.forwardRef(({onInput:e,onViewportMetrics:t,onScrollMetrics:r,fontSize:n=13,readOnly:a=!1,sizingMode:o="measured"},c)=>{const l=i.useRef(null),[d,m]=i.useState(null),u=i.useRef([]),p=i.useRef(!1),x=i.useRef(!1),k=i.useRef(!1),b=i.useRef(!1),f=()=>{const g=l.current;if(g){p.current&&(g.clear(),p.current=!1);for(const y of u.current)g.write(y.data,y.onProcessed);u.current=[],x.current&&(g.fit(),x.current=!1),k.current&&(g.bumpResize(),k.current=!1),b.current&&(g.scrollToTop(),b.current=!1)}};return i.useImperativeHandle(c,()=>({write:(g,y)=>{l.current?l.current.write(g,y):u.current.push({data:g,onProcessed:y})},clear:()=>{l.current?l.current.clear():(u.current=[],p.current=!0)},reset:()=>{l.current&&typeof l.current.reset=="function"?l.current.reset():(u.current=[],p.current=!0)},resize:(g,y)=>{l.current&&typeof l.current.resize=="function"&&l.current.resize(g,y)},fit:()=>{l.current?l.current.fit():x.current=!0},bumpResize:()=>{l.current?l.current.bumpResize():k.current=!0},scrollToTop:()=>{l.current?l.current.scrollToTop():b.current=!0},getSelection:()=>{var g,y;return((y=(g=l.current)==null?void 0:g.getSelection)==null?void 0:y.call(g))||""},getVisibleText:()=>{var g,y;return((y=(g=l.current)==null?void 0:g.getVisibleText)==null?void 0:y.call(g))||""}}),[]),i.useEffect(()=>{d&&f()},[d]),i.useEffect(()=>{let g=!1;return Rm(()=>import("./terminal-BeBmUW3m.js"),__vite__mapDeps([0,1,2])).then(y=>{ai||(ai=!0,console.info("[CliTerminal] renderer module loaded: terminal-render-web")),g||m(()=>y.GhosttyTerminalView)}).catch(y=>{console.error("[CliTerminal] failed to load terminal renderer",y)}),()=>{g=!0}},[]),d?s.jsx(d,{ref:l,onInput:e,onViewportMetrics:t,onScrollMetrics:r,fontSize:n,readOnly:a,sizingMode:o,className:"w-full h-full rounded-lg overflow-hidden"}):s.jsx("div",{className:"w-full h-full rounded-lg overflow-hidden animate-pulse",style:{background:"#0f1117"}})});Dc.displayName="CliTerminal";function Rr({label:e,value:t,sub:r,icon:n}){return s.jsxs("div",{className:"px-4 py-3.5 rounded-xl bg-bg-secondary border border-border-subtle",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[s.jsx("span",{className:"text-base flex items-center",children:n}),s.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wide font-semibold",children:e})]}),s.jsx("div",{className:"text-[22px] font-bold text-text-primary tracking-tight",children:t}),r&&s.jsx("div",{className:"text-[11px] text-text-muted mt-0.5",children:r})]})}function oi({value:e,max:t,label:r,color:n="#8b5cf6",detail:a,compact:o=!1}){const c=t>0?Math.min(Math.round(e/t*100),100):0,l=c>85?"#ef4444":c>60?"var(--status-warning)":n;return o?s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex justify-between mb-0.5",children:[s.jsx("span",{className:"text-[9px] text-text-muted uppercase tracking-wide font-semibold",children:r}),s.jsxs("span",{className:"text-[10px] text-text-secondary font-semibold",children:[c,"%"]})]}),s.jsx("div",{className:"h-1 bg-white/[0.04] rounded-sm overflow-hidden",children:s.jsx("div",{className:"h-full rounded-sm transition-[width] duration-500",style:{width:`${c}%`,background:l}})})]}):s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex justify-between mb-1.5",children:[s.jsx("span",{className:"text-[11px] text-text-secondary font-medium",children:r}),s.jsxs("span",{className:"text-[13px] text-text-primary font-bold",children:[c,"%"]})]}),s.jsx("div",{className:"h-1.5 bg-white/[0.04] rounded-sm overflow-hidden",children:s.jsx("div",{className:"h-full rounded-sm transition-[width] duration-[600ms]",style:{width:`${c}%`,background:`linear-gradient(90deg, ${l}, ${l}cc)`}})}),a&&s.jsx("div",{className:"text-[10px] text-text-muted mt-0.5",children:a})]})}function Lm({cursorPos:e,viewportRef:t,imgRef:r}){var h;if(!e||!r.current)return null;const n=r.current,a=n.getBoundingClientRect(),o=(h=t.current)==null?void 0:h.getBoundingClientRect();if(!o)return null;const c=n.naturalWidth||a.width,l=n.naturalHeight||a.height,d=c/l,m=a.width/a.height;let u,p,x,k;d>m?(u=a.width,p=a.width/d,x=0,k=(a.height-p)/2):(p=a.height,u=a.height*d,x=(a.width-u)/2,k=0);const b=a.left-o.left+x+u*e.nx,f=a.top-o.top+k+p*e.ny,g=Math.max(8,Math.min(o.width-8,b)),y=Math.max(8,Math.min(o.height-8,f));return s.jsxs("div",{style:{position:"absolute",left:g-8,top:y-8,width:16,height:16,pointerEvents:"none",zIndex:100},children:[s.jsx("div",{style:{position:"absolute",left:7,top:0,width:2,height:16,background:"rgba(59,130,246,0.8)"}}),s.jsx("div",{style:{position:"absolute",left:0,top:7,width:16,height:2,background:"rgba(59,130,246,0.8)"}}),s.jsx("div",{style:{position:"absolute",left:5,top:5,width:6,height:6,borderRadius:"50%",background:"#3b82f6",boxShadow:"0 0 8px rgba(59,130,246,0.6)"}})]})}function Pm({inputMode:e,onToggleInputMode:t,isImeOpen:r,setIsImeOpen:n,isMenuOpen:a,setIsMenuOpen:o,imeText:c,setImeText:l,handleImeSubmit:d,isConnActive:m,zoom:u,isMobile:p,mobileFillZoom:x,onZoomOut:k,onZoomReset:b,onZoomIn:f,transportType:g,screenshotUsage:y,lastActionStatus:h}){return s.jsxs(s.Fragment,{children:[s.jsxs("div",{onTouchStart:T=>T.stopPropagation(),className:"absolute bottom-0 left-0 right-0 z-20 flex items-center justify-center gap-1.5 px-3 py-2 bg-black/75 backdrop-blur-xl border-t border-white/[0.08] touch-none",children:[s.jsxs("div",{onClick:t,className:`h-8 px-2.5 rounded-lg flex items-center gap-[5px] cursor-pointer ${e==="mouse"?"bg-blue-500/25 border border-blue-500/40":"bg-white/[0.08] border border-white/10"}`,children:[s.jsx("span",{className:"text-sm",children:e==="mouse"?"🖱️":"👆"}),s.jsx("span",{className:`text-[10px] font-bold ${e==="mouse"?"text-blue-400":"text-slate-400"}`,children:e==="mouse"?"Mouse":"Touch"})]}),s.jsxs("div",{className:"relative",children:[s.jsx("div",{onClick:()=>{n(T=>!T),o(!1)},className:`w-8 h-8 rounded-lg flex items-center justify-center cursor-pointer ${r?"bg-emerald-500/25 border border-emerald-500/40":"bg-white/[0.08] border border-white/10"}`,children:s.jsx("span",{className:"text-sm",children:"⌨️"})}),r&&s.jsx("div",{className:"absolute bottom-10 left-1/2 -translate-x-1/2 w-[220px] bg-neutral-950/[0.98] backdrop-blur-[30px] rounded-xl border border-white/20 p-[10px_12px] shadow-[0_10px_30px_rgba(0,0,0,0.8)] flex flex-col gap-2 z-20",style:{animation:"slideUp 0.15s ease-out"},children:s.jsx("input",{type:"text",placeholder:"Type & Enter...",value:c,autoFocus:!0,onTouchStart:T=>T.stopPropagation(),onChange:T=>l(T.target.value),onKeyDown:T=>{d(T)},className:"w-full bg-black/60 border border-white/15 rounded-lg px-2.5 py-2 text-white text-[13px] outline-none"})})]}),s.jsx("div",{className:"relative",children:s.jsx("div",{onClick:()=>{o(T=>!T),n(!1)},className:`w-8 h-8 rounded-lg flex items-center justify-center cursor-pointer ${a?"bg-blue-500/25 border border-blue-500/40":"bg-white/[0.08] border border-white/10"}`,children:s.jsx("span",{className:"text-sm",children:"⚙️"})})}),s.jsx("div",{className:"w-px h-[18px] bg-white/10"}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsxs("div",{className:"flex items-center gap-0.5 px-1.5 py-0.5 rounded-md",style:{background:m?"rgba(34,197,94,0.12)":"rgba(234,179,8,0.12)"},children:[s.jsx("div",{className:"w-1 h-1 rounded-full",style:{background:m?"#22c55e":"#eab308",boxShadow:m?"0 0 4px #22c55e80":"0 0 4px #eab30880"}}),s.jsx("span",{className:"text-[8px] font-extrabold",style:{color:m?"#22c55e":"#eab308"},children:m?"Connected":"WS"})]}),u>1&&s.jsxs("span",{className:"text-[8px] font-bold text-indigo-400",children:[Math.round(u*100),"%"]}),g==="direct"&&s.jsx("span",{className:"text-[8px] font-bold px-1 py-0.5 rounded",style:{color:"#22c55e",background:"rgba(34,197,94,0.12)"},title:"Direct P2P connection",children:"Direct"}),g==="relay"&&s.jsx("span",{className:"text-[8px] font-bold px-1 py-0.5 rounded",style:{color:"var(--status-warning)",background:"color-mix(in srgb, var(--status-warning) 12%, transparent)"},title:"TURN relay in use",children:"Relay"}),y&&y.dailyBudgetMinutes>0&&s.jsx("span",{className:"text-[8px] font-bold px-1 py-0.5 rounded",style:{color:y.budgetExhausted?"#ef4444":"#c4b5fd",background:y.budgetExhausted?"rgba(239,68,68,0.1)":"rgba(139,92,246,0.14)"},title:"Daily TURN relay usage",children:y.budgetExhausted?"TURN blocked":`TURN ${y.dailyUsedMinutes}/${y.dailyBudgetMinutes}m`}),h&&s.jsx("span",{className:"text-[8px] text-neutral-500 font-semibold max-w-[100px] overflow-hidden text-ellipsis whitespace-nowrap",children:h})]})]}),a&&s.jsxs("div",{onTouchStart:T=>T.stopPropagation(),style:{position:"absolute",bottom:56,left:"50%",transform:"translateX(-50%)",width:220,background:"rgba(23, 23, 23, 0.95)",backdropFilter:"blur(25px)",borderRadius:14,border:"1px solid rgba(255,255,255,0.1)",padding:14,boxShadow:"0 12px 40px rgba(0,0,0,0.6)",display:"flex",flexDirection:"column",gap:12,zIndex:20,touchAction:"none",animation:"slideUpSidebar 0.15s ease-out"},children:[s.jsx("div",{style:{fontSize:9,fontWeight:900,color:"#3b82f6",letterSpacing:1.5},children:"SETTINGS"}),s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[s.jsxs("div",{style:{fontSize:10,color:"#888",fontWeight:700},children:["ZOOM: ",u<=(p?x:1)+.01?p?"FILL":"FIT":`${Math.round(u*100)}%`]}),s.jsxs("div",{style:{display:"flex",gap:4},children:[s.jsx("button",{onClick:T=>{T.stopPropagation(),k()},style:{flex:1,background:"rgba(255,255,255,0.1)",color:"#fff",border:"none",padding:"6px",borderRadius:6,fontSize:12,fontWeight:800,cursor:"pointer"},children:"−"}),s.jsx("button",{onClick:T=>{T.stopPropagation(),b()},style:{flex:1,background:"rgba(255,255,255,0.1)",color:"#fff",border:"none",padding:"6px",borderRadius:6,fontSize:9,fontWeight:800,cursor:"pointer"},children:p?"FILL":"FIT"}),s.jsx("button",{onClick:T=>{T.stopPropagation(),f()},style:{flex:1,background:"rgba(255,255,255,0.1)",color:"#fff",border:"none",padding:"6px",borderRadius:6,fontSize:12,fontWeight:800,cursor:"pointer"},children:"+"})]})]})]})]})}function _m({waitingLabel:e,waitingHint:t,transportType:r}){return s.jsxs("div",{className:"text-center flex flex-col items-center gap-3 px-6",children:[s.jsx("div",{className:"w-14 h-14 rounded-2xl flex items-center justify-center border border-white/10 bg-white/[0.04] shadow-[0_10px_30px_rgba(0,0,0,0.35)]",style:{animation:"remote-float 2.8s ease-in-out infinite"},children:s.jsx("img",{src:"/otter-logo.png",alt:"",className:"w-8 h-8 opacity-90"})}),s.jsx("div",{className:"text-white/85 text-[13px] font-semibold tracking-wide",children:e}),s.jsx("div",{className:"text-[11px] text-white/40",children:t}),r==="relay"&&s.jsx("div",{className:"text-[10px] font-medium",style:{color:"var(--status-warning)",opacity:.8},children:"TURN relay active"})]})}function Dm(){if(typeof window>"u")return!1;try{return window.__ADHDEV_DEBUG_RENDERS__===!0||window.localStorage.getItem("adhdev_debug_renders")==="1"}catch{return window.__ADHDEV_DEBUG_RENDERS__===!0}}function ii(e){return e==null||typeof e=="number"||typeof e=="boolean"?e:typeof e=="string"?e.length>64?`${e.slice(0,61)}...`:e:Array.isArray(e)?`Array(${e.length})`:typeof e=="object"?"Object":typeof e}function yr(e,t){const r=i.useRef(null),n=i.useRef(0);i.useEffect(()=>{if(!Dm())return;n.current+=1;const a=r.current;if(!a){console.debug(`[render-trace] ${e}#${n.current}`,{changed:["mount"],snapshot:Object.fromEntries(Object.entries(t).map(([c,l])=>[c,ii(l)]))}),r.current=t;return}const o=Object.keys({...a,...t}).filter(c=>!Object.is(a[c],t[c]));o.length>0&&console.debug(`[render-trace] ${e}#${n.current}`,{changed:o,snapshot:Object.fromEntries(o.map(c=>[c,ii(t[c])]))}),r.current=t})}function Em({containerRef:e,viewportRef:t,imgRef:r,inputMode:n,setInputMode:a,minZoom:o,zoomRef:c,panXRef:l,panYRef:d,setPanX:m,setPanY:u,setZoom:p,lastWheelTimeRef:x,onAction:k,setLastActionStatus:b,spawnRippleFromNormalized:f,clampPan:g,isMobile:y,mobileFillZoom:h}){const[T,S]=i.useState(null),v=i.useRef(null),A=i.useRef(null),M=i.useRef(null),w=i.useRef(!1),j=i.useRef(null),B=i.useRef(0),P=i.useRef(null),I=i.useRef(1),O=i.useRef({x:0,y:0}),F=i.useRef(!1),L=i.useRef(n),C=i.useRef(k),N=30,K=550,_=18,D=60,H=400,J=12,be=()=>{if(v.current)return;const U={nx:.5,ny:.5};v.current=U,S(U)};return i.useEffect(()=>{L.current=n,n==="mouse"&&be()},[n]),i.useEffect(()=>{C.current=k},[k]),i.useEffect(()=>{const U=e.current;if(!U)return;const le=ue=>{if(!r.current)return null;const ke=r.current.getBoundingClientRect();return!ke.width||!ke.height?null:{nx:Math.max(0,Math.min(1,(ue.clientX-ke.left)/ke.width)),ny:Math.max(0,Math.min(1,(ue.clientY-ke.top)/ke.height))}},pe=(ue,ke)=>{if(!r.current)return{dnx:0,dny:0};const fe=r.current,ye=fe.getBoundingClientRect(),ae=fe.naturalWidth||ye.width,he=fe.naturalHeight||ye.height,ie=ae/he,me=ye.width/ye.height;let Z,ve;return ie>me?(Z=ye.width,ve=ye.width/ie):(ve=ye.height,Z=ye.height*ie),{dnx:ue/Z,dny:ke/ve}},Y=(ue,ke,fe)=>{if(fe<=1.05)return;const ye=-(ue-.5)*100,ae=-(ke-.5)*100,he=g(ye,ae,fe);(Math.abs(he.x-l.current)>.1||Math.abs(he.y-d.current)>.1)&&(m(he.x),u(he.y),l.current=he.x,d.current=he.y)},de=ue=>{const ke=t.current;if(ke&&ue.target instanceof Node&&ke.contains(ue.target))ue.preventDefault();else return;if(ue.touches.length===1){const fe=ue.touches[0];A.current={x:fe.clientX,y:fe.clientY,time:Date.now()},M.current={x:fe.clientX,y:fe.clientY},F.current||(w.current=!1),j.current=setTimeout(()=>{if(!w.current&&!F.current)if(w.current=!0,L.current==="mouse"){const ye=v.current||{nx:.5,ny:.5};b("Right Click"),f(ye.nx,ye.ny,"right"),C.current("input_click",{...ye,button:"right"}).catch(()=>{})}else{const ye=le(fe);ye&&(b("Right Click"),f(ye.nx,ye.ny,"right"),C.current("input_click",{...ye,button:"right"}).catch(()=>{}))}},500);return}if(ue.touches.length===2){j.current&&clearTimeout(j.current),w.current=!0,F.current=!0;const fe=ue.touches[1].clientX-ue.touches[0].clientX,ye=ue.touches[1].clientY-ue.touches[0].clientY;P.current=Math.sqrt(fe*fe+ye*ye),I.current=c.current,O.current={x:(ue.touches[0].clientX+ue.touches[1].clientX)/2,y:(ue.touches[0].clientY+ue.touches[1].clientY)/2}}},ge=ue=>{const ke=t.current;if(ke&&ue.target instanceof Node&&ke.contains(ue.target)&&ue.preventDefault(),ue.touches.length===1&&M.current){const fe=ue.touches[0],ye=fe.clientX-M.current.x,ae=fe.clientY-M.current.y;if(!w.current&&A.current){const he=fe.clientX-A.current.x,ie=fe.clientY-A.current.y;Math.sqrt(he*he+ie*ie)>8&&(w.current=!0,j.current&&clearTimeout(j.current))}if(w.current)if(L.current==="mouse"){const he=pe(ye,ae),ie=v.current||{nx:.5,ny:.5},me=Math.max(0,Math.min(1,ie.nx+he.dnx)),Z=Math.max(0,Math.min(1,ie.ny+he.dny));v.current={nx:me,ny:Z},S({nx:me,ny:Z}),b(`Cursor: ${Math.round(me*100)}%, ${Math.round(Z*100)}%`),Y(me,Z,c.current);const ve=Date.now();ve-x.current>=30&&(x.current=ve,C.current("input_mouseMoved",{nx:me,ny:Z}).catch(()=>{}))}else if(c.current>1){const he=t.current;if(he){const ie=he.clientWidth,me=he.clientHeight,Z=l.current+ye/ie*100,ve=d.current+ae/me*100,oe=g(Z,ve,c.current);m(oe.x),u(oe.y),l.current=oe.x,d.current=oe.y}}else{const he=le(fe);if(he){const ie=Date.now();ie-x.current>=40&&(x.current=ie,b("Scroll"),C.current("input_wheel",{nx:he.nx,ny:he.ny,deltaX:Math.round(-ye*2.5),deltaY:Math.round(-ae*2.5)}).catch(()=>{}))}}M.current={x:fe.clientX,y:fe.clientY};return}if(ue.touches.length===2&&P.current!==null){const fe=ue.touches[1].clientX-ue.touches[0].clientX,ye=ue.touches[1].clientY-ue.touches[0].clientY,he=Math.sqrt(fe*fe+ye*ye)/P.current,ie=(ue.touches[0].clientX+ue.touches[1].clientX)/2,me=(ue.touches[0].clientY+ue.touches[1].clientY)/2,Z=ie-O.current.x,ve=me-O.current.y,oe=Math.abs(he-1)>.03;if(L.current==="mouse"){if(oe){const q=Math.max(o,Math.min(5,I.current*he));p(q),c.current=q}else if(Math.abs(Z)>2||Math.abs(ve)>2){const q=v.current||{nx:.5,ny:.5},Se=Date.now();Se-x.current>=30&&(x.current=Se,b("Scroll"),C.current("input_wheel",{nx:q.nx,ny:q.ny,deltaX:Math.round(-Z*3),deltaY:Math.round(-ve*3)}).catch(()=>{}))}}else{const q=Math.max(o,Math.min(5,I.current*he));p(q),c.current=q;const Se=t.current;if(Se&&q>1){const Ie=Se.clientWidth,Le=Se.clientHeight,Me=l.current+Z/Ie*100,$=d.current+ve/Le*100,Ce=g(Me,$,q);m(Ce.x),u(Ce.y),l.current=Ce.x,d.current=Ce.y}}O.current={x:ie,y:me}}},se=ue=>{var ke;if(j.current&&clearTimeout(j.current),P.current=null,ue.touches.length===1&&F.current){const fe=ue.touches[0];A.current={x:fe.clientX,y:fe.clientY,time:Date.now()},M.current={x:fe.clientX,y:fe.clientY},w.current=!0;return}if(ue.touches.length===0){if(F.current){F.current=!1,w.current=!1;return}if(ue.changedTouches.length===1){const fe=ue.changedTouches[0],ye=Date.now(),ae=ye-(((ke=A.current)==null?void 0:ke.time)||0),he=A.current?fe.clientX-A.current.x:0,ie=A.current?fe.clientY-A.current.y:0,me=Math.sqrt(he*he+ie*ie);if(L.current==="mouse"){if(ae<N||ae>K||me>_){w.current=!1;return}const Z=v.current||le(fe);Z&&(b(`Click: ${Math.round(Z.nx*100)}%, ${Math.round(Z.ny*100)}%`),f(Z.nx,Z.ny,"left"),C.current("input_click",{...Z}).catch(()=>{}))}else{if(w.current){w.current=!1;return}if(ae<D||ae>H||me>J){w.current=!1;return}const Z=le(fe);if(!Z)return;ye-B.current<300?(b("Double tap"),f(Z.nx,Z.ny,"double"),C.current("input_click",{...Z,clickCount:2}).catch(()=>{}),B.current=0):(b(`Tap: ${Math.round(Z.nx*100)}%, ${Math.round(Z.ny*100)}%`),f(Z.nx,Z.ny,"left"),C.current("input_click",{...Z}).catch(()=>{}),B.current=ye)}}w.current=!1}};return U.addEventListener("touchstart",de,{passive:!1}),U.addEventListener("touchmove",ge,{passive:!1}),U.addEventListener("touchend",se,{passive:!1}),()=>{U.removeEventListener("touchstart",de),U.removeEventListener("touchmove",ge),U.removeEventListener("touchend",se),j.current&&clearTimeout(j.current)}},[e,t,r,o,c,l,d,m,u,p,x,b,f,g]),{cursorPos:T,cursorPosRef:v,handleToggleInputMode:()=>{a(U=>{const le=U==="touch"?"mouse":"touch";return le==="mouse"&&be(),le})},handleZoomReset:()=>{const U=y?h:1;p(U),c.current=U,m(0),u(0),l.current=0,d.current=0}}}function Ec({onAction:e,addLog:t,connState:r,connScreenshot:n,screenshotUsage:a,transportType:o}){const c=i.useRef(null),l=i.useRef(null),d=i.useRef(null),[m,u]=i.useState(null),[p,x]=i.useState(""),[,k]=i.useState(!1),[b,f]=i.useState([]),g=i.useRef(0),[y,h]=i.useState(!1),[T,S]=i.useState(!1),v=typeof window<"u"&&window.matchMedia("(max-width: 768px)").matches,[A,M]=i.useState(v?"mouse":"touch"),[w,j]=i.useState(1),B=i.useRef(!1),[P,I]=i.useState(1),[O,F]=i.useState(0),[L,C]=i.useState(0);yr("RemoteView",{connState:r,hasScreenshot:!!n,inputMode:A,zoom:P,panX:O,panY:L,isMenuOpen:y,isImeOpen:T});const N=i.useRef(0),K=i.useRef(P),_=i.useRef(O),D=i.useRef(L);i.useEffect(()=>{K.current=P},[P]),i.useEffect(()=>{_.current=O},[O]),i.useEffect(()=>{D.current=L},[L]),i.useEffect(()=>{var ae;(ae=c.current)==null||ae.focus()},[]);const H=r==="connected",J=n,be=H?"Connected. Waiting for first frame...":r==="connecting"?"Connecting to Host...":"Reconnecting to Host...",ce=H?"The remote stream is warming up":"Waiting for the remote stream to catch up";i.useEffect(()=>{if(!v||B.current||!J)return;const ae=d.current,he=l.current;if(!ae||!he)return;const ie=()=>{const me=he.clientWidth,Z=he.clientHeight,ve=ae.naturalWidth,oe=ae.naturalHeight;if(!ve||!oe||!me||!Z)return;const q=Math.min(me/ve,Z/oe),Ie=Math.max(me/ve,Z/oe)/q;Ie>1.01&&(j(Ie),I(Ie),K.current=Ie),B.current=!0};ae.complete&&ae.naturalWidth?ie():ae.addEventListener("load",ie,{once:!0})},[J,v]);const Q=.5;i.useEffect(()=>{P<=Q&&(F(0),C(0))},[P,Q]);const U=(ae,he,ie)=>{if(ie<=Q)return{x:0,y:0};const me=(ie-1)/(2*ie)*100,Z=(ie-1)/(2*ie)*100;return{x:Math.max(-me,Math.min(me,ae)),y:Math.max(-Z,Math.min(Z,he))}},le=(ae,he)=>{if(!d.current)return null;const ie=d.current.getBoundingClientRect();return!ie.width||!ie.height?null:{nx:Math.max(0,Math.min(1,(ae-ie.left)/ie.width)),ny:Math.max(0,Math.min(1,(he-ie.top)/ie.height))}},pe=(ae,he,ie)=>{const me=l.current;if(!me)return;const Z=me.getBoundingClientRect(),ve=++g.current;f(oe=>[...oe,{id:ve,x:ae-Z.left,y:he-Z.top,type:ie}]),setTimeout(()=>f(oe=>oe.filter(q=>q.id!==ve)),600)},Y=(ae,he,ie)=>{const me=d.current,Z=l.current;if(!me||!Z)return;const ve=me.getBoundingClientRect(),oe=Z.getBoundingClientRect(),q=me.naturalWidth||ve.width,Se=me.naturalHeight||ve.height,Ie=q/Se,Le=ve.width/ve.height;let Me,$,Ce,Pe;Ie>Le?(Me=ve.width,$=ve.width/Ie,Ce=0,Pe=(ve.height-$)/2):($=ve.height,Me=ve.height*Ie,Ce=(ve.width-Me)/2,Pe=0);const Fe=ve.left-oe.left+Ce+Me*ae,He=ve.top-oe.top+Pe+$*he,qe=++g.current;f(Ye=>[...Ye,{id:qe,x:Fe,y:He,type:ie}]),setTimeout(()=>f(Ye=>Ye.filter(tt=>tt.id!==qe)),600)},de=async ae=>{var ie;const he=le(ae.clientX,ae.clientY);if(he){u(`Click: ${Math.round(he.nx*100)}%, ${Math.round(he.ny*100)}%`),pe(ae.clientX,ae.clientY,"left"),(ie=c.current)==null||ie.focus();try{const me=await e("input_click",{nx:he.nx,ny:he.ny});me!=null&&me.success||t(`❌ Click failed: ${me==null?void 0:me.error}`)}catch(me){t(`❌ Click error: ${me.message||me}`)}}},ge=async(ae,he,ie,me=0)=>{try{await e("input_key",{type:ie?"char":"keyDown",key:ae,code:he,text:ie?ae:void 0,unmodifiedText:ie?ae:void 0,modifiers:me})}catch(Z){t(`❌ Key error: ${Z.message||Z}`)}},se=async ae=>{if(ae.target.tagName==="INPUT")return;["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Backspace","Tab","Enter","Escape"].includes(ae.key)&&ae.preventDefault();let ie=0;ae.altKey&&(ie|=1),ae.ctrlKey&&(ie|=2),ae.metaKey&&(ie|=4),ae.shiftKey&&(ie|=8),u(`Key: ${ae.key}`),await ge(ae.key,ae.code,ae.key.length===1,ie)},ue=async ae=>{if(ae.key==="Enter"){if(ae.nativeEvent.isComposing)return;if(p){const he=p;x(""),u(`IME Sent: ${he}`);try{const ie=await e("input_type",{text:he});ie!=null&&ie.success||t(`❌ IME error: ${ie==null?void 0:ie.error}`)}catch(ie){t(`❌ IME error: ${ie.message}`)}}else u("Key: Enter"),await ge("Enter","Enter",!1)}};i.useEffect(()=>{const ae=c.current;if(!ae)return;const he=ie=>{var me;if((me=d.current)!=null&&me.contains(ie.target)){ie.preventDefault();const Z=Date.now();if(Z-N.current<40)return;N.current=Z;const ve=le(ie.clientX,ie.clientY);if(!ve)return;u(`Scroll: ${Math.round(ie.deltaY)}`),e("input_wheel",{nx:ve.nx,ny:ve.ny,deltaX:Math.round(ie.deltaX),deltaY:Math.round(ie.deltaY)}).catch(()=>{})}};return ae.addEventListener("wheel",he,{passive:!1}),()=>ae.removeEventListener("wheel",he)},[e]);const{cursorPos:ke,handleToggleInputMode:fe,handleZoomReset:ye}=Em({containerRef:c,viewportRef:l,imgRef:d,inputMode:A,setInputMode:M,minZoom:Q,zoomRef:K,panXRef:_,panYRef:D,setPanX:F,setPanY:C,setZoom:I,lastWheelTimeRef:N,onAction:e,setLastActionStatus:u,spawnRippleFromNormalized:Y,clampPan:U,isMobile:v,mobileFillZoom:w});return s.jsxs("div",{ref:c,className:"flex-1 flex flex-col bg-black relative overflow-hidden outline-none touch-none",onKeyDown:se,onContextMenu:ae=>ae.preventDefault(),onFocus:()=>k(!0),onBlur:()=>k(!1),tabIndex:0,children:[s.jsxs("div",{ref:l,className:"flex-1 relative overflow-hidden flex items-center justify-center bg-black",children:[J?s.jsx("img",{ref:d,src:J,alt:"Remote View",style:{display:"block",maxWidth:"100%",maxHeight:"100%",width:"auto",height:"auto",transform:`scale(${P}) translate(${O}%, ${L}%)`,transformOrigin:"center center",cursor:A==="mouse"?"default":"crosshair",userSelect:"none",WebkitTouchCallout:"none"},onClick:de,onContextMenu:ae=>ae.preventDefault(),onDragStart:ae=>ae.preventDefault()}):s.jsx(_m,{waitingLabel:be,waitingHint:ce,transportType:o}),A==="mouse"&&J&&s.jsx(Lm,{cursorPos:ke,viewportRef:l,imgRef:d}),b.map(ae=>{const ie={left:"59,130,246",right:"239,68,68",double:"34,197,94"}[ae.type];return s.jsxs("div",{style:{position:"absolute",left:ae.x,top:ae.y,pointerEvents:"none",zIndex:200,transform:"translate(-50%, -50%)"},children:[s.jsx("div",{style:{width:40,height:40,borderRadius:"50%",border:`2px solid rgba(${ie}, 0.8)`,animation:"click-ripple-ring 0.5s ease-out forwards",position:"absolute",left:-20,top:-20}}),s.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:`rgba(${ie}, 0.9)`,boxShadow:`0 0 12px rgba(${ie}, 0.6)`,animation:"click-ripple-dot 0.4s ease-out forwards",position:"absolute",left:-4,top:-4}})]},ae.id)})]}),s.jsx(Pm,{inputMode:A,onToggleInputMode:fe,isImeOpen:T,setIsImeOpen:S,isMenuOpen:y,setIsMenuOpen:h,imeText:p,setImeText:x,handleImeSubmit:ue,isConnActive:H,zoom:P,isMobile:v,mobileFillZoom:w,onZoomOut:()=>I(ae=>Math.max(.5,ae-.25)),onZoomReset:ye,onZoomIn:()=>I(ae=>Math.min(5,ae+.25)),transportType:o,screenshotUsage:a,lastActionStatus:m}),s.jsx("style",{children:`
6
+ `});if(p.isActivityFacing&&u!=="thought"&&u!=="tool"&&u!=="terminal"){const P=p.label||"Activity";return s.jsxs("div",{className:"self-start chat-msg-activity","data-chat-activity-row":"true",children:[s.jsxs("div",{className:"chat-msg-activity-meta","aria-label":"Activity message",children:[s.jsx("span",{className:"activity-dot"}),s.jsx("span",{children:P})]}),k&&x?s.jsx("div",{className:"chat-msg-activity-body",children:s.jsx(Vs,{parts:x,renderAsPreformatted:!1})}):s.jsx("div",{className:"chat-msg-activity-body",style:{whiteSpace:"pre-wrap"},children:b})]})}if(u==="thought"){const P=typeof((w=t.meta)==null?void 0:w.label)=="string"?t.meta.label:"Thought";return s.jsxs("div",{className:"self-start chat-msg-thought","data-chat-activity-row":p.isActivityFacing?"true":void 0,children:[s.jsxs("div",{className:"chat-msg-header",children:[s.jsx(zu,{size:13}),s.jsx("span",{children:P})]}),s.jsx("div",{className:"chat-msg-body",children:b})]})}if(u==="tool")return s.jsxs("div",{className:"self-start chat-msg-tool","data-chat-activity-row":p.isActivityFacing?"true":void 0,children:[s.jsxs("div",{className:"chat-msg-tool-meta","aria-label":"Tool message",children:[s.jsx("span",{className:"tool-icon",children:"⏺"}),s.jsx("span",{className:"tool-label",children:"Tool"})]}),k&&x?s.jsx("div",{className:"tool-text w-full",children:s.jsx(Vs,{parts:x,renderAsPreformatted:!1})}):s.jsx("div",{className:"tool-text w-full",style:{whiteSpace:"pre-wrap"},children:b})]});if(u==="terminal"){const P=(j=t.meta)!=null&&j.isRunning?"⏳":"✅",I=typeof((B=t.meta)==null?void 0:B.label)=="string"?t.meta.label:"Ran command";return s.jsxs("div",{className:"self-start chat-msg-terminal","data-chat-activity-row":p.isActivityFacing?"true":void 0,children:[s.jsxs("div",{className:"chat-msg-header",children:[s.jsx("span",{children:P}),s.jsx("span",{children:I})]}),k&&x?s.jsx("div",{className:"chat-msg-body",children:s.jsx(Vs,{parts:x,renderAsPreformatted:!0})}):s.jsx("pre",{className:"chat-msg-body",children:b})]})}if(u==="system")return s.jsx("div",{className:"self-center chat-msg-system",children:k&&x?s.jsx(Vs,{parts:x,renderAsPreformatted:!1}):b.slice(0,100)});const f=t.meta,y=(typeof(f==null?void 0:f.renderMode)=="string"?f.renderMode.trim():"")==="preformatted",h=b,T=!1,S=h,v=y,A=!v&&_c(S),M=["chat-message-row",m?"chat-message-row-user self-end":"chat-message-row-assistant self-start"].join(" ");return s.jsx("div",{className:M,children:(h||k||m)&&s.jsxs("div",{className:`chat-bubble ${m?"chat-bubble-user":"chat-bubble-assistant"}`,children:[s.jsxs("div",{className:`chat-bubble-header ${h||k?"mb-1.5":"mb-0"}`,children:[s.jsx("span",{className:"chat-sender",children:m?a||"You":t.senderName||n}),r!=null&&s.jsx("span",{className:"chat-time",children:Pc(r)})]}),(h||k)&&s.jsx("div",{className:"chat-markdown",children:k&&x?s.jsx(Vs,{parts:x,renderAsPreformatted:v}):v?s.jsx("pre",{className:"chat-preformatted",children:S}):A?s.jsx(Xa,{remarkPlugins:Lc,children:S}):s.jsx("div",{style:{whiteSpace:"pre-wrap"},children:S})}),T]})})},(e,t)=>e.message===t.message&&e.receivedAt===t.receivedAt&&e.agentName===t.agentName&&e.userName===t.userName&&e.isCliMode===t.isCliMode&&e.isTextExpanded===t.isTextExpanded),Tm=i.forwardRef(function({messages:t,actionLogs:r,agentName:n="Agent",userName:a,isCliMode:o=!1,isWorking:c=!1,contextKey:l="",receivedAtMap:d={},lastMessageHash:m,showActivityMessages:u=!1,emptyState:p,onLoadMore:x,isLoadingMore:k,hasMoreHistory:b,hiddenLiveCount:f=0,loadError:g,scrollToBottomRequestNonce:y,isVisible:h=!0},T){const S=i.useRef(null),v=i.useRef(null),A=i.useRef(null),M=i.useRef(0),w=i.useRef(""),j=i.useRef(""),B=i.useRef(!1),P=i.useRef(null),I=i.useRef(!1),O=i.useRef(null),F=i.useRef(!1),[L,C]=i.useState(new Set),[N,K]=i.useState({showTop:!1,showBottom:!1}),_=i.useRef(!1),D=i.useRef(!1),H=i.useRef(h),J=i.useRef(h),be=i.useRef(null);J.current=h;const ce=()=>{const oe=S.current;return oe?oe.scrollHeight-oe.scrollTop-oe.clientHeight<oo:!0},Q=i.useCallback(()=>{const oe=S.current,q=oe?ym(oe):{showTop:!1,showBottom:!1};K(Se=>Se.showTop===q.showTop&&Se.showBottom===q.showBottom?Se:q)},[]),U=i.useCallback((oe="auto")=>{var Se;const q=S.current;q&&(q.scrollTo({top:q.scrollHeight,behavior:oe}),(Se=q.ownerDocument.defaultView)==null||Se.requestAnimationFrame(()=>Q()))},[Q]),le=i.useCallback((oe="auto")=>{var Se;const q=S.current;q&&(q.scrollTo({top:0,behavior:oe}),(Se=q.ownerDocument.defaultView)==null||Se.requestAnimationFrame(()=>Q()))},[Q]),pe=i.useCallback(()=>{var Le;const oe=S.current,q=(Le=window.getSelection)==null?void 0:Le.call(window);if(!oe||!q||q.rangeCount===0||q.isCollapsed){F.current=!1;return}const Se=q.anchorNode,Ie=q.focusNode;F.current=!!(Se&&Ie&&oe.contains(Se)&&oe.contains(Ie))},[]),Y=i.useMemo(()=>{const oe=um(t),q=Mc(t);return mm(oe,q,u)},[t,u]),de=Y.length===t.length?m:void 0,ge=xm(Y,de),se=i.useCallback(()=>{const oe=S.current;if(!oe||!l||!J.current)return;const q={top:oe.scrollTop,fromBottom:Math.max(0,oe.scrollHeight-oe.scrollTop-oe.clientHeight),messageFingerprint:ge};be.current={contextKey:l,snapshot:q},Us.set(l,q)},[l,ge]),ue=i.useCallback((oe="auto")=>{P.current!=null&&cancelAnimationFrame(P.current),P.current=requestAnimationFrame(()=>{P.current=null,U(oe)})},[U]),ke=i.useCallback(()=>{_.current=!1,I.current=!0,D.current=!0,O.current!=null&&window.clearTimeout(O.current),O.current=window.setTimeout(()=>{I.current=!1,O.current=null},si)},[]);i.useEffect(()=>{const oe=!B.current,q=j.current!==l;if(j.current=l,oe||q){B.current=!0;const Ie=l?Us.get(l):null,Le=!!Ie&&nn(Ie,ge);_.current=Le?nr(Ie):!1,I.current=vm(Ie,ge),F.current||(Le?requestAnimationFrame(()=>{const Me=S.current;Me&&(Kn(Me,Ie),_.current=nr(Ie),Q(),D.current=!0)}):ue("auto")),M.current=Y.length,w.current=ge;return}Y.length>M.current;const Se=ge!==w.current;wm({hasSelection:F.current,userScrolledUp:_.current,hasChatContentChanged:Se})&&ue("auto"),M.current=Y.length,w.current=ge},[ge,l,Y.length,ue,Q]),i.useEffect(()=>{y&&(ke(),F.current||ue("auto"))},[ke,ue,y]),i.useEffect(()=>{const oe=H.current;oe&&!h&&se(),J.current=h,H.current=h;const q=l?Us.get(l):null;if(bm(oe,h,q,ge)){if(!q)return;_.current=nr(q),I.current=!1,F.current||requestAnimationFrame(()=>{const Se=S.current;Se&&(Kn(Se,q),Q())});return}},[h,l,ge,ke,se,ue,Q]),i.useEffect(()=>()=>{const oe=be.current;oe&&Us.set(oe.contextKey,oe.snapshot),P.current!=null&&cancelAnimationFrame(P.current),O.current!=null&&window.clearTimeout(O.current)},[]),i.useEffect(()=>{const oe=v.current,q=S.current;if(!oe||!q)return;const Se=()=>{O.current!=null&&window.clearTimeout(O.current),O.current=window.setTimeout(()=>{I.current=!1,O.current=null},si)},Ie=new ResizeObserver(()=>{Q();const Le=I.current;jm({hasSelection:F.current,userScrolledUp:_.current,contextAutoScrollActive:Le})&&(ue("auto"),Le&&Se())});return Ie.observe(oe),q!==oe&&Ie.observe(q),()=>{Ie.disconnect(),O.current!=null&&(window.clearTimeout(O.current),O.current=null)}},[ue,l,Q]),i.useImperativeHandle(T,()=>({scrollToBottom:(oe="smooth")=>{U(oe)}}),[U]),i.useEffect(()=>{const oe=S.current;if(!oe)return;let q;const Se=()=>{se(),clearTimeout(q),q=setTimeout(()=>{_.current=!ce(),Q()},50)};return oe.addEventListener("scroll",Se,{passive:!0}),()=>{oe.removeEventListener("scroll",Se),clearTimeout(q)}},[se,Q]),i.useEffect(()=>(document.addEventListener("selectionchange",pe),()=>document.removeEventListener("selectionchange",pe)),[pe]);const fe=i.useRef(0),ye=i.useRef(!1);i.useEffect(()=>{const oe=S.current;if(!oe||!ye.current||fe.current===0)return;const q=oe.scrollHeight-fe.current;q>0&&(oe.scrollTop=q),Q(),se(),fe.current=0,ye.current=!1},[Y.length,se,Q]),i.useEffect(()=>{if(D.current||!l)return;const oe=Us.get(l),q=S.current;if(!(!oe||!q)){if(!nn(oe,ge)){U("auto"),D.current=!0;return}Kn(q,oe),_.current=nr(oe),Q(),D.current=!0}},[l,ge,Y.length,U,Q]);const ae=()=>{const oe=S.current;oe&&(fe.current=oe.scrollHeight),ye.current=!0,x==null||x()},he=()=>{_.current=!0,le("smooth"),se()},ie=()=>{ke(),U("smooth"),se()},me=i.useMemo(()=>{const oe=Y.map((Le,Me)=>({type:"message",data:Le,index:Me,ts:km(Le,Me,d)}));if(!r||r.length===0)return oe;const q=[...r].sort((Le,Me)=>Le.timestamp-Me.timestamp).map((Le,Me)=>({type:"action",data:Le,index:Me,ts:Le.timestamp})),Se=[];let Ie=0;for(const Le of oe){for(;Ie<q.length&&Le.ts>0&&q[Ie].ts<Le.ts;)Se.push(q[Ie++]);Se.push(Le)}for(;Ie<q.length;)Se.push(q[Ie++]);return Se},[Y,r,d]),Z=f>0||!!b,ve=f>0?`↑ Show ${Math.min(f,80)} earlier messages${f>80?` (${f} hidden)`:""}`:g?`↻ ${g}`:"↑ Load older messages";return s.jsxs("div",{className:"chat-scroll-frame",children:[s.jsx("div",{ref:S,"data-chat-scroll":!0,className:"chat-container",children:s.jsxs("div",{ref:v,className:"chat-container-content",children:[k&&s.jsx("div",{className:"text-center py-3 text-text-muted text-xs opacity-60 animate-pulse",children:"Loading older messages..."}),Z&&!k&&s.jsx("div",{className:"text-center py-2",children:s.jsx("button",{type:"button",onClick:ae,className:`text-[11px] rounded-xl px-4 py-1.5 cursor-pointer border transition-all ${g&&f===0?"bg-transparent border-yellow-500/30 text-yellow-400 opacity-80 hover:opacity-100":"bg-transparent border-border-subtle text-text-muted opacity-70 hover:opacity-100 hover:border-accent/40"}`,children:ve})}),me.length===0&&!Z&&(p||s.jsx("div",{className:"text-center mt-16 opacity-20 text-[13px]",children:"Waiting for messages..."})),me.map(oe=>{if(oe.type==="action"){const Ce=oe.data;return s.jsx(Nm,{log:Ce},`action-${oe.index}`)}const q=oe.data,Se=oe.index,Ie=an(q,Se),Le=q.receivedAt||d[Ie],Me=`${l}-${Ie}`,$=L.has(Me);return s.jsx(Cm,{message:q,receivedAt:Le,agentName:n,userName:a,isCliMode:o,isTextExpanded:$,onToggleTextExpanded:()=>C(Ce=>{const Pe=new Set(Ce);return $?Pe.delete(Me):Pe.add(Me),Pe})},`msg-${Ie}`)}),c&&s.jsx("div",{className:"self-start chat-typing-wrapper",children:s.jsxs("div",{className:"typing-indicator",children:[s.jsx("div",{className:"dot"}),s.jsx("div",{className:"dot"}),s.jsx("div",{className:"dot"}),s.jsx("span",{className:"text-[11px] text-text-muted ml-1",children:"Agent generating..."})]})}),s.jsx("div",{className:"min-h-10",ref:A})]})}),(N.showTop||N.showBottom)&&s.jsxs("div",{className:"chat-scroll-jump-controls","aria-label":"Chat scroll shortcuts",children:[N.showTop&&s.jsx("button",{type:"button",className:"chat-scroll-jump-button",onClick:he,"aria-label":"Jump to oldest messages",title:"Jump to top",children:"↑ Top"}),N.showBottom&&s.jsx("button",{type:"button",className:"chat-scroll-jump-button chat-scroll-jump-button-primary",onClick:ie,"aria-label":"Jump to latest messages",title:"Jump to bottom",children:"↓ Latest"})]})]})}),Im=i.memo(Tm,(e,t)=>e.messages===t.messages&&e.actionLogs===t.actionLogs&&e.agentName===t.agentName&&e.userName===t.userName&&e.isCliMode===t.isCliMode&&e.isWorking===t.isWorking&&e.contextKey===t.contextKey&&e.receivedAtMap===t.receivedAtMap&&e.lastMessageHash===t.lastMessageHash&&e.showActivityMessages===t.showActivityMessages&&e.emptyState===t.emptyState&&e.onLoadMore===t.onLoadMore&&e.isLoadingMore===t.isLoadingMore&&e.hasMoreHistory===t.hasMoreHistory&&e.hiddenLiveCount===t.hiddenLiveCount&&e.loadError===t.loadError&&e.scrollToBottomRequestNonce===t.scrollToBottomRequestNonce&&e.isVisible===t.isVisible),Am="modulepreload",Mm=function(e){return"/"+e},ni={},Rm=function(t,r,n){let a=Promise.resolve();if(r&&r.length>0){document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),l=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));a=Promise.allSettled(r.map(d=>{if(d=Mm(d),d in ni)return;ni[d]=!0;const m=d.endsWith(".css"),u=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${u}`))return;const p=document.createElement("link");if(p.rel=m?"stylesheet":Am,m||(p.as="script"),p.crossOrigin="",p.href=d,l&&p.setAttribute("nonce",l),document.head.appendChild(p),m)return new Promise((x,k)=>{p.addEventListener("load",x),p.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${d}`)))})}))}function o(c){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=c,window.dispatchEvent(l),!l.defaultPrevented)throw c}return a.then(c=>{for(const l of c||[])l.status==="rejected"&&o(l.reason);return t().catch(o)})};let ai=!1;const Dc=i.forwardRef(({onInput:e,onViewportMetrics:t,onScrollMetrics:r,fontSize:n=13,readOnly:a=!1,sizingMode:o="measured"},c)=>{const l=i.useRef(null),[d,m]=i.useState(null),u=i.useRef([]),p=i.useRef(!1),x=i.useRef(!1),k=i.useRef(!1),b=i.useRef(!1),f=()=>{const g=l.current;if(g){p.current&&(g.clear(),p.current=!1);for(const y of u.current)g.write(y.data,y.onProcessed);u.current=[],x.current&&(g.fit(),x.current=!1),k.current&&(g.bumpResize(),k.current=!1),b.current&&(g.scrollToTop(),b.current=!1)}};return i.useImperativeHandle(c,()=>({write:(g,y)=>{l.current?l.current.write(g,y):u.current.push({data:g,onProcessed:y})},clear:()=>{l.current?l.current.clear():(u.current=[],p.current=!0)},reset:()=>{l.current&&typeof l.current.reset=="function"?l.current.reset():(u.current=[],p.current=!0)},resize:(g,y)=>{l.current&&typeof l.current.resize=="function"&&l.current.resize(g,y)},fit:()=>{l.current?l.current.fit():x.current=!0},bumpResize:()=>{l.current?l.current.bumpResize():k.current=!0},scrollToTop:()=>{l.current?l.current.scrollToTop():b.current=!0},getSelection:()=>{var g,y;return((y=(g=l.current)==null?void 0:g.getSelection)==null?void 0:y.call(g))||""},getVisibleText:()=>{var g,y;return((y=(g=l.current)==null?void 0:g.getVisibleText)==null?void 0:y.call(g))||""}}),[]),i.useEffect(()=>{d&&f()},[d]),i.useEffect(()=>{let g=!1;return Rm(()=>import("./terminal-B-dmfv31.js"),__vite__mapDeps([0,1,2])).then(y=>{ai||(ai=!0,console.info("[CliTerminal] renderer module loaded: terminal-render-web")),g||m(()=>y.GhosttyTerminalView)}).catch(y=>{console.error("[CliTerminal] failed to load terminal renderer",y)}),()=>{g=!0}},[]),d?s.jsx(d,{ref:l,onInput:e,onViewportMetrics:t,onScrollMetrics:r,fontSize:n,readOnly:a,sizingMode:o,className:"w-full h-full rounded-lg overflow-hidden"}):s.jsx("div",{className:"w-full h-full rounded-lg overflow-hidden animate-pulse",style:{background:"#0f1117"}})});Dc.displayName="CliTerminal";function Rr({label:e,value:t,sub:r,icon:n}){return s.jsxs("div",{className:"px-4 py-3.5 rounded-xl bg-bg-secondary border border-border-subtle",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[s.jsx("span",{className:"text-base flex items-center",children:n}),s.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wide font-semibold",children:e})]}),s.jsx("div",{className:"text-[22px] font-bold text-text-primary tracking-tight",children:t}),r&&s.jsx("div",{className:"text-[11px] text-text-muted mt-0.5",children:r})]})}function oi({value:e,max:t,label:r,color:n="#8b5cf6",detail:a,compact:o=!1}){const c=t>0?Math.min(Math.round(e/t*100),100):0,l=c>85?"#ef4444":c>60?"var(--status-warning)":n;return o?s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex justify-between mb-0.5",children:[s.jsx("span",{className:"text-[9px] text-text-muted uppercase tracking-wide font-semibold",children:r}),s.jsxs("span",{className:"text-[10px] text-text-secondary font-semibold",children:[c,"%"]})]}),s.jsx("div",{className:"h-1 bg-white/[0.04] rounded-sm overflow-hidden",children:s.jsx("div",{className:"h-full rounded-sm transition-[width] duration-500",style:{width:`${c}%`,background:l}})})]}):s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex justify-between mb-1.5",children:[s.jsx("span",{className:"text-[11px] text-text-secondary font-medium",children:r}),s.jsxs("span",{className:"text-[13px] text-text-primary font-bold",children:[c,"%"]})]}),s.jsx("div",{className:"h-1.5 bg-white/[0.04] rounded-sm overflow-hidden",children:s.jsx("div",{className:"h-full rounded-sm transition-[width] duration-[600ms]",style:{width:`${c}%`,background:`linear-gradient(90deg, ${l}, ${l}cc)`}})}),a&&s.jsx("div",{className:"text-[10px] text-text-muted mt-0.5",children:a})]})}function Lm({cursorPos:e,viewportRef:t,imgRef:r}){var h;if(!e||!r.current)return null;const n=r.current,a=n.getBoundingClientRect(),o=(h=t.current)==null?void 0:h.getBoundingClientRect();if(!o)return null;const c=n.naturalWidth||a.width,l=n.naturalHeight||a.height,d=c/l,m=a.width/a.height;let u,p,x,k;d>m?(u=a.width,p=a.width/d,x=0,k=(a.height-p)/2):(p=a.height,u=a.height*d,x=(a.width-u)/2,k=0);const b=a.left-o.left+x+u*e.nx,f=a.top-o.top+k+p*e.ny,g=Math.max(8,Math.min(o.width-8,b)),y=Math.max(8,Math.min(o.height-8,f));return s.jsxs("div",{style:{position:"absolute",left:g-8,top:y-8,width:16,height:16,pointerEvents:"none",zIndex:100},children:[s.jsx("div",{style:{position:"absolute",left:7,top:0,width:2,height:16,background:"rgba(59,130,246,0.8)"}}),s.jsx("div",{style:{position:"absolute",left:0,top:7,width:16,height:2,background:"rgba(59,130,246,0.8)"}}),s.jsx("div",{style:{position:"absolute",left:5,top:5,width:6,height:6,borderRadius:"50%",background:"#3b82f6",boxShadow:"0 0 8px rgba(59,130,246,0.6)"}})]})}function Pm({inputMode:e,onToggleInputMode:t,isImeOpen:r,setIsImeOpen:n,isMenuOpen:a,setIsMenuOpen:o,imeText:c,setImeText:l,handleImeSubmit:d,isConnActive:m,zoom:u,isMobile:p,mobileFillZoom:x,onZoomOut:k,onZoomReset:b,onZoomIn:f,transportType:g,screenshotUsage:y,lastActionStatus:h}){return s.jsxs(s.Fragment,{children:[s.jsxs("div",{onTouchStart:T=>T.stopPropagation(),className:"absolute bottom-0 left-0 right-0 z-20 flex items-center justify-center gap-1.5 px-3 py-2 bg-black/75 backdrop-blur-xl border-t border-white/[0.08] touch-none",children:[s.jsxs("div",{onClick:t,className:`h-8 px-2.5 rounded-lg flex items-center gap-[5px] cursor-pointer ${e==="mouse"?"bg-blue-500/25 border border-blue-500/40":"bg-white/[0.08] border border-white/10"}`,children:[s.jsx("span",{className:"text-sm",children:e==="mouse"?"🖱️":"👆"}),s.jsx("span",{className:`text-[10px] font-bold ${e==="mouse"?"text-blue-400":"text-slate-400"}`,children:e==="mouse"?"Mouse":"Touch"})]}),s.jsxs("div",{className:"relative",children:[s.jsx("div",{onClick:()=>{n(T=>!T),o(!1)},className:`w-8 h-8 rounded-lg flex items-center justify-center cursor-pointer ${r?"bg-emerald-500/25 border border-emerald-500/40":"bg-white/[0.08] border border-white/10"}`,children:s.jsx("span",{className:"text-sm",children:"⌨️"})}),r&&s.jsx("div",{className:"absolute bottom-10 left-1/2 -translate-x-1/2 w-[220px] bg-neutral-950/[0.98] backdrop-blur-[30px] rounded-xl border border-white/20 p-[10px_12px] shadow-[0_10px_30px_rgba(0,0,0,0.8)] flex flex-col gap-2 z-20",style:{animation:"slideUp 0.15s ease-out"},children:s.jsx("input",{type:"text",placeholder:"Type & Enter...",value:c,autoFocus:!0,onTouchStart:T=>T.stopPropagation(),onChange:T=>l(T.target.value),onKeyDown:T=>{d(T)},className:"w-full bg-black/60 border border-white/15 rounded-lg px-2.5 py-2 text-white text-[13px] outline-none"})})]}),s.jsx("div",{className:"relative",children:s.jsx("div",{onClick:()=>{o(T=>!T),n(!1)},className:`w-8 h-8 rounded-lg flex items-center justify-center cursor-pointer ${a?"bg-blue-500/25 border border-blue-500/40":"bg-white/[0.08] border border-white/10"}`,children:s.jsx("span",{className:"text-sm",children:"⚙️"})})}),s.jsx("div",{className:"w-px h-[18px] bg-white/10"}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsxs("div",{className:"flex items-center gap-0.5 px-1.5 py-0.5 rounded-md",style:{background:m?"rgba(34,197,94,0.12)":"rgba(234,179,8,0.12)"},children:[s.jsx("div",{className:"w-1 h-1 rounded-full",style:{background:m?"#22c55e":"#eab308",boxShadow:m?"0 0 4px #22c55e80":"0 0 4px #eab30880"}}),s.jsx("span",{className:"text-[8px] font-extrabold",style:{color:m?"#22c55e":"#eab308"},children:m?"Connected":"WS"})]}),u>1&&s.jsxs("span",{className:"text-[8px] font-bold text-indigo-400",children:[Math.round(u*100),"%"]}),g==="direct"&&s.jsx("span",{className:"text-[8px] font-bold px-1 py-0.5 rounded",style:{color:"#22c55e",background:"rgba(34,197,94,0.12)"},title:"Direct P2P connection",children:"Direct"}),g==="relay"&&s.jsx("span",{className:"text-[8px] font-bold px-1 py-0.5 rounded",style:{color:"var(--status-warning)",background:"color-mix(in srgb, var(--status-warning) 12%, transparent)"},title:"TURN relay in use",children:"Relay"}),y&&y.dailyBudgetMinutes>0&&s.jsx("span",{className:"text-[8px] font-bold px-1 py-0.5 rounded",style:{color:y.budgetExhausted?"#ef4444":"#c4b5fd",background:y.budgetExhausted?"rgba(239,68,68,0.1)":"rgba(139,92,246,0.14)"},title:"Daily TURN relay usage",children:y.budgetExhausted?"TURN blocked":`TURN ${y.dailyUsedMinutes}/${y.dailyBudgetMinutes}m`}),h&&s.jsx("span",{className:"text-[8px] text-neutral-500 font-semibold max-w-[100px] overflow-hidden text-ellipsis whitespace-nowrap",children:h})]})]}),a&&s.jsxs("div",{onTouchStart:T=>T.stopPropagation(),style:{position:"absolute",bottom:56,left:"50%",transform:"translateX(-50%)",width:220,background:"rgba(23, 23, 23, 0.95)",backdropFilter:"blur(25px)",borderRadius:14,border:"1px solid rgba(255,255,255,0.1)",padding:14,boxShadow:"0 12px 40px rgba(0,0,0,0.6)",display:"flex",flexDirection:"column",gap:12,zIndex:20,touchAction:"none",animation:"slideUpSidebar 0.15s ease-out"},children:[s.jsx("div",{style:{fontSize:9,fontWeight:900,color:"#3b82f6",letterSpacing:1.5},children:"SETTINGS"}),s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[s.jsxs("div",{style:{fontSize:10,color:"#888",fontWeight:700},children:["ZOOM: ",u<=(p?x:1)+.01?p?"FILL":"FIT":`${Math.round(u*100)}%`]}),s.jsxs("div",{style:{display:"flex",gap:4},children:[s.jsx("button",{onClick:T=>{T.stopPropagation(),k()},style:{flex:1,background:"rgba(255,255,255,0.1)",color:"#fff",border:"none",padding:"6px",borderRadius:6,fontSize:12,fontWeight:800,cursor:"pointer"},children:"−"}),s.jsx("button",{onClick:T=>{T.stopPropagation(),b()},style:{flex:1,background:"rgba(255,255,255,0.1)",color:"#fff",border:"none",padding:"6px",borderRadius:6,fontSize:9,fontWeight:800,cursor:"pointer"},children:p?"FILL":"FIT"}),s.jsx("button",{onClick:T=>{T.stopPropagation(),f()},style:{flex:1,background:"rgba(255,255,255,0.1)",color:"#fff",border:"none",padding:"6px",borderRadius:6,fontSize:12,fontWeight:800,cursor:"pointer"},children:"+"})]})]})]})]})}function _m({waitingLabel:e,waitingHint:t,transportType:r}){return s.jsxs("div",{className:"text-center flex flex-col items-center gap-3 px-6",children:[s.jsx("div",{className:"w-14 h-14 rounded-2xl flex items-center justify-center border border-white/10 bg-white/[0.04] shadow-[0_10px_30px_rgba(0,0,0,0.35)]",style:{animation:"remote-float 2.8s ease-in-out infinite"},children:s.jsx("img",{src:"/otter-logo.png",alt:"",className:"w-8 h-8 opacity-90"})}),s.jsx("div",{className:"text-white/85 text-[13px] font-semibold tracking-wide",children:e}),s.jsx("div",{className:"text-[11px] text-white/40",children:t}),r==="relay"&&s.jsx("div",{className:"text-[10px] font-medium",style:{color:"var(--status-warning)",opacity:.8},children:"TURN relay active"})]})}function Dm(){if(typeof window>"u")return!1;try{return window.__ADHDEV_DEBUG_RENDERS__===!0||window.localStorage.getItem("adhdev_debug_renders")==="1"}catch{return window.__ADHDEV_DEBUG_RENDERS__===!0}}function ii(e){return e==null||typeof e=="number"||typeof e=="boolean"?e:typeof e=="string"?e.length>64?`${e.slice(0,61)}...`:e:Array.isArray(e)?`Array(${e.length})`:typeof e=="object"?"Object":typeof e}function yr(e,t){const r=i.useRef(null),n=i.useRef(0);i.useEffect(()=>{if(!Dm())return;n.current+=1;const a=r.current;if(!a){console.debug(`[render-trace] ${e}#${n.current}`,{changed:["mount"],snapshot:Object.fromEntries(Object.entries(t).map(([c,l])=>[c,ii(l)]))}),r.current=t;return}const o=Object.keys({...a,...t}).filter(c=>!Object.is(a[c],t[c]));o.length>0&&console.debug(`[render-trace] ${e}#${n.current}`,{changed:o,snapshot:Object.fromEntries(o.map(c=>[c,ii(t[c])]))}),r.current=t})}function Em({containerRef:e,viewportRef:t,imgRef:r,inputMode:n,setInputMode:a,minZoom:o,zoomRef:c,panXRef:l,panYRef:d,setPanX:m,setPanY:u,setZoom:p,lastWheelTimeRef:x,onAction:k,setLastActionStatus:b,spawnRippleFromNormalized:f,clampPan:g,isMobile:y,mobileFillZoom:h}){const[T,S]=i.useState(null),v=i.useRef(null),A=i.useRef(null),M=i.useRef(null),w=i.useRef(!1),j=i.useRef(null),B=i.useRef(0),P=i.useRef(null),I=i.useRef(1),O=i.useRef({x:0,y:0}),F=i.useRef(!1),L=i.useRef(n),C=i.useRef(k),N=30,K=550,_=18,D=60,H=400,J=12,be=()=>{if(v.current)return;const U={nx:.5,ny:.5};v.current=U,S(U)};return i.useEffect(()=>{L.current=n,n==="mouse"&&be()},[n]),i.useEffect(()=>{C.current=k},[k]),i.useEffect(()=>{const U=e.current;if(!U)return;const le=ue=>{if(!r.current)return null;const ke=r.current.getBoundingClientRect();return!ke.width||!ke.height?null:{nx:Math.max(0,Math.min(1,(ue.clientX-ke.left)/ke.width)),ny:Math.max(0,Math.min(1,(ue.clientY-ke.top)/ke.height))}},pe=(ue,ke)=>{if(!r.current)return{dnx:0,dny:0};const fe=r.current,ye=fe.getBoundingClientRect(),ae=fe.naturalWidth||ye.width,he=fe.naturalHeight||ye.height,ie=ae/he,me=ye.width/ye.height;let Z,ve;return ie>me?(Z=ye.width,ve=ye.width/ie):(ve=ye.height,Z=ye.height*ie),{dnx:ue/Z,dny:ke/ve}},Y=(ue,ke,fe)=>{if(fe<=1.05)return;const ye=-(ue-.5)*100,ae=-(ke-.5)*100,he=g(ye,ae,fe);(Math.abs(he.x-l.current)>.1||Math.abs(he.y-d.current)>.1)&&(m(he.x),u(he.y),l.current=he.x,d.current=he.y)},de=ue=>{const ke=t.current;if(ke&&ue.target instanceof Node&&ke.contains(ue.target))ue.preventDefault();else return;if(ue.touches.length===1){const fe=ue.touches[0];A.current={x:fe.clientX,y:fe.clientY,time:Date.now()},M.current={x:fe.clientX,y:fe.clientY},F.current||(w.current=!1),j.current=setTimeout(()=>{if(!w.current&&!F.current)if(w.current=!0,L.current==="mouse"){const ye=v.current||{nx:.5,ny:.5};b("Right Click"),f(ye.nx,ye.ny,"right"),C.current("input_click",{...ye,button:"right"}).catch(()=>{})}else{const ye=le(fe);ye&&(b("Right Click"),f(ye.nx,ye.ny,"right"),C.current("input_click",{...ye,button:"right"}).catch(()=>{}))}},500);return}if(ue.touches.length===2){j.current&&clearTimeout(j.current),w.current=!0,F.current=!0;const fe=ue.touches[1].clientX-ue.touches[0].clientX,ye=ue.touches[1].clientY-ue.touches[0].clientY;P.current=Math.sqrt(fe*fe+ye*ye),I.current=c.current,O.current={x:(ue.touches[0].clientX+ue.touches[1].clientX)/2,y:(ue.touches[0].clientY+ue.touches[1].clientY)/2}}},ge=ue=>{const ke=t.current;if(ke&&ue.target instanceof Node&&ke.contains(ue.target)&&ue.preventDefault(),ue.touches.length===1&&M.current){const fe=ue.touches[0],ye=fe.clientX-M.current.x,ae=fe.clientY-M.current.y;if(!w.current&&A.current){const he=fe.clientX-A.current.x,ie=fe.clientY-A.current.y;Math.sqrt(he*he+ie*ie)>8&&(w.current=!0,j.current&&clearTimeout(j.current))}if(w.current)if(L.current==="mouse"){const he=pe(ye,ae),ie=v.current||{nx:.5,ny:.5},me=Math.max(0,Math.min(1,ie.nx+he.dnx)),Z=Math.max(0,Math.min(1,ie.ny+he.dny));v.current={nx:me,ny:Z},S({nx:me,ny:Z}),b(`Cursor: ${Math.round(me*100)}%, ${Math.round(Z*100)}%`),Y(me,Z,c.current);const ve=Date.now();ve-x.current>=30&&(x.current=ve,C.current("input_mouseMoved",{nx:me,ny:Z}).catch(()=>{}))}else if(c.current>1){const he=t.current;if(he){const ie=he.clientWidth,me=he.clientHeight,Z=l.current+ye/ie*100,ve=d.current+ae/me*100,oe=g(Z,ve,c.current);m(oe.x),u(oe.y),l.current=oe.x,d.current=oe.y}}else{const he=le(fe);if(he){const ie=Date.now();ie-x.current>=40&&(x.current=ie,b("Scroll"),C.current("input_wheel",{nx:he.nx,ny:he.ny,deltaX:Math.round(-ye*2.5),deltaY:Math.round(-ae*2.5)}).catch(()=>{}))}}M.current={x:fe.clientX,y:fe.clientY};return}if(ue.touches.length===2&&P.current!==null){const fe=ue.touches[1].clientX-ue.touches[0].clientX,ye=ue.touches[1].clientY-ue.touches[0].clientY,he=Math.sqrt(fe*fe+ye*ye)/P.current,ie=(ue.touches[0].clientX+ue.touches[1].clientX)/2,me=(ue.touches[0].clientY+ue.touches[1].clientY)/2,Z=ie-O.current.x,ve=me-O.current.y,oe=Math.abs(he-1)>.03;if(L.current==="mouse"){if(oe){const q=Math.max(o,Math.min(5,I.current*he));p(q),c.current=q}else if(Math.abs(Z)>2||Math.abs(ve)>2){const q=v.current||{nx:.5,ny:.5},Se=Date.now();Se-x.current>=30&&(x.current=Se,b("Scroll"),C.current("input_wheel",{nx:q.nx,ny:q.ny,deltaX:Math.round(-Z*3),deltaY:Math.round(-ve*3)}).catch(()=>{}))}}else{const q=Math.max(o,Math.min(5,I.current*he));p(q),c.current=q;const Se=t.current;if(Se&&q>1){const Ie=Se.clientWidth,Le=Se.clientHeight,Me=l.current+Z/Ie*100,$=d.current+ve/Le*100,Ce=g(Me,$,q);m(Ce.x),u(Ce.y),l.current=Ce.x,d.current=Ce.y}}O.current={x:ie,y:me}}},se=ue=>{var ke;if(j.current&&clearTimeout(j.current),P.current=null,ue.touches.length===1&&F.current){const fe=ue.touches[0];A.current={x:fe.clientX,y:fe.clientY,time:Date.now()},M.current={x:fe.clientX,y:fe.clientY},w.current=!0;return}if(ue.touches.length===0){if(F.current){F.current=!1,w.current=!1;return}if(ue.changedTouches.length===1){const fe=ue.changedTouches[0],ye=Date.now(),ae=ye-(((ke=A.current)==null?void 0:ke.time)||0),he=A.current?fe.clientX-A.current.x:0,ie=A.current?fe.clientY-A.current.y:0,me=Math.sqrt(he*he+ie*ie);if(L.current==="mouse"){if(ae<N||ae>K||me>_){w.current=!1;return}const Z=v.current||le(fe);Z&&(b(`Click: ${Math.round(Z.nx*100)}%, ${Math.round(Z.ny*100)}%`),f(Z.nx,Z.ny,"left"),C.current("input_click",{...Z}).catch(()=>{}))}else{if(w.current){w.current=!1;return}if(ae<D||ae>H||me>J){w.current=!1;return}const Z=le(fe);if(!Z)return;ye-B.current<300?(b("Double tap"),f(Z.nx,Z.ny,"double"),C.current("input_click",{...Z,clickCount:2}).catch(()=>{}),B.current=0):(b(`Tap: ${Math.round(Z.nx*100)}%, ${Math.round(Z.ny*100)}%`),f(Z.nx,Z.ny,"left"),C.current("input_click",{...Z}).catch(()=>{}),B.current=ye)}}w.current=!1}};return U.addEventListener("touchstart",de,{passive:!1}),U.addEventListener("touchmove",ge,{passive:!1}),U.addEventListener("touchend",se,{passive:!1}),()=>{U.removeEventListener("touchstart",de),U.removeEventListener("touchmove",ge),U.removeEventListener("touchend",se),j.current&&clearTimeout(j.current)}},[e,t,r,o,c,l,d,m,u,p,x,b,f,g]),{cursorPos:T,cursorPosRef:v,handleToggleInputMode:()=>{a(U=>{const le=U==="touch"?"mouse":"touch";return le==="mouse"&&be(),le})},handleZoomReset:()=>{const U=y?h:1;p(U),c.current=U,m(0),u(0),l.current=0,d.current=0}}}function Ec({onAction:e,addLog:t,connState:r,connScreenshot:n,screenshotUsage:a,transportType:o}){const c=i.useRef(null),l=i.useRef(null),d=i.useRef(null),[m,u]=i.useState(null),[p,x]=i.useState(""),[,k]=i.useState(!1),[b,f]=i.useState([]),g=i.useRef(0),[y,h]=i.useState(!1),[T,S]=i.useState(!1),v=typeof window<"u"&&window.matchMedia("(max-width: 768px)").matches,[A,M]=i.useState(v?"mouse":"touch"),[w,j]=i.useState(1),B=i.useRef(!1),[P,I]=i.useState(1),[O,F]=i.useState(0),[L,C]=i.useState(0);yr("RemoteView",{connState:r,hasScreenshot:!!n,inputMode:A,zoom:P,panX:O,panY:L,isMenuOpen:y,isImeOpen:T});const N=i.useRef(0),K=i.useRef(P),_=i.useRef(O),D=i.useRef(L);i.useEffect(()=>{K.current=P},[P]),i.useEffect(()=>{_.current=O},[O]),i.useEffect(()=>{D.current=L},[L]),i.useEffect(()=>{var ae;(ae=c.current)==null||ae.focus()},[]);const H=r==="connected",J=n,be=H?"Connected. Waiting for first frame...":r==="connecting"?"Connecting to Host...":"Reconnecting to Host...",ce=H?"The remote stream is warming up":"Waiting for the remote stream to catch up";i.useEffect(()=>{if(!v||B.current||!J)return;const ae=d.current,he=l.current;if(!ae||!he)return;const ie=()=>{const me=he.clientWidth,Z=he.clientHeight,ve=ae.naturalWidth,oe=ae.naturalHeight;if(!ve||!oe||!me||!Z)return;const q=Math.min(me/ve,Z/oe),Ie=Math.max(me/ve,Z/oe)/q;Ie>1.01&&(j(Ie),I(Ie),K.current=Ie),B.current=!0};ae.complete&&ae.naturalWidth?ie():ae.addEventListener("load",ie,{once:!0})},[J,v]);const Q=.5;i.useEffect(()=>{P<=Q&&(F(0),C(0))},[P,Q]);const U=(ae,he,ie)=>{if(ie<=Q)return{x:0,y:0};const me=(ie-1)/(2*ie)*100,Z=(ie-1)/(2*ie)*100;return{x:Math.max(-me,Math.min(me,ae)),y:Math.max(-Z,Math.min(Z,he))}},le=(ae,he)=>{if(!d.current)return null;const ie=d.current.getBoundingClientRect();return!ie.width||!ie.height?null:{nx:Math.max(0,Math.min(1,(ae-ie.left)/ie.width)),ny:Math.max(0,Math.min(1,(he-ie.top)/ie.height))}},pe=(ae,he,ie)=>{const me=l.current;if(!me)return;const Z=me.getBoundingClientRect(),ve=++g.current;f(oe=>[...oe,{id:ve,x:ae-Z.left,y:he-Z.top,type:ie}]),setTimeout(()=>f(oe=>oe.filter(q=>q.id!==ve)),600)},Y=(ae,he,ie)=>{const me=d.current,Z=l.current;if(!me||!Z)return;const ve=me.getBoundingClientRect(),oe=Z.getBoundingClientRect(),q=me.naturalWidth||ve.width,Se=me.naturalHeight||ve.height,Ie=q/Se,Le=ve.width/ve.height;let Me,$,Ce,Pe;Ie>Le?(Me=ve.width,$=ve.width/Ie,Ce=0,Pe=(ve.height-$)/2):($=ve.height,Me=ve.height*Ie,Ce=(ve.width-Me)/2,Pe=0);const Fe=ve.left-oe.left+Ce+Me*ae,He=ve.top-oe.top+Pe+$*he,qe=++g.current;f(Ye=>[...Ye,{id:qe,x:Fe,y:He,type:ie}]),setTimeout(()=>f(Ye=>Ye.filter(tt=>tt.id!==qe)),600)},de=async ae=>{var ie;const he=le(ae.clientX,ae.clientY);if(he){u(`Click: ${Math.round(he.nx*100)}%, ${Math.round(he.ny*100)}%`),pe(ae.clientX,ae.clientY,"left"),(ie=c.current)==null||ie.focus();try{const me=await e("input_click",{nx:he.nx,ny:he.ny});me!=null&&me.success||t(`❌ Click failed: ${me==null?void 0:me.error}`)}catch(me){t(`❌ Click error: ${me.message||me}`)}}},ge=async(ae,he,ie,me=0)=>{try{await e("input_key",{type:ie?"char":"keyDown",key:ae,code:he,text:ie?ae:void 0,unmodifiedText:ie?ae:void 0,modifiers:me})}catch(Z){t(`❌ Key error: ${Z.message||Z}`)}},se=async ae=>{if(ae.target.tagName==="INPUT")return;["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Backspace","Tab","Enter","Escape"].includes(ae.key)&&ae.preventDefault();let ie=0;ae.altKey&&(ie|=1),ae.ctrlKey&&(ie|=2),ae.metaKey&&(ie|=4),ae.shiftKey&&(ie|=8),u(`Key: ${ae.key}`),await ge(ae.key,ae.code,ae.key.length===1,ie)},ue=async ae=>{if(ae.key==="Enter"){if(ae.nativeEvent.isComposing)return;if(p){const he=p;x(""),u(`IME Sent: ${he}`);try{const ie=await e("input_type",{text:he});ie!=null&&ie.success||t(`❌ IME error: ${ie==null?void 0:ie.error}`)}catch(ie){t(`❌ IME error: ${ie.message}`)}}else u("Key: Enter"),await ge("Enter","Enter",!1)}};i.useEffect(()=>{const ae=c.current;if(!ae)return;const he=ie=>{var me;if((me=d.current)!=null&&me.contains(ie.target)){ie.preventDefault();const Z=Date.now();if(Z-N.current<40)return;N.current=Z;const ve=le(ie.clientX,ie.clientY);if(!ve)return;u(`Scroll: ${Math.round(ie.deltaY)}`),e("input_wheel",{nx:ve.nx,ny:ve.ny,deltaX:Math.round(ie.deltaX),deltaY:Math.round(ie.deltaY)}).catch(()=>{})}};return ae.addEventListener("wheel",he,{passive:!1}),()=>ae.removeEventListener("wheel",he)},[e]);const{cursorPos:ke,handleToggleInputMode:fe,handleZoomReset:ye}=Em({containerRef:c,viewportRef:l,imgRef:d,inputMode:A,setInputMode:M,minZoom:Q,zoomRef:K,panXRef:_,panYRef:D,setPanX:F,setPanY:C,setZoom:I,lastWheelTimeRef:N,onAction:e,setLastActionStatus:u,spawnRippleFromNormalized:Y,clampPan:U,isMobile:v,mobileFillZoom:w});return s.jsxs("div",{ref:c,className:"flex-1 flex flex-col bg-black relative overflow-hidden outline-none touch-none",onKeyDown:se,onContextMenu:ae=>ae.preventDefault(),onFocus:()=>k(!0),onBlur:()=>k(!1),tabIndex:0,children:[s.jsxs("div",{ref:l,className:"flex-1 relative overflow-hidden flex items-center justify-center bg-black",children:[J?s.jsx("img",{ref:d,src:J,alt:"Remote View",style:{display:"block",maxWidth:"100%",maxHeight:"100%",width:"auto",height:"auto",transform:`scale(${P}) translate(${O}%, ${L}%)`,transformOrigin:"center center",cursor:A==="mouse"?"default":"crosshair",userSelect:"none",WebkitTouchCallout:"none"},onClick:de,onContextMenu:ae=>ae.preventDefault(),onDragStart:ae=>ae.preventDefault()}):s.jsx(_m,{waitingLabel:be,waitingHint:ce,transportType:o}),A==="mouse"&&J&&s.jsx(Lm,{cursorPos:ke,viewportRef:l,imgRef:d}),b.map(ae=>{const ie={left:"59,130,246",right:"239,68,68",double:"34,197,94"}[ae.type];return s.jsxs("div",{style:{position:"absolute",left:ae.x,top:ae.y,pointerEvents:"none",zIndex:200,transform:"translate(-50%, -50%)"},children:[s.jsx("div",{style:{width:40,height:40,borderRadius:"50%",border:`2px solid rgba(${ie}, 0.8)`,animation:"click-ripple-ring 0.5s ease-out forwards",position:"absolute",left:-20,top:-20}}),s.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:`rgba(${ie}, 0.9)`,boxShadow:`0 0 12px rgba(${ie}, 0.6)`,animation:"click-ripple-dot 0.4s ease-out forwards",position:"absolute",left:-4,top:-4}})]},ae.id)})]}),s.jsx(Pm,{inputMode:A,onToggleInputMode:fe,isImeOpen:T,setIsImeOpen:S,isMenuOpen:y,setIsMenuOpen:h,imeText:p,setImeText:x,handleImeSubmit:ue,isConnActive:H,zoom:P,isMobile:v,mobileFillZoom:w,onZoomOut:()=>I(ae=>Math.max(.5,ae-.25)),onZoomReset:ye,onZoomIn:()=>I(ae=>Math.min(5,ae+.25)),transportType:o,screenshotUsage:a,lastActionStatus:m}),s.jsx("style",{children:`
7
7
  @keyframes slideUp {
8
8
  from { opacity: 0; transform: translateY(6px); }
9
9
  to { opacity: 1; transform: translateY(0); }