context-lens 0.4.2 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -27,8 +27,8 @@
27
27
  `)),c=A(()=>{const w=n.diffData;if(!w)return"var(--text-dim)";const I=w.delta>=0;return n.deltaTone==="bad"?I?"var(--accent-red)":"var(--accent-green)":I?"var(--accent-green)":"var(--accent-red)"});function p(w){return Math.abs(w)>=zm}function d(w,I){return p(w)?I==="up"?"diff-tone-up":"diff-tone-down":"diff-tone-muted"}function m(w){return w.type==="same"?"diff-tone-muted":w.type==="add"?d(w.delta,"up"):d(w.delta,"down")}function v(w){s("categoryClick",w)}return(w,I)=>{const S=gn("tooltip");return o.value?(g(),b("section",dm,[u("div",fm,[I[0]||(I[0]=u("span",{class:"panel-title"},"Context Diff",-1)),e.diffData?(g(),b(ve,{key:0},[u("span",pm,"Turn "+M(e.diffData.prevTurnNum)+" → "+M(e.diffData.currTurnNum),1),u("span",{class:"diff-delta",style:Me({color:c.value})},M(e.diffData.delta>=0?"+":"")+M(Y(_e)(e.diffData.delta)),5)],64)):le("",!0)]),u("div",hm,[e.diffData?(g(),b(ve,{key:0},[e.showTapes&&e.currentEntry&&e.previousEntry?(g(),b("div",vm,[u("div",mm,[u("span",gm,"T"+M(e.diffData.prevTurnNum),1),u("div",ym,[(g(!0),b(ve,null,Te(e.previousEntry.composition,_=>{var C;return g(),b("div",{key:"prev-"+_.category,class:"diff-tape-seg",style:Me({flex:_.tokens,background:((C=Y(Ye)[_.category])==null?void 0:C.color)??"#475569"})},null,4)}),128))]),u("span",_m,M(Y(_e)(e.previousEntry.contextInfo.totalTokens)),1)]),u("div",bm,[u("span",wm,"T"+M(e.diffData.currTurnNum),1),u("div",km,[(g(!0),b(ve,null,Te(e.currentEntry.composition,_=>{var C;return g(),b("div",{key:"curr-"+_.category,class:"diff-tape-seg",style:Me({flex:_.tokens,background:((C=Y(Ye)[_.category])==null?void 0:C.color)??"#475569"})},null,4)}),128))]),u("span",xm,M(Y(_e)(e.currentEntry.contextInfo.totalTokens)),1)])])):le("",!0),e.diffData.topIncreases.length>0||e.diffData.topDecreases.length>0?(g(),b("div",$m,[e.summaryMode==="combined"?(g(),b("div",Sm,[u("span",Cm,M(e.combinedLabel),1),(g(!0),b(ve,null,Te(e.diffData.topIncreases,_=>(g(),b("button",{key:"inc-"+_.group,class:he(["diff-summary-chip",d(_.delta,"up")]),onClick:C=>v(_.category)},M(_.label)+" +"+M(Y(_e)(_.delta)),11,Tm))),128)),(g(!0),b(ve,null,Te(e.diffData.topDecreases,_=>(g(),b("button",{key:"dec-"+_.group,class:he(["diff-summary-chip",d(_.delta,"down")]),onClick:C=>v(_.category)},M(_.label)+" "+M(Y(_e)(_.delta)),11,Mm))),128))])):(g(),b(ve,{key:1},[e.diffData.topIncreases.length>0?(g(),b("div",Em,[u("span",Pm,M(e.growthLabel),1),(g(!0),b(ve,null,Te(e.diffData.topIncreases,_=>(g(),b("button",{key:"inc-"+_.group,class:he(["diff-summary-chip",d(_.delta,"up")]),onClick:C=>v(_.category)},M(_.label)+" +"+M(Y(_e)(_.delta)),11,Im))),128))])):le("",!0),e.diffData.topDecreases.length>0?(g(),b("div",Am,[u("span",Lm,M(e.shrinkLabel),1),(g(!0),b(ve,null,Te(e.diffData.topDecreases,_=>(g(),b("button",{key:"dec-"+_.group,class:he(["diff-summary-chip",d(_.delta,"down")]),onClick:C=>v(_.category)},M(_.label)+" "+M(Y(_e)(_.delta)),11,Om))),128))])):le("",!0)],64))])):le("",!0),e.hideUnchanged&&r.value.length>0?(g(),b("div",Rm,[Be((g(),b("span",Dm,[xe(M(r.value.length)+" unchanged "+M(r.value.length===1?"category":"categories")+" hidden ",1)])),[[S,l.value]])])):le("",!0),(g(!0),b(ve,null,Te(i.value,(_,C)=>(g(),b("button",{key:"line-"+C,class:he(["diff-line",["diff-"+_.type,m(_)]]),onClick:z=>v(_.category)},M(_.text),11,Nm))),128))],64)):(g(),b("span",Fm,M(e.emptyText),1))])])):le("",!0)}}}),ac=at(Bm,[["__scopeId","data-v-f23cde3c"]]),Hm={key:0,class:"panel panel--primary"},jm={class:"panel-head"},Vm={key:0,class:"finding-count"},Um={key:0,class:"audit-row"},Km=["onClick"],Wm={class:"rec-content"},qm={class:"rec-title"},Gm={class:"rec-detail"},Jm=Qe({__name:"HealthFindings",props:{entry:{},recommendations:{},auditTooltip:{type:Function}},emits:["recommendationClick"],setup(e,{emit:t}){const n=t;function s(o){o.messageIndex!=null&&n("recommendationClick",o)}return(o,i)=>{const r=gn("tooltip");return e.entry.healthScore||e.recommendations.length>0?(g(),b("section",Hm,[u("div",jm,[i[0]||(i[0]=u("span",{class:"panel-title"},"Findings",-1)),e.recommendations.length?(g(),b("span",Vm,M(e.recommendations.length),1)):le("",!0)]),e.entry.healthScore?(g(),b("div",Um,[(g(!0),b(ve,null,Te(e.entry.healthScore.audits,l=>Be((g(),b("span",{key:l.id,class:he(["audit-chip",l.score>=90?"audit-good":l.score>=50?"audit-warn":"audit-bad"])},[xe(M(l.name)+" ",1),u("b",null,M(l.score),1)],2)),[[r,e.auditTooltip(l)]])),128))])):le("",!0),e.recommendations.length>0?(g(),b("div",{key:1,class:he(["panel-body rec-list",{"rec-list--scroll":e.recommendations.length>3}])},[(g(!0),b(ve,null,Te(e.recommendations,(l,c)=>(g(),b("div",{key:c,class:he(["rec",{"rec-clickable":l.messageIndex!=null}]),onClick:p=>l.messageIndex!=null&&s(l)},[u("i",{class:he(["rec-icon",[`sev-${l.severity}`,l.severity==="high"?"i-carbon-warning-alt":l.severity==="med"?"i-carbon-information":"i-carbon-checkmark"]])},null,2),u("div",Wm,[u("div",qm,M(l.title),1),u("div",Gm,M(l.detail),1)]),u("span",{class:he(["rec-impact",`sev-${l.severity}`])},M(l.impact),3)],10,Km))),128))],2)):le("",!0)])):le("",!0)}}}),Ym=at(Jm,[["__scopeId","data-v-f1490cbd"]]),Xm={key:0,class:"overview"},Zm={class:"narrative-copy"},Qm={class:"narrative-title"},eg={class:"narrative-detail"},tg={class:"narrative-actions"},ng={class:"stats-grid"},sg={class:"stat-detail"},og={key:0,class:"stat-projection"},ig={key:1,class:"stat-projection stat-projection--warn"},rg={key:2,class:"stat-tape"},lg={key:3,class:"util-track"},ag={class:"stat-card"},cg={class:"stat-readout green"},ug={class:"stat-detail"},dg={class:"stat-card"},fg={class:"stat-readout"},pg={key:0,class:"stat-detail"},hg={key:0,class:"stat-card stat-card--health"},vg={class:"health-ring"},mg={width:"48",height:"48",viewBox:"0 0 48 48"},gg=["stroke","stroke-dasharray"],yg=["fill"],_g={key:1,class:"stat-card"},bg={class:"meta-row"},wg={key:0},kg={key:1},xg={key:2},$g={key:1,class:"panel panel--secondary"},Sg={class:"panel-head"},Cg={class:"panel-sub"},Tg={class:"panel-body msg-preview"},Mg=["onClick"],Eg={class:"msg-group-name"},Pg={class:"msg-group-count"},Ig={class:"msg-group-tokens"},Ag={class:"msg-group-pct"},Lg={class:"msg-group-bar"},Og={key:2,class:"panel panel--secondary"},Rg={class:"panel-head"},Dg={class:"panel-sub"},Ng={class:"panel-body file-preview"},Fg={class:"file-list"},zg=["onClick"],Bg={class:"file-path"},Hg={class:"file-dir"},jg={class:"file-ops"},Vg={key:0,class:"file-op file-op--read"},Ug={key:1,class:"file-op file-op--write"},Kg={class:"file-tokens"},Wg={class:"file-pct"},qg={class:"file-bar"},Gg=Qe({__name:"OverviewTab",setup(e){const t=At(),n=A(()=>t.selectedEntry),s=A(()=>t.selectedSession),o=A(()=>s.value?[...s.value.entries].reverse():[]),i=A(()=>{const T=n.value;return!T||!T.contextLimit?0:T.contextInfo.totalTokens/T.contextLimit}),r=A(()=>{const T=i.value;return T>=.9?"var(--accent-red)":T>=.7?"var(--accent-amber)":"var(--accent-blue)"}),l=A(()=>{const T=n.value;if(!(T!=null&&T.usage))return null;const P=T.usage.inputTokens+T.usage.cacheReadTokens+T.usage.cacheWriteTokens;return P===0?null:T.usage.cacheReadTokens/P}),c=A(()=>Yt(o.value)),p=A(()=>ic(c.value)),d=A(()=>{const T=n.value;if(!T)return 0;const P=c.value,ee=P.findIndex(ne=>ne.entry.id===T.id);return ee<0?0:P.slice(0,ee+1).reduce((ne,$)=>ne+($.isMain?1:0),0)}),m=A(()=>{const T=n.value;if(!T)return[];const P=o.value,ee=c.value;return sc(T,P,ee)}),v=A(()=>{const T=n.value;if(!T)return null;const P=c.value,ee=P.findIndex(ne=>ne.entry.id===T.id);if(ee<0)return null;for(let ne=ee-1;ne>=0;ne--)if(P[ne].isMain)return P[ne].entry;return null}),w=A(()=>{const T=n.value,P=v.value;if(!T||!P)return[];const ee=new Map(P.composition.map(L=>[L.category,L.tokens])),ne=new Map(T.composition.map(L=>[L.category,L.tokens])),$=new Set([...ee.keys(),...ne.keys()]);return Array.from($).map(L=>{const G=ee.get(L)??0,k=ne.get(L)??0;return{category:L,delta:k-G}}).filter(L=>L.delta!==0).sort((L,G)=>Math.abs(G.delta)-Math.abs(L.delta))}),I=A(()=>{var $;const T=n.value;if(!(($=T==null?void 0:T.composition)!=null&&$.length))return null;const P=T.composition.reduce((L,G)=>L+G.tokens,0);if(P===0)return null;const ee={};for(const[L,G]of Object.entries(Hn))for(const k of G)ee[k]=L;const ne=new Map;for(const L of T.composition){const G=ee[L.category]??L.category;ne.set(G,(ne.get(G)||0)+L.tokens)}return[...ne.entries()].sort((L,G)=>G[1]-L[1]).map(([L,G])=>{var k;return{key:L,color:((k=mt[L])==null?void 0:k.color)??"#475569",pct:G/P*100}})}),S=A(()=>{const T=n.value;return!T||c.value.length===0?null:oc(T,c.value)}),_=A(()=>{var T;return((T=n.value)==null?void 0:T.contextInfo.messages)||[]}),C=A(()=>nc(_.value)),z=A(()=>C.value.reduce((T,P)=>T+P.tokens,0)),K=A(()=>{var T;return((T=n.value)==null?void 0:T.contextInfo.totalTokens)??0}),V=A(()=>{const T=n.value;return T?tv({utilization:i.value,healthScore:T.healthScore,composition:T.composition,topDelta:w.value[0]??null}):null});function Q(T){t.setInspectorTab(T)}function D(){t.setInspectorTab("messages")}function ae(T,P=!0){D(),t.focusMessageCategory(T,P)}function ue(){D()}function O(T){D(),t.focusMessageTool("tool_results",T)}function R(T){T.messageIndex!=null&&(D(),t.focusMessageByIndex(T.messageIndex))}function de(T){if(!(/growth/i.test(T.id)||/growth/i.test(T.name)))return T.description;const ee=T.description||"";if(!/first turn/i.test(ee)||d.value<=1)return ee;const ne=n.value,$=v.value;if(!ne||!$||!ne.contextLimit)return ee;const L=ne.contextInfo.totalTokens-$.contextInfo.totalTokens,G=Math.abs(L),k=G/ne.contextLimit*100;return`Compared with previous main turn, context ${L>=0?"grew":"shrunk"} by ${_e(G)} (${k.toFixed(1)}% of limit).`}function F(T){return cp(T)}function te(T){return up(T)}function ce(T){return K.value>0?Math.round(T/K.value*100):0}function B(T){return K.value>0?`${T/K.value*100}%`:"0%"}const se=A(()=>{const T=s.value;if(!T||T.entries.length===0)return[];const P=T.workingDirectory;return lc(T.entries,P)}),oe=A(()=>se.value.reduce((T,P)=>T+P.tokens,0));function W(T){return oe.value>0?Math.round(T/oe.value*100):0}function re(T){return oe.value>0?`${T/oe.value*100}%`:"0%"}function we(T){D(),t.focusMessageFile(T)}function H(T){we(T)}return(T,P)=>{var ne;const ee=gn("tooltip");return n.value?(g(),b("div",Xm,[V.value?(g(),b("section",{key:0,class:he(["health-narrative",V.value.toneClass])},[u("div",Zm,[u("div",Qm,M(V.value.headline),1),u("div",eg,M(V.value.detail),1)]),u("div",tg,[u("button",{class:"narrative-action",onClick:P[0]||(P[0]=$=>Q("messages"))},[...P[4]||(P[4]=[u("i",{class:"i-carbon-chat"},null,-1),xe(" Review Messages ",-1)])]),u("button",{class:"narrative-action",onClick:P[1]||(P[1]=$=>Q("timeline"))},[...P[5]||(P[5]=[u("i",{class:"i-carbon-activity"},null,-1),xe(" View Timeline ",-1)])])])],2)):le("",!0),u("div",ng,[u("div",{class:"stat-card stat-card--spine",style:Me({"--spine-color":r.value})},[u("div",{class:"stat-readout",style:Me({color:r.value})},M(Y(ui)(i.value)),5),P[7]||(P[7]=u("div",{class:"stat-label"},"Context",-1)),u("div",sg,M(Y(_e)(n.value.contextInfo.totalTokens))+" / "+M(Y(_e)(n.value.contextLimit)),1),p.value.turnsRemaining!==null&&p.value.turnsRemaining>0?Be((g(),b("div",og,[xe(" ~"+M(p.value.turnsRemaining)+" turns left ",1)])),[[ee,`Growing ~${Y(_e)(Math.round(p.value.growthPerTurn))}/turn over ${p.value.sinceCompaction} turns`]]):p.value.turnsRemaining===0?Be((g(),b("div",ig,[...P[6]||(P[6]=[xe(" At limit ",-1)])])),[[ee,"Context window is at or near the limit"]]):le("",!0),I.value?(g(),b("div",rg,[(g(!0),b(ve,null,Te(I.value,$=>(g(),b("div",{key:$.key,class:"stat-tape-seg",style:Me({flex:$.pct,background:$.color})},null,4))),128))])):(g(),b("div",lg,[u("div",{class:"util-fill",style:Me({width:Math.min(i.value*100,100)+"%",background:r.value})},null,4)]))],4),u("div",ag,[u("div",cg,M(Y(_t)(n.value.costUsd)),1),P[8]||(P[8]=u("div",{class:"stat-label"},"Turn cost",-1)),u("div",ug,M(Y(_t)(((ne=s.value)==null?void 0:ne.entries.reduce(($,L)=>$+(L.costUsd??0),0))??0))+" session",1)]),u("div",dg,[u("div",fg,M(n.value.usage?Y(_e)(n.value.usage.outputTokens):"—"),1),P[9]||(P[9]=u("div",{class:"stat-label"},"Output",-1)),n.value.timings?(g(),b("div",pg,M(Y(ci)(n.value.timings.total_ms)),1)):le("",!0)]),n.value.healthScore?(g(),b("div",hg,[u("div",vg,[(g(),b("svg",mg,[P[10]||(P[10]=u("circle",{cx:"24",cy:"24",r:"19",fill:"none",stroke:"var(--border-dim)","stroke-width":"3","stroke-dasharray":`${89.5} 30`,"stroke-linecap":"round",transform:"rotate(135 24 24)"},null,-1)),u("circle",{cx:"24",cy:"24",r:"19",fill:"none",stroke:Y(di)(n.value.healthScore.rating),"stroke-width":"3","stroke-dasharray":`${89.5*(n.value.healthScore.overall/100)} ${119.4-89.5*(n.value.healthScore.overall/100)}`,"stroke-linecap":"round",transform:"rotate(135 24 24)",style:{transition:"stroke-dasharray 0.6s ease"}},null,8,gg),u("text",{x:"24",y:"25","text-anchor":"middle","dominant-baseline":"central",fill:Y(di)(n.value.healthScore.rating),"font-family":"var(--font-display)","font-size":"13","font-weight":"700"},M(n.value.healthScore.overall),9,yg)]))]),P[11]||(P[11]=u("div",{class:"stat-label"},"Health",-1))])):(g(),b("div",_g,[...P[12]||(P[12]=[u("div",{class:"stat-readout dim"},"—",-1),u("div",{class:"stat-label"},"Health",-1)])]))]),u("div",bg,[u("span",null,M(n.value.contextInfo.messages.length)+" messages",1),l.value!==null?(g(),b("span",wg," cache "+M(Y(ui)(l.value))+" hit ("+M(Y(_e)(n.value.usage.cacheReadTokens))+"r / "+M(Y(_e)(n.value.usage.cacheWriteTokens))+"w) ",1)):le("",!0),n.value.stopReason?(g(),b("span",kg,"stop: "+M(n.value.stopReason),1)):le("",!0),n.value.responseModel&&n.value.responseModel!==n.value.contextInfo.model?(g(),b("span",xg," model: "+M(n.value.responseModel),1)):le("",!0)]),Re(um,{entry:n.value,"turn-num":d.value,onCategoryClick:P[2]||(P[2]=$=>ae($,!1)),onToolClick:O,onFileClick:H},null,8,["entry","turn-num"]),Re(Ym,{entry:n.value,recommendations:m.value,"audit-tooltip":de,onRecommendationClick:R},null,8,["entry","recommendations"]),Re(ac,{"diff-data":S.value,"current-entry":n.value,"previous-entry":v.value,"show-tapes":!0,"hide-unchanged":!0,"summary-mode":"combined","delta-tone":"bad",onCategoryClick:P[3]||(P[3]=$=>ae($,!1))},null,8,["diff-data","current-entry","previous-entry"]),C.value.length?(g(),b("section",$g,[u("div",Sg,[P[13]||(P[13]=u("span",{class:"panel-title"},"Messages",-1)),u("span",Cg,M(_.value.length)+" messages · "+M(Y(_e)(z.value)),1)]),u("div",Tg,[(g(!0),b(ve,null,Te(C.value,$=>(g(),b("div",{key:$.category,class:"msg-group-row",onClick:L=>ae($.category,!1)},[u("span",{class:"msg-group-dot",style:Me({background:te($.category)})},null,4),u("span",Eg,M(F($.category)),1),u("span",Pg,M($.items.length),1),u("span",Ig,M(Y(_e)($.tokens)),1),u("span",Ag,M(ce($.tokens))+"%",1),u("div",Lg,[u("div",{class:"msg-group-bar-fill",style:Me({width:B($.tokens),background:te($.category)})},null,4)])],8,Mg))),128)),u("button",{class:"msg-view-all",onClick:ue},"View all messages ›")])])):le("",!0),se.value.length>0?(g(),b("section",Og,[u("div",Rg,[P[14]||(P[14]=u("span",{class:"panel-title"},"Files",-1)),u("span",Dg,M(se.value.length)+" files · "+M(Y(_e)(oe.value)),1)]),u("div",Ng,[u("div",Fg,[(g(!0),b(ve,null,Te(se.value,($,L)=>(g(),b("div",{key:$.path,class:"file-row",onClick:G=>we($.path)},[u("span",{class:"file-dot",style:Me({background:Y(hi)(L)})},null,4),Be((g(),b("span",Bg,[u("span",Hg,M(Y(Zr)($.path)?Y(Zr)($.path)+"/":""),1),xe(M(Y(Bi)($.path)),1)])),[[ee,$.path]]),u("span",jg,[$.reads>0?Be((g(),b("span",Vg,[xe(M($.reads)+"r",1)])),[[ee,`${$.reads} read${$.reads>1?"s":""}`]]):le("",!0),$.writes>0?Be((g(),b("span",Ug,[xe(M($.writes)+"w",1)])),[[ee,`${$.writes} write/edit${$.writes>1?"s":""}`]]):le("",!0)]),u("span",Kg,M(Y(_e)($.tokens)),1),u("span",Wg,M(W($.tokens))+"%",1),u("div",qg,[u("div",{class:"file-bar-fill",style:Me({width:re($.tokens),background:Y(hi)(L)})},null,4)])],8,zg))),128))])])])):le("",!0)])):le("",!0)}}}),Jg=at(Gg,[["__scopeId","data-v-ab5256cd"]]),Yg={__name:"splitpanes",props:{horizontal:{type:Boolean},pushOtherPanes:{type:Boolean,default:!0},dblClickSplitter:{type:Boolean,default:!0},rtl:{type:Boolean,default:!1},firstSplitter:{type:Boolean}},emits:["ready","resize","resized","pane-click","pane-maximize","pane-add","pane-remove","splitter-click"],setup(e,{emit:t}){const n=t,s=e,o=Tu(),i=me([]),r=A(()=>i.value.reduce(($,L)=>($[~~L.id]=L)&&$,{})),l=A(()=>i.value.length),c=me(null),p=me(!1),d=me({mouseDown:!1,dragging:!1,activeSplitter:null,cursorOffset:0}),m=me({splitter:null,timeoutId:null}),v=A(()=>({[`splitpanes splitpanes--${s.horizontal?"horizontal":"vertical"}`]:!0,"splitpanes--dragging":d.value.dragging})),w=()=>{document.addEventListener("mousemove",_,{passive:!1}),document.addEventListener("mouseup",C),"ontouchstart"in window&&(document.addEventListener("touchmove",_,{passive:!1}),document.addEventListener("touchend",C))},I=()=>{document.removeEventListener("mousemove",_,{passive:!1}),document.removeEventListener("mouseup",C),"ontouchstart"in window&&(document.removeEventListener("touchmove",_,{passive:!1}),document.removeEventListener("touchend",C))},S=($,L)=>{const G=$.target.closest(".splitpanes__splitter");if(G){const{left:k,top:y}=G.getBoundingClientRect(),{clientX:h,clientY:a}="ontouchstart"in window&&$.touches?$.touches[0]:$;d.value.cursorOffset=s.horizontal?a-y:h-k}w(),d.value.mouseDown=!0,d.value.activeSplitter=L},_=$=>{d.value.mouseDown&&($.preventDefault(),d.value.dragging=!0,requestAnimationFrame(()=>{ae(Q($)),n("resize",i.value.map(L=>({min:L.min,max:L.max,size:L.size})))}))},C=()=>{d.value.dragging&&n("resized",i.value.map($=>({min:$.min,max:$.max,size:$.size}))),d.value.mouseDown=!1,setTimeout(()=>{d.value.dragging=!1,I()},100)},z=($,L)=>{"ontouchstart"in window&&($.preventDefault(),s.dblClickSplitter&&(m.value.splitter===L?(clearTimeout(m.value.timeoutId),m.value.timeoutId=null,K($,L),m.value.splitter=null):(m.value.splitter=L,m.value.timeoutId=setTimeout(()=>m.value.splitter=null,500)))),d.value.dragging||n("splitter-click",i.value[L])},K=($,L)=>{let G=0;i.value=i.value.map((k,y)=>(k.size=y===L?k.max:k.min,y!==L&&(G+=k.min),k)),i.value[L].size-=G,n("pane-maximize",i.value[L]),n("resized",i.value.map(k=>({min:k.min,max:k.max,size:k.size})))},V=($,L)=>{n("pane-click",r.value[L])},Q=$=>{const L=c.value.getBoundingClientRect(),{clientX:G,clientY:k}="ontouchstart"in window&&$.touches?$.touches[0]:$;return{x:G-(s.horizontal?0:d.value.cursorOffset)-L.left,y:k-(s.horizontal?d.value.cursorOffset:0)-L.top}},D=$=>{$=$[s.horizontal?"y":"x"];const L=c.value[s.horizontal?"clientHeight":"clientWidth"];return s.rtl&&!s.horizontal&&($=L-$),$*100/L},ae=$=>{const L=d.value.activeSplitter;let G={prevPanesSize:O(L),nextPanesSize:R(L),prevReachedMinPanes:0,nextReachedMinPanes:0};const k=0+(s.pushOtherPanes?0:G.prevPanesSize),y=100-(s.pushOtherPanes?0:G.nextPanesSize),h=Math.max(Math.min(D($),y),k);let a=[L,L+1],f=i.value[a[0]]||null,E=i.value[a[1]]||null;const q=f.max<100&&h>=f.max+G.prevPanesSize,N=E.max<100&&h<=100-(E.max+R(L+1));if(q||N){q?(f.size=f.max,E.size=Math.max(100-f.max-G.prevPanesSize-G.nextPanesSize,0)):(f.size=Math.max(100-E.max-G.prevPanesSize-R(L+1),0),E.size=E.max);return}if(s.pushOtherPanes){const J=ue(G,h);if(!J)return;({sums:G,panesToResize:a}=J),f=i.value[a[0]]||null,E=i.value[a[1]]||null}f!==null&&(f.size=Math.min(Math.max(h-G.prevPanesSize-G.prevReachedMinPanes,f.min),f.max)),E!==null&&(E.size=Math.min(Math.max(100-h-G.nextPanesSize-G.nextReachedMinPanes,E.min),E.max))},ue=($,L)=>{const G=d.value.activeSplitter,k=[G,G+1];return L<$.prevPanesSize+i.value[k[0]].min&&(k[0]=de(G).index,$.prevReachedMinPanes=0,k[0]<G&&i.value.forEach((y,h)=>{h>k[0]&&h<=G&&(y.size=y.min,$.prevReachedMinPanes+=y.min)}),$.prevPanesSize=O(k[0]),k[0]===void 0)?($.prevReachedMinPanes=0,i.value[0].size=i.value[0].min,i.value.forEach((y,h)=>{h>0&&h<=G&&(y.size=y.min,$.prevReachedMinPanes+=y.min)}),i.value[k[1]].size=100-$.prevReachedMinPanes-i.value[0].min-$.prevPanesSize-$.nextPanesSize,null):L>100-$.nextPanesSize-i.value[k[1]].min&&(k[1]=F(G).index,$.nextReachedMinPanes=0,k[1]>G+1&&i.value.forEach((y,h)=>{h>G&&h<k[1]&&(y.size=y.min,$.nextReachedMinPanes+=y.min)}),$.nextPanesSize=R(k[1]-1),k[1]===void 0)?($.nextReachedMinPanes=0,i.value.forEach((y,h)=>{h<l.value-1&&h>=G+1&&(y.size=y.min,$.nextReachedMinPanes+=y.min)}),i.value[k[0]].size=100-$.prevPanesSize-R(k[0]-1),null):{sums:$,panesToResize:k}},O=$=>i.value.reduce((L,G,k)=>L+(k<$?G.size:0),0),R=$=>i.value.reduce((L,G,k)=>L+(k>$+1?G.size:0),0),de=$=>[...i.value].reverse().find(L=>L.index<$&&L.size>L.min)||{},F=$=>i.value.find(L=>L.index>$+1&&L.size>L.min)||{},te=()=>{var $;Array.from((($=c.value)==null?void 0:$.children)||[]).forEach(L=>{const G=L.classList.contains("splitpanes__pane"),k=L.classList.contains("splitpanes__splitter");!G&&!k&&(L.remove(),console.warn("Splitpanes: Only <pane> elements are allowed at the root of <splitpanes>. One of your DOM nodes was removed."))})},ce=($,L,G=!1)=>{const k=$-1,y=document.createElement("div");y.classList.add("splitpanes__splitter"),G||(y.onmousedown=h=>S(h,k),typeof window<"u"&&"ontouchstart"in window&&(y.ontouchstart=h=>S(h,k)),y.onclick=h=>z(h,k+1)),s.dblClickSplitter&&(y.ondblclick=h=>K(h,k+1)),L.parentNode.insertBefore(y,L)},B=$=>{$.onmousedown=void 0,$.onclick=void 0,$.ondblclick=void 0,$.remove()},se=()=>{var $;const L=Array.from((($=c.value)==null?void 0:$.children)||[]);L.forEach(k=>{k.className.includes("splitpanes__splitter")&&B(k)});let G=0;L.forEach(k=>{k.className.includes("splitpanes__pane")&&(!G&&s.firstSplitter?ce(G,k,!0):G&&ce(G,k),G++)})},oe=({uid:$,...L})=>{const G=r.value[$];Object.entries(L).forEach(([k,y])=>G[k]=y)},W=$=>{var L;let G=-1;Array.from(((L=c.value)==null?void 0:L.children)||[]).some(k=>(k.className.includes("splitpanes__pane")&&G++,k.isSameNode($.el))),i.value.splice(G,0,{...$,index:G}),i.value.forEach((k,y)=>k.index=y),p.value&&Ue(()=>{se(),we({addedPane:i.value[G]}),n("pane-add",{index:G,panes:i.value.map(k=>({min:k.min,max:k.max,size:k.size}))})})},re=$=>{const L=i.value.findIndex(k=>k.id===$),G=i.value.splice(L,1)[0];i.value.forEach((k,y)=>k.index=y),Ue(()=>{se(),we({removedPane:{...G}}),n("pane-remove",{removed:G,panes:i.value.map(k=>({min:k.min,max:k.max,size:k.size}))})})},we=($={})=>{!$.addedPane&&!$.removedPane?T():i.value.some(L=>L.givenSize!==null||L.min||L.max<100)?P($):H(),p.value&&n("resized",i.value.map(L=>({min:L.min,max:L.max,size:L.size})))},H=()=>{const $=100/l.value;let L=0;const G=[],k=[];i.value.forEach(y=>{y.size=Math.max(Math.min($,y.max),y.min),L-=y.size,y.size>=y.max&&G.push(y.id),y.size<=y.min&&k.push(y.id)}),L>.1&&ee(L,G,k)},T=()=>{let $=100;const L=[],G=[];let k=0;i.value.forEach(h=>{$-=h.size,h.givenSize!==null&&k++,h.size>=h.max&&L.push(h.id),h.size<=h.min&&G.push(h.id)});let y=100;$>.1&&(i.value.forEach(h=>{h.givenSize===null&&(h.size=Math.max(Math.min($/(l.value-k),h.max),h.min)),y-=h.size}),y>.1&&ee(y,L,G))},P=({addedPane:$,removedPane:L}={})=>{let G=100/l.value,k=0;const y=[],h=[];(($==null?void 0:$.givenSize)??null)!==null&&(G=(100-$.givenSize)/(l.value-1).value),i.value.forEach(a=>{k-=a.size,a.size>=a.max&&y.push(a.id),a.size<=a.min&&h.push(a.id)}),!(Math.abs(k)<.1)&&(i.value.forEach(a=>{($==null?void 0:$.givenSize)!==null&&($==null?void 0:$.id)===a.id||(a.size=Math.max(Math.min(G,a.max),a.min)),k-=a.size,a.size>=a.max&&y.push(a.id),a.size<=a.min&&h.push(a.id)}),k>.1&&ee(k,y,h))},ee=($,L,G)=>{let k;$>0?k=$/(l.value-L.length):k=$/(l.value-G.length),i.value.forEach((y,h)=>{if($>0&&!L.includes(y.id)){const a=Math.max(Math.min(y.size+k,y.max),y.min),f=a-y.size;$-=f,y.size=a}else if(!G.includes(y.id)){const a=Math.max(Math.min(y.size+k,y.max),y.min),f=a-y.size;$-=f,y.size=a}}),Math.abs($)>.1&&Ue(()=>{p.value&&console.warn("Splitpanes: Could not resize panes correctly due to their constraints.")})};Ke(()=>s.firstSplitter,()=>se()),Ke(()=>s.dblClickSplitter,$=>{[...c.value.querySelectorAll(".splitpanes__splitter")].forEach((L,G)=>{L.ondblclick=$?k=>K(k,G):void 0})}),fo(()=>p.value=!1),Mn(()=>{te(),se(),we(),n("ready"),p.value=!0});const ne=()=>{var $;return Oi("div",{ref:c,class:v.value},($=o.default)==null?void 0:$.call(o))};return sn("panes",i),sn("indexedPanes",r),sn("horizontal",A(()=>s.horizontal)),sn("requestUpdate",oe),sn("onPaneAdd",W),sn("onPaneRemove",re),sn("onPaneClick",V),($,L)=>(g(),dt(Yl(ne)))}},nl={__name:"pane",props:{size:{type:[Number,String]},minSize:{type:[Number,String],default:0},maxSize:{type:[Number,String],default:100}},setup(e){var t;const n=e,s=xt("requestUpdate"),o=xt("onPaneAdd"),i=xt("horizontal"),r=xt("onPaneRemove"),l=xt("onPaneClick"),c=(t=Ms())==null?void 0:t.uid,p=xt("indexedPanes"),d=A(()=>p.value[c]),m=me(null),v=A(()=>{const _=isNaN(n.size)||n.size===void 0?0:parseFloat(n.size);return Math.max(Math.min(_,I.value),w.value)}),w=A(()=>{const _=parseFloat(n.minSize);return isNaN(_)?0:_}),I=A(()=>{const _=parseFloat(n.maxSize);return isNaN(_)?100:_}),S=A(()=>{var _;return`${i.value?"height":"width"}: ${(_=d.value)==null?void 0:_.size}%`});return Mn(()=>{o({id:c,el:m.value,min:w.value,max:I.value,givenSize:n.size===void 0?null:v.value,size:v.value})}),Ke(()=>v.value,_=>s({uid:c,size:_})),Ke(()=>w.value,_=>s({uid:c,min:_})),Ke(()=>I.value,_=>s({uid:c,max:_})),fo(()=>r(c)),(_,C)=>(g(),b("div",{ref_key:"paneEl",ref:m,class:"splitpanes__pane",onClick:C[0]||(C[0]=z=>Y(l)(z,_._.uid)),style:Me(S.value)},[hs(_.$slots,"default")],4))}};function Xg(){const e=Cs(new Set);function t(r){e.has(r)?e.delete(r):e.add(r)}function n(r){return e.has(r)}function s(r){e.add(r)}function o(r){e.delete(r)}function i(){e.clear()}return{expanded:e,toggle:t,isExpanded:n,expand:s,collapse:o,collapseAll:i}}const Zg="modulepreload",Qg=function(e){return"/"+e},sl={},ey=function(t,n,s){let o=Promise.resolve();if(n&&n.length>0){let r=function(p){return Promise.all(p.map(d=>Promise.resolve(d).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),c=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));o=r(n.map(p=>{if(p=Qg(p),p in sl)return;sl[p]=!0;const d=p.endsWith(".css"),m=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${m}`))return;const v=document.createElement("link");if(v.rel=d?"stylesheet":Zg,d||(v.as="script"),v.crossOrigin="",v.href=p,c&&v.setAttribute("nonce",c),document.head.appendChild(v),d)return new Promise((w,I)=>{v.addEventListener("load",w),v.addEventListener("error",()=>I(new Error(`Unable to preload CSS for ${p}`)))})}))}function i(r){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=r,window.dispatchEvent(l),!l.defaultPrevented)throw r}return o.then(r=>{for(const l of r||[])l.status==="rejected"&&i(l.reason);return t().catch(i)})},ty={class:"detail-header"},ny={class:"header-top"},sy={class:"nav-btns"},oy=["disabled"],iy=["disabled"],ry={key:0,class:"header-meta"},ly={class:"detail-tabs"},ay={key:0,class:"block-sep"},cy=["innerHTML"],uy={class:"raw-header"},dy=["innerHTML"],fy={class:"detail-footer"},py={class:"meta-key"},hy=["title"],ol=5e4,il=500,vy=2e4,my=450,gy=Qe({__name:"DetailPane",props:{entry:{},messages:{},selectedIndex:{}},emits:["close","navigate"],setup(e,{emit:t}){const n=e,s=t,o=me("rendered"),i=me(!1),r=me(null);let l=null,c=null;const p=new Map,d=new Set,m=me(0),v=A(()=>{var k;return((k=n.messages[n.selectedIndex])==null?void 0:k.msg)??null}),w=A(()=>ko(n.entry.contextInfo.messages||[])),I=A(()=>{const k=v.value;if(!k)return"";const y=St(k);let a=(Ye[y]||{label:y}).label;if(k.contentBlocks)for(const f of k.contentBlocks){if(f.type==="tool_use"){a=`Tool Call — ${f.name||"unknown"}`;break}if(f.type==="tool_result"){const q=f.tool_use_id?w.value[f.tool_use_id]:null;a=`Tool Result${q?" — "+q:""}`;break}if(f.type==="thinking"){a="Thinking";break}}return a}),S=A(()=>{if(!v.value)return"";const k=St(v.value);return(Ye[k]||{color:"#4b5563"}).color}),_=A(()=>!v.value||!n.entry.contextInfo.totalTokens?"0":((v.value.tokens||0)/n.entry.contextInfo.totalTokens*100).toFixed(1)),C=A(()=>n.selectedIndex>0),z=A(()=>n.selectedIndex<n.messages.length-1);Ke(()=>n.selectedIndex,()=>{o.value="rendered",i.value=!1,Ue(()=>{r.value&&(r.value.scrollTop=0)}),Ue(()=>{$()})}),Ke([o,i],()=>{Ue(()=>{$()})}),Ke(v,()=>{Ue(()=>{$()})},{immediate:!0});function K(k){const y=n.selectedIndex+k;y>=0&&y<n.messages.length&&s("navigate",y)}function V(k){k.key==="Escape"&&(s("close"),k.preventDefault()),(k.key==="ArrowUp"||k.key==="k")&&(K(-1),k.preventDefault()),(k.key==="ArrowDown"||k.key==="j")&&(K(1),k.preventDefault())}const Q=me("Copy");async function D(){if(!v.value)return;const k=o.value==="raw"?JSON.stringify(Ho(v.value),null,2):dp(v.value);await navigator.clipboard.writeText(k),Q.value="Copied!",setTimeout(()=>{Q.value="Copy"},1500)}function ae(k){if(i.value)return{text:k,truncated:!1};if(k.length>ol)return{text:k.slice(0,ol),truncated:!0};const y=k.split(`
28
28
  `);return y.length>il?{text:y.slice(0,il).join(`
29
29
  `),truncated:!0}:{text:k,truncated:!1}}function ue(k){let y=2166136261;for(let h=0;h<k.length;h++)y^=k.charCodeAt(h),y=Math.imul(y,16777619);return(y>>>0).toString(36)}function O(k){return k.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function R(k,y,h){let a="",f=0;y.lastIndex=0;let E=y.exec(k);for(;E;){const q=E.index,N=E[0];a+=O(k.slice(f,q)),a+=h(N,q),f=q+N.length,E=y.exec(k)}return a+=O(k.slice(f)),a}function de(k){return R(k,/"(?:\\.|[^"\\])*"(?=\s*:)?|"(?:\\.|[^"\\])*"|\btrue\b|\bfalse\b|\bnull\b|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,(h,a)=>{if(h.startsWith('"')){const f=k.slice(a+h.length);return`<span class="${/^\s*:/.test(f)?"syn-key":"syn-str"}">${O(h)}</span>`}return h==="true"||h==="false"?`<span class="syn-bool">${h}</span>`:h==="null"?`<span class="syn-null">${h}</span>`:`<span class="syn-num">${h}</span>`})}function F(k){return R(k,/<!--[\s\S]*?-->|<\/?[\w:.-]+(?:\s+[\w:.-]+(?:\s*=\s*(?:"[^"]*"|'[^']*'))?)*\s*\/?>/g,h=>{if(h.startsWith("<!--"))return`<span class="syn-com">${O(h)}</span>`;const a=/^<(\/?)([\w:.-]+)([\s\S]*?)(\/?)>$/.exec(h);if(!a)return`<span class="syn-tag">${O(h)}</span>`;const f=a[1]?"/":"",E=a[2],q=a[3]||"",N=a[4]?"/":"";let J="";const pe=/([\w:.-]+)(\s*=\s*)(".*?"|'.*?')/g;let fe=0,ie=pe.exec(q);for(;ie;)J+=O(q.slice(fe,ie.index)),J+=`<span class="syn-attr">${O(ie[1])}</span>`,J+=O(ie[2]),J+=`<span class="syn-str">${O(ie[3])}</span>`,fe=ie.index+ie[0].length,ie=pe.exec(q);return J+=O(q.slice(fe)),`<span class="syn-punc">&lt;${f}</span><span class="syn-tag">${O(E)}</span>${J}<span class="syn-punc">${N}&gt;</span>`})}function te(k){return R(k,/```[\s\S]*?```|`[^`\n]+`|^#{1,6}\s.+$|^\s*[-*+]\s.+$|^\s*\d+\.\s.+$|^>\s.+$|\*\*[^*\n]+\*\*|__[^_\n]+__|\*[^*\n]+\*|_[^_\n]+_|~~[^~\n]+~~|\[[^\]]+\]\([^)]+\)/gm,h=>h.startsWith("```")||h.startsWith("`")?`<span class="syn-code">${O(h)}</span>`:h.startsWith("#")?`<span class="syn-heading">${O(h)}</span>`:/^\s*[-*+]\s/.test(h)||/^\s*\d+\.\s/.test(h)?`<span class="syn-list">${O(h)}</span>`:h.startsWith(">")?`<span class="syn-quote">${O(h)}</span>`:h.startsWith("[")?`<span class="syn-link">${O(h)}</span>`:`<span class="syn-em">${O(h)}</span>`)}function ce(k){return R(k,/\/\/.*$|\/\*[\s\S]*?\*\/|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`|\b(?:const|let|var|function|return|if|else|for|while|switch|case|break|continue|try|catch|finally|class|extends|new|import|from|export|async|await|interface|type|public|private|protected|throw|in|of|typeof|instanceof|true|false|null|undefined)\b|-?\d+(?:\.\d+)?/gm,h=>h.startsWith("//")||h.startsWith("/*")?`<span class="syn-com">${O(h)}</span>`:h.startsWith('"')||h.startsWith("'")||h.startsWith("`")?`<span class="syn-str">${O(h)}</span>`:/^-?\d/.test(h)?`<span class="syn-num">${h}</span>`:h==="true"||h==="false"?`<span class="syn-bool">${h}</span>`:h==="null"||h==="undefined"?`<span class="syn-null">${h}</span>`:`<span class="syn-keyword">${h}</span>`)}function B(k){const y=k.trim();if(!(y.startsWith("{")||y.startsWith("[")))return!1;try{return JSON.parse(y),!0}catch{return!1}}function se(k){const y=k.trim();return y.startsWith("<")?/<[\w:.-]+[\s>]/.test(y)&&/<\/[\w:.-]+>/.test(y):!1}function oe(k){return/(^#{1,6}\s)|(^\s*[-*+]\s)|(^\s*\d+\.\s)|(```)|(`[^`\n]+`)|(\[[^\]]+\]\([^)]+\))|(^>\s)|(\*\*[^*\n]+\*\*)/m.test(k)}function W(k){return/[{}();]|(^\s*(const|let|var|function|if|for|while|class|import|export)\s)/m.test(k)}function re(k,y=!1){return y||B(k)?"json":se(k)?"xml":oe(k)?"markdown":W(k)?"code":"text"}function we(k,y=!1){const h=re(k,y);return h==="json"?de(k):h==="xml"?F(k):h==="markdown"?te(k):h==="code"?ce(k):O(k)}function H(k){return k==="json"?"json":k==="xml"?"xml":k==="markdown"?"markdown":k==="code"?"typescript":null}function T(k,y){return!(y==="text"||k.length>vy||k.split(`
30
- `).length>my)}async function P(){if(!l){if(c)return c;c=(async()=>{l=await(await ey(()=>import("./index-TAgDqd5r.js"),[])).createHighlighter({themes:["github-dark"],langs:["json","xml","markdown","typescript"]})})(),await c}}async function ee(k,y,h){if(!T(k,y)||p.has(h)||d.has(h))return;const a=H(y);if(a){d.add(h);try{if(await P(),!l)return;const f=l.codeToHtml(k,{lang:a,theme:"github-dark"});p.set(h,f),m.value+=1}catch{}finally{d.delete(h)}}}function ne(k,y=!1){m.value;const h=re(k,y),a=`${h}:${ue(k)}`;if(T(k,h)){const f=p.get(a);if(f)return f;ee(k,h,a)}return we(k,y)}function $(){const k=v.value;if(!k)return;if(o.value==="raw"){const h=JSON.stringify(Ho(k),null,2),a=ae(h).text,f=re(a,!0);ee(a,f,`${f}:${ue(a)}`);return}const y=L();for(const h of y){const a=ae(h.content).text,f=re(a,h.isJson);ee(a,f,`${f}:${ue(a)}`)}}function L(){const k=v.value;if(!k)return[];const y=k.contentBlocks;return y&&y.length>0?y.map(h=>{if(h.type==="tool_use"){const f=h.input?JSON.stringify(h.input,null,2):"{}";return{type:"tool_use",label:`tool_use: ${h.name||"?"}`,labelClass:"lbl-tool-use",content:f,isJson:!0}}if(h.type==="tool_result"){const f=h.tool_use_id?w.value[h.tool_use_id]:null,E=typeof h.content=="string"?h.content:JSON.stringify(h.content,null,2);return{type:"tool_result",label:`tool_result${f?": "+f:""}`,labelClass:"lbl-tool-result",content:E,isJson:!1}}const a=h;return a.type==="thinking"?{type:"thinking",label:"thinking",labelClass:"lbl-thinking",content:a.thinking||a.text||"",isJson:!1}:h.type==="text"||h.type==="input_text"?{type:h.type,label:h.type,labelClass:"lbl-text",content:h.text||"",isJson:!1}:h.type==="image"?{type:"image",label:"image",labelClass:"lbl-image",content:"[Image content]",isJson:!1}:{type:"unknown",label:"block",labelClass:"lbl-text",content:`[Unknown block type: ${h.type||"unspecified"}]`,isJson:!1}}):[{type:"text",label:"",labelClass:"",content:k.content||"",isJson:!1}]}const G=A(()=>{const k=v.value;if(!k)return[];const y=[["Role",k.role],["Tokens",_e(k.tokens||0)],["% context",_.value+"%"],["Model",n.entry.contextInfo.model||"?"]];if(k.contentBlocks){for(const h of k.contentBlocks)if(h.type==="tool_use"&&(y.push(["tool_use_id",h.id||"?"]),y.push(["tool_name",h.name||"?"])),h.type==="tool_result"&&h.tool_use_id){y.push(["tool_use_id",h.tool_use_id]);const a=w.value[h.tool_use_id];a&&y.push(["tool_name",a])}}return y.push(["Position",`${n.selectedIndex+1} / ${n.messages.length}`]),y});return(k,y)=>{const h=gn("tooltip");return g(),b("div",{class:"detail",tabindex:"0",onKeydown:V},[u("div",ty,[u("div",ny,[u("span",{class:"detail-title",style:Me({color:S.value})},M(I.value),5),u("div",sy,[Be((g(),b("button",{disabled:!C.value,onClick:y[0]||(y[0]=a=>K(-1))},[...y[6]||(y[6]=[u("i",{class:"i-carbon-chevron-up"},null,-1)])],8,oy)),[[h,"↑ Previous"]]),Be((g(),b("button",{disabled:!z.value,onClick:y[1]||(y[1]=a=>K(1))},[...y[7]||(y[7]=[u("i",{class:"i-carbon-chevron-down"},null,-1)])],8,iy)),[[h,"↓ Next"]])]),Be((g(),b("button",{class:"close-btn",onClick:y[2]||(y[2]=a=>k.$emit("close"))},[...y[8]||(y[8]=[u("i",{class:"i-carbon-close"},null,-1)])])),[[h,"Close (Esc)"]])]),v.value?(g(),b("div",ry,[u("span",null,[u("b",null,M(v.value.role),1)]),u("span",null,M(Y(_e)(v.value.tokens||0))+" tok",1),u("span",null,M(_.value)+"%",1),u("span",null,M(e.selectedIndex+1)+"/"+M(e.messages.length),1)])):le("",!0)]),u("div",ly,[u("button",{class:he({on:o.value==="rendered"}),onClick:y[3]||(y[3]=a=>o.value="rendered")},"Rendered",2),u("button",{class:he({on:o.value==="raw"}),onClick:y[4]||(y[4]=a=>o.value="raw")},"Raw",2)]),u("div",{ref_key:"contentEl",ref:r,class:"detail-body"},[o.value==="rendered"&&v.value?(g(!0),b(ve,{key:0},Te(L(),(a,f)=>(g(),b(ve,{key:f},[f>0?(g(),b("hr",ay)):le("",!0),a.label?(g(),b("div",{key:1,class:he(["block-label",a.labelClass])},M(a.label),3)):le("",!0),u("div",{class:he(["block-content syntax rich-html",`kind-${re(ae(a.content).text,a.isJson)}`]),innerHTML:ne(ae(a.content).text,a.isJson)},null,10,cy),ae(a.content).truncated?(g(),b("button",{key:2,class:"show-more",onClick:y[5]||(y[5]=E=>i.value=!0)}," Show full content… ")):le("",!0)],64))),128)):o.value==="raw"&&v.value?(g(),b(ve,{key:1},[u("div",uy,[u("button",{class:he(["copy-btn",{copied:Q.value==="Copied!"}]),onClick:D},[y[9]||(y[9]=u("i",{class:"i-carbon-copy"},null,-1)),xe(" "+M(Q.value),1)],2)]),u("div",{class:"block-content syntax rich-html kind-json",innerHTML:ne(JSON.stringify(Y(Ho)(v.value),null,2),!0)},null,8,dy)],64)):le("",!0)],512),u("div",fy,[y[10]||(y[10]=u("div",{class:"meta-header"},"Metadata",-1)),(g(!0),b(ve,null,Te(G.value,([a,f])=>(g(),b(ve,{key:a},[u("span",py,M(a),1),u("span",{class:"meta-val",title:f},M(f),9,hy)],64))),128))])],32)}}}),yy=at(gy,[["__scopeId","data-v-b5106f07"]]),_y={class:"msg-toolbar"},by={class:"message-view-toggle"},wy={key:0,class:"message-view-toggle agent-toggle"},ky={key:0,class:"heavy-strip"},xy={class:"heavy-actions"},$y=["onClick"],Sy={class:"heavy-category"},Cy={class:"heavy-preview"},Ty={class:"heavy-tokens"},My={key:1,class:"focus-strip"},Ey={key:0},Py={key:1},Iy=["data-category"],Ay=["onClick"],Ly={class:"group-name"},Oy={class:"group-stats"},Ry={class:"group-bar-track"},Dy=["data-tool-name","onClick"],Ny={class:"msg-role"},Fy={class:"msg-preview"},zy={key:0,class:"focus-strip"},By={class:"focus-file-name"},Hy={class:"focus-file-count"},jy={class:"chrono-list"},Vy=["onClick"],Uy={class:"chrono-gutter subagent-gutter"},Ky={class:"chrono-preview subagent-preview"},Wy={class:"chrono-tok subagent-model"},qy={class:"chrono-turn-label"},Gy={key:2,class:"chrono-future-sep"},Jy=["onClick"],Yy={class:"chrono-gutter"},Xy={class:"chrono-type"},Zy={class:"chrono-preview"},Qy=Qe({__name:"MessagesTab",setup(e){const t=At(),n=A(()=>t.selectedEntry),s=A(()=>t.selectedSession),{isExpanded:o,toggle:i,expand:r}=Xg(),l=me(null),c=me("chrono"),p=me(!1),d=me(0),m=me(null),v=me(1),w=me(null),I=me([]),S=me(0),_=A(()=>ko(z.value)),C=A(()=>{const U=s.value;return!U||U.entries.length<=1?!1:Yt([...U.entries].reverse()).some(ye=>!ye.isMain)}),z=A(()=>{var j;if(!n.value)return[];t.entryDetailVersion;const U=t.getEntryDetail(n.value.id);return(j=U==null?void 0:U.messages)!=null&&j.length?U.messages:n.value.contextInfo.messages||[]}),K=A(()=>!s.value||s.value.entries.length===0?null:s.value.entries[0]),V=A(()=>{var j;if(!K.value)return[];t.entryDetailVersion;const U=t.getEntryDetail(K.value.id);return(j=U==null?void 0:U.messages)!=null&&j.length?U.messages:K.value.contextInfo.messages||[]}),Q=A(()=>z.value.length),D=A(()=>t.selectionMode!=="pinned"?!1:V.value.length>Q.value),ae=A(()=>{if(!D.value)return z.value.map((j,ye)=>({msg:j,origIdx:ye,future:!1}));const U=[];for(let j=0;j<z.value.length;j++)U.push({msg:z.value[j],origIdx:j,future:!1});for(let j=z.value.length;j<V.value.length;j++)U.push({msg:V.value[j],origIdx:j,future:!0});return U}),ue=A(()=>{const U=ae.value,j=new Set;U.length>0&&j.add(0);let ye=!1;for(let x=0;x<U.length;x++){const X=U[x].msg.role;X==="assistant"?ye=!0:X==="user"&&ye&&(j.add(x),ye=!1)}return j}),O=A(()=>{const U=s.value,j=n.value;if(!U||!j||t.messagesMode!=="all")return new Map;const ye=Yt([...U.entries].reverse()),x=[],X=[];let be=[];for(const De of ye)De.isMain?(x.push(De.entry),x.length>1&&X.push([...be]),be=[]):x.length>0&&be.push(De.entry);X.push([...be]);const Se=x.findIndex(De=>De.id===j.id);if(Se<0)return new Map;const tt=Array.from(ue.value).sort((De,Ge)=>De-Ge),Ht=F.value,Vn=new Map;for(let De=0;De<=Se&&De<X.length;De++){const Ge=X[De];if(Ge.length===0)continue;const Xe=De+1-Ht;Xe<0||Xe<tt.length&&Vn.set(tt[Xe],Ge)}return Vn}),R=A(()=>{const U=s.value,j=n.value;if(!U||!j)return 1;const ye=Yt([...U.entries].reverse());let x=0;for(const X of ye)if(X.isMain&&x++,X.entry.id===j.id)return x;return 1}),de=A(()=>{const U=Q.value;let j=0;for(const ye of ue.value)ye<U&&j++;return j}),F=A(()=>Math.max(0,R.value-de.value)),te=A(()=>{const U=new Map;let j=F.value;for(const ye of ue.value)j++,U.set(ye,j);return U}),ce=A(()=>nc(z.value)),B=A(()=>{if(c.value==="chrono")return we.value;const U=[];for(const j of ce.value)for(const ye of j.items)U.push(ye);return U}),se=A(()=>w.value!==null),oe=A(()=>se.value?w.value:n.value),W=A(()=>se.value?I.value:B.value),re=A(()=>se.value?S.value:d.value),we=A(()=>z.value.map((U,j)=>({msg:U,origIdx:j}))),H=A(()=>{const U=[];let j=0;for(const ye of ae.value)ye.future||(j+=ye.msg.tokens||0),U.push(j);return U}),T=A(()=>{var U;return((U=n.value)==null?void 0:U.contextInfo.totalTokens)??0}),P=A(()=>{const U=[];for(const j of ce.value)for(const ye of j.items)U.push({origIdx:ye.origIdx,category:j.category,preview:Bo(ye.msg,_.value)||"(empty)",tokens:ye.msg.tokens||0});return U.filter(j=>j.tokens>0).sort((j,ye)=>ye.tokens-j.tokens).slice(0,3)}),ee=A(()=>t.messageFocusTool),ne=A(()=>t.messageFocusCategory),$=A(()=>t.messageFocusFile),L=A(()=>{var x;const U=t.messageFocusCategory;if(!U)return null;const j=new Set(ce.value.map(X=>X.category));if(j.has(U))return U;const ye={assistant_text:["tool_calls","thinking","assistant_text","user_text"],tool_definitions:["tool_calls","tool_results","system_injections"],system_prompt:["system_injections","assistant_text","user_text"],images:["user_text","assistant_text","tool_results"],cache_markers:["tool_results","assistant_text","user_text"],other:["assistant_text","user_text","tool_results"]};for(const X of ye[U]||[])if(j.has(X))return X;return((x=ce.value[0])==null?void 0:x.category)??null}),G=A(()=>!!ne.value&&!!L.value&&ne.value!==L.value);function k(){w.value=null,I.value=[]}function y(U){k(),d.value=U,E(U),p.value=!0}function h(){p.value=!1,k()}function a(U){U.key==="Escape"&&p.value&&(h(),U.preventDefault(),U.stopPropagation())}function f(U){var X;const j=(U.contentBlocks||[])[0];if(!j)return`${U.role}|${U.tokens||0}|${((X=U.content)==null?void 0:X.slice(0,160))||""}`;if(j.type==="tool_result"){const be=typeof j.content=="string"?j.content:JSON.stringify(j.content||"");return`${U.role}|${U.tokens||0}|tool_result|${j.tool_use_id||""}|${be.slice(0,160)}`}if(j.type==="tool_use")return`${U.role}|${U.tokens||0}|tool_use|${j.id||""}|${j.name||""}|${JSON.stringify(j.input||{}).slice(0,120)}`;const ye=j,x=String(ye.text||ye.thinking||"").slice(0,160);return`${U.role}|${U.tokens||0}|${String(ye.type||"other")}|${x}`}function E(U){const j=B.value[U];if(!j)return;const ye=f(j.msg);m.value=ye;let x=0;for(let X=0;X<=U;X++)f(B.value[X].msg)===ye&&(x+=1);v.value=Math.max(1,x)}function q(){const U=m.value;if(!U)return-1;let j=0;for(let ye=0;ye<B.value.length;ye++)if(f(B.value[ye].msg)===U&&(j+=1,j===v.value))return ye;return-1}function N(U){se.value?S.value=U:(d.value=U,E(U))}function J(U,j){let ye=0;for(let x=0;x<ce.value.length;x++){if(x===U)return ye+j;ye+=ce.value[x].items.length}return 0}function pe(U){const j=B.value.findIndex(ye=>ye.origIdx===U);if(j>=0){if(c.value==="category"){const ye=z.value[U];if(ye){const x=St(ye);r(x)}}y(j)}}function fe(U){const j=St(U);return(Ye[j]||{color:"#4b5563"}).color}function ie(U){const j=St(U);return(Ye[j]||{label:j}).label}function Z(U){var x;if(!s.value)return;const j=s.value.entries;let ye=null;for(let X=j.length-1;X>=0;X--)if((((x=j[X].contextInfo.messages)==null?void 0:x.length)??0)>U){ye=j[X];break}ye||(ye=j[0]),t.pinEntry(ye.id)}async function ke(U){var be;const j=s.value;if(!j)return;const ye=j.entries.find(Se=>Se.id===U);if(!ye)return;await t.loadEntryDetail(U),t.entryDetailVersion;const x=t.getEntryDetail(U),X=(be=x==null?void 0:x.messages)!=null&&be.length?x.messages:ye.contextInfo.messages||[];w.value=ye,I.value=X.map((Se,tt)=>({msg:Se,origIdx:tt})),S.value=0,p.value=!0}function ge(U){if(St(U)!=="tool_results")return null;for(const j of U.contentBlocks||[])if(j.type==="tool_result")return j.tool_use_id&&_.value[j.tool_use_id]||null;return null}function $e(U){const j=ee.value;if(!j)return{};const ye=ge(U);if(!ye)return{"tool-muted":!0};const x=ye.trim().toLowerCase(),X=j.trim().toLowerCase();return{"tool-focused":x===X,"tool-muted":x!==X}}async function Ce(){const U=L.value,j=t.messageFocusIndex,ye=t.messageFocusOpenDetail,x=t.messageFocusTool,X=t.messageFocusFile;t.clearMessageFocus();const be=j;if(be!=null){if(c.value==="chrono"){for(let De=0;De<4;De++){await Ue(),pe(be),await Ue();const Ge=l.value;if(Ge){const He=Array.from(Ge.querySelectorAll(".chrono-row")).find(st=>st.classList.contains("selected"));if(He){He.scrollIntoView({block:"center",behavior:"smooth"});return}}}return}for(let De=0;De<4;De++){await Ue();for(const Ge of ce.value)if(Ge.items.find(He=>He.origIdx===be)){r(Ge.category),await Ue(),await Ue(),pe(be),await Ue();const He=l.value;if(He){const vt=Array.from(He.querySelectorAll(".msg-row")).find(xo=>xo.classList.contains("selected"));vt&&vt.scrollIntoView({block:"center",behavior:"smooth"})}return}}return}if(X){t.messageFocusFile=X,c.value="chrono",await Ue();const De=z.value,Ge=new Set;for(const He of De)if(He.contentBlocks){for(const st of He.contentBlocks)if(st.type==="tool_use"){const vt=st;Je(vt)===X&&Ge.add(vt.id)}}let Xe=-1;for(let He=0;He<De.length;He++){const st=De[He];if(st.contentBlocks){for(const vt of st.contentBlocks){if(vt.type==="tool_result"&&Ge.has(vt.tool_use_id)){Xe=He;break}if(vt.type==="tool_use"&&Je(vt)===X&&Xe<0){Xe=He;break}}if(Xe>=0)break}}if(Xe>=0)for(let He=0;He<4;He++){await Ue();const st=l.value;if(!st)continue;const vt=Array.from(st.querySelectorAll(".chrono-row"));if(vt[Xe]){vt[Xe].scrollIntoView({block:"center",behavior:"smooth"});return}}return}const Se=U;if(!Se)return;const tt=ye;if(tt?c.value="chrono":c.value="category",c.value==="chrono"){for(let De=0;De<4;De++){await Ue();const Ge=l.value;if(!Ge)continue;const Xe=Array.from(Ge.querySelectorAll(".chrono-row"));let He=-1;for(let st=z.value.length-1;st>=0;st--)if(St(z.value[st])===Se){He=st;break}if(He>=0&&Xe[He]){Xe[He].scrollIntoView({block:"center",behavior:"smooth"}),tt&&(await Ue(),pe(He));return}}return}let Ht=null;for(let De=0;De<4;De++){if(await Ue(),Ht=l.value,!Ht)continue;r(Se),await Ue();const Ge=Ht.querySelector(`[data-category="${Se}"]`);if(Ge){Ge.scrollIntoView({block:"center",behavior:"smooth"});break}}if(!Ht)return;const Vn=x;if(Vn){const De=Array.from(Ht.querySelectorAll(".msg-row")),Ge=Vn.trim().toLowerCase(),Xe=De.find(He=>(He.getAttribute("data-tool-name")||"").trim().toLowerCase()===Ge);Xe&&Xe.scrollIntoView({block:"center",behavior:"smooth"})}}function Ie(){t.focusMessageCategory(L.value||t.messageFocusCategory||"tool_results")}function Ne(){t.clearMessageFocus()}const Ae=A(()=>{const U=$.value;if(!U)return new Set;const j=z.value,ye=new Set,x=new Set;for(let X=0;X<j.length;X++){const be=j[X];if(be.contentBlocks){for(const Se of be.contentBlocks)if(Se.type==="tool_use"){const tt=Se;Je(tt)===U&&(x.add(tt.id),ye.add(X))}}}for(let X=0;X<j.length;X++){const be=j[X];if(be.contentBlocks)for(const Se of be.contentBlocks)Se.type==="tool_result"&&x.has(Se.tool_use_id)&&ye.add(X)}return ye});function Je(U){var x;const j=U.input,ye=(x=t.selectedSession)==null?void 0:x.workingDirectory;if(j&&typeof j=="object")for(const X of["file_path","path","filePath"]){const be=j[X];if(typeof be=="string"&&be.length>0){let Se=be.replace(/\/+/g,"/");return Se.startsWith("./")&&(Se=Se.slice(2)),Se.length>1&&Se.endsWith("/")&&(Se=Se.slice(0,-1)),rc(Se,ye)}}return null}function et(U){if(!$.value)return{};const ye=Ae.value;return{"file-focused":ye.has(U),"file-muted":!ye.has(U)}}const pt=A(()=>{const U=$.value;return U?Bi(U):""});return Ke(()=>t.messageFocusToken,async()=>{await Ce()},{immediate:!0}),Ke(()=>t.inspectorTab,async U=>{U==="messages"&&await Ce()}),Ke(()=>{var U;return(U=n.value)==null?void 0:U.id},async U=>{U!=null&&await t.loadEntryDetail(U)},{immediate:!0}),Ke(()=>{var U;return(U=K.value)==null?void 0:U.id},async U=>{var j;U!=null&&U!==((j=n.value)==null?void 0:j.id)&&await t.loadEntryDetail(U)},{immediate:!0}),Mn(async()=>{t.inspectorTab==="messages"&&t.messageFocusCategory&&await Ce()}),Ke(B,()=>{if(!p.value||se.value)return;const U=q();if(U>=0&&U!==d.value){d.value=U;return}d.value>=B.value.length&&(d.value=Math.max(0,B.value.length-1),E(d.value))}),(U,j)=>{const ye=gn("tooltip");return n.value?(g(),b("div",{key:0,class:"messages-tab",onKeydown:a},[Re(Y(Yg),{class:"default-theme","push-other-panes":!1},{default:ft(()=>[Re(Y(nl),{"min-size":25,size:p.value?42:100},{default:ft(()=>[u("div",{ref_key:"msgListEl",ref:l,class:"msg-list"},[u("div",_y,[u("div",by,[u("button",{class:he({on:c.value==="chrono"}),onClick:j[0]||(j[0]=x=>c.value="chrono")},"Chronological",2),u("button",{class:he({on:c.value==="category"}),onClick:j[1]||(j[1]=x=>c.value="category")},"By Category",2)]),C.value&&c.value==="chrono"?(g(),b("div",wy,[u("button",{class:he({on:Y(t).messagesMode==="main"}),onClick:j[2]||(j[2]=x=>Y(t).messagesMode="main")},"Main",2),u("button",{class:he({on:Y(t).messagesMode==="all"}),onClick:j[3]||(j[3]=x=>Y(t).messagesMode="all")},"All",2)])):le("",!0)]),c.value==="category"?(g(),b(ve,{key:0},[P.value.length>0?(g(),b("div",ky,[j[4]||(j[4]=u("div",{class:"heavy-title"},"Top heavy messages",-1)),u("div",xy,[(g(!0),b(ve,null,Te(P.value,x=>(g(),b("button",{key:x.origIdx,class:"heavy-action",onClick:X=>pe(x.origIdx)},[u("span",Sy,M((Y(Ye)[x.category]||{label:x.category}).label),1),u("span",Cy,M(x.preview),1),u("span",Ty,M(Y(_e)(x.tokens)),1)],8,$y))),128))])])):le("",!0),ee.value||G.value?(g(),b("div",My,[ee.value?(g(),b("span",Ey,[j[5]||(j[5]=xe(" Filtered tool: ",-1)),u("b",null,M(ee.value),1)])):le("",!0),G.value?(g(),b("span",Py,[j[6]||(j[6]=xe(" Showing ",-1)),u("b",null,M((Y(Ye)[L.value||""]||{label:L.value}).label),1),j[7]||(j[7]=xe(" for ",-1)),u("b",null,M((Y(Ye)[ne.value||""]||{label:ne.value}).label),1),j[8]||(j[8]=xe(". ",-1))])):le("",!0),ee.value?(g(),b("button",{key:2,class:"focus-clear",onClick:dn(Ie,["stop"])},"Show all")):le("",!0)])):le("",!0),(g(!0),b(ve,null,Te(ce.value,(x,X)=>(g(),b("div",{key:x.category,class:"msg-group","data-category":x.category},[u("div",{class:"group-head",onClick:be=>Y(i)(x.category)},[u("i",{class:he(["group-arrow",Y(o)(x.category)||L.value===x.category?"i-carbon-chevron-down":"i-carbon-chevron-right"])},null,2),u("span",{class:"group-dot",style:Me({background:(Y(Ye)[x.category]||{color:"#4b5563"}).color})},null,4),u("span",Ly,M((Y(Ye)[x.category]||{label:x.category}).label),1),u("span",Oy,[xe(M(x.items.length)+" ",1),j[9]||(j[9]=u("span",{class:"group-sep"},"·",-1)),xe(" "+M(Y(_e)(x.tokens))+" ",1),j[10]||(j[10]=u("span",{class:"group-sep"},"·",-1)),xe(" "+M(T.value>0?Math.round(x.tokens/T.value*100):0)+"% ",1)]),u("div",Ry,[u("div",{class:"group-bar-fill",style:Me({width:(T.value>0?Math.round(x.tokens/T.value*100):0)+"%",background:(Y(Ye)[x.category]||{color:"#4b5563"}).color})},null,4)])],8,Ay),u("div",{class:he(["group-items",{open:Y(o)(x.category)||L.value===x.category}])},[(g(!0),b(ve,null,Te(x.items,(be,Se)=>{var tt;return g(),b("div",{key:be.origIdx,class:he(["msg-row",[$e(be.msg),{selected:p.value&&!se.value&&((tt=B.value[d.value])==null?void 0:tt.origIdx)===be.origIdx}]]),"data-tool-name":ge(be.msg)||"",onClick:Ht=>y(J(X,Se))},[u("span",Ny,M(be.msg.role==="user"?"›":be.msg.role==="assistant"?"‹":"·"),1),u("span",Fy,M(Y(Bo)(be.msg,_.value)||"(empty)"),1),u("span",{class:he(["msg-tok",{hot:(be.msg.tokens||0)>2e3}])},M(Y(_e)(be.msg.tokens||0)),3)],10,Dy)}),128))],2)],8,Iy))),128))],64)):c.value==="chrono"?(g(),b(ve,{key:1},[$.value?(g(),b("div",zy,[u("span",null,[j[11]||(j[11]=xe(" Filtered file: ",-1)),Be((g(),b("b",By,[xe(M(pt.value),1)])),[[ye,$.value]]),u("span",Hy,"("+M(Ae.value.size)+" messages)",1)]),u("button",{class:"focus-clear",onClick:dn(Ne,["stop"])},"Show all")])):le("",!0),u("div",jy,[(g(!0),b(ve,null,Te(ae.value,(x,X)=>{var be;return g(),b(ve,{key:X},[O.value.has(X)?(g(!0),b(ve,{key:0},Te(O.value.get(X),Se=>Be((g(),b("div",{key:"sub-"+Se.id,class:"chrono-subagent-row",onClick:tt=>ke(Se.id)},[u("span",Uy,M(Y(_e)(Se.contextInfo.totalTokens)),1),j[12]||(j[12]=u("span",{class:"chrono-cat-dot subagent-dot"},null,-1)),j[13]||(j[13]=u("span",{class:"chrono-type subagent-type"},"subagent",-1)),u("span",Ky,M(Se.agentLabel),1),u("span",Wy,M(Y(en)(Se.contextInfo.model)),1)],8,Vy)),[[ye,"Click to view subagent context"]])),128)):le("",!0),te.value.has(X)?(g(),b("div",{key:1,class:he(["chrono-turn-marker",{future:x.future}])},[u("span",qy,"Turn "+M(te.value.get(X)),1),j[14]||(j[14]=u("span",{class:"chrono-turn-line"},null,-1))],2)):le("",!0),x.future&&X===Q.value?(g(),b("div",Gy,[...j[15]||(j[15]=[u("span",{class:"chrono-future-line"},null,-1),u("span",{class:"chrono-future-label"},"After this turn",-1),u("span",{class:"chrono-future-line"},null,-1)])])):le("",!0),u("div",{class:he(["chrono-row",[et(x.origIdx),{selected:!x.future&&p.value&&!se.value&&((be=B.value[d.value])==null?void 0:be.origIdx)===x.origIdx,future:x.future}]]),style:Me({"--cat-border":fe(x.msg)}),onClick:Se=>x.future?Z(x.origIdx):y(x.origIdx)},[Be((g(),b("span",Yy,[xe(M(x.future?"":Y(_e)(H.value[X])),1)])),[[ye,x.future?"Click to jump to this turn":`Cumulative: ${Y(_e)(H.value[X])} of ${Y(_e)(T.value)}`]]),u("span",{class:"chrono-cat-dot",style:Me({background:fe(x.msg)})},null,4),u("span",Xy,M(ie(x.msg)),1),u("span",Zy,M(Y(Bo)(x.msg,_.value)||"(empty)"),1),u("span",{class:he(["chrono-tok",{hot:!x.future&&(x.msg.tokens||0)>2e3}])},M(Y(_e)(x.msg.tokens||0)),3)],14,Jy)],64)}),128))])],64)):le("",!0)],512)]),_:1},8,["size"]),p.value?(g(),dt(Y(nl),{key:0,"min-size":25,size:58},{default:ft(()=>[Re(yy,{entry:oe.value,messages:W.value,"selected-index":re.value,onClose:h,onNavigate:N},null,8,["entry","messages","selected-index"])]),_:1})):le("",!0)]),_:1})],32)):le("",!0)}}}),e0=at(Qy,[["__scopeId","data-v-c0d2a74a"]]),t0={key:0,class:"timeline-tab"},n0={class:"timeline-scope-controls"},s0={class:"scope-toggle"},o0=["onClick"],i0={class:"panel panel--hero"},r0={class:"panel-head"},l0={class:"panel-controls"},a0={class:"mode-toggle"},c0={class:"panel-body"},u0={class:"chart-container"},d0={class:"y-axis"},f0=["onClick"],p0=["viewBox"],h0=["points"],v0=["aria-label"],m0={class:"chart-legend"},g0=["onClick"],y0={key:0,class:"projection-badge"},_0={key:1,class:"projection-badge projection-badge--warn"},b0={class:"panel panel--secondary panel--spine panel--cost"},w0={class:"panel-head"},k0={class:"panel-sub"},x0={class:"panel-body"},$0={class:"chart-container"},S0={class:"y-axis"},C0=["onClick"],T0={class:"chart-legend"},M0=Qe({__name:"TimelineTab",setup(e){const t=At(),n=A({get:()=>t.timelineMode,set:y=>{t.timelineMode=y}}),s=A({get:()=>t.timelineStackMode,set:y=>{t.timelineStackMode=y}}),o=A({get:()=>t.timelineHiddenLegendKeys,set:y=>{t.timelineHiddenLegendKeys=y}}),i=A({get:()=>t.timelineShowLimitOverlay,set:y=>{t.timelineShowLimitOverlay=y}}),r=A({get:()=>t.timelineShowCacheOverlay,set:y=>{t.timelineShowCacheOverlay=y}}),l=me(null),c=me(null),p=A(()=>t.selectedSession),d=A(()=>t.selectedEntry),m=A(()=>p.value?Yt([...p.value.entries].reverse()):[]),v=A(()=>n.value==="main"?m.value.filter(y=>y.isMain):m.value),w=A(()=>{let y=0;for(const h of v.value){const a=h.entry.contextInfo.totalTokens;a>y&&(y=a)}return y}),I=A(()=>{let y=0;for(const h of v.value){const a=h.entry.costUsd??0;a>y&&(y=a)}return y}),S=A(()=>v.value.length<=40),_=A(()=>Uo(Q.value)),C=A(()=>Zh(v.value)),z=A(()=>Gh(v.value,m.value)),K=A(()=>v.value.map((y,h)=>{const a=z.value.get(y.entry.id)||[],f=a[0]||null,E=C.value[h]||h+1;return{entryId:y.entry.id,firstEvent:f,title:f?Yh(a,E):""}}));function V(y){const h=new Set(o.value);h.has(y)?h.delete(y):h.add(y),o.value=h}const Q=A(()=>{if(o.value.size===0)return w.value;let y=0;for(const h of v.value){const a=jo(h.entry,o.value);a>y&&(y=a)}return y});function D(y){const h=jo(y.entry,o.value);return Vo(h,Q.value)}function ae(y){return Kh(y.entry,o.value)}function ue(y){return Vo(y.entry.costUsd??0,I.value)}function O(y){t.pinEntry(y.id)}function R(y){t.setInspectorTab("messages"),t.focusMessageCategory(y)}const de=A(()=>Xh(v.value.length)),F=A(()=>{const y=d.value;if(y&&y.contextLimit>0)return y.contextLimit;const h=v.value;return h.length>0?h[h.length-1].entry.contextLimit:0}),te=A(()=>{const y=Q.value;return i.value?Math.max(y,F.value):y}),ce=A(()=>{const y=te.value,h=F.value;return y===0||h===0?-1:(1-h/y)*100});function B(y){if(s.value==="normalized")return 100;if(!i.value)return D(y);const h=jo(y.entry,o.value);return Vo(h,te.value)}const se=A(()=>Uo(te.value)),oe=A(()=>Uo(I.value)),W=[0,25,50,75,100],re=A(()=>{const y=d.value;return y?oc(y,m.value):null}),we=A(()=>{const y=new Map;for(const h of v.value){const a=en(h.entry.contextInfo.model);y.has(a)||y.set(a,Yr(h.entry.contextInfo.model,!0))}return Array.from(y.entries()).map(([h,a])=>({name:h,color:a}))}),H=A(()=>Object.entries(mt).map(([y,h])=>({key:y,name:h.label,color:h.color}))),T=A(()=>{const y=v.value;if(y.length===0)return-1;if(n.value!=="all")return y.length-1;for(let h=y.length-1;h>=0;h--)if(y[h].isMain)return h;return-1}),P=A(()=>{const y=v.value,h=T.value;if(h<0)return!1;for(let a=0;a<=h;a++)if(!(n.value==="all"&&!y[a].isMain)&&fi(y[a].entry)!==null)return!0;return!1}),ee=A(()=>{const y=Math.max(0,T.value+1);return y===0?"0 0 1 100":`0 0 ${y} 100`}),ne=A(()=>{const y=v.value.length,h=Math.max(0,T.value+1);return y===0||h===0?"0%":`${h/y*100}%`}),$=A(()=>{const y=v.value,h=T.value;if(y.length===0||h<0)return"";const a=[];for(let f=0;f<=h;f++){if(n.value==="all"&&!y[f].isMain)continue;const E=fi(y[f].entry);if(E===null)continue;const q=f+.5,N=(1-E)*100;a.push(`${q.toFixed(3)},${N.toFixed(2)}`)}return a.join(" ")}),L=A(()=>ic(m.value));function G(y){y&&(y.scrollLeft=y.scrollWidth)}function k(){Ue(()=>{G(l.value),G(c.value)})}return Mn(()=>{k()}),Ke(()=>{var y,h;return[((y=p.value)==null?void 0:y.id)??"",n.value,v.value.length,((h=v.value[v.value.length-1])==null?void 0:h.entry.id)??""]},()=>{k()},{immediate:!0}),(y,h)=>{const a=gn("tooltip");return p.value?(g(),b("div",t0,[u("div",n0,[h[4]||(h[4]=u("span",{class:"scope-label"},"Scope",-1)),u("div",s0,[(g(),b(ve,null,Te(["main","all"],f=>u("button",{key:"scope-"+f,class:he({on:n.value===f}),onClick:E=>n.value=f},M(f==="all"?"All turns":"Main turns"),11,o0)),64))])]),u("section",i0,[u("div",r0,[h[9]||(h[9]=u("span",{class:"panel-title"},"Token Timeline",-1)),u("div",l0,[P.value?(g(),b("button",{key:0,class:he(["overlay-toggle",{on:r.value}]),onClick:h[0]||(h[0]=f=>r.value=!r.value)},[...h[5]||(h[5]=[u("span",{class:"legend-dot legend-dot--cache"},null,-1),xe(" Cache ",-1)])],2)):le("",!0),s.value==="absolute"?(g(),b("button",{key:1,class:he(["overlay-toggle",{on:i.value}]),onClick:h[1]||(h[1]=f=>i.value=!i.value)},[...h[6]||(h[6]=[u("span",{class:"legend-dot legend-dot--dashed"},null,-1),xe(" Limit ",-1)])],2)):le("",!0),u("div",a0,[Be((g(),b("button",{class:he({on:s.value==="absolute"}),onClick:h[2]||(h[2]=f=>s.value="absolute")},[...h[7]||(h[7]=[u("i",{class:"i-carbon-chart-column mode-icon"},null,-1),xe(" Abs ",-1)])],2)),[[a,"Absolute token counts"]]),Be((g(),b("button",{class:he({on:s.value==="normalized"}),onClick:h[3]||(h[3]=f=>s.value="normalized")},[...h[8]||(h[8]=[u("i",{class:"i-carbon-chart-maximum mode-icon"},null,-1),xe(" Pct ",-1)])],2)),[[a,"Normalized to 100% per turn"]])])])]),u("div",c0,[u("div",u0,[u("div",d0,[s.value==="normalized"?(g(!0),b(ve,{key:0},Te([...W].reverse(),f=>(g(),b("span",{key:"norm-"+f},M(f)+"%",1))),128)):(g(!0),b(ve,{key:1},Te([...i.value?se.value:_.value].reverse(),f=>(g(),b("span",{key:f},M(Y(Xr)(f,"tokens")),1))),128))]),u("div",{ref_key:"tokenChartScrollEl",ref:l,class:"chart-scroll"},[u("div",{class:he(["bars-wrap",{sparse:S.value}])},[u("div",{class:he(["bars",{sparse:S.value}])},[(g(!0),b(ve,null,Te(v.value,(f,E)=>{var q;return g(),b("div",{key:f.entry.id,class:he(["bar",{active:((q=d.value)==null?void 0:q.id)===f.entry.id,normalized:s.value==="normalized"}]),style:Me({height:B(f)+"%"}),onClick:N=>O(f.entry)},[(g(!0),b(ve,null,Te(ae(f),N=>Be((g(),b("div",{key:f.entry.id+"-"+N.key,class:"bar-segment",style:Me({height:N.pct+"%",background:N.color})},null,4)),[[a,Y(ev)(f.entry,N)]])),128))],14,f0)}),128))],2),s.value==="absolute"&&i.value&&ce.value>=0?(g(),b("div",{key:0,class:"limit-line",style:Me({top:ce.value+"%"})},null,4)):le("",!0),r.value&&$.value?(g(),b("svg",{key:1,class:"cache-line-svg",viewBox:ee.value,style:Me({width:ne.value}),preserveAspectRatio:"none"},[u("polyline",{points:$.value,fill:"none",stroke:"var(--accent-cyan)","stroke-width":"1.5","vector-effect":"non-scaling-stroke","stroke-linejoin":"round","stroke-linecap":"round",opacity:"0.7"},null,8,h0)],12,p0)):le("",!0)],2),u("div",{class:he(["events",{sparse:S.value}])},[(g(!0),b(ve,null,Te(K.value,f=>(g(),b("div",{key:"evt-"+f.entryId,class:"event-slot"},[f.firstEvent?Be((g(),b("button",{key:0,class:he(["event-marker",`event-marker--${f.firstEvent.type}`]),type:"button","aria-label":f.title},[xe(M(Y(Jh)(f.firstEvent.type)),1)],10,v0)),[[a,f.title]]):le("",!0)]))),128))],2),u("div",{class:he(["labels",{sparse:S.value}])},[(g(!0),b(ve,null,Te(C.value,(f,E)=>(g(),b("div",{key:E,class:"label"},M(f&&(de.value<=1||f%de.value===0)?f:""),1))),128))],2)],512)]),u("div",m0,[(g(!0),b(ve,null,Te(H.value,f=>(g(),b("button",{key:f.key,class:he(["legend-item legend-item--interactive",{"legend-item--hidden":o.value.has(f.key)}]),onClick:E=>V(f.key)},[u("span",{class:"legend-dot",style:Me({background:o.value.has(f.key)?"var(--text-ghost)":f.color})},null,4),xe(" "+M(f.name),1)],10,g0))),128)),L.value.turnsRemaining!==null&&L.value.turnsRemaining>0?Be((g(),b("span",y0,[xe(" ~"+M(L.value.turnsRemaining)+" turns remaining ",1)])),[[a,`Growing ~${Y(_e)(Math.round(L.value.growthPerTurn))}/turn over ${L.value.sinceCompaction} turns since last compaction`]]):L.value.turnsRemaining===0?Be((g(),b("span",_0,[...h[10]||(h[10]=[xe(" At limit ",-1)])])),[[a,"Context window is at or near the limit"]]):le("",!0)])])]),u("section",b0,[u("div",w0,[h[11]||(h[11]=u("span",{class:"panel-title"},"Cost Timeline",-1)),u("span",k0,"Scope: "+M(n.value==="main"?"Main turns only":"All turns"),1)]),u("div",x0,[u("div",$0,[u("div",S0,[(g(!0),b(ve,null,Te([...oe.value].reverse(),f=>(g(),b("span",{key:"cost-"+f},M(Y(Xr)(f,"cost")),1))),128))]),u("div",{ref_key:"costChartScrollEl",ref:c,class:"chart-scroll"},[u("div",{class:he(["bars-wrap",{sparse:S.value}])},[u("div",{class:he(["bars",{sparse:S.value}])},[(g(!0),b(ve,null,Te(v.value,f=>{var E;return Be((g(),b("div",{key:"cost-"+f.entry.id,class:he(["bar",{active:((E=d.value)==null?void 0:E.id)===f.entry.id}]),style:Me({height:ue(f)+"%"}),onClick:q=>O(f.entry)},[u("div",{class:"bar-cost",style:Me({background:Y(Yr)(f.entry.contextInfo.model,f.isMain)})},null,4)],14,C0)),[[a,Y(Qh)(f.entry,f.isMain)]])}),128))],2)],2),u("div",{class:he(["labels",{sparse:S.value}])},[(g(!0),b(ve,null,Te(C.value,(f,E)=>(g(),b("div",{key:"cost-label-"+E,class:"label"},M(f&&(de.value<=1||f%de.value===0)?f:""),1))),128))],2)],512)]),u("div",T0,[(g(!0),b(ve,null,Te(we.value,f=>(g(),b("span",{key:f.name,class:"legend-item"},[u("span",{class:"legend-dot",style:Me({background:f.color})},null,4),xe(" "+M(f.name),1)]))),128))])])]),Re(ac,{"diff-data":re.value,"show-when-empty":!!d.value,onCategoryClick:R},null,8,["diff-data","show-when-empty"])])):le("",!0)}}}),E0=at(M0,[["__scopeId","data-v-8510f6fe"]]),P0=["aria-label","aria-valuemax","aria-valuenow"],I0={class:"scrubber-controls"},A0=["disabled"],L0={class:"readout-num"},O0={class:"readout-total"},R0=["disabled"],D0={class:"spark-bars"},N0={class:"tt-row tt-turn"},F0={class:"tt-row"},z0={class:"tt-row tt-dim"},B0=Qe({__name:"TurnScrubber",setup(e){const t=At(),n=me(null),s=me(!1),o=me(null),i=A(()=>t.selectedSession),r=A(()=>t.selectedEntry),l=A(()=>i.value?Yt([...i.value.entries].reverse()):[]),c=A(()=>l.value.filter(W=>W.isMain)),p=A(()=>c.value.map(W=>W.entry)),d=A(()=>c.value.map(W=>!W.isMain)),m=A(()=>p.value.length),v=A(()=>{const W=r.value;if(!W)return-1;let re=-1;for(const we of l.value)if(we.isMain&&re++,we.entry.id===W.id)return re;return-1}),w=A(()=>{let W=0;for(const re of p.value)re.contextInfo.totalTokens>W&&(W=re.contextInfo.totalTokens);return W}),I=A(()=>{const W=w.value;return W===0?p.value.map(()=>({height:.15,tokens:0,cost:0,model:"",utilization:0})):p.value.map(re=>({height:Math.max(.08,re.contextInfo.totalTokens/W),tokens:re.contextInfo.totalTokens,cost:re.costUsd??0,model:en(re.contextInfo.model),utilization:re.contextLimit>0?re.contextInfo.totalTokens/re.contextLimit:0}))}),S=A(()=>t.selectionMode!=="pinned"||v.value<0?!1:v.value<m.value-1),_=A(()=>S.value?Math.max(0,m.value-1-v.value):0),C=A(()=>S.value?_.value/m.value>=.12:!1),z=A(()=>((v.value+1)/m.value+1)/2*100),K=A(()=>{const W=[];let re=0,we=-1;for(const H of l.value)H.isMain?(we>=0&&W.push(re),re=0,we++):re++;return we>=0&&W.push(re),W}),V=A(()=>{if(o.value===null||o.value<0||o.value>=p.value.length)return null;const W=p.value[o.value],re=I.value[o.value],we=K.value[o.value]||0;return{turn:o.value+1,tokens:_e(W.contextInfo.totalTokens),cost:_t(W.costUsd),model:re.model,subs:we,isSub:d.value[o.value]||!1}});function Q(W){de(W)&&t.pinEntry(p.value[W].id)}function D(){t.followLive()}function ae(){const W=v.value-1;de(W)&&Q(W)}function ue(){const W=v.value+1;de(W)&&Q(W)}function O(){r.value&&t.pinEntry(r.value.id)}function R(W){const re=n.value;if(!re||m.value===0)return-1;const we=re.getBoundingClientRect(),T=Math.max(0,Math.min(W.clientX-we.left,we.width))/we.width;return Math.min(Math.floor(T*m.value),m.value-1)}function de(W){return W>=0&&W<m.value}function F(W){var we,H;if(m.value===0)return;s.value=!0;const re=R(W);de(re)&&Q(re),(H=(we=W.target)==null?void 0:we.setPointerCapture)==null||H.call(we,W.pointerId)}function te(W){const re=R(W);o.value=de(re)?re:null,s.value&&de(re)&&Q(re)}function ce(W){var re,we;s.value=!1,(we=(re=W.target)==null?void 0:re.releasePointerCapture)==null||we.call(re,W.pointerId)}function B(){o.value=null}function se(W){W.key==="ArrowLeft"||W.key==="ArrowUp"?(W.preventDefault(),ae()):W.key==="ArrowRight"||W.key==="ArrowDown"?(W.preventDefault(),ue()):W.key==="Home"?(W.preventDefault(),Q(0)):W.key==="End"?(W.preventDefault(),m.value>0&&Q(m.value-1)):W.key==="Escape"&&(W.preventDefault(),D())}function oe(W){return W>=.9?"var(--accent-red)":W>=.7?"var(--accent-amber)":"var(--accent-blue)"}return(W,re)=>i.value&&r.value&&m.value>=1?(g(),b("div",{key:0,class:"scrubber",role:"slider","aria-label":`Turn scrubber: turn ${v.value+1} of ${m.value}`,"aria-valuemin":1,"aria-valuemax":m.value,"aria-valuenow":v.value+1,tabindex:"0",onKeydown:se},[u("div",I0,[u("button",{class:"ctrl-btn",disabled:v.value<=0,onClick:ae,title:"Previous turn (←)","aria-label":"Previous turn"},[...re[0]||(re[0]=[u("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none"},[u("path",{d:"M7 1L3 5L7 9",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],8,A0),u("span",{class:he(["turn-readout",Y(t).selectionMode==="live"?"is-live":"is-pinned"])},[re[1]||(re[1]=u("span",{class:"readout-dot"},null,-1)),u("span",L0,M(v.value+1),1),re[2]||(re[2]=u("span",{class:"readout-sep"},"/",-1)),u("span",O0,M(m.value),1)],2),u("button",{class:"ctrl-btn",disabled:v.value<0||v.value>=m.value-1,onClick:ue,title:"Next turn (→)","aria-label":"Next turn"},[...re[3]||(re[3]=[u("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none"},[u("path",{d:"M3 1L7 5L3 9",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],8,R0)]),u("div",{ref_key:"trackEl",ref:n,class:"scrubber-track",onPointerdown:F,onPointermove:te,onPointerup:ce,onPointerleave:B},[u("div",D0,[(g(!0),b(ve,null,Te(I.value,(we,H)=>(g(),b("div",{key:H,class:he(["spark-col",{active:H===v.value,hover:H===o.value&&H!==v.value,past:Y(t).selectionMode==="pinned"&&H>v.value,"is-sub":d.value[H]}])},[u("div",{class:"spark-bar",style:Me({height:we.height*100+"%","--bar-color":oe(we.utilization)})},null,4),K.value[H]>0?(g(),b("div",{key:0,class:he(["sub-dot",{"sub-burst":K.value[H]>=3}])},null,2)):le("",!0)],2))),128))]),v.value>=0?(g(),b("div",{key:0,class:he(["playhead",{live:Y(t).selectionMode==="live"}]),style:Me({left:(v.value+.5)/m.value*100+"%"})},[...re[4]||(re[4]=[u("div",{class:"playhead-line"},null,-1),u("div",{class:"playhead-head"},null,-1)])],6)):le("",!0),C.value?(g(),b("div",{key:1,class:"new-turns-badge",style:Me({left:z.value+"%"}),onClick:dn(D,["stop"])}," +"+M(_.value)+" new ",5)):le("",!0),Re(zn,{name:"tooltip-fade"},{default:ft(()=>[V.value&&o.value!==v.value?(g(),b("div",{key:0,class:"scrub-tooltip",style:Me({left:Math.min(Math.max((o.value+.5)/m.value*100,8),92)+"%"})},[u("div",N0,"T"+M(V.value.turn)+M(V.value.isSub?" (sub)":""),1),u("div",F0,M(V.value.tokens)+" · "+M(V.value.cost),1),u("div",z0,M(V.value.model)+M(V.value.subs>0?` · ${V.value.subs} sub`:""),1)],4)):le("",!0)]),_:1})],544),Y(t).selectionMode==="live"?(g(),b("button",{key:0,class:"action-btn action-pin",onClick:O,title:"Pin current turn to scrub history"},[...re[5]||(re[5]=[u("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none"},[u("circle",{cx:"5",cy:"5",r:"3.5",stroke:"currentColor","stroke-width":"1"}),u("circle",{cx:"5",cy:"5",r:"1.5",fill:"currentColor"})],-1),xe(" Pin ",-1)])])):(g(),b("button",{key:1,class:"action-btn action-return",onClick:D,title:"Return to live (Esc)"},[...re[6]||(re[6]=[u("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none"},[u("path",{d:"M2 5H8M8 5L5.5 2.5M8 5L5.5 7.5",stroke:"currentColor","stroke-width":"1.2","stroke-linecap":"round","stroke-linejoin":"round"})],-1),xe(" Live ",-1)])]))],40,P0)):le("",!0)}}),H0=at(B0,[["__scopeId","data-v-865993b3"]]),j0={class:"tab-bar"},V0=["onClick"],U0={class:"tab-content"},K0=Qe({__name:"InspectorPanel",setup(e){const t=At(),n=[{id:"overview",label:"Overview",icon:"i-carbon-dashboard"},{id:"messages",label:"Messages",icon:"i-carbon-chat"},{id:"timeline",label:"Timeline",icon:"i-carbon-activity"}],s={overview:Jg,messages:e0,timeline:E0},o=A(()=>s[t.inspectorTab]);function i(l){l==="messages"&&t.clearMessageFocus(),t.setInspectorTab(l)}function r(l){l.key==="Escape"&&!l.defaultPrevented&&t.setView("dashboard")}return(l,c)=>(g(),b("div",{class:"inspector",onKeydown:r,tabindex:"-1"},[Re(H0),u("div",j0,[(g(),b(ve,null,Te(n,p=>u("button",{key:p.id,class:he(["tab-btn",{active:Y(t).inspectorTab===p.id}]),onClick:d=>i(p.id)},[u("i",{class:he(p.icon)},null,2),xe(" "+M(p.label),1)],10,V0)),64))]),u("div",U0,[(g(),dt(Yl(o.value),{key:Y(t).inspectorTab}))])],32))}}),W0=at(K0,[["__scopeId","data-v-74dad8d1"]]),q0={class:"session-rail","aria-label":"Sessions"},G0={class:"rail-scroll"},J0=["onClick"],Y0={class:"tile-meta"},X0=Qe({__name:"SessionRail",setup(e){const t=At();function n(c){t.selectSession(c),t.setView("inspector")}function s(){t.setView("dashboard")}function o(c){const p=en(c.latestModel),d=c.entryCount+(c.entryCount===1?" turn":" turns"),m=_t(c.totalCost),v=c.healthScore?`
30
+ `).length>my)}async function P(){if(!l){if(c)return c;c=(async()=>{l=await(await ey(()=>import("./index-BxdAuPdU.js"),[])).createHighlighter({themes:["github-dark"],langs:["json","xml","markdown","typescript"]})})(),await c}}async function ee(k,y,h){if(!T(k,y)||p.has(h)||d.has(h))return;const a=H(y);if(a){d.add(h);try{if(await P(),!l)return;const f=l.codeToHtml(k,{lang:a,theme:"github-dark"});p.set(h,f),m.value+=1}catch{}finally{d.delete(h)}}}function ne(k,y=!1){m.value;const h=re(k,y),a=`${h}:${ue(k)}`;if(T(k,h)){const f=p.get(a);if(f)return f;ee(k,h,a)}return we(k,y)}function $(){const k=v.value;if(!k)return;if(o.value==="raw"){const h=JSON.stringify(Ho(k),null,2),a=ae(h).text,f=re(a,!0);ee(a,f,`${f}:${ue(a)}`);return}const y=L();for(const h of y){const a=ae(h.content).text,f=re(a,h.isJson);ee(a,f,`${f}:${ue(a)}`)}}function L(){const k=v.value;if(!k)return[];const y=k.contentBlocks;return y&&y.length>0?y.map(h=>{if(h.type==="tool_use"){const f=h.input?JSON.stringify(h.input,null,2):"{}";return{type:"tool_use",label:`tool_use: ${h.name||"?"}`,labelClass:"lbl-tool-use",content:f,isJson:!0}}if(h.type==="tool_result"){const f=h.tool_use_id?w.value[h.tool_use_id]:null,E=typeof h.content=="string"?h.content:JSON.stringify(h.content,null,2);return{type:"tool_result",label:`tool_result${f?": "+f:""}`,labelClass:"lbl-tool-result",content:E,isJson:!1}}const a=h;return a.type==="thinking"?{type:"thinking",label:"thinking",labelClass:"lbl-thinking",content:a.thinking||a.text||"",isJson:!1}:h.type==="text"||h.type==="input_text"?{type:h.type,label:h.type,labelClass:"lbl-text",content:h.text||"",isJson:!1}:h.type==="image"?{type:"image",label:"image",labelClass:"lbl-image",content:"[Image content]",isJson:!1}:{type:"unknown",label:"block",labelClass:"lbl-text",content:`[Unknown block type: ${h.type||"unspecified"}]`,isJson:!1}}):[{type:"text",label:"",labelClass:"",content:k.content||"",isJson:!1}]}const G=A(()=>{const k=v.value;if(!k)return[];const y=[["Role",k.role],["Tokens",_e(k.tokens||0)],["% context",_.value+"%"],["Model",n.entry.contextInfo.model||"?"]];if(k.contentBlocks){for(const h of k.contentBlocks)if(h.type==="tool_use"&&(y.push(["tool_use_id",h.id||"?"]),y.push(["tool_name",h.name||"?"])),h.type==="tool_result"&&h.tool_use_id){y.push(["tool_use_id",h.tool_use_id]);const a=w.value[h.tool_use_id];a&&y.push(["tool_name",a])}}return y.push(["Position",`${n.selectedIndex+1} / ${n.messages.length}`]),y});return(k,y)=>{const h=gn("tooltip");return g(),b("div",{class:"detail",tabindex:"0",onKeydown:V},[u("div",ty,[u("div",ny,[u("span",{class:"detail-title",style:Me({color:S.value})},M(I.value),5),u("div",sy,[Be((g(),b("button",{disabled:!C.value,onClick:y[0]||(y[0]=a=>K(-1))},[...y[6]||(y[6]=[u("i",{class:"i-carbon-chevron-up"},null,-1)])],8,oy)),[[h,"↑ Previous"]]),Be((g(),b("button",{disabled:!z.value,onClick:y[1]||(y[1]=a=>K(1))},[...y[7]||(y[7]=[u("i",{class:"i-carbon-chevron-down"},null,-1)])],8,iy)),[[h,"↓ Next"]])]),Be((g(),b("button",{class:"close-btn",onClick:y[2]||(y[2]=a=>k.$emit("close"))},[...y[8]||(y[8]=[u("i",{class:"i-carbon-close"},null,-1)])])),[[h,"Close (Esc)"]])]),v.value?(g(),b("div",ry,[u("span",null,[u("b",null,M(v.value.role),1)]),u("span",null,M(Y(_e)(v.value.tokens||0))+" tok",1),u("span",null,M(_.value)+"%",1),u("span",null,M(e.selectedIndex+1)+"/"+M(e.messages.length),1)])):le("",!0)]),u("div",ly,[u("button",{class:he({on:o.value==="rendered"}),onClick:y[3]||(y[3]=a=>o.value="rendered")},"Rendered",2),u("button",{class:he({on:o.value==="raw"}),onClick:y[4]||(y[4]=a=>o.value="raw")},"Raw",2)]),u("div",{ref_key:"contentEl",ref:r,class:"detail-body"},[o.value==="rendered"&&v.value?(g(!0),b(ve,{key:0},Te(L(),(a,f)=>(g(),b(ve,{key:f},[f>0?(g(),b("hr",ay)):le("",!0),a.label?(g(),b("div",{key:1,class:he(["block-label",a.labelClass])},M(a.label),3)):le("",!0),u("div",{class:he(["block-content syntax rich-html",`kind-${re(ae(a.content).text,a.isJson)}`]),innerHTML:ne(ae(a.content).text,a.isJson)},null,10,cy),ae(a.content).truncated?(g(),b("button",{key:2,class:"show-more",onClick:y[5]||(y[5]=E=>i.value=!0)}," Show full content… ")):le("",!0)],64))),128)):o.value==="raw"&&v.value?(g(),b(ve,{key:1},[u("div",uy,[u("button",{class:he(["copy-btn",{copied:Q.value==="Copied!"}]),onClick:D},[y[9]||(y[9]=u("i",{class:"i-carbon-copy"},null,-1)),xe(" "+M(Q.value),1)],2)]),u("div",{class:"block-content syntax rich-html kind-json",innerHTML:ne(JSON.stringify(Y(Ho)(v.value),null,2),!0)},null,8,dy)],64)):le("",!0)],512),u("div",fy,[y[10]||(y[10]=u("div",{class:"meta-header"},"Metadata",-1)),(g(!0),b(ve,null,Te(G.value,([a,f])=>(g(),b(ve,{key:a},[u("span",py,M(a),1),u("span",{class:"meta-val",title:f},M(f),9,hy)],64))),128))])],32)}}}),yy=at(gy,[["__scopeId","data-v-b5106f07"]]),_y={class:"msg-toolbar"},by={class:"message-view-toggle"},wy={key:0,class:"message-view-toggle agent-toggle"},ky={key:0,class:"heavy-strip"},xy={class:"heavy-actions"},$y=["onClick"],Sy={class:"heavy-category"},Cy={class:"heavy-preview"},Ty={class:"heavy-tokens"},My={key:1,class:"focus-strip"},Ey={key:0},Py={key:1},Iy=["data-category"],Ay=["onClick"],Ly={class:"group-name"},Oy={class:"group-stats"},Ry={class:"group-bar-track"},Dy=["data-tool-name","onClick"],Ny={class:"msg-role"},Fy={class:"msg-preview"},zy={key:0,class:"focus-strip"},By={class:"focus-file-name"},Hy={class:"focus-file-count"},jy={class:"chrono-list"},Vy=["onClick"],Uy={class:"chrono-gutter subagent-gutter"},Ky={class:"chrono-preview subagent-preview"},Wy={class:"chrono-tok subagent-model"},qy={class:"chrono-turn-label"},Gy={key:2,class:"chrono-future-sep"},Jy=["onClick"],Yy={class:"chrono-gutter"},Xy={class:"chrono-type"},Zy={class:"chrono-preview"},Qy=Qe({__name:"MessagesTab",setup(e){const t=At(),n=A(()=>t.selectedEntry),s=A(()=>t.selectedSession),{isExpanded:o,toggle:i,expand:r}=Xg(),l=me(null),c=me("chrono"),p=me(!1),d=me(0),m=me(null),v=me(1),w=me(null),I=me([]),S=me(0),_=A(()=>ko(z.value)),C=A(()=>{const U=s.value;return!U||U.entries.length<=1?!1:Yt([...U.entries].reverse()).some(ye=>!ye.isMain)}),z=A(()=>{var j;if(!n.value)return[];t.entryDetailVersion;const U=t.getEntryDetail(n.value.id);return(j=U==null?void 0:U.messages)!=null&&j.length?U.messages:n.value.contextInfo.messages||[]}),K=A(()=>!s.value||s.value.entries.length===0?null:s.value.entries[0]),V=A(()=>{var j;if(!K.value)return[];t.entryDetailVersion;const U=t.getEntryDetail(K.value.id);return(j=U==null?void 0:U.messages)!=null&&j.length?U.messages:K.value.contextInfo.messages||[]}),Q=A(()=>z.value.length),D=A(()=>t.selectionMode!=="pinned"?!1:V.value.length>Q.value),ae=A(()=>{if(!D.value)return z.value.map((j,ye)=>({msg:j,origIdx:ye,future:!1}));const U=[];for(let j=0;j<z.value.length;j++)U.push({msg:z.value[j],origIdx:j,future:!1});for(let j=z.value.length;j<V.value.length;j++)U.push({msg:V.value[j],origIdx:j,future:!0});return U}),ue=A(()=>{const U=ae.value,j=new Set;U.length>0&&j.add(0);let ye=!1;for(let x=0;x<U.length;x++){const X=U[x].msg.role;X==="assistant"?ye=!0:X==="user"&&ye&&(j.add(x),ye=!1)}return j}),O=A(()=>{const U=s.value,j=n.value;if(!U||!j||t.messagesMode!=="all")return new Map;const ye=Yt([...U.entries].reverse()),x=[],X=[];let be=[];for(const De of ye)De.isMain?(x.push(De.entry),x.length>1&&X.push([...be]),be=[]):x.length>0&&be.push(De.entry);X.push([...be]);const Se=x.findIndex(De=>De.id===j.id);if(Se<0)return new Map;const tt=Array.from(ue.value).sort((De,Ge)=>De-Ge),Ht=F.value,Vn=new Map;for(let De=0;De<=Se&&De<X.length;De++){const Ge=X[De];if(Ge.length===0)continue;const Xe=De+1-Ht;Xe<0||Xe<tt.length&&Vn.set(tt[Xe],Ge)}return Vn}),R=A(()=>{const U=s.value,j=n.value;if(!U||!j)return 1;const ye=Yt([...U.entries].reverse());let x=0;for(const X of ye)if(X.isMain&&x++,X.entry.id===j.id)return x;return 1}),de=A(()=>{const U=Q.value;let j=0;for(const ye of ue.value)ye<U&&j++;return j}),F=A(()=>Math.max(0,R.value-de.value)),te=A(()=>{const U=new Map;let j=F.value;for(const ye of ue.value)j++,U.set(ye,j);return U}),ce=A(()=>nc(z.value)),B=A(()=>{if(c.value==="chrono")return we.value;const U=[];for(const j of ce.value)for(const ye of j.items)U.push(ye);return U}),se=A(()=>w.value!==null),oe=A(()=>se.value?w.value:n.value),W=A(()=>se.value?I.value:B.value),re=A(()=>se.value?S.value:d.value),we=A(()=>z.value.map((U,j)=>({msg:U,origIdx:j}))),H=A(()=>{const U=[];let j=0;for(const ye of ae.value)ye.future||(j+=ye.msg.tokens||0),U.push(j);return U}),T=A(()=>{var U;return((U=n.value)==null?void 0:U.contextInfo.totalTokens)??0}),P=A(()=>{const U=[];for(const j of ce.value)for(const ye of j.items)U.push({origIdx:ye.origIdx,category:j.category,preview:Bo(ye.msg,_.value)||"(empty)",tokens:ye.msg.tokens||0});return U.filter(j=>j.tokens>0).sort((j,ye)=>ye.tokens-j.tokens).slice(0,3)}),ee=A(()=>t.messageFocusTool),ne=A(()=>t.messageFocusCategory),$=A(()=>t.messageFocusFile),L=A(()=>{var x;const U=t.messageFocusCategory;if(!U)return null;const j=new Set(ce.value.map(X=>X.category));if(j.has(U))return U;const ye={assistant_text:["tool_calls","thinking","assistant_text","user_text"],tool_definitions:["tool_calls","tool_results","system_injections"],system_prompt:["system_injections","assistant_text","user_text"],images:["user_text","assistant_text","tool_results"],cache_markers:["tool_results","assistant_text","user_text"],other:["assistant_text","user_text","tool_results"]};for(const X of ye[U]||[])if(j.has(X))return X;return((x=ce.value[0])==null?void 0:x.category)??null}),G=A(()=>!!ne.value&&!!L.value&&ne.value!==L.value);function k(){w.value=null,I.value=[]}function y(U){k(),d.value=U,E(U),p.value=!0}function h(){p.value=!1,k()}function a(U){U.key==="Escape"&&p.value&&(h(),U.preventDefault(),U.stopPropagation())}function f(U){var X;const j=(U.contentBlocks||[])[0];if(!j)return`${U.role}|${U.tokens||0}|${((X=U.content)==null?void 0:X.slice(0,160))||""}`;if(j.type==="tool_result"){const be=typeof j.content=="string"?j.content:JSON.stringify(j.content||"");return`${U.role}|${U.tokens||0}|tool_result|${j.tool_use_id||""}|${be.slice(0,160)}`}if(j.type==="tool_use")return`${U.role}|${U.tokens||0}|tool_use|${j.id||""}|${j.name||""}|${JSON.stringify(j.input||{}).slice(0,120)}`;const ye=j,x=String(ye.text||ye.thinking||"").slice(0,160);return`${U.role}|${U.tokens||0}|${String(ye.type||"other")}|${x}`}function E(U){const j=B.value[U];if(!j)return;const ye=f(j.msg);m.value=ye;let x=0;for(let X=0;X<=U;X++)f(B.value[X].msg)===ye&&(x+=1);v.value=Math.max(1,x)}function q(){const U=m.value;if(!U)return-1;let j=0;for(let ye=0;ye<B.value.length;ye++)if(f(B.value[ye].msg)===U&&(j+=1,j===v.value))return ye;return-1}function N(U){se.value?S.value=U:(d.value=U,E(U))}function J(U,j){let ye=0;for(let x=0;x<ce.value.length;x++){if(x===U)return ye+j;ye+=ce.value[x].items.length}return 0}function pe(U){const j=B.value.findIndex(ye=>ye.origIdx===U);if(j>=0){if(c.value==="category"){const ye=z.value[U];if(ye){const x=St(ye);r(x)}}y(j)}}function fe(U){const j=St(U);return(Ye[j]||{color:"#4b5563"}).color}function ie(U){const j=St(U);return(Ye[j]||{label:j}).label}function Z(U){var x;if(!s.value)return;const j=s.value.entries;let ye=null;for(let X=j.length-1;X>=0;X--)if((((x=j[X].contextInfo.messages)==null?void 0:x.length)??0)>U){ye=j[X];break}ye||(ye=j[0]),t.pinEntry(ye.id)}async function ke(U){var be;const j=s.value;if(!j)return;const ye=j.entries.find(Se=>Se.id===U);if(!ye)return;await t.loadEntryDetail(U),t.entryDetailVersion;const x=t.getEntryDetail(U),X=(be=x==null?void 0:x.messages)!=null&&be.length?x.messages:ye.contextInfo.messages||[];w.value=ye,I.value=X.map((Se,tt)=>({msg:Se,origIdx:tt})),S.value=0,p.value=!0}function ge(U){if(St(U)!=="tool_results")return null;for(const j of U.contentBlocks||[])if(j.type==="tool_result")return j.tool_use_id&&_.value[j.tool_use_id]||null;return null}function $e(U){const j=ee.value;if(!j)return{};const ye=ge(U);if(!ye)return{"tool-muted":!0};const x=ye.trim().toLowerCase(),X=j.trim().toLowerCase();return{"tool-focused":x===X,"tool-muted":x!==X}}async function Ce(){const U=L.value,j=t.messageFocusIndex,ye=t.messageFocusOpenDetail,x=t.messageFocusTool,X=t.messageFocusFile;t.clearMessageFocus();const be=j;if(be!=null){if(c.value==="chrono"){for(let De=0;De<4;De++){await Ue(),pe(be),await Ue();const Ge=l.value;if(Ge){const He=Array.from(Ge.querySelectorAll(".chrono-row")).find(st=>st.classList.contains("selected"));if(He){He.scrollIntoView({block:"center",behavior:"smooth"});return}}}return}for(let De=0;De<4;De++){await Ue();for(const Ge of ce.value)if(Ge.items.find(He=>He.origIdx===be)){r(Ge.category),await Ue(),await Ue(),pe(be),await Ue();const He=l.value;if(He){const vt=Array.from(He.querySelectorAll(".msg-row")).find(xo=>xo.classList.contains("selected"));vt&&vt.scrollIntoView({block:"center",behavior:"smooth"})}return}}return}if(X){t.messageFocusFile=X,c.value="chrono",await Ue();const De=z.value,Ge=new Set;for(const He of De)if(He.contentBlocks){for(const st of He.contentBlocks)if(st.type==="tool_use"){const vt=st;Je(vt)===X&&Ge.add(vt.id)}}let Xe=-1;for(let He=0;He<De.length;He++){const st=De[He];if(st.contentBlocks){for(const vt of st.contentBlocks){if(vt.type==="tool_result"&&Ge.has(vt.tool_use_id)){Xe=He;break}if(vt.type==="tool_use"&&Je(vt)===X&&Xe<0){Xe=He;break}}if(Xe>=0)break}}if(Xe>=0)for(let He=0;He<4;He++){await Ue();const st=l.value;if(!st)continue;const vt=Array.from(st.querySelectorAll(".chrono-row"));if(vt[Xe]){vt[Xe].scrollIntoView({block:"center",behavior:"smooth"});return}}return}const Se=U;if(!Se)return;const tt=ye;if(tt?c.value="chrono":c.value="category",c.value==="chrono"){for(let De=0;De<4;De++){await Ue();const Ge=l.value;if(!Ge)continue;const Xe=Array.from(Ge.querySelectorAll(".chrono-row"));let He=-1;for(let st=z.value.length-1;st>=0;st--)if(St(z.value[st])===Se){He=st;break}if(He>=0&&Xe[He]){Xe[He].scrollIntoView({block:"center",behavior:"smooth"}),tt&&(await Ue(),pe(He));return}}return}let Ht=null;for(let De=0;De<4;De++){if(await Ue(),Ht=l.value,!Ht)continue;r(Se),await Ue();const Ge=Ht.querySelector(`[data-category="${Se}"]`);if(Ge){Ge.scrollIntoView({block:"center",behavior:"smooth"});break}}if(!Ht)return;const Vn=x;if(Vn){const De=Array.from(Ht.querySelectorAll(".msg-row")),Ge=Vn.trim().toLowerCase(),Xe=De.find(He=>(He.getAttribute("data-tool-name")||"").trim().toLowerCase()===Ge);Xe&&Xe.scrollIntoView({block:"center",behavior:"smooth"})}}function Ie(){t.focusMessageCategory(L.value||t.messageFocusCategory||"tool_results")}function Ne(){t.clearMessageFocus()}const Ae=A(()=>{const U=$.value;if(!U)return new Set;const j=z.value,ye=new Set,x=new Set;for(let X=0;X<j.length;X++){const be=j[X];if(be.contentBlocks){for(const Se of be.contentBlocks)if(Se.type==="tool_use"){const tt=Se;Je(tt)===U&&(x.add(tt.id),ye.add(X))}}}for(let X=0;X<j.length;X++){const be=j[X];if(be.contentBlocks)for(const Se of be.contentBlocks)Se.type==="tool_result"&&x.has(Se.tool_use_id)&&ye.add(X)}return ye});function Je(U){var x;const j=U.input,ye=(x=t.selectedSession)==null?void 0:x.workingDirectory;if(j&&typeof j=="object")for(const X of["file_path","path","filePath"]){const be=j[X];if(typeof be=="string"&&be.length>0){let Se=be.replace(/\/+/g,"/");return Se.startsWith("./")&&(Se=Se.slice(2)),Se.length>1&&Se.endsWith("/")&&(Se=Se.slice(0,-1)),rc(Se,ye)}}return null}function et(U){if(!$.value)return{};const ye=Ae.value;return{"file-focused":ye.has(U),"file-muted":!ye.has(U)}}const pt=A(()=>{const U=$.value;return U?Bi(U):""});return Ke(()=>t.messageFocusToken,async()=>{await Ce()},{immediate:!0}),Ke(()=>t.inspectorTab,async U=>{U==="messages"&&await Ce()}),Ke(()=>{var U;return(U=n.value)==null?void 0:U.id},async U=>{U!=null&&await t.loadEntryDetail(U)},{immediate:!0}),Ke(()=>{var U;return(U=K.value)==null?void 0:U.id},async U=>{var j;U!=null&&U!==((j=n.value)==null?void 0:j.id)&&await t.loadEntryDetail(U)},{immediate:!0}),Mn(async()=>{t.inspectorTab==="messages"&&t.messageFocusCategory&&await Ce()}),Ke(B,()=>{if(!p.value||se.value)return;const U=q();if(U>=0&&U!==d.value){d.value=U;return}d.value>=B.value.length&&(d.value=Math.max(0,B.value.length-1),E(d.value))}),(U,j)=>{const ye=gn("tooltip");return n.value?(g(),b("div",{key:0,class:"messages-tab",onKeydown:a},[Re(Y(Yg),{class:"default-theme","push-other-panes":!1},{default:ft(()=>[Re(Y(nl),{"min-size":25,size:p.value?42:100},{default:ft(()=>[u("div",{ref_key:"msgListEl",ref:l,class:"msg-list"},[u("div",_y,[u("div",by,[u("button",{class:he({on:c.value==="chrono"}),onClick:j[0]||(j[0]=x=>c.value="chrono")},"Chronological",2),u("button",{class:he({on:c.value==="category"}),onClick:j[1]||(j[1]=x=>c.value="category")},"By Category",2)]),C.value&&c.value==="chrono"?(g(),b("div",wy,[u("button",{class:he({on:Y(t).messagesMode==="main"}),onClick:j[2]||(j[2]=x=>Y(t).messagesMode="main")},"Main",2),u("button",{class:he({on:Y(t).messagesMode==="all"}),onClick:j[3]||(j[3]=x=>Y(t).messagesMode="all")},"All",2)])):le("",!0)]),c.value==="category"?(g(),b(ve,{key:0},[P.value.length>0?(g(),b("div",ky,[j[4]||(j[4]=u("div",{class:"heavy-title"},"Top heavy messages",-1)),u("div",xy,[(g(!0),b(ve,null,Te(P.value,x=>(g(),b("button",{key:x.origIdx,class:"heavy-action",onClick:X=>pe(x.origIdx)},[u("span",Sy,M((Y(Ye)[x.category]||{label:x.category}).label),1),u("span",Cy,M(x.preview),1),u("span",Ty,M(Y(_e)(x.tokens)),1)],8,$y))),128))])])):le("",!0),ee.value||G.value?(g(),b("div",My,[ee.value?(g(),b("span",Ey,[j[5]||(j[5]=xe(" Filtered tool: ",-1)),u("b",null,M(ee.value),1)])):le("",!0),G.value?(g(),b("span",Py,[j[6]||(j[6]=xe(" Showing ",-1)),u("b",null,M((Y(Ye)[L.value||""]||{label:L.value}).label),1),j[7]||(j[7]=xe(" for ",-1)),u("b",null,M((Y(Ye)[ne.value||""]||{label:ne.value}).label),1),j[8]||(j[8]=xe(". ",-1))])):le("",!0),ee.value?(g(),b("button",{key:2,class:"focus-clear",onClick:dn(Ie,["stop"])},"Show all")):le("",!0)])):le("",!0),(g(!0),b(ve,null,Te(ce.value,(x,X)=>(g(),b("div",{key:x.category,class:"msg-group","data-category":x.category},[u("div",{class:"group-head",onClick:be=>Y(i)(x.category)},[u("i",{class:he(["group-arrow",Y(o)(x.category)||L.value===x.category?"i-carbon-chevron-down":"i-carbon-chevron-right"])},null,2),u("span",{class:"group-dot",style:Me({background:(Y(Ye)[x.category]||{color:"#4b5563"}).color})},null,4),u("span",Ly,M((Y(Ye)[x.category]||{label:x.category}).label),1),u("span",Oy,[xe(M(x.items.length)+" ",1),j[9]||(j[9]=u("span",{class:"group-sep"},"·",-1)),xe(" "+M(Y(_e)(x.tokens))+" ",1),j[10]||(j[10]=u("span",{class:"group-sep"},"·",-1)),xe(" "+M(T.value>0?Math.round(x.tokens/T.value*100):0)+"% ",1)]),u("div",Ry,[u("div",{class:"group-bar-fill",style:Me({width:(T.value>0?Math.round(x.tokens/T.value*100):0)+"%",background:(Y(Ye)[x.category]||{color:"#4b5563"}).color})},null,4)])],8,Ay),u("div",{class:he(["group-items",{open:Y(o)(x.category)||L.value===x.category}])},[(g(!0),b(ve,null,Te(x.items,(be,Se)=>{var tt;return g(),b("div",{key:be.origIdx,class:he(["msg-row",[$e(be.msg),{selected:p.value&&!se.value&&((tt=B.value[d.value])==null?void 0:tt.origIdx)===be.origIdx}]]),"data-tool-name":ge(be.msg)||"",onClick:Ht=>y(J(X,Se))},[u("span",Ny,M(be.msg.role==="user"?"›":be.msg.role==="assistant"?"‹":"·"),1),u("span",Fy,M(Y(Bo)(be.msg,_.value)||"(empty)"),1),u("span",{class:he(["msg-tok",{hot:(be.msg.tokens||0)>2e3}])},M(Y(_e)(be.msg.tokens||0)),3)],10,Dy)}),128))],2)],8,Iy))),128))],64)):c.value==="chrono"?(g(),b(ve,{key:1},[$.value?(g(),b("div",zy,[u("span",null,[j[11]||(j[11]=xe(" Filtered file: ",-1)),Be((g(),b("b",By,[xe(M(pt.value),1)])),[[ye,$.value]]),u("span",Hy,"("+M(Ae.value.size)+" messages)",1)]),u("button",{class:"focus-clear",onClick:dn(Ne,["stop"])},"Show all")])):le("",!0),u("div",jy,[(g(!0),b(ve,null,Te(ae.value,(x,X)=>{var be;return g(),b(ve,{key:X},[O.value.has(X)?(g(!0),b(ve,{key:0},Te(O.value.get(X),Se=>Be((g(),b("div",{key:"sub-"+Se.id,class:"chrono-subagent-row",onClick:tt=>ke(Se.id)},[u("span",Uy,M(Y(_e)(Se.contextInfo.totalTokens)),1),j[12]||(j[12]=u("span",{class:"chrono-cat-dot subagent-dot"},null,-1)),j[13]||(j[13]=u("span",{class:"chrono-type subagent-type"},"subagent",-1)),u("span",Ky,M(Se.agentLabel),1),u("span",Wy,M(Y(en)(Se.contextInfo.model)),1)],8,Vy)),[[ye,"Click to view subagent context"]])),128)):le("",!0),te.value.has(X)?(g(),b("div",{key:1,class:he(["chrono-turn-marker",{future:x.future}])},[u("span",qy,"Turn "+M(te.value.get(X)),1),j[14]||(j[14]=u("span",{class:"chrono-turn-line"},null,-1))],2)):le("",!0),x.future&&X===Q.value?(g(),b("div",Gy,[...j[15]||(j[15]=[u("span",{class:"chrono-future-line"},null,-1),u("span",{class:"chrono-future-label"},"After this turn",-1),u("span",{class:"chrono-future-line"},null,-1)])])):le("",!0),u("div",{class:he(["chrono-row",[et(x.origIdx),{selected:!x.future&&p.value&&!se.value&&((be=B.value[d.value])==null?void 0:be.origIdx)===x.origIdx,future:x.future}]]),style:Me({"--cat-border":fe(x.msg)}),onClick:Se=>x.future?Z(x.origIdx):y(x.origIdx)},[Be((g(),b("span",Yy,[xe(M(x.future?"":Y(_e)(H.value[X])),1)])),[[ye,x.future?"Click to jump to this turn":`Cumulative: ${Y(_e)(H.value[X])} of ${Y(_e)(T.value)}`]]),u("span",{class:"chrono-cat-dot",style:Me({background:fe(x.msg)})},null,4),u("span",Xy,M(ie(x.msg)),1),u("span",Zy,M(Y(Bo)(x.msg,_.value)||"(empty)"),1),u("span",{class:he(["chrono-tok",{hot:!x.future&&(x.msg.tokens||0)>2e3}])},M(Y(_e)(x.msg.tokens||0)),3)],14,Jy)],64)}),128))])],64)):le("",!0)],512)]),_:1},8,["size"]),p.value?(g(),dt(Y(nl),{key:0,"min-size":25,size:58},{default:ft(()=>[Re(yy,{entry:oe.value,messages:W.value,"selected-index":re.value,onClose:h,onNavigate:N},null,8,["entry","messages","selected-index"])]),_:1})):le("",!0)]),_:1})],32)):le("",!0)}}}),e0=at(Qy,[["__scopeId","data-v-c0d2a74a"]]),t0={key:0,class:"timeline-tab"},n0={class:"timeline-scope-controls"},s0={class:"scope-toggle"},o0=["onClick"],i0={class:"panel panel--hero"},r0={class:"panel-head"},l0={class:"panel-controls"},a0={class:"mode-toggle"},c0={class:"panel-body"},u0={class:"chart-container"},d0={class:"y-axis"},f0=["onClick"],p0=["viewBox"],h0=["points"],v0=["aria-label"],m0={class:"chart-legend"},g0=["onClick"],y0={key:0,class:"projection-badge"},_0={key:1,class:"projection-badge projection-badge--warn"},b0={class:"panel panel--secondary panel--spine panel--cost"},w0={class:"panel-head"},k0={class:"panel-sub"},x0={class:"panel-body"},$0={class:"chart-container"},S0={class:"y-axis"},C0=["onClick"],T0={class:"chart-legend"},M0=Qe({__name:"TimelineTab",setup(e){const t=At(),n=A({get:()=>t.timelineMode,set:y=>{t.timelineMode=y}}),s=A({get:()=>t.timelineStackMode,set:y=>{t.timelineStackMode=y}}),o=A({get:()=>t.timelineHiddenLegendKeys,set:y=>{t.timelineHiddenLegendKeys=y}}),i=A({get:()=>t.timelineShowLimitOverlay,set:y=>{t.timelineShowLimitOverlay=y}}),r=A({get:()=>t.timelineShowCacheOverlay,set:y=>{t.timelineShowCacheOverlay=y}}),l=me(null),c=me(null),p=A(()=>t.selectedSession),d=A(()=>t.selectedEntry),m=A(()=>p.value?Yt([...p.value.entries].reverse()):[]),v=A(()=>n.value==="main"?m.value.filter(y=>y.isMain):m.value),w=A(()=>{let y=0;for(const h of v.value){const a=h.entry.contextInfo.totalTokens;a>y&&(y=a)}return y}),I=A(()=>{let y=0;for(const h of v.value){const a=h.entry.costUsd??0;a>y&&(y=a)}return y}),S=A(()=>v.value.length<=40),_=A(()=>Uo(Q.value)),C=A(()=>Zh(v.value)),z=A(()=>Gh(v.value,m.value)),K=A(()=>v.value.map((y,h)=>{const a=z.value.get(y.entry.id)||[],f=a[0]||null,E=C.value[h]||h+1;return{entryId:y.entry.id,firstEvent:f,title:f?Yh(a,E):""}}));function V(y){const h=new Set(o.value);h.has(y)?h.delete(y):h.add(y),o.value=h}const Q=A(()=>{if(o.value.size===0)return w.value;let y=0;for(const h of v.value){const a=jo(h.entry,o.value);a>y&&(y=a)}return y});function D(y){const h=jo(y.entry,o.value);return Vo(h,Q.value)}function ae(y){return Kh(y.entry,o.value)}function ue(y){return Vo(y.entry.costUsd??0,I.value)}function O(y){t.pinEntry(y.id)}function R(y){t.setInspectorTab("messages"),t.focusMessageCategory(y)}const de=A(()=>Xh(v.value.length)),F=A(()=>{const y=d.value;if(y&&y.contextLimit>0)return y.contextLimit;const h=v.value;return h.length>0?h[h.length-1].entry.contextLimit:0}),te=A(()=>{const y=Q.value;return i.value?Math.max(y,F.value):y}),ce=A(()=>{const y=te.value,h=F.value;return y===0||h===0?-1:(1-h/y)*100});function B(y){if(s.value==="normalized")return 100;if(!i.value)return D(y);const h=jo(y.entry,o.value);return Vo(h,te.value)}const se=A(()=>Uo(te.value)),oe=A(()=>Uo(I.value)),W=[0,25,50,75,100],re=A(()=>{const y=d.value;return y?oc(y,m.value):null}),we=A(()=>{const y=new Map;for(const h of v.value){const a=en(h.entry.contextInfo.model);y.has(a)||y.set(a,Yr(h.entry.contextInfo.model,!0))}return Array.from(y.entries()).map(([h,a])=>({name:h,color:a}))}),H=A(()=>Object.entries(mt).map(([y,h])=>({key:y,name:h.label,color:h.color}))),T=A(()=>{const y=v.value;if(y.length===0)return-1;if(n.value!=="all")return y.length-1;for(let h=y.length-1;h>=0;h--)if(y[h].isMain)return h;return-1}),P=A(()=>{const y=v.value,h=T.value;if(h<0)return!1;for(let a=0;a<=h;a++)if(!(n.value==="all"&&!y[a].isMain)&&fi(y[a].entry)!==null)return!0;return!1}),ee=A(()=>{const y=Math.max(0,T.value+1);return y===0?"0 0 1 100":`0 0 ${y} 100`}),ne=A(()=>{const y=v.value.length,h=Math.max(0,T.value+1);return y===0||h===0?"0%":`${h/y*100}%`}),$=A(()=>{const y=v.value,h=T.value;if(y.length===0||h<0)return"";const a=[];for(let f=0;f<=h;f++){if(n.value==="all"&&!y[f].isMain)continue;const E=fi(y[f].entry);if(E===null)continue;const q=f+.5,N=(1-E)*100;a.push(`${q.toFixed(3)},${N.toFixed(2)}`)}return a.join(" ")}),L=A(()=>ic(m.value));function G(y){y&&(y.scrollLeft=y.scrollWidth)}function k(){Ue(()=>{G(l.value),G(c.value)})}return Mn(()=>{k()}),Ke(()=>{var y,h;return[((y=p.value)==null?void 0:y.id)??"",n.value,v.value.length,((h=v.value[v.value.length-1])==null?void 0:h.entry.id)??""]},()=>{k()},{immediate:!0}),(y,h)=>{const a=gn("tooltip");return p.value?(g(),b("div",t0,[u("div",n0,[h[4]||(h[4]=u("span",{class:"scope-label"},"Scope",-1)),u("div",s0,[(g(),b(ve,null,Te(["main","all"],f=>u("button",{key:"scope-"+f,class:he({on:n.value===f}),onClick:E=>n.value=f},M(f==="all"?"All turns":"Main turns"),11,o0)),64))])]),u("section",i0,[u("div",r0,[h[9]||(h[9]=u("span",{class:"panel-title"},"Token Timeline",-1)),u("div",l0,[P.value?(g(),b("button",{key:0,class:he(["overlay-toggle",{on:r.value}]),onClick:h[0]||(h[0]=f=>r.value=!r.value)},[...h[5]||(h[5]=[u("span",{class:"legend-dot legend-dot--cache"},null,-1),xe(" Cache ",-1)])],2)):le("",!0),s.value==="absolute"?(g(),b("button",{key:1,class:he(["overlay-toggle",{on:i.value}]),onClick:h[1]||(h[1]=f=>i.value=!i.value)},[...h[6]||(h[6]=[u("span",{class:"legend-dot legend-dot--dashed"},null,-1),xe(" Limit ",-1)])],2)):le("",!0),u("div",a0,[Be((g(),b("button",{class:he({on:s.value==="absolute"}),onClick:h[2]||(h[2]=f=>s.value="absolute")},[...h[7]||(h[7]=[u("i",{class:"i-carbon-chart-column mode-icon"},null,-1),xe(" Abs ",-1)])],2)),[[a,"Absolute token counts"]]),Be((g(),b("button",{class:he({on:s.value==="normalized"}),onClick:h[3]||(h[3]=f=>s.value="normalized")},[...h[8]||(h[8]=[u("i",{class:"i-carbon-chart-maximum mode-icon"},null,-1),xe(" Pct ",-1)])],2)),[[a,"Normalized to 100% per turn"]])])])]),u("div",c0,[u("div",u0,[u("div",d0,[s.value==="normalized"?(g(!0),b(ve,{key:0},Te([...W].reverse(),f=>(g(),b("span",{key:"norm-"+f},M(f)+"%",1))),128)):(g(!0),b(ve,{key:1},Te([...i.value?se.value:_.value].reverse(),f=>(g(),b("span",{key:f},M(Y(Xr)(f,"tokens")),1))),128))]),u("div",{ref_key:"tokenChartScrollEl",ref:l,class:"chart-scroll"},[u("div",{class:he(["bars-wrap",{sparse:S.value}])},[u("div",{class:he(["bars",{sparse:S.value}])},[(g(!0),b(ve,null,Te(v.value,(f,E)=>{var q;return g(),b("div",{key:f.entry.id,class:he(["bar",{active:((q=d.value)==null?void 0:q.id)===f.entry.id,normalized:s.value==="normalized"}]),style:Me({height:B(f)+"%"}),onClick:N=>O(f.entry)},[(g(!0),b(ve,null,Te(ae(f),N=>Be((g(),b("div",{key:f.entry.id+"-"+N.key,class:"bar-segment",style:Me({height:N.pct+"%",background:N.color})},null,4)),[[a,Y(ev)(f.entry,N)]])),128))],14,f0)}),128))],2),s.value==="absolute"&&i.value&&ce.value>=0?(g(),b("div",{key:0,class:"limit-line",style:Me({top:ce.value+"%"})},null,4)):le("",!0),r.value&&$.value?(g(),b("svg",{key:1,class:"cache-line-svg",viewBox:ee.value,style:Me({width:ne.value}),preserveAspectRatio:"none"},[u("polyline",{points:$.value,fill:"none",stroke:"var(--accent-cyan)","stroke-width":"1.5","vector-effect":"non-scaling-stroke","stroke-linejoin":"round","stroke-linecap":"round",opacity:"0.7"},null,8,h0)],12,p0)):le("",!0)],2),u("div",{class:he(["events",{sparse:S.value}])},[(g(!0),b(ve,null,Te(K.value,f=>(g(),b("div",{key:"evt-"+f.entryId,class:"event-slot"},[f.firstEvent?Be((g(),b("button",{key:0,class:he(["event-marker",`event-marker--${f.firstEvent.type}`]),type:"button","aria-label":f.title},[xe(M(Y(Jh)(f.firstEvent.type)),1)],10,v0)),[[a,f.title]]):le("",!0)]))),128))],2),u("div",{class:he(["labels",{sparse:S.value}])},[(g(!0),b(ve,null,Te(C.value,(f,E)=>(g(),b("div",{key:E,class:"label"},M(f&&(de.value<=1||f%de.value===0)?f:""),1))),128))],2)],512)]),u("div",m0,[(g(!0),b(ve,null,Te(H.value,f=>(g(),b("button",{key:f.key,class:he(["legend-item legend-item--interactive",{"legend-item--hidden":o.value.has(f.key)}]),onClick:E=>V(f.key)},[u("span",{class:"legend-dot",style:Me({background:o.value.has(f.key)?"var(--text-ghost)":f.color})},null,4),xe(" "+M(f.name),1)],10,g0))),128)),L.value.turnsRemaining!==null&&L.value.turnsRemaining>0?Be((g(),b("span",y0,[xe(" ~"+M(L.value.turnsRemaining)+" turns remaining ",1)])),[[a,`Growing ~${Y(_e)(Math.round(L.value.growthPerTurn))}/turn over ${L.value.sinceCompaction} turns since last compaction`]]):L.value.turnsRemaining===0?Be((g(),b("span",_0,[...h[10]||(h[10]=[xe(" At limit ",-1)])])),[[a,"Context window is at or near the limit"]]):le("",!0)])])]),u("section",b0,[u("div",w0,[h[11]||(h[11]=u("span",{class:"panel-title"},"Cost Timeline",-1)),u("span",k0,"Scope: "+M(n.value==="main"?"Main turns only":"All turns"),1)]),u("div",x0,[u("div",$0,[u("div",S0,[(g(!0),b(ve,null,Te([...oe.value].reverse(),f=>(g(),b("span",{key:"cost-"+f},M(Y(Xr)(f,"cost")),1))),128))]),u("div",{ref_key:"costChartScrollEl",ref:c,class:"chart-scroll"},[u("div",{class:he(["bars-wrap",{sparse:S.value}])},[u("div",{class:he(["bars",{sparse:S.value}])},[(g(!0),b(ve,null,Te(v.value,f=>{var E;return Be((g(),b("div",{key:"cost-"+f.entry.id,class:he(["bar",{active:((E=d.value)==null?void 0:E.id)===f.entry.id}]),style:Me({height:ue(f)+"%"}),onClick:q=>O(f.entry)},[u("div",{class:"bar-cost",style:Me({background:Y(Yr)(f.entry.contextInfo.model,f.isMain)})},null,4)],14,C0)),[[a,Y(Qh)(f.entry,f.isMain)]])}),128))],2)],2),u("div",{class:he(["labels",{sparse:S.value}])},[(g(!0),b(ve,null,Te(C.value,(f,E)=>(g(),b("div",{key:"cost-label-"+E,class:"label"},M(f&&(de.value<=1||f%de.value===0)?f:""),1))),128))],2)],512)]),u("div",T0,[(g(!0),b(ve,null,Te(we.value,f=>(g(),b("span",{key:f.name,class:"legend-item"},[u("span",{class:"legend-dot",style:Me({background:f.color})},null,4),xe(" "+M(f.name),1)]))),128))])])]),Re(ac,{"diff-data":re.value,"show-when-empty":!!d.value,onCategoryClick:R},null,8,["diff-data","show-when-empty"])])):le("",!0)}}}),E0=at(M0,[["__scopeId","data-v-8510f6fe"]]),P0=["aria-label","aria-valuemax","aria-valuenow"],I0={class:"scrubber-controls"},A0=["disabled"],L0={class:"readout-num"},O0={class:"readout-total"},R0=["disabled"],D0={class:"spark-bars"},N0={class:"tt-row tt-turn"},F0={class:"tt-row"},z0={class:"tt-row tt-dim"},B0=Qe({__name:"TurnScrubber",setup(e){const t=At(),n=me(null),s=me(!1),o=me(null),i=A(()=>t.selectedSession),r=A(()=>t.selectedEntry),l=A(()=>i.value?Yt([...i.value.entries].reverse()):[]),c=A(()=>l.value.filter(W=>W.isMain)),p=A(()=>c.value.map(W=>W.entry)),d=A(()=>c.value.map(W=>!W.isMain)),m=A(()=>p.value.length),v=A(()=>{const W=r.value;if(!W)return-1;let re=-1;for(const we of l.value)if(we.isMain&&re++,we.entry.id===W.id)return re;return-1}),w=A(()=>{let W=0;for(const re of p.value)re.contextInfo.totalTokens>W&&(W=re.contextInfo.totalTokens);return W}),I=A(()=>{const W=w.value;return W===0?p.value.map(()=>({height:.15,tokens:0,cost:0,model:"",utilization:0})):p.value.map(re=>({height:Math.max(.08,re.contextInfo.totalTokens/W),tokens:re.contextInfo.totalTokens,cost:re.costUsd??0,model:en(re.contextInfo.model),utilization:re.contextLimit>0?re.contextInfo.totalTokens/re.contextLimit:0}))}),S=A(()=>t.selectionMode!=="pinned"||v.value<0?!1:v.value<m.value-1),_=A(()=>S.value?Math.max(0,m.value-1-v.value):0),C=A(()=>S.value?_.value/m.value>=.12:!1),z=A(()=>((v.value+1)/m.value+1)/2*100),K=A(()=>{const W=[];let re=0,we=-1;for(const H of l.value)H.isMain?(we>=0&&W.push(re),re=0,we++):re++;return we>=0&&W.push(re),W}),V=A(()=>{if(o.value===null||o.value<0||o.value>=p.value.length)return null;const W=p.value[o.value],re=I.value[o.value],we=K.value[o.value]||0;return{turn:o.value+1,tokens:_e(W.contextInfo.totalTokens),cost:_t(W.costUsd),model:re.model,subs:we,isSub:d.value[o.value]||!1}});function Q(W){de(W)&&t.pinEntry(p.value[W].id)}function D(){t.followLive()}function ae(){const W=v.value-1;de(W)&&Q(W)}function ue(){const W=v.value+1;de(W)&&Q(W)}function O(){r.value&&t.pinEntry(r.value.id)}function R(W){const re=n.value;if(!re||m.value===0)return-1;const we=re.getBoundingClientRect(),T=Math.max(0,Math.min(W.clientX-we.left,we.width))/we.width;return Math.min(Math.floor(T*m.value),m.value-1)}function de(W){return W>=0&&W<m.value}function F(W){var we,H;if(m.value===0)return;s.value=!0;const re=R(W);de(re)&&Q(re),(H=(we=W.target)==null?void 0:we.setPointerCapture)==null||H.call(we,W.pointerId)}function te(W){const re=R(W);o.value=de(re)?re:null,s.value&&de(re)&&Q(re)}function ce(W){var re,we;s.value=!1,(we=(re=W.target)==null?void 0:re.releasePointerCapture)==null||we.call(re,W.pointerId)}function B(){o.value=null}function se(W){W.key==="ArrowLeft"||W.key==="ArrowUp"?(W.preventDefault(),ae()):W.key==="ArrowRight"||W.key==="ArrowDown"?(W.preventDefault(),ue()):W.key==="Home"?(W.preventDefault(),Q(0)):W.key==="End"?(W.preventDefault(),m.value>0&&Q(m.value-1)):W.key==="Escape"&&(W.preventDefault(),D())}function oe(W){return W>=.9?"var(--accent-red)":W>=.7?"var(--accent-amber)":"var(--accent-blue)"}return(W,re)=>i.value&&r.value&&m.value>=1?(g(),b("div",{key:0,class:"scrubber",role:"slider","aria-label":`Turn scrubber: turn ${v.value+1} of ${m.value}`,"aria-valuemin":1,"aria-valuemax":m.value,"aria-valuenow":v.value+1,tabindex:"0",onKeydown:se},[u("div",I0,[u("button",{class:"ctrl-btn",disabled:v.value<=0,onClick:ae,title:"Previous turn (←)","aria-label":"Previous turn"},[...re[0]||(re[0]=[u("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none"},[u("path",{d:"M7 1L3 5L7 9",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],8,A0),u("span",{class:he(["turn-readout",Y(t).selectionMode==="live"?"is-live":"is-pinned"])},[re[1]||(re[1]=u("span",{class:"readout-dot"},null,-1)),u("span",L0,M(v.value+1),1),re[2]||(re[2]=u("span",{class:"readout-sep"},"/",-1)),u("span",O0,M(m.value),1)],2),u("button",{class:"ctrl-btn",disabled:v.value<0||v.value>=m.value-1,onClick:ue,title:"Next turn (→)","aria-label":"Next turn"},[...re[3]||(re[3]=[u("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none"},[u("path",{d:"M3 1L7 5L3 9",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],8,R0)]),u("div",{ref_key:"trackEl",ref:n,class:"scrubber-track",onPointerdown:F,onPointermove:te,onPointerup:ce,onPointerleave:B},[u("div",D0,[(g(!0),b(ve,null,Te(I.value,(we,H)=>(g(),b("div",{key:H,class:he(["spark-col",{active:H===v.value,hover:H===o.value&&H!==v.value,past:Y(t).selectionMode==="pinned"&&H>v.value,"is-sub":d.value[H]}])},[u("div",{class:"spark-bar",style:Me({height:we.height*100+"%","--bar-color":oe(we.utilization)})},null,4),K.value[H]>0?(g(),b("div",{key:0,class:he(["sub-dot",{"sub-burst":K.value[H]>=3}])},null,2)):le("",!0)],2))),128))]),v.value>=0?(g(),b("div",{key:0,class:he(["playhead",{live:Y(t).selectionMode==="live"}]),style:Me({left:(v.value+.5)/m.value*100+"%"})},[...re[4]||(re[4]=[u("div",{class:"playhead-line"},null,-1),u("div",{class:"playhead-head"},null,-1)])],6)):le("",!0),C.value?(g(),b("div",{key:1,class:"new-turns-badge",style:Me({left:z.value+"%"}),onClick:dn(D,["stop"])}," +"+M(_.value)+" new ",5)):le("",!0),Re(zn,{name:"tooltip-fade"},{default:ft(()=>[V.value&&o.value!==v.value?(g(),b("div",{key:0,class:"scrub-tooltip",style:Me({left:Math.min(Math.max((o.value+.5)/m.value*100,8),92)+"%"})},[u("div",N0,"T"+M(V.value.turn)+M(V.value.isSub?" (sub)":""),1),u("div",F0,M(V.value.tokens)+" · "+M(V.value.cost),1),u("div",z0,M(V.value.model)+M(V.value.subs>0?` · ${V.value.subs} sub`:""),1)],4)):le("",!0)]),_:1})],544),Y(t).selectionMode==="live"?(g(),b("button",{key:0,class:"action-btn action-pin",onClick:O,title:"Pin current turn to scrub history"},[...re[5]||(re[5]=[u("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none"},[u("circle",{cx:"5",cy:"5",r:"3.5",stroke:"currentColor","stroke-width":"1"}),u("circle",{cx:"5",cy:"5",r:"1.5",fill:"currentColor"})],-1),xe(" Pin ",-1)])])):(g(),b("button",{key:1,class:"action-btn action-return",onClick:D,title:"Return to live (Esc)"},[...re[6]||(re[6]=[u("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none"},[u("path",{d:"M2 5H8M8 5L5.5 2.5M8 5L5.5 7.5",stroke:"currentColor","stroke-width":"1.2","stroke-linecap":"round","stroke-linejoin":"round"})],-1),xe(" Live ",-1)])]))],40,P0)):le("",!0)}}),H0=at(B0,[["__scopeId","data-v-865993b3"]]),j0={class:"tab-bar"},V0=["onClick"],U0={class:"tab-content"},K0=Qe({__name:"InspectorPanel",setup(e){const t=At(),n=[{id:"overview",label:"Overview",icon:"i-carbon-dashboard"},{id:"messages",label:"Messages",icon:"i-carbon-chat"},{id:"timeline",label:"Timeline",icon:"i-carbon-activity"}],s={overview:Jg,messages:e0,timeline:E0},o=A(()=>s[t.inspectorTab]);function i(l){l==="messages"&&t.clearMessageFocus(),t.setInspectorTab(l)}function r(l){l.key==="Escape"&&!l.defaultPrevented&&t.setView("dashboard")}return(l,c)=>(g(),b("div",{class:"inspector",onKeydown:r,tabindex:"-1"},[Re(H0),u("div",j0,[(g(),b(ve,null,Te(n,p=>u("button",{key:p.id,class:he(["tab-btn",{active:Y(t).inspectorTab===p.id}]),onClick:d=>i(p.id)},[u("i",{class:he(p.icon)},null,2),xe(" "+M(p.label),1)],10,V0)),64))]),u("div",U0,[(g(),dt(Yl(o.value),{key:Y(t).inspectorTab}))])],32))}}),W0=at(K0,[["__scopeId","data-v-74dad8d1"]]),q0={class:"session-rail","aria-label":"Sessions"},G0={class:"rail-scroll"},J0=["onClick"],Y0={class:"tile-meta"},X0=Qe({__name:"SessionRail",setup(e){const t=At();function n(c){t.selectSession(c),t.setView("inspector")}function s(){t.setView("dashboard")}function o(c){const p=en(c.latestModel),d=c.entryCount+(c.entryCount===1?" turn":" turns"),m=_t(c.totalCost),v=c.healthScore?`
31
31
  Health ${c.healthScore.overall}/100 (${c.healthScore.rating})`:"",w=c.workingDirectory?`
32
32
  ${c.workingDirectory}`:"";return`${c.source} · ${p}
33
33
  ${d} · ${m}${v}${w}`}function i(c){return c.contextLimit?Math.min(100,Math.round(c.latestTotalTokens/c.contextLimit*100)):0}function r(c){const p=i(c);return p>=80?"high":p>=60?"mid":"low"}const l={delay:{show:50,hide:0},placement:"right"};return(c,p)=>{const d=gn("tooltip");return g(),b("nav",q0,[Be((g(),b("button",{class:"rail-back",onClick:s},[...p[0]||(p[0]=[u("i",{class:"i-carbon-grid grid-icon"},null,-1)])])),[[d,{content:"Dashboard",...l}]]),p[1]||(p[1]=u("span",{class:"rail-label"},"SESSIONS",-1)),u("div",G0,[(g(!0),b(ve,null,Te(Y(t).summaries,m=>Be((g(),b("button",{key:m.id,class:he(["rail-tile",{active:m.id===Y(t).selectedSessionId,pulse:Y(t).recentlyUpdated.has(m.id)}]),onClick:v=>n(m.id)},[u("span",{class:he(["tile-source",Y($s)(m.source)])},M(m.source||"?"),3),u("span",Y0,M(m.entryCount)+"t",1),u("span",{class:he(["tile-util",r(m)])},M(i(m))+"%",3)],10,J0)),[[d,{content:o(m),...l}]])),128))])])}}}),Z0=at(X0,[["__scopeId","data-v-fe0c47d1"]]),Q0={class:"compare-view"},e_={class:"compare-header"},t_={class:"compare-title"},n_={class:"compare-count"},s_={class:"legend"},o_={class:"lanes"},i_=["onMouseenter"],r_={class:"lane-header"},l_={class:"lane-identity"},a_={class:"lane-index"},c_={class:"lane-model"},u_={key:0,class:"lane-dir"},d_={class:"lane-metrics"},f_={class:"lm-cell"},p_={class:"lm-value"},h_={key:0,class:"lm-winner"},v_={class:"lm-cell"},m_={class:"lm-value green"},g_={key:0,class:"lm-winner"},y_={class:"lm-cell"},__={key:0,class:"lm-winner"},b_={class:"lm-cell"},w_={key:1,class:"lm-value ghost"},k_={key:0,class:"lm-cell"},x_={class:"lm-value dim"},$_={key:1,class:"lm-cell"},S_={class:"lm-value dim"},C_={key:0,class:"lm-winner"},T_={class:"lm-cell"},M_={class:"lm-value dim"},E_=["href","onClick"],P_={class:"lane-body"},I_={class:"turn-track"},A_=["title","href","onMouseenter","onClick"],L_={class:"turn-num"},O_={key:0,class:"turns-empty"},R_={key:0,class:"sparkline-col"},D_={class:"sparkline-cell"},N_={class:"sparkline",viewBox:"0 0 100 100",preserveAspectRatio:"none"},F_=["y1","y2"],z_=["d"],B_=["d"],H_={class:"sparkline-val"},j_={class:"sparkline-cell"},V_={class:"sparkline sparkline--cost",viewBox:"0 0 100 100",preserveAspectRatio:"none"},U_=["d"],K_=["d"],W_={class:"sparkline-val"},q_={key:0,class:"comp-row"},G_={class:"comp-tape"},J_=["title"],Y_={key:0,class:"comp-seg-label"},X_={class:"comp-total"},rl="#ef4444",ll="#9ca3af",Z_=Qe({__name:"CompareView",setup(e){const t=At(),n=me(null),s=me(null),o=me(null),i=A(()=>{const H=Object.entries(mt).map(([T,P])=>({key:T,label:P.label,color:P.color}));return H.push({key:"error",label:"Error",color:rl}),H.push({key:"stall",label:"Stall",color:ll}),H});function r(H){const T={};for(const[P,ee]of Object.entries(Hn)){T[P]=0;for(const ne of ee){const $=H.find(L=>L.category===ne);$&&(T[P]+=$.tokens)}}return T}function l(H){const T=r(H);let P="other",ee=0;for(const[ne,$]of Object.entries(T))$>ee&&(P=ne,ee=$);return P}function c(H){const T=r(H),P=Object.values(T).reduce((ee,ne)=>ee+ne,0);return P===0?[]:Object.entries(T).filter(([,ee])=>ee>0).sort((ee,ne)=>ne[1]-ee[1]).map(([ee,ne])=>{var $;return{key:ee,color:(($=mt[ee])==null?void 0:$.color)??"#475569",pct:ne/P*100}})}function p(H){const T=new Map;for(const ne of H){const $=ne.agentKey||"_default";T.set($,(T.get($)||0)+1)}let P="_default",ee=0;for(const[ne,$]of T)$>ee&&(P=ne,ee=$);return P}function d(H){const T=p(H.entries);return H.entries.filter(ee=>(ee.agentKey||"_default")===T).sort((ee,ne)=>new Date(ee.timestamp).getTime()-new Date(ne.timestamp).getTime()).map((ee,ne)=>{var y;const $=(ee.httpStatus??200)>=400,L=ee.stopReason==="max_tokens",G=l(ee.composition);let k;return $?k=rl:L?k=ll:k=((y=mt[G])==null?void 0:y.color)??mt.other.color,{turnNumber:ne+1,entry:ee,dominantGroup:G,color:k,isError:$,isStall:L,tokens:ee.contextInfo.totalTokens,costUsd:ee.costUsd??0,segments:c(ee.composition)}})}function m(H){if(!H)return"";let T=H;/^\/home\/[^/]+(\/|$)/.test(T)?T=T.replace(/^\/home\/[^/]+/,"~"):/^\/Users\/[^/]+(\/|$)/.test(T)&&(T=T.replace(/^\/Users\/[^/]+/,"~"));const P=T.split("/");return P.length>2?P.slice(-2).join("/"):T}function v(H){for(let T=H.length-1;T>=0;T--){const P=fi(H[T].entry);if(P!==null)return P}return null}const w=A(()=>{const H=[];for(const T of t.compareSessionIds){const P=t.loadedConversations.get(T),ee=t.summaries.find(Z=>Z.id===T);if(!P&&!ee)continue;const ne=P?d(P):[],$=P?P.entries.reduce((Z,ke)=>Z+(ke.costUsd??0),0):(ee==null?void 0:ee.totalCost)??0,L=P?P.entries.reduce((Z,ke)=>{var ge;return Z+(((ge=ke.timings)==null?void 0:ge.total_ms)??0)},0):0,G=ne.length>0?ne[ne.length-1].entry:null,k=ne.map(Z=>Z.tokens),y=ne.map(Z=>Z.costUsd),h=P?(G==null?void 0:G.healthScore)??(ee==null?void 0:ee.healthScore):ee==null?void 0:ee.healthScore,a=(G==null?void 0:G.contextInfo.totalTokens)??(ee==null?void 0:ee.latestTotalTokens)??0,f=(G==null?void 0:G.contextLimit)??(ee==null?void 0:ee.contextLimit)??2e5,E=(ee==null?void 0:ee.latestModel)??(G==null?void 0:G.contextInfo.model)??"",q=(ee==null?void 0:ee.source)??(P==null?void 0:P.source)??"",N=(ee==null?void 0:ee.workingDirectory)??(P==null?void 0:P.workingDirectory)??null,J=P?P.entries.reduce((Z,ke)=>{var ge;return Z+(((ge=ke.usage)==null?void 0:ge.outputTokens)??0)},0):0,pe=G?c(G.composition):[],fe=v(ne),ie=J>0&&$>0?$/J*1e3:null;H.push({id:T,source:q,model:E,directory:m(N),turnCount:ne.length,totalCost:$,totalDurationMs:L,finalTokens:a,contextLimit:f,healthRating:(h==null?void 0:h.rating)??"unknown",healthScore:(h==null?void 0:h.overall)??0,turns:ne,tokenHistory:k,costHistory:y,utilization:f>0?a/f:0,outputTokens:J,cacheRate:fe,costPerOutputK:ie,finalComposition:pe})}return H}),I=A(()=>{let H=0;for(const T of w.value)for(const P of T.turns)P.tokens>H&&(H=P.tokens);return H||1}),S=A(()=>{let H=0;for(const T of w.value)for(const P of T.turns)P.costUsd>H&&(H=P.costUsd);return H||.01}),_=A(()=>{let H=0;for(const T of w.value){H=Math.max(H,T.contextLimit);for(const P of T.tokenHistory)P>H&&(H=P)}return H||1});function C(H){const ne=8+H/I.value*24;return Math.round(ne)+"px"}function z(H){return H<=0?0:.15+H/S.value*.85}function K(H,T){if(H.length===0)return"";const P=100,ee=100,ne=H.length>1?P/(H.length-1):0;return H.map(($,L)=>{const G=H.length===1?P/2:L*ne,k=ee-$/T*ee;return`${L===0?"M":"L"}${G.toFixed(1)},${k.toFixed(1)}`}).join(" ")}function V(H,T){if(H.length===0)return"";const P=100,ee=100,ne=H.length>1?P/(H.length-1):0,$=H.map((k,y)=>{const h=H.length===1?P/2:y*ne,a=ee-k/T*ee;return`${y===0?"M":"L"}${h.toFixed(1)},${a.toFixed(1)}`}).join(" "),L=H.length===1?P/2:(H.length-1)*ne,G=H.length===1?P/2:0;return`${$} L${L.toFixed(1)},${ee} L${G.toFixed(1)},${ee} Z`}function Q(H){const T=_.value;return 100-H/T*100}const D=A(()=>{let H=0;for(const T of w.value)for(const P of T.costHistory)P>H&&(H=P);return H||.01});function ae(H,T){return n.value===null||T===n.value?1:H===s.value?.3:.4}function ue(H){var P;const T=[`Turn ${H.turnNumber}`,`Model: ${en(H.entry.contextInfo.model)}`,`Context: ${_e(H.entry.contextInfo.totalTokens)}`,`Cost: ${_t(H.entry.costUsd)}`,`Dominant: ${((P=mt[H.dominantGroup])==null?void 0:P.label)??H.dominantGroup}`];return H.entry.timings&&T.push(`Duration: ${ci(H.entry.timings.total_ms)}`),H.entry.stopReason&&T.push(`Stop: ${H.entry.stopReason}`),H.isError&&T.push(`HTTP ${H.entry.httpStatus}`),T.join(`
34
- `)}function O(H,T){return`#session/${encodeURIComponent(H)}?tab=overview&turn=${T}`}function R(H){return`#session/${encodeURIComponent(H)}?tab=overview`}function de(H,T){n.value=T,s.value=H}function F(){n.value=null,s.value=null}function te(H,T,P){H.ctrlKey||H.metaKey||H.button===1||(H.preventDefault(),t.exitCompare("inspector"),t.selectSession(T),t.pinEntry(P.entry.id))}function ce(H,T){H.ctrlKey||H.metaKey||H.button===1||(H.preventDefault(),t.exitCompare("inspector"),t.setInspectorTab("overview"),t.selectSession(T))}function B(){t.exitCompare("dashboard")}function se(H){return H>=.8?"util-high":H>=.6?"util-mid":"util-low"}function oe(H){o.value=H}function W(){o.value=null}function re(H){return H>=.01?"$"+H.toFixed(2)+"/K":"$"+H.toFixed(3)+"/K"}const we=A(()=>{const H=w.value;if(H.length<2)return null;const T=H.map(h=>h.totalCost),P=H.map(h=>h.finalTokens),ee=H.map(h=>h.turnCount),ne=H.map(h=>h.costPerOutputK),$=Math.min(...T),L=Math.min(...P),G=Math.min(...ee),k=ne.filter(h=>h!==null),y=k.length>0?Math.min(...k):null;return H.map(h=>({isCheapest:h.totalCost<=$,isLeanest:h.finalTokens<=L,isFewest:h.turnCount<=G,isMostEfficient:y!==null&&h.costPerOutputK!==null&&h.costPerOutputK<=y}))});return(H,T)=>(g(),b("div",Q0,[u("header",e_,[u("button",{class:"back-btn",onClick:B},[...T[0]||(T[0]=[u("i",{class:"i-carbon-arrow-left"},null,-1),xe(" Dashboard ",-1)])]),u("h1",t_,[T[1]||(T[1]=xe(" Compare ",-1)),u("span",n_,M(w.value.length)+" sessions",1)]),u("div",s_,[(g(!0),b(ve,null,Te(i.value,P=>(g(),b("span",{key:P.key,class:"legend-chip"},[u("span",{class:"legend-swatch",style:Me({background:P.color})},null,4),xe(" "+M(P.label),1)]))),128))])]),u("div",o_,[(g(!0),b(ve,null,Te(w.value,(P,ee)=>(g(),b("div",{key:P.id,class:he(["lane",{"lane--focused":o.value===P.id,"lane--dimmed":o.value!==null&&o.value!==P.id}]),onMouseenter:ne=>oe(P.id),onMouseleave:W},[u("div",r_,[u("div",l_,[u("div",a_,M(ee+1),1),u("span",{class:he(["source-badge",Y($s)(P.source)])},M(P.source||"?"),3),u("span",c_,M(Y(en)(P.model)),1),P.directory?(g(),b("span",u_,M(P.directory),1)):le("",!0)]),u("div",d_,[u("div",f_,[u("span",p_,M(P.turnCount),1),T[2]||(T[2]=u("span",{class:"lm-key"},"turns",-1)),we.value&&we.value[ee].isFewest?(g(),b("span",h_)):le("",!0)]),u("div",v_,[u("span",m_,M(Y(_t)(P.totalCost)),1),T[3]||(T[3]=u("span",{class:"lm-key"},"cost",-1)),we.value&&we.value[ee].isCheapest?(g(),b("span",g_)):le("",!0)]),u("div",y_,[u("span",{class:he(["lm-value",se(P.utilization)])},M(Math.round(P.utilization*100))+"% ",3),T[4]||(T[4]=u("span",{class:"lm-key"},"context",-1)),we.value&&we.value[ee].isLeanest?(g(),b("span",__)):le("",!0)]),u("div",b_,[P.healthRating!=="unknown"?(g(),b("span",{key:0,class:"lm-value lm-health",style:Me({color:Y(di)(P.healthRating)})},M(P.healthScore),5)):(g(),b("span",w_,"--")),T[5]||(T[5]=u("span",{class:"lm-key"},"health",-1))]),P.cacheRate!==null?(g(),b("div",k_,[u("span",x_,M(Y(ui)(P.cacheRate)),1),T[6]||(T[6]=u("span",{class:"lm-key"},"cache",-1))])):le("",!0),P.costPerOutputK!==null?(g(),b("div",$_,[u("span",S_,M(re(P.costPerOutputK)),1),T[7]||(T[7]=u("span",{class:"lm-key"},"$/out",-1)),we.value&&we.value[ee].isMostEfficient?(g(),b("span",C_)):le("",!0)])):le("",!0),u("div",T_,[u("span",M_,M(P.totalDurationMs>0?Y(ci)(P.totalDurationMs):"--"),1),T[8]||(T[8]=u("span",{class:"lm-key"},"duration",-1))])]),u("a",{class:"inspect-btn",title:"Open in inspector",href:R(P.id),onClick:ne=>ce(ne,P.id)},[...T[9]||(T[9]=[u("i",{class:"i-carbon-arrow-right"},null,-1)])],8,E_)]),u("div",P_,[u("div",I_,[(g(!0),b(ve,null,Te(P.turns,ne=>(g(),b("a",{key:ne.turnNumber,class:he(["turn-col",{"turn-col--error":ne.isError,"turn-col--stall":ne.isStall,"turn-col--crosslit":n.value===ne.turnNumber&&s.value!==P.id}]),style:Me({opacity:ae(P.id,ne.turnNumber)}),title:ue(ne),href:O(P.id,ne.turnNumber),onMouseenter:$=>de(P.id,ne.turnNumber),onMouseleave:F,onClick:$=>te($,P.id,ne)},[u("div",{class:"turn-bar",style:Me({height:C(ne.tokens)})},[(g(!0),b(ve,null,Te(ne.segments,$=>(g(),b("div",{key:$.key,class:"turn-seg",style:Me({flex:$.pct,background:$.color})},null,4))),128))],4),u("div",{class:"cost-dot",style:Me({opacity:z(ne.costUsd)})},null,4),u("span",L_,M(ne.turnNumber),1)],46,A_))),128)),P.turns.length===0?(g(),b("div",O_," Loading... ")):le("",!0)]),P.tokenHistory.length>1?(g(),b("div",R_,[u("div",D_,[(g(),b("svg",N_,[u("line",{x1:"0",y1:Q(P.contextLimit),x2:"100",y2:Q(P.contextLimit),class:"sparkline-limit"},null,8,F_),u("path",{d:V(P.tokenHistory,_.value),class:"sparkline-area"},null,8,z_),u("path",{d:K(P.tokenHistory,_.value),class:"sparkline-line"},null,8,B_)])),u("span",H_,[xe(M(Y(_e)(P.finalTokens)),1),T[10]||(T[10]=u("span",{class:"sparkline-sep"},"/",-1)),xe(M(Y(_e)(P.contextLimit)),1)])]),u("div",j_,[(g(),b("svg",V_,[u("path",{d:V(P.costHistory,D.value),class:"sparkline-area sparkline-area--cost"},null,8,U_),u("path",{d:K(P.costHistory,D.value),class:"sparkline-line sparkline-line--cost"},null,8,K_)])),u("span",W_,M(Y(_t)(P.totalCost))+" total",1)])])):le("",!0)]),P.finalComposition.length>0?(g(),b("div",q_,[u("div",G_,[(g(!0),b(ve,null,Te(P.finalComposition,ne=>{var $,L;return g(),b("div",{key:ne.key,class:"comp-seg",style:Me({flex:ne.pct,background:ne.color}),title:`${(($=Y(mt)[ne.key])==null?void 0:$.label)??ne.key}: ${Math.round(ne.pct)}%`},[ne.pct>=18?(g(),b("span",Y_,M(((L=Y(mt)[ne.key])==null?void 0:L.label)??ne.key),1)):le("",!0)],12,J_)}),128))]),u("span",X_,M(Y(_e)(P.finalTokens)),1)])):le("",!0)],42,i_))),128))])]))}}),Q_=at(Z_,[["__scopeId","data-v-f1fe8711"]]),eb={},tb={class:"empty"};function nb(e,t){return g(),b("div",tb,[...t[0]||(t[0]=[ya('<svg class="empty-icon" width="48" height="48" viewBox="0 0 48 48" aria-hidden="true" data-v-a14192db><circle cx="24" cy="24" r="20" fill="none" stroke="var(--border-mid)" stroke-width="1" data-v-a14192db></circle><circle cx="24" cy="24" r="10" fill="none" stroke="var(--border-bright)" stroke-width="0.8" data-v-a14192db></circle><circle cx="24" cy="24" r="3" fill="var(--accent-blue)" opacity="0.4" data-v-a14192db></circle></svg><div class="empty-title" data-v-a14192db>No requests captured</div><div class="empty-sub" data-v-a14192db> Point API calls to <code data-v-a14192db>localhost:4040</code></div>',3)])])}const sb=at(eb,[["render",nb],["__scopeId","data-v-a14192db"]]),ob={class:"app"},ib={class:"app-body"},rb={key:0,class:"app-loading"},lb={class:"main-content"},ab={key:"inspector",class:"inspector-content"},cb={key:1,class:"loading-placeholder"},al="#sessions",ub=Qe({__name:"App",setup(e){const t=At(),n=me(!1),s=me(!1),o=["overview","messages","timeline"];let i=null;const r=me(null),l=A(()=>{const _=t.view,C=r.value;return C===null?"view-instant":C==="dashboard"&&_==="inspector"?"view-slide-forward":C==="inspector"&&_==="dashboard"?"view-slide-back":"view-instant"});Ke(()=>t.view,(_,C)=>{r.value!==null?r.value=C:r.value=_});const{connected:c}=pp("/api/events",_=>{t.handleSSEEvent(_)});Ke(c,_=>{t.connected=_});function p(_){const C=_.match(/^#session\/([^?]+)(?:\?(.*))?$/);if(!C)return{sessionId:null,tab:null,turn:null};const K=decodeURIComponent(C[1]).trim()||null;if(!K)return{sessionId:null,tab:null,turn:null};const V=new URLSearchParams(C[2]??""),Q=V.get("tab"),D=Q&&o.includes(Q)?Q:null,ae=V.get("turn"),ue=ae?Number.parseInt(ae,10):NaN,O=Number.isFinite(ue)&&ue>0?ue:null;return{sessionId:K,tab:D,turn:O}}function d(_){return Yt([..._.entries].reverse()).filter(C=>C.isMain).map(C=>C.entry)}function m(){if(t.selectionMode!=="pinned")return null;const _=t.selectedSession;if(!_)return null;const C=d(_);if(C.length===0)return null;const z=t.selectedEntryId;if(z==null)return null;const K=C.findIndex(Q=>Q.id===z);if(K<0)return null;const V=K+1;return V<C.length?V:null}function v(_){const C=_.match(/^#compare\/(.+)$/);return C?C[1].split(",").map(z=>decodeURIComponent(z.trim())).filter(Boolean):null}async function w(){n.value=!0;try{const _=window.location.hash||"",C=v(_);if(C&&C.length>=2){const Q=C.filter(D=>t.summaries.some(ae=>ae.id===D));if(Q.length>=2){await t.enterCompare(new Set(Q));return}}const{sessionId:z,tab:K,turn:V}=p(_);if(z){if(!t.summaries.some(D=>D.id===z)){t.setView("dashboard");return}if(await t.selectSession(z),K&&t.setInspectorTab(K),V!=null&&t.selectedSession){const D=d(t.selectedSession);if(D.length>0){const ae=Math.min(Math.max(V,1),D.length);ae<D.length?t.pinEntry(D[ae-1].id):t.followLive()}else t.followLive()}else t.followLive();t.setView("inspector");return}t.setView("dashboard")}finally{n.value=!1}}function I(){if(n.value)return;let _=al;if(t.view==="compare"&&t.compareSessionIds.size>=2)_=`#compare/${Array.from(t.compareSessionIds).map(z=>encodeURIComponent(z)).join(",")}`;else if(t.view==="inspector"&&t.selectedSessionId){const C=new URLSearchParams;C.set("tab",t.inspectorTab);const z=m();z!=null&&C.set("turn",String(z));const K=C.toString();_=`#session/${encodeURIComponent(t.selectedSessionId)}${K?`?${K}`:""}`}window.location.hash!==_&&(window.location.hash=_)}function S(){w()}return Ke(()=>{var _;return[t.view,t.selectedSessionId,t.inspectorTab,t.selectionMode,t.selectedEntryId,(_=t.selectedSession)==null?void 0:_.entries.length,t.compareMode,t.compareSessionIds.size]},()=>{I()}),Mn(async()=>{try{t.initializeDensity(),await t.load(),window.location.hash||(window.location.hash=al),await w(),window.addEventListener("hashchange",S),i=setInterval(()=>{document.hidden||t.load()},5e3)}finally{s.value=!0}}),po(()=>{window.removeEventListener("hashchange",S),i&&(clearInterval(i),i=null)}),(_,C)=>(g(),b("div",ob,[Re(Ap),u("div",ib,[s.value?(g(),b(ve,{key:1},[Re(zn,{name:"rail-slide"},{default:ft(()=>[Y(t).view==="inspector"?(g(),dt(Z0,{key:0})):le("",!0)]),_:1}),u("div",lb,[Re(zn,{name:l.value},{default:ft(()=>[Y(t).view==="dashboard"?(g(),dt(Uh,{key:"dashboard"})):Y(t).view==="compare"?(g(),dt(Q_,{key:"compare"})):Y(t).view==="inspector"?(g(),b("div",ab,[Y(t).selectedSession?(g(),dt(W0,{key:0})):(g(),b("div",cb,[...C[1]||(C[1]=[u("div",{class:"loading-spinner"},null,-1)])]))])):(g(),dt(sb,{key:"empty"}))]),_:1},8,["name"])])],64)):(g(),b("div",rb,[...C[0]||(C[0]=[u("div",{class:"loading-spinner"},null,-1)])]))])]))}}),db=at(ub,[["__scopeId","data-v-766f3b5b"]]),ji=Ca(db);ji.use(Vd());ji.use(np);ji.mount("#app");export{ey as _};
34
+ `)}function O(H,T){return`#session/${encodeURIComponent(H)}?tab=overview&turn=${T}`}function R(H){return`#session/${encodeURIComponent(H)}?tab=overview`}function de(H,T){n.value=T,s.value=H}function F(){n.value=null,s.value=null}function te(H,T,P){H.ctrlKey||H.metaKey||H.button===1||(H.preventDefault(),t.exitCompare("inspector"),t.selectSession(T),t.pinEntry(P.entry.id))}function ce(H,T){H.ctrlKey||H.metaKey||H.button===1||(H.preventDefault(),t.exitCompare("inspector"),t.setInspectorTab("overview"),t.selectSession(T))}function B(){t.exitCompare("dashboard")}function se(H){return H>=.8?"util-high":H>=.6?"util-mid":"util-low"}function oe(H){o.value=H}function W(){o.value=null}function re(H){return H>=.01?"$"+H.toFixed(2)+"/K":"$"+H.toFixed(3)+"/K"}const we=A(()=>{const H=w.value;if(H.length<2)return null;const T=H.map(h=>h.totalCost),P=H.map(h=>h.finalTokens),ee=H.map(h=>h.turnCount),ne=H.map(h=>h.costPerOutputK),$=Math.min(...T),L=Math.min(...P),G=Math.min(...ee),k=ne.filter(h=>h!==null),y=k.length>0?Math.min(...k):null;return H.map(h=>({isCheapest:h.totalCost<=$,isLeanest:h.finalTokens<=L,isFewest:h.turnCount<=G,isMostEfficient:y!==null&&h.costPerOutputK!==null&&h.costPerOutputK<=y}))});return(H,T)=>(g(),b("div",Q0,[u("header",e_,[u("button",{class:"back-btn",onClick:B},[...T[0]||(T[0]=[u("i",{class:"i-carbon-arrow-left"},null,-1),xe(" Dashboard ",-1)])]),u("h1",t_,[T[1]||(T[1]=xe(" Compare ",-1)),u("span",n_,M(w.value.length)+" sessions",1)]),u("div",s_,[(g(!0),b(ve,null,Te(i.value,P=>(g(),b("span",{key:P.key,class:"legend-chip"},[u("span",{class:"legend-swatch",style:Me({background:P.color})},null,4),xe(" "+M(P.label),1)]))),128))])]),u("div",o_,[(g(!0),b(ve,null,Te(w.value,(P,ee)=>(g(),b("div",{key:P.id,class:he(["lane",{"lane--focused":o.value===P.id,"lane--dimmed":o.value!==null&&o.value!==P.id}]),onMouseenter:ne=>oe(P.id),onMouseleave:W},[u("div",r_,[u("div",l_,[u("div",a_,M(ee+1),1),u("span",{class:he(["source-badge",Y($s)(P.source)])},M(P.source||"?"),3),u("span",c_,M(Y(en)(P.model)),1),P.directory?(g(),b("span",u_,M(P.directory),1)):le("",!0)]),u("div",d_,[u("div",f_,[u("span",p_,M(P.turnCount),1),T[2]||(T[2]=u("span",{class:"lm-key"},"turns",-1)),we.value&&we.value[ee].isFewest?(g(),b("span",h_)):le("",!0)]),u("div",v_,[u("span",m_,M(Y(_t)(P.totalCost)),1),T[3]||(T[3]=u("span",{class:"lm-key"},"cost",-1)),we.value&&we.value[ee].isCheapest?(g(),b("span",g_)):le("",!0)]),u("div",y_,[u("span",{class:he(["lm-value",se(P.utilization)])},M(Math.round(P.utilization*100))+"% ",3),T[4]||(T[4]=u("span",{class:"lm-key"},"context",-1)),we.value&&we.value[ee].isLeanest?(g(),b("span",__)):le("",!0)]),u("div",b_,[P.healthRating!=="unknown"?(g(),b("span",{key:0,class:"lm-value lm-health",style:Me({color:Y(di)(P.healthRating)})},M(P.healthScore),5)):(g(),b("span",w_,"--")),T[5]||(T[5]=u("span",{class:"lm-key"},"health",-1))]),P.cacheRate!==null?(g(),b("div",k_,[u("span",x_,M(Y(ui)(P.cacheRate)),1),T[6]||(T[6]=u("span",{class:"lm-key"},"cache",-1))])):le("",!0),P.costPerOutputK!==null?(g(),b("div",$_,[u("span",S_,M(re(P.costPerOutputK)),1),T[7]||(T[7]=u("span",{class:"lm-key"},"$/out",-1)),we.value&&we.value[ee].isMostEfficient?(g(),b("span",C_)):le("",!0)])):le("",!0),u("div",T_,[u("span",M_,M(P.totalDurationMs>0?Y(ci)(P.totalDurationMs):"--"),1),T[8]||(T[8]=u("span",{class:"lm-key"},"duration",-1))])]),u("a",{class:"inspect-btn",title:"Open in inspector",href:R(P.id),onClick:ne=>ce(ne,P.id)},[...T[9]||(T[9]=[u("i",{class:"i-carbon-arrow-right"},null,-1)])],8,E_)]),u("div",P_,[u("div",I_,[(g(!0),b(ve,null,Te(P.turns,ne=>(g(),b("a",{key:ne.turnNumber,class:he(["turn-col",{"turn-col--error":ne.isError,"turn-col--stall":ne.isStall,"turn-col--crosslit":n.value===ne.turnNumber&&s.value!==P.id}]),style:Me({opacity:ae(P.id,ne.turnNumber)}),title:ue(ne),href:O(P.id,ne.turnNumber),onMouseenter:$=>de(P.id,ne.turnNumber),onMouseleave:F,onClick:$=>te($,P.id,ne)},[u("div",{class:"turn-bar",style:Me({height:C(ne.tokens)})},[(g(!0),b(ve,null,Te(ne.segments,$=>(g(),b("div",{key:$.key,class:"turn-seg",style:Me({flex:$.pct,background:$.color})},null,4))),128))],4),u("div",{class:"cost-dot",style:Me({opacity:z(ne.costUsd)})},null,4),u("span",L_,M(ne.turnNumber),1)],46,A_))),128)),P.turns.length===0?(g(),b("div",O_," Loading... ")):le("",!0)]),P.tokenHistory.length>1?(g(),b("div",R_,[u("div",D_,[(g(),b("svg",N_,[u("line",{x1:"0",y1:Q(P.contextLimit),x2:"100",y2:Q(P.contextLimit),class:"sparkline-limit"},null,8,F_),u("path",{d:V(P.tokenHistory,_.value),class:"sparkline-area"},null,8,z_),u("path",{d:K(P.tokenHistory,_.value),class:"sparkline-line"},null,8,B_)])),u("span",H_,[xe(M(Y(_e)(P.finalTokens)),1),T[10]||(T[10]=u("span",{class:"sparkline-sep"},"/",-1)),xe(M(Y(_e)(P.contextLimit)),1)])]),u("div",j_,[(g(),b("svg",V_,[u("path",{d:V(P.costHistory,D.value),class:"sparkline-area sparkline-area--cost"},null,8,U_),u("path",{d:K(P.costHistory,D.value),class:"sparkline-line sparkline-line--cost"},null,8,K_)])),u("span",W_,M(Y(_t)(P.totalCost))+" total",1)])])):le("",!0)]),P.finalComposition.length>0?(g(),b("div",q_,[u("div",G_,[(g(!0),b(ve,null,Te(P.finalComposition,ne=>{var $,L;return g(),b("div",{key:ne.key,class:"comp-seg",style:Me({flex:ne.pct,background:ne.color}),title:`${(($=Y(mt)[ne.key])==null?void 0:$.label)??ne.key}: ${Math.round(ne.pct)}%`},[ne.pct>=18?(g(),b("span",Y_,M(((L=Y(mt)[ne.key])==null?void 0:L.label)??ne.key),1)):le("",!0)],12,J_)}),128))]),u("span",X_,M(Y(_e)(P.finalTokens)),1)])):le("",!0)],42,i_))),128))])]))}}),Q_=at(Z_,[["__scopeId","data-v-f1fe8711"]]),eb={},tb={class:"empty"};function nb(e,t){return g(),b("div",tb,[...t[0]||(t[0]=[ya('<svg class="empty-icon" width="48" height="48" viewBox="0 0 48 48" aria-hidden="true" data-v-213dcf0e><circle cx="24" cy="24" r="20" fill="none" stroke="var(--border-mid)" stroke-width="1" data-v-213dcf0e></circle><circle cx="24" cy="24" r="10" fill="none" stroke="var(--border-bright)" stroke-width="0.8" data-v-213dcf0e></circle><circle cx="24" cy="24" r="3" fill="var(--accent-blue)" opacity="0.4" data-v-213dcf0e></circle></svg><div class="empty-title" data-v-213dcf0e>No requests captured yet</div><div class="empty-sub" data-v-213dcf0e> Start a tool through the CLI to capture traffic: </div><div class="empty-examples" data-v-213dcf0e><code data-v-213dcf0e>context-lens claude</code><code data-v-213dcf0e>context-lens codex</code><code data-v-213dcf0e>context-lens gemini</code></div>',4)])])}const sb=at(eb,[["render",nb],["__scopeId","data-v-213dcf0e"]]),ob={class:"app"},ib={class:"app-body"},rb={key:0,class:"app-loading"},lb={class:"main-content"},ab={key:"inspector",class:"inspector-content"},cb={key:1,class:"loading-placeholder"},al="#sessions",ub=Qe({__name:"App",setup(e){const t=At(),n=me(!1),s=me(!1),o=["overview","messages","timeline"];let i=null;const r=me(null),l=A(()=>{const _=t.view,C=r.value;return C===null?"view-instant":C==="dashboard"&&_==="inspector"?"view-slide-forward":C==="inspector"&&_==="dashboard"?"view-slide-back":"view-instant"});Ke(()=>t.view,(_,C)=>{r.value!==null?r.value=C:r.value=_});const{connected:c}=pp("/api/events",_=>{t.handleSSEEvent(_)});Ke(c,_=>{t.connected=_});function p(_){const C=_.match(/^#session\/([^?]+)(?:\?(.*))?$/);if(!C)return{sessionId:null,tab:null,turn:null};const K=decodeURIComponent(C[1]).trim()||null;if(!K)return{sessionId:null,tab:null,turn:null};const V=new URLSearchParams(C[2]??""),Q=V.get("tab"),D=Q&&o.includes(Q)?Q:null,ae=V.get("turn"),ue=ae?Number.parseInt(ae,10):NaN,O=Number.isFinite(ue)&&ue>0?ue:null;return{sessionId:K,tab:D,turn:O}}function d(_){return Yt([..._.entries].reverse()).filter(C=>C.isMain).map(C=>C.entry)}function m(){if(t.selectionMode!=="pinned")return null;const _=t.selectedSession;if(!_)return null;const C=d(_);if(C.length===0)return null;const z=t.selectedEntryId;if(z==null)return null;const K=C.findIndex(Q=>Q.id===z);if(K<0)return null;const V=K+1;return V<C.length?V:null}function v(_){const C=_.match(/^#compare\/(.+)$/);return C?C[1].split(",").map(z=>decodeURIComponent(z.trim())).filter(Boolean):null}async function w(){n.value=!0;try{const _=window.location.hash||"",C=v(_);if(C&&C.length>=2){const Q=C.filter(D=>t.summaries.some(ae=>ae.id===D));if(Q.length>=2){await t.enterCompare(new Set(Q));return}}const{sessionId:z,tab:K,turn:V}=p(_);if(z){if(!t.summaries.some(D=>D.id===z)){t.setView("dashboard");return}if(await t.selectSession(z),K&&t.setInspectorTab(K),V!=null&&t.selectedSession){const D=d(t.selectedSession);if(D.length>0){const ae=Math.min(Math.max(V,1),D.length);ae<D.length?t.pinEntry(D[ae-1].id):t.followLive()}else t.followLive()}else t.followLive();t.setView("inspector");return}t.setView("dashboard")}finally{n.value=!1}}function I(){if(n.value)return;let _=al;if(t.view==="compare"&&t.compareSessionIds.size>=2)_=`#compare/${Array.from(t.compareSessionIds).map(z=>encodeURIComponent(z)).join(",")}`;else if(t.view==="inspector"&&t.selectedSessionId){const C=new URLSearchParams;C.set("tab",t.inspectorTab);const z=m();z!=null&&C.set("turn",String(z));const K=C.toString();_=`#session/${encodeURIComponent(t.selectedSessionId)}${K?`?${K}`:""}`}window.location.hash!==_&&(window.location.hash=_)}function S(){w()}return Ke(()=>{var _;return[t.view,t.selectedSessionId,t.inspectorTab,t.selectionMode,t.selectedEntryId,(_=t.selectedSession)==null?void 0:_.entries.length,t.compareMode,t.compareSessionIds.size]},()=>{I()}),Mn(async()=>{try{t.initializeDensity(),await t.load(),window.location.hash||(window.location.hash=al),await w(),window.addEventListener("hashchange",S),i=setInterval(()=>{document.hidden||t.load()},5e3)}finally{s.value=!0}}),po(()=>{window.removeEventListener("hashchange",S),i&&(clearInterval(i),i=null)}),(_,C)=>(g(),b("div",ob,[Re(Ap),u("div",ib,[s.value?(g(),b(ve,{key:1},[Re(zn,{name:"rail-slide"},{default:ft(()=>[Y(t).view==="inspector"?(g(),dt(Z0,{key:0})):le("",!0)]),_:1}),u("div",lb,[Re(zn,{name:l.value},{default:ft(()=>[Y(t).view==="dashboard"?(g(),dt(Uh,{key:"dashboard"})):Y(t).view==="compare"?(g(),dt(Q_,{key:"compare"})):Y(t).view==="inspector"?(g(),b("div",ab,[Y(t).selectedSession?(g(),dt(W0,{key:0})):(g(),b("div",cb,[...C[1]||(C[1]=[u("div",{class:"loading-spinner"},null,-1)])]))])):(g(),dt(sb,{key:"empty"}))]),_:1},8,["name"])])],64)):(g(),b("div",rb,[...C[0]||(C[0]=[u("div",{class:"loading-spinner"},null,-1)])]))])]))}}),db=at(ub,[["__scopeId","data-v-766f3b5b"]]),ji=Ca(db);ji.use(Vd());ji.use(np);ji.mount("#app");export{ey as _};