agent-lookout 0.2.0 → 0.2.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.
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/HistoryPanel-DMnhIoFB.js","assets/react-C2DiJaR6.js","assets/motion-BAhdRuCw.js","assets/radix-27o0jeIu.js","assets/SessionPanel-BNm9wCzf.js"])))=>i.map(i=>d[i]);
2
+ import{j as n,r as g,d as ya}from"./react-C2DiJaR6.js";import{M as ka,A as ja,m as Na}from"./motion-BAhdRuCw.js";import{S as va,P as Sa,R as Aa,T as Ea,a as Ma,C as Ta,b as Ia,c as Ca,D as lo,d as co,e as uo,f as mo,g as fo,h as La,i as Oa}from"./radix-27o0jeIu.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))o(r);new MutationObserver(r=>{for(const a of r)if(a.type==="childList")for(const i of a.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&o(i)}).observe(document,{childList:!0,subtree:!0});function s(r){const a={};return r.integrity&&(a.integrity=r.integrity),r.referrerPolicy&&(a.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?a.credentials="include":r.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function o(r){if(r.ep)return;r.ep=!0;const a=s(r);fetch(r.href,a)}})();const $a="modulepreload",_a=function(e){return"/"+e},us={},ho=function(t,s,o){let r=Promise.resolve();if(s&&s.length>0){let d=function(c){return Promise.all(c.map(u=>Promise.resolve(u).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),l=i?.nonce||i?.getAttribute("nonce");r=d(s.map(c=>{if(c=_a(c),c in us)return;us[c]=!0;const u=c.endsWith(".css"),m=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${m}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":$a,u||(f.as="script"),f.crossOrigin="",f.href=c,l&&f.setAttribute("nonce",l),document.head.appendChild(f),u)return new Promise((p,b)=>{f.addEventListener("load",p),f.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${c}`)))})}))}function a(i){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=i,window.dispatchEvent(l),!l.defaultPrevented)throw i}return r.then(i=>{for(const l of i||[])l.status==="rejected"&&a(l.reason);return t().catch(a)})};function po(e){var t,s,o="";if(typeof e=="string"||typeof e=="number")o+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(s=po(e[t]))&&(o&&(o+=" "),o+=s)}else for(s in e)e[s]&&(o&&(o+=" "),o+=s);return o}function xo(){for(var e,t,s=0,o="",r=arguments.length;s<r;s++)(e=arguments[s])&&(t=po(e))&&(o&&(o+=" "),o+=t);return o}const ms=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,fs=xo,go=(e,t)=>s=>{var o;if(t?.variants==null)return fs(e,s?.class,s?.className);const{variants:r,defaultVariants:a}=t,i=Object.keys(r).map(c=>{const u=s?.[c],m=a?.[c];if(u===null)return null;const f=ms(u)||ms(m);return r[c][f]}),l=s&&Object.entries(s).reduce((c,u)=>{let[m,f]=u;return f===void 0||(c[m]=f),c},{}),d=t==null||(o=t.compoundVariants)===null||o===void 0?void 0:o.reduce((c,u)=>{let{class:m,className:f,...p}=u;return Object.entries(p).every(b=>{let[w,h]=b;return Array.isArray(h)?h.includes({...a,...l}[w]):{...a,...l}[w]===h})?[...c,m,f]:c},[]);return fs(e,i,d,s?.class,s?.className)},Ra=(e,t)=>{const s=new Array(e.length+t.length);for(let o=0;o<e.length;o++)s[o]=e[o];for(let o=0;o<t.length;o++)s[e.length+o]=t[o];return s},Wa=(e,t)=>({classGroupId:e,validator:t}),wo=(e=new Map,t=null,s)=>({nextPart:e,validators:t,classGroupId:s}),Ct="-",hs=[],Pa="arbitrary..",Fa=e=>{const t=Da(e),{conflictingClassGroups:s,conflictingClassGroupModifiers:o}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return za(i);const l=i.split(Ct),d=l[0]===""&&l.length>1?1:0;return bo(l,d,t)},getConflictingClassGroupIds:(i,l)=>{if(l){const d=o[i],c=s[i];return d?c?Ra(c,d):d:c||hs}return s[i]||hs}}},bo=(e,t,s)=>{if(e.length-t===0)return s.classGroupId;const r=e[t],a=s.nextPart.get(r);if(a){const c=bo(e,t+1,a);if(c)return c}const i=s.validators;if(i===null)return;const l=t===0?e.join(Ct):e.slice(t).join(Ct),d=i.length;for(let c=0;c<d;c++){const u=i[c];if(u.validator(l))return u.classGroupId}},za=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),s=t.indexOf(":"),o=t.slice(0,s);return o?Pa+o:void 0})(),Da=e=>{const{theme:t,classGroups:s}=e;return Ua(s,t)},Ua=(e,t)=>{const s=wo();for(const o in e){const r=e[o];Mn(r,s,o,t)}return s},Mn=(e,t,s,o)=>{const r=e.length;for(let a=0;a<r;a++){const i=e[a];Ha(i,t,s,o)}},Ha=(e,t,s,o)=>{if(typeof e=="string"){Ba(e,t,s);return}if(typeof e=="function"){Ga(e,t,s,o);return}Ka(e,t,s,o)},Ba=(e,t,s)=>{const o=e===""?t:yo(t,e);o.classGroupId=s},Ga=(e,t,s,o)=>{if(Va(e)){Mn(e(o),t,s,o);return}t.validators===null&&(t.validators=[]),t.validators.push(Wa(s,e))},Ka=(e,t,s,o)=>{const r=Object.entries(e),a=r.length;for(let i=0;i<a;i++){const[l,d]=r[i];Mn(d,yo(t,l),s,o)}},yo=(e,t)=>{let s=e;const o=t.split(Ct),r=o.length;for(let a=0;a<r;a++){const i=o[a];let l=s.nextPart.get(i);l||(l=wo(),s.nextPart.set(i,l)),s=l}return s},Va=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,Ya=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,s=Object.create(null),o=Object.create(null);const r=(a,i)=>{s[a]=i,t++,t>e&&(t=0,o=s,s=Object.create(null))};return{get(a){let i=s[a];if(i!==void 0)return i;if((i=o[a])!==void 0)return r(a,i),i},set(a,i){a in s?s[a]=i:r(a,i)}}},un="!",ps=":",qa=[],xs=(e,t,s,o,r)=>({modifiers:e,hasImportantModifier:t,baseClassName:s,maybePostfixModifierPosition:o,isExternal:r}),Ja=e=>{const{prefix:t,experimentalParseClassName:s}=e;let o=r=>{const a=[];let i=0,l=0,d=0,c;const u=r.length;for(let w=0;w<u;w++){const h=r[w];if(i===0&&l===0){if(h===ps){a.push(r.slice(d,w)),d=w+1;continue}if(h==="/"){c=w;continue}}h==="["?i++:h==="]"?i--:h==="("?l++:h===")"&&l--}const m=a.length===0?r:r.slice(d);let f=m,p=!1;m.endsWith(un)?(f=m.slice(0,-1),p=!0):m.startsWith(un)&&(f=m.slice(1),p=!0);const b=c&&c>d?c-d:void 0;return xs(a,p,f,b)};if(t){const r=t+ps,a=o;o=i=>i.startsWith(r)?a(i.slice(r.length)):xs(qa,!1,i,void 0,!0)}if(s){const r=o;o=a=>s({className:a,parseClassName:r})}return o},Xa=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((s,o)=>{t.set(s,1e6+o)}),s=>{const o=[];let r=[];for(let a=0;a<s.length;a++){const i=s[a],l=i[0]==="[",d=t.has(i);l||d?(r.length>0&&(r.sort(),o.push(...r),r=[]),o.push(i)):r.push(i)}return r.length>0&&(r.sort(),o.push(...r)),o}},Za=e=>({cache:Ya(e.cacheSize),parseClassName:Ja(e),sortModifiers:Xa(e),postfixLookupClassGroupIds:Qa(e),...Fa(e)}),Qa=e=>{const t=Object.create(null),s=e.postfixLookupClassGroups;if(s)for(let o=0;o<s.length;o++)t[s[o]]=!0;return t},ei=/\s+/,ti=(e,t)=>{const{parseClassName:s,getClassGroupId:o,getConflictingClassGroupIds:r,sortModifiers:a,postfixLookupClassGroupIds:i}=t,l=[],d=e.trim().split(ei);let c="";for(let u=d.length-1;u>=0;u-=1){const m=d[u],{isExternal:f,modifiers:p,hasImportantModifier:b,baseClassName:w,maybePostfixModifierPosition:h}=s(m);if(f){c=m+(c.length>0?" "+c:c);continue}let N=!!h,y;if(N){const M=w.substring(0,h);y=o(M);const x=y&&i[y]?o(w):void 0;x&&x!==y&&(y=x,N=!1)}else y=o(w);if(!y){if(!N){c=m+(c.length>0?" "+c:c);continue}if(y=o(w),!y){c=m+(c.length>0?" "+c:c);continue}N=!1}const v=p.length===0?"":p.length===1?p[0]:a(p).join(":"),k=b?v+un:v,E=k+y;if(l.indexOf(E)>-1)continue;l.push(E);const I=r(y,N);for(let M=0;M<I.length;++M){const x=I[M];l.push(k+x)}c=m+(c.length>0?" "+c:c)}return c},ni=(...e)=>{let t=0,s,o,r="";for(;t<e.length;)(s=e[t++])&&(o=ko(s))&&(r&&(r+=" "),r+=o);return r},ko=e=>{if(typeof e=="string")return e;let t,s="";for(let o=0;o<e.length;o++)e[o]&&(t=ko(e[o]))&&(s&&(s+=" "),s+=t);return s},gs=(e,...t)=>{let s,o,r,a;const i=d=>{const c=t.reduce((u,m)=>m(u),e());return s=Za(c),o=s.cache.get,r=s.cache.set,a=l,l(d)},l=d=>{const c=o(d);if(c)return c;const u=ti(d,s);return r(d,u),u};return a=i,(...d)=>a(ni(...d))},si=[],F=e=>{const t=s=>s[e]||si;return t.isThemeGetter=!0,t.themeKey=e,t},jo=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,No=/^\((?:(\w[\w-]*):)?(.+)\)$/i,oi=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,ri=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,ai=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,ii=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix|color|light-dark)\(.+\)$/,li=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,ci=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,ge=e=>oi.test(e),C=e=>!!e&&!Number.isNaN(Number(e)),ae=e=>!!e&&Number.isInteger(Number(e)),Qt=e=>e.endsWith("%")&&C(e.slice(0,-1)),he=e=>ri.test(e),vo=()=>!0,di=e=>ai.test(e)&&!ii.test(e),Tn=()=>!1,ui=e=>li.test(e),mi=e=>ci.test(e),fi=e=>!S(e)&&!A(e),hi=e=>e.startsWith("@container")&&(e[10]==="/"&&e[11]!==void 0||e[11]==="s"&&e[16]!==void 0&&e.startsWith("-size/",10)||e[11]==="n"&&e[18]!==void 0&&e.startsWith("-normal/",10)),pi=e=>je(e,Eo,Tn),S=e=>jo.test(e),Ee=e=>je(e,Mo,di),ws=e=>je(e,Ni,C),xi=e=>je(e,Io,vo),gi=e=>je(e,To,Tn),bs=e=>je(e,So,Tn),wi=e=>je(e,Ao,mi),yt=e=>je(e,Co,ui),A=e=>No.test(e),Ge=e=>Le(e,Mo),bi=e=>Le(e,To),ys=e=>Le(e,So),yi=e=>Le(e,Eo),ki=e=>Le(e,Ao),kt=e=>Le(e,Co,!0),ji=e=>Le(e,Io,!0),je=(e,t,s)=>{const o=jo.exec(e);return o?o[1]?t(o[1]):s(o[2]):!1},Le=(e,t,s=!1)=>{const o=No.exec(e);return o?o[1]?t(o[1]):s:!1},So=e=>e==="position"||e==="percentage",Ao=e=>e==="image"||e==="url",Eo=e=>e==="length"||e==="size"||e==="bg-size",Mo=e=>e==="length",Ni=e=>e==="number",To=e=>e==="family-name",Io=e=>e==="number"||e==="weight",Co=e=>e==="shadow",ks=()=>{const e=F("color"),t=F("font"),s=F("text"),o=F("font-weight"),r=F("tracking"),a=F("leading"),i=F("breakpoint"),l=F("container"),d=F("spacing"),c=F("radius"),u=F("shadow"),m=F("inset-shadow"),f=F("text-shadow"),p=F("drop-shadow"),b=F("blur"),w=F("perspective"),h=F("aspect"),N=F("ease"),y=F("animate"),v=()=>["auto","avoid","all","avoid-page","page","left","right","column"],k=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],E=()=>[...k(),A,S],I=()=>["auto","hidden","clip","visible","scroll"],M=()=>["auto","contain","none"],x=()=>[A,S,d],O=()=>[ge,"full","auto",...x()],P=()=>[ae,"none","subgrid",A,S],L=()=>["auto",{span:["full",ae,A,S]},ae,A,S],q=()=>[ae,"auto",A,S],Se=()=>["auto","min","max","fr",A,S],$e=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],te=()=>["start","end","center","stretch","center-safe","end-safe"],ne=()=>["auto",...x()],Ae=()=>[ge,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...x()],qt=()=>[l,ge,"screen","full","dvw","lvw","svw","min","max","fit",...x()],Jt=()=>[ge,"screen","full","lh","dvh","lvh","svh","min","max","fit",...x()],T=()=>[e,A,S],as=()=>[...k(),ys,bs,{position:[A,S]}],is=()=>["no-repeat",{repeat:["","x","y","space","round"]}],ls=()=>["auto","cover","contain",yi,pi,{size:[A,S]}],Xt=()=>[Qt,Ge,Ee],G=()=>["","none","full",c,A,S],K=()=>["",C,Ge,Ee],xt=()=>["solid","dashed","dotted","double"],cs=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],D=()=>[C,Qt,ys,bs],ds=()=>["","none",b,A,S],gt=()=>["none",C,A,S],wt=()=>["none",C,A,S],Zt=()=>[C,A,S],bt=()=>[ge,"full",...x()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[he],breakpoint:[he],color:[vo],container:[he],"drop-shadow":[he],ease:["in","out","in-out"],font:[fi],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[he],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[he],shadow:[he],spacing:["px",C],text:[he],"text-shadow":[he],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",ge,S,A,h]}],container:["container"],"container-type":[{"@container":["","normal","size",A,S]}],"container-named":[hi],columns:[{columns:[C,"auto",S,A,l]}],"break-after":[{"break-after":v()}],"break-before":[{"break-before":v()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:E()}],overflow:[{overflow:I()}],"overflow-x":[{"overflow-x":I()}],"overflow-y":[{"overflow-y":I()}],overscroll:[{overscroll:M()}],"overscroll-x":[{"overscroll-x":M()}],"overscroll-y":[{"overscroll-y":M()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:O()}],"inset-x":[{"inset-x":O()}],"inset-y":[{"inset-y":O()}],start:[{"inset-s":O(),start:O()}],end:[{"inset-e":O(),end:O()}],"inset-bs":[{"inset-bs":O()}],"inset-be":[{"inset-be":O()}],top:[{top:O()}],right:[{right:O()}],bottom:[{bottom:O()}],left:[{left:O()}],visibility:["visible","invisible","collapse"],z:[{z:[ae,"auto",A,S]}],basis:[{basis:[ge,"full","auto",l,...x()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[C,ge,"auto","initial","none",S]}],grow:[{grow:["",C,A,S]}],shrink:[{shrink:["",C,A,S]}],order:[{order:[ae,"first","last","none",A,S]}],"grid-cols":[{"grid-cols":P()}],"col-start-end":[{col:L()}],"col-start":[{"col-start":q()}],"col-end":[{"col-end":q()}],"grid-rows":[{"grid-rows":P()}],"row-start-end":[{row:L()}],"row-start":[{"row-start":q()}],"row-end":[{"row-end":q()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":Se()}],"auto-rows":[{"auto-rows":Se()}],gap:[{gap:x()}],"gap-x":[{"gap-x":x()}],"gap-y":[{"gap-y":x()}],"justify-content":[{justify:[...$e(),"normal"]}],"justify-items":[{"justify-items":[...te(),"normal"]}],"justify-self":[{"justify-self":["auto",...te()]}],"align-content":[{content:["normal",...$e()]}],"align-items":[{items:[...te(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...te(),{baseline:["","last"]}]}],"place-content":[{"place-content":$e()}],"place-items":[{"place-items":[...te(),"baseline"]}],"place-self":[{"place-self":["auto",...te()]}],p:[{p:x()}],px:[{px:x()}],py:[{py:x()}],ps:[{ps:x()}],pe:[{pe:x()}],pbs:[{pbs:x()}],pbe:[{pbe:x()}],pt:[{pt:x()}],pr:[{pr:x()}],pb:[{pb:x()}],pl:[{pl:x()}],m:[{m:ne()}],mx:[{mx:ne()}],my:[{my:ne()}],ms:[{ms:ne()}],me:[{me:ne()}],mbs:[{mbs:ne()}],mbe:[{mbe:ne()}],mt:[{mt:ne()}],mr:[{mr:ne()}],mb:[{mb:ne()}],ml:[{ml:ne()}],"space-x":[{"space-x":x()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":x()}],"space-y-reverse":["space-y-reverse"],size:[{size:Ae()}],"inline-size":[{inline:["auto",...qt()]}],"min-inline-size":[{"min-inline":["auto",...qt()]}],"max-inline-size":[{"max-inline":["none",...qt()]}],"block-size":[{block:["auto",...Jt()]}],"min-block-size":[{"min-block":["auto",...Jt()]}],"max-block-size":[{"max-block":["none",...Jt()]}],w:[{w:[l,"screen",...Ae()]}],"min-w":[{"min-w":[l,"screen","none",...Ae()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[i]},...Ae()]}],h:[{h:["screen","lh",...Ae()]}],"min-h":[{"min-h":["screen","lh","none",...Ae()]}],"max-h":[{"max-h":["screen","lh","none",...Ae()]}],"font-size":[{text:["base",s,Ge,Ee]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[o,ji,xi]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Qt,S]}],"font-family":[{font:[bi,gi,t]}],"font-features":[{"font-features":[S]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[r,A,S]}],"line-clamp":[{"line-clamp":[C,"none",A,ws]}],leading:[{leading:["none",a,...x()]}],"list-image":[{"list-image":["none",A,S]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",A,S]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:T()}],"text-color":[{text:T()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...xt(),"wavy"]}],"text-decoration-thickness":[{decoration:[C,"from-font","auto",A,Ee]}],"text-decoration-color":[{decoration:T()}],"underline-offset":[{"underline-offset":[C,"auto",A,S]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:x()}],"tab-size":[{tab:[ae,A,S]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",A,S]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",A,S]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:as()}],"bg-repeat":[{bg:is()}],"bg-size":[{bg:ls()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},ae,A,S],radial:["",A,S],conic:["",ae,A,S]},ki,wi]}],"bg-color":[{bg:T()}],"gradient-from-pos":[{from:Xt()}],"gradient-via-pos":[{via:Xt()}],"gradient-to-pos":[{to:Xt()}],"gradient-from":[{from:T()}],"gradient-via":[{via:T()}],"gradient-to":[{to:T()}],rounded:[{rounded:G()}],"rounded-s":[{"rounded-s":G()}],"rounded-e":[{"rounded-e":G()}],"rounded-t":[{"rounded-t":G()}],"rounded-r":[{"rounded-r":G()}],"rounded-b":[{"rounded-b":G()}],"rounded-l":[{"rounded-l":G()}],"rounded-ss":[{"rounded-ss":G()}],"rounded-se":[{"rounded-se":G()}],"rounded-ee":[{"rounded-ee":G()}],"rounded-es":[{"rounded-es":G()}],"rounded-tl":[{"rounded-tl":G()}],"rounded-tr":[{"rounded-tr":G()}],"rounded-br":[{"rounded-br":G()}],"rounded-bl":[{"rounded-bl":G()}],"border-w":[{border:K()}],"border-w-x":[{"border-x":K()}],"border-w-y":[{"border-y":K()}],"border-w-s":[{"border-s":K()}],"border-w-e":[{"border-e":K()}],"border-w-bs":[{"border-bs":K()}],"border-w-be":[{"border-be":K()}],"border-w-t":[{"border-t":K()}],"border-w-r":[{"border-r":K()}],"border-w-b":[{"border-b":K()}],"border-w-l":[{"border-l":K()}],"divide-x":[{"divide-x":K()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":K()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...xt(),"hidden","none"]}],"divide-style":[{divide:[...xt(),"hidden","none"]}],"border-color":[{border:T()}],"border-color-x":[{"border-x":T()}],"border-color-y":[{"border-y":T()}],"border-color-s":[{"border-s":T()}],"border-color-e":[{"border-e":T()}],"border-color-bs":[{"border-bs":T()}],"border-color-be":[{"border-be":T()}],"border-color-t":[{"border-t":T()}],"border-color-r":[{"border-r":T()}],"border-color-b":[{"border-b":T()}],"border-color-l":[{"border-l":T()}],"divide-color":[{divide:T()}],"outline-style":[{outline:[...xt(),"none","hidden"]}],"outline-offset":[{"outline-offset":[C,A,S]}],"outline-w":[{outline:["",C,Ge,Ee]}],"outline-color":[{outline:T()}],shadow:[{shadow:["","inner","none",u,kt,yt]}],"shadow-color":[{shadow:T()}],"inset-shadow":[{"inset-shadow":["none",m,kt,yt]}],"inset-shadow-color":[{"inset-shadow":T()}],"ring-w":[{ring:K()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:T()}],"ring-offset-w":[{"ring-offset":[C,Ee]}],"ring-offset-color":[{"ring-offset":T()}],"inset-ring-w":[{"inset-ring":K()}],"inset-ring-color":[{"inset-ring":T()}],"text-shadow":[{"text-shadow":["none",f,kt,yt]}],"text-shadow-color":[{"text-shadow":T()}],opacity:[{opacity:[C,A,S]}],"mix-blend":[{"mix-blend":[...cs(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":cs()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[C]}],"mask-image-linear-from-pos":[{"mask-linear-from":D()}],"mask-image-linear-to-pos":[{"mask-linear-to":D()}],"mask-image-linear-from-color":[{"mask-linear-from":T()}],"mask-image-linear-to-color":[{"mask-linear-to":T()}],"mask-image-t-from-pos":[{"mask-t-from":D()}],"mask-image-t-to-pos":[{"mask-t-to":D()}],"mask-image-t-from-color":[{"mask-t-from":T()}],"mask-image-t-to-color":[{"mask-t-to":T()}],"mask-image-r-from-pos":[{"mask-r-from":D()}],"mask-image-r-to-pos":[{"mask-r-to":D()}],"mask-image-r-from-color":[{"mask-r-from":T()}],"mask-image-r-to-color":[{"mask-r-to":T()}],"mask-image-b-from-pos":[{"mask-b-from":D()}],"mask-image-b-to-pos":[{"mask-b-to":D()}],"mask-image-b-from-color":[{"mask-b-from":T()}],"mask-image-b-to-color":[{"mask-b-to":T()}],"mask-image-l-from-pos":[{"mask-l-from":D()}],"mask-image-l-to-pos":[{"mask-l-to":D()}],"mask-image-l-from-color":[{"mask-l-from":T()}],"mask-image-l-to-color":[{"mask-l-to":T()}],"mask-image-x-from-pos":[{"mask-x-from":D()}],"mask-image-x-to-pos":[{"mask-x-to":D()}],"mask-image-x-from-color":[{"mask-x-from":T()}],"mask-image-x-to-color":[{"mask-x-to":T()}],"mask-image-y-from-pos":[{"mask-y-from":D()}],"mask-image-y-to-pos":[{"mask-y-to":D()}],"mask-image-y-from-color":[{"mask-y-from":T()}],"mask-image-y-to-color":[{"mask-y-to":T()}],"mask-image-radial":[{"mask-radial":[A,S]}],"mask-image-radial-from-pos":[{"mask-radial-from":D()}],"mask-image-radial-to-pos":[{"mask-radial-to":D()}],"mask-image-radial-from-color":[{"mask-radial-from":T()}],"mask-image-radial-to-color":[{"mask-radial-to":T()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":k()}],"mask-image-conic-pos":[{"mask-conic":[C]}],"mask-image-conic-from-pos":[{"mask-conic-from":D()}],"mask-image-conic-to-pos":[{"mask-conic-to":D()}],"mask-image-conic-from-color":[{"mask-conic-from":T()}],"mask-image-conic-to-color":[{"mask-conic-to":T()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:as()}],"mask-repeat":[{mask:is()}],"mask-size":[{mask:ls()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",A,S]}],filter:[{filter:["","none",A,S]}],blur:[{blur:ds()}],brightness:[{brightness:[C,A,S]}],contrast:[{contrast:[C,A,S]}],"drop-shadow":[{"drop-shadow":["","none",p,kt,yt]}],"drop-shadow-color":[{"drop-shadow":T()}],grayscale:[{grayscale:["",C,A,S]}],"hue-rotate":[{"hue-rotate":[C,A,S]}],invert:[{invert:["",C,A,S]}],saturate:[{saturate:[C,A,S]}],sepia:[{sepia:["",C,A,S]}],"backdrop-filter":[{"backdrop-filter":["","none",A,S]}],"backdrop-blur":[{"backdrop-blur":ds()}],"backdrop-brightness":[{"backdrop-brightness":[C,A,S]}],"backdrop-contrast":[{"backdrop-contrast":[C,A,S]}],"backdrop-grayscale":[{"backdrop-grayscale":["",C,A,S]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[C,A,S]}],"backdrop-invert":[{"backdrop-invert":["",C,A,S]}],"backdrop-opacity":[{"backdrop-opacity":[C,A,S]}],"backdrop-saturate":[{"backdrop-saturate":[C,A,S]}],"backdrop-sepia":[{"backdrop-sepia":["",C,A,S]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":x()}],"border-spacing-x":[{"border-spacing-x":x()}],"border-spacing-y":[{"border-spacing-y":x()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",A,S]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[C,"initial",A,S]}],ease:[{ease:["linear","initial",N,A,S]}],delay:[{delay:[C,A,S]}],animate:[{animate:["none",y,A,S]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[w,A,S]}],"perspective-origin":[{"perspective-origin":E()}],rotate:[{rotate:gt()}],"rotate-x":[{"rotate-x":gt()}],"rotate-y":[{"rotate-y":gt()}],"rotate-z":[{"rotate-z":gt()}],scale:[{scale:wt()}],"scale-x":[{"scale-x":wt()}],"scale-y":[{"scale-y":wt()}],"scale-z":[{"scale-z":wt()}],"scale-3d":["scale-3d"],skew:[{skew:Zt()}],"skew-x":[{"skew-x":Zt()}],"skew-y":[{"skew-y":Zt()}],transform:[{transform:[A,S,"","none","gpu","cpu"]}],"transform-origin":[{origin:E()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:bt()}],"translate-x":[{"translate-x":bt()}],"translate-y":[{"translate-y":bt()}],"translate-z":[{"translate-z":bt()}],"translate-none":["translate-none"],zoom:[{zoom:[ae,A,S]}],accent:[{accent:T()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:T()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",A,S]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":T()}],"scrollbar-track-color":[{"scrollbar-track":T()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":x()}],"scroll-mx":[{"scroll-mx":x()}],"scroll-my":[{"scroll-my":x()}],"scroll-ms":[{"scroll-ms":x()}],"scroll-me":[{"scroll-me":x()}],"scroll-mbs":[{"scroll-mbs":x()}],"scroll-mbe":[{"scroll-mbe":x()}],"scroll-mt":[{"scroll-mt":x()}],"scroll-mr":[{"scroll-mr":x()}],"scroll-mb":[{"scroll-mb":x()}],"scroll-ml":[{"scroll-ml":x()}],"scroll-p":[{"scroll-p":x()}],"scroll-px":[{"scroll-px":x()}],"scroll-py":[{"scroll-py":x()}],"scroll-ps":[{"scroll-ps":x()}],"scroll-pe":[{"scroll-pe":x()}],"scroll-pbs":[{"scroll-pbs":x()}],"scroll-pbe":[{"scroll-pbe":x()}],"scroll-pt":[{"scroll-pt":x()}],"scroll-pr":[{"scroll-pr":x()}],"scroll-pb":[{"scroll-pb":x()}],"scroll-pl":[{"scroll-pl":x()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",A,S]}],fill:[{fill:["none",...T()]}],"stroke-w":[{stroke:[C,Ge,Ee,ws]}],stroke:[{stroke:["none",...T()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["start","end","right","left"],"inset-y":["inset-bs","inset-be","top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["ps","pe","pr","pl"],py:["pbs","pbe","pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["ms","me","mr","ml"],my:["mbs","mbe","mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-s","border-w-e","border-w-r","border-w-l"],"border-w-y":["border-w-bs","border-w-be","border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-s","border-color-e","border-color-r","border-color-l"],"border-color-y":["border-color-bs","border-color-be","border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-ms","scroll-me","scroll-mr","scroll-ml"],"scroll-my":["scroll-mbs","scroll-mbe","scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-ps","scroll-pe","scroll-pr","scroll-pl"],"scroll-py":["scroll-pbs","scroll-pbe","scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},vi=(e,{cacheSize:t,prefix:s,experimentalParseClassName:o,extend:r={},override:a={}})=>(Pe(e,"cacheSize",t),Pe(e,"prefix",s),Pe(e,"experimentalParseClassName",o),jt(e.theme,a.theme),jt(e.classGroups,a.classGroups),jt(e.conflictingClassGroups,a.conflictingClassGroups),jt(e.conflictingClassGroupModifiers,a.conflictingClassGroupModifiers),Pe(e,"postfixLookupClassGroups",a.postfixLookupClassGroups),Pe(e,"orderSensitiveModifiers",a.orderSensitiveModifiers),Nt(e.theme,r.theme),Nt(e.classGroups,r.classGroups),Nt(e.conflictingClassGroups,r.conflictingClassGroups),Nt(e.conflictingClassGroupModifiers,r.conflictingClassGroupModifiers),mn(e,r,"postfixLookupClassGroups"),mn(e,r,"orderSensitiveModifiers"),e),Pe=(e,t,s)=>{s!==void 0&&(e[t]=s)},jt=(e,t)=>{if(t)for(const s in t)Pe(e,s,t[s])},Nt=(e,t)=>{if(t)for(const s in t)mn(e,t,s)},mn=(e,t,s)=>{const o=t[s];o!==void 0&&(e[s]=e[s]?e[s].concat(o):o)},Si=(e,...t)=>typeof e=="function"?gs(ks,e,...t):gs(()=>vi(ks(),e),...t),Ai=["wait","name","stat","unit","wordmark","lead","title","row","body","fact","caption","micro"],Ei=["window","rail","header","row","group","log-row","control","button","button-hero","mark","icon","track","label-col","bar-needs-you","bar-working","bar-idle","waited-name"],Mi=Si({extend:{theme:{text:Ai,spacing:Ei,leading:["tight","body"],radius:["panel","chrome","inner","row","capsule","tube","bar"],shadow:["thumb","glow","edge"],"inset-shadow":["top","well","lit"],ease:["out"],animate:["lamp","spin-loader","rise-fast","fade-in","fade-out","drop"]}}});function j(...e){return Mi(xo(e))}const Ti=go(["inline-flex shrink-0 cursor-pointer items-center justify-center gap-1.5 whitespace-nowrap","rounded-capsule text-body font-medium","transition-[background-color,color,filter] duration-120","disabled:pointer-events-none disabled:opacity-50"],{variants:{variant:{quiet:["bg-fill-quiet text-ink-secondary inset-ring inset-ring-control-rim inset-shadow-top","hover:bg-fill-selected hover:text-ink","focus-visible:bg-fill-selected focus-visible:text-ink"],"needs-you":["bg-status-needs-you font-semibold text-on-needs-you","inset-ring inset-ring-status-needs-you-edge inset-shadow-lit shadow-glow","hover:brightness-105 active:brightness-97"]},size:{sm:"h-button min-w-16 px-4",hero:"h-button-hero px-6.5 text-row",icon:"size-button"}},defaultVariants:{variant:"quiet",size:"sm"}});function J({className:e,variant:t,size:s,asChild:o=!1,...r}){const a=o?va:"button";return n.jsx(a,{"data-slot":"button","data-variant":t??"quiet",...o?{}:{type:"button"},className:j(Ti({variant:t,size:s}),e),...r})}const Ii=e=>e?.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();function Ci(e,t,s=[]){if(t==null)throw new Error("[lucide]: iconNode is required when icon name is used");return{name:Ii(e),size:24,node:t,...s.length>0?{aliases:s}:{}}}const Li=e=>{let t="",s=!1;for(const o of e){if(o==="-"||o==="_"||o<=" "){s=t.length>0;continue}t.length===0?t+=o.toLowerCase():t+=s?o.toUpperCase():o,s=!1}return t};const Oi=e=>{const t=Li(e);return t.charAt(0).toUpperCase()+t.slice(1)};const fn=(...e)=>e.filter((t,s,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===s).join(" ").trim();const Me={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};function en(e){return e!=null}function $i(e,t={}){const s=t.attributeNames??{},o=f=>s[f]??f,r=e.size??e.width??Me.width,a=e.size??e.height??Me.height,i=e.aliases?.filter(f=>typeof f=="string"&&f.trim()!=="").map(f=>`lucide-${f}`)??[],l=[...e.name?[`lucide-${e.name}`]:[],...i],d=t.className?.split(" ").filter(Boolean)??[],c=t.includeDefaultClasses===!1?fn(...d):fn("lucide",...l,...d),u=t.absoluteStrokeWidth?Number(t.strokeWidth??Me["stroke-width"])*Number(e.size??e.width??Me.width)/Number(t.size??t.width??Me.width):t.strokeWidth??Me["stroke-width"];return["svg",{...Object.entries(Me).reduce((f,[p,b])=>(f[o(p)]=b,f),{}),..."color"in t&&t.color&&{[o("stroke")]:t.color},..."size"in t&&en(t.size)&&{[o("width")]:t.size,[o("height")]:t.size},..."width"in t&&en(t.width)&&{[o("width")]:t.width},..."height"in t&&en(t.height)&&{[o("height")]:t.height},[o("stroke-width")]:u,...c&&{[o("class")]:c},[o("viewBox")]:`0 0 ${r} ${a}`,...t.hasA11yProp===!1?{[o("aria-hidden")]:"true"}:{},..."attributes"in t&&t.attributes},e.node.map(f=>{const[p,b,w]=f,h=t.nonScalingStroke?{[o("vector-effect")]:"non-scaling-stroke",...b}:b;return w?[p,h,w]:[p,h]})]}function _i(e,t={}){return $i(e,{...t,attributeNames:{...t.attributeNames,class:"className","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","vector-effect":"vectorEffect"}})}const Ri=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1},Wi=g.createContext({}),Pi=()=>g.useContext(Wi),Fi=g.forwardRef(({color:e,size:t,width:s,height:o,strokeWidth:r,absoluteStrokeWidth:a,nonScalingStroke:i,className:l="",children:d,iconNode:c=[],icon:u={node:c,aliases:[],size:24},...m},f)=>{const{size:p=24,strokeWidth:b=2,absoluteStrokeWidth:w=!1,nonScalingStroke:h=!1,color:N="currentColor",className:y=""}=Pi()??{},v=!!d||Ri(m),[k,E,I=[]]=_i(u,{color:e??N,width:s??t??p,height:o??t??p,strokeWidth:r??b,absoluteStrokeWidth:a??w,nonScalingStroke:i??h,className:fn(y,l),hasA11yProp:v,attributes:m});return g.createElement(k,{ref:f,...E},[...I.map(([M,x])=>g.createElement(M,x)),...Array.isArray(d)?d:[d]])});function xe(e,t=[],s=[]){const o=typeof e=="string"?Ci(e,t,s):e,r=g.forwardRef(({className:a,...i},l)=>g.createElement(Fi,{ref:l,icon:o,className:a,...i}));return o.name&&(r.displayName=Oi(o.name)),r}const Lo={name:"arrow-down",size:24,node:[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]};Lo.node;const zi=xe(Lo);const Oo={name:"arrow-left",size:24,node:[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]};Oo.node;const Di=xe(Oo);const $o={name:"arrow-right",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]};$o.node;const Ui=xe($o);const _o={name:"arrow-up",size:24,node:[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]};_o.node;const Hi=xe(_o);const Ro={name:"circle-alert",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],aliases:["alert-circle"]};Ro.node;const Bi=xe(Ro);const Wo={name:"command",size:24,node:[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]]};Wo.node;const Gi=xe(Wo);const Po={name:"info",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]};Po.node;const Ki=xe(Po);const Fo={name:"search",size:24,node:[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]};Fo.node;const zo=xe(Fo);const Do={name:"x",size:24,node:[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]};Do.node;const Vi=xe(Do),Yi={info:{box:"bg-fill-quiet inset-ring inset-ring-hairline",icon:"text-ink-muted",Icon:Ki},error:{box:"bg-fill-selected inset-ring inset-ring-rule-strong shadow-edge",icon:"text-ink",Icon:Bi}};function U({tone:e="info",title:t,children:s,action:o,className:r}){const{box:a,icon:i,Icon:l}=Yi[e];return n.jsxs("div",{"data-slot":"callout","data-tone":e,role:e==="info"?"status":"alert",className:j("flex items-start gap-3 rounded-inner px-4 py-3",a,r),children:[n.jsx(l,{"aria-hidden":!0,className:j("mt-px size-4.5 shrink-0",i),strokeWidth:1.75}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("p",{className:"text-row font-semibold text-ink",children:t}),s&&n.jsx("div",{className:"mt-0.5 text-body wrap-break-word text-ink-secondary",children:s})]}),o&&n.jsx("div",{className:"shrink-0 self-center",children:o})]})}function Ne({children:e,className:t}){return n.jsx("dl",{"data-slot":"fact-list",className:j("flex flex-col",t),children:e})}function B({label:e,children:t,mono:s=!1,note:o}){return n.jsxs("div",{"data-slot":"fact-row",className:j("items-baseline border-b border-hairline py-2.5 last:border-b-0",o===void 0?"flex justify-between gap-6":"grid grid-cols-[auto_minmax(0,1fr)] gap-x-6"),children:[n.jsx("dt",{className:"shrink-0 text-body text-ink-secondary",children:e}),n.jsx("dd",{className:j("min-w-0 text-right text-pretty text-ink",s?"font-mono text-fact":"text-body font-medium"),children:t}),o!==void 0&&n.jsx("dd",{"data-part":"note",className:"col-span-2 mt-1 text-caption text-ink-secondary",children:o})]})}const qi=["claude"],Ji=new RegExp([String.raw`\b[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)+\b`,String.raw`\bPATH\b`,String.raw`(?<![\w.:/~])(?:~|\.{1,2})?(?:/[\w.@%+~-]+)+/?`,String.raw`\b[A-Za-z]:\\[^\s,;]+`,String.raw`\b(?:${qi.join("|")})\b(?![\w-]|\.\w)(?:(?: [a-z][\w-]*)*(?: --?[a-z][\w-]*)+)?`,String.raw`(?<![\w-])--[a-z][\w-]*`].join("|"),"g"),Xi=/[.,;:!?]+$/;function Zi(e){const t=[],s=(r,a)=>{if(r==="")return;const i=t[t.length-1];i&&i.fact===a?i.text+=r:t.push({text:r,fact:a})};let o=0;for(const r of e.matchAll(Ji)){const a=r.index,i=r[0].replace(Xi,"");i!==""&&(s(e.slice(o,a),!1),s(i,!0),o=a+i.length)}return s(e.slice(o),!1),t}function ue({children:e}){return n.jsx(n.Fragment,{children:Zi(e).map((t,s)=>t.fact?n.jsx("code",{"data-slot":"fact",className:"font-mono text-fact",children:t.text},s):t.text)})}const Qi=["terminal","vscode","desktop","cloud","browser","unknown"],el={terminal:"Terminal",vscode:"VS Code",desktop:"Desktop app",cloud:"Cloud",browser:"Browser"};function Ft(e){return e==="unknown"?null:el[e]}const Lt=["needs-you","working","idle","finished","failed","unknown"],tl=["permission","question","other"],In=["Terminal","iTerm2"],nl=["ok","searching","unavailable","not-set-up","error"],Uo={ok:"Watching",searching:"Searching",unavailable:"Not found","not-set-up":"Not set up",error:"Not working"},Qe=["working-and-idle","needs-you","finished","failed","names","jump","quiet-for"],Ho={"working-and-idle":"Working and idle","needs-you":"Needs you",finished:"Finished",failed:"Failed",names:"Names",jump:"Jump","quiet-for":"Quiet for"},hn={yes:"Yes",no:"No",partly:"Partly"},sl=["appeared","status-changed","ended"],ol=["advisory","warning","critical"];function rl(e){if(e.waitingText===void 0)return e;const{waitingText:t,...s}=e;return s}function al(e,t){return e.agent??t.find(s=>s.id===e.source)?.label??null}const il=new Map;function ll(e,t){return e===null?t:t===null?e:t>e?t:e}function cl(e,t){const s=new Map;for(const i of t.sources)(i.state==="ok"||i.state==="not-set-up")&&s.set(i.id,new Map);const o=[],r=[];for(const i of t.sessions){if(i.status!=="needs-you")continue;const l=s.get(i.source);if(!l||l.has(i.id))continue;const d=e.get(i.source);if(!d?.has(i.id)){d&&o.push(i),l.set(i.id,i.statusSince);continue}const c=d.get(i.id)??null,u=i.statusSince;c!==null&&u!==null&&u>c&&(r.push(i.id),o.push(i)),l.set(i.id,ll(c,u))}const a=new Map(e);for(const[i,l]of s){for(const d of e.get(i)?.keys()??[])l.has(d)||r.push(d);a.set(i,l)}return{memory:a,started:o,stopped:r}}const Be=["needs-you","finished","failed","ended"],pn=["needs-you"];function dl(e){return Be.includes(e)}function ul(e){const t=e.trim().toLowerCase();if(t==="")return[];const s=t.split(",").map(o=>o.trim());return s.every(dl)?Be.filter(o=>s.includes(o)):null}function ot(e){return Be.filter(t=>e.includes(t)).join(",")}const js={waits:il,seen:new Map,over:new Map};function vt(e){return e==="finished"||e==="failed"}function ml(e,t){return t===void 0?!1:e==="ended"||t==="ended"||t===e}function fl(e,t){const s=cl(e.waits,t),o=new Set(s.started),r=new Map;for(const u of t.sources)(u.state==="ok"||u.state==="not-set-up")&&r.set(u.id,{basis:u.basis??"",sessions:new Map});const a=[];for(const u of t.sessions){const m=r.get(u.source);if(!m||m.sessions.has(u.id))continue;if(m.sessions.set(u.id,rl(u)),o.has(u)){a.push({event:"needs-you",session:u});continue}const f=e.seen.get(u.source)?.get(m.basis)?.get(u.id);f&&f.status!==u.status&&vt(u.status)&&a.push({event:u.status,session:u})}for(const[u,{basis:m,sessions:f}]of r)for(const[p,b]of e.seen.get(u)?.get(m)??[])!f.has(p)&&!vt(b.status)&&a.push({event:"ended",session:b});const i=new Map;for(const[u,{sessions:m}]of r){const f=new Map(e.over.get(u));for(const[p,b]of m)vt(b.status)||f.delete(p);i.set(u,f)}const l=a.filter(({event:u,session:m})=>{const f=i.get(m.source);return u==="needs-you"||!f?!0:ml(u,f.get(m.id))?!1:(f.set(m.id,u),!0)}),d=new Map(e.seen),c=new Map(e.over);for(const[u,{basis:m,sessions:f}]of r){const p=new Map(e.seen.get(u));p.set(m,f),d.set(u,p);const b=i.get(u);for(const[w,h]of f)vt(h.status)&&!b.has(w)&&b.set(w,h.status);for(const w of b.keys())[...p.values()].some(h=>h.has(w))||b.delete(w);c.set(u,b)}return{memory:{waits:s.memory,seen:d,over:c},changes:l,stopped:s.stopped}}const hl=["started","cleared","trimmed"],pl="clear-history",xl=6e4,gl=1e3,zt="X-Agent-Lookout-Action",wl=200,bl="X-Agent-Lookout-Notifications";function Bo(e){const t=ot(e);return t===""?"off":t===ot(pn)?"on":`on; events=${t}`}const Ot=20,yl=/^(?:[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)*\.?|\[[0-9A-Fa-f:.]+\])$/,kl=253;function jl(e){return e.length<=kl&&yl.test(e)}const Nl=900*1e3;function fe(e){return e.since??{at:e.startedAt,by:"started"}}function tn(){return typeof window>"u"?null:window.Notification??null}const Go={permission(){const e=tn();if(!e)return"unsupported";const{permission:t}=e;return t==="granted"||t==="denied"?t:"default"},requestPermission(){const e=tn();return e?new Promise(t=>{const s=()=>t(Go.permission());try{e.requestPermission(s)?.then(s,s)}catch{s()}}):Promise.resolve("unsupported")},show({title:e,body:t,tag:s}){const o=tn();if(!o)return null;try{const r=new o(e,{body:t,tag:s});return r.addEventListener("click",()=>window.focus()),{close(){try{r.close()}catch{}},onClosed(a){r.addEventListener("close",a)}}}catch{return null}}};let vl=Go;function Cn(){return vl}const Ln="agent-lookout-notifications",On="agent-lookout-notification-events";function Ko(){try{return localStorage.getItem(Ln)==="on"?"on":"off"}catch{return"off"}}function Vo(){try{const e=localStorage.getItem(On);return(e===null?null:ul(e))??pn}catch{return pn}}let De=null,Te=null,_e=null,xn=null,nn=null;const qe=new Set;let et=null;function dt(){De??=Ko(),Te??=Vo();const e=Cn().permission();return(!_e||_e.choice!==De||_e.permission!==e||_e.events!==Te)&&(_e={choice:De,permission:e,on:De==="on"&&e==="granted",events:Te}),_e}function $n(){const e=dt();return e.on?e.events:[]}function we(){const e=dt();if(e!==xn){xn=e;for(const t of qe)t()}}function Yo(e){De=e;try{localStorage.setItem(Ln,e)}catch{}}function Sl(){if(et)return;const e=t=>{if((t.key===null||t.key===Ln)&&(De=Ko()),t.key===null||t.key===On){const s=Vo();(Te===null||ot(s)!==ot(Te))&&(Te=s)}we()};window.addEventListener("storage",e),window.addEventListener("focus",we),document.addEventListener("visibilitychange",we),et=()=>{window.removeEventListener("storage",e),window.removeEventListener("focus",we),document.removeEventListener("visibilitychange",we)}}function qo(e){return qe.size===0&&(xn=dt()),qe.add(e),Sl(),()=>{qe.delete(e),qe.size===0&&et&&(et(),et=null)}}async function Al(){const e=Cn();let t=e.permission();if(t==="default")try{t=await e.requestPermission()}catch{t=e.permission()}t==="granted"&&Yo("on"),we()}function El(){return nn??=Al().finally(()=>{nn=null}),nn}function Ml(){Yo("off"),we()}function Tl(e,t){const s=dt().events;if(s.includes(e)===t)return;const o=Be.filter(r=>r===e?t:s.includes(r));Te=o;try{localStorage.setItem(On,ot(o))}catch{}we()}const Il=(e,t)=>fetch(e,t);let Cl=Il;const Ns="http://app.invalid";function Ll(e){if(!e.startsWith("/"))return!1;try{return new URL(e,Ns).origin===Ns}catch{return!1}}function Ol(){return Bo($n())}function re(e,t){if(!Ll(e))return Promise.reject(new TypeError(`apiRequest takes a path on this app's own server, not ${JSON.stringify(e)}.`));const s=new Headers(t?.headers);return s.set(bl,Ol()),Cl(e,{...t,headers:s})}const Jo=(e,t)=>{const s=setInterval(e,t);return()=>clearInterval(s)},$l=1e4,_l=5,Rl=(e,t)=>{let s=null,o=null,r=!1,a=!1,i;const l=()=>{clearTimeout(i),s?.terminate(),s=null,!(r||o)&&(o=Jo(e,t))};try{s=new Worker(new URL("/assets/beatWorker-zHI4d3P9.js",import.meta.url),{type:"module"}),s.addEventListener("message",()=>{a=!0,e()}),s.addEventListener("error",l),s.postMessage(t),i=setTimeout(()=>{a||l()},Math.max($l,t*_l))}catch{l()}return()=>{r=!0,clearTimeout(i),s?.terminate(),s=null,o?.(),o=null}},He=6e4;function gp(e,t){return e.map(s=>({at:s.at,value:s[t]}))}const wp=[{id:"15m",label:"15 min",ms:15*He,words:"the last 15 minutes"},{id:"1h",label:"1 hour",ms:60*He,words:"the last hour"},{id:"6h",label:"6 hours",ms:360*He,words:"the last 6 hours"}],Wl=[1,2,5,10,20,25,50,100,200,250,500,1e3];function Pl(e){const t=Math.max(1,Math.ceil(e)),s=Wl.find(a=>t/a<=4)??Math.ceil(t/4),o=Math.ceil(t/s)*s,r=[];for(let a=0;a<=o;a+=s)r.push(a);return{ceiling:o,ticks:r}}const Fl=[1,2,5,10,15,30,60,120,180,360];function Xo(e,t,s){const o=t-e;if(o<=0||s<1)return[];const r=(Fl.find(l=>o/(l*He)<=s)??720)*He,a=new Date(e).getTimezoneOffset()*He,i=[];for(let l=Math.ceil((e-a)/r)*r+a;l<=t;l+=r)i.push(l);return i}function zl(e,t){if(!t)return e;if(Zo(e,t))return t;const s=t.points[0];if(!s||t.startedAt!==e.startedAt)return e;const o=e.points.filter(r=>r.at<s.at);return{...t,startedAt:e.startedAt,points:[...o,...t.points]}}function Zo(e,t){const s=fe(t);return s.by==="cleared"&&s.at!==fe(e).at}const _n=200;function R(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function $(e){return typeof e=="string"&&e.trim()!==""?e:null}function _(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function Q(e,t){return e.includes(t)?t:null}function gn(e,t){const s=new Set,o=[];for(const r of e){const a=t(r);!a||s.has(a.id)||(s.add(a.id),o.push(a))}return o}function Dl(e){if(!R(e))return null;const t=$(e.id),s=$(e.source);if(!t||!s)return null;const o=$(e.project),r=Q(Lt,e.status)??"unknown",a={id:t,source:s,surface:Q(Qi,e.surface)??"unknown",name:$(e.name)??o??t,cwd:$(e.cwd),project:o,status:r,startedAt:_(e.startedAt),statusSince:_(e.statusSince),links:{},stale:e.stale===!0};if(r==="needs-you"){const m=Q(tl,e.waitingReason);m&&(a.waitingReason=m);const f=$(e.waitingDetail);f&&(a.waitingDetail=f);const p=$(e.waitingText);p&&(a.waitingText=p)}const i=$(e.agent);i&&(a.agent=i);const l=_(e.lastWriteAt);l!==null&&(a.lastWriteAt=l);const d=_(e.pid);if(d!==null&&(a.pid=d),typeof e.alive=="boolean"&&(a.alive=e.alive),R(e.links)){const m=$(e.links.open);m&&(a.links.open=m)}const c=ql(e.jump);c&&(a.jump=c);const u=Gl(e.git);return u&&(a.git=u),a}const Ul=_n,Hl=/^[0-9a-f]{7,64}$/,Bl=/^[0-9a-f]{16,64}$/;function Gl(e){if(!R(e))return null;const t=Kl(e);if(t===null)return null;const s=Vl(e.repository);return s===null?t:{...t,repository:s}}function Kl(e){if(e.commit===void 0){const s=$(e.branch);return s!==null&&Array.from(s).length<=Ul?{branch:s}:null}if(e.branch!==void 0)return null;const{commit:t}=e;return typeof t=="string"&&Hl.test(t)?{commit:t}:null}function Vl(e){if(!R(e))return null;const t=$(e.name);if(t===null||Array.from(t).length>_n)return null;const{id:s}=e;return typeof s=="string"&&Bl.test(s)?{id:s,name:t}:null}const Yl=200;function ql(e){if(!R(e))return null;const t=$(e.place);if(!t||t.length>Yl)return null;if(e.kind==="tmux")return{kind:"tmux",place:t};const s=e.kind==="terminal"?Q(In,e.app):null;return s?{kind:"terminal",app:s,place:t}:null}function Jl(e,t){if(!R(e))return null;const s=$(e.id);if(!s)return null;const o={id:s,label:$(e.label)??s,state:Q(nl,e.state)??"error",checkedAt:_(e.checkedAt)??t},r=$(e.detail);if(r&&(o.detail=r),Array.isArray(e.watching)){const d=[];for(const c of e.watching){const u=Ql(c);u&&d.push(u)}o.watching=d}const a=$(e.advice);a&&(o.advice=a);const i=$(e.basis);i&&(o.basis=i);const l=Zl(e.capabilities);return l&&(o.capabilities=l),o}function Xl(e){if(!R(e))return null;if(e.level==="yes")return{level:"yes"};const t=Q(["no","partly"],e.level),s=$(e.reason);return t&&s?{level:t,reason:s}:null}function Zl(e){if(!R(e))return null;const t={};for(const s of Qe){const o=Xl(e[s]);if(!o)return null;t[s]=o}return t}function Ql(e){if(!R(e))return null;const t=$(e.label),s=$(e.value);return t&&s?{label:t,value:s}:null}function ec(e){if(!R(e)||!Array.isArray(e.sessions)||!Array.isArray(e.sources))return null;const t=_(e.generatedAt);return t===null?null:{generatedAt:t,sources:gn(e.sources,s=>Jl(s,t)),sessions:gn(e.sessions,Dl)}}function tc(e){if(!R(e))return null;const t=$(e.id),s=_(e.at);if(!t||s===null)return null;const o=$(e.sessionId)??"",r={id:t,at:s,sessionId:o,sessionName:$(e.sessionName)??(o||"A session"),kind:Q(sl,e.kind)??"status-changed",severity:Q(ol,e.severity)??"advisory"},a=Q(Lt,e.from);a&&(r.from=a);const i=Q(Lt,e.to);return i&&(r.to=i),r}function nc(e){return!R(e)||!Array.isArray(e.events)?null:gn(e.events,tc)}function sc(e){if(!R(e))return null;const t=_(e.at),s=_(e.needsYou),o=_(e.working),r=_(e.idle),a=_(e.total);return t===null||s===null||o===null||r===null||a===null?null:{at:t,needsYou:s,working:o,idle:r,total:a}}function Qo(e){if(!R(e))return null;const t=_(e.at),s=Q(hl,e.by);return t===null||s===null?null:{at:t,by:s}}const oc=1024;function vs(e){const t=$(e);return t&&t.length<=oc?t:null}function de(e){const t=_(e);return t!==null&&t>=0&&Number.isInteger(t)?t:null}function rc(e){if(!R(e))return null;const t=Q(["disk","memory"],e.where),s=de(e.maxBytes),o=de(e.maxAgeMs);if(t===null||s===null||o===null)return null;const r=t==="disk"?vs(e.folder):null;return t==="disk"&&r===null?null:{where:t,folder:r,bytes:t==="disk"?de(e.bytes):null,maxBytes:s,maxAgeMs:o,canClear:t==="disk"&&e.canClear===!0,problem:vs(e.problem)}}const ac=1e3;function ic(e){if(!R(e))return null;const t=_(e.at),s=_(e.lastBefore);return t===null||s===null||s>=t?null:{at:t,lastBefore:s}}function lc(e){if(!Array.isArray(e))return[];const t=[];for(const s of e.slice(0,ac)){const o=ic(s);o&&t.push(o)}return t.sort((s,o)=>s.at-o.at)}function cc(e){if(!R(e)||!Array.isArray(e.points))return null;const t=_(e.startedAt);if(t===null)return null;const s=[];for(const i of e.points){const l=sc(i);l&&s.push(l)}const o=Qo(e.since),r=rc(e.kept),a=lc(e.restarts);return{points:s,startedAt:t,...o!==null&&{since:o},...r!==null&&{kept:r},...a.length>0&&{restarts:a}}}const Ss=50;function er(e){const t=de(e.waitedMs),s=de(e.openMs),o=de(e.waits),r=de(e.measuredMs);return t===null||s===null||o===null||r===null?null:{waitedMs:t,openMs:Math.min(s,t),waits:o,measuredMs:r}}function dc(e){if(!R(e))return null;const t=$(e.day),s=_(e.from),o=_(e.to),r=er(e);return t===null||!/^\d{4}-\d{2}-\d{2}$/.test(t)||s===null||o===null?null:r&&o>=s?{day:t,from:s,to:o,...r}:null}function uc(e){if(!R(e))return null;const t=$(e.sessionId),s=de(e.waitedMs),o=de(e.waits);if(t===null||s===null||o===null)return null;const r=$(e.name);return{sessionId:t,name:r!==null&&Array.from(r).length<=_n?r:t,waitedMs:s,waits:o,open:e.open===!0}}function As(e){if(!R(e)||!Array.isArray(e.days)||!Array.isArray(e.sessions))return null;const t=_(e.from),s=_(e.to),o=er(e),r=de(e.sessionCount);if(t===null||s===null||s<t||o===null||r===null)return null;const a=[];for(const d of e.days.slice(0,Ss)){const c=dc(d);c&&a.push(c)}const i=[],l=new Set;for(const d of e.sessions.slice(0,Ss)){const c=uc(d);!c||l.has(c.sessionId)||(l.add(c.sessionId),i.push(c))}return{from:t,to:s,...o,days:a.sort((d,c)=>d.from-c.from),sessions:i.sort((d,c)=>c.waitedMs-d.waitedMs),sessionCount:Math.max(r,i.length)}}function mc(e){if(!R(e))return null;const t=_(e.at),s=As(e.today),o=As(e.sevenDays),r=Qo(e.since),a=Q(["disk","memory"],e.where);return t===null||!s||!o||!r||!a?null:{at:t,today:s,sevenDays:o,since:r,where:a}}const fc=300;function rt(e){const t=$(e);return t&&t.length<=fc?t:null}function tr(e,t){if(!R(e))return null;const s=_(e.at);return s===null?null:e.sent===!0?{at:s,sent:!0}:{at:s,sent:!1,reason:rt(e.reason)??t}}function nr(e){if(!Array.isArray(e))return null;const t=e.filter(o=>typeof o=="string"),s=Be.filter(o=>t.includes(o));return s.length>0?s:null}function hc(e){if(!R(e)||typeof e.on!="boolean")return null;const t=rt(e.to),s=nr(e.events),o=_(e.afterMs),r=e.on&&t!==null&&s!==null&&o!==null&&o>=0;return{on:r,to:r?t:null,events:r?s:null,afterMs:r?o:null,asking:r?e.asking===!0:null,problem:r?null:rt(e.problem),last:r?tr(e.last,"the email could not be sent"):null,limitedUntil:r?_(e.limitedUntil):null}}function pc(e){if(!R(e)||typeof e.on!="boolean")return null;const t=rt(e.host),s=nr(e.events),o=_(e.afterMs),r=e.on&&t!==null&&jl(t)&&s!==null&&o!==null&&o>=0;return{on:r,host:r?t:null,events:r?s:null,afterMs:r?o:null,asking:r?e.asking===!0:null,problem:r?null:rt(e.problem),last:r?tr(e.last,"the post could not be sent"):null,limitedUntil:r?_(e.limitedUntil):null}}const sr=2e3,xc=4e3,Es=5e3,Ms=Nl,Ts=3600*1e3,gc=60*1e3,Dt=wl,wc=2,bc={phase:"connecting",snapshot:null,events:[],history:null,lastOkAt:null,problem:null,problemKind:null};class Ie extends Error{kind;constructor(t,s){super(s),this.kind=t}}async function Mt(e){let t;try{t=await re(e,{headers:{accept:"application/json"},signal:AbortSignal.timeout(xc)})}catch(s){const o=s instanceof DOMException&&s.name==="TimeoutError";throw new Ie("no-answer",o?"The local server took too long to answer.":"The local server did not answer.")}if(!t.ok)throw new Ie("error-status",`The local server answered ${e} with error ${t.status}.`);try{return await t.json()}catch{throw new Ie("not-data",`The local server answered ${e} with something that is not data.`)}}function yc(e){const t=ec(e);if(!t)throw new Ie("not-data","The local server sent session data in a shape this page cannot read.");return t}function kc(e){const t=nc(e);if(!t)throw new Ie("not-data","The local server sent events in a shape this page cannot read.");return t}function or(e){const t=cc(e);if(!t)throw new Ie("not-data","The local server sent history in a shape this page cannot read.");return t}function bp(e){return Mt(`/api/history?windowMs=${Math.round(e)}`).then(or)}function jc(e,t){if(t.length===0)return e;const s=new Set(e.map(r=>r.id)),o=t.filter(r=>!s.has(r.id));return o.length===0?e:[...o,...e].sort((r,a)=>a.at-r.at).slice(0,Dt)}function Nc(e={}){const t=e.now??Date.now,s=e.intervalMs??sr,o=e.beat??Jo,r=new Set;let a=bc,i=null,l=!1,d=0,c=null;function u(b){a=b;for(const w of r)w()}async function m(){if(!l){l=!0;try{const b=a.events[0]?.at??0,w=t(),h=c===null||w-c>Ms-Es,[N,y,v]=await Promise.allSettled([Mt("/api/sessions").then(yc),Mt(`/api/events?since=${b}`).then(kc),Mt(`/api/history?windowMs=${h?Ts:Ms}`).then(or)]);let k=a;if(v.status==="fulfilled"){const E=a.history!==null&&(a.history.startedAt!==v.value.startedAt||Zo(a.history,v.value));let I;h?(I=v.value,c=w):E||a.history===null?(I=v.value,c=null):(I=zl(a.history,v.value),c=w);const M=t()-Ts-gc;k={...k,history:{...I,points:I.points.filter(x=>x.at>=M)},events:E?[]:k.events}}if(y.status==="fulfilled"&&(k={...k,events:jc(k.events,y.value)}),N.status==="fulfilled")d=0,k={...k,phase:"live",snapshot:N.value,lastOkAt:t(),problem:null,problemKind:null};else{d+=1;const E=N.reason,I=E instanceof Ie?E:null,M=I?.message??"The local server did not answer.",x=I?.kind??"no-answer";let O;k.snapshot!==null&&k.lastOkAt!==null?O=t()-k.lastOkAt>Es?"stalled":k.phase:O=d>=wc?"unreachable":"connecting",k={...k,phase:O,problem:M,problemKind:x}}u(k)}finally{l=!1}}}function f(){i===null&&(m(),i=o(()=>{m()},s))}function p(){i!==null&&(i(),i=null)}return{subscribe(b){return r.add(b),f(),()=>{r.delete(b),r.size===0&&p()}},getState:()=>a,refresh:()=>{m()}}}const wn=1e3,Je=60*wn,Xe=60*Je,sn=24*Xe;function tt(e){return String(e).padStart(2,"0")}function ut(e){const t=Math.max(0,Math.floor(e));return t<Je?[{value:String(Math.floor(t/wn)),unit:"s"}]:t<Xe?[{value:String(Math.floor(t/Je)),unit:"m"},{value:tt(Math.floor(t%Je/wn)),unit:"s"}]:t<sn?[{value:String(Math.floor(t/Xe)),unit:"h"},{value:tt(Math.floor(t%Xe/Je)),unit:"m"}]:[{value:String(Math.floor(t/sn)),unit:"d"},{value:tt(Math.floor(t%sn/Xe)),unit:"h"}]}function rr(e){return e.map(t=>`${t.value}${t.unit}`).join(" ")}function z(e){return rr(ut(e))}const vc={s:"second",m:"minute",h:"hour",d:"day"};function ar(e){return e.filter((s,o)=>o===0||Number(s.value)!==0).map(s=>{const o=Number(s.value);return`${o} ${vc[s.unit]}${o===1?"":"s"}`}).join(" ")}function pe(e){return ar(ut(e))}function H(e){const t=new Date(e);return`${tt(t.getHours())}:${tt(t.getMinutes())}`}function Y(e){const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}const Sc=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric"}),Ac=new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric"});function Rn(e,t){return(new Date(e).getFullYear()===new Date(t).getFullYear()?Sc:Ac).format(new Date(e))}function se(e,t){const s=H(e);return Y(e)===Y(t)?s:`${s} on ${Rn(e,t)}`}const Ec=1e3;function ye(e){return e.charAt(0).toUpperCase()+e.slice(1)}function on(e){return String(e).padStart(2,"0")}function ir(e){const t=ut(e),s=t[0];return s&&(s.unit==="m"||s.unit==="d")?[s]:t}function $t(e){return rr(ir(e))}function at(e){return ar(ir(e))}function Wn(e){return e<Ec?"just now":`${z(e)} ago`}function oe(e){const t=new Date(e);return`${on(t.getHours())}:${on(t.getMinutes())}:${on(t.getSeconds())}`}const Mc=new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric"});function Tc(e,t){const s=new Date(e),o=new Date(t);return s.getFullYear()===o.getFullYear()&&s.getMonth()===o.getMonth()&&s.getDate()===o.getDate()}function Pn(e){return`${Mc.format(new Date(e))} ${oe(e)}`}function lr(e,t){return Tc(e,t)?oe(e):Pn(e)}const cr="status-files";function Ic(e){return e.id===cr?"status files":e.label}function Fe(e){const t=e.map(Ic);return t.length===0?"your agent tools":t.length===1?t[0]??"":`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}function dr(e){return e.state!=="unavailable"&&e.state!=="not-set-up"}function Cc(e){const t=e.filter(o=>o.state!=="not-set-up"),s=t.filter(dr);return s.length>0?s:t}function ur(e,t=[]){const s=new Set;for(const o of e)dr(o)&&o.id!==cr&&s.add(o.label);for(const o of t)o.agent!==void 0&&s.add(o.agent);return s.size>1}function Fn(e,t){return al(e,t)??e.source}const Lc=/^vscode:\/\/anthropic\.claude-code\/open\?session=[A-Za-z0-9\-_.!~*'()%]{1,200}$/,zn={"needs-you":"Needs you",working:"Working",idle:"Idle",finished:"Finished",failed:"Failed",unknown:"Unknown"};function Oc(e){const t=e.waitingDetail?.trim();return!t||e.waitingReason==="permission"&&/^permission prompt$/i.test(t)||e.waitingReason==="question"&&/^input needed$/i.test(t)?null:t}const it="stopped waiting after";function mr(e,t=null){if(e.kind==="appeared")return"appeared";if(e.kind==="ended")return"ended";if(e.from==="needs-you"&&e.to!=="needs-you"&&t!==null)return`${it} ${z(t)}`;switch(e.to){case"needs-you":return"started waiting";case"working":return"started working";case"idle":return"went idle";case"finished":return"finished";case"failed":return"failed";default:return"changed status"}}const Is={"claude-code":Lc};function $c(e){const t=e.links.open;return typeof t!="string"?null:(Object.hasOwn(Is,e.source)?Is[e.source]:void 0)?.test(t)?t:null}function ke(e){const t=$c(e);return t!==null?{by:"link",href:t,where:Ft(e.surface)??"its app"}:e.jump?.kind==="tmux"?{by:"tmux",where:`tmux, ${e.jump.place}`}:e.jump?.kind==="terminal"?{by:"terminal",app:e.jump.app,where:e.jump.place}:null}const _c={ok:"Last known: watching",searching:"Last known: searching",unavailable:"Last known: not found","not-set-up":"Last known: not set up",error:"Last known: not working"};function fr(e){return Object.hasOwn(Uo,e)?e:"error"}function Rc(e,t){const s=fr(e.state);return{key:e.id,name:e.label,state:t?_c[s]:Uo[s]}}const Wc=[["vscode","VS Code"],["desktop","the desktop app"],["terminal","a terminal"],["cloud","the cloud"],["browser","a browser"],["unknown","another app"]];function Pc(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function Fc(e){const t=new Set(e.map(s=>s.surface));return t.size===1&&t.has("unknown")?"":Pc(Wc.filter(([s])=>t.has(s)).map(([,s])=>s))}function Ke(e,t){return e.filter(s=>fr(s.state)===t)}function zc(e,t,s,o=null){if(e==="connecting")return{key:"connecting",text:"Connecting to the local server",short:"Connecting",fact:null};if(e==="unreachable")return{key:"not-connected",text:"Not connected to the local server",short:"Not connected",fact:null};if(e==="stalled")return{key:"not-updating",text:"Not updating",short:"Not updating",fact:o===null?null:{text:`since ${oe(o)}`,ticking:!1}};const r=(t?.sources??[]).filter(f=>f.state!=="not-set-up"),a=t?.sessions??[];if(r.length===0)return{key:"no-sources",text:"Not watching any agent tool",short:"Not watching",fact:null};const i=Math.max(...r.map(f=>f.checkedAt)),l={text:`checked ${Wn(s-i)}`,ticking:!0};if(a.length>0){const f=`${a.length} ${a.length===1?"session":"sessions"}`,p=Ke(r,"ok"),b=Fc(a),w=p.length>1?` from ${Fe(p)}`:b?` in ${b}`:"";return{key:"watching",text:`Watching ${f}${w}`,short:f,fact:l}}const d=Ke(r,"searching");if(d.length>0)return{key:"searching",text:`Looking for ${Fe(d)} sessions`,short:"Looking for sessions",fact:l};const c=Ke(r,"ok");if(c.length>0)return{key:"none-running",text:`Watching ${Fe(c)}, no sessions running`,short:"No sessions",fact:l};const u=Ke(r,"error");if(u.length>0)return{key:"not-working",text:`${ye(Fe(u))} could not be read`,short:u.length===1?"Source not working":"Sources not working",fact:l};const m=Ke(r,"unavailable");return{key:"not-found",text:`${ye(Fe(m))} ${m.length===1?"was":"were"} not found`,short:m.length===1?"Source not found":"Sources not found",fact:l}}function hr(e){switch(e){case"error-status":return"Agent Lookout answered with an error";case"not-data":return"The answer was not session data";default:return"Agent Lookout is not answering"}}const Dc=sr/1e3;function Uc({lastOkAt:e,now:t,onRetry:s}){return n.jsx(U,{tone:"error",title:"Agent Lookout has stopped updating",action:n.jsx(J,{size:"sm",onClick:s,children:"Try now"}),children:n.jsxs("p",{children:["This is what it last saw, at"," ",n.jsxs("span",{className:"tabular-nums",children:[oe(e),n.jsxs("span",{"data-part":"age","aria-hidden":!0,"aria-live":"off",children:[" ","(",Wn(t-e),")"]})]}),". Check that it is still running in your terminal. The page keeps trying and catches up on its own."]})})}const Cs="font-mono text-fact";function pr({kind:e}){return e==="error-status"?n.jsx("p",{children:"Its local server is running. Restart Agent Lookout in your terminal, and open the address it prints."}):e==="not-data"?n.jsxs("p",{children:["This page is being served without its collector. Start Agent Lookout with"," ",n.jsx("code",{className:Cs,children:"npm start"})," or ",n.jsx("code",{className:Cs,children:"npm run dev"}),", and open the address it prints."]}):n.jsx("p",{children:"Check that Agent Lookout is still running in your terminal."})}function Hc({problem:e,kind:t,onRetry:s}){return n.jsxs("section",{"data-slot":"unreachable","data-kind":t??"no-answer","aria-label":"Connection problem",className:"glass-card mx-auto mt-10 w-full max-w-155 p-6 max-mid:p-5",children:[n.jsx(U,{tone:"error",title:hr(t),action:n.jsx(J,{size:"sm",onClick:s,children:"Try now"}),children:n.jsx(pr,{kind:t})}),n.jsxs(Ne,{className:"mt-3",children:[n.jsx(B,{label:"What happened",children:n.jsx(ue,{children:e??"The local server did not answer."})}),n.jsx(B,{label:"Asked for",mono:!0,children:"/api/sessions"}),n.jsx(B,{label:"Trying again",children:n.jsxs("span",{className:"tabular-nums",children:["every ",Dc,"s"]})})]})]})}function mt({title:e,children:t,visual:s,compact:o=!1,className:r}){return n.jsxs("div",{"data-slot":"empty-state",className:j("flex flex-col items-center text-center",o?"px-5 py-8":"px-5 py-14",r),children:[s&&n.jsx("div",{className:"mb-4",children:s}),n.jsx("p",{className:"text-title font-semibold text-ink",children:e}),t&&n.jsx("div",{className:"mt-1.5 max-w-[52ch] text-body text-ink-secondary",children:t})]})}function W({title:e,count:t,sub:s,aside:o,className:r,children:a,...i}){const l=g.useId();return n.jsxs("section",{"data-slot":"section-card","aria-labelledby":l,className:j("glass-card flex min-w-0 flex-col overflow-hidden",r),...i,children:[n.jsxs("header",{"data-part":"head",className:"flex items-baseline justify-between gap-x-4 gap-y-2 px-6 pt-5 pb-3 max-wide:flex-wrap",children:[n.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[n.jsx("h2",{id:l,className:"text-title font-semibold",children:e}),t!==void 0&&n.jsx("span",{"data-part":"count",className:"-ml-0.5 text-title font-medium text-ink-muted tabular-nums",children:t}),s!==void 0&&n.jsx("span",{"data-part":"sub",className:"text-caption text-ink-muted",children:s})]}),o!==void 0&&n.jsx("div",{"data-part":"aside",className:"min-w-0 text-caption text-ink-muted",children:o})]}),a]})}const Bc={...zn,stale:"Stale",answered:"Needed you, answered",ended:"Ended",lookout:"Agent Lookout"},Gc={"needs-you":"text-status-needs-you-edge",working:"text-status-working",idle:"text-status-idle",stale:"text-status-idle",unknown:"text-status-idle",answered:"text-status-idle",lookout:"text-status-idle",finished:"text-status-finished",failed:"text-status-finished",ended:"text-ink-muted"};function V({kind:e,labelled:t=!1,breathing:s=!1,unlit:o=!1,className:r}){const a=e==="needs-you",i=a&&!o;return n.jsxs("svg",{"data-slot":"status-mark","data-kind":e,"data-lit":a?i:void 0,"data-breathing":i&&s?!0:void 0,viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",className:j("size-mark shrink-0",a&&o?"text-ink":Gc[e],r),...t?{role:"img","aria-label":Bc[e]}:{"aria-hidden":!0},children:[(a||e==="answered")&&n.jsxs(n.Fragment,{children:[n.jsx("circle",{"data-part":"halo",cx:"7",cy:"7",r:"6",strokeWidth:"1.2",strokeOpacity:"0.5",className:j(i&&s&&"motion-safe:animate-lamp")}),n.jsx("circle",{"data-part":"lamp",cx:"7",cy:"7",r:"3.1",strokeWidth:i?1:1.3,className:j(i&&"fill-status-needs-you")})]}),e==="working"&&n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"7",cy:"7",r:"5",strokeWidth:"1.5"}),n.jsx("path",{d:"M7 2a5 5 0 0 1 0 10z",fill:"currentColor",stroke:"none"})]}),e==="idle"&&n.jsx("circle",{cx:"7",cy:"7",r:"5",strokeWidth:"1.5"}),e==="stale"&&n.jsx("circle",{cx:"7",cy:"7",r:"5",strokeWidth:"1.5",strokeDasharray:"2.62 2.62"}),e==="unknown"&&n.jsxs(n.Fragment,{children:[n.jsx("circle",{cx:"7",cy:"7",r:"5",strokeWidth:"1.5"}),n.jsx("path",{d:"M5 7h4",strokeWidth:"1.5",strokeLinecap:"round"})]}),e==="finished"&&n.jsx("path",{d:"M2.6 7.5l2.9 2.9 5.9-6.4",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"}),e==="failed"&&n.jsx("path",{d:"M3.8 3.8l6.4 6.4M10.2 3.8l-6.4 6.4",strokeWidth:"1.75",strokeLinecap:"round"}),e==="ended"&&n.jsx("path",{d:"M3.5 7h7",strokeWidth:"1.75",strokeLinecap:"round"}),e==="lookout"&&n.jsxs(n.Fragment,{children:[n.jsx("rect",{x:"2.5",y:"2.5",width:"9",height:"9",rx:"1.5",strokeWidth:"1.3"}),n.jsx("path",{d:"M5 11.2l6.2-6.2M2.8 9l6.2-6.2",strokeWidth:"1.1"})]})]})}const Kc=250,Vc=250;let bn=!1;typeof window<"u"&&window.addEventListener("scroll",()=>{bn=!0,setTimeout(()=>{bn=!1})},{capture:!0,passive:!0});function Z({content:e,children:t,mono:s=!1,enabled:o=!0,side:r="top",align:a="center"}){const[i,l]=g.useState(!1),d=g.useRef(-1/0),c=o&&e!==null&&e!==void 0&&e!=="";return n.jsx(Sa,{delayDuration:Kc,children:n.jsxs(Aa,{open:i&&c,onOpenChange:u=>{const m=bn&&performance.now()-d.current<Vc;!u&&m||l(u)},children:[n.jsx(Ea,{asChild:!0,onFocus:u=>{if(!u.currentTarget.matches(":focus-visible")){u.preventDefault();return}d.current=performance.now()},onBlur:()=>{d.current=-1/0},children:t}),n.jsx(Ma,{children:n.jsx(Ta,{"data-slot":"tooltip",side:r,align:a,sideOffset:6,collisionPadding:12,className:j("glass-float glass-blur z-60 max-w-[min(26rem,calc(100vw-1.5rem))] animate-in rounded-row","px-2.5 py-1.5 wrap-anywhere text-ink duration-120 fade-in-0",s?"font-mono text-fact":"text-caption font-medium"),children:e})})]})})}function Yc(e,t){if(e.scrollWidth>e.clientWidth)return!0;if(t===1)return!1;const s=Number.parseFloat(getComputedStyle(e).lineHeight),o=Number.isFinite(s)?s/2:1;return e.scrollHeight-e.clientHeight>o}function X({children:e,lines:t=1,tooltip:s,mono:o=!1,href:r,className:a,...i}){const l=g.useRef(null),[d,c]=g.useState(!1),u=s??(typeof e=="string"?e:"");g.useEffect(()=>{const f=l.current;if(!f)return;const p=new ResizeObserver(()=>c(Yc(f,t)));return p.observe(f),()=>p.disconnect()},[u,t]);const m=j(t===1?"truncate":"line-clamp-2","rounded-bar",a);return n.jsx(Z,{content:u,enabled:d,mono:o,children:r!==void 0?n.jsx("a",{ref:l,href:r,"data-cut":d,className:m,...i,children:e}):n.jsx("span",{ref:l,"data-cut":d,tabIndex:d?0:void 0,className:m,...i,children:e})})}const qc=8e3,Ls=.75,ft=qc;function Re(e){return Math.round(e*100)/100}function yp(e,t,s){const{start:o,end:r}=t,a=t.gapMs??ft,i=r-o,l=s.right-s.left,d=e.filter(E=>E.at>=o&&E.at<=r&&Number.isFinite(E.value)).sort((E,I)=>E.at-I.at);if(i<=0||d.length===0)return{lines:[],areas:[],unmeasured:[{x:s.left,width:l}],range:null,runs:[]};let c=1/0,u=-1/0;for(const E of d)E.value<c&&(c=E.value),E.value>u&&(u=E.value);const m=Math.max(1,s.ceiling??u),f=E=>Re(s.left+(E-o)/i*l),p=E=>Re(s.bottom-Math.min(E,m)/m*(s.bottom-s.top)),b=[];for(const E of d){const I=b[b.length-1],M=I?.[I.length-1];I&&M&&E.at-M.at<=a?I.push(E):b.push([E])}const w=[],h=[],N=[],y=[];b.forEach((E,I)=>{const M=E[0],x=E[E.length-1];if(!M||!x)return;const O=I===0&&M.at-o<=a?o:M.at,P=I===b.length-1&&r-x.at<=a?r:x.at,L=f(O),q=f(P);let Se=`M${L} ${p(M.value)}`,$e=M.value;for(const te of E)te.value!==$e&&(Se+=`H${f(te.at)}V${p(te.value)}`,$e=te.value);Se+=`H${q}`,w.push(Se),h.push(`${Se}V${s.bottom}H${L}Z`),N.push({x:L,width:q-L}),y.push({from:O,to:P,samples:E})});const v=[];let k=s.left;for(const E of N)E.x-k>=Ls&&v.push({x:Re(k),width:Re(E.x-k)}),k=Math.max(k,E.x+E.width);return s.right-k>=Ls&&v.push({x:Re(k),width:Re(s.right-k)}),{lines:w,areas:h,unmeasured:v,range:{min:c,max:u},runs:y}}function kp(e,t){for(const s of e){if(t<s.from||t>s.to)continue;let o=0,r=s.samples.length-1;for(;o<r;){const a=Math.ceil((o+r)/2);s.samples[a].at<=t?o=a:r=a-1}return s.samples[o]??null}return null}function Jc(e,t){const s=new Set(t.filter(i=>i.status==="needs-you").map(i=>i.id)),o=new Set,r=new Map,a=new Map;for(let i=e.length-1;i>=0;i-=1){const l=e[i];if(!l)continue;const d=r.get(l.sessionId);d&&a.set(l,d),r.set(l.sessionId,l)}return e.map(i=>{const l=!o.has(i.sessionId);if(o.add(i.sessionId),i.to==="needs-you"){const m=l&&s.has(i.sessionId);return{event:i,mark:m?"needs-you":"answered",open:m,waitedMs:null}}const d=a.get(i),c=i.from==="needs-you"&&d?.to==="needs-you"?i.at-d.at:null,u=i.to??(i.kind==="ended"?"ended":"unknown");return{event:i,mark:u,open:!1,waitedMs:c}})}function Xc(e,t,s){if(s){const r=e[e.length-1];return r?{at:r.at,started:!1}:null}if(!t)return null;const o=fe(t);return o.by==="trimmed"?{at:o.at,started:!1}:o.by==="cleared"?{at:o.at,started:!0,cleared:!0}:{at:o.at,started:!0}}function Zc(e,t=ft){if(!e)return[];const s=fe(e).at,o=(e.points??[]).map(a=>a.at).filter(a=>a>=s).sort((a,i)=>a-i),r=[];o.forEach((a,i)=>{const l=o[i-1];l!==void 0&&a-l>t&&r.push({at:a,unmeasuredMs:a-l,before:l})});for(const a of e.restarts??[])a.at<=s||r.some(l=>l.before<a.at&&a.at<=l.at)||r.push({at:a.at,unmeasuredMs:a.at-a.lastBefore,before:a.lastBefore});return r.sort((a,i)=>i.at-a.at).map(({at:a,unmeasuredMs:i})=>({at:a,unmeasuredMs:i}))}function Qc(e,t){const s=[];let o=0;for(const r of e){for(;o<t.length&&t[o].at>r.event.at;)s.push({kind:"resumed",gap:t[o]}),o+=1;s.push({kind:"event",entry:r})}for(;o<t.length;o+=1)s.push({kind:"resumed",gap:t[o]});return s}const ed=1e4;function td(e){return{away:!0,overview:!1,leftAt:e,since:null,inViewFrom:null}}function nd(e,t){const s=!e.away&&e.overview,o=t.visible&&t.overview;let{leftAt:r,since:a,inViewFrom:i}=e;if(e.away&&t.visible){const c=a??r;a=c!==null&&t.newestAt!==null&&t.newestAt>c?c:null,i=null}else e.overview&&!t.overview&&t.visible&&(a=null);s&&!o&&(r=Math.max(t.now,t.newestAt??t.now)),a!==null&&(t.newestAt===null||t.newestAt<=a)&&(a=null),a!==null&&o&&t.lineInView?(i??=t.now,t.now-i>=ed&&(a=null)):i=null,a===null&&(i=null);const l=!t.visible,d=t.overview;return l===e.away&&d===e.overview&&r===e.leftAt&&a===e.since&&i===e.inViewFrom?e:{away:l,overview:d,leftAt:r,since:a,inViewFrom:i}}function sd(e,t){if(t===null)return 0;let s=0;for(;s<e.length&&e[s].at>t;)s+=1;return s}const Ut="w-16 shrink-0 self-center font-mono text-caption whitespace-nowrap";function Os({kind:e,side:t}){return n.jsx("span",{"aria-hidden":!0,"data-part":"thread","data-kind":e,className:j("absolute left-1/2 -translate-x-1/2",t==="above"?"top-0 bottom-1/2 mb-2.5":"top-1/2 bottom-0 mt-2.5",e==="line"?"w-px bg-rule":"w-0 border-l border-dotted border-ink-muted opacity-70")})}function Dn({thread:e,children:t}){return n.jsxs("span",{className:"relative flex w-mark shrink-0 items-center justify-center",children:[e.above&&n.jsx(Os,{kind:e.above,side:"above"}),t,e.below&&n.jsx(Os,{kind:e.below,side:"below"})]})}function _t({at:e,mark:t,thread:s,lit:o=!1,className:r,children:a,...i}){return n.jsxs("li",{...i,"data-lit":o||void 0,className:j("flex min-h-log-row shrink-0 items-stretch gap-3.5 px-6 text-body",o?"text-ink":"text-ink-secondary",r),children:[n.jsx(Z,{content:Pn(e),mono:!0,align:"start",children:n.jsx("time",{dateTime:new Date(e).toISOString(),className:j(Ut,"rounded-bar",o?"text-ink-secondary":"text-ink-muted"),children:oe(e)})}),n.jsx(Dn,{thread:s,children:t}),n.jsx("div",{className:"flex min-w-0 flex-1 items-baseline gap-x-1 self-center py-2 max-mid:flex-wrap",children:a})]})}const od=g.memo(function({event:t,mark:s,open:o,waitedMs:r,above:a,below:i}){const l=mr(t,r);return n.jsxs(_t,{"data-slot":"event-row",at:t.at,lit:o,thread:{above:a,below:i},mark:n.jsx(V,{kind:s,labelled:!0}),children:[n.jsx(X,{"data-part":"name",tooltip:`${t.sessionName} ${l}`,className:"font-semibold text-ink",children:t.sessionName}),n.jsx("span",{"data-part":"phrase",className:"max-w-full shrink-0",children:r!==null&&l.startsWith(it)?n.jsxs(n.Fragment,{children:[it," ",n.jsx("span",{className:"whitespace-nowrap tabular-nums",children:z(r)})]}):l})]})});function $s(e){return e.charAt(0).toUpperCase()+e.slice(1)}const rd=6;function jp({entries:e,now:t,className:s}){const o=[];let r=Y(t);for(const i of e){const l=Y(i.event.at);l!==r&&(r=l,o.push({kind:"day",day:r})),o.push({kind:"event",entry:i})}const a=e.length>rd;return n.jsx("ol",{"data-slot":"own-events","aria-label":"Its events, newest first",tabIndex:a?0:void 0,className:j("thin-scroll flex flex-col",a&&"max-h-57 overflow-y-auto focus-visible:-outline-offset-2",s),children:o.map((i,l)=>{const d={above:l===0?null:"line",below:l===o.length-1?null:"line"};if(i.kind==="day")return n.jsx(xr,{day:i.day,now:t,thread:d,className:"px-0"},`day-${i.day}`);const{entry:c}=i,u=mr(c.event,c.waitedMs);return n.jsx(_t,{"data-slot":"event-row",at:c.event.at,lit:c.open,thread:d,mark:n.jsx(V,{kind:c.mark,labelled:!0}),className:"px-0",children:n.jsx("span",{"data-part":"phrase",children:c.waitedMs!==null&&u.startsWith(it)?n.jsxs(n.Fragment,{children:[$s(it)," ",n.jsx("span",{className:"whitespace-nowrap tabular-nums",children:z(c.waitedMs)})]}):$s(u)})},c.event.id)})})}function xr({day:e,now:t,thread:s,className:o}){return n.jsxs("li",{"data-slot":"event-day",className:j("flex shrink-0 items-stretch gap-3.5 px-6",o),children:[n.jsx("span",{className:j(Ut,"pt-3 pb-1 font-medium text-ink-muted"),children:Rn(e,t)}),n.jsx(Dn,{thread:s})]})}function ad({since:e,now:t,thread:s,ref:o}){const r=oe(e),a=Y(e)===Y(t)?r:`${Rn(e,t)} ${r}`;return n.jsxs("li",{ref:o,"data-slot":"event-new",className:"flex shrink-0 items-stretch gap-3.5 px-6",children:[n.jsx("span",{"aria-hidden":!0,className:Ut}),n.jsx(Dn,{thread:s}),n.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-3 py-2",children:[n.jsxs("span",{"data-part":"words",className:"min-w-0 text-caption font-medium text-ink-muted",children:["New since"," ",n.jsx("time",{dateTime:new Date(e).toISOString(),className:"whitespace-nowrap tabular-nums",children:a})]}),n.jsx("span",{"aria-hidden":!0,"data-part":"rule",className:"h-px min-w-4 flex-1 bg-rule max-mid:hidden"})]})]})}function id(e,t,s){const[o,r]=g.useState(null);return g.useLayoutEffect(()=>{const a=e.current,i=t.current;if(!a||!i)return;const l=()=>{const c=getComputedStyle(i),u=c.position==="absolute"?a.getBoundingClientRect().height:Number.parseFloat(c.maxHeight);let m=null;if(Number.isFinite(u)&&i.scrollHeight>u+.5){const f=u-Number.parseFloat(c.paddingBottom||"0"),p=i.getBoundingClientRect().top-i.scrollTop;for(const b of i.children){const w=b.getBoundingClientRect().bottom-p;if(w>f+.01)break;m=w}}r(m)};l();const d=new ResizeObserver(l);return d.observe(a),()=>d.disconnect()},[e,t,s]),o}function ld(e,t){const s=g.useRef(null);return g.useEffect(()=>{const o=s.current;if(!e||!o||!t)return;const r=new IntersectionObserver(a=>{const i=a.at(-1);i&&t(i.isIntersecting&&i.intersectionRatio>=.5)},{threshold:[0,.5,1]});return r.observe(o),()=>{r.disconnect(),t(!1)}},[e,t]),s}function cd({events:e,sessions:t=[],history:s=null,now:o,newSince:r=null,onNewLineInView:a,className:i}){const l=Y(o),d=Xc(e,s,e.length>=Dt),c=Zc(s).filter(x=>!d||x.at>=d.at),u=sd(e,r),m=[];let f=u>0?r:null,p=l;const b=x=>{f!==null&&x<=f&&(m.push({kind:"new",key:"new",since:f}),f=null);const O=Y(x);O!==p&&(p=O,m.push({kind:"day",key:`day-${p}`,day:p}))};for(const x of Qc(Jc(e,t),c))x.kind==="event"?(b(x.entry.event.at),m.push({kind:"event",key:x.entry.event.id,...x.entry})):(b(x.gap.at),m.push({kind:"resumed",key:`resumed-${x.gap.at}`,at:x.gap.at,unmeasuredMs:x.gap.unmeasuredMs}));d?.started&&(b(d.at),m.push({kind:"started",key:"started",at:d.at,cleared:d.cleared===!0})),f!==null&&m.push({kind:"new",key:"new",since:f});const w=u>0,h=e.length>0||c.length>0,N=g.useRef(null),y=g.useRef(null),v=id(N,y,h?m.map(x=>x.key).join(" "):""),k=ld(w,a);let E=!1;const I=m.map((x,O)=>{const P=O===0?null:E?"dots":"line";E=x.kind==="resumed"||(x.kind==="day"||x.kind==="new")&&E;const L=O===m.length-1?null:E?"dots":"line",q={above:P,below:L};switch(x.kind){case"day":return n.jsx(xr,{day:x.day,now:o,thread:q},x.key);case"event":return n.jsx(od,{event:x.event,mark:x.mark,open:x.open,waitedMs:x.waitedMs,above:P,below:L},x.key);case"resumed":return n.jsx(_t,{"data-slot":"event-resumed",at:x.at,thread:q,mark:n.jsx(V,{kind:"lookout",labelled:!0}),children:n.jsxs("span",{children:["Watching resumed,"," ",n.jsx("span",{className:"tabular-nums",children:z(x.unmeasuredMs)})," not measured"]})},x.key);case"started":return n.jsx(_t,{"data-slot":"event-start",at:x.at,thread:q,mark:n.jsx(V,{kind:"lookout",labelled:!0}),children:n.jsx("span",{children:x.cleared?"History cleared":"Started watching"})},x.key);case"new":return n.jsx(ad,{ref:k,since:x.since,now:o,thread:q},x.key)}});let M;return h?M=n.jsx("div",{ref:N,className:"relative min-h-65 flex-1 max-wide:min-h-0",children:n.jsx("ol",{ref:y,"data-slot":"event-list","data-whole-rows":v!==null||void 0,"aria-label":"Event log, newest first",tabIndex:0,className:j("thin-scroll flex flex-col overflow-y-auto pt-0.5 pb-3.5 focus-visible:-outline-offset-2","wide:absolute wide:inset-0 max-wide:max-h-120"),style:v!==null?{bottom:"auto",height:v}:void 0,children:I})}):d?.started?M=n.jsxs("div",{className:"pb-4",children:[n.jsx("ol",{"data-slot":"event-list","aria-label":"Event log, newest first",className:"flex flex-col",children:I}),n.jsxs("p",{"data-part":"unchanged",className:"flex gap-3.5 px-6 text-caption text-ink-muted",children:[n.jsx("span",{"aria-hidden":!0,className:j(Ut,"invisible"),children:oe(d.at)}),n.jsx("span",{"aria-hidden":!0,className:"w-mark shrink-0"}),n.jsx("span",{children:"Nothing has changed since."})]})]}):M=n.jsx(mt,{compact:!0,title:"No events yet",className:"my-auto",children:n.jsx("p",{children:"When a session starts, finishes or needs you, it is logged here."})}),n.jsx(W,{title:"Events",count:w?n.jsxs(n.Fragment,{children:[u," new",n.jsx("span",{className:"sr-only",children:", the log"})]}):void 0,aside:d?n.jsxs("span",{"data-part":"since",children:["since ",n.jsx("span",{className:"tabular-nums",children:se(d.at,o)})]}):void 0,className:j("flex flex-col",i),children:M})}const dd={permission:"Waiting for permission",question:"Asked you a question",other:"Waiting for you"};function gr(e){return dd[e.waitingReason??"other"]}function wr(e){return e.name.trim()!==""?e.name:e.project||e.id}function ud(e){const t=gr(e),s=e.waitingText?.trim();return{title:wr(e),body:s?`${t}: ${s}`:t}}const yn={"needs-you":"Needs you",finished:"Finished",failed:"Failed",ended:"Ended"};function md(e){return e.event==="needs-you"?ud(e.session):{title:wr(e.session),body:yn[e.event]}}const fd=1440*60*1e3,hd="a day",ht="–",ce={working:"busy with a task",idle:"ready for a prompt",stale:`idle ${hd} or more`,sessions:"all sessions found",noneWorking:"none working",noneIdle:"none idle",noneRunning:"none running",timeNotReported:"time not reported",notCountedYet:"not counted yet",noSource:"no source to count"};function _s(e,t,s,o){return e?n.jsxs(n.Fragment,{children:["longest"," ",n.jsx("span",{"data-part":"note-value",className:"whitespace-nowrap tabular-nums",children:z(s-e.since)})]}):t>0?ce.timeNotReported:o}function pd(e){if(e.total===0)return ce.noneRunning;const t=[`${e.open} open`];return e.finished>0&&t.push(`${e.finished} finished`),e.failed>0&&t.push(`${e.failed} failed`),t.join(", ")}function St({kind:e,label:t,mark:s,value:o,note:r,onOpen:a}){return n.jsxs("div",{"data-slot":"count","data-kind":e,"data-opens":a?"":void 0,role:"group","aria-label":t,className:a?"relative -m-2 flex min-w-0 cursor-pointer items-center gap-3 rounded-inner p-2 transition-colors duration-120 hover:bg-fill-hover has-[button:focus-visible]:outline-2 has-[button:focus-visible]:outline-offset-2 has-[button:focus-visible]:outline-focus":"flex min-w-0 items-center gap-3",children:[o===null?n.jsx("span",{"data-part":"placeholder","aria-hidden":!0,className:"block h-7 w-5.5 shrink-0 rounded-bar bg-fill-selected"}):n.jsx("p",{"data-part":"value",className:"min-w-5.5 shrink-0 text-stat font-medium tabular-nums",...o===ht?{role:"img","aria-label":"Not known"}:{},children:o}),n.jsxs("div",{className:"min-w-0",children:[n.jsxs("p",{"data-part":"label",className:"flex min-w-0 items-center gap-1.75 text-body leading-tight font-semibold text-ink",children:[s,a?n.jsx("button",{type:"button","aria-haspopup":"dialog","aria-label":`${t}: open history`,onClick:a,className:"min-w-0 cursor-pointer truncate text-left outline-none after:absolute after:inset-0 after:rounded-inner",children:t}):n.jsx("span",{className:"truncate",children:t})]}),n.jsx("p",{"data-part":"note",className:"mt-px text-caption text-pretty text-ink-secondary",children:r})]})]})}function xd({counts:e,asOf:t,onOpenHistory:s}){const{summary:o,counted:r,searching:a}=e,i=d=>o===null?null:r?d??0:ht,l=d=>s&&r?()=>s(d):void 0;return n.jsxs("div",{"data-slot":"counts-row",role:"group","aria-label":"Summary",className:"grid grid-cols-4 gap-4 border-t border-hairline pt-4.5 max-wide:grid-cols-2 max-wide:gap-y-3.5",children:[n.jsx(St,{kind:"working",label:"Working",mark:n.jsx(V,{kind:"working"}),value:i(o?.working),note:o&&r?_s(o.longestWorking,o.working,t,ce.noneWorking):ce.working,onOpen:l("working")}),n.jsx(St,{kind:"idle",label:"Idle",mark:n.jsx(V,{kind:"idle"}),value:i(o?.idle),note:o&&r?_s(o.longestIdle,o.idle,t,ce.noneIdle):ce.idle,onOpen:l("idle")}),n.jsx(St,{kind:"stale",label:"Stale",mark:n.jsx(V,{kind:"stale"}),value:i(o?.stale),note:ce.stale}),n.jsx(St,{kind:"sessions",label:"Sessions",value:i(o?.total),note:o?r?pd(o):a?ce.notCountedYet:ce.noSource:ce.sessions})]})}function gd(e){const t=new Set((e.restarts??[]).map(s=>s.at));return t.add(e.startedAt),[...t].sort((s,o)=>s-o)}function Un(e,t,s){const o=[];if(!e)return o;const r=e.points.map(d=>d.at).sort((d,c)=>d-c),a=gd(e);let i=0,l=null;for(const d of r){let c=!1;for(;i<a.length&&a[i]<=d;)l&&a[i]>l.to&&(c=!0),i+=1;l&&!c&&d-l.to<=s?l.to=d:o.push(l={from:d,to:d})}return l&&t>l.to&&t-l.to<=s&&(l.to=t),o}function Hn(e,t,s,o,r){const a=[];return e.forEach((i,l)=>{const d=l===0&&i.from>t.from&&i.from-t.from<=r?t.from:i.from,c=Math.max(d,t.from,o),u=Math.min(i.to,t.to,s);u>c&&a.push({from:c,to:u})}),a}function Bn(e,t){const s=[];let o=t.from;for(const r of[...e].sort((a,i)=>a.from-i.from))if(!(r.to<=o)&&(r.from>o&&s.push({from:o,to:Math.min(r.from,t.to)}),o=Math.max(o,r.to),o>=t.to))break;return o<t.to&&s.push({from:o,to:t.to}),s.filter(r=>r.to>r.from)}function Rs(e,t){const s=[];for(const o of e)for(const r of t){const a=Math.max(o.from,r.from),i=Math.min(o.to,r.to);i>a&&s.push({from:a,to:i})}return s.sort((o,r)=>o.from-r.from)}function Gn(e){return e.reduce((t,s)=>t+(s.to-s.from),0)}function br(e,t,s="in the last hour"){if(t.length===0)return s;const o=t[0];return Gn(t)>=e.to-e.from?null:t.length===1&&o.from<=e.from?`since ${H(o.to)}`:"in the time measured"}const yr=Lt,wd=new Map(yr.map((e,t)=>[e,t]));function Ws(e){return wd.get(e)??yr.length}function Ps(e,t){const s=e.toLowerCase(),o=t.toLowerCase();return s<o?-1:s>o?1:0}function bd(e,t){const s=Ws(e.status)-Ws(t.status);if(s!==0)return s;if(e.statusSince!==t.statusSince){if(e.statusSince===null)return 1;if(t.statusSince===null)return-1;const o=e.statusSince-t.statusSince;return e.status==="needs-you"?o:-o}return Ps(e.name,t.name)||Ps(e.id,t.id)}function Kn(e){return e.stale&&e.status==="idle"}function Vn(e){const t=e.status==="finished"||e.status==="failed",s=e.alive===!1,o=Kn(e);return{mark:o?"stale":e.status,word:o?"Stale":zn[e.status],ended:t,stale:o,quiet:o||t||s,orphaned:s&&!t}}const yd={"needs-you":"Needs you",working:"Working",idle:"Idle",unknown:"Status unknown"},kd=["needs-you","working","idle","ended","unknown"];function jd(e){switch(e.status){case"needs-you":return"needs-you";case"working":return"working";case"idle":return"idle";case"finished":case"failed":return"ended";default:return"unknown"}}function Nd(e,t){if(e!=="ended")return yd[e];const s=t.some(r=>r.status==="failed"),o=t.some(r=>r.status==="finished");return s&&o?"Finished or failed":s?"Failed":"Finished"}function vd(e,t){return+(t.status==="failed")-+(e.status==="failed")||bd(e,t)}function pt(e){const t=new Map;for(const o of e){const r=jd(o),a=t.get(r);a?a.push(o):t.set(r,[o])}const s=[];for(const o of kd){const r=t.get(o);if(!r)continue;const a=r.filter(Kn).length;s.push({id:o,label:Nd(o,r),sessions:[...r].sort(vd),count:r.length-a,stale:a})}return s}function kn(e){return pt(e).filter(t=>t.id!=="needs-you")}function Sd(e){return pt(e).find(t=>t.id==="needs-you")?.sessions??[]}function Ad(e){return e?.filter(t=>t.status==="needs-you").length??0}function rn(e,t){const s=t.statusSince;return s===null?e:e===null||s<e.since?{session:t,since:s}:e}function Ed(e){const t={total:e.length,needsYou:0,working:0,idle:0,stale:0,open:0,finished:0,failed:0,longestWait:null,longestWorking:null,longestIdle:null};for(const s of e){if(Kn(s)){t.stale+=1;continue}switch(s.status){case"needs-you":t.needsYou+=1,t.longestWait=rn(t.longestWait,s);break;case"working":t.working+=1,t.longestWorking=rn(t.longestWorking,s);break;case"idle":t.idle+=1,t.longestIdle=rn(t.longestIdle,s);break;case"finished":t.finished+=1;break;case"failed":t.failed+=1;break}}return t.open=t.total-t.finished-t.failed,t}function Yn(e,t=[]){const s=e?Ed(e):null,o=s!==null&&(s.total>0||t.some(r=>r.state==="ok"));return{summary:s,counted:o,searching:t.some(r=>r.state==="searching")}}function kr(e){return!e.summary||!e.counted?null:e.summary.needsYou>0?"lamp":"rest"}const jr=3600*1e3;function Md(e,t,s,o,r,a){const i=[],l=e?.startedAt??null,d=t[0];if(d){const m=l!==null&&l<d.at?l:-1/0;d.kind!=="appeared"?i.push({from:m,to:d.at,status:d.from??"unknown",startObserved:m!==-1/0,reaches:!1}):i.push({from:m,to:d.at,status:"unseen",startObserved:m!==-1/0,reaches:!1}),t.forEach((f,p)=>{const b=t[p-1];f.kind==="appeared"&&b?.kind==="ended"&&f.at>b.at&&i.push({from:b.at,to:f.at,status:"unseen",startObserved:!0,reaches:!1});const w=t[p+1]?.at??s.to;f.kind==="ended"||w<=f.at||i.push({from:f.at,to:w,status:f.to??"unknown",startObserved:!0,reaches:!1})})}else if(e){const m=l??-1/0,f=Math.max(m,Math.min(a,e.statusSince??1/0));f>m&&i.push({from:m,to:f,status:"unknown",startObserved:l!==null,reaches:!1,notKnown:!0}),i.push({from:f,to:s.to,status:e.status,startObserved:f!==-1/0,reaches:!1})}if(!e)return i;let c=i[i.length-1];(!c||c.to!==s.to||c.status==="unseen")&&(c={from:t[t.length-1]?.at??-1/0,to:s.to,status:e.status,startObserved:!0,reaches:!1},i.push(c)),c.status=e.status;const u=e.statusSince;return u!==null&&u<o&&(u>c.from+r?(c.to=u,c={from:u,to:s.to,status:e.status,startObserved:!0,reaches:!0},i.push(c)):c.reaches=!0),o<s.to&&c.from<o&&(c.to=o,i.push({from:o,to:s.to,status:e.status,startObserved:!0,reaches:!1})),i}function Td(e,t,s,o){const r=[],a=l=>s.some(d=>d.from<l&&l<=d.to),i=(l,d,c)=>{if(d<=l)return;const u=r[r.length-1];if(u?.kind==="unmeasured"&&u.to===l){u.to=d;return}const m=!(l===o.from&&c.from<l);r.push({from:l,to:d,kind:"unmeasured",startKnown:m})};for(const l of e){const d=Math.max(l.from,o.from),c=Math.min(l.to,o.to);if(c<=d)continue;if(l.notKnown){i(d,c,l);continue}if(l.reaches&&l.status!=="unseen"){const m=l.startObserved&&d===l.from;r.push({from:d,to:c,kind:l.status,startKnown:m});continue}let u=d;for(const m of t){if(m.to<=u)continue;if(m.from>=c)break;const f=Math.max(m.from,u),p=Math.min(m.to,c);if(i(u,f,l),l.status!=="unseen"&&p>f){const b=l.startObserved&&f===l.from&&a(f);r.push({from:f,to:p,kind:l.status,startKnown:b})}u=p}i(u,c,l)}return r}function Id(e,t){return e.flatMap(s=>s.kind!=="idle"||s.to<=t?[s]:s.from>=t?[{...s,kind:"stale"}]:[{...s,to:t},{...s,from:t,kind:"stale",startKnown:!0}])}function Cd(e,t){return e.at-t.at}function Nr(e){const{sessions:t,events:s,history:o,now:r}=e,a=e.gapMs??ft,i={from:r-(e.windowMs??jr),to:r},l=Math.min(e.asOf??r,r),d=new Map;let c=1/0;for(const y of s){y.at<c&&(c=y.at);const v=d.get(y.sessionId);v?v.push(y):d.set(y.sessionId,[y])}for(const y of d.values())y.sort(Cd);const u=Un(o,l,a),m=Math.max(o?fe(o).at:-1/0,e.eventsFull&&c!==1/0?c:-1/0),f=Hn(u,i,l,m,a),p=(y,v,k)=>{const E=Md(k,d.get(y)??[],i,l,a,o?.startedAt??-1/0);let I=Td(E,f,u,i);k?.stale&&k.status==="idle"&&k.statusSince!==null&&(I=Id(I,k.statusSince+fd));const M=I[I.length-1];if(k&&M&&M.to===i.to&&(M.ongoing=!0),k?.status==="needs-you")for(const x of I)x.kind==="needs-you"&&x.to===l&&(x.open=!0);return{id:y,name:v,ended:k===void 0,status:k?.status??null,stale:k?.stale??!1,segments:I}},b=pt(t).flatMap(y=>y.sessions),w=b.map(y=>p(y.id,y.name,y)),h=new Set(b.map(y=>y.id)),N=[];for(const[y,v]of d){const k=v[v.length-1];!k||h.has(y)||k.kind!=="ended"||k.at<=i.from||N.push({at:k.at,row:p(y,k.sessionName,void 0)})}return N.sort((y,v)=>v.at-y.at||y.row.name.localeCompare(v.row.name)),{start:i.from,end:i.to,rows:[...w,...N.map(y=>y.row)],unmeasured:Bn(f,i)}}function Ld(e,t){const{now:s,events:o}=e,r=e.heldMs??jr;let a=1/0;for(const m of t.points)m.at<a&&(a=m.at);let i=1/0;for(const m of o)m.at<i&&(i=m.at);const l=[[fe(t).at,"started"],[Math.max(a===1/0?s:a,s-r),"held"]];e.eventsFull&&i!==1/0&&l.push([i,"events"]);let[d,c]=l[0];for(const[m,f]of l)m>d&&([d,c]=[m,f]);d=Math.min(d,s);const u=Y(s);return d<=u?{from:u,to:s,bound:"midnight",today:!0}:{from:d,to:s,bound:c,today:!1}}function Od(e,t,s){const o=new Map;for(const a of e){const i=o.get(a.sessionId);i?i.push(a):o.set(a.sessionId,[a])}let r=null;for(const a of o.values())a.sort((i,l)=>i.at-l.at),a.forEach((i,l)=>{const d=a[l-1];if(!(d?d.to==="needs-you":i.from==="needs-you")||i.to==="needs-you"||i.at<t.from||i.at>s||d&&i.at<=d.at||r&&i.at<=r.at)return;const u=i.kind==="ended"||i.to==="finished"||i.to==="failed";r={id:i.sessionId,name:i.sessionName,ms:i.at-(d?d.at:t.from),startKnown:d!==void 0,at:i.at,how:u?"ended":"answered"}});return r}function $d(e){const{history:t,now:s}=e;if(!t)return null;const o=e.gapMs??ft,r=Math.min(e.asOf??s,s),a=Ld(e,t),i=Nr({sessions:e.sessions,events:e.events,history:t,now:s,asOf:r,eventsFull:e.eventsFull,windowMs:s-a.from,gapMs:o}),l=[];for(const m of i.rows){let f=0,p=0,b=!1,w=!0,h=!1,N=-1/0;for(const y of m.segments)if(y.from>N&&(h=!1),N=y.to,y.kind!=="unmeasured"){if(y.kind!=="needs-you"){h=!1;continue}h||(p+=1),h=!0,f+=y.to-y.from,y.open&&(b=!0),y.startKnown===!1&&(w=!1)}f>0&&l.push({id:m.id,name:m.name,ms:f,times:p,open:b,startKnown:w})}l.sort((m,f)=>f.ms-m.ms||m.name.localeCompare(f.name));const d={from:a.from,to:Math.max(a.from,r)},c=Hn(Un(t,r,o),d,r,fe(t).at,o),u=Bn(c,d);return{period:a,sessions:l,totalMs:l.reduce((m,f)=>m+f.ms,0),gaps:u,unmeasuredMs:Gn(u),lastWait:Od(e.events,a,r)}}function _d(e){return e.period.today?"Waited on you today":`Waited on you since ${H(e.period.from)}`}function Fs(e){const t=`Measured since ${H(e.period.from)}`,s=vr(e);return s?`${t}, with ${s}.`:`${t}.`}function vr(e){const t=e.gaps[0];if(!t||e.unmeasuredMs<=0)return null;const s=z(e.unmeasuredMs);return e.gaps.length===1?`${s} not measured after ${H(t.from)}`:`${s} not measured in ${e.gaps.length} breaks, the first after ${H(t.from)}`}const Rd=7*6e4;function Wd({waits:e}){const t=e?_d(e):"Waited on you",s=e?.sessions[0]?.ms??0,o=Math.max(Rd,s);return n.jsxs("div",{"data-slot":"waited-on-you",role:"group","aria-label":t,className:"grid grid-cols-1 gap-2.5 border-t border-hairline pt-4.5",children:[n.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1",children:[n.jsx("h3",{className:"min-w-0 text-body font-semibold text-ink",children:t}),e&&e.totalMs>0&&n.jsxs("p",{"data-part":"total",className:"shrink-0 text-caption text-ink-secondary",children:[n.jsx("span",{className:"text-body font-semibold text-ink tabular-nums",children:z(e.totalMs)})," ","in all"]})]}),e&&e.sessions.length>0&&n.jsx("ul",{"data-part":"bars",className:"grid grid-cols-1 gap-1.75",children:e.sessions.map(r=>{const a=`${r.startKnown?"":"at least "}${pe(r.ms)}`;return n.jsxs("li",{"data-part":"waited","data-open":r.open,className:"flex items-center gap-4 text-body leading-5 max-mid:flex-wrap max-mid:gap-y-1",children:[n.jsx(X,{"data-part":"who",className:j("w-waited-name shrink-0 max-mid:w-auto max-mid:min-w-0 max-mid:flex-1",r.open?"font-semibold text-ink":"font-medium text-ink-secondary"),children:r.name}),n.jsx("span",{"data-part":"track",role:"img","aria-label":r.open?`${r.name} has waited ${a}, still waiting`:`${r.name} waited ${a}, answered`,className:"relative h-2.5 min-w-0 flex-1 before:absolute before:inset-x-0 before:top-1/2 before:h-px before:bg-hairline max-mid:order-last max-mid:basis-full",children:n.jsx("i",{"data-part":"bar",className:j("absolute inset-y-0 left-0 rounded-bar",r.open?"bar-open bar-glow":"bar-answered"),style:{width:`${Math.round(r.ms/o*1e4)/100}%`}})}),n.jsx("span",{"data-part":"value","aria-hidden":!0,className:j("w-16 shrink-0 text-right whitespace-nowrap tabular-nums",r.open?"font-semibold text-label-needs-you":"text-ink-secondary"),children:z(r.ms)})]},r.id)})}),n.jsx("p",{"data-part":"note",className:"text-caption text-ink-secondary",children:e===null?"The history could not be read, so how long sessions waited is not known.":e.sessions.length===0?`No session waited on you. ${Fs(e)}`:Fs(e)})]})}const Pd=go("inline-flex h-5 shrink-0 items-center rounded-capsule px-2 text-caption font-medium whitespace-nowrap",{variants:{tone:{neutral:"bg-fill-quiet text-ink-secondary inset-ring inset-ring-control-rim",outline:"text-ink-secondary inset-ring inset-ring-rule-strong"}},defaultVariants:{tone:"neutral"}});function Ht({className:e,tone:t,...s}){return n.jsx("span",{"data-slot":"badge","data-tone":t??"neutral",className:j(Pd({tone:t}),e),...s})}const Fd="agent-lookout",zd=`${Fd}:`;function Sr(){return typeof location>"u"?"":location.protocol}function qn(e=Sr()){return e===zd}function Dd(e=document.documentElement,t=Sr()){qn(t)&&(e.dataset.host="app")}const Ar=4e3,Ud=xl+5e3,Hd=["no-pane","pane-gone","tmux-stopped","tab-gone","not-allowed","too-soon","failed"],Bd={selected:"Selected in tmux","no-pane":"No tmux pane found","pane-gone":"That pane has closed","tmux-stopped":"tmux has stopped","tab-gone":"That tab has closed","not-allowed":"macOS did not allow it","too-soon":"Try again in a moment",failed:"Jump did not work"};function Gd(e,t=null){return t!==null&&e==="selected"?`Switched to ${t}`:t!==null&&e==="no-pane"?"No tab found":Bd[e]}function Kd(e,t=qn()){return`macOS will ask once whether ${t?"Agent Lookout":"the app you started Agent Lookout from"} may control ${e}. Allow it to let Jump switch tabs.`}const Vd="To let Jump switch tabs, allow it in System Settings, Privacy & Security, Automation.";async function Yd(e,t=Ar){try{const s=await re("/api/jump",{method:"POST",headers:{"Content-Type":"application/json",[zt]:"jump"},body:JSON.stringify({sessionId:e}),signal:AbortSignal.timeout(t)}),o=await s.json(),r=typeof o=="object"&&o!==null?o:{};return s.ok?r.ok===!0?"selected":"failed":Hd.find(a=>a===r.reason)??"failed"}catch{return"failed"}}function Bt({session:e,jump:t,variant:s,size:o="sm",className:r}){const a=ke(e);if(!a)return null;const i=`Jump to ${e.name} in ${a.where}`,l=j(o==="sm"&&"w-16",r);return a.by==="link"?n.jsx(J,{asChild:!0,variant:s,size:o,className:l,children:n.jsx("a",{href:a.href,"data-part":"jump","aria-label":i,children:"Jump"})}):n.jsx(Z,{content:a.where,align:"end",children:n.jsx(J,{variant:s,size:o,className:l,"data-part":"jump","data-way":a.by,"aria-label":i,onClick:t.press,children:"Jump"})})}function lt({session:e,jump:t,className:s}){const{outcome:o,asking:r}=t,a=ke(e);if(o===null&&r===null&&(a===null||a.by==="link"))return null;const i=o===null?null:Gd(o,a?.by==="terminal"?a.app:null),l=o==="not-allowed"?Vd:o===null&&r!==null?Kd(r):null;return n.jsxs(n.Fragment,{children:[n.jsx("span",{role:"status","data-part":"jump-said",className:"sr-only",children:i!==null&&l!==null?`${i}. ${l}`:i??l}),i!==null&&n.jsx(Ht,{"aria-hidden":!0,"data-part":"jump-note","data-outcome":o,tone:o==="selected"?"neutral":"outline",className:s,children:i}),l!==null&&n.jsx("span",{"aria-hidden":!0,"data-part":"jump-line",className:"basis-full text-caption text-ink-secondary",children:l})]})}function Jn({git:e,inSentence:t=!1,className:s}){const o=e.branch;if(o===void 0&&e.commit===void 0)return null;const r=o!==void 0?"on":"at",a=o!==void 0?"branch":"commit";return n.jsxs(n.Fragment,{children:[t?n.jsxs(n.Fragment,{children:[r," ",n.jsxs("span",{className:"sr-only",children:[a," "]})]}):n.jsxs("span",{className:"sr-only",children:[r," ",a," "]}),o!==void 0?n.jsx(X,{"data-part":"branch",className:s,children:o}):n.jsx("span",{"data-part":"commit",className:j("font-mono text-fact",s),children:e.commit})]})}function Er({parts:e,className:t}){return n.jsx("span",{"data-slot":"duration-figure",className:j("inline-flex items-baseline gap-1.5 tabular-nums",t),children:e.map(s=>n.jsxs("span",{className:"inline-flex items-baseline",children:[s.value,n.jsx("span",{"data-part":"unit",className:"ml-0.5 text-unit font-medium text-ink-secondary",children:s.unit})]},s.unit))})}function me({label:e,className:t}){return n.jsxs("div",{"data-slot":"loading",role:"status",className:j("flex items-center justify-center gap-2.5 px-6 py-14",t),children:[n.jsx("span",{"aria-hidden":!0,className:"size-mark animate-spin-loader rounded-capsule border-[1.5px] border-rule-strong border-t-ink-secondary"}),n.jsx("span",{className:"text-body font-medium text-ink-secondary",children:e})]})}const Mr="agent-lookout-automation-note",Tr=new Set;function Ir(){try{const e=localStorage.getItem(Mr)??"";return In.filter(t=>e.split(",").includes(t))}catch{return[]}}function qd(e){return!Tr.has(e)&&!Ir().includes(e)}function Jd(e){const t=new Set([...Ir(),e]);try{localStorage.setItem(Mr,In.filter(s=>t.has(s)).join(","))}catch{Tr.add(e)}}const Xd=4e3,Zd=12e3,Qd=1e3;function Gt(e){const t=e.id,s=ke(e),o=s?.by==="terminal"?s.app:null,[r,a]=g.useState(null),[i,l]=g.useState(null),d=g.useRef(!1),c=g.useRef(-1/0),u=g.useRef(!0),m=g.useRef(void 0),f=g.useRef(void 0);return g.useEffect(()=>(u.current=!0,()=>{u.current=!1,clearTimeout(m.current),clearTimeout(f.current)}),[]),{press:g.useCallback(()=>{d.current||performance.now()-c.current<gl||(d.current=!0,clearTimeout(m.current),a(null),o!==null&&qd(o)&&(f.current=setTimeout(()=>{Jd(o),l(o)},Qd)),Yd(t,o!==null?Ud:Ar).then(b=>{d.current=!1,c.current=performance.now(),clearTimeout(f.current),u.current&&(l(null),a(b),m.current=setTimeout(()=>a(null),b==="not-allowed"?Zd:Xd))}))},[t,o]),outcome:r,asking:i}}const jn="#overview/session/";function eu(e){return`${jn}${encodeURIComponent(e).replace(/%3A/gi,":")}`}function tu(e){if(!e.startsWith(jn))return null;const t=e.slice(jn.length);if(t==="")return null;try{return decodeURIComponent(t)}catch{return t}}const Cr="agent-lookout-details";function Kt(e){return eu(e)}function Lr(e){return tu(e)}function Rt(e){const t=Kt(e);window.location.hash!==t&&(window.location.hash=t,window.history.replaceState({[Cr]:!0},""))}let an=!1;function nu(){if(Lr(window.location.hash)===null)return;const e=window.history.state;if(typeof e=="object"&&e!==null&&Cr in e){if(an)return;an=!0,window.addEventListener("hashchange",()=>{an=!1},{once:!0}),window.history.back()}else window.location.replace("#overview")}function Or(e,t){if(e.defaultPrevented||!(e.target instanceof Element))return;const s=e.target.closest("a, button, [tabindex]");s&&s!==e.currentTarget&&e.currentTarget.contains(s)||window.getSelection()?.isCollapsed!==!1&&Rt(t)}function Xn(e,t){e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),Rt(t))}function $r({onOpen:e,children:t}){const s=g.useId();return n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button","aria-haspopup":"dialog","aria-describedby":s,onClick:e,className:"-mx-1.5 -my-0.5 cursor-pointer rounded-row px-1.5 py-0.5 text-left transition-colors duration-120 hover:bg-fill-hover",children:t}),n.jsx("span",{id:s,hidden:!0,children:"Opens the history of how many sessions needed you"})]})}function su({id:e,count:t,onOpen:s}){return n.jsxs("h2",{id:e,"data-part":"title",className:"flex items-center gap-2.5 text-row leading-tight font-semibold text-ink",children:[n.jsx(V,{kind:"needs-you",breathing:!0,className:"size-4.5"}),s?n.jsx($r,{onOpen:s,children:"Needs you"}):n.jsx("span",{children:"Needs you"}),n.jsx("span",{"data-part":"count",className:"font-medium text-ink-secondary tabular-nums",children:t})]})}function _r({session:e,className:t}){const s=gr(e),o=Oc(e);return o?n.jsx(Z,{content:`${s}: ${o}`,children:n.jsxs("span",{"data-part":"reason-text",tabIndex:0,className:j("rounded-bar text-label-needs-you",t),children:[s,n.jsxs("span",{className:"sr-only",children:[": ",o]})]})}):n.jsx("span",{"data-part":"reason-text",className:j("text-label-needs-you",t),children:s})}function Rr({session:e,className:t}){const s=e.waitingText?.trim();return s?n.jsx(X,{"data-part":"asking",lines:2,className:j("min-w-0 text-body wrap-anywhere text-ink-secondary",t),children:s}):null}function Wr({session:e,agent:t,className:s}){const o=Ft(e.surface),r=!!e.project||o!==null;return!r&&t===void 0?null:n.jsxs("span",{"data-part":"place",className:j("relative min-w-0 text-body text-ink-secondary",s),children:[e.project?n.jsxs(n.Fragment,{children:[n.jsx(Z,{content:e.cwd,mono:!0,children:n.jsx("span",{"data-part":"project",tabIndex:e.cwd?0:void 0,className:"rounded-bar font-medium text-ink",children:e.project})}),e.git&&n.jsxs(n.Fragment,{children:[" ",n.jsx("span",{"data-part":"git",children:n.jsx(Jn,{git:e.git,inSentence:!0,className:"inline-block max-w-full align-top font-medium text-ink"})})]}),o!==null&&n.jsxs(n.Fragment,{children:[" ","in ",n.jsx("span",{"data-part":"app",children:o})]})]}):o!==null&&n.jsxs(n.Fragment,{children:["In ",n.jsx("span",{"data-part":"app",children:o})]}),t!==void 0&&n.jsxs(n.Fragment,{children:[r&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"sr-only",children:", "}),n.jsx("span",{"aria-hidden":!0,className:"mx-1.5",children:"·"})]}),n.jsx("span",{"data-part":"agent",children:t})]})]})}function Pr({session:e}){return e.alive===!1?n.jsx(Ht,{tone:"outline",children:"Process ended"}):null}function Fr(e,t){return e.statusSince===null?null:Math.max(0,t-e.statusSince)}function zr({session:e,className:t}){return n.jsx(X,{"data-part":"name",href:Kt(e.id),onClick:s=>Xn(s,e.id),"aria-label":`${e.name}, details`,"aria-haspopup":"dialog",className:j("-mx-1.5 -my-0.5 rounded-row px-1.5 py-0.5 transition-colors duration-120 hover:bg-fill-hover",t),children:e.name})}function ou({session:e,asOf:t,agent:s}){const o=Fr(e,t),r=Gt(e);return n.jsxs("div",{"data-slot":"hero-session","data-session":e.id,className:"mt-3.5 flex items-end justify-between gap-6 max-mid:flex-col max-mid:items-stretch max-mid:gap-4",children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1",children:[n.jsxs("div",{className:"flex max-w-full min-w-0 items-center gap-3",children:[n.jsx(zr,{session:e,className:"text-name font-semibold"}),n.jsx(Pr,{session:e})]}),n.jsx(lt,{session:e,jump:r})]}),n.jsx("p",{"data-part":"reason",className:"mt-2 flex min-w-0 text-lead font-medium",children:n.jsx(_r,{session:e,className:"truncate"})}),n.jsx(Rr,{session:e,className:"mt-1"}),n.jsx(Wr,{session:e,agent:s,className:"mt-1.5 block wrap-anywhere"})]}),n.jsxs("div",{className:"flex shrink-0 items-end gap-6 max-mid:flex-wrap max-mid:justify-between max-mid:gap-y-3",children:[n.jsxs("div",{"data-part":"wait",className:"text-right max-mid:text-left",children:[n.jsx("p",{className:"text-wait font-medium whitespace-nowrap text-label-needs-you",children:o!==null?n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"sr-only",children:["Waiting ",pe(o)]}),n.jsx("span",{"aria-hidden":!0,children:n.jsx(Er,{parts:ut(o)})})]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"sr-only",children:"How long it has waited was not reported"}),n.jsx("span",{"aria-hidden":!0,children:ht})]})}),n.jsx("p",{"data-part":"since",className:"mt-2 text-caption text-ink-secondary",children:e.statusSince!==null?n.jsxs(n.Fragment,{children:["waiting since"," ",n.jsx("span",{className:"font-semibold text-ink tabular-nums",children:H(e.statusSince)})]}):"time not reported"})]}),n.jsx(Bt,{session:e,jump:r,variant:"needs-you",size:"hero"})]})]})}function ru({session:e,asOf:t,agent:s}){const o=Fr(e,t),r=Gt(e);return n.jsxs("li",{"data-slot":"hero-session","data-session":e.id,className:"flex items-center gap-5 border-t border-hairline py-3 max-mid:flex-wrap max-mid:gap-x-4 max-mid:gap-y-2",children:[n.jsxs("div",{className:"min-w-0 flex-1 max-mid:basis-full",children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[n.jsxs("div",{className:"flex max-w-full min-w-0 items-center gap-2",children:[n.jsx(zr,{session:e,className:"text-lead font-semibold text-ink"}),n.jsx(Pr,{session:e})]}),n.jsx(lt,{session:e,jump:r})]}),n.jsxs("p",{"data-part":"reason",className:"mt-1 flex min-w-0 flex-wrap items-baseline gap-x-3 text-body",children:[n.jsx(_r,{session:e,className:"font-medium"}),n.jsx(Wr,{session:e,agent:s,className:"block min-w-0 wrap-anywhere"})]}),n.jsx(Rr,{session:e,className:"mt-1"})]}),n.jsx("p",{"data-part":"wait",className:"shrink-0 text-right text-lead font-semibold whitespace-nowrap text-label-needs-you tabular-nums max-mid:mr-auto max-mid:text-left",children:o!==null?n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"sr-only",children:["Waiting ",pe(o)]}),n.jsx("span",{"aria-hidden":!0,children:z(o)})]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"sr-only",children:"How long it has waited was not reported"}),n.jsx("span",{"aria-hidden":!0,children:ht})]})}),n.jsx(Bt,{session:e,jump:r,variant:"needs-you",size:"sm"})]})}function au(e,t){return n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"font-semibold text-ink",children:e.name}),","," ",e.how==="ended"?"ended at":"answered at"," ",n.jsx("span",{className:"tabular-nums",children:H(e.at)}),!e.startKnown&&n.jsxs(n.Fragment,{children:[", waiting since before ",n.jsx("span",{className:"tabular-nums",children:H(t)})]})]})}function iu({id:e,waits:t,onOpen:s}){const o=t?.lastWait??null,r=t!==null&&t.sessions.length===0,a=t?t.period.today?"today":`since ${H(t.period.from)}`:null,i=t&&t.sessions.length===0?vr(t):null;return n.jsxs("div",{className:"flex items-end justify-between gap-6 max-mid:flex-col max-mid:items-start max-mid:gap-4",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("h2",{id:e,"data-part":"title",className:"mt-1 flex items-center gap-3.5 text-name font-semibold text-ink",children:[n.jsx(V,{kind:"needs-you",unlit:!0,className:"size-6.5"}),s?n.jsx($r,{onOpen:s,children:"Nothing needs you"}):n.jsx("span",{children:"Nothing needs you"})]}),n.jsx("p",{className:"mt-2.5 max-w-md text-row text-ink-secondary",children:"When a session stops to ask for something, it will show here."})]}),n.jsxs("div",{"data-part":"last-wait",className:"shrink-0 text-right max-mid:text-left",children:[n.jsx("p",{className:"mb-2.5 text-caption font-semibold text-ink-secondary",children:"Last wait"}),o?n.jsxs(n.Fragment,{children:[n.jsxs("p",{className:"text-wait font-normal whitespace-nowrap text-ink",children:[n.jsxs("span",{className:"sr-only",children:["The last wait lasted ",o.startKnown?"":"at least ",pe(o.ms)]}),n.jsx("span",{"aria-hidden":!0,children:n.jsx(Er,{parts:ut(o.ms)})})]}),n.jsx("p",{"data-part":"last-note",className:"mt-2 text-caption text-ink-secondary",children:au(o,t?.period.from??o.at)})]}):n.jsxs(n.Fragment,{children:[n.jsx("p",{"data-part":"last-note",className:"text-body text-ink-secondary",children:a&&r?`None ${a}`:"Not known"}),i&&n.jsx("p",{"data-part":"last-gaps",className:"mt-1 text-caption text-ink-secondary",children:i})]})]})]})}function lu({id:e,counts:t}){return n.jsxs("div",{children:[n.jsxs("h2",{id:e,"data-part":"title",className:"flex items-center gap-2.5 text-row leading-tight font-semibold text-ink",children:[n.jsx(V,{kind:"needs-you",unlit:!0,className:"size-4.5"}),"Needs you"]}),t.summary===null?n.jsx(me,{label:"Reading sessions",className:"justify-start px-0 pt-5 pb-1"}):n.jsxs(n.Fragment,{children:[n.jsx("p",{"data-part":"value",role:"img","aria-label":"Not known",className:"mt-3.5 text-name font-semibold text-ink",children:ht}),n.jsx("p",{"data-part":"uncounted",className:"mt-2 max-w-md text-row text-ink-secondary",children:t.searching?"Agent Lookout is still looking for agents on this computer. The count follows as soon as one is read.":"No agent tool could be read, so nothing could be counted. The Sessions card says why."})]})]})}function cu({sessions:e,sources:t=[],events:s=[],history:o=null,now:r,asOf:a=r,onOpenHistory:i,className:l}){const d=g.useId(),c=Yn(e,t),u=kr(c),m=g.useMemo(()=>e?Sd(e):[],[e]),f=ur(t,e??[]),p=k=>f?Fn(k,t):void 0,b=g.useMemo(()=>e&&u?$d({sessions:e,events:s,history:o,now:r,asOf:a,eventsFull:s.length>=Dt}):null,[e,u,s,o,r,a]),w=i&&o&&u?i:void 0,[h,...N]=m;let y,v;return u?h?(v=N.length>0?"several":"one",y=n.jsxs("div",{children:[n.jsx(su,{id:d,count:m.length,onOpen:w&&(()=>w("needsYou"))}),n.jsx(ou,{session:h,asOf:a,agent:p(h)},h.id),N.length>0&&n.jsx("ul",{"data-part":"others","aria-label":"Also waiting, longest first",className:"mt-5",children:N.map(k=>n.jsx(ru,{session:k,asOf:a,agent:p(k)},k.id))})]})):(v="quiet",y=n.jsx(iu,{id:d,waits:b,onOpen:w&&(()=>w("needsYou"))})):(v=c.summary===null?"loading":"uncounted",y=n.jsx(lu,{id:d,counts:c})),n.jsxs("section",{"data-slot":"hero","data-state":v,"data-light":u??void 0,"aria-labelledby":d,className:j("glass-raised flex min-w-0 flex-col justify-between gap-5 px-7 pt-6 pb-5.5 max-mid:px-5",l),children:[y,u&&(b===null||b.sessions.length>0)&&n.jsx(Wd,{waits:b}),n.jsx(xd,{counts:c,asOf:a,onOpenHistory:w})]})}function Dr(){const e=g.useRef(null),[t,s]=g.useState(0);return g.useEffect(()=>{const o=e.current;if(!o)return;const r=new ResizeObserver(([a])=>{a&&s(Math.floor(a.contentRect.width))});return r.observe(o),()=>r.disconnect()},[]),[e,t]}const Zn=6e4,du=60*Zn,Wt=5*Zn;function uu(e){const t=new Date(e).getTimezoneOffset()*Zn;return Math.floor((e-t)/Wt)*Wt+t}function mu(e,t){const s=[];for(const o of e){if(o.status!=="needs-you")continue;if(o.statusSince!==null){s.push(o.statusSince);continue}let r=-1/0;for(const a of t)a.sessionId===o.id&&a.to==="needs-you"&&a.at>r&&(r=a.at);s.push(r)}return s.sort((o,r)=>o-r)}function fu(e,t,s){const o=[...e.points].sort((i,l)=>i.at-l.at),r=[],a=o[0];return a&&r.push({...a,from:-1/0,to:a.at}),o.forEach((i,l)=>{const d=o[l+1];let c=i.at;d&&d.at-i.at<=s?c=d.at:!d&&t>i.at&&t-i.at<=s&&(c=t),c>i.at&&r.push({...i,from:i.at,to:c})}),r}function hu(e){const{history:t,now:s}=e,o=e.gapMs??ft,r=s-(e.windowMs??du),a={from:r,to:s},i=Math.min(e.asOf??s,s),l=Un(t,i,o),d=Hn(l,a,i,t?fe(t).at:-1/0,o),c=[];for(let h=uu(r);h<s;h+=Wt){const N=Math.max(h,r),y=Math.min(h+Wt,s);if(y<=N)continue;const v=Rs(d,[{from:N,to:y}]);c.push({from:N,to:y,measured:v,measuredMs:Gn(v),means:null})}const u=c.map(()=>({open:0,answered:0,working:0,idle:0})),m=mu(e.sessions,e.events),f=h=>m.filter(N=>N<=h).length;let p=0,b=0;if(t)for(const h of fu(t,i,o))for(const N of Rs([h],d)){const y=[N.from,...m.filter(v=>v>N.from&&v<N.to),N.to];for(let v=0;v<y.length-1;v+=1){const k=y[v],E=y[v+1],I=Math.min(h.needsYou,f(k)),M=h.needsYou-I;p+=h.needsYou*(E-k),b+=I*(E-k),c.forEach((x,O)=>{const P=Math.min(E,x.to)-Math.max(k,x.from);if(P<=0)return;const L=u[O];L.open+=I*P,L.answered+=M*P,L.working+=h.working*P,L.idle+=h.idle*P})}}let w=0;return c.forEach((h,N)=>{if(h.measuredMs<=0)return;const y=u[N],v=E=>E/h.measuredMs,k={open:v(y.open),answered:v(y.answered),working:v(y.working),idle:v(y.idle),total:0};k.total=k.open+k.answered+k.working+k.idle,h.means=k,k.total>w&&(w=k.total)}),{start:r,end:s,buckets:c,unmeasured:Bn(d,a),waitedMs:p,openMs:b,axis:Pl(w)}}const pu=.02,Ue=.05,xu=96;function ee(e){return`${Math.round(e*1e5)/1e3}%`}function Nn(e,t){return`${H(e.from)} to ${e.to>=t?"now":H(e.to)}`}function be(e){return e.toFixed(1)}function gu(e){const t=[e.open>=Ue&&`needs you ${be(e.open)}`,e.answered>=Ue&&`answered ${be(e.answered)}`,e.working>=Ue&&`working ${be(e.working)}`,e.idle>=Ue&&`idle ${be(e.idle)}`].filter(Boolean);return t.length>0?t.join(", "):"no sessions"}function Ur(e,t){if(!e.means)return`${Nn(e,t)}: not measured`;const s=e.measuredMs<e.to-e.from-1e3;return`${Nn(e,t)}: ${gu(e.means)}${s?`, measured for ${z(e.measuredMs)}`:""}`}function wu(e){const t=e.unmeasured.map(s=>`from ${H(s.from)} to ${s.to>=e.end?"now":H(s.to)}`);return["The average number of sessions in each status, every five minutes over the last hour.",t.length>0?`Not measured ${t.join(", and ")}.`:"",...e.buckets.map(s=>`${Ur(s,e.end)}.`)].filter(Boolean).join(" ")}function bu(e){const t=new Set,s=e[0],o=e[e.length-1];if(s!==void 0&&t.add(s),o!==void 0&&t.add(o),e.length%2===1){const r=e[(e.length-1)/2];r!==void 0&&t.add(r)}return t}function yu({means:e,ceiling:t,from:s,to:o,hour:r}){if(e.total<=0)return null;const a=r.end-r.start,i=[["open",e.open,"bar-open"],["answered",e.answered,"bar-answered"],["working",e.working,"bar-working"]];return n.jsx("div",{"aria-hidden":!0,"data-part":"bar",className:"bar-tube absolute bottom-0 z-10 flex flex-col-reverse gap-0.5 overflow-hidden rounded-t-tube rounded-b-bar",style:{left:ee((s-r.start)/a),width:`max(2px, calc(${ee((o-s)/a)} - 4px))`,height:ee(Math.min(1,e.total/t))},children:i.map(([l,d,c])=>d>=pu?n.jsx("i",{"data-part":"segment","data-kind":l,className:j("block shrink-0",c),style:{height:ee(d/e.total)}},l):null)})}function ku({fill:e}){return n.jsx("i",{"aria-hidden":!0,className:j("block h-2.5 w-3.5 rounded-bar",e)})}function ju({hour:e}){const t=g.useId(),[s,o]=Dr(),[r,a]=g.useState(null),i=e.end-e.start,l=e.axis.ceiling,d=e.buckets.length-1,c=r===null?d:Math.min(r,d),u=e.buckets[c],m=u?Ur(u,e.end):"",f=bu(e.axis.ticks),p=o>0?Xo(e.start,e.end,Math.max(1,Math.floor(o/xu))).map(h=>({at:h,share:(h-e.start)/i})).filter(({share:h})=>h*o>=16&&h*o<=o-52):[],b=(h,N)=>{const y=e.start+(h-N.left)/N.width*i,v=e.buckets.findIndex(k=>y<k.to);a(v===-1?d:v)},w=h=>{const y={ArrowLeft:v=>v-1,ArrowDown:v=>v-1,ArrowRight:v=>v+1,ArrowUp:v=>v+1,Home:()=>0,End:()=>d}[h.key];y&&(h.preventDefault(),a(Math.min(d,Math.max(0,y(c)))))};return n.jsxs(n.Fragment,{children:[n.jsxs("div",{"data-slot":"last-hour-chart",role:"slider",tabIndex:0,"aria-label":"Last hour, every five minutes. Arrow keys read each five minutes.","aria-describedby":t,"aria-orientation":"horizontal","aria-valuemin":0,"aria-valuemax":Math.max(0,d),"aria-valuenow":c,"aria-valuetext":m,onPointerMove:h=>b(h.clientX,h.currentTarget.getBoundingClientRect()),onPointerLeave:()=>a(null),onBlur:()=>a(null),onFocus:h=>{h.currentTarget.matches(":focus-visible")&&a(N=>N??d)},onKeyDown:w,className:"relative mt-4 mr-11.5 ml-6 min-h-28 flex-1 cursor-crosshair rounded-bar max-wide:h-50 max-wide:flex-none",children:[e.axis.ticks.map(h=>n.jsx("span",{"aria-hidden":!0,"data-part":"grid",className:j("absolute inset-x-0 block h-px",h===0?"bg-rule-strong":"bg-hairline"),style:{bottom:ee(h/l)},children:f.has(h)&&n.jsx("span",{className:"absolute -top-1.75 -right-7.5 w-5.5 font-mono text-micro leading-3.5 text-ink-muted",children:h})},h)),r!==null&&u&&n.jsx("i",{"aria-hidden":!0,"data-part":"chosen",className:"absolute inset-y-0 block rounded-bar bg-fill-selected inset-ring inset-ring-rule",style:{left:ee((u.from-e.start)/i),width:`calc(${ee((u.to-u.from)/i)} - 2px)`}}),e.unmeasured.map(h=>n.jsx("i",{"aria-hidden":!0,"data-part":"unmeasured",className:"unmeasured-hatch absolute inset-y-0 z-0 block",style:{left:ee((h.from-e.start)/i),width:ee((h.to-h.from)/i)}},h.from)),e.buckets.flatMap(h=>h.means?h.measured.map(N=>n.jsx(yu,{means:h.means,ceiling:l,from:N.from,to:N.to,hour:e},N.from)):[]),r!==null&&u&&n.jsxs("div",{"aria-hidden":!0,"data-part":"reading",className:"pointer-events-none absolute top-0 z-20 rounded-row bg-glass-float px-2.5 py-1.5 font-mono text-fact whitespace-nowrap inset-ring inset-ring-rule",style:(u.from-e.start)/i>.55?{right:`calc(${ee((e.end-u.from)/i)} + 6px)`}:{left:`calc(${ee((u.to-e.start)/i)} + 2px)`},children:[n.jsx("span",{className:"block text-ink-secondary",children:Nn(u,e.end)}),u.means?n.jsxs(n.Fragment,{children:[u.means.open>=Ue&&n.jsxs("span",{className:"block text-label-needs-you",children:["Needs you ",be(u.means.open)]}),u.means.answered>=Ue&&n.jsxs("span",{className:"block text-ink",children:["Answered ",be(u.means.answered)]}),n.jsxs("span",{className:"block text-ink",children:["Working ",be(u.means.working)]}),n.jsxs("span",{className:"block text-ink",children:["Idle ",be(u.means.idle)]})]}):n.jsx("span",{className:"block text-ink",children:"Not measured"})]})]}),n.jsx("p",{id:t,className:"sr-only",children:wu(e)}),n.jsxs("div",{ref:s,"aria-hidden":!0,"data-slot":"last-hour-axis",className:"relative mr-11.5 ml-6 h-5.5 font-mono text-micro leading-none text-ink-muted",children:[p.map(h=>n.jsx("span",{"data-part":"time-tick",className:"absolute top-1.75 -translate-x-1/2 whitespace-nowrap",style:{left:ee(h.share)},children:H(h.at)},h.at)),n.jsx("span",{"data-part":"now",className:"absolute top-1.75 right-0 whitespace-nowrap text-ink-secondary",children:"now"})]})]})}function Nu({open:e}){const t=[["working","bar-working","Working"],...e?[["needs-you","bar-open","Needs you"]]:[],["answered","bar-answered","Answered"],["idle","bar-tube","Idle"],["unmeasured","unmeasured-hatch","Not measured"]];return n.jsx("ul",{"data-slot":"last-hour-legend","aria-label":"Legend",className:"flex flex-wrap items-center gap-x-3.5 gap-y-1.5 px-6 pt-2 pb-5 text-caption text-ink-secondary",children:t.map(([s,o,r])=>n.jsxs("li",{"data-kind":s,className:"flex items-center gap-1.5 whitespace-nowrap",children:[n.jsx(ku,{fill:o}),r]},s))})}function vu({sessions:e,sources:t=[],events:s=[],history:o,now:r,asOf:a=r,className:i}){const l=g.useMemo(()=>e&&o?hu({history:o,sessions:e,events:s,now:r,asOf:a}):null,[e,o,s,r,a]),d=l?.buckets.some(m=>(m.means?.total??0)>0)??!1;let c,u="every 5 minutes";if(e===null)c=n.jsx(me,{label:"Reading the last hour"});else if(l===null)u=void 0,c=n.jsx("div",{className:"px-6 pb-5",children:n.jsx(U,{tone:"error",title:"The last hour could not be read",children:n.jsx("p",{children:"Agent Lookout did not answer when asked for its history. The page asks again every two seconds."})})});else if(d||e.length>0)c=n.jsxs(n.Fragment,{children:[n.jsx("p",{"data-part":"sum",className:"px-6 text-body text-ink-secondary",children:l.waitedMs>0?n.jsxs(n.Fragment,{children:["Sessions waited on you for"," ",n.jsx("span",{className:"font-semibold text-ink tabular-nums",children:z(l.waitedMs)})," ","in all"]}):l.unmeasured.length>0?"No session waited on you in the time measured":"No session waited on you in the last hour"}),n.jsx(ju,{hour:l}),n.jsx(Nu,{open:l.openMs>0})]});else if(t.some(m=>m.state==="searching"))c=n.jsx(me,{label:"Looking for sessions"});else if(!t.some(m=>m.state==="ok"))u=void 0,c=n.jsx("div",{className:"px-6 pb-5",children:n.jsx(U,{title:"The last hour was not measured",children:n.jsx("p",{children:"No source could be read, so there is nothing to count. The Sessions card says why."})})});else{const m=br({from:l.start,to:l.end},l.unmeasured);c=n.jsx(mt,{compact:!0,title:m?`No sessions ${m}`:"Nothing was measured in the last hour",children:n.jsx("p",{children:"When a session runs, how many waited, worked or sat idle is drawn here."})})}return n.jsx(W,{title:"Last hour",aside:u,className:j("flex flex-col",i),children:c})}const Su=5*6e4;function Hr(e,t){if(e.status!=="working"||e.lastWriteAt===void 0)return null;const s=t-e.lastWriteAt;return s>=Su?s:null}function Au(e){return`quiet for ${$t(e)}`}function Eu(e){return`quiet for ${at(e)}`}function Br({session:e,now:t,quiet:s}){const o=e.status==="finished"||e.status==="failed",r=e.statusSince,a=r!==null?t-r:null;return n.jsx(Z,{content:r!==null?`Since ${lr(r,t)}`:"The source did not report a time",mono:r!==null,align:"end",children:n.jsx("span",{"data-part":"duration",className:j("shrink-0 rounded-bar whitespace-nowrap tabular-nums",s?"text-ink-secondary":"text-ink"),children:a!==null?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"sr-only",children:o?`${at(a)} ago`:`for ${at(a)}`}),n.jsxs("span",{"aria-hidden":!0,children:[$t(a),o&&" ago"]})]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"sr-only",children:"time not reported"}),n.jsx("span",{"aria-hidden":!0,children:"–"})]})})})}function Gr({session:e,now:t}){const s=Hr(e,t);return s===null||e.lastWriteAt===void 0?null:n.jsx(Z,{content:`Last write at ${lr(e.lastWriteAt,t)}`,mono:!0,align:"end",children:n.jsxs("span",{"data-part":"quiet",tabIndex:0,className:"block w-fit rounded-bar leading-tight whitespace-nowrap text-ink-muted tabular-nums",children:[n.jsx("span",{className:"sr-only",children:Eu(s)}),n.jsx("span",{"aria-hidden":!0,children:Au(s)})]})})}const We="px-3 first:pl-6 last:pr-4.5";function Mu({session:e,now:t,jumpColumn:s,narrow:o=!1,agent:r,folderColumn:a=!0,appColumn:i=!0}){const{mark:l,word:d,stale:c,quiet:u,orphaned:m}=Vn(e),f=Gt(e),p=Ft(e.surface),b=n.jsx(Br,{session:e,now:t,quiet:u}),w=Hr(e,t)!==null&&n.jsx(Gr,{session:e,now:t}),h=N=>n.jsxs("p",{"data-part":"status-under",className:"flex min-w-0 flex-wrap items-baseline gap-x-3 gap-y-px overflow-x-clip leading-tight",children:[r!==void 0&&n.jsxs(n.Fragment,{children:[n.jsx(X,{"data-part":"agent",className:"min-w-0",children:r}),n.jsx("span",{className:"sr-only",children:", "})]}),n.jsxs("span",{"data-part":"status-time",className:"relative flex min-w-0 grow flex-wrap items-baseline justify-between gap-x-3 gap-y-px",children:[r!==void 0&&n.jsx("span",{"aria-hidden":!0,"data-part":"dot",className:"absolute right-full mr-1",children:"·"}),N,b]}),w&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"sr-only",children:", "}),n.jsx("span",{className:"basis-full",children:w})]})]});return n.jsxs("tr",{"data-slot":"session-row","data-session":e.id,"data-status":e.status,"data-stale":c||void 0,onClick:N=>Or(N,e.id),className:"group relative cursor-pointer text-body text-ink-secondary",children:[n.jsx("td",{className:j(We,"h-row",o&&"py-2","before:pointer-events-none before:absolute before:inset-x-2.5 before:inset-y-px before:-z-10 before:rounded-inner before:transition-colors before:duration-120 group-hover:before:bg-fill-hover","group-has-[a[data-part=name]:focus-visible]:before:outline-2 group-has-[a[data-part=name]:focus-visible]:before:outline-offset-2 group-has-[a[data-part=name]:focus-visible]:before:outline-focus"),children:n.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[n.jsx(V,{kind:l}),n.jsxs("div",{className:"grid min-w-0 flex-1 gap-px",children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-px",children:[n.jsxs("div",{className:"flex max-w-full min-w-0 items-center gap-2",children:[n.jsx(X,{"data-part":"name",href:Kt(e.id),onClick:N=>Xn(N,e.id),"aria-label":`${e.name}, details`,"aria-haspopup":"dialog",className:j("text-row focus-visible:outline-none",u?"font-medium text-ink-secondary":"font-semibold text-ink"),children:e.name}),m&&n.jsx(Ht,{tone:"outline",children:"Process ended"})]}),!o&&n.jsx(lt,{session:e,jump:f})]}),o&&n.jsx(lt,{session:e,jump:f,className:"justify-self-start"}),o&&h(n.jsx("span",{"data-part":"status",className:"whitespace-nowrap",children:d}))]})]})}),r!==void 0&&!o&&n.jsx("td",{"data-part":"agent",className:We,children:n.jsx(X,{className:"block min-w-0",children:r})}),a&&n.jsxs("td",{className:j(We,"max-mid:hidden"),children:[n.jsx(Z,{content:e.cwd,mono:!0,children:n.jsx("span",{"data-part":"project",tabIndex:e.cwd?0:void 0,className:j("block truncate rounded-bar text-ink-secondary",e.git&&"leading-tight"),children:e.project??"–"})}),e.git&&n.jsx("span",{"data-part":"git",className:"flex min-w-0 leading-tight text-ink-muted",children:n.jsx(Jn,{git:e.git,className:"min-w-0"})})]}),i&&n.jsx("td",{"data-part":"app",className:j(We,"truncate max-mid:hidden"),children:p??n.jsxs(n.Fragment,{children:[n.jsx("span",{"aria-hidden":!0,children:"–"}),n.jsx("span",{className:"sr-only",children:"app not known"})]})}),!o&&n.jsxs("td",{className:We,children:[n.jsxs("div",{className:j("flex items-baseline justify-between gap-2 whitespace-nowrap",w&&"leading-tight"),children:[n.jsx("span",{"data-part":"status",children:d}),b]}),w]}),s&&n.jsx("td",{className:j(We,"overflow-visible text-right"),children:n.jsx(Bt,{session:e,jump:f,className:"group-hover:bg-fill-selected group-hover:text-ink"})})]})}const Tu="No repository",zs=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"});function Iu(e){const t=new Map,s=[];for(const r of e){const a=r.git?.repository;if(a===void 0){s.push(r);continue}const i=t.get(a.id);i?(i.sessions.push(r),zs.compare(a.name,i.label)<0&&(i.label=a.name)):t.set(a.id,{id:a.id,label:a.name,sessions:[r]})}const o=[...t.values()].sort((r,a)=>zs.compare(r.label,a.label)||(r.id<a.id?-1:r.id>a.id?1:0));return s.length>0?[...o,{id:null,label:Tu,sessions:s}]:o}function Cu(e){const t=e.git?.repository?.name;return t!==void 0&&t!==e.project?t:null}function Lu({session:e,now:t,agent:s}){const{mark:o,word:r,stale:a,quiet:i,orphaned:l}=Vn(e),d=Gt(e),c=Ft(e.surface),u=Cu(e);return n.jsxs("li",{"data-slot":"board-card","data-session":e.id,"data-status":e.status,"data-stale":a||void 0,draggable:!1,onClick:m=>Or(m,e.id),className:j("group flex min-w-0 cursor-pointer flex-col rounded-inner bg-fill-zebra px-3.5 pt-3 pb-3 text-body text-ink-secondary inset-ring inset-ring-hairline","transition-colors duration-120 hover:bg-fill-hover","has-[a[data-part=name]:focus-visible]:outline-2 has-[a[data-part=name]:focus-visible]:outline-offset-2 has-[a[data-part=name]:focus-visible]:outline-focus"),children:[n.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[n.jsxs("div",{className:"flex max-w-full min-w-0 items-center gap-3",children:[n.jsx(V,{kind:o}),n.jsx(X,{"data-part":"name",href:Kt(e.id),onClick:m=>Xn(m,e.id),"aria-label":`${e.name}, details`,"aria-haspopup":"dialog",className:j("text-row focus-visible:outline-none",i?"font-medium text-ink-secondary":"font-semibold text-ink"),children:e.name})]}),l&&n.jsx(Ht,{tone:"outline",children:"Process ended"}),n.jsx(lt,{session:e,jump:d})]}),e.project&&n.jsxs("p",{"data-part":"place",className:"mt-1.5 min-w-0 leading-tight",children:[u!==null&&n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"inline-flex max-w-full align-top",children:[n.jsx(X,{"data-part":"repository",className:"min-w-0",children:u}),n.jsx("span",{"aria-hidden":!0,className:"whitespace-pre",children:" ·"})]}),n.jsx("span",{className:"sr-only",children:","})," "]}),n.jsx(Z,{content:e.cwd,mono:!0,children:n.jsx("span",{"data-part":"project",tabIndex:e.cwd?0:void 0,className:"inline-block max-w-full truncate rounded-bar align-top",children:e.project})}),e.git&&n.jsxs(n.Fragment,{children:[" ",n.jsx("span",{"data-part":"git",className:"inline-flex max-w-full gap-1 align-top whitespace-nowrap text-ink-muted",children:n.jsx(Jn,{git:e.git,inSentence:!0,className:"min-w-0"})})]})]}),(c!==null||s!==void 0)&&n.jsxs("p",{"data-part":"where",className:"mt-1 flex min-w-0 flex-wrap gap-x-3 gap-y-px overflow-x-clip leading-tight",children:[c!==null&&n.jsx("span",{"data-part":"app",className:"whitespace-nowrap",children:c}),s!==void 0&&n.jsxs(n.Fragment,{children:[c!==null&&n.jsx("span",{className:"sr-only",children:", "}),n.jsxs("span",{className:"relative flex min-w-0",children:[c!==null&&n.jsx("span",{"aria-hidden":!0,className:"absolute right-full mr-1",children:"·"}),n.jsx(X,{"data-part":"agent",className:"min-w-0",children:s})]})]})]}),n.jsxs("div",{className:"mt-3 flex min-w-0 flex-wrap items-center gap-2",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("p",{className:"flex items-baseline gap-1.5 leading-tight whitespace-nowrap",children:[n.jsx("span",{"data-part":"status",children:r}),n.jsx(Br,{session:e,now:t,quiet:i})]}),n.jsx(Gr,{session:e,now:t})]}),n.jsx(Bt,{session:e,jump:d,className:"ml-auto group-hover:bg-fill-selected group-hover:text-ink"})]})]})}const Ou=[{id:"needs-you",label:"Needs you",empty:"Nothing waiting"},{id:"working",label:"Working",empty:"Nothing working"},{id:"idle",label:"Idle",empty:"Nothing idle"},{id:"ended",label:"Finished or failed",empty:"Nothing finished or failed"}],$u=5;function _u(e){const t=pt(e);return{columns:Ou.map(o=>{const r=t.find(a=>a.id===o.id);return{...o,sessions:r?.sessions??[],count:r?.count??0,stale:r?.stale??0}}),unknown:t.find(o=>o.id==="unknown")?.sessions??[]}}function ct({children:e}){return n.jsx("span",{"data-part":"count",className:"font-medium text-ink-muted tabular-nums",children:e})}function Ru({column:e,now:t,agentOf:s}){const o=g.useId(),r=e.sessions.slice(0,$u),a=e.sessions.length-r.length;return n.jsxs("div",{"data-slot":"board-column","data-column":e.id,className:"flex min-w-0 flex-col",children:[n.jsxs("h3",{id:o,className:"flex h-group items-end gap-3.5 px-3.5 pb-2 text-caption font-semibold text-ink-secondary",children:[n.jsxs("span",{className:"inline-flex items-baseline gap-1.5",children:[e.label,n.jsx(ct,{children:e.count})]}),e.stale>0&&n.jsxs("span",{"data-part":"stale",className:"inline-flex items-baseline gap-1.5",children:["Stale",n.jsx(ct,{children:e.stale})]})]}),r.length>0?n.jsx("ul",{"aria-labelledby":o,className:"flex flex-col gap-2",children:r.map(i=>n.jsx(Lu,{session:i,now:t,agent:s?.(i)},i.id))}):n.jsx("p",{"data-part":"empty",className:"px-3.5 py-2.5 text-caption text-ink-muted",children:e.empty}),a>0&&n.jsxs("p",{"data-part":"more",className:"rounded-row px-3.5 pt-2.5 text-caption text-ink-muted",children:["and ",n.jsx("span",{className:"tabular-nums",children:a})," more in the list"]})]})}function Wu({sessions:e,now:t,agentOf:s}){const{columns:o,unknown:r}=_u(e);return n.jsxs("div",{"data-slot":"session-board",className:"@container px-2.5 pb-2.5",children:[n.jsx("div",{className:"grid grid-cols-1 gap-x-2.5 gap-y-2 @min-[26rem]:grid-cols-2 @min-[47rem]:grid-cols-4",children:o.map(a=>n.jsx(Ru,{column:a,now:t,agentOf:s},a.id))}),r.length>0&&n.jsx("p",{"data-part":"unknown",className:"rounded-row px-3.5 pt-3 pb-1 text-caption text-ink-muted",children:r.length===1?"The status of 1 session is not known. The list shows it.":`The status of ${r.length} sessions is not known. The list shows them.`})]})}function Oe({value:e,onValueChange:t,options:s,label:o,className:r}){const a=s.findIndex(i=>i.value===e);return n.jsxs(Ia,{"data-slot":"segmented-control","aria-label":o,orientation:"horizontal",value:e,onValueChange:i=>t(i),className:j("relative inline-grid rounded-capsule bg-well p-0.75","inset-ring inset-ring-control-rim inset-shadow-well",r),style:{gridTemplateColumns:`repeat(${s.length}, minmax(0, 1fr))`},children:[a!==-1&&n.jsx("span",{"aria-hidden":!0,"data-part":"thumb",className:j("pointer-events-none absolute inset-y-0.75 left-0.75 rounded-capsule bg-thumb","inset-ring inset-ring-control-rim inset-shadow-top shadow-thumb","motion-safe:transition-transform motion-safe:duration-220 motion-safe:ease-out"),style:{width:`calc((100% - 6px) / ${s.length})`,transform:`translateX(${a*100}%)`}}),s.map(i=>n.jsxs(Ca,{value:i.value,"aria-label":i.name,onFocus:()=>{i.value!==e&&t(i.value)},className:j("relative flex h-control cursor-pointer items-center justify-center gap-2 rounded-capsule px-4","text-body font-medium whitespace-nowrap text-ink-secondary transition-colors duration-120","hover:text-ink data-[state=checked]:text-ink",i.icon!==void 0&&"pl-3"),children:[i.icon,i.label]},i.value))]})}function Pu(e){const t=g.useCallback(s=>{const o=window.matchMedia(e);return o.addEventListener("change",s),()=>o.removeEventListener("change",s)},[e]);return g.useSyncExternalStore(t,()=>window.matchMedia(e).matches)}const Fu="(max-width: 760px)";function Vt(){return Pu(Fu)}const zu=["list","repositories","board"],Kr="agent-lookout-sessions-layout",Ds="list";let Pt=null;function Du(){if(Pt!==null)return Pt;try{const e=localStorage.getItem(Kr);return zu.find(t=>t===e)??Ds}catch{return Ds}}function Uu(e){try{localStorage.setItem(Kr,e),Pt=null}catch{Pt=e}}function Hu(){const[e,t]=g.useState(Du),s=g.useCallback(o=>{Uu(o),t(o)},[]);return[e,s]}const Bu=[{value:"list",label:"List"},{value:"repositories",label:"Repos"},{value:"board",label:"Board"}];function Gu({source:e}){const t=e.state==="unavailable";return n.jsxs(U,{tone:t?"info":"error",title:t?`${e.label} was not found`:`${e.label} could not be read`,children:[n.jsx("p",{children:n.jsx(ue,{children:e.detail??(t?`Agent Lookout could not find ${e.label} on this computer.`:`Agent Lookout found ${e.label} but could not read its sessions.`)})}),n.jsx("p",{"data-part":"advice",children:e.advice?n.jsx(ue,{children:e.advice}):t?`Install ${e.label} or start a session. It will show up here on its own.`:"It keeps trying. If this stays, restart Agent Lookout."})]})}function Ve({sources:e,last:t}){return n.jsx("div",{className:j("flex flex-col gap-2 px-6",t?"pb-6":"pb-3"),children:e.map(s=>n.jsx(Gu,{source:s},s.id))})}function Ku({sources:e}){const t=e.filter(s=>s.state==="searching");return n.jsxs(mt,{title:"Looking for agents",children:[t.map(s=>n.jsx("p",{children:n.jsx(ue,{children:s.detail??`Looking for ${s.label} sessions on this computer.`})},s.id)),n.jsx("p",{className:"mt-2 text-ink-muted",children:"It checks every two seconds. There is nothing you need to do."})]})}function Us({head:e,sessions:t,now:s,jumpColumn:o,columns:r,narrow:a,agentOf:i,folderColumn:l,appColumn:d,...c}){return n.jsxs("tbody",{"data-slot":"session-group",...c,children:[n.jsx("tr",{"data-slot":"group-row",children:n.jsx("th",{scope:"rowgroup",colSpan:r,className:"h-group px-6 pt-2.5 pb-1.5 text-left align-bottom text-caption font-semibold text-ink-secondary",children:e})}),t.map(u=>n.jsx(Mu,{session:u,now:s,jumpColumn:o,narrow:a,agent:i?.(u),folderColumn:l,appColumn:d},u.id))]})}function Vu({group:e}){const t=e.id!=="idle"||e.count>0;return n.jsxs("span",{className:"flex items-baseline gap-3.5",children:[t&&n.jsxs("span",{className:"inline-flex items-baseline gap-1.5",children:[e.label,n.jsx(ct,{children:e.count})]}),e.id==="idle"&&e.stale>0&&n.jsxs("span",{"data-part":"stale",className:"inline-flex items-baseline gap-1.5",children:["Stale",n.jsx(ct,{children:e.stale})]})]})}function Yu({sessions:e,byRepository:t,...s}){if(!t)return kn(e).map(r=>n.jsx(Us,{"data-group":r.id,head:n.jsx(Vu,{group:r}),sessions:r.sessions,...s},r.id));const o=kn(e).flatMap(r=>r.sessions);return Iu(o).map(r=>n.jsx(Us,{"data-group":r.id===null?"no-repository":"repository","data-repository":r.id??void 0,head:n.jsxs("span",{className:"flex min-w-0 items-baseline gap-1.5",children:[n.jsx(X,{"data-part":"repository",className:"min-w-0",children:r.label}),n.jsx(ct,{children:r.sessions.length})]}),sessions:r.sessions,...s},r.id??""))}const le={agent:6.25,folder:7,app:7,status:10,jump:6},qu=12.5,Ju=12,Hs={folder:!0,app:!0,folderRem:le.folder};function Xu(e,t,s,o){const[r,a]=g.useState(Hs);return g.useLayoutEffect(()=>{const i=e.current?.parentElement;if(!t||!i)return;const l=()=>{const c=parseFloat(getComputedStyle(document.documentElement).fontSize)||16,u=qu+le.status+(s?le.agent:0)+(o?le.jump:0),m=i.clientWidth/c,f=m>=u+le.folder,p=f&&m>=u+le.folder+le.app,b=m-(u+le.folder+(p?le.app:0)),w=Math.round(Math.min(Ju,le.folder+Math.max(0,b)/2)*4)/4;a(h=>h.folder===f&&h.app===p&&h.folderRem===w?h:{folder:f,app:p,folderRem:w})};l();const d=new ResizeObserver(l);return d.observe(i),()=>d.disconnect()},[e,t,s,o]),t?r:Hs}function Zu({sessions:e,sources:t,now:s,className:o}){const r=g.useRef(null),a=Cc(t),i=a.filter(L=>L.state==="unavailable"||L.state==="error"),l=a.some(L=>L.state==="searching"),d=kn(e).flatMap(L=>L.sessions),[c,u]=Hu(),m=c==="board"&&e.length>0,f=d.some(L=>ke(L)!==null),p=(m?e:d).map(ke).filter(L=>L!==null),b=p.some(L=>L.by==="tmux")?p.some(L=>L.by!=="tmux")?"Jump opens the session, or selects its pane in tmux":"Jump selects the session's pane in tmux":"Jump opens the session where it runs",w=ur(t,e),h=w?L=>Fn(L,t):void 0,N=Vt(),y=w&&!N,{folder:v,app:k,folderRem:E}=Xu(r,d.length>0&&!N&&!m,y,f),I=(N?1:2+(y?1:0)+(v?1:0)+(k?1:0))+(f?1:0),{counted:M}=Yn(e,t);let x;if(m)x=n.jsxs(n.Fragment,{children:[i.length>0&&n.jsx(Ve,{sources:i,last:!1}),n.jsx(Wu,{sessions:e,now:s,agentOf:h})]});else if(d.length>0)x=n.jsxs(n.Fragment,{children:[i.length>0&&n.jsx(Ve,{sources:i,last:!1}),n.jsxs("table",{ref:r,"data-slot":"session-list",className:"mb-2.5 w-full table-fixed border-separate border-spacing-0",children:[n.jsxs("colgroup",{children:[n.jsx("col",{}),y&&n.jsx("col",{className:"w-25"}),v&&!N&&n.jsx("col",{style:{width:`${E}rem`}}),k&&!N&&n.jsx("col",{className:"w-28"}),!N&&n.jsx("col",{className:"w-40"}),f&&n.jsx("col",{className:"w-24"})]}),n.jsx("thead",{className:"sr-only",children:n.jsxs("tr",{children:[n.jsx("th",{scope:"col",children:"Session"}),y&&n.jsx("th",{scope:"col",children:"Agent"}),v&&!N&&n.jsx("th",{scope:"col",children:"Folder"}),k&&!N&&n.jsx("th",{scope:"col",children:"App"}),!N&&n.jsx("th",{scope:"col",children:"Status and time"}),f&&n.jsx("th",{scope:"col",children:"Jump"})]})}),n.jsx(Yu,{sessions:e,byRepository:c==="repositories",now:s,jumpColumn:f,columns:I,narrow:N,agentOf:h,folderColumn:v,appColumn:k})]})]});else if(e.length>0)x=n.jsxs(n.Fragment,{children:[i.length>0&&n.jsx(Ve,{sources:i,last:!1}),n.jsx("p",{"data-part":"all-waiting",className:"px-6 pb-6 text-body text-ink-secondary",children:"Every session needs you. They are at the top of the page, longest wait first."})]});else if(l)x=n.jsx(Ku,{sources:a});else if(i.length>0&&i.length===a.length)x=n.jsx(Ve,{sources:i,last:!0});else{const L=a.filter(q=>q.state==="ok");x=n.jsxs(n.Fragment,{children:[i.length>0&&n.jsx(Ve,{sources:i,last:!1}),n.jsx(mt,{title:"No agents are running",children:n.jsxs("p",{children:["Agent Lookout is watching ",Fe(L)," on this computer. A session shows up here within a few seconds of starting."]})})]})}const O=p.length>0&&n.jsx("span",{"data-part":"hint",className:"max-mid:hidden @max-[42rem]:hidden",children:b}),P=e.length>0&&n.jsx(Oe,{label:"Show sessions as",value:c,onValueChange:u,options:Bu,className:N?void 0:"-my-2.5"});return n.jsxs(W,{title:"Sessions",count:M?e.length:void 0,aside:P&&!N?n.jsxs("div",{className:"flex items-center gap-4",children:[O,P]}):O||void 0,className:j("@container",o),children:[P&&N&&n.jsx("div",{"data-part":"layout",className:"flex px-6 pb-1",children:P}),x]})}const Qu={...zn,stale:"Stale",unmeasured:"Not measured"};function em({segment:e,from:t,share:s}){switch(e.kind){case"needs-you":return n.jsx("span",{"aria-hidden":!0,"data-part":"mark",className:j("block h-bar-needs-you w-full rounded-bar",e.open?"bar-open bar-glow":"bar-answered")});case"working":return n.jsx("span",{"aria-hidden":!0,"data-part":"mark",className:"bar-working block h-bar-working w-full rounded-capsule"});case"idle":return n.jsx("span",{"aria-hidden":!0,"data-part":"mark",className:"bar-idle block h-bar-idle w-full rounded-capsule"});case"stale":return n.jsx("span",{"aria-hidden":!0,"data-part":"mark",className:"stale-dots block h-bar-idle w-full"});case"unknown":return n.jsx("span",{"aria-hidden":!0,"data-part":"mark",className:"block h-1.5 w-full rounded-bar inset-ring inset-ring-status-idle"});case"finished":return n.jsx("span",{"aria-hidden":!0,"data-part":"mark",className:"absolute left-0 h-3 w-0.5 rounded-bar bg-status-finished"});case"failed":return n.jsx("svg",{"aria-hidden":!0,"data-part":"mark",viewBox:"0 0 10 10",fill:"none",className:"absolute left-0 size-2.5 -translate-x-1/2 text-status-finished",children:n.jsx("path",{d:"M2 2l6 6M8 2l-6 6",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round"})});case"unmeasured":return n.jsx("span",{"aria-hidden":!0,"data-part":"hatch",className:"absolute inset-0",style:{clipPath:"inset(3px 2px 3px 0 round var(--radius-bar))"},children:n.jsx("span",{className:"unmeasured-hatch absolute inset-y-0",style:{left:Ce(-t/s),width:Ce(1/s)}})})}}const tm=.01,nm={ArrowLeft:e=>Math.max(0,e-1),ArrowRight:(e,t)=>Math.min(t,e+1),Home:()=>0,End:(e,t)=>t};function sm(e){const t=e.to-e.from,s=e.kind==="needs-you"&&e.open===!0,o=e.startKnown===!1||s&&!e.ongoing,r=a=>[o&&"at least",a,e.ongoing&&"so far"].filter(Boolean).join(" ");return{status:e.kind==="needs-you"&&!s?"Needed you":Qu[e.kind],lasted:r(z(t)),lastedInWords:r(pe(t)),clock:`${oe(e.from)} to ${e.ongoing?"now":oe(e.to)}`}}function Ce(e){return`${Math.round(e*1e5)/1e3}%`}function om(e,t,s){const o=s-t,r=e.filter(a=>a.kind==="unmeasured").map(a=>{const i=Ce((Math.max(a.from,t)-t)/o),l=`calc(${Ce((Math.min(a.to,s)-t)/o)} - 2px)`;return`black ${i}, transparent ${i} ${l}, black ${l}`});return`linear-gradient(to right, black, ${r.join(", ")}${r.length?", ":""}black)`}function rm({segments:e,start:t,end:s,label:o,rules:r=[],className:a}){const i=g.useRef(null),[l,d]=g.useState(null),c=s-t,u=c>0?e.filter(w=>w.to>w.from&&w.to>t&&w.from<s):[],m=u.length-1,f=l===null?-1:u.findIndex(w=>w.to===l),p=f===-1?m:f,b=w=>{const h=nm[w.key];if(!h||m<0)return;w.preventDefault(),i.current?.querySelectorAll('[data-part="segment"]')?.[h(p,m)]?.focus()};return n.jsxs("div",{ref:i,"data-slot":"status-track",role:"group","aria-label":`${o}: status over time. Arrow keys move along it.`,onKeyDown:b,className:j("relative h-track w-full",a),children:[c>0&&r.some(w=>w>t&&w<s)&&n.jsx("span",{"aria-hidden":!0,"data-part":"rules",className:"pointer-events-none absolute inset-0",style:{maskImage:om(u,t,s)},children:r.filter(w=>w>t&&w<s).map(w=>n.jsx("span",{className:"absolute inset-y-0 w-px bg-hairline",style:{left:Ce((w-t)/c)}},w))}),u.map((w,h)=>{const N=Math.max(w.from,t),v=(Math.min(w.to,s)-N)/c,k=sm(w);return n.jsx(Z,{content:n.jsxs("span",{className:"flex flex-col",children:[n.jsx("span",{children:k.status}),n.jsx("span",{className:"font-mono text-fact text-ink-secondary",children:k.lasted}),n.jsx("span",{className:"font-mono text-fact text-ink-muted",children:k.clock})]}),children:n.jsx("span",{"data-part":"segment","data-kind":w.kind,"data-open":w.kind==="needs-you"?!!w.open:void 0,role:"img","aria-label":`${k.status}, ${k.lastedInWords}, ${k.clock}`,tabIndex:h===p?0:-1,onFocus:()=>d(h===m?null:w.to),className:j("absolute inset-y-0 flex min-w-0.75 items-center pr-0.5 focus-visible:z-20",v<tm&&"z-10 before:absolute before:inset-y-0 before:-inset-x-1"),style:{left:`min(${Ce((N-t)/c)}, calc(100% - 3px))`,width:Ce(v)},children:n.jsx(em,{segment:w,from:(N-t)/c,share:v})})},h===m?"present":w.to)})]})}const am=6,im=96,lm=20,cm=100;function dm(e,t){return(e-t.start)/(t.end-t.start)}function um(e){return`${Math.round(e*1e5)/1e3}%`}function mm(e){return e.status===null?null:e.stale&&e.status==="idle"?"stale":e.status}function fm({row:e,timeline:t,rules:s,named:o}){const r=mm(e),a=e.status==="needs-you";return n.jsxs("li",{"data-slot":"timeline-row","data-ended":e.ended,className:"flex h-track items-center rounded-row odd:bg-fill-zebra",children:[o&&n.jsxs("div",{className:j("flex w-label-col shrink-0 items-center gap-3 px-3 text-body",a?"font-semibold text-ink":"font-medium text-ink-secondary"),children:[r?n.jsx(V,{kind:r}):n.jsx("span",{"aria-hidden":!0,"data-part":"no-mark",className:"size-mark shrink-0"}),n.jsx(X,{"data-part":"name",children:e.name})]}),n.jsx(rm,{segments:e.segments,start:t.start,end:t.end,label:e.ended?`${e.name}, ended`:e.name,rules:s,className:"min-w-0 flex-1"})]})}const At="block h-2.5 w-3.5 rounded-bar",Bs="block h-bar-idle w-3.5",hm=[{kind:"needs-you",label:"Needs you",swatch:n.jsx("i",{className:j(At,"bar-open")})},{kind:"answered",label:"Answered",swatch:n.jsx("i",{className:j(At,"bar-answered")})},{kind:"working",label:"Working",swatch:n.jsx("i",{className:j(At,"bar-working")})},{kind:"idle",label:"Idle",swatch:n.jsx("i",{className:j(Bs,"bar-idle rounded-capsule")})},{kind:"stale",label:"Stale",swatch:n.jsx("i",{className:j(Bs,"stale-dots")})},{kind:"finished",label:"Finished",swatch:n.jsx("i",{className:"mx-1.5 block h-3 w-0.5 rounded-bar bg-status-finished"})},{kind:"failed",label:"Failed",swatch:n.jsx(V,{kind:"failed",className:"size-2.5"})},{kind:"unknown",label:"Unknown",swatch:n.jsx("i",{className:"block h-1.5 w-3.5 rounded-bar inset-ring inset-ring-status-idle"})},{kind:"unmeasured",label:"Not measured",swatch:n.jsx("i",{className:j(At,"unmeasured-hatch")})}];function pm({timeline:e}){const t=new Set(["answered","working","idle","stale","finished","unmeasured"]);for(const s of e.rows)for(const o of s.segments)o.kind==="needs-you"&&o.open&&t.add("needs-you"),(o.kind==="failed"||o.kind==="unknown")&&t.add(o.kind);return n.jsx("ul",{"data-slot":"timeline-legend","aria-label":"Legend",className:"flex flex-wrap items-center gap-x-3.5 gap-y-1.5 text-caption text-ink-secondary",children:hm.filter(s=>t.has(s.kind)).map(s=>n.jsxs("li",{"data-kind":s.kind,className:"flex items-center gap-1.5 whitespace-nowrap",children:[n.jsx("span",{"aria-hidden":!0,className:"flex items-center",children:s.swatch}),s.label]},s.kind))})}function xm(e,t){if(t<=0)return[];const s=Math.max(1,Math.min(am,Math.floor(t/im)));return Xo(e.start,e.end,s).map(o=>({at:o,share:dm(o,e)})).filter(({share:o})=>o*t>=lm&&o*t<=t-cm).map(({at:o,share:r})=>({at:o,left:um(r)}))}function gm({timeline:e,rows:t=e.rows,named:s=!0,label:o="Sessions over the last hour",className:r="px-6 pb-4.5"}){const[a,i]=Dr(),l=xm(e,i),d=l.map(c=>c.at);return n.jsxs("div",{className:r,children:[n.jsx("ul",{"data-slot":"timeline-rows","aria-label":o,children:t.map(c=>n.jsx(fm,{row:c,timeline:e,rules:d,named:s},c.id))}),n.jsxs("div",{ref:a,"data-slot":"timeline-axis","aria-hidden":!0,className:j("relative mt-2 h-5.5 border-t border-rule font-mono text-micro leading-none text-ink-muted",s&&"ml-label-col"),children:[l.map(c=>n.jsx("span",{"data-part":"time-tick",className:"absolute top-2 -translate-x-1/2 whitespace-nowrap before:absolute before:-top-2 before:left-1/2 before:h-1 before:w-px before:bg-rule-strong",style:{left:c.left},children:H(c.at)},c.at)),n.jsxs("span",{"data-part":"now",className:"absolute top-2 right-0 whitespace-nowrap text-ink-secondary before:absolute before:-top-2 before:right-0 before:h-1 before:w-px before:bg-rule-strong",children:[H(e.end)," now"]})]})]})}function wm({sessions:e,sources:t=[],events:s,history:o,now:r,asOf:a=r,className:i}){const l=g.useMemo(()=>e&&o?Nr({sessions:e,events:s,history:o,now:r,asOf:a,eventsFull:s.length>=Dt}):null,[e,s,o,r,a]);let d;if(e===null)d=n.jsx(me,{label:"Reading the last hour"});else if(l===null)d=n.jsx("div",{className:"px-6 pb-6",children:n.jsx(U,{tone:"error",title:"The last hour could not be read",children:n.jsx("p",{children:"Agent Lookout did not answer when asked for its history. The page asks again every two seconds."})})});else if(l.rows.length>0)d=n.jsx(gm,{timeline:l});else if(t.some(c=>c.state==="searching"))d=n.jsx(me,{label:"Looking for sessions"});else if(!t.some(c=>c.state==="ok"))d=n.jsx("div",{className:"px-6 pb-6",children:n.jsx(U,{title:"The last hour was not measured",children:n.jsx("p",{children:"No source could be read, so there is no status to draw. The Sessions card says why."})})});else{const c=br({from:l.start,to:l.end},l.unmeasured);d=n.jsx(mt,{compact:!0,title:c?`No sessions ${c}`:"Nothing was measured in the last hour",children:n.jsx("p",{children:"When a session runs, its status over time is drawn here."})})}return n.jsx(W,{title:"Timeline",sub:"last hour, one row per session",aside:l&&l.rows.length>0?n.jsx(pm,{timeline:l}):void 0,className:i,children:d})}const bm=3e4,ym=4e3;async function km(){try{const e=await re("/api/waits",{headers:{accept:"application/json"},signal:AbortSignal.timeout(ym)});return e.ok?mc(await e.json()):null}catch{return null}}function ve(e){return e.measuredMs>0}function Qn(e){return ve(e)?e.waits===0?"No waits":`${e.waits} ${e.waits===1?"wait":"waits"}`:"Not measured"}const jm=new Intl.DateTimeFormat(void 0,{weekday:"short",month:"short",day:"numeric"}),Nm=new Intl.DateTimeFormat(void 0,{weekday:"long",month:"long",day:"numeric"});function vn(e,t,s=!1){const o=Y(t),r=Y(e.from);if(r===o)return"Today";const a=new Date(o);return a.setDate(a.getDate()-1),r===a.getTime()?"Yesterday":(s?Nm:jm).format(new Date(e.from))}function Vr(e,t){return Y(e.from)===Y(t)?e.openMs:0}function vm(e,t){const s=vn(e,t,!0);if(!ve(e))return`${s}: not measured`;const o=e.waits===0?"no session waited":`waited ${pe(e.waitedMs)} in ${Qn(e).toLowerCase()}`,r=Vr(e,t)>0?", still waiting":"";return`${s}: ${o}${r}, measured for ${pe(e.measuredMs)}`}function Et(e,t){return ve(e)?`${z(e.measuredMs)} of ${t}`:`none of ${t}`}function Sm(e){const{today:t,sevenDays:s,since:o,at:r}=e;if(e.where==="memory"){const i=s.measuredMs===t.measuredMs?"":`, and ${Et(s,"the last 7 days")}`;return`History is kept in memory only, because AGENT_LOOKOUT_HISTORY is set to off, so only the time since Agent Lookout started at ${se(o.at,r)} is counted: ${Et(t,"today")} so far${i}.`}const a=`Only the time Agent Lookout was running is counted: ${Et(t,"today")} so far, and ${Et(s,"the last 7 days")}.`;return o.at<=s.from?a:o.by==="cleared"?`${a} The history was cleared at ${se(o.at,r)}.`:`${a} The history it keeps begins at ${se(o.at,r)}.`}function Am(e,t){const s=t-e.at;if(s<=0||Y(t)!==Y(e.at)||!ve(e.today))return e;const o=new Set([...e.today.sessions,...e.sevenDays.sessions].filter(l=>l.open).map(l=>l.sessionId)),r=l=>({...l,waitedMs:l.waitedMs+o.size*s,openMs:l.openMs+o.size*s,measuredMs:l.measuredMs+s}),a=l=>l.open?{...l,waitedMs:l.waitedMs+s}:l,i=l=>({...r(l),to:t,days:l.days.map((d,c)=>c===l.days.length-1?{...r(d),to:t}:d),sessions:l.sessions.map(a).sort((d,c)=>c.waitedMs-d.waitedMs||d.name.localeCompare(c.name))});return{...e,at:t,today:i(e.today),sevenDays:i(e.sevenDays)}}function Em(e,t){const s=t==="today"?"today":"in the last 7 days";return ve(e)?`No session waited on you ${s}.`:`Nothing was measured ${s}.`}function Mm(e,t){const[s,o]=g.useState(null),[r,a]=g.useState(!1),i=e?.startedAt??null,l=e?fe(e).at:null,d=[...t].sort().join(" ");return g.useEffect(()=>{let c=!0;const u=()=>{km().then(p=>{c&&(p&&o(p),a(p===null))})},m=()=>{document.hidden||u()};u();const f=setInterval(m,bm);return document.addEventListener("visibilitychange",m),()=>{c=!1,clearInterval(f),document.removeEventListener("visibilitychange",m)}},[i,l,d]),s?{waits:s,status:"ready"}:{waits:null,status:r?"failed":"loading"}}const Yr="–",Tm=15*6e4,Im=5,Cm=[{value:"today",label:"Today"},{value:"sevenDays",label:"7 days"}];function Lm(e){return`${Math.round(e*1e5)/1e3}%`}function Om({today:e}){return n.jsx("p",{"data-part":"sum",className:"text-body text-ink-secondary",children:ve(e)?e.waits===0?"No session waited on you today":n.jsxs(n.Fragment,{children:["Sessions waited on you for"," ",n.jsx("span",{className:"font-semibold text-ink tabular-nums",children:z(e.waitedMs)})," ","today, in ",Qn(e).toLowerCase()]}):"Nothing was measured today"})}function Gs({label:e,total:t,className:s}){const o=ve(t);return n.jsxs("div",{"data-part":"figure",className:j("min-w-0",s),children:[n.jsx("dt",{className:"text-body font-medium text-ink-secondary",children:e}),n.jsxs("dd",{"data-part":"value",className:"mt-2 text-stat font-medium whitespace-nowrap tabular-nums",children:[n.jsx("span",{className:"sr-only",children:o?pe(t.waitedMs):"Not measured"}),n.jsx("span",{"aria-hidden":!0,children:o?z(t.waitedMs):Yr})]}),n.jsx("dd",{"data-part":"count",className:"mt-2 text-caption text-ink-muted",children:Qn(t)})]})}function $m({day:e,scale:t,now:s}){const o=ve(e),r=vn(e,s)==="Today",a=Vr(e,s),i=e.waitedMs-a;return n.jsxs("li",{"data-part":"day","data-day":e.day,"data-open":a>0,className:"flex items-center gap-4 text-body leading-5 max-mid:grid max-mid:grid-cols-[minmax(0,1fr)_auto] max-mid:gap-x-4 max-mid:gap-y-1.5",children:[n.jsx("span",{"data-part":"label",className:j("w-waited-name shrink-0 max-mid:col-start-1 max-mid:row-start-1 max-mid:w-auto",r?"font-semibold text-ink":"font-medium text-ink-secondary"),children:vn(e,s)}),n.jsx("span",{"data-part":"track",role:"img","aria-label":vm(e,s),className:"relative h-2.5 min-w-0 flex-1 before:absolute before:inset-x-0 before:top-1/2 before:h-px before:bg-hairline max-mid:col-start-1 max-mid:row-start-2",children:o?e.waitedMs>0?n.jsxs("span",{"data-part":"bar",className:"absolute inset-y-0 left-0 flex min-w-0.5 gap-0.5",style:{width:Lm(Math.min(1,e.waitedMs/t))},children:[i>0&&n.jsx("i",{"data-kind":"answered",className:"block h-full min-w-0.5 rounded-bar bar-answered",style:{flexGrow:i,flexBasis:0}}),a>0&&n.jsx("i",{"data-kind":"open",className:"block h-full min-w-0.5 rounded-bar bar-open",style:{flexGrow:a,flexBasis:0}})]}):null:n.jsx("i",{"data-part":"unmeasured",className:"unmeasured-hatch absolute inset-0 block rounded-bar"})}),n.jsx("span",{"data-part":"value","aria-hidden":!0,className:"w-16 shrink-0 text-right whitespace-nowrap text-ink tabular-nums max-mid:col-start-2 max-mid:row-start-1 max-mid:justify-self-end",children:o?z(e.waitedMs):Yr}),n.jsx("span",{"data-part":"measured","aria-hidden":!0,className:"w-30 shrink-0 text-right text-caption whitespace-nowrap text-ink-muted tabular-nums max-mid:col-start-2 max-mid:row-start-2",children:o?`measured ${z(e.measuredMs)}`:"not measured"})]})}function _m({period:e,now:t}){const s=g.useId(),o=Math.max(0,...e.days.map(a=>a.waitedMs)),r=Math.max(Tm,o);return n.jsxs("section",{"data-part":"by-day","aria-labelledby":s,className:"min-w-0",children:[n.jsx("h3",{id:s,className:"text-caption font-semibold text-ink-secondary",children:"By day"}),n.jsx("ul",{className:"mt-3 grid grid-cols-1 gap-2.5",children:e.days.map(a=>n.jsx($m,{day:a,scale:r,now:t},a.day))})]})}function Rm({waits:e,period:t,onPeriod:s}){const o=g.useId(),r=e[t],a=r.sessions.slice(0,Im),i=r.sessionCount-a.length;return n.jsxs("section",{"data-part":"longest","aria-labelledby":o,className:"min-w-0",children:[n.jsxs("div",{className:"flex items-center justify-between gap-4 max-mid:flex-col max-mid:items-start max-mid:gap-2.5",children:[n.jsx("h3",{id:o,className:"text-caption font-semibold text-ink-secondary",children:"Longest waits"}),n.jsx(Oe,{label:"Longest waits over",value:t,onValueChange:s,options:Cm,className:"-my-2.5 max-mid:my-0"})]}),a.length>0?n.jsxs(n.Fragment,{children:[n.jsx("ul",{className:"mt-1.5",children:a.map(l=>n.jsxs("li",{"data-part":"session","data-open":l.open,className:"flex items-start justify-between gap-4 border-b border-hairline py-2.5 last:border-b-0",children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx(X,{"data-part":"name",className:"block text-body font-semibold text-ink",children:l.name}),n.jsxs("p",{"data-part":"times",className:"mt-0.5 text-caption text-ink-secondary",children:[l.waits," ",l.waits===1?"wait":"waits",l.open&&", waiting now"]})]}),n.jsxs("p",{"data-part":"value",className:"shrink-0 text-body font-medium whitespace-nowrap text-ink tabular-nums",children:[n.jsx("span",{className:"sr-only",children:pe(l.waitedMs)}),n.jsx("span",{"aria-hidden":!0,children:z(l.waitedMs)})]})]},l.sessionId))}),i>0&&n.jsxs("p",{"data-part":"more",className:"mt-1 text-caption text-ink-muted",children:["and ",i," more"]})]}):n.jsx("p",{"data-part":"none",className:"mt-4 text-body text-ink-secondary",children:Em(r,t)})]})}function Wm({waits:e}){const[t,s]=g.useState("today");return n.jsxs("div",{"data-part":"waits",className:"px-6 pb-5.5",children:[n.jsx(Om,{today:e.today}),n.jsxs("dl",{className:"mt-4 flex items-start gap-6 max-mid:flex-col max-mid:gap-4",children:[n.jsx(Gs,{label:"Today",total:e.today}),n.jsx(Gs,{label:"Last 7 days",total:e.sevenDays,className:"border-l border-rule pl-6 max-mid:border-l-0 max-mid:pl-0"})]}),n.jsx("p",{"data-part":"coverage",className:"mt-4 max-w-3xl text-caption text-pretty text-ink-secondary",children:Sm(e)}),n.jsxs("div",{className:"mt-6 grid grid-cols-2 gap-x-12 gap-y-7 max-wide:grid-cols-1",children:[n.jsx(_m,{period:e.sevenDays,now:e.at}),n.jsx(Rm,{waits:e,period:t,onPeriod:s})]})]})}function Pm({history:e,sessions:t,asOf:s,className:o}){const r=t.filter(i=>i.status==="needs-you").map(i=>i.id),a=Mm(e,r);return n.jsx(W,{title:"Waits",className:o,children:a.waits?n.jsx(Wm,{waits:Am(a.waits,s)}):a.status==="failed"?n.jsx("div",{className:"px-6 pb-5",children:n.jsx(U,{tone:"error",title:"How long sessions waited could not be read",children:n.jsx("p",{children:"Agent Lookout did not answer when asked for it. The page asks again every 30 seconds."})})}):n.jsx(me,{label:"Reading waits"})})}function Fm(e){return e!==null&&e.isConnected&&e.tabIndex>=0}function zm(e,t,s="jump"){const o=g.useRef(null),r=g.useRef(null);return g.useLayoutEffect(()=>{const l=r.current,d=o.current;if(!l||!d)return;const c=document.activeElement;if(c===l.element)return;if(c!==null&&c!==document.body){r.current=null;return}let u=l.element.isConnected?l.element:null;if(!u){const m=[...d.querySelectorAll(e)].filter(b=>b.getAttribute(t)===l.key),f=m.find(b=>b.getAttribute("data-slot")===l.slot)??m[0],p=b=>b===null?null:f?.querySelector(`[data-part="${b}"]`)??null;u=[p(l.part),p(s)].find(Fm)??null}u?u.focus():r.current=null}),[o,{onFocus:l=>{const d=l.target,c=d.closest(e),u=c?.getAttribute(t);r.current=u?{key:u,slot:c?.getAttribute("data-slot")??null,part:d.getAttribute("data-part"),element:d}:null},onBlur:l=>{const d=l.relatedTarget;if(d instanceof Node&&o.current?.contains(d))return;if(d!==null){r.current=null;return}const c=l.target;setTimeout(()=>{r.current?.element===c&&c.isConnected&&(r.current=null)})}}]}const qr=['[data-slot="hero-session"]','[data-slot="session-row"]','[data-slot="board-card"]'],Dm=qr.join(", ");function Ks(e,t){if(ke(t)===null){Rt(t.id);return}if(!e)return;const s=CSS.escape(t.id),o=e.querySelector(qr.map(a=>`${a}[data-session="${s}"]`).join(", ")),r=o?.querySelector('[data-part="jump"]');if(!o||!r){Rt(t.id);return}o.scrollIntoView({block:"center"}),r.focus({preventScroll:!0,focusVisible:!0}),r.click()}function Um(e,t){const s=g.useRef(null);return g.useEffect(()=>{if(t!=="overview"||s.current===null)return;const o=s.current;s.current=null,Ks(e.current,o)},[e,t]),g.useCallback(o=>{if(t==="overview"){Ks(e.current,o);return}s.current=o,window.location.hash="#overview"},[e,t])}const ie={hero:"col-start-1 row-start-1",lastHour:"col-start-2 row-start-1 max-wide:col-start-1 max-wide:row-start-2",sessions:"col-start-1 row-start-2 max-wide:row-start-3",events:"col-start-2 row-start-2 max-wide:col-start-1 max-wide:row-start-4",timeline:"col-span-2 col-start-1 row-start-3 max-wide:col-span-1 max-wide:row-start-5",waits:"col-span-2 col-start-1 row-start-4 max-wide:col-span-1 max-wide:row-start-6"};function Hm({state:e,now:t,onRetry:s,onOpenHistory:o,newSince:r=null,onNewLineInView:a}){const{snapshot:i,phase:l}=e,[d,c]=zm(Dm,"data-session");if(!i&&l==="unreachable")return n.jsx(Hc,{problem:e.problem,kind:e.problemKind,onRetry:s});const u=l==="stalled"&&e.lastOkAt!==null?e.lastOkAt:t,m=i?.sessions??null,f=i?.sources??[],p=kr(Yn(m,f));return n.jsxs("div",{"data-slot":"dashboard","data-phase":l,className:"flex flex-col gap-4",children:[i&&l==="stalled"&&e.lastOkAt!==null&&n.jsx(Uc,{lastOkAt:e.lastOkAt,now:t,onRetry:s}),n.jsxs("div",{ref:d,...c,"data-slot":"overview-grid",className:"relative isolate grid grid-cols-[minmax(0,1.75fr)_minmax(0,1fr)] gap-4 max-wide:grid-cols-1",children:[p&&n.jsx("div",{"aria-hidden":!0,"data-slot":"hero-light","data-light":p,className:j(p==="lamp"?"lamp-light":"rest-light",ie.hero)},p),n.jsx(cu,{sessions:m,sources:f,events:e.events,history:e.history,now:t,asOf:u,onOpenHistory:o,className:j("z-1",ie.hero)}),n.jsx(vu,{sessions:m,sources:f,events:e.events,history:e.history,now:t,asOf:u,className:j("z-1",ie.lastHour)}),i?n.jsxs(n.Fragment,{children:[n.jsx(Zu,{sessions:i.sessions,sources:i.sources,now:u,className:j("z-1",ie.sessions)}),n.jsx(cd,{events:e.events,sessions:i.sessions,history:e.history,now:t,newSince:r,onNewLineInView:a,className:j("z-1",ie.events)})]}):n.jsxs(n.Fragment,{children:[n.jsx(W,{title:"Sessions",className:j("z-1",ie.sessions),children:n.jsx(me,{label:"Reading sessions"})}),n.jsx(W,{title:"Events",className:j("z-1",ie.events),children:n.jsx(me,{label:"Reading events"})})]}),n.jsx(wm,{sessions:m,sources:f,events:e.events,history:e.history,now:t,asOf:u,className:j("z-1",ie.timeline)}),i?n.jsx(Pm,{history:e.history,sessions:i.sessions,asOf:u,className:j("z-1",ie.waits)}):n.jsx(W,{title:"Waits",className:j("z-1",ie.waits),children:n.jsx(me,{label:"Reading waits"})})]})]})}function Bm({className:e}){return n.jsxs("svg",{"data-slot":"icon",viewBox:"0 0 20 20","aria-hidden":!0,fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round",className:j("size-icon shrink-0",e),children:[n.jsx("rect",{x:"2.75",y:"3.25",width:"14.5",height:"4",rx:"1"}),n.jsx("rect",{x:"2.75",y:"10.25",width:"8.5",height:"6.5",rx:"1"}),n.jsx("rect",{x:"14.25",y:"10.25",width:"3",height:"6.5",rx:"1"})]})}function Gm({className:e}){return n.jsxs("svg",{"data-slot":"icon",viewBox:"0 0 20 20","aria-hidden":!0,fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:j("size-icon shrink-0",e),children:[n.jsx("path",{d:"M2.75 4.5h4l3.4 4.2M2.75 10h7.5M2.75 15.5h4l3.4-4.2"}),n.jsx("circle",{cx:"13.75",cy:"10",r:"3.25"})]})}function Km({className:e}){return n.jsxs("svg",{"data-slot":"icon",viewBox:"0 0 20 20","aria-hidden":!0,fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",className:j("size-icon shrink-0",e),children:[n.jsx("path",{d:"M2.75 6.25h7M14.75 6.25h2.5M2.75 13.75h2.5M10.25 13.75h7"}),n.jsx("circle",{cx:"12.25",cy:"6.25",r:"2.25"}),n.jsx("circle",{cx:"7.75",cy:"13.75",r:"2.25"})]})}function Jr({className:e}){return n.jsx("svg",{"data-slot":"icon",viewBox:"0 0 14 14","aria-hidden":!0,fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round",className:j("size-mark shrink-0",e),children:n.jsx("path",{d:"M11.9 8.4A5.2 5.2 0 0 1 5.6 2.1a5.2 5.2 0 1 0 6.3 6.3z"})})}function Xr({className:e}){return n.jsxs("svg",{"data-slot":"icon",viewBox:"0 0 14 14","aria-hidden":!0,fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",className:j("size-mark shrink-0",e),children:[n.jsx("circle",{cx:"7",cy:"7",r:"2.6"}),n.jsx("path",{d:"M7 1v1.4M7 11.6V13M1 7h1.4M11.6 7H13M2.8 2.8l1 1M10.2 10.2l1 1M2.8 11.2l1-1M10.2 3.8l1-1"})]})}const Zr="agent-lookout-theme",Vs="dark",Qr="(prefers-color-scheme: light)";function Vm(e){return e==="light"||e==="dark"||e==="system"}function Ym(){try{const e=localStorage.getItem(Zr);return Vm(e)?e:Vs}catch{return Vs}}function ea(){return window.matchMedia(Qr).matches?"light":"dark"}function ta(e){return e==="system"?ea():e}let nt=null;const Tt=new Set;let st=null;function na(){const e=getComputedStyle(document.documentElement).getPropertyValue("--ground-top").trim();if(e==="")return;let t=document.head.querySelector('meta[name="theme-color"]');t||(t=document.createElement("meta"),t.name="theme-color",document.head.append(t)),t.content!==e&&(t.content=e)}function sa(e){nt=e,document.documentElement.setAttribute("data-theme",e.resolved),na();for(const t of Tt)t()}function qm(){if(st)return;const e=window.matchMedia(Qr),t=()=>{nt?.preference==="system"&&sa({preference:"system",resolved:ea()})};e.addEventListener("change",t),st=()=>e.removeEventListener("change",t)}function oa(){if(!nt){const e=Ym();nt={preference:e,resolved:ta(e)}}return nt}function Jm(e){Tt.add(e),qm();const{resolved:t}=oa();return document.documentElement.getAttribute("data-theme")!==t&&document.documentElement.setAttribute("data-theme",t),na(),()=>{Tt.delete(e),Tt.size===0&&st&&(st(),st=null)}}function Xm(e){try{localStorage.setItem(Zr,e)}catch{}sa({preference:e,resolved:ta(e)})}function ra(){return{...g.useSyncExternalStore(Jm,oa),setPreference:Xm}}const Zm=[{value:"dark",label:"Night",name:"Dark theme",icon:n.jsx(Jr,{})},{value:"light",label:"Day",name:"Light theme",icon:n.jsx(Xr,{})}];function Qm({className:e}){const{resolved:t,setPreference:s}=ra();if(Vt()){const r=t==="dark"?"light":"dark",a=r==="light"?"Switch to Day":"Switch to Night";return n.jsx(Z,{content:a,align:"end",children:n.jsx(J,{size:"icon","aria-label":a,"data-part":"theme",onClick:()=>s(r),className:e,children:t==="dark"?n.jsx(Jr,{}):n.jsx(Xr,{})})})}return n.jsx(Oe,{label:"Theme",value:t,onValueChange:s,options:Zm,className:e})}const ef=new Set(["button","checkbox","color","file","hidden","image","radio","range","reset","submit"]);function tf(e){if(!e)return!1;if(e.isContentEditable===!0)return!0;switch(e.tagName){case"TEXTAREA":case"SELECT":return!0;case"INPUT":return!ef.has((e.type??"text").toLowerCase());default:return!1}}function es(e=typeof navigator>"u"?"":navigator.platform||navigator.userAgent||""){return/Mac|iPhone|iPad|iPod/.test(e)}function nf(e){return/^[a-z]$/i.test(e.key)?e.key.toLowerCase():e.code?.startsWith("Key")?e.code.slice(3).toLowerCase():e.key}function sf(e,{mac:t,typing:s}){return(t?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey)&&!e.altKey&&!e.shiftKey&&nf(e)==="k"?"search":s||e.metaKey||e.ctrlKey||e.altKey?null:e.key==="/"?"search":e.key==="?"?"shortcuts":null}function aa(e){return e?{shown:"⌘K",said:"Command K"}:{shown:"Ctrl+K",said:"Control K"}}function of(e){return e?"/ Meta+K":"/ Control+K"}const Ys=[{shown:"←",said:"Left arrow"},{shown:"→",said:"Right arrow"}];function rf(e){return[{title:"On every view",rows:[{does:"Find a session",keys:[{shown:"/"},aa(e)]},{does:"Show these shortcuts",keys:[{shown:"?"}]},{does:"Close a dialog",keys:[{shown:"Esc",said:"Escape"}]}]},{title:"In the search",rows:[{does:"Move through the sessions",keys:[{shown:"↑",said:"Up arrow"},{shown:"↓",said:"Down arrow"}]},{does:"Jump to the session, or open its details",keys:[{shown:"Enter"}]}]},{title:"In a chart or the timeline",rows:[{does:"Move along it",keys:Ys},{does:"Go to the first or the last",keys:[{shown:"Home"},{shown:"End"}]},{does:"Ten steps in a history chart",keys:[{shown:"Page Up"},{shown:"Page Down"}]}]},{title:"In a switch",rows:[{does:"Choose the next or the previous option",keys:Ys}]}]}function af({onSearch:e}){const t=es();return n.jsx(Z,{content:`Find a session: / or ${aa(t).shown}`,align:"end",children:n.jsx(J,{size:"icon","aria-label":"Find a session","aria-haspopup":"dialog","aria-keyshortcuts":of(t),"data-part":"search",onClick:e,children:n.jsx(zo,{"aria-hidden":!0,className:"size-4",strokeWidth:1.75})})})}function lf({phase:e,snapshot:t,lastOkAt:s,now:o,onSearch:r}){const a=zc(e,t,o,s),i=Vt();return n.jsxs("header",{"data-slot":"header",className:"glass-chrome glass-blur sticky top-window z-30 flex h-header shrink-0 items-center gap-5 pr-2.5 pl-6 max-mid:gap-2 max-mid:pl-4",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-5 max-mid:flex-col max-mid:items-start max-mid:gap-0.5",children:[n.jsx("h1",{className:"shrink-0 text-wordmark font-semibold whitespace-nowrap",children:"Agent Lookout"}),n.jsxs("p",{"data-slot":"status-line","data-status":a.key,className:"flex max-w-full min-w-0 items-baseline gap-3 border-l border-rule pl-5 text-body text-ink-secondary max-mid:border-l-0 max-mid:pl-0",children:[n.jsx("a",{href:"#sources",className:"truncate rounded-bar transition-colors duration-120 hover:text-ink",children:i?a.short:a.text}),a.fact&&n.jsx("span",{"data-part":"checked","aria-hidden":a.fact.ticking||void 0,className:j("shrink-0 text-caption whitespace-nowrap text-ink-muted tabular-nums",a.fact.ticking&&"max-wide:hidden"),children:a.fact.text})]})]}),n.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-2.5 max-mid:gap-1.5",children:[r&&n.jsx(af,{onSearch:r}),n.jsx(Qm,{})]})]})}function ia(e){return e.normalize("NFKD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function cf(e){return ia(e).split(/\s+/u).filter(Boolean)}function df(e,t){return ia([e.name,e.project,e.git?.branch,e.git?.commit,t].filter(s=>typeof s=="string").join(" "))}function uf(e,t,s){const o=pt(e).flatMap(a=>a.sessions),r=cf(t);return r.length===0?o:o.filter(a=>{const i=df(a,s(a));return r.every(l=>i.includes(l))})}function mf(e,t){if(e.statusSince===null)return{shown:"–",said:"time not reported"};const s=Math.max(0,t-e.statusSince);return e.status==="finished"||e.status==="failed"?{shown:`${$t(s)} ago`,said:`${at(s)} ago`}:{shown:$t(s),said:`for ${at(s)}`}}function ff(e){if(e.project===null)return null;const{branch:t,commit:s}=e.git??{};return t!==void 0?`${e.project} on branch ${t}`:s!==void 0?`${e.project} at commit ${s}`:e.project}function hf({session:e,agent:t,asOf:s,id:o,active:r,onPoint:a,onPick:i}){const{mark:l,word:d,quiet:c}=Vn(e),u=mf(e,s),m=ke(e),f=[e.name,`${d} ${u.said}`,ff(e),t,m&&`Jump to ${m.where}`].filter(Boolean).join(", "),{branch:p,commit:b}=e.git??{};return n.jsxs("li",{id:o,role:"option","aria-selected":r,"aria-label":f,"data-slot":"search-result","data-session":e.id,"data-status":e.status,onPointerMove:a,onClick:i,className:j("flex cursor-pointer items-start gap-3 rounded-inner px-3.5 py-2.5",r&&"bg-fill-selected"),children:[n.jsx(V,{kind:l,className:"mt-0.75"}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("p",{className:"flex items-baseline justify-between gap-3",children:[n.jsx("span",{"data-part":"name",className:j("min-w-0 text-row wrap-anywhere",c?"font-medium text-ink-secondary":"font-semibold text-ink"),children:e.name}),n.jsxs("span",{"data-part":"status",className:"shrink-0 text-body whitespace-nowrap text-ink-secondary",children:[d," ",n.jsx("span",{"data-part":"duration",className:j("tabular-nums",c?"text-ink-secondary":"text-ink"),children:u.shown})]})]}),n.jsxs("p",{"data-part":"place",className:"text-body wrap-break-word text-ink-secondary",children:[e.project!==null&&n.jsxs(n.Fragment,{children:[n.jsx("span",{"data-part":"project",children:e.project}),p!==void 0?n.jsxs(n.Fragment,{children:[" ","on ",n.jsx("span",{"data-part":"branch",children:p})]}):b!==void 0?n.jsxs(n.Fragment,{children:[" ","at"," ",n.jsx("span",{"data-part":"commit",className:"font-mono text-fact",children:b})]}):null," "]}),n.jsxs("span",{className:"whitespace-nowrap",children:[e.project!==null&&n.jsx("span",{"aria-hidden":!0,className:"mr-1.5 ml-0.5",children:"·"}),n.jsx("span",{"data-part":"agent",children:t})]})]})]})]})}function pf({state:e,now:t,onChoose:s,onShortcuts:o}){const[r,a]=g.useState(""),[i,l]=g.useState(null),d=g.useId(),c=e.snapshot?.sessions??[],u=e.snapshot?.sources??[],m=e.phase==="stalled"&&e.lastOkAt!==null?e.lastOkAt:t,f=M=>Fn(M,u),p=uf(c,r,f),b=p.findIndex(M=>M.id===i),w=p.length===0?-1:Math.max(0,b),h=p[w],N=M=>`${d}-${encodeURIComponent(M.id)}`,y=h?N(h):void 0,v=h?ke(h):null;g.useEffect(()=>{y&&document.getElementById(y)?.scrollIntoView({block:"nearest"})},[y]);const k=M=>{if(!M.nativeEvent.isComposing)if(M.key==="ArrowDown"||M.key==="ArrowUp"){M.preventDefault();const x=p[(w+(M.key==="ArrowDown"?1:-1)+p.length)%p.length];x&&l(x.id)}else M.key==="Enter"&&(M.preventDefault(),h&&s(h))},E=e.snapshot?c.length===0?"No agents are running.":p.length===0?`No session matches “${r.trim()}”.`:null:"Agent Lookout has not read any sessions yet.",I=p.length===0?E??"":`${p.length} ${p.length===1?"session":"sessions"}`;return n.jsxs(n.Fragment,{children:[n.jsx(fo,{className:"sr-only",children:"Find a session"}),n.jsxs("div",{className:"relative",children:[n.jsx(zo,{"aria-hidden":!0,strokeWidth:1.75,className:"pointer-events-none absolute top-1/2 left-3.5 size-4 -translate-y-1/2 text-ink-muted"}),n.jsx("input",{type:"text",role:"combobox","aria-label":"Find a session","aria-expanded":!0,"aria-controls":d,"aria-autocomplete":"list","aria-activedescendant":y,"data-part":"field",placeholder:"Name, folder, branch or agent",autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,enterKeyHint:"go",value:r,onChange:M=>{a(M.target.value),l(null)},onKeyDown:k,className:"h-11 w-full rounded-inner bg-transparent pr-3.5 pl-10 text-row text-ink placeholder:text-ink-muted"})]}),n.jsx("ul",{id:d,role:"listbox","aria-label":"Sessions","data-part":"results",tabIndex:-1,onPointerDown:M=>M.preventDefault(),className:"thin-scroll mt-2 max-h-[min(26rem,55vh)] overflow-y-auto border-t border-hairline pt-2",children:p.map((M,x)=>n.jsx(hf,{session:M,agent:f(M),asOf:m,id:N(M),active:x===w,onPoint:()=>{M.id!==h?.id&&l(M.id)},onPick:()=>s(M)},M.id))}),E&&n.jsx("p",{"data-part":"empty",className:"px-3.5 pt-4 pb-6 text-center text-body text-ink-secondary",children:E}),n.jsxs("div",{className:"mt-2 flex items-baseline justify-between gap-4 border-t border-hairline px-3.5 pt-2.5 pb-1 text-caption text-ink-muted",children:[n.jsx("p",{"data-part":"enter",className:"min-w-0",children:h&&n.jsxs(n.Fragment,{children:[n.jsx("kbd",{className:"font-mono",children:"Enter"})," ",v?`jumps to it in ${v.where}`:"opens its details"]})}),n.jsxs("button",{type:"button","aria-haspopup":"dialog","data-part":"shortcuts",onClick:o,className:"-mx-1.5 -my-0.5 shrink-0 cursor-pointer rounded-row px-1.5 py-0.5 whitespace-nowrap transition-colors duration-120 hover:bg-fill-hover hover:text-ink-secondary",children:[n.jsx("kbd",{className:"font-mono",children:"?"})," for shortcuts"]})]}),n.jsx("p",{role:"status","data-part":"count",className:"sr-only",children:I})]})}function xf({open:e,onOpenChange:t,state:s,now:o,onChoose:r,onShortcuts:a}){const i=g.useRef(null),l=g.useRef(null),d=c=>{l.current=c,t(!1)};return n.jsx(lo,{open:e,onOpenChange:t,children:n.jsxs(co,{children:[n.jsx("div",{"aria-hidden":!0,"data-slot":"scrim","data-state":e?"open":"closed",className:"fixed inset-0 z-40 bg-scrim data-[state=closed]:animate-fade-out data-[state=open]:animate-fade-in"}),n.jsx(uo,{className:"fixed inset-0 z-50 overflow-y-auto px-4 pt-[12vh] pb-24 data-[state=closed]:animate-fade-out",children:n.jsx(mo,{"data-slot":"search-dialog","aria-describedby":void 0,className:j("glass-float glass-blur mx-auto w-[min(600px,100%)] p-2.5","data-[state=closed]:animate-drop data-[state=open]:animate-rise-fast"),onOpenAutoFocus:()=>{i.current=document.activeElement instanceof HTMLElement?document.activeElement:null,l.current=null},onCloseAutoFocus:c=>{c.preventDefault();const u=l.current,m=i.current;if(l.current=null,i.current=null,u!==null&&u!=="shortcuts"){r(u.session);return}m?.focus(),u==="shortcuts"&&a()},onKeyDown:c=>{const u=c.target instanceof HTMLInputElement&&c.target.value!=="";c.key!=="?"||u||(c.preventDefault(),d("shortcuts"))},children:n.jsx(pf,{state:s,now:o,onChoose:c=>d({session:c}),onShortcuts:()=>d("shortcuts")})})})]})})}const gf={sm:"w-[min(440px,100%)]",default:"w-[min(600px,100%)]",wide:"w-[min(760px,100%)]"};function wf({open:e,onOpenChange:t,title:s,description:o,size:r="default",actions:a,focusTitle:i=!1,returnFocus:l,children:d}){const c=g.useRef(null),u=g.useRef(null);return n.jsx(lo,{open:e,onOpenChange:t,children:n.jsxs(co,{children:[n.jsx("div",{"aria-hidden":!0,"data-slot":"scrim","data-state":e?"open":"closed",className:"fixed inset-0 z-40 bg-scrim data-[state=closed]:animate-fade-out data-[state=open]:animate-fade-in"}),n.jsx(uo,{className:"fixed inset-0 z-50 overflow-y-auto px-4 pt-[6vh] pb-24 data-[state=closed]:animate-fade-out",children:n.jsxs(mo,{"data-slot":"details-modal",className:j("glass-float glass-blur mx-auto px-6 pt-5 pb-6","data-[state=closed]:animate-drop data-[state=open]:animate-rise-fast",gf[r]),...o?{}:{"aria-describedby":void 0},onOpenAutoFocus:m=>{c.current=document.activeElement instanceof HTMLElement?document.activeElement:null,i&&(m.preventDefault(),u.current?.focus())},onCloseAutoFocus:m=>{m.preventDefault();const f=l?.(c.current)??c.current;f?.isConnected&&f.focus(),c.current=null},children:[n.jsxs("header",{className:"flex items-start justify-between gap-4",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx(fo,{ref:u,tabIndex:i?-1:void 0,className:"text-title font-semibold wrap-anywhere outline-none",children:s}),o&&n.jsx(La,{className:"mt-1 max-w-[56ch] text-body text-ink-secondary",children:o})]}),n.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[a,n.jsx(Oa,{asChild:!0,children:n.jsx(J,{size:"icon","aria-label":"Close",children:n.jsx(Vi,{"aria-hidden":!0,className:"size-4",strokeWidth:1.75})})})]})]}),d]})})]})})}const bf={"⌘":Gi,"↑":Hi,"↓":zi,"←":Di,"→":Ui};function yf({shown:e}){return e.split(/([⌘↑↓←→])/).filter(Boolean).map((t,s)=>{const o=bf[t];return o?n.jsx(o,{"aria-hidden":!0,"data-sign":t,strokeWidth:1.75,className:"inline-block size-3.5"},s):t})}function kf({keys:e}){return n.jsx(n.Fragment,{children:e.map((t,s)=>n.jsxs(g.Fragment,{children:[s>0&&n.jsx("span",{className:"font-normal text-ink-secondary",children:" or "}),t.said?n.jsxs("kbd",{className:"font-mono text-fact whitespace-nowrap",children:[n.jsx("span",{"aria-hidden":!0,children:n.jsx(yf,{shown:t.shown})}),n.jsx("span",{className:"sr-only",children:t.said})]}):n.jsx("kbd",{className:"font-mono text-fact whitespace-nowrap",children:t.shown})]},t.shown))})}function jf({open:e,onOpenChange:t}){const s=rf(es());return n.jsx(wf,{open:e,onOpenChange:t,title:"Keyboard shortcuts",description:n.jsxs(n.Fragment,{children:[n.jsx("kbd",{className:"font-mono text-fact",children:"/"})," and"," ",n.jsx("kbd",{className:"font-mono text-fact",children:"?"})," work wherever you are not typing."]}),size:"sm",children:n.jsx("div",{"data-slot":"shortcuts",className:"mt-2",children:s.map(o=>n.jsxs("div",{"data-part":"group",className:"mt-4",children:[n.jsx("h3",{className:"text-caption font-semibold text-ink-secondary",children:o.title}),n.jsx(Ne,{className:"mt-0.5",children:o.rows.map(r=>n.jsx(B,{label:r.does,children:n.jsx(kf,{keys:r.keys})},r.does))})]},o.title))})})}function Nf({lit:e=!1,className:t}){return n.jsxs("svg",{"data-slot":"lookout-mark","data-lit":e,viewBox:"0 0 32 32","aria-hidden":!0,fill:"none",className:j("size-7.5 shrink-0",t),children:[n.jsx("path",{d:"M3.63 20a13 13 0 0 0 24.74 0z",fill:"currentColor",opacity:"0.13"}),n.jsx("circle",{cx:"16",cy:"16",r:"13",stroke:"currentColor",strokeWidth:"1.75"}),n.jsx("path",{d:"M3.63 20h24.74",stroke:"currentColor",strokeWidth:"1.75"}),e?n.jsxs(n.Fragment,{children:[n.jsx("circle",{"data-part":"lamp",cx:"20.6",cy:"15.1",r:"2.7",strokeWidth:"1",className:"fill-status-needs-you stroke-status-needs-you-edge"}),n.jsx("path",{"data-part":"glint",d:"M18.9 23.6h3.4",strokeWidth:"1.5",strokeLinecap:"round",className:"stroke-status-needs-you-edge"})]}):n.jsx("circle",{"data-part":"lamp",cx:"20.6",cy:"15.1",r:"2.7",stroke:"currentColor",strokeWidth:"1.4"})]})}const vf="/api/app/update",Sf="/api/app/update/check",Af="/api/app/update/install",Ef="/api/app/update/setting",ts={check:"check-for-updates",install:"install-update",setting:"update-setting"},Mf={translocated:"macOS runs this copy from a read-only place, because it was opened where it was downloaded. Move Agent Lookout to the Applications folder, open it from there, and check again.","disk-image":"This copy runs from its disk image or another disk. Drag Agent Lookout to the Applications folder, open it from there, and check again.","read-only":"This copy is in a folder it cannot change. Move Agent Lookout to the Applications folder, open it from there, and check again.",development:"This is a development run, which never installs an update."},la="#settings/updates",Sn=[{id:"overview",label:"Overview",href:"#overview"},{id:"sources",label:"Sources",href:"#sources"},{id:"settings",label:"Settings",href:"#settings"}];function Tf(e){switch(e){case"#sources":return"sources";case"#settings":case la:return"settings";default:return"overview"}}function If(e){return Sn.find(t=>t.id===e)?.label??"Overview"}const Cf={overview:Bm,sources:Gm,settings:Km};function Lf(e){return e===null?"Agent Lookout":e===0?"Agent Lookout, no session needs you":`Agent Lookout, ${e} ${e===1?"session needs":"sessions need"} you`}function Of({current:e,needsYou:t}){const s=t!==null&&t>0;return n.jsx("nav",{"data-slot":"rail","aria-label":"Views",className:"glass-chrome z-20 w-rail shrink-0 max-mid:w-14 in-app:w-rail",children:n.jsxs("div",{className:"sticky top-window flex flex-col items-center",children:[n.jsx("div",{"data-slot":"rail-buttons","aria-hidden":!0,className:"hidden h-header w-full in-app-windowed:block"}),n.jsx("a",{href:Sn[0]?.href,"data-slot":"rail-mark","data-lit":s,"aria-label":Lf(t),className:"grid h-header w-full place-items-center rounded-t-chrome text-ink focus-visible:-outline-offset-2 in-app-windowed:rounded-inner",children:n.jsx(Nf,{lit:s})}),n.jsx("ul",{className:"flex w-full flex-col items-center gap-1 py-3",children:Sn.map(o=>{const r=Cf[o.id],a=o.id===e;return n.jsx("li",{children:n.jsxs("a",{href:o.href,"data-slot":"rail-link","data-view":o.id,"aria-current":a?"page":void 0,className:j("flex w-15.5 flex-col items-center gap-1.25 rounded-inner pt-2.5 pb-2.25","text-micro leading-none font-medium transition-colors duration-120","max-mid:w-11 max-mid:py-2.5",a?"bg-fill-selected text-ink inset-ring inset-ring-control-rim inset-shadow-top":"text-ink-secondary hover:bg-fill-hover hover:text-ink"),children:[n.jsx(r,{}),n.jsx("span",{className:"max-mid:sr-only",children:o.label})]})},o.id)})})]})})}const $f=1e4,_f=["memory-only","not-writing","failed"],Rf=300;async function Wf(e=$f){try{const t=await re("/api/history/clear",{method:"POST",headers:{"Content-Type":"application/json",[zt]:pl},body:"{}",signal:AbortSignal.timeout(e)}),s=await t.json(),o=typeof s=="object"&&s!==null?s:{};if(t.ok&&o.ok===!0&&typeof o.clearedAt=="number")return{ok:!0,at:o.clearedAt};const r=typeof o.error=="string"&&o.error.length<=Rf?o.error:null;return{ok:!1,reason:_f.find(a=>a===o.reason)??"failed",error:r}}catch{return{ok:!1,reason:"no-answer",error:null}}}const Pf=1024,qs=1024*1024;function Js(e){return e<=0?"0 KB":e<qs?`${Math.max(1,Math.round(e/Pf))} KB`:`${(e/qs).toFixed(1).replace(/\.0$/,"")} MB`}function Ff(e){const t=Math.round(e/864e5);return`${t} ${t===1?"day":"days"}`}function zf(e,t,s){const o=Ff(e.maxAgeMs),r=Js(e.maxBytes);return e.where==="memory"||e.folder===null?{state:"History is kept in memory only.",facts:null,note:null,explanation:["The Events log and the charts start empty each time Agent Lookout starts, because AGENT_LOOKOUT_HISTORY is set to off.",`Without it, they are kept on this computer for ${o}, so they are still there after a restart.`]}:{state:e.problem===null?`History is kept on this computer for ${o}.`:"History is kept in memory for now.",facts:{folder:e.folder,holds:e.bytes===null?"–":`${Js(e.bytes)} of ${r}`,since:se(t.at,s)},note:e.problem===null?null:{title:"This copy is not writing history",detail:e.problem},explanation:[e.problem===null?"The Events log and the counts behind the charts are written to this folder every few seconds, so they are still there when Agent Lookout starts again. It holds no prompt and nothing a waiting session is asking.":"The copy that writes the history writes the Events log and the counts behind the charts to this folder every few seconds, so they are still there when Agent Lookout starts again. It holds no prompt and nothing a waiting session is asking.",`A day's history is deleted ${o} after the day ends, and the oldest goes first once the files would hold more than ${r}.`]}}function Df(e){return e.reason==="no-answer"?"Agent Lookout did not answer. Try again in a moment.":e.error??"Agent Lookout could not clear it. Try again in a moment."}const Uf="Clear the Events log and the charts? This cannot be undone.";function Hf({history:e=null,now:t,onCleared:s,clear:o=Wf}){const[r,a]=g.useState({kind:"idle"}),i=g.useRef(null),l=g.useRef(null),d=g.useRef(null);g.useEffect(()=>{const h=d.current;d.current=null,h==="cancel"?l.current?.focus():h==="clear"&&i.current?.focus()},[r]);const c=e?.kept??null;if(e===null||c===null)return n.jsx(W,{title:"History",children:n.jsx("div",{className:"px-6 pb-6",children:n.jsx("p",{"data-part":"state","aria-live":"polite",className:"text-body font-medium text-ink",children:e===null?null:"Where the history is kept could not be read."})})});const u=zf(c,fe(e),t),m=c.canClear,f=r.kind==="confirming"&&m,p=()=>{d.current="cancel",a({kind:"confirming",busy:!1})},b=()=>{d.current="clear",a({kind:"idle"})},w=()=>{r.kind!=="confirming"||r.busy||(a({kind:"confirming",busy:!0}),o().then(h=>{d.current="clear",h.ok?(a({kind:"cleared",at:h.at}),s?.()):a({kind:"failed",words:Df(h)})}))};return n.jsx(W,{title:"History",children:n.jsxs("div",{className:"px-6 pb-6",children:[n.jsxs("div",{className:"flex min-h-button flex-wrap items-center gap-x-3 gap-y-2",children:[n.jsx("p",{"data-part":"state","aria-live":"polite",className:"text-body font-medium text-ink",children:f?Uf:u.state}),m&&(f?n.jsxs(n.Fragment,{children:[n.jsx(J,{size:"sm",onClick:w,"aria-disabled":r.busy||void 0,children:"Clear history"}),n.jsx(J,{ref:l,size:"sm",onClick:b,children:"Cancel"})]}):n.jsx(J,{ref:i,size:"sm",onClick:p,children:"Clear history"}))]}),u.facts&&n.jsxs(Ne,{className:"mt-3",children:[n.jsx(B,{label:"Folder",mono:!0,children:n.jsx("span",{"data-part":"folder",className:"wrap-anywhere select-text",children:u.facts.folder.split("/").map((h,N,y)=>n.jsxs(g.Fragment,{children:[h,N<y.length-1&&n.jsxs(n.Fragment,{children:["/",n.jsx("wbr",{})]})]},N))})}),n.jsx(B,{label:"Holds",children:n.jsx("span",{className:"tabular-nums",children:u.facts.holds})}),n.jsx(B,{label:"Since",children:n.jsx("span",{className:"tabular-nums",children:u.facts.since})})]}),u.note&&n.jsx(U,{title:u.note.title,className:"mt-3",children:n.jsx("p",{children:n.jsx(ue,{children:u.note.detail})})}),r.kind==="failed"&&n.jsx(U,{title:"The history could not be cleared",className:"mt-3",children:n.jsx("p",{children:n.jsx(ue,{children:r.words})})}),r.kind==="cleared"&&n.jsxs("p",{"data-part":"outcome",role:"status",className:"mt-3 text-body text-ink",children:["History cleared at ",n.jsx("span",{className:"tabular-nums",children:se(r.at,t)}),"."]}),u.explanation.map((h,N)=>n.jsx("p",{className:N===0?"mt-3 text-body text-ink-secondary":"mt-2 text-body text-ink-secondary",children:n.jsx(ue,{children:h})},h))]})})}const Bf="/api/app/menu-bar",Gf="/api/app/menu-bar/setting",Kf="menu-bar-setting",ca=4e3;function da(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;const{show:t}=e;return typeof t=="boolean"?{show:t}:null}async function Vf(){try{const e=await re(Bf,{signal:AbortSignal.timeout(ca)});return e.ok?da(await e.json()):null}catch{return null}}async function Yf(e){try{const t=await re(Gf,{method:"POST",headers:{"Content-Type":"application/json",[zt]:Kf},body:JSON.stringify({show:e}),signal:AbortSignal.timeout(ca)});return t.ok?da(await t.json()):null}catch{return null}}function qf(){const[e,t]=g.useState(null),s=g.useRef(!0);g.useEffect(()=>(s.current=!0,Vf().then(r=>{s.current&&t(r??"unknown")}),()=>{s.current=!1}),[]);const o=g.useCallback(r=>{Yf(r).then(a=>{s.current&&a!==null&&t(a)})},[]);return{reading:e,setShown:o}}const Jf=[{value:"off",label:"Off"},{value:"on",label:"On"}],Xs="Show in menu bar";function Xf(){const{reading:e,setShown:t}=qf();return n.jsx(W,{title:"Menu bar","data-part":"menu-bar",children:n.jsxs("div",{className:"px-6 pb-6",children:[n.jsxs("div",{"data-part":"row",className:"flex min-h-9 items-center justify-between gap-6",children:[e==="unknown"&&n.jsx("p",{"data-part":"state",className:"text-body font-medium text-ink",children:"Whether Agent Lookout is in the menu bar could not be read."}),e!==null&&e!=="unknown"&&n.jsxs(n.Fragment,{children:[n.jsx("span",{"aria-hidden":!0,className:"text-body text-ink",children:Xs}),n.jsx(Oe,{label:Xs,value:e.show?"on":"off",onValueChange:s=>t(s==="on"),options:Jf})]})]}),n.jsx("p",{className:"mt-3 text-body text-ink-secondary",children:"While it is on, Agent Lookout's icon in the menu bar shows how many sessions need you, with the window open or closed. Click it to list them, with how long each has waited and what it is asking, and choose one to open its details."})]})})}const ns=4e3,Zf=3e4,Qf=["translocated","disk-image","read-only","development"];function ss(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const ze=e=>typeof e=="string"&&e!=="",Ze=e=>typeof e=="string"&&e.startsWith("https://"),An=e=>typeof e=="number"&&Number.isSafeInteger(e)&&e>=0;function eh(e){if(!ss(e))return null;switch(e.phase){case"idle":case"checking":case"up-to-date":case"no-release":return{phase:e.phase};case"downloading":return ze(e.version)&&Ze(e.notesUrl)&&An(e.received)&&An(e.total)?{phase:"downloading",version:e.version,notesUrl:e.notesUrl,received:e.received,total:e.total}:null;case"ready":case"installing":return ze(e.version)&&Ze(e.notesUrl)?{phase:e.phase,version:e.version,notesUrl:e.notesUrl}:null;case"cannot-install":{const t=Qf.find(s=>s===e.refusal);return ze(e.version)&&Ze(e.notesUrl)&&t!==void 0?{phase:"cannot-install",version:e.version,notesUrl:e.notesUrl,refusal:t}:null}case"failed":{const t=e.step==="check"||e.step==="download"||e.step==="install"?e.step:null;return t===null||!ze(e.reason)?null:{phase:"failed",step:t,reason:e.reason,version:ze(e.version)?e.version:null,notesUrl:Ze(e.notesUrl)?e.notesUrl:null}}default:return null}}function En(e){if(!ss(e))return null;const t=eh(e.update);if(t===null||!ze(e.version)||typeof e.automatic!="boolean"||!Ze(e.releasesUrl))return null;const s=e.lastCheckedAt;return{version:e.version,automatic:e.automatic,lastCheckedAt:An(s)&&s>0?s:null,releasesUrl:e.releasesUrl,update:t}}async function th(e){const t=await e.json();return e.ok?En(t):ss(t)?En(t.status):null}async function Zs(){try{const e=await re(vf,{signal:AbortSignal.timeout(ns)});return e.ok?En(await e.json()):null}catch{return null}}async function os(e,t,s,o){try{const r=await re(e,{method:"POST",headers:{"Content-Type":"application/json",[zt]:t},body:JSON.stringify(s),signal:AbortSignal.timeout(o)});return await th(r)}catch{return null}}function nh(){return os(Sf,ts.check,{},Zf)}function sh(){return os(Af,ts.install,{},ns)}function oh(e){return os(Ef,ts.setting,{automatic:e},ns)}const rh=1e3,ah=5e3;function ih(e){const{phase:t}=e.update;return t==="downloading"||t==="ready"||t==="installing"}function lh(e){if(e===null||e==="unknown")return!1;const{phase:t}=e.update;return t==="checking"||t==="downloading"||t==="installing"}function ch(){const[e,t]=g.useState(null),[s,o]=g.useState(null),r=g.useRef(!0),a=g.useCallback(u=>{r.current&&t(u??"unknown")},[]);g.useEffect(()=>(r.current=!0,Zs().then(a),()=>{r.current=!1}),[a]);const i=lh(e);g.useEffect(()=>{if(e===null)return;const u=setTimeout(()=>{Zs().then(a)},i?rh:ah);return()=>clearTimeout(u)},[e,i,a]);const l=g.useCallback(()=>{o("check"),t(u=>u===null||u==="unknown"||ih(u)?u:{...u,update:{phase:"checking"}}),nh().then(u=>{r.current&&(o(null),u!==null&&t(u))})},[]),d=g.useCallback(()=>{o("install"),sh().then(u=>{r.current&&(o(null),u!==null&&t(u))})},[]),c=g.useCallback(u=>{oh(u).then(m=>{r.current&&m!==null&&t(m)})},[]);return{reading:e,pressed:s,check:l,install:d,setAutomatic:c}}const dh=1e3;let rs=Date.now(),Ye=null;const It=new Set;function ua(){rs=Date.now();for(const e of It)e()}function Qs(){document.hidden||ua()}function uh(e){return It.add(e),Ye===null&&(rs=Date.now(),Ye=setInterval(ua,dh),document.addEventListener("visibilitychange",Qs)),()=>{It.delete(e),It.size===0&&Ye!==null&&(clearInterval(Ye),Ye=null,document.removeEventListener("visibilitychange",Qs))}}function mh(){return rs}function Yt(){return g.useSyncExternalStore(uh,mh)}const fh=1024*1024;function eo(e){return`${Math.round(e/fh)} MB`}function hh(e,t){return e.lastCheckedAt===null?"Not yet":se(e.lastCheckedAt,t)}function ph(e){const{update:t}=e,s={detail:null,install:!1,canCheck:!0,notesUrl:null,note:null};switch(t.phase){case"idle":return{...s,state:e.automatic?"Agent Lookout checks about once a day.":"Agent Lookout checks only when you ask."};case"checking":return{...s,state:"Checking for updates…",canCheck:!1};case"up-to-date":return{...s,state:"You're up to date."};case"no-release":return{...s,state:"The latest release has no Mac app yet."};case"not-for-this-mac":return{...s,state:"The latest release has no app for this kind of Mac."};case"downloading":return{...s,state:`Version ${t.version} is available.`,detail:t.total>0?`Downloading it: ${eo(t.received)} of ${eo(t.total)}.`:"Downloading it.",notesUrl:t.notesUrl};case"ready":return{...s,state:`Version ${t.version} is available.`,detail:"Downloaded and checked.",install:!0,notesUrl:t.notesUrl};case"installing":return{...s,state:`Installing version ${t.version}…`,detail:"Agent Lookout quits and opens again as the new version.",canCheck:!1,notesUrl:t.notesUrl};case"cannot-install":return{...s,state:`Version ${t.version} is available.`,note:{title:"Agent Lookout cannot update itself here",detail:Mf[t.refusal],link:t.notesUrl}};case"failed":return t.step==="check"?{...s,state:"The last check did not work.",note:{title:"Agent Lookout could not check for updates",detail:`${ye(t.reason)}. Check again in a while.`,link:e.releasesUrl}}:{...s,state:t.version===null?"A newer version is available.":`Version ${t.version} is available.`,note:{title:`${t.version===null?"The new version":`Version ${t.version}`} could not be ${t.step==="install"?"installed":"downloaded"}`,detail:`${ye(t.reason)}. Check again to try once more.`,link:t.notesUrl??e.releasesUrl}}}}const xh=[{value:"off",label:"Off"},{value:"on",label:"On"}],to="Check for updates automatically",no="rounded-bar underline decoration-rule-strong underline-offset-2 transition-colors duration-120 hover:text-ink";function gh(){const{reading:e,pressed:t,check:s,install:o,setAutomatic:r}=ch(),a=Yt(),i=g.useRef(null);g.useEffect(()=>{const c=()=>{window.location.hash===la&&i.current?.scrollIntoView({block:"nearest"})};return c(),window.addEventListener("hashchange",c),()=>window.removeEventListener("hashchange",c)},[]);const l=e===null||e==="unknown"?null:e,d=l===null?null:ph(l);return n.jsx(W,{ref:i,title:"Updates","data-part":"updates",children:n.jsxs("div",{className:"px-6 pb-6",children:[n.jsxs("div",{className:"flex min-h-button flex-wrap items-center gap-x-3 gap-y-2",children:[n.jsx("p",{"data-part":"state","aria-live":"polite",className:"text-body font-medium text-ink",children:e==="unknown"?"Whether a newer version is out could not be read.":d?.state}),d!==null&&(d.install?n.jsx(J,{size:"sm",onClick:o,disabled:t!==null,children:"Install and Restart"}):n.jsx(J,{size:"sm",onClick:s,disabled:!d.canCheck||t!==null,children:"Check for Updates…"}))]}),d!==null&&(d.detail!==null||d.notesUrl!==null)&&n.jsxs("p",{"data-part":"found",className:"mt-1 text-body text-ink-secondary",children:[d.detail,d.detail!==null&&d.notesUrl!==null&&" ",d.notesUrl!==null&&n.jsx("a",{href:d.notesUrl,target:"_blank",rel:"noreferrer",className:no,children:"Release notes"})]}),d?.note&&n.jsx(U,{title:d.note.title,className:"mt-3",children:n.jsxs("p",{children:[d.note.detail," ",n.jsx("a",{href:d.note.link,target:"_blank",rel:"noreferrer",className:no,children:"Release page"})]})}),l!==null&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"mt-3 flex items-center justify-between gap-6 border-b border-hairline py-2",children:[n.jsx("span",{"aria-hidden":!0,className:"text-body text-ink",children:to}),n.jsx(Oe,{label:to,value:l.automatic?"on":"off",onValueChange:c=>r(c==="on"),options:xh})]}),n.jsxs(Ne,{children:[n.jsxs(B,{label:"Version",mono:!0,children:["v",l.version]}),n.jsx(B,{label:"Last checked",children:n.jsx("span",{className:"tabular-nums",children:hh(l,a)})})]})]}),n.jsx("p",{className:"mt-3 text-body text-ink-secondary",children:"Agent Lookout asks GitHub whether a newer version has been released when you press Check for Updates…, and about once a day while Check for updates automatically is on. It sends nothing about your sessions: GitHub sees the app's version number and your IP address, as with any web request."}),n.jsx("p",{className:"mt-2 text-body text-ink-secondary",children:"A newer version is downloaded and checked first, and installed only when you press Install and Restart. To update itself, Agent Lookout must be in a folder it can change, such as Applications."})]})})}function wh(){El()}function bh(){return{...g.useSyncExternalStore(qo,dt),turnOn:wh,turnOff:Ml,chooseEvent:Tl}}const yh=5e3;function so(e){const[t,s]=g.useState(null);return g.useEffect(()=>{let o=!0;const r=()=>{e().then(i=>{o&&s({status:i??"unknown",readAt:Date.now()})})};r();const a=setInterval(r,yh);return()=>{o=!1,clearInterval(a)}},[e]),t}const ma=4e3;function fa(e){const t=Math.round(e/1e3),s=(o,r)=>`${o} ${r}${o===1?"":"s"}`;return t>=3600&&t%3600===0?s(t/3600,"hour"):t>=60&&t%60===0?s(t/60,"minute"):s(t,"second")}function kh(e){return e.length<=1?e.join(""):`${e.slice(0,-1).join(", ")} or ${e[e.length-1]}`}function jh(e,t){switch(e){case"needs-you":return t===0?"starts waiting":`has waited ${fa(t)}`;case"finished":return"finishes";case"failed":return"fails";case"ended":return"ends"}}function ha(e,t,s,o){return s.length===1&&s[0]==="needs-you"?o===0?`${e} go to ${t} as soon as a session waits.`:`${e} go to ${t} after a wait of ${fa(o)}.`:`${e} go to ${t} when a session ${kh(s.map(r=>jh(r,o)))}.`}async function Nh(){try{const e=await re("/api/email",{signal:AbortSignal.timeout(ma)});return e.ok?hc(await e.json()):null}catch{return null}}function vh(e,t){return!e.on||e.to===null||e.events===null||e.afterMs===null?e.problem===null?{state:"Email is off.",asking:null,title:null,detail:"Set AGENT_LOOKOUT_EMAIL_TO and AGENT_LOOKOUT_SMTP_URL to turn it on."}:{state:"Email is off.",asking:null,title:"Email is not set up correctly",detail:`${e.problem} Correct it and start Agent Lookout again.`}:{...{state:ha("Emails",e.to,e.events,e.afterMs),asking:e.asking?"Emails for a wait say what the session is asking.":"Emails leave out what a waiting session is asking."},...Sh(e,t)}}function Sh(e,t){const{last:s,limitedUntil:o}=e;if(o!==null){const r=se(o,t);return s!==null&&!s.sent?{title:"The last email could not be sent",detail:`${ye(s.reason)}. No more will be tried until ${r}, as ${Ot} were tried in the last hour.`}:{title:"Emails are held back",detail:`${Ot} emails were tried in the last hour, the most it tries. The next can go at ${r}.`}}return s===null?{title:null,detail:null}:s.sent?{title:null,detail:`Last sent at ${se(s.at,t)}.`}:{title:"The last email could not be sent",detail:`${ye(s.reason)}.`}}async function Ah(){try{const e=await re("/api/webhook",{signal:AbortSignal.timeout(ma)});return e.ok?pc(await e.json()):null}catch{return null}}function Eh(e,t){return!e.on||e.host===null||e.events===null||e.afterMs===null?e.problem===null?{state:"The webhook is off.",asking:null,title:null,detail:"Set AGENT_LOOKOUT_WEBHOOK_URL to turn it on."}:{state:"The webhook is off.",asking:null,title:"The webhook is not set up correctly",detail:`${e.problem} Correct it and start Agent Lookout again.`}:{...{state:ha("Posts",e.host,e.events,e.afterMs),asking:e.asking?"Posts for a wait say what the session is asking.":"Posts leave out what a waiting session is asking."},...Mh(e,t)}}function Mh(e,t){const{last:s,limitedUntil:o}=e;if(o!==null){const r=se(o,t);return s!==null&&!s.sent?{title:"The last post failed",detail:`${ye(s.reason)}. No more will be tried until ${r}, as ${Ot} were tried in the last hour.`}:{title:"Posts are held back",detail:`${Ot} posts were tried in the last hour, the most it tries. The next can go at ${r}.`}}return s===null?{title:null,detail:null}:s.sent?{title:null,detail:`Last posted at ${se(s.at,t)}.`}:{title:"The last post failed",detail:`${ye(s.reason)}.`}}const Th=[{value:"dark",label:"Night",name:"Dark theme"},{value:"light",label:"Day",name:"Light theme"},{value:"system",label:"System",name:"Follow the computer's setting"}],Ih=[{value:"off",label:"Off"},{value:"on",label:"On"}];function Ch({events:e,chooseEvent:t}){return n.jsx("ul",{"data-part":"events","aria-label":"What sends a notification",className:"mt-3 flex flex-col",children:Be.map(s=>n.jsxs("li",{className:"flex items-center justify-between gap-6 border-b border-hairline py-2 last:border-b-0",children:[n.jsx("span",{"aria-hidden":!0,className:"text-body text-ink",children:yn[s]}),n.jsx(Oe,{label:yn[s],value:e.includes(s)?"on":"off",onValueChange:o=>t(s,o==="on"),options:Ih})]},s))})}function Lh(){const{on:e,permission:t,events:s,turnOn:o,turnOff:r,chooseEvent:a}=bh();return n.jsx(W,{title:"Notifications",children:n.jsxs("div",{className:"px-6 pb-6",children:[n.jsxs("div",{className:"flex min-h-button flex-wrap items-center gap-x-3 gap-y-2",children:[n.jsx("p",{"data-part":"state","aria-live":"polite",className:"text-body font-medium text-ink",children:e?"Notifications are on.":"Notifications are off."}),t!=="unsupported"&&n.jsx(J,{size:"sm",onClick:e?r:o,children:e?"Turn off notifications":"Turn on notifications"})]}),e&&n.jsx(Ch,{events:s,chooseEvent:a}),e&&s.length===0&&n.jsx("p",{className:"mt-3 text-body text-ink-secondary",children:"No event is switched on, so none is sent."}),t==="denied"&&n.jsx(U,{title:"Notifications are blocked",className:"mt-3",children:n.jsx("p",{children:"Your browser is blocking notifications from this address. Allow them for this address in the browser's site settings, then turn them on here."})}),t==="unsupported"&&n.jsx(U,{title:"This browser cannot show notifications",className:"mt-3",children:n.jsx("p",{children:"Open Agent Lookout in a browser that can, then turn them on here."})}),n.jsx("p",{className:"mt-3 text-body text-ink-secondary",children:"With Needs you on, a notification appears each time a session starts waiting for you. It names the session and the reason, and is cleared when the session moves on."}),!e&&n.jsx("p",{className:"mt-2 text-body text-ink-secondary",children:"Once they are on, you can also be told when a session finishes or fails, or ends without saying whether it finished, as when its process stops. Those name the session and what happened, and stay until you clear them."}),n.jsxs("p",{className:"mt-2 text-body text-ink-secondary",children:["On a Mac they also arrive when no dashboard tab is open, for as long as Agent Lookout keeps running, and those stay until you clear them. What each agent can report, under"," ",n.jsx("a",{href:"#sources",className:"rounded-bar underline decoration-rule-strong underline-offset-2 transition-colors duration-120 hover:text-ink",children:"Sources"}),", says which agents can be seen waiting."]})]})})}function oo(e,t,s){return e===null?null:e.status==="unknown"?{state:t,asking:null,title:null,detail:null}:s(e.status,e.readAt)}function ro({title:e,words:t}){return n.jsx(W,{title:e,children:n.jsxs("div",{className:"px-6 pb-6",children:[n.jsx("p",{"data-part":"state","aria-live":"polite",className:"text-body font-medium text-ink",children:t?.state}),t?.asking&&n.jsx("p",{"data-part":"asking",className:"mt-3 text-body text-ink-secondary",children:t.asking}),t?.detail&&(t.title?n.jsx(U,{title:t.title,className:"mt-3",children:n.jsx("p",{children:n.jsx(ue,{children:t.detail})})}):n.jsx("p",{className:"mt-3 text-body text-ink-secondary",children:n.jsx(ue,{children:t.detail})}))]})})}function Oh(e,t){return e&&t?"Sent only in the emails and posts you set up":e?"Sent only in the emails you set up":t?"Sent only in the webhook posts you set up":"Agent Lookout sends it nowhere"}function $h({history:e=null,now:t,onHistoryCleared:s,inApp:o=qn()}={}){const{preference:r,setPreference:a}=ra(),i=Yt(),l=so(Nh),d=so(Ah),c=typeof l?.status=="object"&&l.status.on,u=typeof d?.status=="object"&&d.status.on;return n.jsxs("div",{"data-slot":"settings-view",className:"grid grid-cols-12 items-start gap-4 max-wide:flex max-wide:flex-col",children:[n.jsxs("div",{className:"col-span-8 flex min-w-0 flex-col gap-4 max-wide:w-full",children:[n.jsx(W,{title:"Theme",children:n.jsxs("div",{className:"px-6 pb-6",children:[n.jsx(Oe,{label:"Theme",value:r,onValueChange:a,options:Th}),n.jsx("p",{className:"mt-3 text-body text-ink-secondary",children:"Night is the default. System follows the setting on your computer, and changes when it does."})]})}),n.jsx(Lh,{}),n.jsx(Hf,{history:e,now:t??i,onCleared:s}),o&&n.jsx(Xf,{}),o&&n.jsx(gh,{})]}),n.jsxs("div",{className:"col-span-4 flex min-w-0 flex-col gap-4 max-wide:w-full",children:[n.jsx(ro,{title:"Email",words:oo(l,"Whether email is set up could not be read.",vh)}),n.jsx(ro,{title:"Webhook",words:oo(d,"Whether the webhook is set up could not be read.",Eh)}),n.jsx(W,{title:"This copy",children:n.jsxs(Ne,{className:"px-6 pb-3",children:[n.jsxs(B,{label:"Version",mono:!0,children:["v","0.2.3"]}),n.jsx(B,{label:"Your data",children:Oh(c,u)})]})})]})]})}function _h(e){return e.capabilities!==void 0}function Rh({cell:e}){return e.level==="yes"?n.jsx("span",{"data-part":"capability","data-level":"yes",className:"text-ink-secondary",children:hn.yes}):n.jsx(Z,{content:e.reason,children:n.jsxs("span",{"data-part":"capability","data-level":e.level,tabIndex:0,className:"rounded-bar font-medium text-ink",children:[hn[e.level],n.jsxs("span",{className:"sr-only",children:[": ",e.reason]})]})})}function Wh({sources:e}){const t="pr-2 pb-2 align-bottom text-caption font-medium text-ink-secondary";return n.jsxs("table",{"data-part":"table",className:"mt-3 w-full table-fixed border-collapse text-left",children:[n.jsxs("colgroup",{children:[n.jsx("col",{className:"w-28"}),Qe.map(s=>n.jsx("col",{},s))]}),n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-hairline",children:[n.jsx("th",{scope:"col",className:t,children:"Agent"}),Qe.map(s=>n.jsx("th",{scope:"col",className:t,children:Ho[s]},s))]})}),n.jsx("tbody",{children:e.map(s=>n.jsxs("tr",{"data-source":s.id,className:"border-b border-hairline last:border-b-0",children:[n.jsx("th",{scope:"row",className:"py-2.5 pr-2 text-body font-semibold text-ink",children:s.label}),Qe.map(o=>n.jsx("td",{className:"py-2.5 pr-2 text-body",children:n.jsx(Rh,{cell:s.capabilities[o]})},o))]},s.id))})]})}function Ph({sources:e}){return n.jsx("div",{"data-part":"blocks",className:"mt-3 flex flex-col gap-4",children:e.map(t=>n.jsxs("div",{"data-source":t.id,children:[n.jsx("h3",{className:"text-row font-semibold text-ink",children:t.label}),n.jsx(Ne,{className:"mt-1",children:Qe.map(s=>{const o=t.capabilities[s];return n.jsx(B,{label:Ho[s],note:o.level==="yes"?void 0:o.reason,children:n.jsx("span",{"data-part":"capability","data-level":o.level,className:o.level==="yes"?"font-normal text-ink-secondary":void 0,children:hn[o.level]})},s)})})]},t.id))})}function Fh({sources:e}){const t=Vt(),s=e.filter(_h);return s.length===0?null:n.jsx(W,{"data-slot":"capabilities",title:"What each agent can report",children:n.jsxs("div",{className:"px-6 pb-3",children:[n.jsxs("p",{"data-part":"lead",className:"text-body text-ink-secondary",children:["A signal marked No never appears for that agent, so not seeing it is not good news.",!t&&" Point at No or Partly, or move to it with Tab, to read why."]}),t?n.jsx(Ph,{sources:s}):n.jsx(Wh,{sources:s})]})})}function zh(e){return e.includes("/")||e.startsWith("~")||/ --?\w/.test(e)}function Dh(e){return/^\d+$/.test(e)}function Uh({source:e,sessions:t,now:s,stalled:o}){const r=Rc(e,o),a=t.filter(i=>i.source===e.id).length;return n.jsx(W,{"data-slot":"source","data-state":e.state,"data-stalled":o,title:e.label,aside:n.jsx("span",{"data-part":"state",className:"text-body font-medium text-ink-secondary",children:r.state}),children:n.jsxs("div",{className:"px-6 pb-3",children:[e.detail&&n.jsx("p",{"data-part":"detail",className:"text-body wrap-break-word text-ink-secondary",children:n.jsx(ue,{children:e.detail})}),n.jsxs(Ne,{className:"mt-2",children:[e.watching?.map((i,l)=>n.jsx(B,{label:i.label,mono:zh(i.value),children:n.jsx("span",{"data-part":"watching",className:j("wrap-anywhere",Dh(i.value)&&"tabular-nums"),children:i.value})},`${l}-${i.label}`)),n.jsx(B,{label:"Sessions found",children:n.jsx("span",{className:"tabular-nums",children:a})}),n.jsx(B,{label:"Last checked",children:o?n.jsx("span",{className:"tabular-nums",children:oe(e.checkedAt)}):n.jsx(Z,{content:Pn(e.checkedAt),mono:!0,align:"end",children:n.jsx("span",{className:"tabular-nums",children:Wn(s-e.checkedAt)})})})]})]})})}function ao({children:e}){return n.jsx(W,{title:"Sources",children:n.jsx("div",{className:"px-6 pb-6",children:e})})}function Hh({state:e,now:t}){const{snapshot:s,phase:o}=e,r=o==="stalled";let a;return s?a=s.sources.length>0?s.sources.map(i=>n.jsx(Uh,{source:i,sessions:s.sessions,now:t,stalled:r},i.id)):n.jsx(ao,{children:n.jsx(U,{title:"No sources are set up",children:n.jsx("p",{children:"Agent Lookout is running but is not watching any agent tool."})})}):o==="unreachable"?a=n.jsx(ao,{children:n.jsx(U,{tone:"error",title:hr(e.problemKind),children:n.jsx(pr,{kind:e.problemKind})})}):a=n.jsx(W,{title:"Sources",children:n.jsx(me,{label:"Waiting for the first answer"})}),n.jsxs("div",{"data-slot":"sources-view",className:"grid grid-cols-3 items-start gap-4 max-wide:flex max-wide:flex-col",children:[n.jsxs("div",{className:"col-span-2 flex min-w-0 flex-col gap-4 max-wide:w-full",children:[r&&e.lastOkAt!==null&&n.jsx(U,{tone:"error",title:"Agent Lookout has stopped updating",children:n.jsxs("p",{children:["What follows is from"," ",n.jsx("span",{className:"tabular-nums",children:oe(e.lastOkAt)}),". Check that it is still running in your terminal."]})}),a,s&&n.jsx(Fh,{sources:s.sources})]}),n.jsx(W,{title:"About sources",className:"col-span-1 max-wide:w-full",children:n.jsxs("div",{className:"flex flex-col gap-2 px-6 pb-6 text-body text-ink-secondary",children:[n.jsx("p",{children:"A source is an agent tool Agent Lookout finds sessions in. It only reads: it never starts, stops or changes a session."}),n.jsx("p",{children:"Status files are how any other agent appears: it writes a small file for each of its sessions in a folder that Agent Lookout reads."}),n.jsx("p",{children:"Unless you set up email or a webhook, Agent Lookout itself sends nothing anywhere. A command listed under a source is that tool's own program, and may reach the tool's own servers, as it does whenever it runs."})]})})]})}class pa extends g.Component{state={error:null};static getDerivedStateFromError(t){return{error:t instanceof Error?t:new Error(String(t))}}componentDidCatch(t,s){console.error("Agent Lookout could not draw the page.",t,s.componentStack)}render(){const{error:t}=this.state;return t?n.jsxs("section",{"data-slot":"page-error","aria-label":"Page problem",className:"glass-card mx-auto mt-[6vh] w-full max-w-[620px] p-5",children:[n.jsx(U,{tone:"error",title:"Agent Lookout could not draw this page",action:n.jsx(J,{onClick:()=>this.setState({error:null}),children:"Try again"}),children:n.jsx("p",{children:"Something in the page itself went wrong. Your sessions are not affected: Agent Lookout only reads them. If trying again does not help, reload the page."})}),n.jsx(Ne,{className:"mt-3",children:n.jsx(B,{label:"What happened",mono:!0,children:t.message||t.name})})]}):this.props.children}}function Bh(e){return g.useSyncExternalStore(e.subscribe,e.getState)}function Gh(e){return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)}function Kh(){return document.hidden}function xa(){return g.useSyncExternalStore(Gh,Kh)}const ln="Agent Lookout";function Vh(e){g.useEffect(()=>(document.title=e>0?`(${e}) ${ln}`:ln,()=>{document.title=ln}),[e])}const ga="agent-lookout-last-looked";function Yh(){try{const e=Number(localStorage.getItem(ga));return Number.isSafeInteger(e)&&e>0?e:null}catch{return null}}function qh(e){try{localStorage.setItem(ga,String(e))}catch{}}function Jh(e,t,s){const o=xa(),r=Yt(),[a,i]=g.useState(!1),[l,d]=g.useState(()=>td(Yh())),c=nd(l,{now:r,visible:!o&&s,overview:t,lineInView:a,newestAt:e[0]?.at??null});c!==l&&d(c);const u=g.useRef(c);return g.useEffect(()=>{u.current=c}),g.useEffect(()=>{const m=()=>{const{away:p,overview:b,leftAt:w,since:h}=u.current,N=h??(!p&&b?Date.now():w);N!==null&&qh(N)},f=()=>{document.hidden&&m()};return document.addEventListener("visibilitychange",f),window.addEventListener("pagehide",m),()=>{document.removeEventListener("visibilitychange",f),window.removeEventListener("pagehide",m)}},[]),{since:c.since,onLineInView:i}}function Xh(e){const t=g.useEffectEvent(s=>{if(s.defaultPrevented||s.repeat||s.isComposing)return;const o=tf(s.target),r=sf(s,{mac:es(),typing:o});r!==null&&e(r)&&s.preventDefault()});g.useEffect(()=>{const s=o=>t(o);return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[])}function wa(e){return window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)}function Zh(){return Tf(window.location.hash)}function Qh(){return Lr(window.location.hash)}function ep(){return g.useSyncExternalStore(wa,Zh)}function tp(){return g.useSyncExternalStore(wa,Qh)}const np="agent-lookout-notifications";function sp(e){if(typeof e!="object"||e===null)return[];const{handedOver:t}=e;return Array.isArray(t)?t.filter(s=>typeof s=="string"):[]}function op(e){let t;try{t=new BroadcastChannel(np),t.addEventListener("message",s=>{const o=sp(s.data);o.length>0&&e(o)})}catch{t=null}return{handOver(s){if(!t||s.length===0)return;const o={handedOver:[...s]};try{t.postMessage(o)}catch{}},close(){t?.close(),t=null}}}function rp(e){return`agent-lookout:${e.id}`}function cn(e){try{e.close()}catch{}}function ap({host:e,isOn:t}){let s=js,o=null,r=null;const a=new Map,i=new Map;function l(c){const u=a.get(c);u&&(a.delete(c),cn(u.notification))}function d(c){const{session:u}=c;l(u.id);const m=i.get(u.id);m&&(i.delete(u.id),cn(m));let f;try{f=e.show({...md(c),tag:rp(u)})}catch{f=null}if(!f)return;const p=f;if(c.event!=="needs-you"){i.set(u.id,p),p.onClosed(()=>{i.get(u.id)===p&&i.delete(u.id)});return}a.set(u.id,{notification:p,source:u.source}),p.onClosed(()=>{a.get(u.id)?.notification===p&&a.delete(u.id)})}return{handle(c,u=null){if(!c)return;r=c,u!==null&&(o!==null&&o!==u&&(s=js),o=u);const m=fl(s,c);s=m.memory;for(const f of m.stopped)l(f);for(const[f,{source:p}]of a){const b=s.waits.get(p);b&&!b.has(f)&&l(f)}for(const f of m.changes)t(f.event)&&d(f)},closeAll(){const c=[...a.keys()],u=[...a.values()];a.clear();for(const{notification:m}of u)cn(m);return c},showAgain(c){if(!r)return;const u=new Set(c);for(const m of r.sessions)!u.has(m.id)||m.status!=="needs-you"||s.waits.get(m.source)?.has(m.id)&&(u.delete(m.id),t("needs-you")&&d({event:"needs-you",session:m}))}}}const dn=e=>$n().includes(e),io=()=>Bo($n());async function ip(){try{await re("/api/health",{keepalive:!0})}catch{}}function lp(e){g.useEffect(()=>{const t=ap({host:{show:c=>Cn().show(c)},isOn:dn}),s=()=>{const{snapshot:c,history:u}=e.getState();t.handle(c,u?.startedAt??null)};s();const o=e.subscribe(s);let r=io(),a=dn("needs-you");const i=qo(()=>{const c=io();c!==r&&ip(),r=c;const u=dn("needs-you");a&&!u&&t.closeAll(),a=u}),l=op(c=>t.showAgain(c)),d=()=>l.handOver(t.closeAll());return window.addEventListener("pagehide",d),()=>{o(),i(),window.removeEventListener("pagehide",d),d(),l.close()}},[e])}const cp=g.lazy(()=>ho(()=>import("./HistoryPanel-DMnhIoFB.js"),__vite__mapDeps([0,1,2,3])).then(e=>({default:e.HistoryPanel}))),dp=g.lazy(()=>ho(()=>import("./SessionPanel-BNm9wCzf.js"),__vite__mapDeps([4,1,2,3])).then(e=>({default:e.SessionPanel}))),up=["needsYou","working","idle"];function mp(){const e=xa(),t=(s,o)=>n.jsxs("div",{"aria-hidden":!0,"data-slot":s,"data-drift":e?"paused":void 0,className:o,children:[n.jsx("i",{className:"ground-main"}),n.jsx("i",{className:"ground-deep"}),n.jsx("i",{className:"ground-far"})]});return n.jsxs(n.Fragment,{children:[t("ground","ground"),t("ground-above","ground bottom-auto z-10 h-window bg-fixed")]})}function fp({store:e}){const[t]=g.useState(()=>e??Nc({beat:Rl})),s=Bh(t);lp(t);const o=Yt(),r=ep(),a=tp(),[i,l]=g.useState(null),[d,c]=g.useState(!1),[u,m]=g.useState(!1),f=g.useRef(null),p=g.useRef(r),b=Jh(s.events,r==="overview",s.snapshot!==null),w=Ad(s.snapshot?.sessions);Vh(w);const h=s.snapshot?w:null;g.useEffect(()=>{p.current!==r&&(p.current=r,f.current?.focus({preventScroll:!0}),window.scrollTo({top:0}))},[r]);const N=Um(f,r);Xh(v=>{if(i!==null||u||a!==null)return!1;if(v==="search")c(k=>!k);else{if(d)return!1;m(!0)}return!0});const y=s.snapshot?"dashboard":s.phase==="unreachable"?"problem":"loading";return n.jsxs(ka,{reducedMotion:"user",children:[n.jsx(mp,{}),n.jsxs("div",{"data-slot":"frame",className:"flex min-h-screen gap-window p-window",children:[n.jsx(Of,{current:r,needsYou:h}),n.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-4 pb-7",children:[n.jsx(lf,{phase:s.phase,snapshot:s.snapshot,lastOkAt:s.lastOkAt,now:o,onSearch:()=>c(!0)}),n.jsx("main",{ref:f,tabIndex:-1,"aria-label":If(r),"data-view":r,className:"flex-1 outline-none",children:n.jsx(pa,{children:r==="sources"?n.jsx(Hh,{state:s,now:o}):r==="settings"?n.jsx($h,{history:s.history,now:o,onHistoryCleared:t.refresh}):n.jsx(ja,{mode:"wait",initial:!1,children:n.jsx(Na.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.18,ease:"easeOut"},children:n.jsx(Hm,{state:s,now:o,onRetry:t.refresh,onOpenHistory:l,newSince:b.since,onNewLineInView:b.onLineInView})},y)})},r)})]})]}),n.jsxs(g.Suspense,{fallback:null,children:[up.map(v=>n.jsx(cp,{metric:v,open:i===v,onOpenChange:k=>l(k?v:null),state:s,now:o},v)),n.jsx(dp,{sessionId:a,onClose:nu,state:s,now:o})]}),n.jsx(xf,{open:d,onOpenChange:c,state:s,now:o,onChoose:N,onShortcuts:()=>m(!0)}),n.jsx(jf,{open:u,onOpenChange:m})]})}Dd();const ba=document.getElementById("root");if(!ba)throw new Error("index.html has no #root element to render into.");ya.createRoot(ba).render(n.jsx(g.StrictMode,{children:n.jsx(pa,{children:n.jsx(fp,{})})}));export{Hr as A,Oc as B,U as C,wf as D,gr as E,Ne as F,Au as G,Ms as H,V as I,lt as J,zn as K,me as L,Dt as M,pe as N,jp as O,z as P,X as Q,$d as R,Oe as S,gm as T,J as U,oe as a,yp as b,j as c,Pl as d,bp as e,H as f,wp as g,fe as h,ft as i,Ad as j,ye as k,Bt as l,zl as m,Ft as n,Jc as o,Xc as p,Nr as q,kp as r,gp as s,Xo as t,Gt as u,B as v,rl as w,Fn as x,lr as y,Kn as z};