@tonyclaw/agent-inspector 3.1.0 → 3.1.2
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 +4 -4
- package/.output/server/_ssr/index.mjs +1 -1
- package/.output/server/_ssr/{router-CPZp1dgy.mjs → router-BI9TFWBj.mjs} +58 -5
- package/.output/server/index.mjs +1 -1
- package/.output/ui/assets/{CompareDrawer-CkABWY5h.js → CompareDrawer-fIMqOLC-.js} +1 -1
- package/.output/ui/assets/{InspectorPet-BvsFl3jv.js → InspectorPet-CB3QawLs.js} +1 -1
- package/.output/ui/assets/ProxyViewerContainer-B_N_vA7d.js +59 -0
- package/.output/ui/assets/{ReplayDialog-uJnW9FgF.js → ReplayDialog-BqydXB2T.js} +1 -1
- package/.output/ui/assets/{RequestAnatomy-CJ1IFwXf.js → RequestAnatomy-MVne2sW0.js} +1 -1
- package/.output/ui/assets/{ResponseView-Da8fKfh6.js → ResponseView-C2BZew_E.js} +1 -1
- package/.output/ui/assets/{StreamingChunkSequence-zIZ1fbEj.js → StreamingChunkSequence-DQeuVTBu.js} +1 -1
- package/.output/ui/assets/{_sessionId-WYeJ04Ke.js → _sessionId-DdrpVgxn.js} +1 -1
- package/.output/ui/assets/{_sessionId-CY9mZjlC.js → _sessionId-wxS6YbbQ.js} +1 -1
- package/.output/ui/assets/{index-CwOAPU17.js → index-6dJrsZAp.js} +1 -1
- package/.output/ui/assets/{index-C2AvphEC.js → index-BlnkJVwp.js} +2 -2
- package/.output/ui/assets/{index-Bzm_5L4l.js → index-C4kJ14k6.js} +1 -1
- package/.output/ui/assets/{index-DWI-2j8i.js → index-CuzSabuM.js} +1 -1
- package/.output/ui/assets/{json-viewer-C9EpwpoT.js → json-viewer---Z5aMYi.js} +1 -1
- package/.output/ui/assets/{jszip.min-CEk40IyV.js → jszip.min-BdIGVBGl.js} +1 -1
- package/.output/ui/index.html +1 -1
- package/package.json +4 -4
- package/src/lib/export-logs.ts +64 -7
- package/src/proxy/ecosystemTasks.ts +12 -3
- package/src/proxy/handler.ts +59 -2
- package/.output/ui/assets/ProxyViewerContainer-D6O6tY5h.js +0 -59
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./jszip.min-CEk40IyV.js","./index-C2AvphEC.js","./index-BvXp42al.css","./CompareDrawer-CkABWY5h.js","./InspectorPet-BvsFl3jv.js","./ReplayDialog-uJnW9FgF.js","./ResponseView-Da8fKfh6.js","./RequestAnatomy-CJ1IFwXf.js","./StreamingChunkSequence-zIZ1fbEj.js","./json-viewer-C9EpwpoT.js","./index-CwOAPU17.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{l as wh,u as Ot,s as x,n as E,b as _e,_ as Do,a as K,c as ze,o as T,d as ue,e as re,f as un,g as _s,h as Et,i as Md,k as Ge,r as l,j as t,m as Dt,p as Xn,A as zl,q as jh,t as Wr,v as mr,w as ms,x as O,B as ee,y as An,z as Ad,C as Ee,D as Id,E as vt,F as wi,G as Sh,H as De,L as zo,I as Pd,J as Nh,K as $o,M as Ch,N as kh,O as _h,P as Ld,Q as ji,T as Th,U as Eh}from"./index-C2AvphEC.js";const We=wh(()=>Ot([x(),E(),_e(),Do(),K(We),ze(x(),We)])),At=E().int().nonnegative().max(Number.MAX_SAFE_INTEGER),Rh=ue(["capacity-exceeded","pipeline-closed","write-failed","finalize-failed","upstream-stream-error","shutdown"]),Od=T({index:E(),timestamp:E(),type:x(),data:We}),Mh=T({chunks:K(Od),truncated:_e().optional().default(!1)}),Ah=ue(["request","response"]),Ih=T({logId:At,part:Ah,text:x(),offset:E().int().nonnegative(),limit:E().int().positive(),totalBytes:E().int().nonnegative(),textBytes:E().int().nonnegative(),nextOffset:E().int().nonnegative().nullable(),hasMore:_e(),contentMode:ue(["empty","partial","full"])}),As=T({id:At,timestamp:x(),method:x(),path:x(),model:x().nullable(),sessionId:x().nullable(),rawRequestBody:x().nullable(),responseStatus:E().nullable(),responseText:x().nullable(),inputTokens:E().nullable(),outputTokens:E().nullable(),cacheCreationInputTokens:E().nullable(),cacheReadInputTokens:E().nullable(),elapsedMs:E().nullable(),firstChunkMs:E().nullable().optional(),totalStreamMs:E().nullable().optional(),tokensPerSecond:E().nullable().optional(),streaming:_e(),userAgent:x().nullable(),origin:x().nullable(),rawHeaders:ze(x(),x()).optional(),headers:ze(x(),x()).optional(),apiFormat:ue(["anthropic","openai","unknown"]).default("unknown"),isTest:_e().optional().default(!1),replayOfLogId:At.nullable().optional(),providerName:x().nullable().optional(),clientPort:E().nullable().optional(),clientPid:E().nullable().optional(),clientCwd:x().nullable().optional(),clientProjectFolder:x().nullable().optional(),streamingChunks:Mh.optional(),streamingChunksPath:x().nullable().optional(),rawRequestBodyBytes:E().int().nonnegative().nullable().optional(),responseTextBytes:E().int().nonnegative().nullable().optional(),bodyContentMode:ue(["full","compact","truncated"]).optional(),captureIncomplete:_e().optional(),droppedChunks:E().int().nonnegative().optional(),droppedBytes:E().int().nonnegative().optional(),captureIncompleteReason:Rh.nullable().optional(),warnings:K(x()).optional(),error:x().nullable().optional()}),Si=T({type:x(),ttl:x().optional(),scope:x().optional()}),Ni=T({type:re("text"),text:x(),cache_control:Si.optional()}),Dd=T({type:re("thinking"),thinking:x(),signature:x().optional()}),Ph=T({type:re("think"),thinking:x(),signature:x().optional()}),Lh=T({type:re("base64"),media_type:x(),data:x()}),zd=T({type:re("image"),source:Lh}),$d=T({type:re("tool_use"),id:x(),name:x(),input:ze(x(),We)}),Oh=un("type",[Ni,zd]),Dh=T({type:re("tool_result"),tool_use_id:x().optional(),content:Ot([x(),K(Oh)]),is_error:_e().optional()}),zh=un("type",[Ni,Dd,zd,$d,Dh]),$h=Ot([x(),K(zh)]),Fh=T({role:ue(["user","assistant"]),content:$h}),Uh=T({type:re("text"),text:x(),cache_control:Si.optional()}),Bh=T({type:x(),properties:ze(x(),ze(x(),We)).optional(),required:K(x()).optional(),additionalProperties:_e().optional(),$schema:x().optional()}),qh=T({name:x(),description:x().optional(),input_schema:Bh.optional(),cache_control:Si.optional()}),Hh=un("type",[T({type:re("enabled"),budget_tokens:E()}),T({type:re("disabled")}),T({type:re("adaptive")})]),Wh=T({model:x(),messages:K(Fh),system:K(Uh).optional(),tools:K(qh).optional(),max_tokens:E().optional(),temperature:E().optional(),stream:_e().optional(),thinking:Hh.optional(),metadata:T({user_id:x().optional()}).optional()}),Ci=un("type",[Ni,Dd,Ph,$d]),Vh=T({input_tokens:E().nullable().optional(),output_tokens:E().nullable().optional(),cache_creation_input_tokens:E().nullable().optional(),cache_read_input_tokens:E().nullable().optional()}).passthrough(),Kh=T({id:x(),type:re("message"),model:x(),role:re("assistant"),content:K(Ci),stop_reason:x().nullable(),stop_sequence:x().nullable().optional(),usage:Vh}).passthrough(),Gh=T({type:re("message_start"),message:T({id:x(),type:re("message"),model:x(),role:re("assistant"),content:K(Ci),stop_reason:Do(),stop_sequence:Do(),usage:T({input_tokens:E(),cache_creation_input_tokens:E().optional(),cache_read_input_tokens:E().optional()}).passthrough()})}),Jh=T({type:re("content_block_start"),index:E(),content_block:Ci}),Yh=un("type",[T({type:re("text_delta"),text:x()}),T({type:re("input_json_delta"),partial_json:x()}),T({type:re("thinking_delta"),thinking:x()}),T({type:re("signature_delta"),signature:x()})]),Xh=T({type:re("content_block_delta"),index:E(),delta:Yh}),Zh=T({type:re("content_block_stop"),index:E()}),Qh=T({type:re("message_delta"),delta:T({stop_reason:x().nullable(),stop_sequence:x().nullable().optional()}),usage:T({output_tokens:E(),input_tokens:E().optional(),cache_creation_input_tokens:E().optional(),cache_read_input_tokens:E().optional()}).passthrough()}),ex=T({type:re("message_stop")}),tx=T({type:re("ping")}),nx=T({type:re("error"),error:T({type:x(),message:x()})});un("type",[Gh,Jh,Xh,Zh,Qh,ex,tx,nx]);const sx=Ot([x(),K(un("type",[T({type:re("text"),text:x()}),T({type:re("image_url"),image_url:T({url:x(),detail:x().optional()})})]))]),Fd=T({role:ue(["system","user","assistant","tool"]),content:sx,name:x().optional(),reasoning_content:x().optional(),thinking:x().optional(),think:x().optional()}),ox=T({name:x(),arguments:x()}),Ud=T({index:E().optional(),id:x().optional(),type:re("function").optional(),function:T({name:x().optional(),arguments:x().optional()})});Fd.extend({content:Ot([x(),K(T({type:re("text"),text:x()}))]).optional(),function_call:ox.optional(),tool_calls:K(Ud).optional()});const rx=T({type:re("function"),function:T({name:x(),description:x().optional(),parameters:ze(x(),We)})}),ax=T({model:x(),messages:K(Fd),temperature:E().optional(),max_tokens:E().optional(),stream:_e().optional(),tools:K(rx).optional(),tool_choice:Ot([ue(["auto","none","required"]),T({type:re("auto")}),T({type:re("none")}),T({type:re("function"),function:T({name:x()})})]).optional(),user:x().optional()}),ix=T({type:x(),name:x().optional(),description:x().optional(),parameters:We.optional(),function:T({name:x().optional(),description:x().optional(),parameters:We.optional()}).optional()}).passthrough(),lx=T({model:x(),input:_s().optional(),instructions:Ot([x(),Do()]).optional(),stream:_e().optional(),tools:K(ix).optional(),tool_choice:_s().optional(),max_output_tokens:E().optional(),temperature:E().optional(),user:x().optional(),metadata:ze(x(),_s()).optional()}).passthrough(),Bd=T({role:ue(["assistant"]).optional(),content:x().nullable().optional(),reasoning_content:x().nullable().optional(),thinking:x().nullable().optional(),think:x().nullable().optional(),function_call:T({name:x().optional(),arguments:x().optional()}).nullable().optional(),tool_calls:K(T({index:E(),id:x().optional(),type:re("function").optional(),function:T({name:x().optional(),arguments:x().optional()})})).nullable().optional()}),cx=T({index:E(),message:T({role:ue(["assistant"]),content:x().nullable(),reasoning_content:x().optional(),thinking:x().optional(),think:x().optional(),function_call:T({name:x(),arguments:x()}).nullable().optional(),tool_calls:K(Ud).optional()}).optional(),delta:Bd.optional(),finish_reason:x().nullable()}),dx=T({id:x(),object:re("chat.completion"),created:E(),model:x(),choices:K(cx),usage:T({prompt_tokens:E().nullable().optional(),completion_tokens:E().nullable().optional(),total_tokens:E().nullable().optional()}).passthrough(),service_tier:x().nullable().optional(),system_fingerprint:x().nullable().optional()}).passthrough();T({id:x(),object:re("chat.completion.chunk"),created:E(),model:x(),choices:K(T({index:E(),delta:Bd,finish_reason:x().nullable().optional()})),usage:T({prompt_tokens:E().nullable().optional(),completion_tokens:E().nullable().optional(),total_tokens:E().nullable().optional()}).passthrough().nullable().optional()}).passthrough();const ux=T({input_tokens:E().nullable().optional(),output_tokens:E().nullable().optional(),total_tokens:E().nullable().optional(),input_tokens_details:T({cached_tokens:E().nullable().optional()}).passthrough().nullable().optional(),output_tokens_details:T({reasoning_tokens:E().nullable().optional()}).passthrough().nullable().optional()}).passthrough(),mx=T({type:x()}).passthrough(),px=T({id:x(),object:re("response").optional(),created_at:E().optional(),status:x().nullable().optional(),model:x().optional(),output:K(mx).optional(),output_text:x().optional(),usage:ux.nullable().optional(),error:_s().optional()}).passthrough();T({type:x()}).passthrough();function fx(e){try{const n=JSON.parse(e),s=dx.safeParse(n);return s.success?s.data:null}catch{return null}}function hx(e){try{const n=JSON.parse(e),s=px.safeParse(n);return s.success?s.data:null}catch{return null}}const qd=T({input:E().int().nonnegative(),output:E().int().nonnegative(),cacheCreate:E().int().nonnegative(),cacheRead:E().int().nonnegative(),total:E().int().nonnegative()}),xx=T({id:At,sessionLogNumber:E().int().positive().optional(),timestamp:x(),provider:x().nullable(),model:x().nullable(),apiFormat:ue(["anthropic","openai","unknown"]),method:x(),path:x(),status:E().nullable(),isStreaming:_e(),hasError:_e(),error:x().nullable(),latencyMs:E().nullable(),firstChunkMs:E().nullable().optional(),totalStreamMs:E().nullable().optional(),tokensPerSecond:E().nullable().optional(),tokens:T({input:E().nullable(),output:E().nullable(),cacheCreate:E().nullable(),cacheRead:E().nullable()}),sessionId:x().nullable(),userAgent:x().nullable().optional(),clientPid:E().nullable().optional(),clientProjectFolder:x().nullable().optional()}),Hd=T({id:x(),status:ue(["active","failed","completed","empty"]),logCoverage:ue(["recent","history"]),source:ue(["explicit","client-process","client-connection","provider-test"]).nullable(),runtimeMode:ue(["in-process","worker-thread","child-process"]).nullable(),createdAt:x().nullable(),updatedAt:x().nullable(),requestCount:E().int().nonnegative(),activeRequests:E().int().nonnegative(),completedRequests:E().int().nonnegative(),failedRequests:E().int().nonnegative(),queuedTasks:E().int().nonnegative(),runningTasks:E().int().nonnegative(),lastTaskError:x().nullable(),logCount:E().int().nonnegative(),errorCount:E().int().nonnegative(),models:K(x()),providers:K(x()),tokenUsage:qd,lastLogId:At.nullable(),lastModel:x().nullable(),clientUserAgent:x().nullable().optional(),clientPid:E().nullable(),clientProjectFolder:x().nullable(),inspectorPath:x(),inspectorUrl:x(),apiPath:x(),apiUrl:x(),compactLogsPath:x(),compactLogsUrl:x(),latestLogLimit:E().int().positive(),latestLogs:K(xx)}),qs=ue(["created","running","completed","failed","cancelled"]),ki=T({jsonPath:x(),markdownPath:x(),htmlPath:x(),exportedAt:x()}),gx=ue(["run-created","session-started","request","session-finished","evidence-exported"]),bx=ue(["info","success","warning","error"]),vx=T({timestamp:x(),kind:gx,severity:bx,title:x(),details:x(),logId:At.nullable(),status:E().nullable(),model:x().nullable(),provider:x().nullable(),latencyMs:E().nullable(),isStreaming:_e().nullable()}),yx=ue(["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"]),Wd=T({outcome:ue(["success","failure","active","unknown"]),severity:ue(["none","low","medium","high"]),category:yx,summary:x(),evidenceLogIds:K(At),hints:K(x())}),_i=T({status:ue(["PASS","FAIL","RUNNING","UNKNOWN"]),summary:x(),markdown:x()}),Vd=_i,Ti=T({id:x(),sessionId:x(),groupId:x().nullable().default(null),title:x(),task:x().nullable(),project:x().nullable(),agent:x().nullable(),status:qs,tags:K(x()),metadata:ze(x(),We),evidence:ki.nullable(),createdAt:x(),updatedAt:x()});T({runId:x().min(1).optional(),sessionId:x().min(1).optional(),groupId:x().min(1).nullable().optional(),title:x().min(1).optional(),task:x().nullable().optional(),project:x().nullable().optional(),agent:x().nullable().optional(),status:qs.optional(),tags:K(x()).optional(),metadata:ze(x(),We).optional()}).optional();T({sessionId:x().min(1).optional(),groupId:x().min(1).nullable().optional(),title:x().min(1).optional(),task:x().nullable().optional(),project:x().nullable().optional(),agent:x().nullable().optional(),status:qs.optional(),tags:K(x()).optional(),metadata:ze(x(),We).optional()});T({includeHistory:_e().optional(),latestLogLimit:E().int().positive().max(50).optional()}).optional();T({run:Ti,evidence:ki,session:Hd.nullable(),timeline:K(vx),classification:Wd,jenkinsReport:_i});const wx=T({run:Ti,classification:Wd,evidence:ki.nullable(),jenkinsReport:_i.nullable(),sessionId:x(),inspectorUrl:x().nullable(),evidenceMarkdownPath:x().nullable(),updatedAt:x()});T({failures:K(wx),total:E().int().nonnegative(),limit:E().int().positive()});const Ei=ue(["created","running","completed","failed","cancelled"]),Ri=ue(["evaluation","batch","manual"]),Mi=T({jsonPath:x(),markdownPath:x(),htmlPath:x(),exportedAt:x()}),Kd=T({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:ze(x(),We),addedAt:x(),updatedAt:x()}),Ai=T({id:x(),title:x(),kind:Ri,task:x().nullable(),project:x().nullable(),status:Ei,tags:K(x()),metadata:ze(x(),We),evidence:Mi.nullable(),members:K(Kd),createdAt:x(),updatedAt:x()});T({groupId:x().min(1).optional(),title:x().min(1).optional(),kind:Ri.optional(),task:x().nullable().optional(),project:x().nullable().optional(),status:Ei.optional(),tags:K(x()).optional(),metadata:ze(x(),We).optional()}).optional();T({title:x().min(1).optional(),kind:Ri.optional(),task:x().nullable().optional(),project:x().nullable().optional(),status:Ei.optional(),tags:K(x()).optional(),metadata:ze(x(),We).optional()});T({memberId:x().min(1).optional(),sessionId:x().min(1),runId:x().min(1).nullable().optional(),label:x().min(1).nullable().optional(),agent:x().min(1).nullable().optional(),provider:x().min(1).nullable().optional(),model:x().min(1).nullable().optional(),status:qs.nullable().optional(),metadata:ze(x(),We).optional()});T({includeHistory:_e().optional(),latestLogLimit:E().int().positive().max(50).optional()}).optional();T({deleteEvidence:_e().optional()});const Gd=T({groupId:x(),deleted:_e(),evidenceDeleted:_e(),evidencePath:x().nullable()}),Jd=T({deleted:E().int().nonnegative(),groups:K(Gd)}),Yd=T({member:Kd,run:Ti.nullable(),session:Hd.nullable()}),Xd=T({memberCount:E().int().nonnegative(),sessionsWithData:E().int().nonnegative(),missingSessions:E().int().nonnegative(),requestCount:E().int().nonnegative(),errorCount:E().int().nonnegative(),tokenUsage:qd,models:K(x()),providers:K(x()),completedMembers:E().int().nonnegative(),failedMembers:E().int().nonnegative(),runningMembers:E().int().nonnegative()}),jx=T({group:Ai,evidence:Mi,members:K(Yd).nullable(),markdown:x(),summary:Xd.nullable(),report:Vd.nullable()}),Sx=T({group:Ai,evidence:Mi,members:K(Yd),summary:Xd,jenkinsReport:Vd}),Zd=T({groups:K(Ai)}),Nx=T({sessionId:x(),imported:E().int().nonnegative(),skipped:E().int().nonnegative(),warnings:K(x()),logs:K(As)}),Fo=10,Da=600,Uo=60,za=600,Bo="time",Ii="simple",Qd=ue(["time","full"]),Cx=ue(["simple","full"]),pr=T({stripClaudeCodeBillingHeader:_e(),hasSeenOnboarding:_e().default(!1),slowResponseThresholdSeconds:E().int().min(0).max(Da).default(Fo),providerTestTimeoutSeconds:E().int().min(1).max(za).default(Uo),timeDisplayFormat:Qd.default(Bo),captureMode:Cx.default(Ii)}),Gn="/api/config";async function kx(e){return Ge(e,pr,void 0,n=>`Failed to fetch ${e}: ${n.status}`)}async function to(e){return Ge(Gn,pr,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e)},n=>`PATCH failed with status ${n.status}`)}function Pi(){const e=Et(Gn,kx,{revalidateOnFocus:!1,revalidateIfStale:!1}),{mutate:n}=Md(),s=e.data?.stripClaudeCodeBillingHeader??!1,o=e.data?.captureMode??Ii,r=e.data?.slowResponseThresholdSeconds??Fo,a=e.data?.providerTestTimeoutSeconds??Uo,i=e.data?.timeDisplayFormat??Bo,c=f=>({stripClaudeCodeBillingHeader:e.data?.stripClaudeCodeBillingHeader??!1,hasSeenOnboarding:e.data?.hasSeenOnboarding??!1,slowResponseThresholdSeconds:e.data?.slowResponseThresholdSeconds??Fo,providerTestTimeoutSeconds:e.data?.providerTestTimeoutSeconds??Uo,timeDisplayFormat:e.data?.timeDisplayFormat??Bo,captureMode:o,...f}),d=async f=>{await n(Gn,to({stripClaudeCodeBillingHeader:f}),{optimisticData:c({stripClaudeCodeBillingHeader:f}),rollbackOnError:!0,revalidate:!1})},m=async f=>{await n(Gn,to({slowResponseThresholdSeconds:f}),{optimisticData:c({slowResponseThresholdSeconds:f}),rollbackOnError:!0,revalidate:!1})},u=async f=>{await n(Gn,to({timeDisplayFormat:f}),{optimisticData:c({timeDisplayFormat:f}),rollbackOnError:!0,revalidate:!1})},p=async f=>{await n(Gn,to({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 eu=(...e)=>e.filter((n,s,o)=>!!n&&n.trim()!==""&&o.indexOf(n)===s).join(" ").trim();const _x=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const Tx=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(n,s,o)=>o?o.toUpperCase():s.toLowerCase());const $l=e=>{const n=Tx(e);return n.charAt(0).toUpperCase()+n.slice(1)};var Ex={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 Rx=e=>{for(const n in e)if(n.startsWith("aria-")||n==="role"||n==="title")return!0;return!1};const Mx=l.forwardRef(({color:e="currentColor",size:n=24,strokeWidth:s=2,absoluteStrokeWidth:o,className:r="",children:a,iconNode:i,...c},d)=>l.createElement("svg",{ref:d,...Ex,width:n,height:n,stroke:e,strokeWidth:o?Number(s)*24/Number(n):s,className:eu("lucide",r),...!a&&!Rx(c)&&{"aria-hidden":"true"},...c},[...i.map(([m,u])=>l.createElement(m,u)),...Array.isArray(a)?a:[a]]));const q=(e,n)=>{const s=l.forwardRef(({className:o,...r},a)=>l.createElement(Mx,{ref:a,iconNode:n,className:eu(`lucide-${_x($l(e))}`,`lucide-${e}`,o),...r}));return s.displayName=$l(e),s};const Ax=[["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"}]],Ix=q("a-large-small",Ax);const Px=[["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"}]],Lx=q("activity",Px);const Ox=[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]],Dx=q("arrow-down-right",Ox);const zx=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],$x=q("arrow-down",zx);const Fx=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Ux=q("arrow-left",Fx);const Bx=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],qx=q("arrow-up-right",Bx);const Hx=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Wx=q("arrow-up",Hx);const Vx=[["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"}]],Li=q("beaker",Vx);const Kx=[["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"}]],Gx=q("bell",Kx);const Jx=[["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"}]],Yx=q("blocks",Jx);const Xx=[["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"}]],Zx=q("brain-circuit",Xx);const Qx=[["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"}]],tu=q("brain",Qx);const e0=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Oe=q("check",e0);const t0=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Ve=q("chevron-down",t0);const n0=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],s0=q("chevron-left",n0);const o0=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],it=q("chevron-right",o0);const r0=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Oi=q("chevron-up",r0);const a0=[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]],i0=q("chevrons-down",a0);const l0=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],c0=q("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"}]],u0=q("chevrons-right",d0);const m0=[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]],p0=q("chevrons-up",m0);const f0=[["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"}]],os=q("circle-alert",f0);const h0=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Hs=q("circle-check-big",h0);const x0=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],$a=q("circle-check",x0);const g0=[["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"}]],b0=q("circle-question-mark",g0);const v0=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],y0=q("circle-stop",v0);const w0=[["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"}]],nu=q("circle-x",w0);const j0=[["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"}]],S0=q("clapperboard",j0);const N0=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],C0=q("clock-3",N0);const k0=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Wt=q("clock",k0);const _0=[["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"}]],T0=q("cloud-upload",_0);const E0=[["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"}]],su=q("code-xml",E0);const R0=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],M0=q("columns-2",R0);const A0=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],St=q("copy",A0);const I0=[["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"}]],P0=q("cpu",I0);const L0=[["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"}]],Ws=q("download",L0);const O0=[["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"}]],D0=q("ellipsis",O0);const z0=[["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"}]],Di=q("external-link",z0);const $0=[["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"}]],F0=q("eye-off",$0);const U0=[["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"}]],ou=q("eye",U0);const B0=[["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"}]],q0=q("file-braces",B0);const H0=[["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"}]],W0=q("file-diff",H0);const V0=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["circle",{cx:"11.5",cy:"14.5",r:"2.5",key:"1bq0ko"}],["path",{d:"M13.3 16.3 15 18",key:"2quom7"}]],K0=q("file-search",V0);const G0=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"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"}]],J0=q("file-terminal",G0);const Y0=[["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"}]],X0=q("file-text",Y0);const Z0=[["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"}]],Q0=q("flag",Z0);const eg=[["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"}]],ru=q("flask-conical",eg);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"}]],ng=q("folder-open",tg);const sg=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],zi=q("gauge",sg);const og=[["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"}]],rg=q("git-compare-arrows",og);const ag=[["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=q("globe",ag);const ig=[["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=q("history",ig);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"}]],cg=q("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"}]],Fl=q("layers",dg);const ug=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Ae=q("loader-circle",ug);const mg=[["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"}]],pg=q("lock",mg);const fg=[["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"}]],hg=q("maximize-2",fg);const xg=[["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"}]],fr=q("message-square",xg);const gg=[["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"}]],bg=q("minimize-2",gg);const vg=[["path",{d:"M5 12h14",key:"1ays0h"}]],lu=q("minus",vg);const yg=[["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"}]],wg=q("monitor",yg);const jg=[["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"}]],Sg=q("moon",jg);const Ng=[["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"}]],Cg=q("mouse-pointer-click",Ng);const kg=[["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"}]],_g=q("network",kg);const Tg=[["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"}]],Eg=q("octagon-alert",Tg);const Rg=[["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"}]],Mg=q("package-check",Rg);const Ag=[["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"}]],Ig=q("panel-right-close",Ag);const Pg=[["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"}]],Lg=q("panel-right-open",Pg);const Og=[["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"}]],cu=q("pencil",Og);const Dg=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Ul=q("plus",Dg);const zg=[["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"}]],Bl=q("radio",zg);const $g=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],yt=q("refresh-cw",$g);const Fg=[["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"}]],du=q("rocket",Fg);const Ug=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],uu=q("rotate-ccw",Ug);const Bg=[["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"}]],qo=q("rotate-cw",Bg);const qg=[["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"}]],Hg=q("rows-3",qg);const Wg=[["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"}]],Vg=q("save",Wg);const Kg=[["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"}]],Gg=q("scan",Kg);const Jg=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Yg=q("search",Jg);const Xg=[["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"}]],Zg=q("send",Xg);const Qg=[["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"}]],e1=q("server",Qg);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"}]],n1=q("settings",t1);const s1=[["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"}]],o1=q("shield-alert",s1);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:"m9 12 2 2 4-4",key:"dzmm74"}]],ql=q("shield-check",r1);const a1=[["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"}]],Ho=q("siren",a1);const i1=[["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"}]],Fa=q("sparkles",i1);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"}]],c1=q("sun",l1);const d1=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],In=q("terminal",d1);const u1=[["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"}]],mu=q("timer",u1);const m1=[["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"}]],an=q("trash-2",m1);const p1=[["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"}]],rn=q("triangle-alert",p1);const f1=[["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"}]],pu=q("upload",f1);const h1=[["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"}]],x1=q("wifi-off",h1);const g1=[["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"}]],b1=q("wifi",g1);const v1=[["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"}]],Vs=q("wrench",v1);const y1=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Ks=q("x",y1);const w1=[["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"}]],Is=q("zap",w1),Ua="/api/config";async function j1(e){return Ge(e,pr,void 0,n=>`Failed to fetch ${e}: ${n.status}`)}async function S1(e){return Ge(Ua,pr,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e)},n=>`PATCH failed with status ${n.status}`)}function N1(){const e=Et(Ua,j1,{revalidateOnFocus:!1,revalidateIfStale:!1}),{mutate:n}=Md(),s=e.data?.hasSeenOnboarding??!1,o=e.data?.captureMode??Ii,r=async()=>{await n(Ua,S1({hasSeenOnboarding:!0}),{optimisticData:{stripClaudeCodeBillingHeader:e.data?.stripClaudeCodeBillingHeader??!1,hasSeenOnboarding:!0,slowResponseThresholdSeconds:e.data?.slowResponseThresholdSeconds??Fo,providerTestTimeoutSeconds:e.data?.providerTestTimeoutSeconds??Uo,timeDisplayFormat:e.data?.timeDisplayFormat??Bo,captureMode:o},rollbackOnError:!0,revalidate:!1})};return{hasSeenOnboarding:s,captureMode:o,isLoading:e.isLoading,markSeen:r}}function C1({expanded:e,onToggle:n,onDismiss:s}){const o=e?"grid":"hidden sm:grid";return t.jsx("div",{role:"note","aria-label":"Onboarding tip",className:"mx-3 mt-2 mb-1 rounded-md border border-warning/30 bg-warning/10 px-3 py-2 text-sm shadow-sm sm:mx-4",children:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(cg,{className:"mt-0.5 size-4 shrink-0 text-warning","aria-hidden":"true"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[t.jsx("span",{className:"font-medium text-foreground",children:"Inspector ready"}),t.jsx("span",{className:"hidden truncate text-xs text-muted-foreground sm:inline",children:"Request, response, tool, timing, token, replay, and memory signals are active."})]}),t.jsx("div",{className:"mt-1 text-xs leading-relaxed text-muted-foreground sm:hidden",children:"Core capture is active."}),t.jsxs("div",{className:`${o} mt-2 gap-x-4 gap-y-1 text-xs leading-relaxed text-muted-foreground sm:grid-cols-2`,children:[t.jsxs("div",{children:[t.jsx("strong",{children:"Evidence"}),": logs, sessions, groups, and MCP exports are available."]}),t.jsxs("div",{children:[t.jsx("strong",{children:"Network"}),": replace ",t.jsx("code",{children:"localhost"})," if containers differ."]})]})]}),t.jsx("button",{type:"button",onClick:n,className:"inline-flex h-8 shrink-0 items-center gap-1 rounded-md border border-warning/35 px-2 text-xs font-medium text-foreground transition-colors hover:bg-warning/15 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none sm:hidden","aria-expanded":e,"aria-label":e?"Hide onboarding details":"Show onboarding details",children:t.jsx(Ve,{className:`size-3.5 transition-transform ${e?"rotate-180":""}`})}),t.jsxs("button",{type:"button",onClick:s,className:"hidden h-8 shrink-0 items-center gap-1.5 rounded-md border border-warning/40 px-3 text-xs font-medium text-foreground transition-colors hover:bg-warning/15 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none sm:inline-flex","aria-label":"Dismiss onboarding tip",children:[t.jsx(Oe,{className:"size-3.5"}),"Got it"]}),t.jsx("button",{type:"button",onClick:s,className:"-m-1 shrink-0 rounded-sm p-1 text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none","aria-label":"Dismiss",children:t.jsx(Ks,{className:"size-3.5"})})]})})}function k1(){const{hasSeenOnboarding:e,isLoading:n,markSeen:s}=N1(),[o,r]=l.useState(!1);return n||e?null:t.jsx(C1,{expanded:o,onToggle:()=>r(a=>!a),onDismiss:()=>{s()}})}const _1="3.1.0",fu={version:_1};function Cs(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const hu="[REDACTED]",T1=/(^|[-_])(api[-_]?key|authorization|cookie|token|secret|password|access[-_]?token|refresh[-_]?token)([-_]|$)/i,E1=[/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],Hl=200,R1=25e6,xu=50,M1=1e4;function A1(e){return e<1024?`${e} chars`:e<1024*1024?`${Math.ceil(e/1024)} KB`:`${Math.ceil(e/(1024*1024))} MB`}function I1(e){let n=0;for(const s of e)n+=s.rawRequestBody?.length??0,n+=s.responseText?.length??0;return n}function P1(e){if(e.length>Hl)return`Export is limited to ${Hl} logs at once. Narrow the filter and try again.`;const n=I1(e);return n>R1?`Export is too large (${A1(n)} of text). Narrow the filter and try again.`:null}function no(e){return e?.aborted===!0?{ok:!1,message:"Export canceled.",canceled:!0}:null}async function L1(e,n){try{const s=await Xn(`/api/logs/${e}/chunks`,M1,{signal:n});if(!s.ok)return null;const o=await s.json();return JSON.stringify(o,null,2)}catch{return null}}function Ba(e){if(Array.isArray(e))return e.map(s=>Ba(s));if(!Cs(e))return e;const n={};for(const[s,o]of Object.entries(e))n[s]=T1.test(s)?hu:Ba(o);return n}function O1(e){const n=s=>{let o=s;for(const r of E1)o=o.replace(r,hu);return o};try{const s=JSON.parse(e);return n(JSON.stringify(Ba(s),null,2))}catch{return n(e)}}function Vr(e,n){return n==="redacted"?O1(e):e}function D1(e,n){return{...e,rawRequestBody:null,responseText:null,rawHeaders:n==="raw"?e.rawHeaders:void 0,headers:n==="raw"?e.headers:void 0,streamingChunks:void 0,bodyContentMode:"compact"}}function z1(e,n,s,o=new Date().toISOString()){return{version:fu.version,exportedAt:o,mode:n,redacted:n==="redacted",logCount:e.length,logIds:e.map(r=>r.id),streamingChunkExportLimit:xu,streamingChunkLogIds:s.map(r=>r.id)}}async function $1(e,n="redacted",s={}){const o=no(s.signal);if(o!==null)return o;const r=P1(e);if(r!==null)return{ok:!1,message:r};const{default:a}=await Dt(async()=>{const{default:h}=await import("./jszip.min-CEk40IyV.js").then(g=>g.j);return{default:h}},__vite__mapDeps([0,1,2]),import.meta.url),i=new a,c=n==="redacted"?"redacted":"raw",d=e.filter(h=>h.streaming).slice(0,xu);i.file("manifest.json",JSON.stringify(z1(e,n,d),null,2)),i.file("logs.json",JSON.stringify(e.map(h=>D1(h,n)),null,2));for(const h of e){const g=no(s.signal);if(g!==null)return g;h.rawRequestBody!==null&&i.file(`#${h.id}.Request.json`,Vr(h.rawRequestBody,n)),h.responseText!==null&&i.file(`#${h.id}.Response.json`,Vr(h.responseText,n))}for(const h of d){const g=no(s.signal);if(g!==null)return g;const b=await L1(h.id,s.signal);b!==null&&i.file(`#${h.id}.SSE.Response.json`,Vr(b,n))}const m=await i.generateAsync({type:"blob"}),u=no(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 F1(e){const n=Wr(e,"/proxy"),s=Wr(e,"/proxy/v1"),o=Wr(e,"/api/mcp");return n===null||s===null||o===null?null:{proxy:n,openAiV1:s,mcp:o}}function U1(){const e=jh();return e.ok?F1(e.runtime):null}function $i(e){const n=()=>e(U1());return n(),typeof globalThis.addEventListener!="function"||typeof globalThis.removeEventListener!="function"?()=>{}:(globalThis.addEventListener(zl,n),()=>globalThis.removeEventListener(zl,n))}function qa(e,n){switch(n){case"full":return e;case"time":return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}}function hr(e,n,s){return`${qa(e,s)} - ${qa(n,s)}`}const Fi="agent-inspector.theme";function gu(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 Kr(e){typeof document>"u"||(document.documentElement.dataset.theme=e)}function B1(){if(typeof window>"u")return"dark";try{return gu(window.localStorage.getItem(Fi))}catch{return"dark"}}function q1(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Fi,e)}catch{}}function H1(){const[e,n]=l.useState(B1),s=l.useCallback(o=>{n(o),Kr(o),q1(o)},[]);return l.useEffect(()=>{Kr(e)},[e]),l.useEffect(()=>{function o(r){if(r.key!==Fi)return;const a=gu(r.newValue);n(a),Kr(a)}return window.addEventListener("storage",o),()=>window.removeEventListener("storage",o)},[]),{themeMode:e,setThemeMode:s}}const Ui="agent-inspector.uiScale",W1=1.25,V1=2200,K1=3e3,G1=12;function Gr(e,n){return Number.isFinite(e)&&e>0?e:n}function Bi(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 J1(e,n){switch(e){case"100":return 1;case"125":return 1.25;case"150":return 1.5;case"auto":{const s=Gr(n.viewportWidth,1280),o=Gr(n.screenWidth,s),r=Gr(n.devicePixelRatio,1),a=Math.min(s,o);return r>W1?1:a>=K1?1.25:a>=V1?1.125:1}}}function Y1(e){return`${Math.round(e*100)}%`}function Jr(e,n){return Math.max(G1,e*n)}function X1(){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 Yr(e){const n=J1(e,X1());if(typeof document>"u")return n;const s=document.documentElement;return s.dataset.uiScale=e,s.dataset.uiScaleResolved=String(Math.round(n*100)),s.style.setProperty("--inspector-ui-scale",String(n)),s.style.setProperty("--inspector-root-font-size",`${String(16*n)}px`),s.style.setProperty("--inspector-font-9",`${String(Jr(9,n))}px`),s.style.setProperty("--inspector-font-10",`${String(Jr(10,n))}px`),s.style.setProperty("--inspector-font-11",`${String(Jr(11,n))}px`),s.style.setProperty("--inspector-font-13",`${String(13*n)}px`),n}function Z1(){if(typeof window>"u")return"auto";try{return Bi(window.localStorage.getItem(Ui))}catch{return"auto"}}function Q1(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Ui,e)}catch{}}function eb(){const[e,n]=l.useState(Z1),[s,o]=l.useState(1),r=l.useCallback(a=>{n(a),Q1(a),o(Yr(a))},[]);return l.useEffect(()=>{const a=()=>{o(Yr(e))};if(a(),e==="auto")return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[e]),l.useEffect(()=>{const a=i=>{if(i.key!==Ui)return;const c=Bi(i.newValue);n(c),o(Yr(c))};return window.addEventListener("storage",a),()=>window.removeEventListener("storage",a)},[]),{uiScalePreference:e,resolvedUiScale:s,setUiScalePreference:r}}const _n=64,Ha=256,tb=64,nb=ue(["invalid-page-request","search-limit-exceeded","provider-model-limit-exceeded","sse-capacity-exceeded","provider-test-capacity-exceeded","proxy-capacity-exceeded"]),sb=Ot([re(400),re(413),re(429),re(503)]);T({error:x().min(1).max(300),code:nb,status:sb,resource:x().min(1).max(80),limit:E().int().positive(),retryable:_e()});function so(){return x().refine(e=>{if(e.length===0)return!0;try{const n=new URL(e);return n.protocol==="http:"||n.protocol==="https:"}catch{return!1}},"Must be a valid http(s) URL")}const qi=x().max(Ha),ob=K(qi).max(_n),rb=T({model:qi.min(1),contextWindow:E().int().positive().optional(),outputLimit:E().int().positive().optional(),source:ue(["manual","registry"]).optional(),sourceUrl:x().optional(),updatedAt:x().optional()}),ab=K(rb).max(tb),ib=T({id:x(),name:x(),apiKey:x(),model:qi.optional(),models:ob.optional().default([]),format:ue(["anthropic","openai"]).optional(),baseUrl:so().optional(),anthropicBaseUrl:so().optional(),openaiBaseUrl:so().optional(),openaiResponsesBaseUrl:so().optional(),authHeader:ue(["bearer","x-api-key"]).optional().default("bearer"),apiDocsUrl:x().optional(),modelMetadataUrl:x().optional(),modelMetadata:ab.optional(),source:ue(["company","personal"]).optional(),createdAt:x(),updatedAt:x()}),lb="configured",Wo=ib.extend({apiKey:re(lb)});async function cb(e){return Ge(e,Wo.array(),void 0,n=>`Failed to fetch ${e}: ${n.status}`)}function Hi(){const e=Et("/api/providers",cb,{revalidateOnFocus:!1,revalidateIfStale:!1});return{providers:e.data??[],isLoading:e.isLoading,isError:e.error,mutate:e.mutate}}function Wl(e,n){if(typeof e=="function")return e(n);e!=null&&(e.current=n)}function db(...e){return n=>{let s=!1;const o=e.map(r=>{const a=Wl(r,n);return!s&&typeof a=="function"&&(s=!0),a});if(s)return()=>{for(let r=0;r<o.length;r++){const a=o[r];typeof a=="function"?a():Wl(e[r],null)}}}}function Te(...e){return l.useCallback(db(...e),e)}function rs(e){const n=l.forwardRef((s,o)=>{let{children:r,...a}=s,i=null,c=!1;const d=[];Vl(r)&&typeof oo=="function"&&(r=oo(r._payload)),l.Children.forEach(r,f=>{if(xb(f)){c=!0;const h=f;let g="child"in h.props?h.props.child:h.props.children;Vl(g)&&typeof oo=="function"&&(g=oo(g._payload)),i=pb(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?hb(i):void 0,u=Te(o,m);if(!i){if(r||r===0)throw new Error(c?yb(e):vb(e));return r}const p=fb(a,i.props??{});return i.type!==l.Fragment&&(p.ref=o?u:m),l.cloneElement(i,p)});return n.displayName=`${e}.Slot`,n}var ub=rs("Slot"),bu=Symbol.for("radix.slottable");function mb(e){const n=s=>"child"in s?s.children(s.child):s.children;return n.displayName=`${e}.Slottable`,n.__radixId=bu,n}var pb=(e,n)=>{if("child"in e.props){const s=e.props.child;return l.isValidElement(s)?l.cloneElement(s,void 0,e.props.children(s.props.children)):null}return l.isValidElement(n)?n:null};function fb(e,n){const s={...n};for(const o in n){const r=e[o],a=n[o];/^on[A-Z]/.test(o)?r&&a?s[o]=(...c)=>{const d=a(...c);return r(...c),d}:r&&(s[o]=r):o==="style"?s[o]={...r,...a}:o==="className"&&(s[o]=[r,a].filter(Boolean).join(" "))}return{...e,...s}}function hb(e){let n=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,s=n&&"isReactWarning"in n&&n.isReactWarning;return s?e.ref:(n=Object.getOwnPropertyDescriptor(e,"ref")?.get,s=n&&"isReactWarning"in n&&n.isReactWarning,s?e.props.ref:e.props.ref||e.ref)}function xb(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===bu}var gb=Symbol.for("react.lazy");function Vl(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===gb&&"_payload"in e&&bb(e._payload)}function bb(e){return typeof e=="object"&&e!==null&&"then"in e}var vb=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,yb=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,oo=mr[" use ".trim().toString()],wb=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],xe=wb.reduce((e,n)=>{const s=rs(`Primitive.${n}`),o=l.forwardRef((r,a)=>{const{asChild:i,...c}=r,d=i?s:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),t.jsx(d,{...c,ref:a})});return o.displayName=`Primitive.${n}`,{...e,[n]:o}},{});function jb(e,n){e&&ms.flushSync(()=>e.dispatchEvent(n))}var vu=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"}),Sb="VisuallyHidden",yu=l.forwardRef((e,n)=>t.jsx(xe.span,{...e,ref:n,style:{...vu,...e.style}}));yu.displayName=Sb;var Nb=yu;function Jt(e,n=[]){let s=[];function o(a,i){const c=l.createContext(i);c.displayName=a+"Context";const d=s.length;s=[...s,i];const m=p=>{const{scope:f,children:h,...g}=p,b=f?.[e]?.[d]||c,y=l.useMemo(()=>g,Object.values(g));return t.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,Cb(r,...n)]}function Cb(...e){const n=e[0];if(e.length===1)return n;const s=()=>{const o=e.map(r=>({useScope:r(),scopeName:r.scopeName}));return function(a){const i=o.reduce((c,{useScope:d,scopeName:m})=>{const p=d(a)[`__scope${m}`];return{...c,...p}},{});return l.useMemo(()=>({[`__scope${n.scopeName}`]:i}),[i])}};return s.scopeName=n.scopeName,s}function wu(e){const n=e+"CollectionProvider",[s,o]=Jt(n),[r,a]=s(n,{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 t.jsx(r,{scope:y,itemMap:j,collectionRef:v,children:w})};i.displayName=n;const c=e+"CollectionSlot",d=rs(c),m=l.forwardRef((b,y)=>{const{scope:w,children:v}=b,j=a(c,w),S=Te(y,j.collectionRef);return t.jsx(d,{ref:S,children:v})});m.displayName=c;const u=e+"CollectionItemSlot",p="data-radix-collection-item",f=rs(u),h=l.forwardRef((b,y)=>{const{scope:w,children:v,...j}=b,S=l.useRef(null),N=Te(y,S),C=a(u,w);return l.useEffect(()=>(C.itemMap.set(S,{ref:S,...j}),()=>{C.itemMap.delete(S)})),t.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,R)=>j.indexOf(C.ref.current)-j.indexOf(R.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:i,Slot:m,ItemSlot:h},g,o]}function de(e,n,{checkForDefaultPrevented:s=!0}={}){return function(r){if(e?.(r),s===!1||!r||!r.defaultPrevented)return n?.(r)}}var Ue=globalThis?.document?l.useLayoutEffect:()=>{},kb=mr[" useInsertionEffect ".trim().toString()]||Ue;function En({prop:e,defaultProp:n,onChange:s=()=>{},caller:o}){const[r,a,i]=_b({defaultProp:n,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=Tb(u)?u(e):u;p!==e&&i.current?.(p)}else a(u)},[c,e,a,i]);return[d,m]}function _b({defaultProp:e,onChange:n}){const[s,o]=l.useState(e),r=l.useRef(s),a=l.useRef(n);return kb(()=>{a.current=n},[n]),l.useEffect(()=>{r.current!==s&&(a.current?.(s),r.current=s)},[s,r]),[s,o,a]}function Tb(e){return typeof e=="function"}function Eb(e,n){return l.useReducer((s,o)=>n[s][o]??s,e)}var lt=e=>{const{present:n,children:s}=e,o=Rb(n),r=typeof s=="function"?s({present:o.isPresent}):l.Children.only(s),a=Mb(o.ref,Ab(r));return typeof s=="function"||o.isPresent?l.cloneElement(r,{ref:a}):null};lt.displayName="Presence";function Rb(e){const[n,s]=l.useState(),o=l.useRef(null),r=l.useRef(e),a=l.useRef("none"),i=l.useRef(void 0),c=e?"mounted":"unmounted",[d,m]=Eb(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??bs(o.current),i.current=void 0):a.current="none"},[d]),Ue(()=>{const u=o.current,p=r.current;if(p!==e){const h=a.current,g=bs(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]),Ue(()=>{if(n){let u;const p=n.ownerDocument.defaultView??window,f=g=>{const y=bs(o.current).includes(CSS.escape(g.animationName));if(g.target===n&&y&&(m("ANIMATION_END"),!r.current)){const w=n.style.animationFillMode;n.style.animationFillMode="forwards",u=p.setTimeout(()=>{n.style.animationFillMode==="forwards"&&(n.style.animationFillMode=w)})}},h=g=>{g.target===n&&(a.current=bs(o.current))};return n.addEventListener("animationstart",h),n.addEventListener("animationcancel",f),n.addEventListener("animationend",f),()=>{p.clearTimeout(u),n.removeEventListener("animationstart",h),n.removeEventListener("animationcancel",f),n.removeEventListener("animationend",f)}}else m("ANIMATION_END")},[n,m]),{isPresent:["mounted","unmountSuspended"].includes(d),ref:l.useCallback(u=>{if(u){const p=getComputedStyle(u);o.current=p,i.current=bs(p)}else o.current=null;s(u)},[])}}function Kl(e,n){if(typeof e=="function")return e(n);e!=null&&(e.current=n)}function Mb(...e){const n=l.useRef(e);return n.current=e,l.useCallback(s=>{const o=n.current;let r=!1;const a=o.map(i=>{const c=Kl(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():Kl(o[i],null)}}},[])}function bs(e){return e?.animationName||"none"}function Ab(e){let n=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,s=n&&"isReactWarning"in n&&n.isReactWarning;return s?e.ref:(n=Object.getOwnPropertyDescriptor(e,"ref")?.get,s=n&&"isReactWarning"in n&&n.isReactWarning,s?e.props.ref:e.props.ref||e.ref)}var Ib=mr[" useId ".trim().toString()]||(()=>{}),Pb=0;function Rt(e){const[n,s]=l.useState(Ib());return Ue(()=>{s(o=>o??String(Pb++))},[e]),e||(n?`radix-${n}`:"")}var xr="Collapsible",[Lb]=Jt(xr),[Ob,Wi]=Lb(xr),ju=l.forwardRef((e,n)=>{const{__scopeCollapsible:s,open:o,defaultOpen:r,disabled:a,onOpenChange:i,...c}=e,[d,m]=En({prop:o,defaultProp:r??!1,onChange:i,caller:xr});return t.jsx(Ob,{scope:s,disabled:a,contentId:Rt(),open:d,onOpenToggle:l.useCallback(()=>m(u=>!u),[m]),children:t.jsx(xe.div,{"data-state":Ki(d),"data-disabled":a?"":void 0,...c,ref:n})})});ju.displayName=xr;var Su="CollapsibleTrigger",Nu=l.forwardRef((e,n)=>{const{__scopeCollapsible:s,...o}=e,r=Wi(Su,s);return t.jsx(xe.button,{type:"button","aria-controls":r.open?r.contentId:void 0,"aria-expanded":r.open||!1,"data-state":Ki(r.open),"data-disabled":r.disabled?"":void 0,disabled:r.disabled,...o,ref:n,onClick:de(e.onClick,r.onOpenToggle)})});Nu.displayName=Su;var Vi="CollapsibleContent",Cu=l.forwardRef((e,n)=>{const{forceMount:s,...o}=e,r=Wi(Vi,e.__scopeCollapsible);return t.jsx(lt,{present:s||r.open,children:({present:a})=>t.jsx(Db,{...o,ref:n,present:a})})});Cu.displayName=Vi;var Db=l.forwardRef((e,n)=>{const{__scopeCollapsible:s,present:o,children:r,...a}=e,i=Wi(Vi,s),[c,d]=l.useState(o),m=l.useRef(null),u=Te(n,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)},[]),Ue(()=>{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]),t.jsx(xe.div,{"data-state":Ki(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 Ki(e){return e?"open":"closed"}var zb=ju,$b=l.createContext(void 0);function gr(e){const n=l.useContext($b);return e||n||"ltr"}function He(e){const n=l.useRef(e);return l.useEffect(()=>{n.current=e}),l.useMemo(()=>((...s)=>n.current?.(...s)),[])}var Fb="DismissableLayer",Wa="dismissableLayer.update",Ub="dismissableLayer.pointerDownOutside",Bb="dismissableLayer.focusOutside",Gl,Gi=l.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),br=l.forwardRef((e,n)=>{const{disableOutsidePointerEvents:s=!1,deferPointerDownOutside:o=!1,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:c,onDismiss:d,...m}=e,u=l.useContext(Gi),[p,f]=l.useState(null),h=p?.ownerDocument??globalThis?.document,[,g]=l.useState({}),b=Te(n,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),R=Kb(k=>{a?.(k),c?.(k),k.defaultPrevented||d?.()},{ownerDocument:h,deferPointerDownOutside:o,isDeferredPointerDownOutsideRef:C,dismissableSurfaces:u.dismissableSurfaces,shouldHandlePointerDownOutside:l.useCallback(k=>{if(!(k instanceof Node))return!1;const A=[...u.branches].some(D=>D.contains(k));return N&&!A},[u.branches,N])}),I=Gb(k=>{if(o&&C.current)return;const A=k.target;[...u.branches].some($=>$.contains(A))||(i?.(k),c?.(k),k.defaultPrevented||d?.())},h),P=p?j===y.length-1:!1,M=He(k=>{k.key==="Escape"&&(r?.(k),!k.defaultPrevented&&d&&(k.preventDefault(),d()))});return l.useEffect(()=>{if(P)return h.addEventListener("keydown",M,{capture:!0}),()=>h.removeEventListener("keydown",M,{capture:!0})},[h,P,M]),l.useEffect(()=>{if(p)return s&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Gl=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(p)),u.layers.add(p),Jl(),()=>{s&&(u.layersWithOutsidePointerEventsDisabled.delete(p),u.layersWithOutsidePointerEventsDisabled.size===0&&(h.body.style.pointerEvents=Gl))}},[p,h,s,u]),l.useEffect(()=>()=>{p&&(u.layers.delete(p),u.layersWithOutsidePointerEventsDisabled.delete(p),Jl())},[p,u]),l.useEffect(()=>{const k=()=>g({});return document.addEventListener(Wa,k),()=>document.removeEventListener(Wa,k)},[]),t.jsx(xe.div,{...m,ref:b,style:{pointerEvents:S?N?"auto":"none":void 0,...e.style},onFocusCapture:de(e.onFocusCapture,I.onFocusCapture),onBlurCapture:de(e.onBlurCapture,I.onBlurCapture),onPointerDownCapture:de(e.onPointerDownCapture,R.onPointerDownCapture)})});br.displayName=Fb;var qb="DismissableLayerBranch",Hb=l.forwardRef((e,n)=>{const s=l.useContext(Gi),o=l.useRef(null),r=Te(n,o);return l.useEffect(()=>{const a=o.current;if(a)return s.branches.add(a),()=>{s.branches.delete(a)}},[s.branches]),t.jsx(xe.div,{...e,ref:r})});Hb.displayName=qb;function Wb(){const e=l.useContext(Gi),[n,s]=l.useState(null);return l.useEffect(()=>{if(n)return e.dismissableSurfaces.add(n),()=>{e.dismissableSurfaces.delete(n)}},[n,e.dismissableSurfaces]),s}var Vb=()=>!0;function Kb(e,n){const{ownerDocument:s=globalThis?.document,deferPointerDownOutside:o=!1,isDeferredPointerDownOutsideRef:r,dismissableSurfaces:a,shouldHandlePointerDownOutside:i=Vb}=n,c=He(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||ku(Ub,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 Gb(e,n=globalThis?.document){const s=He(e),o=l.useRef(!1);return l.useEffect(()=>{const r=a=>{a.target&&!o.current&&ku(Bb,s,{originalEvent:a},{discrete:!1})};return n.addEventListener("focusin",r),()=>n.removeEventListener("focusin",r)},[n,s]),{onFocusCapture:()=>o.current=!0,onBlurCapture:()=>o.current=!1}}function Jl(){const e=new CustomEvent(Wa);document.dispatchEvent(e)}function ku(e,n,s,{discrete:o}){const r=s.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:s});n&&r.addEventListener(e,n,{once:!0}),o?jb(r,a):r.dispatchEvent(a)}var Xr="focusScope.autoFocusOnMount",Zr="focusScope.autoFocusOnUnmount",Yl={bubbles:!1,cancelable:!0},Jb="FocusScope",Ji=l.forwardRef((e,n)=>{const{loop:s=!1,trapped:o=!1,onMountAutoFocus:r,onUnmountAutoFocus:a,...i}=e,[c,d]=l.useState(null),m=He(r),u=He(a),p=l.useRef(null),f=Te(n,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:en(p.current,{select:!0})},y=function(j){if(h.paused||!c)return;const S=j.relatedTarget;S!==null&&(c.contains(S)||en(p.current,{select:!0}))},w=function(j){if(document.activeElement===document.body)for(const N of j)N.removedNodes.length>0&&en(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){Zl.add(h);const b=document.activeElement;if(!c.contains(b)){const w=new CustomEvent(Xr,Yl);c.addEventListener(Xr,m),c.dispatchEvent(w),w.defaultPrevented||(Yb(tv(_u(c)),{select:!0}),document.activeElement===b&&en(c))}return()=>{c.removeEventListener(Xr,m),setTimeout(()=>{const w=new CustomEvent(Zr,Yl);c.addEventListener(Zr,u),c.dispatchEvent(w),w.defaultPrevented||en(b??document.body,{select:!0}),c.removeEventListener(Zr,u),Zl.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]=Xb(v);j&&S?!b.shiftKey&&w===S?(b.preventDefault(),s&&en(j,{select:!0})):b.shiftKey&&w===j&&(b.preventDefault(),s&&en(S,{select:!0})):w===v&&b.preventDefault()}},[s,o,h.paused]);return t.jsx(xe.div,{tabIndex:-1,...i,ref:f,onKeyDown:g})});Ji.displayName=Jb;function Yb(e,{select:n=!1}={}){const s=document.activeElement;for(const o of e)if(en(o,{select:n}),document.activeElement!==s)return}function Xb(e){const n=_u(e),s=Xl(n,e),o=Xl(n.reverse(),e);return[s,o]}function _u(e){const n=[],s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:o=>{const r=o.tagName==="INPUT"&&o.type==="hidden";return o.disabled||o.hidden||r?NodeFilter.FILTER_SKIP:o.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;s.nextNode();)n.push(s.currentNode);return n}function Xl(e,n){const s=typeof n.checkVisibility=="function"&&n.checkVisibility({checkVisibilityCSS:!0});for(const o of e)if(!(s?!o.checkVisibility({checkVisibilityCSS:!0}):Zb(o,{upTo:n})))return o}function Zb(e,{upTo:n}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(n!==void 0&&e===n)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Qb(e){return e instanceof HTMLInputElement&&"select"in e}function en(e,{select:n=!1}={}){if(e&&e.focus){const s=document.activeElement;e.focus({preventScroll:!0}),e!==s&&Qb(e)&&n&&e.select()}}var Zl=ev();function ev(){let e=[];return{add(n){const s=e[0];n!==s&&s?.pause(),e=Ql(e,n),e.unshift(n)},remove(n){e=Ql(e,n),e[0]?.resume()}}}function Ql(e,n){const s=[...e],o=s.indexOf(n);return o!==-1&&s.splice(o,1),s}function tv(e){return e.filter(n=>n.tagName!=="A")}var nv="Portal",vr=l.forwardRef((e,n)=>{const{container:s,...o}=e,[r,a]=l.useState(!1);Ue(()=>a(!0),[]);const i=s||r&&globalThis?.document?.body;return i?ms.createPortal(t.jsx(xe.div,{...o,ref:n}),i):null});vr.displayName=nv;var ro=0,Dn=null;function Tu(){l.useEffect(()=>{Dn||(Dn={start:ec(),end:ec()});const{start:e,end:n}=Dn;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==n&&document.body.insertAdjacentElement("beforeend",n),ro++,()=>{ro===1&&(Dn?.start.remove(),Dn?.end.remove(),Dn=null),ro=Math.max(0,ro-1)}},[])}function ec(){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 _t=function(){return _t=Object.assign||function(n){for(var s,o=1,r=arguments.length;o<r;o++){s=arguments[o];for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(n[a]=s[a])}return n},_t.apply(this,arguments)};function Eu(e,n){var s={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&n.indexOf(o)<0&&(s[o]=e[o]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,o=Object.getOwnPropertySymbols(e);r<o.length;r++)n.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(s[o[r]]=e[o[r]]);return s}function sv(e,n,s){if(s||arguments.length===2)for(var o=0,r=n.length,a;o<r;o++)(a||!(o in n))&&(a||(a=Array.prototype.slice.call(n,0,o)),a[o]=n[o]);return e.concat(a||Array.prototype.slice.call(n))}var Ro="right-scroll-bar-position",Mo="width-before-scroll-bar",ov="with-scroll-bars-hidden",rv="--removed-body-scroll-bar-size";function Qr(e,n){return typeof e=="function"?e(n):e&&(e.current=n),e}function av(e,n){var s=l.useState(function(){return{value:e,callback:n,facade:{get current(){return s.value},set current(o){var r=s.value;r!==o&&(s.value=o,s.callback(o,r))}}}})[0];return s.callback=n,s.facade}var iv=typeof window<"u"?l.useLayoutEffect:l.useEffect,tc=new WeakMap;function lv(e,n){var s=av(null,function(o){return e.forEach(function(r){return Qr(r,o)})});return iv(function(){var o=tc.get(s);if(o){var r=new Set(o),a=new Set(e),i=s.current;r.forEach(function(c){a.has(c)||Qr(c,null)}),a.forEach(function(c){r.has(c)||Qr(c,i)})}tc.set(s,e)},[e]),s}function cv(e){return e}function dv(e,n){n===void 0&&(n=cv);var s=[],o=!1,r={read:function(){if(o)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return s.length?s[s.length-1]:e},useMedium:function(a){var i=n(a,o);return s.push(i),function(){s=s.filter(function(c){return c!==i})}},assignSyncMedium:function(a){for(o=!0;s.length;){var i=s;s=[],i.forEach(a)}s={push:function(c){return a(c)},filter:function(){return s}}},assignMedium:function(a){o=!0;var i=[];if(s.length){var c=s;s=[],c.forEach(a),i=s}var d=function(){var u=i;i=[],u.forEach(a)},m=function(){return Promise.resolve().then(d)};m(),s={push:function(u){i.push(u),m()},filter:function(u){return i=i.filter(u),s}}}};return r}function uv(e){e===void 0&&(e={});var n=dv(null);return n.options=_t({async:!0,ssr:!1},e),n}var Ru=function(e){var n=e.sideCar,s=Eu(e,["sideCar"]);if(!n)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var o=n.read();if(!o)throw new Error("Sidecar medium not found");return l.createElement(o,_t({},s))};Ru.isSideCarExport=!0;function mv(e,n){return e.useMedium(n),Ru}var Mu=uv(),ea=function(){},yr=l.forwardRef(function(e,n){var s=l.useRef(null),o=l.useState({onScrollCapture:ea,onWheelCapture:ea,onTouchMoveCapture:ea}),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=Eu(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),N=f,C=lv([s,n]),R=_t(_t({},S),r);return l.createElement(l.Fragment,null,u&&l.createElement(N,{sideCar:Mu,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),_t(_t({},R),{ref:C})):l.createElement(v,_t({},R,{className:d,ref:C}),c))});yr.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};yr.classNames={fullWidth:Mo,zeroRight:Ro};var pv=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function fv(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var n=pv();return n&&e.setAttribute("nonce",n),e}function hv(e,n){e.styleSheet?e.styleSheet.cssText=n:e.appendChild(document.createTextNode(n))}function xv(e){var n=document.head||document.getElementsByTagName("head")[0];n.appendChild(e)}var gv=function(){var e=0,n=null;return{add:function(s){e==0&&(n=fv())&&(hv(n,s),xv(n)),e++},remove:function(){e--,!e&&n&&(n.parentNode&&n.parentNode.removeChild(n),n=null)}}},bv=function(){var e=gv();return function(n,s){l.useEffect(function(){return e.add(n),function(){e.remove()}},[n&&s])}},Au=function(){var e=bv(),n=function(s){var o=s.styles,r=s.dynamic;return e(o,r),null};return n},vv={left:0,top:0,right:0,gap:0},ta=function(e){return parseInt(e||"",10)||0},yv=function(e){var n=window.getComputedStyle(document.body),s=n[e==="padding"?"paddingLeft":"marginLeft"],o=n[e==="padding"?"paddingTop":"marginTop"],r=n[e==="padding"?"paddingRight":"marginRight"];return[ta(s),ta(o),ta(r)]},wv=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return vv;var n=yv(e),s=document.documentElement.clientWidth,o=window.innerWidth;return{left:n[0],top:n[1],right:n[2],gap:Math.max(0,o-s+n[2]-n[0])}},jv=Au(),Zn="data-scroll-locked",Sv=function(e,n,s,o){var r=e.left,a=e.top,i=e.right,c=e.gap;return s===void 0&&(s="margin"),`
|
|
3
|
-
.`.concat(ov,` {
|
|
4
|
-
overflow: hidden `).concat(o,`;
|
|
5
|
-
padding-right: `).concat(c,"px ").concat(o,`;
|
|
6
|
-
}
|
|
7
|
-
body[`).concat(Zn,`] {
|
|
8
|
-
overflow: hidden `).concat(o,`;
|
|
9
|
-
overscroll-behavior: contain;
|
|
10
|
-
`).concat([n&&"position: relative ".concat(o,";"),s==="margin"&&`
|
|
11
|
-
padding-left: `.concat(r,`px;
|
|
12
|
-
padding-top: `).concat(a,`px;
|
|
13
|
-
padding-right: `).concat(i,`px;
|
|
14
|
-
margin-left:0;
|
|
15
|
-
margin-top:0;
|
|
16
|
-
margin-right: `).concat(c,"px ").concat(o,`;
|
|
17
|
-
`),s==="padding"&&"padding-right: ".concat(c,"px ").concat(o,";")].filter(Boolean).join(""),`
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.`).concat(Ro,` {
|
|
21
|
-
right: `).concat(c,"px ").concat(o,`;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.`).concat(Mo,` {
|
|
25
|
-
margin-right: `).concat(c,"px ").concat(o,`;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.`).concat(Ro," .").concat(Ro,` {
|
|
29
|
-
right: 0 `).concat(o,`;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.`).concat(Mo," .").concat(Mo,` {
|
|
33
|
-
margin-right: 0 `).concat(o,`;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
body[`).concat(Zn,`] {
|
|
37
|
-
`).concat(rv,": ").concat(c,`px;
|
|
38
|
-
}
|
|
39
|
-
`)},nc=function(){var e=parseInt(document.body.getAttribute(Zn)||"0",10);return isFinite(e)?e:0},Nv=function(){l.useEffect(function(){return document.body.setAttribute(Zn,(nc()+1).toString()),function(){var e=nc()-1;e<=0?document.body.removeAttribute(Zn):document.body.setAttribute(Zn,e.toString())}},[])},Cv=function(e){var n=e.noRelative,s=e.noImportant,o=e.gapMode,r=o===void 0?"margin":o;Nv();var a=l.useMemo(function(){return wv(r)},[r]);return l.createElement(jv,{styles:Sv(a,!n,r,s?"":"!important")})},Va=!1;if(typeof window<"u")try{var ao=Object.defineProperty({},"passive",{get:function(){return Va=!0,!0}});window.addEventListener("test",ao,ao),window.removeEventListener("test",ao,ao)}catch{Va=!1}var zn=Va?{passive:!1}:!1,kv=function(e){return e.tagName==="TEXTAREA"},Iu=function(e,n){if(!(e instanceof Element))return!1;var s=window.getComputedStyle(e);return s[n]!=="hidden"&&!(s.overflowY===s.overflowX&&!kv(e)&&s[n]==="visible")},_v=function(e){return Iu(e,"overflowY")},Tv=function(e){return Iu(e,"overflowX")},sc=function(e,n){var s=n.ownerDocument,o=n;do{typeof ShadowRoot<"u"&&o instanceof ShadowRoot&&(o=o.host);var r=Pu(e,o);if(r){var a=Lu(e,o),i=a[1],c=a[2];if(i>c)return!0}o=o.parentNode}while(o&&o!==s.body);return!1},Ev=function(e){var n=e.scrollTop,s=e.scrollHeight,o=e.clientHeight;return[n,s,o]},Rv=function(e){var n=e.scrollLeft,s=e.scrollWidth,o=e.clientWidth;return[n,s,o]},Pu=function(e,n){return e==="v"?_v(n):Tv(n)},Lu=function(e,n){return e==="v"?Ev(n):Rv(n)},Mv=function(e,n){return e==="h"&&n==="rtl"?-1:1},Av=function(e,n,s,o,r){var a=Mv(e,window.getComputedStyle(n).direction),i=a*o,c=s.target,d=n.contains(c),m=!1,u=i>0,p=0,f=0;do{if(!c)break;var h=Lu(e,c),g=h[0],b=h[1],y=h[2],w=b-y-a*g;(g||w)&&Pu(e,c)&&(p+=w,f+=g);var v=c.parentNode;c=v&&v.nodeType===Node.DOCUMENT_FRAGMENT_NODE?v.host:v}while(!d&&c!==document.body||d&&(n.contains(c)||n===c));return(u&&Math.abs(p)<1||!u&&Math.abs(f)<1)&&(m=!0),m},io=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},oc=function(e){return[e.deltaX,e.deltaY]},rc=function(e){return e&&"current"in e?e.current:e},Iv=function(e,n){return e[0]===n[0]&&e[1]===n[1]},Pv=function(e){return`
|
|
40
|
-
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
41
|
-
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
42
|
-
`)},Lv=0,$n=[];function Ov(e){var n=l.useRef([]),s=l.useRef([0,0]),o=l.useRef(),r=l.useState(Lv++)[0],a=l.useState(Au)[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=sv([e.lockRef.current],(e.shards||[]).map(rc),!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=io(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,R=Math.abs(j)>Math.abs(S)?"h":"v";if("touches"in b&&R==="h"&&C.type==="range")return!1;var I=window.getSelection(),P=I&&I.anchorNode,M=P?P===C||P.contains(C):!1;if(M)return!1;var k=sc(R,C);if(!k)return!0;if(k?N=R:(N=R==="v"?"h":"v",k=sc(R,C)),!k)return!1;if(!o.current&&"changedTouches"in b&&(j||S)&&(o.current=N),!N)return!0;var A=o.current||N;return Av(A,y,b,A==="h"?j:S)},[]),d=l.useCallback(function(b){var y=b;if(!(!$n.length||$n[$n.length-1]!==a)){var w="deltaY"in y?oc(y):io(y),v=n.current.filter(function(N){return N.name===y.type&&(N.target===y.target||y.target===N.shadowParent)&&Iv(N.delta,w)})[0];if(v&&v.should){y.cancelable&&y.preventDefault();return}if(!v){var j=(i.current.shards||[]).map(rc).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:Dv(w)};n.current.push(j),setTimeout(function(){n.current=n.current.filter(function(S){return S!==j})},1)},[]),u=l.useCallback(function(b){s.current=io(b),o.current=void 0},[]),p=l.useCallback(function(b){m(b.type,oc(b),b.target,c(b,e.lockRef.current))},[]),f=l.useCallback(function(b){m(b.type,io(b),b.target,c(b,e.lockRef.current))},[]);l.useEffect(function(){return $n.push(a),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:f}),document.addEventListener("wheel",d,zn),document.addEventListener("touchmove",d,zn),document.addEventListener("touchstart",u,zn),function(){$n=$n.filter(function(b){return b!==a}),document.removeEventListener("wheel",d,zn),document.removeEventListener("touchmove",d,zn),document.removeEventListener("touchstart",u,zn)}},[]);var h=e.removeScrollBar,g=e.inert;return l.createElement(l.Fragment,null,g?l.createElement(a,{styles:Pv(r)}):null,h?l.createElement(Cv,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Dv(e){for(var n=null;e!==null;)e instanceof ShadowRoot&&(n=e.host,e=e.host),e=e.parentNode;return n}const zv=mv(Mu,Ov);var Yi=l.forwardRef(function(e,n){return l.createElement(yr,_t({},e,{ref:n,sideCar:zv}))});Yi.classNames=yr.classNames;var $v=function(e){if(typeof document>"u")return null;var n=Array.isArray(e)?e[0]:e;return n.ownerDocument.body},Fn=new WeakMap,lo=new WeakMap,co={},na=0,Ou=function(e){return e&&(e.host||Ou(e.parentNode))},Fv=function(e,n){return n.map(function(s){if(e.contains(s))return s;var o=Ou(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})},Uv=function(e,n,s,o){var r=Fv(n,Array.isArray(e)?e:[e]);co[s]||(co[s]=new WeakMap);var a=co[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=(Fn.get(f)||0)+1,y=(a.get(f)||0)+1;Fn.set(f,b),a.set(f,y),i.push(f),b===1&&g&&lo.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(n),c.clear(),na++,function(){i.forEach(function(p){var f=Fn.get(p)-1,h=a.get(p)-1;Fn.set(p,f),a.set(p,h),f||(lo.has(p)||p.removeAttribute(o),lo.delete(p)),h||p.removeAttribute(s)}),na--,na||(Fn=new WeakMap,Fn=new WeakMap,lo=new WeakMap,co={})}},Du=function(e,n,s){s===void 0&&(s="data-aria-hidden");var o=Array.from(Array.isArray(e)?e:[e]),r=$v(e);return r?(o.push.apply(o,Array.from(r.querySelectorAll("[aria-live], script"))),Uv(o,r,s,"aria-hidden")):function(){return null}},wr="Dialog",[zu]=Jt(wr),[Bv,Nt]=zu(wr),$u=e=>{const{__scopeDialog:n,children:s,open:o,defaultOpen:r,onOpenChange:a,modal:i=!0}=e,c=l.useRef(null),d=l.useRef(null),[m,u]=En({prop:o,defaultProp:r??!1,onChange:a,caller:wr});return t.jsx(Bv,{scope:n,triggerRef:c,contentRef:d,contentId:Rt(),titleId:Rt(),descriptionId:Rt(),open:m,onOpenChange:u,onOpenToggle:l.useCallback(()=>u(p=>!p),[u]),modal:i,children:s})};$u.displayName=wr;var Fu="DialogTrigger",Uu=l.forwardRef((e,n)=>{const{__scopeDialog:s,...o}=e,r=Nt(Fu,s),a=Te(n,r.triggerRef);return t.jsx(xe.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.open?r.contentId:void 0,"data-state":Zi(r.open),...o,ref:a,onClick:de(e.onClick,r.onOpenToggle)})});Uu.displayName=Fu;var Xi="DialogPortal",[qv,Bu]=zu(Xi,{forceMount:void 0}),qu=e=>{const{__scopeDialog:n,forceMount:s,children:o,container:r}=e,a=Nt(Xi,n);return t.jsx(qv,{scope:n,forceMount:s,children:l.Children.map(o,i=>t.jsx(lt,{present:s||a.open,children:t.jsx(vr,{asChild:!0,container:r,children:i})}))})};qu.displayName=Xi;var Vo="DialogOverlay",Hu=l.forwardRef((e,n)=>{const s=Bu(Vo,e.__scopeDialog),{forceMount:o=s.forceMount,...r}=e,a=Nt(Vo,e.__scopeDialog);return a.modal?t.jsx(lt,{present:o||a.open,children:t.jsx(Wv,{...r,ref:n})}):null});Hu.displayName=Vo;var Hv=rs("DialogOverlay.RemoveScroll"),Wv=l.forwardRef((e,n)=>{const{__scopeDialog:s,...o}=e,r=Nt(Vo,s),a=Wb(),i=Te(n,a);return t.jsx(Yi,{as:Hv,allowPinchZoom:!0,shards:[r.contentRef],children:t.jsx(xe.div,{"data-state":Zi(r.open),...o,ref:i,style:{pointerEvents:"auto",...o.style}})})}),as="DialogContent",Wu=l.forwardRef((e,n)=>{const s=Bu(as,e.__scopeDialog),{forceMount:o=s.forceMount,...r}=e,a=Nt(as,e.__scopeDialog);return t.jsx(lt,{present:o||a.open,children:a.modal?t.jsx(Vv,{...r,ref:n}):t.jsx(Kv,{...r,ref:n})})});Wu.displayName=as;var Vv=l.forwardRef((e,n)=>{const s=Nt(as,e.__scopeDialog),o=l.useRef(null),r=Te(n,s.contentRef,o);return l.useEffect(()=>{const a=o.current;if(a)return Du(a)},[]),t.jsx(Vu,{...e,ref:r,trapFocus:s.open,disableOutsidePointerEvents:s.open,onCloseAutoFocus:de(e.onCloseAutoFocus,a=>{a.preventDefault(),s.triggerRef.current?.focus()}),onPointerDownOutside:de(e.onPointerDownOutside,a=>{const i=a.detail.originalEvent,c=i.button===0&&i.ctrlKey===!0;(i.button===2||c)&&a.preventDefault()}),onFocusOutside:de(e.onFocusOutside,a=>a.preventDefault())})}),Kv=l.forwardRef((e,n)=>{const s=Nt(as,e.__scopeDialog),o=l.useRef(!1),r=l.useRef(!1);return t.jsx(Vu,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{e.onCloseAutoFocus?.(a),a.defaultPrevented||(o.current||s.triggerRef.current?.focus(),a.preventDefault()),o.current=!1,r.current=!1},onInteractOutside:a=>{e.onInteractOutside?.(a),a.defaultPrevented||(o.current=!0,a.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const i=a.target;s.triggerRef.current?.contains(i)&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&r.current&&a.preventDefault()}})}),Vu=l.forwardRef((e,n)=>{const{__scopeDialog:s,trapFocus:o,onOpenAutoFocus:r,onCloseAutoFocus:a,...i}=e,c=Nt(as,s);return Tu(),t.jsx(t.Fragment,{children:t.jsx(Ji,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:r,onUnmountAutoFocus:a,children:t.jsx(br,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":Zi(c.open),...i,ref:n,deferPointerDownOutside:!0,onDismiss:()=>c.onOpenChange(!1)})})})}),Ku="DialogTitle",Gu=l.forwardRef((e,n)=>{const{__scopeDialog:s,...o}=e,r=Nt(Ku,s);return t.jsx(xe.h2,{id:r.titleId,...o,ref:n})});Gu.displayName=Ku;var Ju="DialogDescription",Yu=l.forwardRef((e,n)=>{const{__scopeDialog:s,...o}=e,r=Nt(Ju,s);return t.jsx(xe.p,{id:r.descriptionId,...o,ref:n})});Yu.displayName=Ju;var Xu="DialogClose",Zu=l.forwardRef((e,n)=>{const{__scopeDialog:s,...o}=e,r=Nt(Xu,s);return t.jsx(xe.button,{type:"button",...o,ref:n,onClick:de(e.onClick,()=>r.onOpenChange(!1))})});Zu.displayName=Xu;function Zi(e){return e?"open":"closed"}function Gv(e){const n=l.useRef({value:e,previous:e});return l.useMemo(()=>(n.current.value!==e&&(n.current.previous=n.current.value,n.current.value=e),n.current.previous),[e])}function Jv(e){const[n,s]=l.useState(void 0);return Ue(()=>{if(e){s({width:e.offsetWidth,height:e.offsetHeight});const o=new ResizeObserver(r=>{if(!Array.isArray(r)||!r.length)return;const a=r[0];let i,c;if("borderBoxSize"in a){const d=a.borderBoxSize,m=Array.isArray(d)?d[0]:d;i=m.inlineSize,c=m.blockSize}else i=e.offsetWidth,c=e.offsetHeight;s({width:i,height:c})});return o.observe(e,{box:"border-box"}),()=>o.unobserve(e)}else s(void 0)},[e]),n}const Yv=["top","right","bottom","left"],ln=Math.min,st=Math.max,Ko=Math.round,uo=Math.floor,Mt=e=>({x:e,y:e}),Xv={left:"right",right:"left",bottom:"top",top:"bottom"},Zv={start:"end",end:"start"};function Ka(e,n,s){return st(e,ln(n,s))}function Vt(e,n){return typeof e=="function"?e(n):e}function Kt(e){return e.split("-")[0]}function ps(e){return e.split("-")[1]}function Qi(e){return e==="x"?"y":"x"}function el(e){return e==="y"?"height":"width"}const Qv=new Set(["top","bottom"]);function Tt(e){return Qv.has(Kt(e))?"y":"x"}function tl(e){return Qi(Tt(e))}function e2(e,n,s){s===void 0&&(s=!1);const o=ps(e),r=tl(e),a=el(r);let i=r==="x"?o===(s?"end":"start")?"right":"left":o==="start"?"bottom":"top";return n.reference[a]>n.floating[a]&&(i=Go(i)),[i,Go(i)]}function t2(e){const n=Go(e);return[Ga(e),n,Ga(n)]}function Ga(e){return e.replace(/start|end/g,n=>Zv[n])}const ac=["left","right"],ic=["right","left"],n2=["top","bottom"],s2=["bottom","top"];function o2(e,n,s){switch(e){case"top":case"bottom":return s?n?ic:ac:n?ac:ic;case"left":case"right":return n?n2:s2;default:return[]}}function r2(e,n,s,o){const r=ps(e);let a=o2(Kt(e),s==="start",o);return r&&(a=a.map(i=>i+"-"+r),n&&(a=a.concat(a.map(Ga)))),a}function Go(e){return e.replace(/left|right|bottom|top/g,n=>Xv[n])}function a2(e){return{top:0,right:0,bottom:0,left:0,...e}}function Qu(e){return typeof e!="number"?a2(e):{top:e,right:e,bottom:e,left:e}}function Jo(e){const{x:n,y:s,width:o,height:r}=e;return{width:o,height:r,top:s,left:n,right:n+o,bottom:s+r,x:n,y:s}}function lc(e,n,s){let{reference:o,floating:r}=e;const a=Tt(n),i=tl(n),c=el(i),d=Kt(n),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(ps(n)){case"start":h[i]-=f*(s&&m?-1:1);break;case"end":h[i]+=f*(s&&m?-1:1);break}return h}async function i2(e,n){var s;n===void 0&&(n={});const{x:o,y:r,platform:a,rects:i,elements:c,strategy:d}=e,{boundary:m="clippingAncestors",rootBoundary:u="viewport",elementContext:p="floating",altBoundary:f=!1,padding:h=0}=Vt(n,e),g=Qu(h),y=c[f?p==="floating"?"reference":"floating":p],w=Jo(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=Jo(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 l2=async(e,n,s)=>{const{placement:o="bottom",strategy:r="absolute",middleware:a=[],platform:i}=s,c=a.filter(Boolean),d=await(i.isRTL==null?void 0:i.isRTL(n));let m=await i.getElementRects({reference:e,floating:n,strategy:r}),{x:u,y:p}=lc(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:i2},elements:{reference:e,floating:n}});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:n,strategy:r}):C.rects),{x:u,y:p}=lc(m,f,d)),y=-1)}return{x:u,y:p,placement:f,strategy:r,middlewareData:h}},c2=e=>({name:"arrow",options:e,async fn(n){const{x:s,y:o,placement:r,rects:a,platform:i,elements:c,middlewareData:d}=n,{element:m,padding:u=0}=Vt(e,n)||{};if(m==null)return{};const p=Qu(u),f={x:s,y:o},h=tl(r),g=el(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 R=C?C[j]:0;(!R||!await(i.isElement==null?void 0:i.isElement(C)))&&(R=c.floating[j]||a.floating[g]);const I=S/2-N/2,P=R/2-b[g]/2-1,M=ln(p[w],P),k=ln(p[v],P),A=M,D=R-b[g]-k,$=R/2-b[g]/2+I,J=Ka(A,$,D),X=!d.arrow&&ps(r)!=null&&$!==J&&a.reference[g]/2-($<A?M:k)-b[g]/2<0,F=X?$<A?$-A:$-D:0;return{[h]:f[h]+F,data:{[h]:J,centerOffset:$-J-F,...X&&{alignmentOffset:F}},reset:X}}}),d2=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(n){var s,o;const{placement:r,middlewareData:a,rects:i,initialPlacement:c,platform:d,elements:m}=n,{mainAxis:u=!0,crossAxis:p=!0,fallbackPlacements:f,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:b=!0,...y}=Vt(e,n);if((s=a.arrow)!=null&&s.alignmentOffset)return{};const w=Kt(r),v=Tt(c),j=Kt(c)===c,S=await(d.isRTL==null?void 0:d.isRTL(m.floating)),N=f||(j||!b?[Go(c)]:t2(c)),C=g!=="none";!f&&C&&N.push(...r2(c,b,g,S));const R=[c,...N],I=await d.detectOverflow(n,y),P=[];let M=((o=a.flip)==null?void 0:o.overflows)||[];if(u&&P.push(I[w]),p){const $=e2(r,i,S);P.push(I[$[0]],I[$[1]])}if(M=[...M,{placement:r,overflows:P}],!P.every($=>$<=0)){var k,A;const $=(((k=a.flip)==null?void 0:k.index)||0)+1,J=R[$];if(J&&(!(p==="alignment"?v!==Tt(J):!1)||M.every(H=>Tt(H.placement)===v?H.overflows[0]>0:!0)))return{data:{index:$,overflows:M},reset:{placement:J}};let X=(A=M.filter(F=>F.overflows[0]<=0).sort((F,H)=>F.overflows[1]-H.overflows[1])[0])==null?void 0:A.placement;if(!X)switch(h){case"bestFit":{var D;const F=(D=M.filter(H=>{if(C){const Y=Tt(H.placement);return Y===v||Y==="y"}return!0}).map(H=>[H.placement,H.overflows.filter(Y=>Y>0).reduce((Y,U)=>Y+U,0)]).sort((H,Y)=>H[1]-Y[1])[0])==null?void 0:D[0];F&&(X=F);break}case"initialPlacement":X=c;break}if(r!==X)return{reset:{placement:X}}}return{}}}};function cc(e,n){return{top:e.top-n.height,right:e.right-n.width,bottom:e.bottom-n.height,left:e.left-n.width}}function dc(e){return Yv.some(n=>e[n]>=0)}const u2=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(n){const{rects:s,platform:o}=n,{strategy:r="referenceHidden",...a}=Vt(e,n);switch(r){case"referenceHidden":{const i=await o.detectOverflow(n,{...a,elementContext:"reference"}),c=cc(i,s.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:dc(c)}}}case"escaped":{const i=await o.detectOverflow(n,{...a,altBoundary:!0}),c=cc(i,s.floating);return{data:{escapedOffsets:c,escaped:dc(c)}}}default:return{}}}}},em=new Set(["left","top"]);async function m2(e,n){const{placement:s,platform:o,elements:r}=e,a=await(o.isRTL==null?void 0:o.isRTL(r.floating)),i=Kt(s),c=ps(s),d=Tt(s)==="y",m=em.has(i)?-1:1,u=a&&d?-1:1,p=Vt(n,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 p2=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(n){var s,o;const{x:r,y:a,placement:i,middlewareData:c}=n,d=await m2(n,e);return i===((s=c.offset)==null?void 0:s.placement)&&(o=c.arrow)!=null&&o.alignmentOffset?{}:{x:r+d.x,y:a+d.y,data:{...d,placement:i}}}}},f2=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(n){const{x:s,y:o,placement:r,platform:a}=n,{mainAxis:i=!0,crossAxis:c=!1,limiter:d={fn:w=>{let{x:v,y:j}=w;return{x:v,y:j}}},...m}=Vt(e,n),u={x:s,y:o},p=await a.detectOverflow(n,m),f=Tt(Kt(r)),h=Qi(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=Ka(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=Ka(j,b,S)}const y=d.fn({...n,[h]:g,[f]:b});return{...y,data:{x:y.x-s,y:y.y-o,enabled:{[h]:i,[f]:c}}}}}},h2=function(e){return e===void 0&&(e={}),{options:e,fn(n){const{x:s,y:o,placement:r,rects:a,middlewareData:i}=n,{offset:c=0,mainAxis:d=!0,crossAxis:m=!0}=Vt(e,n),u={x:s,y:o},p=Tt(r),f=Qi(p);let h=u[f],g=u[p];const b=Vt(c,n),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=em.has(Kt(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}}}},x2=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(n){var s,o;const{placement:r,rects:a,platform:i,elements:c}=n,{apply:d=()=>{},...m}=Vt(e,n),u=await i.detectOverflow(n,m),p=Kt(r),f=ps(r),h=Tt(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=ln(b-u[y],v),N=ln(g-u[w],j),C=!n.middlewareData.shift;let R=S,I=N;if((s=n.middlewareData.shift)!=null&&s.enabled.x&&(I=j),(o=n.middlewareData.shift)!=null&&o.enabled.y&&(R=v),C&&!f){const M=st(u.left,0),k=st(u.right,0),A=st(u.top,0),D=st(u.bottom,0);h?I=g-2*(M!==0||k!==0?M+k:st(u.left,u.right)):R=b-2*(A!==0||D!==0?A+D:st(u.top,u.bottom))}await d({...n,availableWidth:I,availableHeight:R});const P=await i.getDimensions(c.floating);return g!==P.width||b!==P.height?{reset:{rects:!0}}:{}}}};function jr(){return typeof window<"u"}function fs(e){return tm(e)?(e.nodeName||"").toLowerCase():"#document"}function at(e){var n;return(e==null||(n=e.ownerDocument)==null?void 0:n.defaultView)||window}function zt(e){var n;return(n=(tm(e)?e.ownerDocument:e.document)||window.document)==null?void 0:n.documentElement}function tm(e){return jr()?e instanceof Node||e instanceof at(e).Node:!1}function wt(e){return jr()?e instanceof Element||e instanceof at(e).Element:!1}function It(e){return jr()?e instanceof HTMLElement||e instanceof at(e).HTMLElement:!1}function uc(e){return!jr()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof at(e).ShadowRoot}const g2=new Set(["inline","contents"]);function Gs(e){const{overflow:n,overflowX:s,overflowY:o,display:r}=jt(e);return/auto|scroll|overlay|hidden|clip/.test(n+o+s)&&!g2.has(r)}const b2=new Set(["table","td","th"]);function v2(e){return b2.has(fs(e))}const y2=[":popover-open",":modal"];function Sr(e){return y2.some(n=>{try{return e.matches(n)}catch{return!1}})}const w2=["transform","translate","scale","rotate","perspective"],j2=["transform","translate","scale","rotate","perspective","filter"],S2=["paint","layout","strict","content"];function nl(e){const n=sl(),s=wt(e)?jt(e):e;return w2.some(o=>s[o]?s[o]!=="none":!1)||(s.containerType?s.containerType!=="normal":!1)||!n&&(s.backdropFilter?s.backdropFilter!=="none":!1)||!n&&(s.filter?s.filter!=="none":!1)||j2.some(o=>(s.willChange||"").includes(o))||S2.some(o=>(s.contain||"").includes(o))}function N2(e){let n=cn(e);for(;It(n)&&!is(n);){if(nl(n))return n;if(Sr(n))return null;n=cn(n)}return null}function sl(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const C2=new Set(["html","body","#document"]);function is(e){return C2.has(fs(e))}function jt(e){return at(e).getComputedStyle(e)}function Nr(e){return wt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function cn(e){if(fs(e)==="html")return e;const n=e.assignedSlot||e.parentNode||uc(e)&&e.host||zt(e);return uc(n)?n.host:n}function nm(e){const n=cn(e);return is(n)?e.ownerDocument?e.ownerDocument.body:e.body:It(n)&&Gs(n)?n:nm(n)}function Ps(e,n,s){var o;n===void 0&&(n=[]),s===void 0&&(s=!0);const r=nm(e),a=r===((o=e.ownerDocument)==null?void 0:o.body),i=at(r);if(a){const c=Ja(i);return n.concat(i,i.visualViewport||[],Gs(r)?r:[],c&&s?Ps(c):[])}return n.concat(r,Ps(r,[],s))}function Ja(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function sm(e){const n=jt(e);let s=parseFloat(n.width)||0,o=parseFloat(n.height)||0;const r=It(e),a=r?e.offsetWidth:s,i=r?e.offsetHeight:o,c=Ko(s)!==a||Ko(o)!==i;return c&&(s=a,o=i),{width:s,height:o,$:c}}function ol(e){return wt(e)?e:e.contextElement}function Qn(e){const n=ol(e);if(!It(n))return Mt(1);const s=n.getBoundingClientRect(),{width:o,height:r,$:a}=sm(n);let i=(a?Ko(s.width):s.width)/o,c=(a?Ko(s.height):s.height)/r;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const k2=Mt(0);function om(e){const n=at(e);return!sl()||!n.visualViewport?k2:{x:n.visualViewport.offsetLeft,y:n.visualViewport.offsetTop}}function _2(e,n,s){return n===void 0&&(n=!1),!s||n&&s!==at(e)?!1:n}function Rn(e,n,s,o){n===void 0&&(n=!1),s===void 0&&(s=!1);const r=e.getBoundingClientRect(),a=ol(e);let i=Mt(1);n&&(o?wt(o)&&(i=Qn(o)):i=Qn(e));const c=_2(a,s,o)?om(a):Mt(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=at(a),h=o&&wt(o)?at(o):o;let g=f,b=Ja(g);for(;b&&o&&h!==g;){const y=Qn(b),w=b.getBoundingClientRect(),v=jt(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=at(b),b=Ja(g)}}return Jo({width:u,height:p,x:d,y:m})}function Cr(e,n){const s=Nr(e).scrollLeft;return n?n.left+s:Rn(zt(e)).left+s}function rm(e,n){const s=e.getBoundingClientRect(),o=s.left+n.scrollLeft-Cr(e,s),r=s.top+n.scrollTop;return{x:o,y:r}}function T2(e){let{elements:n,rect:s,offsetParent:o,strategy:r}=e;const a=r==="fixed",i=zt(o),c=n?Sr(n.floating):!1;if(o===i||c&&a)return s;let d={scrollLeft:0,scrollTop:0},m=Mt(1);const u=Mt(0),p=It(o);if((p||!p&&!a)&&((fs(o)!=="body"||Gs(i))&&(d=Nr(o)),It(o))){const h=Rn(o);m=Qn(o),u.x=h.x+o.clientLeft,u.y=h.y+o.clientTop}const f=i&&!p&&!a?rm(i,d):Mt(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 E2(e){return Array.from(e.getClientRects())}function R2(e){const n=zt(e),s=Nr(e),o=e.ownerDocument.body,r=st(n.scrollWidth,n.clientWidth,o.scrollWidth,o.clientWidth),a=st(n.scrollHeight,n.clientHeight,o.scrollHeight,o.clientHeight);let i=-s.scrollLeft+Cr(e);const c=-s.scrollTop;return jt(o).direction==="rtl"&&(i+=st(n.clientWidth,o.clientWidth)-r),{width:r,height:a,x:i,y:c}}const mc=25;function M2(e,n){const s=at(e),o=zt(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=sl();(!u||u&&n==="fixed")&&(c=r.offsetLeft,d=r.offsetTop)}const m=Cr(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<=mc&&(a-=g)}else m<=mc&&(a+=m);return{width:a,height:i,x:c,y:d}}const A2=new Set(["absolute","fixed"]);function I2(e,n){const s=Rn(e,!0,n==="fixed"),o=s.top+e.clientTop,r=s.left+e.clientLeft,a=It(e)?Qn(e):Mt(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 pc(e,n,s){let o;if(n==="viewport")o=M2(e,s);else if(n==="document")o=R2(zt(e));else if(wt(n))o=I2(n,s);else{const r=om(e);o={x:n.x-r.x,y:n.y-r.y,width:n.width,height:n.height}}return Jo(o)}function am(e,n){const s=cn(e);return s===n||!wt(s)||is(s)?!1:jt(s).position==="fixed"||am(s,n)}function P2(e,n){const s=n.get(e);if(s)return s;let o=Ps(e,[],!1).filter(c=>wt(c)&&fs(c)!=="body"),r=null;const a=jt(e).position==="fixed";let i=a?cn(e):e;for(;wt(i)&&!is(i);){const c=jt(i),d=nl(i);!d&&c.position==="fixed"&&(r=null),(a?!d&&!r:!d&&c.position==="static"&&!!r&&A2.has(r.position)||Gs(i)&&!d&&am(e,i))?o=o.filter(u=>u!==i):r=c,i=cn(i)}return n.set(e,o),o}function L2(e){let{element:n,boundary:s,rootBoundary:o,strategy:r}=e;const i=[...s==="clippingAncestors"?Sr(n)?[]:P2(n,this._c):[].concat(s),o],c=i[0],d=i.reduce((m,u)=>{const p=pc(n,u,r);return m.top=st(p.top,m.top),m.right=ln(p.right,m.right),m.bottom=ln(p.bottom,m.bottom),m.left=st(p.left,m.left),m},pc(n,c,r));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}}function O2(e){const{width:n,height:s}=sm(e);return{width:n,height:s}}function D2(e,n,s){const o=It(n),r=zt(n),a=s==="fixed",i=Rn(e,!0,a,n);let c={scrollLeft:0,scrollTop:0};const d=Mt(0);function m(){d.x=Cr(r)}if(o||!o&&!a)if((fs(n)!=="body"||Gs(r))&&(c=Nr(n)),o){const h=Rn(n,!0,a,n);d.x=h.x+n.clientLeft,d.y=h.y+n.clientTop}else r&&m();a&&!o&&r&&m();const u=r&&!o&&!a?rm(r,c):Mt(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 sa(e){return jt(e).position==="static"}function fc(e,n){if(!It(e)||jt(e).position==="fixed")return null;if(n)return n(e);let s=e.offsetParent;return zt(e)===s&&(s=s.ownerDocument.body),s}function im(e,n){const s=at(e);if(Sr(e))return s;if(!It(e)){let r=cn(e);for(;r&&!is(r);){if(wt(r)&&!sa(r))return r;r=cn(r)}return s}let o=fc(e,n);for(;o&&v2(o)&&sa(o);)o=fc(o,n);return o&&is(o)&&sa(o)&&!nl(o)?s:o||N2(e)||s}const z2=async function(e){const n=this.getOffsetParent||im,s=this.getDimensions,o=await s(e.floating);return{reference:D2(e.reference,await n(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function $2(e){return jt(e).direction==="rtl"}const F2={convertOffsetParentRelativeRectToViewportRelativeRect:T2,getDocumentElement:zt,getClippingRect:L2,getOffsetParent:im,getElementRects:z2,getClientRects:E2,getDimensions:O2,getScale:Qn,isElement:wt,isRTL:$2};function lm(e,n){return e.x===n.x&&e.y===n.y&&e.width===n.width&&e.height===n.height}function U2(e,n){let s=null,o;const r=zt(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||n(),!f||!h)return;const g=uo(p),b=uo(r.clientWidth-(u+f)),y=uo(r.clientHeight-(p+h)),w=uo(u),j={rootMargin:-g+"px "+-b+"px "+-y+"px "+-w+"px",threshold:st(0,ln(1,d))||1};let S=!0;function N(C){const R=C[0].intersectionRatio;if(R!==d){if(!S)return i();R?i(!1,R):o=setTimeout(()=>{i(!1,1e-7)},1e3)}R===1&&!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 B2(e,n,s,o){o===void 0&&(o={});const{ancestorScroll:r=!0,ancestorResize:a=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:d=!1}=o,m=ol(e),u=r||a?[...m?Ps(m):[],...Ps(n)]:[];u.forEach(w=>{r&&w.addEventListener("scroll",s,{passive:!0}),a&&w.addEventListener("resize",s)});const p=m&&c?U2(m,s):null;let f=-1,h=null;i&&(h=new ResizeObserver(w=>{let[v]=w;v&&v.target===m&&h&&(h.unobserve(n),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var j;(j=h)==null||j.observe(n)})),s()}),m&&!d&&h.observe(m),h.observe(n));let g,b=d?Rn(e):null;d&&y();function y(){const w=Rn(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 q2=p2,H2=f2,W2=d2,V2=x2,K2=u2,hc=c2,G2=h2,J2=(e,n,s)=>{const o=new Map,r={platform:F2,...s},a={...r.platform,_c:o};return l2(e,n,{...r,platform:a})};var Y2=typeof document<"u",X2=function(){},Ao=Y2?l.useLayoutEffect:X2;function Yo(e,n){if(e===n)return!0;if(typeof e!=typeof n)return!1;if(typeof e=="function"&&e.toString()===n.toString())return!0;let s,o,r;if(e&&n&&typeof e=="object"){if(Array.isArray(e)){if(s=e.length,s!==n.length)return!1;for(o=s;o--!==0;)if(!Yo(e[o],n[o]))return!1;return!0}if(r=Object.keys(e),s=r.length,s!==Object.keys(n).length)return!1;for(o=s;o--!==0;)if(!{}.hasOwnProperty.call(n,r[o]))return!1;for(o=s;o--!==0;){const a=r[o];if(!(a==="_owner"&&e.$$typeof)&&!Yo(e[a],n[a]))return!1}return!0}return e!==e&&n!==n}function cm(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function xc(e,n){const s=cm(e);return Math.round(n*s)/s}function oa(e){const n=l.useRef(e);return Ao(()=>{n.current=e}),n}function Z2(e){e===void 0&&(e={});const{placement:n="bottom",strategy:s="absolute",middleware:o=[],platform:r,elements:{reference:a,floating:i}={},transform:c=!0,whileElementsMounted:d,open:m}=e,[u,p]=l.useState({x:0,y:0,strategy:s,placement:n,middlewareData:{},isPositioned:!1}),[f,h]=l.useState(o);Yo(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!==R.current&&(R.current=H,w(H))},[]),S=a||g,N=i||y,C=l.useRef(null),R=l.useRef(null),I=l.useRef(u),P=d!=null,M=oa(d),k=oa(r),A=oa(m),D=l.useCallback(()=>{if(!C.current||!R.current)return;const H={placement:n,strategy:s,middleware:f};k.current&&(H.platform=k.current),J2(C.current,R.current,H).then(Y=>{const U={...Y,isPositioned:A.current!==!1};$.current&&!Yo(I.current,U)&&(I.current=U,ms.flushSync(()=>{p(U)}))})},[f,n,s,k,A]);Ao(()=>{m===!1&&I.current.isPositioned&&(I.current.isPositioned=!1,p(H=>({...H,isPositioned:!1})))},[m]);const $=l.useRef(!1);Ao(()=>($.current=!0,()=>{$.current=!1}),[]),Ao(()=>{if(S&&(C.current=S),N&&(R.current=N),S&&N){if(M.current)return M.current(S,N,D);D()}},[S,N,D,M,P]);const J=l.useMemo(()=>({reference:C,floating:R,setReference:v,setFloating:j}),[v,j]),X=l.useMemo(()=>({reference:S,floating:N}),[S,N]),F=l.useMemo(()=>{const H={position:s,left:0,top:0};if(!X.floating)return H;const Y=xc(X.floating,u.x),U=xc(X.floating,u.y);return c?{...H,transform:"translate("+Y+"px, "+U+"px)",...cm(X.floating)>=1.5&&{willChange:"transform"}}:{position:s,left:Y,top:U}},[s,c,X.floating,u.x,u.y]);return l.useMemo(()=>({...u,update:D,refs:J,elements:X,floatingStyles:F}),[u,D,J,X,F])}const Q2=e=>{function n(s){return{}.hasOwnProperty.call(s,"current")}return{name:"arrow",options:e,fn(s){const{element:o,padding:r}=typeof e=="function"?e(s):e;return o&&n(o)?o.current!=null?hc({element:o.current,padding:r}).fn(s):{}:o?hc({element:o,padding:r}).fn(s):{}}}},ey=(e,n)=>({...q2(e),options:[e,n]}),ty=(e,n)=>({...H2(e),options:[e,n]}),ny=(e,n)=>({...G2(e),options:[e,n]}),sy=(e,n)=>({...W2(e),options:[e,n]}),oy=(e,n)=>({...V2(e),options:[e,n]}),ry=(e,n)=>({...K2(e),options:[e,n]}),ay=(e,n)=>({...Q2(e),options:[e,n]});var iy="Arrow",dm=l.forwardRef((e,n)=>{const{children:s,width:o=10,height:r=5,...a}=e;return t.jsx(xe.svg,{...a,ref:n,width:o,height:r,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?s:t.jsx("polygon",{points:"0,0 30,0 15,10"})})});dm.displayName=iy;var ly=dm,rl="Popper",[um,kr]=Jt(rl),[cy,mm]=um(rl),pm=e=>{const{__scopePopper:n,children:s}=e,[o,r]=l.useState(null),[a,i]=l.useState(void 0);return t.jsx(cy,{scope:n,anchor:o,onAnchorChange:r,placementState:a,setPlacementState:i,children:s})};pm.displayName=rl;var fm="PopperAnchor",hm=l.forwardRef((e,n)=>{const{__scopePopper:s,virtualRef:o,...r}=e,a=mm(fm,s),i=l.useRef(null),c=a.onAnchorChange,d=l.useCallback(g=>{i.current=g,g&&c(g)},[c]),m=Te(n,d),u=l.useRef(null);l.useEffect(()=>{if(!o)return;const g=u.current;u.current=o.current,g!==u.current&&c(u.current)});const p=a.placementState&&il(a.placementState),f=p?.[0],h=p?.[1];return o?null:t.jsx(xe.div,{"data-radix-popper-side":f,"data-radix-popper-align":h,...r,ref:m})});hm.displayName=fm;var al="PopperContent",[dy,uy]=um(al),xm=l.forwardRef((e,n)=>{const{__scopePopper:s,side:o="bottom",sideOffset:r=0,align:a="center",alignOffset:i=0,arrowPadding:c=0,avoidCollisions:d=!0,collisionBoundary:m=[],collisionPadding:u=0,sticky:p="partial",hideWhenDetached:f=!1,updatePositionStrategy:h="optimized",onPlaced:g,...b}=e,y=mm(al,s),[w,v]=l.useState(null),j=Te(n,v),[S,N]=l.useState(null),C=Jv(S),R=C?.width??0,I=C?.height??0,P=o+(a!=="center"?"-"+a:""),M=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},k=Array.isArray(m)?m:[m],A=k.length>0,D={padding:M,boundary:k.filter(py),altBoundary:A},{refs:$,floatingStyles:J,placement:X,isPositioned:F,middlewareData:H}=Z2({strategy:"fixed",placement:P,whileElementsMounted:(...Se)=>B2(...Se,{animationFrame:h==="always"}),elements:{reference:y.anchor},middleware:[ey({mainAxis:r+I,alignmentAxis:i}),d&&ty({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?ny():void 0,...D}),d&&sy({...D}),oy({...D,apply:({elements:Se,rects:Ne,availableWidth:ie,availableHeight:le})=>{const{width:fe,height:ye}=Ne.reference,Ce=Se.floating.style;Ce.setProperty("--radix-popper-available-width",`${ie}px`),Ce.setProperty("--radix-popper-available-height",`${le}px`),Ce.setProperty("--radix-popper-anchor-width",`${fe}px`),Ce.setProperty("--radix-popper-anchor-height",`${ye}px`)}}),S&&ay({element:S,padding:c}),fy({arrowWidth:R,arrowHeight:I}),f&&ry({strategy:"referenceHidden",...D,boundary:A?D.boundary:void 0})]}),Y=y.setPlacementState;Ue(()=>(Y(X),()=>{Y(void 0)}),[X,Y]);const[U,W]=il(X),me=He(g);Ue(()=>{F&&me?.()},[F,me]);const be=H.arrow?.x,ve=H.arrow?.y,z=H.arrow?.centerOffset!==0,[se,te]=l.useState();return Ue(()=>{w&&te(window.getComputedStyle(w).zIndex)},[w]),t.jsx("div",{ref:$.setFloating,"data-radix-popper-content-wrapper":"",style:{...J,transform:F?J.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:se,"--radix-popper-transform-origin":[H.transformOrigin?.x,H.transformOrigin?.y].join(" "),...H.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:t.jsx(dy,{scope:s,placedSide:U,placedAlign:W,onArrowChange:N,arrowX:be,arrowY:ve,shouldHideArrow:z,children:t.jsx(xe.div,{"data-side":U,"data-align":W,...b,ref:j,style:{...b.style,animation:F?void 0:"none"}})})})});xm.displayName=al;var gm="PopperArrow",my={top:"bottom",right:"left",bottom:"top",left:"right"},bm=l.forwardRef(function(n,s){const{__scopePopper:o,...r}=n,a=uy(gm,o),i=my[a.placedSide];return t.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:t.jsx(ly,{...r,ref:s,style:{...r.style,display:"block"}})})});bm.displayName=gm;function py(e){return e!==null}var fy=e=>({name:"transformOrigin",options:e,fn(n){const{placement:s,rects:o,middlewareData:r}=n,i=r.arrow?.centerOffset!==0,c=i?0:e.arrowWidth,d=i?0:e.arrowHeight,[m,u]=il(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 il(e){const[n,s="center"]=e.split("-");return[n,s]}var vm=pm,ym=hm,wm=xm,jm=bm,ra=!1;function hy(){const[e,n]=l.useState(ra);return l.useEffect(()=>{ra||(ra=!0,n(!0))},[]),e}var Sm=mr[" useSyncExternalStore ".trim().toString()];function xy(){return()=>{}}function gy(){return Sm(xy,()=>!0,()=>!1)}var by=typeof Sm=="function"?gy:hy,aa="rovingFocusGroup.onEntryFocus",vy={bubbles:!1,cancelable:!0},Js="RovingFocusGroup",[Ya,Nm,yy]=wu(Js),[wy,Cm]=Jt(Js,[yy]),[jy,Sy]=wy(Js),km=l.forwardRef((e,n)=>t.jsx(Ya.Provider,{scope:e.__scopeRovingFocusGroup,children:t.jsx(Ya.Slot,{scope:e.__scopeRovingFocusGroup,children:t.jsx(Ny,{...e,ref:n})})}));km.displayName=Js;var Ny=l.forwardRef((e,n)=>{const{__scopeRovingFocusGroup:s,orientation:o,loop:r=!1,dir:a,currentTabStopId:i,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:d,onEntryFocus:m,preventScrollOnEntryFocus:u=!1,...p}=e,f=l.useRef(null),h=Te(n,f),g=gr(a),[b,y]=En({prop:i,defaultProp:c??null,onChange:d,caller:Js}),[w,v]=l.useState(!1),j=He(m),S=Nm(s),N=l.useRef(!1),[C,R]=l.useState(0);return l.useEffect(()=>{const I=f.current;if(I)return I.addEventListener(aa,j),()=>I.removeEventListener(aa,j)},[j]),t.jsx(jy,{scope:s,orientation:o,dir:g,loop:r,currentTabStopId:b,onItemFocus:l.useCallback(I=>y(I),[y]),onItemShiftTab:l.useCallback(()=>v(!0),[]),onFocusableItemAdd:l.useCallback(()=>R(I=>I+1),[]),onFocusableItemRemove:l.useCallback(()=>R(I=>I-1),[]),children:t.jsx(xe.div,{tabIndex:w||C===0?-1:0,"data-orientation":o,...p,ref:h,style:{outline:"none",...e.style},onMouseDown:de(e.onMouseDown,()=>{N.current=!0}),onFocus:de(e.onFocus,I=>{const P=!N.current;if(I.target===I.currentTarget&&P&&!w){const M=new CustomEvent(aa,vy);if(I.currentTarget.dispatchEvent(M),!M.defaultPrevented){const k=S().filter(X=>X.focusable),A=k.find(X=>X.active),D=k.find(X=>X.id===b),J=[A,D,...k].filter(Boolean).map(X=>X.ref.current);Em(J,u)}}N.current=!1}),onBlur:de(e.onBlur,()=>v(!1))})})}),_m="RovingFocusGroupItem",Tm=l.forwardRef((e,n)=>{const{__scopeRovingFocusGroup:s,focusable:o=!0,active:r=!1,tabStopId:a,children:i,...c}=e,d=Rt(),m=a||d,u=Sy(_m,s),p=u.currentTabStopId===m,f=Nm(s),{onFocusableItemAdd:h,onFocusableItemRemove:g,currentTabStopId:b}=u,y=by();return Ue(()=>{if(!(!y||!o))return h(),()=>g()},[y,o,h,g]),l.useEffect(()=>{if(!(y||!o))return h(),()=>g()},[y,o,h,g]),t.jsx(Ya.ItemSlot,{scope:s,id:m,focusable:o,active:r,children:t.jsx(xe.span,{tabIndex:p?0:-1,"data-orientation":u.orientation,...c,ref:n,onMouseDown:de(e.onMouseDown,w=>{o?u.onItemFocus(m):w.preventDefault()}),onFocus:de(e.onFocus,()=>u.onItemFocus(m)),onKeyDown:de(e.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){u.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const v=_y(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?Ty(S,N+1):S.slice(N+1)}setTimeout(()=>Em(S))}}),children:typeof i=="function"?i({isCurrentTabStop:p,hasTabStop:b!=null}):i})})});Tm.displayName=_m;var Cy={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function ky(e,n){return n!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function _y(e,n,s){const o=ky(e.key,s);if(!(n==="vertical"&&["ArrowLeft","ArrowRight"].includes(o))&&!(n==="horizontal"&&["ArrowUp","ArrowDown"].includes(o)))return Cy[o]}function Em(e,n=!1){const s=document.activeElement;for(const o of e)if(o===s||(o.focus({preventScroll:n}),document.activeElement!==s))return}function Ty(e,n){return e.map((s,o)=>e[(n+o)%e.length])}var Ey=km,Ry=Tm;function Xa(e,[n,s]){return Math.min(s,Math.max(n,e))}function My(e,n){return l.useReducer((s,o)=>n[s][o]??s,e)}var ll="ScrollArea",[Rm]=Jt(ll),[Ay,pt]=Rm(ll),Mm=l.forwardRef((e,n)=>{const{__scopeScrollArea:s,type:o="hover",dir:r,scrollHideDelay:a=600,...i}=e,[c,d]=l.useState(null),[m,u]=l.useState(null),[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),[R,I]=l.useState(!1),P=Te(n,d),M=gr(r);return t.jsx(Ay,{scope:s,type:o,dir:M,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:R,onScrollbarYEnabledChange:I,onCornerWidthChange:v,onCornerHeightChange:S,children:t.jsx(xe.div,{dir:M,...i,ref:P,style:{position:"relative","--radix-scroll-area-corner-width":w+"px","--radix-scroll-area-corner-height":j+"px",...e.style}})})});Mm.displayName=ll;var Am="ScrollAreaViewport",Im=l.forwardRef((e,n)=>{const{__scopeScrollArea:s,children:o,nonce:r,...a}=e,i=pt(Am,s),c=l.useRef(null),d=Te(n,c,i.onViewportChange);return t.jsxs(t.Fragment,{children:[t.jsx(Iy,{nonce:r}),t.jsx(xe.div,{"data-radix-scroll-area-viewport":"",...a,ref:d,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:t.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:o})})]})});Im.displayName=Am;var Iy=l.memo(({nonce:e})=>t.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:e}),(e,n)=>e.nonce===n.nonce),$t="ScrollAreaScrollbar",Pm=l.forwardRef((e,n)=>{const{forceMount:s,...o}=e,r=pt($t,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:i}=r,c=e.orientation==="horizontal";return l.useEffect(()=>(c?a(!0):i(!0),()=>{c?a(!1):i(!1)}),[c,a,i]),r.type==="hover"?t.jsx(Py,{...o,ref:n,forceMount:s}):r.type==="scroll"?t.jsx(Ly,{...o,ref:n,forceMount:s}):r.type==="auto"?t.jsx(Lm,{...o,ref:n,forceMount:s}):r.type==="always"?t.jsx(cl,{...o,ref:n,"data-state":"visible"}):null});Pm.displayName=$t;var Py=l.forwardRef((e,n)=>{const{forceMount:s,...o}=e,r=pt($t,e.__scopeScrollArea),[a,i]=l.useState(!1);return l.useEffect(()=>{const c=r.scrollArea;let d=0;if(c){const m=()=>{window.clearTimeout(d),i(!0)},u=()=>{d=window.setTimeout(()=>i(!1),r.scrollHideDelay)};return c.addEventListener("pointerenter",m),c.addEventListener("pointerleave",u),()=>{window.clearTimeout(d),c.removeEventListener("pointerenter",m),c.removeEventListener("pointerleave",u)}}},[r.scrollArea,r.scrollHideDelay]),t.jsx(lt,{present:s||a,children:t.jsx(Lm,{"data-state":a?"visible":"hidden",...o,ref:n})})}),Ly=l.forwardRef((e,n)=>{const{forceMount:s,...o}=e,r=pt($t,e.__scopeScrollArea),a=e.orientation==="horizontal",i=Tr(()=>d("SCROLL_END"),100),[c,d]=My("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]),t.jsx(lt,{present:s||c!=="hidden",children:t.jsx(cl,{"data-state":c==="hidden"?"hidden":"visible",...o,ref:n,onPointerEnter:de(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:de(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),Lm=l.forwardRef((e,n)=>{const s=pt($t,e.__scopeScrollArea),{forceMount:o,...r}=e,[a,i]=l.useState(!1),c=e.orientation==="horizontal",d=Tr(()=>{if(s.viewport){const m=s.viewport.offsetWidth<s.viewport.scrollWidth,u=s.viewport.offsetHeight<s.viewport.scrollHeight;i(c?m:u)}},10);return ls(s.viewport,d),ls(s.content,d),t.jsx(lt,{present:o||a,children:t.jsx(cl,{"data-state":a?"visible":"hidden",...r,ref:n})})}),cl=l.forwardRef((e,n)=>{const{orientation:s="vertical",...o}=e,r=pt($t,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=Fm(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 Uy(f,i.current,c,h)}return s==="horizontal"?t.jsx(Oy,{...u,ref:n,onThumbPositionChange:()=>{if(r.viewport&&a.current){const f=r.viewport.scrollLeft,h=gc(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"?t.jsx(Dy,{...u,ref:n,onThumbPositionChange:()=>{if(r.viewport&&a.current){const f=r.viewport.scrollTop,h=gc(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}),Oy=l.forwardRef((e,n)=>{const{sizes:s,onSizesChange:o,...r}=e,a=pt($t,e.__scopeScrollArea),[i,c]=l.useState(),d=l.useRef(null),m=Te(n,d,a.onScrollbarXChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),t.jsx(Dm,{"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),Bm(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:Zo(i.paddingLeft),paddingEnd:Zo(i.paddingRight)}})}})}),Dy=l.forwardRef((e,n)=>{const{sizes:s,onSizesChange:o,...r}=e,a=pt($t,e.__scopeScrollArea),[i,c]=l.useState(),d=l.useRef(null),m=Te(n,d,a.onScrollbarYChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),t.jsx(Dm,{"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),Bm(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:Zo(i.paddingTop),paddingEnd:Zo(i.paddingBottom)}})}})}),[zy,Om]=Rm($t),Dm=l.forwardRef((e,n)=>{const{__scopeScrollArea:s,sizes:o,hasThumb:r,onThumbChange:a,onThumbPointerUp:i,onThumbPointerDown:c,onThumbPositionChange:d,onDragScroll:m,onWheelScroll:u,onResize:p,...f}=e,h=pt($t,s),[g,b]=l.useState(null),y=Te(n,b),w=l.useRef(null),v=l.useRef(""),j=h.viewport,S=o.content-o.viewport,N=He(u),C=He(d),R=Tr(p,10);function I(P){if(w.current){const M=P.clientX-w.current.left,k=P.clientY-w.current.top;m({x:M,y:k})}}return l.useEffect(()=>{const P=M=>{const k=M.target;g?.contains(k)&&N(M,S)};return document.addEventListener("wheel",P,{passive:!1}),()=>document.removeEventListener("wheel",P,{passive:!1})},[j,g,S,N]),l.useEffect(C,[o,C]),ls(g,R),ls(h.content,R),t.jsx(zy,{scope:s,scrollbar:g,hasThumb:r,onThumbChange:He(a),onThumbPointerUp:He(i),onThumbPositionChange:C,onThumbPointerDown:He(c),children:t.jsx(xe.div,{...f,ref:y,style:{position:"absolute",...f.style},onPointerDown:de(e.onPointerDown,P=>{P.button===0&&(P.target.setPointerCapture(P.pointerId),w.current=g.getBoundingClientRect(),v.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",h.viewport&&(h.viewport.style.scrollBehavior="auto"),I(P))}),onPointerMove:de(e.onPointerMove,I),onPointerUp:de(e.onPointerUp,P=>{const M=P.target;M.hasPointerCapture(P.pointerId)&&M.releasePointerCapture(P.pointerId),document.body.style.webkitUserSelect=v.current,h.viewport&&(h.viewport.style.scrollBehavior=""),w.current=null})})})}),Xo="ScrollAreaThumb",zm=l.forwardRef((e,n)=>{const{forceMount:s,...o}=e,r=Om(Xo,e.__scopeScrollArea);return t.jsx(lt,{present:s||r.hasThumb,children:t.jsx($y,{ref:n,...o})})}),$y=l.forwardRef((e,n)=>{const{__scopeScrollArea:s,style:o,...r}=e,a=pt(Xo,s),i=Om(Xo,s),{onThumbPositionChange:c}=i,d=Te(n,i.onThumbChange),m=l.useRef(void 0),u=Tr(()=>{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=By(p,c);m.current=h,c()}};return c(),p.addEventListener("scroll",f),()=>p.removeEventListener("scroll",f)}},[a.viewport,u,c]),t.jsx(xe.div,{"data-state":i.hasThumb?"visible":"hidden",...r,ref:d,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...o},onPointerDownCapture:de(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:de(e.onPointerUp,i.onThumbPointerUp)})});zm.displayName=Xo;var dl="ScrollAreaCorner",$m=l.forwardRef((e,n)=>{const s=pt(dl,e.__scopeScrollArea),o=!!(s.scrollbarX&&s.scrollbarY);return s.type!=="scroll"&&o?t.jsx(Fy,{...e,ref:n}):null});$m.displayName=dl;var Fy=l.forwardRef((e,n)=>{const{__scopeScrollArea:s,...o}=e,r=pt(dl,s),[a,i]=l.useState(0),[c,d]=l.useState(0),m=!!(a&&c),{onCornerWidthChange:u,onCornerHeightChange:p}=r;return ls(r.scrollbarX,()=>{const f=r.scrollbarX?.offsetHeight||0;r.onCornerHeightChange(f),d(f)}),ls(r.scrollbarY,()=>{const f=r.scrollbarY?.offsetWidth||0;r.onCornerWidthChange(f),i(f)}),l.useEffect(()=>()=>{u(0),p(0)},[u,p]),m?t.jsx(xe.div,{...o,ref:n,style:{width:a,height:c,position:"absolute",right:r.dir==="ltr"?0:void 0,left:r.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function Zo(e){return e?parseInt(e,10):0}function Fm(e,n){const s=e/n;return isNaN(s)?0:s}function _r(e){const n=Fm(e.viewport,e.content),s=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,o=(e.scrollbar.size-s)*n;return Math.max(o,18)}function Uy(e,n,s,o="ltr"){const r=_r(s),a=r/2,i=n||a,c=r-i,d=s.scrollbar.paddingStart+i,m=s.scrollbar.size-s.scrollbar.paddingEnd-c,u=s.content-s.viewport,p=o==="ltr"?[0,u]:[u*-1,0];return Um([d,m],p)(e)}function gc(e,n,s="ltr"){const o=_r(n),r=n.scrollbar.paddingStart+n.scrollbar.paddingEnd,a=n.scrollbar.size-r,i=n.content-n.viewport,c=a-o,d=s==="ltr"?[0,i]:[i*-1,0],m=Xa(e,d);return Um([0,i],[0,c])(m)}function Um(e,n){return s=>{if(e[0]===e[1]||n[0]===n[1])return n[0];const o=(n[1]-n[0])/(e[1]-e[0]);return n[0]+o*(s-e[0])}}function Bm(e,n){return e>0&&e<n}var By=(e,n=()=>{})=>{let s={left:e.scrollLeft,top:e.scrollTop},o=0;return(function r(){const a={left:e.scrollLeft,top:e.scrollTop},i=s.left!==a.left,c=s.top!==a.top;(i||c)&&n(),s=a,o=window.requestAnimationFrame(r)})(),()=>window.cancelAnimationFrame(o)};function Tr(e,n){const s=He(e),o=l.useRef(0);return l.useEffect(()=>()=>window.clearTimeout(o.current),[]),l.useCallback(()=>{window.clearTimeout(o.current),o.current=window.setTimeout(s,n)},[s,n])}function ls(e,n){const s=He(n);Ue(()=>{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 qy=Mm,Hy=Im,Wy=$m,Vy=[" ","Enter","ArrowUp","ArrowDown"],Ky=[" ","Enter"],Mn="Select",[Er,Rr,Gy]=wu(Mn),[Pn]=Jt(Mn,[Gy,kr]),Mr=kr(),[Jy,mn]=Pn(Mn),[Yy,Xy]=Pn(Mn),Zy="SelectProvider";function qm(e){const{__scopeSelect:n,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=Mr(n),[w,v]=l.useState(null),[j,S]=l.useState(null),[N,C]=l.useState(!1),R=gr(m),[I,P]=En({prop:o,defaultProp:r??!1,onChange:a,caller:Mn}),[M,k]=En({prop:i,defaultProp:c,onChange:d,caller:Mn}),A=l.useRef(null),D=l.useRef(M);l.useEffect(()=>{const me=g?w?.ownerDocument.getElementById(g):w?.form;if(me instanceof HTMLFormElement){const be=()=>k(D.current);return me.addEventListener("reset",be),()=>me.removeEventListener("reset",be)}},[g,w,k]);const $=w?!!g||!!w.closest("form"):!0,[J,X]=l.useState(new Set),F=Rt(),H=Array.from(J).map(me=>me.props.value).join(";"),Y=l.useCallback(me=>{X(be=>new Set(be).add(me))},[]),U=l.useCallback(me=>{X(be=>{const ve=new Set(be);return ve.delete(me),ve})},[]),W={required:h,trigger:w,onTriggerChange:v,valueNode:j,onValueNodeChange:S,valueNodeHasChildren:N,onValueNodeHasChildrenChange:C,contentId:F,value:M,onValueChange:k,open:I,onOpenChange:P,dir:R,triggerPointerDownPosRef:A,disabled:f,name:u,autoComplete:p,form:g,nativeOptions:J,nativeSelectKey:H,isFormControl:$};return t.jsx(vm,{...y,children:t.jsx(Jy,{scope:n,...W,children:t.jsx(Er.Provider,{scope:n,children:t.jsx(Yy,{scope:n,onNativeOptionAdd:Y,onNativeOptionRemove:U,children:hw(b)?b(W):s})})})})}qm.displayName=Zy;var Hm=e=>{const{__scopeSelect:n,children:s,...o}=e;return t.jsx(qm,{__scopeSelect:n,...o,internal_do_not_use_render:({isFormControl:r})=>t.jsxs(t.Fragment,{children:[s,r?t.jsx(xp,{__scopeSelect:n}):null]})})};Hm.displayName=Mn;var Wm="SelectTrigger",Vm=l.forwardRef((e,n)=>{const{__scopeSelect:s,disabled:o=!1,...r}=e,a=Mr(s),i=mn(Wm,s),c=i.disabled||o,d=Te(n,i.onTriggerChange),m=Rr(s),u=l.useRef("touch"),[p,f,h]=gp(b=>{const y=m().filter(j=>!j.disabled),w=y.find(j=>j.value===i.value),v=bp(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 t.jsx(ym,{asChild:!0,...a,children:t.jsx(xe.button,{type:"button",role:"combobox","aria-controls":i.open?i.contentId:void 0,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":Ar(i.value)?"":void 0,...r,ref:d,onClick:de(r.onClick,b=>{b.currentTarget.focus(),u.current!=="mouse"&&g(b)}),onPointerDown:de(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:de(r.onKeyDown,b=>{const y=p.current!=="";!(b.ctrlKey||b.altKey||b.metaKey)&&b.key.length===1&&f(b.key),!(y&&b.key===" ")&&Vy.includes(b.key)&&(g(),b.preventDefault())})})})});Vm.displayName=Wm;var Km="SelectValue",Gm=l.forwardRef((e,n)=>{const{__scopeSelect:s,className:o,style:r,children:a,placeholder:i="",...c}=e,d=mn(Km,s),{onValueNodeHasChildrenChange:m}=d,u=a!==void 0,p=Te(n,d.onValueNodeChange);Ue(()=>{m(u)},[m,u]);const f=Ar(d.value);return t.jsx(xe.span,{...c,asChild:f?!1:c.asChild,ref:p,style:{pointerEvents:"none"},children:t.jsx(l.Fragment,{children:f?i:a},f?"placeholder":"value")})});Gm.displayName=Km;var Qy="SelectIcon",Jm=l.forwardRef((e,n)=>{const{__scopeSelect:s,children:o,...r}=e;return t.jsx(xe.span,{"aria-hidden":!0,...r,ref:n,children:o||"▼"})});Jm.displayName=Qy;var Ym="SelectPortal",[ew,tw]=Pn(Ym,{forceMount:void 0}),Xm=e=>{const{__scopeSelect:n,forceMount:s,...o}=e;return t.jsx(ew,{scope:e.__scopeSelect,forceMount:s,children:t.jsx(vr,{asChild:!0,...o})})};Xm.displayName=Ym;var dn="SelectContent",Zm=l.forwardRef((e,n)=>{const s=tw(dn,e.__scopeSelect),{forceMount:o=s.forceMount,...r}=e,a=mn(dn,e.__scopeSelect),[i,c]=l.useState();return Ue(()=>{c(new DocumentFragment)},[]),t.jsx(lt,{present:o||a.open,children:({present:d})=>d?t.jsx(tp,{...r,ref:n}):t.jsx(Qm,{...r,fragment:i})})});Zm.displayName=dn;var Qm=l.forwardRef((e,n)=>{const{__scopeSelect:s,children:o,fragment:r}=e;return r?ms.createPortal(t.jsx(ep,{scope:s,children:t.jsx(Er.Slot,{scope:s,children:t.jsx("div",{ref:n,children:o})})}),r):null});Qm.displayName="SelectContentFragment";var bt=10,[ep,pn]=Pn(dn),nw="SelectContentImpl",sw=rs("SelectContent.RemoveScroll"),tp=l.forwardRef((e,n)=>{const{__scopeSelect:s}=e,{position:o="item-aligned",onCloseAutoFocus:r,onEscapeKeyDown:a,onPointerDownOutside:i,side:c,sideOffset:d,align:m,alignOffset:u,arrowPadding:p,collisionBoundary:f,collisionPadding:h,sticky:g,hideWhenDetached:b,avoidCollisions:y,...w}=e,v=mn(dn,s),[j,S]=l.useState(null),[N,C]=l.useState(null),R=Te(n,S),[I,P]=l.useState(null),[M,k]=l.useState(null),A=Rr(s),[D,$]=l.useState(!1),J=l.useRef(!1);l.useEffect(()=>{if(j)return Du(j)},[j]),Tu();const X=l.useCallback(te=>{const[Se,...Ne]=A().map(fe=>fe.ref.current),[ie]=Ne.slice(-1),le=document.activeElement;for(const fe of te)if(fe===le||(fe?.scrollIntoView({block:"nearest"}),fe===Se&&N&&(N.scrollTop=0),fe===ie&&N&&(N.scrollTop=N.scrollHeight),fe?.focus(),document.activeElement!==le))return},[A,N]),F=l.useCallback(()=>X([I,j]),[X,I,j]);l.useEffect(()=>{D&&F()},[D,F]);const{onOpenChange:H,triggerPointerDownPosRef:Y}=v;l.useEffect(()=>{if(j){let te={x:0,y:0};const Se=ie=>{te={x:Math.abs(Math.round(ie.pageX)-(Y.current?.x??0)),y:Math.abs(Math.round(ie.pageY)-(Y.current?.y??0))}},Ne=ie=>{te.x<=10&&te.y<=10?ie.preventDefault():ie.composedPath().includes(j)||H(!1),document.removeEventListener("pointermove",Se),Y.current=null};return Y.current!==null&&(document.addEventListener("pointermove",Se),document.addEventListener("pointerup",Ne,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Se),document.removeEventListener("pointerup",Ne,{capture:!0})}}},[j,H,Y]),l.useEffect(()=>{const te=()=>H(!1);return window.addEventListener("blur",te),window.addEventListener("resize",te),()=>{window.removeEventListener("blur",te),window.removeEventListener("resize",te)}},[H]);const[U,W]=gp(te=>{const Se=A().filter(le=>!le.disabled),Ne=Se.find(le=>le.ref.current===document.activeElement),ie=bp(Se,te,Ne);ie&&setTimeout(()=>ie.ref.current?.focus())}),me=l.useCallback((te,Se,Ne)=>{const ie=!J.current&&!Ne;(v.value!==void 0&&v.value===Se||ie)&&(P(te),ie&&(J.current=!0))},[v.value]),be=l.useCallback(()=>j?.focus(),[j]),ve=l.useCallback((te,Se,Ne)=>{const ie=!J.current&&!Ne;(v.value!==void 0&&v.value===Se||ie)&&k(te)},[v.value]),z=o==="popper"?Za:np,se=z===Za?{side:c,sideOffset:d,align:m,alignOffset:u,arrowPadding:p,collisionBoundary:f,collisionPadding:h,sticky:g,hideWhenDetached:b,avoidCollisions:y}:{};return t.jsx(ep,{scope:s,content:j,viewport:N,onViewportChange:C,itemRefCallback:me,selectedItem:I,onItemLeave:be,itemTextRefCallback:ve,focusSelectedItem:F,selectedItemText:M,position:o,isPositioned:D,searchRef:U,children:t.jsx(Yi,{as:sw,allowPinchZoom:!0,children:t.jsx(Ji,{asChild:!0,trapped:v.open,onMountAutoFocus:te=>{te.preventDefault()},onUnmountAutoFocus:de(r,te=>{v.trigger?.focus({preventScroll:!0}),te.preventDefault()}),children:t.jsx(br,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:te=>te.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:t.jsx(z,{role:"listbox",id:v.contentId,"data-state":v.open?"open":"closed",dir:v.dir,onContextMenu:te=>te.preventDefault(),...w,...se,onPlaced:()=>$(!0),ref:R,style:{display:"flex",flexDirection:"column",outline:"none",...w.style},onKeyDown:de(w.onKeyDown,te=>{const Se=te.ctrlKey||te.altKey||te.metaKey;if(te.key==="Tab"&&te.preventDefault(),!Se&&te.key.length===1&&W(te.key),["ArrowUp","ArrowDown","Home","End"].includes(te.key)){let ie=A().filter(le=>!le.disabled).map(le=>le.ref.current);if(["ArrowUp","End"].includes(te.key)&&(ie=ie.slice().reverse()),["ArrowUp","ArrowDown"].includes(te.key)){const le=te.target,fe=ie.indexOf(le);ie=ie.slice(fe+1)}setTimeout(()=>X(ie)),te.preventDefault()}})})})})})})});tp.displayName=nw;var ow="SelectItemAlignedPosition",np=l.forwardRef((e,n)=>{const{__scopeSelect:s,onPlaced:o,...r}=e,a=mn(dn,s),i=pn(dn,s),[c,d]=l.useState(null),[m,u]=l.useState(null),p=Te(n,u),f=Rr(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 R=a.trigger.getBoundingClientRect(),I=m.getBoundingClientRect(),P=a.valueNode.getBoundingClientRect(),M=w.getBoundingClientRect();if(a.dir!=="rtl"){const le=M.left-I.left,fe=P.left-le,ye=R.left-fe,Ce=R.width+ye,Ie=Math.max(Ce,I.width),$e=window.innerWidth-bt,Pe=Xa(fe,[bt,Math.max(bt,$e-Ie)]);c.style.minWidth=Ce+"px",c.style.left=Pe+"px"}else{const le=I.right-M.right,fe=window.innerWidth-P.right-le,ye=window.innerWidth-R.right-fe,Ce=R.width+ye,Ie=Math.max(Ce,I.width),$e=window.innerWidth-bt,Pe=Xa(fe,[bt,Math.max(bt,$e-Ie)]);c.style.minWidth=Ce+"px",c.style.right=Pe+"px"}const k=f(),A=window.innerHeight-bt*2,D=b.scrollHeight,$=window.getComputedStyle(m),J=parseInt($.borderTopWidth,10),X=parseInt($.paddingTop,10),F=parseInt($.borderBottomWidth,10),H=parseInt($.paddingBottom,10),Y=J+X+D+H+F,U=Math.min(y.offsetHeight*5,Y),W=window.getComputedStyle(b),me=parseInt(W.paddingTop,10),be=parseInt(W.paddingBottom,10),ve=R.top+R.height/2-bt,z=A-ve,se=y.offsetHeight/2,te=y.offsetTop+se,Se=J+X+te,Ne=Y-Se;if(Se<=ve){const le=k.length>0&&y===k[k.length-1].ref.current;c.style.bottom="0px";const fe=m.clientHeight-b.offsetTop-b.offsetHeight,ye=Math.max(z,se+(le?be:0)+fe+F),Ce=Se+ye;c.style.height=Ce+"px"}else{const le=k.length>0&&y===k[0].ref.current;c.style.top="0px";const ye=Math.max(ve,J+b.offsetTop+(le?me:0)+se)+Ne;c.style.height=ye+"px",b.scrollTop=Se-ve+b.offsetTop}c.style.margin=`${bt}px 0`,c.style.minHeight=U+"px",c.style.maxHeight=A+"px",o?.(),requestAnimationFrame(()=>h.current=!0)}},[f,a.trigger,a.valueNode,c,m,b,y,w,a.dir,o]);Ue(()=>j(),[j]);const[S,N]=l.useState();Ue(()=>{m&&N(window.getComputedStyle(m).zIndex)},[m]);const C=l.useCallback(R=>{R&&g.current===!0&&(j(),v?.(),g.current=!1)},[j,v]);return t.jsx(aw,{scope:s,contentWrapper:c,shouldExpandOnScrollRef:h,onScrollButtonChange:C,children:t.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:S},children:t.jsx(xe.div,{...r,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...r.style}})})})});np.displayName=ow;var rw="SelectPopperPosition",Za=l.forwardRef((e,n)=>{const{__scopeSelect:s,align:o="start",collisionPadding:r=bt,...a}=e,i=Mr(s);return t.jsx(wm,{...i,...a,ref:n,align:o,collisionPadding:r,style:{boxSizing:"border-box",...a.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Za.displayName=rw;var[aw,ul]=Pn(dn,{}),Qa="SelectViewport",sp=l.forwardRef((e,n)=>{const{__scopeSelect:s,nonce:o,...r}=e,a=pn(Qa,s),i=ul(Qa,s),c=Te(n,a.onViewportChange),d=l.useRef(0);return t.jsxs(t.Fragment,{children:[t.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),t.jsx(Er.Slot,{scope:s,children:t.jsx(xe.div,{"data-radix-select-viewport":"",role:"presentation",...r,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...r.style},onScroll:de(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-bt*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})})})]})});sp.displayName=Qa;var op="SelectGroup",[iw,lw]=Pn(op),cw=l.forwardRef((e,n)=>{const{__scopeSelect:s,...o}=e,r=Rt();return t.jsx(iw,{scope:s,id:r,children:t.jsx(xe.div,{role:"group","aria-labelledby":r,...o,ref:n})})});cw.displayName=op;var rp="SelectLabel",dw=l.forwardRef((e,n)=>{const{__scopeSelect:s,...o}=e,r=lw(rp,s);return t.jsx(xe.div,{id:r.id,...o,ref:n})});dw.displayName=rp;var Qo="SelectItem",[uw,ap]=Pn(Qo),ip=l.forwardRef((e,n)=>{const{__scopeSelect:s,value:o,disabled:r=!1,textValue:a,...i}=e,c=mn(Qo,s),d=pn(Qo,s),m=c.value===o,[u,p]=l.useState(a??""),[f,h]=l.useState(!1),g=He(j=>d.itemRefCallback?.(j,o,r)),b=Te(n,g),y=Rt(),w=l.useRef("touch"),v=()=>{r||(c.onValueChange(o),c.onOpenChange(!1))};return t.jsx(uw,{scope:s,value:o,disabled:r,textId:y,isSelected:m,onItemTextChange:l.useCallback(j=>{p(S=>S||(j?.textContent??"").trim())},[]),children:t.jsx(Er.ItemSlot,{scope:s,value:o,disabled:r,textValue:u,children:t.jsx(xe.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:de(i.onFocus,()=>h(!0)),onBlur:de(i.onBlur,()=>h(!1)),onClick:de(i.onClick,()=>{w.current!=="mouse"&&v()}),onPointerUp:de(i.onPointerUp,()=>{w.current==="mouse"&&v()}),onPointerDown:de(i.onPointerDown,j=>{w.current=j.pointerType}),onPointerMove:de(i.onPointerMove,j=>{w.current=j.pointerType,r?d.onItemLeave?.():w.current==="mouse"&&j.currentTarget.focus({preventScroll:!0})}),onPointerLeave:de(i.onPointerLeave,j=>{j.currentTarget===document.activeElement&&d.onItemLeave?.()}),onKeyDown:de(i.onKeyDown,j=>{r||j.target!==j.currentTarget||d.searchRef?.current!==""&&j.key===" "||(Ky.includes(j.key)&&v(),j.key===" "&&j.preventDefault())})})})})});ip.displayName=Qo;var ks="SelectItemText",lp=l.forwardRef((e,n)=>{const{__scopeSelect:s,className:o,style:r,...a}=e,i=mn(ks,s),c=pn(ks,s),d=ap(ks,s),m=Xy(ks,s),[u,p]=l.useState(null),f=He(v=>c.itemTextRefCallback?.(v,d.value,d.disabled)),h=Te(n,p,d.onItemTextChange,f),g=u?.textContent,b=l.useMemo(()=>t.jsx("option",{value:d.value,disabled:d.disabled,children:g},d.value),[d.disabled,d.value,g]),{onNativeOptionAdd:y,onNativeOptionRemove:w}=m;return Ue(()=>(y(b),()=>w(b)),[y,w,b]),t.jsxs(t.Fragment,{children:[t.jsx(xe.span,{id:d.textId,...a,ref:h}),d.isSelected&&i.valueNode&&!i.valueNodeHasChildren&&!Ar(i.value)?ms.createPortal(a.children,i.valueNode):null]})});lp.displayName=ks;var cp="SelectItemIndicator",dp=l.forwardRef((e,n)=>{const{__scopeSelect:s,...o}=e;return ap(cp,s).isSelected?t.jsx(xe.span,{"aria-hidden":!0,...o,ref:n}):null});dp.displayName=cp;var ei="SelectScrollUpButton",up=l.forwardRef((e,n)=>{const s=pn(ei,e.__scopeSelect),o=ul(ei,e.__scopeSelect),[r,a]=l.useState(!1),i=Te(n,o.onScrollButtonChange);return Ue(()=>{if(s.viewport&&s.isPositioned){let c=function(){const m=d.scrollTop>0;a(m)};const d=s.viewport;return c(),d.addEventListener("scroll",c),()=>d.removeEventListener("scroll",c)}},[s.viewport,s.isPositioned]),r?t.jsx(pp,{...e,ref:i,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=s;c&&d&&(c.scrollTop=c.scrollTop-d.offsetHeight)}}):null});up.displayName=ei;var ti="SelectScrollDownButton",mp=l.forwardRef((e,n)=>{const s=pn(ti,e.__scopeSelect),o=ul(ti,e.__scopeSelect),[r,a]=l.useState(!1),i=Te(n,o.onScrollButtonChange);return Ue(()=>{if(s.viewport&&s.isPositioned){let c=function(){const m=d.scrollHeight-d.clientHeight,u=Math.ceil(d.scrollTop)<m;a(u)};const d=s.viewport;return c(),d.addEventListener("scroll",c),()=>d.removeEventListener("scroll",c)}},[s.viewport,s.isPositioned]),r?t.jsx(pp,{...e,ref:i,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=s;c&&d&&(c.scrollTop=c.scrollTop+d.offsetHeight)}}):null});mp.displayName=ti;var pp=l.forwardRef((e,n)=>{const{__scopeSelect:s,onAutoScroll:o,...r}=e,a=pn("SelectScrollButton",s),i=l.useRef(null),c=Rr(s),d=l.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return l.useEffect(()=>()=>d(),[d]),Ue(()=>{c().find(u=>u.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[c]),t.jsx(xe.div,{"aria-hidden":!0,...r,ref:n,style:{flexShrink:0,...r.style},onPointerDown:de(r.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(o,50))}),onPointerMove:de(r.onPointerMove,()=>{a.onItemLeave?.(),i.current===null&&(i.current=window.setInterval(o,50))}),onPointerLeave:de(r.onPointerLeave,()=>{d()})})}),mw="SelectSeparator",pw=l.forwardRef((e,n)=>{const{__scopeSelect:s,...o}=e;return t.jsx(xe.div,{"aria-hidden":!0,...o,ref:n})});pw.displayName=mw;var fp="SelectArrow",fw=l.forwardRef((e,n)=>{const{__scopeSelect:s,...o}=e,r=Mr(s);return pn(fp,s).position==="popper"?t.jsx(jm,{...r,...o,ref:n}):null});fw.displayName=fp;var hp="SelectBubbleInput",xp=l.forwardRef(({__scopeSelect:e,...n},s)=>{const o=mn(hp,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=Te(s,h),b=r??"",y=Gv(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]),t.jsxs(xe.select,{"aria-hidden":!0,required:i,tabIndex:-1,name:d,autoComplete:m,disabled:c,form:u,onChange:v=>a(v.target.value),...n,style:{...vu,...n.style},ref:g,defaultValue:b,children:[Ar(r)&&!w?t.jsx("option",{value:""}):null,Array.from(p)]},f)});xp.displayName=hp;function hw(e){return typeof e=="function"}function Ar(e){return e===""||e===void 0}function gp(e){const n=He(e),s=l.useRef(""),o=l.useRef(0),r=l.useCallback(i=>{const c=s.current+i;n(c),(function d(m){s.current=m,window.clearTimeout(o.current),m!==""&&(o.current=window.setTimeout(()=>d(""),1e3))})(c)},[n]),a=l.useCallback(()=>{s.current="",window.clearTimeout(o.current)},[]);return l.useEffect(()=>()=>window.clearTimeout(o.current),[]),[s,r,a]}function bp(e,n,s){const r=n.length>1&&Array.from(n).every(m=>m===n[0])?n[0]:n,a=s?e.indexOf(s):-1;let i=xw(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 xw(e,n){return e.map((s,o)=>e[(n+o)%e.length])}var Ir="Tabs",[gw]=Jt(Ir,[Cm]),vp=Cm(),[bw,ml]=gw(Ir),yp=l.forwardRef((e,n)=>{const{__scopeTabs:s,value:o,onValueChange:r,defaultValue:a,orientation:i="horizontal",dir:c,activationMode:d="automatic",...m}=e,u=gr(c),[p,f]=En({prop:o,onChange:r,defaultProp:a??"",caller:Ir});return t.jsx(bw,{scope:s,baseId:Rt(),value:p,onValueChange:f,orientation:i,dir:u,activationMode:d,children:t.jsx(xe.div,{dir:u,"data-orientation":i,...m,ref:n})})});yp.displayName=Ir;var wp="TabsList",jp=l.forwardRef((e,n)=>{const{__scopeTabs:s,loop:o=!0,...r}=e,a=ml(wp,s),i=vp(s);return t.jsx(Ey,{asChild:!0,...i,orientation:a.orientation,dir:a.dir,loop:o,children:t.jsx(xe.div,{role:"tablist","aria-orientation":a.orientation,...r,ref:n})})});jp.displayName=wp;var Sp="TabsTrigger",Np=l.forwardRef((e,n)=>{const{__scopeTabs:s,value:o,disabled:r=!1,...a}=e,i=ml(Sp,s),c=vp(s),d=_p(i.baseId,o),m=Tp(i.baseId,o),u=o===i.value;return t.jsx(Ry,{asChild:!0,...c,focusable:!r,active:u,children:t.jsx(xe.button,{type:"button",role:"tab","aria-selected":u,"aria-controls":m,"data-state":u?"active":"inactive","data-disabled":r?"":void 0,disabled:r,id:d,...a,ref:n,onMouseDown:de(e.onMouseDown,p=>{!r&&p.button===0&&p.ctrlKey===!1?i.onValueChange(o):p.preventDefault()}),onKeyDown:de(e.onKeyDown,p=>{r||p.target!==p.currentTarget||[" ","Enter"].includes(p.key)&&i.onValueChange(o)}),onFocus:de(e.onFocus,()=>{const p=i.activationMode!=="manual";!u&&!r&&p&&i.onValueChange(o)})})})});Np.displayName=Sp;var Cp="TabsContent",kp=l.forwardRef((e,n)=>{const{__scopeTabs:s,value:o,forceMount:r,children:a,...i}=e,c=ml(Cp,s),d=_p(c.baseId,o),m=Tp(c.baseId,o),u=o===c.value,p=l.useRef(u);return l.useEffect(()=>{const f=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(f)},[]),t.jsx(lt,{present:r||u,children:({present:f})=>t.jsx(xe.div,{"data-state":u?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":d,hidden:!f,id:m,tabIndex:0,...i,ref:n,style:{...e.style,animationDuration:p.current?"0s":void 0},children:f&&a})})});kp.displayName=Cp;function _p(e,n){return`${e}-trigger-${n}`}function Tp(e,n){return`${e}-content-${n}`}var vw=yp,yw=jp,ww=Np,jw=kp,[Pr]=Jt("Tooltip",[kr]),Lr=kr(),Ep="TooltipProvider",Sw=700,ni="tooltip.open",[Nw,pl]=Pr(Ep),Rp=e=>{const{__scopeTooltip:n,delayDuration:s=Sw,skipDelayDuration:o=300,disableHoverableContent:r=!1,children:a}=e,i=l.useRef(!0),c=l.useRef(!1),d=l.useRef(0);return l.useEffect(()=>{const m=d.current;return()=>window.clearTimeout(m)},[]),t.jsx(Nw,{scope:n,isOpenDelayedRef:i,delayDuration:s,onOpen:l.useCallback(()=>{o<=0||(window.clearTimeout(d.current),i.current=!1)},[o]),onClose:l.useCallback(()=>{o<=0||(window.clearTimeout(d.current),d.current=window.setTimeout(()=>i.current=!0,o))},[o]),isPointerInTransitRef:c,onPointerInTransitChange:l.useCallback(m=>{c.current=m},[]),disableHoverableContent:r,children:a})};Rp.displayName=Ep;var Ls="Tooltip",[Cw,Ys]=Pr(Ls),Mp=e=>{const{__scopeTooltip:n,children:s,open:o,defaultOpen:r,onOpenChange:a,disableHoverableContent:i,delayDuration:c}=e,d=pl(Ls,e.__scopeTooltip),m=Lr(n),[u,p]=l.useState(null),f=Rt(),h=l.useRef(0),g=i??d.disableHoverableContent,b=c??d.delayDuration,y=l.useRef(!1),[w,v]=En({prop:o,defaultProp:r??!1,onChange:R=>{R?(d.onOpen(),document.dispatchEvent(new CustomEvent(ni))):d.onClose(),a?.(R)},caller:Ls}),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)},[]),t.jsx(vm,{...m,children:t.jsx(Cw,{scope:n,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})})};Mp.displayName=Ls;var si="TooltipTrigger",Ap=l.forwardRef((e,n)=>{const{__scopeTooltip:s,...o}=e,r=Ys(si,s),a=pl(si,s),i=Lr(s),c=l.useRef(null),d=Te(n,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]),t.jsx(ym,{asChild:!0,...i,children:t.jsx(xe.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...o,ref:d,onPointerMove:de(e.onPointerMove,f=>{f.pointerType!=="touch"&&!u.current&&!a.isPointerInTransitRef.current&&(r.onTriggerEnter(),u.current=!0)}),onPointerLeave:de(e.onPointerLeave,()=>{r.onTriggerLeave(),u.current=!1}),onPointerDown:de(e.onPointerDown,()=>{r.open&&r.onClose(),m.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:de(e.onFocus,()=>{m.current||r.onOpen()}),onBlur:de(e.onBlur,r.onClose),onClick:de(e.onClick,r.onClose)})})});Ap.displayName=si;var fl="TooltipPortal",[kw,_w]=Pr(fl,{forceMount:void 0}),Ip=e=>{const{__scopeTooltip:n,forceMount:s,children:o,container:r}=e,a=Ys(fl,n);return t.jsx(kw,{scope:n,forceMount:s,children:t.jsx(lt,{present:s||a.open,children:t.jsx(vr,{asChild:!0,container:r,children:o})})})};Ip.displayName=fl;var cs="TooltipContent",Pp=l.forwardRef((e,n)=>{const s=_w(cs,e.__scopeTooltip),{forceMount:o=s.forceMount,side:r="top",...a}=e,i=Ys(cs,e.__scopeTooltip);return t.jsx(lt,{present:o||i.open,children:i.disableHoverableContent?t.jsx(Lp,{side:r,...a,ref:n}):t.jsx(Tw,{side:r,...a,ref:n})})}),Tw=l.forwardRef((e,n)=>{const s=Ys(cs,e.__scopeTooltip),o=pl(cs,e.__scopeTooltip),r=l.useRef(null),a=Te(n,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=Aw(w,y.getBoundingClientRect()),j=Iw(w,v),S=Pw(b.getBoundingClientRect()),N=Ow([...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=!Lw(w,i);v?f():j&&(f(),m())};return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}},[d,u,i,m,f]),t.jsx(Lp,{...e,ref:a})}),[Ew,Rw]=Pr(Ls,{isInside:!1}),Mw=mb("TooltipContent"),Lp=l.forwardRef((e,n)=>{const{__scopeTooltip:s,children:o,"aria-label":r,onEscapeKeyDown:a,onPointerDownOutside:i,...c}=e,d=Ys(cs,s),m=Lr(s),{onClose:u}=d;return l.useEffect(()=>(document.addEventListener(ni,u),()=>document.removeEventListener(ni,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]),t.jsx(br,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:p=>p.preventDefault(),onDismiss:u,children:t.jsxs(wm,{"data-state":d.stateAttribute,...m,...c,ref:n,style:{...c.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[t.jsx(Mw,{children:o}),t.jsx(Ew,{scope:s,isInside:!0,children:t.jsx(Nb,{id:d.contentId,role:"tooltip",children:r||o})})]})})});Pp.displayName=cs;var Op="TooltipArrow",Dp=l.forwardRef((e,n)=>{const{__scopeTooltip:s,...o}=e,r=Lr(s);return Rw(Op,s).isInside?null:t.jsx(jm,{...r,...o,ref:n})});Dp.displayName=Op;function Aw(e,n){const s=Math.abs(n.top-e.y),o=Math.abs(n.bottom-e.y),r=Math.abs(n.right-e.x),a=Math.abs(n.left-e.x);switch(Math.min(s,o,r,a)){case a:return"left";case r:return"right";case s:return"top";case o:return"bottom";default:throw new Error("unreachable")}}function Iw(e,n,s=5){const o=[];switch(n){case"top":o.push({x:e.x-s,y:e.y+s},{x:e.x+s,y:e.y+s});break;case"bottom":o.push({x:e.x-s,y:e.y-s},{x:e.x+s,y:e.y-s});break;case"left":o.push({x:e.x+s,y:e.y-s},{x:e.x+s,y:e.y+s});break;case"right":o.push({x:e.x-s,y:e.y-s},{x:e.x-s,y:e.y+s});break}return o}function Pw(e){const{top:n,right:s,bottom:o,left:r}=e;return[{x:r,y:n},{x:s,y:n},{x:s,y:o},{x:r,y:o}]}function Lw(e,n){const{x:s,y:o}=e;let r=!1;for(let a=0,i=n.length-1;a<n.length;i=a++){const c=n[a],d=n[i],m=c.x,u=c.y,p=d.x,f=d.y;u>o!=f>o&&s<(p-m)*(o-u)/(f-u)+m&&(r=!r)}return r}function Ow(e){const n=e.slice();return n.sort((s,o)=>s.x<o.x?-1:s.x>o.x?1:s.y<o.y?-1:s.y>o.y?1:0),Dw(n)}function Dw(e){if(e.length<=1)return e.slice();const n=[];for(let o=0;o<e.length;o++){const r=e[o];for(;n.length>=2;){const a=n[n.length-1],i=n[n.length-2];if((a.x-i.x)*(r.y-i.y)>=(a.y-i.y)*(r.x-i.x))n.pop();else break}n.push(r)}n.pop();const s=[];for(let o=e.length-1;o>=0;o--){const r=e[o];for(;s.length>=2;){const a=s[s.length-1],i=s[s.length-2];if((a.x-i.x)*(r.y-i.y)>=(a.y-i.y)*(r.x-i.x))s.pop();else break}s.push(r)}return s.pop(),n.length===1&&s.length===1&&n[0].x===s[0].x&&n[0].y===s[0].y?n:n.concat(s)}var zw=Rp,$w=Mp,Fw=Ap,Uw=Ip,Bw=Pp,qw=Dp;function Pt({...e}){return t.jsx($u,{"data-slot":"dialog",...e})}function Xs({...e}){return t.jsx(Uu,{"data-slot":"dialog-trigger",...e})}function Hw({...e}){return t.jsx(qu,{"data-slot":"dialog-portal",...e})}function Ww({className:e,...n}){return t.jsx(Hu,{"data-slot":"dialog-overlay",className:O("fixed inset-0 z-40 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...n})}function Lt({className:e,children:n,...s}){return t.jsxs(Hw,{children:[t.jsx(Ww,{}),t.jsxs(Wu,{"data-slot":"dialog-content",className:O("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-lg",e),...s,children:[n,t.jsxs(Zu,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[t.jsx(Ks,{className:"size-4"}),t.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Ft({className:e,...n}){return t.jsx("div",{"data-slot":"dialog-header",className:O("flex flex-col space-y-1.5 text-center sm:text-left",e),...n})}function Ut({className:e,...n}){return t.jsx(Gu,{"data-slot":"dialog-title",className:O("text-lg font-semibold leading-none tracking-tight",e),...n})}function Zs({className:e,...n}){return t.jsx(Yu,{"data-slot":"dialog-description",className:O("text-sm text-muted-foreground",e),...n})}function zp({open:e,onOpenChange:n,title:s,description:o,confirmLabel:r="Confirm",variant:a="default",onConfirm:i}){return t.jsx(Pt,{open:e,onOpenChange:n,children:t.jsxs(Lt,{children:[t.jsx(Ft,{children:t.jsx(Ut,{children:s})}),t.jsx("p",{className:"text-sm text-muted-foreground",children:o}),t.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[t.jsx(ee,{variant:"outline",size:"sm",onClick:()=>n(!1),children:"Cancel"}),t.jsx(ee,{variant:a,size:"sm",onClick:()=>{i(),n(!1)},children:r})]})]})})}const Vw="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",Kw="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",Gw="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",Jw="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",Yw=""+new URL("agent-inspector-58K1_MsC.ico",import.meta.url).href,Xw={"agent-inspector":"Inspector",codex:"Codex",opencode:"OpenCode","mimo-code":"MiMo Code","claude-code":"Claude Code","ai-sdk":"AI SDK"};function mo(e){return e?.toLowerCase()??""}function Un(e,n){for(const s of n)if(e.includes(s))return!0;return!1}function hl(e){const n=[mo(e.userAgent),mo(e.conversationId),mo(e.clientProjectFolder)].join(" ");return Un(n,["agent-inspector","agent inspector","provider-test"])?"agent-inspector":Un(n,["mimocode","mimo-code","mimo code"])?"mimo-code":Un(n,["opencode","open-code","open code"])?"opencode":Un(n,["claude-code","claude code","claudecode","claude-cli","claude cli"])?"claude-code":Un(n,["codex desktop","codex-cli","openai-codex","codex"])?"codex":Un(mo(e.userAgent),["ai-sdk","ai/"])?"ai-sdk":"unknown"}function Or(e){switch(e){case"agent-inspector":case"codex":case"opencode":case"mimo-code":case"claude-code":case"ai-sdk":return Xw[e];case"unknown":return null}}function Zw(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 Qw={"agent-inspector":Yw,codex:Kw,opencode:Gw,"mimo-code":Jw,"claude-code":Vw},ej={"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]"},tj={"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 Dr({client:e,className:n,decorative:s=!1}){if(e==="unknown")return null;const o=Or(e);if(o===null)return null;if(e==="ai-sdk")return t.jsx("span",{className:O("inline-flex size-6 shrink-0 items-center justify-center rounded-md border border-cyan-700/15 bg-cyan-500/[0.08] text-[var(--inspector-status-cool)] shadow-sm dark:border-cyan-200/20 dark:bg-cyan-300/[0.08]",n),"aria-label":s?void 0:o,"aria-hidden":s?!0:void 0,title:o,children:t.jsx(su,{className:"size-1/2","aria-hidden":"true"})});const r=Qw[e];return t.jsx("span",{className:O("inline-flex size-6 shrink-0 items-center justify-center rounded-md border p-0 shadow-sm",ej[e],n),"aria-label":s?void 0:o,"aria-hidden":s?!0:void 0,title:o,children:t.jsx("img",{src:r,alt:"",className:O("size-full object-contain",tj[e]),"aria-hidden":"true"})})}const nj="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",sj="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",oj="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",rj=""+new URL("minimax-BPMzvuL-.jpeg",import.meta.url).href,aj=""+new URL("alibaba-TTwafVwX.svg",import.meta.url).href,ij=""+new URL("qwen-mMn3f5ul.webp",import.meta.url).href,lj=""+new URL("zhipuai-BPNAnxo-.svg",import.meta.url).href,cj={"claude-":"anthropic","gpt-":"openai","o1-":"openai","o3-":"openai","deepseek-":"deepseek",MiniMax:"minimax",qwen:"qwen"};function dj(e){return e.replace(/[_\s]+/g,"-").split(/[/:@]/).some(s=>s.startsWith("glm-"))}function uj(e){if(e===null)return"unknown";const n=e.toLowerCase();if(dj(n))return"zhipuai";for(const[s,o]of Object.entries(cj))if(n.startsWith(s.toLowerCase()))return o;return"unknown"}const Ln={width:24,height:24,objectFit:"contain"},mj=An.memo(({className:e})=>t.jsx("img",{src:nj,alt:"Anthropic",className:e,style:Ln})),pj=An.memo(({className:e})=>t.jsx("img",{src:sj,alt:"OpenAI",className:e,style:{...Ln,background:"white",borderRadius:"4px"}})),fj=An.memo(({className:e})=>t.jsx("img",{src:oj,alt:"DeepSeek",className:e,style:Ln})),hj=An.memo(({className:e})=>t.jsx("img",{src:rj,alt:"MiniMax",className:e,style:Ln})),xj=An.memo(({className:e})=>t.jsx("img",{src:aj,alt:"Alibaba",className:e,style:Ln})),gj=An.memo(({className:e})=>t.jsx("img",{src:ij,alt:"Qwen",className:e,style:Ln})),bj=An.memo(({className:e})=>t.jsx("img",{src:lj,alt:"ZhipuAI",className:e,style:Ln}));function vj({provider:e,className:n}){switch(e){case"anthropic":return t.jsx(mj,{className:n});case"openai":return t.jsx(pj,{className:n});case"deepseek":return t.jsx(fj,{className:n});case"minimax":return t.jsx(hj,{className:n});case"alibaba":return t.jsx(xj,{className:n});case"qwen":return t.jsx(gj,{className:n});case"zhipuai":return t.jsx(bj,{className:n});case"unknown":return null}}function hs({delayDuration:e=600,...n}){return t.jsx(zw,{"data-slot":"tooltip-provider",delayDuration:e,...n})}function et({...e}){return t.jsx($w,{"data-slot":"tooltip",...e})}function tt({...e}){return t.jsx(Fw,{"data-slot":"tooltip-trigger",...e})}function nt({className:e,sideOffset:n=0,children:s,...o}){return t.jsx(Uw,{children:t.jsxs(Bw,{"data-slot":"tooltip-content",sideOffset:n,className:O("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...o,children:[s,t.jsx(qw,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}const yj=3;function wj({items:e,ariaLabel:n,className:s}){if(e.length===0)return t.jsx("span",{className:O("flex h-8 w-12 shrink-0 items-center",s),"aria-hidden":"true"});const o=e.slice(0,yj),r=e.length-o.length;return t.jsx(hs,{delayDuration:150,children:t.jsxs("span",{className:O("flex h-8 w-12 shrink-0 items-center",s),"aria-label":n,children:[o.map((a,i)=>t.jsxs(et,{children:[t.jsx(tt,{asChild:!0,children:t.jsx("span",{className:O("border border-border bg-muted/40 inline-flex size-6 shrink-0 items-center justify-center rounded-md",i>0&&"-ml-2"),children:t.jsx(vj,{provider:a.provider,className:"size-4"})})}),t.jsx(nt,{children:a.tooltip})]},`${a.provider}-${String(i)}`)),r>0&&t.jsxs("span",{className:"border border-border bg-muted/40 -ml-2 inline-flex h-6 min-w-6 shrink-0 items-center justify-center rounded-md px-1 font-mono text-[10px] text-muted-foreground",children:["+",r]})]})})}const jj=[["/v1/messages","anthropic"],["/v1/chat/completions","openai"],["/chat/completions","openai"],["/v1/responses","openai"],["/responses","openai"]];function Sj(e){const n=e.split("?")[0]??"";for(const[s,o]of jj)if(n===s)return o;return"unknown"}function $p(e,n){for(const s of Array.from(e))n(s)}const Nj=/[\u3000-\u9FFF\uAC00-\uD7FF\uF900-\uFAFF\uFF00-\uFFEF\u{1F300}-\u{1FAFF}]/u;function xl(e){if(e.length===0)return 0;let n=0,s=0;return $p(e,o=>{Nj.test(o)?n+=1:s+=1}),Math.ceil(n*1)+Math.ceil(s/4)}function gl(e){if(e.length===0)return 0;let n=0;return $p(e,()=>{n+=1}),n}function bl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Z(e,n){return e===null||typeof e!="object"||Array.isArray(e)?void 0:Object.getOwnPropertyDescriptor(e,n)?.value}const Cj=["file","shell","browser","web","mcp","code","other"];function oi(e){const n=e.replace(/\s+/g," ").trim();return n.length<=120?n:`${n.slice(0,119)}...`}function Fp(e){if(e===null)return null;const n=e.replace(/\s+/g," ").trim();if(n.length===0)return null;const s=n.search(/[.!?。!?]/);return s>=24?oi(n.slice(0,s+1)):oi(n)}function kj(e,n){return`${e} ${n??""}`.toLowerCase()}function Bn(e,n){return n.some(s=>e.includes(s))}function Up(e,n){const s=kj(e,n);return e.startsWith("mcp__")||e.startsWith("inspector_")||Bn(s,[" mcp","model context protocol"])?"mcp":Bn(s,["bash","shell","terminal","command","powershell","exec","process"])?"shell":Bn(s,["browser","playwright","screenshot","click","navigate","page","tab"])?"browser":Bn(s,["read","write","edit","file","glob","grep","patch","filesystem","directory"])?"file":Bn(s,["web","search","http","url","fetch"])?"web":Bn(s,["code","typescript","javascript","python","repl"])?"code":"other"}function Bp(e){const n=Z(e,"properties");return n===null||typeof n!="object"||Array.isArray(n)?[]:Object.keys(n).sort((s,o)=>s.localeCompare(o))}function qp(e){const n=Z(e,"required");if(!Array.isArray(n))return[];const s=[];for(const o of n)typeof o=="string"&&o.length>0&&s.push(o);return s.sort((o,r)=>o.localeCompare(r))}function _j(e){const n=Z(e,"name");if(typeof n!="string"||n.length===0)return null;const s=Z(e,"description"),o=Z(e,"input_schema")??null,r=typeof s=="string"?s:null;return{name:n,description:r,descriptionPreview:Fp(r),category:Up(n,r),parameterCount:Bp(o).length,requiredParameters:qp(o),schema:o}}function Tj(e){const n=Z(e,"function"),s=Z(e,"type");if(n===void 0&&typeof s!="string")return null;const o=Z(n,"name")??Z(e,"name")??(typeof s=="string"?s:void 0);if(typeof o!="string"||o.length===0)return null;const r=Z(n,"description")??Z(e,"description"),a=Z(n,"parameters")??Z(e,"parameters")??null,i=typeof r=="string"?r:null;return{name:o,description:i,descriptionPreview:Fp(i),category:Up(o,i),parameterCount:Bp(a).length,requiredParameters:qp(a),schema:a}}function Ej(e){const n=Tj(e);return n!==null?n:_j(e)}function Rj(e){if(e==null)return null;if(typeof e=="string")return e;const n=Z(e,"type"),s=Z(e,"name"),o=Z(Z(e,"function"),"name");if(typeof n=="string"&&typeof o=="string"&&o.length>0)return`${n}: ${o}`;if(typeof n=="string"&&typeof s=="string"&&s.length>0)return`${n}: ${s}`;if(typeof n=="string")return n;const r=JSON.stringify(e);return r===void 0?null:oi(r)}function Mj(e){const n=new Map;for(const s of e)n.set(s.category,(n.get(s.category)??0)+1);return Cj.flatMap(s=>{const o=n.get(s)??0;return o>0?[{category:s,count:o}]:[]})}function vl(e){const n=Z(e,"tools");if(!Array.isArray(n)||n.length===0)return null;const s=[];for(const o of n){const r=Ej(o);r!==null&&s.push(r)}return s.length===0?null:{tools:s,toolChoiceLabel:Rj(Z(e,"tool_choice")),categories:Mj(s)}}function Tn(e){return{parsed:null,comparisonValue:e,messageCount:null,toolCount:null}}const es={parsed:null,toolNames:null};function Aj(e){if(typeof e=="string")return e;if(!Array.isArray(e))return"";const n=[];for(const s of e){if(s===null||typeof s!="object")continue;const o=s;switch(o.type){case"text":typeof o.text=="string"&&n.push(o.text);break;case"thinking":case"think":typeof o.thinking=="string"&&n.push(o.thinking);break;case"tool_use":{const a=typeof o.name=="string"?o.name:"",i=o.input!==void 0?JSON.stringify(o.input):"";n.push(`${a} ${i}`.trim());break}case"tool_result":{const a=o.content;if(typeof a=="string")n.push(a);else if(Array.isArray(a)){for(const i of a)if(i!==null&&typeof i=="object"){const c=i.text;typeof c=="string"&&n.push(c)}}break}case"image":n.push("[image]");break}}return n.join(`
|
|
43
|
-
`)}function Ij(e){if(typeof e=="string")return e;if(!Array.isArray(e))return"";const n=[];for(const s of e)if(s!==null&&typeof s=="object"){const o=s.text;s.type==="text"&&typeof o=="string"&&n.push(o)}return n.join(`
|
|
44
|
-
`)}function Pj(e){if(!Array.isArray(e))return"";const n=[];for(const s of e){if(s===null||typeof s!="object")continue;const o=s;typeof o.name=="string"&&n.push(o.name),typeof o.description=="string"&&n.push(o.description),o.input_schema!==void 0&&n.push(JSON.stringify(o.input_schema))}return n.join(`
|
|
45
|
-
`)}function ia(e,n,s,o){return{role:e,label:n,text:s,size:xl(s),characters:gl(s),path:o}}const Lj={format:"anthropic",analyzeRequest(e){if(e===null)return Tn(e);try{const n=JSON.parse(e),s=vl(n)?.tools.length??null,o=Wh.safeParse(n);return o.success?{parsed:o.data,comparisonValue:o.data,messageCount:o.data.messages.length,toolCount:s}:Tn(e)}catch{return Tn(e)}},analyzeResponse(e){if(e===null)return es;try{let n=JSON.parse(e);typeof n=="string"&&(n=JSON.parse(n));const s=Kh.safeParse(n);if(!s.success)return es;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 es}},anatomySegments(e){if(e===null||typeof e!="object")return null;const n=e,s=[];if(n.system!==void 0){const o=Ij(n.system);o.length>0&&s.push(ia("system","system",o,"/system"))}if(Array.isArray(n.messages)&&n.messages.forEach((o,r)=>{if(o===null||typeof o!="object")return;const a=o,i=a.role==="user"||a.role==="assistant"?a.role:"user",c=Aj(a.content);s.push(ia(i,`[${r}] ${i}`,c,`/messages/${r}`))}),Array.isArray(n.tools)&&n.tools.length>0){const o=Pj(n.tools);s.push(ia("tools","tools",o,"/tools"))}return s.length>0?s:null}};function ri(e){if(typeof e=="string")return e;if(!Array.isArray(e))return"";const n=[];for(const s of e){if(s===null||typeof s!="object")continue;const o=s,r=o.type;(r==="text"||r==="input_text"||r==="output_text")&&typeof o.text=="string"?n.push(o.text):(r==="image_url"||r==="input_image")&&n.push("[image]")}return n.join(`
|
|
46
|
-
`)}function Oj(e){const n=[],s=ri(e.content);s.length>0&&n.push(s);const o=typeof e.reasoning_content=="string"?e.reasoning_content:typeof e.thinking=="string"?e.thinking:typeof e.think=="string"?e.think:"";o.length>0&&n.push(o);const r=e.tool_calls;if(Array.isArray(r))for(const a of r){if(a===null||typeof a!="object")continue;const i=a.function;if(i===void 0)continue;const c=typeof i.name=="string"?i.name:"",d=typeof i.arguments=="string"?i.arguments:"";n.push(`${c} ${d}`.trim())}return n.join(`
|
|
47
|
-
`)}function Dj(e){if(!Array.isArray(e))return"";const n=[];for(const s of e){if(s===null||typeof s!="object")continue;const o=Z(s,"function"),r=Z(o,"name")??Z(s,"name"),a=Z(o,"description")??Z(s,"description"),i=Z(o,"parameters")??Z(s,"parameters");typeof r=="string"&&n.push(r),typeof a=="string"&&n.push(a),i!==void 0&&n.push(JSON.stringify(i))}return n.join(`
|
|
48
|
-
`)}function zj(e){return typeof e=="string"?e.length>0?1:0:Array.isArray(e)?e.length:e==null?null:1}function $j(e){if(typeof e=="string")return e;const n=Z(e,"text");if(typeof n=="string")return n;const s=ri(Z(e,"content"));if(s.length>0)return s;const o=ri(Z(e,"output"));if(o.length>0)return o;const r=Z(e,"arguments");return typeof r=="string"?r:""}function Fj(e){const n=Z(e,"role");if(n==="system"||n==="user"||n==="assistant"||n==="tool")return n;const s=Z(e,"type");return s==="function_call_output"?"tool":"user"}function Uj(e){const n=Z(e,"output");if(!Array.isArray(n))return[];const s=[];for(const o of n){if(Z(o,"type")!=="function_call")continue;const r=Z(o,"name");typeof r=="string"&&r.length>0&&s.push(r)}return s}function vs(e,n,s,o){return{role:e,label:n,text:s,size:xl(s),characters:gl(s),path:o}}const Bj={format:"openai",analyzeRequest(e){if(e===null)return Tn(e);try{const n=JSON.parse(e),s=vl(n)?.tools.length??null,o=ax.safeParse(n);if(!o.success){const r=lx.safeParse(n);return r.success?{parsed:r.data,comparisonValue:r.data,messageCount:zj(r.data.input),toolCount:s}:Tn(e)}return{parsed:o.data,comparisonValue:o.data,messageCount:o.data.messages.length,toolCount:s}}catch{return Tn(e)}},analyzeResponse(e){if(e===null)return es;const n=fx(e);if(n===null){const o=hx(e);if(o===null)return es;const r=Uj(o);return{parsed:o,toolNames:r.length>0?r:null}}const s=n.choices[0]?.message?.tool_calls?.map(o=>o.function?.name??"").filter(o=>o!=="")??[];return{parsed:n,toolNames:s.length>0?s:null}},anatomySegments(e){if(e===null||typeof e!="object")return null;const n=e,s=[];if(typeof n.instructions=="string"&&n.instructions.length>0&&s.push(vs("system","instructions",n.instructions,"/instructions")),Array.isArray(n.messages)&&n.messages.forEach((o,r)=>{if(o===null||typeof o!="object")return;const a=o,i=a.role==="user"||a.role==="assistant"||a.role==="system"||a.role==="tool"?a.role:"user",c=Oj(a);s.push(vs(i,`[${r}] ${i}`,c,`/messages/${r}`))}),Array.isArray(n.messages)||(typeof n.input=="string"&&n.input.length>0?s.push(vs("user","input",n.input,"/input")):Array.isArray(n.input)&&n.input.forEach((o,r)=>{const a=Fj(o),i=$j(o);s.push(vs(a,`[${r}] ${a}`,i,`/input/${r}`))})),Array.isArray(n.tools)&&n.tools.length>0){const o=Dj(n.tools);s.push(vs("tools","tools",o,"/tools"))}return s.length>0?s:null}},qj={format:"unknown",analyzeRequest(e){return Tn(e)},analyzeResponse(){return es},anatomySegments(){return null}},Hj={anthropic:Lj,openai:Bj,unknown:qj};function Hp(e){return Hj[e]}function Os(e){const n=Sj(e.path);return n==="unknown"?e.apiFormat:n}const bc="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 Wp(e){return e.startsWith("PID:")||e.startsWith("process:")||e.startsWith("connection:")||e.includes("|")}function Wj(e){return Wp(e)?"No session ID":e.length>24?`${e.slice(0,12)}...${e.slice(-12)}`:e}function la({icon:e,children:n,title:s,className:o}){return t.jsxs("span",{className:O("inline-flex h-7 min-w-0 items-center gap-1.5 rounded-md bg-[var(--inspector-surface-low)] px-2 text-xs text-muted-foreground",o),title:s,children:[e,t.jsx("span",{className:"min-w-0 font-mono tabular-nums",children:n})]})}function Vj(){return t.jsxs("span",{className:"inline-flex h-6 shrink-0 items-center gap-1.5 rounded-md bg-[var(--inspector-surface-medium)] px-1.5 font-mono text-[10px] uppercase text-[var(--inspector-status-watch)] ring-1 ring-border/50",title:"This session has a turn that has not finished yet",children:[t.jsx(Ae,{className:"size-3 animate-spin"}),"Turn open"]})}function Kj({conversationId:e,startTime:n,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=J=>{J.stopPropagation(),y!==void 0&&v(!0)},S=l.useCallback(J=>{J.stopPropagation(),window.open(Ad(e),"_blank","noopener,noreferrer")},[e]),N=d?.map(({provider:J,models:X})=>({provider:J,tooltip:X.length===1?X[0]??J:X.join(", ")}))??[],C=hl({userAgent:u,conversationId:e,clientProjectFolder:f}),R=Or(C),I=u!=null&&u!=="",P=R??u??null,M=R!==null&&I?`${R} - ${u}`:null,k=Wp(e),A=Wj(e),D=hr(n,s,b),$=`${o} call${o!==1?"s":""}`;return t.jsxs("div",{role:"button",tabIndex:0,"data-nav-id":`conv-${e}`,"data-nav-action":i?"collapse":"expand",className:O("relative flex cursor-pointer items-start gap-2.5 overflow-hidden rounded-md bg-[var(--inspector-surface-low)] px-3 py-2.5 transition-colors","hover:bg-[var(--inspector-surface-medium)]","select-none","sticky top-0 z-10 mb-2","focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none"),onClick:c,onKeyDown:J=>{J.target===J.currentTarget&&(J.key==="Enter"||J.key===" ")&&(J.preventDefault(),c())},children:[t.jsx(wj,{items:N,ariaLabel:"Models used in this session",className:"mt-0.5"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[t.jsx("span",{className:"shrink-0 rounded bg-[var(--inspector-surface-medium)] px-1.5 py-0.5 font-mono text-[9px] uppercase text-muted-foreground",children:"Session"}),k&&g?p!=null?t.jsxs("span",{className:"min-w-0 max-w-full truncate font-mono text-xs font-semibold text-foreground",title:`PID ${p}`,children:["PID ",p]}):t.jsx("span",{className:"min-w-0 max-w-full truncate font-mono text-xs font-semibold text-foreground",title:e,children:e}):t.jsx("span",{className:"min-w-0 max-w-full truncate font-mono text-xs font-semibold text-foreground",title:e,children:A}),!k&&g&&p!==null&&p!==void 0&&t.jsxs("span",{className:"shrink-0 rounded bg-[var(--inspector-surface-medium)] px-1.5 py-0.5 font-mono text-xs tabular-nums text-muted-foreground",title:`Client process ID ${p}`,children:["PID ",p]}),k&&g&&f!==null&&f!==void 0&&f!==""&&t.jsx("span",{className:"min-w-0 max-w-[240px] truncate font-mono text-xs text-muted-foreground",title:f,children:f}),h&&P!==null&&P!==""&&t.jsxs("span",{className:"inline-flex min-h-6 shrink-0 flex-wrap items-center gap-1 rounded-md bg-[var(--inspector-surface-medium)] px-1.5 py-0.5 text-xs text-muted-foreground",title:M??P,children:[t.jsx(Dr,{client:C,className:"size-4 shrink-0",decorative:!0}),t.jsx("span",{className:"font-mono leading-snug tabular-nums",children:P})]}),m&&t.jsx(Vj,{})]}),t.jsxs("span",{className:"mt-1.5 flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx(la,{icon:t.jsx(Wt,{className:"size-3 shrink-0"}),title:D,children:D}),t.jsx(la,{icon:t.jsx(fr,{className:"size-3 shrink-0"}),children:$}),t.jsxs(la,{icon:t.jsx(Is,{className:"size-3 shrink-0"}),className:"max-w-full",children:[t.jsx("span",{className:"text-[var(--inspector-status-info)]",children:Ee(r)})," / ",t.jsx("span",{className:"text-[var(--inspector-status-watch)]",children:Ee(a)})]})]})]}),t.jsxs("span",{className:"flex shrink-0 items-start gap-1.5",children:[t.jsx("button",{type:"button",onClick:S,onKeyDown:J=>{(J.key==="Enter"||J.key===" ")&&S(J)},"aria-label":`Open session ${e} in a new tab`,title:"Open this session in a new tab",className:bc,children:t.jsx(Di,{className:"size-3.5"})}),y!==void 0&&t.jsx("button",{type:"button",onClick:j,"aria-label":`Clear group (${o} request${o!==1?"s":""})`,title:"Clear this group from the current view",className:bc,children:t.jsx(an,{className:"size-3.5"})}),t.jsx("span",{className:"inline-flex size-8 shrink-0 items-center justify-center rounded-md bg-[var(--inspector-surface-low)] text-muted-foreground transition-colors hover:bg-[var(--inspector-surface-medium)] hover:text-foreground","aria-hidden":"true",children:i?t.jsx(Ve,{className:"size-4 shrink-0"}):m?t.jsx(Ae,{className:"size-4 shrink-0 animate-spin"}):t.jsx(it,{className:"size-4 shrink-0"})})]}),m&&t.jsx("span",{className:"pointer-events-none absolute inset-x-3 bottom-0 h-px overflow-hidden rounded-full bg-[var(--inspector-surface-medium)]","aria-hidden":"true",children:t.jsx("span",{className:"absolute inset-y-0 left-0 w-1/3 animate-pulse rounded-full bg-[var(--inspector-status-watch)] opacity-70"})}),t.jsx(zp,{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 Gj(e){if(e.sessionId!==null&&e.sessionId!==""&&e.sessionId!==void 0)return e.sessionId;if(e.isTest===!0)return"provider-test";const n=e.clientPid!==null&&e.clientPid!==void 0,s=e.clientProjectFolder!==null&&e.clientProjectFolder!==void 0;if(!n&&!s)return"default";const o=n?`PID:${e.clientPid}`:"unknown",r=s?e.clientProjectFolder:"no-folder";return`${o}|${r}`}function Jj(e){const n=new Map;for(const o of e){const r=Gj(o),a=n.get(r);a!==void 0?a.push(o):n.set(r,[o])}const s=[];for(const[o,r]of n){const a=[...r].sort((i,c)=>i.timestamp.localeCompare(c.timestamp));s.push({id:o,conversationId:o,logs:a})}return s.sort((o,r)=>(o.logs[0]?.timestamp??"").localeCompare(r.logs[0]?.timestamp??"")),s}function Yj(e,n,s){const o=new Array(e);return new Proxy(o,{get(r,a,i){if(typeof a=="string"){const c=a.charCodeAt(0);if(c>=48&&c<=57){const d=+a;if(Number.isInteger(d)&&d>=0&&d<e){let m=r[d];if(!m){const u=n[d*2];m=r[d]={index:d,key:s(d),start:u,size:n[d*2+1],end:u+n[d*2+1],lane:0}}return m}}if(a==="length")return e}return Reflect.get(r,a,i)}})}function qn(e,n,s){let o=s.initialDeps??[],r,a=!0;function i(){const c=e();return(c.length!==o.length||c.some((m,u)=>o[u]!==m))&&(o=c,r=n(...c),s?.onChange&&!(a&&s.skipInitialOnChange)&&s.onChange(r),a=!1),r}return i.updateDeps=c=>{o=c},i}function vc(e,n){if(e===void 0)throw new Error("Unexpected undefined");return e}const Xj=(e,n)=>Math.abs(e-n)<1.01,Zj=(e,n,s)=>{let o;return function(...r){e.clearTimeout(o),o=e.setTimeout(()=>n.apply(this,r),s)}};let ys;const ca=()=>{if(ys!==void 0)return ys;if(typeof navigator>"u")return ys=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return ys=!0;const e=navigator.maxTouchPoints;return ys=navigator.platform==="MacIntel"&&e!==void 0&&e>0},yc=e=>{const{offsetWidth:n,offsetHeight:s}=e;return{width:n,height:s}},Qj=e=>e,e5=e=>{const n=Math.max(e.startIndex-e.overscan,0),o=Math.min(e.endIndex+e.overscan,e.count-1)-n+1,r=new Array(o);for(let a=0;a<o;a++)r[a]=n+a;return r},t5=(e,n)=>{const s=e.scrollElement;if(!s)return;const o=e.targetWindow;if(!o)return;const r=i=>{const{width:c,height:d}=i;n({width:Math.round(c),height:Math.round(d)})};if(r(yc(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(yc(s))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(c):c()});return a.observe(s,{box:"border-box"}),()=>{a.unobserve(s)}},Ds={passive:!0},n5=(e,n)=>{const s=e.scrollElement;if(!s)return;const o=()=>{n({width:s.innerWidth,height:s.innerHeight})};return o(),s.addEventListener("resize",o,Ds),()=>{s.removeEventListener("resize",o)}},s5=typeof window>"u"?!0:"onscrollend"in window,Vp=(e,n,s)=>{const o=e.scrollElement;if(!o)return;const r=e.targetWindow;if(!r)return;const a=e.options.useScrollendEvent&&s5;let i=0;const c=a?null:Zj(r,()=>n(i,!1),e.options.isScrollingResetDelay),d=p=>()=>{i=s(o),c?.(),n(i,p)},m=d(!0),u=d(!1);return o.addEventListener("scroll",m,Ds),a&&o.addEventListener("scrollend",u,Ds),()=>{o.removeEventListener("scroll",m),a&&o.removeEventListener("scrollend",u)}},o5=(e,n)=>Vp(e,n,s=>{const{horizontal:o,isRtl:r}=e.options;return o?s.scrollLeft*(r&&-1||1):s.scrollTop}),r5=(e,n)=>Vp(e,n,s=>e.options.horizontal?s.scrollX:s.scrollY),a5=(e,n,s)=>{if(s.options.useCachedMeasurements){const o=s.indexFromElement(e),r=s.options.getItemKey(o);return s.itemSizeCache.get(r)??s.options.estimateSize(o)}if(n?.borderBoxSize){const o=n.borderBoxSize[0];if(o)return Math.round(o[s.options.horizontal?"inlineSize":"blockSize"])}if(!n){const o=s.indexFromElement(e),r=s.options.getItemKey(o),a=s.itemSizeCache.get(r);if(a!==void 0)return a}return e[s.options.horizontal?"offsetWidth":"offsetHeight"]},Kp=(e,{adjustments:n=0,behavior:s},o)=>{var r,a;(a=(r=o.scrollElement)==null?void 0:r.scrollTo)==null||a.call(r,{[o.options.horizontal?"left":"top"]:e+n,behavior:s})},i5=Kp,l5=Kp;class c5{constructor(n){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var s,o,r;return((r=(o=(s=this.targetWindow)==null?void 0:s.performance)==null?void 0:o.now)==null?void 0:r.call(o))??Date.now()},this.observer=(()=>{let s=null;const o=()=>s||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:s=new this.targetWindow.ResizeObserver(r=>{r.forEach(a=>{const i=()=>{const c=a.target,d=this.indexFromElement(c);if(!c.isConnected){this.observer.unobserve(c);for(const[m,u]of this.elementsCache)if(u===c){this.elementsCache.delete(m);break}return}this.shouldMeasureDuringScroll(d)&&this.resizeItem(d,this.options.measureElement(c,a,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(i):i()})}));return{disconnect:()=>{var r;(r=o())==null||r.disconnect(),s=null},observe:r=>{var a;return(a=o())==null?void 0:a.observe(r,{box:"border-box"})},unobserve:r=>{var a;return(a=o())==null?void 0:a.unobserve(r)}}})(),this.range=null,this.setOptions=s=>{var o,r;const a={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Qj,rangeExtractor:e5,onChange:()=>{},measureElement:a5,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=qn(()=>(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,!(!ca()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};a.addEventListener("touchstart",i,Ds),a.addEventListener("touchend",c,Ds),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&&(ca()&&(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=qn(()=>[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=qn(()=>[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),R=p.get(C),I=typeof R=="number"?R:this.options.estimateSize(N);v[N*2]=j,v[N*2+1]=I,j+=I+m}const S=Yj(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 M=g[S],k=M!==void 0?h[M]:void 0;N=k?k.end+m:o+r}else if(y===c){let M=0,k=b[0],A=g[0];for(let D=1;D<c;D++){const $=b[D];($<k||$===k&&g[D]<A)&&(M=D,k=$,A=g[D])}S=M,N=k+m,C&&this.laneAssignments.set(w,S)}else S=w%this.options.lanes,N=o+r,C&&this.laneAssignments.set(w,S);const R=p.get(v),I=typeof R=="number"?R:this.options.estimateSize(w),P=N+I;h[w]={index:w,start:N,size:I,end:P,key:v,lane:S},g[S]===void 0&&y++,g[S]=w,b[S]=P}return this.measurementsCache=h,h},{key:!1,debug:()=>this.options.debug}),this.calculateRange=qn(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(s,o,r,a)=>s.length===0||o===0?(this.range=null,null):(this.range=u5(s,o,r,a,a===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=qn(()=>{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=qn(()=>[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=Gp(0,o.length-1,a?c=>r[c*2]:c=>vc(o[c]).start,s);return vc(o[i])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const s=this.scrollElement.document.documentElement;return this.options.horizontal?s.scrollWidth-this.scrollElement.innerWidth:s.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(s=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=s,this.getOffsetForAlignment=(s,o,r=0)=>{if(!this.scrollElement)return 0;const a=this.getSize(),i=this.getScrollOffset();o==="auto"&&(o=s>=i+a?"end":"start"),o==="center"?s+=(r-a)/2:o==="end"&&(s-=a);const c=this.getMaxScrollOffset();return Math.max(Math.min(c,s),0)},this.getOffsetForIndex=(s,o="auto")=>{s=Math.max(0,Math.min(s,this.options.count-1));const r=this.getSize(),a=this.getScrollOffset(),i=this.measurementsCache[s];if(!i)return;if(o==="auto")if(i.end>=a+r-this.options.scrollPaddingEnd)o="end";else if(i.start<=a+this.options.scrollPaddingStart)o="start";else return[a,o];if(o==="end"&&s===this.options.count-1)return[this.getMaxScrollOffset(),o];const c=o==="end"?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(c,o,i.size),o]},this.scrollToOffset=(s,{align:o="start",behavior:r="auto"}={})=>{const a=this.getOffsetForAlignment(s,o),i=this.now();this.scrollState={index:null,align:o,behavior:r,startedAt:i,lastTargetOffset:a,stableFrames:0},this._scrollToOffset(a,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollToIndex=(s,{align:o="auto",behavior:r="auto"}={})=>{s=Math.max(0,Math.min(s,this.options.count-1));const a=this.getOffsetForIndex(s,o);if(!a)return;const[i,c]=a,d=this.now();this.scrollState={index:s,align:c,behavior:r,startedAt:d,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollBy=(s,{behavior:o="auto"}={})=>{const r=this.getScrollOffset()+s,a=this.now();this.scrollState={index:null,align:"start",behavior:o,startedAt:a,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:s="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:s});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:s})},this.getTotalSize=()=>{var s;const o=this.getMeasurements();let r;if(o.length===0)r=this.options.paddingStart;else if(this.options.lanes===1){const a=o.length-1,i=this._flatMeasurements;i!=null?r=i[a*2]+i[a*2+1]:r=((s=o[a])==null?void 0:s.end)??0}else{const a=Array(this.options.lanes).fill(null);let i=o.length-1;for(;i>=0&&a.some(c=>c===null);){const c=o[i];a[c.lane]===null&&(a[c.lane]=c.end),i--}r=Math.max(...a.filter(c=>c!==null))}return Math.max(r-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const s=[];if(this.itemSizeCache.size===0)return s;const o=this.getMeasurements();for(const r of o)r&&this.itemSizeCache.has(r.key)&&s.push({index:r.index,key:r.key,start:r.start,size:r.size,end:r.end,lane:r.lane});return s},this._scrollToOffset=(s,{adjustments:o,behavior:r})=>{this._intendedScrollOffset=s+(o??0),this.options.scrollToFn(s,{behavior:r,adjustments:o},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(n)}applyScrollAdjustment(n,s){n!==0&&(ca()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=n:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=n,behavior:s}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollAdjustments=0)))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const o=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,r=o?o[0]:this.scrollState.lastTargetOffset,a=1,i=r!==this.scrollState.lastTargetOffset;if(!i&&Xj(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 Gp=(e,n,s,o)=>{for(;e<=n;){const r=(e+n)/2|0,a=s(r);if(a<o)e=r+1;else if(a>o)n=r-1;else return r}return e>0?e-1:0};function d5(e,n,s){let o=0;for(;o<=n;){const r=(o+n)/2|0,a=e[r*2];if(a<s)o=r+1;else if(a>s)n=r-1;else return r}return o>0?o-1:0}function u5(e,n,s,o,r){const a=e.length-1;if(e.length<=o)return{startIndex:0,endIndex:a};if(o===1&&r!==null){const m=d5(r,a,s);let u=m;const p=s+n;for(;u<a&&r[u*2]+r[u*2+1]<p;)u++;return{startIndex:m,endIndex:u}}let c=Gp(0,a,m=>e[m].start,s),d=c;if(o===1)for(;d<a&&e[d].end<s+n;)d++;else if(o>1){const m=Array(o).fill(0);for(;d<a&&m.some(p=>p<s+n);){const p=e[d];m[p.lane]=p.end,d++}const u=Array(o).fill(s+n);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 da=typeof document<"u"?l.useLayoutEffect:l.useEffect;function Jp({useFlushSync:e=!0,directDomUpdates:n=!1,directDomUpdatesMode:s="transform",...o}){const r=l.useReducer(m=>m+1,0)[1],a=l.useRef({enabled:n,mode:s,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=n,a.current.mode=s;const i=m=>{const u=a.current;if(!u.enabled||!u.container)return;const 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?ms.flushSync(r):r()),(p=o.onChange)==null||p.call(o,m,u)}},[d]=l.useState(()=>{const m=new c5(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),da(()=>d._didMount(),[]),da(()=>d._willUpdate()),da(()=>{i(d)}),d}function m5(e){return Jp({observeElementRect:t5,observeElementOffset:o5,scrollToFn:l5,...e})}function p5(e){return Jp({getScrollElement:()=>typeof document<"u"?window:null,observeElementRect:n5,observeElementOffset:r5,scrollToFn:i5,initialOffset:()=>typeof document<"u"?window.scrollY:0,...e})}const Gt="agent-inspector:focus-log";function ds(e){window.dispatchEvent(new CustomEvent(Gt,{detail:e}))}function zr(e){if(typeof CustomEvent>"u"||!(e instanceof CustomEvent))return null;const n=e.detail,s=Z(n,"logId");if(typeof s!="number"||!Number.isInteger(s)||s<0)return null;const o=Z(n,"tab");switch(o){case"anatomy":case"request":case"response":break;case void 0:break;default:return null}const r=Z(n,"source"),a=Z(n,"toolCallIndex"),i=typeof a=="number"&&Number.isInteger(a)&&a>=0?{logId:s,tab:o??"request",toolCallIndex:a}:{logId:s,tab:o??"request"};switch(r){case"virtualizer":return{...i,source:r};case void 0:return i;default:return null}}function f5(e){switch(e){case"end_turn":case"tool_use":return e;case"max_tokens":return"length";default:return null}}function h5(e){switch(e){case"stop":case"length":return e;case"max_tokens":return"length";default:return null}}function x5(e){switch(e){case"max_output_tokens":case"max_tokens":return!0;default:return!1}}function Yp(e){if(e.responseText===null)return null;try{let n=JSON.parse(e.responseText);if(typeof n=="string"&&(n=JSON.parse(n)),!Cs(n))return null;if(typeof n.stop_reason=="string")return f5(n.stop_reason);if(Array.isArray(n.choices))for(const s of n.choices){if(!Cs(s)||typeof s.finish_reason!="string")continue;const o=h5(s.finish_reason);if(o!==null)return o}if(Array.isArray(n.output)){for(const s of n.output)if(Cs(s)&&s.type==="function_call")return"tool_use";if(n.status==="completed")return"stop"}if(n.status==="incomplete"&&Cs(n.incomplete_details)){const s=n.incomplete_details.reason;if(typeof s=="string"&&x5(s))return"length"}return null}catch{return null}}function yl(e){return e==="end_turn"||e==="stop"||e==="length"}function ft({className:e,style:n,d:s,eyeStalks:o,eyes:r,legs:a,extras:i}){return t.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:n,className:O("inline-block size-5",e),children:[t.jsx("path",{d:s}),o,r,a,i]})}const fn=t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"6.5",y1:"16",x2:"4.5",y2:"19.5"}),t.jsx("line",{x1:"9",y1:"17.5",x2:"8",y2:"20.5"}),t.jsx("line",{x1:"15",y1:"17.5",x2:"16",y2:"20.5"}),t.jsx("line",{x1:"17.5",y1:"16",x2:"19.5",y2:"19.5"})]}),Xp=t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"7",y1:"16",x2:"5.5",y2:"18.5"}),t.jsx("line",{x1:"9.5",y1:"17",x2:"8.5",y2:"19.5"}),t.jsx("line",{x1:"14.5",y1:"17",x2:"15.5",y2:"19.5"}),t.jsx("line",{x1:"17",y1:"16",x2:"18.5",y2:"18.5"})]});function Zp({className:e}){return t.jsx(ft,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),t.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"})]}),legs:fn,extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),t.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"})]})})}function g5({className:e}){return t.jsx(ft,{className:e,d:"M4 13 C4 7 7.5 5.5 12 5.5 C16.5 5.5 20 7 20 13 C20 17.5 16.5 19 12 19 C7.5 19 4 17.5 4 13 Z",eyeStalks:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"9.5",y1:"6.5",x2:"9.5",y2:"4.5"}),t.jsx("line",{x1:"14.5",y1:"6.5",x2:"14.5",y2:"4.5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"9.5",cy:"4",r:"1.1",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"14.5",cy:"4",r:"1.1",fill:"currentColor",stroke:"none"})]}),legs:Xp,extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M5 11 C4 9.5 2.5 10 3 12 C3.5 13.5 4.5 13 5 12"}),t.jsx("path",{d:"M19 11 C20 9.5 21.5 10 21 12 C20.5 13.5 19.5 13 19 12"})]})})}function b5({className:e}){return t.jsx(ft,{className:e,d:"M3 13.5 C3 8 7 6 12 6 C17 6 21 8 21 13.5 C21 17 17 19 12 19 C7 19 3 17 3 13.5 Z",eyeStalks:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"7",y1:"7",x2:"6.5",y2:"4.5"}),t.jsx("line",{x1:"17",y1:"7",x2:"17.5",y2:"4.5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"6.5",cy:"4",r:"0.8",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"17.5",cy:"4",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:fn,extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M4 12 C2.5 10.5 1 11 1.5 13 C2 14.5 3.5 14 4.5 13"}),t.jsx("path",{d:"M20 12 C21.5 10.5 23 11 22.5 13 C22 14.5 20.5 14 19.5 13"})]})})}function v5({className:e}){return t.jsx(ft,{className:e,d:"M6 14 C6 8 9 5.5 12 5.5 C15 5.5 18 8 18 14 C18 18 15 20 12 20 C9 20 6 18 6 14 Z",eyeStalks:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"10",y1:"6.5",x2:"10",y2:"3.5"}),t.jsx("line",{x1:"14",y1:"6.5",x2:"14",y2:"3.5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"10",cy:"3",r:"0.7",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"14",cy:"3",r:"0.7",fill:"currentColor",stroke:"none"})]}),legs:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"7",y1:"17",x2:"5",y2:"20.5"}),t.jsx("line",{x1:"9.5",y1:"18.5",x2:"8.5",y2:"21.5"}),t.jsx("line",{x1:"14.5",y1:"18.5",x2:"15.5",y2:"21.5"}),t.jsx("line",{x1:"17",y1:"17",x2:"19",y2:"20.5"})]}),extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M6.5 11 C5 8.5 3 9 3.5 11.5 C4 13.5 5 13 6 12"}),t.jsx("path",{d:"M17.5 11 C19 8.5 21 9 20.5 11.5 C20 13.5 19 13 18 12"})]})})}function y5({className:e}){return t.jsx(ft,{className:e,d:"M5 13 C5 9 8 7 12 7 L13 4 L14 7 C16 7 19 9 19 13 C19 16 16 18 13 18 L12 21 L11 18 C8 18 5 16 5 13 Z",eyeStalks:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),t.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.8",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:fn,extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),t.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"})]})})}function w5({className:e}){return t.jsx(ft,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),t.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"}),t.jsx("line",{x1:"13.5",y1:"4",x2:"15.5",y2:"5"})]}),legs:fn,extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),t.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"})]})})}function j5({className:e}){return t.jsx(ft,{className:e,d:"M5.5 13.5 C5.5 10 8.5 8 12 8 C15.5 8 18.5 10 18.5 13.5 C18.5 16 15.5 17.5 12 17.5 C8.5 17.5 5.5 16 5.5 13.5 Z",eyeStalks:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"10",y1:"8",x2:"10",y2:"6"}),t.jsx("line",{x1:"14",y1:"8",x2:"14",y2:"6"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"9",y1:"6",x2:"11",y2:"6.5"}),t.jsx("line",{x1:"13",y1:"6",x2:"15",y2:"6.5"})]}),legs:Xp,extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M6 11.5 C4.5 10.5 3 11 3.5 12.5 C4 13.5 5 13 5.5 12.5"}),t.jsx("path",{d:"M18 11.5 C19.5 10.5 21 11 20.5 12.5 C20 13.5 19 13 18.5 12.5"})]})})}function S5({className:e}){return t.jsx(ft,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),t.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.7",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.7",fill:"currentColor",stroke:"none"})]}),legs:fn,extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),t.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),t.jsx("line",{x1:"8.5",y1:"4",x2:"10.5",y2:"4.5"}),t.jsx("line",{x1:"15.5",y1:"4",x2:"13.5",y2:"4.5"}),t.jsx("path",{d:"M9 15.5 C10 14.5 14 14.5 15 15.5"})]})})}function N5({className:e}){return t.jsx(ft,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),t.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"9.5",cy:"4.5",r:"1.2",fill:"none",stroke:"currentColor"}),t.jsx("circle",{cx:"14.5",cy:"4.5",r:"1.2",fill:"none",stroke:"currentColor"})]}),legs:fn,extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),t.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),t.jsx("ellipse",{cx:"12",cy:"15",rx:"2",ry:"1.5",fill:"currentColor",stroke:"none"})]})})}function C5({className:e}){return t.jsx(ft,{className:e,d:"M4.5 13 C4.5 8 7.5 6 12 6 C16.5 6 19.5 8 19.5 13 C19.5 17 16.5 18.5 12 18.5 C7.5 18.5 4.5 17 4.5 13 Z",eyeStalks:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"9.5",y1:"7",x2:"9",y2:"5"}),t.jsx("line",{x1:"14.5",y1:"7",x2:"15",y2:"5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"9",cy:"4.5",r:"1",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"15",cy:"4.5",r:"1",fill:"currentColor",stroke:"none"})]}),legs:fn,extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M5 11 C3.5 9 2 9.5 2.5 12 C3 14 4 13 5 12"}),t.jsx("path",{d:"M19 11 C20.5 9 22 9.5 21.5 12 C21 14 20 13 19 12"}),t.jsx("path",{d:"M9 14.5 C10 16 14 16 15 14.5"}),t.jsx("circle",{cx:"7",cy:"13",r:"1",fill:"currentColor",stroke:"none",opacity:"0.3"}),t.jsx("circle",{cx:"17",cy:"13",r:"1",fill:"currentColor",stroke:"none",opacity:"0.3"})]})})}function k5({className:e}){return t.jsx(ft,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5.5"}),t.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5.5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"7.5",y1:"5.5",x2:"16.5",y2:"5.5"}),t.jsx("rect",{x:"7",y:"5",width:"4",height:"2",rx:"0.5",fill:"currentColor",stroke:"none"}),t.jsx("rect",{x:"13",y:"5",width:"4",height:"2",rx:"0.5",fill:"currentColor",stroke:"none"})]}),legs:fn,extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),t.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),t.jsx("path",{d:"M9.5 15 C10.5 16 13.5 16 14.5 15"})]})})}function _5({className:e}){return t.jsx(ft,{className:e,d:"M7 13.5 C7 10.5 9.5 9 12 9 C14.5 9 17 10.5 17 13.5 C17 16 14.5 17.5 12 17.5 C9.5 17.5 7 16 7 13.5 Z",eyeStalks:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"10.5",y1:"9.5",x2:"10.5",y2:"8"}),t.jsx("line",{x1:"13.5",y1:"9.5",x2:"13.5",y2:"8"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"10.5",cy:"7.5",r:"0.8",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"13.5",cy:"7.5",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"8",y1:"16",x2:"6.5",y2:"18"}),t.jsx("line",{x1:"10",y1:"17",x2:"9.5",y2:"19"}),t.jsx("line",{x1:"14",y1:"17",x2:"14.5",y2:"19"}),t.jsx("line",{x1:"16",y1:"16",x2:"17.5",y2:"18"})]}),extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M7.5 12 C6.5 11 5.5 11.5 6 13 C6.5 14 7 13.5 7.5 13"}),t.jsx("path",{d:"M16.5 12 C17.5 11 18.5 11.5 18 13 C17.5 14 17 13.5 16.5 13"})]})})}const ai=[Zp,g5,b5,v5,y5,w5,j5,S5,N5,C5,k5,_5];function wl(e){return ai[Math.abs(e)%ai.length]??Zp}function T5(e){const n=ai.length-2;return n<=0?0:1+((Number.isFinite(e)?Math.trunc(e):0)%n+n)%n}function E5(e){return wl(T5(e))}const R5="x-anthropic-billing-header:";function M5(e){return e.trimStart().toLowerCase().startsWith(R5)}function A5(e){return bl(e)?Object.prototype.hasOwnProperty.call(e,"system"):!1}function I5(e){if(!bl(e))return!1;const n=Z(e,"type"),s=Z(e,"text");return typeof n!="string"||n!=="text"||typeof s!="string"?!1:M5(s)}function P5(e){let n;try{n=JSON.parse(e)}catch{return{body:e,removed:0}}if(!A5(n))return{body:e,removed:0};const s=n.system;if(!Array.isArray(s)||s.length===0)return{body:e,removed:0};const o=[];let r=0;for(const a of s){if(I5(a)){r+=1;continue}o.push(a)}return r===0?{body:e,removed:0}:(o.length===0?delete n.system:n.system=o,{body:JSON.stringify(n),removed:r})}const L5=400,wc=2e3;function O5(e){return Array.isArray(e)}function D5(e,n){const s=[e];let o=0;for(;s.length>0;){const r=s.pop();if(r!==void 0){if(o+=1,o>n)return o;if(!(r===null||typeof r!="object")){if(O5(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 z5(e){const n=D5(e,wc+1);return n<=L5?{depth:Number.POSITIVE_INFINITY}:n<=wc?{depth:3}:{depth:2}}function $5(e){try{const n=JSON.parse(e);return{kind:"json",data:er(n)}}catch{return{kind:"text"}}}function ua(e){const n=l.useMemo(()=>e===null?null:$5(e),[e]),s=n?.kind==="json"?n.data:null,o=l.useMemo(()=>s===null?null:z5(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 er(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=>er(s));const n={};for(const s of Object.keys(e)){const o=Object.getOwnPropertyDescriptor(e,s);n[s]=er(o?.value)}return n}case"bigint":case"symbol":case"function":case"undefined":return String(e)}return null}function Qp({className:e,orientation:n="horizontal",...s}){return t.jsx(vw,{"data-slot":"tabs","data-orientation":n,orientation:n,className:O("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",e),...s})}const F5=Id("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 ef({className:e,variant:n="default",...s}){return t.jsx(yw,{"data-slot":"tabs-list","data-variant":n,className:O(F5({variant:n}),e),...s})}function tn({className:e,...n}){return t.jsx(ww,{"data-slot":"tabs-trigger",className:O("focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring text-muted-foreground hover:text-foreground relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent","data-[state=active]:border-border data-[state=active]:bg-background data-[state=active]:text-foreground","after:bg-foreground after:absolute after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100",e),...n})}function ut({className:e,...n}){return t.jsx(jw,{"data-slot":"tabs-content",className:O("flex-1 outline-none",e),...n})}function sn(e){const[n,s]=l.useState(!1),o=l.useRef(null);l.useEffect(()=>()=>{o.current!==null&&clearTimeout(o.current)},[]);const r=l.useCallback(a=>{a.stopPropagation(),e!==null&&vt(e).then(i=>{i&&(s(!0),o.current!==null&&clearTimeout(o.current),o.current=setTimeout(()=>s(!1),2e3))})},[e]);return{copied:n,copy:r}}const U5=l.lazy(()=>Dt(()=>import("./CompareDrawer-CkABWY5h.js"),__vite__mapDeps([3,1,2]),import.meta.url).then(e=>({default:e.CompareDrawer}))),B5=l.lazy(()=>Dt(()=>import("./InspectorPet-BvsFl3jv.js"),__vite__mapDeps([4,1,2]),import.meta.url).then(e=>({default:e.InspectorPet}))),q5=l.lazy(()=>Dt(()=>import("./ReplayDialog-uJnW9FgF.js"),__vite__mapDeps([5,1,2,6]),import.meta.url).then(e=>({default:e.ReplayDialog}))),H5=l.lazy(()=>Dt(()=>import("./RequestAnatomy-CJ1IFwXf.js"),__vite__mapDeps([7,1,2]),import.meta.url).then(e=>({default:e.RequestAnatomy}))),W5=l.lazy(()=>Dt(()=>import("./ResponseView-Da8fKfh6.js"),__vite__mapDeps([6,1,2]),import.meta.url).then(e=>({default:e.ResponseView}))),V5=l.lazy(()=>Dt(()=>import("./StreamingChunkSequence-zIZ1fbEj.js"),__vite__mapDeps([8,1,2]),import.meta.url).then(e=>({default:e.StreamingChunkSequence}))),ii=l.lazy(()=>Dt(()=>import("./json-viewer-C9EpwpoT.js"),__vite__mapDeps([9,1,2]),import.meta.url).then(e=>({default:e.JsonViewer}))),K5=l.lazy(()=>Dt(()=>import("./json-viewer-C9EpwpoT.js"),__vite__mapDeps([9,1,2]),import.meta.url).then(e=>({default:e.JsonViewerFromString}))),G5=1200,J5=12;function Y5(e){const{containerRef:n,setExpandToPath:s,ensureTabActive:o,highlightMs:r}=e,a=l.useRef(null);return l.useCallback(i=>{o?.(),s(i.path);const c=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??G5)},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=n.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(J5))},[n,o,r,s])}const jc="The compact log metadata is still available. Retry if the local server was restarting or the body store was briefly unavailable.";function Jn(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 X5(e,n){const s=[];return e!=null&&s.push(`Request ${Jn(e)}`),n!=null&&s.push(`Response ${Jn(n)}`),s.length===0?null:s.join(" · ")}function Z5(e){if(e instanceof wi)return{title:"Full bodies timed out",detail:"The log store did not answer before the UI timeout. Compact metadata is still available; retry loading the bodies."};if(e instanceof Error){const n=e.message.trim();return{title:"Full bodies could not be loaded",detail:n===""?jc:n}}return{title:"Full bodies could not be loaded",detail:jc}}class tf{diff(n,s,o={}){let r;typeof o=="function"?(r=o,o={}):"callback"in o&&(r=o.callback);const a=this.castInput(n,o),i=this.castInput(s,o),c=this.removeEmpty(this.tokenize(a,o)),d=this.removeEmpty(this.tokenize(i,o));return this.diffWithOptionsObj(c,d,o,r)}diffWithOptionsObj(n,s,o,r){var a;const i=v=>{if(v=this.postProcess(v,o),r){setTimeout(function(){r(v)},0);return}else return v},c=s.length,d=n.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,n,0,o);if(h[0].oldPos+1>=d&&g+1>=c)return i(this.buildValues(h[0].lastComponent,s,n));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 I=N.oldPos-v;C=N&&0<=I&&I<c}const R=S&&S.oldPos+1<d;if(!C&&!R){h[v]=void 0;continue}if(!R||C&&S.oldPos<N.oldPos?j=this.addToPath(N,!0,!1,0,o):j=this.addToPath(S,!1,!0,1,o),g=this.extractCommon(j,s,n,v,o),j.oldPos+1>=d&&g+1>=c)return i(this.buildValues(j.lastComponent,s,n))||!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(n,s,o,r,a){const i=n.lastComponent;return i&&!a.oneChangePerToken&&i.added===s&&i.removed===o?{oldPos:n.oldPos+r,lastComponent:{count:i.count+1,added:s,removed:o,previousComponent:i.previousComponent}}:{oldPos:n.oldPos+r,lastComponent:{count:1,added:s,removed:o,previousComponent:i}}}extractCommon(n,s,o,r,a){const i=s.length,c=o.length;let d=n.oldPos,m=d-r,u=0;for(;m+1<i&&d+1<c&&this.equals(o[d+1],s[m+1],a);)m++,d++,u++,a.oneChangePerToken&&(n.lastComponent={count:1,previousComponent:n.lastComponent,added:!1,removed:!1});return u&&!a.oneChangePerToken&&(n.lastComponent={count:u,previousComponent:n.lastComponent,added:!1,removed:!1}),n.oldPos=d,m}equals(n,s,o){return o.comparator?o.comparator(n,s):n===s||!!o.ignoreCase&&n.toLowerCase()===s.toLowerCase()}removeEmpty(n){const s=[];for(let o=0;o<n.length;o++)n[o]&&s.push(n[o]);return s}castInput(n,s){return n}tokenize(n,s){return Array.from(n)}join(n){return n.join("")}postProcess(n,s){return n}get useLongestToken(){return!1}buildValues(n,s,o){const r=[];let a;for(;n;)r.push(n),a=n.previousComponent,delete n.previousComponent,n=a;r.reverse();const i=r.length;let c=0,d=0,m=0;for(;c<i;c++){const u=r[c];if(u.removed)u.value=this.join(o.slice(m,m+u.count)),m+=u.count;else{if(!u.added&&this.useLongestToken){let 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 Q5 extends tf{constructor(){super(...arguments),this.tokenize=sf}equals(n,s,o){return o.ignoreWhitespace?((!o.newlineIsToken||!n.includes(`
|
|
49
|
-
`))&&(n=n.trim()),(!o.newlineIsToken||!s.includes(`
|
|
50
|
-
`))&&(s=s.trim())):o.ignoreNewlineAtEof&&!o.newlineIsToken&&(n.endsWith(`
|
|
51
|
-
`)&&(n=n.slice(0,-1)),s.endsWith(`
|
|
52
|
-
`)&&(s=s.slice(0,-1))),super.equals(n,s,o)}}const eS=new Q5;function nf(e,n,s){return eS.diff(e,n,s)}function sf(e,n){n.stripTrailingCr&&(e=e.replace(/\r\n/g,`
|
|
53
|
-
`));const s=[],o=e.split(/(\n|\r\n)/);o[o.length-1]||o.pop();for(let r=0;r<o.length;r++){const a=o[r];r%2&&!n.newlineIsToken?s[s.length-1]+=a:s.push(a)}return s}class tS extends tf{constructor(){super(...arguments),this.tokenize=sf}get useLongestToken(){return!0}castInput(n,s){const{undefinedReplacement:o,stringifyReplacer:r=(a,i)=>typeof i>"u"?o:i}=s;return typeof n=="string"?n:JSON.stringify(li(n,null,null,r),null," ")}equals(n,s,o){return super.equals(n.replace(/,([\r\n])/g,"$1"),s.replace(/,([\r\n])/g,"$1"),o)}}const nS=new tS;function sS(e,n,s){return nS.diff(e,n,s)}function li(e,n,s,o,r){n=n||[],s=s||[],o&&(e=o(r===void 0?"":r,e));let a;for(a=0;a<n.length;a+=1)if(n[a]===e)return s[a];let i;if(Object.prototype.toString.call(e)==="[object Array]"){for(n.push(e),i=new Array(e.length),s.push(i),a=0;a<e.length;a+=1)i[a]=li(e[a],n,s,o,String(a));return n.pop(),s.pop(),i}if(e&&e.toJSON&&(e=e.toJSON()),typeof e=="object"&&e!==null){n.push(e),i={},s.push(i);const c=[];let d;for(d in e)Object.prototype.hasOwnProperty.call(e,d)&&c.push(d);for(c.sort(),a=0;a<c.length;a+=1)d=c[a],i[d]=li(e[d],n,s,o,d);n.pop(),s.pop()}else i=e;return i}function Sc(e){return e===void 0?[]:Object.entries(e).map(n=>[n[0].toLowerCase(),n[1]]).sort(([n],[s])=>n.localeCompare(s))}function Nc([e,n]){return`${e}: ${n}`}function ci(e){const n=[];let s=0,o=0;for(const r of e){const a=r.value.split(`
|
|
54
|
-
`);a.length>0&&a[a.length-1]===""&&a.pop();for(const i of a)r.added?(o+=1,n.push({kind:"added",text:i,oldLineNumber:null,newLineNumber:o})):r.removed?(s+=1,n.push({kind:"removed",text:i,oldLineNumber:s,newLineNumber:null})):(s+=1,o+=1,n.push({kind:"context",text:i,oldLineNumber:s,newLineNumber:o}))}return n}function oS(e,n){const s=Sc(e).map(Nc).join(`
|
|
55
|
-
`),o=Sc(n).map(Nc).join(`
|
|
56
|
-
`);if(s===o)return{lines:[],isEmpty:!0};const r=nf(s,o);return{lines:ci(r),isEmpty:!1}}function Cc(e){try{const n=JSON.parse(e);return n===null||typeof n=="string"||typeof n=="object"?n:null}catch{return null}}function rS(e,n){const s=e??"",o=n??"";if(s===o)return{lines:[],isEmpty:!0};const r=Cc(s),a=Cc(o);if(r!==null&&a!==null){const c=sS(r,a)??[];if(c.length===1){const d=c[0];if(d!==void 0&&!d.added&&!d.removed)return{lines:[],isEmpty:!0}}return{lines:ci(c),isEmpty:!1}}const i=nf(s,o);return{lines:ci(i),isEmpty:!1}}const aS=22,ma=1e4;function iS(e){return e==="added"?"+":e==="removed"?"-":" "}function lS(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 cS=function({result:n,emptyLabel:s}){const[o,r]=l.useState("unified"),a=l.useRef(null),i=m5({count:n.lines.length,getScrollElement:()=>a.current,estimateSize:()=>aS,overscan:10});if(n.isEmpty)return t.jsx("div",{className:"rounded border border-dashed border-border bg-muted/30 px-4 py-6 text-center text-xs text-muted-foreground","data-testid":"diff-empty",children:s??"No transformation applied — raw and processed are identical."});const c=n.lines.length,d=c>ma,m=d?n.lines.slice(0,ma):n.lines;return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[t.jsxs("span",{children:[c.toLocaleString()," line",c===1?"":"s",d&&` (showing first ${ma.toLocaleString()})`]}),t.jsxs("div",{className:"inline-flex rounded-md border border-border overflow-hidden",children:[t.jsxs("button",{type:"button",onClick:()=>r("unified"),"aria-pressed":o==="unified",className:O("flex items-center gap-1 px-2 py-1 transition-colors",o==="unified"?"bg-muted text-foreground":"hover:bg-muted/50"),title:"Unified diff (single column)",children:[t.jsx(Hg,{className:"size-3"}),"Unified"]}),t.jsxs("button",{type:"button",onClick:()=>r("split"),"aria-pressed":o==="split",className:O("flex items-center gap-1 px-2 py-1 transition-colors border-l border-border",o==="split"?"bg-muted text-foreground":"hover:bg-muted/50"),title:"Split diff (side by side)",children:[t.jsx(M0,{className:"size-3"}),"Split"]})]})]}),t.jsx("div",{ref:a,className:"max-h-[60vh] overflow-auto rounded border border-border bg-background font-mono text-xs","data-testid":"diff-viewport",children:o==="unified"?t.jsx(dS,{virtualizer:i,lines:m}):t.jsx(pS,{lines:m})})]})};function dS({virtualizer:e,lines:n}){return t.jsx("div",{style:{height:`${e.getTotalSize()}px`,width:"100%",position:"relative"},children:e.getVirtualItems().map(s=>{const o=n[s.index];return o===void 0?null:t.jsxs("div",{"data-index":s.index,ref:e.measureElement,className:O("flex items-start gap-3 px-2",lS(o.kind)),style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${s.start}px)`},children:[t.jsx("span",{className:"select-none text-muted-foreground/60 w-10 text-right tabular-nums",children:o.oldLineNumber??""}),t.jsx("span",{className:"select-none text-muted-foreground/60 w-10 text-right tabular-nums",children:o.newLineNumber??""}),t.jsx("span",{className:O("select-none w-3 text-right font-bold",o.kind==="added"&&"text-green-600 dark:text-green-400",o.kind==="removed"&&"text-red-600 dark:text-red-400"),children:iS(o.kind)}),t.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:o.text})]},s.key)})})}function uS(e){const n=[];let s=0;for(;s<e.length;){const o=e[s];if(o===void 0)break;if(o.kind==="context"){n.push({left:{text:o.text,lineNumber:o.oldLineNumber},right:{text:o.text,lineNumber:o.newLineNumber},kind:"equal"}),s+=1;continue}const r=[],a=[];for(;s<e.length&&e[s]?.kind==="removed";){const c=e[s];c!==void 0&&r.push(c),s+=1}for(;s<e.length&&e[s]?.kind==="added";){const c=e[s];c!==void 0&&a.push(c),s+=1}const i=Math.max(r.length,a.length);for(let c=0;c<i;c+=1){const d=r[c],m=a[c];d!==void 0&&m!==void 0?n.push({left:{text:d.text,lineNumber:d.oldLineNumber},right:{text:m.text,lineNumber:m.newLineNumber},kind:"changed"}):d!==void 0?n.push({left:{text:d.text,lineNumber:d.oldLineNumber},right:null,kind:"removed"}):m!==void 0&&n.push({left:null,right:{text:m.text,lineNumber:m.newLineNumber},kind:"added"})}}return n}function mS(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 pS({lines:e}){const n=uS(e);return t.jsx("div",{"data-testid":"diff-split",children:n.map((s,o)=>t.jsxs("div",{className:O("grid grid-cols-2 font-mono text-xs",mS(s.kind)),children:[t.jsxs("div",{className:"flex items-start gap-2 px-2 border-r border-border/50",children:[t.jsx("span",{className:"select-none text-muted-foreground/60 w-8 text-right tabular-nums",children:s.left?.lineNumber??""}),t.jsx("span",{className:O("select-none w-3 text-right font-bold",(s.kind==="removed"||s.kind==="changed")&&"text-red-600 dark:text-red-400"),children:s.left!==null?"-":" "}),t.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:s.left?.text??""})]}),t.jsxs("div",{className:"flex items-start gap-2 px-2",children:[t.jsx("span",{className:"select-none text-muted-foreground/60 w-8 text-right tabular-nums",children:s.right?.lineNumber??""}),t.jsx("span",{className:O("select-none w-3 text-right font-bold",(s.kind==="added"||s.kind==="changed")&&"text-green-600 dark:text-green-400"),children:s.right!==null?"+":" "}),t.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:s.right?.text??""})]})]},o))})}const of=l.memo(cS),fS=Id("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 ke({className:e,variant:n="default",asChild:s=!1,...o}){const r=s?ub:"span";return t.jsx(r,{"data-slot":"badge","data-variant":n,className:O(fS({variant:n}),e),...o})}const hS=3;function xS({event:e}){const n=s=>{s.stopPropagation(),ds({logId:e.logId,tab:"response",toolCallIndex:e.index})};return t.jsx("button",{type:"button",className:"inline-flex h-5 min-w-0 max-w-[8.5rem] items-center rounded px-1.5 text-[10px] text-muted-foreground transition-colors hover:bg-background/65 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:n,onKeyDown:s=>s.stopPropagation(),"aria-label":`Open response tool call ${e.name}`,title:e.name,children:t.jsx("span",{className:"min-w-0 truncate font-mono font-semibold",children:e.name})})}function gS({events:e}){if(e.length===0)return null;const n=e.slice(0,hS),s=Math.max(0,e.length-n.length);return t.jsxs("span",{className:"inline-flex h-7 min-w-0 max-w-full items-center gap-1 overflow-hidden rounded-md border border-cyan-300/10 bg-cyan-300/[0.055] px-1 sm:max-w-[26rem]",role:"group","aria-label":`${e.length} response tool ${e.length===1?"call":"calls"}`,onClick:o=>o.stopPropagation(),onKeyDown:o=>o.stopPropagation(),children:[t.jsxs("span",{className:"inline-flex h-5 shrink-0 items-center gap-1 px-1 font-mono text-[9px] font-semibold uppercase text-cyan-300",children:[t.jsx(Vs,{className:"size-3"}),"Call ",e.length]}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-0.5 overflow-hidden",children:[n.map(o=>t.jsx(xS,{event:o},o.id)),s>0&&t.jsxs("span",{className:"inline-flex h-5 shrink-0 items-center rounded px-1 font-mono text-[10px] font-semibold text-muted-foreground",children:["+",s]})]})]})}const bS={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"},vS={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"}},ws="border border-transparent bg-white/[0.045] hover:bg-white/[0.075] size-8 text-muted-foreground shadow-none hover:text-cyan-100",gt="bg-white/[0.045] flex h-7 items-center gap-1 rounded-md px-2 text-xs";function js(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function yS(e){return e>=10?`${e.toFixed(0)}/s`:`${e.toFixed(1)}/s`}function wS(e,n){switch(e){case"success":return n===null?"OK":String(n);case"client_error":return n===null?"WARN":String(n);case"server_error":return n===null?"FAIL":String(n);case"pending":return"ROLL"}}function kc({trend:e}){if(e===null)return null;const n=e.direction==="up",s=n?Wx:$x,o=n?"+":"-";return t.jsxs("span",{className:"flex items-center gap-0.5 text-muted-foreground tabular-nums",children:[t.jsx(s,{className:n?"size-3 text-cyan-300":"size-3 text-rose-400"}),t.jsxs("span",{className:"font-mono",children:[o,Ee(e.delta)]})]})}const jS=l.memo(function({log:e,displayNumber:n,messageCount:s=null,toolCount:o=null,toolEvents:r=[],expanded:a,onToggle:i,cacheTrend:c=null,activeTab:d,tabActions:m,onReplay:u,slowResponseThresholdSeconds:p=0,showClientMetadata:f=!0,timeDisplayFormat:h}){const g=Sh(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:js(w),S=v===null||v<=0?null:yS(v),N=e.warnings?.length??0,C=e.clientPid!==null&&e.clientPid!==void 0,R=e.clientProjectFolder!==null&&e.clientProjectFolder!==void 0&&e.clientProjectFolder!=="";e.clientCwd!==null&&e.clientCwd!==void 0&&e.clientCwd;const I=vS[g],P=wS(g,e.responseStatus),M=g!=="success"||e.responseStatus!==200,k=e.streaming&&j===null&&S===null;return t.jsx(hs,{children:t.jsxs("div",{id:`log-${e.id}`,role:"button",tabIndex:0,"data-nav-id":`log-${e.id}`,"data-nav-action":a?"collapse":"expand",className:O("group/header relative isolate flex min-w-0 cursor-pointer items-start gap-2 overflow-hidden px-3 py-2 transition-[background-color,border-color,box-shadow]",a?"bg-white/[0.04]":"bg-transparent hover:bg-white/[0.035]","select-none","focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-none"),onClick:i,onKeyDown:A=>{(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),i())},children:[t.jsxs("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1",children:[t.jsx("span",{className:O("inline-flex h-8 shrink-0 items-center rounded-md px-2 font-mono",I.frame),children:t.jsxs("span",{className:"text-xs font-semibold tabular-nums",title:`Log ID ${String(e.id)}`,children:["#",n]})}),t.jsxs("span",{className:"bg-white/[0.045] flex h-7 shrink-0 items-center gap-1 rounded-md px-2 text-xs text-muted-foreground",children:[t.jsx(Wt,{className:"size-3"}),t.jsx("span",{className:"font-mono tabular-nums",title:e.timestamp,children:qa(e.timestamp,h)})]}),M&&t.jsxs(ke,{variant:"outline",className:O("h-6 gap-1 rounded-md px-2 py-0 font-mono text-[10px] font-semibold uppercase tabular-nums shadow-[inset_0_1px_0_rgba(255,255,255,0.05)]",bS[g]),children:[g==="success"?t.jsx(Oe,{className:"size-3","aria-label":"Success"}):g==="server_error"?t.jsx(Eg,{className:"size-3","aria-label":"Server error"}):g==="client_error"?t.jsx(rn,{className:"size-3","aria-label":"Client error"}):t.jsx(Ae,{className:"size-3 animate-spin","aria-label":"Pending"}),P]}),N>0&&t.jsxs(et,{children:[t.jsx(tt,{asChild:!0,children:t.jsxs(ke,{variant:"outline",className:"h-6 gap-1 rounded-md border-amber-300/30 bg-amber-300/[0.10] px-2 py-0 font-mono text-[10px] tabular-nums text-amber-100",children:[t.jsx(rn,{className:"size-3","aria-label":"Tool schema warnings"}),N]})}),t.jsx(nt,{children:N===1?"1 tool schema warning":`${N} tool schema warnings`})]}),e.elapsedMs!==null&&(b?t.jsxs(et,{children:[t.jsx(tt,{asChild:!0,children:t.jsxs("span",{className:O(gt,"shrink-0 border-amber-300/25 text-amber-200"),children:[t.jsx(Wt,{className:"size-3"}),t.jsx("span",{className:"font-mono tabular-nums",children:js(e.elapsedMs)}),t.jsx(rn,{className:"size-3","aria-label":"Slow response"})]})}),t.jsxs(nt,{children:["Slow response: ",js(e.elapsedMs)," exceeds"," ",js(p*1e3)]})]}):t.jsxs("span",{className:O(gt,"shrink-0 text-muted-foreground"),children:[t.jsx(Wt,{className:"size-3"}),t.jsx("span",{className:"font-mono tabular-nums",children:js(e.elapsedMs)})]})),e.streaming&&j!==null&&t.jsxs("span",{className:O(gt,"shrink-0 text-cyan-300"),children:[t.jsx(Bl,{className:"size-3"}),t.jsxs("span",{className:"font-mono tabular-nums",children:["first ",j]})]}),e.streaming&&S!==null&&t.jsxs("span",{className:O(gt,"shrink-0 text-cyan-300"),children:[t.jsx(zi,{className:"size-3"}),t.jsx("span",{className:"font-mono tabular-nums",children:S})]}),y&&t.jsxs("span",{className:O(gt,"min-w-0 sm:shrink-0"),children:[t.jsx(Is,{className:"size-3 text-muted-foreground"}),t.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-1 font-mono tabular-nums",children:[t.jsxs("span",{className:O("whitespace-nowrap",e.inputTokens!==null?"text-blue-400":"text-muted-foreground"),children:["IN ",e.inputTokens!==null?Ee(e.inputTokens):"n/a"]}),t.jsx("span",{className:"text-muted-foreground",children:"/"}),t.jsxs("span",{className:O("whitespace-nowrap",e.outputTokens!==null?"text-amber-400":"text-muted-foreground"),children:["OUT ",e.outputTokens!==null?Ee(e.outputTokens):"n/a"]})]})]}),e.cacheCreationInputTokens!==null&&e.cacheCreationInputTokens>0&&t.jsxs("span",{className:O(gt,"shrink-0"),children:[t.jsx(kc,{trend:c?.creation??null}),t.jsxs("span",{className:"font-mono tabular-nums text-cyan-300",children:["KV Cache +",Ee(e.cacheCreationInputTokens)]})]}),e.cacheReadInputTokens!==null&&e.cacheReadInputTokens>0&&t.jsxs("span",{className:O(gt,"shrink-0"),children:[t.jsx(kc,{trend:c?.read??null}),t.jsxs("span",{className:"font-mono tabular-nums text-purple-400",children:["KV Cache ~",Ee(e.cacheReadInputTokens)]})]}),s!==null&&t.jsxs("span",{className:O(gt,"shrink-0 text-muted-foreground"),children:[t.jsx(fr,{className:"size-3"}),t.jsx("span",{className:"font-mono tabular-nums",children:s})]}),o!==null&&t.jsxs("span",{className:O(gt,"shrink-0 text-muted-foreground"),children:[t.jsx(Vs,{className:"size-3"}),t.jsx("span",{className:"font-mono tabular-nums",children:o})]}),t.jsx(gS,{events:r}),e.origin!==null&&t.jsxs("span",{className:O(gt,"hidden shrink-0 text-muted-foreground xl:flex"),title:`Origin: ${e.origin}`,children:[t.jsx(au,{className:"size-3"}),t.jsx("span",{className:"font-mono tabular-nums truncate max-w-[120px]",title:e.origin,children:e.origin})]}),f&&(C||R)&&t.jsxs("span",{className:O(gt,"hidden shrink-0 text-purple-300 xl:flex"),children:[t.jsx(J0,{className:"size-3"}),R?t.jsx("span",{className:"font-mono tabular-nums",children:e.clientProjectFolder}):t.jsxs("span",{className:"font-mono tabular-nums",children:["PID ",e.clientPid]})]}),k&&t.jsx(Bl,{className:"size-3 shrink-0 text-muted-foreground/60"})]}),t.jsxs("span",{className:"flex shrink-0 items-start gap-1.5",children:[a&&t.jsxs("span",{className:"flex items-center gap-1.5 shrink-0",onClick:A=>A.stopPropagation(),onKeyDown:A=>A.stopPropagation(),children:[m!==void 0&&d!==void 0&&(()=>{const A=m[d];return A===void 0?null:t.jsxs(t.Fragment,{children:[A.expansion!==null&&t.jsxs(et,{children:[t.jsx(tt,{asChild:!0,children:t.jsx(ee,{variant:"outline",size:"icon",className:ws,onClick:A.expansion.onToggle,disabled:A.expansion.isPending,"aria-pressed":A.expansion.isExpanded,"aria-label":A.expansion.isExpanded?"Collapse all JSON":"Expand all JSON",children:A.expansion.isExpanded?t.jsx(p0,{className:"size-3.5"}):t.jsx(i0,{className:"size-3.5"})})}),t.jsx(nt,{children:A.expansion.isExpanded?"Collapse all JSON nodes":"Expand all JSON nodes"})]}),A.diffWithRaw!==void 0&&t.jsxs(et,{children:[t.jsx(tt,{asChild:!0,children:t.jsx(ee,{variant:"outline",size:"icon",className:O(ws,A.diffWithRaw.active&&"border-cyan-300/35 bg-cyan-400/15 text-cyan-100"),onClick:A.diffWithRaw.onToggle,"aria-pressed":A.diffWithRaw.active,"aria-label":A.diffWithRaw.active?"Hide raw diff":"Diff with raw",children:t.jsx(W0,{className:"size-3.5"})})}),t.jsx(nt,{children:A.diffWithRaw.active?"Hide diff with raw request":"Show diff between displayed and raw request body"})]}),A.diffWithPrevious!==void 0&&t.jsxs(et,{children:[t.jsx(tt,{asChild:!0,children:t.jsx(ee,{variant:"outline",size:"icon",className:ws,onClick:A.diffWithPrevious,"aria-label":"Diff with previous",children:t.jsx(iu,{className:"size-3.5"})})}),t.jsx(nt,{children:"Compare this request with the immediately preceding one"})]}),A.copyText!==null&&t.jsxs(et,{children:[t.jsx(tt,{asChild:!0,children:t.jsx(ee,{variant:"outline",size:"icon",className:ws,onClick:A.onCopy,"aria-label":A.copyCopied?"Copied":A.copyLabel,children:A.copyCopied?t.jsx(Oe,{className:"size-3.5 text-cyan-300"}):t.jsx(St,{className:"size-3.5"})})}),t.jsx(nt,{children:A.copyCopied?"Copied to clipboard":A.copyLabel})]})]})})(),u!==void 0&&t.jsxs(et,{children:[t.jsx(tt,{asChild:!0,children:t.jsx(ee,{variant:"outline",size:"icon",className:ws,onClick:u,"aria-label":"Replay request",children:t.jsx(uu,{className:"size-3.5"})})}),t.jsx(nt,{children:"Re-send this request to the provider"})]})]}),t.jsx("span",{className:"bg-white/[0.045] hover:bg-white/[0.075] inline-flex size-8 shrink-0 items-center justify-center rounded-md text-text-strong","aria-hidden":"true",children:a?t.jsx(Ve,{className:"size-4 shrink-0"}):t.jsx(it,{className:"size-4 shrink-0"})})]})]})})});function SS({...e}){return t.jsx(zb,{"data-slot":"collapsible",...e})}function ZT({...e}){return t.jsx(Nu,{"data-slot":"collapsible-trigger",...e})}function NS({...e}){return t.jsx(Cu,{"data-slot":"collapsible-content",...e})}function CS({className:e,children:n,...s}){return t.jsxs(qy,{"data-slot":"scroll-area",className:O("relative overflow-hidden",e),...s,children:[t.jsx(Hy,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full max-h-[inherit] rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:n}),t.jsx(kS,{}),t.jsx(Wy,{})]})}function kS({className:e,orientation:n="vertical",...s}){return t.jsx(Pm,{"data-slot":"scroll-area-scrollbar",orientation:n,className:O("flex touch-none p-px transition-colors select-none",n==="vertical"&&"h-full w-2.5 border-l border-l-transparent",n==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",e),...s,children:t.jsx(zm,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}const rf={file:"file",shell:"shell",browser:"browser",web:"web",mcp:"MCP",code:"code",other:"other"},_S={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 TS({category:e}){switch(e){case"file":return t.jsx(X0,{className:"size-3.5"});case"shell":return t.jsx(In,{className:"size-3.5"});case"browser":return t.jsx(Cg,{className:"size-3.5"});case"web":return t.jsx(au,{className:"size-3.5"});case"mcp":return t.jsx(Yx,{className:"size-3.5"});case"code":return t.jsx(su,{className:"size-3.5"});case"other":return t.jsx(D0,{className:"size-3.5"})}}function ES({names:e}){return e.length===0?null:t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:[t.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:"required"}),e.slice(0,4).map(n=>t.jsx(ke,{variant:"outline",className:"h-5 max-w-36 truncate rounded-md px-1.5 py-0 font-mono text-[10px]",children:n},n)),e.length>4&&t.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:["+",e.length-4]})]})}function RS({tool:e,called:n}){const[s,o]=l.useState(!1),r=sn(e.name),a=e.description!==null||e.requiredParameters.length>0||e.schema!==null;return t.jsx(SS,{open:s,onOpenChange:o,children:t.jsxs("div",{className:"bg-white/[0.035] rounded-[8px]",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-2.5 py-2",children:[t.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>o(i=>!i),"aria-expanded":s,disabled:!a,children:[t.jsx(TS,{category:e.category}),t.jsx("span",{className:"min-w-0 truncate font-mono text-xs font-semibold text-foreground/90",children:e.name}),n&&t.jsx(ke,{variant:"outline",className:"h-5 rounded-md border-emerald-400/20 bg-emerald-400/5 px-1.5 py-0 text-[10px] text-emerald-300",children:"called"}),t.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:[e.parameterCount," params"]}),e.descriptionPreview!==null&&t.jsx("span",{className:"hidden min-w-0 truncate text-xs text-muted-foreground md:inline",children:e.descriptionPreview}),t.jsx("span",{className:"flex-1"}),a&&(s?t.jsx(Ve,{className:"size-3.5 shrink-0 text-muted-foreground"}):t.jsx(it,{className:"size-3.5 shrink-0 text-muted-foreground"}))]}),t.jsx("button",{type:"button",className:"bg-white/[0.045] hover:bg-white/[0.075] inline-flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:r.copy,"aria-label":r.copied?"Copied tool name":"Copy tool name",children:r.copied?t.jsx(Oe,{className:"size-3.5 text-emerald-400"}):t.jsx(St,{className:"size-3.5"})})]}),t.jsx(NS,{children:s&&t.jsxs("div",{className:"space-y-2 bg-white/[0.025] px-2.5 py-2",children:[e.description!==null&&t.jsx("p",{className:"text-xs leading-relaxed text-muted-foreground",children:e.description}),t.jsx(ES,{names:e.requiredParameters}),e.schema!==null&&t.jsx(CS,{className:"bg-black/[0.16] max-h-64 rounded-[8px] p-2",children:t.jsx(l.Suspense,{fallback:t.jsx("div",{className:"text-xs text-muted-foreground",children:"Loading JSON..."}),children:t.jsx(ii,{data:er(e.schema),defaultExpandDepth:0})})})]})})]})})}function MS(e,n){return n.length===0?!0:`${e.name} ${e.description??""} ${rf[e.category]}`.toLowerCase().trim().includes(n)}const AS=l.memo(function({summary:n,calledToolNames:s}){const[o,r]=l.useState(!1),[a,i]=l.useState(""),c=l.useMemo(()=>new Set(s),[s]),d=a.trim().toLowerCase(),m=l.useMemo(()=>n===null?[]:n.tools.filter(f=>MS(f,d)),[d,n]);if(n===null)return null;const u=n.tools.slice(0,6),p=n.tools.length-u.length;return t.jsxs("section",{className:"bg-black/[0.10] mb-3 overflow-hidden rounded-[8px]",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 px-3 py-2",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx(Vs,{className:"size-4 shrink-0 text-sky-300/80"}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:"text-sm font-semibold text-foreground",children:"Request Tools"}),t.jsx(ke,{variant:"outline",className:"h-5 rounded-md px-1.5 py-0 font-mono text-[10px]",children:n.tools.length}),n.toolChoiceLabel!==null&&t.jsxs(ke,{variant:"outline",className:"h-5 rounded-md px-1.5 py-0 font-mono text-[10px] text-muted-foreground",children:["tool_choice: ",n.toolChoiceLabel]})]}),t.jsx("div",{className:"mt-1 flex min-w-0 flex-wrap gap-1",children:n.categories.map(f=>t.jsxs(ke,{variant:"outline",className:O("h-5 rounded-md px-1.5 py-0 font-mono text-[10px]",_S[f.category]),children:[f.count," ",rf[f.category]]},f.category))})]})]}),t.jsxs(ee,{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?t.jsx(Ve,{className:"size-3.5"}):t.jsx(it,{className:"size-3.5"}),o?"Hide":"Show"]})]}),t.jsxs("div",{className:"flex min-w-0 flex-wrap gap-1.5 bg-white/[0.025] px-3 py-2",children:[u.map(f=>t.jsx(ke,{variant:"outline",className:O("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&&t.jsxs("span",{className:"font-mono text-[10px] leading-5 text-muted-foreground",children:["+",p]})]}),o&&t.jsxs("div",{className:"space-y-2 bg-black/10 px-3 py-3",children:[t.jsxs("label",{className:"bg-white/[0.045] hover:bg-white/[0.075] flex h-8 items-center gap-2 rounded-md px-2 text-xs",children:[t.jsx(Yg,{className:"size-3.5 shrink-0 text-muted-foreground"}),t.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"})]}),t.jsx("div",{className:"grid gap-1.5",children:m.length>0?m.map(f=>t.jsx(RS,{tool:f,called:c.has(f.name)},f.name)):t.jsx("p",{className:"py-2 text-xs text-muted-foreground",children:"No matching tools"})})]})]})});function _c(e,n,s){return e==="anthropic"&&n==="full"&&s}function IS(e,n){return e==="full"&&n}function pa(e,n){return e==="full"&&n}function fa(e,n){return e==="full"&&n}function PS(e,n,s,o){return e==="anthropic"&&n==="full"&&s&&o}function Hn(){return t.jsx("div",{className:"h-1","aria-hidden":"true"})}function LS(e,n){switch(e){case"anatomy":return n===null?"request":"anatomy";case"request":return"request";case"response":return"parsed"}}const OS=15e3,DS=15e3,zS=256*1024,tr=1024*1024,vn="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 po(e=null){return{status:"idle",text:"",offset:0,totalBytes:e,hasMore:e!==null&&e>0,error:null}}function nr(e){return e??0}function af(e){return e.bodyContentMode==="compact"||e.bodyContentMode==="truncated"}function lf(e){return af(e)?nr(e.rawRequestBodyBytes)>tr||nr(e.responseTextBytes)>tr:!1}function $S(e){return af(e)&&!lf(e)}function FS(e){return e instanceof wi?"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 fo({status:e,error:n,footprint:s,onRetry:o}){switch(e){case"idle":return null;case"loading":return t.jsx(zs,{tone:"loading",title:"Loading full bodies",children:t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Ae,{className:"size-3.5 shrink-0 animate-spin text-cyan-200"}),t.jsx("span",{children:"Loading full request and response bodies from the log store."})]}),s!==null&&t.jsx("span",{className:"rounded border border-cyan-300/15 bg-cyan-300/[0.06] px-2 py-0.5 font-mono text-[11px] text-cyan-100",children:s})]})});case"failed":return t.jsx(zs,{tone:"warning",title:n?.title??"Full bodies could not be loaded",children:t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsx("span",{children:n?.detail??"Compact metadata is still available."}),t.jsxs(ee,{type:"button",variant:"outline",size:"sm",className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground h-7 gap-1.5 text-xs text-amber-100",onClick:o,children:[t.jsx(yt,{className:"size-3"}),"Retry"]})]})})}}function Tc(e,n){return e?n.text!==""?n.text:n.status==="success"?"":null:null}function yn({children:e,className:n}){return t.jsx("div",{className:O("bg-black/[0.14] inspector-scrollbar mx-3 mb-3 max-h-[72vh] overflow-auto rounded-[8px] p-3",n),children:e})}function Io({children:e}){return t.jsx("div",{className:"bg-white/[0.035] rounded-md px-3 py-5 text-center text-xs italic text-muted-foreground",children:e})}function ho({children:e}){return t.jsx("pre",{className:"bg-black/[0.18] inspector-scrollbar max-h-[64vh] overflow-auto whitespace-pre-wrap break-words rounded-[8px] p-3 font-mono text-xs leading-relaxed text-muted-foreground",children:e})}const US={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 zs({tone:e,title:n,children:s}){return t.jsxs("div",{className:O("mb-3 rounded-md border px-3 py-2 text-xs shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]",US[e]),children:[n!==void 0&&t.jsx("div",{className:"mb-1 font-semibold",children:n}),t.jsx("div",{className:"leading-relaxed text-muted-foreground",children:s})]})}function xo({label:e,state:n,expectedBytes:s,onLoadMore:o}){const r=n.totalBytes??s,a=r===null?Jn(n.offset):`${Jn(n.offset)} / ${Jn(r)}`,i=n.status!=="loading"&&n.hasMore,c=n.status==="failed"?"Retry":"Load more";return t.jsx(zs,{tone:n.status==="failed"?"warning":"loading",title:`${e} body preview`,children:t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsxs("span",{children:[n.status==="idle"&&r!==null?`${e} body is ${Jn(r)}. Loading the first preview chunk.`:`Loaded ${a}.`,n.status==="failed"&&n.error!==null&&` ${n.error}`]}),i&&t.jsx(ee,{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 Ec({headers:e,emptyLabel:n}){const s=e===void 0?[]:Object.entries(e).sort(([o],[r])=>o.localeCompare(r));return s.length===0?t.jsx(Io,{children:n}):t.jsx("div",{className:"bg-black/[0.14] overflow-hidden rounded-[8px] font-mono text-xs",children:s.map(([o,r])=>t.jsxs("div",{className:"grid min-w-0 grid-cols-[minmax(140px,0.32fr)_minmax(0,1fr)] border-b border-white/[0.055] last:border-b-0",children:[t.jsx("div",{className:"min-w-0 truncate bg-white/[0.035] px-2.5 py-2 font-semibold text-cyan-200",children:o}),t.jsx("div",{className:"min-w-0 truncate px-2.5 py-2 text-muted-foreground",title:r,children:r})]},o))})}function BS({active:e,onClick:n}){return t.jsxs(et,{children:[t.jsx(tt,{asChild:!0,children:t.jsxs(ee,{variant:e?"default":"outline",size:"sm",className:O("h-8 border-white/10 text-xs shadow-none",e?"bg-cyan-300 text-black hover:bg-cyan-200":"border border-input bg-background hover:bg-accent hover:text-accent-foreground text-muted-foreground hover:text-cyan-100"),onClick:n,"aria-pressed":e,children:[t.jsx(rg,{className:"size-3.5 mr-1"}),e?"Showing diff":"Diff with Raw"]})}),t.jsx(nt,{children:e?"Hide diff view":"Compare proxy output against the original raw version"})]})}const qS=l.memo(function({rawBody:e,displayedBody:n,emptyLabel:s}){const o=l.useMemo(()=>rS(e,n),[e,n]);return t.jsx(of,{result:o,emptyLabel:s})}),HS=l.memo(function({rawHeaders:e,headers:n,emptyLabel:s}){const o=l.useMemo(()=>oS(e,n),[e,n]);return t.jsx(of,{result:o,emptyLabel:s})}),WS=l.memo(function({log:e,displayNumber:n,viewMode:s="simple",strip:o,slowResponseThresholdSeconds:r,timeDisplayFormat:a,cacheTrend:i=null,onCompareWithPrevious:c,showClientMetadata:d=!0,toolEvents:m=[]}){const[u,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,R]=l.useState(0),[I,P]=l.useState(null),[M,k]=l.useState(null),[A,D]=l.useState("idle"),[$,J]=l.useState(null),[X,F]=l.useState(0),[H,Y]=l.useState(()=>po(e.rawRequestBodyBytes??null)),[U,W]=l.useState(()=>po(e.responseTextBytes??null)),me=l.useRef(null),be=l.useRef(e.id),ve=l.useRef(!1),z=M??e,se=M===null&&lf(e),te=l.useMemo(()=>X5(e.rawRequestBodyBytes,e.responseTextBytes),[e.rawRequestBodyBytes,e.responseTextBytes]),Se=Tc(se,H),Ne=Tc(se,U),ie=z.rawRequestBody??Se,le=z.responseText??Ne,fe=z.rawRequestBody===null&&Se!==null,ye=z.responseText===null&&Ne!==null,Ce=!fe||H.hasMore===!1&&nr(H.totalBytes)<=tr,Ie=!ye||U.hasMore===!1&&nr(U.totalBytes)<=tr,$e=Os(z),Pe=Hp($e),Ze=l.useMemo(()=>Pe.analyzeRequest(z.rawRequestBody),[Pe,z.rawRequestBody]),Bt=l.useMemo(()=>Pe.analyzeResponse(z.responseText),[Pe,z.responseText]),Fe=l.useMemo(()=>!o||$e!=="anthropic"||z.rawRequestBody===null?null:P5(z.rawRequestBody).body,[z.rawRequestBody,$e,o])??ie,Me=ua(Ce?Fe:null),Le=ua(v==="raw-request"&&Ce?ie:null),B=ua(v==="raw"&&Ie?le:null),ne=l.useMemo(()=>z.headers&&Object.keys(z.headers).length>0?JSON.stringify(z.headers,null,2):null,[z.headers]),we=l.useMemo(()=>z.rawHeaders&&Object.keys(z.rawHeaders).length>0?JSON.stringify(z.rawHeaders,null,2):null,[z.rawHeaders]),he=sn(Fe),je=sn(ie),Be=sn(ne),G=sn(we),_=sn(le),L=l.useMemo(()=>({request:{copyLabel:fe?"Copy loaded request preview":"Copy request body",copyText:Fe,copyCopied:he.copied,onCopy:he.copy,expansion:Ce?{isExpanded:Me.isExpanded,isPending:Me.isPending,onToggle:Me.toggle}:null,diffWithRaw:PS($e,s,o,z.rawRequestBody!==null)?{active:y,onToggle:()=>w(!y)}:void 0,diffWithPrevious:c===void 0?void 0:()=>{c(z)}},"raw-request":{copyLabel:fe?"Copy loaded raw request preview":"Copy raw request",copyText:ie,copyCopied:je.copied,onCopy:je.copy,expansion:Ce?{isExpanded:Le.isExpanded,isPending:Le.isPending,onToggle:Le.toggle}:null},...fa(s,z.headers!==void 0&&Object.keys(z.headers).length>0)?{headers:{copyLabel:"Copy headers",copyText:ne,copyCopied:Be.copied,onCopy:Be.copy,expansion:null}}:{},...pa(s,z.rawHeaders!==void 0&&Object.keys(z.rawHeaders).length>0)?{"raw-headers":{copyLabel:"Copy raw headers",copyText:we,copyCopied:G.copied,onCopy:G.copy,expansion:null}}:{},raw:{copyLabel:ye?"Copy loaded response preview":"Copy response",copyText:le,copyCopied:_.copied,onCopy:_.copy,expansion:Ie?{isExpanded:B.isExpanded,isPending:B.isPending,onToggle:B.toggle}:null}}),[Fe,fe,Ce,he,Me,y,z,z.rawRequestBody,ie,je,Le,ne,Be,we,G,z.responseText,ye,Ie,le,_,B,$e,s,o,c]),V=l.useMemo(()=>Me.parsedData!==null?Pe.anatomySegments(Me.parsedData):null,[Pe,Me.parsedData]),oe=l.useMemo(()=>vl(Me.parsedData),[Me.parsedData]),ce=z.warnings??[],Q=l.useMemo(()=>{if(V!==null)return new Set(V.map(Re=>Re.path))},[V]),pe=Y5({containerRef:me,setExpandToPath:P,ensureTabActive:()=>{v!=="request"&&j("request")}}),ae=l.useCallback((Re,qt)=>{const dt=Re==="request"?Y:W;dt(Qe=>({...Qe,status:"loading",error:null}));const xs=new URLSearchParams({part:Re,offset:String(qt),limit:String(zS)});De(`/api/logs/${String(e.id)}/body?${xs.toString()}`,Ih,DS).then(Qe=>{be.current===e.id&&dt(xn=>({status:"success",text:Qe.offset===0?Qe.text:`${xn.text}${Qe.text}`,offset:Qe.nextOffset??Qe.totalBytes,totalBytes:Qe.totalBytes,hasMore:Qe.hasMore,error:null}))}).catch(Qe=>{be.current===e.id&&dt(xn=>({...xn,status:"failed",error:FS(Qe)}))})},[e.id]),ht=l.useCallback(()=>{ve.current||(k(null),D("idle"),J(null),F(Re=>Re+1))},[]),hn=l.useCallback(()=>{const Re=!u;Re&&j(V!==null?"anatomy":"request"),p(Re)},[V,u]);return l.useEffect(()=>{be.current=e.id,ve.current=!1,k(null),D("idle"),J(null),F(0),Y(po(e.rawRequestBodyBytes??null)),W(po(e.responseTextBytes??null))},[e.id,e.rawRequestBodyBytes,e.responseTextBytes]),l.useEffect(()=>{if(!u||!$S(e)||M!==null||ve.current)return;let Re=!1;return ve.current=!0,D("loading"),J(null),De(`/api/logs/${String(e.id)}`,As,OS).then(qt=>{Re||(ve.current=!1,k(qt),D("idle"),J(null))}).catch(qt=>{Re||(ve.current=!1,D("failed"),J(Z5(qt)))}),()=>{Re=!0,ve.current=!1}},[u,M,e.bodyContentMode,e.id,e.rawRequestBodyBytes,e.responseTextBytes,X]),l.useEffect(()=>{u&&se&&H.status==="idle"&&(v!=="request"&&v!=="raw-request"&&v!=="anatomy"||ae("request",0))},[v,u,ae,H.status,se]),l.useEffect(()=>{u&&se&&U.status==="idle"&&(v!=="parsed"&&v!=="raw"||ae("response",0))},[v,u,ae,U.status,se]),l.useEffect(()=>{const Re=qt=>{const dt=zr(qt);dt!==null&&dt.logId===e.id&&(p(!0),j(LS(dt.tab,V)),dt.tab==="response"&&dt.toolCallIndex!==void 0&&(N(dt.toolCallIndex),R(xs=>xs+1)))};return window.addEventListener(Gt,Re),()=>{window.removeEventListener(Gt,Re)}},[V,e.id]),t.jsxs(hs,{children:[t.jsxs("div",{className:O("bg-card/80 relative mb-1.5 overflow-hidden rounded-[8px] transition-[background-color,box-shadow]",u?"bg-card shadow-[0_18px_60px_rgba(0,0,0,0.30),0_0_0_1px_rgba(103,232,249,0.08)]":"hover:bg-card"),children:[t.jsx(jS,{log:z,displayNumber:n,messageCount:Ze.messageCount,toolCount:Ze.toolCount,toolEvents:m,expanded:u,onToggle:hn,cacheTrend:i,slowResponseThresholdSeconds:r,showClientMetadata:d,timeDisplayFormat:a,activeTab:v,tabActions:L,onReplay:c===void 0?void 0:()=>{h(!0)}}),u&&t.jsxs("div",{className:"relative bg-black/[0.14] pt-2",onClick:Re=>Re.stopPropagation(),onKeyDown:Re=>Re.stopPropagation(),children:[t.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-12 bg-gradient-to-b from-white/[0.05] to-transparent","aria-hidden":"true"}),t.jsx(zo,{feature:"Log details",children:t.jsxs(Qp,{value:v,onValueChange:j,className:"gap-2",children:[t.jsxs(ef,{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:[pa(s,z.rawHeaders!==void 0&&Object.keys(z.rawHeaders).length>0)&&t.jsx(tn,{className:vn,value:"raw-headers",children:"Raw Headers"}),fa(s,z.headers!==void 0&&Object.keys(z.headers).length>0)&&t.jsx(tn,{className:vn,value:"headers",children:"Headers"}),V!==null&&t.jsx(tn,{className:vn,value:"anatomy",children:"Context"}),_c($e,s,o)&&t.jsx(tn,{className:vn,value:"raw-request",children:"Raw Request"}),t.jsx(tn,{className:vn,value:"request",children:"Request"}),s==="full"&&t.jsx(tn,{className:vn,value:"raw",children:"Raw Response"}),t.jsx(tn,{className:vn,value:"parsed",children:"Response"})]}),_c($e,s,o)&&t.jsx(ut,{value:"raw-request",children:v==="raw-request"&&t.jsxs(yn,{children:[t.jsx(fo,{status:A,error:$,footprint:te,onRetry:ht}),se&&t.jsx(xo,{label:"Request",state:H,expectedBytes:e.rawRequestBodyBytes??null,onLoadMore:()=>ae("request",H.offset)}),ie===null?t.jsx(Io,{children:se?"Request preview is loading":"No request body"}):Le.parsedData!==null?t.jsx(l.Suspense,{fallback:t.jsx(Hn,{}),children:t.jsx(ii,{data:Le.parsedData,bulkDepth:Le.bulkDepth,bulkRevision:Le.bulkRevision})}):t.jsx(ho,{children:ie})]})}),t.jsx(ut,{value:"request",children:v==="request"&&t.jsxs(yn,{children:[t.jsx(fo,{status:A,error:$,footprint:te,onRetry:ht}),se&&t.jsx(xo,{label:"Request",state:H,expectedBytes:e.rawRequestBodyBytes??null,onLoadMore:()=>ae("request",H.offset)}),ce.length>0&&t.jsxs(zs,{tone:"warning",children:[t.jsxs("div",{className:"flex items-center gap-2 font-semibold text-amber-300",children:[t.jsx(rn,{className:"size-3.5"}),"Tool schema warnings"]}),t.jsx("ul",{className:"mt-2 space-y-1 text-muted-foreground",children:ce.map(Re=>t.jsx("li",{children:Re},Re))})]}),t.jsx(AS,{summary:oe,calledToolNames:Bt.toolNames??[]}),y?t.jsx(qS,{rawBody:z.rawRequestBody,displayedBody:Fe,emptyLabel:"No transformation applied; raw and sent request bodies are identical."}):t.jsx("div",{ref:me,children:Fe===null?t.jsx(Io,{children:se?"Request preview is loading":"No request body"}):Me.parsedData!==null?t.jsx(l.Suspense,{fallback:t.jsx(Hn,{}),children:t.jsx(ii,{data:Me.parsedData,bulkDepth:Me.bulkDepth,bulkRevision:Me.bulkRevision,anatomyPaths:Q,expandToPath:I})}):t.jsx(ho,{children:Fe})})]})}),V!==null&&t.jsx(ut,{value:"anatomy",children:v==="anatomy"&&t.jsx(yn,{className:"p-0",children:t.jsx(l.Suspense,{fallback:t.jsx(Hn,{}),children:t.jsx(H5,{parsed:Me.parsedData,inputTokens:z.inputTokens??null,model:z.model,segments:V,onSegmentActivate:pe})})})}),fa(s,z.headers!==void 0&&Object.keys(z.headers).length>0)&&t.jsx(ut,{value:"headers",children:v==="headers"&&t.jsxs(yn,{children:[t.jsx("div",{className:"flex justify-end gap-2 mb-2",children:IS(s,z.rawHeaders!==void 0&&Object.keys(z.rawHeaders).length>0)&&t.jsx(BS,{active:g,onClick:Re=>{Re.stopPropagation(),b(!g)}})}),g?t.jsx(HS,{rawHeaders:z.rawHeaders,headers:z.headers,emptyLabel:"No transformation applied; raw and processed headers are identical."}):t.jsx(Ec,{headers:z.headers,emptyLabel:"No headers captured"})]})}),pa(s,z.rawHeaders!==void 0&&Object.keys(z.rawHeaders).length>0)&&t.jsx(ut,{value:"raw-headers",children:v==="raw-headers"&&t.jsx(yn,{children:t.jsx(Ec,{headers:z.rawHeaders,emptyLabel:"No raw headers captured"})})}),t.jsx(ut,{value:"raw",children:v==="raw"&&t.jsxs(yn,{className:"space-y-3",children:[t.jsx(fo,{status:A,error:$,footprint:te,onRetry:ht}),se&&t.jsx(xo,{label:"Response",state:U,expectedBytes:e.responseTextBytes??null,onLoadMore:()=>ae("response",U.offset)}),z.error!==void 0&&z.error!==null&&t.jsx(zs,{tone:"danger",title:"SSE Error",children:t.jsx("span",{className:"font-mono",children:z.error})}),le!==null&&Ie?t.jsx(l.Suspense,{fallback:t.jsx(Hn,{}),children:t.jsx(K5,{text:le,defaultExpandDepth:0,bulkDepth:B.bulkDepth,bulkRevision:B.bulkRevision})}):le!==null?t.jsx(ho,{children:le}):t.jsx(Io,{children:se?"Response preview is loading":"No response"}),z.streaming===!0&&t.jsx(l.Suspense,{fallback:t.jsx(Hn,{}),children:t.jsx(V5,{logId:z.id,truncated:z.streamingChunksPath!==null})})]})}),t.jsx(ut,{value:"parsed",children:v==="parsed"&&t.jsxs(yn,{children:[t.jsx(fo,{status:A,error:$,footprint:te,onRetry:ht}),se&&t.jsx(xo,{label:"Response",state:U,expectedBytes:e.responseTextBytes??null,onLoadMore:()=>ae("response",U.offset)}),ye&&!Ie?t.jsx(ho,{children:le}):t.jsx(l.Suspense,{fallback:t.jsx(Hn,{}),children:t.jsx(W5,{responseText:le,responseStatus:z.responseStatus,streaming:z.streaming,inputTokens:z.inputTokens,outputTokens:z.outputTokens,cacheCreationInputTokens:z.cacheCreationInputTokens,cacheReadInputTokens:z.cacheReadInputTokens,apiFormat:$e,error:z.error,focusedToolIndex:S,toolFocusNonce:C})})]})})]})})]})]}),t.jsx(zo,{feature:"Replay",children:t.jsx(l.Suspense,{fallback:null,children:t.jsx(q5,{log:z,displayNumber:n,open:f,onOpenChange:h})})})]})});function VS(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 ha(e){return e?"cursor-pointer transition-transform hover:scale-110":""}function KS({stopReason:e,isPending:n,isFirst:s,isTurnStart:o,isOnlyEntry:r=!1,isOpenTurnTail:a=!1,crabIndex:i=0,collapsible:c=!1,onToggle:d}){const m=yl(e),u=r&&o&&m,p=n&&!m,f=c&&d!==void 0,h=l.useMemo(()=>wl(i),[i]),g=l.useMemo(()=>E5(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 t.jsxs("div",{className:"flex flex-col items-center w-6 shrink-0 pt-0.5 pb-0.5",children:[t.jsx("div",{className:"flex justify-center h-[calc(0.75rem-8px)]",children:!s&&t.jsx("div",{className:"w-px bg-muted-foreground/18 h-full"})}),u?t.jsx("span",{role:f?"button":void 0,tabIndex:f?0:void 0,title:"Single-request turn",className:ha(f),onClick:b,onKeyDown:y,children:t.jsx(g,{className:O("size-3.5 text-[#80FF00]","animate-crab-settle","drop-shadow-[0_0_4px_rgba(128,255,0,0.5)]")})}):m?t.jsx("span",{role:f?"button":void 0,tabIndex:f?0:void 0,title:VS(e),className:ha(f),onClick:b,onKeyDown:y,children:t.jsx(h,{className:O("size-3.5 text-amber-400","animate-crab-settle","drop-shadow-[0_0_4px_rgba(251,191,36,0.5)]")})}):o?t.jsx("span",{role:f?"button":void 0,tabIndex:f?0:void 0,title:"Start of turn",className:ha(f),onClick:b,onKeyDown:y,children:t.jsx(h,{className:O("size-3.5 text-emerald-400","animate-crab-appear","drop-shadow-[0_0_4px_rgba(52,211,153,0.5)]")})}):a?t.jsx("span",{title:n?"Current end of open turn (processing)":"Current end of open turn",children:t.jsx(h,{className:O("size-3.5 text-cyan-300/85",p?"animate-crab-crawl":"animate-crab-appear","drop-shadow-[0_0_4px_rgba(103,232,249,0.4)]")})}):p?t.jsx("span",{title:"Processing",children:t.jsx(h,{className:O("size-3.5 text-amber-300/80","animate-crab-crawl")})}):t.jsx("span",{title:"Request in turn",children:t.jsx(h,{className:"size-3.5 text-muted-foreground/40"})}),t.jsx("div",{className:"flex-1 flex justify-center min-h-0",children:!m&&!a&&t.jsx("div",{className:O("w-0.5 h-full",n?"border-dashed bg-transparent border-l border-muted-foreground/14":"bg-muted-foreground/18")})})]})}const Rc=180,xa=new WeakMap;function GS(e,n){const s=e.responseText;if(s===null)return!1;switch(n){case"anthropic":return s.includes("tool_use");case"openai":return s.includes("tool_calls")||s.includes("function_call");case"unknown":return!1}}function JS(e){return e>1}function di(e){const n=[];let s=[],o=0;for(let r=0;r<e.length;r+=1){const a=e[r];if(a===void 0)continue;s.push({log:a,stopReason:Yp(a),sessionLogNumber:r+1});const i=s[s.length-1];i!==void 0&&yl(i.stopReason)&&(n.push({entries:s,turnIndex:o}),s=[],o+=1)}return s.length>0&&n.push({entries:s,turnIndex:o}),n}function YS(e){const n=new Map;for(const s of e)for(let o=1;o<s.logs.length;o+=1){const r=s.logs[o],a=s.logs[o-1];if(r===void 0||a===void 0)continue;const i=Os(r),c=Os(a);i==="unknown"||i!==c||n.set(r.id,a)}return n}function cf(e){if(e===null)return null;try{const n=JSON.parse(e);return typeof n=="string"?JSON.parse(n):n}catch{return null}}function Po(e){if(e==null)return null;const n=typeof e=="string"?e:JSON.stringify(e);if(n===void 0)return null;const s=n.replace(/\s+/g," ").trim();return s.length===0?null:s.length>Rc?`${s.slice(0,Rc-1)}...`:s}function Lo(e){if(e==null)return null;if(typeof e=="string")return e.length>0?e:null;const n=JSON.stringify(e,null,2);return n===void 0||n.length===0?null:n}function XS(e){const n=cf(e.responseText),s=Z(n,"content");if(!Array.isArray(s))return[];const o=[];for(const r of s){if(Z(r,"type")!=="tool_use")continue;const i=Z(r,"name");if(typeof i!="string"||i.length===0)continue;const c=Z(r,"input");o.push({id:`${String(e.id)}-anthropic-tool-${String(o.length)}`,logId:e.id,index:o.length,provider:"anthropic",name:i,argumentsText:Lo(c),argumentsPreview:Po(c)})}return o}function ZS(e){const n=cf(e.responseText),s=Z(n,"choices");if(!Array.isArray(s))return[];const o=[];for(const a of s){const i=Z(a,"message"),c=Z(i,"tool_calls");if(Array.isArray(c))for(const u of c){const p=Z(u,"function"),f=Z(p,"name");if(typeof f!="string"||f.length===0)continue;const h=Z(p,"arguments");o.push({id:`${String(e.id)}-openai-tool-${String(o.length)}`,logId:e.id,index:o.length,provider:"openai",name:f,argumentsText:Lo(h),argumentsPreview:Po(h)})}const d=Z(i,"function_call"),m=Z(d,"name");if(typeof m=="string"&&m.length>0){const u=Z(d,"arguments");o.push({id:`${String(e.id)}-openai-tool-${String(o.length)}`,logId:e.id,index:o.length,provider:"openai",name:m,argumentsText:Lo(u),argumentsPreview:Po(u)})}}const r=Z(n,"output");if(Array.isArray(r))for(const a of r){if(Z(a,"type")!=="function_call")continue;const i=Z(a,"name");if(typeof i!="string"||i.length===0)continue;const c=Z(a,"arguments");o.push({id:`${String(e.id)}-openai-tool-${String(o.length)}`,logId:e.id,index:o.length,provider:"openai",name:i,argumentsText:Lo(c),argumentsPreview:Po(c)})}return o}function jl(e){const n=xa.get(e);if(n!==void 0&&n.apiFormat===e.apiFormat&&n.responseText===e.responseText)return n.events;const s=Os(e);if(!GS(e,s)){const r=[];return xa.set(e,{apiFormat:e.apiFormat,responseText:e.responseText,events:r}),r}let o;switch(s){case"anthropic":o=XS(e);break;case"openai":o=ZS(e);break;case"unknown":o=[];break}return xa.set(e,{apiFormat:e.apiFormat,responseText:e.responseText,events:o}),o}function QS(e,n,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&&n>0&&h.elapsedMs>n*1e3&&(a+=1),h.inputTokens!==null&&(i+=h.inputTokens),h.outputTokens!==null&&(c+=h.outputTokens),h.cacheCreationInputTokens!==null&&(d+=h.cacheCreationInputTokens),h.cacheReadInputTokens!==null&&(m+=h.cacheReadInputTokens),h.elapsedMs!==null&&(u+=h.elapsedMs,p=p===null?h.elapsedMs:Math.max(p,h.elapsedMs)),f+=jl(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 ga(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}const eN=l.memo(function({entries:n,viewMode:s,strip:o,slowResponseThresholdSeconds:r,cacheTrends:a,onCompareWithPrevious:i,comparisonPredecessors:c,turnIndex:d=0,timeDisplayFormat:m,pendingFocusRequest:u,showLogClientMetadata:p=!0}){const f=n.length-1,h=n[f]?.stopReason??null,g=h!==null?yl(h):!1,b=n[f]?.log.responseStatus===null,y=n.length===1,w=JS(n.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 F=H=>{const Y=zr(H);Y!==null&&n.some(U=>U.log.id===Y.logId)&&w&&j(!1)};return window.addEventListener(Gt,F),()=>{window.removeEventListener(Gt,F)}},[w,n]),l.useEffect(()=>{if(u===void 0||!n.some(H=>H.log.id===u.logId))return;w&&j(!1);const F=window.setTimeout(()=>{ds({logId:u.logId,tab:u.tab,source:"virtualizer"})},0);return()=>window.clearTimeout(F)},[w,n,u]);const N=l.useCallback(()=>{w&&j(F=>!F)},[w]),C=l.useMemo(()=>{let F=0,H=0,Y=null,U=!1;for(const W of n)W.log.inputTokens!==null&&(F+=W.log.inputTokens,U=!0),W.log.outputTokens!==null&&(H+=W.log.outputTokens,U=!0),W.log.elapsedMs!==null&&(Y=Y===null?W.log.elapsedMs:Math.max(Y,W.log.elapsedMs));return{totalInput:F,totalOutput:H,hasTokens:U,maxElapsed:Y}},[n,f]),R=d%2===0?"bg-white/[0.008]":"bg-cyan-300/[0.008]",I=C.maxElapsed!==null&&r>0&&C.maxElapsed>r*1e3,P=l.useMemo(()=>{const F=new Map;for(const H of n){const Y=jl(H.log);Y.length>0&&F.set(H.log.id,Y)}return F},[n]),[M,k]=l.useState(0),A=l.useRef(null);l.useEffect(()=>{const F=A.current;if(!F)return;let H=0;const Y=new ResizeObserver(()=>{window.cancelAnimationFrame(H),H=window.requestAnimationFrame(()=>k(U=>U+1))});return Y.observe(F),()=>{Y.disconnect(),window.cancelAnimationFrame(H)}},[]);const D=n[0]?.log.id??d,$=`Turn ${String(d+1)}`,J=l.useMemo(()=>wl(D%12),[D]),X=l.useMemo(()=>({contentVisibility:"auto",containIntrinsicSize:v?"48px":"160px"}),[v]);return t.jsx("div",{ref:A,style:X,tabIndex:v?void 0:0,role:v?void 0:"group","aria-label":v?void 0:$,"data-nav-id":v?void 0:`turn-${String(D)}`,className:O("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?t.jsxs("div",{"data-nav-id":`turn-collapsed-${String(D)}`,"data-nav-action":"expand",role:"button",tabIndex:0,className:"flex items-stretch cursor-pointer focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-none rounded-lg",onClick:N,onKeyDown:F=>{(F.key==="Enter"||F.key===" ")&&(F.preventDefault(),N())},children:[t.jsxs("div",{className:"w-6 shrink-0 flex flex-col items-center pt-1.5 pb-1.5",children:[t.jsx("div",{className:"flex justify-center h-[calc(0.75rem-8px)]"}),t.jsx(J,{className:O("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)]")}),t.jsx("div",{className:"flex-1 flex justify-center min-h-0",children:t.jsx("div",{className:"w-px bg-muted-foreground/14 h-full"})}),g?t.jsx(J,{className:O("size-3.5 animate-crab-settle text-amber-400","drop-shadow-[0_0_4px_rgba(251,191,36,0.45)]")}):t.jsx("span",{title:"Current end of open turn","aria-label":"Current end of open turn",children:t.jsx(J,{className:O("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)]")})})]}),n.length>1&&t.jsxs("div",{className:O("flex-1 min-w-0 mb-0.5 rounded-[8px] py-1.5 px-3 flex items-center gap-3 text-xs","bg-card/80 transition-colors hover:bg-card",R),children:[t.jsx("span",{className:"font-mono text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground/70",children:$}),t.jsxs("span",{className:"text-blue-300/85 font-mono font-semibold tabular-nums shrink-0",title:`Log IDs ${String(n[0]?.log.id??"?")} ~ ${String(n[f]?.log.id??"?")}`,children:["#",n[0]?.sessionLogNumber??"?"," ~ #",n[f]?.sessionLogNumber??"?"]}),t.jsxs("span",{className:"text-muted-foreground shrink-0",children:[n.length," request",n.length>1?"s":""]}),C.maxElapsed!==null&&t.jsx(hs,{children:t.jsxs(et,{children:[t.jsx(tt,{asChild:!0,children:t.jsxs("span",{className:O("flex items-center gap-1 shrink-0",I?"text-amber-400":"text-muted-foreground"),children:[t.jsx(Wt,{className:"size-3"}),t.jsx("span",{className:"font-mono tabular-nums",children:ga(C.maxElapsed)}),I&&t.jsx(rn,{className:"size-3","aria-label":"Slow response"})]})}),t.jsx(nt,{children:I?`Slow response: ${ga(C.maxElapsed)} exceeds ${ga(r*1e3)}`:"Slowest request in this turn"})]})}),C.hasTokens&&t.jsxs("span",{className:"flex items-center gap-1 shrink-0",children:[t.jsx(Is,{className:"size-3 text-muted-foreground"}),t.jsxs("span",{className:"font-mono tabular-nums",children:[t.jsxs("span",{className:"text-blue-400",children:["IN ",Ee(C.totalInput)]})," / ",t.jsxs("span",{className:"text-amber-400",children:["OUT ",Ee(C.totalOutput)]})]})]}),t.jsx("span",{className:"flex-1 min-w-0"}),t.jsx("span",{className:"bg-white/[0.045] inline-flex size-7 shrink-0 items-center justify-center rounded-md text-text-strong","aria-hidden":"true",children:t.jsx(it,{className:"size-4 shrink-0"})})]})]}):n.map((F,H)=>{const{log:Y,stopReason:U}=F,W=H===0;return t.jsxs("div",{className:"flex items-stretch",children:[t.jsx(KS,{stopReason:U,isPending:Y.responseStatus===null,isFirst:H===0,isTurnStart:W,isOnlyEntry:y,isOpenTurnTail:H===f&&!g,crabIndex:Y.id%12,collapsible:w&&W,onToggle:N}),t.jsx("div",{className:O("flex-1 min-w-0 mb-0.5 rounded-[8px]",R),children:t.jsx(WS,{log:Y,displayNumber:F.sessionLogNumber,viewMode:s,strip:o,slowResponseThresholdSeconds:r,timeDisplayFormat:m,cacheTrend:a?.get(Y.id)??null,showClientMetadata:p,toolEvents:P.get(Y.id),onCompareWithPrevious:c.has(Y.id)?i:void 0})})]},Y.id)})})}),tN=24,nN=132,sN=8;function oN(e){return e>tN}function rN(e){const n=new Map;for(let s=0;s<e.length;s++){const o=e[s];if(o!==void 0)for(const r of o.entries)n.set(r.log.id,s)}return n}function df(e,n,s){return t.jsx(eN,{entries:e.entries,viewMode:n.viewMode,strip:n.strip,slowResponseThresholdSeconds:n.slowResponseThresholdSeconds,timeDisplayFormat:n.timeDisplayFormat,cacheTrends:n.cacheTrends,onCompareWithPrevious:n.onCompareWithPrevious,comparisonPredecessors:n.comparisonPredecessors,turnIndex:e.turnIndex,pendingFocusRequest:s,showLogClientMetadata:n.showLogClientMetadata},e.turnIndex)}function aN(e){return oN(e.turnGroups.length)?t.jsx(iN,{...e}):t.jsx(t.Fragment,{children:e.turnGroups.map(n=>df(n,e))})}function iN(e){const{turnGroups:n}=e,[s,o]=l.useState(null),r=p5({count:n.length,estimateSize:()=>nN,overscan:sN,getItemKey:i=>n[i]?.turnIndex??i}),a=l.useMemo(()=>rN(n),[n]);return l.useEffect(()=>{const i=c=>{const d=zr(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(Gt,i),()=>{window.removeEventListener(Gt,i)}},[a,r]),t.jsx("div",{className:"relative w-full",style:{height:`${r.getTotalSize()}px`},"data-virtualized-turn-list":"true",children:r.getVirtualItems().map(i=>{const c=n[i.index];if(c===void 0)return null;const d=s!==null&&s.turnIndex===i.index?s:void 0;return t.jsx("div",{"data-index":i.index,ref:r.measureElement,className:"absolute left-0 top-0 w-full",style:{transform:`translateY(${i.start}px)`},children:df(c,e,d)},i.key)})})}const Sl=ue(["episode","procedure","preference","project-fact"]),lN=ue(["draft","promoted","failed"]),uf=T({source:re("agent-inspector"),sessionId:x(),logIds:K(At),project:x().nullable(),models:K(x())}),cN=T({redacted:_e(),patterns:K(x())}),Qs=T({id:x(),type:Sl,title:x(),content:x(),tags:K(x()),source:re("agent-inspector"),sessionId:x(),logIds:K(At),evidence:uf,status:lN,createdAt:x(),updatedAt:x(),openClawMemoryId:x().nullable(),error:x().nullable(),redaction:cN});T({idempotencyKey:x(),type:Sl,title:x(),content:x(),tags:K(x()),source:re("agent-inspector"),project:x().nullable(),evidence:uf});const dN=T({id:x(),type:Sl.or(x()),title:x(),content:x(),score:E().nullable(),source:x().nullable(),project:x().nullable(),evidence:_s().optional()});T({results:K(dN),warning:x().nullable()});const uN=T({candidates:K(Qs)}),mN=T({candidate:Qs}),pN=T({error:x().optional(),candidate:Qs.optional()}),fN=T({candidate:Qs}),hN=3e4,xN=15e3,gN=15e3,bN={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 ui(e){return e===null?"-":e<1e3?`${String(e)}ms`:`${(e/1e3).toFixed(1)}s`}function vN(e,n,s){return e===null||n===null?null:hr(e,n,s)}function yN(e){return`${String(e)} candidate${e===1?"":"s"}`}function mf(e){return`log-${String(e)}`}function pf(e){const n=mf(e),s=document.getElementById(n);window.history.replaceState(null,"",`#${n}`),s instanceof HTMLElement&&(s.scrollIntoView({block:"center",behavior:"smooth"}),s.focus({preventScroll:!0}))}function wN(e){for(const n of e)if(n.responseStatus!==null&&n.responseStatus>=400)return n;return null}function jN(e){let n=null,s=-1;for(const o of e)o.elapsedMs!==null&&o.elapsedMs>s&&(n=o,s=o.elapsedMs);return n}function SN(e){for(const n of e)if(jl(n).length>0)return n;return null}function NN(e){const n=new Map;for(let s=0;s<e.length;s+=1){const o=e[s];o!==void 0&&n.set(o.id,s+1)}return n}function ts(e,n){return String(n.get(e)??e)}function CN(e){const n=[{kind:"session",title:`${String(e.summary.llmCallCount)} LLM call${e.summary.llmCallCount===1?"":"s"}`,detail:`Scope ${e.scopeId}`,logId:e.logs[0]?.id??null}],s=SN(e.logs);e.summary.toolCallCount>0&&s!==null&&n.push({kind:"tool",title:`${String(e.summary.toolCallCount)} tool call${e.summary.toolCallCount===1?"":"s"}`,detail:`First tool evidence at #${ts(s.id,e.displayNumberByLogId)}`,logId:s.id});const o=wN(e.logs);o!==null&&n.push({kind:"failure",title:`Failure #${String(o.responseStatus)}`,detail:`First failed request is #${ts(o.id,e.displayNumberByLogId)}`,logId:o.id});const r=jN(e.logs);if(r!==null&&e.summary.maxElapsedMs!==null&&n.push({kind:"slow",title:`Slowest ${ui(e.summary.maxElapsedMs)}`,detail:`Max latency observed at #${ts(r.id,e.displayNumberByLogId)}`,logId:r.id}),e.candidates.length>0){const a=e.candidates.filter(c=>c.status==="draft").length,i=e.candidates.filter(c=>c.status==="promoted").length;n.push({kind:"candidate",title:`${String(e.candidates.length)} memory candidate${e.candidates.length===1?"":"s"}`,detail:`${String(a)} draft / ${String(i)} promoted`,logId:e.candidates[0]?.logIds[0]??null})}return n}function kN(e){switch(e){case"session":return t.jsx(fr,{className:"size-3.5 text-blue-400"});case"tool":return t.jsx(Vs,{className:"size-3.5 text-sky-400/70"});case"slow":return t.jsx(Wt,{className:"size-3.5 text-amber-400"});case"failure":return t.jsx(nu,{className:"size-3.5 text-destructive"});case"candidate":return t.jsx(tu,{className:"size-3.5 text-emerald-400"})}}function _N({insights:e}){return e.length===0?null:t.jsx("div",{className:"mt-2 grid gap-1.5 border-t border-border/70 pt-2 md:grid-cols-2 xl:grid-cols-3",children:e.map(n=>t.jsxs("button",{type:"button",className:O("flex min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs","text-muted-foreground transition-colors hover:bg-muted/40 hover:text-foreground","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),onClick:()=>{n.logId!==null&&pf(n.logId)},disabled:n.logId===null,children:[kN(n.kind),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block truncate font-medium text-foreground/90",children:n.title}),t.jsx("span",{className:"block truncate font-mono text-[10px]",children:n.detail})]})]},`${n.kind}-${n.title}`))})}function TN(e){switch(e){case"draft":return"Draft";case"promoted":return"Promoted";case"failed":return"Failed"}}function EN(e,n){if(n)return"Promoting";switch(e.status){case"draft":return"Promote";case"failed":return"Retry";case"promoted":return"Promoted"}}function RN(e){return e.redaction.redacted?`Redacted ${e.redaction.patterns.join(", ")}`:"No sensitive pattern matched"}function MN(e,n){const s=e.replace(/\s+/g," ").trim();return s.length<=n?s:`${s.slice(0,n-3)}...`}function AN(e,n){const s=e[0],o=e[e.length-1];if(s===void 0)return"No evidence logs";const r=ts(s,n);return o===void 0||s===o?`#${r}`:`#${r}-#${ts(o,n)}`}function Mc(e){return e.join(", ")}function IN(e){return e.split(",").map(n=>n.trim()).filter(n=>n.length>0)}function PN({candidate:e,isPromoting:n,isUpdating:s,onPromoteCandidate:o,onUpdateCandidate:r,displayNumberByLogId:a}){const[i,c]=l.useState(!1),[d,m]=l.useState(e.type),[u,p]=l.useState(e.title),[f,h]=l.useState(e.content),[g,b]=l.useState(Mc(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(Mc(e.tags)),w(null)},[e.content,e.tags,e.title,e.type]),N=l.useCallback(async()=>{const C=u.trim(),R=f.trim(),I=IN(g);if(C.length===0){w("Title is required.");return}if(R.length===0){w("Content is required.");return}if(I.length===0){w("At least one tag is required.");return}w(null),await r(e.id,{type:d,title:C,content:R,tags:I})&&c(!1)},[e.id,f,g,u,d,r]);return i?t.jsx("div",{className:"border border-border bg-card shadow-sm rounded-[8px] px-2.5 py-2",children:t.jsxs("div",{className:"grid gap-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("select",{value:d,disabled:s,onChange:C=>{const R=Qs.shape.type.safeParse(C.currentTarget.value);R.success&&m(R.data)},className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground h-7 rounded-md px-2 text-xs","aria-label":"Candidate type",children:[t.jsx("option",{value:"episode",children:"episode"}),t.jsx("option",{value:"procedure",children:"procedure"}),t.jsx("option",{value:"preference",children:"preference"}),t.jsx("option",{value:"project-fact",children:"project-fact"})]}),t.jsx("input",{value:u,disabled:s,onChange:C=>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"})]}),t.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"}),t.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"}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-muted-foreground",children:[t.jsx(ql,{className:"size-3"}),"Saving reruns Inspector redaction before promotion."]}),t.jsx("span",{className:"flex-1"}),y!==null&&t.jsx("span",{className:"text-[10px] text-destructive",children:y}),t.jsxs(ee,{type:"button",variant:"ghost",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:s,onClick:()=>{S(),c(!1)},children:[t.jsx(Ks,{className:"size-3.5"}),"Cancel"]}),t.jsxs(ee,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:s,onClick:()=>{N()},children:[s?t.jsx(yt,{className:"size-3.5 animate-spin"}):t.jsx(Vg,{className:"size-3.5"}),"Save"]})]})]})}):t.jsxs("div",{className:"rounded-md border border-border/80 bg-background/60 px-2.5 py-2",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(ke,{variant:"outline",className:"h-5 px-1.5 text-[10px] font-mono",children:e.type}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium",title:e.title,children:e.title}),t.jsx(ke,{variant:"outline",className:O("h-5 shrink-0 px-1.5 text-[10px] font-mono",bN[e.status]),children:TN(e.status)})]}),t.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",title:e.content,children:MN(e.content,360)}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] text-muted-foreground",children:[t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(K0,{className:"size-3"}),AN(e.logIds,a)]}),t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(ql,{className:"size-3"}),RN(e)]}),e.status==="promoted"&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-emerald-500",children:[t.jsx($a,{className:"size-3"}),e.openClawMemoryId??"OpenClaw"]}),e.status==="failed"&&e.error!==null&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-destructive",children:[t.jsx(nu,{className:"size-3"}),e.error]})]}),t.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5",children:[e.logIds.map(C=>{const R=ts(C,a);return t.jsxs("a",{href:`#${mf(C)}`,onClick:I=>{I.preventDefault(),pf(C)},className:"rounded border border-blue-400/25 px-1.5 py-0.5 font-mono text-[10px] text-blue-400 underline-offset-2 transition-colors hover:bg-blue-400/10 hover:text-blue-300 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":`Jump to evidence log ${R}`,title:`Log ID ${String(C)}`,children:["#",R]},C)}),t.jsx("span",{className:"flex-1"}),j&&t.jsxs(ee,{type:"button",variant:"ghost",size:"sm",className:"h-6 gap-1.5 px-2 text-[10px]",disabled:s||n,onClick:()=>c(!0),children:[t.jsx(cu,{className:"size-3"}),"Review"]}),t.jsxs(ee,{type:"button",variant:v?"outline":"ghost",size:"sm",className:"h-6 gap-1.5 px-2 text-[10px]",onClick:()=>o(e.id),disabled:!v||n||s,children:[n?t.jsx(yt,{className:"size-3 animate-spin"}):v?t.jsx(T0,{className:"size-3"}):t.jsx($a,{className:"size-3"}),EN(e,n)]})]})]})}function LN({candidates:e,promotingCandidateIds:n,updatingCandidateIds:s,onPromoteCandidate:o,onUpdateCandidate:r,displayNumberByLogId:a}){return e.length===0?null:t.jsx("div",{className:"mt-2 grid gap-1.5",children:e.map(i=>t.jsx(PN,{candidate:i,isPromoting:n.has(i.id),isUpdating:s.has(i.id),onPromoteCandidate:o,onUpdateCandidate:r,displayNumberByLogId:a},i.id))})}function ON({logs:e,scopeId:n,slowResponseThresholdSeconds:s,showRollupMetrics:o,timeDisplayFormat:r}){const[a,i]=l.useState([]),[c,d]=l.useState(!0),[m,u]=l.useState({status:"idle",error:null}),[p,f]=l.useState(()=>new Set),[h,g]=l.useState(()=>new Set),b=a.length>0,y=l.useMemo(()=>QS(e,s,a.length),[a.length,e,s]),w=l.useMemo(()=>NN(e),[e]),v=l.useMemo(()=>CN({logs:e,scopeId:n,summary:y,candidates:a,displayNumberByLogId:w}),[a,w,e,n,y]),j=o||y.maxElapsedMs!==null,S=l.useMemo(()=>vN(y.startedAt,y.endedAt,r),[y.endedAt,y.startedAt,r]),N=l.useCallback(()=>{e.length===0||m.status==="loading"||(u({status:"loading",error:null}),(async()=>{try{const I=await De(`/api/knowledge/sessions/${encodeURIComponent(n)}/candidates`,uN,hN,{method:"POST"},P=>`Candidate generation failed with ${String(P.status)}`);i(I.candidates),d(I.candidates.length>0),u(I.candidates.length>0?{status:"ready",error:null}:{status:"failed",error:"No candidate was generated for this trace scope."})}catch(I){u({status:"failed",error:I instanceof Error?I.message:"Candidate response was invalid"})}})())},[m.status,e.length,n]),C=l.useCallback(I=>{f(P=>{if(P.has(I))return P;const M=new Set(P);return M.add(I),M}),(async()=>{try{const P=await Xn(`/api/knowledge/candidates/${encodeURIComponent(I)}/promote`,xN,{method:"POST"}),M=await P.json().catch(()=>null),k=mN.safeParse(M);if(P.ok&&k.success){i(D=>D.map($=>$.id===k.data.candidate.id?k.data.candidate:$)),u({status:"ready",error:null});return}const A=pN.safeParse(M);A.success&&A.data.candidate!==void 0&&i(D=>D.map($=>$.id===A.data.candidate?.id?A.data.candidate:$)),u({status:"failed",error:A.success?A.data.error??"Candidate promotion failed":`Candidate promotion failed with ${String(P.status)}`})}catch(P){u({status:"failed",error:P instanceof Error?P.message:"Candidate promotion failed"})}finally{f(P=>{const M=new Set(P);return M.delete(I),M})}})()},[]),R=l.useCallback(async(I,P)=>{g(M=>{if(M.has(I))return M;const k=new Set(M);return k.add(I),k});try{const M=await De(`/api/knowledge/candidates/${encodeURIComponent(I)}`,fN,gN,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(P)},k=>`Candidate update failed with ${String(k.status)}`);return i(k=>k.map(A=>A.id===M.candidate.id?M.candidate:A)),u({status:"ready",error:null}),!0}catch(M){return u({status:"failed",error:M instanceof Error?M.message:"Candidate update failed"}),!1}finally{g(M=>{const k=new Set(M);return k.delete(I),k})}},[]);return e.length===0?null:t.jsxs("section",{className:"border border-border bg-card shadow-sm mb-2 rounded-[8px] px-3 py-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 text-xs",children:[o&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 font-semibold text-foreground",children:[t.jsx(fr,{className:"size-3.5 text-blue-400"}),y.llmCallCount," LLM"]}),t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(Vs,{className:"size-3.5 text-sky-400/70"}),y.toolCallCount," tools"]}),o&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(Is,{className:"size-3.5 text-emerald-400"}),t.jsxs("span",{className:"font-mono",children:[Ee(y.totalInputTokens)," / ",Ee(y.totalOutputTokens)]})]}),(y.totalCacheCreationInputTokens>0||y.totalCacheReadInputTokens>0)&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(Is,{className:"size-3.5 text-purple-400"}),t.jsxs("span",{className:"font-mono",children:["KV Cache +",Ee(y.totalCacheCreationInputTokens)," / ~",Ee(y.totalCacheReadInputTokens)]})]}),j&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(Wt,{className:"size-3.5"}),o&&t.jsx("span",{className:"font-mono",children:ui(y.totalElapsedMs)}),y.maxElapsedMs!==null&&t.jsxs("span",{className:"font-mono text-muted-foreground/70",children:["max ",ui(y.maxElapsedMs)]})]}),o&&S!==null&&t.jsx("span",{className:"font-mono text-muted-foreground/70",children:S}),(y.failedCallCount>0||y.pendingCallCount>0||y.slowCallCount>0)&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-amber-400",children:[t.jsx(rn,{className:"size-3.5"}),t.jsxs("span",{className:"font-mono",children:[y.failedCallCount," fail / ",y.pendingCallCount," pending /"," ",y.slowCallCount," slow"]})]}),t.jsx("span",{className:"flex-1"}),b&&t.jsx(ke,{variant:"outline",className:"h-6 px-2 text-[10px] font-mono",children:yN(y.knowledgeCandidateCount)}),t.jsxs(ee,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",onClick:N,disabled:m.status==="loading",children:[m.status==="loading"?t.jsx(Ae,{className:"size-3.5 animate-spin"}):t.jsx(tu,{className:"size-3.5"}),"Candidate"]}),b&&t.jsx(ee,{type:"button",variant:"ghost",size:"icon",className:"size-7 text-muted-foreground",onClick:()=>d(I=>!I),"aria-expanded":c,"aria-label":c?"Collapse memory candidates":"Expand memory candidates",children:c?t.jsx(Ve,{className:"size-3.5"}):t.jsx(it,{className:"size-3.5"})})]}),m.status==="failed"&&t.jsx("p",{className:"mt-2 text-xs text-destructive",children:m.error}),t.jsx(_N,{insights:v}),c&&t.jsx(LN,{candidates:a,promotingCandidateIds:p,updatingCandidateIds:h,onPromoteCandidate:C,onUpdateCandidate:R,displayNumberByLogId:w})]})}function DN(e){let n=0,s=0;for(const o of e)o.inputTokens!==null&&(n+=o.inputTokens),o.outputTokens!==null&&(s+=o.outputTokens);return{totalInputTokens:n,totalOutputTokens:s}}function zN(e){const n=new Map;for(const s of e){if(s.model===null)continue;const o=uj(s.model);if(o==="unknown")continue;let r=n.get(o);r===void 0&&(r=new Set,n.set(o,r)),r.add(s.model)}return[...n.entries()].map(([s,o])=>({provider:s,models:[...o]}))}function $N(e){for(const n of e){const s=n.clientPid;if(s!=null)return s}return null}function FN(e){for(const n of e){const s=n.clientProjectFolder;if(s!=null&&s!=="")return s}return null}const UN=l.memo(function({group:e,viewMode:n="simple",strip:s,slowResponseThresholdSeconds:o,cacheTrends:r,onCompareWithPrevious:a,comparisonPredecessors:i,onClearGroup:c,showClientIdentity:d=!0,showProcessMetadata:m=!0,showLogClientMetadata:u=!0,defaultExpanded: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(()=>DN(e.logs),[e.logs]),S=l.useMemo(()=>zN(e.logs),[e.logs]),N=e.logs[0]?.timestamp??new Date().toISOString(),C=e.logs[e.logs.length-1]?.timestamp??new Date().toISOString(),R=e.logs.some(k=>k.responseStatus===null),I=l.useMemo(()=>$N(e.logs),[e.logs]),P=l.useMemo(()=>FN(e.logs),[e.logs]),M=l.useMemo(()=>di(e.logs),[e.logs]);return l.useEffect(()=>{const k=A=>{const D=zr(A);D!==null&&e.logs.some($=>$.id===D.logId)&&v(!0)};return window.addEventListener(Gt,k),()=>{window.removeEventListener(Gt,k)}},[e.logs,v]),t.jsxs("div",{className:"mb-1.5",children:[t.jsx(Kj,{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:R,userAgent:e.logs[0]?.userAgent??null,clientPid:I,clientProjectFolder:P,showClientIdentity:d,showProcessMetadata:m,timeDisplayFormat:f,onClear:()=>c(e.logs.map(k=>k.id))}),w&&t.jsxs("div",{children:[t.jsx(ON,{logs:e.logs,scopeId:e.conversationId,slowResponseThresholdSeconds:o,showRollupMetrics:!1,timeDisplayFormat:f}),t.jsx(aN,{turnGroups:M,viewMode:n,strip:s,slowResponseThresholdSeconds:o,timeDisplayFormat:f,cacheTrends:r,onCompareWithPrevious:a,comparisonPredecessors:i,showLogClientMetadata:u})]})]})}),BN="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",qN="m-0 min-w-0 flex-1 overflow-x-auto font-mono text-xs text-foreground sm:text-sm";function HN(e){return[`PROXY_BASE_URL=${e.proxy}`,`MCP_URL=${e.mcp}`]}function WN(e){return e==="full"}function VN(e){return e==="raw"}function KN(e,n){const s=n>0;return{redacted:s,raw:s&&WN(e)}}function GN(e,n){const s=e[0],o=e[e.length-1];return s===void 0||o===void 0?null:hr(s.timestamp,o.timestamp,n)}function JN(e){return e.error!==null&&e.error!==void 0&&e.error.length>0?!0:e.responseStatus!==null&&e.responseStatus>=400}function YN(e){const n=new Set;for(const o of e)o.model!==null&&o.model.length>0&&n.add(o.model);const s=[...n].sort();return s.length===0?"Model unknown":s.length===1?s[0]??"Model unknown":`${s.length} models`}function XN(e){const n=new Set;for(const o of e)o.providerName!==null&&o.providerName!==void 0&&o.providerName.length>0&&n.add(o.providerName);const s=[...n].sort();return s.length===0?"Provider unknown":s.length===1?s[0]??"Provider unknown":`${s.length} providers`}function ZN(e){if(e<1e3)return`${e}ms`;if(e<6e4){const r=e/1e3;return`${r<10?r.toFixed(1):r.toFixed(0)}s`}const n=Math.round(e/1e3),s=Math.floor(n/60),o=n%60;return`${s}m ${o}s`}function QN(e,n){return`${Ee(e)} in / ${Ee(n)} out`}function eC(e,n){if(e.length===0)return 0;if(n.length===0)return di(e).length;let s=0;for(const o of n)s+=di(o.logs).length;return s}function tC({stopReason:e,pending:n,lastFailureLogNumber:s}){if(n>0)return{label:"In flight",detail:`${n} request${n===1?"":"s"} pending`,tone:"cool"};if(s!==null&&e===null)return{label:"Error",detail:`Last failed request #${s}`,tone:"danger"};switch(e){case"end_turn":return{label:"End turn",detail:"Assistant completed the turn",tone:"neutral"};case"stop":return{label:"Stop",detail:"Model reached a stop condition",tone:"neutral"};case"length":return{label:"Output limit",detail:"Turn ended at max output tokens",tone:"watch"};case"tool_use":return{label:"Tool call",detail:"Assistant requested a tool",tone:"cool"};case null:return{label:"Unknown",detail:"No finish reason captured",tone:"neutral"}}}function nC(e){if(e===null)return!1;const n=e.toLowerCase();return n.includes("abort")||n.includes("cancel")||n.includes("client disconnected")||n.includes("stream disconnected")||n.includes("connection closed")}function sC({pending:e,failures:n,lengthStops:s,stopReason:o,lastFailure:r}){if(r!==null&&(r.status===499||nC(r.error)))return{label:"Client aborted",detail:`Request #${r.logNumber} ended before completion`,tone:"watch"};if(e>0)return{label:"In flight",detail:`${e} request${e===1?"":"s"} still running`,tone:"cool"};if(r!==null&&r.status!==null&&r.status>=500)return{label:"Provider error",detail:`Request #${r.logNumber} returned HTTP ${r.status}`,tone:"danger"};if(n>0&&r!==null)return{label:"Failed",detail:`Request #${r.logNumber} needs attention`,tone:"danger"};if(s>0||o==="length")return{label:"Output limited",detail:"Model stopped at the output token limit",tone:"watch"};switch(o){case"end_turn":case"stop":return{label:"Completed",detail:"Assistant completed normally",tone:"neutral"};case"tool_use":return{label:"Tool requested",detail:"Assistant handed off to a tool",tone:"cool"};case null:return{label:"Unknown",detail:"No terminal signal captured",tone:"neutral"}}}function oC({logs:e,conversationGroups:n,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 P=0;P<e.length;P+=1){const M=e[P];if(M===void 0)continue;const k=P+1,A=Yp(M);A!==null&&(p=A),A==="length"&&(d+=1),JN(M)&&(a+=1,f=k,h={logNumber:k,status:M.responseStatus,error:M.error??null}),M.responseStatus===null&&(i+=1),r>0&&M.elapsedMs!==null&&M.elapsedMs>=S&&(c+=1),M.inputTokens!==null&&(m+=M.inputTokens),M.outputTokens!==null&&(u+=M.outputTokens),M.elapsedMs!==null&&(g===null||M.elapsedMs>g)&&(g=M.elapsedMs,b=k);const D=M.inputTokens??0,$=M.outputTokens??0,J=D+$;J>y&&(y=J,w=D,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",R=tC({stopReason:p,pending:i,lastFailureLogNumber:f}),I=sC({pending:i,failures:a,lengthStops:d,stopReason:p,lastFailure:h});return{status:N,statusLabel:C,modelLabel:YN(e),providerLabel:XN(e),requests:e.length,turns:eC(e,n),failures:a,pending:i,slow:c,lengthStops:d,timeRange:GN(e,o),tokenLabel:`${Ee(m)} in / ${Ee(u)} out`,finishLabel:R.label,finishDetail:R.detail,finishTone:R.tone,outcomeLabel:I.label,outcomeDetail:I.detail,outcomeTone:I.tone,slowestLabel:g===null?"n/a":ZN(g),slowestDetail:b===null?"Latency pending":`Request #${b}`,heaviestDetail:j===null?"Tokens pending":`#${j} ${QN(w,v)}`}}function rC({pinnedSessionId:e,selectedSession:n,sessions:s,logs:o}){if(e!==void 0){const i=o.filter(c=>c.sessionId===e);return i.length===0?null:{label:e,logs:i,showBackLink:!0}}if(n!=="__all__"){const i=o.filter(c=>c.sessionId===n);return i.length===0?null:{label:n,logs:i,showBackLink:!0}}const r=s.length===1?s[0]??null:null;return r!==null&&o.every(c=>c.sessionId===r)?{label:r,logs:[...o],showBackLink:!1}:s.length===0&&o.length>0&&o.every(i=>i.sessionId===null)?{label:"Visible requests",logs:[...o],showBackLink:!1}:null}function aC({logs:e,pagination:n}){if(n.isLoading&&e.length===0)return"Loading logs...";if(e.length===0)return"No logs on this page";const s=e[0],o=e[e.length-1],r=s===void 0||o===void 0?"Current page":`#${s.id}-#${o.id}`;return n.total===null?`Showing ${e.length} logs (${r})`:n.total<=e.length?`Showing all ${n.total} logs`:`Showing ${e.length} of ${n.total} logs (${r})`}function $s({...e}){return t.jsx(Hm,{"data-slot":"select",...e})}function sr({...e}){return t.jsx(Gm,{"data-slot":"select-value",...e})}function Fs({className:e,size:n="default",children:s,...o}){return t.jsxs(Vm,{"data-slot":"select-trigger","data-size":n,className:O("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...o,children:[s,t.jsx(Jm,{asChild:!0,children:t.jsx(Ve,{className:"size-4 opacity-50"})})]})}function Us({className:e,children:n,position:s="popper",align:o="center",...r}){return t.jsx(Xm,{children:t.jsxs(Zm,{"data-slot":"select-content",className:O("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 motion-reduce:data-[state=open]:animate-none motion-reduce:data-[state=closed]:animate-none relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",s==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:s,align:o,...r,children:[t.jsx(iC,{}),t.jsx(sp,{className:O("p-1",s==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:n}),t.jsx(lC,{})]})})}function Xe({className:e,children:n,...s}){return t.jsxs(ip,{"data-slot":"select-item",className:O("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...s,children:[t.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:t.jsx(dp,{children:t.jsx(Oe,{className:"size-4"})})}),t.jsx(lp,{children:n})]})}function iC({className:e,...n}){return t.jsx(up,{"data-slot":"select-scroll-up-button",className:O("flex cursor-default items-center justify-center py-1",e),...n,children:t.jsx(Oi,{className:"size-4"})})}function lC({className:e,...n}){return t.jsx(mp,{"data-slot":"select-scroll-down-button",className:O("flex cursor-default items-center justify-center py-1",e),...n,children:t.jsx(Ve,{className:"size-4"})})}const cC=ue(["critical","warning","notice"]),dC=ue(["open"]),uC=ue(["proxy","tool-schema","run","group"]),ff=ue(["request-failure","request-timeout","slow-response","tool-schema","run-failure","group-failure","group-incomplete"]),mC=ue(["log","session","run","group"]),pC=ue(["anthropic","openai","unknown"]),fC=T({kind:mC,id:x(),label:x(),href:x().nullable()}),hC=T({id:x(),fingerprint:x(),severity:cC,category:ff,source:uC,status:dC,title:x(),message:x(),count:E().int().positive(),firstSeenAt:x(),lastSeenAt:x(),logIds:K(At),sessionIds:K(x()),runIds:K(x()),groupIds:K(x()),provider:x().nullable(),model:x().nullable(),apiFormat:pC.nullable(),evidence:K(fC),metadata:ze(x(),We)}),xC=T({category:ff,count:E().int().nonnegative()}),hf=T({total:E().int().nonnegative(),open:E().int().nonnegative(),critical:E().int().nonnegative(),warning:E().int().nonnegative(),notice:E().int().nonnegative(),byCategory:K(xC)}),gC=T({alerts:K(hC),total:E().int().nonnegative(),limit:E().int().positive(),summary:hf}),bC=8e3,vC=1e4;function yC(e){const n=new URLSearchParams;e.severity!==void 0&&n.set("severity",e.severity),e.category!==void 0&&n.set("category",e.category),e.source!==void 0&&n.set("source",e.source),e.limit!==void 0&&n.set("limit",String(e.limit));const s=n.toString();return s.length>0?`/api/alerts?${s}`:"/api/alerts"}function wC(e,n){const s=Et(n?yC(e):null,o=>De(o,gC,vC));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 jC(){const e=Et("/api/alerts/summary",n=>De(n,hf,bC),{refreshInterval:5e3,revalidateOnFocus:!0});return{summary:e.data??null,isLoading:e.isLoading,error:e.error,mutate:e.mutate}}const eo="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",SC=["request-failure","request-timeout","slow-response","tool-schema","run-failure","group-failure","group-incomplete"];function xf(e){switch(e){case"critical":return"Critical";case"warning":return"Warning";case"notice":return"Notice"}}function NC(e){switch(e){case"proxy":return"Proxy";case"tool-schema":return"Tool schema";case"run":return"Run";case"group":return"Group"}}function Nl(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 CC(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 kC(e){switch(e){case"critical":return"bg-status-danger";case"warning":return"bg-status-watch";case"notice":return"bg-status-cool"}}function _C(e){switch(e){case"critical":return"text-status-danger";case"warning":return"text-status-watch";case"notice":return"text-status-cool"}}function TC(e){switch(e){case"request-failure":case"run-failure":case"group-failure":return t.jsx(o1,{className:"size-3.5"});case"request-timeout":case"slow-response":return t.jsx(C0,{className:"size-3.5"});case"tool-schema":return t.jsx(rn,{className:"size-3.5"});case"group-incomplete":return t.jsx(Gx,{className:"size-3.5"})}}function mi(e){const n=Date.parse(e);return Number.isFinite(n)?new Intl.DateTimeFormat(void 0,{month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(n)):e}function rt(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 EC(e,n){const s={limit:100};return e!=="all"&&(s.severity=e),n!=="all"&&(s.category=n),s}function RC(e,n){if(n!==null){const s=e.find(o=>o.id===n);if(s!==void 0)return s}return e[0]??null}function go({label:e,count:n,tone:s}){const o=s==="critical"?"border-status-danger/30 bg-status-danger/10 text-status-danger":s==="warning"?"border-status-watch/30 bg-status-watch/10 text-status-watch":s==="notice"?"border-status-cool/30 bg-status-cool/10 text-status-cool":"border-border bg-muted/40 text-foreground";return t.jsxs("div",{className:O("rounded-md border px-3 py-2",o),children:[t.jsx("div",{className:"text-[10px] font-semibold uppercase opacity-75",children:e}),t.jsx("div",{className:"mt-1 text-lg font-semibold leading-none",children:rt(n)})]})}function bo({value:e,active:n,label:s,count:o,onClick:r}){return t.jsxs(ee,{type:"button",variant:n?"secondary":"ghost",size:"sm","aria-pressed":n,onClick:()=>r(e),className:"h-7 px-2",children:[s,o!==null?t.jsx(ke,{variant:"outline",children:rt(o)}):null]})}function MC({category:e,active:n,count:s,onClick:o}){return t.jsxs(ee,{type:"button",variant:n?"secondary":"ghost",size:"sm","aria-pressed":n,onClick:()=>o(e),className:"h-7 px-2",children:[TC(e),Nl(e),t.jsx(ke,{variant:"outline",children:rt(s)})]})}function AC({alerts:e,selectedAlertId:n,isLoading:s,error:o,onSelect:r}){return s?t.jsxs("div",{className:"flex min-h-56 items-center justify-center rounded-md border border-dashed border-border text-xs text-muted-foreground",children:[t.jsx(Ae,{className:"mr-2 size-3.5 animate-spin"}),"Loading alerts..."]}):o!==void 0?t.jsx("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-2 text-xs text-status-danger",children:o.message}):e.length===0?t.jsx("div",{className:"flex min-h-56 items-center justify-center rounded-md border border-dashed border-border px-4 text-center text-xs text-muted-foreground",children:"No alerts match the current filters."}):t.jsx("div",{className:"min-h-0 space-y-2 overflow-y-auto pr-1",children:e.map(a=>{const i=a.id===n;return t.jsxs("button",{type:"button",onClick:()=>r(a.id),className:O("w-full rounded-md border px-3 py-3 text-left transition-colors",i?"border-primary/60 bg-primary/12":"border-border bg-background/70 hover:border-primary/30 hover:bg-muted/60"),children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:O("size-2 rounded-full",kC(a.severity))}),t.jsx("span",{className:O("text-xs font-semibold",_C(a.severity)),children:xf(a.severity)}),t.jsx("span",{className:"truncate text-xs text-muted-foreground",children:Nl(a.category)})]}),t.jsx("div",{className:"mt-1 text-sm font-semibold leading-snug",children:a.title}),t.jsx("div",{className:"mt-1 line-clamp-2 text-xs text-muted-foreground",children:a.message})]}),a.count>1?t.jsxs(ke,{variant:"outline",className:"shrink-0",children:["x",rt(a.count)]}):null]}),t.jsxs("div",{className:"mt-2 flex min-w-0 items-start justify-between gap-2 text-[11px] text-muted-foreground",children:[t.jsx("span",{className:"min-w-0 leading-snug",children:gf(a)}),t.jsx("span",{className:"shrink-0",children:mi(a.lastSeenAt)})]})]},a.id)})})}function IC({alert:e,onNavigate:n}){return e.evidence.length===0?t.jsx("span",{className:"text-xs text-muted-foreground",children:"No linked evidence"}):t.jsx("div",{className:"flex flex-wrap gap-2",children:e.evidence.map(s=>s.href===null?t.jsx(ke,{variant:"outline",children:s.label},`${s.kind}:${s.id}`):t.jsx(ke,{variant:"outline",asChild:!0,children:t.jsx("a",{href:s.href,onClick:n,children:s.label})},`${s.kind}:${s.id}`))})}function PC({alert:e,onNavigate:n}){return e===null?t.jsx("div",{className:"flex min-h-56 items-center justify-center rounded-md border border-dashed border-border px-4 text-center text-xs text-muted-foreground",children:"Select an alert to inspect its evidence."}):t.jsxs("div",{className:"min-h-0 overflow-y-auto rounded-md border border-border bg-background/70",children:[t.jsx("div",{className:O("border-b px-4 py-3",CC(e.severity)),children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(ke,{variant:"outline",children:xf(e.severity)}),t.jsx(ke,{variant:"outline",children:NC(e.source)}),t.jsx(ke,{variant:"outline",children:Nl(e.category)})]}),t.jsx("h3",{className:"mt-3 text-base font-semibold",children:e.title}),t.jsx("p",{className:"mt-1 text-sm opacity-85",children:e.message})]}),e.count>1?t.jsxs(ke,{variant:"outline",className:"shrink-0",children:[rt(e.count)," hits"]}):null]})}),t.jsxs("div",{className:"space-y-4 p-4",children:[t.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[t.jsx(Yt,{label:"Target",value:gf(e)}),t.jsx(Yt,{label:"Last seen",value:mi(e.lastSeenAt)}),t.jsx(Yt,{label:"First seen",value:mi(e.firstSeenAt)}),t.jsx(Yt,{label:"Protocol",value:e.apiFormat??"n/a"})]}),t.jsxs("div",{children:[t.jsx("div",{className:"mb-2 text-xs font-semibold text-muted-foreground",children:"Evidence"}),t.jsx(IC,{alert:e,onNavigate:n})]}),t.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[t.jsx(Yt,{label:"Logs",value:e.logIds.length===0?"n/a":rt(e.logIds.length)}),t.jsx(Yt,{label:"Sessions",value:e.sessionIds.length===0?"n/a":rt(e.sessionIds.length)}),t.jsx(Yt,{label:"Runs",value:e.runIds.length===0?"n/a":rt(e.runIds.length)}),t.jsx(Yt,{label:"Groups",value:e.groupIds.length===0?"n/a":rt(e.groupIds.length)})]})]})]})}function Yt({label:e,value:n}){return t.jsxs("div",{className:"rounded-md border border-border bg-muted/30 px-3 py-2",children:[t.jsx("div",{className:"text-[10px] font-semibold uppercase text-muted-foreground",children:e}),t.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-foreground",children:n})]})}function LC(){const[e,n]=l.useState(!1),[s,o]=l.useState("all"),[r,a]=l.useState("all"),[i,c]=l.useState(null),{summary:d,isLoading:m}=jC(),u=l.useMemo(()=>EC(s,r),[r,s]),{alerts:p,total:f,isLoading:h,error:g,mutate:b}=wC(u,e),y=l.useMemo(()=>RC(p,i),[p,i]);l.useEffect(()=>{!e||i!==null&&p.some(R=>R.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 t.jsxs(Pt,{open:e,onOpenChange:n,children:[t.jsx(Xs,{asChild:!0,children:t.jsxs(ee,{type:"button",variant:"ghost",size:"icon",className:eo,"aria-label":"Alerts",title:"Alerts",children:[t.jsx(Ho,{className:"size-4"}),m?t.jsx(Ae,{className:"absolute -right-0.5 -top-0.5 size-3 animate-spin text-muted-foreground"}):w>0?t.jsx("span",{className:O("absolute -right-1 -top-1 min-w-4 rounded-full px-1 text-[10px] font-semibold leading-4",N),children:rt(w)}):null,t.jsx("span",{className:"sr-only",children:"Alerts"})]})}),t.jsxs(Lt,{className:"flex max-h-[86vh] max-w-6xl flex-col overflow-hidden",children:[t.jsxs(Ft,{children:[t.jsxs(Ut,{className:"flex items-center gap-2 pr-8",children:[t.jsx(Ho,{className:"size-5 text-status-danger"}),t.jsx("span",{children:"Alerts"}),t.jsx(ke,{variant:"outline",children:rt(w)})]}),t.jsx(Zs,{className:"sr-only",children:"Local alert board for captured Inspector evidence."})]}),t.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[t.jsx(go,{label:"Open",count:d?.open??0,tone:"neutral"}),t.jsx(go,{label:"Critical",count:v,tone:"critical"}),t.jsx(go,{label:"Warning",count:j,tone:"warning"}),t.jsx(go,{label:"Notice",count:S,tone:"notice"})]}),t.jsxs("div",{className:"flex min-h-0 flex-wrap items-center justify-between gap-2 border-y border-border py-3",children:[t.jsxs("div",{className:"flex flex-wrap gap-1",children:[t.jsx(bo,{value:"all",active:s==="all",label:"All",count:d?.total??null,onClick:o}),t.jsx(bo,{value:"critical",active:s==="critical",label:"Critical",count:v,onClick:o}),t.jsx(bo,{value:"warning",active:s==="warning",label:"Warning",count:j,onClick:o}),t.jsx(bo,{value:"notice",active:s==="notice",label:"Notice",count:S,onClick:o})]}),t.jsxs(ee,{type:"button",variant:"outline",size:"sm",className:"h-7 shrink-0 px-2",onClick:()=>{b()},children:[t.jsx(yt,{className:"size-3.5"}),"Refresh"]})]}),t.jsxs("div",{className:"flex flex-wrap gap-1",children:[t.jsx(ee,{type:"button",variant:r==="all"?"secondary":"ghost",size:"sm","aria-pressed":r==="all",onClick:()=>a("all"),className:"h-7 px-2",children:"All categories"}),SC.map(C=>{const R=d?.byCategory.find(I=>I.category===C)?.count??0;return R===0?null:t.jsx(MC,{category:C,active:r===C,count:R,onClick:a},C)})]}),t.jsxs("div",{className:"grid min-h-0 flex-1 gap-4 md:grid-cols-[360px_minmax(0,1fr)]",children:[t.jsxs("div",{className:"flex min-h-0 flex-col",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between text-xs text-muted-foreground",children:[t.jsxs("span",{children:[rt(f)," matched"]}),t.jsx("span",{children:p.length<f?`${rt(p.length)} shown`:"Latest"})]}),t.jsx(AC,{alerts:p,selectedAlertId:y?.id??null,isLoading:h,error:g,onSelect:c})]}),t.jsx(PC,{alert:y,onNavigate:()=>n(!1)})]})]})]})}const OC=12e3;function DC(e){return e===null||e.evidence===null?null:`/api/groups/${encodeURIComponent(e.id)}/evidence`}function zC(e){const n=Et(DC(e),s=>De(s,jx,OC));return{evidenceResponse:n.data??null,isLoading:n.isLoading,error:n.error,mutate:n.mutate}}const $C=8e3;function FC(){const e=Et("/api/groups",n=>De(n,Zd,$C));return{groups:e.data?.groups??[],isLoading:e.isLoading,error:e.error,mutate:e.mutate}}const UC=3e3;function BC(e,n){return{id:(e?.id??0)+1,message:n.message,tone:n.tone??"error"}}function bf(){const[e,n]=l.useState(null),s=l.useCallback(r=>{n(a=>BC(a,r))},[]),o=l.useCallback(()=>{n(null)},[]);return l.useEffect(()=>{if(e===null)return;const r=window.setTimeout(()=>{n(null)},UC);return()=>{window.clearTimeout(r)}},[e]),{notice:e,showToast:s,dismissToast:o}}function vf({notice:e,onDismiss:n}){if(e===null)return null;const s=e.tone==="error",o=s?rn:$a;return t.jsx("div",{"aria-atomic":"true","aria-live":"polite",className:"pointer-events-none fixed top-4 right-4 z-[100] w-[min(calc(100vw-2rem),26rem)]",role:"status",children:t.jsxs("div",{className:O("pointer-events-auto flex items-start gap-2 rounded-md border bg-popover/95 px-3 py-2 text-sm text-popover-foreground shadow-[0_18px_50px_color-mix(in_oklch,var(--foreground)_16%,transparent)] backdrop-blur",s?"border-status-danger/35":"border-status-success/35"),children:[t.jsx(o,{className:O("mt-0.5 size-4 shrink-0",s?"text-status-danger":"text-status-success")}),t.jsx("div",{className:"min-w-0 flex-1 break-words leading-5",children:e.message}),t.jsx("button",{type:"button",className:"inline-flex size-6 shrink-0 items-center justify-center rounded-md text-current/70 transition-colors hover:bg-white/10 hover:text-current focus-visible:ring-1 focus-visible:ring-current focus-visible:outline-none","aria-label":"Dismiss notification",onClick:n,children:t.jsx(Ks,{className:"size-3.5"})})]},e.id)})}const ba=2e4;function qC(e,n){const s=`/api/groups/${encodeURIComponent(e)}`;return n?`${s}?deleteEvidence=1`:s}function HC(e){return"/api/groups"}function yf(e){let n=0,s=0,o=0,r=0;for(const a of e.members)switch(a.status){case"completed":n+=1;break;case"failed":case"cancelled":s+=1;break;case"running":o+=1;break;case"created":break;case null:r+=1;break}return{memberCount:e.members.length,completedMembers:n,failedMembers:s,runningMembers:o,missingStatusMembers:r}}function WC(e,n,s=null){return n!==null&&n.group.id===e.id?n.members.map(o=>({member:o.member,exportMember:o,source:"export"})):s!==null&&s.group.id===e.id&&s.members!==null?s.members.map(o=>({member:o.member,exportMember:o,source:"evidence"})):e.members.map(o=>({member:o,exportMember:null,source:"group"}))}function Cl(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 kl(e){return e??"unknown"}function VC(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 $r(e){return e===null||e.trim().length===0?"-":e}function ot(e){return e.toLocaleString()}function pi(e){return e==null?"-":e<1e3?`${ot(e)} ms`:`${(e/1e3).toFixed(1)} s`}function us(e){const n=Date.parse(e);return Number.isFinite(n)?new Intl.DateTimeFormat(void 0,{month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(n)):e}function Ac(e){return e===null?"-":us(e)}function KC(e){const n=JSON.stringify(e),s=n===void 0?String(e):n;return s.length<=160?s:`${s.slice(0,157)}...`}function wf(...e){for(const n of e)if(n!==null&&n.trim().length>0)return n;return"-"}function GC(...e){for(const n of e)if(n!=null&&n.trim().length>0)return n;return null}function JC(e){const n=e.provider,s=e.model;return n!==null&&n.length>0&&s!==null&&s.length>0?`${n} / ${s}`:wf(n,s)}function YC(e,n){if(n!==null){const s=e.find(o=>o.id===n);if(s!==void 0)return s}return e[0]??null}function XC(e){return(e.exportMember?.session?.latestLogs??[])[0]??null}function ZC(e){switch(e){case"export":return"fresh export";case"evidence":return"evidence";case"group":return"group"}}function QC(e,n){return n!==null&&n.group.id===e.id?n.evidence:e.evidence}function ek(e,n,s){return n!==null&&n.group.id===e.id?n.summary:s!==null&&s.group.id===e.id?s.summary:null}function tk(e,n,s){return n!==null&&n.group.id===e.id?n.jenkinsReport:s!==null&&s.group.id===e.id?s.report:null}function nk({labelledTrigger:e=!1}){const[n,s]=l.useState(!1),[o,r]=l.useState(null),[a,i]=l.useState(null),[c,d]=l.useState(null),[m,u]=l.useState(null),[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:R}=bf(),{groups:I,isLoading:P,error:M,mutate:k}=FC(),A=l.useMemo(()=>YC(I,o),[I,o]);l.useEffect(()=>{!n||o!==null&&I.some(se=>se.id===o)||r(I[0]?.id??null)},[I,n,o]);const D=A!==null&&m!==null&&m.group.id===A.id?m:null,{evidenceResponse:$,isLoading:J,error:X,mutate:F}=zC(A),H=l.useCallback(()=>{k()},[k]),Y=l.useCallback(async()=>{if(!(I.length===0||j)){S(!0),f(null),g(!1),v(null),d(null);try{const z=await De(HC(!1),Jd,ba,{method:"DELETE"},se=>`Clear failed with status ${String(se.status)}`);u(null),r(null),await k(),await F(),C({message:`Cleared ${ot(z.deleted)} group${z.deleted===1?"":"s"}.`,tone:"success"})}catch(z){C({message:z instanceof Error?z.message:"Unknown error clearing groups",tone:"error"})}finally{S(!1)}}},[j,I.length,k,F,C]),U=l.useCallback(async z=>{i(z.id),d(null);try{const se=await De(`/api/groups/${encodeURIComponent(z.id)}/evidence`,Sx,ba,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({latestLogLimit:10})},te=>`Export failed with status ${String(te.status)}`);u(se),await k(),await F()}catch(se){d(se instanceof Error?se.message:String(se))}finally{i(null)}},[k,F]),W=l.useCallback(z=>{f(z),g(!1),v(null)},[]),me=l.useCallback(()=>{b===null&&(f(null),g(!1),v(null))},[b]),be=l.useCallback(z=>{r(z),f(null),g(!1),v(null)},[]),ve=l.useCallback(async()=>{const z=p;if(z!==null){y(z.id),v(null);try{await De(qC(z.id,h),Gd,ba,{method:"DELETE"},se=>`Delete failed with status ${String(se.status)}`),u(se=>se!==null&&se.group.id===z.id?null:se),r(se=>se===z.id?null:se),f(null),g(!1),await k(),await F()}catch(se){v(se instanceof Error?se.message:String(se))}finally{y(null)}}},[h,p,k,F]);return t.jsxs(Pt,{open:n,onOpenChange:s,children:[t.jsx(vf,{notice:N,onDismiss:R}),t.jsx(Xs,{asChild:!0,children:t.jsxs(ee,{type:"button",variant:"ghost",size:e?"default":"icon",className:O(eo,e&&"w-auto gap-2 px-3 text-xs max-lg:h-11 max-lg:w-auto"),"aria-label":"Evaluation groups",title:"Evaluation groups",children:[t.jsx(Fl,{className:"size-4"}),P?t.jsx(Ae,{className:"absolute -right-0.5 -top-0.5 size-3 animate-spin text-muted-foreground"}):I.length>0?t.jsx("span",{className:"absolute -right-1 -top-1 min-w-4 rounded-full bg-primary px-1 text-[10px] leading-4 text-primary-foreground",children:I.length}):null,t.jsx("span",{className:e?"":"sr-only",children:"Groups"})]})}),t.jsxs(Lt,{className:"flex max-h-[85vh] max-w-5xl flex-col overflow-hidden",children:[t.jsx(Ft,{children:t.jsxs(Ut,{className:"flex items-center gap-2 pr-8",children:[t.jsx(Fl,{className:"size-5 text-muted-foreground"}),t.jsx("span",{children:"Groups"}),t.jsx(ke,{variant:"outline",children:ot(I.length)})]})}),t.jsxs("div",{className:"flex min-h-0 items-center justify-between gap-3 border-b border-border pb-3",children:[t.jsx("p",{className:"text-xs text-muted-foreground",children:"Evaluation batches, model runs, and exported evidence packs."}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsxs(ee,{type:"button",variant:"outline",size:"sm",disabled:I.length===0||j,onClick:()=>{Y()},title:"Clear all groups. Session logs and run records stay intact.",children:[j?t.jsx(Ae,{className:"size-3.5 animate-spin"}):t.jsx(an,{className:"size-3.5"}),"Clear"]}),t.jsxs(ee,{type:"button",variant:"outline",size:"sm",onClick:H,children:[t.jsx(yt,{className:"size-3.5"}),"Refresh"]})]})]}),t.jsxs("div",{className:"grid min-h-0 flex-1 gap-4 md:grid-cols-[260px_minmax(0,1fr)]",children:[t.jsx(sk,{groups:I,selectedGroupId:A?.id??null,isLoading:P,error:M,onSelect:be}),t.jsx(ok,{group:A,deleteTarget:p,deleteEvidence:h,exportResult:D,evidenceResponse:$,evidenceLoading:J,evidenceError:X,exportError:c,deleteError:w,exportingGroupId:a,deletingGroupId:b,onDeleteEvidenceChange:g,onExport:U,onRequestDelete:W,onCancelDelete:me,onConfirmDelete:()=>{ve()}})]})]})]})}function sk({groups:e,selectedGroupId:n,isLoading:s,error:o,onSelect:r}){return s?t.jsx("div",{className:"flex min-h-48 items-center justify-center rounded-md border border-dashed border-border text-xs text-muted-foreground",children:"Loading groups..."}):o!==void 0?t.jsx("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-2 text-xs text-status-danger",children:o.message}):e.length===0?t.jsx("div",{className:"rounded-md border border-dashed border-border px-3 py-8 text-center text-xs text-muted-foreground",children:"No groups yet."}):t.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:t.jsx("div",{className:"space-y-2",children:e.map(a=>{const i=yf(a),c=n===a.id;return t.jsxs("button",{type:"button",onClick:()=>r(a.id),className:O("w-full rounded-md border px-3 py-2 text-left text-xs transition-colors",c?"border-primary bg-primary/5":"border-border bg-background hover:bg-muted/50"),children:[t.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[t.jsx("span",{className:"min-w-0 text-sm font-medium leading-snug",children:a.title}),t.jsx(ke,{variant:"outline",className:Cl(a.status),children:kl(a.status)})]}),t.jsxs("div",{className:"mt-1 flex items-center gap-2 text-muted-foreground",children:[t.jsxs("span",{children:[i.memberCount," sessions"]}),t.jsx("span",{children:us(a.updatedAt)})]})]},a.id)})})})}function ok({group:e,deleteTarget:n,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 t.jsx("div",{className:"flex min-h-48 items-center justify-center rounded-md border border-dashed border-border text-xs text-muted-foreground",children:"Select a group to inspect."});const y=yf(e),w=ek(e,o,r),v=tk(e,o,r),j=QC(e,o),S=WC(e,o,r),N=m===e.id,C=u===e.id,R=n?.id===e.id;return t.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex min-w-0 flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[t.jsxs("div",{className:"min-w-0 space-y-1",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[t.jsx("h3",{className:"min-w-0 text-base font-semibold leading-snug",children:e.title}),t.jsx(ke,{variant:"outline",className:Cl(e.status),children:kl(e.status)}),t.jsx(ke,{variant:"outline",children:e.kind})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[t.jsx("span",{children:$r(e.project)}),t.jsxs("span",{children:["updated ",us(e.updatedAt)]})]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(ee,{type:"button",variant:"outline",size:"icon",className:"size-8 text-status-danger hover:text-status-danger/80","aria-label":"Delete group",title:"Delete group",disabled:C,onClick:()=>h(e),children:C?t.jsx(Ae,{className:"size-3.5 animate-spin"}):t.jsx(an,{className:"size-3.5"})}),t.jsxs(ee,{type:"button",variant:"default",size:"sm",className:"shrink-0",disabled:N||C,onClick:()=>{f(e)},children:[N?t.jsx(Ae,{className:"size-3.5 animate-spin"}):t.jsx(Ws,{className:"size-3.5"}),"Export evidence"]})]})]}),e.task!==null&&e.task.trim().length>0&&t.jsx("p",{className:"rounded-md border border-border bg-muted/20 px-3 py-2 text-xs text-muted-foreground",children:e.task}),R&&t.jsx(rk,{group:e,deleteEvidence:s,isDeleting:C,error:d,onDeleteEvidenceChange:p,onCancel:g,onConfirm:b}),t.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[t.jsx(Xt,{label:"Members",value:y.memberCount}),t.jsx(Xt,{label:"Done",value:y.completedMembers}),t.jsx(Xt,{label:"Failed",value:y.failedMembers}),t.jsx(Xt,{label:"Running",value:y.runningMembers})]}),w!==null&&t.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[t.jsx(Xt,{label:"Requests",value:w.requestCount}),t.jsx(Xt,{label:"Errors",value:w.errorCount}),t.jsx(Xt,{label:"Tokens",value:w.tokenUsage.total}),t.jsx(Xt,{label:"Missing",value:w.missingSessions})]}),t.jsx(ak,{report:v,loading:a,error:i,hasEvidence:j!==null}),t.jsx(ik,{evidence:j}),c!==null&&t.jsx("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-2 text-xs text-status-danger",children:c}),d!==null&&!R&&t.jsx("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-2 text-xs text-status-danger",children:d}),t.jsx(lk,{rows:S})]})})}function rk({group:e,deleteEvidence:n,isDeleting:s,error:o,onDeleteEvidenceChange:r,onCancel:a,onConfirm:i}){const c=e.evidence!==null,d=e.evidence?.markdownPath??"No evidence pack exported.";return t.jsx("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-3 text-status-danger",children:t.jsxs("div",{className:"flex min-w-0 flex-col gap-3 lg:flex-row lg:items-start lg:justify-between",children:[t.jsxs("div",{className:"min-w-0 space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[t.jsx(an,{className:"size-4 text-status-danger"}),t.jsx("span",{children:"Delete group?"})]}),t.jsxs("p",{className:"text-xs text-status-danger",children:["Delete ",t.jsx("span",{className:"font-medium",children:e.title}),". Session logs and run records stay intact."]}),t.jsxs("label",{className:O("flex min-w-0 items-start gap-2 text-xs",c?"cursor-pointer":"opacity-60"),children:[t.jsx("input",{type:"checkbox",className:"mt-0.5 size-4 shrink-0",checked:n,disabled:!c||s,onChange:m=>r(m.currentTarget.checked)}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block font-medium",children:"Also delete exported evidence files"}),t.jsx("code",{className:"mt-1 block truncate font-mono text-[11px] text-status-danger",children:d})]})]}),o!==null&&t.jsx("div",{className:"rounded-md border border-status-danger/30 bg-card px-2 py-1.5 text-xs text-status-danger",children:o})]}),t.jsxs("div",{className:"flex shrink-0 justify-end gap-2",children:[t.jsx(ee,{type:"button",variant:"outline",size:"sm",disabled:s,onClick:a,children:"Cancel"}),t.jsxs(ee,{type:"button",variant:"destructive",size:"sm",disabled:s,onClick:i,children:[s?t.jsx(Ae,{className:"size-3.5 animate-spin"}):t.jsx(an,{className:"size-3.5"}),"Delete"]})]})]})})}function Xt({label:e,value:n}){return t.jsxs("div",{className:"rounded-md border border-border bg-muted/20 px-3 py-2",children:[t.jsx("div",{className:"text-[11px] font-medium uppercase text-muted-foreground",children:e}),t.jsx("div",{className:"mt-1 font-mono text-sm font-semibold",children:ot(n)})]})}function ak({report:e,loading:n,error:s,hasEvidence:o}){const{copied:r,copy:a}=sn(e?.markdown??null);return e===null&&!n&&s===void 0?null:n?t.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-muted/20 px-3 py-2 text-xs text-muted-foreground",children:[t.jsx(Ae,{className:"size-3.5 animate-spin"}),"Loading evidence report..."]}):s!==void 0&&o?t.jsxs("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-2 text-xs text-status-danger",children:["Failed to load evidence report: ",s.message]}):e===null?null:t.jsxs("div",{className:"rounded-md border border-border bg-muted/20 px-3 py-2",children:[t.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"text-xs font-semibold",children:"Evidence report"}),t.jsx(ke,{variant:"outline",className:VC(e.status),children:e.status})]}),t.jsx(ee,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0","aria-label":r?"Copied evidence report":"Copy evidence report",onClick:a,children:r?t.jsx(Oe,{className:"size-3.5 text-status-success"}):t.jsx(St,{className:"size-3.5"})})]}),t.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:e.summary})]})}function ik({evidence:e}){return e===null?t.jsx("div",{className:"rounded-md border border-dashed border-border px-3 py-2 text-xs text-muted-foreground",children:"No evidence pack exported yet."}):t.jsxs("div",{className:"space-y-2 rounded-md border border-border bg-muted/20 px-3 py-2",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-xs font-semibold",children:"Evidence paths"}),t.jsx("span",{className:"text-[11px] text-muted-foreground",children:us(e.exportedAt)})]}),t.jsxs("div",{className:"grid gap-2",children:[t.jsx(va,{label:"JSON",value:e.jsonPath}),t.jsx(va,{label:"Markdown",value:e.markdownPath}),t.jsx(va,{label:"HTML",value:e.htmlPath})]})]})}function va({label:e,value:n}){const{copied:s,copy:o}=sn(n);return t.jsxs("div",{className:"flex min-w-0 items-center gap-2 rounded-md border border-border bg-background px-2 py-1.5",children:[t.jsx("span",{className:"w-16 shrink-0 text-[11px] font-medium text-muted-foreground",children:e}),t.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs",children:n}),t.jsx(ee,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0","aria-label":s?`Copied ${e} path`:`Copy ${e} path`,onClick:o,children:s?t.jsx(Oe,{className:"size-3.5 text-status-success"}):t.jsx(St,{className:"size-3.5"})})]})}function lk({rows:e}){const[n,s]=l.useState(null),o=l.useCallback(r=>{s(a=>a===r?null:r)},[]);return e.length===0?t.jsx("div",{className:"rounded-md border border-dashed border-border px-3 py-8 text-center text-xs text-muted-foreground",children:"No sessions attached."}):t.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[t.jsx("div",{className:"border-b border-border bg-muted/30 px-3 py-2 text-xs font-semibold",children:"Members"}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full min-w-[760px] text-left text-xs",children:[t.jsx("thead",{className:"border-b border-border bg-muted/20 text-muted-foreground",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-3 py-2 font-medium",children:"Session"}),t.jsx("th",{className:"px-3 py-2 font-medium",children:"Provider / Model"}),t.jsx("th",{className:"px-3 py-2 font-medium",children:"Status"}),t.jsx("th",{className:"px-3 py-2 font-medium",children:"Requests"}),t.jsx("th",{className:"px-3 py-2 font-medium",children:"Errors"}),t.jsx("th",{className:"px-3 py-2 font-medium",children:"First chunk"}),t.jsx("th",{className:"px-3 py-2 font-medium",children:"Tokens"})]})}),t.jsx("tbody",{children:e.map(r=>{const a=n===r.member.id;return t.jsxs(l.Fragment,{children:[t.jsx(ck,{row:r,isExpanded:a,onToggleDetails:o}),t.jsx(dk,{row:r,isExpanded:a})]},r.member.id)})})]})})]})}function ck({row:e,isExpanded:n,onToggleDetails:s}){const o=e.member,r=e.exportMember?.session??null,a=XC(e),i=r?.inspectorPath??Ad(o.sessionId),c=e.source!=="evidence",d=r?.requestCount??null,m=r?.errorCount??null,u=r?.tokenUsage.total??null,p=a?.firstChunkMs??null,f=wf(o.label,o.sessionId),h=GC(r?.clientUserAgent,a?.userAgent,o.agent),g=r?.clientProjectFolder??null,b=hl({userAgent:h,conversationId:o.sessionId,clientProjectFolder:g}),y=Or(b);return t.jsxs("tr",{className:"border-b border-border last:border-0 hover:bg-muted/20",children:[t.jsxs("td",{className:"max-w-56 px-3 py-2",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx(ee,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0 text-muted-foreground","aria-label":n?`Hide member ${f}`:`Show member ${f}`,title:n?"Hide member details":"Show member details",onClick:()=>{s(o.id)},children:n?t.jsx(Ve,{className:"size-3.5"}):t.jsx(it,{className:"size-3.5"})}),y!==null&&t.jsx(Dr,{client:b,className:"size-5"}),c?t.jsxs("a",{href:i,target:"_blank",rel:"noreferrer",className:"inline-flex max-w-full min-w-0 items-center gap-2 rounded-sm font-mono text-xs text-primary outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","aria-label":`Open session ${f}`,title:`Open session ${f}`,children:[t.jsx("span",{className:"min-w-0 truncate",children:f}),t.jsx(Di,{className:"size-3 shrink-0 text-muted-foreground"})]}):t.jsxs("button",{type:"button",className:"inline-flex max-w-full min-w-0 items-center gap-2 rounded-sm font-mono text-xs text-foreground outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",title:`Show evidence snapshot for ${f}`,"aria-label":`Show evidence snapshot for ${f}`,onClick:()=>{s(o.id)},children:[t.jsx("span",{className:"min-w-0 truncate",children:f}),t.jsx(ke,{variant:"outline",className:"shrink-0 border-border bg-muted/30 text-muted-foreground",children:"evidence"})]})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:$r(o.agent)})]}),t.jsx("td",{className:"max-w-52 px-3 py-2",children:t.jsx("span",{className:"block whitespace-normal leading-snug",children:JC(o)})}),t.jsx("td",{className:"px-3 py-2",children:t.jsx(ke,{variant:"outline",className:Cl(o.status),children:kl(o.status)})}),t.jsx("td",{className:"px-3 py-2 font-mono",children:d===null?"-":ot(d)}),t.jsx("td",{className:"px-3 py-2 font-mono",children:m===null?"-":ot(m)}),t.jsx("td",{className:"px-3 py-2 font-mono",children:pi(p)}),t.jsx("td",{className:"px-3 py-2 font-mono",children:u===null?"-":ot(u)})]})}function dk({row:e,isExpanded:n}){if(!n)return null;const s=e.member,o=e.exportMember,r=o?.session??null,a=o?.run??null,i=Object.entries(s.metadata);return t.jsx("tr",{className:"border-b border-border bg-muted/10",children:t.jsx("td",{colSpan:7,className:"px-3 pb-4 pt-2",children:t.jsxs("div",{className:"space-y-3 rounded-md border border-border bg-background p-3",children:[t.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4",children:[t.jsx(Ke,{label:"Source",value:ZC(e.source)}),t.jsx(Ke,{label:"Member ID",value:s.id,mono:!0}),t.jsx(Ke,{label:"Session ID",value:s.sessionId,mono:!0}),t.jsx(Ke,{label:"Run ID",value:a?.id??s.runId??"-",mono:!0}),t.jsx(Ke,{label:"Created",value:us(s.addedAt)}),t.jsx(Ke,{label:"Updated",value:us(s.updatedAt)}),t.jsx(Ke,{label:"Session created",value:Ac(r?.createdAt??null)}),t.jsx(Ke,{label:"Session updated",value:Ac(r?.updatedAt??null)})]}),r===null?t.jsx("div",{className:"rounded-md border border-dashed border-border px-3 py-2 text-xs text-muted-foreground",children:"No session snapshot is available for this member."}):t.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4",children:[t.jsx(Ke,{label:"Log coverage",value:r.logCoverage}),t.jsx(Ke,{label:"Runtime",value:$r(r.runtimeMode)}),t.jsx(Ke,{label:"Requests",value:ot(r.requestCount),mono:!0}),t.jsx(Ke,{label:"Errors",value:ot(r.errorCount),mono:!0}),t.jsx(Ke,{label:"Input tokens",value:ot(r.tokenUsage.input),mono:!0}),t.jsx(Ke,{label:"Output tokens",value:ot(r.tokenUsage.output),mono:!0}),t.jsx(Ke,{label:"Cache read",value:ot(r.tokenUsage.cacheRead),mono:!0}),t.jsx(Ke,{label:"Total tokens",value:ot(r.tokenUsage.total),mono:!0})]}),t.jsx(uk,{logs:r?.latestLogs??[]}),t.jsx(mk,{entries:i})]})})})}function Ke({label:e,value:n,mono:s=!1}){return t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:e}),t.jsx("div",{className:O("truncate text-xs text-foreground",s?"font-mono":""),title:n,children:n})]})}function uk({logs:e}){const n=e.slice(0,5);return n.length===0?t.jsx("div",{className:"rounded-md border border-dashed border-border px-3 py-2 text-xs text-muted-foreground",children:"No latest logs in this snapshot."}):t.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[t.jsx("div",{className:"border-b border-border bg-muted/30 px-3 py-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Latest logs"}),t.jsx("div",{className:"divide-y divide-border",children:n.map(s=>{const o=s.sessionLogNumber??s.id;return t.jsxs("div",{className:"grid gap-2 px-3 py-2 text-xs sm:grid-cols-[72px_1fr_88px_88px]",children:[t.jsxs("span",{className:"font-mono text-muted-foreground",title:`Log ID ${String(s.id)}`,children:["#",o]}),t.jsxs("span",{className:"min-w-0 truncate",children:[$r(s.model)," · ",s.apiFormat," · ",s.path]}),t.jsx("span",{className:"font-mono text-muted-foreground",children:pi(s.firstChunkMs)}),t.jsx("span",{className:"font-mono text-muted-foreground",children:pi(s.latencyMs)})]},s.id)})})]})}function mk({entries:e}){return e.length===0?null:t.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[t.jsx("div",{className:"border-b border-border bg-muted/30 px-3 py-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Metadata"}),t.jsx("div",{className:"grid gap-x-3 gap-y-2 p-3 text-xs sm:grid-cols-2",children:e.map(([n,s])=>{const o=KC(s);return t.jsxs("div",{className:"min-w-0",children:[t.jsx("span",{className:"mr-2 text-muted-foreground",children:n}),t.jsx("span",{className:"font-mono text-foreground",title:o,children:o})]},n)})})]})}const pk=T({selectionId:x().uuid(),name:x(),apiKeyHint:x(),format:ue(["anthropic","openai"]),anthropicBaseUrl:x(),openaiBaseUrl:x(),openaiResponsesBaseUrl:x().optional().default(""),models:K(x()),sourceTool:ue(["claude-code","opencode","mimo-code"]),alreadyExists:_e()}),fk=T({scanId:x().uuid(),providers:K(pk),warnings:K(x()).optional()});T({scanId:x().uuid(),selectionIds:K(x().uuid()).min(1).max(100)});const hk=T({success:_e().optional(),imported:E().optional(),message:x().optional(),errors:K(x()).optional()}),Ic=2e4;function xk({open:e,onOpenChange:n,onImportComplete:s}){const[o,r]=l.useState(!1),[a,i]=l.useState(null),[c,d]=l.useState(null),[m,u]=l.useState([]),[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),R=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),De("/api/providers/scan",fk,Ic,{method:"POST"},A=>`Scan failed (${String(A.status)})`).then(A=>{if(N.current!==k)return;d(A.scanId),u(A.providers),f(A.warnings??[]);const D=new Set;A.providers.forEach(($,J)=>{$.alreadyExists||D.add(J)}),g(D)}).catch(A=>{N.current===k&&i(A instanceof Error?A.message:String(A))}).finally(()=>{N.current===k&&r(!1)})},[]);l.useEffect(()=>{e&&R()},[e,R]),l.useEffect(()=>{e||(N.current+=1,C.current+=1,r(!1),y(!1))},[e]);const I=l.useCallback(k=>{g(A=>{const D=new Set(A);return D.has(k)?D.delete(k):D.add(k),D})},[]),P=l.useCallback(()=>{const k=m.filter((D,$)=>h.has($));if(k.length===0||c===null)return;const A=C.current+1;C.current=A,y(!0),S(null),v(null),De("/api/providers/import",hk,Ic,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scanId:c,selectionIds:k.map(D=>D.selectionId)})},D=>`Import failed (${String(D.status)})`).then(D=>{C.current===A&&(u($=>$.map((J,X)=>h.has(X)?{...J,alreadyExists:!0}:J)),g(new Set),D.errors!==void 0&&D.errors.length>0&&D.message!==void 0?v(D.message):v(`Imported ${D.imported??k.length} provider(s)`),s())}).catch(D=>{C.current===A&&S(D instanceof Error?D.message:String(D))}).finally(()=>{C.current===A&&y(!1)})},[m,c,h,s]),M=m.some(k=>!k.alreadyExists);return t.jsx(Pt,{open:e,onOpenChange:n,children:t.jsxs(Lt,{className:"max-w-xl max-h-[80vh] overflow-hidden flex flex-col",children:[t.jsxs(Ft,{children:[t.jsx(Ut,{children:"Import from External Tools"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Detect provider configurations from Claude Code, OpenCode, and MiMo Code."})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto space-y-3",children:[o&&t.jsxs("div",{className:"flex items-center justify-center py-8 gap-2 text-muted-foreground",children:[t.jsx(Ae,{className:"size-4 animate-spin"}),t.jsx("span",{className:"text-sm",children:"Scanning for external providers..."})]}),a!==null&&t.jsxs("div",{className:"flex items-center gap-2 text-destructive text-sm py-4",children:[t.jsx(os,{className:"size-4"}),a]}),!o&&a===null&&m.length===0&&t.jsxs("p",{className:"text-sm text-muted-foreground py-8 text-center",children:["No external provider configurations found.",t.jsx("br",{}),t.jsx("span",{className:"text-xs",children:"Supported tools: Claude Code (~/.claude/settings.json), OpenCode (~/.config/opencode/opencode.json), MiMo Code (~/.config/mimocode/mimocode.jsonc)"})]}),!o&&m.map((k,A)=>t.jsxs("label",{className:`flex items-start gap-3 p-3 border rounded-md ${k.alreadyExists?"":"cursor-pointer hover:bg-muted/50"}`,children:[!k.alreadyExists&&t.jsx("input",{type:"checkbox",checked:h.has(A),disabled:b,onChange:()=>I(A),className:"mt-0.5 size-4"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(Dr,{client:k.sourceTool,className:"size-7 rounded-[8px]"}),k.alreadyExists&&t.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Already added"})]}),t.jsxs("div",{className:"mt-1 text-xs leading-snug text-muted-foreground",children:[k.models.slice(0,4).join(", "),k.models.length>4?` +${k.models.length-4} more`:""]}),t.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:k.format==="anthropic"?k.anthropicBaseUrl:k.openaiResponsesBaseUrl!==""?k.openaiResponsesBaseUrl:k.openaiBaseUrl}),t.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 font-mono",children:k.apiKeyHint})]})]},k.selectionId)),p.length>0&&t.jsx("div",{className:"text-xs text-muted-foreground space-y-1 border-t pt-2",children:p.map((k,A)=>t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(os,{className:"size-3"}),k]},A))}),w!==null&&t.jsx("div",{className:"border-t pt-2 text-sm text-status-success",children:w}),j!==null&&t.jsx("div",{className:"text-sm text-destructive border-t pt-2",children:j})]}),t.jsxs("div",{className:"flex items-center justify-between pt-3 border-t",children:[t.jsxs(ee,{variant:"outline",size:"sm",onClick:R,disabled:o,children:[t.jsx(Ae,{className:`size-3 mr-1 ${o?"animate-spin":""}`}),"Rescan"]}),t.jsxs(ee,{size:"sm",onClick:P,disabled:!M||h.size===0||b,children:[t.jsx(Ws,{className:"size-3 mr-1"}),b?"Importing...":`Import Selected (${h.size})`]})]})]})})}const jf=T({id:x().min(1).max(Ha),aliases:K(x().max(Ha)).max(_n).optional().default([]),contextWindow:E().int().positive().optional(),outputLimit:E().int().positive().optional(),sourceUrl:x().optional()}),gk=T({name:x().min(1).optional(),aliases:K(x()).max(_n).optional().default([]),baseUrls:K(x()).max(_n).optional().default([]),models:K(jf).min(1).max(_n)});T({version:E().int().positive().optional(),updatedAt:x().optional(),providers:K(gk).max(_n).optional().default([]),models:K(jf).max(_n).optional().default([])});function Pc(e){return e.trim().toLowerCase().replace(/\s+/g,"-")}function bk(e){const n=e.models.filter(s=>s.trim()!=="");return n.length>0?n:e.model!==void 0&&e.model.trim()!==""?[e.model]:[]}function _l(e,n){const s=Pc(n);return(e.modelMetadata??[]).find(r=>Pc(r.model)===s)??null}function vk(e){const n=bk(e);return n.length===0?!1:n.every(s=>{const o=_l(e,s);return o!==null&&o.contextWindow!==void 0})}function yk(e,n){if(e===null)return null;for(const s of n){const o=_l(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 Bs(e){return Object.prototype.hasOwnProperty.call(e,"success")}function Fr(e){return Object.prototype.hasOwnProperty.call(e,"notConfigured")}function mt(e){return e!==void 0&&e!==""}function Je(e){return e!==void 0&&e.trim()!==""}function ns(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function Sf(e){return e>=10?`${e.toFixed(0)}/s`:`${e.toFixed(1)}/s`}function Nf(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 wk(e){return e.firstChunkMs!==void 0&&e.firstChunkMs!==null?ns(e.firstChunkMs):e.latencyMs!==void 0?ns(e.latencyMs):e.totalStreamMs!==void 0&&e.totalStreamMs!==null?ns(e.totalStreamMs):e.tokensPerSecond!==void 0&&e.tokensPerSecond!==null&&e.tokensPerSecond>0?Sf(e.tokensPerSecond):null}function jk(e){return Fr(e)?{tone:"quiet",label:"N/A",metric:null,hasDetails:!1}:Bs(e)?e.success?{tone:"success",label:"Pass",metric:wk(e),hasDetails:!0}:{tone:"failure",label:Nf(e.error?.type??"unknown"),metric:null,hasDetails:!0}:{tone:"pending",label:"Running",metric:null,hasDetails:!1}}function Sk(e,n){if(n===void 0)return[];const s=[];return mt(e.anthropicBaseUrl)&&s.push(n.anthropic),mt(e.openaiBaseUrl)&&s.push(n.openaiChat),mt(e.openaiResponsesBaseUrl)&&s.push(n.openaiResponses),s}function Nk(e,n){const s={total:0,passed:0,failed:0,testing:0};for(const o of Sk(e,n))for(const r of[o.nonStreaming,o.streaming])Fr(r)||(s.total+=1,Bs(r)?r.success?s.passed+=1:s.failed+=1:s.testing+=1);return s}function Lc(e){if(e===void 0)return;const n=Object.entries(e).map(([s,o])=>`${s}: ${o}`);return n.length===0?void 0:n.join(`
|
|
57
|
-
`)}function Zt({title:e,children:n}){return t.jsxs("section",{className:"space-y-1.5",children:[t.jsx("h4",{className:"text-xs font-medium text-foreground/80",children:e}),n]})}function wn({value:e}){return t.jsx("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap break-all rounded-md bg-muted/40 p-3 font-mono text-[11px] leading-relaxed text-foreground/80",children:e})}function jn({label:e,value:n}){return t.jsxs("div",{className:"min-w-0 rounded-md bg-muted/35 px-3 py-2",children:[t.jsx("dt",{className:"text-[10px] text-muted-foreground",children:e}),t.jsx("dd",{className:"mt-1 truncate font-mono text-xs font-semibold text-foreground",title:n,children:n})]})}function Ck({result:e}){const n=e.inputTokens!==void 0||e.outputTokens!==void 0,s=e.cacheCreationInputTokens!==void 0||e.cacheReadInputTokens!==void 0;return Je(e.model)||n||s||e.latencyMs!==void 0||e.firstChunkMs!==void 0&&e.firstChunkMs!==null||e.totalStreamMs!==void 0&&e.totalStreamMs!==null||e.tokensPerSecond!==void 0&&e.tokensPerSecond!==null&&e.tokensPerSecond>0?t.jsxs("dl",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4",children:[Je(e.model)&&t.jsx(jn,{label:"Model",value:e.model}),e.latencyMs!==void 0&&t.jsx(jn,{label:"Latency",value:ns(e.latencyMs)}),e.firstChunkMs!==void 0&&e.firstChunkMs!==null&&t.jsx(jn,{label:"First chunk",value:ns(e.firstChunkMs)}),e.totalStreamMs!==void 0&&e.totalStreamMs!==null&&t.jsx(jn,{label:"Stream total",value:ns(e.totalStreamMs)}),e.tokensPerSecond!==void 0&&e.tokensPerSecond!==null&&e.tokensPerSecond>0&&t.jsx(jn,{label:"Token rate",value:`${Sf(e.tokensPerSecond)} tok`}),n&&t.jsx(jn,{label:"Tokens in / out",value:`${String(e.inputTokens??0)} / ${String(e.outputTokens??0)}`}),s&&t.jsx(jn,{label:"Cache create / read",value:`${String(e.cacheCreationInputTokens??0)} / ${String(e.cacheReadInputTokens??0)}`})]}):null}function kk({result:e}){const n=e.debug,s=n?.requestUrl,o=n?.requestMethod??"POST",r=Lc(n?.requestHeaders),a=Lc(n?.responseHeaders),i=n?.responseStatus===void 0?void 0:`${String(n.responseStatus)}${Je(n.responseStatusText)?` ${n.responseStatusText}`:""}`,c=n?.responseBody??e.rawResponse;return Je(e.error?.hint)||Je(e.error?.details)||Je(s)||r!==void 0||Je(n?.requestBody)||Je(i)||a!==void 0||Je(c)?t.jsxs("div",{className:"space-y-4 border-t border-border/70 pt-4 text-xs text-muted-foreground",children:[Je(e.error?.hint)&&t.jsx(Zt,{title:"Hint",children:t.jsx("p",{className:"break-words text-foreground/80",children:e.error.hint})}),Je(e.error?.details)&&t.jsx(Zt,{title:"Error details",children:t.jsx(wn,{value:e.error.details})}),Je(s)&&t.jsx(Zt,{title:"Request",children:t.jsx(wn,{value:`${o} ${s}`})}),r!==void 0&&t.jsx(Zt,{title:"Request headers",children:t.jsx(wn,{value:r})}),Je(n?.requestBody)&&t.jsx(Zt,{title:"Request body",children:t.jsx(wn,{value:n.requestBody})}),Je(i)&&t.jsx(Zt,{title:"Response status",children:t.jsx(wn,{value:i})}),a!==void 0&&t.jsx(Zt,{title:"Response headers",children:t.jsx(wn,{value:a})}),Je(c)&&t.jsx(Zt,{title:"Response body",children:t.jsx(wn,{value:c})})]}):null}function _k({result:e,probeLabel:n,children:s}){const o=e.error?.message??"Connection failed";return t.jsxs(Pt,{children:[t.jsx(Xs,{asChild:!0,children:s}),t.jsxs(Lt,{className:"max-h-[82vh] max-w-2xl gap-0 overflow-hidden p-0",children:[t.jsxs(Ft,{className:"border-b border-border/70 px-5 py-4 pr-12",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[e.success?t.jsx(Hs,{className:"size-4 text-status-success"}):t.jsx(os,{className:"size-4 text-status-danger"}),t.jsx(Ut,{className:"text-base",children:n})]}),t.jsx(Zs,{children:e.success?"Connection probe passed.":o})]}),t.jsxs("div",{className:"space-y-4 overflow-y-auto p-5",children:[!e.success&&t.jsxs("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-2 text-sm text-status-danger",children:[t.jsx("div",{className:"font-medium",children:Nf(e.error?.type??"unknown")}),t.jsx("div",{className:"mt-1 break-words text-xs text-muted-foreground",children:o})]}),t.jsx(Ck,{result:e}),t.jsx(kk,{result:e})]})]})]})}function Tk(e){const n="size-3 shrink-0";switch(e){case"timeout":return t.jsx(Wt,{className:n});case"network_unreachable":return t.jsx(x1,{className:n});case"connection_refused":return t.jsx(b1,{className:n});case"auth_failed":return t.jsx(pg,{className:n});case"rate_limited":return t.jsx(zi,{className:n});case"server_error":return t.jsx(e1,{className:n});case"invalid_response":return t.jsx(b0,{className:n});case"unknown":return t.jsx(os,{className:n})}}const Ek={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 Oc({result:e,probeLabel:n}){const s=jk(e),o=Fr(e)?t.jsx(lu,{className:"size-3 shrink-0"}):Bs(e)?e.success?t.jsx(Hs,{className:"size-3 shrink-0"}):Tk(e.error?.type??"unknown"):t.jsx(qo,{className:"size-3 shrink-0 animate-spin"}),r=t.jsxs(t.Fragment,{children:[o,t.jsx("span",{className:"min-w-0 truncate",children:s.label}),s.metric!==null&&t.jsx("span",{className:"ml-auto shrink-0 font-mono text-[10px] opacity-75",children:s.metric})]}),a=O("inline-flex h-7 w-full min-w-0 items-center gap-1.5 rounded-md px-2 text-left text-xs transition-colors",Ek[s.tone]);return Bs(e)&&s.hasDetails?t.jsx(_k,{result:e,probeLabel:n,children:t.jsx("button",{type:"button",className:a,"aria-label":`Open ${n} result: ${s.label}`,children:r})}):t.jsx("div",{className:a,children:r})}function Dc({label:e}){return t.jsxs("div",{className:"inline-flex h-7 w-full min-w-0 items-center gap-1.5 rounded-md px-2 text-xs text-muted-foreground/70",children:[t.jsx(lu,{className:"size-3 shrink-0"}),t.jsx("span",{className:"truncate",children:e})]})}function ya({label:e,results:n,configured:s=!0}){return t.jsxs("div",{className:"grid min-w-0 grid-cols-[minmax(6.5rem,1fr)_minmax(6rem,0.9fr)_minmax(6rem,0.9fr)] items-center gap-2 border-t border-border/60 px-2 py-2",children:[t.jsx("div",{className:"min-w-0 truncate text-xs font-medium text-foreground/85",title:e,children:e}),s&&n!==void 0?t.jsx(Oc,{result:n.nonStreaming,probeLabel:`${e} non-stream`}):t.jsx(Dc,{label:s?"Not tested":"Off"}),s&&n!==void 0?t.jsx(Oc,{result:n.streaming,probeLabel:`${e} stream`}):t.jsx(Dc,{label:s?"Not tested":"Off"})]})}function Cf({provider:e,results:n}){const s=mt(e.anthropicBaseUrl),o=mt(e.openaiBaseUrl),r=mt(e.openaiResponsesBaseUrl);return!s&&!o&&!r?t.jsx("div",{className:"text-xs text-muted-foreground",children:"No testable endpoint configured."}):t.jsx("div",{className:"min-w-0 overflow-x-auto rounded-md border border-border/70",children:t.jsxs("div",{className:"min-w-[20rem]",children:[t.jsxs("div",{className:"grid grid-cols-[minmax(6.5rem,1fr)_minmax(6rem,0.9fr)_minmax(6rem,0.9fr)] gap-2 bg-muted/25 px-2 py-1.5 text-[10px] text-muted-foreground",children:[t.jsx("span",{children:"Protocol"}),t.jsx("span",{children:"Non-stream"}),t.jsx("span",{children:"Stream"})]}),s&&t.jsx(ya,{label:"Anthropic",results:n?.anthropic}),o&&t.jsx(ya,{label:"OpenAI Chat",results:n?.openaiChat}),r&&t.jsx(ya,{label:"OpenAI Responses",results:n?.openaiResponses})]})})}function Rk(e){const n={total:0,passed:0,failed:0,testing:0};for(const s of[e.nonStreaming,e.streaming])Fr(s)||(n.total+=1,Bs(s)?s.success?n.passed+=1:n.failed+=1:n.testing+=1);return n}function wa({label:e,results:n}){const s=Rk(n),o=s.failed>0?"border-status-danger/30 bg-status-danger/10 text-status-danger":s.testing>0?"border-status-watch/30 bg-status-watch/10 text-status-watch":s.total>0&&s.passed===s.total?"border-status-success/30 bg-status-success/10 text-status-success":"border-border/60 bg-transparent text-muted-foreground",r=s.failed>0?`${s.failed} fail`:s.testing>0?"running":s.total===0?"off":`${s.passed}/${s.total}`;return t.jsxs("span",{className:O("rounded border px-1.5 py-0.5 text-[10px]",o),children:[e," ",r]})}function Mk({provider:e,modelName:n,results:s,expanded:o,onToggle:r}){return t.jsxs("div",{className:"min-w-0",children:[t.jsxs("button",{type:"button",onClick:r,className:"flex w-full min-w-0 flex-wrap items-center gap-2 px-2 py-2 text-left transition-colors hover:bg-muted/20","aria-expanded":o,children:[o?t.jsx(Ve,{className:"size-3.5 shrink-0 text-muted-foreground"}):t.jsx(it,{className:"size-3.5 shrink-0 text-muted-foreground"}),t.jsx("span",{className:"min-w-[8rem] flex-1 truncate text-xs font-medium",title:n,children:n}),t.jsxs("span",{className:"flex flex-wrap items-center justify-end gap-1",children:[mt(e.anthropicBaseUrl)&&t.jsx(wa,{label:"A",results:s.anthropic}),mt(e.openaiBaseUrl)&&t.jsx(wa,{label:"Chat",results:s.openaiChat}),mt(e.openaiResponsesBaseUrl)&&t.jsx(wa,{label:"Resp",results:s.openaiResponses})]})]}),o&&t.jsx("div",{className:"px-2 pb-3",children:t.jsx(Cf,{provider:e,results:s})})]})}function Ak({provider:e,testResults:n}){const s=Object.entries(n.models??{}),[o,r]=l.useState(!1),[a,i]=l.useState(null);return s.length===0?null:t.jsxs("section",{className:"space-y-2",children:[t.jsxs("button",{type:"button",onClick:()=>r(c=>!c),className:"flex w-full items-center gap-1.5 text-left text-xs font-medium text-foreground/80 transition-colors hover:text-foreground","aria-expanded":o,children:[o?t.jsx(Ve,{className:"size-3.5"}):t.jsx(it,{className:"size-3.5"}),"Model probes",t.jsx("span",{className:"rounded bg-muted/50 px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground",children:s.length})]}),o&&t.jsx("div",{className:"min-w-0 divide-y divide-border/60 rounded-md border border-border/70",children:s.map(([c,d])=>t.jsx(Mk,{provider:e,modelName:c,results:d,expanded:a===c,onToggle:()=>i(m=>m===c?null:c)},c))})]})}function Ik({provider:e,testResults:n,isTesting:s}){const o=mt(e.anthropicBaseUrl)||mt(e.openaiBaseUrl)||mt(e.openaiResponsesBaseUrl),r=Nk(e,n);return s?t.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-status-cool/30 bg-status-cool/10 px-2 py-1 text-xs text-status-cool",children:[t.jsx(qo,{className:"size-3 animate-spin"}),"Testing"]}):o?n===void 0||r.total===0?t.jsx("span",{className:"rounded border border-border/70 bg-muted/20 px-2 py-1 text-xs text-muted-foreground",children:"Not tested"}):r.failed>0?t.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-status-danger/30 bg-status-danger/10 px-2 py-1 text-xs text-status-danger",children:[t.jsx(os,{className:"size-3"}),r.failed," failed"]}):r.testing>0||r.passed<r.total?t.jsxs("span",{className:"rounded border border-status-watch/30 bg-status-watch/10 px-2 py-1 text-xs text-status-watch",children:[r.passed,"/",r.total]}):t.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-status-success/30 bg-status-success/10 px-2 py-1 text-xs text-status-success",children:[t.jsx(Hs,{className:"size-3"}),r.passed,"/",r.total]}):t.jsx("span",{className:"rounded border border-border/70 bg-muted/20 px-2 py-1 text-xs text-muted-foreground",children:"No endpoint"})}const Pk={deepseek:"https://api-docs.deepseek.com/zh-cn/"};function ja(e){return e!==void 0&&e!==""}function Sa({label:e}){return t.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-border/70 bg-muted/25 px-1.5 py-0.5 text-foreground/80",children:[t.jsx(Hs,{className:"size-3"}),e]})}function Lk({provider:e}){const n=ja(e.anthropicBaseUrl),s=ja(e.openaiBaseUrl),o=ja(e.openaiResponsesBaseUrl);return!n&&!s&&!o?t.jsx("div",{className:"text-xs text-muted-foreground",children:"Test requires at least one configured endpoint."}):t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5 text-xs text-muted-foreground",children:[n&&t.jsx(Sa,{label:"Anthropic"}),s&&t.jsx(Sa,{label:"OpenAI Chat"}),o&&t.jsx(Sa,{label:"OpenAI Responses"})]})}function Ok(e){const n=e.models??[];if(n.length===0)return"No models configured";const s=n.slice(0,2).join(", "),o=n.length-2;return o>0?`${s} +${o} more`:s}function Dk({provider:e,model:n}){const s=_l(e,n),o=$k(s?.sourceUrl);return t.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:[t.jsx("span",{children:n}),s!==null&&s.contextWindow!==void 0&&t.jsx("span",{className:"font-mono text-foreground/80",children:Pd(s.contextWindow)}),o!==null&&t.jsx(hs,{children:t.jsxs(et,{children:[t.jsx(tt,{asChild:!0,children:t.jsx("a",{href:o.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-0.5 rounded border border-border/70 bg-background/70 px-1 font-mono text-[10px] leading-4 text-muted-foreground transition-colors hover:text-foreground","aria-label":o.title,children:o.label})}),t.jsx(nt,{children:o.title})]})})]})}function zk(e){const n=Date.now(),s=new Date(e).getTime(),o=n-s,r=Math.floor(o/1e3);if(r<60)return"just now";const a=Math.floor(r/60);if(a<60)return`${a}m ago`;const i=Math.floor(a/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function $k(e){if(e===void 0||e.trim()==="")return null;try{const n=new URL(e);if(n.protocol!=="https:"&&n.protocol!=="http:")return null;const s=n.hostname.toLowerCase(),o=s==="huggingface.co"||s.endsWith(".huggingface.co");return{label:o?"HF":"Source",title:o?"Open Hugging Face model source":"Open model metadata source",url:e}}catch{return null}}function Fk({provider:e,testResults:n,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(Pk).find(([v])=>e.name.toLowerCase().includes(v))?.[1],h=vk(e),g=e.modelMetadataUrl!==void 0&&e.modelMetadataUrl.trim()!=="",b=g?"Refresh":"Import defaults",y=s??!1,w=e.source==="company"?t.jsx("span",{className:"shrink-0 rounded border border-status-cool/30 bg-status-cool/10 px-1.5 py-0.5 text-xs text-status-cool",children:"Company"}):e.source==="personal"?t.jsx("span",{className:"shrink-0 rounded border border-status-accent/30 bg-status-accent/10 px-1.5 py-0.5 text-xs text-status-accent",children:"Personal"}):null;return t.jsxs("div",{"data-provider-id":e.id,className:`flex flex-col gap-3 rounded-[8px] border border-border bg-card p-4 shadow-sm transition-all duration-500 ${r===!0?"ring-2 ring-primary shadow-md":""}`,children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0 space-y-1",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[t.jsx("span",{className:"font-medium leading-snug",children:e.name}),w]}),t.jsx("div",{className:"text-xs leading-snug text-muted-foreground",children:Ok(e)})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(Ik,{provider:e,testResults:n,isTesting:y}),f!==void 0&&t.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:[t.jsx(Di,{className:"size-3"}),t.jsx("span",{className:"sr-only",children:"Docs"})]})]})]}),t.jsxs("div",{className:"flex flex-col gap-2 text-xs text-muted-foreground sm:flex-row sm:items-center sm:justify-between",children:[t.jsx(Lk,{provider:e}),n?.testedAt!==void 0&&t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(Wt,{className:"size-3"}),zk(n.testedAt)]})]}),!h&&t.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-status-watch/30 bg-status-watch/10 px-2 py-1.5 text-xs text-status-watch",children:[t.jsx("span",{children:"Context window metadata missing"}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.jsxs(ee,{type:"button",variant:"outline",size:"sm",onClick:()=>d?.(e.id),className:"h-6 gap-1 px-2 text-xs",disabled:m,children:[t.jsx(qo,{className:`size-3 ${m?"animate-spin":""}`}),b]}),!g&&t.jsx(ee,{type:"button",variant:"ghost",size:"sm",onClick:()=>a(e),className:"h-6 px-2 text-xs",children:"Set URL"})]})]}),u&&t.jsxs("div",{className:"space-y-3 border-t border-border/60 pt-3",children:[t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[t.jsx(Hs,{className:"size-3.5 text-status-success"}),t.jsx("span",{children:"API key configured"})]}),e.models!==void 0&&e.models.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1",children:e.models.map(v=>t.jsx(Dk,{provider:e,model:v},v))}),t.jsxs("section",{className:"space-y-2",children:[t.jsx("h4",{className:"text-xs font-medium text-foreground/80",children:"Connection probes"}),t.jsx(Cf,{provider:e,results:n})]}),n!==void 0&&t.jsx(Ak,{provider:e,testResults:n})]}),t.jsxs("div",{className:"flex flex-col gap-2 border-t pt-1 sm:flex-row sm:items-center sm:justify-between",children:[t.jsxs("button",{type:"button",onClick:()=>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?t.jsx(Ve,{className:"size-3"}):t.jsx(it,{className:"size-3"}),"Details"]}),t.jsxs("div",{className:"flex gap-2",children:[c!==void 0&&t.jsxs(ee,{variant:"outline",size:"sm",onClick:()=>c(e.id),className:"text-xs h-7 gap-1",disabled:y,children:[t.jsx(qo,{className:`size-3 ${y?"animate-spin":""}`}),y?o!==void 0?`Testing (${o}s)`:"Testing...":"Test"]}),t.jsxs(ee,{variant:"outline",size:"sm",onClick:()=>a(e),className:"text-xs h-7 gap-1",disabled:y,children:[t.jsx(cu,{className:"size-3"}),"Edit"]}),t.jsxs(ee,{variant:"outline",size:"sm",onClick:()=>i(e.id),className:"text-xs h-7 gap-1 text-destructive hover:text-destructive",disabled:y,children:[t.jsx(an,{className:"size-3"}),"Delete"]})]})]})]})}const ss="/v1/chat/completions",fi="/v1/responses",Uk="/v1/messages";function Bk(e,n){const s=e.endsWith("/")?e.slice(0,-1):e,o=kf(n),r=n.indexOf("?"),a=r>=0?n.slice(r):"";return o!==""&&s.endsWith(o)?s+a:Tf(s)&&_f(n)||s.endsWith("/v1")&&n.startsWith("/v1/")?s+n.slice(3):s+n}function qk(e,n,s={}){const o=e.trim().replace(/\/+$/,""),r=kf(n),a=Bk(o,n),i=[];return r!==""&&o.endsWith(r)?i.push({severity:"info",message:"This already includes the exact endpoint; no duplicate suffix will be appended."}):Tf(o)&&_f(n)?i.push({severity:"info",message:"Zhipu bases already include the API version; only /chat/completions is appended."}):o.endsWith("/v1")&&n.startsWith("/v1/")&&i.push({severity:"info",message:"Base URL already ends with /v1; the suffix will not repeat /v1."}),zc(r)&&Wk(o)&&i.push({severity:"warning",message:"This looks like a Chat Completions endpoint, so Responses would append after it."}),Hk(r)&&Vk(o)&&i.push({severity:"warning",message:"This looks like a Responses endpoint, so Chat Completions would append after it."}),zc(r)&&Kk(o,s.providerName)&&i.push({severity:"warning",message:"DeepSeek's official API does not currently expose OpenAI Responses."}),{finalUrl:a,diagnostics:i}}function kf(e){return e.split("?")[0]??e}function _f(e){return e===ss||e.startsWith(`${ss}?`)||e.startsWith(`${ss}/`)}function Hk(e){return e===ss||e.startsWith(`${ss}/`)}function zc(e){return e===fi||e.startsWith(`${fi}/`)}function Wk(e){return e.toLowerCase().endsWith("/chat/completions")}function Vk(e){return e.toLowerCase().endsWith("/responses")}function Kk(e,n){const s=n?.toLowerCase();if(s!==void 0&&s.includes("deepseek"))return!0;try{return new URL(e).hostname.toLowerCase().includes("deepseek")}catch{return e.toLowerCase().includes("deepseek")}}function Tf(e){try{const n=new URL(e),s=n.pathname.replace(/\/+$/,"");return n.hostname==="open.bigmodel.cn"&&(s==="/api/paas/v4"||s==="/api/coding/paas/v4")}catch{return!1}}function Na(e){return e!==void 0&&e.trim()!==""}function $c(e){const n=Na(e?.anthropicBaseUrl),s=Na(e?.openaiBaseUrl),o=Na(e?.openaiResponsesBaseUrl);return{anthropic:n,openai:s||o,openaiChat:s,openaiResponses:o}}function Ca(e,n,s){if(!e)return s?"":void 0;const o=n.trim();return o===""?void 0:o}const Fc=["zhipu","zhipuai","bigmodel","z.ai","zai","glm"],Uc=["zhipu coding","glm coding","bigmodel coding","z.ai coding","zai coding"],vo=Uk,yo=ss,wo=fi,Gk={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"}},Bc=["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"],qc=["qwen3.6-plus","qwen3.7-max"],Hc=["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"],hi="__unset__",or="__custom__",Ef=[{value:"32K",label:"Small"},{value:"64K",label:"Standard"},{value:"128K",label:"Medium"},{value:"200K",label:"Long"},{value:"256K",label:"Extended"},{value:"512K",label:"Large"},{value:"1M",label:"Max"}];function Sn(){return{contextWindow:"",contextWindowMode:"unset",outputLimit:""}}function Wc(e){return e.trim().toLowerCase().replace(/\s+/g,"-")}function Rf(e,n){const s=Wc(n);return e?.modelMetadata?.find(o=>Wc(o.model)===s)??null}function Mf(e){const n=$o(e);if(n===null)return null;for(const s of Ef)if($o(s.value)===n)return s.value;return null}function Jk(e){return e.trim()===""?"unset":Mf(e)!==null?"preset":"custom"}function Yk(e){switch(e.contextWindowMode){case"unset":return hi;case"custom":return or;case"preset":return Mf(e.contextWindow)??or}}function ka(e){const n=e.trim().replaceAll(",","");if(n==="")return{amount:"",unit:"K"};const s=/^(\d+(?:\.\d+)?)\s*([kKmM])?$/.exec(n);if(s===null)return{amount:n,unit:"K"};const o=s[1];if(o===void 0)return{amount:n,unit:"K"};const r=s[2];if(r===void 0||r==="")return{amount:o,unit:"tokens"};switch(r.toLowerCase()){case"k":return{amount:o,unit:"K"};case"m":return{amount:o,unit:"M"};default:return{amount:n,unit:"K"}}}function Vc(e,n){const s=e.trim();if(s==="")return"";switch(n){case"K":return`${s}K`;case"M":return`${s}M`;case"tokens":return s}}function Kc(e,n){return n.map(s=>{const o=Rf(e,s),r=o?.contextWindow!==void 0?Nh(o.contextWindow):"";return{contextWindow:r,contextWindowMode:Jk(r),outputLimit:o?.outputLimit?.toString()??""}})}function Gc(e){const n=e.trim();if(n==="")return null;const s=Number(n);return!Number.isInteger(s)||s<=0?null:s}function Wn(e,n){if(e===void 0)return"";const s=e.trim(),o=s.replace(/\/+$/,"");return o.endsWith(n)?o.slice(0,-n.length).replace(/\/+$/,""):s}function Xk(e,n,s){const o=e.trim();return o===""?null:qk(o,n,{providerName:s})}function _a({baseUrl:e,endpoint:n,providerName:s}){const o=Xk(e,n,s);return o===null?null:t.jsxs("div",{className:"border border-border bg-muted/40 rounded-md px-3 py-2 text-xs",children:[t.jsx("div",{className:"text-muted-foreground",children:"Final URL"}),t.jsx("div",{className:"break-all font-mono text-foreground",children:o.finalUrl}),o.diagnostics.length>0&&t.jsx("div",{className:"mt-2 space-y-1",children:o.diagnostics.map(r=>t.jsx("div",{className:r.severity==="warning"?"text-status-watch":"text-muted-foreground",children:r.message},`${r.severity}:${r.message}`))})]})}function Zk({provider:e,onSubmit:n,onCancel:s}){const o=$c(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(()=>Kc(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),[R,I]=l.useState(o.openaiResponses),[P,M]=l.useState(Wn(e?.anthropicBaseUrl,vo)),[k,A]=l.useState(Wn(e?.openaiBaseUrl,yo)),[D,$]=l.useState(Wn(e?.openaiResponsesBaseUrl,wo)),[J,X]=l.useState(e?.apiDocsUrl??""),[F,H]=l.useState(e?.modelMetadataUrl??""),[Y,U]=l.useState(e?.source),[W,me]=l.useState({}),[be,ve]=l.useState(!1),[z,se]=l.useState(null),te=l.useRef([]);l.useEffect(()=>{if(z===null)return;const _=z;function L(V){if(!(V.target instanceof Node))return;const oe=te.current[_];oe!=null&&!oe.contains(V.target)&&se(null)}return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[z]);const[Se,Ne]=l.useState(!1),[ie,le]=l.useState(!1),[fe,ye]=l.useState(!1),Ce=r.toLowerCase().includes("minimax"),Ie=r.toLowerCase().includes("alibaba"),$e=[...Fc,...Uc].some(_=>r.toLowerCase().includes(_)),Pe=Ce?Bc:$e?Hc:Ie?qc:[],Ze=e?.modelMetadata?.some(_=>_.contextWindow!==void 0)??!1;function Bt(){vt(i).then(_=>{_&&(p(!0),setTimeout(()=>p(!1),2e3))})}l.useEffect(()=>{if(e){a(e.name),c(""),m(!1);const _=(e.models?.length??0)>0?e.models:[""];g(_),y(Kc(e,_));const L=$c(e);v(L.anthropic),S(L.openai),C(L.openaiChat),I(L.openaiResponses),M(Wn(e.anthropicBaseUrl,vo)),A(Wn(e.openaiBaseUrl,yo)),$(Wn(e.openaiResponsesBaseUrl,wo)),X(e.apiDocsUrl??""),H(e.modelMetadataUrl??""),U(e.source),Ne(!1),le(!1),ye(!1)}},[e]),l.useEffect(()=>{const _=r.toLowerCase();for(const[L,V]of Object.entries(Gk))if(_.includes(L)){V.anthropicBaseUrl!==void 0&&!Se&&M(V.anthropicBaseUrl),V.openaiBaseUrl!==void 0&&!ie&&A(V.openaiBaseUrl),V.openaiResponsesBaseUrl!==void 0&&!fe&&$(V.openaiResponsesBaseUrl),V.apiDocsUrl!==void 0&&!J&&X(V.apiDocsUrl),L==="minimax"&&h.length===1&&h[0]===""&&g([Bc[0]??""]),L==="alibaba"&&h.length===1&&h[0]===""&&g([qc[0]??""]),(Fc.includes(L)||Uc.includes(L))&&h.length===1&&h[0]===""&&g([Hc[0]??""]);break}},[r]);function ct(){const _={};return r.trim()||(_.name="Name is required"),e===void 0&&!i.trim()&&(_.apiKey="API key is required"),(h.length===0||h.every(L=>!L.trim()))&&(_.models="At least one model is required"),!w&&!j&&(_.capabilities="Select at least one API capability"),j&&!N&&!R&&(_.openaiCapabilities="Select Chat Completions, Responses, or both"),w&&(P.trim()===""?_.anthropicBaseUrl="Anthropic base URL is required":Fe(P.trim())||(_.anthropicBaseUrl="Invalid URL format")),j&&N&&(k.trim()===""?_.openaiBaseUrl="OpenAI Chat base URL is required":Fe(k.trim())||(_.openaiBaseUrl="Invalid URL format")),j&&R&&(D.trim()===""?_.openaiResponsesBaseUrl="OpenAI Responses base URL is required":Fe(D.trim())||(_.openaiResponsesBaseUrl="Invalid URL format")),F.trim()&&!Fe(F.trim())&&(_.modelMetadataUrl="Invalid URL format"),b.forEach((L,V)=>{const oe=$o(L.contextWindow),ce=Gc(L.outputLimit);L.contextWindow.trim()!==""&&oe===null&&(_[`modelMetadata.${V}.contextWindow`]="Context window must be a positive number, optionally using K or M"),L.outputLimit.trim()!==""&&ce===null&&(_[`modelMetadata.${V}.outputLimit`]="Output limit must be a positive integer"),oe!==null&&ce!==null&&ce>oe&&(_[`modelMetadata.${V}.outputLimit`]="Output limit should not exceed context window")}),me(_),Object.keys(_).length===0}function Fe(_){try{return new URL(_),!0}catch{return!1}}function Me(_,L){g(V=>{const oe=[...V];return oe[_]=L,oe})}function Le(_,L){y(V=>{const oe=[...V];return oe[_]={...oe[_]??Sn(),...L},oe})}function B(_,L){switch(L){case hi:Le(_,{contextWindow:"",contextWindowMode:"unset"});return;case or:{const V=b[_]??Sn();Le(_,{contextWindow:V.contextWindow,contextWindowMode:"custom"});return}default:Le(_,{contextWindow:L,contextWindowMode:"preset"});return}}function ne(_,L){const V=b[_]??Sn(),oe=ka(V.contextWindow);Le(_,{contextWindow:Vc(L,oe.unit),contextWindowMode:"custom"})}function we(_,L){const V=b[_]??Sn(),oe=ka(V.contextWindow);switch(L){case"K":case"M":case"tokens":Le(_,{contextWindow:Vc(oe.amount,L),contextWindowMode:"custom"});return;default:return}}function he(_){g(L=>L.filter((V,oe)=>oe!==_)),y(L=>L.filter((V,oe)=>oe!==_))}function je(){g(_=>[..._,""]),y(_=>[..._,Sn()])}function Be(){const _=new Date().toISOString(),L=[];return h.forEach((V,oe)=>{const ce=V.trim();if(ce==="")return;const Q=b[oe]??Sn(),pe=$o(Q.contextWindow),ae=Gc(Q.outputLimit);if(pe===null&&ae===null)return;const ht=Rf(e,ce);if(ht!==null&&ht.contextWindow===(pe??void 0)&&ht.outputLimit===(ae??void 0)){L.push({...ht,model:ce});return}const hn={model:ce,source:"manual",updatedAt:_};pe!==null&&(hn.contextWindow=pe),ae!==null&&(hn.outputLimit=ae),L.push(hn)}),L.length>0?L:e?.modelMetadata!==void 0?[]:void 0}function G(_){if(_.preventDefault(),!ct())return;ve(!0);const L=e!==void 0;try{n({name:r.trim(),apiKey:i.trim(),models:h.map(V=>V.trim()).filter(V=>V!==""),anthropicBaseUrl:Ca(w,P,L),openaiBaseUrl:Ca(j&&N,k,L),openaiResponsesBaseUrl:Ca(j&&R,D,L),apiDocsUrl:J.trim()||void 0,modelMetadataUrl:F.trim()||void 0,modelMetadata:Be(),source:Y})}finally{ve(!1)}}return t.jsxs("form",{onSubmit:G,className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{htmlFor:"provider-name",className:"text-sm font-medium",children:["Name ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsx("input",{id:"provider-name",type:"text",value:r,onChange:_=>a(_.target.value),placeholder:"Provider Name",className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50"}),W.name!==void 0&&t.jsx("p",{className:"text-xs text-destructive",children:W.name})]}),t.jsxs("fieldset",{className:"space-y-3",children:[t.jsxs("legend",{className:"text-sm font-medium",children:["Capabilities ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsxs("div",{className:"divide-y divide-border overflow-hidden rounded-md border border-border",children:[t.jsxs("div",{className:j?"bg-primary/[0.04] px-3 py-3":"px-3 py-3",children:[t.jsxs("label",{htmlFor:"provider-capability-openai",className:"flex cursor-pointer items-start gap-3",children:[t.jsx("input",{id:"provider-capability-openai",type:"checkbox",checked:j,onChange:_=>S(_.target.checked),className:"mt-0.5 size-4 shrink-0 accent-primary"}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block text-sm font-medium",children:"OpenAI"}),t.jsx("span",{className:"block text-xs text-muted-foreground",children:"Chat Completions and Responses"})]})]}),j&&t.jsxs("div",{className:"ml-7 mt-3 flex flex-wrap gap-x-5 gap-y-2 border-t border-border/70 pt-3",children:[t.jsxs("label",{htmlFor:"provider-capability-openai-chat",className:"flex cursor-pointer items-center gap-2 text-sm",children:[t.jsx("input",{id:"provider-capability-openai-chat",type:"checkbox",checked:N,onChange:_=>C(_.target.checked),className:"size-4 shrink-0 accent-primary"}),"Chat Completions"]}),t.jsxs("label",{htmlFor:"provider-capability-openai-responses",className:"flex cursor-pointer items-center gap-2 text-sm",children:[t.jsx("input",{id:"provider-capability-openai-responses",type:"checkbox",checked:R,onChange:_=>I(_.target.checked),className:"size-4 shrink-0 accent-primary"}),"Responses"]})]}),W.openaiCapabilities!==void 0&&j&&t.jsx("p",{className:"ml-7 mt-2 text-xs text-destructive",children:W.openaiCapabilities})]}),t.jsxs("label",{htmlFor:"provider-capability-anthropic",className:`flex cursor-pointer items-start gap-3 px-3 py-3 ${w?"bg-primary/[0.04]":""}`,children:[t.jsx("input",{id:"provider-capability-anthropic",type:"checkbox",checked:w,onChange:_=>v(_.target.checked),className:"mt-0.5 size-4 shrink-0 accent-primary"}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block text-sm font-medium",children:"Anthropic"}),t.jsx("span",{className:"block text-xs text-muted-foreground",children:"Messages"})]})]})]}),W.capabilities!==void 0&&t.jsx("p",{className:"text-xs text-destructive",children:W.capabilities})]}),(w||j&&(N||R))&&t.jsxs("section",{className:"space-y-5 border-l border-border pl-4","aria-label":"API endpoints",children:[t.jsx("h3",{className:"text-sm font-medium",children:"Endpoint Configuration"}),w&&t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{htmlFor:"provider-anthropic-base-url",className:"text-sm font-medium",children:["Anthropic Messages Base URL ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsxs("div",{className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground flex min-w-0 overflow-hidden rounded-md focus-within:border-ring focus-within:outline-ring focus-within:ring-[3px]",children:[t.jsx("input",{id:"provider-anthropic-base-url",type:"text",value:P,onChange:_=>{Ne(!0),M(_.target.value)},placeholder:"https://api.anthropic.com",className:"min-w-0 flex-1 bg-transparent px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"}),t.jsx("span",{className:"shrink-0 select-none border-l border-border bg-muted/35 px-3 py-2 font-mono text-xs text-muted-foreground",children:vo})]}),W.anthropicBaseUrl!==void 0&&t.jsx("p",{className:"text-xs text-destructive",children:W.anthropicBaseUrl}),t.jsx(_a,{baseUrl:P,endpoint:vo,providerName:r})]}),j&&N&&t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{htmlFor:"provider-openai-base-url",className:"text-sm font-medium",children:["OpenAI Chat Base URL ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsxs("div",{className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground flex min-w-0 overflow-hidden rounded-md focus-within:border-ring focus-within:outline-ring focus-within:ring-[3px]",children:[t.jsx("input",{id:"provider-openai-base-url",type:"text",value:k,onChange:_=>{le(!0),A(_.target.value)},placeholder:"https://api.openai.com",className:"min-w-0 flex-1 bg-transparent px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"}),t.jsx("span",{className:"shrink-0 select-none border-l border-border bg-muted/35 px-3 py-2 font-mono text-xs text-muted-foreground",children:yo})]}),W.openaiBaseUrl!==void 0&&t.jsx("p",{className:"text-xs text-destructive",children:W.openaiBaseUrl}),t.jsx(_a,{baseUrl:k,endpoint:yo,providerName:r})]}),j&&R&&t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{htmlFor:"provider-openai-responses-base-url",className:"text-sm font-medium",children:["OpenAI Responses Base URL ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsxs("div",{className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground flex min-w-0 overflow-hidden rounded-md focus-within:border-ring focus-within:outline-ring focus-within:ring-[3px]",children:[t.jsx("input",{id:"provider-openai-responses-base-url",type:"text",value:D,onChange:_=>{ye(!0),$(_.target.value)},placeholder:"https://api.openai.com",className:"min-w-0 flex-1 bg-transparent px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"}),t.jsx("span",{className:"shrink-0 select-none border-l border-border bg-muted/35 px-3 py-2 font-mono text-xs text-muted-foreground",children:wo})]}),W.openaiResponsesBaseUrl!==void 0&&t.jsx("p",{className:"text-xs text-destructive",children:W.openaiResponsesBaseUrl}),t.jsx(_a,{baseUrl:D,endpoint:wo,providerName:r})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:"provider-source",className:"text-sm font-medium",children:"Token Source"}),t.jsxs("select",{id:"provider-source",value:Y??"",onChange:_=>U(_.target.value==="company"||_.target.value==="personal"?_.target.value:void 0),className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx("option",{value:"",children:"Unspecified"}),t.jsx("option",{value:"personal",children:"个人 (Personal)"}),t.jsx("option",{value:"company",children:"公司 (Company)"})]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Label whether this API key is company-provided or personal."})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:"provider-model-metadata-url",className:"text-sm font-medium",children:"Model Metadata URL"}),t.jsx("input",{id:"provider-model-metadata-url",type:"text",value:F,onChange:_=>H(_.target.value),placeholder:"https://example.com/agent-inspector-models.json",className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50"}),W.modelMetadataUrl!==void 0&&t.jsx("p",{className:"text-xs text-destructive",children:W.modelMetadataUrl}),F.trim()===""&&t.jsx("div",{className:"border border-border bg-muted/40 rounded-md px-3 py-2 text-xs text-muted-foreground",children:"Built-in limits cover DeepSeek v4 pro/flash, MiniMax M3/M2.7/M2.5/M2.1, and GLM coding models. Use a registry URL for private or custom model limits."}),e!==void 0&&!Ze&&F.trim()===""&&t.jsx("p",{className:"text-xs text-status-watch",children:"This provider has no matching context metadata yet."}),F.trim()!==""&&t.jsx("p",{className:"text-xs text-muted-foreground",children:"Agent Inspector will refresh model limits from this JSON registry after save."})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{htmlFor:"provider-apikey",className:"text-sm font-medium",children:["API Key ",e===void 0&&t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{id:"provider-apikey",type:d?"text":"password",value:i,onChange:_=>c(_.target.value),placeholder:e===void 0?"sk-ant-...":"Leave blank to keep current key",className:"flex-1 rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50"}),t.jsx("button",{type:"button",onClick:()=>m(_=>!_),className:"text-muted-foreground hover:text-foreground transition-colors p-1 shrink-0","aria-label":d?"Hide API key":"Show API key",children:d?t.jsx(F0,{className:"size-4"}):t.jsx(ou,{className:"size-4"})}),t.jsx("button",{type:"button",onClick:Bt,className:"text-muted-foreground hover:text-foreground transition-colors p-1 shrink-0","aria-label":"Copy API key",children:u?t.jsx(Oe,{className:"size-4 text-status-success"}):t.jsx(St,{className:"size-4"})})]}),e!==void 0&&i.trim()===""&&t.jsx("p",{className:"text-xs text-muted-foreground",children:"A key is configured. Enter a new value only to rotate it."}),W.apiKey!==void 0&&t.jsx("p",{className:"text-xs text-destructive",children:W.apiKey})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{className:"text-sm font-medium",children:["Models ",t.jsx("span",{className:"text-destructive",children:"*"})]}),h.map((_,L)=>{const V=b[L]??Sn(),oe=W[`modelMetadata.${L}.contextWindow`],ce=W[`modelMetadata.${L}.outputLimit`],Q=Yk(V),pe=ka(V.contextWindow);return t.jsxs("div",{ref:ae=>{te.current[L]=ae},className:"border border-border bg-card shadow-sm space-y-2 rounded-[8px] p-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("div",{className:"relative flex-1",children:[t.jsx("input",{type:"text",value:_,onChange:ae=>Me(L,ae.target.value),placeholder:Pe.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"}),Pe.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>se(z===L?null:L),className:"absolute right-1 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors p-1 z-10","aria-label":"Show model suggestions",children:t.jsx(Ve,{className:"size-4"})}),z===L&&t.jsx("div",{className:"bg-popover text-popover-foreground absolute left-0 right-0 top-full z-50 mt-1 max-h-48 overflow-y-auto rounded-md border shadow-md",children:Pe.map(ae=>t.jsx("button",{type:"button",onClick:()=>{Me(L,ae),se(null)},className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/60",children:ae},ae))})]})]}),h.length>1&&t.jsx("button",{type:"button",onClick:()=>he(L),className:"text-muted-foreground hover:text-destructive transition-colors p-1 shrink-0","aria-label":"Remove model",children:t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M3 6h18"}),t.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),t.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]})})]}),t.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[t.jsxs("div",{className:"space-y-1 text-xs text-muted-foreground",children:[t.jsx("span",{children:"Context Window"}),t.jsxs($s,{value:Q,onValueChange:ae=>B(L,ae),children:[t.jsx(Fs,{size:"sm",className:"w-full bg-background font-mono text-xs",children:t.jsx(sr,{})}),t.jsxs(Us,{className:"max-h-64",children:[t.jsx(Xe,{value:hi,children:"Not set"}),Ef.map(ae=>t.jsxs(Xe,{value:ae.value,children:[ae.label," · ",ae.value]},ae.value)),t.jsx(Xe,{value:or,children:"Custom"})]})]}),V.contextWindowMode==="custom"&&t.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_5.75rem] gap-1.5",children:[t.jsx("input",{type:"text",inputMode:"decimal",value:pe.amount,onChange:ae=>ne(L,ae.target.value),placeholder:"128",className:"w-full rounded-md border border-input bg-background px-3 py-2 font-mono text-xs text-foreground ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px]"}),t.jsxs($s,{value:pe.unit,onValueChange:ae=>we(L,ae),children:[t.jsx(Fs,{size:"sm",className:"w-full bg-background font-mono text-xs",children:t.jsx(sr,{})}),t.jsxs(Us,{children:[t.jsx(Xe,{value:"K",children:"K"}),t.jsx(Xe,{value:"M",children:"M"}),t.jsx(Xe,{value:"tokens",children:"tokens"})]})]})]}),oe!==void 0&&t.jsx("span",{className:"block text-destructive",children:oe})]}),t.jsxs("label",{className:"space-y-1 text-xs text-muted-foreground",children:[t.jsx("span",{children:"Output Limit"}),t.jsx("input",{type:"number",min:1,step:1e3,value:V.outputLimit,onChange:ae=>Le(L,{outputLimit:ae.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]"}),ce!==void 0&&t.jsx("span",{className:"block text-destructive",children:ce})]})]})]},L)}),t.jsx("button",{type:"button",onClick:je,className:"text-xs text-primary hover:underline flex items-center gap-1",children:"+ Add Model"}),W.models!==void 0&&t.jsx("p",{className:"text-xs text-destructive",children:W.models})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:"provider-api-docs-url",className:"text-sm font-medium",children:"API Docs URL"}),t.jsx("input",{id:"provider-api-docs-url",type:"text",value:J,onChange:_=>X(_.target.value),placeholder:"https://api.example.com/docs",className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional API documentation URL. If not set, uses known provider docs."})]}),t.jsxs("div",{className:"border border-border bg-background/95 shadow-sm sticky bottom-0 flex justify-end gap-2 rounded-[8px] px-3 py-2",children:[t.jsx(ee,{type:"button",variant:"outline",onClick:s,disabled:be,children:"Cancel"}),t.jsx(ee,{type:"submit",disabled:be,children:be?"Saving...":e?"Update Provider":"Add Provider"})]})]})}const Qk=ue(["timeout","network_unreachable","connection_refused","auth_failed","rate_limited","server_error","invalid_response","unknown"]),e3=T({message:x(),type:Qk,details:x().optional(),hint:x().optional()}),t3=T({type:ue(["text","thinking"]),text:x().optional(),thinking:x().optional()}),n3=T({requestUrl:x().optional(),requestMethod:x().optional(),requestHeaders:ze(x(),x()).optional(),requestBody:x().optional(),responseStatus:E().optional(),responseStatusText:x().optional(),responseHeaders:ze(x(),x()).optional(),responseBody:x().optional()}),s3=T({success:_e(),error:e3.optional(),model:x().optional(),inputTokens:E().optional(),outputTokens:E().optional(),cacheCreationInputTokens:E().optional(),cacheReadInputTokens:E().optional(),latencyMs:E().optional(),firstChunkMs:E().nullable().optional(),totalStreamMs:E().nullable().optional(),tokensPerSecond:E().nullable().optional(),content:K(t3).optional(),rawResponse:x().optional(),streaming:_e().optional(),streamingChunks:T({chunks:K(Od),truncated:_e().default(!1)}).optional(),requestHeaders:ze(x(),x()).optional(),debug:n3.optional()}),Jc=Ot([s3,T({notConfigured:re(!0)}),T({testing:re(!0)})]),on=T({nonStreaming:Jc,streaming:Jc});function rr(){return{nonStreaming:{notConfigured:!0},streaming:{notConfigured:!0}}}const o3=T({anthropic:on,openai:on.optional(),openaiChat:on.optional(),openaiResponses:on.optional()}).transform(e=>{const n=e.openaiChat??e.openai??rr();return{...e,openai:e.openai??n,openaiChat:n,openaiResponses:e.openaiResponses??rr()}}),r3=T({anthropic:on,openai:on.optional(),openaiChat:on.optional(),openaiResponses:on.optional(),models:ze(x(),o3).optional(),testedAt:x().optional()}).transform(e=>{const n=e.openaiChat??e.openai??rr();return{...e,openai:e.openai??n,openaiChat:n,openaiResponses:e.openaiResponses??rr()}});function a3(){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 Yc(e,n){const s=()=>({nonStreaming:{success:!1,error:{message:e,type:n}},streaming:{notConfigured:!0}});return{anthropic:s(),openai:s(),openaiChat:s(),openaiResponses:s()}}const i3=T({providerConfig:x()}),l3=T({success:_e().optional(),imported:E().optional(),message:x().optional(),errors:K(x()).optional()}),c3=T({provider:Wo,imported:E(),matchedModels:K(x()),missingModels:K(x()),sourceUrl:x()}),jo="Network error: could not reach the server. Is the proxy running?",d3=5e3,u3=5e3,Xc=15e3,m3=1e4,p3=2e4,f3=2e4,h3=3e4;function Ta(e,n){return(e?.length??0)>0?e:n&&e!==void 0?"":void 0}function Zc(e,n=!1){return{name:e.name,...e.apiKey.trim()===""?{}:{apiKey:e.apiKey},models:e.models,anthropicBaseUrl:Ta(e.anthropicBaseUrl,n),openaiBaseUrl:Ta(e.openaiBaseUrl,n),openaiResponsesBaseUrl:Ta(e.openaiResponsesBaseUrl,n),apiDocsUrl:(e.apiDocsUrl?.length??0)>0?e.apiDocsUrl:void 0,modelMetadataUrl:(e.modelMetadataUrl?.length??0)>0?e.modelMetadataUrl:void 0,modelMetadata:e.modelMetadata,source:e.source}}function x3(e,n){const s=e?.models?.map(o=>o.trim()).filter(o=>o!=="").length??0;return Math.max(1,s)*n}async function g3(e,n){if(n.models!==void 0)try{await Xn(`/api/providers/${e}/test/log`,u3,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}catch{}}function b3({externalProviders:e,isLoading:n=!1,externalTestResults:s,externalTestingProviders:o,externalTestingTimeLeft:r,onProvidersMutate:a,onTestResultsChange:i,onTestingProvidersChange:c,onTestingTimeLeftChange:d}){const[m,u]=l.useState(!1),[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),[R,I]=l.useState(!1),[P,M]=l.useState(null),[k,A]=l.useState(!1),[D,$]=l.useState(!1),[J,X]=l.useState(null),[F,H]=l.useState("all"),[Y,U]=l.useState(new Set),{providerTestTimeoutSeconds:W}=Pi(),me=l.useRef(null),be=l.useRef(null),ve=e??[],z=l.useMemo(()=>{const B=F==="all"?ve:ve.filter(ne=>ne.source===F);return F==="all"?[...B].sort((ne,we)=>{const he={personal:0,company:1};return(he[ne.source??""]??2)-(he[we.source??""]??2)}):B},[ve,F]),se=s??b,te=o??w,Se=r??j,Ne=d?(B,ne)=>d(B,ne):(B,ne)=>{S(ne===void 0?we=>{const he={...we};return delete he[B],he}:we=>({...we,[B]:ne}))};l.useEffect(()=>{(async()=>{try{const B=await De("/api/config/paths",i3,d3);C(B.providerConfig)}catch{}})()},[]);const ie=l.useCallback(B=>{be.current!==null&&clearTimeout(be.current),M(B),me.current?.scrollTo({top:me.current.scrollHeight,behavior:"smooth"}),be.current=setTimeout(()=>{M(null),be.current=null},2e3)},[]);l.useEffect(()=>()=>{be.current!==null&&clearTimeout(be.current)},[]);const le=l.useCallback(()=>{a?.().catch(()=>{})},[a]),fe=l.useCallback((B,ne)=>{i?i(B,ne):y(we=>({...we,[B]:ne}))},[i]),ye=l.useCallback((B,ne)=>{if(c){c(B,ne);return}v(we=>{const he=new Set(we);return ne?he.add(B):he.delete(B),he})},[c]),Ce=l.useCallback(async B=>{fe(B,a3()),ye(B,!0);const ne=new AbortController,we=ve.find(G=>G.id===B),he=x3(we,W);let je=he;Ne(B,je);const Be=setInterval(()=>{je--,Ne(B,je),je<=0&&(clearInterval(Be),ne.abort())},1e3);try{const G=await De(`/api/providers/${B}/test`,r3,he*1e3+1e3,{method:"POST",signal:ne.signal},_=>`HTTP ${_.status}: ${_.statusText}`);fe(B,G),await g3(B,G)}catch(G){const _=G instanceof Error&&G.name==="AbortError",L=G instanceof wi;_||L?fe(B,Yc("Request timed out","timeout")):G instanceof Error&&fe(B,Yc(G.message,"server_error"))}finally{clearInterval(Be),Ne(B,void 0),ye(B,!1)}},[W,ve,Ne,fe,ye]),Ie=l.useCallback(async(B,ne,we=!0)=>{U(he=>{const je=new Set(he);return je.add(B),je});try{const he=ne!==void 0&&ne.trim()!==""?{url:ne}:{},je=await De(`/api/providers/${B}/model-metadata`,c3,h3,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(he)},()=>"Failed to refresh model metadata");return je.imported===0&&we?g("No matching model metadata found for this provider."):g(null),ie(je.provider.id),le(),je.imported>0}catch(he){return we&&g(he instanceof Error?he.message:jo),!1}finally{U(he=>{const je=new Set(he);return je.delete(B),je})}},[le,ie]);function $e(B){(async()=>{try{const ne=await De("/api/providers",Wo,Xc,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Zc(B))},()=>"Failed to add provider");u(!1),ie(ne.id),B.modelMetadataUrl!==void 0&&B.modelMetadataUrl.trim()!==""&&await Ie(ne.id,B.modelMetadataUrl,!1),le(),await Ce(ne.id)}catch(ne){g(ne instanceof Error?ne.message:jo)}})()}function Pe(B){p&&(async()=>{try{const ne=await De(`/api/providers/${p.id}`,Wo,Xc,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(Zc(B,!0))},()=>"Failed to update provider");f(void 0),ie(ne.id),B.modelMetadataUrl!==void 0&&B.modelMetadataUrl.trim()!==""&&await Ie(ne.id,B.modelMetadataUrl,!1),le(),(B.apiKey.trim()!==""||JSON.stringify(B.models)!==JSON.stringify(p.models)||(B.anthropicBaseUrl??"")!==(p.anthropicBaseUrl??"")||(B.openaiBaseUrl??"")!==(p.openaiBaseUrl??"")||(B.openaiResponsesBaseUrl??"")!==(p.openaiResponsesBaseUrl??""))&&await Ce(ne.id)}catch(ne){g(ne instanceof Error?ne.message:jo)}})()}function Ze(B){X(B),$(!0)}function Bt(){const B=J;B!==null&&(async()=>{let ne;try{ne=await Xn(`/api/providers/${B}`,m3,{method:"DELETE"})}catch{g(jo);return}if(!ne.ok){g(await kh(ne,"Failed to delete provider"));return}le()})()}const ct=l.useRef(null);function Fe(B){const ne="/api/providers/export";(async()=>{try{const we=await Xn(ne,p3);if(!we.ok){g("Failed to export providers");return}const he=await we.blob(),je=URL.createObjectURL(he),Be=document.createElement("a");Be.href=je,Be.download=we.headers.get("Content-Disposition")?.match(/filename="(.+)"/)?.[1]??"providers.json",document.body.appendChild(Be),Be.click(),document.body.removeChild(Be),URL.revokeObjectURL(je)}catch{g("Failed to export providers")}})()}function Me(){ct.current?.click()}function Le(B){const ne=B.target.files?.[0];ne&&(async()=>{try{const we=await ne.text(),he=await Xn("/api/providers/import",f3,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(we)}),je=await Ch(he,l3);he.ok&&je.imported!==void 0&&je.imported>0?(le(),g(null)):je.errors&&je.errors.length>0?g(je.errors.join("; ")):g(je.message??"Import failed")}catch{g("Failed to import providers")}B.target.value=""})()}return n?t.jsx("div",{className:"flex items-center justify-center py-8",children:t.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading providers..."})}):m||p?t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"sticky top-0 z-10 flex items-center justify-between gap-3 rounded-[8px] bg-background/95 px-1 py-1 backdrop-blur",children:t.jsx("h3",{className:"text-lg font-medium",children:p?"Edit Provider":"Add New Provider"})}),t.jsx(Zk,{provider:p,onSubmit:p?Pe:$e,onCancel:()=>{u(!1),f(void 0)}})]}):t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{"data-provider-toolbar":"true",className:"sticky top-0 z-10 flex min-w-0 flex-wrap items-center justify-start gap-2 rounded-[8px] bg-background/95 px-1 py-1 backdrop-blur sm:justify-end",children:[t.jsxs(ee,{variant:"outline",size:"sm",onClick:()=>Fe(),className:"gap-1 hover:bg-muted",children:[t.jsx(Ws,{className:"size-3"}),"Export"]}),t.jsxs(ee,{variant:"outline",size:"sm",onClick:Me,className:"gap-1 hover:bg-muted",children:[t.jsx(pu,{className:"size-3"}),"Import"]}),t.jsx("input",{type:"file",ref:ct,accept:".json",onChange:Le,style:{display:"none"}}),t.jsxs(ee,{variant:"outline",size:"sm",onClick:()=>A(!0),className:"gap-1",children:[t.jsx(Gg,{className:"size-3"}),"Scan"]}),t.jsxs(ee,{onClick:()=>u(!0),size:"sm",className:"gap-1",children:[t.jsx(Ul,{className:"size-4"}),"Add Provider"]})]}),N!==null&&t.jsxs("div",{className:"flex items-center gap-2 rounded-[8px] bg-muted/15 px-3 py-2 text-xs text-muted-foreground",children:[t.jsx("span",{className:"font-mono truncate",title:N,children:N}),t.jsx("button",{type:"button",onClick:()=>{vt(N).then(B=>{B&&(I(!0),setTimeout(()=>I(!1),2e3))})},className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-foreground","aria-label":R?"Copied config file path":"Copy config file path",children:R?t.jsx(Oe,{className:"size-3 text-status-success"}):t.jsx(St,{className:"size-3"})})]}),h!==null&&t.jsxs("div",{className:"border border-border bg-card shadow-sm flex items-center gap-2 rounded-[8px] px-3 py-2 text-sm text-destructive",children:[t.jsx(os,{className:"size-4 shrink-0"}),h]}),ve.length===0?t.jsxs("div",{className:"border border-border bg-card shadow-sm space-y-3 rounded-[8px] py-12 text-center",children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:"No providers configured yet."}),t.jsxs(ee,{onClick:()=>u(!0),variant:"outline",size:"sm",children:[t.jsx(Ul,{className:"size-4"}),"Add Your First Provider"]})]}):t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{className:"inline-flex w-fit gap-1 rounded-[8px] bg-muted/20 p-1",children:["all","personal","company"].map(B=>t.jsx("button",{type:"button",onClick:()=>H(B),className:`rounded-md px-3 py-1.5 text-sm font-medium transition-colors ${F===B?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:B==="all"?"All":B==="personal"?"Personal":"Company"},B))}),t.jsx("div",{ref:me,className:"space-y-3",children:z.map(B=>t.jsx(Fk,{provider:B,testResults:se[B.id],isTesting:te.has(B.id),testingTimeLeft:Se[B.id],isHighlighted:B.id===P,onEdit:ne=>f(ne),onDelete:Ze,onRefreshMetadata:ne=>{Ie(ne)},isRefreshingMetadata:Y.has(B.id),onTest:ne=>{Ce(ne)}},B.id))})]}),t.jsx(xk,{open:k,onOpenChange:A,onImportComplete:()=>{a!==void 0&&a()}}),t.jsx(zp,{open:D,onOpenChange:$,title:"Delete Provider",description:"Are you sure you want to delete this provider? This action cannot be undone.",confirmLabel:"Delete",variant:"destructive",onConfirm:Bt})]})}const v3=[{value:"providers",label:"Providers"},{value:"proxy",label:"Proxy"},{value:"storage",label:"Storage"},{value:"mcp",label:"MCP"},{value:"onboarding",label:"Onboarding"}];function y3(){return t.jsx(ef,{"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:v3.map(e=>t.jsx(tn,{value:e.value,className:"min-w-0 w-full",children:e.label},e.value))})}function w3(){const[e,n]=l.useState(!1),[s,o]=l.useState("providers"),{providers:r,isLoading:a,mutate:i}=Hi(),[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 t.jsxs(Pt,{open:e,onOpenChange:n,children:[t.jsx(Xs,{asChild:!0,children:t.jsxs(ee,{variant:"ghost",size:"icon",className:eo,"aria-label":"Settings",title:"Settings",children:[t.jsx(n1,{className:"size-4"}),t.jsx("span",{className:"sr-only",children:"Settings"})]})}),t.jsxs(Lt,{className:"flex max-h-[calc(100vh-1rem)] w-[calc(100%-1rem)] max-w-2xl flex-col overflow-hidden p-4 sm:max-h-[80vh] sm:p-6",children:[t.jsx(Ft,{children:t.jsx(Ut,{children:"Settings"})}),t.jsxs(Qp,{value:s,onValueChange:o,className:"min-h-0 min-w-0 flex-1 overflow-hidden",children:[t.jsx(y3,{}),t.jsxs("div",{className:"mt-4 min-w-0 flex-1 overflow-x-hidden overflow-y-auto pr-1 sm:pr-2",children:[t.jsx(ut,{value:"providers",children:t.jsx(b3,{externalProviders:r,isLoading:a,externalTestResults:c,externalTestingProviders:m,externalTestingTimeLeft:p,onProvidersMutate:()=>i(),onTestResultsChange:h,onTestingProvidersChange:g,onTestingTimeLeftChange:b})}),t.jsx(ut,{value:"proxy",children:t.jsx(_3,{})}),t.jsx(ut,{value:"storage",children:t.jsx(N3,{})}),t.jsx(ut,{value:"mcp",children:t.jsx(k3,{})}),t.jsx(ut,{value:"onboarding",children:t.jsx(C3,{})})]})]})]})]})}const j3=T({memoryCount:E(),logDir:x(),logFileCount:E(),logBytes:E(),chunkDir:x(),chunkFileCount:E(),chunkBytes:E(),sessionArchiveDir:x(),sessionArchiveFileCount:E(),sessionArchiveBytes:E()}),S3=1e4;function Ea(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 N3(){const[e,n]=l.useState(null),[s,o]=l.useState(null),[r,a]=l.useState(!1),[i,c]=l.useState(null),d=l.useCallback(async()=>{a(!0),o(null);try{const u=await De("/api/logs?stats=1",j3,S3,void 0,p=>`Failed to load storage stats: HTTP ${String(p.status)}`);n(u)}catch(u){o(u instanceof Error?u.message:String(u))}finally{a(!1)}},[]);l.useEffect(()=>{d()},[d]);const m=l.useCallback((u,p)=>{vt(p).then(f=>{f&&(c(u),setTimeout(()=>c(null),1600))})},[]);return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Log storage"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Inspect local log and streaming chunk footprint before exporting or clearing sessions."})]}),t.jsx(ee,{type:"button",variant:"outline",size:"sm",onClick:()=>{d()},children:r?"Refreshing...":"Refresh"})]}),e!==null&&t.jsxs("div",{className:"grid gap-2 text-xs",children:[t.jsx(Ts,{id:"log-dir",label:"Log storage path",value:e.logDir,copiedId:i,onCopy:m}),t.jsx(Ts,{id:"chunk-dir",label:"Streaming chunks storage path",value:e.chunkDir,copiedId:i,onCopy:m}),t.jsx(Ts,{id:"session-archive-dir",label:"Session archive storage path",value:e.sessionArchiveDir,copiedId:i,onCopy:m}),t.jsxs("div",{className:"rounded-md bg-muted/20 px-3 py-2",children:[t.jsx("div",{className:"font-medium",children:"In-memory logs"}),t.jsxs("div",{className:"mt-1 font-mono text-muted-foreground",children:[e.memoryCount.toLocaleString()," loaded"]})]}),t.jsxs("div",{className:"rounded-md bg-muted/20 px-3 py-2",children:[t.jsx("div",{className:"font-medium",children:"Log files"}),t.jsxs("div",{className:"mt-1 font-mono text-muted-foreground",children:[e.logFileCount.toLocaleString()," files / ",Ea(e.logBytes)]})]}),t.jsxs("div",{className:"rounded-md bg-muted/20 px-3 py-2",children:[t.jsx("div",{className:"font-medium",children:"Streaming chunks"}),t.jsxs("div",{className:"mt-1 font-mono text-muted-foreground",children:[e.chunkFileCount.toLocaleString()," files / ",Ea(e.chunkBytes)]})]}),t.jsxs("div",{className:"rounded-md bg-muted/20 px-3 py-2",children:[t.jsx("div",{className:"font-medium",children:"Session archives"}),t.jsxs("div",{className:"mt-1 font-mono text-muted-foreground",children:[e.sessionArchiveFileCount.toLocaleString()," files /"," ",Ea(e.sessionArchiveBytes)]})]})]}),s!==null&&t.jsx("p",{className:"text-xs text-destructive",children:s})]})}function Ts({id:e,label:n,value:s,copiedId:o,onCopy:r}){const a=o===e;return t.jsxs("div",{className:"min-w-0 rounded-md border border-border/45 bg-muted/15 px-3 py-2 transition-colors hover:bg-muted/25",children:[t.jsx("div",{className:"mb-1 text-xs font-medium text-muted-foreground",children:n}),t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs text-foreground",title:s,children:s}),t.jsx(ee,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0",onClick:()=>r(e,s),"aria-label":a?`Copied ${n}`:`Copy ${n}`,children:a?t.jsx(Oe,{className:"size-3.5 text-status-success"}):t.jsx(St,{className:"size-3.5"})})]})]})}function C3(){const[e,n]=l.useState(null),[s,o]=l.useState(null);l.useEffect(()=>$i(o),[]);const r=l.useMemo(()=>[{id:"status",label:"Check onboarding",value:"agent-inspector onboard --status"},{id:"status-json",label:"Check onboarding JSON",value:"agent-inspector onboard --status --json"},{id:"refresh",label:"Refresh generated files",value:"agent-inspector onboard --force"},{id:"uninstall",label:"Remove matching generated files",value:"agent-inspector onboard --uninstall"},{id:"claude",label:"Claude Code command",value:"/agent-inspector:onboard"},{id:"codex",label:"Codex prompt",value:"Use the agent-inspector-onboard skill"},{id:"opencode-config",label:"OpenCode config",value:"agent-inspector onboard --opencode-only"},{id:"opencode-status",label:"OpenCode status",value:"agent-inspector onboard --status --opencode-only"},{id:"opencode-verify",label:"OpenCode verify",value:"opencode mcp list"},{id:"mimo-config",label:"MiMo Code config",value:"agent-inspector onboard --mimo-only"},{id:"mimo-status",label:"MiMo Code status",value:"agent-inspector onboard --status --mimo-only"},{id:"mimo-verify",label:"MiMo Code verify",value:"mimo mcp list"},...s===null?[]:[{id:"opencode-proxy",label:"OpenCode proxy",value:`LLM_BASE_URL=${s.proxy}`},{id:"mimo-proxy",label:"MiMo Code proxy",value:`OPENAI_BASE_URL=${s.openAiV1}`},{id:"mcp",label:"MCP URL",value:s.mcp},{id:"proxy",label:"Proxy URL",value:s.proxy},{id:"anthropic",label:"Anthropic base",value:`ANTHROPIC_BASE_URL=${s.proxy}`},{id:"openai",label:"OpenAI base",value:`OPENAI_BASE_URL=${s.openAiV1}`}]],[s]),a=l.useCallback((i,c)=>{vt(c).then(d=>{d&&(n(i),setTimeout(()=>n(null),1600))})},[]);return t.jsxs("div",{className:"min-w-0 space-y-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(In,{className:"size-4 text-muted-foreground"}),t.jsx("h3",{className:"text-sm font-semibold",children:"Agent onboarding"})]}),t.jsx("div",{className:"grid gap-2",children:r.map(i=>t.jsx(Ts,{id:i.id,label:i.label,value:i.value,copiedId:e,onCopy:a},i.id))}),t.jsxs("div",{className:"grid gap-2 rounded-md bg-muted/15 px-3 py-2 text-xs text-muted-foreground",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Oe,{className:"size-3.5 text-status-success"}),t.jsx("span",{children:"Provider test creates a traceable memory probe session."})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Oe,{className:"size-3.5 text-status-success"}),t.jsx("span",{children:"Captured sessions can produce reviewable memory candidates."})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(Oe,{className:"mt-0.5 size-3.5 text-status-success"}),t.jsxs("span",{children:["Streamable HTTP clients should use the MCP URL directly. Stdio-only clients should use",t.jsx("code",{className:"mx-1 rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"agent-inspector-mcp stdio"}),"instead. Configure only one entry for the same Inspector."]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(Oe,{className:"mt-0.5 size-3.5 text-status-success"}),t.jsxs("span",{children:["OpenCode onboarding safely merges"," ",t.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"mcp.agent-inspector"})," ","into"," ",t.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"opencode.json"}),", then verify with"," ",t.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"opencode mcp list"}),"."]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(Oe,{className:"mt-0.5 size-3.5 text-status-success"}),t.jsxs("span",{children:["MiMo Code onboarding safely merges"," ",t.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"mcp.agent-inspector"})," ","into"," ",t.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"mimocode.jsonc"}),", then route OpenAI-format traffic with"," ",t.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"OPENAI_BASE_URL"}),"."]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(Oe,{className:"mt-0.5 size-3.5 text-status-success"}),t.jsx("span",{children:"If your AI tool runs in another container or host, replace localhost with an address reachable from that tool and verify the network/firewall path."})]})]})]})}function k3(){const[e,n]=l.useState(null),[s,o]=l.useState(null);l.useEffect(()=>$i(i=>{o(i?.mcp??null)}),[]);const r=l.useMemo(()=>s===null?[]:[{id:"mcp-url",label:"Streamable HTTP MCP URL",value:s},{id:"stdio",label:"Stdio bridge command",value:`agent-inspector-mcp stdio --url ${s}`},{id:"doctor",label:"Bridge doctor",value:`agent-inspector-mcp doctor --url ${s}`},{id:"writes",label:"Enable write tools",value:"AGENT_INSPECTOR_MCP_WRITES=1 agent-inspector"},{id:"capabilities",label:"Capabilities resource",value:"inspector://mcp/capabilities"},{id:"context",label:"Current context resource",value:"inspector://context/current"},{id:"streamable-json",label:"Streamable HTTP JSON",value:JSON.stringify({mcpServers:{"agent-inspector":{type:"streamableHttp",url:s}}},null,2)},{id:"stdio-json",label:"Stdio MCP JSON",value:JSON.stringify({mcpServers:{"agent-inspector":{command:"agent-inspector-mcp",args:["stdio","--url",s]}}},null,2)},{id:"opencode-local",label:"OpenCode local MCP",value:JSON.stringify({mcp:{"agent-inspector":{type:"local",command:["agent-inspector-mcp","stdio","--url",s],enabled:!0}}},null,2)},{id:"mimo-local",label:"MiMo Code local MCP",value:JSON.stringify({mcp:{"agent-inspector":{type:"local",command:["agent-inspector-mcp","stdio","--url",s],enabled:!0}}},null,2)},{id:"codex-toml",label:"Codex TOML",value:`[mcp_servers.agent-inspector]
|
|
58
|
-
command = "agent-inspector-mcp"
|
|
59
|
-
args = ["stdio", "--url", "${s}"]`}],[s]),a=l.useCallback((i,c)=>{vt(c).then(d=>{d&&(n(i),setTimeout(()=>n(null),1600))})},[]);return t.jsxs("div",{className:"min-w-0 space-y-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(In,{className:"size-4 text-muted-foreground"}),t.jsx("h3",{className:"text-sm font-semibold",children:"MCP access"})]}),t.jsxs("div",{className:"grid gap-2 rounded-md bg-muted/15 px-3 py-2 text-xs text-muted-foreground",children:[t.jsx("div",{children:"Use Streamable HTTP when the client supports URL-based MCP. Use the stdio bridge only for stdio-only clients. Configure one entry for the same Inspector instance."}),t.jsx("div",{children:"If the MCP client runs in another container or host, replace localhost with a reachable host/IP and verify the network path."})]}),s===null?t.jsx("div",{role:"alert",className:"rounded-md bg-destructive/10 px-3 py-2 text-xs text-destructive",children:"The browser runtime does not provide a valid agent-facing MCP endpoint."}):t.jsx("div",{className:"grid gap-2",children:r.map(i=>t.jsx(Ts,{id:i.id,label:i.label,value:i.value,copiedId:e,onCopy:a},i.id))})]})}function _3(){const{strip:e,slowResponseThresholdSeconds:n,providerTestTimeoutSeconds:s,timeDisplayFormat:o,isLoading:r,setStrip:a,setSlowResponseThresholdSeconds:i,setProviderTestTimeoutSeconds:c,setTimeDisplayFormat:d}=Pi(),[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 t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Claude Code billing header"}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Strip Claude Code's synthetic billing block before upstream forwarding. This can improve prefix-cache hits with third-party providers and is persisted to ",t.jsx("code",{children:"config.json"}),"."]})]}),t.jsxs("label",{className:"flex items-center gap-3",children:[t.jsx("input",{type:"checkbox",role:"switch",checked:e,disabled:r||p,onChange:w=>{h(w.currentTarget.checked)},className:"size-4 cursor-pointer disabled:cursor-not-allowed disabled:opacity-50"}),t.jsx("span",{className:"text-sm",children:r?"Loading...":e?"Stripping enabled":"Stripping disabled"})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{htmlFor:"slow-response-threshold",className:"text-sm font-semibold",children:"Slow response threshold"}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Show a slow marker when elapsed time exceeds this many seconds. Use ",t.jsx("code",{children:"0"})," to disable it."]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{id:"slow-response-threshold",type:"number",min:0,max:Da,step:1,value:n,disabled:r||p,onChange:w=>{const v=Number(w.currentTarget.value);Number.isInteger(v)&&(v<0||v>Da||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"}),t.jsx("span",{className:"text-xs text-muted-foreground",children:"seconds"})]})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{htmlFor:"provider-test-timeout",className:"text-sm font-semibold",children:"Provider test timeout"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Abort slow Provider Test probes after this many seconds per model."}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{id:"provider-test-timeout",type:"number",min:1,max: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"}),t.jsx("span",{className:"text-xs text-muted-foreground",children:"seconds / model"})]})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{htmlFor:"time-display-format",className:"text-sm font-semibold",children:"Time display"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Controls timestamps in session summaries, headers, and log rows."}),t.jsxs("select",{id:"time-display-format",value:o,disabled:r||p,onChange:w=>{const v=Qd.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:[t.jsx("option",{value:"time",children:"Time only"}),t.jsx("option",{value:"full",children:"Full ISO"})]})]}),m!==null&&t.jsxs("p",{className:"text-xs text-destructive",children:["Failed to save: ",m]})]})}const T3=ue(["installed","update-available","available","planned","unknown"]),E3=T({id:x(),name:x(),npmName:x(),capability:x(),description:x(),workflow:x(),installCommand:x(),state:T3,installedVersion:x().nullable(),latestVersion:x().nullable(),primary:_e()}),R3=T({id:x(),name:x(),validatedVersion:x(),binary:x(),modelFlag:x(),variantFlag:x().nullable(),tools:K(x()),logDir:x(),skillsDir:x(),agentsDir:x()}),M3=T({id:x(),title:x(),stage:x(),packageId:x(),description:x(),command:x(),requiresSession:_e(),runnable:_e()}),A3=T({checkedAt:x(),packages:K(E3),runnerPresets:K(R3),recipes:K(M3)}),Af=ue(["install","upgrade","help","runner-presets","recipe"]),If="RUN_LOCAL_COMMAND",I3=T({action:Af,targetId:x(),targetName:x(),command:x(),source:x(),timeoutMs:E().int().positive(),scope:x()}),P3=T({nonce:x().uuid(),phrase:re(If),expiresAt:x().datetime(),plan:I3}),Pf=T({confirmation:P3});un("intent",[T({intent:re("prepare")}),T({intent:re("confirm"),nonce:x().uuid(),confirmation:re(If)})]);const L3=ue(["queued","running","succeeded","failed"]),Lf=T({id:x(),packageId:x(),npmName:x(),recipeId:x().nullable().default(null),action:Af,status:L3,command:x(),output:x(),createdAt:x(),startedAt:x().nullable(),finishedAt:x().nullable(),exitCode:E().nullable(),error:x().nullable()}),Of=T({task:Lf}),O3=T({tasks:K(Lf)}),D3=[{id:"observe",title:"Observe",label:"Live",description:"Capture IDE, process, session, turn, request, response, tools, and providers.",metric:"Inspector core",icon:Lx},{id:"replay",title:"Replay",label:"Ready",description:"Promote real logs into repeatable replay evidence without losing the raw context.",metric:"Session asset",icon:yt},{id:"evaluate",title:"Evaluate",label:"Next",description:"Use eval-harness to turn sessions into regression cases and provider bakeoffs.",metric:"Eval loop",icon:Li},{id:"connect",title:"Connect",label:"MCP",description:"Expose Inspector state to coding agents as queryable context and durable evidence.",metric:"/api/mcp",icon:_g}];async function z3(e){return Ge(e,A3,void 0,n=>`Failed to load ecosystem packages: ${String(n.status)}`)}async function $3(e){return Ge(e,Of,void 0,n=>`Failed to load ecosystem task: ${String(n.status)}`)}async function F3(e){return Ge(e,O3,void 0,n=>`Failed to load ecosystem tasks: ${String(n.status)}`)}async function U3(e,n){const s=`/api/ecosystem/packages/${encodeURIComponent(e)}/${n}`,o=await Ge(s,Pf,{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 B3(e){const n=`/api/ecosystem/recipes/${encodeURIComponent(e)}/run`,s=await Ge(n,Pf,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({intent:"prepare"})},o=>`Failed to prepare ecosystem recipe: ${String(o.status)}`);return{endpoint:n,confirmation:s.confirmation}}async function q3(e){return(await Ge(e.endpoint,Of,{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 H3(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 W3(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 V3(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 Es(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 K3(e){switch(e.status){case"queued":return"Queued";case"running":return`${Es(e.action)} running`;case"succeeded":return`${Es(e.action)} complete`;case"failed":return`${Es(e.action)} failed`}}function Df(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 G3(e){switch(e.state){case"available":return"install";case"update-available":return"upgrade";case"installed":case"planned":case"unknown":return null}}function J3({pkg:e,activeTask:n,onStartTask:s}){const o=G3(e),r=n!==null&&n.packageId===e.id&&n.status==="running";return t.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[t.jsx(Mg,{className:"size-4 shrink-0 text-white/55"}),t.jsx("div",{className:"text-sm font-semibold leading-snug",children:e.name})]}),t.jsx("div",{className:"mt-1 break-all font-mono text-[11px] leading-snug text-white/35",children:e.npmName})]}),t.jsx(ke,{className:O("shrink-0",W3(e.state)),variant:"outline",children:H3(e.state)})]}),t.jsx("div",{className:"mt-3 text-xs leading-5 text-muted-foreground",children:e.description}),t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2 text-[11px]",children:[t.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 font-mono text-white/50",children:V3(e)}),t.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 text-white/45",children:e.capability}),t.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 font-mono text-white/35",children:e.installCommand})]}),t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[o!==null&&t.jsxs(ee,{type:"button",size:"sm",variant:"secondary",disabled:r,onClick:()=>s(e.id,o),children:[r?t.jsx(Ae,{className:"size-3.5 animate-spin"}):t.jsx(Ws,{className:"size-3.5"}),Es(o)]}),t.jsxs(ee,{type:"button",size:"sm",variant:"outline",disabled:r||e.state==="planned",onClick:()=>s(e.id,"help"),children:[t.jsx(In,{className:"size-3.5"}),"Help"]}),e.id==="eval-harness"&&t.jsxs(ee,{type:"button",size:"sm",variant:"ghost",disabled:r||e.state==="planned",onClick:()=>s(e.id,"runner-presets"),children:[t.jsx(Li,{className:"size-3.5"}),"Presets"]})]})]})}function Y3({task:e}){if(e===null)return null;const n=e.status==="queued"||e.status==="running";return t.jsxs("section",{className:"mt-3 rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n?t.jsx(Ae,{className:"size-4 animate-spin text-cyan-200/75"}):t.jsx(In,{className:"size-4 text-white/55"}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-sm font-semibold",children:K3(e)}),t.jsx("div",{className:"break-all font-mono text-[11px] text-white/35",children:e.command})]})]}),t.jsx(ke,{variant:"outline",className:O("shrink-0",Df(e.status)),children:e.status})]}),t.jsx("pre",{className:"mt-3 max-h-56 overflow-auto whitespace-pre-wrap rounded-md bg-black/30 p-3 font-mono text-[11px] leading-5 text-white/60 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:e.output.trim().length>0?e.output:"Waiting for npm output..."}),e.error!==null&&t.jsx("div",{className:"mt-2 text-xs text-red-100",children:e.error})]})}function X3({workflow:e}){const n=e.icon;return t.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(n,{className:"size-4 shrink-0 text-cyan-200/75"}),t.jsx("div",{className:"text-sm font-semibold",children:e.title})]}),t.jsx("span",{className:"rounded bg-white/[0.04] px-2 py-0.5 font-mono text-[10px] text-white/45",children:e.label})]}),t.jsx("div",{className:"mt-2 min-h-10 text-xs leading-5 text-muted-foreground",children:e.description}),t.jsx("div",{className:"mt-3 font-mono text-[11px] text-white/35",children:e.metric})]})}function Z3(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 Q3({preset:e}){return t.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[t.jsx(du,{className:"size-4 shrink-0 text-cyan-200/75"}),t.jsx("div",{className:"text-sm font-semibold leading-snug",children:e.name})]}),t.jsxs("div",{className:"mt-1 break-all font-mono text-[11px] leading-snug text-white/35",children:[e.binary," ",e.modelFlag,e.variantFlag!==null?` ${e.variantFlag}`:""]})]}),t.jsxs(ke,{variant:"outline",className:"border-white/10 bg-white/[0.04] text-white/55",children:["v",e.validatedVersion]})]}),t.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-[11px]",children:[t.jsxs("div",{className:"rounded bg-black/15 px-2 py-1 text-white/45",children:["logs/",e.logDir]}),t.jsx("div",{className:"rounded bg-black/15 px-2 py-1 text-white/45",children:e.tools.join(", ")}),t.jsx("div",{className:"rounded bg-black/15 px-2 py-1 font-mono text-white/35",children:e.skillsDir}),t.jsx("div",{className:"rounded bg-black/15 px-2 py-1 font-mono text-white/35",children:e.agentsDir})]})]})}function e4({recipe:e,copied:n,running:s,onCopy:o,onRun:r}){return t.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[t.jsx(ru,{className:"size-4 shrink-0 text-cyan-200/75"}),t.jsx("div",{className:"text-sm font-semibold leading-snug",children:e.title})]}),t.jsx("div",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:e.description})]}),t.jsx(ke,{variant:"outline",className:"border-white/10 bg-white/[0.04] text-white/55",children:e.runnable?e.stage:"Template"})]}),t.jsx("div",{className:"mt-3 rounded-md bg-black/20 p-2 font-mono text-[11px] leading-5 text-white/50 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:e.command}),t.jsxs("div",{className:"mt-3 flex items-center justify-between gap-2",children:[t.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 font-mono text-[11px] text-white/35",children:e.packageId}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(ee,{type:"button",size:"sm",variant:"outline",onClick:()=>o(e),children:[n?t.jsx(Oe,{className:"size-3.5"}):t.jsx(St,{className:"size-3.5"}),n?"Copied":"Copy"]}),e.runnable&&t.jsxs(ee,{type:"button",size:"sm",variant:"secondary",disabled:s,onClick:()=>r(e),children:[s?t.jsx(Ae,{className:"size-3.5 animate-spin"}):t.jsx(du,{className:"size-3.5"}),s?"Running":"Run"]})]})]})]})}function t4({task:e,selected:n,onSelect:s}){const o=e.recipeId??Es(e.action);return t.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md bg-white/[0.025] px-3 py-2 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(iu,{className:"size-3.5 shrink-0 text-white/40"}),t.jsx("div",{className:"truncate text-xs font-semibold text-white/75",children:o}),t.jsx(ke,{variant:"outline",className:O("shrink-0",Df(e.status)),children:e.status})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-2 font-mono text-[10px] text-white/35",children:[t.jsx("span",{children:e.packageId}),t.jsx("span",{children:new Date(e.createdAt).toLocaleTimeString()}),e.exitCode!==null&&t.jsxs("span",{children:["exit ",String(e.exitCode)]})]})]}),t.jsx(ee,{type:"button",size:"sm",variant:n?"secondary":"outline",onClick:()=>s(e),children:n?"Open":"View"})]})}function n4({pending:e,busy:n,onOpenChange:s,onConfirm:o}){const r=e?.confirmation.plan??null;return t.jsx(Pt,{open:e!==null,onOpenChange:s,children:t.jsxs(Lt,{className:"max-w-xl",children:[t.jsxs(Ft,{children:[t.jsx(Ut,{children:"Confirm local command"}),t.jsx(Zs,{children:"Review the exact allowlisted action Agent Inspector will run on this machine."})]}),r!==null&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[t.jsxs("div",{className:"rounded-md border bg-muted/30 p-3",children:[t.jsx("div",{className:"text-muted-foreground",children:"Source"}),t.jsx("div",{className:"mt-1 break-words font-medium",children:r.source})]}),t.jsxs("div",{className:"rounded-md border bg-muted/30 p-3",children:[t.jsx("div",{className:"text-muted-foreground",children:"Timeout"}),t.jsxs("div",{className:"mt-1 font-medium",children:[String(r.timeoutMs/1e3)," seconds"]})]}),t.jsxs("div",{className:"rounded-md border bg-muted/30 p-3 sm:col-span-2",children:[t.jsx("div",{className:"text-muted-foreground",children:"Affected scope"}),t.jsx("div",{className:"mt-1 font-medium",children:r.scope})]})]}),t.jsxs("div",{children:[t.jsx("div",{className:"mb-1 text-xs font-medium",children:"Resolved command"}),t.jsx("pre",{className:"max-h-32 overflow-auto whitespace-pre-wrap break-all rounded-md bg-black/80 p-3 font-mono text-xs leading-5 text-white/80",children:r.command})]}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Confirmation phrase: ",t.jsx("code",{children:e?.confirmation.phrase}),". The one-time confirmation expires at"," ",new Date(e?.confirmation.expiresAt??"").toLocaleTimeString(),"."]})]}),t.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[t.jsx(ee,{type:"button",variant:"outline",disabled:n,onClick:()=>s(!1),children:"Cancel"}),t.jsxs(ee,{type:"button",variant:"secondary",disabled:n||r===null,onClick:o,children:[n?t.jsx(Ae,{className:"size-3.5 animate-spin"}):t.jsx(In,{className:"size-3.5"}),n?"Starting":"Confirm & Run"]})]})]})})}function s4({currentSessionId:e,logCount:n,labelledTrigger:s=!1}){const[o,r]=l.useState(!1),[a,i]=l.useState(!1),[c,d]=l.useState(!1),[m,u]=l.useState(null),[p,f]=l.useState(null),[h,g]=l.useState(null),[b,y]=l.useState(null),[w,v]=l.useState(!1),j=Et("/api/ecosystem/packages",z3,{revalidateOnFocus:!1,revalidateIfStale:!1}),S=Et(p===null?null:`/api/ecosystem/tasks/${p}`,$3,{refreshInterval:U=>{const W=U?.task;return W!==void 0&&(W.status==="queued"||W.status==="running")?900:0},revalidateOnFocus:!1}),N=Et(o?"/api/ecosystem/tasks":null,F3,{refreshInterval:2500,revalidateOnFocus:!1}),C=j.data?.packages??[],R=j.data?.runnerPresets??[],I=j.data?.recipes??[],P=(N.data?.tasks??[]).slice(0,6),M=l.useMemo(()=>C.filter(U=>U.state==="installed"||U.state==="update-available").length,[C]),k=Z3(e),A="npx @tonyclaw/eval-harness runner-presets",D=()=>{vt(k).then(()=>{i(!0),window.setTimeout(()=>i(!1),1200)})},$=()=>{vt(A).then(()=>{d(!0),window.setTimeout(()=>d(!1),1200)})},J=U=>{vt(U.command).then(()=>{u(U.id),window.setTimeout(()=>u(null),1200)})},X=U=>{g(null),B3(U.id).then(W=>{y(W)}).catch(W=>{g(W instanceof Error?W.message:"Failed to prepare ecosystem recipe")})},F=S.data?.task??null;l.useEffect(()=>{F!==null&&(N.mutate(),F.status==="succeeded"&&j.mutate())},[F,j,N]);const H=(U,W)=>{g(null),U3(U,W).then(me=>{y(me)}).catch(me=>{g(me instanceof Error?me.message:"Failed to prepare ecosystem task")})},Y=()=>{b!==null&&(g(null),v(!0),q3(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 t.jsxs(Pt,{open:o,onOpenChange:r,children:[t.jsx(Xs,{asChild:!0,children:t.jsxs(ee,{variant:"ghost",size:s?"default":"icon",className:O(eo,s&&"w-auto gap-2 px-3 text-xs max-lg:h-11 max-lg:w-auto"),"aria-label":"TonyClaw Lab",title:"TonyClaw Lab",children:[t.jsx(ru,{className:"size-4"}),t.jsx("span",{className:s?"":"sr-only",children:"Lab"})]})}),t.jsxs(Lt,{className:"flex max-h-[84vh] max-w-5xl flex-col overflow-hidden",children:[t.jsx(Ft,{children:t.jsxs(Ut,{className:"flex items-center gap-2",children:[t.jsx(Fa,{className:"size-4 text-cyan-200/80"}),"TonyClaw Lab"]})}),t.jsxs("div",{className:"overflow-y-auto pr-2",children:[t.jsxs("div",{className:"grid gap-3 lg:grid-cols-[1.1fr_0.9fr]",children:[t.jsxs("section",{className:"rounded-lg bg-white/[0.025] p-4 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-semibold",children:"Session asset pipeline"}),t.jsx("div",{className:"mt-1 max-w-2xl text-xs leading-5 text-muted-foreground",children:"Treat captured traffic as durable assets: observe it, replay it, evaluate it, and expose it back to agents through MCP."})]}),t.jsxs(ke,{variant:"outline",className:"border-cyan-300/20 bg-cyan-300/8 text-cyan-100",children:[String(M),"/",String(C.length)," packages"]})]}),t.jsx("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:D3.map(U=>t.jsx(X3,{workflow:U},U.id))})]}),t.jsxs("section",{className:"rounded-lg bg-white/[0.025] p-4 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-semibold",children:"Current session"}),t.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:e===null?"MCP smoke command":e})]}),t.jsxs(ke,{variant:"outline",className:"border-white/10 bg-white/[0.04] text-white/55",children:[String(n)," logs"]})]}),t.jsx("div",{className:"mt-4 rounded-md bg-black/20 p-3 font-mono text-[11px] leading-5 text-white/55 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:k}),t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[t.jsxs(ee,{size:"sm",variant:"secondary",onClick:D,children:[a?t.jsx(Oe,{className:"size-3.5"}):t.jsx(St,{className:"size-3.5"}),a?"Copied":"Copy"]}),t.jsxs(ee,{size:"sm",variant:"outline",onClick:$,children:[t.jsx(Li,{className:"size-3.5"}),c?"Presets copied":"Runner Presets"]})]})]})]}),t.jsxs("section",{className:"mt-3",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[t.jsx("div",{className:"text-sm font-semibold",children:"Lab recipes"}),t.jsxs("div",{className:"hidden items-center gap-1 font-mono text-[11px] text-muted-foreground sm:flex",children:[t.jsx(Fa,{className:"size-3.5"}),"copy-ready workflows"]})]}),t.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[I.map(U=>t.jsx(e4,{recipe:U,copied:m===U.id,running:F!==null&&F.recipeId===U.id&&(F.status==="queued"||F.status==="running"),onCopy:J,onRun:X},U.id)),j.isLoading&&I.length===0&&[0,1].map(U=>t.jsx("div",{className:"h-40 animate-pulse rounded-lg bg-white/[0.025] shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]"},U))]})]}),t.jsxs("section",{className:"mt-3",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[t.jsx("div",{className:"text-sm font-semibold",children:"Runner presets"}),t.jsxs("div",{className:"hidden items-center gap-1 font-mono text-[11px] text-muted-foreground sm:flex",children:[t.jsx(In,{className:"size-3.5"}),A]})]}),t.jsxs("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:[R.map(U=>t.jsx(Q3,{preset:U},U.id)),j.isLoading&&R.length===0&&[0,1,2,3].map(U=>t.jsx("div",{className:"h-32 animate-pulse rounded-lg bg-white/[0.025] shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]"},U))]})]}),t.jsxs("section",{className:"mt-3",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[t.jsx("div",{className:"text-sm font-semibold",children:"TonyClaw packages"}),j.isLoading&&t.jsx("div",{className:"font-mono text-[11px] text-muted-foreground",children:"checking npm..."})]}),j.error!==void 0&&t.jsx("div",{className:"rounded-lg bg-red-500/8 p-3 text-xs text-red-100 shadow-[inset_0_0_0_1px_rgba(248,113,113,0.16)]",children:"Package status is temporarily unavailable."}),t.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[C.map(U=>t.jsx(J3,{pkg:U,activeTask:F,onStartTask:H},U.id)),j.isLoading&&C.length===0&&[0,1,2].map(U=>t.jsx("div",{className:"h-36 animate-pulse rounded-lg bg-white/[0.025] shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]"},U))]})]}),h!==null&&t.jsx("div",{className:"mt-3 rounded-lg bg-red-500/8 p-3 text-xs text-red-100 shadow-[inset_0_0_0_1px_rgba(248,113,113,0.16)]",children:h}),P.length>0&&t.jsxs("section",{className:"mt-3",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[t.jsx("div",{className:"text-sm font-semibold",children:"Recent Lab runs"}),t.jsxs("div",{className:"hidden font-mono text-[11px] text-muted-foreground sm:block",children:["last ",String(P.length)]})]}),t.jsx("div",{className:"grid gap-2 md:grid-cols-2",children:P.map(U=>t.jsx(t4,{task:U,selected:p===U.id,onSelect:W=>{f(W.id),S.mutate({task:W},{revalidate:!0})}},U.id))})]}),t.jsx(Y3,{task:F})]})]}),t.jsx(n4,{pending:b,busy:w,onOpenChange:U=>{!U&&!w&&y(null)},onConfirm:Y})]})}function o4(e){return[...new Set(e.evidence.map(n=>n.logId).filter(n=>n!==null))]}const r4=[{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?"}],a4=4e3,Ra=12;function Qc(){return{messages:[],question:"",error:null}}function i4(e){return e.filter(n=>n.content.trim().length>0).slice(-10).map(n=>({role:n.role,content:n.content.trim().slice(0,a4)}))}function Ye(e,...n){for(const s of n){const o=Z(e,s);if(typeof o=="string"&&o.trim().length>0)return o}return null}function nn(e,...n){for(const s of n){const o=Z(e,s);if(typeof o=="number"&&Number.isFinite(o))return o}return null}function l4(e,n){const s=Z(e,n);return Array.isArray(s)?s.filter(o=>typeof o=="string").slice(0,8):[]}function c4(e){const n=Ye(e,"source")??"log",s=Ye(e,"id")??"",o=nn(e,"logId","id");if(s===""&&o===null||o!==null&&(!Number.isInteger(o)||o<0))return null;const r=nn(e,"inputTokens"),a=nn(e,"outputTokens"),i=nn(e,"totalTokens","tokenCount"),c=nn(e,"responseStatus","status"),d=Ye(e,"responseStatus","status");return{source:n,id:s!==""?s:String(o),logId:o,sessionId:Ye(e,"sessionId"),timestamp:Ye(e,"timestamp"),model:Ye(e,"model"),providerName:Ye(e,"providerName","provider"),path:Ye(e,"path"),status:c??d,elapsedMs:nn(e,"elapsedMs","latencyMs"),inputTokens:r,outputTokens:a,totalTokens:i??(r===null&&a===null?null:(r??0)+(a??0)),score:nn(e,"score","relevanceScore"),matchedFields:l4(e,"matchedFields"),excerpt:Ye(e,"excerpt","snippet")??"No excerpt available."}}function Ma(e){const n=e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim();return n.length===0?"Metric":`${n[0]?.toUpperCase()??""}${n.slice(1)}`}function ed(e){if(typeof e=="number"&&Number.isFinite(e))return e.toLocaleString();if(typeof e=="string"&&e.trim().length>0)return e;if(typeof e=="boolean")return e?"Yes":"No";if(Array.isArray(e)){const n=e.filter(s=>typeof s=="string"||typeof s=="number"&&Number.isFinite(s)).slice(0,6);return n.length>0?n.join(", "):null}return null}function td(e){return Object.getOwnPropertyNames(e).map(n=>[n,Z(e,n)])}function nd(e){if(e===null||typeof e!="object"||Array.isArray(e))return[];const n=[];for(const[s,o]of td(e)){const r=ed(o);if(r!==null){if(n.push({key:s,label:Ma(s),value:r}),n.length>=Ra)break;continue}if(!(o===null||typeof o!="object"||Array.isArray(o))){for(const[a,i]of td(o)){const c=ed(i);if(c===null)continue;const d=`${s}.${a}`;if(n.push({key:d,label:`${Ma(s)} ${Ma(a).toLowerCase()}`,value:c}),n.length>=Ra)break}if(n.length>=Ra)break}}return n}function d4(e){const n=Ye(e,"answer"),s=Ye(e,"providerId"),o=Ye(e,"providerName"),r=Ye(e,"model"),a=Ye(e,"protocol"),i=nn(e,"logCount");if(n===null||s===null||o===null||r===null||a===null||i===null)return null;const c=Z(e,"evidence"),d=Array.isArray(c)?c.map(c4).filter(m=>m!==null).slice(0,12):[];return{answer:n,providerId:s,providerName:o,model:r,protocol:a,logCount:i,evidence:d,summaryMetrics:nd(Z(e,"summary")),queryMetrics:nd(Z(e,"queryStats"))}}const u4=l.lazy(()=>Dt(()=>import("./index-CwOAPU17.js"),__vite__mapDeps([10,1,2]),import.meta.url)),m4="prose prose-sm dark:prose-invert max-w-none text-[13px] leading-[1.65] [&_pre]:bg-muted [&_pre]:text-foreground [&_code]:text-[0.8em] [&_p]:my-1 [&_p]:leading-[1.65] [&_ul]:my-1 [&_ol]:my-1 [&_li]:my-0.5 [&_li]:leading-[1.6]";function p4({text:e}){return t.jsx("div",{className:m4,children:t.jsx(l.Suspense,{fallback:t.jsx("span",{className:"text-xs text-muted-foreground",children:"Loading Markdown..."}),children:t.jsx(u4,{children:e})})})}const sd="What looks abnormal, slow, or likely to hang?";function f4(e){return e.openaiResponsesBaseUrl!==void 0||e.openaiBaseUrl!==void 0||e.anthropicBaseUrl!==void 0}function h4(e){return e.openaiResponsesBaseUrl!==void 0&&e.openaiResponsesBaseUrl!==""?"Responses":e.openaiBaseUrl!==void 0&&e.openaiBaseUrl!==""?"Chat":"Anthropic"}function x4(e){return e.toSorted((n,s)=>{const o=n.source==="company"?0:1,r=s.source==="company"?0:1;return o!==r?o-r:n.name.localeCompare(s.name)})}function od(e){return`${e}-${String(Date.now())}-${String(Math.random()).slice(2)}`}function Cn({label:e,value:n,tone:s="muted"}){return t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 font-mono text-[10px]",children:[t.jsx("span",{className:s==="cyan"?"text-cyan-100":"text-muted-foreground",children:e}),n!==void 0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-muted-foreground/55",children:":"}),t.jsx("span",{className:"truncate text-muted-foreground",children:n})]})]})}function g4({metrics:e}){return e.length===0?null:t.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:e.slice(0,8).map(n=>t.jsxs("div",{className:"rounded-sm bg-black/25 px-2 py-1 shadow-[inset_2px_0_0_rgba(103,232,249,0.22)]",children:[t.jsx("div",{className:"truncate font-mono text-[9px] text-muted-foreground",children:n.label}),t.jsx("div",{className:"truncate font-mono text-[11px] text-cyan-50/95",children:n.value})]},n.key))})}function b4({evidence:e}){const n=()=>{e.logId!==null&&ds({logId:e.logId,tab:"anatomy"})},s=e.logId===null?`${e.source}:${e.id}`:`${e.source}:log #${String(e.logId)}`;return t.jsxs("button",{type:"button",onClick:n,disabled:e.logId===null,className:"w-full rounded-sm bg-black/25 px-2 py-2 text-left shadow-[inset_2px_0_0_rgba(103,232,249,0.22),inset_0_0_0_1px_rgba(255,255,255,0.045)] transition-colors hover:bg-black/35 disabled:cursor-default disabled:hover:bg-black/25",children:[t.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[t.jsx("span",{className:"truncate font-mono text-[10px] text-cyan-100",children:s}),e.score!==null&&t.jsx("span",{className:"shrink-0 font-mono text-[9px] text-muted-foreground",children:e.score.toFixed(1)})]}),t.jsxs("div",{className:"mt-1 flex flex-wrap gap-x-2 gap-y-1 text-[10px] text-muted-foreground",children:[e.providerName!==null&&t.jsx("span",{children:e.providerName}),e.model!==null&&t.jsx("span",{children:e.model}),e.status!==null&&t.jsxs("span",{children:["status ",String(e.status)]}),e.elapsedMs!==null&&t.jsxs("span",{children:[String(e.elapsedMs)," ms"]})]}),t.jsx("p",{className:"mt-1 line-clamp-3 text-[11px] leading-4 text-foreground/85",children:e.excerpt})]})}function v4({response:e}){return t.jsxs("div",{className:"overflow-hidden rounded-md bg-[#050b12]/85 shadow-[inset_0_0_0_1px_rgba(103,232,249,0.12),0_10px_24px_rgba(0,0,0,0.18)]",children:[t.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2 border-b border-cyan-100/[0.08] bg-cyan-400/[0.045] px-3 py-2",children:[t.jsx(Cn,{label:"assistant@inspector",value:"output",tone:"cyan"}),t.jsxs("span",{className:"shrink-0 font-mono text-[9px] text-muted-foreground",children:[String(e.logCount)," logs"]})]}),t.jsxs("div",{className:"space-y-3 p-3",children:[t.jsx("div",{className:"rounded-sm bg-black/20 px-2.5 py-2 text-xs leading-5 shadow-[inset_2px_0_0_rgba(103,232,249,0.28)]",children:t.jsx(p4,{text:e.answer})}),t.jsxs("div",{className:"grid gap-1.5 rounded-sm bg-black/20 px-2 py-1.5",children:[t.jsx(Cn,{label:"provider",value:e.providerName}),t.jsx(Cn,{label:"model",value:e.model}),t.jsx(Cn,{label:"protocol",value:e.protocol})]}),(e.summaryMetrics.length>0||e.queryMetrics.length>0)&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Cn,{label:"metrics",tone:"cyan"}),t.jsx(g4,{metrics:[...e.summaryMetrics,...e.queryMetrics]})]}),e.evidence.length>0&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Cn,{label:"evidence",value:"click to inspect source log",tone:"cyan"}),e.evidence.slice(0,6).map(n=>t.jsx(b4,{evidence:n},`${n.source}-${n.id}`))]})]})]})}function y4({message:e}){return e.role==="assistant"&&e.response!==null?t.jsx(v4,{response:e.response}):t.jsxs("div",{className:"overflow-hidden rounded-md bg-black/25 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[t.jsx("div",{className:"border-b border-white/[0.06] px-3 py-1.5",children:t.jsx(Cn,{label:"user@inspector",value:"query",tone:"cyan"})}),t.jsxs("div",{className:"px-3 py-2 font-mono text-[11px] leading-5 text-cyan-50",children:[t.jsx("span",{className:"select-none text-cyan-100/60",children:"> "}),e.content]})]})}function w4({currentSessionId:e,logCount:n,onResultChange:s}){const{providers:o}=Hi(),r=l.useMemo(()=>x4(o.filter(f4)),[o]),[a,i]=l.useState(()=>({...Qc(),question:sd})),[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(R=>({...R,question:C.currentTarget.value}))},v=C=>{d(C),u("__auto__")},j=()=>{i({...Qc(),question:sd}),s(null)},S=C=>{i(R=>({...R,question:C,error:null}))},N=()=>{if(!y)return;const C=b.trim(),R=i4(a.messages),I={id:od("user"),role:"user",content:C,response:null};f(!0),i(M=>({...M,messages:[...M.messages,I],question:"",error:null}));const P={question:C,history:R,...e!==null?{sessionId:e}:{},...c!=="__auto__"?{providerId:c}:{},...m!=="__auto__"?{model:m}:{},logLimit:16};_h("/api/pi-agent",{method:"POST",headers:{"content-type":"application/json","x-agent-inspector-csrf":"1"},body:JSON.stringify(P)}).then(async M=>{const k=await M.text();if(!M.ok){i($=>({...$,error:`Inspector Assistant failed: HTTP ${String(M.status)} ${k}`}));return}const A=JSON.parse(k),D=d4(A);if(D===null){i($=>({...$,error:"Inspector Assistant returned an unexpected response."}));return}i($=>({...$,messages:[...$.messages,{id:od("assistant"),role:"assistant",content:D.answer,response:D}]})),s({question:C,logIds:o4(D),reportedLogCount:D.logCount})}).catch(M=>{i(k=>({...k,error:M instanceof Error?M.message:"Inspector Assistant request failed."}))}).finally(()=>{f(!1)})};return t.jsxs("section",{className:"rounded-md bg-black/20 px-3 py-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Zx,{className:"size-4 text-cyan-200"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-xs font-semibold text-foreground",children:"Assistant"}),t.jsx("div",{className:"text-[11px] text-muted-foreground",children:e===null?"All evidence":"Current session"})]}),t.jsx("button",{type:"button",onClick:j,className:"inline-flex size-7 items-center justify-center rounded-md bg-black/25 text-muted-foreground transition-colors hover:text-foreground",title:"Reset conversation",children:t.jsx(uu,{className:"size-3.5"})})]}),a.messages.length===0&&t.jsx("p",{className:"mt-3 text-[11px] leading-5 text-muted-foreground",children:"Ask about failures, latency, tokens, and tools."}),t.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2",children:[t.jsxs($s,{value:c,onValueChange:v,children:[t.jsx(Fs,{className:"h-8 border-0 bg-black/25 text-xs shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)]",children:t.jsx(sr,{placeholder:"Provider"})}),t.jsxs(Us,{children:[t.jsx(Xe,{value:"__auto__",children:"Auto provider"}),r.map(C=>t.jsxs(Xe,{value:C.id,children:[C.name," / ",h4(C)]},C.id))]})]}),t.jsxs($s,{value:m,onValueChange:u,children:[t.jsx(Fs,{className:"h-8 border-0 bg-black/25 text-xs shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)]",children:t.jsx(sr,{placeholder:"Model"})}),t.jsxs(Us,{children:[t.jsx(Xe,{value:"__auto__",children:"Auto model"}),g.map(C=>t.jsx(Xe,{value:C,children:C},C))]})]})]}),a.messages.length===0&&t.jsx("div",{className:"mt-3 flex flex-wrap gap-1.5",children:r4.map(C=>t.jsxs("button",{type:"button",onClick:()=>{S(C.question)},className:"inline-flex h-7 items-center gap-1.5 rounded-sm bg-black/25 px-2 text-[11px] text-cyan-50 transition-colors hover:bg-cyan-400/12",children:[t.jsx(Fa,{className:"size-3"}),t.jsx("span",{children:C.label})]},C.id))}),a.messages.length>0&&t.jsxs("div",{className:"mt-3 max-h-96 space-y-2 overflow-y-auto pr-1",children:[a.messages.map(C=>t.jsx(y4,{message:C},C.id)),p&&t.jsxs("div",{className:"inline-flex items-center gap-2 rounded-md bg-black/25 px-3 py-2 text-xs text-muted-foreground",children:[t.jsx(Ae,{className:"size-3.5 animate-spin"}),t.jsx("span",{children:"Searching Inspector..."})]})]}),t.jsx("textarea",{value: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..."}),t.jsxs("button",{type:"button",onClick:N,disabled:!y,className:"mt-2 inline-flex h-8 w-full items-center justify-center gap-2 rounded-md bg-cyan-400/12 px-3 text-xs font-medium text-cyan-100 shadow-[inset_0_0_0_1px_rgba(103,232,249,0.18)] transition-colors hover:bg-cyan-400/18 disabled:cursor-not-allowed disabled:opacity-50",children:[p?t.jsx(Ae,{className:"size-3.5 animate-spin"}):t.jsx(Zg,{className:"size-3.5"}),t.jsx("span",{children:p?"Searching...":"Ask Assistant"})]}),a.error!==null&&t.jsx("p",{className:"mt-2 break-words text-[11px] leading-5 text-red-200",children:a.error}),n===0&&t.jsx("p",{className:"mt-2 text-[11px] leading-5 text-muted-foreground",children:"No logs in this scope. Setup questions still work."})]})}function j4(e){const n=new Map;for(const s of e){const o=s.logs;for(let r=1;r<o.length;r++){const a=o[r-1],i=o[r];a===void 0||i===void 0||n.set(i.id,{creation:rd(a.cacheCreationInputTokens,i.cacheCreationInputTokens),read:rd(a.cacheReadInputTokens,i.cacheReadInputTokens)})}}return n}function rd(e,n){return n===null||e===null?null:n>e?{direction:"up",delta:n-e}:n<e?{direction:"down",delta:e-n}:null}function zf(e){return e===null?null:new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Vn(e,n,s){const o=zf(e.lastSuccessAt),r=e.retryCount>0?` Retry ${e.retryCount.toString()}.`:"",a=s?" Captured logs remain visible.":"",i=o===null?"":` Last update ${o}.`;return`${n}${i}${r}${a}`}function $f(e,n,s){switch(e){case"connecting":return{label:"Connecting",description:Vn(n,"Waiting for the first live update.",s),toneClass:"border-cyan-400/20 bg-cyan-500/8 text-cyan-100",dotClass:"bg-cyan-300 animate-pulse motion-reduce:animate-none",canRetry:!1,canStop:!1};case"live":return{label:"Live",description:Vn(n,"Live updates are current.",s),toneClass:"border-emerald-400/20 bg-emerald-500/8 text-emerald-100",dotClass:"bg-emerald-300",canRetry:!1,canStop:!1};case"reconnecting":return{label:"Reconnecting",description:Vn(n,"Live updates were interrupted.",s),toneClass:"border-amber-400/20 bg-amber-500/8 text-amber-100",dotClass:"bg-amber-300 animate-pulse motion-reduce:animate-none",canRetry:!0,canStop:!0};case"stale":return{label:"Stale data",description:Vn(n,"Live updates have not resumed.",s),toneClass:"border-orange-400/25 bg-orange-500/10 text-orange-100",dotClass:"bg-orange-300",canRetry:!0,canStop:!0};case"offline":return{label:"Offline",description:Vn(n,n.errorMessage??"Live updates are paused.",s),toneClass:"border-slate-400/20 bg-slate-500/10 text-slate-200",dotClass:"bg-slate-400",canRetry:!0,canStop:!1};case"error":return{label:"Connection error",description:Vn(n,n.errorMessage??"The live stream reported a recoverable error.",s),toneClass:"border-red-400/25 bg-red-500/10 text-red-100",dotClass:"bg-red-300",canRetry:!0,canStop:!0}}}function S4({state:e}){const n=$f(e.status,e,!1),s=zf(e.lastSuccessAt),o=e.retryCount>0?`Retry ${e.retryCount.toString()}`:null;return t.jsxs("span",{role:"status","aria-label":n.description,"data-connection-state":e.status,className:O("inline-flex h-7 max-w-full items-center gap-1.5 rounded-full border px-2.5 text-xs font-medium",n.toneClass),children:[t.jsx("span",{className:O("size-1.5 shrink-0 rounded-full",n.dotClass)}),t.jsx("span",{className:"shrink-0",children:n.label}),o!==null&&t.jsx("span",{className:"hidden truncate text-current/70 sm:inline",children:o}),s!==null&&t.jsxs("span",{className:"hidden truncate font-mono text-[10px] text-current/65 md:inline",children:["Last ",s]})]})}function N4({state:e,hasLogs:n,onRetry:s,onStop:o}){const r=$f(e.status,e,n);return t.jsxs("div",{role:"status","aria-live":"polite","data-connection-state":e.status,className:O("mt-2 flex flex-wrap items-center gap-x-3 gap-y-2 rounded-md border px-3 py-2 text-xs",r.toneClass),children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:O("size-2 shrink-0 rounded-full",r.dotClass)}),t.jsx("span",{className:"shrink-0 font-semibold",children:r.label}),t.jsx("span",{className:"min-w-0 text-current/75",children:r.description})]}),(r.canRetry||r.canStop)&&t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[r.canRetry&&t.jsxs("button",{type:"button",onClick:s,className:"inline-flex h-7 items-center gap-1 rounded-md bg-black/15 px-2 font-medium transition-colors hover:bg-black/25 focus-visible:ring-1 focus-visible:ring-current focus-visible:outline-none",children:[t.jsx(yt,{className:"size-3"}),"Retry now"]}),r.canStop&&t.jsxs("button",{type:"button",onClick:o,className:"inline-flex h-7 items-center gap-1 rounded-md px-2 text-current/70 transition-colors hover:bg-black/15 hover:text-current focus-visible:ring-1 focus-visible:ring-current focus-visible:outline-none",children:[t.jsx(y0,{className:"size-3"}),"Stop retrying"]})]})]})}function C4(){const[e,n]=l.useState(!1),[s,o]=l.useState(!1);l.useEffect(()=>{const i=()=>{n(document.fullscreenElement!==null),o(document.fullscreenEnabled&&document.documentElement.requestFullscreen!==void 0&&document.exitFullscreen!==void 0)};return i(),document.addEventListener("fullscreenchange",i),()=>{document.removeEventListener("fullscreenchange",i)}},[]);const r=l.useCallback(()=>{if(s){if(document.fullscreenElement===null){document.documentElement.requestFullscreen().catch(()=>{n(document.fullscreenElement!==null)});return}document.exitFullscreen().catch(()=>{n(document.fullscreenElement!==null)})}},[s]),a=e?"Exit fullscreen":"Enter fullscreen";return t.jsxs(ee,{type:"button",variant:"ghost",size:"icon",className:eo,"aria-label":a,"aria-pressed":e,title:a,disabled:!s,onClick:r,children:[e?t.jsx(bg,{className:"size-4"}):t.jsx(hg,{className:"size-4"}),t.jsx("span",{className:"sr-only",children:a})]})}function k4({liveConnection:e,alertsAction:n,settingsAction:s}){return t.jsx("header",{"data-application-bar":"true",className:"border-border/70 bg-background/95 sticky top-0 z-50 shrink-0 border-b px-3 py-2 shadow-[0_10px_30px_rgba(0,0,0,0.14)] backdrop-blur lg:px-4",children:t.jsxs("div",{className:"grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-2 sm:grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)]",children:[t.jsxs("a",{href:ji("/"),"aria-label":"Agent Inspector home",className:"flex min-w-0 items-center gap-2 rounded-md focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",children:[t.jsx(Ld,{className:"size-7 shrink-0 text-amber-500"}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block truncate text-sm font-bold leading-4",children:"Agent Inspector"}),t.jsx("span",{className:"hidden truncate text-[10px] font-medium text-muted-foreground md:block",children:"Local First. Evidence First."})]}),t.jsxs("span",{className:"hidden shrink-0 font-mono text-[10px] text-muted-foreground lg:inline",children:["v",fu.version]})]}),t.jsx("div",{className:"order-3 col-span-2 flex min-w-0 justify-start sm:order-2 sm:col-span-1 sm:justify-center",children:e===void 0?t.jsxs("span",{"data-connection-state":"stored",className:"border-border/70 bg-muted/50 inline-flex h-7 max-w-full items-center gap-1.5 rounded-full border px-2.5 text-xs font-medium text-muted-foreground",children:[t.jsx("span",{className:"size-1.5 shrink-0 rounded-full bg-slate-400"}),"Stored session"]}):t.jsx(S4,{state:e})}),t.jsxs("nav",{"aria-label":"Application actions",className:"order-2 flex shrink-0 items-center justify-end gap-1 sm:order-3",children:[t.jsx(C4,{}),n,s]})]})})}function _4(e){return`${Math.max(0,Math.ceil(e/1e3)).toString()}s`}function Oo({progress:e}){const n=Math.min(1,e.elapsedMs/e.timeoutMs),s=Math.max(4,Math.round(n*100)),o=Math.max(0,e.timeoutMs-e.elapsedMs),r=n>=.75,a=[e.loadedLogs>0?`${e.loadedLogs.toString()} logs`:null,e.loadedPages>0?`${e.loadedPages.toString()} page${e.loadedPages===1?"":"s"}`:null,`${_4(o)} before timeout`].filter(c=>c!==null),i=`${e.label}: ${a.join(", ")}`;return t.jsxs("div",{className:"min-w-0 space-y-1 px-1 pb-1",children:[t.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3 font-mono text-[10px] text-muted-foreground",children:[t.jsx("span",{className:"min-w-0 truncate",children:e.label}),t.jsx("span",{className:O("shrink-0 tabular-nums",r&&"text-amber-300"),children:a.join(" / ")})]}),t.jsx("div",{role:"progressbar","aria-label":e.label,"aria-valuemin":0,"aria-valuemax":e.timeoutMs,"aria-valuenow":Math.min(e.elapsedMs,e.timeoutMs),"aria-valuetext":i,className:"h-1.5 overflow-hidden rounded-full bg-white/[0.06]",children:t.jsx("div",{className:O("h-full rounded-full transition-all duration-300 motion-reduce:transition-none",r?"bg-amber-300/80":"bg-cyan-300/70"),style:{width:`${s.toString()}%`}})})]})}function Ff(e){return e?"auto":"smooth"}function Uf(){return typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function T4(){return{status:"connecting",lastSuccessAt:null,retryCount:0,errorMessage:null}}function kt(e,n){switch(n.type){case"connect-requested":return{...e,status:e.lastSuccessAt===null?"connecting":e.status==="stale"?"stale":"reconnecting",errorMessage:null};case"message-received":return{status:"live",lastSuccessAt:n.at,retryCount:0,errorMessage:null};case"connection-lost":{const s=e.retryCount+1;return n.online?{...e,status:e.lastSuccessAt===null?"error":"reconnecting",retryCount:s,errorMessage:n.message}:{...e,status:"offline",retryCount:s,errorMessage:"Browser is offline."}}case"stale-timeout":return e.lastSuccessAt===null||e.status==="live"||e.status==="offline"?e:{...e,status:"stale"};case"browser-offline":return{...e,status:"offline",errorMessage:"Browser is offline."};case"stop-retrying":return{...e,status:"offline",errorMessage:"Automatic live updates are paused."};case"recoverable-error":return{...e,status:"error",errorMessage:n.message}}}function E4(e){return e===void 0||e.status==="live"?"empty":e.status}function R4(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 ad="agent-inspector.hierarchy.collapsedClients",id="agent-inspector.hierarchy.collapsedProcesses";function ar(e){return e.some(n=>n.responseStatus===null)}function Bf(e){return e.filter(n=>n.responseStatus===null).length}function qf(e){for(const n of e){const s=n.userAgent;if(s!=null&&s!=="")return s}return null}function M4(e){for(const n of e){const s=n.clientPid;if(s!=null)return s}return null}function Hf(e){for(const n of e){const s=n.clientProjectFolder;if(s!=null&&s!=="")return s}return null}function A4(e){return hl({userAgent:qf(e.logs),conversationId:e.conversationId,clientProjectFolder:Hf(e.logs)})}function I4(e){if(e===null||e==="")return"Unknown client";const n=e.split(/[ /;]/)[0]??"";return n===""?"Unknown client":n}function P4(e,n){const s=Or(e);return s!==null?s:I4(n)}function ir(e){return e===null||e===""?"unknown":String(e)}function L4(e,n,s){return e!=="unknown"?e:`unknown:${ir(n)}:${ir(s)}`}function O4(e,n){return`${ir(e)}:${ir(n)}`}function ld(e){return[...e].sort((n,s)=>n.timestamp.localeCompare(s.timestamp))}function cd(e){let n="";for(const s of e)s.timestamp>n&&(n=s.timestamp);return n}function dd(e){return ar(e)?0:e.some(n=>n.error!==null&&n.error!==void 0||n.responseStatus!==null&&n.responseStatus!==void 0&&n.responseStatus>=400)?1:2}function Aa(e){return[...e].sort((n,s)=>{const o=dd(n.logs)-dd(s.logs);if(o!==0)return o;const r=cd(s.logs).localeCompare(cd(n.logs));return r!==0?r:n.id.localeCompare(s.id)})}function D4(e){const n=new Map;for(const o of e){const r=qf(o.logs),a=Hf(o.logs),i=A4(o),c=L4(i,r,a);let d=n.get(c);d===void 0&&(d={id:c,client:i,label:P4(i,r),userAgent:r,processes:new Map,logs:[]},n.set(c,d)),d.logs.push(...o.logs);const m=M4(o.logs),u=`${c}:${O4(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 n.values()){const r=Aa([...o.processes.values()].map(a=>({id:a.id,clientPid:a.clientPid,clientProjectFolder:a.clientProjectFolder,sessions:Aa(a.sessions),logs:ld(a.logs)})));s.push({id:o.id,client:o.client,label:o.label,userAgent:o.userAgent,processes:r,logs:ld(o.logs)})}return Aa(s)}function lr(e){return e<=0?"0":Ee(e)}function Wf(e){let n=0,s=0;for(const o of e)o.inputTokens!==null&&o.inputTokens!==void 0&&(n+=o.inputTokens),o.outputTokens!==null&&o.outputTokens!==void 0&&(s+=o.outputTokens);return{inputTokens:n,outputTokens:s}}function z4(e){let n=0;for(const s of e)n+=s.sessions.length;return n}function ud(e){if(typeof window>"u")return null;try{const n=window.localStorage.getItem(e);if(n===null)return null;const s=JSON.parse(n);return Array.isArray(s)?new Set(s.filter(o=>typeof o=="string")):null}catch{return null}}function md(e,n){try{window.localStorage.setItem(e,JSON.stringify([...n]))}catch{}}function pd(e,n){let s=!1;const o=new Set(e);for(const r of n)o.delete(r)&&(s=!0);return s?o:e}function $4(e){const n=new Set;for(const s of e)for(let o=1;o<s.processes.length;o++){const r=s.processes[o];r!==void 0&&!ar(r.logs)&&n.add(r.id)}return n}function F4(e){if(e===null||e==="")return null;const n=e.replaceAll("\\","/").split("/").filter(r=>r!==""),s=n[n.length-1];if(s===void 0)return e;const o=n[n.length-2];return o===void 0?s:`${o}/${s}`}function cr({label:e,value:n,className:s}){return t.jsxs("span",{className:O("inline-flex h-7 items-center gap-1 rounded-md bg-[var(--inspector-surface-low)] px-2 text-xs text-muted-foreground",s),children:[t.jsx("span",{className:"font-mono text-[10px] uppercase text-muted-foreground/70",children:e}),t.jsx("span",{className:"font-mono tabular-nums text-foreground",children:n})]})}function Vf({count:e}){const n=`${e} open turn${e===1?"":"s"}`;return t.jsxs("span",{className:"relative inline-flex size-6 shrink-0 items-center justify-center rounded-md bg-[var(--inspector-surface-medium)] text-[var(--inspector-status-watch)] ring-1 ring-border/50","aria-label":n,title:n,children:[t.jsx(Ae,{className:"size-3 animate-spin"}),e>1&&t.jsx("span",{className:"absolute translate-x-2 -translate-y-2 rounded bg-card px-0.5 font-mono text-[8px] tabular-nums text-[var(--inspector-status-watch)]",children:e})]})}function U4({groups:e,...n}){const s=l.useMemo(()=>D4(e),[e]),[o,r]=l.useState(()=>new Set),[a,i]=l.useState(()=>$4(s)),[c,d]=l.useState(!1);l.useEffect(()=>{const p=ud(ad),f=ud(id);p!==null&&r(p),f!==null&&i(f),d(!0)},[]),l.useEffect(()=>{c&&(md(ad,o),md(id,a))},[o,a,c]),l.useEffect(()=>{const p=new Set(s.filter(h=>ar(h.logs)).map(h=>h.id)),f=new Set(s.flatMap(h=>h.processes.filter(g=>ar(g.logs)).map(g=>g.id)));r(h=>pd(h,p)),i(h=>pd(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 t.jsx("div",{className:"space-y-2",children:s.map(p=>t.jsx(B4,{group:p,collapsed:o.has(p.id),collapsedProcessIds:a,onToggleClient:()=>m(p.id),onToggleProcess:u,conversationProps:n},p.id))})}function B4({group:e,collapsed:n,collapsedProcessIds:s,onToggleClient:o,onToggleProcess:r,conversationProps:a}){const i=Wf(e.logs),c=z4(e.processes),d=e.logs.length,m=Bf(e.logs),u=m>0;return t.jsxs("section",{className:O("relative isolate overflow-hidden rounded-[8px] bg-card/65",u&&"bg-card/80"),"data-ide-group":e.id,children:[t.jsxs("button",{type:"button",className:"grid w-full min-w-0 grid-cols-[2.25rem_minmax(0,1fr)_auto] items-center gap-2.5 px-3 py-2.5 text-left transition-colors hover:bg-[var(--inspector-surface-low)] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",onClick:o,"aria-expanded":!n,children:[e.client==="unknown"?t.jsx("span",{className:"inline-flex size-9 shrink-0 items-center justify-center rounded-md bg-[var(--inspector-surface-low)] text-muted-foreground",children:t.jsx(wg,{className:"size-4"})}):t.jsx(Dr,{client:e.client,className:"size-9 rounded-md",decorative:!0}),t.jsxs("span",{className:"min-w-0",children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"truncate text-sm font-semibold text-foreground",title:e.userAgent??e.label,children:e.label}),t.jsx("span",{className:"rounded bg-[var(--inspector-surface-medium)] px-1.5 py-0.5 font-mono text-[9px] uppercase text-muted-foreground",children:Zw(e.client)}),u&&t.jsx(Vf,{count:m})]}),t.jsxs("span",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:[t.jsxs("span",{children:[e.processes.length," process",e.processes.length!==1?"es":""]}),t.jsxs("span",{children:[c," session",c!==1?"s":""]}),t.jsxs("span",{children:[d," req"]})]})]}),t.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[n&&t.jsxs("span",{className:"hidden shrink-0 items-center gap-2 md:flex",children:[t.jsx(cr,{label:"IN",value:lr(i.inputTokens)}),t.jsx(cr,{label:"OUT",value:lr(i.outputTokens)})]}),t.jsx("span",{className:"inline-flex size-8 shrink-0 items-center justify-center rounded-md bg-[var(--inspector-surface-low)] text-muted-foreground transition-colors group-hover:bg-[var(--inspector-surface-medium)]",children:n?t.jsx(it,{className:"size-4"}):t.jsx(Ve,{className:"size-4"})})]})]}),!n&&t.jsx("div",{className:"space-y-0.5 px-2 pb-2 pt-0.5",children:e.processes.map(p=>t.jsx(q4,{group:p,collapsed:s.has(p.id),onToggle:()=>r(p.id),conversationProps:a},p.id))})]})}function q4({group:e,collapsed:n,onToggle:s,conversationProps:o}){const r=Wf(e.logs),a=F4(e.clientProjectFolder),i=e.sessions.length,c=e.logs.length,d=Bf(e.logs),m=d>0,u=e.clientPid!==null&&e.clientPid!==void 0?`PID ${e.clientPid}`:"Process unavailable";return t.jsxs("section",{className:"relative pl-3",children:[t.jsxs("button",{type:"button",className:"grid w-full min-w-0 grid-cols-[2rem_minmax(0,1fr)_auto] items-center gap-2.5 rounded-md bg-[var(--inspector-surface-low)] px-2.5 py-2 text-left transition-colors hover:bg-[var(--inspector-surface-medium)] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",onClick:s,"aria-expanded":!n,children:[t.jsx("span",{className:"inline-flex size-8 shrink-0 items-center justify-center text-[var(--inspector-status-watch)]",children:t.jsx(P0,{className:"size-4"})}),t.jsxs("span",{className:"min-w-0",children:[t.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[t.jsx("span",{className:"font-mono text-xs font-semibold tabular-nums text-foreground",children:u}),m&&t.jsx(Vf,{count:d}),a!==null&&t.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1 text-[11px] text-muted-foreground",title:e.clientProjectFolder??a,children:[t.jsx(ng,{className:"size-3 shrink-0"}),t.jsx("span",{className:"truncate font-mono",children:a})]})]}),t.jsxs("span",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:[t.jsxs("span",{children:[i," session",i!==1?"s":""]}),t.jsxs("span",{children:[c," req"]})]})]}),t.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[n&&t.jsxs("span",{className:"hidden shrink-0 items-center gap-2 md:flex",children:[t.jsx(cr,{label:"IN",value:lr(r.inputTokens)}),t.jsx(cr,{label:"OUT",value:lr(r.outputTokens)})]}),t.jsx("span",{className:"inline-flex size-7 shrink-0 items-center justify-center rounded-md bg-[var(--inspector-surface-low)] text-muted-foreground transition-colors hover:bg-[var(--inspector-surface-medium)]",children:n?t.jsx(it,{className:"size-4"}):t.jsx(Ve,{className:"size-4"})})]})]}),!n&&t.jsx("div",{className:"space-y-1 pb-1 pl-3 pr-1 pt-1",children:e.sessions.map(p=>t.jsx(UN,{group:p,...o,showClientIdentity:!1,showLogClientMetadata:!1,showProcessMetadata:!1},p.id))})]})}const H4="w-[calc(100%-1rem)] border-warning/30 bg-popover text-popover-foreground sm:max-w-lg",W4=[{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 V4({onCancel:e,onExportRedacted:n,onConfirmRaw:s}){return t.jsxs(t.Fragment,{children:[t.jsxs(Ft,{children:[t.jsx(Ut,{children:"Export unredacted logs?"}),t.jsx(Zs,{children:"Raw exports bypass Agent Inspector redaction and may expose sensitive captured data."})]}),t.jsxs("div",{role:"alert",className:"rounded-md border border-warning/35 bg-warning/10 px-3 py-3 text-sm text-foreground",children:[t.jsx("p",{className:"font-medium",children:"The raw archive may include:"}),t.jsx("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-xs leading-relaxed text-muted-foreground",children:W4.map(o=>t.jsxs("li",{children:[t.jsxs("span",{className:"font-semibold text-foreground",children:[o.label,":"]})," ",o.detail]},o.label))}),t.jsx("p",{className:"mt-3 text-xs leading-relaxed text-muted-foreground",children:"Only continue if you trust where this file will be stored and everyone it may be shared with."})]}),t.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[t.jsx(ee,{type:"button",variant:"outline",size:"sm",onClick:e,children:"Cancel"}),t.jsx(ee,{type:"button",variant:"outline",size:"sm",onClick:n,children:"Export redacted instead"}),t.jsx(ee,{type:"button",variant:"destructive",size:"sm",onClick:s,children:"Export raw data"})]})]})}const dr="data-nav-id",K4="data-nav-action";function fd(e){return Array.from(e.querySelectorAll(`[${dr}]`))}function hd(e){return e instanceof HTMLElement}function G4(e,n){let s=e;for(;s!==null&&s!==n;){if(s.hasAttribute(dr))return s;s=s.parentElement}return e.hasAttribute(dr)?e:null}function Ia(e){const n=e.getAttribute(K4);return n==="toggle"||n==="expand"||n==="collapse"?n:null}function Ss(e){e.focus({preventScroll:!0}),e.scrollIntoView({block:"nearest",behavior:"smooth"})}function Ns(e,n){return e[n]??null}function Kf(e){const n=e.tagName;return!!(n==="INPUT"||n==="TEXTAREA"||n==="SELECT"||e.isContentEditable)}function xd(e){const n=e.tagName;return n==="BUTTON"||n==="A"||Kf(e)?!0:e.closest("[role='button'],[role='menuitem'],[role='option']")!==null}function J4(e){return e.closest("[role='dialog'],[role='menu'],[role='listbox']")!==null?!0:document.querySelector("[role='dialog'],[role='menu'],[role='listbox']")!==null}function Y4(){const e=window.getSelection();return e===null?!1:e.type==="Range"&&e.toString().length>0}function So(e,n){return e.key===n&&e.shiftKey}function X4(e,n,s={}){const o=n??e,r=s.pageWide===!0,a=l.useCallback(i=>{const c=e.current,d=o.current;if(!c||!d)return;const m=i.target;if(!hd(m)||m!==d)return;const u=fd(c),p=Ns(u,0);p!==null&&Ss(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(!hd(m)||Kf(m)||Y4())return;const u=d.contains(m);if(u&&xd(m)&&!m.hasAttribute(dr)||!u&&(!r||xd(m)||J4(m)))return;const p=fd(d);if(p.length===0)return;const f=G4(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"&&!So(c,"W"))break;c.preventDefault();const b=h>0?h-1:h===-1?p.length-1:-1;if(b!==-1){const y=Ns(p,b);y!==null&&Ss(y)}g=!0;break}case"ArrowDown":case"S":{if(c.shiftKey&&c.key==="ArrowDown"||c.key==="S"&&!So(c,"S"))break;c.preventDefault();const b=h<p.length-1?h+1:h===-1?0:-1;if(b!==-1){const y=Ns(p,b);y!==null&&Ss(y)}g=!0;break}case"ArrowLeft":case"A":{if(c.shiftKey&&c.key==="ArrowLeft"||c.key==="A"&&!So(c,"A")||f===null)break;if(c.preventDefault(),Ia(f)==="collapse")f.click();else if(h>0){const y=Ns(p,h-1);y!==null&&Ss(y)}g=!0;break}case"ArrowRight":case"D":{if(c.shiftKey&&c.key==="ArrowRight"||c.key==="D"&&!So(c,"D")||f===null)break;if(c.preventDefault(),Ia(f)==="expand")f.click();else if(h<p.length-1){const y=Ns(p,h+1);y!==null&&Ss(y)}g=!0;break}case" ":{if(f===null)break;c.preventDefault(),Ia(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 Z4={system:"System",user:"User",assistant:"Assistant",tool:"Tool Results",tools:"Tool Definitions"},Q4={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"},e_={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"},Pa=12,No=1,gd=80,bd=24;function t_(e){return e.length<=bd?e:`${e.slice(0,bd-3)}...`}function n_(e){const n=e.replace(/\s+/g," ").trim();return n.length<=gd?n:`${n.slice(0,gd)}...`}function Co(e){return e>=10?`${e.toFixed(0)}%`:e>=1?`${e.toFixed(1)}%`:e>0?"<1%":"0%"}const s_=l.memo(function({segments:n,totalTokens:s,showLabels:o=!0,onActivate:r}){const a=l.useMemo(()=>s>0?s:n.reduce((y,w)=>y+w.size,0),[n,s]),i=n.slice(0,Pa),c=n.slice(Pa),d=c.reduce((y,w)=>y+w.size,0),m=c.length,u=Pa,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: ~${Ee(a)} tokens across ${n.length} segment${n.length===1?"":"s"}`,[n.length,a]);return n.length===0||a<=0?t.jsx("div",{role:"img","aria-label":b,className:"h-6"}):t.jsx(hs,{delayDuration:150,children:t.jsxs("div",{role:"img","aria-label":b,className:"flex flex-col gap-1.5",children:[t.jsxs("div",{className:"relative flex h-6 w-full overflow-hidden rounded border border-border/40 bg-muted/30","data-testid":"anatomy-segment-bar",children:[i.map((y,w)=>{const v=a>0?y.size/a*100:0,j=Math.max(No,v),S=O("h-full border-r border-background/80 last:border-r-0",h?"opacity-90 hover:opacity-100 focus:opacity-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-offset-background":"opacity-90",Q4[y.role],h?e_[y.role]:""),N={width:`${j}%`},C=`${y.label}, ${Co(v)}, ~${Ee(y.size)} tokens`;return t.jsxs(et,{children:[t.jsx(tt,{asChild:!0,children:h?t.jsx("button",{type:"button",role:"button",tabIndex:0,onClick:()=>r(y),onKeyDown:R=>{(R.key==="Enter"||R.key===" ")&&(R.preventDefault(),r(y))},"data-anatomy-path":y.path,"aria-label":C,className:S,style:N}):t.jsx("span",{"aria-label":C,className:S,style:N})}),t.jsxs(nt,{side:"bottom",className:"max-w-sm text-xs p-2 space-y-0.5",children:[t.jsxs("div",{className:"font-semibold",children:[y.label," - ",Co(v)," - ~",Ee(y.size)," ","tokens"]}),t.jsx("div",{className:"text-muted-foreground",children:Z4[y.role]}),t.jsxs("div",{className:"text-muted-foreground",children:[y.characters.toLocaleString()," chars"]}),y.text.length>0&&t.jsx("div",{className:"text-muted-foreground/90 break-words whitespace-pre-wrap",children:n_(y.text)})]})]},`${y.path}-${w}`)}),f&&t.jsxs(et,{children:[t.jsx(tt,{asChild:!0,children:t.jsxs("div",{role:"img","aria-label":`${m} additional segments`,className:"flex h-full items-center justify-center bg-muted-foreground/30 px-1.5 text-[10px] font-mono text-background",style:{width:`${Math.max(No,d/a*100)}%`},children:["... +",m]})}),t.jsxs(nt,{side:"bottom",className:"text-xs",children:[m," more segment",m===1?"":"s"," (indices"," ",u,"-",p,")"]})]})]}),o&&t.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(No,v);return t.jsxs("div",{className:"flex flex-col gap-0.5 truncate",style:{width:`${j}%`},title:`${y.label} - ${Co(v)} - ~${Ee(y.size)} tokens`,children:[t.jsx("span",{className:"truncate font-mono text-foreground/80",children:t_(y.label)}),t.jsxs("span",{className:"truncate font-mono text-muted-foreground/70",children:[Co(v)," - ~",Ee(y.size)]})]},`label-${y.path}-${w}`)}),f&&t.jsxs("div",{className:"flex flex-col gap-0.5 truncate text-muted-foreground",style:{width:`${Math.max(No,d/a*100)}%`},children:[t.jsxs("span",{className:"truncate font-mono text-foreground/60",children:["... +",m]}),t.jsxs("span",{className:"truncate font-mono text-muted-foreground/60",children:["~",Ee(d)]})]})]}),g<a*.1&&t.jsx("div",{className:"h-0"})]})})}),Gf=.75,Jf=.9,xi=8e3,o_=.35,Yf=40,Xf=160,r_=5,a_=8,i_=18,l_=6e4,c_=.7,vd=3e3,d_=.3,yd=160,u_=new Set(["answer","body","content","data","error","message","markdown","output","response","result","stderr","stdout","text","transcript"]),m_=["context_window","contextWindow","context_length","contextLength","max_context_length","maxContextLength","max_input_tokens","maxInputTokens"],p_=["max_tokens","maxTokens","max_completion_tokens","maxCompletionTokens","max_output_tokens","maxOutputTokens"],f_=[{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"]}],h_={system:"System",user:"User messages",assistant:"Assistant messages",tool:"Tool results",tools:"Tool definitions"};function x_(e){if(typeof e=="number")return Number.isFinite(e)&&e>0?Math.floor(e):null;if(typeof e=="string"){const n=Number(e);if(Number.isFinite(n)&&n>0)return Math.floor(n)}return null}function Zf(e,n){for(const s of n){const o=x_(Z(e,s));if(o!==null)return o}return null}function g_(e){const n=Z(e,"model");if(typeof n!="string")return null;const s=n.trim();return s===""?null:s}function b_(e,n){switch(n.mode){case"prefix":return n.patterns.some(s=>e.startsWith(s));case"includes":return n.patterns.some(s=>e.includes(s))}}function v_(e,n,s=[]){const o=Zf(n,m_);if(o!==null)return{tokens:o,label:"Request metadata",source:"request"};const r=yk(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 f_)if(b_(a,i))return{tokens:i.tokens,label:`${i.family} local rule`,source:"model-rule"};return{tokens:null,label:"No local rule",source:"unknown"}}function y_(e){return e<0?0:e>1?1:e}function w_(e){return e===null?"unknown":e>=Jf?"danger":e>=Gf?"watch":"ok"}function j_(e,n){return e.filter(s=>s.role===n).reduce((s,o)=>s+o.size,0)}function S_(e,n){return["system","user","assistant","tool","tools"].map(o=>{const r=j_(e,o);return{role:o,label:h_[o],tokens:r,percent:n>0?r/n:0}}).filter(o=>o.tokens>0).sort((o,r)=>r.tokens-o.tokens)}function gi(e){return e.replace(/\s+/g," ").trim().toLowerCase()}function N_(e){const n=e.replace(/\s+/g," ").trim();return n.length<=yd?n:`${n.slice(0,yd-3)}...`}function C_(e){return{role:e.role,label:e.label,path:e.path,tokens:e.tokens,characters:e.characters}}function k_(e){return{role:e.role,label:e.label,path:e.path,tokens:e.size,characters:e.characters,text:e.text}}function __(e){const n=e.trim();return n.startsWith("{")||n.startsWith("[")}function T_(e){if(!__(e))return null;try{return JSON.parse(e)}catch{return null}}function E_(e){return e.toLowerCase().replace(/[^a-z0-9]/g,"")}function R_(e){for(let n=e.length-1;n>=0;n-=1){const s=e[n]??"";if(!(s.startsWith("[")&&s.endsWith("]")))return s}return null}function M_(e){const n=R_(e);return n===null?!1:u_.has(E_(n))}function A_(e){return e.map(n=>n.startsWith("[")?n:`.${n}`).join("").replace(/^\./,"")}function I_(e,n,s){const o=gl(n);if(o<Xf)return null;const r=xl(n);return r<Yf?null:{role:e.role,label:`${e.label} ${A_(s)}`,path:e.path,tokens:r,characters:o,text:n}}function bi({value:e,segment:n,path:s,depth:o,candidates:r}){if(!(r.length>=a_)&&!(o>r_)){if(typeof e=="string"){if(!M_(s))return;const a=I_(n,e,s);a!==null&&r.push(a);return}if(Array.isArray(e)){e.forEach((a,i)=>bi({value:a,segment:n,path:[...s,`[${String(i)}]`],depth:o+1,candidates:r}));return}bl(e)&&Object.entries(e).forEach(([a,i])=>bi({value:i,segment:n,path:[...s,a],depth:o+1,candidates:r}))}}function P_(e){const n=k_(e),s=T_(e.text);if(s===null)return[n];const o=[];bi({value:s,segment:e,path:[],depth:0,candidates:o});const r=gi(e.text),a=new Set([r]),i=o.filter(c=>{const d=gi(c.text);return d===""||a.has(d)?!1:(a.add(d),!0)});return[n,...i]}function L_(e){const n=new Map;for(const o of e){const r=P_(o);for(const a of r){if(a.tokens<Yf||a.characters<Xf)continue;const i=gi(a.text);if(i==="")continue;const c=n.get(i);if(c===void 0){n.set(i,{tokens:a.tokens,candidates:[a]});continue}n.set(i,{tokens:c.tokens+a.tokens,candidates:[...c.candidates,a]})}}const s=[];for(const o of n.values()){if(o.candidates.length<2)continue;const r=o.candidates[0]??null;if(r===null)continue;const a=o.tokens-r.tokens;s.push({key:`${r.path}:${r.label}:${String(o.candidates.length)}:${String(o.tokens)}`,count:o.candidates.length,totalTokens:o.tokens,repeatedTokens:a,preview:N_(r.text),firstLabel:r.label,segments:o.candidates.map(C_)})}return s.sort((o,r)=>r.repeatedTokens-o.repeatedTokens||r.totalTokens-o.totalTokens)}function O_(e){if(e.length===0)return null;const n=e.length,s=e.reduce((r,a)=>r+a.count,0),o=e.reduce((r,a)=>r+a.repeatedTokens,0);return{kind:"duplicate",severity:o>=xi?"danger":"watch",title:"Duplicate context",detail:`${String(s)} repeated blocks across ${String(n)} group${n===1?"":"s"}, ~${String(o)} repeated tokens.`}}function D_(e){return e.reduce((n,s)=>n+s.repeatedTokens,0)}function z_(e,n,s){const o=[],r=e.find(d=>d.role==="tools")??null;r!==null&&(r.tokens>=xi||r.percent>=o_&&r.tokens>=vd)&&o.push({kind:"tool-schema",severity:r.tokens>=xi?"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>=vd&&a.percent>=d_&&o.push({kind:"system-heavy",severity:"watch",title:"Large system prompt",detail:`System instructions take ${Math.round(a.percent*100)}% of request context.`});const i=e.filter(d=>d.role==="user"||d.role==="assistant"||d.role==="tool").reduce((d,m)=>d+m.tokens,0),c=n>0?i/n:0;return s>=i_&&(i>=l_||c>=c_)&&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 $_({risk:e,contextWindow:n,diagnostics:s,duplicateGroups:o}){let a=new Set(s.map(d=>d.kind)).size;(e==="watch"||e==="danger")&&(a+=1),n.source==="unknown"&&(a+=1);const i=s.some(d=>d.severity==="danger");return{level:e==="danger"||i?"risk":a>0?"optimizable":"ok",opportunityCount:a,reclaimableTokens:D_(o)}}function F_({segments:e,inputTokens:n,parsed:s,model:o,providers:r=[]}){const a=e.reduce((C,R)=>C+R.size,0),i=o??g_(s),c=n??a,d=Zf(s,p_),m=v_(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:y_(p/m.tokens),b=S_(e,a),y=b[0]??null,w=e.filter(C=>C.role!=="tools").length,v=L_(e),j=O_(v),S=z_(b,a,w);j!==null&&S.unshift(j);const N=w_(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:$_({risk:N,contextWindow:m,diagnostics:S,duplicateGroups:v})}}const QT={watch:Gf,danger:Jf},wd=new WeakMap;function U_(e){return e.map(n=>{const s=n.modelMetadata?.map(o=>`${o.model}:${String(o.contextWindow??"")}`).join(",")??"";return`${n.id}:${n.updatedAt}:${n.models.join(",")}:${s}`}).join("|")}function B_(e){if(e===null)return null;try{return JSON.parse(e)}catch{return null}}function q_(e){return{role:e.role,label:e.label,size:e.tokens,characters:e.tokens*4,text:"",path:`role:${e.role}`}}function H_(e,n){const s=B_(e.rawRequestBody);if(s===null)return null;const r=Hp(Os(e)).anatomySegments(s);if(r===null)return null;const a=F_({segments:r,inputTokens:e.inputTokens??null,parsed:s,model:e.model,providers:n}),i=a.model??e.model??"Unknown model",c=a.roleUsages.map(q_);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 W_(e,n,s){const o=wd.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=H_(e,n);return wd.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 V_(e,n){return e.usagePercent!==null&&n.usagePercent!==null?e.usagePercent>n.usagePercent:e.usagePercent!==null&&n.usagePercent===null?!0:e.usagePercent===null&&n.usagePercent!==null?!1:e.estimatedInputTokens>n.estimatedInputTokens}function jd(e){switch(e){case"danger":return 4;case"watch":return 3;case"unknown":return 2;case"ok":return 1}}function K_(e,n){const s=jd(n.latest.riskLevel)-jd(e.latest.riskLevel);if(s!==0)return s;const o=e.peak.usagePercent??-1,a=(n.peak.usagePercent??-1)-o;return a!==0?a:n.latest.logId-e.latest.logId}function G_(e,n){return e.usagePercent===null||n.usagePercent===null?null:(n.usagePercent-e.usagePercent)*100}function J_(e){for(let n=1;n<e.length;n++){const s=e[n-1],o=e[n];if(!(s===void 0||o===void 0)&&s.id>o.id)return[...e].sort((r,a)=>r.id-a.id)}return e}function Y_(e,n=[]){const s=J_(e),o=U_(n),r=new Map;for(const i of s){const c=W_(i,n,o);if(c===null)continue;const d=r.get(c.model);if(d===void 0){r.set(c.model,{model:c.model,requestCount:1,first:c,latest:c,peak:c});continue}r.set(c.model,{model:d.model,requestCount:d.requestCount+1,first:d.first,latest:c,peak:V_(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:G_(i.first,i.latest)})).sort(K_)}}function kn(e){return e.length<=30?e:`${e.slice(0,12)}...${e.slice(-12)}`}function X_(e){const n=new Map;for(const s of e)for(let o=0;o<s.logs.length;o+=1){const r=s.logs[o];r!==void 0&&n.set(r.id,o+1)}return n}function Sd(e,n){return n.get(e.id)??e.id}function Nd(e){let n=0,s=0;for(const o of e)o.inputTokens!==null&&(n+=o.inputTokens),o.outputTokens!==null&&(s+=o.outputTokens);return{totalIn:n,totalOut:s}}function Z_(e){for(const n of e)if(n.userAgent!==null&&n.userAgent!==void 0&&n.userAgent!=="")return n.userAgent;return null}function Q_(e,n){const s=e[0],o=e[e.length-1];return s===void 0||o===void 0?null:hr(s.timestamp,o.timestamp,n)}function eT(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 tT(e){switch(e){case"rolling":return t.jsx(yt,{className:"size-3 text-status-cool"});case"failed":return t.jsx(Ho,{className:"size-3 text-status-danger"});case"watch":return t.jsx(mu,{className:"size-3 text-status-watch"});case"clear":return t.jsx(Oe,{className:"size-3 text-status-success"})}}function nT(e){switch(e){case"rolling":return"cool";case"failed":return"danger";case"watch":return"watch";case"clear":return"neutral"}}function sT(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 Kn({label:e,value:n,detail:s,icon:o,tone:r="neutral"}){return t.jsxs("div",{className:"min-w-0 border-t border-border/60 px-4 py-3",children:[t.jsxs("div",{className:"flex items-center gap-1 text-[10px] uppercase text-muted-foreground",children:[o,e]}),t.jsx("div",{className:O("mt-2 font-mono text-sm font-semibold",eT(r)),children:n}),t.jsx("div",{className:"mt-1 font-mono text-[11px] leading-snug text-muted-foreground",children:s})]})}function oT({stats:e}){return e.requests===0?null:t.jsxs("div",{className:"mb-4 overflow-hidden rounded-[8px] border border-border bg-card",children:[t.jsx("div",{className:"px-4 py-3",children:t.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-semibold uppercase text-muted-foreground",children:[t.jsx(S0,{className:"size-3.5 text-slate-300"}),"Flight Recorder"]}),t.jsx("div",{className:"mt-2 min-w-0 font-mono text-sm font-semibold text-foreground",children:e.modelLabel})]}),t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-muted-foreground",children:[t.jsx("span",{className:"min-w-0 font-mono",children:e.providerLabel}),t.jsx("span",{className:"min-w-0 font-mono",children:e.timeRange??"Timeline pending"})]})]})}),t.jsxs("div",{className:"grid grid-cols-2 border-t border-border/60 md:grid-cols-3 2xl:grid-cols-6",children:[t.jsx(Kn,{label:"Status",value:e.statusLabel,detail:sT(e),icon:tT(e.status),tone:nT(e.status)}),t.jsx(Kn,{label:"Turns",value:String(e.turns),detail:e.finishLabel,icon:t.jsx(Q0,{className:"size-3 text-muted-foreground"}),tone:e.finishTone}),t.jsx(Kn,{label:"Requests",value:String(e.requests),detail:`${e.failures} failed / ${e.slow} slow`,icon:t.jsx(Ho,{className:"size-3 text-muted-foreground"}),tone:e.failures>0?"danger":"neutral"}),t.jsx(Kn,{label:"Peak",value:e.slowestLabel,detail:e.slowestDetail,icon:t.jsx(mu,{className:"size-3 text-muted-foreground"}),tone:e.slow>0?"watch":"neutral"}),t.jsx(Kn,{label:"Tokens",value:e.tokenLabel,detail:e.heaviestDetail,icon:t.jsx(zi,{className:"size-3 text-muted-foreground"})}),t.jsx(Kn,{label:"Outcome",value:e.outcomeLabel,detail:e.outcomeDetail,tone:e.outcomeTone})]})]})}function Rs(e){if(e===null)return"Unknown";const n=e*100;return n>=10?`${n.toFixed(0)}%`:n>=1?`${n.toFixed(1)}%`:n>0?"<1%":"0%"}function rT(e){return e===null?"n/a":Math.abs(e)<.1?"0%":`${e>0?"+":""}${e.toFixed(1)}%`}function vi(e){return e===null||!Number.isFinite(e)?0:Math.min(Math.max(e*100,0),100)}function aT(e,n){if(n===null)return null;const s=vi(e),o=vi(n);return o<=0||Math.abs(o-s)<.5?null:o}function iT(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 lT(e){const n=e.latest.contextWindow.tokens;return n===null?"Context window unknown":`Context window ${Pd(n)}`}const cT=["score","decision","final_status","validation_pass_ratio","semantic_memory_score","opencode_exit","actual_model","run_dir","workspace","project_dir","work_dir"];function Qf(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 La(e,n){if(e===null)return null;const s=e.metadata[n];return s===void 0?null:Qf(s)}function dT(e){const n=e.toLowerCase();return n.includes("reject")||n.includes("fail")||n.includes("error")?"border-red-400/35 bg-red-500/10 text-red-100":n.includes("partial")||n.includes("pending")||n.includes("slow")?"border-amber-300/35 bg-amber-400/10 text-amber-100":n.includes("pass")||n.includes("complete")||n.includes("accept")?"border-cyan-300/25 bg-cyan-400/10 text-cyan-100":"border-border/70 bg-background/70 text-muted-foreground"}function uT(e){const n=[];for(const s of cT){const o=e.metadata[s];if(o===void 0)continue;const r=Qf(o);r!==null&&n.push({key:s,value:r})}return n}function Cd({memberships:e,defaultOpen:n=!1}){const[s,o]=l.useState(n);if(e.length===0)return null;const r=e[0],a=r?.member??null,i=La(a,"score"),c=La(a,"decision"),d=La(a,"final_status"),m=[i===null?null:{label:`score ${i}`,value:i},c===null?null:{label:c,value:c},d===null?null:{label:d,value:d},a?.model===null||a?.model===void 0?null:{label:a.model,value:a.model}].filter(u=>u!==null&&u.label.length>0&&u.value.length>0);return t.jsxs("div",{className:"border border-border bg-card shadow-sm mb-3 rounded-[8px] text-xs",children:[t.jsxs("button",{type:"button",onClick:()=>o(u=>!u),className:"flex w-full items-center gap-3 px-3 py-2 text-left transition-colors hover:bg-white/[0.04]","aria-expanded":s,children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[t.jsx("span",{className:"font-semibold text-foreground",children:"Case File"}),r!==void 0&&t.jsx("span",{className:"truncate text-muted-foreground",title:r.groupTitle,children:r.groupTitle}),t.jsxs("span",{className:"font-mono text-[10px] uppercase text-muted-foreground",children:[e.length," group",e.length===1?"":"s"]})]}),m.length>0&&t.jsx("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:m.slice(0,4).map(u=>t.jsx("span",{className:O("rounded border px-1.5 py-0.5 font-mono text-[10px]",dT(u.value)),children:u.label},u.label))})]}),s?t.jsx(Oi,{className:"size-4 shrink-0 text-muted-foreground"}):t.jsx(Ve,{className:"size-4 shrink-0 text-muted-foreground"})]}),s&&t.jsx("div",{className:"space-y-2 border-t border-white/10 px-3 py-2",children:e.map(u=>{const p=u.member,f=uT(p);return t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[t.jsx("span",{className:"truncate font-medium text-foreground",title:u.groupTitle,children:u.groupTitle}),t.jsx("span",{className:"font-mono text-[10px] uppercase text-muted-foreground",children:u.groupStatus}),p.status!==null&&t.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:["member ",p.status]})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-muted-foreground",children:[t.jsx("span",{className:"font-mono",title:p.sessionId,children:kn(p.sessionId)}),p.label!==null&&t.jsx("span",{children:p.label}),p.provider!==null&&t.jsx("span",{children:p.provider}),p.model!==null&&t.jsx("span",{className:"font-mono",children:p.model}),p.runId!==null&&t.jsxs("span",{className:"font-mono",title:p.runId,children:["run ",kn(p.runId)]})]}),f.length>0&&t.jsx("div",{className:"mt-2 grid gap-1 sm:grid-cols-2 xl:grid-cols-3",children:f.map(h=>t.jsxs("div",{className:"border border-border bg-muted/40 min-w-0 rounded-md px-2 py-1",children:[t.jsx("div",{className:"font-mono text-[10px] text-muted-foreground",children:h.key}),t.jsx("div",{className:"truncate font-mono text-[11px] text-foreground",title:h.value,children:h.value})]},h.key))})]},`${u.groupId}:${p.id}`)})})]})}function ko({label:e,title:n,icon:s,disabled:o,onClick:r}){return t.jsxs("button",{type:"button",onClick:r,disabled:o,className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-45",title:n,children:[s,t.jsx("span",{children:e})]})}function kd({logs:e,pagination:n,embedded:s=!1}){if(n===void 0)return null;const o=n.isLoading;return t.jsxs("nav",{"aria-label":"Session log pagination",className:O("flex min-h-9 flex-col gap-2 px-1 py-1 sm:flex-row sm:items-center",s?"border-t border-white/10 pt-2":"border border-border bg-card shadow-sm mb-3 rounded-[8px] px-2"),children:[t.jsxs("div",{className:"w-full min-w-0 px-1 font-mono text-[11px] text-muted-foreground sm:flex-1",children:[t.jsxs("div",{role:"status","aria-live":"polite","aria-atomic":"true",children:[aC({logs:e,pagination:n}),n.isLoading&&e.length>0&&t.jsx("span",{className:"ml-2",children:"Loading..."})]}),n.loadProgress!==void 0&&t.jsx(Oo,{progress:n.loadProgress})]}),t.jsxs("div",{className:"flex w-full items-center gap-1 overflow-x-auto sm:w-auto",children:[t.jsx(ko,{label:"Oldest",title:"Load the oldest logs in this session",icon:t.jsx(c0,{className:"size-3.5"}),disabled:o||!n.hasOlder,onClick:n.onOldest}),t.jsx(ko,{label:"Older",title:"Load older logs",icon:t.jsx(s0,{className:"size-3.5"}),disabled:o||!n.hasOlder,onClick:n.onOlder}),t.jsx(ko,{label:"Newer",title:"Load newer logs",icon:t.jsx(it,{className:"size-3.5"}),disabled:o||!n.hasNewer,onClick:n.onNewer}),t.jsx(ko,{label:"Newest",title:"Load the newest logs in this session",icon:t.jsx(u0,{className:"size-3.5"}),disabled:o||!n.hasNewer,onClick:n.onNewest})]})]})}function mT(e){return`${e} ${e===1?"request":"requests"}`}function _d(e){return`#${String(e)}`}function Td(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 pT(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 fT(e){switch(e){case"risk":return"Risk";case"optimizable":return"Optimizable";case"ok":return"OK"}}const hT=10,xT=80;function gT(e){e.setAttribute("data-deep-link-highlight","true"),window.setTimeout(()=>{e.removeAttribute("data-deep-link-highlight")},1800)}function bT(e){const n=document.getElementById(`log-${String(e)}`);return n instanceof HTMLElement?(n.scrollIntoView({block:"center",behavior:Ff(Uf())}),n.focus({preventScroll:!0}),gT(n),!0):!1}function eh(e){ds({logId:e,tab:"anatomy"});let n=0;const s=()=>{ds({logId:e,tab:"anatomy"}),!bT(e)&&(n+=1,n<hT&&window.setTimeout(s,xT))};window.setTimeout(s,0)}function vT({command:e}){const[n,s]=l.useState(!1),o=l.useCallback(()=>{vt(e).then(r=>{r&&(s(!0),setTimeout(()=>s(!1),2e3))})},[e]);return t.jsxs("div",{"data-command-example":"true",className:BN,children:[t.jsx("pre",{className:qN,children:e}),t.jsx("button",{type:"button",onClick:o,className:"shrink-0 cursor-pointer rounded-sm text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none","aria-label":"Copy command",children:n?t.jsx(Oe,{className:"size-4"}):t.jsx(St,{className:"size-4"})})]})}function Oa({label:e,children:n,className:s}){return t.jsxs("section",{className:O("rounded-[8px] border border-border/60 bg-card/55",s),children:[t.jsx("div",{className:"px-3 pt-3",children:t.jsx("div",{className:"font-mono text-[10px] font-semibold uppercase tracking-[0.14em] text-text-subtle",children:e})}),t.jsx("div",{className:"p-3 pt-2",children:n})]})}function _o({label:e,value:n}){return t.jsxs("div",{className:"min-w-0 rounded-md border border-border/50 bg-muted/30 px-2 py-2",children:[t.jsx("div",{className:"truncate font-mono text-lg font-semibold leading-6 text-text-strong",children:n}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] uppercase tracking-[0.12em] text-text-subtle",children:e})]})}function yT(){const{themeMode:e,setThemeMode:n}=H1();return t.jsxs("div",{className:"inline-flex h-9 items-center rounded-md border border-border/70 bg-muted/70 p-0.5","aria-label":"Theme mode",role:"group",children:[t.jsx("button",{type:"button",onClick:()=>n("light"),className:O("inline-flex size-8 items-center justify-center rounded-[6px] text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none max-lg:size-11",e==="light"&&"bg-background text-foreground shadow-sm"),"aria-label":"Use light mode","aria-pressed":e==="light",title:"Light mode",children:t.jsx(c1,{className:"size-3.5"})}),t.jsx("button",{type:"button",onClick:()=>n("eye-care"),className:O("inline-flex size-8 items-center justify-center rounded-[6px] text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none max-lg:size-11",e==="eye-care"&&"bg-background text-foreground shadow-sm"),"aria-label":"Use eye care mode","aria-pressed":e==="eye-care",title:"Eye care mode",children:t.jsx(ou,{className:"size-3.5"})}),t.jsx("button",{type:"button",onClick:()=>n("dark"),className:O("inline-flex size-8 items-center justify-center rounded-[6px] text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none max-lg:size-11",e==="dark"&&"bg-background text-foreground shadow-sm"),"aria-label":"Use dark mode","aria-pressed":e==="dark",title:"Dark mode",children:t.jsx(Sg,{className:"size-3.5"})})]})}function wT({visible:e,onToggle:n}){const s=e?"Hide Inspector pet":"Summon Inspector pet";return t.jsx("button",{type:"button",onClick:n,className:O("border-border/70 bg-muted/70 inline-flex size-8 shrink-0 items-center justify-center rounded-md border text-muted-foreground shadow-sm transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",e&&"bg-background text-amber-500 shadow-sm"),"aria-label":s,"aria-pressed":e,title:s,children:t.jsx(Ld,{className:O("size-4 transition-opacity",!e&&"opacity-45")})})}function jT({preference:e,resolvedScale:n,onChange:s}){const o=Y1(n),r=e==="auto"?`Auto (${o})`:`${e}%`;return t.jsxs($s,{value:e,onValueChange:a=>s(Bi(a)),children:[t.jsxs(Fs,{size:"sm",className:"h-9 min-w-[4.5rem] justify-center gap-1 border-border/70 bg-muted/70 px-2 py-0 text-muted-foreground hover:bg-muted max-lg:h-11 [&>svg:last-child]:hidden","aria-label":`Interface size: ${r}`,children:[t.jsx(Ix,{className:"size-3.5"}),t.jsx("span",{className:"font-mono text-[10px] font-semibold tabular-nums",children:o})]}),t.jsxs(Us,{align:"end",children:[t.jsx(Xe,{value:"auto",children:"Auto"}),t.jsx(Xe,{value:"100",children:"100%"}),t.jsx(Xe,{value:"125",children:"125%"}),t.jsx(Xe,{value:"150",children:"150%"})]})]})}const th="agent-inspector.detailsPanelCollapsed",nh="agent-inspector.detailsPanelWidth",sh="agent-inspector.pet.visible",Yn=360,ST=288,NT=520;function oh(e){return Math.min(Math.max(e,ST),NT)}function CT(){if(typeof window>"u")return!0;try{const e=window.localStorage.getItem(th);return e===null||e==="1"}catch{return!0}}function kT(){if(typeof window>"u")return Yn;try{const e=window.localStorage.getItem(nh);if(e===null)return Yn;const n=Number.parseInt(e,10);return Number.isFinite(n)?oh(n):Yn}catch{return Yn}}function _T(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(sh)!=="0"}catch{return!0}}function Ed({label:e,logId:n}){return t.jsxs("button",{type:"button",onClick:()=>eh(n),className:"inline-flex h-5 items-center rounded px-1 font-mono text-[10px] text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground",title:`Open Context for ${_d(n)}`,children:[e," ",_d(n)]})}function TT({latestPercent:e,peakPercent:n,risk:s,onOpenContext:o}){const r=vi(e),a=aT(e,n),i=n===null?`Latest context window usage ${Rs(e)}`:`Latest context window usage ${Rs(e)}, peak ${Rs(n)}`;return t.jsx("button",{type:"button",onClick:o,className:"group block w-full rounded-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1","aria-label":`${i}. Open latest Context details`,title:"Open latest Context details",children:t.jsxs("span",{className:"relative block h-2.5 overflow-hidden rounded-full border border-white/10 bg-black/25 transition-colors group-hover:border-cyan-200/35",role:"meter","aria-label":i,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(r),children:[t.jsx("span",{className:O("block h-full rounded-full transition-[width]",iT(s)),style:{width:`${r}%`}}),a!==null&&t.jsx("span",{className:"absolute top-0 h-full w-0.5 rounded-full bg-amber-100/75 shadow-[0_0_0_1px_rgba(0,0,0,0.25)]",style:{left:`calc(${a}% - 0.5px)`},"aria-hidden":"true"})]})})}function ET({summary:e}){const n=e.trendPercent,s=n===null||Math.abs(n)<.1?null:n>0?qx:Dx,o=e.latest.diagnostics[0]??null,r=Rs(e.latest.usagePercent),a=Rs(e.peak.usagePercent),i=()=>{eh(e.latest.logId)};return t.jsxs("div",{className:"grid gap-x-4 gap-y-2 border-t border-white/10 py-2 first:border-t-0 lg:grid-cols-[minmax(180px,1fr)_minmax(260px,1fr)_minmax(260px,1.4fr)]",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("button",{type:"button",onClick:i,className:"min-w-0 truncate rounded-sm text-left font-mono font-semibold text-foreground transition-colors hover:text-text-link focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1",title:`Open latest Context for ${e.model}`,children:e.model}),t.jsx("span",{className:O("inline-flex h-5 shrink-0 items-center rounded border px-1.5 font-mono text-[10px]",pT(e.latest.health.level)),children:fT(e.latest.health.level)})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-muted-foreground",children:[t.jsx("span",{children:mT(e.requestCount)}),t.jsx("span",{children:lT(e)})]})]}),t.jsxs("div",{className:"min-w-0 space-y-2 text-xs",children:[t.jsx(TT,{latestPercent:e.latest.usagePercent,peakPercent:e.peak.usagePercent,risk:e.latest.riskLevel,onOpenContext:i}),t.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Latest"}),t.jsx("div",{className:O("mt-0.5 font-mono",Td(e.latest.riskLevel)),children:r}),t.jsx(Ed,{label:"Log",logId:e.latest.logId})]}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Peak"}),t.jsx("div",{className:O("mt-0.5 font-mono",Td(e.peak.riskLevel)),children:a}),t.jsx(Ed,{label:"Log",logId:e.peak.logId})]}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Trend"}),t.jsxs("div",{className:"mt-0.5 flex items-center gap-1 font-mono text-foreground",children:[s!==null&&t.jsx(s,{className:O("size-3",n!==null&&n>0?"text-amber-300":"text-cyan-300")}),rT(n)]}),t.jsx("div",{className:"h-5","aria-hidden":"true"})]})]})]}),t.jsxs("div",{className:"min-w-0 space-y-1.5",children:[t.jsx(s_,{segments:e.latest.roleSegments,totalTokens:e.latest.roleTotalTokens,showLabels:!1}),t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-muted-foreground",children:[t.jsxs("span",{className:"font-mono",children:["~",Ee(e.latest.estimatedInputTokens)," input"]}),e.latest.windowUsedTokens!==null&&t.jsxs("span",{className:"font-mono",children:["~",Ee(e.latest.windowUsedTokens)," used"]}),o!==null&&t.jsx("span",{className:"truncate",children:o})]})]})]})}function RT({summary:e}){return e.models.length===0?null:t.jsxs("div",{className:"mt-3 border-t border-white/10 pt-2",children:[t.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2",children:[t.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-normal text-muted-foreground",children:"Session Context"}),t.jsxs("div",{className:"font-mono text-[10px] text-muted-foreground",children:[e.models.length," model",e.models.length===1?"":"s"]})]}),t.jsx("div",{className:"max-h-52 overflow-y-auto pr-1",children:e.models.map(n=>t.jsx(ET,{summary:n},n.model))})]})}function MT(e){const n=e.models.filter(o=>o.latest.health.level==="risk").length;if(n>0)return`${n} risk`;const s=e.models.filter(o=>o.latest.health.level==="optimizable").length;return s>0?`${s} optimizable`:`${e.models.length} model${e.models.length===1?"":"s"}`}function AT({label:e,logs:n,totalIn:s,totalOut:o,timeDisplayFormat:r,contextSummary:a,showBackLink:i}){const[c,d]=l.useState(!1),[m,u]=l.useState(!1),p=l.useMemo(()=>Q_(n,r),[n,r]),f=l.useMemo(()=>Z_(n),[n]),h=l.useMemo(()=>MT(a),[a]),g=l.useCallback(()=>{vt(window.location.href).then(b=>{b&&(d(!0),setTimeout(()=>d(!1),2e3))})},[]);return t.jsxs("div",{className:"border border-border bg-card shadow-sm mb-3 rounded-[8px] px-3 py-2 text-xs",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[i&&t.jsx("a",{href:ji("/"),className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex size-8 shrink-0 items-center justify-center rounded-md text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground","aria-label":"Back to all sessions",title:"Back to all sessions",children:t.jsx(Ux,{className:"size-3.5"})}),t.jsxs("div",{className:"min-w-[180px] flex-1",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"font-mono font-semibold text-purple-400/90 truncate",title:e,children:kn(e)}),f!==null&&t.jsx("span",{className:"font-mono text-muted-foreground truncate max-w-[220px]",title:f,children:f})]}),t.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-muted-foreground",children:[t.jsxs("span",{children:[n.length," request",n.length!==1?"s":""]}),p!==null&&t.jsx("span",{children:p}),(s>0||o>0)&&t.jsxs("span",{className:"font-mono",children:[Ee(s)," in / ",Ee(o)," out"]})]})]}),a.models.length>0&&t.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:[t.jsx("span",{children:h}),m?t.jsx(Oi,{className:"size-3.5"}):t.jsx(Ve,{className:"size-3.5"})]}),t.jsx("button",{type:"button",onClick:g,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex size-8 shrink-0 items-center justify-center rounded-md text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground","aria-label":c?"Copied session link":"Copy session link",title:c?"Copied session link":"Copy session link",children:c?t.jsx(Oe,{className:"size-3.5"}):t.jsx(St,{className:"size-3.5"})})]}),m&&t.jsx(RT,{summary:a})]})}function IT({logs:e,sessions:n,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:R=[],hideSessionFilter:I=!1,pinnedSessionId:P}){const{totalIn:M,totalOut:k}=l.useMemo(()=>Nd(e),[e]),{providers:A}=Hi(),{uiScalePreference:D,resolvedUiScale:$,setUiScalePreference:J}=eb(),[X,F]=l.useState(null),[H,Y]=l.useState(null),[U,W]=l.useState(!1),[me,be]=l.useState(!1),[ve,z]=l.useState(null),[se,te]=l.useState(null),[Se,Ne]=l.useState(!1),[ie,le]=l.useState(!1),[fe,ye]=l.useState(!0),[Ce,Ie]=l.useState(Yn),[$e,Pe]=l.useState(!1),[Ze,Bt]=l.useState(!1),[ct,Fe]=l.useState(!0),[Me,Le]=l.useState(!1),[B,ne]=l.useState(null),[we,he]=l.useState(null),je=l.useRef(null),Be=l.useRef(null),G=l.useRef(null),_=l.useRef(null),L=l.useRef(0),V=l.useRef(null);X4(je,Be,{pageWide:!0});const[oe,ce]=l.useState(null);l.useEffect(()=>$i(ce),[]);const Q=l.useCallback(()=>{L.current+=1,_.current?.abort(),_.current=null,F(null),Y(null)},[]);l.useEffect(()=>()=>{L.current+=1,_.current?.abort(),_.current=null},[]),l.useEffect(()=>{ye(CT()),Ie(kT()),Bt(!0)},[]),l.useEffect(()=>{Ze&&window.localStorage.setItem(th,fe?"1":"0")},[fe,Ze]),l.useEffect(()=>{if(Ze)try{window.localStorage.setItem(nh,String(Ce))}catch{}},[Ze,Ce]),l.useEffect(()=>{Fe(_T()),Le(!0)},[]),l.useEffect(()=>{if(Me)try{window.localStorage.setItem(sh,ct?"1":"0")}catch{}},[Me,ct]),l.useEffect(()=>{if(P===void 0){document.title="Agent Inspector";return}const ge=e.length===1?"1 req":`${e.length} req`;document.title=`${kn(P)} - ${ge} - Agent Inspector`},[e.length,P]);const pe=l.useCallback(async ge=>{_.current?.abort();const qe=new AbortController;_.current=qe;const xt=L.current+1;L.current=xt,F(ge),Y(null);try{const Ht=await $1(e,ge,{signal:qe.signal});if(L.current!==xt)return;if(!Ht.ok){if(Ht.canceled===!0)return;m!==void 0?m({message:Ht.message,tone:"error"}):Y(Ht.message)}}finally{L.current===xt&&(_.current=null,F(null))}},[e,m]),ae=l.useCallback(ge=>{if(VN(ge)){W(!0);return}pe(ge)},[pe]),ht=l.useCallback(()=>{W(!1),pe("redacted")},[pe]),hn=l.useCallback(()=>{W(!1),pe("raw")},[pe]),Re=l.useCallback(()=>{G.current?.click()},[]),qt=l.useCallback(ge=>{const qe=ge.currentTarget.files?.[0];ge.currentTarget.value="",!(qe===void 0||u===void 0)&&(be(!0),te(null),z(null),u(qe).then(xt=>{const Ht=xt.skipped>0?`, skipped ${String(xt.skipped)}`:"",Dl=`Imported ${String(xt.imported)} logs as ${xt.sessionId}${Ht}.`;m!==void 0?m({message:Dl,tone:"success"}):z(Dl)}).catch(xt=>{const Ht=xt instanceof Error?xt.message:"Failed to import logs";m!==void 0?m({message:Ht,tone:"error"}):te(Ht)}).finally(()=>{be(!1)}))},[u,m]);l.useEffect(()=>{Q(),he(null),ne(null)},[Q,s,o]);const dt=l.useCallback(()=>{Q(),z(null),te(null),he(null),a()},[Q,a]),xs=l.useCallback(()=>{Ne(!0)},[]),Qe=l.useCallback(()=>{Q(),z(null),te(null),he(null),i!==void 0&&(le(!0),i().then(()=>{Ne(!1)}).catch(ge=>{const qe=ge instanceof Error?ge.message:"Failed to delete stored logs";m!==void 0?m({message:qe,tone:"error"}):te(qe)}).finally(()=>{le(!1)}))},[Q,i,m]),xn=l.useCallback(()=>{c!==void 0&&(Q(),z(null),te(null),he(null),c())},[Q,c]),ah=l.useCallback(()=>{he(null)},[]),El=l.useCallback(()=>{ye(ge=>!ge)},[]),ih=l.useCallback(ge=>{V.current={startX:ge.clientX,startWidth:Ce,pointerId:ge.pointerId},ge.currentTarget.setPointerCapture(ge.pointerId),Pe(!0)},[Ce]),lh=l.useCallback(ge=>{const qe=V.current;qe===null||qe.pointerId!==ge.pointerId||Ie(oh(qe.startWidth+qe.startX-ge.clientX))},[]),Rl=l.useCallback(ge=>{const qe=V.current;qe===null||qe.pointerId!==ge.pointerId||(ge.currentTarget.hasPointerCapture(ge.pointerId)&&ge.currentTarget.releasePointerCapture(ge.pointerId),V.current=null,Pe(!1))},[]),ch=l.useCallback(()=>{Ie(Yn)},[]),dh=l.useCallback(()=>{Fe(ge=>!ge)},[]),Ur=l.useMemo(()=>B===null?null:new Set(B.logIds),[B]),gn=l.useMemo(()=>Ur===null?e:e.filter(ge=>Ur.has(ge.id)),[Ur,e]),Ct=l.useMemo(()=>Jj(gn),[gn]),Ml=l.useMemo(()=>X_(Ct),[Ct]),bn=l.useMemo(()=>rC({pinnedSessionId:P,selectedSession:s,sessions:n,logs:e}),[e,P,s,n]),On=bn?.logs??[],gs=bn!==null&&On.length>0,{totalIn:Al,totalOut:Il}=l.useMemo(()=>Nd(On),[On]),uh=l.useMemo(()=>Y_(On,A),[On,A]),mh=l.useMemo(()=>j4(Ct),[Ct]),Br=l.useMemo(()=>YS(Ct),[Ct]),Pl=KN(f,e.length),ph=P!==void 0,fh=e.length>0,hh=i!==void 0&&(e.length>0||s!=="__all__"),xh=s==="__all__"?"all sessions":"this session",gh=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.",bh=e.length===0?"Load":"Reload",qr=gs&&bn!==null?kn(bn.label):s==="__all__"?"All sessions":kn(s),Ll=E4(w),Hr=R4(Ll),vh=l.useMemo(()=>oC({logs:gn,conversationGroups:Ct,isLoading:y,timeDisplayFormat:b,slowResponseThresholdSeconds:g}),[gn,Ct,y,g,b]),yh=l.useCallback(ge=>{const qe=Br.get(ge.id);qe!==void 0&&he([qe,ge])},[Br]),Ol=P!==void 0?P:s==="__all__"?null:s;return t.jsxs("div",{className:"bg-background min-h-screen w-full overflow-x-clip text-foreground lg:h-screen lg:flex lg:flex-col lg:overflow-hidden",children:[t.jsx(k4,{liveConnection:w,alertsAction:t.jsx(LC,{}),settingsAction:t.jsx(w3,{})}),t.jsxs("button",{type:"button",onClick:El,className:O("group fixed top-1/2 right-3 z-50 inline-flex h-14 w-8 -translate-y-1/2 items-center justify-center rounded-l-md border border-border/70 bg-background/90 text-muted-foreground shadow-lg backdrop-blur transition-colors motion-reduce:transition-none hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none"),"aria-label":fe?"Show details panel":"Hide details panel",title:fe?"Show details panel":"Hide details panel",children:[t.jsx("span",{className:"absolute bottom-2 left-1 top-2 w-px rounded-full bg-border transition-colors group-hover:bg-foreground/35"}),fe?t.jsx(Lg,{className:"size-3.5"}):t.jsx(Ig,{className:"size-3.5"})]}),Me&&ct&&t.jsx(zo,{feature:"Inspector Pet",children:t.jsx(l.Suspense,{fallback:null,children:t.jsx(B5,{logs:e})})}),t.jsxs("div",{className:O("flex w-full min-w-0 flex-col lg:min-h-0 lg:flex-1 lg:flex-row lg:overflow-hidden",$e&&"cursor-col-resize select-none"),children:[!fe&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"fixed inset-0 z-30 bg-background/70 backdrop-blur-sm lg:hidden",onClick:El,"aria-label":"Close details panel"}),t.jsxs("aside",{className:"inspector-scrollbar fixed inset-x-3 bottom-3 top-24 z-40 order-1 overflow-y-auto rounded-lg border border-border bg-background/98 shadow-2xl max-lg:!w-auto lg:relative lg:inset-auto lg:order-2 lg:h-full lg:shrink-0 lg:rounded-none lg:border-y-0 lg:border-r-0 lg:shadow-none",style:{width:Ce},children:[t.jsx("button",{type:"button",className:"absolute bottom-0 left-0 top-0 z-30 hidden w-2 -translate-x-1/2 cursor-col-resize touch-none items-center justify-center lg:flex",onPointerDown:ih,onPointerMove:lh,onPointerUp:Rl,onPointerCancel:Rl,onDoubleClick:ch,"aria-label":"Resize details panel",title:"Drag to resize; double-click to reset",children:t.jsx("span",{className:"h-12 w-1 rounded-full bg-border transition-colors hover:bg-primary"})}),t.jsxs("div",{className:"flex min-h-full flex-col gap-4 p-4",children:[t.jsxs("div",{className:"sticky top-0 z-20 -mx-4 -mt-4 grid gap-2 border-b border-border/60 bg-background/95 px-4 pb-3 pt-4 backdrop-blur",children:[t.jsx(Oa,{label:"View",children:t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsx(yT,{}),t.jsx(jT,{preference:D,resolvedScale:$,onChange:J})]})}),t.jsx(Oa,{label:"Workspace",children:t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(nk,{labelledTrigger:!0}),t.jsx(s4,{currentSessionId:Ol,logCount:e.length,labelledTrigger:!0})]})})]}),t.jsxs(Oa,{label:"Current scope",children:[t.jsxs("div",{className:"mb-2 rounded-md border border-border/50 bg-muted/25 px-3 py-2",children:[t.jsx("div",{className:"truncate font-mono text-xs font-semibold text-text-link",title:qr,children:qr}),t.jsx("div",{className:"mt-1 text-[11px] text-muted-foreground",children:ph?"Pinned session":"Live Inspector data"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsx(_o,{label:B===null?"Requests":"Results",value:gn.length}),t.jsx(_o,{label:"Sessions",value:n.length}),t.jsx(_o,{label:"Input",value:Ee(gs?Al:M)}),t.jsx(_o,{label:"Output",value:Ee(gs?Il:k)})]}),N!==void 0&&t.jsx("div",{className:"mt-2 rounded-md border border-border/50 bg-muted/25 px-2 py-2",children:t.jsx(Oo,{progress:N})})]}),gs&&bn!==null&&t.jsx(AT,{label:bn.label,logs:On,totalIn:Al,totalOut:Il,timeDisplayFormat:b,contextSummary:uh,showBackLink:bn.showBackLink}),gs&&P!==void 0&&R.length>0&&t.jsx(Cd,{memberships:R}),t.jsx("div",{className:"flex-1"}),t.jsx(w4,{currentSessionId:Ol,logCount:e.length,onResultChange:ne})]})]})]}),t.jsxs("main",{className:"inspector-scrollbar order-2 min-w-0 lg:order-1 lg:h-full lg:flex-1 lg:overflow-y-auto",children:[t.jsxs("div",{className:"bg-background/95 shadow-[0_12px_36px_rgba(0,0,0,0.18),inset_0_-1px_0_rgba(255,255,255,0.045)] sticky top-0 z-30 px-4 py-3 lg:px-5",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("div",{className:"min-w-[180px] flex-1",children:[t.jsx("div",{className:"text-sm font-semibold text-foreground",children:"Logs"}),t.jsx("div",{className:"mt-0.5 font-mono text-[11px] text-muted-foreground",children:qr})]}),t.jsx(wT,{visible:ct,onToggle:dh}),u!==void 0&&t.jsxs(t.Fragment,{children:[t.jsx("input",{ref:G,type:"file",accept:".zip,.json,.jsonl,application/zip,application/json",className:"hidden",onChange:qt}),t.jsx("button",{type:"button",onClick:Re,disabled:me,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:me?t.jsx("span",{children:"Importing..."}):t.jsxs(t.Fragment,{children:[t.jsx(pu,{className:"size-3.5"}),t.jsx("span",{children:"Import"})]})})]}),Pl.redacted&&t.jsx("button",{type:"button",onClick:()=>{ae("redacted")},disabled:X!==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:X==="redacted"?t.jsx("span",{children:"Exporting..."}):t.jsxs(t.Fragment,{children:[t.jsx(Ws,{className:"size-3.5"}),t.jsx("span",{children:"Export"})]})}),Pl.raw&&t.jsx("button",{type:"button",onClick:()=>{ae("raw")},disabled:X!==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:X==="raw"?t.jsx("span",{children:"Exporting..."}):t.jsxs(t.Fragment,{children:[t.jsx(q0,{className:"size-3.5"}),t.jsx("span",{children:"Raw"})]})}),c!==void 0&&t.jsxs("button",{type:"button",onClick:xn,disabled:y,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Reload this session from stored logs",children:[t.jsx(yt,{className:O("size-3.5",y&&"animate-spin motion-reduce:animate-none")}),t.jsx("span",{children:bh})]}),t.jsxs("button",{type:"button",onClick:dt,disabled:!fh,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Clear the current view. Stored logs remain reloadable.",children:[t.jsx(an,{className:"size-3.5"}),t.jsx("span",{children:"Clear"})]}),i!==void 0&&t.jsxs("button",{type:"button",onClick:xs,disabled:!hh||ie,className:"bg-red-500/[0.07] hover:bg-red-500/[0.12] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-red-200 shadow-[inset_0_0_0_1px_rgba(248,113,113,0.14)] transition-colors hover:text-red-100 focus-visible:ring-1 focus-visible:ring-red-300 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Delete persisted history for the selected session.",children:[t.jsx(an,{className:"size-3.5"}),t.jsx("span",{children:"Delete"})]})]}),S===void 0&&N!==void 0&&t.jsx("div",{className:"mt-2 rounded-md bg-black/20 px-2 py-2 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:t.jsx(Oo,{progress:N})}),C!==void 0&&t.jsxs("div",{role:"alert",className:"mt-2 flex flex-wrap items-center gap-2 rounded-md border border-red-400/25 bg-red-500/10 px-3 py-2 text-xs text-red-100",children:[t.jsxs("span",{className:"min-w-0 flex-1",children:["Session logs could not be loaded. ",C," Existing logs remain visible."]}),c!==void 0&&t.jsxs("button",{type:"button",onClick:xn,className:"inline-flex h-7 items-center gap-1 rounded-md bg-black/15 px-2 font-medium transition-colors hover:bg-black/25 focus-visible:ring-1 focus-visible:ring-current focus-visible:outline-none",children:[t.jsx(yt,{className:"size-3"}),"Retry"]})]}),B!==null&&t.jsxs("div",{className:"mt-2 flex items-center gap-3 rounded-md bg-cyan-400/[0.07] px-3 py-2 shadow-[inset_2px_0_0_rgba(103,232,249,0.35),inset_0_0_0_1px_rgba(103,232,249,0.08)]",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"truncate text-xs font-medium text-cyan-50",children:B.question}),t.jsxs("div",{className:"mt-0.5 text-[10px] text-muted-foreground",children:["Showing ",String(gn.length)," loaded logs from"," ",String(B.logIds.length)," linked results"]})]}),t.jsxs("button",{type:"button",onClick:()=>ne(null),className:"inline-flex h-7 shrink-0 items-center gap-1 rounded-md bg-black/20 px-2 text-[11px] text-muted-foreground transition-colors hover:bg-black/30 hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",children:[t.jsx(Ks,{className:"size-3"}),"All logs"]})]}),B===null&&t.jsx(kd,{logs:e,pagination:S,embedded:!0}),m===void 0&&H!==null&&t.jsx("div",{className:"mt-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:H}),m===void 0&&se!==null&&t.jsx("div",{className:"mt-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:se}),m===void 0&&ve!==null&&se===null&&t.jsx("div",{className:"mt-2 rounded-md border border-cyan-400/25 bg-cyan-500/10 px-3 py-2 text-xs text-cyan-100",children:ve}),w!==void 0&&w.status!=="live"&&v!==void 0&&j!==void 0&&t.jsx(N4,{state:w,hasLogs:e.length>0,onRetry:v,onStop:j})]}),t.jsxs("div",{className:"px-4 py-4 lg:px-5",children:[t.jsx(oT,{stats:vh}),B!==null&&gn.length===0?t.jsx("div",{className:"py-16 text-center text-muted-foreground",children:t.jsxs("div",{className:"mx-auto max-w-xl rounded-[8px] bg-white/[0.035] px-5 py-8 shadow-[inset_0_1px_0_rgba(255,255,255,0.045),0_18px_52px_rgba(0,0,0,0.18)]",children:[t.jsx("p",{className:"text-sm font-medium text-foreground",children:"No linked logs are loaded"}),t.jsx("p",{className:"mt-2 text-xs leading-5 text-muted-foreground",children:"Assistant found evidence, but none of its linked log IDs are in the current loaded window. Open an evidence card in Assistant or restore the full log view."}),t.jsx("button",{type:"button",onClick:()=>ne(null),className:"mt-4 inline-flex h-8 items-center rounded-md bg-cyan-400/10 px-3 text-xs text-cyan-100 transition-colors hover:bg-cyan-400/16",children:"Show all logs"})]})}):e.length===0?s!=="__all__"?t.jsx("div",{className:"py-16 text-center text-muted-foreground",children:t.jsxs("div",{className:"bg-white/[0.035] shadow-[inset_0_1px_0_rgba(255,255,255,0.045),0_18px_52px_rgba(0,0,0,0.18)] mx-auto max-w-xl space-y-4 rounded-[8px] px-4 py-8",children:[t.jsx("p",{className:"text-sm font-medium",children:y?"Loading session data...":C===void 0?"No logs loaded for this session":"Session logs could not be loaded"}),t.jsx("p",{className:"inline-block max-w-full rounded bg-muted px-3 py-1 font-mono text-xs break-all",children:kn(s)}),N!==void 0&&t.jsx("div",{className:"mx-auto max-w-md rounded-md bg-black/20 px-2 py-2 text-left shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:t.jsx(Oo,{progress:N})}),R.length>0&&t.jsx("div",{className:"text-left",children:t.jsx(Cd,{memberships:R})}),!y&&t.jsxs("div",{className:"flex flex-col items-center gap-3 text-xs",children:[t.jsx("p",{children:"Stored logs may still be available."}),t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[c!==void 0&&t.jsxs("button",{type:"button",onClick:xn,className:"bg-white/[0.045] hover:bg-white/[0.075] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",children:[t.jsx(yt,{className:"size-3.5"}),t.jsx("span",{children:"Load session"})]}),I?t.jsx("a",{href:ji("/"),className:"inline-flex h-8 items-center rounded-md px-3 text-xs text-muted-foreground underline transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",children:"Back to all sessions"}):t.jsx("button",{type:"button",onClick:()=>r("__all__"),className:"inline-flex h-8 items-center rounded-md px-3 text-xs text-muted-foreground underline transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",children:"Show all sessions"})]})]})]})}):t.jsx("div",{className:"py-16 text-center text-muted-foreground",children:t.jsxs("div",{className:"bg-white/[0.035] shadow-[inset_0_1px_0_rgba(255,255,255,0.045),0_18px_52px_rgba(0,0,0,0.18)] mx-auto max-w-2xl space-y-4 rounded-[8px] px-4 py-8",children:[t.jsx("p",{className:"text-sm font-medium",children:Hr.title}),t.jsx("p",{className:"mx-auto max-w-xl text-xs leading-relaxed text-muted-foreground",children:Hr.description}),Ll==="empty"&&n.length>0&&t.jsx("p",{className:"mx-auto max-w-xl text-xs leading-relaxed text-muted-foreground",children:"Pick a session from the filter panel to load stored logs on demand."}),Hr.showConnectionCommands&&oe!==null&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex flex-col items-center gap-2",children:HN(oe).map(ge=>t.jsx(vT,{command:ge},ge))}),t.jsx("p",{className:"mx-auto max-w-xl text-xs leading-relaxed text-muted-foreground",children:"Container note: if your AI tool runs in a different container or host than Agent Inspector, replace localhost with an address reachable from that tool and verify the network/firewall path."})]})]})}):t.jsxs("div",{ref:Be,tabIndex:0,"aria-label":"Captured logs",className:"flex flex-col gap-2 rounded-md focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-none",children:[t.jsx("div",{ref:je,children:t.jsx(U4,{groups:Ct,viewMode:p,strip:h,slowResponseThresholdSeconds:g,cacheTrends:mh,onCompareWithPrevious:yh,comparisonPredecessors:Br,onClearGroup:d,defaultExpanded:Ct.length===1,timeDisplayFormat:b})}),B===null&&t.jsx("div",{className:"mt-3",children:t.jsx(kd,{logs:e,pagination:S})})]})]})]})]}),t.jsx(Pt,{open:U,onOpenChange:W,children:t.jsx(Lt,{className:H4,children:t.jsx(V4,{onCancel:()=>W(!1),onExportRedacted:ht,onConfirmRaw:hn})})}),t.jsx(Pt,{open:Se,onOpenChange:Ne,children:t.jsxs(Lt,{className:"border-red-500/20 bg-zinc-950 text-zinc-100 sm:max-w-md",children:[t.jsxs(Ft,{children:[t.jsxs(Ut,{children:["Delete ",xh," history?"]}),t.jsx(Zs,{children:"Clear only hides logs from the UI. Delete removes stored history from disk."})]}),t.jsxs("div",{className:"rounded-md bg-red-500/[0.08] px-3 py-3 text-sm text-red-100 shadow-[inset_0_0_0_1px_rgba(248,113,113,0.16)]",children:[t.jsx("span",{className:"block font-medium",children:"This is a full history delete."}),t.jsx("span",{className:"mt-1 block text-xs text-red-200/80",children:gh})]}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx(ee,{type:"button",variant:"outline",size:"sm",disabled:ie,onClick:()=>Ne(!1),children:"Cancel"}),t.jsx(ee,{type:"button",variant:"destructive",size:"sm",disabled:ie,onClick:Qe,children:ie?"Deleting...":"Delete history"})]})]})}),we!==null&&t.jsx(zo,{feature:"Compare",children:t.jsx(l.Suspense,{fallback:null,children:t.jsx(U5,{left:we[0],right:we[1],leftDisplayNumber:Sd(we[0],Ml),rightDisplayNumber:Sd(we[1],Ml),onClose:ah})})})]})}function PT(e,n,s){return n==="__all__"&&s==="__all__"?e:e.filter(o=>!(n!=="__all__"&&o.sessionId!==n||s!=="__all__"&&o.model!==s))}function To(e,n){if(e.length===0)return[...n];if(n.length===0)return[...e];const s=new Map;for(const o of e)s.set(o.id,o);for(const o of n)s.set(o.id,o);return[...s.values()].toSorted((o,r)=>o.id-r.id)}function Nn(e,n){const s=new Set;for(const o of e)o!==""&&s.add(o);for(const o of n)o!==""&&s.add(o);return[...s].sort()}function LT(e){const n=new URLSearchParams({compact:"1"});e!==void 0&&n.set("sessionId",e);const s=Th();return s.ok?Eh(s.runtime,`/api/logs/stream?${n.toString()}`):null}function OT(e){const n=LT(e);return n===null?null:new EventSource(n)}const DT=Ot([T({type:re("init"),logs:K(As)}),T({type:re("update"),log:As})]),zT=T({logs:K(As),total:E().int().nonnegative(),limit:E().int().positive(),hasOlder:_e(),hasNewer:_e(),oldestLogId:E().int().positive().nullable(),newestLogId:E().int().positive().nullable()}),$T=K(x()),Rd=T({success:_e(),cleared:E().int().nonnegative(),logFilesRewritten:E().int().nonnegative().optional(),chunkFilesDeleted:E().int().nonnegative(),sessionArchiveLogsDeleted:E().int().nonnegative().optional()});function FT(e,n){const s=[];for(const o of e)for(const r of o.members)r.sessionId===n&&s.push({groupId:o.id,groupTitle:o.title,groupKind:o.kind,groupStatus:o.status,groupTask:o.task,groupProject:o.project,groupEvidence:o.evidence,member:r});return s}function Eo(e){const n=new Set;for(const s of e)s.sessionId!==null&&s.sessionId!==""&&n.add(s.sessionId);return[...n]}function UT(e){const n=new Set;for(const s of e)s.model!==null&&s.model!==""&&n.add(s.model);return[...n]}const BT=100,qT=12,HT=1800,Tl=100,ur=500,rh=200,yi=2e4,WT=1e4,VT=3e3,KT=1e4;function GT(e,n,s=Tl){const o=new URLSearchParams({cursor:"1",compact:"1",limit:String(s),sessionId:e});switch(n.kind){case"oldest":o.set("anchor","oldest");break;case"older":o.set("beforeLogId",String(n.beforeLogId));break;case"newer":o.set("afterLogId",String(n.afterLogId));break}return`/api/logs?${o.toString()}`}function Qt(e){const n=new Map;for(let s=0;s<e.length;s++){const o=e[s];o!==void 0&&n.set(o.id,s)}return n}function Ms(e,n,s=Tl){return De(GT(e,n,s),zT,yi)}async function JT(e,n){const s=new Set;let o=await Ms(e,{kind:"oldest"},ur);for(const a of o.logs)s.add(a.id);n(s.size,1);let r=1;for(;o.hasNewer&&o.newestLogId!==null&&r<rh;){o=await Ms(e,{kind:"newer",afterLogId:o.newestLogId},ur);for(const a of o.logs)s.add(a.id);r+=1,n(s.size,r)}return{ids:[...s],truncated:o.hasNewer}}async function YT(){try{return{deleted:(await Ge("/api/groups",Jd,{method:"DELETE"})).deleted,ok:!0}}catch{return{deleted:0,ok:!1}}}function eE({initialSessionId:e}={}){const[n,s]=l.useState([]),[o,r]=l.useState(e??"__all__"),[a,i]=l.useState("__all__"),[c,d]=l.useState([]),{notice:m,showToast:u,dismissToast:p}=bf(),[f,h]=l.useState(T4),[g,b]=l.useState(null),[y,w]=l.useState(e!==void 0),[v,j]=l.useState(null),[S,N]=l.useState(void 0),[C,R]=l.useState([]),[,I]=l.useTransition(),P=l.useRef(null),M=l.useRef(null),k=l.useRef(null),A=l.useRef(!0),D=l.useRef(null),$=l.useRef(0),J=l.useRef(null),X=l.useRef(null),F=l.useRef(new Map),H=l.useRef([]),Y=l.useRef(null),U=l.useCallback(G=>{u({message:G,tone:"error"})},[u]),W=l.useCallback(()=>{X.current!==null&&(clearInterval(X.current),X.current=null),J.current=null,N(void 0)},[]),me=l.useCallback((G,_,L=0,V=0)=>{X.current!==null&&clearInterval(X.current);const oe=Date.now();J.current=oe;const ce=()=>{$.current===_&&N({label:G,elapsedMs:Date.now()-oe,timeoutMs:yi,loadedLogs:L,loadedPages:V})};ce(),X.current=setInterval(ce,250)},[]),be=l.useCallback((G,_,L,V)=>{const oe=J.current;oe===null||$.current!==_||N({label:G,elapsedMs:Date.now()-oe,timeoutMs:yi,loadedLogs:L,loadedPages:V})},[]),ve=l.useMemo(()=>PT(n,o,a),[n,o,a]),z=l.useMemo(()=>Nn(c,Eo(n)),[n,c]),se=l.useMemo(()=>UT(n),[n]),te=l.useCallback(()=>{Ge("/api/sessions",$T).then(G=>{d(_=>Nn(_,G))}).catch(()=>{})},[]),Se=l.useCallback(()=>{Y.current=null;const G=H.current;H.current=[],G.length!==0&&I(()=>{s(_=>{const L=To(_,G);return F.current=Qt(L),L})})},[I]),Ne=l.useCallback(G=>{H.current.push(G),Y.current===null&&(Y.current=setTimeout(Se,BT))},[Se]),ie=l.useCallback(()=>{P.current&&P.current.close(),M.current!==null&&(clearTimeout(M.current),M.current=null),h(_=>kt(_,{type:"connect-requested"}));const G=OT(e);if(G===null){h(_=>kt(_,{type:"recoverable-error",message:"The browser runtime does not provide a valid log stream endpoint."})),U("Failed to resolve the live stream endpoint");return}P.current=G,G.onmessage=_=>{try{const L=String(_.data),V=JSON.parse(L),oe=DT.safeParse(V);if(!oe.success){h(Q=>kt(Q,{type:"recoverable-error",message:"The live stream returned invalid data."})),U("Failed to parse SSE data");return}const ce=oe.data;ce.type==="init"?(Y.current!==null&&(clearTimeout(Y.current),Y.current=null),H.current=[],s(Q=>{const pe=To(Q,ce.logs);return F.current=Qt(pe),pe}),d(Q=>Nn(Q,Eo(ce.logs))),k.current!==null&&(clearTimeout(k.current),k.current=null),h(Q=>kt(Q,{type:"message-received",at:Date.now()})),p()):ce.type==="update"&&(d(Q=>ce.log.sessionId===null||ce.log.sessionId===""?Q:Nn(Q,[ce.log.sessionId])),Ne(ce.log),k.current!==null&&(clearTimeout(k.current),k.current=null),h(Q=>kt(Q,{type:"message-received",at:Date.now()})))}catch{h(L=>kt(L,{type:"recoverable-error",message:"The live stream returned malformed JSON."})),U("Failed to parse SSE data")}},G.onerror=()=>{const _=navigator.onLine;h(L=>kt(L,{type:"connection-lost",online:_,message:"The live stream disconnected."})),G.close(),!(!_||!A.current)&&(k.current===null&&(k.current=setTimeout(()=>{k.current=null,h(L=>kt(L,{type:"stale-timeout"}))},KT)),M.current=setTimeout(ie,VT))}},[p,e,Ne,U]),le=l.useCallback(()=>{A.current=!0,M.current!==null&&(clearTimeout(M.current),M.current=null),ie()},[ie]),fe=l.useCallback(()=>{A.current=!1,P.current?.close(),P.current=null,M.current!==null&&(clearTimeout(M.current),M.current=null),k.current!==null&&(clearTimeout(k.current),k.current=null),h(G=>kt(G,{type:"stop-retrying"}))},[]),ye=l.useCallback(G=>{if(e===void 0)return;const _=$.current+1;$.current=_,w(!0),j(null),me("Loading session logs",_),p(),Ms(e,G).then(L=>{if($.current!==_)return;const V=L.logs;F.current=Qt(V),s(V),b(L),r(e),w(!1),j(null),W(),p()}).catch(L=>{if($.current!==_)return;w(!1),W();const V=L instanceof Error?L.message:"Failed to load session logs";j(V),U(V)})},[p,e,U,me,W]),Ce=l.useCallback(G=>{const _=$.current+1;$.current=_,w(!0),j(null),me("Reloading full session",_),p(),(async()=>{const L=[];let V=await Ms(G,{kind:"oldest"},ur);L.push(...V.logs),be("Reloading full session",_,L.length,1);let oe=1;for(;V.hasNewer&&V.newestLogId!==null&&oe<rh;)V=await Ms(G,{kind:"newer",afterLogId:V.newestLogId},ur),L.push(...V.logs),oe+=1,be("Reloading full session",_,L.length,oe);$.current===_&&(s(ce=>{const Q=To(ce,L);return F.current=Qt(Q),Q}),d(ce=>Nn(ce,[G])),w(!1),j(null),W(),V.hasNewer?u({message:`Loaded ${String(L.length)} logs for this session. More history is available.`,tone:"success"}):p())})().catch(L=>{if($.current!==_)return;w(!1),W();const V=L instanceof Error?L.message:"Failed to reload session logs";j(V),U(V)})},[p,U,u,me,W,be]);l.useEffect(()=>{if(e===void 0){R([]);return}let G=!1;return De("/api/groups",Zd,WT).then(_=>_.groups).then(_=>{G||_===null||R(FT(_,e))}).catch(()=>{G||R([])}),()=>{G=!0}},[e]),l.useEffect(()=>{te()},[te]),l.useEffect(()=>()=>{W()},[W]),l.useEffect(()=>{e!==void 0&&ye({kind:"newest"})},[e,ye]),l.useEffect(()=>{e===void 0&&o!=="__all__"&&Ce(o)},[e,Ce,o]),l.useEffect(()=>{if(e!==void 0)return;ie();const G=()=>{P.current?.close(),P.current=null,M.current!==null&&(clearTimeout(M.current),M.current=null),k.current!==null&&(clearTimeout(k.current),k.current=null),h(L=>kt(L,{type:"browser-offline"}))},_=()=>{A.current&&ie()};return window.addEventListener("offline",G),window.addEventListener("online",_),()=>{window.removeEventListener("offline",G),window.removeEventListener("online",_),P.current&&(P.current.close(),P.current=null),M.current!==null&&(clearTimeout(M.current),M.current=null),k.current!==null&&(clearTimeout(k.current),k.current=null),Y.current!==null&&(clearTimeout(Y.current),Y.current=null)}},[ie,e]),l.useEffect(()=>{const G=window.location.hash;if(!G.startsWith("#log-")||D.current===G)return;const _=G.slice(1),L=Number(_.replace(/^log-/,""));Number.isInteger(L)&&L>0&&ds({logId:L,tab:"request"});let V=!1,oe=0,ce=null,Q=null;const pe=()=>{if(V)return;const ae=document.getElementById(_);if(ae!==null){D.current=G,ae.scrollIntoView({block:"center",behavior:Ff(Uf())}),ae instanceof HTMLElement&&(ce=ae,ae.setAttribute("data-deep-link-highlight","true"),Q=window.setTimeout(()=>{ae.removeAttribute("data-deep-link-highlight")},HT),ae.focus({preventScroll:!0}),ae.getAttribute("data-nav-action")==="expand"&&ae.click());return}oe+=1,oe<qT&&window.setTimeout(pe,100)};return pe(),()=>{V=!0,Q!==null&&window.clearTimeout(Q),ce!==null&&ce.removeAttribute("data-deep-link-highlight")}},[ve.length]);const Ie=l.useCallback(()=>{const G=Eo(n);W(),w(!1),F.current.clear(),s([]),b(null),d(_=>Nn(_,G)),u({message:"Cleared the current view. Stored logs are still reloadable.",tone:"success"})},[n,u,W]),$e=l.useCallback(G=>{if(G.length===0)return;const _=new Set(G);s(L=>{const V=L.filter(ce=>_.has(ce.id)),oe=L.filter(ce=>!_.has(ce.id));return d(ce=>Nn(ce,Eo(V))),F.current=Qt(oe),oe}),u({message:"Cleared this group from the current view.",tone:"success"})},[u]),Pe=l.useCallback(async()=>{const G=$.current+1;$.current=G,w(!0),W(),p();try{if(o==="__all__"){me("Deleting stored history",G);const Q=await Ge("/api/logs",Rd,{method:"DELETE"}),pe=await YT();if($.current!==G)return;s([]),F.current.clear(),b(null),d([]),R([]),w(!1),W();const ae=pe.ok?` Cleared ${pe.deleted.toString()} group${pe.deleted===1?"":"s"}.`:" Group cleanup failed; open Groups to retry Clear.";u({message:`Deleted ${Q.cleared.toString()} stored log${Q.cleared===1?"":"s"} across all sessions.${ae}`,tone:pe.ok?"success":"error"});return}const _=o;me("Deleting session history",G);const L=await JT(_,(Q,pe)=>{be("Deleting session history",G,Q,pe)}),V=new Set(L.ids);for(const Q of n)Q.sessionId===_&&V.add(Q.id);const oe=[...V].filter(Q=>Number.isInteger(Q)&&Q>=0);if(oe.length===0){if($.current!==G)return;s(Q=>{const pe=Q.filter(ae=>ae.sessionId!==_);return F.current=Qt(pe),pe}),b(Q=>Q===null?null:{...Q,logs:Q.logs.filter(pe=>pe.sessionId!==_)}),d(Q=>Q.filter(pe=>pe!==_)),w(!1),W(),u({message:"No stored log records were found for this session.",tone:"success"});return}const ce=await Ge("/api/logs",Rd,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({ids:oe})});if($.current!==G)return;s(Q=>{const pe=Q.filter(ae=>ae.sessionId!==_);return F.current=Qt(pe),pe}),b(Q=>Q===null?null:{...Q,logs:Q.logs.filter(pe=>pe.sessionId!==_)}),d(Q=>Q.filter(pe=>pe!==_)),w(!1),W(),u({message:`Deleted ${ce.cleared.toString()} stored log${ce.cleared===1?"":"s"} for this session${L.truncated?". More history may remain.":"."}`,tone:L.truncated?"error":"success"})}finally{$.current===G&&(w(!1),W())}},[n,p,o,u,me,W,be]),Ze=l.useCallback(()=>{if(e!==void 0){ye({kind:"newest"});return}if(o==="__all__"){te();return}Ce(o)},[e,ye,te,Ce,o]),Bt=l.useCallback(async G=>{const _=new FormData;_.set("file",G);const L=await Ge("/api/logs/import",Nx,{method:"POST",body:_});return s(V=>{const oe=new Set(L.logs.map(Q=>Q.id)),ce=To(V.filter(Q=>!oe.has(Q.id)),L.logs);return F.current=Qt(ce),ce}),r(L.sessionId),i("__all__"),b(null),p(),L},[p]),{strip:ct,captureMode:Fe,slowResponseThresholdSeconds:Me,timeDisplayFormat:Le}=Pi(),B=Fe,ne=l.useCallback(()=>{ye({kind:"oldest"})},[ye]),we=l.useCallback(()=>{ye({kind:"newest"})},[ye]),he=l.useCallback(()=>{const G=n[0],_=g?.oldestLogId??G?.id??null;_!==null&&ye({kind:"older",beforeLogId:_})},[n,ye,g]),je=l.useCallback(()=>{const G=n[n.length-1],_=g?.newestLogId??G?.id??null;_!==null&&ye({kind:"newer",afterLogId:_})},[n,ye,g]),Be=l.useMemo(()=>{if(e!==void 0)return{isLoading:y,loadProgress:S,total:g?.total??null,pageSize:g?.limit??Tl,hasOlder:g?.hasOlder??!1,hasNewer:g?.hasNewer??!1,oldestLogId:g?.oldestLogId??null,newestLogId:g?.newestLogId??null,onOldest:ne,onOlder:he,onNewer:je,onNewest:we}},[e,we,je,he,ne,g,S,y]);return t.jsxs(t.Fragment,{children:[t.jsx(vf,{notice:m,onDismiss:p}),t.jsx(k1,{}),t.jsx(IT,{logs:ve,sessions:z,models:se,selectedSession:o,selectedModel:a,onSessionChange:r,onModelChange:i,onClearAll:Ie,onDeleteCurrentView:Pe,onReloadSession:e!==void 0||o!=="__all__"?Ze:void 0,onClearGroup:$e,onNotify:u,onImportLogs:e===void 0?Bt:void 0,isLoading:e===void 0&&f.status==="connecting"&&f.lastSuccessAt===null||y,liveConnection:e===void 0?f:void 0,onRetryLiveConnection:le,onStopLiveConnection:fe,pagination:Be,sessionLoadProgress:S,sessionLoadError:v??void 0,sessionMemberships:C,viewMode:B,captureMode:Fe,strip:ct,slowResponseThresholdSeconds:Me,timeDisplayFormat:Le,hideSessionFilter:e!==void 0,pinnedSessionId:e})]})}export{rn as $,Z4 as A,ke as B,M0 as C,Pt as D,QT as E,Ve as F,xe as G,SS as H,cg as I,ZT as J,tu as K,K5 as L,lu as M,NS as N,CS as O,eE as P,In as Q,Hg as R,s_ as S,Qp as T,ii as U,er as V,p4 as W,Ks as X,y0 as Y,Is as Z,Z as _,Gj as a,Ae as a0,Od as a1,$5 as a2,i0 as a3,Ul as b,q as c,cu as d,it as e,Oe as f,Hp as g,St as h,Lt as i,Ft as j,Ut as k,uu as l,ef as m,tn as n,ut as o,bg as p,hs as q,Os as r,et as s,tt as t,Hi as u,nt as v,ds as w,As as x,F_ as y,Q4 as z};
|