@tonyclaw/agent-inspector 4.0.12 → 4.0.13
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 +1 -1
- package/.output/server/_ssr/index.mjs +1 -1
- package/.output/server/_ssr/{router-DdQM-GKb.mjs → router-C1qBqYEd.mjs} +1 -1
- package/.output/server/index.mjs +1 -1
- package/.output/ui/assets/{CompareDrawer-CShDEmfP.js → CompareDrawer-B6l7sK_o.js} +1 -1
- package/.output/ui/assets/{InspectorPet-CWhTcJ9B.js → InspectorPet-Dv-hDdxU.js} +1 -1
- package/.output/ui/assets/{ProxyViewerContainer-CqshEdSs.js → ProxyViewerContainer-B5SUiugd.js} +9 -9
- package/.output/ui/assets/{ReplayDialog-BJ8D4xB2.js → ReplayDialog-BACtWGKs.js} +1 -1
- package/.output/ui/assets/{RequestAnatomy-BFKM3yGQ.js → RequestAnatomy-DqG3yRes.js} +1 -1
- package/.output/ui/assets/{ResponseView-Bf3XTX0j.js → ResponseView-CwqmhaXg.js} +1 -1
- package/.output/ui/assets/{StreamingChunkSequence-DXJml955.js → StreamingChunkSequence-DMdSkso8.js} +1 -1
- package/.output/ui/assets/{_sessionId-CowTEw-q.js → _sessionId-C_2LW0jh.js} +1 -1
- package/.output/ui/assets/{_sessionId-ARN26_qP.js → _sessionId-Ca0TjDw_.js} +1 -1
- package/.output/ui/assets/{index-IbmvwYpF.js → index-C85xqQrL.js} +1 -1
- package/.output/ui/assets/{index-DFRkItda.js → index-DZdFLvt4.js} +1 -1
- package/.output/ui/assets/{index-P5NBm7WS.js → index-Dt0cOy7U.js} +1 -1
- package/.output/ui/assets/{index-BiHhje8y.js → index-OquTzqLZ.js} +2 -2
- package/.output/ui/assets/{json-viewer-C1LnVpk8.js → json-viewer-DIr-vdVp.js} +1 -1
- package/.output/ui/assets/{jszip.min-DxviP4Rn.js → jszip.min-D5ch91g-.js} +1 -1
- package/.output/ui/index.html +1 -1
- package/package.json +4 -4
package/.output/ui/assets/{ProxyViewerContainer-CqshEdSs.js → ProxyViewerContainer-B5SUiugd.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./jszip.min-
|
|
2
|
-
import{l as Wh,u as Vt,s as x,n as T,b as Ce,_ as Yo,a as V,c as qe,o as _,d as me,e as ae,f as Nn,g as Fs,h as $t,i as nu,k as tt,r as l,j as n,m as Wt,p as On,A as Zl,q as Gh,t as oa,v as Nr,w as Cs,x as P,B as te,y as Un,z as su,C as Ie,D as ou,E as Tt,F as Li,G as Kh,H as Be,L as Jo,I as ru,J as Yh,K as Xo,M as Jh,N as Xh,O as Zh,P as au,Q as Oi,T as Qh,U as ex}from"./index-BiHhje8y.js";const Je=Wh(()=>Vt([x(),T(),Ce(),Yo(),V(Je),qe(x(),Je)])),Rt=T().int().nonnegative().max(Number.MAX_SAFE_INTEGER),tx=me(["capacity-exceeded","pipeline-closed","write-failed","finalize-failed","finalize-timeout","upstream-stream-error","shutdown"]),iu=_({index:T(),timestamp:T(),type:x(),data:Je}),nx=_({id:x(),logId:Rt,index:T().int().nonnegative(),provider:me(["anthropic","openai"]),name:x(),argumentsText:x().nullable(),argumentsPreview:x().nullable()}),sx=me(["end_turn","tool_use","stop","length"]),ox=sx.nullable(),rx=_({chunks:V(iu),truncated:Ce().optional().default(!1)}),ax=me(["request","response"]),lu=_({logId:Rt,part:ax,text:x(),offset:T().int().nonnegative(),limit:T().int().positive(),totalBytes:T().int().nonnegative(),textBytes:T().int().nonnegative(),nextOffset:T().int().nonnegative().nullable(),hasMore:Ce(),contentMode:me(["empty","partial","full"])}),Hs=_({id:Rt,timestamp:x(),method:x(),path:x(),model:x().nullable(),sessionId:x().nullable(),rawRequestBody:x().nullable(),responseStatus:T().nullable(),responseText:x().nullable(),inputTokens:T().nullable(),outputTokens:T().nullable(),cacheCreationInputTokens:T().nullable(),cacheReadInputTokens:T().nullable(),elapsedMs:T().nullable(),firstChunkMs:T().nullable().optional(),totalStreamMs:T().nullable().optional(),tokensPerSecond:T().nullable().optional(),streaming:Ce(),userAgent:x().nullable(),origin:x().nullable(),rawHeaders:qe(x(),x()).optional(),headers:qe(x(),x()).optional(),apiFormat:me(["anthropic","openai","unknown"]).default("unknown"),isTest:Ce().optional().default(!1),replayOfLogId:Rt.nullable().optional(),providerName:x().nullable().optional(),clientPort:T().nullable().optional(),clientPid:T().nullable().optional(),clientCwd:x().nullable().optional(),clientProjectFolder:x().nullable().optional(),streamingChunks:rx.optional(),streamingChunksPath:x().nullable().optional(),rawRequestBodyBytes:T().int().nonnegative().nullable().optional(),responseTextBytes:T().int().nonnegative().nullable().optional(),bodyContentMode:me(["full","compact","truncated"]).optional(),captureIncomplete:Ce().optional(),droppedChunks:T().int().nonnegative().optional(),droppedBytes:T().int().nonnegative().optional(),captureIncompleteReason:tx.nullable().optional(),warnings:V(x()).optional(),toolTraceEvents:V(nx).optional(),stopReason:ox.optional(),error:x().nullable().optional()}),Di=_({type:x(),ttl:x().optional(),scope:x().optional()}),zi=_({type:ae("text"),text:x(),cache_control:Di.optional()}),cu=_({type:ae("thinking"),thinking:x(),signature:x().optional()}),ix=_({type:ae("think"),thinking:x(),signature:x().optional()}),lx=_({type:ae("base64"),media_type:x(),data:x()}),du=_({type:ae("image"),source:lx}),uu=_({type:ae("tool_use"),id:x(),name:x(),input:qe(x(),Je)}),cx=Nn("type",[zi,du]),dx=_({type:ae("tool_result"),tool_use_id:x().optional(),content:Vt([x(),V(cx)]),is_error:Ce().optional()}),ux=Nn("type",[zi,cu,du,uu,dx]),mx=Vt([x(),V(ux)]),px=_({role:me(["user","assistant"]),content:mx}),fx=_({type:ae("text"),text:x(),cache_control:Di.optional()}),hx=_({type:x(),properties:qe(x(),qe(x(),Je)).optional(),required:V(x()).optional(),additionalProperties:Ce().optional(),$schema:x().optional()}),xx=_({name:x(),description:x().optional(),input_schema:hx.optional(),cache_control:Di.optional()}),gx=Nn("type",[_({type:ae("enabled"),budget_tokens:T()}),_({type:ae("disabled")}),_({type:ae("adaptive")})]),bx=_({model:x(),messages:V(px),system:V(fx).optional(),tools:V(xx).optional(),max_tokens:T().optional(),temperature:T().optional(),stream:Ce().optional(),thinking:gx.optional(),metadata:_({user_id:x().optional()}).optional()}),$i=Nn("type",[zi,cu,ix,uu]),vx=_({input_tokens:T().nullable().optional(),output_tokens:T().nullable().optional(),cache_creation_input_tokens:T().nullable().optional(),cache_read_input_tokens:T().nullable().optional()}).passthrough(),yx=_({id:x(),type:ae("message"),model:x(),role:ae("assistant"),content:V($i),stop_reason:x().nullable(),stop_sequence:x().nullable().optional(),usage:vx}).passthrough(),wx=_({type:ae("message_start"),message:_({id:x(),type:ae("message"),model:x(),role:ae("assistant"),content:V($i),stop_reason:Yo(),stop_sequence:Yo(),usage:_({input_tokens:T(),cache_creation_input_tokens:T().optional(),cache_read_input_tokens:T().optional()}).passthrough()})}),jx=_({type:ae("content_block_start"),index:T(),content_block:$i}),Sx=Nn("type",[_({type:ae("text_delta"),text:x()}),_({type:ae("input_json_delta"),partial_json:x()}),_({type:ae("thinking_delta"),thinking:x()}),_({type:ae("signature_delta"),signature:x()})]),Nx=_({type:ae("content_block_delta"),index:T(),delta:Sx}),Cx=_({type:ae("content_block_stop"),index:T()}),kx=_({type:ae("message_delta"),delta:_({stop_reason:x().nullable(),stop_sequence:x().nullable().optional()}),usage:_({output_tokens:T(),input_tokens:T().optional(),cache_creation_input_tokens:T().optional(),cache_read_input_tokens:T().optional()}).passthrough()}),_x=_({type:ae("message_stop")}),Tx=_({type:ae("ping")}),Ex=_({type:ae("error"),error:_({type:x(),message:x()})});Nn("type",[wx,jx,Nx,Cx,kx,_x,Tx,Ex]);const Rx=Vt([x(),V(Nn("type",[_({type:ae("text"),text:x()}),_({type:ae("image_url"),image_url:_({url:x(),detail:x().optional()})})]))]),mu=_({role:me(["system","user","assistant","tool"]),content:Rx,name:x().optional(),reasoning_content:x().optional(),thinking:x().optional(),think:x().optional()}),Mx=_({name:x(),arguments:x()}),pu=_({index:T().optional(),id:x().optional(),type:ae("function").optional(),function:_({name:x().optional(),arguments:x().optional()})});mu.extend({content:Vt([x(),V(_({type:ae("text"),text:x()}))]).optional(),function_call:Mx.optional(),tool_calls:V(pu).optional()});const Ax=_({type:ae("function"),function:_({name:x(),description:x().optional(),parameters:qe(x(),Je)})}),Ix=_({model:x(),messages:V(mu),temperature:T().optional(),max_tokens:T().optional(),stream:Ce().optional(),tools:V(Ax).optional(),tool_choice:Vt([me(["auto","none","required"]),_({type:ae("auto")}),_({type:ae("none")}),_({type:ae("function"),function:_({name:x()})})]).optional(),user:x().optional()}),Px=_({type:x(),name:x().optional(),description:x().optional(),parameters:Je.optional(),function:_({name:x().optional(),description:x().optional(),parameters:Je.optional()}).optional()}).passthrough(),Lx=_({model:x(),input:Fs().optional(),instructions:Vt([x(),Yo()]).optional(),stream:Ce().optional(),tools:V(Px).optional(),tool_choice:Fs().optional(),max_output_tokens:T().optional(),temperature:T().optional(),user:x().optional(),metadata:qe(x(),Fs()).optional()}).passthrough(),fu=_({role:me(["assistant"]).optional(),content:x().nullable().optional(),reasoning_content:x().nullable().optional(),thinking:x().nullable().optional(),think:x().nullable().optional(),function_call:_({name:x().optional(),arguments:x().optional()}).nullable().optional(),tool_calls:V(_({index:T(),id:x().optional(),type:ae("function").optional(),function:_({name:x().optional(),arguments:x().optional()})})).nullable().optional()}),Ox=_({index:T(),message:_({role:me(["assistant"]),content:x().nullable(),reasoning_content:x().optional(),thinking:x().optional(),think:x().optional(),function_call:_({name:x(),arguments:x()}).nullable().optional(),tool_calls:V(pu).optional()}).optional(),delta:fu.optional(),finish_reason:x().nullable()}),Dx=_({id:x(),object:ae("chat.completion"),created:T(),model:x(),choices:V(Ox),usage:_({prompt_tokens:T().nullable().optional(),completion_tokens:T().nullable().optional(),total_tokens:T().nullable().optional()}).passthrough(),service_tier:x().nullable().optional(),system_fingerprint:x().nullable().optional()}).passthrough();_({id:x(),object:ae("chat.completion.chunk"),created:T(),model:x(),choices:V(_({index:T(),delta:fu,finish_reason:x().nullable().optional()})),usage:_({prompt_tokens:T().nullable().optional(),completion_tokens:T().nullable().optional(),total_tokens:T().nullable().optional()}).passthrough().nullable().optional()}).passthrough();const zx=_({input_tokens:T().nullable().optional(),output_tokens:T().nullable().optional(),total_tokens:T().nullable().optional(),input_tokens_details:_({cached_tokens:T().nullable().optional()}).passthrough().nullable().optional(),output_tokens_details:_({reasoning_tokens:T().nullable().optional()}).passthrough().nullable().optional()}).passthrough(),$x=_({type:x()}).passthrough(),Fx=_({id:x(),object:ae("response").optional(),created_at:T().optional(),status:x().nullable().optional(),model:x().optional(),output:V($x).optional(),output_text:x().optional(),usage:zx.nullable().optional(),error:Fs().optional()}).passthrough();_({type:x()}).passthrough();function Bx(e){try{const t=JSON.parse(e),s=Dx.safeParse(t);return s.success?s.data:null}catch{return null}}function Ux(e){try{const t=JSON.parse(e),s=Fx.safeParse(t);return s.success?s.data:null}catch{return null}}const hu=_({input:T().int().nonnegative(),output:T().int().nonnegative(),cacheCreate:T().int().nonnegative(),cacheRead:T().int().nonnegative(),total:T().int().nonnegative()}),qx=_({id:Rt,sessionLogNumber:T().int().positive().optional(),timestamp:x(),provider:x().nullable(),model:x().nullable(),apiFormat:me(["anthropic","openai","unknown"]),method:x(),path:x(),status:T().nullable(),isStreaming:Ce(),hasError:Ce(),error:x().nullable(),latencyMs:T().nullable(),firstChunkMs:T().nullable().optional(),totalStreamMs:T().nullable().optional(),tokensPerSecond:T().nullable().optional(),tokens:_({input:T().nullable(),output:T().nullable(),cacheCreate:T().nullable(),cacheRead:T().nullable()}),sessionId:x().nullable(),userAgent:x().nullable().optional(),clientPid:T().nullable().optional(),clientProjectFolder:x().nullable().optional()}),xu=_({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:T().int().nonnegative(),activeRequests:T().int().nonnegative(),completedRequests:T().int().nonnegative(),failedRequests:T().int().nonnegative(),queuedTasks:T().int().nonnegative(),runningTasks:T().int().nonnegative(),lastTaskError:x().nullable(),logCount:T().int().nonnegative(),errorCount:T().int().nonnegative(),models:V(x()),providers:V(x()),tokenUsage:hu,lastLogId:Rt.nullable(),lastModel:x().nullable(),clientUserAgent:x().nullable().optional(),clientPid:T().nullable(),clientProjectFolder:x().nullable(),inspectorPath:x(),inspectorUrl:x(),apiPath:x(),apiUrl:x(),compactLogsPath:x(),compactLogsUrl:x(),latestLogLimit:T().int().positive(),latestLogs:V(qx)}),Qs=me(["created","running","completed","failed","cancelled"]),Fi=_({jsonPath:x(),markdownPath:x(),htmlPath:x(),exportedAt:x()}),Hx=me(["run-created","session-started","request","session-finished","evidence-exported"]),Vx=me(["info","success","warning","error"]),Wx=_({timestamp:x(),kind:Hx,severity:Vx,title:x(),details:x(),logId:Rt.nullable(),status:T().nullable(),model:x().nullable(),provider:x().nullable(),latencyMs:T().nullable(),isStreaming:Ce().nullable()}),Gx=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"]),gu=_({outcome:me(["success","failure","active","unknown"]),severity:me(["none","low","medium","high"]),category:Gx,summary:x(),evidenceLogIds:V(Rt),hints:V(x())}),Bi=_({status:me(["PASS","FAIL","RUNNING","UNKNOWN"]),summary:x(),markdown:x()}),bu=Bi,Ui=_({id:x(),sessionId:x(),groupId:x().nullable().default(null),title:x(),task:x().nullable(),project:x().nullable(),agent:x().nullable(),status:Qs,tags:V(x()),metadata:qe(x(),Je),evidence:Fi.nullable(),createdAt:x(),updatedAt:x()});_({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:Qs.optional(),tags:V(x()).optional(),metadata:qe(x(),Je).optional()}).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:Qs.optional(),tags:V(x()).optional(),metadata:qe(x(),Je).optional()});_({includeHistory:Ce().optional(),latestLogLimit:T().int().positive().max(50).optional()}).optional();_({run:Ui,evidence:Fi,session:xu.nullable(),timeline:V(Wx),classification:gu,jenkinsReport:Bi});const Kx=_({run:Ui,classification:gu,evidence:Fi.nullable(),jenkinsReport:Bi.nullable(),sessionId:x(),inspectorUrl:x().nullable(),evidenceMarkdownPath:x().nullable(),updatedAt:x()});_({failures:V(Kx),total:T().int().nonnegative(),limit:T().int().positive()});const qi=me(["created","running","completed","failed","cancelled"]),Hi=me(["evaluation","batch","manual"]),Vi=_({jsonPath:x(),markdownPath:x(),htmlPath:x(),exportedAt:x()}),vu=_({id:x(),groupId:x(),sessionId:x(),runId:x().nullable(),label:x().nullable(),agent:x().nullable(),provider:x().nullable(),model:x().nullable(),status:Qs.nullable(),metadata:qe(x(),Je),addedAt:x(),updatedAt:x()}),Wi=_({id:x(),title:x(),kind:Hi,task:x().nullable(),project:x().nullable(),status:qi,tags:V(x()),metadata:qe(x(),Je),evidence:Vi.nullable(),members:V(vu),createdAt:x(),updatedAt:x()});_({groupId:x().min(1).optional(),title:x().min(1).optional(),kind:Hi.optional(),task:x().nullable().optional(),project:x().nullable().optional(),status:qi.optional(),tags:V(x()).optional(),metadata:qe(x(),Je).optional()}).optional();_({title:x().min(1).optional(),kind:Hi.optional(),task:x().nullable().optional(),project:x().nullable().optional(),status:qi.optional(),tags:V(x()).optional(),metadata:qe(x(),Je).optional()});_({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:Qs.nullable().optional(),metadata:qe(x(),Je).optional()});_({includeHistory:Ce().optional(),latestLogLimit:T().int().positive().max(50).optional()}).optional();_({deleteEvidence:Ce().optional()});const yu=_({groupId:x(),deleted:Ce(),evidenceDeleted:Ce(),evidencePath:x().nullable()}),wu=_({deleted:T().int().nonnegative(),groups:V(yu)}),ju=_({member:vu,run:Ui.nullable(),session:xu.nullable()}),Su=_({memberCount:T().int().nonnegative(),sessionsWithData:T().int().nonnegative(),missingSessions:T().int().nonnegative(),requestCount:T().int().nonnegative(),errorCount:T().int().nonnegative(),tokenUsage:hu,models:V(x()),providers:V(x()),completedMembers:T().int().nonnegative(),failedMembers:T().int().nonnegative(),runningMembers:T().int().nonnegative()}),Yx=_({group:Wi,evidence:Vi,members:V(ju).nullable(),markdown:x(),summary:Su.nullable(),report:bu.nullable()}),Jx=_({group:Wi,evidence:Vi,members:V(ju),summary:Su,jenkinsReport:bu}),Nu=_({groups:V(Wi)}),Xx=_({sessionId:x(),imported:T().int().nonnegative(),skipped:T().int().nonnegative(),warnings:V(x()),logs:V(Hs)}),Zo=10,Xa=600,Qo=60,Za=600,er="time",Gi="simple",Cu=me(["time","full"]),Zx=me(["simple","full"]),Cr=_({stripClaudeCodeBillingHeader:Ce(),hasSeenOnboarding:Ce().default(!1),slowResponseThresholdSeconds:T().int().min(0).max(Xa).default(Zo),providerTestTimeoutSeconds:T().int().min(1).max(Za).default(Qo),timeDisplayFormat:Cu.default(er),captureMode:Zx.default(Gi)}),as="/api/config";async function Qx(e){return tt(e,Cr,void 0,t=>`Failed to fetch ${e}: ${t.status}`)}async function mo(e){return tt(as,Cr,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e)},t=>`PATCH failed with status ${t.status}`)}function Ki(){const e=$t(as,Qx,{revalidateOnFocus:!1,revalidateIfStale:!1}),{mutate:t}=nu(),s=e.data?.stripClaudeCodeBillingHeader??!1,o=e.data?.captureMode??Gi,r=e.data?.slowResponseThresholdSeconds??Zo,a=e.data?.providerTestTimeoutSeconds??Qo,i=e.data?.timeDisplayFormat??er,c=f=>({stripClaudeCodeBillingHeader:e.data?.stripClaudeCodeBillingHeader??!1,hasSeenOnboarding:e.data?.hasSeenOnboarding??!1,slowResponseThresholdSeconds:e.data?.slowResponseThresholdSeconds??Zo,providerTestTimeoutSeconds:e.data?.providerTestTimeoutSeconds??Qo,timeDisplayFormat:e.data?.timeDisplayFormat??er,captureMode:o,...f}),d=async f=>{await t(as,mo({stripClaudeCodeBillingHeader:f}),{optimisticData:c({stripClaudeCodeBillingHeader:f}),rollbackOnError:!0,revalidate:!1})},m=async f=>{await t(as,mo({slowResponseThresholdSeconds:f}),{optimisticData:c({slowResponseThresholdSeconds:f}),rollbackOnError:!0,revalidate:!1})},u=async f=>{await t(as,mo({timeDisplayFormat:f}),{optimisticData:c({timeDisplayFormat:f}),rollbackOnError:!0,revalidate:!1})},p=async f=>{await t(as,mo({providerTestTimeoutSeconds:f}),{optimisticData:c({providerTestTimeoutSeconds:f}),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:p,setTimeDisplayFormat:u}}const ku=(...e)=>e.filter((t,s,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===s).join(" ").trim();const e0=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const t0=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,s,o)=>o?o.toUpperCase():s.toLowerCase());const Ql=e=>{const t=t0(e);return t.charAt(0).toUpperCase()+t.slice(1)};var n0={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 s0=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};const o0=l.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:s=2,absoluteStrokeWidth:o,className:r="",children:a,iconNode:i,...c},d)=>l.createElement("svg",{ref:d,...n0,width:t,height:t,stroke:e,strokeWidth:o?Number(s)*24/Number(t):s,className:ku("lucide",r),...!a&&!s0(c)&&{"aria-hidden":"true"},...c},[...i.map(([m,u])=>l.createElement(m,u)),...Array.isArray(a)?a:[a]]));const B=(e,t)=>{const s=l.forwardRef(({className:o,...r},a)=>l.createElement(o0,{ref:a,iconNode:t,className:ku(`lucide-${e0(Ql(e))}`,`lucide-${e}`,o),...r}));return s.displayName=Ql(e),s};const r0=[["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"}]],a0=B("a-large-small",r0);const i0=[["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"}]],l0=B("activity",i0);const c0=[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]],d0=B("arrow-down-right",c0);const u0=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],m0=B("arrow-down",u0);const p0=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],f0=B("arrow-left",p0);const h0=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],x0=B("arrow-up-right",h0);const g0=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],b0=B("arrow-up",g0);const v0=[["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"}]],Yi=B("beaker",v0);const y0=[["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"}]],w0=B("bell",y0);const j0=[["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"}]],S0=B("blocks",j0);const N0=[["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"}]],C0=B("brain-circuit",N0);const k0=[["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"}]],_u=B("brain",k0);const _0=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Fe=B("check",_0);const T0=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Xe=B("chevron-down",T0);const E0=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],R0=B("chevron-left",E0);const M0=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],gt=B("chevron-right",M0);const A0=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Ji=B("chevron-up",A0);const I0=[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]],P0=B("chevrons-down",I0);const L0=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],O0=B("chevrons-left",L0);const D0=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],z0=B("chevrons-right",D0);const $0=[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]],F0=B("chevrons-up",$0);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"}]],gs=B("circle-alert",B0);const U0=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],eo=B("circle-check-big",U0);const q0=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Qa=B("circle-check",q0);const H0=[["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"}]],V0=B("circle-question-mark",H0);const W0=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],G0=B("circle-stop",W0);const K0=[["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"}]],Tu=B("circle-x",K0);const Y0=[["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"}]],J0=B("clapperboard",Y0);const X0=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Z0=B("clock-3",X0);const Q0=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],en=B("clock",Q0);const eg=[["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"}]],tg=B("cloud-upload",eg);const ng=[["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"}]],Eu=B("code-xml",ng);const sg=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],og=B("columns-2",sg);const rg=[["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"}]],It=B("copy",rg);const ag=[["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"}]],ig=B("cpu",ag);const lg=[["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"}]],to=B("download",lg);const cg=[["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"}]],dg=B("ellipsis",cg);const ug=[["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"}]],Xi=B("external-link",ug);const mg=[["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"}]],pg=B("eye-off",mg);const fg=[["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"}]],Ru=B("eye",fg);const hg=[["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"}]],xg=B("file-braces",hg);const gg=[["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"}]],bg=B("file-diff",gg);const vg=[["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"}]],yg=B("file-search",vg);const wg=[["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"}]],jg=B("file-terminal",wg);const Sg=[["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"}]],Ng=B("file-text",Sg);const Cg=[["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"}]],kg=B("flag",Cg);const _g=[["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"}]],Mu=B("flask-conical",_g);const Tg=[["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"}]],Eg=B("folder-open",Tg);const Rg=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Zi=B("gauge",Rg);const Mg=[["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"}]],Ag=B("git-compare-arrows",Mg);const Ig=[["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"}]],Au=B("globe",Ig);const Pg=[["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"}]],Iu=B("history",Pg);const Lg=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Og=B("info",Lg);const Dg=[["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"}]],ec=B("layers",Dg);const zg=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Ue=B("loader-circle",zg);const $g=[["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"}]],Fg=B("lock",$g);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"}]],Ug=B("maximize-2",Bg);const qg=[["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"}]],kr=B("message-square",qg);const Hg=[["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"}]],Vg=B("minimize-2",Hg);const Wg=[["path",{d:"M5 12h14",key:"1ays0h"}]],Pu=B("minus",Wg);const Gg=[["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"}]],Kg=B("monitor",Gg);const Yg=[["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"}]],Jg=B("moon",Yg);const Xg=[["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"}]],Zg=B("mouse-pointer-click",Xg);const Qg=[["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"}]],e1=B("network",Qg);const t1=[["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"}]],n1=B("octagon-alert",t1);const s1=[["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"}]],o1=B("package-check",s1);const r1=[["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"}]],a1=B("panel-right-close",r1);const i1=[["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"}]],l1=B("panel-right-open",i1);const c1=[["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"}]],Lu=B("pencil",c1);const d1=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],tc=B("plus",d1);const u1=[["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"}]],nc=B("radio",u1);const m1=[["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"}]],Et=B("refresh-cw",m1);const p1=[["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"}]],Ou=B("rocket",p1);const f1=[["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"}]],Du=B("rotate-ccw",f1);const h1=[["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"}]],tr=B("rotate-cw",h1);const x1=[["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"}]],g1=B("rows-3",x1);const b1=[["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"}]],v1=B("save",b1);const y1=[["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"}]],w1=B("scan",y1);const j1=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],S1=B("search",j1);const N1=[["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"}]],C1=B("send",N1);const k1=[["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"}]],_1=B("server",k1);const T1=[["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"}]],E1=B("settings",T1);const R1=[["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"}]],M1=B("shield-alert",R1);const A1=[["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"}]],sc=B("shield-check",A1);const I1=[["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"}]],nr=B("siren",I1);const P1=[["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"}]],ei=B("sparkles",P1);const L1=[["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"}]],O1=B("sun",L1);const D1=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],qn=B("terminal",D1);const z1=[["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"}]],zu=B("timer",z1);const $1=[["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"}]],yn=B("trash-2",$1);const F1=[["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"}]],gn=B("triangle-alert",F1);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"}]],$u=B("upload",B1);const U1=[["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"}]],q1=B("wifi-off",U1);const H1=[["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"}]],V1=B("wifi",H1);const W1=[["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"}]],no=B("wrench",W1);const G1=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],so=B("x",G1);const K1=[["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"}]],Vs=B("zap",K1),ti="/api/config";async function Y1(e){return tt(e,Cr,void 0,t=>`Failed to fetch ${e}: ${t.status}`)}async function J1(e){return tt(ti,Cr,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e)},t=>`PATCH failed with status ${t.status}`)}function X1(){const e=$t(ti,Y1,{revalidateOnFocus:!1,revalidateIfStale:!1}),{mutate:t}=nu(),s=e.data?.hasSeenOnboarding??!1,o=e.data?.captureMode??Gi,r=async()=>{await t(ti,J1({hasSeenOnboarding:!0}),{optimisticData:{stripClaudeCodeBillingHeader:e.data?.stripClaudeCodeBillingHeader??!1,hasSeenOnboarding:!0,slowResponseThresholdSeconds:e.data?.slowResponseThresholdSeconds??Zo,providerTestTimeoutSeconds:e.data?.providerTestTimeoutSeconds??Qo,timeDisplayFormat:e.data?.timeDisplayFormat??er,captureMode:o},rollbackOnError:!0,revalidate:!1})};return{hasSeenOnboarding:s,captureMode:o,isLoading:e.isLoading,markSeen:r}}function Z1({isLoading:e,hasSeenOnboarding:t,dismissedInView:s}){return!e&&!t&&!s}function Q1({expanded:e,onToggle:t,onDismiss:s}){const o=e?"grid":"hidden sm:grid";return n.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:n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx(Og,{className:"mt-0.5 size-4 shrink-0 text-warning","aria-hidden":"true"}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[n.jsx("span",{className:"font-medium text-foreground",children:"Inspector ready"}),n.jsx("span",{className:"hidden truncate text-xs text-muted-foreground sm:inline",children:"Request, response, tool, timing, token, replay, and memory signals are active."})]}),n.jsx("div",{className:"mt-1 text-xs leading-relaxed text-muted-foreground sm:hidden",children:"Core capture is active."}),n.jsxs("div",{className:`${o} mt-2 gap-x-4 gap-y-1 text-xs leading-relaxed text-muted-foreground sm:grid-cols-2`,children:[n.jsxs("div",{children:[n.jsx("strong",{children:"Evidence"}),": logs, sessions, groups, and MCP exports are available."]}),n.jsxs("div",{children:[n.jsx("strong",{children:"Network"}),": replace ",n.jsx("code",{children:"localhost"})," if containers differ."]})]})]}),n.jsx("button",{type:"button",onClick:t,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:n.jsx(Xe,{className:`size-3.5 transition-transform ${e?"rotate-180":""}`})}),n.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:[n.jsx(Fe,{className:"size-3.5"}),"Got it"]}),n.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:n.jsx(so,{className:"size-3.5"})})]})})}function eb(){const{hasSeenOnboarding:e,isLoading:t,markSeen:s}=X1(),[o,r]=l.useState(!1),[a,i]=l.useState(!1);return Z1({isLoading:t,hasSeenOnboarding:e,dismissedInView:a})?n.jsx(Q1,{expanded:o,onToggle:()=>r(c=>!c),onDismiss:()=>{i(!0),s().catch(()=>{})}}):null}const tb="4.0.12",Fu={version:tb};function is(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Bu="[REDACTED]",nb=/(^|[-_])(api[-_]?key|authorization|cookie|token|secret|password|access[-_]?token|refresh[-_]?token)([-_]|$)/i,sb=[/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],oc=200,ob=25e6,Uu=50,rb=1e4,ab=1024*1024,ib=64,lb=1e4;function cb(e){return e<1024?`${e} chars`:e<1024*1024?`${Math.ceil(e/1024)} KB`:`${Math.ceil(e/(1024*1024))} MB`}function db(e){let t=0;for(const s of e)t+=s.rawRequestBody?.length??s.rawRequestBodyBytes??0,t+=s.responseText?.length??s.responseTextBytes??0;return t}function ub(e){if(e.length>oc)return`Export is limited to ${oc} logs at once. Narrow the filter and try again.`;const t=db(e);return t>ob?`Export is too large (${cb(t)} of text). Narrow the filter and try again.`:null}function po(e){return e?.aborted===!0?{ok:!1,message:"Export canceled.",canceled:!0}:null}async function mb(e,t){try{const s=await On(`/api/logs/${e}/chunks`,rb,{signal:t});if(!s.ok)return null;const o=await s.json();return JSON.stringify(o,null,2)}catch{return null}}function pb(e,t){switch(t){case"request":return e.rawRequestBody;case"response":return e.responseText}}async function rc(e,t,s){const o=pb(e,t);if(o!==null)return o;let r=0,a="";for(let i=0;i<ib;i+=1){const c=new URLSearchParams({part:t,offset:String(r),limit:String(ab)});try{const d=await On(`/api/logs/${String(e.id)}/body?${c.toString()}`,lb,{signal:s});if(!d.ok)return a.length>0?a:null;const m=await d.json(),u=lu.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 ni(e){if(Array.isArray(e))return e.map(s=>ni(s));if(!is(e))return e;const t={};for(const[s,o]of Object.entries(e))t[s]=nb.test(s)?Bu:ni(o);return t}function fb(e){const t=s=>{let o=s;for(const r of sb)o=o.replace(r,Bu);return o};try{const s=JSON.parse(e);return t(JSON.stringify(ni(s),null,2))}catch{return t(e)}}function ra(e,t){return t==="redacted"?fb(e):e}function hb(e,t){return{...e,rawRequestBody:null,responseText:null,rawHeaders:t==="raw"?e.rawHeaders:void 0,headers:t==="raw"?e.headers:void 0,streamingChunks:void 0,bodyContentMode:"compact"}}function xb(e,t,s,o=new Date().toISOString()){return{version:Fu.version,exportedAt:o,mode:t,redacted:t==="redacted",logCount:e.length,logIds:e.map(r=>r.id),streamingChunkExportLimit:Uu,streamingChunkLogIds:s.map(r=>r.id)}}async function gb(e,t="redacted",s={}){const o=po(s.signal);if(o!==null)return o;const r=ub(e);if(r!==null)return{ok:!1,message:r};const{default:a}=await Wt(async()=>{const{default:h}=await import("./jszip.min-DxviP4Rn.js").then(g=>g.j);return{default:h}},__vite__mapDeps([0,1,2]),import.meta.url),i=new a,c=t==="redacted"?"redacted":"raw",d=e.filter(h=>h.streaming).slice(0,Uu);i.file("manifest.json",JSON.stringify(xb(e,t,d),null,2)),i.file("logs.json",JSON.stringify(e.map(h=>hb(h,t)),null,2));for(const h of e){const g=po(s.signal);if(g!==null)return g;const b=await rc(h,"request",s.signal);b!==null&&i.file(`#${h.id}.Request.json`,ra(b,t));const y=await rc(h,"response",s.signal);y!==null&&i.file(`#${h.id}.Response.json`,ra(y,t))}for(const h of d){const g=po(s.signal);if(g!==null)return g;const b=await mb(h.id,s.signal);b!==null&&i.file(`#${h.id}.SSE.Response.json`,ra(b,t))}const m=await i.generateAsync({type:"blob"}),u=po(s.signal);if(u!==null)return u;const p=URL.createObjectURL(m),f=document.createElement("a");return f.href=p,f.download=`agent-inspector-export-${c}-${new Date().toISOString().slice(0,10)}.zip`,document.body.appendChild(f),f.click(),document.body.removeChild(f),URL.revokeObjectURL(p),{ok:!0}}function bb(e){const t=oa(e,"/proxy"),s=oa(e,"/proxy/v1"),o=oa(e,"/api/mcp");return t===null||s===null||o===null?null:{proxy:t,openAiV1:s,mcp:o}}function vb(){const e=Gh();return e.ok?bb(e.runtime):null}function Qi(e){const t=()=>e(vb());return t(),typeof globalThis.addEventListener!="function"||typeof globalThis.removeEventListener!="function"?()=>{}:(globalThis.addEventListener(Zl,t),()=>globalThis.removeEventListener(Zl,t))}function si(e,t){switch(t){case"full":return e;case"time":return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}}function _r(e,t,s){return`${si(e,s)} - ${si(t,s)}`}const el="agent-inspector.theme";function qu(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 aa(e){typeof document>"u"||(document.documentElement.dataset.theme=e)}function yb(){if(typeof window>"u")return"dark";try{return qu(window.localStorage.getItem(el))}catch{return"dark"}}function wb(e){if(!(typeof window>"u"))try{window.localStorage.setItem(el,e)}catch{}}function jb(){const[e,t]=l.useState(yb),s=l.useCallback(o=>{t(o),aa(o),wb(o)},[]);return l.useEffect(()=>{aa(e)},[e]),l.useEffect(()=>{function o(r){if(r.key!==el)return;const a=qu(r.newValue);t(a),aa(a)}return window.addEventListener("storage",o),()=>window.removeEventListener("storage",o)},[]),{themeMode:e,setThemeMode:s}}const tl="agent-inspector.uiScale",Sb=1.25,Nb=2200,Cb=3e3,kb=12;function ia(e,t){return Number.isFinite(e)&&e>0?e:t}function nl(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 _b(e,t){switch(e){case"100":return 1;case"125":return 1.25;case"150":return 1.5;case"auto":{const s=ia(t.viewportWidth,1280),o=ia(t.screenWidth,s),r=ia(t.devicePixelRatio,1),a=Math.min(s,o);return r>Sb?1:a>=Cb?1.25:a>=Nb?1.125:1}}}function Tb(e){return`${Math.round(e*100)}%`}function la(e,t){return Math.max(kb,e*t)}function Eb(){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 ca(e){const t=_b(e,Eb());if(typeof document>"u")return t;const s=document.documentElement;return s.dataset.uiScale=e,s.dataset.uiScaleResolved=String(Math.round(t*100)),s.style.setProperty("--inspector-ui-scale",String(t)),s.style.setProperty("--inspector-root-font-size",`${String(16*t)}px`),s.style.setProperty("--inspector-font-9",`${String(la(9,t))}px`),s.style.setProperty("--inspector-font-10",`${String(la(10,t))}px`),s.style.setProperty("--inspector-font-11",`${String(la(11,t))}px`),s.style.setProperty("--inspector-font-13",`${String(13*t)}px`),t}function Rb(){if(typeof window>"u")return"auto";try{return nl(window.localStorage.getItem(tl))}catch{return"auto"}}function Mb(e){if(!(typeof window>"u"))try{window.localStorage.setItem(tl,e)}catch{}}function Ab(){const[e,t]=l.useState(Rb),[s,o]=l.useState(1),r=l.useCallback(a=>{t(a),Mb(a),o(ca(a))},[]);return l.useEffect(()=>{const a=()=>{o(ca(e))};if(a(),e==="auto")return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[e]),l.useEffect(()=>{const a=i=>{if(i.key!==tl)return;const c=nl(i.newValue);t(c),o(ca(c))};return window.addEventListener("storage",a),()=>window.removeEventListener("storage",a)},[]),{uiScalePreference:e,resolvedUiScale:s,setUiScalePreference:r}}const Ib=200,Pb=512,Lb=256,bn=64,oi=256,Hu=64,Ob=32,Db=2,zb=4,ac=16,ve=T().int().positive(),$b=_({proxy:_({requestBytes:ve,responseBytes:ve,headerBytes:ve,deadlineMs:ve,idleTimeoutMs:ve,activeRequests:ve}),control:_({requestBytes:ve,responseBytes:ve,headerBytes:ve,deadlineMs:ve,idleTimeoutMs:ve,activeRequests:ve}),upstream:_({fetchResponseBytes:ve,fetchDeadlineMs:ve,replayResponseBytes:ve,replayDeadlineMs:ve,metadataResponseBytes:ve,metadataDeadlineMs:ve,connectTimeoutMs:ve,idleTimeoutMs:ve}),pagination:_({restPageSize:ve,searchQueryChars:ve,searchProjectChars:ve}),sse:_({clients:ve,initLogs:ve,heartbeatMs:ve}),imports:_({archiveBytes:ve,entries:ve,entryBytes:ve,uncompressedBytes:ve,expansionRatio:ve}),fanOut:_({providerModels:ve,providerModelMetadata:ve,providerTestConcurrency:ve,activeProviderTests:ve}),queues:_({proxyRequests:ve,finalizerJobs:ve,rawStreamMessages:ve,rawStreamBytes:ve,backgroundWorkers:ve})}).superRefine((e,t)=>{e.control.requestBytes>e.proxy.requestBytes&&t.addIssue({code:"custom",path:["control","requestBytes"],message:"control request budget must not exceed proxy request budget"}),e.control.responseBytes>e.proxy.responseBytes&&t.addIssue({code:"custom",path:["control","responseBytes"],message:"control response budget must not exceed proxy response budget"}),e.control.activeRequests>e.proxy.activeRequests&&t.addIssue({code:"custom",path:["control","activeRequests"],message:"control active request budget must not exceed proxy active request budget"}),e.upstream.fetchResponseBytes>e.proxy.responseBytes&&t.addIssue({code:"custom",path:["upstream","fetchResponseBytes"],message:"upstream fetch response budget must not exceed proxy response budget"}),e.upstream.replayResponseBytes>e.proxy.responseBytes&&t.addIssue({code:"custom",path:["upstream","replayResponseBytes"],message:"upstream replay response budget must not exceed proxy response budget"}),e.upstream.metadataResponseBytes>e.control.responseBytes&&t.addIssue({code:"custom",path:["upstream","metadataResponseBytes"],message:"upstream metadata response budget must not exceed control response budget"}),e.upstream.metadataDeadlineMs>e.control.deadlineMs&&t.addIssue({code:"custom",path:["upstream","metadataDeadlineMs"],message:"upstream metadata deadline must not exceed control deadline"}),e.queues.proxyRequests<e.proxy.activeRequests&&t.addIssue({code:"custom",path:["queues","proxyRequests"],message:"proxy request queue budget must cover active proxy requests"})});$b.parse({proxy:{requestBytes:64*1024*1024,responseBytes:256*1024*1024,headerBytes:64*1024,deadlineMs:12e4,idleTimeoutMs:3e4,activeRequests:ac},control:{requestBytes:8*1024*1024,responseBytes:64*1024*1024,headerBytes:32*1024,deadlineMs:3e4,idleTimeoutMs:1e4,activeRequests:8},upstream:{fetchResponseBytes:256*1024*1024,fetchDeadlineMs:12e4,replayResponseBytes:256*1024*1024,replayDeadlineMs:12e4,metadataResponseBytes:10*1024*1024,metadataDeadlineMs:3e4,connectTimeoutMs:1e4,idleTimeoutMs:3e4},pagination:{restPageSize:Ib,searchQueryChars:Pb,searchProjectChars:Lb},sse:{clients:Ob,initLogs:500,heartbeatMs:15e3},imports:{archiveBytes:64*1024*1024,entries:5e3,entryBytes:32*1024*1024,uncompressedBytes:256*1024*1024,expansionRatio:20},fanOut:{providerModels:bn,providerModelMetadata:Hu,providerTestConcurrency:zb,activeProviderTests:Db},queues:{proxyRequests:ac,finalizerJobs:1e3,rawStreamMessages:16384,rawStreamBytes:64*1024*1024,backgroundWorkers:4}});const Fb=me(["invalid-page-request","search-limit-exceeded","provider-model-limit-exceeded","sse-capacity-exceeded","provider-test-capacity-exceeded","proxy-capacity-exceeded"]),Bb=Vt([ae(400),ae(413),ae(429),ae(503)]);_({error:x().min(1).max(300),code:Fb,status:Bb,resource:x().min(1).max(80),limit:T().int().positive(),retryable:Ce()});function fo(){return x().refine(e=>{if(e.length===0)return!0;try{const t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}},"Must be a valid http(s) URL")}const sl=x().max(oi),Ub=V(sl).max(bn),qb=_({model:sl.min(1),contextWindow:T().int().positive().optional(),outputLimit:T().int().positive().optional(),source:me(["manual","registry"]).optional(),sourceUrl:x().optional(),updatedAt:x().optional()}),Hb=V(qb).max(Hu),Vb=_({id:x(),name:x(),apiKey:x(),model:sl.optional(),models:Ub.optional().default([]),format:me(["anthropic","openai"]).optional(),baseUrl:fo().optional(),anthropicBaseUrl:fo().optional(),openaiBaseUrl:fo().optional(),openaiResponsesBaseUrl:fo().optional(),authHeader:me(["bearer","x-api-key"]).optional().default("bearer"),apiDocsUrl:x().optional(),modelMetadataUrl:x().optional(),modelMetadata:Hb.optional(),source:me(["company","personal"]).optional(),createdAt:x(),updatedAt:x()}),Wb="configured",sr=Vb.extend({apiKey:ae(Wb)});async function Gb(e){return tt(e,sr.array(),void 0,t=>`Failed to fetch ${e}: ${t.status}`)}function ol(){const e=$t("/api/providers",Gb,{revalidateOnFocus:!1,revalidateIfStale:!1});return{providers:e.data??[],isLoading:e.isLoading,isError:e.error,mutate:e.mutate}}function ic(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Kb(...e){return t=>{let s=!1;const o=e.map(r=>{const a=ic(r,t);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():ic(e[r],null)}}}}function Ae(...e){return l.useCallback(Kb(...e),e)}function bs(e){const t=l.forwardRef((s,o)=>{let{children:r,...a}=s,i=null,c=!1;const d=[];lc(r)&&typeof ho=="function"&&(r=ho(r._payload)),l.Children.forEach(r,f=>{if(ev(f)){c=!0;const h=f;let g="child"in h.props?h.props.child:h.props.children;lc(g)&&typeof ho=="function"&&(g=ho(g._payload)),i=Xb(h,g),d.push(i?.props?.children)}else d.push(f)}),i?i=l.cloneElement(i,void 0,d):!c&&l.Children.count(r)===1&&l.isValidElement(r)&&(i=r);const m=i?Qb(i):void 0,u=Ae(o,m);if(!i){if(r||r===0)throw new Error(c?ov(e):sv(e));return r}const p=Zb(a,i.props??{});return i.type!==l.Fragment&&(p.ref=o?u:m),l.cloneElement(i,p)});return t.displayName=`${e}.Slot`,t}var Yb=bs("Slot"),Vu=Symbol.for("radix.slottable");function Jb(e){const t=s=>"child"in s?s.children(s.child):s.children;return t.displayName=`${e}.Slottable`,t.__radixId=Vu,t}var Xb=(e,t)=>{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(t)?t:null};function Zb(e,t){const s={...t};for(const o in t){const r=e[o],a=t[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 Qb(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,s=t&&"isReactWarning"in t&&t.isReactWarning;return s?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,s=t&&"isReactWarning"in t&&t.isReactWarning,s?e.props.ref:e.props.ref||e.ref)}function ev(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Vu}var tv=Symbol.for("react.lazy");function lc(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===tv&&"_payload"in e&&nv(e._payload)}function nv(e){return typeof e=="object"&&e!==null&&"then"in e}var sv=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,ov=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,ho=Nr[" use ".trim().toString()],rv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],be=rv.reduce((e,t)=>{const s=bs(`Primitive.${t}`),o=l.forwardRef((r,a)=>{const{asChild:i,...c}=r,d=i?s:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),n.jsx(d,{...c,ref:a})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{});function av(e,t){e&&Cs.flushSync(()=>e.dispatchEvent(t))}var Wu=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"}),iv="VisuallyHidden",Gu=l.forwardRef((e,t)=>n.jsx(be.span,{...e,ref:t,style:{...Wu,...e.style}}));Gu.displayName=iv;var lv=Gu;function on(e,t=[]){let s=[];function o(a,i){const c=l.createContext(i);c.displayName=a+"Context";const d=s.length;s=[...s,i];const m=p=>{const{scope:f,children:h,...g}=p,b=f?.[e]?.[d]||c,y=l.useMemo(()=>g,Object.values(g));return n.jsx(b.Provider,{value:y,children:h})};m.displayName=a+"Provider";function u(p,f,h={}){const{optional:g=!1}=h,b=f?.[e]?.[d]||c,y=l.useContext(b);if(y)return y;if(i!==void 0)return i;if(!g)throw new Error(`\`${p}\` 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,cv(r,...t)]}function cv(...e){const t=e[0];if(e.length===1)return t;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 p=d(a)[`__scope${m}`];return{...c,...p}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return s.scopeName=t.scopeName,s}function Ku(e){const t=e+"CollectionProvider",[s,o]=on(t),[r,a]=s(t,{collectionRef:{current:null},itemMap:new Map}),i=b=>{const{scope:y,children:w}=b,v=l.useRef(null),j=l.useRef(new Map).current;return n.jsx(r,{scope:y,itemMap:j,collectionRef:v,children:w})};i.displayName=t;const c=e+"CollectionSlot",d=bs(c),m=l.forwardRef((b,y)=>{const{scope:w,children:v}=b,j=a(c,w),S=Ae(y,j.collectionRef);return n.jsx(d,{ref:S,children:v})});m.displayName=c;const u=e+"CollectionItemSlot",p="data-radix-collection-item",f=bs(u),h=l.forwardRef((b,y)=>{const{scope:w,children:v,...j}=b,S=l.useRef(null),N=Ae(y,S),C=a(u,w);return l.useEffect(()=>(C.itemMap.set(S,{ref:S,...j}),()=>{C.itemMap.delete(S)})),n.jsx(f,{[p]:"",ref:N,children:v})});h.displayName=u;function g(b){const y=a(e+"CollectionConsumer",b);return l.useCallback(()=>{const v=y.collectionRef.current;if(!v)return[];const j=Array.from(v.querySelectorAll(`[${p}]`));return Array.from(y.itemMap.values()).sort((C,E)=>j.indexOf(C.ref.current)-j.indexOf(E.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:i,Slot:m,ItemSlot:h},g,o]}function ue(e,t,{checkForDefaultPrevented:s=!0}={}){return function(r){if(e?.(r),s===!1||!r||!r.defaultPrevented)return t?.(r)}}var Ve=globalThis?.document?l.useLayoutEffect:()=>{},dv=Nr[" useInsertionEffect ".trim().toString()]||Ve;function zn({prop:e,defaultProp:t,onChange:s=()=>{},caller:o}){const[r,a,i]=uv({defaultProp:t,onChange:s}),c=e!==void 0,d=c?e:r;{const u=l.useRef(e!==void 0);l.useEffect(()=>{const p=u.current;p!==c&&console.warn(`${o} is changing from ${p?"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 p=mv(u)?u(e):u;p!==e&&i.current?.(p)}else a(u)},[c,e,a,i]);return[d,m]}function uv({defaultProp:e,onChange:t}){const[s,o]=l.useState(e),r=l.useRef(s),a=l.useRef(t);return dv(()=>{a.current=t},[t]),l.useEffect(()=>{r.current!==s&&(a.current?.(s),r.current=s)},[s,r]),[s,o,a]}function mv(e){return typeof e=="function"}function pv(e,t){return l.useReducer((s,o)=>t[s][o]??s,e)}var bt=e=>{const{present:t,children:s}=e,o=fv(t),r=typeof s=="function"?s({present:o.isPresent}):l.Children.only(s),a=hv(o.ref,xv(r));return typeof s=="function"||o.isPresent?l.cloneElement(r,{ref:a}):null};bt.displayName="Presence";function fv(e){const[t,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]=pv(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??Ms(o.current),i.current=void 0):a.current="none"},[d]),Ve(()=>{const u=o.current,p=r.current;if(p!==e){const h=a.current,g=Ms(u);e?(i.current=g,m("MOUNT")):g==="none"||u?.display==="none"?m("UNMOUNT"):m(p&&h!==g?"ANIMATION_OUT":"UNMOUNT"),r.current=e}},[e,m]),Ve(()=>{if(t){let u;const p=t.ownerDocument.defaultView??window,f=g=>{const y=Ms(o.current).includes(CSS.escape(g.animationName));if(g.target===t&&y&&(m("ANIMATION_END"),!r.current)){const w=t.style.animationFillMode;t.style.animationFillMode="forwards",u=p.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=w)})}},h=g=>{g.target===t&&(a.current=Ms(o.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{p.clearTimeout(u),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else m("ANIMATION_END")},[t,m]),{isPresent:["mounted","unmountSuspended"].includes(d),ref:l.useCallback(u=>{if(u){const p=getComputedStyle(u);o.current=p,i.current=Ms(p)}else o.current=null;s(u)},[])}}function cc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function hv(...e){const t=l.useRef(e);return t.current=e,l.useCallback(s=>{const o=t.current;let r=!1;const a=o.map(i=>{const c=cc(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():cc(o[i],null)}}},[])}function Ms(e){return e?.animationName||"none"}function xv(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,s=t&&"isReactWarning"in t&&t.isReactWarning;return s?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,s=t&&"isReactWarning"in t&&t.isReactWarning,s?e.props.ref:e.props.ref||e.ref)}var gv=Nr[" useId ".trim().toString()]||(()=>{}),bv=0;function Ft(e){const[t,s]=l.useState(gv());return Ve(()=>{s(o=>o??String(bv++))},[e]),e||(t?`radix-${t}`:"")}var Tr="Collapsible",[vv]=on(Tr),[yv,rl]=vv(Tr),Yu=l.forwardRef((e,t)=>{const{__scopeCollapsible:s,open:o,defaultOpen:r,disabled:a,onOpenChange:i,...c}=e,[d,m]=zn({prop:o,defaultProp:r??!1,onChange:i,caller:Tr});return n.jsx(yv,{scope:s,disabled:a,contentId:Ft(),open:d,onOpenToggle:l.useCallback(()=>m(u=>!u),[m]),children:n.jsx(be.div,{"data-state":il(d),"data-disabled":a?"":void 0,...c,ref:t})})});Yu.displayName=Tr;var Ju="CollapsibleTrigger",Xu=l.forwardRef((e,t)=>{const{__scopeCollapsible:s,...o}=e,r=rl(Ju,s);return n.jsx(be.button,{type:"button","aria-controls":r.open?r.contentId:void 0,"aria-expanded":r.open||!1,"data-state":il(r.open),"data-disabled":r.disabled?"":void 0,disabled:r.disabled,...o,ref:t,onClick:ue(e.onClick,r.onOpenToggle)})});Xu.displayName=Ju;var al="CollapsibleContent",Zu=l.forwardRef((e,t)=>{const{forceMount:s,...o}=e,r=rl(al,e.__scopeCollapsible);return n.jsx(bt,{present:s||r.open,children:({present:a})=>n.jsx(wv,{...o,ref:t,present:a})})});Zu.displayName=al;var wv=l.forwardRef((e,t)=>{const{__scopeCollapsible:s,present:o,children:r,...a}=e,i=rl(al,s),[c,d]=l.useState(o),m=l.useRef(null),u=Ae(t,m),p=l.useRef(0),f=p.current,h=l.useRef(0),g=h.current,b=i.open||c,y=l.useRef(b),w=l.useRef(void 0);return l.useEffect(()=>{const v=requestAnimationFrame(()=>y.current=!1);return()=>cancelAnimationFrame(v)},[]),Ve(()=>{const v=m.current;if(v){w.current=w.current||{transitionDuration:v.style.transitionDuration,animationName:v.style.animationName},v.style.transitionDuration="0s",v.style.animationName="none";const j=v.getBoundingClientRect();p.current=j.height,h.current=j.width,y.current||(v.style.transitionDuration=w.current.transitionDuration,v.style.animationName=w.current.animationName),d(o)}},[i.open,o]),n.jsx(be.div,{"data-state":il(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!b,...a,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...e.style},children:b&&r})});function il(e){return e?"open":"closed"}var jv=Yu,Sv=l.createContext(void 0);function Er(e){const t=l.useContext(Sv);return e||t||"ltr"}function Ye(e){const t=l.useRef(e);return l.useEffect(()=>{t.current=e}),l.useMemo(()=>((...s)=>t.current?.(...s)),[])}var Nv="DismissableLayer",ri="dismissableLayer.update",Cv="dismissableLayer.pointerDownOutside",kv="dismissableLayer.focusOutside",dc,ll=l.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Rr=l.forwardRef((e,t)=>{const{disableOutsidePointerEvents:s=!1,deferPointerDownOutside:o=!1,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:c,onDismiss:d,...m}=e,u=l.useContext(ll),[p,f]=l.useState(null),h=p?.ownerDocument??globalThis?.document,[,g]=l.useState({}),b=Ae(t,f),y=Array.from(u.layers),[w]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),v=w?y.indexOf(w):-1,j=p?y.indexOf(p):-1,S=u.layersWithOutsidePointerEventsDisabled.size>0,N=j>=v,C=l.useRef(!1),E=Mv(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 M=[...u.branches].some(O=>O.contains(k));return N&&!M},[u.branches,N])}),A=Av(k=>{if(o&&C.current)return;const M=k.target;[...u.branches].some($=>$.contains(M))||(i?.(k),c?.(k),k.defaultPrevented||d?.())},h),I=p?j===y.length-1:!1,R=Ye(k=>{k.key==="Escape"&&(r?.(k),!k.defaultPrevented&&d&&(k.preventDefault(),d()))});return l.useEffect(()=>{if(I)return h.addEventListener("keydown",R,{capture:!0}),()=>h.removeEventListener("keydown",R,{capture:!0})},[h,I,R]),l.useEffect(()=>{if(p)return s&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(dc=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(p)),u.layers.add(p),uc(),()=>{s&&(u.layersWithOutsidePointerEventsDisabled.delete(p),u.layersWithOutsidePointerEventsDisabled.size===0&&(h.body.style.pointerEvents=dc))}},[p,h,s,u]),l.useEffect(()=>()=>{p&&(u.layers.delete(p),u.layersWithOutsidePointerEventsDisabled.delete(p),uc())},[p,u]),l.useEffect(()=>{const k=()=>g({});return document.addEventListener(ri,k),()=>document.removeEventListener(ri,k)},[]),n.jsx(be.div,{...m,ref:b,style:{pointerEvents:S?N?"auto":"none":void 0,...e.style},onFocusCapture:ue(e.onFocusCapture,A.onFocusCapture),onBlurCapture:ue(e.onBlurCapture,A.onBlurCapture),onPointerDownCapture:ue(e.onPointerDownCapture,E.onPointerDownCapture)})});Rr.displayName=Nv;var _v="DismissableLayerBranch",Tv=l.forwardRef((e,t)=>{const s=l.useContext(ll),o=l.useRef(null),r=Ae(t,o);return l.useEffect(()=>{const a=o.current;if(a)return s.branches.add(a),()=>{s.branches.delete(a)}},[s.branches]),n.jsx(be.div,{...e,ref:r})});Tv.displayName=_v;function Ev(){const e=l.useContext(ll),[t,s]=l.useState(null);return l.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),s}var Rv=()=>!0;function Mv(e,t){const{ownerDocument:s=globalThis?.document,deferPointerDownOutside:o=!1,isDeferredPointerDownOutsideRef:r,dismissableSurfaces:a,shouldHandlePointerDownOutside:i=Rv}=t,c=Ye(e),d=l.useRef(!1),m=l.useRef(!1),u=l.useRef(new Map),p=l.useRef(()=>{});return l.useEffect(()=>{function f(){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&&p.current()},0)}function b(j){m.current&&u.current.set(j.type,!1)}const y=j=>{if(j.target&&!d.current){let S=function(){s.removeEventListener("click",p.current);const C=h();f(),C||Qu(Cv,c,N,{discrete:!0})};if(!i(j.target)){s.removeEventListener("click",p.current),f(),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",p.current),p.current=S,s.addEventListener("click",p.current,{once:!0}))}else s.removeEventListener("click",p.current),f();d.current=!1},w=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const j of w)s.addEventListener(j,g,!0),s.addEventListener(j,b);const v=window.setTimeout(()=>{s.addEventListener("pointerdown",y)},0);return()=>{window.clearTimeout(v),s.removeEventListener("pointerdown",y),s.removeEventListener("click",p.current);for(const j of w)s.removeEventListener(j,g,!0),s.removeEventListener(j,b)}},[s,c,o,r,a,i]),{onPointerDownCapture:()=>d.current=!0}}function Av(e,t=globalThis?.document){const s=Ye(e),o=l.useRef(!1);return l.useEffect(()=>{const r=a=>{a.target&&!o.current&&Qu(kv,s,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",r),()=>t.removeEventListener("focusin",r)},[t,s]),{onFocusCapture:()=>o.current=!0,onBlurCapture:()=>o.current=!1}}function uc(){const e=new CustomEvent(ri);document.dispatchEvent(e)}function Qu(e,t,s,{discrete:o}){const r=s.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:s});t&&r.addEventListener(e,t,{once:!0}),o?av(r,a):r.dispatchEvent(a)}var da="focusScope.autoFocusOnMount",ua="focusScope.autoFocusOnUnmount",mc={bubbles:!1,cancelable:!0},Iv="FocusScope",cl=l.forwardRef((e,t)=>{const{loop:s=!1,trapped:o=!1,onMountAutoFocus:r,onUnmountAutoFocus:a,...i}=e,[c,d]=l.useState(null),m=Ye(r),u=Ye(a),p=l.useRef(null),f=Ae(t,d),h=l.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;l.useEffect(()=>{if(o){let b=function(j){if(h.paused||!c)return;const S=j.target;c.contains(S)?p.current=S:mn(p.current,{select:!0})},y=function(j){if(h.paused||!c)return;const S=j.relatedTarget;S!==null&&(c.contains(S)||mn(p.current,{select:!0}))},w=function(j){if(document.activeElement===document.body)for(const N of j)N.removedNodes.length>0&&mn(c)};document.addEventListener("focusin",b),document.addEventListener("focusout",y);const v=new MutationObserver(w);return c&&v.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",b),document.removeEventListener("focusout",y),v.disconnect()}}},[o,c,h.paused]),l.useEffect(()=>{if(c){fc.add(h);const b=document.activeElement;if(!c.contains(b)){const w=new CustomEvent(da,mc);c.addEventListener(da,m),c.dispatchEvent(w),w.defaultPrevented||(Pv($v(em(c)),{select:!0}),document.activeElement===b&&mn(c))}return()=>{c.removeEventListener(da,m),setTimeout(()=>{const w=new CustomEvent(ua,mc);c.addEventListener(ua,u),c.dispatchEvent(w),w.defaultPrevented||mn(b??document.body,{select:!0}),c.removeEventListener(ua,u),fc.remove(h)},0)}}},[c,m,u,h]);const g=l.useCallback(b=>{if(!s&&!o||h.paused)return;const y=b.key==="Tab"&&!b.altKey&&!b.ctrlKey&&!b.metaKey,w=document.activeElement;if(y&&w){const v=b.currentTarget,[j,S]=Lv(v);j&&S?!b.shiftKey&&w===S?(b.preventDefault(),s&&mn(j,{select:!0})):b.shiftKey&&w===j&&(b.preventDefault(),s&&mn(S,{select:!0})):w===v&&b.preventDefault()}},[s,o,h.paused]);return n.jsx(be.div,{tabIndex:-1,...i,ref:f,onKeyDown:g})});cl.displayName=Iv;function Pv(e,{select:t=!1}={}){const s=document.activeElement;for(const o of e)if(mn(o,{select:t}),document.activeElement!==s)return}function Lv(e){const t=em(e),s=pc(t,e),o=pc(t.reverse(),e);return[s,o]}function em(e){const t=[],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();)t.push(s.currentNode);return t}function pc(e,t){const s=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const o of e)if(!(s?!o.checkVisibility({checkVisibilityCSS:!0}):Ov(o,{upTo:t})))return o}function Ov(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Dv(e){return e instanceof HTMLInputElement&&"select"in e}function mn(e,{select:t=!1}={}){if(e&&e.focus){const s=document.activeElement;e.focus({preventScroll:!0}),e!==s&&Dv(e)&&t&&e.select()}}var fc=zv();function zv(){let e=[];return{add(t){const s=e[0];t!==s&&s?.pause(),e=hc(e,t),e.unshift(t)},remove(t){e=hc(e,t),e[0]?.resume()}}}function hc(e,t){const s=[...e],o=s.indexOf(t);return o!==-1&&s.splice(o,1),s}function $v(e){return e.filter(t=>t.tagName!=="A")}var Fv="Portal",Mr=l.forwardRef((e,t)=>{const{container:s,...o}=e,[r,a]=l.useState(!1);Ve(()=>a(!0),[]);const i=s||r&&globalThis?.document?.body;return i?Cs.createPortal(n.jsx(be.div,{...o,ref:t}),i):null});Mr.displayName=Fv;var xo=0,Yn=null;function tm(){l.useEffect(()=>{Yn||(Yn={start:xc(),end:xc()});const{start:e,end:t}=Yn;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),xo++,()=>{xo===1&&(Yn?.start.remove(),Yn?.end.remove(),Yn=null),xo=Math.max(0,xo-1)}},[])}function xc(){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 Dt=function(){return Dt=Object.assign||function(t){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)&&(t[a]=s[a])}return t},Dt.apply(this,arguments)};function nm(e,t){var s={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.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++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(s[o[r]]=e[o[r]]);return s}function Bv(e,t,s){if(s||arguments.length===2)for(var o=0,r=t.length,a;o<r;o++)(a||!(o in t))&&(a||(a=Array.prototype.slice.call(t,0,o)),a[o]=t[o]);return e.concat(a||Array.prototype.slice.call(t))}var Uo="right-scroll-bar-position",qo="width-before-scroll-bar",Uv="with-scroll-bars-hidden",qv="--removed-body-scroll-bar-size";function ma(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Hv(e,t){var s=l.useState(function(){return{value:e,callback:t,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=t,s.facade}var Vv=typeof window<"u"?l.useLayoutEffect:l.useEffect,gc=new WeakMap;function Wv(e,t){var s=Hv(null,function(o){return e.forEach(function(r){return ma(r,o)})});return Vv(function(){var o=gc.get(s);if(o){var r=new Set(o),a=new Set(e),i=s.current;r.forEach(function(c){a.has(c)||ma(c,null)}),a.forEach(function(c){r.has(c)||ma(c,i)})}gc.set(s,e)},[e]),s}function Gv(e){return e}function Kv(e,t){t===void 0&&(t=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=t(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 Yv(e){e===void 0&&(e={});var t=Kv(null);return t.options=Dt({async:!0,ssr:!1},e),t}var sm=function(e){var t=e.sideCar,s=nm(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var o=t.read();if(!o)throw new Error("Sidecar medium not found");return l.createElement(o,Dt({},s))};sm.isSideCarExport=!0;function Jv(e,t){return e.useMedium(t),sm}var om=Yv(),pa=function(){},Ar=l.forwardRef(function(e,t){var s=l.useRef(null),o=l.useState({onScrollCapture:pa,onWheelCapture:pa,onTouchMoveCapture:pa}),r=o[0],a=o[1],i=e.forwardProps,c=e.children,d=e.className,m=e.removeScrollBar,u=e.enabled,p=e.shards,f=e.sideCar,h=e.noRelative,g=e.noIsolation,b=e.inert,y=e.allowPinchZoom,w=e.as,v=w===void 0?"div":w,j=e.gapMode,S=nm(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),N=f,C=Wv([s,t]),E=Dt(Dt({},S),r);return l.createElement(l.Fragment,null,u&&l.createElement(N,{sideCar:om,removeScrollBar:m,shards:p,noRelative:h,noIsolation:g,inert:b,setCallbacks:a,allowPinchZoom:!!y,lockRef:s,gapMode:j}),i?l.cloneElement(l.Children.only(c),Dt(Dt({},E),{ref:C})):l.createElement(v,Dt({},E,{className:d,ref:C}),c))});Ar.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Ar.classNames={fullWidth:qo,zeroRight:Uo};var Xv=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Zv(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Xv();return t&&e.setAttribute("nonce",t),e}function Qv(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function e2(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var t2=function(){var e=0,t=null;return{add:function(s){e==0&&(t=Zv())&&(Qv(t,s),e2(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},n2=function(){var e=t2();return function(t,s){l.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&s])}},rm=function(){var e=n2(),t=function(s){var o=s.styles,r=s.dynamic;return e(o,r),null};return t},s2={left:0,top:0,right:0,gap:0},fa=function(e){return parseInt(e||"",10)||0},o2=function(e){var t=window.getComputedStyle(document.body),s=t[e==="padding"?"paddingLeft":"marginLeft"],o=t[e==="padding"?"paddingTop":"marginTop"],r=t[e==="padding"?"paddingRight":"marginRight"];return[fa(s),fa(o),fa(r)]},r2=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return s2;var t=o2(e),s=document.documentElement.clientWidth,o=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,o-s+t[2]-t[0])}},a2=rm(),us="data-scroll-locked",i2=function(e,t,s,o){var r=e.left,a=e.top,i=e.right,c=e.gap;return s===void 0&&(s="margin"),`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./jszip.min-D5ch91g-.js","./index-OquTzqLZ.js","./index-B-Qod-aA.css","./CompareDrawer-B6l7sK_o.js","./InspectorPet-Dv-hDdxU.js","./ReplayDialog-BACtWGKs.js","./ResponseView-CwqmhaXg.js","./RequestAnatomy-DqG3yRes.js","./StreamingChunkSequence-DMdSkso8.js","./json-viewer-DIr-vdVp.js","./index-Dt0cOy7U.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{l as Wh,u as Vt,s as x,n as T,b as Ce,_ as Yo,a as V,c as qe,o as _,d as me,e as ae,f as Cn,g as Fs,h as $t,i as nu,k as tt,r as l,j as n,m as Wt,p as On,A as Zl,q as Gh,t as oa,v as Nr,w as Cs,x as P,B as te,y as Un,z as su,C as Ie,D as ou,E as yt,F as Li,G as Kh,H as Be,L as Jo,I as ru,J as Yh,K as Xo,M as Jh,N as Xh,O as Zh,P as au,Q as Oi,T as Qh,U as ex}from"./index-OquTzqLZ.js";const Je=Wh(()=>Vt([x(),T(),Ce(),Yo(),V(Je),qe(x(),Je)])),Mt=T().int().nonnegative().max(Number.MAX_SAFE_INTEGER),tx=me(["capacity-exceeded","pipeline-closed","write-failed","finalize-failed","finalize-timeout","upstream-stream-error","shutdown"]),iu=_({index:T(),timestamp:T(),type:x(),data:Je}),nx=_({id:x(),logId:Mt,index:T().int().nonnegative(),provider:me(["anthropic","openai"]),name:x(),argumentsText:x().nullable(),argumentsPreview:x().nullable()}),sx=me(["end_turn","tool_use","stop","length"]),ox=sx.nullable(),rx=_({chunks:V(iu),truncated:Ce().optional().default(!1)}),ax=me(["request","response"]),lu=_({logId:Mt,part:ax,text:x(),offset:T().int().nonnegative(),limit:T().int().positive(),totalBytes:T().int().nonnegative(),textBytes:T().int().nonnegative(),nextOffset:T().int().nonnegative().nullable(),hasMore:Ce(),contentMode:me(["empty","partial","full"])}),Hs=_({id:Mt,timestamp:x(),method:x(),path:x(),model:x().nullable(),sessionId:x().nullable(),rawRequestBody:x().nullable(),responseStatus:T().nullable(),responseText:x().nullable(),inputTokens:T().nullable(),outputTokens:T().nullable(),cacheCreationInputTokens:T().nullable(),cacheReadInputTokens:T().nullable(),elapsedMs:T().nullable(),firstChunkMs:T().nullable().optional(),totalStreamMs:T().nullable().optional(),tokensPerSecond:T().nullable().optional(),streaming:Ce(),userAgent:x().nullable(),origin:x().nullable(),rawHeaders:qe(x(),x()).optional(),headers:qe(x(),x()).optional(),apiFormat:me(["anthropic","openai","unknown"]).default("unknown"),isTest:Ce().optional().default(!1),replayOfLogId:Mt.nullable().optional(),providerName:x().nullable().optional(),clientPort:T().nullable().optional(),clientPid:T().nullable().optional(),clientCwd:x().nullable().optional(),clientProjectFolder:x().nullable().optional(),streamingChunks:rx.optional(),streamingChunksPath:x().nullable().optional(),rawRequestBodyBytes:T().int().nonnegative().nullable().optional(),responseTextBytes:T().int().nonnegative().nullable().optional(),bodyContentMode:me(["full","compact","truncated"]).optional(),captureIncomplete:Ce().optional(),droppedChunks:T().int().nonnegative().optional(),droppedBytes:T().int().nonnegative().optional(),captureIncompleteReason:tx.nullable().optional(),warnings:V(x()).optional(),toolTraceEvents:V(nx).optional(),stopReason:ox.optional(),error:x().nullable().optional()}),Di=_({type:x(),ttl:x().optional(),scope:x().optional()}),zi=_({type:ae("text"),text:x(),cache_control:Di.optional()}),cu=_({type:ae("thinking"),thinking:x(),signature:x().optional()}),ix=_({type:ae("think"),thinking:x(),signature:x().optional()}),lx=_({type:ae("base64"),media_type:x(),data:x()}),du=_({type:ae("image"),source:lx}),uu=_({type:ae("tool_use"),id:x(),name:x(),input:qe(x(),Je)}),cx=Cn("type",[zi,du]),dx=_({type:ae("tool_result"),tool_use_id:x().optional(),content:Vt([x(),V(cx)]),is_error:Ce().optional()}),ux=Cn("type",[zi,cu,du,uu,dx]),mx=Vt([x(),V(ux)]),px=_({role:me(["user","assistant"]),content:mx}),fx=_({type:ae("text"),text:x(),cache_control:Di.optional()}),hx=_({type:x(),properties:qe(x(),qe(x(),Je)).optional(),required:V(x()).optional(),additionalProperties:Ce().optional(),$schema:x().optional()}),xx=_({name:x(),description:x().optional(),input_schema:hx.optional(),cache_control:Di.optional()}),gx=Cn("type",[_({type:ae("enabled"),budget_tokens:T()}),_({type:ae("disabled")}),_({type:ae("adaptive")})]),bx=_({model:x(),messages:V(px),system:V(fx).optional(),tools:V(xx).optional(),max_tokens:T().optional(),temperature:T().optional(),stream:Ce().optional(),thinking:gx.optional(),metadata:_({user_id:x().optional()}).optional()}),$i=Cn("type",[zi,cu,ix,uu]),vx=_({input_tokens:T().nullable().optional(),output_tokens:T().nullable().optional(),cache_creation_input_tokens:T().nullable().optional(),cache_read_input_tokens:T().nullable().optional()}).passthrough(),yx=_({id:x(),type:ae("message"),model:x(),role:ae("assistant"),content:V($i),stop_reason:x().nullable(),stop_sequence:x().nullable().optional(),usage:vx}).passthrough(),wx=_({type:ae("message_start"),message:_({id:x(),type:ae("message"),model:x(),role:ae("assistant"),content:V($i),stop_reason:Yo(),stop_sequence:Yo(),usage:_({input_tokens:T(),cache_creation_input_tokens:T().optional(),cache_read_input_tokens:T().optional()}).passthrough()})}),jx=_({type:ae("content_block_start"),index:T(),content_block:$i}),Sx=Cn("type",[_({type:ae("text_delta"),text:x()}),_({type:ae("input_json_delta"),partial_json:x()}),_({type:ae("thinking_delta"),thinking:x()}),_({type:ae("signature_delta"),signature:x()})]),Nx=_({type:ae("content_block_delta"),index:T(),delta:Sx}),Cx=_({type:ae("content_block_stop"),index:T()}),kx=_({type:ae("message_delta"),delta:_({stop_reason:x().nullable(),stop_sequence:x().nullable().optional()}),usage:_({output_tokens:T(),input_tokens:T().optional(),cache_creation_input_tokens:T().optional(),cache_read_input_tokens:T().optional()}).passthrough()}),_x=_({type:ae("message_stop")}),Tx=_({type:ae("ping")}),Ex=_({type:ae("error"),error:_({type:x(),message:x()})});Cn("type",[wx,jx,Nx,Cx,kx,_x,Tx,Ex]);const Rx=Vt([x(),V(Cn("type",[_({type:ae("text"),text:x()}),_({type:ae("image_url"),image_url:_({url:x(),detail:x().optional()})})]))]),mu=_({role:me(["system","user","assistant","tool"]),content:Rx,name:x().optional(),reasoning_content:x().optional(),thinking:x().optional(),think:x().optional()}),Mx=_({name:x(),arguments:x()}),pu=_({index:T().optional(),id:x().optional(),type:ae("function").optional(),function:_({name:x().optional(),arguments:x().optional()})});mu.extend({content:Vt([x(),V(_({type:ae("text"),text:x()}))]).optional(),function_call:Mx.optional(),tool_calls:V(pu).optional()});const Ax=_({type:ae("function"),function:_({name:x(),description:x().optional(),parameters:qe(x(),Je)})}),Ix=_({model:x(),messages:V(mu),temperature:T().optional(),max_tokens:T().optional(),stream:Ce().optional(),tools:V(Ax).optional(),tool_choice:Vt([me(["auto","none","required"]),_({type:ae("auto")}),_({type:ae("none")}),_({type:ae("function"),function:_({name:x()})})]).optional(),user:x().optional()}),Px=_({type:x(),name:x().optional(),description:x().optional(),parameters:Je.optional(),function:_({name:x().optional(),description:x().optional(),parameters:Je.optional()}).optional()}).passthrough(),Lx=_({model:x(),input:Fs().optional(),instructions:Vt([x(),Yo()]).optional(),stream:Ce().optional(),tools:V(Px).optional(),tool_choice:Fs().optional(),max_output_tokens:T().optional(),temperature:T().optional(),user:x().optional(),metadata:qe(x(),Fs()).optional()}).passthrough(),fu=_({role:me(["assistant"]).optional(),content:x().nullable().optional(),reasoning_content:x().nullable().optional(),thinking:x().nullable().optional(),think:x().nullable().optional(),function_call:_({name:x().optional(),arguments:x().optional()}).nullable().optional(),tool_calls:V(_({index:T(),id:x().optional(),type:ae("function").optional(),function:_({name:x().optional(),arguments:x().optional()})})).nullable().optional()}),Ox=_({index:T(),message:_({role:me(["assistant"]),content:x().nullable(),reasoning_content:x().optional(),thinking:x().optional(),think:x().optional(),function_call:_({name:x(),arguments:x()}).nullable().optional(),tool_calls:V(pu).optional()}).optional(),delta:fu.optional(),finish_reason:x().nullable()}),Dx=_({id:x(),object:ae("chat.completion"),created:T(),model:x(),choices:V(Ox),usage:_({prompt_tokens:T().nullable().optional(),completion_tokens:T().nullable().optional(),total_tokens:T().nullable().optional()}).passthrough(),service_tier:x().nullable().optional(),system_fingerprint:x().nullable().optional()}).passthrough();_({id:x(),object:ae("chat.completion.chunk"),created:T(),model:x(),choices:V(_({index:T(),delta:fu,finish_reason:x().nullable().optional()})),usage:_({prompt_tokens:T().nullable().optional(),completion_tokens:T().nullable().optional(),total_tokens:T().nullable().optional()}).passthrough().nullable().optional()}).passthrough();const zx=_({input_tokens:T().nullable().optional(),output_tokens:T().nullable().optional(),total_tokens:T().nullable().optional(),input_tokens_details:_({cached_tokens:T().nullable().optional()}).passthrough().nullable().optional(),output_tokens_details:_({reasoning_tokens:T().nullable().optional()}).passthrough().nullable().optional()}).passthrough(),$x=_({type:x()}).passthrough(),Fx=_({id:x(),object:ae("response").optional(),created_at:T().optional(),status:x().nullable().optional(),model:x().optional(),output:V($x).optional(),output_text:x().optional(),usage:zx.nullable().optional(),error:Fs().optional()}).passthrough();_({type:x()}).passthrough();function Bx(e){try{const t=JSON.parse(e),s=Dx.safeParse(t);return s.success?s.data:null}catch{return null}}function Ux(e){try{const t=JSON.parse(e),s=Fx.safeParse(t);return s.success?s.data:null}catch{return null}}const hu=_({input:T().int().nonnegative(),output:T().int().nonnegative(),cacheCreate:T().int().nonnegative(),cacheRead:T().int().nonnegative(),total:T().int().nonnegative()}),qx=_({id:Mt,sessionLogNumber:T().int().positive().optional(),timestamp:x(),provider:x().nullable(),model:x().nullable(),apiFormat:me(["anthropic","openai","unknown"]),method:x(),path:x(),status:T().nullable(),isStreaming:Ce(),hasError:Ce(),error:x().nullable(),latencyMs:T().nullable(),firstChunkMs:T().nullable().optional(),totalStreamMs:T().nullable().optional(),tokensPerSecond:T().nullable().optional(),tokens:_({input:T().nullable(),output:T().nullable(),cacheCreate:T().nullable(),cacheRead:T().nullable()}),sessionId:x().nullable(),userAgent:x().nullable().optional(),clientPid:T().nullable().optional(),clientProjectFolder:x().nullable().optional()}),xu=_({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:T().int().nonnegative(),activeRequests:T().int().nonnegative(),completedRequests:T().int().nonnegative(),failedRequests:T().int().nonnegative(),queuedTasks:T().int().nonnegative(),runningTasks:T().int().nonnegative(),lastTaskError:x().nullable(),logCount:T().int().nonnegative(),errorCount:T().int().nonnegative(),models:V(x()),providers:V(x()),tokenUsage:hu,lastLogId:Mt.nullable(),lastModel:x().nullable(),clientUserAgent:x().nullable().optional(),clientPid:T().nullable(),clientProjectFolder:x().nullable(),inspectorPath:x(),inspectorUrl:x(),apiPath:x(),apiUrl:x(),compactLogsPath:x(),compactLogsUrl:x(),latestLogLimit:T().int().positive(),latestLogs:V(qx)}),Qs=me(["created","running","completed","failed","cancelled"]),Fi=_({jsonPath:x(),markdownPath:x(),htmlPath:x(),exportedAt:x()}),Hx=me(["run-created","session-started","request","session-finished","evidence-exported"]),Vx=me(["info","success","warning","error"]),Wx=_({timestamp:x(),kind:Hx,severity:Vx,title:x(),details:x(),logId:Mt.nullable(),status:T().nullable(),model:x().nullable(),provider:x().nullable(),latencyMs:T().nullable(),isStreaming:Ce().nullable()}),Gx=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"]),gu=_({outcome:me(["success","failure","active","unknown"]),severity:me(["none","low","medium","high"]),category:Gx,summary:x(),evidenceLogIds:V(Mt),hints:V(x())}),Bi=_({status:me(["PASS","FAIL","RUNNING","UNKNOWN"]),summary:x(),markdown:x()}),bu=Bi,Ui=_({id:x(),sessionId:x(),groupId:x().nullable().default(null),title:x(),task:x().nullable(),project:x().nullable(),agent:x().nullable(),status:Qs,tags:V(x()),metadata:qe(x(),Je),evidence:Fi.nullable(),createdAt:x(),updatedAt:x()});_({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:Qs.optional(),tags:V(x()).optional(),metadata:qe(x(),Je).optional()}).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:Qs.optional(),tags:V(x()).optional(),metadata:qe(x(),Je).optional()});_({includeHistory:Ce().optional(),latestLogLimit:T().int().positive().max(50).optional()}).optional();_({run:Ui,evidence:Fi,session:xu.nullable(),timeline:V(Wx),classification:gu,jenkinsReport:Bi});const Kx=_({run:Ui,classification:gu,evidence:Fi.nullable(),jenkinsReport:Bi.nullable(),sessionId:x(),inspectorUrl:x().nullable(),evidenceMarkdownPath:x().nullable(),updatedAt:x()});_({failures:V(Kx),total:T().int().nonnegative(),limit:T().int().positive()});const qi=me(["created","running","completed","failed","cancelled"]),Hi=me(["evaluation","batch","manual"]),Vi=_({jsonPath:x(),markdownPath:x(),htmlPath:x(),exportedAt:x()}),vu=_({id:x(),groupId:x(),sessionId:x(),runId:x().nullable(),label:x().nullable(),agent:x().nullable(),provider:x().nullable(),model:x().nullable(),status:Qs.nullable(),metadata:qe(x(),Je),addedAt:x(),updatedAt:x()}),Wi=_({id:x(),title:x(),kind:Hi,task:x().nullable(),project:x().nullable(),status:qi,tags:V(x()),metadata:qe(x(),Je),evidence:Vi.nullable(),members:V(vu),createdAt:x(),updatedAt:x()});_({groupId:x().min(1).optional(),title:x().min(1).optional(),kind:Hi.optional(),task:x().nullable().optional(),project:x().nullable().optional(),status:qi.optional(),tags:V(x()).optional(),metadata:qe(x(),Je).optional()}).optional();_({title:x().min(1).optional(),kind:Hi.optional(),task:x().nullable().optional(),project:x().nullable().optional(),status:qi.optional(),tags:V(x()).optional(),metadata:qe(x(),Je).optional()});_({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:Qs.nullable().optional(),metadata:qe(x(),Je).optional()});_({includeHistory:Ce().optional(),latestLogLimit:T().int().positive().max(50).optional()}).optional();_({deleteEvidence:Ce().optional()});const yu=_({groupId:x(),deleted:Ce(),evidenceDeleted:Ce(),evidencePath:x().nullable()}),wu=_({deleted:T().int().nonnegative(),groups:V(yu)}),ju=_({member:vu,run:Ui.nullable(),session:xu.nullable()}),Su=_({memberCount:T().int().nonnegative(),sessionsWithData:T().int().nonnegative(),missingSessions:T().int().nonnegative(),requestCount:T().int().nonnegative(),errorCount:T().int().nonnegative(),tokenUsage:hu,models:V(x()),providers:V(x()),completedMembers:T().int().nonnegative(),failedMembers:T().int().nonnegative(),runningMembers:T().int().nonnegative()}),Yx=_({group:Wi,evidence:Vi,members:V(ju).nullable(),markdown:x(),summary:Su.nullable(),report:bu.nullable()}),Jx=_({group:Wi,evidence:Vi,members:V(ju),summary:Su,jenkinsReport:bu}),Nu=_({groups:V(Wi)}),Xx=_({sessionId:x(),imported:T().int().nonnegative(),skipped:T().int().nonnegative(),warnings:V(x()),logs:V(Hs)}),Zo=10,Xa=600,Qo=60,Za=600,er="time",Gi="simple",Cu=me(["time","full"]),Zx=me(["simple","full"]),Cr=_({stripClaudeCodeBillingHeader:Ce(),hasSeenOnboarding:Ce().default(!1),slowResponseThresholdSeconds:T().int().min(0).max(Xa).default(Zo),providerTestTimeoutSeconds:T().int().min(1).max(Za).default(Qo),timeDisplayFormat:Cu.default(er),captureMode:Zx.default(Gi)}),as="/api/config";async function Qx(e){return tt(e,Cr,void 0,t=>`Failed to fetch ${e}: ${t.status}`)}async function mo(e){return tt(as,Cr,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e)},t=>`PATCH failed with status ${t.status}`)}function Ki(){const e=$t(as,Qx,{revalidateOnFocus:!1,revalidateIfStale:!1}),{mutate:t}=nu(),s=e.data?.stripClaudeCodeBillingHeader??!1,o=e.data?.captureMode??Gi,r=e.data?.slowResponseThresholdSeconds??Zo,a=e.data?.providerTestTimeoutSeconds??Qo,i=e.data?.timeDisplayFormat??er,c=f=>({stripClaudeCodeBillingHeader:e.data?.stripClaudeCodeBillingHeader??!1,hasSeenOnboarding:e.data?.hasSeenOnboarding??!1,slowResponseThresholdSeconds:e.data?.slowResponseThresholdSeconds??Zo,providerTestTimeoutSeconds:e.data?.providerTestTimeoutSeconds??Qo,timeDisplayFormat:e.data?.timeDisplayFormat??er,captureMode:o,...f}),d=async f=>{await t(as,mo({stripClaudeCodeBillingHeader:f}),{optimisticData:c({stripClaudeCodeBillingHeader:f}),rollbackOnError:!0,revalidate:!1})},m=async f=>{await t(as,mo({slowResponseThresholdSeconds:f}),{optimisticData:c({slowResponseThresholdSeconds:f}),rollbackOnError:!0,revalidate:!1})},u=async f=>{await t(as,mo({timeDisplayFormat:f}),{optimisticData:c({timeDisplayFormat:f}),rollbackOnError:!0,revalidate:!1})},p=async f=>{await t(as,mo({providerTestTimeoutSeconds:f}),{optimisticData:c({providerTestTimeoutSeconds:f}),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:p,setTimeDisplayFormat:u}}const ku=(...e)=>e.filter((t,s,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===s).join(" ").trim();const e0=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const t0=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,s,o)=>o?o.toUpperCase():s.toLowerCase());const Ql=e=>{const t=t0(e);return t.charAt(0).toUpperCase()+t.slice(1)};var n0={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 s0=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};const o0=l.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:s=2,absoluteStrokeWidth:o,className:r="",children:a,iconNode:i,...c},d)=>l.createElement("svg",{ref:d,...n0,width:t,height:t,stroke:e,strokeWidth:o?Number(s)*24/Number(t):s,className:ku("lucide",r),...!a&&!s0(c)&&{"aria-hidden":"true"},...c},[...i.map(([m,u])=>l.createElement(m,u)),...Array.isArray(a)?a:[a]]));const B=(e,t)=>{const s=l.forwardRef(({className:o,...r},a)=>l.createElement(o0,{ref:a,iconNode:t,className:ku(`lucide-${e0(Ql(e))}`,`lucide-${e}`,o),...r}));return s.displayName=Ql(e),s};const r0=[["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"}]],a0=B("a-large-small",r0);const i0=[["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"}]],l0=B("activity",i0);const c0=[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]],d0=B("arrow-down-right",c0);const u0=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],m0=B("arrow-down",u0);const p0=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],f0=B("arrow-left",p0);const h0=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],x0=B("arrow-up-right",h0);const g0=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],b0=B("arrow-up",g0);const v0=[["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"}]],Yi=B("beaker",v0);const y0=[["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"}]],w0=B("bell",y0);const j0=[["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"}]],S0=B("blocks",j0);const N0=[["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"}]],C0=B("brain-circuit",N0);const k0=[["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"}]],_u=B("brain",k0);const _0=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],$e=B("check",_0);const T0=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Xe=B("chevron-down",T0);const E0=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],R0=B("chevron-left",E0);const M0=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],gt=B("chevron-right",M0);const A0=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Ji=B("chevron-up",A0);const I0=[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]],P0=B("chevrons-down",I0);const L0=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],O0=B("chevrons-left",L0);const D0=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],z0=B("chevrons-right",D0);const $0=[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]],F0=B("chevrons-up",$0);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"}]],gs=B("circle-alert",B0);const U0=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],eo=B("circle-check-big",U0);const q0=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Qa=B("circle-check",q0);const H0=[["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"}]],V0=B("circle-question-mark",H0);const W0=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],G0=B("circle-stop",W0);const K0=[["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"}]],Tu=B("circle-x",K0);const Y0=[["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"}]],J0=B("clapperboard",Y0);const X0=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Z0=B("clock-3",X0);const Q0=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],en=B("clock",Q0);const eg=[["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"}]],tg=B("cloud-upload",eg);const ng=[["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"}]],Eu=B("code-xml",ng);const sg=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],og=B("columns-2",sg);const rg=[["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"}]],jt=B("copy",rg);const ag=[["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"}]],ig=B("cpu",ag);const lg=[["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"}]],to=B("download",lg);const cg=[["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"}]],dg=B("ellipsis",cg);const ug=[["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"}]],Xi=B("external-link",ug);const mg=[["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"}]],pg=B("eye-off",mg);const fg=[["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"}]],Ru=B("eye",fg);const hg=[["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"}]],xg=B("file-braces",hg);const gg=[["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"}]],bg=B("file-diff",gg);const vg=[["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"}]],yg=B("file-search",vg);const wg=[["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"}]],jg=B("file-terminal",wg);const Sg=[["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"}]],Ng=B("file-text",Sg);const Cg=[["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"}]],kg=B("flag",Cg);const _g=[["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"}]],Mu=B("flask-conical",_g);const Tg=[["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"}]],Eg=B("folder-open",Tg);const Rg=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Zi=B("gauge",Rg);const Mg=[["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"}]],Ag=B("git-compare-arrows",Mg);const Ig=[["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"}]],Au=B("globe",Ig);const Pg=[["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"}]],Iu=B("history",Pg);const Lg=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Og=B("info",Lg);const Dg=[["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"}]],ec=B("layers",Dg);const zg=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Ue=B("loader-circle",zg);const $g=[["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"}]],Fg=B("lock",$g);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"}]],Ug=B("maximize-2",Bg);const qg=[["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"}]],kr=B("message-square",qg);const Hg=[["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"}]],Vg=B("minimize-2",Hg);const Wg=[["path",{d:"M5 12h14",key:"1ays0h"}]],Pu=B("minus",Wg);const Gg=[["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"}]],Kg=B("monitor",Gg);const Yg=[["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"}]],Jg=B("moon",Yg);const Xg=[["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"}]],Zg=B("mouse-pointer-click",Xg);const Qg=[["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"}]],e1=B("network",Qg);const t1=[["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"}]],n1=B("octagon-alert",t1);const s1=[["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"}]],o1=B("package-check",s1);const r1=[["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"}]],a1=B("panel-right-close",r1);const i1=[["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"}]],l1=B("panel-right-open",i1);const c1=[["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"}]],Lu=B("pencil",c1);const d1=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],tc=B("plus",d1);const u1=[["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"}]],nc=B("radio",u1);const m1=[["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"}]],Rt=B("refresh-cw",m1);const p1=[["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"}]],Ou=B("rocket",p1);const f1=[["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"}]],Du=B("rotate-ccw",f1);const h1=[["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"}]],tr=B("rotate-cw",h1);const x1=[["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"}]],g1=B("rows-3",x1);const b1=[["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"}]],v1=B("save",b1);const y1=[["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"}]],w1=B("scan",y1);const j1=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],S1=B("search",j1);const N1=[["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"}]],C1=B("send",N1);const k1=[["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"}]],_1=B("server",k1);const T1=[["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"}]],E1=B("settings",T1);const R1=[["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"}]],M1=B("shield-alert",R1);const A1=[["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"}]],sc=B("shield-check",A1);const I1=[["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"}]],nr=B("siren",I1);const P1=[["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"}]],ei=B("sparkles",P1);const L1=[["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"}]],O1=B("sun",L1);const D1=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],qn=B("terminal",D1);const z1=[["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"}]],zu=B("timer",z1);const $1=[["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"}]],wn=B("trash-2",$1);const F1=[["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"}]],bn=B("triangle-alert",F1);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"}]],$u=B("upload",B1);const U1=[["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"}]],q1=B("wifi-off",U1);const H1=[["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"}]],V1=B("wifi",H1);const W1=[["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"}]],no=B("wrench",W1);const G1=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],so=B("x",G1);const K1=[["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"}]],Vs=B("zap",K1),ti="/api/config";async function Y1(e){return tt(e,Cr,void 0,t=>`Failed to fetch ${e}: ${t.status}`)}async function J1(e){return tt(ti,Cr,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e)},t=>`PATCH failed with status ${t.status}`)}function X1(){const e=$t(ti,Y1,{revalidateOnFocus:!1,revalidateIfStale:!1}),{mutate:t}=nu(),s=e.data?.hasSeenOnboarding??!1,o=e.data?.captureMode??Gi,r=async()=>{await t(ti,J1({hasSeenOnboarding:!0}),{optimisticData:{stripClaudeCodeBillingHeader:e.data?.stripClaudeCodeBillingHeader??!1,hasSeenOnboarding:!0,slowResponseThresholdSeconds:e.data?.slowResponseThresholdSeconds??Zo,providerTestTimeoutSeconds:e.data?.providerTestTimeoutSeconds??Qo,timeDisplayFormat:e.data?.timeDisplayFormat??er,captureMode:o},rollbackOnError:!0,revalidate:!1})};return{hasSeenOnboarding:s,captureMode:o,isLoading:e.isLoading,markSeen:r}}function Z1({isLoading:e,hasSeenOnboarding:t,dismissedInView:s}){return!e&&!t&&!s}function Q1({expanded:e,onToggle:t,onDismiss:s}){const o=e?"grid":"hidden sm:grid";return n.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:n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx(Og,{className:"mt-0.5 size-4 shrink-0 text-warning","aria-hidden":"true"}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[n.jsx("span",{className:"font-medium text-foreground",children:"Inspector ready"}),n.jsx("span",{className:"hidden truncate text-xs text-muted-foreground sm:inline",children:"Request, response, tool, timing, token, replay, and memory signals are active."})]}),n.jsx("div",{className:"mt-1 text-xs leading-relaxed text-muted-foreground sm:hidden",children:"Core capture is active."}),n.jsxs("div",{className:`${o} mt-2 gap-x-4 gap-y-1 text-xs leading-relaxed text-muted-foreground sm:grid-cols-2`,children:[n.jsxs("div",{children:[n.jsx("strong",{children:"Evidence"}),": logs, sessions, groups, and MCP exports are available."]}),n.jsxs("div",{children:[n.jsx("strong",{children:"Network"}),": replace ",n.jsx("code",{children:"localhost"})," if containers differ."]})]})]}),n.jsx("button",{type:"button",onClick:t,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:n.jsx(Xe,{className:`size-3.5 transition-transform ${e?"rotate-180":""}`})}),n.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:[n.jsx($e,{className:"size-3.5"}),"Got it"]}),n.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:n.jsx(so,{className:"size-3.5"})})]})})}function eb(){const{hasSeenOnboarding:e,isLoading:t,markSeen:s}=X1(),[o,r]=l.useState(!1),[a,i]=l.useState(!1);return Z1({isLoading:t,hasSeenOnboarding:e,dismissedInView:a})?n.jsx(Q1,{expanded:o,onToggle:()=>r(c=>!c),onDismiss:()=>{i(!0),s().catch(()=>{})}}):null}const tb="4.0.13",Fu={version:tb};function is(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Bu="[REDACTED]",nb=/(^|[-_])(api[-_]?key|authorization|cookie|token|secret|password|access[-_]?token|refresh[-_]?token)([-_]|$)/i,sb=[/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],oc=200,ob=25e6,Uu=50,rb=1e4,ab=1024*1024,ib=64,lb=1e4;function cb(e){return e<1024?`${e} chars`:e<1024*1024?`${Math.ceil(e/1024)} KB`:`${Math.ceil(e/(1024*1024))} MB`}function db(e){let t=0;for(const s of e)t+=s.rawRequestBody?.length??s.rawRequestBodyBytes??0,t+=s.responseText?.length??s.responseTextBytes??0;return t}function ub(e){if(e.length>oc)return`Export is limited to ${oc} logs at once. Narrow the filter and try again.`;const t=db(e);return t>ob?`Export is too large (${cb(t)} of text). Narrow the filter and try again.`:null}function po(e){return e?.aborted===!0?{ok:!1,message:"Export canceled.",canceled:!0}:null}async function mb(e,t){try{const s=await On(`/api/logs/${e}/chunks`,rb,{signal:t});if(!s.ok)return null;const o=await s.json();return JSON.stringify(o,null,2)}catch{return null}}function pb(e,t){switch(t){case"request":return e.rawRequestBody;case"response":return e.responseText}}async function rc(e,t,s){const o=pb(e,t);if(o!==null)return o;let r=0,a="";for(let i=0;i<ib;i+=1){const c=new URLSearchParams({part:t,offset:String(r),limit:String(ab)});try{const d=await On(`/api/logs/${String(e.id)}/body?${c.toString()}`,lb,{signal:s});if(!d.ok)return a.length>0?a:null;const m=await d.json(),u=lu.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 ni(e){if(Array.isArray(e))return e.map(s=>ni(s));if(!is(e))return e;const t={};for(const[s,o]of Object.entries(e))t[s]=nb.test(s)?Bu:ni(o);return t}function fb(e){const t=s=>{let o=s;for(const r of sb)o=o.replace(r,Bu);return o};try{const s=JSON.parse(e);return t(JSON.stringify(ni(s),null,2))}catch{return t(e)}}function ra(e,t){return t==="redacted"?fb(e):e}function hb(e,t){return{...e,rawRequestBody:null,responseText:null,rawHeaders:t==="raw"?e.rawHeaders:void 0,headers:t==="raw"?e.headers:void 0,streamingChunks:void 0,bodyContentMode:"compact"}}function xb(e,t,s,o=new Date().toISOString()){return{version:Fu.version,exportedAt:o,mode:t,redacted:t==="redacted",logCount:e.length,logIds:e.map(r=>r.id),streamingChunkExportLimit:Uu,streamingChunkLogIds:s.map(r=>r.id)}}async function gb(e,t="redacted",s={}){const o=po(s.signal);if(o!==null)return o;const r=ub(e);if(r!==null)return{ok:!1,message:r};const{default:a}=await Wt(async()=>{const{default:h}=await import("./jszip.min-D5ch91g-.js").then(g=>g.j);return{default:h}},__vite__mapDeps([0,1,2]),import.meta.url),i=new a,c=t==="redacted"?"redacted":"raw",d=e.filter(h=>h.streaming).slice(0,Uu);i.file("manifest.json",JSON.stringify(xb(e,t,d),null,2)),i.file("logs.json",JSON.stringify(e.map(h=>hb(h,t)),null,2));for(const h of e){const g=po(s.signal);if(g!==null)return g;const v=await rc(h,"request",s.signal);v!==null&&i.file(`#${h.id}.Request.json`,ra(v,t));const y=await rc(h,"response",s.signal);y!==null&&i.file(`#${h.id}.Response.json`,ra(y,t))}for(const h of d){const g=po(s.signal);if(g!==null)return g;const v=await mb(h.id,s.signal);v!==null&&i.file(`#${h.id}.SSE.Response.json`,ra(v,t))}const m=await i.generateAsync({type:"blob"}),u=po(s.signal);if(u!==null)return u;const p=URL.createObjectURL(m),f=document.createElement("a");return f.href=p,f.download=`agent-inspector-export-${c}-${new Date().toISOString().slice(0,10)}.zip`,document.body.appendChild(f),f.click(),document.body.removeChild(f),URL.revokeObjectURL(p),{ok:!0}}function bb(e){const t=oa(e,"/proxy"),s=oa(e,"/proxy/v1"),o=oa(e,"/api/mcp");return t===null||s===null||o===null?null:{proxy:t,openAiV1:s,mcp:o}}function vb(){const e=Gh();return e.ok?bb(e.runtime):null}function Qi(e){const t=()=>e(vb());return t(),typeof globalThis.addEventListener!="function"||typeof globalThis.removeEventListener!="function"?()=>{}:(globalThis.addEventListener(Zl,t),()=>globalThis.removeEventListener(Zl,t))}function si(e,t){switch(t){case"full":return e;case"time":return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}}function _r(e,t,s){return`${si(e,s)} - ${si(t,s)}`}const el="agent-inspector.theme";function qu(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 aa(e){typeof document>"u"||(document.documentElement.dataset.theme=e)}function yb(){if(typeof window>"u")return"dark";try{return qu(window.localStorage.getItem(el))}catch{return"dark"}}function wb(e){if(!(typeof window>"u"))try{window.localStorage.setItem(el,e)}catch{}}function jb(){const[e,t]=l.useState(yb),s=l.useCallback(o=>{t(o),aa(o),wb(o)},[]);return l.useEffect(()=>{aa(e)},[e]),l.useEffect(()=>{function o(r){if(r.key!==el)return;const a=qu(r.newValue);t(a),aa(a)}return window.addEventListener("storage",o),()=>window.removeEventListener("storage",o)},[]),{themeMode:e,setThemeMode:s}}const tl="agent-inspector.uiScale",Sb=1.25,Nb=2200,Cb=3e3,kb=12;function ia(e,t){return Number.isFinite(e)&&e>0?e:t}function nl(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 _b(e,t){switch(e){case"100":return 1;case"125":return 1.25;case"150":return 1.5;case"auto":{const s=ia(t.viewportWidth,1280),o=ia(t.screenWidth,s),r=ia(t.devicePixelRatio,1),a=Math.min(s,o);return r>Sb?1:a>=Cb?1.25:a>=Nb?1.125:1}}}function Tb(e){return`${Math.round(e*100)}%`}function la(e,t){return Math.max(kb,e*t)}function Eb(){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 ca(e){const t=_b(e,Eb());if(typeof document>"u")return t;const s=document.documentElement;return s.dataset.uiScale=e,s.dataset.uiScaleResolved=String(Math.round(t*100)),s.style.setProperty("--inspector-ui-scale",String(t)),s.style.setProperty("--inspector-root-font-size",`${String(16*t)}px`),s.style.setProperty("--inspector-font-9",`${String(la(9,t))}px`),s.style.setProperty("--inspector-font-10",`${String(la(10,t))}px`),s.style.setProperty("--inspector-font-11",`${String(la(11,t))}px`),s.style.setProperty("--inspector-font-13",`${String(13*t)}px`),t}function Rb(){if(typeof window>"u")return"auto";try{return nl(window.localStorage.getItem(tl))}catch{return"auto"}}function Mb(e){if(!(typeof window>"u"))try{window.localStorage.setItem(tl,e)}catch{}}function Ab(){const[e,t]=l.useState(Rb),[s,o]=l.useState(1),r=l.useCallback(a=>{t(a),Mb(a),o(ca(a))},[]);return l.useEffect(()=>{const a=()=>{o(ca(e))};if(a(),e==="auto")return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[e]),l.useEffect(()=>{const a=i=>{if(i.key!==tl)return;const c=nl(i.newValue);t(c),o(ca(c))};return window.addEventListener("storage",a),()=>window.removeEventListener("storage",a)},[]),{uiScalePreference:e,resolvedUiScale:s,setUiScalePreference:r}}const Ib=200,Pb=512,Lb=256,vn=64,oi=256,Hu=64,Ob=32,Db=2,zb=4,ac=16,ve=T().int().positive(),$b=_({proxy:_({requestBytes:ve,responseBytes:ve,headerBytes:ve,deadlineMs:ve,idleTimeoutMs:ve,activeRequests:ve}),control:_({requestBytes:ve,responseBytes:ve,headerBytes:ve,deadlineMs:ve,idleTimeoutMs:ve,activeRequests:ve}),upstream:_({fetchResponseBytes:ve,fetchDeadlineMs:ve,replayResponseBytes:ve,replayDeadlineMs:ve,metadataResponseBytes:ve,metadataDeadlineMs:ve,connectTimeoutMs:ve,idleTimeoutMs:ve}),pagination:_({restPageSize:ve,searchQueryChars:ve,searchProjectChars:ve}),sse:_({clients:ve,initLogs:ve,heartbeatMs:ve}),imports:_({archiveBytes:ve,entries:ve,entryBytes:ve,uncompressedBytes:ve,expansionRatio:ve}),fanOut:_({providerModels:ve,providerModelMetadata:ve,providerTestConcurrency:ve,activeProviderTests:ve}),queues:_({proxyRequests:ve,finalizerJobs:ve,rawStreamMessages:ve,rawStreamBytes:ve,backgroundWorkers:ve})}).superRefine((e,t)=>{e.control.requestBytes>e.proxy.requestBytes&&t.addIssue({code:"custom",path:["control","requestBytes"],message:"control request budget must not exceed proxy request budget"}),e.control.responseBytes>e.proxy.responseBytes&&t.addIssue({code:"custom",path:["control","responseBytes"],message:"control response budget must not exceed proxy response budget"}),e.control.activeRequests>e.proxy.activeRequests&&t.addIssue({code:"custom",path:["control","activeRequests"],message:"control active request budget must not exceed proxy active request budget"}),e.upstream.fetchResponseBytes>e.proxy.responseBytes&&t.addIssue({code:"custom",path:["upstream","fetchResponseBytes"],message:"upstream fetch response budget must not exceed proxy response budget"}),e.upstream.replayResponseBytes>e.proxy.responseBytes&&t.addIssue({code:"custom",path:["upstream","replayResponseBytes"],message:"upstream replay response budget must not exceed proxy response budget"}),e.upstream.metadataResponseBytes>e.control.responseBytes&&t.addIssue({code:"custom",path:["upstream","metadataResponseBytes"],message:"upstream metadata response budget must not exceed control response budget"}),e.upstream.metadataDeadlineMs>e.control.deadlineMs&&t.addIssue({code:"custom",path:["upstream","metadataDeadlineMs"],message:"upstream metadata deadline must not exceed control deadline"}),e.queues.proxyRequests<e.proxy.activeRequests&&t.addIssue({code:"custom",path:["queues","proxyRequests"],message:"proxy request queue budget must cover active proxy requests"})});$b.parse({proxy:{requestBytes:64*1024*1024,responseBytes:256*1024*1024,headerBytes:64*1024,deadlineMs:12e4,idleTimeoutMs:3e4,activeRequests:ac},control:{requestBytes:8*1024*1024,responseBytes:64*1024*1024,headerBytes:32*1024,deadlineMs:3e4,idleTimeoutMs:1e4,activeRequests:8},upstream:{fetchResponseBytes:256*1024*1024,fetchDeadlineMs:12e4,replayResponseBytes:256*1024*1024,replayDeadlineMs:12e4,metadataResponseBytes:10*1024*1024,metadataDeadlineMs:3e4,connectTimeoutMs:1e4,idleTimeoutMs:3e4},pagination:{restPageSize:Ib,searchQueryChars:Pb,searchProjectChars:Lb},sse:{clients:Ob,initLogs:500,heartbeatMs:15e3},imports:{archiveBytes:64*1024*1024,entries:5e3,entryBytes:32*1024*1024,uncompressedBytes:256*1024*1024,expansionRatio:20},fanOut:{providerModels:vn,providerModelMetadata:Hu,providerTestConcurrency:zb,activeProviderTests:Db},queues:{proxyRequests:ac,finalizerJobs:1e3,rawStreamMessages:16384,rawStreamBytes:64*1024*1024,backgroundWorkers:4}});const Fb=me(["invalid-page-request","search-limit-exceeded","provider-model-limit-exceeded","sse-capacity-exceeded","provider-test-capacity-exceeded","proxy-capacity-exceeded"]),Bb=Vt([ae(400),ae(413),ae(429),ae(503)]);_({error:x().min(1).max(300),code:Fb,status:Bb,resource:x().min(1).max(80),limit:T().int().positive(),retryable:Ce()});function fo(){return x().refine(e=>{if(e.length===0)return!0;try{const t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}},"Must be a valid http(s) URL")}const sl=x().max(oi),Ub=V(sl).max(vn),qb=_({model:sl.min(1),contextWindow:T().int().positive().optional(),outputLimit:T().int().positive().optional(),source:me(["manual","registry"]).optional(),sourceUrl:x().optional(),updatedAt:x().optional()}),Hb=V(qb).max(Hu),Vb=_({id:x(),name:x(),apiKey:x(),model:sl.optional(),models:Ub.optional().default([]),format:me(["anthropic","openai"]).optional(),baseUrl:fo().optional(),anthropicBaseUrl:fo().optional(),openaiBaseUrl:fo().optional(),openaiResponsesBaseUrl:fo().optional(),authHeader:me(["bearer","x-api-key"]).optional().default("bearer"),apiDocsUrl:x().optional(),modelMetadataUrl:x().optional(),modelMetadata:Hb.optional(),source:me(["company","personal"]).optional(),createdAt:x(),updatedAt:x()}),Wb="configured",sr=Vb.extend({apiKey:ae(Wb)});async function Gb(e){return tt(e,sr.array(),void 0,t=>`Failed to fetch ${e}: ${t.status}`)}function ol(){const e=$t("/api/providers",Gb,{revalidateOnFocus:!1,revalidateIfStale:!1});return{providers:e.data??[],isLoading:e.isLoading,isError:e.error,mutate:e.mutate}}function ic(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Kb(...e){return t=>{let s=!1;const o=e.map(r=>{const a=ic(r,t);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():ic(e[r],null)}}}}function Ae(...e){return l.useCallback(Kb(...e),e)}function bs(e){const t=l.forwardRef((s,o)=>{let{children:r,...a}=s,i=null,c=!1;const d=[];lc(r)&&typeof ho=="function"&&(r=ho(r._payload)),l.Children.forEach(r,f=>{if(ev(f)){c=!0;const h=f;let g="child"in h.props?h.props.child:h.props.children;lc(g)&&typeof ho=="function"&&(g=ho(g._payload)),i=Xb(h,g),d.push(i?.props?.children)}else d.push(f)}),i?i=l.cloneElement(i,void 0,d):!c&&l.Children.count(r)===1&&l.isValidElement(r)&&(i=r);const m=i?Qb(i):void 0,u=Ae(o,m);if(!i){if(r||r===0)throw new Error(c?ov(e):sv(e));return r}const p=Zb(a,i.props??{});return i.type!==l.Fragment&&(p.ref=o?u:m),l.cloneElement(i,p)});return t.displayName=`${e}.Slot`,t}var Yb=bs("Slot"),Vu=Symbol.for("radix.slottable");function Jb(e){const t=s=>"child"in s?s.children(s.child):s.children;return t.displayName=`${e}.Slottable`,t.__radixId=Vu,t}var Xb=(e,t)=>{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(t)?t:null};function Zb(e,t){const s={...t};for(const o in t){const r=e[o],a=t[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 Qb(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,s=t&&"isReactWarning"in t&&t.isReactWarning;return s?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,s=t&&"isReactWarning"in t&&t.isReactWarning,s?e.props.ref:e.props.ref||e.ref)}function ev(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Vu}var tv=Symbol.for("react.lazy");function lc(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===tv&&"_payload"in e&&nv(e._payload)}function nv(e){return typeof e=="object"&&e!==null&&"then"in e}var sv=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,ov=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,ho=Nr[" use ".trim().toString()],rv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],be=rv.reduce((e,t)=>{const s=bs(`Primitive.${t}`),o=l.forwardRef((r,a)=>{const{asChild:i,...c}=r,d=i?s:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),n.jsx(d,{...c,ref:a})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{});function av(e,t){e&&Cs.flushSync(()=>e.dispatchEvent(t))}var Wu=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"}),iv="VisuallyHidden",Gu=l.forwardRef((e,t)=>n.jsx(be.span,{...e,ref:t,style:{...Wu,...e.style}}));Gu.displayName=iv;var lv=Gu;function on(e,t=[]){let s=[];function o(a,i){const c=l.createContext(i);c.displayName=a+"Context";const d=s.length;s=[...s,i];const m=p=>{const{scope:f,children:h,...g}=p,v=f?.[e]?.[d]||c,y=l.useMemo(()=>g,Object.values(g));return n.jsx(v.Provider,{value:y,children:h})};m.displayName=a+"Provider";function u(p,f,h={}){const{optional:g=!1}=h,v=f?.[e]?.[d]||c,y=l.useContext(v);if(y)return y;if(i!==void 0)return i;if(!g)throw new Error(`\`${p}\` 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,cv(r,...t)]}function cv(...e){const t=e[0];if(e.length===1)return t;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 p=d(a)[`__scope${m}`];return{...c,...p}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return s.scopeName=t.scopeName,s}function Ku(e){const t=e+"CollectionProvider",[s,o]=on(t),[r,a]=s(t,{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 n.jsx(r,{scope:y,itemMap:j,collectionRef:b,children:w})};i.displayName=t;const c=e+"CollectionSlot",d=bs(c),m=l.forwardRef((v,y)=>{const{scope:w,children:b}=v,j=a(c,w),S=Ae(y,j.collectionRef);return n.jsx(d,{ref:S,children:b})});m.displayName=c;const u=e+"CollectionItemSlot",p="data-radix-collection-item",f=bs(u),h=l.forwardRef((v,y)=>{const{scope:w,children:b,...j}=v,S=l.useRef(null),N=Ae(y,S),C=a(u,w);return l.useEffect(()=>(C.itemMap.set(S,{ref:S,...j}),()=>{C.itemMap.delete(S)})),n.jsx(f,{[p]:"",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(`[${p}]`));return Array.from(y.itemMap.values()).sort((C,E)=>j.indexOf(C.ref.current)-j.indexOf(E.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:i,Slot:m,ItemSlot:h},g,o]}function ue(e,t,{checkForDefaultPrevented:s=!0}={}){return function(r){if(e?.(r),s===!1||!r||!r.defaultPrevented)return t?.(r)}}var Ve=globalThis?.document?l.useLayoutEffect:()=>{},dv=Nr[" useInsertionEffect ".trim().toString()]||Ve;function zn({prop:e,defaultProp:t,onChange:s=()=>{},caller:o}){const[r,a,i]=uv({defaultProp:t,onChange:s}),c=e!==void 0,d=c?e:r;{const u=l.useRef(e!==void 0);l.useEffect(()=>{const p=u.current;p!==c&&console.warn(`${o} is changing from ${p?"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 p=mv(u)?u(e):u;p!==e&&i.current?.(p)}else a(u)},[c,e,a,i]);return[d,m]}function uv({defaultProp:e,onChange:t}){const[s,o]=l.useState(e),r=l.useRef(s),a=l.useRef(t);return dv(()=>{a.current=t},[t]),l.useEffect(()=>{r.current!==s&&(a.current?.(s),r.current=s)},[s,r]),[s,o,a]}function mv(e){return typeof e=="function"}function pv(e,t){return l.useReducer((s,o)=>t[s][o]??s,e)}var bt=e=>{const{present:t,children:s}=e,o=fv(t),r=typeof s=="function"?s({present:o.isPresent}):l.Children.only(s),a=hv(o.ref,xv(r));return typeof s=="function"||o.isPresent?l.cloneElement(r,{ref:a}):null};bt.displayName="Presence";function fv(e){const[t,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]=pv(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??Ms(o.current),i.current=void 0):a.current="none"},[d]),Ve(()=>{const u=o.current,p=r.current;if(p!==e){const h=a.current,g=Ms(u);e?(i.current=g,m("MOUNT")):g==="none"||u?.display==="none"?m("UNMOUNT"):m(p&&h!==g?"ANIMATION_OUT":"UNMOUNT"),r.current=e}},[e,m]),Ve(()=>{if(t){let u;const p=t.ownerDocument.defaultView??window,f=g=>{const y=Ms(o.current).includes(CSS.escape(g.animationName));if(g.target===t&&y&&(m("ANIMATION_END"),!r.current)){const w=t.style.animationFillMode;t.style.animationFillMode="forwards",u=p.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=w)})}},h=g=>{g.target===t&&(a.current=Ms(o.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{p.clearTimeout(u),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else m("ANIMATION_END")},[t,m]),{isPresent:["mounted","unmountSuspended"].includes(d),ref:l.useCallback(u=>{if(u){const p=getComputedStyle(u);o.current=p,i.current=Ms(p)}else o.current=null;s(u)},[])}}function cc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function hv(...e){const t=l.useRef(e);return t.current=e,l.useCallback(s=>{const o=t.current;let r=!1;const a=o.map(i=>{const c=cc(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():cc(o[i],null)}}},[])}function Ms(e){return e?.animationName||"none"}function xv(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,s=t&&"isReactWarning"in t&&t.isReactWarning;return s?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,s=t&&"isReactWarning"in t&&t.isReactWarning,s?e.props.ref:e.props.ref||e.ref)}var gv=Nr[" useId ".trim().toString()]||(()=>{}),bv=0;function Ft(e){const[t,s]=l.useState(gv());return Ve(()=>{s(o=>o??String(bv++))},[e]),e||(t?`radix-${t}`:"")}var Tr="Collapsible",[vv]=on(Tr),[yv,rl]=vv(Tr),Yu=l.forwardRef((e,t)=>{const{__scopeCollapsible:s,open:o,defaultOpen:r,disabled:a,onOpenChange:i,...c}=e,[d,m]=zn({prop:o,defaultProp:r??!1,onChange:i,caller:Tr});return n.jsx(yv,{scope:s,disabled:a,contentId:Ft(),open:d,onOpenToggle:l.useCallback(()=>m(u=>!u),[m]),children:n.jsx(be.div,{"data-state":il(d),"data-disabled":a?"":void 0,...c,ref:t})})});Yu.displayName=Tr;var Ju="CollapsibleTrigger",Xu=l.forwardRef((e,t)=>{const{__scopeCollapsible:s,...o}=e,r=rl(Ju,s);return n.jsx(be.button,{type:"button","aria-controls":r.open?r.contentId:void 0,"aria-expanded":r.open||!1,"data-state":il(r.open),"data-disabled":r.disabled?"":void 0,disabled:r.disabled,...o,ref:t,onClick:ue(e.onClick,r.onOpenToggle)})});Xu.displayName=Ju;var al="CollapsibleContent",Zu=l.forwardRef((e,t)=>{const{forceMount:s,...o}=e,r=rl(al,e.__scopeCollapsible);return n.jsx(bt,{present:s||r.open,children:({present:a})=>n.jsx(wv,{...o,ref:t,present:a})})});Zu.displayName=al;var wv=l.forwardRef((e,t)=>{const{__scopeCollapsible:s,present:o,children:r,...a}=e,i=rl(al,s),[c,d]=l.useState(o),m=l.useRef(null),u=Ae(t,m),p=l.useRef(0),f=p.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)},[]),Ve(()=>{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();p.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]),n.jsx(be.div,{"data-state":il(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!v,...a,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...e.style},children:v&&r})});function il(e){return e?"open":"closed"}var jv=Yu,Sv=l.createContext(void 0);function Er(e){const t=l.useContext(Sv);return e||t||"ltr"}function Ye(e){const t=l.useRef(e);return l.useEffect(()=>{t.current=e}),l.useMemo(()=>((...s)=>t.current?.(...s)),[])}var Nv="DismissableLayer",ri="dismissableLayer.update",Cv="dismissableLayer.pointerDownOutside",kv="dismissableLayer.focusOutside",dc,ll=l.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Rr=l.forwardRef((e,t)=>{const{disableOutsidePointerEvents:s=!1,deferPointerDownOutside:o=!1,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:c,onDismiss:d,...m}=e,u=l.useContext(ll),[p,f]=l.useState(null),h=p?.ownerDocument??globalThis?.document,[,g]=l.useState({}),v=Ae(t,f),y=Array.from(u.layers),[w]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),b=w?y.indexOf(w):-1,j=p?y.indexOf(p):-1,S=u.layersWithOutsidePointerEventsDisabled.size>0,N=j>=b,C=l.useRef(!1),E=Mv(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 M=[...u.branches].some(O=>O.contains(k));return N&&!M},[u.branches,N])}),A=Av(k=>{if(o&&C.current)return;const M=k.target;[...u.branches].some($=>$.contains(M))||(i?.(k),c?.(k),k.defaultPrevented||d?.())},h),I=p?j===y.length-1:!1,R=Ye(k=>{k.key==="Escape"&&(r?.(k),!k.defaultPrevented&&d&&(k.preventDefault(),d()))});return l.useEffect(()=>{if(I)return h.addEventListener("keydown",R,{capture:!0}),()=>h.removeEventListener("keydown",R,{capture:!0})},[h,I,R]),l.useEffect(()=>{if(p)return s&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(dc=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(p)),u.layers.add(p),uc(),()=>{s&&(u.layersWithOutsidePointerEventsDisabled.delete(p),u.layersWithOutsidePointerEventsDisabled.size===0&&(h.body.style.pointerEvents=dc))}},[p,h,s,u]),l.useEffect(()=>()=>{p&&(u.layers.delete(p),u.layersWithOutsidePointerEventsDisabled.delete(p),uc())},[p,u]),l.useEffect(()=>{const k=()=>g({});return document.addEventListener(ri,k),()=>document.removeEventListener(ri,k)},[]),n.jsx(be.div,{...m,ref:v,style:{pointerEvents:S?N?"auto":"none":void 0,...e.style},onFocusCapture:ue(e.onFocusCapture,A.onFocusCapture),onBlurCapture:ue(e.onBlurCapture,A.onBlurCapture),onPointerDownCapture:ue(e.onPointerDownCapture,E.onPointerDownCapture)})});Rr.displayName=Nv;var _v="DismissableLayerBranch",Tv=l.forwardRef((e,t)=>{const s=l.useContext(ll),o=l.useRef(null),r=Ae(t,o);return l.useEffect(()=>{const a=o.current;if(a)return s.branches.add(a),()=>{s.branches.delete(a)}},[s.branches]),n.jsx(be.div,{...e,ref:r})});Tv.displayName=_v;function Ev(){const e=l.useContext(ll),[t,s]=l.useState(null);return l.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),s}var Rv=()=>!0;function Mv(e,t){const{ownerDocument:s=globalThis?.document,deferPointerDownOutside:o=!1,isDeferredPointerDownOutsideRef:r,dismissableSurfaces:a,shouldHandlePointerDownOutside:i=Rv}=t,c=Ye(e),d=l.useRef(!1),m=l.useRef(!1),u=l.useRef(new Map),p=l.useRef(()=>{});return l.useEffect(()=>{function f(){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&&p.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",p.current);const C=h();f(),C||Qu(Cv,c,N,{discrete:!0})};if(!i(j.target)){s.removeEventListener("click",p.current),f(),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",p.current),p.current=S,s.addEventListener("click",p.current,{once:!0}))}else s.removeEventListener("click",p.current),f();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",p.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 Av(e,t=globalThis?.document){const s=Ye(e),o=l.useRef(!1);return l.useEffect(()=>{const r=a=>{a.target&&!o.current&&Qu(kv,s,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",r),()=>t.removeEventListener("focusin",r)},[t,s]),{onFocusCapture:()=>o.current=!0,onBlurCapture:()=>o.current=!1}}function uc(){const e=new CustomEvent(ri);document.dispatchEvent(e)}function Qu(e,t,s,{discrete:o}){const r=s.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:s});t&&r.addEventListener(e,t,{once:!0}),o?av(r,a):r.dispatchEvent(a)}var da="focusScope.autoFocusOnMount",ua="focusScope.autoFocusOnUnmount",mc={bubbles:!1,cancelable:!0},Iv="FocusScope",cl=l.forwardRef((e,t)=>{const{loop:s=!1,trapped:o=!1,onMountAutoFocus:r,onUnmountAutoFocus:a,...i}=e,[c,d]=l.useState(null),m=Ye(r),u=Ye(a),p=l.useRef(null),f=Ae(t,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)?p.current=S:pn(p.current,{select:!0})},y=function(j){if(h.paused||!c)return;const S=j.relatedTarget;S!==null&&(c.contains(S)||pn(p.current,{select:!0}))},w=function(j){if(document.activeElement===document.body)for(const N of j)N.removedNodes.length>0&&pn(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){fc.add(h);const v=document.activeElement;if(!c.contains(v)){const w=new CustomEvent(da,mc);c.addEventListener(da,m),c.dispatchEvent(w),w.defaultPrevented||(Pv($v(em(c)),{select:!0}),document.activeElement===v&&pn(c))}return()=>{c.removeEventListener(da,m),setTimeout(()=>{const w=new CustomEvent(ua,mc);c.addEventListener(ua,u),c.dispatchEvent(w),w.defaultPrevented||pn(v??document.body,{select:!0}),c.removeEventListener(ua,u),fc.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]=Lv(b);j&&S?!v.shiftKey&&w===S?(v.preventDefault(),s&&pn(j,{select:!0})):v.shiftKey&&w===j&&(v.preventDefault(),s&&pn(S,{select:!0})):w===b&&v.preventDefault()}},[s,o,h.paused]);return n.jsx(be.div,{tabIndex:-1,...i,ref:f,onKeyDown:g})});cl.displayName=Iv;function Pv(e,{select:t=!1}={}){const s=document.activeElement;for(const o of e)if(pn(o,{select:t}),document.activeElement!==s)return}function Lv(e){const t=em(e),s=pc(t,e),o=pc(t.reverse(),e);return[s,o]}function em(e){const t=[],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();)t.push(s.currentNode);return t}function pc(e,t){const s=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const o of e)if(!(s?!o.checkVisibility({checkVisibilityCSS:!0}):Ov(o,{upTo:t})))return o}function Ov(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Dv(e){return e instanceof HTMLInputElement&&"select"in e}function pn(e,{select:t=!1}={}){if(e&&e.focus){const s=document.activeElement;e.focus({preventScroll:!0}),e!==s&&Dv(e)&&t&&e.select()}}var fc=zv();function zv(){let e=[];return{add(t){const s=e[0];t!==s&&s?.pause(),e=hc(e,t),e.unshift(t)},remove(t){e=hc(e,t),e[0]?.resume()}}}function hc(e,t){const s=[...e],o=s.indexOf(t);return o!==-1&&s.splice(o,1),s}function $v(e){return e.filter(t=>t.tagName!=="A")}var Fv="Portal",Mr=l.forwardRef((e,t)=>{const{container:s,...o}=e,[r,a]=l.useState(!1);Ve(()=>a(!0),[]);const i=s||r&&globalThis?.document?.body;return i?Cs.createPortal(n.jsx(be.div,{...o,ref:t}),i):null});Mr.displayName=Fv;var xo=0,Yn=null;function tm(){l.useEffect(()=>{Yn||(Yn={start:xc(),end:xc()});const{start:e,end:t}=Yn;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),xo++,()=>{xo===1&&(Yn?.start.remove(),Yn?.end.remove(),Yn=null),xo=Math.max(0,xo-1)}},[])}function xc(){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 Dt=function(){return Dt=Object.assign||function(t){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)&&(t[a]=s[a])}return t},Dt.apply(this,arguments)};function nm(e,t){var s={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.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++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(s[o[r]]=e[o[r]]);return s}function Bv(e,t,s){if(s||arguments.length===2)for(var o=0,r=t.length,a;o<r;o++)(a||!(o in t))&&(a||(a=Array.prototype.slice.call(t,0,o)),a[o]=t[o]);return e.concat(a||Array.prototype.slice.call(t))}var Uo="right-scroll-bar-position",qo="width-before-scroll-bar",Uv="with-scroll-bars-hidden",qv="--removed-body-scroll-bar-size";function ma(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Hv(e,t){var s=l.useState(function(){return{value:e,callback:t,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=t,s.facade}var Vv=typeof window<"u"?l.useLayoutEffect:l.useEffect,gc=new WeakMap;function Wv(e,t){var s=Hv(null,function(o){return e.forEach(function(r){return ma(r,o)})});return Vv(function(){var o=gc.get(s);if(o){var r=new Set(o),a=new Set(e),i=s.current;r.forEach(function(c){a.has(c)||ma(c,null)}),a.forEach(function(c){r.has(c)||ma(c,i)})}gc.set(s,e)},[e]),s}function Gv(e){return e}function Kv(e,t){t===void 0&&(t=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=t(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 Yv(e){e===void 0&&(e={});var t=Kv(null);return t.options=Dt({async:!0,ssr:!1},e),t}var sm=function(e){var t=e.sideCar,s=nm(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var o=t.read();if(!o)throw new Error("Sidecar medium not found");return l.createElement(o,Dt({},s))};sm.isSideCarExport=!0;function Jv(e,t){return e.useMedium(t),sm}var om=Yv(),pa=function(){},Ar=l.forwardRef(function(e,t){var s=l.useRef(null),o=l.useState({onScrollCapture:pa,onWheelCapture:pa,onTouchMoveCapture:pa}),r=o[0],a=o[1],i=e.forwardProps,c=e.children,d=e.className,m=e.removeScrollBar,u=e.enabled,p=e.shards,f=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=nm(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),N=f,C=Wv([s,t]),E=Dt(Dt({},S),r);return l.createElement(l.Fragment,null,u&&l.createElement(N,{sideCar:om,removeScrollBar:m,shards:p,noRelative:h,noIsolation:g,inert:v,setCallbacks:a,allowPinchZoom:!!y,lockRef:s,gapMode:j}),i?l.cloneElement(l.Children.only(c),Dt(Dt({},E),{ref:C})):l.createElement(b,Dt({},E,{className:d,ref:C}),c))});Ar.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Ar.classNames={fullWidth:qo,zeroRight:Uo};var Xv=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Zv(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Xv();return t&&e.setAttribute("nonce",t),e}function Qv(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function e2(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var t2=function(){var e=0,t=null;return{add:function(s){e==0&&(t=Zv())&&(Qv(t,s),e2(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},n2=function(){var e=t2();return function(t,s){l.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&s])}},rm=function(){var e=n2(),t=function(s){var o=s.styles,r=s.dynamic;return e(o,r),null};return t},s2={left:0,top:0,right:0,gap:0},fa=function(e){return parseInt(e||"",10)||0},o2=function(e){var t=window.getComputedStyle(document.body),s=t[e==="padding"?"paddingLeft":"marginLeft"],o=t[e==="padding"?"paddingTop":"marginTop"],r=t[e==="padding"?"paddingRight":"marginRight"];return[fa(s),fa(o),fa(r)]},r2=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return s2;var t=o2(e),s=document.documentElement.clientWidth,o=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,o-s+t[2]-t[0])}},a2=rm(),us="data-scroll-locked",i2=function(e,t,s,o){var r=e.left,a=e.top,i=e.right,c=e.gap;return s===void 0&&(s="margin"),`
|
|
3
3
|
.`.concat(Uv,` {
|
|
4
4
|
overflow: hidden `).concat(o,`;
|
|
5
5
|
padding-right: `).concat(c,"px ").concat(o,`;
|
|
@@ -36,17 +36,17 @@ import{l as Wh,u as Vt,s as x,n as T,b as Ce,_ as Yo,a as V,c as qe,o as _,d as
|
|
|
36
36
|
body[`).concat(us,`] {
|
|
37
37
|
`).concat(qv,": ").concat(c,`px;
|
|
38
38
|
}
|
|
39
|
-
`)},bc=function(){var e=parseInt(document.body.getAttribute(us)||"0",10);return isFinite(e)?e:0},l2=function(){l.useEffect(function(){return document.body.setAttribute(us,(bc()+1).toString()),function(){var e=bc()-1;e<=0?document.body.removeAttribute(us):document.body.setAttribute(us,e.toString())}},[])},c2=function(e){var t=e.noRelative,s=e.noImportant,o=e.gapMode,r=o===void 0?"margin":o;l2();var a=l.useMemo(function(){return r2(r)},[r]);return l.createElement(a2,{styles:i2(a,!t,r,s?"":"!important")})},ai=!1;if(typeof window<"u")try{var go=Object.defineProperty({},"passive",{get:function(){return ai=!0,!0}});window.addEventListener("test",go,go),window.removeEventListener("test",go,go)}catch{ai=!1}var Jn=ai?{passive:!1}:!1,d2=function(e){return e.tagName==="TEXTAREA"},am=function(e,t){if(!(e instanceof Element))return!1;var s=window.getComputedStyle(e);return s[t]!=="hidden"&&!(s.overflowY===s.overflowX&&!d2(e)&&s[t]==="visible")},u2=function(e){return am(e,"overflowY")},m2=function(e){return am(e,"overflowX")},vc=function(e,t){var s=t.ownerDocument,o=t;do{typeof ShadowRoot<"u"&&o instanceof ShadowRoot&&(o=o.host);var r=im(e,o);if(r){var a=lm(e,o),i=a[1],c=a[2];if(i>c)return!0}o=o.parentNode}while(o&&o!==s.body);return!1},p2=function(e){var t=e.scrollTop,s=e.scrollHeight,o=e.clientHeight;return[t,s,o]},f2=function(e){var t=e.scrollLeft,s=e.scrollWidth,o=e.clientWidth;return[t,s,o]},im=function(e,t){return e==="v"?u2(t):m2(t)},lm=function(e,t){return e==="v"?p2(t):f2(t)},h2=function(e,t){return e==="h"&&t==="rtl"?-1:1},x2=function(e,t,s,o,r){var a=h2(e,window.getComputedStyle(t).direction),i=a*o,c=s.target,d=t.contains(c),m=!1,u=i>0,p=0,f=0;do{if(!c)break;var h=lm(e,c),g=h[0],
|
|
39
|
+
`)},bc=function(){var e=parseInt(document.body.getAttribute(us)||"0",10);return isFinite(e)?e:0},l2=function(){l.useEffect(function(){return document.body.setAttribute(us,(bc()+1).toString()),function(){var e=bc()-1;e<=0?document.body.removeAttribute(us):document.body.setAttribute(us,e.toString())}},[])},c2=function(e){var t=e.noRelative,s=e.noImportant,o=e.gapMode,r=o===void 0?"margin":o;l2();var a=l.useMemo(function(){return r2(r)},[r]);return l.createElement(a2,{styles:i2(a,!t,r,s?"":"!important")})},ai=!1;if(typeof window<"u")try{var go=Object.defineProperty({},"passive",{get:function(){return ai=!0,!0}});window.addEventListener("test",go,go),window.removeEventListener("test",go,go)}catch{ai=!1}var Jn=ai?{passive:!1}:!1,d2=function(e){return e.tagName==="TEXTAREA"},am=function(e,t){if(!(e instanceof Element))return!1;var s=window.getComputedStyle(e);return s[t]!=="hidden"&&!(s.overflowY===s.overflowX&&!d2(e)&&s[t]==="visible")},u2=function(e){return am(e,"overflowY")},m2=function(e){return am(e,"overflowX")},vc=function(e,t){var s=t.ownerDocument,o=t;do{typeof ShadowRoot<"u"&&o instanceof ShadowRoot&&(o=o.host);var r=im(e,o);if(r){var a=lm(e,o),i=a[1],c=a[2];if(i>c)return!0}o=o.parentNode}while(o&&o!==s.body);return!1},p2=function(e){var t=e.scrollTop,s=e.scrollHeight,o=e.clientHeight;return[t,s,o]},f2=function(e){var t=e.scrollLeft,s=e.scrollWidth,o=e.clientWidth;return[t,s,o]},im=function(e,t){return e==="v"?u2(t):m2(t)},lm=function(e,t){return e==="v"?p2(t):f2(t)},h2=function(e,t){return e==="h"&&t==="rtl"?-1:1},x2=function(e,t,s,o,r){var a=h2(e,window.getComputedStyle(t).direction),i=a*o,c=s.target,d=t.contains(c),m=!1,u=i>0,p=0,f=0;do{if(!c)break;var h=lm(e,c),g=h[0],v=h[1],y=h[2],w=v-y-a*g;(g||w)&&im(e,c)&&(p+=w,f+=g);var b=c.parentNode;c=b&&b.nodeType===Node.DOCUMENT_FRAGMENT_NODE?b.host:b}while(!d&&c!==document.body||d&&(t.contains(c)||t===c));return(u&&Math.abs(p)<1||!u&&Math.abs(f)<1)&&(m=!0),m},bo=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},yc=function(e){return[e.deltaX,e.deltaY]},wc=function(e){return e&&"current"in e?e.current:e},g2=function(e,t){return e[0]===t[0]&&e[1]===t[1]},b2=function(e){return`
|
|
40
40
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
41
41
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
42
|
-
`)},v2=0,Xn=[];function y2(e){var t=l.useRef([]),s=l.useRef([0,0]),o=l.useRef(),r=l.useState(v2++)[0],a=l.useState(rm)[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 b=Bv([e.lockRef.current],(e.shards||[]).map(wc),!0).filter(Boolean);return b.forEach(function(y){return y.classList.add("allow-interactivity-".concat(r))}),function(){document.body.classList.remove("block-interactivity-".concat(r)),b.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(r))})}}},[e.inert,e.lockRef.current,e.shards]);var c=l.useCallback(function(b,y){if("touches"in b&&b.touches.length===2||b.type==="wheel"&&b.ctrlKey)return!i.current.allowPinchZoom;var w=bo(b),v=s.current,j="deltaX"in b?b.deltaX:v[0]-w[0],S="deltaY"in b?b.deltaY:v[1]-w[1],N,C=b.target,E=Math.abs(j)>Math.abs(S)?"h":"v";if("touches"in b&&E==="h"&&C.type==="range")return!1;var A=window.getSelection(),I=A&&A.anchorNode,R=I?I===C||I.contains(C):!1;if(R)return!1;var k=vc(E,C);if(!k)return!0;if(k?N=E:(N=E==="v"?"h":"v",k=vc(E,C)),!k)return!1;if(!o.current&&"changedTouches"in b&&(j||S)&&(o.current=N),!N)return!0;var M=o.current||N;return x2(M,y,b,M==="h"?j:S)},[]),d=l.useCallback(function(b){var y=b;if(!(!Xn.length||Xn[Xn.length-1]!==a)){var w="deltaY"in y?yc(y):bo(y),v=t.current.filter(function(N){return N.name===y.type&&(N.target===y.target||y.target===N.shadowParent)&&g2(N.delta,w)})[0];if(v&&v.should){y.cancelable&&y.preventDefault();return}if(!v){var j=(i.current.shards||[]).map(wc).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(b,y,w,v){var j={name:b,delta:y,target:w,should:v,shadowParent:w2(w)};t.current.push(j),setTimeout(function(){t.current=t.current.filter(function(S){return S!==j})},1)},[]),u=l.useCallback(function(b){s.current=bo(b),o.current=void 0},[]),p=l.useCallback(function(b){m(b.type,yc(b),b.target,c(b,e.lockRef.current))},[]),f=l.useCallback(function(b){m(b.type,bo(b),b.target,c(b,e.lockRef.current))},[]);l.useEffect(function(){return Xn.push(a),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:f}),document.addEventListener("wheel",d,Jn),document.addEventListener("touchmove",d,Jn),document.addEventListener("touchstart",u,Jn),function(){Xn=Xn.filter(function(b){return b!==a}),document.removeEventListener("wheel",d,Jn),document.removeEventListener("touchmove",d,Jn),document.removeEventListener("touchstart",u,Jn)}},[]);var h=e.removeScrollBar,g=e.inert;return l.createElement(l.Fragment,null,g?l.createElement(a,{styles:b2(r)}):null,h?l.createElement(c2,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function w2(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const j2=Jv(om,y2);var dl=l.forwardRef(function(e,t){return l.createElement(Ar,Dt({},e,{ref:t,sideCar:j2}))});dl.classNames=Ar.classNames;var S2=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Zn=new WeakMap,vo=new WeakMap,yo={},ha=0,cm=function(e){return e&&(e.host||cm(e.parentNode))},N2=function(e,t){return t.map(function(s){if(e.contains(s))return s;var o=cm(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})},C2=function(e,t,s,o){var r=N2(t,Array.isArray(e)?e:[e]);yo[s]||(yo[s]=new WeakMap);var a=yo[s],i=[],c=new Set,d=new Set(r),m=function(p){!p||c.has(p)||(c.add(p),m(p.parentNode))};r.forEach(m);var u=function(p){!p||d.has(p)||Array.prototype.forEach.call(p.children,function(f){if(c.has(f))u(f);else try{var h=f.getAttribute(o),g=h!==null&&h!=="false",b=(Zn.get(f)||0)+1,y=(a.get(f)||0)+1;Zn.set(f,b),a.set(f,y),i.push(f),b===1&&g&&vo.set(f,!0),y===1&&f.setAttribute(s,"true"),g||f.setAttribute(o,"true")}catch(w){console.error("aria-hidden: cannot operate on ",f,w)}})};return u(t),c.clear(),ha++,function(){i.forEach(function(p){var f=Zn.get(p)-1,h=a.get(p)-1;Zn.set(p,f),a.set(p,h),f||(vo.has(p)||p.removeAttribute(o),vo.delete(p)),h||p.removeAttribute(s)}),ha--,ha||(Zn=new WeakMap,Zn=new WeakMap,vo=new WeakMap,yo={})}},dm=function(e,t,s){s===void 0&&(s="data-aria-hidden");var o=Array.from(Array.isArray(e)?e:[e]),r=S2(e);return r?(o.push.apply(o,Array.from(r.querySelectorAll("[aria-live], script"))),C2(o,r,s,"aria-hidden")):function(){return null}},Ir="Dialog",[um]=on(Ir),[k2,Pt]=um(Ir),mm=e=>{const{__scopeDialog:t,children:s,open:o,defaultOpen:r,onOpenChange:a,modal:i=!0}=e,c=l.useRef(null),d=l.useRef(null),[m,u]=zn({prop:o,defaultProp:r??!1,onChange:a,caller:Ir});return n.jsx(k2,{scope:t,triggerRef:c,contentRef:d,contentId:Ft(),titleId:Ft(),descriptionId:Ft(),open:m,onOpenChange:u,onOpenToggle:l.useCallback(()=>u(p=>!p),[u]),modal:i,children:s})};mm.displayName=Ir;var pm="DialogTrigger",fm=l.forwardRef((e,t)=>{const{__scopeDialog:s,...o}=e,r=Pt(pm,s),a=Ae(t,r.triggerRef);return n.jsx(be.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.open?r.contentId:void 0,"data-state":ml(r.open),...o,ref:a,onClick:ue(e.onClick,r.onOpenToggle)})});fm.displayName=pm;var ul="DialogPortal",[_2,hm]=um(ul,{forceMount:void 0}),xm=e=>{const{__scopeDialog:t,forceMount:s,children:o,container:r}=e,a=Pt(ul,t);return n.jsx(_2,{scope:t,forceMount:s,children:l.Children.map(o,i=>n.jsx(bt,{present:s||a.open,children:n.jsx(Mr,{asChild:!0,container:r,children:i})}))})};xm.displayName=ul;var or="DialogOverlay",gm=l.forwardRef((e,t)=>{const s=hm(or,e.__scopeDialog),{forceMount:o=s.forceMount,...r}=e,a=Pt(or,e.__scopeDialog);return a.modal?n.jsx(bt,{present:o||a.open,children:n.jsx(E2,{...r,ref:t})}):null});gm.displayName=or;var T2=bs("DialogOverlay.RemoveScroll"),E2=l.forwardRef((e,t)=>{const{__scopeDialog:s,...o}=e,r=Pt(or,s),a=Ev(),i=Ae(t,a);return n.jsx(dl,{as:T2,allowPinchZoom:!0,shards:[r.contentRef],children:n.jsx(be.div,{"data-state":ml(r.open),...o,ref:i,style:{pointerEvents:"auto",...o.style}})})}),vs="DialogContent",bm=l.forwardRef((e,t)=>{const s=hm(vs,e.__scopeDialog),{forceMount:o=s.forceMount,...r}=e,a=Pt(vs,e.__scopeDialog);return n.jsx(bt,{present:o||a.open,children:a.modal?n.jsx(R2,{...r,ref:t}):n.jsx(M2,{...r,ref:t})})});bm.displayName=vs;var R2=l.forwardRef((e,t)=>{const s=Pt(vs,e.__scopeDialog),o=l.useRef(null),r=Ae(t,s.contentRef,o);return l.useEffect(()=>{const a=o.current;if(a)return dm(a)},[]),n.jsx(vm,{...e,ref:r,trapFocus:s.open,disableOutsidePointerEvents:s.open,onCloseAutoFocus:ue(e.onCloseAutoFocus,a=>{a.preventDefault(),s.triggerRef.current?.focus()}),onPointerDownOutside:ue(e.onPointerDownOutside,a=>{const i=a.detail.originalEvent,c=i.button===0&&i.ctrlKey===!0;(i.button===2||c)&&a.preventDefault()}),onFocusOutside:ue(e.onFocusOutside,a=>a.preventDefault())})}),M2=l.forwardRef((e,t)=>{const s=Pt(vs,e.__scopeDialog),o=l.useRef(!1),r=l.useRef(!1);return n.jsx(vm,{...e,ref:t,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()}})}),vm=l.forwardRef((e,t)=>{const{__scopeDialog:s,trapFocus:o,onOpenAutoFocus:r,onCloseAutoFocus:a,...i}=e,c=Pt(vs,s);return tm(),n.jsx(n.Fragment,{children:n.jsx(cl,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:r,onUnmountAutoFocus:a,children:n.jsx(Rr,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":ml(c.open),...i,ref:t,deferPointerDownOutside:!0,onDismiss:()=>c.onOpenChange(!1)})})})}),ym="DialogTitle",wm=l.forwardRef((e,t)=>{const{__scopeDialog:s,...o}=e,r=Pt(ym,s);return n.jsx(be.h2,{id:r.titleId,...o,ref:t})});wm.displayName=ym;var jm="DialogDescription",Sm=l.forwardRef((e,t)=>{const{__scopeDialog:s,...o}=e,r=Pt(jm,s);return n.jsx(be.p,{id:r.descriptionId,...o,ref:t})});Sm.displayName=jm;var Nm="DialogClose",Cm=l.forwardRef((e,t)=>{const{__scopeDialog:s,...o}=e,r=Pt(Nm,s);return n.jsx(be.button,{type:"button",...o,ref:t,onClick:ue(e.onClick,()=>r.onOpenChange(!1))})});Cm.displayName=Nm;function ml(e){return e?"open":"closed"}function A2(e){const t=l.useRef({value:e,previous:e});return l.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}function I2(e){const[t,s]=l.useState(void 0);return Ve(()=>{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]),t}const P2=["top","right","bottom","left"],wn=Math.min,pt=Math.max,rr=Math.round,wo=Math.floor,Bt=e=>({x:e,y:e}),L2={left:"right",right:"left",bottom:"top",top:"bottom"},O2={start:"end",end:"start"};function ii(e,t,s){return pt(e,wn(t,s))}function tn(e,t){return typeof e=="function"?e(t):e}function nn(e){return e.split("-")[0]}function ks(e){return e.split("-")[1]}function pl(e){return e==="x"?"y":"x"}function fl(e){return e==="y"?"height":"width"}const D2=new Set(["top","bottom"]);function zt(e){return D2.has(nn(e))?"y":"x"}function hl(e){return pl(zt(e))}function z2(e,t,s){s===void 0&&(s=!1);const o=ks(e),r=hl(e),a=fl(r);let i=r==="x"?o===(s?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=ar(i)),[i,ar(i)]}function $2(e){const t=ar(e);return[li(e),t,li(t)]}function li(e){return e.replace(/start|end/g,t=>O2[t])}const jc=["left","right"],Sc=["right","left"],F2=["top","bottom"],B2=["bottom","top"];function U2(e,t,s){switch(e){case"top":case"bottom":return s?t?Sc:jc:t?jc:Sc;case"left":case"right":return t?F2:B2;default:return[]}}function q2(e,t,s,o){const r=ks(e);let a=U2(nn(e),s==="start",o);return r&&(a=a.map(i=>i+"-"+r),t&&(a=a.concat(a.map(li)))),a}function ar(e){return e.replace(/left|right|bottom|top/g,t=>L2[t])}function H2(e){return{top:0,right:0,bottom:0,left:0,...e}}function km(e){return typeof e!="number"?H2(e):{top:e,right:e,bottom:e,left:e}}function ir(e){const{x:t,y:s,width:o,height:r}=e;return{width:o,height:r,top:s,left:t,right:t+o,bottom:s+r,x:t,y:s}}function Nc(e,t,s){let{reference:o,floating:r}=e;const a=zt(t),i=hl(t),c=fl(i),d=nn(t),m=a==="y",u=o.x+o.width/2-r.width/2,p=o.y+o.height/2-r.height/2,f=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:p};break;case"left":h={x:o.x-r.width,y:p};break;default:h={x:o.x,y:o.y}}switch(ks(t)){case"start":h[i]-=f*(s&&m?-1:1);break;case"end":h[i]+=f*(s&&m?-1:1);break}return h}async function V2(e,t){var s;t===void 0&&(t={});const{x:o,y:r,platform:a,rects:i,elements:c,strategy:d}=e,{boundary:m="clippingAncestors",rootBoundary:u="viewport",elementContext:p="floating",altBoundary:f=!1,padding:h=0}=tn(t,e),g=km(h),y=c[f?p==="floating"?"reference":"floating":p],w=ir(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})),v=p==="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=ir(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:v,offsetParent:j,strategy:d}):v);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 W2=async(e,t,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(t));let m=await i.getElementRects({reference:e,floating:t,strategy:r}),{x:u,y:p}=Nc(m,o,d),f=o,h={},g=0;for(let y=0;y<c.length;y++){var b;const{name:w,fn:v}=c[y],{x:j,y:S,data:N,reset:C}=await v({x:u,y:p,initialPlacement:o,placement:f,strategy:r,middlewareData:h,rects:m,platform:{...i,detectOverflow:(b=i.detectOverflow)!=null?b:V2},elements:{reference:e,floating:t}});u=j??u,p=S??p,h={...h,[w]:{...h[w],...N}},C&&g<=50&&(g++,typeof C=="object"&&(C.placement&&(f=C.placement),C.rects&&(m=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:r}):C.rects),{x:u,y:p}=Nc(m,f,d)),y=-1)}return{x:u,y:p,placement:f,strategy:r,middlewareData:h}},G2=e=>({name:"arrow",options:e,async fn(t){const{x:s,y:o,placement:r,rects:a,platform:i,elements:c,middlewareData:d}=t,{element:m,padding:u=0}=tn(e,t)||{};if(m==null)return{};const p=km(u),f={x:s,y:o},h=hl(r),g=fl(h),b=await i.getDimensions(m),y=h==="y",w=y?"top":"left",v=y?"bottom":"right",j=y?"clientHeight":"clientWidth",S=a.reference[g]+a.reference[h]-f[h]-a.floating[g],N=f[h]-a.reference[h],C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(m));let E=C?C[j]:0;(!E||!await(i.isElement==null?void 0:i.isElement(C)))&&(E=c.floating[j]||a.floating[g]);const A=S/2-N/2,I=E/2-b[g]/2-1,R=wn(p[w],I),k=wn(p[v],I),M=R,O=E-b[g]-k,$=E/2-b[g]/2+A,K=ii(M,$,O),Q=!d.arrow&&ks(r)!=null&&$!==K&&a.reference[g]/2-($<M?R:k)-b[g]/2<0,z=Q?$<M?$-M:$-O:0;return{[h]:f[h]+z,data:{[h]:K,centerOffset:$-K-z,...Q&&{alignmentOffset:z}},reset:Q}}}),K2=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var s,o;const{placement:r,middlewareData:a,rects:i,initialPlacement:c,platform:d,elements:m}=t,{mainAxis:u=!0,crossAxis:p=!0,fallbackPlacements:f,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:b=!0,...y}=tn(e,t);if((s=a.arrow)!=null&&s.alignmentOffset)return{};const w=nn(r),v=zt(c),j=nn(c)===c,S=await(d.isRTL==null?void 0:d.isRTL(m.floating)),N=f||(j||!b?[ar(c)]:$2(c)),C=g!=="none";!f&&C&&N.push(...q2(c,b,g,S));const E=[c,...N],A=await d.detectOverflow(t,y),I=[];let R=((o=a.flip)==null?void 0:o.overflows)||[];if(u&&I.push(A[w]),p){const $=z2(r,i,S);I.push(A[$[0]],A[$[1]])}if(R=[...R,{placement:r,overflows:I}],!I.every($=>$<=0)){var k,M;const $=(((k=a.flip)==null?void 0:k.index)||0)+1,K=E[$];if(K&&(!(p==="alignment"?v!==zt(K):!1)||R.every(H=>zt(H.placement)===v?H.overflows[0]>0:!0)))return{data:{index:$,overflows:R},reset:{placement:K}};let Q=(M=R.filter(z=>z.overflows[0]<=0).sort((z,H)=>z.overflows[1]-H.overflows[1])[0])==null?void 0:M.placement;if(!Q)switch(h){case"bestFit":{var O;const z=(O=R.filter(H=>{if(C){const ee=zt(H.placement);return ee===v||ee==="y"}return!0}).map(H=>[H.placement,H.overflows.filter(ee=>ee>0).reduce((ee,U)=>ee+U,0)]).sort((H,ee)=>H[1]-ee[1])[0])==null?void 0:O[0];z&&(Q=z);break}case"initialPlacement":Q=c;break}if(r!==Q)return{reset:{placement:Q}}}return{}}}};function Cc(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function kc(e){return P2.some(t=>e[t]>=0)}const Y2=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:s,platform:o}=t,{strategy:r="referenceHidden",...a}=tn(e,t);switch(r){case"referenceHidden":{const i=await o.detectOverflow(t,{...a,elementContext:"reference"}),c=Cc(i,s.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:kc(c)}}}case"escaped":{const i=await o.detectOverflow(t,{...a,altBoundary:!0}),c=Cc(i,s.floating);return{data:{escapedOffsets:c,escaped:kc(c)}}}default:return{}}}}},_m=new Set(["left","top"]);async function J2(e,t){const{placement:s,platform:o,elements:r}=e,a=await(o.isRTL==null?void 0:o.isRTL(r.floating)),i=nn(s),c=ks(s),d=zt(s)==="y",m=_m.has(i)?-1:1,u=a&&d?-1:1,p=tn(t,e);let{mainAxis:f,crossAxis:h,alignmentAxis:g}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return c&&typeof g=="number"&&(h=c==="end"?g*-1:g),d?{x:h*u,y:f*m}:{x:f*m,y:h*u}}const X2=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var s,o;const{x:r,y:a,placement:i,middlewareData:c}=t,d=await J2(t,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}}}}},Z2=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:s,y:o,placement:r,platform:a}=t,{mainAxis:i=!0,crossAxis:c=!1,limiter:d={fn:w=>{let{x:v,y:j}=w;return{x:v,y:j}}},...m}=tn(e,t),u={x:s,y:o},p=await a.detectOverflow(t,m),f=zt(nn(r)),h=pl(f);let g=u[h],b=u[f];if(i){const w=h==="y"?"top":"left",v=h==="y"?"bottom":"right",j=g+p[w],S=g-p[v];g=ii(j,g,S)}if(c){const w=f==="y"?"top":"left",v=f==="y"?"bottom":"right",j=b+p[w],S=b-p[v];b=ii(j,b,S)}const y=d.fn({...t,[h]:g,[f]:b});return{...y,data:{x:y.x-s,y:y.y-o,enabled:{[h]:i,[f]:c}}}}}},Q2=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:s,y:o,placement:r,rects:a,middlewareData:i}=t,{offset:c=0,mainAxis:d=!0,crossAxis:m=!0}=tn(e,t),u={x:s,y:o},p=zt(r),f=pl(p);let h=u[f],g=u[p];const b=tn(c,t),y=typeof b=="number"?{mainAxis:b,crossAxis:0}:{mainAxis:0,crossAxis:0,...b};if(d){const j=f==="y"?"height":"width",S=a.reference[f]-a.floating[j]+y.mainAxis,N=a.reference[f]+a.reference[j]-y.mainAxis;h<S?h=S:h>N&&(h=N)}if(m){var w,v;const j=f==="y"?"width":"height",S=_m.has(nn(r)),N=a.reference[p]-a.floating[j]+(S&&((w=i.offset)==null?void 0:w[p])||0)+(S?0:y.crossAxis),C=a.reference[p]+a.reference[j]+(S?0:((v=i.offset)==null?void 0:v[p])||0)-(S?y.crossAxis:0);g<N?g=N:g>C&&(g=C)}return{[f]:h,[p]:g}}}},ey=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var s,o;const{placement:r,rects:a,platform:i,elements:c}=t,{apply:d=()=>{},...m}=tn(e,t),u=await i.detectOverflow(t,m),p=nn(r),f=ks(r),h=zt(r)==="y",{width:g,height:b}=a.floating;let y,w;p==="top"||p==="bottom"?(y=p,w=f===(await(i.isRTL==null?void 0:i.isRTL(c.floating))?"start":"end")?"left":"right"):(w=p,y=f==="end"?"top":"bottom");const v=b-u.top-u.bottom,j=g-u.left-u.right,S=wn(b-u[y],v),N=wn(g-u[w],j),C=!t.middlewareData.shift;let E=S,A=N;if((s=t.middlewareData.shift)!=null&&s.enabled.x&&(A=j),(o=t.middlewareData.shift)!=null&&o.enabled.y&&(E=v),C&&!f){const R=pt(u.left,0),k=pt(u.right,0),M=pt(u.top,0),O=pt(u.bottom,0);h?A=g-2*(R!==0||k!==0?R+k:pt(u.left,u.right)):E=b-2*(M!==0||O!==0?M+O:pt(u.top,u.bottom))}await d({...t,availableWidth:A,availableHeight:E});const I=await i.getDimensions(c.floating);return g!==I.width||b!==I.height?{reset:{rects:!0}}:{}}}};function Pr(){return typeof window<"u"}function _s(e){return Tm(e)?(e.nodeName||"").toLowerCase():"#document"}function xt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Gt(e){var t;return(t=(Tm(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Tm(e){return Pr()?e instanceof Node||e instanceof xt(e).Node:!1}function Mt(e){return Pr()?e instanceof Element||e instanceof xt(e).Element:!1}function Ut(e){return Pr()?e instanceof HTMLElement||e instanceof xt(e).HTMLElement:!1}function _c(e){return!Pr()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof xt(e).ShadowRoot}const ty=new Set(["inline","contents"]);function oo(e){const{overflow:t,overflowX:s,overflowY:o,display:r}=At(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+s)&&!ty.has(r)}const ny=new Set(["table","td","th"]);function sy(e){return ny.has(_s(e))}const oy=[":popover-open",":modal"];function Lr(e){return oy.some(t=>{try{return e.matches(t)}catch{return!1}})}const ry=["transform","translate","scale","rotate","perspective"],ay=["transform","translate","scale","rotate","perspective","filter"],iy=["paint","layout","strict","content"];function xl(e){const t=gl(),s=Mt(e)?At(e):e;return ry.some(o=>s[o]?s[o]!=="none":!1)||(s.containerType?s.containerType!=="normal":!1)||!t&&(s.backdropFilter?s.backdropFilter!=="none":!1)||!t&&(s.filter?s.filter!=="none":!1)||ay.some(o=>(s.willChange||"").includes(o))||iy.some(o=>(s.contain||"").includes(o))}function ly(e){let t=jn(e);for(;Ut(t)&&!ys(t);){if(xl(t))return t;if(Lr(t))return null;t=jn(t)}return null}function gl(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const cy=new Set(["html","body","#document"]);function ys(e){return cy.has(_s(e))}function At(e){return xt(e).getComputedStyle(e)}function Or(e){return Mt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function jn(e){if(_s(e)==="html")return e;const t=e.assignedSlot||e.parentNode||_c(e)&&e.host||Gt(e);return _c(t)?t.host:t}function Em(e){const t=jn(e);return ys(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ut(t)&&oo(t)?t:Em(t)}function Ws(e,t,s){var o;t===void 0&&(t=[]),s===void 0&&(s=!0);const r=Em(e),a=r===((o=e.ownerDocument)==null?void 0:o.body),i=xt(r);if(a){const c=ci(i);return t.concat(i,i.visualViewport||[],oo(r)?r:[],c&&s?Ws(c):[])}return t.concat(r,Ws(r,[],s))}function ci(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Rm(e){const t=At(e);let s=parseFloat(t.width)||0,o=parseFloat(t.height)||0;const r=Ut(e),a=r?e.offsetWidth:s,i=r?e.offsetHeight:o,c=rr(s)!==a||rr(o)!==i;return c&&(s=a,o=i),{width:s,height:o,$:c}}function bl(e){return Mt(e)?e:e.contextElement}function ms(e){const t=bl(e);if(!Ut(t))return Bt(1);const s=t.getBoundingClientRect(),{width:o,height:r,$:a}=Rm(t);let i=(a?rr(s.width):s.width)/o,c=(a?rr(s.height):s.height)/r;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const dy=Bt(0);function Mm(e){const t=xt(e);return!gl()||!t.visualViewport?dy:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function uy(e,t,s){return t===void 0&&(t=!1),!s||t&&s!==xt(e)?!1:t}function $n(e,t,s,o){t===void 0&&(t=!1),s===void 0&&(s=!1);const r=e.getBoundingClientRect(),a=bl(e);let i=Bt(1);t&&(o?Mt(o)&&(i=ms(o)):i=ms(e));const c=uy(a,s,o)?Mm(a):Bt(0);let d=(r.left+c.x)/i.x,m=(r.top+c.y)/i.y,u=r.width/i.x,p=r.height/i.y;if(a){const f=xt(a),h=o&&Mt(o)?xt(o):o;let g=f,b=ci(g);for(;b&&o&&h!==g;){const y=ms(b),w=b.getBoundingClientRect(),v=At(b),j=w.left+(b.clientLeft+parseFloat(v.paddingLeft))*y.x,S=w.top+(b.clientTop+parseFloat(v.paddingTop))*y.y;d*=y.x,m*=y.y,u*=y.x,p*=y.y,d+=j,m+=S,g=xt(b),b=ci(g)}}return ir({width:u,height:p,x:d,y:m})}function Dr(e,t){const s=Or(e).scrollLeft;return t?t.left+s:$n(Gt(e)).left+s}function Am(e,t){const s=e.getBoundingClientRect(),o=s.left+t.scrollLeft-Dr(e,s),r=s.top+t.scrollTop;return{x:o,y:r}}function my(e){let{elements:t,rect:s,offsetParent:o,strategy:r}=e;const a=r==="fixed",i=Gt(o),c=t?Lr(t.floating):!1;if(o===i||c&&a)return s;let d={scrollLeft:0,scrollTop:0},m=Bt(1);const u=Bt(0),p=Ut(o);if((p||!p&&!a)&&((_s(o)!=="body"||oo(i))&&(d=Or(o)),Ut(o))){const h=$n(o);m=ms(o),u.x=h.x+o.clientLeft,u.y=h.y+o.clientTop}const f=i&&!p&&!a?Am(i,d):Bt(0);return{width:s.width*m.x,height:s.height*m.y,x:s.x*m.x-d.scrollLeft*m.x+u.x+f.x,y:s.y*m.y-d.scrollTop*m.y+u.y+f.y}}function py(e){return Array.from(e.getClientRects())}function fy(e){const t=Gt(e),s=Or(e),o=e.ownerDocument.body,r=pt(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),a=pt(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight);let i=-s.scrollLeft+Dr(e);const c=-s.scrollTop;return At(o).direction==="rtl"&&(i+=pt(t.clientWidth,o.clientWidth)-r),{width:r,height:a,x:i,y:c}}const Tc=25;function hy(e,t){const s=xt(e),o=Gt(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=gl();(!u||u&&t==="fixed")&&(c=r.offsetLeft,d=r.offsetTop)}const m=Dr(o);if(m<=0){const u=o.ownerDocument,p=u.body,f=getComputedStyle(p),h=u.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,g=Math.abs(o.clientWidth-p.clientWidth-h);g<=Tc&&(a-=g)}else m<=Tc&&(a+=m);return{width:a,height:i,x:c,y:d}}const xy=new Set(["absolute","fixed"]);function gy(e,t){const s=$n(e,!0,t==="fixed"),o=s.top+e.clientTop,r=s.left+e.clientLeft,a=Ut(e)?ms(e):Bt(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 Ec(e,t,s){let o;if(t==="viewport")o=hy(e,s);else if(t==="document")o=fy(Gt(e));else if(Mt(t))o=gy(t,s);else{const r=Mm(e);o={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return ir(o)}function Im(e,t){const s=jn(e);return s===t||!Mt(s)||ys(s)?!1:At(s).position==="fixed"||Im(s,t)}function by(e,t){const s=t.get(e);if(s)return s;let o=Ws(e,[],!1).filter(c=>Mt(c)&&_s(c)!=="body"),r=null;const a=At(e).position==="fixed";let i=a?jn(e):e;for(;Mt(i)&&!ys(i);){const c=At(i),d=xl(i);!d&&c.position==="fixed"&&(r=null),(a?!d&&!r:!d&&c.position==="static"&&!!r&&xy.has(r.position)||oo(i)&&!d&&Im(e,i))?o=o.filter(u=>u!==i):r=c,i=jn(i)}return t.set(e,o),o}function vy(e){let{element:t,boundary:s,rootBoundary:o,strategy:r}=e;const i=[...s==="clippingAncestors"?Lr(t)?[]:by(t,this._c):[].concat(s),o],c=i[0],d=i.reduce((m,u)=>{const p=Ec(t,u,r);return m.top=pt(p.top,m.top),m.right=wn(p.right,m.right),m.bottom=wn(p.bottom,m.bottom),m.left=pt(p.left,m.left),m},Ec(t,c,r));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}}function yy(e){const{width:t,height:s}=Rm(e);return{width:t,height:s}}function wy(e,t,s){const o=Ut(t),r=Gt(t),a=s==="fixed",i=$n(e,!0,a,t);let c={scrollLeft:0,scrollTop:0};const d=Bt(0);function m(){d.x=Dr(r)}if(o||!o&&!a)if((_s(t)!=="body"||oo(r))&&(c=Or(t)),o){const h=$n(t,!0,a,t);d.x=h.x+t.clientLeft,d.y=h.y+t.clientTop}else r&&m();a&&!o&&r&&m();const u=r&&!o&&!a?Am(r,c):Bt(0),p=i.left+c.scrollLeft-d.x-u.x,f=i.top+c.scrollTop-d.y-u.y;return{x:p,y:f,width:i.width,height:i.height}}function xa(e){return At(e).position==="static"}function Rc(e,t){if(!Ut(e)||At(e).position==="fixed")return null;if(t)return t(e);let s=e.offsetParent;return Gt(e)===s&&(s=s.ownerDocument.body),s}function Pm(e,t){const s=xt(e);if(Lr(e))return s;if(!Ut(e)){let r=jn(e);for(;r&&!ys(r);){if(Mt(r)&&!xa(r))return r;r=jn(r)}return s}let o=Rc(e,t);for(;o&&sy(o)&&xa(o);)o=Rc(o,t);return o&&ys(o)&&xa(o)&&!xl(o)?s:o||ly(e)||s}const jy=async function(e){const t=this.getOffsetParent||Pm,s=this.getDimensions,o=await s(e.floating);return{reference:wy(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function Sy(e){return At(e).direction==="rtl"}const Ny={convertOffsetParentRelativeRectToViewportRelativeRect:my,getDocumentElement:Gt,getClippingRect:vy,getOffsetParent:Pm,getElementRects:jy,getClientRects:py,getDimensions:yy,getScale:ms,isElement:Mt,isRTL:Sy};function Lm(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Cy(e,t){let s=null,o;const r=Gt(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:p,width:f,height:h}=m;if(c||t(),!f||!h)return;const g=wo(p),b=wo(r.clientWidth-(u+f)),y=wo(r.clientHeight-(p+h)),w=wo(u),j={rootMargin:-g+"px "+-b+"px "+-y+"px "+-w+"px",threshold:pt(0,wn(1,d))||1};let S=!0;function N(C){const E=C[0].intersectionRatio;if(E!==d){if(!S)return i();E?i(!1,E):o=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!Lm(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 ky(e,t,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=bl(e),u=r||a?[...m?Ws(m):[],...Ws(t)]:[];u.forEach(w=>{r&&w.addEventListener("scroll",s,{passive:!0}),a&&w.addEventListener("resize",s)});const p=m&&c?Cy(m,s):null;let f=-1,h=null;i&&(h=new ResizeObserver(w=>{let[v]=w;v&&v.target===m&&h&&(h.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var j;(j=h)==null||j.observe(t)})),s()}),m&&!d&&h.observe(m),h.observe(t));let g,b=d?$n(e):null;d&&y();function y(){const w=$n(e);b&&!Lm(b,w)&&s(),b=w,g=requestAnimationFrame(y)}return s(),()=>{var w;u.forEach(v=>{r&&v.removeEventListener("scroll",s),a&&v.removeEventListener("resize",s)}),p?.(),(w=h)==null||w.disconnect(),h=null,d&&cancelAnimationFrame(g)}}const _y=X2,Ty=Z2,Ey=K2,Ry=ey,My=Y2,Mc=G2,Ay=Q2,Iy=(e,t,s)=>{const o=new Map,r={platform:Ny,...s},a={...r.platform,_c:o};return W2(e,t,{...r,platform:a})};var Py=typeof document<"u",Ly=function(){},Ho=Py?l.useLayoutEffect:Ly;function lr(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let s,o,r;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(s=e.length,s!==t.length)return!1;for(o=s;o--!==0;)if(!lr(e[o],t[o]))return!1;return!0}if(r=Object.keys(e),s=r.length,s!==Object.keys(t).length)return!1;for(o=s;o--!==0;)if(!{}.hasOwnProperty.call(t,r[o]))return!1;for(o=s;o--!==0;){const a=r[o];if(!(a==="_owner"&&e.$$typeof)&&!lr(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function Om(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Ac(e,t){const s=Om(e);return Math.round(t*s)/s}function ga(e){const t=l.useRef(e);return Ho(()=>{t.current=e}),t}function Oy(e){e===void 0&&(e={});const{placement:t="bottom",strategy:s="absolute",middleware:o=[],platform:r,elements:{reference:a,floating:i}={},transform:c=!0,whileElementsMounted:d,open:m}=e,[u,p]=l.useState({x:0,y:0,strategy:s,placement:t,middlewareData:{},isPositioned:!1}),[f,h]=l.useState(o);lr(f,o)||h(o);const[g,b]=l.useState(null),[y,w]=l.useState(null),v=l.useCallback(H=>{H!==C.current&&(C.current=H,b(H))},[]),j=l.useCallback(H=>{H!==E.current&&(E.current=H,w(H))},[]),S=a||g,N=i||y,C=l.useRef(null),E=l.useRef(null),A=l.useRef(u),I=d!=null,R=ga(d),k=ga(r),M=ga(m),O=l.useCallback(()=>{if(!C.current||!E.current)return;const H={placement:t,strategy:s,middleware:f};k.current&&(H.platform=k.current),Iy(C.current,E.current,H).then(ee=>{const U={...ee,isPositioned:M.current!==!1};$.current&&!lr(A.current,U)&&(A.current=U,Cs.flushSync(()=>{p(U)}))})},[f,t,s,k,M]);Ho(()=>{m===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,p(H=>({...H,isPositioned:!1})))},[m]);const $=l.useRef(!1);Ho(()=>($.current=!0,()=>{$.current=!1}),[]),Ho(()=>{if(S&&(C.current=S),N&&(E.current=N),S&&N){if(R.current)return R.current(S,N,O);O()}},[S,N,O,R,I]);const K=l.useMemo(()=>({reference:C,floating:E,setReference:v,setFloating:j}),[v,j]),Q=l.useMemo(()=>({reference:S,floating:N}),[S,N]),z=l.useMemo(()=>{const H={position:s,left:0,top:0};if(!Q.floating)return H;const ee=Ac(Q.floating,u.x),U=Ac(Q.floating,u.y);return c?{...H,transform:"translate("+ee+"px, "+U+"px)",...Om(Q.floating)>=1.5&&{willChange:"transform"}}:{position:s,left:ee,top:U}},[s,c,Q.floating,u.x,u.y]);return l.useMemo(()=>({...u,update:O,refs:K,elements:Q,floatingStyles:z}),[u,O,K,Q,z])}const Dy=e=>{function t(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&&t(o)?o.current!=null?Mc({element:o.current,padding:r}).fn(s):{}:o?Mc({element:o,padding:r}).fn(s):{}}}},zy=(e,t)=>({..._y(e),options:[e,t]}),$y=(e,t)=>({...Ty(e),options:[e,t]}),Fy=(e,t)=>({...Ay(e),options:[e,t]}),By=(e,t)=>({...Ey(e),options:[e,t]}),Uy=(e,t)=>({...Ry(e),options:[e,t]}),qy=(e,t)=>({...My(e),options:[e,t]}),Hy=(e,t)=>({...Dy(e),options:[e,t]});var Vy="Arrow",Dm=l.forwardRef((e,t)=>{const{children:s,width:o=10,height:r=5,...a}=e;return n.jsx(be.svg,{...a,ref:t,width:o,height:r,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?s:n.jsx("polygon",{points:"0,0 30,0 15,10"})})});Dm.displayName=Vy;var Wy=Dm,vl="Popper",[zm,zr]=on(vl),[Gy,$m]=zm(vl),Fm=e=>{const{__scopePopper:t,children:s}=e,[o,r]=l.useState(null),[a,i]=l.useState(void 0);return n.jsx(Gy,{scope:t,anchor:o,onAnchorChange:r,placementState:a,setPlacementState:i,children:s})};Fm.displayName=vl;var Bm="PopperAnchor",Um=l.forwardRef((e,t)=>{const{__scopePopper:s,virtualRef:o,...r}=e,a=$m(Bm,s),i=l.useRef(null),c=a.onAnchorChange,d=l.useCallback(g=>{i.current=g,g&&c(g)},[c]),m=Ae(t,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 p=a.placementState&&wl(a.placementState),f=p?.[0],h=p?.[1];return o?null:n.jsx(be.div,{"data-radix-popper-side":f,"data-radix-popper-align":h,...r,ref:m})});Um.displayName=Bm;var yl="PopperContent",[Ky,Yy]=zm(yl),qm=l.forwardRef((e,t)=>{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:p="partial",hideWhenDetached:f=!1,updatePositionStrategy:h="optimized",onPlaced:g,...b}=e,y=$m(yl,s),[w,v]=l.useState(null),j=Ae(t,v),[S,N]=l.useState(null),C=I2(S),E=C?.width??0,A=C?.height??0,I=o+(a!=="center"?"-"+a:""),R=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},k=Array.isArray(m)?m:[m],M=k.length>0,O={padding:R,boundary:k.filter(Xy),altBoundary:M},{refs:$,floatingStyles:K,placement:Q,isPositioned:z,middlewareData:H}=Oy({strategy:"fixed",placement:I,whileElementsMounted:(...Se)=>ky(...Se,{animationFrame:h==="always"}),elements:{reference:y.anchor},middleware:[zy({mainAxis:r+A,alignmentAxis:i}),d&&$y({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?Fy():void 0,...O}),d&&By({...O}),Uy({...O,apply:({elements:Se,rects:Te,availableWidth:ge,availableHeight:le})=>{const{width:ce,height:Pe}=Te.reference,Re=Se.floating.style;Re.setProperty("--radix-popper-available-width",`${ge}px`),Re.setProperty("--radix-popper-available-height",`${le}px`),Re.setProperty("--radix-popper-anchor-width",`${ce}px`),Re.setProperty("--radix-popper-anchor-height",`${Pe}px`)}}),S&&Hy({element:S,padding:c}),Zy({arrowWidth:E,arrowHeight:A}),f&&qy({strategy:"referenceHidden",...O,boundary:M?O.boundary:void 0})]}),ee=y.setPlacementState;Ve(()=>(ee(Q),()=>{ee(void 0)}),[Q,ee]);const[U,Z]=wl(Q),fe=Ye(g);Ve(()=>{z&&fe?.()},[z,fe]);const je=H.arrow?.x,he=H.arrow?.y,oe=H.arrow?.centerOffset!==0,[L,J]=l.useState();return Ve(()=>{w&&J(window.getComputedStyle(w).zIndex)},[w]),n.jsx("div",{ref:$.setFloating,"data-radix-popper-content-wrapper":"",style:{...K,transform:z?K.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:L,"--radix-popper-transform-origin":[H.transformOrigin?.x,H.transformOrigin?.y].join(" "),...H.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:n.jsx(Ky,{scope:s,placedSide:U,placedAlign:Z,onArrowChange:N,arrowX:je,arrowY:he,shouldHideArrow:oe,children:n.jsx(be.div,{"data-side":U,"data-align":Z,...b,ref:j,style:{...b.style,animation:z?void 0:"none"}})})})});qm.displayName=yl;var Hm="PopperArrow",Jy={top:"bottom",right:"left",bottom:"top",left:"right"},Vm=l.forwardRef(function(t,s){const{__scopePopper:o,...r}=t,a=Yy(Hm,o),i=Jy[a.placedSide];return n.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:n.jsx(Wy,{...r,ref:s,style:{...r.style,display:"block"}})})});Vm.displayName=Hm;function Xy(e){return e!==null}var Zy=e=>({name:"transformOrigin",options:e,fn(t){const{placement:s,rects:o,middlewareData:r}=t,i=r.arrow?.centerOffset!==0,c=i?0:e.arrowWidth,d=i?0:e.arrowHeight,[m,u]=wl(s),p={start:"0%",center:"50%",end:"100%"}[u],f=(r.arrow?.x??0)+c/2,h=(r.arrow?.y??0)+d/2;let g="",b="";return m==="bottom"?(g=i?p:`${f}px`,b=`${-d}px`):m==="top"?(g=i?p:`${f}px`,b=`${o.floating.height+d}px`):m==="right"?(g=`${-d}px`,b=i?p:`${h}px`):m==="left"&&(g=`${o.floating.width+d}px`,b=i?p:`${h}px`),{data:{x:g,y:b}}}});function wl(e){const[t,s="center"]=e.split("-");return[t,s]}var Wm=Fm,Gm=Um,Km=qm,Ym=Vm,ba=!1;function Qy(){const[e,t]=l.useState(ba);return l.useEffect(()=>{ba||(ba=!0,t(!0))},[]),e}var Jm=Nr[" useSyncExternalStore ".trim().toString()];function ew(){return()=>{}}function tw(){return Jm(ew,()=>!0,()=>!1)}var nw=typeof Jm=="function"?tw:Qy,va="rovingFocusGroup.onEntryFocus",sw={bubbles:!1,cancelable:!0},ro="RovingFocusGroup",[di,Xm,ow]=Ku(ro),[rw,Zm]=on(ro,[ow]),[aw,iw]=rw(ro),Qm=l.forwardRef((e,t)=>n.jsx(di.Provider,{scope:e.__scopeRovingFocusGroup,children:n.jsx(di.Slot,{scope:e.__scopeRovingFocusGroup,children:n.jsx(lw,{...e,ref:t})})}));Qm.displayName=ro;var lw=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:s,orientation:o,loop:r=!1,dir:a,currentTabStopId:i,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:d,onEntryFocus:m,preventScrollOnEntryFocus:u=!1,...p}=e,f=l.useRef(null),h=Ae(t,f),g=Er(a),[b,y]=zn({prop:i,defaultProp:c??null,onChange:d,caller:ro}),[w,v]=l.useState(!1),j=Ye(m),S=Xm(s),N=l.useRef(!1),[C,E]=l.useState(0);return l.useEffect(()=>{const A=f.current;if(A)return A.addEventListener(va,j),()=>A.removeEventListener(va,j)},[j]),n.jsx(aw,{scope:s,orientation:o,dir:g,loop:r,currentTabStopId:b,onItemFocus:l.useCallback(A=>y(A),[y]),onItemShiftTab:l.useCallback(()=>v(!0),[]),onFocusableItemAdd:l.useCallback(()=>E(A=>A+1),[]),onFocusableItemRemove:l.useCallback(()=>E(A=>A-1),[]),children:n.jsx(be.div,{tabIndex:w||C===0?-1:0,"data-orientation":o,...p,ref:h,style:{outline:"none",...e.style},onMouseDown:ue(e.onMouseDown,()=>{N.current=!0}),onFocus:ue(e.onFocus,A=>{const I=!N.current;if(A.target===A.currentTarget&&I&&!w){const R=new CustomEvent(va,sw);if(A.currentTarget.dispatchEvent(R),!R.defaultPrevented){const k=S().filter(Q=>Q.focusable),M=k.find(Q=>Q.active),O=k.find(Q=>Q.id===b),K=[M,O,...k].filter(Boolean).map(Q=>Q.ref.current);np(K,u)}}N.current=!1}),onBlur:ue(e.onBlur,()=>v(!1))})})}),ep="RovingFocusGroupItem",tp=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:s,focusable:o=!0,active:r=!1,tabStopId:a,children:i,...c}=e,d=Ft(),m=a||d,u=iw(ep,s),p=u.currentTabStopId===m,f=Xm(s),{onFocusableItemAdd:h,onFocusableItemRemove:g,currentTabStopId:b}=u,y=nw();return Ve(()=>{if(!(!y||!o))return h(),()=>g()},[y,o,h,g]),l.useEffect(()=>{if(!(y||!o))return h(),()=>g()},[y,o,h,g]),n.jsx(di.ItemSlot,{scope:s,id:m,focusable:o,active:r,children:n.jsx(be.span,{tabIndex:p?0:-1,"data-orientation":u.orientation,...c,ref:t,onMouseDown:ue(e.onMouseDown,w=>{o?u.onItemFocus(m):w.preventDefault()}),onFocus:ue(e.onFocus,()=>u.onItemFocus(m)),onKeyDown:ue(e.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){u.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const v=uw(w,u.orientation,u.dir);if(v!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let S=f().filter(N=>N.focusable).map(N=>N.ref.current);if(v==="last")S.reverse();else if(v==="prev"||v==="next"){v==="prev"&&S.reverse();const N=S.indexOf(w.currentTarget);S=u.loop?mw(S,N+1):S.slice(N+1)}setTimeout(()=>np(S))}}),children:typeof i=="function"?i({isCurrentTabStop:p,hasTabStop:b!=null}):i})})});tp.displayName=ep;var cw={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function dw(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function uw(e,t,s){const o=dw(e.key,s);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(o))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(o)))return cw[o]}function np(e,t=!1){const s=document.activeElement;for(const o of e)if(o===s||(o.focus({preventScroll:t}),document.activeElement!==s))return}function mw(e,t){return e.map((s,o)=>e[(t+o)%e.length])}var pw=Qm,fw=tp;function ui(e,[t,s]){return Math.min(s,Math.max(t,e))}function hw(e,t){return l.useReducer((s,o)=>t[s][o]??s,e)}var jl="ScrollArea",[sp]=on(jl),[xw,wt]=sp(jl),op=l.forwardRef((e,t)=>{const{__scopeScrollArea:s,type:o="hover",dir:r,scrollHideDelay:a=600,...i}=e,[c,d]=l.useState(null),[m,u]=l.useState(null),[p,f]=l.useState(null),[h,g]=l.useState(null),[b,y]=l.useState(null),[w,v]=l.useState(0),[j,S]=l.useState(0),[N,C]=l.useState(!1),[E,A]=l.useState(!1),I=Ae(t,d),R=Er(r);return n.jsx(xw,{scope:s,type:o,dir:R,scrollHideDelay:a,scrollArea:c,viewport:m,onViewportChange:u,content:p,onContentChange:f,scrollbarX:h,onScrollbarXChange:g,scrollbarXEnabled:N,onScrollbarXEnabledChange:C,scrollbarY:b,onScrollbarYChange:y,scrollbarYEnabled:E,onScrollbarYEnabledChange:A,onCornerWidthChange:v,onCornerHeightChange:S,children:n.jsx(be.div,{dir:R,...i,ref:I,style:{position:"relative","--radix-scroll-area-corner-width":w+"px","--radix-scroll-area-corner-height":j+"px",...e.style}})})});op.displayName=jl;var rp="ScrollAreaViewport",ap=l.forwardRef((e,t)=>{const{__scopeScrollArea:s,children:o,nonce:r,...a}=e,i=wt(rp,s),c=l.useRef(null),d=Ae(t,c,i.onViewportChange);return n.jsxs(n.Fragment,{children:[n.jsx(gw,{nonce:r}),n.jsx(be.div,{"data-radix-scroll-area-viewport":"",...a,ref:d,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:n.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:o})})]})});ap.displayName=rp;var gw=l.memo(({nonce:e})=>n.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,t)=>e.nonce===t.nonce),Kt="ScrollAreaScrollbar",ip=l.forwardRef((e,t)=>{const{forceMount:s,...o}=e,r=wt(Kt,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"?n.jsx(bw,{...o,ref:t,forceMount:s}):r.type==="scroll"?n.jsx(vw,{...o,ref:t,forceMount:s}):r.type==="auto"?n.jsx(lp,{...o,ref:t,forceMount:s}):r.type==="always"?n.jsx(Sl,{...o,ref:t,"data-state":"visible"}):null});ip.displayName=Kt;var bw=l.forwardRef((e,t)=>{const{forceMount:s,...o}=e,r=wt(Kt,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]),n.jsx(bt,{present:s||a,children:n.jsx(lp,{"data-state":a?"visible":"hidden",...o,ref:t})})}),vw=l.forwardRef((e,t)=>{const{forceMount:s,...o}=e,r=wt(Kt,e.__scopeScrollArea),a=e.orientation==="horizontal",i=Fr(()=>d("SCROLL_END"),100),[c,d]=hw("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 p=m[u];const f=()=>{const h=m[u];p!==h&&(d("SCROLL"),i()),p=h};return m.addEventListener("scroll",f),()=>m.removeEventListener("scroll",f)}},[r.viewport,a,d,i]),n.jsx(bt,{present:s||c!=="hidden",children:n.jsx(Sl,{"data-state":c==="hidden"?"hidden":"visible",...o,ref:t,onPointerEnter:ue(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:ue(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),lp=l.forwardRef((e,t)=>{const s=wt(Kt,e.__scopeScrollArea),{forceMount:o,...r}=e,[a,i]=l.useState(!1),c=e.orientation==="horizontal",d=Fr(()=>{if(s.viewport){const m=s.viewport.offsetWidth<s.viewport.scrollWidth,u=s.viewport.offsetHeight<s.viewport.scrollHeight;i(c?m:u)}},10);return ws(s.viewport,d),ws(s.content,d),n.jsx(bt,{present:o||a,children:n.jsx(Sl,{"data-state":a?"visible":"hidden",...r,ref:t})})}),Sl=l.forwardRef((e,t)=>{const{orientation:s="vertical",...o}=e,r=wt(Kt,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=pp(c.viewport,c.content),u={...o,sizes:c,onSizesChange:d,hasThumb:m>0&&m<1,onThumbChange:f=>a.current=f,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:f=>i.current=f};function p(f,h){return Cw(f,i.current,c,h)}return s==="horizontal"?n.jsx(yw,{...u,ref:t,onThumbPositionChange:()=>{if(r.viewport&&a.current){const f=r.viewport.scrollLeft,h=Ic(f,c,r.dir);a.current.style.transform=`translate3d(${h}px, 0, 0)`}},onWheelScroll:f=>{r.viewport&&(r.viewport.scrollLeft=f)},onDragScroll:f=>{r.viewport&&(r.viewport.scrollLeft=p(f,r.dir))}}):s==="vertical"?n.jsx(ww,{...u,ref:t,onThumbPositionChange:()=>{if(r.viewport&&a.current){const f=r.viewport.scrollTop,h=Ic(f,c);a.current.style.transform=`translate3d(0, ${h}px, 0)`}},onWheelScroll:f=>{r.viewport&&(r.viewport.scrollTop=f)},onDragScroll:f=>{r.viewport&&(r.viewport.scrollTop=p(f))}}):null}),yw=l.forwardRef((e,t)=>{const{sizes:s,onSizesChange:o,...r}=e,a=wt(Kt,e.__scopeScrollArea),[i,c]=l.useState(),d=l.useRef(null),m=Ae(t,d,a.onScrollbarXChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),n.jsx(dp,{"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":$r(s)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.x),onDragScroll:u=>e.onDragScroll(u.x),onWheelScroll:(u,p)=>{if(a.viewport){const f=a.viewport.scrollLeft+u.deltaX;e.onWheelScroll(f),hp(f,p)&&u.preventDefault()}},onResize:()=>{d.current&&a.viewport&&i&&o({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:dr(i.paddingLeft),paddingEnd:dr(i.paddingRight)}})}})}),ww=l.forwardRef((e,t)=>{const{sizes:s,onSizesChange:o,...r}=e,a=wt(Kt,e.__scopeScrollArea),[i,c]=l.useState(),d=l.useRef(null),m=Ae(t,d,a.onScrollbarYChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),n.jsx(dp,{"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":$r(s)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.y),onDragScroll:u=>e.onDragScroll(u.y),onWheelScroll:(u,p)=>{if(a.viewport){const f=a.viewport.scrollTop+u.deltaY;e.onWheelScroll(f),hp(f,p)&&u.preventDefault()}},onResize:()=>{d.current&&a.viewport&&i&&o({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:dr(i.paddingTop),paddingEnd:dr(i.paddingBottom)}})}})}),[jw,cp]=sp(Kt),dp=l.forwardRef((e,t)=>{const{__scopeScrollArea:s,sizes:o,hasThumb:r,onThumbChange:a,onThumbPointerUp:i,onThumbPointerDown:c,onThumbPositionChange:d,onDragScroll:m,onWheelScroll:u,onResize:p,...f}=e,h=wt(Kt,s),[g,b]=l.useState(null),y=Ae(t,b),w=l.useRef(null),v=l.useRef(""),j=h.viewport,S=o.content-o.viewport,N=Ye(u),C=Ye(d),E=Fr(p,10);function A(I){if(w.current){const R=I.clientX-w.current.left,k=I.clientY-w.current.top;m({x:R,y:k})}}return l.useEffect(()=>{const I=R=>{const k=R.target;g?.contains(k)&&N(R,S)};return document.addEventListener("wheel",I,{passive:!1}),()=>document.removeEventListener("wheel",I,{passive:!1})},[j,g,S,N]),l.useEffect(C,[o,C]),ws(g,E),ws(h.content,E),n.jsx(jw,{scope:s,scrollbar:g,hasThumb:r,onThumbChange:Ye(a),onThumbPointerUp:Ye(i),onThumbPositionChange:C,onThumbPointerDown:Ye(c),children:n.jsx(be.div,{...f,ref:y,style:{position:"absolute",...f.style},onPointerDown:ue(e.onPointerDown,I=>{I.button===0&&(I.target.setPointerCapture(I.pointerId),w.current=g.getBoundingClientRect(),v.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",h.viewport&&(h.viewport.style.scrollBehavior="auto"),A(I))}),onPointerMove:ue(e.onPointerMove,A),onPointerUp:ue(e.onPointerUp,I=>{const R=I.target;R.hasPointerCapture(I.pointerId)&&R.releasePointerCapture(I.pointerId),document.body.style.webkitUserSelect=v.current,h.viewport&&(h.viewport.style.scrollBehavior=""),w.current=null})})})}),cr="ScrollAreaThumb",up=l.forwardRef((e,t)=>{const{forceMount:s,...o}=e,r=cp(cr,e.__scopeScrollArea);return n.jsx(bt,{present:s||r.hasThumb,children:n.jsx(Sw,{ref:t,...o})})}),Sw=l.forwardRef((e,t)=>{const{__scopeScrollArea:s,style:o,...r}=e,a=wt(cr,s),i=cp(cr,s),{onThumbPositionChange:c}=i,d=Ae(t,i.onThumbChange),m=l.useRef(void 0),u=Fr(()=>{m.current&&(m.current(),m.current=void 0)},100);return l.useEffect(()=>{const p=a.viewport;if(p){const f=()=>{if(u(),!m.current){const h=kw(p,c);m.current=h,c()}};return c(),p.addEventListener("scroll",f),()=>p.removeEventListener("scroll",f)}},[a.viewport,u,c]),n.jsx(be.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:ue(e.onPointerDownCapture,p=>{const h=p.target.getBoundingClientRect(),g=p.clientX-h.left,b=p.clientY-h.top;i.onThumbPointerDown({x:g,y:b})}),onPointerUp:ue(e.onPointerUp,i.onThumbPointerUp)})});up.displayName=cr;var Nl="ScrollAreaCorner",mp=l.forwardRef((e,t)=>{const s=wt(Nl,e.__scopeScrollArea),o=!!(s.scrollbarX&&s.scrollbarY);return s.type!=="scroll"&&o?n.jsx(Nw,{...e,ref:t}):null});mp.displayName=Nl;var Nw=l.forwardRef((e,t)=>{const{__scopeScrollArea:s,...o}=e,r=wt(Nl,s),[a,i]=l.useState(0),[c,d]=l.useState(0),m=!!(a&&c),{onCornerWidthChange:u,onCornerHeightChange:p}=r;return ws(r.scrollbarX,()=>{const f=r.scrollbarX?.offsetHeight||0;r.onCornerHeightChange(f),d(f)}),ws(r.scrollbarY,()=>{const f=r.scrollbarY?.offsetWidth||0;r.onCornerWidthChange(f),i(f)}),l.useEffect(()=>()=>{u(0),p(0)},[u,p]),m?n.jsx(be.div,{...o,ref:t,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 dr(e){return e?parseInt(e,10):0}function pp(e,t){const s=e/t;return isNaN(s)?0:s}function $r(e){const t=pp(e.viewport,e.content),s=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,o=(e.scrollbar.size-s)*t;return Math.max(o,18)}function Cw(e,t,s,o="ltr"){const r=$r(s),a=r/2,i=t||a,c=r-i,d=s.scrollbar.paddingStart+i,m=s.scrollbar.size-s.scrollbar.paddingEnd-c,u=s.content-s.viewport,p=o==="ltr"?[0,u]:[u*-1,0];return fp([d,m],p)(e)}function Ic(e,t,s="ltr"){const o=$r(t),r=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-r,i=t.content-t.viewport,c=a-o,d=s==="ltr"?[0,i]:[i*-1,0],m=ui(e,d);return fp([0,i],[0,c])(m)}function fp(e,t){return s=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const o=(t[1]-t[0])/(e[1]-e[0]);return t[0]+o*(s-e[0])}}function hp(e,t){return e>0&&e<t}var kw=(e,t=()=>{})=>{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)&&t(),s=a,o=window.requestAnimationFrame(r)})(),()=>window.cancelAnimationFrame(o)};function Fr(e,t){const s=Ye(e),o=l.useRef(0);return l.useEffect(()=>()=>window.clearTimeout(o.current),[]),l.useCallback(()=>{window.clearTimeout(o.current),o.current=window.setTimeout(s,t)},[s,t])}function ws(e,t){const s=Ye(t);Ve(()=>{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 _w=op,Tw=ap,Ew=mp,Rw=[" ","Enter","ArrowUp","ArrowDown"],Mw=[" ","Enter"],Fn="Select",[Br,Ur,Aw]=Ku(Fn),[Hn]=on(Fn,[Aw,zr]),qr=zr(),[Iw,Cn]=Hn(Fn),[Pw,Lw]=Hn(Fn),Ow="SelectProvider";function xp(e){const{__scopeSelect:t,children:s,open:o,defaultOpen:r,onOpenChange:a,value:i,defaultValue:c,onValueChange:d,dir:m,name:u,autoComplete:p,disabled:f,required:h,form:g,internal_do_not_use_render:b}=e,y=qr(t),[w,v]=l.useState(null),[j,S]=l.useState(null),[N,C]=l.useState(!1),E=Er(m),[A,I]=zn({prop:o,defaultProp:r??!1,onChange:a,caller:Fn}),[R,k]=zn({prop:i,defaultProp:c,onChange:d,caller:Fn}),M=l.useRef(null),O=l.useRef(R);l.useEffect(()=>{const fe=g?w?.ownerDocument.getElementById(g):w?.form;if(fe instanceof HTMLFormElement){const je=()=>k(O.current);return fe.addEventListener("reset",je),()=>fe.removeEventListener("reset",je)}},[g,w,k]);const $=w?!!g||!!w.closest("form"):!0,[K,Q]=l.useState(new Set),z=Ft(),H=Array.from(K).map(fe=>fe.props.value).join(";"),ee=l.useCallback(fe=>{Q(je=>new Set(je).add(fe))},[]),U=l.useCallback(fe=>{Q(je=>{const he=new Set(je);return he.delete(fe),he})},[]),Z={required:h,trigger:w,onTriggerChange:v,valueNode:j,onValueNodeChange:S,valueNodeHasChildren:N,onValueNodeHasChildrenChange:C,contentId:z,value:R,onValueChange:k,open:A,onOpenChange:I,dir:E,triggerPointerDownPosRef:M,disabled:f,name:u,autoComplete:p,form:g,nativeOptions:K,nativeSelectKey:H,isFormControl:$};return n.jsx(Wm,{...y,children:n.jsx(Iw,{scope:t,...Z,children:n.jsx(Br.Provider,{scope:t,children:n.jsx(Pw,{scope:t,onNativeOptionAdd:ee,onNativeOptionRemove:U,children:Qw(b)?b(Z):s})})})})}xp.displayName=Ow;var gp=e=>{const{__scopeSelect:t,children:s,...o}=e;return n.jsx(xp,{__scopeSelect:t,...o,internal_do_not_use_render:({isFormControl:r})=>n.jsxs(n.Fragment,{children:[s,r?n.jsx(qp,{__scopeSelect:t}):null]})})};gp.displayName=Fn;var bp="SelectTrigger",vp=l.forwardRef((e,t)=>{const{__scopeSelect:s,disabled:o=!1,...r}=e,a=qr(s),i=Cn(bp,s),c=i.disabled||o,d=Ae(t,i.onTriggerChange),m=Ur(s),u=l.useRef("touch"),[p,f,h]=Hp(b=>{const y=m().filter(j=>!j.disabled),w=y.find(j=>j.value===i.value),v=Vp(y,b,w);v!==void 0&&i.onValueChange(v.value)}),g=b=>{c||(i.onOpenChange(!0),h()),b&&(i.triggerPointerDownPosRef.current={x:Math.round(b.pageX),y:Math.round(b.pageY)})};return n.jsx(Gm,{asChild:!0,...a,children:n.jsx(be.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":Hr(i.value)?"":void 0,...r,ref:d,onClick:ue(r.onClick,b=>{b.currentTarget.focus(),u.current!=="mouse"&&g(b)}),onPointerDown:ue(r.onPointerDown,b=>{u.current=b.pointerType;const y=b.target;y.hasPointerCapture(b.pointerId)&&y.releasePointerCapture(b.pointerId),b.button===0&&b.ctrlKey===!1&&b.pointerType==="mouse"&&(g(b),b.preventDefault())}),onKeyDown:ue(r.onKeyDown,b=>{const y=p.current!=="";!(b.ctrlKey||b.altKey||b.metaKey)&&b.key.length===1&&f(b.key),!(y&&b.key===" ")&&Rw.includes(b.key)&&(g(),b.preventDefault())})})})});vp.displayName=bp;var yp="SelectValue",wp=l.forwardRef((e,t)=>{const{__scopeSelect:s,className:o,style:r,children:a,placeholder:i="",...c}=e,d=Cn(yp,s),{onValueNodeHasChildrenChange:m}=d,u=a!==void 0,p=Ae(t,d.onValueNodeChange);Ve(()=>{m(u)},[m,u]);const f=Hr(d.value);return n.jsx(be.span,{...c,asChild:f?!1:c.asChild,ref:p,style:{pointerEvents:"none"},children:n.jsx(l.Fragment,{children:f?i:a},f?"placeholder":"value")})});wp.displayName=yp;var Dw="SelectIcon",jp=l.forwardRef((e,t)=>{const{__scopeSelect:s,children:o,...r}=e;return n.jsx(be.span,{"aria-hidden":!0,...r,ref:t,children:o||"▼"})});jp.displayName=Dw;var Sp="SelectPortal",[zw,$w]=Hn(Sp,{forceMount:void 0}),Np=e=>{const{__scopeSelect:t,forceMount:s,...o}=e;return n.jsx(zw,{scope:e.__scopeSelect,forceMount:s,children:n.jsx(Mr,{asChild:!0,...o})})};Np.displayName=Sp;var Sn="SelectContent",Cp=l.forwardRef((e,t)=>{const s=$w(Sn,e.__scopeSelect),{forceMount:o=s.forceMount,...r}=e,a=Cn(Sn,e.__scopeSelect),[i,c]=l.useState();return Ve(()=>{c(new DocumentFragment)},[]),n.jsx(bt,{present:o||a.open,children:({present:d})=>d?n.jsx(Tp,{...r,ref:t}):n.jsx(kp,{...r,fragment:i})})});Cp.displayName=Sn;var kp=l.forwardRef((e,t)=>{const{__scopeSelect:s,children:o,fragment:r}=e;return r?Cs.createPortal(n.jsx(_p,{scope:s,children:n.jsx(Br.Slot,{scope:s,children:n.jsx("div",{ref:t,children:o})})}),r):null});kp.displayName="SelectContentFragment";var _t=10,[_p,kn]=Hn(Sn),Fw="SelectContentImpl",Bw=bs("SelectContent.RemoveScroll"),Tp=l.forwardRef((e,t)=>{const{__scopeSelect:s}=e,{position:o="item-aligned",onCloseAutoFocus:r,onEscapeKeyDown:a,onPointerDownOutside:i,side:c,sideOffset:d,align:m,alignOffset:u,arrowPadding:p,collisionBoundary:f,collisionPadding:h,sticky:g,hideWhenDetached:b,avoidCollisions:y,...w}=e,v=Cn(Sn,s),[j,S]=l.useState(null),[N,C]=l.useState(null),E=Ae(t,S),[A,I]=l.useState(null),[R,k]=l.useState(null),M=Ur(s),[O,$]=l.useState(!1),K=l.useRef(!1);l.useEffect(()=>{if(j)return dm(j)},[j]),tm();const Q=l.useCallback(J=>{const[Se,...Te]=M().map(ce=>ce.ref.current),[ge]=Te.slice(-1),le=document.activeElement;for(const ce of J)if(ce===le||(ce?.scrollIntoView({block:"nearest"}),ce===Se&&N&&(N.scrollTop=0),ce===ge&&N&&(N.scrollTop=N.scrollHeight),ce?.focus(),document.activeElement!==le))return},[M,N]),z=l.useCallback(()=>Q([A,j]),[Q,A,j]);l.useEffect(()=>{O&&z()},[O,z]);const{onOpenChange:H,triggerPointerDownPosRef:ee}=v;l.useEffect(()=>{if(j){let J={x:0,y:0};const Se=ge=>{J={x:Math.abs(Math.round(ge.pageX)-(ee.current?.x??0)),y:Math.abs(Math.round(ge.pageY)-(ee.current?.y??0))}},Te=ge=>{J.x<=10&&J.y<=10?ge.preventDefault():ge.composedPath().includes(j)||H(!1),document.removeEventListener("pointermove",Se),ee.current=null};return ee.current!==null&&(document.addEventListener("pointermove",Se),document.addEventListener("pointerup",Te,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Se),document.removeEventListener("pointerup",Te,{capture:!0})}}},[j,H,ee]),l.useEffect(()=>{const J=()=>H(!1);return window.addEventListener("blur",J),window.addEventListener("resize",J),()=>{window.removeEventListener("blur",J),window.removeEventListener("resize",J)}},[H]);const[U,Z]=Hp(J=>{const Se=M().filter(le=>!le.disabled),Te=Se.find(le=>le.ref.current===document.activeElement),ge=Vp(Se,J,Te);ge&&setTimeout(()=>ge.ref.current?.focus())}),fe=l.useCallback((J,Se,Te)=>{const ge=!K.current&&!Te;(v.value!==void 0&&v.value===Se||ge)&&(I(J),ge&&(K.current=!0))},[v.value]),je=l.useCallback(()=>j?.focus(),[j]),he=l.useCallback((J,Se,Te)=>{const ge=!K.current&&!Te;(v.value!==void 0&&v.value===Se||ge)&&k(J)},[v.value]),oe=o==="popper"?mi:Ep,L=oe===mi?{side:c,sideOffset:d,align:m,alignOffset:u,arrowPadding:p,collisionBoundary:f,collisionPadding:h,sticky:g,hideWhenDetached:b,avoidCollisions:y}:{};return n.jsx(_p,{scope:s,content:j,viewport:N,onViewportChange:C,itemRefCallback:fe,selectedItem:A,onItemLeave:je,itemTextRefCallback:he,focusSelectedItem:z,selectedItemText:R,position:o,isPositioned:O,searchRef:U,children:n.jsx(dl,{as:Bw,allowPinchZoom:!0,children:n.jsx(cl,{asChild:!0,trapped:v.open,onMountAutoFocus:J=>{J.preventDefault()},onUnmountAutoFocus:ue(r,J=>{v.trigger?.focus({preventScroll:!0}),J.preventDefault()}),children:n.jsx(Rr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:J=>J.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:n.jsx(oe,{role:"listbox",id:v.contentId,"data-state":v.open?"open":"closed",dir:v.dir,onContextMenu:J=>J.preventDefault(),...w,...L,onPlaced:()=>$(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...w.style},onKeyDown:ue(w.onKeyDown,J=>{const Se=J.ctrlKey||J.altKey||J.metaKey;if(J.key==="Tab"&&J.preventDefault(),!Se&&J.key.length===1&&Z(J.key),["ArrowUp","ArrowDown","Home","End"].includes(J.key)){let ge=M().filter(le=>!le.disabled).map(le=>le.ref.current);if(["ArrowUp","End"].includes(J.key)&&(ge=ge.slice().reverse()),["ArrowUp","ArrowDown"].includes(J.key)){const le=J.target,ce=ge.indexOf(le);ge=ge.slice(ce+1)}setTimeout(()=>Q(ge)),J.preventDefault()}})})})})})})});Tp.displayName=Fw;var Uw="SelectItemAlignedPosition",Ep=l.forwardRef((e,t)=>{const{__scopeSelect:s,onPlaced:o,...r}=e,a=Cn(Sn,s),i=kn(Sn,s),[c,d]=l.useState(null),[m,u]=l.useState(null),p=Ae(t,u),f=Ur(s),h=l.useRef(!1),g=l.useRef(!0),{viewport:b,selectedItem:y,selectedItemText:w,focusSelectedItem:v}=i,j=l.useCallback(()=>{if(a.trigger&&a.valueNode&&c&&m&&b&&y&&w){const E=a.trigger.getBoundingClientRect(),A=m.getBoundingClientRect(),I=a.valueNode.getBoundingClientRect(),R=w.getBoundingClientRect();if(a.dir!=="rtl"){const le=R.left-A.left,ce=I.left-le,Pe=E.left-ce,Re=E.width+Pe,$e=Math.max(Re,A.width),lt=window.innerWidth-_t,He=ui(ce,[_t,Math.max(_t,lt-$e)]);c.style.minWidth=Re+"px",c.style.left=He+"px"}else{const le=A.right-R.right,ce=window.innerWidth-I.right-le,Pe=window.innerWidth-E.right-ce,Re=E.width+Pe,$e=Math.max(Re,A.width),lt=window.innerWidth-_t,He=ui(ce,[_t,Math.max(_t,lt-$e)]);c.style.minWidth=Re+"px",c.style.right=He+"px"}const k=f(),M=window.innerHeight-_t*2,O=b.scrollHeight,$=window.getComputedStyle(m),K=parseInt($.borderTopWidth,10),Q=parseInt($.paddingTop,10),z=parseInt($.borderBottomWidth,10),H=parseInt($.paddingBottom,10),ee=K+Q+O+H+z,U=Math.min(y.offsetHeight*5,ee),Z=window.getComputedStyle(b),fe=parseInt(Z.paddingTop,10),je=parseInt(Z.paddingBottom,10),he=E.top+E.height/2-_t,oe=M-he,L=y.offsetHeight/2,J=y.offsetTop+L,Se=K+Q+J,Te=ee-Se;if(Se<=he){const le=k.length>0&&y===k[k.length-1].ref.current;c.style.bottom="0px";const ce=m.clientHeight-b.offsetTop-b.offsetHeight,Pe=Math.max(oe,L+(le?je:0)+ce+z),Re=Se+Pe;c.style.height=Re+"px"}else{const le=k.length>0&&y===k[0].ref.current;c.style.top="0px";const Pe=Math.max(he,K+b.offsetTop+(le?fe:0)+L)+Te;c.style.height=Pe+"px",b.scrollTop=Se-he+b.offsetTop}c.style.margin=`${_t}px 0`,c.style.minHeight=U+"px",c.style.maxHeight=M+"px",o?.(),requestAnimationFrame(()=>h.current=!0)}},[f,a.trigger,a.valueNode,c,m,b,y,w,a.dir,o]);Ve(()=>j(),[j]);const[S,N]=l.useState();Ve(()=>{m&&N(window.getComputedStyle(m).zIndex)},[m]);const C=l.useCallback(E=>{E&&g.current===!0&&(j(),v?.(),g.current=!1)},[j,v]);return n.jsx(Hw,{scope:s,contentWrapper:c,shouldExpandOnScrollRef:h,onScrollButtonChange:C,children:n.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:S},children:n.jsx(be.div,{...r,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...r.style}})})})});Ep.displayName=Uw;var qw="SelectPopperPosition",mi=l.forwardRef((e,t)=>{const{__scopeSelect:s,align:o="start",collisionPadding:r=_t,...a}=e,i=qr(s);return n.jsx(Km,{...i,...a,ref:t,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)"}})});mi.displayName=qw;var[Hw,Cl]=Hn(Sn,{}),pi="SelectViewport",Rp=l.forwardRef((e,t)=>{const{__scopeSelect:s,nonce:o,...r}=e,a=kn(pi,s),i=Cl(pi,s),c=Ae(t,a.onViewportChange),d=l.useRef(0);return n.jsxs(n.Fragment,{children:[n.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}),n.jsx(Br.Slot,{scope:s,children:n.jsx(be.div,{"data-radix-select-viewport":"",role:"presentation",...r,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...r.style},onScroll:ue(r.onScroll,m=>{const u=m.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:f}=i;if(f?.current&&p){const h=Math.abs(d.current-u.scrollTop);if(h>0){const g=window.innerHeight-_t*2,b=parseFloat(p.style.minHeight),y=parseFloat(p.style.height),w=Math.max(b,y);if(w<g){const v=w+h,j=Math.min(g,v),S=v-j;p.style.height=j+"px",p.style.bottom==="0px"&&(u.scrollTop=S>0?S:0,p.style.justifyContent="flex-end")}}}d.current=u.scrollTop})})})]})});Rp.displayName=pi;var Mp="SelectGroup",[Vw,Ww]=Hn(Mp),Gw=l.forwardRef((e,t)=>{const{__scopeSelect:s,...o}=e,r=Ft();return n.jsx(Vw,{scope:s,id:r,children:n.jsx(be.div,{role:"group","aria-labelledby":r,...o,ref:t})})});Gw.displayName=Mp;var Ap="SelectLabel",Kw=l.forwardRef((e,t)=>{const{__scopeSelect:s,...o}=e,r=Ww(Ap,s);return n.jsx(be.div,{id:r.id,...o,ref:t})});Kw.displayName=Ap;var ur="SelectItem",[Yw,Ip]=Hn(ur),Pp=l.forwardRef((e,t)=>{const{__scopeSelect:s,value:o,disabled:r=!1,textValue:a,...i}=e,c=Cn(ur,s),d=kn(ur,s),m=c.value===o,[u,p]=l.useState(a??""),[f,h]=l.useState(!1),g=Ye(j=>d.itemRefCallback?.(j,o,r)),b=Ae(t,g),y=Ft(),w=l.useRef("touch"),v=()=>{r||(c.onValueChange(o),c.onOpenChange(!1))};return n.jsx(Yw,{scope:s,value:o,disabled:r,textId:y,isSelected:m,onItemTextChange:l.useCallback(j=>{p(S=>S||(j?.textContent??"").trim())},[]),children:n.jsx(Br.ItemSlot,{scope:s,value:o,disabled:r,textValue:u,children:n.jsx(be.div,{role:"option","aria-labelledby":y,"data-highlighted":f?"":void 0,"aria-selected":m&&f,"data-state":m?"checked":"unchecked","aria-disabled":r||void 0,"data-disabled":r?"":void 0,tabIndex:r?void 0:-1,...i,ref:b,onFocus:ue(i.onFocus,()=>h(!0)),onBlur:ue(i.onBlur,()=>h(!1)),onClick:ue(i.onClick,()=>{w.current!=="mouse"&&v()}),onPointerUp:ue(i.onPointerUp,()=>{w.current==="mouse"&&v()}),onPointerDown:ue(i.onPointerDown,j=>{w.current=j.pointerType}),onPointerMove:ue(i.onPointerMove,j=>{w.current=j.pointerType,r?d.onItemLeave?.():w.current==="mouse"&&j.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ue(i.onPointerLeave,j=>{j.currentTarget===document.activeElement&&d.onItemLeave?.()}),onKeyDown:ue(i.onKeyDown,j=>{r||j.target!==j.currentTarget||d.searchRef?.current!==""&&j.key===" "||(Mw.includes(j.key)&&v(),j.key===" "&&j.preventDefault())})})})})});Pp.displayName=ur;var zs="SelectItemText",Lp=l.forwardRef((e,t)=>{const{__scopeSelect:s,className:o,style:r,...a}=e,i=Cn(zs,s),c=kn(zs,s),d=Ip(zs,s),m=Lw(zs,s),[u,p]=l.useState(null),f=Ye(v=>c.itemTextRefCallback?.(v,d.value,d.disabled)),h=Ae(t,p,d.onItemTextChange,f),g=u?.textContent,b=l.useMemo(()=>n.jsx("option",{value:d.value,disabled:d.disabled,children:g},d.value),[d.disabled,d.value,g]),{onNativeOptionAdd:y,onNativeOptionRemove:w}=m;return Ve(()=>(y(b),()=>w(b)),[y,w,b]),n.jsxs(n.Fragment,{children:[n.jsx(be.span,{id:d.textId,...a,ref:h}),d.isSelected&&i.valueNode&&!i.valueNodeHasChildren&&!Hr(i.value)?Cs.createPortal(a.children,i.valueNode):null]})});Lp.displayName=zs;var Op="SelectItemIndicator",Dp=l.forwardRef((e,t)=>{const{__scopeSelect:s,...o}=e;return Ip(Op,s).isSelected?n.jsx(be.span,{"aria-hidden":!0,...o,ref:t}):null});Dp.displayName=Op;var fi="SelectScrollUpButton",zp=l.forwardRef((e,t)=>{const s=kn(fi,e.__scopeSelect),o=Cl(fi,e.__scopeSelect),[r,a]=l.useState(!1),i=Ae(t,o.onScrollButtonChange);return Ve(()=>{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?n.jsx(Fp,{...e,ref:i,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=s;c&&d&&(c.scrollTop=c.scrollTop-d.offsetHeight)}}):null});zp.displayName=fi;var hi="SelectScrollDownButton",$p=l.forwardRef((e,t)=>{const s=kn(hi,e.__scopeSelect),o=Cl(hi,e.__scopeSelect),[r,a]=l.useState(!1),i=Ae(t,o.onScrollButtonChange);return Ve(()=>{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?n.jsx(Fp,{...e,ref:i,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=s;c&&d&&(c.scrollTop=c.scrollTop+d.offsetHeight)}}):null});$p.displayName=hi;var Fp=l.forwardRef((e,t)=>{const{__scopeSelect:s,onAutoScroll:o,...r}=e,a=kn("SelectScrollButton",s),i=l.useRef(null),c=Ur(s),d=l.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return l.useEffect(()=>()=>d(),[d]),Ve(()=>{c().find(u=>u.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[c]),n.jsx(be.div,{"aria-hidden":!0,...r,ref:t,style:{flexShrink:0,...r.style},onPointerDown:ue(r.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(o,50))}),onPointerMove:ue(r.onPointerMove,()=>{a.onItemLeave?.(),i.current===null&&(i.current=window.setInterval(o,50))}),onPointerLeave:ue(r.onPointerLeave,()=>{d()})})}),Jw="SelectSeparator",Xw=l.forwardRef((e,t)=>{const{__scopeSelect:s,...o}=e;return n.jsx(be.div,{"aria-hidden":!0,...o,ref:t})});Xw.displayName=Jw;var Bp="SelectArrow",Zw=l.forwardRef((e,t)=>{const{__scopeSelect:s,...o}=e,r=qr(s);return kn(Bp,s).position==="popper"?n.jsx(Ym,{...r,...o,ref:t}):null});Zw.displayName=Bp;var Up="SelectBubbleInput",qp=l.forwardRef(({__scopeSelect:e,...t},s)=>{const o=Cn(Up,e),{value:r,onValueChange:a,required:i,disabled:c,name:d,autoComplete:m,form:u}=o,{nativeOptions:p,nativeSelectKey:f}=o,h=l.useRef(null),g=Ae(s,h),b=r??"",y=A2(b),w=Array.from(p).some(v=>(v.props.value??"")==="");return l.useEffect(()=>{const v=h.current;if(!v)return;const j=window.HTMLSelectElement.prototype,N=Object.getOwnPropertyDescriptor(j,"value").set;if(y!==b&&N){const C=new Event("change",{bubbles:!0});N.call(v,b),v.dispatchEvent(C)}},[y,b]),n.jsxs(be.select,{"aria-hidden":!0,required:i,tabIndex:-1,name:d,autoComplete:m,disabled:c,form:u,onChange:v=>a(v.target.value),...t,style:{...Wu,...t.style},ref:g,defaultValue:b,children:[Hr(r)&&!w?n.jsx("option",{value:""}):null,Array.from(p)]},f)});qp.displayName=Up;function Qw(e){return typeof e=="function"}function Hr(e){return e===""||e===void 0}function Hp(e){const t=Ye(e),s=l.useRef(""),o=l.useRef(0),r=l.useCallback(i=>{const c=s.current+i;t(c),(function d(m){s.current=m,window.clearTimeout(o.current),m!==""&&(o.current=window.setTimeout(()=>d(""),1e3))})(c)},[t]),a=l.useCallback(()=>{s.current="",window.clearTimeout(o.current)},[]);return l.useEffect(()=>()=>window.clearTimeout(o.current),[]),[s,r,a]}function Vp(e,t,s){const r=t.length>1&&Array.from(t).every(m=>m===t[0])?t[0]:t,a=s?e.indexOf(s):-1;let i=ej(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 ej(e,t){return e.map((s,o)=>e[(t+o)%e.length])}var Vr="Tabs",[tj]=on(Vr,[Zm]),Wp=Zm(),[nj,kl]=tj(Vr),Gp=l.forwardRef((e,t)=>{const{__scopeTabs:s,value:o,onValueChange:r,defaultValue:a,orientation:i="horizontal",dir:c,activationMode:d="automatic",...m}=e,u=Er(c),[p,f]=zn({prop:o,onChange:r,defaultProp:a??"",caller:Vr});return n.jsx(nj,{scope:s,baseId:Ft(),value:p,onValueChange:f,orientation:i,dir:u,activationMode:d,children:n.jsx(be.div,{dir:u,"data-orientation":i,...m,ref:t})})});Gp.displayName=Vr;var Kp="TabsList",Yp=l.forwardRef((e,t)=>{const{__scopeTabs:s,loop:o=!0,...r}=e,a=kl(Kp,s),i=Wp(s);return n.jsx(pw,{asChild:!0,...i,orientation:a.orientation,dir:a.dir,loop:o,children:n.jsx(be.div,{role:"tablist","aria-orientation":a.orientation,...r,ref:t})})});Yp.displayName=Kp;var Jp="TabsTrigger",Xp=l.forwardRef((e,t)=>{const{__scopeTabs:s,value:o,disabled:r=!1,...a}=e,i=kl(Jp,s),c=Wp(s),d=ef(i.baseId,o),m=tf(i.baseId,o),u=o===i.value;return n.jsx(fw,{asChild:!0,...c,focusable:!r,active:u,children:n.jsx(be.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:t,onMouseDown:ue(e.onMouseDown,p=>{!r&&p.button===0&&p.ctrlKey===!1?i.onValueChange(o):p.preventDefault()}),onKeyDown:ue(e.onKeyDown,p=>{r||p.target!==p.currentTarget||[" ","Enter"].includes(p.key)&&i.onValueChange(o)}),onFocus:ue(e.onFocus,()=>{const p=i.activationMode!=="manual";!u&&!r&&p&&i.onValueChange(o)})})})});Xp.displayName=Jp;var Zp="TabsContent",Qp=l.forwardRef((e,t)=>{const{__scopeTabs:s,value:o,forceMount:r,children:a,...i}=e,c=kl(Zp,s),d=ef(c.baseId,o),m=tf(c.baseId,o),u=o===c.value,p=l.useRef(u);return l.useEffect(()=>{const f=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(f)},[]),n.jsx(bt,{present:r||u,children:({present:f})=>n.jsx(be.div,{"data-state":u?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":d,hidden:!f,id:m,tabIndex:0,...i,ref:t,style:{...e.style,animationDuration:p.current?"0s":void 0},children:f&&a})})});Qp.displayName=Zp;function ef(e,t){return`${e}-trigger-${t}`}function tf(e,t){return`${e}-content-${t}`}var sj=Gp,oj=Yp,rj=Xp,aj=Qp,[Wr]=on("Tooltip",[zr]),Gr=zr(),nf="TooltipProvider",ij=700,xi="tooltip.open",[lj,_l]=Wr(nf),sf=e=>{const{__scopeTooltip:t,delayDuration:s=ij,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)},[]),n.jsx(lj,{scope:t,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})};sf.displayName=nf;var Gs="Tooltip",[cj,ao]=Wr(Gs),of=e=>{const{__scopeTooltip:t,children:s,open:o,defaultOpen:r,onOpenChange:a,disableHoverableContent:i,delayDuration:c}=e,d=_l(Gs,e.__scopeTooltip),m=Gr(t),[u,p]=l.useState(null),f=Ft(),h=l.useRef(0),g=i??d.disableHoverableContent,b=c??d.delayDuration,y=l.useRef(!1),[w,v]=zn({prop:o,defaultProp:r??!1,onChange:E=>{E?(d.onOpen(),document.dispatchEvent(new CustomEvent(xi))):d.onClose(),a?.(E)},caller:Gs}),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,v(!0)},[v]),N=l.useCallback(()=>{window.clearTimeout(h.current),h.current=0,v(!1)},[v]),C=l.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{y.current=!0,v(!0),h.current=0},b)},[b,v]);return l.useEffect(()=>()=>{h.current&&(window.clearTimeout(h.current),h.current=0)},[]),n.jsx(Wm,{...m,children:n.jsx(cj,{scope:t,contentId:f,open:w,stateAttribute:j,trigger:u,onTriggerChange:p,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})})};of.displayName=Gs;var gi="TooltipTrigger",rf=l.forwardRef((e,t)=>{const{__scopeTooltip:s,...o}=e,r=ao(gi,s),a=_l(gi,s),i=Gr(s),c=l.useRef(null),d=Ae(t,c,r.onTriggerChange),m=l.useRef(!1),u=l.useRef(!1),p=l.useCallback(()=>m.current=!1,[]);return l.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),n.jsx(Gm,{asChild:!0,...i,children:n.jsx(be.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...o,ref:d,onPointerMove:ue(e.onPointerMove,f=>{f.pointerType!=="touch"&&!u.current&&!a.isPointerInTransitRef.current&&(r.onTriggerEnter(),u.current=!0)}),onPointerLeave:ue(e.onPointerLeave,()=>{r.onTriggerLeave(),u.current=!1}),onPointerDown:ue(e.onPointerDown,()=>{r.open&&r.onClose(),m.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:ue(e.onFocus,()=>{m.current||r.onOpen()}),onBlur:ue(e.onBlur,r.onClose),onClick:ue(e.onClick,r.onClose)})})});rf.displayName=gi;var Tl="TooltipPortal",[dj,uj]=Wr(Tl,{forceMount:void 0}),af=e=>{const{__scopeTooltip:t,forceMount:s,children:o,container:r}=e,a=ao(Tl,t);return n.jsx(dj,{scope:t,forceMount:s,children:n.jsx(bt,{present:s||a.open,children:n.jsx(Mr,{asChild:!0,container:r,children:o})})})};af.displayName=Tl;var js="TooltipContent",lf=l.forwardRef((e,t)=>{const s=uj(js,e.__scopeTooltip),{forceMount:o=s.forceMount,side:r="top",...a}=e,i=ao(js,e.__scopeTooltip);return n.jsx(bt,{present:o||i.open,children:i.disableHoverableContent?n.jsx(cf,{side:r,...a,ref:t}):n.jsx(mj,{side:r,...a,ref:t})})}),mj=l.forwardRef((e,t)=>{const s=ao(js,e.__scopeTooltip),o=_l(js,e.__scopeTooltip),r=l.useRef(null),a=Ae(t,r),[i,c]=l.useState(null),{trigger:d,onClose:m}=s,u=r.current,{onPointerInTransitChange:p}=o,f=l.useCallback(()=>{c(null),p(!1)},[p]),h=l.useCallback((g,b)=>{const y=g.currentTarget,w={x:g.clientX,y:g.clientY},v=xj(w,y.getBoundingClientRect()),j=gj(w,v),S=bj(b.getBoundingClientRect()),N=yj([...j,...S]);c(N),p(!0)},[p]);return l.useEffect(()=>()=>f(),[f]),l.useEffect(()=>{if(d&&u){const g=y=>h(y,u),b=y=>h(y,d);return d.addEventListener("pointerleave",g),u.addEventListener("pointerleave",b),()=>{d.removeEventListener("pointerleave",g),u.removeEventListener("pointerleave",b)}}},[d,u,h,f]),l.useEffect(()=>{if(i){const g=b=>{const y=b.target,w={x:b.clientX,y:b.clientY},v=d?.contains(y)||u?.contains(y),j=!vj(w,i);v?f():j&&(f(),m())};return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}},[d,u,i,m,f]),n.jsx(cf,{...e,ref:a})}),[pj,fj]=Wr(Gs,{isInside:!1}),hj=Jb("TooltipContent"),cf=l.forwardRef((e,t)=>{const{__scopeTooltip:s,children:o,"aria-label":r,onEscapeKeyDown:a,onPointerDownOutside:i,...c}=e,d=ao(js,s),m=Gr(s),{onClose:u}=d;return l.useEffect(()=>(document.addEventListener(xi,u),()=>document.removeEventListener(xi,u)),[u]),l.useEffect(()=>{if(d.trigger){const p=f=>{f.target instanceof Node&&f.target.contains(d.trigger)&&u()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[d.trigger,u]),n.jsx(Rr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:p=>p.preventDefault(),onDismiss:u,children:n.jsxs(Km,{"data-state":d.stateAttribute,...m,...c,ref:t,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:[n.jsx(hj,{children:o}),n.jsx(pj,{scope:s,isInside:!0,children:n.jsx(lv,{id:d.contentId,role:"tooltip",children:r||o})})]})})});lf.displayName=js;var df="TooltipArrow",uf=l.forwardRef((e,t)=>{const{__scopeTooltip:s,...o}=e,r=Gr(s);return fj(df,s).isInside?null:n.jsx(Ym,{...r,...o,ref:t})});uf.displayName=df;function xj(e,t){const s=Math.abs(t.top-e.y),o=Math.abs(t.bottom-e.y),r=Math.abs(t.right-e.x),a=Math.abs(t.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 gj(e,t,s=5){const o=[];switch(t){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 bj(e){const{top:t,right:s,bottom:o,left:r}=e;return[{x:r,y:t},{x:s,y:t},{x:s,y:o},{x:r,y:o}]}function vj(e,t){const{x:s,y:o}=e;let r=!1;for(let a=0,i=t.length-1;a<t.length;i=a++){const c=t[a],d=t[i],m=c.x,u=c.y,p=d.x,f=d.y;u>o!=f>o&&s<(p-m)*(o-u)/(f-u)+m&&(r=!r)}return r}function yj(e){const t=e.slice();return t.sort((s,o)=>s.x<o.x?-1:s.x>o.x?1:s.y<o.y?-1:s.y>o.y?1:0),wj(t)}function wj(e){if(e.length<=1)return e.slice();const t=[];for(let o=0;o<e.length;o++){const r=e[o];for(;t.length>=2;){const a=t[t.length-1],i=t[t.length-2];if((a.x-i.x)*(r.y-i.y)>=(a.y-i.y)*(r.x-i.x))t.pop();else break}t.push(r)}t.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(),t.length===1&&s.length===1&&t[0].x===s[0].x&&t[0].y===s[0].y?t:t.concat(s)}var jj=sf,Sj=of,Nj=rf,Cj=af,kj=lf,_j=uf;function qt({...e}){return n.jsx(mm,{"data-slot":"dialog",...e})}function io({...e}){return n.jsx(fm,{"data-slot":"dialog-trigger",...e})}function Tj({...e}){return n.jsx(xm,{"data-slot":"dialog-portal",...e})}function Ej({className:e,...t}){return n.jsx(gm,{"data-slot":"dialog-overlay",className:P("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),...t})}function Ht({className:e,children:t,...s}){return n.jsxs(Tj,{children:[n.jsx(Ej,{}),n.jsxs(bm,{"data-slot":"dialog-content",className:P("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:[t,n.jsxs(Cm,{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:[n.jsx(so,{className:"size-4"}),n.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Yt({className:e,...t}){return n.jsx("div",{"data-slot":"dialog-header",className:P("flex flex-col space-y-1.5 text-center sm:text-left",e),...t})}function Jt({className:e,...t}){return n.jsx(wm,{"data-slot":"dialog-title",className:P("text-lg font-semibold leading-none tracking-tight",e),...t})}function lo({className:e,...t}){return n.jsx(Sm,{"data-slot":"dialog-description",className:P("text-sm text-muted-foreground",e),...t})}function mf({open:e,onOpenChange:t,title:s,description:o,confirmLabel:r="Confirm",variant:a="default",onConfirm:i}){return n.jsx(qt,{open:e,onOpenChange:t,children:n.jsxs(Ht,{children:[n.jsx(Yt,{children:n.jsx(Jt,{children:s})}),n.jsx("p",{className:"text-sm text-muted-foreground",children:o}),n.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[n.jsx(te,{variant:"outline",size:"sm",onClick:()=>t(!1),children:"Cancel"}),n.jsx(te,{variant:a,size:"sm",onClick:()=>{i(),t(!1)},children:r})]})]})})}const Rj="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",Mj="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",Aj="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",Ij="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",Pj=""+new URL("agent-inspector-58K1_MsC.ico",import.meta.url).href,Lj={"agent-inspector":"Inspector",codex:"Codex",opencode:"OpenCode","mimo-code":"MiMo Code","claude-code":"Claude Code","ai-sdk":"AI SDK"};function jo(e){return e?.toLowerCase()??""}function Qn(e,t){for(const s of t)if(e.includes(s))return!0;return!1}function El(e){const t=[jo(e.userAgent),jo(e.conversationId),jo(e.clientProjectFolder)].join(" ");return Qn(t,["agent-inspector","agent inspector","provider-test"])?"agent-inspector":Qn(t,["mimocode","mimo-code","mimo code"])?"mimo-code":Qn(t,["opencode","open-code","open code"])?"opencode":Qn(t,["claude-code","claude code","claudecode","claude-cli","claude cli"])?"claude-code":Qn(t,["codex desktop","codex-cli","openai-codex","codex"])?"codex":Qn(jo(e.userAgent),["ai-sdk","ai/"])?"ai-sdk":"unknown"}function Kr(e){switch(e){case"agent-inspector":case"codex":case"opencode":case"mimo-code":case"claude-code":case"ai-sdk":return Lj[e];case"unknown":return null}}function Oj(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 Dj={"agent-inspector":Pj,codex:Mj,opencode:Aj,"mimo-code":Ij,"claude-code":Rj},zj={"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]"},$j={"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 Yr({client:e,className:t,decorative:s=!1}){if(e==="unknown")return null;const o=Kr(e);if(o===null)return null;if(e==="ai-sdk")return n.jsx("span",{className:P("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]",t),"aria-label":s?void 0:o,"aria-hidden":s?!0:void 0,title:o,children:n.jsx(Eu,{className:"size-1/2","aria-hidden":"true"})});const r=Dj[e];return n.jsx("span",{className:P("inline-flex size-6 shrink-0 items-center justify-center rounded-md border p-0 shadow-sm",zj[e],t),"aria-label":s?void 0:o,"aria-hidden":s?!0:void 0,title:o,children:n.jsx("img",{src:r,alt:"",className:P("size-full object-contain",$j[e]),"aria-hidden":"true"})})}const Fj="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",Bj="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",Uj="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",qj=""+new URL("minimax-BPMzvuL-.jpeg",import.meta.url).href,Hj=""+new URL("alibaba-TTwafVwX.svg",import.meta.url).href,Vj=""+new URL("qwen-mMn3f5ul.webp",import.meta.url).href,Wj=""+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 Kj(e){return e.replace(/[_\s]+/g,"-").split(/[/:@]/).some(s=>s.startsWith("glm-"))}function Yj(e){if(e===null)return"unknown";const t=e.toLowerCase();if(Kj(t))return"zhipuai";for(const[s,o]of Object.entries(Gj))if(t.startsWith(s.toLowerCase()))return o;return"unknown"}const Vn={width:24,height:24,objectFit:"contain"},Jj=Un.memo(({className:e})=>n.jsx("img",{src:Fj,alt:"Anthropic",className:e,style:Vn})),Xj=Un.memo(({className:e})=>n.jsx("img",{src:Bj,alt:"OpenAI",className:e,style:{...Vn,background:"white",borderRadius:"4px"}})),Zj=Un.memo(({className:e})=>n.jsx("img",{src:Uj,alt:"DeepSeek",className:e,style:Vn})),Qj=Un.memo(({className:e})=>n.jsx("img",{src:qj,alt:"MiniMax",className:e,style:Vn})),e5=Un.memo(({className:e})=>n.jsx("img",{src:Hj,alt:"Alibaba",className:e,style:Vn})),t5=Un.memo(({className:e})=>n.jsx("img",{src:Vj,alt:"Qwen",className:e,style:Vn})),n5=Un.memo(({className:e})=>n.jsx("img",{src:Wj,alt:"ZhipuAI",className:e,style:Vn}));function s5({provider:e,className:t}){switch(e){case"anthropic":return n.jsx(Jj,{className:t});case"openai":return n.jsx(Xj,{className:t});case"deepseek":return n.jsx(Zj,{className:t});case"minimax":return n.jsx(Qj,{className:t});case"alibaba":return n.jsx(e5,{className:t});case"qwen":return n.jsx(t5,{className:t});case"zhipuai":return n.jsx(n5,{className:t});case"unknown":return null}}function Ts({delayDuration:e=600,...t}){return n.jsx(jj,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function dt({...e}){return n.jsx(Sj,{"data-slot":"tooltip",...e})}function ut({...e}){return n.jsx(Nj,{"data-slot":"tooltip-trigger",...e})}function mt({className:e,sideOffset:t=0,children:s,...o}){return n.jsx(Cj,{children:n.jsxs(kj,{"data-slot":"tooltip-content",sideOffset:t,className:P("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,n.jsx(_j,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}const o5=3;function r5({items:e,ariaLabel:t,className:s}){if(e.length===0)return n.jsx("span",{className:P("flex h-8 w-12 shrink-0 items-center",s),"aria-hidden":"true"});const o=e.slice(0,o5),r=e.length-o.length;return n.jsx(Ts,{delayDuration:150,children:n.jsxs("span",{className:P("flex h-8 w-12 shrink-0 items-center",s),"aria-label":t,children:[o.map((a,i)=>n.jsxs(dt,{children:[n.jsx(ut,{asChild:!0,children:n.jsx("span",{className:P("border border-border bg-muted/40 inline-flex size-6 shrink-0 items-center justify-center rounded-md",i>0&&"-ml-2"),children:n.jsx(s5,{provider:a.provider,className:"size-4"})})}),n.jsx(mt,{children:a.tooltip})]},`${a.provider}-${String(i)}`)),r>0&&n.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 a5=[["/v1/messages","anthropic"],["/v1/chat/completions","openai"],["/chat/completions","openai"],["/v1/responses","openai"],["/responses","openai"]];function pf(e){const t=e.split("?")[0]??"";for(const[s,o]of a5)if(t===s)return o;return"unknown"}function ff(e,t){for(const s of Array.from(e))t(s)}const i5=/[\u3000-\u9FFF\uAC00-\uD7FF\uF900-\uFAFF\uFF00-\uFFEF\u{1F300}-\u{1FAFF}]/u;function Rl(e){if(e.length===0)return 0;let t=0,s=0;return ff(e,o=>{i5.test(o)?t+=1:s+=1}),Math.ceil(t*1)+Math.ceil(s/4)}function Ml(e){if(e.length===0)return 0;let t=0;return ff(e,()=>{t+=1}),t}function Al(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function G(e,t){return e===null||typeof e!="object"||Array.isArray(e)?void 0:Object.getOwnPropertyDescriptor(e,t)?.value}const l5=["file","shell","browser","web","mcp","code","other"];function bi(e){const t=e.replace(/\s+/g," ").trim();return t.length<=120?t:`${t.slice(0,119)}...`}function hf(e){if(e===null)return null;const t=e.replace(/\s+/g," ").trim();if(t.length===0)return null;const s=t.search(/[.!?。!?]/);return s>=24?bi(t.slice(0,s+1)):bi(t)}function c5(e,t){return`${e} ${t??""}`.toLowerCase()}function es(e,t){return t.some(s=>e.includes(s))}function xf(e,t){const s=c5(e,t);return e.startsWith("mcp__")||e.startsWith("inspector_")||es(s,[" mcp","model context protocol"])?"mcp":es(s,["bash","shell","terminal","command","powershell","exec","process"])?"shell":es(s,["browser","playwright","screenshot","click","navigate","page","tab"])?"browser":es(s,["read","write","edit","file","glob","grep","patch","filesystem","directory"])?"file":es(s,["web","search","http","url","fetch"])?"web":es(s,["code","typescript","javascript","python","repl"])?"code":"other"}function gf(e){const t=G(e,"properties");return t===null||typeof t!="object"||Array.isArray(t)?[]:Object.keys(t).sort((s,o)=>s.localeCompare(o))}function bf(e){const t=G(e,"required");if(!Array.isArray(t))return[];const s=[];for(const o of t)typeof o=="string"&&o.length>0&&s.push(o);return s.sort((o,r)=>o.localeCompare(r))}function d5(e){const t=G(e,"name");if(typeof t!="string"||t.length===0)return null;const s=G(e,"description"),o=G(e,"input_schema")??null,r=typeof s=="string"?s:null;return{name:t,description:r,descriptionPreview:hf(r),category:xf(t,r),parameterCount:gf(o).length,requiredParameters:bf(o),schema:o}}function u5(e){const t=G(e,"function"),s=G(e,"type");if(t===void 0&&typeof s!="string")return null;const o=G(t,"name")??G(e,"name")??(typeof s=="string"?s:void 0);if(typeof o!="string"||o.length===0)return null;const r=G(t,"description")??G(e,"description"),a=G(t,"parameters")??G(e,"parameters")??null,i=typeof r=="string"?r:null;return{name:o,description:i,descriptionPreview:hf(i),category:xf(o,i),parameterCount:gf(a).length,requiredParameters:bf(a),schema:a}}function m5(e){const t=u5(e);return t!==null?t:d5(e)}function p5(e){if(e==null)return null;if(typeof e=="string")return e;const t=G(e,"type"),s=G(e,"name"),o=G(G(e,"function"),"name");if(typeof t=="string"&&typeof o=="string"&&o.length>0)return`${t}: ${o}`;if(typeof t=="string"&&typeof s=="string"&&s.length>0)return`${t}: ${s}`;if(typeof t=="string")return t;const r=JSON.stringify(e);return r===void 0?null:bi(r)}function f5(e){const t=new Map;for(const s of e)t.set(s.category,(t.get(s.category)??0)+1);return l5.flatMap(s=>{const o=t.get(s)??0;return o>0?[{category:s,count:o}]:[]})}function Il(e){const t=G(e,"tools");if(!Array.isArray(t)||t.length===0)return null;const s=[];for(const o of t){const r=m5(o);r!==null&&s.push(r)}return s.length===0?null:{tools:s,toolChoiceLabel:p5(G(e,"tool_choice")),categories:f5(s)}}function Dn(e){return{parsed:null,comparisonValue:e,messageCount:null,toolCount:null}}const ps={parsed:null,toolNames:null};function h5(e){if(typeof e=="string")return e;if(!Array.isArray(e))return"";const t=[];for(const s of e){if(s===null||typeof s!="object")continue;const o=s;switch(o.type){case"text":typeof o.text=="string"&&t.push(o.text);break;case"thinking":case"think":typeof o.thinking=="string"&&t.push(o.thinking);break;case"tool_use":{const a=typeof o.name=="string"?o.name:"",i=o.input!==void 0?JSON.stringify(o.input):"";t.push(`${a} ${i}`.trim());break}case"tool_result":{const a=o.content;if(typeof a=="string")t.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"&&t.push(c)}}break}case"image":t.push("[image]");break}}return t.join(`
|
|
42
|
+
`)},v2=0,Xn=[];function y2(e){var t=l.useRef([]),s=l.useRef([0,0]),o=l.useRef(),r=l.useState(v2++)[0],a=l.useState(rm)[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=Bv([e.lockRef.current],(e.shards||[]).map(wc),!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=bo(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,E=Math.abs(j)>Math.abs(S)?"h":"v";if("touches"in v&&E==="h"&&C.type==="range")return!1;var A=window.getSelection(),I=A&&A.anchorNode,R=I?I===C||I.contains(C):!1;if(R)return!1;var k=vc(E,C);if(!k)return!0;if(k?N=E:(N=E==="v"?"h":"v",k=vc(E,C)),!k)return!1;if(!o.current&&"changedTouches"in v&&(j||S)&&(o.current=N),!N)return!0;var M=o.current||N;return x2(M,y,v,M==="h"?j:S)},[]),d=l.useCallback(function(v){var y=v;if(!(!Xn.length||Xn[Xn.length-1]!==a)){var w="deltaY"in y?yc(y):bo(y),b=t.current.filter(function(N){return N.name===y.type&&(N.target===y.target||y.target===N.shadowParent)&&g2(N.delta,w)})[0];if(b&&b.should){y.cancelable&&y.preventDefault();return}if(!b){var j=(i.current.shards||[]).map(wc).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:w2(w)};t.current.push(j),setTimeout(function(){t.current=t.current.filter(function(S){return S!==j})},1)},[]),u=l.useCallback(function(v){s.current=bo(v),o.current=void 0},[]),p=l.useCallback(function(v){m(v.type,yc(v),v.target,c(v,e.lockRef.current))},[]),f=l.useCallback(function(v){m(v.type,bo(v),v.target,c(v,e.lockRef.current))},[]);l.useEffect(function(){return Xn.push(a),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:f}),document.addEventListener("wheel",d,Jn),document.addEventListener("touchmove",d,Jn),document.addEventListener("touchstart",u,Jn),function(){Xn=Xn.filter(function(v){return v!==a}),document.removeEventListener("wheel",d,Jn),document.removeEventListener("touchmove",d,Jn),document.removeEventListener("touchstart",u,Jn)}},[]);var h=e.removeScrollBar,g=e.inert;return l.createElement(l.Fragment,null,g?l.createElement(a,{styles:b2(r)}):null,h?l.createElement(c2,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function w2(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const j2=Jv(om,y2);var dl=l.forwardRef(function(e,t){return l.createElement(Ar,Dt({},e,{ref:t,sideCar:j2}))});dl.classNames=Ar.classNames;var S2=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Zn=new WeakMap,vo=new WeakMap,yo={},ha=0,cm=function(e){return e&&(e.host||cm(e.parentNode))},N2=function(e,t){return t.map(function(s){if(e.contains(s))return s;var o=cm(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})},C2=function(e,t,s,o){var r=N2(t,Array.isArray(e)?e:[e]);yo[s]||(yo[s]=new WeakMap);var a=yo[s],i=[],c=new Set,d=new Set(r),m=function(p){!p||c.has(p)||(c.add(p),m(p.parentNode))};r.forEach(m);var u=function(p){!p||d.has(p)||Array.prototype.forEach.call(p.children,function(f){if(c.has(f))u(f);else try{var h=f.getAttribute(o),g=h!==null&&h!=="false",v=(Zn.get(f)||0)+1,y=(a.get(f)||0)+1;Zn.set(f,v),a.set(f,y),i.push(f),v===1&&g&&vo.set(f,!0),y===1&&f.setAttribute(s,"true"),g||f.setAttribute(o,"true")}catch(w){console.error("aria-hidden: cannot operate on ",f,w)}})};return u(t),c.clear(),ha++,function(){i.forEach(function(p){var f=Zn.get(p)-1,h=a.get(p)-1;Zn.set(p,f),a.set(p,h),f||(vo.has(p)||p.removeAttribute(o),vo.delete(p)),h||p.removeAttribute(s)}),ha--,ha||(Zn=new WeakMap,Zn=new WeakMap,vo=new WeakMap,yo={})}},dm=function(e,t,s){s===void 0&&(s="data-aria-hidden");var o=Array.from(Array.isArray(e)?e:[e]),r=S2(e);return r?(o.push.apply(o,Array.from(r.querySelectorAll("[aria-live], script"))),C2(o,r,s,"aria-hidden")):function(){return null}},Ir="Dialog",[um]=on(Ir),[k2,Pt]=um(Ir),mm=e=>{const{__scopeDialog:t,children:s,open:o,defaultOpen:r,onOpenChange:a,modal:i=!0}=e,c=l.useRef(null),d=l.useRef(null),[m,u]=zn({prop:o,defaultProp:r??!1,onChange:a,caller:Ir});return n.jsx(k2,{scope:t,triggerRef:c,contentRef:d,contentId:Ft(),titleId:Ft(),descriptionId:Ft(),open:m,onOpenChange:u,onOpenToggle:l.useCallback(()=>u(p=>!p),[u]),modal:i,children:s})};mm.displayName=Ir;var pm="DialogTrigger",fm=l.forwardRef((e,t)=>{const{__scopeDialog:s,...o}=e,r=Pt(pm,s),a=Ae(t,r.triggerRef);return n.jsx(be.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.open?r.contentId:void 0,"data-state":ml(r.open),...o,ref:a,onClick:ue(e.onClick,r.onOpenToggle)})});fm.displayName=pm;var ul="DialogPortal",[_2,hm]=um(ul,{forceMount:void 0}),xm=e=>{const{__scopeDialog:t,forceMount:s,children:o,container:r}=e,a=Pt(ul,t);return n.jsx(_2,{scope:t,forceMount:s,children:l.Children.map(o,i=>n.jsx(bt,{present:s||a.open,children:n.jsx(Mr,{asChild:!0,container:r,children:i})}))})};xm.displayName=ul;var or="DialogOverlay",gm=l.forwardRef((e,t)=>{const s=hm(or,e.__scopeDialog),{forceMount:o=s.forceMount,...r}=e,a=Pt(or,e.__scopeDialog);return a.modal?n.jsx(bt,{present:o||a.open,children:n.jsx(E2,{...r,ref:t})}):null});gm.displayName=or;var T2=bs("DialogOverlay.RemoveScroll"),E2=l.forwardRef((e,t)=>{const{__scopeDialog:s,...o}=e,r=Pt(or,s),a=Ev(),i=Ae(t,a);return n.jsx(dl,{as:T2,allowPinchZoom:!0,shards:[r.contentRef],children:n.jsx(be.div,{"data-state":ml(r.open),...o,ref:i,style:{pointerEvents:"auto",...o.style}})})}),vs="DialogContent",bm=l.forwardRef((e,t)=>{const s=hm(vs,e.__scopeDialog),{forceMount:o=s.forceMount,...r}=e,a=Pt(vs,e.__scopeDialog);return n.jsx(bt,{present:o||a.open,children:a.modal?n.jsx(R2,{...r,ref:t}):n.jsx(M2,{...r,ref:t})})});bm.displayName=vs;var R2=l.forwardRef((e,t)=>{const s=Pt(vs,e.__scopeDialog),o=l.useRef(null),r=Ae(t,s.contentRef,o);return l.useEffect(()=>{const a=o.current;if(a)return dm(a)},[]),n.jsx(vm,{...e,ref:r,trapFocus:s.open,disableOutsidePointerEvents:s.open,onCloseAutoFocus:ue(e.onCloseAutoFocus,a=>{a.preventDefault(),s.triggerRef.current?.focus()}),onPointerDownOutside:ue(e.onPointerDownOutside,a=>{const i=a.detail.originalEvent,c=i.button===0&&i.ctrlKey===!0;(i.button===2||c)&&a.preventDefault()}),onFocusOutside:ue(e.onFocusOutside,a=>a.preventDefault())})}),M2=l.forwardRef((e,t)=>{const s=Pt(vs,e.__scopeDialog),o=l.useRef(!1),r=l.useRef(!1);return n.jsx(vm,{...e,ref:t,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()}})}),vm=l.forwardRef((e,t)=>{const{__scopeDialog:s,trapFocus:o,onOpenAutoFocus:r,onCloseAutoFocus:a,...i}=e,c=Pt(vs,s);return tm(),n.jsx(n.Fragment,{children:n.jsx(cl,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:r,onUnmountAutoFocus:a,children:n.jsx(Rr,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":ml(c.open),...i,ref:t,deferPointerDownOutside:!0,onDismiss:()=>c.onOpenChange(!1)})})})}),ym="DialogTitle",wm=l.forwardRef((e,t)=>{const{__scopeDialog:s,...o}=e,r=Pt(ym,s);return n.jsx(be.h2,{id:r.titleId,...o,ref:t})});wm.displayName=ym;var jm="DialogDescription",Sm=l.forwardRef((e,t)=>{const{__scopeDialog:s,...o}=e,r=Pt(jm,s);return n.jsx(be.p,{id:r.descriptionId,...o,ref:t})});Sm.displayName=jm;var Nm="DialogClose",Cm=l.forwardRef((e,t)=>{const{__scopeDialog:s,...o}=e,r=Pt(Nm,s);return n.jsx(be.button,{type:"button",...o,ref:t,onClick:ue(e.onClick,()=>r.onOpenChange(!1))})});Cm.displayName=Nm;function ml(e){return e?"open":"closed"}function A2(e){const t=l.useRef({value:e,previous:e});return l.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}function I2(e){const[t,s]=l.useState(void 0);return Ve(()=>{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]),t}const P2=["top","right","bottom","left"],jn=Math.min,pt=Math.max,rr=Math.round,wo=Math.floor,Bt=e=>({x:e,y:e}),L2={left:"right",right:"left",bottom:"top",top:"bottom"},O2={start:"end",end:"start"};function ii(e,t,s){return pt(e,jn(t,s))}function tn(e,t){return typeof e=="function"?e(t):e}function nn(e){return e.split("-")[0]}function ks(e){return e.split("-")[1]}function pl(e){return e==="x"?"y":"x"}function fl(e){return e==="y"?"height":"width"}const D2=new Set(["top","bottom"]);function zt(e){return D2.has(nn(e))?"y":"x"}function hl(e){return pl(zt(e))}function z2(e,t,s){s===void 0&&(s=!1);const o=ks(e),r=hl(e),a=fl(r);let i=r==="x"?o===(s?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=ar(i)),[i,ar(i)]}function $2(e){const t=ar(e);return[li(e),t,li(t)]}function li(e){return e.replace(/start|end/g,t=>O2[t])}const jc=["left","right"],Sc=["right","left"],F2=["top","bottom"],B2=["bottom","top"];function U2(e,t,s){switch(e){case"top":case"bottom":return s?t?Sc:jc:t?jc:Sc;case"left":case"right":return t?F2:B2;default:return[]}}function q2(e,t,s,o){const r=ks(e);let a=U2(nn(e),s==="start",o);return r&&(a=a.map(i=>i+"-"+r),t&&(a=a.concat(a.map(li)))),a}function ar(e){return e.replace(/left|right|bottom|top/g,t=>L2[t])}function H2(e){return{top:0,right:0,bottom:0,left:0,...e}}function km(e){return typeof e!="number"?H2(e):{top:e,right:e,bottom:e,left:e}}function ir(e){const{x:t,y:s,width:o,height:r}=e;return{width:o,height:r,top:s,left:t,right:t+o,bottom:s+r,x:t,y:s}}function Nc(e,t,s){let{reference:o,floating:r}=e;const a=zt(t),i=hl(t),c=fl(i),d=nn(t),m=a==="y",u=o.x+o.width/2-r.width/2,p=o.y+o.height/2-r.height/2,f=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:p};break;case"left":h={x:o.x-r.width,y:p};break;default:h={x:o.x,y:o.y}}switch(ks(t)){case"start":h[i]-=f*(s&&m?-1:1);break;case"end":h[i]+=f*(s&&m?-1:1);break}return h}async function V2(e,t){var s;t===void 0&&(t={});const{x:o,y:r,platform:a,rects:i,elements:c,strategy:d}=e,{boundary:m="clippingAncestors",rootBoundary:u="viewport",elementContext:p="floating",altBoundary:f=!1,padding:h=0}=tn(t,e),g=km(h),y=c[f?p==="floating"?"reference":"floating":p],w=ir(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=p==="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=ir(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 W2=async(e,t,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(t));let m=await i.getElementRects({reference:e,floating:t,strategy:r}),{x:u,y:p}=Nc(m,o,d),f=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:p,initialPlacement:o,placement:f,strategy:r,middlewareData:h,rects:m,platform:{...i,detectOverflow:(v=i.detectOverflow)!=null?v:V2},elements:{reference:e,floating:t}});u=j??u,p=S??p,h={...h,[w]:{...h[w],...N}},C&&g<=50&&(g++,typeof C=="object"&&(C.placement&&(f=C.placement),C.rects&&(m=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:r}):C.rects),{x:u,y:p}=Nc(m,f,d)),y=-1)}return{x:u,y:p,placement:f,strategy:r,middlewareData:h}},G2=e=>({name:"arrow",options:e,async fn(t){const{x:s,y:o,placement:r,rects:a,platform:i,elements:c,middlewareData:d}=t,{element:m,padding:u=0}=tn(e,t)||{};if(m==null)return{};const p=km(u),f={x:s,y:o},h=hl(r),g=fl(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]-f[h]-a.floating[g],N=f[h]-a.reference[h],C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(m));let E=C?C[j]:0;(!E||!await(i.isElement==null?void 0:i.isElement(C)))&&(E=c.floating[j]||a.floating[g]);const A=S/2-N/2,I=E/2-v[g]/2-1,R=jn(p[w],I),k=jn(p[b],I),M=R,O=E-v[g]-k,$=E/2-v[g]/2+A,K=ii(M,$,O),Q=!d.arrow&&ks(r)!=null&&$!==K&&a.reference[g]/2-($<M?R:k)-v[g]/2<0,z=Q?$<M?$-M:$-O:0;return{[h]:f[h]+z,data:{[h]:K,centerOffset:$-K-z,...Q&&{alignmentOffset:z}},reset:Q}}}),K2=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var s,o;const{placement:r,middlewareData:a,rects:i,initialPlacement:c,platform:d,elements:m}=t,{mainAxis:u=!0,crossAxis:p=!0,fallbackPlacements:f,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:v=!0,...y}=tn(e,t);if((s=a.arrow)!=null&&s.alignmentOffset)return{};const w=nn(r),b=zt(c),j=nn(c)===c,S=await(d.isRTL==null?void 0:d.isRTL(m.floating)),N=f||(j||!v?[ar(c)]:$2(c)),C=g!=="none";!f&&C&&N.push(...q2(c,v,g,S));const E=[c,...N],A=await d.detectOverflow(t,y),I=[];let R=((o=a.flip)==null?void 0:o.overflows)||[];if(u&&I.push(A[w]),p){const $=z2(r,i,S);I.push(A[$[0]],A[$[1]])}if(R=[...R,{placement:r,overflows:I}],!I.every($=>$<=0)){var k,M;const $=(((k=a.flip)==null?void 0:k.index)||0)+1,K=E[$];if(K&&(!(p==="alignment"?b!==zt(K):!1)||R.every(H=>zt(H.placement)===b?H.overflows[0]>0:!0)))return{data:{index:$,overflows:R},reset:{placement:K}};let Q=(M=R.filter(z=>z.overflows[0]<=0).sort((z,H)=>z.overflows[1]-H.overflows[1])[0])==null?void 0:M.placement;if(!Q)switch(h){case"bestFit":{var O;const z=(O=R.filter(H=>{if(C){const ee=zt(H.placement);return ee===b||ee==="y"}return!0}).map(H=>[H.placement,H.overflows.filter(ee=>ee>0).reduce((ee,U)=>ee+U,0)]).sort((H,ee)=>H[1]-ee[1])[0])==null?void 0:O[0];z&&(Q=z);break}case"initialPlacement":Q=c;break}if(r!==Q)return{reset:{placement:Q}}}return{}}}};function Cc(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function kc(e){return P2.some(t=>e[t]>=0)}const Y2=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:s,platform:o}=t,{strategy:r="referenceHidden",...a}=tn(e,t);switch(r){case"referenceHidden":{const i=await o.detectOverflow(t,{...a,elementContext:"reference"}),c=Cc(i,s.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:kc(c)}}}case"escaped":{const i=await o.detectOverflow(t,{...a,altBoundary:!0}),c=Cc(i,s.floating);return{data:{escapedOffsets:c,escaped:kc(c)}}}default:return{}}}}},_m=new Set(["left","top"]);async function J2(e,t){const{placement:s,platform:o,elements:r}=e,a=await(o.isRTL==null?void 0:o.isRTL(r.floating)),i=nn(s),c=ks(s),d=zt(s)==="y",m=_m.has(i)?-1:1,u=a&&d?-1:1,p=tn(t,e);let{mainAxis:f,crossAxis:h,alignmentAxis:g}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return c&&typeof g=="number"&&(h=c==="end"?g*-1:g),d?{x:h*u,y:f*m}:{x:f*m,y:h*u}}const X2=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var s,o;const{x:r,y:a,placement:i,middlewareData:c}=t,d=await J2(t,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}}}}},Z2=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:s,y:o,placement:r,platform:a}=t,{mainAxis:i=!0,crossAxis:c=!1,limiter:d={fn:w=>{let{x:b,y:j}=w;return{x:b,y:j}}},...m}=tn(e,t),u={x:s,y:o},p=await a.detectOverflow(t,m),f=zt(nn(r)),h=pl(f);let g=u[h],v=u[f];if(i){const w=h==="y"?"top":"left",b=h==="y"?"bottom":"right",j=g+p[w],S=g-p[b];g=ii(j,g,S)}if(c){const w=f==="y"?"top":"left",b=f==="y"?"bottom":"right",j=v+p[w],S=v-p[b];v=ii(j,v,S)}const y=d.fn({...t,[h]:g,[f]:v});return{...y,data:{x:y.x-s,y:y.y-o,enabled:{[h]:i,[f]:c}}}}}},Q2=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:s,y:o,placement:r,rects:a,middlewareData:i}=t,{offset:c=0,mainAxis:d=!0,crossAxis:m=!0}=tn(e,t),u={x:s,y:o},p=zt(r),f=pl(p);let h=u[f],g=u[p];const v=tn(c,t),y=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(d){const j=f==="y"?"height":"width",S=a.reference[f]-a.floating[j]+y.mainAxis,N=a.reference[f]+a.reference[j]-y.mainAxis;h<S?h=S:h>N&&(h=N)}if(m){var w,b;const j=f==="y"?"width":"height",S=_m.has(nn(r)),N=a.reference[p]-a.floating[j]+(S&&((w=i.offset)==null?void 0:w[p])||0)+(S?0:y.crossAxis),C=a.reference[p]+a.reference[j]+(S?0:((b=i.offset)==null?void 0:b[p])||0)-(S?y.crossAxis:0);g<N?g=N:g>C&&(g=C)}return{[f]:h,[p]:g}}}},ey=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var s,o;const{placement:r,rects:a,platform:i,elements:c}=t,{apply:d=()=>{},...m}=tn(e,t),u=await i.detectOverflow(t,m),p=nn(r),f=ks(r),h=zt(r)==="y",{width:g,height:v}=a.floating;let y,w;p==="top"||p==="bottom"?(y=p,w=f===(await(i.isRTL==null?void 0:i.isRTL(c.floating))?"start":"end")?"left":"right"):(w=p,y=f==="end"?"top":"bottom");const b=v-u.top-u.bottom,j=g-u.left-u.right,S=jn(v-u[y],b),N=jn(g-u[w],j),C=!t.middlewareData.shift;let E=S,A=N;if((s=t.middlewareData.shift)!=null&&s.enabled.x&&(A=j),(o=t.middlewareData.shift)!=null&&o.enabled.y&&(E=b),C&&!f){const R=pt(u.left,0),k=pt(u.right,0),M=pt(u.top,0),O=pt(u.bottom,0);h?A=g-2*(R!==0||k!==0?R+k:pt(u.left,u.right)):E=v-2*(M!==0||O!==0?M+O:pt(u.top,u.bottom))}await d({...t,availableWidth:A,availableHeight:E});const I=await i.getDimensions(c.floating);return g!==I.width||v!==I.height?{reset:{rects:!0}}:{}}}};function Pr(){return typeof window<"u"}function _s(e){return Tm(e)?(e.nodeName||"").toLowerCase():"#document"}function xt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Gt(e){var t;return(t=(Tm(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Tm(e){return Pr()?e instanceof Node||e instanceof xt(e).Node:!1}function At(e){return Pr()?e instanceof Element||e instanceof xt(e).Element:!1}function Ut(e){return Pr()?e instanceof HTMLElement||e instanceof xt(e).HTMLElement:!1}function _c(e){return!Pr()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof xt(e).ShadowRoot}const ty=new Set(["inline","contents"]);function oo(e){const{overflow:t,overflowX:s,overflowY:o,display:r}=It(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+s)&&!ty.has(r)}const ny=new Set(["table","td","th"]);function sy(e){return ny.has(_s(e))}const oy=[":popover-open",":modal"];function Lr(e){return oy.some(t=>{try{return e.matches(t)}catch{return!1}})}const ry=["transform","translate","scale","rotate","perspective"],ay=["transform","translate","scale","rotate","perspective","filter"],iy=["paint","layout","strict","content"];function xl(e){const t=gl(),s=At(e)?It(e):e;return ry.some(o=>s[o]?s[o]!=="none":!1)||(s.containerType?s.containerType!=="normal":!1)||!t&&(s.backdropFilter?s.backdropFilter!=="none":!1)||!t&&(s.filter?s.filter!=="none":!1)||ay.some(o=>(s.willChange||"").includes(o))||iy.some(o=>(s.contain||"").includes(o))}function ly(e){let t=Sn(e);for(;Ut(t)&&!ys(t);){if(xl(t))return t;if(Lr(t))return null;t=Sn(t)}return null}function gl(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const cy=new Set(["html","body","#document"]);function ys(e){return cy.has(_s(e))}function It(e){return xt(e).getComputedStyle(e)}function Or(e){return At(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Sn(e){if(_s(e)==="html")return e;const t=e.assignedSlot||e.parentNode||_c(e)&&e.host||Gt(e);return _c(t)?t.host:t}function Em(e){const t=Sn(e);return ys(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ut(t)&&oo(t)?t:Em(t)}function Ws(e,t,s){var o;t===void 0&&(t=[]),s===void 0&&(s=!0);const r=Em(e),a=r===((o=e.ownerDocument)==null?void 0:o.body),i=xt(r);if(a){const c=ci(i);return t.concat(i,i.visualViewport||[],oo(r)?r:[],c&&s?Ws(c):[])}return t.concat(r,Ws(r,[],s))}function ci(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Rm(e){const t=It(e);let s=parseFloat(t.width)||0,o=parseFloat(t.height)||0;const r=Ut(e),a=r?e.offsetWidth:s,i=r?e.offsetHeight:o,c=rr(s)!==a||rr(o)!==i;return c&&(s=a,o=i),{width:s,height:o,$:c}}function bl(e){return At(e)?e:e.contextElement}function ms(e){const t=bl(e);if(!Ut(t))return Bt(1);const s=t.getBoundingClientRect(),{width:o,height:r,$:a}=Rm(t);let i=(a?rr(s.width):s.width)/o,c=(a?rr(s.height):s.height)/r;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const dy=Bt(0);function Mm(e){const t=xt(e);return!gl()||!t.visualViewport?dy:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function uy(e,t,s){return t===void 0&&(t=!1),!s||t&&s!==xt(e)?!1:t}function $n(e,t,s,o){t===void 0&&(t=!1),s===void 0&&(s=!1);const r=e.getBoundingClientRect(),a=bl(e);let i=Bt(1);t&&(o?At(o)&&(i=ms(o)):i=ms(e));const c=uy(a,s,o)?Mm(a):Bt(0);let d=(r.left+c.x)/i.x,m=(r.top+c.y)/i.y,u=r.width/i.x,p=r.height/i.y;if(a){const f=xt(a),h=o&&At(o)?xt(o):o;let g=f,v=ci(g);for(;v&&o&&h!==g;){const y=ms(v),w=v.getBoundingClientRect(),b=It(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,p*=y.y,d+=j,m+=S,g=xt(v),v=ci(g)}}return ir({width:u,height:p,x:d,y:m})}function Dr(e,t){const s=Or(e).scrollLeft;return t?t.left+s:$n(Gt(e)).left+s}function Am(e,t){const s=e.getBoundingClientRect(),o=s.left+t.scrollLeft-Dr(e,s),r=s.top+t.scrollTop;return{x:o,y:r}}function my(e){let{elements:t,rect:s,offsetParent:o,strategy:r}=e;const a=r==="fixed",i=Gt(o),c=t?Lr(t.floating):!1;if(o===i||c&&a)return s;let d={scrollLeft:0,scrollTop:0},m=Bt(1);const u=Bt(0),p=Ut(o);if((p||!p&&!a)&&((_s(o)!=="body"||oo(i))&&(d=Or(o)),Ut(o))){const h=$n(o);m=ms(o),u.x=h.x+o.clientLeft,u.y=h.y+o.clientTop}const f=i&&!p&&!a?Am(i,d):Bt(0);return{width:s.width*m.x,height:s.height*m.y,x:s.x*m.x-d.scrollLeft*m.x+u.x+f.x,y:s.y*m.y-d.scrollTop*m.y+u.y+f.y}}function py(e){return Array.from(e.getClientRects())}function fy(e){const t=Gt(e),s=Or(e),o=e.ownerDocument.body,r=pt(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),a=pt(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight);let i=-s.scrollLeft+Dr(e);const c=-s.scrollTop;return It(o).direction==="rtl"&&(i+=pt(t.clientWidth,o.clientWidth)-r),{width:r,height:a,x:i,y:c}}const Tc=25;function hy(e,t){const s=xt(e),o=Gt(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=gl();(!u||u&&t==="fixed")&&(c=r.offsetLeft,d=r.offsetTop)}const m=Dr(o);if(m<=0){const u=o.ownerDocument,p=u.body,f=getComputedStyle(p),h=u.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,g=Math.abs(o.clientWidth-p.clientWidth-h);g<=Tc&&(a-=g)}else m<=Tc&&(a+=m);return{width:a,height:i,x:c,y:d}}const xy=new Set(["absolute","fixed"]);function gy(e,t){const s=$n(e,!0,t==="fixed"),o=s.top+e.clientTop,r=s.left+e.clientLeft,a=Ut(e)?ms(e):Bt(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 Ec(e,t,s){let o;if(t==="viewport")o=hy(e,s);else if(t==="document")o=fy(Gt(e));else if(At(t))o=gy(t,s);else{const r=Mm(e);o={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return ir(o)}function Im(e,t){const s=Sn(e);return s===t||!At(s)||ys(s)?!1:It(s).position==="fixed"||Im(s,t)}function by(e,t){const s=t.get(e);if(s)return s;let o=Ws(e,[],!1).filter(c=>At(c)&&_s(c)!=="body"),r=null;const a=It(e).position==="fixed";let i=a?Sn(e):e;for(;At(i)&&!ys(i);){const c=It(i),d=xl(i);!d&&c.position==="fixed"&&(r=null),(a?!d&&!r:!d&&c.position==="static"&&!!r&&xy.has(r.position)||oo(i)&&!d&&Im(e,i))?o=o.filter(u=>u!==i):r=c,i=Sn(i)}return t.set(e,o),o}function vy(e){let{element:t,boundary:s,rootBoundary:o,strategy:r}=e;const i=[...s==="clippingAncestors"?Lr(t)?[]:by(t,this._c):[].concat(s),o],c=i[0],d=i.reduce((m,u)=>{const p=Ec(t,u,r);return m.top=pt(p.top,m.top),m.right=jn(p.right,m.right),m.bottom=jn(p.bottom,m.bottom),m.left=pt(p.left,m.left),m},Ec(t,c,r));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}}function yy(e){const{width:t,height:s}=Rm(e);return{width:t,height:s}}function wy(e,t,s){const o=Ut(t),r=Gt(t),a=s==="fixed",i=$n(e,!0,a,t);let c={scrollLeft:0,scrollTop:0};const d=Bt(0);function m(){d.x=Dr(r)}if(o||!o&&!a)if((_s(t)!=="body"||oo(r))&&(c=Or(t)),o){const h=$n(t,!0,a,t);d.x=h.x+t.clientLeft,d.y=h.y+t.clientTop}else r&&m();a&&!o&&r&&m();const u=r&&!o&&!a?Am(r,c):Bt(0),p=i.left+c.scrollLeft-d.x-u.x,f=i.top+c.scrollTop-d.y-u.y;return{x:p,y:f,width:i.width,height:i.height}}function xa(e){return It(e).position==="static"}function Rc(e,t){if(!Ut(e)||It(e).position==="fixed")return null;if(t)return t(e);let s=e.offsetParent;return Gt(e)===s&&(s=s.ownerDocument.body),s}function Pm(e,t){const s=xt(e);if(Lr(e))return s;if(!Ut(e)){let r=Sn(e);for(;r&&!ys(r);){if(At(r)&&!xa(r))return r;r=Sn(r)}return s}let o=Rc(e,t);for(;o&&sy(o)&&xa(o);)o=Rc(o,t);return o&&ys(o)&&xa(o)&&!xl(o)?s:o||ly(e)||s}const jy=async function(e){const t=this.getOffsetParent||Pm,s=this.getDimensions,o=await s(e.floating);return{reference:wy(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function Sy(e){return It(e).direction==="rtl"}const Ny={convertOffsetParentRelativeRectToViewportRelativeRect:my,getDocumentElement:Gt,getClippingRect:vy,getOffsetParent:Pm,getElementRects:jy,getClientRects:py,getDimensions:yy,getScale:ms,isElement:At,isRTL:Sy};function Lm(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Cy(e,t){let s=null,o;const r=Gt(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:p,width:f,height:h}=m;if(c||t(),!f||!h)return;const g=wo(p),v=wo(r.clientWidth-(u+f)),y=wo(r.clientHeight-(p+h)),w=wo(u),j={rootMargin:-g+"px "+-v+"px "+-y+"px "+-w+"px",threshold:pt(0,jn(1,d))||1};let S=!0;function N(C){const E=C[0].intersectionRatio;if(E!==d){if(!S)return i();E?i(!1,E):o=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!Lm(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 ky(e,t,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=bl(e),u=r||a?[...m?Ws(m):[],...Ws(t)]:[];u.forEach(w=>{r&&w.addEventListener("scroll",s,{passive:!0}),a&&w.addEventListener("resize",s)});const p=m&&c?Cy(m,s):null;let f=-1,h=null;i&&(h=new ResizeObserver(w=>{let[b]=w;b&&b.target===m&&h&&(h.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var j;(j=h)==null||j.observe(t)})),s()}),m&&!d&&h.observe(m),h.observe(t));let g,v=d?$n(e):null;d&&y();function y(){const w=$n(e);v&&!Lm(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)}),p?.(),(w=h)==null||w.disconnect(),h=null,d&&cancelAnimationFrame(g)}}const _y=X2,Ty=Z2,Ey=K2,Ry=ey,My=Y2,Mc=G2,Ay=Q2,Iy=(e,t,s)=>{const o=new Map,r={platform:Ny,...s},a={...r.platform,_c:o};return W2(e,t,{...r,platform:a})};var Py=typeof document<"u",Ly=function(){},Ho=Py?l.useLayoutEffect:Ly;function lr(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let s,o,r;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(s=e.length,s!==t.length)return!1;for(o=s;o--!==0;)if(!lr(e[o],t[o]))return!1;return!0}if(r=Object.keys(e),s=r.length,s!==Object.keys(t).length)return!1;for(o=s;o--!==0;)if(!{}.hasOwnProperty.call(t,r[o]))return!1;for(o=s;o--!==0;){const a=r[o];if(!(a==="_owner"&&e.$$typeof)&&!lr(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function Om(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Ac(e,t){const s=Om(e);return Math.round(t*s)/s}function ga(e){const t=l.useRef(e);return Ho(()=>{t.current=e}),t}function Oy(e){e===void 0&&(e={});const{placement:t="bottom",strategy:s="absolute",middleware:o=[],platform:r,elements:{reference:a,floating:i}={},transform:c=!0,whileElementsMounted:d,open:m}=e,[u,p]=l.useState({x:0,y:0,strategy:s,placement:t,middlewareData:{},isPositioned:!1}),[f,h]=l.useState(o);lr(f,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!==E.current&&(E.current=H,w(H))},[]),S=a||g,N=i||y,C=l.useRef(null),E=l.useRef(null),A=l.useRef(u),I=d!=null,R=ga(d),k=ga(r),M=ga(m),O=l.useCallback(()=>{if(!C.current||!E.current)return;const H={placement:t,strategy:s,middleware:f};k.current&&(H.platform=k.current),Iy(C.current,E.current,H).then(ee=>{const U={...ee,isPositioned:M.current!==!1};$.current&&!lr(A.current,U)&&(A.current=U,Cs.flushSync(()=>{p(U)}))})},[f,t,s,k,M]);Ho(()=>{m===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,p(H=>({...H,isPositioned:!1})))},[m]);const $=l.useRef(!1);Ho(()=>($.current=!0,()=>{$.current=!1}),[]),Ho(()=>{if(S&&(C.current=S),N&&(E.current=N),S&&N){if(R.current)return R.current(S,N,O);O()}},[S,N,O,R,I]);const K=l.useMemo(()=>({reference:C,floating:E,setReference:b,setFloating:j}),[b,j]),Q=l.useMemo(()=>({reference:S,floating:N}),[S,N]),z=l.useMemo(()=>{const H={position:s,left:0,top:0};if(!Q.floating)return H;const ee=Ac(Q.floating,u.x),U=Ac(Q.floating,u.y);return c?{...H,transform:"translate("+ee+"px, "+U+"px)",...Om(Q.floating)>=1.5&&{willChange:"transform"}}:{position:s,left:ee,top:U}},[s,c,Q.floating,u.x,u.y]);return l.useMemo(()=>({...u,update:O,refs:K,elements:Q,floatingStyles:z}),[u,O,K,Q,z])}const Dy=e=>{function t(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&&t(o)?o.current!=null?Mc({element:o.current,padding:r}).fn(s):{}:o?Mc({element:o,padding:r}).fn(s):{}}}},zy=(e,t)=>({..._y(e),options:[e,t]}),$y=(e,t)=>({...Ty(e),options:[e,t]}),Fy=(e,t)=>({...Ay(e),options:[e,t]}),By=(e,t)=>({...Ey(e),options:[e,t]}),Uy=(e,t)=>({...Ry(e),options:[e,t]}),qy=(e,t)=>({...My(e),options:[e,t]}),Hy=(e,t)=>({...Dy(e),options:[e,t]});var Vy="Arrow",Dm=l.forwardRef((e,t)=>{const{children:s,width:o=10,height:r=5,...a}=e;return n.jsx(be.svg,{...a,ref:t,width:o,height:r,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?s:n.jsx("polygon",{points:"0,0 30,0 15,10"})})});Dm.displayName=Vy;var Wy=Dm,vl="Popper",[zm,zr]=on(vl),[Gy,$m]=zm(vl),Fm=e=>{const{__scopePopper:t,children:s}=e,[o,r]=l.useState(null),[a,i]=l.useState(void 0);return n.jsx(Gy,{scope:t,anchor:o,onAnchorChange:r,placementState:a,setPlacementState:i,children:s})};Fm.displayName=vl;var Bm="PopperAnchor",Um=l.forwardRef((e,t)=>{const{__scopePopper:s,virtualRef:o,...r}=e,a=$m(Bm,s),i=l.useRef(null),c=a.onAnchorChange,d=l.useCallback(g=>{i.current=g,g&&c(g)},[c]),m=Ae(t,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 p=a.placementState&&wl(a.placementState),f=p?.[0],h=p?.[1];return o?null:n.jsx(be.div,{"data-radix-popper-side":f,"data-radix-popper-align":h,...r,ref:m})});Um.displayName=Bm;var yl="PopperContent",[Ky,Yy]=zm(yl),qm=l.forwardRef((e,t)=>{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:p="partial",hideWhenDetached:f=!1,updatePositionStrategy:h="optimized",onPlaced:g,...v}=e,y=$m(yl,s),[w,b]=l.useState(null),j=Ae(t,b),[S,N]=l.useState(null),C=I2(S),E=C?.width??0,A=C?.height??0,I=o+(a!=="center"?"-"+a:""),R=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},k=Array.isArray(m)?m:[m],M=k.length>0,O={padding:R,boundary:k.filter(Xy),altBoundary:M},{refs:$,floatingStyles:K,placement:Q,isPositioned:z,middlewareData:H}=Oy({strategy:"fixed",placement:I,whileElementsMounted:(...Se)=>ky(...Se,{animationFrame:h==="always"}),elements:{reference:y.anchor},middleware:[zy({mainAxis:r+A,alignmentAxis:i}),d&&$y({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?Fy():void 0,...O}),d&&By({...O}),Uy({...O,apply:({elements:Se,rects:Te,availableWidth:ge,availableHeight:le})=>{const{width:ce,height:Pe}=Te.reference,Re=Se.floating.style;Re.setProperty("--radix-popper-available-width",`${ge}px`),Re.setProperty("--radix-popper-available-height",`${le}px`),Re.setProperty("--radix-popper-anchor-width",`${ce}px`),Re.setProperty("--radix-popper-anchor-height",`${Pe}px`)}}),S&&Hy({element:S,padding:c}),Zy({arrowWidth:E,arrowHeight:A}),f&&qy({strategy:"referenceHidden",...O,boundary:M?O.boundary:void 0})]}),ee=y.setPlacementState;Ve(()=>(ee(Q),()=>{ee(void 0)}),[Q,ee]);const[U,Z]=wl(Q),fe=Ye(g);Ve(()=>{z&&fe?.()},[z,fe]);const je=H.arrow?.x,he=H.arrow?.y,oe=H.arrow?.centerOffset!==0,[L,J]=l.useState();return Ve(()=>{w&&J(window.getComputedStyle(w).zIndex)},[w]),n.jsx("div",{ref:$.setFloating,"data-radix-popper-content-wrapper":"",style:{...K,transform:z?K.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:L,"--radix-popper-transform-origin":[H.transformOrigin?.x,H.transformOrigin?.y].join(" "),...H.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:n.jsx(Ky,{scope:s,placedSide:U,placedAlign:Z,onArrowChange:N,arrowX:je,arrowY:he,shouldHideArrow:oe,children:n.jsx(be.div,{"data-side":U,"data-align":Z,...v,ref:j,style:{...v.style,animation:z?void 0:"none"}})})})});qm.displayName=yl;var Hm="PopperArrow",Jy={top:"bottom",right:"left",bottom:"top",left:"right"},Vm=l.forwardRef(function(t,s){const{__scopePopper:o,...r}=t,a=Yy(Hm,o),i=Jy[a.placedSide];return n.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:n.jsx(Wy,{...r,ref:s,style:{...r.style,display:"block"}})})});Vm.displayName=Hm;function Xy(e){return e!==null}var Zy=e=>({name:"transformOrigin",options:e,fn(t){const{placement:s,rects:o,middlewareData:r}=t,i=r.arrow?.centerOffset!==0,c=i?0:e.arrowWidth,d=i?0:e.arrowHeight,[m,u]=wl(s),p={start:"0%",center:"50%",end:"100%"}[u],f=(r.arrow?.x??0)+c/2,h=(r.arrow?.y??0)+d/2;let g="",v="";return m==="bottom"?(g=i?p:`${f}px`,v=`${-d}px`):m==="top"?(g=i?p:`${f}px`,v=`${o.floating.height+d}px`):m==="right"?(g=`${-d}px`,v=i?p:`${h}px`):m==="left"&&(g=`${o.floating.width+d}px`,v=i?p:`${h}px`),{data:{x:g,y:v}}}});function wl(e){const[t,s="center"]=e.split("-");return[t,s]}var Wm=Fm,Gm=Um,Km=qm,Ym=Vm,ba=!1;function Qy(){const[e,t]=l.useState(ba);return l.useEffect(()=>{ba||(ba=!0,t(!0))},[]),e}var Jm=Nr[" useSyncExternalStore ".trim().toString()];function ew(){return()=>{}}function tw(){return Jm(ew,()=>!0,()=>!1)}var nw=typeof Jm=="function"?tw:Qy,va="rovingFocusGroup.onEntryFocus",sw={bubbles:!1,cancelable:!0},ro="RovingFocusGroup",[di,Xm,ow]=Ku(ro),[rw,Zm]=on(ro,[ow]),[aw,iw]=rw(ro),Qm=l.forwardRef((e,t)=>n.jsx(di.Provider,{scope:e.__scopeRovingFocusGroup,children:n.jsx(di.Slot,{scope:e.__scopeRovingFocusGroup,children:n.jsx(lw,{...e,ref:t})})}));Qm.displayName=ro;var lw=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:s,orientation:o,loop:r=!1,dir:a,currentTabStopId:i,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:d,onEntryFocus:m,preventScrollOnEntryFocus:u=!1,...p}=e,f=l.useRef(null),h=Ae(t,f),g=Er(a),[v,y]=zn({prop:i,defaultProp:c??null,onChange:d,caller:ro}),[w,b]=l.useState(!1),j=Ye(m),S=Xm(s),N=l.useRef(!1),[C,E]=l.useState(0);return l.useEffect(()=>{const A=f.current;if(A)return A.addEventListener(va,j),()=>A.removeEventListener(va,j)},[j]),n.jsx(aw,{scope:s,orientation:o,dir:g,loop:r,currentTabStopId:v,onItemFocus:l.useCallback(A=>y(A),[y]),onItemShiftTab:l.useCallback(()=>b(!0),[]),onFocusableItemAdd:l.useCallback(()=>E(A=>A+1),[]),onFocusableItemRemove:l.useCallback(()=>E(A=>A-1),[]),children:n.jsx(be.div,{tabIndex:w||C===0?-1:0,"data-orientation":o,...p,ref:h,style:{outline:"none",...e.style},onMouseDown:ue(e.onMouseDown,()=>{N.current=!0}),onFocus:ue(e.onFocus,A=>{const I=!N.current;if(A.target===A.currentTarget&&I&&!w){const R=new CustomEvent(va,sw);if(A.currentTarget.dispatchEvent(R),!R.defaultPrevented){const k=S().filter(Q=>Q.focusable),M=k.find(Q=>Q.active),O=k.find(Q=>Q.id===v),K=[M,O,...k].filter(Boolean).map(Q=>Q.ref.current);np(K,u)}}N.current=!1}),onBlur:ue(e.onBlur,()=>b(!1))})})}),ep="RovingFocusGroupItem",tp=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:s,focusable:o=!0,active:r=!1,tabStopId:a,children:i,...c}=e,d=Ft(),m=a||d,u=iw(ep,s),p=u.currentTabStopId===m,f=Xm(s),{onFocusableItemAdd:h,onFocusableItemRemove:g,currentTabStopId:v}=u,y=nw();return Ve(()=>{if(!(!y||!o))return h(),()=>g()},[y,o,h,g]),l.useEffect(()=>{if(!(y||!o))return h(),()=>g()},[y,o,h,g]),n.jsx(di.ItemSlot,{scope:s,id:m,focusable:o,active:r,children:n.jsx(be.span,{tabIndex:p?0:-1,"data-orientation":u.orientation,...c,ref:t,onMouseDown:ue(e.onMouseDown,w=>{o?u.onItemFocus(m):w.preventDefault()}),onFocus:ue(e.onFocus,()=>u.onItemFocus(m)),onKeyDown:ue(e.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){u.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const b=uw(w,u.orientation,u.dir);if(b!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let S=f().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?mw(S,N+1):S.slice(N+1)}setTimeout(()=>np(S))}}),children:typeof i=="function"?i({isCurrentTabStop:p,hasTabStop:v!=null}):i})})});tp.displayName=ep;var cw={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function dw(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function uw(e,t,s){const o=dw(e.key,s);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(o))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(o)))return cw[o]}function np(e,t=!1){const s=document.activeElement;for(const o of e)if(o===s||(o.focus({preventScroll:t}),document.activeElement!==s))return}function mw(e,t){return e.map((s,o)=>e[(t+o)%e.length])}var pw=Qm,fw=tp;function ui(e,[t,s]){return Math.min(s,Math.max(t,e))}function hw(e,t){return l.useReducer((s,o)=>t[s][o]??s,e)}var jl="ScrollArea",[sp]=on(jl),[xw,St]=sp(jl),op=l.forwardRef((e,t)=>{const{__scopeScrollArea:s,type:o="hover",dir:r,scrollHideDelay:a=600,...i}=e,[c,d]=l.useState(null),[m,u]=l.useState(null),[p,f]=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),[E,A]=l.useState(!1),I=Ae(t,d),R=Er(r);return n.jsx(xw,{scope:s,type:o,dir:R,scrollHideDelay:a,scrollArea:c,viewport:m,onViewportChange:u,content:p,onContentChange:f,scrollbarX:h,onScrollbarXChange:g,scrollbarXEnabled:N,onScrollbarXEnabledChange:C,scrollbarY:v,onScrollbarYChange:y,scrollbarYEnabled:E,onScrollbarYEnabledChange:A,onCornerWidthChange:b,onCornerHeightChange:S,children:n.jsx(be.div,{dir:R,...i,ref:I,style:{position:"relative","--radix-scroll-area-corner-width":w+"px","--radix-scroll-area-corner-height":j+"px",...e.style}})})});op.displayName=jl;var rp="ScrollAreaViewport",ap=l.forwardRef((e,t)=>{const{__scopeScrollArea:s,children:o,nonce:r,...a}=e,i=St(rp,s),c=l.useRef(null),d=Ae(t,c,i.onViewportChange);return n.jsxs(n.Fragment,{children:[n.jsx(gw,{nonce:r}),n.jsx(be.div,{"data-radix-scroll-area-viewport":"",...a,ref:d,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:n.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:o})})]})});ap.displayName=rp;var gw=l.memo(({nonce:e})=>n.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,t)=>e.nonce===t.nonce),Kt="ScrollAreaScrollbar",ip=l.forwardRef((e,t)=>{const{forceMount:s,...o}=e,r=St(Kt,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"?n.jsx(bw,{...o,ref:t,forceMount:s}):r.type==="scroll"?n.jsx(vw,{...o,ref:t,forceMount:s}):r.type==="auto"?n.jsx(lp,{...o,ref:t,forceMount:s}):r.type==="always"?n.jsx(Sl,{...o,ref:t,"data-state":"visible"}):null});ip.displayName=Kt;var bw=l.forwardRef((e,t)=>{const{forceMount:s,...o}=e,r=St(Kt,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]),n.jsx(bt,{present:s||a,children:n.jsx(lp,{"data-state":a?"visible":"hidden",...o,ref:t})})}),vw=l.forwardRef((e,t)=>{const{forceMount:s,...o}=e,r=St(Kt,e.__scopeScrollArea),a=e.orientation==="horizontal",i=Fr(()=>d("SCROLL_END"),100),[c,d]=hw("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 p=m[u];const f=()=>{const h=m[u];p!==h&&(d("SCROLL"),i()),p=h};return m.addEventListener("scroll",f),()=>m.removeEventListener("scroll",f)}},[r.viewport,a,d,i]),n.jsx(bt,{present:s||c!=="hidden",children:n.jsx(Sl,{"data-state":c==="hidden"?"hidden":"visible",...o,ref:t,onPointerEnter:ue(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:ue(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),lp=l.forwardRef((e,t)=>{const s=St(Kt,e.__scopeScrollArea),{forceMount:o,...r}=e,[a,i]=l.useState(!1),c=e.orientation==="horizontal",d=Fr(()=>{if(s.viewport){const m=s.viewport.offsetWidth<s.viewport.scrollWidth,u=s.viewport.offsetHeight<s.viewport.scrollHeight;i(c?m:u)}},10);return ws(s.viewport,d),ws(s.content,d),n.jsx(bt,{present:o||a,children:n.jsx(Sl,{"data-state":a?"visible":"hidden",...r,ref:t})})}),Sl=l.forwardRef((e,t)=>{const{orientation:s="vertical",...o}=e,r=St(Kt,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=pp(c.viewport,c.content),u={...o,sizes:c,onSizesChange:d,hasThumb:m>0&&m<1,onThumbChange:f=>a.current=f,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:f=>i.current=f};function p(f,h){return Cw(f,i.current,c,h)}return s==="horizontal"?n.jsx(yw,{...u,ref:t,onThumbPositionChange:()=>{if(r.viewport&&a.current){const f=r.viewport.scrollLeft,h=Ic(f,c,r.dir);a.current.style.transform=`translate3d(${h}px, 0, 0)`}},onWheelScroll:f=>{r.viewport&&(r.viewport.scrollLeft=f)},onDragScroll:f=>{r.viewport&&(r.viewport.scrollLeft=p(f,r.dir))}}):s==="vertical"?n.jsx(ww,{...u,ref:t,onThumbPositionChange:()=>{if(r.viewport&&a.current){const f=r.viewport.scrollTop,h=Ic(f,c);a.current.style.transform=`translate3d(0, ${h}px, 0)`}},onWheelScroll:f=>{r.viewport&&(r.viewport.scrollTop=f)},onDragScroll:f=>{r.viewport&&(r.viewport.scrollTop=p(f))}}):null}),yw=l.forwardRef((e,t)=>{const{sizes:s,onSizesChange:o,...r}=e,a=St(Kt,e.__scopeScrollArea),[i,c]=l.useState(),d=l.useRef(null),m=Ae(t,d,a.onScrollbarXChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),n.jsx(dp,{"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":$r(s)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.x),onDragScroll:u=>e.onDragScroll(u.x),onWheelScroll:(u,p)=>{if(a.viewport){const f=a.viewport.scrollLeft+u.deltaX;e.onWheelScroll(f),hp(f,p)&&u.preventDefault()}},onResize:()=>{d.current&&a.viewport&&i&&o({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:dr(i.paddingLeft),paddingEnd:dr(i.paddingRight)}})}})}),ww=l.forwardRef((e,t)=>{const{sizes:s,onSizesChange:o,...r}=e,a=St(Kt,e.__scopeScrollArea),[i,c]=l.useState(),d=l.useRef(null),m=Ae(t,d,a.onScrollbarYChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),n.jsx(dp,{"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":$r(s)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.y),onDragScroll:u=>e.onDragScroll(u.y),onWheelScroll:(u,p)=>{if(a.viewport){const f=a.viewport.scrollTop+u.deltaY;e.onWheelScroll(f),hp(f,p)&&u.preventDefault()}},onResize:()=>{d.current&&a.viewport&&i&&o({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:dr(i.paddingTop),paddingEnd:dr(i.paddingBottom)}})}})}),[jw,cp]=sp(Kt),dp=l.forwardRef((e,t)=>{const{__scopeScrollArea:s,sizes:o,hasThumb:r,onThumbChange:a,onThumbPointerUp:i,onThumbPointerDown:c,onThumbPositionChange:d,onDragScroll:m,onWheelScroll:u,onResize:p,...f}=e,h=St(Kt,s),[g,v]=l.useState(null),y=Ae(t,v),w=l.useRef(null),b=l.useRef(""),j=h.viewport,S=o.content-o.viewport,N=Ye(u),C=Ye(d),E=Fr(p,10);function A(I){if(w.current){const R=I.clientX-w.current.left,k=I.clientY-w.current.top;m({x:R,y:k})}}return l.useEffect(()=>{const I=R=>{const k=R.target;g?.contains(k)&&N(R,S)};return document.addEventListener("wheel",I,{passive:!1}),()=>document.removeEventListener("wheel",I,{passive:!1})},[j,g,S,N]),l.useEffect(C,[o,C]),ws(g,E),ws(h.content,E),n.jsx(jw,{scope:s,scrollbar:g,hasThumb:r,onThumbChange:Ye(a),onThumbPointerUp:Ye(i),onThumbPositionChange:C,onThumbPointerDown:Ye(c),children:n.jsx(be.div,{...f,ref:y,style:{position:"absolute",...f.style},onPointerDown:ue(e.onPointerDown,I=>{I.button===0&&(I.target.setPointerCapture(I.pointerId),w.current=g.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",h.viewport&&(h.viewport.style.scrollBehavior="auto"),A(I))}),onPointerMove:ue(e.onPointerMove,A),onPointerUp:ue(e.onPointerUp,I=>{const R=I.target;R.hasPointerCapture(I.pointerId)&&R.releasePointerCapture(I.pointerId),document.body.style.webkitUserSelect=b.current,h.viewport&&(h.viewport.style.scrollBehavior=""),w.current=null})})})}),cr="ScrollAreaThumb",up=l.forwardRef((e,t)=>{const{forceMount:s,...o}=e,r=cp(cr,e.__scopeScrollArea);return n.jsx(bt,{present:s||r.hasThumb,children:n.jsx(Sw,{ref:t,...o})})}),Sw=l.forwardRef((e,t)=>{const{__scopeScrollArea:s,style:o,...r}=e,a=St(cr,s),i=cp(cr,s),{onThumbPositionChange:c}=i,d=Ae(t,i.onThumbChange),m=l.useRef(void 0),u=Fr(()=>{m.current&&(m.current(),m.current=void 0)},100);return l.useEffect(()=>{const p=a.viewport;if(p){const f=()=>{if(u(),!m.current){const h=kw(p,c);m.current=h,c()}};return c(),p.addEventListener("scroll",f),()=>p.removeEventListener("scroll",f)}},[a.viewport,u,c]),n.jsx(be.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:ue(e.onPointerDownCapture,p=>{const h=p.target.getBoundingClientRect(),g=p.clientX-h.left,v=p.clientY-h.top;i.onThumbPointerDown({x:g,y:v})}),onPointerUp:ue(e.onPointerUp,i.onThumbPointerUp)})});up.displayName=cr;var Nl="ScrollAreaCorner",mp=l.forwardRef((e,t)=>{const s=St(Nl,e.__scopeScrollArea),o=!!(s.scrollbarX&&s.scrollbarY);return s.type!=="scroll"&&o?n.jsx(Nw,{...e,ref:t}):null});mp.displayName=Nl;var Nw=l.forwardRef((e,t)=>{const{__scopeScrollArea:s,...o}=e,r=St(Nl,s),[a,i]=l.useState(0),[c,d]=l.useState(0),m=!!(a&&c),{onCornerWidthChange:u,onCornerHeightChange:p}=r;return ws(r.scrollbarX,()=>{const f=r.scrollbarX?.offsetHeight||0;r.onCornerHeightChange(f),d(f)}),ws(r.scrollbarY,()=>{const f=r.scrollbarY?.offsetWidth||0;r.onCornerWidthChange(f),i(f)}),l.useEffect(()=>()=>{u(0),p(0)},[u,p]),m?n.jsx(be.div,{...o,ref:t,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 dr(e){return e?parseInt(e,10):0}function pp(e,t){const s=e/t;return isNaN(s)?0:s}function $r(e){const t=pp(e.viewport,e.content),s=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,o=(e.scrollbar.size-s)*t;return Math.max(o,18)}function Cw(e,t,s,o="ltr"){const r=$r(s),a=r/2,i=t||a,c=r-i,d=s.scrollbar.paddingStart+i,m=s.scrollbar.size-s.scrollbar.paddingEnd-c,u=s.content-s.viewport,p=o==="ltr"?[0,u]:[u*-1,0];return fp([d,m],p)(e)}function Ic(e,t,s="ltr"){const o=$r(t),r=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-r,i=t.content-t.viewport,c=a-o,d=s==="ltr"?[0,i]:[i*-1,0],m=ui(e,d);return fp([0,i],[0,c])(m)}function fp(e,t){return s=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const o=(t[1]-t[0])/(e[1]-e[0]);return t[0]+o*(s-e[0])}}function hp(e,t){return e>0&&e<t}var kw=(e,t=()=>{})=>{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)&&t(),s=a,o=window.requestAnimationFrame(r)})(),()=>window.cancelAnimationFrame(o)};function Fr(e,t){const s=Ye(e),o=l.useRef(0);return l.useEffect(()=>()=>window.clearTimeout(o.current),[]),l.useCallback(()=>{window.clearTimeout(o.current),o.current=window.setTimeout(s,t)},[s,t])}function ws(e,t){const s=Ye(t);Ve(()=>{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 _w=op,Tw=ap,Ew=mp,Rw=[" ","Enter","ArrowUp","ArrowDown"],Mw=[" ","Enter"],Fn="Select",[Br,Ur,Aw]=Ku(Fn),[Hn]=on(Fn,[Aw,zr]),qr=zr(),[Iw,kn]=Hn(Fn),[Pw,Lw]=Hn(Fn),Ow="SelectProvider";function xp(e){const{__scopeSelect:t,children:s,open:o,defaultOpen:r,onOpenChange:a,value:i,defaultValue:c,onValueChange:d,dir:m,name:u,autoComplete:p,disabled:f,required:h,form:g,internal_do_not_use_render:v}=e,y=qr(t),[w,b]=l.useState(null),[j,S]=l.useState(null),[N,C]=l.useState(!1),E=Er(m),[A,I]=zn({prop:o,defaultProp:r??!1,onChange:a,caller:Fn}),[R,k]=zn({prop:i,defaultProp:c,onChange:d,caller:Fn}),M=l.useRef(null),O=l.useRef(R);l.useEffect(()=>{const fe=g?w?.ownerDocument.getElementById(g):w?.form;if(fe instanceof HTMLFormElement){const je=()=>k(O.current);return fe.addEventListener("reset",je),()=>fe.removeEventListener("reset",je)}},[g,w,k]);const $=w?!!g||!!w.closest("form"):!0,[K,Q]=l.useState(new Set),z=Ft(),H=Array.from(K).map(fe=>fe.props.value).join(";"),ee=l.useCallback(fe=>{Q(je=>new Set(je).add(fe))},[]),U=l.useCallback(fe=>{Q(je=>{const he=new Set(je);return he.delete(fe),he})},[]),Z={required:h,trigger:w,onTriggerChange:b,valueNode:j,onValueNodeChange:S,valueNodeHasChildren:N,onValueNodeHasChildrenChange:C,contentId:z,value:R,onValueChange:k,open:A,onOpenChange:I,dir:E,triggerPointerDownPosRef:M,disabled:f,name:u,autoComplete:p,form:g,nativeOptions:K,nativeSelectKey:H,isFormControl:$};return n.jsx(Wm,{...y,children:n.jsx(Iw,{scope:t,...Z,children:n.jsx(Br.Provider,{scope:t,children:n.jsx(Pw,{scope:t,onNativeOptionAdd:ee,onNativeOptionRemove:U,children:Qw(v)?v(Z):s})})})})}xp.displayName=Ow;var gp=e=>{const{__scopeSelect:t,children:s,...o}=e;return n.jsx(xp,{__scopeSelect:t,...o,internal_do_not_use_render:({isFormControl:r})=>n.jsxs(n.Fragment,{children:[s,r?n.jsx(qp,{__scopeSelect:t}):null]})})};gp.displayName=Fn;var bp="SelectTrigger",vp=l.forwardRef((e,t)=>{const{__scopeSelect:s,disabled:o=!1,...r}=e,a=qr(s),i=kn(bp,s),c=i.disabled||o,d=Ae(t,i.onTriggerChange),m=Ur(s),u=l.useRef("touch"),[p,f,h]=Hp(v=>{const y=m().filter(j=>!j.disabled),w=y.find(j=>j.value===i.value),b=Vp(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 n.jsx(Gm,{asChild:!0,...a,children:n.jsx(be.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":Hr(i.value)?"":void 0,...r,ref:d,onClick:ue(r.onClick,v=>{v.currentTarget.focus(),u.current!=="mouse"&&g(v)}),onPointerDown:ue(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:ue(r.onKeyDown,v=>{const y=p.current!=="";!(v.ctrlKey||v.altKey||v.metaKey)&&v.key.length===1&&f(v.key),!(y&&v.key===" ")&&Rw.includes(v.key)&&(g(),v.preventDefault())})})})});vp.displayName=bp;var yp="SelectValue",wp=l.forwardRef((e,t)=>{const{__scopeSelect:s,className:o,style:r,children:a,placeholder:i="",...c}=e,d=kn(yp,s),{onValueNodeHasChildrenChange:m}=d,u=a!==void 0,p=Ae(t,d.onValueNodeChange);Ve(()=>{m(u)},[m,u]);const f=Hr(d.value);return n.jsx(be.span,{...c,asChild:f?!1:c.asChild,ref:p,style:{pointerEvents:"none"},children:n.jsx(l.Fragment,{children:f?i:a},f?"placeholder":"value")})});wp.displayName=yp;var Dw="SelectIcon",jp=l.forwardRef((e,t)=>{const{__scopeSelect:s,children:o,...r}=e;return n.jsx(be.span,{"aria-hidden":!0,...r,ref:t,children:o||"▼"})});jp.displayName=Dw;var Sp="SelectPortal",[zw,$w]=Hn(Sp,{forceMount:void 0}),Np=e=>{const{__scopeSelect:t,forceMount:s,...o}=e;return n.jsx(zw,{scope:e.__scopeSelect,forceMount:s,children:n.jsx(Mr,{asChild:!0,...o})})};Np.displayName=Sp;var Nn="SelectContent",Cp=l.forwardRef((e,t)=>{const s=$w(Nn,e.__scopeSelect),{forceMount:o=s.forceMount,...r}=e,a=kn(Nn,e.__scopeSelect),[i,c]=l.useState();return Ve(()=>{c(new DocumentFragment)},[]),n.jsx(bt,{present:o||a.open,children:({present:d})=>d?n.jsx(Tp,{...r,ref:t}):n.jsx(kp,{...r,fragment:i})})});Cp.displayName=Nn;var kp=l.forwardRef((e,t)=>{const{__scopeSelect:s,children:o,fragment:r}=e;return r?Cs.createPortal(n.jsx(_p,{scope:s,children:n.jsx(Br.Slot,{scope:s,children:n.jsx("div",{ref:t,children:o})})}),r):null});kp.displayName="SelectContentFragment";var Et=10,[_p,_n]=Hn(Nn),Fw="SelectContentImpl",Bw=bs("SelectContent.RemoveScroll"),Tp=l.forwardRef((e,t)=>{const{__scopeSelect:s}=e,{position:o="item-aligned",onCloseAutoFocus:r,onEscapeKeyDown:a,onPointerDownOutside:i,side:c,sideOffset:d,align:m,alignOffset:u,arrowPadding:p,collisionBoundary:f,collisionPadding:h,sticky:g,hideWhenDetached:v,avoidCollisions:y,...w}=e,b=kn(Nn,s),[j,S]=l.useState(null),[N,C]=l.useState(null),E=Ae(t,S),[A,I]=l.useState(null),[R,k]=l.useState(null),M=Ur(s),[O,$]=l.useState(!1),K=l.useRef(!1);l.useEffect(()=>{if(j)return dm(j)},[j]),tm();const Q=l.useCallback(J=>{const[Se,...Te]=M().map(ce=>ce.ref.current),[ge]=Te.slice(-1),le=document.activeElement;for(const ce of J)if(ce===le||(ce?.scrollIntoView({block:"nearest"}),ce===Se&&N&&(N.scrollTop=0),ce===ge&&N&&(N.scrollTop=N.scrollHeight),ce?.focus(),document.activeElement!==le))return},[M,N]),z=l.useCallback(()=>Q([A,j]),[Q,A,j]);l.useEffect(()=>{O&&z()},[O,z]);const{onOpenChange:H,triggerPointerDownPosRef:ee}=b;l.useEffect(()=>{if(j){let J={x:0,y:0};const Se=ge=>{J={x:Math.abs(Math.round(ge.pageX)-(ee.current?.x??0)),y:Math.abs(Math.round(ge.pageY)-(ee.current?.y??0))}},Te=ge=>{J.x<=10&&J.y<=10?ge.preventDefault():ge.composedPath().includes(j)||H(!1),document.removeEventListener("pointermove",Se),ee.current=null};return ee.current!==null&&(document.addEventListener("pointermove",Se),document.addEventListener("pointerup",Te,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Se),document.removeEventListener("pointerup",Te,{capture:!0})}}},[j,H,ee]),l.useEffect(()=>{const J=()=>H(!1);return window.addEventListener("blur",J),window.addEventListener("resize",J),()=>{window.removeEventListener("blur",J),window.removeEventListener("resize",J)}},[H]);const[U,Z]=Hp(J=>{const Se=M().filter(le=>!le.disabled),Te=Se.find(le=>le.ref.current===document.activeElement),ge=Vp(Se,J,Te);ge&&setTimeout(()=>ge.ref.current?.focus())}),fe=l.useCallback((J,Se,Te)=>{const ge=!K.current&&!Te;(b.value!==void 0&&b.value===Se||ge)&&(I(J),ge&&(K.current=!0))},[b.value]),je=l.useCallback(()=>j?.focus(),[j]),he=l.useCallback((J,Se,Te)=>{const ge=!K.current&&!Te;(b.value!==void 0&&b.value===Se||ge)&&k(J)},[b.value]),oe=o==="popper"?mi:Ep,L=oe===mi?{side:c,sideOffset:d,align:m,alignOffset:u,arrowPadding:p,collisionBoundary:f,collisionPadding:h,sticky:g,hideWhenDetached:v,avoidCollisions:y}:{};return n.jsx(_p,{scope:s,content:j,viewport:N,onViewportChange:C,itemRefCallback:fe,selectedItem:A,onItemLeave:je,itemTextRefCallback:he,focusSelectedItem:z,selectedItemText:R,position:o,isPositioned:O,searchRef:U,children:n.jsx(dl,{as:Bw,allowPinchZoom:!0,children:n.jsx(cl,{asChild:!0,trapped:b.open,onMountAutoFocus:J=>{J.preventDefault()},onUnmountAutoFocus:ue(r,J=>{b.trigger?.focus({preventScroll:!0}),J.preventDefault()}),children:n.jsx(Rr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:J=>J.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:n.jsx(oe,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:J=>J.preventDefault(),...w,...L,onPlaced:()=>$(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...w.style},onKeyDown:ue(w.onKeyDown,J=>{const Se=J.ctrlKey||J.altKey||J.metaKey;if(J.key==="Tab"&&J.preventDefault(),!Se&&J.key.length===1&&Z(J.key),["ArrowUp","ArrowDown","Home","End"].includes(J.key)){let ge=M().filter(le=>!le.disabled).map(le=>le.ref.current);if(["ArrowUp","End"].includes(J.key)&&(ge=ge.slice().reverse()),["ArrowUp","ArrowDown"].includes(J.key)){const le=J.target,ce=ge.indexOf(le);ge=ge.slice(ce+1)}setTimeout(()=>Q(ge)),J.preventDefault()}})})})})})})});Tp.displayName=Fw;var Uw="SelectItemAlignedPosition",Ep=l.forwardRef((e,t)=>{const{__scopeSelect:s,onPlaced:o,...r}=e,a=kn(Nn,s),i=_n(Nn,s),[c,d]=l.useState(null),[m,u]=l.useState(null),p=Ae(t,u),f=Ur(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 E=a.trigger.getBoundingClientRect(),A=m.getBoundingClientRect(),I=a.valueNode.getBoundingClientRect(),R=w.getBoundingClientRect();if(a.dir!=="rtl"){const le=R.left-A.left,ce=I.left-le,Pe=E.left-ce,Re=E.width+Pe,Fe=Math.max(Re,A.width),lt=window.innerWidth-Et,He=ui(ce,[Et,Math.max(Et,lt-Fe)]);c.style.minWidth=Re+"px",c.style.left=He+"px"}else{const le=A.right-R.right,ce=window.innerWidth-I.right-le,Pe=window.innerWidth-E.right-ce,Re=E.width+Pe,Fe=Math.max(Re,A.width),lt=window.innerWidth-Et,He=ui(ce,[Et,Math.max(Et,lt-Fe)]);c.style.minWidth=Re+"px",c.style.right=He+"px"}const k=f(),M=window.innerHeight-Et*2,O=v.scrollHeight,$=window.getComputedStyle(m),K=parseInt($.borderTopWidth,10),Q=parseInt($.paddingTop,10),z=parseInt($.borderBottomWidth,10),H=parseInt($.paddingBottom,10),ee=K+Q+O+H+z,U=Math.min(y.offsetHeight*5,ee),Z=window.getComputedStyle(v),fe=parseInt(Z.paddingTop,10),je=parseInt(Z.paddingBottom,10),he=E.top+E.height/2-Et,oe=M-he,L=y.offsetHeight/2,J=y.offsetTop+L,Se=K+Q+J,Te=ee-Se;if(Se<=he){const le=k.length>0&&y===k[k.length-1].ref.current;c.style.bottom="0px";const ce=m.clientHeight-v.offsetTop-v.offsetHeight,Pe=Math.max(oe,L+(le?je:0)+ce+z),Re=Se+Pe;c.style.height=Re+"px"}else{const le=k.length>0&&y===k[0].ref.current;c.style.top="0px";const Pe=Math.max(he,K+v.offsetTop+(le?fe:0)+L)+Te;c.style.height=Pe+"px",v.scrollTop=Se-he+v.offsetTop}c.style.margin=`${Et}px 0`,c.style.minHeight=U+"px",c.style.maxHeight=M+"px",o?.(),requestAnimationFrame(()=>h.current=!0)}},[f,a.trigger,a.valueNode,c,m,v,y,w,a.dir,o]);Ve(()=>j(),[j]);const[S,N]=l.useState();Ve(()=>{m&&N(window.getComputedStyle(m).zIndex)},[m]);const C=l.useCallback(E=>{E&&g.current===!0&&(j(),b?.(),g.current=!1)},[j,b]);return n.jsx(Hw,{scope:s,contentWrapper:c,shouldExpandOnScrollRef:h,onScrollButtonChange:C,children:n.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:S},children:n.jsx(be.div,{...r,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...r.style}})})})});Ep.displayName=Uw;var qw="SelectPopperPosition",mi=l.forwardRef((e,t)=>{const{__scopeSelect:s,align:o="start",collisionPadding:r=Et,...a}=e,i=qr(s);return n.jsx(Km,{...i,...a,ref:t,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)"}})});mi.displayName=qw;var[Hw,Cl]=Hn(Nn,{}),pi="SelectViewport",Rp=l.forwardRef((e,t)=>{const{__scopeSelect:s,nonce:o,...r}=e,a=_n(pi,s),i=Cl(pi,s),c=Ae(t,a.onViewportChange),d=l.useRef(0);return n.jsxs(n.Fragment,{children:[n.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}),n.jsx(Br.Slot,{scope:s,children:n.jsx(be.div,{"data-radix-select-viewport":"",role:"presentation",...r,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...r.style},onScroll:ue(r.onScroll,m=>{const u=m.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:f}=i;if(f?.current&&p){const h=Math.abs(d.current-u.scrollTop);if(h>0){const g=window.innerHeight-Et*2,v=parseFloat(p.style.minHeight),y=parseFloat(p.style.height),w=Math.max(v,y);if(w<g){const b=w+h,j=Math.min(g,b),S=b-j;p.style.height=j+"px",p.style.bottom==="0px"&&(u.scrollTop=S>0?S:0,p.style.justifyContent="flex-end")}}}d.current=u.scrollTop})})})]})});Rp.displayName=pi;var Mp="SelectGroup",[Vw,Ww]=Hn(Mp),Gw=l.forwardRef((e,t)=>{const{__scopeSelect:s,...o}=e,r=Ft();return n.jsx(Vw,{scope:s,id:r,children:n.jsx(be.div,{role:"group","aria-labelledby":r,...o,ref:t})})});Gw.displayName=Mp;var Ap="SelectLabel",Kw=l.forwardRef((e,t)=>{const{__scopeSelect:s,...o}=e,r=Ww(Ap,s);return n.jsx(be.div,{id:r.id,...o,ref:t})});Kw.displayName=Ap;var ur="SelectItem",[Yw,Ip]=Hn(ur),Pp=l.forwardRef((e,t)=>{const{__scopeSelect:s,value:o,disabled:r=!1,textValue:a,...i}=e,c=kn(ur,s),d=_n(ur,s),m=c.value===o,[u,p]=l.useState(a??""),[f,h]=l.useState(!1),g=Ye(j=>d.itemRefCallback?.(j,o,r)),v=Ae(t,g),y=Ft(),w=l.useRef("touch"),b=()=>{r||(c.onValueChange(o),c.onOpenChange(!1))};return n.jsx(Yw,{scope:s,value:o,disabled:r,textId:y,isSelected:m,onItemTextChange:l.useCallback(j=>{p(S=>S||(j?.textContent??"").trim())},[]),children:n.jsx(Br.ItemSlot,{scope:s,value:o,disabled:r,textValue:u,children:n.jsx(be.div,{role:"option","aria-labelledby":y,"data-highlighted":f?"":void 0,"aria-selected":m&&f,"data-state":m?"checked":"unchecked","aria-disabled":r||void 0,"data-disabled":r?"":void 0,tabIndex:r?void 0:-1,...i,ref:v,onFocus:ue(i.onFocus,()=>h(!0)),onBlur:ue(i.onBlur,()=>h(!1)),onClick:ue(i.onClick,()=>{w.current!=="mouse"&&b()}),onPointerUp:ue(i.onPointerUp,()=>{w.current==="mouse"&&b()}),onPointerDown:ue(i.onPointerDown,j=>{w.current=j.pointerType}),onPointerMove:ue(i.onPointerMove,j=>{w.current=j.pointerType,r?d.onItemLeave?.():w.current==="mouse"&&j.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ue(i.onPointerLeave,j=>{j.currentTarget===document.activeElement&&d.onItemLeave?.()}),onKeyDown:ue(i.onKeyDown,j=>{r||j.target!==j.currentTarget||d.searchRef?.current!==""&&j.key===" "||(Mw.includes(j.key)&&b(),j.key===" "&&j.preventDefault())})})})})});Pp.displayName=ur;var zs="SelectItemText",Lp=l.forwardRef((e,t)=>{const{__scopeSelect:s,className:o,style:r,...a}=e,i=kn(zs,s),c=_n(zs,s),d=Ip(zs,s),m=Lw(zs,s),[u,p]=l.useState(null),f=Ye(b=>c.itemTextRefCallback?.(b,d.value,d.disabled)),h=Ae(t,p,d.onItemTextChange,f),g=u?.textContent,v=l.useMemo(()=>n.jsx("option",{value:d.value,disabled:d.disabled,children:g},d.value),[d.disabled,d.value,g]),{onNativeOptionAdd:y,onNativeOptionRemove:w}=m;return Ve(()=>(y(v),()=>w(v)),[y,w,v]),n.jsxs(n.Fragment,{children:[n.jsx(be.span,{id:d.textId,...a,ref:h}),d.isSelected&&i.valueNode&&!i.valueNodeHasChildren&&!Hr(i.value)?Cs.createPortal(a.children,i.valueNode):null]})});Lp.displayName=zs;var Op="SelectItemIndicator",Dp=l.forwardRef((e,t)=>{const{__scopeSelect:s,...o}=e;return Ip(Op,s).isSelected?n.jsx(be.span,{"aria-hidden":!0,...o,ref:t}):null});Dp.displayName=Op;var fi="SelectScrollUpButton",zp=l.forwardRef((e,t)=>{const s=_n(fi,e.__scopeSelect),o=Cl(fi,e.__scopeSelect),[r,a]=l.useState(!1),i=Ae(t,o.onScrollButtonChange);return Ve(()=>{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?n.jsx(Fp,{...e,ref:i,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=s;c&&d&&(c.scrollTop=c.scrollTop-d.offsetHeight)}}):null});zp.displayName=fi;var hi="SelectScrollDownButton",$p=l.forwardRef((e,t)=>{const s=_n(hi,e.__scopeSelect),o=Cl(hi,e.__scopeSelect),[r,a]=l.useState(!1),i=Ae(t,o.onScrollButtonChange);return Ve(()=>{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?n.jsx(Fp,{...e,ref:i,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=s;c&&d&&(c.scrollTop=c.scrollTop+d.offsetHeight)}}):null});$p.displayName=hi;var Fp=l.forwardRef((e,t)=>{const{__scopeSelect:s,onAutoScroll:o,...r}=e,a=_n("SelectScrollButton",s),i=l.useRef(null),c=Ur(s),d=l.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return l.useEffect(()=>()=>d(),[d]),Ve(()=>{c().find(u=>u.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[c]),n.jsx(be.div,{"aria-hidden":!0,...r,ref:t,style:{flexShrink:0,...r.style},onPointerDown:ue(r.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(o,50))}),onPointerMove:ue(r.onPointerMove,()=>{a.onItemLeave?.(),i.current===null&&(i.current=window.setInterval(o,50))}),onPointerLeave:ue(r.onPointerLeave,()=>{d()})})}),Jw="SelectSeparator",Xw=l.forwardRef((e,t)=>{const{__scopeSelect:s,...o}=e;return n.jsx(be.div,{"aria-hidden":!0,...o,ref:t})});Xw.displayName=Jw;var Bp="SelectArrow",Zw=l.forwardRef((e,t)=>{const{__scopeSelect:s,...o}=e,r=qr(s);return _n(Bp,s).position==="popper"?n.jsx(Ym,{...r,...o,ref:t}):null});Zw.displayName=Bp;var Up="SelectBubbleInput",qp=l.forwardRef(({__scopeSelect:e,...t},s)=>{const o=kn(Up,e),{value:r,onValueChange:a,required:i,disabled:c,name:d,autoComplete:m,form:u}=o,{nativeOptions:p,nativeSelectKey:f}=o,h=l.useRef(null),g=Ae(s,h),v=r??"",y=A2(v),w=Array.from(p).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]),n.jsxs(be.select,{"aria-hidden":!0,required:i,tabIndex:-1,name:d,autoComplete:m,disabled:c,form:u,onChange:b=>a(b.target.value),...t,style:{...Wu,...t.style},ref:g,defaultValue:v,children:[Hr(r)&&!w?n.jsx("option",{value:""}):null,Array.from(p)]},f)});qp.displayName=Up;function Qw(e){return typeof e=="function"}function Hr(e){return e===""||e===void 0}function Hp(e){const t=Ye(e),s=l.useRef(""),o=l.useRef(0),r=l.useCallback(i=>{const c=s.current+i;t(c),(function d(m){s.current=m,window.clearTimeout(o.current),m!==""&&(o.current=window.setTimeout(()=>d(""),1e3))})(c)},[t]),a=l.useCallback(()=>{s.current="",window.clearTimeout(o.current)},[]);return l.useEffect(()=>()=>window.clearTimeout(o.current),[]),[s,r,a]}function Vp(e,t,s){const r=t.length>1&&Array.from(t).every(m=>m===t[0])?t[0]:t,a=s?e.indexOf(s):-1;let i=ej(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 ej(e,t){return e.map((s,o)=>e[(t+o)%e.length])}var Vr="Tabs",[tj]=on(Vr,[Zm]),Wp=Zm(),[nj,kl]=tj(Vr),Gp=l.forwardRef((e,t)=>{const{__scopeTabs:s,value:o,onValueChange:r,defaultValue:a,orientation:i="horizontal",dir:c,activationMode:d="automatic",...m}=e,u=Er(c),[p,f]=zn({prop:o,onChange:r,defaultProp:a??"",caller:Vr});return n.jsx(nj,{scope:s,baseId:Ft(),value:p,onValueChange:f,orientation:i,dir:u,activationMode:d,children:n.jsx(be.div,{dir:u,"data-orientation":i,...m,ref:t})})});Gp.displayName=Vr;var Kp="TabsList",Yp=l.forwardRef((e,t)=>{const{__scopeTabs:s,loop:o=!0,...r}=e,a=kl(Kp,s),i=Wp(s);return n.jsx(pw,{asChild:!0,...i,orientation:a.orientation,dir:a.dir,loop:o,children:n.jsx(be.div,{role:"tablist","aria-orientation":a.orientation,...r,ref:t})})});Yp.displayName=Kp;var Jp="TabsTrigger",Xp=l.forwardRef((e,t)=>{const{__scopeTabs:s,value:o,disabled:r=!1,...a}=e,i=kl(Jp,s),c=Wp(s),d=ef(i.baseId,o),m=tf(i.baseId,o),u=o===i.value;return n.jsx(fw,{asChild:!0,...c,focusable:!r,active:u,children:n.jsx(be.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:t,onMouseDown:ue(e.onMouseDown,p=>{!r&&p.button===0&&p.ctrlKey===!1?i.onValueChange(o):p.preventDefault()}),onKeyDown:ue(e.onKeyDown,p=>{r||p.target!==p.currentTarget||[" ","Enter"].includes(p.key)&&i.onValueChange(o)}),onFocus:ue(e.onFocus,()=>{const p=i.activationMode!=="manual";!u&&!r&&p&&i.onValueChange(o)})})})});Xp.displayName=Jp;var Zp="TabsContent",Qp=l.forwardRef((e,t)=>{const{__scopeTabs:s,value:o,forceMount:r,children:a,...i}=e,c=kl(Zp,s),d=ef(c.baseId,o),m=tf(c.baseId,o),u=o===c.value,p=l.useRef(u);return l.useEffect(()=>{const f=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(f)},[]),n.jsx(bt,{present:r||u,children:({present:f})=>n.jsx(be.div,{"data-state":u?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":d,hidden:!f,id:m,tabIndex:0,...i,ref:t,style:{...e.style,animationDuration:p.current?"0s":void 0},children:f&&a})})});Qp.displayName=Zp;function ef(e,t){return`${e}-trigger-${t}`}function tf(e,t){return`${e}-content-${t}`}var sj=Gp,oj=Yp,rj=Xp,aj=Qp,[Wr]=on("Tooltip",[zr]),Gr=zr(),nf="TooltipProvider",ij=700,xi="tooltip.open",[lj,_l]=Wr(nf),sf=e=>{const{__scopeTooltip:t,delayDuration:s=ij,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)},[]),n.jsx(lj,{scope:t,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})};sf.displayName=nf;var Gs="Tooltip",[cj,ao]=Wr(Gs),of=e=>{const{__scopeTooltip:t,children:s,open:o,defaultOpen:r,onOpenChange:a,disableHoverableContent:i,delayDuration:c}=e,d=_l(Gs,e.__scopeTooltip),m=Gr(t),[u,p]=l.useState(null),f=Ft(),h=l.useRef(0),g=i??d.disableHoverableContent,v=c??d.delayDuration,y=l.useRef(!1),[w,b]=zn({prop:o,defaultProp:r??!1,onChange:E=>{E?(d.onOpen(),document.dispatchEvent(new CustomEvent(xi))):d.onClose(),a?.(E)},caller:Gs}),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)},[]),n.jsx(Wm,{...m,children:n.jsx(cj,{scope:t,contentId:f,open:w,stateAttribute:j,trigger:u,onTriggerChange:p,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})})};of.displayName=Gs;var gi="TooltipTrigger",rf=l.forwardRef((e,t)=>{const{__scopeTooltip:s,...o}=e,r=ao(gi,s),a=_l(gi,s),i=Gr(s),c=l.useRef(null),d=Ae(t,c,r.onTriggerChange),m=l.useRef(!1),u=l.useRef(!1),p=l.useCallback(()=>m.current=!1,[]);return l.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),n.jsx(Gm,{asChild:!0,...i,children:n.jsx(be.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...o,ref:d,onPointerMove:ue(e.onPointerMove,f=>{f.pointerType!=="touch"&&!u.current&&!a.isPointerInTransitRef.current&&(r.onTriggerEnter(),u.current=!0)}),onPointerLeave:ue(e.onPointerLeave,()=>{r.onTriggerLeave(),u.current=!1}),onPointerDown:ue(e.onPointerDown,()=>{r.open&&r.onClose(),m.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:ue(e.onFocus,()=>{m.current||r.onOpen()}),onBlur:ue(e.onBlur,r.onClose),onClick:ue(e.onClick,r.onClose)})})});rf.displayName=gi;var Tl="TooltipPortal",[dj,uj]=Wr(Tl,{forceMount:void 0}),af=e=>{const{__scopeTooltip:t,forceMount:s,children:o,container:r}=e,a=ao(Tl,t);return n.jsx(dj,{scope:t,forceMount:s,children:n.jsx(bt,{present:s||a.open,children:n.jsx(Mr,{asChild:!0,container:r,children:o})})})};af.displayName=Tl;var js="TooltipContent",lf=l.forwardRef((e,t)=>{const s=uj(js,e.__scopeTooltip),{forceMount:o=s.forceMount,side:r="top",...a}=e,i=ao(js,e.__scopeTooltip);return n.jsx(bt,{present:o||i.open,children:i.disableHoverableContent?n.jsx(cf,{side:r,...a,ref:t}):n.jsx(mj,{side:r,...a,ref:t})})}),mj=l.forwardRef((e,t)=>{const s=ao(js,e.__scopeTooltip),o=_l(js,e.__scopeTooltip),r=l.useRef(null),a=Ae(t,r),[i,c]=l.useState(null),{trigger:d,onClose:m}=s,u=r.current,{onPointerInTransitChange:p}=o,f=l.useCallback(()=>{c(null),p(!1)},[p]),h=l.useCallback((g,v)=>{const y=g.currentTarget,w={x:g.clientX,y:g.clientY},b=xj(w,y.getBoundingClientRect()),j=gj(w,b),S=bj(v.getBoundingClientRect()),N=yj([...j,...S]);c(N),p(!0)},[p]);return l.useEffect(()=>()=>f(),[f]),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,f]),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=!vj(w,i);b?f():j&&(f(),m())};return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}},[d,u,i,m,f]),n.jsx(cf,{...e,ref:a})}),[pj,fj]=Wr(Gs,{isInside:!1}),hj=Jb("TooltipContent"),cf=l.forwardRef((e,t)=>{const{__scopeTooltip:s,children:o,"aria-label":r,onEscapeKeyDown:a,onPointerDownOutside:i,...c}=e,d=ao(js,s),m=Gr(s),{onClose:u}=d;return l.useEffect(()=>(document.addEventListener(xi,u),()=>document.removeEventListener(xi,u)),[u]),l.useEffect(()=>{if(d.trigger){const p=f=>{f.target instanceof Node&&f.target.contains(d.trigger)&&u()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[d.trigger,u]),n.jsx(Rr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:p=>p.preventDefault(),onDismiss:u,children:n.jsxs(Km,{"data-state":d.stateAttribute,...m,...c,ref:t,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:[n.jsx(hj,{children:o}),n.jsx(pj,{scope:s,isInside:!0,children:n.jsx(lv,{id:d.contentId,role:"tooltip",children:r||o})})]})})});lf.displayName=js;var df="TooltipArrow",uf=l.forwardRef((e,t)=>{const{__scopeTooltip:s,...o}=e,r=Gr(s);return fj(df,s).isInside?null:n.jsx(Ym,{...r,...o,ref:t})});uf.displayName=df;function xj(e,t){const s=Math.abs(t.top-e.y),o=Math.abs(t.bottom-e.y),r=Math.abs(t.right-e.x),a=Math.abs(t.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 gj(e,t,s=5){const o=[];switch(t){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 bj(e){const{top:t,right:s,bottom:o,left:r}=e;return[{x:r,y:t},{x:s,y:t},{x:s,y:o},{x:r,y:o}]}function vj(e,t){const{x:s,y:o}=e;let r=!1;for(let a=0,i=t.length-1;a<t.length;i=a++){const c=t[a],d=t[i],m=c.x,u=c.y,p=d.x,f=d.y;u>o!=f>o&&s<(p-m)*(o-u)/(f-u)+m&&(r=!r)}return r}function yj(e){const t=e.slice();return t.sort((s,o)=>s.x<o.x?-1:s.x>o.x?1:s.y<o.y?-1:s.y>o.y?1:0),wj(t)}function wj(e){if(e.length<=1)return e.slice();const t=[];for(let o=0;o<e.length;o++){const r=e[o];for(;t.length>=2;){const a=t[t.length-1],i=t[t.length-2];if((a.x-i.x)*(r.y-i.y)>=(a.y-i.y)*(r.x-i.x))t.pop();else break}t.push(r)}t.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(),t.length===1&&s.length===1&&t[0].x===s[0].x&&t[0].y===s[0].y?t:t.concat(s)}var jj=sf,Sj=of,Nj=rf,Cj=af,kj=lf,_j=uf;function qt({...e}){return n.jsx(mm,{"data-slot":"dialog",...e})}function io({...e}){return n.jsx(fm,{"data-slot":"dialog-trigger",...e})}function Tj({...e}){return n.jsx(xm,{"data-slot":"dialog-portal",...e})}function Ej({className:e,...t}){return n.jsx(gm,{"data-slot":"dialog-overlay",className:P("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),...t})}function Ht({className:e,children:t,...s}){return n.jsxs(Tj,{children:[n.jsx(Ej,{}),n.jsxs(bm,{"data-slot":"dialog-content",className:P("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:[t,n.jsxs(Cm,{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:[n.jsx(so,{className:"size-4"}),n.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Yt({className:e,...t}){return n.jsx("div",{"data-slot":"dialog-header",className:P("flex flex-col space-y-1.5 text-center sm:text-left",e),...t})}function Jt({className:e,...t}){return n.jsx(wm,{"data-slot":"dialog-title",className:P("text-lg font-semibold leading-none tracking-tight",e),...t})}function lo({className:e,...t}){return n.jsx(Sm,{"data-slot":"dialog-description",className:P("text-sm text-muted-foreground",e),...t})}function mf({open:e,onOpenChange:t,title:s,description:o,confirmLabel:r="Confirm",variant:a="default",onConfirm:i}){return n.jsx(qt,{open:e,onOpenChange:t,children:n.jsxs(Ht,{children:[n.jsx(Yt,{children:n.jsx(Jt,{children:s})}),n.jsx("p",{className:"text-sm text-muted-foreground",children:o}),n.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[n.jsx(te,{variant:"outline",size:"sm",onClick:()=>t(!1),children:"Cancel"}),n.jsx(te,{variant:a,size:"sm",onClick:()=>{i(),t(!1)},children:r})]})]})})}const Rj="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",Mj="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",Aj="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",Ij="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",Pj=""+new URL("agent-inspector-58K1_MsC.ico",import.meta.url).href,Lj={"agent-inspector":"Inspector",codex:"Codex",opencode:"OpenCode","mimo-code":"MiMo Code","claude-code":"Claude Code","ai-sdk":"AI SDK"};function jo(e){return e?.toLowerCase()??""}function Qn(e,t){for(const s of t)if(e.includes(s))return!0;return!1}function El(e){const t=[jo(e.userAgent),jo(e.conversationId),jo(e.clientProjectFolder)].join(" ");return Qn(t,["agent-inspector","agent inspector","provider-test"])?"agent-inspector":Qn(t,["mimocode","mimo-code","mimo code"])?"mimo-code":Qn(t,["opencode","open-code","open code"])?"opencode":Qn(t,["claude-code","claude code","claudecode","claude-cli","claude cli"])?"claude-code":Qn(t,["codex desktop","codex-cli","openai-codex","codex"])?"codex":Qn(jo(e.userAgent),["ai-sdk","ai/"])?"ai-sdk":"unknown"}function Kr(e){switch(e){case"agent-inspector":case"codex":case"opencode":case"mimo-code":case"claude-code":case"ai-sdk":return Lj[e];case"unknown":return null}}function Oj(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 Dj={"agent-inspector":Pj,codex:Mj,opencode:Aj,"mimo-code":Ij,"claude-code":Rj},zj={"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]"},$j={"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 Yr({client:e,className:t,decorative:s=!1}){if(e==="unknown")return null;const o=Kr(e);if(o===null)return null;if(e==="ai-sdk")return n.jsx("span",{className:P("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]",t),"aria-label":s?void 0:o,"aria-hidden":s?!0:void 0,title:o,children:n.jsx(Eu,{className:"size-1/2","aria-hidden":"true"})});const r=Dj[e];return n.jsx("span",{className:P("inline-flex size-6 shrink-0 items-center justify-center rounded-md border p-0 shadow-sm",zj[e],t),"aria-label":s?void 0:o,"aria-hidden":s?!0:void 0,title:o,children:n.jsx("img",{src:r,alt:"",className:P("size-full object-contain",$j[e]),"aria-hidden":"true"})})}const Fj="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",Bj="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",Uj="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",qj=""+new URL("minimax-BPMzvuL-.jpeg",import.meta.url).href,Hj=""+new URL("alibaba-TTwafVwX.svg",import.meta.url).href,Vj=""+new URL("qwen-mMn3f5ul.webp",import.meta.url).href,Wj=""+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 Kj(e){return e.replace(/[_\s]+/g,"-").split(/[/:@]/).some(s=>s.startsWith("glm-"))}function Yj(e){if(e===null)return"unknown";const t=e.toLowerCase();if(Kj(t))return"zhipuai";for(const[s,o]of Object.entries(Gj))if(t.startsWith(s.toLowerCase()))return o;return"unknown"}const Vn={width:24,height:24,objectFit:"contain"},Jj=Un.memo(({className:e})=>n.jsx("img",{src:Fj,alt:"Anthropic",className:e,style:Vn})),Xj=Un.memo(({className:e})=>n.jsx("img",{src:Bj,alt:"OpenAI",className:e,style:{...Vn,background:"white",borderRadius:"4px"}})),Zj=Un.memo(({className:e})=>n.jsx("img",{src:Uj,alt:"DeepSeek",className:e,style:Vn})),Qj=Un.memo(({className:e})=>n.jsx("img",{src:qj,alt:"MiniMax",className:e,style:Vn})),e5=Un.memo(({className:e})=>n.jsx("img",{src:Hj,alt:"Alibaba",className:e,style:Vn})),t5=Un.memo(({className:e})=>n.jsx("img",{src:Vj,alt:"Qwen",className:e,style:Vn})),n5=Un.memo(({className:e})=>n.jsx("img",{src:Wj,alt:"ZhipuAI",className:e,style:Vn}));function s5({provider:e,className:t}){switch(e){case"anthropic":return n.jsx(Jj,{className:t});case"openai":return n.jsx(Xj,{className:t});case"deepseek":return n.jsx(Zj,{className:t});case"minimax":return n.jsx(Qj,{className:t});case"alibaba":return n.jsx(e5,{className:t});case"qwen":return n.jsx(t5,{className:t});case"zhipuai":return n.jsx(n5,{className:t});case"unknown":return null}}function Ts({delayDuration:e=600,...t}){return n.jsx(jj,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function dt({...e}){return n.jsx(Sj,{"data-slot":"tooltip",...e})}function ut({...e}){return n.jsx(Nj,{"data-slot":"tooltip-trigger",...e})}function mt({className:e,sideOffset:t=0,children:s,...o}){return n.jsx(Cj,{children:n.jsxs(kj,{"data-slot":"tooltip-content",sideOffset:t,className:P("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,n.jsx(_j,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}const o5=3;function r5({items:e,ariaLabel:t,className:s}){if(e.length===0)return n.jsx("span",{className:P("flex h-8 w-12 shrink-0 items-center",s),"aria-hidden":"true"});const o=e.slice(0,o5),r=e.length-o.length;return n.jsx(Ts,{delayDuration:150,children:n.jsxs("span",{className:P("flex h-8 w-12 shrink-0 items-center",s),"aria-label":t,children:[o.map((a,i)=>n.jsxs(dt,{children:[n.jsx(ut,{asChild:!0,children:n.jsx("span",{className:P("border border-border bg-muted/40 inline-flex size-6 shrink-0 items-center justify-center rounded-md",i>0&&"-ml-2"),children:n.jsx(s5,{provider:a.provider,className:"size-4"})})}),n.jsx(mt,{children:a.tooltip})]},`${a.provider}-${String(i)}`)),r>0&&n.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 a5=[["/v1/messages","anthropic"],["/v1/chat/completions","openai"],["/chat/completions","openai"],["/v1/responses","openai"],["/responses","openai"]];function pf(e){const t=e.split("?")[0]??"";for(const[s,o]of a5)if(t===s)return o;return"unknown"}function ff(e,t){for(const s of Array.from(e))t(s)}const i5=/[\u3000-\u9FFF\uAC00-\uD7FF\uF900-\uFAFF\uFF00-\uFFEF\u{1F300}-\u{1FAFF}]/u;function Rl(e){if(e.length===0)return 0;let t=0,s=0;return ff(e,o=>{i5.test(o)?t+=1:s+=1}),Math.ceil(t*1)+Math.ceil(s/4)}function Ml(e){if(e.length===0)return 0;let t=0;return ff(e,()=>{t+=1}),t}function Al(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function G(e,t){return e===null||typeof e!="object"||Array.isArray(e)?void 0:Object.getOwnPropertyDescriptor(e,t)?.value}const l5=["file","shell","browser","web","mcp","code","other"];function bi(e){const t=e.replace(/\s+/g," ").trim();return t.length<=120?t:`${t.slice(0,119)}...`}function hf(e){if(e===null)return null;const t=e.replace(/\s+/g," ").trim();if(t.length===0)return null;const s=t.search(/[.!?。!?]/);return s>=24?bi(t.slice(0,s+1)):bi(t)}function c5(e,t){return`${e} ${t??""}`.toLowerCase()}function es(e,t){return t.some(s=>e.includes(s))}function xf(e,t){const s=c5(e,t);return e.startsWith("mcp__")||e.startsWith("inspector_")||es(s,[" mcp","model context protocol"])?"mcp":es(s,["bash","shell","terminal","command","powershell","exec","process"])?"shell":es(s,["browser","playwright","screenshot","click","navigate","page","tab"])?"browser":es(s,["read","write","edit","file","glob","grep","patch","filesystem","directory"])?"file":es(s,["web","search","http","url","fetch"])?"web":es(s,["code","typescript","javascript","python","repl"])?"code":"other"}function gf(e){const t=G(e,"properties");return t===null||typeof t!="object"||Array.isArray(t)?[]:Object.keys(t).sort((s,o)=>s.localeCompare(o))}function bf(e){const t=G(e,"required");if(!Array.isArray(t))return[];const s=[];for(const o of t)typeof o=="string"&&o.length>0&&s.push(o);return s.sort((o,r)=>o.localeCompare(r))}function d5(e){const t=G(e,"name");if(typeof t!="string"||t.length===0)return null;const s=G(e,"description"),o=G(e,"input_schema")??null,r=typeof s=="string"?s:null;return{name:t,description:r,descriptionPreview:hf(r),category:xf(t,r),parameterCount:gf(o).length,requiredParameters:bf(o),schema:o}}function u5(e){const t=G(e,"function"),s=G(e,"type");if(t===void 0&&typeof s!="string")return null;const o=G(t,"name")??G(e,"name")??(typeof s=="string"?s:void 0);if(typeof o!="string"||o.length===0)return null;const r=G(t,"description")??G(e,"description"),a=G(t,"parameters")??G(e,"parameters")??null,i=typeof r=="string"?r:null;return{name:o,description:i,descriptionPreview:hf(i),category:xf(o,i),parameterCount:gf(a).length,requiredParameters:bf(a),schema:a}}function m5(e){const t=u5(e);return t!==null?t:d5(e)}function p5(e){if(e==null)return null;if(typeof e=="string")return e;const t=G(e,"type"),s=G(e,"name"),o=G(G(e,"function"),"name");if(typeof t=="string"&&typeof o=="string"&&o.length>0)return`${t}: ${o}`;if(typeof t=="string"&&typeof s=="string"&&s.length>0)return`${t}: ${s}`;if(typeof t=="string")return t;const r=JSON.stringify(e);return r===void 0?null:bi(r)}function f5(e){const t=new Map;for(const s of e)t.set(s.category,(t.get(s.category)??0)+1);return l5.flatMap(s=>{const o=t.get(s)??0;return o>0?[{category:s,count:o}]:[]})}function Il(e){const t=G(e,"tools");if(!Array.isArray(t)||t.length===0)return null;const s=[];for(const o of t){const r=m5(o);r!==null&&s.push(r)}return s.length===0?null:{tools:s,toolChoiceLabel:p5(G(e,"tool_choice")),categories:f5(s)}}function Dn(e){return{parsed:null,comparisonValue:e,messageCount:null,toolCount:null}}const ps={parsed:null,toolNames:null};function h5(e){if(typeof e=="string")return e;if(!Array.isArray(e))return"";const t=[];for(const s of e){if(s===null||typeof s!="object")continue;const o=s;switch(o.type){case"text":typeof o.text=="string"&&t.push(o.text);break;case"thinking":case"think":typeof o.thinking=="string"&&t.push(o.thinking);break;case"tool_use":{const a=typeof o.name=="string"?o.name:"",i=o.input!==void 0?JSON.stringify(o.input):"";t.push(`${a} ${i}`.trim());break}case"tool_result":{const a=o.content;if(typeof a=="string")t.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"&&t.push(c)}}break}case"image":t.push("[image]");break}}return t.join(`
|
|
43
43
|
`)}function x5(e){if(typeof e=="string")return e;if(!Array.isArray(e))return"";const t=[];for(const s of e)if(s!==null&&typeof s=="object"){const o=s.text;s.type==="text"&&typeof o=="string"&&t.push(o)}return t.join(`
|
|
44
44
|
`)}function g5(e){if(!Array.isArray(e))return"";const t=[];for(const s of e){if(s===null||typeof s!="object")continue;const o=s;typeof o.name=="string"&&t.push(o.name),typeof o.description=="string"&&t.push(o.description),o.input_schema!==void 0&&t.push(JSON.stringify(o.input_schema))}return t.join(`
|
|
45
45
|
`)}function ya(e,t,s,o){return{role:e,label:t,text:s,size:Rl(s),characters:Ml(s),path:o}}const b5={format:"anthropic",analyzeRequest(e){if(e===null)return Dn(e);try{const t=JSON.parse(e),s=Il(t)?.tools.length??null,o=bx.safeParse(t);return o.success?{parsed:o.data,comparisonValue:o.data,messageCount:o.data.messages.length,toolCount:s}:Dn(e)}catch{return Dn(e)}},analyzeResponse(e){if(e===null)return ps;try{let t=JSON.parse(e);typeof t=="string"&&(t=JSON.parse(t));const s=yx.safeParse(t);if(!s.success)return ps;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 ps}},anatomySegments(e){if(e===null||typeof e!="object")return null;const t=e,s=[];if(t.system!==void 0){const o=x5(t.system);o.length>0&&s.push(ya("system","system",o,"/system"))}if(Array.isArray(t.messages)&&t.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=h5(a.content);s.push(ya(i,`[${r}] ${i}`,c,`/messages/${r}`))}),Array.isArray(t.tools)&&t.tools.length>0){const o=g5(t.tools);s.push(ya("tools","tools",o,"/tools"))}return s.length>0?s:null}};function vi(e){if(typeof e=="string")return e;if(!Array.isArray(e))return"";const t=[];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"?t.push(o.text):(r==="image_url"||r==="input_image")&&t.push("[image]")}return t.join(`
|
|
46
46
|
`)}function v5(e){const t=[],s=vi(e.content);s.length>0&&t.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&&t.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:"";t.push(`${c} ${d}`.trim())}return t.join(`
|
|
47
47
|
`)}function y5(e){if(!Array.isArray(e))return"";const t=[];for(const s of e){if(s===null||typeof s!="object")continue;const o=G(s,"function"),r=G(o,"name")??G(s,"name"),a=G(o,"description")??G(s,"description"),i=G(o,"parameters")??G(s,"parameters");typeof r=="string"&&t.push(r),typeof a=="string"&&t.push(a),i!==void 0&&t.push(JSON.stringify(i))}return t.join(`
|
|
48
|
-
`)}function w5(e){return typeof e=="string"?e.length>0?1:0:Array.isArray(e)?e.length:e==null?null:1}function j5(e){if(typeof e=="string")return e;const t=G(e,"text");if(typeof t=="string")return t;const s=vi(G(e,"content"));if(s.length>0)return s;const o=vi(G(e,"output"));if(o.length>0)return o;const r=G(e,"arguments");return typeof r=="string"?r:""}function S5(e){const t=G(e,"role");if(t==="system"||t==="user"||t==="assistant"||t==="tool")return t;const s=G(e,"type");return s==="function_call_output"?"tool":"user"}function N5(e){const t=G(e,"output");if(!Array.isArray(t))return[];const s=[];for(const o of t){if(G(o,"type")!=="function_call")continue;const r=G(o,"name");typeof r=="string"&&r.length>0&&s.push(r)}return s}function As(e,t,s,o){return{role:e,label:t,text:s,size:Rl(s),characters:Ml(s),path:o}}const C5={format:"openai",analyzeRequest(e){if(e===null)return Dn(e);try{const t=JSON.parse(e),s=Il(t)?.tools.length??null,o=Ix.safeParse(t);if(!o.success){const r=Lx.safeParse(t);return r.success?{parsed:r.data,comparisonValue:r.data,messageCount:w5(r.data.input),toolCount:s}:Dn(e)}return{parsed:o.data,comparisonValue:o.data,messageCount:o.data.messages.length,toolCount:s}}catch{return Dn(e)}},analyzeResponse(e){if(e===null)return ps;const t=Bx(e);if(t===null){const o=Ux(e);if(o===null)return ps;const r=N5(o);return{parsed:o,toolNames:r.length>0?r:null}}const s=t.choices[0]?.message?.tool_calls?.map(o=>o.function?.name??"").filter(o=>o!=="")??[];return{parsed:t,toolNames:s.length>0?s:null}},anatomySegments(e){if(e===null||typeof e!="object")return null;const t=e,s=[];if(typeof t.instructions=="string"&&t.instructions.length>0&&s.push(As("system","instructions",t.instructions,"/instructions")),Array.isArray(t.messages)&&t.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=v5(a);s.push(As(i,`[${r}] ${i}`,c,`/messages/${r}`))}),Array.isArray(t.messages)||(typeof t.input=="string"&&t.input.length>0?s.push(As("user","input",t.input,"/input")):Array.isArray(t.input)&&t.input.forEach((o,r)=>{const a=S5(o),i=j5(o);s.push(As(a,`[${r}] ${a}`,i,`/input/${r}`))})),Array.isArray(t.tools)&&t.tools.length>0){const o=y5(t.tools);s.push(As("tools","tools",o,"/tools"))}return s.length>0?s:null}},k5={format:"unknown",analyzeRequest(e){return Dn(e)},analyzeResponse(){return ps},anatomySegments(){return null}},_5={anthropic:b5,openai:C5,unknown:k5};function vf(e){return _5[e]}function mr(e){const t=pf(e.path);return t==="unknown"?e.apiFormat:t}const Pc="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 yf(e){return e.startsWith("PID:")||e.startsWith("process:")||e.startsWith("connection:")||e.includes("|")}function T5(e){return yf(e)?"No session ID":e.length>24?`${e.slice(0,12)}...${e.slice(-12)}`:e}function wa({icon:e,children:t,title:s,className:o}){return n.jsxs("span",{className:P("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,n.jsx("span",{className:"min-w-0 font-mono tabular-nums",children:t})]})}function E5(){return n.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:[n.jsx(Ue,{className:"size-3 animate-spin"}),"Turn open"]})}function R5({conversationId:e,startTime:t,endTime:s,totalCalls:o,totalInputTokens:r,totalOutputTokens:a,expanded:i,onToggle:c,providers:d,isLoading:m=!1,userAgent:u,clientPid:p,clientProjectFolder:f,showClientIdentity:h=!0,showProcessMetadata:g=!0,timeDisplayFormat:b,onClear:y}){const[w,v]=l.useState(!1),j=K=>{K.stopPropagation(),y!==void 0&&v(!0)},S=l.useCallback(K=>{K.stopPropagation(),window.open(su(e),"_blank","noopener,noreferrer")},[e]),N=d?.map(({provider:K,models:Q})=>({provider:K,tooltip:Q.length===1?Q[0]??K:Q.join(", ")}))??[],C=El({userAgent:u,conversationId:e,clientProjectFolder:f}),E=Kr(C),A=u!=null&&u!=="",I=E??u??null,R=E!==null&&A?`${E} - ${u}`:null,k=yf(e),M=T5(e),O=_r(t,s,b),$=`${o} call${o!==1?"s":""}`;return n.jsxs("div",{role:"button",tabIndex:0,"data-nav-id":`conv-${e}`,"data-nav-action":i?"collapse":"expand",className:P("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:K=>{K.target===K.currentTarget&&(K.key==="Enter"||K.key===" ")&&(K.preventDefault(),c())},children:[n.jsx(r5,{items:N,ariaLabel:"Models used in this session",className:"mt-0.5"}),n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[n.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?p!=null?n.jsxs("span",{className:"min-w-0 max-w-full truncate font-mono text-xs font-semibold text-foreground",title:`PID ${p}`,children:["PID ",p]}):n.jsx("span",{className:"min-w-0 max-w-full truncate font-mono text-xs font-semibold text-foreground",title:e,children:e}):n.jsx("span",{className:"min-w-0 max-w-full truncate font-mono text-xs font-semibold text-foreground",title:e,children:M}),!k&&g&&p!==null&&p!==void 0&&n.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 ${p}`,children:["PID ",p]}),k&&g&&f!==null&&f!==void 0&&f!==""&&n.jsx("span",{className:"min-w-0 max-w-[240px] truncate font-mono text-xs text-muted-foreground",title:f,children:f}),h&&I!==null&&I!==""&&n.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:R??I,children:[n.jsx(Yr,{client:C,className:"size-4 shrink-0",decorative:!0}),n.jsx("span",{className:"font-mono leading-snug tabular-nums",children:I})]}),m&&n.jsx(E5,{})]}),n.jsxs("span",{className:"mt-1.5 flex min-w-0 flex-wrap items-center gap-1.5",children:[n.jsx(wa,{icon:n.jsx(en,{className:"size-3 shrink-0"}),title:O,children:O}),n.jsx(wa,{icon:n.jsx(kr,{className:"size-3 shrink-0"}),children:$}),n.jsxs(wa,{icon:n.jsx(Vs,{className:"size-3 shrink-0"}),className:"max-w-full",children:[n.jsx("span",{className:"text-[var(--inspector-status-info)]",children:Ie(r)})," / ",n.jsx("span",{className:"text-[var(--inspector-status-watch)]",children:Ie(a)})]})]})]}),n.jsxs("span",{className:"flex shrink-0 items-start gap-1.5",children:[n.jsx("button",{type:"button",onClick:S,onKeyDown:K=>{(K.key==="Enter"||K.key===" ")&&S(K)},"aria-label":`Open session ${e} in a new tab`,title:"Open this session in a new tab",className:Pc,children:n.jsx(Xi,{className:"size-3.5"})}),y!==void 0&&n.jsx("button",{type:"button",onClick:j,"aria-label":`Clear group (${o} request${o!==1?"s":""})`,title:"Clear this group from the current view",className:Pc,children:n.jsx(yn,{className:"size-3.5"})}),n.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?n.jsx(Xe,{className:"size-4 shrink-0"}):m?n.jsx(Ue,{className:"size-4 shrink-0 animate-spin"}):n.jsx(gt,{className:"size-4 shrink-0"})})]}),m&&n.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:n.jsx("span",{className:"absolute inset-y-0 left-0 w-1/3 animate-pulse rounded-full bg-[var(--inspector-status-watch)] opacity-70"})}),n.jsx(mf,{open:w,onOpenChange:v,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 M5(e){if(e.sessionId!==null&&e.sessionId!==""&&e.sessionId!==void 0)return e.sessionId;if(e.isTest===!0)return"provider-test";const t=e.clientPid!==null&&e.clientPid!==void 0,s=e.clientProjectFolder!==null&&e.clientProjectFolder!==void 0;if(!t&&!s)return"default";const o=t?`PID:${e.clientPid}`:"unknown",r=s?e.clientProjectFolder:"no-folder";return`${o}|${r}`}function A5(e){const t=new Map;for(const o of e){const r=M5(o),a=t.get(r);a!==void 0?a.push(o):t.set(r,[o])}const s=[];for(const[o,r]of t){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 I5(e,t,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=t[d*2];m=r[d]={index:d,key:s(d),start:u,size:t[d*2+1],end:u+t[d*2+1],lane:0}}return m}}if(a==="length")return e}return Reflect.get(r,a,i)}})}function ts(e,t,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=t(...c),s?.onChange&&!(a&&s.skipInitialOnChange)&&s.onChange(r),a=!1),r}return i.updateDeps=c=>{o=c},i}function Lc(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const P5=(e,t)=>Math.abs(e-t)<1.01,L5=(e,t,s)=>{let o;return function(...r){e.clearTimeout(o),o=e.setTimeout(()=>t.apply(this,r),s)}};let Is;const ja=()=>{if(Is!==void 0)return Is;if(typeof navigator>"u")return Is=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Is=!0;const e=navigator.maxTouchPoints;return Is=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Oc=e=>{const{offsetWidth:t,offsetHeight:s}=e;return{width:t,height:s}},O5=e=>e,D5=e=>{const t=Math.max(e.startIndex-e.overscan,0),o=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=new Array(o);for(let a=0;a<o;a++)r[a]=t+a;return r},z5=(e,t)=>{const s=e.scrollElement;if(!s)return;const o=e.targetWindow;if(!o)return;const r=i=>{const{width:c,height:d}=i;t({width:Math.round(c),height:Math.round(d)})};if(r(Oc(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(Oc(s))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(c):c()});return a.observe(s,{box:"border-box"}),()=>{a.unobserve(s)}},Ks={passive:!0},$5=(e,t)=>{const s=e.scrollElement;if(!s)return;const o=()=>{t({width:s.innerWidth,height:s.innerHeight})};return o(),s.addEventListener("resize",o,Ks),()=>{s.removeEventListener("resize",o)}},F5=typeof window>"u"?!0:"onscrollend"in window,wf=(e,t,s)=>{const o=e.scrollElement;if(!o)return;const r=e.targetWindow;if(!r)return;const a=e.options.useScrollendEvent&&F5;let i=0;const c=a?null:L5(r,()=>t(i,!1),e.options.isScrollingResetDelay),d=p=>()=>{i=s(o),c?.(),t(i,p)},m=d(!0),u=d(!1);return o.addEventListener("scroll",m,Ks),a&&o.addEventListener("scrollend",u,Ks),()=>{o.removeEventListener("scroll",m),a&&o.removeEventListener("scrollend",u)}},B5=(e,t)=>wf(e,t,s=>{const{horizontal:o,isRtl:r}=e.options;return o?s.scrollLeft*(r&&-1||1):s.scrollTop}),U5=(e,t)=>wf(e,t,s=>e.options.horizontal?s.scrollX:s.scrollY),q5=(e,t,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(t?.borderBoxSize){const o=t.borderBoxSize[0];if(o)return Math.round(o[s.options.horizontal?"inlineSize":"blockSize"])}if(!t){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"]},jf=(e,{adjustments:t=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+t,behavior:s})},H5=jf,V5=jf;class W5{constructor(t){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:O5,rangeExtractor:D5,onChange:()=>{},measureElement:q5,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 f in s){const h=s[f];h!==void 0&&(a[f]=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 f=i.count,h=a.count,g=this.getMeasurements(),b=f>0?((o=g[0])==null?void 0:o.key)??i.getItemKey(0):null,y=f>0?((r=g[f-1])==null?void 0:r.key)??i.getItemKey(f-1):null;if(h!==f||f>0&&h>0&&(a.getItemKey(0)!==b||a.getItemKey(h-1)!==y)){m=!0;const j=f>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>f&&this.isAtEnd(i.scrollEndThreshold)&&(f===0||a.getItemKey(h-1)!==y)&&(d=S)}}this.options=a,m&&(this.pendingMin=0,this.itemSizeCacheVersion++);let u=!1,p=0;if(c&&this.scrollOffset!==null){const[f,h]=c,g=this.getMeasurements(),{count:b,getItemKey:y}=this.options;let w=0;for(;w<b&&y(w)!==f;)w++;if(w<b){const v=g[w];if(v){const j=v.start+h;j!==this.scrollOffset&&(p=j-this.scrollOffset,this.scrollOffset=j,u=!0)}}}(u||d)&&(this.pendingScrollAnchor=[u?c[0]:null,u?c[1]:0,d,p])},this.notify=s=>{var o,r;(r=(o=this.options).onChange)==null||r.call(o,this,s)},this.maybeNotify=ts(()=>(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,!(!ja()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};a.addEventListener("touchstart",i,Ks),a.addEventListener("touchend",c,Ks),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&&(ja()&&(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=ts(()=>[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=ts(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:s,paddingStart:o,scrollMargin:r,getItemKey:a,enabled:i,lanes:c,laneAssignmentMode:d,gap:m},u)=>{const p=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 f=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 v=this._flatMeasurements;if(!v||v.length<w){const N=new Float64Array(w);v&&f>0&&N.set(v.subarray(0,f*2)),v=N,this._flatMeasurements=v}let j;if(f===0)j=o+r;else{const N=f-1;j=v[N*2]+v[N*2+1]+m}for(let N=f;N<s;N++){const C=a(N),E=p.get(C),A=typeof E=="number"?E:this.options.estimateSize(N);v[N*2]=j,v[N*2+1]=A,j+=A+m}const S=I5(s,v,a);return this.measurementsCache=S,S}const h=this.measurementsCache.slice(0,f),g=new Array(c).fill(void 0),b=new Float64Array(c);let y=0;for(let w=0;w<f;w++){const v=h[w];v&&(g[v.lane]===void 0&&y++,g[v.lane]=w,b[v.lane]=v.end)}for(let w=f;w<s;w++){const v=a(w),j=this.laneAssignments.get(w);let S,N;const C=d==="estimate"||p.has(v);if(j!==void 0&&this.options.lanes>1){S=j;const R=g[S],k=R!==void 0?h[R]:void 0;N=k?k.end+m:o+r}else if(y===c){let R=0,k=b[0],M=g[0];for(let O=1;O<c;O++){const $=b[O];($<k||$===k&&g[O]<M)&&(R=O,k=$,M=g[O])}S=R,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 E=p.get(v),A=typeof E=="number"?E:this.options.estimateSize(w),I=N+A;h[w]={index:w,start:N,size:A,end:I,key:v,lane:S},g[S]===void 0&&y++,g[S]=w,b[S]=I}return this.measurementsCache=h,h},{key:!1,debug:()=>this.options.debug}),this.calculateRange=ts(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(s,o,r,a)=>s.length===0||o===0?(this.range=null,null):(this.range=K5(s,o,r,a,a===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=ts(()=>{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 f=this.measurementsCache[s];if(!f)return;d=f.key,c=f.start,i=f.size}const u=this.itemSizeCache.get(d)??i,p=o-u;if(p!==0){const f=this.options.anchorTo==="end"&&((r=this.scrollState)==null?void 0:r.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,h=f?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},p,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++,f?this.applyScrollAdjustment(this.getTotalSize()-h):g&&this.applyScrollAdjustment(p),this.notify(!1)}},this.getVirtualItems=ts(()=>[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=Sf(0,o.length-1,a?c=>r[c*2]:c=>Lc(o[c]).start,s);return Lc(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(t)}applyScrollAdjustment(t,s){t!==0&&(ja()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=t:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=t,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&&P5(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 Sf=(e,t,s,o)=>{for(;e<=t;){const r=(e+t)/2|0,a=s(r);if(a<o)e=r+1;else if(a>o)t=r-1;else return r}return e>0?e-1:0};function G5(e,t,s){let o=0;for(;o<=t;){const r=(o+t)/2|0,a=e[r*2];if(a<s)o=r+1;else if(a>s)t=r-1;else return r}return o>0?o-1:0}function K5(e,t,s,o,r){const a=e.length-1;if(e.length<=o)return{startIndex:0,endIndex:a};if(o===1&&r!==null){const m=G5(r,a,s);let u=m;const p=s+t;for(;u<a&&r[u*2]+r[u*2+1]<p;)u++;return{startIndex:m,endIndex:u}}let c=Sf(0,a,m=>e[m].start,s),d=c;if(o===1)for(;d<a&&e[d].end<s+t;)d++;else if(o>1){const m=Array(o).fill(0);for(;d<a&&m.some(p=>p<s+t);){const p=e[d];m[p.lane]=p.end,d++}const u=Array(o).fill(s+t);for(;c>=0&&u.some(p=>p>=s);){const p=e[c];u[p.lane]=p.start,c--}c=Math.max(0,c-c%o),d=Math.min(a,d+(o-1-d%o))}return{startIndex:c,endIndex:d}}const Sa=typeof document<"u"?l.useLayoutEffect:l.useEffect;function Nf({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:s="transform",...o}){const r=l.useReducer(m=>m+1,0)[1],a=l.useRef({enabled:t,mode:s,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=s;const i=m=>{const u=a.current;if(!u.enabled||!u.container)return;const p=m.getTotalSize();if(p!==u.lastSize){u.lastSize=p;const w=m.options.horizontal?"width":"height";u.container.style[w]=`${p}px`}const f=!!m.options.horizontal,h=u.mode==="transform",g=f?"left":"top",b=m.options.scrollMargin,y=m.getVirtualItems();for(const w of y){const v=w.start-b,j=m.elementsCache.get(w.key);j&&u.lastPositions.get(j)!==v&&(u.lastPositions.set(j,v),h?j.style.transform=f?`translate3d(${v}px, 0, 0)`:`translate3d(0, ${v}px, 0)`:j.style[g]=`${v}px`)}},c={...o,onChange:(m,u)=>{var p;const f=a.current;let h=!0;if(f.enabled){i(m);const g=m.range,b=f.prevRange;h=!b||b.isScrolling!==m.isScrolling||b.startIndex!==g?.startIndex||b.endIndex!==g?.endIndex,h&&(f.prevRange=g?{startIndex:g.startIndex,endIndex:g.endIndex,isScrolling:m.isScrolling}:null)}h&&(e&&u?Cs.flushSync(r):r()),(p=o.onChange)==null||p.call(o,m,u)}},[d]=l.useState(()=>{const m=new W5(c);return Object.assign(m,{containerRef:u=>{const p=a.current;if(p.container=u,p.lastSize=null,u&&p.enabled){const f=m.getTotalSize();p.lastSize=f;const h=m.options.horizontal?"width":"height";u.style[h]=`${f}px`}}})});return d.setOptions(c),Sa(()=>d._didMount(),[]),Sa(()=>d._willUpdate()),Sa(()=>{i(d)}),d}function Y5(e){return Nf({observeElementRect:z5,observeElementOffset:B5,scrollToFn:V5,...e})}function J5(e){return Nf({getScrollElement:()=>typeof document<"u"?window:null,observeElementRect:$5,observeElementOffset:U5,scrollToFn:H5,initialOffset:()=>typeof document<"u"?window.scrollY:0,...e})}const sn="agent-inspector:focus-log";function Ss(e){window.dispatchEvent(new CustomEvent(sn,{detail:e}))}function Jr(e){if(typeof CustomEvent>"u"||!(e instanceof CustomEvent))return null;const t=e.detail,s=G(t,"logId");if(typeof s!="number"||!Number.isInteger(s)||s<0)return null;const o=G(t,"tab");switch(o){case"anatomy":case"request":case"response":break;case void 0:break;default:return null}const r=G(t,"source"),a=G(t,"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 Dc(e){switch(e){case"end_turn":case"tool_use":return e;case"max_tokens":return"length";default:return null}}function Cf(e){if(!is(e))return null;if(typeof e.stop_reason=="string")return Dc(e.stop_reason);if(is(e.delta)&&typeof e.delta.stop_reason=="string")return Dc(e.delta.stop_reason);if(Array.isArray(e.choices))for(const t of e.choices){if(!is(t)||typeof t.finish_reason!="string")continue;const s=Z5(t.finish_reason);if(s!==null)return s}if(Array.isArray(e.output)){for(const t of e.output)if(is(t)&&t.type==="function_call")return"tool_use";if(e.status==="completed")return"stop"}if(e.status==="incomplete"&&is(e.incomplete_details)){const t=e.incomplete_details.reason;if(typeof t=="string"&&Q5(t))return"length"}return null}function X5(e){let t=null;for(const s of e.split(`
|
|
49
|
-
`)){const o=s.trim();if(!o.startsWith("data: "))continue;const r=o.slice(6).trim();if(r==="[DONE]")break;try{const a=Cf(JSON.parse(r));a!==null&&(t=a)}catch{}}return t}function Z5(e){switch(e){case"stop":case"length":return e;case"max_tokens":return"length";default:return null}}function Q5(e){switch(e){case"max_output_tokens":case"max_tokens":return!0;default:return!1}}function kf(e){if(e.stopReason!==void 0)return e.stopReason;if(e.responseText===null)return null;try{let t=JSON.parse(e.responseText);return typeof t=="string"&&(t=JSON.parse(t)),Cf(t)}catch{return X5(e.responseText)}}function Pl(e){return e==="end_turn"||e==="stop"||e==="length"}function jt({className:e,style:t,d:s,eyeStalks:o,eyes:r,legs:a,extras:i}){return n.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:t,className:P("inline-block size-5",e),children:[n.jsx("path",{d:s}),o,r,a,i]})}const _n=n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"6.5",y1:"16",x2:"4.5",y2:"19.5"}),n.jsx("line",{x1:"9",y1:"17.5",x2:"8",y2:"20.5"}),n.jsx("line",{x1:"15",y1:"17.5",x2:"16",y2:"20.5"}),n.jsx("line",{x1:"17.5",y1:"16",x2:"19.5",y2:"19.5"})]}),_f=n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"7",y1:"16",x2:"5.5",y2:"18.5"}),n.jsx("line",{x1:"9.5",y1:"17",x2:"8.5",y2:"19.5"}),n.jsx("line",{x1:"14.5",y1:"17",x2:"15.5",y2:"19.5"}),n.jsx("line",{x1:"17",y1:"16",x2:"18.5",y2:"18.5"})]});function Tf({className:e}){return n.jsx(jt,{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:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),n.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"})]}),legs:_n,extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),n.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 eS({className:e}){return n.jsx(jt,{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:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"9.5",y1:"6.5",x2:"9.5",y2:"4.5"}),n.jsx("line",{x1:"14.5",y1:"6.5",x2:"14.5",y2:"4.5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9.5",cy:"4",r:"1.1",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"14.5",cy:"4",r:"1.1",fill:"currentColor",stroke:"none"})]}),legs:_f,extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5 11 C4 9.5 2.5 10 3 12 C3.5 13.5 4.5 13 5 12"}),n.jsx("path",{d:"M19 11 C20 9.5 21.5 10 21 12 C20.5 13.5 19.5 13 19 12"})]})})}function tS({className:e}){return n.jsx(jt,{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:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"7",y1:"7",x2:"6.5",y2:"4.5"}),n.jsx("line",{x1:"17",y1:"7",x2:"17.5",y2:"4.5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"6.5",cy:"4",r:"0.8",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"17.5",cy:"4",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:_n,extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M4 12 C2.5 10.5 1 11 1.5 13 C2 14.5 3.5 14 4.5 13"}),n.jsx("path",{d:"M20 12 C21.5 10.5 23 11 22.5 13 C22 14.5 20.5 14 19.5 13"})]})})}function nS({className:e}){return n.jsx(jt,{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:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"10",y1:"6.5",x2:"10",y2:"3.5"}),n.jsx("line",{x1:"14",y1:"6.5",x2:"14",y2:"3.5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"10",cy:"3",r:"0.7",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"14",cy:"3",r:"0.7",fill:"currentColor",stroke:"none"})]}),legs:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"7",y1:"17",x2:"5",y2:"20.5"}),n.jsx("line",{x1:"9.5",y1:"18.5",x2:"8.5",y2:"21.5"}),n.jsx("line",{x1:"14.5",y1:"18.5",x2:"15.5",y2:"21.5"}),n.jsx("line",{x1:"17",y1:"17",x2:"19",y2:"20.5"})]}),extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M6.5 11 C5 8.5 3 9 3.5 11.5 C4 13.5 5 13 6 12"}),n.jsx("path",{d:"M17.5 11 C19 8.5 21 9 20.5 11.5 C20 13.5 19 13 18 12"})]})})}function sS({className:e}){return n.jsx(jt,{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:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),n.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.8",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:_n,extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),n.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 oS({className:e}){return n.jsx(jt,{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:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),n.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"}),n.jsx("line",{x1:"13.5",y1:"4",x2:"15.5",y2:"5"})]}),legs:_n,extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),n.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 rS({className:e}){return n.jsx(jt,{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:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"10",y1:"8",x2:"10",y2:"6"}),n.jsx("line",{x1:"14",y1:"8",x2:"14",y2:"6"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"9",y1:"6",x2:"11",y2:"6.5"}),n.jsx("line",{x1:"13",y1:"6",x2:"15",y2:"6.5"})]}),legs:_f,extras:n.jsxs(n.Fragment,{children:[n.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"}),n.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 aS({className:e}){return n.jsx(jt,{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:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),n.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.7",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.7",fill:"currentColor",stroke:"none"})]}),legs:_n,extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),n.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),n.jsx("line",{x1:"8.5",y1:"4",x2:"10.5",y2:"4.5"}),n.jsx("line",{x1:"15.5",y1:"4",x2:"13.5",y2:"4.5"}),n.jsx("path",{d:"M9 15.5 C10 14.5 14 14.5 15 15.5"})]})})}function iS({className:e}){return n.jsx(jt,{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:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),n.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9.5",cy:"4.5",r:"1.2",fill:"none",stroke:"currentColor"}),n.jsx("circle",{cx:"14.5",cy:"4.5",r:"1.2",fill:"none",stroke:"currentColor"})]}),legs:_n,extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),n.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),n.jsx("ellipse",{cx:"12",cy:"15",rx:"2",ry:"1.5",fill:"currentColor",stroke:"none"})]})})}function lS({className:e}){return n.jsx(jt,{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:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"9.5",y1:"7",x2:"9",y2:"5"}),n.jsx("line",{x1:"14.5",y1:"7",x2:"15",y2:"5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9",cy:"4.5",r:"1",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"15",cy:"4.5",r:"1",fill:"currentColor",stroke:"none"})]}),legs:_n,extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5 11 C3.5 9 2 9.5 2.5 12 C3 14 4 13 5 12"}),n.jsx("path",{d:"M19 11 C20.5 9 22 9.5 21.5 12 C21 14 20 13 19 12"}),n.jsx("path",{d:"M9 14.5 C10 16 14 16 15 14.5"}),n.jsx("circle",{cx:"7",cy:"13",r:"1",fill:"currentColor",stroke:"none",opacity:"0.3"}),n.jsx("circle",{cx:"17",cy:"13",r:"1",fill:"currentColor",stroke:"none",opacity:"0.3"})]})})}function cS({className:e}){return n.jsx(jt,{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:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5.5"}),n.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5.5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"7.5",y1:"5.5",x2:"16.5",y2:"5.5"}),n.jsx("rect",{x:"7",y:"5",width:"4",height:"2",rx:"0.5",fill:"currentColor",stroke:"none"}),n.jsx("rect",{x:"13",y:"5",width:"4",height:"2",rx:"0.5",fill:"currentColor",stroke:"none"})]}),legs:_n,extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),n.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),n.jsx("path",{d:"M9.5 15 C10.5 16 13.5 16 14.5 15"})]})})}function dS({className:e}){return n.jsx(jt,{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:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"10.5",y1:"9.5",x2:"10.5",y2:"8"}),n.jsx("line",{x1:"13.5",y1:"9.5",x2:"13.5",y2:"8"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"10.5",cy:"7.5",r:"0.8",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"13.5",cy:"7.5",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"8",y1:"16",x2:"6.5",y2:"18"}),n.jsx("line",{x1:"10",y1:"17",x2:"9.5",y2:"19"}),n.jsx("line",{x1:"14",y1:"17",x2:"14.5",y2:"19"}),n.jsx("line",{x1:"16",y1:"16",x2:"17.5",y2:"18"})]}),extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M7.5 12 C6.5 11 5.5 11.5 6 13 C6.5 14 7 13.5 7.5 13"}),n.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 yi=[Tf,eS,tS,nS,sS,oS,rS,aS,iS,lS,cS,dS];function Ll(e){return yi[Math.abs(e)%yi.length]??Tf}function uS(e){const t=yi.length-2;return t<=0?0:1+((Number.isFinite(e)?Math.trunc(e):0)%t+t)%t}function mS(e){return Ll(uS(e))}const pS="x-anthropic-billing-header:";function fS(e){return e.trimStart().toLowerCase().startsWith(pS)}function hS(e){return Al(e)?Object.prototype.hasOwnProperty.call(e,"system"):!1}function xS(e){if(!Al(e))return!1;const t=G(e,"type"),s=G(e,"text");return typeof t!="string"||t!=="text"||typeof s!="string"?!1:fS(s)}function gS(e){let t;try{t=JSON.parse(e)}catch{return{body:e,removed:0}}if(!hS(t))return{body:e,removed:0};const s=t.system;if(!Array.isArray(s)||s.length===0)return{body:e,removed:0};const o=[];let r=0;for(const a of s){if(xS(a)){r+=1;continue}o.push(a)}return r===0?{body:e,removed:0}:(o.length===0?delete t.system:t.system=o,{body:JSON.stringify(t),removed:r})}const bS=400,zc=2e3;function vS(e){return Array.isArray(e)}function yS(e,t){const s=[e];let o=0;for(;s.length>0;){const r=s.pop();if(r!==void 0){if(o+=1,o>t)return o;if(!(r===null||typeof r!="object")){if(vS(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 wS(e){const t=yS(e,zc+1);return t<=bS?{depth:Number.POSITIVE_INFINITY}:t<=zc?{depth:3}:{depth:2}}function jS(e){try{const t=JSON.parse(e);return{kind:"json",data:pr(t)}}catch{return{kind:"text"}}}function Na(e){const t=l.useMemo(()=>e===null?null:jS(e),[e]),s=t?.kind==="json"?t.data:null,o=l.useMemo(()=>s===null?null:wS(s),[s]),[r,a]=l.useState(!1),[i,c]=l.useState(0),[d,m]=l.useState(0),[u,p]=l.useTransition(),f=l.useCallback(()=>{const h=!r,g=h&&o!==null?o.depth:0;p(()=>{a(h),c(g),m(b=>b+1)})},[r,o]);return{parsedData:s,policy:o,isExpanded:r,toggle:f,isPending:u,bulkDepth:i,bulkRevision:d}}function pr(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=>pr(s));const t={};for(const s of Object.keys(e)){const o=Object.getOwnPropertyDescriptor(e,s);t[s]=pr(o?.value)}return t}case"bigint":case"symbol":case"function":case"undefined":return String(e)}return null}function Ef({className:e,orientation:t="horizontal",...s}){return n.jsx(sj,{"data-slot":"tabs","data-orientation":t,orientation:t,className:P("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",e),...s})}const SS=ou("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 Rf({className:e,variant:t="default",...s}){return n.jsx(oj,{"data-slot":"tabs-list","data-variant":t,className:P(SS({variant:t}),e),...s})}function Zt({className:e,...t}){return n.jsx(rj,{"data-slot":"tabs-trigger",className:P("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),...t})}function ct({className:e,...t}){return n.jsx(aj,{"data-slot":"tabs-content",className:P("flex-1 outline-none",e),...t})}function fn(e){const[t,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&&Tt(e).then(i=>{i&&(s(!0),o.current!==null&&clearTimeout(o.current),o.current=setTimeout(()=>s(!1),2e3))})},[e]);return{copied:t,copy:r}}const NS=l.lazy(()=>Wt(()=>import("./CompareDrawer-CShDEmfP.js"),__vite__mapDeps([3,1,2]),import.meta.url).then(e=>({default:e.CompareDrawer}))),CS=l.lazy(()=>Wt(()=>import("./InspectorPet-CWhTcJ9B.js"),__vite__mapDeps([4,1,2]),import.meta.url).then(e=>({default:e.InspectorPet}))),kS=l.lazy(()=>Wt(()=>import("./ReplayDialog-BJ8D4xB2.js"),__vite__mapDeps([5,1,2,6]),import.meta.url).then(e=>({default:e.ReplayDialog}))),_S=l.lazy(()=>Wt(()=>import("./RequestAnatomy-BFKM3yGQ.js"),__vite__mapDeps([7,1,2]),import.meta.url).then(e=>({default:e.RequestAnatomy}))),TS=l.lazy(()=>Wt(()=>import("./ResponseView-Bf3XTX0j.js"),__vite__mapDeps([6,1,2]),import.meta.url).then(e=>({default:e.ResponseView}))),ES=l.lazy(()=>Wt(()=>import("./StreamingChunkSequence-DXJml955.js"),__vite__mapDeps([8,1,2]),import.meta.url).then(e=>({default:e.StreamingChunkSequence}))),wi=l.lazy(()=>Wt(()=>import("./json-viewer-C1LnVpk8.js"),__vite__mapDeps([9,1,2]),import.meta.url).then(e=>({default:e.JsonViewer}))),RS=l.lazy(()=>Wt(()=>import("./json-viewer-C1LnVpk8.js"),__vite__mapDeps([9,1,2]),import.meta.url).then(e=>({default:e.JsonViewerFromString}))),MS=1200,AS=12;function IS(e){const{containerRef:t,setExpandToPath:s,ensureTabActive:o,highlightMs:r}=e,a=l.useRef(null);return l.useCallback(i=>{o?.(),s(i.path);const c=p=>{p.scrollIntoView({behavior:"smooth",block:"center"}),p.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(()=>{p.classList.remove("ring-2","ring-primary/60","ring-offset-1","ring-offset-background","rounded-sm","transition-shadow"),s(null)},r??MS)},m=`[data-anatomy-path="${(p=>typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(p):p.replace(/(["'\\[\](){}])/g,"\\$1"))(i.path)}"]`,u=p=>{const f=t.current;if(f!==null){const h=f.querySelector(m);if(h!==null){c(h);return}}p>0?window.requestAnimationFrame(()=>u(p-1)):s(null)};window.requestAnimationFrame(()=>u(AS))},[t,o,r,s])}var PS={};const $c="The compact log metadata is still available. Retry if the local server was restarting or the body store was briefly unavailable.",Fc=64,Qt=new Map,Vo=new Map;function ls(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 LS(e,t){const s=[];return e!=null&&s.push(`Request ${ls(e)}`),t!=null&&s.push(`Response ${ls(t)}`),s.length===0?null:s.join(" · ")}function OS(e){if(e instanceof Li)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 t=e.message.trim();return{title:"Full bodies could not be loaded",detail:t===""?$c:t}}return{title:"Full bodies could not be loaded",detail:$c}}function DS(){const e=PS.AGENT_INSPECTOR_UI_DETAIL_CACHE_LIMIT;if(e===void 0||e==="")return Fc;const t=Number(e);return!Number.isSafeInteger(t)||t<1||t>1e3?Fc:t}function zS(e){for(Qt.delete(e.id),Qt.set(e.id,e);Qt.size>DS();){const t=Qt.keys().next().value;if(typeof t!="number")break;Qt.delete(t)}return e}function Mf(e){const t=Qt.get(e);return t===void 0?null:(Qt.delete(e),Qt.set(e,t),t)}function $S(e){Qt.delete(e),Vo.delete(e)}async function FS(e,t){const s=Mf(e);if(s!==null)return s;const o=Vo.get(e);if(o!==void 0)return await o;const r=t().then(zS).finally(()=>{Vo.delete(e)});return Vo.set(e,r),await r}class Af{diff(t,s,o={}){let r;typeof o=="function"?(r=o,o={}):"callback"in o&&(r=o.callback);const a=this.castInput(t,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(t,s,o,r){var a;const i=v=>{if(v=this.postProcess(v,o),r){setTimeout(function(){r(v)},0);return}else return v},c=s.length,d=t.length;let m=1,u=c+d;o.maxEditLength!=null&&(u=Math.min(u,o.maxEditLength));const p=(a=o.timeout)!==null&&a!==void 0?a:1/0,f=Date.now()+p,h=[{oldPos:-1,lastComponent:void 0}];let g=this.extractCommon(h[0],s,t,0,o);if(h[0].oldPos+1>=d&&g+1>=c)return i(this.buildValues(h[0].lastComponent,s,t));let b=-1/0,y=1/0;const w=()=>{for(let v=Math.max(b,-m);v<=Math.min(y,m);v+=2){let j;const S=h[v-1],N=h[v+1];S&&(h[v-1]=void 0);let C=!1;if(N){const A=N.oldPos-v;C=N&&0<=A&&A<c}const E=S&&S.oldPos+1<d;if(!C&&!E){h[v]=void 0;continue}if(!E||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,t,v,o),j.oldPos+1>=d&&g+1>=c)return i(this.buildValues(j.lastComponent,s,t))||!0;h[v]=j,j.oldPos+1>=d&&(y=Math.min(y,v-1)),g+1>=c&&(b=Math.max(b,v+1))}m++};if(r)(function v(){setTimeout(function(){if(m>u||Date.now()>f)return r(void 0);w()||v()},0)})();else for(;m<=u&&Date.now()<=f;){const v=w();if(v)return v}}addToPath(t,s,o,r,a){const i=t.lastComponent;return i&&!a.oneChangePerToken&&i.added===s&&i.removed===o?{oldPos:t.oldPos+r,lastComponent:{count:i.count+1,added:s,removed:o,previousComponent:i.previousComponent}}:{oldPos:t.oldPos+r,lastComponent:{count:1,added:s,removed:o,previousComponent:i}}}extractCommon(t,s,o,r,a){const i=s.length,c=o.length;let d=t.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&&(t.lastComponent={count:1,previousComponent:t.lastComponent,added:!1,removed:!1});return u&&!a.oneChangePerToken&&(t.lastComponent={count:u,previousComponent:t.lastComponent,added:!1,removed:!1}),t.oldPos=d,m}equals(t,s,o){return o.comparator?o.comparator(t,s):t===s||!!o.ignoreCase&&t.toLowerCase()===s.toLowerCase()}removeEmpty(t){const s=[];for(let o=0;o<t.length;o++)t[o]&&s.push(t[o]);return s}castInput(t,s){return t}tokenize(t,s){return Array.from(t)}join(t){return t.join("")}postProcess(t,s){return t}get useLongestToken(){return!1}buildValues(t,s,o){const r=[];let a;for(;t;)r.push(t),a=t.previousComponent,delete t.previousComponent,t=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 p=s.slice(d,d+u.count);p=p.map(function(f,h){const g=o[m+h];return g.length>f.length?g:f}),u.value=this.join(p)}else u.value=this.join(s.slice(d,d+u.count));d+=u.count,u.added||(m+=u.count)}}return r}}class BS extends Af{constructor(){super(...arguments),this.tokenize=Pf}equals(t,s,o){return o.ignoreWhitespace?((!o.newlineIsToken||!t.includes(`
|
|
48
|
+
`)}function w5(e){return typeof e=="string"?e.length>0?1:0:Array.isArray(e)?e.length:e==null?null:1}function j5(e){if(typeof e=="string")return e;const t=G(e,"text");if(typeof t=="string")return t;const s=vi(G(e,"content"));if(s.length>0)return s;const o=vi(G(e,"output"));if(o.length>0)return o;const r=G(e,"arguments");return typeof r=="string"?r:""}function S5(e){const t=G(e,"role");if(t==="system"||t==="user"||t==="assistant"||t==="tool")return t;const s=G(e,"type");return s==="function_call_output"?"tool":"user"}function N5(e){const t=G(e,"output");if(!Array.isArray(t))return[];const s=[];for(const o of t){if(G(o,"type")!=="function_call")continue;const r=G(o,"name");typeof r=="string"&&r.length>0&&s.push(r)}return s}function As(e,t,s,o){return{role:e,label:t,text:s,size:Rl(s),characters:Ml(s),path:o}}const C5={format:"openai",analyzeRequest(e){if(e===null)return Dn(e);try{const t=JSON.parse(e),s=Il(t)?.tools.length??null,o=Ix.safeParse(t);if(!o.success){const r=Lx.safeParse(t);return r.success?{parsed:r.data,comparisonValue:r.data,messageCount:w5(r.data.input),toolCount:s}:Dn(e)}return{parsed:o.data,comparisonValue:o.data,messageCount:o.data.messages.length,toolCount:s}}catch{return Dn(e)}},analyzeResponse(e){if(e===null)return ps;const t=Bx(e);if(t===null){const o=Ux(e);if(o===null)return ps;const r=N5(o);return{parsed:o,toolNames:r.length>0?r:null}}const s=t.choices[0]?.message?.tool_calls?.map(o=>o.function?.name??"").filter(o=>o!=="")??[];return{parsed:t,toolNames:s.length>0?s:null}},anatomySegments(e){if(e===null||typeof e!="object")return null;const t=e,s=[];if(typeof t.instructions=="string"&&t.instructions.length>0&&s.push(As("system","instructions",t.instructions,"/instructions")),Array.isArray(t.messages)&&t.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=v5(a);s.push(As(i,`[${r}] ${i}`,c,`/messages/${r}`))}),Array.isArray(t.messages)||(typeof t.input=="string"&&t.input.length>0?s.push(As("user","input",t.input,"/input")):Array.isArray(t.input)&&t.input.forEach((o,r)=>{const a=S5(o),i=j5(o);s.push(As(a,`[${r}] ${a}`,i,`/input/${r}`))})),Array.isArray(t.tools)&&t.tools.length>0){const o=y5(t.tools);s.push(As("tools","tools",o,"/tools"))}return s.length>0?s:null}},k5={format:"unknown",analyzeRequest(e){return Dn(e)},analyzeResponse(){return ps},anatomySegments(){return null}},_5={anthropic:b5,openai:C5,unknown:k5};function vf(e){return _5[e]}function mr(e){const t=pf(e.path);return t==="unknown"?e.apiFormat:t}const Pc="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 yf(e){return e.startsWith("PID:")||e.startsWith("process:")||e.startsWith("connection:")||e.includes("|")}function T5(e){return yf(e)?"No session ID":e.length>24?`${e.slice(0,12)}...${e.slice(-12)}`:e}function wa({icon:e,children:t,title:s,className:o}){return n.jsxs("span",{className:P("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,n.jsx("span",{className:"min-w-0 font-mono tabular-nums",children:t})]})}function E5(){return n.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:[n.jsx(Ue,{className:"size-3 animate-spin"}),"Turn open"]})}function R5({conversationId:e,startTime:t,endTime:s,totalCalls:o,totalInputTokens:r,totalOutputTokens:a,expanded:i,onToggle:c,providers:d,isLoading:m=!1,userAgent:u,clientPid:p,clientProjectFolder:f,showClientIdentity:h=!0,showProcessMetadata:g=!0,timeDisplayFormat:v,onClear:y}){const[w,b]=l.useState(!1),j=K=>{K.stopPropagation(),y!==void 0&&b(!0)},S=l.useCallback(K=>{K.stopPropagation(),window.open(su(e),"_blank","noopener,noreferrer")},[e]),N=d?.map(({provider:K,models:Q})=>({provider:K,tooltip:Q.length===1?Q[0]??K:Q.join(", ")}))??[],C=El({userAgent:u,conversationId:e,clientProjectFolder:f}),E=Kr(C),A=u!=null&&u!=="",I=E??u??null,R=E!==null&&A?`${E} - ${u}`:null,k=yf(e),M=T5(e),O=_r(t,s,v),$=`${o} call${o!==1?"s":""}`;return n.jsxs("div",{role:"button",tabIndex:0,"data-nav-id":`conv-${e}`,"data-nav-action":i?"collapse":"expand",className:P("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:K=>{K.target===K.currentTarget&&(K.key==="Enter"||K.key===" ")&&(K.preventDefault(),c())},children:[n.jsx(r5,{items:N,ariaLabel:"Models used in this session",className:"mt-0.5"}),n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[n.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?p!=null?n.jsxs("span",{className:"min-w-0 max-w-full truncate font-mono text-xs font-semibold text-foreground",title:`PID ${p}`,children:["PID ",p]}):n.jsx("span",{className:"min-w-0 max-w-full truncate font-mono text-xs font-semibold text-foreground",title:e,children:e}):n.jsx("span",{className:"min-w-0 max-w-full truncate font-mono text-xs font-semibold text-foreground",title:e,children:M}),!k&&g&&p!==null&&p!==void 0&&n.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 ${p}`,children:["PID ",p]}),k&&g&&f!==null&&f!==void 0&&f!==""&&n.jsx("span",{className:"min-w-0 max-w-[240px] truncate font-mono text-xs text-muted-foreground",title:f,children:f}),h&&I!==null&&I!==""&&n.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:R??I,children:[n.jsx(Yr,{client:C,className:"size-4 shrink-0",decorative:!0}),n.jsx("span",{className:"font-mono leading-snug tabular-nums",children:I})]}),m&&n.jsx(E5,{})]}),n.jsxs("span",{className:"mt-1.5 flex min-w-0 flex-wrap items-center gap-1.5",children:[n.jsx(wa,{icon:n.jsx(en,{className:"size-3 shrink-0"}),title:O,children:O}),n.jsx(wa,{icon:n.jsx(kr,{className:"size-3 shrink-0"}),children:$}),n.jsxs(wa,{icon:n.jsx(Vs,{className:"size-3 shrink-0"}),className:"max-w-full",children:[n.jsx("span",{className:"text-[var(--inspector-status-info)]",children:Ie(r)})," / ",n.jsx("span",{className:"text-[var(--inspector-status-watch)]",children:Ie(a)})]})]})]}),n.jsxs("span",{className:"flex shrink-0 items-start gap-1.5",children:[n.jsx("button",{type:"button",onClick:S,onKeyDown:K=>{(K.key==="Enter"||K.key===" ")&&S(K)},"aria-label":`Open session ${e} in a new tab`,title:"Open this session in a new tab",className:Pc,children:n.jsx(Xi,{className:"size-3.5"})}),y!==void 0&&n.jsx("button",{type:"button",onClick:j,"aria-label":`Clear group (${o} request${o!==1?"s":""})`,title:"Clear this group from the current view",className:Pc,children:n.jsx(wn,{className:"size-3.5"})}),n.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?n.jsx(Xe,{className:"size-4 shrink-0"}):m?n.jsx(Ue,{className:"size-4 shrink-0 animate-spin"}):n.jsx(gt,{className:"size-4 shrink-0"})})]}),m&&n.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:n.jsx("span",{className:"absolute inset-y-0 left-0 w-1/3 animate-pulse rounded-full bg-[var(--inspector-status-watch)] opacity-70"})}),n.jsx(mf,{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 M5(e){if(e.sessionId!==null&&e.sessionId!==""&&e.sessionId!==void 0)return e.sessionId;if(e.isTest===!0)return"provider-test";const t=e.clientPid!==null&&e.clientPid!==void 0,s=e.clientProjectFolder!==null&&e.clientProjectFolder!==void 0;if(!t&&!s)return"default";const o=t?`PID:${e.clientPid}`:"unknown",r=s?e.clientProjectFolder:"no-folder";return`${o}|${r}`}function A5(e){const t=new Map;for(const o of e){const r=M5(o),a=t.get(r);a!==void 0?a.push(o):t.set(r,[o])}const s=[];for(const[o,r]of t){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 I5(e,t,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=t[d*2];m=r[d]={index:d,key:s(d),start:u,size:t[d*2+1],end:u+t[d*2+1],lane:0}}return m}}if(a==="length")return e}return Reflect.get(r,a,i)}})}function ts(e,t,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=t(...c),s?.onChange&&!(a&&s.skipInitialOnChange)&&s.onChange(r),a=!1),r}return i.updateDeps=c=>{o=c},i}function Lc(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const P5=(e,t)=>Math.abs(e-t)<1.01,L5=(e,t,s)=>{let o;return function(...r){e.clearTimeout(o),o=e.setTimeout(()=>t.apply(this,r),s)}};let Is;const ja=()=>{if(Is!==void 0)return Is;if(typeof navigator>"u")return Is=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Is=!0;const e=navigator.maxTouchPoints;return Is=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Oc=e=>{const{offsetWidth:t,offsetHeight:s}=e;return{width:t,height:s}},O5=e=>e,D5=e=>{const t=Math.max(e.startIndex-e.overscan,0),o=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=new Array(o);for(let a=0;a<o;a++)r[a]=t+a;return r},z5=(e,t)=>{const s=e.scrollElement;if(!s)return;const o=e.targetWindow;if(!o)return;const r=i=>{const{width:c,height:d}=i;t({width:Math.round(c),height:Math.round(d)})};if(r(Oc(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(Oc(s))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(c):c()});return a.observe(s,{box:"border-box"}),()=>{a.unobserve(s)}},Ks={passive:!0},$5=(e,t)=>{const s=e.scrollElement;if(!s)return;const o=()=>{t({width:s.innerWidth,height:s.innerHeight})};return o(),s.addEventListener("resize",o,Ks),()=>{s.removeEventListener("resize",o)}},F5=typeof window>"u"?!0:"onscrollend"in window,wf=(e,t,s)=>{const o=e.scrollElement;if(!o)return;const r=e.targetWindow;if(!r)return;const a=e.options.useScrollendEvent&&F5;let i=0;const c=a?null:L5(r,()=>t(i,!1),e.options.isScrollingResetDelay),d=p=>()=>{i=s(o),c?.(),t(i,p)},m=d(!0),u=d(!1);return o.addEventListener("scroll",m,Ks),a&&o.addEventListener("scrollend",u,Ks),()=>{o.removeEventListener("scroll",m),a&&o.removeEventListener("scrollend",u)}},B5=(e,t)=>wf(e,t,s=>{const{horizontal:o,isRtl:r}=e.options;return o?s.scrollLeft*(r&&-1||1):s.scrollTop}),U5=(e,t)=>wf(e,t,s=>e.options.horizontal?s.scrollX:s.scrollY),q5=(e,t,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(t?.borderBoxSize){const o=t.borderBoxSize[0];if(o)return Math.round(o[s.options.horizontal?"inlineSize":"blockSize"])}if(!t){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"]},jf=(e,{adjustments:t=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+t,behavior:s})},H5=jf,V5=jf;class W5{constructor(t){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:O5,rangeExtractor:D5,onChange:()=>{},measureElement:q5,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 f in s){const h=s[f];h!==void 0&&(a[f]=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 f=i.count,h=a.count,g=this.getMeasurements(),v=f>0?((o=g[0])==null?void 0:o.key)??i.getItemKey(0):null,y=f>0?((r=g[f-1])==null?void 0:r.key)??i.getItemKey(f-1):null;if(h!==f||f>0&&h>0&&(a.getItemKey(0)!==v||a.getItemKey(h-1)!==y)){m=!0;const j=f>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>f&&this.isAtEnd(i.scrollEndThreshold)&&(f===0||a.getItemKey(h-1)!==y)&&(d=S)}}this.options=a,m&&(this.pendingMin=0,this.itemSizeCacheVersion++);let u=!1,p=0;if(c&&this.scrollOffset!==null){const[f,h]=c,g=this.getMeasurements(),{count:v,getItemKey:y}=this.options;let w=0;for(;w<v&&y(w)!==f;)w++;if(w<v){const b=g[w];if(b){const j=b.start+h;j!==this.scrollOffset&&(p=j-this.scrollOffset,this.scrollOffset=j,u=!0)}}}(u||d)&&(this.pendingScrollAnchor=[u?c[0]:null,u?c[1]:0,d,p])},this.notify=s=>{var o,r;(r=(o=this.options).onChange)==null||r.call(o,this,s)},this.maybeNotify=ts(()=>(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,!(!ja()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};a.addEventListener("touchstart",i,Ks),a.addEventListener("touchend",c,Ks),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&&(ja()&&(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=ts(()=>[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=ts(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:s,paddingStart:o,scrollMargin:r,getItemKey:a,enabled:i,lanes:c,laneAssignmentMode:d,gap:m},u)=>{const p=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 f=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&&f>0&&N.set(b.subarray(0,f*2)),b=N,this._flatMeasurements=b}let j;if(f===0)j=o+r;else{const N=f-1;j=b[N*2]+b[N*2+1]+m}for(let N=f;N<s;N++){const C=a(N),E=p.get(C),A=typeof E=="number"?E:this.options.estimateSize(N);b[N*2]=j,b[N*2+1]=A,j+=A+m}const S=I5(s,b,a);return this.measurementsCache=S,S}const h=this.measurementsCache.slice(0,f),g=new Array(c).fill(void 0),v=new Float64Array(c);let y=0;for(let w=0;w<f;w++){const b=h[w];b&&(g[b.lane]===void 0&&y++,g[b.lane]=w,v[b.lane]=b.end)}for(let w=f;w<s;w++){const b=a(w),j=this.laneAssignments.get(w);let S,N;const C=d==="estimate"||p.has(b);if(j!==void 0&&this.options.lanes>1){S=j;const R=g[S],k=R!==void 0?h[R]:void 0;N=k?k.end+m:o+r}else if(y===c){let R=0,k=v[0],M=g[0];for(let O=1;O<c;O++){const $=v[O];($<k||$===k&&g[O]<M)&&(R=O,k=$,M=g[O])}S=R,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 E=p.get(b),A=typeof E=="number"?E:this.options.estimateSize(w),I=N+A;h[w]={index:w,start:N,size:A,end:I,key:b,lane:S},g[S]===void 0&&y++,g[S]=w,v[S]=I}return this.measurementsCache=h,h},{key:!1,debug:()=>this.options.debug}),this.calculateRange=ts(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(s,o,r,a)=>s.length===0||o===0?(this.range=null,null):(this.range=K5(s,o,r,a,a===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=ts(()=>{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 f=this.measurementsCache[s];if(!f)return;d=f.key,c=f.start,i=f.size}const u=this.itemSizeCache.get(d)??i,p=o-u;if(p!==0){const f=this.options.anchorTo==="end"&&((r=this.scrollState)==null?void 0:r.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,h=f?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},p,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++,f?this.applyScrollAdjustment(this.getTotalSize()-h):g&&this.applyScrollAdjustment(p),this.notify(!1)}},this.getVirtualItems=ts(()=>[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=Sf(0,o.length-1,a?c=>r[c*2]:c=>Lc(o[c]).start,s);return Lc(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(t)}applyScrollAdjustment(t,s){t!==0&&(ja()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=t:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=t,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&&P5(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 Sf=(e,t,s,o)=>{for(;e<=t;){const r=(e+t)/2|0,a=s(r);if(a<o)e=r+1;else if(a>o)t=r-1;else return r}return e>0?e-1:0};function G5(e,t,s){let o=0;for(;o<=t;){const r=(o+t)/2|0,a=e[r*2];if(a<s)o=r+1;else if(a>s)t=r-1;else return r}return o>0?o-1:0}function K5(e,t,s,o,r){const a=e.length-1;if(e.length<=o)return{startIndex:0,endIndex:a};if(o===1&&r!==null){const m=G5(r,a,s);let u=m;const p=s+t;for(;u<a&&r[u*2]+r[u*2+1]<p;)u++;return{startIndex:m,endIndex:u}}let c=Sf(0,a,m=>e[m].start,s),d=c;if(o===1)for(;d<a&&e[d].end<s+t;)d++;else if(o>1){const m=Array(o).fill(0);for(;d<a&&m.some(p=>p<s+t);){const p=e[d];m[p.lane]=p.end,d++}const u=Array(o).fill(s+t);for(;c>=0&&u.some(p=>p>=s);){const p=e[c];u[p.lane]=p.start,c--}c=Math.max(0,c-c%o),d=Math.min(a,d+(o-1-d%o))}return{startIndex:c,endIndex:d}}const Sa=typeof document<"u"?l.useLayoutEffect:l.useEffect;function Nf({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:s="transform",...o}){const r=l.useReducer(m=>m+1,0)[1],a=l.useRef({enabled:t,mode:s,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=s;const i=m=>{const u=a.current;if(!u.enabled||!u.container)return;const p=m.getTotalSize();if(p!==u.lastSize){u.lastSize=p;const w=m.options.horizontal?"width":"height";u.container.style[w]=`${p}px`}const f=!!m.options.horizontal,h=u.mode==="transform",g=f?"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=f?`translate3d(${b}px, 0, 0)`:`translate3d(0, ${b}px, 0)`:j.style[g]=`${b}px`)}},c={...o,onChange:(m,u)=>{var p;const f=a.current;let h=!0;if(f.enabled){i(m);const g=m.range,v=f.prevRange;h=!v||v.isScrolling!==m.isScrolling||v.startIndex!==g?.startIndex||v.endIndex!==g?.endIndex,h&&(f.prevRange=g?{startIndex:g.startIndex,endIndex:g.endIndex,isScrolling:m.isScrolling}:null)}h&&(e&&u?Cs.flushSync(r):r()),(p=o.onChange)==null||p.call(o,m,u)}},[d]=l.useState(()=>{const m=new W5(c);return Object.assign(m,{containerRef:u=>{const p=a.current;if(p.container=u,p.lastSize=null,u&&p.enabled){const f=m.getTotalSize();p.lastSize=f;const h=m.options.horizontal?"width":"height";u.style[h]=`${f}px`}}})});return d.setOptions(c),Sa(()=>d._didMount(),[]),Sa(()=>d._willUpdate()),Sa(()=>{i(d)}),d}function Y5(e){return Nf({observeElementRect:z5,observeElementOffset:B5,scrollToFn:V5,...e})}function J5(e){return Nf({getScrollElement:()=>typeof document<"u"?window:null,observeElementRect:$5,observeElementOffset:U5,scrollToFn:H5,initialOffset:()=>typeof document<"u"?window.scrollY:0,...e})}const sn="agent-inspector:focus-log";function Ss(e){window.dispatchEvent(new CustomEvent(sn,{detail:e}))}function Jr(e){if(typeof CustomEvent>"u"||!(e instanceof CustomEvent))return null;const t=e.detail,s=G(t,"logId");if(typeof s!="number"||!Number.isInteger(s)||s<0)return null;const o=G(t,"tab");switch(o){case"anatomy":case"request":case"response":break;case void 0:break;default:return null}const r=G(t,"source"),a=G(t,"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 Dc(e){switch(e){case"end_turn":case"tool_use":return e;case"max_tokens":return"length";default:return null}}function Cf(e){if(!is(e))return null;if(typeof e.stop_reason=="string")return Dc(e.stop_reason);if(is(e.delta)&&typeof e.delta.stop_reason=="string")return Dc(e.delta.stop_reason);if(Array.isArray(e.choices))for(const t of e.choices){if(!is(t)||typeof t.finish_reason!="string")continue;const s=Z5(t.finish_reason);if(s!==null)return s}if(Array.isArray(e.output)){for(const t of e.output)if(is(t)&&t.type==="function_call")return"tool_use";if(e.status==="completed")return"stop"}if(e.status==="incomplete"&&is(e.incomplete_details)){const t=e.incomplete_details.reason;if(typeof t=="string"&&Q5(t))return"length"}return null}function X5(e){let t=null;for(const s of e.split(`
|
|
49
|
+
`)){const o=s.trim();if(!o.startsWith("data: "))continue;const r=o.slice(6).trim();if(r==="[DONE]")break;try{const a=Cf(JSON.parse(r));a!==null&&(t=a)}catch{}}return t}function Z5(e){switch(e){case"stop":case"length":return e;case"max_tokens":return"length";default:return null}}function Q5(e){switch(e){case"max_output_tokens":case"max_tokens":return!0;default:return!1}}function kf(e){if(e.stopReason!==void 0)return e.stopReason;if(e.responseText===null)return null;try{let t=JSON.parse(e.responseText);return typeof t=="string"&&(t=JSON.parse(t)),Cf(t)}catch{return X5(e.responseText)}}function Pl(e){return e==="end_turn"||e==="stop"||e==="length"}function Nt({className:e,style:t,d:s,eyeStalks:o,eyes:r,legs:a,extras:i}){return n.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:t,className:P("inline-block size-5",e),children:[n.jsx("path",{d:s}),o,r,a,i]})}const Tn=n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"6.5",y1:"16",x2:"4.5",y2:"19.5"}),n.jsx("line",{x1:"9",y1:"17.5",x2:"8",y2:"20.5"}),n.jsx("line",{x1:"15",y1:"17.5",x2:"16",y2:"20.5"}),n.jsx("line",{x1:"17.5",y1:"16",x2:"19.5",y2:"19.5"})]}),_f=n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"7",y1:"16",x2:"5.5",y2:"18.5"}),n.jsx("line",{x1:"9.5",y1:"17",x2:"8.5",y2:"19.5"}),n.jsx("line",{x1:"14.5",y1:"17",x2:"15.5",y2:"19.5"}),n.jsx("line",{x1:"17",y1:"16",x2:"18.5",y2:"18.5"})]});function Tf({className:e}){return n.jsx(Nt,{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:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),n.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"})]}),legs:Tn,extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),n.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 eS({className:e}){return n.jsx(Nt,{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:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"9.5",y1:"6.5",x2:"9.5",y2:"4.5"}),n.jsx("line",{x1:"14.5",y1:"6.5",x2:"14.5",y2:"4.5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9.5",cy:"4",r:"1.1",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"14.5",cy:"4",r:"1.1",fill:"currentColor",stroke:"none"})]}),legs:_f,extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5 11 C4 9.5 2.5 10 3 12 C3.5 13.5 4.5 13 5 12"}),n.jsx("path",{d:"M19 11 C20 9.5 21.5 10 21 12 C20.5 13.5 19.5 13 19 12"})]})})}function tS({className:e}){return n.jsx(Nt,{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:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"7",y1:"7",x2:"6.5",y2:"4.5"}),n.jsx("line",{x1:"17",y1:"7",x2:"17.5",y2:"4.5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"6.5",cy:"4",r:"0.8",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"17.5",cy:"4",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:Tn,extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M4 12 C2.5 10.5 1 11 1.5 13 C2 14.5 3.5 14 4.5 13"}),n.jsx("path",{d:"M20 12 C21.5 10.5 23 11 22.5 13 C22 14.5 20.5 14 19.5 13"})]})})}function nS({className:e}){return n.jsx(Nt,{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:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"10",y1:"6.5",x2:"10",y2:"3.5"}),n.jsx("line",{x1:"14",y1:"6.5",x2:"14",y2:"3.5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"10",cy:"3",r:"0.7",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"14",cy:"3",r:"0.7",fill:"currentColor",stroke:"none"})]}),legs:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"7",y1:"17",x2:"5",y2:"20.5"}),n.jsx("line",{x1:"9.5",y1:"18.5",x2:"8.5",y2:"21.5"}),n.jsx("line",{x1:"14.5",y1:"18.5",x2:"15.5",y2:"21.5"}),n.jsx("line",{x1:"17",y1:"17",x2:"19",y2:"20.5"})]}),extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M6.5 11 C5 8.5 3 9 3.5 11.5 C4 13.5 5 13 6 12"}),n.jsx("path",{d:"M17.5 11 C19 8.5 21 9 20.5 11.5 C20 13.5 19 13 18 12"})]})})}function sS({className:e}){return n.jsx(Nt,{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:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),n.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.8",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:Tn,extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),n.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 oS({className:e}){return n.jsx(Nt,{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:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),n.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"}),n.jsx("line",{x1:"13.5",y1:"4",x2:"15.5",y2:"5"})]}),legs:Tn,extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),n.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 rS({className:e}){return n.jsx(Nt,{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:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"10",y1:"8",x2:"10",y2:"6"}),n.jsx("line",{x1:"14",y1:"8",x2:"14",y2:"6"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"9",y1:"6",x2:"11",y2:"6.5"}),n.jsx("line",{x1:"13",y1:"6",x2:"15",y2:"6.5"})]}),legs:_f,extras:n.jsxs(n.Fragment,{children:[n.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"}),n.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 aS({className:e}){return n.jsx(Nt,{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:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),n.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.7",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.7",fill:"currentColor",stroke:"none"})]}),legs:Tn,extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),n.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),n.jsx("line",{x1:"8.5",y1:"4",x2:"10.5",y2:"4.5"}),n.jsx("line",{x1:"15.5",y1:"4",x2:"13.5",y2:"4.5"}),n.jsx("path",{d:"M9 15.5 C10 14.5 14 14.5 15 15.5"})]})})}function iS({className:e}){return n.jsx(Nt,{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:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),n.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9.5",cy:"4.5",r:"1.2",fill:"none",stroke:"currentColor"}),n.jsx("circle",{cx:"14.5",cy:"4.5",r:"1.2",fill:"none",stroke:"currentColor"})]}),legs:Tn,extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),n.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),n.jsx("ellipse",{cx:"12",cy:"15",rx:"2",ry:"1.5",fill:"currentColor",stroke:"none"})]})})}function lS({className:e}){return n.jsx(Nt,{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:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"9.5",y1:"7",x2:"9",y2:"5"}),n.jsx("line",{x1:"14.5",y1:"7",x2:"15",y2:"5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"9",cy:"4.5",r:"1",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"15",cy:"4.5",r:"1",fill:"currentColor",stroke:"none"})]}),legs:Tn,extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5 11 C3.5 9 2 9.5 2.5 12 C3 14 4 13 5 12"}),n.jsx("path",{d:"M19 11 C20.5 9 22 9.5 21.5 12 C21 14 20 13 19 12"}),n.jsx("path",{d:"M9 14.5 C10 16 14 16 15 14.5"}),n.jsx("circle",{cx:"7",cy:"13",r:"1",fill:"currentColor",stroke:"none",opacity:"0.3"}),n.jsx("circle",{cx:"17",cy:"13",r:"1",fill:"currentColor",stroke:"none",opacity:"0.3"})]})})}function cS({className:e}){return n.jsx(Nt,{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:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5.5"}),n.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5.5"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"7.5",y1:"5.5",x2:"16.5",y2:"5.5"}),n.jsx("rect",{x:"7",y:"5",width:"4",height:"2",rx:"0.5",fill:"currentColor",stroke:"none"}),n.jsx("rect",{x:"13",y:"5",width:"4",height:"2",rx:"0.5",fill:"currentColor",stroke:"none"})]}),legs:Tn,extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),n.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),n.jsx("path",{d:"M9.5 15 C10.5 16 13.5 16 14.5 15"})]})})}function dS({className:e}){return n.jsx(Nt,{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:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"10.5",y1:"9.5",x2:"10.5",y2:"8"}),n.jsx("line",{x1:"13.5",y1:"9.5",x2:"13.5",y2:"8"})]}),eyes:n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"10.5",cy:"7.5",r:"0.8",fill:"currentColor",stroke:"none"}),n.jsx("circle",{cx:"13.5",cy:"7.5",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:"8",y1:"16",x2:"6.5",y2:"18"}),n.jsx("line",{x1:"10",y1:"17",x2:"9.5",y2:"19"}),n.jsx("line",{x1:"14",y1:"17",x2:"14.5",y2:"19"}),n.jsx("line",{x1:"16",y1:"16",x2:"17.5",y2:"18"})]}),extras:n.jsxs(n.Fragment,{children:[n.jsx("path",{d:"M7.5 12 C6.5 11 5.5 11.5 6 13 C6.5 14 7 13.5 7.5 13"}),n.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 yi=[Tf,eS,tS,nS,sS,oS,rS,aS,iS,lS,cS,dS];function Ll(e){return yi[Math.abs(e)%yi.length]??Tf}function uS(e){const t=yi.length-2;return t<=0?0:1+((Number.isFinite(e)?Math.trunc(e):0)%t+t)%t}function mS(e){return Ll(uS(e))}const pS="x-anthropic-billing-header:";function fS(e){return e.trimStart().toLowerCase().startsWith(pS)}function hS(e){return Al(e)?Object.prototype.hasOwnProperty.call(e,"system"):!1}function xS(e){if(!Al(e))return!1;const t=G(e,"type"),s=G(e,"text");return typeof t!="string"||t!=="text"||typeof s!="string"?!1:fS(s)}function gS(e){let t;try{t=JSON.parse(e)}catch{return{body:e,removed:0}}if(!hS(t))return{body:e,removed:0};const s=t.system;if(!Array.isArray(s)||s.length===0)return{body:e,removed:0};const o=[];let r=0;for(const a of s){if(xS(a)){r+=1;continue}o.push(a)}return r===0?{body:e,removed:0}:(o.length===0?delete t.system:t.system=o,{body:JSON.stringify(t),removed:r})}const bS=400,zc=2e3;function vS(e){return Array.isArray(e)}function yS(e,t){const s=[e];let o=0;for(;s.length>0;){const r=s.pop();if(r!==void 0){if(o+=1,o>t)return o;if(!(r===null||typeof r!="object")){if(vS(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 wS(e){const t=yS(e,zc+1);return t<=bS?{depth:Number.POSITIVE_INFINITY}:t<=zc?{depth:3}:{depth:2}}function jS(e){try{const t=JSON.parse(e);return{kind:"json",data:pr(t)}}catch{return{kind:"text"}}}function Na(e){const t=l.useMemo(()=>e===null?null:jS(e),[e]),s=t?.kind==="json"?t.data:null,o=l.useMemo(()=>s===null?null:wS(s),[s]),[r,a]=l.useState(!1),[i,c]=l.useState(0),[d,m]=l.useState(0),[u,p]=l.useTransition(),f=l.useCallback(()=>{const h=!r,g=h&&o!==null?o.depth:0;p(()=>{a(h),c(g),m(v=>v+1)})},[r,o]);return{parsedData:s,policy:o,isExpanded:r,toggle:f,isPending:u,bulkDepth:i,bulkRevision:d}}function pr(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=>pr(s));const t={};for(const s of Object.keys(e)){const o=Object.getOwnPropertyDescriptor(e,s);t[s]=pr(o?.value)}return t}case"bigint":case"symbol":case"function":case"undefined":return String(e)}return null}function Ef({className:e,orientation:t="horizontal",...s}){return n.jsx(sj,{"data-slot":"tabs","data-orientation":t,orientation:t,className:P("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",e),...s})}const SS=ou("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 Rf({className:e,variant:t="default",...s}){return n.jsx(oj,{"data-slot":"tabs-list","data-variant":t,className:P(SS({variant:t}),e),...s})}function Zt({className:e,...t}){return n.jsx(rj,{"data-slot":"tabs-trigger",className:P("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),...t})}function ct({className:e,...t}){return n.jsx(aj,{"data-slot":"tabs-content",className:P("flex-1 outline-none",e),...t})}function hn(e){const[t,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&&yt(e).then(i=>{i&&(s(!0),o.current!==null&&clearTimeout(o.current),o.current=setTimeout(()=>s(!1),2e3))})},[e]);return{copied:t,copy:r}}const NS=l.lazy(()=>Wt(()=>import("./CompareDrawer-B6l7sK_o.js"),__vite__mapDeps([3,1,2]),import.meta.url).then(e=>({default:e.CompareDrawer}))),CS=l.lazy(()=>Wt(()=>import("./InspectorPet-Dv-hDdxU.js"),__vite__mapDeps([4,1,2]),import.meta.url).then(e=>({default:e.InspectorPet}))),kS=l.lazy(()=>Wt(()=>import("./ReplayDialog-BACtWGKs.js"),__vite__mapDeps([5,1,2,6]),import.meta.url).then(e=>({default:e.ReplayDialog}))),_S=l.lazy(()=>Wt(()=>import("./RequestAnatomy-DqG3yRes.js"),__vite__mapDeps([7,1,2]),import.meta.url).then(e=>({default:e.RequestAnatomy}))),TS=l.lazy(()=>Wt(()=>import("./ResponseView-CwqmhaXg.js"),__vite__mapDeps([6,1,2]),import.meta.url).then(e=>({default:e.ResponseView}))),ES=l.lazy(()=>Wt(()=>import("./StreamingChunkSequence-DMdSkso8.js"),__vite__mapDeps([8,1,2]),import.meta.url).then(e=>({default:e.StreamingChunkSequence}))),wi=l.lazy(()=>Wt(()=>import("./json-viewer-DIr-vdVp.js"),__vite__mapDeps([9,1,2]),import.meta.url).then(e=>({default:e.JsonViewer}))),RS=l.lazy(()=>Wt(()=>import("./json-viewer-DIr-vdVp.js"),__vite__mapDeps([9,1,2]),import.meta.url).then(e=>({default:e.JsonViewerFromString}))),MS=1200,AS=12;function IS(e){const{containerRef:t,setExpandToPath:s,ensureTabActive:o,highlightMs:r}=e,a=l.useRef(null);return l.useCallback(i=>{o?.(),s(i.path);const c=p=>{p.scrollIntoView({behavior:"smooth",block:"center"}),p.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(()=>{p.classList.remove("ring-2","ring-primary/60","ring-offset-1","ring-offset-background","rounded-sm","transition-shadow"),s(null)},r??MS)},m=`[data-anatomy-path="${(p=>typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(p):p.replace(/(["'\\[\](){}])/g,"\\$1"))(i.path)}"]`,u=p=>{const f=t.current;if(f!==null){const h=f.querySelector(m);if(h!==null){c(h);return}}p>0?window.requestAnimationFrame(()=>u(p-1)):s(null)};window.requestAnimationFrame(()=>u(AS))},[t,o,r,s])}var PS={};const $c="The compact log metadata is still available. Retry if the local server was restarting or the body store was briefly unavailable.",Fc=64,Qt=new Map,Vo=new Map;function ls(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 LS(e,t){const s=[];return e!=null&&s.push(`Request ${ls(e)}`),t!=null&&s.push(`Response ${ls(t)}`),s.length===0?null:s.join(" · ")}function OS(e){if(e instanceof Li)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 t=e.message.trim();return{title:"Full bodies could not be loaded",detail:t===""?$c:t}}return{title:"Full bodies could not be loaded",detail:$c}}function DS(){const e=PS.AGENT_INSPECTOR_UI_DETAIL_CACHE_LIMIT;if(e===void 0||e==="")return Fc;const t=Number(e);return!Number.isSafeInteger(t)||t<1||t>1e3?Fc:t}function zS(e){for(Qt.delete(e.id),Qt.set(e.id,e);Qt.size>DS();){const t=Qt.keys().next().value;if(typeof t!="number")break;Qt.delete(t)}return e}function Mf(e){const t=Qt.get(e);return t===void 0?null:(Qt.delete(e),Qt.set(e,t),t)}function $S(e){Qt.delete(e),Vo.delete(e)}async function FS(e,t){const s=Mf(e);if(s!==null)return s;const o=Vo.get(e);if(o!==void 0)return await o;const r=t().then(zS).finally(()=>{Vo.delete(e)});return Vo.set(e,r),await r}class Af{diff(t,s,o={}){let r;typeof o=="function"?(r=o,o={}):"callback"in o&&(r=o.callback);const a=this.castInput(t,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(t,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=t.length;let m=1,u=c+d;o.maxEditLength!=null&&(u=Math.min(u,o.maxEditLength));const p=(a=o.timeout)!==null&&a!==void 0?a:1/0,f=Date.now()+p,h=[{oldPos:-1,lastComponent:void 0}];let g=this.extractCommon(h[0],s,t,0,o);if(h[0].oldPos+1>=d&&g+1>=c)return i(this.buildValues(h[0].lastComponent,s,t));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 A=N.oldPos-b;C=N&&0<=A&&A<c}const E=S&&S.oldPos+1<d;if(!C&&!E){h[b]=void 0;continue}if(!E||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,t,b,o),j.oldPos+1>=d&&g+1>=c)return i(this.buildValues(j.lastComponent,s,t))||!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()>f)return r(void 0);w()||b()},0)})();else for(;m<=u&&Date.now()<=f;){const b=w();if(b)return b}}addToPath(t,s,o,r,a){const i=t.lastComponent;return i&&!a.oneChangePerToken&&i.added===s&&i.removed===o?{oldPos:t.oldPos+r,lastComponent:{count:i.count+1,added:s,removed:o,previousComponent:i.previousComponent}}:{oldPos:t.oldPos+r,lastComponent:{count:1,added:s,removed:o,previousComponent:i}}}extractCommon(t,s,o,r,a){const i=s.length,c=o.length;let d=t.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&&(t.lastComponent={count:1,previousComponent:t.lastComponent,added:!1,removed:!1});return u&&!a.oneChangePerToken&&(t.lastComponent={count:u,previousComponent:t.lastComponent,added:!1,removed:!1}),t.oldPos=d,m}equals(t,s,o){return o.comparator?o.comparator(t,s):t===s||!!o.ignoreCase&&t.toLowerCase()===s.toLowerCase()}removeEmpty(t){const s=[];for(let o=0;o<t.length;o++)t[o]&&s.push(t[o]);return s}castInput(t,s){return t}tokenize(t,s){return Array.from(t)}join(t){return t.join("")}postProcess(t,s){return t}get useLongestToken(){return!1}buildValues(t,s,o){const r=[];let a;for(;t;)r.push(t),a=t.previousComponent,delete t.previousComponent,t=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 p=s.slice(d,d+u.count);p=p.map(function(f,h){const g=o[m+h];return g.length>f.length?g:f}),u.value=this.join(p)}else u.value=this.join(s.slice(d,d+u.count));d+=u.count,u.added||(m+=u.count)}}return r}}class BS extends Af{constructor(){super(...arguments),this.tokenize=Pf}equals(t,s,o){return o.ignoreWhitespace?((!o.newlineIsToken||!t.includes(`
|
|
50
50
|
`))&&(t=t.trim()),(!o.newlineIsToken||!s.includes(`
|
|
51
51
|
`))&&(s=s.trim())):o.ignoreNewlineAtEof&&!o.newlineIsToken&&(t.endsWith(`
|
|
52
52
|
`)&&(t=t.slice(0,-1)),s.endsWith(`
|
|
@@ -54,7 +54,7 @@ import{l as Wh,u as Vt,s as x,n as T,b as Ce,_ as Yo,a as V,c as qe,o as _,d as
|
|
|
54
54
|
`));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&&!t.newlineIsToken?s[s.length-1]+=a:s.push(a)}return s}class qS extends Af{constructor(){super(...arguments),this.tokenize=Pf}get useLongestToken(){return!0}castInput(t,s){const{undefinedReplacement:o,stringifyReplacer:r=(a,i)=>typeof i>"u"?o:i}=s;return typeof t=="string"?t:JSON.stringify(ji(t,null,null,r),null," ")}equals(t,s,o){return super.equals(t.replace(/,([\r\n])/g,"$1"),s.replace(/,([\r\n])/g,"$1"),o)}}const HS=new qS;function VS(e,t,s){return HS.diff(e,t,s)}function ji(e,t,s,o,r){t=t||[],s=s||[],o&&(e=o(r===void 0?"":r,e));let a;for(a=0;a<t.length;a+=1)if(t[a]===e)return s[a];let i;if(Object.prototype.toString.call(e)==="[object Array]"){for(t.push(e),i=new Array(e.length),s.push(i),a=0;a<e.length;a+=1)i[a]=ji(e[a],t,s,o,String(a));return t.pop(),s.pop(),i}if(e&&e.toJSON&&(e=e.toJSON()),typeof e=="object"&&e!==null){t.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]=ji(e[d],t,s,o,d);t.pop(),s.pop()}else i=e;return i}function Bc(e){return e===void 0?[]:Object.entries(e).map(t=>[t[0].toLowerCase(),t[1]]).sort(([t],[s])=>t.localeCompare(s))}function Uc([e,t]){return`${e}: ${t}`}function Si(e){const t=[];let s=0,o=0;for(const r of e){const a=r.value.split(`
|
|
55
55
|
`);a.length>0&&a[a.length-1]===""&&a.pop();for(const i of a)r.added?(o+=1,t.push({kind:"added",text:i,oldLineNumber:null,newLineNumber:o})):r.removed?(s+=1,t.push({kind:"removed",text:i,oldLineNumber:s,newLineNumber:null})):(s+=1,o+=1,t.push({kind:"context",text:i,oldLineNumber:s,newLineNumber:o}))}return t}function WS(e,t){const s=Bc(e).map(Uc).join(`
|
|
56
56
|
`),o=Bc(t).map(Uc).join(`
|
|
57
|
-
`);if(s===o)return{lines:[],isEmpty:!0};const r=If(s,o);return{lines:Si(r),isEmpty:!1}}function qc(e){try{const t=JSON.parse(e);return t===null||typeof t=="string"||typeof t=="object"?t:null}catch{return null}}function GS(e,t){const s=e??"",o=t??"";if(s===o)return{lines:[],isEmpty:!0};const r=qc(s),a=qc(o);if(r!==null&&a!==null){const c=VS(r,a)??[];if(c.length===1){const d=c[0];if(d!==void 0&&!d.added&&!d.removed)return{lines:[],isEmpty:!0}}return{lines:Si(c),isEmpty:!1}}const i=If(s,o);return{lines:Si(i),isEmpty:!1}}const KS=22,Ca=1e4;function YS(e){return e==="added"?"+":e==="removed"?"-":" "}function JS(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 XS=function({result:t,emptyLabel:s}){const[o,r]=l.useState("unified"),a=l.useRef(null),i=Y5({count:t.lines.length,getScrollElement:()=>a.current,estimateSize:()=>KS,overscan:10});if(t.isEmpty)return n.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=t.lines.length,d=c>Ca,m=d?t.lines.slice(0,Ca):t.lines;return n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[n.jsxs("span",{children:[c.toLocaleString()," line",c===1?"":"s",d&&` (showing first ${Ca.toLocaleString()})`]}),n.jsxs("div",{className:"inline-flex rounded-md border border-border overflow-hidden",children:[n.jsxs("button",{type:"button",onClick:()=>r("unified"),"aria-pressed":o==="unified",className:P("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:[n.jsx(g1,{className:"size-3"}),"Unified"]}),n.jsxs("button",{type:"button",onClick:()=>r("split"),"aria-pressed":o==="split",className:P("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:[n.jsx(og,{className:"size-3"}),"Split"]})]})]}),n.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"?n.jsx(ZS,{virtualizer:i,lines:m}):n.jsx(tN,{lines:m})})]})};function ZS({virtualizer:e,lines:t}){return n.jsx("div",{style:{height:`${e.getTotalSize()}px`,width:"100%",position:"relative"},children:e.getVirtualItems().map(s=>{const o=t[s.index];return o===void 0?null:n.jsxs("div",{"data-index":s.index,ref:e.measureElement,className:P("flex items-start gap-3 px-2",JS(o.kind)),style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${s.start}px)`},children:[n.jsx("span",{className:"select-none text-muted-foreground/60 w-10 text-right tabular-nums",children:o.oldLineNumber??""}),n.jsx("span",{className:"select-none text-muted-foreground/60 w-10 text-right tabular-nums",children:o.newLineNumber??""}),n.jsx("span",{className:P("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:YS(o.kind)}),n.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:o.text})]},s.key)})})}function QS(e){const t=[];let s=0;for(;s<e.length;){const o=e[s];if(o===void 0)break;if(o.kind==="context"){t.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?t.push({left:{text:d.text,lineNumber:d.oldLineNumber},right:{text:m.text,lineNumber:m.newLineNumber},kind:"changed"}):d!==void 0?t.push({left:{text:d.text,lineNumber:d.oldLineNumber},right:null,kind:"removed"}):m!==void 0&&t.push({left:null,right:{text:m.text,lineNumber:m.newLineNumber},kind:"added"})}}return t}function eN(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 tN({lines:e}){const t=QS(e);return n.jsx("div",{"data-testid":"diff-split",children:t.map((s,o)=>n.jsxs("div",{className:P("grid grid-cols-2 font-mono text-xs",eN(s.kind)),children:[n.jsxs("div",{className:"flex items-start gap-2 px-2 border-r border-border/50",children:[n.jsx("span",{className:"select-none text-muted-foreground/60 w-8 text-right tabular-nums",children:s.left?.lineNumber??""}),n.jsx("span",{className:P("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?"-":" "}),n.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:s.left?.text??""})]}),n.jsxs("div",{className:"flex items-start gap-2 px-2",children:[n.jsx("span",{className:"select-none text-muted-foreground/60 w-8 text-right tabular-nums",children:s.right?.lineNumber??""}),n.jsx("span",{className:P("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?"+":" "}),n.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:s.right?.text??""})]})]},o))})}const Lf=l.memo(XS),nN=ou("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 _e({className:e,variant:t="default",asChild:s=!1,...o}){const r=s?Yb:"span";return n.jsx(r,{"data-slot":"badge","data-variant":t,className:P(nN({variant:t}),e),...o})}const sN=3;function oN({event:e}){const t=s=>{s.stopPropagation(),Ss({logId:e.logId,tab:"response",toolCallIndex:e.index})};return n.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:t,onKeyDown:s=>s.stopPropagation(),"aria-label":`Open response tool call ${e.name}`,title:e.name,children:n.jsx("span",{className:"min-w-0 truncate font-mono font-semibold",children:e.name})})}function rN({events:e}){if(e.length===0)return null;const t=e.slice(0,sN),s=Math.max(0,e.length-t.length);return n.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:[n.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:[n.jsx(no,{className:"size-3"}),"Call ",e.length]}),n.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-0.5 overflow-hidden",children:[t.map(o=>n.jsx(oN,{event:o},o.id)),s>0&&n.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 aN={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"},iN={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"}},Ps="border border-transparent bg-white/[0.045] hover:bg-white/[0.075] size-8 text-muted-foreground shadow-none hover:text-cyan-100",Ct="bg-white/[0.045] flex h-7 items-center gap-1 rounded-md px-2 text-xs";function Ls(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function lN(e){return e>=10?`${e.toFixed(0)}/s`:`${e.toFixed(1)}/s`}function cN(e,t){switch(e){case"success":return t===null?"OK":String(t);case"client_error":return t===null?"WARN":String(t);case"server_error":return t===null?"FAIL":String(t);case"pending":return"ROLL"}}function Hc({trend:e}){if(e===null)return null;const t=e.direction==="up",s=t?b0:m0,o=t?"+":"-";return n.jsxs("span",{className:"flex items-center gap-0.5 text-muted-foreground tabular-nums",children:[n.jsx(s,{className:t?"size-3 text-cyan-300":"size-3 text-rose-400"}),n.jsxs("span",{className:"font-mono",children:[o,Ie(e.delta)]})]})}const dN=l.memo(function({log:e,displayNumber:t,messageCount:s=null,toolCount:o=null,toolEvents:r=[],expanded:a,onToggle:i,cacheTrend:c=null,activeTab:d,tabActions:m,onReplay:u,slowResponseThresholdSeconds:p=0,showClientMetadata:f=!0,timeDisplayFormat:h}){const g=Kh(e.responseStatus),b=e.elapsedMs!==null&&p>0&&e.elapsedMs>p*1e3,y=e.inputTokens!==null||e.outputTokens!==null,w=e.firstChunkMs??null,v=e.tokensPerSecond??null,j=w===null?null:Ls(w),S=v===null||v<=0?null:lN(v),N=e.warnings?.length??0,C=e.clientPid!==null&&e.clientPid!==void 0,E=e.clientProjectFolder!==null&&e.clientProjectFolder!==void 0&&e.clientProjectFolder!=="";e.clientCwd!==null&&e.clientCwd!==void 0&&e.clientCwd;const A=iN[g],I=cN(g,e.responseStatus),R=g!=="success"||e.responseStatus!==200,k=e.streaming&&j===null&&S===null;return n.jsx(Ts,{children:n.jsxs("div",{id:`log-${e.id}`,role:"button",tabIndex:0,"data-nav-id":`log-${e.id}`,"data-nav-action":a?"collapse":"expand",className:P("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:M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),i())},children:[n.jsxs("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1",children:[n.jsx("span",{className:P("inline-flex h-8 shrink-0 items-center rounded-md px-2 font-mono",A.frame),children:n.jsxs("span",{className:"text-xs font-semibold tabular-nums",title:`Log ID ${String(e.id)}`,children:["#",t]})}),n.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:[n.jsx(en,{className:"size-3"}),n.jsx("span",{className:"font-mono tabular-nums",title:e.timestamp,children:si(e.timestamp,h)})]}),R&&n.jsxs(_e,{variant:"outline",className:P("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)]",aN[g]),children:[g==="success"?n.jsx(Fe,{className:"size-3","aria-label":"Success"}):g==="server_error"?n.jsx(n1,{className:"size-3","aria-label":"Server error"}):g==="client_error"?n.jsx(gn,{className:"size-3","aria-label":"Client error"}):n.jsx(Ue,{className:"size-3 animate-spin","aria-label":"Pending"}),I]}),N>0&&n.jsxs(dt,{children:[n.jsx(ut,{asChild:!0,children:n.jsxs(_e,{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:[n.jsx(gn,{className:"size-3","aria-label":"Tool schema warnings"}),N]})}),n.jsx(mt,{children:N===1?"1 tool schema warning":`${N} tool schema warnings`})]}),e.elapsedMs!==null&&(b?n.jsxs(dt,{children:[n.jsx(ut,{asChild:!0,children:n.jsxs("span",{className:P(Ct,"shrink-0 border-amber-300/25 text-amber-200"),children:[n.jsx(en,{className:"size-3"}),n.jsx("span",{className:"font-mono tabular-nums",children:Ls(e.elapsedMs)}),n.jsx(gn,{className:"size-3","aria-label":"Slow response"})]})}),n.jsxs(mt,{children:["Slow response: ",Ls(e.elapsedMs)," exceeds"," ",Ls(p*1e3)]})]}):n.jsxs("span",{className:P(Ct,"shrink-0 text-muted-foreground"),children:[n.jsx(en,{className:"size-3"}),n.jsx("span",{className:"font-mono tabular-nums",children:Ls(e.elapsedMs)})]})),e.streaming&&j!==null&&n.jsxs("span",{className:P(Ct,"shrink-0 text-cyan-300"),children:[n.jsx(nc,{className:"size-3"}),n.jsxs("span",{className:"font-mono tabular-nums",children:["first ",j]})]}),e.streaming&&S!==null&&n.jsxs("span",{className:P(Ct,"shrink-0 text-cyan-300"),children:[n.jsx(Zi,{className:"size-3"}),n.jsx("span",{className:"font-mono tabular-nums",children:S})]}),y&&n.jsxs("span",{className:P(Ct,"min-w-0 sm:shrink-0"),children:[n.jsx(Vs,{className:"size-3 text-muted-foreground"}),n.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-1 font-mono tabular-nums",children:[n.jsxs("span",{className:P("whitespace-nowrap",e.inputTokens!==null?"text-blue-400":"text-muted-foreground"),children:["IN ",e.inputTokens!==null?Ie(e.inputTokens):"n/a"]}),n.jsx("span",{className:"text-muted-foreground",children:"/"}),n.jsxs("span",{className:P("whitespace-nowrap",e.outputTokens!==null?"text-amber-400":"text-muted-foreground"),children:["OUT ",e.outputTokens!==null?Ie(e.outputTokens):"n/a"]})]})]}),e.cacheCreationInputTokens!==null&&e.cacheCreationInputTokens>0&&n.jsxs("span",{className:P(Ct,"shrink-0"),children:[n.jsx(Hc,{trend:c?.creation??null}),n.jsxs("span",{className:"font-mono tabular-nums text-cyan-300",children:["KV Cache +",Ie(e.cacheCreationInputTokens)]})]}),e.cacheReadInputTokens!==null&&e.cacheReadInputTokens>0&&n.jsxs("span",{className:P(Ct,"shrink-0"),children:[n.jsx(Hc,{trend:c?.read??null}),n.jsxs("span",{className:"font-mono tabular-nums text-purple-400",children:["KV Cache ~",Ie(e.cacheReadInputTokens)]})]}),s!==null&&n.jsxs("span",{className:P(Ct,"shrink-0 text-muted-foreground"),children:[n.jsx(kr,{className:"size-3"}),n.jsx("span",{className:"font-mono tabular-nums",children:s})]}),o!==null&&n.jsxs("span",{className:P(Ct,"shrink-0 text-muted-foreground"),children:[n.jsx(no,{className:"size-3"}),n.jsx("span",{className:"font-mono tabular-nums",children:o})]}),n.jsx(rN,{events:r}),e.origin!==null&&n.jsxs("span",{className:P(Ct,"hidden shrink-0 text-muted-foreground xl:flex"),title:`Origin: ${e.origin}`,children:[n.jsx(Au,{className:"size-3"}),n.jsx("span",{className:"font-mono tabular-nums truncate max-w-[120px]",title:e.origin,children:e.origin})]}),f&&(C||E)&&n.jsxs("span",{className:P(Ct,"hidden shrink-0 text-purple-300 xl:flex"),children:[n.jsx(jg,{className:"size-3"}),E?n.jsx("span",{className:"font-mono tabular-nums",children:e.clientProjectFolder}):n.jsxs("span",{className:"font-mono tabular-nums",children:["PID ",e.clientPid]})]}),k&&n.jsx(nc,{className:"size-3 shrink-0 text-muted-foreground/60"})]}),n.jsxs("span",{className:"flex shrink-0 items-start gap-1.5",children:[a&&n.jsxs("span",{className:"flex items-center gap-1.5 shrink-0",onClick:M=>M.stopPropagation(),onKeyDown:M=>M.stopPropagation(),children:[m!==void 0&&d!==void 0&&(()=>{const M=m[d];return M===void 0?null:n.jsxs(n.Fragment,{children:[M.expansion!==null&&n.jsxs(dt,{children:[n.jsx(ut,{asChild:!0,children:n.jsx(te,{variant:"outline",size:"icon",className:Ps,onClick:M.expansion.onToggle,disabled:M.expansion.isPending,"aria-pressed":M.expansion.isExpanded,"aria-label":M.expansion.isExpanded?"Collapse all JSON":"Expand all JSON",children:M.expansion.isExpanded?n.jsx(F0,{className:"size-3.5"}):n.jsx(P0,{className:"size-3.5"})})}),n.jsx(mt,{children:M.expansion.isExpanded?"Collapse all JSON nodes":"Expand all JSON nodes"})]}),M.diffWithRaw!==void 0&&n.jsxs(dt,{children:[n.jsx(ut,{asChild:!0,children:n.jsx(te,{variant:"outline",size:"icon",className:P(Ps,M.diffWithRaw.active&&"border-cyan-300/35 bg-cyan-400/15 text-cyan-100"),onClick:M.diffWithRaw.onToggle,"aria-pressed":M.diffWithRaw.active,"aria-label":M.diffWithRaw.active?"Hide raw diff":"Diff with raw",children:n.jsx(bg,{className:"size-3.5"})})}),n.jsx(mt,{children:M.diffWithRaw.active?"Hide diff with raw request":"Show diff between displayed and raw request body"})]}),M.diffWithPrevious!==void 0&&n.jsxs(dt,{children:[n.jsx(ut,{asChild:!0,children:n.jsx(te,{variant:"outline",size:"icon",className:Ps,onClick:M.diffWithPrevious,"aria-label":"Diff with previous",children:n.jsx(Iu,{className:"size-3.5"})})}),n.jsx(mt,{children:"Compare this request with the immediately preceding one"})]}),M.copyText!==null&&n.jsxs(dt,{children:[n.jsx(ut,{asChild:!0,children:n.jsx(te,{variant:"outline",size:"icon",className:Ps,onClick:M.onCopy,"aria-label":M.copyCopied?"Copied":M.copyLabel,children:M.copyCopied?n.jsx(Fe,{className:"size-3.5 text-cyan-300"}):n.jsx(It,{className:"size-3.5"})})}),n.jsx(mt,{children:M.copyCopied?"Copied to clipboard":M.copyLabel})]})]})})(),u!==void 0&&n.jsxs(dt,{children:[n.jsx(ut,{asChild:!0,children:n.jsx(te,{variant:"outline",size:"icon",className:Ps,onClick:u,"aria-label":"Replay request",children:n.jsx(Du,{className:"size-3.5"})})}),n.jsx(mt,{children:"Re-send this request to the provider"})]})]}),n.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?n.jsx(Xe,{className:"size-4 shrink-0"}):n.jsx(gt,{className:"size-4 shrink-0"})})]})]})})});function uN({...e}){return n.jsx(jv,{"data-slot":"collapsible",...e})}function tR({...e}){return n.jsx(Xu,{"data-slot":"collapsible-trigger",...e})}function mN({...e}){return n.jsx(Zu,{"data-slot":"collapsible-content",...e})}function pN({className:e,children:t,...s}){return n.jsxs(_w,{"data-slot":"scroll-area",className:P("relative overflow-hidden",e),...s,children:[n.jsx(Tw,{"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:t}),n.jsx(fN,{}),n.jsx(Ew,{})]})}function fN({className:e,orientation:t="vertical",...s}){return n.jsx(ip,{"data-slot":"scroll-area-scrollbar",orientation:t,className:P("flex touch-none p-px transition-colors select-none",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",e),...s,children:n.jsx(up,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}const Of={file:"file",shell:"shell",browser:"browser",web:"web",mcp:"MCP",code:"code",other:"other"},hN={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 xN({category:e}){switch(e){case"file":return n.jsx(Ng,{className:"size-3.5"});case"shell":return n.jsx(qn,{className:"size-3.5"});case"browser":return n.jsx(Zg,{className:"size-3.5"});case"web":return n.jsx(Au,{className:"size-3.5"});case"mcp":return n.jsx(S0,{className:"size-3.5"});case"code":return n.jsx(Eu,{className:"size-3.5"});case"other":return n.jsx(dg,{className:"size-3.5"})}}function gN({names:e}){return e.length===0?null:n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:[n.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:"required"}),e.slice(0,4).map(t=>n.jsx(_e,{variant:"outline",className:"h-5 max-w-36 truncate rounded-md px-1.5 py-0 font-mono text-[10px]",children:t},t)),e.length>4&&n.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:["+",e.length-4]})]})}function bN({tool:e,called:t}){const[s,o]=l.useState(!1),r=fn(e.name),a=e.description!==null||e.requiredParameters.length>0||e.schema!==null;return n.jsx(uN,{open:s,onOpenChange:o,children:n.jsxs("div",{className:"bg-white/[0.035] rounded-[8px]",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-2.5 py-2",children:[n.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:[n.jsx(xN,{category:e.category}),n.jsx("span",{className:"min-w-0 truncate font-mono text-xs font-semibold text-foreground/90",children:e.name}),t&&n.jsx(_e,{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"}),n.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:[e.parameterCount," params"]}),e.descriptionPreview!==null&&n.jsx("span",{className:"hidden min-w-0 truncate text-xs text-muted-foreground md:inline",children:e.descriptionPreview}),n.jsx("span",{className:"flex-1"}),a&&(s?n.jsx(Xe,{className:"size-3.5 shrink-0 text-muted-foreground"}):n.jsx(gt,{className:"size-3.5 shrink-0 text-muted-foreground"}))]}),n.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?n.jsx(Fe,{className:"size-3.5 text-emerald-400"}):n.jsx(It,{className:"size-3.5"})})]}),n.jsx(mN,{children:s&&n.jsxs("div",{className:"space-y-2 bg-white/[0.025] px-2.5 py-2",children:[e.description!==null&&n.jsx("p",{className:"text-xs leading-relaxed text-muted-foreground",children:e.description}),n.jsx(gN,{names:e.requiredParameters}),e.schema!==null&&n.jsx(pN,{className:"bg-black/[0.16] max-h-64 rounded-[8px] p-2",children:n.jsx(l.Suspense,{fallback:n.jsx("div",{className:"text-xs text-muted-foreground",children:"Loading JSON..."}),children:n.jsx(wi,{data:pr(e.schema),defaultExpandDepth:0})})})]})})]})})}function vN(e,t){return t.length===0?!0:`${e.name} ${e.description??""} ${Of[e.category]}`.toLowerCase().trim().includes(t)}const yN=l.memo(function({summary:t,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(()=>t===null?[]:t.tools.filter(f=>vN(f,d)),[d,t]);if(t===null)return null;const u=t.tools.slice(0,6),p=t.tools.length-u.length;return n.jsxs("section",{className:"bg-black/[0.10] mb-3 overflow-hidden rounded-[8px]",children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 px-3 py-2",children:[n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[n.jsx(no,{className:"size-4 shrink-0 text-sky-300/80"}),n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[n.jsx("span",{className:"text-sm font-semibold text-foreground",children:"Request Tools"}),n.jsx(_e,{variant:"outline",className:"h-5 rounded-md px-1.5 py-0 font-mono text-[10px]",children:t.tools.length}),t.toolChoiceLabel!==null&&n.jsxs(_e,{variant:"outline",className:"h-5 rounded-md px-1.5 py-0 font-mono text-[10px] text-muted-foreground",children:["tool_choice: ",t.toolChoiceLabel]})]}),n.jsx("div",{className:"mt-1 flex min-w-0 flex-wrap gap-1",children:t.categories.map(f=>n.jsxs(_e,{variant:"outline",className:P("h-5 rounded-md px-1.5 py-0 font-mono text-[10px]",hN[f.category]),children:[f.count," ",Of[f.category]]},f.category))})]})]}),n.jsxs(te,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-muted-foreground hover:text-cyan-100",onClick:()=>r(f=>!f),"aria-expanded":o,children:[o?n.jsx(Xe,{className:"size-3.5"}):n.jsx(gt,{className:"size-3.5"}),o?"Hide":"Show"]})]}),n.jsxs("div",{className:"flex min-w-0 flex-wrap gap-1.5 bg-white/[0.025] px-3 py-2",children:[u.map(f=>n.jsx(_e,{variant:"outline",className:P("h-5 max-w-44 truncate rounded-md px-1.5 py-0 font-mono text-[10px]",c.has(f.name)&&"border-emerald-400/20 text-emerald-300"),children:f.name},f.name)),p>0&&n.jsxs("span",{className:"font-mono text-[10px] leading-5 text-muted-foreground",children:["+",p]})]}),o&&n.jsxs("div",{className:"space-y-2 bg-black/10 px-3 py-3",children:[n.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:[n.jsx(S1,{className:"size-3.5 shrink-0 text-muted-foreground"}),n.jsx("input",{value:a,onChange:f=>i(f.target.value),placeholder:"Filter tools",className:"min-w-0 flex-1 bg-transparent font-mono text-xs outline-none placeholder:text-muted-foreground/70"})]}),n.jsx("div",{className:"grid gap-1.5",children:m.length>0?m.map(f=>n.jsx(bN,{tool:f,called:c.has(f.name)},f.name)):n.jsx("p",{className:"py-2 text-xs text-muted-foreground",children:"No matching tools"})})]})]})});function Vc(e,t,s){return e==="anthropic"&&t==="full"&&s}function wN(e,t){return e==="full"&&t}function ka(e,t){return e==="full"&&t}function _a(e,t){return e==="full"&&t}function jN(e,t){return e==="full"&&t===!0}function SN(e,t,s,o){return e==="anthropic"&&t==="full"&&s&&o}function ns(){return n.jsx("div",{className:"h-1","aria-hidden":"true"})}function NN(e,t){switch(e){case"anatomy":return t===null?"request":"anatomy";case"request":return"request";case"response":return"parsed"}}const CN=15e3,kN=15e3,_N=256*1024,hn=1024*1024,Wc=256*1024,Ta=512*1024,an="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 So(e=null){return{status:"idle",text:"",offset:0,totalBytes:e,hasMore:e!==null&&e>0,error:null}}function fr(e){return e??0}function cs(e,t){return t??e?.length??0}function Ol(e){return e.bodyContentMode==="compact"||e.bodyContentMode==="truncated"}function Df(e){return Ol(e)?fr(e.rawRequestBodyBytes)>hn||fr(e.responseTextBytes)>hn:!1}function TN(e){return Ol(e)&&!Df(e)}function EN(e,t){return Ol(e)?!1:t?cs(e.rawRequestBody,e.rawRequestBodyBytes)<=hn&&cs(e.responseText,e.responseTextBytes)<=hn:cs(e.rawRequestBody,e.rawRequestBodyBytes)<=Wc&&cs(e.responseText,e.responseTextBytes)<=Wc}function RN(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 MN(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 AN(e){return e instanceof Li?"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 No({status:e,error:t,footprint:s,onRetry:o}){switch(e){case"idle":return null;case"loading":return n.jsx(Bn,{tone:"loading",title:"Loading full bodies",children:n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(Ue,{className:"size-3.5 shrink-0 animate-spin text-cyan-200"}),n.jsx("span",{children:"Loading full request and response bodies from the log store."})]}),s!==null&&n.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 n.jsx(Bn,{tone:"warning",title:t?.title??"Full bodies could not be loaded",children:n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n.jsx("span",{children:t?.detail??"Compact metadata is still available."}),n.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:[n.jsx(Et,{className:"size-3"}),"Retry"]})]})})}}function Gc(e,t){return e?t.text!==""?t.text:t.status==="success"?"":null:null}function ln({children:e,className:t}){return n.jsx("div",{className:P("bg-black/[0.14] inspector-scrollbar mx-3 mb-3 max-h-[72vh] overflow-auto rounded-[8px] p-3",t),children:e})}function Wo({children:e}){return n.jsx("div",{className:"bg-white/[0.035] rounded-md px-3 py-5 text-center text-xs italic text-muted-foreground",children:e})}function Co({children:e}){const[t,s]=l.useState(!1),o=typeof e=="string"?e:null,r=o!==null&&o.length>Ta,a=o!==null&&r&&!t?o.slice(0,Ta):e;return l.useEffect(()=>{s(!1)},[o]),n.jsxs("div",{className:"space-y-2",children:[r&&!t&&n.jsxs("div",{className:"rounded-md border border-cyan-300/20 bg-cyan-300/[0.06] px-3 py-2 text-xs text-muted-foreground",children:["Showing the first ",Ta.toLocaleString()," characters for fast rendering. The full body is preserved and can still be copied from the tab action."]}),n.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:a}),r&&n.jsx("button",{type:"button",className:"rounded-md border border-border bg-background px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",onClick:()=>s(i=>!i),children:t?"Collapse fast preview":`Render full body (${o.length.toLocaleString()} chars)`})]})}const IN={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 Bn({tone:e,title:t,children:s}){return n.jsxs("div",{className:P("mb-3 rounded-md border px-3 py-2 text-xs shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]",IN[e]),children:[t!==void 0&&n.jsx("div",{className:"mb-1 font-semibold",children:t}),n.jsx("div",{className:"leading-relaxed text-muted-foreground",children:s})]})}function ko({label:e,state:t,expectedBytes:s,onLoadMore:o}){const r=t.totalBytes??s,a=r===null?ls(t.offset):`${ls(t.offset)} / ${ls(r)}`,i=t.status!=="loading"&&t.hasMore,c=t.status==="failed"?"Retry":"Load more";return n.jsx(Bn,{tone:t.status==="failed"?"warning":"loading",title:`${e} body preview`,children:n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n.jsxs("span",{children:[t.status==="idle"&&r!==null?`${e} body is ${ls(r)}. Loading the first preview chunk.`:`Loaded ${a}.`,t.status==="failed"&&t.error!==null&&` ${t.error}`]}),i&&n.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 Kc({error:e,onOpenSse:t}){return e==null?null:n.jsx(Bn,{tone:"danger",title:"SSE Error",children:n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n.jsx("span",{className:"font-mono",children:e}),t!==void 0&&n.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:t,children:"View SSE"})]})})}function PN({onOpenSse:e}){return n.jsx(Bn,{tone:"loading",title:"SSE chunks",children:n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n.jsx("span",{children:"Streaming chunks are available in the SSE tab."}),n.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 Yc({headers:e,emptyLabel:t}){const s=e===void 0?[]:Object.entries(e).sort(([o],[r])=>o.localeCompare(r));return s.length===0?n.jsx(Wo,{children:t}):n.jsx("div",{className:"bg-black/[0.14] overflow-hidden rounded-[8px] font-mono text-xs",children:s.map(([o,r])=>n.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:[n.jsx("div",{className:"min-w-0 truncate bg-white/[0.035] px-2.5 py-2 font-semibold text-cyan-200",children:o}),n.jsx("div",{className:"min-w-0 truncate px-2.5 py-2 text-muted-foreground",title:r,children:r})]},o))})}function LN({active:e,onClick:t}){return n.jsxs(dt,{children:[n.jsx(ut,{asChild:!0,children:n.jsxs(te,{variant:e?"default":"outline",size:"sm",className:P("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:t,"aria-pressed":e,children:[n.jsx(Ag,{className:"size-3.5 mr-1"}),e?"Showing diff":"Diff with Raw"]})}),n.jsx(mt,{children:e?"Hide diff view":"Compare proxy output against the original raw version"})]})}const ON=l.memo(function({rawBody:e,displayedBody:t,emptyLabel:s}){const o=l.useMemo(()=>GS(e,t),[e,t]);return n.jsx(Lf,{result:o,emptyLabel:s})}),DN=l.memo(function({rawHeaders:e,headers:t,emptyLabel:s}){const o=l.useMemo(()=>WS(e,t),[e,t]);return n.jsx(Lf,{result:o,emptyLabel:s})}),zN=l.memo(function({log:e,displayNumber:t,viewMode:s="simple",strip:o,slowResponseThresholdSeconds:r,timeDisplayFormat:a,cacheTrend:i=null,onCompareWithPrevious:c,showClientMetadata:d=!0,toolEvents:m=[]}){const[u,p]=l.useState(!1),[f,h]=l.useState(!1),[g,b]=l.useState(!1),[y,w]=l.useState(!1),[v,j]=l.useState("request"),[S,N]=l.useState(null),[C,E]=l.useState(0),[A,I]=l.useState(null),[R,k]=l.useState(null),[M,O]=l.useState("idle"),[$,K]=l.useState(null),[Q,z]=l.useState(0),[H,ee]=l.useState(()=>So(e.rawRequestBodyBytes??null)),[U,Z]=l.useState(()=>So(e.responseTextBytes??null)),fe=l.useRef(null),je=l.useRef(e.id),he=l.useRef(!1),oe=l.useRef(!1),L=R??e,J=R===null&&Df(e),Se=l.useMemo(()=>LS(e.rawRequestBodyBytes,e.responseTextBytes),[e.rawRequestBodyBytes,e.responseTextBytes]),Te=Gc(J,H),ge=Gc(J,U),le=L.rawRequestBody??Te,ce=L.responseText??ge,Pe=L.rawRequestBody===null&&Te!==null,Re=L.responseText===null&&ge!==null,$e=cs(le,e.rawRequestBodyBytes)<=hn,lt=cs(ce,e.responseTextBytes)<=hn,He=$e&&(!Pe||H.hasMore===!1&&fr(H.totalBytes)<=hn),Le=lt&&(!Re||U.hasMore===!1&&fr(U.totalBytes)<=hn),We=mr(L),Ke=vf(We),Ze=EN(L,u),rt=l.useMemo(()=>Ke.analyzeRequest(Ze?L.rawRequestBody:null),[Ke,Ze,L.rawRequestBody]),nt=l.useMemo(()=>Ke.analyzeResponse(Ze?L.responseText:null),[Ke,Ze,L.responseText]),se=l.useMemo(()=>!o||We!=="anthropic"||L.rawRequestBody===null?null:gS(L.rawRequestBody).body,[L.rawRequestBody,We,o])??le,xe=Na(u&&MN(v)&&He?se:null),pe=Na(v==="raw-request"&&He?le:null),we=Na(v==="raw"&&Le?ce:null),Oe=jN(s,L.streaming),ze=xe.parsedData??rt.parsed,D=l.useMemo(()=>{const Me=nt.toolNames;return Me!==null?Me:m.map(vt=>vt.name)},[nt.toolNames,m]),Y=l.useMemo(()=>L.headers&&Object.keys(L.headers).length>0?JSON.stringify(L.headers,null,2):null,[L.headers]),de=l.useMemo(()=>L.rawHeaders&&Object.keys(L.rawHeaders).length>0?JSON.stringify(L.rawHeaders,null,2):null,[L.rawHeaders]),Ne=fn(se),F=fn(le),W=fn(Y),X=fn(de),ne=fn(ce),Ee=l.useMemo(()=>({request:{copyLabel:Pe?"Copy loaded request preview":"Copy request body",copyText:se,copyCopied:Ne.copied,onCopy:Ne.copy,expansion:He?{isExpanded:xe.isExpanded,isPending:xe.isPending,onToggle:xe.toggle}:null,diffWithRaw:SN(We,s,o,L.rawRequestBody!==null)?{active:y,onToggle:()=>w(!y)}:void 0,diffWithPrevious:c===void 0?void 0:()=>{c(L)}},"raw-request":{copyLabel:Pe?"Copy loaded raw request preview":"Copy raw request",copyText:le,copyCopied:F.copied,onCopy:F.copy,expansion:He?{isExpanded:pe.isExpanded,isPending:pe.isPending,onToggle:pe.toggle}:null},..._a(s,L.headers!==void 0&&Object.keys(L.headers).length>0)?{headers:{copyLabel:"Copy headers",copyText:Y,copyCopied:W.copied,onCopy:W.copy,expansion:null}}:{},...ka(s,L.rawHeaders!==void 0&&Object.keys(L.rawHeaders).length>0)?{"raw-headers":{copyLabel:"Copy raw headers",copyText:de,copyCopied:X.copied,onCopy:X.copy,expansion:null}}:{},raw:{copyLabel:Re?"Copy loaded response preview":"Copy response",copyText:ce,copyCopied:ne.copied,onCopy:ne.copy,expansion:Le?{isExpanded:we.isExpanded,isPending:we.isPending,onToggle:we.toggle}:null}}),[se,Pe,He,Ne,xe,y,L,L.rawRequestBody,le,F,pe,Y,W,de,X,L.responseText,Re,Le,ce,ne,we,We,s,o,c]),ie=l.useMemo(()=>ze!==null?Ke.anatomySegments(ze):null,[Ke,ze]),re=l.useMemo(()=>Il(ze),[ze]),ke=L.warnings??[],De=l.useMemo(()=>{if(ie!==null)return new Set(ie.map(Me=>Me.path))},[ie]),Wn=IS({containerRef:fe,setExpandToPath:I,ensureTabActive:()=>{v!=="request"&&(oe.current=!0,j("request"))}}),Lt=l.useCallback((Me,vt)=>{const Qe=Me==="request"?ee:Z;Qe(st=>({...st,status:"loading",error:null}));const Es=new URLSearchParams({part:Me,offset:String(vt),limit:String(_N)});Be(`/api/logs/${String(e.id)}/body?${Es.toString()}`,lu,kN).then(st=>{je.current===e.id&&Qe(St=>({status:"success",text:st.offset===0?st.text:`${St.text}${st.text}`,offset:st.nextOffset??st.totalBytes,totalBytes:st.totalBytes,hasMore:st.hasMore,error:null}))}).catch(st=>{je.current===e.id&&Qe(St=>({...St,status:"failed",error:AN(st)}))})},[e.id]),rn=l.useCallback(()=>{he.current||($S(e.id),k(null),O("idle"),K(null),z(Me=>Me+1))},[e.id]),Qr=l.useCallback(()=>{const Me=!u;Me&&(oe.current=!1,j(ie!==null?"anatomy":"request")),p(Me)},[ie,u]),Gn=l.useCallback(()=>{Oe&&(oe.current=!0,j("sse"))},[Oe]),ea=l.useCallback(Me=>{oe.current=!0,j(Me)},[]);return l.useEffect(()=>{je.current=e.id,he.current=!1,k(null),O("idle"),K(null),z(0),oe.current=!1,ee(So(e.rawRequestBodyBytes??null)),Z(So(e.responseTextBytes??null))},[e.id,e.rawRequestBodyBytes,e.responseTextBytes]),l.useEffect(()=>{u&&(oe.current||v==="request"&&ie!==null&&j("anatomy"))},[v,ie,u]),l.useEffect(()=>{v!=="sse"||Oe||j("parsed")},[v,Oe]),l.useEffect(()=>{if(!u||!RN(v)||!TN(e)||R!==null||he.current)return;const Me=Mf(e.id);if(Me!==null){k(Me),O("idle"),K(null);return}let vt=!1;return he.current=!0,O("loading"),K(null),FS(e.id,()=>Be(`/api/logs/${String(e.id)}`,Hs,CN)).then(Qe=>{vt||(he.current=!1,k(Qe),O("idle"),K(null))}).catch(Qe=>{vt||(he.current=!1,O("failed"),K(OS(Qe)))}),()=>{vt=!0,he.current=!1}},[v,u,R,e.bodyContentMode,e.id,e.rawRequestBodyBytes,e.responseTextBytes,Q]),l.useEffect(()=>{u&&J&&H.status==="idle"&&(v!=="request"&&v!=="raw-request"&&v!=="anatomy"||Lt("request",0))},[v,u,Lt,H.status,J]),l.useEffect(()=>{u&&J&&U.status==="idle"&&(v!=="parsed"&&v!=="raw"||Lt("response",0))},[v,u,Lt,U.status,J]),l.useEffect(()=>{const Me=vt=>{const Qe=Jr(vt);Qe!==null&&Qe.logId===e.id&&(p(!0),oe.current=!0,j(NN(Qe.tab,ie)),Qe.tab==="response"&&Qe.toolCallIndex!==void 0&&(N(Qe.toolCallIndex),E(Es=>Es+1)))};return window.addEventListener(sn,Me),()=>{window.removeEventListener(sn,Me)}},[ie,e.id]),n.jsxs(Ts,{children:[n.jsxs("div",{className:P("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:[n.jsx(dN,{log:L,displayNumber:t,messageCount:rt.messageCount,toolCount:rt.toolCount,toolEvents:m,expanded:u,onToggle:Qr,cacheTrend:i,slowResponseThresholdSeconds:r,showClientMetadata:d,timeDisplayFormat:a,activeTab:v,tabActions:Ee,onReplay:c===void 0?void 0:()=>{h(!0)}}),u&&n.jsxs("div",{className:"relative bg-black/[0.14] pt-2",onClick:Me=>Me.stopPropagation(),onKeyDown:Me=>Me.stopPropagation(),children:[n.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"}),n.jsx(Jo,{feature:"Log details",children:n.jsxs(Ef,{value:v,onValueChange:ea,className:"gap-2",children:[n.jsxs(Rf,{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:[ka(s,L.rawHeaders!==void 0&&Object.keys(L.rawHeaders).length>0)&&n.jsx(Zt,{className:an,value:"raw-headers",children:"Raw Headers"}),_a(s,L.headers!==void 0&&Object.keys(L.headers).length>0)&&n.jsx(Zt,{className:an,value:"headers",children:"Headers"}),ie!==null&&n.jsx(Zt,{className:an,value:"anatomy",children:"Context"}),Vc(We,s,o)&&n.jsx(Zt,{className:an,value:"raw-request",children:"Raw Request"}),n.jsx(Zt,{className:an,value:"request",children:"Request"}),s==="full"&&n.jsx(Zt,{className:an,value:"raw",children:"Raw Response"}),n.jsx(Zt,{className:an,value:"parsed",children:"Response"}),Oe&&n.jsx(Zt,{className:an,value:"sse",children:"SSE"})]}),Vc(We,s,o)&&n.jsx(ct,{value:"raw-request",children:v==="raw-request"&&n.jsxs(ln,{children:[n.jsx(No,{status:M,error:$,footprint:Se,onRetry:rn}),J&&n.jsx(ko,{label:"Request",state:H,expectedBytes:e.rawRequestBodyBytes??null,onLoadMore:()=>Lt("request",H.offset)}),le===null?n.jsx(Wo,{children:J?"Request preview is loading":"No request body"}):pe.parsedData!==null?n.jsx(l.Suspense,{fallback:n.jsx(ns,{}),children:n.jsx(wi,{data:pe.parsedData,bulkDepth:pe.bulkDepth,bulkRevision:pe.bulkRevision})}):n.jsx(Co,{children:le})]})}),n.jsx(ct,{value:"request",children:v==="request"&&n.jsxs(ln,{children:[n.jsx(No,{status:M,error:$,footprint:Se,onRetry:rn}),J&&n.jsx(ko,{label:"Request",state:H,expectedBytes:e.rawRequestBodyBytes??null,onLoadMore:()=>Lt("request",H.offset)}),ke.length>0&&n.jsxs(Bn,{tone:"warning",children:[n.jsxs("div",{className:"flex items-center gap-2 font-semibold text-amber-300",children:[n.jsx(gn,{className:"size-3.5"}),"Tool schema warnings"]}),n.jsx("ul",{className:"mt-2 space-y-1 text-muted-foreground",children:ke.map(Me=>n.jsx("li",{children:Me},Me))})]}),n.jsx(yN,{summary:re,calledToolNames:D}),y?n.jsx(ON,{rawBody:L.rawRequestBody,displayedBody:se,emptyLabel:"No transformation applied; raw and sent request bodies are identical."}):n.jsx("div",{ref:fe,children:se===null?n.jsx(Wo,{children:J?"Request preview is loading":"No request body"}):xe.parsedData!==null?n.jsx(l.Suspense,{fallback:n.jsx(ns,{}),children:n.jsx(wi,{data:xe.parsedData,bulkDepth:xe.bulkDepth,bulkRevision:xe.bulkRevision,anatomyPaths:De,expandToPath:A})}):n.jsx(Co,{children:se})})]})}),ie!==null&&n.jsx(ct,{value:"anatomy",children:v==="anatomy"&&n.jsx(ln,{className:"p-0",children:n.jsx(l.Suspense,{fallback:n.jsx(ns,{}),children:n.jsx(_S,{parsed:xe.parsedData,inputTokens:L.inputTokens??null,model:L.model,segments:ie,onSegmentActivate:Wn})})})}),_a(s,L.headers!==void 0&&Object.keys(L.headers).length>0)&&n.jsx(ct,{value:"headers",children:v==="headers"&&n.jsxs(ln,{children:[n.jsx("div",{className:"flex justify-end gap-2 mb-2",children:wN(s,L.rawHeaders!==void 0&&Object.keys(L.rawHeaders).length>0)&&n.jsx(LN,{active:g,onClick:Me=>{Me.stopPropagation(),b(!g)}})}),g?n.jsx(DN,{rawHeaders:L.rawHeaders,headers:L.headers,emptyLabel:"No transformation applied; raw and processed headers are identical."}):n.jsx(Yc,{headers:L.headers,emptyLabel:"No headers captured"})]})}),ka(s,L.rawHeaders!==void 0&&Object.keys(L.rawHeaders).length>0)&&n.jsx(ct,{value:"raw-headers",children:v==="raw-headers"&&n.jsx(ln,{children:n.jsx(Yc,{headers:L.rawHeaders,emptyLabel:"No raw headers captured"})})}),n.jsx(ct,{value:"raw",children:v==="raw"&&n.jsxs(ln,{className:"space-y-3",children:[n.jsx(No,{status:M,error:$,footprint:Se,onRetry:rn}),J&&n.jsx(ko,{label:"Response",state:U,expectedBytes:e.responseTextBytes??null,onLoadMore:()=>Lt("response",U.offset)}),n.jsx(Kc,{error:L.error,onOpenSse:Oe?Gn:void 0}),ce!==null&&Le?n.jsx(l.Suspense,{fallback:n.jsx(ns,{}),children:n.jsx(RS,{text:ce,defaultExpandDepth:0,bulkDepth:we.bulkDepth,bulkRevision:we.bulkRevision})}):ce!==null?n.jsx(Co,{children:ce}):n.jsx(Wo,{children:J?"Response preview is loading":"No response"}),Oe&&n.jsx(PN,{onOpenSse:Gn})]})}),Oe&&n.jsx(ct,{value:"sse",children:v==="sse"&&n.jsxs(ln,{className:"space-y-3",children:[L.error!==void 0&&L.error!==null&&n.jsx(Bn,{tone:"danger",title:"SSE Error",children:n.jsx("span",{className:"font-mono",children:L.error})}),n.jsx(l.Suspense,{fallback:n.jsx(ns,{}),children:n.jsx(ES,{logId:L.id,truncated:L.streamingChunksPath!==null})})]})}),n.jsx(ct,{value:"parsed",children:v==="parsed"&&n.jsxs(ln,{children:[n.jsx(No,{status:M,error:$,footprint:Se,onRetry:rn}),J&&n.jsx(ko,{label:"Response",state:U,expectedBytes:e.responseTextBytes??null,onLoadMore:()=>Lt("response",U.offset)}),n.jsx(Kc,{error:L.error,onOpenSse:Oe?Gn:void 0}),Re&&!Le?n.jsx(Co,{children:ce}):n.jsx(l.Suspense,{fallback:n.jsx(ns,{}),children:n.jsx(TS,{responseText:ce,responseStatus:L.responseStatus,streaming:L.streaming,inputTokens:L.inputTokens,outputTokens:L.outputTokens,cacheCreationInputTokens:L.cacheCreationInputTokens,cacheReadInputTokens:L.cacheReadInputTokens,apiFormat:We,focusedToolIndex:S,toolFocusNonce:C})})]})})]})})]})]}),n.jsx(Jo,{feature:"Replay",children:n.jsx(l.Suspense,{fallback:null,children:n.jsx(kS,{log:L,displayNumber:t,open:f,onOpenChange:h})})})]})});function $N(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 Ea(e){return e?"cursor-pointer transition-transform hover:scale-110":""}function FN({stopReason:e,isPending:t,isFirst:s,isTurnStart:o,isOnlyEntry:r=!1,isOpenTurnTail:a=!1,crabIndex:i=0,collapsible:c=!1,onToggle:d}){const m=Pl(e),u=r&&o&&m,p=t&&!m,f=c&&d!==void 0,h=l.useMemo(()=>Ll(i),[i]),g=l.useMemo(()=>mS(i),[i]),b=w=>{!f||d===void 0||(w.stopPropagation(),d())},y=w=>{!f||d===void 0||w.key!=="Enter"&&w.key!==" "||(w.preventDefault(),d())};return n.jsxs("div",{className:"flex flex-col items-center w-6 shrink-0 pt-0.5 pb-0.5",children:[n.jsx("div",{className:"flex justify-center h-[calc(0.75rem-8px)]",children:!s&&n.jsx("div",{className:"w-px bg-muted-foreground/18 h-full"})}),u?n.jsx("span",{role:f?"button":void 0,tabIndex:f?0:void 0,title:"Single-request turn",className:Ea(f),onClick:b,onKeyDown:y,children:n.jsx(g,{className:P("size-3.5 text-[#80FF00]","animate-crab-settle","drop-shadow-[0_0_4px_rgba(128,255,0,0.5)]")})}):m?n.jsx("span",{role:f?"button":void 0,tabIndex:f?0:void 0,title:$N(e),className:Ea(f),onClick:b,onKeyDown:y,children:n.jsx(h,{className:P("size-3.5 text-amber-400","animate-crab-settle","drop-shadow-[0_0_4px_rgba(251,191,36,0.5)]")})}):o?n.jsx("span",{role:f?"button":void 0,tabIndex:f?0:void 0,title:"Start of turn",className:Ea(f),onClick:b,onKeyDown:y,children:n.jsx(h,{className:P("size-3.5 text-emerald-400","animate-crab-appear","drop-shadow-[0_0_4px_rgba(52,211,153,0.5)]")})}):a?n.jsx("span",{title:t?"Current end of open turn (processing)":"Current end of open turn",children:n.jsx(h,{className:P("size-3.5 text-cyan-300/85",p?"animate-crab-crawl":"animate-crab-appear","drop-shadow-[0_0_4px_rgba(103,232,249,0.4)]")})}):p?n.jsx("span",{title:"Processing",children:n.jsx(h,{className:P("size-3.5 text-amber-300/80","animate-crab-crawl")})}):n.jsx("span",{title:"Request in turn",children:n.jsx(h,{className:"size-3.5 text-muted-foreground/40"})}),n.jsx("div",{className:"flex-1 flex justify-center min-h-0",children:!m&&!a&&n.jsx("div",{className:P("w-0.5 h-full",t?"border-dashed bg-transparent border-l border-muted-foreground/14":"bg-muted-foreground/18")})})]})}const Jc=180;function BN(e){const t=pf(e.path);return t==="unknown"?e.apiFormat:t}function UN(e,t){const s=e.responseText;if(s===null)return!1;switch(t){case"anthropic":return s.includes("tool_use");case"openai":return s.includes("tool_calls")||s.includes("function_call");case"unknown":return!1}}function zf(e){if(e===null)return null;try{const t=JSON.parse(e);return typeof t=="string"?JSON.parse(t):t}catch{return null}}function qN(e){if(e==null)return null;const t=typeof e=="string"?e:JSON.stringify(e);if(t===void 0)return null;const s=t.replace(/\s+/g," ").trim();return s.length===0?null:s.length>Jc?`${s.slice(0,Jc-1)}...`:s}function HN(e){if(e==null)return null;if(typeof e=="string")return e.length>0?e:null;const t=JSON.stringify(e,null,2);return t===void 0||t.length===0?null:t}function vn({log:e,provider:t,index:s,name:o,input:r}){return{id:`${String(e.id)}-${t}-tool-${String(s)}`,logId:e.id,index:s,provider:t,name:o,argumentsText:HN(r),argumentsPreview:qN(r)}}function VN(e){const t=zf(e.responseText),s=G(t,"content");if(!Array.isArray(s))return[];const o=[];for(const r of s){if(G(r,"type")!=="tool_use")continue;const i=G(r,"name");if(typeof i!="string"||i.length===0)continue;const c=G(r,"input");o.push(vn({log:e,provider:"anthropic",index:o.length,name:i,input:c}))}return o}function WN(e){const t=zf(e.responseText),s=G(t,"choices"),o=[];if(Array.isArray(s))for(const a of s){const i=G(a,"message"),c=G(i,"tool_calls");if(Array.isArray(c))for(const u of c){const p=G(u,"function"),f=G(p,"name");if(typeof f!="string"||f.length===0)continue;const h=G(p,"arguments");o.push(vn({log:e,provider:"openai",index:o.length,name:f,input:h}))}const d=G(i,"function_call"),m=G(d,"name");if(typeof m=="string"&&m.length>0){const u=G(d,"arguments");o.push(vn({log:e,provider:"openai",index:o.length,name:m,input:u}))}}const r=G(t,"output");if(Array.isArray(r))for(const a of r){if(G(a,"type")!=="function_call")continue;const i=G(a,"name");if(typeof i!="string"||i.length===0)continue;const c=G(a,"arguments");o.push(vn({log:e,provider:"openai",index:o.length,name:i,input:c}))}return o}function $f(e){if(typeof e.data=="string")try{return JSON.parse(e.data)}catch{return e.data}return e.data}function Go(e,t,s){const o=`${s.provider}:${s.name}:${s.index}`;t.has(o)||(t.add(o),e.push(s))}function GN(e){const t=e.streamingChunks?.chunks??[],s=[],o=new Set;for(const r of t){const a=$f(r),i=G(a,"content_block");if(G(i,"type")!=="tool_use")continue;const c=G(i,"name");if(typeof c!="string"||c.length===0)continue;const d=G(i,"input");Go(s,o,vn({log:e,provider:"anthropic",index:r.index,name:c,input:d}))}return s.map((r,a)=>({...r,id:`${String(e.id)}-anthropic-tool-${String(a)}`,index:a}))}function KN(e){const t=e.streamingChunks?.chunks??[],s=[],o=new Set;for(const r of t){const a=$f(r),i=G(a,"choices");if(Array.isArray(i))for(const d of i){const m=G(d,"delta"),u=G(m,"tool_calls");if(Array.isArray(u))for(const h of u){const g=G(h,"function"),b=G(g,"name");if(typeof b!="string"||b.length===0)continue;const y=G(g,"arguments");Go(s,o,vn({log:e,provider:"openai",index:s.length,name:b,input:y}))}const p=G(m,"function_call"),f=G(p,"name");if(typeof f=="string"&&f.length>0){const h=G(p,"arguments");Go(s,o,vn({log:e,provider:"openai",index:s.length,name:f,input:h}))}}const c=G(a,"item");if(G(c,"type")==="function_call"){const d=G(c,"name");if(typeof d=="string"&&d.length>0){const m=G(c,"arguments");Go(s,o,vn({log:e,provider:"openai",index:s.length,name:d,input:m}))}}}return s.map((r,a)=>({...r,id:`${String(e.id)}-openai-tool-${String(a)}`,index:a}))}function YN(e){if(e.toolTraceEvents!==void 0&&e.toolTraceEvents.length>0)return e.toolTraceEvents;const t=BN(e);if(UN(e,t))switch(t){case"anthropic":return VN(e);case"openai":return WN(e);case"unknown":return[]}switch(t){case"anthropic":return GN(e);case"openai":return KN(e);case"unknown":return[]}}const Xc=new WeakMap;function JN(e){return e>1}function Ni(e){const t=[];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:kf(a),sessionLogNumber:r+1});const i=s[s.length-1];i!==void 0&&Pl(i.stopReason)&&(t.push({entries:s,turnIndex:o}),s=[],o+=1)}return s.length>0&&t.push({entries:s,turnIndex:o}),t}function XN(e){const t=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=mr(r),c=mr(a);i==="unknown"||i!==c||t.set(r.id,a)}return t}function Dl(e){const t=Xc.get(e);if(t!==void 0&&t.apiFormat===e.apiFormat&&t.responseText===e.responseText&&t.toolTraceEvents===e.toolTraceEvents)return t.events;const s=YN(e);return Xc.set(e,{apiFormat:e.apiFormat,responseText:e.responseText,toolTraceEvents:e.toolTraceEvents,events:s}),s}function ZN(e,t,s=0){let o=0,r=0,a=0,i=0,c=0,d=0,m=0,u=0,p=null,f=0;for(const h of e)h.responseStatus===null?r+=1:h.responseStatus>=400&&(o+=1),h.elapsedMs!==null&&t>0&&h.elapsedMs>t*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,p=p===null?h.elapsedMs:Math.max(p,h.elapsedMs)),f+=Dl(h).length;return{llmCallCount:e.length,toolCallCount:f,failedCallCount:o,pendingCallCount:r,slowCallCount:a,totalInputTokens:i,totalOutputTokens:c,totalCacheCreationInputTokens:d,totalCacheReadInputTokens:m,totalElapsedMs:u,maxElapsedMs:p,startedAt:e[0]?.timestamp??null,endedAt:e[e.length-1]?.timestamp??null,knowledgeCandidateCount:s}}function Ra(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}const QN=l.memo(function({entries:t,viewMode:s,strip:o,slowResponseThresholdSeconds:r,cacheTrends:a,onCompareWithPrevious:i,comparisonPredecessors:c,turnIndex:d=0,timeDisplayFormat:m,pendingFocusRequest:u,showLogClientMetadata:p=!0}){const f=t.length-1,h=t[f]?.stopReason??null,g=h!==null?Pl(h):!1,b=t[f]?.log.responseStatus===null,y=t.length===1,w=JN(t.length),[v,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 z=H=>{const ee=Jr(H);ee!==null&&t.some(U=>U.log.id===ee.logId)&&w&&j(!1)};return window.addEventListener(sn,z),()=>{window.removeEventListener(sn,z)}},[w,t]),l.useEffect(()=>{if(u===void 0||!t.some(H=>H.log.id===u.logId))return;w&&j(!1);const z=window.setTimeout(()=>{Ss({logId:u.logId,tab:u.tab,source:"virtualizer"})},0);return()=>window.clearTimeout(z)},[w,t,u]);const N=l.useCallback(()=>{w&&j(z=>!z)},[w]),C=l.useMemo(()=>{let z=0,H=0,ee=null,U=!1;for(const Z of t)Z.log.inputTokens!==null&&(z+=Z.log.inputTokens,U=!0),Z.log.outputTokens!==null&&(H+=Z.log.outputTokens,U=!0),Z.log.elapsedMs!==null&&(ee=ee===null?Z.log.elapsedMs:Math.max(ee,Z.log.elapsedMs));return{totalInput:z,totalOutput:H,hasTokens:U,maxElapsed:ee}},[t,f]),E=d%2===0?"bg-white/[0.008]":"bg-cyan-300/[0.008]",A=C.maxElapsed!==null&&r>0&&C.maxElapsed>r*1e3,I=l.useMemo(()=>{const z=new Map;for(const H of t){const ee=Dl(H.log);ee.length>0&&z.set(H.log.id,ee)}return z},[t]),[R,k]=l.useState(0),M=l.useRef(null);l.useEffect(()=>{const z=M.current;if(!z)return;let H=0;const ee=new ResizeObserver(()=>{window.cancelAnimationFrame(H),H=window.requestAnimationFrame(()=>k(U=>U+1))});return ee.observe(z),()=>{ee.disconnect(),window.cancelAnimationFrame(H)}},[]);const O=t[0]?.log.id??d,$=`Turn ${String(d+1)}`,K=l.useMemo(()=>Ll(O%12),[O]),Q=l.useMemo(()=>({contentVisibility:"auto",containIntrinsicSize:v?"48px":"160px"}),[v]);return n.jsx("div",{ref:M,style:Q,tabIndex:v?void 0:0,role:v?void 0:"group","aria-label":v?void 0:$,"data-nav-id":v?void 0:`turn-${String(O)}`,className:P("rounded-[8px] transition-[background-color,box-shadow]",b?"bg-amber-300/[0.018] shadow-[0_0_0_1px_rgba(252,211,77,0.035)]":"",!v&&"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-none"),children:v?n.jsxs("div",{"data-nav-id":`turn-collapsed-${String(O)}`,"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:z=>{(z.key==="Enter"||z.key===" ")&&(z.preventDefault(),N())},children:[n.jsxs("div",{className:"w-6 shrink-0 flex flex-col items-center pt-1.5 pb-1.5",children:[n.jsx("div",{className:"flex justify-center h-[calc(0.75rem-8px)]"}),n.jsx(K,{className:P("size-3.5",b?"animate-crab-crawl text-amber-300/80":"animate-crab-appear text-emerald-400",b?"drop-shadow-[0_0_4px_rgba(252,211,77,0.42)]":"drop-shadow-[0_0_4px_rgba(52,211,153,0.45)]")}),n.jsx("div",{className:"flex-1 flex justify-center min-h-0",children:n.jsx("div",{className:"w-px bg-muted-foreground/14 h-full"})}),g?n.jsx(K,{className:P("size-3.5 animate-crab-settle text-amber-400","drop-shadow-[0_0_4px_rgba(251,191,36,0.45)]")}):n.jsx("span",{title:"Current end of open turn","aria-label":"Current end of open turn",children:n.jsx(K,{className:P("size-3.5 text-cyan-300/85",b?"animate-crab-crawl":"animate-crab-appear","drop-shadow-[0_0_4px_rgba(103,232,249,0.4)]")})})]}),t.length>1&&n.jsxs("div",{className:P("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",E),children:[n.jsx("span",{className:"font-mono text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground/70",children:$}),n.jsxs("span",{className:"text-blue-300/85 font-mono font-semibold tabular-nums shrink-0",title:`Log IDs ${String(t[0]?.log.id??"?")} ~ ${String(t[f]?.log.id??"?")}`,children:["#",t[0]?.sessionLogNumber??"?"," ~ #",t[f]?.sessionLogNumber??"?"]}),n.jsxs("span",{className:"text-muted-foreground shrink-0",children:[t.length," request",t.length>1?"s":""]}),C.maxElapsed!==null&&n.jsx(Ts,{children:n.jsxs(dt,{children:[n.jsx(ut,{asChild:!0,children:n.jsxs("span",{className:P("flex items-center gap-1 shrink-0",A?"text-amber-400":"text-muted-foreground"),children:[n.jsx(en,{className:"size-3"}),n.jsx("span",{className:"font-mono tabular-nums",children:Ra(C.maxElapsed)}),A&&n.jsx(gn,{className:"size-3","aria-label":"Slow response"})]})}),n.jsx(mt,{children:A?`Slow response: ${Ra(C.maxElapsed)} exceeds ${Ra(r*1e3)}`:"Slowest request in this turn"})]})}),C.hasTokens&&n.jsxs("span",{className:"flex items-center gap-1 shrink-0",children:[n.jsx(Vs,{className:"size-3 text-muted-foreground"}),n.jsxs("span",{className:"font-mono tabular-nums",children:[n.jsxs("span",{className:"text-blue-400",children:["IN ",Ie(C.totalInput)]})," / ",n.jsxs("span",{className:"text-amber-400",children:["OUT ",Ie(C.totalOutput)]})]})]}),n.jsx("span",{className:"flex-1 min-w-0"}),n.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:n.jsx(gt,{className:"size-4 shrink-0"})})]})]}):t.map((z,H)=>{const{log:ee,stopReason:U}=z,Z=H===0;return n.jsxs("div",{className:"flex items-stretch",children:[n.jsx(FN,{stopReason:U,isPending:ee.responseStatus===null,isFirst:H===0,isTurnStart:Z,isOnlyEntry:y,isOpenTurnTail:H===f&&!g,crabIndex:ee.id%12,collapsible:w&&Z,onToggle:N}),n.jsx("div",{className:P("flex-1 min-w-0 mb-0.5 rounded-[8px]",E),children:n.jsx(zN,{log:ee,displayNumber:z.sessionLogNumber,viewMode:s,strip:o,slowResponseThresholdSeconds:r,timeDisplayFormat:m,cacheTrend:a?.get(ee.id)??null,showClientMetadata:p,toolEvents:I.get(ee.id),onCompareWithPrevious:c.has(ee.id)?i:void 0})})]},ee.id)})})}),eC=24,tC=132,nC=8;function sC(e){return e>eC}function oC(e){const t=new Map;for(let s=0;s<e.length;s++){const o=e[s];if(o!==void 0)for(const r of o.entries)t.set(r.log.id,s)}return t}function Ff(e,t,s){return n.jsx(QN,{entries:e.entries,viewMode:t.viewMode,strip:t.strip,slowResponseThresholdSeconds:t.slowResponseThresholdSeconds,timeDisplayFormat:t.timeDisplayFormat,cacheTrends:t.cacheTrends,onCompareWithPrevious:t.onCompareWithPrevious,comparisonPredecessors:t.comparisonPredecessors,turnIndex:e.turnIndex,pendingFocusRequest:s,showLogClientMetadata:t.showLogClientMetadata},e.turnIndex)}function rC(e){return sC(e.turnGroups.length)?n.jsx(aC,{...e}):n.jsx(n.Fragment,{children:e.turnGroups.map(t=>Ff(t,e))})}function aC(e){const{turnGroups:t}=e,[s,o]=l.useState(null),r=J5({count:t.length,estimateSize:()=>tC,overscan:nC,getItemKey:i=>t[i]?.turnIndex??i}),a=l.useMemo(()=>oC(t),[t]);return l.useEffect(()=>{const i=c=>{const d=Jr(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(sn,i),()=>{window.removeEventListener(sn,i)}},[a,r]),n.jsx("div",{className:"relative w-full",style:{height:`${r.getTotalSize()}px`},"data-virtualized-turn-list":"true",children:r.getVirtualItems().map(i=>{const c=t[i.index];if(c===void 0)return null;const d=s!==null&&s.turnIndex===i.index?s:void 0;return n.jsx("div",{"data-index":i.index,ref:r.measureElement,className:"absolute left-0 top-0 w-full",style:{transform:`translateY(${i.start}px)`},children:Ff(c,e,d)},i.key)})})}const zl=me(["episode","procedure","preference","project-fact"]),iC=me(["draft","promoted","failed"]),Bf=_({source:ae("agent-inspector"),sessionId:x(),logIds:V(Rt),project:x().nullable(),models:V(x())}),lC=_({redacted:Ce(),patterns:V(x())}),co=_({id:x(),type:zl,title:x(),content:x(),tags:V(x()),source:ae("agent-inspector"),sessionId:x(),logIds:V(Rt),evidence:Bf,status:iC,createdAt:x(),updatedAt:x(),openClawMemoryId:x().nullable(),error:x().nullable(),redaction:lC});_({idempotencyKey:x(),type:zl,title:x(),content:x(),tags:V(x()),source:ae("agent-inspector"),project:x().nullable(),evidence:Bf});const cC=_({id:x(),type:zl.or(x()),title:x(),content:x(),score:T().nullable(),source:x().nullable(),project:x().nullable(),evidence:Fs().optional()});_({results:V(cC),warning:x().nullable()});const dC=_({candidates:V(co)}),uC=_({candidate:co}),mC=_({error:x().optional(),candidate:co.optional()}),pC=_({candidate:co}),fC=3e4,hC=15e3,xC=15e3,gC={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 Ci(e){return e===null?"-":e<1e3?`${String(e)}ms`:`${(e/1e3).toFixed(1)}s`}function bC(e,t,s){return e===null||t===null?null:_r(e,t,s)}function vC(e){return`${String(e)} candidate${e===1?"":"s"}`}function Uf(e){return`log-${String(e)}`}function qf(e){const t=Uf(e),s=document.getElementById(t);window.history.replaceState(null,"",`#${t}`),s instanceof HTMLElement&&(s.scrollIntoView({block:"center",behavior:"smooth"}),s.focus({preventScroll:!0}))}function yC(e){for(const t of e)if(t.responseStatus!==null&&t.responseStatus>=400)return t;return null}function wC(e){let t=null,s=-1;for(const o of e)o.elapsedMs!==null&&o.elapsedMs>s&&(t=o,s=o.elapsedMs);return t}function jC(e){for(const t of e)if(Dl(t).length>0)return t;return null}function SC(e){const t=new Map;for(let s=0;s<e.length;s+=1){const o=e[s];o!==void 0&&t.set(o.id,s+1)}return t}function fs(e,t){return String(t.get(e)??e)}function NC(e){const t=[{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=jC(e.logs);e.summary.toolCallCount>0&&s!==null&&t.push({kind:"tool",title:`${String(e.summary.toolCallCount)} tool call${e.summary.toolCallCount===1?"":"s"}`,detail:`First tool evidence at #${fs(s.id,e.displayNumberByLogId)}`,logId:s.id});const o=yC(e.logs);o!==null&&t.push({kind:"failure",title:`Failure #${String(o.responseStatus)}`,detail:`First failed request is #${fs(o.id,e.displayNumberByLogId)}`,logId:o.id});const r=wC(e.logs);if(r!==null&&e.summary.maxElapsedMs!==null&&t.push({kind:"slow",title:`Slowest ${Ci(e.summary.maxElapsedMs)}`,detail:`Max latency observed at #${fs(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;t.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 t}function CC(e){switch(e){case"session":return n.jsx(kr,{className:"size-3.5 text-blue-400"});case"tool":return n.jsx(no,{className:"size-3.5 text-sky-400/70"});case"slow":return n.jsx(en,{className:"size-3.5 text-amber-400"});case"failure":return n.jsx(Tu,{className:"size-3.5 text-destructive"});case"candidate":return n.jsx(_u,{className:"size-3.5 text-emerald-400"})}}function kC({insights:e}){return e.length===0?null:n.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(t=>n.jsxs("button",{type:"button",className:P("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:()=>{t.logId!==null&&qf(t.logId)},disabled:t.logId===null,children:[CC(t.kind),n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"block truncate font-medium text-foreground/90",children:t.title}),n.jsx("span",{className:"block truncate font-mono text-[10px]",children:t.detail})]})]},`${t.kind}-${t.title}`))})}function _C(e){switch(e){case"draft":return"Draft";case"promoted":return"Promoted";case"failed":return"Failed"}}function TC(e,t){if(t)return"Promoting";switch(e.status){case"draft":return"Promote";case"failed":return"Retry";case"promoted":return"Promoted"}}function EC(e){return e.redaction.redacted?`Redacted ${e.redaction.patterns.join(", ")}`:"No sensitive pattern matched"}function RC(e,t){const s=e.replace(/\s+/g," ").trim();return s.length<=t?s:`${s.slice(0,t-3)}...`}function MC(e,t){const s=e[0],o=e[e.length-1];if(s===void 0)return"No evidence logs";const r=fs(s,t);return o===void 0||s===o?`#${r}`:`#${r}-#${fs(o,t)}`}function Zc(e){return e.join(", ")}function AC(e){return e.split(",").map(t=>t.trim()).filter(t=>t.length>0)}function IC({candidate:e,isPromoting:t,isUpdating:s,onPromoteCandidate:o,onUpdateCandidate:r,displayNumberByLogId:a}){const[i,c]=l.useState(!1),[d,m]=l.useState(e.type),[u,p]=l.useState(e.title),[f,h]=l.useState(e.content),[g,b]=l.useState(Zc(e.tags)),[y,w]=l.useState(null),v=e.status!=="promoted",j=e.status!=="promoted",S=l.useCallback(()=>{m(e.type),p(e.title),h(e.content),b(Zc(e.tags)),w(null)},[e.content,e.tags,e.title,e.type]),N=l.useCallback(async()=>{const C=u.trim(),E=f.trim(),A=AC(g);if(C.length===0){w("Title is required.");return}if(E.length===0){w("Content is required.");return}if(A.length===0){w("At least one tag is required.");return}w(null),await r(e.id,{type:d,title:C,content:E,tags:A})&&c(!1)},[e.id,f,g,u,d,r]);return i?n.jsx("div",{className:"border border-border bg-card shadow-sm rounded-[8px] px-2.5 py-2",children:n.jsxs("div",{className:"grid gap-2",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsxs("select",{value:d,disabled:s,onChange:C=>{const E=co.shape.type.safeParse(C.currentTarget.value);E.success&&m(E.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:[n.jsx("option",{value:"episode",children:"episode"}),n.jsx("option",{value:"procedure",children:"procedure"}),n.jsx("option",{value:"preference",children:"preference"}),n.jsx("option",{value:"project-fact",children:"project-fact"})]}),n.jsx("input",{value:u,disabled:s,onChange:C=>p(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"})]}),n.jsx("textarea",{value:f,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"}),n.jsx("input",{value:g,disabled:s,onChange:C=>b(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"}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-muted-foreground",children:[n.jsx(sc,{className:"size-3"}),"Saving reruns Inspector redaction before promotion."]}),n.jsx("span",{className:"flex-1"}),y!==null&&n.jsx("span",{className:"text-[10px] text-destructive",children:y}),n.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:[n.jsx(so,{className:"size-3.5"}),"Cancel"]}),n.jsxs(te,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:s,onClick:()=>{N()},children:[s?n.jsx(Et,{className:"size-3.5 animate-spin"}):n.jsx(v1,{className:"size-3.5"}),"Save"]})]})]})}):n.jsxs("div",{className:"rounded-md border border-border/80 bg-background/60 px-2.5 py-2",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(_e,{variant:"outline",className:"h-5 px-1.5 text-[10px] font-mono",children:e.type}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium",title:e.title,children:e.title}),n.jsx(_e,{variant:"outline",className:P("h-5 shrink-0 px-1.5 text-[10px] font-mono",gC[e.status]),children:_C(e.status)})]}),n.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",title:e.content,children:RC(e.content,360)}),n.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] text-muted-foreground",children:[n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx(yg,{className:"size-3"}),MC(e.logIds,a)]}),n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx(sc,{className:"size-3"}),EC(e)]}),e.status==="promoted"&&n.jsxs("span",{className:"inline-flex items-center gap-1 text-emerald-500",children:[n.jsx(Qa,{className:"size-3"}),e.openClawMemoryId??"OpenClaw"]}),e.status==="failed"&&e.error!==null&&n.jsxs("span",{className:"inline-flex items-center gap-1 text-destructive",children:[n.jsx(Tu,{className:"size-3"}),e.error]})]}),n.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5",children:[e.logIds.map(C=>{const E=fs(C,a);return n.jsxs("a",{href:`#${Uf(C)}`,onClick:A=>{A.preventDefault(),qf(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 ${E}`,title:`Log ID ${String(C)}`,children:["#",E]},C)}),n.jsx("span",{className:"flex-1"}),j&&n.jsxs(te,{type:"button",variant:"ghost",size:"sm",className:"h-6 gap-1.5 px-2 text-[10px]",disabled:s||t,onClick:()=>c(!0),children:[n.jsx(Lu,{className:"size-3"}),"Review"]}),n.jsxs(te,{type:"button",variant:v?"outline":"ghost",size:"sm",className:"h-6 gap-1.5 px-2 text-[10px]",onClick:()=>o(e.id),disabled:!v||t||s,children:[t?n.jsx(Et,{className:"size-3 animate-spin"}):v?n.jsx(tg,{className:"size-3"}):n.jsx(Qa,{className:"size-3"}),TC(e,t)]})]})]})}function PC({candidates:e,promotingCandidateIds:t,updatingCandidateIds:s,onPromoteCandidate:o,onUpdateCandidate:r,displayNumberByLogId:a}){return e.length===0?null:n.jsx("div",{className:"mt-2 grid gap-1.5",children:e.map(i=>n.jsx(IC,{candidate:i,isPromoting:t.has(i.id),isUpdating:s.has(i.id),onPromoteCandidate:o,onUpdateCandidate:r,displayNumberByLogId:a},i.id))})}function LC({logs:e,scopeId:t,slowResponseThresholdSeconds:s,showRollupMetrics:o,timeDisplayFormat:r}){const[a,i]=l.useState([]),[c,d]=l.useState(!0),[m,u]=l.useState({status:"idle",error:null}),[p,f]=l.useState(()=>new Set),[h,g]=l.useState(()=>new Set),b=a.length>0,y=l.useMemo(()=>ZN(e,s,a.length),[a.length,e,s]),w=l.useMemo(()=>SC(e),[e]),v=l.useMemo(()=>NC({logs:e,scopeId:t,summary:y,candidates:a,displayNumberByLogId:w}),[a,w,e,t,y]),j=o||y.maxElapsedMs!==null,S=l.useMemo(()=>bC(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 A=await Be(`/api/knowledge/sessions/${encodeURIComponent(t)}/candidates`,dC,fC,{method:"POST"},I=>`Candidate generation failed with ${String(I.status)}`);i(A.candidates),d(A.candidates.length>0),u(A.candidates.length>0?{status:"ready",error:null}:{status:"failed",error:"No candidate was generated for this trace scope."})}catch(A){u({status:"failed",error:A instanceof Error?A.message:"Candidate response was invalid"})}})())},[m.status,e.length,t]),C=l.useCallback(A=>{f(I=>{if(I.has(A))return I;const R=new Set(I);return R.add(A),R}),(async()=>{try{const I=await On(`/api/knowledge/candidates/${encodeURIComponent(A)}/promote`,hC,{method:"POST"}),R=await I.json().catch(()=>null),k=uC.safeParse(R);if(I.ok&&k.success){i(O=>O.map($=>$.id===k.data.candidate.id?k.data.candidate:$)),u({status:"ready",error:null});return}const M=mC.safeParse(R);M.success&&M.data.candidate!==void 0&&i(O=>O.map($=>$.id===M.data.candidate?.id?M.data.candidate:$)),u({status:"failed",error:M.success?M.data.error??"Candidate promotion failed":`Candidate promotion failed with ${String(I.status)}`})}catch(I){u({status:"failed",error:I instanceof Error?I.message:"Candidate promotion failed"})}finally{f(I=>{const R=new Set(I);return R.delete(A),R})}})()},[]),E=l.useCallback(async(A,I)=>{g(R=>{if(R.has(A))return R;const k=new Set(R);return k.add(A),k});try{const R=await Be(`/api/knowledge/candidates/${encodeURIComponent(A)}`,pC,xC,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(I)},k=>`Candidate update failed with ${String(k.status)}`);return i(k=>k.map(M=>M.id===R.candidate.id?R.candidate:M)),u({status:"ready",error:null}),!0}catch(R){return u({status:"failed",error:R instanceof Error?R.message:"Candidate update failed"}),!1}finally{g(R=>{const k=new Set(R);return k.delete(A),k})}},[]);return e.length===0?null:n.jsxs("section",{className:"border border-border bg-card shadow-sm mb-2 rounded-[8px] px-3 py-2",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 text-xs",children:[o&&n.jsxs("span",{className:"inline-flex items-center gap-1.5 font-semibold text-foreground",children:[n.jsx(kr,{className:"size-3.5 text-blue-400"}),y.llmCallCount," LLM"]}),n.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[n.jsx(no,{className:"size-3.5 text-sky-400/70"}),y.toolCallCount," tools"]}),o&&n.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[n.jsx(Vs,{className:"size-3.5 text-emerald-400"}),n.jsxs("span",{className:"font-mono",children:[Ie(y.totalInputTokens)," / ",Ie(y.totalOutputTokens)]})]}),(y.totalCacheCreationInputTokens>0||y.totalCacheReadInputTokens>0)&&n.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[n.jsx(Vs,{className:"size-3.5 text-purple-400"}),n.jsxs("span",{className:"font-mono",children:["KV Cache +",Ie(y.totalCacheCreationInputTokens)," / ~",Ie(y.totalCacheReadInputTokens)]})]}),j&&n.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[n.jsx(en,{className:"size-3.5"}),o&&n.jsx("span",{className:"font-mono",children:Ci(y.totalElapsedMs)}),y.maxElapsedMs!==null&&n.jsxs("span",{className:"font-mono text-muted-foreground/70",children:["max ",Ci(y.maxElapsedMs)]})]}),o&&S!==null&&n.jsx("span",{className:"font-mono text-muted-foreground/70",children:S}),(y.failedCallCount>0||y.pendingCallCount>0||y.slowCallCount>0)&&n.jsxs("span",{className:"inline-flex items-center gap-1.5 text-amber-400",children:[n.jsx(gn,{className:"size-3.5"}),n.jsxs("span",{className:"font-mono",children:[y.failedCallCount," fail / ",y.pendingCallCount," pending /"," ",y.slowCallCount," slow"]})]}),n.jsx("span",{className:"flex-1"}),b&&n.jsx(_e,{variant:"outline",className:"h-6 px-2 text-[10px] font-mono",children:vC(y.knowledgeCandidateCount)}),n.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"?n.jsx(Ue,{className:"size-3.5 animate-spin"}):n.jsx(_u,{className:"size-3.5"}),"Candidate"]}),b&&n.jsx(te,{type:"button",variant:"ghost",size:"icon",className:"size-7 text-muted-foreground",onClick:()=>d(A=>!A),"aria-expanded":c,"aria-label":c?"Collapse memory candidates":"Expand memory candidates",children:c?n.jsx(Xe,{className:"size-3.5"}):n.jsx(gt,{className:"size-3.5"})})]}),m.status==="failed"&&n.jsx("p",{className:"mt-2 text-xs text-destructive",children:m.error}),n.jsx(kC,{insights:v}),c&&n.jsx(PC,{candidates:a,promotingCandidateIds:p,updatingCandidateIds:h,onPromoteCandidate:C,onUpdateCandidate:E,displayNumberByLogId:w})]})}function OC(e){let t=0,s=0;for(const o of e)o.inputTokens!==null&&(t+=o.inputTokens),o.outputTokens!==null&&(s+=o.outputTokens);return{totalInputTokens:t,totalOutputTokens:s}}function DC(e){const t=new Map;for(const s of e){if(s.model===null)continue;const o=Yj(s.model);if(o==="unknown")continue;let r=t.get(o);r===void 0&&(r=new Set,t.set(o,r)),r.add(s.model)}return[...t.entries()].map(([s,o])=>({provider:s,models:[...o]}))}function zC(e){for(const t of e){const s=t.clientPid;if(s!=null)return s}return null}function $C(e){for(const t of e){const s=t.clientProjectFolder;if(s!=null&&s!=="")return s}return null}const FC=l.memo(function({group:e,viewMode:t="simple",strip:s,slowResponseThresholdSeconds:o,cacheTrends:r,onCompareWithPrevious:a,comparisonPredecessors:i,onClearGroup:c,showClientIdentity:d=!0,showProcessMetadata:m=!0,showLogClientMetadata:u=!0,defaultExpanded:p=!1,timeDisplayFormat:f,expanded:h,onExpandedChange:g}){const[b,y]=l.useState(p),w=h??b,v=l.useCallback(k=>{if(g!==void 0){g(k);return}y(k)},[g]);l.useEffect(()=>{!p||h!==void 0||y(!0)},[h,p]);const j=l.useMemo(()=>OC(e.logs),[e.logs]),S=l.useMemo(()=>DC(e.logs),[e.logs]),N=e.logs[0]?.timestamp??new Date().toISOString(),C=e.logs[e.logs.length-1]?.timestamp??new Date().toISOString(),E=e.logs.some(k=>k.responseStatus===null),A=l.useMemo(()=>zC(e.logs),[e.logs]),I=l.useMemo(()=>$C(e.logs),[e.logs]),R=l.useMemo(()=>Ni(e.logs),[e.logs]);return l.useEffect(()=>{const k=M=>{const O=Jr(M);O!==null&&e.logs.some($=>$.id===O.logId)&&v(!0)};return window.addEventListener(sn,k),()=>{window.removeEventListener(sn,k)}},[e.logs,v]),n.jsxs("div",{className:"mb-1.5",children:[n.jsx(R5,{conversationId:e.conversationId,startTime:N,endTime:C,totalCalls:e.logs.length,totalInputTokens:j.totalInputTokens,totalOutputTokens:j.totalOutputTokens,expanded:w,onToggle:()=>v(!w),providers:S,isLoading:E,userAgent:e.logs[0]?.userAgent??null,clientPid:A,clientProjectFolder:I,showClientIdentity:d,showProcessMetadata:m,timeDisplayFormat:f,onClear:()=>c(e.logs.map(k=>k.id))}),w&&n.jsxs("div",{children:[n.jsx(LC,{logs:e.logs,scopeId:e.conversationId,slowResponseThresholdSeconds:o,showRollupMetrics:!1,timeDisplayFormat:f}),n.jsx(rC,{turnGroups:R,viewMode:t,strip:s,slowResponseThresholdSeconds:o,timeDisplayFormat:f,cacheTrends:r,onCompareWithPrevious:a,comparisonPredecessors:i,showLogClientMetadata:u})]})]})}),BC="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",UC="m-0 min-w-0 flex-1 overflow-x-auto font-mono text-xs text-foreground sm:text-sm";function qC(e){return[`PROXY_BASE_URL=${e.proxy}`,`MCP_URL=${e.mcp}`]}function HC(e){return e==="full"}function VC(e){return e==="raw"}function WC(e,t){const s=t>0;return{redacted:s,raw:s&&HC(e)}}function GC(e,t){const s=e[0],o=e[e.length-1];return s===void 0||o===void 0?null:_r(s.timestamp,o.timestamp,t)}function KC(e){return e.error!==null&&e.error!==void 0&&e.error.length>0?!0:e.responseStatus!==null&&e.responseStatus>=400}function YC(e){const t=new Set;for(const o of e)o.model!==null&&o.model.length>0&&t.add(o.model);const s=[...t].sort();return s.length===0?"Model unknown":s.length===1?s[0]??"Model unknown":`${s.length} models`}function JC(e){const t=new Set;for(const o of e)o.providerName!==null&&o.providerName!==void 0&&o.providerName.length>0&&t.add(o.providerName);const s=[...t].sort();return s.length===0?"Provider unknown":s.length===1?s[0]??"Provider unknown":`${s.length} providers`}function XC(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 t=Math.round(e/1e3),s=Math.floor(t/60),o=t%60;return`${s}m ${o}s`}function ZC(e,t){return`${Ie(e)} in / ${Ie(t)} out`}function QC(e,t){if(e.length===0)return 0;if(t.length===0)return Ni(e).length;let s=0;for(const o of t)s+=Ni(o.logs).length;return s}function ek({stopReason:e,pending:t,lastFailureLogNumber:s}){if(t>0)return{label:"In flight",detail:`${t} request${t===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 tk(e){if(e===null)return!1;const t=e.toLowerCase();return t.includes("abort")||t.includes("cancel")||t.includes("client disconnected")||t.includes("stream disconnected")||t.includes("connection closed")}function nk({pending:e,failures:t,lengthStops:s,stopReason:o,lastFailure:r}){if(r!==null&&(r.status===499||tk(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(t>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 sk({logs:e,conversationGroups:t,isLoading:s,timeDisplayFormat:o,slowResponseThresholdSeconds:r}){let a=0,i=0,c=0,d=0,m=0,u=0,p=null,f=null,h=null,g=null,b=null,y=0,w=0,v=0,j=null;const S=r*1e3;for(let I=0;I<e.length;I+=1){const R=e[I];if(R===void 0)continue;const k=I+1,M=kf(R);M!==null&&(p=M),M==="length"&&(d+=1),KC(R)&&(a+=1,f=k,h={logNumber:k,status:R.responseStatus,error:R.error??null}),R.responseStatus===null&&(i+=1),r>0&&R.elapsedMs!==null&&R.elapsedMs>=S&&(c+=1),R.inputTokens!==null&&(m+=R.inputTokens),R.outputTokens!==null&&(u+=R.outputTokens),R.elapsedMs!==null&&(g===null||R.elapsedMs>g)&&(g=R.elapsedMs,b=k);const O=R.inputTokens??0,$=R.outputTokens??0,K=O+$;K>y&&(y=K,w=O,v=$,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",E=ek({stopReason:p,pending:i,lastFailureLogNumber:f}),A=nk({pending:i,failures:a,lengthStops:d,stopReason:p,lastFailure:h});return{status:N,statusLabel:C,modelLabel:YC(e),providerLabel:JC(e),requests:e.length,turns:QC(e,t),failures:a,pending:i,slow:c,lengthStops:d,timeRange:GC(e,o),tokenLabel:`${Ie(m)} in / ${Ie(u)} out`,finishLabel:E.label,finishDetail:E.detail,finishTone:E.tone,outcomeLabel:A.label,outcomeDetail:A.detail,outcomeTone:A.tone,slowestLabel:g===null?"n/a":XC(g),slowestDetail:b===null?"Latency pending":`Request #${b}`,heaviestDetail:j===null?"Tokens pending":`#${j} ${ZC(w,v)}`}}function ok({pinnedSessionId:e,selectedSession:t,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(t!=="__all__"){const i=o.filter(c=>c.sessionId===t);return i.length===0?null:{label:t,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 rk({logs:e,pagination:t}){if(t.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 t.total===null?`Showing ${e.length} logs (${r})`:t.total<=e.length?`Showing all ${t.total} logs`:`Showing ${e.length} of ${t.total} logs (${r})`}function Ys({...e}){return n.jsx(gp,{"data-slot":"select",...e})}function hr({...e}){return n.jsx(wp,{"data-slot":"select-value",...e})}function Js({className:e,size:t="default",children:s,...o}){return n.jsxs(vp,{"data-slot":"select-trigger","data-size":t,className:P("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,n.jsx(jp,{asChild:!0,children:n.jsx(Xe,{className:"size-4 opacity-50"})})]})}function Xs({className:e,children:t,position:s="popper",align:o="center",...r}){return n.jsx(Np,{children:n.jsxs(Cp,{"data-slot":"select-content",className:P("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:[n.jsx(ak,{}),n.jsx(Rp,{className:P("p-1",s==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),n.jsx(ik,{})]})})}function it({className:e,children:t,...s}){return n.jsxs(Pp,{"data-slot":"select-item",className:P("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:[n.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:n.jsx(Dp,{children:n.jsx(Fe,{className:"size-4"})})}),n.jsx(Lp,{children:t})]})}function ak({className:e,...t}){return n.jsx(zp,{"data-slot":"select-scroll-up-button",className:P("flex cursor-default items-center justify-center py-1",e),...t,children:n.jsx(Ji,{className:"size-4"})})}function ik({className:e,...t}){return n.jsx($p,{"data-slot":"select-scroll-down-button",className:P("flex cursor-default items-center justify-center py-1",e),...t,children:n.jsx(Xe,{className:"size-4"})})}const lk=me(["critical","warning","notice"]),ck=me(["open"]),dk=me(["proxy","tool-schema","run","group"]),Hf=me(["request-failure","request-timeout","slow-response","tool-schema","run-failure","group-failure","group-incomplete"]),uk=me(["log","session","run","group"]),mk=me(["anthropic","openai","unknown"]),pk=_({kind:uk,id:x(),label:x(),href:x().nullable()}),fk=_({id:x(),fingerprint:x(),severity:lk,category:Hf,source:dk,status:ck,title:x(),message:x(),count:T().int().positive(),firstSeenAt:x(),lastSeenAt:x(),logIds:V(Rt),sessionIds:V(x()),runIds:V(x()),groupIds:V(x()),provider:x().nullable(),model:x().nullable(),apiFormat:mk.nullable(),evidence:V(pk),metadata:qe(x(),Je)}),hk=_({category:Hf,count:T().int().nonnegative()}),Vf=_({total:T().int().nonnegative(),open:T().int().nonnegative(),critical:T().int().nonnegative(),warning:T().int().nonnegative(),notice:T().int().nonnegative(),byCategory:V(hk)}),xk=_({alerts:V(fk),total:T().int().nonnegative(),limit:T().int().positive(),summary:Vf}),gk=8e3,bk=1e4;function vk(e){const t=new URLSearchParams;e.severity!==void 0&&t.set("severity",e.severity),e.category!==void 0&&t.set("category",e.category),e.source!==void 0&&t.set("source",e.source),e.limit!==void 0&&t.set("limit",String(e.limit));const s=t.toString();return s.length>0?`/api/alerts?${s}`:"/api/alerts"}function yk(e,t){const s=$t(t?vk(e):null,o=>Be(o,xk,bk));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 wk(){const e=$t("/api/alerts/summary",t=>Be(t,Vf,gk),{refreshInterval:5e3,revalidateOnFocus:!0});return{summary:e.data??null,isLoading:e.isLoading,error:e.error,mutate:e.mutate}}const uo="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",jk=["request-failure","request-timeout","slow-response","tool-schema","run-failure","group-failure","group-incomplete"];function Wf(e){switch(e){case"critical":return"Critical";case"warning":return"Warning";case"notice":return"Notice"}}function Sk(e){switch(e){case"proxy":return"Proxy";case"tool-schema":return"Tool schema";case"run":return"Run";case"group":return"Group"}}function $l(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 Nk(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 Ck(e){switch(e){case"critical":return"bg-status-danger";case"warning":return"bg-status-watch";case"notice":return"bg-status-cool"}}function kk(e){switch(e){case"critical":return"text-status-danger";case"warning":return"text-status-watch";case"notice":return"text-status-cool"}}function _k(e){switch(e){case"request-failure":case"run-failure":case"group-failure":return n.jsx(M1,{className:"size-3.5"});case"request-timeout":case"slow-response":return n.jsx(Z0,{className:"size-3.5"});case"tool-schema":return n.jsx(gn,{className:"size-3.5"});case"group-incomplete":return n.jsx(w0,{className:"size-3.5"})}}function ki(e){const t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat(void 0,{month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t)):e}function ht(e){return e.toLocaleString()}function Gf(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 Tk(e,t){const s={limit:100};return e!=="all"&&(s.severity=e),t!=="all"&&(s.category=t),s}function Ek(e,t){if(t!==null){const s=e.find(o=>o.id===t);if(s!==void 0)return s}return e[0]??null}function _o({label:e,count:t,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 n.jsxs("div",{className:P("rounded-md border px-3 py-2",o),children:[n.jsx("div",{className:"text-[10px] font-semibold uppercase opacity-75",children:e}),n.jsx("div",{className:"mt-1 text-lg font-semibold leading-none",children:ht(t)})]})}function To({value:e,active:t,label:s,count:o,onClick:r}){return n.jsxs(te,{type:"button",variant:t?"secondary":"ghost",size:"sm","aria-pressed":t,onClick:()=>r(e),className:"h-7 px-2",children:[s,o!==null?n.jsx(_e,{variant:"outline",children:ht(o)}):null]})}function Rk({category:e,active:t,count:s,onClick:o}){return n.jsxs(te,{type:"button",variant:t?"secondary":"ghost",size:"sm","aria-pressed":t,onClick:()=>o(e),className:"h-7 px-2",children:[_k(e),$l(e),n.jsx(_e,{variant:"outline",children:ht(s)})]})}function Mk({alerts:e,selectedAlertId:t,isLoading:s,error:o,onSelect:r}){return s?n.jsxs("div",{className:"flex min-h-56 items-center justify-center rounded-md border border-dashed border-border text-xs text-muted-foreground",children:[n.jsx(Ue,{className:"mr-2 size-3.5 animate-spin"}),"Loading alerts..."]}):o!==void 0?n.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?n.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."}):n.jsx("div",{className:"min-h-0 space-y-2 overflow-y-auto pr-1",children:e.map(a=>{const i=a.id===t;return n.jsxs("button",{type:"button",onClick:()=>r(a.id),className:P("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:[n.jsxs("div",{className:"flex items-start justify-between gap-3",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsx("span",{className:P("size-2 rounded-full",Ck(a.severity))}),n.jsx("span",{className:P("text-xs font-semibold",kk(a.severity)),children:Wf(a.severity)}),n.jsx("span",{className:"truncate text-xs text-muted-foreground",children:$l(a.category)})]}),n.jsx("div",{className:"mt-1 text-sm font-semibold leading-snug",children:a.title}),n.jsx("div",{className:"mt-1 line-clamp-2 text-xs text-muted-foreground",children:a.message})]}),a.count>1?n.jsxs(_e,{variant:"outline",className:"shrink-0",children:["x",ht(a.count)]}):null]}),n.jsxs("div",{className:"mt-2 flex min-w-0 items-start justify-between gap-2 text-[11px] text-muted-foreground",children:[n.jsx("span",{className:"min-w-0 leading-snug",children:Gf(a)}),n.jsx("span",{className:"shrink-0",children:ki(a.lastSeenAt)})]})]},a.id)})})}function Ak({alert:e,onNavigate:t}){return e.evidence.length===0?n.jsx("span",{className:"text-xs text-muted-foreground",children:"No linked evidence"}):n.jsx("div",{className:"flex flex-wrap gap-2",children:e.evidence.map(s=>s.href===null?n.jsx(_e,{variant:"outline",children:s.label},`${s.kind}:${s.id}`):n.jsx(_e,{variant:"outline",asChild:!0,children:n.jsx("a",{href:s.href,onClick:t,children:s.label})},`${s.kind}:${s.id}`))})}function Ik({alert:e,onNavigate:t}){return e===null?n.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."}):n.jsxs("div",{className:"min-h-0 overflow-y-auto rounded-md border border-border bg-background/70",children:[n.jsx("div",{className:P("border-b px-4 py-3",Nk(e.severity)),children:n.jsxs("div",{className:"flex items-start justify-between gap-3",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx(_e,{variant:"outline",children:Wf(e.severity)}),n.jsx(_e,{variant:"outline",children:Sk(e.source)}),n.jsx(_e,{variant:"outline",children:$l(e.category)})]}),n.jsx("h3",{className:"mt-3 text-base font-semibold",children:e.title}),n.jsx("p",{className:"mt-1 text-sm opacity-85",children:e.message})]}),e.count>1?n.jsxs(_e,{variant:"outline",className:"shrink-0",children:[ht(e.count)," hits"]}):null]})}),n.jsxs("div",{className:"space-y-4 p-4",children:[n.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[n.jsx(cn,{label:"Target",value:Gf(e)}),n.jsx(cn,{label:"Last seen",value:ki(e.lastSeenAt)}),n.jsx(cn,{label:"First seen",value:ki(e.firstSeenAt)}),n.jsx(cn,{label:"Protocol",value:e.apiFormat??"n/a"})]}),n.jsxs("div",{children:[n.jsx("div",{className:"mb-2 text-xs font-semibold text-muted-foreground",children:"Evidence"}),n.jsx(Ak,{alert:e,onNavigate:t})]}),n.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[n.jsx(cn,{label:"Logs",value:e.logIds.length===0?"n/a":ht(e.logIds.length)}),n.jsx(cn,{label:"Sessions",value:e.sessionIds.length===0?"n/a":ht(e.sessionIds.length)}),n.jsx(cn,{label:"Runs",value:e.runIds.length===0?"n/a":ht(e.runIds.length)}),n.jsx(cn,{label:"Groups",value:e.groupIds.length===0?"n/a":ht(e.groupIds.length)})]})]})]})}function cn({label:e,value:t}){return n.jsxs("div",{className:"rounded-md border border-border bg-muted/30 px-3 py-2",children:[n.jsx("div",{className:"text-[10px] font-semibold uppercase text-muted-foreground",children:e}),n.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-foreground",children:t})]})}function Pk(){const[e,t]=l.useState(!1),[s,o]=l.useState("all"),[r,a]=l.useState("all"),[i,c]=l.useState(null),{summary:d,isLoading:m}=wk(),u=l.useMemo(()=>Tk(s,r),[r,s]),{alerts:p,total:f,isLoading:h,error:g,mutate:b}=yk(u,e),y=l.useMemo(()=>Ek(p,i),[p,i]);l.useEffect(()=>{!e||i!==null&&p.some(E=>E.id===i)||c(p[0]?.id??null)},[p,e,i]);const w=d?.total??0,v=d?.critical??0,j=d?.warning??0,S=d?.notice??0,N=v>0?"bg-status-danger text-primary-foreground":j>0?"bg-status-watch text-primary-foreground":"bg-status-cool text-primary-foreground";return n.jsxs(qt,{open:e,onOpenChange:t,children:[n.jsx(io,{asChild:!0,children:n.jsxs(te,{type:"button",variant:"ghost",size:"icon",className:uo,"aria-label":"Alerts",title:"Alerts",children:[n.jsx(nr,{className:"size-4"}),m?n.jsx(Ue,{className:"absolute -right-0.5 -top-0.5 size-3 animate-spin text-muted-foreground"}):w>0?n.jsx("span",{className:P("absolute -right-1 -top-1 min-w-4 rounded-full px-1 text-[10px] font-semibold leading-4",N),children:ht(w)}):null,n.jsx("span",{className:"sr-only",children:"Alerts"})]})}),n.jsxs(Ht,{className:"flex max-h-[86vh] max-w-6xl flex-col overflow-hidden",children:[n.jsxs(Yt,{children:[n.jsxs(Jt,{className:"flex items-center gap-2 pr-8",children:[n.jsx(nr,{className:"size-5 text-status-danger"}),n.jsx("span",{children:"Alerts"}),n.jsx(_e,{variant:"outline",children:ht(w)})]}),n.jsx(lo,{className:"sr-only",children:"Local alert board for captured Inspector evidence."})]}),n.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[n.jsx(_o,{label:"Open",count:d?.open??0,tone:"neutral"}),n.jsx(_o,{label:"Critical",count:v,tone:"critical"}),n.jsx(_o,{label:"Warning",count:j,tone:"warning"}),n.jsx(_o,{label:"Notice",count:S,tone:"notice"})]}),n.jsxs("div",{className:"flex min-h-0 flex-wrap items-center justify-between gap-2 border-y border-border py-3",children:[n.jsxs("div",{className:"flex flex-wrap gap-1",children:[n.jsx(To,{value:"all",active:s==="all",label:"All",count:d?.total??null,onClick:o}),n.jsx(To,{value:"critical",active:s==="critical",label:"Critical",count:v,onClick:o}),n.jsx(To,{value:"warning",active:s==="warning",label:"Warning",count:j,onClick:o}),n.jsx(To,{value:"notice",active:s==="notice",label:"Notice",count:S,onClick:o})]}),n.jsxs(te,{type:"button",variant:"outline",size:"sm",className:"h-7 shrink-0 px-2",onClick:()=>{b()},children:[n.jsx(Et,{className:"size-3.5"}),"Refresh"]})]}),n.jsxs("div",{className:"flex flex-wrap gap-1",children:[n.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"}),jk.map(C=>{const E=d?.byCategory.find(A=>A.category===C)?.count??0;return E===0?null:n.jsx(Rk,{category:C,active:r===C,count:E,onClick:a},C)})]}),n.jsxs("div",{className:"grid min-h-0 flex-1 gap-4 md:grid-cols-[360px_minmax(0,1fr)]",children:[n.jsxs("div",{className:"flex min-h-0 flex-col",children:[n.jsxs("div",{className:"mb-2 flex items-center justify-between text-xs text-muted-foreground",children:[n.jsxs("span",{children:[ht(f)," matched"]}),n.jsx("span",{children:p.length<f?`${ht(p.length)} shown`:"Latest"})]}),n.jsx(Mk,{alerts:p,selectedAlertId:y?.id??null,isLoading:h,error:g,onSelect:c})]}),n.jsx(Ik,{alert:y,onNavigate:()=>t(!1)})]})]})]})}const Lk=12e3;function Ok(e){return e===null||e.evidence===null?null:`/api/groups/${encodeURIComponent(e.id)}/evidence`}function Dk(e){const t=$t(Ok(e),s=>Be(s,Yx,Lk));return{evidenceResponse:t.data??null,isLoading:t.isLoading,error:t.error,mutate:t.mutate}}const zk=8e3;function $k(){const e=$t("/api/groups",t=>Be(t,Nu,zk));return{groups:e.data?.groups??[],isLoading:e.isLoading,error:e.error,mutate:e.mutate}}const Fk=3e3;function Bk(e,t){return{id:(e?.id??0)+1,message:t.message,tone:t.tone??"error"}}function Kf(){const[e,t]=l.useState(null),s=l.useCallback(r=>{t(a=>Bk(a,r))},[]),o=l.useCallback(()=>{t(null)},[]);return l.useEffect(()=>{if(e===null)return;const r=window.setTimeout(()=>{t(null)},Fk);return()=>{window.clearTimeout(r)}},[e]),{notice:e,showToast:s,dismissToast:o}}function Yf({notice:e,onDismiss:t}){if(e===null)return null;const s=e.tone==="error",o=s?gn:Qa;return n.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:n.jsxs("div",{className:P("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:[n.jsx(o,{className:P("mt-0.5 size-4 shrink-0",s?"text-status-danger":"text-status-success")}),n.jsx("div",{className:"min-w-0 flex-1 break-words leading-5",children:e.message}),n.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:t,children:n.jsx(so,{className:"size-3.5"})})]},e.id)})}const Ma=2e4;function Uk(e,t){const s=`/api/groups/${encodeURIComponent(e)}`;return t?`${s}?deleteEvidence=1`:s}function qk(e){return"/api/groups"}function Jf(e){let t=0,s=0,o=0,r=0;for(const a of e.members)switch(a.status){case"completed":t+=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:t,failedMembers:s,runningMembers:o,missingStatusMembers:r}}function Hk(e,t,s=null){return t!==null&&t.group.id===e.id?t.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 Fl(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 Bl(e){return e??"unknown"}function Vk(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 Xr(e){return e===null||e.trim().length===0?"-":e}function ft(e){return e.toLocaleString()}function _i(e){return e==null?"-":e<1e3?`${ft(e)} ms`:`${(e/1e3).toFixed(1)} s`}function Ns(e){const t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat(void 0,{month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t)):e}function Qc(e){return e===null?"-":Ns(e)}function Wk(e){const t=JSON.stringify(e),s=t===void 0?String(e):t;return s.length<=160?s:`${s.slice(0,157)}...`}function Xf(...e){for(const t of e)if(t!==null&&t.trim().length>0)return t;return"-"}function Gk(...e){for(const t of e)if(t!=null&&t.trim().length>0)return t;return null}function Kk(e){const t=e.provider,s=e.model;return t!==null&&t.length>0&&s!==null&&s.length>0?`${t} / ${s}`:Xf(t,s)}function Yk(e,t){if(t!==null){const s=e.find(o=>o.id===t);if(s!==void 0)return s}return e[0]??null}function Jk(e){return(e.exportMember?.session?.latestLogs??[])[0]??null}function Xk(e){switch(e){case"export":return"fresh export";case"evidence":return"evidence";case"group":return"group"}}function Zk(e,t){return t!==null&&t.group.id===e.id?t.evidence:e.evidence}function Qk(e,t,s){return t!==null&&t.group.id===e.id?t.summary:s!==null&&s.group.id===e.id?s.summary:null}function e3(e,t,s){return t!==null&&t.group.id===e.id?t.jenkinsReport:s!==null&&s.group.id===e.id?s.report:null}function t3({labelledTrigger:e=!1}){const[t,s]=l.useState(!1),[o,r]=l.useState(null),[a,i]=l.useState(null),[c,d]=l.useState(null),[m,u]=l.useState(null),[p,f]=l.useState(null),[h,g]=l.useState(!1),[b,y]=l.useState(null),[w,v]=l.useState(null),[j,S]=l.useState(!1),{notice:N,showToast:C,dismissToast:E}=Kf(),{groups:A,isLoading:I,error:R,mutate:k}=$k(),M=l.useMemo(()=>Yk(A,o),[A,o]);l.useEffect(()=>{!t||o!==null&&A.some(L=>L.id===o)||r(A[0]?.id??null)},[A,t,o]);const O=M!==null&&m!==null&&m.group.id===M.id?m:null,{evidenceResponse:$,isLoading:K,error:Q,mutate:z}=Dk(M),H=l.useCallback(()=>{k()},[k]),ee=l.useCallback(async()=>{if(!(A.length===0||j)){S(!0),f(null),g(!1),v(null),d(null);try{const oe=await Be(qk(!1),wu,Ma,{method:"DELETE"},L=>`Clear failed with status ${String(L.status)}`);u(null),r(null),await k(),await z(),C({message:`Cleared ${ft(oe.deleted)} group${oe.deleted===1?"":"s"}.`,tone:"success"})}catch(oe){C({message:oe instanceof Error?oe.message:"Unknown error clearing groups",tone:"error"})}finally{S(!1)}}},[j,A.length,k,z,C]),U=l.useCallback(async oe=>{i(oe.id),d(null);try{const L=await Be(`/api/groups/${encodeURIComponent(oe.id)}/evidence`,Jx,Ma,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({latestLogLimit:10})},J=>`Export failed with status ${String(J.status)}`);u(L),await k(),await z()}catch(L){d(L instanceof Error?L.message:String(L))}finally{i(null)}},[k,z]),Z=l.useCallback(oe=>{f(oe),g(!1),v(null)},[]),fe=l.useCallback(()=>{b===null&&(f(null),g(!1),v(null))},[b]),je=l.useCallback(oe=>{r(oe),f(null),g(!1),v(null)},[]),he=l.useCallback(async()=>{const oe=p;if(oe!==null){y(oe.id),v(null);try{await Be(Uk(oe.id,h),yu,Ma,{method:"DELETE"},L=>`Delete failed with status ${String(L.status)}`),u(L=>L!==null&&L.group.id===oe.id?null:L),r(L=>L===oe.id?null:L),f(null),g(!1),await k(),await z()}catch(L){v(L instanceof Error?L.message:String(L))}finally{y(null)}}},[h,p,k,z]);return n.jsxs(qt,{open:t,onOpenChange:s,children:[n.jsx(Yf,{notice:N,onDismiss:E}),n.jsx(io,{asChild:!0,children:n.jsxs(te,{type:"button",variant:"ghost",size:e?"default":"icon",className:P(uo,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:[n.jsx(ec,{className:"size-4"}),I?n.jsx(Ue,{className:"absolute -right-0.5 -top-0.5 size-3 animate-spin text-muted-foreground"}):A.length>0?n.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:A.length}):null,n.jsx("span",{className:e?"":"sr-only",children:"Groups"})]})}),n.jsxs(Ht,{className:"flex max-h-[85vh] max-w-5xl flex-col overflow-hidden",children:[n.jsx(Yt,{children:n.jsxs(Jt,{className:"flex items-center gap-2 pr-8",children:[n.jsx(ec,{className:"size-5 text-muted-foreground"}),n.jsx("span",{children:"Groups"}),n.jsx(_e,{variant:"outline",children:ft(A.length)})]})}),n.jsxs("div",{className:"flex min-h-0 items-center justify-between gap-3 border-b border-border pb-3",children:[n.jsx("p",{className:"text-xs text-muted-foreground",children:"Evaluation batches, model runs, and exported evidence packs."}),n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[n.jsxs(te,{type:"button",variant:"outline",size:"sm",disabled:A.length===0||j,onClick:()=>{ee()},title:"Clear all groups. Session logs and run records stay intact.",children:[j?n.jsx(Ue,{className:"size-3.5 animate-spin"}):n.jsx(yn,{className:"size-3.5"}),"Clear"]}),n.jsxs(te,{type:"button",variant:"outline",size:"sm",onClick:H,children:[n.jsx(Et,{className:"size-3.5"}),"Refresh"]})]})]}),n.jsxs("div",{className:"grid min-h-0 flex-1 gap-4 md:grid-cols-[260px_minmax(0,1fr)]",children:[n.jsx(n3,{groups:A,selectedGroupId:M?.id??null,isLoading:I,error:R,onSelect:je}),n.jsx(s3,{group:M,deleteTarget:p,deleteEvidence:h,exportResult:O,evidenceResponse:$,evidenceLoading:K,evidenceError:Q,exportError:c,deleteError:w,exportingGroupId:a,deletingGroupId:b,onDeleteEvidenceChange:g,onExport:U,onRequestDelete:Z,onCancelDelete:fe,onConfirmDelete:()=>{he()}})]})]})]})}function n3({groups:e,selectedGroupId:t,isLoading:s,error:o,onSelect:r}){return s?n.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?n.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?n.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."}):n.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:n.jsx("div",{className:"space-y-2",children:e.map(a=>{const i=Jf(a),c=t===a.id;return n.jsxs("button",{type:"button",onClick:()=>r(a.id),className:P("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:[n.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[n.jsx("span",{className:"min-w-0 text-sm font-medium leading-snug",children:a.title}),n.jsx(_e,{variant:"outline",className:Fl(a.status),children:Bl(a.status)})]}),n.jsxs("div",{className:"mt-1 flex items-center gap-2 text-muted-foreground",children:[n.jsxs("span",{children:[i.memberCount," sessions"]}),n.jsx("span",{children:Ns(a.updatedAt)})]})]},a.id)})})})}function s3({group:e,deleteTarget:t,deleteEvidence:s,exportResult:o,evidenceResponse:r,evidenceLoading:a,evidenceError:i,exportError:c,deleteError:d,exportingGroupId:m,deletingGroupId:u,onDeleteEvidenceChange:p,onExport:f,onRequestDelete:h,onCancelDelete:g,onConfirmDelete:b}){if(e===null)return n.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=Jf(e),w=Qk(e,o,r),v=e3(e,o,r),j=Zk(e,o),S=Hk(e,o,r),N=m===e.id,C=u===e.id,E=t?.id===e.id;return n.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex min-w-0 flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[n.jsxs("div",{className:"min-w-0 space-y-1",children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[n.jsx("h3",{className:"min-w-0 text-base font-semibold leading-snug",children:e.title}),n.jsx(_e,{variant:"outline",className:Fl(e.status),children:Bl(e.status)}),n.jsx(_e,{variant:"outline",children:e.kind})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[n.jsx("span",{children:Xr(e.project)}),n.jsxs("span",{children:["updated ",Ns(e.updatedAt)]})]})]}),n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[n.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?n.jsx(Ue,{className:"size-3.5 animate-spin"}):n.jsx(yn,{className:"size-3.5"})}),n.jsxs(te,{type:"button",variant:"default",size:"sm",className:"shrink-0",disabled:N||C,onClick:()=>{f(e)},children:[N?n.jsx(Ue,{className:"size-3.5 animate-spin"}):n.jsx(to,{className:"size-3.5"}),"Export evidence"]})]})]}),e.task!==null&&e.task.trim().length>0&&n.jsx("p",{className:"rounded-md border border-border bg-muted/20 px-3 py-2 text-xs text-muted-foreground",children:e.task}),E&&n.jsx(o3,{group:e,deleteEvidence:s,isDeleting:C,error:d,onDeleteEvidenceChange:p,onCancel:g,onConfirm:b}),n.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[n.jsx(dn,{label:"Members",value:y.memberCount}),n.jsx(dn,{label:"Done",value:y.completedMembers}),n.jsx(dn,{label:"Failed",value:y.failedMembers}),n.jsx(dn,{label:"Running",value:y.runningMembers})]}),w!==null&&n.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[n.jsx(dn,{label:"Requests",value:w.requestCount}),n.jsx(dn,{label:"Errors",value:w.errorCount}),n.jsx(dn,{label:"Tokens",value:w.tokenUsage.total}),n.jsx(dn,{label:"Missing",value:w.missingSessions})]}),n.jsx(r3,{report:v,loading:a,error:i,hasEvidence:j!==null}),n.jsx(a3,{evidence:j}),c!==null&&n.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&&!E&&n.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}),n.jsx(i3,{rows:S})]})})}function o3({group:e,deleteEvidence:t,isDeleting:s,error:o,onDeleteEvidenceChange:r,onCancel:a,onConfirm:i}){const c=e.evidence!==null,d=e.evidence?.markdownPath??"No evidence pack exported.";return n.jsx("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-3 text-status-danger",children:n.jsxs("div",{className:"flex min-w-0 flex-col gap-3 lg:flex-row lg:items-start lg:justify-between",children:[n.jsxs("div",{className:"min-w-0 space-y-2",children:[n.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[n.jsx(yn,{className:"size-4 text-status-danger"}),n.jsx("span",{children:"Delete group?"})]}),n.jsxs("p",{className:"text-xs text-status-danger",children:["Delete ",n.jsx("span",{className:"font-medium",children:e.title}),". Session logs and run records stay intact."]}),n.jsxs("label",{className:P("flex min-w-0 items-start gap-2 text-xs",c?"cursor-pointer":"opacity-60"),children:[n.jsx("input",{type:"checkbox",className:"mt-0.5 size-4 shrink-0",checked:t,disabled:!c||s,onChange:m=>r(m.currentTarget.checked)}),n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"block font-medium",children:"Also delete exported evidence files"}),n.jsx("code",{className:"mt-1 block truncate font-mono text-[11px] text-status-danger",children:d})]})]}),o!==null&&n.jsx("div",{className:"rounded-md border border-status-danger/30 bg-card px-2 py-1.5 text-xs text-status-danger",children:o})]}),n.jsxs("div",{className:"flex shrink-0 justify-end gap-2",children:[n.jsx(te,{type:"button",variant:"outline",size:"sm",disabled:s,onClick:a,children:"Cancel"}),n.jsxs(te,{type:"button",variant:"destructive",size:"sm",disabled:s,onClick:i,children:[s?n.jsx(Ue,{className:"size-3.5 animate-spin"}):n.jsx(yn,{className:"size-3.5"}),"Delete"]})]})]})})}function dn({label:e,value:t}){return n.jsxs("div",{className:"rounded-md border border-border bg-muted/20 px-3 py-2",children:[n.jsx("div",{className:"text-[11px] font-medium uppercase text-muted-foreground",children:e}),n.jsx("div",{className:"mt-1 font-mono text-sm font-semibold",children:ft(t)})]})}function r3({report:e,loading:t,error:s,hasEvidence:o}){const{copied:r,copy:a}=fn(e?.markdown??null);return e===null&&!t&&s===void 0?null:t?n.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:[n.jsx(Ue,{className:"size-3.5 animate-spin"}),"Loading evidence report..."]}):s!==void 0&&o?n.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:n.jsxs("div",{className:"rounded-md border border-border bg-muted/20 px-3 py-2",children:[n.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsx("span",{className:"text-xs font-semibold",children:"Evidence report"}),n.jsx(_e,{variant:"outline",className:Vk(e.status),children:e.status})]}),n.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?n.jsx(Fe,{className:"size-3.5 text-status-success"}):n.jsx(It,{className:"size-3.5"})})]}),n.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:e.summary})]})}function a3({evidence:e}){return e===null?n.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."}):n.jsxs("div",{className:"space-y-2 rounded-md border border-border bg-muted/20 px-3 py-2",children:[n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx("span",{className:"text-xs font-semibold",children:"Evidence paths"}),n.jsx("span",{className:"text-[11px] text-muted-foreground",children:Ns(e.exportedAt)})]}),n.jsxs("div",{className:"grid gap-2",children:[n.jsx(Aa,{label:"JSON",value:e.jsonPath}),n.jsx(Aa,{label:"Markdown",value:e.markdownPath}),n.jsx(Aa,{label:"HTML",value:e.htmlPath})]})]})}function Aa({label:e,value:t}){const{copied:s,copy:o}=fn(t);return n.jsxs("div",{className:"flex min-w-0 items-center gap-2 rounded-md border border-border bg-background px-2 py-1.5",children:[n.jsx("span",{className:"w-16 shrink-0 text-[11px] font-medium text-muted-foreground",children:e}),n.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs",children:t}),n.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?n.jsx(Fe,{className:"size-3.5 text-status-success"}):n.jsx(It,{className:"size-3.5"})})]})}function i3({rows:e}){const[t,s]=l.useState(null),o=l.useCallback(r=>{s(a=>a===r?null:r)},[]);return e.length===0?n.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."}):n.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[n.jsx("div",{className:"border-b border-border bg-muted/30 px-3 py-2 text-xs font-semibold",children:"Members"}),n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full min-w-[760px] text-left text-xs",children:[n.jsx("thead",{className:"border-b border-border bg-muted/20 text-muted-foreground",children:n.jsxs("tr",{children:[n.jsx("th",{className:"px-3 py-2 font-medium",children:"Session"}),n.jsx("th",{className:"px-3 py-2 font-medium",children:"Provider / Model"}),n.jsx("th",{className:"px-3 py-2 font-medium",children:"Status"}),n.jsx("th",{className:"px-3 py-2 font-medium",children:"Requests"}),n.jsx("th",{className:"px-3 py-2 font-medium",children:"Errors"}),n.jsx("th",{className:"px-3 py-2 font-medium",children:"First chunk"}),n.jsx("th",{className:"px-3 py-2 font-medium",children:"Tokens"})]})}),n.jsx("tbody",{children:e.map(r=>{const a=t===r.member.id;return n.jsxs(l.Fragment,{children:[n.jsx(l3,{row:r,isExpanded:a,onToggleDetails:o}),n.jsx(c3,{row:r,isExpanded:a})]},r.member.id)})})]})})]})}function l3({row:e,isExpanded:t,onToggleDetails:s}){const o=e.member,r=e.exportMember?.session??null,a=Jk(e),i=r?.inspectorPath??su(o.sessionId),c=e.source!=="evidence",d=r?.requestCount??null,m=r?.errorCount??null,u=r?.tokenUsage.total??null,p=a?.firstChunkMs??null,f=Xf(o.label,o.sessionId),h=Gk(r?.clientUserAgent,a?.userAgent,o.agent),g=r?.clientProjectFolder??null,b=El({userAgent:h,conversationId:o.sessionId,clientProjectFolder:g}),y=Kr(b);return n.jsxs("tr",{className:"border-b border-border last:border-0 hover:bg-muted/20",children:[n.jsxs("td",{className:"max-w-56 px-3 py-2",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[n.jsx(te,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0 text-muted-foreground","aria-label":t?`Hide member ${f}`:`Show member ${f}`,title:t?"Hide member details":"Show member details",onClick:()=>{s(o.id)},children:t?n.jsx(Xe,{className:"size-3.5"}):n.jsx(gt,{className:"size-3.5"})}),y!==null&&n.jsx(Yr,{client:b,className:"size-5"}),c?n.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 ${f}`,title:`Open session ${f}`,children:[n.jsx("span",{className:"min-w-0 truncate",children:f}),n.jsx(Xi,{className:"size-3 shrink-0 text-muted-foreground"})]}):n.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 ${f}`,"aria-label":`Show evidence snapshot for ${f}`,onClick:()=>{s(o.id)},children:[n.jsx("span",{className:"min-w-0 truncate",children:f}),n.jsx(_e,{variant:"outline",className:"shrink-0 border-border bg-muted/30 text-muted-foreground",children:"evidence"})]})]}),n.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:Xr(o.agent)})]}),n.jsx("td",{className:"max-w-52 px-3 py-2",children:n.jsx("span",{className:"block whitespace-normal leading-snug",children:Kk(o)})}),n.jsx("td",{className:"px-3 py-2",children:n.jsx(_e,{variant:"outline",className:Fl(o.status),children:Bl(o.status)})}),n.jsx("td",{className:"px-3 py-2 font-mono",children:d===null?"-":ft(d)}),n.jsx("td",{className:"px-3 py-2 font-mono",children:m===null?"-":ft(m)}),n.jsx("td",{className:"px-3 py-2 font-mono",children:_i(p)}),n.jsx("td",{className:"px-3 py-2 font-mono",children:u===null?"-":ft(u)})]})}function c3({row:e,isExpanded:t}){if(!t)return null;const s=e.member,o=e.exportMember,r=o?.session??null,a=o?.run??null,i=Object.entries(s.metadata);return n.jsx("tr",{className:"border-b border-border bg-muted/10",children:n.jsx("td",{colSpan:7,className:"px-3 pb-4 pt-2",children:n.jsxs("div",{className:"space-y-3 rounded-md border border-border bg-background p-3",children:[n.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4",children:[n.jsx(et,{label:"Source",value:Xk(e.source)}),n.jsx(et,{label:"Member ID",value:s.id,mono:!0}),n.jsx(et,{label:"Session ID",value:s.sessionId,mono:!0}),n.jsx(et,{label:"Run ID",value:a?.id??s.runId??"-",mono:!0}),n.jsx(et,{label:"Created",value:Ns(s.addedAt)}),n.jsx(et,{label:"Updated",value:Ns(s.updatedAt)}),n.jsx(et,{label:"Session created",value:Qc(r?.createdAt??null)}),n.jsx(et,{label:"Session updated",value:Qc(r?.updatedAt??null)})]}),r===null?n.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."}):n.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4",children:[n.jsx(et,{label:"Log coverage",value:r.logCoverage}),n.jsx(et,{label:"Runtime",value:Xr(r.runtimeMode)}),n.jsx(et,{label:"Requests",value:ft(r.requestCount),mono:!0}),n.jsx(et,{label:"Errors",value:ft(r.errorCount),mono:!0}),n.jsx(et,{label:"Input tokens",value:ft(r.tokenUsage.input),mono:!0}),n.jsx(et,{label:"Output tokens",value:ft(r.tokenUsage.output),mono:!0}),n.jsx(et,{label:"Cache read",value:ft(r.tokenUsage.cacheRead),mono:!0}),n.jsx(et,{label:"Total tokens",value:ft(r.tokenUsage.total),mono:!0})]}),n.jsx(d3,{logs:r?.latestLogs??[]}),n.jsx(u3,{entries:i})]})})})}function et({label:e,value:t,mono:s=!1}){return n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:e}),n.jsx("div",{className:P("truncate text-xs text-foreground",s?"font-mono":""),title:t,children:t})]})}function d3({logs:e}){const t=e.slice(0,5);return t.length===0?n.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."}):n.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[n.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"}),n.jsx("div",{className:"divide-y divide-border",children:t.map(s=>{const o=s.sessionLogNumber??s.id;return n.jsxs("div",{className:"grid gap-2 px-3 py-2 text-xs sm:grid-cols-[72px_1fr_88px_88px]",children:[n.jsxs("span",{className:"font-mono text-muted-foreground",title:`Log ID ${String(s.id)}`,children:["#",o]}),n.jsxs("span",{className:"min-w-0 truncate",children:[Xr(s.model)," · ",s.apiFormat," · ",s.path]}),n.jsx("span",{className:"font-mono text-muted-foreground",children:_i(s.firstChunkMs)}),n.jsx("span",{className:"font-mono text-muted-foreground",children:_i(s.latencyMs)})]},s.id)})})]})}function u3({entries:e}){return e.length===0?null:n.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[n.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"}),n.jsx("div",{className:"grid gap-x-3 gap-y-2 p-3 text-xs sm:grid-cols-2",children:e.map(([t,s])=>{const o=Wk(s);return n.jsxs("div",{className:"min-w-0",children:[n.jsx("span",{className:"mr-2 text-muted-foreground",children:t}),n.jsx("span",{className:"font-mono text-foreground",title:o,children:o})]},t)})})]})}const m3=_({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:Ce()}),p3=_({scanId:x().uuid(),providers:V(m3),warnings:V(x()).optional()});_({scanId:x().uuid(),selectionIds:V(x().uuid()).min(1).max(100)});const f3=_({success:Ce().optional(),imported:T().optional(),message:x().optional(),errors:V(x()).optional()}),ed=2e4;function h3({open:e,onOpenChange:t,onImportComplete:s}){const[o,r]=l.useState(!1),[a,i]=l.useState(null),[c,d]=l.useState(null),[m,u]=l.useState([]),[p,f]=l.useState([]),[h,g]=l.useState(new Set),[b,y]=l.useState(!1),[w,v]=l.useState(null),[j,S]=l.useState(null),N=l.useRef(0),C=l.useRef(0),E=l.useCallback(()=>{const k=N.current+1;N.current=k,r(!0),i(null),f([]),d(null),u([]),g(new Set),v(null),S(null),Be("/api/providers/scan",p3,ed,{method:"POST"},M=>`Scan failed (${String(M.status)})`).then(M=>{if(N.current!==k)return;d(M.scanId),u(M.providers),f(M.warnings??[]);const O=new Set;M.providers.forEach(($,K)=>{$.alreadyExists||O.add(K)}),g(O)}).catch(M=>{N.current===k&&i(M instanceof Error?M.message:String(M))}).finally(()=>{N.current===k&&r(!1)})},[]);l.useEffect(()=>{e&&E()},[e,E]),l.useEffect(()=>{e||(N.current+=1,C.current+=1,r(!1),y(!1))},[e]);const A=l.useCallback(k=>{g(M=>{const O=new Set(M);return O.has(k)?O.delete(k):O.add(k),O})},[]),I=l.useCallback(()=>{const k=m.filter((O,$)=>h.has($));if(k.length===0||c===null)return;const M=C.current+1;C.current=M,y(!0),S(null),v(null),Be("/api/providers/import",f3,ed,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scanId:c,selectionIds:k.map(O=>O.selectionId)})},O=>`Import failed (${String(O.status)})`).then(O=>{C.current===M&&(u($=>$.map((K,Q)=>h.has(Q)?{...K,alreadyExists:!0}:K)),g(new Set),O.errors!==void 0&&O.errors.length>0&&O.message!==void 0?v(O.message):v(`Imported ${O.imported??k.length} provider(s)`),s())}).catch(O=>{C.current===M&&S(O instanceof Error?O.message:String(O))}).finally(()=>{C.current===M&&y(!1)})},[m,c,h,s]),R=m.some(k=>!k.alreadyExists);return n.jsx(qt,{open:e,onOpenChange:t,children:n.jsxs(Ht,{className:"max-w-xl max-h-[80vh] overflow-hidden flex flex-col",children:[n.jsxs(Yt,{children:[n.jsx(Jt,{children:"Import from External Tools"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Detect provider configurations from Claude Code, OpenCode, and MiMo Code."})]}),n.jsxs("div",{className:"flex-1 overflow-y-auto space-y-3",children:[o&&n.jsxs("div",{className:"flex items-center justify-center py-8 gap-2 text-muted-foreground",children:[n.jsx(Ue,{className:"size-4 animate-spin"}),n.jsx("span",{className:"text-sm",children:"Scanning for external providers..."})]}),a!==null&&n.jsxs("div",{className:"flex items-center gap-2 text-destructive text-sm py-4",children:[n.jsx(gs,{className:"size-4"}),a]}),!o&&a===null&&m.length===0&&n.jsxs("p",{className:"text-sm text-muted-foreground py-8 text-center",children:["No external provider configurations found.",n.jsx("br",{}),n.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,M)=>n.jsxs("label",{className:`flex items-start gap-3 p-3 border rounded-md ${k.alreadyExists?"":"cursor-pointer hover:bg-muted/50"}`,children:[!k.alreadyExists&&n.jsx("input",{type:"checkbox",checked:h.has(M),disabled:b,onChange:()=>A(M),className:"mt-0.5 size-4"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(Yr,{client:k.sourceTool,className:"size-7 rounded-[8px]"}),k.alreadyExists&&n.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Already added"})]}),n.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`:""]}),n.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:k.format==="anthropic"?k.anthropicBaseUrl:k.openaiResponsesBaseUrl!==""?k.openaiResponsesBaseUrl:k.openaiBaseUrl}),n.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 font-mono",children:k.apiKeyHint})]})]},k.selectionId)),p.length>0&&n.jsx("div",{className:"text-xs text-muted-foreground space-y-1 border-t pt-2",children:p.map((k,M)=>n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx(gs,{className:"size-3"}),k]},M))}),w!==null&&n.jsx("div",{className:"border-t pt-2 text-sm text-status-success",children:w}),j!==null&&n.jsx("div",{className:"text-sm text-destructive border-t pt-2",children:j})]}),n.jsxs("div",{className:"flex items-center justify-between pt-3 border-t",children:[n.jsxs(te,{variant:"outline",size:"sm",onClick:E,disabled:o,children:[n.jsx(Ue,{className:`size-3 mr-1 ${o?"animate-spin":""}`}),"Rescan"]}),n.jsxs(te,{size:"sm",onClick:I,disabled:!R||h.size===0||b,children:[n.jsx(to,{className:"size-3 mr-1"}),b?"Importing...":`Import Selected (${h.size})`]})]})]})})}const Zf=_({id:x().min(1).max(oi),aliases:V(x().max(oi)).max(bn).optional().default([]),contextWindow:T().int().positive().optional(),outputLimit:T().int().positive().optional(),sourceUrl:x().optional()}),x3=_({name:x().min(1).optional(),aliases:V(x()).max(bn).optional().default([]),baseUrls:V(x()).max(bn).optional().default([]),models:V(Zf).min(1).max(bn)});_({version:T().int().positive().optional(),updatedAt:x().optional(),providers:V(x3).max(bn).optional().default([]),models:V(Zf).max(bn).optional().default([])});function td(e){return e.trim().toLowerCase().replace(/\s+/g,"-")}function g3(e){const t=e.models.filter(s=>s.trim()!=="");return t.length>0?t:e.model!==void 0&&e.model.trim()!==""?[e.model]:[]}function Ul(e,t){const s=td(t);return(e.modelMetadata??[]).find(r=>td(r.model)===s)??null}function b3(e){const t=g3(e);return t.length===0?!1:t.every(s=>{const o=Ul(e,s);return o!==null&&o.contextWindow!==void 0})}function v3(e,t){if(e===null)return null;for(const s of t){const o=Ul(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 Zs(e){return Object.prototype.hasOwnProperty.call(e,"success")}function Zr(e){return Object.prototype.hasOwnProperty.call(e,"notConfigured")}function yt(e){return e!==void 0&&e!==""}function ot(e){return e!==void 0&&e.trim()!==""}function Eo(e){return e!=null}function hs(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function Qf(e){return e>=10?`${e.toFixed(0)}/s`:`${e.toFixed(1)}/s`}function eh(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 y3(e){return e.firstChunkMs!==void 0&&e.firstChunkMs!==null?hs(e.firstChunkMs):e.latencyMs!==void 0?hs(e.latencyMs):e.totalStreamMs!==void 0&&e.totalStreamMs!==null?hs(e.totalStreamMs):e.tokensPerSecond!==void 0&&e.tokensPerSecond!==null&&e.tokensPerSecond>0?Qf(e.tokensPerSecond):null}function w3(e){return Zr(e)?{tone:"quiet",label:"N/A",metric:null,hasDetails:!1}:Zs(e)?e.success?{tone:"success",label:"Pass",metric:y3(e),hasDetails:!0}:{tone:"failure",label:eh(e.error?.type??"unknown"),metric:null,hasDetails:!0}:{tone:"pending",label:"Running",metric:null,hasDetails:!1}}function j3(e,t){if(t===void 0)return[];const s=[];return yt(e.anthropicBaseUrl)&&s.push(t.anthropic),yt(e.openaiBaseUrl)&&s.push(t.openaiChat),yt(e.openaiResponsesBaseUrl)&&s.push(t.openaiResponses),s}function S3(e,t){const s={total:0,passed:0,failed:0,testing:0};for(const o of j3(e,t))for(const r of[o.nonStreaming,o.streaming])Zr(r)||(s.total+=1,Zs(r)?r.success?s.passed+=1:s.failed+=1:s.testing+=1);return s}function nd(e){if(e===void 0)return;const t=Object.entries(e).map(([s,o])=>`${s}: ${o}`);return t.length===0?void 0:t.join(`
|
|
58
|
-
`)}function un({title:e,children:t}){return n.jsxs("section",{className:"space-y-1.5",children:[n.jsx("h4",{className:"text-xs font-medium text-foreground/80",children:e}),t]})}function En({value:e}){return n.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 Rn({label:e,value:t}){return n.jsxs("div",{className:"min-w-0 rounded-md bg-muted/35 px-3 py-2",children:[n.jsx("dt",{className:"text-[10px] text-muted-foreground",children:e}),n.jsx("dd",{className:"mt-1 truncate font-mono text-xs font-semibold text-foreground",title:t,children:t})]})}function N3({result:e}){const t=Eo(e.inputTokens)||Eo(e.outputTokens),s=Eo(e.cacheCreationInputTokens)||Eo(e.cacheReadInputTokens);return ot(e.model)||t||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?n.jsxs("dl",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4",children:[ot(e.model)&&n.jsx(Rn,{label:"Model",value:e.model}),e.latencyMs!==void 0&&n.jsx(Rn,{label:"Latency",value:hs(e.latencyMs)}),e.firstChunkMs!==void 0&&e.firstChunkMs!==null&&n.jsx(Rn,{label:"First chunk",value:hs(e.firstChunkMs)}),e.totalStreamMs!==void 0&&e.totalStreamMs!==null&&n.jsx(Rn,{label:"Stream total",value:hs(e.totalStreamMs)}),e.tokensPerSecond!==void 0&&e.tokensPerSecond!==null&&e.tokensPerSecond>0&&n.jsx(Rn,{label:"Token rate",value:`${Qf(e.tokensPerSecond)} tok`}),t&&n.jsx(Rn,{label:"Tokens in / out",value:`${String(e.inputTokens??0)} / ${String(e.outputTokens??0)}`}),s&&n.jsx(Rn,{label:"Cache create / read",value:`${String(e.cacheCreationInputTokens??0)} / ${String(e.cacheReadInputTokens??0)}`})]}):null}function C3({result:e}){const t=e.debug,s=t?.requestUrl,o=t?.requestMethod??"POST",r=nd(t?.requestHeaders),a=nd(t?.responseHeaders),i=t?.responseStatus===void 0?void 0:`${String(t.responseStatus)}${ot(t.responseStatusText)?` ${t.responseStatusText}`:""}`,c=t?.responseBody??e.rawResponse;return ot(e.error?.hint)||ot(e.error?.details)||ot(s)||r!==void 0||ot(t?.requestBody)||ot(i)||a!==void 0||ot(c)?n.jsxs("div",{className:"space-y-4 border-t border-border/70 pt-4 text-xs text-muted-foreground",children:[ot(e.error?.hint)&&n.jsx(un,{title:"Hint",children:n.jsx("p",{className:"break-words text-foreground/80",children:e.error.hint})}),ot(e.error?.details)&&n.jsx(un,{title:"Error details",children:n.jsx(En,{value:e.error.details})}),ot(s)&&n.jsx(un,{title:"Request",children:n.jsx(En,{value:`${o} ${s}`})}),r!==void 0&&n.jsx(un,{title:"Request headers",children:n.jsx(En,{value:r})}),ot(t?.requestBody)&&n.jsx(un,{title:"Request body",children:n.jsx(En,{value:t.requestBody})}),ot(i)&&n.jsx(un,{title:"Response status",children:n.jsx(En,{value:i})}),a!==void 0&&n.jsx(un,{title:"Response headers",children:n.jsx(En,{value:a})}),ot(c)&&n.jsx(un,{title:"Response body",children:n.jsx(En,{value:c})})]}):null}function k3({result:e,probeLabel:t,children:s}){const o=e.error?.message??"Connection failed";return n.jsxs(qt,{children:[n.jsx(io,{asChild:!0,children:s}),n.jsxs(Ht,{className:"max-h-[82vh] max-w-2xl gap-0 overflow-hidden p-0",children:[n.jsxs(Yt,{className:"border-b border-border/70 px-5 py-4 pr-12",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[e.success?n.jsx(eo,{className:"size-4 text-status-success"}):n.jsx(gs,{className:"size-4 text-status-danger"}),n.jsx(Jt,{className:"text-base",children:t})]}),n.jsx(lo,{children:e.success?"Connection probe passed.":o})]}),n.jsxs("div",{className:"space-y-4 overflow-y-auto p-5",children:[!e.success&&n.jsxs("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-2 text-sm text-status-danger",children:[n.jsx("div",{className:"font-medium",children:eh(e.error?.type??"unknown")}),n.jsx("div",{className:"mt-1 break-words text-xs text-muted-foreground",children:o})]}),n.jsx(N3,{result:e}),n.jsx(C3,{result:e})]})]})]})}function _3(e){const t="size-3 shrink-0";switch(e){case"timeout":return n.jsx(en,{className:t});case"network_unreachable":return n.jsx(q1,{className:t});case"connection_refused":return n.jsx(V1,{className:t});case"auth_failed":return n.jsx(Fg,{className:t});case"rate_limited":return n.jsx(Zi,{className:t});case"server_error":return n.jsx(_1,{className:t});case"invalid_response":return n.jsx(V0,{className:t});case"unknown":return n.jsx(gs,{className:t})}}const T3={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 sd({result:e,probeLabel:t}){const s=w3(e),o=Zr(e)?n.jsx(Pu,{className:"size-3 shrink-0"}):Zs(e)?e.success?n.jsx(eo,{className:"size-3 shrink-0"}):_3(e.error?.type??"unknown"):n.jsx(tr,{className:"size-3 shrink-0 animate-spin"}),r=n.jsxs(n.Fragment,{children:[o,n.jsx("span",{className:"min-w-0 truncate",children:s.label}),s.metric!==null&&n.jsx("span",{className:"ml-auto shrink-0 font-mono text-[10px] opacity-75",children:s.metric})]}),a=P("inline-flex h-7 w-full min-w-0 items-center gap-1.5 rounded-md px-2 text-left text-xs transition-colors",T3[s.tone]);return Zs(e)&&s.hasDetails?n.jsx(k3,{result:e,probeLabel:t,children:n.jsx("button",{type:"button",className:a,"aria-label":`Open ${t} result: ${s.label}`,children:r})}):n.jsx("div",{className:a,children:r})}function od({label:e}){return n.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:[n.jsx(Pu,{className:"size-3 shrink-0"}),n.jsx("span",{className:"truncate",children:e})]})}function Ia({label:e,results:t,configured:s=!0}){return n.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:[n.jsx("div",{className:"min-w-0 truncate text-xs font-medium text-foreground/85",title:e,children:e}),s&&t!==void 0?n.jsx(sd,{result:t.nonStreaming,probeLabel:`${e} non-stream`}):n.jsx(od,{label:s?"Not tested":"Off"}),s&&t!==void 0?n.jsx(sd,{result:t.streaming,probeLabel:`${e} stream`}):n.jsx(od,{label:s?"Not tested":"Off"})]})}function th({provider:e,results:t}){const s=yt(e.anthropicBaseUrl),o=yt(e.openaiBaseUrl),r=yt(e.openaiResponsesBaseUrl);return!s&&!o&&!r?n.jsx("div",{className:"text-xs text-muted-foreground",children:"No testable endpoint configured."}):n.jsx("div",{className:"min-w-0 overflow-x-auto rounded-md border border-border/70",children:n.jsxs("div",{className:"min-w-[20rem]",children:[n.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:[n.jsx("span",{children:"Protocol"}),n.jsx("span",{children:"Non-stream"}),n.jsx("span",{children:"Stream"})]}),s&&n.jsx(Ia,{label:"Anthropic",results:t?.anthropic}),o&&n.jsx(Ia,{label:"OpenAI Chat",results:t?.openaiChat}),r&&n.jsx(Ia,{label:"OpenAI Responses",results:t?.openaiResponses})]})})}function E3(e){const t={total:0,passed:0,failed:0,testing:0};for(const s of[e.nonStreaming,e.streaming])Zr(s)||(t.total+=1,Zs(s)?s.success?t.passed+=1:t.failed+=1:t.testing+=1);return t}function Pa({label:e,results:t}){const s=E3(t),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 n.jsxs("span",{className:P("rounded border px-1.5 py-0.5 text-[10px]",o),children:[e," ",r]})}function R3({provider:e,modelName:t,results:s,expanded:o,onToggle:r}){return n.jsxs("div",{className:"min-w-0",children:[n.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?n.jsx(Xe,{className:"size-3.5 shrink-0 text-muted-foreground"}):n.jsx(gt,{className:"size-3.5 shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-[8rem] flex-1 truncate text-xs font-medium",title:t,children:t}),n.jsxs("span",{className:"flex flex-wrap items-center justify-end gap-1",children:[yt(e.anthropicBaseUrl)&&n.jsx(Pa,{label:"A",results:s.anthropic}),yt(e.openaiBaseUrl)&&n.jsx(Pa,{label:"Chat",results:s.openaiChat}),yt(e.openaiResponsesBaseUrl)&&n.jsx(Pa,{label:"Resp",results:s.openaiResponses})]})]}),o&&n.jsx("div",{className:"px-2 pb-3",children:n.jsx(th,{provider:e,results:s})})]})}function M3({provider:e,testResults:t}){const s=Object.entries(t.models??{}),[o,r]=l.useState(!1),[a,i]=l.useState(null);return s.length===0?null:n.jsxs("section",{className:"space-y-2",children:[n.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?n.jsx(Xe,{className:"size-3.5"}):n.jsx(gt,{className:"size-3.5"}),"Model probes",n.jsx("span",{className:"rounded bg-muted/50 px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground",children:s.length})]}),o&&n.jsx("div",{className:"min-w-0 divide-y divide-border/60 rounded-md border border-border/70",children:s.map(([c,d])=>n.jsx(R3,{provider:e,modelName:c,results:d,expanded:a===c,onToggle:()=>i(m=>m===c?null:c)},c))})]})}function A3({provider:e,testResults:t,isTesting:s}){const o=yt(e.anthropicBaseUrl)||yt(e.openaiBaseUrl)||yt(e.openaiResponsesBaseUrl),r=S3(e,t);return s?n.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:[n.jsx(tr,{className:"size-3 animate-spin"}),"Testing"]}):o?t===void 0||r.total===0?n.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?n.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:[n.jsx(gs,{className:"size-3"}),r.failed," failed"]}):r.testing>0||r.passed<r.total?n.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]}):n.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:[n.jsx(eo,{className:"size-3"}),r.passed,"/",r.total]}):n.jsx("span",{className:"rounded border border-border/70 bg-muted/20 px-2 py-1 text-xs text-muted-foreground",children:"No endpoint"})}const I3={deepseek:"https://api-docs.deepseek.com/zh-cn/"};function La(e){return e!==void 0&&e!==""}function Oa({label:e}){return n.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:[n.jsx(eo,{className:"size-3"}),e]})}function P3({provider:e}){const t=La(e.anthropicBaseUrl),s=La(e.openaiBaseUrl),o=La(e.openaiResponsesBaseUrl);return!t&&!s&&!o?n.jsx("div",{className:"text-xs text-muted-foreground",children:"Test requires at least one configured endpoint."}):n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5 text-xs text-muted-foreground",children:[t&&n.jsx(Oa,{label:"Anthropic"}),s&&n.jsx(Oa,{label:"OpenAI Chat"}),o&&n.jsx(Oa,{label:"OpenAI Responses"})]})}function L3(e){const t=e.models??[];if(t.length===0)return"No models configured";const s=t.slice(0,2).join(", "),o=t.length-2;return o>0?`${s} +${o} more`:s}function O3({provider:e,model:t}){const s=Ul(e,t),o=z3(s?.sourceUrl);return n.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:[n.jsx("span",{children:t}),s!==null&&s.contextWindow!==void 0&&n.jsx("span",{className:"font-mono text-foreground/80",children:ru(s.contextWindow)}),o!==null&&n.jsx(Ts,{children:n.jsxs(dt,{children:[n.jsx(ut,{asChild:!0,children:n.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})}),n.jsx(mt,{children:o.title})]})})]})}function D3(e){const t=Date.now(),s=new Date(e).getTime(),o=t-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 z3(e){if(e===void 0||e.trim()==="")return null;try{const t=new URL(e);if(t.protocol!=="https:"&&t.protocol!=="http:")return null;const s=t.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 $3({provider:e,testResults:t,isTesting:s,testingTimeLeft:o,isHighlighted:r,onEdit:a,onDelete:i,onTest:c,onRefreshMetadata:d,isRefreshingMetadata:m=!1}){const[u,p]=l.useState(!1),f=e.apiDocsUrl??Object.entries(I3).find(([v])=>e.name.toLowerCase().includes(v))?.[1],h=b3(e),g=e.modelMetadataUrl!==void 0&&e.modelMetadataUrl.trim()!=="",b=g?"Refresh":"Import defaults",y=s??!1,w=e.source==="company"?n.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"?n.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 n.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:[n.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[n.jsxs("div",{className:"min-w-0 space-y-1",children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[n.jsx("span",{className:"font-medium leading-snug",children:e.name}),w]}),n.jsx("div",{className:"text-xs leading-snug text-muted-foreground",children:L3(e)})]}),n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[n.jsx(A3,{provider:e,testResults:t,isTesting:y}),f!==void 0&&n.jsxs("a",{href:f,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:[n.jsx(Xi,{className:"size-3"}),n.jsx("span",{className:"sr-only",children:"Docs"})]})]})]}),n.jsxs("div",{className:"flex flex-col gap-2 text-xs text-muted-foreground sm:flex-row sm:items-center sm:justify-between",children:[n.jsx(P3,{provider:e}),t?.testedAt!==void 0&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx(en,{className:"size-3"}),D3(t.testedAt)]})]}),!h&&n.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:[n.jsx("span",{children:"Context window metadata missing"}),n.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[n.jsxs(te,{type:"button",variant:"outline",size:"sm",onClick:()=>d?.(e.id),className:"h-6 gap-1 px-2 text-xs",disabled:m,children:[n.jsx(tr,{className:`size-3 ${m?"animate-spin":""}`}),b]}),!g&&n.jsx(te,{type:"button",variant:"ghost",size:"sm",onClick:()=>a(e),className:"h-6 px-2 text-xs",children:"Set URL"})]})]}),u&&n.jsxs("div",{className:"space-y-3 border-t border-border/60 pt-3",children:[n.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[n.jsx(eo,{className:"size-3.5 text-status-success"}),n.jsx("span",{children:"API key configured"})]}),e.models!==void 0&&e.models.length>0&&n.jsx("div",{className:"flex flex-wrap gap-1",children:e.models.map(v=>n.jsx(O3,{provider:e,model:v},v))}),n.jsxs("section",{className:"space-y-2",children:[n.jsx("h4",{className:"text-xs font-medium text-foreground/80",children:"Connection probes"}),n.jsx(th,{provider:e,results:t})]}),t!==void 0&&n.jsx(M3,{provider:e,testResults:t})]}),n.jsxs("div",{className:"flex flex-col gap-2 border-t pt-1 sm:flex-row sm:items-center sm:justify-between",children:[n.jsxs("button",{type:"button",onClick:()=>p(v=>!v),className:"inline-flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground","aria-expanded":u,children:[u?n.jsx(Xe,{className:"size-3"}):n.jsx(gt,{className:"size-3"}),"Details"]}),n.jsxs("div",{className:"flex gap-2",children:[c!==void 0&&n.jsxs(te,{variant:"outline",size:"sm",onClick:()=>c(e.id),className:"text-xs h-7 gap-1",disabled:y,children:[n.jsx(tr,{className:`size-3 ${y?"animate-spin":""}`}),y?o!==void 0?`Testing (${o}s)`:"Testing...":"Test"]}),n.jsxs(te,{variant:"outline",size:"sm",onClick:()=>a(e),className:"text-xs h-7 gap-1",disabled:y,children:[n.jsx(Lu,{className:"size-3"}),"Edit"]}),n.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:[n.jsx(yn,{className:"size-3"}),"Delete"]})]})]})]})}const xs="/v1/chat/completions",Ti="/v1/responses",F3="/v1/messages";function B3(e,t){const s=e.endsWith("/")?e.slice(0,-1):e,o=nh(t),r=t.indexOf("?"),a=r>=0?t.slice(r):"";return o!==""&&s.endsWith(o)?s+a:oh(s)&&sh(t)||s.endsWith("/v1")&&t.startsWith("/v1/")?s+t.slice(3):s+t}function U3(e,t,s={}){const o=e.trim().replace(/\/+$/,""),r=nh(t),a=B3(o,t),i=[];return r!==""&&o.endsWith(r)?i.push({severity:"info",message:"This already includes the exact endpoint; no duplicate suffix will be appended."}):oh(o)&&sh(t)?i.push({severity:"info",message:"Zhipu bases already include the API version; only /chat/completions is appended."}):o.endsWith("/v1")&&t.startsWith("/v1/")&&i.push({severity:"info",message:"Base URL already ends with /v1; the suffix will not repeat /v1."}),rd(r)&&H3(o)&&i.push({severity:"warning",message:"This looks like a Chat Completions endpoint, so Responses would append after it."}),q3(r)&&V3(o)&&i.push({severity:"warning",message:"This looks like a Responses endpoint, so Chat Completions would append after it."}),rd(r)&&W3(o,s.providerName)&&i.push({severity:"warning",message:"DeepSeek's official API does not currently expose OpenAI Responses."}),{finalUrl:a,diagnostics:i}}function nh(e){return e.split("?")[0]??e}function sh(e){return e===xs||e.startsWith(`${xs}?`)||e.startsWith(`${xs}/`)}function q3(e){return e===xs||e.startsWith(`${xs}/`)}function rd(e){return e===Ti||e.startsWith(`${Ti}/`)}function H3(e){return e.toLowerCase().endsWith("/chat/completions")}function V3(e){return e.toLowerCase().endsWith("/responses")}function W3(e,t){const s=t?.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 oh(e){try{const t=new URL(e),s=t.pathname.replace(/\/+$/,"");return t.hostname==="open.bigmodel.cn"&&(s==="/api/paas/v4"||s==="/api/coding/paas/v4")}catch{return!1}}function Da(e){return e!==void 0&&e.trim()!==""}function ad(e){const t=Da(e?.anthropicBaseUrl),s=Da(e?.openaiBaseUrl),o=Da(e?.openaiResponsesBaseUrl);return{anthropic:t,openai:s||o,openaiChat:s,openaiResponses:o}}function za(e,t,s){if(!e)return s?"":void 0;const o=t.trim();return o===""?void 0:o}const id=["zhipu","zhipuai","bigmodel","z.ai","zai","glm"],ld=["zhipu coding","glm coding","bigmodel coding","z.ai coding","zai coding"],Ro=F3,Mo=xs,Ao=Ti,G3={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"}},cd=["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"],dd=["qwen3.6-plus","qwen3.7-max"],ud=["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"],Ei="__unset__",xr="__custom__",rh=[{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 Mn(){return{contextWindow:"",contextWindowMode:"unset",outputLimit:""}}function md(e){return e.trim().toLowerCase().replace(/\s+/g,"-")}function ah(e,t){const s=md(t);return e?.modelMetadata?.find(o=>md(o.model)===s)??null}function ih(e){const t=Xo(e);if(t===null)return null;for(const s of rh)if(Xo(s.value)===t)return s.value;return null}function K3(e){return e.trim()===""?"unset":ih(e)!==null?"preset":"custom"}function Y3(e){switch(e.contextWindowMode){case"unset":return Ei;case"custom":return xr;case"preset":return ih(e.contextWindow)??xr}}function $a(e){const t=e.trim().replaceAll(",","");if(t==="")return{amount:"",unit:"K"};const s=/^(\d+(?:\.\d+)?)\s*([kKmM])?$/.exec(t);if(s===null)return{amount:t,unit:"K"};const o=s[1];if(o===void 0)return{amount:t,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:t,unit:"K"}}}function pd(e,t){const s=e.trim();if(s==="")return"";switch(t){case"K":return`${s}K`;case"M":return`${s}M`;case"tokens":return s}}function fd(e,t){return t.map(s=>{const o=ah(e,s),r=o?.contextWindow!==void 0?Yh(o.contextWindow):"";return{contextWindow:r,contextWindowMode:K3(r),outputLimit:o?.outputLimit?.toString()??""}})}function hd(e){const t=e.trim();if(t==="")return null;const s=Number(t);return!Number.isInteger(s)||s<=0?null:s}function ss(e,t){if(e===void 0)return"";const s=e.trim(),o=s.replace(/\/+$/,"");return o.endsWith(t)?o.slice(0,-t.length).replace(/\/+$/,""):s}function J3(e,t,s){const o=e.trim();return o===""?null:U3(o,t,{providerName:s})}function Fa({baseUrl:e,endpoint:t,providerName:s}){const o=J3(e,t,s);return o===null?null:n.jsxs("div",{className:"border border-border bg-muted/40 rounded-md px-3 py-2 text-xs",children:[n.jsx("div",{className:"text-muted-foreground",children:"Final URL"}),n.jsx("div",{className:"break-all font-mono text-foreground",children:o.finalUrl}),o.diagnostics.length>0&&n.jsx("div",{className:"mt-2 space-y-1",children:o.diagnostics.map(r=>n.jsx("div",{className:r.severity==="warning"?"text-status-watch":"text-muted-foreground",children:r.message},`${r.severity}:${r.message}`))})]})}function X3({provider:e,onSubmit:t,onCancel:s}){const o=ad(e),[r,a]=l.useState(e?.name??""),[i,c]=l.useState(""),[d,m]=l.useState(!1),[u,p]=l.useState(!1),f=e?.models,[h,g]=l.useState(f!==void 0&&f.length>0?f:[""]),[b,y]=l.useState(()=>fd(e,f!==void 0&&f.length>0?f:[""])),[w,v]=l.useState(o.anthropic),[j,S]=l.useState(o.openai),[N,C]=l.useState(o.openaiChat),[E,A]=l.useState(o.openaiResponses),[I,R]=l.useState(ss(e?.anthropicBaseUrl,Ro)),[k,M]=l.useState(ss(e?.openaiBaseUrl,Mo)),[O,$]=l.useState(ss(e?.openaiResponsesBaseUrl,Ao)),[K,Q]=l.useState(e?.apiDocsUrl??""),[z,H]=l.useState(e?.modelMetadataUrl??""),[ee,U]=l.useState(e?.source),[Z,fe]=l.useState({}),[je,he]=l.useState(!1),[oe,L]=l.useState(null),J=l.useRef([]);l.useEffect(()=>{if(oe===null)return;const D=oe;function Y(de){if(!(de.target instanceof Node))return;const Ne=J.current[D];Ne!=null&&!Ne.contains(de.target)&&L(null)}return document.addEventListener("mousedown",Y),()=>document.removeEventListener("mousedown",Y)},[oe]);const[Se,Te]=l.useState(!1),[ge,le]=l.useState(!1),[ce,Pe]=l.useState(!1),Re=r.toLowerCase().includes("minimax"),$e=r.toLowerCase().includes("alibaba"),lt=[...id,...ld].some(D=>r.toLowerCase().includes(D)),He=Re?cd:lt?ud:$e?dd:[],Le=e?.modelMetadata?.some(D=>D.contextWindow!==void 0)??!1;function We(){Tt(i).then(D=>{D&&(p(!0),setTimeout(()=>p(!1),2e3))})}l.useEffect(()=>{if(e){a(e.name),c(""),m(!1);const D=(e.models?.length??0)>0?e.models:[""];g(D),y(fd(e,D));const Y=ad(e);v(Y.anthropic),S(Y.openai),C(Y.openaiChat),A(Y.openaiResponses),R(ss(e.anthropicBaseUrl,Ro)),M(ss(e.openaiBaseUrl,Mo)),$(ss(e.openaiResponsesBaseUrl,Ao)),Q(e.apiDocsUrl??""),H(e.modelMetadataUrl??""),U(e.source),Te(!1),le(!1),Pe(!1)}},[e]),l.useEffect(()=>{const D=r.toLowerCase();for(const[Y,de]of Object.entries(G3))if(D.includes(Y)){de.anthropicBaseUrl!==void 0&&!Se&&R(de.anthropicBaseUrl),de.openaiBaseUrl!==void 0&&!ge&&M(de.openaiBaseUrl),de.openaiResponsesBaseUrl!==void 0&&!ce&&$(de.openaiResponsesBaseUrl),de.apiDocsUrl!==void 0&&!K&&Q(de.apiDocsUrl),Y==="minimax"&&h.length===1&&h[0]===""&&g([cd[0]??""]),Y==="alibaba"&&h.length===1&&h[0]===""&&g([dd[0]??""]),(id.includes(Y)||ld.includes(Y))&&h.length===1&&h[0]===""&&g([ud[0]??""]);break}},[r]);function Ke(){const D={};return r.trim()||(D.name="Name is required"),e===void 0&&!i.trim()&&(D.apiKey="API key is required"),(h.length===0||h.every(Y=>!Y.trim()))&&(D.models="At least one model is required"),!w&&!j&&(D.capabilities="Select at least one API capability"),j&&!N&&!E&&(D.openaiCapabilities="Select Chat Completions, Responses, or both"),w&&(I.trim()===""?D.anthropicBaseUrl="Anthropic base URL is required":Ze(I.trim())||(D.anthropicBaseUrl="Invalid URL format")),j&&N&&(k.trim()===""?D.openaiBaseUrl="OpenAI Chat base URL is required":Ze(k.trim())||(D.openaiBaseUrl="Invalid URL format")),j&&E&&(O.trim()===""?D.openaiResponsesBaseUrl="OpenAI Responses base URL is required":Ze(O.trim())||(D.openaiResponsesBaseUrl="Invalid URL format")),z.trim()&&!Ze(z.trim())&&(D.modelMetadataUrl="Invalid URL format"),b.forEach((Y,de)=>{const Ne=Xo(Y.contextWindow),F=hd(Y.outputLimit);Y.contextWindow.trim()!==""&&Ne===null&&(D[`modelMetadata.${de}.contextWindow`]="Context window must be a positive number, optionally using K or M"),Y.outputLimit.trim()!==""&&F===null&&(D[`modelMetadata.${de}.outputLimit`]="Output limit must be a positive integer"),Ne!==null&&F!==null&&F>Ne&&(D[`modelMetadata.${de}.outputLimit`]="Output limit should not exceed context window")}),fe(D),Object.keys(D).length===0}function Ze(D){try{return new URL(D),!0}catch{return!1}}function rt(D,Y){g(de=>{const Ne=[...de];return Ne[D]=Y,Ne})}function nt(D,Y){y(de=>{const Ne=[...de];return Ne[D]={...Ne[D]??Mn(),...Y},Ne})}function q(D,Y){switch(Y){case Ei:nt(D,{contextWindow:"",contextWindowMode:"unset"});return;case xr:{const de=b[D]??Mn();nt(D,{contextWindow:de.contextWindow,contextWindowMode:"custom"});return}default:nt(D,{contextWindow:Y,contextWindowMode:"preset"});return}}function se(D,Y){const de=b[D]??Mn(),Ne=$a(de.contextWindow);nt(D,{contextWindow:pd(Y,Ne.unit),contextWindowMode:"custom"})}function xe(D,Y){const de=b[D]??Mn(),Ne=$a(de.contextWindow);switch(Y){case"K":case"M":case"tokens":nt(D,{contextWindow:pd(Ne.amount,Y),contextWindowMode:"custom"});return;default:return}}function pe(D){g(Y=>Y.filter((de,Ne)=>Ne!==D)),y(Y=>Y.filter((de,Ne)=>Ne!==D))}function we(){g(D=>[...D,""]),y(D=>[...D,Mn()])}function Oe(){const D=new Date().toISOString(),Y=[];return h.forEach((de,Ne)=>{const F=de.trim();if(F==="")return;const W=b[Ne]??Mn(),X=Xo(W.contextWindow),ne=hd(W.outputLimit);if(X===null&&ne===null)return;const Ee=ah(e,F);if(Ee!==null&&Ee.contextWindow===(X??void 0)&&Ee.outputLimit===(ne??void 0)){Y.push({...Ee,model:F});return}const ie={model:F,source:"manual",updatedAt:D};X!==null&&(ie.contextWindow=X),ne!==null&&(ie.outputLimit=ne),Y.push(ie)}),Y.length>0?Y:e?.modelMetadata!==void 0?[]:void 0}function ze(D){if(D.preventDefault(),!Ke())return;he(!0);const Y=e!==void 0;try{t({name:r.trim(),apiKey:i.trim(),models:h.map(de=>de.trim()).filter(de=>de!==""),anthropicBaseUrl:za(w,I,Y),openaiBaseUrl:za(j&&N,k,Y),openaiResponsesBaseUrl:za(j&&E,O,Y),apiDocsUrl:K.trim()||void 0,modelMetadataUrl:z.trim()||void 0,modelMetadata:Oe(),source:ee})}finally{he(!1)}}return n.jsxs("form",{onSubmit:ze,className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsxs("label",{htmlFor:"provider-name",className:"text-sm font-medium",children:["Name ",n.jsx("span",{className:"text-destructive",children:"*"})]}),n.jsx("input",{id:"provider-name",type:"text",value:r,onChange:D=>a(D.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"}),Z.name!==void 0&&n.jsx("p",{className:"text-xs text-destructive",children:Z.name})]}),n.jsxs("fieldset",{className:"space-y-3",children:[n.jsxs("legend",{className:"text-sm font-medium",children:["Capabilities ",n.jsx("span",{className:"text-destructive",children:"*"})]}),n.jsxs("div",{className:"divide-y divide-border overflow-hidden rounded-md border border-border",children:[n.jsxs("div",{className:j?"bg-primary/[0.04] px-3 py-3":"px-3 py-3",children:[n.jsxs("label",{htmlFor:"provider-capability-openai",className:"flex cursor-pointer items-start gap-3",children:[n.jsx("input",{id:"provider-capability-openai",type:"checkbox",checked:j,onChange:D=>S(D.target.checked),className:"mt-0.5 size-4 shrink-0 accent-primary"}),n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"block text-sm font-medium",children:"OpenAI"}),n.jsx("span",{className:"block text-xs text-muted-foreground",children:"Chat Completions and Responses"})]})]}),j&&n.jsxs("div",{className:"ml-7 mt-3 flex flex-wrap gap-x-5 gap-y-2 border-t border-border/70 pt-3",children:[n.jsxs("label",{htmlFor:"provider-capability-openai-chat",className:"flex cursor-pointer items-center gap-2 text-sm",children:[n.jsx("input",{id:"provider-capability-openai-chat",type:"checkbox",checked:N,onChange:D=>C(D.target.checked),className:"size-4 shrink-0 accent-primary"}),"Chat Completions"]}),n.jsxs("label",{htmlFor:"provider-capability-openai-responses",className:"flex cursor-pointer items-center gap-2 text-sm",children:[n.jsx("input",{id:"provider-capability-openai-responses",type:"checkbox",checked:E,onChange:D=>A(D.target.checked),className:"size-4 shrink-0 accent-primary"}),"Responses"]})]}),Z.openaiCapabilities!==void 0&&j&&n.jsx("p",{className:"ml-7 mt-2 text-xs text-destructive",children:Z.openaiCapabilities})]}),n.jsxs("label",{htmlFor:"provider-capability-anthropic",className:`flex cursor-pointer items-start gap-3 px-3 py-3 ${w?"bg-primary/[0.04]":""}`,children:[n.jsx("input",{id:"provider-capability-anthropic",type:"checkbox",checked:w,onChange:D=>v(D.target.checked),className:"mt-0.5 size-4 shrink-0 accent-primary"}),n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"block text-sm font-medium",children:"Anthropic"}),n.jsx("span",{className:"block text-xs text-muted-foreground",children:"Messages"})]})]})]}),Z.capabilities!==void 0&&n.jsx("p",{className:"text-xs text-destructive",children:Z.capabilities})]}),(w||j&&(N||E))&&n.jsxs("section",{className:"space-y-5 border-l border-border pl-4","aria-label":"API endpoints",children:[n.jsx("h3",{className:"text-sm font-medium",children:"Endpoint Configuration"}),w&&n.jsxs("div",{className:"space-y-2",children:[n.jsxs("label",{htmlFor:"provider-anthropic-base-url",className:"text-sm font-medium",children:["Anthropic Messages Base URL ",n.jsx("span",{className:"text-destructive",children:"*"})]}),n.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:[n.jsx("input",{id:"provider-anthropic-base-url",type:"text",value:I,onChange:D=>{Te(!0),R(D.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"}),n.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:Ro})]}),Z.anthropicBaseUrl!==void 0&&n.jsx("p",{className:"text-xs text-destructive",children:Z.anthropicBaseUrl}),n.jsx(Fa,{baseUrl:I,endpoint:Ro,providerName:r})]}),j&&N&&n.jsxs("div",{className:"space-y-2",children:[n.jsxs("label",{htmlFor:"provider-openai-base-url",className:"text-sm font-medium",children:["OpenAI Chat Base URL ",n.jsx("span",{className:"text-destructive",children:"*"})]}),n.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:[n.jsx("input",{id:"provider-openai-base-url",type:"text",value:k,onChange:D=>{le(!0),M(D.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"}),n.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:Mo})]}),Z.openaiBaseUrl!==void 0&&n.jsx("p",{className:"text-xs text-destructive",children:Z.openaiBaseUrl}),n.jsx(Fa,{baseUrl:k,endpoint:Mo,providerName:r})]}),j&&E&&n.jsxs("div",{className:"space-y-2",children:[n.jsxs("label",{htmlFor:"provider-openai-responses-base-url",className:"text-sm font-medium",children:["OpenAI Responses Base URL ",n.jsx("span",{className:"text-destructive",children:"*"})]}),n.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:[n.jsx("input",{id:"provider-openai-responses-base-url",type:"text",value:O,onChange:D=>{Pe(!0),$(D.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"}),n.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:Ao})]}),Z.openaiResponsesBaseUrl!==void 0&&n.jsx("p",{className:"text-xs text-destructive",children:Z.openaiResponsesBaseUrl}),n.jsx(Fa,{baseUrl:O,endpoint:Ao,providerName:r})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx("label",{htmlFor:"provider-source",className:"text-sm font-medium",children:"Token Source"}),n.jsxs("select",{id:"provider-source",value:ee??"",onChange:D=>U(D.target.value==="company"||D.target.value==="personal"?D.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:[n.jsx("option",{value:"",children:"Unspecified"}),n.jsx("option",{value:"personal",children:"个人 (Personal)"}),n.jsx("option",{value:"company",children:"公司 (Company)"})]}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Label whether this API key is company-provided or personal."})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx("label",{htmlFor:"provider-model-metadata-url",className:"text-sm font-medium",children:"Model Metadata URL"}),n.jsx("input",{id:"provider-model-metadata-url",type:"text",value:z,onChange:D=>H(D.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"}),Z.modelMetadataUrl!==void 0&&n.jsx("p",{className:"text-xs text-destructive",children:Z.modelMetadataUrl}),z.trim()===""&&n.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&&!Le&&z.trim()===""&&n.jsx("p",{className:"text-xs text-status-watch",children:"This provider has no matching context metadata yet."}),z.trim()!==""&&n.jsx("p",{className:"text-xs text-muted-foreground",children:"Agent Inspector will refresh model limits from this JSON registry after save."})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("label",{htmlFor:"provider-apikey",className:"text-sm font-medium",children:["API Key ",e===void 0&&n.jsx("span",{className:"text-destructive",children:"*"})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("input",{id:"provider-apikey",type:d?"text":"password",value:i,onChange:D=>c(D.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"}),n.jsx("button",{type:"button",onClick:()=>m(D=>!D),className:"text-muted-foreground hover:text-foreground transition-colors p-1 shrink-0","aria-label":d?"Hide API key":"Show API key",children:d?n.jsx(pg,{className:"size-4"}):n.jsx(Ru,{className:"size-4"})}),n.jsx("button",{type:"button",onClick:We,className:"text-muted-foreground hover:text-foreground transition-colors p-1 shrink-0","aria-label":"Copy API key",children:u?n.jsx(Fe,{className:"size-4 text-status-success"}):n.jsx(It,{className:"size-4"})})]}),e!==void 0&&i.trim()===""&&n.jsx("p",{className:"text-xs text-muted-foreground",children:"A key is configured. Enter a new value only to rotate it."}),Z.apiKey!==void 0&&n.jsx("p",{className:"text-xs text-destructive",children:Z.apiKey})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("label",{className:"text-sm font-medium",children:["Models ",n.jsx("span",{className:"text-destructive",children:"*"})]}),h.map((D,Y)=>{const de=b[Y]??Mn(),Ne=Z[`modelMetadata.${Y}.contextWindow`],F=Z[`modelMetadata.${Y}.outputLimit`],W=Y3(de),X=$a(de.contextWindow);return n.jsxs("div",{ref:ne=>{J.current[Y]=ne},className:"border border-border bg-card shadow-sm space-y-2 rounded-[8px] p-2",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("div",{className:"relative flex-1",children:[n.jsx("input",{type:"text",value:D,onChange:ne=>rt(Y,ne.target.value),placeholder:He.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"}),He.length>0&&n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",onClick:()=>L(oe===Y?null:Y),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:n.jsx(Xe,{className:"size-4"})}),oe===Y&&n.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:He.map(ne=>n.jsx("button",{type:"button",onClick:()=>{rt(Y,ne),L(null)},className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/60",children:ne},ne))})]})]}),h.length>1&&n.jsx("button",{type:"button",onClick:()=>pe(Y),className:"text-muted-foreground hover:text-destructive transition-colors p-1 shrink-0","aria-label":"Remove model",children:n.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:[n.jsx("path",{d:"M3 6h18"}),n.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),n.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]})})]}),n.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[n.jsxs("div",{className:"space-y-1 text-xs text-muted-foreground",children:[n.jsx("span",{children:"Context Window"}),n.jsxs(Ys,{value:W,onValueChange:ne=>q(Y,ne),children:[n.jsx(Js,{size:"sm",className:"w-full bg-background font-mono text-xs",children:n.jsx(hr,{})}),n.jsxs(Xs,{className:"max-h-64",children:[n.jsx(it,{value:Ei,children:"Not set"}),rh.map(ne=>n.jsxs(it,{value:ne.value,children:[ne.label," · ",ne.value]},ne.value)),n.jsx(it,{value:xr,children:"Custom"})]})]}),de.contextWindowMode==="custom"&&n.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_5.75rem] gap-1.5",children:[n.jsx("input",{type:"text",inputMode:"decimal",value:X.amount,onChange:ne=>se(Y,ne.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]"}),n.jsxs(Ys,{value:X.unit,onValueChange:ne=>xe(Y,ne),children:[n.jsx(Js,{size:"sm",className:"w-full bg-background font-mono text-xs",children:n.jsx(hr,{})}),n.jsxs(Xs,{children:[n.jsx(it,{value:"K",children:"K"}),n.jsx(it,{value:"M",children:"M"}),n.jsx(it,{value:"tokens",children:"tokens"})]})]})]}),Ne!==void 0&&n.jsx("span",{className:"block text-destructive",children:Ne})]}),n.jsxs("label",{className:"space-y-1 text-xs text-muted-foreground",children:[n.jsx("span",{children:"Output Limit"}),n.jsx("input",{type:"number",min:1,step:1e3,value:de.outputLimit,onChange:ne=>nt(Y,{outputLimit:ne.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]"}),F!==void 0&&n.jsx("span",{className:"block text-destructive",children:F})]})]})]},Y)}),n.jsx("button",{type:"button",onClick:we,className:"text-xs text-primary hover:underline flex items-center gap-1",children:"+ Add Model"}),Z.models!==void 0&&n.jsx("p",{className:"text-xs text-destructive",children:Z.models})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx("label",{htmlFor:"provider-api-docs-url",className:"text-sm font-medium",children:"API Docs URL"}),n.jsx("input",{id:"provider-api-docs-url",type:"text",value:K,onChange:D=>Q(D.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"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional API documentation URL. If not set, uses known provider docs."})]}),n.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:[n.jsx(te,{type:"button",variant:"outline",onClick:s,disabled:je,children:"Cancel"}),n.jsx(te,{type:"submit",disabled:je,children:je?"Saving...":e?"Update Provider":"Add Provider"})]})]})}const Z3=me(["timeout","network_unreachable","connection_refused","auth_failed","rate_limited","server_error","invalid_response","unknown"]),Q3=_({message:x(),type:Z3,details:x().optional(),hint:x().optional()}),e4=_({type:me(["text","thinking"]),text:x().optional(),thinking:x().optional()}),t4=_({requestUrl:x().optional(),requestMethod:x().optional(),requestHeaders:qe(x(),x()).optional(),requestBody:x().optional(),responseStatus:T().optional(),responseStatusText:x().optional(),responseHeaders:qe(x(),x()).optional(),responseBody:x().optional()}),Io=T().nullable().optional(),n4=_({success:Ce(),error:Q3.optional(),model:x().optional(),inputTokens:Io,outputTokens:Io,cacheCreationInputTokens:Io,cacheReadInputTokens:Io,latencyMs:T().optional(),firstChunkMs:T().nullable().optional(),totalStreamMs:T().nullable().optional(),tokensPerSecond:T().nullable().optional(),content:V(e4).optional(),rawResponse:x().optional(),streaming:Ce().optional(),streamingChunks:_({chunks:V(iu),truncated:Ce().default(!1)}).optional(),requestHeaders:qe(x(),x()).optional(),debug:t4.optional()}),xd=Vt([n4,_({notConfigured:ae(!0)}),_({testing:ae(!0)})]),xn=_({nonStreaming:xd,streaming:xd});function gr(){return{nonStreaming:{notConfigured:!0},streaming:{notConfigured:!0}}}const s4=_({anthropic:xn,openai:xn.optional(),openaiChat:xn.optional(),openaiResponses:xn.optional()}).transform(e=>{const t=e.openaiChat??e.openai??gr();return{...e,openai:e.openai??t,openaiChat:t,openaiResponses:e.openaiResponses??gr()}}),o4=_({anthropic:xn,openai:xn.optional(),openaiChat:xn.optional(),openaiResponses:xn.optional(),models:qe(x(),s4).optional(),testedAt:x().optional()}).transform(e=>{const t=e.openaiChat??e.openai??gr();return{...e,openai:e.openai??t,openaiChat:t,openaiResponses:e.openaiResponses??gr()}});function r4(){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 gd(e,t){const s=()=>({nonStreaming:{success:!1,error:{message:e,type:t}},streaming:{notConfigured:!0}});return{anthropic:s(),openai:s(),openaiChat:s(),openaiResponses:s()}}const a4=_({providerConfig:x()}),i4=_({success:Ce().optional(),imported:T().optional(),message:x().optional(),errors:V(x()).optional()}),l4=_({provider:sr,imported:T(),matchedModels:V(x()),missingModels:V(x()),sourceUrl:x()}),Po="Network error: could not reach the server. Is the proxy running?",c4=5e3,d4=5e3,bd=15e3,u4=1e4,m4=2e4,p4=2e4,f4=3e4;function Ba(e,t){return(e?.length??0)>0?e:t&&e!==void 0?"":void 0}function vd(e,t=!1){return{name:e.name,...e.apiKey.trim()===""?{}:{apiKey:e.apiKey},models:e.models,anthropicBaseUrl:Ba(e.anthropicBaseUrl,t),openaiBaseUrl:Ba(e.openaiBaseUrl,t),openaiResponsesBaseUrl:Ba(e.openaiResponsesBaseUrl,t),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 h4(e,t){const s=e?.models?.map(o=>o.trim()).filter(o=>o!=="").length??0;return Math.max(1,s)*t}async function x4(e,t){if(t.models!==void 0)try{await On(`/api/providers/${e}/test/log`,d4,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}catch{}}function g4({externalProviders:e,isLoading:t=!1,externalTestResults:s,externalTestingProviders:o,externalTestingTimeLeft:r,onProvidersMutate:a,onTestResultsChange:i,onTestingProvidersChange:c,onTestingTimeLeftChange:d}){const[m,u]=l.useState(!1),[p,f]=l.useState(),[h,g]=l.useState(null),[b,y]=l.useState({}),[w,v]=l.useState(new Set),[j,S]=l.useState({}),[N,C]=l.useState(null),[E,A]=l.useState(!1),[I,R]=l.useState(null),[k,M]=l.useState(!1),[O,$]=l.useState(!1),[K,Q]=l.useState(null),[z,H]=l.useState("all"),[ee,U]=l.useState(new Set),{providerTestTimeoutSeconds:Z}=Ki(),fe=l.useRef(null),je=l.useRef(null),he=e??[],oe=l.useMemo(()=>{const q=z==="all"?he:he.filter(se=>se.source===z);return z==="all"?[...q].sort((se,xe)=>{const pe={personal:0,company:1};return(pe[se.source??""]??2)-(pe[xe.source??""]??2)}):q},[he,z]),L=s??b,J=o??w,Se=r??j,Te=d?(q,se)=>d(q,se):(q,se)=>{S(se===void 0?xe=>{const pe={...xe};return delete pe[q],pe}:xe=>({...xe,[q]:se}))};l.useEffect(()=>{(async()=>{try{const q=await Be("/api/config/paths",a4,c4);C(q.providerConfig)}catch{}})()},[]);const ge=l.useCallback(q=>{je.current!==null&&clearTimeout(je.current),R(q),fe.current?.scrollTo({top:fe.current.scrollHeight,behavior:"smooth"}),je.current=setTimeout(()=>{R(null),je.current=null},2e3)},[]);l.useEffect(()=>()=>{je.current!==null&&clearTimeout(je.current)},[]);const le=l.useCallback(()=>{a?.().catch(()=>{})},[a]),ce=l.useCallback((q,se)=>{i?i(q,se):y(xe=>({...xe,[q]:se}))},[i]),Pe=l.useCallback((q,se)=>{if(c){c(q,se);return}v(xe=>{const pe=new Set(xe);return se?pe.add(q):pe.delete(q),pe})},[c]),Re=l.useCallback(async q=>{ce(q,r4()),Pe(q,!0);const se=new AbortController,xe=he.find(ze=>ze.id===q),pe=h4(xe,Z);let we=pe;Te(q,we);const Oe=setInterval(()=>{we--,Te(q,we),we<=0&&(clearInterval(Oe),se.abort())},1e3);try{const ze=await Be(`/api/providers/${q}/test`,o4,pe*1e3+1e3,{method:"POST",signal:se.signal},D=>`HTTP ${D.status}: ${D.statusText}`);ce(q,ze),await x4(q,ze)}catch(ze){const D=ze instanceof Error&&ze.name==="AbortError",Y=ze instanceof Li;D||Y?ce(q,gd("Request timed out","timeout")):ze instanceof Error&&ce(q,gd(ze.message,"server_error"))}finally{clearInterval(Oe),Te(q,void 0),Pe(q,!1)}},[Z,he,Te,ce,Pe]),$e=l.useCallback(async(q,se,xe=!0)=>{U(pe=>{const we=new Set(pe);return we.add(q),we});try{const pe=se!==void 0&&se.trim()!==""?{url:se}:{},we=await Be(`/api/providers/${q}/model-metadata`,l4,f4,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(pe)},()=>"Failed to refresh model metadata");return we.imported===0&&xe?g("No matching model metadata found for this provider."):g(null),ge(we.provider.id),le(),we.imported>0}catch(pe){return xe&&g(pe instanceof Error?pe.message:Po),!1}finally{U(pe=>{const we=new Set(pe);return we.delete(q),we})}},[le,ge]);function lt(q){(async()=>{try{const se=await Be("/api/providers",sr,bd,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(vd(q))},()=>"Failed to add provider");u(!1),ge(se.id),q.modelMetadataUrl!==void 0&&q.modelMetadataUrl.trim()!==""&&await $e(se.id,q.modelMetadataUrl,!1),le(),await Re(se.id)}catch(se){g(se instanceof Error?se.message:Po)}})()}function He(q){p&&(async()=>{try{const se=await Be(`/api/providers/${p.id}`,sr,bd,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(vd(q,!0))},()=>"Failed to update provider");f(void 0),ge(se.id),q.modelMetadataUrl!==void 0&&q.modelMetadataUrl.trim()!==""&&await $e(se.id,q.modelMetadataUrl,!1),le(),(q.apiKey.trim()!==""||JSON.stringify(q.models)!==JSON.stringify(p.models)||(q.anthropicBaseUrl??"")!==(p.anthropicBaseUrl??"")||(q.openaiBaseUrl??"")!==(p.openaiBaseUrl??"")||(q.openaiResponsesBaseUrl??"")!==(p.openaiResponsesBaseUrl??""))&&await Re(se.id)}catch(se){g(se instanceof Error?se.message:Po)}})()}function Le(q){Q(q),$(!0)}function We(){const q=K;q!==null&&(async()=>{let se;try{se=await On(`/api/providers/${q}`,u4,{method:"DELETE"})}catch{g(Po);return}if(!se.ok){g(await Xh(se,"Failed to delete provider"));return}le()})()}const Ke=l.useRef(null);function Ze(q){const se="/api/providers/export";(async()=>{try{const xe=await On(se,m4);if(!xe.ok){g("Failed to export providers");return}const pe=await xe.blob(),we=URL.createObjectURL(pe),Oe=document.createElement("a");Oe.href=we,Oe.download=xe.headers.get("Content-Disposition")?.match(/filename="(.+)"/)?.[1]??"providers.json",document.body.appendChild(Oe),Oe.click(),document.body.removeChild(Oe),URL.revokeObjectURL(we)}catch{g("Failed to export providers")}})()}function rt(){Ke.current?.click()}function nt(q){const se=q.target.files?.[0];se&&(async()=>{try{const xe=await se.text(),pe=await On("/api/providers/import",p4,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(xe)}),we=await Jh(pe,i4);pe.ok&&we.imported!==void 0&&we.imported>0?(le(),g(null)):we.errors&&we.errors.length>0?g(we.errors.join("; ")):g(we.message??"Import failed")}catch{g("Failed to import providers")}q.target.value=""})()}return t?n.jsx("div",{className:"flex items-center justify-center py-8",children:n.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading providers..."})}):m||p?n.jsxs("div",{className:"space-y-4",children:[n.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:n.jsx("h3",{className:"text-lg font-medium",children:p?"Edit Provider":"Add New Provider"})}),n.jsx(X3,{provider:p,onSubmit:p?He:lt,onCancel:()=>{u(!1),f(void 0)}})]}):n.jsxs("div",{className:"space-y-4",children:[n.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:[n.jsxs(te,{variant:"outline",size:"sm",onClick:()=>Ze(),className:"gap-1 hover:bg-muted",children:[n.jsx(to,{className:"size-3"}),"Export"]}),n.jsxs(te,{variant:"outline",size:"sm",onClick:rt,className:"gap-1 hover:bg-muted",children:[n.jsx($u,{className:"size-3"}),"Import"]}),n.jsx("input",{type:"file",ref:Ke,accept:".json",onChange:nt,style:{display:"none"}}),n.jsxs(te,{variant:"outline",size:"sm",onClick:()=>M(!0),className:"gap-1",children:[n.jsx(w1,{className:"size-3"}),"Scan"]}),n.jsxs(te,{onClick:()=>u(!0),size:"sm",className:"gap-1",children:[n.jsx(tc,{className:"size-4"}),"Add Provider"]})]}),N!==null&&n.jsxs("div",{className:"flex items-center gap-2 rounded-[8px] bg-muted/15 px-3 py-2 text-xs text-muted-foreground",children:[n.jsx("span",{className:"font-mono truncate",title:N,children:N}),n.jsx("button",{type:"button",onClick:()=>{Tt(N).then(q=>{q&&(A(!0),setTimeout(()=>A(!1),2e3))})},className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-foreground","aria-label":E?"Copied config file path":"Copy config file path",children:E?n.jsx(Fe,{className:"size-3 text-status-success"}):n.jsx(It,{className:"size-3"})})]}),h!==null&&n.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:[n.jsx(gs,{className:"size-4 shrink-0"}),h]}),he.length===0?n.jsxs("div",{className:"border border-border bg-card shadow-sm space-y-3 rounded-[8px] py-12 text-center",children:[n.jsx("p",{className:"text-sm text-muted-foreground",children:"No providers configured yet."}),n.jsxs(te,{onClick:()=>u(!0),variant:"outline",size:"sm",children:[n.jsx(tc,{className:"size-4"}),"Add Your First Provider"]})]}):n.jsxs("div",{className:"space-y-3",children:[n.jsx("div",{className:"inline-flex w-fit gap-1 rounded-[8px] bg-muted/20 p-1",children:["all","personal","company"].map(q=>n.jsx("button",{type:"button",onClick:()=>H(q),className:`rounded-md px-3 py-1.5 text-sm font-medium transition-colors ${z===q?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:q==="all"?"All":q==="personal"?"Personal":"Company"},q))}),n.jsx("div",{ref:fe,className:"space-y-3",children:oe.map(q=>n.jsx($3,{provider:q,testResults:L[q.id],isTesting:J.has(q.id),testingTimeLeft:Se[q.id],isHighlighted:q.id===I,onEdit:se=>f(se),onDelete:Le,onRefreshMetadata:se=>{$e(se)},isRefreshingMetadata:ee.has(q.id),onTest:se=>{Re(se)}},q.id))})]}),n.jsx(h3,{open:k,onOpenChange:M,onImportComplete:()=>{a!==void 0&&a()}}),n.jsx(mf,{open:O,onOpenChange:$,title:"Delete Provider",description:"Are you sure you want to delete this provider? This action cannot be undone.",confirmLabel:"Delete",variant:"destructive",onConfirm:We})]})}const b4=[{value:"providers",label:"Providers"},{value:"proxy",label:"Proxy"},{value:"storage",label:"Storage"},{value:"mcp",label:"MCP"},{value:"onboarding",label:"Onboarding"}];function v4(){return n.jsx(Rf,{"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:b4.map(e=>n.jsx(Zt,{value:e.value,className:"min-w-0 w-full",children:e.label},e.value))})}function y4(){const[e,t]=l.useState(!1),[s,o]=l.useState("providers"),{providers:r,isLoading:a,mutate:i}=ol(),[c,d]=l.useState({}),[m,u]=l.useState(new Set),[p,f]=l.useState({}),h=l.useCallback((y,w)=>{d(v=>({...v,[y]:w}))},[]),g=l.useCallback((y,w)=>{u(v=>{const j=new Set(v);return w?j.add(y):j.delete(y),j})},[]),b=l.useCallback((y,w)=>{f(v=>{if(w===void 0){const j={...v};return delete j[y],j}return{...v,[y]:w}})},[]);return n.jsxs(qt,{open:e,onOpenChange:t,children:[n.jsx(io,{asChild:!0,children:n.jsxs(te,{variant:"ghost",size:"icon",className:uo,"aria-label":"Settings",title:"Settings",children:[n.jsx(E1,{className:"size-4"}),n.jsx("span",{className:"sr-only",children:"Settings"})]})}),n.jsxs(Ht,{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:[n.jsx(Yt,{children:n.jsx(Jt,{children:"Settings"})}),n.jsxs(Ef,{value:s,onValueChange:o,className:"min-h-0 min-w-0 flex-1 overflow-hidden",children:[n.jsx(v4,{}),n.jsxs("div",{className:"mt-4 min-w-0 flex-1 overflow-x-hidden overflow-y-auto pr-1 sm:pr-2",children:[n.jsx(ct,{value:"providers",children:n.jsx(g4,{externalProviders:r,isLoading:a,externalTestResults:c,externalTestingProviders:m,externalTestingTimeLeft:p,onProvidersMutate:()=>i(),onTestResultsChange:h,onTestingProvidersChange:g,onTestingTimeLeftChange:b})}),n.jsx(ct,{value:"proxy",children:n.jsx(T4,{})}),n.jsx(ct,{value:"storage",children:n.jsx(S4,{})}),n.jsx(ct,{value:"mcp",children:n.jsx(_4,{})}),n.jsx(ct,{value:"onboarding",children:n.jsx(k4,{})})]})]})]})]})}const w4=_({kind:x(),root:x(),sensitivity:x(),cleanupBehavior:x(),fileCount:T(),bytes:T(),oldestModifiedAt:x().nullable(),newestModifiedAt:x().nullable()}),yd=_({memoryCount:T(),inventory:_({checkedAt:x(),totalFiles:T(),totalBytes:T(),artifacts:V(w4)}),policy:_({maxAgeMs:T(),maxTotalBytes:T()}),reclaimableBytes:T(),lastGc:_({checkedAt:x(),filesDeleted:T(),bytesDeleted:T(),errors:T(),beforeTotalBytes:T(),afterTotalBytes:T()}).nullable()}),wd=1e4;function $s(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 j4(e){return`${Math.round(e/1e3/60/60/24).toLocaleString()} days`}function S4(){const[e,t]=l.useState(null),[s,o]=l.useState(null),[r,a]=l.useState(!1),[i,c]=l.useState(!1),[d,m]=l.useState(null),u=l.useCallback(async()=>{a(!0),o(null);try{const h=await Be("/api/storage",yd,wd,void 0,g=>`Failed to load storage stats: HTTP ${String(g.status)}`);t(h)}catch(h){o(h instanceof Error?h.message:String(h))}finally{a(!1)}},[]);l.useEffect(()=>{u()},[u]);const p=l.useCallback((h,g)=>{Tt(g).then(b=>{b&&(m(h),setTimeout(()=>m(null),1600))})},[]),f=l.useCallback(async()=>{c(!0),o(null);try{const h=await Be("/api/storage",yd,wd,{method:"POST"},g=>`Failed to run storage GC: HTTP ${String(g.status)}`);t(h)}catch(h){o(h instanceof Error?h.message:String(h))}finally{c(!1)}},[]);return n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("h3",{className:"text-sm font-semibold",children:"Storage lifecycle"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Inspect local captured-data footprint, retention policy, and safe reclaim actions."})]}),n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[n.jsx(te,{type:"button",variant:"outline",size:"sm",onClick:()=>{f()},disabled:i,children:i?"Running...":"Run GC now"}),n.jsx(te,{type:"button",variant:"outline",size:"sm",onClick:()=>{u()},children:r?"Refreshing...":"Refresh"})]})]}),e!==null&&n.jsxs("div",{className:"grid gap-2 text-xs",children:[n.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[n.jsx(Lo,{label:"Persisted footprint",value:`${e.inventory.totalFiles.toLocaleString()} files / ${$s(e.inventory.totalBytes)}`,detail:`Checked ${new Date(e.inventory.checkedAt).toLocaleString()}`}),n.jsx(Lo,{label:"Auto-reclaimable",value:$s(e.reclaimableBytes),detail:`Retention ${j4(e.policy.maxAgeMs)} / max ${$s(e.policy.maxTotalBytes)}`}),n.jsx(Lo,{label:"In-memory logs",value:`${e.memoryCount.toLocaleString()} loaded`,detail:"Recent completed entries kept hot for the UI"}),n.jsx(Lo,{label:"Last GC",value:e.lastGc===null?"Not run yet":`${e.lastGc.filesDeleted.toLocaleString()} files / ${$s(e.lastGc.bytesDeleted)}`,detail:e.lastGc===null?"Runs at startup, on schedule, or manually here":`${new Date(e.lastGc.checkedAt).toLocaleString()} · ${e.lastGc.errors} errors`})]}),e.inventory.artifacts.map(h=>n.jsx(C4,{artifact:h,copiedId:d,onCopy:p},`${h.kind}:${h.root}`))]}),s!==null&&n.jsx("p",{className:"text-xs text-destructive",children:s})]})}function N4(e){switch(e){case"retention-gc":return"Retention GC";case"orphan-reclaim":return"Orphan reclaim";case"rotation":return"Rotation-owned";case"manual-owner-delete":return"Manual only";default:return e}}function Lo({label:e,value:t,detail:s}){return n.jsxs("div",{className:"rounded-md bg-muted/20 px-3 py-2",children:[n.jsx("div",{className:"font-medium",children:e}),n.jsx("div",{className:"mt-1 font-mono text-muted-foreground",children:t}),n.jsx("div",{className:"mt-1 text-[11px] text-muted-foreground",children:s})]})}function C4({artifact:e,copiedId:t,onCopy:s}){const o=`storage-${e.kind}`,r=e.oldestModifiedAt===null?"none":new Date(e.oldestModifiedAt),a=e.newestModifiedAt===null?"none":new Date(e.newestModifiedAt);return n.jsxs("div",{className:"rounded-md border border-border/45 bg-muted/15 px-3 py-2",children:[n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n.jsxs("div",{children:[n.jsx("div",{className:"font-medium",children:e.kind}),n.jsxs("div",{className:"mt-1 text-[11px] text-muted-foreground",children:[N4(e.cleanupBehavior)," · ",e.sensitivity]})]}),n.jsxs("div",{className:"text-right font-mono text-muted-foreground",children:[e.fileCount.toLocaleString()," files / ",$s(e.bytes)]})]}),n.jsxs("div",{className:"mt-2 grid gap-1 text-[11px] text-muted-foreground sm:grid-cols-2",children:[n.jsxs("div",{children:["Oldest: ",r instanceof Date?r.toLocaleString():r]}),n.jsxs("div",{children:["Newest: ",a instanceof Date?a.toLocaleString():a]})]}),n.jsx("div",{className:"mt-2",children:n.jsx(ql,{id:o,label:"Root path",value:e.root,copiedId:t,onCopy:s})})]})}function ql({id:e,label:t,value:s,copiedId:o,onCopy:r}){const a=o===e;return n.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:[n.jsx("div",{className:"mb-1 text-xs font-medium text-muted-foreground",children:t}),n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs text-foreground",title:s,children:s}),n.jsx(te,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0",onClick:()=>r(e,s),"aria-label":a?`Copied ${t}`:`Copy ${t}`,children:a?n.jsx(Fe,{className:"size-3.5 text-status-success"}):n.jsx(It,{className:"size-3.5"})})]})]})}function k4(){const[e,t]=l.useState(null),[s,o]=l.useState(null);l.useEffect(()=>Qi(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:"doctor",label:"Backend doctor",value:"agent-inspector doctor --verbose"},{id:"support-bundle",label:"Redacted support bundle",value:"agent-inspector doctor --support-bundle"},{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)=>{Tt(c).then(d=>{d&&(t(i),setTimeout(()=>t(null),1600))})},[]);return n.jsxs("div",{className:"min-w-0 space-y-4",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(qn,{className:"size-4 text-muted-foreground"}),n.jsx("h3",{className:"text-sm font-semibold",children:"Agent onboarding"})]}),n.jsx("div",{className:"grid gap-2",children:r.map(i=>n.jsx(ql,{id:i.id,label:i.label,value:i.value,copiedId:e,onCopy:a},i.id))}),n.jsxs("div",{className:"grid gap-2 rounded-md border border-status-info/25 bg-status-info/10 px-3 py-2 text-xs",children:[n.jsx("div",{className:"font-medium text-foreground",children:"Verified first trace flow"}),n.jsxs("ol",{className:"ml-4 list-decimal space-y-1 text-muted-foreground",children:[n.jsx("li",{children:"Start Agent Inspector and confirm the application bar shows Live."}),n.jsx("li",{children:"Copy the Proxy URL or MCP URL that matches your coding agent."}),n.jsx("li",{children:"Run a tiny coding-agent prompt such as “say hello and stop”."}),n.jsx("li",{children:"Return to Logs and confirm one new request appears with request, response, tokens, and tool activity when present."})]})]}),n.jsxs("div",{className:"grid gap-2 rounded-md bg-muted/15 px-3 py-2 text-xs text-muted-foreground",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Fe,{className:"size-3.5 text-status-success"}),n.jsx("span",{children:"Provider test creates a traceable memory probe session."})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Fe,{className:"size-3.5 text-status-success"}),n.jsx("span",{children:"Captured sessions can produce reviewable memory candidates."})]}),n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(Fe,{className:"mt-0.5 size-3.5 text-status-success"}),n.jsxs("span",{children:["Streamable HTTP clients should use the MCP URL directly. Stdio-only clients should use",n.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."]})]}),n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(Fe,{className:"mt-0.5 size-3.5 text-status-success"}),n.jsxs("span",{children:["OpenCode onboarding safely merges"," ",n.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"mcp.agent-inspector"})," ","into"," ",n.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"opencode.json"}),", then verify with"," ",n.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"opencode mcp list"}),"."]})]}),n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(Fe,{className:"mt-0.5 size-3.5 text-status-success"}),n.jsxs("span",{children:["MiMo Code onboarding safely merges"," ",n.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"mcp.agent-inspector"})," ","into"," ",n.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"," ",n.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"OPENAI_BASE_URL"}),"."]})]}),n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(Fe,{className:"mt-0.5 size-3.5 text-status-success"}),n.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."})]}),n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(Fe,{className:"mt-0.5 size-3.5 text-status-success"}),n.jsxs("span",{children:["If the first trace does not appear, run"," ",n.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"agent-inspector doctor --verbose"})," ","and compare the agent base URL with the current Proxy URL. A base-path mismatch such as"," ",n.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"/"})," ","versus"," ",n.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"/inspector"})," ","means the tool is talking to a different Inspector surface."]})]})]})]})}function _4(){const[e,t]=l.useState(null),[s,o]=l.useState(null);l.useEffect(()=>Qi(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]
|
|
57
|
+
`);if(s===o)return{lines:[],isEmpty:!0};const r=If(s,o);return{lines:Si(r),isEmpty:!1}}function qc(e){try{const t=JSON.parse(e);return t===null||typeof t=="string"||typeof t=="object"?t:null}catch{return null}}function GS(e,t){const s=e??"",o=t??"";if(s===o)return{lines:[],isEmpty:!0};const r=qc(s),a=qc(o);if(r!==null&&a!==null){const c=VS(r,a)??[];if(c.length===1){const d=c[0];if(d!==void 0&&!d.added&&!d.removed)return{lines:[],isEmpty:!0}}return{lines:Si(c),isEmpty:!1}}const i=If(s,o);return{lines:Si(i),isEmpty:!1}}const KS=22,Ca=1e4;function YS(e){return e==="added"?"+":e==="removed"?"-":" "}function JS(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 XS=function({result:t,emptyLabel:s}){const[o,r]=l.useState("unified"),a=l.useRef(null),i=Y5({count:t.lines.length,getScrollElement:()=>a.current,estimateSize:()=>KS,overscan:10});if(t.isEmpty)return n.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=t.lines.length,d=c>Ca,m=d?t.lines.slice(0,Ca):t.lines;return n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[n.jsxs("span",{children:[c.toLocaleString()," line",c===1?"":"s",d&&` (showing first ${Ca.toLocaleString()})`]}),n.jsxs("div",{className:"inline-flex rounded-md border border-border overflow-hidden",children:[n.jsxs("button",{type:"button",onClick:()=>r("unified"),"aria-pressed":o==="unified",className:P("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:[n.jsx(g1,{className:"size-3"}),"Unified"]}),n.jsxs("button",{type:"button",onClick:()=>r("split"),"aria-pressed":o==="split",className:P("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:[n.jsx(og,{className:"size-3"}),"Split"]})]})]}),n.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"?n.jsx(ZS,{virtualizer:i,lines:m}):n.jsx(tN,{lines:m})})]})};function ZS({virtualizer:e,lines:t}){return n.jsx("div",{style:{height:`${e.getTotalSize()}px`,width:"100%",position:"relative"},children:e.getVirtualItems().map(s=>{const o=t[s.index];return o===void 0?null:n.jsxs("div",{"data-index":s.index,ref:e.measureElement,className:P("flex items-start gap-3 px-2",JS(o.kind)),style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${s.start}px)`},children:[n.jsx("span",{className:"select-none text-muted-foreground/60 w-10 text-right tabular-nums",children:o.oldLineNumber??""}),n.jsx("span",{className:"select-none text-muted-foreground/60 w-10 text-right tabular-nums",children:o.newLineNumber??""}),n.jsx("span",{className:P("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:YS(o.kind)}),n.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:o.text})]},s.key)})})}function QS(e){const t=[];let s=0;for(;s<e.length;){const o=e[s];if(o===void 0)break;if(o.kind==="context"){t.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?t.push({left:{text:d.text,lineNumber:d.oldLineNumber},right:{text:m.text,lineNumber:m.newLineNumber},kind:"changed"}):d!==void 0?t.push({left:{text:d.text,lineNumber:d.oldLineNumber},right:null,kind:"removed"}):m!==void 0&&t.push({left:null,right:{text:m.text,lineNumber:m.newLineNumber},kind:"added"})}}return t}function eN(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 tN({lines:e}){const t=QS(e);return n.jsx("div",{"data-testid":"diff-split",children:t.map((s,o)=>n.jsxs("div",{className:P("grid grid-cols-2 font-mono text-xs",eN(s.kind)),children:[n.jsxs("div",{className:"flex items-start gap-2 px-2 border-r border-border/50",children:[n.jsx("span",{className:"select-none text-muted-foreground/60 w-8 text-right tabular-nums",children:s.left?.lineNumber??""}),n.jsx("span",{className:P("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?"-":" "}),n.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:s.left?.text??""})]}),n.jsxs("div",{className:"flex items-start gap-2 px-2",children:[n.jsx("span",{className:"select-none text-muted-foreground/60 w-8 text-right tabular-nums",children:s.right?.lineNumber??""}),n.jsx("span",{className:P("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?"+":" "}),n.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:s.right?.text??""})]})]},o))})}const Lf=l.memo(XS),nN=ou("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 _e({className:e,variant:t="default",asChild:s=!1,...o}){const r=s?Yb:"span";return n.jsx(r,{"data-slot":"badge","data-variant":t,className:P(nN({variant:t}),e),...o})}const sN=3;function oN({event:e}){const t=s=>{s.stopPropagation(),Ss({logId:e.logId,tab:"response",toolCallIndex:e.index})};return n.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:t,onKeyDown:s=>s.stopPropagation(),"aria-label":`Open response tool call ${e.name}`,title:e.name,children:n.jsx("span",{className:"min-w-0 truncate font-mono font-semibold",children:e.name})})}function rN({events:e}){if(e.length===0)return null;const t=e.slice(0,sN),s=Math.max(0,e.length-t.length);return n.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:[n.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:[n.jsx(no,{className:"size-3"}),"Call ",e.length]}),n.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-0.5 overflow-hidden",children:[t.map(o=>n.jsx(oN,{event:o},o.id)),s>0&&n.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 aN={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"},iN={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"}},Ps="border border-transparent bg-white/[0.045] hover:bg-white/[0.075] size-8 text-muted-foreground shadow-none hover:text-cyan-100",_t="bg-white/[0.045] flex h-7 items-center gap-1 rounded-md px-2 text-xs";function Ls(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function lN(e){return e>=10?`${e.toFixed(0)}/s`:`${e.toFixed(1)}/s`}function cN(e,t){switch(e){case"success":return t===null?"OK":String(t);case"client_error":return t===null?"WARN":String(t);case"server_error":return t===null?"FAIL":String(t);case"pending":return"ROLL"}}function Hc({trend:e}){if(e===null)return null;const t=e.direction==="up",s=t?b0:m0,o=t?"+":"-";return n.jsxs("span",{className:"flex items-center gap-0.5 text-muted-foreground tabular-nums",children:[n.jsx(s,{className:t?"size-3 text-cyan-300":"size-3 text-rose-400"}),n.jsxs("span",{className:"font-mono",children:[o,Ie(e.delta)]})]})}const dN=l.memo(function({log:e,displayNumber:t,messageCount:s=null,toolCount:o=null,toolEvents:r=[],expanded:a,onToggle:i,cacheTrend:c=null,activeTab:d,tabActions:m,onReplay:u,slowResponseThresholdSeconds:p=0,showClientMetadata:f=!0,timeDisplayFormat:h}){const g=Kh(e.responseStatus),v=e.elapsedMs!==null&&p>0&&e.elapsedMs>p*1e3,y=e.inputTokens!==null||e.outputTokens!==null,w=e.firstChunkMs??null,b=e.tokensPerSecond??null,j=w===null?null:Ls(w),S=b===null||b<=0?null:lN(b),N=e.warnings?.length??0,C=e.clientPid!==null&&e.clientPid!==void 0,E=e.clientProjectFolder!==null&&e.clientProjectFolder!==void 0&&e.clientProjectFolder!=="";e.clientCwd!==null&&e.clientCwd!==void 0&&e.clientCwd;const A=iN[g],I=cN(g,e.responseStatus),R=g!=="success"||e.responseStatus!==200,k=e.streaming&&j===null&&S===null;return n.jsx(Ts,{children:n.jsxs("div",{id:`log-${e.id}`,role:"button",tabIndex:0,"data-nav-id":`log-${e.id}`,"data-nav-action":a?"collapse":"expand",className:P("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:M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),i())},children:[n.jsxs("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1",children:[n.jsx("span",{className:P("inline-flex h-8 shrink-0 items-center rounded-md px-2 font-mono",A.frame),children:n.jsxs("span",{className:"text-xs font-semibold tabular-nums",title:`Log ID ${String(e.id)}`,children:["#",t]})}),n.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:[n.jsx(en,{className:"size-3"}),n.jsx("span",{className:"font-mono tabular-nums",title:e.timestamp,children:si(e.timestamp,h)})]}),R&&n.jsxs(_e,{variant:"outline",className:P("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)]",aN[g]),children:[g==="success"?n.jsx($e,{className:"size-3","aria-label":"Success"}):g==="server_error"?n.jsx(n1,{className:"size-3","aria-label":"Server error"}):g==="client_error"?n.jsx(bn,{className:"size-3","aria-label":"Client error"}):n.jsx(Ue,{className:"size-3 animate-spin","aria-label":"Pending"}),I]}),N>0&&n.jsxs(dt,{children:[n.jsx(ut,{asChild:!0,children:n.jsxs(_e,{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:[n.jsx(bn,{className:"size-3","aria-label":"Tool schema warnings"}),N]})}),n.jsx(mt,{children:N===1?"1 tool schema warning":`${N} tool schema warnings`})]}),e.elapsedMs!==null&&(v?n.jsxs(dt,{children:[n.jsx(ut,{asChild:!0,children:n.jsxs("span",{className:P(_t,"shrink-0 border-amber-300/25 text-amber-200"),children:[n.jsx(en,{className:"size-3"}),n.jsx("span",{className:"font-mono tabular-nums",children:Ls(e.elapsedMs)}),n.jsx(bn,{className:"size-3","aria-label":"Slow response"})]})}),n.jsxs(mt,{children:["Slow response: ",Ls(e.elapsedMs)," exceeds"," ",Ls(p*1e3)]})]}):n.jsxs("span",{className:P(_t,"shrink-0 text-muted-foreground"),children:[n.jsx(en,{className:"size-3"}),n.jsx("span",{className:"font-mono tabular-nums",children:Ls(e.elapsedMs)})]})),e.streaming&&j!==null&&n.jsxs("span",{className:P(_t,"shrink-0 text-cyan-300"),children:[n.jsx(nc,{className:"size-3"}),n.jsxs("span",{className:"font-mono tabular-nums",children:["first ",j]})]}),e.streaming&&S!==null&&n.jsxs("span",{className:P(_t,"shrink-0 text-cyan-300"),children:[n.jsx(Zi,{className:"size-3"}),n.jsx("span",{className:"font-mono tabular-nums",children:S})]}),y&&n.jsxs("span",{className:P(_t,"min-w-0 sm:shrink-0"),children:[n.jsx(Vs,{className:"size-3 text-muted-foreground"}),n.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-1 font-mono tabular-nums",children:[n.jsxs("span",{className:P("whitespace-nowrap",e.inputTokens!==null?"text-blue-400":"text-muted-foreground"),children:["IN ",e.inputTokens!==null?Ie(e.inputTokens):"n/a"]}),n.jsx("span",{className:"text-muted-foreground",children:"/"}),n.jsxs("span",{className:P("whitespace-nowrap",e.outputTokens!==null?"text-amber-400":"text-muted-foreground"),children:["OUT ",e.outputTokens!==null?Ie(e.outputTokens):"n/a"]})]})]}),e.cacheCreationInputTokens!==null&&e.cacheCreationInputTokens>0&&n.jsxs("span",{className:P(_t,"shrink-0"),children:[n.jsx(Hc,{trend:c?.creation??null}),n.jsxs("span",{className:"font-mono tabular-nums text-cyan-300",children:["KV Cache +",Ie(e.cacheCreationInputTokens)]})]}),e.cacheReadInputTokens!==null&&e.cacheReadInputTokens>0&&n.jsxs("span",{className:P(_t,"shrink-0"),children:[n.jsx(Hc,{trend:c?.read??null}),n.jsxs("span",{className:"font-mono tabular-nums text-purple-400",children:["KV Cache ~",Ie(e.cacheReadInputTokens)]})]}),s!==null&&n.jsxs("span",{className:P(_t,"shrink-0 text-muted-foreground"),children:[n.jsx(kr,{className:"size-3"}),n.jsx("span",{className:"font-mono tabular-nums",children:s})]}),o!==null&&n.jsxs("span",{className:P(_t,"shrink-0 text-muted-foreground"),children:[n.jsx(no,{className:"size-3"}),n.jsx("span",{className:"font-mono tabular-nums",children:o})]}),n.jsx(rN,{events:r}),e.origin!==null&&n.jsxs("span",{className:P(_t,"hidden shrink-0 text-muted-foreground xl:flex"),title:`Origin: ${e.origin}`,children:[n.jsx(Au,{className:"size-3"}),n.jsx("span",{className:"font-mono tabular-nums truncate max-w-[120px]",title:e.origin,children:e.origin})]}),f&&(C||E)&&n.jsxs("span",{className:P(_t,"hidden shrink-0 text-purple-300 xl:flex"),children:[n.jsx(jg,{className:"size-3"}),E?n.jsx("span",{className:"font-mono tabular-nums",children:e.clientProjectFolder}):n.jsxs("span",{className:"font-mono tabular-nums",children:["PID ",e.clientPid]})]}),k&&n.jsx(nc,{className:"size-3 shrink-0 text-muted-foreground/60"})]}),n.jsxs("span",{className:"flex shrink-0 items-start gap-1.5",children:[a&&n.jsxs("span",{className:"flex items-center gap-1.5 shrink-0",onClick:M=>M.stopPropagation(),onKeyDown:M=>M.stopPropagation(),children:[m!==void 0&&d!==void 0&&(()=>{const M=m[d];return M===void 0?null:n.jsxs(n.Fragment,{children:[M.expansion!==null&&n.jsxs(dt,{children:[n.jsx(ut,{asChild:!0,children:n.jsx(te,{variant:"outline",size:"icon",className:Ps,onClick:M.expansion.onToggle,disabled:M.expansion.isPending,"aria-pressed":M.expansion.isExpanded,"aria-label":M.expansion.isExpanded?"Collapse all JSON":"Expand all JSON",children:M.expansion.isExpanded?n.jsx(F0,{className:"size-3.5"}):n.jsx(P0,{className:"size-3.5"})})}),n.jsx(mt,{children:M.expansion.isExpanded?"Collapse all JSON nodes":"Expand all JSON nodes"})]}),M.diffWithRaw!==void 0&&n.jsxs(dt,{children:[n.jsx(ut,{asChild:!0,children:n.jsx(te,{variant:"outline",size:"icon",className:P(Ps,M.diffWithRaw.active&&"border-cyan-300/35 bg-cyan-400/15 text-cyan-100"),onClick:M.diffWithRaw.onToggle,"aria-pressed":M.diffWithRaw.active,"aria-label":M.diffWithRaw.active?"Hide raw diff":"Diff with raw",children:n.jsx(bg,{className:"size-3.5"})})}),n.jsx(mt,{children:M.diffWithRaw.active?"Hide diff with raw request":"Show diff between displayed and raw request body"})]}),M.diffWithPrevious!==void 0&&n.jsxs(dt,{children:[n.jsx(ut,{asChild:!0,children:n.jsx(te,{variant:"outline",size:"icon",className:Ps,onClick:M.diffWithPrevious,"aria-label":"Diff with previous",children:n.jsx(Iu,{className:"size-3.5"})})}),n.jsx(mt,{children:"Compare this request with the immediately preceding one"})]}),M.copyText!==null&&n.jsxs(dt,{children:[n.jsx(ut,{asChild:!0,children:n.jsx(te,{variant:"outline",size:"icon",className:Ps,onClick:M.onCopy,"aria-label":M.copyCopied?"Copied":M.copyLabel,children:M.copyCopied?n.jsx($e,{className:"size-3.5 text-cyan-300"}):n.jsx(jt,{className:"size-3.5"})})}),n.jsx(mt,{children:M.copyCopied?"Copied to clipboard":M.copyLabel})]})]})})(),u!==void 0&&n.jsxs(dt,{children:[n.jsx(ut,{asChild:!0,children:n.jsx(te,{variant:"outline",size:"icon",className:Ps,onClick:u,"aria-label":"Replay request",children:n.jsx(Du,{className:"size-3.5"})})}),n.jsx(mt,{children:"Re-send this request to the provider"})]})]}),n.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?n.jsx(Xe,{className:"size-4 shrink-0"}):n.jsx(gt,{className:"size-4 shrink-0"})})]})]})})});function uN({...e}){return n.jsx(jv,{"data-slot":"collapsible",...e})}function tR({...e}){return n.jsx(Xu,{"data-slot":"collapsible-trigger",...e})}function mN({...e}){return n.jsx(Zu,{"data-slot":"collapsible-content",...e})}function pN({className:e,children:t,...s}){return n.jsxs(_w,{"data-slot":"scroll-area",className:P("relative overflow-hidden",e),...s,children:[n.jsx(Tw,{"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:t}),n.jsx(fN,{}),n.jsx(Ew,{})]})}function fN({className:e,orientation:t="vertical",...s}){return n.jsx(ip,{"data-slot":"scroll-area-scrollbar",orientation:t,className:P("flex touch-none p-px transition-colors select-none",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",e),...s,children:n.jsx(up,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}const Of={file:"file",shell:"shell",browser:"browser",web:"web",mcp:"MCP",code:"code",other:"other"},hN={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 xN({category:e}){switch(e){case"file":return n.jsx(Ng,{className:"size-3.5"});case"shell":return n.jsx(qn,{className:"size-3.5"});case"browser":return n.jsx(Zg,{className:"size-3.5"});case"web":return n.jsx(Au,{className:"size-3.5"});case"mcp":return n.jsx(S0,{className:"size-3.5"});case"code":return n.jsx(Eu,{className:"size-3.5"});case"other":return n.jsx(dg,{className:"size-3.5"})}}function gN({names:e}){return e.length===0?null:n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:[n.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:"required"}),e.slice(0,4).map(t=>n.jsx(_e,{variant:"outline",className:"h-5 max-w-36 truncate rounded-md px-1.5 py-0 font-mono text-[10px]",children:t},t)),e.length>4&&n.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:["+",e.length-4]})]})}function bN({tool:e,called:t}){const[s,o]=l.useState(!1),r=hn(e.name),a=e.description!==null||e.requiredParameters.length>0||e.schema!==null;return n.jsx(uN,{open:s,onOpenChange:o,children:n.jsxs("div",{className:"bg-white/[0.035] rounded-[8px]",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-2.5 py-2",children:[n.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:[n.jsx(xN,{category:e.category}),n.jsx("span",{className:"min-w-0 truncate font-mono text-xs font-semibold text-foreground/90",children:e.name}),t&&n.jsx(_e,{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"}),n.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:[e.parameterCount," params"]}),e.descriptionPreview!==null&&n.jsx("span",{className:"hidden min-w-0 truncate text-xs text-muted-foreground md:inline",children:e.descriptionPreview}),n.jsx("span",{className:"flex-1"}),a&&(s?n.jsx(Xe,{className:"size-3.5 shrink-0 text-muted-foreground"}):n.jsx(gt,{className:"size-3.5 shrink-0 text-muted-foreground"}))]}),n.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?n.jsx($e,{className:"size-3.5 text-emerald-400"}):n.jsx(jt,{className:"size-3.5"})})]}),n.jsx(mN,{children:s&&n.jsxs("div",{className:"space-y-2 bg-white/[0.025] px-2.5 py-2",children:[e.description!==null&&n.jsx("p",{className:"text-xs leading-relaxed text-muted-foreground",children:e.description}),n.jsx(gN,{names:e.requiredParameters}),e.schema!==null&&n.jsx(pN,{className:"bg-black/[0.16] max-h-64 rounded-[8px] p-2",children:n.jsx(l.Suspense,{fallback:n.jsx("div",{className:"text-xs text-muted-foreground",children:"Loading JSON..."}),children:n.jsx(wi,{data:pr(e.schema),defaultExpandDepth:0})})})]})})]})})}function vN(e,t){return t.length===0?!0:`${e.name} ${e.description??""} ${Of[e.category]}`.toLowerCase().trim().includes(t)}const yN=l.memo(function({summary:t,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(()=>t===null?[]:t.tools.filter(f=>vN(f,d)),[d,t]);if(t===null)return null;const u=t.tools.slice(0,6),p=t.tools.length-u.length;return n.jsxs("section",{className:"bg-black/[0.10] mb-3 overflow-hidden rounded-[8px]",children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 px-3 py-2",children:[n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[n.jsx(no,{className:"size-4 shrink-0 text-sky-300/80"}),n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[n.jsx("span",{className:"text-sm font-semibold text-foreground",children:"Request Tools"}),n.jsx(_e,{variant:"outline",className:"h-5 rounded-md px-1.5 py-0 font-mono text-[10px]",children:t.tools.length}),t.toolChoiceLabel!==null&&n.jsxs(_e,{variant:"outline",className:"h-5 rounded-md px-1.5 py-0 font-mono text-[10px] text-muted-foreground",children:["tool_choice: ",t.toolChoiceLabel]})]}),n.jsx("div",{className:"mt-1 flex min-w-0 flex-wrap gap-1",children:t.categories.map(f=>n.jsxs(_e,{variant:"outline",className:P("h-5 rounded-md px-1.5 py-0 font-mono text-[10px]",hN[f.category]),children:[f.count," ",Of[f.category]]},f.category))})]})]}),n.jsxs(te,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-muted-foreground hover:text-cyan-100",onClick:()=>r(f=>!f),"aria-expanded":o,children:[o?n.jsx(Xe,{className:"size-3.5"}):n.jsx(gt,{className:"size-3.5"}),o?"Hide":"Show"]})]}),n.jsxs("div",{className:"flex min-w-0 flex-wrap gap-1.5 bg-white/[0.025] px-3 py-2",children:[u.map(f=>n.jsx(_e,{variant:"outline",className:P("h-5 max-w-44 truncate rounded-md px-1.5 py-0 font-mono text-[10px]",c.has(f.name)&&"border-emerald-400/20 text-emerald-300"),children:f.name},f.name)),p>0&&n.jsxs("span",{className:"font-mono text-[10px] leading-5 text-muted-foreground",children:["+",p]})]}),o&&n.jsxs("div",{className:"space-y-2 bg-black/10 px-3 py-3",children:[n.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:[n.jsx(S1,{className:"size-3.5 shrink-0 text-muted-foreground"}),n.jsx("input",{value:a,onChange:f=>i(f.target.value),placeholder:"Filter tools",className:"min-w-0 flex-1 bg-transparent font-mono text-xs outline-none placeholder:text-muted-foreground/70"})]}),n.jsx("div",{className:"grid gap-1.5",children:m.length>0?m.map(f=>n.jsx(bN,{tool:f,called:c.has(f.name)},f.name)):n.jsx("p",{className:"py-2 text-xs text-muted-foreground",children:"No matching tools"})})]})]})});function Vc(e,t,s){return e==="anthropic"&&t==="full"&&s}function wN(e,t){return e==="full"&&t}function ka(e,t){return e==="full"&&t}function _a(e,t){return e==="full"&&t}function jN(e,t){return e==="full"&&t===!0}function SN(e,t,s,o){return e==="anthropic"&&t==="full"&&s&&o}function ns(){return n.jsx("div",{className:"h-1","aria-hidden":"true"})}function NN(e,t){switch(e){case"anatomy":return t===null?"request":"anatomy";case"request":return"request";case"response":return"parsed"}}const CN=15e3,kN=15e3,_N=256*1024,xn=1024*1024,Wc=256*1024,Ta=512*1024,ln="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 So(e=null){return{status:"idle",text:"",offset:0,totalBytes:e,hasMore:e!==null&&e>0,error:null}}function fr(e){return e??0}function cs(e,t){return t??e?.length??0}function Ol(e){return e.bodyContentMode==="compact"||e.bodyContentMode==="truncated"}function Df(e){return Ol(e)?fr(e.rawRequestBodyBytes)>xn||fr(e.responseTextBytes)>xn:!1}function TN(e){return Ol(e)&&!Df(e)}function EN(e,t){return Ol(e)?!1:t?cs(e.rawRequestBody,e.rawRequestBodyBytes)<=xn&&cs(e.responseText,e.responseTextBytes)<=xn:cs(e.rawRequestBody,e.rawRequestBodyBytes)<=Wc&&cs(e.responseText,e.responseTextBytes)<=Wc}function RN(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 MN(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 AN(e){return e instanceof Li?"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 No({status:e,error:t,footprint:s,onRetry:o}){switch(e){case"idle":return null;case"loading":return n.jsx(Bn,{tone:"loading",title:"Loading full bodies",children:n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(Ue,{className:"size-3.5 shrink-0 animate-spin text-cyan-200"}),n.jsx("span",{children:"Loading full request and response bodies from the log store."})]}),s!==null&&n.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 n.jsx(Bn,{tone:"warning",title:t?.title??"Full bodies could not be loaded",children:n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n.jsx("span",{children:t?.detail??"Compact metadata is still available."}),n.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:[n.jsx(Rt,{className:"size-3"}),"Retry"]})]})})}}function Gc(e,t){return e?t.text!==""?t.text:t.status==="success"?"":null:null}function cn({children:e,className:t}){return n.jsx("div",{className:P("bg-black/[0.14] inspector-scrollbar mx-3 mb-3 max-h-[72vh] overflow-auto rounded-[8px] p-3",t),children:e})}function Wo({children:e}){return n.jsx("div",{className:"bg-white/[0.035] rounded-md px-3 py-5 text-center text-xs italic text-muted-foreground",children:e})}function Co({children:e}){const[t,s]=l.useState(!1),o=typeof e=="string"?e:null,r=o!==null&&o.length>Ta,a=o!==null&&r&&!t?o.slice(0,Ta):e;return l.useEffect(()=>{s(!1)},[o]),n.jsxs("div",{className:"space-y-2",children:[r&&!t&&n.jsxs("div",{className:"rounded-md border border-cyan-300/20 bg-cyan-300/[0.06] px-3 py-2 text-xs text-muted-foreground",children:["Showing the first ",Ta.toLocaleString()," characters for fast rendering. The full body is preserved and can still be copied from the tab action."]}),n.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:a}),r&&n.jsx("button",{type:"button",className:"rounded-md border border-border bg-background px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",onClick:()=>s(i=>!i),children:t?"Collapse fast preview":`Render full body (${o.length.toLocaleString()} chars)`})]})}const IN={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 Bn({tone:e,title:t,children:s}){return n.jsxs("div",{className:P("mb-3 rounded-md border px-3 py-2 text-xs shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]",IN[e]),children:[t!==void 0&&n.jsx("div",{className:"mb-1 font-semibold",children:t}),n.jsx("div",{className:"leading-relaxed text-muted-foreground",children:s})]})}function ko({label:e,state:t,expectedBytes:s,onLoadMore:o}){const r=t.totalBytes??s,a=r===null?ls(t.offset):`${ls(t.offset)} / ${ls(r)}`,i=t.status!=="loading"&&t.hasMore,c=t.status==="failed"?"Retry":"Load more";return n.jsx(Bn,{tone:t.status==="failed"?"warning":"loading",title:`${e} body preview`,children:n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n.jsxs("span",{children:[t.status==="idle"&&r!==null?`${e} body is ${ls(r)}. Loading the first preview chunk.`:`Loaded ${a}.`,t.status==="failed"&&t.error!==null&&` ${t.error}`]}),i&&n.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 Kc({error:e,onOpenSse:t}){return e==null?null:n.jsx(Bn,{tone:"danger",title:"SSE Error",children:n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n.jsx("span",{className:"font-mono",children:e}),t!==void 0&&n.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:t,children:"View SSE"})]})})}function PN({onOpenSse:e}){return n.jsx(Bn,{tone:"loading",title:"SSE chunks",children:n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n.jsx("span",{children:"Streaming chunks are available in the SSE tab."}),n.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 Yc({headers:e,emptyLabel:t}){const s=e===void 0?[]:Object.entries(e).sort(([o],[r])=>o.localeCompare(r));return s.length===0?n.jsx(Wo,{children:t}):n.jsx("div",{className:"bg-black/[0.14] overflow-hidden rounded-[8px] font-mono text-xs",children:s.map(([o,r])=>n.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:[n.jsx("div",{className:"min-w-0 truncate bg-white/[0.035] px-2.5 py-2 font-semibold text-cyan-200",children:o}),n.jsx("div",{className:"min-w-0 truncate px-2.5 py-2 text-muted-foreground",title:r,children:r})]},o))})}function LN({active:e,onClick:t}){return n.jsxs(dt,{children:[n.jsx(ut,{asChild:!0,children:n.jsxs(te,{variant:e?"default":"outline",size:"sm",className:P("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:t,"aria-pressed":e,children:[n.jsx(Ag,{className:"size-3.5 mr-1"}),e?"Showing diff":"Diff with Raw"]})}),n.jsx(mt,{children:e?"Hide diff view":"Compare proxy output against the original raw version"})]})}const ON=l.memo(function({rawBody:e,displayedBody:t,emptyLabel:s}){const o=l.useMemo(()=>GS(e,t),[e,t]);return n.jsx(Lf,{result:o,emptyLabel:s})}),DN=l.memo(function({rawHeaders:e,headers:t,emptyLabel:s}){const o=l.useMemo(()=>WS(e,t),[e,t]);return n.jsx(Lf,{result:o,emptyLabel:s})}),zN=l.memo(function({log:e,displayNumber:t,viewMode:s="simple",strip:o,slowResponseThresholdSeconds:r,timeDisplayFormat:a,cacheTrend:i=null,onCompareWithPrevious:c,showClientMetadata:d=!0,toolEvents:m=[]}){const[u,p]=l.useState(!1),[f,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,E]=l.useState(0),[A,I]=l.useState(null),[R,k]=l.useState(null),[M,O]=l.useState("idle"),[$,K]=l.useState(null),[Q,z]=l.useState(0),[H,ee]=l.useState(()=>So(e.rawRequestBodyBytes??null)),[U,Z]=l.useState(()=>So(e.responseTextBytes??null)),fe=l.useRef(null),je=l.useRef(e.id),he=l.useRef(!1),oe=l.useRef(!1),L=R??e,J=R===null&&Df(e),Se=l.useMemo(()=>LS(e.rawRequestBodyBytes,e.responseTextBytes),[e.rawRequestBodyBytes,e.responseTextBytes]),Te=Gc(J,H),ge=Gc(J,U),le=L.rawRequestBody??Te,ce=L.responseText??ge,Pe=L.rawRequestBody===null&&Te!==null,Re=L.responseText===null&&ge!==null,Fe=cs(le,e.rawRequestBodyBytes)<=xn,lt=cs(ce,e.responseTextBytes)<=xn,He=Fe&&(!Pe||H.hasMore===!1&&fr(H.totalBytes)<=xn),Le=lt&&(!Re||U.hasMore===!1&&fr(U.totalBytes)<=xn),We=mr(L),Ke=vf(We),Ze=EN(L,u),rt=l.useMemo(()=>Ke.analyzeRequest(Ze?L.rawRequestBody:null),[Ke,Ze,L.rawRequestBody]),nt=l.useMemo(()=>Ke.analyzeResponse(Ze?L.responseText:null),[Ke,Ze,L.responseText]),se=l.useMemo(()=>!o||We!=="anthropic"||L.rawRequestBody===null?null:gS(L.rawRequestBody).body,[L.rawRequestBody,We,o])??le,xe=Na(u&&MN(b)&&He?se:null),pe=Na(b==="raw-request"&&He?le:null),we=Na(b==="raw"&&Le?ce:null),Oe=jN(s,L.streaming),ze=xe.parsedData??rt.parsed,D=l.useMemo(()=>{const Me=nt.toolNames;return Me!==null?Me:m.map(vt=>vt.name)},[nt.toolNames,m]),Y=l.useMemo(()=>L.headers&&Object.keys(L.headers).length>0?JSON.stringify(L.headers,null,2):null,[L.headers]),de=l.useMemo(()=>L.rawHeaders&&Object.keys(L.rawHeaders).length>0?JSON.stringify(L.rawHeaders,null,2):null,[L.rawHeaders]),Ne=hn(se),F=hn(le),W=hn(Y),X=hn(de),ne=hn(ce),Ee=l.useMemo(()=>({request:{copyLabel:Pe?"Copy loaded request preview":"Copy request body",copyText:se,copyCopied:Ne.copied,onCopy:Ne.copy,expansion:He?{isExpanded:xe.isExpanded,isPending:xe.isPending,onToggle:xe.toggle}:null,diffWithRaw:SN(We,s,o,L.rawRequestBody!==null)?{active:y,onToggle:()=>w(!y)}:void 0,diffWithPrevious:c===void 0?void 0:()=>{c(L)}},"raw-request":{copyLabel:Pe?"Copy loaded raw request preview":"Copy raw request",copyText:le,copyCopied:F.copied,onCopy:F.copy,expansion:He?{isExpanded:pe.isExpanded,isPending:pe.isPending,onToggle:pe.toggle}:null},..._a(s,L.headers!==void 0&&Object.keys(L.headers).length>0)?{headers:{copyLabel:"Copy headers",copyText:Y,copyCopied:W.copied,onCopy:W.copy,expansion:null}}:{},...ka(s,L.rawHeaders!==void 0&&Object.keys(L.rawHeaders).length>0)?{"raw-headers":{copyLabel:"Copy raw headers",copyText:de,copyCopied:X.copied,onCopy:X.copy,expansion:null}}:{},raw:{copyLabel:Re?"Copy loaded response preview":"Copy response",copyText:ce,copyCopied:ne.copied,onCopy:ne.copy,expansion:Le?{isExpanded:we.isExpanded,isPending:we.isPending,onToggle:we.toggle}:null}}),[se,Pe,He,Ne,xe,y,L,L.rawRequestBody,le,F,pe,Y,W,de,X,L.responseText,Re,Le,ce,ne,we,We,s,o,c]),ie=l.useMemo(()=>ze!==null?Ke.anatomySegments(ze):null,[Ke,ze]),re=l.useMemo(()=>Il(ze),[ze]),ke=L.warnings??[],De=l.useMemo(()=>{if(ie!==null)return new Set(ie.map(Me=>Me.path))},[ie]),Wn=IS({containerRef:fe,setExpandToPath:I,ensureTabActive:()=>{b!=="request"&&(oe.current=!0,j("request"))}}),Lt=l.useCallback((Me,vt)=>{const Qe=Me==="request"?ee:Z;Qe(st=>({...st,status:"loading",error:null}));const Es=new URLSearchParams({part:Me,offset:String(vt),limit:String(_N)});Be(`/api/logs/${String(e.id)}/body?${Es.toString()}`,lu,kN).then(st=>{je.current===e.id&&Qe(Ct=>({status:"success",text:st.offset===0?st.text:`${Ct.text}${st.text}`,offset:st.nextOffset??st.totalBytes,totalBytes:st.totalBytes,hasMore:st.hasMore,error:null}))}).catch(st=>{je.current===e.id&&Qe(Ct=>({...Ct,status:"failed",error:AN(st)}))})},[e.id]),rn=l.useCallback(()=>{he.current||($S(e.id),k(null),O("idle"),K(null),z(Me=>Me+1))},[e.id]),Qr=l.useCallback(()=>{const Me=!u;Me&&(oe.current=!1,j(ie!==null?"anatomy":"request")),p(Me)},[ie,u]),Gn=l.useCallback(()=>{Oe&&(oe.current=!0,j("sse"))},[Oe]),ea=l.useCallback(Me=>{oe.current=!0,j(Me)},[]);return l.useEffect(()=>{je.current=e.id,he.current=!1,k(null),O("idle"),K(null),z(0),oe.current=!1,ee(So(e.rawRequestBodyBytes??null)),Z(So(e.responseTextBytes??null))},[e.id,e.rawRequestBodyBytes,e.responseTextBytes]),l.useEffect(()=>{u&&(oe.current||b==="request"&&ie!==null&&j("anatomy"))},[b,ie,u]),l.useEffect(()=>{b!=="sse"||Oe||j("parsed")},[b,Oe]),l.useEffect(()=>{if(!u||!RN(b)||!TN(e)||R!==null||he.current)return;const Me=Mf(e.id);if(Me!==null){k(Me),O("idle"),K(null);return}let vt=!1;return he.current=!0,O("loading"),K(null),FS(e.id,()=>Be(`/api/logs/${String(e.id)}`,Hs,CN)).then(Qe=>{vt||(he.current=!1,k(Qe),O("idle"),K(null))}).catch(Qe=>{vt||(he.current=!1,O("failed"),K(OS(Qe)))}),()=>{vt=!0,he.current=!1}},[b,u,R,e.bodyContentMode,e.id,e.rawRequestBodyBytes,e.responseTextBytes,Q]),l.useEffect(()=>{u&&J&&H.status==="idle"&&(b!=="request"&&b!=="raw-request"&&b!=="anatomy"||Lt("request",0))},[b,u,Lt,H.status,J]),l.useEffect(()=>{u&&J&&U.status==="idle"&&(b!=="parsed"&&b!=="raw"||Lt("response",0))},[b,u,Lt,U.status,J]),l.useEffect(()=>{const Me=vt=>{const Qe=Jr(vt);Qe!==null&&Qe.logId===e.id&&(p(!0),oe.current=!0,j(NN(Qe.tab,ie)),Qe.tab==="response"&&Qe.toolCallIndex!==void 0&&(N(Qe.toolCallIndex),E(Es=>Es+1)))};return window.addEventListener(sn,Me),()=>{window.removeEventListener(sn,Me)}},[ie,e.id]),n.jsxs(Ts,{children:[n.jsxs("div",{className:P("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:[n.jsx(dN,{log:L,displayNumber:t,messageCount:rt.messageCount,toolCount:rt.toolCount,toolEvents:m,expanded:u,onToggle:Qr,cacheTrend:i,slowResponseThresholdSeconds:r,showClientMetadata:d,timeDisplayFormat:a,activeTab:b,tabActions:Ee,onReplay:c===void 0?void 0:()=>{h(!0)}}),u&&n.jsxs("div",{className:"relative bg-black/[0.14] pt-2",onClick:Me=>Me.stopPropagation(),onKeyDown:Me=>Me.stopPropagation(),children:[n.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"}),n.jsx(Jo,{feature:"Log details",children:n.jsxs(Ef,{value:b,onValueChange:ea,className:"gap-2",children:[n.jsxs(Rf,{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:[ka(s,L.rawHeaders!==void 0&&Object.keys(L.rawHeaders).length>0)&&n.jsx(Zt,{className:ln,value:"raw-headers",children:"Raw Headers"}),_a(s,L.headers!==void 0&&Object.keys(L.headers).length>0)&&n.jsx(Zt,{className:ln,value:"headers",children:"Headers"}),ie!==null&&n.jsx(Zt,{className:ln,value:"anatomy",children:"Context"}),Vc(We,s,o)&&n.jsx(Zt,{className:ln,value:"raw-request",children:"Raw Request"}),n.jsx(Zt,{className:ln,value:"request",children:"Request"}),s==="full"&&n.jsx(Zt,{className:ln,value:"raw",children:"Raw Response"}),n.jsx(Zt,{className:ln,value:"parsed",children:"Response"}),Oe&&n.jsx(Zt,{className:ln,value:"sse",children:"SSE"})]}),Vc(We,s,o)&&n.jsx(ct,{value:"raw-request",children:b==="raw-request"&&n.jsxs(cn,{children:[n.jsx(No,{status:M,error:$,footprint:Se,onRetry:rn}),J&&n.jsx(ko,{label:"Request",state:H,expectedBytes:e.rawRequestBodyBytes??null,onLoadMore:()=>Lt("request",H.offset)}),le===null?n.jsx(Wo,{children:J?"Request preview is loading":"No request body"}):pe.parsedData!==null?n.jsx(l.Suspense,{fallback:n.jsx(ns,{}),children:n.jsx(wi,{data:pe.parsedData,bulkDepth:pe.bulkDepth,bulkRevision:pe.bulkRevision})}):n.jsx(Co,{children:le})]})}),n.jsx(ct,{value:"request",children:b==="request"&&n.jsxs(cn,{children:[n.jsx(No,{status:M,error:$,footprint:Se,onRetry:rn}),J&&n.jsx(ko,{label:"Request",state:H,expectedBytes:e.rawRequestBodyBytes??null,onLoadMore:()=>Lt("request",H.offset)}),ke.length>0&&n.jsxs(Bn,{tone:"warning",children:[n.jsxs("div",{className:"flex items-center gap-2 font-semibold text-amber-300",children:[n.jsx(bn,{className:"size-3.5"}),"Tool schema warnings"]}),n.jsx("ul",{className:"mt-2 space-y-1 text-muted-foreground",children:ke.map(Me=>n.jsx("li",{children:Me},Me))})]}),n.jsx(yN,{summary:re,calledToolNames:D}),y?n.jsx(ON,{rawBody:L.rawRequestBody,displayedBody:se,emptyLabel:"No transformation applied; raw and sent request bodies are identical."}):n.jsx("div",{ref:fe,children:se===null?n.jsx(Wo,{children:J?"Request preview is loading":"No request body"}):xe.parsedData!==null?n.jsx(l.Suspense,{fallback:n.jsx(ns,{}),children:n.jsx(wi,{data:xe.parsedData,bulkDepth:xe.bulkDepth,bulkRevision:xe.bulkRevision,anatomyPaths:De,expandToPath:A})}):n.jsx(Co,{children:se})})]})}),ie!==null&&n.jsx(ct,{value:"anatomy",children:b==="anatomy"&&n.jsx(cn,{className:"p-0",children:n.jsx(l.Suspense,{fallback:n.jsx(ns,{}),children:n.jsx(_S,{parsed:xe.parsedData,inputTokens:L.inputTokens??null,model:L.model,segments:ie,onSegmentActivate:Wn})})})}),_a(s,L.headers!==void 0&&Object.keys(L.headers).length>0)&&n.jsx(ct,{value:"headers",children:b==="headers"&&n.jsxs(cn,{children:[n.jsx("div",{className:"flex justify-end gap-2 mb-2",children:wN(s,L.rawHeaders!==void 0&&Object.keys(L.rawHeaders).length>0)&&n.jsx(LN,{active:g,onClick:Me=>{Me.stopPropagation(),v(!g)}})}),g?n.jsx(DN,{rawHeaders:L.rawHeaders,headers:L.headers,emptyLabel:"No transformation applied; raw and processed headers are identical."}):n.jsx(Yc,{headers:L.headers,emptyLabel:"No headers captured"})]})}),ka(s,L.rawHeaders!==void 0&&Object.keys(L.rawHeaders).length>0)&&n.jsx(ct,{value:"raw-headers",children:b==="raw-headers"&&n.jsx(cn,{children:n.jsx(Yc,{headers:L.rawHeaders,emptyLabel:"No raw headers captured"})})}),n.jsx(ct,{value:"raw",children:b==="raw"&&n.jsxs(cn,{className:"space-y-3",children:[n.jsx(No,{status:M,error:$,footprint:Se,onRetry:rn}),J&&n.jsx(ko,{label:"Response",state:U,expectedBytes:e.responseTextBytes??null,onLoadMore:()=>Lt("response",U.offset)}),n.jsx(Kc,{error:L.error,onOpenSse:Oe?Gn:void 0}),ce!==null&&Le?n.jsx(l.Suspense,{fallback:n.jsx(ns,{}),children:n.jsx(RS,{text:ce,defaultExpandDepth:0,bulkDepth:we.bulkDepth,bulkRevision:we.bulkRevision})}):ce!==null?n.jsx(Co,{children:ce}):n.jsx(Wo,{children:J?"Response preview is loading":"No response"}),Oe&&n.jsx(PN,{onOpenSse:Gn})]})}),Oe&&n.jsx(ct,{value:"sse",children:b==="sse"&&n.jsxs(cn,{className:"space-y-3",children:[L.error!==void 0&&L.error!==null&&n.jsx(Bn,{tone:"danger",title:"SSE Error",children:n.jsx("span",{className:"font-mono",children:L.error})}),n.jsx(l.Suspense,{fallback:n.jsx(ns,{}),children:n.jsx(ES,{logId:L.id,truncated:L.streamingChunksPath!==null})})]})}),n.jsx(ct,{value:"parsed",children:b==="parsed"&&n.jsxs(cn,{children:[n.jsx(No,{status:M,error:$,footprint:Se,onRetry:rn}),J&&n.jsx(ko,{label:"Response",state:U,expectedBytes:e.responseTextBytes??null,onLoadMore:()=>Lt("response",U.offset)}),n.jsx(Kc,{error:L.error,onOpenSse:Oe?Gn:void 0}),Re&&!Le?n.jsx(Co,{children:ce}):n.jsx(l.Suspense,{fallback:n.jsx(ns,{}),children:n.jsx(TS,{responseText:ce,responseStatus:L.responseStatus,streaming:L.streaming,inputTokens:L.inputTokens,outputTokens:L.outputTokens,cacheCreationInputTokens:L.cacheCreationInputTokens,cacheReadInputTokens:L.cacheReadInputTokens,apiFormat:We,focusedToolIndex:S,toolFocusNonce:C})})]})})]})})]})]}),n.jsx(Jo,{feature:"Replay",children:n.jsx(l.Suspense,{fallback:null,children:n.jsx(kS,{log:L,displayNumber:t,open:f,onOpenChange:h})})})]})});function $N(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 Ea(e){return e?"cursor-pointer transition-transform hover:scale-110":""}function FN({stopReason:e,isPending:t,isFirst:s,isTurnStart:o,isOnlyEntry:r=!1,isOpenTurnTail:a=!1,crabIndex:i=0,collapsible:c=!1,onToggle:d}){const m=Pl(e),u=r&&o&&m,p=t&&!m,f=c&&d!==void 0,h=l.useMemo(()=>Ll(i),[i]),g=l.useMemo(()=>mS(i),[i]),v=w=>{!f||d===void 0||(w.stopPropagation(),d())},y=w=>{!f||d===void 0||w.key!=="Enter"&&w.key!==" "||(w.preventDefault(),d())};return n.jsxs("div",{className:"flex flex-col items-center w-6 shrink-0 pt-0.5 pb-0.5",children:[n.jsx("div",{className:"flex justify-center h-[calc(0.75rem-8px)]",children:!s&&n.jsx("div",{className:"w-px bg-muted-foreground/18 h-full"})}),u?n.jsx("span",{role:f?"button":void 0,tabIndex:f?0:void 0,title:"Single-request turn",className:Ea(f),onClick:v,onKeyDown:y,children:n.jsx(g,{className:P("size-3.5 text-[#80FF00]","animate-crab-settle","drop-shadow-[0_0_4px_rgba(128,255,0,0.5)]")})}):m?n.jsx("span",{role:f?"button":void 0,tabIndex:f?0:void 0,title:$N(e),className:Ea(f),onClick:v,onKeyDown:y,children:n.jsx(h,{className:P("size-3.5 text-amber-400","animate-crab-settle","drop-shadow-[0_0_4px_rgba(251,191,36,0.5)]")})}):o?n.jsx("span",{role:f?"button":void 0,tabIndex:f?0:void 0,title:"Start of turn",className:Ea(f),onClick:v,onKeyDown:y,children:n.jsx(h,{className:P("size-3.5 text-emerald-400","animate-crab-appear","drop-shadow-[0_0_4px_rgba(52,211,153,0.5)]")})}):a?n.jsx("span",{title:t?"Current end of open turn (processing)":"Current end of open turn",children:n.jsx(h,{className:P("size-3.5 text-cyan-300/85",p?"animate-crab-crawl":"animate-crab-appear","drop-shadow-[0_0_4px_rgba(103,232,249,0.4)]")})}):p?n.jsx("span",{title:"Processing",children:n.jsx(h,{className:P("size-3.5 text-amber-300/80","animate-crab-crawl")})}):n.jsx("span",{title:"Request in turn",children:n.jsx(h,{className:"size-3.5 text-muted-foreground/40"})}),n.jsx("div",{className:"flex-1 flex justify-center min-h-0",children:!m&&!a&&n.jsx("div",{className:P("w-0.5 h-full",t?"border-dashed bg-transparent border-l border-muted-foreground/14":"bg-muted-foreground/18")})})]})}const Jc=180;function BN(e){const t=pf(e.path);return t==="unknown"?e.apiFormat:t}function UN(e,t){const s=e.responseText;if(s===null)return!1;switch(t){case"anthropic":return s.includes("tool_use");case"openai":return s.includes("tool_calls")||s.includes("function_call");case"unknown":return!1}}function zf(e){if(e===null)return null;try{const t=JSON.parse(e);return typeof t=="string"?JSON.parse(t):t}catch{return null}}function qN(e){if(e==null)return null;const t=typeof e=="string"?e:JSON.stringify(e);if(t===void 0)return null;const s=t.replace(/\s+/g," ").trim();return s.length===0?null:s.length>Jc?`${s.slice(0,Jc-1)}...`:s}function HN(e){if(e==null)return null;if(typeof e=="string")return e.length>0?e:null;const t=JSON.stringify(e,null,2);return t===void 0||t.length===0?null:t}function yn({log:e,provider:t,index:s,name:o,input:r}){return{id:`${String(e.id)}-${t}-tool-${String(s)}`,logId:e.id,index:s,provider:t,name:o,argumentsText:HN(r),argumentsPreview:qN(r)}}function VN(e){const t=zf(e.responseText),s=G(t,"content");if(!Array.isArray(s))return[];const o=[];for(const r of s){if(G(r,"type")!=="tool_use")continue;const i=G(r,"name");if(typeof i!="string"||i.length===0)continue;const c=G(r,"input");o.push(yn({log:e,provider:"anthropic",index:o.length,name:i,input:c}))}return o}function WN(e){const t=zf(e.responseText),s=G(t,"choices"),o=[];if(Array.isArray(s))for(const a of s){const i=G(a,"message"),c=G(i,"tool_calls");if(Array.isArray(c))for(const u of c){const p=G(u,"function"),f=G(p,"name");if(typeof f!="string"||f.length===0)continue;const h=G(p,"arguments");o.push(yn({log:e,provider:"openai",index:o.length,name:f,input:h}))}const d=G(i,"function_call"),m=G(d,"name");if(typeof m=="string"&&m.length>0){const u=G(d,"arguments");o.push(yn({log:e,provider:"openai",index:o.length,name:m,input:u}))}}const r=G(t,"output");if(Array.isArray(r))for(const a of r){if(G(a,"type")!=="function_call")continue;const i=G(a,"name");if(typeof i!="string"||i.length===0)continue;const c=G(a,"arguments");o.push(yn({log:e,provider:"openai",index:o.length,name:i,input:c}))}return o}function $f(e){if(typeof e.data=="string")try{return JSON.parse(e.data)}catch{return e.data}return e.data}function Go(e,t,s){const o=`${s.provider}:${s.name}:${s.index}`;t.has(o)||(t.add(o),e.push(s))}function GN(e){const t=e.streamingChunks?.chunks??[],s=[],o=new Set;for(const r of t){const a=$f(r),i=G(a,"content_block");if(G(i,"type")!=="tool_use")continue;const c=G(i,"name");if(typeof c!="string"||c.length===0)continue;const d=G(i,"input");Go(s,o,yn({log:e,provider:"anthropic",index:r.index,name:c,input:d}))}return s.map((r,a)=>({...r,id:`${String(e.id)}-anthropic-tool-${String(a)}`,index:a}))}function KN(e){const t=e.streamingChunks?.chunks??[],s=[],o=new Set;for(const r of t){const a=$f(r),i=G(a,"choices");if(Array.isArray(i))for(const d of i){const m=G(d,"delta"),u=G(m,"tool_calls");if(Array.isArray(u))for(const h of u){const g=G(h,"function"),v=G(g,"name");if(typeof v!="string"||v.length===0)continue;const y=G(g,"arguments");Go(s,o,yn({log:e,provider:"openai",index:s.length,name:v,input:y}))}const p=G(m,"function_call"),f=G(p,"name");if(typeof f=="string"&&f.length>0){const h=G(p,"arguments");Go(s,o,yn({log:e,provider:"openai",index:s.length,name:f,input:h}))}}const c=G(a,"item");if(G(c,"type")==="function_call"){const d=G(c,"name");if(typeof d=="string"&&d.length>0){const m=G(c,"arguments");Go(s,o,yn({log:e,provider:"openai",index:s.length,name:d,input:m}))}}}return s.map((r,a)=>({...r,id:`${String(e.id)}-openai-tool-${String(a)}`,index:a}))}function YN(e){if(e.toolTraceEvents!==void 0&&e.toolTraceEvents.length>0)return e.toolTraceEvents;const t=BN(e);if(UN(e,t))switch(t){case"anthropic":return VN(e);case"openai":return WN(e);case"unknown":return[]}switch(t){case"anthropic":return GN(e);case"openai":return KN(e);case"unknown":return[]}}const Xc=new WeakMap;function JN(e){return e>1}function Ni(e){const t=[];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:kf(a),sessionLogNumber:r+1});const i=s[s.length-1];i!==void 0&&Pl(i.stopReason)&&(t.push({entries:s,turnIndex:o}),s=[],o+=1)}return s.length>0&&t.push({entries:s,turnIndex:o}),t}function XN(e){const t=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=mr(r),c=mr(a);i==="unknown"||i!==c||t.set(r.id,a)}return t}function Dl(e){const t=Xc.get(e);if(t!==void 0&&t.apiFormat===e.apiFormat&&t.responseText===e.responseText&&t.toolTraceEvents===e.toolTraceEvents)return t.events;const s=YN(e);return Xc.set(e,{apiFormat:e.apiFormat,responseText:e.responseText,toolTraceEvents:e.toolTraceEvents,events:s}),s}function ZN(e,t,s=0){let o=0,r=0,a=0,i=0,c=0,d=0,m=0,u=0,p=null,f=0;for(const h of e)h.responseStatus===null?r+=1:h.responseStatus>=400&&(o+=1),h.elapsedMs!==null&&t>0&&h.elapsedMs>t*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,p=p===null?h.elapsedMs:Math.max(p,h.elapsedMs)),f+=Dl(h).length;return{llmCallCount:e.length,toolCallCount:f,failedCallCount:o,pendingCallCount:r,slowCallCount:a,totalInputTokens:i,totalOutputTokens:c,totalCacheCreationInputTokens:d,totalCacheReadInputTokens:m,totalElapsedMs:u,maxElapsedMs:p,startedAt:e[0]?.timestamp??null,endedAt:e[e.length-1]?.timestamp??null,knowledgeCandidateCount:s}}function Ra(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}const QN=l.memo(function({entries:t,viewMode:s,strip:o,slowResponseThresholdSeconds:r,cacheTrends:a,onCompareWithPrevious:i,comparisonPredecessors:c,turnIndex:d=0,timeDisplayFormat:m,pendingFocusRequest:u,showLogClientMetadata:p=!0}){const f=t.length-1,h=t[f]?.stopReason??null,g=h!==null?Pl(h):!1,v=t[f]?.log.responseStatus===null,y=t.length===1,w=JN(t.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 z=H=>{const ee=Jr(H);ee!==null&&t.some(U=>U.log.id===ee.logId)&&w&&j(!1)};return window.addEventListener(sn,z),()=>{window.removeEventListener(sn,z)}},[w,t]),l.useEffect(()=>{if(u===void 0||!t.some(H=>H.log.id===u.logId))return;w&&j(!1);const z=window.setTimeout(()=>{Ss({logId:u.logId,tab:u.tab,source:"virtualizer"})},0);return()=>window.clearTimeout(z)},[w,t,u]);const N=l.useCallback(()=>{w&&j(z=>!z)},[w]),C=l.useMemo(()=>{let z=0,H=0,ee=null,U=!1;for(const Z of t)Z.log.inputTokens!==null&&(z+=Z.log.inputTokens,U=!0),Z.log.outputTokens!==null&&(H+=Z.log.outputTokens,U=!0),Z.log.elapsedMs!==null&&(ee=ee===null?Z.log.elapsedMs:Math.max(ee,Z.log.elapsedMs));return{totalInput:z,totalOutput:H,hasTokens:U,maxElapsed:ee}},[t,f]),E=d%2===0?"bg-white/[0.008]":"bg-cyan-300/[0.008]",A=C.maxElapsed!==null&&r>0&&C.maxElapsed>r*1e3,I=l.useMemo(()=>{const z=new Map;for(const H of t){const ee=Dl(H.log);ee.length>0&&z.set(H.log.id,ee)}return z},[t]),[R,k]=l.useState(0),M=l.useRef(null);l.useEffect(()=>{const z=M.current;if(!z)return;let H=0;const ee=new ResizeObserver(()=>{window.cancelAnimationFrame(H),H=window.requestAnimationFrame(()=>k(U=>U+1))});return ee.observe(z),()=>{ee.disconnect(),window.cancelAnimationFrame(H)}},[]);const O=t[0]?.log.id??d,$=`Turn ${String(d+1)}`,K=l.useMemo(()=>Ll(O%12),[O]),Q=l.useMemo(()=>({contentVisibility:"auto",containIntrinsicSize:b?"48px":"160px"}),[b]);return n.jsx("div",{ref:M,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(O)}`,className:P("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?n.jsxs("div",{"data-nav-id":`turn-collapsed-${String(O)}`,"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:z=>{(z.key==="Enter"||z.key===" ")&&(z.preventDefault(),N())},children:[n.jsxs("div",{className:"w-6 shrink-0 flex flex-col items-center pt-1.5 pb-1.5",children:[n.jsx("div",{className:"flex justify-center h-[calc(0.75rem-8px)]"}),n.jsx(K,{className:P("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)]")}),n.jsx("div",{className:"flex-1 flex justify-center min-h-0",children:n.jsx("div",{className:"w-px bg-muted-foreground/14 h-full"})}),g?n.jsx(K,{className:P("size-3.5 animate-crab-settle text-amber-400","drop-shadow-[0_0_4px_rgba(251,191,36,0.45)]")}):n.jsx("span",{title:"Current end of open turn","aria-label":"Current end of open turn",children:n.jsx(K,{className:P("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)]")})})]}),t.length>1&&n.jsxs("div",{className:P("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",E),children:[n.jsx("span",{className:"font-mono text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground/70",children:$}),n.jsxs("span",{className:"text-blue-300/85 font-mono font-semibold tabular-nums shrink-0",title:`Log IDs ${String(t[0]?.log.id??"?")} ~ ${String(t[f]?.log.id??"?")}`,children:["#",t[0]?.sessionLogNumber??"?"," ~ #",t[f]?.sessionLogNumber??"?"]}),n.jsxs("span",{className:"text-muted-foreground shrink-0",children:[t.length," request",t.length>1?"s":""]}),C.maxElapsed!==null&&n.jsx(Ts,{children:n.jsxs(dt,{children:[n.jsx(ut,{asChild:!0,children:n.jsxs("span",{className:P("flex items-center gap-1 shrink-0",A?"text-amber-400":"text-muted-foreground"),children:[n.jsx(en,{className:"size-3"}),n.jsx("span",{className:"font-mono tabular-nums",children:Ra(C.maxElapsed)}),A&&n.jsx(bn,{className:"size-3","aria-label":"Slow response"})]})}),n.jsx(mt,{children:A?`Slow response: ${Ra(C.maxElapsed)} exceeds ${Ra(r*1e3)}`:"Slowest request in this turn"})]})}),C.hasTokens&&n.jsxs("span",{className:"flex items-center gap-1 shrink-0",children:[n.jsx(Vs,{className:"size-3 text-muted-foreground"}),n.jsxs("span",{className:"font-mono tabular-nums",children:[n.jsxs("span",{className:"text-blue-400",children:["IN ",Ie(C.totalInput)]})," / ",n.jsxs("span",{className:"text-amber-400",children:["OUT ",Ie(C.totalOutput)]})]})]}),n.jsx("span",{className:"flex-1 min-w-0"}),n.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:n.jsx(gt,{className:"size-4 shrink-0"})})]})]}):t.map((z,H)=>{const{log:ee,stopReason:U}=z,Z=H===0;return n.jsxs("div",{className:"flex items-stretch",children:[n.jsx(FN,{stopReason:U,isPending:ee.responseStatus===null,isFirst:H===0,isTurnStart:Z,isOnlyEntry:y,isOpenTurnTail:H===f&&!g,crabIndex:ee.id%12,collapsible:w&&Z,onToggle:N}),n.jsx("div",{className:P("flex-1 min-w-0 mb-0.5 rounded-[8px]",E),children:n.jsx(zN,{log:ee,displayNumber:z.sessionLogNumber,viewMode:s,strip:o,slowResponseThresholdSeconds:r,timeDisplayFormat:m,cacheTrend:a?.get(ee.id)??null,showClientMetadata:p,toolEvents:I.get(ee.id),onCompareWithPrevious:c.has(ee.id)?i:void 0})})]},ee.id)})})}),eC=24,tC=132,nC=8;function sC(e){return e>eC}function oC(e){const t=new Map;for(let s=0;s<e.length;s++){const o=e[s];if(o!==void 0)for(const r of o.entries)t.set(r.log.id,s)}return t}function Ff(e,t,s){return n.jsx(QN,{entries:e.entries,viewMode:t.viewMode,strip:t.strip,slowResponseThresholdSeconds:t.slowResponseThresholdSeconds,timeDisplayFormat:t.timeDisplayFormat,cacheTrends:t.cacheTrends,onCompareWithPrevious:t.onCompareWithPrevious,comparisonPredecessors:t.comparisonPredecessors,turnIndex:e.turnIndex,pendingFocusRequest:s,showLogClientMetadata:t.showLogClientMetadata},e.turnIndex)}function rC(e){return sC(e.turnGroups.length)?n.jsx(aC,{...e}):n.jsx(n.Fragment,{children:e.turnGroups.map(t=>Ff(t,e))})}function aC(e){const{turnGroups:t}=e,[s,o]=l.useState(null),r=J5({count:t.length,estimateSize:()=>tC,overscan:nC,getItemKey:i=>t[i]?.turnIndex??i}),a=l.useMemo(()=>oC(t),[t]);return l.useEffect(()=>{const i=c=>{const d=Jr(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(sn,i),()=>{window.removeEventListener(sn,i)}},[a,r]),n.jsx("div",{className:"relative w-full",style:{height:`${r.getTotalSize()}px`},"data-virtualized-turn-list":"true",children:r.getVirtualItems().map(i=>{const c=t[i.index];if(c===void 0)return null;const d=s!==null&&s.turnIndex===i.index?s:void 0;return n.jsx("div",{"data-index":i.index,ref:r.measureElement,className:"absolute left-0 top-0 w-full",style:{transform:`translateY(${i.start}px)`},children:Ff(c,e,d)},i.key)})})}const zl=me(["episode","procedure","preference","project-fact"]),iC=me(["draft","promoted","failed"]),Bf=_({source:ae("agent-inspector"),sessionId:x(),logIds:V(Mt),project:x().nullable(),models:V(x())}),lC=_({redacted:Ce(),patterns:V(x())}),co=_({id:x(),type:zl,title:x(),content:x(),tags:V(x()),source:ae("agent-inspector"),sessionId:x(),logIds:V(Mt),evidence:Bf,status:iC,createdAt:x(),updatedAt:x(),openClawMemoryId:x().nullable(),error:x().nullable(),redaction:lC});_({idempotencyKey:x(),type:zl,title:x(),content:x(),tags:V(x()),source:ae("agent-inspector"),project:x().nullable(),evidence:Bf});const cC=_({id:x(),type:zl.or(x()),title:x(),content:x(),score:T().nullable(),source:x().nullable(),project:x().nullable(),evidence:Fs().optional()});_({results:V(cC),warning:x().nullable()});const dC=_({candidates:V(co)}),uC=_({candidate:co}),mC=_({error:x().optional(),candidate:co.optional()}),pC=_({candidate:co}),fC=3e4,hC=15e3,xC=15e3,gC={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 Ci(e){return e===null?"-":e<1e3?`${String(e)}ms`:`${(e/1e3).toFixed(1)}s`}function bC(e,t,s){return e===null||t===null?null:_r(e,t,s)}function vC(e){return`${String(e)} candidate${e===1?"":"s"}`}function Uf(e){return`log-${String(e)}`}function qf(e){const t=Uf(e),s=document.getElementById(t);window.history.replaceState(null,"",`#${t}`),s instanceof HTMLElement&&(s.scrollIntoView({block:"center",behavior:"smooth"}),s.focus({preventScroll:!0}))}function yC(e){for(const t of e)if(t.responseStatus!==null&&t.responseStatus>=400)return t;return null}function wC(e){let t=null,s=-1;for(const o of e)o.elapsedMs!==null&&o.elapsedMs>s&&(t=o,s=o.elapsedMs);return t}function jC(e){for(const t of e)if(Dl(t).length>0)return t;return null}function SC(e){const t=new Map;for(let s=0;s<e.length;s+=1){const o=e[s];o!==void 0&&t.set(o.id,s+1)}return t}function fs(e,t){return String(t.get(e)??e)}function NC(e){const t=[{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=jC(e.logs);e.summary.toolCallCount>0&&s!==null&&t.push({kind:"tool",title:`${String(e.summary.toolCallCount)} tool call${e.summary.toolCallCount===1?"":"s"}`,detail:`First tool evidence at #${fs(s.id,e.displayNumberByLogId)}`,logId:s.id});const o=yC(e.logs);o!==null&&t.push({kind:"failure",title:`Failure #${String(o.responseStatus)}`,detail:`First failed request is #${fs(o.id,e.displayNumberByLogId)}`,logId:o.id});const r=wC(e.logs);if(r!==null&&e.summary.maxElapsedMs!==null&&t.push({kind:"slow",title:`Slowest ${Ci(e.summary.maxElapsedMs)}`,detail:`Max latency observed at #${fs(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;t.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 t}function CC(e){switch(e){case"session":return n.jsx(kr,{className:"size-3.5 text-blue-400"});case"tool":return n.jsx(no,{className:"size-3.5 text-sky-400/70"});case"slow":return n.jsx(en,{className:"size-3.5 text-amber-400"});case"failure":return n.jsx(Tu,{className:"size-3.5 text-destructive"});case"candidate":return n.jsx(_u,{className:"size-3.5 text-emerald-400"})}}function kC({insights:e}){return e.length===0?null:n.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(t=>n.jsxs("button",{type:"button",className:P("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:()=>{t.logId!==null&&qf(t.logId)},disabled:t.logId===null,children:[CC(t.kind),n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"block truncate font-medium text-foreground/90",children:t.title}),n.jsx("span",{className:"block truncate font-mono text-[10px]",children:t.detail})]})]},`${t.kind}-${t.title}`))})}function _C(e){switch(e){case"draft":return"Draft";case"promoted":return"Promoted";case"failed":return"Failed"}}function TC(e,t){if(t)return"Promoting";switch(e.status){case"draft":return"Promote";case"failed":return"Retry";case"promoted":return"Promoted"}}function EC(e){return e.redaction.redacted?`Redacted ${e.redaction.patterns.join(", ")}`:"No sensitive pattern matched"}function RC(e,t){const s=e.replace(/\s+/g," ").trim();return s.length<=t?s:`${s.slice(0,t-3)}...`}function MC(e,t){const s=e[0],o=e[e.length-1];if(s===void 0)return"No evidence logs";const r=fs(s,t);return o===void 0||s===o?`#${r}`:`#${r}-#${fs(o,t)}`}function Zc(e){return e.join(", ")}function AC(e){return e.split(",").map(t=>t.trim()).filter(t=>t.length>0)}function IC({candidate:e,isPromoting:t,isUpdating:s,onPromoteCandidate:o,onUpdateCandidate:r,displayNumberByLogId:a}){const[i,c]=l.useState(!1),[d,m]=l.useState(e.type),[u,p]=l.useState(e.title),[f,h]=l.useState(e.content),[g,v]=l.useState(Zc(e.tags)),[y,w]=l.useState(null),b=e.status!=="promoted",j=e.status!=="promoted",S=l.useCallback(()=>{m(e.type),p(e.title),h(e.content),v(Zc(e.tags)),w(null)},[e.content,e.tags,e.title,e.type]),N=l.useCallback(async()=>{const C=u.trim(),E=f.trim(),A=AC(g);if(C.length===0){w("Title is required.");return}if(E.length===0){w("Content is required.");return}if(A.length===0){w("At least one tag is required.");return}w(null),await r(e.id,{type:d,title:C,content:E,tags:A})&&c(!1)},[e.id,f,g,u,d,r]);return i?n.jsx("div",{className:"border border-border bg-card shadow-sm rounded-[8px] px-2.5 py-2",children:n.jsxs("div",{className:"grid gap-2",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsxs("select",{value:d,disabled:s,onChange:C=>{const E=co.shape.type.safeParse(C.currentTarget.value);E.success&&m(E.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:[n.jsx("option",{value:"episode",children:"episode"}),n.jsx("option",{value:"procedure",children:"procedure"}),n.jsx("option",{value:"preference",children:"preference"}),n.jsx("option",{value:"project-fact",children:"project-fact"})]}),n.jsx("input",{value:u,disabled:s,onChange:C=>p(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"})]}),n.jsx("textarea",{value:f,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"}),n.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"}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-muted-foreground",children:[n.jsx(sc,{className:"size-3"}),"Saving reruns Inspector redaction before promotion."]}),n.jsx("span",{className:"flex-1"}),y!==null&&n.jsx("span",{className:"text-[10px] text-destructive",children:y}),n.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:[n.jsx(so,{className:"size-3.5"}),"Cancel"]}),n.jsxs(te,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:s,onClick:()=>{N()},children:[s?n.jsx(Rt,{className:"size-3.5 animate-spin"}):n.jsx(v1,{className:"size-3.5"}),"Save"]})]})]})}):n.jsxs("div",{className:"rounded-md border border-border/80 bg-background/60 px-2.5 py-2",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(_e,{variant:"outline",className:"h-5 px-1.5 text-[10px] font-mono",children:e.type}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium",title:e.title,children:e.title}),n.jsx(_e,{variant:"outline",className:P("h-5 shrink-0 px-1.5 text-[10px] font-mono",gC[e.status]),children:_C(e.status)})]}),n.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",title:e.content,children:RC(e.content,360)}),n.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] text-muted-foreground",children:[n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx(yg,{className:"size-3"}),MC(e.logIds,a)]}),n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx(sc,{className:"size-3"}),EC(e)]}),e.status==="promoted"&&n.jsxs("span",{className:"inline-flex items-center gap-1 text-emerald-500",children:[n.jsx(Qa,{className:"size-3"}),e.openClawMemoryId??"OpenClaw"]}),e.status==="failed"&&e.error!==null&&n.jsxs("span",{className:"inline-flex items-center gap-1 text-destructive",children:[n.jsx(Tu,{className:"size-3"}),e.error]})]}),n.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5",children:[e.logIds.map(C=>{const E=fs(C,a);return n.jsxs("a",{href:`#${Uf(C)}`,onClick:A=>{A.preventDefault(),qf(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 ${E}`,title:`Log ID ${String(C)}`,children:["#",E]},C)}),n.jsx("span",{className:"flex-1"}),j&&n.jsxs(te,{type:"button",variant:"ghost",size:"sm",className:"h-6 gap-1.5 px-2 text-[10px]",disabled:s||t,onClick:()=>c(!0),children:[n.jsx(Lu,{className:"size-3"}),"Review"]}),n.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||t||s,children:[t?n.jsx(Rt,{className:"size-3 animate-spin"}):b?n.jsx(tg,{className:"size-3"}):n.jsx(Qa,{className:"size-3"}),TC(e,t)]})]})]})}function PC({candidates:e,promotingCandidateIds:t,updatingCandidateIds:s,onPromoteCandidate:o,onUpdateCandidate:r,displayNumberByLogId:a}){return e.length===0?null:n.jsx("div",{className:"mt-2 grid gap-1.5",children:e.map(i=>n.jsx(IC,{candidate:i,isPromoting:t.has(i.id),isUpdating:s.has(i.id),onPromoteCandidate:o,onUpdateCandidate:r,displayNumberByLogId:a},i.id))})}function LC({logs:e,scopeId:t,slowResponseThresholdSeconds:s,showRollupMetrics:o,timeDisplayFormat:r}){const[a,i]=l.useState([]),[c,d]=l.useState(!0),[m,u]=l.useState({status:"idle",error:null}),[p,f]=l.useState(()=>new Set),[h,g]=l.useState(()=>new Set),v=a.length>0,y=l.useMemo(()=>ZN(e,s,a.length),[a.length,e,s]),w=l.useMemo(()=>SC(e),[e]),b=l.useMemo(()=>NC({logs:e,scopeId:t,summary:y,candidates:a,displayNumberByLogId:w}),[a,w,e,t,y]),j=o||y.maxElapsedMs!==null,S=l.useMemo(()=>bC(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 A=await Be(`/api/knowledge/sessions/${encodeURIComponent(t)}/candidates`,dC,fC,{method:"POST"},I=>`Candidate generation failed with ${String(I.status)}`);i(A.candidates),d(A.candidates.length>0),u(A.candidates.length>0?{status:"ready",error:null}:{status:"failed",error:"No candidate was generated for this trace scope."})}catch(A){u({status:"failed",error:A instanceof Error?A.message:"Candidate response was invalid"})}})())},[m.status,e.length,t]),C=l.useCallback(A=>{f(I=>{if(I.has(A))return I;const R=new Set(I);return R.add(A),R}),(async()=>{try{const I=await On(`/api/knowledge/candidates/${encodeURIComponent(A)}/promote`,hC,{method:"POST"}),R=await I.json().catch(()=>null),k=uC.safeParse(R);if(I.ok&&k.success){i(O=>O.map($=>$.id===k.data.candidate.id?k.data.candidate:$)),u({status:"ready",error:null});return}const M=mC.safeParse(R);M.success&&M.data.candidate!==void 0&&i(O=>O.map($=>$.id===M.data.candidate?.id?M.data.candidate:$)),u({status:"failed",error:M.success?M.data.error??"Candidate promotion failed":`Candidate promotion failed with ${String(I.status)}`})}catch(I){u({status:"failed",error:I instanceof Error?I.message:"Candidate promotion failed"})}finally{f(I=>{const R=new Set(I);return R.delete(A),R})}})()},[]),E=l.useCallback(async(A,I)=>{g(R=>{if(R.has(A))return R;const k=new Set(R);return k.add(A),k});try{const R=await Be(`/api/knowledge/candidates/${encodeURIComponent(A)}`,pC,xC,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(I)},k=>`Candidate update failed with ${String(k.status)}`);return i(k=>k.map(M=>M.id===R.candidate.id?R.candidate:M)),u({status:"ready",error:null}),!0}catch(R){return u({status:"failed",error:R instanceof Error?R.message:"Candidate update failed"}),!1}finally{g(R=>{const k=new Set(R);return k.delete(A),k})}},[]);return e.length===0?null:n.jsxs("section",{className:"border border-border bg-card shadow-sm mb-2 rounded-[8px] px-3 py-2",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 text-xs",children:[o&&n.jsxs("span",{className:"inline-flex items-center gap-1.5 font-semibold text-foreground",children:[n.jsx(kr,{className:"size-3.5 text-blue-400"}),y.llmCallCount," LLM"]}),n.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[n.jsx(no,{className:"size-3.5 text-sky-400/70"}),y.toolCallCount," tools"]}),o&&n.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[n.jsx(Vs,{className:"size-3.5 text-emerald-400"}),n.jsxs("span",{className:"font-mono",children:[Ie(y.totalInputTokens)," / ",Ie(y.totalOutputTokens)]})]}),(y.totalCacheCreationInputTokens>0||y.totalCacheReadInputTokens>0)&&n.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[n.jsx(Vs,{className:"size-3.5 text-purple-400"}),n.jsxs("span",{className:"font-mono",children:["KV Cache +",Ie(y.totalCacheCreationInputTokens)," / ~",Ie(y.totalCacheReadInputTokens)]})]}),j&&n.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[n.jsx(en,{className:"size-3.5"}),o&&n.jsx("span",{className:"font-mono",children:Ci(y.totalElapsedMs)}),y.maxElapsedMs!==null&&n.jsxs("span",{className:"font-mono text-muted-foreground/70",children:["max ",Ci(y.maxElapsedMs)]})]}),o&&S!==null&&n.jsx("span",{className:"font-mono text-muted-foreground/70",children:S}),(y.failedCallCount>0||y.pendingCallCount>0||y.slowCallCount>0)&&n.jsxs("span",{className:"inline-flex items-center gap-1.5 text-amber-400",children:[n.jsx(bn,{className:"size-3.5"}),n.jsxs("span",{className:"font-mono",children:[y.failedCallCount," fail / ",y.pendingCallCount," pending /"," ",y.slowCallCount," slow"]})]}),n.jsx("span",{className:"flex-1"}),v&&n.jsx(_e,{variant:"outline",className:"h-6 px-2 text-[10px] font-mono",children:vC(y.knowledgeCandidateCount)}),n.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"?n.jsx(Ue,{className:"size-3.5 animate-spin"}):n.jsx(_u,{className:"size-3.5"}),"Candidate"]}),v&&n.jsx(te,{type:"button",variant:"ghost",size:"icon",className:"size-7 text-muted-foreground",onClick:()=>d(A=>!A),"aria-expanded":c,"aria-label":c?"Collapse memory candidates":"Expand memory candidates",children:c?n.jsx(Xe,{className:"size-3.5"}):n.jsx(gt,{className:"size-3.5"})})]}),m.status==="failed"&&n.jsx("p",{className:"mt-2 text-xs text-destructive",children:m.error}),n.jsx(kC,{insights:b}),c&&n.jsx(PC,{candidates:a,promotingCandidateIds:p,updatingCandidateIds:h,onPromoteCandidate:C,onUpdateCandidate:E,displayNumberByLogId:w})]})}function OC(e){let t=0,s=0;for(const o of e)o.inputTokens!==null&&(t+=o.inputTokens),o.outputTokens!==null&&(s+=o.outputTokens);return{totalInputTokens:t,totalOutputTokens:s}}function DC(e){const t=new Map;for(const s of e){if(s.model===null)continue;const o=Yj(s.model);if(o==="unknown")continue;let r=t.get(o);r===void 0&&(r=new Set,t.set(o,r)),r.add(s.model)}return[...t.entries()].map(([s,o])=>({provider:s,models:[...o]}))}function zC(e){for(const t of e){const s=t.clientPid;if(s!=null)return s}return null}function $C(e){for(const t of e){const s=t.clientProjectFolder;if(s!=null&&s!=="")return s}return null}const FC=l.memo(function({group:e,viewMode:t="simple",strip:s,slowResponseThresholdSeconds:o,cacheTrends:r,onCompareWithPrevious:a,comparisonPredecessors:i,onClearGroup:c,showClientIdentity:d=!0,showProcessMetadata:m=!0,showLogClientMetadata:u=!0,defaultExpanded:p=!1,timeDisplayFormat:f,expanded:h,onExpandedChange:g}){const[v,y]=l.useState(p),w=h??v,b=l.useCallback(k=>{if(g!==void 0){g(k);return}y(k)},[g]);l.useEffect(()=>{!p||h!==void 0||y(!0)},[h,p]);const j=l.useMemo(()=>OC(e.logs),[e.logs]),S=l.useMemo(()=>DC(e.logs),[e.logs]),N=e.logs[0]?.timestamp??new Date().toISOString(),C=e.logs[e.logs.length-1]?.timestamp??new Date().toISOString(),E=e.logs.some(k=>k.responseStatus===null),A=l.useMemo(()=>zC(e.logs),[e.logs]),I=l.useMemo(()=>$C(e.logs),[e.logs]),R=l.useMemo(()=>Ni(e.logs),[e.logs]);return l.useEffect(()=>{const k=M=>{const O=Jr(M);O!==null&&e.logs.some($=>$.id===O.logId)&&b(!0)};return window.addEventListener(sn,k),()=>{window.removeEventListener(sn,k)}},[e.logs,b]),n.jsxs("div",{className:"mb-1.5",children:[n.jsx(R5,{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:E,userAgent:e.logs[0]?.userAgent??null,clientPid:A,clientProjectFolder:I,showClientIdentity:d,showProcessMetadata:m,timeDisplayFormat:f,onClear:()=>c(e.logs.map(k=>k.id))}),w&&n.jsxs("div",{children:[n.jsx(LC,{logs:e.logs,scopeId:e.conversationId,slowResponseThresholdSeconds:o,showRollupMetrics:!1,timeDisplayFormat:f}),n.jsx(rC,{turnGroups:R,viewMode:t,strip:s,slowResponseThresholdSeconds:o,timeDisplayFormat:f,cacheTrends:r,onCompareWithPrevious:a,comparisonPredecessors:i,showLogClientMetadata:u})]})]})}),BC="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",UC="m-0 min-w-0 flex-1 overflow-x-auto font-mono text-xs text-foreground sm:text-sm";function qC(e){return[`PROXY_BASE_URL=${e.proxy}`,`MCP_URL=${e.mcp}`]}function HC(e){return e==="full"}function VC(e){return e==="raw"}function WC(e,t){const s=t>0;return{redacted:s,raw:s&&HC(e)}}function GC(e,t){const s=e[0],o=e[e.length-1];return s===void 0||o===void 0?null:_r(s.timestamp,o.timestamp,t)}function KC(e){return e.error!==null&&e.error!==void 0&&e.error.length>0?!0:e.responseStatus!==null&&e.responseStatus>=400}function YC(e){const t=new Set;for(const o of e)o.model!==null&&o.model.length>0&&t.add(o.model);const s=[...t].sort();return s.length===0?"Model unknown":s.length===1?s[0]??"Model unknown":`${s.length} models`}function JC(e){const t=new Set;for(const o of e)o.providerName!==null&&o.providerName!==void 0&&o.providerName.length>0&&t.add(o.providerName);const s=[...t].sort();return s.length===0?"Provider unknown":s.length===1?s[0]??"Provider unknown":`${s.length} providers`}function XC(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 t=Math.round(e/1e3),s=Math.floor(t/60),o=t%60;return`${s}m ${o}s`}function ZC(e,t){return`${Ie(e)} in / ${Ie(t)} out`}function QC(e,t){if(e.length===0)return 0;if(t.length===0)return Ni(e).length;let s=0;for(const o of t)s+=Ni(o.logs).length;return s}function ek({stopReason:e,pending:t,lastFailureLogNumber:s}){if(t>0)return{label:"In flight",detail:`${t} request${t===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 tk(e){if(e===null)return!1;const t=e.toLowerCase();return t.includes("abort")||t.includes("cancel")||t.includes("client disconnected")||t.includes("stream disconnected")||t.includes("connection closed")}function nk({pending:e,failures:t,lengthStops:s,stopReason:o,lastFailure:r}){if(r!==null&&(r.status===499||tk(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(t>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 sk({logs:e,conversationGroups:t,isLoading:s,timeDisplayFormat:o,slowResponseThresholdSeconds:r}){let a=0,i=0,c=0,d=0,m=0,u=0,p=null,f=null,h=null,g=null,v=null,y=0,w=0,b=0,j=null;const S=r*1e3;for(let I=0;I<e.length;I+=1){const R=e[I];if(R===void 0)continue;const k=I+1,M=kf(R);M!==null&&(p=M),M==="length"&&(d+=1),KC(R)&&(a+=1,f=k,h={logNumber:k,status:R.responseStatus,error:R.error??null}),R.responseStatus===null&&(i+=1),r>0&&R.elapsedMs!==null&&R.elapsedMs>=S&&(c+=1),R.inputTokens!==null&&(m+=R.inputTokens),R.outputTokens!==null&&(u+=R.outputTokens),R.elapsedMs!==null&&(g===null||R.elapsedMs>g)&&(g=R.elapsedMs,v=k);const O=R.inputTokens??0,$=R.outputTokens??0,K=O+$;K>y&&(y=K,w=O,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",E=ek({stopReason:p,pending:i,lastFailureLogNumber:f}),A=nk({pending:i,failures:a,lengthStops:d,stopReason:p,lastFailure:h});return{status:N,statusLabel:C,modelLabel:YC(e),providerLabel:JC(e),requests:e.length,turns:QC(e,t),failures:a,pending:i,slow:c,lengthStops:d,timeRange:GC(e,o),tokenLabel:`${Ie(m)} in / ${Ie(u)} out`,finishLabel:E.label,finishDetail:E.detail,finishTone:E.tone,outcomeLabel:A.label,outcomeDetail:A.detail,outcomeTone:A.tone,slowestLabel:g===null?"n/a":XC(g),slowestDetail:v===null?"Latency pending":`Request #${v}`,heaviestDetail:j===null?"Tokens pending":`#${j} ${ZC(w,b)}`}}function ok({pinnedSessionId:e,selectedSession:t,sessions:s,logs:o}){if(e!==void 0){const i=o.filter(c=>c.sessionId===e);return i.length===0?null:{label:e,sessionId:e,logs:i,showBackLink:!0}}if(t!=="__all__"){const i=o.filter(c=>c.sessionId===t);return i.length===0?null:{label:t,sessionId:t,logs:i,showBackLink:!0}}const r=s.length===1?s[0]??null:null;return r!==null&&o.every(c=>c.sessionId===r)?{label:r,sessionId:r,logs:[...o],showBackLink:!1}:s.length===0&&o.length>0&&o.every(i=>i.sessionId===null)?{label:"Visible requests",sessionId:null,logs:[...o],showBackLink:!1}:null}function rk({logs:e,pagination:t}){if(t.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 t.total===null?`Showing ${e.length} logs (${r})`:t.total<=e.length?`Showing all ${t.total} logs`:`Showing ${e.length} of ${t.total} logs (${r})`}function Ys({...e}){return n.jsx(gp,{"data-slot":"select",...e})}function hr({...e}){return n.jsx(wp,{"data-slot":"select-value",...e})}function Js({className:e,size:t="default",children:s,...o}){return n.jsxs(vp,{"data-slot":"select-trigger","data-size":t,className:P("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,n.jsx(jp,{asChild:!0,children:n.jsx(Xe,{className:"size-4 opacity-50"})})]})}function Xs({className:e,children:t,position:s="popper",align:o="center",...r}){return n.jsx(Np,{children:n.jsxs(Cp,{"data-slot":"select-content",className:P("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:[n.jsx(ak,{}),n.jsx(Rp,{className:P("p-1",s==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),n.jsx(ik,{})]})})}function it({className:e,children:t,...s}){return n.jsxs(Pp,{"data-slot":"select-item",className:P("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:[n.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:n.jsx(Dp,{children:n.jsx($e,{className:"size-4"})})}),n.jsx(Lp,{children:t})]})}function ak({className:e,...t}){return n.jsx(zp,{"data-slot":"select-scroll-up-button",className:P("flex cursor-default items-center justify-center py-1",e),...t,children:n.jsx(Ji,{className:"size-4"})})}function ik({className:e,...t}){return n.jsx($p,{"data-slot":"select-scroll-down-button",className:P("flex cursor-default items-center justify-center py-1",e),...t,children:n.jsx(Xe,{className:"size-4"})})}const lk=me(["critical","warning","notice"]),ck=me(["open"]),dk=me(["proxy","tool-schema","run","group"]),Hf=me(["request-failure","request-timeout","slow-response","tool-schema","run-failure","group-failure","group-incomplete"]),uk=me(["log","session","run","group"]),mk=me(["anthropic","openai","unknown"]),pk=_({kind:uk,id:x(),label:x(),href:x().nullable()}),fk=_({id:x(),fingerprint:x(),severity:lk,category:Hf,source:dk,status:ck,title:x(),message:x(),count:T().int().positive(),firstSeenAt:x(),lastSeenAt:x(),logIds:V(Mt),sessionIds:V(x()),runIds:V(x()),groupIds:V(x()),provider:x().nullable(),model:x().nullable(),apiFormat:mk.nullable(),evidence:V(pk),metadata:qe(x(),Je)}),hk=_({category:Hf,count:T().int().nonnegative()}),Vf=_({total:T().int().nonnegative(),open:T().int().nonnegative(),critical:T().int().nonnegative(),warning:T().int().nonnegative(),notice:T().int().nonnegative(),byCategory:V(hk)}),xk=_({alerts:V(fk),total:T().int().nonnegative(),limit:T().int().positive(),summary:Vf}),gk=8e3,bk=1e4;function vk(e){const t=new URLSearchParams;e.severity!==void 0&&t.set("severity",e.severity),e.category!==void 0&&t.set("category",e.category),e.source!==void 0&&t.set("source",e.source),e.limit!==void 0&&t.set("limit",String(e.limit));const s=t.toString();return s.length>0?`/api/alerts?${s}`:"/api/alerts"}function yk(e,t){const s=$t(t?vk(e):null,o=>Be(o,xk,bk));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 wk(){const e=$t("/api/alerts/summary",t=>Be(t,Vf,gk),{refreshInterval:5e3,revalidateOnFocus:!0});return{summary:e.data??null,isLoading:e.isLoading,error:e.error,mutate:e.mutate}}const uo="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",jk=["request-failure","request-timeout","slow-response","tool-schema","run-failure","group-failure","group-incomplete"];function Wf(e){switch(e){case"critical":return"Critical";case"warning":return"Warning";case"notice":return"Notice"}}function Sk(e){switch(e){case"proxy":return"Proxy";case"tool-schema":return"Tool schema";case"run":return"Run";case"group":return"Group"}}function $l(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 Nk(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 Ck(e){switch(e){case"critical":return"bg-status-danger";case"warning":return"bg-status-watch";case"notice":return"bg-status-cool"}}function kk(e){switch(e){case"critical":return"text-status-danger";case"warning":return"text-status-watch";case"notice":return"text-status-cool"}}function _k(e){switch(e){case"request-failure":case"run-failure":case"group-failure":return n.jsx(M1,{className:"size-3.5"});case"request-timeout":case"slow-response":return n.jsx(Z0,{className:"size-3.5"});case"tool-schema":return n.jsx(bn,{className:"size-3.5"});case"group-incomplete":return n.jsx(w0,{className:"size-3.5"})}}function ki(e){const t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat(void 0,{month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t)):e}function ht(e){return e.toLocaleString()}function Gf(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 Tk(e,t){const s={limit:100};return e!=="all"&&(s.severity=e),t!=="all"&&(s.category=t),s}function Ek(e,t){if(t!==null){const s=e.find(o=>o.id===t);if(s!==void 0)return s}return e[0]??null}function _o({label:e,count:t,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 n.jsxs("div",{className:P("rounded-md border px-3 py-2",o),children:[n.jsx("div",{className:"text-[10px] font-semibold uppercase opacity-75",children:e}),n.jsx("div",{className:"mt-1 text-lg font-semibold leading-none",children:ht(t)})]})}function To({value:e,active:t,label:s,count:o,onClick:r}){return n.jsxs(te,{type:"button",variant:t?"secondary":"ghost",size:"sm","aria-pressed":t,onClick:()=>r(e),className:"h-7 px-2",children:[s,o!==null?n.jsx(_e,{variant:"outline",children:ht(o)}):null]})}function Rk({category:e,active:t,count:s,onClick:o}){return n.jsxs(te,{type:"button",variant:t?"secondary":"ghost",size:"sm","aria-pressed":t,onClick:()=>o(e),className:"h-7 px-2",children:[_k(e),$l(e),n.jsx(_e,{variant:"outline",children:ht(s)})]})}function Mk({alerts:e,selectedAlertId:t,isLoading:s,error:o,onSelect:r}){return s?n.jsxs("div",{className:"flex min-h-56 items-center justify-center rounded-md border border-dashed border-border text-xs text-muted-foreground",children:[n.jsx(Ue,{className:"mr-2 size-3.5 animate-spin"}),"Loading alerts..."]}):o!==void 0?n.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?n.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."}):n.jsx("div",{className:"min-h-0 space-y-2 overflow-y-auto pr-1",children:e.map(a=>{const i=a.id===t;return n.jsxs("button",{type:"button",onClick:()=>r(a.id),className:P("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:[n.jsxs("div",{className:"flex items-start justify-between gap-3",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsx("span",{className:P("size-2 rounded-full",Ck(a.severity))}),n.jsx("span",{className:P("text-xs font-semibold",kk(a.severity)),children:Wf(a.severity)}),n.jsx("span",{className:"truncate text-xs text-muted-foreground",children:$l(a.category)})]}),n.jsx("div",{className:"mt-1 text-sm font-semibold leading-snug",children:a.title}),n.jsx("div",{className:"mt-1 line-clamp-2 text-xs text-muted-foreground",children:a.message})]}),a.count>1?n.jsxs(_e,{variant:"outline",className:"shrink-0",children:["x",ht(a.count)]}):null]}),n.jsxs("div",{className:"mt-2 flex min-w-0 items-start justify-between gap-2 text-[11px] text-muted-foreground",children:[n.jsx("span",{className:"min-w-0 leading-snug",children:Gf(a)}),n.jsx("span",{className:"shrink-0",children:ki(a.lastSeenAt)})]})]},a.id)})})}function Ak({alert:e,onNavigate:t}){return e.evidence.length===0?n.jsx("span",{className:"text-xs text-muted-foreground",children:"No linked evidence"}):n.jsx("div",{className:"flex flex-wrap gap-2",children:e.evidence.map(s=>s.href===null?n.jsx(_e,{variant:"outline",children:s.label},`${s.kind}:${s.id}`):n.jsx(_e,{variant:"outline",asChild:!0,children:n.jsx("a",{href:s.href,onClick:t,children:s.label})},`${s.kind}:${s.id}`))})}function Ik({alert:e,onNavigate:t}){return e===null?n.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."}):n.jsxs("div",{className:"min-h-0 overflow-y-auto rounded-md border border-border bg-background/70",children:[n.jsx("div",{className:P("border-b px-4 py-3",Nk(e.severity)),children:n.jsxs("div",{className:"flex items-start justify-between gap-3",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx(_e,{variant:"outline",children:Wf(e.severity)}),n.jsx(_e,{variant:"outline",children:Sk(e.source)}),n.jsx(_e,{variant:"outline",children:$l(e.category)})]}),n.jsx("h3",{className:"mt-3 text-base font-semibold",children:e.title}),n.jsx("p",{className:"mt-1 text-sm opacity-85",children:e.message})]}),e.count>1?n.jsxs(_e,{variant:"outline",className:"shrink-0",children:[ht(e.count)," hits"]}):null]})}),n.jsxs("div",{className:"space-y-4 p-4",children:[n.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[n.jsx(dn,{label:"Target",value:Gf(e)}),n.jsx(dn,{label:"Last seen",value:ki(e.lastSeenAt)}),n.jsx(dn,{label:"First seen",value:ki(e.firstSeenAt)}),n.jsx(dn,{label:"Protocol",value:e.apiFormat??"n/a"})]}),n.jsxs("div",{children:[n.jsx("div",{className:"mb-2 text-xs font-semibold text-muted-foreground",children:"Evidence"}),n.jsx(Ak,{alert:e,onNavigate:t})]}),n.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[n.jsx(dn,{label:"Logs",value:e.logIds.length===0?"n/a":ht(e.logIds.length)}),n.jsx(dn,{label:"Sessions",value:e.sessionIds.length===0?"n/a":ht(e.sessionIds.length)}),n.jsx(dn,{label:"Runs",value:e.runIds.length===0?"n/a":ht(e.runIds.length)}),n.jsx(dn,{label:"Groups",value:e.groupIds.length===0?"n/a":ht(e.groupIds.length)})]})]})]})}function dn({label:e,value:t}){return n.jsxs("div",{className:"rounded-md border border-border bg-muted/30 px-3 py-2",children:[n.jsx("div",{className:"text-[10px] font-semibold uppercase text-muted-foreground",children:e}),n.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-foreground",children:t})]})}function Pk(){const[e,t]=l.useState(!1),[s,o]=l.useState("all"),[r,a]=l.useState("all"),[i,c]=l.useState(null),{summary:d,isLoading:m}=wk(),u=l.useMemo(()=>Tk(s,r),[r,s]),{alerts:p,total:f,isLoading:h,error:g,mutate:v}=yk(u,e),y=l.useMemo(()=>Ek(p,i),[p,i]);l.useEffect(()=>{!e||i!==null&&p.some(E=>E.id===i)||c(p[0]?.id??null)},[p,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 n.jsxs(qt,{open:e,onOpenChange:t,children:[n.jsx(io,{asChild:!0,children:n.jsxs(te,{type:"button",variant:"ghost",size:"icon",className:uo,"aria-label":"Alerts",title:"Alerts",children:[n.jsx(nr,{className:"size-4"}),m?n.jsx(Ue,{className:"absolute -right-0.5 -top-0.5 size-3 animate-spin text-muted-foreground"}):w>0?n.jsx("span",{className:P("absolute -right-1 -top-1 min-w-4 rounded-full px-1 text-[10px] font-semibold leading-4",N),children:ht(w)}):null,n.jsx("span",{className:"sr-only",children:"Alerts"})]})}),n.jsxs(Ht,{className:"flex max-h-[86vh] max-w-6xl flex-col overflow-hidden",children:[n.jsxs(Yt,{children:[n.jsxs(Jt,{className:"flex items-center gap-2 pr-8",children:[n.jsx(nr,{className:"size-5 text-status-danger"}),n.jsx("span",{children:"Alerts"}),n.jsx(_e,{variant:"outline",children:ht(w)})]}),n.jsx(lo,{className:"sr-only",children:"Local alert board for captured Inspector evidence."})]}),n.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[n.jsx(_o,{label:"Open",count:d?.open??0,tone:"neutral"}),n.jsx(_o,{label:"Critical",count:b,tone:"critical"}),n.jsx(_o,{label:"Warning",count:j,tone:"warning"}),n.jsx(_o,{label:"Notice",count:S,tone:"notice"})]}),n.jsxs("div",{className:"flex min-h-0 flex-wrap items-center justify-between gap-2 border-y border-border py-3",children:[n.jsxs("div",{className:"flex flex-wrap gap-1",children:[n.jsx(To,{value:"all",active:s==="all",label:"All",count:d?.total??null,onClick:o}),n.jsx(To,{value:"critical",active:s==="critical",label:"Critical",count:b,onClick:o}),n.jsx(To,{value:"warning",active:s==="warning",label:"Warning",count:j,onClick:o}),n.jsx(To,{value:"notice",active:s==="notice",label:"Notice",count:S,onClick:o})]}),n.jsxs(te,{type:"button",variant:"outline",size:"sm",className:"h-7 shrink-0 px-2",onClick:()=>{v()},children:[n.jsx(Rt,{className:"size-3.5"}),"Refresh"]})]}),n.jsxs("div",{className:"flex flex-wrap gap-1",children:[n.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"}),jk.map(C=>{const E=d?.byCategory.find(A=>A.category===C)?.count??0;return E===0?null:n.jsx(Rk,{category:C,active:r===C,count:E,onClick:a},C)})]}),n.jsxs("div",{className:"grid min-h-0 flex-1 gap-4 md:grid-cols-[360px_minmax(0,1fr)]",children:[n.jsxs("div",{className:"flex min-h-0 flex-col",children:[n.jsxs("div",{className:"mb-2 flex items-center justify-between text-xs text-muted-foreground",children:[n.jsxs("span",{children:[ht(f)," matched"]}),n.jsx("span",{children:p.length<f?`${ht(p.length)} shown`:"Latest"})]}),n.jsx(Mk,{alerts:p,selectedAlertId:y?.id??null,isLoading:h,error:g,onSelect:c})]}),n.jsx(Ik,{alert:y,onNavigate:()=>t(!1)})]})]})]})}const Lk=12e3;function Ok(e){return e===null||e.evidence===null?null:`/api/groups/${encodeURIComponent(e.id)}/evidence`}function Dk(e){const t=$t(Ok(e),s=>Be(s,Yx,Lk));return{evidenceResponse:t.data??null,isLoading:t.isLoading,error:t.error,mutate:t.mutate}}const zk=8e3;function $k(){const e=$t("/api/groups",t=>Be(t,Nu,zk));return{groups:e.data?.groups??[],isLoading:e.isLoading,error:e.error,mutate:e.mutate}}const Fk=3e3;function Bk(e,t){return{id:(e?.id??0)+1,message:t.message,tone:t.tone??"error"}}function Kf(){const[e,t]=l.useState(null),s=l.useCallback(r=>{t(a=>Bk(a,r))},[]),o=l.useCallback(()=>{t(null)},[]);return l.useEffect(()=>{if(e===null)return;const r=window.setTimeout(()=>{t(null)},Fk);return()=>{window.clearTimeout(r)}},[e]),{notice:e,showToast:s,dismissToast:o}}function Yf({notice:e,onDismiss:t}){if(e===null)return null;const s=e.tone==="error",o=s?bn:Qa;return n.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:n.jsxs("div",{className:P("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:[n.jsx(o,{className:P("mt-0.5 size-4 shrink-0",s?"text-status-danger":"text-status-success")}),n.jsx("div",{className:"min-w-0 flex-1 break-words leading-5",children:e.message}),n.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:t,children:n.jsx(so,{className:"size-3.5"})})]},e.id)})}const Ma=2e4;function Uk(e,t){const s=`/api/groups/${encodeURIComponent(e)}`;return t?`${s}?deleteEvidence=1`:s}function qk(e){return"/api/groups"}function Jf(e){let t=0,s=0,o=0,r=0;for(const a of e.members)switch(a.status){case"completed":t+=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:t,failedMembers:s,runningMembers:o,missingStatusMembers:r}}function Hk(e,t,s=null){return t!==null&&t.group.id===e.id?t.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 Fl(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 Bl(e){return e??"unknown"}function Vk(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 Xr(e){return e===null||e.trim().length===0?"-":e}function ft(e){return e.toLocaleString()}function _i(e){return e==null?"-":e<1e3?`${ft(e)} ms`:`${(e/1e3).toFixed(1)} s`}function Ns(e){const t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat(void 0,{month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t)):e}function Qc(e){return e===null?"-":Ns(e)}function Wk(e){const t=JSON.stringify(e),s=t===void 0?String(e):t;return s.length<=160?s:`${s.slice(0,157)}...`}function Xf(...e){for(const t of e)if(t!==null&&t.trim().length>0)return t;return"-"}function Gk(...e){for(const t of e)if(t!=null&&t.trim().length>0)return t;return null}function Kk(e){const t=e.provider,s=e.model;return t!==null&&t.length>0&&s!==null&&s.length>0?`${t} / ${s}`:Xf(t,s)}function Yk(e,t){if(t!==null){const s=e.find(o=>o.id===t);if(s!==void 0)return s}return e[0]??null}function Jk(e){return(e.exportMember?.session?.latestLogs??[])[0]??null}function Xk(e){switch(e){case"export":return"fresh export";case"evidence":return"evidence";case"group":return"group"}}function Zk(e,t){return t!==null&&t.group.id===e.id?t.evidence:e.evidence}function Qk(e,t,s){return t!==null&&t.group.id===e.id?t.summary:s!==null&&s.group.id===e.id?s.summary:null}function e3(e,t,s){return t!==null&&t.group.id===e.id?t.jenkinsReport:s!==null&&s.group.id===e.id?s.report:null}function t3({labelledTrigger:e=!1}){const[t,s]=l.useState(!1),[o,r]=l.useState(null),[a,i]=l.useState(null),[c,d]=l.useState(null),[m,u]=l.useState(null),[p,f]=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:E}=Kf(),{groups:A,isLoading:I,error:R,mutate:k}=$k(),M=l.useMemo(()=>Yk(A,o),[A,o]);l.useEffect(()=>{!t||o!==null&&A.some(L=>L.id===o)||r(A[0]?.id??null)},[A,t,o]);const O=M!==null&&m!==null&&m.group.id===M.id?m:null,{evidenceResponse:$,isLoading:K,error:Q,mutate:z}=Dk(M),H=l.useCallback(()=>{k()},[k]),ee=l.useCallback(async()=>{if(!(A.length===0||j)){S(!0),f(null),g(!1),b(null),d(null);try{const oe=await Be(qk(!1),wu,Ma,{method:"DELETE"},L=>`Clear failed with status ${String(L.status)}`);u(null),r(null),await k(),await z(),C({message:`Cleared ${ft(oe.deleted)} group${oe.deleted===1?"":"s"}.`,tone:"success"})}catch(oe){C({message:oe instanceof Error?oe.message:"Unknown error clearing groups",tone:"error"})}finally{S(!1)}}},[j,A.length,k,z,C]),U=l.useCallback(async oe=>{i(oe.id),d(null);try{const L=await Be(`/api/groups/${encodeURIComponent(oe.id)}/evidence`,Jx,Ma,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({latestLogLimit:10})},J=>`Export failed with status ${String(J.status)}`);u(L),await k(),await z()}catch(L){d(L instanceof Error?L.message:String(L))}finally{i(null)}},[k,z]),Z=l.useCallback(oe=>{f(oe),g(!1),b(null)},[]),fe=l.useCallback(()=>{v===null&&(f(null),g(!1),b(null))},[v]),je=l.useCallback(oe=>{r(oe),f(null),g(!1),b(null)},[]),he=l.useCallback(async()=>{const oe=p;if(oe!==null){y(oe.id),b(null);try{await Be(Uk(oe.id,h),yu,Ma,{method:"DELETE"},L=>`Delete failed with status ${String(L.status)}`),u(L=>L!==null&&L.group.id===oe.id?null:L),r(L=>L===oe.id?null:L),f(null),g(!1),await k(),await z()}catch(L){b(L instanceof Error?L.message:String(L))}finally{y(null)}}},[h,p,k,z]);return n.jsxs(qt,{open:t,onOpenChange:s,children:[n.jsx(Yf,{notice:N,onDismiss:E}),n.jsx(io,{asChild:!0,children:n.jsxs(te,{type:"button",variant:"ghost",size:e?"default":"icon",className:P(uo,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:[n.jsx(ec,{className:"size-4"}),I?n.jsx(Ue,{className:"absolute -right-0.5 -top-0.5 size-3 animate-spin text-muted-foreground"}):A.length>0?n.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:A.length}):null,n.jsx("span",{className:e?"":"sr-only",children:"Groups"})]})}),n.jsxs(Ht,{className:"flex max-h-[85vh] max-w-5xl flex-col overflow-hidden",children:[n.jsx(Yt,{children:n.jsxs(Jt,{className:"flex items-center gap-2 pr-8",children:[n.jsx(ec,{className:"size-5 text-muted-foreground"}),n.jsx("span",{children:"Groups"}),n.jsx(_e,{variant:"outline",children:ft(A.length)})]})}),n.jsxs("div",{className:"flex min-h-0 items-center justify-between gap-3 border-b border-border pb-3",children:[n.jsx("p",{className:"text-xs text-muted-foreground",children:"Evaluation batches, model runs, and exported evidence packs."}),n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[n.jsxs(te,{type:"button",variant:"outline",size:"sm",disabled:A.length===0||j,onClick:()=>{ee()},title:"Clear all groups. Session logs and run records stay intact.",children:[j?n.jsx(Ue,{className:"size-3.5 animate-spin"}):n.jsx(wn,{className:"size-3.5"}),"Clear"]}),n.jsxs(te,{type:"button",variant:"outline",size:"sm",onClick:H,children:[n.jsx(Rt,{className:"size-3.5"}),"Refresh"]})]})]}),n.jsxs("div",{className:"grid min-h-0 flex-1 gap-4 md:grid-cols-[260px_minmax(0,1fr)]",children:[n.jsx(n3,{groups:A,selectedGroupId:M?.id??null,isLoading:I,error:R,onSelect:je}),n.jsx(s3,{group:M,deleteTarget:p,deleteEvidence:h,exportResult:O,evidenceResponse:$,evidenceLoading:K,evidenceError:Q,exportError:c,deleteError:w,exportingGroupId:a,deletingGroupId:v,onDeleteEvidenceChange:g,onExport:U,onRequestDelete:Z,onCancelDelete:fe,onConfirmDelete:()=>{he()}})]})]})]})}function n3({groups:e,selectedGroupId:t,isLoading:s,error:o,onSelect:r}){return s?n.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?n.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?n.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."}):n.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:n.jsx("div",{className:"space-y-2",children:e.map(a=>{const i=Jf(a),c=t===a.id;return n.jsxs("button",{type:"button",onClick:()=>r(a.id),className:P("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:[n.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[n.jsx("span",{className:"min-w-0 text-sm font-medium leading-snug",children:a.title}),n.jsx(_e,{variant:"outline",className:Fl(a.status),children:Bl(a.status)})]}),n.jsxs("div",{className:"mt-1 flex items-center gap-2 text-muted-foreground",children:[n.jsxs("span",{children:[i.memberCount," sessions"]}),n.jsx("span",{children:Ns(a.updatedAt)})]})]},a.id)})})})}function s3({group:e,deleteTarget:t,deleteEvidence:s,exportResult:o,evidenceResponse:r,evidenceLoading:a,evidenceError:i,exportError:c,deleteError:d,exportingGroupId:m,deletingGroupId:u,onDeleteEvidenceChange:p,onExport:f,onRequestDelete:h,onCancelDelete:g,onConfirmDelete:v}){if(e===null)return n.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=Jf(e),w=Qk(e,o,r),b=e3(e,o,r),j=Zk(e,o),S=Hk(e,o,r),N=m===e.id,C=u===e.id,E=t?.id===e.id;return n.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex min-w-0 flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[n.jsxs("div",{className:"min-w-0 space-y-1",children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[n.jsx("h3",{className:"min-w-0 text-base font-semibold leading-snug",children:e.title}),n.jsx(_e,{variant:"outline",className:Fl(e.status),children:Bl(e.status)}),n.jsx(_e,{variant:"outline",children:e.kind})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[n.jsx("span",{children:Xr(e.project)}),n.jsxs("span",{children:["updated ",Ns(e.updatedAt)]})]})]}),n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[n.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?n.jsx(Ue,{className:"size-3.5 animate-spin"}):n.jsx(wn,{className:"size-3.5"})}),n.jsxs(te,{type:"button",variant:"default",size:"sm",className:"shrink-0",disabled:N||C,onClick:()=>{f(e)},children:[N?n.jsx(Ue,{className:"size-3.5 animate-spin"}):n.jsx(to,{className:"size-3.5"}),"Export evidence"]})]})]}),e.task!==null&&e.task.trim().length>0&&n.jsx("p",{className:"rounded-md border border-border bg-muted/20 px-3 py-2 text-xs text-muted-foreground",children:e.task}),E&&n.jsx(o3,{group:e,deleteEvidence:s,isDeleting:C,error:d,onDeleteEvidenceChange:p,onCancel:g,onConfirm:v}),n.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[n.jsx(un,{label:"Members",value:y.memberCount}),n.jsx(un,{label:"Done",value:y.completedMembers}),n.jsx(un,{label:"Failed",value:y.failedMembers}),n.jsx(un,{label:"Running",value:y.runningMembers})]}),w!==null&&n.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[n.jsx(un,{label:"Requests",value:w.requestCount}),n.jsx(un,{label:"Errors",value:w.errorCount}),n.jsx(un,{label:"Tokens",value:w.tokenUsage.total}),n.jsx(un,{label:"Missing",value:w.missingSessions})]}),n.jsx(r3,{report:b,loading:a,error:i,hasEvidence:j!==null}),n.jsx(a3,{evidence:j}),c!==null&&n.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&&!E&&n.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}),n.jsx(i3,{rows:S})]})})}function o3({group:e,deleteEvidence:t,isDeleting:s,error:o,onDeleteEvidenceChange:r,onCancel:a,onConfirm:i}){const c=e.evidence!==null,d=e.evidence?.markdownPath??"No evidence pack exported.";return n.jsx("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-3 text-status-danger",children:n.jsxs("div",{className:"flex min-w-0 flex-col gap-3 lg:flex-row lg:items-start lg:justify-between",children:[n.jsxs("div",{className:"min-w-0 space-y-2",children:[n.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[n.jsx(wn,{className:"size-4 text-status-danger"}),n.jsx("span",{children:"Delete group?"})]}),n.jsxs("p",{className:"text-xs text-status-danger",children:["Delete ",n.jsx("span",{className:"font-medium",children:e.title}),". Session logs and run records stay intact."]}),n.jsxs("label",{className:P("flex min-w-0 items-start gap-2 text-xs",c?"cursor-pointer":"opacity-60"),children:[n.jsx("input",{type:"checkbox",className:"mt-0.5 size-4 shrink-0",checked:t,disabled:!c||s,onChange:m=>r(m.currentTarget.checked)}),n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"block font-medium",children:"Also delete exported evidence files"}),n.jsx("code",{className:"mt-1 block truncate font-mono text-[11px] text-status-danger",children:d})]})]}),o!==null&&n.jsx("div",{className:"rounded-md border border-status-danger/30 bg-card px-2 py-1.5 text-xs text-status-danger",children:o})]}),n.jsxs("div",{className:"flex shrink-0 justify-end gap-2",children:[n.jsx(te,{type:"button",variant:"outline",size:"sm",disabled:s,onClick:a,children:"Cancel"}),n.jsxs(te,{type:"button",variant:"destructive",size:"sm",disabled:s,onClick:i,children:[s?n.jsx(Ue,{className:"size-3.5 animate-spin"}):n.jsx(wn,{className:"size-3.5"}),"Delete"]})]})]})})}function un({label:e,value:t}){return n.jsxs("div",{className:"rounded-md border border-border bg-muted/20 px-3 py-2",children:[n.jsx("div",{className:"text-[11px] font-medium uppercase text-muted-foreground",children:e}),n.jsx("div",{className:"mt-1 font-mono text-sm font-semibold",children:ft(t)})]})}function r3({report:e,loading:t,error:s,hasEvidence:o}){const{copied:r,copy:a}=hn(e?.markdown??null);return e===null&&!t&&s===void 0?null:t?n.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:[n.jsx(Ue,{className:"size-3.5 animate-spin"}),"Loading evidence report..."]}):s!==void 0&&o?n.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:n.jsxs("div",{className:"rounded-md border border-border bg-muted/20 px-3 py-2",children:[n.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsx("span",{className:"text-xs font-semibold",children:"Evidence report"}),n.jsx(_e,{variant:"outline",className:Vk(e.status),children:e.status})]}),n.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?n.jsx($e,{className:"size-3.5 text-status-success"}):n.jsx(jt,{className:"size-3.5"})})]}),n.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:e.summary})]})}function a3({evidence:e}){return e===null?n.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."}):n.jsxs("div",{className:"space-y-2 rounded-md border border-border bg-muted/20 px-3 py-2",children:[n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx("span",{className:"text-xs font-semibold",children:"Evidence paths"}),n.jsx("span",{className:"text-[11px] text-muted-foreground",children:Ns(e.exportedAt)})]}),n.jsxs("div",{className:"grid gap-2",children:[n.jsx(Aa,{label:"JSON",value:e.jsonPath}),n.jsx(Aa,{label:"Markdown",value:e.markdownPath}),n.jsx(Aa,{label:"HTML",value:e.htmlPath})]})]})}function Aa({label:e,value:t}){const{copied:s,copy:o}=hn(t);return n.jsxs("div",{className:"flex min-w-0 items-center gap-2 rounded-md border border-border bg-background px-2 py-1.5",children:[n.jsx("span",{className:"w-16 shrink-0 text-[11px] font-medium text-muted-foreground",children:e}),n.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs",children:t}),n.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?n.jsx($e,{className:"size-3.5 text-status-success"}):n.jsx(jt,{className:"size-3.5"})})]})}function i3({rows:e}){const[t,s]=l.useState(null),o=l.useCallback(r=>{s(a=>a===r?null:r)},[]);return e.length===0?n.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."}):n.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[n.jsx("div",{className:"border-b border-border bg-muted/30 px-3 py-2 text-xs font-semibold",children:"Members"}),n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full min-w-[760px] text-left text-xs",children:[n.jsx("thead",{className:"border-b border-border bg-muted/20 text-muted-foreground",children:n.jsxs("tr",{children:[n.jsx("th",{className:"px-3 py-2 font-medium",children:"Session"}),n.jsx("th",{className:"px-3 py-2 font-medium",children:"Provider / Model"}),n.jsx("th",{className:"px-3 py-2 font-medium",children:"Status"}),n.jsx("th",{className:"px-3 py-2 font-medium",children:"Requests"}),n.jsx("th",{className:"px-3 py-2 font-medium",children:"Errors"}),n.jsx("th",{className:"px-3 py-2 font-medium",children:"First chunk"}),n.jsx("th",{className:"px-3 py-2 font-medium",children:"Tokens"})]})}),n.jsx("tbody",{children:e.map(r=>{const a=t===r.member.id;return n.jsxs(l.Fragment,{children:[n.jsx(l3,{row:r,isExpanded:a,onToggleDetails:o}),n.jsx(c3,{row:r,isExpanded:a})]},r.member.id)})})]})})]})}function l3({row:e,isExpanded:t,onToggleDetails:s}){const o=e.member,r=e.exportMember?.session??null,a=Jk(e),i=r?.inspectorPath??su(o.sessionId),c=e.source!=="evidence",d=r?.requestCount??null,m=r?.errorCount??null,u=r?.tokenUsage.total??null,p=a?.firstChunkMs??null,f=Xf(o.label,o.sessionId),h=Gk(r?.clientUserAgent,a?.userAgent,o.agent),g=r?.clientProjectFolder??null,v=El({userAgent:h,conversationId:o.sessionId,clientProjectFolder:g}),y=Kr(v);return n.jsxs("tr",{className:"border-b border-border last:border-0 hover:bg-muted/20",children:[n.jsxs("td",{className:"max-w-56 px-3 py-2",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[n.jsx(te,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0 text-muted-foreground","aria-label":t?`Hide member ${f}`:`Show member ${f}`,title:t?"Hide member details":"Show member details",onClick:()=>{s(o.id)},children:t?n.jsx(Xe,{className:"size-3.5"}):n.jsx(gt,{className:"size-3.5"})}),y!==null&&n.jsx(Yr,{client:v,className:"size-5"}),c?n.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 ${f}`,title:`Open session ${f}`,children:[n.jsx("span",{className:"min-w-0 truncate",children:f}),n.jsx(Xi,{className:"size-3 shrink-0 text-muted-foreground"})]}):n.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 ${f}`,"aria-label":`Show evidence snapshot for ${f}`,onClick:()=>{s(o.id)},children:[n.jsx("span",{className:"min-w-0 truncate",children:f}),n.jsx(_e,{variant:"outline",className:"shrink-0 border-border bg-muted/30 text-muted-foreground",children:"evidence"})]})]}),n.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:Xr(o.agent)})]}),n.jsx("td",{className:"max-w-52 px-3 py-2",children:n.jsx("span",{className:"block whitespace-normal leading-snug",children:Kk(o)})}),n.jsx("td",{className:"px-3 py-2",children:n.jsx(_e,{variant:"outline",className:Fl(o.status),children:Bl(o.status)})}),n.jsx("td",{className:"px-3 py-2 font-mono",children:d===null?"-":ft(d)}),n.jsx("td",{className:"px-3 py-2 font-mono",children:m===null?"-":ft(m)}),n.jsx("td",{className:"px-3 py-2 font-mono",children:_i(p)}),n.jsx("td",{className:"px-3 py-2 font-mono",children:u===null?"-":ft(u)})]})}function c3({row:e,isExpanded:t}){if(!t)return null;const s=e.member,o=e.exportMember,r=o?.session??null,a=o?.run??null,i=Object.entries(s.metadata);return n.jsx("tr",{className:"border-b border-border bg-muted/10",children:n.jsx("td",{colSpan:7,className:"px-3 pb-4 pt-2",children:n.jsxs("div",{className:"space-y-3 rounded-md border border-border bg-background p-3",children:[n.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4",children:[n.jsx(et,{label:"Source",value:Xk(e.source)}),n.jsx(et,{label:"Member ID",value:s.id,mono:!0}),n.jsx(et,{label:"Session ID",value:s.sessionId,mono:!0}),n.jsx(et,{label:"Run ID",value:a?.id??s.runId??"-",mono:!0}),n.jsx(et,{label:"Created",value:Ns(s.addedAt)}),n.jsx(et,{label:"Updated",value:Ns(s.updatedAt)}),n.jsx(et,{label:"Session created",value:Qc(r?.createdAt??null)}),n.jsx(et,{label:"Session updated",value:Qc(r?.updatedAt??null)})]}),r===null?n.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."}):n.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4",children:[n.jsx(et,{label:"Log coverage",value:r.logCoverage}),n.jsx(et,{label:"Runtime",value:Xr(r.runtimeMode)}),n.jsx(et,{label:"Requests",value:ft(r.requestCount),mono:!0}),n.jsx(et,{label:"Errors",value:ft(r.errorCount),mono:!0}),n.jsx(et,{label:"Input tokens",value:ft(r.tokenUsage.input),mono:!0}),n.jsx(et,{label:"Output tokens",value:ft(r.tokenUsage.output),mono:!0}),n.jsx(et,{label:"Cache read",value:ft(r.tokenUsage.cacheRead),mono:!0}),n.jsx(et,{label:"Total tokens",value:ft(r.tokenUsage.total),mono:!0})]}),n.jsx(d3,{logs:r?.latestLogs??[]}),n.jsx(u3,{entries:i})]})})})}function et({label:e,value:t,mono:s=!1}){return n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:e}),n.jsx("div",{className:P("truncate text-xs text-foreground",s?"font-mono":""),title:t,children:t})]})}function d3({logs:e}){const t=e.slice(0,5);return t.length===0?n.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."}):n.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[n.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"}),n.jsx("div",{className:"divide-y divide-border",children:t.map(s=>{const o=s.sessionLogNumber??s.id;return n.jsxs("div",{className:"grid gap-2 px-3 py-2 text-xs sm:grid-cols-[72px_1fr_88px_88px]",children:[n.jsxs("span",{className:"font-mono text-muted-foreground",title:`Log ID ${String(s.id)}`,children:["#",o]}),n.jsxs("span",{className:"min-w-0 truncate",children:[Xr(s.model)," · ",s.apiFormat," · ",s.path]}),n.jsx("span",{className:"font-mono text-muted-foreground",children:_i(s.firstChunkMs)}),n.jsx("span",{className:"font-mono text-muted-foreground",children:_i(s.latencyMs)})]},s.id)})})]})}function u3({entries:e}){return e.length===0?null:n.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[n.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"}),n.jsx("div",{className:"grid gap-x-3 gap-y-2 p-3 text-xs sm:grid-cols-2",children:e.map(([t,s])=>{const o=Wk(s);return n.jsxs("div",{className:"min-w-0",children:[n.jsx("span",{className:"mr-2 text-muted-foreground",children:t}),n.jsx("span",{className:"font-mono text-foreground",title:o,children:o})]},t)})})]})}const m3=_({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:Ce()}),p3=_({scanId:x().uuid(),providers:V(m3),warnings:V(x()).optional()});_({scanId:x().uuid(),selectionIds:V(x().uuid()).min(1).max(100)});const f3=_({success:Ce().optional(),imported:T().optional(),message:x().optional(),errors:V(x()).optional()}),ed=2e4;function h3({open:e,onOpenChange:t,onImportComplete:s}){const[o,r]=l.useState(!1),[a,i]=l.useState(null),[c,d]=l.useState(null),[m,u]=l.useState([]),[p,f]=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),E=l.useCallback(()=>{const k=N.current+1;N.current=k,r(!0),i(null),f([]),d(null),u([]),g(new Set),b(null),S(null),Be("/api/providers/scan",p3,ed,{method:"POST"},M=>`Scan failed (${String(M.status)})`).then(M=>{if(N.current!==k)return;d(M.scanId),u(M.providers),f(M.warnings??[]);const O=new Set;M.providers.forEach(($,K)=>{$.alreadyExists||O.add(K)}),g(O)}).catch(M=>{N.current===k&&i(M instanceof Error?M.message:String(M))}).finally(()=>{N.current===k&&r(!1)})},[]);l.useEffect(()=>{e&&E()},[e,E]),l.useEffect(()=>{e||(N.current+=1,C.current+=1,r(!1),y(!1))},[e]);const A=l.useCallback(k=>{g(M=>{const O=new Set(M);return O.has(k)?O.delete(k):O.add(k),O})},[]),I=l.useCallback(()=>{const k=m.filter((O,$)=>h.has($));if(k.length===0||c===null)return;const M=C.current+1;C.current=M,y(!0),S(null),b(null),Be("/api/providers/import",f3,ed,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scanId:c,selectionIds:k.map(O=>O.selectionId)})},O=>`Import failed (${String(O.status)})`).then(O=>{C.current===M&&(u($=>$.map((K,Q)=>h.has(Q)?{...K,alreadyExists:!0}:K)),g(new Set),O.errors!==void 0&&O.errors.length>0&&O.message!==void 0?b(O.message):b(`Imported ${O.imported??k.length} provider(s)`),s())}).catch(O=>{C.current===M&&S(O instanceof Error?O.message:String(O))}).finally(()=>{C.current===M&&y(!1)})},[m,c,h,s]),R=m.some(k=>!k.alreadyExists);return n.jsx(qt,{open:e,onOpenChange:t,children:n.jsxs(Ht,{className:"max-w-xl max-h-[80vh] overflow-hidden flex flex-col",children:[n.jsxs(Yt,{children:[n.jsx(Jt,{children:"Import from External Tools"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Detect provider configurations from Claude Code, OpenCode, and MiMo Code."})]}),n.jsxs("div",{className:"flex-1 overflow-y-auto space-y-3",children:[o&&n.jsxs("div",{className:"flex items-center justify-center py-8 gap-2 text-muted-foreground",children:[n.jsx(Ue,{className:"size-4 animate-spin"}),n.jsx("span",{className:"text-sm",children:"Scanning for external providers..."})]}),a!==null&&n.jsxs("div",{className:"flex items-center gap-2 text-destructive text-sm py-4",children:[n.jsx(gs,{className:"size-4"}),a]}),!o&&a===null&&m.length===0&&n.jsxs("p",{className:"text-sm text-muted-foreground py-8 text-center",children:["No external provider configurations found.",n.jsx("br",{}),n.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,M)=>n.jsxs("label",{className:`flex items-start gap-3 p-3 border rounded-md ${k.alreadyExists?"":"cursor-pointer hover:bg-muted/50"}`,children:[!k.alreadyExists&&n.jsx("input",{type:"checkbox",checked:h.has(M),disabled:v,onChange:()=>A(M),className:"mt-0.5 size-4"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(Yr,{client:k.sourceTool,className:"size-7 rounded-[8px]"}),k.alreadyExists&&n.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Already added"})]}),n.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`:""]}),n.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:k.format==="anthropic"?k.anthropicBaseUrl:k.openaiResponsesBaseUrl!==""?k.openaiResponsesBaseUrl:k.openaiBaseUrl}),n.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 font-mono",children:k.apiKeyHint})]})]},k.selectionId)),p.length>0&&n.jsx("div",{className:"text-xs text-muted-foreground space-y-1 border-t pt-2",children:p.map((k,M)=>n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx(gs,{className:"size-3"}),k]},M))}),w!==null&&n.jsx("div",{className:"border-t pt-2 text-sm text-status-success",children:w}),j!==null&&n.jsx("div",{className:"text-sm text-destructive border-t pt-2",children:j})]}),n.jsxs("div",{className:"flex items-center justify-between pt-3 border-t",children:[n.jsxs(te,{variant:"outline",size:"sm",onClick:E,disabled:o,children:[n.jsx(Ue,{className:`size-3 mr-1 ${o?"animate-spin":""}`}),"Rescan"]}),n.jsxs(te,{size:"sm",onClick:I,disabled:!R||h.size===0||v,children:[n.jsx(to,{className:"size-3 mr-1"}),v?"Importing...":`Import Selected (${h.size})`]})]})]})})}const Zf=_({id:x().min(1).max(oi),aliases:V(x().max(oi)).max(vn).optional().default([]),contextWindow:T().int().positive().optional(),outputLimit:T().int().positive().optional(),sourceUrl:x().optional()}),x3=_({name:x().min(1).optional(),aliases:V(x()).max(vn).optional().default([]),baseUrls:V(x()).max(vn).optional().default([]),models:V(Zf).min(1).max(vn)});_({version:T().int().positive().optional(),updatedAt:x().optional(),providers:V(x3).max(vn).optional().default([]),models:V(Zf).max(vn).optional().default([])});function td(e){return e.trim().toLowerCase().replace(/\s+/g,"-")}function g3(e){const t=e.models.filter(s=>s.trim()!=="");return t.length>0?t:e.model!==void 0&&e.model.trim()!==""?[e.model]:[]}function Ul(e,t){const s=td(t);return(e.modelMetadata??[]).find(r=>td(r.model)===s)??null}function b3(e){const t=g3(e);return t.length===0?!1:t.every(s=>{const o=Ul(e,s);return o!==null&&o.contextWindow!==void 0})}function v3(e,t){if(e===null)return null;for(const s of t){const o=Ul(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 Zs(e){return Object.prototype.hasOwnProperty.call(e,"success")}function Zr(e){return Object.prototype.hasOwnProperty.call(e,"notConfigured")}function wt(e){return e!==void 0&&e!==""}function ot(e){return e!==void 0&&e.trim()!==""}function Eo(e){return e!=null}function hs(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function Qf(e){return e>=10?`${e.toFixed(0)}/s`:`${e.toFixed(1)}/s`}function eh(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 y3(e){return e.firstChunkMs!==void 0&&e.firstChunkMs!==null?hs(e.firstChunkMs):e.latencyMs!==void 0?hs(e.latencyMs):e.totalStreamMs!==void 0&&e.totalStreamMs!==null?hs(e.totalStreamMs):e.tokensPerSecond!==void 0&&e.tokensPerSecond!==null&&e.tokensPerSecond>0?Qf(e.tokensPerSecond):null}function w3(e){return Zr(e)?{tone:"quiet",label:"N/A",metric:null,hasDetails:!1}:Zs(e)?e.success?{tone:"success",label:"Pass",metric:y3(e),hasDetails:!0}:{tone:"failure",label:eh(e.error?.type??"unknown"),metric:null,hasDetails:!0}:{tone:"pending",label:"Running",metric:null,hasDetails:!1}}function j3(e,t){if(t===void 0)return[];const s=[];return wt(e.anthropicBaseUrl)&&s.push(t.anthropic),wt(e.openaiBaseUrl)&&s.push(t.openaiChat),wt(e.openaiResponsesBaseUrl)&&s.push(t.openaiResponses),s}function S3(e,t){const s={total:0,passed:0,failed:0,testing:0};for(const o of j3(e,t))for(const r of[o.nonStreaming,o.streaming])Zr(r)||(s.total+=1,Zs(r)?r.success?s.passed+=1:s.failed+=1:s.testing+=1);return s}function nd(e){if(e===void 0)return;const t=Object.entries(e).map(([s,o])=>`${s}: ${o}`);return t.length===0?void 0:t.join(`
|
|
58
|
+
`)}function mn({title:e,children:t}){return n.jsxs("section",{className:"space-y-1.5",children:[n.jsx("h4",{className:"text-xs font-medium text-foreground/80",children:e}),t]})}function En({value:e}){return n.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 Rn({label:e,value:t}){return n.jsxs("div",{className:"min-w-0 rounded-md bg-muted/35 px-3 py-2",children:[n.jsx("dt",{className:"text-[10px] text-muted-foreground",children:e}),n.jsx("dd",{className:"mt-1 truncate font-mono text-xs font-semibold text-foreground",title:t,children:t})]})}function N3({result:e}){const t=Eo(e.inputTokens)||Eo(e.outputTokens),s=Eo(e.cacheCreationInputTokens)||Eo(e.cacheReadInputTokens);return ot(e.model)||t||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?n.jsxs("dl",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4",children:[ot(e.model)&&n.jsx(Rn,{label:"Model",value:e.model}),e.latencyMs!==void 0&&n.jsx(Rn,{label:"Latency",value:hs(e.latencyMs)}),e.firstChunkMs!==void 0&&e.firstChunkMs!==null&&n.jsx(Rn,{label:"First chunk",value:hs(e.firstChunkMs)}),e.totalStreamMs!==void 0&&e.totalStreamMs!==null&&n.jsx(Rn,{label:"Stream total",value:hs(e.totalStreamMs)}),e.tokensPerSecond!==void 0&&e.tokensPerSecond!==null&&e.tokensPerSecond>0&&n.jsx(Rn,{label:"Token rate",value:`${Qf(e.tokensPerSecond)} tok`}),t&&n.jsx(Rn,{label:"Tokens in / out",value:`${String(e.inputTokens??0)} / ${String(e.outputTokens??0)}`}),s&&n.jsx(Rn,{label:"Cache create / read",value:`${String(e.cacheCreationInputTokens??0)} / ${String(e.cacheReadInputTokens??0)}`})]}):null}function C3({result:e}){const t=e.debug,s=t?.requestUrl,o=t?.requestMethod??"POST",r=nd(t?.requestHeaders),a=nd(t?.responseHeaders),i=t?.responseStatus===void 0?void 0:`${String(t.responseStatus)}${ot(t.responseStatusText)?` ${t.responseStatusText}`:""}`,c=t?.responseBody??e.rawResponse;return ot(e.error?.hint)||ot(e.error?.details)||ot(s)||r!==void 0||ot(t?.requestBody)||ot(i)||a!==void 0||ot(c)?n.jsxs("div",{className:"space-y-4 border-t border-border/70 pt-4 text-xs text-muted-foreground",children:[ot(e.error?.hint)&&n.jsx(mn,{title:"Hint",children:n.jsx("p",{className:"break-words text-foreground/80",children:e.error.hint})}),ot(e.error?.details)&&n.jsx(mn,{title:"Error details",children:n.jsx(En,{value:e.error.details})}),ot(s)&&n.jsx(mn,{title:"Request",children:n.jsx(En,{value:`${o} ${s}`})}),r!==void 0&&n.jsx(mn,{title:"Request headers",children:n.jsx(En,{value:r})}),ot(t?.requestBody)&&n.jsx(mn,{title:"Request body",children:n.jsx(En,{value:t.requestBody})}),ot(i)&&n.jsx(mn,{title:"Response status",children:n.jsx(En,{value:i})}),a!==void 0&&n.jsx(mn,{title:"Response headers",children:n.jsx(En,{value:a})}),ot(c)&&n.jsx(mn,{title:"Response body",children:n.jsx(En,{value:c})})]}):null}function k3({result:e,probeLabel:t,children:s}){const o=e.error?.message??"Connection failed";return n.jsxs(qt,{children:[n.jsx(io,{asChild:!0,children:s}),n.jsxs(Ht,{className:"max-h-[82vh] max-w-2xl gap-0 overflow-hidden p-0",children:[n.jsxs(Yt,{className:"border-b border-border/70 px-5 py-4 pr-12",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[e.success?n.jsx(eo,{className:"size-4 text-status-success"}):n.jsx(gs,{className:"size-4 text-status-danger"}),n.jsx(Jt,{className:"text-base",children:t})]}),n.jsx(lo,{children:e.success?"Connection probe passed.":o})]}),n.jsxs("div",{className:"space-y-4 overflow-y-auto p-5",children:[!e.success&&n.jsxs("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-2 text-sm text-status-danger",children:[n.jsx("div",{className:"font-medium",children:eh(e.error?.type??"unknown")}),n.jsx("div",{className:"mt-1 break-words text-xs text-muted-foreground",children:o})]}),n.jsx(N3,{result:e}),n.jsx(C3,{result:e})]})]})]})}function _3(e){const t="size-3 shrink-0";switch(e){case"timeout":return n.jsx(en,{className:t});case"network_unreachable":return n.jsx(q1,{className:t});case"connection_refused":return n.jsx(V1,{className:t});case"auth_failed":return n.jsx(Fg,{className:t});case"rate_limited":return n.jsx(Zi,{className:t});case"server_error":return n.jsx(_1,{className:t});case"invalid_response":return n.jsx(V0,{className:t});case"unknown":return n.jsx(gs,{className:t})}}const T3={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 sd({result:e,probeLabel:t}){const s=w3(e),o=Zr(e)?n.jsx(Pu,{className:"size-3 shrink-0"}):Zs(e)?e.success?n.jsx(eo,{className:"size-3 shrink-0"}):_3(e.error?.type??"unknown"):n.jsx(tr,{className:"size-3 shrink-0 animate-spin"}),r=n.jsxs(n.Fragment,{children:[o,n.jsx("span",{className:"min-w-0 truncate",children:s.label}),s.metric!==null&&n.jsx("span",{className:"ml-auto shrink-0 font-mono text-[10px] opacity-75",children:s.metric})]}),a=P("inline-flex h-7 w-full min-w-0 items-center gap-1.5 rounded-md px-2 text-left text-xs transition-colors",T3[s.tone]);return Zs(e)&&s.hasDetails?n.jsx(k3,{result:e,probeLabel:t,children:n.jsx("button",{type:"button",className:a,"aria-label":`Open ${t} result: ${s.label}`,children:r})}):n.jsx("div",{className:a,children:r})}function od({label:e}){return n.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:[n.jsx(Pu,{className:"size-3 shrink-0"}),n.jsx("span",{className:"truncate",children:e})]})}function Ia({label:e,results:t,configured:s=!0}){return n.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:[n.jsx("div",{className:"min-w-0 truncate text-xs font-medium text-foreground/85",title:e,children:e}),s&&t!==void 0?n.jsx(sd,{result:t.nonStreaming,probeLabel:`${e} non-stream`}):n.jsx(od,{label:s?"Not tested":"Off"}),s&&t!==void 0?n.jsx(sd,{result:t.streaming,probeLabel:`${e} stream`}):n.jsx(od,{label:s?"Not tested":"Off"})]})}function th({provider:e,results:t}){const s=wt(e.anthropicBaseUrl),o=wt(e.openaiBaseUrl),r=wt(e.openaiResponsesBaseUrl);return!s&&!o&&!r?n.jsx("div",{className:"text-xs text-muted-foreground",children:"No testable endpoint configured."}):n.jsx("div",{className:"min-w-0 overflow-x-auto rounded-md border border-border/70",children:n.jsxs("div",{className:"min-w-[20rem]",children:[n.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:[n.jsx("span",{children:"Protocol"}),n.jsx("span",{children:"Non-stream"}),n.jsx("span",{children:"Stream"})]}),s&&n.jsx(Ia,{label:"Anthropic",results:t?.anthropic}),o&&n.jsx(Ia,{label:"OpenAI Chat",results:t?.openaiChat}),r&&n.jsx(Ia,{label:"OpenAI Responses",results:t?.openaiResponses})]})})}function E3(e){const t={total:0,passed:0,failed:0,testing:0};for(const s of[e.nonStreaming,e.streaming])Zr(s)||(t.total+=1,Zs(s)?s.success?t.passed+=1:t.failed+=1:t.testing+=1);return t}function Pa({label:e,results:t}){const s=E3(t),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 n.jsxs("span",{className:P("rounded border px-1.5 py-0.5 text-[10px]",o),children:[e," ",r]})}function R3({provider:e,modelName:t,results:s,expanded:o,onToggle:r}){return n.jsxs("div",{className:"min-w-0",children:[n.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?n.jsx(Xe,{className:"size-3.5 shrink-0 text-muted-foreground"}):n.jsx(gt,{className:"size-3.5 shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-[8rem] flex-1 truncate text-xs font-medium",title:t,children:t}),n.jsxs("span",{className:"flex flex-wrap items-center justify-end gap-1",children:[wt(e.anthropicBaseUrl)&&n.jsx(Pa,{label:"A",results:s.anthropic}),wt(e.openaiBaseUrl)&&n.jsx(Pa,{label:"Chat",results:s.openaiChat}),wt(e.openaiResponsesBaseUrl)&&n.jsx(Pa,{label:"Resp",results:s.openaiResponses})]})]}),o&&n.jsx("div",{className:"px-2 pb-3",children:n.jsx(th,{provider:e,results:s})})]})}function M3({provider:e,testResults:t}){const s=Object.entries(t.models??{}),[o,r]=l.useState(!1),[a,i]=l.useState(null);return s.length===0?null:n.jsxs("section",{className:"space-y-2",children:[n.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?n.jsx(Xe,{className:"size-3.5"}):n.jsx(gt,{className:"size-3.5"}),"Model probes",n.jsx("span",{className:"rounded bg-muted/50 px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground",children:s.length})]}),o&&n.jsx("div",{className:"min-w-0 divide-y divide-border/60 rounded-md border border-border/70",children:s.map(([c,d])=>n.jsx(R3,{provider:e,modelName:c,results:d,expanded:a===c,onToggle:()=>i(m=>m===c?null:c)},c))})]})}function A3({provider:e,testResults:t,isTesting:s}){const o=wt(e.anthropicBaseUrl)||wt(e.openaiBaseUrl)||wt(e.openaiResponsesBaseUrl),r=S3(e,t);return s?n.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:[n.jsx(tr,{className:"size-3 animate-spin"}),"Testing"]}):o?t===void 0||r.total===0?n.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?n.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:[n.jsx(gs,{className:"size-3"}),r.failed," failed"]}):r.testing>0||r.passed<r.total?n.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]}):n.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:[n.jsx(eo,{className:"size-3"}),r.passed,"/",r.total]}):n.jsx("span",{className:"rounded border border-border/70 bg-muted/20 px-2 py-1 text-xs text-muted-foreground",children:"No endpoint"})}const I3={deepseek:"https://api-docs.deepseek.com/zh-cn/"};function La(e){return e!==void 0&&e!==""}function Oa({label:e}){return n.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:[n.jsx(eo,{className:"size-3"}),e]})}function P3({provider:e}){const t=La(e.anthropicBaseUrl),s=La(e.openaiBaseUrl),o=La(e.openaiResponsesBaseUrl);return!t&&!s&&!o?n.jsx("div",{className:"text-xs text-muted-foreground",children:"Test requires at least one configured endpoint."}):n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5 text-xs text-muted-foreground",children:[t&&n.jsx(Oa,{label:"Anthropic"}),s&&n.jsx(Oa,{label:"OpenAI Chat"}),o&&n.jsx(Oa,{label:"OpenAI Responses"})]})}function L3(e){const t=e.models??[];if(t.length===0)return"No models configured";const s=t.slice(0,2).join(", "),o=t.length-2;return o>0?`${s} +${o} more`:s}function O3({provider:e,model:t}){const s=Ul(e,t),o=z3(s?.sourceUrl);return n.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:[n.jsx("span",{children:t}),s!==null&&s.contextWindow!==void 0&&n.jsx("span",{className:"font-mono text-foreground/80",children:ru(s.contextWindow)}),o!==null&&n.jsx(Ts,{children:n.jsxs(dt,{children:[n.jsx(ut,{asChild:!0,children:n.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})}),n.jsx(mt,{children:o.title})]})})]})}function D3(e){const t=Date.now(),s=new Date(e).getTime(),o=t-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 z3(e){if(e===void 0||e.trim()==="")return null;try{const t=new URL(e);if(t.protocol!=="https:"&&t.protocol!=="http:")return null;const s=t.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 $3({provider:e,testResults:t,isTesting:s,testingTimeLeft:o,isHighlighted:r,onEdit:a,onDelete:i,onTest:c,onRefreshMetadata:d,isRefreshingMetadata:m=!1}){const[u,p]=l.useState(!1),f=e.apiDocsUrl??Object.entries(I3).find(([b])=>e.name.toLowerCase().includes(b))?.[1],h=b3(e),g=e.modelMetadataUrl!==void 0&&e.modelMetadataUrl.trim()!=="",v=g?"Refresh":"Import defaults",y=s??!1,w=e.source==="company"?n.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"?n.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 n.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:[n.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[n.jsxs("div",{className:"min-w-0 space-y-1",children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[n.jsx("span",{className:"font-medium leading-snug",children:e.name}),w]}),n.jsx("div",{className:"text-xs leading-snug text-muted-foreground",children:L3(e)})]}),n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[n.jsx(A3,{provider:e,testResults:t,isTesting:y}),f!==void 0&&n.jsxs("a",{href:f,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:[n.jsx(Xi,{className:"size-3"}),n.jsx("span",{className:"sr-only",children:"Docs"})]})]})]}),n.jsxs("div",{className:"flex flex-col gap-2 text-xs text-muted-foreground sm:flex-row sm:items-center sm:justify-between",children:[n.jsx(P3,{provider:e}),t?.testedAt!==void 0&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx(en,{className:"size-3"}),D3(t.testedAt)]})]}),!h&&n.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:[n.jsx("span",{children:"Context window metadata missing"}),n.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[n.jsxs(te,{type:"button",variant:"outline",size:"sm",onClick:()=>d?.(e.id),className:"h-6 gap-1 px-2 text-xs",disabled:m,children:[n.jsx(tr,{className:`size-3 ${m?"animate-spin":""}`}),v]}),!g&&n.jsx(te,{type:"button",variant:"ghost",size:"sm",onClick:()=>a(e),className:"h-6 px-2 text-xs",children:"Set URL"})]})]}),u&&n.jsxs("div",{className:"space-y-3 border-t border-border/60 pt-3",children:[n.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[n.jsx(eo,{className:"size-3.5 text-status-success"}),n.jsx("span",{children:"API key configured"})]}),e.models!==void 0&&e.models.length>0&&n.jsx("div",{className:"flex flex-wrap gap-1",children:e.models.map(b=>n.jsx(O3,{provider:e,model:b},b))}),n.jsxs("section",{className:"space-y-2",children:[n.jsx("h4",{className:"text-xs font-medium text-foreground/80",children:"Connection probes"}),n.jsx(th,{provider:e,results:t})]}),t!==void 0&&n.jsx(M3,{provider:e,testResults:t})]}),n.jsxs("div",{className:"flex flex-col gap-2 border-t pt-1 sm:flex-row sm:items-center sm:justify-between",children:[n.jsxs("button",{type:"button",onClick:()=>p(b=>!b),className:"inline-flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground","aria-expanded":u,children:[u?n.jsx(Xe,{className:"size-3"}):n.jsx(gt,{className:"size-3"}),"Details"]}),n.jsxs("div",{className:"flex gap-2",children:[c!==void 0&&n.jsxs(te,{variant:"outline",size:"sm",onClick:()=>c(e.id),className:"text-xs h-7 gap-1",disabled:y,children:[n.jsx(tr,{className:`size-3 ${y?"animate-spin":""}`}),y?o!==void 0?`Testing (${o}s)`:"Testing...":"Test"]}),n.jsxs(te,{variant:"outline",size:"sm",onClick:()=>a(e),className:"text-xs h-7 gap-1",disabled:y,children:[n.jsx(Lu,{className:"size-3"}),"Edit"]}),n.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:[n.jsx(wn,{className:"size-3"}),"Delete"]})]})]})]})}const xs="/v1/chat/completions",Ti="/v1/responses",F3="/v1/messages";function B3(e,t){const s=e.endsWith("/")?e.slice(0,-1):e,o=nh(t),r=t.indexOf("?"),a=r>=0?t.slice(r):"";return o!==""&&s.endsWith(o)?s+a:oh(s)&&sh(t)||s.endsWith("/v1")&&t.startsWith("/v1/")?s+t.slice(3):s+t}function U3(e,t,s={}){const o=e.trim().replace(/\/+$/,""),r=nh(t),a=B3(o,t),i=[];return r!==""&&o.endsWith(r)?i.push({severity:"info",message:"This already includes the exact endpoint; no duplicate suffix will be appended."}):oh(o)&&sh(t)?i.push({severity:"info",message:"Zhipu bases already include the API version; only /chat/completions is appended."}):o.endsWith("/v1")&&t.startsWith("/v1/")&&i.push({severity:"info",message:"Base URL already ends with /v1; the suffix will not repeat /v1."}),rd(r)&&H3(o)&&i.push({severity:"warning",message:"This looks like a Chat Completions endpoint, so Responses would append after it."}),q3(r)&&V3(o)&&i.push({severity:"warning",message:"This looks like a Responses endpoint, so Chat Completions would append after it."}),rd(r)&&W3(o,s.providerName)&&i.push({severity:"warning",message:"DeepSeek's official API does not currently expose OpenAI Responses."}),{finalUrl:a,diagnostics:i}}function nh(e){return e.split("?")[0]??e}function sh(e){return e===xs||e.startsWith(`${xs}?`)||e.startsWith(`${xs}/`)}function q3(e){return e===xs||e.startsWith(`${xs}/`)}function rd(e){return e===Ti||e.startsWith(`${Ti}/`)}function H3(e){return e.toLowerCase().endsWith("/chat/completions")}function V3(e){return e.toLowerCase().endsWith("/responses")}function W3(e,t){const s=t?.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 oh(e){try{const t=new URL(e),s=t.pathname.replace(/\/+$/,"");return t.hostname==="open.bigmodel.cn"&&(s==="/api/paas/v4"||s==="/api/coding/paas/v4")}catch{return!1}}function Da(e){return e!==void 0&&e.trim()!==""}function ad(e){const t=Da(e?.anthropicBaseUrl),s=Da(e?.openaiBaseUrl),o=Da(e?.openaiResponsesBaseUrl);return{anthropic:t,openai:s||o,openaiChat:s,openaiResponses:o}}function za(e,t,s){if(!e)return s?"":void 0;const o=t.trim();return o===""?void 0:o}const id=["zhipu","zhipuai","bigmodel","z.ai","zai","glm"],ld=["zhipu coding","glm coding","bigmodel coding","z.ai coding","zai coding"],Ro=F3,Mo=xs,Ao=Ti,G3={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"}},cd=["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"],dd=["qwen3.6-plus","qwen3.7-max"],ud=["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"],Ei="__unset__",xr="__custom__",rh=[{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 Mn(){return{contextWindow:"",contextWindowMode:"unset",outputLimit:""}}function md(e){return e.trim().toLowerCase().replace(/\s+/g,"-")}function ah(e,t){const s=md(t);return e?.modelMetadata?.find(o=>md(o.model)===s)??null}function ih(e){const t=Xo(e);if(t===null)return null;for(const s of rh)if(Xo(s.value)===t)return s.value;return null}function K3(e){return e.trim()===""?"unset":ih(e)!==null?"preset":"custom"}function Y3(e){switch(e.contextWindowMode){case"unset":return Ei;case"custom":return xr;case"preset":return ih(e.contextWindow)??xr}}function $a(e){const t=e.trim().replaceAll(",","");if(t==="")return{amount:"",unit:"K"};const s=/^(\d+(?:\.\d+)?)\s*([kKmM])?$/.exec(t);if(s===null)return{amount:t,unit:"K"};const o=s[1];if(o===void 0)return{amount:t,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:t,unit:"K"}}}function pd(e,t){const s=e.trim();if(s==="")return"";switch(t){case"K":return`${s}K`;case"M":return`${s}M`;case"tokens":return s}}function fd(e,t){return t.map(s=>{const o=ah(e,s),r=o?.contextWindow!==void 0?Yh(o.contextWindow):"";return{contextWindow:r,contextWindowMode:K3(r),outputLimit:o?.outputLimit?.toString()??""}})}function hd(e){const t=e.trim();if(t==="")return null;const s=Number(t);return!Number.isInteger(s)||s<=0?null:s}function ss(e,t){if(e===void 0)return"";const s=e.trim(),o=s.replace(/\/+$/,"");return o.endsWith(t)?o.slice(0,-t.length).replace(/\/+$/,""):s}function J3(e,t,s){const o=e.trim();return o===""?null:U3(o,t,{providerName:s})}function Fa({baseUrl:e,endpoint:t,providerName:s}){const o=J3(e,t,s);return o===null?null:n.jsxs("div",{className:"border border-border bg-muted/40 rounded-md px-3 py-2 text-xs",children:[n.jsx("div",{className:"text-muted-foreground",children:"Final URL"}),n.jsx("div",{className:"break-all font-mono text-foreground",children:o.finalUrl}),o.diagnostics.length>0&&n.jsx("div",{className:"mt-2 space-y-1",children:o.diagnostics.map(r=>n.jsx("div",{className:r.severity==="warning"?"text-status-watch":"text-muted-foreground",children:r.message},`${r.severity}:${r.message}`))})]})}function X3({provider:e,onSubmit:t,onCancel:s}){const o=ad(e),[r,a]=l.useState(e?.name??""),[i,c]=l.useState(""),[d,m]=l.useState(!1),[u,p]=l.useState(!1),f=e?.models,[h,g]=l.useState(f!==void 0&&f.length>0?f:[""]),[v,y]=l.useState(()=>fd(e,f!==void 0&&f.length>0?f:[""])),[w,b]=l.useState(o.anthropic),[j,S]=l.useState(o.openai),[N,C]=l.useState(o.openaiChat),[E,A]=l.useState(o.openaiResponses),[I,R]=l.useState(ss(e?.anthropicBaseUrl,Ro)),[k,M]=l.useState(ss(e?.openaiBaseUrl,Mo)),[O,$]=l.useState(ss(e?.openaiResponsesBaseUrl,Ao)),[K,Q]=l.useState(e?.apiDocsUrl??""),[z,H]=l.useState(e?.modelMetadataUrl??""),[ee,U]=l.useState(e?.source),[Z,fe]=l.useState({}),[je,he]=l.useState(!1),[oe,L]=l.useState(null),J=l.useRef([]);l.useEffect(()=>{if(oe===null)return;const D=oe;function Y(de){if(!(de.target instanceof Node))return;const Ne=J.current[D];Ne!=null&&!Ne.contains(de.target)&&L(null)}return document.addEventListener("mousedown",Y),()=>document.removeEventListener("mousedown",Y)},[oe]);const[Se,Te]=l.useState(!1),[ge,le]=l.useState(!1),[ce,Pe]=l.useState(!1),Re=r.toLowerCase().includes("minimax"),Fe=r.toLowerCase().includes("alibaba"),lt=[...id,...ld].some(D=>r.toLowerCase().includes(D)),He=Re?cd:lt?ud:Fe?dd:[],Le=e?.modelMetadata?.some(D=>D.contextWindow!==void 0)??!1;function We(){yt(i).then(D=>{D&&(p(!0),setTimeout(()=>p(!1),2e3))})}l.useEffect(()=>{if(e){a(e.name),c(""),m(!1);const D=(e.models?.length??0)>0?e.models:[""];g(D),y(fd(e,D));const Y=ad(e);b(Y.anthropic),S(Y.openai),C(Y.openaiChat),A(Y.openaiResponses),R(ss(e.anthropicBaseUrl,Ro)),M(ss(e.openaiBaseUrl,Mo)),$(ss(e.openaiResponsesBaseUrl,Ao)),Q(e.apiDocsUrl??""),H(e.modelMetadataUrl??""),U(e.source),Te(!1),le(!1),Pe(!1)}},[e]),l.useEffect(()=>{const D=r.toLowerCase();for(const[Y,de]of Object.entries(G3))if(D.includes(Y)){de.anthropicBaseUrl!==void 0&&!Se&&R(de.anthropicBaseUrl),de.openaiBaseUrl!==void 0&&!ge&&M(de.openaiBaseUrl),de.openaiResponsesBaseUrl!==void 0&&!ce&&$(de.openaiResponsesBaseUrl),de.apiDocsUrl!==void 0&&!K&&Q(de.apiDocsUrl),Y==="minimax"&&h.length===1&&h[0]===""&&g([cd[0]??""]),Y==="alibaba"&&h.length===1&&h[0]===""&&g([dd[0]??""]),(id.includes(Y)||ld.includes(Y))&&h.length===1&&h[0]===""&&g([ud[0]??""]);break}},[r]);function Ke(){const D={};return r.trim()||(D.name="Name is required"),e===void 0&&!i.trim()&&(D.apiKey="API key is required"),(h.length===0||h.every(Y=>!Y.trim()))&&(D.models="At least one model is required"),!w&&!j&&(D.capabilities="Select at least one API capability"),j&&!N&&!E&&(D.openaiCapabilities="Select Chat Completions, Responses, or both"),w&&(I.trim()===""?D.anthropicBaseUrl="Anthropic base URL is required":Ze(I.trim())||(D.anthropicBaseUrl="Invalid URL format")),j&&N&&(k.trim()===""?D.openaiBaseUrl="OpenAI Chat base URL is required":Ze(k.trim())||(D.openaiBaseUrl="Invalid URL format")),j&&E&&(O.trim()===""?D.openaiResponsesBaseUrl="OpenAI Responses base URL is required":Ze(O.trim())||(D.openaiResponsesBaseUrl="Invalid URL format")),z.trim()&&!Ze(z.trim())&&(D.modelMetadataUrl="Invalid URL format"),v.forEach((Y,de)=>{const Ne=Xo(Y.contextWindow),F=hd(Y.outputLimit);Y.contextWindow.trim()!==""&&Ne===null&&(D[`modelMetadata.${de}.contextWindow`]="Context window must be a positive number, optionally using K or M"),Y.outputLimit.trim()!==""&&F===null&&(D[`modelMetadata.${de}.outputLimit`]="Output limit must be a positive integer"),Ne!==null&&F!==null&&F>Ne&&(D[`modelMetadata.${de}.outputLimit`]="Output limit should not exceed context window")}),fe(D),Object.keys(D).length===0}function Ze(D){try{return new URL(D),!0}catch{return!1}}function rt(D,Y){g(de=>{const Ne=[...de];return Ne[D]=Y,Ne})}function nt(D,Y){y(de=>{const Ne=[...de];return Ne[D]={...Ne[D]??Mn(),...Y},Ne})}function q(D,Y){switch(Y){case Ei:nt(D,{contextWindow:"",contextWindowMode:"unset"});return;case xr:{const de=v[D]??Mn();nt(D,{contextWindow:de.contextWindow,contextWindowMode:"custom"});return}default:nt(D,{contextWindow:Y,contextWindowMode:"preset"});return}}function se(D,Y){const de=v[D]??Mn(),Ne=$a(de.contextWindow);nt(D,{contextWindow:pd(Y,Ne.unit),contextWindowMode:"custom"})}function xe(D,Y){const de=v[D]??Mn(),Ne=$a(de.contextWindow);switch(Y){case"K":case"M":case"tokens":nt(D,{contextWindow:pd(Ne.amount,Y),contextWindowMode:"custom"});return;default:return}}function pe(D){g(Y=>Y.filter((de,Ne)=>Ne!==D)),y(Y=>Y.filter((de,Ne)=>Ne!==D))}function we(){g(D=>[...D,""]),y(D=>[...D,Mn()])}function Oe(){const D=new Date().toISOString(),Y=[];return h.forEach((de,Ne)=>{const F=de.trim();if(F==="")return;const W=v[Ne]??Mn(),X=Xo(W.contextWindow),ne=hd(W.outputLimit);if(X===null&&ne===null)return;const Ee=ah(e,F);if(Ee!==null&&Ee.contextWindow===(X??void 0)&&Ee.outputLimit===(ne??void 0)){Y.push({...Ee,model:F});return}const ie={model:F,source:"manual",updatedAt:D};X!==null&&(ie.contextWindow=X),ne!==null&&(ie.outputLimit=ne),Y.push(ie)}),Y.length>0?Y:e?.modelMetadata!==void 0?[]:void 0}function ze(D){if(D.preventDefault(),!Ke())return;he(!0);const Y=e!==void 0;try{t({name:r.trim(),apiKey:i.trim(),models:h.map(de=>de.trim()).filter(de=>de!==""),anthropicBaseUrl:za(w,I,Y),openaiBaseUrl:za(j&&N,k,Y),openaiResponsesBaseUrl:za(j&&E,O,Y),apiDocsUrl:K.trim()||void 0,modelMetadataUrl:z.trim()||void 0,modelMetadata:Oe(),source:ee})}finally{he(!1)}}return n.jsxs("form",{onSubmit:ze,className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsxs("label",{htmlFor:"provider-name",className:"text-sm font-medium",children:["Name ",n.jsx("span",{className:"text-destructive",children:"*"})]}),n.jsx("input",{id:"provider-name",type:"text",value:r,onChange:D=>a(D.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"}),Z.name!==void 0&&n.jsx("p",{className:"text-xs text-destructive",children:Z.name})]}),n.jsxs("fieldset",{className:"space-y-3",children:[n.jsxs("legend",{className:"text-sm font-medium",children:["Capabilities ",n.jsx("span",{className:"text-destructive",children:"*"})]}),n.jsxs("div",{className:"divide-y divide-border overflow-hidden rounded-md border border-border",children:[n.jsxs("div",{className:j?"bg-primary/[0.04] px-3 py-3":"px-3 py-3",children:[n.jsxs("label",{htmlFor:"provider-capability-openai",className:"flex cursor-pointer items-start gap-3",children:[n.jsx("input",{id:"provider-capability-openai",type:"checkbox",checked:j,onChange:D=>S(D.target.checked),className:"mt-0.5 size-4 shrink-0 accent-primary"}),n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"block text-sm font-medium",children:"OpenAI"}),n.jsx("span",{className:"block text-xs text-muted-foreground",children:"Chat Completions and Responses"})]})]}),j&&n.jsxs("div",{className:"ml-7 mt-3 flex flex-wrap gap-x-5 gap-y-2 border-t border-border/70 pt-3",children:[n.jsxs("label",{htmlFor:"provider-capability-openai-chat",className:"flex cursor-pointer items-center gap-2 text-sm",children:[n.jsx("input",{id:"provider-capability-openai-chat",type:"checkbox",checked:N,onChange:D=>C(D.target.checked),className:"size-4 shrink-0 accent-primary"}),"Chat Completions"]}),n.jsxs("label",{htmlFor:"provider-capability-openai-responses",className:"flex cursor-pointer items-center gap-2 text-sm",children:[n.jsx("input",{id:"provider-capability-openai-responses",type:"checkbox",checked:E,onChange:D=>A(D.target.checked),className:"size-4 shrink-0 accent-primary"}),"Responses"]})]}),Z.openaiCapabilities!==void 0&&j&&n.jsx("p",{className:"ml-7 mt-2 text-xs text-destructive",children:Z.openaiCapabilities})]}),n.jsxs("label",{htmlFor:"provider-capability-anthropic",className:`flex cursor-pointer items-start gap-3 px-3 py-3 ${w?"bg-primary/[0.04]":""}`,children:[n.jsx("input",{id:"provider-capability-anthropic",type:"checkbox",checked:w,onChange:D=>b(D.target.checked),className:"mt-0.5 size-4 shrink-0 accent-primary"}),n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"block text-sm font-medium",children:"Anthropic"}),n.jsx("span",{className:"block text-xs text-muted-foreground",children:"Messages"})]})]})]}),Z.capabilities!==void 0&&n.jsx("p",{className:"text-xs text-destructive",children:Z.capabilities})]}),(w||j&&(N||E))&&n.jsxs("section",{className:"space-y-5 border-l border-border pl-4","aria-label":"API endpoints",children:[n.jsx("h3",{className:"text-sm font-medium",children:"Endpoint Configuration"}),w&&n.jsxs("div",{className:"space-y-2",children:[n.jsxs("label",{htmlFor:"provider-anthropic-base-url",className:"text-sm font-medium",children:["Anthropic Messages Base URL ",n.jsx("span",{className:"text-destructive",children:"*"})]}),n.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:[n.jsx("input",{id:"provider-anthropic-base-url",type:"text",value:I,onChange:D=>{Te(!0),R(D.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"}),n.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:Ro})]}),Z.anthropicBaseUrl!==void 0&&n.jsx("p",{className:"text-xs text-destructive",children:Z.anthropicBaseUrl}),n.jsx(Fa,{baseUrl:I,endpoint:Ro,providerName:r})]}),j&&N&&n.jsxs("div",{className:"space-y-2",children:[n.jsxs("label",{htmlFor:"provider-openai-base-url",className:"text-sm font-medium",children:["OpenAI Chat Base URL ",n.jsx("span",{className:"text-destructive",children:"*"})]}),n.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:[n.jsx("input",{id:"provider-openai-base-url",type:"text",value:k,onChange:D=>{le(!0),M(D.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"}),n.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:Mo})]}),Z.openaiBaseUrl!==void 0&&n.jsx("p",{className:"text-xs text-destructive",children:Z.openaiBaseUrl}),n.jsx(Fa,{baseUrl:k,endpoint:Mo,providerName:r})]}),j&&E&&n.jsxs("div",{className:"space-y-2",children:[n.jsxs("label",{htmlFor:"provider-openai-responses-base-url",className:"text-sm font-medium",children:["OpenAI Responses Base URL ",n.jsx("span",{className:"text-destructive",children:"*"})]}),n.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:[n.jsx("input",{id:"provider-openai-responses-base-url",type:"text",value:O,onChange:D=>{Pe(!0),$(D.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"}),n.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:Ao})]}),Z.openaiResponsesBaseUrl!==void 0&&n.jsx("p",{className:"text-xs text-destructive",children:Z.openaiResponsesBaseUrl}),n.jsx(Fa,{baseUrl:O,endpoint:Ao,providerName:r})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx("label",{htmlFor:"provider-source",className:"text-sm font-medium",children:"Token Source"}),n.jsxs("select",{id:"provider-source",value:ee??"",onChange:D=>U(D.target.value==="company"||D.target.value==="personal"?D.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:[n.jsx("option",{value:"",children:"Unspecified"}),n.jsx("option",{value:"personal",children:"个人 (Personal)"}),n.jsx("option",{value:"company",children:"公司 (Company)"})]}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Label whether this API key is company-provided or personal."})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx("label",{htmlFor:"provider-model-metadata-url",className:"text-sm font-medium",children:"Model Metadata URL"}),n.jsx("input",{id:"provider-model-metadata-url",type:"text",value:z,onChange:D=>H(D.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"}),Z.modelMetadataUrl!==void 0&&n.jsx("p",{className:"text-xs text-destructive",children:Z.modelMetadataUrl}),z.trim()===""&&n.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&&!Le&&z.trim()===""&&n.jsx("p",{className:"text-xs text-status-watch",children:"This provider has no matching context metadata yet."}),z.trim()!==""&&n.jsx("p",{className:"text-xs text-muted-foreground",children:"Agent Inspector will refresh model limits from this JSON registry after save."})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("label",{htmlFor:"provider-apikey",className:"text-sm font-medium",children:["API Key ",e===void 0&&n.jsx("span",{className:"text-destructive",children:"*"})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("input",{id:"provider-apikey",type:d?"text":"password",value:i,onChange:D=>c(D.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"}),n.jsx("button",{type:"button",onClick:()=>m(D=>!D),className:"text-muted-foreground hover:text-foreground transition-colors p-1 shrink-0","aria-label":d?"Hide API key":"Show API key",children:d?n.jsx(pg,{className:"size-4"}):n.jsx(Ru,{className:"size-4"})}),n.jsx("button",{type:"button",onClick:We,className:"text-muted-foreground hover:text-foreground transition-colors p-1 shrink-0","aria-label":"Copy API key",children:u?n.jsx($e,{className:"size-4 text-status-success"}):n.jsx(jt,{className:"size-4"})})]}),e!==void 0&&i.trim()===""&&n.jsx("p",{className:"text-xs text-muted-foreground",children:"A key is configured. Enter a new value only to rotate it."}),Z.apiKey!==void 0&&n.jsx("p",{className:"text-xs text-destructive",children:Z.apiKey})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("label",{className:"text-sm font-medium",children:["Models ",n.jsx("span",{className:"text-destructive",children:"*"})]}),h.map((D,Y)=>{const de=v[Y]??Mn(),Ne=Z[`modelMetadata.${Y}.contextWindow`],F=Z[`modelMetadata.${Y}.outputLimit`],W=Y3(de),X=$a(de.contextWindow);return n.jsxs("div",{ref:ne=>{J.current[Y]=ne},className:"border border-border bg-card shadow-sm space-y-2 rounded-[8px] p-2",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("div",{className:"relative flex-1",children:[n.jsx("input",{type:"text",value:D,onChange:ne=>rt(Y,ne.target.value),placeholder:He.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"}),He.length>0&&n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",onClick:()=>L(oe===Y?null:Y),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:n.jsx(Xe,{className:"size-4"})}),oe===Y&&n.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:He.map(ne=>n.jsx("button",{type:"button",onClick:()=>{rt(Y,ne),L(null)},className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/60",children:ne},ne))})]})]}),h.length>1&&n.jsx("button",{type:"button",onClick:()=>pe(Y),className:"text-muted-foreground hover:text-destructive transition-colors p-1 shrink-0","aria-label":"Remove model",children:n.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:[n.jsx("path",{d:"M3 6h18"}),n.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),n.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]})})]}),n.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[n.jsxs("div",{className:"space-y-1 text-xs text-muted-foreground",children:[n.jsx("span",{children:"Context Window"}),n.jsxs(Ys,{value:W,onValueChange:ne=>q(Y,ne),children:[n.jsx(Js,{size:"sm",className:"w-full bg-background font-mono text-xs",children:n.jsx(hr,{})}),n.jsxs(Xs,{className:"max-h-64",children:[n.jsx(it,{value:Ei,children:"Not set"}),rh.map(ne=>n.jsxs(it,{value:ne.value,children:[ne.label," · ",ne.value]},ne.value)),n.jsx(it,{value:xr,children:"Custom"})]})]}),de.contextWindowMode==="custom"&&n.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_5.75rem] gap-1.5",children:[n.jsx("input",{type:"text",inputMode:"decimal",value:X.amount,onChange:ne=>se(Y,ne.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]"}),n.jsxs(Ys,{value:X.unit,onValueChange:ne=>xe(Y,ne),children:[n.jsx(Js,{size:"sm",className:"w-full bg-background font-mono text-xs",children:n.jsx(hr,{})}),n.jsxs(Xs,{children:[n.jsx(it,{value:"K",children:"K"}),n.jsx(it,{value:"M",children:"M"}),n.jsx(it,{value:"tokens",children:"tokens"})]})]})]}),Ne!==void 0&&n.jsx("span",{className:"block text-destructive",children:Ne})]}),n.jsxs("label",{className:"space-y-1 text-xs text-muted-foreground",children:[n.jsx("span",{children:"Output Limit"}),n.jsx("input",{type:"number",min:1,step:1e3,value:de.outputLimit,onChange:ne=>nt(Y,{outputLimit:ne.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]"}),F!==void 0&&n.jsx("span",{className:"block text-destructive",children:F})]})]})]},Y)}),n.jsx("button",{type:"button",onClick:we,className:"text-xs text-primary hover:underline flex items-center gap-1",children:"+ Add Model"}),Z.models!==void 0&&n.jsx("p",{className:"text-xs text-destructive",children:Z.models})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx("label",{htmlFor:"provider-api-docs-url",className:"text-sm font-medium",children:"API Docs URL"}),n.jsx("input",{id:"provider-api-docs-url",type:"text",value:K,onChange:D=>Q(D.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"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional API documentation URL. If not set, uses known provider docs."})]}),n.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:[n.jsx(te,{type:"button",variant:"outline",onClick:s,disabled:je,children:"Cancel"}),n.jsx(te,{type:"submit",disabled:je,children:je?"Saving...":e?"Update Provider":"Add Provider"})]})]})}const Z3=me(["timeout","network_unreachable","connection_refused","auth_failed","rate_limited","server_error","invalid_response","unknown"]),Q3=_({message:x(),type:Z3,details:x().optional(),hint:x().optional()}),e4=_({type:me(["text","thinking"]),text:x().optional(),thinking:x().optional()}),t4=_({requestUrl:x().optional(),requestMethod:x().optional(),requestHeaders:qe(x(),x()).optional(),requestBody:x().optional(),responseStatus:T().optional(),responseStatusText:x().optional(),responseHeaders:qe(x(),x()).optional(),responseBody:x().optional()}),Io=T().nullable().optional(),n4=_({success:Ce(),error:Q3.optional(),model:x().optional(),inputTokens:Io,outputTokens:Io,cacheCreationInputTokens:Io,cacheReadInputTokens:Io,latencyMs:T().optional(),firstChunkMs:T().nullable().optional(),totalStreamMs:T().nullable().optional(),tokensPerSecond:T().nullable().optional(),content:V(e4).optional(),rawResponse:x().optional(),streaming:Ce().optional(),streamingChunks:_({chunks:V(iu),truncated:Ce().default(!1)}).optional(),requestHeaders:qe(x(),x()).optional(),debug:t4.optional()}),xd=Vt([n4,_({notConfigured:ae(!0)}),_({testing:ae(!0)})]),gn=_({nonStreaming:xd,streaming:xd});function gr(){return{nonStreaming:{notConfigured:!0},streaming:{notConfigured:!0}}}const s4=_({anthropic:gn,openai:gn.optional(),openaiChat:gn.optional(),openaiResponses:gn.optional()}).transform(e=>{const t=e.openaiChat??e.openai??gr();return{...e,openai:e.openai??t,openaiChat:t,openaiResponses:e.openaiResponses??gr()}}),o4=_({anthropic:gn,openai:gn.optional(),openaiChat:gn.optional(),openaiResponses:gn.optional(),models:qe(x(),s4).optional(),testedAt:x().optional()}).transform(e=>{const t=e.openaiChat??e.openai??gr();return{...e,openai:e.openai??t,openaiChat:t,openaiResponses:e.openaiResponses??gr()}});function r4(){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 gd(e,t){const s=()=>({nonStreaming:{success:!1,error:{message:e,type:t}},streaming:{notConfigured:!0}});return{anthropic:s(),openai:s(),openaiChat:s(),openaiResponses:s()}}const a4=_({providerConfig:x()}),i4=_({success:Ce().optional(),imported:T().optional(),message:x().optional(),errors:V(x()).optional()}),l4=_({provider:sr,imported:T(),matchedModels:V(x()),missingModels:V(x()),sourceUrl:x()}),Po="Network error: could not reach the server. Is the proxy running?",c4=5e3,d4=5e3,bd=15e3,u4=1e4,m4=2e4,p4=2e4,f4=3e4;function Ba(e,t){return(e?.length??0)>0?e:t&&e!==void 0?"":void 0}function vd(e,t=!1){return{name:e.name,...e.apiKey.trim()===""?{}:{apiKey:e.apiKey},models:e.models,anthropicBaseUrl:Ba(e.anthropicBaseUrl,t),openaiBaseUrl:Ba(e.openaiBaseUrl,t),openaiResponsesBaseUrl:Ba(e.openaiResponsesBaseUrl,t),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 h4(e,t){const s=e?.models?.map(o=>o.trim()).filter(o=>o!=="").length??0;return Math.max(1,s)*t}async function x4(e,t){if(t.models!==void 0)try{await On(`/api/providers/${e}/test/log`,d4,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}catch{}}function g4({externalProviders:e,isLoading:t=!1,externalTestResults:s,externalTestingProviders:o,externalTestingTimeLeft:r,onProvidersMutate:a,onTestResultsChange:i,onTestingProvidersChange:c,onTestingTimeLeftChange:d}){const[m,u]=l.useState(!1),[p,f]=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),[E,A]=l.useState(!1),[I,R]=l.useState(null),[k,M]=l.useState(!1),[O,$]=l.useState(!1),[K,Q]=l.useState(null),[z,H]=l.useState("all"),[ee,U]=l.useState(new Set),{providerTestTimeoutSeconds:Z}=Ki(),fe=l.useRef(null),je=l.useRef(null),he=e??[],oe=l.useMemo(()=>{const q=z==="all"?he:he.filter(se=>se.source===z);return z==="all"?[...q].sort((se,xe)=>{const pe={personal:0,company:1};return(pe[se.source??""]??2)-(pe[xe.source??""]??2)}):q},[he,z]),L=s??v,J=o??w,Se=r??j,Te=d?(q,se)=>d(q,se):(q,se)=>{S(se===void 0?xe=>{const pe={...xe};return delete pe[q],pe}:xe=>({...xe,[q]:se}))};l.useEffect(()=>{(async()=>{try{const q=await Be("/api/config/paths",a4,c4);C(q.providerConfig)}catch{}})()},[]);const ge=l.useCallback(q=>{je.current!==null&&clearTimeout(je.current),R(q),fe.current?.scrollTo({top:fe.current.scrollHeight,behavior:"smooth"}),je.current=setTimeout(()=>{R(null),je.current=null},2e3)},[]);l.useEffect(()=>()=>{je.current!==null&&clearTimeout(je.current)},[]);const le=l.useCallback(()=>{a?.().catch(()=>{})},[a]),ce=l.useCallback((q,se)=>{i?i(q,se):y(xe=>({...xe,[q]:se}))},[i]),Pe=l.useCallback((q,se)=>{if(c){c(q,se);return}b(xe=>{const pe=new Set(xe);return se?pe.add(q):pe.delete(q),pe})},[c]),Re=l.useCallback(async q=>{ce(q,r4()),Pe(q,!0);const se=new AbortController,xe=he.find(ze=>ze.id===q),pe=h4(xe,Z);let we=pe;Te(q,we);const Oe=setInterval(()=>{we--,Te(q,we),we<=0&&(clearInterval(Oe),se.abort())},1e3);try{const ze=await Be(`/api/providers/${q}/test`,o4,pe*1e3+1e3,{method:"POST",signal:se.signal},D=>`HTTP ${D.status}: ${D.statusText}`);ce(q,ze),await x4(q,ze)}catch(ze){const D=ze instanceof Error&&ze.name==="AbortError",Y=ze instanceof Li;D||Y?ce(q,gd("Request timed out","timeout")):ze instanceof Error&&ce(q,gd(ze.message,"server_error"))}finally{clearInterval(Oe),Te(q,void 0),Pe(q,!1)}},[Z,he,Te,ce,Pe]),Fe=l.useCallback(async(q,se,xe=!0)=>{U(pe=>{const we=new Set(pe);return we.add(q),we});try{const pe=se!==void 0&&se.trim()!==""?{url:se}:{},we=await Be(`/api/providers/${q}/model-metadata`,l4,f4,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(pe)},()=>"Failed to refresh model metadata");return we.imported===0&&xe?g("No matching model metadata found for this provider."):g(null),ge(we.provider.id),le(),we.imported>0}catch(pe){return xe&&g(pe instanceof Error?pe.message:Po),!1}finally{U(pe=>{const we=new Set(pe);return we.delete(q),we})}},[le,ge]);function lt(q){(async()=>{try{const se=await Be("/api/providers",sr,bd,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(vd(q))},()=>"Failed to add provider");u(!1),ge(se.id),q.modelMetadataUrl!==void 0&&q.modelMetadataUrl.trim()!==""&&await Fe(se.id,q.modelMetadataUrl,!1),le(),await Re(se.id)}catch(se){g(se instanceof Error?se.message:Po)}})()}function He(q){p&&(async()=>{try{const se=await Be(`/api/providers/${p.id}`,sr,bd,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(vd(q,!0))},()=>"Failed to update provider");f(void 0),ge(se.id),q.modelMetadataUrl!==void 0&&q.modelMetadataUrl.trim()!==""&&await Fe(se.id,q.modelMetadataUrl,!1),le(),(q.apiKey.trim()!==""||JSON.stringify(q.models)!==JSON.stringify(p.models)||(q.anthropicBaseUrl??"")!==(p.anthropicBaseUrl??"")||(q.openaiBaseUrl??"")!==(p.openaiBaseUrl??"")||(q.openaiResponsesBaseUrl??"")!==(p.openaiResponsesBaseUrl??""))&&await Re(se.id)}catch(se){g(se instanceof Error?se.message:Po)}})()}function Le(q){Q(q),$(!0)}function We(){const q=K;q!==null&&(async()=>{let se;try{se=await On(`/api/providers/${q}`,u4,{method:"DELETE"})}catch{g(Po);return}if(!se.ok){g(await Xh(se,"Failed to delete provider"));return}le()})()}const Ke=l.useRef(null);function Ze(q){const se="/api/providers/export";(async()=>{try{const xe=await On(se,m4);if(!xe.ok){g("Failed to export providers");return}const pe=await xe.blob(),we=URL.createObjectURL(pe),Oe=document.createElement("a");Oe.href=we,Oe.download=xe.headers.get("Content-Disposition")?.match(/filename="(.+)"/)?.[1]??"providers.json",document.body.appendChild(Oe),Oe.click(),document.body.removeChild(Oe),URL.revokeObjectURL(we)}catch{g("Failed to export providers")}})()}function rt(){Ke.current?.click()}function nt(q){const se=q.target.files?.[0];se&&(async()=>{try{const xe=await se.text(),pe=await On("/api/providers/import",p4,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(xe)}),we=await Jh(pe,i4);pe.ok&&we.imported!==void 0&&we.imported>0?(le(),g(null)):we.errors&&we.errors.length>0?g(we.errors.join("; ")):g(we.message??"Import failed")}catch{g("Failed to import providers")}q.target.value=""})()}return t?n.jsx("div",{className:"flex items-center justify-center py-8",children:n.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading providers..."})}):m||p?n.jsxs("div",{className:"space-y-4",children:[n.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:n.jsx("h3",{className:"text-lg font-medium",children:p?"Edit Provider":"Add New Provider"})}),n.jsx(X3,{provider:p,onSubmit:p?He:lt,onCancel:()=>{u(!1),f(void 0)}})]}):n.jsxs("div",{className:"space-y-4",children:[n.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:[n.jsxs(te,{variant:"outline",size:"sm",onClick:()=>Ze(),className:"gap-1 hover:bg-muted",children:[n.jsx(to,{className:"size-3"}),"Export"]}),n.jsxs(te,{variant:"outline",size:"sm",onClick:rt,className:"gap-1 hover:bg-muted",children:[n.jsx($u,{className:"size-3"}),"Import"]}),n.jsx("input",{type:"file",ref:Ke,accept:".json",onChange:nt,style:{display:"none"}}),n.jsxs(te,{variant:"outline",size:"sm",onClick:()=>M(!0),className:"gap-1",children:[n.jsx(w1,{className:"size-3"}),"Scan"]}),n.jsxs(te,{onClick:()=>u(!0),size:"sm",className:"gap-1",children:[n.jsx(tc,{className:"size-4"}),"Add Provider"]})]}),N!==null&&n.jsxs("div",{className:"flex items-center gap-2 rounded-[8px] bg-muted/15 px-3 py-2 text-xs text-muted-foreground",children:[n.jsx("span",{className:"font-mono truncate",title:N,children:N}),n.jsx("button",{type:"button",onClick:()=>{yt(N).then(q=>{q&&(A(!0),setTimeout(()=>A(!1),2e3))})},className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-foreground","aria-label":E?"Copied config file path":"Copy config file path",children:E?n.jsx($e,{className:"size-3 text-status-success"}):n.jsx(jt,{className:"size-3"})})]}),h!==null&&n.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:[n.jsx(gs,{className:"size-4 shrink-0"}),h]}),he.length===0?n.jsxs("div",{className:"border border-border bg-card shadow-sm space-y-3 rounded-[8px] py-12 text-center",children:[n.jsx("p",{className:"text-sm text-muted-foreground",children:"No providers configured yet."}),n.jsxs(te,{onClick:()=>u(!0),variant:"outline",size:"sm",children:[n.jsx(tc,{className:"size-4"}),"Add Your First Provider"]})]}):n.jsxs("div",{className:"space-y-3",children:[n.jsx("div",{className:"inline-flex w-fit gap-1 rounded-[8px] bg-muted/20 p-1",children:["all","personal","company"].map(q=>n.jsx("button",{type:"button",onClick:()=>H(q),className:`rounded-md px-3 py-1.5 text-sm font-medium transition-colors ${z===q?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:q==="all"?"All":q==="personal"?"Personal":"Company"},q))}),n.jsx("div",{ref:fe,className:"space-y-3",children:oe.map(q=>n.jsx($3,{provider:q,testResults:L[q.id],isTesting:J.has(q.id),testingTimeLeft:Se[q.id],isHighlighted:q.id===I,onEdit:se=>f(se),onDelete:Le,onRefreshMetadata:se=>{Fe(se)},isRefreshingMetadata:ee.has(q.id),onTest:se=>{Re(se)}},q.id))})]}),n.jsx(h3,{open:k,onOpenChange:M,onImportComplete:()=>{a!==void 0&&a()}}),n.jsx(mf,{open:O,onOpenChange:$,title:"Delete Provider",description:"Are you sure you want to delete this provider? This action cannot be undone.",confirmLabel:"Delete",variant:"destructive",onConfirm:We})]})}const b4=[{value:"providers",label:"Providers"},{value:"proxy",label:"Proxy"},{value:"storage",label:"Storage"},{value:"mcp",label:"MCP"},{value:"onboarding",label:"Onboarding"}];function v4(){return n.jsx(Rf,{"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:b4.map(e=>n.jsx(Zt,{value:e.value,className:"min-w-0 w-full",children:e.label},e.value))})}function y4(){const[e,t]=l.useState(!1),[s,o]=l.useState("providers"),{providers:r,isLoading:a,mutate:i}=ol(),[c,d]=l.useState({}),[m,u]=l.useState(new Set),[p,f]=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)=>{f(b=>{if(w===void 0){const j={...b};return delete j[y],j}return{...b,[y]:w}})},[]);return n.jsxs(qt,{open:e,onOpenChange:t,children:[n.jsx(io,{asChild:!0,children:n.jsxs(te,{variant:"ghost",size:"icon",className:uo,"aria-label":"Settings",title:"Settings",children:[n.jsx(E1,{className:"size-4"}),n.jsx("span",{className:"sr-only",children:"Settings"})]})}),n.jsxs(Ht,{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:[n.jsx(Yt,{children:n.jsx(Jt,{children:"Settings"})}),n.jsxs(Ef,{value:s,onValueChange:o,className:"min-h-0 min-w-0 flex-1 overflow-hidden",children:[n.jsx(v4,{}),n.jsxs("div",{className:"mt-4 min-w-0 flex-1 overflow-x-hidden overflow-y-auto pr-1 sm:pr-2",children:[n.jsx(ct,{value:"providers",children:n.jsx(g4,{externalProviders:r,isLoading:a,externalTestResults:c,externalTestingProviders:m,externalTestingTimeLeft:p,onProvidersMutate:()=>i(),onTestResultsChange:h,onTestingProvidersChange:g,onTestingTimeLeftChange:v})}),n.jsx(ct,{value:"proxy",children:n.jsx(T4,{})}),n.jsx(ct,{value:"storage",children:n.jsx(S4,{})}),n.jsx(ct,{value:"mcp",children:n.jsx(_4,{})}),n.jsx(ct,{value:"onboarding",children:n.jsx(k4,{})})]})]})]})]})}const w4=_({kind:x(),root:x(),sensitivity:x(),cleanupBehavior:x(),fileCount:T(),bytes:T(),oldestModifiedAt:x().nullable(),newestModifiedAt:x().nullable()}),yd=_({memoryCount:T(),inventory:_({checkedAt:x(),totalFiles:T(),totalBytes:T(),artifacts:V(w4)}),policy:_({maxAgeMs:T(),maxTotalBytes:T()}),reclaimableBytes:T(),lastGc:_({checkedAt:x(),filesDeleted:T(),bytesDeleted:T(),errors:T(),beforeTotalBytes:T(),afterTotalBytes:T()}).nullable()}),wd=1e4;function $s(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 j4(e){return`${Math.round(e/1e3/60/60/24).toLocaleString()} days`}function S4(){const[e,t]=l.useState(null),[s,o]=l.useState(null),[r,a]=l.useState(!1),[i,c]=l.useState(!1),[d,m]=l.useState(null),u=l.useCallback(async()=>{a(!0),o(null);try{const h=await Be("/api/storage",yd,wd,void 0,g=>`Failed to load storage stats: HTTP ${String(g.status)}`);t(h)}catch(h){o(h instanceof Error?h.message:String(h))}finally{a(!1)}},[]);l.useEffect(()=>{u()},[u]);const p=l.useCallback((h,g)=>{yt(g).then(v=>{v&&(m(h),setTimeout(()=>m(null),1600))})},[]),f=l.useCallback(async()=>{c(!0),o(null);try{const h=await Be("/api/storage",yd,wd,{method:"POST"},g=>`Failed to run storage GC: HTTP ${String(g.status)}`);t(h)}catch(h){o(h instanceof Error?h.message:String(h))}finally{c(!1)}},[]);return n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("h3",{className:"text-sm font-semibold",children:"Storage lifecycle"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Inspect local captured-data footprint, retention policy, and safe reclaim actions."})]}),n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[n.jsx(te,{type:"button",variant:"outline",size:"sm",onClick:()=>{f()},disabled:i,children:i?"Running...":"Run GC now"}),n.jsx(te,{type:"button",variant:"outline",size:"sm",onClick:()=>{u()},children:r?"Refreshing...":"Refresh"})]})]}),e!==null&&n.jsxs("div",{className:"grid gap-2 text-xs",children:[n.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[n.jsx(Lo,{label:"Persisted footprint",value:`${e.inventory.totalFiles.toLocaleString()} files / ${$s(e.inventory.totalBytes)}`,detail:`Checked ${new Date(e.inventory.checkedAt).toLocaleString()}`}),n.jsx(Lo,{label:"Auto-reclaimable",value:$s(e.reclaimableBytes),detail:`Retention ${j4(e.policy.maxAgeMs)} / max ${$s(e.policy.maxTotalBytes)}`}),n.jsx(Lo,{label:"In-memory logs",value:`${e.memoryCount.toLocaleString()} loaded`,detail:"Recent completed entries kept hot for the UI"}),n.jsx(Lo,{label:"Last GC",value:e.lastGc===null?"Not run yet":`${e.lastGc.filesDeleted.toLocaleString()} files / ${$s(e.lastGc.bytesDeleted)}`,detail:e.lastGc===null?"Runs at startup, on schedule, or manually here":`${new Date(e.lastGc.checkedAt).toLocaleString()} · ${e.lastGc.errors} errors`})]}),e.inventory.artifacts.map(h=>n.jsx(C4,{artifact:h,copiedId:d,onCopy:p},`${h.kind}:${h.root}`))]}),s!==null&&n.jsx("p",{className:"text-xs text-destructive",children:s})]})}function N4(e){switch(e){case"retention-gc":return"Retention GC";case"orphan-reclaim":return"Orphan reclaim";case"rotation":return"Rotation-owned";case"manual-owner-delete":return"Manual only";default:return e}}function Lo({label:e,value:t,detail:s}){return n.jsxs("div",{className:"rounded-md bg-muted/20 px-3 py-2",children:[n.jsx("div",{className:"font-medium",children:e}),n.jsx("div",{className:"mt-1 font-mono text-muted-foreground",children:t}),n.jsx("div",{className:"mt-1 text-[11px] text-muted-foreground",children:s})]})}function C4({artifact:e,copiedId:t,onCopy:s}){const o=`storage-${e.kind}`,r=e.oldestModifiedAt===null?"none":new Date(e.oldestModifiedAt),a=e.newestModifiedAt===null?"none":new Date(e.newestModifiedAt);return n.jsxs("div",{className:"rounded-md border border-border/45 bg-muted/15 px-3 py-2",children:[n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n.jsxs("div",{children:[n.jsx("div",{className:"font-medium",children:e.kind}),n.jsxs("div",{className:"mt-1 text-[11px] text-muted-foreground",children:[N4(e.cleanupBehavior)," · ",e.sensitivity]})]}),n.jsxs("div",{className:"text-right font-mono text-muted-foreground",children:[e.fileCount.toLocaleString()," files / ",$s(e.bytes)]})]}),n.jsxs("div",{className:"mt-2 grid gap-1 text-[11px] text-muted-foreground sm:grid-cols-2",children:[n.jsxs("div",{children:["Oldest: ",r instanceof Date?r.toLocaleString():r]}),n.jsxs("div",{children:["Newest: ",a instanceof Date?a.toLocaleString():a]})]}),n.jsx("div",{className:"mt-2",children:n.jsx(ql,{id:o,label:"Root path",value:e.root,copiedId:t,onCopy:s})})]})}function ql({id:e,label:t,value:s,copiedId:o,onCopy:r}){const a=o===e;return n.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:[n.jsx("div",{className:"mb-1 text-xs font-medium text-muted-foreground",children:t}),n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs text-foreground",title:s,children:s}),n.jsx(te,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0",onClick:()=>r(e,s),"aria-label":a?`Copied ${t}`:`Copy ${t}`,children:a?n.jsx($e,{className:"size-3.5 text-status-success"}):n.jsx(jt,{className:"size-3.5"})})]})]})}function k4(){const[e,t]=l.useState(null),[s,o]=l.useState(null);l.useEffect(()=>Qi(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:"doctor",label:"Backend doctor",value:"agent-inspector doctor --verbose"},{id:"support-bundle",label:"Redacted support bundle",value:"agent-inspector doctor --support-bundle"},{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)=>{yt(c).then(d=>{d&&(t(i),setTimeout(()=>t(null),1600))})},[]);return n.jsxs("div",{className:"min-w-0 space-y-4",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(qn,{className:"size-4 text-muted-foreground"}),n.jsx("h3",{className:"text-sm font-semibold",children:"Agent onboarding"})]}),n.jsx("div",{className:"grid gap-2",children:r.map(i=>n.jsx(ql,{id:i.id,label:i.label,value:i.value,copiedId:e,onCopy:a},i.id))}),n.jsxs("div",{className:"grid gap-2 rounded-md border border-status-info/25 bg-status-info/10 px-3 py-2 text-xs",children:[n.jsx("div",{className:"font-medium text-foreground",children:"Verified first trace flow"}),n.jsxs("ol",{className:"ml-4 list-decimal space-y-1 text-muted-foreground",children:[n.jsx("li",{children:"Start Agent Inspector and confirm the application bar shows Live."}),n.jsx("li",{children:"Copy the Proxy URL or MCP URL that matches your coding agent."}),n.jsx("li",{children:"Run a tiny coding-agent prompt such as “say hello and stop”."}),n.jsx("li",{children:"Return to Logs and confirm one new request appears with request, response, tokens, and tool activity when present."})]})]}),n.jsxs("div",{className:"grid gap-2 rounded-md bg-muted/15 px-3 py-2 text-xs text-muted-foreground",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx($e,{className:"size-3.5 text-status-success"}),n.jsx("span",{children:"Provider test creates a traceable memory probe session."})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx($e,{className:"size-3.5 text-status-success"}),n.jsx("span",{children:"Captured sessions can produce reviewable memory candidates."})]}),n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx($e,{className:"mt-0.5 size-3.5 text-status-success"}),n.jsxs("span",{children:["Streamable HTTP clients should use the MCP URL directly. Stdio-only clients should use",n.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."]})]}),n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx($e,{className:"mt-0.5 size-3.5 text-status-success"}),n.jsxs("span",{children:["OpenCode onboarding safely merges"," ",n.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"mcp.agent-inspector"})," ","into"," ",n.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"opencode.json"}),", then verify with"," ",n.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"opencode mcp list"}),"."]})]}),n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx($e,{className:"mt-0.5 size-3.5 text-status-success"}),n.jsxs("span",{children:["MiMo Code onboarding safely merges"," ",n.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"mcp.agent-inspector"})," ","into"," ",n.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"," ",n.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"OPENAI_BASE_URL"}),"."]})]}),n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx($e,{className:"mt-0.5 size-3.5 text-status-success"}),n.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."})]}),n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx($e,{className:"mt-0.5 size-3.5 text-status-success"}),n.jsxs("span",{children:["If the first trace does not appear, run"," ",n.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"agent-inspector doctor --verbose"})," ","and compare the agent base URL with the current Proxy URL. A base-path mismatch such as"," ",n.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"/"})," ","versus"," ",n.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"/inspector"})," ","means the tool is talking to a different Inspector surface."]})]})]})]})}function _4(){const[e,t]=l.useState(null),[s,o]=l.useState(null);l.useEffect(()=>Qi(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]
|
|
59
59
|
command = "agent-inspector-mcp"
|
|
60
|
-
args = ["stdio", "--url", "${s}"]`}],[s]),a=l.useCallback((i,c)=>{Tt(c).then(d=>{d&&(t(i),setTimeout(()=>t(null),1600))})},[]);return n.jsxs("div",{className:"min-w-0 space-y-4",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(qn,{className:"size-4 text-muted-foreground"}),n.jsx("h3",{className:"text-sm font-semibold",children:"MCP access"})]}),n.jsxs("div",{className:"grid gap-2 rounded-md bg-muted/15 px-3 py-2 text-xs text-muted-foreground",children:[n.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."}),n.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?n.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."}):n.jsx("div",{className:"grid gap-2",children:r.map(i=>n.jsx(ql,{id:i.id,label:i.label,value:i.value,copiedId:e,onCopy:a},i.id))})]})}function T4(){const{strip:e,slowResponseThresholdSeconds:t,providerTestTimeoutSeconds:s,timeDisplayFormat:o,isLoading:r,setStrip:a,setSlowResponseThresholdSeconds:i,setProviderTestTimeoutSeconds:c,setTimeDisplayFormat:d}=Ki(),[m,u]=l.useState(null),[p,f]=l.useState(!1),h=l.useCallback(async w=>{u(null),f(!0);try{await a(w)}catch(v){u(v instanceof Error?v.message:String(v))}finally{f(!1)}},[a]),g=l.useCallback(async w=>{u(null),f(!0);try{await i(w)}catch(v){u(v instanceof Error?v.message:String(v))}finally{f(!1)}},[i]),b=l.useCallback(async w=>{u(null),f(!0);try{await c(w)}catch(v){u(v instanceof Error?v.message:String(v))}finally{f(!1)}},[c]),y=l.useCallback(async w=>{u(null),f(!0);try{await d(w)}catch(v){u(v instanceof Error?v.message:String(v))}finally{f(!1)}},[d]);return n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsx("h3",{className:"text-sm font-semibold",children:"Claude Code billing header"}),n.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 ",n.jsx("code",{children:"config.json"}),"."]})]}),n.jsxs("label",{className:"flex items-center gap-3",children:[n.jsx("input",{type:"checkbox",role:"switch",checked:e,disabled:r||p,onChange:w=>{h(w.currentTarget.checked)},className:"size-4 cursor-pointer disabled:cursor-not-allowed disabled:opacity-50"}),n.jsx("span",{className:"text-sm",children:r?"Loading...":e?"Stripping enabled":"Stripping disabled"})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsx("label",{htmlFor:"slow-response-threshold",className:"text-sm font-semibold",children:"Slow response threshold"}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:["Show a slow marker when elapsed time exceeds this many seconds. Use ",n.jsx("code",{children:"0"})," to disable it."]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("input",{id:"slow-response-threshold",type:"number",min:0,max:Xa,step:1,value:t,disabled:r||p,onChange:w=>{const v=Number(w.currentTarget.value);Number.isInteger(v)&&(v<0||v>Xa||g(v))},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"}),n.jsx("span",{className:"text-xs text-muted-foreground",children:"seconds"})]})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsx("label",{htmlFor:"provider-test-timeout",className:"text-sm font-semibold",children:"Provider test timeout"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Abort slow Provider Test probes after this many seconds per model."}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("input",{id:"provider-test-timeout",type:"number",min:1,max:Za,step:1,value:s,disabled:r||p,onChange:w=>{const v=Number(w.currentTarget.value);Number.isInteger(v)&&(v<1||v>Za||b(v))},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"}),n.jsx("span",{className:"text-xs text-muted-foreground",children:"seconds / model"})]})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsx("label",{htmlFor:"time-display-format",className:"text-sm font-semibold",children:"Time display"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Controls timestamps in session summaries, headers, and log rows."}),n.jsxs("select",{id:"time-display-format",value:o,disabled:r||p,onChange:w=>{const v=Cu.safeParse(w.currentTarget.value);v.success&&y(v.data)},className:"h-8 rounded-md border border-input bg-background px-2 text-sm disabled:cursor-not-allowed disabled:opacity-50",children:[n.jsx("option",{value:"time",children:"Time only"}),n.jsx("option",{value:"full",children:"Full ISO"})]})]}),m!==null&&n.jsxs("p",{className:"text-xs text-destructive",children:["Failed to save: ",m]})]})}const E4=me(["installed","update-available","available","planned","unknown"]),R4=_({id:x(),name:x(),npmName:x(),capability:x(),description:x(),workflow:x(),installCommand:x(),state:E4,installedVersion:x().nullable(),latestVersion:x().nullable(),primary:Ce()}),M4=_({id:x(),name:x(),validatedVersion:x(),binary:x(),modelFlag:x(),variantFlag:x().nullable(),tools:V(x()),logDir:x(),skillsDir:x(),agentsDir:x()}),A4=_({id:x(),title:x(),stage:x(),packageId:x(),description:x(),command:x(),requiresSession:Ce(),runnable:Ce()}),I4=_({checkedAt:x(),packages:V(R4),runnerPresets:V(M4),recipes:V(A4)}),lh=me(["install","upgrade","help","runner-presets","recipe"]),ch="RUN_LOCAL_COMMAND",P4=_({action:lh,targetId:x(),targetName:x(),command:x(),source:x(),timeoutMs:T().int().positive(),scope:x()}),L4=_({nonce:x().uuid(),phrase:ae(ch),expiresAt:x().datetime(),plan:P4}),dh=_({confirmation:L4});Nn("intent",[_({intent:ae("prepare")}),_({intent:ae("confirm"),nonce:x().uuid(),confirmation:ae(ch)})]);const O4=me(["queued","running","succeeded","failed"]),uh=_({id:x(),packageId:x(),npmName:x(),recipeId:x().nullable().default(null),action:lh,status:O4,command:x(),output:x(),createdAt:x(),startedAt:x().nullable(),finishedAt:x().nullable(),exitCode:T().nullable(),error:x().nullable()}),mh=_({task:uh}),D4=_({tasks:V(uh)}),z4=[{id:"observe",title:"Observe",label:"Live",description:"Capture IDE, process, session, turn, request, response, tools, and providers.",metric:"Inspector core",icon:l0},{id:"replay",title:"Replay",label:"Ready",description:"Promote real logs into repeatable replay evidence without losing the raw context.",metric:"Session asset",icon:Et},{id:"evaluate",title:"Evaluate",label:"Next",description:"Use eval-harness to turn sessions into regression cases and provider bakeoffs.",metric:"Eval loop",icon:Yi},{id:"connect",title:"Connect",label:"MCP",description:"Expose Inspector state to coding agents as queryable context and durable evidence.",metric:"/api/mcp",icon:e1}];async function $4(e){return tt(e,I4,void 0,t=>`Failed to load ecosystem packages: ${String(t.status)}`)}async function F4(e){return tt(e,mh,void 0,t=>`Failed to load ecosystem task: ${String(t.status)}`)}async function B4(e){return tt(e,D4,void 0,t=>`Failed to load ecosystem tasks: ${String(t.status)}`)}async function U4(e,t){const s=`/api/ecosystem/packages/${encodeURIComponent(e)}/${t}`,o=await tt(s,dh,{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 q4(e){const t=`/api/ecosystem/recipes/${encodeURIComponent(e)}/run`,s=await tt(t,dh,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({intent:"prepare"})},o=>`Failed to prepare ecosystem recipe: ${String(o.status)}`);return{endpoint:t,confirmation:s.confirmation}}async function H4(e){return(await tt(e.endpoint,mh,{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 V4(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 W4(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 G4(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 Bs(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 K4(e){switch(e.status){case"queued":return"Queued";case"running":return`${Bs(e.action)} running`;case"succeeded":return`${Bs(e.action)} complete`;case"failed":return`${Bs(e.action)} failed`}}function ph(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 Y4(e){switch(e.state){case"available":return"install";case"update-available":return"upgrade";case"installed":case"planned":case"unknown":return null}}function J4({pkg:e,activeTask:t,onStartTask:s}){const o=Y4(e),r=t!==null&&t.packageId===e.id&&t.status==="running";return n.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[n.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[n.jsx(o1,{className:"size-4 shrink-0 text-white/55"}),n.jsx("div",{className:"text-sm font-semibold leading-snug",children:e.name})]}),n.jsx("div",{className:"mt-1 break-all font-mono text-[11px] leading-snug text-white/35",children:e.npmName})]}),n.jsx(_e,{className:P("shrink-0",W4(e.state)),variant:"outline",children:V4(e.state)})]}),n.jsx("div",{className:"mt-3 text-xs leading-5 text-muted-foreground",children:e.description}),n.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2 text-[11px]",children:[n.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 font-mono text-white/50",children:G4(e)}),n.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 text-white/45",children:e.capability}),n.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 font-mono text-white/35",children:e.installCommand})]}),n.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[o!==null&&n.jsxs(te,{type:"button",size:"sm",variant:"secondary",disabled:r,onClick:()=>s(e.id,o),children:[r?n.jsx(Ue,{className:"size-3.5 animate-spin"}):n.jsx(to,{className:"size-3.5"}),Bs(o)]}),n.jsxs(te,{type:"button",size:"sm",variant:"outline",disabled:r||e.state==="planned",onClick:()=>s(e.id,"help"),children:[n.jsx(qn,{className:"size-3.5"}),"Help"]}),e.id==="eval-harness"&&n.jsxs(te,{type:"button",size:"sm",variant:"ghost",disabled:r||e.state==="planned",onClick:()=>s(e.id,"runner-presets"),children:[n.jsx(Yi,{className:"size-3.5"}),"Presets"]})]})]})}function X4({task:e}){if(e===null)return null;const t=e.status==="queued"||e.status==="running";return n.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:[n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t?n.jsx(Ue,{className:"size-4 animate-spin text-cyan-200/75"}):n.jsx(qn,{className:"size-4 text-white/55"}),n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:"text-sm font-semibold",children:K4(e)}),n.jsx("div",{className:"break-all font-mono text-[11px] text-white/35",children:e.command})]})]}),n.jsx(_e,{variant:"outline",className:P("shrink-0",ph(e.status)),children:e.status})]}),n.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&&n.jsx("div",{className:"mt-2 text-xs text-red-100",children:e.error})]})}function Z4({workflow:e}){const t=e.icon;return n.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[n.jsxs("div",{className:"flex items-start justify-between gap-3",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(t,{className:"size-4 shrink-0 text-cyan-200/75"}),n.jsx("div",{className:"text-sm font-semibold",children:e.title})]}),n.jsx("span",{className:"rounded bg-white/[0.04] px-2 py-0.5 font-mono text-[10px] text-white/45",children:e.label})]}),n.jsx("div",{className:"mt-2 min-h-10 text-xs leading-5 text-muted-foreground",children:e.description}),n.jsx("div",{className:"mt-3 font-mono text-[11px] text-white/35",children:e.metric})]})}function Q4(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 e_({preset:e}){return n.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[n.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[n.jsx(Ou,{className:"size-4 shrink-0 text-cyan-200/75"}),n.jsx("div",{className:"text-sm font-semibold leading-snug",children:e.name})]}),n.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}`:""]})]}),n.jsxs(_e,{variant:"outline",className:"border-white/10 bg-white/[0.04] text-white/55",children:["v",e.validatedVersion]})]}),n.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-[11px]",children:[n.jsxs("div",{className:"rounded bg-black/15 px-2 py-1 text-white/45",children:["logs/",e.logDir]}),n.jsx("div",{className:"rounded bg-black/15 px-2 py-1 text-white/45",children:e.tools.join(", ")}),n.jsx("div",{className:"rounded bg-black/15 px-2 py-1 font-mono text-white/35",children:e.skillsDir}),n.jsx("div",{className:"rounded bg-black/15 px-2 py-1 font-mono text-white/35",children:e.agentsDir})]})]})}function t_({recipe:e,copied:t,running:s,onCopy:o,onRun:r}){return n.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[n.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[n.jsx(Mu,{className:"size-4 shrink-0 text-cyan-200/75"}),n.jsx("div",{className:"text-sm font-semibold leading-snug",children:e.title})]}),n.jsx("div",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:e.description})]}),n.jsx(_e,{variant:"outline",className:"border-white/10 bg-white/[0.04] text-white/55",children:e.runnable?e.stage:"Template"})]}),n.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}),n.jsxs("div",{className:"mt-3 flex items-center justify-between gap-2",children:[n.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 font-mono text-[11px] text-white/35",children:e.packageId}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs(te,{type:"button",size:"sm",variant:"outline",onClick:()=>o(e),children:[t?n.jsx(Fe,{className:"size-3.5"}):n.jsx(It,{className:"size-3.5"}),t?"Copied":"Copy"]}),e.runnable&&n.jsxs(te,{type:"button",size:"sm",variant:"secondary",disabled:s,onClick:()=>r(e),children:[s?n.jsx(Ue,{className:"size-3.5 animate-spin"}):n.jsx(Ou,{className:"size-3.5"}),s?"Running":"Run"]})]})]})]})}function n_({task:e,selected:t,onSelect:s}){const o=e.recipeId??Bs(e.action);return n.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:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(Iu,{className:"size-3.5 shrink-0 text-white/40"}),n.jsx("div",{className:"truncate text-xs font-semibold text-white/75",children:o}),n.jsx(_e,{variant:"outline",className:P("shrink-0",ph(e.status)),children:e.status})]}),n.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-2 font-mono text-[10px] text-white/35",children:[n.jsx("span",{children:e.packageId}),n.jsx("span",{children:new Date(e.createdAt).toLocaleTimeString()}),e.exitCode!==null&&n.jsxs("span",{children:["exit ",String(e.exitCode)]})]})]}),n.jsx(te,{type:"button",size:"sm",variant:t?"secondary":"outline",onClick:()=>s(e),children:t?"Open":"View"})]})}function s_({pending:e,busy:t,onOpenChange:s,onConfirm:o}){const r=e?.confirmation.plan??null;return n.jsx(qt,{open:e!==null,onOpenChange:s,children:n.jsxs(Ht,{className:"max-w-xl",children:[n.jsxs(Yt,{children:[n.jsx(Jt,{children:"Confirm local command"}),n.jsx(lo,{children:"Review the exact allowlisted action Agent Inspector will run on this machine."})]}),r!==null&&n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[n.jsxs("div",{className:"rounded-md border bg-muted/30 p-3",children:[n.jsx("div",{className:"text-muted-foreground",children:"Source"}),n.jsx("div",{className:"mt-1 break-words font-medium",children:r.source})]}),n.jsxs("div",{className:"rounded-md border bg-muted/30 p-3",children:[n.jsx("div",{className:"text-muted-foreground",children:"Timeout"}),n.jsxs("div",{className:"mt-1 font-medium",children:[String(r.timeoutMs/1e3)," seconds"]})]}),n.jsxs("div",{className:"rounded-md border bg-muted/30 p-3 sm:col-span-2",children:[n.jsx("div",{className:"text-muted-foreground",children:"Affected scope"}),n.jsx("div",{className:"mt-1 font-medium",children:r.scope})]})]}),n.jsxs("div",{children:[n.jsx("div",{className:"mb-1 text-xs font-medium",children:"Resolved command"}),n.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})]}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:["Confirmation phrase: ",n.jsx("code",{children:e?.confirmation.phrase}),". The one-time confirmation expires at"," ",new Date(e?.confirmation.expiresAt??"").toLocaleTimeString(),"."]})]}),n.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[n.jsx(te,{type:"button",variant:"outline",disabled:t,onClick:()=>s(!1),children:"Cancel"}),n.jsxs(te,{type:"button",variant:"secondary",disabled:t||r===null,onClick:o,children:[t?n.jsx(Ue,{className:"size-3.5 animate-spin"}):n.jsx(qn,{className:"size-3.5"}),t?"Starting":"Confirm & Run"]})]})]})})}function o_({currentSessionId:e,logCount:t,labelledTrigger:s=!1}){const[o,r]=l.useState(!1),[a,i]=l.useState(!1),[c,d]=l.useState(!1),[m,u]=l.useState(null),[p,f]=l.useState(null),[h,g]=l.useState(null),[b,y]=l.useState(null),[w,v]=l.useState(!1),j=$t("/api/ecosystem/packages",$4,{revalidateOnFocus:!1,revalidateIfStale:!1}),S=$t(p===null?null:`/api/ecosystem/tasks/${p}`,F4,{refreshInterval:U=>{const Z=U?.task;return Z!==void 0&&(Z.status==="queued"||Z.status==="running")?900:0},revalidateOnFocus:!1}),N=$t(o?"/api/ecosystem/tasks":null,B4,{refreshInterval:2500,revalidateOnFocus:!1}),C=j.data?.packages??[],E=j.data?.runnerPresets??[],A=j.data?.recipes??[],I=(N.data?.tasks??[]).slice(0,6),R=l.useMemo(()=>C.filter(U=>U.state==="installed"||U.state==="update-available").length,[C]),k=Q4(e),M="npx @tonyclaw/eval-harness runner-presets",O=()=>{Tt(k).then(()=>{i(!0),window.setTimeout(()=>i(!1),1200)})},$=()=>{Tt(M).then(()=>{d(!0),window.setTimeout(()=>d(!1),1200)})},K=U=>{Tt(U.command).then(()=>{u(U.id),window.setTimeout(()=>u(null),1200)})},Q=U=>{g(null),q4(U.id).then(Z=>{y(Z)}).catch(Z=>{g(Z instanceof Error?Z.message:"Failed to prepare ecosystem recipe")})},z=S.data?.task??null;l.useEffect(()=>{z!==null&&(N.mutate(),z.status==="succeeded"&&j.mutate())},[z,j,N]);const H=(U,Z)=>{g(null),U4(U,Z).then(fe=>{y(fe)}).catch(fe=>{g(fe instanceof Error?fe.message:"Failed to prepare ecosystem task")})},ee=()=>{b!==null&&(g(null),v(!0),H4(b).then(U=>{f(U.id),y(null),S.mutate({task:U},{revalidate:!0}),N.mutate()}).catch(U=>{g(U instanceof Error?U.message:"Failed to start ecosystem task")}).finally(()=>{v(!1)}))};return n.jsxs(qt,{open:o,onOpenChange:r,children:[n.jsx(io,{asChild:!0,children:n.jsxs(te,{variant:"ghost",size:s?"default":"icon",className:P(uo,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:[n.jsx(Mu,{className:"size-4"}),n.jsx("span",{className:s?"":"sr-only",children:"Lab"})]})}),n.jsxs(Ht,{className:"flex max-h-[84vh] max-w-5xl flex-col overflow-hidden",children:[n.jsx(Yt,{children:n.jsxs(Jt,{className:"flex items-center gap-2",children:[n.jsx(ei,{className:"size-4 text-cyan-200/80"}),"TonyClaw Lab"]})}),n.jsxs("div",{className:"overflow-y-auto pr-2",children:[n.jsxs("div",{className:"grid gap-3 lg:grid-cols-[1.1fr_0.9fr]",children:[n.jsxs("section",{className:"rounded-lg bg-white/[0.025] p-4 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[n.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[n.jsxs("div",{children:[n.jsx("div",{className:"text-sm font-semibold",children:"Session asset pipeline"}),n.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."})]}),n.jsxs(_e,{variant:"outline",className:"border-cyan-300/20 bg-cyan-300/8 text-cyan-100",children:[String(R),"/",String(C.length)," packages"]})]}),n.jsx("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:z4.map(U=>n.jsx(Z4,{workflow:U},U.id))})]}),n.jsxs("section",{className:"rounded-lg bg-white/[0.025] p-4 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[n.jsxs("div",{className:"flex items-start justify-between gap-3",children:[n.jsxs("div",{children:[n.jsx("div",{className:"text-sm font-semibold",children:"Current session"}),n.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:e===null?"MCP smoke command":e})]}),n.jsxs(_e,{variant:"outline",className:"border-white/10 bg-white/[0.04] text-white/55",children:[String(t)," logs"]})]}),n.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}),n.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[n.jsxs(te,{size:"sm",variant:"secondary",onClick:O,children:[a?n.jsx(Fe,{className:"size-3.5"}):n.jsx(It,{className:"size-3.5"}),a?"Copied":"Copy"]}),n.jsxs(te,{size:"sm",variant:"outline",onClick:$,children:[n.jsx(Yi,{className:"size-3.5"}),c?"Presets copied":"Runner Presets"]})]})]})]}),n.jsxs("section",{className:"mt-3",children:[n.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[n.jsx("div",{className:"text-sm font-semibold",children:"Lab recipes"}),n.jsxs("div",{className:"hidden items-center gap-1 font-mono text-[11px] text-muted-foreground sm:flex",children:[n.jsx(ei,{className:"size-3.5"}),"copy-ready workflows"]})]}),n.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[A.map(U=>n.jsx(t_,{recipe:U,copied:m===U.id,running:z!==null&&z.recipeId===U.id&&(z.status==="queued"||z.status==="running"),onCopy:K,onRun:Q},U.id)),j.isLoading&&A.length===0&&[0,1].map(U=>n.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)]"},U))]})]}),n.jsxs("section",{className:"mt-3",children:[n.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[n.jsx("div",{className:"text-sm font-semibold",children:"Runner presets"}),n.jsxs("div",{className:"hidden items-center gap-1 font-mono text-[11px] text-muted-foreground sm:flex",children:[n.jsx(qn,{className:"size-3.5"}),M]})]}),n.jsxs("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:[E.map(U=>n.jsx(e_,{preset:U},U.id)),j.isLoading&&E.length===0&&[0,1,2,3].map(U=>n.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)]"},U))]})]}),n.jsxs("section",{className:"mt-3",children:[n.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[n.jsx("div",{className:"text-sm font-semibold",children:"TonyClaw packages"}),j.isLoading&&n.jsx("div",{className:"font-mono text-[11px] text-muted-foreground",children:"checking npm..."})]}),j.error!==void 0&&n.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."}),n.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[C.map(U=>n.jsx(J4,{pkg:U,activeTask:z,onStartTask:H},U.id)),j.isLoading&&C.length===0&&[0,1,2].map(U=>n.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)]"},U))]})]}),h!==null&&n.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}),I.length>0&&n.jsxs("section",{className:"mt-3",children:[n.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[n.jsx("div",{className:"text-sm font-semibold",children:"Recent Lab runs"}),n.jsxs("div",{className:"hidden font-mono text-[11px] text-muted-foreground sm:block",children:["last ",String(I.length)]})]}),n.jsx("div",{className:"grid gap-2 md:grid-cols-2",children:I.map(U=>n.jsx(n_,{task:U,selected:p===U.id,onSelect:Z=>{f(Z.id),S.mutate({task:Z},{revalidate:!0})}},U.id))})]}),n.jsx(X4,{task:z})]})]}),n.jsx(s_,{pending:b,busy:w,onOpenChange:U=>{!U&&!w&&y(null)},onConfirm:ee})]})}function r_(e){return[...new Set(e.evidence.map(t=>t.logId).filter(t=>t!==null))]}const a_=[{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?"}],i_=4e3,Ua=12;function jd(){return{messages:[],question:"",error:null}}function l_(e){return e.filter(t=>t.content.trim().length>0).slice(-10).map(t=>({role:t.role,content:t.content.trim().slice(0,i_)}))}function at(e,...t){for(const s of t){const o=G(e,s);if(typeof o=="string"&&o.trim().length>0)return o}return null}function pn(e,...t){for(const s of t){const o=G(e,s);if(typeof o=="number"&&Number.isFinite(o))return o}return null}function c_(e,t){const s=G(e,t);return Array.isArray(s)?s.filter(o=>typeof o=="string").slice(0,8):[]}function d_(e){const t=at(e,"source")??"log",s=at(e,"id")??"",o=pn(e,"logId","id");if(s===""&&o===null||o!==null&&(!Number.isInteger(o)||o<0))return null;const r=pn(e,"inputTokens"),a=pn(e,"outputTokens"),i=pn(e,"totalTokens","tokenCount"),c=pn(e,"responseStatus","status"),d=at(e,"responseStatus","status");return{source:t,id:s!==""?s:String(o),logId:o,sessionId:at(e,"sessionId"),timestamp:at(e,"timestamp"),model:at(e,"model"),providerName:at(e,"providerName","provider"),path:at(e,"path"),status:c??d,elapsedMs:pn(e,"elapsedMs","latencyMs"),inputTokens:r,outputTokens:a,totalTokens:i??(r===null&&a===null?null:(r??0)+(a??0)),score:pn(e,"score","relevanceScore"),matchedFields:c_(e,"matchedFields"),excerpt:at(e,"excerpt","snippet")??"No excerpt available."}}function qa(e){const t=e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim();return t.length===0?"Metric":`${t[0]?.toUpperCase()??""}${t.slice(1)}`}function Sd(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 t=e.filter(s=>typeof s=="string"||typeof s=="number"&&Number.isFinite(s)).slice(0,6);return t.length>0?t.join(", "):null}return null}function Nd(e){return Object.getOwnPropertyNames(e).map(t=>[t,G(e,t)])}function Cd(e){if(e===null||typeof e!="object"||Array.isArray(e))return[];const t=[];for(const[s,o]of Nd(e)){const r=Sd(o);if(r!==null){if(t.push({key:s,label:qa(s),value:r}),t.length>=Ua)break;continue}if(!(o===null||typeof o!="object"||Array.isArray(o))){for(const[a,i]of Nd(o)){const c=Sd(i);if(c===null)continue;const d=`${s}.${a}`;if(t.push({key:d,label:`${qa(s)} ${qa(a).toLowerCase()}`,value:c}),t.length>=Ua)break}if(t.length>=Ua)break}}return t}function u_(e){const t=at(e,"answer"),s=at(e,"providerId"),o=at(e,"providerName"),r=at(e,"model"),a=at(e,"protocol"),i=pn(e,"logCount");if(t===null||s===null||o===null||r===null||a===null||i===null)return null;const c=G(e,"evidence"),d=Array.isArray(c)?c.map(d_).filter(m=>m!==null).slice(0,12):[];return{answer:t,providerId:s,providerName:o,model:r,protocol:a,logCount:i,evidence:d,summaryMetrics:Cd(G(e,"summary")),queryMetrics:Cd(G(e,"queryStats"))}}const m_=l.lazy(()=>Wt(()=>import("./index-P5NBm7WS.js"),__vite__mapDeps([10,1,2]),import.meta.url)),p_="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]",Ha=96*1024;function f_({text:e}){const[t,s]=l.useState(!1),o=e.length>Ha,r=o&&!t?e.slice(0,Ha):e;return l.useEffect(()=>{s(!1)},[e]),n.jsxs("div",{className:"space-y-2",children:[o&&!t&&n.jsxs("div",{className:"rounded-md border border-cyan-300/20 bg-cyan-300/[0.06] px-3 py-2 text-xs text-muted-foreground",children:["Showing the first ",Ha.toLocaleString()," characters for fast rendering. The full response is preserved."]}),n.jsx("div",{className:p_,children:n.jsx(l.Suspense,{fallback:n.jsx("span",{className:"text-xs text-muted-foreground",children:"Loading Markdown..."}),children:n.jsx(m_,{children:r})})}),o&&n.jsx("button",{type:"button",className:"rounded-md border border-border bg-background px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",onClick:()=>s(a=>!a),children:t?"Collapse fast preview":`Render full response (${e.length.toLocaleString()} chars)`})]})}const kd="What looks abnormal, slow, or likely to hang?";function h_(e){return e.openaiResponsesBaseUrl!==void 0||e.openaiBaseUrl!==void 0||e.anthropicBaseUrl!==void 0}function x_(e){return e.openaiResponsesBaseUrl!==void 0&&e.openaiResponsesBaseUrl!==""?"Responses":e.openaiBaseUrl!==void 0&&e.openaiBaseUrl!==""?"Chat":"Anthropic"}function g_(e){return e.toSorted((t,s)=>{const o=t.source==="company"?0:1,r=s.source==="company"?0:1;return o!==r?o-r:t.name.localeCompare(s.name)})}function _d(e){return`${e}-${String(Date.now())}-${String(Math.random()).slice(2)}`}function In({label:e,value:t,tone:s="muted"}){return n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 font-mono text-[10px]",children:[n.jsx("span",{className:s==="cyan"?"text-cyan-100":"text-muted-foreground",children:e}),t!==void 0&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"text-muted-foreground/55",children:":"}),n.jsx("span",{className:"truncate text-muted-foreground",children:t})]})]})}function b_({metrics:e}){return e.length===0?null:n.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:e.slice(0,8).map(t=>n.jsxs("div",{className:"rounded-sm bg-black/25 px-2 py-1 shadow-[inset_2px_0_0_rgba(103,232,249,0.22)]",children:[n.jsx("div",{className:"truncate font-mono text-[9px] text-muted-foreground",children:t.label}),n.jsx("div",{className:"truncate font-mono text-[11px] text-cyan-50/95",children:t.value})]},t.key))})}function v_({evidence:e}){const t=()=>{e.logId!==null&&Ss({logId:e.logId,tab:"anatomy"})},s=e.logId===null?`${e.source}:${e.id}`:`${e.source}:log #${String(e.logId)}`;return n.jsxs("button",{type:"button",onClick:t,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:[n.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[n.jsx("span",{className:"truncate font-mono text-[10px] text-cyan-100",children:s}),e.score!==null&&n.jsx("span",{className:"shrink-0 font-mono text-[9px] text-muted-foreground",children:e.score.toFixed(1)})]}),n.jsxs("div",{className:"mt-1 flex flex-wrap gap-x-2 gap-y-1 text-[10px] text-muted-foreground",children:[e.providerName!==null&&n.jsx("span",{children:e.providerName}),e.model!==null&&n.jsx("span",{children:e.model}),e.status!==null&&n.jsxs("span",{children:["status ",String(e.status)]}),e.elapsedMs!==null&&n.jsxs("span",{children:[String(e.elapsedMs)," ms"]})]}),n.jsx("p",{className:"mt-1 line-clamp-3 text-[11px] leading-4 text-foreground/85",children:e.excerpt})]})}function y_({response:e}){return n.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:[n.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:[n.jsx(In,{label:"assistant@inspector",value:"output",tone:"cyan"}),n.jsxs("span",{className:"shrink-0 font-mono text-[9px] text-muted-foreground",children:[String(e.logCount)," logs"]})]}),n.jsxs("div",{className:"space-y-3 p-3",children:[n.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:n.jsx(f_,{text:e.answer})}),n.jsxs("div",{className:"grid gap-1.5 rounded-sm bg-black/20 px-2 py-1.5",children:[n.jsx(In,{label:"provider",value:e.providerName}),n.jsx(In,{label:"model",value:e.model}),n.jsx(In,{label:"protocol",value:e.protocol})]}),(e.summaryMetrics.length>0||e.queryMetrics.length>0)&&n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(In,{label:"metrics",tone:"cyan"}),n.jsx(b_,{metrics:[...e.summaryMetrics,...e.queryMetrics]})]}),e.evidence.length>0&&n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(In,{label:"evidence",value:"click to inspect source log",tone:"cyan"}),e.evidence.slice(0,6).map(t=>n.jsx(v_,{evidence:t},`${t.source}-${t.id}`))]})]})]})}function w_({message:e}){return e.role==="assistant"&&e.response!==null?n.jsx(y_,{response:e.response}):n.jsxs("div",{className:"overflow-hidden rounded-md bg-black/25 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[n.jsx("div",{className:"border-b border-white/[0.06] px-3 py-1.5",children:n.jsx(In,{label:"user@inspector",value:"query",tone:"cyan"})}),n.jsxs("div",{className:"px-3 py-2 font-mono text-[11px] leading-5 text-cyan-50",children:[n.jsx("span",{className:"select-none text-cyan-100/60",children:"> "}),e.content]})]})}function j_({currentSessionId:e,logCount:t,onResultChange:s}){const{providers:o}=ol(),r=l.useMemo(()=>g_(o.filter(h_)),[o]),[a,i]=l.useState(()=>({...jd(),question:kd})),[c,d]=l.useState("__auto__"),[m,u]=l.useState("__auto__"),[p,f]=l.useState(!1),g=r.find(C=>C.id===c)?.models??[],b=a.question,y=b.trim()!==""&&r.length>0&&!p;if(r.length===0)return null;const w=C=>{i(E=>({...E,question:C.currentTarget.value}))},v=C=>{d(C),u("__auto__")},j=()=>{i({...jd(),question:kd}),s(null)},S=C=>{i(E=>({...E,question:C,error:null}))},N=()=>{if(!y)return;const C=b.trim(),E=l_(a.messages),A={id:_d("user"),role:"user",content:C,response:null};f(!0),i(R=>({...R,messages:[...R.messages,A],question:"",error:null}));const I={question:C,history:E,...e!==null?{sessionId:e}:{},...c!=="__auto__"?{providerId:c}:{},...m!=="__auto__"?{model:m}:{},logLimit:16};Zh("/api/pi-agent",{method:"POST",headers:{"content-type":"application/json","x-agent-inspector-csrf":"1"},body:JSON.stringify(I)}).then(async R=>{const k=await R.text();if(!R.ok){i($=>({...$,error:`Inspector Assistant failed: HTTP ${String(R.status)} ${k}`}));return}const M=JSON.parse(k),O=u_(M);if(O===null){i($=>({...$,error:"Inspector Assistant returned an unexpected response."}));return}i($=>({...$,messages:[...$.messages,{id:_d("assistant"),role:"assistant",content:O.answer,response:O}]})),s({question:C,logIds:r_(O),reportedLogCount:O.logCount})}).catch(R=>{i(k=>({...k,error:R instanceof Error?R.message:"Inspector Assistant request failed."}))}).finally(()=>{f(!1)})};return n.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:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(C0,{className:"size-4 text-cyan-200"}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"text-xs font-semibold text-foreground",children:"Assistant"}),n.jsx("div",{className:"text-[11px] text-muted-foreground",children:e===null?"All evidence":"Current session"})]}),n.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:n.jsx(Du,{className:"size-3.5"})})]}),a.messages.length===0&&n.jsx("p",{className:"mt-3 text-[11px] leading-5 text-muted-foreground",children:"Ask about failures, latency, tokens, and tools."}),n.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2",children:[n.jsxs(Ys,{value:c,onValueChange:v,children:[n.jsx(Js,{className:"h-8 border-0 bg-black/25 text-xs shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)]",children:n.jsx(hr,{placeholder:"Provider"})}),n.jsxs(Xs,{children:[n.jsx(it,{value:"__auto__",children:"Auto provider"}),r.map(C=>n.jsxs(it,{value:C.id,children:[C.name," / ",x_(C)]},C.id))]})]}),n.jsxs(Ys,{value:m,onValueChange:u,children:[n.jsx(Js,{className:"h-8 border-0 bg-black/25 text-xs shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)]",children:n.jsx(hr,{placeholder:"Model"})}),n.jsxs(Xs,{children:[n.jsx(it,{value:"__auto__",children:"Auto model"}),g.map(C=>n.jsx(it,{value:C,children:C},C))]})]})]}),a.messages.length===0&&n.jsx("div",{className:"mt-3 flex flex-wrap gap-1.5",children:a_.map(C=>n.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:[n.jsx(ei,{className:"size-3"}),n.jsx("span",{children:C.label})]},C.id))}),a.messages.length>0&&n.jsxs("div",{className:"mt-3 max-h-96 space-y-2 overflow-y-auto pr-1",children:[a.messages.map(C=>n.jsx(w_,{message:C},C.id)),p&&n.jsxs("div",{className:"inline-flex items-center gap-2 rounded-md bg-black/25 px-3 py-2 text-xs text-muted-foreground",children:[n.jsx(Ue,{className:"size-3.5 animate-spin"}),n.jsx("span",{children:"Searching Inspector..."})]})]}),n.jsx("textarea",{value:b,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..."}),n.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:[p?n.jsx(Ue,{className:"size-3.5 animate-spin"}):n.jsx(C1,{className:"size-3.5"}),n.jsx("span",{children:p?"Searching...":"Ask Assistant"})]}),a.error!==null&&n.jsx("p",{className:"mt-2 break-words text-[11px] leading-5 text-red-200",children:a.error}),t===0&&n.jsx("p",{className:"mt-2 text-[11px] leading-5 text-muted-foreground",children:"No logs in this scope. Setup questions still work."})]})}function S_(e){const t=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||t.set(i.id,{creation:Td(a.cacheCreationInputTokens,i.cacheCreationInputTokens),read:Td(a.cacheReadInputTokens,i.cacheReadInputTokens)})}}return t}function Td(e,t){return t===null||e===null?null:t>e?{direction:"up",delta:t-e}:t<e?{direction:"down",delta:e-t}:null}function fh(e){return e===null?null:new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function os(e,t,s){const o=fh(e.lastSuccessAt),r=e.retryCount>0?` Retry ${e.retryCount.toString()}.`:"",a=s?" Captured logs remain visible.":"",i=o===null?"":` Last update ${o}.`;return`${t}${i}${r}${a}`}function hh(e,t,s){switch(e){case"connecting":return{label:"Connecting",description:os(t,"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:os(t,"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:os(t,"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:os(t,"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:os(t,t.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:os(t,t.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 N_({state:e}){const t=hh(e.status,e,!1),s=fh(e.lastSuccessAt),o=e.retryCount>0?`Retry ${e.retryCount.toString()}`:null;return n.jsxs("span",{role:"status","aria-label":t.description,"data-connection-state":e.status,className:P("inline-flex h-7 max-w-full items-center gap-1.5 rounded-full border px-2.5 text-xs font-medium",t.toneClass),children:[n.jsx("span",{className:P("size-1.5 shrink-0 rounded-full",t.dotClass)}),n.jsx("span",{className:"shrink-0",children:t.label}),o!==null&&n.jsx("span",{className:"hidden truncate text-current/70 sm:inline",children:o}),s!==null&&n.jsxs("span",{className:"hidden truncate font-mono text-[10px] text-current/65 md:inline",children:["Last ",s]})]})}function C_({state:e,hasLogs:t,onRetry:s,onStop:o}){const r=hh(e.status,e,t);return n.jsxs("div",{role:"status","aria-live":"polite","data-connection-state":e.status,className:P("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:[n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[n.jsx("span",{className:P("size-2 shrink-0 rounded-full",r.dotClass)}),n.jsx("span",{className:"shrink-0 font-semibold",children:r.label}),n.jsx("span",{className:"min-w-0 text-current/75",children:r.description})]}),(r.canRetry||r.canStop)&&n.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[r.canRetry&&n.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:[n.jsx(Et,{className:"size-3"}),"Retry now"]}),r.canStop&&n.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:[n.jsx(G0,{className:"size-3"}),"Stop retrying"]})]})]})}function k_(){const[e,t]=l.useState(!1),[s,o]=l.useState(!1);l.useEffect(()=>{const i=()=>{t(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(()=>{t(document.fullscreenElement!==null)});return}document.exitFullscreen().catch(()=>{t(document.fullscreenElement!==null)})}},[s]),a=e?"Exit fullscreen":"Enter fullscreen";return n.jsxs(te,{type:"button",variant:"ghost",size:"icon",className:uo,"aria-label":a,"aria-pressed":e,title:a,disabled:!s,onClick:r,children:[e?n.jsx(Vg,{className:"size-4"}):n.jsx(Ug,{className:"size-4"}),n.jsx("span",{className:"sr-only",children:a})]})}function __({liveConnection:e,alertsAction:t,settingsAction:s}){return n.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:n.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:[n.jsxs("a",{href:Oi("/"),"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:[n.jsx(au,{className:"size-7 shrink-0 text-amber-500"}),n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"block truncate text-sm font-bold leading-4",children:"Agent Inspector"}),n.jsx("span",{className:"hidden truncate text-[10px] font-medium text-muted-foreground md:block",children:"Local First. Evidence First."})]}),n.jsxs("span",{className:"hidden shrink-0 font-mono text-[10px] text-muted-foreground lg:inline",children:["v",Fu.version]})]}),n.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?n.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:[n.jsx("span",{className:"size-1.5 shrink-0 rounded-full bg-slate-400"}),"Stored session"]}):n.jsx(N_,{state:e})}),n.jsxs("nav",{"aria-label":"Application actions",className:"order-2 flex shrink-0 items-center justify-end gap-1 sm:order-3",children:[n.jsx(k_,{}),t,s]})]})})}function T_(e){return`${Math.max(0,Math.ceil(e/1e3)).toString()}s`}function Ko({progress:e}){const t=Math.min(1,e.elapsedMs/e.timeoutMs),s=Math.max(4,Math.round(t*100)),o=Math.max(0,e.timeoutMs-e.elapsedMs),r=t>=.75,a=[e.loadedLogs>0?`${e.loadedLogs.toString()} logs`:null,e.loadedPages>0?`${e.loadedPages.toString()} page${e.loadedPages===1?"":"s"}`:null,`${T_(o)} before timeout`].filter(c=>c!==null),i=`${e.label}: ${a.join(", ")}`;return n.jsxs("div",{className:"min-w-0 space-y-1 px-1 pb-1",children:[n.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3 font-mono text-[10px] text-muted-foreground",children:[n.jsx("span",{className:"min-w-0 truncate",children:e.label}),n.jsx("span",{className:P("shrink-0 tabular-nums",r&&"text-amber-300"),children:a.join(" / ")})]}),n.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:n.jsx("div",{className:P("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 xh(e){return e?"auto":"smooth"}function gh(){return typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function E_(){return{status:"connecting",lastSuccessAt:null,retryCount:0,errorMessage:null}}function kt(e,t){switch(t.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:t.at,retryCount:0,errorMessage:null};case"connection-lost":{const s=e.retryCount+1;return t.online?{...e,status:e.lastSuccessAt===null?"error":"reconnecting",retryCount:s,errorMessage:t.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:t.message}}}function R_(e){return e===void 0||e.status==="live"?"empty":e.status}function M_(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 Ed="agent-inspector.hierarchy.collapsedClients",Rd="agent-inspector.hierarchy.collapsedProcesses";function br(e){return e.some(t=>t.responseStatus===null)}function bh(e){return e.filter(t=>t.responseStatus===null).length}function vh(e){for(const t of e){const s=t.userAgent;if(s!=null&&s!=="")return s}return null}function A_(e){for(const t of e){const s=t.clientPid;if(s!=null)return s}return null}function yh(e){for(const t of e){const s=t.clientProjectFolder;if(s!=null&&s!=="")return s}return null}function I_(e){return El({userAgent:vh(e.logs),conversationId:e.conversationId,clientProjectFolder:yh(e.logs)})}function P_(e){if(e===null||e==="")return"Unknown client";const t=e.split(/[ /;]/)[0]??"";return t===""?"Unknown client":t}function L_(e,t){const s=Kr(e);return s!==null?s:P_(t)}function vr(e){return e===null||e===""?"unknown":String(e)}function O_(e,t,s){return e!=="unknown"?e:`unknown:${vr(t)}:${vr(s)}`}function D_(e,t){return`${vr(e)}:${vr(t)}`}function Md(e){return[...e].sort((t,s)=>t.timestamp.localeCompare(s.timestamp))}function Ad(e){let t="";for(const s of e)s.timestamp>t&&(t=s.timestamp);return t}function Id(e){return br(e)?0:e.some(t=>t.error!==null&&t.error!==void 0||t.responseStatus!==null&&t.responseStatus!==void 0&&t.responseStatus>=400)?1:2}function Va(e){return[...e].sort((t,s)=>{const o=Id(t.logs)-Id(s.logs);if(o!==0)return o;const r=Ad(s.logs).localeCompare(Ad(t.logs));return r!==0?r:t.id.localeCompare(s.id)})}function z_(e){const t=new Map;for(const o of e){const r=vh(o.logs),a=yh(o.logs),i=I_(o),c=O_(i,r,a);let d=t.get(c);d===void 0&&(d={id:c,client:i,label:L_(i,r),userAgent:r,processes:new Map,logs:[]},t.set(c,d)),d.logs.push(...o.logs);const m=A_(o.logs),u=`${c}:${D_(m,a)}`;let p=d.processes.get(u);p===void 0&&(p={id:u,clientPid:m,clientProjectFolder:a,sessions:[],logs:[]},d.processes.set(u,p)),p.sessions.push(o),p.logs.push(...o.logs)}const s=[];for(const o of t.values()){const r=Va([...o.processes.values()].map(a=>({id:a.id,clientPid:a.clientPid,clientProjectFolder:a.clientProjectFolder,sessions:Va(a.sessions),logs:Md(a.logs)})));s.push({id:o.id,client:o.client,label:o.label,userAgent:o.userAgent,processes:r,logs:Md(o.logs)})}return Va(s)}function yr(e){return e<=0?"0":Ie(e)}function wh(e){let t=0,s=0;for(const o of e)o.inputTokens!==null&&o.inputTokens!==void 0&&(t+=o.inputTokens),o.outputTokens!==null&&o.outputTokens!==void 0&&(s+=o.outputTokens);return{inputTokens:t,outputTokens:s}}function $_(e){let t=0;for(const s of e)t+=s.sessions.length;return t}function Pd(e){if(typeof window>"u")return null;try{const t=window.localStorage.getItem(e);if(t===null)return null;const s=JSON.parse(t);return Array.isArray(s)?new Set(s.filter(o=>typeof o=="string")):null}catch{return null}}function Ld(e,t){try{window.localStorage.setItem(e,JSON.stringify([...t]))}catch{}}function Od(e,t){let s=!1;const o=new Set(e);for(const r of t)o.delete(r)&&(s=!0);return s?o:e}function F_(e){const t=new Set;for(const s of e)for(let o=1;o<s.processes.length;o++){const r=s.processes[o];r!==void 0&&!br(r.logs)&&t.add(r.id)}return t}function B_(e){if(e===null||e==="")return null;const t=e.replaceAll("\\","/").split("/").filter(r=>r!==""),s=t[t.length-1];if(s===void 0)return e;const o=t[t.length-2];return o===void 0?s:`${o}/${s}`}function wr({label:e,value:t,className:s}){return n.jsxs("span",{className:P("inline-flex h-7 items-center gap-1 rounded-md bg-[var(--inspector-surface-low)] px-2 text-xs text-muted-foreground",s),children:[n.jsx("span",{className:"font-mono text-[10px] uppercase text-muted-foreground/70",children:e}),n.jsx("span",{className:"font-mono tabular-nums text-foreground",children:t})]})}function jh({count:e}){const t=`${e} open turn${e===1?"":"s"}`;return n.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":t,title:t,children:[n.jsx(Ue,{className:"size-3 animate-spin"}),e>1&&n.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 U_({groups:e,...t}){const s=l.useMemo(()=>z_(e),[e]),[o,r]=l.useState(()=>new Set),[a,i]=l.useState(()=>F_(s)),[c,d]=l.useState(!1);l.useEffect(()=>{const p=Pd(Ed),f=Pd(Rd);p!==null&&r(p),f!==null&&i(f),d(!0)},[]),l.useEffect(()=>{c&&(Ld(Ed,o),Ld(Rd,a))},[o,a,c]),l.useEffect(()=>{const p=new Set(s.filter(h=>br(h.logs)).map(h=>h.id)),f=new Set(s.flatMap(h=>h.processes.filter(g=>br(g.logs)).map(g=>g.id)));r(h=>Od(h,p)),i(h=>Od(h,f))},[s]);const m=l.useCallback(p=>{r(f=>{const h=new Set(f);return h.has(p)?h.delete(p):h.add(p),h})},[]),u=l.useCallback(p=>{i(f=>{const h=new Set(f);return h.has(p)?h.delete(p):h.add(p),h})},[]);return n.jsx("div",{className:"space-y-2",children:s.map(p=>n.jsx(q_,{group:p,collapsed:o.has(p.id),collapsedProcessIds:a,onToggleClient:()=>m(p.id),onToggleProcess:u,conversationProps:t},p.id))})}function q_({group:e,collapsed:t,collapsedProcessIds:s,onToggleClient:o,onToggleProcess:r,conversationProps:a}){const i=wh(e.logs),c=$_(e.processes),d=e.logs.length,m=bh(e.logs),u=m>0;return n.jsxs("section",{className:P("relative isolate overflow-hidden rounded-[8px] bg-card/65",u&&"bg-card/80"),"data-ide-group":e.id,children:[n.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":!t,children:[e.client==="unknown"?n.jsx("span",{className:"inline-flex size-9 shrink-0 items-center justify-center rounded-md bg-[var(--inspector-surface-low)] text-muted-foreground",children:n.jsx(Kg,{className:"size-4"})}):n.jsx(Yr,{client:e.client,className:"size-9 rounded-md",decorative:!0}),n.jsxs("span",{className:"min-w-0",children:[n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[n.jsx("span",{className:"truncate text-sm font-semibold text-foreground",title:e.userAgent??e.label,children:e.label}),n.jsx("span",{className:"rounded bg-[var(--inspector-surface-medium)] px-1.5 py-0.5 font-mono text-[9px] uppercase text-muted-foreground",children:Oj(e.client)}),u&&n.jsx(jh,{count:m})]}),n.jsxs("span",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:[n.jsxs("span",{children:[e.processes.length," process",e.processes.length!==1?"es":""]}),n.jsxs("span",{children:[c," session",c!==1?"s":""]}),n.jsxs("span",{children:[d," req"]})]})]}),n.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[t&&n.jsxs("span",{className:"hidden shrink-0 items-center gap-2 md:flex",children:[n.jsx(wr,{label:"IN",value:yr(i.inputTokens)}),n.jsx(wr,{label:"OUT",value:yr(i.outputTokens)})]}),n.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:t?n.jsx(gt,{className:"size-4"}):n.jsx(Xe,{className:"size-4"})})]})]}),!t&&n.jsx("div",{className:"space-y-0.5 px-2 pb-2 pt-0.5",children:e.processes.map(p=>n.jsx(H_,{group:p,collapsed:s.has(p.id),onToggle:()=>r(p.id),conversationProps:a},p.id))})]})}function H_({group:e,collapsed:t,onToggle:s,conversationProps:o}){const r=wh(e.logs),a=B_(e.clientProjectFolder),i=e.sessions.length,c=e.logs.length,d=bh(e.logs),m=d>0,u=e.clientPid!==null&&e.clientPid!==void 0?`PID ${e.clientPid}`:"Process unavailable";return n.jsxs("section",{className:"relative pl-3",children:[n.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":!t,children:[n.jsx("span",{className:"inline-flex size-8 shrink-0 items-center justify-center text-[var(--inspector-status-watch)]",children:n.jsx(ig,{className:"size-4"})}),n.jsxs("span",{className:"min-w-0",children:[n.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[n.jsx("span",{className:"font-mono text-xs font-semibold tabular-nums text-foreground",children:u}),m&&n.jsx(jh,{count:d}),a!==null&&n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1 text-[11px] text-muted-foreground",title:e.clientProjectFolder??a,children:[n.jsx(Eg,{className:"size-3 shrink-0"}),n.jsx("span",{className:"truncate font-mono",children:a})]})]}),n.jsxs("span",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:[n.jsxs("span",{children:[i," session",i!==1?"s":""]}),n.jsxs("span",{children:[c," req"]})]})]}),n.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[t&&n.jsxs("span",{className:"hidden shrink-0 items-center gap-2 md:flex",children:[n.jsx(wr,{label:"IN",value:yr(r.inputTokens)}),n.jsx(wr,{label:"OUT",value:yr(r.outputTokens)})]}),n.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:t?n.jsx(gt,{className:"size-4"}):n.jsx(Xe,{className:"size-4"})})]})]}),!t&&n.jsx("div",{className:"space-y-1 pb-1 pl-3 pr-1 pt-1",children:e.sessions.map(p=>n.jsx(FC,{group:p,...o,showClientIdentity:!1,showLogClientMetadata:!1,showProcessMetadata:!1},p.id))})]})}const V_="w-[calc(100%-1rem)] border-warning/30 bg-popover text-popover-foreground sm:max-w-lg",W_=[{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 G_({onCancel:e,onExportRedacted:t,onConfirmRaw:s}){return n.jsxs(n.Fragment,{children:[n.jsxs(Yt,{children:[n.jsx(Jt,{children:"Export unredacted logs?"}),n.jsx(lo,{children:"Raw exports bypass Agent Inspector redaction and may expose sensitive captured data."})]}),n.jsxs("div",{role:"alert",className:"rounded-md border border-warning/35 bg-warning/10 px-3 py-3 text-sm text-foreground",children:[n.jsx("p",{className:"font-medium",children:"The raw archive may include:"}),n.jsx("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-xs leading-relaxed text-muted-foreground",children:W_.map(o=>n.jsxs("li",{children:[n.jsxs("span",{className:"font-semibold text-foreground",children:[o.label,":"]})," ",o.detail]},o.label))}),n.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."})]}),n.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[n.jsx(te,{type:"button",variant:"outline",size:"sm",onClick:e,children:"Cancel"}),n.jsx(te,{type:"button",variant:"outline",size:"sm",onClick:t,children:"Export redacted instead"}),n.jsx(te,{type:"button",variant:"destructive",size:"sm",onClick:s,children:"Export raw data"})]})]})}const jr="data-nav-id",K_="data-nav-action";function Dd(e){return Array.from(e.querySelectorAll(`[${jr}]`))}function zd(e){return e instanceof HTMLElement}function Y_(e,t){let s=e;for(;s!==null&&s!==t;){if(s.hasAttribute(jr))return s;s=s.parentElement}return e.hasAttribute(jr)?e:null}function Wa(e){const t=e.getAttribute(K_);return t==="toggle"||t==="expand"||t==="collapse"?t:null}function Os(e){e.focus({preventScroll:!0}),e.scrollIntoView({block:"nearest",behavior:"smooth"})}function Ds(e,t){return e[t]??null}function Sh(e){const t=e.tagName;return!!(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable)}function $d(e){const t=e.tagName;return t==="BUTTON"||t==="A"||Sh(e)?!0:e.closest("[role='button'],[role='menuitem'],[role='option']")!==null}function J_(e){return e.closest("[role='dialog'],[role='menu'],[role='listbox']")!==null?!0:document.querySelector("[role='dialog'],[role='menu'],[role='listbox']")!==null}function X_(){const e=window.getSelection();return e===null?!1:e.type==="Range"&&e.toString().length>0}function Oo(e,t){return e.key===t&&e.shiftKey}function Z_(e,t,s={}){const o=t??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(!zd(m)||m!==d)return;const u=Dd(c),p=Ds(u,0);p!==null&&Os(p)},[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(!zd(m)||Sh(m)||X_())return;const u=d.contains(m);if(u&&$d(m)&&!m.hasAttribute(jr)||!u&&(!r||$d(m)||J_(m)))return;const p=Dd(d);if(p.length===0)return;const f=Y_(m,d),h=f!==null?p.indexOf(f):-1;let g=!1;switch(c.key){case"ArrowUp":case"W":{if(c.shiftKey&&c.key==="ArrowUp"||c.key==="W"&&!Oo(c,"W"))break;c.preventDefault();const b=h>0?h-1:h===-1?p.length-1:-1;if(b!==-1){const y=Ds(p,b);y!==null&&Os(y)}g=!0;break}case"ArrowDown":case"S":{if(c.shiftKey&&c.key==="ArrowDown"||c.key==="S"&&!Oo(c,"S"))break;c.preventDefault();const b=h<p.length-1?h+1:h===-1?0:-1;if(b!==-1){const y=Ds(p,b);y!==null&&Os(y)}g=!0;break}case"ArrowLeft":case"A":{if(c.shiftKey&&c.key==="ArrowLeft"||c.key==="A"&&!Oo(c,"A")||f===null)break;if(c.preventDefault(),Wa(f)==="collapse")f.click();else if(h>0){const y=Ds(p,h-1);y!==null&&Os(y)}g=!0;break}case"ArrowRight":case"D":{if(c.shiftKey&&c.key==="ArrowRight"||c.key==="D"&&!Oo(c,"D")||f===null)break;if(c.preventDefault(),Wa(f)==="expand")f.click();else if(h<p.length-1){const y=Ds(p,h+1);y!==null&&Os(y)}g=!0;break}case" ":{if(f===null)break;c.preventDefault(),Wa(f)!==null&&f.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 Q_={system:"System",user:"User",assistant:"Assistant",tool:"Tool Results",tools:"Tool Definitions"},eT={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"},tT={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"},Ga=12,Do=1,Fd=80,Bd=24;function nT(e){return e.length<=Bd?e:`${e.slice(0,Bd-3)}...`}function sT(e){const t=e.replace(/\s+/g," ").trim();return t.length<=Fd?t:`${t.slice(0,Fd)}...`}function zo(e){return e>=10?`${e.toFixed(0)}%`:e>=1?`${e.toFixed(1)}%`:e>0?"<1%":"0%"}const oT=l.memo(function({segments:t,totalTokens:s,showLabels:o=!0,onActivate:r}){const a=l.useMemo(()=>s>0?s:t.reduce((y,w)=>y+w.size,0),[t,s]),i=t.slice(0,Ga),c=t.slice(Ga),d=c.reduce((y,w)=>y+w.size,0),m=c.length,u=Ga,p=u+m-1,f=m>0,h=r!==void 0,g=l.useMemo(()=>i.reduce((y,w)=>y+w.size,0),[i]),b=l.useMemo(()=>`Request context: ~${Ie(a)} tokens across ${t.length} segment${t.length===1?"":"s"}`,[t.length,a]);return t.length===0||a<=0?n.jsx("div",{role:"img","aria-label":b,className:"h-6"}):n.jsx(Ts,{delayDuration:150,children:n.jsxs("div",{role:"img","aria-label":b,className:"flex flex-col gap-1.5",children:[n.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 v=a>0?y.size/a*100:0,j=Math.max(Do,v),S=P("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",eT[y.role],h?tT[y.role]:""),N={width:`${j}%`},C=`${y.label}, ${zo(v)}, ~${Ie(y.size)} tokens`;return n.jsxs(dt,{children:[n.jsx(ut,{asChild:!0,children:h?n.jsx("button",{type:"button",role:"button",tabIndex:0,onClick:()=>r(y),onKeyDown:E=>{(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),r(y))},"data-anatomy-path":y.path,"aria-label":C,className:S,style:N}):n.jsx("span",{"aria-label":C,className:S,style:N})}),n.jsxs(mt,{side:"bottom",className:"max-w-sm text-xs p-2 space-y-0.5",children:[n.jsxs("div",{className:"font-semibold",children:[y.label," - ",zo(v)," - ~",Ie(y.size)," ","tokens"]}),n.jsx("div",{className:"text-muted-foreground",children:Q_[y.role]}),n.jsxs("div",{className:"text-muted-foreground",children:[y.characters.toLocaleString()," chars"]}),y.text.length>0&&n.jsx("div",{className:"text-muted-foreground/90 break-words whitespace-pre-wrap",children:sT(y.text)})]})]},`${y.path}-${w}`)}),f&&n.jsxs(dt,{children:[n.jsx(ut,{asChild:!0,children:n.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(Do,d/a*100)}%`},children:["... +",m]})}),n.jsxs(mt,{side:"bottom",className:"text-xs",children:[m," more segment",m===1?"":"s"," (indices"," ",u,"-",p,")"]})]})]}),o&&n.jsxs("div",{className:"flex w-full gap-1 text-[10px] text-muted-foreground",children:[i.map((y,w)=>{const v=a>0?y.size/a*100:0,j=Math.max(Do,v);return n.jsxs("div",{className:"flex flex-col gap-0.5 truncate",style:{width:`${j}%`},title:`${y.label} - ${zo(v)} - ~${Ie(y.size)} tokens`,children:[n.jsx("span",{className:"truncate font-mono text-foreground/80",children:nT(y.label)}),n.jsxs("span",{className:"truncate font-mono text-muted-foreground/70",children:[zo(v)," - ~",Ie(y.size)]})]},`label-${y.path}-${w}`)}),f&&n.jsxs("div",{className:"flex flex-col gap-0.5 truncate text-muted-foreground",style:{width:`${Math.max(Do,d/a*100)}%`},children:[n.jsxs("span",{className:"truncate font-mono text-foreground/60",children:["... +",m]}),n.jsxs("span",{className:"truncate font-mono text-muted-foreground/60",children:["~",Ie(d)]})]})]}),g<a*.1&&n.jsx("div",{className:"h-0"})]})})}),Nh=.75,Ch=.9,Ri=8e3,rT=.35,kh=40,_h=160,aT=5,iT=8,lT=18,cT=6e4,dT=.7,Ud=3e3,uT=.3,qd=160,mT=new Set(["answer","body","content","data","error","message","markdown","output","response","result","stderr","stdout","text","transcript"]),pT=["context_window","contextWindow","context_length","contextLength","max_context_length","maxContextLength","max_input_tokens","maxInputTokens"],fT=["max_tokens","maxTokens","max_completion_tokens","maxCompletionTokens","max_output_tokens","maxOutputTokens"],hT=[{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"]}],xT={system:"System",user:"User messages",assistant:"Assistant messages",tool:"Tool results",tools:"Tool definitions"};function gT(e){if(typeof e=="number")return Number.isFinite(e)&&e>0?Math.floor(e):null;if(typeof e=="string"){const t=Number(e);if(Number.isFinite(t)&&t>0)return Math.floor(t)}return null}function Th(e,t){for(const s of t){const o=gT(G(e,s));if(o!==null)return o}return null}function bT(e){const t=G(e,"model");if(typeof t!="string")return null;const s=t.trim();return s===""?null:s}function vT(e,t){switch(t.mode){case"prefix":return t.patterns.some(s=>e.startsWith(s));case"includes":return t.patterns.some(s=>e.includes(s))}}function yT(e,t,s=[]){const o=Th(t,pT);if(o!==null)return{tokens:o,label:"Request metadata",source:"request"};const r=v3(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 hT)if(vT(a,i))return{tokens:i.tokens,label:`${i.family} local rule`,source:"model-rule"};return{tokens:null,label:"No local rule",source:"unknown"}}function wT(e){return e<0?0:e>1?1:e}function jT(e){return e===null?"unknown":e>=Ch?"danger":e>=Nh?"watch":"ok"}function ST(e,t){return e.filter(s=>s.role===t).reduce((s,o)=>s+o.size,0)}function NT(e,t){return["system","user","assistant","tool","tools"].map(o=>{const r=ST(e,o);return{role:o,label:xT[o],tokens:r,percent:t>0?r/t:0}}).filter(o=>o.tokens>0).sort((o,r)=>r.tokens-o.tokens)}function Mi(e){return e.replace(/\s+/g," ").trim().toLowerCase()}function CT(e){const t=e.replace(/\s+/g," ").trim();return t.length<=qd?t:`${t.slice(0,qd-3)}...`}function kT(e){return{role:e.role,label:e.label,path:e.path,tokens:e.tokens,characters:e.characters}}function _T(e){return{role:e.role,label:e.label,path:e.path,tokens:e.size,characters:e.characters,text:e.text}}function TT(e){const t=e.trim();return t.startsWith("{")||t.startsWith("[")}function ET(e){if(!TT(e))return null;try{return JSON.parse(e)}catch{return null}}function RT(e){return e.toLowerCase().replace(/[^a-z0-9]/g,"")}function MT(e){for(let t=e.length-1;t>=0;t-=1){const s=e[t]??"";if(!(s.startsWith("[")&&s.endsWith("]")))return s}return null}function AT(e){const t=MT(e);return t===null?!1:mT.has(RT(t))}function IT(e){return e.map(t=>t.startsWith("[")?t:`.${t}`).join("").replace(/^\./,"")}function PT(e,t,s){const o=Ml(t);if(o<_h)return null;const r=Rl(t);return r<kh?null:{role:e.role,label:`${e.label} ${IT(s)}`,path:e.path,tokens:r,characters:o,text:t}}function Ai({value:e,segment:t,path:s,depth:o,candidates:r}){if(!(r.length>=iT)&&!(o>aT)){if(typeof e=="string"){if(!AT(s))return;const a=PT(t,e,s);a!==null&&r.push(a);return}if(Array.isArray(e)){e.forEach((a,i)=>Ai({value:a,segment:t,path:[...s,`[${String(i)}]`],depth:o+1,candidates:r}));return}Al(e)&&Object.entries(e).forEach(([a,i])=>Ai({value:i,segment:t,path:[...s,a],depth:o+1,candidates:r}))}}function LT(e){const t=_T(e),s=ET(e.text);if(s===null)return[t];const o=[];Ai({value:s,segment:e,path:[],depth:0,candidates:o});const r=Mi(e.text),a=new Set([r]),i=o.filter(c=>{const d=Mi(c.text);return d===""||a.has(d)?!1:(a.add(d),!0)});return[t,...i]}function OT(e){const t=new Map;for(const o of e){const r=LT(o);for(const a of r){if(a.tokens<kh||a.characters<_h)continue;const i=Mi(a.text);if(i==="")continue;const c=t.get(i);if(c===void 0){t.set(i,{tokens:a.tokens,candidates:[a]});continue}t.set(i,{tokens:c.tokens+a.tokens,candidates:[...c.candidates,a]})}}const s=[];for(const o of t.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:CT(r.text),firstLabel:r.label,segments:o.candidates.map(kT)})}return s.sort((o,r)=>r.repeatedTokens-o.repeatedTokens||r.totalTokens-o.totalTokens)}function DT(e){if(e.length===0)return null;const t=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>=Ri?"danger":"watch",title:"Duplicate context",detail:`${String(s)} repeated blocks across ${String(t)} group${t===1?"":"s"}, ~${String(o)} repeated tokens.`}}function zT(e){return e.reduce((t,s)=>t+s.repeatedTokens,0)}function $T(e,t,s){const o=[],r=e.find(d=>d.role==="tools")??null;r!==null&&(r.tokens>=Ri||r.percent>=rT&&r.tokens>=Ud)&&o.push({kind:"tool-schema",severity:r.tokens>=Ri?"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>=Ud&&a.percent>=uT&&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=t>0?i/t:0;return s>=lT&&(i>=cT||c>=dT)&&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 FT({risk:e,contextWindow:t,diagnostics:s,duplicateGroups:o}){let a=new Set(s.map(d=>d.kind)).size;(e==="watch"||e==="danger")&&(a+=1),t.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:zT(o)}}function BT({segments:e,inputTokens:t,parsed:s,model:o,providers:r=[]}){const a=e.reduce((C,E)=>C+E.size,0),i=o??bT(s),c=t??a,d=Th(s,fT),m=yT(i,s,r),u=d??0,p=m.tokens===null?null:c+u,f=m.tokens===null?null:m.tokens-c,h=m.tokens===null?null:m.tokens-c-u,g=m.tokens===null||p===null?null:wT(p/m.tokens),b=NT(e,a),y=b[0]??null,w=e.filter(C=>C.role!=="tools").length,v=OT(e),j=DT(v),S=$T(b,a,w);j!==null&&S.unshift(j);const N=jT(g);return{model:i,contextWindow:m,estimatedInputTokens:c,outputReserveTokens:d,windowUsedTokens:p,remainingInputTokens:f,remainingAfterReserveTokens:h,usagePercent:g,riskLevel:N,roleUsages:b,largestRole:y,diagnostics:S,duplicateGroups:v,health:FT({risk:N,contextWindow:m,diagnostics:S,duplicateGroups:v})}}const nR={watch:Nh,danger:Ch},Hd=new WeakMap;function UT(e){return e.map(t=>{const s=t.modelMetadata?.map(o=>`${o.model}:${String(o.contextWindow??"")}`).join(",")??"";return`${t.id}:${t.updatedAt}:${t.models.join(",")}:${s}`}).join("|")}function qT(e){if(e===null)return null;try{return JSON.parse(e)}catch{return null}}function HT(e){return{role:e.role,label:e.label,size:e.tokens,characters:e.tokens*4,text:"",path:`role:${e.role}`}}function VT(e,t){const s=qT(e.rawRequestBody);if(s===null)return null;const r=vf(mr(e)).anatomySegments(s);if(r===null)return null;const a=BT({segments:r,inputTokens:e.inputTokens??null,parsed:s,model:e.model,providers:t}),i=a.model??e.model??"Unknown model",c=a.roleUsages.map(HT);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 WT(e,t,s){const o=Hd.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=VT(e,t);return Hd.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 GT(e,t){return e.usagePercent!==null&&t.usagePercent!==null?e.usagePercent>t.usagePercent:e.usagePercent!==null&&t.usagePercent===null?!0:e.usagePercent===null&&t.usagePercent!==null?!1:e.estimatedInputTokens>t.estimatedInputTokens}function Vd(e){switch(e){case"danger":return 4;case"watch":return 3;case"unknown":return 2;case"ok":return 1}}function KT(e,t){const s=Vd(t.latest.riskLevel)-Vd(e.latest.riskLevel);if(s!==0)return s;const o=e.peak.usagePercent??-1,a=(t.peak.usagePercent??-1)-o;return a!==0?a:t.latest.logId-e.latest.logId}function YT(e,t){return e.usagePercent===null||t.usagePercent===null?null:(t.usagePercent-e.usagePercent)*100}function JT(e){for(let t=1;t<e.length;t++){const s=e[t-1],o=e[t];if(!(s===void 0||o===void 0)&&s.id>o.id)return[...e].sort((r,a)=>r.id-a.id)}return e}function XT(e,t=[]){const s=JT(e),o=UT(t),r=new Map;for(const i of s){const c=WT(i,t,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:GT(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:YT(i.first,i.latest)})).sort(KT)}}function Ln(e){return e.length<=30?e:`${e.slice(0,12)}...${e.slice(-12)}`}function ZT(e){const t=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&&t.set(r.id,o+1)}return t}function Wd(e,t){return t.get(e.id)??e.id}function Gd(e){let t=0,s=0;for(const o of e)o.inputTokens!==null&&(t+=o.inputTokens),o.outputTokens!==null&&(s+=o.outputTokens);return{totalIn:t,totalOut:s}}function QT(e){for(const t of e)if(t.userAgent!==null&&t.userAgent!==void 0&&t.userAgent!=="")return t.userAgent;return null}function eE(e,t){const s=e[0],o=e[e.length-1];return s===void 0||o===void 0?null:_r(s.timestamp,o.timestamp,t)}function tE(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 nE(e){switch(e){case"rolling":return n.jsx(Et,{className:"size-3 text-status-cool"});case"failed":return n.jsx(nr,{className:"size-3 text-status-danger"});case"watch":return n.jsx(zu,{className:"size-3 text-status-watch"});case"clear":return n.jsx(Fe,{className:"size-3 text-status-success"})}}function sE(e){switch(e){case"rolling":return"cool";case"failed":return"danger";case"watch":return"watch";case"clear":return"neutral"}}function oE(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 rs({label:e,value:t,detail:s,icon:o,tone:r="neutral"}){return n.jsxs("div",{className:"min-w-0 border-t border-border/60 px-4 py-3",children:[n.jsxs("div",{className:"flex items-center gap-1 text-[10px] uppercase text-muted-foreground",children:[o,e]}),n.jsx("div",{className:P("mt-2 font-mono text-sm font-semibold",tE(r)),children:t}),n.jsx("div",{className:"mt-1 font-mono text-[11px] leading-snug text-muted-foreground",children:s})]})}function rE({stats:e}){return e.requests===0?null:n.jsxs("div",{className:"mb-4 overflow-hidden rounded-[8px] border border-border bg-card",children:[n.jsx("div",{className:"px-4 py-3",children:n.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-semibold uppercase text-muted-foreground",children:[n.jsx(J0,{className:"size-3.5 text-slate-300"}),"Flight Recorder"]}),n.jsx("div",{className:"mt-2 min-w-0 font-mono text-sm font-semibold text-foreground",children:e.modelLabel})]}),n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-muted-foreground",children:[n.jsx("span",{className:"min-w-0 font-mono",children:e.providerLabel}),n.jsx("span",{className:"min-w-0 font-mono",children:e.timeRange??"Timeline pending"})]})]})}),n.jsxs("div",{className:"grid grid-cols-2 border-t border-border/60 md:grid-cols-3 2xl:grid-cols-6",children:[n.jsx(rs,{label:"Status",value:e.statusLabel,detail:oE(e),icon:nE(e.status),tone:sE(e.status)}),n.jsx(rs,{label:"Turns",value:String(e.turns),detail:e.finishLabel,icon:n.jsx(kg,{className:"size-3 text-muted-foreground"}),tone:e.finishTone}),n.jsx(rs,{label:"Requests",value:String(e.requests),detail:`${e.failures} failed / ${e.slow} slow`,icon:n.jsx(nr,{className:"size-3 text-muted-foreground"}),tone:e.failures>0?"danger":"neutral"}),n.jsx(rs,{label:"Peak",value:e.slowestLabel,detail:e.slowestDetail,icon:n.jsx(zu,{className:"size-3 text-muted-foreground"}),tone:e.slow>0?"watch":"neutral"}),n.jsx(rs,{label:"Tokens",value:e.tokenLabel,detail:e.heaviestDetail,icon:n.jsx(Zi,{className:"size-3 text-muted-foreground"})}),n.jsx(rs,{label:"Outcome",value:e.outcomeLabel,detail:e.outcomeDetail,tone:e.outcomeTone})]})]})}function Us(e){if(e===null)return"Unknown";const t=e*100;return t>=10?`${t.toFixed(0)}%`:t>=1?`${t.toFixed(1)}%`:t>0?"<1%":"0%"}function aE(e){return e===null?"n/a":Math.abs(e)<.1?"0%":`${e>0?"+":""}${e.toFixed(1)}%`}function Ii(e){return e===null||!Number.isFinite(e)?0:Math.min(Math.max(e*100,0),100)}function iE(e,t){if(t===null)return null;const s=Ii(e),o=Ii(t);return o<=0||Math.abs(o-s)<.5?null:o}function lE(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 cE(e){const t=e.latest.contextWindow.tokens;return t===null?"Context window unknown":`Context window ${ru(t)}`}const dE=["score","decision","final_status","validation_pass_ratio","semantic_memory_score","opencode_exit","actual_model","run_dir","workspace","project_dir","work_dir"];function Eh(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 Ka(e,t){if(e===null)return null;const s=e.metadata[t];return s===void 0?null:Eh(s)}function uE(e){const t=e.toLowerCase();return t.includes("reject")||t.includes("fail")||t.includes("error")?"border-red-400/35 bg-red-500/10 text-red-100":t.includes("partial")||t.includes("pending")||t.includes("slow")?"border-amber-300/35 bg-amber-400/10 text-amber-100":t.includes("pass")||t.includes("complete")||t.includes("accept")?"border-cyan-300/25 bg-cyan-400/10 text-cyan-100":"border-border/70 bg-background/70 text-muted-foreground"}function mE(e){const t=[];for(const s of dE){const o=e.metadata[s];if(o===void 0)continue;const r=Eh(o);r!==null&&t.push({key:s,value:r})}return t}function Kd({memberships:e,defaultOpen:t=!1}){const[s,o]=l.useState(t);if(e.length===0)return null;const r=e[0],a=r?.member??null,i=Ka(a,"score"),c=Ka(a,"decision"),d=Ka(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 n.jsxs("div",{className:"border border-border bg-card shadow-sm mb-3 rounded-[8px] text-xs",children:[n.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:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[n.jsx("span",{className:"font-semibold text-foreground",children:"Case File"}),r!==void 0&&n.jsx("span",{className:"truncate text-muted-foreground",title:r.groupTitle,children:r.groupTitle}),n.jsxs("span",{className:"font-mono text-[10px] uppercase text-muted-foreground",children:[e.length," group",e.length===1?"":"s"]})]}),m.length>0&&n.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=>n.jsx("span",{className:P("rounded border px-1.5 py-0.5 font-mono text-[10px]",uE(u.value)),children:u.label},u.label))})]}),s?n.jsx(Ji,{className:"size-4 shrink-0 text-muted-foreground"}):n.jsx(Xe,{className:"size-4 shrink-0 text-muted-foreground"})]}),s&&n.jsx("div",{className:"space-y-2 border-t border-white/10 px-3 py-2",children:e.map(u=>{const p=u.member,f=mE(p);return n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[n.jsx("span",{className:"truncate font-medium text-foreground",title:u.groupTitle,children:u.groupTitle}),n.jsx("span",{className:"font-mono text-[10px] uppercase text-muted-foreground",children:u.groupStatus}),p.status!==null&&n.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:["member ",p.status]})]}),n.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-muted-foreground",children:[n.jsx("span",{className:"font-mono",title:p.sessionId,children:Ln(p.sessionId)}),p.label!==null&&n.jsx("span",{children:p.label}),p.provider!==null&&n.jsx("span",{children:p.provider}),p.model!==null&&n.jsx("span",{className:"font-mono",children:p.model}),p.runId!==null&&n.jsxs("span",{className:"font-mono",title:p.runId,children:["run ",Ln(p.runId)]})]}),f.length>0&&n.jsx("div",{className:"mt-2 grid gap-1 sm:grid-cols-2 xl:grid-cols-3",children:f.map(h=>n.jsxs("div",{className:"border border-border bg-muted/40 min-w-0 rounded-md px-2 py-1",children:[n.jsx("div",{className:"font-mono text-[10px] text-muted-foreground",children:h.key}),n.jsx("div",{className:"truncate font-mono text-[11px] text-foreground",title:h.value,children:h.value})]},h.key))})]},`${u.groupId}:${p.id}`)})})]})}function $o({label:e,title:t,icon:s,disabled:o,onClick:r}){return n.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:t,children:[s,n.jsx("span",{children:e})]})}function Yd({logs:e,pagination:t,embedded:s=!1}){if(t===void 0)return null;const o=t.isLoading;return n.jsxs("nav",{"aria-label":"Session log pagination",className:P("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:[n.jsxs("div",{className:"w-full min-w-0 px-1 font-mono text-[11px] text-muted-foreground sm:flex-1",children:[n.jsxs("div",{role:"status","aria-live":"polite","aria-atomic":"true",children:[rk({logs:e,pagination:t}),t.isLoading&&e.length>0&&n.jsx("span",{className:"ml-2",children:"Loading..."})]}),t.loadProgress!==void 0&&n.jsx(Ko,{progress:t.loadProgress})]}),n.jsxs("div",{className:"flex w-full items-center gap-1 overflow-x-auto sm:w-auto",children:[n.jsx($o,{label:"Oldest",title:"Load the oldest logs in this session",icon:n.jsx(O0,{className:"size-3.5"}),disabled:o||!t.hasOlder,onClick:t.onOldest}),n.jsx($o,{label:"Older",title:"Load older logs",icon:n.jsx(R0,{className:"size-3.5"}),disabled:o||!t.hasOlder,onClick:t.onOlder}),n.jsx($o,{label:"Newer",title:"Load newer logs",icon:n.jsx(gt,{className:"size-3.5"}),disabled:o||!t.hasNewer,onClick:t.onNewer}),n.jsx($o,{label:"Newest",title:"Load the newest logs in this session",icon:n.jsx(z0,{className:"size-3.5"}),disabled:o||!t.hasNewer,onClick:t.onNewest})]})]})}function pE(e){return`${e} ${e===1?"request":"requests"}`}function Jd(e){return`#${String(e)}`}function Xd(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 fE(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 hE(e){switch(e){case"risk":return"Risk";case"optimizable":return"Optimizable";case"ok":return"OK"}}const xE=10,gE=80;function bE(e){e.setAttribute("data-deep-link-highlight","true"),window.setTimeout(()=>{e.removeAttribute("data-deep-link-highlight")},1800)}function vE(e){const t=document.getElementById(`log-${String(e)}`);return t instanceof HTMLElement?(t.scrollIntoView({block:"center",behavior:xh(gh())}),t.focus({preventScroll:!0}),bE(t),!0):!1}function Rh(e){Ss({logId:e,tab:"anatomy"});let t=0;const s=()=>{Ss({logId:e,tab:"anatomy"}),!vE(e)&&(t+=1,t<xE&&window.setTimeout(s,gE))};window.setTimeout(s,0)}function yE({command:e}){const[t,s]=l.useState(!1),o=l.useCallback(()=>{Tt(e).then(r=>{r&&(s(!0),setTimeout(()=>s(!1),2e3))})},[e]);return n.jsxs("div",{"data-command-example":"true",className:BC,children:[n.jsx("pre",{className:UC,children:e}),n.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:t?n.jsx(Fe,{className:"size-4"}):n.jsx(It,{className:"size-4"})})]})}function Ya({label:e,children:t,className:s}){return n.jsxs("section",{className:P("rounded-[8px] border border-border/60 bg-card/55",s),children:[n.jsx("div",{className:"px-3 pt-3",children:n.jsx("div",{className:"font-mono text-[10px] font-semibold uppercase tracking-[0.14em] text-text-subtle",children:e})}),n.jsx("div",{className:"p-3 pt-2",children:t})]})}function Fo({label:e,value:t}){return n.jsxs("div",{className:"min-w-0 rounded-md border border-border/50 bg-muted/30 px-2 py-2",children:[n.jsx("div",{className:"truncate font-mono text-lg font-semibold leading-6 text-text-strong",children:t}),n.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] uppercase tracking-[0.12em] text-text-subtle",children:e})]})}function wE(){const{themeMode:e,setThemeMode:t}=jb();return n.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:[n.jsx("button",{type:"button",onClick:()=>t("light"),className:P("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:n.jsx(O1,{className:"size-3.5"})}),n.jsx("button",{type:"button",onClick:()=>t("eye-care"),className:P("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:n.jsx(Ru,{className:"size-3.5"})}),n.jsx("button",{type:"button",onClick:()=>t("dark"),className:P("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:n.jsx(Jg,{className:"size-3.5"})})]})}function jE({visible:e,onToggle:t}){const s=e?"Hide Inspector pet":"Summon Inspector pet";return n.jsx("button",{type:"button",onClick:t,className:P("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:n.jsx(au,{className:P("size-4 transition-opacity",!e&&"opacity-45")})})}function SE({preference:e,resolvedScale:t,onChange:s}){const o=Tb(t),r=e==="auto"?`Auto (${o})`:`${e}%`;return n.jsxs(Ys,{value:e,onValueChange:a=>s(nl(a)),children:[n.jsxs(Js,{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:[n.jsx(a0,{className:"size-3.5"}),n.jsx("span",{className:"font-mono text-[10px] font-semibold tabular-nums",children:o})]}),n.jsxs(Xs,{align:"end",children:[n.jsx(it,{value:"auto",children:"Auto"}),n.jsx(it,{value:"100",children:"100%"}),n.jsx(it,{value:"125",children:"125%"}),n.jsx(it,{value:"150",children:"150%"})]})]})}const Mh="agent-inspector.detailsPanelCollapsed",Ah="agent-inspector.detailsPanelWidth",Ih="agent-inspector.pet.visible",ds=360,NE=288,CE=520;function Ph(e){return Math.min(Math.max(e,NE),CE)}function kE(){if(typeof window>"u")return!0;try{const e=window.localStorage.getItem(Mh);return e===null||e==="1"}catch{return!0}}function _E(){if(typeof window>"u")return ds;try{const e=window.localStorage.getItem(Ah);if(e===null)return ds;const t=Number.parseInt(e,10);return Number.isFinite(t)?Ph(t):ds}catch{return ds}}function TE(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(Ih)!=="0"}catch{return!0}}function Zd({label:e,logId:t}){return n.jsxs("button",{type:"button",onClick:()=>Rh(t),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 ${Jd(t)}`,children:[e," ",Jd(t)]})}function EE({latestPercent:e,peakPercent:t,risk:s,onOpenContext:o}){const r=Ii(e),a=iE(e,t),i=t===null?`Latest context window usage ${Us(e)}`:`Latest context window usage ${Us(e)}, peak ${Us(t)}`;return n.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:n.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:[n.jsx("span",{className:P("block h-full rounded-full transition-[width]",lE(s)),style:{width:`${r}%`}}),a!==null&&n.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 RE({summary:e}){const t=e.trendPercent,s=t===null||Math.abs(t)<.1?null:t>0?x0:d0,o=e.latest.diagnostics[0]??null,r=Us(e.latest.usagePercent),a=Us(e.peak.usagePercent),i=()=>{Rh(e.latest.logId)};return n.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:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.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}),n.jsx("span",{className:P("inline-flex h-5 shrink-0 items-center rounded border px-1.5 font-mono text-[10px]",fE(e.latest.health.level)),children:hE(e.latest.health.level)})]}),n.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:[n.jsx("span",{children:pE(e.requestCount)}),n.jsx("span",{children:cE(e)})]})]}),n.jsxs("div",{className:"min-w-0 space-y-2 text-xs",children:[n.jsx(EE,{latestPercent:e.latest.usagePercent,peakPercent:e.peak.usagePercent,risk:e.latest.riskLevel,onOpenContext:i}),n.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Latest"}),n.jsx("div",{className:P("mt-0.5 font-mono",Xd(e.latest.riskLevel)),children:r}),n.jsx(Zd,{label:"Log",logId:e.latest.logId})]}),n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Peak"}),n.jsx("div",{className:P("mt-0.5 font-mono",Xd(e.peak.riskLevel)),children:a}),n.jsx(Zd,{label:"Log",logId:e.peak.logId})]}),n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Trend"}),n.jsxs("div",{className:"mt-0.5 flex items-center gap-1 font-mono text-foreground",children:[s!==null&&n.jsx(s,{className:P("size-3",t!==null&&t>0?"text-amber-300":"text-cyan-300")}),aE(t)]}),n.jsx("div",{className:"h-5","aria-hidden":"true"})]})]})]}),n.jsxs("div",{className:"min-w-0 space-y-1.5",children:[n.jsx(oT,{segments:e.latest.roleSegments,totalTokens:e.latest.roleTotalTokens,showLabels:!1}),n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-muted-foreground",children:[n.jsxs("span",{className:"font-mono",children:["~",Ie(e.latest.estimatedInputTokens)," input"]}),e.latest.windowUsedTokens!==null&&n.jsxs("span",{className:"font-mono",children:["~",Ie(e.latest.windowUsedTokens)," used"]}),o!==null&&n.jsx("span",{className:"truncate",children:o})]})]})]})}function ME({summary:e}){return e.models.length===0?null:n.jsxs("div",{className:"mt-3 border-t border-white/10 pt-2",children:[n.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2",children:[n.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-normal text-muted-foreground",children:"Session Context"}),n.jsxs("div",{className:"font-mono text-[10px] text-muted-foreground",children:[e.models.length," model",e.models.length===1?"":"s"]})]}),n.jsx("div",{className:"max-h-52 overflow-y-auto pr-1",children:e.models.map(t=>n.jsx(RE,{summary:t},t.model))})]})}function AE(e){const t=e.models.filter(o=>o.latest.health.level==="risk").length;if(t>0)return`${t} 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 IE({label:e,logs:t,totalIn:s,totalOut:o,timeDisplayFormat:r,contextSummary:a,showBackLink:i}){const[c,d]=l.useState(!1),[m,u]=l.useState(!1),p=l.useMemo(()=>eE(t,r),[t,r]),f=l.useMemo(()=>QT(t),[t]),h=l.useMemo(()=>AE(a),[a]),g=l.useCallback(()=>{Tt(window.location.href).then(b=>{b&&(d(!0),setTimeout(()=>d(!1),2e3))})},[]);return n.jsxs("div",{className:"border border-border bg-card shadow-sm mb-3 rounded-[8px] px-3 py-2 text-xs",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[i&&n.jsx("a",{href:Oi("/"),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:n.jsx(f0,{className:"size-3.5"})}),n.jsxs("div",{className:"min-w-[180px] flex-1",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsx("span",{className:"font-mono font-semibold text-purple-400/90 truncate",title:e,children:Ln(e)}),f!==null&&n.jsx("span",{className:"font-mono text-muted-foreground truncate max-w-[220px]",title:f,children:f})]}),n.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-muted-foreground",children:[n.jsxs("span",{children:[t.length," request",t.length!==1?"s":""]}),p!==null&&n.jsx("span",{children:p}),(s>0||o>0)&&n.jsxs("span",{className:"font-mono",children:[Ie(s)," in / ",Ie(o)," out"]})]})]}),a.models.length>0&&n.jsxs("button",{type:"button",onClick:()=>u(b=>!b),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:[n.jsx("span",{children:h}),m?n.jsx(Ji,{className:"size-3.5"}):n.jsx(Xe,{className:"size-3.5"})]}),n.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?n.jsx(Fe,{className:"size-3.5"}):n.jsx(It,{className:"size-3.5"})})]}),m&&n.jsx(ME,{summary:a})]})}function PE({logs:e,sessions:t,selectedSession:s,selectedModel:o,onSessionChange:r,onClearAll:a,onDeleteCurrentView:i,onReloadSession:c,onClearGroup:d,onNotify:m,onImportLogs:u,viewMode:p,captureMode:f,strip:h,slowResponseThresholdSeconds:g,timeDisplayFormat:b,isLoading:y=!1,liveConnection:w,onRetryLiveConnection:v,onStopLiveConnection:j,pagination:S,sessionLoadProgress:N,sessionLoadError:C,sessionMemberships:E=[],hideSessionFilter:A=!1,pinnedSessionId:I}){const{totalIn:R,totalOut:k}=l.useMemo(()=>Gd(e),[e]),{providers:M}=ol(),{uiScalePreference:O,resolvedUiScale:$,setUiScalePreference:K}=Ab(),[Q,z]=l.useState(null),[H,ee]=l.useState(null),[U,Z]=l.useState(!1),[fe,je]=l.useState(!1),[he,oe]=l.useState(null),[L,J]=l.useState(null),[Se,Te]=l.useState(!1),[ge,le]=l.useState(!1),[ce,Pe]=l.useState(!0),[Re,$e]=l.useState(ds),[lt,He]=l.useState(!1),[Le,We]=l.useState(!1),[Ke,Ze]=l.useState(!0),[rt,nt]=l.useState(!1),[q,se]=l.useState(null),[xe,pe]=l.useState(null),we=l.useRef(null),Oe=l.useRef(null),ze=l.useRef(null),D=l.useRef(null),Y=l.useRef(0),de=l.useRef(null);Z_(we,Oe,{pageWide:!0});const[Ne,F]=l.useState(null);l.useEffect(()=>Qi(F),[]);const W=l.useCallback(()=>{Y.current+=1,D.current?.abort(),D.current=null,z(null),ee(null)},[]);l.useEffect(()=>()=>{Y.current+=1,D.current?.abort(),D.current=null},[]),l.useEffect(()=>{Pe(kE()),$e(_E()),We(!0)},[]),l.useEffect(()=>{Le&&window.localStorage.setItem(Mh,ce?"1":"0")},[ce,Le]),l.useEffect(()=>{if(Le)try{window.localStorage.setItem(Ah,String(Re))}catch{}},[Le,Re]),l.useEffect(()=>{Ze(TE()),nt(!0)},[]),l.useEffect(()=>{if(rt)try{window.localStorage.setItem(Ih,Ke?"1":"0")}catch{}},[rt,Ke]),l.useEffect(()=>{if(I===void 0){document.title="Agent Inspector";return}const ye=e.length===1?"1 req":`${e.length} req`;document.title=`${Ln(I)} - ${ye} - Agent Inspector`},[e.length,I]);const X=l.useCallback(async ye=>{D.current?.abort();const Ge=new AbortController;D.current=Ge;const Nt=Y.current+1;Y.current=Nt,z(ye),ee(null);try{const Xt=await gb(e,ye,{signal:Ge.signal});if(Y.current!==Nt)return;if(!Xt.ok){if(Xt.canceled===!0)return;m!==void 0?m({message:Xt.message,tone:"error"}):ee(Xt.message)}}finally{Y.current===Nt&&(D.current=null,z(null))}},[e,m]),ne=l.useCallback(ye=>{if(VC(ye)){Z(!0);return}X(ye)},[X]),Ee=l.useCallback(()=>{Z(!1),X("redacted")},[X]),ie=l.useCallback(()=>{Z(!1),X("raw")},[X]),re=l.useCallback(()=>{ze.current?.click()},[]),ke=l.useCallback(ye=>{const Ge=ye.currentTarget.files?.[0];ye.currentTarget.value="",!(Ge===void 0||u===void 0)&&(je(!0),J(null),oe(null),u(Ge).then(Nt=>{const Xt=Nt.skipped>0?`, skipped ${String(Nt.skipped)}`:"",Xl=`Imported ${String(Nt.imported)} logs as ${Nt.sessionId}${Xt}.`;m!==void 0?m({message:Xl,tone:"success"}):oe(Xl)}).catch(Nt=>{const Xt=Nt instanceof Error?Nt.message:"Failed to import logs";m!==void 0?m({message:Xt,tone:"error"}):J(Xt)}).finally(()=>{je(!1)}))},[u,m]);l.useEffect(()=>{W(),pe(null),se(null)},[W,s,o]);const De=l.useCallback(()=>{W(),oe(null),J(null),pe(null),a()},[W,a]),Wn=l.useCallback(()=>{Te(!0)},[]),Lt=l.useCallback(()=>{W(),oe(null),J(null),pe(null),i!==void 0&&(le(!0),i().then(()=>{Te(!1)}).catch(ye=>{const Ge=ye instanceof Error?ye.message:"Failed to delete stored logs";m!==void 0?m({message:Ge,tone:"error"}):J(Ge)}).finally(()=>{le(!1)}))},[W,i,m]),rn=l.useCallback(()=>{c!==void 0&&(W(),oe(null),J(null),pe(null),c())},[W,c]),Qr=l.useCallback(()=>{pe(null)},[]),Gn=l.useCallback(()=>{Pe(ye=>!ye)},[]),ea=l.useCallback(ye=>{de.current={startX:ye.clientX,startWidth:Re,pointerId:ye.pointerId},ye.currentTarget.setPointerCapture(ye.pointerId),He(!0)},[Re]),Me=l.useCallback(ye=>{const Ge=de.current;Ge===null||Ge.pointerId!==ye.pointerId||$e(Ph(Ge.startWidth+Ge.startX-ye.clientX))},[]),vt=l.useCallback(ye=>{const Ge=de.current;Ge===null||Ge.pointerId!==ye.pointerId||(ye.currentTarget.hasPointerCapture(ye.pointerId)&&ye.currentTarget.releasePointerCapture(ye.pointerId),de.current=null,He(!1))},[]),Qe=l.useCallback(()=>{$e(ds)},[]),Es=l.useCallback(()=>{Ze(ye=>!ye)},[]),st=l.useMemo(()=>q===null?null:new Set(q.logIds),[q]),St=l.useMemo(()=>st===null?e:e.filter(ye=>st.has(ye.id)),[st,e]),Ot=l.useMemo(()=>A5(St),[St]),Vl=l.useMemo(()=>ZT(Ot),[Ot]),Tn=l.useMemo(()=>ok({pinnedSessionId:I,selectedSession:s,sessions:t,logs:e}),[e,I,s,t]),Kn=Tn?.logs??[],Rs=Tn!==null&&Kn.length>0,{totalIn:Wl,totalOut:Gl}=l.useMemo(()=>Gd(Kn),[Kn]),Oh=l.useMemo(()=>XT(Kn,M),[Kn,M]),Dh=l.useMemo(()=>S_(Ot),[Ot]),ta=l.useMemo(()=>XN(Ot),[Ot]),Kl=WC(f,e.length),zh=I!==void 0,$h=e.length>0,Fh=i!==void 0&&(e.length>0||s!=="__all__"),Bh=s==="__all__"?"all sessions":"this session",Uh=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.",qh=e.length===0?"Load":"Reload",na=Rs&&Tn!==null?Ln(Tn.label):s==="__all__"?"All sessions":Ln(s),Yl=R_(w),sa=M_(Yl),Hh=l.useMemo(()=>sk({logs:St,conversationGroups:Ot,isLoading:y,timeDisplayFormat:b,slowResponseThresholdSeconds:g}),[St,Ot,y,g,b]),Vh=l.useCallback(ye=>{const Ge=ta.get(ye.id);Ge!==void 0&&pe([Ge,ye])},[ta]),Jl=I!==void 0?I:s==="__all__"?null:s;return n.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:[n.jsx(__,{liveConnection:w,alertsAction:n.jsx(Pk,{}),settingsAction:n.jsx(y4,{})}),n.jsxs("button",{type:"button",onClick:Gn,className:P("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":ce?"Show details panel":"Hide details panel",title:ce?"Show details panel":"Hide details panel",children:[n.jsx("span",{className:"absolute bottom-2 left-1 top-2 w-px rounded-full bg-border transition-colors group-hover:bg-foreground/35"}),ce?n.jsx(l1,{className:"size-3.5"}):n.jsx(a1,{className:"size-3.5"})]}),rt&&Ke&&n.jsx(Jo,{feature:"Inspector Pet",children:n.jsx(l.Suspense,{fallback:null,children:n.jsx(CS,{logs:e})})}),n.jsxs("div",{className:P("flex w-full min-w-0 flex-col lg:min-h-0 lg:flex-1 lg:flex-row lg:overflow-hidden",lt&&"cursor-col-resize select-none"),children:[!ce&&n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"fixed inset-0 z-30 bg-background/70 backdrop-blur-sm lg:hidden",onClick:Gn,"aria-label":"Close details panel"}),n.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:Re},children:[n.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:ea,onPointerMove:Me,onPointerUp:vt,onPointerCancel:vt,onDoubleClick:Qe,"aria-label":"Resize details panel",title:"Drag to resize; double-click to reset",children:n.jsx("span",{className:"h-12 w-1 rounded-full bg-border transition-colors hover:bg-primary"})}),n.jsxs("div",{className:"flex min-h-full flex-col gap-4 p-4",children:[n.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:[n.jsx(Ya,{label:"View",children:n.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.jsx(wE,{}),n.jsx(SE,{preference:O,resolvedScale:$,onChange:K})]})}),n.jsx(Ya,{label:"Workspace",children:n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx(t3,{labelledTrigger:!0}),n.jsx(o_,{currentSessionId:Jl,logCount:e.length,labelledTrigger:!0})]})})]}),n.jsxs(Ya,{label:"Current scope",children:[n.jsxs("div",{className:"mb-2 rounded-md border border-border/50 bg-muted/25 px-3 py-2",children:[n.jsx("div",{className:"truncate font-mono text-xs font-semibold text-text-link",title:na,children:na}),n.jsx("div",{className:"mt-1 text-[11px] text-muted-foreground",children:zh?"Pinned session":"Live Inspector data"})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[n.jsx(Fo,{label:q===null?"Requests":"Results",value:St.length}),n.jsx(Fo,{label:"Sessions",value:t.length}),n.jsx(Fo,{label:"Input",value:Ie(Rs?Wl:R)}),n.jsx(Fo,{label:"Output",value:Ie(Rs?Gl:k)})]}),N!==void 0&&n.jsx("div",{className:"mt-2 rounded-md border border-border/50 bg-muted/25 px-2 py-2",children:n.jsx(Ko,{progress:N})})]}),Rs&&Tn!==null&&n.jsx(IE,{label:Tn.label,logs:Kn,totalIn:Wl,totalOut:Gl,timeDisplayFormat:b,contextSummary:Oh,showBackLink:Tn.showBackLink}),Rs&&I!==void 0&&E.length>0&&n.jsx(Kd,{memberships:E}),n.jsx("div",{className:"flex-1"}),n.jsx(j_,{currentSessionId:Jl,logCount:e.length,onResultChange:se})]})]})]}),n.jsxs("main",{className:"inspector-scrollbar order-2 min-w-0 lg:order-1 lg:h-full lg:flex-1 lg:overflow-y-auto",children:[n.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:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsxs("div",{className:"min-w-[180px] flex-1",children:[n.jsx("div",{className:"text-sm font-semibold text-foreground",children:"Logs"}),n.jsx("div",{className:"mt-0.5 font-mono text-[11px] text-muted-foreground",children:na})]}),n.jsx(jE,{visible:Ke,onToggle:Es}),u!==void 0&&n.jsxs(n.Fragment,{children:[n.jsx("input",{ref:ze,type:"file",accept:".zip,.json,.jsonl,application/zip,application/json",className:"hidden",onChange:ke}),n.jsx("button",{type:"button",onClick:re,disabled:fe,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:fe?n.jsx("span",{children:"Importing..."}):n.jsxs(n.Fragment,{children:[n.jsx($u,{className:"size-3.5"}),n.jsx("span",{children:"Import"})]})})]}),Kl.redacted&&n.jsx("button",{type:"button",onClick:()=>{ne("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"?n.jsx("span",{children:"Exporting..."}):n.jsxs(n.Fragment,{children:[n.jsx(to,{className:"size-3.5"}),n.jsx("span",{children:"Export"})]})}),Kl.raw&&n.jsx("button",{type:"button",onClick:()=>{ne("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"?n.jsx("span",{children:"Exporting..."}):n.jsxs(n.Fragment,{children:[n.jsx(xg,{className:"size-3.5"}),n.jsx("span",{children:"Raw"})]})}),c!==void 0&&n.jsxs("button",{type:"button",onClick:rn,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:[n.jsx(Et,{className:P("size-3.5",y&&"animate-spin motion-reduce:animate-none")}),n.jsx("span",{children:qh})]}),n.jsxs("button",{type:"button",onClick:De,disabled:!$h,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:[n.jsx(yn,{className:"size-3.5"}),n.jsx("span",{children:"Clear"})]}),i!==void 0&&n.jsxs("button",{type:"button",onClick:Wn,disabled:!Fh||ge,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:[n.jsx(yn,{className:"size-3.5"}),n.jsx("span",{children:"Delete"})]})]}),S===void 0&&N!==void 0&&n.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:n.jsx(Ko,{progress:N})}),C!==void 0&&n.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:[n.jsxs("span",{className:"min-w-0 flex-1",children:["Session logs could not be loaded. ",C," Existing logs remain visible."]}),c!==void 0&&n.jsxs("button",{type:"button",onClick:rn,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:[n.jsx(Et,{className:"size-3"}),"Retry"]})]}),q!==null&&n.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:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"truncate text-xs font-medium text-cyan-50",children:q.question}),n.jsxs("div",{className:"mt-0.5 text-[10px] text-muted-foreground",children:["Showing ",String(St.length)," loaded logs from"," ",String(q.logIds.length)," linked results"]})]}),n.jsxs("button",{type:"button",onClick:()=>se(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:[n.jsx(so,{className:"size-3"}),"All logs"]})]}),q===null&&n.jsx(Yd,{logs:e,pagination:S,embedded:!0}),m===void 0&&H!==null&&n.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&&L!==null&&n.jsx("div",{className:"mt-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:L}),m===void 0&&he!==null&&L===null&&n.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:he}),w!==void 0&&w.status!=="live"&&v!==void 0&&j!==void 0&&n.jsx(C_,{state:w,hasLogs:e.length>0,onRetry:v,onStop:j})]}),n.jsxs("div",{className:"px-4 py-4 lg:px-5",children:[n.jsx(rE,{stats:Hh}),q!==null&&St.length===0?n.jsx("div",{className:"py-16 text-center text-muted-foreground",children:n.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:[n.jsx("p",{className:"text-sm font-medium text-foreground",children:"No linked logs are loaded"}),n.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."}),n.jsx("button",{type:"button",onClick:()=>se(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__"?n.jsx("div",{className:"py-16 text-center text-muted-foreground",children:n.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:[n.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"}),n.jsx("p",{className:"inline-block max-w-full rounded bg-muted px-3 py-1 font-mono text-xs break-all",children:Ln(s)}),N!==void 0&&n.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:n.jsx(Ko,{progress:N})}),E.length>0&&n.jsx("div",{className:"text-left",children:n.jsx(Kd,{memberships:E})}),!y&&n.jsxs("div",{className:"flex flex-col items-center gap-3 text-xs",children:[n.jsx("p",{children:"Stored logs may still be available."}),n.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[c!==void 0&&n.jsxs("button",{type:"button",onClick:rn,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:[n.jsx(Et,{className:"size-3.5"}),n.jsx("span",{children:"Load session"})]}),A?n.jsx("a",{href:Oi("/"),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"}):n.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"})]})]})]})}):n.jsx("div",{className:"py-16 text-center text-muted-foreground",children:n.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:[n.jsx("p",{className:"text-sm font-medium",children:sa.title}),n.jsx("p",{className:"mx-auto max-w-xl text-xs leading-relaxed text-muted-foreground",children:sa.description}),Yl==="empty"&&t.length>0&&n.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."}),sa.showConnectionCommands&&Ne!==null&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"flex flex-col items-center gap-2",children:qC(Ne).map(ye=>n.jsx(yE,{command:ye},ye))}),n.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."})]})]})}):n.jsxs("div",{ref:Oe,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:[n.jsx("div",{ref:we,children:n.jsx(U_,{groups:Ot,viewMode:p,strip:h,slowResponseThresholdSeconds:g,cacheTrends:Dh,onCompareWithPrevious:Vh,comparisonPredecessors:ta,onClearGroup:d,defaultExpanded:Ot.length===1,timeDisplayFormat:b})}),q===null&&n.jsx("div",{className:"mt-3",children:n.jsx(Yd,{logs:e,pagination:S})})]})]})]})]}),n.jsx(qt,{open:U,onOpenChange:Z,children:n.jsx(Ht,{className:V_,children:n.jsx(G_,{onCancel:()=>Z(!1),onExportRedacted:Ee,onConfirmRaw:ie})})}),n.jsx(qt,{open:Se,onOpenChange:Te,children:n.jsxs(Ht,{className:"border-red-500/20 bg-zinc-950 text-zinc-100 sm:max-w-md",children:[n.jsxs(Yt,{children:[n.jsxs(Jt,{children:["Delete ",Bh," history?"]}),n.jsx(lo,{children:"Clear only hides logs from the UI. Delete removes stored history from disk."})]}),n.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:[n.jsx("span",{className:"block font-medium",children:"This is a full history delete."}),n.jsx("span",{className:"mt-1 block text-xs text-red-200/80",children:Uh})]}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(te,{type:"button",variant:"outline",size:"sm",disabled:ge,onClick:()=>Te(!1),children:"Cancel"}),n.jsx(te,{type:"button",variant:"destructive",size:"sm",disabled:ge,onClick:Lt,children:ge?"Deleting...":"Delete history"})]})]})}),xe!==null&&n.jsx(Jo,{feature:"Compare",children:n.jsx(l.Suspense,{fallback:null,children:n.jsx(NS,{left:xe[0],right:xe[1],leftDisplayNumber:Wd(xe[0],Vl),rightDisplayNumber:Wd(xe[1],Vl),onClose:Qr})})})]})}function LE(e,t,s){return t==="__all__"&&s==="__all__"?e:e.filter(o=>!(t!=="__all__"&&o.sessionId!==t||s!=="__all__"&&o.model!==s))}function OE(e,t){if(e.length===0)return[...t];if(t.length===0)return[...e];const s=new Map;for(const o of e)s.set(o.id,o);for(const o of t)s.set(o.id,o);return[...s.values()].toSorted((o,r)=>o.id-r.id)}function Qd(e,t){return t.retainIds?.has(e.id)===!0||t.retainSessionId!==void 0&&e.sessionId===t.retainSessionId}function eu(e,t){const s=e.reduce((a,i)=>a+(Qd(i,t)?0:1),0);if(s<=t.recentLimit)return e;let o=s-t.recentLimit;const r=[];for(const a of e){if(o>0&&!Qd(a,t)){o-=1;continue}r.push(a)}return r}function Pn(e){const t=new Map;for(let s=0;s<e.length;s+=1){const o=e[s];o!==void 0&&t.set(o.id,s)}return t}function Ja(e,t,s,o){if(s.length===0){const m=eu([...e],o);return{logs:m,index:Pn(m)}}const r=[...e];let a=r.length===0?Number.NEGATIVE_INFINITY:r.at(-1)?.id??0,i=!0;for(const m of s){const u=t.get(m.id);if(u!==void 0&&u>=0&&u<r.length){r[u]=m;continue}r.push(m),m.id<a&&(i=!1),a=Math.max(a,m.id)}const c=i?r:r.toSorted((m,u)=>m.id-u.id),d=eu(c,o);return{logs:d,index:Pn(d)}}function An(e,t){const s=new Set;for(const o of e)o!==""&&s.add(o);for(const o of t)o!==""&&s.add(o);return[...s].sort()}function DE(e){const t=new URLSearchParams({compact:"1"});e!==void 0&&t.set("sessionId",e);const s=Qh();return s.ok?ex(s.runtime,`/api/logs/stream?${t.toString()}`):null}function zE(e){const t=DE(e);return t===null?null:new EventSource(t)}const $E=Vt([_({type:ae("init"),logs:V(Hs)}),_({type:ae("update"),log:Hs}),_({type:ae("progress"),logId:T().int().positive(),chunkBase64:x(),responseBytes:T().int().nonnegative(),responseStatus:T().int().nullable(),elapsedMs:T().int().nonnegative().nullable(),terminal:Ce()})]),FE=_({logs:V(Hs),total:T().int().nonnegative(),limit:T().int().positive(),hasOlder:Ce(),hasNewer:Ce(),oldestLogId:T().int().positive().nullable(),newestLogId:T().int().positive().nullable()}),BE=V(x()),tu=_({success:Ce(),cleared:T().int().nonnegative(),logFilesRewritten:T().int().nonnegative().optional(),chunkFilesDeleted:T().int().nonnegative(),sessionArchiveLogsDeleted:T().int().nonnegative().optional()});function UE(e,t){const s=[];for(const o of e)for(const r of o.members)r.sessionId===t&&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 Bo(e){const t=new Set;for(const s of e)s.sessionId!==null&&s.sessionId!==""&&t.add(s.sessionId);return[...t]}function qE(e){const t=new Set;for(const s of e)s.model!==null&&s.model!==""&&t.add(s.model);return[...t]}const HE=100,VE=12,WE=1800,Hl=100,Sr=500,Lh=200,Pi=2e4,GE=1e4,KE=3e3,YE=1e4,JE=2e3;function XE(e,t,s=Hl){const o=new URLSearchParams({cursor:"1",compact:"1",limit:String(s),sessionId:e});switch(t.kind){case"oldest":o.set("anchor","oldest");break;case"older":o.set("beforeLogId",String(t.beforeLogId));break;case"newer":o.set("afterLogId",String(t.afterLogId));break}return`/api/logs?${o.toString()}`}function qs(e,t,s=Hl){return Be(XE(e,t,s),FE,Pi)}async function ZE(e,t){const s=new Set;let o=await qs(e,{kind:"oldest"},Sr);for(const a of o.logs)s.add(a.id);t(s.size,1);let r=1;for(;o.hasNewer&&o.newestLogId!==null&&r<Lh;){o=await qs(e,{kind:"newer",afterLogId:o.newestLogId},Sr);for(const a of o.logs)s.add(a.id);r+=1,t(s.size,r)}return{ids:[...s],truncated:o.hasNewer}}async function QE(){try{return{deleted:(await tt("/api/groups",wu,{method:"DELETE"})).deleted,ok:!0}}catch{return{deleted:0,ok:!1}}}function sR({initialSessionId:e}={}){const[t,s]=l.useState([]),[o,r]=l.useState(e??"__all__"),[a,i]=l.useState("__all__"),[c,d]=l.useState([]),{notice:m,showToast:u,dismissToast:p}=Kf(),[f,h]=l.useState(E_),[g,b]=l.useState(null),[y,w]=l.useState(e!==void 0),[v,j]=l.useState(null),[S,N]=l.useState(void 0),[C,E]=l.useState([]),[,A]=l.useTransition(),I=l.useRef(null),R=l.useRef(null),k=l.useRef(null),M=l.useRef(!0),O=l.useRef(null),$=l.useRef(0),K=l.useRef(null),Q=l.useRef(null),z=l.useRef(new Map),H=l.useRef([]),ee=l.useRef(new Map),U=l.useRef(new Map),Z=l.useRef(new Map),fe=l.useRef(null),je=l.useCallback(()=>({recentLimit:JE,retainSessionId:e??(o==="__all__"?void 0:o)}),[e,o]),he=l.useCallback(F=>{u({message:F,tone:"error"})},[u]),oe=l.useCallback(()=>{Q.current!==null&&(clearInterval(Q.current),Q.current=null),K.current=null,N(void 0)},[]),L=l.useCallback((F,W,X=0,ne=0)=>{Q.current!==null&&clearInterval(Q.current);const Ee=Date.now();K.current=Ee;const ie=()=>{$.current===W&&N({label:F,elapsedMs:Date.now()-Ee,timeoutMs:Pi,loadedLogs:X,loadedPages:ne})};ie(),Q.current=setInterval(ie,250)},[]),J=l.useCallback((F,W,X,ne)=>{const Ee=K.current;Ee===null||$.current!==W||N({label:F,elapsedMs:Date.now()-Ee,timeoutMs:Pi,loadedLogs:X,loadedPages:ne})},[]),Se=l.useMemo(()=>LE(t,o,a),[t,o,a]),Te=l.useMemo(()=>An(c,Bo(t)),[t,c]),ge=l.useMemo(()=>qE(t),[t]),le=l.useCallback(()=>{tt("/api/sessions",BE).then(F=>{d(W=>An(W,F))}).catch(()=>{})},[]),ce=l.useCallback(()=>{fe.current=null;const F=H.current;H.current=[],F.length!==0&&A(()=>{s(W=>{const X=Ja(W,z.current,F,je());return z.current=X.index,X.logs})})},[je,A]),Pe=l.useCallback(F=>{const W=ee.current.get(F.id),X=Z.current.get(F.id);H.current.push(W!==void 0&&F.responseText===null?{...F,responseText:W,responseTextBytes:X?.responseBytes??new TextEncoder().encode(W).byteLength,responseStatus:X?.responseStatus??F.responseStatus,elapsedMs:X?.elapsedMs??F.elapsedMs,totalStreamMs:X?.elapsedMs??F.totalStreamMs,streaming:!0,bodyContentMode:"full"}:F),fe.current===null&&(fe.current=setTimeout(ce,HE))},[ce]),Re=l.useCallback(F=>{const W=atob(F.chunkBase64),X=Uint8Array.from(W,re=>re.charCodeAt(0)),ne=U.current.get(F.logId)??new TextDecoder("utf-8");U.current.set(F.logId,ne);const ie=`${ee.current.get(F.logId)??""}${ne.decode(X,{stream:!F.terminal})}`;ee.current.set(F.logId,ie),Z.current.set(F.logId,{responseBytes:F.responseBytes,responseStatus:F.responseStatus,elapsedMs:F.elapsedMs}),F.terminal&&U.current.delete(F.logId),s(re=>{const ke=z.current.get(F.logId);if(ke===void 0)return re;const De=re[ke];if(De===void 0)return re;const Wn=[...re];return Wn[ke]={...De,responseText:ie,responseTextBytes:F.responseBytes,responseStatus:F.responseStatus??De.responseStatus,elapsedMs:F.elapsedMs??De.elapsedMs,totalStreamMs:F.elapsedMs??De.totalStreamMs,streaming:!0,bodyContentMode:"full"},Wn})},[]),$e=l.useCallback(()=>{I.current&&I.current.close(),R.current!==null&&(clearTimeout(R.current),R.current=null),h(W=>kt(W,{type:"connect-requested"}));const F=zE(e);if(F===null){h(W=>kt(W,{type:"recoverable-error",message:"The browser runtime does not provide a valid log stream endpoint."})),he("Failed to resolve the live stream endpoint");return}I.current=F,F.onmessage=W=>{try{const X=String(W.data),ne=JSON.parse(X),Ee=$E.safeParse(ne);if(!Ee.success){h(re=>kt(re,{type:"recoverable-error",message:"The live stream returned invalid data."})),he("Failed to parse SSE data");return}const ie=Ee.data;switch(ie.type){case"init":{fe.current!==null&&(clearTimeout(fe.current),fe.current=null),H.current=[],s(re=>{const ke=Ja(re,z.current,ie.logs,je());return z.current=ke.index,ke.logs}),d(re=>An(re,Bo(ie.logs))),k.current!==null&&(clearTimeout(k.current),k.current=null),h(re=>kt(re,{type:"message-received",at:Date.now()})),p();break}case"update":{d(re=>ie.log.sessionId===null||ie.log.sessionId===""?re:An(re,[ie.log.sessionId])),Pe(ie.log),k.current!==null&&(clearTimeout(k.current),k.current=null),h(re=>kt(re,{type:"message-received",at:Date.now()}));break}case"progress":{Re(ie),h(re=>kt(re,{type:"message-received",at:Date.now()}));break}}}catch{h(X=>kt(X,{type:"recoverable-error",message:"The live stream returned malformed JSON."})),he("Failed to parse SSE data")}},F.onerror=()=>{const W=navigator.onLine;h(X=>kt(X,{type:"connection-lost",online:W,message:"The live stream disconnected."})),F.close(),!(!W||!M.current)&&(k.current===null&&(k.current=setTimeout(()=>{k.current=null,h(X=>kt(X,{type:"stale-timeout"}))},YE)),R.current=setTimeout($e,KE))}},[Re,p,e,Pe,he]),lt=l.useCallback(()=>{M.current=!0,R.current!==null&&(clearTimeout(R.current),R.current=null),$e()},[$e]),He=l.useCallback(()=>{M.current=!1,I.current?.close(),I.current=null,R.current!==null&&(clearTimeout(R.current),R.current=null),k.current!==null&&(clearTimeout(k.current),k.current=null),h(F=>kt(F,{type:"stop-retrying"}))},[]),Le=l.useCallback(F=>{if(e===void 0)return;const W=$.current+1;$.current=W,w(!0),j(null),L("Loading session logs",W),p(),qs(e,F).then(X=>{if($.current!==W)return;const ne=X.logs;z.current=Pn(ne),s(ne),b(X),r(e),w(!1),j(null),oe(),p()}).catch(X=>{if($.current!==W)return;w(!1),oe();const ne=X instanceof Error?X.message:"Failed to load session logs";j(ne),he(ne)})},[p,e,he,L,oe]),We=l.useCallback(F=>{const W=$.current+1;$.current=W,w(!0),j(null),L("Reloading full session",W),p(),(async()=>{const X=[];let ne=await qs(F,{kind:"oldest"},Sr);X.push(...ne.logs),J("Reloading full session",W,X.length,1);let Ee=1;for(;ne.hasNewer&&ne.newestLogId!==null&&Ee<Lh;)ne=await qs(F,{kind:"newer",afterLogId:ne.newestLogId},Sr),X.push(...ne.logs),Ee+=1,J("Reloading full session",W,X.length,Ee);$.current===W&&(s(ie=>{const re=Ja(ie,z.current,X,je());return z.current=re.index,re.logs}),d(ie=>An(ie,[F])),w(!1),j(null),oe(),ne.hasNewer?u({message:`Loaded ${String(X.length)} logs for this session. More history is available.`,tone:"success"}):p())})().catch(X=>{if($.current!==W)return;w(!1),oe();const ne=X instanceof Error?X.message:"Failed to reload session logs";j(ne),he(ne)})},[p,he,u,L,oe,J]);l.useEffect(()=>{if(e===void 0){E([]);return}let F=!1;return Be("/api/groups",Nu,GE).then(W=>W.groups).then(W=>{F||W===null||E(UE(W,e))}).catch(()=>{F||E([])}),()=>{F=!0}},[e]),l.useEffect(()=>{le()},[le]),l.useEffect(()=>()=>{oe()},[oe]),l.useEffect(()=>{e!==void 0&&Le({kind:"newest"})},[e,Le]),l.useEffect(()=>{e===void 0&&o!=="__all__"&&We(o)},[e,We,o]),l.useEffect(()=>{$e();const F=()=>{I.current?.close(),I.current=null,R.current!==null&&(clearTimeout(R.current),R.current=null),k.current!==null&&(clearTimeout(k.current),k.current=null),h(X=>kt(X,{type:"browser-offline"}))},W=()=>{M.current&&$e()};return window.addEventListener("offline",F),window.addEventListener("online",W),()=>{window.removeEventListener("offline",F),window.removeEventListener("online",W),I.current&&(I.current.close(),I.current=null),R.current!==null&&(clearTimeout(R.current),R.current=null),k.current!==null&&(clearTimeout(k.current),k.current=null),fe.current!==null&&(clearTimeout(fe.current),fe.current=null)}},[$e,e]),l.useEffect(()=>{const F=window.location.hash;if(!F.startsWith("#log-")||O.current===F)return;const W=F.slice(1),X=Number(W.replace(/^log-/,""));Number.isInteger(X)&&X>0&&Ss({logId:X,tab:"request"});let ne=!1,Ee=0,ie=null,re=null;const ke=()=>{if(ne)return;const De=document.getElementById(W);if(De!==null){O.current=F,De.scrollIntoView({block:"center",behavior:xh(gh())}),De instanceof HTMLElement&&(ie=De,De.setAttribute("data-deep-link-highlight","true"),re=window.setTimeout(()=>{De.removeAttribute("data-deep-link-highlight")},WE),De.focus({preventScroll:!0}),De.getAttribute("data-nav-action")==="expand"&&De.click());return}Ee+=1,Ee<VE&&window.setTimeout(ke,100)};return ke(),()=>{ne=!0,re!==null&&window.clearTimeout(re),ie!==null&&ie.removeAttribute("data-deep-link-highlight")}},[Se.length]);const Ke=l.useCallback(()=>{const F=Bo(t);oe(),w(!1),z.current.clear(),s([]),b(null),d(W=>An(W,F)),u({message:"Cleared the current view. Stored logs are still reloadable.",tone:"success"})},[t,u,oe]),Ze=l.useCallback(F=>{if(F.length===0)return;const W=new Set(F);s(X=>{const ne=X.filter(ie=>W.has(ie.id)),Ee=X.filter(ie=>!W.has(ie.id));return d(ie=>An(ie,Bo(ne))),z.current=Pn(Ee),Ee}),u({message:"Cleared this group from the current view.",tone:"success"})},[u]),rt=l.useCallback(async()=>{const F=$.current+1;$.current=F,w(!0),oe(),p();try{if(o==="__all__"){L("Deleting stored history",F);const re=await tt("/api/logs",tu,{method:"DELETE"}),ke=await QE();if($.current!==F)return;s([]),z.current.clear(),b(null),d([]),E([]),w(!1),oe();const De=ke.ok?` Cleared ${ke.deleted.toString()} group${ke.deleted===1?"":"s"}.`:" Group cleanup failed; open Groups to retry Clear.";u({message:`Deleted ${re.cleared.toString()} stored log${re.cleared===1?"":"s"} across all sessions.${De}`,tone:ke.ok?"success":"error"});return}const W=o;L("Deleting session history",F);const X=await ZE(W,(re,ke)=>{J("Deleting session history",F,re,ke)}),ne=new Set(X.ids);for(const re of t)re.sessionId===W&&ne.add(re.id);const Ee=[...ne].filter(re=>Number.isInteger(re)&&re>=0);if(Ee.length===0){if($.current!==F)return;s(re=>{const ke=re.filter(De=>De.sessionId!==W);return z.current=Pn(ke),ke}),b(re=>re===null?null:{...re,logs:re.logs.filter(ke=>ke.sessionId!==W)}),d(re=>re.filter(ke=>ke!==W)),w(!1),oe(),u({message:"No stored log records were found for this session.",tone:"success"});return}const ie=await tt("/api/logs",tu,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({ids:Ee})});if($.current!==F)return;s(re=>{const ke=re.filter(De=>De.sessionId!==W);return z.current=Pn(ke),ke}),b(re=>re===null?null:{...re,logs:re.logs.filter(ke=>ke.sessionId!==W)}),d(re=>re.filter(ke=>ke!==W)),w(!1),oe(),u({message:`Deleted ${ie.cleared.toString()} stored log${ie.cleared===1?"":"s"} for this session${X.truncated?". More history may remain.":"."}`,tone:X.truncated?"error":"success"})}finally{$.current===F&&(w(!1),oe())}},[t,p,o,u,L,oe,J]),nt=l.useCallback(()=>{if(e!==void 0){Le({kind:"newest"});return}if(o==="__all__"){le();return}We(o)},[e,Le,le,We,o]),q=l.useCallback(async F=>{const W=new FormData;W.set("file",F);const X=await tt("/api/logs/import",Xx,{method:"POST",body:W});return s(ne=>{const Ee=new Set(X.logs.map(re=>re.id)),ie=OE(ne.filter(re=>!Ee.has(re.id)),X.logs);return z.current=Pn(ie),ie}),r(X.sessionId),i("__all__"),b(null),p(),X},[p]),{strip:se,captureMode:xe,slowResponseThresholdSeconds:pe,timeDisplayFormat:we}=Ki(),Oe=xe,ze=l.useCallback(()=>{Le({kind:"oldest"})},[Le]),D=l.useCallback(()=>{Le({kind:"newest"})},[Le]),Y=l.useCallback(()=>{const F=t[0],W=g?.oldestLogId??F?.id??null;W!==null&&Le({kind:"older",beforeLogId:W})},[t,Le,g]),de=l.useCallback(()=>{const F=t[t.length-1],W=g?.newestLogId??F?.id??null;W!==null&&Le({kind:"newer",afterLogId:W})},[t,Le,g]),Ne=l.useMemo(()=>{if(e!==void 0)return{isLoading:y,loadProgress:S,total:g?.total??null,pageSize:g?.limit??Hl,hasOlder:g?.hasOlder??!1,hasNewer:g?.hasNewer??!1,oldestLogId:g?.oldestLogId??null,newestLogId:g?.newestLogId??null,onOldest:ze,onOlder:Y,onNewer:de,onNewest:D}},[e,D,de,Y,ze,g,S,y]);return n.jsxs(n.Fragment,{children:[n.jsx(Yf,{notice:m,onDismiss:p}),n.jsx(eb,{}),n.jsx(PE,{logs:Se,sessions:Te,models:ge,selectedSession:o,selectedModel:a,onSessionChange:r,onModelChange:i,onClearAll:Ke,onDeleteCurrentView:rt,onReloadSession:e!==void 0||o!=="__all__"?nt:void 0,onClearGroup:Ze,onNotify:u,onImportLogs:e===void 0?q:void 0,isLoading:e===void 0&&f.status==="connecting"&&f.lastSuccessAt===null||y,liveConnection:e===void 0?f:void 0,onRetryLiveConnection:lt,onStopLiveConnection:He,pagination:Ne,sessionLoadProgress:S,sessionLoadError:v??void 0,sessionMemberships:C,viewMode:Oe,captureMode:xe,strip:se,slowResponseThresholdSeconds:pe,timeDisplayFormat:we,hideSessionFilter:e!==void 0,pinnedSessionId:e})]})}export{gn as $,Q_ as A,_e as B,og as C,qt as D,nR as E,Xe as F,be as G,uN as H,Og as I,tR as J,_u as K,RS as L,Pu as M,mN as N,pN as O,sR as P,qn as Q,g1 as R,oT as S,Ef as T,wi as U,pr as V,f_ as W,so as X,G0 as Y,Vs as Z,G as _,M5 as a,Ue as a0,iu as a1,jS as a2,P0 as a3,tc as b,B as c,Lu as d,gt as e,Fe as f,vf as g,It as h,Ht as i,Yt as j,Jt as k,Du as l,Rf as m,Zt as n,ct as o,Vg as p,Ts as q,mr as r,dt as s,ut as t,ol as u,mt as v,Ss as w,Hs as x,BT as y,eT as z};
|
|
60
|
+
args = ["stdio", "--url", "${s}"]`}],[s]),a=l.useCallback((i,c)=>{yt(c).then(d=>{d&&(t(i),setTimeout(()=>t(null),1600))})},[]);return n.jsxs("div",{className:"min-w-0 space-y-4",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(qn,{className:"size-4 text-muted-foreground"}),n.jsx("h3",{className:"text-sm font-semibold",children:"MCP access"})]}),n.jsxs("div",{className:"grid gap-2 rounded-md bg-muted/15 px-3 py-2 text-xs text-muted-foreground",children:[n.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."}),n.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?n.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."}):n.jsx("div",{className:"grid gap-2",children:r.map(i=>n.jsx(ql,{id:i.id,label:i.label,value:i.value,copiedId:e,onCopy:a},i.id))})]})}function T4(){const{strip:e,slowResponseThresholdSeconds:t,providerTestTimeoutSeconds:s,timeDisplayFormat:o,isLoading:r,setStrip:a,setSlowResponseThresholdSeconds:i,setProviderTestTimeoutSeconds:c,setTimeDisplayFormat:d}=Ki(),[m,u]=l.useState(null),[p,f]=l.useState(!1),h=l.useCallback(async w=>{u(null),f(!0);try{await a(w)}catch(b){u(b instanceof Error?b.message:String(b))}finally{f(!1)}},[a]),g=l.useCallback(async w=>{u(null),f(!0);try{await i(w)}catch(b){u(b instanceof Error?b.message:String(b))}finally{f(!1)}},[i]),v=l.useCallback(async w=>{u(null),f(!0);try{await c(w)}catch(b){u(b instanceof Error?b.message:String(b))}finally{f(!1)}},[c]),y=l.useCallback(async w=>{u(null),f(!0);try{await d(w)}catch(b){u(b instanceof Error?b.message:String(b))}finally{f(!1)}},[d]);return n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsx("h3",{className:"text-sm font-semibold",children:"Claude Code billing header"}),n.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 ",n.jsx("code",{children:"config.json"}),"."]})]}),n.jsxs("label",{className:"flex items-center gap-3",children:[n.jsx("input",{type:"checkbox",role:"switch",checked:e,disabled:r||p,onChange:w=>{h(w.currentTarget.checked)},className:"size-4 cursor-pointer disabled:cursor-not-allowed disabled:opacity-50"}),n.jsx("span",{className:"text-sm",children:r?"Loading...":e?"Stripping enabled":"Stripping disabled"})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsx("label",{htmlFor:"slow-response-threshold",className:"text-sm font-semibold",children:"Slow response threshold"}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:["Show a slow marker when elapsed time exceeds this many seconds. Use ",n.jsx("code",{children:"0"})," to disable it."]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("input",{id:"slow-response-threshold",type:"number",min:0,max:Xa,step:1,value:t,disabled:r||p,onChange:w=>{const b=Number(w.currentTarget.value);Number.isInteger(b)&&(b<0||b>Xa||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"}),n.jsx("span",{className:"text-xs text-muted-foreground",children:"seconds"})]})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsx("label",{htmlFor:"provider-test-timeout",className:"text-sm font-semibold",children:"Provider test timeout"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Abort slow Provider Test probes after this many seconds per model."}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("input",{id:"provider-test-timeout",type:"number",min:1,max:Za,step:1,value:s,disabled:r||p,onChange:w=>{const b=Number(w.currentTarget.value);Number.isInteger(b)&&(b<1||b>Za||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"}),n.jsx("span",{className:"text-xs text-muted-foreground",children:"seconds / model"})]})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsx("label",{htmlFor:"time-display-format",className:"text-sm font-semibold",children:"Time display"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Controls timestamps in session summaries, headers, and log rows."}),n.jsxs("select",{id:"time-display-format",value:o,disabled:r||p,onChange:w=>{const b=Cu.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:[n.jsx("option",{value:"time",children:"Time only"}),n.jsx("option",{value:"full",children:"Full ISO"})]})]}),m!==null&&n.jsxs("p",{className:"text-xs text-destructive",children:["Failed to save: ",m]})]})}const E4=me(["installed","update-available","available","planned","unknown"]),R4=_({id:x(),name:x(),npmName:x(),capability:x(),description:x(),workflow:x(),installCommand:x(),state:E4,installedVersion:x().nullable(),latestVersion:x().nullable(),primary:Ce()}),M4=_({id:x(),name:x(),validatedVersion:x(),binary:x(),modelFlag:x(),variantFlag:x().nullable(),tools:V(x()),logDir:x(),skillsDir:x(),agentsDir:x()}),A4=_({id:x(),title:x(),stage:x(),packageId:x(),description:x(),command:x(),requiresSession:Ce(),runnable:Ce()}),I4=_({checkedAt:x(),packages:V(R4),runnerPresets:V(M4),recipes:V(A4)}),lh=me(["install","upgrade","help","runner-presets","recipe"]),ch="RUN_LOCAL_COMMAND",P4=_({action:lh,targetId:x(),targetName:x(),command:x(),source:x(),timeoutMs:T().int().positive(),scope:x()}),L4=_({nonce:x().uuid(),phrase:ae(ch),expiresAt:x().datetime(),plan:P4}),dh=_({confirmation:L4});Cn("intent",[_({intent:ae("prepare")}),_({intent:ae("confirm"),nonce:x().uuid(),confirmation:ae(ch)})]);const O4=me(["queued","running","succeeded","failed"]),uh=_({id:x(),packageId:x(),npmName:x(),recipeId:x().nullable().default(null),action:lh,status:O4,command:x(),output:x(),createdAt:x(),startedAt:x().nullable(),finishedAt:x().nullable(),exitCode:T().nullable(),error:x().nullable()}),mh=_({task:uh}),D4=_({tasks:V(uh)}),z4=[{id:"observe",title:"Observe",label:"Live",description:"Capture IDE, process, session, turn, request, response, tools, and providers.",metric:"Inspector core",icon:l0},{id:"replay",title:"Replay",label:"Ready",description:"Promote real logs into repeatable replay evidence without losing the raw context.",metric:"Session asset",icon:Rt},{id:"evaluate",title:"Evaluate",label:"Next",description:"Use eval-harness to turn sessions into regression cases and provider bakeoffs.",metric:"Eval loop",icon:Yi},{id:"connect",title:"Connect",label:"MCP",description:"Expose Inspector state to coding agents as queryable context and durable evidence.",metric:"/api/mcp",icon:e1}];async function $4(e){return tt(e,I4,void 0,t=>`Failed to load ecosystem packages: ${String(t.status)}`)}async function F4(e){return tt(e,mh,void 0,t=>`Failed to load ecosystem task: ${String(t.status)}`)}async function B4(e){return tt(e,D4,void 0,t=>`Failed to load ecosystem tasks: ${String(t.status)}`)}async function U4(e,t){const s=`/api/ecosystem/packages/${encodeURIComponent(e)}/${t}`,o=await tt(s,dh,{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 q4(e){const t=`/api/ecosystem/recipes/${encodeURIComponent(e)}/run`,s=await tt(t,dh,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({intent:"prepare"})},o=>`Failed to prepare ecosystem recipe: ${String(o.status)}`);return{endpoint:t,confirmation:s.confirmation}}async function H4(e){return(await tt(e.endpoint,mh,{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 V4(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 W4(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 G4(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 Bs(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 K4(e){switch(e.status){case"queued":return"Queued";case"running":return`${Bs(e.action)} running`;case"succeeded":return`${Bs(e.action)} complete`;case"failed":return`${Bs(e.action)} failed`}}function ph(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 Y4(e){switch(e.state){case"available":return"install";case"update-available":return"upgrade";case"installed":case"planned":case"unknown":return null}}function J4({pkg:e,activeTask:t,onStartTask:s}){const o=Y4(e),r=t!==null&&t.packageId===e.id&&t.status==="running";return n.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[n.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[n.jsx(o1,{className:"size-4 shrink-0 text-white/55"}),n.jsx("div",{className:"text-sm font-semibold leading-snug",children:e.name})]}),n.jsx("div",{className:"mt-1 break-all font-mono text-[11px] leading-snug text-white/35",children:e.npmName})]}),n.jsx(_e,{className:P("shrink-0",W4(e.state)),variant:"outline",children:V4(e.state)})]}),n.jsx("div",{className:"mt-3 text-xs leading-5 text-muted-foreground",children:e.description}),n.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2 text-[11px]",children:[n.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 font-mono text-white/50",children:G4(e)}),n.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 text-white/45",children:e.capability}),n.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 font-mono text-white/35",children:e.installCommand})]}),n.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[o!==null&&n.jsxs(te,{type:"button",size:"sm",variant:"secondary",disabled:r,onClick:()=>s(e.id,o),children:[r?n.jsx(Ue,{className:"size-3.5 animate-spin"}):n.jsx(to,{className:"size-3.5"}),Bs(o)]}),n.jsxs(te,{type:"button",size:"sm",variant:"outline",disabled:r||e.state==="planned",onClick:()=>s(e.id,"help"),children:[n.jsx(qn,{className:"size-3.5"}),"Help"]}),e.id==="eval-harness"&&n.jsxs(te,{type:"button",size:"sm",variant:"ghost",disabled:r||e.state==="planned",onClick:()=>s(e.id,"runner-presets"),children:[n.jsx(Yi,{className:"size-3.5"}),"Presets"]})]})]})}function X4({task:e}){if(e===null)return null;const t=e.status==="queued"||e.status==="running";return n.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:[n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t?n.jsx(Ue,{className:"size-4 animate-spin text-cyan-200/75"}):n.jsx(qn,{className:"size-4 text-white/55"}),n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:"text-sm font-semibold",children:K4(e)}),n.jsx("div",{className:"break-all font-mono text-[11px] text-white/35",children:e.command})]})]}),n.jsx(_e,{variant:"outline",className:P("shrink-0",ph(e.status)),children:e.status})]}),n.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&&n.jsx("div",{className:"mt-2 text-xs text-red-100",children:e.error})]})}function Z4({workflow:e}){const t=e.icon;return n.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[n.jsxs("div",{className:"flex items-start justify-between gap-3",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(t,{className:"size-4 shrink-0 text-cyan-200/75"}),n.jsx("div",{className:"text-sm font-semibold",children:e.title})]}),n.jsx("span",{className:"rounded bg-white/[0.04] px-2 py-0.5 font-mono text-[10px] text-white/45",children:e.label})]}),n.jsx("div",{className:"mt-2 min-h-10 text-xs leading-5 text-muted-foreground",children:e.description}),n.jsx("div",{className:"mt-3 font-mono text-[11px] text-white/35",children:e.metric})]})}function Q4(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 e_({preset:e}){return n.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[n.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[n.jsx(Ou,{className:"size-4 shrink-0 text-cyan-200/75"}),n.jsx("div",{className:"text-sm font-semibold leading-snug",children:e.name})]}),n.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}`:""]})]}),n.jsxs(_e,{variant:"outline",className:"border-white/10 bg-white/[0.04] text-white/55",children:["v",e.validatedVersion]})]}),n.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-[11px]",children:[n.jsxs("div",{className:"rounded bg-black/15 px-2 py-1 text-white/45",children:["logs/",e.logDir]}),n.jsx("div",{className:"rounded bg-black/15 px-2 py-1 text-white/45",children:e.tools.join(", ")}),n.jsx("div",{className:"rounded bg-black/15 px-2 py-1 font-mono text-white/35",children:e.skillsDir}),n.jsx("div",{className:"rounded bg-black/15 px-2 py-1 font-mono text-white/35",children:e.agentsDir})]})]})}function t_({recipe:e,copied:t,running:s,onCopy:o,onRun:r}){return n.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[n.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[n.jsx(Mu,{className:"size-4 shrink-0 text-cyan-200/75"}),n.jsx("div",{className:"text-sm font-semibold leading-snug",children:e.title})]}),n.jsx("div",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:e.description})]}),n.jsx(_e,{variant:"outline",className:"border-white/10 bg-white/[0.04] text-white/55",children:e.runnable?e.stage:"Template"})]}),n.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}),n.jsxs("div",{className:"mt-3 flex items-center justify-between gap-2",children:[n.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 font-mono text-[11px] text-white/35",children:e.packageId}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs(te,{type:"button",size:"sm",variant:"outline",onClick:()=>o(e),children:[t?n.jsx($e,{className:"size-3.5"}):n.jsx(jt,{className:"size-3.5"}),t?"Copied":"Copy"]}),e.runnable&&n.jsxs(te,{type:"button",size:"sm",variant:"secondary",disabled:s,onClick:()=>r(e),children:[s?n.jsx(Ue,{className:"size-3.5 animate-spin"}):n.jsx(Ou,{className:"size-3.5"}),s?"Running":"Run"]})]})]})]})}function n_({task:e,selected:t,onSelect:s}){const o=e.recipeId??Bs(e.action);return n.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:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(Iu,{className:"size-3.5 shrink-0 text-white/40"}),n.jsx("div",{className:"truncate text-xs font-semibold text-white/75",children:o}),n.jsx(_e,{variant:"outline",className:P("shrink-0",ph(e.status)),children:e.status})]}),n.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-2 font-mono text-[10px] text-white/35",children:[n.jsx("span",{children:e.packageId}),n.jsx("span",{children:new Date(e.createdAt).toLocaleTimeString()}),e.exitCode!==null&&n.jsxs("span",{children:["exit ",String(e.exitCode)]})]})]}),n.jsx(te,{type:"button",size:"sm",variant:t?"secondary":"outline",onClick:()=>s(e),children:t?"Open":"View"})]})}function s_({pending:e,busy:t,onOpenChange:s,onConfirm:o}){const r=e?.confirmation.plan??null;return n.jsx(qt,{open:e!==null,onOpenChange:s,children:n.jsxs(Ht,{className:"max-w-xl",children:[n.jsxs(Yt,{children:[n.jsx(Jt,{children:"Confirm local command"}),n.jsx(lo,{children:"Review the exact allowlisted action Agent Inspector will run on this machine."})]}),r!==null&&n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[n.jsxs("div",{className:"rounded-md border bg-muted/30 p-3",children:[n.jsx("div",{className:"text-muted-foreground",children:"Source"}),n.jsx("div",{className:"mt-1 break-words font-medium",children:r.source})]}),n.jsxs("div",{className:"rounded-md border bg-muted/30 p-3",children:[n.jsx("div",{className:"text-muted-foreground",children:"Timeout"}),n.jsxs("div",{className:"mt-1 font-medium",children:[String(r.timeoutMs/1e3)," seconds"]})]}),n.jsxs("div",{className:"rounded-md border bg-muted/30 p-3 sm:col-span-2",children:[n.jsx("div",{className:"text-muted-foreground",children:"Affected scope"}),n.jsx("div",{className:"mt-1 font-medium",children:r.scope})]})]}),n.jsxs("div",{children:[n.jsx("div",{className:"mb-1 text-xs font-medium",children:"Resolved command"}),n.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})]}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:["Confirmation phrase: ",n.jsx("code",{children:e?.confirmation.phrase}),". The one-time confirmation expires at"," ",new Date(e?.confirmation.expiresAt??"").toLocaleTimeString(),"."]})]}),n.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[n.jsx(te,{type:"button",variant:"outline",disabled:t,onClick:()=>s(!1),children:"Cancel"}),n.jsxs(te,{type:"button",variant:"secondary",disabled:t||r===null,onClick:o,children:[t?n.jsx(Ue,{className:"size-3.5 animate-spin"}):n.jsx(qn,{className:"size-3.5"}),t?"Starting":"Confirm & Run"]})]})]})})}function o_({currentSessionId:e,logCount:t,labelledTrigger:s=!1}){const[o,r]=l.useState(!1),[a,i]=l.useState(!1),[c,d]=l.useState(!1),[m,u]=l.useState(null),[p,f]=l.useState(null),[h,g]=l.useState(null),[v,y]=l.useState(null),[w,b]=l.useState(!1),j=$t("/api/ecosystem/packages",$4,{revalidateOnFocus:!1,revalidateIfStale:!1}),S=$t(p===null?null:`/api/ecosystem/tasks/${p}`,F4,{refreshInterval:U=>{const Z=U?.task;return Z!==void 0&&(Z.status==="queued"||Z.status==="running")?900:0},revalidateOnFocus:!1}),N=$t(o?"/api/ecosystem/tasks":null,B4,{refreshInterval:2500,revalidateOnFocus:!1}),C=j.data?.packages??[],E=j.data?.runnerPresets??[],A=j.data?.recipes??[],I=(N.data?.tasks??[]).slice(0,6),R=l.useMemo(()=>C.filter(U=>U.state==="installed"||U.state==="update-available").length,[C]),k=Q4(e),M="npx @tonyclaw/eval-harness runner-presets",O=()=>{yt(k).then(()=>{i(!0),window.setTimeout(()=>i(!1),1200)})},$=()=>{yt(M).then(()=>{d(!0),window.setTimeout(()=>d(!1),1200)})},K=U=>{yt(U.command).then(()=>{u(U.id),window.setTimeout(()=>u(null),1200)})},Q=U=>{g(null),q4(U.id).then(Z=>{y(Z)}).catch(Z=>{g(Z instanceof Error?Z.message:"Failed to prepare ecosystem recipe")})},z=S.data?.task??null;l.useEffect(()=>{z!==null&&(N.mutate(),z.status==="succeeded"&&j.mutate())},[z,j,N]);const H=(U,Z)=>{g(null),U4(U,Z).then(fe=>{y(fe)}).catch(fe=>{g(fe instanceof Error?fe.message:"Failed to prepare ecosystem task")})},ee=()=>{v!==null&&(g(null),b(!0),H4(v).then(U=>{f(U.id),y(null),S.mutate({task:U},{revalidate:!0}),N.mutate()}).catch(U=>{g(U instanceof Error?U.message:"Failed to start ecosystem task")}).finally(()=>{b(!1)}))};return n.jsxs(qt,{open:o,onOpenChange:r,children:[n.jsx(io,{asChild:!0,children:n.jsxs(te,{variant:"ghost",size:s?"default":"icon",className:P(uo,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:[n.jsx(Mu,{className:"size-4"}),n.jsx("span",{className:s?"":"sr-only",children:"Lab"})]})}),n.jsxs(Ht,{className:"flex max-h-[84vh] max-w-5xl flex-col overflow-hidden",children:[n.jsx(Yt,{children:n.jsxs(Jt,{className:"flex items-center gap-2",children:[n.jsx(ei,{className:"size-4 text-cyan-200/80"}),"TonyClaw Lab"]})}),n.jsxs("div",{className:"overflow-y-auto pr-2",children:[n.jsxs("div",{className:"grid gap-3 lg:grid-cols-[1.1fr_0.9fr]",children:[n.jsxs("section",{className:"rounded-lg bg-white/[0.025] p-4 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[n.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[n.jsxs("div",{children:[n.jsx("div",{className:"text-sm font-semibold",children:"Session asset pipeline"}),n.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."})]}),n.jsxs(_e,{variant:"outline",className:"border-cyan-300/20 bg-cyan-300/8 text-cyan-100",children:[String(R),"/",String(C.length)," packages"]})]}),n.jsx("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:z4.map(U=>n.jsx(Z4,{workflow:U},U.id))})]}),n.jsxs("section",{className:"rounded-lg bg-white/[0.025] p-4 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[n.jsxs("div",{className:"flex items-start justify-between gap-3",children:[n.jsxs("div",{children:[n.jsx("div",{className:"text-sm font-semibold",children:"Current session"}),n.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:e===null?"MCP smoke command":e})]}),n.jsxs(_e,{variant:"outline",className:"border-white/10 bg-white/[0.04] text-white/55",children:[String(t)," logs"]})]}),n.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}),n.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[n.jsxs(te,{size:"sm",variant:"secondary",onClick:O,children:[a?n.jsx($e,{className:"size-3.5"}):n.jsx(jt,{className:"size-3.5"}),a?"Copied":"Copy"]}),n.jsxs(te,{size:"sm",variant:"outline",onClick:$,children:[n.jsx(Yi,{className:"size-3.5"}),c?"Presets copied":"Runner Presets"]})]})]})]}),n.jsxs("section",{className:"mt-3",children:[n.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[n.jsx("div",{className:"text-sm font-semibold",children:"Lab recipes"}),n.jsxs("div",{className:"hidden items-center gap-1 font-mono text-[11px] text-muted-foreground sm:flex",children:[n.jsx(ei,{className:"size-3.5"}),"copy-ready workflows"]})]}),n.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[A.map(U=>n.jsx(t_,{recipe:U,copied:m===U.id,running:z!==null&&z.recipeId===U.id&&(z.status==="queued"||z.status==="running"),onCopy:K,onRun:Q},U.id)),j.isLoading&&A.length===0&&[0,1].map(U=>n.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)]"},U))]})]}),n.jsxs("section",{className:"mt-3",children:[n.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[n.jsx("div",{className:"text-sm font-semibold",children:"Runner presets"}),n.jsxs("div",{className:"hidden items-center gap-1 font-mono text-[11px] text-muted-foreground sm:flex",children:[n.jsx(qn,{className:"size-3.5"}),M]})]}),n.jsxs("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:[E.map(U=>n.jsx(e_,{preset:U},U.id)),j.isLoading&&E.length===0&&[0,1,2,3].map(U=>n.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)]"},U))]})]}),n.jsxs("section",{className:"mt-3",children:[n.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[n.jsx("div",{className:"text-sm font-semibold",children:"TonyClaw packages"}),j.isLoading&&n.jsx("div",{className:"font-mono text-[11px] text-muted-foreground",children:"checking npm..."})]}),j.error!==void 0&&n.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."}),n.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[C.map(U=>n.jsx(J4,{pkg:U,activeTask:z,onStartTask:H},U.id)),j.isLoading&&C.length===0&&[0,1,2].map(U=>n.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)]"},U))]})]}),h!==null&&n.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}),I.length>0&&n.jsxs("section",{className:"mt-3",children:[n.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[n.jsx("div",{className:"text-sm font-semibold",children:"Recent Lab runs"}),n.jsxs("div",{className:"hidden font-mono text-[11px] text-muted-foreground sm:block",children:["last ",String(I.length)]})]}),n.jsx("div",{className:"grid gap-2 md:grid-cols-2",children:I.map(U=>n.jsx(n_,{task:U,selected:p===U.id,onSelect:Z=>{f(Z.id),S.mutate({task:Z},{revalidate:!0})}},U.id))})]}),n.jsx(X4,{task:z})]})]}),n.jsx(s_,{pending:v,busy:w,onOpenChange:U=>{!U&&!w&&y(null)},onConfirm:ee})]})}function r_(e){return[...new Set(e.evidence.map(t=>t.logId).filter(t=>t!==null))]}const a_=[{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?"}],i_=4e3,Ua=12;function jd(){return{messages:[],question:"",error:null}}function l_(e){return e.filter(t=>t.content.trim().length>0).slice(-10).map(t=>({role:t.role,content:t.content.trim().slice(0,i_)}))}function at(e,...t){for(const s of t){const o=G(e,s);if(typeof o=="string"&&o.trim().length>0)return o}return null}function fn(e,...t){for(const s of t){const o=G(e,s);if(typeof o=="number"&&Number.isFinite(o))return o}return null}function c_(e,t){const s=G(e,t);return Array.isArray(s)?s.filter(o=>typeof o=="string").slice(0,8):[]}function d_(e){const t=at(e,"source")??"log",s=at(e,"id")??"",o=fn(e,"logId","id");if(s===""&&o===null||o!==null&&(!Number.isInteger(o)||o<0))return null;const r=fn(e,"inputTokens"),a=fn(e,"outputTokens"),i=fn(e,"totalTokens","tokenCount"),c=fn(e,"responseStatus","status"),d=at(e,"responseStatus","status");return{source:t,id:s!==""?s:String(o),logId:o,sessionId:at(e,"sessionId"),timestamp:at(e,"timestamp"),model:at(e,"model"),providerName:at(e,"providerName","provider"),path:at(e,"path"),status:c??d,elapsedMs:fn(e,"elapsedMs","latencyMs"),inputTokens:r,outputTokens:a,totalTokens:i??(r===null&&a===null?null:(r??0)+(a??0)),score:fn(e,"score","relevanceScore"),matchedFields:c_(e,"matchedFields"),excerpt:at(e,"excerpt","snippet")??"No excerpt available."}}function qa(e){const t=e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim();return t.length===0?"Metric":`${t[0]?.toUpperCase()??""}${t.slice(1)}`}function Sd(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 t=e.filter(s=>typeof s=="string"||typeof s=="number"&&Number.isFinite(s)).slice(0,6);return t.length>0?t.join(", "):null}return null}function Nd(e){return Object.getOwnPropertyNames(e).map(t=>[t,G(e,t)])}function Cd(e){if(e===null||typeof e!="object"||Array.isArray(e))return[];const t=[];for(const[s,o]of Nd(e)){const r=Sd(o);if(r!==null){if(t.push({key:s,label:qa(s),value:r}),t.length>=Ua)break;continue}if(!(o===null||typeof o!="object"||Array.isArray(o))){for(const[a,i]of Nd(o)){const c=Sd(i);if(c===null)continue;const d=`${s}.${a}`;if(t.push({key:d,label:`${qa(s)} ${qa(a).toLowerCase()}`,value:c}),t.length>=Ua)break}if(t.length>=Ua)break}}return t}function u_(e){const t=at(e,"answer"),s=at(e,"providerId"),o=at(e,"providerName"),r=at(e,"model"),a=at(e,"protocol"),i=fn(e,"logCount");if(t===null||s===null||o===null||r===null||a===null||i===null)return null;const c=G(e,"evidence"),d=Array.isArray(c)?c.map(d_).filter(m=>m!==null).slice(0,12):[];return{answer:t,providerId:s,providerName:o,model:r,protocol:a,logCount:i,evidence:d,summaryMetrics:Cd(G(e,"summary")),queryMetrics:Cd(G(e,"queryStats"))}}const m_=l.lazy(()=>Wt(()=>import("./index-Dt0cOy7U.js"),__vite__mapDeps([10,1,2]),import.meta.url)),p_="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]",Ha=96*1024;function f_({text:e}){const[t,s]=l.useState(!1),o=e.length>Ha,r=o&&!t?e.slice(0,Ha):e;return l.useEffect(()=>{s(!1)},[e]),n.jsxs("div",{className:"space-y-2",children:[o&&!t&&n.jsxs("div",{className:"rounded-md border border-cyan-300/20 bg-cyan-300/[0.06] px-3 py-2 text-xs text-muted-foreground",children:["Showing the first ",Ha.toLocaleString()," characters for fast rendering. The full response is preserved."]}),n.jsx("div",{className:p_,children:n.jsx(l.Suspense,{fallback:n.jsx("span",{className:"text-xs text-muted-foreground",children:"Loading Markdown..."}),children:n.jsx(m_,{children:r})})}),o&&n.jsx("button",{type:"button",className:"rounded-md border border-border bg-background px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",onClick:()=>s(a=>!a),children:t?"Collapse fast preview":`Render full response (${e.length.toLocaleString()} chars)`})]})}const kd="What looks abnormal, slow, or likely to hang?";function h_(e){return e.openaiResponsesBaseUrl!==void 0||e.openaiBaseUrl!==void 0||e.anthropicBaseUrl!==void 0}function x_(e){return e.openaiResponsesBaseUrl!==void 0&&e.openaiResponsesBaseUrl!==""?"Responses":e.openaiBaseUrl!==void 0&&e.openaiBaseUrl!==""?"Chat":"Anthropic"}function g_(e){return e.toSorted((t,s)=>{const o=t.source==="company"?0:1,r=s.source==="company"?0:1;return o!==r?o-r:t.name.localeCompare(s.name)})}function _d(e){return`${e}-${String(Date.now())}-${String(Math.random()).slice(2)}`}function In({label:e,value:t,tone:s="muted"}){return n.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 font-mono text-[10px]",children:[n.jsx("span",{className:s==="cyan"?"text-cyan-100":"text-muted-foreground",children:e}),t!==void 0&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"text-muted-foreground/55",children:":"}),n.jsx("span",{className:"truncate text-muted-foreground",children:t})]})]})}function b_({metrics:e}){return e.length===0?null:n.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:e.slice(0,8).map(t=>n.jsxs("div",{className:"rounded-sm bg-black/25 px-2 py-1 shadow-[inset_2px_0_0_rgba(103,232,249,0.22)]",children:[n.jsx("div",{className:"truncate font-mono text-[9px] text-muted-foreground",children:t.label}),n.jsx("div",{className:"truncate font-mono text-[11px] text-cyan-50/95",children:t.value})]},t.key))})}function v_({evidence:e}){const t=()=>{e.logId!==null&&Ss({logId:e.logId,tab:"anatomy"})},s=e.logId===null?`${e.source}:${e.id}`:`${e.source}:log #${String(e.logId)}`;return n.jsxs("button",{type:"button",onClick:t,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:[n.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[n.jsx("span",{className:"truncate font-mono text-[10px] text-cyan-100",children:s}),e.score!==null&&n.jsx("span",{className:"shrink-0 font-mono text-[9px] text-muted-foreground",children:e.score.toFixed(1)})]}),n.jsxs("div",{className:"mt-1 flex flex-wrap gap-x-2 gap-y-1 text-[10px] text-muted-foreground",children:[e.providerName!==null&&n.jsx("span",{children:e.providerName}),e.model!==null&&n.jsx("span",{children:e.model}),e.status!==null&&n.jsxs("span",{children:["status ",String(e.status)]}),e.elapsedMs!==null&&n.jsxs("span",{children:[String(e.elapsedMs)," ms"]})]}),n.jsx("p",{className:"mt-1 line-clamp-3 text-[11px] leading-4 text-foreground/85",children:e.excerpt})]})}function y_({response:e}){return n.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:[n.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:[n.jsx(In,{label:"assistant@inspector",value:"output",tone:"cyan"}),n.jsxs("span",{className:"shrink-0 font-mono text-[9px] text-muted-foreground",children:[String(e.logCount)," logs"]})]}),n.jsxs("div",{className:"space-y-3 p-3",children:[n.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:n.jsx(f_,{text:e.answer})}),n.jsxs("div",{className:"grid gap-1.5 rounded-sm bg-black/20 px-2 py-1.5",children:[n.jsx(In,{label:"provider",value:e.providerName}),n.jsx(In,{label:"model",value:e.model}),n.jsx(In,{label:"protocol",value:e.protocol})]}),(e.summaryMetrics.length>0||e.queryMetrics.length>0)&&n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(In,{label:"metrics",tone:"cyan"}),n.jsx(b_,{metrics:[...e.summaryMetrics,...e.queryMetrics]})]}),e.evidence.length>0&&n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(In,{label:"evidence",value:"click to inspect source log",tone:"cyan"}),e.evidence.slice(0,6).map(t=>n.jsx(v_,{evidence:t},`${t.source}-${t.id}`))]})]})]})}function w_({message:e}){return e.role==="assistant"&&e.response!==null?n.jsx(y_,{response:e.response}):n.jsxs("div",{className:"overflow-hidden rounded-md bg-black/25 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[n.jsx("div",{className:"border-b border-white/[0.06] px-3 py-1.5",children:n.jsx(In,{label:"user@inspector",value:"query",tone:"cyan"})}),n.jsxs("div",{className:"px-3 py-2 font-mono text-[11px] leading-5 text-cyan-50",children:[n.jsx("span",{className:"select-none text-cyan-100/60",children:"> "}),e.content]})]})}function j_({currentSessionId:e,logCount:t,onResultChange:s}){const{providers:o}=ol(),r=l.useMemo(()=>g_(o.filter(h_)),[o]),[a,i]=l.useState(()=>({...jd(),question:kd})),[c,d]=l.useState("__auto__"),[m,u]=l.useState("__auto__"),[p,f]=l.useState(!1),g=r.find(C=>C.id===c)?.models??[],v=a.question,y=v.trim()!==""&&r.length>0&&!p;if(r.length===0)return null;const w=C=>{i(E=>({...E,question:C.currentTarget.value}))},b=C=>{d(C),u("__auto__")},j=()=>{i({...jd(),question:kd}),s(null)},S=C=>{i(E=>({...E,question:C,error:null}))},N=()=>{if(!y)return;const C=v.trim(),E=l_(a.messages),A={id:_d("user"),role:"user",content:C,response:null};f(!0),i(R=>({...R,messages:[...R.messages,A],question:"",error:null}));const I={question:C,history:E,...e!==null?{sessionId:e}:{},...c!=="__auto__"?{providerId:c}:{},...m!=="__auto__"?{model:m}:{},logLimit:16};Zh("/api/pi-agent",{method:"POST",headers:{"content-type":"application/json","x-agent-inspector-csrf":"1"},body:JSON.stringify(I)}).then(async R=>{const k=await R.text();if(!R.ok){i($=>({...$,error:`Inspector Assistant failed: HTTP ${String(R.status)} ${k}`}));return}const M=JSON.parse(k),O=u_(M);if(O===null){i($=>({...$,error:"Inspector Assistant returned an unexpected response."}));return}i($=>({...$,messages:[...$.messages,{id:_d("assistant"),role:"assistant",content:O.answer,response:O}]})),s({question:C,logIds:r_(O),reportedLogCount:O.logCount})}).catch(R=>{i(k=>({...k,error:R instanceof Error?R.message:"Inspector Assistant request failed."}))}).finally(()=>{f(!1)})};return n.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:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(C0,{className:"size-4 text-cyan-200"}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"text-xs font-semibold text-foreground",children:"Assistant"}),n.jsx("div",{className:"text-[11px] text-muted-foreground",children:e===null?"All evidence":"Current session"})]}),n.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:n.jsx(Du,{className:"size-3.5"})})]}),a.messages.length===0&&n.jsx("p",{className:"mt-3 text-[11px] leading-5 text-muted-foreground",children:"Ask about failures, latency, tokens, and tools."}),n.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2",children:[n.jsxs(Ys,{value:c,onValueChange:b,children:[n.jsx(Js,{className:"h-8 border-0 bg-black/25 text-xs shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)]",children:n.jsx(hr,{placeholder:"Provider"})}),n.jsxs(Xs,{children:[n.jsx(it,{value:"__auto__",children:"Auto provider"}),r.map(C=>n.jsxs(it,{value:C.id,children:[C.name," / ",x_(C)]},C.id))]})]}),n.jsxs(Ys,{value:m,onValueChange:u,children:[n.jsx(Js,{className:"h-8 border-0 bg-black/25 text-xs shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)]",children:n.jsx(hr,{placeholder:"Model"})}),n.jsxs(Xs,{children:[n.jsx(it,{value:"__auto__",children:"Auto model"}),g.map(C=>n.jsx(it,{value:C,children:C},C))]})]})]}),a.messages.length===0&&n.jsx("div",{className:"mt-3 flex flex-wrap gap-1.5",children:a_.map(C=>n.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:[n.jsx(ei,{className:"size-3"}),n.jsx("span",{children:C.label})]},C.id))}),a.messages.length>0&&n.jsxs("div",{className:"mt-3 max-h-96 space-y-2 overflow-y-auto pr-1",children:[a.messages.map(C=>n.jsx(w_,{message:C},C.id)),p&&n.jsxs("div",{className:"inline-flex items-center gap-2 rounded-md bg-black/25 px-3 py-2 text-xs text-muted-foreground",children:[n.jsx(Ue,{className:"size-3.5 animate-spin"}),n.jsx("span",{children:"Searching Inspector..."})]})]}),n.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..."}),n.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:[p?n.jsx(Ue,{className:"size-3.5 animate-spin"}):n.jsx(C1,{className:"size-3.5"}),n.jsx("span",{children:p?"Searching...":"Ask Assistant"})]}),a.error!==null&&n.jsx("p",{className:"mt-2 break-words text-[11px] leading-5 text-red-200",children:a.error}),t===0&&n.jsx("p",{className:"mt-2 text-[11px] leading-5 text-muted-foreground",children:"No logs in this scope. Setup questions still work."})]})}function S_(e){const t=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||t.set(i.id,{creation:Td(a.cacheCreationInputTokens,i.cacheCreationInputTokens),read:Td(a.cacheReadInputTokens,i.cacheReadInputTokens)})}}return t}function Td(e,t){return t===null||e===null?null:t>e?{direction:"up",delta:t-e}:t<e?{direction:"down",delta:e-t}:null}function fh(e){return e===null?null:new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function os(e,t,s){const o=fh(e.lastSuccessAt),r=e.retryCount>0?` Retry ${e.retryCount.toString()}.`:"",a=s?" Captured logs remain visible.":"",i=o===null?"":` Last update ${o}.`;return`${t}${i}${r}${a}`}function hh(e,t,s){switch(e){case"connecting":return{label:"Connecting",description:os(t,"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:os(t,"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:os(t,"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:os(t,"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:os(t,t.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:os(t,t.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 N_({state:e}){const t=hh(e.status,e,!1),s=fh(e.lastSuccessAt),o=e.retryCount>0?`Retry ${e.retryCount.toString()}`:null;return n.jsxs("span",{role:"status","aria-label":t.description,"data-connection-state":e.status,className:P("inline-flex h-7 max-w-full items-center gap-1.5 rounded-full border px-2.5 text-xs font-medium",t.toneClass),children:[n.jsx("span",{className:P("size-1.5 shrink-0 rounded-full",t.dotClass)}),n.jsx("span",{className:"shrink-0",children:t.label}),o!==null&&n.jsx("span",{className:"hidden truncate text-current/70 sm:inline",children:o}),s!==null&&n.jsxs("span",{className:"hidden truncate font-mono text-[10px] text-current/65 md:inline",children:["Last ",s]})]})}function C_({state:e,hasLogs:t,onRetry:s,onStop:o}){const r=hh(e.status,e,t);return n.jsxs("div",{role:"status","aria-live":"polite","data-connection-state":e.status,className:P("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:[n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[n.jsx("span",{className:P("size-2 shrink-0 rounded-full",r.dotClass)}),n.jsx("span",{className:"shrink-0 font-semibold",children:r.label}),n.jsx("span",{className:"min-w-0 text-current/75",children:r.description})]}),(r.canRetry||r.canStop)&&n.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[r.canRetry&&n.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:[n.jsx(Rt,{className:"size-3"}),"Retry now"]}),r.canStop&&n.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:[n.jsx(G0,{className:"size-3"}),"Stop retrying"]})]})]})}function k_(){const[e,t]=l.useState(!1),[s,o]=l.useState(!1);l.useEffect(()=>{const i=()=>{t(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(()=>{t(document.fullscreenElement!==null)});return}document.exitFullscreen().catch(()=>{t(document.fullscreenElement!==null)})}},[s]),a=e?"Exit fullscreen":"Enter fullscreen";return n.jsxs(te,{type:"button",variant:"ghost",size:"icon",className:uo,"aria-label":a,"aria-pressed":e,title:a,disabled:!s,onClick:r,children:[e?n.jsx(Vg,{className:"size-4"}):n.jsx(Ug,{className:"size-4"}),n.jsx("span",{className:"sr-only",children:a})]})}function __({liveConnection:e,alertsAction:t,settingsAction:s}){return n.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:n.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:[n.jsxs("a",{href:Oi("/"),"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:[n.jsx(au,{className:"size-7 shrink-0 text-amber-500"}),n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"block truncate text-sm font-bold leading-4",children:"Agent Inspector"}),n.jsx("span",{className:"hidden truncate text-[10px] font-medium text-muted-foreground md:block",children:"Local First. Evidence First."})]}),n.jsxs("span",{className:"hidden shrink-0 font-mono text-[10px] text-muted-foreground lg:inline",children:["v",Fu.version]})]}),n.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?n.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:[n.jsx("span",{className:"size-1.5 shrink-0 rounded-full bg-slate-400"}),"Stored session"]}):n.jsx(N_,{state:e})}),n.jsxs("nav",{"aria-label":"Application actions",className:"order-2 flex shrink-0 items-center justify-end gap-1 sm:order-3",children:[n.jsx(k_,{}),t,s]})]})})}function T_(e){return`${Math.max(0,Math.ceil(e/1e3)).toString()}s`}function Ko({progress:e}){const t=Math.min(1,e.elapsedMs/e.timeoutMs),s=Math.max(4,Math.round(t*100)),o=Math.max(0,e.timeoutMs-e.elapsedMs),r=t>=.75,a=[e.loadedLogs>0?`${e.loadedLogs.toString()} logs`:null,e.loadedPages>0?`${e.loadedPages.toString()} page${e.loadedPages===1?"":"s"}`:null,`${T_(o)} before timeout`].filter(c=>c!==null),i=`${e.label}: ${a.join(", ")}`;return n.jsxs("div",{className:"min-w-0 space-y-1 px-1 pb-1",children:[n.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3 font-mono text-[10px] text-muted-foreground",children:[n.jsx("span",{className:"min-w-0 truncate",children:e.label}),n.jsx("span",{className:P("shrink-0 tabular-nums",r&&"text-amber-300"),children:a.join(" / ")})]}),n.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:n.jsx("div",{className:P("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 xh(e){return e?"auto":"smooth"}function gh(){return typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function E_(){return{status:"connecting",lastSuccessAt:null,retryCount:0,errorMessage:null}}function Tt(e,t){switch(t.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:t.at,retryCount:0,errorMessage:null};case"connection-lost":{const s=e.retryCount+1;return t.online?{...e,status:e.lastSuccessAt===null?"error":"reconnecting",retryCount:s,errorMessage:t.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:t.message}}}function R_(e){return e===void 0||e.status==="live"?"empty":e.status}function M_(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 Ed="agent-inspector.hierarchy.collapsedClients",Rd="agent-inspector.hierarchy.collapsedProcesses";function br(e){return e.some(t=>t.responseStatus===null)}function bh(e){return e.filter(t=>t.responseStatus===null).length}function vh(e){for(const t of e){const s=t.userAgent;if(s!=null&&s!=="")return s}return null}function A_(e){for(const t of e){const s=t.clientPid;if(s!=null)return s}return null}function yh(e){for(const t of e){const s=t.clientProjectFolder;if(s!=null&&s!=="")return s}return null}function I_(e){return El({userAgent:vh(e.logs),conversationId:e.conversationId,clientProjectFolder:yh(e.logs)})}function P_(e){if(e===null||e==="")return"Unknown client";const t=e.split(/[ /;]/)[0]??"";return t===""?"Unknown client":t}function L_(e,t){const s=Kr(e);return s!==null?s:P_(t)}function vr(e){return e===null||e===""?"unknown":String(e)}function O_(e,t,s){return e!=="unknown"?e:`unknown:${vr(t)}:${vr(s)}`}function D_(e,t){return`${vr(e)}:${vr(t)}`}function Md(e){return[...e].sort((t,s)=>t.timestamp.localeCompare(s.timestamp))}function Ad(e){let t="";for(const s of e)s.timestamp>t&&(t=s.timestamp);return t}function Id(e){return br(e)?0:e.some(t=>t.error!==null&&t.error!==void 0||t.responseStatus!==null&&t.responseStatus!==void 0&&t.responseStatus>=400)?1:2}function Va(e){return[...e].sort((t,s)=>{const o=Id(t.logs)-Id(s.logs);if(o!==0)return o;const r=Ad(s.logs).localeCompare(Ad(t.logs));return r!==0?r:t.id.localeCompare(s.id)})}function z_(e){const t=new Map;for(const o of e){const r=vh(o.logs),a=yh(o.logs),i=I_(o),c=O_(i,r,a);let d=t.get(c);d===void 0&&(d={id:c,client:i,label:L_(i,r),userAgent:r,processes:new Map,logs:[]},t.set(c,d)),d.logs.push(...o.logs);const m=A_(o.logs),u=`${c}:${D_(m,a)}`;let p=d.processes.get(u);p===void 0&&(p={id:u,clientPid:m,clientProjectFolder:a,sessions:[],logs:[]},d.processes.set(u,p)),p.sessions.push(o),p.logs.push(...o.logs)}const s=[];for(const o of t.values()){const r=Va([...o.processes.values()].map(a=>({id:a.id,clientPid:a.clientPid,clientProjectFolder:a.clientProjectFolder,sessions:Va(a.sessions),logs:Md(a.logs)})));s.push({id:o.id,client:o.client,label:o.label,userAgent:o.userAgent,processes:r,logs:Md(o.logs)})}return Va(s)}function yr(e){return e<=0?"0":Ie(e)}function wh(e){let t=0,s=0;for(const o of e)o.inputTokens!==null&&o.inputTokens!==void 0&&(t+=o.inputTokens),o.outputTokens!==null&&o.outputTokens!==void 0&&(s+=o.outputTokens);return{inputTokens:t,outputTokens:s}}function $_(e){let t=0;for(const s of e)t+=s.sessions.length;return t}function Pd(e){if(typeof window>"u")return null;try{const t=window.localStorage.getItem(e);if(t===null)return null;const s=JSON.parse(t);return Array.isArray(s)?new Set(s.filter(o=>typeof o=="string")):null}catch{return null}}function Ld(e,t){try{window.localStorage.setItem(e,JSON.stringify([...t]))}catch{}}function Od(e,t){let s=!1;const o=new Set(e);for(const r of t)o.delete(r)&&(s=!0);return s?o:e}function F_(e){const t=new Set;for(const s of e)for(let o=1;o<s.processes.length;o++){const r=s.processes[o];r!==void 0&&!br(r.logs)&&t.add(r.id)}return t}function B_(e){if(e===null||e==="")return null;const t=e.replaceAll("\\","/").split("/").filter(r=>r!==""),s=t[t.length-1];if(s===void 0)return e;const o=t[t.length-2];return o===void 0?s:`${o}/${s}`}function wr({label:e,value:t,className:s}){return n.jsxs("span",{className:P("inline-flex h-7 items-center gap-1 rounded-md bg-[var(--inspector-surface-low)] px-2 text-xs text-muted-foreground",s),children:[n.jsx("span",{className:"font-mono text-[10px] uppercase text-muted-foreground/70",children:e}),n.jsx("span",{className:"font-mono tabular-nums text-foreground",children:t})]})}function jh({count:e}){const t=`${e} open turn${e===1?"":"s"}`;return n.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":t,title:t,children:[n.jsx(Ue,{className:"size-3 animate-spin"}),e>1&&n.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 U_({groups:e,...t}){const s=l.useMemo(()=>z_(e),[e]),[o,r]=l.useState(()=>new Set),[a,i]=l.useState(()=>F_(s)),[c,d]=l.useState(!1);l.useEffect(()=>{const p=Pd(Ed),f=Pd(Rd);p!==null&&r(p),f!==null&&i(f),d(!0)},[]),l.useEffect(()=>{c&&(Ld(Ed,o),Ld(Rd,a))},[o,a,c]),l.useEffect(()=>{const p=new Set(s.filter(h=>br(h.logs)).map(h=>h.id)),f=new Set(s.flatMap(h=>h.processes.filter(g=>br(g.logs)).map(g=>g.id)));r(h=>Od(h,p)),i(h=>Od(h,f))},[s]);const m=l.useCallback(p=>{r(f=>{const h=new Set(f);return h.has(p)?h.delete(p):h.add(p),h})},[]),u=l.useCallback(p=>{i(f=>{const h=new Set(f);return h.has(p)?h.delete(p):h.add(p),h})},[]);return n.jsx("div",{className:"space-y-2",children:s.map(p=>n.jsx(q_,{group:p,collapsed:o.has(p.id),collapsedProcessIds:a,onToggleClient:()=>m(p.id),onToggleProcess:u,conversationProps:t},p.id))})}function q_({group:e,collapsed:t,collapsedProcessIds:s,onToggleClient:o,onToggleProcess:r,conversationProps:a}){const i=wh(e.logs),c=$_(e.processes),d=e.logs.length,m=bh(e.logs),u=m>0;return n.jsxs("section",{className:P("relative isolate overflow-hidden rounded-[8px] bg-card/65",u&&"bg-card/80"),"data-ide-group":e.id,children:[n.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":!t,children:[e.client==="unknown"?n.jsx("span",{className:"inline-flex size-9 shrink-0 items-center justify-center rounded-md bg-[var(--inspector-surface-low)] text-muted-foreground",children:n.jsx(Kg,{className:"size-4"})}):n.jsx(Yr,{client:e.client,className:"size-9 rounded-md",decorative:!0}),n.jsxs("span",{className:"min-w-0",children:[n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[n.jsx("span",{className:"truncate text-sm font-semibold text-foreground",title:e.userAgent??e.label,children:e.label}),n.jsx("span",{className:"rounded bg-[var(--inspector-surface-medium)] px-1.5 py-0.5 font-mono text-[9px] uppercase text-muted-foreground",children:Oj(e.client)}),u&&n.jsx(jh,{count:m})]}),n.jsxs("span",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:[n.jsxs("span",{children:[e.processes.length," process",e.processes.length!==1?"es":""]}),n.jsxs("span",{children:[c," session",c!==1?"s":""]}),n.jsxs("span",{children:[d," req"]})]})]}),n.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[t&&n.jsxs("span",{className:"hidden shrink-0 items-center gap-2 md:flex",children:[n.jsx(wr,{label:"IN",value:yr(i.inputTokens)}),n.jsx(wr,{label:"OUT",value:yr(i.outputTokens)})]}),n.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:t?n.jsx(gt,{className:"size-4"}):n.jsx(Xe,{className:"size-4"})})]})]}),!t&&n.jsx("div",{className:"space-y-0.5 px-2 pb-2 pt-0.5",children:e.processes.map(p=>n.jsx(H_,{group:p,collapsed:s.has(p.id),onToggle:()=>r(p.id),conversationProps:a},p.id))})]})}function H_({group:e,collapsed:t,onToggle:s,conversationProps:o}){const r=wh(e.logs),a=B_(e.clientProjectFolder),i=e.sessions.length,c=e.logs.length,d=bh(e.logs),m=d>0,u=e.clientPid!==null&&e.clientPid!==void 0?`PID ${e.clientPid}`:"Process unavailable";return n.jsxs("section",{className:"relative pl-3",children:[n.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":!t,children:[n.jsx("span",{className:"inline-flex size-8 shrink-0 items-center justify-center text-[var(--inspector-status-watch)]",children:n.jsx(ig,{className:"size-4"})}),n.jsxs("span",{className:"min-w-0",children:[n.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[n.jsx("span",{className:"font-mono text-xs font-semibold tabular-nums text-foreground",children:u}),m&&n.jsx(jh,{count:d}),a!==null&&n.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1 text-[11px] text-muted-foreground",title:e.clientProjectFolder??a,children:[n.jsx(Eg,{className:"size-3 shrink-0"}),n.jsx("span",{className:"truncate font-mono",children:a})]})]}),n.jsxs("span",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:[n.jsxs("span",{children:[i," session",i!==1?"s":""]}),n.jsxs("span",{children:[c," req"]})]})]}),n.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[t&&n.jsxs("span",{className:"hidden shrink-0 items-center gap-2 md:flex",children:[n.jsx(wr,{label:"IN",value:yr(r.inputTokens)}),n.jsx(wr,{label:"OUT",value:yr(r.outputTokens)})]}),n.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:t?n.jsx(gt,{className:"size-4"}):n.jsx(Xe,{className:"size-4"})})]})]}),!t&&n.jsx("div",{className:"space-y-1 pb-1 pl-3 pr-1 pt-1",children:e.sessions.map(p=>n.jsx(FC,{group:p,...o,showClientIdentity:!1,showLogClientMetadata:!1,showProcessMetadata:!1},p.id))})]})}const V_="w-[calc(100%-1rem)] border-warning/30 bg-popover text-popover-foreground sm:max-w-lg",W_=[{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 G_({onCancel:e,onExportRedacted:t,onConfirmRaw:s}){return n.jsxs(n.Fragment,{children:[n.jsxs(Yt,{children:[n.jsx(Jt,{children:"Export unredacted logs?"}),n.jsx(lo,{children:"Raw exports bypass Agent Inspector redaction and may expose sensitive captured data."})]}),n.jsxs("div",{role:"alert",className:"rounded-md border border-warning/35 bg-warning/10 px-3 py-3 text-sm text-foreground",children:[n.jsx("p",{className:"font-medium",children:"The raw archive may include:"}),n.jsx("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-xs leading-relaxed text-muted-foreground",children:W_.map(o=>n.jsxs("li",{children:[n.jsxs("span",{className:"font-semibold text-foreground",children:[o.label,":"]})," ",o.detail]},o.label))}),n.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."})]}),n.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[n.jsx(te,{type:"button",variant:"outline",size:"sm",onClick:e,children:"Cancel"}),n.jsx(te,{type:"button",variant:"outline",size:"sm",onClick:t,children:"Export redacted instead"}),n.jsx(te,{type:"button",variant:"destructive",size:"sm",onClick:s,children:"Export raw data"})]})]})}const jr="data-nav-id",K_="data-nav-action";function Dd(e){return Array.from(e.querySelectorAll(`[${jr}]`))}function zd(e){return e instanceof HTMLElement}function Y_(e,t){let s=e;for(;s!==null&&s!==t;){if(s.hasAttribute(jr))return s;s=s.parentElement}return e.hasAttribute(jr)?e:null}function Wa(e){const t=e.getAttribute(K_);return t==="toggle"||t==="expand"||t==="collapse"?t:null}function Os(e){e.focus({preventScroll:!0}),e.scrollIntoView({block:"nearest",behavior:"smooth"})}function Ds(e,t){return e[t]??null}function Sh(e){const t=e.tagName;return!!(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable)}function $d(e){const t=e.tagName;return t==="BUTTON"||t==="A"||Sh(e)?!0:e.closest("[role='button'],[role='menuitem'],[role='option']")!==null}function J_(e){return e.closest("[role='dialog'],[role='menu'],[role='listbox']")!==null?!0:document.querySelector("[role='dialog'],[role='menu'],[role='listbox']")!==null}function X_(){const e=window.getSelection();return e===null?!1:e.type==="Range"&&e.toString().length>0}function Oo(e,t){return e.key===t&&e.shiftKey}function Z_(e,t,s={}){const o=t??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(!zd(m)||m!==d)return;const u=Dd(c),p=Ds(u,0);p!==null&&Os(p)},[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(!zd(m)||Sh(m)||X_())return;const u=d.contains(m);if(u&&$d(m)&&!m.hasAttribute(jr)||!u&&(!r||$d(m)||J_(m)))return;const p=Dd(d);if(p.length===0)return;const f=Y_(m,d),h=f!==null?p.indexOf(f):-1;let g=!1;switch(c.key){case"ArrowUp":case"W":{if(c.shiftKey&&c.key==="ArrowUp"||c.key==="W"&&!Oo(c,"W"))break;c.preventDefault();const v=h>0?h-1:h===-1?p.length-1:-1;if(v!==-1){const y=Ds(p,v);y!==null&&Os(y)}g=!0;break}case"ArrowDown":case"S":{if(c.shiftKey&&c.key==="ArrowDown"||c.key==="S"&&!Oo(c,"S"))break;c.preventDefault();const v=h<p.length-1?h+1:h===-1?0:-1;if(v!==-1){const y=Ds(p,v);y!==null&&Os(y)}g=!0;break}case"ArrowLeft":case"A":{if(c.shiftKey&&c.key==="ArrowLeft"||c.key==="A"&&!Oo(c,"A")||f===null)break;if(c.preventDefault(),Wa(f)==="collapse")f.click();else if(h>0){const y=Ds(p,h-1);y!==null&&Os(y)}g=!0;break}case"ArrowRight":case"D":{if(c.shiftKey&&c.key==="ArrowRight"||c.key==="D"&&!Oo(c,"D")||f===null)break;if(c.preventDefault(),Wa(f)==="expand")f.click();else if(h<p.length-1){const y=Ds(p,h+1);y!==null&&Os(y)}g=!0;break}case" ":{if(f===null)break;c.preventDefault(),Wa(f)!==null&&f.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 Q_={system:"System",user:"User",assistant:"Assistant",tool:"Tool Results",tools:"Tool Definitions"},eT={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"},tT={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"},Ga=12,Do=1,Fd=80,Bd=24;function nT(e){return e.length<=Bd?e:`${e.slice(0,Bd-3)}...`}function sT(e){const t=e.replace(/\s+/g," ").trim();return t.length<=Fd?t:`${t.slice(0,Fd)}...`}function zo(e){return e>=10?`${e.toFixed(0)}%`:e>=1?`${e.toFixed(1)}%`:e>0?"<1%":"0%"}const oT=l.memo(function({segments:t,totalTokens:s,showLabels:o=!0,onActivate:r}){const a=l.useMemo(()=>s>0?s:t.reduce((y,w)=>y+w.size,0),[t,s]),i=t.slice(0,Ga),c=t.slice(Ga),d=c.reduce((y,w)=>y+w.size,0),m=c.length,u=Ga,p=u+m-1,f=m>0,h=r!==void 0,g=l.useMemo(()=>i.reduce((y,w)=>y+w.size,0),[i]),v=l.useMemo(()=>`Request context: ~${Ie(a)} tokens across ${t.length} segment${t.length===1?"":"s"}`,[t.length,a]);return t.length===0||a<=0?n.jsx("div",{role:"img","aria-label":v,className:"h-6"}):n.jsx(Ts,{delayDuration:150,children:n.jsxs("div",{role:"img","aria-label":v,className:"flex flex-col gap-1.5",children:[n.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(Do,b),S=P("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",eT[y.role],h?tT[y.role]:""),N={width:`${j}%`},C=`${y.label}, ${zo(b)}, ~${Ie(y.size)} tokens`;return n.jsxs(dt,{children:[n.jsx(ut,{asChild:!0,children:h?n.jsx("button",{type:"button",role:"button",tabIndex:0,onClick:()=>r(y),onKeyDown:E=>{(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),r(y))},"data-anatomy-path":y.path,"aria-label":C,className:S,style:N}):n.jsx("span",{"aria-label":C,className:S,style:N})}),n.jsxs(mt,{side:"bottom",className:"max-w-sm text-xs p-2 space-y-0.5",children:[n.jsxs("div",{className:"font-semibold",children:[y.label," - ",zo(b)," - ~",Ie(y.size)," ","tokens"]}),n.jsx("div",{className:"text-muted-foreground",children:Q_[y.role]}),n.jsxs("div",{className:"text-muted-foreground",children:[y.characters.toLocaleString()," chars"]}),y.text.length>0&&n.jsx("div",{className:"text-muted-foreground/90 break-words whitespace-pre-wrap",children:sT(y.text)})]})]},`${y.path}-${w}`)}),f&&n.jsxs(dt,{children:[n.jsx(ut,{asChild:!0,children:n.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(Do,d/a*100)}%`},children:["... +",m]})}),n.jsxs(mt,{side:"bottom",className:"text-xs",children:[m," more segment",m===1?"":"s"," (indices"," ",u,"-",p,")"]})]})]}),o&&n.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(Do,b);return n.jsxs("div",{className:"flex flex-col gap-0.5 truncate",style:{width:`${j}%`},title:`${y.label} - ${zo(b)} - ~${Ie(y.size)} tokens`,children:[n.jsx("span",{className:"truncate font-mono text-foreground/80",children:nT(y.label)}),n.jsxs("span",{className:"truncate font-mono text-muted-foreground/70",children:[zo(b)," - ~",Ie(y.size)]})]},`label-${y.path}-${w}`)}),f&&n.jsxs("div",{className:"flex flex-col gap-0.5 truncate text-muted-foreground",style:{width:`${Math.max(Do,d/a*100)}%`},children:[n.jsxs("span",{className:"truncate font-mono text-foreground/60",children:["... +",m]}),n.jsxs("span",{className:"truncate font-mono text-muted-foreground/60",children:["~",Ie(d)]})]})]}),g<a*.1&&n.jsx("div",{className:"h-0"})]})})}),Nh=.75,Ch=.9,Ri=8e3,rT=.35,kh=40,_h=160,aT=5,iT=8,lT=18,cT=6e4,dT=.7,Ud=3e3,uT=.3,qd=160,mT=new Set(["answer","body","content","data","error","message","markdown","output","response","result","stderr","stdout","text","transcript"]),pT=["context_window","contextWindow","context_length","contextLength","max_context_length","maxContextLength","max_input_tokens","maxInputTokens"],fT=["max_tokens","maxTokens","max_completion_tokens","maxCompletionTokens","max_output_tokens","maxOutputTokens"],hT=[{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"]}],xT={system:"System",user:"User messages",assistant:"Assistant messages",tool:"Tool results",tools:"Tool definitions"};function gT(e){if(typeof e=="number")return Number.isFinite(e)&&e>0?Math.floor(e):null;if(typeof e=="string"){const t=Number(e);if(Number.isFinite(t)&&t>0)return Math.floor(t)}return null}function Th(e,t){for(const s of t){const o=gT(G(e,s));if(o!==null)return o}return null}function bT(e){const t=G(e,"model");if(typeof t!="string")return null;const s=t.trim();return s===""?null:s}function vT(e,t){switch(t.mode){case"prefix":return t.patterns.some(s=>e.startsWith(s));case"includes":return t.patterns.some(s=>e.includes(s))}}function yT(e,t,s=[]){const o=Th(t,pT);if(o!==null)return{tokens:o,label:"Request metadata",source:"request"};const r=v3(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 hT)if(vT(a,i))return{tokens:i.tokens,label:`${i.family} local rule`,source:"model-rule"};return{tokens:null,label:"No local rule",source:"unknown"}}function wT(e){return e<0?0:e>1?1:e}function jT(e){return e===null?"unknown":e>=Ch?"danger":e>=Nh?"watch":"ok"}function ST(e,t){return e.filter(s=>s.role===t).reduce((s,o)=>s+o.size,0)}function NT(e,t){return["system","user","assistant","tool","tools"].map(o=>{const r=ST(e,o);return{role:o,label:xT[o],tokens:r,percent:t>0?r/t:0}}).filter(o=>o.tokens>0).sort((o,r)=>r.tokens-o.tokens)}function Mi(e){return e.replace(/\s+/g," ").trim().toLowerCase()}function CT(e){const t=e.replace(/\s+/g," ").trim();return t.length<=qd?t:`${t.slice(0,qd-3)}...`}function kT(e){return{role:e.role,label:e.label,path:e.path,tokens:e.tokens,characters:e.characters}}function _T(e){return{role:e.role,label:e.label,path:e.path,tokens:e.size,characters:e.characters,text:e.text}}function TT(e){const t=e.trim();return t.startsWith("{")||t.startsWith("[")}function ET(e){if(!TT(e))return null;try{return JSON.parse(e)}catch{return null}}function RT(e){return e.toLowerCase().replace(/[^a-z0-9]/g,"")}function MT(e){for(let t=e.length-1;t>=0;t-=1){const s=e[t]??"";if(!(s.startsWith("[")&&s.endsWith("]")))return s}return null}function AT(e){const t=MT(e);return t===null?!1:mT.has(RT(t))}function IT(e){return e.map(t=>t.startsWith("[")?t:`.${t}`).join("").replace(/^\./,"")}function PT(e,t,s){const o=Ml(t);if(o<_h)return null;const r=Rl(t);return r<kh?null:{role:e.role,label:`${e.label} ${IT(s)}`,path:e.path,tokens:r,characters:o,text:t}}function Ai({value:e,segment:t,path:s,depth:o,candidates:r}){if(!(r.length>=iT)&&!(o>aT)){if(typeof e=="string"){if(!AT(s))return;const a=PT(t,e,s);a!==null&&r.push(a);return}if(Array.isArray(e)){e.forEach((a,i)=>Ai({value:a,segment:t,path:[...s,`[${String(i)}]`],depth:o+1,candidates:r}));return}Al(e)&&Object.entries(e).forEach(([a,i])=>Ai({value:i,segment:t,path:[...s,a],depth:o+1,candidates:r}))}}function LT(e){const t=_T(e),s=ET(e.text);if(s===null)return[t];const o=[];Ai({value:s,segment:e,path:[],depth:0,candidates:o});const r=Mi(e.text),a=new Set([r]),i=o.filter(c=>{const d=Mi(c.text);return d===""||a.has(d)?!1:(a.add(d),!0)});return[t,...i]}function OT(e){const t=new Map;for(const o of e){const r=LT(o);for(const a of r){if(a.tokens<kh||a.characters<_h)continue;const i=Mi(a.text);if(i==="")continue;const c=t.get(i);if(c===void 0){t.set(i,{tokens:a.tokens,candidates:[a]});continue}t.set(i,{tokens:c.tokens+a.tokens,candidates:[...c.candidates,a]})}}const s=[];for(const o of t.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:CT(r.text),firstLabel:r.label,segments:o.candidates.map(kT)})}return s.sort((o,r)=>r.repeatedTokens-o.repeatedTokens||r.totalTokens-o.totalTokens)}function DT(e){if(e.length===0)return null;const t=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>=Ri?"danger":"watch",title:"Duplicate context",detail:`${String(s)} repeated blocks across ${String(t)} group${t===1?"":"s"}, ~${String(o)} repeated tokens.`}}function zT(e){return e.reduce((t,s)=>t+s.repeatedTokens,0)}function $T(e,t,s){const o=[],r=e.find(d=>d.role==="tools")??null;r!==null&&(r.tokens>=Ri||r.percent>=rT&&r.tokens>=Ud)&&o.push({kind:"tool-schema",severity:r.tokens>=Ri?"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>=Ud&&a.percent>=uT&&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=t>0?i/t:0;return s>=lT&&(i>=cT||c>=dT)&&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 FT({risk:e,contextWindow:t,diagnostics:s,duplicateGroups:o}){let a=new Set(s.map(d=>d.kind)).size;(e==="watch"||e==="danger")&&(a+=1),t.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:zT(o)}}function BT({segments:e,inputTokens:t,parsed:s,model:o,providers:r=[]}){const a=e.reduce((C,E)=>C+E.size,0),i=o??bT(s),c=t??a,d=Th(s,fT),m=yT(i,s,r),u=d??0,p=m.tokens===null?null:c+u,f=m.tokens===null?null:m.tokens-c,h=m.tokens===null?null:m.tokens-c-u,g=m.tokens===null||p===null?null:wT(p/m.tokens),v=NT(e,a),y=v[0]??null,w=e.filter(C=>C.role!=="tools").length,b=OT(e),j=DT(b),S=$T(v,a,w);j!==null&&S.unshift(j);const N=jT(g);return{model:i,contextWindow:m,estimatedInputTokens:c,outputReserveTokens:d,windowUsedTokens:p,remainingInputTokens:f,remainingAfterReserveTokens:h,usagePercent:g,riskLevel:N,roleUsages:v,largestRole:y,diagnostics:S,duplicateGroups:b,health:FT({risk:N,contextWindow:m,diagnostics:S,duplicateGroups:b})}}const nR={watch:Nh,danger:Ch},Hd=new WeakMap;function UT(e){return e.map(t=>{const s=t.modelMetadata?.map(o=>`${o.model}:${String(o.contextWindow??"")}`).join(",")??"";return`${t.id}:${t.updatedAt}:${t.models.join(",")}:${s}`}).join("|")}function qT(e){if(e===null)return null;try{return JSON.parse(e)}catch{return null}}function HT(e){return{role:e.role,label:e.label,size:e.tokens,characters:e.tokens*4,text:"",path:`role:${e.role}`}}function VT(e,t){const s=qT(e.rawRequestBody);if(s===null)return null;const r=vf(mr(e)).anatomySegments(s);if(r===null)return null;const a=BT({segments:r,inputTokens:e.inputTokens??null,parsed:s,model:e.model,providers:t}),i=a.model??e.model??"Unknown model",c=a.roleUsages.map(HT);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 WT(e,t,s){const o=Hd.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=VT(e,t);return Hd.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 GT(e,t){return e.usagePercent!==null&&t.usagePercent!==null?e.usagePercent>t.usagePercent:e.usagePercent!==null&&t.usagePercent===null?!0:e.usagePercent===null&&t.usagePercent!==null?!1:e.estimatedInputTokens>t.estimatedInputTokens}function Vd(e){switch(e){case"danger":return 4;case"watch":return 3;case"unknown":return 2;case"ok":return 1}}function KT(e,t){const s=Vd(t.latest.riskLevel)-Vd(e.latest.riskLevel);if(s!==0)return s;const o=e.peak.usagePercent??-1,a=(t.peak.usagePercent??-1)-o;return a!==0?a:t.latest.logId-e.latest.logId}function YT(e,t){return e.usagePercent===null||t.usagePercent===null?null:(t.usagePercent-e.usagePercent)*100}function JT(e){for(let t=1;t<e.length;t++){const s=e[t-1],o=e[t];if(!(s===void 0||o===void 0)&&s.id>o.id)return[...e].sort((r,a)=>r.id-a.id)}return e}function XT(e,t=[]){const s=JT(e),o=UT(t),r=new Map;for(const i of s){const c=WT(i,t,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:GT(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:YT(i.first,i.latest)})).sort(KT)}}function Ln(e){return e.length<=30?e:`${e.slice(0,12)}...${e.slice(-12)}`}function ZT(e){const t=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&&t.set(r.id,o+1)}return t}function Wd(e,t){return t.get(e.id)??e.id}function Gd(e){let t=0,s=0;for(const o of e)o.inputTokens!==null&&(t+=o.inputTokens),o.outputTokens!==null&&(s+=o.outputTokens);return{totalIn:t,totalOut:s}}function QT(e){for(const t of e)if(t.userAgent!==null&&t.userAgent!==void 0&&t.userAgent!=="")return t.userAgent;return null}function eE(e,t){const s=e[0],o=e[e.length-1];return s===void 0||o===void 0?null:_r(s.timestamp,o.timestamp,t)}function tE(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 nE(e){switch(e){case"rolling":return n.jsx(Rt,{className:"size-3 text-status-cool"});case"failed":return n.jsx(nr,{className:"size-3 text-status-danger"});case"watch":return n.jsx(zu,{className:"size-3 text-status-watch"});case"clear":return n.jsx($e,{className:"size-3 text-status-success"})}}function sE(e){switch(e){case"rolling":return"cool";case"failed":return"danger";case"watch":return"watch";case"clear":return"neutral"}}function oE(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 rs({label:e,value:t,detail:s,icon:o,tone:r="neutral"}){return n.jsxs("div",{className:"min-w-0 border-t border-border/60 px-4 py-3",children:[n.jsxs("div",{className:"flex items-center gap-1 text-[10px] uppercase text-muted-foreground",children:[o,e]}),n.jsx("div",{className:P("mt-2 font-mono text-sm font-semibold",tE(r)),children:t}),n.jsx("div",{className:"mt-1 font-mono text-[11px] leading-snug text-muted-foreground",children:s})]})}function rE({stats:e}){return e.requests===0?null:n.jsxs("div",{className:"mb-4 overflow-hidden rounded-[8px] border border-border bg-card",children:[n.jsx("div",{className:"px-4 py-3",children:n.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-semibold uppercase text-muted-foreground",children:[n.jsx(J0,{className:"size-3.5 text-slate-300"}),"Flight Recorder"]}),n.jsx("div",{className:"mt-2 min-w-0 font-mono text-sm font-semibold text-foreground",children:e.modelLabel})]}),n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-muted-foreground",children:[n.jsx("span",{className:"min-w-0 font-mono",children:e.providerLabel}),n.jsx("span",{className:"min-w-0 font-mono",children:e.timeRange??"Timeline pending"})]})]})}),n.jsxs("div",{className:"grid grid-cols-2 border-t border-border/60 md:grid-cols-3 2xl:grid-cols-6",children:[n.jsx(rs,{label:"Status",value:e.statusLabel,detail:oE(e),icon:nE(e.status),tone:sE(e.status)}),n.jsx(rs,{label:"Turns",value:String(e.turns),detail:e.finishLabel,icon:n.jsx(kg,{className:"size-3 text-muted-foreground"}),tone:e.finishTone}),n.jsx(rs,{label:"Requests",value:String(e.requests),detail:`${e.failures} failed / ${e.slow} slow`,icon:n.jsx(nr,{className:"size-3 text-muted-foreground"}),tone:e.failures>0?"danger":"neutral"}),n.jsx(rs,{label:"Peak",value:e.slowestLabel,detail:e.slowestDetail,icon:n.jsx(zu,{className:"size-3 text-muted-foreground"}),tone:e.slow>0?"watch":"neutral"}),n.jsx(rs,{label:"Tokens",value:e.tokenLabel,detail:e.heaviestDetail,icon:n.jsx(Zi,{className:"size-3 text-muted-foreground"})}),n.jsx(rs,{label:"Outcome",value:e.outcomeLabel,detail:e.outcomeDetail,tone:e.outcomeTone})]})]})}function Us(e){if(e===null)return"Unknown";const t=e*100;return t>=10?`${t.toFixed(0)}%`:t>=1?`${t.toFixed(1)}%`:t>0?"<1%":"0%"}function aE(e){return e===null?"n/a":Math.abs(e)<.1?"0%":`${e>0?"+":""}${e.toFixed(1)}%`}function Ii(e){return e===null||!Number.isFinite(e)?0:Math.min(Math.max(e*100,0),100)}function iE(e,t){if(t===null)return null;const s=Ii(e),o=Ii(t);return o<=0||Math.abs(o-s)<.5?null:o}function lE(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 cE(e){const t=e.latest.contextWindow.tokens;return t===null?"Context window unknown":`Context window ${ru(t)}`}const dE=["score","decision","final_status","validation_pass_ratio","semantic_memory_score","opencode_exit","actual_model","run_dir","workspace","project_dir","work_dir"];function Eh(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 Ka(e,t){if(e===null)return null;const s=e.metadata[t];return s===void 0?null:Eh(s)}function uE(e){const t=e.toLowerCase();return t.includes("reject")||t.includes("fail")||t.includes("error")?"border-red-400/35 bg-red-500/10 text-red-100":t.includes("partial")||t.includes("pending")||t.includes("slow")?"border-amber-300/35 bg-amber-400/10 text-amber-100":t.includes("pass")||t.includes("complete")||t.includes("accept")?"border-cyan-300/25 bg-cyan-400/10 text-cyan-100":"border-border/70 bg-background/70 text-muted-foreground"}function mE(e){const t=[];for(const s of dE){const o=e.metadata[s];if(o===void 0)continue;const r=Eh(o);r!==null&&t.push({key:s,value:r})}return t}function Kd({memberships:e,defaultOpen:t=!1}){const[s,o]=l.useState(t);if(e.length===0)return null;const r=e[0],a=r?.member??null,i=Ka(a,"score"),c=Ka(a,"decision"),d=Ka(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 n.jsxs("div",{className:"border border-border bg-card shadow-sm mb-3 rounded-[8px] text-xs",children:[n.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:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[n.jsx("span",{className:"font-semibold text-foreground",children:"Case File"}),r!==void 0&&n.jsx("span",{className:"truncate text-muted-foreground",title:r.groupTitle,children:r.groupTitle}),n.jsxs("span",{className:"font-mono text-[10px] uppercase text-muted-foreground",children:[e.length," group",e.length===1?"":"s"]})]}),m.length>0&&n.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=>n.jsx("span",{className:P("rounded border px-1.5 py-0.5 font-mono text-[10px]",uE(u.value)),children:u.label},u.label))})]}),s?n.jsx(Ji,{className:"size-4 shrink-0 text-muted-foreground"}):n.jsx(Xe,{className:"size-4 shrink-0 text-muted-foreground"})]}),s&&n.jsx("div",{className:"space-y-2 border-t border-white/10 px-3 py-2",children:e.map(u=>{const p=u.member,f=mE(p);return n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[n.jsx("span",{className:"truncate font-medium text-foreground",title:u.groupTitle,children:u.groupTitle}),n.jsx("span",{className:"font-mono text-[10px] uppercase text-muted-foreground",children:u.groupStatus}),p.status!==null&&n.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:["member ",p.status]})]}),n.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-muted-foreground",children:[n.jsx("span",{className:"font-mono",title:p.sessionId,children:Ln(p.sessionId)}),p.label!==null&&n.jsx("span",{children:p.label}),p.provider!==null&&n.jsx("span",{children:p.provider}),p.model!==null&&n.jsx("span",{className:"font-mono",children:p.model}),p.runId!==null&&n.jsxs("span",{className:"font-mono",title:p.runId,children:["run ",Ln(p.runId)]})]}),f.length>0&&n.jsx("div",{className:"mt-2 grid gap-1 sm:grid-cols-2 xl:grid-cols-3",children:f.map(h=>n.jsxs("div",{className:"border border-border bg-muted/40 min-w-0 rounded-md px-2 py-1",children:[n.jsx("div",{className:"font-mono text-[10px] text-muted-foreground",children:h.key}),n.jsx("div",{className:"truncate font-mono text-[11px] text-foreground",title:h.value,children:h.value})]},h.key))})]},`${u.groupId}:${p.id}`)})})]})}function $o({label:e,title:t,icon:s,disabled:o,onClick:r}){return n.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:t,children:[s,n.jsx("span",{children:e})]})}function Yd({logs:e,pagination:t,embedded:s=!1}){if(t===void 0)return null;const o=t.isLoading;return n.jsxs("nav",{"aria-label":"Session log pagination",className:P("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:[n.jsxs("div",{className:"w-full min-w-0 px-1 font-mono text-[11px] text-muted-foreground sm:flex-1",children:[n.jsxs("div",{role:"status","aria-live":"polite","aria-atomic":"true",children:[rk({logs:e,pagination:t}),t.isLoading&&e.length>0&&n.jsx("span",{className:"ml-2",children:"Loading..."})]}),t.loadProgress!==void 0&&n.jsx(Ko,{progress:t.loadProgress})]}),n.jsxs("div",{className:"flex w-full items-center gap-1 overflow-x-auto sm:w-auto",children:[n.jsx($o,{label:"Oldest",title:"Load the oldest logs in this session",icon:n.jsx(O0,{className:"size-3.5"}),disabled:o||!t.hasOlder,onClick:t.onOldest}),n.jsx($o,{label:"Older",title:"Load older logs",icon:n.jsx(R0,{className:"size-3.5"}),disabled:o||!t.hasOlder,onClick:t.onOlder}),n.jsx($o,{label:"Newer",title:"Load newer logs",icon:n.jsx(gt,{className:"size-3.5"}),disabled:o||!t.hasNewer,onClick:t.onNewer}),n.jsx($o,{label:"Newest",title:"Load the newest logs in this session",icon:n.jsx(z0,{className:"size-3.5"}),disabled:o||!t.hasNewer,onClick:t.onNewest})]})]})}function pE(e){return`${e} ${e===1?"request":"requests"}`}function Jd(e){return`#${String(e)}`}function Xd(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 fE(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 hE(e){switch(e){case"risk":return"Risk";case"optimizable":return"Optimizable";case"ok":return"OK"}}const xE=10,gE=80;function bE(e){e.setAttribute("data-deep-link-highlight","true"),window.setTimeout(()=>{e.removeAttribute("data-deep-link-highlight")},1800)}function vE(e){const t=document.getElementById(`log-${String(e)}`);return t instanceof HTMLElement?(t.scrollIntoView({block:"center",behavior:xh(gh())}),t.focus({preventScroll:!0}),bE(t),!0):!1}function Rh(e){Ss({logId:e,tab:"anatomy"});let t=0;const s=()=>{Ss({logId:e,tab:"anatomy"}),!vE(e)&&(t+=1,t<xE&&window.setTimeout(s,gE))};window.setTimeout(s,0)}function yE({command:e}){const[t,s]=l.useState(!1),o=l.useCallback(()=>{yt(e).then(r=>{r&&(s(!0),setTimeout(()=>s(!1),2e3))})},[e]);return n.jsxs("div",{"data-command-example":"true",className:BC,children:[n.jsx("pre",{className:UC,children:e}),n.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:t?n.jsx($e,{className:"size-4"}):n.jsx(jt,{className:"size-4"})})]})}function Ya({label:e,children:t,className:s}){return n.jsxs("section",{className:P("rounded-[8px] border border-border/60 bg-card/55",s),children:[n.jsx("div",{className:"px-3 pt-3",children:n.jsx("div",{className:"font-mono text-[10px] font-semibold uppercase tracking-[0.14em] text-text-subtle",children:e})}),n.jsx("div",{className:"p-3 pt-2",children:t})]})}function Fo({label:e,value:t}){return n.jsxs("div",{className:"min-w-0 rounded-md border border-border/50 bg-muted/30 px-2 py-2",children:[n.jsx("div",{className:"truncate font-mono text-lg font-semibold leading-6 text-text-strong",children:t}),n.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] uppercase tracking-[0.12em] text-text-subtle",children:e})]})}function wE(){const{themeMode:e,setThemeMode:t}=jb();return n.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:[n.jsx("button",{type:"button",onClick:()=>t("light"),className:P("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:n.jsx(O1,{className:"size-3.5"})}),n.jsx("button",{type:"button",onClick:()=>t("eye-care"),className:P("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:n.jsx(Ru,{className:"size-3.5"})}),n.jsx("button",{type:"button",onClick:()=>t("dark"),className:P("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:n.jsx(Jg,{className:"size-3.5"})})]})}function jE({visible:e,onToggle:t}){const s=e?"Hide Inspector pet":"Summon Inspector pet";return n.jsx("button",{type:"button",onClick:t,className:P("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:n.jsx(au,{className:P("size-4 transition-opacity",!e&&"opacity-45")})})}function SE({preference:e,resolvedScale:t,onChange:s}){const o=Tb(t),r=e==="auto"?`Auto (${o})`:`${e}%`;return n.jsxs(Ys,{value:e,onValueChange:a=>s(nl(a)),children:[n.jsxs(Js,{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:[n.jsx(a0,{className:"size-3.5"}),n.jsx("span",{className:"font-mono text-[10px] font-semibold tabular-nums",children:o})]}),n.jsxs(Xs,{align:"end",children:[n.jsx(it,{value:"auto",children:"Auto"}),n.jsx(it,{value:"100",children:"100%"}),n.jsx(it,{value:"125",children:"125%"}),n.jsx(it,{value:"150",children:"150%"})]})]})}const Mh="agent-inspector.detailsPanelCollapsed",Ah="agent-inspector.detailsPanelWidth",Ih="agent-inspector.pet.visible",ds=360,NE=288,CE=520;function Ph(e){return Math.min(Math.max(e,NE),CE)}function kE(){if(typeof window>"u")return!0;try{const e=window.localStorage.getItem(Mh);return e===null||e==="1"}catch{return!0}}function _E(){if(typeof window>"u")return ds;try{const e=window.localStorage.getItem(Ah);if(e===null)return ds;const t=Number.parseInt(e,10);return Number.isFinite(t)?Ph(t):ds}catch{return ds}}function TE(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(Ih)!=="0"}catch{return!0}}function Zd({label:e,logId:t}){return n.jsxs("button",{type:"button",onClick:()=>Rh(t),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 ${Jd(t)}`,children:[e," ",Jd(t)]})}function EE({latestPercent:e,peakPercent:t,risk:s,onOpenContext:o}){const r=Ii(e),a=iE(e,t),i=t===null?`Latest context window usage ${Us(e)}`:`Latest context window usage ${Us(e)}, peak ${Us(t)}`;return n.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:n.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:[n.jsx("span",{className:P("block h-full rounded-full transition-[width]",lE(s)),style:{width:`${r}%`}}),a!==null&&n.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 RE({summary:e}){const t=e.trendPercent,s=t===null||Math.abs(t)<.1?null:t>0?x0:d0,o=e.latest.diagnostics[0]??null,r=Us(e.latest.usagePercent),a=Us(e.peak.usagePercent),i=()=>{Rh(e.latest.logId)};return n.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:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.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}),n.jsx("span",{className:P("inline-flex h-5 shrink-0 items-center rounded border px-1.5 font-mono text-[10px]",fE(e.latest.health.level)),children:hE(e.latest.health.level)})]}),n.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:[n.jsx("span",{children:pE(e.requestCount)}),n.jsx("span",{children:cE(e)})]})]}),n.jsxs("div",{className:"min-w-0 space-y-2 text-xs",children:[n.jsx(EE,{latestPercent:e.latest.usagePercent,peakPercent:e.peak.usagePercent,risk:e.latest.riskLevel,onOpenContext:i}),n.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Latest"}),n.jsx("div",{className:P("mt-0.5 font-mono",Xd(e.latest.riskLevel)),children:r}),n.jsx(Zd,{label:"Log",logId:e.latest.logId})]}),n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Peak"}),n.jsx("div",{className:P("mt-0.5 font-mono",Xd(e.peak.riskLevel)),children:a}),n.jsx(Zd,{label:"Log",logId:e.peak.logId})]}),n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Trend"}),n.jsxs("div",{className:"mt-0.5 flex items-center gap-1 font-mono text-foreground",children:[s!==null&&n.jsx(s,{className:P("size-3",t!==null&&t>0?"text-amber-300":"text-cyan-300")}),aE(t)]}),n.jsx("div",{className:"h-5","aria-hidden":"true"})]})]})]}),n.jsxs("div",{className:"min-w-0 space-y-1.5",children:[n.jsx(oT,{segments:e.latest.roleSegments,totalTokens:e.latest.roleTotalTokens,showLabels:!1}),n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-muted-foreground",children:[n.jsxs("span",{className:"font-mono",children:["~",Ie(e.latest.estimatedInputTokens)," input"]}),e.latest.windowUsedTokens!==null&&n.jsxs("span",{className:"font-mono",children:["~",Ie(e.latest.windowUsedTokens)," used"]}),o!==null&&n.jsx("span",{className:"truncate",children:o})]})]})]})}function ME({summary:e}){return e.models.length===0?null:n.jsxs("div",{className:"mt-3 border-t border-white/10 pt-2",children:[n.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2",children:[n.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-normal text-muted-foreground",children:"Session Context"}),n.jsxs("div",{className:"font-mono text-[10px] text-muted-foreground",children:[e.models.length," model",e.models.length===1?"":"s"]})]}),n.jsx("div",{className:"max-h-52 overflow-y-auto pr-1",children:e.models.map(t=>n.jsx(RE,{summary:t},t.model))})]})}function AE(e){const t=e.models.filter(o=>o.latest.health.level==="risk").length;if(t>0)return`${t} 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 IE({label:e,sessionId:t,logs:s,totalIn:o,totalOut:r,timeDisplayFormat:a,contextSummary:i,showBackLink:c}){const[d,m]=l.useState(!1),[u,p]=l.useState(!1),[f,h]=l.useState(!1),g=l.useMemo(()=>eE(s,a),[s,a]),v=l.useMemo(()=>QT(s),[s]),y=l.useMemo(()=>AE(i),[i]),w=l.useCallback(()=>{t!==null&&yt(t).then(j=>{j&&(m(!0),setTimeout(()=>m(!1),2e3))})},[t]),b=l.useCallback(()=>{yt(window.location.href).then(j=>{j&&(p(!0),setTimeout(()=>p(!1),2e3))})},[]);return n.jsxs("div",{className:"border border-border bg-card shadow-sm mb-3 rounded-[8px] px-3 py-2 text-xs",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[c&&n.jsx("a",{href:Oi("/"),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:n.jsx(f0,{className:"size-3.5"})}),n.jsxs("div",{className:"min-w-[180px] flex-1",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.jsx("span",{className:"font-mono font-semibold text-purple-400/90 truncate",title:e,children:Ln(e)}),t!==null&&n.jsx("button",{type:"button",onClick:w,className:"hover:bg-white/[0.065] inline-flex size-6 shrink-0 items-center justify-center rounded text-muted-foreground transition-colors hover:text-foreground","aria-label":d?"Copied session ID":"Copy session ID",title:d?"Copied session ID":"Copy session ID",children:d?n.jsx($e,{className:"size-3"}):n.jsx(jt,{className:"size-3"})}),v!==null&&n.jsx("span",{className:"font-mono text-muted-foreground truncate max-w-[220px]",title:v,children:v})]}),n.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-muted-foreground",children:[n.jsxs("span",{children:[s.length," request",s.length!==1?"s":""]}),g!==null&&n.jsx("span",{children:g}),(o>0||r>0)&&n.jsxs("span",{className:"font-mono",children:[Ie(o)," in / ",Ie(r)," out"]})]})]}),i.models.length>0&&n.jsxs("button",{type:"button",onClick:()=>h(j=>!j),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":f,title:f?"Hide context details":"Show context details",children:[n.jsx("span",{children:y}),f?n.jsx(Ji,{className:"size-3.5"}):n.jsx(Xe,{className:"size-3.5"})]}),n.jsx("button",{type:"button",onClick:b,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":u?"Copied session link":"Copy session link",title:u?"Copied session link":"Copy session link",children:u?n.jsx($e,{className:"size-3.5"}):n.jsx(jt,{className:"size-3.5"})})]}),f&&n.jsx(ME,{summary:i})]})}function PE({logs:e,sessions:t,selectedSession:s,selectedModel:o,onSessionChange:r,onClearAll:a,onDeleteCurrentView:i,onReloadSession:c,onClearGroup:d,onNotify:m,onImportLogs:u,viewMode:p,captureMode:f,strip:h,slowResponseThresholdSeconds:g,timeDisplayFormat:v,isLoading:y=!1,liveConnection:w,onRetryLiveConnection:b,onStopLiveConnection:j,pagination:S,sessionLoadProgress:N,sessionLoadError:C,sessionMemberships:E=[],hideSessionFilter:A=!1,pinnedSessionId:I}){const{totalIn:R,totalOut:k}=l.useMemo(()=>Gd(e),[e]),{providers:M}=ol(),{uiScalePreference:O,resolvedUiScale:$,setUiScalePreference:K}=Ab(),[Q,z]=l.useState(null),[H,ee]=l.useState(null),[U,Z]=l.useState(!1),[fe,je]=l.useState(!1),[he,oe]=l.useState(null),[L,J]=l.useState(null),[Se,Te]=l.useState(!1),[ge,le]=l.useState(!1),[ce,Pe]=l.useState(!0),[Re,Fe]=l.useState(ds),[lt,He]=l.useState(!1),[Le,We]=l.useState(!1),[Ke,Ze]=l.useState(!0),[rt,nt]=l.useState(!1),[q,se]=l.useState(null),[xe,pe]=l.useState(null),we=l.useRef(null),Oe=l.useRef(null),ze=l.useRef(null),D=l.useRef(null),Y=l.useRef(0),de=l.useRef(null);Z_(we,Oe,{pageWide:!0});const[Ne,F]=l.useState(null);l.useEffect(()=>Qi(F),[]);const W=l.useCallback(()=>{Y.current+=1,D.current?.abort(),D.current=null,z(null),ee(null)},[]);l.useEffect(()=>()=>{Y.current+=1,D.current?.abort(),D.current=null},[]),l.useEffect(()=>{Pe(kE()),Fe(_E()),We(!0)},[]),l.useEffect(()=>{Le&&window.localStorage.setItem(Mh,ce?"1":"0")},[ce,Le]),l.useEffect(()=>{if(Le)try{window.localStorage.setItem(Ah,String(Re))}catch{}},[Le,Re]),l.useEffect(()=>{Ze(TE()),nt(!0)},[]),l.useEffect(()=>{if(rt)try{window.localStorage.setItem(Ih,Ke?"1":"0")}catch{}},[rt,Ke]),l.useEffect(()=>{if(I===void 0){document.title="Agent Inspector";return}const ye=e.length===1?"1 req":`${e.length} req`;document.title=`${Ln(I)} - ${ye} - Agent Inspector`},[e.length,I]);const X=l.useCallback(async ye=>{D.current?.abort();const Ge=new AbortController;D.current=Ge;const kt=Y.current+1;Y.current=kt,z(ye),ee(null);try{const Xt=await gb(e,ye,{signal:Ge.signal});if(Y.current!==kt)return;if(!Xt.ok){if(Xt.canceled===!0)return;m!==void 0?m({message:Xt.message,tone:"error"}):ee(Xt.message)}}finally{Y.current===kt&&(D.current=null,z(null))}},[e,m]),ne=l.useCallback(ye=>{if(VC(ye)){Z(!0);return}X(ye)},[X]),Ee=l.useCallback(()=>{Z(!1),X("redacted")},[X]),ie=l.useCallback(()=>{Z(!1),X("raw")},[X]),re=l.useCallback(()=>{ze.current?.click()},[]),ke=l.useCallback(ye=>{const Ge=ye.currentTarget.files?.[0];ye.currentTarget.value="",!(Ge===void 0||u===void 0)&&(je(!0),J(null),oe(null),u(Ge).then(kt=>{const Xt=kt.skipped>0?`, skipped ${String(kt.skipped)}`:"",Xl=`Imported ${String(kt.imported)} logs as ${kt.sessionId}${Xt}.`;m!==void 0?m({message:Xl,tone:"success"}):oe(Xl)}).catch(kt=>{const Xt=kt instanceof Error?kt.message:"Failed to import logs";m!==void 0?m({message:Xt,tone:"error"}):J(Xt)}).finally(()=>{je(!1)}))},[u,m]);l.useEffect(()=>{W(),pe(null),se(null)},[W,s,o]);const De=l.useCallback(()=>{W(),oe(null),J(null),pe(null),a()},[W,a]),Wn=l.useCallback(()=>{Te(!0)},[]),Lt=l.useCallback(()=>{W(),oe(null),J(null),pe(null),i!==void 0&&(le(!0),i().then(()=>{Te(!1)}).catch(ye=>{const Ge=ye instanceof Error?ye.message:"Failed to delete stored logs";m!==void 0?m({message:Ge,tone:"error"}):J(Ge)}).finally(()=>{le(!1)}))},[W,i,m]),rn=l.useCallback(()=>{c!==void 0&&(W(),oe(null),J(null),pe(null),c())},[W,c]),Qr=l.useCallback(()=>{pe(null)},[]),Gn=l.useCallback(()=>{Pe(ye=>!ye)},[]),ea=l.useCallback(ye=>{de.current={startX:ye.clientX,startWidth:Re,pointerId:ye.pointerId},ye.currentTarget.setPointerCapture(ye.pointerId),He(!0)},[Re]),Me=l.useCallback(ye=>{const Ge=de.current;Ge===null||Ge.pointerId!==ye.pointerId||Fe(Ph(Ge.startWidth+Ge.startX-ye.clientX))},[]),vt=l.useCallback(ye=>{const Ge=de.current;Ge===null||Ge.pointerId!==ye.pointerId||(ye.currentTarget.hasPointerCapture(ye.pointerId)&&ye.currentTarget.releasePointerCapture(ye.pointerId),de.current=null,He(!1))},[]),Qe=l.useCallback(()=>{Fe(ds)},[]),Es=l.useCallback(()=>{Ze(ye=>!ye)},[]),st=l.useMemo(()=>q===null?null:new Set(q.logIds),[q]),Ct=l.useMemo(()=>st===null?e:e.filter(ye=>st.has(ye.id)),[st,e]),Ot=l.useMemo(()=>A5(Ct),[Ct]),Vl=l.useMemo(()=>ZT(Ot),[Ot]),an=l.useMemo(()=>ok({pinnedSessionId:I,selectedSession:s,sessions:t,logs:e}),[e,I,s,t]),Kn=an?.logs??[],Rs=an!==null&&Kn.length>0,{totalIn:Wl,totalOut:Gl}=l.useMemo(()=>Gd(Kn),[Kn]),Oh=l.useMemo(()=>XT(Kn,M),[Kn,M]),Dh=l.useMemo(()=>S_(Ot),[Ot]),ta=l.useMemo(()=>XN(Ot),[Ot]),Kl=WC(f,e.length),zh=I!==void 0,$h=e.length>0,Fh=i!==void 0&&(e.length>0||s!=="__all__"),Bh=s==="__all__"?"all sessions":"this session",Uh=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.",qh=e.length===0?"Load":"Reload",na=Rs&&an!==null?Ln(an.label):s==="__all__"?"All sessions":Ln(s),Yl=R_(w),sa=M_(Yl),Hh=l.useMemo(()=>sk({logs:Ct,conversationGroups:Ot,isLoading:y,timeDisplayFormat:v,slowResponseThresholdSeconds:g}),[Ct,Ot,y,g,v]),Vh=l.useCallback(ye=>{const Ge=ta.get(ye.id);Ge!==void 0&&pe([Ge,ye])},[ta]),Jl=I!==void 0?I:s==="__all__"?null:s;return n.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:[n.jsx(__,{liveConnection:w,alertsAction:n.jsx(Pk,{}),settingsAction:n.jsx(y4,{})}),n.jsxs("button",{type:"button",onClick:Gn,className:P("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":ce?"Show details panel":"Hide details panel",title:ce?"Show details panel":"Hide details panel",children:[n.jsx("span",{className:"absolute bottom-2 left-1 top-2 w-px rounded-full bg-border transition-colors group-hover:bg-foreground/35"}),ce?n.jsx(l1,{className:"size-3.5"}):n.jsx(a1,{className:"size-3.5"})]}),rt&&Ke&&n.jsx(Jo,{feature:"Inspector Pet",children:n.jsx(l.Suspense,{fallback:null,children:n.jsx(CS,{logs:e})})}),n.jsxs("div",{className:P("flex w-full min-w-0 flex-col lg:min-h-0 lg:flex-1 lg:flex-row lg:overflow-hidden",lt&&"cursor-col-resize select-none"),children:[!ce&&n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"fixed inset-0 z-30 bg-background/70 backdrop-blur-sm lg:hidden",onClick:Gn,"aria-label":"Close details panel"}),n.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:Re},children:[n.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:ea,onPointerMove:Me,onPointerUp:vt,onPointerCancel:vt,onDoubleClick:Qe,"aria-label":"Resize details panel",title:"Drag to resize; double-click to reset",children:n.jsx("span",{className:"h-12 w-1 rounded-full bg-border transition-colors hover:bg-primary"})}),n.jsxs("div",{className:"flex min-h-full flex-col gap-4 p-4",children:[n.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:[n.jsx(Ya,{label:"View",children:n.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.jsx(wE,{}),n.jsx(SE,{preference:O,resolvedScale:$,onChange:K})]})}),n.jsx(Ya,{label:"Workspace",children:n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx(t3,{labelledTrigger:!0}),n.jsx(o_,{currentSessionId:Jl,logCount:e.length,labelledTrigger:!0})]})})]}),n.jsxs(Ya,{label:"Current scope",children:[n.jsxs("div",{className:"mb-2 rounded-md border border-border/50 bg-muted/25 px-3 py-2",children:[n.jsx("div",{className:"truncate font-mono text-xs font-semibold text-text-link",title:na,children:na}),n.jsx("div",{className:"mt-1 text-[11px] text-muted-foreground",children:zh?"Pinned session":"Live Inspector data"})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[n.jsx(Fo,{label:q===null?"Requests":"Results",value:Ct.length}),n.jsx(Fo,{label:"Sessions",value:t.length}),n.jsx(Fo,{label:"Input",value:Ie(Rs?Wl:R)}),n.jsx(Fo,{label:"Output",value:Ie(Rs?Gl:k)})]}),N!==void 0&&n.jsx("div",{className:"mt-2 rounded-md border border-border/50 bg-muted/25 px-2 py-2",children:n.jsx(Ko,{progress:N})})]}),Rs&&an!==null&&n.jsx(IE,{label:an.label,sessionId:an.sessionId,logs:Kn,totalIn:Wl,totalOut:Gl,timeDisplayFormat:v,contextSummary:Oh,showBackLink:an.showBackLink}),Rs&&I!==void 0&&E.length>0&&n.jsx(Kd,{memberships:E}),n.jsx("div",{className:"flex-1"}),n.jsx(j_,{currentSessionId:Jl,logCount:e.length,onResultChange:se})]})]})]}),n.jsxs("main",{className:"inspector-scrollbar order-2 min-w-0 lg:order-1 lg:h-full lg:flex-1 lg:overflow-y-auto",children:[n.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:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsxs("div",{className:"min-w-[180px] flex-1",children:[n.jsx("div",{className:"text-sm font-semibold text-foreground",children:"Logs"}),n.jsx("div",{className:"mt-0.5 font-mono text-[11px] text-muted-foreground",children:na})]}),n.jsx(jE,{visible:Ke,onToggle:Es}),u!==void 0&&n.jsxs(n.Fragment,{children:[n.jsx("input",{ref:ze,type:"file",accept:".zip,.json,.jsonl,application/zip,application/json",className:"hidden",onChange:ke}),n.jsx("button",{type:"button",onClick:re,disabled:fe,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:fe?n.jsx("span",{children:"Importing..."}):n.jsxs(n.Fragment,{children:[n.jsx($u,{className:"size-3.5"}),n.jsx("span",{children:"Import"})]})})]}),Kl.redacted&&n.jsx("button",{type:"button",onClick:()=>{ne("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"?n.jsx("span",{children:"Exporting..."}):n.jsxs(n.Fragment,{children:[n.jsx(to,{className:"size-3.5"}),n.jsx("span",{children:"Export"})]})}),Kl.raw&&n.jsx("button",{type:"button",onClick:()=>{ne("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"?n.jsx("span",{children:"Exporting..."}):n.jsxs(n.Fragment,{children:[n.jsx(xg,{className:"size-3.5"}),n.jsx("span",{children:"Raw"})]})}),c!==void 0&&n.jsxs("button",{type:"button",onClick:rn,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:[n.jsx(Rt,{className:P("size-3.5",y&&"animate-spin motion-reduce:animate-none")}),n.jsx("span",{children:qh})]}),n.jsxs("button",{type:"button",onClick:De,disabled:!$h,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:[n.jsx(wn,{className:"size-3.5"}),n.jsx("span",{children:"Clear"})]}),i!==void 0&&n.jsxs("button",{type:"button",onClick:Wn,disabled:!Fh||ge,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:[n.jsx(wn,{className:"size-3.5"}),n.jsx("span",{children:"Delete"})]})]}),S===void 0&&N!==void 0&&n.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:n.jsx(Ko,{progress:N})}),C!==void 0&&n.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:[n.jsxs("span",{className:"min-w-0 flex-1",children:["Session logs could not be loaded. ",C," Existing logs remain visible."]}),c!==void 0&&n.jsxs("button",{type:"button",onClick:rn,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:[n.jsx(Rt,{className:"size-3"}),"Retry"]})]}),q!==null&&n.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:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"truncate text-xs font-medium text-cyan-50",children:q.question}),n.jsxs("div",{className:"mt-0.5 text-[10px] text-muted-foreground",children:["Showing ",String(Ct.length)," loaded logs from"," ",String(q.logIds.length)," linked results"]})]}),n.jsxs("button",{type:"button",onClick:()=>se(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:[n.jsx(so,{className:"size-3"}),"All logs"]})]}),q===null&&n.jsx(Yd,{logs:e,pagination:S,embedded:!0}),m===void 0&&H!==null&&n.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&&L!==null&&n.jsx("div",{className:"mt-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:L}),m===void 0&&he!==null&&L===null&&n.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:he}),w!==void 0&&w.status!=="live"&&b!==void 0&&j!==void 0&&n.jsx(C_,{state:w,hasLogs:e.length>0,onRetry:b,onStop:j})]}),n.jsxs("div",{className:"px-4 py-4 lg:px-5",children:[n.jsx(rE,{stats:Hh}),q!==null&&Ct.length===0?n.jsx("div",{className:"py-16 text-center text-muted-foreground",children:n.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:[n.jsx("p",{className:"text-sm font-medium text-foreground",children:"No linked logs are loaded"}),n.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."}),n.jsx("button",{type:"button",onClick:()=>se(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__"?n.jsx("div",{className:"py-16 text-center text-muted-foreground",children:n.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:[n.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"}),n.jsx("p",{className:"inline-block max-w-full rounded bg-muted px-3 py-1 font-mono text-xs break-all",children:Ln(s)}),N!==void 0&&n.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:n.jsx(Ko,{progress:N})}),E.length>0&&n.jsx("div",{className:"text-left",children:n.jsx(Kd,{memberships:E})}),!y&&n.jsxs("div",{className:"flex flex-col items-center gap-3 text-xs",children:[n.jsx("p",{children:"Stored logs may still be available."}),n.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[c!==void 0&&n.jsxs("button",{type:"button",onClick:rn,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:[n.jsx(Rt,{className:"size-3.5"}),n.jsx("span",{children:"Load session"})]}),A?n.jsx("a",{href:Oi("/"),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"}):n.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"})]})]})]})}):n.jsx("div",{className:"py-16 text-center text-muted-foreground",children:n.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:[n.jsx("p",{className:"text-sm font-medium",children:sa.title}),n.jsx("p",{className:"mx-auto max-w-xl text-xs leading-relaxed text-muted-foreground",children:sa.description}),Yl==="empty"&&t.length>0&&n.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."}),sa.showConnectionCommands&&Ne!==null&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"flex flex-col items-center gap-2",children:qC(Ne).map(ye=>n.jsx(yE,{command:ye},ye))}),n.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."})]})]})}):n.jsxs("div",{ref:Oe,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:[n.jsx("div",{ref:we,children:n.jsx(U_,{groups:Ot,viewMode:p,strip:h,slowResponseThresholdSeconds:g,cacheTrends:Dh,onCompareWithPrevious:Vh,comparisonPredecessors:ta,onClearGroup:d,defaultExpanded:Ot.length===1,timeDisplayFormat:v})}),q===null&&n.jsx("div",{className:"mt-3",children:n.jsx(Yd,{logs:e,pagination:S})})]})]})]})]}),n.jsx(qt,{open:U,onOpenChange:Z,children:n.jsx(Ht,{className:V_,children:n.jsx(G_,{onCancel:()=>Z(!1),onExportRedacted:Ee,onConfirmRaw:ie})})}),n.jsx(qt,{open:Se,onOpenChange:Te,children:n.jsxs(Ht,{className:"border-red-500/20 bg-zinc-950 text-zinc-100 sm:max-w-md",children:[n.jsxs(Yt,{children:[n.jsxs(Jt,{children:["Delete ",Bh," history?"]}),n.jsx(lo,{children:"Clear only hides logs from the UI. Delete removes stored history from disk."})]}),n.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:[n.jsx("span",{className:"block font-medium",children:"This is a full history delete."}),n.jsx("span",{className:"mt-1 block text-xs text-red-200/80",children:Uh})]}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(te,{type:"button",variant:"outline",size:"sm",disabled:ge,onClick:()=>Te(!1),children:"Cancel"}),n.jsx(te,{type:"button",variant:"destructive",size:"sm",disabled:ge,onClick:Lt,children:ge?"Deleting...":"Delete history"})]})]})}),xe!==null&&n.jsx(Jo,{feature:"Compare",children:n.jsx(l.Suspense,{fallback:null,children:n.jsx(NS,{left:xe[0],right:xe[1],leftDisplayNumber:Wd(xe[0],Vl),rightDisplayNumber:Wd(xe[1],Vl),onClose:Qr})})})]})}function LE(e,t,s){return t==="__all__"&&s==="__all__"?e:e.filter(o=>!(t!=="__all__"&&o.sessionId!==t||s!=="__all__"&&o.model!==s))}function OE(e,t){if(e.length===0)return[...t];if(t.length===0)return[...e];const s=new Map;for(const o of e)s.set(o.id,o);for(const o of t)s.set(o.id,o);return[...s.values()].toSorted((o,r)=>o.id-r.id)}function Qd(e,t){return t.retainIds?.has(e.id)===!0||t.retainSessionId!==void 0&&e.sessionId===t.retainSessionId}function eu(e,t){const s=e.reduce((a,i)=>a+(Qd(i,t)?0:1),0);if(s<=t.recentLimit)return e;let o=s-t.recentLimit;const r=[];for(const a of e){if(o>0&&!Qd(a,t)){o-=1;continue}r.push(a)}return r}function Pn(e){const t=new Map;for(let s=0;s<e.length;s+=1){const o=e[s];o!==void 0&&t.set(o.id,s)}return t}function Ja(e,t,s,o){if(s.length===0){const m=eu([...e],o);return{logs:m,index:Pn(m)}}const r=[...e];let a=r.length===0?Number.NEGATIVE_INFINITY:r.at(-1)?.id??0,i=!0;for(const m of s){const u=t.get(m.id);if(u!==void 0&&u>=0&&u<r.length){r[u]=m;continue}r.push(m),m.id<a&&(i=!1),a=Math.max(a,m.id)}const c=i?r:r.toSorted((m,u)=>m.id-u.id),d=eu(c,o);return{logs:d,index:Pn(d)}}function An(e,t){const s=new Set;for(const o of e)o!==""&&s.add(o);for(const o of t)o!==""&&s.add(o);return[...s].sort()}function DE(e){const t=new URLSearchParams({compact:"1"});e!==void 0&&t.set("sessionId",e);const s=Qh();return s.ok?ex(s.runtime,`/api/logs/stream?${t.toString()}`):null}function zE(e){const t=DE(e);return t===null?null:new EventSource(t)}const $E=Vt([_({type:ae("init"),logs:V(Hs)}),_({type:ae("update"),log:Hs}),_({type:ae("progress"),logId:T().int().positive(),chunkBase64:x(),responseBytes:T().int().nonnegative(),responseStatus:T().int().nullable(),elapsedMs:T().int().nonnegative().nullable(),terminal:Ce()})]),FE=_({logs:V(Hs),total:T().int().nonnegative(),limit:T().int().positive(),hasOlder:Ce(),hasNewer:Ce(),oldestLogId:T().int().positive().nullable(),newestLogId:T().int().positive().nullable()}),BE=V(x()),tu=_({success:Ce(),cleared:T().int().nonnegative(),logFilesRewritten:T().int().nonnegative().optional(),chunkFilesDeleted:T().int().nonnegative(),sessionArchiveLogsDeleted:T().int().nonnegative().optional()});function UE(e,t){const s=[];for(const o of e)for(const r of o.members)r.sessionId===t&&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 Bo(e){const t=new Set;for(const s of e)s.sessionId!==null&&s.sessionId!==""&&t.add(s.sessionId);return[...t]}function qE(e){const t=new Set;for(const s of e)s.model!==null&&s.model!==""&&t.add(s.model);return[...t]}const HE=100,VE=12,WE=1800,Hl=100,Sr=500,Lh=200,Pi=2e4,GE=1e4,KE=3e3,YE=1e4,JE=2e3;function XE(e,t,s=Hl){const o=new URLSearchParams({cursor:"1",compact:"1",limit:String(s),sessionId:e});switch(t.kind){case"oldest":o.set("anchor","oldest");break;case"older":o.set("beforeLogId",String(t.beforeLogId));break;case"newer":o.set("afterLogId",String(t.afterLogId));break}return`/api/logs?${o.toString()}`}function qs(e,t,s=Hl){return Be(XE(e,t,s),FE,Pi)}async function ZE(e,t){const s=new Set;let o=await qs(e,{kind:"oldest"},Sr);for(const a of o.logs)s.add(a.id);t(s.size,1);let r=1;for(;o.hasNewer&&o.newestLogId!==null&&r<Lh;){o=await qs(e,{kind:"newer",afterLogId:o.newestLogId},Sr);for(const a of o.logs)s.add(a.id);r+=1,t(s.size,r)}return{ids:[...s],truncated:o.hasNewer}}async function QE(){try{return{deleted:(await tt("/api/groups",wu,{method:"DELETE"})).deleted,ok:!0}}catch{return{deleted:0,ok:!1}}}function sR({initialSessionId:e}={}){const[t,s]=l.useState([]),[o,r]=l.useState(e??"__all__"),[a,i]=l.useState("__all__"),[c,d]=l.useState([]),{notice:m,showToast:u,dismissToast:p}=Kf(),[f,h]=l.useState(E_),[g,v]=l.useState(null),[y,w]=l.useState(e!==void 0),[b,j]=l.useState(null),[S,N]=l.useState(void 0),[C,E]=l.useState([]),[,A]=l.useTransition(),I=l.useRef(null),R=l.useRef(null),k=l.useRef(null),M=l.useRef(!0),O=l.useRef(null),$=l.useRef(0),K=l.useRef(null),Q=l.useRef(null),z=l.useRef(new Map),H=l.useRef([]),ee=l.useRef(new Map),U=l.useRef(new Map),Z=l.useRef(new Map),fe=l.useRef(null),je=l.useCallback(()=>({recentLimit:JE,retainSessionId:e??(o==="__all__"?void 0:o)}),[e,o]),he=l.useCallback(F=>{u({message:F,tone:"error"})},[u]),oe=l.useCallback(()=>{Q.current!==null&&(clearInterval(Q.current),Q.current=null),K.current=null,N(void 0)},[]),L=l.useCallback((F,W,X=0,ne=0)=>{Q.current!==null&&clearInterval(Q.current);const Ee=Date.now();K.current=Ee;const ie=()=>{$.current===W&&N({label:F,elapsedMs:Date.now()-Ee,timeoutMs:Pi,loadedLogs:X,loadedPages:ne})};ie(),Q.current=setInterval(ie,250)},[]),J=l.useCallback((F,W,X,ne)=>{const Ee=K.current;Ee===null||$.current!==W||N({label:F,elapsedMs:Date.now()-Ee,timeoutMs:Pi,loadedLogs:X,loadedPages:ne})},[]),Se=l.useMemo(()=>LE(t,o,a),[t,o,a]),Te=l.useMemo(()=>An(c,Bo(t)),[t,c]),ge=l.useMemo(()=>qE(t),[t]),le=l.useCallback(()=>{tt("/api/sessions",BE).then(F=>{d(W=>An(W,F))}).catch(()=>{})},[]),ce=l.useCallback(()=>{fe.current=null;const F=H.current;H.current=[],F.length!==0&&A(()=>{s(W=>{const X=Ja(W,z.current,F,je());return z.current=X.index,X.logs})})},[je,A]),Pe=l.useCallback(F=>{const W=ee.current.get(F.id),X=Z.current.get(F.id);H.current.push(W!==void 0&&F.responseText===null?{...F,responseText:W,responseTextBytes:X?.responseBytes??new TextEncoder().encode(W).byteLength,responseStatus:X?.responseStatus??F.responseStatus,elapsedMs:X?.elapsedMs??F.elapsedMs,totalStreamMs:X?.elapsedMs??F.totalStreamMs,streaming:!0,bodyContentMode:"full"}:F),fe.current===null&&(fe.current=setTimeout(ce,HE))},[ce]),Re=l.useCallback(F=>{const W=atob(F.chunkBase64),X=Uint8Array.from(W,re=>re.charCodeAt(0)),ne=U.current.get(F.logId)??new TextDecoder("utf-8");U.current.set(F.logId,ne);const ie=`${ee.current.get(F.logId)??""}${ne.decode(X,{stream:!F.terminal})}`;ee.current.set(F.logId,ie),Z.current.set(F.logId,{responseBytes:F.responseBytes,responseStatus:F.responseStatus,elapsedMs:F.elapsedMs}),F.terminal&&U.current.delete(F.logId),s(re=>{const ke=z.current.get(F.logId);if(ke===void 0)return re;const De=re[ke];if(De===void 0)return re;const Wn=[...re];return Wn[ke]={...De,responseText:ie,responseTextBytes:F.responseBytes,responseStatus:F.responseStatus??De.responseStatus,elapsedMs:F.elapsedMs??De.elapsedMs,totalStreamMs:F.elapsedMs??De.totalStreamMs,streaming:!0,bodyContentMode:"full"},Wn})},[]),Fe=l.useCallback(()=>{I.current&&I.current.close(),R.current!==null&&(clearTimeout(R.current),R.current=null),h(W=>Tt(W,{type:"connect-requested"}));const F=zE(e);if(F===null){h(W=>Tt(W,{type:"recoverable-error",message:"The browser runtime does not provide a valid log stream endpoint."})),he("Failed to resolve the live stream endpoint");return}I.current=F,F.onmessage=W=>{try{const X=String(W.data),ne=JSON.parse(X),Ee=$E.safeParse(ne);if(!Ee.success){h(re=>Tt(re,{type:"recoverable-error",message:"The live stream returned invalid data."})),he("Failed to parse SSE data");return}const ie=Ee.data;switch(ie.type){case"init":{fe.current!==null&&(clearTimeout(fe.current),fe.current=null),H.current=[],s(re=>{const ke=Ja(re,z.current,ie.logs,je());return z.current=ke.index,ke.logs}),d(re=>An(re,Bo(ie.logs))),k.current!==null&&(clearTimeout(k.current),k.current=null),h(re=>Tt(re,{type:"message-received",at:Date.now()})),p();break}case"update":{d(re=>ie.log.sessionId===null||ie.log.sessionId===""?re:An(re,[ie.log.sessionId])),Pe(ie.log),k.current!==null&&(clearTimeout(k.current),k.current=null),h(re=>Tt(re,{type:"message-received",at:Date.now()}));break}case"progress":{Re(ie),h(re=>Tt(re,{type:"message-received",at:Date.now()}));break}}}catch{h(X=>Tt(X,{type:"recoverable-error",message:"The live stream returned malformed JSON."})),he("Failed to parse SSE data")}},F.onerror=()=>{const W=navigator.onLine;h(X=>Tt(X,{type:"connection-lost",online:W,message:"The live stream disconnected."})),F.close(),!(!W||!M.current)&&(k.current===null&&(k.current=setTimeout(()=>{k.current=null,h(X=>Tt(X,{type:"stale-timeout"}))},YE)),R.current=setTimeout(Fe,KE))}},[Re,p,e,Pe,he]),lt=l.useCallback(()=>{M.current=!0,R.current!==null&&(clearTimeout(R.current),R.current=null),Fe()},[Fe]),He=l.useCallback(()=>{M.current=!1,I.current?.close(),I.current=null,R.current!==null&&(clearTimeout(R.current),R.current=null),k.current!==null&&(clearTimeout(k.current),k.current=null),h(F=>Tt(F,{type:"stop-retrying"}))},[]),Le=l.useCallback(F=>{if(e===void 0)return;const W=$.current+1;$.current=W,w(!0),j(null),L("Loading session logs",W),p(),qs(e,F).then(X=>{if($.current!==W)return;const ne=X.logs;z.current=Pn(ne),s(ne),v(X),r(e),w(!1),j(null),oe(),p()}).catch(X=>{if($.current!==W)return;w(!1),oe();const ne=X instanceof Error?X.message:"Failed to load session logs";j(ne),he(ne)})},[p,e,he,L,oe]),We=l.useCallback(F=>{const W=$.current+1;$.current=W,w(!0),j(null),L("Reloading full session",W),p(),(async()=>{const X=[];let ne=await qs(F,{kind:"oldest"},Sr);X.push(...ne.logs),J("Reloading full session",W,X.length,1);let Ee=1;for(;ne.hasNewer&&ne.newestLogId!==null&&Ee<Lh;)ne=await qs(F,{kind:"newer",afterLogId:ne.newestLogId},Sr),X.push(...ne.logs),Ee+=1,J("Reloading full session",W,X.length,Ee);$.current===W&&(s(ie=>{const re=Ja(ie,z.current,X,je());return z.current=re.index,re.logs}),d(ie=>An(ie,[F])),w(!1),j(null),oe(),ne.hasNewer?u({message:`Loaded ${String(X.length)} logs for this session. More history is available.`,tone:"success"}):p())})().catch(X=>{if($.current!==W)return;w(!1),oe();const ne=X instanceof Error?X.message:"Failed to reload session logs";j(ne),he(ne)})},[p,he,u,L,oe,J]);l.useEffect(()=>{if(e===void 0){E([]);return}let F=!1;return Be("/api/groups",Nu,GE).then(W=>W.groups).then(W=>{F||W===null||E(UE(W,e))}).catch(()=>{F||E([])}),()=>{F=!0}},[e]),l.useEffect(()=>{le()},[le]),l.useEffect(()=>()=>{oe()},[oe]),l.useEffect(()=>{e!==void 0&&Le({kind:"newest"})},[e,Le]),l.useEffect(()=>{e===void 0&&o!=="__all__"&&We(o)},[e,We,o]),l.useEffect(()=>{Fe();const F=()=>{I.current?.close(),I.current=null,R.current!==null&&(clearTimeout(R.current),R.current=null),k.current!==null&&(clearTimeout(k.current),k.current=null),h(X=>Tt(X,{type:"browser-offline"}))},W=()=>{M.current&&Fe()};return window.addEventListener("offline",F),window.addEventListener("online",W),()=>{window.removeEventListener("offline",F),window.removeEventListener("online",W),I.current&&(I.current.close(),I.current=null),R.current!==null&&(clearTimeout(R.current),R.current=null),k.current!==null&&(clearTimeout(k.current),k.current=null),fe.current!==null&&(clearTimeout(fe.current),fe.current=null)}},[Fe,e]),l.useEffect(()=>{const F=window.location.hash;if(!F.startsWith("#log-")||O.current===F)return;const W=F.slice(1),X=Number(W.replace(/^log-/,""));Number.isInteger(X)&&X>0&&Ss({logId:X,tab:"request"});let ne=!1,Ee=0,ie=null,re=null;const ke=()=>{if(ne)return;const De=document.getElementById(W);if(De!==null){O.current=F,De.scrollIntoView({block:"center",behavior:xh(gh())}),De instanceof HTMLElement&&(ie=De,De.setAttribute("data-deep-link-highlight","true"),re=window.setTimeout(()=>{De.removeAttribute("data-deep-link-highlight")},WE),De.focus({preventScroll:!0}),De.getAttribute("data-nav-action")==="expand"&&De.click());return}Ee+=1,Ee<VE&&window.setTimeout(ke,100)};return ke(),()=>{ne=!0,re!==null&&window.clearTimeout(re),ie!==null&&ie.removeAttribute("data-deep-link-highlight")}},[Se.length]);const Ke=l.useCallback(()=>{const F=Bo(t);oe(),w(!1),z.current.clear(),s([]),v(null),d(W=>An(W,F)),u({message:"Cleared the current view. Stored logs are still reloadable.",tone:"success"})},[t,u,oe]),Ze=l.useCallback(F=>{if(F.length===0)return;const W=new Set(F);s(X=>{const ne=X.filter(ie=>W.has(ie.id)),Ee=X.filter(ie=>!W.has(ie.id));return d(ie=>An(ie,Bo(ne))),z.current=Pn(Ee),Ee}),u({message:"Cleared this group from the current view.",tone:"success"})},[u]),rt=l.useCallback(async()=>{const F=$.current+1;$.current=F,w(!0),oe(),p();try{if(o==="__all__"){L("Deleting stored history",F);const re=await tt("/api/logs",tu,{method:"DELETE"}),ke=await QE();if($.current!==F)return;s([]),z.current.clear(),v(null),d([]),E([]),w(!1),oe();const De=ke.ok?` Cleared ${ke.deleted.toString()} group${ke.deleted===1?"":"s"}.`:" Group cleanup failed; open Groups to retry Clear.";u({message:`Deleted ${re.cleared.toString()} stored log${re.cleared===1?"":"s"} across all sessions.${De}`,tone:ke.ok?"success":"error"});return}const W=o;L("Deleting session history",F);const X=await ZE(W,(re,ke)=>{J("Deleting session history",F,re,ke)}),ne=new Set(X.ids);for(const re of t)re.sessionId===W&&ne.add(re.id);const Ee=[...ne].filter(re=>Number.isInteger(re)&&re>=0);if(Ee.length===0){if($.current!==F)return;s(re=>{const ke=re.filter(De=>De.sessionId!==W);return z.current=Pn(ke),ke}),v(re=>re===null?null:{...re,logs:re.logs.filter(ke=>ke.sessionId!==W)}),d(re=>re.filter(ke=>ke!==W)),w(!1),oe(),u({message:"No stored log records were found for this session.",tone:"success"});return}const ie=await tt("/api/logs",tu,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({ids:Ee})});if($.current!==F)return;s(re=>{const ke=re.filter(De=>De.sessionId!==W);return z.current=Pn(ke),ke}),v(re=>re===null?null:{...re,logs:re.logs.filter(ke=>ke.sessionId!==W)}),d(re=>re.filter(ke=>ke!==W)),w(!1),oe(),u({message:`Deleted ${ie.cleared.toString()} stored log${ie.cleared===1?"":"s"} for this session${X.truncated?". More history may remain.":"."}`,tone:X.truncated?"error":"success"})}finally{$.current===F&&(w(!1),oe())}},[t,p,o,u,L,oe,J]),nt=l.useCallback(()=>{if(e!==void 0){Le({kind:"newest"});return}if(o==="__all__"){le();return}We(o)},[e,Le,le,We,o]),q=l.useCallback(async F=>{const W=new FormData;W.set("file",F);const X=await tt("/api/logs/import",Xx,{method:"POST",body:W});return s(ne=>{const Ee=new Set(X.logs.map(re=>re.id)),ie=OE(ne.filter(re=>!Ee.has(re.id)),X.logs);return z.current=Pn(ie),ie}),r(X.sessionId),i("__all__"),v(null),p(),X},[p]),{strip:se,captureMode:xe,slowResponseThresholdSeconds:pe,timeDisplayFormat:we}=Ki(),Oe=xe,ze=l.useCallback(()=>{Le({kind:"oldest"})},[Le]),D=l.useCallback(()=>{Le({kind:"newest"})},[Le]),Y=l.useCallback(()=>{const F=t[0],W=g?.oldestLogId??F?.id??null;W!==null&&Le({kind:"older",beforeLogId:W})},[t,Le,g]),de=l.useCallback(()=>{const F=t[t.length-1],W=g?.newestLogId??F?.id??null;W!==null&&Le({kind:"newer",afterLogId:W})},[t,Le,g]),Ne=l.useMemo(()=>{if(e!==void 0)return{isLoading:y,loadProgress:S,total:g?.total??null,pageSize:g?.limit??Hl,hasOlder:g?.hasOlder??!1,hasNewer:g?.hasNewer??!1,oldestLogId:g?.oldestLogId??null,newestLogId:g?.newestLogId??null,onOldest:ze,onOlder:Y,onNewer:de,onNewest:D}},[e,D,de,Y,ze,g,S,y]);return n.jsxs(n.Fragment,{children:[n.jsx(Yf,{notice:m,onDismiss:p}),n.jsx(eb,{}),n.jsx(PE,{logs:Se,sessions:Te,models:ge,selectedSession:o,selectedModel:a,onSessionChange:r,onModelChange:i,onClearAll:Ke,onDeleteCurrentView:rt,onReloadSession:e!==void 0||o!=="__all__"?nt:void 0,onClearGroup:Ze,onNotify:u,onImportLogs:e===void 0?q:void 0,isLoading:e===void 0&&f.status==="connecting"&&f.lastSuccessAt===null||y,liveConnection:e===void 0?f:void 0,onRetryLiveConnection:lt,onStopLiveConnection:He,pagination:Ne,sessionLoadProgress:S,sessionLoadError:b??void 0,sessionMemberships:C,viewMode:Oe,captureMode:xe,strip:se,slowResponseThresholdSeconds:pe,timeDisplayFormat:we,hideSessionFilter:e!==void 0,pinnedSessionId:e})]})}export{bn as $,Q_ as A,_e as B,og as C,qt as D,nR as E,Xe as F,be as G,uN as H,Og as I,tR as J,_u as K,RS as L,Pu as M,mN as N,pN as O,sR as P,qn as Q,g1 as R,oT as S,Ef as T,wi as U,pr as V,f_ as W,so as X,G0 as Y,Vs as Z,G as _,M5 as a,Ue as a0,iu as a1,jS as a2,P0 as a3,tc as b,B as c,Lu as d,gt as e,$e as f,vf as g,jt as h,Ht as i,Yt as j,Jt as k,Du as l,Rf as m,Zt as n,ct as o,Vg as p,Ts as q,mr as r,dt as s,ut as t,ol as u,mt as v,Ss as w,Hs as x,BT as y,eT as z};
|