@tonyclaw/agent-inspector 3.1.8 → 3.1.9
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/.output/backend/nitro.json +1 -1
- package/.output/cli.js +14 -4
- package/.output/server/_ssr/index.mjs +1 -1
- package/.output/server/_ssr/{router-CHcOqlej.mjs → router-Lc1aOs3g.mjs} +270 -3
- package/.output/server/index.mjs +1 -1
- package/.output/ui/assets/{CompareDrawer-D6p2D3aR.js → CompareDrawer-YdfnAMiC.js} +1 -1
- package/.output/ui/assets/{InspectorPet-DteVBsK4.js → InspectorPet-Bt0vxGL8.js} +1 -1
- package/.output/ui/assets/ProxyViewerContainer-D4_GM20S.js +59 -0
- package/.output/ui/assets/{ReplayDialog-BxfD3Ni8.js → ReplayDialog-9BWotxhQ.js} +1 -1
- package/.output/ui/assets/{RequestAnatomy-Bc-HEy3u.js → RequestAnatomy-0VrsjZmK.js} +1 -1
- package/.output/ui/assets/ResponseView-mmW2Z9sl.js +2 -0
- package/.output/ui/assets/StreamingChunkSequence-ZC90PIBc.js +1 -0
- package/.output/ui/assets/{_sessionId-MXVCdKA6.js → _sessionId-C84un6eF.js} +1 -1
- package/.output/ui/assets/{_sessionId-Dm2fmwl6.js → _sessionId-CB7Eytuo.js} +1 -1
- package/.output/ui/assets/{index-r-7cZ1UL.js → index-2feCKPew.js} +2 -2
- package/.output/ui/assets/{index-aah_H3hN.js → index-7oLdSt17.js} +1 -1
- package/.output/ui/assets/{index-BuF4rMwu.js → index-BswExFrv.js} +1 -1
- package/.output/ui/assets/index-IBEDJoV_.css +1 -0
- package/.output/ui/assets/{index-Dr_GO75d.js → index-YEgoJRUl.js} +1 -1
- package/.output/ui/assets/{json-viewer-Dikr00zS.js → json-viewer-CJ96a0P_.js} +1 -1
- package/.output/ui/assets/{jszip.min-zWpW-aD7.js → jszip.min-BDO1ePnu.js} +1 -1
- package/.output/ui/index.html +2 -2
- package/.output/workers/logFinalizer.worker.js +10 -0
- package/.output/workers/sessionWorkerEntry.js +10 -0
- package/package.json +4 -4
- package/src/components/proxy-viewer/AnswerMarkdown.tsx +37 -7
- package/src/components/proxy-viewer/LogEntry.tsx +82 -32
- package/src/components/proxy-viewer/ResponseView.tsx +33 -3
- package/src/components/proxy-viewer/StreamingChunkSequence.tsx +60 -3
- package/src/components/proxy-viewer/viewerState.ts +11 -169
- package/src/contracts/index.ts +2 -0
- package/src/contracts/log.ts +13 -0
- package/src/lib/toolTrace.ts +290 -0
- package/src/proxy/logIndex.ts +4 -0
- package/src/proxy/schemas.ts +2 -0
- package/src/proxy/sqliteLogIndex.ts +24 -2
- package/src/proxy/store.ts +3 -0
- package/.output/ui/assets/ProxyViewerContainer-Dw723CdA.js +0 -59
- package/.output/ui/assets/ResponseView-Be5xdsIm.js +0 -2
- package/.output/ui/assets/StreamingChunkSequence-Cd5G2xRQ.js +0 -1
- package/.output/ui/assets/index-BvXp42al.css +0 -1
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./jszip.min-zWpW-aD7.js","./index-r-7cZ1UL.js","./index-BvXp42al.css","./CompareDrawer-D6p2D3aR.js","./InspectorPet-DteVBsK4.js","./ReplayDialog-BxfD3Ni8.js","./ResponseView-Be5xdsIm.js","./RequestAnatomy-Bc-HEy3u.js","./StreamingChunkSequence-Cd5G2xRQ.js","./json-viewer-Dikr00zS.js","./index-aah_H3hN.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{l as kh,u as Dt,s as x,n as E,b as ke,_ as Fo,a as V,c as Oe,o as T,d as me,e as oe,f as pn,g as Ms,h as Rt,i as $d,k as Ke,r as l,j as t,m as zt,p as _n,A as Bl,q as _h,t as Jr,v as hr,w as hs,x as O,B as te,y as Pn,z as Fd,C as Re,D as Ud,E as vt,F as ki,G as Th,H as Le,L as Uo,I as Bd,J as Eh,K as Bo,M as Rh,N as Mh,O as Ah,P as qd,Q as _i,T as Ih,U as Ph}from"./index-r-7cZ1UL.js";const He=kh(()=>Dt([x(),E(),ke(),Fo(),V(He),Oe(x(),He)])),It=E().int().nonnegative().max(Number.MAX_SAFE_INTEGER),Lh=me(["capacity-exceeded","pipeline-closed","write-failed","finalize-failed","finalize-timeout","upstream-stream-error","shutdown"]),Hd=T({index:E(),timestamp:E(),type:x(),data:He}),Oh=T({chunks:V(Hd),truncated:ke().optional().default(!1)}),Dh=me(["request","response"]),Wd=T({logId:It,part:Dh,text:x(),offset:E().int().nonnegative(),limit:E().int().positive(),totalBytes:E().int().nonnegative(),textBytes:E().int().nonnegative(),nextOffset:E().int().nonnegative().nullable(),hasMore:ke(),contentMode:me(["empty","partial","full"])}),Os=T({id:It,timestamp:x(),method:x(),path:x(),model:x().nullable(),sessionId:x().nullable(),rawRequestBody:x().nullable(),responseStatus:E().nullable(),responseText:x().nullable(),inputTokens:E().nullable(),outputTokens:E().nullable(),cacheCreationInputTokens:E().nullable(),cacheReadInputTokens:E().nullable(),elapsedMs:E().nullable(),firstChunkMs:E().nullable().optional(),totalStreamMs:E().nullable().optional(),tokensPerSecond:E().nullable().optional(),streaming:ke(),userAgent:x().nullable(),origin:x().nullable(),rawHeaders:Oe(x(),x()).optional(),headers:Oe(x(),x()).optional(),apiFormat:me(["anthropic","openai","unknown"]).default("unknown"),isTest:ke().optional().default(!1),replayOfLogId:It.nullable().optional(),providerName:x().nullable().optional(),clientPort:E().nullable().optional(),clientPid:E().nullable().optional(),clientCwd:x().nullable().optional(),clientProjectFolder:x().nullable().optional(),streamingChunks:Oh.optional(),streamingChunksPath:x().nullable().optional(),rawRequestBodyBytes:E().int().nonnegative().nullable().optional(),responseTextBytes:E().int().nonnegative().nullable().optional(),bodyContentMode:me(["full","compact","truncated"]).optional(),captureIncomplete:ke().optional(),droppedChunks:E().int().nonnegative().optional(),droppedBytes:E().int().nonnegative().optional(),captureIncompleteReason:Lh.nullable().optional(),warnings:V(x()).optional(),error:x().nullable().optional()}),Ti=T({type:x(),ttl:x().optional(),scope:x().optional()}),Ei=T({type:oe("text"),text:x(),cache_control:Ti.optional()}),Vd=T({type:oe("thinking"),thinking:x(),signature:x().optional()}),zh=T({type:oe("think"),thinking:x(),signature:x().optional()}),$h=T({type:oe("base64"),media_type:x(),data:x()}),Kd=T({type:oe("image"),source:$h}),Gd=T({type:oe("tool_use"),id:x(),name:x(),input:Oe(x(),He)}),Fh=pn("type",[Ei,Kd]),Uh=T({type:oe("tool_result"),tool_use_id:x().optional(),content:Dt([x(),V(Fh)]),is_error:ke().optional()}),Bh=pn("type",[Ei,Vd,Kd,Gd,Uh]),qh=Dt([x(),V(Bh)]),Hh=T({role:me(["user","assistant"]),content:qh}),Wh=T({type:oe("text"),text:x(),cache_control:Ti.optional()}),Vh=T({type:x(),properties:Oe(x(),Oe(x(),He)).optional(),required:V(x()).optional(),additionalProperties:ke().optional(),$schema:x().optional()}),Kh=T({name:x(),description:x().optional(),input_schema:Vh.optional(),cache_control:Ti.optional()}),Gh=pn("type",[T({type:oe("enabled"),budget_tokens:E()}),T({type:oe("disabled")}),T({type:oe("adaptive")})]),Yh=T({model:x(),messages:V(Hh),system:V(Wh).optional(),tools:V(Kh).optional(),max_tokens:E().optional(),temperature:E().optional(),stream:ke().optional(),thinking:Gh.optional(),metadata:T({user_id:x().optional()}).optional()}),Ri=pn("type",[Ei,Vd,zh,Gd]),Jh=T({input_tokens:E().nullable().optional(),output_tokens:E().nullable().optional(),cache_creation_input_tokens:E().nullable().optional(),cache_read_input_tokens:E().nullable().optional()}).passthrough(),Xh=T({id:x(),type:oe("message"),model:x(),role:oe("assistant"),content:V(Ri),stop_reason:x().nullable(),stop_sequence:x().nullable().optional(),usage:Jh}).passthrough(),Zh=T({type:oe("message_start"),message:T({id:x(),type:oe("message"),model:x(),role:oe("assistant"),content:V(Ri),stop_reason:Fo(),stop_sequence:Fo(),usage:T({input_tokens:E(),cache_creation_input_tokens:E().optional(),cache_read_input_tokens:E().optional()}).passthrough()})}),Qh=T({type:oe("content_block_start"),index:E(),content_block:Ri}),ex=pn("type",[T({type:oe("text_delta"),text:x()}),T({type:oe("input_json_delta"),partial_json:x()}),T({type:oe("thinking_delta"),thinking:x()}),T({type:oe("signature_delta"),signature:x()})]),tx=T({type:oe("content_block_delta"),index:E(),delta:ex}),nx=T({type:oe("content_block_stop"),index:E()}),sx=T({type:oe("message_delta"),delta:T({stop_reason:x().nullable(),stop_sequence:x().nullable().optional()}),usage:T({output_tokens:E(),input_tokens:E().optional(),cache_creation_input_tokens:E().optional(),cache_read_input_tokens:E().optional()}).passthrough()}),ox=T({type:oe("message_stop")}),rx=T({type:oe("ping")}),ax=T({type:oe("error"),error:T({type:x(),message:x()})});pn("type",[Zh,Qh,tx,nx,sx,ox,rx,ax]);const ix=Dt([x(),V(pn("type",[T({type:oe("text"),text:x()}),T({type:oe("image_url"),image_url:T({url:x(),detail:x().optional()})})]))]),Yd=T({role:me(["system","user","assistant","tool"]),content:ix,name:x().optional(),reasoning_content:x().optional(),thinking:x().optional(),think:x().optional()}),lx=T({name:x(),arguments:x()}),Jd=T({index:E().optional(),id:x().optional(),type:oe("function").optional(),function:T({name:x().optional(),arguments:x().optional()})});Yd.extend({content:Dt([x(),V(T({type:oe("text"),text:x()}))]).optional(),function_call:lx.optional(),tool_calls:V(Jd).optional()});const cx=T({type:oe("function"),function:T({name:x(),description:x().optional(),parameters:Oe(x(),He)})}),dx=T({model:x(),messages:V(Yd),temperature:E().optional(),max_tokens:E().optional(),stream:ke().optional(),tools:V(cx).optional(),tool_choice:Dt([me(["auto","none","required"]),T({type:oe("auto")}),T({type:oe("none")}),T({type:oe("function"),function:T({name:x()})})]).optional(),user:x().optional()}),ux=T({type:x(),name:x().optional(),description:x().optional(),parameters:He.optional(),function:T({name:x().optional(),description:x().optional(),parameters:He.optional()}).optional()}).passthrough(),mx=T({model:x(),input:Ms().optional(),instructions:Dt([x(),Fo()]).optional(),stream:ke().optional(),tools:V(ux).optional(),tool_choice:Ms().optional(),max_output_tokens:E().optional(),temperature:E().optional(),user:x().optional(),metadata:Oe(x(),Ms()).optional()}).passthrough(),Xd=T({role:me(["assistant"]).optional(),content:x().nullable().optional(),reasoning_content:x().nullable().optional(),thinking:x().nullable().optional(),think:x().nullable().optional(),function_call:T({name:x().optional(),arguments:x().optional()}).nullable().optional(),tool_calls:V(T({index:E(),id:x().optional(),type:oe("function").optional(),function:T({name:x().optional(),arguments:x().optional()})})).nullable().optional()}),fx=T({index:E(),message:T({role:me(["assistant"]),content:x().nullable(),reasoning_content:x().optional(),thinking:x().optional(),think:x().optional(),function_call:T({name:x(),arguments:x()}).nullable().optional(),tool_calls:V(Jd).optional()}).optional(),delta:Xd.optional(),finish_reason:x().nullable()}),px=T({id:x(),object:oe("chat.completion"),created:E(),model:x(),choices:V(fx),usage:T({prompt_tokens:E().nullable().optional(),completion_tokens:E().nullable().optional(),total_tokens:E().nullable().optional()}).passthrough(),service_tier:x().nullable().optional(),system_fingerprint:x().nullable().optional()}).passthrough();T({id:x(),object:oe("chat.completion.chunk"),created:E(),model:x(),choices:V(T({index:E(),delta:Xd,finish_reason:x().nullable().optional()})),usage:T({prompt_tokens:E().nullable().optional(),completion_tokens:E().nullable().optional(),total_tokens:E().nullable().optional()}).passthrough().nullable().optional()}).passthrough();const hx=T({input_tokens:E().nullable().optional(),output_tokens:E().nullable().optional(),total_tokens:E().nullable().optional(),input_tokens_details:T({cached_tokens:E().nullable().optional()}).passthrough().nullable().optional(),output_tokens_details:T({reasoning_tokens:E().nullable().optional()}).passthrough().nullable().optional()}).passthrough(),xx=T({type:x()}).passthrough(),gx=T({id:x(),object:oe("response").optional(),created_at:E().optional(),status:x().nullable().optional(),model:x().optional(),output:V(xx).optional(),output_text:x().optional(),usage:hx.nullable().optional(),error:Ms().optional()}).passthrough();T({type:x()}).passthrough();function bx(e){try{const n=JSON.parse(e),s=px.safeParse(n);return s.success?s.data:null}catch{return null}}function vx(e){try{const n=JSON.parse(e),s=gx.safeParse(n);return s.success?s.data:null}catch{return null}}const Zd=T({input:E().int().nonnegative(),output:E().int().nonnegative(),cacheCreate:E().int().nonnegative(),cacheRead:E().int().nonnegative(),total:E().int().nonnegative()}),yx=T({id:It,sessionLogNumber:E().int().positive().optional(),timestamp:x(),provider:x().nullable(),model:x().nullable(),apiFormat:me(["anthropic","openai","unknown"]),method:x(),path:x(),status:E().nullable(),isStreaming:ke(),hasError:ke(),error:x().nullable(),latencyMs:E().nullable(),firstChunkMs:E().nullable().optional(),totalStreamMs:E().nullable().optional(),tokensPerSecond:E().nullable().optional(),tokens:T({input:E().nullable(),output:E().nullable(),cacheCreate:E().nullable(),cacheRead:E().nullable()}),sessionId:x().nullable(),userAgent:x().nullable().optional(),clientPid:E().nullable().optional(),clientProjectFolder:x().nullable().optional()}),Qd=T({id:x(),status:me(["active","failed","completed","empty"]),logCoverage:me(["recent","history"]),source:me(["explicit","client-process","client-connection","provider-test"]).nullable(),runtimeMode:me(["in-process","worker-thread","child-process"]).nullable(),createdAt:x().nullable(),updatedAt:x().nullable(),requestCount:E().int().nonnegative(),activeRequests:E().int().nonnegative(),completedRequests:E().int().nonnegative(),failedRequests:E().int().nonnegative(),queuedTasks:E().int().nonnegative(),runningTasks:E().int().nonnegative(),lastTaskError:x().nullable(),logCount:E().int().nonnegative(),errorCount:E().int().nonnegative(),models:V(x()),providers:V(x()),tokenUsage:Zd,lastLogId:It.nullable(),lastModel:x().nullable(),clientUserAgent:x().nullable().optional(),clientPid:E().nullable(),clientProjectFolder:x().nullable(),inspectorPath:x(),inspectorUrl:x(),apiPath:x(),apiUrl:x(),compactLogsPath:x(),compactLogsUrl:x(),latestLogLimit:E().int().positive(),latestLogs:V(yx)}),Vs=me(["created","running","completed","failed","cancelled"]),Mi=T({jsonPath:x(),markdownPath:x(),htmlPath:x(),exportedAt:x()}),wx=me(["run-created","session-started","request","session-finished","evidence-exported"]),jx=me(["info","success","warning","error"]),Sx=T({timestamp:x(),kind:wx,severity:jx,title:x(),details:x(),logId:It.nullable(),status:E().nullable(),model:x().nullable(),provider:x().nullable(),latencyMs:E().nullable(),isStreaming:ke().nullable()}),Nx=me(["none","active","provider-timeout","provider-http-error","provider-auth-error","provider-rate-limit","network-or-container","streaming-mismatch","context-pressure","runtime-task-error","model-output-error","unknown-failure","no-session-data"]),eu=T({outcome:me(["success","failure","active","unknown"]),severity:me(["none","low","medium","high"]),category:Nx,summary:x(),evidenceLogIds:V(It),hints:V(x())}),Ai=T({status:me(["PASS","FAIL","RUNNING","UNKNOWN"]),summary:x(),markdown:x()}),tu=Ai,Ii=T({id:x(),sessionId:x(),groupId:x().nullable().default(null),title:x(),task:x().nullable(),project:x().nullable(),agent:x().nullable(),status:Vs,tags:V(x()),metadata:Oe(x(),He),evidence:Mi.nullable(),createdAt:x(),updatedAt:x()});T({runId:x().min(1).optional(),sessionId:x().min(1).optional(),groupId:x().min(1).nullable().optional(),title:x().min(1).optional(),task:x().nullable().optional(),project:x().nullable().optional(),agent:x().nullable().optional(),status:Vs.optional(),tags:V(x()).optional(),metadata:Oe(x(),He).optional()}).optional();T({sessionId:x().min(1).optional(),groupId:x().min(1).nullable().optional(),title:x().min(1).optional(),task:x().nullable().optional(),project:x().nullable().optional(),agent:x().nullable().optional(),status:Vs.optional(),tags:V(x()).optional(),metadata:Oe(x(),He).optional()});T({includeHistory:ke().optional(),latestLogLimit:E().int().positive().max(50).optional()}).optional();T({run:Ii,evidence:Mi,session:Qd.nullable(),timeline:V(Sx),classification:eu,jenkinsReport:Ai});const Cx=T({run:Ii,classification:eu,evidence:Mi.nullable(),jenkinsReport:Ai.nullable(),sessionId:x(),inspectorUrl:x().nullable(),evidenceMarkdownPath:x().nullable(),updatedAt:x()});T({failures:V(Cx),total:E().int().nonnegative(),limit:E().int().positive()});const Pi=me(["created","running","completed","failed","cancelled"]),Li=me(["evaluation","batch","manual"]),Oi=T({jsonPath:x(),markdownPath:x(),htmlPath:x(),exportedAt:x()}),nu=T({id:x(),groupId:x(),sessionId:x(),runId:x().nullable(),label:x().nullable(),agent:x().nullable(),provider:x().nullable(),model:x().nullable(),status:Vs.nullable(),metadata:Oe(x(),He),addedAt:x(),updatedAt:x()}),Di=T({id:x(),title:x(),kind:Li,task:x().nullable(),project:x().nullable(),status:Pi,tags:V(x()),metadata:Oe(x(),He),evidence:Oi.nullable(),members:V(nu),createdAt:x(),updatedAt:x()});T({groupId:x().min(1).optional(),title:x().min(1).optional(),kind:Li.optional(),task:x().nullable().optional(),project:x().nullable().optional(),status:Pi.optional(),tags:V(x()).optional(),metadata:Oe(x(),He).optional()}).optional();T({title:x().min(1).optional(),kind:Li.optional(),task:x().nullable().optional(),project:x().nullable().optional(),status:Pi.optional(),tags:V(x()).optional(),metadata:Oe(x(),He).optional()});T({memberId:x().min(1).optional(),sessionId:x().min(1),runId:x().min(1).nullable().optional(),label:x().min(1).nullable().optional(),agent:x().min(1).nullable().optional(),provider:x().min(1).nullable().optional(),model:x().min(1).nullable().optional(),status:Vs.nullable().optional(),metadata:Oe(x(),He).optional()});T({includeHistory:ke().optional(),latestLogLimit:E().int().positive().max(50).optional()}).optional();T({deleteEvidence:ke().optional()});const su=T({groupId:x(),deleted:ke(),evidenceDeleted:ke(),evidencePath:x().nullable()}),ou=T({deleted:E().int().nonnegative(),groups:V(su)}),ru=T({member:nu,run:Ii.nullable(),session:Qd.nullable()}),au=T({memberCount:E().int().nonnegative(),sessionsWithData:E().int().nonnegative(),missingSessions:E().int().nonnegative(),requestCount:E().int().nonnegative(),errorCount:E().int().nonnegative(),tokenUsage:Zd,models:V(x()),providers:V(x()),completedMembers:E().int().nonnegative(),failedMembers:E().int().nonnegative(),runningMembers:E().int().nonnegative()}),kx=T({group:Di,evidence:Oi,members:V(ru).nullable(),markdown:x(),summary:au.nullable(),report:tu.nullable()}),_x=T({group:Di,evidence:Oi,members:V(ru),summary:au,jenkinsReport:tu}),iu=T({groups:V(Di)}),Tx=T({sessionId:x(),imported:E().int().nonnegative(),skipped:E().int().nonnegative(),warnings:V(x()),logs:V(Os)}),qo=10,Ba=600,Ho=60,qa=600,Wo="time",zi="simple",lu=me(["time","full"]),Ex=me(["simple","full"]),xr=T({stripClaudeCodeBillingHeader:ke(),hasSeenOnboarding:ke().default(!1),slowResponseThresholdSeconds:E().int().min(0).max(Ba).default(qo),providerTestTimeoutSeconds:E().int().min(1).max(qa).default(Ho),timeDisplayFormat:lu.default(Wo),captureMode:Ex.default(zi)}),Zn="/api/config";async function Rx(e){return Ke(e,xr,void 0,n=>`Failed to fetch ${e}: ${n.status}`)}async function oo(e){return Ke(Zn,xr,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e)},n=>`PATCH failed with status ${n.status}`)}function $i(){const e=Rt(Zn,Rx,{revalidateOnFocus:!1,revalidateIfStale:!1}),{mutate:n}=$d(),s=e.data?.stripClaudeCodeBillingHeader??!1,o=e.data?.captureMode??zi,r=e.data?.slowResponseThresholdSeconds??qo,a=e.data?.providerTestTimeoutSeconds??Ho,i=e.data?.timeDisplayFormat??Wo,c=p=>({stripClaudeCodeBillingHeader:e.data?.stripClaudeCodeBillingHeader??!1,hasSeenOnboarding:e.data?.hasSeenOnboarding??!1,slowResponseThresholdSeconds:e.data?.slowResponseThresholdSeconds??qo,providerTestTimeoutSeconds:e.data?.providerTestTimeoutSeconds??Ho,timeDisplayFormat:e.data?.timeDisplayFormat??Wo,captureMode:o,...p}),d=async p=>{await n(Zn,oo({stripClaudeCodeBillingHeader:p}),{optimisticData:c({stripClaudeCodeBillingHeader:p}),rollbackOnError:!0,revalidate:!1})},m=async p=>{await n(Zn,oo({slowResponseThresholdSeconds:p}),{optimisticData:c({slowResponseThresholdSeconds:p}),rollbackOnError:!0,revalidate:!1})},u=async p=>{await n(Zn,oo({timeDisplayFormat:p}),{optimisticData:c({timeDisplayFormat:p}),rollbackOnError:!0,revalidate:!1})},f=async p=>{await n(Zn,oo({providerTestTimeoutSeconds:p}),{optimisticData:c({providerTestTimeoutSeconds:p}),rollbackOnError:!0,revalidate:!1})};return{strip:s,captureMode:o,slowResponseThresholdSeconds:r,providerTestTimeoutSeconds:a,timeDisplayFormat:i,isLoading:e.isLoading,isError:e.error!==void 0,setStrip:d,setSlowResponseThresholdSeconds:m,setProviderTestTimeoutSeconds:f,setTimeDisplayFormat:u}}const cu=(...e)=>e.filter((n,s,o)=>!!n&&n.trim()!==""&&o.indexOf(n)===s).join(" ").trim();const Mx=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const Ax=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(n,s,o)=>o?o.toUpperCase():s.toLowerCase());const ql=e=>{const n=Ax(e);return n.charAt(0).toUpperCase()+n.slice(1)};var Ix={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Px=e=>{for(const n in e)if(n.startsWith("aria-")||n==="role"||n==="title")return!0;return!1};const Lx=l.forwardRef(({color:e="currentColor",size:n=24,strokeWidth:s=2,absoluteStrokeWidth:o,className:r="",children:a,iconNode:i,...c},d)=>l.createElement("svg",{ref:d,...Ix,width:n,height:n,stroke:e,strokeWidth:o?Number(s)*24/Number(n):s,className:cu("lucide",r),...!a&&!Px(c)&&{"aria-hidden":"true"},...c},[...i.map(([m,u])=>l.createElement(m,u)),...Array.isArray(a)?a:[a]]));const q=(e,n)=>{const s=l.forwardRef(({className:o,...r},a)=>l.createElement(Lx,{ref:a,iconNode:n,className:cu(`lucide-${Mx(ql(e))}`,`lucide-${e}`,o),...r}));return s.displayName=ql(e),s};const Ox=[["path",{d:"m15 16 2.536-7.328a1.02 1.02 1 0 1 1.928 0L22 16",key:"xik6mr"}],["path",{d:"M15.697 14h5.606",key:"1stdlc"}],["path",{d:"m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16",key:"d5nyq2"}],["path",{d:"M3.304 13h6.392",key:"1q3zxz"}]],Dx=q("a-large-small",Ox);const zx=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],$x=q("activity",zx);const Fx=[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]],Ux=q("arrow-down-right",Fx);const Bx=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],qx=q("arrow-down",Bx);const Hx=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Wx=q("arrow-left",Hx);const Vx=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],Kx=q("arrow-up-right",Vx);const Gx=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Yx=q("arrow-up",Gx);const Jx=[["path",{d:"M4.5 3h15",key:"c7n0jr"}],["path",{d:"M6 3v16a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V3",key:"m1uhx7"}],["path",{d:"M6 14h12",key:"4cwo0f"}]],Fi=q("beaker",Jx);const Xx=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],Zx=q("bell",Xx);const Qx=[["path",{d:"M10 22V7a1 1 0 0 0-1-1H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5a1 1 0 0 0-1-1H2",key:"1ah6g2"}],["rect",{x:"14",y:"2",width:"8",height:"8",rx:"1",key:"88lufb"}]],e0=q("blocks",Qx);const t0=[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M9 13a4.5 4.5 0 0 0 3-4",key:"10igwf"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M12 13h4",key:"1ku699"}],["path",{d:"M12 18h6a2 2 0 0 1 2 2v1",key:"105ag5"}],["path",{d:"M12 8h8",key:"1lhi5i"}],["path",{d:"M16 8V5a2 2 0 0 1 2-2",key:"u6izg6"}],["circle",{cx:"16",cy:"13",r:".5",key:"ry7gng"}],["circle",{cx:"18",cy:"3",r:".5",key:"1aiba7"}],["circle",{cx:"20",cy:"21",r:".5",key:"yhc1fs"}],["circle",{cx:"20",cy:"8",r:".5",key:"1e43v0"}]],n0=q("brain-circuit",t0);const s0=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],du=q("brain",s0);const o0=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Pe=q("check",o0);const r0=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],We=q("chevron-down",r0);const a0=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],i0=q("chevron-left",a0);const l0=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],ct=q("chevron-right",l0);const c0=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Ui=q("chevron-up",c0);const d0=[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]],u0=q("chevrons-down",d0);const m0=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],f0=q("chevrons-left",m0);const p0=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],h0=q("chevrons-right",p0);const x0=[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]],g0=q("chevrons-up",x0);const b0=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],is=q("circle-alert",b0);const v0=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Ks=q("circle-check-big",v0);const y0=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Ha=q("circle-check",y0);const w0=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],j0=q("circle-question-mark",w0);const S0=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],N0=q("circle-stop",S0);const C0=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],uu=q("circle-x",C0);const k0=[["path",{d:"M20.2 6 3 11l-.9-2.4c-.3-1.1.3-2.2 1.3-2.5l13.5-4c1.1-.3 2.2.3 2.5 1.3Z",key:"1tn4o7"}],["path",{d:"m6.2 5.3 3.1 3.9",key:"iuk76l"}],["path",{d:"m12.4 3.4 3.1 4",key:"6hsd6n"}],["path",{d:"M3 11h18v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z",key:"ltgou9"}]],_0=q("clapperboard",k0);const T0=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],E0=q("clock-3",T0);const R0=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Vt=q("clock",R0);const M0=[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]],A0=q("cloud-upload",M0);const I0=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],mu=q("code-xml",I0);const P0=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],L0=q("columns-2",P0);const O0=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],St=q("copy",O0);const D0=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],z0=q("cpu",D0);const $0=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],Gs=q("download",$0);const F0=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],U0=q("ellipsis",F0);const B0=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Bi=q("external-link",B0);const q0=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],H0=q("eye-off",q0);const W0=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],fu=q("eye",W0);const V0=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]],K0=q("file-braces",V0);const G0=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M9 17h6",key:"r8uit2"}]],Y0=q("file-diff",G0);const J0=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["circle",{cx:"11.5",cy:"14.5",r:"2.5",key:"1bq0ko"}],["path",{d:"M13.3 16.3 15 18",key:"2quom7"}]],X0=q("file-search",J0);const Z0=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m8 16 2-2-2-2",key:"10vzyd"}],["path",{d:"M12 18h4",key:"1wd2n7"}]],Q0=q("file-terminal",Z0);const eg=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],tg=q("file-text",eg);const ng=[["path",{d:"M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528",key:"1jaruq"}]],sg=q("flag",ng);const og=[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]],pu=q("flask-conical",og);const rg=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],ag=q("folder-open",rg);const ig=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],qi=q("gauge",ig);const lg=[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v7",key:"1yj91y"}],["path",{d:"m15 9-3-3 3-3",key:"1lwv8l"}],["circle",{cx:"19",cy:"18",r:"3",key:"1qljk2"}],["path",{d:"M12 18H7a2 2 0 0 1-2-2V9",key:"16sdep"}],["path",{d:"m9 15 3 3-3 3",key:"1m3kbl"}]],cg=q("git-compare-arrows",lg);const dg=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],hu=q("globe",dg);const ug=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],xu=q("history",ug);const mg=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],fg=q("info",mg);const pg=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],Hl=q("layers",pg);const hg=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Ae=q("loader-circle",hg);const xg=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],gg=q("lock",xg);const bg=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],vg=q("maximize-2",bg);const yg=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],gr=q("message-square",yg);const wg=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],jg=q("minimize-2",wg);const Sg=[["path",{d:"M5 12h14",key:"1ays0h"}]],gu=q("minus",Sg);const Ng=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],Cg=q("monitor",Ng);const kg=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],_g=q("moon",kg);const Tg=[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]],Eg=q("mouse-pointer-click",Tg);const Rg=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]],Mg=q("network",Rg);const Ag=[["path",{d:"M12 16h.01",key:"1drbdi"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z",key:"1fd625"}]],Ig=q("octagon-alert",Ag);const Pg=[["path",{d:"m16 16 2 2 4-4",key:"gfu2re"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]],Lg=q("package-check",Pg);const Og=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],Dg=q("panel-right-close",Og);const zg=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],$g=q("panel-right-open",zg);const Fg=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],bu=q("pencil",Fg);const Ug=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Wl=q("plus",Ug);const Bg=[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],Vl=q("radio",Bg);const qg=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],yt=q("refresh-cw",qg);const Hg=[["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",key:"m3kijz"}],["path",{d:"m12 15-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",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]],vu=q("rocket",Hg);const Wg=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],yu=q("rotate-ccw",Wg);const Vg=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],Vo=q("rotate-cw",Vg);const Kg=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]],Gg=q("rows-3",Kg);const Yg=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],Jg=q("save",Yg);const Xg=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]],Zg=q("scan",Xg);const Qg=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],e1=q("search",Qg);const t1=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],n1=q("send",t1);const s1=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],o1=q("server",s1);const r1=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],a1=q("settings",r1);const i1=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],l1=q("shield-alert",i1);const c1=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Kl=q("shield-check",c1);const d1=[["path",{d:"M7 18v-6a5 5 0 1 1 10 0v6",key:"pcx96s"}],["path",{d:"M5 21a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-1a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2z",key:"1b4s83"}],["path",{d:"M21 12h1",key:"jtio3y"}],["path",{d:"M18.5 4.5 18 5",key:"g5sp9y"}],["path",{d:"M2 12h1",key:"1uaihz"}],["path",{d:"M12 2v1",key:"11qlp1"}],["path",{d:"m4.929 4.929.707.707",key:"1i51kw"}],["path",{d:"M12 12v6",key:"3ahymv"}]],Ko=q("siren",d1);const u1=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],Wa=q("sparkles",u1);const m1=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],f1=q("sun",m1);const p1=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Ln=q("terminal",p1);const h1=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],wu=q("timer",h1);const x1=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],dn=q("trash-2",x1);const g1=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],cn=q("triangle-alert",g1);const b1=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],ju=q("upload",b1);const v1=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],y1=q("wifi-off",v1);const w1=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],j1=q("wifi",w1);const S1=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],Ys=q("wrench",S1);const N1=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Js=q("x",N1);const C1=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Ds=q("zap",C1),Va="/api/config";async function k1(e){return Ke(e,xr,void 0,n=>`Failed to fetch ${e}: ${n.status}`)}async function _1(e){return Ke(Va,xr,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e)},n=>`PATCH failed with status ${n.status}`)}function T1(){const e=Rt(Va,k1,{revalidateOnFocus:!1,revalidateIfStale:!1}),{mutate:n}=$d(),s=e.data?.hasSeenOnboarding??!1,o=e.data?.captureMode??zi,r=async()=>{await n(Va,_1({hasSeenOnboarding:!0}),{optimisticData:{stripClaudeCodeBillingHeader:e.data?.stripClaudeCodeBillingHeader??!1,hasSeenOnboarding:!0,slowResponseThresholdSeconds:e.data?.slowResponseThresholdSeconds??qo,providerTestTimeoutSeconds:e.data?.providerTestTimeoutSeconds??Ho,timeDisplayFormat:e.data?.timeDisplayFormat??Wo,captureMode:o},rollbackOnError:!0,revalidate:!1})};return{hasSeenOnboarding:s,captureMode:o,isLoading:e.isLoading,markSeen:r}}function E1({expanded:e,onToggle:n,onDismiss:s}){const o=e?"grid":"hidden sm:grid";return t.jsx("div",{role:"note","aria-label":"Onboarding tip",className:"mx-3 mt-2 mb-1 rounded-md border border-warning/30 bg-warning/10 px-3 py-2 text-sm shadow-sm sm:mx-4",children:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(fg,{className:"mt-0.5 size-4 shrink-0 text-warning","aria-hidden":"true"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[t.jsx("span",{className:"font-medium text-foreground",children:"Inspector ready"}),t.jsx("span",{className:"hidden truncate text-xs text-muted-foreground sm:inline",children:"Request, response, tool, timing, token, replay, and memory signals are active."})]}),t.jsx("div",{className:"mt-1 text-xs leading-relaxed text-muted-foreground sm:hidden",children:"Core capture is active."}),t.jsxs("div",{className:`${o} mt-2 gap-x-4 gap-y-1 text-xs leading-relaxed text-muted-foreground sm:grid-cols-2`,children:[t.jsxs("div",{children:[t.jsx("strong",{children:"Evidence"}),": logs, sessions, groups, and MCP exports are available."]}),t.jsxs("div",{children:[t.jsx("strong",{children:"Network"}),": replace ",t.jsx("code",{children:"localhost"})," if containers differ."]})]})]}),t.jsx("button",{type:"button",onClick:n,className:"inline-flex h-8 shrink-0 items-center gap-1 rounded-md border border-warning/35 px-2 text-xs font-medium text-foreground transition-colors hover:bg-warning/15 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none sm:hidden","aria-expanded":e,"aria-label":e?"Hide onboarding details":"Show onboarding details",children:t.jsx(We,{className:`size-3.5 transition-transform ${e?"rotate-180":""}`})}),t.jsxs("button",{type:"button",onClick:s,className:"hidden h-8 shrink-0 items-center gap-1.5 rounded-md border border-warning/40 px-3 text-xs font-medium text-foreground transition-colors hover:bg-warning/15 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none sm:inline-flex","aria-label":"Dismiss onboarding tip",children:[t.jsx(Pe,{className:"size-3.5"}),"Got it"]}),t.jsx("button",{type:"button",onClick:s,className:"-m-1 shrink-0 rounded-sm p-1 text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none","aria-label":"Dismiss",children:t.jsx(Js,{className:"size-3.5"})})]})})}function R1(){const{hasSeenOnboarding:e,isLoading:n,markSeen:s}=T1(),[o,r]=l.useState(!1);return n||e?null:t.jsx(E1,{expanded:o,onToggle:()=>r(a=>!a),onDismiss:()=>{s()}})}const M1="3.1.8",Su={version:M1};function Es(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Nu="[REDACTED]",A1=/(^|[-_])(api[-_]?key|authorization|cookie|token|secret|password|access[-_]?token|refresh[-_]?token)([-_]|$)/i,I1=[/Bearer\s+[A-Za-z0-9._~+/=-]{12,}/gi,/\bsk-[A-Za-z0-9_-]{12,}\b/g,/\bsk-ant-[A-Za-z0-9_-]{12,}\b/g,/\bghp_[A-Za-z0-9_]{12,}\b/g,/\bglpat-[A-Za-z0-9_-]{12,}\b/g],Gl=200,P1=25e6,Cu=50,L1=1e4,O1=1024*1024,D1=64,z1=1e4;function $1(e){return e<1024?`${e} chars`:e<1024*1024?`${Math.ceil(e/1024)} KB`:`${Math.ceil(e/(1024*1024))} MB`}function F1(e){let n=0;for(const s of e)n+=s.rawRequestBody?.length??s.rawRequestBodyBytes??0,n+=s.responseText?.length??s.responseTextBytes??0;return n}function U1(e){if(e.length>Gl)return`Export is limited to ${Gl} logs at once. Narrow the filter and try again.`;const n=F1(e);return n>P1?`Export is too large (${$1(n)} of text). Narrow the filter and try again.`:null}function ro(e){return e?.aborted===!0?{ok:!1,message:"Export canceled.",canceled:!0}:null}async function B1(e,n){try{const s=await _n(`/api/logs/${e}/chunks`,L1,{signal:n});if(!s.ok)return null;const o=await s.json();return JSON.stringify(o,null,2)}catch{return null}}function q1(e,n){switch(n){case"request":return e.rawRequestBody;case"response":return e.responseText}}async function Yl(e,n,s){const o=q1(e,n);if(o!==null)return o;let r=0,a="";for(let i=0;i<D1;i+=1){const c=new URLSearchParams({part:n,offset:String(r),limit:String(O1)});try{const d=await _n(`/api/logs/${String(e.id)}/body?${c.toString()}`,z1,{signal:s});if(!d.ok)return a.length>0?a:null;const m=await d.json(),u=Wd.safeParse(m);if(!u.success||(a=`${a}${u.data.text}`,!u.data.hasMore||u.data.nextOffset===null))return a.length>0?a:null;r=u.data.nextOffset}catch{return a.length>0?a:null}}return a.length>0?a:null}function Ka(e){if(Array.isArray(e))return e.map(s=>Ka(s));if(!Es(e))return e;const n={};for(const[s,o]of Object.entries(e))n[s]=A1.test(s)?Nu:Ka(o);return n}function H1(e){const n=s=>{let o=s;for(const r of I1)o=o.replace(r,Nu);return o};try{const s=JSON.parse(e);return n(JSON.stringify(Ka(s),null,2))}catch{return n(e)}}function Xr(e,n){return n==="redacted"?H1(e):e}function W1(e,n){return{...e,rawRequestBody:null,responseText:null,rawHeaders:n==="raw"?e.rawHeaders:void 0,headers:n==="raw"?e.headers:void 0,streamingChunks:void 0,bodyContentMode:"compact"}}function V1(e,n,s,o=new Date().toISOString()){return{version:Su.version,exportedAt:o,mode:n,redacted:n==="redacted",logCount:e.length,logIds:e.map(r=>r.id),streamingChunkExportLimit:Cu,streamingChunkLogIds:s.map(r=>r.id)}}async function K1(e,n="redacted",s={}){const o=ro(s.signal);if(o!==null)return o;const r=U1(e);if(r!==null)return{ok:!1,message:r};const{default:a}=await zt(async()=>{const{default:h}=await import("./jszip.min-zWpW-aD7.js").then(g=>g.j);return{default:h}},__vite__mapDeps([0,1,2]),import.meta.url),i=new a,c=n==="redacted"?"redacted":"raw",d=e.filter(h=>h.streaming).slice(0,Cu);i.file("manifest.json",JSON.stringify(V1(e,n,d),null,2)),i.file("logs.json",JSON.stringify(e.map(h=>W1(h,n)),null,2));for(const h of e){const g=ro(s.signal);if(g!==null)return g;const v=await Yl(h,"request",s.signal);v!==null&&i.file(`#${h.id}.Request.json`,Xr(v,n));const y=await Yl(h,"response",s.signal);y!==null&&i.file(`#${h.id}.Response.json`,Xr(y,n))}for(const h of d){const g=ro(s.signal);if(g!==null)return g;const v=await B1(h.id,s.signal);v!==null&&i.file(`#${h.id}.SSE.Response.json`,Xr(v,n))}const m=await i.generateAsync({type:"blob"}),u=ro(s.signal);if(u!==null)return u;const f=URL.createObjectURL(m),p=document.createElement("a");return p.href=f,p.download=`agent-inspector-export-${c}-${new Date().toISOString().slice(0,10)}.zip`,document.body.appendChild(p),p.click(),document.body.removeChild(p),URL.revokeObjectURL(f),{ok:!0}}function G1(e){const n=Jr(e,"/proxy"),s=Jr(e,"/proxy/v1"),o=Jr(e,"/api/mcp");return n===null||s===null||o===null?null:{proxy:n,openAiV1:s,mcp:o}}function Y1(){const e=_h();return e.ok?G1(e.runtime):null}function Hi(e){const n=()=>e(Y1());return n(),typeof globalThis.addEventListener!="function"||typeof globalThis.removeEventListener!="function"?()=>{}:(globalThis.addEventListener(Bl,n),()=>globalThis.removeEventListener(Bl,n))}function Ga(e,n){switch(n){case"full":return e;case"time":return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}}function br(e,n,s){return`${Ga(e,s)} - ${Ga(n,s)}`}const Wi="agent-inspector.theme";function ku(e){switch(e){case"light":return"light";case"dark":return"dark";case"eye-care":return"eye-care";case null:return"dark";default:return"dark"}}function Zr(e){typeof document>"u"||(document.documentElement.dataset.theme=e)}function J1(){if(typeof window>"u")return"dark";try{return ku(window.localStorage.getItem(Wi))}catch{return"dark"}}function X1(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Wi,e)}catch{}}function Z1(){const[e,n]=l.useState(J1),s=l.useCallback(o=>{n(o),Zr(o),X1(o)},[]);return l.useEffect(()=>{Zr(e)},[e]),l.useEffect(()=>{function o(r){if(r.key!==Wi)return;const a=ku(r.newValue);n(a),Zr(a)}return window.addEventListener("storage",o),()=>window.removeEventListener("storage",o)},[]),{themeMode:e,setThemeMode:s}}const Vi="agent-inspector.uiScale",Q1=1.25,eb=2200,tb=3e3,nb=12;function Qr(e,n){return Number.isFinite(e)&&e>0?e:n}function Ki(e){switch(e){case"auto":return"auto";case"100":return"100";case"125":return"125";case"150":return"150";case null:return"auto";default:return"auto"}}function sb(e,n){switch(e){case"100":return 1;case"125":return 1.25;case"150":return 1.5;case"auto":{const s=Qr(n.viewportWidth,1280),o=Qr(n.screenWidth,s),r=Qr(n.devicePixelRatio,1),a=Math.min(s,o);return r>Q1?1:a>=tb?1.25:a>=eb?1.125:1}}}function ob(e){return`${Math.round(e*100)}%`}function ea(e,n){return Math.max(nb,e*n)}function rb(){if(typeof window>"u")return{viewportWidth:1280,screenWidth:1280,devicePixelRatio:1};const e=typeof window.screen>"u"?window.innerWidth:window.screen.availWidth;return{viewportWidth:window.innerWidth,screenWidth:e,devicePixelRatio:window.devicePixelRatio}}function ta(e){const n=sb(e,rb());if(typeof document>"u")return n;const s=document.documentElement;return s.dataset.uiScale=e,s.dataset.uiScaleResolved=String(Math.round(n*100)),s.style.setProperty("--inspector-ui-scale",String(n)),s.style.setProperty("--inspector-root-font-size",`${String(16*n)}px`),s.style.setProperty("--inspector-font-9",`${String(ea(9,n))}px`),s.style.setProperty("--inspector-font-10",`${String(ea(10,n))}px`),s.style.setProperty("--inspector-font-11",`${String(ea(11,n))}px`),s.style.setProperty("--inspector-font-13",`${String(13*n)}px`),n}function ab(){if(typeof window>"u")return"auto";try{return Ki(window.localStorage.getItem(Vi))}catch{return"auto"}}function ib(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Vi,e)}catch{}}function lb(){const[e,n]=l.useState(ab),[s,o]=l.useState(1),r=l.useCallback(a=>{n(a),ib(a),o(ta(a))},[]);return l.useEffect(()=>{const a=()=>{o(ta(e))};if(a(),e==="auto")return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[e]),l.useEffect(()=>{const a=i=>{if(i.key!==Vi)return;const c=Ki(i.newValue);n(c),o(ta(c))};return window.addEventListener("storage",a),()=>window.removeEventListener("storage",a)},[]),{uiScalePreference:e,resolvedUiScale:s,setUiScalePreference:r}}const Tn=64,Ya=256,cb=64,db=me(["invalid-page-request","search-limit-exceeded","provider-model-limit-exceeded","sse-capacity-exceeded","provider-test-capacity-exceeded","proxy-capacity-exceeded"]),ub=Dt([oe(400),oe(413),oe(429),oe(503)]);T({error:x().min(1).max(300),code:db,status:ub,resource:x().min(1).max(80),limit:E().int().positive(),retryable:ke()});function ao(){return x().refine(e=>{if(e.length===0)return!0;try{const n=new URL(e);return n.protocol==="http:"||n.protocol==="https:"}catch{return!1}},"Must be a valid http(s) URL")}const Gi=x().max(Ya),mb=V(Gi).max(Tn),fb=T({model:Gi.min(1),contextWindow:E().int().positive().optional(),outputLimit:E().int().positive().optional(),source:me(["manual","registry"]).optional(),sourceUrl:x().optional(),updatedAt:x().optional()}),pb=V(fb).max(cb),hb=T({id:x(),name:x(),apiKey:x(),model:Gi.optional(),models:mb.optional().default([]),format:me(["anthropic","openai"]).optional(),baseUrl:ao().optional(),anthropicBaseUrl:ao().optional(),openaiBaseUrl:ao().optional(),openaiResponsesBaseUrl:ao().optional(),authHeader:me(["bearer","x-api-key"]).optional().default("bearer"),apiDocsUrl:x().optional(),modelMetadataUrl:x().optional(),modelMetadata:pb.optional(),source:me(["company","personal"]).optional(),createdAt:x(),updatedAt:x()}),xb="configured",Go=hb.extend({apiKey:oe(xb)});async function gb(e){return Ke(e,Go.array(),void 0,n=>`Failed to fetch ${e}: ${n.status}`)}function Yi(){const e=Rt("/api/providers",gb,{revalidateOnFocus:!1,revalidateIfStale:!1});return{providers:e.data??[],isLoading:e.isLoading,isError:e.error,mutate:e.mutate}}function Jl(e,n){if(typeof e=="function")return e(n);e!=null&&(e.current=n)}function bb(...e){return n=>{let s=!1;const o=e.map(r=>{const a=Jl(r,n);return!s&&typeof a=="function"&&(s=!0),a});if(s)return()=>{for(let r=0;r<o.length;r++){const a=o[r];typeof a=="function"?a():Jl(e[r],null)}}}}function Ee(...e){return l.useCallback(bb(...e),e)}function ls(e){const n=l.forwardRef((s,o)=>{let{children:r,...a}=s,i=null,c=!1;const d=[];Xl(r)&&typeof io=="function"&&(r=io(r._payload)),l.Children.forEach(r,p=>{if(Nb(p)){c=!0;const h=p;let g="child"in h.props?h.props.child:h.props.children;Xl(g)&&typeof io=="function"&&(g=io(g._payload)),i=wb(h,g),d.push(i?.props?.children)}else d.push(p)}),i?i=l.cloneElement(i,void 0,d):!c&&l.Children.count(r)===1&&l.isValidElement(r)&&(i=r);const m=i?Sb(i):void 0,u=Ee(o,m);if(!i){if(r||r===0)throw new Error(c?Tb(e):_b(e));return r}const f=jb(a,i.props??{});return i.type!==l.Fragment&&(f.ref=o?u:m),l.cloneElement(i,f)});return n.displayName=`${e}.Slot`,n}var vb=ls("Slot"),_u=Symbol.for("radix.slottable");function yb(e){const n=s=>"child"in s?s.children(s.child):s.children;return n.displayName=`${e}.Slottable`,n.__radixId=_u,n}var wb=(e,n)=>{if("child"in e.props){const s=e.props.child;return l.isValidElement(s)?l.cloneElement(s,void 0,e.props.children(s.props.children)):null}return l.isValidElement(n)?n:null};function jb(e,n){const s={...n};for(const o in n){const r=e[o],a=n[o];/^on[A-Z]/.test(o)?r&&a?s[o]=(...c)=>{const d=a(...c);return r(...c),d}:r&&(s[o]=r):o==="style"?s[o]={...r,...a}:o==="className"&&(s[o]=[r,a].filter(Boolean).join(" "))}return{...e,...s}}function Sb(e){let n=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,s=n&&"isReactWarning"in n&&n.isReactWarning;return s?e.ref:(n=Object.getOwnPropertyDescriptor(e,"ref")?.get,s=n&&"isReactWarning"in n&&n.isReactWarning,s?e.props.ref:e.props.ref||e.ref)}function Nb(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===_u}var Cb=Symbol.for("react.lazy");function Xl(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Cb&&"_payload"in e&&kb(e._payload)}function kb(e){return typeof e=="object"&&e!==null&&"then"in e}var _b=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,Tb=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,io=hr[" use ".trim().toString()],Eb=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],xe=Eb.reduce((e,n)=>{const s=ls(`Primitive.${n}`),o=l.forwardRef((r,a)=>{const{asChild:i,...c}=r,d=i?s:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),t.jsx(d,{...c,ref:a})});return o.displayName=`Primitive.${n}`,{...e,[n]:o}},{});function Rb(e,n){e&&hs.flushSync(()=>e.dispatchEvent(n))}var Tu=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Mb="VisuallyHidden",Eu=l.forwardRef((e,n)=>t.jsx(xe.span,{...e,ref:n,style:{...Tu,...e.style}}));Eu.displayName=Mb;var Ab=Eu;function Jt(e,n=[]){let s=[];function o(a,i){const c=l.createContext(i);c.displayName=a+"Context";const d=s.length;s=[...s,i];const m=f=>{const{scope:p,children:h,...g}=f,v=p?.[e]?.[d]||c,y=l.useMemo(()=>g,Object.values(g));return t.jsx(v.Provider,{value:y,children:h})};m.displayName=a+"Provider";function u(f,p,h={}){const{optional:g=!1}=h,v=p?.[e]?.[d]||c,y=l.useContext(v);if(y)return y;if(i!==void 0)return i;if(!g)throw new Error(`\`${f}\` must be used within \`${a}\``)}return[m,u]}const r=()=>{const a=s.map(i=>l.createContext(i));return function(c){const d=c?.[e]||a;return l.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return r.scopeName=e,[o,Ib(r,...n)]}function Ib(...e){const n=e[0];if(e.length===1)return n;const s=()=>{const o=e.map(r=>({useScope:r(),scopeName:r.scopeName}));return function(a){const i=o.reduce((c,{useScope:d,scopeName:m})=>{const f=d(a)[`__scope${m}`];return{...c,...f}},{});return l.useMemo(()=>({[`__scope${n.scopeName}`]:i}),[i])}};return s.scopeName=n.scopeName,s}function Ru(e){const n=e+"CollectionProvider",[s,o]=Jt(n),[r,a]=s(n,{collectionRef:{current:null},itemMap:new Map}),i=v=>{const{scope:y,children:w}=v,b=l.useRef(null),j=l.useRef(new Map).current;return t.jsx(r,{scope:y,itemMap:j,collectionRef:b,children:w})};i.displayName=n;const c=e+"CollectionSlot",d=ls(c),m=l.forwardRef((v,y)=>{const{scope:w,children:b}=v,j=a(c,w),S=Ee(y,j.collectionRef);return t.jsx(d,{ref:S,children:b})});m.displayName=c;const u=e+"CollectionItemSlot",f="data-radix-collection-item",p=ls(u),h=l.forwardRef((v,y)=>{const{scope:w,children:b,...j}=v,S=l.useRef(null),N=Ee(y,S),C=a(u,w);return l.useEffect(()=>(C.itemMap.set(S,{ref:S,...j}),()=>{C.itemMap.delete(S)})),t.jsx(p,{[f]:"",ref:N,children:b})});h.displayName=u;function g(v){const y=a(e+"CollectionConsumer",v);return l.useCallback(()=>{const b=y.collectionRef.current;if(!b)return[];const j=Array.from(b.querySelectorAll(`[${f}]`));return Array.from(y.itemMap.values()).sort((C,R)=>j.indexOf(C.ref.current)-j.indexOf(R.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:i,Slot:m,ItemSlot:h},g,o]}function ie(e,n,{checkForDefaultPrevented:s=!0}={}){return function(r){if(e?.(r),s===!1||!r||!r.defaultPrevented)return n?.(r)}}var ze=globalThis?.document?l.useLayoutEffect:()=>{},Pb=hr[" useInsertionEffect ".trim().toString()]||ze;function Rn({prop:e,defaultProp:n,onChange:s=()=>{},caller:o}){const[r,a,i]=Lb({defaultProp:n,onChange:s}),c=e!==void 0,d=c?e:r;{const u=l.useRef(e!==void 0);l.useEffect(()=>{const f=u.current;f!==c&&console.warn(`${o} is changing from ${f?"controlled":"uncontrolled"} to ${c?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=c},[c,o])}const m=l.useCallback(u=>{if(c){const f=Ob(u)?u(e):u;f!==e&&i.current?.(f)}else a(u)},[c,e,a,i]);return[d,m]}function Lb({defaultProp:e,onChange:n}){const[s,o]=l.useState(e),r=l.useRef(s),a=l.useRef(n);return Pb(()=>{a.current=n},[n]),l.useEffect(()=>{r.current!==s&&(a.current?.(s),r.current=s)},[s,r]),[s,o,a]}function Ob(e){return typeof e=="function"}function Db(e,n){return l.useReducer((s,o)=>n[s][o]??s,e)}var dt=e=>{const{present:n,children:s}=e,o=zb(n),r=typeof s=="function"?s({present:o.isPresent}):l.Children.only(s),a=$b(o.ref,Fb(r));return typeof s=="function"||o.isPresent?l.cloneElement(r,{ref:a}):null};dt.displayName="Presence";function zb(e){const[n,s]=l.useState(),o=l.useRef(null),r=l.useRef(e),a=l.useRef("none"),i=l.useRef(void 0),c=e?"mounted":"unmounted",[d,m]=Db(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return l.useEffect(()=>{d==="mounted"?(a.current=i.current??js(o.current),i.current=void 0):a.current="none"},[d]),ze(()=>{const u=o.current,f=r.current;if(f!==e){const h=a.current,g=js(u);e?(i.current=g,m("MOUNT")):g==="none"||u?.display==="none"?m("UNMOUNT"):m(f&&h!==g?"ANIMATION_OUT":"UNMOUNT"),r.current=e}},[e,m]),ze(()=>{if(n){let u;const f=n.ownerDocument.defaultView??window,p=g=>{const y=js(o.current).includes(CSS.escape(g.animationName));if(g.target===n&&y&&(m("ANIMATION_END"),!r.current)){const w=n.style.animationFillMode;n.style.animationFillMode="forwards",u=f.setTimeout(()=>{n.style.animationFillMode==="forwards"&&(n.style.animationFillMode=w)})}},h=g=>{g.target===n&&(a.current=js(o.current))};return n.addEventListener("animationstart",h),n.addEventListener("animationcancel",p),n.addEventListener("animationend",p),()=>{f.clearTimeout(u),n.removeEventListener("animationstart",h),n.removeEventListener("animationcancel",p),n.removeEventListener("animationend",p)}}else m("ANIMATION_END")},[n,m]),{isPresent:["mounted","unmountSuspended"].includes(d),ref:l.useCallback(u=>{if(u){const f=getComputedStyle(u);o.current=f,i.current=js(f)}else o.current=null;s(u)},[])}}function Zl(e,n){if(typeof e=="function")return e(n);e!=null&&(e.current=n)}function $b(...e){const n=l.useRef(e);return n.current=e,l.useCallback(s=>{const o=n.current;let r=!1;const a=o.map(i=>{const c=Zl(i,s);return!r&&typeof c=="function"&&(r=!0),c});if(r)return()=>{for(let i=0;i<a.length;i++){const c=a[i];typeof c=="function"?c():Zl(o[i],null)}}},[])}function js(e){return e?.animationName||"none"}function Fb(e){let n=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,s=n&&"isReactWarning"in n&&n.isReactWarning;return s?e.ref:(n=Object.getOwnPropertyDescriptor(e,"ref")?.get,s=n&&"isReactWarning"in n&&n.isReactWarning,s?e.props.ref:e.props.ref||e.ref)}var Ub=hr[" useId ".trim().toString()]||(()=>{}),Bb=0;function Mt(e){const[n,s]=l.useState(Ub());return ze(()=>{s(o=>o??String(Bb++))},[e]),e||(n?`radix-${n}`:"")}var vr="Collapsible",[qb]=Jt(vr),[Hb,Ji]=qb(vr),Mu=l.forwardRef((e,n)=>{const{__scopeCollapsible:s,open:o,defaultOpen:r,disabled:a,onOpenChange:i,...c}=e,[d,m]=Rn({prop:o,defaultProp:r??!1,onChange:i,caller:vr});return t.jsx(Hb,{scope:s,disabled:a,contentId:Mt(),open:d,onOpenToggle:l.useCallback(()=>m(u=>!u),[m]),children:t.jsx(xe.div,{"data-state":Zi(d),"data-disabled":a?"":void 0,...c,ref:n})})});Mu.displayName=vr;var Au="CollapsibleTrigger",Iu=l.forwardRef((e,n)=>{const{__scopeCollapsible:s,...o}=e,r=Ji(Au,s);return t.jsx(xe.button,{type:"button","aria-controls":r.open?r.contentId:void 0,"aria-expanded":r.open||!1,"data-state":Zi(r.open),"data-disabled":r.disabled?"":void 0,disabled:r.disabled,...o,ref:n,onClick:ie(e.onClick,r.onOpenToggle)})});Iu.displayName=Au;var Xi="CollapsibleContent",Pu=l.forwardRef((e,n)=>{const{forceMount:s,...o}=e,r=Ji(Xi,e.__scopeCollapsible);return t.jsx(dt,{present:s||r.open,children:({present:a})=>t.jsx(Wb,{...o,ref:n,present:a})})});Pu.displayName=Xi;var Wb=l.forwardRef((e,n)=>{const{__scopeCollapsible:s,present:o,children:r,...a}=e,i=Ji(Xi,s),[c,d]=l.useState(o),m=l.useRef(null),u=Ee(n,m),f=l.useRef(0),p=f.current,h=l.useRef(0),g=h.current,v=i.open||c,y=l.useRef(v),w=l.useRef(void 0);return l.useEffect(()=>{const b=requestAnimationFrame(()=>y.current=!1);return()=>cancelAnimationFrame(b)},[]),ze(()=>{const b=m.current;if(b){w.current=w.current||{transitionDuration:b.style.transitionDuration,animationName:b.style.animationName},b.style.transitionDuration="0s",b.style.animationName="none";const j=b.getBoundingClientRect();f.current=j.height,h.current=j.width,y.current||(b.style.transitionDuration=w.current.transitionDuration,b.style.animationName=w.current.animationName),d(o)}},[i.open,o]),t.jsx(xe.div,{"data-state":Zi(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!v,...a,ref:u,style:{"--radix-collapsible-content-height":p?`${p}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...e.style},children:v&&r})});function Zi(e){return e?"open":"closed"}var Vb=Mu,Kb=l.createContext(void 0);function yr(e){const n=l.useContext(Kb);return e||n||"ltr"}function qe(e){const n=l.useRef(e);return l.useEffect(()=>{n.current=e}),l.useMemo(()=>((...s)=>n.current?.(...s)),[])}var Gb="DismissableLayer",Ja="dismissableLayer.update",Yb="dismissableLayer.pointerDownOutside",Jb="dismissableLayer.focusOutside",Ql,Qi=l.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),wr=l.forwardRef((e,n)=>{const{disableOutsidePointerEvents:s=!1,deferPointerDownOutside:o=!1,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:c,onDismiss:d,...m}=e,u=l.useContext(Qi),[f,p]=l.useState(null),h=f?.ownerDocument??globalThis?.document,[,g]=l.useState({}),v=Ee(n,p),y=Array.from(u.layers),[w]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),b=w?y.indexOf(w):-1,j=f?y.indexOf(f):-1,S=u.layersWithOutsidePointerEventsDisabled.size>0,N=j>=b,C=l.useRef(!1),R=tv(k=>{a?.(k),c?.(k),k.defaultPrevented||d?.()},{ownerDocument:h,deferPointerDownOutside:o,isDeferredPointerDownOutsideRef:C,dismissableSurfaces:u.dismissableSurfaces,shouldHandlePointerDownOutside:l.useCallback(k=>{if(!(k instanceof Node))return!1;const A=[...u.branches].some(D=>D.contains(k));return N&&!A},[u.branches,N])}),I=nv(k=>{if(o&&C.current)return;const A=k.target;[...u.branches].some($=>$.contains(A))||(i?.(k),c?.(k),k.defaultPrevented||d?.())},h),P=f?j===y.length-1:!1,M=qe(k=>{k.key==="Escape"&&(r?.(k),!k.defaultPrevented&&d&&(k.preventDefault(),d()))});return l.useEffect(()=>{if(P)return h.addEventListener("keydown",M,{capture:!0}),()=>h.removeEventListener("keydown",M,{capture:!0})},[h,P,M]),l.useEffect(()=>{if(f)return s&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Ql=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(f)),u.layers.add(f),ec(),()=>{s&&(u.layersWithOutsidePointerEventsDisabled.delete(f),u.layersWithOutsidePointerEventsDisabled.size===0&&(h.body.style.pointerEvents=Ql))}},[f,h,s,u]),l.useEffect(()=>()=>{f&&(u.layers.delete(f),u.layersWithOutsidePointerEventsDisabled.delete(f),ec())},[f,u]),l.useEffect(()=>{const k=()=>g({});return document.addEventListener(Ja,k),()=>document.removeEventListener(Ja,k)},[]),t.jsx(xe.div,{...m,ref:v,style:{pointerEvents:S?N?"auto":"none":void 0,...e.style},onFocusCapture:ie(e.onFocusCapture,I.onFocusCapture),onBlurCapture:ie(e.onBlurCapture,I.onBlurCapture),onPointerDownCapture:ie(e.onPointerDownCapture,R.onPointerDownCapture)})});wr.displayName=Gb;var Xb="DismissableLayerBranch",Zb=l.forwardRef((e,n)=>{const s=l.useContext(Qi),o=l.useRef(null),r=Ee(n,o);return l.useEffect(()=>{const a=o.current;if(a)return s.branches.add(a),()=>{s.branches.delete(a)}},[s.branches]),t.jsx(xe.div,{...e,ref:r})});Zb.displayName=Xb;function Qb(){const e=l.useContext(Qi),[n,s]=l.useState(null);return l.useEffect(()=>{if(n)return e.dismissableSurfaces.add(n),()=>{e.dismissableSurfaces.delete(n)}},[n,e.dismissableSurfaces]),s}var ev=()=>!0;function tv(e,n){const{ownerDocument:s=globalThis?.document,deferPointerDownOutside:o=!1,isDeferredPointerDownOutsideRef:r,dismissableSurfaces:a,shouldHandlePointerDownOutside:i=ev}=n,c=qe(e),d=l.useRef(!1),m=l.useRef(!1),u=l.useRef(new Map),f=l.useRef(()=>{});return l.useEffect(()=>{function p(){m.current=!1,r.current=!1,u.current.clear()}function h(){return Array.from(u.current.values()).some(Boolean)}function g(j){if(!m.current)return;const S=j.target;S instanceof Node&&[...a].some(C=>C.contains(S))||u.current.set(j.type,!0),j.type==="click"&&window.setTimeout(()=>{m.current&&f.current()},0)}function v(j){m.current&&u.current.set(j.type,!1)}const y=j=>{if(j.target&&!d.current){let S=function(){s.removeEventListener("click",f.current);const C=h();p(),C||Lu(Yb,c,N,{discrete:!0})};if(!i(j.target)){s.removeEventListener("click",f.current),p(),d.current=!1;return}const N={originalEvent:j};m.current=!0,r.current=o&&j.button===0,u.current.clear(),!o||j.button!==0?S():(s.removeEventListener("click",f.current),f.current=S,s.addEventListener("click",f.current,{once:!0}))}else s.removeEventListener("click",f.current),p();d.current=!1},w=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const j of w)s.addEventListener(j,g,!0),s.addEventListener(j,v);const b=window.setTimeout(()=>{s.addEventListener("pointerdown",y)},0);return()=>{window.clearTimeout(b),s.removeEventListener("pointerdown",y),s.removeEventListener("click",f.current);for(const j of w)s.removeEventListener(j,g,!0),s.removeEventListener(j,v)}},[s,c,o,r,a,i]),{onPointerDownCapture:()=>d.current=!0}}function nv(e,n=globalThis?.document){const s=qe(e),o=l.useRef(!1);return l.useEffect(()=>{const r=a=>{a.target&&!o.current&&Lu(Jb,s,{originalEvent:a},{discrete:!1})};return n.addEventListener("focusin",r),()=>n.removeEventListener("focusin",r)},[n,s]),{onFocusCapture:()=>o.current=!0,onBlurCapture:()=>o.current=!1}}function ec(){const e=new CustomEvent(Ja);document.dispatchEvent(e)}function Lu(e,n,s,{discrete:o}){const r=s.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:s});n&&r.addEventListener(e,n,{once:!0}),o?Rb(r,a):r.dispatchEvent(a)}var na="focusScope.autoFocusOnMount",sa="focusScope.autoFocusOnUnmount",tc={bubbles:!1,cancelable:!0},sv="FocusScope",el=l.forwardRef((e,n)=>{const{loop:s=!1,trapped:o=!1,onMountAutoFocus:r,onUnmountAutoFocus:a,...i}=e,[c,d]=l.useState(null),m=qe(r),u=qe(a),f=l.useRef(null),p=Ee(n,d),h=l.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;l.useEffect(()=>{if(o){let v=function(j){if(h.paused||!c)return;const S=j.target;c.contains(S)?f.current=S:on(f.current,{select:!0})},y=function(j){if(h.paused||!c)return;const S=j.relatedTarget;S!==null&&(c.contains(S)||on(f.current,{select:!0}))},w=function(j){if(document.activeElement===document.body)for(const N of j)N.removedNodes.length>0&&on(c)};document.addEventListener("focusin",v),document.addEventListener("focusout",y);const b=new MutationObserver(w);return c&&b.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",y),b.disconnect()}}},[o,c,h.paused]),l.useEffect(()=>{if(c){sc.add(h);const v=document.activeElement;if(!c.contains(v)){const w=new CustomEvent(na,tc);c.addEventListener(na,m),c.dispatchEvent(w),w.defaultPrevented||(ov(cv(Ou(c)),{select:!0}),document.activeElement===v&&on(c))}return()=>{c.removeEventListener(na,m),setTimeout(()=>{const w=new CustomEvent(sa,tc);c.addEventListener(sa,u),c.dispatchEvent(w),w.defaultPrevented||on(v??document.body,{select:!0}),c.removeEventListener(sa,u),sc.remove(h)},0)}}},[c,m,u,h]);const g=l.useCallback(v=>{if(!s&&!o||h.paused)return;const y=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,w=document.activeElement;if(y&&w){const b=v.currentTarget,[j,S]=rv(b);j&&S?!v.shiftKey&&w===S?(v.preventDefault(),s&&on(j,{select:!0})):v.shiftKey&&w===j&&(v.preventDefault(),s&&on(S,{select:!0})):w===b&&v.preventDefault()}},[s,o,h.paused]);return t.jsx(xe.div,{tabIndex:-1,...i,ref:p,onKeyDown:g})});el.displayName=sv;function ov(e,{select:n=!1}={}){const s=document.activeElement;for(const o of e)if(on(o,{select:n}),document.activeElement!==s)return}function rv(e){const n=Ou(e),s=nc(n,e),o=nc(n.reverse(),e);return[s,o]}function Ou(e){const n=[],s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:o=>{const r=o.tagName==="INPUT"&&o.type==="hidden";return o.disabled||o.hidden||r?NodeFilter.FILTER_SKIP:o.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;s.nextNode();)n.push(s.currentNode);return n}function nc(e,n){const s=typeof n.checkVisibility=="function"&&n.checkVisibility({checkVisibilityCSS:!0});for(const o of e)if(!(s?!o.checkVisibility({checkVisibilityCSS:!0}):av(o,{upTo:n})))return o}function av(e,{upTo:n}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(n!==void 0&&e===n)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function iv(e){return e instanceof HTMLInputElement&&"select"in e}function on(e,{select:n=!1}={}){if(e&&e.focus){const s=document.activeElement;e.focus({preventScroll:!0}),e!==s&&iv(e)&&n&&e.select()}}var sc=lv();function lv(){let e=[];return{add(n){const s=e[0];n!==s&&s?.pause(),e=oc(e,n),e.unshift(n)},remove(n){e=oc(e,n),e[0]?.resume()}}}function oc(e,n){const s=[...e],o=s.indexOf(n);return o!==-1&&s.splice(o,1),s}function cv(e){return e.filter(n=>n.tagName!=="A")}var dv="Portal",jr=l.forwardRef((e,n)=>{const{container:s,...o}=e,[r,a]=l.useState(!1);ze(()=>a(!0),[]);const i=s||r&&globalThis?.document?.body;return i?hs.createPortal(t.jsx(xe.div,{...o,ref:n}),i):null});jr.displayName=dv;var lo=0,Un=null;function Du(){l.useEffect(()=>{Un||(Un={start:rc(),end:rc()});const{start:e,end:n}=Un;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==n&&document.body.insertAdjacentElement("beforeend",n),lo++,()=>{lo===1&&(Un?.start.remove(),Un?.end.remove(),Un=null),lo=Math.max(0,lo-1)}},[])}function rc(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Tt=function(){return Tt=Object.assign||function(n){for(var s,o=1,r=arguments.length;o<r;o++){s=arguments[o];for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(n[a]=s[a])}return n},Tt.apply(this,arguments)};function zu(e,n){var s={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&n.indexOf(o)<0&&(s[o]=e[o]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,o=Object.getOwnPropertySymbols(e);r<o.length;r++)n.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(s[o[r]]=e[o[r]]);return s}function uv(e,n,s){if(s||arguments.length===2)for(var o=0,r=n.length,a;o<r;o++)(a||!(o in n))&&(a||(a=Array.prototype.slice.call(n,0,o)),a[o]=n[o]);return e.concat(a||Array.prototype.slice.call(n))}var Io="right-scroll-bar-position",Po="width-before-scroll-bar",mv="with-scroll-bars-hidden",fv="--removed-body-scroll-bar-size";function oa(e,n){return typeof e=="function"?e(n):e&&(e.current=n),e}function pv(e,n){var s=l.useState(function(){return{value:e,callback:n,facade:{get current(){return s.value},set current(o){var r=s.value;r!==o&&(s.value=o,s.callback(o,r))}}}})[0];return s.callback=n,s.facade}var hv=typeof window<"u"?l.useLayoutEffect:l.useEffect,ac=new WeakMap;function xv(e,n){var s=pv(null,function(o){return e.forEach(function(r){return oa(r,o)})});return hv(function(){var o=ac.get(s);if(o){var r=new Set(o),a=new Set(e),i=s.current;r.forEach(function(c){a.has(c)||oa(c,null)}),a.forEach(function(c){r.has(c)||oa(c,i)})}ac.set(s,e)},[e]),s}function gv(e){return e}function bv(e,n){n===void 0&&(n=gv);var s=[],o=!1,r={read:function(){if(o)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return s.length?s[s.length-1]:e},useMedium:function(a){var i=n(a,o);return s.push(i),function(){s=s.filter(function(c){return c!==i})}},assignSyncMedium:function(a){for(o=!0;s.length;){var i=s;s=[],i.forEach(a)}s={push:function(c){return a(c)},filter:function(){return s}}},assignMedium:function(a){o=!0;var i=[];if(s.length){var c=s;s=[],c.forEach(a),i=s}var d=function(){var u=i;i=[],u.forEach(a)},m=function(){return Promise.resolve().then(d)};m(),s={push:function(u){i.push(u),m()},filter:function(u){return i=i.filter(u),s}}}};return r}function vv(e){e===void 0&&(e={});var n=bv(null);return n.options=Tt({async:!0,ssr:!1},e),n}var $u=function(e){var n=e.sideCar,s=zu(e,["sideCar"]);if(!n)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var o=n.read();if(!o)throw new Error("Sidecar medium not found");return l.createElement(o,Tt({},s))};$u.isSideCarExport=!0;function yv(e,n){return e.useMedium(n),$u}var Fu=vv(),ra=function(){},Sr=l.forwardRef(function(e,n){var s=l.useRef(null),o=l.useState({onScrollCapture:ra,onWheelCapture:ra,onTouchMoveCapture:ra}),r=o[0],a=o[1],i=e.forwardProps,c=e.children,d=e.className,m=e.removeScrollBar,u=e.enabled,f=e.shards,p=e.sideCar,h=e.noRelative,g=e.noIsolation,v=e.inert,y=e.allowPinchZoom,w=e.as,b=w===void 0?"div":w,j=e.gapMode,S=zu(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),N=p,C=xv([s,n]),R=Tt(Tt({},S),r);return l.createElement(l.Fragment,null,u&&l.createElement(N,{sideCar:Fu,removeScrollBar:m,shards:f,noRelative:h,noIsolation:g,inert:v,setCallbacks:a,allowPinchZoom:!!y,lockRef:s,gapMode:j}),i?l.cloneElement(l.Children.only(c),Tt(Tt({},R),{ref:C})):l.createElement(b,Tt({},R,{className:d,ref:C}),c))});Sr.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Sr.classNames={fullWidth:Po,zeroRight:Io};var wv=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function jv(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var n=wv();return n&&e.setAttribute("nonce",n),e}function Sv(e,n){e.styleSheet?e.styleSheet.cssText=n:e.appendChild(document.createTextNode(n))}function Nv(e){var n=document.head||document.getElementsByTagName("head")[0];n.appendChild(e)}var Cv=function(){var e=0,n=null;return{add:function(s){e==0&&(n=jv())&&(Sv(n,s),Nv(n)),e++},remove:function(){e--,!e&&n&&(n.parentNode&&n.parentNode.removeChild(n),n=null)}}},kv=function(){var e=Cv();return function(n,s){l.useEffect(function(){return e.add(n),function(){e.remove()}},[n&&s])}},Uu=function(){var e=kv(),n=function(s){var o=s.styles,r=s.dynamic;return e(o,r),null};return n},_v={left:0,top:0,right:0,gap:0},aa=function(e){return parseInt(e||"",10)||0},Tv=function(e){var n=window.getComputedStyle(document.body),s=n[e==="padding"?"paddingLeft":"marginLeft"],o=n[e==="padding"?"paddingTop":"marginTop"],r=n[e==="padding"?"paddingRight":"marginRight"];return[aa(s),aa(o),aa(r)]},Ev=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return _v;var n=Tv(e),s=document.documentElement.clientWidth,o=window.innerWidth;return{left:n[0],top:n[1],right:n[2],gap:Math.max(0,o-s+n[2]-n[0])}},Rv=Uu(),ts="data-scroll-locked",Mv=function(e,n,s,o){var r=e.left,a=e.top,i=e.right,c=e.gap;return s===void 0&&(s="margin"),`
|
|
3
|
-
.`.concat(mv,` {
|
|
4
|
-
overflow: hidden `).concat(o,`;
|
|
5
|
-
padding-right: `).concat(c,"px ").concat(o,`;
|
|
6
|
-
}
|
|
7
|
-
body[`).concat(ts,`] {
|
|
8
|
-
overflow: hidden `).concat(o,`;
|
|
9
|
-
overscroll-behavior: contain;
|
|
10
|
-
`).concat([n&&"position: relative ".concat(o,";"),s==="margin"&&`
|
|
11
|
-
padding-left: `.concat(r,`px;
|
|
12
|
-
padding-top: `).concat(a,`px;
|
|
13
|
-
padding-right: `).concat(i,`px;
|
|
14
|
-
margin-left:0;
|
|
15
|
-
margin-top:0;
|
|
16
|
-
margin-right: `).concat(c,"px ").concat(o,`;
|
|
17
|
-
`),s==="padding"&&"padding-right: ".concat(c,"px ").concat(o,";")].filter(Boolean).join(""),`
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.`).concat(Io,` {
|
|
21
|
-
right: `).concat(c,"px ").concat(o,`;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.`).concat(Po,` {
|
|
25
|
-
margin-right: `).concat(c,"px ").concat(o,`;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.`).concat(Io," .").concat(Io,` {
|
|
29
|
-
right: 0 `).concat(o,`;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.`).concat(Po," .").concat(Po,` {
|
|
33
|
-
margin-right: 0 `).concat(o,`;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
body[`).concat(ts,`] {
|
|
37
|
-
`).concat(fv,": ").concat(c,`px;
|
|
38
|
-
}
|
|
39
|
-
`)},ic=function(){var e=parseInt(document.body.getAttribute(ts)||"0",10);return isFinite(e)?e:0},Av=function(){l.useEffect(function(){return document.body.setAttribute(ts,(ic()+1).toString()),function(){var e=ic()-1;e<=0?document.body.removeAttribute(ts):document.body.setAttribute(ts,e.toString())}},[])},Iv=function(e){var n=e.noRelative,s=e.noImportant,o=e.gapMode,r=o===void 0?"margin":o;Av();var a=l.useMemo(function(){return Ev(r)},[r]);return l.createElement(Rv,{styles:Mv(a,!n,r,s?"":"!important")})},Xa=!1;if(typeof window<"u")try{var co=Object.defineProperty({},"passive",{get:function(){return Xa=!0,!0}});window.addEventListener("test",co,co),window.removeEventListener("test",co,co)}catch{Xa=!1}var Bn=Xa?{passive:!1}:!1,Pv=function(e){return e.tagName==="TEXTAREA"},Bu=function(e,n){if(!(e instanceof Element))return!1;var s=window.getComputedStyle(e);return s[n]!=="hidden"&&!(s.overflowY===s.overflowX&&!Pv(e)&&s[n]==="visible")},Lv=function(e){return Bu(e,"overflowY")},Ov=function(e){return Bu(e,"overflowX")},lc=function(e,n){var s=n.ownerDocument,o=n;do{typeof ShadowRoot<"u"&&o instanceof ShadowRoot&&(o=o.host);var r=qu(e,o);if(r){var a=Hu(e,o),i=a[1],c=a[2];if(i>c)return!0}o=o.parentNode}while(o&&o!==s.body);return!1},Dv=function(e){var n=e.scrollTop,s=e.scrollHeight,o=e.clientHeight;return[n,s,o]},zv=function(e){var n=e.scrollLeft,s=e.scrollWidth,o=e.clientWidth;return[n,s,o]},qu=function(e,n){return e==="v"?Lv(n):Ov(n)},Hu=function(e,n){return e==="v"?Dv(n):zv(n)},$v=function(e,n){return e==="h"&&n==="rtl"?-1:1},Fv=function(e,n,s,o,r){var a=$v(e,window.getComputedStyle(n).direction),i=a*o,c=s.target,d=n.contains(c),m=!1,u=i>0,f=0,p=0;do{if(!c)break;var h=Hu(e,c),g=h[0],v=h[1],y=h[2],w=v-y-a*g;(g||w)&&qu(e,c)&&(f+=w,p+=g);var b=c.parentNode;c=b&&b.nodeType===Node.DOCUMENT_FRAGMENT_NODE?b.host:b}while(!d&&c!==document.body||d&&(n.contains(c)||n===c));return(u&&Math.abs(f)<1||!u&&Math.abs(p)<1)&&(m=!0),m},uo=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},cc=function(e){return[e.deltaX,e.deltaY]},dc=function(e){return e&&"current"in e?e.current:e},Uv=function(e,n){return e[0]===n[0]&&e[1]===n[1]},Bv=function(e){return`
|
|
40
|
-
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
41
|
-
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
42
|
-
`)},qv=0,qn=[];function Hv(e){var n=l.useRef([]),s=l.useRef([0,0]),o=l.useRef(),r=l.useState(qv++)[0],a=l.useState(Uu)[0],i=l.useRef(e);l.useEffect(function(){i.current=e},[e]),l.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(r));var v=uv([e.lockRef.current],(e.shards||[]).map(dc),!0).filter(Boolean);return v.forEach(function(y){return y.classList.add("allow-interactivity-".concat(r))}),function(){document.body.classList.remove("block-interactivity-".concat(r)),v.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(r))})}}},[e.inert,e.lockRef.current,e.shards]);var c=l.useCallback(function(v,y){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!i.current.allowPinchZoom;var w=uo(v),b=s.current,j="deltaX"in v?v.deltaX:b[0]-w[0],S="deltaY"in v?v.deltaY:b[1]-w[1],N,C=v.target,R=Math.abs(j)>Math.abs(S)?"h":"v";if("touches"in v&&R==="h"&&C.type==="range")return!1;var I=window.getSelection(),P=I&&I.anchorNode,M=P?P===C||P.contains(C):!1;if(M)return!1;var k=lc(R,C);if(!k)return!0;if(k?N=R:(N=R==="v"?"h":"v",k=lc(R,C)),!k)return!1;if(!o.current&&"changedTouches"in v&&(j||S)&&(o.current=N),!N)return!0;var A=o.current||N;return Fv(A,y,v,A==="h"?j:S)},[]),d=l.useCallback(function(v){var y=v;if(!(!qn.length||qn[qn.length-1]!==a)){var w="deltaY"in y?cc(y):uo(y),b=n.current.filter(function(N){return N.name===y.type&&(N.target===y.target||y.target===N.shadowParent)&&Uv(N.delta,w)})[0];if(b&&b.should){y.cancelable&&y.preventDefault();return}if(!b){var j=(i.current.shards||[]).map(dc).filter(Boolean).filter(function(N){return N.contains(y.target)}),S=j.length>0?c(y,j[0]):!i.current.noIsolation;S&&y.cancelable&&y.preventDefault()}}},[]),m=l.useCallback(function(v,y,w,b){var j={name:v,delta:y,target:w,should:b,shadowParent:Wv(w)};n.current.push(j),setTimeout(function(){n.current=n.current.filter(function(S){return S!==j})},1)},[]),u=l.useCallback(function(v){s.current=uo(v),o.current=void 0},[]),f=l.useCallback(function(v){m(v.type,cc(v),v.target,c(v,e.lockRef.current))},[]),p=l.useCallback(function(v){m(v.type,uo(v),v.target,c(v,e.lockRef.current))},[]);l.useEffect(function(){return qn.push(a),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:p}),document.addEventListener("wheel",d,Bn),document.addEventListener("touchmove",d,Bn),document.addEventListener("touchstart",u,Bn),function(){qn=qn.filter(function(v){return v!==a}),document.removeEventListener("wheel",d,Bn),document.removeEventListener("touchmove",d,Bn),document.removeEventListener("touchstart",u,Bn)}},[]);var h=e.removeScrollBar,g=e.inert;return l.createElement(l.Fragment,null,g?l.createElement(a,{styles:Bv(r)}):null,h?l.createElement(Iv,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Wv(e){for(var n=null;e!==null;)e instanceof ShadowRoot&&(n=e.host,e=e.host),e=e.parentNode;return n}const Vv=yv(Fu,Hv);var tl=l.forwardRef(function(e,n){return l.createElement(Sr,Tt({},e,{ref:n,sideCar:Vv}))});tl.classNames=Sr.classNames;var Kv=function(e){if(typeof document>"u")return null;var n=Array.isArray(e)?e[0]:e;return n.ownerDocument.body},Hn=new WeakMap,mo=new WeakMap,fo={},ia=0,Wu=function(e){return e&&(e.host||Wu(e.parentNode))},Gv=function(e,n){return n.map(function(s){if(e.contains(s))return s;var o=Wu(s);return o&&e.contains(o)?o:(console.error("aria-hidden",s,"in not contained inside",e,". Doing nothing"),null)}).filter(function(s){return!!s})},Yv=function(e,n,s,o){var r=Gv(n,Array.isArray(e)?e:[e]);fo[s]||(fo[s]=new WeakMap);var a=fo[s],i=[],c=new Set,d=new Set(r),m=function(f){!f||c.has(f)||(c.add(f),m(f.parentNode))};r.forEach(m);var u=function(f){!f||d.has(f)||Array.prototype.forEach.call(f.children,function(p){if(c.has(p))u(p);else try{var h=p.getAttribute(o),g=h!==null&&h!=="false",v=(Hn.get(p)||0)+1,y=(a.get(p)||0)+1;Hn.set(p,v),a.set(p,y),i.push(p),v===1&&g&&mo.set(p,!0),y===1&&p.setAttribute(s,"true"),g||p.setAttribute(o,"true")}catch(w){console.error("aria-hidden: cannot operate on ",p,w)}})};return u(n),c.clear(),ia++,function(){i.forEach(function(f){var p=Hn.get(f)-1,h=a.get(f)-1;Hn.set(f,p),a.set(f,h),p||(mo.has(f)||f.removeAttribute(o),mo.delete(f)),h||f.removeAttribute(s)}),ia--,ia||(Hn=new WeakMap,Hn=new WeakMap,mo=new WeakMap,fo={})}},Vu=function(e,n,s){s===void 0&&(s="data-aria-hidden");var o=Array.from(Array.isArray(e)?e:[e]),r=Kv(e);return r?(o.push.apply(o,Array.from(r.querySelectorAll("[aria-live], script"))),Yv(o,r,s,"aria-hidden")):function(){return null}},Nr="Dialog",[Ku]=Jt(Nr),[Jv,Nt]=Ku(Nr),Gu=e=>{const{__scopeDialog:n,children:s,open:o,defaultOpen:r,onOpenChange:a,modal:i=!0}=e,c=l.useRef(null),d=l.useRef(null),[m,u]=Rn({prop:o,defaultProp:r??!1,onChange:a,caller:Nr});return t.jsx(Jv,{scope:n,triggerRef:c,contentRef:d,contentId:Mt(),titleId:Mt(),descriptionId:Mt(),open:m,onOpenChange:u,onOpenToggle:l.useCallback(()=>u(f=>!f),[u]),modal:i,children:s})};Gu.displayName=Nr;var Yu="DialogTrigger",Ju=l.forwardRef((e,n)=>{const{__scopeDialog:s,...o}=e,r=Nt(Yu,s),a=Ee(n,r.triggerRef);return t.jsx(xe.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.open?r.contentId:void 0,"data-state":sl(r.open),...o,ref:a,onClick:ie(e.onClick,r.onOpenToggle)})});Ju.displayName=Yu;var nl="DialogPortal",[Xv,Xu]=Ku(nl,{forceMount:void 0}),Zu=e=>{const{__scopeDialog:n,forceMount:s,children:o,container:r}=e,a=Nt(nl,n);return t.jsx(Xv,{scope:n,forceMount:s,children:l.Children.map(o,i=>t.jsx(dt,{present:s||a.open,children:t.jsx(jr,{asChild:!0,container:r,children:i})}))})};Zu.displayName=nl;var Yo="DialogOverlay",Qu=l.forwardRef((e,n)=>{const s=Xu(Yo,e.__scopeDialog),{forceMount:o=s.forceMount,...r}=e,a=Nt(Yo,e.__scopeDialog);return a.modal?t.jsx(dt,{present:o||a.open,children:t.jsx(Qv,{...r,ref:n})}):null});Qu.displayName=Yo;var Zv=ls("DialogOverlay.RemoveScroll"),Qv=l.forwardRef((e,n)=>{const{__scopeDialog:s,...o}=e,r=Nt(Yo,s),a=Qb(),i=Ee(n,a);return t.jsx(tl,{as:Zv,allowPinchZoom:!0,shards:[r.contentRef],children:t.jsx(xe.div,{"data-state":sl(r.open),...o,ref:i,style:{pointerEvents:"auto",...o.style}})})}),cs="DialogContent",em=l.forwardRef((e,n)=>{const s=Xu(cs,e.__scopeDialog),{forceMount:o=s.forceMount,...r}=e,a=Nt(cs,e.__scopeDialog);return t.jsx(dt,{present:o||a.open,children:a.modal?t.jsx(e2,{...r,ref:n}):t.jsx(t2,{...r,ref:n})})});em.displayName=cs;var e2=l.forwardRef((e,n)=>{const s=Nt(cs,e.__scopeDialog),o=l.useRef(null),r=Ee(n,s.contentRef,o);return l.useEffect(()=>{const a=o.current;if(a)return Vu(a)},[]),t.jsx(tm,{...e,ref:r,trapFocus:s.open,disableOutsidePointerEvents:s.open,onCloseAutoFocus:ie(e.onCloseAutoFocus,a=>{a.preventDefault(),s.triggerRef.current?.focus()}),onPointerDownOutside:ie(e.onPointerDownOutside,a=>{const i=a.detail.originalEvent,c=i.button===0&&i.ctrlKey===!0;(i.button===2||c)&&a.preventDefault()}),onFocusOutside:ie(e.onFocusOutside,a=>a.preventDefault())})}),t2=l.forwardRef((e,n)=>{const s=Nt(cs,e.__scopeDialog),o=l.useRef(!1),r=l.useRef(!1);return t.jsx(tm,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{e.onCloseAutoFocus?.(a),a.defaultPrevented||(o.current||s.triggerRef.current?.focus(),a.preventDefault()),o.current=!1,r.current=!1},onInteractOutside:a=>{e.onInteractOutside?.(a),a.defaultPrevented||(o.current=!0,a.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const i=a.target;s.triggerRef.current?.contains(i)&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&r.current&&a.preventDefault()}})}),tm=l.forwardRef((e,n)=>{const{__scopeDialog:s,trapFocus:o,onOpenAutoFocus:r,onCloseAutoFocus:a,...i}=e,c=Nt(cs,s);return Du(),t.jsx(t.Fragment,{children:t.jsx(el,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:r,onUnmountAutoFocus:a,children:t.jsx(wr,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":sl(c.open),...i,ref:n,deferPointerDownOutside:!0,onDismiss:()=>c.onOpenChange(!1)})})})}),nm="DialogTitle",sm=l.forwardRef((e,n)=>{const{__scopeDialog:s,...o}=e,r=Nt(nm,s);return t.jsx(xe.h2,{id:r.titleId,...o,ref:n})});sm.displayName=nm;var om="DialogDescription",rm=l.forwardRef((e,n)=>{const{__scopeDialog:s,...o}=e,r=Nt(om,s);return t.jsx(xe.p,{id:r.descriptionId,...o,ref:n})});rm.displayName=om;var am="DialogClose",im=l.forwardRef((e,n)=>{const{__scopeDialog:s,...o}=e,r=Nt(am,s);return t.jsx(xe.button,{type:"button",...o,ref:n,onClick:ie(e.onClick,()=>r.onOpenChange(!1))})});im.displayName=am;function sl(e){return e?"open":"closed"}function n2(e){const n=l.useRef({value:e,previous:e});return l.useMemo(()=>(n.current.value!==e&&(n.current.previous=n.current.value,n.current.value=e),n.current.previous),[e])}function s2(e){const[n,s]=l.useState(void 0);return ze(()=>{if(e){s({width:e.offsetWidth,height:e.offsetHeight});const o=new ResizeObserver(r=>{if(!Array.isArray(r)||!r.length)return;const a=r[0];let i,c;if("borderBoxSize"in a){const d=a.borderBoxSize,m=Array.isArray(d)?d[0]:d;i=m.inlineSize,c=m.blockSize}else i=e.offsetWidth,c=e.offsetHeight;s({width:i,height:c})});return o.observe(e,{box:"border-box"}),()=>o.unobserve(e)}else s(void 0)},[e]),n}const o2=["top","right","bottom","left"],un=Math.min,rt=Math.max,Jo=Math.round,po=Math.floor,At=e=>({x:e,y:e}),r2={left:"right",right:"left",bottom:"top",top:"bottom"},a2={start:"end",end:"start"};function Za(e,n,s){return rt(e,un(n,s))}function Kt(e,n){return typeof e=="function"?e(n):e}function Gt(e){return e.split("-")[0]}function xs(e){return e.split("-")[1]}function ol(e){return e==="x"?"y":"x"}function rl(e){return e==="y"?"height":"width"}const i2=new Set(["top","bottom"]);function Et(e){return i2.has(Gt(e))?"y":"x"}function al(e){return ol(Et(e))}function l2(e,n,s){s===void 0&&(s=!1);const o=xs(e),r=al(e),a=rl(r);let i=r==="x"?o===(s?"end":"start")?"right":"left":o==="start"?"bottom":"top";return n.reference[a]>n.floating[a]&&(i=Xo(i)),[i,Xo(i)]}function c2(e){const n=Xo(e);return[Qa(e),n,Qa(n)]}function Qa(e){return e.replace(/start|end/g,n=>a2[n])}const uc=["left","right"],mc=["right","left"],d2=["top","bottom"],u2=["bottom","top"];function m2(e,n,s){switch(e){case"top":case"bottom":return s?n?mc:uc:n?uc:mc;case"left":case"right":return n?d2:u2;default:return[]}}function f2(e,n,s,o){const r=xs(e);let a=m2(Gt(e),s==="start",o);return r&&(a=a.map(i=>i+"-"+r),n&&(a=a.concat(a.map(Qa)))),a}function Xo(e){return e.replace(/left|right|bottom|top/g,n=>r2[n])}function p2(e){return{top:0,right:0,bottom:0,left:0,...e}}function lm(e){return typeof e!="number"?p2(e):{top:e,right:e,bottom:e,left:e}}function Zo(e){const{x:n,y:s,width:o,height:r}=e;return{width:o,height:r,top:s,left:n,right:n+o,bottom:s+r,x:n,y:s}}function fc(e,n,s){let{reference:o,floating:r}=e;const a=Et(n),i=al(n),c=rl(i),d=Gt(n),m=a==="y",u=o.x+o.width/2-r.width/2,f=o.y+o.height/2-r.height/2,p=o[c]/2-r[c]/2;let h;switch(d){case"top":h={x:u,y:o.y-r.height};break;case"bottom":h={x:u,y:o.y+o.height};break;case"right":h={x:o.x+o.width,y:f};break;case"left":h={x:o.x-r.width,y:f};break;default:h={x:o.x,y:o.y}}switch(xs(n)){case"start":h[i]-=p*(s&&m?-1:1);break;case"end":h[i]+=p*(s&&m?-1:1);break}return h}async function h2(e,n){var s;n===void 0&&(n={});const{x:o,y:r,platform:a,rects:i,elements:c,strategy:d}=e,{boundary:m="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:p=!1,padding:h=0}=Kt(n,e),g=lm(h),y=c[p?f==="floating"?"reference":"floating":f],w=Zo(await a.getClippingRect({element:(s=await(a.isElement==null?void 0:a.isElement(y)))==null||s?y:y.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(c.floating)),boundary:m,rootBoundary:u,strategy:d})),b=f==="floating"?{x:o,y:r,width:i.floating.width,height:i.floating.height}:i.reference,j=await(a.getOffsetParent==null?void 0:a.getOffsetParent(c.floating)),S=await(a.isElement==null?void 0:a.isElement(j))?await(a.getScale==null?void 0:a.getScale(j))||{x:1,y:1}:{x:1,y:1},N=Zo(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:b,offsetParent:j,strategy:d}):b);return{top:(w.top-N.top+g.top)/S.y,bottom:(N.bottom-w.bottom+g.bottom)/S.y,left:(w.left-N.left+g.left)/S.x,right:(N.right-w.right+g.right)/S.x}}const x2=async(e,n,s)=>{const{placement:o="bottom",strategy:r="absolute",middleware:a=[],platform:i}=s,c=a.filter(Boolean),d=await(i.isRTL==null?void 0:i.isRTL(n));let m=await i.getElementRects({reference:e,floating:n,strategy:r}),{x:u,y:f}=fc(m,o,d),p=o,h={},g=0;for(let y=0;y<c.length;y++){var v;const{name:w,fn:b}=c[y],{x:j,y:S,data:N,reset:C}=await b({x:u,y:f,initialPlacement:o,placement:p,strategy:r,middlewareData:h,rects:m,platform:{...i,detectOverflow:(v=i.detectOverflow)!=null?v:h2},elements:{reference:e,floating:n}});u=j??u,f=S??f,h={...h,[w]:{...h[w],...N}},C&&g<=50&&(g++,typeof C=="object"&&(C.placement&&(p=C.placement),C.rects&&(m=C.rects===!0?await i.getElementRects({reference:e,floating:n,strategy:r}):C.rects),{x:u,y:f}=fc(m,p,d)),y=-1)}return{x:u,y:f,placement:p,strategy:r,middlewareData:h}},g2=e=>({name:"arrow",options:e,async fn(n){const{x:s,y:o,placement:r,rects:a,platform:i,elements:c,middlewareData:d}=n,{element:m,padding:u=0}=Kt(e,n)||{};if(m==null)return{};const f=lm(u),p={x:s,y:o},h=al(r),g=rl(h),v=await i.getDimensions(m),y=h==="y",w=y?"top":"left",b=y?"bottom":"right",j=y?"clientHeight":"clientWidth",S=a.reference[g]+a.reference[h]-p[h]-a.floating[g],N=p[h]-a.reference[h],C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(m));let R=C?C[j]:0;(!R||!await(i.isElement==null?void 0:i.isElement(C)))&&(R=c.floating[j]||a.floating[g]);const I=S/2-N/2,P=R/2-v[g]/2-1,M=un(f[w],P),k=un(f[b],P),A=M,D=R-v[g]-k,$=R/2-v[g]/2+I,Y=Za(A,$,D),Q=!d.arrow&&xs(r)!=null&&$!==Y&&a.reference[g]/2-($<A?M:k)-v[g]/2<0,U=Q?$<A?$-A:$-D:0;return{[h]:p[h]+U,data:{[h]:Y,centerOffset:$-Y-U,...Q&&{alignmentOffset:U}},reset:Q}}}),b2=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(n){var s,o;const{placement:r,middlewareData:a,rects:i,initialPlacement:c,platform:d,elements:m}=n,{mainAxis:u=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:v=!0,...y}=Kt(e,n);if((s=a.arrow)!=null&&s.alignmentOffset)return{};const w=Gt(r),b=Et(c),j=Gt(c)===c,S=await(d.isRTL==null?void 0:d.isRTL(m.floating)),N=p||(j||!v?[Xo(c)]:c2(c)),C=g!=="none";!p&&C&&N.push(...f2(c,v,g,S));const R=[c,...N],I=await d.detectOverflow(n,y),P=[];let M=((o=a.flip)==null?void 0:o.overflows)||[];if(u&&P.push(I[w]),f){const $=l2(r,i,S);P.push(I[$[0]],I[$[1]])}if(M=[...M,{placement:r,overflows:P}],!P.every($=>$<=0)){var k,A;const $=(((k=a.flip)==null?void 0:k.index)||0)+1,Y=R[$];if(Y&&(!(f==="alignment"?b!==Et(Y):!1)||M.every(H=>Et(H.placement)===b?H.overflows[0]>0:!0)))return{data:{index:$,overflows:M},reset:{placement:Y}};let Q=(A=M.filter(U=>U.overflows[0]<=0).sort((U,H)=>U.overflows[1]-H.overflows[1])[0])==null?void 0:A.placement;if(!Q)switch(h){case"bestFit":{var D;const U=(D=M.filter(H=>{if(C){const X=Et(H.placement);return X===b||X==="y"}return!0}).map(H=>[H.placement,H.overflows.filter(X=>X>0).reduce((X,B)=>X+B,0)]).sort((H,X)=>H[1]-X[1])[0])==null?void 0:D[0];U&&(Q=U);break}case"initialPlacement":Q=c;break}if(r!==Q)return{reset:{placement:Q}}}return{}}}};function pc(e,n){return{top:e.top-n.height,right:e.right-n.width,bottom:e.bottom-n.height,left:e.left-n.width}}function hc(e){return o2.some(n=>e[n]>=0)}const v2=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(n){const{rects:s,platform:o}=n,{strategy:r="referenceHidden",...a}=Kt(e,n);switch(r){case"referenceHidden":{const i=await o.detectOverflow(n,{...a,elementContext:"reference"}),c=pc(i,s.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:hc(c)}}}case"escaped":{const i=await o.detectOverflow(n,{...a,altBoundary:!0}),c=pc(i,s.floating);return{data:{escapedOffsets:c,escaped:hc(c)}}}default:return{}}}}},cm=new Set(["left","top"]);async function y2(e,n){const{placement:s,platform:o,elements:r}=e,a=await(o.isRTL==null?void 0:o.isRTL(r.floating)),i=Gt(s),c=xs(s),d=Et(s)==="y",m=cm.has(i)?-1:1,u=a&&d?-1:1,f=Kt(n,e);let{mainAxis:p,crossAxis:h,alignmentAxis:g}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return c&&typeof g=="number"&&(h=c==="end"?g*-1:g),d?{x:h*u,y:p*m}:{x:p*m,y:h*u}}const w2=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(n){var s,o;const{x:r,y:a,placement:i,middlewareData:c}=n,d=await y2(n,e);return i===((s=c.offset)==null?void 0:s.placement)&&(o=c.arrow)!=null&&o.alignmentOffset?{}:{x:r+d.x,y:a+d.y,data:{...d,placement:i}}}}},j2=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(n){const{x:s,y:o,placement:r,platform:a}=n,{mainAxis:i=!0,crossAxis:c=!1,limiter:d={fn:w=>{let{x:b,y:j}=w;return{x:b,y:j}}},...m}=Kt(e,n),u={x:s,y:o},f=await a.detectOverflow(n,m),p=Et(Gt(r)),h=ol(p);let g=u[h],v=u[p];if(i){const w=h==="y"?"top":"left",b=h==="y"?"bottom":"right",j=g+f[w],S=g-f[b];g=Za(j,g,S)}if(c){const w=p==="y"?"top":"left",b=p==="y"?"bottom":"right",j=v+f[w],S=v-f[b];v=Za(j,v,S)}const y=d.fn({...n,[h]:g,[p]:v});return{...y,data:{x:y.x-s,y:y.y-o,enabled:{[h]:i,[p]:c}}}}}},S2=function(e){return e===void 0&&(e={}),{options:e,fn(n){const{x:s,y:o,placement:r,rects:a,middlewareData:i}=n,{offset:c=0,mainAxis:d=!0,crossAxis:m=!0}=Kt(e,n),u={x:s,y:o},f=Et(r),p=ol(f);let h=u[p],g=u[f];const v=Kt(c,n),y=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(d){const j=p==="y"?"height":"width",S=a.reference[p]-a.floating[j]+y.mainAxis,N=a.reference[p]+a.reference[j]-y.mainAxis;h<S?h=S:h>N&&(h=N)}if(m){var w,b;const j=p==="y"?"width":"height",S=cm.has(Gt(r)),N=a.reference[f]-a.floating[j]+(S&&((w=i.offset)==null?void 0:w[f])||0)+(S?0:y.crossAxis),C=a.reference[f]+a.reference[j]+(S?0:((b=i.offset)==null?void 0:b[f])||0)-(S?y.crossAxis:0);g<N?g=N:g>C&&(g=C)}return{[p]:h,[f]:g}}}},N2=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(n){var s,o;const{placement:r,rects:a,platform:i,elements:c}=n,{apply:d=()=>{},...m}=Kt(e,n),u=await i.detectOverflow(n,m),f=Gt(r),p=xs(r),h=Et(r)==="y",{width:g,height:v}=a.floating;let y,w;f==="top"||f==="bottom"?(y=f,w=p===(await(i.isRTL==null?void 0:i.isRTL(c.floating))?"start":"end")?"left":"right"):(w=f,y=p==="end"?"top":"bottom");const b=v-u.top-u.bottom,j=g-u.left-u.right,S=un(v-u[y],b),N=un(g-u[w],j),C=!n.middlewareData.shift;let R=S,I=N;if((s=n.middlewareData.shift)!=null&&s.enabled.x&&(I=j),(o=n.middlewareData.shift)!=null&&o.enabled.y&&(R=b),C&&!p){const M=rt(u.left,0),k=rt(u.right,0),A=rt(u.top,0),D=rt(u.bottom,0);h?I=g-2*(M!==0||k!==0?M+k:rt(u.left,u.right)):R=v-2*(A!==0||D!==0?A+D:rt(u.top,u.bottom))}await d({...n,availableWidth:I,availableHeight:R});const P=await i.getDimensions(c.floating);return g!==P.width||v!==P.height?{reset:{rects:!0}}:{}}}};function Cr(){return typeof window<"u"}function gs(e){return dm(e)?(e.nodeName||"").toLowerCase():"#document"}function lt(e){var n;return(e==null||(n=e.ownerDocument)==null?void 0:n.defaultView)||window}function $t(e){var n;return(n=(dm(e)?e.ownerDocument:e.document)||window.document)==null?void 0:n.documentElement}function dm(e){return Cr()?e instanceof Node||e instanceof lt(e).Node:!1}function wt(e){return Cr()?e instanceof Element||e instanceof lt(e).Element:!1}function Pt(e){return Cr()?e instanceof HTMLElement||e instanceof lt(e).HTMLElement:!1}function xc(e){return!Cr()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof lt(e).ShadowRoot}const C2=new Set(["inline","contents"]);function Xs(e){const{overflow:n,overflowX:s,overflowY:o,display:r}=jt(e);return/auto|scroll|overlay|hidden|clip/.test(n+o+s)&&!C2.has(r)}const k2=new Set(["table","td","th"]);function _2(e){return k2.has(gs(e))}const T2=[":popover-open",":modal"];function kr(e){return T2.some(n=>{try{return e.matches(n)}catch{return!1}})}const E2=["transform","translate","scale","rotate","perspective"],R2=["transform","translate","scale","rotate","perspective","filter"],M2=["paint","layout","strict","content"];function il(e){const n=ll(),s=wt(e)?jt(e):e;return E2.some(o=>s[o]?s[o]!=="none":!1)||(s.containerType?s.containerType!=="normal":!1)||!n&&(s.backdropFilter?s.backdropFilter!=="none":!1)||!n&&(s.filter?s.filter!=="none":!1)||R2.some(o=>(s.willChange||"").includes(o))||M2.some(o=>(s.contain||"").includes(o))}function A2(e){let n=mn(e);for(;Pt(n)&&!ds(n);){if(il(n))return n;if(kr(n))return null;n=mn(n)}return null}function ll(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const I2=new Set(["html","body","#document"]);function ds(e){return I2.has(gs(e))}function jt(e){return lt(e).getComputedStyle(e)}function _r(e){return wt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function mn(e){if(gs(e)==="html")return e;const n=e.assignedSlot||e.parentNode||xc(e)&&e.host||$t(e);return xc(n)?n.host:n}function um(e){const n=mn(e);return ds(n)?e.ownerDocument?e.ownerDocument.body:e.body:Pt(n)&&Xs(n)?n:um(n)}function zs(e,n,s){var o;n===void 0&&(n=[]),s===void 0&&(s=!0);const r=um(e),a=r===((o=e.ownerDocument)==null?void 0:o.body),i=lt(r);if(a){const c=ei(i);return n.concat(i,i.visualViewport||[],Xs(r)?r:[],c&&s?zs(c):[])}return n.concat(r,zs(r,[],s))}function ei(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function mm(e){const n=jt(e);let s=parseFloat(n.width)||0,o=parseFloat(n.height)||0;const r=Pt(e),a=r?e.offsetWidth:s,i=r?e.offsetHeight:o,c=Jo(s)!==a||Jo(o)!==i;return c&&(s=a,o=i),{width:s,height:o,$:c}}function cl(e){return wt(e)?e:e.contextElement}function ns(e){const n=cl(e);if(!Pt(n))return At(1);const s=n.getBoundingClientRect(),{width:o,height:r,$:a}=mm(n);let i=(a?Jo(s.width):s.width)/o,c=(a?Jo(s.height):s.height)/r;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const P2=At(0);function fm(e){const n=lt(e);return!ll()||!n.visualViewport?P2:{x:n.visualViewport.offsetLeft,y:n.visualViewport.offsetTop}}function L2(e,n,s){return n===void 0&&(n=!1),!s||n&&s!==lt(e)?!1:n}function Mn(e,n,s,o){n===void 0&&(n=!1),s===void 0&&(s=!1);const r=e.getBoundingClientRect(),a=cl(e);let i=At(1);n&&(o?wt(o)&&(i=ns(o)):i=ns(e));const c=L2(a,s,o)?fm(a):At(0);let d=(r.left+c.x)/i.x,m=(r.top+c.y)/i.y,u=r.width/i.x,f=r.height/i.y;if(a){const p=lt(a),h=o&&wt(o)?lt(o):o;let g=p,v=ei(g);for(;v&&o&&h!==g;){const y=ns(v),w=v.getBoundingClientRect(),b=jt(v),j=w.left+(v.clientLeft+parseFloat(b.paddingLeft))*y.x,S=w.top+(v.clientTop+parseFloat(b.paddingTop))*y.y;d*=y.x,m*=y.y,u*=y.x,f*=y.y,d+=j,m+=S,g=lt(v),v=ei(g)}}return Zo({width:u,height:f,x:d,y:m})}function Tr(e,n){const s=_r(e).scrollLeft;return n?n.left+s:Mn($t(e)).left+s}function pm(e,n){const s=e.getBoundingClientRect(),o=s.left+n.scrollLeft-Tr(e,s),r=s.top+n.scrollTop;return{x:o,y:r}}function O2(e){let{elements:n,rect:s,offsetParent:o,strategy:r}=e;const a=r==="fixed",i=$t(o),c=n?kr(n.floating):!1;if(o===i||c&&a)return s;let d={scrollLeft:0,scrollTop:0},m=At(1);const u=At(0),f=Pt(o);if((f||!f&&!a)&&((gs(o)!=="body"||Xs(i))&&(d=_r(o)),Pt(o))){const h=Mn(o);m=ns(o),u.x=h.x+o.clientLeft,u.y=h.y+o.clientTop}const p=i&&!f&&!a?pm(i,d):At(0);return{width:s.width*m.x,height:s.height*m.y,x:s.x*m.x-d.scrollLeft*m.x+u.x+p.x,y:s.y*m.y-d.scrollTop*m.y+u.y+p.y}}function D2(e){return Array.from(e.getClientRects())}function z2(e){const n=$t(e),s=_r(e),o=e.ownerDocument.body,r=rt(n.scrollWidth,n.clientWidth,o.scrollWidth,o.clientWidth),a=rt(n.scrollHeight,n.clientHeight,o.scrollHeight,o.clientHeight);let i=-s.scrollLeft+Tr(e);const c=-s.scrollTop;return jt(o).direction==="rtl"&&(i+=rt(n.clientWidth,o.clientWidth)-r),{width:r,height:a,x:i,y:c}}const gc=25;function $2(e,n){const s=lt(e),o=$t(e),r=s.visualViewport;let a=o.clientWidth,i=o.clientHeight,c=0,d=0;if(r){a=r.width,i=r.height;const u=ll();(!u||u&&n==="fixed")&&(c=r.offsetLeft,d=r.offsetTop)}const m=Tr(o);if(m<=0){const u=o.ownerDocument,f=u.body,p=getComputedStyle(f),h=u.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,g=Math.abs(o.clientWidth-f.clientWidth-h);g<=gc&&(a-=g)}else m<=gc&&(a+=m);return{width:a,height:i,x:c,y:d}}const F2=new Set(["absolute","fixed"]);function U2(e,n){const s=Mn(e,!0,n==="fixed"),o=s.top+e.clientTop,r=s.left+e.clientLeft,a=Pt(e)?ns(e):At(1),i=e.clientWidth*a.x,c=e.clientHeight*a.y,d=r*a.x,m=o*a.y;return{width:i,height:c,x:d,y:m}}function bc(e,n,s){let o;if(n==="viewport")o=$2(e,s);else if(n==="document")o=z2($t(e));else if(wt(n))o=U2(n,s);else{const r=fm(e);o={x:n.x-r.x,y:n.y-r.y,width:n.width,height:n.height}}return Zo(o)}function hm(e,n){const s=mn(e);return s===n||!wt(s)||ds(s)?!1:jt(s).position==="fixed"||hm(s,n)}function B2(e,n){const s=n.get(e);if(s)return s;let o=zs(e,[],!1).filter(c=>wt(c)&&gs(c)!=="body"),r=null;const a=jt(e).position==="fixed";let i=a?mn(e):e;for(;wt(i)&&!ds(i);){const c=jt(i),d=il(i);!d&&c.position==="fixed"&&(r=null),(a?!d&&!r:!d&&c.position==="static"&&!!r&&F2.has(r.position)||Xs(i)&&!d&&hm(e,i))?o=o.filter(u=>u!==i):r=c,i=mn(i)}return n.set(e,o),o}function q2(e){let{element:n,boundary:s,rootBoundary:o,strategy:r}=e;const i=[...s==="clippingAncestors"?kr(n)?[]:B2(n,this._c):[].concat(s),o],c=i[0],d=i.reduce((m,u)=>{const f=bc(n,u,r);return m.top=rt(f.top,m.top),m.right=un(f.right,m.right),m.bottom=un(f.bottom,m.bottom),m.left=rt(f.left,m.left),m},bc(n,c,r));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}}function H2(e){const{width:n,height:s}=mm(e);return{width:n,height:s}}function W2(e,n,s){const o=Pt(n),r=$t(n),a=s==="fixed",i=Mn(e,!0,a,n);let c={scrollLeft:0,scrollTop:0};const d=At(0);function m(){d.x=Tr(r)}if(o||!o&&!a)if((gs(n)!=="body"||Xs(r))&&(c=_r(n)),o){const h=Mn(n,!0,a,n);d.x=h.x+n.clientLeft,d.y=h.y+n.clientTop}else r&&m();a&&!o&&r&&m();const u=r&&!o&&!a?pm(r,c):At(0),f=i.left+c.scrollLeft-d.x-u.x,p=i.top+c.scrollTop-d.y-u.y;return{x:f,y:p,width:i.width,height:i.height}}function la(e){return jt(e).position==="static"}function vc(e,n){if(!Pt(e)||jt(e).position==="fixed")return null;if(n)return n(e);let s=e.offsetParent;return $t(e)===s&&(s=s.ownerDocument.body),s}function xm(e,n){const s=lt(e);if(kr(e))return s;if(!Pt(e)){let r=mn(e);for(;r&&!ds(r);){if(wt(r)&&!la(r))return r;r=mn(r)}return s}let o=vc(e,n);for(;o&&_2(o)&&la(o);)o=vc(o,n);return o&&ds(o)&&la(o)&&!il(o)?s:o||A2(e)||s}const V2=async function(e){const n=this.getOffsetParent||xm,s=this.getDimensions,o=await s(e.floating);return{reference:W2(e.reference,await n(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function K2(e){return jt(e).direction==="rtl"}const G2={convertOffsetParentRelativeRectToViewportRelativeRect:O2,getDocumentElement:$t,getClippingRect:q2,getOffsetParent:xm,getElementRects:V2,getClientRects:D2,getDimensions:H2,getScale:ns,isElement:wt,isRTL:K2};function gm(e,n){return e.x===n.x&&e.y===n.y&&e.width===n.width&&e.height===n.height}function Y2(e,n){let s=null,o;const r=$t(e);function a(){var c;clearTimeout(o),(c=s)==null||c.disconnect(),s=null}function i(c,d){c===void 0&&(c=!1),d===void 0&&(d=1),a();const m=e.getBoundingClientRect(),{left:u,top:f,width:p,height:h}=m;if(c||n(),!p||!h)return;const g=po(f),v=po(r.clientWidth-(u+p)),y=po(r.clientHeight-(f+h)),w=po(u),j={rootMargin:-g+"px "+-v+"px "+-y+"px "+-w+"px",threshold:rt(0,un(1,d))||1};let S=!0;function N(C){const R=C[0].intersectionRatio;if(R!==d){if(!S)return i();R?i(!1,R):o=setTimeout(()=>{i(!1,1e-7)},1e3)}R===1&&!gm(m,e.getBoundingClientRect())&&i(),S=!1}try{s=new IntersectionObserver(N,{...j,root:r.ownerDocument})}catch{s=new IntersectionObserver(N,j)}s.observe(e)}return i(!0),a}function J2(e,n,s,o){o===void 0&&(o={});const{ancestorScroll:r=!0,ancestorResize:a=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:d=!1}=o,m=cl(e),u=r||a?[...m?zs(m):[],...zs(n)]:[];u.forEach(w=>{r&&w.addEventListener("scroll",s,{passive:!0}),a&&w.addEventListener("resize",s)});const f=m&&c?Y2(m,s):null;let p=-1,h=null;i&&(h=new ResizeObserver(w=>{let[b]=w;b&&b.target===m&&h&&(h.unobserve(n),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var j;(j=h)==null||j.observe(n)})),s()}),m&&!d&&h.observe(m),h.observe(n));let g,v=d?Mn(e):null;d&&y();function y(){const w=Mn(e);v&&!gm(v,w)&&s(),v=w,g=requestAnimationFrame(y)}return s(),()=>{var w;u.forEach(b=>{r&&b.removeEventListener("scroll",s),a&&b.removeEventListener("resize",s)}),f?.(),(w=h)==null||w.disconnect(),h=null,d&&cancelAnimationFrame(g)}}const X2=w2,Z2=j2,Q2=b2,ey=N2,ty=v2,yc=g2,ny=S2,sy=(e,n,s)=>{const o=new Map,r={platform:G2,...s},a={...r.platform,_c:o};return x2(e,n,{...r,platform:a})};var oy=typeof document<"u",ry=function(){},Lo=oy?l.useLayoutEffect:ry;function Qo(e,n){if(e===n)return!0;if(typeof e!=typeof n)return!1;if(typeof e=="function"&&e.toString()===n.toString())return!0;let s,o,r;if(e&&n&&typeof e=="object"){if(Array.isArray(e)){if(s=e.length,s!==n.length)return!1;for(o=s;o--!==0;)if(!Qo(e[o],n[o]))return!1;return!0}if(r=Object.keys(e),s=r.length,s!==Object.keys(n).length)return!1;for(o=s;o--!==0;)if(!{}.hasOwnProperty.call(n,r[o]))return!1;for(o=s;o--!==0;){const a=r[o];if(!(a==="_owner"&&e.$$typeof)&&!Qo(e[a],n[a]))return!1}return!0}return e!==e&&n!==n}function bm(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function wc(e,n){const s=bm(e);return Math.round(n*s)/s}function ca(e){const n=l.useRef(e);return Lo(()=>{n.current=e}),n}function ay(e){e===void 0&&(e={});const{placement:n="bottom",strategy:s="absolute",middleware:o=[],platform:r,elements:{reference:a,floating:i}={},transform:c=!0,whileElementsMounted:d,open:m}=e,[u,f]=l.useState({x:0,y:0,strategy:s,placement:n,middlewareData:{},isPositioned:!1}),[p,h]=l.useState(o);Qo(p,o)||h(o);const[g,v]=l.useState(null),[y,w]=l.useState(null),b=l.useCallback(H=>{H!==C.current&&(C.current=H,v(H))},[]),j=l.useCallback(H=>{H!==R.current&&(R.current=H,w(H))},[]),S=a||g,N=i||y,C=l.useRef(null),R=l.useRef(null),I=l.useRef(u),P=d!=null,M=ca(d),k=ca(r),A=ca(m),D=l.useCallback(()=>{if(!C.current||!R.current)return;const H={placement:n,strategy:s,middleware:p};k.current&&(H.platform=k.current),sy(C.current,R.current,H).then(X=>{const B={...X,isPositioned:A.current!==!1};$.current&&!Qo(I.current,B)&&(I.current=B,hs.flushSync(()=>{f(B)}))})},[p,n,s,k,A]);Lo(()=>{m===!1&&I.current.isPositioned&&(I.current.isPositioned=!1,f(H=>({...H,isPositioned:!1})))},[m]);const $=l.useRef(!1);Lo(()=>($.current=!0,()=>{$.current=!1}),[]),Lo(()=>{if(S&&(C.current=S),N&&(R.current=N),S&&N){if(M.current)return M.current(S,N,D);D()}},[S,N,D,M,P]);const Y=l.useMemo(()=>({reference:C,floating:R,setReference:b,setFloating:j}),[b,j]),Q=l.useMemo(()=>({reference:S,floating:N}),[S,N]),U=l.useMemo(()=>{const H={position:s,left:0,top:0};if(!Q.floating)return H;const X=wc(Q.floating,u.x),B=wc(Q.floating,u.y);return c?{...H,transform:"translate("+X+"px, "+B+"px)",...bm(Q.floating)>=1.5&&{willChange:"transform"}}:{position:s,left:X,top:B}},[s,c,Q.floating,u.x,u.y]);return l.useMemo(()=>({...u,update:D,refs:Y,elements:Q,floatingStyles:U}),[u,D,Y,Q,U])}const iy=e=>{function n(s){return{}.hasOwnProperty.call(s,"current")}return{name:"arrow",options:e,fn(s){const{element:o,padding:r}=typeof e=="function"?e(s):e;return o&&n(o)?o.current!=null?yc({element:o.current,padding:r}).fn(s):{}:o?yc({element:o,padding:r}).fn(s):{}}}},ly=(e,n)=>({...X2(e),options:[e,n]}),cy=(e,n)=>({...Z2(e),options:[e,n]}),dy=(e,n)=>({...ny(e),options:[e,n]}),uy=(e,n)=>({...Q2(e),options:[e,n]}),my=(e,n)=>({...ey(e),options:[e,n]}),fy=(e,n)=>({...ty(e),options:[e,n]}),py=(e,n)=>({...iy(e),options:[e,n]});var hy="Arrow",vm=l.forwardRef((e,n)=>{const{children:s,width:o=10,height:r=5,...a}=e;return t.jsx(xe.svg,{...a,ref:n,width:o,height:r,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?s:t.jsx("polygon",{points:"0,0 30,0 15,10"})})});vm.displayName=hy;var xy=vm,dl="Popper",[ym,Er]=Jt(dl),[gy,wm]=ym(dl),jm=e=>{const{__scopePopper:n,children:s}=e,[o,r]=l.useState(null),[a,i]=l.useState(void 0);return t.jsx(gy,{scope:n,anchor:o,onAnchorChange:r,placementState:a,setPlacementState:i,children:s})};jm.displayName=dl;var Sm="PopperAnchor",Nm=l.forwardRef((e,n)=>{const{__scopePopper:s,virtualRef:o,...r}=e,a=wm(Sm,s),i=l.useRef(null),c=a.onAnchorChange,d=l.useCallback(g=>{i.current=g,g&&c(g)},[c]),m=Ee(n,d),u=l.useRef(null);l.useEffect(()=>{if(!o)return;const g=u.current;u.current=o.current,g!==u.current&&c(u.current)});const f=a.placementState&&ml(a.placementState),p=f?.[0],h=f?.[1];return o?null:t.jsx(xe.div,{"data-radix-popper-side":p,"data-radix-popper-align":h,...r,ref:m})});Nm.displayName=Sm;var ul="PopperContent",[by,vy]=ym(ul),Cm=l.forwardRef((e,n)=>{const{__scopePopper:s,side:o="bottom",sideOffset:r=0,align:a="center",alignOffset:i=0,arrowPadding:c=0,avoidCollisions:d=!0,collisionBoundary:m=[],collisionPadding:u=0,sticky:f="partial",hideWhenDetached:p=!1,updatePositionStrategy:h="optimized",onPlaced:g,...v}=e,y=wm(ul,s),[w,b]=l.useState(null),j=Ee(n,b),[S,N]=l.useState(null),C=s2(S),R=C?.width??0,I=C?.height??0,P=o+(a!=="center"?"-"+a:""),M=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},k=Array.isArray(m)?m:[m],A=k.length>0,D={padding:M,boundary:k.filter(wy),altBoundary:A},{refs:$,floatingStyles:Y,placement:Q,isPositioned:U,middlewareData:H}=ay({strategy:"fixed",placement:P,whileElementsMounted:(...we)=>J2(...we,{animationFrame:h==="always"}),elements:{reference:y.anchor},middleware:[ly({mainAxis:r+I,alignmentAxis:i}),d&&cy({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?dy():void 0,...D}),d&&uy({...D}),my({...D,apply:({elements:we,rects:Ne,availableWidth:le,availableHeight:ce})=>{const{width:ae,height:je}=Ne.reference,_e=we.floating.style;_e.setProperty("--radix-popper-available-width",`${le}px`),_e.setProperty("--radix-popper-available-height",`${ce}px`),_e.setProperty("--radix-popper-anchor-width",`${ae}px`),_e.setProperty("--radix-popper-anchor-height",`${je}px`)}}),S&&py({element:S,padding:c}),jy({arrowWidth:R,arrowHeight:I}),p&&fy({strategy:"referenceHidden",...D,boundary:A?D.boundary:void 0})]}),X=y.setPlacementState;ze(()=>(X(Q),()=>{X(void 0)}),[Q,X]);const[B,W]=ml(Q),pe=qe(g);ze(()=>{U&&pe?.()},[U,pe]);const ve=H.arrow?.x,ye=H.arrow?.y,re=H.arrow?.centerOffset!==0,[z,Z]=l.useState();return ze(()=>{w&&Z(window.getComputedStyle(w).zIndex)},[w]),t.jsx("div",{ref:$.setFloating,"data-radix-popper-content-wrapper":"",style:{...Y,transform:U?Y.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:z,"--radix-popper-transform-origin":[H.transformOrigin?.x,H.transformOrigin?.y].join(" "),...H.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:t.jsx(by,{scope:s,placedSide:B,placedAlign:W,onArrowChange:N,arrowX:ve,arrowY:ye,shouldHideArrow:re,children:t.jsx(xe.div,{"data-side":B,"data-align":W,...v,ref:j,style:{...v.style,animation:U?void 0:"none"}})})})});Cm.displayName=ul;var km="PopperArrow",yy={top:"bottom",right:"left",bottom:"top",left:"right"},_m=l.forwardRef(function(n,s){const{__scopePopper:o,...r}=n,a=vy(km,o),i=yy[a.placedSide];return t.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:t.jsx(xy,{...r,ref:s,style:{...r.style,display:"block"}})})});_m.displayName=km;function wy(e){return e!==null}var jy=e=>({name:"transformOrigin",options:e,fn(n){const{placement:s,rects:o,middlewareData:r}=n,i=r.arrow?.centerOffset!==0,c=i?0:e.arrowWidth,d=i?0:e.arrowHeight,[m,u]=ml(s),f={start:"0%",center:"50%",end:"100%"}[u],p=(r.arrow?.x??0)+c/2,h=(r.arrow?.y??0)+d/2;let g="",v="";return m==="bottom"?(g=i?f:`${p}px`,v=`${-d}px`):m==="top"?(g=i?f:`${p}px`,v=`${o.floating.height+d}px`):m==="right"?(g=`${-d}px`,v=i?f:`${h}px`):m==="left"&&(g=`${o.floating.width+d}px`,v=i?f:`${h}px`),{data:{x:g,y:v}}}});function ml(e){const[n,s="center"]=e.split("-");return[n,s]}var Tm=jm,Em=Nm,Rm=Cm,Mm=_m,da=!1;function Sy(){const[e,n]=l.useState(da);return l.useEffect(()=>{da||(da=!0,n(!0))},[]),e}var Am=hr[" useSyncExternalStore ".trim().toString()];function Ny(){return()=>{}}function Cy(){return Am(Ny,()=>!0,()=>!1)}var ky=typeof Am=="function"?Cy:Sy,ua="rovingFocusGroup.onEntryFocus",_y={bubbles:!1,cancelable:!0},Zs="RovingFocusGroup",[ti,Im,Ty]=Ru(Zs),[Ey,Pm]=Jt(Zs,[Ty]),[Ry,My]=Ey(Zs),Lm=l.forwardRef((e,n)=>t.jsx(ti.Provider,{scope:e.__scopeRovingFocusGroup,children:t.jsx(ti.Slot,{scope:e.__scopeRovingFocusGroup,children:t.jsx(Ay,{...e,ref:n})})}));Lm.displayName=Zs;var Ay=l.forwardRef((e,n)=>{const{__scopeRovingFocusGroup:s,orientation:o,loop:r=!1,dir:a,currentTabStopId:i,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:d,onEntryFocus:m,preventScrollOnEntryFocus:u=!1,...f}=e,p=l.useRef(null),h=Ee(n,p),g=yr(a),[v,y]=Rn({prop:i,defaultProp:c??null,onChange:d,caller:Zs}),[w,b]=l.useState(!1),j=qe(m),S=Im(s),N=l.useRef(!1),[C,R]=l.useState(0);return l.useEffect(()=>{const I=p.current;if(I)return I.addEventListener(ua,j),()=>I.removeEventListener(ua,j)},[j]),t.jsx(Ry,{scope:s,orientation:o,dir:g,loop:r,currentTabStopId:v,onItemFocus:l.useCallback(I=>y(I),[y]),onItemShiftTab:l.useCallback(()=>b(!0),[]),onFocusableItemAdd:l.useCallback(()=>R(I=>I+1),[]),onFocusableItemRemove:l.useCallback(()=>R(I=>I-1),[]),children:t.jsx(xe.div,{tabIndex:w||C===0?-1:0,"data-orientation":o,...f,ref:h,style:{outline:"none",...e.style},onMouseDown:ie(e.onMouseDown,()=>{N.current=!0}),onFocus:ie(e.onFocus,I=>{const P=!N.current;if(I.target===I.currentTarget&&P&&!w){const M=new CustomEvent(ua,_y);if(I.currentTarget.dispatchEvent(M),!M.defaultPrevented){const k=S().filter(Q=>Q.focusable),A=k.find(Q=>Q.active),D=k.find(Q=>Q.id===v),Y=[A,D,...k].filter(Boolean).map(Q=>Q.ref.current);zm(Y,u)}}N.current=!1}),onBlur:ie(e.onBlur,()=>b(!1))})})}),Om="RovingFocusGroupItem",Dm=l.forwardRef((e,n)=>{const{__scopeRovingFocusGroup:s,focusable:o=!0,active:r=!1,tabStopId:a,children:i,...c}=e,d=Mt(),m=a||d,u=My(Om,s),f=u.currentTabStopId===m,p=Im(s),{onFocusableItemAdd:h,onFocusableItemRemove:g,currentTabStopId:v}=u,y=ky();return ze(()=>{if(!(!y||!o))return h(),()=>g()},[y,o,h,g]),l.useEffect(()=>{if(!(y||!o))return h(),()=>g()},[y,o,h,g]),t.jsx(ti.ItemSlot,{scope:s,id:m,focusable:o,active:r,children:t.jsx(xe.span,{tabIndex:f?0:-1,"data-orientation":u.orientation,...c,ref:n,onMouseDown:ie(e.onMouseDown,w=>{o?u.onItemFocus(m):w.preventDefault()}),onFocus:ie(e.onFocus,()=>u.onItemFocus(m)),onKeyDown:ie(e.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){u.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const b=Ly(w,u.orientation,u.dir);if(b!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let S=p().filter(N=>N.focusable).map(N=>N.ref.current);if(b==="last")S.reverse();else if(b==="prev"||b==="next"){b==="prev"&&S.reverse();const N=S.indexOf(w.currentTarget);S=u.loop?Oy(S,N+1):S.slice(N+1)}setTimeout(()=>zm(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:v!=null}):i})})});Dm.displayName=Om;var Iy={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Py(e,n){return n!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Ly(e,n,s){const o=Py(e.key,s);if(!(n==="vertical"&&["ArrowLeft","ArrowRight"].includes(o))&&!(n==="horizontal"&&["ArrowUp","ArrowDown"].includes(o)))return Iy[o]}function zm(e,n=!1){const s=document.activeElement;for(const o of e)if(o===s||(o.focus({preventScroll:n}),document.activeElement!==s))return}function Oy(e,n){return e.map((s,o)=>e[(n+o)%e.length])}var Dy=Lm,zy=Dm;function ni(e,[n,s]){return Math.min(s,Math.max(n,e))}function $y(e,n){return l.useReducer((s,o)=>n[s][o]??s,e)}var fl="ScrollArea",[$m]=Jt(fl),[Fy,ft]=$m(fl),Fm=l.forwardRef((e,n)=>{const{__scopeScrollArea:s,type:o="hover",dir:r,scrollHideDelay:a=600,...i}=e,[c,d]=l.useState(null),[m,u]=l.useState(null),[f,p]=l.useState(null),[h,g]=l.useState(null),[v,y]=l.useState(null),[w,b]=l.useState(0),[j,S]=l.useState(0),[N,C]=l.useState(!1),[R,I]=l.useState(!1),P=Ee(n,d),M=yr(r);return t.jsx(Fy,{scope:s,type:o,dir:M,scrollHideDelay:a,scrollArea:c,viewport:m,onViewportChange:u,content:f,onContentChange:p,scrollbarX:h,onScrollbarXChange:g,scrollbarXEnabled:N,onScrollbarXEnabledChange:C,scrollbarY:v,onScrollbarYChange:y,scrollbarYEnabled:R,onScrollbarYEnabledChange:I,onCornerWidthChange:b,onCornerHeightChange:S,children:t.jsx(xe.div,{dir:M,...i,ref:P,style:{position:"relative","--radix-scroll-area-corner-width":w+"px","--radix-scroll-area-corner-height":j+"px",...e.style}})})});Fm.displayName=fl;var Um="ScrollAreaViewport",Bm=l.forwardRef((e,n)=>{const{__scopeScrollArea:s,children:o,nonce:r,...a}=e,i=ft(Um,s),c=l.useRef(null),d=Ee(n,c,i.onViewportChange);return t.jsxs(t.Fragment,{children:[t.jsx(Uy,{nonce:r}),t.jsx(xe.div,{"data-radix-scroll-area-viewport":"",...a,ref:d,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:t.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:o})})]})});Bm.displayName=Um;var Uy=l.memo(({nonce:e})=>t.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:e}),(e,n)=>e.nonce===n.nonce),Ft="ScrollAreaScrollbar",qm=l.forwardRef((e,n)=>{const{forceMount:s,...o}=e,r=ft(Ft,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:i}=r,c=e.orientation==="horizontal";return l.useEffect(()=>(c?a(!0):i(!0),()=>{c?a(!1):i(!1)}),[c,a,i]),r.type==="hover"?t.jsx(By,{...o,ref:n,forceMount:s}):r.type==="scroll"?t.jsx(qy,{...o,ref:n,forceMount:s}):r.type==="auto"?t.jsx(Hm,{...o,ref:n,forceMount:s}):r.type==="always"?t.jsx(pl,{...o,ref:n,"data-state":"visible"}):null});qm.displayName=Ft;var By=l.forwardRef((e,n)=>{const{forceMount:s,...o}=e,r=ft(Ft,e.__scopeScrollArea),[a,i]=l.useState(!1);return l.useEffect(()=>{const c=r.scrollArea;let d=0;if(c){const m=()=>{window.clearTimeout(d),i(!0)},u=()=>{d=window.setTimeout(()=>i(!1),r.scrollHideDelay)};return c.addEventListener("pointerenter",m),c.addEventListener("pointerleave",u),()=>{window.clearTimeout(d),c.removeEventListener("pointerenter",m),c.removeEventListener("pointerleave",u)}}},[r.scrollArea,r.scrollHideDelay]),t.jsx(dt,{present:s||a,children:t.jsx(Hm,{"data-state":a?"visible":"hidden",...o,ref:n})})}),qy=l.forwardRef((e,n)=>{const{forceMount:s,...o}=e,r=ft(Ft,e.__scopeScrollArea),a=e.orientation==="horizontal",i=Mr(()=>d("SCROLL_END"),100),[c,d]=$y("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return l.useEffect(()=>{if(c==="idle"){const m=window.setTimeout(()=>d("HIDE"),r.scrollHideDelay);return()=>window.clearTimeout(m)}},[c,r.scrollHideDelay,d]),l.useEffect(()=>{const m=r.viewport,u=a?"scrollLeft":"scrollTop";if(m){let f=m[u];const p=()=>{const h=m[u];f!==h&&(d("SCROLL"),i()),f=h};return m.addEventListener("scroll",p),()=>m.removeEventListener("scroll",p)}},[r.viewport,a,d,i]),t.jsx(dt,{present:s||c!=="hidden",children:t.jsx(pl,{"data-state":c==="hidden"?"hidden":"visible",...o,ref:n,onPointerEnter:ie(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:ie(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),Hm=l.forwardRef((e,n)=>{const s=ft(Ft,e.__scopeScrollArea),{forceMount:o,...r}=e,[a,i]=l.useState(!1),c=e.orientation==="horizontal",d=Mr(()=>{if(s.viewport){const m=s.viewport.offsetWidth<s.viewport.scrollWidth,u=s.viewport.offsetHeight<s.viewport.scrollHeight;i(c?m:u)}},10);return us(s.viewport,d),us(s.content,d),t.jsx(dt,{present:o||a,children:t.jsx(pl,{"data-state":a?"visible":"hidden",...r,ref:n})})}),pl=l.forwardRef((e,n)=>{const{orientation:s="vertical",...o}=e,r=ft(Ft,e.__scopeScrollArea),a=l.useRef(null),i=l.useRef(0),[c,d]=l.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),m=Ym(c.viewport,c.content),u={...o,sizes:c,onSizesChange:d,hasThumb:m>0&&m<1,onThumbChange:p=>a.current=p,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:p=>i.current=p};function f(p,h){return Yy(p,i.current,c,h)}return s==="horizontal"?t.jsx(Hy,{...u,ref:n,onThumbPositionChange:()=>{if(r.viewport&&a.current){const p=r.viewport.scrollLeft,h=jc(p,c,r.dir);a.current.style.transform=`translate3d(${h}px, 0, 0)`}},onWheelScroll:p=>{r.viewport&&(r.viewport.scrollLeft=p)},onDragScroll:p=>{r.viewport&&(r.viewport.scrollLeft=f(p,r.dir))}}):s==="vertical"?t.jsx(Wy,{...u,ref:n,onThumbPositionChange:()=>{if(r.viewport&&a.current){const p=r.viewport.scrollTop,h=jc(p,c);a.current.style.transform=`translate3d(0, ${h}px, 0)`}},onWheelScroll:p=>{r.viewport&&(r.viewport.scrollTop=p)},onDragScroll:p=>{r.viewport&&(r.viewport.scrollTop=f(p))}}):null}),Hy=l.forwardRef((e,n)=>{const{sizes:s,onSizesChange:o,...r}=e,a=ft(Ft,e.__scopeScrollArea),[i,c]=l.useState(),d=l.useRef(null),m=Ee(n,d,a.onScrollbarXChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),t.jsx(Vm,{"data-orientation":"horizontal",...r,ref:m,sizes:s,style:{bottom:0,left:a.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:a.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Rr(s)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.x),onDragScroll:u=>e.onDragScroll(u.x),onWheelScroll:(u,f)=>{if(a.viewport){const p=a.viewport.scrollLeft+u.deltaX;e.onWheelScroll(p),Xm(p,f)&&u.preventDefault()}},onResize:()=>{d.current&&a.viewport&&i&&o({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:tr(i.paddingLeft),paddingEnd:tr(i.paddingRight)}})}})}),Wy=l.forwardRef((e,n)=>{const{sizes:s,onSizesChange:o,...r}=e,a=ft(Ft,e.__scopeScrollArea),[i,c]=l.useState(),d=l.useRef(null),m=Ee(n,d,a.onScrollbarYChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),t.jsx(Vm,{"data-orientation":"vertical",...r,ref:m,sizes:s,style:{top:0,right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Rr(s)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.y),onDragScroll:u=>e.onDragScroll(u.y),onWheelScroll:(u,f)=>{if(a.viewport){const p=a.viewport.scrollTop+u.deltaY;e.onWheelScroll(p),Xm(p,f)&&u.preventDefault()}},onResize:()=>{d.current&&a.viewport&&i&&o({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:tr(i.paddingTop),paddingEnd:tr(i.paddingBottom)}})}})}),[Vy,Wm]=$m(Ft),Vm=l.forwardRef((e,n)=>{const{__scopeScrollArea:s,sizes:o,hasThumb:r,onThumbChange:a,onThumbPointerUp:i,onThumbPointerDown:c,onThumbPositionChange:d,onDragScroll:m,onWheelScroll:u,onResize:f,...p}=e,h=ft(Ft,s),[g,v]=l.useState(null),y=Ee(n,v),w=l.useRef(null),b=l.useRef(""),j=h.viewport,S=o.content-o.viewport,N=qe(u),C=qe(d),R=Mr(f,10);function I(P){if(w.current){const M=P.clientX-w.current.left,k=P.clientY-w.current.top;m({x:M,y:k})}}return l.useEffect(()=>{const P=M=>{const k=M.target;g?.contains(k)&&N(M,S)};return document.addEventListener("wheel",P,{passive:!1}),()=>document.removeEventListener("wheel",P,{passive:!1})},[j,g,S,N]),l.useEffect(C,[o,C]),us(g,R),us(h.content,R),t.jsx(Vy,{scope:s,scrollbar:g,hasThumb:r,onThumbChange:qe(a),onThumbPointerUp:qe(i),onThumbPositionChange:C,onThumbPointerDown:qe(c),children:t.jsx(xe.div,{...p,ref:y,style:{position:"absolute",...p.style},onPointerDown:ie(e.onPointerDown,P=>{P.button===0&&(P.target.setPointerCapture(P.pointerId),w.current=g.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",h.viewport&&(h.viewport.style.scrollBehavior="auto"),I(P))}),onPointerMove:ie(e.onPointerMove,I),onPointerUp:ie(e.onPointerUp,P=>{const M=P.target;M.hasPointerCapture(P.pointerId)&&M.releasePointerCapture(P.pointerId),document.body.style.webkitUserSelect=b.current,h.viewport&&(h.viewport.style.scrollBehavior=""),w.current=null})})})}),er="ScrollAreaThumb",Km=l.forwardRef((e,n)=>{const{forceMount:s,...o}=e,r=Wm(er,e.__scopeScrollArea);return t.jsx(dt,{present:s||r.hasThumb,children:t.jsx(Ky,{ref:n,...o})})}),Ky=l.forwardRef((e,n)=>{const{__scopeScrollArea:s,style:o,...r}=e,a=ft(er,s),i=Wm(er,s),{onThumbPositionChange:c}=i,d=Ee(n,i.onThumbChange),m=l.useRef(void 0),u=Mr(()=>{m.current&&(m.current(),m.current=void 0)},100);return l.useEffect(()=>{const f=a.viewport;if(f){const p=()=>{if(u(),!m.current){const h=Jy(f,c);m.current=h,c()}};return c(),f.addEventListener("scroll",p),()=>f.removeEventListener("scroll",p)}},[a.viewport,u,c]),t.jsx(xe.div,{"data-state":i.hasThumb?"visible":"hidden",...r,ref:d,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...o},onPointerDownCapture:ie(e.onPointerDownCapture,f=>{const h=f.target.getBoundingClientRect(),g=f.clientX-h.left,v=f.clientY-h.top;i.onThumbPointerDown({x:g,y:v})}),onPointerUp:ie(e.onPointerUp,i.onThumbPointerUp)})});Km.displayName=er;var hl="ScrollAreaCorner",Gm=l.forwardRef((e,n)=>{const s=ft(hl,e.__scopeScrollArea),o=!!(s.scrollbarX&&s.scrollbarY);return s.type!=="scroll"&&o?t.jsx(Gy,{...e,ref:n}):null});Gm.displayName=hl;var Gy=l.forwardRef((e,n)=>{const{__scopeScrollArea:s,...o}=e,r=ft(hl,s),[a,i]=l.useState(0),[c,d]=l.useState(0),m=!!(a&&c),{onCornerWidthChange:u,onCornerHeightChange:f}=r;return us(r.scrollbarX,()=>{const p=r.scrollbarX?.offsetHeight||0;r.onCornerHeightChange(p),d(p)}),us(r.scrollbarY,()=>{const p=r.scrollbarY?.offsetWidth||0;r.onCornerWidthChange(p),i(p)}),l.useEffect(()=>()=>{u(0),f(0)},[u,f]),m?t.jsx(xe.div,{...o,ref:n,style:{width:a,height:c,position:"absolute",right:r.dir==="ltr"?0:void 0,left:r.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function tr(e){return e?parseInt(e,10):0}function Ym(e,n){const s=e/n;return isNaN(s)?0:s}function Rr(e){const n=Ym(e.viewport,e.content),s=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,o=(e.scrollbar.size-s)*n;return Math.max(o,18)}function Yy(e,n,s,o="ltr"){const r=Rr(s),a=r/2,i=n||a,c=r-i,d=s.scrollbar.paddingStart+i,m=s.scrollbar.size-s.scrollbar.paddingEnd-c,u=s.content-s.viewport,f=o==="ltr"?[0,u]:[u*-1,0];return Jm([d,m],f)(e)}function jc(e,n,s="ltr"){const o=Rr(n),r=n.scrollbar.paddingStart+n.scrollbar.paddingEnd,a=n.scrollbar.size-r,i=n.content-n.viewport,c=a-o,d=s==="ltr"?[0,i]:[i*-1,0],m=ni(e,d);return Jm([0,i],[0,c])(m)}function Jm(e,n){return s=>{if(e[0]===e[1]||n[0]===n[1])return n[0];const o=(n[1]-n[0])/(e[1]-e[0]);return n[0]+o*(s-e[0])}}function Xm(e,n){return e>0&&e<n}var Jy=(e,n=()=>{})=>{let s={left:e.scrollLeft,top:e.scrollTop},o=0;return(function r(){const a={left:e.scrollLeft,top:e.scrollTop},i=s.left!==a.left,c=s.top!==a.top;(i||c)&&n(),s=a,o=window.requestAnimationFrame(r)})(),()=>window.cancelAnimationFrame(o)};function Mr(e,n){const s=qe(e),o=l.useRef(0);return l.useEffect(()=>()=>window.clearTimeout(o.current),[]),l.useCallback(()=>{window.clearTimeout(o.current),o.current=window.setTimeout(s,n)},[s,n])}function us(e,n){const s=qe(n);ze(()=>{let o=0;if(e){const r=new ResizeObserver(()=>{cancelAnimationFrame(o),o=window.requestAnimationFrame(s)});return r.observe(e),()=>{window.cancelAnimationFrame(o),r.unobserve(e)}}},[e,s])}var Xy=Fm,Zy=Bm,Qy=Gm,ew=[" ","Enter","ArrowUp","ArrowDown"],tw=[" ","Enter"],An="Select",[Ar,Ir,nw]=Ru(An),[On]=Jt(An,[nw,Er]),Pr=Er(),[sw,hn]=On(An),[ow,rw]=On(An),aw="SelectProvider";function Zm(e){const{__scopeSelect:n,children:s,open:o,defaultOpen:r,onOpenChange:a,value:i,defaultValue:c,onValueChange:d,dir:m,name:u,autoComplete:f,disabled:p,required:h,form:g,internal_do_not_use_render:v}=e,y=Pr(n),[w,b]=l.useState(null),[j,S]=l.useState(null),[N,C]=l.useState(!1),R=yr(m),[I,P]=Rn({prop:o,defaultProp:r??!1,onChange:a,caller:An}),[M,k]=Rn({prop:i,defaultProp:c,onChange:d,caller:An}),A=l.useRef(null),D=l.useRef(M);l.useEffect(()=>{const pe=g?w?.ownerDocument.getElementById(g):w?.form;if(pe instanceof HTMLFormElement){const ve=()=>k(D.current);return pe.addEventListener("reset",ve),()=>pe.removeEventListener("reset",ve)}},[g,w,k]);const $=w?!!g||!!w.closest("form"):!0,[Y,Q]=l.useState(new Set),U=Mt(),H=Array.from(Y).map(pe=>pe.props.value).join(";"),X=l.useCallback(pe=>{Q(ve=>new Set(ve).add(pe))},[]),B=l.useCallback(pe=>{Q(ve=>{const ye=new Set(ve);return ye.delete(pe),ye})},[]),W={required:h,trigger:w,onTriggerChange:b,valueNode:j,onValueNodeChange:S,valueNodeHasChildren:N,onValueNodeHasChildrenChange:C,contentId:U,value:M,onValueChange:k,open:I,onOpenChange:P,dir:R,triggerPointerDownPosRef:A,disabled:p,name:u,autoComplete:f,form:g,nativeOptions:Y,nativeSelectKey:H,isFormControl:$};return t.jsx(Tm,{...y,children:t.jsx(sw,{scope:n,...W,children:t.jsx(Ar.Provider,{scope:n,children:t.jsx(ow,{scope:n,onNativeOptionAdd:X,onNativeOptionRemove:B,children:Sw(v)?v(W):s})})})})}Zm.displayName=aw;var Qm=e=>{const{__scopeSelect:n,children:s,...o}=e;return t.jsx(Zm,{__scopeSelect:n,...o,internal_do_not_use_render:({isFormControl:r})=>t.jsxs(t.Fragment,{children:[s,r?t.jsx(kf,{__scopeSelect:n}):null]})})};Qm.displayName=An;var ef="SelectTrigger",tf=l.forwardRef((e,n)=>{const{__scopeSelect:s,disabled:o=!1,...r}=e,a=Pr(s),i=hn(ef,s),c=i.disabled||o,d=Ee(n,i.onTriggerChange),m=Ir(s),u=l.useRef("touch"),[f,p,h]=_f(v=>{const y=m().filter(j=>!j.disabled),w=y.find(j=>j.value===i.value),b=Tf(y,v,w);b!==void 0&&i.onValueChange(b.value)}),g=v=>{c||(i.onOpenChange(!0),h()),v&&(i.triggerPointerDownPosRef.current={x:Math.round(v.pageX),y:Math.round(v.pageY)})};return t.jsx(Em,{asChild:!0,...a,children:t.jsx(xe.button,{type:"button",role:"combobox","aria-controls":i.open?i.contentId:void 0,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":Lr(i.value)?"":void 0,...r,ref:d,onClick:ie(r.onClick,v=>{v.currentTarget.focus(),u.current!=="mouse"&&g(v)}),onPointerDown:ie(r.onPointerDown,v=>{u.current=v.pointerType;const y=v.target;y.hasPointerCapture(v.pointerId)&&y.releasePointerCapture(v.pointerId),v.button===0&&v.ctrlKey===!1&&v.pointerType==="mouse"&&(g(v),v.preventDefault())}),onKeyDown:ie(r.onKeyDown,v=>{const y=f.current!=="";!(v.ctrlKey||v.altKey||v.metaKey)&&v.key.length===1&&p(v.key),!(y&&v.key===" ")&&ew.includes(v.key)&&(g(),v.preventDefault())})})})});tf.displayName=ef;var nf="SelectValue",sf=l.forwardRef((e,n)=>{const{__scopeSelect:s,className:o,style:r,children:a,placeholder:i="",...c}=e,d=hn(nf,s),{onValueNodeHasChildrenChange:m}=d,u=a!==void 0,f=Ee(n,d.onValueNodeChange);ze(()=>{m(u)},[m,u]);const p=Lr(d.value);return t.jsx(xe.span,{...c,asChild:p?!1:c.asChild,ref:f,style:{pointerEvents:"none"},children:t.jsx(l.Fragment,{children:p?i:a},p?"placeholder":"value")})});sf.displayName=nf;var iw="SelectIcon",of=l.forwardRef((e,n)=>{const{__scopeSelect:s,children:o,...r}=e;return t.jsx(xe.span,{"aria-hidden":!0,...r,ref:n,children:o||"▼"})});of.displayName=iw;var rf="SelectPortal",[lw,cw]=On(rf,{forceMount:void 0}),af=e=>{const{__scopeSelect:n,forceMount:s,...o}=e;return t.jsx(lw,{scope:e.__scopeSelect,forceMount:s,children:t.jsx(jr,{asChild:!0,...o})})};af.displayName=rf;var fn="SelectContent",lf=l.forwardRef((e,n)=>{const s=cw(fn,e.__scopeSelect),{forceMount:o=s.forceMount,...r}=e,a=hn(fn,e.__scopeSelect),[i,c]=l.useState();return ze(()=>{c(new DocumentFragment)},[]),t.jsx(dt,{present:o||a.open,children:({present:d})=>d?t.jsx(uf,{...r,ref:n}):t.jsx(cf,{...r,fragment:i})})});lf.displayName=fn;var cf=l.forwardRef((e,n)=>{const{__scopeSelect:s,children:o,fragment:r}=e;return r?hs.createPortal(t.jsx(df,{scope:s,children:t.jsx(Ar.Slot,{scope:s,children:t.jsx("div",{ref:n,children:o})})}),r):null});cf.displayName="SelectContentFragment";var bt=10,[df,xn]=On(fn),dw="SelectContentImpl",uw=ls("SelectContent.RemoveScroll"),uf=l.forwardRef((e,n)=>{const{__scopeSelect:s}=e,{position:o="item-aligned",onCloseAutoFocus:r,onEscapeKeyDown:a,onPointerDownOutside:i,side:c,sideOffset:d,align:m,alignOffset:u,arrowPadding:f,collisionBoundary:p,collisionPadding:h,sticky:g,hideWhenDetached:v,avoidCollisions:y,...w}=e,b=hn(fn,s),[j,S]=l.useState(null),[N,C]=l.useState(null),R=Ee(n,S),[I,P]=l.useState(null),[M,k]=l.useState(null),A=Ir(s),[D,$]=l.useState(!1),Y=l.useRef(!1);l.useEffect(()=>{if(j)return Vu(j)},[j]),Du();const Q=l.useCallback(Z=>{const[we,...Ne]=A().map(ae=>ae.ref.current),[le]=Ne.slice(-1),ce=document.activeElement;for(const ae of Z)if(ae===ce||(ae?.scrollIntoView({block:"nearest"}),ae===we&&N&&(N.scrollTop=0),ae===le&&N&&(N.scrollTop=N.scrollHeight),ae?.focus(),document.activeElement!==ce))return},[A,N]),U=l.useCallback(()=>Q([I,j]),[Q,I,j]);l.useEffect(()=>{D&&U()},[D,U]);const{onOpenChange:H,triggerPointerDownPosRef:X}=b;l.useEffect(()=>{if(j){let Z={x:0,y:0};const we=le=>{Z={x:Math.abs(Math.round(le.pageX)-(X.current?.x??0)),y:Math.abs(Math.round(le.pageY)-(X.current?.y??0))}},Ne=le=>{Z.x<=10&&Z.y<=10?le.preventDefault():le.composedPath().includes(j)||H(!1),document.removeEventListener("pointermove",we),X.current=null};return X.current!==null&&(document.addEventListener("pointermove",we),document.addEventListener("pointerup",Ne,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",we),document.removeEventListener("pointerup",Ne,{capture:!0})}}},[j,H,X]),l.useEffect(()=>{const Z=()=>H(!1);return window.addEventListener("blur",Z),window.addEventListener("resize",Z),()=>{window.removeEventListener("blur",Z),window.removeEventListener("resize",Z)}},[H]);const[B,W]=_f(Z=>{const we=A().filter(ce=>!ce.disabled),Ne=we.find(ce=>ce.ref.current===document.activeElement),le=Tf(we,Z,Ne);le&&setTimeout(()=>le.ref.current?.focus())}),pe=l.useCallback((Z,we,Ne)=>{const le=!Y.current&&!Ne;(b.value!==void 0&&b.value===we||le)&&(P(Z),le&&(Y.current=!0))},[b.value]),ve=l.useCallback(()=>j?.focus(),[j]),ye=l.useCallback((Z,we,Ne)=>{const le=!Y.current&&!Ne;(b.value!==void 0&&b.value===we||le)&&k(Z)},[b.value]),re=o==="popper"?si:mf,z=re===si?{side:c,sideOffset:d,align:m,alignOffset:u,arrowPadding:f,collisionBoundary:p,collisionPadding:h,sticky:g,hideWhenDetached:v,avoidCollisions:y}:{};return t.jsx(df,{scope:s,content:j,viewport:N,onViewportChange:C,itemRefCallback:pe,selectedItem:I,onItemLeave:ve,itemTextRefCallback:ye,focusSelectedItem:U,selectedItemText:M,position:o,isPositioned:D,searchRef:B,children:t.jsx(tl,{as:uw,allowPinchZoom:!0,children:t.jsx(el,{asChild:!0,trapped:b.open,onMountAutoFocus:Z=>{Z.preventDefault()},onUnmountAutoFocus:ie(r,Z=>{b.trigger?.focus({preventScroll:!0}),Z.preventDefault()}),children:t.jsx(wr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:Z=>Z.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:t.jsx(re,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:Z=>Z.preventDefault(),...w,...z,onPlaced:()=>$(!0),ref:R,style:{display:"flex",flexDirection:"column",outline:"none",...w.style},onKeyDown:ie(w.onKeyDown,Z=>{const we=Z.ctrlKey||Z.altKey||Z.metaKey;if(Z.key==="Tab"&&Z.preventDefault(),!we&&Z.key.length===1&&W(Z.key),["ArrowUp","ArrowDown","Home","End"].includes(Z.key)){let le=A().filter(ce=>!ce.disabled).map(ce=>ce.ref.current);if(["ArrowUp","End"].includes(Z.key)&&(le=le.slice().reverse()),["ArrowUp","ArrowDown"].includes(Z.key)){const ce=Z.target,ae=le.indexOf(ce);le=le.slice(ae+1)}setTimeout(()=>Q(le)),Z.preventDefault()}})})})})})})});uf.displayName=dw;var mw="SelectItemAlignedPosition",mf=l.forwardRef((e,n)=>{const{__scopeSelect:s,onPlaced:o,...r}=e,a=hn(fn,s),i=xn(fn,s),[c,d]=l.useState(null),[m,u]=l.useState(null),f=Ee(n,u),p=Ir(s),h=l.useRef(!1),g=l.useRef(!0),{viewport:v,selectedItem:y,selectedItemText:w,focusSelectedItem:b}=i,j=l.useCallback(()=>{if(a.trigger&&a.valueNode&&c&&m&&v&&y&&w){const R=a.trigger.getBoundingClientRect(),I=m.getBoundingClientRect(),P=a.valueNode.getBoundingClientRect(),M=w.getBoundingClientRect();if(a.dir!=="rtl"){const ce=M.left-I.left,ae=P.left-ce,je=R.left-ae,_e=R.width+je,Ie=Math.max(_e,I.width),Ue=window.innerWidth-bt,Me=ni(ae,[bt,Math.max(bt,Ue-Ie)]);c.style.minWidth=_e+"px",c.style.left=Me+"px"}else{const ce=I.right-M.right,ae=window.innerWidth-P.right-ce,je=window.innerWidth-R.right-ae,_e=R.width+je,Ie=Math.max(_e,I.width),Ue=window.innerWidth-bt,Me=ni(ae,[bt,Math.max(bt,Ue-Ie)]);c.style.minWidth=_e+"px",c.style.right=Me+"px"}const k=p(),A=window.innerHeight-bt*2,D=v.scrollHeight,$=window.getComputedStyle(m),Y=parseInt($.borderTopWidth,10),Q=parseInt($.paddingTop,10),U=parseInt($.borderBottomWidth,10),H=parseInt($.paddingBottom,10),X=Y+Q+D+H+U,B=Math.min(y.offsetHeight*5,X),W=window.getComputedStyle(v),pe=parseInt(W.paddingTop,10),ve=parseInt(W.paddingBottom,10),ye=R.top+R.height/2-bt,re=A-ye,z=y.offsetHeight/2,Z=y.offsetTop+z,we=Y+Q+Z,Ne=X-we;if(we<=ye){const ce=k.length>0&&y===k[k.length-1].ref.current;c.style.bottom="0px";const ae=m.clientHeight-v.offsetTop-v.offsetHeight,je=Math.max(re,z+(ce?ve:0)+ae+U),_e=we+je;c.style.height=_e+"px"}else{const ce=k.length>0&&y===k[0].ref.current;c.style.top="0px";const je=Math.max(ye,Y+v.offsetTop+(ce?pe:0)+z)+Ne;c.style.height=je+"px",v.scrollTop=we-ye+v.offsetTop}c.style.margin=`${bt}px 0`,c.style.minHeight=B+"px",c.style.maxHeight=A+"px",o?.(),requestAnimationFrame(()=>h.current=!0)}},[p,a.trigger,a.valueNode,c,m,v,y,w,a.dir,o]);ze(()=>j(),[j]);const[S,N]=l.useState();ze(()=>{m&&N(window.getComputedStyle(m).zIndex)},[m]);const C=l.useCallback(R=>{R&&g.current===!0&&(j(),b?.(),g.current=!1)},[j,b]);return t.jsx(pw,{scope:s,contentWrapper:c,shouldExpandOnScrollRef:h,onScrollButtonChange:C,children:t.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:S},children:t.jsx(xe.div,{...r,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...r.style}})})})});mf.displayName=mw;var fw="SelectPopperPosition",si=l.forwardRef((e,n)=>{const{__scopeSelect:s,align:o="start",collisionPadding:r=bt,...a}=e,i=Pr(s);return t.jsx(Rm,{...i,...a,ref:n,align:o,collisionPadding:r,style:{boxSizing:"border-box",...a.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});si.displayName=fw;var[pw,xl]=On(fn,{}),oi="SelectViewport",ff=l.forwardRef((e,n)=>{const{__scopeSelect:s,nonce:o,...r}=e,a=xn(oi,s),i=xl(oi,s),c=Ee(n,a.onViewportChange),d=l.useRef(0);return t.jsxs(t.Fragment,{children:[t.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),t.jsx(Ar.Slot,{scope:s,children:t.jsx(xe.div,{"data-radix-select-viewport":"",role:"presentation",...r,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...r.style},onScroll:ie(r.onScroll,m=>{const u=m.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:p}=i;if(p?.current&&f){const h=Math.abs(d.current-u.scrollTop);if(h>0){const g=window.innerHeight-bt*2,v=parseFloat(f.style.minHeight),y=parseFloat(f.style.height),w=Math.max(v,y);if(w<g){const b=w+h,j=Math.min(g,b),S=b-j;f.style.height=j+"px",f.style.bottom==="0px"&&(u.scrollTop=S>0?S:0,f.style.justifyContent="flex-end")}}}d.current=u.scrollTop})})})]})});ff.displayName=oi;var pf="SelectGroup",[hw,xw]=On(pf),gw=l.forwardRef((e,n)=>{const{__scopeSelect:s,...o}=e,r=Mt();return t.jsx(hw,{scope:s,id:r,children:t.jsx(xe.div,{role:"group","aria-labelledby":r,...o,ref:n})})});gw.displayName=pf;var hf="SelectLabel",bw=l.forwardRef((e,n)=>{const{__scopeSelect:s,...o}=e,r=xw(hf,s);return t.jsx(xe.div,{id:r.id,...o,ref:n})});bw.displayName=hf;var nr="SelectItem",[vw,xf]=On(nr),gf=l.forwardRef((e,n)=>{const{__scopeSelect:s,value:o,disabled:r=!1,textValue:a,...i}=e,c=hn(nr,s),d=xn(nr,s),m=c.value===o,[u,f]=l.useState(a??""),[p,h]=l.useState(!1),g=qe(j=>d.itemRefCallback?.(j,o,r)),v=Ee(n,g),y=Mt(),w=l.useRef("touch"),b=()=>{r||(c.onValueChange(o),c.onOpenChange(!1))};return t.jsx(vw,{scope:s,value:o,disabled:r,textId:y,isSelected:m,onItemTextChange:l.useCallback(j=>{f(S=>S||(j?.textContent??"").trim())},[]),children:t.jsx(Ar.ItemSlot,{scope:s,value:o,disabled:r,textValue:u,children:t.jsx(xe.div,{role:"option","aria-labelledby":y,"data-highlighted":p?"":void 0,"aria-selected":m&&p,"data-state":m?"checked":"unchecked","aria-disabled":r||void 0,"data-disabled":r?"":void 0,tabIndex:r?void 0:-1,...i,ref:v,onFocus:ie(i.onFocus,()=>h(!0)),onBlur:ie(i.onBlur,()=>h(!1)),onClick:ie(i.onClick,()=>{w.current!=="mouse"&&b()}),onPointerUp:ie(i.onPointerUp,()=>{w.current==="mouse"&&b()}),onPointerDown:ie(i.onPointerDown,j=>{w.current=j.pointerType}),onPointerMove:ie(i.onPointerMove,j=>{w.current=j.pointerType,r?d.onItemLeave?.():w.current==="mouse"&&j.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ie(i.onPointerLeave,j=>{j.currentTarget===document.activeElement&&d.onItemLeave?.()}),onKeyDown:ie(i.onKeyDown,j=>{r||j.target!==j.currentTarget||d.searchRef?.current!==""&&j.key===" "||(tw.includes(j.key)&&b(),j.key===" "&&j.preventDefault())})})})})});gf.displayName=nr;var Rs="SelectItemText",bf=l.forwardRef((e,n)=>{const{__scopeSelect:s,className:o,style:r,...a}=e,i=hn(Rs,s),c=xn(Rs,s),d=xf(Rs,s),m=rw(Rs,s),[u,f]=l.useState(null),p=qe(b=>c.itemTextRefCallback?.(b,d.value,d.disabled)),h=Ee(n,f,d.onItemTextChange,p),g=u?.textContent,v=l.useMemo(()=>t.jsx("option",{value:d.value,disabled:d.disabled,children:g},d.value),[d.disabled,d.value,g]),{onNativeOptionAdd:y,onNativeOptionRemove:w}=m;return ze(()=>(y(v),()=>w(v)),[y,w,v]),t.jsxs(t.Fragment,{children:[t.jsx(xe.span,{id:d.textId,...a,ref:h}),d.isSelected&&i.valueNode&&!i.valueNodeHasChildren&&!Lr(i.value)?hs.createPortal(a.children,i.valueNode):null]})});bf.displayName=Rs;var vf="SelectItemIndicator",yf=l.forwardRef((e,n)=>{const{__scopeSelect:s,...o}=e;return xf(vf,s).isSelected?t.jsx(xe.span,{"aria-hidden":!0,...o,ref:n}):null});yf.displayName=vf;var ri="SelectScrollUpButton",wf=l.forwardRef((e,n)=>{const s=xn(ri,e.__scopeSelect),o=xl(ri,e.__scopeSelect),[r,a]=l.useState(!1),i=Ee(n,o.onScrollButtonChange);return ze(()=>{if(s.viewport&&s.isPositioned){let c=function(){const m=d.scrollTop>0;a(m)};const d=s.viewport;return c(),d.addEventListener("scroll",c),()=>d.removeEventListener("scroll",c)}},[s.viewport,s.isPositioned]),r?t.jsx(Sf,{...e,ref:i,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=s;c&&d&&(c.scrollTop=c.scrollTop-d.offsetHeight)}}):null});wf.displayName=ri;var ai="SelectScrollDownButton",jf=l.forwardRef((e,n)=>{const s=xn(ai,e.__scopeSelect),o=xl(ai,e.__scopeSelect),[r,a]=l.useState(!1),i=Ee(n,o.onScrollButtonChange);return ze(()=>{if(s.viewport&&s.isPositioned){let c=function(){const m=d.scrollHeight-d.clientHeight,u=Math.ceil(d.scrollTop)<m;a(u)};const d=s.viewport;return c(),d.addEventListener("scroll",c),()=>d.removeEventListener("scroll",c)}},[s.viewport,s.isPositioned]),r?t.jsx(Sf,{...e,ref:i,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=s;c&&d&&(c.scrollTop=c.scrollTop+d.offsetHeight)}}):null});jf.displayName=ai;var Sf=l.forwardRef((e,n)=>{const{__scopeSelect:s,onAutoScroll:o,...r}=e,a=xn("SelectScrollButton",s),i=l.useRef(null),c=Ir(s),d=l.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return l.useEffect(()=>()=>d(),[d]),ze(()=>{c().find(u=>u.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[c]),t.jsx(xe.div,{"aria-hidden":!0,...r,ref:n,style:{flexShrink:0,...r.style},onPointerDown:ie(r.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(o,50))}),onPointerMove:ie(r.onPointerMove,()=>{a.onItemLeave?.(),i.current===null&&(i.current=window.setInterval(o,50))}),onPointerLeave:ie(r.onPointerLeave,()=>{d()})})}),yw="SelectSeparator",ww=l.forwardRef((e,n)=>{const{__scopeSelect:s,...o}=e;return t.jsx(xe.div,{"aria-hidden":!0,...o,ref:n})});ww.displayName=yw;var Nf="SelectArrow",jw=l.forwardRef((e,n)=>{const{__scopeSelect:s,...o}=e,r=Pr(s);return xn(Nf,s).position==="popper"?t.jsx(Mm,{...r,...o,ref:n}):null});jw.displayName=Nf;var Cf="SelectBubbleInput",kf=l.forwardRef(({__scopeSelect:e,...n},s)=>{const o=hn(Cf,e),{value:r,onValueChange:a,required:i,disabled:c,name:d,autoComplete:m,form:u}=o,{nativeOptions:f,nativeSelectKey:p}=o,h=l.useRef(null),g=Ee(s,h),v=r??"",y=n2(v),w=Array.from(f).some(b=>(b.props.value??"")==="");return l.useEffect(()=>{const b=h.current;if(!b)return;const j=window.HTMLSelectElement.prototype,N=Object.getOwnPropertyDescriptor(j,"value").set;if(y!==v&&N){const C=new Event("change",{bubbles:!0});N.call(b,v),b.dispatchEvent(C)}},[y,v]),t.jsxs(xe.select,{"aria-hidden":!0,required:i,tabIndex:-1,name:d,autoComplete:m,disabled:c,form:u,onChange:b=>a(b.target.value),...n,style:{...Tu,...n.style},ref:g,defaultValue:v,children:[Lr(r)&&!w?t.jsx("option",{value:""}):null,Array.from(f)]},p)});kf.displayName=Cf;function Sw(e){return typeof e=="function"}function Lr(e){return e===""||e===void 0}function _f(e){const n=qe(e),s=l.useRef(""),o=l.useRef(0),r=l.useCallback(i=>{const c=s.current+i;n(c),(function d(m){s.current=m,window.clearTimeout(o.current),m!==""&&(o.current=window.setTimeout(()=>d(""),1e3))})(c)},[n]),a=l.useCallback(()=>{s.current="",window.clearTimeout(o.current)},[]);return l.useEffect(()=>()=>window.clearTimeout(o.current),[]),[s,r,a]}function Tf(e,n,s){const r=n.length>1&&Array.from(n).every(m=>m===n[0])?n[0]:n,a=s?e.indexOf(s):-1;let i=Nw(e,Math.max(a,0));r.length===1&&(i=i.filter(m=>m!==s));const d=i.find(m=>m.textValue.toLowerCase().startsWith(r.toLowerCase()));return d!==s?d:void 0}function Nw(e,n){return e.map((s,o)=>e[(n+o)%e.length])}var Or="Tabs",[Cw]=Jt(Or,[Pm]),Ef=Pm(),[kw,gl]=Cw(Or),Rf=l.forwardRef((e,n)=>{const{__scopeTabs:s,value:o,onValueChange:r,defaultValue:a,orientation:i="horizontal",dir:c,activationMode:d="automatic",...m}=e,u=yr(c),[f,p]=Rn({prop:o,onChange:r,defaultProp:a??"",caller:Or});return t.jsx(kw,{scope:s,baseId:Mt(),value:f,onValueChange:p,orientation:i,dir:u,activationMode:d,children:t.jsx(xe.div,{dir:u,"data-orientation":i,...m,ref:n})})});Rf.displayName=Or;var Mf="TabsList",Af=l.forwardRef((e,n)=>{const{__scopeTabs:s,loop:o=!0,...r}=e,a=gl(Mf,s),i=Ef(s);return t.jsx(Dy,{asChild:!0,...i,orientation:a.orientation,dir:a.dir,loop:o,children:t.jsx(xe.div,{role:"tablist","aria-orientation":a.orientation,...r,ref:n})})});Af.displayName=Mf;var If="TabsTrigger",Pf=l.forwardRef((e,n)=>{const{__scopeTabs:s,value:o,disabled:r=!1,...a}=e,i=gl(If,s),c=Ef(s),d=Df(i.baseId,o),m=zf(i.baseId,o),u=o===i.value;return t.jsx(zy,{asChild:!0,...c,focusable:!r,active:u,children:t.jsx(xe.button,{type:"button",role:"tab","aria-selected":u,"aria-controls":m,"data-state":u?"active":"inactive","data-disabled":r?"":void 0,disabled:r,id:d,...a,ref:n,onMouseDown:ie(e.onMouseDown,f=>{!r&&f.button===0&&f.ctrlKey===!1?i.onValueChange(o):f.preventDefault()}),onKeyDown:ie(e.onKeyDown,f=>{r||f.target!==f.currentTarget||[" ","Enter"].includes(f.key)&&i.onValueChange(o)}),onFocus:ie(e.onFocus,()=>{const f=i.activationMode!=="manual";!u&&!r&&f&&i.onValueChange(o)})})})});Pf.displayName=If;var Lf="TabsContent",Of=l.forwardRef((e,n)=>{const{__scopeTabs:s,value:o,forceMount:r,children:a,...i}=e,c=gl(Lf,s),d=Df(c.baseId,o),m=zf(c.baseId,o),u=o===c.value,f=l.useRef(u);return l.useEffect(()=>{const p=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(p)},[]),t.jsx(dt,{present:r||u,children:({present:p})=>t.jsx(xe.div,{"data-state":u?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":d,hidden:!p,id:m,tabIndex:0,...i,ref:n,style:{...e.style,animationDuration:f.current?"0s":void 0},children:p&&a})})});Of.displayName=Lf;function Df(e,n){return`${e}-trigger-${n}`}function zf(e,n){return`${e}-content-${n}`}var _w=Rf,Tw=Af,Ew=Pf,Rw=Of,[Dr]=Jt("Tooltip",[Er]),zr=Er(),$f="TooltipProvider",Mw=700,ii="tooltip.open",[Aw,bl]=Dr($f),Ff=e=>{const{__scopeTooltip:n,delayDuration:s=Mw,skipDelayDuration:o=300,disableHoverableContent:r=!1,children:a}=e,i=l.useRef(!0),c=l.useRef(!1),d=l.useRef(0);return l.useEffect(()=>{const m=d.current;return()=>window.clearTimeout(m)},[]),t.jsx(Aw,{scope:n,isOpenDelayedRef:i,delayDuration:s,onOpen:l.useCallback(()=>{o<=0||(window.clearTimeout(d.current),i.current=!1)},[o]),onClose:l.useCallback(()=>{o<=0||(window.clearTimeout(d.current),d.current=window.setTimeout(()=>i.current=!0,o))},[o]),isPointerInTransitRef:c,onPointerInTransitChange:l.useCallback(m=>{c.current=m},[]),disableHoverableContent:r,children:a})};Ff.displayName=$f;var $s="Tooltip",[Iw,Qs]=Dr($s),Uf=e=>{const{__scopeTooltip:n,children:s,open:o,defaultOpen:r,onOpenChange:a,disableHoverableContent:i,delayDuration:c}=e,d=bl($s,e.__scopeTooltip),m=zr(n),[u,f]=l.useState(null),p=Mt(),h=l.useRef(0),g=i??d.disableHoverableContent,v=c??d.delayDuration,y=l.useRef(!1),[w,b]=Rn({prop:o,defaultProp:r??!1,onChange:R=>{R?(d.onOpen(),document.dispatchEvent(new CustomEvent(ii))):d.onClose(),a?.(R)},caller:$s}),j=l.useMemo(()=>w?y.current?"delayed-open":"instant-open":"closed",[w]),S=l.useCallback(()=>{window.clearTimeout(h.current),h.current=0,y.current=!1,b(!0)},[b]),N=l.useCallback(()=>{window.clearTimeout(h.current),h.current=0,b(!1)},[b]),C=l.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{y.current=!0,b(!0),h.current=0},v)},[v,b]);return l.useEffect(()=>()=>{h.current&&(window.clearTimeout(h.current),h.current=0)},[]),t.jsx(Tm,{...m,children:t.jsx(Iw,{scope:n,contentId:p,open:w,stateAttribute:j,trigger:u,onTriggerChange:f,onTriggerEnter:l.useCallback(()=>{d.isOpenDelayedRef.current?C():S()},[d.isOpenDelayedRef,C,S]),onTriggerLeave:l.useCallback(()=>{g?N():(window.clearTimeout(h.current),h.current=0)},[N,g]),onOpen:S,onClose:N,disableHoverableContent:g,children:s})})};Uf.displayName=$s;var li="TooltipTrigger",Bf=l.forwardRef((e,n)=>{const{__scopeTooltip:s,...o}=e,r=Qs(li,s),a=bl(li,s),i=zr(s),c=l.useRef(null),d=Ee(n,c,r.onTriggerChange),m=l.useRef(!1),u=l.useRef(!1),f=l.useCallback(()=>m.current=!1,[]);return l.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),t.jsx(Em,{asChild:!0,...i,children:t.jsx(xe.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...o,ref:d,onPointerMove:ie(e.onPointerMove,p=>{p.pointerType!=="touch"&&!u.current&&!a.isPointerInTransitRef.current&&(r.onTriggerEnter(),u.current=!0)}),onPointerLeave:ie(e.onPointerLeave,()=>{r.onTriggerLeave(),u.current=!1}),onPointerDown:ie(e.onPointerDown,()=>{r.open&&r.onClose(),m.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:ie(e.onFocus,()=>{m.current||r.onOpen()}),onBlur:ie(e.onBlur,r.onClose),onClick:ie(e.onClick,r.onClose)})})});Bf.displayName=li;var vl="TooltipPortal",[Pw,Lw]=Dr(vl,{forceMount:void 0}),qf=e=>{const{__scopeTooltip:n,forceMount:s,children:o,container:r}=e,a=Qs(vl,n);return t.jsx(Pw,{scope:n,forceMount:s,children:t.jsx(dt,{present:s||a.open,children:t.jsx(jr,{asChild:!0,container:r,children:o})})})};qf.displayName=vl;var ms="TooltipContent",Hf=l.forwardRef((e,n)=>{const s=Lw(ms,e.__scopeTooltip),{forceMount:o=s.forceMount,side:r="top",...a}=e,i=Qs(ms,e.__scopeTooltip);return t.jsx(dt,{present:o||i.open,children:i.disableHoverableContent?t.jsx(Wf,{side:r,...a,ref:n}):t.jsx(Ow,{side:r,...a,ref:n})})}),Ow=l.forwardRef((e,n)=>{const s=Qs(ms,e.__scopeTooltip),o=bl(ms,e.__scopeTooltip),r=l.useRef(null),a=Ee(n,r),[i,c]=l.useState(null),{trigger:d,onClose:m}=s,u=r.current,{onPointerInTransitChange:f}=o,p=l.useCallback(()=>{c(null),f(!1)},[f]),h=l.useCallback((g,v)=>{const y=g.currentTarget,w={x:g.clientX,y:g.clientY},b=Fw(w,y.getBoundingClientRect()),j=Uw(w,b),S=Bw(v.getBoundingClientRect()),N=Hw([...j,...S]);c(N),f(!0)},[f]);return l.useEffect(()=>()=>p(),[p]),l.useEffect(()=>{if(d&&u){const g=y=>h(y,u),v=y=>h(y,d);return d.addEventListener("pointerleave",g),u.addEventListener("pointerleave",v),()=>{d.removeEventListener("pointerleave",g),u.removeEventListener("pointerleave",v)}}},[d,u,h,p]),l.useEffect(()=>{if(i){const g=v=>{const y=v.target,w={x:v.clientX,y:v.clientY},b=d?.contains(y)||u?.contains(y),j=!qw(w,i);b?p():j&&(p(),m())};return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}},[d,u,i,m,p]),t.jsx(Wf,{...e,ref:a})}),[Dw,zw]=Dr($s,{isInside:!1}),$w=yb("TooltipContent"),Wf=l.forwardRef((e,n)=>{const{__scopeTooltip:s,children:o,"aria-label":r,onEscapeKeyDown:a,onPointerDownOutside:i,...c}=e,d=Qs(ms,s),m=zr(s),{onClose:u}=d;return l.useEffect(()=>(document.addEventListener(ii,u),()=>document.removeEventListener(ii,u)),[u]),l.useEffect(()=>{if(d.trigger){const f=p=>{p.target instanceof Node&&p.target.contains(d.trigger)&&u()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[d.trigger,u]),t.jsx(wr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:f=>f.preventDefault(),onDismiss:u,children:t.jsxs(Rm,{"data-state":d.stateAttribute,...m,...c,ref:n,style:{...c.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[t.jsx($w,{children:o}),t.jsx(Dw,{scope:s,isInside:!0,children:t.jsx(Ab,{id:d.contentId,role:"tooltip",children:r||o})})]})})});Hf.displayName=ms;var Vf="TooltipArrow",Kf=l.forwardRef((e,n)=>{const{__scopeTooltip:s,...o}=e,r=zr(s);return zw(Vf,s).isInside?null:t.jsx(Mm,{...r,...o,ref:n})});Kf.displayName=Vf;function Fw(e,n){const s=Math.abs(n.top-e.y),o=Math.abs(n.bottom-e.y),r=Math.abs(n.right-e.x),a=Math.abs(n.left-e.x);switch(Math.min(s,o,r,a)){case a:return"left";case r:return"right";case s:return"top";case o:return"bottom";default:throw new Error("unreachable")}}function Uw(e,n,s=5){const o=[];switch(n){case"top":o.push({x:e.x-s,y:e.y+s},{x:e.x+s,y:e.y+s});break;case"bottom":o.push({x:e.x-s,y:e.y-s},{x:e.x+s,y:e.y-s});break;case"left":o.push({x:e.x+s,y:e.y-s},{x:e.x+s,y:e.y+s});break;case"right":o.push({x:e.x-s,y:e.y-s},{x:e.x-s,y:e.y+s});break}return o}function Bw(e){const{top:n,right:s,bottom:o,left:r}=e;return[{x:r,y:n},{x:s,y:n},{x:s,y:o},{x:r,y:o}]}function qw(e,n){const{x:s,y:o}=e;let r=!1;for(let a=0,i=n.length-1;a<n.length;i=a++){const c=n[a],d=n[i],m=c.x,u=c.y,f=d.x,p=d.y;u>o!=p>o&&s<(f-m)*(o-u)/(p-u)+m&&(r=!r)}return r}function Hw(e){const n=e.slice();return n.sort((s,o)=>s.x<o.x?-1:s.x>o.x?1:s.y<o.y?-1:s.y>o.y?1:0),Ww(n)}function Ww(e){if(e.length<=1)return e.slice();const n=[];for(let o=0;o<e.length;o++){const r=e[o];for(;n.length>=2;){const a=n[n.length-1],i=n[n.length-2];if((a.x-i.x)*(r.y-i.y)>=(a.y-i.y)*(r.x-i.x))n.pop();else break}n.push(r)}n.pop();const s=[];for(let o=e.length-1;o>=0;o--){const r=e[o];for(;s.length>=2;){const a=s[s.length-1],i=s[s.length-2];if((a.x-i.x)*(r.y-i.y)>=(a.y-i.y)*(r.x-i.x))s.pop();else break}s.push(r)}return s.pop(),n.length===1&&s.length===1&&n[0].x===s[0].x&&n[0].y===s[0].y?n:n.concat(s)}var Vw=Ff,Kw=Uf,Gw=Bf,Yw=qf,Jw=Hf,Xw=Kf;function Lt({...e}){return t.jsx(Gu,{"data-slot":"dialog",...e})}function eo({...e}){return t.jsx(Ju,{"data-slot":"dialog-trigger",...e})}function Zw({...e}){return t.jsx(Zu,{"data-slot":"dialog-portal",...e})}function Qw({className:e,...n}){return t.jsx(Qu,{"data-slot":"dialog-overlay",className:O("fixed inset-0 z-40 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...n})}function Ot({className:e,children:n,...s}){return t.jsxs(Zw,{children:[t.jsx(Qw,{}),t.jsxs(em,{"data-slot":"dialog-content",className:O("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-lg",e),...s,children:[n,t.jsxs(im,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[t.jsx(Js,{className:"size-4"}),t.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Ut({className:e,...n}){return t.jsx("div",{"data-slot":"dialog-header",className:O("flex flex-col space-y-1.5 text-center sm:text-left",e),...n})}function Bt({className:e,...n}){return t.jsx(sm,{"data-slot":"dialog-title",className:O("text-lg font-semibold leading-none tracking-tight",e),...n})}function to({className:e,...n}){return t.jsx(rm,{"data-slot":"dialog-description",className:O("text-sm text-muted-foreground",e),...n})}function Gf({open:e,onOpenChange:n,title:s,description:o,confirmLabel:r="Confirm",variant:a="default",onConfirm:i}){return t.jsx(Lt,{open:e,onOpenChange:n,children:t.jsxs(Ot,{children:[t.jsx(Ut,{children:t.jsx(Bt,{children:s})}),t.jsx("p",{className:"text-sm text-muted-foreground",children:o}),t.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[t.jsx(te,{variant:"outline",size:"sm",onClick:()=>n(!1),children:"Cancel"}),t.jsx(te,{variant:a,size:"sm",onClick:()=>{i(),n(!1)},children:r})]})]})})}const ej="data:image/svg+xml,%3csvg%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eClaude%20Code%3c/title%3e%3cpath%20clip-rule='evenodd'%20d='M20.998%2010.949H24v3.102h-3v3.028h-1.487V20H18v-2.921h-1.487V20H15v-2.921H9V20H7.488v-2.921H6V20H4.487v-2.921H3V14.05H0V10.95h3V5h17.998v5.949zM6%2010.949h1.488V8.102H6v2.847zm10.51%200H18V8.102h-1.49v2.847z'%20fill='%23D97757'%20fill-rule='evenodd'%3e%3c/path%3e%3c/svg%3e",tj="data:image/svg+xml,%3csvg%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eCodex%3c/title%3e%3cpath%20d='M19.503%200H4.496A4.496%204.496%200%20000%204.496v15.007A4.496%204.496%200%20004.496%2024h15.007A4.496%204.496%200%200024%2019.503V4.496A4.496%204.496%200%200019.503%200z'%20fill='%23fff'%3e%3c/path%3e%3cpath%20d='M9.064%203.344a4.578%204.578%200%20012.285-.312c1%20.115%201.891.54%202.673%201.275.01.01.024.017.037.021a.09.09%200%2000.043%200%204.55%204.55%200%20013.046.275l.047.022.116.057a4.581%204.581%200%20012.188%202.399c.209.51.313%201.041.315%201.595a4.24%204.24%200%2001-.134%201.223.123.123%200%2000.03.115c.594.607.988%201.33%201.183%202.17.289%201.425-.007%202.71-.887%203.854l-.136.166a4.548%204.548%200%2001-2.201%201.388.123.123%200%2000-.081.076c-.191.551-.383%201.023-.74%201.494-.9%201.187-2.222%201.846-3.711%201.838-1.187-.006-2.239-.44-3.157-1.302a.107.107%200%2000-.105-.024c-.388.125-.78.143-1.204.138a4.441%204.441%200%2001-1.945-.466%204.544%204.544%200%2001-1.61-1.335c-.152-.202-.303-.392-.414-.617a5.81%205.81%200%2001-.37-.961%204.582%204.582%200%2001-.014-2.298.124.124%200%2000.006-.056.085.085%200%2000-.027-.048%204.467%204.467%200%2001-1.034-1.651%203.896%203.896%200%2001-.251-1.192%205.189%205.189%200%2001.141-1.6c.337-1.112.982-1.985%201.933-2.618.212-.141.413-.251.601-.33.215-.089.43-.164.646-.227a.098.098%200%2000.065-.066%204.51%204.51%200%2001.829-1.615%204.535%204.535%200%20011.837-1.388zm3.482%2010.565a.637.637%200%20000%201.272h3.636a.637.637%200%20100-1.272h-3.636zM8.462%209.23a.637.637%200%2000-1.106.631l1.272%202.224-1.266%202.136a.636.636%200%20101.095.649l1.454-2.455a.636.636%200%2000.005-.64L8.462%209.23z'%20fill='url(%23lobe-icons-codex-_R_0_)'%3e%3c/path%3e%3cdefs%3e%3clinearGradient%20gradientUnits='userSpaceOnUse'%20id='lobe-icons-codex-_R_0_'%20x1='12'%20x2='12'%20y1='3'%20y2='21'%3e%3cstop%20stop-color='%23B1A7FF'%3e%3c/stop%3e%3cstop%20offset='.5'%20stop-color='%237A9DFF'%3e%3c/stop%3e%3cstop%20offset='1'%20stop-color='%233941FF'%3e%3c/stop%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e",nj="data:image/svg+xml,%3csvg%20fill='%237dd3fc'%20fill-rule='evenodd'%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eOpenCode%3c/title%3e%3cpath%20d='M16%206H8v12h8V6zm4%2016H4V2h16v20z'%3e%3c/path%3e%3c/svg%3e",sj="data:image/svg+xml,%3csvg%20fill='%23ff6900'%20fill-rule='evenodd'%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eMiMo%20Code%3c/title%3e%3cpath%20d='M.958%2015.936a.459.459%200%2001.459.44v2.729a.46.46%200%2001-.918%200v-2.729a.459.459%200%2001.459-.44zm4.814-2.035a.46.46%200%2001.553.45v4.754a.458.458%200%2011-.918%200V15.48L3.74%2017.202a.462.462%200%2001-.655.016.462.462%200%2001-.065-.082L.628%2014.67a.459.459%200%2001.658-.637l2.124%202.187%202.127-2.188a.46.46%200%2001.235-.13zm2.068.004a.46.46%200%2001.458.445v4.755a.46.46%200%2001-.458.458.459.459%200%2001-.458-.458V14.35a.459.459%200%2001.458-.445zm1.973%202.014a.46.46%200%2001.46.457v2.729a.46.46%200%2001-.784.324.46.46%200%2001-.134-.324v-2.729a.46.46%200%2001.458-.458zm.002-2.045a.458.458%200%2001.328.157l2.127%202.19%202.125-2.19a.459.459%200%2001.784.318v4.756a.46.46%200%2001-.455.458.46.46%200%2001-.458-.458V15.48l-1.667%201.723a.46.46%200%2001-.65.008l-.005-.005c0-.002-.002-.002-.004-.003l-2.455-2.534a.46.46%200%2001-.008-.667.461.461%200%2001.338-.128zm6.797%201.206a.46.46%200%2001.53.651A1.966%201.966%200%200019.81%2018.4a.462.462%200%2001.623.18.46.46%200%2001-.181.624%202.863%202.863%200%2001-1.38.353l-.142-.004a2.88%202.88%200%2001-2.393-4.263.461.461%200%2001.274-.21zm.864-.931a2.884%202.884%200%20013.915%203.914.46.46%200%2001-.402.24l-.057-.004a.458.458%200%2001-.164-.055.46.46%200%2001-.182-.622%201.967%201.967%200%2000-2.669-2.67.459.459%200%2011-.441-.803zM9.59%206.368c1.481%200%201.696%201.202%201.696%201.654v2.648h-.917v-.432c-.26.346-.792.535-1.36.535-.133%200-1.289-.03-1.384-1.136-.082-.932.675-1.61%202.053-1.61h.691c0-.563-.367-.886-.983-.886-.44.013-.864.174-1.2.458l-.36-.664c.484-.379%201.012-.567%201.764-.567zm4.427.1c1.263%200%202.082.97%202.083%202.15%200%201.181-.824%202.154-2.083%202.154-1.26%200-2.084-.972-2.084-2.152%200-1.18.82-2.153%202.084-2.153zm6.801.015c.68%200%201.202.465%201.197%201.548v2.642H21.1V8.29c0-.312-.002-.98-.63-.98s-.628.667-.628.838v2.524h-.89V8.148c0-.17-.001-.838-.63-.838-.628%200-.628.668-.628.98v2.383h-.917v-4.03h.917V7a1.22%201.22%200%2001.947-.516c.398%200%20.76.193.982.686a1.321%201.321%200%20011.195-.686zm-18.093.872l1.457-1.772H5.32L3.311%208.07l2.14%202.602H4.24L2.725%208.796%201.21%2010.672H0L2.138%208.07.13%205.583h1.138l1.458%201.772zm4.149%203.317h-.916V6.644h.916v4.028zm16.99%200h-.916V6.644h.916v4.028zM9.925%208.71c-1.055%200-1.359.412-1.326.742.032.329.324.537.757.537a1.013%201.013%200%20001.014-.968l.002-.31h-.447zM14.018%207.3c-.663%200-1.184.487-1.184%201.32%200%20.832.52%201.32%201.184%201.32.662%200%201.182-.49%201.182-1.32%200-.832-.52-1.32-1.182-1.32zM6.417%205.001a.568.568%200%2001.587.582.588.588%200%2001-1.175%200A.57.57%200%20016.417%205zm16.991%200a.57.57%200%2001.592.582.588.588%200%2001-1.174%200%20.57.57%200%2001.357-.542.572.572%200%2001.225-.04z'%3e%3c/path%3e%3c/svg%3e",oj=""+new URL("agent-inspector-58K1_MsC.ico",import.meta.url).href,rj={"agent-inspector":"Inspector",codex:"Codex",opencode:"OpenCode","mimo-code":"MiMo Code","claude-code":"Claude Code","ai-sdk":"AI SDK"};function ho(e){return e?.toLowerCase()??""}function Wn(e,n){for(const s of n)if(e.includes(s))return!0;return!1}function yl(e){const n=[ho(e.userAgent),ho(e.conversationId),ho(e.clientProjectFolder)].join(" ");return Wn(n,["agent-inspector","agent inspector","provider-test"])?"agent-inspector":Wn(n,["mimocode","mimo-code","mimo code"])?"mimo-code":Wn(n,["opencode","open-code","open code"])?"opencode":Wn(n,["claude-code","claude code","claudecode","claude-cli","claude cli"])?"claude-code":Wn(n,["codex desktop","codex-cli","openai-codex","codex"])?"codex":Wn(ho(e.userAgent),["ai-sdk","ai/"])?"ai-sdk":"unknown"}function $r(e){switch(e){case"agent-inspector":case"codex":case"opencode":case"mimo-code":case"claude-code":case"ai-sdk":return rj[e];case"unknown":return null}}function aj(e){switch(e){case"codex":case"opencode":case"mimo-code":case"claude-code":return"IDE";case"agent-inspector":case"ai-sdk":case"unknown":return"CLIENT"}}const ij={"agent-inspector":oj,codex:tj,opencode:nj,"mimo-code":sj,"claude-code":ej},lj={"agent-inspector":"border-orange-700/15 bg-orange-500/[0.08] dark:border-orange-200/25 dark:bg-orange-300/[0.12]",codex:"border-cyan-700/15 bg-cyan-500/[0.08] dark:border-cyan-200/20 dark:bg-cyan-300/[0.08]",opencode:"border-sky-700/15 bg-sky-500/[0.09] dark:border-sky-200/25 dark:bg-sky-300/[0.12]","mimo-code":"border-orange-700/15 bg-orange-500/[0.09] dark:border-orange-200/25 dark:bg-orange-400/[0.12]","claude-code":"border-amber-700/15 bg-amber-500/[0.08] dark:border-amber-100/20 dark:bg-amber-300/[0.09]"},cj={"agent-inspector":"p-0.5 drop-shadow-[0_0_8px_rgba(251,146,60,0.35)]",codex:"p-0.5",opencode:"p-1 drop-shadow-[0_0_8px_rgba(125,211,252,0.35)]","mimo-code":"p-0.5 drop-shadow-[0_0_8px_rgba(255,105,0,0.35)]","claude-code":"p-0.5"};function Fr({client:e,className:n,decorative:s=!1}){if(e==="unknown")return null;const o=$r(e);if(o===null)return null;if(e==="ai-sdk")return t.jsx("span",{className:O("inline-flex size-6 shrink-0 items-center justify-center rounded-md border border-cyan-700/15 bg-cyan-500/[0.08] text-[var(--inspector-status-cool)] shadow-sm dark:border-cyan-200/20 dark:bg-cyan-300/[0.08]",n),"aria-label":s?void 0:o,"aria-hidden":s?!0:void 0,title:o,children:t.jsx(mu,{className:"size-1/2","aria-hidden":"true"})});const r=ij[e];return t.jsx("span",{className:O("inline-flex size-6 shrink-0 items-center justify-center rounded-md border p-0 shadow-sm",lj[e],n),"aria-label":s?void 0:o,"aria-hidden":s?!0:void 0,title:o,children:t.jsx("img",{src:r,alt:"",className:O("size-full object-contain",cj[e]),"aria-hidden":"true"})})}const dj="data:image/svg+xml,%3csvg%20height='2500'%20viewBox='0%206.603%201192.672%201193.397'%20width='2500'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='m233.96%20800.215%20234.684-131.678%203.947-11.436-3.947-6.363h-11.436l-39.221-2.416-134.094-3.624-116.296-4.832-112.67-6.04-28.35-6.04-26.577-35.035%202.738-17.477%2023.84-16.027%2034.147%202.98%2075.463%205.155%20113.235%207.812%2082.147%204.832%20121.692%2012.644h19.329l2.738-7.812-6.604-4.832-5.154-4.832-117.182-79.41-126.845-83.92-66.443-48.321-35.92-24.484-18.12-22.953-7.813-50.093%2032.618-35.92%2043.812%202.98%2011.195%202.98%2044.375%2034.147%2094.792%2073.37%20123.786%2091.167%2018.12%2015.06%207.249-5.154.886-3.624-8.135-13.61-67.329-121.692-71.838-123.785-31.974-51.302-8.456-30.765c-2.98-12.645-5.154-23.275-5.154-36.242l37.127-50.416%2020.537-6.604%2049.53%206.604%2020.86%2018.121%2030.765%2070.39%2049.852%20110.818%2077.315%20150.684%2022.631%2044.698%2012.08%2041.396%204.51%2012.645h7.813v-7.248l6.362-84.886%2011.759-104.215%2011.436-134.094%203.946-37.772%2018.685-45.262%2037.127-24.482%2028.994%2013.852%2023.839%2034.148-3.303%2022.067-14.174%2092.134-27.785%20144.323-18.121%2096.644h10.55l12.08-12.08%2048.887-64.913%2082.147-102.685%2036.242-40.752%2042.282-45.02%2027.14-21.423h51.303l37.772%2056.135-16.913%2057.986-52.832%2067.007-43.812%2056.779-62.82%2084.563-39.22%2067.651%203.623%205.396%209.343-.886%20141.906-30.201%2076.671-13.852%2091.49-15.705%2041.396%2019.329%204.51%2019.65-16.269%2040.189-97.852%2024.16-114.764%2022.954-170.9%2040.43-2.093%201.53%202.416%202.98%2076.993%207.248%2032.94%201.771h80.617l150.12%2011.195%2039.222%2025.933%2023.517%2031.732-3.946%2024.16-60.403%2030.766-81.503-19.33-190.228-45.26-65.235-16.27h-9.02v5.397l54.362%2053.154%2099.624%2089.96%20124.752%20115.973%206.362%2028.671-16.027%2022.63-16.912-2.415-109.611-82.47-42.282-37.127-95.758-80.618h-6.363v8.456l22.067%2032.296%20116.537%20175.167%206.04%2053.719-8.456%2017.476-30.201%2010.55-33.181-6.04-68.215-95.758-70.39-107.84-56.778-96.644-6.926%203.947-33.503%20360.886-15.705%2018.443-36.243%2013.852-30.201-22.953-16.027-37.127%2016.027-73.37%2019.329-95.758%2015.704-76.107%2014.175-94.55%208.456-31.41-.563-2.094-6.927.886-71.275%2097.852-108.402%20146.497-85.772%2091.812-20.537%208.134-35.597-18.443%203.301-32.94%2019.893-29.315%20118.712-151.007%2071.597-93.583%2046.228-54.04-.322-7.813h-2.738l-315.302%20204.725-56.135%207.248-24.16-22.63%202.98-37.128%2011.435-12.08%2094.792-65.236-.322.323z'%20fill='%23d97757'/%3e%3c/svg%3e",uj="data:image/svg+xml,%3csvg%20height='2500'%20viewBox='-1%20-.1%20949.1%20959.8'%20width='2474'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='m925.8%20456.3c10.4%2023.2%2017%2048%2019.7%2073.3%202.6%2025.3%201.3%2050.9-4.1%2075.8-5.3%2024.9-14.5%2048.8-27.3%2070.8-8.4%2014.7-18.3%2028.5-29.7%2041.2-11.3%2012.6-23.9%2024-37.6%2034-13.8%2010-28.5%2018.4-44.1%2025.3-15.5%206.8-31.7%2012-48.3%2015.4-7.8%2024.2-19.4%2047.1-34.4%2067.7-14.9%2020.6-33%2038.7-53.6%2053.6-20.6%2015-43.4%2026.6-67.6%2034.4-24.2%207.9-49.5%2011.8-75%2011.8-16.9.1-33.9-1.7-50.5-5.1-16.5-3.5-32.7-8.8-48.2-15.7s-30.2-15.5-43.9-25.5c-13.6-10-26.2-21.5-37.4-34.2-25%205.4-50.6%206.7-75.9%204.1-25.3-2.7-50.1-9.3-73.4-19.7-23.2-10.3-44.7-24.3-63.6-41.4s-35-37.1-47.7-59.1c-8.5-14.7-15.5-30.2-20.8-46.3s-8.8-32.7-10.6-49.6c-1.8-16.8-1.7-33.8.1-50.7%201.8-16.8%205.5-33.4%2010.8-49.5-17-18.9-31-40.4-41.4-63.6-10.3-23.3-17-48-19.6-73.3-2.7-25.3-1.3-50.9%204-75.8s14.5-48.8%2027.3-70.8c8.4-14.7%2018.3-28.6%2029.6-41.2s24-24%2037.7-34%2028.5-18.5%2044-25.3c15.6-6.9%2031.8-12%2048.4-15.4%207.8-24.3%2019.4-47.1%2034.3-67.7%2015-20.6%2033.1-38.7%2053.7-53.7%2020.6-14.9%2043.4-26.5%2067.6-34.4%2024.2-7.8%2049.5-11.8%2075-11.7%2016.9-.1%2033.9%201.6%2050.5%205.1s32.8%208.7%2048.3%2015.6c15.5%207%2030.2%2015.5%2043.9%2025.5%2013.7%2010.1%2026.3%2021.5%2037.5%2034.2%2024.9-5.3%2050.5-6.6%2075.8-4s50%209.3%2073.3%2019.6c23.2%2010.4%2044.7%2024.3%2063.6%2041.4%2018.9%2017%2035%2036.9%2047.7%2059%208.5%2014.6%2015.5%2030.1%2020.8%2046.3%205.3%2016.1%208.9%2032.7%2010.6%2049.6%201.8%2016.9%201.8%2033.9-.1%2050.8-1.8%2016.9-5.5%2033.5-10.8%2049.6%2017.1%2018.9%2031%2040.3%2041.4%2063.6zm-333.2%20426.9c21.8-9%2041.6-22.3%2058.3-39s30-36.5%2039-58.4c9-21.8%2013.7-45.2%2013.7-68.8v-223q-.1-.3-.2-.7-.1-.3-.3-.6-.2-.3-.5-.5-.3-.3-.6-.4l-80.7-46.6v269.4c0%202.7-.4%205.5-1.1%208.1-.7%202.7-1.7%205.2-3.1%207.6s-3%204.6-5%206.5a32.1%2032.1%200%200%201%20-6.5%205l-191.1%20110.3c-1.6%201-4.3%202.4-5.7%203.2%207.9%206.7%2016.5%2012.6%2025.5%2017.8%209.1%205.2%2018.5%209.6%2028.3%2013.2%209.8%203.5%2019.9%206.2%2030.1%208%2010.3%201.8%2020.7%202.7%2031.1%202.7%2023.6%200%2047-4.7%2068.8-13.8zm-455.1-151.4c11.9%2020.5%2027.6%2038.3%2046.3%2052.7%2018.8%2014.4%2040.1%2024.9%2062.9%2031s46.6%207.7%2070%204.6%2045.9-10.7%2066.4-22.5l193.2-111.5.5-.5q.2-.2.3-.6.2-.3.3-.6v-94l-233.2%20134.9c-2.4%201.4-4.9%202.4-7.5%203.2-2.7.7-5.4%201-8.2%201-2.7%200-5.4-.3-8.1-1-2.6-.8-5.2-1.8-7.6-3.2l-191.1-110.4c-1.7-1-4.2-2.5-5.6-3.4-1.8%2010.3-2.7%2020.7-2.7%2031.1s1%2020.8%202.8%2031.1c1.8%2010.2%204.6%2020.3%208.1%2030.1%203.6%209.8%208%2019.2%2013.2%2028.2zm-50.2-417c-11.8%2020.5-19.4%2043.1-22.5%2066.5s-1.5%2047.1%204.6%2070c6.1%2022.8%2016.6%2044.1%2031%2062.9%2014.4%2018.7%2032.3%2034.4%2052.7%2046.2l193.1%20111.6q.3.1.7.2h.7q.4%200%20.7-.2.3-.1.6-.3l81-46.8-233.2-134.6c-2.3-1.4-4.5-3.1-6.5-5a32.1%2032.1%200%200%201%20-5-6.5c-1.3-2.4-2.4-4.9-3.1-7.6-.7-2.6-1.1-5.3-1-8.1v-227.1c-9.8%203.6-19.3%208-28.3%2013.2-9%205.3-17.5%2011.3-25.5%2018-7.9%206.7-15.3%2014.1-22%2022.1-6.7%207.9-12.6%2016.5-17.8%2025.5zm663.3%20154.4c2.4%201.4%204.6%203%206.6%205%201.9%201.9%203.6%204.1%205%206.5%201.3%202.4%202.4%205%203.1%207.6.6%202.7%201%205.4.9%208.2v227.1c32.1-11.8%2060.1-32.5%2080.8-59.7%2020.8-27.2%2033.3-59.7%2036.2-93.7s-3.9-68.2-19.7-98.5-39.9-55.5-69.5-72.5l-193.1-111.6q-.3-.1-.7-.2h-.7q-.3.1-.7.2-.3.1-.6.3l-80.6%2046.6%20233.2%20134.7zm80.5-121h-.1v.1zm-.1-.1c5.8-33.6%201.9-68.2-11.3-99.7-13.1-31.5-35-58.6-63-78.2-28-19.5-61-30.7-95.1-32.2-34.2-1.4-68%206.9-97.6%2023.9l-193.1%20111.5q-.3.2-.5.5l-.4.6q-.1.3-.2.7-.1.3-.1.7v93.2l233.2-134.7c2.4-1.4%205-2.4%207.6-3.2%202.7-.7%205.4-1%208.1-1%202.8%200%205.5.3%208.2%201%202.6.8%205.1%201.8%207.5%203.2l191.1%20110.4c1.7%201%204.2%202.4%205.6%203.3zm-505.3-103.2c0-2.7.4-5.4%201.1-8.1.7-2.6%201.7-5.2%203.1-7.6%201.4-2.3%203-4.5%205-6.5%201.9-1.9%204.1-3.6%206.5-4.9l191.1-110.3c1.8-1.1%204.3-2.5%205.7-3.2-26.2-21.9-58.2-35.9-92.1-40.2-33.9-4.4-68.3%201-99.2%2015.5-31%2014.5-57.2%2037.6-75.5%2066.4-18.3%2028.9-28%2062.3-28%2096.5v223q.1.4.2.7.1.3.3.6.2.3.5.6.2.2.6.4l80.7%2046.6zm43.8%20294.7%20103.9%2060%20103.9-60v-119.9l-103.8-60-103.9%2060z'/%3e%3c/svg%3e",mj="data:image/svg+xml,%3csvg%20fill='none'%20height='1320'%20viewBox='3.771%206.973%2023.993%2017.652'%20width='2500'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='m27.501%208.469c-.252-.123-.36.111-.508.23-.05.04-.093.09-.135.135-.368.395-.797.652-1.358.621-.821-.045-1.521.213-2.14.842-.132-.776-.57-1.238-1.235-1.535-.349-.155-.701-.309-.944-.645-.171-.238-.217-.504-.303-.765-.054-.159-.108-.32-.29-.348-.197-.031-.274.135-.352.273-.31.567-.43%201.192-.419%201.825.028%201.421.628%202.554%201.82%203.36.136.093.17.186.128.321-.081.278-.178.547-.264.824-.054.178-.135.217-.324.14a5.448%205.448%200%200%201%20-1.719-1.169c-.848-.82-1.614-1.726-2.57-2.435-.225-.166-.449-.32-.681-.467-.976-.95.128-1.729.383-1.82.267-.096.093-.428-.77-.424s-1.653.293-2.659.677a2.782%202.782%200%200%201%20-.46.135%209.554%209.554%200%200%200%20-2.853-.1c-1.866.21-3.356%201.092-4.452%202.6-1.315%201.81-1.625%203.87-1.246%206.018.399%202.261%201.552%204.136%203.326%205.601%201.837%201.518%203.955%202.262%206.37%202.12%201.466-.085%203.1-.282%204.942-1.842.465.23.952.322%201.762.392.623.059%201.223-.031%201.687-.127.728-.154.677-.828.414-.953-2.132-.994-1.665-.59-2.09-.916%201.084-1.285%202.717-2.619%203.356-6.94.05-.343.007-.558%200-.837-.004-.168.034-.235.228-.254a4.084%204.084%200%200%200%201.529-.47c1.382-.757%201.938-1.997%202.07-3.485.02-.227-.004-.463-.243-.582zm-12.041%2013.391c-2.067-1.627-3.07-2.162-3.483-2.138-.387.021-.318.465-.233.754.089.285.205.482.368.732.113.166.19.414-.112.598-.666.414-1.823-.139-1.878-.166-1.347-.793-2.473-1.842-3.267-3.276-.765-1.38-1.21-2.861-1.284-4.441-.02-.383.093-.518.472-.586a4.692%204.692%200%200%201%201.514-.04c2.109.31%203.905%201.255%205.41%202.749.86.853%201.51%201.871%202.18%202.865.711%201.057%201.478%202.063%202.454%202.887.343.289.619.51.881.672-.792.088-2.117.107-3.022-.61zm.99-6.38a.304.304%200%201%201%20.609%200c0%20.17-.136.304-.306.304a.3.3%200%200%201%20-.303-.305zm3.077%201.581c-.197.08-.394.15-.584.159a1.246%201.246%200%200%201%20-.79-.252c-.27-.227-.463-.354-.546-.752a1.752%201.752%200%200%201%20.016-.582c.07-.324-.008-.531-.235-.72-.187-.155-.422-.196-.682-.196a.551.551%200%200%201%20-.252-.078c-.108-.055-.197-.19-.112-.356.027-.053.159-.183.19-.207.352-.201.758-.135%201.134.016.349.142.611.404.99.773.388.448.457.573.678.906.174.264.333.534.441.842.066.192-.02.35-.248.448z'%20fill='%234d6bfe'/%3e%3c/svg%3e",fj=""+new URL("minimax-BPMzvuL-.jpeg",import.meta.url).href,pj=""+new URL("alibaba-TTwafVwX.svg",import.meta.url).href,hj=""+new URL("qwen-mMn3f5ul.webp",import.meta.url).href,xj=""+new URL("zhipuai-BPNAnxo-.svg",import.meta.url).href,gj={"claude-":"anthropic","gpt-":"openai","o1-":"openai","o3-":"openai","deepseek-":"deepseek",MiniMax:"minimax",qwen:"qwen"};function bj(e){return e.replace(/[_\s]+/g,"-").split(/[/:@]/).some(s=>s.startsWith("glm-"))}function vj(e){if(e===null)return"unknown";const n=e.toLowerCase();if(bj(n))return"zhipuai";for(const[s,o]of Object.entries(gj))if(n.startsWith(s.toLowerCase()))return o;return"unknown"}const Dn={width:24,height:24,objectFit:"contain"},yj=Pn.memo(({className:e})=>t.jsx("img",{src:dj,alt:"Anthropic",className:e,style:Dn})),wj=Pn.memo(({className:e})=>t.jsx("img",{src:uj,alt:"OpenAI",className:e,style:{...Dn,background:"white",borderRadius:"4px"}})),jj=Pn.memo(({className:e})=>t.jsx("img",{src:mj,alt:"DeepSeek",className:e,style:Dn})),Sj=Pn.memo(({className:e})=>t.jsx("img",{src:fj,alt:"MiniMax",className:e,style:Dn})),Nj=Pn.memo(({className:e})=>t.jsx("img",{src:pj,alt:"Alibaba",className:e,style:Dn})),Cj=Pn.memo(({className:e})=>t.jsx("img",{src:hj,alt:"Qwen",className:e,style:Dn})),kj=Pn.memo(({className:e})=>t.jsx("img",{src:xj,alt:"ZhipuAI",className:e,style:Dn}));function _j({provider:e,className:n}){switch(e){case"anthropic":return t.jsx(yj,{className:n});case"openai":return t.jsx(wj,{className:n});case"deepseek":return t.jsx(jj,{className:n});case"minimax":return t.jsx(Sj,{className:n});case"alibaba":return t.jsx(Nj,{className:n});case"qwen":return t.jsx(Cj,{className:n});case"zhipuai":return t.jsx(kj,{className:n});case"unknown":return null}}function bs({delayDuration:e=600,...n}){return t.jsx(Vw,{"data-slot":"tooltip-provider",delayDuration:e,...n})}function nt({...e}){return t.jsx(Kw,{"data-slot":"tooltip",...e})}function st({...e}){return t.jsx(Gw,{"data-slot":"tooltip-trigger",...e})}function ot({className:e,sideOffset:n=0,children:s,...o}){return t.jsx(Yw,{children:t.jsxs(Jw,{"data-slot":"tooltip-content",sideOffset:n,className:O("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...o,children:[s,t.jsx(Xw,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}const Tj=3;function Ej({items:e,ariaLabel:n,className:s}){if(e.length===0)return t.jsx("span",{className:O("flex h-8 w-12 shrink-0 items-center",s),"aria-hidden":"true"});const o=e.slice(0,Tj),r=e.length-o.length;return t.jsx(bs,{delayDuration:150,children:t.jsxs("span",{className:O("flex h-8 w-12 shrink-0 items-center",s),"aria-label":n,children:[o.map((a,i)=>t.jsxs(nt,{children:[t.jsx(st,{asChild:!0,children:t.jsx("span",{className:O("border border-border bg-muted/40 inline-flex size-6 shrink-0 items-center justify-center rounded-md",i>0&&"-ml-2"),children:t.jsx(_j,{provider:a.provider,className:"size-4"})})}),t.jsx(ot,{children:a.tooltip})]},`${a.provider}-${String(i)}`)),r>0&&t.jsxs("span",{className:"border border-border bg-muted/40 -ml-2 inline-flex h-6 min-w-6 shrink-0 items-center justify-center rounded-md px-1 font-mono text-[10px] text-muted-foreground",children:["+",r]})]})})}const Rj=[["/v1/messages","anthropic"],["/v1/chat/completions","openai"],["/chat/completions","openai"],["/v1/responses","openai"],["/responses","openai"]];function Mj(e){const n=e.split("?")[0]??"";for(const[s,o]of Rj)if(n===s)return o;return"unknown"}function Yf(e,n){for(const s of Array.from(e))n(s)}const Aj=/[\u3000-\u9FFF\uAC00-\uD7FF\uF900-\uFAFF\uFF00-\uFFEF\u{1F300}-\u{1FAFF}]/u;function wl(e){if(e.length===0)return 0;let n=0,s=0;return Yf(e,o=>{Aj.test(o)?n+=1:s+=1}),Math.ceil(n*1)+Math.ceil(s/4)}function jl(e){if(e.length===0)return 0;let n=0;return Yf(e,()=>{n+=1}),n}function Sl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ne(e,n){return e===null||typeof e!="object"||Array.isArray(e)?void 0:Object.getOwnPropertyDescriptor(e,n)?.value}const Ij=["file","shell","browser","web","mcp","code","other"];function ci(e){const n=e.replace(/\s+/g," ").trim();return n.length<=120?n:`${n.slice(0,119)}...`}function Jf(e){if(e===null)return null;const n=e.replace(/\s+/g," ").trim();if(n.length===0)return null;const s=n.search(/[.!?。!?]/);return s>=24?ci(n.slice(0,s+1)):ci(n)}function Pj(e,n){return`${e} ${n??""}`.toLowerCase()}function Vn(e,n){return n.some(s=>e.includes(s))}function Xf(e,n){const s=Pj(e,n);return e.startsWith("mcp__")||e.startsWith("inspector_")||Vn(s,[" mcp","model context protocol"])?"mcp":Vn(s,["bash","shell","terminal","command","powershell","exec","process"])?"shell":Vn(s,["browser","playwright","screenshot","click","navigate","page","tab"])?"browser":Vn(s,["read","write","edit","file","glob","grep","patch","filesystem","directory"])?"file":Vn(s,["web","search","http","url","fetch"])?"web":Vn(s,["code","typescript","javascript","python","repl"])?"code":"other"}function Zf(e){const n=ne(e,"properties");return n===null||typeof n!="object"||Array.isArray(n)?[]:Object.keys(n).sort((s,o)=>s.localeCompare(o))}function Qf(e){const n=ne(e,"required");if(!Array.isArray(n))return[];const s=[];for(const o of n)typeof o=="string"&&o.length>0&&s.push(o);return s.sort((o,r)=>o.localeCompare(r))}function Lj(e){const n=ne(e,"name");if(typeof n!="string"||n.length===0)return null;const s=ne(e,"description"),o=ne(e,"input_schema")??null,r=typeof s=="string"?s:null;return{name:n,description:r,descriptionPreview:Jf(r),category:Xf(n,r),parameterCount:Zf(o).length,requiredParameters:Qf(o),schema:o}}function Oj(e){const n=ne(e,"function"),s=ne(e,"type");if(n===void 0&&typeof s!="string")return null;const o=ne(n,"name")??ne(e,"name")??(typeof s=="string"?s:void 0);if(typeof o!="string"||o.length===0)return null;const r=ne(n,"description")??ne(e,"description"),a=ne(n,"parameters")??ne(e,"parameters")??null,i=typeof r=="string"?r:null;return{name:o,description:i,descriptionPreview:Jf(i),category:Xf(o,i),parameterCount:Zf(a).length,requiredParameters:Qf(a),schema:a}}function Dj(e){const n=Oj(e);return n!==null?n:Lj(e)}function zj(e){if(e==null)return null;if(typeof e=="string")return e;const n=ne(e,"type"),s=ne(e,"name"),o=ne(ne(e,"function"),"name");if(typeof n=="string"&&typeof o=="string"&&o.length>0)return`${n}: ${o}`;if(typeof n=="string"&&typeof s=="string"&&s.length>0)return`${n}: ${s}`;if(typeof n=="string")return n;const r=JSON.stringify(e);return r===void 0?null:ci(r)}function $j(e){const n=new Map;for(const s of e)n.set(s.category,(n.get(s.category)??0)+1);return Ij.flatMap(s=>{const o=n.get(s)??0;return o>0?[{category:s,count:o}]:[]})}function Nl(e){const n=ne(e,"tools");if(!Array.isArray(n)||n.length===0)return null;const s=[];for(const o of n){const r=Dj(o);r!==null&&s.push(r)}return s.length===0?null:{tools:s,toolChoiceLabel:zj(ne(e,"tool_choice")),categories:$j(s)}}function En(e){return{parsed:null,comparisonValue:e,messageCount:null,toolCount:null}}const ss={parsed:null,toolNames:null};function Fj(e){if(typeof e=="string")return e;if(!Array.isArray(e))return"";const n=[];for(const s of e){if(s===null||typeof s!="object")continue;const o=s;switch(o.type){case"text":typeof o.text=="string"&&n.push(o.text);break;case"thinking":case"think":typeof o.thinking=="string"&&n.push(o.thinking);break;case"tool_use":{const a=typeof o.name=="string"?o.name:"",i=o.input!==void 0?JSON.stringify(o.input):"";n.push(`${a} ${i}`.trim());break}case"tool_result":{const a=o.content;if(typeof a=="string")n.push(a);else if(Array.isArray(a)){for(const i of a)if(i!==null&&typeof i=="object"){const c=i.text;typeof c=="string"&&n.push(c)}}break}case"image":n.push("[image]");break}}return n.join(`
|
|
43
|
-
`)}function Uj(e){if(typeof e=="string")return e;if(!Array.isArray(e))return"";const n=[];for(const s of e)if(s!==null&&typeof s=="object"){const o=s.text;s.type==="text"&&typeof o=="string"&&n.push(o)}return n.join(`
|
|
44
|
-
`)}function Bj(e){if(!Array.isArray(e))return"";const n=[];for(const s of e){if(s===null||typeof s!="object")continue;const o=s;typeof o.name=="string"&&n.push(o.name),typeof o.description=="string"&&n.push(o.description),o.input_schema!==void 0&&n.push(JSON.stringify(o.input_schema))}return n.join(`
|
|
45
|
-
`)}function ma(e,n,s,o){return{role:e,label:n,text:s,size:wl(s),characters:jl(s),path:o}}const qj={format:"anthropic",analyzeRequest(e){if(e===null)return En(e);try{const n=JSON.parse(e),s=Nl(n)?.tools.length??null,o=Yh.safeParse(n);return o.success?{parsed:o.data,comparisonValue:o.data,messageCount:o.data.messages.length,toolCount:s}:En(e)}catch{return En(e)}},analyzeResponse(e){if(e===null)return ss;try{let n=JSON.parse(e);typeof n=="string"&&(n=JSON.parse(n));const s=Xh.safeParse(n);if(!s.success)return ss;const o=s.data.content.filter(r=>r.type==="tool_use").map(r=>r.name);return{parsed:s.data,toolNames:o.length>0?o:null}}catch{return ss}},anatomySegments(e){if(e===null||typeof e!="object")return null;const n=e,s=[];if(n.system!==void 0){const o=Uj(n.system);o.length>0&&s.push(ma("system","system",o,"/system"))}if(Array.isArray(n.messages)&&n.messages.forEach((o,r)=>{if(o===null||typeof o!="object")return;const a=o,i=a.role==="user"||a.role==="assistant"?a.role:"user",c=Fj(a.content);s.push(ma(i,`[${r}] ${i}`,c,`/messages/${r}`))}),Array.isArray(n.tools)&&n.tools.length>0){const o=Bj(n.tools);s.push(ma("tools","tools",o,"/tools"))}return s.length>0?s:null}};function di(e){if(typeof e=="string")return e;if(!Array.isArray(e))return"";const n=[];for(const s of e){if(s===null||typeof s!="object")continue;const o=s,r=o.type;(r==="text"||r==="input_text"||r==="output_text")&&typeof o.text=="string"?n.push(o.text):(r==="image_url"||r==="input_image")&&n.push("[image]")}return n.join(`
|
|
46
|
-
`)}function Hj(e){const n=[],s=di(e.content);s.length>0&&n.push(s);const o=typeof e.reasoning_content=="string"?e.reasoning_content:typeof e.thinking=="string"?e.thinking:typeof e.think=="string"?e.think:"";o.length>0&&n.push(o);const r=e.tool_calls;if(Array.isArray(r))for(const a of r){if(a===null||typeof a!="object")continue;const i=a.function;if(i===void 0)continue;const c=typeof i.name=="string"?i.name:"",d=typeof i.arguments=="string"?i.arguments:"";n.push(`${c} ${d}`.trim())}return n.join(`
|
|
47
|
-
`)}function Wj(e){if(!Array.isArray(e))return"";const n=[];for(const s of e){if(s===null||typeof s!="object")continue;const o=ne(s,"function"),r=ne(o,"name")??ne(s,"name"),a=ne(o,"description")??ne(s,"description"),i=ne(o,"parameters")??ne(s,"parameters");typeof r=="string"&&n.push(r),typeof a=="string"&&n.push(a),i!==void 0&&n.push(JSON.stringify(i))}return n.join(`
|
|
48
|
-
`)}function Vj(e){return typeof e=="string"?e.length>0?1:0:Array.isArray(e)?e.length:e==null?null:1}function Kj(e){if(typeof e=="string")return e;const n=ne(e,"text");if(typeof n=="string")return n;const s=di(ne(e,"content"));if(s.length>0)return s;const o=di(ne(e,"output"));if(o.length>0)return o;const r=ne(e,"arguments");return typeof r=="string"?r:""}function Gj(e){const n=ne(e,"role");if(n==="system"||n==="user"||n==="assistant"||n==="tool")return n;const s=ne(e,"type");return s==="function_call_output"?"tool":"user"}function Yj(e){const n=ne(e,"output");if(!Array.isArray(n))return[];const s=[];for(const o of n){if(ne(o,"type")!=="function_call")continue;const r=ne(o,"name");typeof r=="string"&&r.length>0&&s.push(r)}return s}function Ss(e,n,s,o){return{role:e,label:n,text:s,size:wl(s),characters:jl(s),path:o}}const Jj={format:"openai",analyzeRequest(e){if(e===null)return En(e);try{const n=JSON.parse(e),s=Nl(n)?.tools.length??null,o=dx.safeParse(n);if(!o.success){const r=mx.safeParse(n);return r.success?{parsed:r.data,comparisonValue:r.data,messageCount:Vj(r.data.input),toolCount:s}:En(e)}return{parsed:o.data,comparisonValue:o.data,messageCount:o.data.messages.length,toolCount:s}}catch{return En(e)}},analyzeResponse(e){if(e===null)return ss;const n=bx(e);if(n===null){const o=vx(e);if(o===null)return ss;const r=Yj(o);return{parsed:o,toolNames:r.length>0?r:null}}const s=n.choices[0]?.message?.tool_calls?.map(o=>o.function?.name??"").filter(o=>o!=="")??[];return{parsed:n,toolNames:s.length>0?s:null}},anatomySegments(e){if(e===null||typeof e!="object")return null;const n=e,s=[];if(typeof n.instructions=="string"&&n.instructions.length>0&&s.push(Ss("system","instructions",n.instructions,"/instructions")),Array.isArray(n.messages)&&n.messages.forEach((o,r)=>{if(o===null||typeof o!="object")return;const a=o,i=a.role==="user"||a.role==="assistant"||a.role==="system"||a.role==="tool"?a.role:"user",c=Hj(a);s.push(Ss(i,`[${r}] ${i}`,c,`/messages/${r}`))}),Array.isArray(n.messages)||(typeof n.input=="string"&&n.input.length>0?s.push(Ss("user","input",n.input,"/input")):Array.isArray(n.input)&&n.input.forEach((o,r)=>{const a=Gj(o),i=Kj(o);s.push(Ss(a,`[${r}] ${a}`,i,`/input/${r}`))})),Array.isArray(n.tools)&&n.tools.length>0){const o=Wj(n.tools);s.push(Ss("tools","tools",o,"/tools"))}return s.length>0?s:null}},Xj={format:"unknown",analyzeRequest(e){return En(e)},analyzeResponse(){return ss},anatomySegments(){return null}},Zj={anthropic:qj,openai:Jj,unknown:Xj};function ep(e){return Zj[e]}function Fs(e){const n=Mj(e.path);return n==="unknown"?e.apiFormat:n}const Sc="inline-flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-md bg-[var(--inspector-surface-low)] text-muted-foreground transition-colors hover:bg-[var(--inspector-surface-medium)] hover:text-foreground";function tp(e){return e.startsWith("PID:")||e.startsWith("process:")||e.startsWith("connection:")||e.includes("|")}function Qj(e){return tp(e)?"No session ID":e.length>24?`${e.slice(0,12)}...${e.slice(-12)}`:e}function fa({icon:e,children:n,title:s,className:o}){return t.jsxs("span",{className:O("inline-flex h-7 min-w-0 items-center gap-1.5 rounded-md bg-[var(--inspector-surface-low)] px-2 text-xs text-muted-foreground",o),title:s,children:[e,t.jsx("span",{className:"min-w-0 font-mono tabular-nums",children:n})]})}function e5(){return t.jsxs("span",{className:"inline-flex h-6 shrink-0 items-center gap-1.5 rounded-md bg-[var(--inspector-surface-medium)] px-1.5 font-mono text-[10px] uppercase text-[var(--inspector-status-watch)] ring-1 ring-border/50",title:"This session has a turn that has not finished yet",children:[t.jsx(Ae,{className:"size-3 animate-spin"}),"Turn open"]})}function t5({conversationId:e,startTime:n,endTime:s,totalCalls:o,totalInputTokens:r,totalOutputTokens:a,expanded:i,onToggle:c,providers:d,isLoading:m=!1,userAgent:u,clientPid:f,clientProjectFolder:p,showClientIdentity:h=!0,showProcessMetadata:g=!0,timeDisplayFormat:v,onClear:y}){const[w,b]=l.useState(!1),j=Y=>{Y.stopPropagation(),y!==void 0&&b(!0)},S=l.useCallback(Y=>{Y.stopPropagation(),window.open(Fd(e),"_blank","noopener,noreferrer")},[e]),N=d?.map(({provider:Y,models:Q})=>({provider:Y,tooltip:Q.length===1?Q[0]??Y:Q.join(", ")}))??[],C=yl({userAgent:u,conversationId:e,clientProjectFolder:p}),R=$r(C),I=u!=null&&u!=="",P=R??u??null,M=R!==null&&I?`${R} - ${u}`:null,k=tp(e),A=Qj(e),D=br(n,s,v),$=`${o} call${o!==1?"s":""}`;return t.jsxs("div",{role:"button",tabIndex:0,"data-nav-id":`conv-${e}`,"data-nav-action":i?"collapse":"expand",className:O("relative flex cursor-pointer items-start gap-2.5 overflow-hidden rounded-md bg-[var(--inspector-surface-low)] px-3 py-2.5 transition-colors","hover:bg-[var(--inspector-surface-medium)]","select-none","sticky top-0 z-10 mb-2","focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none"),onClick:c,onKeyDown:Y=>{Y.target===Y.currentTarget&&(Y.key==="Enter"||Y.key===" ")&&(Y.preventDefault(),c())},children:[t.jsx(Ej,{items:N,ariaLabel:"Models used in this session",className:"mt-0.5"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[t.jsx("span",{className:"shrink-0 rounded bg-[var(--inspector-surface-medium)] px-1.5 py-0.5 font-mono text-[9px] uppercase text-muted-foreground",children:"Session"}),k&&g?f!=null?t.jsxs("span",{className:"min-w-0 max-w-full truncate font-mono text-xs font-semibold text-foreground",title:`PID ${f}`,children:["PID ",f]}):t.jsx("span",{className:"min-w-0 max-w-full truncate font-mono text-xs font-semibold text-foreground",title:e,children:e}):t.jsx("span",{className:"min-w-0 max-w-full truncate font-mono text-xs font-semibold text-foreground",title:e,children:A}),!k&&g&&f!==null&&f!==void 0&&t.jsxs("span",{className:"shrink-0 rounded bg-[var(--inspector-surface-medium)] px-1.5 py-0.5 font-mono text-xs tabular-nums text-muted-foreground",title:`Client process ID ${f}`,children:["PID ",f]}),k&&g&&p!==null&&p!==void 0&&p!==""&&t.jsx("span",{className:"min-w-0 max-w-[240px] truncate font-mono text-xs text-muted-foreground",title:p,children:p}),h&&P!==null&&P!==""&&t.jsxs("span",{className:"inline-flex min-h-6 shrink-0 flex-wrap items-center gap-1 rounded-md bg-[var(--inspector-surface-medium)] px-1.5 py-0.5 text-xs text-muted-foreground",title:M??P,children:[t.jsx(Fr,{client:C,className:"size-4 shrink-0",decorative:!0}),t.jsx("span",{className:"font-mono leading-snug tabular-nums",children:P})]}),m&&t.jsx(e5,{})]}),t.jsxs("span",{className:"mt-1.5 flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx(fa,{icon:t.jsx(Vt,{className:"size-3 shrink-0"}),title:D,children:D}),t.jsx(fa,{icon:t.jsx(gr,{className:"size-3 shrink-0"}),children:$}),t.jsxs(fa,{icon:t.jsx(Ds,{className:"size-3 shrink-0"}),className:"max-w-full",children:[t.jsx("span",{className:"text-[var(--inspector-status-info)]",children:Re(r)})," / ",t.jsx("span",{className:"text-[var(--inspector-status-watch)]",children:Re(a)})]})]})]}),t.jsxs("span",{className:"flex shrink-0 items-start gap-1.5",children:[t.jsx("button",{type:"button",onClick:S,onKeyDown:Y=>{(Y.key==="Enter"||Y.key===" ")&&S(Y)},"aria-label":`Open session ${e} in a new tab`,title:"Open this session in a new tab",className:Sc,children:t.jsx(Bi,{className:"size-3.5"})}),y!==void 0&&t.jsx("button",{type:"button",onClick:j,"aria-label":`Clear group (${o} request${o!==1?"s":""})`,title:"Clear this group from the current view",className:Sc,children:t.jsx(dn,{className:"size-3.5"})}),t.jsx("span",{className:"inline-flex size-8 shrink-0 items-center justify-center rounded-md bg-[var(--inspector-surface-low)] text-muted-foreground transition-colors hover:bg-[var(--inspector-surface-medium)] hover:text-foreground","aria-hidden":"true",children:i?t.jsx(We,{className:"size-4 shrink-0"}):m?t.jsx(Ae,{className:"size-4 shrink-0 animate-spin"}):t.jsx(ct,{className:"size-4 shrink-0"})})]}),m&&t.jsx("span",{className:"pointer-events-none absolute inset-x-3 bottom-0 h-px overflow-hidden rounded-full bg-[var(--inspector-surface-medium)]","aria-hidden":"true",children:t.jsx("span",{className:"absolute inset-y-0 left-0 w-1/3 animate-pulse rounded-full bg-[var(--inspector-status-watch)] opacity-70"})}),t.jsx(Gf,{open:w,onOpenChange:b,title:"Clear this group from the current view?",description:`This will hide ${o} request${o!==1?"s":""} from the current view. Stored logs remain reloadable.`,confirmLabel:"Clear",variant:"destructive",onConfirm:()=>{y?.()}})]})}function n5(e){if(e.sessionId!==null&&e.sessionId!==""&&e.sessionId!==void 0)return e.sessionId;if(e.isTest===!0)return"provider-test";const n=e.clientPid!==null&&e.clientPid!==void 0,s=e.clientProjectFolder!==null&&e.clientProjectFolder!==void 0;if(!n&&!s)return"default";const o=n?`PID:${e.clientPid}`:"unknown",r=s?e.clientProjectFolder:"no-folder";return`${o}|${r}`}function s5(e){const n=new Map;for(const o of e){const r=n5(o),a=n.get(r);a!==void 0?a.push(o):n.set(r,[o])}const s=[];for(const[o,r]of n){const a=[...r].sort((i,c)=>i.timestamp.localeCompare(c.timestamp));s.push({id:o,conversationId:o,logs:a})}return s.sort((o,r)=>(o.logs[0]?.timestamp??"").localeCompare(r.logs[0]?.timestamp??"")),s}function o5(e,n,s){const o=new Array(e);return new Proxy(o,{get(r,a,i){if(typeof a=="string"){const c=a.charCodeAt(0);if(c>=48&&c<=57){const d=+a;if(Number.isInteger(d)&&d>=0&&d<e){let m=r[d];if(!m){const u=n[d*2];m=r[d]={index:d,key:s(d),start:u,size:n[d*2+1],end:u+n[d*2+1],lane:0}}return m}}if(a==="length")return e}return Reflect.get(r,a,i)}})}function Kn(e,n,s){let o=s.initialDeps??[],r,a=!0;function i(){const c=e();return(c.length!==o.length||c.some((m,u)=>o[u]!==m))&&(o=c,r=n(...c),s?.onChange&&!(a&&s.skipInitialOnChange)&&s.onChange(r),a=!1),r}return i.updateDeps=c=>{o=c},i}function Nc(e,n){if(e===void 0)throw new Error("Unexpected undefined");return e}const r5=(e,n)=>Math.abs(e-n)<1.01,a5=(e,n,s)=>{let o;return function(...r){e.clearTimeout(o),o=e.setTimeout(()=>n.apply(this,r),s)}};let Ns;const pa=()=>{if(Ns!==void 0)return Ns;if(typeof navigator>"u")return Ns=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Ns=!0;const e=navigator.maxTouchPoints;return Ns=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Cc=e=>{const{offsetWidth:n,offsetHeight:s}=e;return{width:n,height:s}},i5=e=>e,l5=e=>{const n=Math.max(e.startIndex-e.overscan,0),o=Math.min(e.endIndex+e.overscan,e.count-1)-n+1,r=new Array(o);for(let a=0;a<o;a++)r[a]=n+a;return r},c5=(e,n)=>{const s=e.scrollElement;if(!s)return;const o=e.targetWindow;if(!o)return;const r=i=>{const{width:c,height:d}=i;n({width:Math.round(c),height:Math.round(d)})};if(r(Cc(s)),!o.ResizeObserver)return()=>{};const a=new o.ResizeObserver(i=>{const c=()=>{const d=i[0];if(d?.borderBoxSize){const m=d.borderBoxSize[0];if(m){r({width:m.inlineSize,height:m.blockSize});return}}r(Cc(s))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(c):c()});return a.observe(s,{box:"border-box"}),()=>{a.unobserve(s)}},Us={passive:!0},d5=(e,n)=>{const s=e.scrollElement;if(!s)return;const o=()=>{n({width:s.innerWidth,height:s.innerHeight})};return o(),s.addEventListener("resize",o,Us),()=>{s.removeEventListener("resize",o)}},u5=typeof window>"u"?!0:"onscrollend"in window,np=(e,n,s)=>{const o=e.scrollElement;if(!o)return;const r=e.targetWindow;if(!r)return;const a=e.options.useScrollendEvent&&u5;let i=0;const c=a?null:a5(r,()=>n(i,!1),e.options.isScrollingResetDelay),d=f=>()=>{i=s(o),c?.(),n(i,f)},m=d(!0),u=d(!1);return o.addEventListener("scroll",m,Us),a&&o.addEventListener("scrollend",u,Us),()=>{o.removeEventListener("scroll",m),a&&o.removeEventListener("scrollend",u)}},m5=(e,n)=>np(e,n,s=>{const{horizontal:o,isRtl:r}=e.options;return o?s.scrollLeft*(r&&-1||1):s.scrollTop}),f5=(e,n)=>np(e,n,s=>e.options.horizontal?s.scrollX:s.scrollY),p5=(e,n,s)=>{if(s.options.useCachedMeasurements){const o=s.indexFromElement(e),r=s.options.getItemKey(o);return s.itemSizeCache.get(r)??s.options.estimateSize(o)}if(n?.borderBoxSize){const o=n.borderBoxSize[0];if(o)return Math.round(o[s.options.horizontal?"inlineSize":"blockSize"])}if(!n){const o=s.indexFromElement(e),r=s.options.getItemKey(o),a=s.itemSizeCache.get(r);if(a!==void 0)return a}return e[s.options.horizontal?"offsetWidth":"offsetHeight"]},sp=(e,{adjustments:n=0,behavior:s},o)=>{var r,a;(a=(r=o.scrollElement)==null?void 0:r.scrollTo)==null||a.call(r,{[o.options.horizontal?"left":"top"]:e+n,behavior:s})},h5=sp,x5=sp;class g5{constructor(n){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var s,o,r;return((r=(o=(s=this.targetWindow)==null?void 0:s.performance)==null?void 0:o.now)==null?void 0:r.call(o))??Date.now()},this.observer=(()=>{let s=null;const o=()=>s||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:s=new this.targetWindow.ResizeObserver(r=>{r.forEach(a=>{const i=()=>{const c=a.target,d=this.indexFromElement(c);if(!c.isConnected){this.observer.unobserve(c);for(const[m,u]of this.elementsCache)if(u===c){this.elementsCache.delete(m);break}return}this.shouldMeasureDuringScroll(d)&&this.resizeItem(d,this.options.measureElement(c,a,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(i):i()})}));return{disconnect:()=>{var r;(r=o())==null||r.disconnect(),s=null},observe:r=>{var a;return(a=o())==null?void 0:a.observe(r,{box:"border-box"})},unobserve:r=>{var a;return(a=o())==null?void 0:a.unobserve(r)}}})(),this.range=null,this.setOptions=s=>{var o,r;const a={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:i5,rangeExtractor:l5,onChange:()=>{},measureElement:p5,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const p in s){const h=s[p];h!==void 0&&(a[p]=h)}const i=this.options;let c=null,d=null,m=!1;if(i!==void 0&&i.enabled&&a.enabled&&a.anchorTo==="end"&&this.scrollElement!==null){const p=i.count,h=a.count,g=this.getMeasurements(),v=p>0?((o=g[0])==null?void 0:o.key)??i.getItemKey(0):null,y=p>0?((r=g[p-1])==null?void 0:r.key)??i.getItemKey(p-1):null;if(h!==p||p>0&&h>0&&(a.getItemKey(0)!==v||a.getItemKey(h-1)!==y)){m=!0;const j=p>0?this.getVirtualItemForOffset(this.getScrollOffset())??g[0]:null;j&&(c=[j.key,this.getScrollOffset()-j.start]);const S=a.followOnAppend===!0?"auto":a.followOnAppend||null;S&&h>p&&this.isAtEnd(i.scrollEndThreshold)&&(p===0||a.getItemKey(h-1)!==y)&&(d=S)}}this.options=a,m&&(this.pendingMin=0,this.itemSizeCacheVersion++);let u=!1,f=0;if(c&&this.scrollOffset!==null){const[p,h]=c,g=this.getMeasurements(),{count:v,getItemKey:y}=this.options;let w=0;for(;w<v&&y(w)!==p;)w++;if(w<v){const b=g[w];if(b){const j=b.start+h;j!==this.scrollOffset&&(f=j-this.scrollOffset,this.scrollOffset=j,u=!0)}}}(u||d)&&(this.pendingScrollAnchor=[u?c[0]:null,u?c[1]:0,d,f])},this.notify=s=>{var o,r;(r=(o=this.options).onChange)==null||r.call(o,this,s)},this.maybeNotify=Kn(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),s=>{this.notify(s)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(s=>s()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var s;const o=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==o){if(this.cleanup(),!o){this.maybeNotify();return}if(this.scrollElement=o,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((s=this.scrollElement)==null?void 0:s.window)??null,this.elementsCache.forEach(a=>{this.observer.observe(a)}),this.unsubs.push(this.options.observeElementRect(this,a=>{this.scrollRect=a,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(a,i)=>{if(i&&this._intendedScrollOffset===null&&a===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(a-this._intendedScrollOffset)<1.5&&(a=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;const c=this.getScrollOffset();this.scrollDirection=i?c===a?this.scrollDirection:c<a?"forward":"backward":null,this.scrollOffset=a,this.isScrolling=i,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const a=this.scrollElement,i=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},c=()=>{this._iosTouching=!1,!(!pa()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};a.addEventListener("touchstart",i,Us),a.addEventListener("touchend",c,Us),this.unsubs.push(()=>{a.removeEventListener("touchstart",i),a.removeEventListener("touchend",c),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const r=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,r&&this.scrollElement&&this.options.enabled){const[a,i,c,d]=r;a!==null&&!c&&(pa()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?d!==0&&(this._iosDeferredAdjustment+=d):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),c&&this.scrollToEnd({behavior:c})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const s=this.getScrollOffset(),o=this.getMaxScrollOffset();if(s<0||s>o)return;const r=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(s,{adjustments:this.scrollAdjustments+=r,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=Kn(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(s,o,r,a,i,c,d,m)=>(this.prevLanes!==void 0&&this.prevLanes!==c&&(this.lanesChangedFlag=!0),this.prevLanes=c,this.pendingMin=null,{count:s,paddingStart:o,scrollMargin:r,getItemKey:a,enabled:i,lanes:c,laneAssignmentMode:d,gap:m}),{key:!1}),this.getMeasurements=Kn(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:s,paddingStart:o,scrollMargin:r,getItemKey:a,enabled:i,lanes:c,laneAssignmentMode:d,gap:m},u)=>{const f=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>s)for(const w of this.laneAssignments.keys())w>=s&&this.laneAssignments.delete(w);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(w=>{this.itemSizeCache.set(w.key,w.size)}));const p=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===s&&(this.lanesSettling=!1),c===1){const w=s*2;let b=this._flatMeasurements;if(!b||b.length<w){const N=new Float64Array(w);b&&p>0&&N.set(b.subarray(0,p*2)),b=N,this._flatMeasurements=b}let j;if(p===0)j=o+r;else{const N=p-1;j=b[N*2]+b[N*2+1]+m}for(let N=p;N<s;N++){const C=a(N),R=f.get(C),I=typeof R=="number"?R:this.options.estimateSize(N);b[N*2]=j,b[N*2+1]=I,j+=I+m}const S=o5(s,b,a);return this.measurementsCache=S,S}const h=this.measurementsCache.slice(0,p),g=new Array(c).fill(void 0),v=new Float64Array(c);let y=0;for(let w=0;w<p;w++){const b=h[w];b&&(g[b.lane]===void 0&&y++,g[b.lane]=w,v[b.lane]=b.end)}for(let w=p;w<s;w++){const b=a(w),j=this.laneAssignments.get(w);let S,N;const C=d==="estimate"||f.has(b);if(j!==void 0&&this.options.lanes>1){S=j;const M=g[S],k=M!==void 0?h[M]:void 0;N=k?k.end+m:o+r}else if(y===c){let M=0,k=v[0],A=g[0];for(let D=1;D<c;D++){const $=v[D];($<k||$===k&&g[D]<A)&&(M=D,k=$,A=g[D])}S=M,N=k+m,C&&this.laneAssignments.set(w,S)}else S=w%this.options.lanes,N=o+r,C&&this.laneAssignments.set(w,S);const R=f.get(b),I=typeof R=="number"?R:this.options.estimateSize(w),P=N+I;h[w]={index:w,start:N,size:I,end:P,key:b,lane:S},g[S]===void 0&&y++,g[S]=w,v[S]=P}return this.measurementsCache=h,h},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Kn(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(s,o,r,a)=>s.length===0||o===0?(this.range=null,null):(this.range=v5(s,o,r,a,a===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Kn(()=>{let s=null,o=null;const r=this.calculateRange();return r&&(s=r.startIndex,o=r.endIndex),this.maybeNotify.updateDeps([this.isScrolling,s,o]),[this.options.rangeExtractor,this.options.overscan,this.options.count,s,o]},(s,o,r,a,i)=>a===null||i===null?[]:s({startIndex:a,endIndex:i,overscan:o,count:r}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=s=>{const o=this.options.indexAttribute,r=s.getAttribute(o);return r?parseInt(r,10):(console.warn(`Missing attribute name '${o}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=s=>{var o;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const r=this.scrollState.index??((o=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:o.index);if(r!==void 0&&this.range){const a=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),i=Math.max(0,r-a),c=Math.min(this.options.count-1,r+a);return s>=i&&s<=c}return!0},this.measureElement=s=>{if(!s){this.elementsCache.forEach((i,c)=>{i.isConnected||(this.observer.unobserve(i),this.elementsCache.delete(c))});return}const o=this.indexFromElement(s),r=this.options.getItemKey(o),a=this.elementsCache.get(r);a!==s&&(a&&this.observer.unobserve(a),this.observer.observe(s),this.elementsCache.set(r,s)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(o)&&this.resizeItem(o,this.options.measureElement(s,void 0,this))},this.resizeItem=(s,o)=>{var r,a;if(s<0||s>=this.options.count)return;let i,c,d;const m=this._flatMeasurements;if(this.options.lanes===1&&m!==null)d=this.options.getItemKey(s),c=m[s*2],i=m[s*2+1];else{const p=this.measurementsCache[s];if(!p)return;d=p.key,c=p.start,i=p.size}const u=this.itemSizeCache.get(d)??i,f=o-u;if(f!==0){const p=this.options.anchorTo==="end"&&((r=this.scrollState)==null?void 0:r.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,h=p?this.getTotalSize():0,g=((a=this.scrollState)==null?void 0:a.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[s]??{index:s,key:d,start:c,size:i,end:c+i,lane:0},f,this):c<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(d)||this.scrollDirection!=="backward"));(this.pendingMin===null||s<this.pendingMin)&&(this.pendingMin=s),this.itemSizeCache.set(d,o),this.itemSizeCacheVersion++,p?this.applyScrollAdjustment(this.getTotalSize()-h):g&&this.applyScrollAdjustment(f),this.notify(!1)}},this.getVirtualItems=Kn(()=>[this.getVirtualIndexes(),this.getMeasurements()],(s,o)=>{const r=[];for(let a=0,i=s.length;a<i;a++){const c=s[a],d=o[c];r.push(d)}return r},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=s=>{const o=this.getMeasurements();if(o.length===0)return;const r=this._flatMeasurements,a=this.options.lanes===1&&r!=null,i=op(0,o.length-1,a?c=>r[c*2]:c=>Nc(o[c]).start,s);return Nc(o[i])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const s=this.scrollElement.document.documentElement;return this.options.horizontal?s.scrollWidth-this.scrollElement.innerWidth:s.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(s=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=s,this.getOffsetForAlignment=(s,o,r=0)=>{if(!this.scrollElement)return 0;const a=this.getSize(),i=this.getScrollOffset();o==="auto"&&(o=s>=i+a?"end":"start"),o==="center"?s+=(r-a)/2:o==="end"&&(s-=a);const c=this.getMaxScrollOffset();return Math.max(Math.min(c,s),0)},this.getOffsetForIndex=(s,o="auto")=>{s=Math.max(0,Math.min(s,this.options.count-1));const r=this.getSize(),a=this.getScrollOffset(),i=this.measurementsCache[s];if(!i)return;if(o==="auto")if(i.end>=a+r-this.options.scrollPaddingEnd)o="end";else if(i.start<=a+this.options.scrollPaddingStart)o="start";else return[a,o];if(o==="end"&&s===this.options.count-1)return[this.getMaxScrollOffset(),o];const c=o==="end"?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(c,o,i.size),o]},this.scrollToOffset=(s,{align:o="start",behavior:r="auto"}={})=>{const a=this.getOffsetForAlignment(s,o),i=this.now();this.scrollState={index:null,align:o,behavior:r,startedAt:i,lastTargetOffset:a,stableFrames:0},this._scrollToOffset(a,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollToIndex=(s,{align:o="auto",behavior:r="auto"}={})=>{s=Math.max(0,Math.min(s,this.options.count-1));const a=this.getOffsetForIndex(s,o);if(!a)return;const[i,c]=a,d=this.now();this.scrollState={index:s,align:c,behavior:r,startedAt:d,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollBy=(s,{behavior:o="auto"}={})=>{const r=this.getScrollOffset()+s,a=this.now();this.scrollState={index:null,align:"start",behavior:o,startedAt:a,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:s="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:s});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:s})},this.getTotalSize=()=>{var s;const o=this.getMeasurements();let r;if(o.length===0)r=this.options.paddingStart;else if(this.options.lanes===1){const a=o.length-1,i=this._flatMeasurements;i!=null?r=i[a*2]+i[a*2+1]:r=((s=o[a])==null?void 0:s.end)??0}else{const a=Array(this.options.lanes).fill(null);let i=o.length-1;for(;i>=0&&a.some(c=>c===null);){const c=o[i];a[c.lane]===null&&(a[c.lane]=c.end),i--}r=Math.max(...a.filter(c=>c!==null))}return Math.max(r-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const s=[];if(this.itemSizeCache.size===0)return s;const o=this.getMeasurements();for(const r of o)r&&this.itemSizeCache.has(r.key)&&s.push({index:r.index,key:r.key,start:r.start,size:r.size,end:r.end,lane:r.lane});return s},this._scrollToOffset=(s,{adjustments:o,behavior:r})=>{this._intendedScrollOffset=s+(o??0),this.options.scrollToFn(s,{behavior:r,adjustments:o},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(n)}applyScrollAdjustment(n,s){n!==0&&(pa()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=n:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=n,behavior:s}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollAdjustments=0)))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const o=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,r=o?o[0]:this.scrollState.lastTargetOffset,a=1,i=r!==this.scrollState.lastTargetOffset;if(!i&&r5(r,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=a){this.getScrollOffset()!==r&&this._scrollToOffset(r,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,i){const c=this.getSize()||600,d=Math.abs(r-this.getScrollOffset()),m=this.scrollState.behavior==="smooth"&&d>c;this.scrollState.lastTargetOffset=r,m||(this.scrollState.behavior="auto"),this._scrollToOffset(r,{adjustments:void 0,behavior:m?"smooth":"auto"})}this.scheduleScrollReconcile()}}const op=(e,n,s,o)=>{for(;e<=n;){const r=(e+n)/2|0,a=s(r);if(a<o)e=r+1;else if(a>o)n=r-1;else return r}return e>0?e-1:0};function b5(e,n,s){let o=0;for(;o<=n;){const r=(o+n)/2|0,a=e[r*2];if(a<s)o=r+1;else if(a>s)n=r-1;else return r}return o>0?o-1:0}function v5(e,n,s,o,r){const a=e.length-1;if(e.length<=o)return{startIndex:0,endIndex:a};if(o===1&&r!==null){const m=b5(r,a,s);let u=m;const f=s+n;for(;u<a&&r[u*2]+r[u*2+1]<f;)u++;return{startIndex:m,endIndex:u}}let c=op(0,a,m=>e[m].start,s),d=c;if(o===1)for(;d<a&&e[d].end<s+n;)d++;else if(o>1){const m=Array(o).fill(0);for(;d<a&&m.some(f=>f<s+n);){const f=e[d];m[f.lane]=f.end,d++}const u=Array(o).fill(s+n);for(;c>=0&&u.some(f=>f>=s);){const f=e[c];u[f.lane]=f.start,c--}c=Math.max(0,c-c%o),d=Math.min(a,d+(o-1-d%o))}return{startIndex:c,endIndex:d}}const ha=typeof document<"u"?l.useLayoutEffect:l.useEffect;function rp({useFlushSync:e=!0,directDomUpdates:n=!1,directDomUpdatesMode:s="transform",...o}){const r=l.useReducer(m=>m+1,0)[1],a=l.useRef({enabled:n,mode:s,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=n,a.current.mode=s;const i=m=>{const u=a.current;if(!u.enabled||!u.container)return;const f=m.getTotalSize();if(f!==u.lastSize){u.lastSize=f;const w=m.options.horizontal?"width":"height";u.container.style[w]=`${f}px`}const p=!!m.options.horizontal,h=u.mode==="transform",g=p?"left":"top",v=m.options.scrollMargin,y=m.getVirtualItems();for(const w of y){const b=w.start-v,j=m.elementsCache.get(w.key);j&&u.lastPositions.get(j)!==b&&(u.lastPositions.set(j,b),h?j.style.transform=p?`translate3d(${b}px, 0, 0)`:`translate3d(0, ${b}px, 0)`:j.style[g]=`${b}px`)}},c={...o,onChange:(m,u)=>{var f;const p=a.current;let h=!0;if(p.enabled){i(m);const g=m.range,v=p.prevRange;h=!v||v.isScrolling!==m.isScrolling||v.startIndex!==g?.startIndex||v.endIndex!==g?.endIndex,h&&(p.prevRange=g?{startIndex:g.startIndex,endIndex:g.endIndex,isScrolling:m.isScrolling}:null)}h&&(e&&u?hs.flushSync(r):r()),(f=o.onChange)==null||f.call(o,m,u)}},[d]=l.useState(()=>{const m=new g5(c);return Object.assign(m,{containerRef:u=>{const f=a.current;if(f.container=u,f.lastSize=null,u&&f.enabled){const p=m.getTotalSize();f.lastSize=p;const h=m.options.horizontal?"width":"height";u.style[h]=`${p}px`}}})});return d.setOptions(c),ha(()=>d._didMount(),[]),ha(()=>d._willUpdate()),ha(()=>{i(d)}),d}function y5(e){return rp({observeElementRect:c5,observeElementOffset:m5,scrollToFn:x5,...e})}function w5(e){return rp({getScrollElement:()=>typeof document<"u"?window:null,observeElementRect:d5,observeElementOffset:f5,scrollToFn:h5,initialOffset:()=>typeof document<"u"?window.scrollY:0,...e})}const Yt="agent-inspector:focus-log";function fs(e){window.dispatchEvent(new CustomEvent(Yt,{detail:e}))}function Ur(e){if(typeof CustomEvent>"u"||!(e instanceof CustomEvent))return null;const n=e.detail,s=ne(n,"logId");if(typeof s!="number"||!Number.isInteger(s)||s<0)return null;const o=ne(n,"tab");switch(o){case"anatomy":case"request":case"response":break;case void 0:break;default:return null}const r=ne(n,"source"),a=ne(n,"toolCallIndex"),i=typeof a=="number"&&Number.isInteger(a)&&a>=0?{logId:s,tab:o??"request",toolCallIndex:a}:{logId:s,tab:o??"request"};switch(r){case"virtualizer":return{...i,source:r};case void 0:return i;default:return null}}function j5(e){switch(e){case"end_turn":case"tool_use":return e;case"max_tokens":return"length";default:return null}}function S5(e){switch(e){case"stop":case"length":return e;case"max_tokens":return"length";default:return null}}function N5(e){switch(e){case"max_output_tokens":case"max_tokens":return!0;default:return!1}}function ap(e){if(e.responseText===null)return null;try{let n=JSON.parse(e.responseText);if(typeof n=="string"&&(n=JSON.parse(n)),!Es(n))return null;if(typeof n.stop_reason=="string")return j5(n.stop_reason);if(Array.isArray(n.choices))for(const s of n.choices){if(!Es(s)||typeof s.finish_reason!="string")continue;const o=S5(s.finish_reason);if(o!==null)return o}if(Array.isArray(n.output)){for(const s of n.output)if(Es(s)&&s.type==="function_call")return"tool_use";if(n.status==="completed")return"stop"}if(n.status==="incomplete"&&Es(n.incomplete_details)){const s=n.incomplete_details.reason;if(typeof s=="string"&&N5(s))return"length"}return null}catch{return null}}function Cl(e){return e==="end_turn"||e==="stop"||e==="length"}function pt({className:e,style:n,d:s,eyeStalks:o,eyes:r,legs:a,extras:i}){return t.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:n,className:O("inline-block size-5",e),children:[t.jsx("path",{d:s}),o,r,a,i]})}const gn=t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"6.5",y1:"16",x2:"4.5",y2:"19.5"}),t.jsx("line",{x1:"9",y1:"17.5",x2:"8",y2:"20.5"}),t.jsx("line",{x1:"15",y1:"17.5",x2:"16",y2:"20.5"}),t.jsx("line",{x1:"17.5",y1:"16",x2:"19.5",y2:"19.5"})]}),ip=t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"7",y1:"16",x2:"5.5",y2:"18.5"}),t.jsx("line",{x1:"9.5",y1:"17",x2:"8.5",y2:"19.5"}),t.jsx("line",{x1:"14.5",y1:"17",x2:"15.5",y2:"19.5"}),t.jsx("line",{x1:"17",y1:"16",x2:"18.5",y2:"18.5"})]});function lp({className:e}){return t.jsx(pt,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),t.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"})]}),legs:gn,extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),t.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"})]})})}function C5({className:e}){return t.jsx(pt,{className:e,d:"M4 13 C4 7 7.5 5.5 12 5.5 C16.5 5.5 20 7 20 13 C20 17.5 16.5 19 12 19 C7.5 19 4 17.5 4 13 Z",eyeStalks:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"9.5",y1:"6.5",x2:"9.5",y2:"4.5"}),t.jsx("line",{x1:"14.5",y1:"6.5",x2:"14.5",y2:"4.5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"9.5",cy:"4",r:"1.1",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"14.5",cy:"4",r:"1.1",fill:"currentColor",stroke:"none"})]}),legs:ip,extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M5 11 C4 9.5 2.5 10 3 12 C3.5 13.5 4.5 13 5 12"}),t.jsx("path",{d:"M19 11 C20 9.5 21.5 10 21 12 C20.5 13.5 19.5 13 19 12"})]})})}function k5({className:e}){return t.jsx(pt,{className:e,d:"M3 13.5 C3 8 7 6 12 6 C17 6 21 8 21 13.5 C21 17 17 19 12 19 C7 19 3 17 3 13.5 Z",eyeStalks:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"7",y1:"7",x2:"6.5",y2:"4.5"}),t.jsx("line",{x1:"17",y1:"7",x2:"17.5",y2:"4.5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"6.5",cy:"4",r:"0.8",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"17.5",cy:"4",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:gn,extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M4 12 C2.5 10.5 1 11 1.5 13 C2 14.5 3.5 14 4.5 13"}),t.jsx("path",{d:"M20 12 C21.5 10.5 23 11 22.5 13 C22 14.5 20.5 14 19.5 13"})]})})}function _5({className:e}){return t.jsx(pt,{className:e,d:"M6 14 C6 8 9 5.5 12 5.5 C15 5.5 18 8 18 14 C18 18 15 20 12 20 C9 20 6 18 6 14 Z",eyeStalks:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"10",y1:"6.5",x2:"10",y2:"3.5"}),t.jsx("line",{x1:"14",y1:"6.5",x2:"14",y2:"3.5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"10",cy:"3",r:"0.7",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"14",cy:"3",r:"0.7",fill:"currentColor",stroke:"none"})]}),legs:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"7",y1:"17",x2:"5",y2:"20.5"}),t.jsx("line",{x1:"9.5",y1:"18.5",x2:"8.5",y2:"21.5"}),t.jsx("line",{x1:"14.5",y1:"18.5",x2:"15.5",y2:"21.5"}),t.jsx("line",{x1:"17",y1:"17",x2:"19",y2:"20.5"})]}),extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M6.5 11 C5 8.5 3 9 3.5 11.5 C4 13.5 5 13 6 12"}),t.jsx("path",{d:"M17.5 11 C19 8.5 21 9 20.5 11.5 C20 13.5 19 13 18 12"})]})})}function T5({className:e}){return t.jsx(pt,{className:e,d:"M5 13 C5 9 8 7 12 7 L13 4 L14 7 C16 7 19 9 19 13 C19 16 16 18 13 18 L12 21 L11 18 C8 18 5 16 5 13 Z",eyeStalks:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),t.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.8",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:gn,extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),t.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"})]})})}function E5({className:e}){return t.jsx(pt,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),t.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"}),t.jsx("line",{x1:"13.5",y1:"4",x2:"15.5",y2:"5"})]}),legs:gn,extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),t.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"})]})})}function R5({className:e}){return t.jsx(pt,{className:e,d:"M5.5 13.5 C5.5 10 8.5 8 12 8 C15.5 8 18.5 10 18.5 13.5 C18.5 16 15.5 17.5 12 17.5 C8.5 17.5 5.5 16 5.5 13.5 Z",eyeStalks:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"10",y1:"8",x2:"10",y2:"6"}),t.jsx("line",{x1:"14",y1:"8",x2:"14",y2:"6"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"9",y1:"6",x2:"11",y2:"6.5"}),t.jsx("line",{x1:"13",y1:"6",x2:"15",y2:"6.5"})]}),legs:ip,extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M6 11.5 C4.5 10.5 3 11 3.5 12.5 C4 13.5 5 13 5.5 12.5"}),t.jsx("path",{d:"M18 11.5 C19.5 10.5 21 11 20.5 12.5 C20 13.5 19 13 18.5 12.5"})]})})}function M5({className:e}){return t.jsx(pt,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),t.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.7",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.7",fill:"currentColor",stroke:"none"})]}),legs:gn,extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),t.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),t.jsx("line",{x1:"8.5",y1:"4",x2:"10.5",y2:"4.5"}),t.jsx("line",{x1:"15.5",y1:"4",x2:"13.5",y2:"4.5"}),t.jsx("path",{d:"M9 15.5 C10 14.5 14 14.5 15 15.5"})]})})}function A5({className:e}){return t.jsx(pt,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),t.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"9.5",cy:"4.5",r:"1.2",fill:"none",stroke:"currentColor"}),t.jsx("circle",{cx:"14.5",cy:"4.5",r:"1.2",fill:"none",stroke:"currentColor"})]}),legs:gn,extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),t.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),t.jsx("ellipse",{cx:"12",cy:"15",rx:"2",ry:"1.5",fill:"currentColor",stroke:"none"})]})})}function I5({className:e}){return t.jsx(pt,{className:e,d:"M4.5 13 C4.5 8 7.5 6 12 6 C16.5 6 19.5 8 19.5 13 C19.5 17 16.5 18.5 12 18.5 C7.5 18.5 4.5 17 4.5 13 Z",eyeStalks:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"9.5",y1:"7",x2:"9",y2:"5"}),t.jsx("line",{x1:"14.5",y1:"7",x2:"15",y2:"5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"9",cy:"4.5",r:"1",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"15",cy:"4.5",r:"1",fill:"currentColor",stroke:"none"})]}),legs:gn,extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M5 11 C3.5 9 2 9.5 2.5 12 C3 14 4 13 5 12"}),t.jsx("path",{d:"M19 11 C20.5 9 22 9.5 21.5 12 C21 14 20 13 19 12"}),t.jsx("path",{d:"M9 14.5 C10 16 14 16 15 14.5"}),t.jsx("circle",{cx:"7",cy:"13",r:"1",fill:"currentColor",stroke:"none",opacity:"0.3"}),t.jsx("circle",{cx:"17",cy:"13",r:"1",fill:"currentColor",stroke:"none",opacity:"0.3"})]})})}function P5({className:e}){return t.jsx(pt,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5.5"}),t.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5.5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"7.5",y1:"5.5",x2:"16.5",y2:"5.5"}),t.jsx("rect",{x:"7",y:"5",width:"4",height:"2",rx:"0.5",fill:"currentColor",stroke:"none"}),t.jsx("rect",{x:"13",y:"5",width:"4",height:"2",rx:"0.5",fill:"currentColor",stroke:"none"})]}),legs:gn,extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),t.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),t.jsx("path",{d:"M9.5 15 C10.5 16 13.5 16 14.5 15"})]})})}function L5({className:e}){return t.jsx(pt,{className:e,d:"M7 13.5 C7 10.5 9.5 9 12 9 C14.5 9 17 10.5 17 13.5 C17 16 14.5 17.5 12 17.5 C9.5 17.5 7 16 7 13.5 Z",eyeStalks:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"10.5",y1:"9.5",x2:"10.5",y2:"8"}),t.jsx("line",{x1:"13.5",y1:"9.5",x2:"13.5",y2:"8"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"10.5",cy:"7.5",r:"0.8",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"13.5",cy:"7.5",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"8",y1:"16",x2:"6.5",y2:"18"}),t.jsx("line",{x1:"10",y1:"17",x2:"9.5",y2:"19"}),t.jsx("line",{x1:"14",y1:"17",x2:"14.5",y2:"19"}),t.jsx("line",{x1:"16",y1:"16",x2:"17.5",y2:"18"})]}),extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M7.5 12 C6.5 11 5.5 11.5 6 13 C6.5 14 7 13.5 7.5 13"}),t.jsx("path",{d:"M16.5 12 C17.5 11 18.5 11.5 18 13 C17.5 14 17 13.5 16.5 13"})]})})}const ui=[lp,C5,k5,_5,T5,E5,R5,M5,A5,I5,P5,L5];function kl(e){return ui[Math.abs(e)%ui.length]??lp}function O5(e){const n=ui.length-2;return n<=0?0:1+((Number.isFinite(e)?Math.trunc(e):0)%n+n)%n}function D5(e){return kl(O5(e))}const z5="x-anthropic-billing-header:";function $5(e){return e.trimStart().toLowerCase().startsWith(z5)}function F5(e){return Sl(e)?Object.prototype.hasOwnProperty.call(e,"system"):!1}function U5(e){if(!Sl(e))return!1;const n=ne(e,"type"),s=ne(e,"text");return typeof n!="string"||n!=="text"||typeof s!="string"?!1:$5(s)}function B5(e){let n;try{n=JSON.parse(e)}catch{return{body:e,removed:0}}if(!F5(n))return{body:e,removed:0};const s=n.system;if(!Array.isArray(s)||s.length===0)return{body:e,removed:0};const o=[];let r=0;for(const a of s){if(U5(a)){r+=1;continue}o.push(a)}return r===0?{body:e,removed:0}:(o.length===0?delete n.system:n.system=o,{body:JSON.stringify(n),removed:r})}const q5=400,kc=2e3;function H5(e){return Array.isArray(e)}function W5(e,n){const s=[e];let o=0;for(;s.length>0;){const r=s.pop();if(r!==void 0){if(o+=1,o>n)return o;if(!(r===null||typeof r!="object")){if(H5(r)){for(const a of r)s.push(a);continue}for(const a of Object.keys(r)){const i=r[a];i!==void 0&&s.push(i)}}}}return o}function V5(e){const n=W5(e,kc+1);return n<=q5?{depth:Number.POSITIVE_INFINITY}:n<=kc?{depth:3}:{depth:2}}function K5(e){try{const n=JSON.parse(e);return{kind:"json",data:sr(n)}}catch{return{kind:"text"}}}function xa(e){const n=l.useMemo(()=>e===null?null:K5(e),[e]),s=n?.kind==="json"?n.data:null,o=l.useMemo(()=>s===null?null:V5(s),[s]),[r,a]=l.useState(!1),[i,c]=l.useState(0),[d,m]=l.useState(0),[u,f]=l.useTransition(),p=l.useCallback(()=>{const h=!r,g=h&&o!==null?o.depth:0;f(()=>{a(h),c(g),m(v=>v+1)})},[r,o]);return{parsedData:s,policy:o,isExpanded:r,toggle:p,isPending:u,bulkDepth:i,bulkRevision:d}}function sr(e){if(e==null)return null;switch(typeof e){case"string":return e;case"number":return e;case"boolean":return e;case"object":{if(Array.isArray(e))return e.map(s=>sr(s));const n={};for(const s of Object.keys(e)){const o=Object.getOwnPropertyDescriptor(e,s);n[s]=sr(o?.value)}return n}case"bigint":case"symbol":case"function":case"undefined":return String(e)}return null}function cp({className:e,orientation:n="horizontal",...s}){return t.jsx(_w,{"data-slot":"tabs","data-orientation":n,orientation:n,className:O("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",e),...s})}const G5=Ud("rounded-lg p-[3px] group-data-[orientation=horizontal]/tabs:h-9 data-[variant=line]:rounded-none group/tabs-list text-muted-foreground inline-flex w-fit items-center justify-center group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col",{variants:{variant:{default:"bg-muted",line:"gap-1 bg-transparent"}},defaultVariants:{variant:"default"}});function dp({className:e,variant:n="default",...s}){return t.jsx(Tw,{"data-slot":"tabs-list","data-variant":n,className:O(G5({variant:n}),e),...s})}function Wt({className:e,...n}){return t.jsx(Ew,{"data-slot":"tabs-trigger",className:O("focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring text-muted-foreground hover:text-foreground relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent","data-[state=active]:border-border data-[state=active]:bg-background data-[state=active]:text-foreground","after:bg-foreground after:absolute after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100",e),...n})}function tt({className:e,...n}){return t.jsx(Rw,{"data-slot":"tabs-content",className:O("flex-1 outline-none",e),...n})}function an(e){const[n,s]=l.useState(!1),o=l.useRef(null);l.useEffect(()=>()=>{o.current!==null&&clearTimeout(o.current)},[]);const r=l.useCallback(a=>{a.stopPropagation(),e!==null&&vt(e).then(i=>{i&&(s(!0),o.current!==null&&clearTimeout(o.current),o.current=setTimeout(()=>s(!1),2e3))})},[e]);return{copied:n,copy:r}}const Y5=l.lazy(()=>zt(()=>import("./CompareDrawer-D6p2D3aR.js"),__vite__mapDeps([3,1,2]),import.meta.url).then(e=>({default:e.CompareDrawer}))),J5=l.lazy(()=>zt(()=>import("./InspectorPet-DteVBsK4.js"),__vite__mapDeps([4,1,2]),import.meta.url).then(e=>({default:e.InspectorPet}))),X5=l.lazy(()=>zt(()=>import("./ReplayDialog-BxfD3Ni8.js"),__vite__mapDeps([5,1,2,6]),import.meta.url).then(e=>({default:e.ReplayDialog}))),Z5=l.lazy(()=>zt(()=>import("./RequestAnatomy-Bc-HEy3u.js"),__vite__mapDeps([7,1,2]),import.meta.url).then(e=>({default:e.RequestAnatomy}))),Q5=l.lazy(()=>zt(()=>import("./ResponseView-Be5xdsIm.js"),__vite__mapDeps([6,1,2]),import.meta.url).then(e=>({default:e.ResponseView}))),eS=l.lazy(()=>zt(()=>import("./StreamingChunkSequence-Cd5G2xRQ.js"),__vite__mapDeps([8,1,2]),import.meta.url).then(e=>({default:e.StreamingChunkSequence}))),mi=l.lazy(()=>zt(()=>import("./json-viewer-Dikr00zS.js"),__vite__mapDeps([9,1,2]),import.meta.url).then(e=>({default:e.JsonViewer}))),tS=l.lazy(()=>zt(()=>import("./json-viewer-Dikr00zS.js"),__vite__mapDeps([9,1,2]),import.meta.url).then(e=>({default:e.JsonViewerFromString}))),nS=1200,sS=12;function oS(e){const{containerRef:n,setExpandToPath:s,ensureTabActive:o,highlightMs:r}=e,a=l.useRef(null);return l.useCallback(i=>{o?.(),s(i.path);const c=f=>{f.scrollIntoView({behavior:"smooth",block:"center"}),f.classList.add("ring-2","ring-primary/60","ring-offset-1","ring-offset-background","rounded-sm","transition-shadow"),a.current!==null&&clearTimeout(a.current),a.current=setTimeout(()=>{f.classList.remove("ring-2","ring-primary/60","ring-offset-1","ring-offset-background","rounded-sm","transition-shadow"),s(null)},r??nS)},m=`[data-anatomy-path="${(f=>typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(f):f.replace(/(["'\\[\](){}])/g,"\\$1"))(i.path)}"]`,u=f=>{const p=n.current;if(p!==null){const h=p.querySelector(m);if(h!==null){c(h);return}}f>0?window.requestAnimationFrame(()=>u(f-1)):s(null)};window.requestAnimationFrame(()=>u(sS))},[n,o,r,s])}const _c="The compact log metadata is still available. Retry if the local server was restarting or the body store was briefly unavailable.";function Qn(e){return e<1024?`${e.toLocaleString()} B`:e<1024*1024?`${(e/1024).toFixed(1)} KiB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)} MiB`:`${(e/1024/1024/1024).toFixed(1)} GiB`}function rS(e,n){const s=[];return e!=null&&s.push(`Request ${Qn(e)}`),n!=null&&s.push(`Response ${Qn(n)}`),s.length===0?null:s.join(" · ")}function aS(e){if(e instanceof ki)return{title:"Full bodies timed out",detail:"The log store did not answer before the UI timeout. Compact metadata is still available; retry loading the bodies."};if(e instanceof Error){const n=e.message.trim();return{title:"Full bodies could not be loaded",detail:n===""?_c:n}}return{title:"Full bodies could not be loaded",detail:_c}}class up{diff(n,s,o={}){let r;typeof o=="function"?(r=o,o={}):"callback"in o&&(r=o.callback);const a=this.castInput(n,o),i=this.castInput(s,o),c=this.removeEmpty(this.tokenize(a,o)),d=this.removeEmpty(this.tokenize(i,o));return this.diffWithOptionsObj(c,d,o,r)}diffWithOptionsObj(n,s,o,r){var a;const i=b=>{if(b=this.postProcess(b,o),r){setTimeout(function(){r(b)},0);return}else return b},c=s.length,d=n.length;let m=1,u=c+d;o.maxEditLength!=null&&(u=Math.min(u,o.maxEditLength));const f=(a=o.timeout)!==null&&a!==void 0?a:1/0,p=Date.now()+f,h=[{oldPos:-1,lastComponent:void 0}];let g=this.extractCommon(h[0],s,n,0,o);if(h[0].oldPos+1>=d&&g+1>=c)return i(this.buildValues(h[0].lastComponent,s,n));let v=-1/0,y=1/0;const w=()=>{for(let b=Math.max(v,-m);b<=Math.min(y,m);b+=2){let j;const S=h[b-1],N=h[b+1];S&&(h[b-1]=void 0);let C=!1;if(N){const I=N.oldPos-b;C=N&&0<=I&&I<c}const R=S&&S.oldPos+1<d;if(!C&&!R){h[b]=void 0;continue}if(!R||C&&S.oldPos<N.oldPos?j=this.addToPath(N,!0,!1,0,o):j=this.addToPath(S,!1,!0,1,o),g=this.extractCommon(j,s,n,b,o),j.oldPos+1>=d&&g+1>=c)return i(this.buildValues(j.lastComponent,s,n))||!0;h[b]=j,j.oldPos+1>=d&&(y=Math.min(y,b-1)),g+1>=c&&(v=Math.max(v,b+1))}m++};if(r)(function b(){setTimeout(function(){if(m>u||Date.now()>p)return r(void 0);w()||b()},0)})();else for(;m<=u&&Date.now()<=p;){const b=w();if(b)return b}}addToPath(n,s,o,r,a){const i=n.lastComponent;return i&&!a.oneChangePerToken&&i.added===s&&i.removed===o?{oldPos:n.oldPos+r,lastComponent:{count:i.count+1,added:s,removed:o,previousComponent:i.previousComponent}}:{oldPos:n.oldPos+r,lastComponent:{count:1,added:s,removed:o,previousComponent:i}}}extractCommon(n,s,o,r,a){const i=s.length,c=o.length;let d=n.oldPos,m=d-r,u=0;for(;m+1<i&&d+1<c&&this.equals(o[d+1],s[m+1],a);)m++,d++,u++,a.oneChangePerToken&&(n.lastComponent={count:1,previousComponent:n.lastComponent,added:!1,removed:!1});return u&&!a.oneChangePerToken&&(n.lastComponent={count:u,previousComponent:n.lastComponent,added:!1,removed:!1}),n.oldPos=d,m}equals(n,s,o){return o.comparator?o.comparator(n,s):n===s||!!o.ignoreCase&&n.toLowerCase()===s.toLowerCase()}removeEmpty(n){const s=[];for(let o=0;o<n.length;o++)n[o]&&s.push(n[o]);return s}castInput(n,s){return n}tokenize(n,s){return Array.from(n)}join(n){return n.join("")}postProcess(n,s){return n}get useLongestToken(){return!1}buildValues(n,s,o){const r=[];let a;for(;n;)r.push(n),a=n.previousComponent,delete n.previousComponent,n=a;r.reverse();const i=r.length;let c=0,d=0,m=0;for(;c<i;c++){const u=r[c];if(u.removed)u.value=this.join(o.slice(m,m+u.count)),m+=u.count;else{if(!u.added&&this.useLongestToken){let f=s.slice(d,d+u.count);f=f.map(function(p,h){const g=o[m+h];return g.length>p.length?g:p}),u.value=this.join(f)}else u.value=this.join(s.slice(d,d+u.count));d+=u.count,u.added||(m+=u.count)}}return r}}class iS extends up{constructor(){super(...arguments),this.tokenize=fp}equals(n,s,o){return o.ignoreWhitespace?((!o.newlineIsToken||!n.includes(`
|
|
49
|
-
`))&&(n=n.trim()),(!o.newlineIsToken||!s.includes(`
|
|
50
|
-
`))&&(s=s.trim())):o.ignoreNewlineAtEof&&!o.newlineIsToken&&(n.endsWith(`
|
|
51
|
-
`)&&(n=n.slice(0,-1)),s.endsWith(`
|
|
52
|
-
`)&&(s=s.slice(0,-1))),super.equals(n,s,o)}}const lS=new iS;function mp(e,n,s){return lS.diff(e,n,s)}function fp(e,n){n.stripTrailingCr&&(e=e.replace(/\r\n/g,`
|
|
53
|
-
`));const s=[],o=e.split(/(\n|\r\n)/);o[o.length-1]||o.pop();for(let r=0;r<o.length;r++){const a=o[r];r%2&&!n.newlineIsToken?s[s.length-1]+=a:s.push(a)}return s}class cS extends up{constructor(){super(...arguments),this.tokenize=fp}get useLongestToken(){return!0}castInput(n,s){const{undefinedReplacement:o,stringifyReplacer:r=(a,i)=>typeof i>"u"?o:i}=s;return typeof n=="string"?n:JSON.stringify(fi(n,null,null,r),null," ")}equals(n,s,o){return super.equals(n.replace(/,([\r\n])/g,"$1"),s.replace(/,([\r\n])/g,"$1"),o)}}const dS=new cS;function uS(e,n,s){return dS.diff(e,n,s)}function fi(e,n,s,o,r){n=n||[],s=s||[],o&&(e=o(r===void 0?"":r,e));let a;for(a=0;a<n.length;a+=1)if(n[a]===e)return s[a];let i;if(Object.prototype.toString.call(e)==="[object Array]"){for(n.push(e),i=new Array(e.length),s.push(i),a=0;a<e.length;a+=1)i[a]=fi(e[a],n,s,o,String(a));return n.pop(),s.pop(),i}if(e&&e.toJSON&&(e=e.toJSON()),typeof e=="object"&&e!==null){n.push(e),i={},s.push(i);const c=[];let d;for(d in e)Object.prototype.hasOwnProperty.call(e,d)&&c.push(d);for(c.sort(),a=0;a<c.length;a+=1)d=c[a],i[d]=fi(e[d],n,s,o,d);n.pop(),s.pop()}else i=e;return i}function Tc(e){return e===void 0?[]:Object.entries(e).map(n=>[n[0].toLowerCase(),n[1]]).sort(([n],[s])=>n.localeCompare(s))}function Ec([e,n]){return`${e}: ${n}`}function pi(e){const n=[];let s=0,o=0;for(const r of e){const a=r.value.split(`
|
|
54
|
-
`);a.length>0&&a[a.length-1]===""&&a.pop();for(const i of a)r.added?(o+=1,n.push({kind:"added",text:i,oldLineNumber:null,newLineNumber:o})):r.removed?(s+=1,n.push({kind:"removed",text:i,oldLineNumber:s,newLineNumber:null})):(s+=1,o+=1,n.push({kind:"context",text:i,oldLineNumber:s,newLineNumber:o}))}return n}function mS(e,n){const s=Tc(e).map(Ec).join(`
|
|
55
|
-
`),o=Tc(n).map(Ec).join(`
|
|
56
|
-
`);if(s===o)return{lines:[],isEmpty:!0};const r=mp(s,o);return{lines:pi(r),isEmpty:!1}}function Rc(e){try{const n=JSON.parse(e);return n===null||typeof n=="string"||typeof n=="object"?n:null}catch{return null}}function fS(e,n){const s=e??"",o=n??"";if(s===o)return{lines:[],isEmpty:!0};const r=Rc(s),a=Rc(o);if(r!==null&&a!==null){const c=uS(r,a)??[];if(c.length===1){const d=c[0];if(d!==void 0&&!d.added&&!d.removed)return{lines:[],isEmpty:!0}}return{lines:pi(c),isEmpty:!1}}const i=mp(s,o);return{lines:pi(i),isEmpty:!1}}const pS=22,ga=1e4;function hS(e){return e==="added"?"+":e==="removed"?"-":" "}function xS(e){return e==="added"?"bg-green-500/10 text-green-700 dark:text-green-300":e==="removed"?"bg-red-500/10 text-red-700 dark:text-red-300":"text-foreground/80"}const gS=function({result:n,emptyLabel:s}){const[o,r]=l.useState("unified"),a=l.useRef(null),i=y5({count:n.lines.length,getScrollElement:()=>a.current,estimateSize:()=>pS,overscan:10});if(n.isEmpty)return t.jsx("div",{className:"rounded border border-dashed border-border bg-muted/30 px-4 py-6 text-center text-xs text-muted-foreground","data-testid":"diff-empty",children:s??"No transformation applied — raw and processed are identical."});const c=n.lines.length,d=c>ga,m=d?n.lines.slice(0,ga):n.lines;return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[t.jsxs("span",{children:[c.toLocaleString()," line",c===1?"":"s",d&&` (showing first ${ga.toLocaleString()})`]}),t.jsxs("div",{className:"inline-flex rounded-md border border-border overflow-hidden",children:[t.jsxs("button",{type:"button",onClick:()=>r("unified"),"aria-pressed":o==="unified",className:O("flex items-center gap-1 px-2 py-1 transition-colors",o==="unified"?"bg-muted text-foreground":"hover:bg-muted/50"),title:"Unified diff (single column)",children:[t.jsx(Gg,{className:"size-3"}),"Unified"]}),t.jsxs("button",{type:"button",onClick:()=>r("split"),"aria-pressed":o==="split",className:O("flex items-center gap-1 px-2 py-1 transition-colors border-l border-border",o==="split"?"bg-muted text-foreground":"hover:bg-muted/50"),title:"Split diff (side by side)",children:[t.jsx(L0,{className:"size-3"}),"Split"]})]})]}),t.jsx("div",{ref:a,className:"max-h-[60vh] overflow-auto rounded border border-border bg-background font-mono text-xs","data-testid":"diff-viewport",children:o==="unified"?t.jsx(bS,{virtualizer:i,lines:m}):t.jsx(wS,{lines:m})})]})};function bS({virtualizer:e,lines:n}){return t.jsx("div",{style:{height:`${e.getTotalSize()}px`,width:"100%",position:"relative"},children:e.getVirtualItems().map(s=>{const o=n[s.index];return o===void 0?null:t.jsxs("div",{"data-index":s.index,ref:e.measureElement,className:O("flex items-start gap-3 px-2",xS(o.kind)),style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${s.start}px)`},children:[t.jsx("span",{className:"select-none text-muted-foreground/60 w-10 text-right tabular-nums",children:o.oldLineNumber??""}),t.jsx("span",{className:"select-none text-muted-foreground/60 w-10 text-right tabular-nums",children:o.newLineNumber??""}),t.jsx("span",{className:O("select-none w-3 text-right font-bold",o.kind==="added"&&"text-green-600 dark:text-green-400",o.kind==="removed"&&"text-red-600 dark:text-red-400"),children:hS(o.kind)}),t.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:o.text})]},s.key)})})}function vS(e){const n=[];let s=0;for(;s<e.length;){const o=e[s];if(o===void 0)break;if(o.kind==="context"){n.push({left:{text:o.text,lineNumber:o.oldLineNumber},right:{text:o.text,lineNumber:o.newLineNumber},kind:"equal"}),s+=1;continue}const r=[],a=[];for(;s<e.length&&e[s]?.kind==="removed";){const c=e[s];c!==void 0&&r.push(c),s+=1}for(;s<e.length&&e[s]?.kind==="added";){const c=e[s];c!==void 0&&a.push(c),s+=1}const i=Math.max(r.length,a.length);for(let c=0;c<i;c+=1){const d=r[c],m=a[c];d!==void 0&&m!==void 0?n.push({left:{text:d.text,lineNumber:d.oldLineNumber},right:{text:m.text,lineNumber:m.newLineNumber},kind:"changed"}):d!==void 0?n.push({left:{text:d.text,lineNumber:d.oldLineNumber},right:null,kind:"removed"}):m!==void 0&&n.push({left:null,right:{text:m.text,lineNumber:m.newLineNumber},kind:"added"})}}return n}function yS(e){switch(e){case"changed":return"bg-amber-500/10";case"removed":return"bg-red-500/10";case"added":return"bg-green-500/10";case"equal":return""}}function wS({lines:e}){const n=vS(e);return t.jsx("div",{"data-testid":"diff-split",children:n.map((s,o)=>t.jsxs("div",{className:O("grid grid-cols-2 font-mono text-xs",yS(s.kind)),children:[t.jsxs("div",{className:"flex items-start gap-2 px-2 border-r border-border/50",children:[t.jsx("span",{className:"select-none text-muted-foreground/60 w-8 text-right tabular-nums",children:s.left?.lineNumber??""}),t.jsx("span",{className:O("select-none w-3 text-right font-bold",(s.kind==="removed"||s.kind==="changed")&&"text-red-600 dark:text-red-400"),children:s.left!==null?"-":" "}),t.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:s.left?.text??""})]}),t.jsxs("div",{className:"flex items-start gap-2 px-2",children:[t.jsx("span",{className:"select-none text-muted-foreground/60 w-8 text-right tabular-nums",children:s.right?.lineNumber??""}),t.jsx("span",{className:O("select-none w-3 text-right font-bold",(s.kind==="added"||s.kind==="changed")&&"text-green-600 dark:text-green-400"),children:s.right!==null?"+":" "}),t.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:s.right?.text??""})]})]},o))})}const pp=l.memo(gS),jS=Ud("inline-flex items-center justify-center rounded-full border border-transparent px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",ghost:"[a&]:hover:bg-accent [a&]:hover:text-accent-foreground",link:"text-primary underline-offset-4 [a&]:hover:underline"}},defaultVariants:{variant:"default"}});function Ce({className:e,variant:n="default",asChild:s=!1,...o}){const r=s?vb:"span";return t.jsx(r,{"data-slot":"badge","data-variant":n,className:O(jS({variant:n}),e),...o})}const SS=3;function NS({event:e}){const n=s=>{s.stopPropagation(),fs({logId:e.logId,tab:"response",toolCallIndex:e.index})};return t.jsx("button",{type:"button",className:"inline-flex h-5 min-w-0 max-w-[8.5rem] items-center rounded px-1.5 text-[10px] text-muted-foreground transition-colors hover:bg-background/65 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:n,onKeyDown:s=>s.stopPropagation(),"aria-label":`Open response tool call ${e.name}`,title:e.name,children:t.jsx("span",{className:"min-w-0 truncate font-mono font-semibold",children:e.name})})}function CS({events:e}){if(e.length===0)return null;const n=e.slice(0,SS),s=Math.max(0,e.length-n.length);return t.jsxs("span",{className:"inline-flex h-7 min-w-0 max-w-full items-center gap-1 overflow-hidden rounded-md border border-cyan-300/10 bg-cyan-300/[0.055] px-1 sm:max-w-[26rem]",role:"group","aria-label":`${e.length} response tool ${e.length===1?"call":"calls"}`,onClick:o=>o.stopPropagation(),onKeyDown:o=>o.stopPropagation(),children:[t.jsxs("span",{className:"inline-flex h-5 shrink-0 items-center gap-1 px-1 font-mono text-[9px] font-semibold uppercase text-cyan-300",children:[t.jsx(Ys,{className:"size-3"}),"Call ",e.length]}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-0.5 overflow-hidden",children:[n.map(o=>t.jsx(NS,{event:o},o.id)),s>0&&t.jsxs("span",{className:"inline-flex h-5 shrink-0 items-center rounded px-1 font-mono text-[10px] font-semibold text-muted-foreground",children:["+",s]})]})]})}const kS={success:"bg-slate-300/[0.08] text-slate-100 border-transparent",client_error:"bg-amber-300/[0.10] text-amber-100 border-transparent",server_error:"bg-rose-400/[0.10] text-rose-100 border-transparent",pending:"bg-cyan-300/[0.08] text-cyan-100 border-transparent"},_S={success:{frame:"border-cyan-200/15 bg-white/[0.04] text-text-strong"},client_error:{frame:"border-amber-300/25 bg-amber-300/[0.08] text-amber-100"},server_error:{frame:"border-rose-300/25 bg-rose-300/[0.08] text-rose-100"},pending:{frame:"border-cyan-300/25 bg-cyan-300/[0.08] text-cyan-100"}},Cs="border border-transparent bg-white/[0.045] hover:bg-white/[0.075] size-8 text-muted-foreground shadow-none hover:text-cyan-100",gt="bg-white/[0.045] flex h-7 items-center gap-1 rounded-md px-2 text-xs";function ks(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function TS(e){return e>=10?`${e.toFixed(0)}/s`:`${e.toFixed(1)}/s`}function ES(e,n){switch(e){case"success":return n===null?"OK":String(n);case"client_error":return n===null?"WARN":String(n);case"server_error":return n===null?"FAIL":String(n);case"pending":return"ROLL"}}function Mc({trend:e}){if(e===null)return null;const n=e.direction==="up",s=n?Yx:qx,o=n?"+":"-";return t.jsxs("span",{className:"flex items-center gap-0.5 text-muted-foreground tabular-nums",children:[t.jsx(s,{className:n?"size-3 text-cyan-300":"size-3 text-rose-400"}),t.jsxs("span",{className:"font-mono",children:[o,Re(e.delta)]})]})}const RS=l.memo(function({log:e,displayNumber:n,messageCount:s=null,toolCount:o=null,toolEvents:r=[],expanded:a,onToggle:i,cacheTrend:c=null,activeTab:d,tabActions:m,onReplay:u,slowResponseThresholdSeconds:f=0,showClientMetadata:p=!0,timeDisplayFormat:h}){const g=Th(e.responseStatus),v=e.elapsedMs!==null&&f>0&&e.elapsedMs>f*1e3,y=e.inputTokens!==null||e.outputTokens!==null,w=e.firstChunkMs??null,b=e.tokensPerSecond??null,j=w===null?null:ks(w),S=b===null||b<=0?null:TS(b),N=e.warnings?.length??0,C=e.clientPid!==null&&e.clientPid!==void 0,R=e.clientProjectFolder!==null&&e.clientProjectFolder!==void 0&&e.clientProjectFolder!=="";e.clientCwd!==null&&e.clientCwd!==void 0&&e.clientCwd;const I=_S[g],P=ES(g,e.responseStatus),M=g!=="success"||e.responseStatus!==200,k=e.streaming&&j===null&&S===null;return t.jsx(bs,{children:t.jsxs("div",{id:`log-${e.id}`,role:"button",tabIndex:0,"data-nav-id":`log-${e.id}`,"data-nav-action":a?"collapse":"expand",className:O("group/header relative isolate flex min-w-0 cursor-pointer items-start gap-2 overflow-hidden px-3 py-2 transition-[background-color,border-color,box-shadow]",a?"bg-white/[0.04]":"bg-transparent hover:bg-white/[0.035]","select-none","focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-none"),onClick:i,onKeyDown:A=>{(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),i())},children:[t.jsxs("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1",children:[t.jsx("span",{className:O("inline-flex h-8 shrink-0 items-center rounded-md px-2 font-mono",I.frame),children:t.jsxs("span",{className:"text-xs font-semibold tabular-nums",title:`Log ID ${String(e.id)}`,children:["#",n]})}),t.jsxs("span",{className:"bg-white/[0.045] flex h-7 shrink-0 items-center gap-1 rounded-md px-2 text-xs text-muted-foreground",children:[t.jsx(Vt,{className:"size-3"}),t.jsx("span",{className:"font-mono tabular-nums",title:e.timestamp,children:Ga(e.timestamp,h)})]}),M&&t.jsxs(Ce,{variant:"outline",className:O("h-6 gap-1 rounded-md px-2 py-0 font-mono text-[10px] font-semibold uppercase tabular-nums shadow-[inset_0_1px_0_rgba(255,255,255,0.05)]",kS[g]),children:[g==="success"?t.jsx(Pe,{className:"size-3","aria-label":"Success"}):g==="server_error"?t.jsx(Ig,{className:"size-3","aria-label":"Server error"}):g==="client_error"?t.jsx(cn,{className:"size-3","aria-label":"Client error"}):t.jsx(Ae,{className:"size-3 animate-spin","aria-label":"Pending"}),P]}),N>0&&t.jsxs(nt,{children:[t.jsx(st,{asChild:!0,children:t.jsxs(Ce,{variant:"outline",className:"h-6 gap-1 rounded-md border-amber-300/30 bg-amber-300/[0.10] px-2 py-0 font-mono text-[10px] tabular-nums text-amber-100",children:[t.jsx(cn,{className:"size-3","aria-label":"Tool schema warnings"}),N]})}),t.jsx(ot,{children:N===1?"1 tool schema warning":`${N} tool schema warnings`})]}),e.elapsedMs!==null&&(v?t.jsxs(nt,{children:[t.jsx(st,{asChild:!0,children:t.jsxs("span",{className:O(gt,"shrink-0 border-amber-300/25 text-amber-200"),children:[t.jsx(Vt,{className:"size-3"}),t.jsx("span",{className:"font-mono tabular-nums",children:ks(e.elapsedMs)}),t.jsx(cn,{className:"size-3","aria-label":"Slow response"})]})}),t.jsxs(ot,{children:["Slow response: ",ks(e.elapsedMs)," exceeds"," ",ks(f*1e3)]})]}):t.jsxs("span",{className:O(gt,"shrink-0 text-muted-foreground"),children:[t.jsx(Vt,{className:"size-3"}),t.jsx("span",{className:"font-mono tabular-nums",children:ks(e.elapsedMs)})]})),e.streaming&&j!==null&&t.jsxs("span",{className:O(gt,"shrink-0 text-cyan-300"),children:[t.jsx(Vl,{className:"size-3"}),t.jsxs("span",{className:"font-mono tabular-nums",children:["first ",j]})]}),e.streaming&&S!==null&&t.jsxs("span",{className:O(gt,"shrink-0 text-cyan-300"),children:[t.jsx(qi,{className:"size-3"}),t.jsx("span",{className:"font-mono tabular-nums",children:S})]}),y&&t.jsxs("span",{className:O(gt,"min-w-0 sm:shrink-0"),children:[t.jsx(Ds,{className:"size-3 text-muted-foreground"}),t.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-1 font-mono tabular-nums",children:[t.jsxs("span",{className:O("whitespace-nowrap",e.inputTokens!==null?"text-blue-400":"text-muted-foreground"),children:["IN ",e.inputTokens!==null?Re(e.inputTokens):"n/a"]}),t.jsx("span",{className:"text-muted-foreground",children:"/"}),t.jsxs("span",{className:O("whitespace-nowrap",e.outputTokens!==null?"text-amber-400":"text-muted-foreground"),children:["OUT ",e.outputTokens!==null?Re(e.outputTokens):"n/a"]})]})]}),e.cacheCreationInputTokens!==null&&e.cacheCreationInputTokens>0&&t.jsxs("span",{className:O(gt,"shrink-0"),children:[t.jsx(Mc,{trend:c?.creation??null}),t.jsxs("span",{className:"font-mono tabular-nums text-cyan-300",children:["KV Cache +",Re(e.cacheCreationInputTokens)]})]}),e.cacheReadInputTokens!==null&&e.cacheReadInputTokens>0&&t.jsxs("span",{className:O(gt,"shrink-0"),children:[t.jsx(Mc,{trend:c?.read??null}),t.jsxs("span",{className:"font-mono tabular-nums text-purple-400",children:["KV Cache ~",Re(e.cacheReadInputTokens)]})]}),s!==null&&t.jsxs("span",{className:O(gt,"shrink-0 text-muted-foreground"),children:[t.jsx(gr,{className:"size-3"}),t.jsx("span",{className:"font-mono tabular-nums",children:s})]}),o!==null&&t.jsxs("span",{className:O(gt,"shrink-0 text-muted-foreground"),children:[t.jsx(Ys,{className:"size-3"}),t.jsx("span",{className:"font-mono tabular-nums",children:o})]}),t.jsx(CS,{events:r}),e.origin!==null&&t.jsxs("span",{className:O(gt,"hidden shrink-0 text-muted-foreground xl:flex"),title:`Origin: ${e.origin}`,children:[t.jsx(hu,{className:"size-3"}),t.jsx("span",{className:"font-mono tabular-nums truncate max-w-[120px]",title:e.origin,children:e.origin})]}),p&&(C||R)&&t.jsxs("span",{className:O(gt,"hidden shrink-0 text-purple-300 xl:flex"),children:[t.jsx(Q0,{className:"size-3"}),R?t.jsx("span",{className:"font-mono tabular-nums",children:e.clientProjectFolder}):t.jsxs("span",{className:"font-mono tabular-nums",children:["PID ",e.clientPid]})]}),k&&t.jsx(Vl,{className:"size-3 shrink-0 text-muted-foreground/60"})]}),t.jsxs("span",{className:"flex shrink-0 items-start gap-1.5",children:[a&&t.jsxs("span",{className:"flex items-center gap-1.5 shrink-0",onClick:A=>A.stopPropagation(),onKeyDown:A=>A.stopPropagation(),children:[m!==void 0&&d!==void 0&&(()=>{const A=m[d];return A===void 0?null:t.jsxs(t.Fragment,{children:[A.expansion!==null&&t.jsxs(nt,{children:[t.jsx(st,{asChild:!0,children:t.jsx(te,{variant:"outline",size:"icon",className:Cs,onClick:A.expansion.onToggle,disabled:A.expansion.isPending,"aria-pressed":A.expansion.isExpanded,"aria-label":A.expansion.isExpanded?"Collapse all JSON":"Expand all JSON",children:A.expansion.isExpanded?t.jsx(g0,{className:"size-3.5"}):t.jsx(u0,{className:"size-3.5"})})}),t.jsx(ot,{children:A.expansion.isExpanded?"Collapse all JSON nodes":"Expand all JSON nodes"})]}),A.diffWithRaw!==void 0&&t.jsxs(nt,{children:[t.jsx(st,{asChild:!0,children:t.jsx(te,{variant:"outline",size:"icon",className:O(Cs,A.diffWithRaw.active&&"border-cyan-300/35 bg-cyan-400/15 text-cyan-100"),onClick:A.diffWithRaw.onToggle,"aria-pressed":A.diffWithRaw.active,"aria-label":A.diffWithRaw.active?"Hide raw diff":"Diff with raw",children:t.jsx(Y0,{className:"size-3.5"})})}),t.jsx(ot,{children:A.diffWithRaw.active?"Hide diff with raw request":"Show diff between displayed and raw request body"})]}),A.diffWithPrevious!==void 0&&t.jsxs(nt,{children:[t.jsx(st,{asChild:!0,children:t.jsx(te,{variant:"outline",size:"icon",className:Cs,onClick:A.diffWithPrevious,"aria-label":"Diff with previous",children:t.jsx(xu,{className:"size-3.5"})})}),t.jsx(ot,{children:"Compare this request with the immediately preceding one"})]}),A.copyText!==null&&t.jsxs(nt,{children:[t.jsx(st,{asChild:!0,children:t.jsx(te,{variant:"outline",size:"icon",className:Cs,onClick:A.onCopy,"aria-label":A.copyCopied?"Copied":A.copyLabel,children:A.copyCopied?t.jsx(Pe,{className:"size-3.5 text-cyan-300"}):t.jsx(St,{className:"size-3.5"})})}),t.jsx(ot,{children:A.copyCopied?"Copied to clipboard":A.copyLabel})]})]})})(),u!==void 0&&t.jsxs(nt,{children:[t.jsx(st,{asChild:!0,children:t.jsx(te,{variant:"outline",size:"icon",className:Cs,onClick:u,"aria-label":"Replay request",children:t.jsx(yu,{className:"size-3.5"})})}),t.jsx(ot,{children:"Re-send this request to the provider"})]})]}),t.jsx("span",{className:"bg-white/[0.045] hover:bg-white/[0.075] inline-flex size-8 shrink-0 items-center justify-center rounded-md text-text-strong","aria-hidden":"true",children:a?t.jsx(We,{className:"size-4 shrink-0"}):t.jsx(ct,{className:"size-4 shrink-0"})})]})]})})});function MS({...e}){return t.jsx(Vb,{"data-slot":"collapsible",...e})}function dE({...e}){return t.jsx(Iu,{"data-slot":"collapsible-trigger",...e})}function AS({...e}){return t.jsx(Pu,{"data-slot":"collapsible-content",...e})}function IS({className:e,children:n,...s}){return t.jsxs(Xy,{"data-slot":"scroll-area",className:O("relative overflow-hidden",e),...s,children:[t.jsx(Zy,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full max-h-[inherit] rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:n}),t.jsx(PS,{}),t.jsx(Qy,{})]})}function PS({className:e,orientation:n="vertical",...s}){return t.jsx(qm,{"data-slot":"scroll-area-scrollbar",orientation:n,className:O("flex touch-none p-px transition-colors select-none",n==="vertical"&&"h-full w-2.5 border-l border-l-transparent",n==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",e),...s,children:t.jsx(Km,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}const hp={file:"file",shell:"shell",browser:"browser",web:"web",mcp:"MCP",code:"code",other:"other"},LS={file:"border-transparent bg-blue-400/5 text-blue-300",shell:"border-transparent bg-teal-400/5 text-teal-300",browser:"border-transparent bg-cyan-400/5 text-cyan-300",web:"border-transparent bg-sky-400/5 text-sky-300",mcp:"border-transparent bg-violet-400/5 text-violet-300",code:"border-transparent bg-emerald-400/5 text-emerald-300",other:"border-transparent bg-muted/30 text-muted-foreground"};function OS({category:e}){switch(e){case"file":return t.jsx(tg,{className:"size-3.5"});case"shell":return t.jsx(Ln,{className:"size-3.5"});case"browser":return t.jsx(Eg,{className:"size-3.5"});case"web":return t.jsx(hu,{className:"size-3.5"});case"mcp":return t.jsx(e0,{className:"size-3.5"});case"code":return t.jsx(mu,{className:"size-3.5"});case"other":return t.jsx(U0,{className:"size-3.5"})}}function DS({names:e}){return e.length===0?null:t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:[t.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:"required"}),e.slice(0,4).map(n=>t.jsx(Ce,{variant:"outline",className:"h-5 max-w-36 truncate rounded-md px-1.5 py-0 font-mono text-[10px]",children:n},n)),e.length>4&&t.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:["+",e.length-4]})]})}function zS({tool:e,called:n}){const[s,o]=l.useState(!1),r=an(e.name),a=e.description!==null||e.requiredParameters.length>0||e.schema!==null;return t.jsx(MS,{open:s,onOpenChange:o,children:t.jsxs("div",{className:"bg-white/[0.035] rounded-[8px]",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-2.5 py-2",children:[t.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>o(i=>!i),"aria-expanded":s,disabled:!a,children:[t.jsx(OS,{category:e.category}),t.jsx("span",{className:"min-w-0 truncate font-mono text-xs font-semibold text-foreground/90",children:e.name}),n&&t.jsx(Ce,{variant:"outline",className:"h-5 rounded-md border-emerald-400/20 bg-emerald-400/5 px-1.5 py-0 text-[10px] text-emerald-300",children:"called"}),t.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:[e.parameterCount," params"]}),e.descriptionPreview!==null&&t.jsx("span",{className:"hidden min-w-0 truncate text-xs text-muted-foreground md:inline",children:e.descriptionPreview}),t.jsx("span",{className:"flex-1"}),a&&(s?t.jsx(We,{className:"size-3.5 shrink-0 text-muted-foreground"}):t.jsx(ct,{className:"size-3.5 shrink-0 text-muted-foreground"}))]}),t.jsx("button",{type:"button",className:"bg-white/[0.045] hover:bg-white/[0.075] inline-flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:r.copy,"aria-label":r.copied?"Copied tool name":"Copy tool name",children:r.copied?t.jsx(Pe,{className:"size-3.5 text-emerald-400"}):t.jsx(St,{className:"size-3.5"})})]}),t.jsx(AS,{children:s&&t.jsxs("div",{className:"space-y-2 bg-white/[0.025] px-2.5 py-2",children:[e.description!==null&&t.jsx("p",{className:"text-xs leading-relaxed text-muted-foreground",children:e.description}),t.jsx(DS,{names:e.requiredParameters}),e.schema!==null&&t.jsx(IS,{className:"bg-black/[0.16] max-h-64 rounded-[8px] p-2",children:t.jsx(l.Suspense,{fallback:t.jsx("div",{className:"text-xs text-muted-foreground",children:"Loading JSON..."}),children:t.jsx(mi,{data:sr(e.schema),defaultExpandDepth:0})})})]})})]})})}function $S(e,n){return n.length===0?!0:`${e.name} ${e.description??""} ${hp[e.category]}`.toLowerCase().trim().includes(n)}const FS=l.memo(function({summary:n,calledToolNames:s}){const[o,r]=l.useState(!1),[a,i]=l.useState(""),c=l.useMemo(()=>new Set(s),[s]),d=a.trim().toLowerCase(),m=l.useMemo(()=>n===null?[]:n.tools.filter(p=>$S(p,d)),[d,n]);if(n===null)return null;const u=n.tools.slice(0,6),f=n.tools.length-u.length;return t.jsxs("section",{className:"bg-black/[0.10] mb-3 overflow-hidden rounded-[8px]",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 px-3 py-2",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx(Ys,{className:"size-4 shrink-0 text-sky-300/80"}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:"text-sm font-semibold text-foreground",children:"Request Tools"}),t.jsx(Ce,{variant:"outline",className:"h-5 rounded-md px-1.5 py-0 font-mono text-[10px]",children:n.tools.length}),n.toolChoiceLabel!==null&&t.jsxs(Ce,{variant:"outline",className:"h-5 rounded-md px-1.5 py-0 font-mono text-[10px] text-muted-foreground",children:["tool_choice: ",n.toolChoiceLabel]})]}),t.jsx("div",{className:"mt-1 flex min-w-0 flex-wrap gap-1",children:n.categories.map(p=>t.jsxs(Ce,{variant:"outline",className:O("h-5 rounded-md px-1.5 py-0 font-mono text-[10px]",LS[p.category]),children:[p.count," ",hp[p.category]]},p.category))})]})]}),t.jsxs(te,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-muted-foreground hover:text-cyan-100",onClick:()=>r(p=>!p),"aria-expanded":o,children:[o?t.jsx(We,{className:"size-3.5"}):t.jsx(ct,{className:"size-3.5"}),o?"Hide":"Show"]})]}),t.jsxs("div",{className:"flex min-w-0 flex-wrap gap-1.5 bg-white/[0.025] px-3 py-2",children:[u.map(p=>t.jsx(Ce,{variant:"outline",className:O("h-5 max-w-44 truncate rounded-md px-1.5 py-0 font-mono text-[10px]",c.has(p.name)&&"border-emerald-400/20 text-emerald-300"),children:p.name},p.name)),f>0&&t.jsxs("span",{className:"font-mono text-[10px] leading-5 text-muted-foreground",children:["+",f]})]}),o&&t.jsxs("div",{className:"space-y-2 bg-black/10 px-3 py-3",children:[t.jsxs("label",{className:"bg-white/[0.045] hover:bg-white/[0.075] flex h-8 items-center gap-2 rounded-md px-2 text-xs",children:[t.jsx(e1,{className:"size-3.5 shrink-0 text-muted-foreground"}),t.jsx("input",{value:a,onChange:p=>i(p.target.value),placeholder:"Filter tools",className:"min-w-0 flex-1 bg-transparent font-mono text-xs outline-none placeholder:text-muted-foreground/70"})]}),t.jsx("div",{className:"grid gap-1.5",children:m.length>0?m.map(p=>t.jsx(zS,{tool:p,called:c.has(p.name)},p.name)):t.jsx("p",{className:"py-2 text-xs text-muted-foreground",children:"No matching tools"})})]})]})});function Ac(e,n,s){return e==="anthropic"&&n==="full"&&s}function US(e,n){return e==="full"&&n}function ba(e,n){return e==="full"&&n}function va(e,n){return e==="full"&&n}function BS(e,n,s,o){return e==="anthropic"&&n==="full"&&s&&o}function Gn(){return t.jsx("div",{className:"h-1","aria-hidden":"true"})}function qS(e,n){switch(e){case"anatomy":return n===null?"request":"anatomy";case"request":return"request";case"response":return"parsed"}}const HS=15e3,WS=15e3,VS=256*1024,or=1024*1024,Ic=256*1024,Zt="h-9 flex-none rounded-md border border-transparent bg-transparent px-3 text-xs font-semibold text-muted-foreground shadow-none transition-colors hover:bg-white/[0.045] hover:text-foreground data-[state=active]:bg-cyan-300/[0.08] data-[state=active]:text-cyan-100 data-[state=active]:shadow-none";function xo(e=null){return{status:"idle",text:"",offset:0,totalBytes:e,hasMore:e!==null&&e>0,error:null}}function rr(e){return e??0}function Pc(e,n){return n??e?.length??0}function _l(e){return e.bodyContentMode==="compact"||e.bodyContentMode==="truncated"}function xp(e){return _l(e)?rr(e.rawRequestBodyBytes)>or||rr(e.responseTextBytes)>or:!1}function KS(e){return _l(e)&&!xp(e)}function GS(e,n){return n?!0:_l(e)?!1:Pc(e.rawRequestBody,e.rawRequestBodyBytes)<=Ic&&Pc(e.responseText,e.responseTextBytes)<=Ic}function YS(e){switch(e){case"request":case"raw-request":case"anatomy":case"raw":case"parsed":return!0;case"headers":case"raw-headers":case"sse":return!1;default:return!1}}function JS(e){switch(e){case"request":case"anatomy":return!0;case"headers":case"raw-headers":case"raw-request":case"raw":case"parsed":case"sse":return!1;default:return!1}}function XS(e){return e instanceof ki?"Body preview timed out. The log is still available on disk; try loading again.":e instanceof Error?e.message:"Body preview could not be loaded."}function go({status:e,error:n,footprint:s,onRetry:o}){switch(e){case"idle":return null;case"loading":return t.jsx(In,{tone:"loading",title:"Loading full bodies",children:t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Ae,{className:"size-3.5 shrink-0 animate-spin text-cyan-200"}),t.jsx("span",{children:"Loading full request and response bodies from the log store."})]}),s!==null&&t.jsx("span",{className:"rounded border border-cyan-300/15 bg-cyan-300/[0.06] px-2 py-0.5 font-mono text-[11px] text-cyan-100",children:s})]})});case"failed":return t.jsx(In,{tone:"warning",title:n?.title??"Full bodies could not be loaded",children:t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsx("span",{children:n?.detail??"Compact metadata is still available."}),t.jsxs(te,{type:"button",variant:"outline",size:"sm",className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground h-7 gap-1.5 text-xs text-amber-100",onClick:o,children:[t.jsx(yt,{className:"size-3"}),"Retry"]})]})})}}function Lc(e,n){return e?n.text!==""?n.text:n.status==="success"?"":null:null}function Qt({children:e,className:n}){return t.jsx("div",{className:O("bg-black/[0.14] inspector-scrollbar mx-3 mb-3 max-h-[72vh] overflow-auto rounded-[8px] p-3",n),children:e})}function Oo({children:e}){return t.jsx("div",{className:"bg-white/[0.035] rounded-md px-3 py-5 text-center text-xs italic text-muted-foreground",children:e})}function bo({children:e}){return t.jsx("pre",{className:"bg-black/[0.18] inspector-scrollbar max-h-[64vh] overflow-auto whitespace-pre-wrap break-words rounded-[8px] p-3 font-mono text-xs leading-relaxed text-muted-foreground",children:e})}const ZS={loading:"border-transparent bg-cyan-400/[0.06] text-cyan-100",warning:"border-transparent bg-amber-400/[0.08] text-amber-100",danger:"border-transparent bg-rose-400/[0.08] text-rose-100"};function In({tone:e,title:n,children:s}){return t.jsxs("div",{className:O("mb-3 rounded-md border px-3 py-2 text-xs shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]",ZS[e]),children:[n!==void 0&&t.jsx("div",{className:"mb-1 font-semibold",children:n}),t.jsx("div",{className:"leading-relaxed text-muted-foreground",children:s})]})}function vo({label:e,state:n,expectedBytes:s,onLoadMore:o}){const r=n.totalBytes??s,a=r===null?Qn(n.offset):`${Qn(n.offset)} / ${Qn(r)}`,i=n.status!=="loading"&&n.hasMore,c=n.status==="failed"?"Retry":"Load more";return t.jsx(In,{tone:n.status==="failed"?"warning":"loading",title:`${e} body preview`,children:t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsxs("span",{children:[n.status==="idle"&&r!==null?`${e} body is ${Qn(r)}. Loading the first preview chunk.`:`Loaded ${a}.`,n.status==="failed"&&n.error!==null&&` ${n.error}`]}),i&&t.jsx(te,{type:"button",variant:"outline",size:"sm",className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground h-7 text-xs text-cyan-100",onClick:o,children:c})]})})}function Oc({error:e,onOpenSse:n}){return e==null?null:t.jsx(In,{tone:"danger",title:"SSE Error",children:t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsx("span",{className:"font-mono",children:e}),t.jsx(te,{type:"button",variant:"outline",size:"sm",className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground h-7 text-xs text-rose-100",onClick:n,children:"View SSE"})]})})}function QS({onOpenSse:e}){return t.jsx(In,{tone:"loading",title:"SSE chunks",children:t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsx("span",{children:"Streaming chunks are available in the SSE tab."}),t.jsx(te,{type:"button",variant:"outline",size:"sm",className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground h-7 text-xs text-cyan-100",onClick:e,children:"View SSE"})]})})}function Dc({headers:e,emptyLabel:n}){const s=e===void 0?[]:Object.entries(e).sort(([o],[r])=>o.localeCompare(r));return s.length===0?t.jsx(Oo,{children:n}):t.jsx("div",{className:"bg-black/[0.14] overflow-hidden rounded-[8px] font-mono text-xs",children:s.map(([o,r])=>t.jsxs("div",{className:"grid min-w-0 grid-cols-[minmax(140px,0.32fr)_minmax(0,1fr)] border-b border-white/[0.055] last:border-b-0",children:[t.jsx("div",{className:"min-w-0 truncate bg-white/[0.035] px-2.5 py-2 font-semibold text-cyan-200",children:o}),t.jsx("div",{className:"min-w-0 truncate px-2.5 py-2 text-muted-foreground",title:r,children:r})]},o))})}function eN({active:e,onClick:n}){return t.jsxs(nt,{children:[t.jsx(st,{asChild:!0,children:t.jsxs(te,{variant:e?"default":"outline",size:"sm",className:O("h-8 border-white/10 text-xs shadow-none",e?"bg-cyan-300 text-black hover:bg-cyan-200":"border border-input bg-background hover:bg-accent hover:text-accent-foreground text-muted-foreground hover:text-cyan-100"),onClick:n,"aria-pressed":e,children:[t.jsx(cg,{className:"size-3.5 mr-1"}),e?"Showing diff":"Diff with Raw"]})}),t.jsx(ot,{children:e?"Hide diff view":"Compare proxy output against the original raw version"})]})}const tN=l.memo(function({rawBody:e,displayedBody:n,emptyLabel:s}){const o=l.useMemo(()=>fS(e,n),[e,n]);return t.jsx(pp,{result:o,emptyLabel:s})}),nN=l.memo(function({rawHeaders:e,headers:n,emptyLabel:s}){const o=l.useMemo(()=>mS(e,n),[e,n]);return t.jsx(pp,{result:o,emptyLabel:s})}),sN=l.memo(function({log:e,displayNumber:n,viewMode:s="simple",strip:o,slowResponseThresholdSeconds:r,timeDisplayFormat:a,cacheTrend:i=null,onCompareWithPrevious:c,showClientMetadata:d=!0,toolEvents:m=[]}){const[u,f]=l.useState(!1),[p,h]=l.useState(!1),[g,v]=l.useState(!1),[y,w]=l.useState(!1),[b,j]=l.useState("request"),[S,N]=l.useState(null),[C,R]=l.useState(0),[I,P]=l.useState(null),[M,k]=l.useState(null),[A,D]=l.useState("idle"),[$,Y]=l.useState(null),[Q,U]=l.useState(0),[H,X]=l.useState(()=>xo(e.rawRequestBodyBytes??null)),[B,W]=l.useState(()=>xo(e.responseTextBytes??null)),pe=l.useRef(null),ve=l.useRef(e.id),ye=l.useRef(!1),re=l.useRef(!1),z=M??e,Z=M===null&&xp(e),we=l.useMemo(()=>rS(e.rawRequestBodyBytes,e.responseTextBytes),[e.rawRequestBodyBytes,e.responseTextBytes]),Ne=Lc(Z,H),le=Lc(Z,B),ce=z.rawRequestBody??Ne,ae=z.responseText??le,je=z.rawRequestBody===null&&Ne!==null,_e=z.responseText===null&&le!==null,Ie=!je||H.hasMore===!1&&rr(H.totalBytes)<=or,Ue=!_e||B.hasMore===!1&&rr(B.totalBytes)<=or,Me=Fs(z),Be=ep(Me),ut=GS(z,u),Ge=l.useMemo(()=>Be.analyzeRequest(ut?z.rawRequestBody:null),[Be,ut,z.rawRequestBody]),Je=l.useMemo(()=>Be.analyzeResponse(ut?z.responseText:null),[Be,ut,z.responseText]),De=l.useMemo(()=>!o||Me!=="anthropic"||z.rawRequestBody===null?null:B5(z.rawRequestBody).body,[z.rawRequestBody,Me,o])??ce,F=xa(u&&JS(b)&&Ie?De:null),ee=xa(b==="raw-request"&&Ie?ce:null),ge=xa(b==="raw"&&Ue?ae:null),fe=F.parsedData??Ge.parsed,Se=l.useMemo(()=>z.headers&&Object.keys(z.headers).length>0?JSON.stringify(z.headers,null,2):null,[z.headers]),$e=l.useMemo(()=>z.rawHeaders&&Object.keys(z.rawHeaders).length>0?JSON.stringify(z.rawHeaders,null,2):null,[z.rawHeaders]),G=an(De),_=an(ce),L=an(Se),K=an($e),se=an(ae),de=l.useMemo(()=>({request:{copyLabel:je?"Copy loaded request preview":"Copy request body",copyText:De,copyCopied:G.copied,onCopy:G.copy,expansion:Ie?{isExpanded:F.isExpanded,isPending:F.isPending,onToggle:F.toggle}:null,diffWithRaw:BS(Me,s,o,z.rawRequestBody!==null)?{active:y,onToggle:()=>w(!y)}:void 0,diffWithPrevious:c===void 0?void 0:()=>{c(z)}},"raw-request":{copyLabel:je?"Copy loaded raw request preview":"Copy raw request",copyText:ce,copyCopied:_.copied,onCopy:_.copy,expansion:Ie?{isExpanded:ee.isExpanded,isPending:ee.isPending,onToggle:ee.toggle}:null},...va(s,z.headers!==void 0&&Object.keys(z.headers).length>0)?{headers:{copyLabel:"Copy headers",copyText:Se,copyCopied:L.copied,onCopy:L.copy,expansion:null}}:{},...ba(s,z.rawHeaders!==void 0&&Object.keys(z.rawHeaders).length>0)?{"raw-headers":{copyLabel:"Copy raw headers",copyText:$e,copyCopied:K.copied,onCopy:K.copy,expansion:null}}:{},raw:{copyLabel:_e?"Copy loaded response preview":"Copy response",copyText:ae,copyCopied:se.copied,onCopy:se.copy,expansion:Ue?{isExpanded:ge.isExpanded,isPending:ge.isPending,onToggle:ge.toggle}:null}}),[De,je,Ie,G,F,y,z,z.rawRequestBody,ce,_,ee,Se,L,$e,K,z.responseText,_e,Ue,ae,se,ge,Me,s,o,c]),J=l.useMemo(()=>fe!==null?Be.anatomySegments(fe):null,[Be,fe]),he=l.useMemo(()=>Nl(fe),[fe]),ue=z.warnings??[],Xt=l.useMemo(()=>{if(J!==null)return new Set(J.map(Te=>Te.path))},[J]),bn=oS({containerRef:pe,setExpandToPath:P,ensureTabActive:()=>{b!=="request"&&(re.current=!0,j("request"))}}),Ct=l.useCallback((Te,qt)=>{const Qe=Te==="request"?X:W;Qe(et=>({...et,status:"loading",error:null}));const ys=new URLSearchParams({part:Te,offset:String(qt),limit:String(VS)});Le(`/api/logs/${String(e.id)}/body?${ys.toString()}`,Wd,WS).then(et=>{ve.current===e.id&&Qe($n=>({status:"success",text:et.offset===0?et.text:`${$n.text}${et.text}`,offset:et.nextOffset??et.totalBytes,totalBytes:et.totalBytes,hasMore:et.hasMore,error:null}))}).catch(et=>{ve.current===e.id&&Qe($n=>({...$n,status:"failed",error:XS(et)}))})},[e.id]),zn=l.useCallback(()=>{ye.current||(k(null),D("idle"),Y(null),U(Te=>Te+1))},[]),Hr=l.useCallback(()=>{const Te=!u;Te&&(re.current=!1,j(J!==null?"anatomy":"request")),f(Te)},[J,u]),vs=l.useCallback(()=>{re.current=!0,j("sse")},[]),Wr=l.useCallback(Te=>{re.current=!0,j(Te)},[]);return l.useEffect(()=>{ve.current=e.id,ye.current=!1,k(null),D("idle"),Y(null),U(0),re.current=!1,X(xo(e.rawRequestBodyBytes??null)),W(xo(e.responseTextBytes??null))},[e.id,e.rawRequestBodyBytes,e.responseTextBytes]),l.useEffect(()=>{u&&(re.current||b==="request"&&J!==null&&j("anatomy"))},[b,J,u]),l.useEffect(()=>{if(!u||!YS(b)||!KS(e)||M!==null||ye.current)return;let Te=!1;return ye.current=!0,D("loading"),Y(null),Le(`/api/logs/${String(e.id)}`,Os,HS).then(qt=>{Te||(ye.current=!1,k(qt),D("idle"),Y(null))}).catch(qt=>{Te||(ye.current=!1,D("failed"),Y(aS(qt)))}),()=>{Te=!0,ye.current=!1}},[b,u,M,e.bodyContentMode,e.id,e.rawRequestBodyBytes,e.responseTextBytes,Q]),l.useEffect(()=>{u&&Z&&H.status==="idle"&&(b!=="request"&&b!=="raw-request"&&b!=="anatomy"||Ct("request",0))},[b,u,Ct,H.status,Z]),l.useEffect(()=>{u&&Z&&B.status==="idle"&&(b!=="parsed"&&b!=="raw"||Ct("response",0))},[b,u,Ct,B.status,Z]),l.useEffect(()=>{const Te=qt=>{const Qe=Ur(qt);Qe!==null&&Qe.logId===e.id&&(f(!0),re.current=!0,j(qS(Qe.tab,J)),Qe.tab==="response"&&Qe.toolCallIndex!==void 0&&(N(Qe.toolCallIndex),R(ys=>ys+1)))};return window.addEventListener(Yt,Te),()=>{window.removeEventListener(Yt,Te)}},[J,e.id]),t.jsxs(bs,{children:[t.jsxs("div",{className:O("bg-card/80 relative mb-1.5 overflow-hidden rounded-[8px] transition-[background-color,box-shadow]",u?"bg-card shadow-[0_18px_60px_rgba(0,0,0,0.30),0_0_0_1px_rgba(103,232,249,0.08)]":"hover:bg-card"),children:[t.jsx(RS,{log:z,displayNumber:n,messageCount:Ge.messageCount,toolCount:Ge.toolCount,toolEvents:m,expanded:u,onToggle:Hr,cacheTrend:i,slowResponseThresholdSeconds:r,showClientMetadata:d,timeDisplayFormat:a,activeTab:b,tabActions:de,onReplay:c===void 0?void 0:()=>{h(!0)}}),u&&t.jsxs("div",{className:"relative bg-black/[0.14] pt-2",onClick:Te=>Te.stopPropagation(),onKeyDown:Te=>Te.stopPropagation(),children:[t.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-12 bg-gradient-to-b from-white/[0.05] to-transparent","aria-hidden":"true"}),t.jsx(Uo,{feature:"Log details",children:t.jsxs(cp,{value:b,onValueChange:Wr,className:"gap-2",children:[t.jsxs(dp,{variant:"line",className:"bg-white/[0.04] inspector-scrollbar relative mx-3 h-auto w-[calc(100%-1.5rem)] justify-start overflow-x-auto rounded-[8px] p-1",children:[ba(s,z.rawHeaders!==void 0&&Object.keys(z.rawHeaders).length>0)&&t.jsx(Wt,{className:Zt,value:"raw-headers",children:"Raw Headers"}),va(s,z.headers!==void 0&&Object.keys(z.headers).length>0)&&t.jsx(Wt,{className:Zt,value:"headers",children:"Headers"}),J!==null&&t.jsx(Wt,{className:Zt,value:"anatomy",children:"Context"}),Ac(Me,s,o)&&t.jsx(Wt,{className:Zt,value:"raw-request",children:"Raw Request"}),t.jsx(Wt,{className:Zt,value:"request",children:"Request"}),s==="full"&&t.jsx(Wt,{className:Zt,value:"raw",children:"Raw Response"}),t.jsx(Wt,{className:Zt,value:"parsed",children:"Response"}),z.streaming===!0&&t.jsx(Wt,{className:Zt,value:"sse",children:"SSE"})]}),Ac(Me,s,o)&&t.jsx(tt,{value:"raw-request",children:b==="raw-request"&&t.jsxs(Qt,{children:[t.jsx(go,{status:A,error:$,footprint:we,onRetry:zn}),Z&&t.jsx(vo,{label:"Request",state:H,expectedBytes:e.rawRequestBodyBytes??null,onLoadMore:()=>Ct("request",H.offset)}),ce===null?t.jsx(Oo,{children:Z?"Request preview is loading":"No request body"}):ee.parsedData!==null?t.jsx(l.Suspense,{fallback:t.jsx(Gn,{}),children:t.jsx(mi,{data:ee.parsedData,bulkDepth:ee.bulkDepth,bulkRevision:ee.bulkRevision})}):t.jsx(bo,{children:ce})]})}),t.jsx(tt,{value:"request",children:b==="request"&&t.jsxs(Qt,{children:[t.jsx(go,{status:A,error:$,footprint:we,onRetry:zn}),Z&&t.jsx(vo,{label:"Request",state:H,expectedBytes:e.rawRequestBodyBytes??null,onLoadMore:()=>Ct("request",H.offset)}),ue.length>0&&t.jsxs(In,{tone:"warning",children:[t.jsxs("div",{className:"flex items-center gap-2 font-semibold text-amber-300",children:[t.jsx(cn,{className:"size-3.5"}),"Tool schema warnings"]}),t.jsx("ul",{className:"mt-2 space-y-1 text-muted-foreground",children:ue.map(Te=>t.jsx("li",{children:Te},Te))})]}),t.jsx(FS,{summary:he,calledToolNames:Je.toolNames??[]}),y?t.jsx(tN,{rawBody:z.rawRequestBody,displayedBody:De,emptyLabel:"No transformation applied; raw and sent request bodies are identical."}):t.jsx("div",{ref:pe,children:De===null?t.jsx(Oo,{children:Z?"Request preview is loading":"No request body"}):F.parsedData!==null?t.jsx(l.Suspense,{fallback:t.jsx(Gn,{}),children:t.jsx(mi,{data:F.parsedData,bulkDepth:F.bulkDepth,bulkRevision:F.bulkRevision,anatomyPaths:Xt,expandToPath:I})}):t.jsx(bo,{children:De})})]})}),J!==null&&t.jsx(tt,{value:"anatomy",children:b==="anatomy"&&t.jsx(Qt,{className:"p-0",children:t.jsx(l.Suspense,{fallback:t.jsx(Gn,{}),children:t.jsx(Z5,{parsed:F.parsedData,inputTokens:z.inputTokens??null,model:z.model,segments:J,onSegmentActivate:bn})})})}),va(s,z.headers!==void 0&&Object.keys(z.headers).length>0)&&t.jsx(tt,{value:"headers",children:b==="headers"&&t.jsxs(Qt,{children:[t.jsx("div",{className:"flex justify-end gap-2 mb-2",children:US(s,z.rawHeaders!==void 0&&Object.keys(z.rawHeaders).length>0)&&t.jsx(eN,{active:g,onClick:Te=>{Te.stopPropagation(),v(!g)}})}),g?t.jsx(nN,{rawHeaders:z.rawHeaders,headers:z.headers,emptyLabel:"No transformation applied; raw and processed headers are identical."}):t.jsx(Dc,{headers:z.headers,emptyLabel:"No headers captured"})]})}),ba(s,z.rawHeaders!==void 0&&Object.keys(z.rawHeaders).length>0)&&t.jsx(tt,{value:"raw-headers",children:b==="raw-headers"&&t.jsx(Qt,{children:t.jsx(Dc,{headers:z.rawHeaders,emptyLabel:"No raw headers captured"})})}),t.jsx(tt,{value:"raw",children:b==="raw"&&t.jsxs(Qt,{className:"space-y-3",children:[t.jsx(go,{status:A,error:$,footprint:we,onRetry:zn}),Z&&t.jsx(vo,{label:"Response",state:B,expectedBytes:e.responseTextBytes??null,onLoadMore:()=>Ct("response",B.offset)}),t.jsx(Oc,{error:z.error,onOpenSse:vs}),ae!==null&&Ue?t.jsx(l.Suspense,{fallback:t.jsx(Gn,{}),children:t.jsx(tS,{text:ae,defaultExpandDepth:0,bulkDepth:ge.bulkDepth,bulkRevision:ge.bulkRevision})}):ae!==null?t.jsx(bo,{children:ae}):t.jsx(Oo,{children:Z?"Response preview is loading":"No response"}),z.streaming===!0&&t.jsx(QS,{onOpenSse:vs})]})}),z.streaming===!0&&t.jsx(tt,{value:"sse",children:b==="sse"&&t.jsxs(Qt,{className:"space-y-3",children:[z.error!==void 0&&z.error!==null&&t.jsx(In,{tone:"danger",title:"SSE Error",children:t.jsx("span",{className:"font-mono",children:z.error})}),t.jsx(l.Suspense,{fallback:t.jsx(Gn,{}),children:t.jsx(eS,{logId:z.id,truncated:z.streamingChunksPath!==null})})]})}),t.jsx(tt,{value:"parsed",children:b==="parsed"&&t.jsxs(Qt,{children:[t.jsx(go,{status:A,error:$,footprint:we,onRetry:zn}),Z&&t.jsx(vo,{label:"Response",state:B,expectedBytes:e.responseTextBytes??null,onLoadMore:()=>Ct("response",B.offset)}),t.jsx(Oc,{error:z.error,onOpenSse:vs}),_e&&!Ue?t.jsx(bo,{children:ae}):t.jsx(l.Suspense,{fallback:t.jsx(Gn,{}),children:t.jsx(Q5,{responseText:ae,responseStatus:z.responseStatus,streaming:z.streaming,inputTokens:z.inputTokens,outputTokens:z.outputTokens,cacheCreationInputTokens:z.cacheCreationInputTokens,cacheReadInputTokens:z.cacheReadInputTokens,apiFormat:Me,focusedToolIndex:S,toolFocusNonce:C})})]})})]})})]})]}),t.jsx(Uo,{feature:"Replay",children:t.jsx(l.Suspense,{fallback:null,children:t.jsx(X5,{log:z,displayNumber:n,open:p,onOpenChange:h})})})]})});function oN(e){switch(e){case"end_turn":return"End of Turn (Anthropic)";case"stop":return"End of Turn (OpenAI)";case"length":return"End of Turn (length limit)";case"tool_use":case null:return"End of Turn"}}function ya(e){return e?"cursor-pointer transition-transform hover:scale-110":""}function rN({stopReason:e,isPending:n,isFirst:s,isTurnStart:o,isOnlyEntry:r=!1,isOpenTurnTail:a=!1,crabIndex:i=0,collapsible:c=!1,onToggle:d}){const m=Cl(e),u=r&&o&&m,f=n&&!m,p=c&&d!==void 0,h=l.useMemo(()=>kl(i),[i]),g=l.useMemo(()=>D5(i),[i]),v=w=>{!p||d===void 0||(w.stopPropagation(),d())},y=w=>{!p||d===void 0||w.key!=="Enter"&&w.key!==" "||(w.preventDefault(),d())};return t.jsxs("div",{className:"flex flex-col items-center w-6 shrink-0 pt-0.5 pb-0.5",children:[t.jsx("div",{className:"flex justify-center h-[calc(0.75rem-8px)]",children:!s&&t.jsx("div",{className:"w-px bg-muted-foreground/18 h-full"})}),u?t.jsx("span",{role:p?"button":void 0,tabIndex:p?0:void 0,title:"Single-request turn",className:ya(p),onClick:v,onKeyDown:y,children:t.jsx(g,{className:O("size-3.5 text-[#80FF00]","animate-crab-settle","drop-shadow-[0_0_4px_rgba(128,255,0,0.5)]")})}):m?t.jsx("span",{role:p?"button":void 0,tabIndex:p?0:void 0,title:oN(e),className:ya(p),onClick:v,onKeyDown:y,children:t.jsx(h,{className:O("size-3.5 text-amber-400","animate-crab-settle","drop-shadow-[0_0_4px_rgba(251,191,36,0.5)]")})}):o?t.jsx("span",{role:p?"button":void 0,tabIndex:p?0:void 0,title:"Start of turn",className:ya(p),onClick:v,onKeyDown:y,children:t.jsx(h,{className:O("size-3.5 text-emerald-400","animate-crab-appear","drop-shadow-[0_0_4px_rgba(52,211,153,0.5)]")})}):a?t.jsx("span",{title:n?"Current end of open turn (processing)":"Current end of open turn",children:t.jsx(h,{className:O("size-3.5 text-cyan-300/85",f?"animate-crab-crawl":"animate-crab-appear","drop-shadow-[0_0_4px_rgba(103,232,249,0.4)]")})}):f?t.jsx("span",{title:"Processing",children:t.jsx(h,{className:O("size-3.5 text-amber-300/80","animate-crab-crawl")})}):t.jsx("span",{title:"Request in turn",children:t.jsx(h,{className:"size-3.5 text-muted-foreground/40"})}),t.jsx("div",{className:"flex-1 flex justify-center min-h-0",children:!m&&!a&&t.jsx("div",{className:O("w-0.5 h-full",n?"border-dashed bg-transparent border-l border-muted-foreground/14":"bg-muted-foreground/18")})})]})}const zc=180,wa=new WeakMap;function aN(e,n){const s=e.responseText;if(s===null)return!1;switch(n){case"anthropic":return s.includes("tool_use");case"openai":return s.includes("tool_calls")||s.includes("function_call");case"unknown":return!1}}function iN(e){return e>1}function hi(e){const n=[];let s=[],o=0;for(let r=0;r<e.length;r+=1){const a=e[r];if(a===void 0)continue;s.push({log:a,stopReason:ap(a),sessionLogNumber:r+1});const i=s[s.length-1];i!==void 0&&Cl(i.stopReason)&&(n.push({entries:s,turnIndex:o}),s=[],o+=1)}return s.length>0&&n.push({entries:s,turnIndex:o}),n}function lN(e){const n=new Map;for(const s of e)for(let o=1;o<s.logs.length;o+=1){const r=s.logs[o],a=s.logs[o-1];if(r===void 0||a===void 0)continue;const i=Fs(r),c=Fs(a);i==="unknown"||i!==c||n.set(r.id,a)}return n}function gp(e){if(e===null)return null;try{const n=JSON.parse(e);return typeof n=="string"?JSON.parse(n):n}catch{return null}}function Do(e){if(e==null)return null;const n=typeof e=="string"?e:JSON.stringify(e);if(n===void 0)return null;const s=n.replace(/\s+/g," ").trim();return s.length===0?null:s.length>zc?`${s.slice(0,zc-1)}...`:s}function zo(e){if(e==null)return null;if(typeof e=="string")return e.length>0?e:null;const n=JSON.stringify(e,null,2);return n===void 0||n.length===0?null:n}function cN(e){const n=gp(e.responseText),s=ne(n,"content");if(!Array.isArray(s))return[];const o=[];for(const r of s){if(ne(r,"type")!=="tool_use")continue;const i=ne(r,"name");if(typeof i!="string"||i.length===0)continue;const c=ne(r,"input");o.push({id:`${String(e.id)}-anthropic-tool-${String(o.length)}`,logId:e.id,index:o.length,provider:"anthropic",name:i,argumentsText:zo(c),argumentsPreview:Do(c)})}return o}function dN(e){const n=gp(e.responseText),s=ne(n,"choices");if(!Array.isArray(s))return[];const o=[];for(const a of s){const i=ne(a,"message"),c=ne(i,"tool_calls");if(Array.isArray(c))for(const u of c){const f=ne(u,"function"),p=ne(f,"name");if(typeof p!="string"||p.length===0)continue;const h=ne(f,"arguments");o.push({id:`${String(e.id)}-openai-tool-${String(o.length)}`,logId:e.id,index:o.length,provider:"openai",name:p,argumentsText:zo(h),argumentsPreview:Do(h)})}const d=ne(i,"function_call"),m=ne(d,"name");if(typeof m=="string"&&m.length>0){const u=ne(d,"arguments");o.push({id:`${String(e.id)}-openai-tool-${String(o.length)}`,logId:e.id,index:o.length,provider:"openai",name:m,argumentsText:zo(u),argumentsPreview:Do(u)})}}const r=ne(n,"output");if(Array.isArray(r))for(const a of r){if(ne(a,"type")!=="function_call")continue;const i=ne(a,"name");if(typeof i!="string"||i.length===0)continue;const c=ne(a,"arguments");o.push({id:`${String(e.id)}-openai-tool-${String(o.length)}`,logId:e.id,index:o.length,provider:"openai",name:i,argumentsText:zo(c),argumentsPreview:Do(c)})}return o}function Tl(e){const n=wa.get(e);if(n!==void 0&&n.apiFormat===e.apiFormat&&n.responseText===e.responseText)return n.events;const s=Fs(e);if(!aN(e,s)){const r=[];return wa.set(e,{apiFormat:e.apiFormat,responseText:e.responseText,events:r}),r}let o;switch(s){case"anthropic":o=cN(e);break;case"openai":o=dN(e);break;case"unknown":o=[];break}return wa.set(e,{apiFormat:e.apiFormat,responseText:e.responseText,events:o}),o}function uN(e,n,s=0){let o=0,r=0,a=0,i=0,c=0,d=0,m=0,u=0,f=null,p=0;for(const h of e)h.responseStatus===null?r+=1:h.responseStatus>=400&&(o+=1),h.elapsedMs!==null&&n>0&&h.elapsedMs>n*1e3&&(a+=1),h.inputTokens!==null&&(i+=h.inputTokens),h.outputTokens!==null&&(c+=h.outputTokens),h.cacheCreationInputTokens!==null&&(d+=h.cacheCreationInputTokens),h.cacheReadInputTokens!==null&&(m+=h.cacheReadInputTokens),h.elapsedMs!==null&&(u+=h.elapsedMs,f=f===null?h.elapsedMs:Math.max(f,h.elapsedMs)),p+=Tl(h).length;return{llmCallCount:e.length,toolCallCount:p,failedCallCount:o,pendingCallCount:r,slowCallCount:a,totalInputTokens:i,totalOutputTokens:c,totalCacheCreationInputTokens:d,totalCacheReadInputTokens:m,totalElapsedMs:u,maxElapsedMs:f,startedAt:e[0]?.timestamp??null,endedAt:e[e.length-1]?.timestamp??null,knowledgeCandidateCount:s}}function ja(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}const mN=l.memo(function({entries:n,viewMode:s,strip:o,slowResponseThresholdSeconds:r,cacheTrends:a,onCompareWithPrevious:i,comparisonPredecessors:c,turnIndex:d=0,timeDisplayFormat:m,pendingFocusRequest:u,showLogClientMetadata:f=!0}){const p=n.length-1,h=n[p]?.stopReason??null,g=h!==null?Cl(h):!1,v=n[p]?.log.responseStatus===null,y=n.length===1,w=iN(n.length),[b,j]=l.useState(!1),S=l.useRef(!1);l.useEffect(()=>{w?g&&!S.current&&j(!0):j(!1),S.current=g},[w,g]),l.useEffect(()=>{const U=H=>{const X=Ur(H);X!==null&&n.some(B=>B.log.id===X.logId)&&w&&j(!1)};return window.addEventListener(Yt,U),()=>{window.removeEventListener(Yt,U)}},[w,n]),l.useEffect(()=>{if(u===void 0||!n.some(H=>H.log.id===u.logId))return;w&&j(!1);const U=window.setTimeout(()=>{fs({logId:u.logId,tab:u.tab,source:"virtualizer"})},0);return()=>window.clearTimeout(U)},[w,n,u]);const N=l.useCallback(()=>{w&&j(U=>!U)},[w]),C=l.useMemo(()=>{let U=0,H=0,X=null,B=!1;for(const W of n)W.log.inputTokens!==null&&(U+=W.log.inputTokens,B=!0),W.log.outputTokens!==null&&(H+=W.log.outputTokens,B=!0),W.log.elapsedMs!==null&&(X=X===null?W.log.elapsedMs:Math.max(X,W.log.elapsedMs));return{totalInput:U,totalOutput:H,hasTokens:B,maxElapsed:X}},[n,p]),R=d%2===0?"bg-white/[0.008]":"bg-cyan-300/[0.008]",I=C.maxElapsed!==null&&r>0&&C.maxElapsed>r*1e3,P=l.useMemo(()=>{const U=new Map;for(const H of n){const X=Tl(H.log);X.length>0&&U.set(H.log.id,X)}return U},[n]),[M,k]=l.useState(0),A=l.useRef(null);l.useEffect(()=>{const U=A.current;if(!U)return;let H=0;const X=new ResizeObserver(()=>{window.cancelAnimationFrame(H),H=window.requestAnimationFrame(()=>k(B=>B+1))});return X.observe(U),()=>{X.disconnect(),window.cancelAnimationFrame(H)}},[]);const D=n[0]?.log.id??d,$=`Turn ${String(d+1)}`,Y=l.useMemo(()=>kl(D%12),[D]),Q=l.useMemo(()=>({contentVisibility:"auto",containIntrinsicSize:b?"48px":"160px"}),[b]);return t.jsx("div",{ref:A,style:Q,tabIndex:b?void 0:0,role:b?void 0:"group","aria-label":b?void 0:$,"data-nav-id":b?void 0:`turn-${String(D)}`,className:O("rounded-[8px] transition-[background-color,box-shadow]",v?"bg-amber-300/[0.018] shadow-[0_0_0_1px_rgba(252,211,77,0.035)]":"",!b&&"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-none"),children:b?t.jsxs("div",{"data-nav-id":`turn-collapsed-${String(D)}`,"data-nav-action":"expand",role:"button",tabIndex:0,className:"flex items-stretch cursor-pointer focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-none rounded-lg",onClick:N,onKeyDown:U=>{(U.key==="Enter"||U.key===" ")&&(U.preventDefault(),N())},children:[t.jsxs("div",{className:"w-6 shrink-0 flex flex-col items-center pt-1.5 pb-1.5",children:[t.jsx("div",{className:"flex justify-center h-[calc(0.75rem-8px)]"}),t.jsx(Y,{className:O("size-3.5",v?"animate-crab-crawl text-amber-300/80":"animate-crab-appear text-emerald-400",v?"drop-shadow-[0_0_4px_rgba(252,211,77,0.42)]":"drop-shadow-[0_0_4px_rgba(52,211,153,0.45)]")}),t.jsx("div",{className:"flex-1 flex justify-center min-h-0",children:t.jsx("div",{className:"w-px bg-muted-foreground/14 h-full"})}),g?t.jsx(Y,{className:O("size-3.5 animate-crab-settle text-amber-400","drop-shadow-[0_0_4px_rgba(251,191,36,0.45)]")}):t.jsx("span",{title:"Current end of open turn","aria-label":"Current end of open turn",children:t.jsx(Y,{className:O("size-3.5 text-cyan-300/85",v?"animate-crab-crawl":"animate-crab-appear","drop-shadow-[0_0_4px_rgba(103,232,249,0.4)]")})})]}),n.length>1&&t.jsxs("div",{className:O("flex-1 min-w-0 mb-0.5 rounded-[8px] py-1.5 px-3 flex items-center gap-3 text-xs","bg-card/80 transition-colors hover:bg-card",R),children:[t.jsx("span",{className:"font-mono text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground/70",children:$}),t.jsxs("span",{className:"text-blue-300/85 font-mono font-semibold tabular-nums shrink-0",title:`Log IDs ${String(n[0]?.log.id??"?")} ~ ${String(n[p]?.log.id??"?")}`,children:["#",n[0]?.sessionLogNumber??"?"," ~ #",n[p]?.sessionLogNumber??"?"]}),t.jsxs("span",{className:"text-muted-foreground shrink-0",children:[n.length," request",n.length>1?"s":""]}),C.maxElapsed!==null&&t.jsx(bs,{children:t.jsxs(nt,{children:[t.jsx(st,{asChild:!0,children:t.jsxs("span",{className:O("flex items-center gap-1 shrink-0",I?"text-amber-400":"text-muted-foreground"),children:[t.jsx(Vt,{className:"size-3"}),t.jsx("span",{className:"font-mono tabular-nums",children:ja(C.maxElapsed)}),I&&t.jsx(cn,{className:"size-3","aria-label":"Slow response"})]})}),t.jsx(ot,{children:I?`Slow response: ${ja(C.maxElapsed)} exceeds ${ja(r*1e3)}`:"Slowest request in this turn"})]})}),C.hasTokens&&t.jsxs("span",{className:"flex items-center gap-1 shrink-0",children:[t.jsx(Ds,{className:"size-3 text-muted-foreground"}),t.jsxs("span",{className:"font-mono tabular-nums",children:[t.jsxs("span",{className:"text-blue-400",children:["IN ",Re(C.totalInput)]})," / ",t.jsxs("span",{className:"text-amber-400",children:["OUT ",Re(C.totalOutput)]})]})]}),t.jsx("span",{className:"flex-1 min-w-0"}),t.jsx("span",{className:"bg-white/[0.045] inline-flex size-7 shrink-0 items-center justify-center rounded-md text-text-strong","aria-hidden":"true",children:t.jsx(ct,{className:"size-4 shrink-0"})})]})]}):n.map((U,H)=>{const{log:X,stopReason:B}=U,W=H===0;return t.jsxs("div",{className:"flex items-stretch",children:[t.jsx(rN,{stopReason:B,isPending:X.responseStatus===null,isFirst:H===0,isTurnStart:W,isOnlyEntry:y,isOpenTurnTail:H===p&&!g,crabIndex:X.id%12,collapsible:w&&W,onToggle:N}),t.jsx("div",{className:O("flex-1 min-w-0 mb-0.5 rounded-[8px]",R),children:t.jsx(sN,{log:X,displayNumber:U.sessionLogNumber,viewMode:s,strip:o,slowResponseThresholdSeconds:r,timeDisplayFormat:m,cacheTrend:a?.get(X.id)??null,showClientMetadata:f,toolEvents:P.get(X.id),onCompareWithPrevious:c.has(X.id)?i:void 0})})]},X.id)})})}),fN=24,pN=132,hN=8;function xN(e){return e>fN}function gN(e){const n=new Map;for(let s=0;s<e.length;s++){const o=e[s];if(o!==void 0)for(const r of o.entries)n.set(r.log.id,s)}return n}function bp(e,n,s){return t.jsx(mN,{entries:e.entries,viewMode:n.viewMode,strip:n.strip,slowResponseThresholdSeconds:n.slowResponseThresholdSeconds,timeDisplayFormat:n.timeDisplayFormat,cacheTrends:n.cacheTrends,onCompareWithPrevious:n.onCompareWithPrevious,comparisonPredecessors:n.comparisonPredecessors,turnIndex:e.turnIndex,pendingFocusRequest:s,showLogClientMetadata:n.showLogClientMetadata},e.turnIndex)}function bN(e){return xN(e.turnGroups.length)?t.jsx(vN,{...e}):t.jsx(t.Fragment,{children:e.turnGroups.map(n=>bp(n,e))})}function vN(e){const{turnGroups:n}=e,[s,o]=l.useState(null),r=w5({count:n.length,estimateSize:()=>pN,overscan:hN,getItemKey:i=>n[i]?.turnIndex??i}),a=l.useMemo(()=>gN(n),[n]);return l.useEffect(()=>{const i=c=>{const d=Ur(c);if(d===null||d.source==="virtualizer")return;const m=a.get(d.logId);m!==void 0&&(r.scrollToIndex(m,{align:"center"}),o(u=>({...d,turnIndex:m,nonce:u===null?1:u.nonce+1})))};return window.addEventListener(Yt,i),()=>{window.removeEventListener(Yt,i)}},[a,r]),t.jsx("div",{className:"relative w-full",style:{height:`${r.getTotalSize()}px`},"data-virtualized-turn-list":"true",children:r.getVirtualItems().map(i=>{const c=n[i.index];if(c===void 0)return null;const d=s!==null&&s.turnIndex===i.index?s:void 0;return t.jsx("div",{"data-index":i.index,ref:r.measureElement,className:"absolute left-0 top-0 w-full",style:{transform:`translateY(${i.start}px)`},children:bp(c,e,d)},i.key)})})}const El=me(["episode","procedure","preference","project-fact"]),yN=me(["draft","promoted","failed"]),vp=T({source:oe("agent-inspector"),sessionId:x(),logIds:V(It),project:x().nullable(),models:V(x())}),wN=T({redacted:ke(),patterns:V(x())}),no=T({id:x(),type:El,title:x(),content:x(),tags:V(x()),source:oe("agent-inspector"),sessionId:x(),logIds:V(It),evidence:vp,status:yN,createdAt:x(),updatedAt:x(),openClawMemoryId:x().nullable(),error:x().nullable(),redaction:wN});T({idempotencyKey:x(),type:El,title:x(),content:x(),tags:V(x()),source:oe("agent-inspector"),project:x().nullable(),evidence:vp});const jN=T({id:x(),type:El.or(x()),title:x(),content:x(),score:E().nullable(),source:x().nullable(),project:x().nullable(),evidence:Ms().optional()});T({results:V(jN),warning:x().nullable()});const SN=T({candidates:V(no)}),NN=T({candidate:no}),CN=T({error:x().optional(),candidate:no.optional()}),kN=T({candidate:no}),_N=3e4,TN=15e3,EN=15e3,RN={draft:"border-amber-500/30 bg-amber-500/10 text-amber-500",promoted:"border-emerald-500/30 bg-emerald-500/10 text-emerald-500",failed:"border-destructive/30 bg-destructive/10 text-destructive"};function xi(e){return e===null?"-":e<1e3?`${String(e)}ms`:`${(e/1e3).toFixed(1)}s`}function MN(e,n,s){return e===null||n===null?null:br(e,n,s)}function AN(e){return`${String(e)} candidate${e===1?"":"s"}`}function yp(e){return`log-${String(e)}`}function wp(e){const n=yp(e),s=document.getElementById(n);window.history.replaceState(null,"",`#${n}`),s instanceof HTMLElement&&(s.scrollIntoView({block:"center",behavior:"smooth"}),s.focus({preventScroll:!0}))}function IN(e){for(const n of e)if(n.responseStatus!==null&&n.responseStatus>=400)return n;return null}function PN(e){let n=null,s=-1;for(const o of e)o.elapsedMs!==null&&o.elapsedMs>s&&(n=o,s=o.elapsedMs);return n}function LN(e){for(const n of e)if(Tl(n).length>0)return n;return null}function ON(e){const n=new Map;for(let s=0;s<e.length;s+=1){const o=e[s];o!==void 0&&n.set(o.id,s+1)}return n}function os(e,n){return String(n.get(e)??e)}function DN(e){const n=[{kind:"session",title:`${String(e.summary.llmCallCount)} LLM call${e.summary.llmCallCount===1?"":"s"}`,detail:`Scope ${e.scopeId}`,logId:e.logs[0]?.id??null}],s=LN(e.logs);e.summary.toolCallCount>0&&s!==null&&n.push({kind:"tool",title:`${String(e.summary.toolCallCount)} tool call${e.summary.toolCallCount===1?"":"s"}`,detail:`First tool evidence at #${os(s.id,e.displayNumberByLogId)}`,logId:s.id});const o=IN(e.logs);o!==null&&n.push({kind:"failure",title:`Failure #${String(o.responseStatus)}`,detail:`First failed request is #${os(o.id,e.displayNumberByLogId)}`,logId:o.id});const r=PN(e.logs);if(r!==null&&e.summary.maxElapsedMs!==null&&n.push({kind:"slow",title:`Slowest ${xi(e.summary.maxElapsedMs)}`,detail:`Max latency observed at #${os(r.id,e.displayNumberByLogId)}`,logId:r.id}),e.candidates.length>0){const a=e.candidates.filter(c=>c.status==="draft").length,i=e.candidates.filter(c=>c.status==="promoted").length;n.push({kind:"candidate",title:`${String(e.candidates.length)} memory candidate${e.candidates.length===1?"":"s"}`,detail:`${String(a)} draft / ${String(i)} promoted`,logId:e.candidates[0]?.logIds[0]??null})}return n}function zN(e){switch(e){case"session":return t.jsx(gr,{className:"size-3.5 text-blue-400"});case"tool":return t.jsx(Ys,{className:"size-3.5 text-sky-400/70"});case"slow":return t.jsx(Vt,{className:"size-3.5 text-amber-400"});case"failure":return t.jsx(uu,{className:"size-3.5 text-destructive"});case"candidate":return t.jsx(du,{className:"size-3.5 text-emerald-400"})}}function $N({insights:e}){return e.length===0?null:t.jsx("div",{className:"mt-2 grid gap-1.5 border-t border-border/70 pt-2 md:grid-cols-2 xl:grid-cols-3",children:e.map(n=>t.jsxs("button",{type:"button",className:O("flex min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs","text-muted-foreground transition-colors hover:bg-muted/40 hover:text-foreground","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),onClick:()=>{n.logId!==null&&wp(n.logId)},disabled:n.logId===null,children:[zN(n.kind),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block truncate font-medium text-foreground/90",children:n.title}),t.jsx("span",{className:"block truncate font-mono text-[10px]",children:n.detail})]})]},`${n.kind}-${n.title}`))})}function FN(e){switch(e){case"draft":return"Draft";case"promoted":return"Promoted";case"failed":return"Failed"}}function UN(e,n){if(n)return"Promoting";switch(e.status){case"draft":return"Promote";case"failed":return"Retry";case"promoted":return"Promoted"}}function BN(e){return e.redaction.redacted?`Redacted ${e.redaction.patterns.join(", ")}`:"No sensitive pattern matched"}function qN(e,n){const s=e.replace(/\s+/g," ").trim();return s.length<=n?s:`${s.slice(0,n-3)}...`}function HN(e,n){const s=e[0],o=e[e.length-1];if(s===void 0)return"No evidence logs";const r=os(s,n);return o===void 0||s===o?`#${r}`:`#${r}-#${os(o,n)}`}function $c(e){return e.join(", ")}function WN(e){return e.split(",").map(n=>n.trim()).filter(n=>n.length>0)}function VN({candidate:e,isPromoting:n,isUpdating:s,onPromoteCandidate:o,onUpdateCandidate:r,displayNumberByLogId:a}){const[i,c]=l.useState(!1),[d,m]=l.useState(e.type),[u,f]=l.useState(e.title),[p,h]=l.useState(e.content),[g,v]=l.useState($c(e.tags)),[y,w]=l.useState(null),b=e.status!=="promoted",j=e.status!=="promoted",S=l.useCallback(()=>{m(e.type),f(e.title),h(e.content),v($c(e.tags)),w(null)},[e.content,e.tags,e.title,e.type]),N=l.useCallback(async()=>{const C=u.trim(),R=p.trim(),I=WN(g);if(C.length===0){w("Title is required.");return}if(R.length===0){w("Content is required.");return}if(I.length===0){w("At least one tag is required.");return}w(null),await r(e.id,{type:d,title:C,content:R,tags:I})&&c(!1)},[e.id,p,g,u,d,r]);return i?t.jsx("div",{className:"border border-border bg-card shadow-sm rounded-[8px] px-2.5 py-2",children:t.jsxs("div",{className:"grid gap-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("select",{value:d,disabled:s,onChange:C=>{const R=no.shape.type.safeParse(C.currentTarget.value);R.success&&m(R.data)},className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground h-7 rounded-md px-2 text-xs","aria-label":"Candidate type",children:[t.jsx("option",{value:"episode",children:"episode"}),t.jsx("option",{value:"procedure",children:"procedure"}),t.jsx("option",{value:"preference",children:"preference"}),t.jsx("option",{value:"project-fact",children:"project-fact"})]}),t.jsx("input",{value:u,disabled:s,onChange:C=>f(C.currentTarget.value),className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground h-7 min-w-[220px] flex-1 rounded-md px-2 text-xs","aria-label":"Candidate title"})]}),t.jsx("textarea",{value:p,disabled:s,onChange:C=>h(C.currentTarget.value),className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground min-h-28 rounded-md px-2 py-1.5 font-mono text-[11px] leading-relaxed","aria-label":"Candidate content"}),t.jsx("input",{value:g,disabled:s,onChange:C=>v(C.currentTarget.value),className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground h-7 rounded-md px-2 text-xs","aria-label":"Candidate tags"}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-muted-foreground",children:[t.jsx(Kl,{className:"size-3"}),"Saving reruns Inspector redaction before promotion."]}),t.jsx("span",{className:"flex-1"}),y!==null&&t.jsx("span",{className:"text-[10px] text-destructive",children:y}),t.jsxs(te,{type:"button",variant:"ghost",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:s,onClick:()=>{S(),c(!1)},children:[t.jsx(Js,{className:"size-3.5"}),"Cancel"]}),t.jsxs(te,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:s,onClick:()=>{N()},children:[s?t.jsx(yt,{className:"size-3.5 animate-spin"}):t.jsx(Jg,{className:"size-3.5"}),"Save"]})]})]})}):t.jsxs("div",{className:"rounded-md border border-border/80 bg-background/60 px-2.5 py-2",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Ce,{variant:"outline",className:"h-5 px-1.5 text-[10px] font-mono",children:e.type}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium",title:e.title,children:e.title}),t.jsx(Ce,{variant:"outline",className:O("h-5 shrink-0 px-1.5 text-[10px] font-mono",RN[e.status]),children:FN(e.status)})]}),t.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",title:e.content,children:qN(e.content,360)}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] text-muted-foreground",children:[t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(X0,{className:"size-3"}),HN(e.logIds,a)]}),t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(Kl,{className:"size-3"}),BN(e)]}),e.status==="promoted"&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-emerald-500",children:[t.jsx(Ha,{className:"size-3"}),e.openClawMemoryId??"OpenClaw"]}),e.status==="failed"&&e.error!==null&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-destructive",children:[t.jsx(uu,{className:"size-3"}),e.error]})]}),t.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5",children:[e.logIds.map(C=>{const R=os(C,a);return t.jsxs("a",{href:`#${yp(C)}`,onClick:I=>{I.preventDefault(),wp(C)},className:"rounded border border-blue-400/25 px-1.5 py-0.5 font-mono text-[10px] text-blue-400 underline-offset-2 transition-colors hover:bg-blue-400/10 hover:text-blue-300 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":`Jump to evidence log ${R}`,title:`Log ID ${String(C)}`,children:["#",R]},C)}),t.jsx("span",{className:"flex-1"}),j&&t.jsxs(te,{type:"button",variant:"ghost",size:"sm",className:"h-6 gap-1.5 px-2 text-[10px]",disabled:s||n,onClick:()=>c(!0),children:[t.jsx(bu,{className:"size-3"}),"Review"]}),t.jsxs(te,{type:"button",variant:b?"outline":"ghost",size:"sm",className:"h-6 gap-1.5 px-2 text-[10px]",onClick:()=>o(e.id),disabled:!b||n||s,children:[n?t.jsx(yt,{className:"size-3 animate-spin"}):b?t.jsx(A0,{className:"size-3"}):t.jsx(Ha,{className:"size-3"}),UN(e,n)]})]})]})}function KN({candidates:e,promotingCandidateIds:n,updatingCandidateIds:s,onPromoteCandidate:o,onUpdateCandidate:r,displayNumberByLogId:a}){return e.length===0?null:t.jsx("div",{className:"mt-2 grid gap-1.5",children:e.map(i=>t.jsx(VN,{candidate:i,isPromoting:n.has(i.id),isUpdating:s.has(i.id),onPromoteCandidate:o,onUpdateCandidate:r,displayNumberByLogId:a},i.id))})}function GN({logs:e,scopeId:n,slowResponseThresholdSeconds:s,showRollupMetrics:o,timeDisplayFormat:r}){const[a,i]=l.useState([]),[c,d]=l.useState(!0),[m,u]=l.useState({status:"idle",error:null}),[f,p]=l.useState(()=>new Set),[h,g]=l.useState(()=>new Set),v=a.length>0,y=l.useMemo(()=>uN(e,s,a.length),[a.length,e,s]),w=l.useMemo(()=>ON(e),[e]),b=l.useMemo(()=>DN({logs:e,scopeId:n,summary:y,candidates:a,displayNumberByLogId:w}),[a,w,e,n,y]),j=o||y.maxElapsedMs!==null,S=l.useMemo(()=>MN(y.startedAt,y.endedAt,r),[y.endedAt,y.startedAt,r]),N=l.useCallback(()=>{e.length===0||m.status==="loading"||(u({status:"loading",error:null}),(async()=>{try{const I=await Le(`/api/knowledge/sessions/${encodeURIComponent(n)}/candidates`,SN,_N,{method:"POST"},P=>`Candidate generation failed with ${String(P.status)}`);i(I.candidates),d(I.candidates.length>0),u(I.candidates.length>0?{status:"ready",error:null}:{status:"failed",error:"No candidate was generated for this trace scope."})}catch(I){u({status:"failed",error:I instanceof Error?I.message:"Candidate response was invalid"})}})())},[m.status,e.length,n]),C=l.useCallback(I=>{p(P=>{if(P.has(I))return P;const M=new Set(P);return M.add(I),M}),(async()=>{try{const P=await _n(`/api/knowledge/candidates/${encodeURIComponent(I)}/promote`,TN,{method:"POST"}),M=await P.json().catch(()=>null),k=NN.safeParse(M);if(P.ok&&k.success){i(D=>D.map($=>$.id===k.data.candidate.id?k.data.candidate:$)),u({status:"ready",error:null});return}const A=CN.safeParse(M);A.success&&A.data.candidate!==void 0&&i(D=>D.map($=>$.id===A.data.candidate?.id?A.data.candidate:$)),u({status:"failed",error:A.success?A.data.error??"Candidate promotion failed":`Candidate promotion failed with ${String(P.status)}`})}catch(P){u({status:"failed",error:P instanceof Error?P.message:"Candidate promotion failed"})}finally{p(P=>{const M=new Set(P);return M.delete(I),M})}})()},[]),R=l.useCallback(async(I,P)=>{g(M=>{if(M.has(I))return M;const k=new Set(M);return k.add(I),k});try{const M=await Le(`/api/knowledge/candidates/${encodeURIComponent(I)}`,kN,EN,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(P)},k=>`Candidate update failed with ${String(k.status)}`);return i(k=>k.map(A=>A.id===M.candidate.id?M.candidate:A)),u({status:"ready",error:null}),!0}catch(M){return u({status:"failed",error:M instanceof Error?M.message:"Candidate update failed"}),!1}finally{g(M=>{const k=new Set(M);return k.delete(I),k})}},[]);return e.length===0?null:t.jsxs("section",{className:"border border-border bg-card shadow-sm mb-2 rounded-[8px] px-3 py-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 text-xs",children:[o&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 font-semibold text-foreground",children:[t.jsx(gr,{className:"size-3.5 text-blue-400"}),y.llmCallCount," LLM"]}),t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(Ys,{className:"size-3.5 text-sky-400/70"}),y.toolCallCount," tools"]}),o&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(Ds,{className:"size-3.5 text-emerald-400"}),t.jsxs("span",{className:"font-mono",children:[Re(y.totalInputTokens)," / ",Re(y.totalOutputTokens)]})]}),(y.totalCacheCreationInputTokens>0||y.totalCacheReadInputTokens>0)&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(Ds,{className:"size-3.5 text-purple-400"}),t.jsxs("span",{className:"font-mono",children:["KV Cache +",Re(y.totalCacheCreationInputTokens)," / ~",Re(y.totalCacheReadInputTokens)]})]}),j&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(Vt,{className:"size-3.5"}),o&&t.jsx("span",{className:"font-mono",children:xi(y.totalElapsedMs)}),y.maxElapsedMs!==null&&t.jsxs("span",{className:"font-mono text-muted-foreground/70",children:["max ",xi(y.maxElapsedMs)]})]}),o&&S!==null&&t.jsx("span",{className:"font-mono text-muted-foreground/70",children:S}),(y.failedCallCount>0||y.pendingCallCount>0||y.slowCallCount>0)&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-amber-400",children:[t.jsx(cn,{className:"size-3.5"}),t.jsxs("span",{className:"font-mono",children:[y.failedCallCount," fail / ",y.pendingCallCount," pending /"," ",y.slowCallCount," slow"]})]}),t.jsx("span",{className:"flex-1"}),v&&t.jsx(Ce,{variant:"outline",className:"h-6 px-2 text-[10px] font-mono",children:AN(y.knowledgeCandidateCount)}),t.jsxs(te,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",onClick:N,disabled:m.status==="loading",children:[m.status==="loading"?t.jsx(Ae,{className:"size-3.5 animate-spin"}):t.jsx(du,{className:"size-3.5"}),"Candidate"]}),v&&t.jsx(te,{type:"button",variant:"ghost",size:"icon",className:"size-7 text-muted-foreground",onClick:()=>d(I=>!I),"aria-expanded":c,"aria-label":c?"Collapse memory candidates":"Expand memory candidates",children:c?t.jsx(We,{className:"size-3.5"}):t.jsx(ct,{className:"size-3.5"})})]}),m.status==="failed"&&t.jsx("p",{className:"mt-2 text-xs text-destructive",children:m.error}),t.jsx($N,{insights:b}),c&&t.jsx(KN,{candidates:a,promotingCandidateIds:f,updatingCandidateIds:h,onPromoteCandidate:C,onUpdateCandidate:R,displayNumberByLogId:w})]})}function YN(e){let n=0,s=0;for(const o of e)o.inputTokens!==null&&(n+=o.inputTokens),o.outputTokens!==null&&(s+=o.outputTokens);return{totalInputTokens:n,totalOutputTokens:s}}function JN(e){const n=new Map;for(const s of e){if(s.model===null)continue;const o=vj(s.model);if(o==="unknown")continue;let r=n.get(o);r===void 0&&(r=new Set,n.set(o,r)),r.add(s.model)}return[...n.entries()].map(([s,o])=>({provider:s,models:[...o]}))}function XN(e){for(const n of e){const s=n.clientPid;if(s!=null)return s}return null}function ZN(e){for(const n of e){const s=n.clientProjectFolder;if(s!=null&&s!=="")return s}return null}const QN=l.memo(function({group:e,viewMode:n="simple",strip:s,slowResponseThresholdSeconds:o,cacheTrends:r,onCompareWithPrevious:a,comparisonPredecessors:i,onClearGroup:c,showClientIdentity:d=!0,showProcessMetadata:m=!0,showLogClientMetadata:u=!0,defaultExpanded:f=!1,timeDisplayFormat:p,expanded:h,onExpandedChange:g}){const[v,y]=l.useState(f),w=h??v,b=l.useCallback(k=>{if(g!==void 0){g(k);return}y(k)},[g]);l.useEffect(()=>{!f||h!==void 0||y(!0)},[h,f]);const j=l.useMemo(()=>YN(e.logs),[e.logs]),S=l.useMemo(()=>JN(e.logs),[e.logs]),N=e.logs[0]?.timestamp??new Date().toISOString(),C=e.logs[e.logs.length-1]?.timestamp??new Date().toISOString(),R=e.logs.some(k=>k.responseStatus===null),I=l.useMemo(()=>XN(e.logs),[e.logs]),P=l.useMemo(()=>ZN(e.logs),[e.logs]),M=l.useMemo(()=>hi(e.logs),[e.logs]);return l.useEffect(()=>{const k=A=>{const D=Ur(A);D!==null&&e.logs.some($=>$.id===D.logId)&&b(!0)};return window.addEventListener(Yt,k),()=>{window.removeEventListener(Yt,k)}},[e.logs,b]),t.jsxs("div",{className:"mb-1.5",children:[t.jsx(t5,{conversationId:e.conversationId,startTime:N,endTime:C,totalCalls:e.logs.length,totalInputTokens:j.totalInputTokens,totalOutputTokens:j.totalOutputTokens,expanded:w,onToggle:()=>b(!w),providers:S,isLoading:R,userAgent:e.logs[0]?.userAgent??null,clientPid:I,clientProjectFolder:P,showClientIdentity:d,showProcessMetadata:m,timeDisplayFormat:p,onClear:()=>c(e.logs.map(k=>k.id))}),w&&t.jsxs("div",{children:[t.jsx(GN,{logs:e.logs,scopeId:e.conversationId,slowResponseThresholdSeconds:o,showRollupMetrics:!1,timeDisplayFormat:p}),t.jsx(bN,{turnGroups:M,viewMode:n,strip:s,slowResponseThresholdSeconds:o,timeDisplayFormat:p,cacheTrends:r,onCompareWithPrevious:a,comparisonPredecessors:i,showLogClientMetadata:u})]})]})}),eC="flex w-full min-w-0 items-center gap-2 rounded-md border border-border/70 bg-muted/35 px-3 py-2 sm:w-auto sm:max-w-full",tC="m-0 min-w-0 flex-1 overflow-x-auto font-mono text-xs text-foreground sm:text-sm";function nC(e){return[`PROXY_BASE_URL=${e.proxy}`,`MCP_URL=${e.mcp}`]}function sC(e){return e==="full"}function oC(e){return e==="raw"}function rC(e,n){const s=n>0;return{redacted:s,raw:s&&sC(e)}}function aC(e,n){const s=e[0],o=e[e.length-1];return s===void 0||o===void 0?null:br(s.timestamp,o.timestamp,n)}function iC(e){return e.error!==null&&e.error!==void 0&&e.error.length>0?!0:e.responseStatus!==null&&e.responseStatus>=400}function lC(e){const n=new Set;for(const o of e)o.model!==null&&o.model.length>0&&n.add(o.model);const s=[...n].sort();return s.length===0?"Model unknown":s.length===1?s[0]??"Model unknown":`${s.length} models`}function cC(e){const n=new Set;for(const o of e)o.providerName!==null&&o.providerName!==void 0&&o.providerName.length>0&&n.add(o.providerName);const s=[...n].sort();return s.length===0?"Provider unknown":s.length===1?s[0]??"Provider unknown":`${s.length} providers`}function dC(e){if(e<1e3)return`${e}ms`;if(e<6e4){const r=e/1e3;return`${r<10?r.toFixed(1):r.toFixed(0)}s`}const n=Math.round(e/1e3),s=Math.floor(n/60),o=n%60;return`${s}m ${o}s`}function uC(e,n){return`${Re(e)} in / ${Re(n)} out`}function mC(e,n){if(e.length===0)return 0;if(n.length===0)return hi(e).length;let s=0;for(const o of n)s+=hi(o.logs).length;return s}function fC({stopReason:e,pending:n,lastFailureLogNumber:s}){if(n>0)return{label:"In flight",detail:`${n} request${n===1?"":"s"} pending`,tone:"cool"};if(s!==null&&e===null)return{label:"Error",detail:`Last failed request #${s}`,tone:"danger"};switch(e){case"end_turn":return{label:"End turn",detail:"Assistant completed the turn",tone:"neutral"};case"stop":return{label:"Stop",detail:"Model reached a stop condition",tone:"neutral"};case"length":return{label:"Output limit",detail:"Turn ended at max output tokens",tone:"watch"};case"tool_use":return{label:"Tool call",detail:"Assistant requested a tool",tone:"cool"};case null:return{label:"Unknown",detail:"No finish reason captured",tone:"neutral"}}}function pC(e){if(e===null)return!1;const n=e.toLowerCase();return n.includes("abort")||n.includes("cancel")||n.includes("client disconnected")||n.includes("stream disconnected")||n.includes("connection closed")}function hC({pending:e,failures:n,lengthStops:s,stopReason:o,lastFailure:r}){if(r!==null&&(r.status===499||pC(r.error)))return{label:"Client aborted",detail:`Request #${r.logNumber} ended before completion`,tone:"watch"};if(e>0)return{label:"In flight",detail:`${e} request${e===1?"":"s"} still running`,tone:"cool"};if(r!==null&&r.status!==null&&r.status>=500)return{label:"Provider error",detail:`Request #${r.logNumber} returned HTTP ${r.status}`,tone:"danger"};if(n>0&&r!==null)return{label:"Failed",detail:`Request #${r.logNumber} needs attention`,tone:"danger"};if(s>0||o==="length")return{label:"Output limited",detail:"Model stopped at the output token limit",tone:"watch"};switch(o){case"end_turn":case"stop":return{label:"Completed",detail:"Assistant completed normally",tone:"neutral"};case"tool_use":return{label:"Tool requested",detail:"Assistant handed off to a tool",tone:"cool"};case null:return{label:"Unknown",detail:"No terminal signal captured",tone:"neutral"}}}function xC({logs:e,conversationGroups:n,isLoading:s,timeDisplayFormat:o,slowResponseThresholdSeconds:r}){let a=0,i=0,c=0,d=0,m=0,u=0,f=null,p=null,h=null,g=null,v=null,y=0,w=0,b=0,j=null;const S=r*1e3;for(let P=0;P<e.length;P+=1){const M=e[P];if(M===void 0)continue;const k=P+1,A=ap(M);A!==null&&(f=A),A==="length"&&(d+=1),iC(M)&&(a+=1,p=k,h={logNumber:k,status:M.responseStatus,error:M.error??null}),M.responseStatus===null&&(i+=1),r>0&&M.elapsedMs!==null&&M.elapsedMs>=S&&(c+=1),M.inputTokens!==null&&(m+=M.inputTokens),M.outputTokens!==null&&(u+=M.outputTokens),M.elapsedMs!==null&&(g===null||M.elapsedMs>g)&&(g=M.elapsedMs,v=k);const D=M.inputTokens??0,$=M.outputTokens??0,Y=D+$;Y>y&&(y=Y,w=D,b=$,j=k)}const N=s||i>0&&a===0?"rolling":a>0?"failed":c>0||d>0?"watch":"clear",C=N==="rolling"?"Rolling":N==="failed"?"Failure":N==="watch"?"Watch":"Clear",R=fC({stopReason:f,pending:i,lastFailureLogNumber:p}),I=hC({pending:i,failures:a,lengthStops:d,stopReason:f,lastFailure:h});return{status:N,statusLabel:C,modelLabel:lC(e),providerLabel:cC(e),requests:e.length,turns:mC(e,n),failures:a,pending:i,slow:c,lengthStops:d,timeRange:aC(e,o),tokenLabel:`${Re(m)} in / ${Re(u)} out`,finishLabel:R.label,finishDetail:R.detail,finishTone:R.tone,outcomeLabel:I.label,outcomeDetail:I.detail,outcomeTone:I.tone,slowestLabel:g===null?"n/a":dC(g),slowestDetail:v===null?"Latency pending":`Request #${v}`,heaviestDetail:j===null?"Tokens pending":`#${j} ${uC(w,b)}`}}function gC({pinnedSessionId:e,selectedSession:n,sessions:s,logs:o}){if(e!==void 0){const i=o.filter(c=>c.sessionId===e);return i.length===0?null:{label:e,logs:i,showBackLink:!0}}if(n!=="__all__"){const i=o.filter(c=>c.sessionId===n);return i.length===0?null:{label:n,logs:i,showBackLink:!0}}const r=s.length===1?s[0]??null:null;return r!==null&&o.every(c=>c.sessionId===r)?{label:r,logs:[...o],showBackLink:!1}:s.length===0&&o.length>0&&o.every(i=>i.sessionId===null)?{label:"Visible requests",logs:[...o],showBackLink:!1}:null}function bC({logs:e,pagination:n}){if(n.isLoading&&e.length===0)return"Loading logs...";if(e.length===0)return"No logs on this page";const s=e[0],o=e[e.length-1],r=s===void 0||o===void 0?"Current page":`#${s.id}-#${o.id}`;return n.total===null?`Showing ${e.length} logs (${r})`:n.total<=e.length?`Showing all ${n.total} logs`:`Showing ${e.length} of ${n.total} logs (${r})`}function Bs({...e}){return t.jsx(Qm,{"data-slot":"select",...e})}function ar({...e}){return t.jsx(sf,{"data-slot":"select-value",...e})}function qs({className:e,size:n="default",children:s,...o}){return t.jsxs(tf,{"data-slot":"select-trigger","data-size":n,className:O("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...o,children:[s,t.jsx(of,{asChild:!0,children:t.jsx(We,{className:"size-4 opacity-50"})})]})}function Hs({className:e,children:n,position:s="popper",align:o="center",...r}){return t.jsx(af,{children:t.jsxs(lf,{"data-slot":"select-content",className:O("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 motion-reduce:data-[state=open]:animate-none motion-reduce:data-[state=closed]:animate-none relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",s==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:s,align:o,...r,children:[t.jsx(vC,{}),t.jsx(ff,{className:O("p-1",s==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:n}),t.jsx(yC,{})]})})}function Ze({className:e,children:n,...s}){return t.jsxs(gf,{"data-slot":"select-item",className:O("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...s,children:[t.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:t.jsx(yf,{children:t.jsx(Pe,{className:"size-4"})})}),t.jsx(bf,{children:n})]})}function vC({className:e,...n}){return t.jsx(wf,{"data-slot":"select-scroll-up-button",className:O("flex cursor-default items-center justify-center py-1",e),...n,children:t.jsx(Ui,{className:"size-4"})})}function yC({className:e,...n}){return t.jsx(jf,{"data-slot":"select-scroll-down-button",className:O("flex cursor-default items-center justify-center py-1",e),...n,children:t.jsx(We,{className:"size-4"})})}const wC=me(["critical","warning","notice"]),jC=me(["open"]),SC=me(["proxy","tool-schema","run","group"]),jp=me(["request-failure","request-timeout","slow-response","tool-schema","run-failure","group-failure","group-incomplete"]),NC=me(["log","session","run","group"]),CC=me(["anthropic","openai","unknown"]),kC=T({kind:NC,id:x(),label:x(),href:x().nullable()}),_C=T({id:x(),fingerprint:x(),severity:wC,category:jp,source:SC,status:jC,title:x(),message:x(),count:E().int().positive(),firstSeenAt:x(),lastSeenAt:x(),logIds:V(It),sessionIds:V(x()),runIds:V(x()),groupIds:V(x()),provider:x().nullable(),model:x().nullable(),apiFormat:CC.nullable(),evidence:V(kC),metadata:Oe(x(),He)}),TC=T({category:jp,count:E().int().nonnegative()}),Sp=T({total:E().int().nonnegative(),open:E().int().nonnegative(),critical:E().int().nonnegative(),warning:E().int().nonnegative(),notice:E().int().nonnegative(),byCategory:V(TC)}),EC=T({alerts:V(_C),total:E().int().nonnegative(),limit:E().int().positive(),summary:Sp}),RC=8e3,MC=1e4;function AC(e){const n=new URLSearchParams;e.severity!==void 0&&n.set("severity",e.severity),e.category!==void 0&&n.set("category",e.category),e.source!==void 0&&n.set("source",e.source),e.limit!==void 0&&n.set("limit",String(e.limit));const s=n.toString();return s.length>0?`/api/alerts?${s}`:"/api/alerts"}function IC(e,n){const s=Rt(n?AC(e):null,o=>Le(o,EC,MC));return{alerts:s.data?.alerts??[],total:s.data?.total??0,summary:s.data?.summary??null,isLoading:s.isLoading,error:s.error,mutate:s.mutate}}function PC(){const e=Rt("/api/alerts/summary",n=>Le(n,Sp,RC),{refreshInterval:5e3,revalidateOnFocus:!0});return{summary:e.data??null,isLoading:e.isLoading,error:e.error,mutate:e.mutate}}const so="relative size-9 rounded-md border border-border/70 bg-muted/60 text-muted-foreground transition-colors hover:bg-muted hover:text-accent-foreground focus-visible:ring-ring/50 max-lg:size-11",LC=["request-failure","request-timeout","slow-response","tool-schema","run-failure","group-failure","group-incomplete"];function Np(e){switch(e){case"critical":return"Critical";case"warning":return"Warning";case"notice":return"Notice"}}function OC(e){switch(e){case"proxy":return"Proxy";case"tool-schema":return"Tool schema";case"run":return"Run";case"group":return"Group"}}function Rl(e){switch(e){case"request-failure":return"Request failure";case"request-timeout":return"Timeout";case"slow-response":return"Slow response";case"tool-schema":return"Tool calling";case"run-failure":return"Run failure";case"group-failure":return"Group failure";case"group-incomplete":return"Group incomplete"}}function DC(e){switch(e){case"critical":return"border-status-danger/40 bg-status-danger/10 text-status-danger";case"warning":return"border-status-watch/40 bg-status-watch/10 text-status-watch";case"notice":return"border-status-cool/40 bg-status-cool/10 text-status-cool"}}function zC(e){switch(e){case"critical":return"bg-status-danger";case"warning":return"bg-status-watch";case"notice":return"bg-status-cool"}}function $C(e){switch(e){case"critical":return"text-status-danger";case"warning":return"text-status-watch";case"notice":return"text-status-cool"}}function FC(e){switch(e){case"request-failure":case"run-failure":case"group-failure":return t.jsx(l1,{className:"size-3.5"});case"request-timeout":case"slow-response":return t.jsx(E0,{className:"size-3.5"});case"tool-schema":return t.jsx(cn,{className:"size-3.5"});case"group-incomplete":return t.jsx(Zx,{className:"size-3.5"})}}function gi(e){const n=Date.parse(e);return Number.isFinite(n)?new Intl.DateTimeFormat(void 0,{month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(n)):e}function it(e){return e.toLocaleString()}function Cp(e){return e.provider!==null&&e.model!==null?`${e.provider} / ${e.model}`:e.provider!==null?e.provider:e.model!==null?e.model:"Unknown target"}function UC(e,n){const s={limit:100};return e!=="all"&&(s.severity=e),n!=="all"&&(s.category=n),s}function BC(e,n){if(n!==null){const s=e.find(o=>o.id===n);if(s!==void 0)return s}return e[0]??null}function yo({label:e,count:n,tone:s}){const o=s==="critical"?"border-status-danger/30 bg-status-danger/10 text-status-danger":s==="warning"?"border-status-watch/30 bg-status-watch/10 text-status-watch":s==="notice"?"border-status-cool/30 bg-status-cool/10 text-status-cool":"border-border bg-muted/40 text-foreground";return t.jsxs("div",{className:O("rounded-md border px-3 py-2",o),children:[t.jsx("div",{className:"text-[10px] font-semibold uppercase opacity-75",children:e}),t.jsx("div",{className:"mt-1 text-lg font-semibold leading-none",children:it(n)})]})}function wo({value:e,active:n,label:s,count:o,onClick:r}){return t.jsxs(te,{type:"button",variant:n?"secondary":"ghost",size:"sm","aria-pressed":n,onClick:()=>r(e),className:"h-7 px-2",children:[s,o!==null?t.jsx(Ce,{variant:"outline",children:it(o)}):null]})}function qC({category:e,active:n,count:s,onClick:o}){return t.jsxs(te,{type:"button",variant:n?"secondary":"ghost",size:"sm","aria-pressed":n,onClick:()=>o(e),className:"h-7 px-2",children:[FC(e),Rl(e),t.jsx(Ce,{variant:"outline",children:it(s)})]})}function HC({alerts:e,selectedAlertId:n,isLoading:s,error:o,onSelect:r}){return s?t.jsxs("div",{className:"flex min-h-56 items-center justify-center rounded-md border border-dashed border-border text-xs text-muted-foreground",children:[t.jsx(Ae,{className:"mr-2 size-3.5 animate-spin"}),"Loading alerts..."]}):o!==void 0?t.jsx("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-2 text-xs text-status-danger",children:o.message}):e.length===0?t.jsx("div",{className:"flex min-h-56 items-center justify-center rounded-md border border-dashed border-border px-4 text-center text-xs text-muted-foreground",children:"No alerts match the current filters."}):t.jsx("div",{className:"min-h-0 space-y-2 overflow-y-auto pr-1",children:e.map(a=>{const i=a.id===n;return t.jsxs("button",{type:"button",onClick:()=>r(a.id),className:O("w-full rounded-md border px-3 py-3 text-left transition-colors",i?"border-primary/60 bg-primary/12":"border-border bg-background/70 hover:border-primary/30 hover:bg-muted/60"),children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:O("size-2 rounded-full",zC(a.severity))}),t.jsx("span",{className:O("text-xs font-semibold",$C(a.severity)),children:Np(a.severity)}),t.jsx("span",{className:"truncate text-xs text-muted-foreground",children:Rl(a.category)})]}),t.jsx("div",{className:"mt-1 text-sm font-semibold leading-snug",children:a.title}),t.jsx("div",{className:"mt-1 line-clamp-2 text-xs text-muted-foreground",children:a.message})]}),a.count>1?t.jsxs(Ce,{variant:"outline",className:"shrink-0",children:["x",it(a.count)]}):null]}),t.jsxs("div",{className:"mt-2 flex min-w-0 items-start justify-between gap-2 text-[11px] text-muted-foreground",children:[t.jsx("span",{className:"min-w-0 leading-snug",children:Cp(a)}),t.jsx("span",{className:"shrink-0",children:gi(a.lastSeenAt)})]})]},a.id)})})}function WC({alert:e,onNavigate:n}){return e.evidence.length===0?t.jsx("span",{className:"text-xs text-muted-foreground",children:"No linked evidence"}):t.jsx("div",{className:"flex flex-wrap gap-2",children:e.evidence.map(s=>s.href===null?t.jsx(Ce,{variant:"outline",children:s.label},`${s.kind}:${s.id}`):t.jsx(Ce,{variant:"outline",asChild:!0,children:t.jsx("a",{href:s.href,onClick:n,children:s.label})},`${s.kind}:${s.id}`))})}function VC({alert:e,onNavigate:n}){return e===null?t.jsx("div",{className:"flex min-h-56 items-center justify-center rounded-md border border-dashed border-border px-4 text-center text-xs text-muted-foreground",children:"Select an alert to inspect its evidence."}):t.jsxs("div",{className:"min-h-0 overflow-y-auto rounded-md border border-border bg-background/70",children:[t.jsx("div",{className:O("border-b px-4 py-3",DC(e.severity)),children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(Ce,{variant:"outline",children:Np(e.severity)}),t.jsx(Ce,{variant:"outline",children:OC(e.source)}),t.jsx(Ce,{variant:"outline",children:Rl(e.category)})]}),t.jsx("h3",{className:"mt-3 text-base font-semibold",children:e.title}),t.jsx("p",{className:"mt-1 text-sm opacity-85",children:e.message})]}),e.count>1?t.jsxs(Ce,{variant:"outline",className:"shrink-0",children:[it(e.count)," hits"]}):null]})}),t.jsxs("div",{className:"space-y-4 p-4",children:[t.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[t.jsx(en,{label:"Target",value:Cp(e)}),t.jsx(en,{label:"Last seen",value:gi(e.lastSeenAt)}),t.jsx(en,{label:"First seen",value:gi(e.firstSeenAt)}),t.jsx(en,{label:"Protocol",value:e.apiFormat??"n/a"})]}),t.jsxs("div",{children:[t.jsx("div",{className:"mb-2 text-xs font-semibold text-muted-foreground",children:"Evidence"}),t.jsx(WC,{alert:e,onNavigate:n})]}),t.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[t.jsx(en,{label:"Logs",value:e.logIds.length===0?"n/a":it(e.logIds.length)}),t.jsx(en,{label:"Sessions",value:e.sessionIds.length===0?"n/a":it(e.sessionIds.length)}),t.jsx(en,{label:"Runs",value:e.runIds.length===0?"n/a":it(e.runIds.length)}),t.jsx(en,{label:"Groups",value:e.groupIds.length===0?"n/a":it(e.groupIds.length)})]})]})]})}function en({label:e,value:n}){return t.jsxs("div",{className:"rounded-md border border-border bg-muted/30 px-3 py-2",children:[t.jsx("div",{className:"text-[10px] font-semibold uppercase text-muted-foreground",children:e}),t.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-foreground",children:n})]})}function KC(){const[e,n]=l.useState(!1),[s,o]=l.useState("all"),[r,a]=l.useState("all"),[i,c]=l.useState(null),{summary:d,isLoading:m}=PC(),u=l.useMemo(()=>UC(s,r),[r,s]),{alerts:f,total:p,isLoading:h,error:g,mutate:v}=IC(u,e),y=l.useMemo(()=>BC(f,i),[f,i]);l.useEffect(()=>{!e||i!==null&&f.some(R=>R.id===i)||c(f[0]?.id??null)},[f,e,i]);const w=d?.total??0,b=d?.critical??0,j=d?.warning??0,S=d?.notice??0,N=b>0?"bg-status-danger text-primary-foreground":j>0?"bg-status-watch text-primary-foreground":"bg-status-cool text-primary-foreground";return t.jsxs(Lt,{open:e,onOpenChange:n,children:[t.jsx(eo,{asChild:!0,children:t.jsxs(te,{type:"button",variant:"ghost",size:"icon",className:so,"aria-label":"Alerts",title:"Alerts",children:[t.jsx(Ko,{className:"size-4"}),m?t.jsx(Ae,{className:"absolute -right-0.5 -top-0.5 size-3 animate-spin text-muted-foreground"}):w>0?t.jsx("span",{className:O("absolute -right-1 -top-1 min-w-4 rounded-full px-1 text-[10px] font-semibold leading-4",N),children:it(w)}):null,t.jsx("span",{className:"sr-only",children:"Alerts"})]})}),t.jsxs(Ot,{className:"flex max-h-[86vh] max-w-6xl flex-col overflow-hidden",children:[t.jsxs(Ut,{children:[t.jsxs(Bt,{className:"flex items-center gap-2 pr-8",children:[t.jsx(Ko,{className:"size-5 text-status-danger"}),t.jsx("span",{children:"Alerts"}),t.jsx(Ce,{variant:"outline",children:it(w)})]}),t.jsx(to,{className:"sr-only",children:"Local alert board for captured Inspector evidence."})]}),t.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[t.jsx(yo,{label:"Open",count:d?.open??0,tone:"neutral"}),t.jsx(yo,{label:"Critical",count:b,tone:"critical"}),t.jsx(yo,{label:"Warning",count:j,tone:"warning"}),t.jsx(yo,{label:"Notice",count:S,tone:"notice"})]}),t.jsxs("div",{className:"flex min-h-0 flex-wrap items-center justify-between gap-2 border-y border-border py-3",children:[t.jsxs("div",{className:"flex flex-wrap gap-1",children:[t.jsx(wo,{value:"all",active:s==="all",label:"All",count:d?.total??null,onClick:o}),t.jsx(wo,{value:"critical",active:s==="critical",label:"Critical",count:b,onClick:o}),t.jsx(wo,{value:"warning",active:s==="warning",label:"Warning",count:j,onClick:o}),t.jsx(wo,{value:"notice",active:s==="notice",label:"Notice",count:S,onClick:o})]}),t.jsxs(te,{type:"button",variant:"outline",size:"sm",className:"h-7 shrink-0 px-2",onClick:()=>{v()},children:[t.jsx(yt,{className:"size-3.5"}),"Refresh"]})]}),t.jsxs("div",{className:"flex flex-wrap gap-1",children:[t.jsx(te,{type:"button",variant:r==="all"?"secondary":"ghost",size:"sm","aria-pressed":r==="all",onClick:()=>a("all"),className:"h-7 px-2",children:"All categories"}),LC.map(C=>{const R=d?.byCategory.find(I=>I.category===C)?.count??0;return R===0?null:t.jsx(qC,{category:C,active:r===C,count:R,onClick:a},C)})]}),t.jsxs("div",{className:"grid min-h-0 flex-1 gap-4 md:grid-cols-[360px_minmax(0,1fr)]",children:[t.jsxs("div",{className:"flex min-h-0 flex-col",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between text-xs text-muted-foreground",children:[t.jsxs("span",{children:[it(p)," matched"]}),t.jsx("span",{children:f.length<p?`${it(f.length)} shown`:"Latest"})]}),t.jsx(HC,{alerts:f,selectedAlertId:y?.id??null,isLoading:h,error:g,onSelect:c})]}),t.jsx(VC,{alert:y,onNavigate:()=>n(!1)})]})]})]})}const GC=12e3;function YC(e){return e===null||e.evidence===null?null:`/api/groups/${encodeURIComponent(e.id)}/evidence`}function JC(e){const n=Rt(YC(e),s=>Le(s,kx,GC));return{evidenceResponse:n.data??null,isLoading:n.isLoading,error:n.error,mutate:n.mutate}}const XC=8e3;function ZC(){const e=Rt("/api/groups",n=>Le(n,iu,XC));return{groups:e.data?.groups??[],isLoading:e.isLoading,error:e.error,mutate:e.mutate}}const QC=3e3;function ek(e,n){return{id:(e?.id??0)+1,message:n.message,tone:n.tone??"error"}}function kp(){const[e,n]=l.useState(null),s=l.useCallback(r=>{n(a=>ek(a,r))},[]),o=l.useCallback(()=>{n(null)},[]);return l.useEffect(()=>{if(e===null)return;const r=window.setTimeout(()=>{n(null)},QC);return()=>{window.clearTimeout(r)}},[e]),{notice:e,showToast:s,dismissToast:o}}function _p({notice:e,onDismiss:n}){if(e===null)return null;const s=e.tone==="error",o=s?cn:Ha;return t.jsx("div",{"aria-atomic":"true","aria-live":"polite",className:"pointer-events-none fixed top-4 right-4 z-[100] w-[min(calc(100vw-2rem),26rem)]",role:"status",children:t.jsxs("div",{className:O("pointer-events-auto flex items-start gap-2 rounded-md border bg-popover/95 px-3 py-2 text-sm text-popover-foreground shadow-[0_18px_50px_color-mix(in_oklch,var(--foreground)_16%,transparent)] backdrop-blur",s?"border-status-danger/35":"border-status-success/35"),children:[t.jsx(o,{className:O("mt-0.5 size-4 shrink-0",s?"text-status-danger":"text-status-success")}),t.jsx("div",{className:"min-w-0 flex-1 break-words leading-5",children:e.message}),t.jsx("button",{type:"button",className:"inline-flex size-6 shrink-0 items-center justify-center rounded-md text-current/70 transition-colors hover:bg-white/10 hover:text-current focus-visible:ring-1 focus-visible:ring-current focus-visible:outline-none","aria-label":"Dismiss notification",onClick:n,children:t.jsx(Js,{className:"size-3.5"})})]},e.id)})}const Sa=2e4;function tk(e,n){const s=`/api/groups/${encodeURIComponent(e)}`;return n?`${s}?deleteEvidence=1`:s}function nk(e){return"/api/groups"}function Tp(e){let n=0,s=0,o=0,r=0;for(const a of e.members)switch(a.status){case"completed":n+=1;break;case"failed":case"cancelled":s+=1;break;case"running":o+=1;break;case"created":break;case null:r+=1;break}return{memberCount:e.members.length,completedMembers:n,failedMembers:s,runningMembers:o,missingStatusMembers:r}}function sk(e,n,s=null){return n!==null&&n.group.id===e.id?n.members.map(o=>({member:o.member,exportMember:o,source:"export"})):s!==null&&s.group.id===e.id&&s.members!==null?s.members.map(o=>({member:o.member,exportMember:o,source:"evidence"})):e.members.map(o=>({member:o,exportMember:null,source:"group"}))}function Ml(e){switch(e){case"completed":return"border-status-success/30 bg-status-success/10 text-status-success";case"failed":case"cancelled":return"border-status-danger/30 bg-status-danger/10 text-status-danger";case"running":return"border-status-cool/30 bg-status-cool/10 text-status-cool";case"created":return"border-border bg-muted/30 text-muted-foreground";case null:return"border-border bg-muted/30 text-muted-foreground"}}function Al(e){return e??"unknown"}function ok(e){switch(e){case"PASS":return"border-status-success/30 bg-status-success/10 text-status-success";case"FAIL":return"border-status-danger/30 bg-status-danger/10 text-status-danger";case"RUNNING":return"border-status-cool/30 bg-status-cool/10 text-status-cool";case"UNKNOWN":return"border-border bg-muted/30 text-muted-foreground"}}function Br(e){return e===null||e.trim().length===0?"-":e}function at(e){return e.toLocaleString()}function bi(e){return e==null?"-":e<1e3?`${at(e)} ms`:`${(e/1e3).toFixed(1)} s`}function ps(e){const n=Date.parse(e);return Number.isFinite(n)?new Intl.DateTimeFormat(void 0,{month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(n)):e}function Fc(e){return e===null?"-":ps(e)}function rk(e){const n=JSON.stringify(e),s=n===void 0?String(e):n;return s.length<=160?s:`${s.slice(0,157)}...`}function Ep(...e){for(const n of e)if(n!==null&&n.trim().length>0)return n;return"-"}function ak(...e){for(const n of e)if(n!=null&&n.trim().length>0)return n;return null}function ik(e){const n=e.provider,s=e.model;return n!==null&&n.length>0&&s!==null&&s.length>0?`${n} / ${s}`:Ep(n,s)}function lk(e,n){if(n!==null){const s=e.find(o=>o.id===n);if(s!==void 0)return s}return e[0]??null}function ck(e){return(e.exportMember?.session?.latestLogs??[])[0]??null}function dk(e){switch(e){case"export":return"fresh export";case"evidence":return"evidence";case"group":return"group"}}function uk(e,n){return n!==null&&n.group.id===e.id?n.evidence:e.evidence}function mk(e,n,s){return n!==null&&n.group.id===e.id?n.summary:s!==null&&s.group.id===e.id?s.summary:null}function fk(e,n,s){return n!==null&&n.group.id===e.id?n.jenkinsReport:s!==null&&s.group.id===e.id?s.report:null}function pk({labelledTrigger:e=!1}){const[n,s]=l.useState(!1),[o,r]=l.useState(null),[a,i]=l.useState(null),[c,d]=l.useState(null),[m,u]=l.useState(null),[f,p]=l.useState(null),[h,g]=l.useState(!1),[v,y]=l.useState(null),[w,b]=l.useState(null),[j,S]=l.useState(!1),{notice:N,showToast:C,dismissToast:R}=kp(),{groups:I,isLoading:P,error:M,mutate:k}=ZC(),A=l.useMemo(()=>lk(I,o),[I,o]);l.useEffect(()=>{!n||o!==null&&I.some(z=>z.id===o)||r(I[0]?.id??null)},[I,n,o]);const D=A!==null&&m!==null&&m.group.id===A.id?m:null,{evidenceResponse:$,isLoading:Y,error:Q,mutate:U}=JC(A),H=l.useCallback(()=>{k()},[k]),X=l.useCallback(async()=>{if(!(I.length===0||j)){S(!0),p(null),g(!1),b(null),d(null);try{const re=await Le(nk(!1),ou,Sa,{method:"DELETE"},z=>`Clear failed with status ${String(z.status)}`);u(null),r(null),await k(),await U(),C({message:`Cleared ${at(re.deleted)} group${re.deleted===1?"":"s"}.`,tone:"success"})}catch(re){C({message:re instanceof Error?re.message:"Unknown error clearing groups",tone:"error"})}finally{S(!1)}}},[j,I.length,k,U,C]),B=l.useCallback(async re=>{i(re.id),d(null);try{const z=await Le(`/api/groups/${encodeURIComponent(re.id)}/evidence`,_x,Sa,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({latestLogLimit:10})},Z=>`Export failed with status ${String(Z.status)}`);u(z),await k(),await U()}catch(z){d(z instanceof Error?z.message:String(z))}finally{i(null)}},[k,U]),W=l.useCallback(re=>{p(re),g(!1),b(null)},[]),pe=l.useCallback(()=>{v===null&&(p(null),g(!1),b(null))},[v]),ve=l.useCallback(re=>{r(re),p(null),g(!1),b(null)},[]),ye=l.useCallback(async()=>{const re=f;if(re!==null){y(re.id),b(null);try{await Le(tk(re.id,h),su,Sa,{method:"DELETE"},z=>`Delete failed with status ${String(z.status)}`),u(z=>z!==null&&z.group.id===re.id?null:z),r(z=>z===re.id?null:z),p(null),g(!1),await k(),await U()}catch(z){b(z instanceof Error?z.message:String(z))}finally{y(null)}}},[h,f,k,U]);return t.jsxs(Lt,{open:n,onOpenChange:s,children:[t.jsx(_p,{notice:N,onDismiss:R}),t.jsx(eo,{asChild:!0,children:t.jsxs(te,{type:"button",variant:"ghost",size:e?"default":"icon",className:O(so,e&&"w-auto gap-2 px-3 text-xs max-lg:h-11 max-lg:w-auto"),"aria-label":"Evaluation groups",title:"Evaluation groups",children:[t.jsx(Hl,{className:"size-4"}),P?t.jsx(Ae,{className:"absolute -right-0.5 -top-0.5 size-3 animate-spin text-muted-foreground"}):I.length>0?t.jsx("span",{className:"absolute -right-1 -top-1 min-w-4 rounded-full bg-primary px-1 text-[10px] leading-4 text-primary-foreground",children:I.length}):null,t.jsx("span",{className:e?"":"sr-only",children:"Groups"})]})}),t.jsxs(Ot,{className:"flex max-h-[85vh] max-w-5xl flex-col overflow-hidden",children:[t.jsx(Ut,{children:t.jsxs(Bt,{className:"flex items-center gap-2 pr-8",children:[t.jsx(Hl,{className:"size-5 text-muted-foreground"}),t.jsx("span",{children:"Groups"}),t.jsx(Ce,{variant:"outline",children:at(I.length)})]})}),t.jsxs("div",{className:"flex min-h-0 items-center justify-between gap-3 border-b border-border pb-3",children:[t.jsx("p",{className:"text-xs text-muted-foreground",children:"Evaluation batches, model runs, and exported evidence packs."}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsxs(te,{type:"button",variant:"outline",size:"sm",disabled:I.length===0||j,onClick:()=>{X()},title:"Clear all groups. Session logs and run records stay intact.",children:[j?t.jsx(Ae,{className:"size-3.5 animate-spin"}):t.jsx(dn,{className:"size-3.5"}),"Clear"]}),t.jsxs(te,{type:"button",variant:"outline",size:"sm",onClick:H,children:[t.jsx(yt,{className:"size-3.5"}),"Refresh"]})]})]}),t.jsxs("div",{className:"grid min-h-0 flex-1 gap-4 md:grid-cols-[260px_minmax(0,1fr)]",children:[t.jsx(hk,{groups:I,selectedGroupId:A?.id??null,isLoading:P,error:M,onSelect:ve}),t.jsx(xk,{group:A,deleteTarget:f,deleteEvidence:h,exportResult:D,evidenceResponse:$,evidenceLoading:Y,evidenceError:Q,exportError:c,deleteError:w,exportingGroupId:a,deletingGroupId:v,onDeleteEvidenceChange:g,onExport:B,onRequestDelete:W,onCancelDelete:pe,onConfirmDelete:()=>{ye()}})]})]})]})}function hk({groups:e,selectedGroupId:n,isLoading:s,error:o,onSelect:r}){return s?t.jsx("div",{className:"flex min-h-48 items-center justify-center rounded-md border border-dashed border-border text-xs text-muted-foreground",children:"Loading groups..."}):o!==void 0?t.jsx("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-2 text-xs text-status-danger",children:o.message}):e.length===0?t.jsx("div",{className:"rounded-md border border-dashed border-border px-3 py-8 text-center text-xs text-muted-foreground",children:"No groups yet."}):t.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:t.jsx("div",{className:"space-y-2",children:e.map(a=>{const i=Tp(a),c=n===a.id;return t.jsxs("button",{type:"button",onClick:()=>r(a.id),className:O("w-full rounded-md border px-3 py-2 text-left text-xs transition-colors",c?"border-primary bg-primary/5":"border-border bg-background hover:bg-muted/50"),children:[t.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[t.jsx("span",{className:"min-w-0 text-sm font-medium leading-snug",children:a.title}),t.jsx(Ce,{variant:"outline",className:Ml(a.status),children:Al(a.status)})]}),t.jsxs("div",{className:"mt-1 flex items-center gap-2 text-muted-foreground",children:[t.jsxs("span",{children:[i.memberCount," sessions"]}),t.jsx("span",{children:ps(a.updatedAt)})]})]},a.id)})})})}function xk({group:e,deleteTarget:n,deleteEvidence:s,exportResult:o,evidenceResponse:r,evidenceLoading:a,evidenceError:i,exportError:c,deleteError:d,exportingGroupId:m,deletingGroupId:u,onDeleteEvidenceChange:f,onExport:p,onRequestDelete:h,onCancelDelete:g,onConfirmDelete:v}){if(e===null)return t.jsx("div",{className:"flex min-h-48 items-center justify-center rounded-md border border-dashed border-border text-xs text-muted-foreground",children:"Select a group to inspect."});const y=Tp(e),w=mk(e,o,r),b=fk(e,o,r),j=uk(e,o),S=sk(e,o,r),N=m===e.id,C=u===e.id,R=n?.id===e.id;return t.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex min-w-0 flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[t.jsxs("div",{className:"min-w-0 space-y-1",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[t.jsx("h3",{className:"min-w-0 text-base font-semibold leading-snug",children:e.title}),t.jsx(Ce,{variant:"outline",className:Ml(e.status),children:Al(e.status)}),t.jsx(Ce,{variant:"outline",children:e.kind})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[t.jsx("span",{children:Br(e.project)}),t.jsxs("span",{children:["updated ",ps(e.updatedAt)]})]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(te,{type:"button",variant:"outline",size:"icon",className:"size-8 text-status-danger hover:text-status-danger/80","aria-label":"Delete group",title:"Delete group",disabled:C,onClick:()=>h(e),children:C?t.jsx(Ae,{className:"size-3.5 animate-spin"}):t.jsx(dn,{className:"size-3.5"})}),t.jsxs(te,{type:"button",variant:"default",size:"sm",className:"shrink-0",disabled:N||C,onClick:()=>{p(e)},children:[N?t.jsx(Ae,{className:"size-3.5 animate-spin"}):t.jsx(Gs,{className:"size-3.5"}),"Export evidence"]})]})]}),e.task!==null&&e.task.trim().length>0&&t.jsx("p",{className:"rounded-md border border-border bg-muted/20 px-3 py-2 text-xs text-muted-foreground",children:e.task}),R&&t.jsx(gk,{group:e,deleteEvidence:s,isDeleting:C,error:d,onDeleteEvidenceChange:f,onCancel:g,onConfirm:v}),t.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[t.jsx(tn,{label:"Members",value:y.memberCount}),t.jsx(tn,{label:"Done",value:y.completedMembers}),t.jsx(tn,{label:"Failed",value:y.failedMembers}),t.jsx(tn,{label:"Running",value:y.runningMembers})]}),w!==null&&t.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[t.jsx(tn,{label:"Requests",value:w.requestCount}),t.jsx(tn,{label:"Errors",value:w.errorCount}),t.jsx(tn,{label:"Tokens",value:w.tokenUsage.total}),t.jsx(tn,{label:"Missing",value:w.missingSessions})]}),t.jsx(bk,{report:b,loading:a,error:i,hasEvidence:j!==null}),t.jsx(vk,{evidence:j}),c!==null&&t.jsx("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-2 text-xs text-status-danger",children:c}),d!==null&&!R&&t.jsx("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-2 text-xs text-status-danger",children:d}),t.jsx(yk,{rows:S})]})})}function gk({group:e,deleteEvidence:n,isDeleting:s,error:o,onDeleteEvidenceChange:r,onCancel:a,onConfirm:i}){const c=e.evidence!==null,d=e.evidence?.markdownPath??"No evidence pack exported.";return t.jsx("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-3 text-status-danger",children:t.jsxs("div",{className:"flex min-w-0 flex-col gap-3 lg:flex-row lg:items-start lg:justify-between",children:[t.jsxs("div",{className:"min-w-0 space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[t.jsx(dn,{className:"size-4 text-status-danger"}),t.jsx("span",{children:"Delete group?"})]}),t.jsxs("p",{className:"text-xs text-status-danger",children:["Delete ",t.jsx("span",{className:"font-medium",children:e.title}),". Session logs and run records stay intact."]}),t.jsxs("label",{className:O("flex min-w-0 items-start gap-2 text-xs",c?"cursor-pointer":"opacity-60"),children:[t.jsx("input",{type:"checkbox",className:"mt-0.5 size-4 shrink-0",checked:n,disabled:!c||s,onChange:m=>r(m.currentTarget.checked)}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block font-medium",children:"Also delete exported evidence files"}),t.jsx("code",{className:"mt-1 block truncate font-mono text-[11px] text-status-danger",children:d})]})]}),o!==null&&t.jsx("div",{className:"rounded-md border border-status-danger/30 bg-card px-2 py-1.5 text-xs text-status-danger",children:o})]}),t.jsxs("div",{className:"flex shrink-0 justify-end gap-2",children:[t.jsx(te,{type:"button",variant:"outline",size:"sm",disabled:s,onClick:a,children:"Cancel"}),t.jsxs(te,{type:"button",variant:"destructive",size:"sm",disabled:s,onClick:i,children:[s?t.jsx(Ae,{className:"size-3.5 animate-spin"}):t.jsx(dn,{className:"size-3.5"}),"Delete"]})]})]})})}function tn({label:e,value:n}){return t.jsxs("div",{className:"rounded-md border border-border bg-muted/20 px-3 py-2",children:[t.jsx("div",{className:"text-[11px] font-medium uppercase text-muted-foreground",children:e}),t.jsx("div",{className:"mt-1 font-mono text-sm font-semibold",children:at(n)})]})}function bk({report:e,loading:n,error:s,hasEvidence:o}){const{copied:r,copy:a}=an(e?.markdown??null);return e===null&&!n&&s===void 0?null:n?t.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-muted/20 px-3 py-2 text-xs text-muted-foreground",children:[t.jsx(Ae,{className:"size-3.5 animate-spin"}),"Loading evidence report..."]}):s!==void 0&&o?t.jsxs("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-2 text-xs text-status-danger",children:["Failed to load evidence report: ",s.message]}):e===null?null:t.jsxs("div",{className:"rounded-md border border-border bg-muted/20 px-3 py-2",children:[t.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"text-xs font-semibold",children:"Evidence report"}),t.jsx(Ce,{variant:"outline",className:ok(e.status),children:e.status})]}),t.jsx(te,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0","aria-label":r?"Copied evidence report":"Copy evidence report",onClick:a,children:r?t.jsx(Pe,{className:"size-3.5 text-status-success"}):t.jsx(St,{className:"size-3.5"})})]}),t.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:e.summary})]})}function vk({evidence:e}){return e===null?t.jsx("div",{className:"rounded-md border border-dashed border-border px-3 py-2 text-xs text-muted-foreground",children:"No evidence pack exported yet."}):t.jsxs("div",{className:"space-y-2 rounded-md border border-border bg-muted/20 px-3 py-2",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-xs font-semibold",children:"Evidence paths"}),t.jsx("span",{className:"text-[11px] text-muted-foreground",children:ps(e.exportedAt)})]}),t.jsxs("div",{className:"grid gap-2",children:[t.jsx(Na,{label:"JSON",value:e.jsonPath}),t.jsx(Na,{label:"Markdown",value:e.markdownPath}),t.jsx(Na,{label:"HTML",value:e.htmlPath})]})]})}function Na({label:e,value:n}){const{copied:s,copy:o}=an(n);return t.jsxs("div",{className:"flex min-w-0 items-center gap-2 rounded-md border border-border bg-background px-2 py-1.5",children:[t.jsx("span",{className:"w-16 shrink-0 text-[11px] font-medium text-muted-foreground",children:e}),t.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs",children:n}),t.jsx(te,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0","aria-label":s?`Copied ${e} path`:`Copy ${e} path`,onClick:o,children:s?t.jsx(Pe,{className:"size-3.5 text-status-success"}):t.jsx(St,{className:"size-3.5"})})]})}function yk({rows:e}){const[n,s]=l.useState(null),o=l.useCallback(r=>{s(a=>a===r?null:r)},[]);return e.length===0?t.jsx("div",{className:"rounded-md border border-dashed border-border px-3 py-8 text-center text-xs text-muted-foreground",children:"No sessions attached."}):t.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[t.jsx("div",{className:"border-b border-border bg-muted/30 px-3 py-2 text-xs font-semibold",children:"Members"}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full min-w-[760px] text-left text-xs",children:[t.jsx("thead",{className:"border-b border-border bg-muted/20 text-muted-foreground",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-3 py-2 font-medium",children:"Session"}),t.jsx("th",{className:"px-3 py-2 font-medium",children:"Provider / Model"}),t.jsx("th",{className:"px-3 py-2 font-medium",children:"Status"}),t.jsx("th",{className:"px-3 py-2 font-medium",children:"Requests"}),t.jsx("th",{className:"px-3 py-2 font-medium",children:"Errors"}),t.jsx("th",{className:"px-3 py-2 font-medium",children:"First chunk"}),t.jsx("th",{className:"px-3 py-2 font-medium",children:"Tokens"})]})}),t.jsx("tbody",{children:e.map(r=>{const a=n===r.member.id;return t.jsxs(l.Fragment,{children:[t.jsx(wk,{row:r,isExpanded:a,onToggleDetails:o}),t.jsx(jk,{row:r,isExpanded:a})]},r.member.id)})})]})})]})}function wk({row:e,isExpanded:n,onToggleDetails:s}){const o=e.member,r=e.exportMember?.session??null,a=ck(e),i=r?.inspectorPath??Fd(o.sessionId),c=e.source!=="evidence",d=r?.requestCount??null,m=r?.errorCount??null,u=r?.tokenUsage.total??null,f=a?.firstChunkMs??null,p=Ep(o.label,o.sessionId),h=ak(r?.clientUserAgent,a?.userAgent,o.agent),g=r?.clientProjectFolder??null,v=yl({userAgent:h,conversationId:o.sessionId,clientProjectFolder:g}),y=$r(v);return t.jsxs("tr",{className:"border-b border-border last:border-0 hover:bg-muted/20",children:[t.jsxs("td",{className:"max-w-56 px-3 py-2",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx(te,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0 text-muted-foreground","aria-label":n?`Hide member ${p}`:`Show member ${p}`,title:n?"Hide member details":"Show member details",onClick:()=>{s(o.id)},children:n?t.jsx(We,{className:"size-3.5"}):t.jsx(ct,{className:"size-3.5"})}),y!==null&&t.jsx(Fr,{client:v,className:"size-5"}),c?t.jsxs("a",{href:i,target:"_blank",rel:"noreferrer",className:"inline-flex max-w-full min-w-0 items-center gap-2 rounded-sm font-mono text-xs text-primary outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","aria-label":`Open session ${p}`,title:`Open session ${p}`,children:[t.jsx("span",{className:"min-w-0 truncate",children:p}),t.jsx(Bi,{className:"size-3 shrink-0 text-muted-foreground"})]}):t.jsxs("button",{type:"button",className:"inline-flex max-w-full min-w-0 items-center gap-2 rounded-sm font-mono text-xs text-foreground outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",title:`Show evidence snapshot for ${p}`,"aria-label":`Show evidence snapshot for ${p}`,onClick:()=>{s(o.id)},children:[t.jsx("span",{className:"min-w-0 truncate",children:p}),t.jsx(Ce,{variant:"outline",className:"shrink-0 border-border bg-muted/30 text-muted-foreground",children:"evidence"})]})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:Br(o.agent)})]}),t.jsx("td",{className:"max-w-52 px-3 py-2",children:t.jsx("span",{className:"block whitespace-normal leading-snug",children:ik(o)})}),t.jsx("td",{className:"px-3 py-2",children:t.jsx(Ce,{variant:"outline",className:Ml(o.status),children:Al(o.status)})}),t.jsx("td",{className:"px-3 py-2 font-mono",children:d===null?"-":at(d)}),t.jsx("td",{className:"px-3 py-2 font-mono",children:m===null?"-":at(m)}),t.jsx("td",{className:"px-3 py-2 font-mono",children:bi(f)}),t.jsx("td",{className:"px-3 py-2 font-mono",children:u===null?"-":at(u)})]})}function jk({row:e,isExpanded:n}){if(!n)return null;const s=e.member,o=e.exportMember,r=o?.session??null,a=o?.run??null,i=Object.entries(s.metadata);return t.jsx("tr",{className:"border-b border-border bg-muted/10",children:t.jsx("td",{colSpan:7,className:"px-3 pb-4 pt-2",children:t.jsxs("div",{className:"space-y-3 rounded-md border border-border bg-background p-3",children:[t.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4",children:[t.jsx(Ve,{label:"Source",value:dk(e.source)}),t.jsx(Ve,{label:"Member ID",value:s.id,mono:!0}),t.jsx(Ve,{label:"Session ID",value:s.sessionId,mono:!0}),t.jsx(Ve,{label:"Run ID",value:a?.id??s.runId??"-",mono:!0}),t.jsx(Ve,{label:"Created",value:ps(s.addedAt)}),t.jsx(Ve,{label:"Updated",value:ps(s.updatedAt)}),t.jsx(Ve,{label:"Session created",value:Fc(r?.createdAt??null)}),t.jsx(Ve,{label:"Session updated",value:Fc(r?.updatedAt??null)})]}),r===null?t.jsx("div",{className:"rounded-md border border-dashed border-border px-3 py-2 text-xs text-muted-foreground",children:"No session snapshot is available for this member."}):t.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4",children:[t.jsx(Ve,{label:"Log coverage",value:r.logCoverage}),t.jsx(Ve,{label:"Runtime",value:Br(r.runtimeMode)}),t.jsx(Ve,{label:"Requests",value:at(r.requestCount),mono:!0}),t.jsx(Ve,{label:"Errors",value:at(r.errorCount),mono:!0}),t.jsx(Ve,{label:"Input tokens",value:at(r.tokenUsage.input),mono:!0}),t.jsx(Ve,{label:"Output tokens",value:at(r.tokenUsage.output),mono:!0}),t.jsx(Ve,{label:"Cache read",value:at(r.tokenUsage.cacheRead),mono:!0}),t.jsx(Ve,{label:"Total tokens",value:at(r.tokenUsage.total),mono:!0})]}),t.jsx(Sk,{logs:r?.latestLogs??[]}),t.jsx(Nk,{entries:i})]})})})}function Ve({label:e,value:n,mono:s=!1}){return t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:e}),t.jsx("div",{className:O("truncate text-xs text-foreground",s?"font-mono":""),title:n,children:n})]})}function Sk({logs:e}){const n=e.slice(0,5);return n.length===0?t.jsx("div",{className:"rounded-md border border-dashed border-border px-3 py-2 text-xs text-muted-foreground",children:"No latest logs in this snapshot."}):t.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[t.jsx("div",{className:"border-b border-border bg-muted/30 px-3 py-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Latest logs"}),t.jsx("div",{className:"divide-y divide-border",children:n.map(s=>{const o=s.sessionLogNumber??s.id;return t.jsxs("div",{className:"grid gap-2 px-3 py-2 text-xs sm:grid-cols-[72px_1fr_88px_88px]",children:[t.jsxs("span",{className:"font-mono text-muted-foreground",title:`Log ID ${String(s.id)}`,children:["#",o]}),t.jsxs("span",{className:"min-w-0 truncate",children:[Br(s.model)," · ",s.apiFormat," · ",s.path]}),t.jsx("span",{className:"font-mono text-muted-foreground",children:bi(s.firstChunkMs)}),t.jsx("span",{className:"font-mono text-muted-foreground",children:bi(s.latencyMs)})]},s.id)})})]})}function Nk({entries:e}){return e.length===0?null:t.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[t.jsx("div",{className:"border-b border-border bg-muted/30 px-3 py-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Metadata"}),t.jsx("div",{className:"grid gap-x-3 gap-y-2 p-3 text-xs sm:grid-cols-2",children:e.map(([n,s])=>{const o=rk(s);return t.jsxs("div",{className:"min-w-0",children:[t.jsx("span",{className:"mr-2 text-muted-foreground",children:n}),t.jsx("span",{className:"font-mono text-foreground",title:o,children:o})]},n)})})]})}const Ck=T({selectionId:x().uuid(),name:x(),apiKeyHint:x(),format:me(["anthropic","openai"]),anthropicBaseUrl:x(),openaiBaseUrl:x(),openaiResponsesBaseUrl:x().optional().default(""),models:V(x()),sourceTool:me(["claude-code","opencode","mimo-code"]),alreadyExists:ke()}),kk=T({scanId:x().uuid(),providers:V(Ck),warnings:V(x()).optional()});T({scanId:x().uuid(),selectionIds:V(x().uuid()).min(1).max(100)});const _k=T({success:ke().optional(),imported:E().optional(),message:x().optional(),errors:V(x()).optional()}),Uc=2e4;function Tk({open:e,onOpenChange:n,onImportComplete:s}){const[o,r]=l.useState(!1),[a,i]=l.useState(null),[c,d]=l.useState(null),[m,u]=l.useState([]),[f,p]=l.useState([]),[h,g]=l.useState(new Set),[v,y]=l.useState(!1),[w,b]=l.useState(null),[j,S]=l.useState(null),N=l.useRef(0),C=l.useRef(0),R=l.useCallback(()=>{const k=N.current+1;N.current=k,r(!0),i(null),p([]),d(null),u([]),g(new Set),b(null),S(null),Le("/api/providers/scan",kk,Uc,{method:"POST"},A=>`Scan failed (${String(A.status)})`).then(A=>{if(N.current!==k)return;d(A.scanId),u(A.providers),p(A.warnings??[]);const D=new Set;A.providers.forEach(($,Y)=>{$.alreadyExists||D.add(Y)}),g(D)}).catch(A=>{N.current===k&&i(A instanceof Error?A.message:String(A))}).finally(()=>{N.current===k&&r(!1)})},[]);l.useEffect(()=>{e&&R()},[e,R]),l.useEffect(()=>{e||(N.current+=1,C.current+=1,r(!1),y(!1))},[e]);const I=l.useCallback(k=>{g(A=>{const D=new Set(A);return D.has(k)?D.delete(k):D.add(k),D})},[]),P=l.useCallback(()=>{const k=m.filter((D,$)=>h.has($));if(k.length===0||c===null)return;const A=C.current+1;C.current=A,y(!0),S(null),b(null),Le("/api/providers/import",_k,Uc,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scanId:c,selectionIds:k.map(D=>D.selectionId)})},D=>`Import failed (${String(D.status)})`).then(D=>{C.current===A&&(u($=>$.map((Y,Q)=>h.has(Q)?{...Y,alreadyExists:!0}:Y)),g(new Set),D.errors!==void 0&&D.errors.length>0&&D.message!==void 0?b(D.message):b(`Imported ${D.imported??k.length} provider(s)`),s())}).catch(D=>{C.current===A&&S(D instanceof Error?D.message:String(D))}).finally(()=>{C.current===A&&y(!1)})},[m,c,h,s]),M=m.some(k=>!k.alreadyExists);return t.jsx(Lt,{open:e,onOpenChange:n,children:t.jsxs(Ot,{className:"max-w-xl max-h-[80vh] overflow-hidden flex flex-col",children:[t.jsxs(Ut,{children:[t.jsx(Bt,{children:"Import from External Tools"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Detect provider configurations from Claude Code, OpenCode, and MiMo Code."})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto space-y-3",children:[o&&t.jsxs("div",{className:"flex items-center justify-center py-8 gap-2 text-muted-foreground",children:[t.jsx(Ae,{className:"size-4 animate-spin"}),t.jsx("span",{className:"text-sm",children:"Scanning for external providers..."})]}),a!==null&&t.jsxs("div",{className:"flex items-center gap-2 text-destructive text-sm py-4",children:[t.jsx(is,{className:"size-4"}),a]}),!o&&a===null&&m.length===0&&t.jsxs("p",{className:"text-sm text-muted-foreground py-8 text-center",children:["No external provider configurations found.",t.jsx("br",{}),t.jsx("span",{className:"text-xs",children:"Supported tools: Claude Code (~/.claude/settings.json), OpenCode (~/.config/opencode/opencode.json), MiMo Code (~/.config/mimocode/mimocode.jsonc)"})]}),!o&&m.map((k,A)=>t.jsxs("label",{className:`flex items-start gap-3 p-3 border rounded-md ${k.alreadyExists?"":"cursor-pointer hover:bg-muted/50"}`,children:[!k.alreadyExists&&t.jsx("input",{type:"checkbox",checked:h.has(A),disabled:v,onChange:()=>I(A),className:"mt-0.5 size-4"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(Fr,{client:k.sourceTool,className:"size-7 rounded-[8px]"}),k.alreadyExists&&t.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Already added"})]}),t.jsxs("div",{className:"mt-1 text-xs leading-snug text-muted-foreground",children:[k.models.slice(0,4).join(", "),k.models.length>4?` +${k.models.length-4} more`:""]}),t.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:k.format==="anthropic"?k.anthropicBaseUrl:k.openaiResponsesBaseUrl!==""?k.openaiResponsesBaseUrl:k.openaiBaseUrl}),t.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 font-mono",children:k.apiKeyHint})]})]},k.selectionId)),f.length>0&&t.jsx("div",{className:"text-xs text-muted-foreground space-y-1 border-t pt-2",children:f.map((k,A)=>t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(is,{className:"size-3"}),k]},A))}),w!==null&&t.jsx("div",{className:"border-t pt-2 text-sm text-status-success",children:w}),j!==null&&t.jsx("div",{className:"text-sm text-destructive border-t pt-2",children:j})]}),t.jsxs("div",{className:"flex items-center justify-between pt-3 border-t",children:[t.jsxs(te,{variant:"outline",size:"sm",onClick:R,disabled:o,children:[t.jsx(Ae,{className:`size-3 mr-1 ${o?"animate-spin":""}`}),"Rescan"]}),t.jsxs(te,{size:"sm",onClick:P,disabled:!M||h.size===0||v,children:[t.jsx(Gs,{className:"size-3 mr-1"}),v?"Importing...":`Import Selected (${h.size})`]})]})]})})}const Rp=T({id:x().min(1).max(Ya),aliases:V(x().max(Ya)).max(Tn).optional().default([]),contextWindow:E().int().positive().optional(),outputLimit:E().int().positive().optional(),sourceUrl:x().optional()}),Ek=T({name:x().min(1).optional(),aliases:V(x()).max(Tn).optional().default([]),baseUrls:V(x()).max(Tn).optional().default([]),models:V(Rp).min(1).max(Tn)});T({version:E().int().positive().optional(),updatedAt:x().optional(),providers:V(Ek).max(Tn).optional().default([]),models:V(Rp).max(Tn).optional().default([])});function Bc(e){return e.trim().toLowerCase().replace(/\s+/g,"-")}function Rk(e){const n=e.models.filter(s=>s.trim()!=="");return n.length>0?n:e.model!==void 0&&e.model.trim()!==""?[e.model]:[]}function Il(e,n){const s=Bc(n);return(e.modelMetadata??[]).find(r=>Bc(r.model)===s)??null}function Mk(e){const n=Rk(e);return n.length===0?!1:n.every(s=>{const o=Il(e,s);return o!==null&&o.contextWindow!==void 0})}function Ak(e,n){if(e===null)return null;for(const s of n){const o=Il(s,e);if(o!==null&&o.contextWindow!==void 0)return{providerName:s.name,model:o.model,tokens:o.contextWindow,sourceUrl:o.sourceUrl}}return null}function Ws(e){return Object.prototype.hasOwnProperty.call(e,"success")}function qr(e){return Object.prototype.hasOwnProperty.call(e,"notConfigured")}function mt(e){return e!==void 0&&e!==""}function Ye(e){return e!==void 0&&e.trim()!==""}function rs(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function Mp(e){return e>=10?`${e.toFixed(0)}/s`:`${e.toFixed(1)}/s`}function Ap(e){switch(e){case"timeout":return"Timeout";case"network_unreachable":return"Offline";case"connection_refused":return"Refused";case"auth_failed":return"Auth";case"rate_limited":return"Rate limit";case"server_error":return"Server";case"invalid_response":return"Invalid";case"unknown":return"Failed"}}function Ik(e){return e.firstChunkMs!==void 0&&e.firstChunkMs!==null?rs(e.firstChunkMs):e.latencyMs!==void 0?rs(e.latencyMs):e.totalStreamMs!==void 0&&e.totalStreamMs!==null?rs(e.totalStreamMs):e.tokensPerSecond!==void 0&&e.tokensPerSecond!==null&&e.tokensPerSecond>0?Mp(e.tokensPerSecond):null}function Pk(e){return qr(e)?{tone:"quiet",label:"N/A",metric:null,hasDetails:!1}:Ws(e)?e.success?{tone:"success",label:"Pass",metric:Ik(e),hasDetails:!0}:{tone:"failure",label:Ap(e.error?.type??"unknown"),metric:null,hasDetails:!0}:{tone:"pending",label:"Running",metric:null,hasDetails:!1}}function Lk(e,n){if(n===void 0)return[];const s=[];return mt(e.anthropicBaseUrl)&&s.push(n.anthropic),mt(e.openaiBaseUrl)&&s.push(n.openaiChat),mt(e.openaiResponsesBaseUrl)&&s.push(n.openaiResponses),s}function Ok(e,n){const s={total:0,passed:0,failed:0,testing:0};for(const o of Lk(e,n))for(const r of[o.nonStreaming,o.streaming])qr(r)||(s.total+=1,Ws(r)?r.success?s.passed+=1:s.failed+=1:s.testing+=1);return s}function qc(e){if(e===void 0)return;const n=Object.entries(e).map(([s,o])=>`${s}: ${o}`);return n.length===0?void 0:n.join(`
|
|
57
|
-
`)}function nn({title:e,children:n}){return t.jsxs("section",{className:"space-y-1.5",children:[t.jsx("h4",{className:"text-xs font-medium text-foreground/80",children:e}),n]})}function wn({value:e}){return t.jsx("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap break-all rounded-md bg-muted/40 p-3 font-mono text-[11px] leading-relaxed text-foreground/80",children:e})}function jn({label:e,value:n}){return t.jsxs("div",{className:"min-w-0 rounded-md bg-muted/35 px-3 py-2",children:[t.jsx("dt",{className:"text-[10px] text-muted-foreground",children:e}),t.jsx("dd",{className:"mt-1 truncate font-mono text-xs font-semibold text-foreground",title:n,children:n})]})}function Dk({result:e}){const n=e.inputTokens!==void 0||e.outputTokens!==void 0,s=e.cacheCreationInputTokens!==void 0||e.cacheReadInputTokens!==void 0;return Ye(e.model)||n||s||e.latencyMs!==void 0||e.firstChunkMs!==void 0&&e.firstChunkMs!==null||e.totalStreamMs!==void 0&&e.totalStreamMs!==null||e.tokensPerSecond!==void 0&&e.tokensPerSecond!==null&&e.tokensPerSecond>0?t.jsxs("dl",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4",children:[Ye(e.model)&&t.jsx(jn,{label:"Model",value:e.model}),e.latencyMs!==void 0&&t.jsx(jn,{label:"Latency",value:rs(e.latencyMs)}),e.firstChunkMs!==void 0&&e.firstChunkMs!==null&&t.jsx(jn,{label:"First chunk",value:rs(e.firstChunkMs)}),e.totalStreamMs!==void 0&&e.totalStreamMs!==null&&t.jsx(jn,{label:"Stream total",value:rs(e.totalStreamMs)}),e.tokensPerSecond!==void 0&&e.tokensPerSecond!==null&&e.tokensPerSecond>0&&t.jsx(jn,{label:"Token rate",value:`${Mp(e.tokensPerSecond)} tok`}),n&&t.jsx(jn,{label:"Tokens in / out",value:`${String(e.inputTokens??0)} / ${String(e.outputTokens??0)}`}),s&&t.jsx(jn,{label:"Cache create / read",value:`${String(e.cacheCreationInputTokens??0)} / ${String(e.cacheReadInputTokens??0)}`})]}):null}function zk({result:e}){const n=e.debug,s=n?.requestUrl,o=n?.requestMethod??"POST",r=qc(n?.requestHeaders),a=qc(n?.responseHeaders),i=n?.responseStatus===void 0?void 0:`${String(n.responseStatus)}${Ye(n.responseStatusText)?` ${n.responseStatusText}`:""}`,c=n?.responseBody??e.rawResponse;return Ye(e.error?.hint)||Ye(e.error?.details)||Ye(s)||r!==void 0||Ye(n?.requestBody)||Ye(i)||a!==void 0||Ye(c)?t.jsxs("div",{className:"space-y-4 border-t border-border/70 pt-4 text-xs text-muted-foreground",children:[Ye(e.error?.hint)&&t.jsx(nn,{title:"Hint",children:t.jsx("p",{className:"break-words text-foreground/80",children:e.error.hint})}),Ye(e.error?.details)&&t.jsx(nn,{title:"Error details",children:t.jsx(wn,{value:e.error.details})}),Ye(s)&&t.jsx(nn,{title:"Request",children:t.jsx(wn,{value:`${o} ${s}`})}),r!==void 0&&t.jsx(nn,{title:"Request headers",children:t.jsx(wn,{value:r})}),Ye(n?.requestBody)&&t.jsx(nn,{title:"Request body",children:t.jsx(wn,{value:n.requestBody})}),Ye(i)&&t.jsx(nn,{title:"Response status",children:t.jsx(wn,{value:i})}),a!==void 0&&t.jsx(nn,{title:"Response headers",children:t.jsx(wn,{value:a})}),Ye(c)&&t.jsx(nn,{title:"Response body",children:t.jsx(wn,{value:c})})]}):null}function $k({result:e,probeLabel:n,children:s}){const o=e.error?.message??"Connection failed";return t.jsxs(Lt,{children:[t.jsx(eo,{asChild:!0,children:s}),t.jsxs(Ot,{className:"max-h-[82vh] max-w-2xl gap-0 overflow-hidden p-0",children:[t.jsxs(Ut,{className:"border-b border-border/70 px-5 py-4 pr-12",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[e.success?t.jsx(Ks,{className:"size-4 text-status-success"}):t.jsx(is,{className:"size-4 text-status-danger"}),t.jsx(Bt,{className:"text-base",children:n})]}),t.jsx(to,{children:e.success?"Connection probe passed.":o})]}),t.jsxs("div",{className:"space-y-4 overflow-y-auto p-5",children:[!e.success&&t.jsxs("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-2 text-sm text-status-danger",children:[t.jsx("div",{className:"font-medium",children:Ap(e.error?.type??"unknown")}),t.jsx("div",{className:"mt-1 break-words text-xs text-muted-foreground",children:o})]}),t.jsx(Dk,{result:e}),t.jsx(zk,{result:e})]})]})]})}function Fk(e){const n="size-3 shrink-0";switch(e){case"timeout":return t.jsx(Vt,{className:n});case"network_unreachable":return t.jsx(y1,{className:n});case"connection_refused":return t.jsx(j1,{className:n});case"auth_failed":return t.jsx(gg,{className:n});case"rate_limited":return t.jsx(qi,{className:n});case"server_error":return t.jsx(o1,{className:n});case"invalid_response":return t.jsx(j0,{className:n});case"unknown":return t.jsx(is,{className:n})}}const Uk={success:"bg-status-success/10 text-status-success hover:bg-status-success/15",failure:"bg-status-danger/10 text-status-danger hover:bg-status-danger/15",pending:"bg-muted/40 text-foreground/80",quiet:"bg-transparent text-muted-foreground/70"};function Hc({result:e,probeLabel:n}){const s=Pk(e),o=qr(e)?t.jsx(gu,{className:"size-3 shrink-0"}):Ws(e)?e.success?t.jsx(Ks,{className:"size-3 shrink-0"}):Fk(e.error?.type??"unknown"):t.jsx(Vo,{className:"size-3 shrink-0 animate-spin"}),r=t.jsxs(t.Fragment,{children:[o,t.jsx("span",{className:"min-w-0 truncate",children:s.label}),s.metric!==null&&t.jsx("span",{className:"ml-auto shrink-0 font-mono text-[10px] opacity-75",children:s.metric})]}),a=O("inline-flex h-7 w-full min-w-0 items-center gap-1.5 rounded-md px-2 text-left text-xs transition-colors",Uk[s.tone]);return Ws(e)&&s.hasDetails?t.jsx($k,{result:e,probeLabel:n,children:t.jsx("button",{type:"button",className:a,"aria-label":`Open ${n} result: ${s.label}`,children:r})}):t.jsx("div",{className:a,children:r})}function Wc({label:e}){return t.jsxs("div",{className:"inline-flex h-7 w-full min-w-0 items-center gap-1.5 rounded-md px-2 text-xs text-muted-foreground/70",children:[t.jsx(gu,{className:"size-3 shrink-0"}),t.jsx("span",{className:"truncate",children:e})]})}function Ca({label:e,results:n,configured:s=!0}){return t.jsxs("div",{className:"grid min-w-0 grid-cols-[minmax(6.5rem,1fr)_minmax(6rem,0.9fr)_minmax(6rem,0.9fr)] items-center gap-2 border-t border-border/60 px-2 py-2",children:[t.jsx("div",{className:"min-w-0 truncate text-xs font-medium text-foreground/85",title:e,children:e}),s&&n!==void 0?t.jsx(Hc,{result:n.nonStreaming,probeLabel:`${e} non-stream`}):t.jsx(Wc,{label:s?"Not tested":"Off"}),s&&n!==void 0?t.jsx(Hc,{result:n.streaming,probeLabel:`${e} stream`}):t.jsx(Wc,{label:s?"Not tested":"Off"})]})}function Ip({provider:e,results:n}){const s=mt(e.anthropicBaseUrl),o=mt(e.openaiBaseUrl),r=mt(e.openaiResponsesBaseUrl);return!s&&!o&&!r?t.jsx("div",{className:"text-xs text-muted-foreground",children:"No testable endpoint configured."}):t.jsx("div",{className:"min-w-0 overflow-x-auto rounded-md border border-border/70",children:t.jsxs("div",{className:"min-w-[20rem]",children:[t.jsxs("div",{className:"grid grid-cols-[minmax(6.5rem,1fr)_minmax(6rem,0.9fr)_minmax(6rem,0.9fr)] gap-2 bg-muted/25 px-2 py-1.5 text-[10px] text-muted-foreground",children:[t.jsx("span",{children:"Protocol"}),t.jsx("span",{children:"Non-stream"}),t.jsx("span",{children:"Stream"})]}),s&&t.jsx(Ca,{label:"Anthropic",results:n?.anthropic}),o&&t.jsx(Ca,{label:"OpenAI Chat",results:n?.openaiChat}),r&&t.jsx(Ca,{label:"OpenAI Responses",results:n?.openaiResponses})]})})}function Bk(e){const n={total:0,passed:0,failed:0,testing:0};for(const s of[e.nonStreaming,e.streaming])qr(s)||(n.total+=1,Ws(s)?s.success?n.passed+=1:n.failed+=1:n.testing+=1);return n}function ka({label:e,results:n}){const s=Bk(n),o=s.failed>0?"border-status-danger/30 bg-status-danger/10 text-status-danger":s.testing>0?"border-status-watch/30 bg-status-watch/10 text-status-watch":s.total>0&&s.passed===s.total?"border-status-success/30 bg-status-success/10 text-status-success":"border-border/60 bg-transparent text-muted-foreground",r=s.failed>0?`${s.failed} fail`:s.testing>0?"running":s.total===0?"off":`${s.passed}/${s.total}`;return t.jsxs("span",{className:O("rounded border px-1.5 py-0.5 text-[10px]",o),children:[e," ",r]})}function qk({provider:e,modelName:n,results:s,expanded:o,onToggle:r}){return t.jsxs("div",{className:"min-w-0",children:[t.jsxs("button",{type:"button",onClick:r,className:"flex w-full min-w-0 flex-wrap items-center gap-2 px-2 py-2 text-left transition-colors hover:bg-muted/20","aria-expanded":o,children:[o?t.jsx(We,{className:"size-3.5 shrink-0 text-muted-foreground"}):t.jsx(ct,{className:"size-3.5 shrink-0 text-muted-foreground"}),t.jsx("span",{className:"min-w-[8rem] flex-1 truncate text-xs font-medium",title:n,children:n}),t.jsxs("span",{className:"flex flex-wrap items-center justify-end gap-1",children:[mt(e.anthropicBaseUrl)&&t.jsx(ka,{label:"A",results:s.anthropic}),mt(e.openaiBaseUrl)&&t.jsx(ka,{label:"Chat",results:s.openaiChat}),mt(e.openaiResponsesBaseUrl)&&t.jsx(ka,{label:"Resp",results:s.openaiResponses})]})]}),o&&t.jsx("div",{className:"px-2 pb-3",children:t.jsx(Ip,{provider:e,results:s})})]})}function Hk({provider:e,testResults:n}){const s=Object.entries(n.models??{}),[o,r]=l.useState(!1),[a,i]=l.useState(null);return s.length===0?null:t.jsxs("section",{className:"space-y-2",children:[t.jsxs("button",{type:"button",onClick:()=>r(c=>!c),className:"flex w-full items-center gap-1.5 text-left text-xs font-medium text-foreground/80 transition-colors hover:text-foreground","aria-expanded":o,children:[o?t.jsx(We,{className:"size-3.5"}):t.jsx(ct,{className:"size-3.5"}),"Model probes",t.jsx("span",{className:"rounded bg-muted/50 px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground",children:s.length})]}),o&&t.jsx("div",{className:"min-w-0 divide-y divide-border/60 rounded-md border border-border/70",children:s.map(([c,d])=>t.jsx(qk,{provider:e,modelName:c,results:d,expanded:a===c,onToggle:()=>i(m=>m===c?null:c)},c))})]})}function Wk({provider:e,testResults:n,isTesting:s}){const o=mt(e.anthropicBaseUrl)||mt(e.openaiBaseUrl)||mt(e.openaiResponsesBaseUrl),r=Ok(e,n);return s?t.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-status-cool/30 bg-status-cool/10 px-2 py-1 text-xs text-status-cool",children:[t.jsx(Vo,{className:"size-3 animate-spin"}),"Testing"]}):o?n===void 0||r.total===0?t.jsx("span",{className:"rounded border border-border/70 bg-muted/20 px-2 py-1 text-xs text-muted-foreground",children:"Not tested"}):r.failed>0?t.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-status-danger/30 bg-status-danger/10 px-2 py-1 text-xs text-status-danger",children:[t.jsx(is,{className:"size-3"}),r.failed," failed"]}):r.testing>0||r.passed<r.total?t.jsxs("span",{className:"rounded border border-status-watch/30 bg-status-watch/10 px-2 py-1 text-xs text-status-watch",children:[r.passed,"/",r.total]}):t.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-status-success/30 bg-status-success/10 px-2 py-1 text-xs text-status-success",children:[t.jsx(Ks,{className:"size-3"}),r.passed,"/",r.total]}):t.jsx("span",{className:"rounded border border-border/70 bg-muted/20 px-2 py-1 text-xs text-muted-foreground",children:"No endpoint"})}const Vk={deepseek:"https://api-docs.deepseek.com/zh-cn/"};function _a(e){return e!==void 0&&e!==""}function Ta({label:e}){return t.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-border/70 bg-muted/25 px-1.5 py-0.5 text-foreground/80",children:[t.jsx(Ks,{className:"size-3"}),e]})}function Kk({provider:e}){const n=_a(e.anthropicBaseUrl),s=_a(e.openaiBaseUrl),o=_a(e.openaiResponsesBaseUrl);return!n&&!s&&!o?t.jsx("div",{className:"text-xs text-muted-foreground",children:"Test requires at least one configured endpoint."}):t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5 text-xs text-muted-foreground",children:[n&&t.jsx(Ta,{label:"Anthropic"}),s&&t.jsx(Ta,{label:"OpenAI Chat"}),o&&t.jsx(Ta,{label:"OpenAI Responses"})]})}function Gk(e){const n=e.models??[];if(n.length===0)return"No models configured";const s=n.slice(0,2).join(", "),o=n.length-2;return o>0?`${s} +${o} more`:s}function Yk({provider:e,model:n}){const s=Il(e,n),o=Xk(s?.sourceUrl);return t.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:[t.jsx("span",{children:n}),s!==null&&s.contextWindow!==void 0&&t.jsx("span",{className:"font-mono text-foreground/80",children:Bd(s.contextWindow)}),o!==null&&t.jsx(bs,{children:t.jsxs(nt,{children:[t.jsx(st,{asChild:!0,children:t.jsx("a",{href:o.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-0.5 rounded border border-border/70 bg-background/70 px-1 font-mono text-[10px] leading-4 text-muted-foreground transition-colors hover:text-foreground","aria-label":o.title,children:o.label})}),t.jsx(ot,{children:o.title})]})})]})}function Jk(e){const n=Date.now(),s=new Date(e).getTime(),o=n-s,r=Math.floor(o/1e3);if(r<60)return"just now";const a=Math.floor(r/60);if(a<60)return`${a}m ago`;const i=Math.floor(a/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function Xk(e){if(e===void 0||e.trim()==="")return null;try{const n=new URL(e);if(n.protocol!=="https:"&&n.protocol!=="http:")return null;const s=n.hostname.toLowerCase(),o=s==="huggingface.co"||s.endsWith(".huggingface.co");return{label:o?"HF":"Source",title:o?"Open Hugging Face model source":"Open model metadata source",url:e}}catch{return null}}function Zk({provider:e,testResults:n,isTesting:s,testingTimeLeft:o,isHighlighted:r,onEdit:a,onDelete:i,onTest:c,onRefreshMetadata:d,isRefreshingMetadata:m=!1}){const[u,f]=l.useState(!1),p=e.apiDocsUrl??Object.entries(Vk).find(([b])=>e.name.toLowerCase().includes(b))?.[1],h=Mk(e),g=e.modelMetadataUrl!==void 0&&e.modelMetadataUrl.trim()!=="",v=g?"Refresh":"Import defaults",y=s??!1,w=e.source==="company"?t.jsx("span",{className:"shrink-0 rounded border border-status-cool/30 bg-status-cool/10 px-1.5 py-0.5 text-xs text-status-cool",children:"Company"}):e.source==="personal"?t.jsx("span",{className:"shrink-0 rounded border border-status-accent/30 bg-status-accent/10 px-1.5 py-0.5 text-xs text-status-accent",children:"Personal"}):null;return t.jsxs("div",{"data-provider-id":e.id,className:`flex flex-col gap-3 rounded-[8px] border border-border bg-card p-4 shadow-sm transition-all duration-500 ${r===!0?"ring-2 ring-primary shadow-md":""}`,children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0 space-y-1",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[t.jsx("span",{className:"font-medium leading-snug",children:e.name}),w]}),t.jsx("div",{className:"text-xs leading-snug text-muted-foreground",children:Gk(e)})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(Wk,{provider:e,testResults:n,isTesting:y}),p!==void 0&&t.jsxs("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground",title:"View API documentation",children:[t.jsx(Bi,{className:"size-3"}),t.jsx("span",{className:"sr-only",children:"Docs"})]})]})]}),t.jsxs("div",{className:"flex flex-col gap-2 text-xs text-muted-foreground sm:flex-row sm:items-center sm:justify-between",children:[t.jsx(Kk,{provider:e}),n?.testedAt!==void 0&&t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(Vt,{className:"size-3"}),Jk(n.testedAt)]})]}),!h&&t.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-status-watch/30 bg-status-watch/10 px-2 py-1.5 text-xs text-status-watch",children:[t.jsx("span",{children:"Context window metadata missing"}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.jsxs(te,{type:"button",variant:"outline",size:"sm",onClick:()=>d?.(e.id),className:"h-6 gap-1 px-2 text-xs",disabled:m,children:[t.jsx(Vo,{className:`size-3 ${m?"animate-spin":""}`}),v]}),!g&&t.jsx(te,{type:"button",variant:"ghost",size:"sm",onClick:()=>a(e),className:"h-6 px-2 text-xs",children:"Set URL"})]})]}),u&&t.jsxs("div",{className:"space-y-3 border-t border-border/60 pt-3",children:[t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[t.jsx(Ks,{className:"size-3.5 text-status-success"}),t.jsx("span",{children:"API key configured"})]}),e.models!==void 0&&e.models.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1",children:e.models.map(b=>t.jsx(Yk,{provider:e,model:b},b))}),t.jsxs("section",{className:"space-y-2",children:[t.jsx("h4",{className:"text-xs font-medium text-foreground/80",children:"Connection probes"}),t.jsx(Ip,{provider:e,results:n})]}),n!==void 0&&t.jsx(Hk,{provider:e,testResults:n})]}),t.jsxs("div",{className:"flex flex-col gap-2 border-t pt-1 sm:flex-row sm:items-center sm:justify-between",children:[t.jsxs("button",{type:"button",onClick:()=>f(b=>!b),className:"inline-flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground","aria-expanded":u,children:[u?t.jsx(We,{className:"size-3"}):t.jsx(ct,{className:"size-3"}),"Details"]}),t.jsxs("div",{className:"flex gap-2",children:[c!==void 0&&t.jsxs(te,{variant:"outline",size:"sm",onClick:()=>c(e.id),className:"text-xs h-7 gap-1",disabled:y,children:[t.jsx(Vo,{className:`size-3 ${y?"animate-spin":""}`}),y?o!==void 0?`Testing (${o}s)`:"Testing...":"Test"]}),t.jsxs(te,{variant:"outline",size:"sm",onClick:()=>a(e),className:"text-xs h-7 gap-1",disabled:y,children:[t.jsx(bu,{className:"size-3"}),"Edit"]}),t.jsxs(te,{variant:"outline",size:"sm",onClick:()=>i(e.id),className:"text-xs h-7 gap-1 text-destructive hover:text-destructive",disabled:y,children:[t.jsx(dn,{className:"size-3"}),"Delete"]})]})]})]})}const as="/v1/chat/completions",vi="/v1/responses",Qk="/v1/messages";function e3(e,n){const s=e.endsWith("/")?e.slice(0,-1):e,o=Pp(n),r=n.indexOf("?"),a=r>=0?n.slice(r):"";return o!==""&&s.endsWith(o)?s+a:Op(s)&&Lp(n)||s.endsWith("/v1")&&n.startsWith("/v1/")?s+n.slice(3):s+n}function t3(e,n,s={}){const o=e.trim().replace(/\/+$/,""),r=Pp(n),a=e3(o,n),i=[];return r!==""&&o.endsWith(r)?i.push({severity:"info",message:"This already includes the exact endpoint; no duplicate suffix will be appended."}):Op(o)&&Lp(n)?i.push({severity:"info",message:"Zhipu bases already include the API version; only /chat/completions is appended."}):o.endsWith("/v1")&&n.startsWith("/v1/")&&i.push({severity:"info",message:"Base URL already ends with /v1; the suffix will not repeat /v1."}),Vc(r)&&s3(o)&&i.push({severity:"warning",message:"This looks like a Chat Completions endpoint, so Responses would append after it."}),n3(r)&&o3(o)&&i.push({severity:"warning",message:"This looks like a Responses endpoint, so Chat Completions would append after it."}),Vc(r)&&r3(o,s.providerName)&&i.push({severity:"warning",message:"DeepSeek's official API does not currently expose OpenAI Responses."}),{finalUrl:a,diagnostics:i}}function Pp(e){return e.split("?")[0]??e}function Lp(e){return e===as||e.startsWith(`${as}?`)||e.startsWith(`${as}/`)}function n3(e){return e===as||e.startsWith(`${as}/`)}function Vc(e){return e===vi||e.startsWith(`${vi}/`)}function s3(e){return e.toLowerCase().endsWith("/chat/completions")}function o3(e){return e.toLowerCase().endsWith("/responses")}function r3(e,n){const s=n?.toLowerCase();if(s!==void 0&&s.includes("deepseek"))return!0;try{return new URL(e).hostname.toLowerCase().includes("deepseek")}catch{return e.toLowerCase().includes("deepseek")}}function Op(e){try{const n=new URL(e),s=n.pathname.replace(/\/+$/,"");return n.hostname==="open.bigmodel.cn"&&(s==="/api/paas/v4"||s==="/api/coding/paas/v4")}catch{return!1}}function Ea(e){return e!==void 0&&e.trim()!==""}function Kc(e){const n=Ea(e?.anthropicBaseUrl),s=Ea(e?.openaiBaseUrl),o=Ea(e?.openaiResponsesBaseUrl);return{anthropic:n,openai:s||o,openaiChat:s,openaiResponses:o}}function Ra(e,n,s){if(!e)return s?"":void 0;const o=n.trim();return o===""?void 0:o}const Gc=["zhipu","zhipuai","bigmodel","z.ai","zai","glm"],Yc=["zhipu coding","glm coding","bigmodel coding","z.ai coding","zai coding"],jo=Qk,So=as,No=vi,a3={deepseek:{openaiBaseUrl:"https://api.deepseek.com"},minimax:{anthropicBaseUrl:"https://api.minimaxi.com/anthropic",openaiBaseUrl:"https://api.minimaxi.com",openaiResponsesBaseUrl:"https://api.minimaxi.com",apiDocsUrl:"https://platform.minimaxi.com/docs/api-reference/api-overview"},"zhipu coding":{anthropicBaseUrl:"https://open.bigmodel.cn/api/anthropic",openaiBaseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/coding-plan/quick-start"},"glm coding":{anthropicBaseUrl:"https://open.bigmodel.cn/api/anthropic",openaiBaseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/coding-plan/quick-start"},"bigmodel coding":{anthropicBaseUrl:"https://open.bigmodel.cn/api/anthropic",openaiBaseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/coding-plan/quick-start"},"z.ai coding":{anthropicBaseUrl:"https://open.bigmodel.cn/api/anthropic",openaiBaseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/coding-plan/quick-start"},"zai coding":{anthropicBaseUrl:"https://open.bigmodel.cn/api/anthropic",openaiBaseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/coding-plan/quick-start"},zhipu:{openaiBaseUrl:"https://open.bigmodel.cn/api/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/guide/develop/openai/introduction"},zhipuai:{openaiBaseUrl:"https://open.bigmodel.cn/api/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/guide/develop/openai/introduction"},bigmodel:{openaiBaseUrl:"https://open.bigmodel.cn/api/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/guide/develop/openai/introduction"},"z.ai":{openaiBaseUrl:"https://open.bigmodel.cn/api/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/guide/develop/openai/introduction"},zai:{openaiBaseUrl:"https://open.bigmodel.cn/api/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/guide/develop/openai/introduction"},glm:{openaiBaseUrl:"https://open.bigmodel.cn/api/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/guide/develop/openai/introduction"},alibaba:{openaiBaseUrl:"https://dashscope.aliyuncs.com/compatible-mode"}},Jc=["MiniMax M3","MiniMax M2.7","MiniMax M2.7-highspeed","MiniMax M2.5","MiniMax M2.5-highspeed","MiniMax M2.1","MiniMax M2.1-highspeed","MiniMax M2"],Xc=["qwen3.6-plus","qwen3.7-max"],Zc=["glm-5.2","glm-5.1","glm-5","glm-5-turbo","glm-4.7","glm-4.7-flashx","glm-4.6","glm-4.5","glm-4.5-air","glm-4.5-x","glm-4.5-airx","glm-4.5-flash"],yi="__unset__",ir="__custom__",Dp=[{value:"32K",label:"Small"},{value:"64K",label:"Standard"},{value:"128K",label:"Medium"},{value:"200K",label:"Long"},{value:"256K",label:"Extended"},{value:"512K",label:"Large"},{value:"1M",label:"Max"}];function Sn(){return{contextWindow:"",contextWindowMode:"unset",outputLimit:""}}function Qc(e){return e.trim().toLowerCase().replace(/\s+/g,"-")}function zp(e,n){const s=Qc(n);return e?.modelMetadata?.find(o=>Qc(o.model)===s)??null}function $p(e){const n=Bo(e);if(n===null)return null;for(const s of Dp)if(Bo(s.value)===n)return s.value;return null}function i3(e){return e.trim()===""?"unset":$p(e)!==null?"preset":"custom"}function l3(e){switch(e.contextWindowMode){case"unset":return yi;case"custom":return ir;case"preset":return $p(e.contextWindow)??ir}}function Ma(e){const n=e.trim().replaceAll(",","");if(n==="")return{amount:"",unit:"K"};const s=/^(\d+(?:\.\d+)?)\s*([kKmM])?$/.exec(n);if(s===null)return{amount:n,unit:"K"};const o=s[1];if(o===void 0)return{amount:n,unit:"K"};const r=s[2];if(r===void 0||r==="")return{amount:o,unit:"tokens"};switch(r.toLowerCase()){case"k":return{amount:o,unit:"K"};case"m":return{amount:o,unit:"M"};default:return{amount:n,unit:"K"}}}function ed(e,n){const s=e.trim();if(s==="")return"";switch(n){case"K":return`${s}K`;case"M":return`${s}M`;case"tokens":return s}}function td(e,n){return n.map(s=>{const o=zp(e,s),r=o?.contextWindow!==void 0?Eh(o.contextWindow):"";return{contextWindow:r,contextWindowMode:i3(r),outputLimit:o?.outputLimit?.toString()??""}})}function nd(e){const n=e.trim();if(n==="")return null;const s=Number(n);return!Number.isInteger(s)||s<=0?null:s}function Yn(e,n){if(e===void 0)return"";const s=e.trim(),o=s.replace(/\/+$/,"");return o.endsWith(n)?o.slice(0,-n.length).replace(/\/+$/,""):s}function c3(e,n,s){const o=e.trim();return o===""?null:t3(o,n,{providerName:s})}function Aa({baseUrl:e,endpoint:n,providerName:s}){const o=c3(e,n,s);return o===null?null:t.jsxs("div",{className:"border border-border bg-muted/40 rounded-md px-3 py-2 text-xs",children:[t.jsx("div",{className:"text-muted-foreground",children:"Final URL"}),t.jsx("div",{className:"break-all font-mono text-foreground",children:o.finalUrl}),o.diagnostics.length>0&&t.jsx("div",{className:"mt-2 space-y-1",children:o.diagnostics.map(r=>t.jsx("div",{className:r.severity==="warning"?"text-status-watch":"text-muted-foreground",children:r.message},`${r.severity}:${r.message}`))})]})}function d3({provider:e,onSubmit:n,onCancel:s}){const o=Kc(e),[r,a]=l.useState(e?.name??""),[i,c]=l.useState(""),[d,m]=l.useState(!1),[u,f]=l.useState(!1),p=e?.models,[h,g]=l.useState(p!==void 0&&p.length>0?p:[""]),[v,y]=l.useState(()=>td(e,p!==void 0&&p.length>0?p:[""])),[w,b]=l.useState(o.anthropic),[j,S]=l.useState(o.openai),[N,C]=l.useState(o.openaiChat),[R,I]=l.useState(o.openaiResponses),[P,M]=l.useState(Yn(e?.anthropicBaseUrl,jo)),[k,A]=l.useState(Yn(e?.openaiBaseUrl,So)),[D,$]=l.useState(Yn(e?.openaiResponsesBaseUrl,No)),[Y,Q]=l.useState(e?.apiDocsUrl??""),[U,H]=l.useState(e?.modelMetadataUrl??""),[X,B]=l.useState(e?.source),[W,pe]=l.useState({}),[ve,ye]=l.useState(!1),[re,z]=l.useState(null),Z=l.useRef([]);l.useEffect(()=>{if(re===null)return;const _=re;function L(K){if(!(K.target instanceof Node))return;const se=Z.current[_];se!=null&&!se.contains(K.target)&&z(null)}return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[re]);const[we,Ne]=l.useState(!1),[le,ce]=l.useState(!1),[ae,je]=l.useState(!1),_e=r.toLowerCase().includes("minimax"),Ie=r.toLowerCase().includes("alibaba"),Ue=[...Gc,...Yc].some(_=>r.toLowerCase().includes(_)),Me=_e?Jc:Ue?Zc:Ie?Xc:[],Be=e?.modelMetadata?.some(_=>_.contextWindow!==void 0)??!1;function ut(){vt(i).then(_=>{_&&(f(!0),setTimeout(()=>f(!1),2e3))})}l.useEffect(()=>{if(e){a(e.name),c(""),m(!1);const _=(e.models?.length??0)>0?e.models:[""];g(_),y(td(e,_));const L=Kc(e);b(L.anthropic),S(L.openai),C(L.openaiChat),I(L.openaiResponses),M(Yn(e.anthropicBaseUrl,jo)),A(Yn(e.openaiBaseUrl,So)),$(Yn(e.openaiResponsesBaseUrl,No)),Q(e.apiDocsUrl??""),H(e.modelMetadataUrl??""),B(e.source),Ne(!1),ce(!1),je(!1)}},[e]),l.useEffect(()=>{const _=r.toLowerCase();for(const[L,K]of Object.entries(a3))if(_.includes(L)){K.anthropicBaseUrl!==void 0&&!we&&M(K.anthropicBaseUrl),K.openaiBaseUrl!==void 0&&!le&&A(K.openaiBaseUrl),K.openaiResponsesBaseUrl!==void 0&&!ae&&$(K.openaiResponsesBaseUrl),K.apiDocsUrl!==void 0&&!Y&&Q(K.apiDocsUrl),L==="minimax"&&h.length===1&&h[0]===""&&g([Jc[0]??""]),L==="alibaba"&&h.length===1&&h[0]===""&&g([Xc[0]??""]),(Gc.includes(L)||Yc.includes(L))&&h.length===1&&h[0]===""&&g([Zc[0]??""]);break}},[r]);function Ge(){const _={};return r.trim()||(_.name="Name is required"),e===void 0&&!i.trim()&&(_.apiKey="API key is required"),(h.length===0||h.every(L=>!L.trim()))&&(_.models="At least one model is required"),!w&&!j&&(_.capabilities="Select at least one API capability"),j&&!N&&!R&&(_.openaiCapabilities="Select Chat Completions, Responses, or both"),w&&(P.trim()===""?_.anthropicBaseUrl="Anthropic base URL is required":Je(P.trim())||(_.anthropicBaseUrl="Invalid URL format")),j&&N&&(k.trim()===""?_.openaiBaseUrl="OpenAI Chat base URL is required":Je(k.trim())||(_.openaiBaseUrl="Invalid URL format")),j&&R&&(D.trim()===""?_.openaiResponsesBaseUrl="OpenAI Responses base URL is required":Je(D.trim())||(_.openaiResponsesBaseUrl="Invalid URL format")),U.trim()&&!Je(U.trim())&&(_.modelMetadataUrl="Invalid URL format"),v.forEach((L,K)=>{const se=Bo(L.contextWindow),de=nd(L.outputLimit);L.contextWindow.trim()!==""&&se===null&&(_[`modelMetadata.${K}.contextWindow`]="Context window must be a positive number, optionally using K or M"),L.outputLimit.trim()!==""&&de===null&&(_[`modelMetadata.${K}.outputLimit`]="Output limit must be a positive integer"),se!==null&&de!==null&&de>se&&(_[`modelMetadata.${K}.outputLimit`]="Output limit should not exceed context window")}),pe(_),Object.keys(_).length===0}function Je(_){try{return new URL(_),!0}catch{return!1}}function ht(_,L){g(K=>{const se=[...K];return se[_]=L,se})}function De(_,L){y(K=>{const se=[...K];return se[_]={...se[_]??Sn(),...L},se})}function F(_,L){switch(L){case yi:De(_,{contextWindow:"",contextWindowMode:"unset"});return;case ir:{const K=v[_]??Sn();De(_,{contextWindow:K.contextWindow,contextWindowMode:"custom"});return}default:De(_,{contextWindow:L,contextWindowMode:"preset"});return}}function ee(_,L){const K=v[_]??Sn(),se=Ma(K.contextWindow);De(_,{contextWindow:ed(L,se.unit),contextWindowMode:"custom"})}function ge(_,L){const K=v[_]??Sn(),se=Ma(K.contextWindow);switch(L){case"K":case"M":case"tokens":De(_,{contextWindow:ed(se.amount,L),contextWindowMode:"custom"});return;default:return}}function fe(_){g(L=>L.filter((K,se)=>se!==_)),y(L=>L.filter((K,se)=>se!==_))}function Se(){g(_=>[..._,""]),y(_=>[..._,Sn()])}function $e(){const _=new Date().toISOString(),L=[];return h.forEach((K,se)=>{const de=K.trim();if(de==="")return;const J=v[se]??Sn(),he=Bo(J.contextWindow),ue=nd(J.outputLimit);if(he===null&&ue===null)return;const Xt=zp(e,de);if(Xt!==null&&Xt.contextWindow===(he??void 0)&&Xt.outputLimit===(ue??void 0)){L.push({...Xt,model:de});return}const bn={model:de,source:"manual",updatedAt:_};he!==null&&(bn.contextWindow=he),ue!==null&&(bn.outputLimit=ue),L.push(bn)}),L.length>0?L:e?.modelMetadata!==void 0?[]:void 0}function G(_){if(_.preventDefault(),!Ge())return;ye(!0);const L=e!==void 0;try{n({name:r.trim(),apiKey:i.trim(),models:h.map(K=>K.trim()).filter(K=>K!==""),anthropicBaseUrl:Ra(w,P,L),openaiBaseUrl:Ra(j&&N,k,L),openaiResponsesBaseUrl:Ra(j&&R,D,L),apiDocsUrl:Y.trim()||void 0,modelMetadataUrl:U.trim()||void 0,modelMetadata:$e(),source:X})}finally{ye(!1)}}return t.jsxs("form",{onSubmit:G,className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{htmlFor:"provider-name",className:"text-sm font-medium",children:["Name ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsx("input",{id:"provider-name",type:"text",value:r,onChange:_=>a(_.target.value),placeholder:"Provider Name",className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50"}),W.name!==void 0&&t.jsx("p",{className:"text-xs text-destructive",children:W.name})]}),t.jsxs("fieldset",{className:"space-y-3",children:[t.jsxs("legend",{className:"text-sm font-medium",children:["Capabilities ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsxs("div",{className:"divide-y divide-border overflow-hidden rounded-md border border-border",children:[t.jsxs("div",{className:j?"bg-primary/[0.04] px-3 py-3":"px-3 py-3",children:[t.jsxs("label",{htmlFor:"provider-capability-openai",className:"flex cursor-pointer items-start gap-3",children:[t.jsx("input",{id:"provider-capability-openai",type:"checkbox",checked:j,onChange:_=>S(_.target.checked),className:"mt-0.5 size-4 shrink-0 accent-primary"}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block text-sm font-medium",children:"OpenAI"}),t.jsx("span",{className:"block text-xs text-muted-foreground",children:"Chat Completions and Responses"})]})]}),j&&t.jsxs("div",{className:"ml-7 mt-3 flex flex-wrap gap-x-5 gap-y-2 border-t border-border/70 pt-3",children:[t.jsxs("label",{htmlFor:"provider-capability-openai-chat",className:"flex cursor-pointer items-center gap-2 text-sm",children:[t.jsx("input",{id:"provider-capability-openai-chat",type:"checkbox",checked:N,onChange:_=>C(_.target.checked),className:"size-4 shrink-0 accent-primary"}),"Chat Completions"]}),t.jsxs("label",{htmlFor:"provider-capability-openai-responses",className:"flex cursor-pointer items-center gap-2 text-sm",children:[t.jsx("input",{id:"provider-capability-openai-responses",type:"checkbox",checked:R,onChange:_=>I(_.target.checked),className:"size-4 shrink-0 accent-primary"}),"Responses"]})]}),W.openaiCapabilities!==void 0&&j&&t.jsx("p",{className:"ml-7 mt-2 text-xs text-destructive",children:W.openaiCapabilities})]}),t.jsxs("label",{htmlFor:"provider-capability-anthropic",className:`flex cursor-pointer items-start gap-3 px-3 py-3 ${w?"bg-primary/[0.04]":""}`,children:[t.jsx("input",{id:"provider-capability-anthropic",type:"checkbox",checked:w,onChange:_=>b(_.target.checked),className:"mt-0.5 size-4 shrink-0 accent-primary"}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block text-sm font-medium",children:"Anthropic"}),t.jsx("span",{className:"block text-xs text-muted-foreground",children:"Messages"})]})]})]}),W.capabilities!==void 0&&t.jsx("p",{className:"text-xs text-destructive",children:W.capabilities})]}),(w||j&&(N||R))&&t.jsxs("section",{className:"space-y-5 border-l border-border pl-4","aria-label":"API endpoints",children:[t.jsx("h3",{className:"text-sm font-medium",children:"Endpoint Configuration"}),w&&t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{htmlFor:"provider-anthropic-base-url",className:"text-sm font-medium",children:["Anthropic Messages Base URL ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsxs("div",{className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground flex min-w-0 overflow-hidden rounded-md focus-within:border-ring focus-within:outline-ring focus-within:ring-[3px]",children:[t.jsx("input",{id:"provider-anthropic-base-url",type:"text",value:P,onChange:_=>{Ne(!0),M(_.target.value)},placeholder:"https://api.anthropic.com",className:"min-w-0 flex-1 bg-transparent px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"}),t.jsx("span",{className:"shrink-0 select-none border-l border-border bg-muted/35 px-3 py-2 font-mono text-xs text-muted-foreground",children:jo})]}),W.anthropicBaseUrl!==void 0&&t.jsx("p",{className:"text-xs text-destructive",children:W.anthropicBaseUrl}),t.jsx(Aa,{baseUrl:P,endpoint:jo,providerName:r})]}),j&&N&&t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{htmlFor:"provider-openai-base-url",className:"text-sm font-medium",children:["OpenAI Chat Base URL ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsxs("div",{className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground flex min-w-0 overflow-hidden rounded-md focus-within:border-ring focus-within:outline-ring focus-within:ring-[3px]",children:[t.jsx("input",{id:"provider-openai-base-url",type:"text",value:k,onChange:_=>{ce(!0),A(_.target.value)},placeholder:"https://api.openai.com",className:"min-w-0 flex-1 bg-transparent px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"}),t.jsx("span",{className:"shrink-0 select-none border-l border-border bg-muted/35 px-3 py-2 font-mono text-xs text-muted-foreground",children:So})]}),W.openaiBaseUrl!==void 0&&t.jsx("p",{className:"text-xs text-destructive",children:W.openaiBaseUrl}),t.jsx(Aa,{baseUrl:k,endpoint:So,providerName:r})]}),j&&R&&t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{htmlFor:"provider-openai-responses-base-url",className:"text-sm font-medium",children:["OpenAI Responses Base URL ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsxs("div",{className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground flex min-w-0 overflow-hidden rounded-md focus-within:border-ring focus-within:outline-ring focus-within:ring-[3px]",children:[t.jsx("input",{id:"provider-openai-responses-base-url",type:"text",value:D,onChange:_=>{je(!0),$(_.target.value)},placeholder:"https://api.openai.com",className:"min-w-0 flex-1 bg-transparent px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"}),t.jsx("span",{className:"shrink-0 select-none border-l border-border bg-muted/35 px-3 py-2 font-mono text-xs text-muted-foreground",children:No})]}),W.openaiResponsesBaseUrl!==void 0&&t.jsx("p",{className:"text-xs text-destructive",children:W.openaiResponsesBaseUrl}),t.jsx(Aa,{baseUrl:D,endpoint:No,providerName:r})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:"provider-source",className:"text-sm font-medium",children:"Token Source"}),t.jsxs("select",{id:"provider-source",value:X??"",onChange:_=>B(_.target.value==="company"||_.target.value==="personal"?_.target.value:void 0),className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx("option",{value:"",children:"Unspecified"}),t.jsx("option",{value:"personal",children:"个人 (Personal)"}),t.jsx("option",{value:"company",children:"公司 (Company)"})]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Label whether this API key is company-provided or personal."})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:"provider-model-metadata-url",className:"text-sm font-medium",children:"Model Metadata URL"}),t.jsx("input",{id:"provider-model-metadata-url",type:"text",value:U,onChange:_=>H(_.target.value),placeholder:"https://example.com/agent-inspector-models.json",className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50"}),W.modelMetadataUrl!==void 0&&t.jsx("p",{className:"text-xs text-destructive",children:W.modelMetadataUrl}),U.trim()===""&&t.jsx("div",{className:"border border-border bg-muted/40 rounded-md px-3 py-2 text-xs text-muted-foreground",children:"Built-in limits cover DeepSeek v4 pro/flash, MiniMax M3/M2.7/M2.5/M2.1, and GLM coding models. Use a registry URL for private or custom model limits."}),e!==void 0&&!Be&&U.trim()===""&&t.jsx("p",{className:"text-xs text-status-watch",children:"This provider has no matching context metadata yet."}),U.trim()!==""&&t.jsx("p",{className:"text-xs text-muted-foreground",children:"Agent Inspector will refresh model limits from this JSON registry after save."})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{htmlFor:"provider-apikey",className:"text-sm font-medium",children:["API Key ",e===void 0&&t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{id:"provider-apikey",type:d?"text":"password",value:i,onChange:_=>c(_.target.value),placeholder:e===void 0?"sk-ant-...":"Leave blank to keep current key",className:"flex-1 rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50"}),t.jsx("button",{type:"button",onClick:()=>m(_=>!_),className:"text-muted-foreground hover:text-foreground transition-colors p-1 shrink-0","aria-label":d?"Hide API key":"Show API key",children:d?t.jsx(H0,{className:"size-4"}):t.jsx(fu,{className:"size-4"})}),t.jsx("button",{type:"button",onClick:ut,className:"text-muted-foreground hover:text-foreground transition-colors p-1 shrink-0","aria-label":"Copy API key",children:u?t.jsx(Pe,{className:"size-4 text-status-success"}):t.jsx(St,{className:"size-4"})})]}),e!==void 0&&i.trim()===""&&t.jsx("p",{className:"text-xs text-muted-foreground",children:"A key is configured. Enter a new value only to rotate it."}),W.apiKey!==void 0&&t.jsx("p",{className:"text-xs text-destructive",children:W.apiKey})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{className:"text-sm font-medium",children:["Models ",t.jsx("span",{className:"text-destructive",children:"*"})]}),h.map((_,L)=>{const K=v[L]??Sn(),se=W[`modelMetadata.${L}.contextWindow`],de=W[`modelMetadata.${L}.outputLimit`],J=l3(K),he=Ma(K.contextWindow);return t.jsxs("div",{ref:ue=>{Z.current[L]=ue},className:"border border-border bg-card shadow-sm space-y-2 rounded-[8px] p-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("div",{className:"relative flex-1",children:[t.jsx("input",{type:"text",value:_,onChange:ue=>ht(L,ue.target.value),placeholder:Me.length>0?"Type or select a model...":"Model name",className:"w-full rounded-md border border-input bg-background px-4 py-3 pr-8 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50"}),Me.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>z(re===L?null:L),className:"absolute right-1 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors p-1 z-10","aria-label":"Show model suggestions",children:t.jsx(We,{className:"size-4"})}),re===L&&t.jsx("div",{className:"bg-popover text-popover-foreground absolute left-0 right-0 top-full z-50 mt-1 max-h-48 overflow-y-auto rounded-md border shadow-md",children:Me.map(ue=>t.jsx("button",{type:"button",onClick:()=>{ht(L,ue),z(null)},className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/60",children:ue},ue))})]})]}),h.length>1&&t.jsx("button",{type:"button",onClick:()=>fe(L),className:"text-muted-foreground hover:text-destructive transition-colors p-1 shrink-0","aria-label":"Remove model",children:t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M3 6h18"}),t.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),t.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]})})]}),t.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[t.jsxs("div",{className:"space-y-1 text-xs text-muted-foreground",children:[t.jsx("span",{children:"Context Window"}),t.jsxs(Bs,{value:J,onValueChange:ue=>F(L,ue),children:[t.jsx(qs,{size:"sm",className:"w-full bg-background font-mono text-xs",children:t.jsx(ar,{})}),t.jsxs(Hs,{className:"max-h-64",children:[t.jsx(Ze,{value:yi,children:"Not set"}),Dp.map(ue=>t.jsxs(Ze,{value:ue.value,children:[ue.label," · ",ue.value]},ue.value)),t.jsx(Ze,{value:ir,children:"Custom"})]})]}),K.contextWindowMode==="custom"&&t.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_5.75rem] gap-1.5",children:[t.jsx("input",{type:"text",inputMode:"decimal",value:he.amount,onChange:ue=>ee(L,ue.target.value),placeholder:"128",className:"w-full rounded-md border border-input bg-background px-3 py-2 font-mono text-xs text-foreground ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px]"}),t.jsxs(Bs,{value:he.unit,onValueChange:ue=>ge(L,ue),children:[t.jsx(qs,{size:"sm",className:"w-full bg-background font-mono text-xs",children:t.jsx(ar,{})}),t.jsxs(Hs,{children:[t.jsx(Ze,{value:"K",children:"K"}),t.jsx(Ze,{value:"M",children:"M"}),t.jsx(Ze,{value:"tokens",children:"tokens"})]})]})]}),se!==void 0&&t.jsx("span",{className:"block text-destructive",children:se})]}),t.jsxs("label",{className:"space-y-1 text-xs text-muted-foreground",children:[t.jsx("span",{children:"Output Limit"}),t.jsx("input",{type:"number",min:1,step:1e3,value:K.outputLimit,onChange:ue=>De(L,{outputLimit:ue.target.value}),placeholder:"e.g. 8192",className:"w-full rounded-md border border-input bg-background px-3 py-2 font-mono text-xs text-foreground ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px]"}),de!==void 0&&t.jsx("span",{className:"block text-destructive",children:de})]})]})]},L)}),t.jsx("button",{type:"button",onClick:Se,className:"text-xs text-primary hover:underline flex items-center gap-1",children:"+ Add Model"}),W.models!==void 0&&t.jsx("p",{className:"text-xs text-destructive",children:W.models})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:"provider-api-docs-url",className:"text-sm font-medium",children:"API Docs URL"}),t.jsx("input",{id:"provider-api-docs-url",type:"text",value:Y,onChange:_=>Q(_.target.value),placeholder:"https://api.example.com/docs",className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional API documentation URL. If not set, uses known provider docs."})]}),t.jsxs("div",{className:"border border-border bg-background/95 shadow-sm sticky bottom-0 flex justify-end gap-2 rounded-[8px] px-3 py-2",children:[t.jsx(te,{type:"button",variant:"outline",onClick:s,disabled:ve,children:"Cancel"}),t.jsx(te,{type:"submit",disabled:ve,children:ve?"Saving...":e?"Update Provider":"Add Provider"})]})]})}const u3=me(["timeout","network_unreachable","connection_refused","auth_failed","rate_limited","server_error","invalid_response","unknown"]),m3=T({message:x(),type:u3,details:x().optional(),hint:x().optional()}),f3=T({type:me(["text","thinking"]),text:x().optional(),thinking:x().optional()}),p3=T({requestUrl:x().optional(),requestMethod:x().optional(),requestHeaders:Oe(x(),x()).optional(),requestBody:x().optional(),responseStatus:E().optional(),responseStatusText:x().optional(),responseHeaders:Oe(x(),x()).optional(),responseBody:x().optional()}),h3=T({success:ke(),error:m3.optional(),model:x().optional(),inputTokens:E().optional(),outputTokens:E().optional(),cacheCreationInputTokens:E().optional(),cacheReadInputTokens:E().optional(),latencyMs:E().optional(),firstChunkMs:E().nullable().optional(),totalStreamMs:E().nullable().optional(),tokensPerSecond:E().nullable().optional(),content:V(f3).optional(),rawResponse:x().optional(),streaming:ke().optional(),streamingChunks:T({chunks:V(Hd),truncated:ke().default(!1)}).optional(),requestHeaders:Oe(x(),x()).optional(),debug:p3.optional()}),sd=Dt([h3,T({notConfigured:oe(!0)}),T({testing:oe(!0)})]),ln=T({nonStreaming:sd,streaming:sd});function lr(){return{nonStreaming:{notConfigured:!0},streaming:{notConfigured:!0}}}const x3=T({anthropic:ln,openai:ln.optional(),openaiChat:ln.optional(),openaiResponses:ln.optional()}).transform(e=>{const n=e.openaiChat??e.openai??lr();return{...e,openai:e.openai??n,openaiChat:n,openaiResponses:e.openaiResponses??lr()}}),g3=T({anthropic:ln,openai:ln.optional(),openaiChat:ln.optional(),openaiResponses:ln.optional(),models:Oe(x(),x3).optional(),testedAt:x().optional()}).transform(e=>{const n=e.openaiChat??e.openai??lr();return{...e,openai:e.openai??n,openaiChat:n,openaiResponses:e.openaiResponses??lr()}});function b3(){return{anthropic:{nonStreaming:{testing:!0},streaming:{testing:!0}},openai:{nonStreaming:{testing:!0},streaming:{testing:!0}},openaiChat:{nonStreaming:{testing:!0},streaming:{testing:!0}},openaiResponses:{nonStreaming:{testing:!0},streaming:{testing:!0}}}}function od(e,n){const s=()=>({nonStreaming:{success:!1,error:{message:e,type:n}},streaming:{notConfigured:!0}});return{anthropic:s(),openai:s(),openaiChat:s(),openaiResponses:s()}}const v3=T({providerConfig:x()}),y3=T({success:ke().optional(),imported:E().optional(),message:x().optional(),errors:V(x()).optional()}),w3=T({provider:Go,imported:E(),matchedModels:V(x()),missingModels:V(x()),sourceUrl:x()}),Co="Network error: could not reach the server. Is the proxy running?",j3=5e3,S3=5e3,rd=15e3,N3=1e4,C3=2e4,k3=2e4,_3=3e4;function Ia(e,n){return(e?.length??0)>0?e:n&&e!==void 0?"":void 0}function ad(e,n=!1){return{name:e.name,...e.apiKey.trim()===""?{}:{apiKey:e.apiKey},models:e.models,anthropicBaseUrl:Ia(e.anthropicBaseUrl,n),openaiBaseUrl:Ia(e.openaiBaseUrl,n),openaiResponsesBaseUrl:Ia(e.openaiResponsesBaseUrl,n),apiDocsUrl:(e.apiDocsUrl?.length??0)>0?e.apiDocsUrl:void 0,modelMetadataUrl:(e.modelMetadataUrl?.length??0)>0?e.modelMetadataUrl:void 0,modelMetadata:e.modelMetadata,source:e.source}}function T3(e,n){const s=e?.models?.map(o=>o.trim()).filter(o=>o!=="").length??0;return Math.max(1,s)*n}async function E3(e,n){if(n.models!==void 0)try{await _n(`/api/providers/${e}/test/log`,S3,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}catch{}}function R3({externalProviders:e,isLoading:n=!1,externalTestResults:s,externalTestingProviders:o,externalTestingTimeLeft:r,onProvidersMutate:a,onTestResultsChange:i,onTestingProvidersChange:c,onTestingTimeLeftChange:d}){const[m,u]=l.useState(!1),[f,p]=l.useState(),[h,g]=l.useState(null),[v,y]=l.useState({}),[w,b]=l.useState(new Set),[j,S]=l.useState({}),[N,C]=l.useState(null),[R,I]=l.useState(!1),[P,M]=l.useState(null),[k,A]=l.useState(!1),[D,$]=l.useState(!1),[Y,Q]=l.useState(null),[U,H]=l.useState("all"),[X,B]=l.useState(new Set),{providerTestTimeoutSeconds:W}=$i(),pe=l.useRef(null),ve=l.useRef(null),ye=e??[],re=l.useMemo(()=>{const F=U==="all"?ye:ye.filter(ee=>ee.source===U);return U==="all"?[...F].sort((ee,ge)=>{const fe={personal:0,company:1};return(fe[ee.source??""]??2)-(fe[ge.source??""]??2)}):F},[ye,U]),z=s??v,Z=o??w,we=r??j,Ne=d?(F,ee)=>d(F,ee):(F,ee)=>{S(ee===void 0?ge=>{const fe={...ge};return delete fe[F],fe}:ge=>({...ge,[F]:ee}))};l.useEffect(()=>{(async()=>{try{const F=await Le("/api/config/paths",v3,j3);C(F.providerConfig)}catch{}})()},[]);const le=l.useCallback(F=>{ve.current!==null&&clearTimeout(ve.current),M(F),pe.current?.scrollTo({top:pe.current.scrollHeight,behavior:"smooth"}),ve.current=setTimeout(()=>{M(null),ve.current=null},2e3)},[]);l.useEffect(()=>()=>{ve.current!==null&&clearTimeout(ve.current)},[]);const ce=l.useCallback(()=>{a?.().catch(()=>{})},[a]),ae=l.useCallback((F,ee)=>{i?i(F,ee):y(ge=>({...ge,[F]:ee}))},[i]),je=l.useCallback((F,ee)=>{if(c){c(F,ee);return}b(ge=>{const fe=new Set(ge);return ee?fe.add(F):fe.delete(F),fe})},[c]),_e=l.useCallback(async F=>{ae(F,b3()),je(F,!0);const ee=new AbortController,ge=ye.find(G=>G.id===F),fe=T3(ge,W);let Se=fe;Ne(F,Se);const $e=setInterval(()=>{Se--,Ne(F,Se),Se<=0&&(clearInterval($e),ee.abort())},1e3);try{const G=await Le(`/api/providers/${F}/test`,g3,fe*1e3+1e3,{method:"POST",signal:ee.signal},_=>`HTTP ${_.status}: ${_.statusText}`);ae(F,G),await E3(F,G)}catch(G){const _=G instanceof Error&&G.name==="AbortError",L=G instanceof ki;_||L?ae(F,od("Request timed out","timeout")):G instanceof Error&&ae(F,od(G.message,"server_error"))}finally{clearInterval($e),Ne(F,void 0),je(F,!1)}},[W,ye,Ne,ae,je]),Ie=l.useCallback(async(F,ee,ge=!0)=>{B(fe=>{const Se=new Set(fe);return Se.add(F),Se});try{const fe=ee!==void 0&&ee.trim()!==""?{url:ee}:{},Se=await Le(`/api/providers/${F}/model-metadata`,w3,_3,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(fe)},()=>"Failed to refresh model metadata");return Se.imported===0&&ge?g("No matching model metadata found for this provider."):g(null),le(Se.provider.id),ce(),Se.imported>0}catch(fe){return ge&&g(fe instanceof Error?fe.message:Co),!1}finally{B(fe=>{const Se=new Set(fe);return Se.delete(F),Se})}},[ce,le]);function Ue(F){(async()=>{try{const ee=await Le("/api/providers",Go,rd,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ad(F))},()=>"Failed to add provider");u(!1),le(ee.id),F.modelMetadataUrl!==void 0&&F.modelMetadataUrl.trim()!==""&&await Ie(ee.id,F.modelMetadataUrl,!1),ce(),await _e(ee.id)}catch(ee){g(ee instanceof Error?ee.message:Co)}})()}function Me(F){f&&(async()=>{try{const ee=await Le(`/api/providers/${f.id}`,Go,rd,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(ad(F,!0))},()=>"Failed to update provider");p(void 0),le(ee.id),F.modelMetadataUrl!==void 0&&F.modelMetadataUrl.trim()!==""&&await Ie(ee.id,F.modelMetadataUrl,!1),ce(),(F.apiKey.trim()!==""||JSON.stringify(F.models)!==JSON.stringify(f.models)||(F.anthropicBaseUrl??"")!==(f.anthropicBaseUrl??"")||(F.openaiBaseUrl??"")!==(f.openaiBaseUrl??"")||(F.openaiResponsesBaseUrl??"")!==(f.openaiResponsesBaseUrl??""))&&await _e(ee.id)}catch(ee){g(ee instanceof Error?ee.message:Co)}})()}function Be(F){Q(F),$(!0)}function ut(){const F=Y;F!==null&&(async()=>{let ee;try{ee=await _n(`/api/providers/${F}`,N3,{method:"DELETE"})}catch{g(Co);return}if(!ee.ok){g(await Mh(ee,"Failed to delete provider"));return}ce()})()}const Ge=l.useRef(null);function Je(F){const ee="/api/providers/export";(async()=>{try{const ge=await _n(ee,C3);if(!ge.ok){g("Failed to export providers");return}const fe=await ge.blob(),Se=URL.createObjectURL(fe),$e=document.createElement("a");$e.href=Se,$e.download=ge.headers.get("Content-Disposition")?.match(/filename="(.+)"/)?.[1]??"providers.json",document.body.appendChild($e),$e.click(),document.body.removeChild($e),URL.revokeObjectURL(Se)}catch{g("Failed to export providers")}})()}function ht(){Ge.current?.click()}function De(F){const ee=F.target.files?.[0];ee&&(async()=>{try{const ge=await ee.text(),fe=await _n("/api/providers/import",k3,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ge)}),Se=await Rh(fe,y3);fe.ok&&Se.imported!==void 0&&Se.imported>0?(ce(),g(null)):Se.errors&&Se.errors.length>0?g(Se.errors.join("; ")):g(Se.message??"Import failed")}catch{g("Failed to import providers")}F.target.value=""})()}return n?t.jsx("div",{className:"flex items-center justify-center py-8",children:t.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading providers..."})}):m||f?t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"sticky top-0 z-10 flex items-center justify-between gap-3 rounded-[8px] bg-background/95 px-1 py-1 backdrop-blur",children:t.jsx("h3",{className:"text-lg font-medium",children:f?"Edit Provider":"Add New Provider"})}),t.jsx(d3,{provider:f,onSubmit:f?Me:Ue,onCancel:()=>{u(!1),p(void 0)}})]}):t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{"data-provider-toolbar":"true",className:"sticky top-0 z-10 flex min-w-0 flex-wrap items-center justify-start gap-2 rounded-[8px] bg-background/95 px-1 py-1 backdrop-blur sm:justify-end",children:[t.jsxs(te,{variant:"outline",size:"sm",onClick:()=>Je(),className:"gap-1 hover:bg-muted",children:[t.jsx(Gs,{className:"size-3"}),"Export"]}),t.jsxs(te,{variant:"outline",size:"sm",onClick:ht,className:"gap-1 hover:bg-muted",children:[t.jsx(ju,{className:"size-3"}),"Import"]}),t.jsx("input",{type:"file",ref:Ge,accept:".json",onChange:De,style:{display:"none"}}),t.jsxs(te,{variant:"outline",size:"sm",onClick:()=>A(!0),className:"gap-1",children:[t.jsx(Zg,{className:"size-3"}),"Scan"]}),t.jsxs(te,{onClick:()=>u(!0),size:"sm",className:"gap-1",children:[t.jsx(Wl,{className:"size-4"}),"Add Provider"]})]}),N!==null&&t.jsxs("div",{className:"flex items-center gap-2 rounded-[8px] bg-muted/15 px-3 py-2 text-xs text-muted-foreground",children:[t.jsx("span",{className:"font-mono truncate",title:N,children:N}),t.jsx("button",{type:"button",onClick:()=>{vt(N).then(F=>{F&&(I(!0),setTimeout(()=>I(!1),2e3))})},className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-foreground","aria-label":R?"Copied config file path":"Copy config file path",children:R?t.jsx(Pe,{className:"size-3 text-status-success"}):t.jsx(St,{className:"size-3"})})]}),h!==null&&t.jsxs("div",{className:"border border-border bg-card shadow-sm flex items-center gap-2 rounded-[8px] px-3 py-2 text-sm text-destructive",children:[t.jsx(is,{className:"size-4 shrink-0"}),h]}),ye.length===0?t.jsxs("div",{className:"border border-border bg-card shadow-sm space-y-3 rounded-[8px] py-12 text-center",children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:"No providers configured yet."}),t.jsxs(te,{onClick:()=>u(!0),variant:"outline",size:"sm",children:[t.jsx(Wl,{className:"size-4"}),"Add Your First Provider"]})]}):t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{className:"inline-flex w-fit gap-1 rounded-[8px] bg-muted/20 p-1",children:["all","personal","company"].map(F=>t.jsx("button",{type:"button",onClick:()=>H(F),className:`rounded-md px-3 py-1.5 text-sm font-medium transition-colors ${U===F?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:F==="all"?"All":F==="personal"?"Personal":"Company"},F))}),t.jsx("div",{ref:pe,className:"space-y-3",children:re.map(F=>t.jsx(Zk,{provider:F,testResults:z[F.id],isTesting:Z.has(F.id),testingTimeLeft:we[F.id],isHighlighted:F.id===P,onEdit:ee=>p(ee),onDelete:Be,onRefreshMetadata:ee=>{Ie(ee)},isRefreshingMetadata:X.has(F.id),onTest:ee=>{_e(ee)}},F.id))})]}),t.jsx(Tk,{open:k,onOpenChange:A,onImportComplete:()=>{a!==void 0&&a()}}),t.jsx(Gf,{open:D,onOpenChange:$,title:"Delete Provider",description:"Are you sure you want to delete this provider? This action cannot be undone.",confirmLabel:"Delete",variant:"destructive",onConfirm:ut})]})}const M3=[{value:"providers",label:"Providers"},{value:"proxy",label:"Proxy"},{value:"storage",label:"Storage"},{value:"mcp",label:"MCP"},{value:"onboarding",label:"Onboarding"}];function A3(){return t.jsx(dp,{"aria-label":"Settings sections",className:"grid w-full grid-cols-3 justify-stretch gap-1 bg-muted/35 p-1 group-data-[orientation=horizontal]/tabs:h-auto sm:grid-cols-5",children:M3.map(e=>t.jsx(Wt,{value:e.value,className:"min-w-0 w-full",children:e.label},e.value))})}function I3(){const[e,n]=l.useState(!1),[s,o]=l.useState("providers"),{providers:r,isLoading:a,mutate:i}=Yi(),[c,d]=l.useState({}),[m,u]=l.useState(new Set),[f,p]=l.useState({}),h=l.useCallback((y,w)=>{d(b=>({...b,[y]:w}))},[]),g=l.useCallback((y,w)=>{u(b=>{const j=new Set(b);return w?j.add(y):j.delete(y),j})},[]),v=l.useCallback((y,w)=>{p(b=>{if(w===void 0){const j={...b};return delete j[y],j}return{...b,[y]:w}})},[]);return t.jsxs(Lt,{open:e,onOpenChange:n,children:[t.jsx(eo,{asChild:!0,children:t.jsxs(te,{variant:"ghost",size:"icon",className:so,"aria-label":"Settings",title:"Settings",children:[t.jsx(a1,{className:"size-4"}),t.jsx("span",{className:"sr-only",children:"Settings"})]})}),t.jsxs(Ot,{className:"flex max-h-[calc(100vh-1rem)] w-[calc(100%-1rem)] max-w-2xl flex-col overflow-hidden p-4 sm:max-h-[80vh] sm:p-6",children:[t.jsx(Ut,{children:t.jsx(Bt,{children:"Settings"})}),t.jsxs(cp,{value:s,onValueChange:o,className:"min-h-0 min-w-0 flex-1 overflow-hidden",children:[t.jsx(A3,{}),t.jsxs("div",{className:"mt-4 min-w-0 flex-1 overflow-x-hidden overflow-y-auto pr-1 sm:pr-2",children:[t.jsx(tt,{value:"providers",children:t.jsx(R3,{externalProviders:r,isLoading:a,externalTestResults:c,externalTestingProviders:m,externalTestingTimeLeft:f,onProvidersMutate:()=>i(),onTestResultsChange:h,onTestingProvidersChange:g,onTestingTimeLeftChange:v})}),t.jsx(tt,{value:"proxy",children:t.jsx($3,{})}),t.jsx(tt,{value:"storage",children:t.jsx(O3,{})}),t.jsx(tt,{value:"mcp",children:t.jsx(z3,{})}),t.jsx(tt,{value:"onboarding",children:t.jsx(D3,{})})]})]})]})]})}const P3=T({memoryCount:E(),logDir:x(),logFileCount:E(),logBytes:E(),chunkDir:x(),chunkFileCount:E(),chunkBytes:E(),sessionArchiveDir:x(),sessionArchiveFileCount:E(),sessionArchiveBytes:E()}),L3=1e4;function Pa(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KiB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)} MiB`:`${(e/1024/1024/1024).toFixed(1)} GiB`}function O3(){const[e,n]=l.useState(null),[s,o]=l.useState(null),[r,a]=l.useState(!1),[i,c]=l.useState(null),d=l.useCallback(async()=>{a(!0),o(null);try{const u=await Le("/api/logs?stats=1",P3,L3,void 0,f=>`Failed to load storage stats: HTTP ${String(f.status)}`);n(u)}catch(u){o(u instanceof Error?u.message:String(u))}finally{a(!1)}},[]);l.useEffect(()=>{d()},[d]);const m=l.useCallback((u,f)=>{vt(f).then(p=>{p&&(c(u),setTimeout(()=>c(null),1600))})},[]);return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Log storage"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Inspect local log and streaming chunk footprint before exporting or clearing sessions."})]}),t.jsx(te,{type:"button",variant:"outline",size:"sm",onClick:()=>{d()},children:r?"Refreshing...":"Refresh"})]}),e!==null&&t.jsxs("div",{className:"grid gap-2 text-xs",children:[t.jsx(As,{id:"log-dir",label:"Log storage path",value:e.logDir,copiedId:i,onCopy:m}),t.jsx(As,{id:"chunk-dir",label:"Streaming chunks storage path",value:e.chunkDir,copiedId:i,onCopy:m}),t.jsx(As,{id:"session-archive-dir",label:"Session archive storage path",value:e.sessionArchiveDir,copiedId:i,onCopy:m}),t.jsxs("div",{className:"rounded-md bg-muted/20 px-3 py-2",children:[t.jsx("div",{className:"font-medium",children:"In-memory logs"}),t.jsxs("div",{className:"mt-1 font-mono text-muted-foreground",children:[e.memoryCount.toLocaleString()," loaded"]})]}),t.jsxs("div",{className:"rounded-md bg-muted/20 px-3 py-2",children:[t.jsx("div",{className:"font-medium",children:"Log files"}),t.jsxs("div",{className:"mt-1 font-mono text-muted-foreground",children:[e.logFileCount.toLocaleString()," files / ",Pa(e.logBytes)]})]}),t.jsxs("div",{className:"rounded-md bg-muted/20 px-3 py-2",children:[t.jsx("div",{className:"font-medium",children:"Streaming chunks"}),t.jsxs("div",{className:"mt-1 font-mono text-muted-foreground",children:[e.chunkFileCount.toLocaleString()," files / ",Pa(e.chunkBytes)]})]}),t.jsxs("div",{className:"rounded-md bg-muted/20 px-3 py-2",children:[t.jsx("div",{className:"font-medium",children:"Session archives"}),t.jsxs("div",{className:"mt-1 font-mono text-muted-foreground",children:[e.sessionArchiveFileCount.toLocaleString()," files /"," ",Pa(e.sessionArchiveBytes)]})]})]}),s!==null&&t.jsx("p",{className:"text-xs text-destructive",children:s})]})}function As({id:e,label:n,value:s,copiedId:o,onCopy:r}){const a=o===e;return t.jsxs("div",{className:"min-w-0 rounded-md border border-border/45 bg-muted/15 px-3 py-2 transition-colors hover:bg-muted/25",children:[t.jsx("div",{className:"mb-1 text-xs font-medium text-muted-foreground",children:n}),t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs text-foreground",title:s,children:s}),t.jsx(te,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0",onClick:()=>r(e,s),"aria-label":a?`Copied ${n}`:`Copy ${n}`,children:a?t.jsx(Pe,{className:"size-3.5 text-status-success"}):t.jsx(St,{className:"size-3.5"})})]})]})}function D3(){const[e,n]=l.useState(null),[s,o]=l.useState(null);l.useEffect(()=>Hi(o),[]);const r=l.useMemo(()=>[{id:"status",label:"Check onboarding",value:"agent-inspector onboard --status"},{id:"status-json",label:"Check onboarding JSON",value:"agent-inspector onboard --status --json"},{id:"refresh",label:"Refresh generated files",value:"agent-inspector onboard --force"},{id:"uninstall",label:"Remove matching generated files",value:"agent-inspector onboard --uninstall"},{id:"claude",label:"Claude Code command",value:"/agent-inspector:onboard"},{id:"codex",label:"Codex prompt",value:"Use the agent-inspector-onboard skill"},{id:"opencode-config",label:"OpenCode config",value:"agent-inspector onboard --opencode-only"},{id:"opencode-status",label:"OpenCode status",value:"agent-inspector onboard --status --opencode-only"},{id:"opencode-verify",label:"OpenCode verify",value:"opencode mcp list"},{id:"mimo-config",label:"MiMo Code config",value:"agent-inspector onboard --mimo-only"},{id:"mimo-status",label:"MiMo Code status",value:"agent-inspector onboard --status --mimo-only"},{id:"mimo-verify",label:"MiMo Code verify",value:"mimo mcp list"},...s===null?[]:[{id:"opencode-proxy",label:"OpenCode proxy",value:`LLM_BASE_URL=${s.proxy}`},{id:"mimo-proxy",label:"MiMo Code proxy",value:`OPENAI_BASE_URL=${s.openAiV1}`},{id:"mcp",label:"MCP URL",value:s.mcp},{id:"proxy",label:"Proxy URL",value:s.proxy},{id:"anthropic",label:"Anthropic base",value:`ANTHROPIC_BASE_URL=${s.proxy}`},{id:"openai",label:"OpenAI base",value:`OPENAI_BASE_URL=${s.openAiV1}`}]],[s]),a=l.useCallback((i,c)=>{vt(c).then(d=>{d&&(n(i),setTimeout(()=>n(null),1600))})},[]);return t.jsxs("div",{className:"min-w-0 space-y-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ln,{className:"size-4 text-muted-foreground"}),t.jsx("h3",{className:"text-sm font-semibold",children:"Agent onboarding"})]}),t.jsx("div",{className:"grid gap-2",children:r.map(i=>t.jsx(As,{id:i.id,label:i.label,value:i.value,copiedId:e,onCopy:a},i.id))}),t.jsxs("div",{className:"grid gap-2 rounded-md bg-muted/15 px-3 py-2 text-xs text-muted-foreground",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Pe,{className:"size-3.5 text-status-success"}),t.jsx("span",{children:"Provider test creates a traceable memory probe session."})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Pe,{className:"size-3.5 text-status-success"}),t.jsx("span",{children:"Captured sessions can produce reviewable memory candidates."})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(Pe,{className:"mt-0.5 size-3.5 text-status-success"}),t.jsxs("span",{children:["Streamable HTTP clients should use the MCP URL directly. Stdio-only clients should use",t.jsx("code",{className:"mx-1 rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"agent-inspector-mcp stdio"}),"instead. Configure only one entry for the same Inspector."]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(Pe,{className:"mt-0.5 size-3.5 text-status-success"}),t.jsxs("span",{children:["OpenCode onboarding safely merges"," ",t.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"mcp.agent-inspector"})," ","into"," ",t.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"opencode.json"}),", then verify with"," ",t.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"opencode mcp list"}),"."]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(Pe,{className:"mt-0.5 size-3.5 text-status-success"}),t.jsxs("span",{children:["MiMo Code onboarding safely merges"," ",t.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"mcp.agent-inspector"})," ","into"," ",t.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"mimocode.jsonc"}),", then route OpenAI-format traffic with"," ",t.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"OPENAI_BASE_URL"}),"."]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(Pe,{className:"mt-0.5 size-3.5 text-status-success"}),t.jsx("span",{children:"If your AI tool runs in another container or host, replace localhost with an address reachable from that tool and verify the network/firewall path."})]})]})]})}function z3(){const[e,n]=l.useState(null),[s,o]=l.useState(null);l.useEffect(()=>Hi(i=>{o(i?.mcp??null)}),[]);const r=l.useMemo(()=>s===null?[]:[{id:"mcp-url",label:"Streamable HTTP MCP URL",value:s},{id:"stdio",label:"Stdio bridge command",value:`agent-inspector-mcp stdio --url ${s}`},{id:"doctor",label:"Bridge doctor",value:`agent-inspector-mcp doctor --url ${s}`},{id:"writes",label:"Enable write tools",value:"AGENT_INSPECTOR_MCP_WRITES=1 agent-inspector"},{id:"capabilities",label:"Capabilities resource",value:"inspector://mcp/capabilities"},{id:"context",label:"Current context resource",value:"inspector://context/current"},{id:"streamable-json",label:"Streamable HTTP JSON",value:JSON.stringify({mcpServers:{"agent-inspector":{type:"streamableHttp",url:s}}},null,2)},{id:"stdio-json",label:"Stdio MCP JSON",value:JSON.stringify({mcpServers:{"agent-inspector":{command:"agent-inspector-mcp",args:["stdio","--url",s]}}},null,2)},{id:"opencode-local",label:"OpenCode local MCP",value:JSON.stringify({mcp:{"agent-inspector":{type:"local",command:["agent-inspector-mcp","stdio","--url",s],enabled:!0}}},null,2)},{id:"mimo-local",label:"MiMo Code local MCP",value:JSON.stringify({mcp:{"agent-inspector":{type:"local",command:["agent-inspector-mcp","stdio","--url",s],enabled:!0}}},null,2)},{id:"codex-toml",label:"Codex TOML",value:`[mcp_servers.agent-inspector]
|
|
58
|
-
command = "agent-inspector-mcp"
|
|
59
|
-
args = ["stdio", "--url", "${s}"]`}],[s]),a=l.useCallback((i,c)=>{vt(c).then(d=>{d&&(n(i),setTimeout(()=>n(null),1600))})},[]);return t.jsxs("div",{className:"min-w-0 space-y-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ln,{className:"size-4 text-muted-foreground"}),t.jsx("h3",{className:"text-sm font-semibold",children:"MCP access"})]}),t.jsxs("div",{className:"grid gap-2 rounded-md bg-muted/15 px-3 py-2 text-xs text-muted-foreground",children:[t.jsx("div",{children:"Use Streamable HTTP when the client supports URL-based MCP. Use the stdio bridge only for stdio-only clients. Configure one entry for the same Inspector instance."}),t.jsx("div",{children:"If the MCP client runs in another container or host, replace localhost with a reachable host/IP and verify the network path."})]}),s===null?t.jsx("div",{role:"alert",className:"rounded-md bg-destructive/10 px-3 py-2 text-xs text-destructive",children:"The browser runtime does not provide a valid agent-facing MCP endpoint."}):t.jsx("div",{className:"grid gap-2",children:r.map(i=>t.jsx(As,{id:i.id,label:i.label,value:i.value,copiedId:e,onCopy:a},i.id))})]})}function $3(){const{strip:e,slowResponseThresholdSeconds:n,providerTestTimeoutSeconds:s,timeDisplayFormat:o,isLoading:r,setStrip:a,setSlowResponseThresholdSeconds:i,setProviderTestTimeoutSeconds:c,setTimeDisplayFormat:d}=$i(),[m,u]=l.useState(null),[f,p]=l.useState(!1),h=l.useCallback(async w=>{u(null),p(!0);try{await a(w)}catch(b){u(b instanceof Error?b.message:String(b))}finally{p(!1)}},[a]),g=l.useCallback(async w=>{u(null),p(!0);try{await i(w)}catch(b){u(b instanceof Error?b.message:String(b))}finally{p(!1)}},[i]),v=l.useCallback(async w=>{u(null),p(!0);try{await c(w)}catch(b){u(b instanceof Error?b.message:String(b))}finally{p(!1)}},[c]),y=l.useCallback(async w=>{u(null),p(!0);try{await d(w)}catch(b){u(b instanceof Error?b.message:String(b))}finally{p(!1)}},[d]);return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Claude Code billing header"}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Strip Claude Code's synthetic billing block before upstream forwarding. This can improve prefix-cache hits with third-party providers and is persisted to ",t.jsx("code",{children:"config.json"}),"."]})]}),t.jsxs("label",{className:"flex items-center gap-3",children:[t.jsx("input",{type:"checkbox",role:"switch",checked:e,disabled:r||f,onChange:w=>{h(w.currentTarget.checked)},className:"size-4 cursor-pointer disabled:cursor-not-allowed disabled:opacity-50"}),t.jsx("span",{className:"text-sm",children:r?"Loading...":e?"Stripping enabled":"Stripping disabled"})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{htmlFor:"slow-response-threshold",className:"text-sm font-semibold",children:"Slow response threshold"}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Show a slow marker when elapsed time exceeds this many seconds. Use ",t.jsx("code",{children:"0"})," to disable it."]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{id:"slow-response-threshold",type:"number",min:0,max:Ba,step:1,value:n,disabled:r||f,onChange:w=>{const b=Number(w.currentTarget.value);Number.isInteger(b)&&(b<0||b>Ba||g(b))},className:"h-8 w-24 rounded-md border border-input bg-transparent px-2 text-sm font-mono disabled:cursor-not-allowed disabled:opacity-50"}),t.jsx("span",{className:"text-xs text-muted-foreground",children:"seconds"})]})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{htmlFor:"provider-test-timeout",className:"text-sm font-semibold",children:"Provider test timeout"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Abort slow Provider Test probes after this many seconds per model."}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{id:"provider-test-timeout",type:"number",min:1,max:qa,step:1,value:s,disabled:r||f,onChange:w=>{const b=Number(w.currentTarget.value);Number.isInteger(b)&&(b<1||b>qa||v(b))},className:"h-8 w-24 rounded-md border border-input bg-transparent px-2 text-sm font-mono disabled:cursor-not-allowed disabled:opacity-50"}),t.jsx("span",{className:"text-xs text-muted-foreground",children:"seconds / model"})]})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{htmlFor:"time-display-format",className:"text-sm font-semibold",children:"Time display"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Controls timestamps in session summaries, headers, and log rows."}),t.jsxs("select",{id:"time-display-format",value:o,disabled:r||f,onChange:w=>{const b=lu.safeParse(w.currentTarget.value);b.success&&y(b.data)},className:"h-8 rounded-md border border-input bg-background px-2 text-sm disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx("option",{value:"time",children:"Time only"}),t.jsx("option",{value:"full",children:"Full ISO"})]})]}),m!==null&&t.jsxs("p",{className:"text-xs text-destructive",children:["Failed to save: ",m]})]})}const F3=me(["installed","update-available","available","planned","unknown"]),U3=T({id:x(),name:x(),npmName:x(),capability:x(),description:x(),workflow:x(),installCommand:x(),state:F3,installedVersion:x().nullable(),latestVersion:x().nullable(),primary:ke()}),B3=T({id:x(),name:x(),validatedVersion:x(),binary:x(),modelFlag:x(),variantFlag:x().nullable(),tools:V(x()),logDir:x(),skillsDir:x(),agentsDir:x()}),q3=T({id:x(),title:x(),stage:x(),packageId:x(),description:x(),command:x(),requiresSession:ke(),runnable:ke()}),H3=T({checkedAt:x(),packages:V(U3),runnerPresets:V(B3),recipes:V(q3)}),Fp=me(["install","upgrade","help","runner-presets","recipe"]),Up="RUN_LOCAL_COMMAND",W3=T({action:Fp,targetId:x(),targetName:x(),command:x(),source:x(),timeoutMs:E().int().positive(),scope:x()}),V3=T({nonce:x().uuid(),phrase:oe(Up),expiresAt:x().datetime(),plan:W3}),Bp=T({confirmation:V3});pn("intent",[T({intent:oe("prepare")}),T({intent:oe("confirm"),nonce:x().uuid(),confirmation:oe(Up)})]);const K3=me(["queued","running","succeeded","failed"]),qp=T({id:x(),packageId:x(),npmName:x(),recipeId:x().nullable().default(null),action:Fp,status:K3,command:x(),output:x(),createdAt:x(),startedAt:x().nullable(),finishedAt:x().nullable(),exitCode:E().nullable(),error:x().nullable()}),Hp=T({task:qp}),G3=T({tasks:V(qp)}),Y3=[{id:"observe",title:"Observe",label:"Live",description:"Capture IDE, process, session, turn, request, response, tools, and providers.",metric:"Inspector core",icon:$x},{id:"replay",title:"Replay",label:"Ready",description:"Promote real logs into repeatable replay evidence without losing the raw context.",metric:"Session asset",icon:yt},{id:"evaluate",title:"Evaluate",label:"Next",description:"Use eval-harness to turn sessions into regression cases and provider bakeoffs.",metric:"Eval loop",icon:Fi},{id:"connect",title:"Connect",label:"MCP",description:"Expose Inspector state to coding agents as queryable context and durable evidence.",metric:"/api/mcp",icon:Mg}];async function J3(e){return Ke(e,H3,void 0,n=>`Failed to load ecosystem packages: ${String(n.status)}`)}async function X3(e){return Ke(e,Hp,void 0,n=>`Failed to load ecosystem task: ${String(n.status)}`)}async function Z3(e){return Ke(e,G3,void 0,n=>`Failed to load ecosystem tasks: ${String(n.status)}`)}async function Q3(e,n){const s=`/api/ecosystem/packages/${encodeURIComponent(e)}/${n}`,o=await Ke(s,Bp,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({intent:"prepare"})},r=>`Failed to prepare ecosystem task: ${String(r.status)}`);return{endpoint:s,confirmation:o.confirmation}}async function e4(e){const n=`/api/ecosystem/recipes/${encodeURIComponent(e)}/run`,s=await Ke(n,Bp,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({intent:"prepare"})},o=>`Failed to prepare ecosystem recipe: ${String(o.status)}`);return{endpoint:n,confirmation:s.confirmation}}async function t4(e){return(await Ke(e.endpoint,Hp,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({intent:"confirm",nonce:e.confirmation.nonce,confirmation:e.confirmation.phrase})},s=>`Failed to start ecosystem task: ${String(s.status)}`)).task}function n4(e){switch(e){case"installed":return"Installed";case"update-available":return"Update";case"available":return"Available";case"planned":return"Planned";case"unknown":return"Unknown"}}function s4(e){switch(e){case"installed":return"border-emerald-400/20 bg-emerald-400/8 text-emerald-200";case"update-available":return"border-amber-400/20 bg-amber-400/8 text-amber-200";case"available":return"border-sky-400/20 bg-sky-400/8 text-sky-200";case"planned":return"border-white/10 bg-white/[0.04] text-white/55";case"unknown":return"border-white/10 bg-white/[0.04] text-white/45"}}function o4(e){return e.installedVersion!==null&&e.latestVersion!==null?e.installedVersion===e.latestVersion?`v${e.installedVersion}`:`v${e.installedVersion} -> v${e.latestVersion}`:e.installedVersion!==null?`v${e.installedVersion}`:e.latestVersion!==null?`latest v${e.latestVersion}`:"not published"}function Is(e){switch(e){case"install":return"Install";case"upgrade":return"Upgrade";case"help":return"Help";case"runner-presets":return"Presets";case"recipe":return"Recipe"}}function r4(e){switch(e.status){case"queued":return"Queued";case"running":return`${Is(e.action)} running`;case"succeeded":return`${Is(e.action)} complete`;case"failed":return`${Is(e.action)} failed`}}function Wp(e){switch(e){case"queued":case"running":return"border-cyan-300/20 bg-cyan-300/8 text-cyan-100";case"succeeded":return"border-emerald-400/20 bg-emerald-400/8 text-emerald-100";case"failed":return"border-red-400/20 bg-red-400/8 text-red-100"}}function a4(e){switch(e.state){case"available":return"install";case"update-available":return"upgrade";case"installed":case"planned":case"unknown":return null}}function i4({pkg:e,activeTask:n,onStartTask:s}){const o=a4(e),r=n!==null&&n.packageId===e.id&&n.status==="running";return t.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[t.jsx(Lg,{className:"size-4 shrink-0 text-white/55"}),t.jsx("div",{className:"text-sm font-semibold leading-snug",children:e.name})]}),t.jsx("div",{className:"mt-1 break-all font-mono text-[11px] leading-snug text-white/35",children:e.npmName})]}),t.jsx(Ce,{className:O("shrink-0",s4(e.state)),variant:"outline",children:n4(e.state)})]}),t.jsx("div",{className:"mt-3 text-xs leading-5 text-muted-foreground",children:e.description}),t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2 text-[11px]",children:[t.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 font-mono text-white/50",children:o4(e)}),t.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 text-white/45",children:e.capability}),t.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 font-mono text-white/35",children:e.installCommand})]}),t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[o!==null&&t.jsxs(te,{type:"button",size:"sm",variant:"secondary",disabled:r,onClick:()=>s(e.id,o),children:[r?t.jsx(Ae,{className:"size-3.5 animate-spin"}):t.jsx(Gs,{className:"size-3.5"}),Is(o)]}),t.jsxs(te,{type:"button",size:"sm",variant:"outline",disabled:r||e.state==="planned",onClick:()=>s(e.id,"help"),children:[t.jsx(Ln,{className:"size-3.5"}),"Help"]}),e.id==="eval-harness"&&t.jsxs(te,{type:"button",size:"sm",variant:"ghost",disabled:r||e.state==="planned",onClick:()=>s(e.id,"runner-presets"),children:[t.jsx(Fi,{className:"size-3.5"}),"Presets"]})]})]})}function l4({task:e}){if(e===null)return null;const n=e.status==="queued"||e.status==="running";return t.jsxs("section",{className:"mt-3 rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n?t.jsx(Ae,{className:"size-4 animate-spin text-cyan-200/75"}):t.jsx(Ln,{className:"size-4 text-white/55"}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-sm font-semibold",children:r4(e)}),t.jsx("div",{className:"break-all font-mono text-[11px] text-white/35",children:e.command})]})]}),t.jsx(Ce,{variant:"outline",className:O("shrink-0",Wp(e.status)),children:e.status})]}),t.jsx("pre",{className:"mt-3 max-h-56 overflow-auto whitespace-pre-wrap rounded-md bg-black/30 p-3 font-mono text-[11px] leading-5 text-white/60 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:e.output.trim().length>0?e.output:"Waiting for npm output..."}),e.error!==null&&t.jsx("div",{className:"mt-2 text-xs text-red-100",children:e.error})]})}function c4({workflow:e}){const n=e.icon;return t.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(n,{className:"size-4 shrink-0 text-cyan-200/75"}),t.jsx("div",{className:"text-sm font-semibold",children:e.title})]}),t.jsx("span",{className:"rounded bg-white/[0.04] px-2 py-0.5 font-mono text-[10px] text-white/45",children:e.label})]}),t.jsx("div",{className:"mt-2 min-h-10 text-xs leading-5 text-muted-foreground",children:e.description}),t.jsx("div",{className:"mt-3 font-mono text-[11px] text-white/35",children:e.metric})]})}function d4(e){return e===null?'npx @tonyclaw/eval-harness inspector-smoke --title "TonyClaw Lab smoke" --latest-log-limit 5':`npx @tonyclaw/eval-harness inspector-smoke --title "TonyClaw Lab smoke ${e}" --latest-log-limit 5`}function u4({preset:e}){return t.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[t.jsx(vu,{className:"size-4 shrink-0 text-cyan-200/75"}),t.jsx("div",{className:"text-sm font-semibold leading-snug",children:e.name})]}),t.jsxs("div",{className:"mt-1 break-all font-mono text-[11px] leading-snug text-white/35",children:[e.binary," ",e.modelFlag,e.variantFlag!==null?` ${e.variantFlag}`:""]})]}),t.jsxs(Ce,{variant:"outline",className:"border-white/10 bg-white/[0.04] text-white/55",children:["v",e.validatedVersion]})]}),t.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-[11px]",children:[t.jsxs("div",{className:"rounded bg-black/15 px-2 py-1 text-white/45",children:["logs/",e.logDir]}),t.jsx("div",{className:"rounded bg-black/15 px-2 py-1 text-white/45",children:e.tools.join(", ")}),t.jsx("div",{className:"rounded bg-black/15 px-2 py-1 font-mono text-white/35",children:e.skillsDir}),t.jsx("div",{className:"rounded bg-black/15 px-2 py-1 font-mono text-white/35",children:e.agentsDir})]})]})}function m4({recipe:e,copied:n,running:s,onCopy:o,onRun:r}){return t.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[t.jsx(pu,{className:"size-4 shrink-0 text-cyan-200/75"}),t.jsx("div",{className:"text-sm font-semibold leading-snug",children:e.title})]}),t.jsx("div",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:e.description})]}),t.jsx(Ce,{variant:"outline",className:"border-white/10 bg-white/[0.04] text-white/55",children:e.runnable?e.stage:"Template"})]}),t.jsx("div",{className:"mt-3 rounded-md bg-black/20 p-2 font-mono text-[11px] leading-5 text-white/50 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:e.command}),t.jsxs("div",{className:"mt-3 flex items-center justify-between gap-2",children:[t.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 font-mono text-[11px] text-white/35",children:e.packageId}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(te,{type:"button",size:"sm",variant:"outline",onClick:()=>o(e),children:[n?t.jsx(Pe,{className:"size-3.5"}):t.jsx(St,{className:"size-3.5"}),n?"Copied":"Copy"]}),e.runnable&&t.jsxs(te,{type:"button",size:"sm",variant:"secondary",disabled:s,onClick:()=>r(e),children:[s?t.jsx(Ae,{className:"size-3.5 animate-spin"}):t.jsx(vu,{className:"size-3.5"}),s?"Running":"Run"]})]})]})]})}function f4({task:e,selected:n,onSelect:s}){const o=e.recipeId??Is(e.action);return t.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md bg-white/[0.025] px-3 py-2 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(xu,{className:"size-3.5 shrink-0 text-white/40"}),t.jsx("div",{className:"truncate text-xs font-semibold text-white/75",children:o}),t.jsx(Ce,{variant:"outline",className:O("shrink-0",Wp(e.status)),children:e.status})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-2 font-mono text-[10px] text-white/35",children:[t.jsx("span",{children:e.packageId}),t.jsx("span",{children:new Date(e.createdAt).toLocaleTimeString()}),e.exitCode!==null&&t.jsxs("span",{children:["exit ",String(e.exitCode)]})]})]}),t.jsx(te,{type:"button",size:"sm",variant:n?"secondary":"outline",onClick:()=>s(e),children:n?"Open":"View"})]})}function p4({pending:e,busy:n,onOpenChange:s,onConfirm:o}){const r=e?.confirmation.plan??null;return t.jsx(Lt,{open:e!==null,onOpenChange:s,children:t.jsxs(Ot,{className:"max-w-xl",children:[t.jsxs(Ut,{children:[t.jsx(Bt,{children:"Confirm local command"}),t.jsx(to,{children:"Review the exact allowlisted action Agent Inspector will run on this machine."})]}),r!==null&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[t.jsxs("div",{className:"rounded-md border bg-muted/30 p-3",children:[t.jsx("div",{className:"text-muted-foreground",children:"Source"}),t.jsx("div",{className:"mt-1 break-words font-medium",children:r.source})]}),t.jsxs("div",{className:"rounded-md border bg-muted/30 p-3",children:[t.jsx("div",{className:"text-muted-foreground",children:"Timeout"}),t.jsxs("div",{className:"mt-1 font-medium",children:[String(r.timeoutMs/1e3)," seconds"]})]}),t.jsxs("div",{className:"rounded-md border bg-muted/30 p-3 sm:col-span-2",children:[t.jsx("div",{className:"text-muted-foreground",children:"Affected scope"}),t.jsx("div",{className:"mt-1 font-medium",children:r.scope})]})]}),t.jsxs("div",{children:[t.jsx("div",{className:"mb-1 text-xs font-medium",children:"Resolved command"}),t.jsx("pre",{className:"max-h-32 overflow-auto whitespace-pre-wrap break-all rounded-md bg-black/80 p-3 font-mono text-xs leading-5 text-white/80",children:r.command})]}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Confirmation phrase: ",t.jsx("code",{children:e?.confirmation.phrase}),". The one-time confirmation expires at"," ",new Date(e?.confirmation.expiresAt??"").toLocaleTimeString(),"."]})]}),t.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[t.jsx(te,{type:"button",variant:"outline",disabled:n,onClick:()=>s(!1),children:"Cancel"}),t.jsxs(te,{type:"button",variant:"secondary",disabled:n||r===null,onClick:o,children:[n?t.jsx(Ae,{className:"size-3.5 animate-spin"}):t.jsx(Ln,{className:"size-3.5"}),n?"Starting":"Confirm & Run"]})]})]})})}function h4({currentSessionId:e,logCount:n,labelledTrigger:s=!1}){const[o,r]=l.useState(!1),[a,i]=l.useState(!1),[c,d]=l.useState(!1),[m,u]=l.useState(null),[f,p]=l.useState(null),[h,g]=l.useState(null),[v,y]=l.useState(null),[w,b]=l.useState(!1),j=Rt("/api/ecosystem/packages",J3,{revalidateOnFocus:!1,revalidateIfStale:!1}),S=Rt(f===null?null:`/api/ecosystem/tasks/${f}`,X3,{refreshInterval:B=>{const W=B?.task;return W!==void 0&&(W.status==="queued"||W.status==="running")?900:0},revalidateOnFocus:!1}),N=Rt(o?"/api/ecosystem/tasks":null,Z3,{refreshInterval:2500,revalidateOnFocus:!1}),C=j.data?.packages??[],R=j.data?.runnerPresets??[],I=j.data?.recipes??[],P=(N.data?.tasks??[]).slice(0,6),M=l.useMemo(()=>C.filter(B=>B.state==="installed"||B.state==="update-available").length,[C]),k=d4(e),A="npx @tonyclaw/eval-harness runner-presets",D=()=>{vt(k).then(()=>{i(!0),window.setTimeout(()=>i(!1),1200)})},$=()=>{vt(A).then(()=>{d(!0),window.setTimeout(()=>d(!1),1200)})},Y=B=>{vt(B.command).then(()=>{u(B.id),window.setTimeout(()=>u(null),1200)})},Q=B=>{g(null),e4(B.id).then(W=>{y(W)}).catch(W=>{g(W instanceof Error?W.message:"Failed to prepare ecosystem recipe")})},U=S.data?.task??null;l.useEffect(()=>{U!==null&&(N.mutate(),U.status==="succeeded"&&j.mutate())},[U,j,N]);const H=(B,W)=>{g(null),Q3(B,W).then(pe=>{y(pe)}).catch(pe=>{g(pe instanceof Error?pe.message:"Failed to prepare ecosystem task")})},X=()=>{v!==null&&(g(null),b(!0),t4(v).then(B=>{p(B.id),y(null),S.mutate({task:B},{revalidate:!0}),N.mutate()}).catch(B=>{g(B instanceof Error?B.message:"Failed to start ecosystem task")}).finally(()=>{b(!1)}))};return t.jsxs(Lt,{open:o,onOpenChange:r,children:[t.jsx(eo,{asChild:!0,children:t.jsxs(te,{variant:"ghost",size:s?"default":"icon",className:O(so,s&&"w-auto gap-2 px-3 text-xs max-lg:h-11 max-lg:w-auto"),"aria-label":"TonyClaw Lab",title:"TonyClaw Lab",children:[t.jsx(pu,{className:"size-4"}),t.jsx("span",{className:s?"":"sr-only",children:"Lab"})]})}),t.jsxs(Ot,{className:"flex max-h-[84vh] max-w-5xl flex-col overflow-hidden",children:[t.jsx(Ut,{children:t.jsxs(Bt,{className:"flex items-center gap-2",children:[t.jsx(Wa,{className:"size-4 text-cyan-200/80"}),"TonyClaw Lab"]})}),t.jsxs("div",{className:"overflow-y-auto pr-2",children:[t.jsxs("div",{className:"grid gap-3 lg:grid-cols-[1.1fr_0.9fr]",children:[t.jsxs("section",{className:"rounded-lg bg-white/[0.025] p-4 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-semibold",children:"Session asset pipeline"}),t.jsx("div",{className:"mt-1 max-w-2xl text-xs leading-5 text-muted-foreground",children:"Treat captured traffic as durable assets: observe it, replay it, evaluate it, and expose it back to agents through MCP."})]}),t.jsxs(Ce,{variant:"outline",className:"border-cyan-300/20 bg-cyan-300/8 text-cyan-100",children:[String(M),"/",String(C.length)," packages"]})]}),t.jsx("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:Y3.map(B=>t.jsx(c4,{workflow:B},B.id))})]}),t.jsxs("section",{className:"rounded-lg bg-white/[0.025] p-4 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-semibold",children:"Current session"}),t.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:e===null?"MCP smoke command":e})]}),t.jsxs(Ce,{variant:"outline",className:"border-white/10 bg-white/[0.04] text-white/55",children:[String(n)," logs"]})]}),t.jsx("div",{className:"mt-4 rounded-md bg-black/20 p-3 font-mono text-[11px] leading-5 text-white/55 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:k}),t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[t.jsxs(te,{size:"sm",variant:"secondary",onClick:D,children:[a?t.jsx(Pe,{className:"size-3.5"}):t.jsx(St,{className:"size-3.5"}),a?"Copied":"Copy"]}),t.jsxs(te,{size:"sm",variant:"outline",onClick:$,children:[t.jsx(Fi,{className:"size-3.5"}),c?"Presets copied":"Runner Presets"]})]})]})]}),t.jsxs("section",{className:"mt-3",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[t.jsx("div",{className:"text-sm font-semibold",children:"Lab recipes"}),t.jsxs("div",{className:"hidden items-center gap-1 font-mono text-[11px] text-muted-foreground sm:flex",children:[t.jsx(Wa,{className:"size-3.5"}),"copy-ready workflows"]})]}),t.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[I.map(B=>t.jsx(m4,{recipe:B,copied:m===B.id,running:U!==null&&U.recipeId===B.id&&(U.status==="queued"||U.status==="running"),onCopy:Y,onRun:Q},B.id)),j.isLoading&&I.length===0&&[0,1].map(B=>t.jsx("div",{className:"h-40 animate-pulse rounded-lg bg-white/[0.025] shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]"},B))]})]}),t.jsxs("section",{className:"mt-3",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[t.jsx("div",{className:"text-sm font-semibold",children:"Runner presets"}),t.jsxs("div",{className:"hidden items-center gap-1 font-mono text-[11px] text-muted-foreground sm:flex",children:[t.jsx(Ln,{className:"size-3.5"}),A]})]}),t.jsxs("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:[R.map(B=>t.jsx(u4,{preset:B},B.id)),j.isLoading&&R.length===0&&[0,1,2,3].map(B=>t.jsx("div",{className:"h-32 animate-pulse rounded-lg bg-white/[0.025] shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]"},B))]})]}),t.jsxs("section",{className:"mt-3",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[t.jsx("div",{className:"text-sm font-semibold",children:"TonyClaw packages"}),j.isLoading&&t.jsx("div",{className:"font-mono text-[11px] text-muted-foreground",children:"checking npm..."})]}),j.error!==void 0&&t.jsx("div",{className:"rounded-lg bg-red-500/8 p-3 text-xs text-red-100 shadow-[inset_0_0_0_1px_rgba(248,113,113,0.16)]",children:"Package status is temporarily unavailable."}),t.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[C.map(B=>t.jsx(i4,{pkg:B,activeTask:U,onStartTask:H},B.id)),j.isLoading&&C.length===0&&[0,1,2].map(B=>t.jsx("div",{className:"h-36 animate-pulse rounded-lg bg-white/[0.025] shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]"},B))]})]}),h!==null&&t.jsx("div",{className:"mt-3 rounded-lg bg-red-500/8 p-3 text-xs text-red-100 shadow-[inset_0_0_0_1px_rgba(248,113,113,0.16)]",children:h}),P.length>0&&t.jsxs("section",{className:"mt-3",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[t.jsx("div",{className:"text-sm font-semibold",children:"Recent Lab runs"}),t.jsxs("div",{className:"hidden font-mono text-[11px] text-muted-foreground sm:block",children:["last ",String(P.length)]})]}),t.jsx("div",{className:"grid gap-2 md:grid-cols-2",children:P.map(B=>t.jsx(f4,{task:B,selected:f===B.id,onSelect:W=>{p(W.id),S.mutate({task:W},{revalidate:!0})}},B.id))})]}),t.jsx(l4,{task:U})]})]}),t.jsx(p4,{pending:v,busy:w,onOpenChange:B=>{!B&&!w&&y(null)},onConfirm:X})]})}function x4(e){return[...new Set(e.evidence.map(n=>n.logId).filter(n=>n!==null))]}const g4=[{id:"reliability",label:"Reliability",question:"Which requests failed, stalled, or look most likely to hang, and why?"},{id:"performance",label:"Performance",question:"Summarize latency and identify the slowest requests with supporting evidence."},{id:"tokens",label:"Token usage",question:"Where are tokens being spent, and which requests have unusually high usage?"},{id:"providers",label:"Providers",question:"Compare Provider and model reliability, latency, and token usage in this scope."},{id:"tools",label:"Tool activity",question:"Which tools were used most, and where did tool calls fail or produce warnings?"}],b4=4e3,La=12;function id(){return{messages:[],question:"",error:null}}function v4(e){return e.filter(n=>n.content.trim().length>0).slice(-10).map(n=>({role:n.role,content:n.content.trim().slice(0,b4)}))}function Xe(e,...n){for(const s of n){const o=ne(e,s);if(typeof o=="string"&&o.trim().length>0)return o}return null}function rn(e,...n){for(const s of n){const o=ne(e,s);if(typeof o=="number"&&Number.isFinite(o))return o}return null}function y4(e,n){const s=ne(e,n);return Array.isArray(s)?s.filter(o=>typeof o=="string").slice(0,8):[]}function w4(e){const n=Xe(e,"source")??"log",s=Xe(e,"id")??"",o=rn(e,"logId","id");if(s===""&&o===null||o!==null&&(!Number.isInteger(o)||o<0))return null;const r=rn(e,"inputTokens"),a=rn(e,"outputTokens"),i=rn(e,"totalTokens","tokenCount"),c=rn(e,"responseStatus","status"),d=Xe(e,"responseStatus","status");return{source:n,id:s!==""?s:String(o),logId:o,sessionId:Xe(e,"sessionId"),timestamp:Xe(e,"timestamp"),model:Xe(e,"model"),providerName:Xe(e,"providerName","provider"),path:Xe(e,"path"),status:c??d,elapsedMs:rn(e,"elapsedMs","latencyMs"),inputTokens:r,outputTokens:a,totalTokens:i??(r===null&&a===null?null:(r??0)+(a??0)),score:rn(e,"score","relevanceScore"),matchedFields:y4(e,"matchedFields"),excerpt:Xe(e,"excerpt","snippet")??"No excerpt available."}}function Oa(e){const n=e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim();return n.length===0?"Metric":`${n[0]?.toUpperCase()??""}${n.slice(1)}`}function ld(e){if(typeof e=="number"&&Number.isFinite(e))return e.toLocaleString();if(typeof e=="string"&&e.trim().length>0)return e;if(typeof e=="boolean")return e?"Yes":"No";if(Array.isArray(e)){const n=e.filter(s=>typeof s=="string"||typeof s=="number"&&Number.isFinite(s)).slice(0,6);return n.length>0?n.join(", "):null}return null}function cd(e){return Object.getOwnPropertyNames(e).map(n=>[n,ne(e,n)])}function dd(e){if(e===null||typeof e!="object"||Array.isArray(e))return[];const n=[];for(const[s,o]of cd(e)){const r=ld(o);if(r!==null){if(n.push({key:s,label:Oa(s),value:r}),n.length>=La)break;continue}if(!(o===null||typeof o!="object"||Array.isArray(o))){for(const[a,i]of cd(o)){const c=ld(i);if(c===null)continue;const d=`${s}.${a}`;if(n.push({key:d,label:`${Oa(s)} ${Oa(a).toLowerCase()}`,value:c}),n.length>=La)break}if(n.length>=La)break}}return n}function j4(e){const n=Xe(e,"answer"),s=Xe(e,"providerId"),o=Xe(e,"providerName"),r=Xe(e,"model"),a=Xe(e,"protocol"),i=rn(e,"logCount");if(n===null||s===null||o===null||r===null||a===null||i===null)return null;const c=ne(e,"evidence"),d=Array.isArray(c)?c.map(w4).filter(m=>m!==null).slice(0,12):[];return{answer:n,providerId:s,providerName:o,model:r,protocol:a,logCount:i,evidence:d,summaryMetrics:dd(ne(e,"summary")),queryMetrics:dd(ne(e,"queryStats"))}}const S4=l.lazy(()=>zt(()=>import("./index-aah_H3hN.js"),__vite__mapDeps([10,1,2]),import.meta.url)),N4="prose prose-sm dark:prose-invert max-w-none text-[13px] leading-[1.65] [&_pre]:bg-muted [&_pre]:text-foreground [&_code]:text-[0.8em] [&_p]:my-1 [&_p]:leading-[1.65] [&_ul]:my-1 [&_ol]:my-1 [&_li]:my-0.5 [&_li]:leading-[1.6]";function C4({text:e}){return t.jsx("div",{className:N4,children:t.jsx(l.Suspense,{fallback:t.jsx("span",{className:"text-xs text-muted-foreground",children:"Loading Markdown..."}),children:t.jsx(S4,{children:e})})})}const ud="What looks abnormal, slow, or likely to hang?";function k4(e){return e.openaiResponsesBaseUrl!==void 0||e.openaiBaseUrl!==void 0||e.anthropicBaseUrl!==void 0}function _4(e){return e.openaiResponsesBaseUrl!==void 0&&e.openaiResponsesBaseUrl!==""?"Responses":e.openaiBaseUrl!==void 0&&e.openaiBaseUrl!==""?"Chat":"Anthropic"}function T4(e){return e.toSorted((n,s)=>{const o=n.source==="company"?0:1,r=s.source==="company"?0:1;return o!==r?o-r:n.name.localeCompare(s.name)})}function md(e){return`${e}-${String(Date.now())}-${String(Math.random()).slice(2)}`}function Cn({label:e,value:n,tone:s="muted"}){return t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 font-mono text-[10px]",children:[t.jsx("span",{className:s==="cyan"?"text-cyan-100":"text-muted-foreground",children:e}),n!==void 0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-muted-foreground/55",children:":"}),t.jsx("span",{className:"truncate text-muted-foreground",children:n})]})]})}function E4({metrics:e}){return e.length===0?null:t.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:e.slice(0,8).map(n=>t.jsxs("div",{className:"rounded-sm bg-black/25 px-2 py-1 shadow-[inset_2px_0_0_rgba(103,232,249,0.22)]",children:[t.jsx("div",{className:"truncate font-mono text-[9px] text-muted-foreground",children:n.label}),t.jsx("div",{className:"truncate font-mono text-[11px] text-cyan-50/95",children:n.value})]},n.key))})}function R4({evidence:e}){const n=()=>{e.logId!==null&&fs({logId:e.logId,tab:"anatomy"})},s=e.logId===null?`${e.source}:${e.id}`:`${e.source}:log #${String(e.logId)}`;return t.jsxs("button",{type:"button",onClick:n,disabled:e.logId===null,className:"w-full rounded-sm bg-black/25 px-2 py-2 text-left shadow-[inset_2px_0_0_rgba(103,232,249,0.22),inset_0_0_0_1px_rgba(255,255,255,0.045)] transition-colors hover:bg-black/35 disabled:cursor-default disabled:hover:bg-black/25",children:[t.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[t.jsx("span",{className:"truncate font-mono text-[10px] text-cyan-100",children:s}),e.score!==null&&t.jsx("span",{className:"shrink-0 font-mono text-[9px] text-muted-foreground",children:e.score.toFixed(1)})]}),t.jsxs("div",{className:"mt-1 flex flex-wrap gap-x-2 gap-y-1 text-[10px] text-muted-foreground",children:[e.providerName!==null&&t.jsx("span",{children:e.providerName}),e.model!==null&&t.jsx("span",{children:e.model}),e.status!==null&&t.jsxs("span",{children:["status ",String(e.status)]}),e.elapsedMs!==null&&t.jsxs("span",{children:[String(e.elapsedMs)," ms"]})]}),t.jsx("p",{className:"mt-1 line-clamp-3 text-[11px] leading-4 text-foreground/85",children:e.excerpt})]})}function M4({response:e}){return t.jsxs("div",{className:"overflow-hidden rounded-md bg-[#050b12]/85 shadow-[inset_0_0_0_1px_rgba(103,232,249,0.12),0_10px_24px_rgba(0,0,0,0.18)]",children:[t.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2 border-b border-cyan-100/[0.08] bg-cyan-400/[0.045] px-3 py-2",children:[t.jsx(Cn,{label:"assistant@inspector",value:"output",tone:"cyan"}),t.jsxs("span",{className:"shrink-0 font-mono text-[9px] text-muted-foreground",children:[String(e.logCount)," logs"]})]}),t.jsxs("div",{className:"space-y-3 p-3",children:[t.jsx("div",{className:"rounded-sm bg-black/20 px-2.5 py-2 text-xs leading-5 shadow-[inset_2px_0_0_rgba(103,232,249,0.28)]",children:t.jsx(C4,{text:e.answer})}),t.jsxs("div",{className:"grid gap-1.5 rounded-sm bg-black/20 px-2 py-1.5",children:[t.jsx(Cn,{label:"provider",value:e.providerName}),t.jsx(Cn,{label:"model",value:e.model}),t.jsx(Cn,{label:"protocol",value:e.protocol})]}),(e.summaryMetrics.length>0||e.queryMetrics.length>0)&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Cn,{label:"metrics",tone:"cyan"}),t.jsx(E4,{metrics:[...e.summaryMetrics,...e.queryMetrics]})]}),e.evidence.length>0&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Cn,{label:"evidence",value:"click to inspect source log",tone:"cyan"}),e.evidence.slice(0,6).map(n=>t.jsx(R4,{evidence:n},`${n.source}-${n.id}`))]})]})]})}function A4({message:e}){return e.role==="assistant"&&e.response!==null?t.jsx(M4,{response:e.response}):t.jsxs("div",{className:"overflow-hidden rounded-md bg-black/25 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[t.jsx("div",{className:"border-b border-white/[0.06] px-3 py-1.5",children:t.jsx(Cn,{label:"user@inspector",value:"query",tone:"cyan"})}),t.jsxs("div",{className:"px-3 py-2 font-mono text-[11px] leading-5 text-cyan-50",children:[t.jsx("span",{className:"select-none text-cyan-100/60",children:"> "}),e.content]})]})}function I4({currentSessionId:e,logCount:n,onResultChange:s}){const{providers:o}=Yi(),r=l.useMemo(()=>T4(o.filter(k4)),[o]),[a,i]=l.useState(()=>({...id(),question:ud})),[c,d]=l.useState("__auto__"),[m,u]=l.useState("__auto__"),[f,p]=l.useState(!1),g=r.find(C=>C.id===c)?.models??[],v=a.question,y=v.trim()!==""&&r.length>0&&!f;if(r.length===0)return null;const w=C=>{i(R=>({...R,question:C.currentTarget.value}))},b=C=>{d(C),u("__auto__")},j=()=>{i({...id(),question:ud}),s(null)},S=C=>{i(R=>({...R,question:C,error:null}))},N=()=>{if(!y)return;const C=v.trim(),R=v4(a.messages),I={id:md("user"),role:"user",content:C,response:null};p(!0),i(M=>({...M,messages:[...M.messages,I],question:"",error:null}));const P={question:C,history:R,...e!==null?{sessionId:e}:{},...c!=="__auto__"?{providerId:c}:{},...m!=="__auto__"?{model:m}:{},logLimit:16};Ah("/api/pi-agent",{method:"POST",headers:{"content-type":"application/json","x-agent-inspector-csrf":"1"},body:JSON.stringify(P)}).then(async M=>{const k=await M.text();if(!M.ok){i($=>({...$,error:`Inspector Assistant failed: HTTP ${String(M.status)} ${k}`}));return}const A=JSON.parse(k),D=j4(A);if(D===null){i($=>({...$,error:"Inspector Assistant returned an unexpected response."}));return}i($=>({...$,messages:[...$.messages,{id:md("assistant"),role:"assistant",content:D.answer,response:D}]})),s({question:C,logIds:x4(D),reportedLogCount:D.logCount})}).catch(M=>{i(k=>({...k,error:M instanceof Error?M.message:"Inspector Assistant request failed."}))}).finally(()=>{p(!1)})};return t.jsxs("section",{className:"rounded-md bg-black/20 px-3 py-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(n0,{className:"size-4 text-cyan-200"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-xs font-semibold text-foreground",children:"Assistant"}),t.jsx("div",{className:"text-[11px] text-muted-foreground",children:e===null?"All evidence":"Current session"})]}),t.jsx("button",{type:"button",onClick:j,className:"inline-flex size-7 items-center justify-center rounded-md bg-black/25 text-muted-foreground transition-colors hover:text-foreground",title:"Reset conversation",children:t.jsx(yu,{className:"size-3.5"})})]}),a.messages.length===0&&t.jsx("p",{className:"mt-3 text-[11px] leading-5 text-muted-foreground",children:"Ask about failures, latency, tokens, and tools."}),t.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2",children:[t.jsxs(Bs,{value:c,onValueChange:b,children:[t.jsx(qs,{className:"h-8 border-0 bg-black/25 text-xs shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)]",children:t.jsx(ar,{placeholder:"Provider"})}),t.jsxs(Hs,{children:[t.jsx(Ze,{value:"__auto__",children:"Auto provider"}),r.map(C=>t.jsxs(Ze,{value:C.id,children:[C.name," / ",_4(C)]},C.id))]})]}),t.jsxs(Bs,{value:m,onValueChange:u,children:[t.jsx(qs,{className:"h-8 border-0 bg-black/25 text-xs shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)]",children:t.jsx(ar,{placeholder:"Model"})}),t.jsxs(Hs,{children:[t.jsx(Ze,{value:"__auto__",children:"Auto model"}),g.map(C=>t.jsx(Ze,{value:C,children:C},C))]})]})]}),a.messages.length===0&&t.jsx("div",{className:"mt-3 flex flex-wrap gap-1.5",children:g4.map(C=>t.jsxs("button",{type:"button",onClick:()=>{S(C.question)},className:"inline-flex h-7 items-center gap-1.5 rounded-sm bg-black/25 px-2 text-[11px] text-cyan-50 transition-colors hover:bg-cyan-400/12",children:[t.jsx(Wa,{className:"size-3"}),t.jsx("span",{children:C.label})]},C.id))}),a.messages.length>0&&t.jsxs("div",{className:"mt-3 max-h-96 space-y-2 overflow-y-auto pr-1",children:[a.messages.map(C=>t.jsx(A4,{message:C},C.id)),f&&t.jsxs("div",{className:"inline-flex items-center gap-2 rounded-md bg-black/25 px-3 py-2 text-xs text-muted-foreground",children:[t.jsx(Ae,{className:"size-3.5 animate-spin"}),t.jsx("span",{children:"Searching Inspector..."})]})]}),t.jsx("textarea",{value:v,onChange:w,className:"mt-3 min-h-20 w-full resize-y rounded-md bg-black/25 px-3 py-2 text-xs leading-5 text-foreground outline-none shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors placeholder:text-muted-foreground focus-visible:ring-1 focus-visible:ring-ring",placeholder:"Ask about this Inspector data..."}),t.jsxs("button",{type:"button",onClick:N,disabled:!y,className:"mt-2 inline-flex h-8 w-full items-center justify-center gap-2 rounded-md bg-cyan-400/12 px-3 text-xs font-medium text-cyan-100 shadow-[inset_0_0_0_1px_rgba(103,232,249,0.18)] transition-colors hover:bg-cyan-400/18 disabled:cursor-not-allowed disabled:opacity-50",children:[f?t.jsx(Ae,{className:"size-3.5 animate-spin"}):t.jsx(n1,{className:"size-3.5"}),t.jsx("span",{children:f?"Searching...":"Ask Assistant"})]}),a.error!==null&&t.jsx("p",{className:"mt-2 break-words text-[11px] leading-5 text-red-200",children:a.error}),n===0&&t.jsx("p",{className:"mt-2 text-[11px] leading-5 text-muted-foreground",children:"No logs in this scope. Setup questions still work."})]})}function P4(e){const n=new Map;for(const s of e){const o=s.logs;for(let r=1;r<o.length;r++){const a=o[r-1],i=o[r];a===void 0||i===void 0||n.set(i.id,{creation:fd(a.cacheCreationInputTokens,i.cacheCreationInputTokens),read:fd(a.cacheReadInputTokens,i.cacheReadInputTokens)})}}return n}function fd(e,n){return n===null||e===null?null:n>e?{direction:"up",delta:n-e}:n<e?{direction:"down",delta:e-n}:null}function Vp(e){return e===null?null:new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Jn(e,n,s){const o=Vp(e.lastSuccessAt),r=e.retryCount>0?` Retry ${e.retryCount.toString()}.`:"",a=s?" Captured logs remain visible.":"",i=o===null?"":` Last update ${o}.`;return`${n}${i}${r}${a}`}function Kp(e,n,s){switch(e){case"connecting":return{label:"Connecting",description:Jn(n,"Waiting for the first live update.",s),toneClass:"border-cyan-400/20 bg-cyan-500/8 text-cyan-100",dotClass:"bg-cyan-300 animate-pulse motion-reduce:animate-none",canRetry:!1,canStop:!1};case"live":return{label:"Live",description:Jn(n,"Live updates are current.",s),toneClass:"border-emerald-400/20 bg-emerald-500/8 text-emerald-100",dotClass:"bg-emerald-300",canRetry:!1,canStop:!1};case"reconnecting":return{label:"Reconnecting",description:Jn(n,"Live updates were interrupted.",s),toneClass:"border-amber-400/20 bg-amber-500/8 text-amber-100",dotClass:"bg-amber-300 animate-pulse motion-reduce:animate-none",canRetry:!0,canStop:!0};case"stale":return{label:"Stale data",description:Jn(n,"Live updates have not resumed.",s),toneClass:"border-orange-400/25 bg-orange-500/10 text-orange-100",dotClass:"bg-orange-300",canRetry:!0,canStop:!0};case"offline":return{label:"Offline",description:Jn(n,n.errorMessage??"Live updates are paused.",s),toneClass:"border-slate-400/20 bg-slate-500/10 text-slate-200",dotClass:"bg-slate-400",canRetry:!0,canStop:!1};case"error":return{label:"Connection error",description:Jn(n,n.errorMessage??"The live stream reported a recoverable error.",s),toneClass:"border-red-400/25 bg-red-500/10 text-red-100",dotClass:"bg-red-300",canRetry:!0,canStop:!0}}}function L4({state:e}){const n=Kp(e.status,e,!1),s=Vp(e.lastSuccessAt),o=e.retryCount>0?`Retry ${e.retryCount.toString()}`:null;return t.jsxs("span",{role:"status","aria-label":n.description,"data-connection-state":e.status,className:O("inline-flex h-7 max-w-full items-center gap-1.5 rounded-full border px-2.5 text-xs font-medium",n.toneClass),children:[t.jsx("span",{className:O("size-1.5 shrink-0 rounded-full",n.dotClass)}),t.jsx("span",{className:"shrink-0",children:n.label}),o!==null&&t.jsx("span",{className:"hidden truncate text-current/70 sm:inline",children:o}),s!==null&&t.jsxs("span",{className:"hidden truncate font-mono text-[10px] text-current/65 md:inline",children:["Last ",s]})]})}function O4({state:e,hasLogs:n,onRetry:s,onStop:o}){const r=Kp(e.status,e,n);return t.jsxs("div",{role:"status","aria-live":"polite","data-connection-state":e.status,className:O("mt-2 flex flex-wrap items-center gap-x-3 gap-y-2 rounded-md border px-3 py-2 text-xs",r.toneClass),children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:O("size-2 shrink-0 rounded-full",r.dotClass)}),t.jsx("span",{className:"shrink-0 font-semibold",children:r.label}),t.jsx("span",{className:"min-w-0 text-current/75",children:r.description})]}),(r.canRetry||r.canStop)&&t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[r.canRetry&&t.jsxs("button",{type:"button",onClick:s,className:"inline-flex h-7 items-center gap-1 rounded-md bg-black/15 px-2 font-medium transition-colors hover:bg-black/25 focus-visible:ring-1 focus-visible:ring-current focus-visible:outline-none",children:[t.jsx(yt,{className:"size-3"}),"Retry now"]}),r.canStop&&t.jsxs("button",{type:"button",onClick:o,className:"inline-flex h-7 items-center gap-1 rounded-md px-2 text-current/70 transition-colors hover:bg-black/15 hover:text-current focus-visible:ring-1 focus-visible:ring-current focus-visible:outline-none",children:[t.jsx(N0,{className:"size-3"}),"Stop retrying"]})]})]})}function D4(){const[e,n]=l.useState(!1),[s,o]=l.useState(!1);l.useEffect(()=>{const i=()=>{n(document.fullscreenElement!==null),o(document.fullscreenEnabled&&document.documentElement.requestFullscreen!==void 0&&document.exitFullscreen!==void 0)};return i(),document.addEventListener("fullscreenchange",i),()=>{document.removeEventListener("fullscreenchange",i)}},[]);const r=l.useCallback(()=>{if(s){if(document.fullscreenElement===null){document.documentElement.requestFullscreen().catch(()=>{n(document.fullscreenElement!==null)});return}document.exitFullscreen().catch(()=>{n(document.fullscreenElement!==null)})}},[s]),a=e?"Exit fullscreen":"Enter fullscreen";return t.jsxs(te,{type:"button",variant:"ghost",size:"icon",className:so,"aria-label":a,"aria-pressed":e,title:a,disabled:!s,onClick:r,children:[e?t.jsx(jg,{className:"size-4"}):t.jsx(vg,{className:"size-4"}),t.jsx("span",{className:"sr-only",children:a})]})}function z4({liveConnection:e,alertsAction:n,settingsAction:s}){return t.jsx("header",{"data-application-bar":"true",className:"border-border/70 bg-background/95 sticky top-0 z-50 shrink-0 border-b px-3 py-2 shadow-[0_10px_30px_rgba(0,0,0,0.14)] backdrop-blur lg:px-4",children:t.jsxs("div",{className:"grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-2 sm:grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)]",children:[t.jsxs("a",{href:_i("/"),"aria-label":"Agent Inspector home",className:"flex min-w-0 items-center gap-2 rounded-md focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",children:[t.jsx(qd,{className:"size-7 shrink-0 text-amber-500"}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block truncate text-sm font-bold leading-4",children:"Agent Inspector"}),t.jsx("span",{className:"hidden truncate text-[10px] font-medium text-muted-foreground md:block",children:"Local First. Evidence First."})]}),t.jsxs("span",{className:"hidden shrink-0 font-mono text-[10px] text-muted-foreground lg:inline",children:["v",Su.version]})]}),t.jsx("div",{className:"order-3 col-span-2 flex min-w-0 justify-start sm:order-2 sm:col-span-1 sm:justify-center",children:e===void 0?t.jsxs("span",{"data-connection-state":"stored",className:"border-border/70 bg-muted/50 inline-flex h-7 max-w-full items-center gap-1.5 rounded-full border px-2.5 text-xs font-medium text-muted-foreground",children:[t.jsx("span",{className:"size-1.5 shrink-0 rounded-full bg-slate-400"}),"Stored session"]}):t.jsx(L4,{state:e})}),t.jsxs("nav",{"aria-label":"Application actions",className:"order-2 flex shrink-0 items-center justify-end gap-1 sm:order-3",children:[t.jsx(D4,{}),n,s]})]})})}function $4(e){return`${Math.max(0,Math.ceil(e/1e3)).toString()}s`}function $o({progress:e}){const n=Math.min(1,e.elapsedMs/e.timeoutMs),s=Math.max(4,Math.round(n*100)),o=Math.max(0,e.timeoutMs-e.elapsedMs),r=n>=.75,a=[e.loadedLogs>0?`${e.loadedLogs.toString()} logs`:null,e.loadedPages>0?`${e.loadedPages.toString()} page${e.loadedPages===1?"":"s"}`:null,`${$4(o)} before timeout`].filter(c=>c!==null),i=`${e.label}: ${a.join(", ")}`;return t.jsxs("div",{className:"min-w-0 space-y-1 px-1 pb-1",children:[t.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3 font-mono text-[10px] text-muted-foreground",children:[t.jsx("span",{className:"min-w-0 truncate",children:e.label}),t.jsx("span",{className:O("shrink-0 tabular-nums",r&&"text-amber-300"),children:a.join(" / ")})]}),t.jsx("div",{role:"progressbar","aria-label":e.label,"aria-valuemin":0,"aria-valuemax":e.timeoutMs,"aria-valuenow":Math.min(e.elapsedMs,e.timeoutMs),"aria-valuetext":i,className:"h-1.5 overflow-hidden rounded-full bg-white/[0.06]",children:t.jsx("div",{className:O("h-full rounded-full transition-all duration-300 motion-reduce:transition-none",r?"bg-amber-300/80":"bg-cyan-300/70"),style:{width:`${s.toString()}%`}})})]})}function Gp(e){return e?"auto":"smooth"}function Yp(){return typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function F4(){return{status:"connecting",lastSuccessAt:null,retryCount:0,errorMessage:null}}function _t(e,n){switch(n.type){case"connect-requested":return{...e,status:e.lastSuccessAt===null?"connecting":e.status==="stale"?"stale":"reconnecting",errorMessage:null};case"message-received":return{status:"live",lastSuccessAt:n.at,retryCount:0,errorMessage:null};case"connection-lost":{const s=e.retryCount+1;return n.online?{...e,status:e.lastSuccessAt===null?"error":"reconnecting",retryCount:s,errorMessage:n.message}:{...e,status:"offline",retryCount:s,errorMessage:"Browser is offline."}}case"stale-timeout":return e.lastSuccessAt===null||e.status==="live"||e.status==="offline"?e:{...e,status:"stale"};case"browser-offline":return{...e,status:"offline",errorMessage:"Browser is offline."};case"stop-retrying":return{...e,status:"offline",errorMessage:"Automatic live updates are paused."};case"recoverable-error":return{...e,status:"error",errorMessage:n.message}}}function U4(e){return e===void 0||e.status==="live"?"empty":e.status}function B4(e){switch(e){case"connecting":return{title:"Connecting to the live stream...",description:"Waiting for the first successful initialization before checking for logs.",showConnectionCommands:!1};case"empty":return{title:"No logs captured yet.",description:"Connect an AI coding tool to capture its first request.",showConnectionCommands:!0};case"reconnecting":return{title:"Reconnecting to live updates...",description:"The stream was interrupted. Agent Inspector is retrying automatically.",showConnectionCommands:!1};case"stale":return{title:"Live data is stale.",description:"No logs are hidden; retry the connection to resume live updates.",showConnectionCommands:!1};case"offline":return{title:"Live updates are offline.",description:"Check the browser and Inspector connection, then retry.",showConnectionCommands:!1};case"error":return{title:"Live updates could not initialize.",description:"The error is recoverable. Retry without reloading the page.",showConnectionCommands:!1}}}const pd="agent-inspector.hierarchy.collapsedClients",hd="agent-inspector.hierarchy.collapsedProcesses";function cr(e){return e.some(n=>n.responseStatus===null)}function Jp(e){return e.filter(n=>n.responseStatus===null).length}function Xp(e){for(const n of e){const s=n.userAgent;if(s!=null&&s!=="")return s}return null}function q4(e){for(const n of e){const s=n.clientPid;if(s!=null)return s}return null}function Zp(e){for(const n of e){const s=n.clientProjectFolder;if(s!=null&&s!=="")return s}return null}function H4(e){return yl({userAgent:Xp(e.logs),conversationId:e.conversationId,clientProjectFolder:Zp(e.logs)})}function W4(e){if(e===null||e==="")return"Unknown client";const n=e.split(/[ /;]/)[0]??"";return n===""?"Unknown client":n}function V4(e,n){const s=$r(e);return s!==null?s:W4(n)}function dr(e){return e===null||e===""?"unknown":String(e)}function K4(e,n,s){return e!=="unknown"?e:`unknown:${dr(n)}:${dr(s)}`}function G4(e,n){return`${dr(e)}:${dr(n)}`}function xd(e){return[...e].sort((n,s)=>n.timestamp.localeCompare(s.timestamp))}function gd(e){let n="";for(const s of e)s.timestamp>n&&(n=s.timestamp);return n}function bd(e){return cr(e)?0:e.some(n=>n.error!==null&&n.error!==void 0||n.responseStatus!==null&&n.responseStatus!==void 0&&n.responseStatus>=400)?1:2}function Da(e){return[...e].sort((n,s)=>{const o=bd(n.logs)-bd(s.logs);if(o!==0)return o;const r=gd(s.logs).localeCompare(gd(n.logs));return r!==0?r:n.id.localeCompare(s.id)})}function Y4(e){const n=new Map;for(const o of e){const r=Xp(o.logs),a=Zp(o.logs),i=H4(o),c=K4(i,r,a);let d=n.get(c);d===void 0&&(d={id:c,client:i,label:V4(i,r),userAgent:r,processes:new Map,logs:[]},n.set(c,d)),d.logs.push(...o.logs);const m=q4(o.logs),u=`${c}:${G4(m,a)}`;let f=d.processes.get(u);f===void 0&&(f={id:u,clientPid:m,clientProjectFolder:a,sessions:[],logs:[]},d.processes.set(u,f)),f.sessions.push(o),f.logs.push(...o.logs)}const s=[];for(const o of n.values()){const r=Da([...o.processes.values()].map(a=>({id:a.id,clientPid:a.clientPid,clientProjectFolder:a.clientProjectFolder,sessions:Da(a.sessions),logs:xd(a.logs)})));s.push({id:o.id,client:o.client,label:o.label,userAgent:o.userAgent,processes:r,logs:xd(o.logs)})}return Da(s)}function ur(e){return e<=0?"0":Re(e)}function Qp(e){let n=0,s=0;for(const o of e)o.inputTokens!==null&&o.inputTokens!==void 0&&(n+=o.inputTokens),o.outputTokens!==null&&o.outputTokens!==void 0&&(s+=o.outputTokens);return{inputTokens:n,outputTokens:s}}function J4(e){let n=0;for(const s of e)n+=s.sessions.length;return n}function vd(e){if(typeof window>"u")return null;try{const n=window.localStorage.getItem(e);if(n===null)return null;const s=JSON.parse(n);return Array.isArray(s)?new Set(s.filter(o=>typeof o=="string")):null}catch{return null}}function yd(e,n){try{window.localStorage.setItem(e,JSON.stringify([...n]))}catch{}}function wd(e,n){let s=!1;const o=new Set(e);for(const r of n)o.delete(r)&&(s=!0);return s?o:e}function X4(e){const n=new Set;for(const s of e)for(let o=1;o<s.processes.length;o++){const r=s.processes[o];r!==void 0&&!cr(r.logs)&&n.add(r.id)}return n}function Z4(e){if(e===null||e==="")return null;const n=e.replaceAll("\\","/").split("/").filter(r=>r!==""),s=n[n.length-1];if(s===void 0)return e;const o=n[n.length-2];return o===void 0?s:`${o}/${s}`}function mr({label:e,value:n,className:s}){return t.jsxs("span",{className:O("inline-flex h-7 items-center gap-1 rounded-md bg-[var(--inspector-surface-low)] px-2 text-xs text-muted-foreground",s),children:[t.jsx("span",{className:"font-mono text-[10px] uppercase text-muted-foreground/70",children:e}),t.jsx("span",{className:"font-mono tabular-nums text-foreground",children:n})]})}function eh({count:e}){const n=`${e} open turn${e===1?"":"s"}`;return t.jsxs("span",{className:"relative inline-flex size-6 shrink-0 items-center justify-center rounded-md bg-[var(--inspector-surface-medium)] text-[var(--inspector-status-watch)] ring-1 ring-border/50","aria-label":n,title:n,children:[t.jsx(Ae,{className:"size-3 animate-spin"}),e>1&&t.jsx("span",{className:"absolute translate-x-2 -translate-y-2 rounded bg-card px-0.5 font-mono text-[8px] tabular-nums text-[var(--inspector-status-watch)]",children:e})]})}function Q4({groups:e,...n}){const s=l.useMemo(()=>Y4(e),[e]),[o,r]=l.useState(()=>new Set),[a,i]=l.useState(()=>X4(s)),[c,d]=l.useState(!1);l.useEffect(()=>{const f=vd(pd),p=vd(hd);f!==null&&r(f),p!==null&&i(p),d(!0)},[]),l.useEffect(()=>{c&&(yd(pd,o),yd(hd,a))},[o,a,c]),l.useEffect(()=>{const f=new Set(s.filter(h=>cr(h.logs)).map(h=>h.id)),p=new Set(s.flatMap(h=>h.processes.filter(g=>cr(g.logs)).map(g=>g.id)));r(h=>wd(h,f)),i(h=>wd(h,p))},[s]);const m=l.useCallback(f=>{r(p=>{const h=new Set(p);return h.has(f)?h.delete(f):h.add(f),h})},[]),u=l.useCallback(f=>{i(p=>{const h=new Set(p);return h.has(f)?h.delete(f):h.add(f),h})},[]);return t.jsx("div",{className:"space-y-2",children:s.map(f=>t.jsx(e_,{group:f,collapsed:o.has(f.id),collapsedProcessIds:a,onToggleClient:()=>m(f.id),onToggleProcess:u,conversationProps:n},f.id))})}function e_({group:e,collapsed:n,collapsedProcessIds:s,onToggleClient:o,onToggleProcess:r,conversationProps:a}){const i=Qp(e.logs),c=J4(e.processes),d=e.logs.length,m=Jp(e.logs),u=m>0;return t.jsxs("section",{className:O("relative isolate overflow-hidden rounded-[8px] bg-card/65",u&&"bg-card/80"),"data-ide-group":e.id,children:[t.jsxs("button",{type:"button",className:"grid w-full min-w-0 grid-cols-[2.25rem_minmax(0,1fr)_auto] items-center gap-2.5 px-3 py-2.5 text-left transition-colors hover:bg-[var(--inspector-surface-low)] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",onClick:o,"aria-expanded":!n,children:[e.client==="unknown"?t.jsx("span",{className:"inline-flex size-9 shrink-0 items-center justify-center rounded-md bg-[var(--inspector-surface-low)] text-muted-foreground",children:t.jsx(Cg,{className:"size-4"})}):t.jsx(Fr,{client:e.client,className:"size-9 rounded-md",decorative:!0}),t.jsxs("span",{className:"min-w-0",children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"truncate text-sm font-semibold text-foreground",title:e.userAgent??e.label,children:e.label}),t.jsx("span",{className:"rounded bg-[var(--inspector-surface-medium)] px-1.5 py-0.5 font-mono text-[9px] uppercase text-muted-foreground",children:aj(e.client)}),u&&t.jsx(eh,{count:m})]}),t.jsxs("span",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:[t.jsxs("span",{children:[e.processes.length," process",e.processes.length!==1?"es":""]}),t.jsxs("span",{children:[c," session",c!==1?"s":""]}),t.jsxs("span",{children:[d," req"]})]})]}),t.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[n&&t.jsxs("span",{className:"hidden shrink-0 items-center gap-2 md:flex",children:[t.jsx(mr,{label:"IN",value:ur(i.inputTokens)}),t.jsx(mr,{label:"OUT",value:ur(i.outputTokens)})]}),t.jsx("span",{className:"inline-flex size-8 shrink-0 items-center justify-center rounded-md bg-[var(--inspector-surface-low)] text-muted-foreground transition-colors group-hover:bg-[var(--inspector-surface-medium)]",children:n?t.jsx(ct,{className:"size-4"}):t.jsx(We,{className:"size-4"})})]})]}),!n&&t.jsx("div",{className:"space-y-0.5 px-2 pb-2 pt-0.5",children:e.processes.map(f=>t.jsx(t_,{group:f,collapsed:s.has(f.id),onToggle:()=>r(f.id),conversationProps:a},f.id))})]})}function t_({group:e,collapsed:n,onToggle:s,conversationProps:o}){const r=Qp(e.logs),a=Z4(e.clientProjectFolder),i=e.sessions.length,c=e.logs.length,d=Jp(e.logs),m=d>0,u=e.clientPid!==null&&e.clientPid!==void 0?`PID ${e.clientPid}`:"Process unavailable";return t.jsxs("section",{className:"relative pl-3",children:[t.jsxs("button",{type:"button",className:"grid w-full min-w-0 grid-cols-[2rem_minmax(0,1fr)_auto] items-center gap-2.5 rounded-md bg-[var(--inspector-surface-low)] px-2.5 py-2 text-left transition-colors hover:bg-[var(--inspector-surface-medium)] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",onClick:s,"aria-expanded":!n,children:[t.jsx("span",{className:"inline-flex size-8 shrink-0 items-center justify-center text-[var(--inspector-status-watch)]",children:t.jsx(z0,{className:"size-4"})}),t.jsxs("span",{className:"min-w-0",children:[t.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[t.jsx("span",{className:"font-mono text-xs font-semibold tabular-nums text-foreground",children:u}),m&&t.jsx(eh,{count:d}),a!==null&&t.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1 text-[11px] text-muted-foreground",title:e.clientProjectFolder??a,children:[t.jsx(ag,{className:"size-3 shrink-0"}),t.jsx("span",{className:"truncate font-mono",children:a})]})]}),t.jsxs("span",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:[t.jsxs("span",{children:[i," session",i!==1?"s":""]}),t.jsxs("span",{children:[c," req"]})]})]}),t.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[n&&t.jsxs("span",{className:"hidden shrink-0 items-center gap-2 md:flex",children:[t.jsx(mr,{label:"IN",value:ur(r.inputTokens)}),t.jsx(mr,{label:"OUT",value:ur(r.outputTokens)})]}),t.jsx("span",{className:"inline-flex size-7 shrink-0 items-center justify-center rounded-md bg-[var(--inspector-surface-low)] text-muted-foreground transition-colors hover:bg-[var(--inspector-surface-medium)]",children:n?t.jsx(ct,{className:"size-4"}):t.jsx(We,{className:"size-4"})})]})]}),!n&&t.jsx("div",{className:"space-y-1 pb-1 pl-3 pr-1 pt-1",children:e.sessions.map(f=>t.jsx(QN,{group:f,...o,showClientIdentity:!1,showLogClientMetadata:!1,showProcessMetadata:!1},f.id))})]})}const n_="w-[calc(100%-1rem)] border-warning/30 bg-popover text-popover-foreground sm:max-w-lg",s_=[{label:"Headers",detail:"request and response headers, including authorization or cookie values"},{label:"Prompts",detail:"system instructions, user prompts, model responses, and conversation history"},{label:"Source content",detail:"source code, file contents, tool inputs, and tool output"},{label:"Secrets",detail:"API keys, access tokens, credentials, and other sensitive values"}];function o_({onCancel:e,onExportRedacted:n,onConfirmRaw:s}){return t.jsxs(t.Fragment,{children:[t.jsxs(Ut,{children:[t.jsx(Bt,{children:"Export unredacted logs?"}),t.jsx(to,{children:"Raw exports bypass Agent Inspector redaction and may expose sensitive captured data."})]}),t.jsxs("div",{role:"alert",className:"rounded-md border border-warning/35 bg-warning/10 px-3 py-3 text-sm text-foreground",children:[t.jsx("p",{className:"font-medium",children:"The raw archive may include:"}),t.jsx("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-xs leading-relaxed text-muted-foreground",children:s_.map(o=>t.jsxs("li",{children:[t.jsxs("span",{className:"font-semibold text-foreground",children:[o.label,":"]})," ",o.detail]},o.label))}),t.jsx("p",{className:"mt-3 text-xs leading-relaxed text-muted-foreground",children:"Only continue if you trust where this file will be stored and everyone it may be shared with."})]}),t.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[t.jsx(te,{type:"button",variant:"outline",size:"sm",onClick:e,children:"Cancel"}),t.jsx(te,{type:"button",variant:"outline",size:"sm",onClick:n,children:"Export redacted instead"}),t.jsx(te,{type:"button",variant:"destructive",size:"sm",onClick:s,children:"Export raw data"})]})]})}const fr="data-nav-id",r_="data-nav-action";function jd(e){return Array.from(e.querySelectorAll(`[${fr}]`))}function Sd(e){return e instanceof HTMLElement}function a_(e,n){let s=e;for(;s!==null&&s!==n;){if(s.hasAttribute(fr))return s;s=s.parentElement}return e.hasAttribute(fr)?e:null}function za(e){const n=e.getAttribute(r_);return n==="toggle"||n==="expand"||n==="collapse"?n:null}function _s(e){e.focus({preventScroll:!0}),e.scrollIntoView({block:"nearest",behavior:"smooth"})}function Ts(e,n){return e[n]??null}function th(e){const n=e.tagName;return!!(n==="INPUT"||n==="TEXTAREA"||n==="SELECT"||e.isContentEditable)}function Nd(e){const n=e.tagName;return n==="BUTTON"||n==="A"||th(e)?!0:e.closest("[role='button'],[role='menuitem'],[role='option']")!==null}function i_(e){return e.closest("[role='dialog'],[role='menu'],[role='listbox']")!==null?!0:document.querySelector("[role='dialog'],[role='menu'],[role='listbox']")!==null}function l_(){const e=window.getSelection();return e===null?!1:e.type==="Range"&&e.toString().length>0}function ko(e,n){return e.key===n&&e.shiftKey}function c_(e,n,s={}){const o=n??e,r=s.pageWide===!0,a=l.useCallback(i=>{const c=e.current,d=o.current;if(!c||!d)return;const m=i.target;if(!Sd(m)||m!==d)return;const u=jd(c),f=Ts(u,0);f!==null&&_s(f)},[e,o]);l.useEffect(()=>{const i=c=>{if(c.altKey||c.ctrlKey||c.metaKey)return;const d=e.current;if(!d)return;const m=c.target;if(!Sd(m)||th(m)||l_())return;const u=d.contains(m);if(u&&Nd(m)&&!m.hasAttribute(fr)||!u&&(!r||Nd(m)||i_(m)))return;const f=jd(d);if(f.length===0)return;const p=a_(m,d),h=p!==null?f.indexOf(p):-1;let g=!1;switch(c.key){case"ArrowUp":case"W":{if(c.shiftKey&&c.key==="ArrowUp"||c.key==="W"&&!ko(c,"W"))break;c.preventDefault();const v=h>0?h-1:h===-1?f.length-1:-1;if(v!==-1){const y=Ts(f,v);y!==null&&_s(y)}g=!0;break}case"ArrowDown":case"S":{if(c.shiftKey&&c.key==="ArrowDown"||c.key==="S"&&!ko(c,"S"))break;c.preventDefault();const v=h<f.length-1?h+1:h===-1?0:-1;if(v!==-1){const y=Ts(f,v);y!==null&&_s(y)}g=!0;break}case"ArrowLeft":case"A":{if(c.shiftKey&&c.key==="ArrowLeft"||c.key==="A"&&!ko(c,"A")||p===null)break;if(c.preventDefault(),za(p)==="collapse")p.click();else if(h>0){const y=Ts(f,h-1);y!==null&&_s(y)}g=!0;break}case"ArrowRight":case"D":{if(c.shiftKey&&c.key==="ArrowRight"||c.key==="D"&&!ko(c,"D")||p===null)break;if(c.preventDefault(),za(p)==="expand")p.click();else if(h<f.length-1){const y=Ts(f,h+1);y!==null&&_s(y)}g=!0;break}case" ":{if(p===null)break;c.preventDefault(),za(p)!==null&&p.click(),g=!0;break}}g&&c.stopPropagation()};return document.addEventListener("keydown",i,{capture:!0}),()=>document.removeEventListener("keydown",i,{capture:!0})},[e,r,o]),l.useEffect(()=>(document.addEventListener("focusin",a),()=>document.removeEventListener("focusin",a)),[a])}const d_={system:"System",user:"User",assistant:"Assistant",tool:"Tool Results",tools:"Tool Definitions"},u_={system:"bg-sky-500/70",user:"bg-emerald-500/70",assistant:"bg-violet-500/70",tool:"bg-sky-400/55",tools:"bg-slate-500/70"},m_={system:"focus-visible:ring-sky-300",user:"focus-visible:ring-emerald-300",assistant:"focus-visible:ring-violet-300",tool:"focus-visible:ring-sky-300",tools:"focus-visible:ring-slate-300"},$a=12,_o=1,Cd=80,kd=24;function f_(e){return e.length<=kd?e:`${e.slice(0,kd-3)}...`}function p_(e){const n=e.replace(/\s+/g," ").trim();return n.length<=Cd?n:`${n.slice(0,Cd)}...`}function To(e){return e>=10?`${e.toFixed(0)}%`:e>=1?`${e.toFixed(1)}%`:e>0?"<1%":"0%"}const h_=l.memo(function({segments:n,totalTokens:s,showLabels:o=!0,onActivate:r}){const a=l.useMemo(()=>s>0?s:n.reduce((y,w)=>y+w.size,0),[n,s]),i=n.slice(0,$a),c=n.slice($a),d=c.reduce((y,w)=>y+w.size,0),m=c.length,u=$a,f=u+m-1,p=m>0,h=r!==void 0,g=l.useMemo(()=>i.reduce((y,w)=>y+w.size,0),[i]),v=l.useMemo(()=>`Request context: ~${Re(a)} tokens across ${n.length} segment${n.length===1?"":"s"}`,[n.length,a]);return n.length===0||a<=0?t.jsx("div",{role:"img","aria-label":v,className:"h-6"}):t.jsx(bs,{delayDuration:150,children:t.jsxs("div",{role:"img","aria-label":v,className:"flex flex-col gap-1.5",children:[t.jsxs("div",{className:"relative flex h-6 w-full overflow-hidden rounded border border-border/40 bg-muted/30","data-testid":"anatomy-segment-bar",children:[i.map((y,w)=>{const b=a>0?y.size/a*100:0,j=Math.max(_o,b),S=O("h-full border-r border-background/80 last:border-r-0",h?"opacity-90 hover:opacity-100 focus:opacity-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-offset-background":"opacity-90",u_[y.role],h?m_[y.role]:""),N={width:`${j}%`},C=`${y.label}, ${To(b)}, ~${Re(y.size)} tokens`;return t.jsxs(nt,{children:[t.jsx(st,{asChild:!0,children:h?t.jsx("button",{type:"button",role:"button",tabIndex:0,onClick:()=>r(y),onKeyDown:R=>{(R.key==="Enter"||R.key===" ")&&(R.preventDefault(),r(y))},"data-anatomy-path":y.path,"aria-label":C,className:S,style:N}):t.jsx("span",{"aria-label":C,className:S,style:N})}),t.jsxs(ot,{side:"bottom",className:"max-w-sm text-xs p-2 space-y-0.5",children:[t.jsxs("div",{className:"font-semibold",children:[y.label," - ",To(b)," - ~",Re(y.size)," ","tokens"]}),t.jsx("div",{className:"text-muted-foreground",children:d_[y.role]}),t.jsxs("div",{className:"text-muted-foreground",children:[y.characters.toLocaleString()," chars"]}),y.text.length>0&&t.jsx("div",{className:"text-muted-foreground/90 break-words whitespace-pre-wrap",children:p_(y.text)})]})]},`${y.path}-${w}`)}),p&&t.jsxs(nt,{children:[t.jsx(st,{asChild:!0,children:t.jsxs("div",{role:"img","aria-label":`${m} additional segments`,className:"flex h-full items-center justify-center bg-muted-foreground/30 px-1.5 text-[10px] font-mono text-background",style:{width:`${Math.max(_o,d/a*100)}%`},children:["... +",m]})}),t.jsxs(ot,{side:"bottom",className:"text-xs",children:[m," more segment",m===1?"":"s"," (indices"," ",u,"-",f,")"]})]})]}),o&&t.jsxs("div",{className:"flex w-full gap-1 text-[10px] text-muted-foreground",children:[i.map((y,w)=>{const b=a>0?y.size/a*100:0,j=Math.max(_o,b);return t.jsxs("div",{className:"flex flex-col gap-0.5 truncate",style:{width:`${j}%`},title:`${y.label} - ${To(b)} - ~${Re(y.size)} tokens`,children:[t.jsx("span",{className:"truncate font-mono text-foreground/80",children:f_(y.label)}),t.jsxs("span",{className:"truncate font-mono text-muted-foreground/70",children:[To(b)," - ~",Re(y.size)]})]},`label-${y.path}-${w}`)}),p&&t.jsxs("div",{className:"flex flex-col gap-0.5 truncate text-muted-foreground",style:{width:`${Math.max(_o,d/a*100)}%`},children:[t.jsxs("span",{className:"truncate font-mono text-foreground/60",children:["... +",m]}),t.jsxs("span",{className:"truncate font-mono text-muted-foreground/60",children:["~",Re(d)]})]})]}),g<a*.1&&t.jsx("div",{className:"h-0"})]})})}),nh=.75,sh=.9,wi=8e3,x_=.35,oh=40,rh=160,g_=5,b_=8,v_=18,y_=6e4,w_=.7,_d=3e3,j_=.3,Td=160,S_=new Set(["answer","body","content","data","error","message","markdown","output","response","result","stderr","stdout","text","transcript"]),N_=["context_window","contextWindow","context_length","contextLength","max_context_length","maxContextLength","max_input_tokens","maxInputTokens"],C_=["max_tokens","maxTokens","max_completion_tokens","maxCompletionTokens","max_output_tokens","maxOutputTokens"],k_=[{family:"OpenAI GPT-4.1",tokens:1047576,mode:"prefix",patterns:["gpt-4.1"]},{family:"OpenAI GPT-4o",tokens:128e3,mode:"prefix",patterns:["gpt-4o"]},{family:"OpenAI o-series",tokens:128e3,mode:"prefix",patterns:["o1","o3","o4"]},{family:"Anthropic Claude",tokens:2e5,mode:"prefix",patterns:["claude-"]},{family:"DeepSeek V4",tokens:1048576,mode:"prefix",patterns:["deepseek-v4-pro","deepseek-v4-flash"]},{family:"DeepSeek",tokens:64e3,mode:"prefix",patterns:["deepseek-"]},{family:"MiniMax M3",tokens:1048576,mode:"includes",patterns:["minimax-m3"]},{family:"MiniMax M2.7",tokens:204800,mode:"includes",patterns:["minimax-m2.7"]},{family:"MiniMax M2.5/M2.1",tokens:196608,mode:"includes",patterns:["minimax-m2.5","minimax-m2.1"]},{family:"GLM-5.2",tokens:1048576,mode:"prefix",patterns:["glm-5.2"]},{family:"GLM-5",tokens:202752,mode:"prefix",patterns:["glm-5","glm-5.1"]}],__={system:"System",user:"User messages",assistant:"Assistant messages",tool:"Tool results",tools:"Tool definitions"};function T_(e){if(typeof e=="number")return Number.isFinite(e)&&e>0?Math.floor(e):null;if(typeof e=="string"){const n=Number(e);if(Number.isFinite(n)&&n>0)return Math.floor(n)}return null}function ah(e,n){for(const s of n){const o=T_(ne(e,s));if(o!==null)return o}return null}function E_(e){const n=ne(e,"model");if(typeof n!="string")return null;const s=n.trim();return s===""?null:s}function R_(e,n){switch(n.mode){case"prefix":return n.patterns.some(s=>e.startsWith(s));case"includes":return n.patterns.some(s=>e.includes(s))}}function M_(e,n,s=[]){const o=ah(n,N_);if(o!==null)return{tokens:o,label:"Request metadata",source:"request"};const r=Ak(e,s);if(r!==null)return{tokens:r.tokens,label:`${r.providerName} config`,source:"provider"};if(e===null)return{tokens:null,label:"Unknown model",source:"unknown"};const a=e.trim().toLowerCase().replace(/\s+/g,"-");for(const i of k_)if(R_(a,i))return{tokens:i.tokens,label:`${i.family} local rule`,source:"model-rule"};return{tokens:null,label:"No local rule",source:"unknown"}}function A_(e){return e<0?0:e>1?1:e}function I_(e){return e===null?"unknown":e>=sh?"danger":e>=nh?"watch":"ok"}function P_(e,n){return e.filter(s=>s.role===n).reduce((s,o)=>s+o.size,0)}function L_(e,n){return["system","user","assistant","tool","tools"].map(o=>{const r=P_(e,o);return{role:o,label:__[o],tokens:r,percent:n>0?r/n:0}}).filter(o=>o.tokens>0).sort((o,r)=>r.tokens-o.tokens)}function ji(e){return e.replace(/\s+/g," ").trim().toLowerCase()}function O_(e){const n=e.replace(/\s+/g," ").trim();return n.length<=Td?n:`${n.slice(0,Td-3)}...`}function D_(e){return{role:e.role,label:e.label,path:e.path,tokens:e.tokens,characters:e.characters}}function z_(e){return{role:e.role,label:e.label,path:e.path,tokens:e.size,characters:e.characters,text:e.text}}function $_(e){const n=e.trim();return n.startsWith("{")||n.startsWith("[")}function F_(e){if(!$_(e))return null;try{return JSON.parse(e)}catch{return null}}function U_(e){return e.toLowerCase().replace(/[^a-z0-9]/g,"")}function B_(e){for(let n=e.length-1;n>=0;n-=1){const s=e[n]??"";if(!(s.startsWith("[")&&s.endsWith("]")))return s}return null}function q_(e){const n=B_(e);return n===null?!1:S_.has(U_(n))}function H_(e){return e.map(n=>n.startsWith("[")?n:`.${n}`).join("").replace(/^\./,"")}function W_(e,n,s){const o=jl(n);if(o<rh)return null;const r=wl(n);return r<oh?null:{role:e.role,label:`${e.label} ${H_(s)}`,path:e.path,tokens:r,characters:o,text:n}}function Si({value:e,segment:n,path:s,depth:o,candidates:r}){if(!(r.length>=b_)&&!(o>g_)){if(typeof e=="string"){if(!q_(s))return;const a=W_(n,e,s);a!==null&&r.push(a);return}if(Array.isArray(e)){e.forEach((a,i)=>Si({value:a,segment:n,path:[...s,`[${String(i)}]`],depth:o+1,candidates:r}));return}Sl(e)&&Object.entries(e).forEach(([a,i])=>Si({value:i,segment:n,path:[...s,a],depth:o+1,candidates:r}))}}function V_(e){const n=z_(e),s=F_(e.text);if(s===null)return[n];const o=[];Si({value:s,segment:e,path:[],depth:0,candidates:o});const r=ji(e.text),a=new Set([r]),i=o.filter(c=>{const d=ji(c.text);return d===""||a.has(d)?!1:(a.add(d),!0)});return[n,...i]}function K_(e){const n=new Map;for(const o of e){const r=V_(o);for(const a of r){if(a.tokens<oh||a.characters<rh)continue;const i=ji(a.text);if(i==="")continue;const c=n.get(i);if(c===void 0){n.set(i,{tokens:a.tokens,candidates:[a]});continue}n.set(i,{tokens:c.tokens+a.tokens,candidates:[...c.candidates,a]})}}const s=[];for(const o of n.values()){if(o.candidates.length<2)continue;const r=o.candidates[0]??null;if(r===null)continue;const a=o.tokens-r.tokens;s.push({key:`${r.path}:${r.label}:${String(o.candidates.length)}:${String(o.tokens)}`,count:o.candidates.length,totalTokens:o.tokens,repeatedTokens:a,preview:O_(r.text),firstLabel:r.label,segments:o.candidates.map(D_)})}return s.sort((o,r)=>r.repeatedTokens-o.repeatedTokens||r.totalTokens-o.totalTokens)}function G_(e){if(e.length===0)return null;const n=e.length,s=e.reduce((r,a)=>r+a.count,0),o=e.reduce((r,a)=>r+a.repeatedTokens,0);return{kind:"duplicate",severity:o>=wi?"danger":"watch",title:"Duplicate context",detail:`${String(s)} repeated blocks across ${String(n)} group${n===1?"":"s"}, ~${String(o)} repeated tokens.`}}function Y_(e){return e.reduce((n,s)=>n+s.repeatedTokens,0)}function J_(e,n,s){const o=[],r=e.find(d=>d.role==="tools")??null;r!==null&&(r.tokens>=wi||r.percent>=x_&&r.tokens>=_d)&&o.push({kind:"tool-schema",severity:r.tokens>=wi?"danger":"watch",title:"Large tool schema",detail:`Tool definitions take ${Math.round(r.percent*100)}% of request context.`});const a=e.find(d=>d.role==="system")??null;a!==null&&a.tokens>=_d&&a.percent>=j_&&o.push({kind:"system-heavy",severity:"watch",title:"Large system prompt",detail:`System instructions take ${Math.round(a.percent*100)}% of request context.`});const i=e.filter(d=>d.role==="user"||d.role==="assistant"||d.role==="tool").reduce((d,m)=>d+m.tokens,0),c=n>0?i/n:0;return s>=v_&&(i>=y_||c>=w_)&&o.push({kind:"history-bloat",severity:c>=.85?"danger":"watch",title:"Conversation history growth",detail:`${String(s)} message blocks take ${Math.round(c*100)}% of request context.`}),o}function X_({risk:e,contextWindow:n,diagnostics:s,duplicateGroups:o}){let a=new Set(s.map(d=>d.kind)).size;(e==="watch"||e==="danger")&&(a+=1),n.source==="unknown"&&(a+=1);const i=s.some(d=>d.severity==="danger");return{level:e==="danger"||i?"risk":a>0?"optimizable":"ok",opportunityCount:a,reclaimableTokens:Y_(o)}}function Z_({segments:e,inputTokens:n,parsed:s,model:o,providers:r=[]}){const a=e.reduce((C,R)=>C+R.size,0),i=o??E_(s),c=n??a,d=ah(s,C_),m=M_(i,s,r),u=d??0,f=m.tokens===null?null:c+u,p=m.tokens===null?null:m.tokens-c,h=m.tokens===null?null:m.tokens-c-u,g=m.tokens===null||f===null?null:A_(f/m.tokens),v=L_(e,a),y=v[0]??null,w=e.filter(C=>C.role!=="tools").length,b=K_(e),j=G_(b),S=J_(v,a,w);j!==null&&S.unshift(j);const N=I_(g);return{model:i,contextWindow:m,estimatedInputTokens:c,outputReserveTokens:d,windowUsedTokens:f,remainingInputTokens:p,remainingAfterReserveTokens:h,usagePercent:g,riskLevel:N,roleUsages:v,largestRole:y,diagnostics:S,duplicateGroups:b,health:X_({risk:N,contextWindow:m,diagnostics:S,duplicateGroups:b})}}const uE={watch:nh,danger:sh},Ed=new WeakMap;function Q_(e){return e.map(n=>{const s=n.modelMetadata?.map(o=>`${o.model}:${String(o.contextWindow??"")}`).join(",")??"";return`${n.id}:${n.updatedAt}:${n.models.join(",")}:${s}`}).join("|")}function eT(e){if(e===null)return null;try{return JSON.parse(e)}catch{return null}}function tT(e){return{role:e.role,label:e.label,size:e.tokens,characters:e.tokens*4,text:"",path:`role:${e.role}`}}function nT(e,n){const s=eT(e.rawRequestBody);if(s===null)return null;const r=ep(Fs(e)).anatomySegments(s);if(r===null)return null;const a=Z_({segments:r,inputTokens:e.inputTokens??null,parsed:s,model:e.model,providers:n}),i=a.model??e.model??"Unknown model",c=a.roleUsages.map(tT);return{logId:e.id,model:i,timestamp:e.timestamp,contextWindow:a.contextWindow,estimatedInputTokens:a.estimatedInputTokens,windowUsedTokens:a.windowUsedTokens,usagePercent:a.usagePercent,riskLevel:a.riskLevel,health:a.health,diagnostics:a.diagnostics.map(d=>d.title),roleSegments:c,roleTotalTokens:c.reduce((d,m)=>d+m.size,0)}}function sT(e,n,s){const o=Ed.get(e);if(o!==void 0&&o.id===e.id&&o.rawRequestBody===e.rawRequestBody&&o.inputTokens===e.inputTokens&&o.model===e.model&&o.path===e.path&&o.apiFormat===e.apiFormat&&o.timestamp===e.timestamp&&o.providersSignature===s)return o.snapshot;const r=nT(e,n);return Ed.set(e,{id:e.id,rawRequestBody:e.rawRequestBody,inputTokens:e.inputTokens,model:e.model,path:e.path,apiFormat:e.apiFormat,timestamp:e.timestamp,providersSignature:s,snapshot:r}),r}function oT(e,n){return e.usagePercent!==null&&n.usagePercent!==null?e.usagePercent>n.usagePercent:e.usagePercent!==null&&n.usagePercent===null?!0:e.usagePercent===null&&n.usagePercent!==null?!1:e.estimatedInputTokens>n.estimatedInputTokens}function Rd(e){switch(e){case"danger":return 4;case"watch":return 3;case"unknown":return 2;case"ok":return 1}}function rT(e,n){const s=Rd(n.latest.riskLevel)-Rd(e.latest.riskLevel);if(s!==0)return s;const o=e.peak.usagePercent??-1,a=(n.peak.usagePercent??-1)-o;return a!==0?a:n.latest.logId-e.latest.logId}function aT(e,n){return e.usagePercent===null||n.usagePercent===null?null:(n.usagePercent-e.usagePercent)*100}function iT(e){for(let n=1;n<e.length;n++){const s=e[n-1],o=e[n];if(!(s===void 0||o===void 0)&&s.id>o.id)return[...e].sort((r,a)=>r.id-a.id)}return e}function lT(e,n=[]){const s=iT(e),o=Q_(n),r=new Map;for(const i of s){const c=sT(i,n,o);if(c===null)continue;const d=r.get(c.model);if(d===void 0){r.set(c.model,{model:c.model,requestCount:1,first:c,latest:c,peak:c});continue}r.set(c.model,{model:d.model,requestCount:d.requestCount+1,first:d.first,latest:c,peak:oT(c,d.peak)?c:d.peak})}return{models:[...r.values()].map(i=>({model:i.model,requestCount:i.requestCount,first:i.first,latest:i.latest,peak:i.peak,trendPercent:aT(i.first,i.latest)})).sort(rT)}}function kn(e){return e.length<=30?e:`${e.slice(0,12)}...${e.slice(-12)}`}function cT(e){const n=new Map;for(const s of e)for(let o=0;o<s.logs.length;o+=1){const r=s.logs[o];r!==void 0&&n.set(r.id,o+1)}return n}function Md(e,n){return n.get(e.id)??e.id}function Ad(e){let n=0,s=0;for(const o of e)o.inputTokens!==null&&(n+=o.inputTokens),o.outputTokens!==null&&(s+=o.outputTokens);return{totalIn:n,totalOut:s}}function dT(e){for(const n of e)if(n.userAgent!==null&&n.userAgent!==void 0&&n.userAgent!=="")return n.userAgent;return null}function uT(e,n){const s=e[0],o=e[e.length-1];return s===void 0||o===void 0?null:br(s.timestamp,o.timestamp,n)}function mT(e){switch(e){case"cool":return"text-status-cool";case"danger":return"text-status-danger";case"watch":return"text-status-watch";case"neutral":return"text-foreground"}}function fT(e){switch(e){case"rolling":return t.jsx(yt,{className:"size-3 text-status-cool"});case"failed":return t.jsx(Ko,{className:"size-3 text-status-danger"});case"watch":return t.jsx(wu,{className:"size-3 text-status-watch"});case"clear":return t.jsx(Pe,{className:"size-3 text-status-success"})}}function pT(e){switch(e){case"rolling":return"cool";case"failed":return"danger";case"watch":return"watch";case"clear":return"neutral"}}function hT(e){return e.pending>0?`${e.pending} pending / ${e.failures} failed`:e.lengthStops>0?`${e.lengthStops} output limit / ${e.failures} failed`:`${e.failures} failed / ${e.slow} slow`}function Xn({label:e,value:n,detail:s,icon:o,tone:r="neutral"}){return t.jsxs("div",{className:"min-w-0 border-t border-border/60 px-4 py-3",children:[t.jsxs("div",{className:"flex items-center gap-1 text-[10px] uppercase text-muted-foreground",children:[o,e]}),t.jsx("div",{className:O("mt-2 font-mono text-sm font-semibold",mT(r)),children:n}),t.jsx("div",{className:"mt-1 font-mono text-[11px] leading-snug text-muted-foreground",children:s})]})}function xT({stats:e}){return e.requests===0?null:t.jsxs("div",{className:"mb-4 overflow-hidden rounded-[8px] border border-border bg-card",children:[t.jsx("div",{className:"px-4 py-3",children:t.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-semibold uppercase text-muted-foreground",children:[t.jsx(_0,{className:"size-3.5 text-slate-300"}),"Flight Recorder"]}),t.jsx("div",{className:"mt-2 min-w-0 font-mono text-sm font-semibold text-foreground",children:e.modelLabel})]}),t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-muted-foreground",children:[t.jsx("span",{className:"min-w-0 font-mono",children:e.providerLabel}),t.jsx("span",{className:"min-w-0 font-mono",children:e.timeRange??"Timeline pending"})]})]})}),t.jsxs("div",{className:"grid grid-cols-2 border-t border-border/60 md:grid-cols-3 2xl:grid-cols-6",children:[t.jsx(Xn,{label:"Status",value:e.statusLabel,detail:hT(e),icon:fT(e.status),tone:pT(e.status)}),t.jsx(Xn,{label:"Turns",value:String(e.turns),detail:e.finishLabel,icon:t.jsx(sg,{className:"size-3 text-muted-foreground"}),tone:e.finishTone}),t.jsx(Xn,{label:"Requests",value:String(e.requests),detail:`${e.failures} failed / ${e.slow} slow`,icon:t.jsx(Ko,{className:"size-3 text-muted-foreground"}),tone:e.failures>0?"danger":"neutral"}),t.jsx(Xn,{label:"Peak",value:e.slowestLabel,detail:e.slowestDetail,icon:t.jsx(wu,{className:"size-3 text-muted-foreground"}),tone:e.slow>0?"watch":"neutral"}),t.jsx(Xn,{label:"Tokens",value:e.tokenLabel,detail:e.heaviestDetail,icon:t.jsx(qi,{className:"size-3 text-muted-foreground"})}),t.jsx(Xn,{label:"Outcome",value:e.outcomeLabel,detail:e.outcomeDetail,tone:e.outcomeTone})]})]})}function Ps(e){if(e===null)return"Unknown";const n=e*100;return n>=10?`${n.toFixed(0)}%`:n>=1?`${n.toFixed(1)}%`:n>0?"<1%":"0%"}function gT(e){return e===null?"n/a":Math.abs(e)<.1?"0%":`${e>0?"+":""}${e.toFixed(1)}%`}function Ni(e){return e===null||!Number.isFinite(e)?0:Math.min(Math.max(e*100,0),100)}function bT(e,n){if(n===null)return null;const s=Ni(e),o=Ni(n);return o<=0||Math.abs(o-s)<.5?null:o}function vT(e){switch(e){case"danger":return"bg-red-400";case"watch":return"bg-amber-300";case"unknown":return"bg-muted-foreground/50";case"ok":return"bg-cyan-300"}}function yT(e){const n=e.latest.contextWindow.tokens;return n===null?"Context window unknown":`Context window ${Bd(n)}`}const wT=["score","decision","final_status","validation_pass_ratio","semantic_memory_score","opencode_exit","actual_model","run_dir","workspace","project_dir","work_dir"];function ih(e){return typeof e=="string"?e.length>0?e:null:typeof e=="number"||typeof e=="boolean"?String(e):e===null?null:JSON.stringify(e)}function Fa(e,n){if(e===null)return null;const s=e.metadata[n];return s===void 0?null:ih(s)}function jT(e){const n=e.toLowerCase();return n.includes("reject")||n.includes("fail")||n.includes("error")?"border-red-400/35 bg-red-500/10 text-red-100":n.includes("partial")||n.includes("pending")||n.includes("slow")?"border-amber-300/35 bg-amber-400/10 text-amber-100":n.includes("pass")||n.includes("complete")||n.includes("accept")?"border-cyan-300/25 bg-cyan-400/10 text-cyan-100":"border-border/70 bg-background/70 text-muted-foreground"}function ST(e){const n=[];for(const s of wT){const o=e.metadata[s];if(o===void 0)continue;const r=ih(o);r!==null&&n.push({key:s,value:r})}return n}function Id({memberships:e,defaultOpen:n=!1}){const[s,o]=l.useState(n);if(e.length===0)return null;const r=e[0],a=r?.member??null,i=Fa(a,"score"),c=Fa(a,"decision"),d=Fa(a,"final_status"),m=[i===null?null:{label:`score ${i}`,value:i},c===null?null:{label:c,value:c},d===null?null:{label:d,value:d},a?.model===null||a?.model===void 0?null:{label:a.model,value:a.model}].filter(u=>u!==null&&u.label.length>0&&u.value.length>0);return t.jsxs("div",{className:"border border-border bg-card shadow-sm mb-3 rounded-[8px] text-xs",children:[t.jsxs("button",{type:"button",onClick:()=>o(u=>!u),className:"flex w-full items-center gap-3 px-3 py-2 text-left transition-colors hover:bg-white/[0.04]","aria-expanded":s,children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[t.jsx("span",{className:"font-semibold text-foreground",children:"Case File"}),r!==void 0&&t.jsx("span",{className:"truncate text-muted-foreground",title:r.groupTitle,children:r.groupTitle}),t.jsxs("span",{className:"font-mono text-[10px] uppercase text-muted-foreground",children:[e.length," group",e.length===1?"":"s"]})]}),m.length>0&&t.jsx("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:m.slice(0,4).map(u=>t.jsx("span",{className:O("rounded border px-1.5 py-0.5 font-mono text-[10px]",jT(u.value)),children:u.label},u.label))})]}),s?t.jsx(Ui,{className:"size-4 shrink-0 text-muted-foreground"}):t.jsx(We,{className:"size-4 shrink-0 text-muted-foreground"})]}),s&&t.jsx("div",{className:"space-y-2 border-t border-white/10 px-3 py-2",children:e.map(u=>{const f=u.member,p=ST(f);return t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[t.jsx("span",{className:"truncate font-medium text-foreground",title:u.groupTitle,children:u.groupTitle}),t.jsx("span",{className:"font-mono text-[10px] uppercase text-muted-foreground",children:u.groupStatus}),f.status!==null&&t.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:["member ",f.status]})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-muted-foreground",children:[t.jsx("span",{className:"font-mono",title:f.sessionId,children:kn(f.sessionId)}),f.label!==null&&t.jsx("span",{children:f.label}),f.provider!==null&&t.jsx("span",{children:f.provider}),f.model!==null&&t.jsx("span",{className:"font-mono",children:f.model}),f.runId!==null&&t.jsxs("span",{className:"font-mono",title:f.runId,children:["run ",kn(f.runId)]})]}),p.length>0&&t.jsx("div",{className:"mt-2 grid gap-1 sm:grid-cols-2 xl:grid-cols-3",children:p.map(h=>t.jsxs("div",{className:"border border-border bg-muted/40 min-w-0 rounded-md px-2 py-1",children:[t.jsx("div",{className:"font-mono text-[10px] text-muted-foreground",children:h.key}),t.jsx("div",{className:"truncate font-mono text-[11px] text-foreground",title:h.value,children:h.value})]},h.key))})]},`${u.groupId}:${f.id}`)})})]})}function Eo({label:e,title:n,icon:s,disabled:o,onClick:r}){return t.jsxs("button",{type:"button",onClick:r,disabled:o,className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-45",title:n,children:[s,t.jsx("span",{children:e})]})}function Pd({logs:e,pagination:n,embedded:s=!1}){if(n===void 0)return null;const o=n.isLoading;return t.jsxs("nav",{"aria-label":"Session log pagination",className:O("flex min-h-9 flex-col gap-2 px-1 py-1 sm:flex-row sm:items-center",s?"border-t border-white/10 pt-2":"border border-border bg-card shadow-sm mb-3 rounded-[8px] px-2"),children:[t.jsxs("div",{className:"w-full min-w-0 px-1 font-mono text-[11px] text-muted-foreground sm:flex-1",children:[t.jsxs("div",{role:"status","aria-live":"polite","aria-atomic":"true",children:[bC({logs:e,pagination:n}),n.isLoading&&e.length>0&&t.jsx("span",{className:"ml-2",children:"Loading..."})]}),n.loadProgress!==void 0&&t.jsx($o,{progress:n.loadProgress})]}),t.jsxs("div",{className:"flex w-full items-center gap-1 overflow-x-auto sm:w-auto",children:[t.jsx(Eo,{label:"Oldest",title:"Load the oldest logs in this session",icon:t.jsx(f0,{className:"size-3.5"}),disabled:o||!n.hasOlder,onClick:n.onOldest}),t.jsx(Eo,{label:"Older",title:"Load older logs",icon:t.jsx(i0,{className:"size-3.5"}),disabled:o||!n.hasOlder,onClick:n.onOlder}),t.jsx(Eo,{label:"Newer",title:"Load newer logs",icon:t.jsx(ct,{className:"size-3.5"}),disabled:o||!n.hasNewer,onClick:n.onNewer}),t.jsx(Eo,{label:"Newest",title:"Load the newest logs in this session",icon:t.jsx(h0,{className:"size-3.5"}),disabled:o||!n.hasNewer,onClick:n.onNewest})]})]})}function NT(e){return`${e} ${e===1?"request":"requests"}`}function Ld(e){return`#${String(e)}`}function Od(e){switch(e){case"danger":return"text-red-300";case"watch":return"text-amber-200";case"unknown":return"text-muted-foreground";case"ok":return"text-cyan-200"}}function CT(e){switch(e){case"risk":return"border-red-400/30 bg-red-500/10 text-red-100";case"optimizable":return"border-amber-400/25 bg-amber-400/8 text-amber-100";case"ok":return"border-cyan-300/25 bg-cyan-400/8 text-cyan-100"}}function kT(e){switch(e){case"risk":return"Risk";case"optimizable":return"Optimizable";case"ok":return"OK"}}const _T=10,TT=80;function ET(e){e.setAttribute("data-deep-link-highlight","true"),window.setTimeout(()=>{e.removeAttribute("data-deep-link-highlight")},1800)}function RT(e){const n=document.getElementById(`log-${String(e)}`);return n instanceof HTMLElement?(n.scrollIntoView({block:"center",behavior:Gp(Yp())}),n.focus({preventScroll:!0}),ET(n),!0):!1}function lh(e){fs({logId:e,tab:"anatomy"});let n=0;const s=()=>{fs({logId:e,tab:"anatomy"}),!RT(e)&&(n+=1,n<_T&&window.setTimeout(s,TT))};window.setTimeout(s,0)}function MT({command:e}){const[n,s]=l.useState(!1),o=l.useCallback(()=>{vt(e).then(r=>{r&&(s(!0),setTimeout(()=>s(!1),2e3))})},[e]);return t.jsxs("div",{"data-command-example":"true",className:eC,children:[t.jsx("pre",{className:tC,children:e}),t.jsx("button",{type:"button",onClick:o,className:"shrink-0 cursor-pointer rounded-sm text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none","aria-label":"Copy command",children:n?t.jsx(Pe,{className:"size-4"}):t.jsx(St,{className:"size-4"})})]})}function Ua({label:e,children:n,className:s}){return t.jsxs("section",{className:O("rounded-[8px] border border-border/60 bg-card/55",s),children:[t.jsx("div",{className:"px-3 pt-3",children:t.jsx("div",{className:"font-mono text-[10px] font-semibold uppercase tracking-[0.14em] text-text-subtle",children:e})}),t.jsx("div",{className:"p-3 pt-2",children:n})]})}function Ro({label:e,value:n}){return t.jsxs("div",{className:"min-w-0 rounded-md border border-border/50 bg-muted/30 px-2 py-2",children:[t.jsx("div",{className:"truncate font-mono text-lg font-semibold leading-6 text-text-strong",children:n}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] uppercase tracking-[0.12em] text-text-subtle",children:e})]})}function AT(){const{themeMode:e,setThemeMode:n}=Z1();return t.jsxs("div",{className:"inline-flex h-9 items-center rounded-md border border-border/70 bg-muted/70 p-0.5","aria-label":"Theme mode",role:"group",children:[t.jsx("button",{type:"button",onClick:()=>n("light"),className:O("inline-flex size-8 items-center justify-center rounded-[6px] text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none max-lg:size-11",e==="light"&&"bg-background text-foreground shadow-sm"),"aria-label":"Use light mode","aria-pressed":e==="light",title:"Light mode",children:t.jsx(f1,{className:"size-3.5"})}),t.jsx("button",{type:"button",onClick:()=>n("eye-care"),className:O("inline-flex size-8 items-center justify-center rounded-[6px] text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none max-lg:size-11",e==="eye-care"&&"bg-background text-foreground shadow-sm"),"aria-label":"Use eye care mode","aria-pressed":e==="eye-care",title:"Eye care mode",children:t.jsx(fu,{className:"size-3.5"})}),t.jsx("button",{type:"button",onClick:()=>n("dark"),className:O("inline-flex size-8 items-center justify-center rounded-[6px] text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none max-lg:size-11",e==="dark"&&"bg-background text-foreground shadow-sm"),"aria-label":"Use dark mode","aria-pressed":e==="dark",title:"Dark mode",children:t.jsx(_g,{className:"size-3.5"})})]})}function IT({visible:e,onToggle:n}){const s=e?"Hide Inspector pet":"Summon Inspector pet";return t.jsx("button",{type:"button",onClick:n,className:O("border-border/70 bg-muted/70 inline-flex size-8 shrink-0 items-center justify-center rounded-md border text-muted-foreground shadow-sm transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",e&&"bg-background text-amber-500 shadow-sm"),"aria-label":s,"aria-pressed":e,title:s,children:t.jsx(qd,{className:O("size-4 transition-opacity",!e&&"opacity-45")})})}function PT({preference:e,resolvedScale:n,onChange:s}){const o=ob(n),r=e==="auto"?`Auto (${o})`:`${e}%`;return t.jsxs(Bs,{value:e,onValueChange:a=>s(Ki(a)),children:[t.jsxs(qs,{size:"sm",className:"h-9 min-w-[4.5rem] justify-center gap-1 border-border/70 bg-muted/70 px-2 py-0 text-muted-foreground hover:bg-muted max-lg:h-11 [&>svg:last-child]:hidden","aria-label":`Interface size: ${r}`,children:[t.jsx(Dx,{className:"size-3.5"}),t.jsx("span",{className:"font-mono text-[10px] font-semibold tabular-nums",children:o})]}),t.jsxs(Hs,{align:"end",children:[t.jsx(Ze,{value:"auto",children:"Auto"}),t.jsx(Ze,{value:"100",children:"100%"}),t.jsx(Ze,{value:"125",children:"125%"}),t.jsx(Ze,{value:"150",children:"150%"})]})]})}const ch="agent-inspector.detailsPanelCollapsed",dh="agent-inspector.detailsPanelWidth",uh="agent-inspector.pet.visible",es=360,LT=288,OT=520;function mh(e){return Math.min(Math.max(e,LT),OT)}function DT(){if(typeof window>"u")return!0;try{const e=window.localStorage.getItem(ch);return e===null||e==="1"}catch{return!0}}function zT(){if(typeof window>"u")return es;try{const e=window.localStorage.getItem(dh);if(e===null)return es;const n=Number.parseInt(e,10);return Number.isFinite(n)?mh(n):es}catch{return es}}function $T(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(uh)!=="0"}catch{return!0}}function Dd({label:e,logId:n}){return t.jsxs("button",{type:"button",onClick:()=>lh(n),className:"inline-flex h-5 items-center rounded px-1 font-mono text-[10px] text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground",title:`Open Context for ${Ld(n)}`,children:[e," ",Ld(n)]})}function FT({latestPercent:e,peakPercent:n,risk:s,onOpenContext:o}){const r=Ni(e),a=bT(e,n),i=n===null?`Latest context window usage ${Ps(e)}`:`Latest context window usage ${Ps(e)}, peak ${Ps(n)}`;return t.jsx("button",{type:"button",onClick:o,className:"group block w-full rounded-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1","aria-label":`${i}. Open latest Context details`,title:"Open latest Context details",children:t.jsxs("span",{className:"relative block h-2.5 overflow-hidden rounded-full border border-white/10 bg-black/25 transition-colors group-hover:border-cyan-200/35",role:"meter","aria-label":i,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(r),children:[t.jsx("span",{className:O("block h-full rounded-full transition-[width]",vT(s)),style:{width:`${r}%`}}),a!==null&&t.jsx("span",{className:"absolute top-0 h-full w-0.5 rounded-full bg-amber-100/75 shadow-[0_0_0_1px_rgba(0,0,0,0.25)]",style:{left:`calc(${a}% - 0.5px)`},"aria-hidden":"true"})]})})}function UT({summary:e}){const n=e.trendPercent,s=n===null||Math.abs(n)<.1?null:n>0?Kx:Ux,o=e.latest.diagnostics[0]??null,r=Ps(e.latest.usagePercent),a=Ps(e.peak.usagePercent),i=()=>{lh(e.latest.logId)};return t.jsxs("div",{className:"grid gap-x-4 gap-y-2 border-t border-white/10 py-2 first:border-t-0 lg:grid-cols-[minmax(180px,1fr)_minmax(260px,1fr)_minmax(260px,1.4fr)]",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("button",{type:"button",onClick:i,className:"min-w-0 truncate rounded-sm text-left font-mono font-semibold text-foreground transition-colors hover:text-text-link focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1",title:`Open latest Context for ${e.model}`,children:e.model}),t.jsx("span",{className:O("inline-flex h-5 shrink-0 items-center rounded border px-1.5 font-mono text-[10px]",CT(e.latest.health.level)),children:kT(e.latest.health.level)})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-muted-foreground",children:[t.jsx("span",{children:NT(e.requestCount)}),t.jsx("span",{children:yT(e)})]})]}),t.jsxs("div",{className:"min-w-0 space-y-2 text-xs",children:[t.jsx(FT,{latestPercent:e.latest.usagePercent,peakPercent:e.peak.usagePercent,risk:e.latest.riskLevel,onOpenContext:i}),t.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Latest"}),t.jsx("div",{className:O("mt-0.5 font-mono",Od(e.latest.riskLevel)),children:r}),t.jsx(Dd,{label:"Log",logId:e.latest.logId})]}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Peak"}),t.jsx("div",{className:O("mt-0.5 font-mono",Od(e.peak.riskLevel)),children:a}),t.jsx(Dd,{label:"Log",logId:e.peak.logId})]}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Trend"}),t.jsxs("div",{className:"mt-0.5 flex items-center gap-1 font-mono text-foreground",children:[s!==null&&t.jsx(s,{className:O("size-3",n!==null&&n>0?"text-amber-300":"text-cyan-300")}),gT(n)]}),t.jsx("div",{className:"h-5","aria-hidden":"true"})]})]})]}),t.jsxs("div",{className:"min-w-0 space-y-1.5",children:[t.jsx(h_,{segments:e.latest.roleSegments,totalTokens:e.latest.roleTotalTokens,showLabels:!1}),t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-muted-foreground",children:[t.jsxs("span",{className:"font-mono",children:["~",Re(e.latest.estimatedInputTokens)," input"]}),e.latest.windowUsedTokens!==null&&t.jsxs("span",{className:"font-mono",children:["~",Re(e.latest.windowUsedTokens)," used"]}),o!==null&&t.jsx("span",{className:"truncate",children:o})]})]})]})}function BT({summary:e}){return e.models.length===0?null:t.jsxs("div",{className:"mt-3 border-t border-white/10 pt-2",children:[t.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2",children:[t.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-normal text-muted-foreground",children:"Session Context"}),t.jsxs("div",{className:"font-mono text-[10px] text-muted-foreground",children:[e.models.length," model",e.models.length===1?"":"s"]})]}),t.jsx("div",{className:"max-h-52 overflow-y-auto pr-1",children:e.models.map(n=>t.jsx(UT,{summary:n},n.model))})]})}function qT(e){const n=e.models.filter(o=>o.latest.health.level==="risk").length;if(n>0)return`${n} risk`;const s=e.models.filter(o=>o.latest.health.level==="optimizable").length;return s>0?`${s} optimizable`:`${e.models.length} model${e.models.length===1?"":"s"}`}function HT({label:e,logs:n,totalIn:s,totalOut:o,timeDisplayFormat:r,contextSummary:a,showBackLink:i}){const[c,d]=l.useState(!1),[m,u]=l.useState(!1),f=l.useMemo(()=>uT(n,r),[n,r]),p=l.useMemo(()=>dT(n),[n]),h=l.useMemo(()=>qT(a),[a]),g=l.useCallback(()=>{vt(window.location.href).then(v=>{v&&(d(!0),setTimeout(()=>d(!1),2e3))})},[]);return t.jsxs("div",{className:"border border-border bg-card shadow-sm mb-3 rounded-[8px] px-3 py-2 text-xs",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[i&&t.jsx("a",{href:_i("/"),className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex size-8 shrink-0 items-center justify-center rounded-md text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground","aria-label":"Back to all sessions",title:"Back to all sessions",children:t.jsx(Wx,{className:"size-3.5"})}),t.jsxs("div",{className:"min-w-[180px] flex-1",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"font-mono font-semibold text-purple-400/90 truncate",title:e,children:kn(e)}),p!==null&&t.jsx("span",{className:"font-mono text-muted-foreground truncate max-w-[220px]",title:p,children:p})]}),t.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-muted-foreground",children:[t.jsxs("span",{children:[n.length," request",n.length!==1?"s":""]}),f!==null&&t.jsx("span",{children:f}),(s>0||o>0)&&t.jsxs("span",{className:"font-mono",children:[Re(s)," in / ",Re(o)," out"]})]})]}),a.models.length>0&&t.jsxs("button",{type:"button",onClick:()=>u(v=>!v),className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md px-2.5 font-mono text-[11px] text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground","aria-expanded":m,title:m?"Hide context details":"Show context details",children:[t.jsx("span",{children:h}),m?t.jsx(Ui,{className:"size-3.5"}):t.jsx(We,{className:"size-3.5"})]}),t.jsx("button",{type:"button",onClick:g,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex size-8 shrink-0 items-center justify-center rounded-md text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground","aria-label":c?"Copied session link":"Copy session link",title:c?"Copied session link":"Copy session link",children:c?t.jsx(Pe,{className:"size-3.5"}):t.jsx(St,{className:"size-3.5"})})]}),m&&t.jsx(BT,{summary:a})]})}function WT({logs:e,sessions:n,selectedSession:s,selectedModel:o,onSessionChange:r,onClearAll:a,onDeleteCurrentView:i,onReloadSession:c,onClearGroup:d,onNotify:m,onImportLogs:u,viewMode:f,captureMode:p,strip:h,slowResponseThresholdSeconds:g,timeDisplayFormat:v,isLoading:y=!1,liveConnection:w,onRetryLiveConnection:b,onStopLiveConnection:j,pagination:S,sessionLoadProgress:N,sessionLoadError:C,sessionMemberships:R=[],hideSessionFilter:I=!1,pinnedSessionId:P}){const{totalIn:M,totalOut:k}=l.useMemo(()=>Ad(e),[e]),{providers:A}=Yi(),{uiScalePreference:D,resolvedUiScale:$,setUiScalePreference:Y}=lb(),[Q,U]=l.useState(null),[H,X]=l.useState(null),[B,W]=l.useState(!1),[pe,ve]=l.useState(!1),[ye,re]=l.useState(null),[z,Z]=l.useState(null),[we,Ne]=l.useState(!1),[le,ce]=l.useState(!1),[ae,je]=l.useState(!0),[_e,Ie]=l.useState(es),[Ue,Me]=l.useState(!1),[Be,ut]=l.useState(!1),[Ge,Je]=l.useState(!0),[ht,De]=l.useState(!1),[F,ee]=l.useState(null),[ge,fe]=l.useState(null),Se=l.useRef(null),$e=l.useRef(null),G=l.useRef(null),_=l.useRef(null),L=l.useRef(0),K=l.useRef(null);c_(Se,$e,{pageWide:!0});const[se,de]=l.useState(null);l.useEffect(()=>Hi(de),[]);const J=l.useCallback(()=>{L.current+=1,_.current?.abort(),_.current=null,U(null),X(null)},[]);l.useEffect(()=>()=>{L.current+=1,_.current?.abort(),_.current=null},[]),l.useEffect(()=>{je(DT()),Ie(zT()),ut(!0)},[]),l.useEffect(()=>{Be&&window.localStorage.setItem(ch,ae?"1":"0")},[ae,Be]),l.useEffect(()=>{if(Be)try{window.localStorage.setItem(dh,String(_e))}catch{}},[Be,_e]),l.useEffect(()=>{Je($T()),De(!0)},[]),l.useEffect(()=>{if(ht)try{window.localStorage.setItem(uh,Ge?"1":"0")}catch{}},[ht,Ge]),l.useEffect(()=>{if(P===void 0){document.title="Agent Inspector";return}const be=e.length===1?"1 req":`${e.length} req`;document.title=`${kn(P)} - ${be} - Agent Inspector`},[e.length,P]);const he=l.useCallback(async be=>{_.current?.abort();const Fe=new AbortController;_.current=Fe;const xt=L.current+1;L.current=xt,U(be),X(null);try{const Ht=await K1(e,be,{signal:Fe.signal});if(L.current!==xt)return;if(!Ht.ok){if(Ht.canceled===!0)return;m!==void 0?m({message:Ht.message,tone:"error"}):X(Ht.message)}}finally{L.current===xt&&(_.current=null,U(null))}},[e,m]),ue=l.useCallback(be=>{if(oC(be)){W(!0);return}he(be)},[he]),Xt=l.useCallback(()=>{W(!1),he("redacted")},[he]),bn=l.useCallback(()=>{W(!1),he("raw")},[he]),Ct=l.useCallback(()=>{G.current?.click()},[]),zn=l.useCallback(be=>{const Fe=be.currentTarget.files?.[0];be.currentTarget.value="",!(Fe===void 0||u===void 0)&&(ve(!0),Z(null),re(null),u(Fe).then(xt=>{const Ht=xt.skipped>0?`, skipped ${String(xt.skipped)}`:"",Ul=`Imported ${String(xt.imported)} logs as ${xt.sessionId}${Ht}.`;m!==void 0?m({message:Ul,tone:"success"}):re(Ul)}).catch(xt=>{const Ht=xt instanceof Error?xt.message:"Failed to import logs";m!==void 0?m({message:Ht,tone:"error"}):Z(Ht)}).finally(()=>{ve(!1)}))},[u,m]);l.useEffect(()=>{J(),fe(null),ee(null)},[J,s,o]);const Hr=l.useCallback(()=>{J(),re(null),Z(null),fe(null),a()},[J,a]),vs=l.useCallback(()=>{Ne(!0)},[]),Wr=l.useCallback(()=>{J(),re(null),Z(null),fe(null),i!==void 0&&(ce(!0),i().then(()=>{Ne(!1)}).catch(be=>{const Fe=be instanceof Error?be.message:"Failed to delete stored logs";m!==void 0?m({message:Fe,tone:"error"}):Z(Fe)}).finally(()=>{ce(!1)}))},[J,i,m]),Te=l.useCallback(()=>{c!==void 0&&(J(),re(null),Z(null),fe(null),c())},[J,c]),qt=l.useCallback(()=>{fe(null)},[]),Qe=l.useCallback(()=>{je(be=>!be)},[]),ys=l.useCallback(be=>{K.current={startX:be.clientX,startWidth:_e,pointerId:be.pointerId},be.currentTarget.setPointerCapture(be.pointerId),Me(!0)},[_e]),et=l.useCallback(be=>{const Fe=K.current;Fe===null||Fe.pointerId!==be.pointerId||Ie(mh(Fe.startWidth+Fe.startX-be.clientX))},[]),$n=l.useCallback(be=>{const Fe=K.current;Fe===null||Fe.pointerId!==be.pointerId||(be.currentTarget.hasPointerCapture(be.pointerId)&&be.currentTarget.releasePointerCapture(be.pointerId),K.current=null,Me(!1))},[]),ph=l.useCallback(()=>{Ie(es)},[]),hh=l.useCallback(()=>{Je(be=>!be)},[]),Vr=l.useMemo(()=>F===null?null:new Set(F.logIds),[F]),vn=l.useMemo(()=>Vr===null?e:e.filter(be=>Vr.has(be.id)),[Vr,e]),kt=l.useMemo(()=>s5(vn),[vn]),Ll=l.useMemo(()=>cT(kt),[kt]),yn=l.useMemo(()=>gC({pinnedSessionId:P,selectedSession:s,sessions:n,logs:e}),[e,P,s,n]),Fn=yn?.logs??[],ws=yn!==null&&Fn.length>0,{totalIn:Ol,totalOut:Dl}=l.useMemo(()=>Ad(Fn),[Fn]),xh=l.useMemo(()=>lT(Fn,A),[Fn,A]),gh=l.useMemo(()=>P4(kt),[kt]),Kr=l.useMemo(()=>lN(kt),[kt]),zl=rC(p,e.length),bh=P!==void 0,vh=e.length>0,yh=i!==void 0&&(e.length>0||s!=="__all__"),wh=s==="__all__"?"all sessions":"this session",jh=s==="__all__"?"Deletes every stored log, streaming chunk, and session archive entry across all sessions.":"Deletes every stored log, streaming chunk, and session archive entry for this session, including history that is not currently loaded.",Sh=e.length===0?"Load":"Reload",Gr=ws&&yn!==null?kn(yn.label):s==="__all__"?"All sessions":kn(s),$l=U4(w),Yr=B4($l),Nh=l.useMemo(()=>xC({logs:vn,conversationGroups:kt,isLoading:y,timeDisplayFormat:v,slowResponseThresholdSeconds:g}),[vn,kt,y,g,v]),Ch=l.useCallback(be=>{const Fe=Kr.get(be.id);Fe!==void 0&&fe([Fe,be])},[Kr]),Fl=P!==void 0?P:s==="__all__"?null:s;return t.jsxs("div",{className:"bg-background min-h-screen w-full overflow-x-clip text-foreground lg:h-screen lg:flex lg:flex-col lg:overflow-hidden",children:[t.jsx(z4,{liveConnection:w,alertsAction:t.jsx(KC,{}),settingsAction:t.jsx(I3,{})}),t.jsxs("button",{type:"button",onClick:Qe,className:O("group fixed top-1/2 right-3 z-50 inline-flex h-14 w-8 -translate-y-1/2 items-center justify-center rounded-l-md border border-border/70 bg-background/90 text-muted-foreground shadow-lg backdrop-blur transition-colors motion-reduce:transition-none hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none"),"aria-label":ae?"Show details panel":"Hide details panel",title:ae?"Show details panel":"Hide details panel",children:[t.jsx("span",{className:"absolute bottom-2 left-1 top-2 w-px rounded-full bg-border transition-colors group-hover:bg-foreground/35"}),ae?t.jsx($g,{className:"size-3.5"}):t.jsx(Dg,{className:"size-3.5"})]}),ht&&Ge&&t.jsx(Uo,{feature:"Inspector Pet",children:t.jsx(l.Suspense,{fallback:null,children:t.jsx(J5,{logs:e})})}),t.jsxs("div",{className:O("flex w-full min-w-0 flex-col lg:min-h-0 lg:flex-1 lg:flex-row lg:overflow-hidden",Ue&&"cursor-col-resize select-none"),children:[!ae&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"fixed inset-0 z-30 bg-background/70 backdrop-blur-sm lg:hidden",onClick:Qe,"aria-label":"Close details panel"}),t.jsxs("aside",{className:"inspector-scrollbar fixed inset-x-3 bottom-3 top-24 z-40 order-1 overflow-y-auto rounded-lg border border-border bg-background/98 shadow-2xl max-lg:!w-auto lg:relative lg:inset-auto lg:order-2 lg:h-full lg:shrink-0 lg:rounded-none lg:border-y-0 lg:border-r-0 lg:shadow-none",style:{width:_e},children:[t.jsx("button",{type:"button",className:"absolute bottom-0 left-0 top-0 z-30 hidden w-2 -translate-x-1/2 cursor-col-resize touch-none items-center justify-center lg:flex",onPointerDown:ys,onPointerMove:et,onPointerUp:$n,onPointerCancel:$n,onDoubleClick:ph,"aria-label":"Resize details panel",title:"Drag to resize; double-click to reset",children:t.jsx("span",{className:"h-12 w-1 rounded-full bg-border transition-colors hover:bg-primary"})}),t.jsxs("div",{className:"flex min-h-full flex-col gap-4 p-4",children:[t.jsxs("div",{className:"sticky top-0 z-20 -mx-4 -mt-4 grid gap-2 border-b border-border/60 bg-background/95 px-4 pb-3 pt-4 backdrop-blur",children:[t.jsx(Ua,{label:"View",children:t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsx(AT,{}),t.jsx(PT,{preference:D,resolvedScale:$,onChange:Y})]})}),t.jsx(Ua,{label:"Workspace",children:t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(pk,{labelledTrigger:!0}),t.jsx(h4,{currentSessionId:Fl,logCount:e.length,labelledTrigger:!0})]})})]}),t.jsxs(Ua,{label:"Current scope",children:[t.jsxs("div",{className:"mb-2 rounded-md border border-border/50 bg-muted/25 px-3 py-2",children:[t.jsx("div",{className:"truncate font-mono text-xs font-semibold text-text-link",title:Gr,children:Gr}),t.jsx("div",{className:"mt-1 text-[11px] text-muted-foreground",children:bh?"Pinned session":"Live Inspector data"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsx(Ro,{label:F===null?"Requests":"Results",value:vn.length}),t.jsx(Ro,{label:"Sessions",value:n.length}),t.jsx(Ro,{label:"Input",value:Re(ws?Ol:M)}),t.jsx(Ro,{label:"Output",value:Re(ws?Dl:k)})]}),N!==void 0&&t.jsx("div",{className:"mt-2 rounded-md border border-border/50 bg-muted/25 px-2 py-2",children:t.jsx($o,{progress:N})})]}),ws&&yn!==null&&t.jsx(HT,{label:yn.label,logs:Fn,totalIn:Ol,totalOut:Dl,timeDisplayFormat:v,contextSummary:xh,showBackLink:yn.showBackLink}),ws&&P!==void 0&&R.length>0&&t.jsx(Id,{memberships:R}),t.jsx("div",{className:"flex-1"}),t.jsx(I4,{currentSessionId:Fl,logCount:e.length,onResultChange:ee})]})]})]}),t.jsxs("main",{className:"inspector-scrollbar order-2 min-w-0 lg:order-1 lg:h-full lg:flex-1 lg:overflow-y-auto",children:[t.jsxs("div",{className:"bg-background/95 shadow-[0_12px_36px_rgba(0,0,0,0.18),inset_0_-1px_0_rgba(255,255,255,0.045)] sticky top-0 z-30 px-4 py-3 lg:px-5",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("div",{className:"min-w-[180px] flex-1",children:[t.jsx("div",{className:"text-sm font-semibold text-foreground",children:"Logs"}),t.jsx("div",{className:"mt-0.5 font-mono text-[11px] text-muted-foreground",children:Gr})]}),t.jsx(IT,{visible:Ge,onToggle:hh}),u!==void 0&&t.jsxs(t.Fragment,{children:[t.jsx("input",{ref:G,type:"file",accept:".zip,.json,.jsonl,application/zip,application/json",className:"hidden",onChange:zn}),t.jsx("button",{type:"button",onClick:Ct,disabled:pe,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Import Agent Inspector export",children:pe?t.jsx("span",{children:"Importing..."}):t.jsxs(t.Fragment,{children:[t.jsx(ju,{className:"size-3.5"}),t.jsx("span",{children:"Import"})]})})]}),zl.redacted&&t.jsx("button",{type:"button",onClick:()=>{ue("redacted")},disabled:Q!==null,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Export redacted logs as JSON ZIP",children:Q==="redacted"?t.jsx("span",{children:"Exporting..."}):t.jsxs(t.Fragment,{children:[t.jsx(Gs,{className:"size-3.5"}),t.jsx("span",{children:"Export"})]})}),zl.raw&&t.jsx("button",{type:"button",onClick:()=>{ue("raw")},disabled:Q!==null,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Export raw logs without redaction",children:Q==="raw"?t.jsx("span",{children:"Exporting..."}):t.jsxs(t.Fragment,{children:[t.jsx(K0,{className:"size-3.5"}),t.jsx("span",{children:"Raw"})]})}),c!==void 0&&t.jsxs("button",{type:"button",onClick:Te,disabled:y,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Reload this session from stored logs",children:[t.jsx(yt,{className:O("size-3.5",y&&"animate-spin motion-reduce:animate-none")}),t.jsx("span",{children:Sh})]}),t.jsxs("button",{type:"button",onClick:Hr,disabled:!vh,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Clear the current view. Stored logs remain reloadable.",children:[t.jsx(dn,{className:"size-3.5"}),t.jsx("span",{children:"Clear"})]}),i!==void 0&&t.jsxs("button",{type:"button",onClick:vs,disabled:!yh||le,className:"bg-red-500/[0.07] hover:bg-red-500/[0.12] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-red-200 shadow-[inset_0_0_0_1px_rgba(248,113,113,0.14)] transition-colors hover:text-red-100 focus-visible:ring-1 focus-visible:ring-red-300 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Delete persisted history for the selected session.",children:[t.jsx(dn,{className:"size-3.5"}),t.jsx("span",{children:"Delete"})]})]}),S===void 0&&N!==void 0&&t.jsx("div",{className:"mt-2 rounded-md bg-black/20 px-2 py-2 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:t.jsx($o,{progress:N})}),C!==void 0&&t.jsxs("div",{role:"alert",className:"mt-2 flex flex-wrap items-center gap-2 rounded-md border border-red-400/25 bg-red-500/10 px-3 py-2 text-xs text-red-100",children:[t.jsxs("span",{className:"min-w-0 flex-1",children:["Session logs could not be loaded. ",C," Existing logs remain visible."]}),c!==void 0&&t.jsxs("button",{type:"button",onClick:Te,className:"inline-flex h-7 items-center gap-1 rounded-md bg-black/15 px-2 font-medium transition-colors hover:bg-black/25 focus-visible:ring-1 focus-visible:ring-current focus-visible:outline-none",children:[t.jsx(yt,{className:"size-3"}),"Retry"]})]}),F!==null&&t.jsxs("div",{className:"mt-2 flex items-center gap-3 rounded-md bg-cyan-400/[0.07] px-3 py-2 shadow-[inset_2px_0_0_rgba(103,232,249,0.35),inset_0_0_0_1px_rgba(103,232,249,0.08)]",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"truncate text-xs font-medium text-cyan-50",children:F.question}),t.jsxs("div",{className:"mt-0.5 text-[10px] text-muted-foreground",children:["Showing ",String(vn.length)," loaded logs from"," ",String(F.logIds.length)," linked results"]})]}),t.jsxs("button",{type:"button",onClick:()=>ee(null),className:"inline-flex h-7 shrink-0 items-center gap-1 rounded-md bg-black/20 px-2 text-[11px] text-muted-foreground transition-colors hover:bg-black/30 hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",children:[t.jsx(Js,{className:"size-3"}),"All logs"]})]}),F===null&&t.jsx(Pd,{logs:e,pagination:S,embedded:!0}),m===void 0&&H!==null&&t.jsx("div",{className:"mt-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:H}),m===void 0&&z!==null&&t.jsx("div",{className:"mt-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:z}),m===void 0&&ye!==null&&z===null&&t.jsx("div",{className:"mt-2 rounded-md border border-cyan-400/25 bg-cyan-500/10 px-3 py-2 text-xs text-cyan-100",children:ye}),w!==void 0&&w.status!=="live"&&b!==void 0&&j!==void 0&&t.jsx(O4,{state:w,hasLogs:e.length>0,onRetry:b,onStop:j})]}),t.jsxs("div",{className:"px-4 py-4 lg:px-5",children:[t.jsx(xT,{stats:Nh}),F!==null&&vn.length===0?t.jsx("div",{className:"py-16 text-center text-muted-foreground",children:t.jsxs("div",{className:"mx-auto max-w-xl rounded-[8px] bg-white/[0.035] px-5 py-8 shadow-[inset_0_1px_0_rgba(255,255,255,0.045),0_18px_52px_rgba(0,0,0,0.18)]",children:[t.jsx("p",{className:"text-sm font-medium text-foreground",children:"No linked logs are loaded"}),t.jsx("p",{className:"mt-2 text-xs leading-5 text-muted-foreground",children:"Assistant found evidence, but none of its linked log IDs are in the current loaded window. Open an evidence card in Assistant or restore the full log view."}),t.jsx("button",{type:"button",onClick:()=>ee(null),className:"mt-4 inline-flex h-8 items-center rounded-md bg-cyan-400/10 px-3 text-xs text-cyan-100 transition-colors hover:bg-cyan-400/16",children:"Show all logs"})]})}):e.length===0?s!=="__all__"?t.jsx("div",{className:"py-16 text-center text-muted-foreground",children:t.jsxs("div",{className:"bg-white/[0.035] shadow-[inset_0_1px_0_rgba(255,255,255,0.045),0_18px_52px_rgba(0,0,0,0.18)] mx-auto max-w-xl space-y-4 rounded-[8px] px-4 py-8",children:[t.jsx("p",{className:"text-sm font-medium",children:y?"Loading session data...":C===void 0?"No logs loaded for this session":"Session logs could not be loaded"}),t.jsx("p",{className:"inline-block max-w-full rounded bg-muted px-3 py-1 font-mono text-xs break-all",children:kn(s)}),N!==void 0&&t.jsx("div",{className:"mx-auto max-w-md rounded-md bg-black/20 px-2 py-2 text-left shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:t.jsx($o,{progress:N})}),R.length>0&&t.jsx("div",{className:"text-left",children:t.jsx(Id,{memberships:R})}),!y&&t.jsxs("div",{className:"flex flex-col items-center gap-3 text-xs",children:[t.jsx("p",{children:"Stored logs may still be available."}),t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[c!==void 0&&t.jsxs("button",{type:"button",onClick:Te,className:"bg-white/[0.045] hover:bg-white/[0.075] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",children:[t.jsx(yt,{className:"size-3.5"}),t.jsx("span",{children:"Load session"})]}),I?t.jsx("a",{href:_i("/"),className:"inline-flex h-8 items-center rounded-md px-3 text-xs text-muted-foreground underline transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",children:"Back to all sessions"}):t.jsx("button",{type:"button",onClick:()=>r("__all__"),className:"inline-flex h-8 items-center rounded-md px-3 text-xs text-muted-foreground underline transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",children:"Show all sessions"})]})]})]})}):t.jsx("div",{className:"py-16 text-center text-muted-foreground",children:t.jsxs("div",{className:"bg-white/[0.035] shadow-[inset_0_1px_0_rgba(255,255,255,0.045),0_18px_52px_rgba(0,0,0,0.18)] mx-auto max-w-2xl space-y-4 rounded-[8px] px-4 py-8",children:[t.jsx("p",{className:"text-sm font-medium",children:Yr.title}),t.jsx("p",{className:"mx-auto max-w-xl text-xs leading-relaxed text-muted-foreground",children:Yr.description}),$l==="empty"&&n.length>0&&t.jsx("p",{className:"mx-auto max-w-xl text-xs leading-relaxed text-muted-foreground",children:"Pick a session from the filter panel to load stored logs on demand."}),Yr.showConnectionCommands&&se!==null&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex flex-col items-center gap-2",children:nC(se).map(be=>t.jsx(MT,{command:be},be))}),t.jsx("p",{className:"mx-auto max-w-xl text-xs leading-relaxed text-muted-foreground",children:"Container note: if your AI tool runs in a different container or host than Agent Inspector, replace localhost with an address reachable from that tool and verify the network/firewall path."})]})]})}):t.jsxs("div",{ref:$e,tabIndex:0,"aria-label":"Captured logs",className:"flex flex-col gap-2 rounded-md focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-none",children:[t.jsx("div",{ref:Se,children:t.jsx(Q4,{groups:kt,viewMode:f,strip:h,slowResponseThresholdSeconds:g,cacheTrends:gh,onCompareWithPrevious:Ch,comparisonPredecessors:Kr,onClearGroup:d,defaultExpanded:kt.length===1,timeDisplayFormat:v})}),F===null&&t.jsx("div",{className:"mt-3",children:t.jsx(Pd,{logs:e,pagination:S})})]})]})]})]}),t.jsx(Lt,{open:B,onOpenChange:W,children:t.jsx(Ot,{className:n_,children:t.jsx(o_,{onCancel:()=>W(!1),onExportRedacted:Xt,onConfirmRaw:bn})})}),t.jsx(Lt,{open:we,onOpenChange:Ne,children:t.jsxs(Ot,{className:"border-red-500/20 bg-zinc-950 text-zinc-100 sm:max-w-md",children:[t.jsxs(Ut,{children:[t.jsxs(Bt,{children:["Delete ",wh," history?"]}),t.jsx(to,{children:"Clear only hides logs from the UI. Delete removes stored history from disk."})]}),t.jsxs("div",{className:"rounded-md bg-red-500/[0.08] px-3 py-3 text-sm text-red-100 shadow-[inset_0_0_0_1px_rgba(248,113,113,0.16)]",children:[t.jsx("span",{className:"block font-medium",children:"This is a full history delete."}),t.jsx("span",{className:"mt-1 block text-xs text-red-200/80",children:jh})]}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx(te,{type:"button",variant:"outline",size:"sm",disabled:le,onClick:()=>Ne(!1),children:"Cancel"}),t.jsx(te,{type:"button",variant:"destructive",size:"sm",disabled:le,onClick:Wr,children:le?"Deleting...":"Delete history"})]})]})}),ge!==null&&t.jsx(Uo,{feature:"Compare",children:t.jsx(l.Suspense,{fallback:null,children:t.jsx(Y5,{left:ge[0],right:ge[1],leftDisplayNumber:Md(ge[0],Ll),rightDisplayNumber:Md(ge[1],Ll),onClose:qt})})})]})}function VT(e,n,s){return n==="__all__"&&s==="__all__"?e:e.filter(o=>!(n!=="__all__"&&o.sessionId!==n||s!=="__all__"&&o.model!==s))}function Mo(e,n){if(e.length===0)return[...n];if(n.length===0)return[...e];const s=new Map;for(const o of e)s.set(o.id,o);for(const o of n)s.set(o.id,o);return[...s.values()].toSorted((o,r)=>o.id-r.id)}function Nn(e,n){const s=new Set;for(const o of e)o!==""&&s.add(o);for(const o of n)o!==""&&s.add(o);return[...s].sort()}function KT(e){const n=new URLSearchParams({compact:"1"});e!==void 0&&n.set("sessionId",e);const s=Ih();return s.ok?Ph(s.runtime,`/api/logs/stream?${n.toString()}`):null}function GT(e){const n=KT(e);return n===null?null:new EventSource(n)}const YT=Dt([T({type:oe("init"),logs:V(Os)}),T({type:oe("update"),log:Os})]),JT=T({logs:V(Os),total:E().int().nonnegative(),limit:E().int().positive(),hasOlder:ke(),hasNewer:ke(),oldestLogId:E().int().positive().nullable(),newestLogId:E().int().positive().nullable()}),XT=V(x()),zd=T({success:ke(),cleared:E().int().nonnegative(),logFilesRewritten:E().int().nonnegative().optional(),chunkFilesDeleted:E().int().nonnegative(),sessionArchiveLogsDeleted:E().int().nonnegative().optional()});function ZT(e,n){const s=[];for(const o of e)for(const r of o.members)r.sessionId===n&&s.push({groupId:o.id,groupTitle:o.title,groupKind:o.kind,groupStatus:o.status,groupTask:o.task,groupProject:o.project,groupEvidence:o.evidence,member:r});return s}function Ao(e){const n=new Set;for(const s of e)s.sessionId!==null&&s.sessionId!==""&&n.add(s.sessionId);return[...n]}function QT(e){const n=new Set;for(const s of e)s.model!==null&&s.model!==""&&n.add(s.model);return[...n]}const eE=100,tE=12,nE=1800,Pl=100,pr=500,fh=200,Ci=2e4,sE=1e4,oE=3e3,rE=1e4;function aE(e,n,s=Pl){const o=new URLSearchParams({cursor:"1",compact:"1",limit:String(s),sessionId:e});switch(n.kind){case"oldest":o.set("anchor","oldest");break;case"older":o.set("beforeLogId",String(n.beforeLogId));break;case"newer":o.set("afterLogId",String(n.afterLogId));break}return`/api/logs?${o.toString()}`}function sn(e){const n=new Map;for(let s=0;s<e.length;s++){const o=e[s];o!==void 0&&n.set(o.id,s)}return n}function Ls(e,n,s=Pl){return Le(aE(e,n,s),JT,Ci)}async function iE(e,n){const s=new Set;let o=await Ls(e,{kind:"oldest"},pr);for(const a of o.logs)s.add(a.id);n(s.size,1);let r=1;for(;o.hasNewer&&o.newestLogId!==null&&r<fh;){o=await Ls(e,{kind:"newer",afterLogId:o.newestLogId},pr);for(const a of o.logs)s.add(a.id);r+=1,n(s.size,r)}return{ids:[...s],truncated:o.hasNewer}}async function lE(){try{return{deleted:(await Ke("/api/groups",ou,{method:"DELETE"})).deleted,ok:!0}}catch{return{deleted:0,ok:!1}}}function mE({initialSessionId:e}={}){const[n,s]=l.useState([]),[o,r]=l.useState(e??"__all__"),[a,i]=l.useState("__all__"),[c,d]=l.useState([]),{notice:m,showToast:u,dismissToast:f}=kp(),[p,h]=l.useState(F4),[g,v]=l.useState(null),[y,w]=l.useState(e!==void 0),[b,j]=l.useState(null),[S,N]=l.useState(void 0),[C,R]=l.useState([]),[,I]=l.useTransition(),P=l.useRef(null),M=l.useRef(null),k=l.useRef(null),A=l.useRef(!0),D=l.useRef(null),$=l.useRef(0),Y=l.useRef(null),Q=l.useRef(null),U=l.useRef(new Map),H=l.useRef([]),X=l.useRef(null),B=l.useCallback(G=>{u({message:G,tone:"error"})},[u]),W=l.useCallback(()=>{Q.current!==null&&(clearInterval(Q.current),Q.current=null),Y.current=null,N(void 0)},[]),pe=l.useCallback((G,_,L=0,K=0)=>{Q.current!==null&&clearInterval(Q.current);const se=Date.now();Y.current=se;const de=()=>{$.current===_&&N({label:G,elapsedMs:Date.now()-se,timeoutMs:Ci,loadedLogs:L,loadedPages:K})};de(),Q.current=setInterval(de,250)},[]),ve=l.useCallback((G,_,L,K)=>{const se=Y.current;se===null||$.current!==_||N({label:G,elapsedMs:Date.now()-se,timeoutMs:Ci,loadedLogs:L,loadedPages:K})},[]),ye=l.useMemo(()=>VT(n,o,a),[n,o,a]),re=l.useMemo(()=>Nn(c,Ao(n)),[n,c]),z=l.useMemo(()=>QT(n),[n]),Z=l.useCallback(()=>{Ke("/api/sessions",XT).then(G=>{d(_=>Nn(_,G))}).catch(()=>{})},[]),we=l.useCallback(()=>{X.current=null;const G=H.current;H.current=[],G.length!==0&&I(()=>{s(_=>{const L=Mo(_,G);return U.current=sn(L),L})})},[I]),Ne=l.useCallback(G=>{H.current.push(G),X.current===null&&(X.current=setTimeout(we,eE))},[we]),le=l.useCallback(()=>{P.current&&P.current.close(),M.current!==null&&(clearTimeout(M.current),M.current=null),h(_=>_t(_,{type:"connect-requested"}));const G=GT(e);if(G===null){h(_=>_t(_,{type:"recoverable-error",message:"The browser runtime does not provide a valid log stream endpoint."})),B("Failed to resolve the live stream endpoint");return}P.current=G,G.onmessage=_=>{try{const L=String(_.data),K=JSON.parse(L),se=YT.safeParse(K);if(!se.success){h(J=>_t(J,{type:"recoverable-error",message:"The live stream returned invalid data."})),B("Failed to parse SSE data");return}const de=se.data;de.type==="init"?(X.current!==null&&(clearTimeout(X.current),X.current=null),H.current=[],s(J=>{const he=Mo(J,de.logs);return U.current=sn(he),he}),d(J=>Nn(J,Ao(de.logs))),k.current!==null&&(clearTimeout(k.current),k.current=null),h(J=>_t(J,{type:"message-received",at:Date.now()})),f()):de.type==="update"&&(d(J=>de.log.sessionId===null||de.log.sessionId===""?J:Nn(J,[de.log.sessionId])),Ne(de.log),k.current!==null&&(clearTimeout(k.current),k.current=null),h(J=>_t(J,{type:"message-received",at:Date.now()})))}catch{h(L=>_t(L,{type:"recoverable-error",message:"The live stream returned malformed JSON."})),B("Failed to parse SSE data")}},G.onerror=()=>{const _=navigator.onLine;h(L=>_t(L,{type:"connection-lost",online:_,message:"The live stream disconnected."})),G.close(),!(!_||!A.current)&&(k.current===null&&(k.current=setTimeout(()=>{k.current=null,h(L=>_t(L,{type:"stale-timeout"}))},rE)),M.current=setTimeout(le,oE))}},[f,e,Ne,B]),ce=l.useCallback(()=>{A.current=!0,M.current!==null&&(clearTimeout(M.current),M.current=null),le()},[le]),ae=l.useCallback(()=>{A.current=!1,P.current?.close(),P.current=null,M.current!==null&&(clearTimeout(M.current),M.current=null),k.current!==null&&(clearTimeout(k.current),k.current=null),h(G=>_t(G,{type:"stop-retrying"}))},[]),je=l.useCallback(G=>{if(e===void 0)return;const _=$.current+1;$.current=_,w(!0),j(null),pe("Loading session logs",_),f(),Ls(e,G).then(L=>{if($.current!==_)return;const K=L.logs;U.current=sn(K),s(K),v(L),r(e),w(!1),j(null),W(),f()}).catch(L=>{if($.current!==_)return;w(!1),W();const K=L instanceof Error?L.message:"Failed to load session logs";j(K),B(K)})},[f,e,B,pe,W]),_e=l.useCallback(G=>{const _=$.current+1;$.current=_,w(!0),j(null),pe("Reloading full session",_),f(),(async()=>{const L=[];let K=await Ls(G,{kind:"oldest"},pr);L.push(...K.logs),ve("Reloading full session",_,L.length,1);let se=1;for(;K.hasNewer&&K.newestLogId!==null&&se<fh;)K=await Ls(G,{kind:"newer",afterLogId:K.newestLogId},pr),L.push(...K.logs),se+=1,ve("Reloading full session",_,L.length,se);$.current===_&&(s(de=>{const J=Mo(de,L);return U.current=sn(J),J}),d(de=>Nn(de,[G])),w(!1),j(null),W(),K.hasNewer?u({message:`Loaded ${String(L.length)} logs for this session. More history is available.`,tone:"success"}):f())})().catch(L=>{if($.current!==_)return;w(!1),W();const K=L instanceof Error?L.message:"Failed to reload session logs";j(K),B(K)})},[f,B,u,pe,W,ve]);l.useEffect(()=>{if(e===void 0){R([]);return}let G=!1;return Le("/api/groups",iu,sE).then(_=>_.groups).then(_=>{G||_===null||R(ZT(_,e))}).catch(()=>{G||R([])}),()=>{G=!0}},[e]),l.useEffect(()=>{Z()},[Z]),l.useEffect(()=>()=>{W()},[W]),l.useEffect(()=>{e!==void 0&&je({kind:"newest"})},[e,je]),l.useEffect(()=>{e===void 0&&o!=="__all__"&&_e(o)},[e,_e,o]),l.useEffect(()=>{if(e!==void 0)return;le();const G=()=>{P.current?.close(),P.current=null,M.current!==null&&(clearTimeout(M.current),M.current=null),k.current!==null&&(clearTimeout(k.current),k.current=null),h(L=>_t(L,{type:"browser-offline"}))},_=()=>{A.current&&le()};return window.addEventListener("offline",G),window.addEventListener("online",_),()=>{window.removeEventListener("offline",G),window.removeEventListener("online",_),P.current&&(P.current.close(),P.current=null),M.current!==null&&(clearTimeout(M.current),M.current=null),k.current!==null&&(clearTimeout(k.current),k.current=null),X.current!==null&&(clearTimeout(X.current),X.current=null)}},[le,e]),l.useEffect(()=>{const G=window.location.hash;if(!G.startsWith("#log-")||D.current===G)return;const _=G.slice(1),L=Number(_.replace(/^log-/,""));Number.isInteger(L)&&L>0&&fs({logId:L,tab:"request"});let K=!1,se=0,de=null,J=null;const he=()=>{if(K)return;const ue=document.getElementById(_);if(ue!==null){D.current=G,ue.scrollIntoView({block:"center",behavior:Gp(Yp())}),ue instanceof HTMLElement&&(de=ue,ue.setAttribute("data-deep-link-highlight","true"),J=window.setTimeout(()=>{ue.removeAttribute("data-deep-link-highlight")},nE),ue.focus({preventScroll:!0}),ue.getAttribute("data-nav-action")==="expand"&&ue.click());return}se+=1,se<tE&&window.setTimeout(he,100)};return he(),()=>{K=!0,J!==null&&window.clearTimeout(J),de!==null&&de.removeAttribute("data-deep-link-highlight")}},[ye.length]);const Ie=l.useCallback(()=>{const G=Ao(n);W(),w(!1),U.current.clear(),s([]),v(null),d(_=>Nn(_,G)),u({message:"Cleared the current view. Stored logs are still reloadable.",tone:"success"})},[n,u,W]),Ue=l.useCallback(G=>{if(G.length===0)return;const _=new Set(G);s(L=>{const K=L.filter(de=>_.has(de.id)),se=L.filter(de=>!_.has(de.id));return d(de=>Nn(de,Ao(K))),U.current=sn(se),se}),u({message:"Cleared this group from the current view.",tone:"success"})},[u]),Me=l.useCallback(async()=>{const G=$.current+1;$.current=G,w(!0),W(),f();try{if(o==="__all__"){pe("Deleting stored history",G);const J=await Ke("/api/logs",zd,{method:"DELETE"}),he=await lE();if($.current!==G)return;s([]),U.current.clear(),v(null),d([]),R([]),w(!1),W();const ue=he.ok?` Cleared ${he.deleted.toString()} group${he.deleted===1?"":"s"}.`:" Group cleanup failed; open Groups to retry Clear.";u({message:`Deleted ${J.cleared.toString()} stored log${J.cleared===1?"":"s"} across all sessions.${ue}`,tone:he.ok?"success":"error"});return}const _=o;pe("Deleting session history",G);const L=await iE(_,(J,he)=>{ve("Deleting session history",G,J,he)}),K=new Set(L.ids);for(const J of n)J.sessionId===_&&K.add(J.id);const se=[...K].filter(J=>Number.isInteger(J)&&J>=0);if(se.length===0){if($.current!==G)return;s(J=>{const he=J.filter(ue=>ue.sessionId!==_);return U.current=sn(he),he}),v(J=>J===null?null:{...J,logs:J.logs.filter(he=>he.sessionId!==_)}),d(J=>J.filter(he=>he!==_)),w(!1),W(),u({message:"No stored log records were found for this session.",tone:"success"});return}const de=await Ke("/api/logs",zd,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({ids:se})});if($.current!==G)return;s(J=>{const he=J.filter(ue=>ue.sessionId!==_);return U.current=sn(he),he}),v(J=>J===null?null:{...J,logs:J.logs.filter(he=>he.sessionId!==_)}),d(J=>J.filter(he=>he!==_)),w(!1),W(),u({message:`Deleted ${de.cleared.toString()} stored log${de.cleared===1?"":"s"} for this session${L.truncated?". More history may remain.":"."}`,tone:L.truncated?"error":"success"})}finally{$.current===G&&(w(!1),W())}},[n,f,o,u,pe,W,ve]),Be=l.useCallback(()=>{if(e!==void 0){je({kind:"newest"});return}if(o==="__all__"){Z();return}_e(o)},[e,je,Z,_e,o]),ut=l.useCallback(async G=>{const _=new FormData;_.set("file",G);const L=await Ke("/api/logs/import",Tx,{method:"POST",body:_});return s(K=>{const se=new Set(L.logs.map(J=>J.id)),de=Mo(K.filter(J=>!se.has(J.id)),L.logs);return U.current=sn(de),de}),r(L.sessionId),i("__all__"),v(null),f(),L},[f]),{strip:Ge,captureMode:Je,slowResponseThresholdSeconds:ht,timeDisplayFormat:De}=$i(),F=Je,ee=l.useCallback(()=>{je({kind:"oldest"})},[je]),ge=l.useCallback(()=>{je({kind:"newest"})},[je]),fe=l.useCallback(()=>{const G=n[0],_=g?.oldestLogId??G?.id??null;_!==null&&je({kind:"older",beforeLogId:_})},[n,je,g]),Se=l.useCallback(()=>{const G=n[n.length-1],_=g?.newestLogId??G?.id??null;_!==null&&je({kind:"newer",afterLogId:_})},[n,je,g]),$e=l.useMemo(()=>{if(e!==void 0)return{isLoading:y,loadProgress:S,total:g?.total??null,pageSize:g?.limit??Pl,hasOlder:g?.hasOlder??!1,hasNewer:g?.hasNewer??!1,oldestLogId:g?.oldestLogId??null,newestLogId:g?.newestLogId??null,onOldest:ee,onOlder:fe,onNewer:Se,onNewest:ge}},[e,ge,Se,fe,ee,g,S,y]);return t.jsxs(t.Fragment,{children:[t.jsx(_p,{notice:m,onDismiss:f}),t.jsx(R1,{}),t.jsx(WT,{logs:ye,sessions:re,models:z,selectedSession:o,selectedModel:a,onSessionChange:r,onModelChange:i,onClearAll:Ie,onDeleteCurrentView:Me,onReloadSession:e!==void 0||o!=="__all__"?Be:void 0,onClearGroup:Ue,onNotify:u,onImportLogs:e===void 0?ut:void 0,isLoading:e===void 0&&p.status==="connecting"&&p.lastSuccessAt===null||y,liveConnection:e===void 0?p:void 0,onRetryLiveConnection:ce,onStopLiveConnection:ae,pagination:$e,sessionLoadProgress:S,sessionLoadError:b??void 0,sessionMemberships:C,viewMode:F,captureMode:Je,strip:Ge,slowResponseThresholdSeconds:ht,timeDisplayFormat:De,hideSessionFilter:e!==void 0,pinnedSessionId:e})]})}export{cn as $,d_ as A,Ce as B,L0 as C,Lt as D,uE as E,We as F,xe as G,MS as H,fg as I,dE as J,du as K,tS as L,gu as M,AS as N,IS as O,mE as P,Ln as Q,Gg as R,h_ as S,cp as T,mi as U,sr as V,C4 as W,Js as X,N0 as Y,Ds as Z,ne as _,n5 as a,Ae as a0,Hd as a1,K5 as a2,u0 as a3,Wl as b,q as c,bu as d,ct as e,Pe as f,ep as g,St as h,Ot as i,Ut as j,Bt as k,yu as l,dp as m,Wt as n,tt as o,jg as p,bs as q,Fs as r,nt as s,st as t,Yi as u,ot as v,fs as w,Os as x,Z_ as y,u_ as z};
|